mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 19:42:23 +00:00
client: add NNS price getter
This commit is contained in:
parent
f308a9995d
commit
87d4939093
2 changed files with 21 additions and 0 deletions
|
@ -16,3 +16,12 @@ func (c *Client) GetOraclePrice() (int64, error) {
|
|||
}
|
||||
return c.invokeNativeGetMethod(oracleHash, "getPrice")
|
||||
}
|
||||
|
||||
// GetNNSPrice invokes `getPrice` method on a native NameService contract.
|
||||
func (c *Client) GetNNSPrice() (int64, error) {
|
||||
nnsHash, err := c.GetNativeContractHash(nativenames.NameService)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to get native NameService hash: %w", err)
|
||||
}
|
||||
return c.invokeNativeGetMethod(nnsHash, "getPrice")
|
||||
}
|
||||
|
|
|
@ -452,6 +452,18 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
},
|
||||
},
|
||||
},
|
||||
"getNNSPrice": {
|
||||
{
|
||||
name: "positive",
|
||||
invoke: func(c *Client) (interface{}, error) {
|
||||
return c.GetNNSPrice()
|
||||
},
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"state":"HALT","gasconsumed":"2007390","script":"EMAMDWdldEZlZVBlckJ5dGUMFJphpG7sl7iTBtfOgfFbRiCR0AkyQWJ9W1I=","stack":[{"type":"Integer","value":"1000000"}],"tx":null}}`,
|
||||
result: func(c *Client) interface{} {
|
||||
return int64(1000000)
|
||||
},
|
||||
},
|
||||
},
|
||||
"getMaxNotValidBeforeDelta": {
|
||||
{
|
||||
name: "positive",
|
||||
|
|
Loading…
Reference in a new issue