[#750] adm: Drop deprecated rpcclient.TransferTarget
Some checks failed
DCO action / DCO (pull_request) Successful in 2m5s
Build / Build Components (1.20) (pull_request) Successful in 3m50s
Build / Build Components (1.21) (pull_request) Successful in 3m53s
Vulncheck / Vulncheck (pull_request) Successful in 3m42s
Tests and linters / Tests with -race (pull_request) Failing after 4m41s
Tests and linters / Tests (1.20) (pull_request) Successful in 6m4s
Tests and linters / Staticcheck (pull_request) Successful in 6m31s
Tests and linters / Tests (1.21) (pull_request) Successful in 6m46s
Tests and linters / Lint (pull_request) Successful in 7m21s

We do not use `nep17` wrapper, because transfers of different tokens are
possible in a single transaction.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-10-24 15:20:38 +03:00
parent 017df2542a
commit 693d023fdf

View file

@ -7,13 +7,13 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/native"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/actor"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/gas"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/neo"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nep17"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
scContext "github.com/nspcc-dev/neo-go/pkg/smartcontract/context"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
"github.com/nspcc-dev/neo-go/pkg/wallet"
@ -36,11 +36,11 @@ func (c *initializeContext) transferFunds() error {
return err
}
var transfers []rpcclient.TransferTarget
var transfers []transferTarget
for _, acc := range c.Accounts {
to := acc.Contract.ScriptHash()
transfers = append(transfers,
rpcclient.TransferTarget{
transferTarget{
Token: gas.Hash,
Address: to,
Amount: initialAlphabetGASAmount,
@ -50,12 +50,12 @@ func (c *initializeContext) transferFunds() error {
// It is convenient to have all funds at the committee account.
transfers = append(transfers,
rpcclient.TransferTarget{
transferTarget{
Token: gas.Hash,
Address: c.CommitteeAcc.Contract.ScriptHash(),
Amount: (gasInitialTotalSupply - initialAlphabetGASAmount*int64(len(c.Wallets))) / 2,
},
rpcclient.TransferTarget{
transferTarget{
Token: neo.Hash,
Address: c.CommitteeAcc.Contract.ScriptHash(),
Amount: native.NEOTotalSupply,
@ -151,7 +151,7 @@ func (c *initializeContext) transferGASToProxy() error {
return err
}
tx, err := createNEP17MultiTransferTx(c.Client, c.CommitteeAcc, []rpcclient.TransferTarget{{
tx, err := createNEP17MultiTransferTx(c.Client, c.CommitteeAcc, []transferTarget{{
Token: gas.Hash,
Address: proxyCs.Hash,
Amount: initialProxyGASAmount,
@ -167,8 +167,14 @@ func (c *initializeContext) transferGASToProxy() error {
return c.awaitTx()
}
func createNEP17MultiTransferTx(c Client, acc *wallet.Account,
recipients []rpcclient.TransferTarget) (*transaction.Transaction, error) {
type transferTarget struct {
Token util.Uint160
Address util.Uint160
Amount int64
Data any
}
func createNEP17MultiTransferTx(c Client, acc *wallet.Account, recipients []transferTarget) (*transaction.Transaction, error) {
from := acc.Contract.ScriptHash()
w := io.NewBufBinWriter()