forked from TrueCloudLab/frostfs-node
[#122] Implement balance precision getter for inner ring
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
7db40eafe0
commit
b6012977bc
1 changed files with 20 additions and 0 deletions
|
@ -36,6 +36,7 @@ const (
|
||||||
lockMethod = "lock"
|
lockMethod = "lock"
|
||||||
mintMethod = "mint"
|
mintMethod = "mint"
|
||||||
burnMethod = "burn"
|
burnMethod = "burn"
|
||||||
|
precisionMethod = "decimals"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TransferBalanceX invokes transferX method.
|
// TransferBalanceX invokes transferX method.
|
||||||
|
@ -92,3 +93,22 @@ func LockAsset(cli *client.Client, con util.Uint160, p *LockParams) error {
|
||||||
int64(p.Until),
|
int64(p.Until),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BalancePrecision invokes Decimal method that returns precision of NEP-5 contract.
|
||||||
|
func BalancePrecision(cli *client.Client, con util.Uint160) (uint32, error) {
|
||||||
|
if cli == nil {
|
||||||
|
return 0, client.ErrNilClient
|
||||||
|
}
|
||||||
|
|
||||||
|
v, err := cli.TestInvoke(con, precisionMethod)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
precision, err := client.IntFromStackItem(v[0])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return uint32(precision), nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue