diff --git a/types/transform.go b/types/transform.go index 103e753..d89e057 100644 --- a/types/transform.go +++ b/types/transform.go @@ -63,6 +63,23 @@ func (t *Transform) ParseAsWriteTransfer() (*WriteTransfer, error) { return &jsonRes.WriteTransfer, nil } +func (t *Transform) IsWriteAccount() bool { + return strings.Contains(string(*t), "WriteAccount") +} + +func (t *Transform) ParseAsWriteAccount() (key.AccountHash, error) { + type RawWriteAccountTransform struct { + key.AccountHash `json:"WriteAccount"` + } + + jsonRes := RawWriteAccountTransform{} + if err := json.Unmarshal(*t, &jsonRes); err != nil { + return key.AccountHash{}, err + } + + return jsonRes.AccountHash, nil +} + func (t *Transform) IsWriteContract() bool { return bytes.Equal(*t, []byte("\"WriteContract\"")) }