[#787] morph: Return VUB from Invoke method

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-11-07 18:13:26 +03:00
parent 5466e88444
commit 518f3baf41
25 changed files with 69 additions and 48 deletions

View file

@ -120,6 +120,10 @@ func (i *InvokePrmOptional) IsControl() bool {
return i.controlTX
}
type InvokeRes struct {
VUB uint32
}
// Invoke calls Invoke method of Client with static internal script hash and fee.
// Supported args types are the same as in Client.
//
@ -129,7 +133,9 @@ func (i *InvokePrmOptional) IsControl() bool {
//
// If fee for the operation executed using specified method is customized, then StaticClient uses it.
// Otherwise, default fee is used.
func (s StaticClient) Invoke(prm InvokePrm) error {
func (s StaticClient) Invoke(prm InvokePrm) (InvokeRes, error) {
var res InvokeRes
var err error
if s.tryNotary {
if s.alpha {
var (
@ -146,24 +152,27 @@ func (s StaticClient) Invoke(prm InvokePrm) error {
nonce, vub, err = s.client.CalculateNonceAndVUB(*prm.hash)
}
if err != nil {
return fmt.Errorf("could not calculate nonce and VUB for notary alphabet invoke: %w", err)
return InvokeRes{}, fmt.Errorf("could not calculate nonce and VUB for notary alphabet invoke: %w", err)
}
vubP = &vub
}
return s.client.NotaryInvoke(s.scScriptHash, s.fee, nonce, vubP, prm.method, prm.args...)
res.VUB, err = s.client.NotaryInvoke(s.scScriptHash, s.fee, nonce, vubP, prm.method, prm.args...)
return res, err
}
return s.client.NotaryInvokeNotAlpha(s.scScriptHash, s.fee, prm.method, prm.args...)
res.VUB, err = s.client.NotaryInvokeNotAlpha(s.scScriptHash, s.fee, prm.method, prm.args...)
return res, err
}
return s.client.Invoke(
res.VUB, err = s.client.Invoke(
s.scScriptHash,
s.fee,
prm.method,
prm.args...,
)
return res, err
}
// TestInvokePrm groups parameters of the TestInvoke operation.