[#1711] adm: Drop deprecated neo-go calls

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-08-26 14:03:55 +03:00 committed by fyrchik
parent 6d277a57aa
commit a99474c40e

View file

@ -6,7 +6,6 @@ import (
"encoding/hex" "encoding/hex"
"errors" "errors"
"fmt" "fmt"
"math/big"
"math/rand" "math/rand"
"net" "net"
"net/url" "net/url"
@ -25,10 +24,10 @@ import (
"github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
"github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/rpcclient"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/rpcclient/actor"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nep17"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate"
"github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neo-go/pkg/wallet"
netutil "github.com/nspcc-dev/neofs-node/pkg/network" netutil "github.com/nspcc-dev/neofs-node/pkg/network"
@ -322,23 +321,17 @@ func depositGas(cmd *cobra.Command, acc *wallet.Account, network string) {
sideClient := initClient(n3config[network].MorphRPC) sideClient := initClient(n3config[network].MorphRPC)
balanceHash, _ := util.Uint160DecodeStringLE(n3config[network].BalanceContract) balanceHash, _ := util.Uint160DecodeStringLE(n3config[network].BalanceContract)
res, err := sideClient.InvokeFunction(balanceHash, "balanceOf", []smartcontract.Parameter{{ sideActor, err := actor.NewSimple(sideClient, acc)
Type: smartcontract.Hash160Type, if err != nil {
Value: acc.Contract.ScriptHash(), fatalOnErr(fmt.Errorf("creating actor over side chain client: %w", err))
}}, nil)
fatalOnErr(err)
if res.State != vmstate.Halt.String() {
fatalOnErr(fmt.Errorf("invalid response from balance contract: %s", res.FaultException))
} }
var balance *big.Int sideGas := nep17.NewReader(sideActor, balanceHash)
if len(res.Stack) != 0 { accSH := acc.Contract.ScriptHash()
balance, _ = res.Stack[0].TryInteger()
}
if balance == nil { balance, err := sideGas.BalanceOf(accSH)
fatalOnErr(errors.New("invalid response from balance contract")) if err != nil {
fatalOnErr(fmt.Errorf("side chain balance: %w", err))
} }
ok := getConfirmation(false, fmt.Sprintf("Current NeoFS balance is %s, make a deposit? y/[n]: ", ok := getConfirmation(false, fmt.Sprintf("Current NeoFS balance is %s, make a deposit? y/[n]: ",
@ -359,11 +352,17 @@ func depositGas(cmd *cobra.Command, acc *wallet.Account, network string) {
gasHash, err := mainClient.GetNativeContractHash(nativenames.Gas) gasHash, err := mainClient.GetNativeContractHash(nativenames.Gas)
fatalOnErr(err) fatalOnErr(err)
tx, err := mainClient.CreateNEP17TransferTx(acc, neofsHash, gasHash, amount.Int64(), 0, nil, nil) mainActor, err := actor.NewSimple(mainClient, acc)
fatalOnErr(err) if err != nil {
fatalOnErr(fmt.Errorf("creating actor over main chain client: %w", err))
}
txHash, err := mainClient.SignAndPushTx(tx, acc, nil) mainGas := nep17.New(mainActor, gasHash)
fatalOnErr(err)
txHash, _, err := mainGas.Transfer(accSH, neofsHash, amount, nil)
if err != nil {
fatalOnErr(fmt.Errorf("sending TX to the NeoFS contract: %w", err))
}
cmd.Print("Waiting for transactions to persist.") cmd.Print("Waiting for transactions to persist.")
tick := time.NewTicker(time.Second / 2) tick := time.NewTicker(time.Second / 2)