mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-28 23:27:36 +00:00
5d5455312a
And test it with the RPC server. Notice that getters still return int64 instead of *big.Int, that's because these values are very limited and technically could even fit into an int (but that seems to be too dangerous to use for long-term compatibility).
63 lines
2.2 KiB
Go
63 lines
2.2 KiB
Go
package rpcclient
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
)
|
|
|
|
// GetFeePerByte invokes `getFeePerByte` method on a native Policy contract.
|
|
//
|
|
// Deprecated: please use policy subpackage.
|
|
func (c *Client) GetFeePerByte() (int64, error) {
|
|
return c.invokeNativePolicyMethod("getFeePerByte")
|
|
}
|
|
|
|
// GetExecFeeFactor invokes `getExecFeeFactor` method on a native Policy contract.
|
|
//
|
|
// Deprecated: please use policy subpackage.
|
|
func (c *Client) GetExecFeeFactor() (int64, error) {
|
|
return c.invokeNativePolicyMethod("getExecFeeFactor")
|
|
}
|
|
|
|
// GetStoragePrice invokes `getStoragePrice` method on a native Policy contract.
|
|
//
|
|
// Deprecated: please use policy subpackage.
|
|
func (c *Client) GetStoragePrice() (int64, error) {
|
|
return c.invokeNativePolicyMethod("getStoragePrice")
|
|
}
|
|
|
|
// GetMaxNotValidBeforeDelta invokes `getMaxNotValidBeforeDelta` method on a native Notary contract.
|
|
func (c *Client) GetMaxNotValidBeforeDelta() (int64, error) {
|
|
notaryHash, err := c.GetNativeContractHash(nativenames.Notary)
|
|
if err != nil {
|
|
return 0, fmt.Errorf("failed to get native Notary hash: %w", err)
|
|
}
|
|
return c.invokeNativeGetMethod(notaryHash, "getMaxNotValidBeforeDelta")
|
|
}
|
|
|
|
// invokeNativePolicy method invokes Get* method on a native Policy contract.
|
|
func (c *Client) invokeNativePolicyMethod(operation string) (int64, error) {
|
|
policyHash, err := c.GetNativeContractHash(nativenames.Policy)
|
|
if err != nil {
|
|
return 0, fmt.Errorf("failed to get native Policy hash: %w", err)
|
|
}
|
|
return c.invokeNativeGetMethod(policyHash, operation)
|
|
}
|
|
|
|
func (c *Client) invokeNativeGetMethod(hash util.Uint160, operation string) (int64, error) {
|
|
return unwrap.Int64(c.reader.Call(hash, operation))
|
|
}
|
|
|
|
// IsBlocked invokes `isBlocked` method on native Policy contract.
|
|
//
|
|
// Deprecated: please use policy subpackage.
|
|
func (c *Client) IsBlocked(hash util.Uint160) (bool, error) {
|
|
policyHash, err := c.GetNativeContractHash(nativenames.Policy)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to get native Policy hash: %w", err)
|
|
}
|
|
return unwrap.Bool(c.reader.Call(policyHash, "isBlocked", hash))
|
|
}
|