From b2524a3ba918ff81ff89eb0788d9739084045c35 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 19 Aug 2022 16:45:16 +0300 Subject: [PATCH] actor: add Sender helper method --- pkg/rpcclient/actor/actor.go | 6 ++++++ pkg/rpcclient/actor/actor_test.go | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/pkg/rpcclient/actor/actor.go b/pkg/rpcclient/actor/actor.go index abf79530f..07b436227 100644 --- a/pkg/rpcclient/actor/actor.go +++ b/pkg/rpcclient/actor/actor.go @@ -202,3 +202,9 @@ func (a *Actor) SendTunedRun(script []byte, attrs []transaction.Attribute, txHoo func (a *Actor) SendUncheckedRun(script []byte, sysfee int64, attrs []transaction.Attribute, txHook TransactionModifier) (util.Uint256, uint32, error) { return a.sendWrapper(a.MakeUncheckedRun(script, sysfee, attrs, txHook)) } + +// Sender return the sender address that will be used in transactions created +// by Actor. +func (a *Actor) Sender() util.Uint160 { + return a.txSigners[0].Account +} diff --git a/pkg/rpcclient/actor/actor_test.go b/pkg/rpcclient/actor/actor_test.go index 32e9eca00..c87b127bd 100644 --- a/pkg/rpcclient/actor/actor_test.go +++ b/pkg/rpcclient/actor/actor_test.go @@ -7,6 +7,7 @@ import ( "github.com/google/uuid" "github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/core/transaction" + "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/neorpc/result" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/util" @@ -259,3 +260,13 @@ func TestSenders(t *testing.T) { require.Equal(t, client.hash, h) require.Equal(t, uint32(8), vub) } + +func TestSender(t *testing.T) { + client, acc := testRPCAndAccount(t) + a, err := NewSimple(client, acc) + require.NoError(t, err) + + addr, err := address.StringToUint160(acc.Address) + require.NoError(t, err) + require.Equal(t, addr, a.Sender()) +}