2022-07-21 19:39:53 +00:00
|
|
|
package rpcclient
|
2020-06-16 12:46:28 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2020-12-13 18:25:04 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
2022-08-09 12:18:16 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
2020-06-16 12:46:28 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetFeePerByte invokes `getFeePerByte` method on a native Policy contract.
|
2022-08-15 15:44:12 +00:00
|
|
|
//
|
|
|
|
// Deprecated: please use policy subpackage.
|
2020-06-16 12:46:28 +00:00
|
|
|
func (c *Client) GetFeePerByte() (int64, error) {
|
|
|
|
return c.invokeNativePolicyMethod("getFeePerByte")
|
|
|
|
}
|
|
|
|
|
2020-12-14 09:18:59 +00:00
|
|
|
// GetExecFeeFactor invokes `getExecFeeFactor` method on a native Policy contract.
|
2022-08-15 15:44:12 +00:00
|
|
|
//
|
|
|
|
// Deprecated: please use policy subpackage.
|
2020-12-14 09:18:59 +00:00
|
|
|
func (c *Client) GetExecFeeFactor() (int64, error) {
|
|
|
|
return c.invokeNativePolicyMethod("getExecFeeFactor")
|
|
|
|
}
|
|
|
|
|
2021-03-16 19:50:14 +00:00
|
|
|
// GetStoragePrice invokes `getStoragePrice` method on a native Policy contract.
|
2022-08-15 15:44:12 +00:00
|
|
|
//
|
|
|
|
// Deprecated: please use policy subpackage.
|
2021-03-16 19:50:14 +00:00
|
|
|
func (c *Client) GetStoragePrice() (int64, error) {
|
|
|
|
return c.invokeNativePolicyMethod("getStoragePrice")
|
|
|
|
}
|
|
|
|
|
2021-02-09 08:35:45 +00:00
|
|
|
// 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.
|
2020-06-16 12:46:28 +00:00
|
|
|
func (c *Client) invokeNativePolicyMethod(operation string) (int64, error) {
|
2022-02-21 10:41:14 +00:00
|
|
|
policyHash, err := c.GetNativeContractHash(nativenames.Policy)
|
|
|
|
if err != nil {
|
|
|
|
return 0, fmt.Errorf("failed to get native Policy hash: %w", err)
|
2020-12-13 16:08:47 +00:00
|
|
|
}
|
2022-02-21 10:41:14 +00:00
|
|
|
return c.invokeNativeGetMethod(policyHash, operation)
|
2021-02-09 08:35:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Client) invokeNativeGetMethod(hash util.Uint160, operation string) (int64, error) {
|
2022-08-09 12:18:16 +00:00
|
|
|
return unwrap.Int64(c.reader.Call(hash, operation))
|
2020-06-16 12:46:28 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 12:51:59 +00:00
|
|
|
// IsBlocked invokes `isBlocked` method on native Policy contract.
|
2022-08-15 15:44:12 +00:00
|
|
|
//
|
|
|
|
// Deprecated: please use policy subpackage.
|
2020-10-21 12:51:59 +00:00
|
|
|
func (c *Client) IsBlocked(hash util.Uint160) (bool, error) {
|
2022-02-21 10:41:14 +00:00
|
|
|
policyHash, err := c.GetNativeContractHash(nativenames.Policy)
|
|
|
|
if err != nil {
|
|
|
|
return false, fmt.Errorf("failed to get native Policy hash: %w", err)
|
2020-12-13 16:08:47 +00:00
|
|
|
}
|
2022-08-09 12:18:16 +00:00
|
|
|
return unwrap.Bool(c.reader.Call(policyHash, "isBlocked", hash))
|
2020-06-16 12:46:28 +00:00
|
|
|
}
|