From a7c45fdd0d61d02efb747ded61daba322a671712 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 11 Jan 2024 15:36:55 +0300 Subject: [PATCH] [#68] policy: Add Version() method Signed-off-by: Evgenii Stratonikov --- policy/config.yml | 1 + policy/policy_contract.go | 5 +++++ rpcclient/policy/client.go | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/policy/config.yml b/policy/config.yml index 27ca4bd..94ab0d3 100644 --- a/policy/config.yml +++ b/policy/config.yml @@ -4,3 +4,4 @@ safemethods: - "listChains" - "getChain" - "listChainsByPrefix" + - "version" diff --git a/policy/policy_contract.go b/policy/policy_contract.go index 89b0ae8..f66646b 100644 --- a/policy/policy_contract.go +++ b/policy/policy_contract.go @@ -58,6 +58,11 @@ func checkAuthorization(ctx storage.Context) { panic(ErrNotAuthorized) } +// Version returns the version of the contract. +func Version() int { + return common.Version +} + func SetAdmin(addr interop.Hash160) { common.CheckAlphabetWitness() diff --git a/rpcclient/policy/client.go b/rpcclient/policy/client.go index 9dd9ca6..4174dcb 100644 --- a/rpcclient/policy/client.go +++ b/rpcclient/policy/client.go @@ -72,6 +72,11 @@ func (c *ContractReader) ListChainsByPrefix(entity *big.Int, entityName string, return unwrap.Array(c.invoker.Call(c.hash, "listChainsByPrefix", entity, entityName, prefix)) } +// Version invokes `version` method of contract. +func (c *ContractReader) Version() (*big.Int, error) { + return unwrap.BigInt(c.invoker.Call(c.hash, "version")) +} + // AddChain creates a transaction invoking `addChain` method of the contract. // This transaction is signed and immediately sent to the network. // The values returned are its hash, ValidUntilBlock value and error if any.