contracts

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2021 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PROPOSAL_PREFIX = "proposal-"

	AppchainMgr ProposalType = "AppchainMgr"
	RuleMgr     ProposalType = "RuleMgr"
	NodeMgr     ProposalType = "NodeMgr"
	ServiceMgr  ProposalType = "ServiceMgr"

	PROPOSED ProposalStatus = "proposed"
	APPOVED  ProposalStatus = "approve"
	REJECTED ProposalStatus = "reject"
	PAUSED   ProposalStatus = "pause"

	BallotApprove = "approve"
	BallotReject  = "reject"
)
View Source
const (
	AppchainNotAvailable = "appchain not available"
	InvalidIBTP          = "invalid ibtp"
)
View Source
const (
	InCounterKey  = "InCounter"
	OutCounterKey = "OutCounter"
	InMessageKey  = "InMessage"
	OutMessageKey = "OutMessage"
	Locked        = true
)
View Source
const PREFIX = "tx-"

Variables

This section is empty.

Functions

func AppchainKey added in v1.0.1

func AppchainKey(id string) string

func AssetExchangeKey added in v1.0.1

func AssetExchangeKey(id string) string

func ProposalKey added in v1.6.0

func ProposalKey(id string) string

Key ====================================================================

func RuleKey added in v1.0.1

func RuleKey(id string) string

Types

type AppchainManager

type AppchainManager struct {
	boltvm.Stub
	appchainMgr.AppchainManager
}

func (*AppchainManager) ActivateAppchain added in v1.6.1

func (am *AppchainManager) ActivateAppchain(id string) *boltvm.Response

ActivateAppchain updates freezing appchain

func (*AppchainManager) Appchains

func (am *AppchainManager) Appchains() *boltvm.Response

Appchains returns all appchains

func (*AppchainManager) CountAppchains

func (am *AppchainManager) CountAppchains() *boltvm.Response

CountAppchains counts all appchains including approved, rejected or registered

func (*AppchainManager) CountAvailableAppchains added in v1.6.0

func (am *AppchainManager) CountAvailableAppchains() *boltvm.Response

CountAvailableAppchains counts all available appchains

func (*AppchainManager) DeleteAppchain

func (am *AppchainManager) DeleteAppchain(toDeleteMethod string) *boltvm.Response

func (*AppchainManager) FreezeAppchain added in v1.6.1

func (am *AppchainManager) FreezeAppchain(id string) *boltvm.Response

FreezeAppchain freezes available appchain

func (*AppchainManager) GetAppchain

func (am *AppchainManager) GetAppchain(id string) *boltvm.Response

GetAppchain returns appchain info by appchain id

func (*AppchainManager) GetPubKeyByChainID

func (am *AppchainManager) GetPubKeyByChainID(id string) *boltvm.Response

GetPubKeyByChainID can get aim chain's public key using aim chain ID

func (*AppchainManager) IsAdmin

func (am *AppchainManager) IsAdmin() *boltvm.Response

func (*AppchainManager) IsAvailable added in v1.6.1

func (am *AppchainManager) IsAvailable(chainId string) *boltvm.Response

func (*AppchainManager) LogoutAppchain added in v1.6.1

func (am *AppchainManager) LogoutAppchain(id string) *boltvm.Response

LogoutAppchain updates available appchain

func (*AppchainManager) Manage added in v1.8.0

func (am *AppchainManager) Manage(eventTyp string, proposalResult string, extra []byte) *boltvm.Response

extra: appchainMgr.Appchain

func (*AppchainManager) Register

func (am *AppchainManager) Register(appchainAdminDID, appchainMethod string, docAddr, docHash, validators string,
	consensusType, chainType, name, desc, version, pubkey string) *boltvm.Response

Register registers appchain info caller is the appchain manager address return appchain id, proposal id and error

func (*AppchainManager) UpdateAppchain

func (am *AppchainManager) UpdateAppchain(id, docAddr, docHash, validators string, consensusType, chainType,
	name, desc, version, pubkey string) *boltvm.Response

UpdateAppchain updates available appchain

type AssetExchange added in v1.0.1

type AssetExchange struct {
	boltvm.Stub
}

func (*AssetExchange) GetStatus added in v1.0.1

func (t *AssetExchange) GetStatus(id string) *boltvm.Response

func (*AssetExchange) Init added in v1.0.1

func (t *AssetExchange) Init(from, to string, info []byte) *boltvm.Response

func (*AssetExchange) Redeem added in v1.0.1

func (t *AssetExchange) Redeem(from, to string, info []byte) *boltvm.Response

func (*AssetExchange) Refund added in v1.0.1

func (t *AssetExchange) Refund(from, to string, info []byte) *boltvm.Response

type AssetExchangeRecord added in v1.0.1

type AssetExchangeRecord struct {
	Chain0 string
	Chain1 string
	Status AssetExchangeStatus
	Info   pb.AssetExchangeInfo
}

type AssetExchangeStatus added in v1.0.1

type AssetExchangeStatus uint64
const (
	ASSET_PREFIX                            = "asset-"
	AssetExchangeInit   AssetExchangeStatus = 0
	AssetExchangeRedeem AssetExchangeStatus = 1
	AssetExchangeRefund AssetExchangeStatus = 2
)

type AssetExchangeType added in v1.0.1

type AssetExchangeType uint64

type Ballot added in v1.6.0

type Ballot struct {
	VoterAddr string `json:"voter_addr"`
	Approve   string `json:"approve"`
	Num       uint64 `json:"num"`
	Reason    string `json:"reason"`
}

type BxhValidators added in v1.0.1

type BxhValidators struct {
	Addresses []string `json:"addresses"`
}

type Governance added in v1.6.0

type Governance struct {
	boltvm.Stub
}

func (*Governance) GetAgainst added in v1.6.0

func (g *Governance) GetAgainst(id string) *boltvm.Response

Get negative vote information

func (*Governance) GetAgainstNum added in v1.6.0

func (g *Governance) GetAgainstNum(id string) *boltvm.Response

Get the total number of negative votes

func (*Governance) GetApprove added in v1.6.0

func (g *Governance) GetApprove(id string) *boltvm.Response

Get affirmative vote information

func (*Governance) GetApproveNum added in v1.6.0

func (g *Governance) GetApproveNum(id string) *boltvm.Response

Get the total number of affirmative votes

func (*Governance) GetBallot added in v1.6.0

func (g *Governance) GetBallot(voterAddr, proposalId string) *boltvm.Response

func (*Governance) GetDes added in v1.6.0

func (g *Governance) GetDes(id string) *boltvm.Response

Get proposal description information

func (*Governance) GetElectorateNum added in v1.6.0

func (g *Governance) GetElectorateNum(id string) *boltvm.Response

Get the number of total votes, include all votes cast and all votes not cast

func (*Governance) GetProposal added in v1.6.0

func (g *Governance) GetProposal(id string) *boltvm.Response

GetProposal query proposal by id

func (*Governance) GetProposalStrategy added in v1.6.0

func (g *Governance) GetProposalStrategy(pt string) *boltvm.Response

func (*Governance) GetProposalStrategyType added in v1.6.0

func (g *Governance) GetProposalStrategyType(pt string) *boltvm.Response

func (*Governance) GetProposalsByFrom added in v1.6.0

func (g *Governance) GetProposalsByFrom(from string) *boltvm.Response

Query proposals by proposal type, returning a list of proposal for that type

func (*Governance) GetProposalsByObjId added in v1.8.0

func (g *Governance) GetProposalsByObjId(objId string) *boltvm.Response

Query proposals by the ID of the managed chain, returning a list of proposal for that type

func (*Governance) GetProposalsByStatus added in v1.6.0

func (g *Governance) GetProposalsByStatus(status string) *boltvm.Response

Query proposals based on proposal status, returning a list of proposal for that status

func (*Governance) GetProposalsByTyp added in v1.6.0

func (g *Governance) GetProposalsByTyp(typ string) *boltvm.Response

Query proposals by proposal type, returning a list of proposal for that type

func (*Governance) GetStatus added in v1.6.0

func (g *Governance) GetStatus(id string) *boltvm.Response

Get proposal status

func (*Governance) GetThresholdNum added in v1.6.0

func (g *Governance) GetThresholdNum(id string) *boltvm.Response

Get the minimum number of votes required for the current voting strategy

func (*Governance) GetTyp added in v1.6.0

func (g *Governance) GetTyp(id string) *boltvm.Response

Get Proposal Type

func (*Governance) GetUnvote added in v1.6.0

func (g *Governance) GetUnvote(id string) *boltvm.Response

Get Unvoted information

func (*Governance) GetUnvoteNum added in v1.6.0

func (g *Governance) GetUnvoteNum(id string) *boltvm.Response

Get Unvoted information

func (*Governance) GetVoted added in v1.6.0

func (g *Governance) GetVoted(id string) *boltvm.Response

Get voted information

func (*Governance) GetVotedNum added in v1.6.0

func (g *Governance) GetVotedNum(id string) *boltvm.Response

Get the number of people who have voted

func (*Governance) NewProposalStrategy added in v1.6.0

func (g *Governance) NewProposalStrategy(typ string, participateThreshold float64, extra []byte) *boltvm.Response

func (*Governance) SetProposalStrategy added in v1.6.0

func (g *Governance) SetProposalStrategy(pt string, psData []byte) *boltvm.Response

set proposal strategy for a proposal type

func (*Governance) SubmitProposal added in v1.6.0

func (g *Governance) SubmitProposal(from, eventTyp, des, typ, objId string, extra []byte) *boltvm.Response

func (*Governance) Vote added in v1.6.0

func (g *Governance) Vote(id, approve string, reason string) *boltvm.Response

Add someone's voting information (each person can only vote once)

func (*Governance) WithdrawProposal added in v1.8.0

func (g *Governance) WithdrawProposal(id string) *boltvm.Response

Withdraw the proposal

type InterRelayBroker added in v1.5.0

type InterRelayBroker struct {
	boltvm.Stub
}

InterRelayBroker manages all interchain ibtp meta data produced on relaychain, similar to broker contract on appchain.

func (*InterRelayBroker) GetInCouterMap added in v1.5.0

func (ibroker *InterRelayBroker) GetInCouterMap() *boltvm.Response

GetInCouterMap .

func (*InterRelayBroker) GetOutCouterMap added in v1.5.0

func (ibroker *InterRelayBroker) GetOutCouterMap() *boltvm.Response

GetOutCouterMap gets an index map, which implicates the greatest index of

func (*InterRelayBroker) GetOutMessage added in v1.5.0

func (ibroker *InterRelayBroker) GetOutMessage(destChain string, index uint64) *boltvm.Response

GetOutMessage returns interchain ibtp by index and target chain_id

func (*InterRelayBroker) GetOutMessageMap added in v1.5.0

func (ibroker *InterRelayBroker) GetOutMessageMap() *boltvm.Response

GetOutMessageMap returns interchain-message(ibtp) map

func (*InterRelayBroker) IncInCounter added in v1.5.0

func (ibroker *InterRelayBroker) IncInCounter(from string) *boltvm.Response

IncInCounter increases InCounter[from] by once

func (*InterRelayBroker) InvokeInterRelayContract added in v1.5.0

func (ibroker *InterRelayBroker) InvokeInterRelayContract(addr string, fun string, args []byte) *boltvm.Response

InvokeInterRelayContract receives inter-relaychain execution call and invokes

func (*InterRelayBroker) RecordIBTPs added in v1.5.0

func (ibroker *InterRelayBroker) RecordIBTPs(ibtpsBytes []byte) *boltvm.Response

RecordIBTPs receives ibtps, adds index for them, and stores in counter and message maps, called by inter-relaychain ibtp producer contracts

type InterchainManager

type InterchainManager struct {
	boltvm.Stub
}

func (*InterchainManager) DeleteInterchain

func (x *InterchainManager) DeleteInterchain(id string) *boltvm.Response

func (*InterchainManager) GetIBTPByID

func (x *InterchainManager) GetIBTPByID(id string) *boltvm.Response

func (*InterchainManager) GetInterchain added in v1.0.1

func (x *InterchainManager) GetInterchain(id string) *boltvm.Response

GetInterchain returns information of the interchain count, Receipt count and SourceReceipt count by id

func (*InterchainManager) HandleIBTP

func (x *InterchainManager) HandleIBTP(ibtp *pb.IBTP) *boltvm.Response

func (*InterchainManager) HandleIBTPs added in v1.0.1

func (x *InterchainManager) HandleIBTPs(data []byte) *boltvm.Response

func (*InterchainManager) Interchain

func (x *InterchainManager) Interchain(method string) *boltvm.Response

Interchain returns information of the interchain count, Receipt count and SourceReceipt count

func (*InterchainManager) ProcessIBTP added in v1.0.1

func (x *InterchainManager) ProcessIBTP(ibtp *pb.IBTP, interchain *pb.Interchain)

func (*InterchainManager) Register

func (x *InterchainManager) Register(method string) *boltvm.Response

type Permission added in v1.6.1

type Permission string

Permission manager

const (
	PermissionSelf      Permission = "PermissionSelf"
	PermissionAdmin     Permission = "PermissionAdmin"
	PermissionSelfAdmin Permission = "PermissionSelfAdmin"
	PermissionSpecific  Permission = "PermissionSpecific"
)

type Proposal added in v1.6.0

type Proposal struct {
	Id     string         `json:"id"`
	Des    string         `json:"des"`
	Typ    ProposalType   `json:"typ"`
	Status ProposalStatus `json:"status"`
	ObjId  string         `json:"obj_id`
	// ballot information: voter address -> ballot
	BallotMap      map[string]Ballot    `json:"ballot_map"`
	ApproveNum     uint64               `json:"approve_num"`
	AgainstNum     uint64               `json:"against_num"`
	ElectorateNum  uint64               `json:"electorate_num"`
	ThresholdNum   uint64               `json:"threshold_num"`
	EventType      governance.EventType `json:"event_type"`
	EndReason      string               `json:"end_reason"`
	LockProposalId string               `json:"lock_proposal_id"`
	Extra          []byte               `json:"extra"`
}

type ProposalStatus added in v1.6.0

type ProposalStatus string

type ProposalStrategy added in v1.6.0

type ProposalStrategy struct {
	Typ ProposalStrategyType `json:"typ"`
	// The minimum participation threshold.
	// Only when the number of voting participants reaches this proportion,
	// the proposal will take effect. That is, the proposal can be judged
	// according to the voting situation.
	ParticipateThreshold float64 `json:"participate_threshold"`
	Extra                []byte  `json:"extra"`
}

type ProposalStrategyType added in v1.6.0

type ProposalStrategyType string
const (
	SuperMajorityApprove ProposalStrategyType = "SuperMajorityApprove"
	SuperMajorityAgainst ProposalStrategyType = "SuperMajorityAgainst"
	SimpleMajority       ProposalStrategyType = "SimpleMajority"
)

type ProposalType added in v1.6.0

type ProposalType string

type RegisterResult added in v1.6.0

type RegisterResult struct {
	ChainID    string `json:"chain_id"`
	ProposalID string `json:"proposal_id"`
}

type Role

type Role struct {
	boltvm.Stub
}

func (*Role) CheckPermission added in v1.6.1

func (r *Role) CheckPermission(permission string, regulatedAddr string, regulatorAddr string, specificAddrsData []byte) *boltvm.Response

func (*Role) GetAdminRoles

func (r *Role) GetAdminRoles() *boltvm.Response

func (*Role) GetRole

func (r *Role) GetRole() *boltvm.Response

func (*Role) GetRoleWeight added in v1.6.0

func (r *Role) GetRoleWeight(address string) *boltvm.Response

func (*Role) IsAdmin

func (r *Role) IsAdmin(address string) *boltvm.Response

func (*Role) SetAdminRoles

func (r *Role) SetAdminRoles(addrs string) *boltvm.Response

type RuleManager

type RuleManager struct {
	boltvm.Stub
	ruleMgr.RuleManager
}

RuleManager is the contract manage validation rules

func (*RuleManager) ActivateRule added in v1.8.0

func (rm *RuleManager) ActivateRule(chainId string, ruleAddress string) *boltvm.Response

ActivateRule activate the validation rule address with the chain id

func (*RuleManager) BindRule added in v1.8.0

func (rm *RuleManager) BindRule(chainId string, ruleAddress string) *boltvm.Response

BindRule binds the validation rule address with the chain id

func (*RuleManager) CountAvailableRules added in v1.8.0

func (rm *RuleManager) CountAvailableRules(chainId string) *boltvm.Response

CountAvailableRules counts all available rules (should be 0 or 1)

func (*RuleManager) CountRules added in v1.8.0

func (rm *RuleManager) CountRules(chainId string) *boltvm.Response

CountRules counts all rules of a chain

func (*RuleManager) FreezeRule added in v1.8.0

func (rm *RuleManager) FreezeRule(chainId string, ruleAddress string) *boltvm.Response

FreezeRule freezes the validation rule address with the chain id

func (*RuleManager) GetAvailableRuleAddr added in v1.8.0

func (rm *RuleManager) GetAvailableRuleAddr(chainId, chainType string) *boltvm.Response

GetRule returns available rule address by appchain id and rule address

func (*RuleManager) GetRuleByAddr added in v1.8.0

func (rm *RuleManager) GetRuleByAddr(chainId, ruleAddr string) *boltvm.Response

GetRule returns available rule address by appchain id and rule address

func (*RuleManager) IsAvailableRule added in v1.8.0

func (rm *RuleManager) IsAvailableRule(chainId, ruleAddress string) *boltvm.Response

func (*RuleManager) LogoutRule added in v1.8.0

func (rm *RuleManager) LogoutRule(chainId string, ruleAddress string) *boltvm.Response

LogoutRule logout the validation rule address with the chain id

func (*RuleManager) Manage added in v1.8.0

func (rm *RuleManager) Manage(eventTyp string, proposalResult string, extra []byte) *boltvm.Response

extra: ruleMgr.rule

func (*RuleManager) Rules added in v1.8.0

func (rm *RuleManager) Rules(chainId string) *boltvm.Response

Rules returns all rules of a chain

func (*RuleManager) UnbindRule added in v1.8.0

func (rm *RuleManager) UnbindRule(chainId string, ruleAddress string) *boltvm.Response

UnbindRule unbinds the validation rule address with the chain id

type Store

type Store struct {
	boltvm.Stub
}

func (*Store) Get

func (s *Store) Get(key string) *boltvm.Response

func (*Store) Set

func (s *Store) Set(key string, value string) *boltvm.Response

type TransactionInfo added in v1.0.1

type TransactionInfo struct {
	GlobalState pb.TransactionStatus
	ChildTxInfo map[string]pb.TransactionStatus
}

type TransactionManager added in v1.0.1

type TransactionManager struct {
	boltvm.Stub
}

func (*TransactionManager) Begin added in v1.0.1

func (t *TransactionManager) Begin(txId string) *boltvm.Response

func (*TransactionManager) BeginMultiTXs added in v1.0.1

func (t *TransactionManager) BeginMultiTXs(globalId string, childTxIds ...string) *boltvm.Response

func (*TransactionManager) GetStatus added in v1.0.1

func (t *TransactionManager) GetStatus(txId string) *boltvm.Response

func (*TransactionManager) Report added in v1.0.1

func (t *TransactionManager) Report(txId string, result int32) *boltvm.Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL