diff --git a/pkg/innerring/invoke/alphabet.go b/pkg/innerring/invoke/alphabet.go index ba662746b..393e5b146 100644 --- a/pkg/innerring/invoke/alphabet.go +++ b/pkg/innerring/invoke/alphabet.go @@ -27,9 +27,5 @@ func AlphabetVote(cli *client.Client, con util.Uint160, fee SideFeeProvider, epo return client.ErrNilClient } - if !cli.NotaryEnabled() { - return cli.Invoke(con, fee.SideChainFee(), voteMethod, int64(epoch), keys) - } - - return cli.NotaryInvoke(con, voteMethod, int64(epoch), keys) + return cli.NotaryInvoke(con, fee.SideChainFee(), voteMethod, int64(epoch), keys) } diff --git a/pkg/innerring/invoke/balance.go b/pkg/innerring/invoke/balance.go index b50709e87..5da410b87 100644 --- a/pkg/innerring/invoke/balance.go +++ b/pkg/innerring/invoke/balance.go @@ -37,15 +37,7 @@ func Mint(cli *client.Client, con util.Uint160, fee SideFeeProvider, p *MintBurn return client.ErrNilClient } - if !cli.NotaryEnabled() { - return cli.Invoke(con, fee.SideChainFee(), mintMethod, - p.ScriptHash, - p.Amount, - p.Comment, - ) - } - - return cli.NotaryInvoke(con, mintMethod, + return cli.NotaryInvoke(con, fee.SideChainFee(), mintMethod, p.ScriptHash, p.Amount, p.Comment, @@ -58,15 +50,7 @@ func Burn(cli *client.Client, con util.Uint160, fee SideFeeProvider, p *MintBurn return client.ErrNilClient } - if !cli.NotaryEnabled() { - return cli.Invoke(con, fee.SideChainFee(), burnMethod, - p.ScriptHash, - p.Amount, - p.Comment, - ) - } - - return cli.NotaryInvoke(con, burnMethod, + return cli.NotaryInvoke(con, fee.SideChainFee(), burnMethod, p.ScriptHash, p.Amount, p.Comment, @@ -79,17 +63,7 @@ func LockAsset(cli *client.Client, con util.Uint160, fee SideFeeProvider, p *Loc return client.ErrNilClient } - if !cli.NotaryEnabled() { - return cli.Invoke(con, fee.SideChainFee(), lockMethod, - p.ID, - p.User.BytesBE(), - p.LockAccount.BytesBE(), - p.Amount, - int64(p.Until), - ) - } - - return cli.NotaryInvoke(con, lockMethod, + return cli.NotaryInvoke(con, fee.SideChainFee(), lockMethod, p.ID, p.User.BytesBE(), p.LockAccount.BytesBE(), diff --git a/pkg/innerring/invoke/container.go b/pkg/innerring/invoke/container.go index 13c787828..3533efc01 100644 --- a/pkg/innerring/invoke/container.go +++ b/pkg/innerring/invoke/container.go @@ -32,15 +32,7 @@ func RegisterContainer(cli *client.Client, con util.Uint160, fee SideFeeProvider return client.ErrNilClient } - if !cli.NotaryEnabled() { - return cli.Invoke(con, fee.SideChainFee(), putContainerMethod, - p.Container, - p.Signature, - p.Key.Bytes(), - ) - } - - return cli.NotaryInvoke(con, putContainerMethod, + return cli.NotaryInvoke(con, fee.SideChainFee(), putContainerMethod, p.Container, p.Signature, p.Key.Bytes(), @@ -53,14 +45,7 @@ func RemoveContainer(cli *client.Client, con util.Uint160, fee SideFeeProvider, return client.ErrNilClient } - if !cli.NotaryEnabled() { - return cli.Invoke(con, fee.SideChainFee(), deleteContainerMethod, - p.ContainerID, - p.Signature, - ) - } - - return cli.NotaryInvoke(con, deleteContainerMethod, + return cli.NotaryInvoke(con, fee.SideChainFee(), deleteContainerMethod, p.ContainerID, p.Signature, ) diff --git a/pkg/innerring/invoke/neofs.go b/pkg/innerring/invoke/neofs.go index ce1e2ca9e..66f7fada8 100644 --- a/pkg/innerring/invoke/neofs.go +++ b/pkg/innerring/invoke/neofs.go @@ -36,16 +36,7 @@ func CashOutCheque(cli *client.Client, con util.Uint160, fee MainFeeProvider, p return client.ErrNilClient } - if !cli.NotaryEnabled() { - return cli.Invoke(con, fee.MainChainFee(), chequeMethod, - p.ID, - p.User.BytesBE(), - p.Amount, - p.LockAccount.BytesBE(), - ) - } - - return cli.NotaryInvoke(con, chequeMethod, + return cli.NotaryInvoke(con, fee.MainChainFee(), chequeMethod, p.ID, p.User.BytesBE(), p.Amount, @@ -59,9 +50,5 @@ func AlphabetUpdate(cli *client.Client, con util.Uint160, fee MainFeeProvider, i return client.ErrNilClient } - if !cli.NotaryEnabled() { - return cli.Invoke(con, fee.MainChainFee(), alphabetUpdateMethod, id, list) - } - - return cli.NotaryInvoke(con, alphabetUpdateMethod, id, list) + return cli.NotaryInvoke(con, fee.MainChainFee(), alphabetUpdateMethod, id, list) } diff --git a/pkg/innerring/invoke/netmap.go b/pkg/innerring/invoke/netmap.go index 71d7a55c5..9ddaffc92 100644 --- a/pkg/innerring/invoke/netmap.go +++ b/pkg/innerring/invoke/netmap.go @@ -59,11 +59,7 @@ func SetNewEpoch(cli *client.Client, con util.Uint160, fee SideFeeProvider, epoc return client.ErrNilClient } - if !cli.NotaryEnabled() { - return cli.Invoke(con, fee.SideChainFee(), setNewEpochMethod, int64(epoch)) - } - - return cli.NotaryInvoke(con, setNewEpochMethod, int64(epoch)) + return cli.NotaryInvoke(con, fee.SideChainFee(), setNewEpochMethod, int64(epoch)) } // ApprovePeer invokes addPeer method. @@ -72,11 +68,7 @@ func ApprovePeer(cli *client.Client, con util.Uint160, fee SideFeeProvider, peer return client.ErrNilClient } - if !cli.NotaryEnabled() { - return cli.Invoke(con, fee.SideChainFee(), approvePeerMethod, peer) - } - - return cli.NotaryInvoke(con, approvePeerMethod, peer) + return cli.NotaryInvoke(con, fee.SideChainFee(), approvePeerMethod, peer) } // UpdatePeerState invokes addPeer method. @@ -85,14 +77,7 @@ func UpdatePeerState(cli *client.Client, con util.Uint160, fee SideFeeProvider, return client.ErrNilClient } - if !cli.NotaryEnabled() { - return cli.Invoke(con, fee.SideChainFee(), updatePeerStateMethod, - int64(args.Status.ToV2()), - args.Key.Bytes(), - ) - } - - return cli.NotaryInvoke(con, updatePeerStateMethod, + return cli.NotaryInvoke(con, fee.SideChainFee(), updatePeerStateMethod, int64(args.Status.ToV2()), args.Key.Bytes(), ) @@ -104,15 +89,7 @@ func SetConfig(cli *client.Client, con util.Uint160, fee SideFeeProvider, args * return client.ErrNilClient } - if !cli.NotaryEnabled() { - return cli.Invoke(con, fee.SideChainFee(), setConfigMethod, - args.ID, - args.Key, - args.Value, - ) - } - - return cli.NotaryInvoke(con, setConfigMethod, + return cli.NotaryInvoke(con, fee.SideChainFee(), setConfigMethod, args.ID, args.Key, args.Value, @@ -126,11 +103,7 @@ func SetInnerRing(cli *client.Client, con util.Uint160, fee SideFeeProvider, lis return client.ErrNilClient } - if !cli.NotaryEnabled() { - return cli.Invoke(con, fee.SideChainFee(), setInnerRingMethod, list) - } - - return cli.NotaryInvoke(con, setInnerRingMethod, list) + return cli.NotaryInvoke(con, fee.SideChainFee(), setInnerRingMethod, list) } // NetmapSnapshot returns current netmap node infos. diff --git a/pkg/morph/client/notary.go b/pkg/morph/client/notary.go index 04fc8dfc8..f523b057c 100644 --- a/pkg/morph/client/notary.go +++ b/pkg/morph/client/notary.go @@ -200,14 +200,14 @@ func (c *Client) UpdateNeoFSAlphabetList(list keys.PublicKeys) error { } // NotaryInvoke invokes contract method by sending tx to notary contract in -// blockchain. Fallback tx is a `RET`. Notary support should be enabled -// in client to use this function. +// blockchain. Fallback tx is a `RET`. If Notary support is not enabled +// it fallbacks to a simple `Invoke()`. // // This function must be invoked after `EnableNotarySupport()` otherwise it // throws panic. -func (c *Client) NotaryInvoke(contract util.Uint160, method string, args ...interface{}) error { +func (c *Client) NotaryInvoke(contract util.Uint160, fee fixedn.Fixed8, method string, args ...interface{}) error { if c.notary == nil { - panic(notaryNotEnabledPanicMsg) + return c.Invoke(contract, fee, method, args...) } return c.notaryInvoke(false, contract, method, args...) diff --git a/pkg/morph/client/static.go b/pkg/morph/client/static.go index 62530e275..98e6c4f36 100644 --- a/pkg/morph/client/static.go +++ b/pkg/morph/client/static.go @@ -63,10 +63,14 @@ func (s StaticClient) TestInvoke(method string, args ...interface{}) ([]stackite } // NotaryInvoke calls NotaryInvoke method of Client with static internal -// script hash. Returns error if notary support was not enabled in underlying +// script hash. Panics if notary support was not enabled in underlying // moprh client. func (s StaticClient) NotaryInvoke(method string, args ...interface{}) error { - return s.client.NotaryInvoke( + if s.client.notary == nil { + panic(notaryNotEnabledPanicMsg) + } + return s.client.notaryInvoke( + false, s.scScriptHash, method, args...,