frostfs-node/pkg/morph/client/balance/decimals.go
Alexander Chuprov 9b113c3156
[#1613] morph: Add tracing for morph queries to neo-go
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
2025-02-05 16:38:20 +03:00

28 lines
818 B
Go

package balance
import (
"context"
"fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
)
// Decimals decimal precision of currency transactions
// through the Balance contract call, and returns it.
func (c *Client) Decimals(ctx context.Context) (uint32, error) {
invokePrm := client.TestInvokePrm{}
invokePrm.SetMethod(decimalsMethod)
prms, err := c.client.TestInvoke(ctx, invokePrm)
if err != nil {
return 0, fmt.Errorf("test invoke (%s): %w", decimalsMethod, err)
} else if ln := len(prms); ln != 1 {
return 0, fmt.Errorf("unexpected stack item count (%s): %d", decimalsMethod, ln)
}
decimals, err := client.IntFromStackItem(prms[0])
if err != nil {
return 0, fmt.Errorf("get integer stack item from stack item (%s): %w", decimalsMethod, err)
}
return uint32(decimals), nil
}