From 1ebf89687d68d77982c43ada3f346570e294c26e Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 28 Jul 2022 19:22:32 +0300 Subject: [PATCH] [#1637] go.mod: Update neo-go to v0.99.1 Signed-off-by: Evgenii Stratonikov --- .../internal/modules/morph/initialize.go | 6 ++-- .../modules/morph/initialize_deploy.go | 4 +-- .../internal/modules/morph/initialize_nns.go | 4 +-- .../modules/morph/initialize_register.go | 8 ++--- .../modules/morph/initialize_transfer.go | 18 +++++------ .../internal/modules/morph/local_client.go | 10 +++--- .../internal/modules/morph/n3client.go | 10 +++--- .../internal/modules/morph/notary.go | 4 +-- .../internal/modules/morph/subnet.go | 6 ++-- .../internal/modules/storagecfg/root.go | 8 ++--- go.mod | 4 +-- go.sum | 6 ++-- pkg/morph/client/client.go | 10 +++--- pkg/morph/client/constructor.go | 14 ++++----- pkg/morph/client/nns.go | 8 ++--- pkg/morph/event/balance/lock.go | 4 +-- pkg/morph/event/balance/lock_test.go | 5 ++- pkg/morph/event/container/delete.go | 4 +-- pkg/morph/event/container/eacl.go | 4 +-- pkg/morph/event/container/eacl_test.go | 5 ++- pkg/morph/event/container/estimates.go | 6 ++-- pkg/morph/event/container/put.go | 4 +-- pkg/morph/event/listener.go | 11 ++++--- pkg/morph/event/neofs/bind.go | 4 +-- pkg/morph/event/neofs/bind_test.go | 5 ++- pkg/morph/event/neofs/cheque.go | 4 +-- pkg/morph/event/neofs/config.go | 4 +-- pkg/morph/event/neofs/deposit.go | 4 +-- pkg/morph/event/neofs/unbind.go | 4 +-- pkg/morph/event/neofs/withdraw.go | 4 +-- pkg/morph/event/netmap/add_peer.go | 4 +-- pkg/morph/event/netmap/add_peer_test.go | 5 ++- pkg/morph/event/netmap/epoch.go | 4 +-- pkg/morph/event/netmap/update_peer.go | 4 +-- pkg/morph/event/parsers.go | 4 +-- pkg/morph/event/reputation/put.go | 4 +-- pkg/morph/event/reputation/put_test.go | 5 ++- pkg/morph/event/rolemanagement/designate.go | 4 +-- .../event/rolemanagement/designate_test.go | 5 ++- pkg/morph/event/subnet/delete.go | 4 +-- pkg/morph/event/subnet/put.go | 4 +-- pkg/morph/event/subnet/remove_node.go | 4 +-- pkg/morph/event/subnet/remove_node_test.go | 5 ++- pkg/morph/event/utils.go | 4 +-- pkg/morph/subscriber/subscriber.go | 31 ++++++++++--------- 45 files changed, 140 insertions(+), 143 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize.go b/cmd/neofs-adm/internal/modules/morph/initialize.go index 9ffd2853d..1af3c1d86 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize.go @@ -11,7 +11,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" - "github.com/nspcc-dev/neo-go/pkg/rpc/client" + "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/vmstate" @@ -363,7 +363,7 @@ loop: // If sysFee is -1, it is calculated automatically. If tryGroup is false, // global scope is used for the signer (useful when working with native contracts). func (c *initializeContext) sendCommitteeTx(script []byte, sysFee int64, tryGroup bool) error { - tx, err := c.Client.CreateTxFromScript(script, c.CommitteeAcc, sysFee, 0, []client.SignerAccount{{ + tx, err := c.Client.CreateTxFromScript(script, c.CommitteeAcc, sysFee, 0, []rpcclient.SignerAccount{{ Signer: c.getSigner(tryGroup), Account: c.CommitteeAcc, }}) @@ -377,7 +377,7 @@ func (c *initializeContext) sendCommitteeTx(script []byte, sysFee int64, tryGrou // sendSingleTx creates transaction signed by a simple account and pushes in onto the chain. // It neither waits until tx persists nor checks the execution result. func (c *initializeContext) sendSingleTx(script []byte, sysFee int64, acc *wallet.Account) error { - tx, err := c.Client.CreateTxFromScript(script, acc, sysFee, 0, []client.SignerAccount{{ + tx, err := c.Client.CreateTxFromScript(script, acc, sysFee, 0, []rpcclient.SignerAccount{{ Signer: transaction.Signer{ Account: acc.Contract.ScriptHash(), Scopes: transaction.CalledByEntry, diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go index 0aba7dfec..8033419e3 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go @@ -17,7 +17,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/transaction" io2 "github.com/nspcc-dev/neo-go/pkg/io" - "github.com/nspcc-dev/neo-go/pkg/rpc/client" + "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" @@ -133,7 +133,7 @@ func (c *initializeContext) deployNNS(method string) error { return fmt.Errorf("can't deploy NNS contract: %s", res.FaultException) } - tx, err := c.Client.CreateTxFromScript(res.Script, c.CommitteeAcc, res.GasConsumed, 0, []client.SignerAccount{{ + tx, err := c.Client.CreateTxFromScript(res.Script, c.CommitteeAcc, res.GasConsumed, 0, []rpcclient.SignerAccount{{ Signer: signer, Account: c.CommitteeAcc, }}) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go index 63e94d063..981850ad7 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go @@ -11,7 +11,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/io" - "github.com/nspcc-dev/neo-go/pkg/rpc/client" + "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/emit" @@ -238,7 +238,7 @@ var errNNSIsAvailableInvalid = errors.New("`isAvailable`: invalid response") func nnsIsAvailable(c Client, nnsHash util.Uint160, name string) (bool, error) { switch ct := c.(type) { - case *client.Client: + case *rpcclient.Client: return ct.NNSIsAvailable(nnsHash, name) default: res, err := invokeFunction(c, nnsHash, "isAvailable", []interface{}{name}, nil) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_register.go b/cmd/neofs-adm/internal/modules/morph/initialize_register.go index 2d37f3327..42706c8aa 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_register.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_register.go @@ -9,7 +9,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/io" - "github.com/nspcc-dev/neo-go/pkg/rpc/client" + "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/emit" @@ -52,12 +52,12 @@ func (c *initializeContext) registerCandidates() error { panic(fmt.Sprintf("BUG: %v", w.Err)) } - signers := []client.SignerAccount{{ + signers := []rpcclient.SignerAccount{{ Signer: c.getSigner(false), Account: c.CommitteeAcc, }} for i := range c.Accounts { - signers = append(signers, client.SignerAccount{ + signers = append(signers, rpcclient.SignerAccount{ Signer: transaction.Signer{ Account: c.Accounts[i].Contract.ScriptHash(), Scopes: transaction.CustomContracts, @@ -120,7 +120,7 @@ var errGetPriceInvalid = errors.New("`getRegisterPrice`: invalid response") func (c *initializeContext) getCandidateRegisterPrice() (int64, error) { switch ct := c.Client.(type) { - case *client.Client: + case *rpcclient.Client: return ct.GetCandidateRegisterPrice() default: neoHash := c.nativeHash(nativenames.Neo) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go b/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go index 40faf1aa7..f0ceb7bfb 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go @@ -7,7 +7,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/io" - "github.com/nspcc-dev/neo-go/pkg/rpc/client" + "github.com/nspcc-dev/neo-go/pkg/rpcclient" "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/vm/emit" @@ -35,11 +35,11 @@ func (c *initializeContext) transferFunds() error { gasHash := c.nativeHash(nativenames.Gas) neoHash := c.nativeHash(nativenames.Neo) - var transfers []client.TransferTarget + var transfers []rpcclient.TransferTarget for _, acc := range c.Accounts { to := acc.Contract.ScriptHash() transfers = append(transfers, - client.TransferTarget{ + rpcclient.TransferTarget{ Token: gasHash, Address: to, Amount: initialAlphabetGASAmount, @@ -49,19 +49,19 @@ func (c *initializeContext) transferFunds() error { // It is convenient to have all funds at the committee account. transfers = append(transfers, - client.TransferTarget{ + rpcclient.TransferTarget{ Token: gasHash, Address: c.CommitteeAcc.Contract.ScriptHash(), Amount: (gasInitialTotalSupply - initialAlphabetGASAmount*int64(len(c.Wallets))) / 2, }, - client.TransferTarget{ + rpcclient.TransferTarget{ Token: neoHash, Address: c.CommitteeAcc.Contract.ScriptHash(), Amount: native.NEOTotalSupply, }, ) - tx, err := createNEP17MultiTransferTx(c.Client, c.ConsensusAcc, 0, transfers, []client.SignerAccount{{ + tx, err := createNEP17MultiTransferTx(c.Client, c.ConsensusAcc, 0, transfers, []rpcclient.SignerAccount{{ Signer: transaction.Signer{ Account: c.ConsensusAcc.Contract.ScriptHash(), Scopes: transaction.CalledByEntry, @@ -143,7 +143,7 @@ func (c *initializeContext) transferGASToProxy() error { return err } - tx, err := createNEP17MultiTransferTx(c.Client, c.CommitteeAcc, 0, []client.TransferTarget{{ + tx, err := createNEP17MultiTransferTx(c.Client, c.CommitteeAcc, 0, []rpcclient.TransferTarget{{ Token: gasHash, Address: proxyCs.Hash, Amount: initialProxyGASAmount, @@ -160,7 +160,7 @@ func (c *initializeContext) transferGASToProxy() error { } func createNEP17MultiTransferTx(c Client, acc *wallet.Account, netFee int64, - recipients []client.TransferTarget, cosigners []client.SignerAccount) (*transaction.Transaction, error) { + recipients []rpcclient.TransferTarget, cosigners []rpcclient.SignerAccount) (*transaction.Transaction, error) { from := acc.Contract.ScriptHash() w := io.NewBufBinWriter() @@ -172,7 +172,7 @@ func createNEP17MultiTransferTx(c Client, acc *wallet.Account, netFee int64, if w.Err != nil { return nil, fmt.Errorf("failed to create transfer script: %w", w.Err) } - return c.CreateTxFromScript(w.Bytes(), acc, -1, netFee, append([]client.SignerAccount{{ + return c.CreateTxFromScript(w.Bytes(), acc, -1, netFee, append([]rpcclient.SignerAccount{{ Signer: transaction.Signer{ Account: from, Scopes: transaction.CalledByEntry, diff --git a/cmd/neofs-adm/internal/modules/morph/local_client.go b/cmd/neofs-adm/internal/modules/morph/local_client.go index ba4971033..f94ff83f9 100644 --- a/cmd/neofs-adm/internal/modules/morph/local_client.go +++ b/cmd/neofs-adm/internal/modules/morph/local_client.go @@ -21,9 +21,9 @@ import ( "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/io" + "github.com/nspcc-dev/neo-go/pkg/neorpc/result" "github.com/nspcc-dev/neo-go/pkg/network/payload" - "github.com/nspcc-dev/neo-go/pkg/rpc/client" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" + "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" @@ -125,7 +125,7 @@ func (l *localClient) GetApplicationLog(h util.Uint256, t *trigger.Type) (*resul return &a, nil } -func (l *localClient) CreateTxFromScript(script []byte, acc *wallet.Account, sysFee int64, netFee int64, cosigners []client.SignerAccount) (*transaction.Transaction, error) { +func (l *localClient) CreateTxFromScript(script []byte, acc *wallet.Account, sysFee int64, netFee int64, cosigners []rpcclient.SignerAccount) (*transaction.Transaction, error) { signers, accounts, err := getSigners(acc, cosigners) if err != nil { return nil, fmt.Errorf("failed to construct tx signers: %w", err) @@ -173,7 +173,7 @@ func (l *localClient) SignAndPushP2PNotaryRequest(_ *transaction.Transaction, _ panic("unexpected call") } -func (l *localClient) SignAndPushInvocationTx(_ []byte, _ *wallet.Account, _ int64, _ fixedn.Fixed8, _ []client.SignerAccount) (util.Uint256, error) { +func (l *localClient) SignAndPushInvocationTx(_ []byte, _ *wallet.Account, _ int64, _ fixedn.Fixed8, _ []rpcclient.SignerAccount) (util.Uint256, error) { // not used by `morph init` command panic("unexpected call") } @@ -204,7 +204,7 @@ func (l *localClient) AddNetworkFee(tx *transaction.Transaction, extraFee int64, // will be placed at the start of the list. // Copied from neo-go with minor corrections: // https://github.com/nspcc-dev/neo-go/blob/6ff11baa1b9e4c71ef0d1de43b92a8c541ca732c/pkg/rpc/client/rpc.go#L735 -func getSigners(sender *wallet.Account, cosigners []client.SignerAccount) ([]transaction.Signer, []*wallet.Account, error) { +func getSigners(sender *wallet.Account, cosigners []rpcclient.SignerAccount) ([]transaction.Signer, []*wallet.Account, error) { var ( signers []transaction.Signer accounts []*wallet.Account diff --git a/cmd/neofs-adm/internal/modules/morph/n3client.go b/cmd/neofs-adm/internal/modules/morph/n3client.go index fdf1b6330..8e7f7a300 100644 --- a/cmd/neofs-adm/internal/modules/morph/n3client.go +++ b/cmd/neofs-adm/internal/modules/morph/n3client.go @@ -11,9 +11,9 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" + "github.com/nspcc-dev/neo-go/pkg/neorpc/result" "github.com/nspcc-dev/neo-go/pkg/network/payload" - "github.com/nspcc-dev/neo-go/pkg/rpc/client" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" + "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/wallet" @@ -30,14 +30,14 @@ type Client interface { GetNativeContracts() ([]state.NativeContract, error) GetNetwork() (netmode.Magic, error) GetApplicationLog(util.Uint256, *trigger.Type) (*result.ApplicationLog, error) - CreateTxFromScript([]byte, *wallet.Account, int64, int64, []client.SignerAccount) (*transaction.Transaction, error) + CreateTxFromScript([]byte, *wallet.Account, int64, int64, []rpcclient.SignerAccount) (*transaction.Transaction, error) NEP17BalanceOf(util.Uint160, util.Uint160) (int64, error) InvokeScript([]byte, []transaction.Signer) (*result.Invoke, error) SendRawTransaction(*transaction.Transaction) (util.Uint256, error) GetCommittee() (keys.PublicKeys, error) CalculateNotaryFee(uint8) (int64, error) AddNetworkFee(*transaction.Transaction, int64, ...*wallet.Account) error - SignAndPushInvocationTx([]byte, *wallet.Account, int64, fixedn.Fixed8, []client.SignerAccount) (util.Uint256, error) + SignAndPushInvocationTx([]byte, *wallet.Account, int64, fixedn.Fixed8, []rpcclient.SignerAccount) (util.Uint256, error) SignAndPushP2PNotaryRequest(*transaction.Transaction, []byte, int64, int64, uint32, *wallet.Account) (*payload.P2PNotaryRequest, error) } @@ -61,7 +61,7 @@ func getN3Client(v *viper.Viper) (Client, error) { if endpoint == "" { return nil, errors.New("missing endpoint") } - c, err := client.New(ctx, endpoint, client.Options{ + c, err := rpcclient.New(ctx, endpoint, rpcclient.Options{ MaxConnsPerHost: maxConnsPerHost, RequestTimeout: requestTimeout, }) diff --git a/cmd/neofs-adm/internal/modules/morph/notary.go b/cmd/neofs-adm/internal/modules/morph/notary.go index 7c60ddd90..58baec389 100644 --- a/cmd/neofs-adm/internal/modules/morph/notary.go +++ b/cmd/neofs-adm/internal/modules/morph/notary.go @@ -10,7 +10,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/io" - "github.com/nspcc-dev/neo-go/pkg/rpc/client" + "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag" "github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/opcode" @@ -113,7 +113,7 @@ func depositNotary(cmd *cobra.Command, _ []string) error { return fmt.Errorf("BUG: invalid transfer arguments: %w", bw.Err) } - tx, err := c.CreateTxFromScript(bw.Bytes(), acc, -1, 0, []client.SignerAccount{{ + tx, err := c.CreateTxFromScript(bw.Bytes(), acc, -1, 0, []rpcclient.SignerAccount{{ Signer: transaction.Signer{ Account: acc.Contract.ScriptHash(), Scopes: transaction.Global, diff --git a/cmd/neofs-adm/internal/modules/morph/subnet.go b/cmd/neofs-adm/internal/modules/morph/subnet.go index b1e41a124..52a304a40 100644 --- a/cmd/neofs-adm/internal/modules/morph/subnet.go +++ b/cmd/neofs-adm/internal/modules/morph/subnet.go @@ -12,8 +12,8 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" - neogocli "github.com/nspcc-dev/neo-go/pkg/rpc/client" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result" + "github.com/nspcc-dev/neo-go/pkg/neorpc/result" + "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/opcode" @@ -851,7 +851,7 @@ func invokeNonNotary(c Client, key keys.PrivateKey, method string, args ...inter }, } - cosignerAcc := []neogocli.SignerAccount{ + cosignerAcc := []rpcclient.SignerAccount{ { Signer: cosigner[0], Account: acc, diff --git a/cmd/neofs-adm/internal/modules/storagecfg/root.go b/cmd/neofs-adm/internal/modules/storagecfg/root.go index ac7f07df9..551b25d7c 100644 --- a/cmd/neofs-adm/internal/modules/storagecfg/root.go +++ b/cmd/neofs-adm/internal/modules/storagecfg/root.go @@ -24,7 +24,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "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/rpc/client" + "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" @@ -394,8 +394,8 @@ loop: } } -func initClient(rpc []string) *client.Client { - var c *client.Client +func initClient(rpc []string) *rpcclient.Client { + var c *rpcclient.Client var err error shuffled := make([]string, len(rpc)) @@ -403,7 +403,7 @@ func initClient(rpc []string) *client.Client { rand.Shuffle(len(shuffled), func(i, j int) { shuffled[i], shuffled[j] = shuffled[j], shuffled[i] }) for _, endpoint := range shuffled { - c, err = client.New(context.Background(), "https://"+endpoint, client.Options{ + c, err = rpcclient.New(context.Background(), "https://"+endpoint, rpcclient.Options{ DialTimeout: time.Second * 2, RequestTimeout: time.Second * 5, }) diff --git a/go.mod b/go.mod index ae821b7ff..a557a1b13 100644 --- a/go.mod +++ b/go.mod @@ -15,8 +15,8 @@ require ( github.com/multiformats/go-multiaddr v0.4.0 github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d github.com/nspcc-dev/hrw v1.0.9 - github.com/nspcc-dev/neo-go v0.99.1-pre.0.20220714084516-54849ef3e58e - github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220713145417-4f184498bc42 // indirect + github.com/nspcc-dev/neo-go v0.99.1 + github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220727202624-6c7a401f776a // indirect github.com/nspcc-dev/neofs-api-go/v2 v2.13.0 github.com/nspcc-dev/neofs-contract v0.15.3 github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.5.0.20220725101411-90f1cc7a1a77 diff --git a/go.sum b/go.sum index c7b4a7e38..72547dde1 100644 --- a/go.sum +++ b/go.sum @@ -373,10 +373,12 @@ github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y= github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU= github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg= github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM= -github.com/nspcc-dev/neo-go v0.99.1-pre.0.20220714084516-54849ef3e58e h1:sjl8sniYkjoOsD8F+wzkpRfm9RzZSLQlh5Z/SMyf4A8= github.com/nspcc-dev/neo-go v0.99.1-pre.0.20220714084516-54849ef3e58e/go.mod h1:/y5Sl8p3YheTygriBtCCMWKkDOek8HcvSo5ds2rJtKI= -github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220713145417-4f184498bc42 h1:Krhg2cD5mqvC+lin7irw6hj0M+x4ZOZrRGzrZQB+wcQ= +github.com/nspcc-dev/neo-go v0.99.1 h1:/dlDVVCqlmazusIu+Emd4TlwxjIOpNNU5ob7bwUH6Qk= +github.com/nspcc-dev/neo-go v0.99.1/go.mod h1:wvKMQXlE/M3eqtN0KIi1MjkEVTvYIJRrOMnJtqEkCxs= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220713145417-4f184498bc42/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220727202624-6c7a401f776a h1:ND5lYt9/cybrbS6/DVX0398a4ilt4/xE/QtEaOzJSGY= +github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220727202624-6c7a401f776a/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.13.0 h1:7BcBiSjmWqJx0SPFlGRYt9ZFbMjucRIz9+Mv8UBLeq8= diff --git a/pkg/morph/client/client.go b/pkg/morph/client/client.go index 98613c441..8ec9e7240 100644 --- a/pkg/morph/client/client.go +++ b/pkg/morph/client/client.go @@ -14,7 +14,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" - "github.com/nspcc-dev/neo-go/pkg/rpc/client" + "github.com/nspcc-dev/neo-go/pkg/rpcclient" sc "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" @@ -44,7 +44,7 @@ type Client struct { logger *logger.Logger // logging component - client *client.WSClient // neo-go websocket client + client *rpcclient.WSClient // neo-go websocket client acc *wallet.Account // neo account @@ -62,7 +62,7 @@ type Client struct { switchLock *sync.RWMutex // channel for ws notifications - notifications chan client.Notification + notifications chan rpcclient.Notification // channel for internal stop closeChan chan struct{} @@ -194,7 +194,7 @@ func (c *Client) Invoke(contract util.Uint160, fee fixedn.Fixed8, method string, }, } - cosignerAcc := []client.SignerAccount{ + cosignerAcc := []rpcclient.SignerAccount{ { Signer: cosigner[0], Account: c.acc, @@ -569,7 +569,7 @@ func (c *Client) IsValidScript(script []byte, signers []transaction.Signer) (res // notification from the connected RPC node. // Channel is closed when connection to the RPC node has been // lost without the possibility of recovery. -func (c *Client) NotificationChannel() <-chan client.Notification { +func (c *Client) NotificationChannel() <-chan rpcclient.Notification { return c.notifications } diff --git a/pkg/morph/client/constructor.go b/pkg/morph/client/constructor.go index 5820e24ef..62ebbf558 100644 --- a/pkg/morph/client/constructor.go +++ b/pkg/morph/client/constructor.go @@ -10,7 +10,7 @@ import ( lru "github.com/hashicorp/golang-lru" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" - "github.com/nspcc-dev/neo-go/pkg/rpc/client" + "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neofs-node/pkg/util/logger" @@ -38,7 +38,7 @@ type cfg struct { endpoints []Endpoint - singleCli *client.WSClient // neo-go client for single client mode + singleCli *rpcclient.WSClient // neo-go client for single client mode inactiveModeCb Callback } @@ -101,7 +101,7 @@ func New(key *keys.PrivateKey, opts ...Option) (*Client, error) { signer: cfg.signer, cfg: *cfg, switchLock: &sync.RWMutex{}, - notifications: make(chan client.Notification), + notifications: make(chan rpcclient.Notification), subscribedEvents: make(map[util.Uint160]string), subscribedNotaryEvents: make(map[util.Uint160]string), closeChan: make(chan struct{}), @@ -136,11 +136,11 @@ func New(key *keys.PrivateKey, opts ...Option) (*Client, error) { return cli, nil } -func newWSClient(cfg cfg, endpoint string) (*client.WSClient, error) { - return client.NewWS( +func newWSClient(cfg cfg, endpoint string) (*rpcclient.WSClient, error) { + return rpcclient.NewWS( cfg.ctx, endpoint, - client.Options{DialTimeout: cfg.dialTimeout}, + rpcclient.Options{DialTimeout: cfg.dialTimeout}, ) } @@ -223,7 +223,7 @@ func WithEndpoints(endpoints ...Endpoint) Option { // to use it for requests. // // Passed client must already be initialized. -func WithSingleClient(cli *client.WSClient) Option { +func WithSingleClient(cli *rpcclient.WSClient) Option { return func(c *cfg) { c.singleCli = cli } diff --git a/pkg/morph/client/nns.go b/pkg/morph/client/nns.go index 3bf29c567..46f7d717f 100644 --- a/pkg/morph/client/nns.go +++ b/pkg/morph/client/nns.go @@ -8,7 +8,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" - "github.com/nspcc-dev/neo-go/pkg/rpc/client" + "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" @@ -98,7 +98,7 @@ func (c *Client) NNSHash() (util.Uint160, error) { return *nnsHash, nil } -func nnsResolveItem(c *client.WSClient, nnsHash util.Uint160, domain string) (stackitem.Item, error) { +func nnsResolveItem(c *rpcclient.WSClient, nnsHash util.Uint160, domain string) (stackitem.Item, error) { found, err := exists(c, nnsHash, domain) if err != nil { return nil, fmt.Errorf("could not check presence in NNS contract for %s: %w", domain, err) @@ -130,7 +130,7 @@ func nnsResolveItem(c *client.WSClient, nnsHash util.Uint160, domain string) (st return result.Stack[0], nil } -func nnsResolve(c *client.WSClient, nnsHash util.Uint160, domain string) (util.Uint160, error) { +func nnsResolve(c *rpcclient.WSClient, nnsHash util.Uint160, domain string) (util.Uint160, error) { res, err := nnsResolveItem(c, nnsHash, domain) if err != nil { return util.Uint160{}, err @@ -152,7 +152,7 @@ func nnsResolve(c *client.WSClient, nnsHash util.Uint160, domain string) (util.U return util.Uint160DecodeStringLE(string(bs)) } -func exists(c *client.WSClient, nnsHash util.Uint160, domain string) (bool, error) { +func exists(c *rpcclient.WSClient, nnsHash util.Uint160, domain string) (bool, error) { result, err := c.InvokeFunction(nnsHash, "isAvailable", []smartcontract.Parameter{ { Type: smartcontract.StringType, diff --git a/pkg/morph/event/balance/lock.go b/pkg/morph/event/balance/lock.go index 1f0695426..da30ddc7e 100644 --- a/pkg/morph/event/balance/lock.go +++ b/pkg/morph/event/balance/lock.go @@ -3,7 +3,7 @@ package balance import ( "fmt" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" @@ -46,7 +46,7 @@ func (l Lock) Until() int64 { return l.until } func (l Lock) TxHash() util.Uint256 { return l.txHash } // ParseLock from notification into lock structure. -func ParseLock(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseLock(e *state.ContainedNotificationEvent) (event.Event, error) { var ( ev Lock err error diff --git a/pkg/morph/event/balance/lock_test.go b/pkg/morph/event/balance/lock_test.go index 7bc539a11..d2a8ed6b6 100644 --- a/pkg/morph/event/balance/lock_test.go +++ b/pkg/morph/event/balance/lock_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/nspcc-dev/neo-go/pkg/core/state" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neofs-node/pkg/morph/event" @@ -102,8 +101,8 @@ func TestParseLock(t *testing.T) { }) } -func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent { - return &subscriptions.NotificationEvent{ +func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent { + return &state.ContainedNotificationEvent{ NotificationEvent: state.NotificationEvent{ Item: stackitem.NewArray(items), }, diff --git a/pkg/morph/event/container/delete.go b/pkg/morph/event/container/delete.go index 1fc977f76..a37cf333b 100644 --- a/pkg/morph/event/container/delete.go +++ b/pkg/morph/event/container/delete.go @@ -3,8 +3,8 @@ package container import ( "fmt" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/network/payload" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" ) @@ -46,7 +46,7 @@ const expectedItemNumDelete = 3 // ParseDelete from notification into container event structure. // // Expects 3 stack items. -func ParseDelete(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseDelete(e *state.ContainedNotificationEvent) (event.Event, error) { var ( ev Delete err error diff --git a/pkg/morph/event/container/eacl.go b/pkg/morph/event/container/eacl.go index cdb9f9bd8..9405136be 100644 --- a/pkg/morph/event/container/eacl.go +++ b/pkg/morph/event/container/eacl.go @@ -3,8 +3,8 @@ package container import ( "fmt" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/network/payload" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" ) @@ -58,7 +58,7 @@ const expectedItemNumEACL = 4 // ParseSetEACL parses SetEACL notification event from list of stack items. // // Expects 4 stack items. -func ParseSetEACL(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseSetEACL(e *state.ContainedNotificationEvent) (event.Event, error) { var ( ev SetEACL err error diff --git a/pkg/morph/event/container/eacl_test.go b/pkg/morph/event/container/eacl_test.go index b521d4293..4d99b8401 100644 --- a/pkg/morph/event/container/eacl_test.go +++ b/pkg/morph/event/container/eacl_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/nspcc-dev/neo-go/pkg/core/state" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/stretchr/testify/require" @@ -86,8 +85,8 @@ func TestParseEACL(t *testing.T) { }) } -func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent { - return &subscriptions.NotificationEvent{ +func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent { + return &state.ContainedNotificationEvent{ NotificationEvent: state.NotificationEvent{ Item: stackitem.NewArray(items), }, diff --git a/pkg/morph/event/container/estimates.go b/pkg/morph/event/container/estimates.go index 9d5468706..078441b5b 100644 --- a/pkg/morph/event/container/estimates.go +++ b/pkg/morph/event/container/estimates.go @@ -3,7 +3,7 @@ package container import ( "fmt" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" @@ -34,7 +34,7 @@ func (s StartEstimation) Epoch() uint64 { return s.epoch } func (s StopEstimation) Epoch() uint64 { return s.epoch } // ParseStartEstimation from notification into container event structure. -func ParseStartEstimation(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseStartEstimation(e *state.ContainedNotificationEvent) (event.Event, error) { params, err := event.ParseStackArray(e) if err != nil { return nil, fmt.Errorf("could not parse stack items from notify event: %w", err) @@ -49,7 +49,7 @@ func ParseStartEstimation(e *subscriptions.NotificationEvent) (event.Event, erro } // ParseStopEstimation from notification into container event structure. -func ParseStopEstimation(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseStopEstimation(e *state.ContainedNotificationEvent) (event.Event, error) { params, err := event.ParseStackArray(e) if err != nil { return nil, fmt.Errorf("could not parse stack items from notify event: %w", err) diff --git a/pkg/morph/event/container/put.go b/pkg/morph/event/container/put.go index 348c8d535..abf177cd2 100644 --- a/pkg/morph/event/container/put.go +++ b/pkg/morph/event/container/put.go @@ -3,8 +3,8 @@ package container import ( "fmt" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/network/payload" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" ) @@ -65,7 +65,7 @@ func (x PutNamed) Zone() string { } // ParsePut from notification into container event structure. -func ParsePut(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParsePut(e *state.ContainedNotificationEvent) (event.Event, error) { var ( ev Put err error diff --git a/pkg/morph/event/listener.go b/pkg/morph/event/listener.go index 0a5f96af1..a210fd85f 100644 --- a/pkg/morph/event/listener.go +++ b/pkg/morph/event/listener.go @@ -7,7 +7,8 @@ import ( "sync" "github.com/nspcc-dev/neo-go/pkg/core/block" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" + "github.com/nspcc-dev/neo-go/pkg/neorpc/result" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/subscriber" @@ -189,11 +190,11 @@ func (l *listener) listen(ctx context.Context, intError chan<- error) error { return nil } -func (l *listener) listenLoop(ctx context.Context, chEvent <-chan *subscriptions.NotificationEvent, intErr chan<- error) { +func (l *listener) listenLoop(ctx context.Context, chEvent <-chan *state.ContainedNotificationEvent, intErr chan<- error) { var ( blockChan <-chan *block.Block - notaryChan <-chan *subscriptions.NotaryRequestEvent + notaryChan <-chan *result.NotaryRequestEvent err error ) @@ -294,7 +295,7 @@ loop: } } -func (l *listener) parseAndHandleNotification(notifyEvent *subscriptions.NotificationEvent) { +func (l *listener) parseAndHandleNotification(notifyEvent *state.ContainedNotificationEvent) { log := l.log.With( zap.String("script hash LE", notifyEvent.ScriptHash.StringLE()), ) @@ -349,7 +350,7 @@ func (l *listener) parseAndHandleNotification(notifyEvent *subscriptions.Notific } } -func (l *listener) parseAndHandleNotary(nr *subscriptions.NotaryRequestEvent) { +func (l *listener) parseAndHandleNotary(nr *result.NotaryRequestEvent) { // prepare the notary event notaryEvent, err := l.notaryEventsPreparator.Prepare(nr.NotaryRequest) if err != nil { diff --git a/pkg/morph/event/neofs/bind.go b/pkg/morph/event/neofs/bind.go index 8e154c933..a976bcbd7 100644 --- a/pkg/morph/event/neofs/bind.go +++ b/pkg/morph/event/neofs/bind.go @@ -3,7 +3,7 @@ package neofs import ( "fmt" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neofs-node/pkg/morph/client" @@ -37,7 +37,7 @@ func (b bindCommon) Keys() [][]byte { return b.keys } func (b bindCommon) User() []byte { return b.user } -func ParseBind(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseBind(e *state.ContainedNotificationEvent) (event.Event, error) { var ( ev Bind err error diff --git a/pkg/morph/event/neofs/bind_test.go b/pkg/morph/event/neofs/bind_test.go index c7a628833..4c0f5609b 100644 --- a/pkg/morph/event/neofs/bind_test.go +++ b/pkg/morph/event/neofs/bind_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/nspcc-dev/neo-go/pkg/core/state" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/stretchr/testify/require" @@ -64,8 +63,8 @@ func TestParseBind(t *testing.T) { }) } -func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent { - return &subscriptions.NotificationEvent{ +func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent { + return &state.ContainedNotificationEvent{ NotificationEvent: state.NotificationEvent{ Item: stackitem.NewArray(items), }, diff --git a/pkg/morph/event/neofs/cheque.go b/pkg/morph/event/neofs/cheque.go index 8c09fba57..66f16ca81 100644 --- a/pkg/morph/event/neofs/cheque.go +++ b/pkg/morph/event/neofs/cheque.go @@ -3,7 +3,7 @@ package neofs import ( "fmt" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" @@ -33,7 +33,7 @@ func (c Cheque) Amount() int64 { return c.amount } func (c Cheque) LockAccount() util.Uint160 { return c.lock } // ParseCheque from notification into cheque structure. -func ParseCheque(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseCheque(e *state.ContainedNotificationEvent) (event.Event, error) { var ( ev Cheque err error diff --git a/pkg/morph/event/neofs/config.go b/pkg/morph/event/neofs/config.go index 0853617f9..8a74233db 100644 --- a/pkg/morph/event/neofs/config.go +++ b/pkg/morph/event/neofs/config.go @@ -3,7 +3,7 @@ package neofs import ( "fmt" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" @@ -35,7 +35,7 @@ func (u Config) Key() []byte { return u.key } func (u Config) Value() []byte { return u.value } -func ParseConfig(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseConfig(e *state.ContainedNotificationEvent) (event.Event, error) { var ( ev Config err error diff --git a/pkg/morph/event/neofs/deposit.go b/pkg/morph/event/neofs/deposit.go index 2485a01cd..cbfb20219 100644 --- a/pkg/morph/event/neofs/deposit.go +++ b/pkg/morph/event/neofs/deposit.go @@ -3,7 +3,7 @@ package neofs import ( "fmt" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" @@ -33,7 +33,7 @@ func (d Deposit) To() util.Uint160 { return d.to } func (d Deposit) Amount() int64 { return d.amount } // ParseDeposit notification into deposit structure. -func ParseDeposit(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseDeposit(e *state.ContainedNotificationEvent) (event.Event, error) { var ev Deposit params, err := event.ParseStackArray(e) diff --git a/pkg/morph/event/neofs/unbind.go b/pkg/morph/event/neofs/unbind.go index 5f870e3f8..61044e0d3 100644 --- a/pkg/morph/event/neofs/unbind.go +++ b/pkg/morph/event/neofs/unbind.go @@ -3,7 +3,7 @@ package neofs import ( "fmt" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neofs-node/pkg/morph/event" ) @@ -11,7 +11,7 @@ type Unbind struct { bindCommon } -func ParseUnbind(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseUnbind(e *state.ContainedNotificationEvent) (event.Event, error) { var ( ev Unbind err error diff --git a/pkg/morph/event/neofs/withdraw.go b/pkg/morph/event/neofs/withdraw.go index 781f74e66..ab8a29f00 100644 --- a/pkg/morph/event/neofs/withdraw.go +++ b/pkg/morph/event/neofs/withdraw.go @@ -3,7 +3,7 @@ package neofs import ( "fmt" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" @@ -29,7 +29,7 @@ func (w Withdraw) User() util.Uint160 { return w.user } func (w Withdraw) Amount() int64 { return w.amount } // ParseWithdraw notification into withdraw structure. -func ParseWithdraw(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseWithdraw(e *state.ContainedNotificationEvent) (event.Event, error) { var ev Withdraw params, err := event.ParseStackArray(e) diff --git a/pkg/morph/event/netmap/add_peer.go b/pkg/morph/event/netmap/add_peer.go index aa0014e14..7cae418b9 100644 --- a/pkg/morph/event/netmap/add_peer.go +++ b/pkg/morph/event/netmap/add_peer.go @@ -3,8 +3,8 @@ package netmap import ( "fmt" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/network/payload" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" ) @@ -32,7 +32,7 @@ func (s AddPeer) NotaryRequest() *payload.P2PNotaryRequest { const expectedItemNumAddPeer = 1 -func ParseAddPeer(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseAddPeer(e *state.ContainedNotificationEvent) (event.Event, error) { var ( ev AddPeer err error diff --git a/pkg/morph/event/netmap/add_peer_test.go b/pkg/morph/event/netmap/add_peer_test.go index ae231ecf0..a5efa96ef 100644 --- a/pkg/morph/event/netmap/add_peer_test.go +++ b/pkg/morph/event/netmap/add_peer_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/nspcc-dev/neo-go/pkg/core/state" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/stretchr/testify/require" @@ -43,8 +42,8 @@ func TestParseAddPeer(t *testing.T) { }) } -func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent { - return &subscriptions.NotificationEvent{ +func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent { + return &state.ContainedNotificationEvent{ NotificationEvent: state.NotificationEvent{ Item: stackitem.NewArray(items), }, diff --git a/pkg/morph/event/netmap/epoch.go b/pkg/morph/event/netmap/epoch.go index 19922392c..224b91988 100644 --- a/pkg/morph/event/netmap/epoch.go +++ b/pkg/morph/event/netmap/epoch.go @@ -3,7 +3,7 @@ package netmap import ( "fmt" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" @@ -36,7 +36,7 @@ func (s NewEpoch) TxHash() util.Uint256 { // ParseNewEpoch is a parser of new epoch notification event. // // Result is type of NewEpoch. -func ParseNewEpoch(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseNewEpoch(e *state.ContainedNotificationEvent) (event.Event, error) { params, err := event.ParseStackArray(e) if err != nil { return nil, fmt.Errorf("could not parse stack items from notify event: %w", err) diff --git a/pkg/morph/event/netmap/update_peer.go b/pkg/morph/event/netmap/update_peer.go index 83037a595..b96a932e2 100644 --- a/pkg/morph/event/netmap/update_peer.go +++ b/pkg/morph/event/netmap/update_peer.go @@ -4,9 +4,9 @@ import ( "crypto/elliptic" "fmt" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/network/payload" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neofs-contract/netmap" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" @@ -41,7 +41,7 @@ func (s UpdatePeer) NotaryRequest() *payload.P2PNotaryRequest { const expectedItemNumUpdatePeer = 2 -func ParseUpdatePeer(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseUpdatePeer(e *state.ContainedNotificationEvent) (event.Event, error) { var ( ev UpdatePeer err error diff --git a/pkg/morph/event/parsers.go b/pkg/morph/event/parsers.go index 37b57f467..90eff0bd2 100644 --- a/pkg/morph/event/parsers.go +++ b/pkg/morph/event/parsers.go @@ -3,13 +3,13 @@ package event import ( "fmt" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/network/payload" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" ) // NotificationParser is a function that constructs Event // from the StackItem list. -type NotificationParser func(*subscriptions.NotificationEvent) (Event, error) +type NotificationParser func(*state.ContainedNotificationEvent) (Event, error) // NotificationParserInfo is a structure that groups // the parameters of particular contract diff --git a/pkg/morph/event/reputation/put.go b/pkg/morph/event/reputation/put.go index 81d2b961c..8ac197a29 100644 --- a/pkg/morph/event/reputation/put.go +++ b/pkg/morph/event/reputation/put.go @@ -3,8 +3,8 @@ package reputation import ( "fmt" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/network/payload" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-sdk-go/reputation" @@ -49,7 +49,7 @@ func (p Put) NotaryRequest() *payload.P2PNotaryRequest { } // ParsePut from notification into reputation event structure. -func ParsePut(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParsePut(e *state.ContainedNotificationEvent) (event.Event, error) { var ( ev Put err error diff --git a/pkg/morph/event/reputation/put_test.go b/pkg/morph/event/reputation/put_test.go index b183843c8..beeb26330 100644 --- a/pkg/morph/event/reputation/put_test.go +++ b/pkg/morph/event/reputation/put_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/nspcc-dev/neo-go/pkg/core/state" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-sdk-go/reputation" @@ -84,8 +83,8 @@ func TestParsePut(t *testing.T) { }) } -func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent { - return &subscriptions.NotificationEvent{ +func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent { + return &state.ContainedNotificationEvent{ NotificationEvent: state.NotificationEvent{ Item: stackitem.NewArray(items), }, diff --git a/pkg/morph/event/rolemanagement/designate.go b/pkg/morph/event/rolemanagement/designate.go index 1fc7bcc73..9640641b9 100644 --- a/pkg/morph/event/rolemanagement/designate.go +++ b/pkg/morph/event/rolemanagement/designate.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/nspcc-dev/neo-go/pkg/core/native/noderoles" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/morph/event" ) @@ -23,7 +23,7 @@ type Designate struct { func (Designate) MorphEvent() {} // ParseDesignate from notification into container event structure. -func ParseDesignate(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseDesignate(e *state.ContainedNotificationEvent) (event.Event, error) { params, err := event.ParseStackArray(e) if err != nil { return nil, fmt.Errorf("could not parse stack items from notify event: %w", err) diff --git a/pkg/morph/event/rolemanagement/designate_test.go b/pkg/morph/event/rolemanagement/designate_test.go index 1c9ca7f5c..c5238b0bc 100644 --- a/pkg/morph/event/rolemanagement/designate_test.go +++ b/pkg/morph/event/rolemanagement/designate_test.go @@ -5,7 +5,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/native/noderoles" "github.com/nspcc-dev/neo-go/pkg/core/state" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/stretchr/testify/require" ) @@ -28,8 +27,8 @@ func TestParseRoleUpdate(t *testing.T) { }) } -func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent { - return &subscriptions.NotificationEvent{ +func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent { + return &state.ContainedNotificationEvent{ NotificationEvent: state.NotificationEvent{ Item: stackitem.NewArray(items), }, diff --git a/pkg/morph/event/subnet/delete.go b/pkg/morph/event/subnet/delete.go index cb81e3833..2c3ae9d91 100644 --- a/pkg/morph/event/subnet/delete.go +++ b/pkg/morph/event/subnet/delete.go @@ -3,7 +3,7 @@ package subnetevents import ( "fmt" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" @@ -34,7 +34,7 @@ func (x Delete) TxHash() util.Uint256 { // by the appropriate method of the Subnet contract. // // Resulting event is of Delete type. -func ParseDelete(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseDelete(e *state.ContainedNotificationEvent) (event.Event, error) { var ( ev Delete err error diff --git a/pkg/morph/event/subnet/put.go b/pkg/morph/event/subnet/put.go index 790573704..fb03935cd 100644 --- a/pkg/morph/event/subnet/put.go +++ b/pkg/morph/event/subnet/put.go @@ -3,9 +3,9 @@ package subnetevents import ( "fmt" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/network/payload" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" @@ -65,7 +65,7 @@ const itemNumPut = 3 // by the appropriate method of the subnet contract. // // Resulting event is of Put type. -func ParsePut(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParsePut(e *state.ContainedNotificationEvent) (event.Event, error) { var ( put Put err error diff --git a/pkg/morph/event/subnet/remove_node.go b/pkg/morph/event/subnet/remove_node.go index 229df2477..a8793dc29 100644 --- a/pkg/morph/event/subnet/remove_node.go +++ b/pkg/morph/event/subnet/remove_node.go @@ -3,7 +3,7 @@ package subnetevents import ( "fmt" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/event" @@ -38,7 +38,7 @@ const expectedItemNumRemoveNode = 2 // ParseRemoveNode parses notification into subnet event structure. // // Expects 2 stack items. -func ParseRemoveNode(e *subscriptions.NotificationEvent) (event.Event, error) { +func ParseRemoveNode(e *state.ContainedNotificationEvent) (event.Event, error) { var ( ev RemoveNode err error diff --git a/pkg/morph/event/subnet/remove_node_test.go b/pkg/morph/event/subnet/remove_node_test.go index dcad25e9e..57d00326e 100644 --- a/pkg/morph/event/subnet/remove_node_test.go +++ b/pkg/morph/event/subnet/remove_node_test.go @@ -5,7 +5,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" . "github.com/nspcc-dev/neofs-node/pkg/morph/event/subnet" subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id" @@ -48,8 +47,8 @@ func TestParseRemoveNode(t *testing.T) { }) } -func createNotifyEventFromItems(items []stackitem.Item) *subscriptions.NotificationEvent { - return &subscriptions.NotificationEvent{ +func createNotifyEventFromItems(items []stackitem.Item) *state.ContainedNotificationEvent { + return &state.ContainedNotificationEvent{ NotificationEvent: state.NotificationEvent{ Item: stackitem.NewArray(items), }, diff --git a/pkg/morph/event/utils.go b/pkg/morph/event/utils.go index f85d9598f..cd37a0f37 100644 --- a/pkg/morph/event/utils.go +++ b/pkg/morph/event/utils.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/nspcc-dev/neo-go/pkg/core/mempoolevent" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neofs-node/pkg/morph/client" @@ -99,7 +99,7 @@ var errEmptyStackArray = errors.New("stack item array is empty") // ParseStackArray parses stack array from raw notification // event received from neo-go RPC node. -func ParseStackArray(event *subscriptions.NotificationEvent) ([]stackitem.Item, error) { +func ParseStackArray(event *state.ContainedNotificationEvent) ([]stackitem.Item, error) { arr, err := client.ArrayFromStackItem(event.Item) if err != nil { return nil, fmt.Errorf("stack item is not an array type: %w", err) diff --git a/pkg/morph/subscriber/subscriber.go b/pkg/morph/subscriber/subscriber.go index 3e28aa7ea..8a95126f2 100644 --- a/pkg/morph/subscriber/subscriber.go +++ b/pkg/morph/subscriber/subscriber.go @@ -7,8 +7,9 @@ import ( "sync" "github.com/nspcc-dev/neo-go/pkg/core/block" - "github.com/nspcc-dev/neo-go/pkg/rpc/response" - "github.com/nspcc-dev/neo-go/pkg/rpc/response/result/subscriptions" + "github.com/nspcc-dev/neo-go/pkg/core/state" + "github.com/nspcc-dev/neo-go/pkg/neorpc" + "github.com/nspcc-dev/neo-go/pkg/neorpc/result" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/morph/client" "go.uber.org/zap" @@ -17,10 +18,10 @@ import ( type ( // Subscriber is an interface of the NotificationEvent listener. Subscriber interface { - SubscribeForNotification(...util.Uint160) (<-chan *subscriptions.NotificationEvent, error) + SubscribeForNotification(...util.Uint160) (<-chan *state.ContainedNotificationEvent, error) UnsubscribeForNotification() BlockNotifications() (<-chan *block.Block, error) - SubscribeForNotaryRequests(mainTXSigner util.Uint160) (<-chan *subscriptions.NotaryRequestEvent, error) + SubscribeForNotaryRequests(mainTXSigner util.Uint160) (<-chan *result.NotaryRequestEvent, error) Close() } @@ -29,11 +30,11 @@ type ( log *zap.Logger client *client.Client - notifyChan chan *subscriptions.NotificationEvent + notifyChan chan *state.ContainedNotificationEvent blockChan chan *block.Block - notaryChan chan *subscriptions.NotaryRequestEvent + notaryChan chan *result.NotaryRequestEvent } // Params is a group of Subscriber constructor parameters. @@ -52,7 +53,7 @@ var ( errNilClient = errors.New("chain/subscriber: client was not provided to the constructor") ) -func (s *subscriber) SubscribeForNotification(contracts ...util.Uint160) (<-chan *subscriptions.NotificationEvent, error) { +func (s *subscriber) SubscribeForNotification(contracts ...util.Uint160) (<-chan *state.ContainedNotificationEvent, error) { s.Lock() defer s.Unlock() @@ -97,7 +98,7 @@ func (s *subscriber) BlockNotifications() (<-chan *block.Block, error) { return s.blockChan, nil } -func (s *subscriber) SubscribeForNotaryRequests(mainTXSigner util.Uint160) (<-chan *subscriptions.NotaryRequestEvent, error) { +func (s *subscriber) SubscribeForNotaryRequests(mainTXSigner util.Uint160) (<-chan *result.NotaryRequestEvent, error) { if err := s.client.SubscribeForNotaryRequests(mainTXSigner); err != nil { return nil, fmt.Errorf("could not subscribe for notary request events: %w", err) } @@ -123,8 +124,8 @@ func (s *subscriber) routeNotifications(ctx context.Context) { } switch notification.Type { - case response.NotificationEventID: - notifyEvent, ok := notification.Value.(*subscriptions.NotificationEvent) + case neorpc.NotificationEventID: + notifyEvent, ok := notification.Value.(*state.ContainedNotificationEvent) if !ok { s.log.Error("can't cast notify event value to the notify struct", zap.String("received type", fmt.Sprintf("%T", notification.Value)), @@ -133,7 +134,7 @@ func (s *subscriber) routeNotifications(ctx context.Context) { } s.notifyChan <- notifyEvent - case response.BlockEventID: + case neorpc.BlockEventID: b, ok := notification.Value.(*block.Block) if !ok { s.log.Error("can't cast block event value to block", @@ -143,8 +144,8 @@ func (s *subscriber) routeNotifications(ctx context.Context) { } s.blockChan <- b - case response.NotaryRequestEventID: - notaryRequest, ok := notification.Value.(*subscriptions.NotaryRequestEvent) + case neorpc.NotaryRequestEventID: + notaryRequest, ok := notification.Value.(*result.NotaryRequestEvent) if !ok { s.log.Error("can't cast notify event value to the notary request struct", zap.String("received type", fmt.Sprintf("%T", notification.Value)), @@ -182,9 +183,9 @@ func New(ctx context.Context, p *Params) (Subscriber, error) { RWMutex: new(sync.RWMutex), log: p.Log, client: p.Client, - notifyChan: make(chan *subscriptions.NotificationEvent), + notifyChan: make(chan *state.ContainedNotificationEvent), blockChan: make(chan *block.Block), - notaryChan: make(chan *subscriptions.NotaryRequestEvent), + notaryChan: make(chan *result.NotaryRequestEvent), } // Worker listens all events from neo-go websocket and puts them