[#1496] morph: Return InvokeRes from all invoke*() methods

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-11-14 10:01:59 +03:00
parent 69c63006da
commit b65874d1c3
Signed by: fyrchik
SSH key fingerprint: SHA256:m/TTwCzjnRkXgnzEx9X92ccxy1CcVeinOgDb3NPWWmg
5 changed files with 25 additions and 27 deletions

View file

@ -180,7 +180,7 @@ func wrapFrostFSError(err error) error {
// Invoke invokes contract method by sending transaction into blockchain.
// Returns valid until block value.
// Supported args types: int64, string, util.Uint160, []byte and bool.
func (c *Client) Invoke(ctx context.Context, contract util.Uint160, fee fixedn.Fixed8, method string, args ...any) (uint32, error) {
func (c *Client) Invoke(ctx context.Context, contract util.Uint160, fee fixedn.Fixed8, method string, args ...any) (InvokeRes, error) {
start := time.Now()
success := false
defer func() {
@ -191,12 +191,12 @@ func (c *Client) Invoke(ctx context.Context, contract util.Uint160, fee fixedn.F
defer c.switchLock.RUnlock()
if c.inactive {
return 0, ErrConnectionLost
return InvokeRes{}, ErrConnectionLost
}
txHash, vub, err := c.rpcActor.SendTunedCall(contract, method, nil, addFeeCheckerModifier(int64(fee)), args...)
if err != nil {
return 0, fmt.Errorf("could not invoke %s: %w", method, err)
return InvokeRes{}, fmt.Errorf("could not invoke %s: %w", method, err)
}
c.logger.Debug(ctx, logs.ClientNeoClientInvoke,
@ -205,7 +205,7 @@ func (c *Client) Invoke(ctx context.Context, contract util.Uint160, fee fixedn.F
zap.Stringer("tx_hash", txHash.Reverse()))
success = true
return vub, nil
return InvokeRes{Hash: txHash, VUB: vub}, nil
}
// TestInvokeIterator invokes contract method returning an iterator and executes cb on each element.