Documentation ¶
Overview ¶
'root' a core contract on the chain. It is responsible for: - initial setup of the chain during chain deployment - maintaining of core parameters of the chain - maintaining (setting, delegating) chain owner ID - maintaining (granting, revoking) smart contract deployment rights - deployment of smart contracts on the chain and maintenance of contract registry
Index ¶
- Constants
- Variables
- func CheckAuthorizationByChainOwner(state kv.KVStore, agentID coretypes.AgentID) bool
- func DecodeContractRegistry(contractRegistry *collections.ImmutableMap) (map[coretypes.Hname]*ContractRecord, error)
- func EncodeContractRecord(p *ContractRecord) []byte
- func GetDefaultFeeInfo(state kv.KVStoreReader) (balance.Color, int64, int64, error)
- func GetFeeInfo(state kv.KVStoreReader, hname coretypes.Hname) (balance.Color, int64, int64)
- func GetFeeInfoByContractRecord(state kv.KVStoreReader, rec *ContractRecord) (balance.Color, int64, int64)
- type ChainInfo
- type ContractRecord
Constants ¶
const ( VarStateInitialized = "i" VarChainID = "c" VarChainColor = "co" VarChainAddress = "ad" VarChainOwnerID = "o" VarFeeColor = "f" VarDefaultOwnerFee = "do" VarDefaultValidatorFee = "dv" VarChainOwnerIDDelegated = "n" VarContractRegistry = "r" VarDescription = "d" VarDeployPermissions = "dep" )
state variables
const ( ParamChainID = "$$chainid$$" ParamChainColor = "$$color$$" ParamChainAddress = "$$address$$" ParamChainOwner = "$$owner$$" ParamProgramHash = "$$proghash$$" ParamDescription = "$$description$$" ParamHname = "$$hname$$" ParamName = "$$name$$" ParamData = "$$data$$" ParamFeeColor = "$$feecolor$$" ParamOwnerFee = "$$ownerfee$$" ParamValidatorFee = "$$validatorfee$$" ParamDeployer = "$$deployer$$" )
param variables
const ( FuncDeployContract = "deployContract" FuncFindContract = "findContract" FuncGetChainInfo = "getChainInfo" FuncDelegateChainOwnership = "delegateChainOwnership" FuncClaimChainOwnership = "claimChainOwnership" FuncGetFeeInfo = "getFeeInfo" FuncSetDefaultFee = "setDefaultFee" FuncSetContractFee = "setContractFee" FuncGrantDeploy = "grantDeployPermission" FuncRevokeDeploy = "revokeDeployPermission" )
function names
const (
Name = "root"
)
Variables ¶
var ( Interface = &coreutil.ContractInterface{ Name: Name, Description: description, ProgramHash: hashing.HashStrings(Name), } ErrContractNotFound = errors.New("smart contract not found") )
Functions ¶
func DecodeContractRegistry ¶
func DecodeContractRegistry(contractRegistry *collections.ImmutableMap) (map[coretypes.Hname]*ContractRecord, error)
DecodeContractRegistry encodes the whole contract registry from the map into a Go map.
func EncodeContractRecord ¶
func EncodeContractRecord(p *ContractRecord) []byte
func GetDefaultFeeInfo ¶
func GetFeeInfo ¶
GetFeeInfo is an internal utility function which returns fee info for the contract It is called from within the 'root' contract as well as VMContext and viewcontext objects It is not exposed to the sandbox
func GetFeeInfoByContractRecord ¶
func GetFeeInfoByContractRecord(state kv.KVStoreReader, rec *ContractRecord) (balance.Color, int64, int64)
Types ¶
type ChainInfo ¶
type ChainInfo struct { ChainID coretypes.ChainID ChainOwnerID coretypes.AgentID ChainColor balance.Color ChainAddress address.Address Description string FeeColor balance.Color DefaultOwnerFee int64 DefaultValidatorFee int64 }
ChainInfo is an API structure which contains main properties of the chain in on place
func MustGetChainInfo ¶
func MustGetChainInfo(state kv.KVStoreReader) ChainInfo
MustGetChainInfo return global variables of the chain
type ContractRecord ¶
type ContractRecord struct { // The ProgramHash uniquely defines the program of the smart contract // It is interpreted either as one of builtin contracts (including examples) // or a hash (reference) to the of the blob in 'blob' contract in the 'program binary' format, // i.e. with at least 2 pre-defined fields: // - VarFieldVType // - VarFieldProgramBinary ProgramHash hashing.HashValue // Description of the instance Description string // Unique name of the contract on the chain. The real identity of the instance on the chain // is hname(name) = coretypes.Hn(name) Name string // Chain owner part of the fee. If it is 0, it means chain-global default is in effect OwnerFee int64 // Validator part of the fee. If it is 0, it means chain-global default is in effect ValidatorFee int64 // validator part of the fee // The agentID of the entity which deployed the instance. It can be interpreted as // an priviledged user of the instance, however it is up to the smart contract. Creator coretypes.AgentID }
ContractRecord is a structure which contains metadata of the deployed contract instance
func DecodeContractRecord ¶
func DecodeContractRecord(data []byte) (*ContractRecord, error)
func FindContract ¶
func FindContract(state kv.KVStoreReader, hname coretypes.Hname) (*ContractRecord, error)
FindContract is an internal utility function which finds a contract in the KVStore It is called from within the 'root' contract as well as VMContext and viewcontext objects It is not directly exposed to the sandbox
func NewContractRecord ¶
func NewContractRecord(itf *coreutil.ContractInterface, creator coretypes.AgentID) (ret ContractRecord)
func (*ContractRecord) HasCreator ¶
func (p *ContractRecord) HasCreator() bool
func (*ContractRecord) Hname ¶
func (p *ContractRecord) Hname() coretypes.Hname