[#68] policy: Add Version() method

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-01-11 15:36:55 +03:00
parent 5363aaf16a
commit a7c45fdd0d
3 changed files with 11 additions and 0 deletions

View file

@ -4,3 +4,4 @@ safemethods:
- "listChains" - "listChains"
- "getChain" - "getChain"
- "listChainsByPrefix" - "listChainsByPrefix"
- "version"

View file

@ -58,6 +58,11 @@ func checkAuthorization(ctx storage.Context) {
panic(ErrNotAuthorized) panic(ErrNotAuthorized)
} }
// Version returns the version of the contract.
func Version() int {
return common.Version
}
func SetAdmin(addr interop.Hash160) { func SetAdmin(addr interop.Hash160) {
common.CheckAlphabetWitness() common.CheckAlphabetWitness()

View file

@ -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)) 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. // AddChain creates a transaction invoking `addChain` method of the contract.
// This transaction is signed and immediately sent to the network. // This transaction is signed and immediately sent to the network.
// The values returned are its hash, ValidUntilBlock value and error if any. // The values returned are its hash, ValidUntilBlock value and error if any.