utils

package
Version: v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const BridgePalletName = "ChainBridge"
View Source
const BridgeStoragePrefix = "ChainBridge"

Variables

This section is empty.

Functions

func BalanceOf

func BalanceOf(client *Client, publicKey []byte) (*big.Int, error)

BalanceOf returns the free balance of an account

func BatchSubmit

func BatchSubmit(client *Client, calls []types.Call) error

Batch submit take multiple calls and attempts to sumbit all of them, then waits until they complete. This should allow for the calls to be processed in a single block (to some limit). WARNING: Failed calls are not reported

func InitializeChain

func InitializeChain(client *Client, relayers []types.AccountID, chains []msg.ChainId, resources map[msg.ResourceId]Method, threshold uint32) error

func QueryConst

func QueryConst(client *Client, prefix, name string, res interface{}) error

QueryConst looks up a constant in the metadata

func QueryStorage

func QueryStorage(client *Client, prefix, method string, arg1, arg2 []byte, result interface{}) (bool, error)

func SubmitSudoTx

func SubmitSudoTx(client *Client, method Method, args ...interface{}) error

func SubmitTx

func SubmitTx(client *Client, method Method, args ...interface{}) error

Types

type AssetId

type AssetId struct {
	RegistryId RegistryId
	TokenId    TokenId
}

type Client

type Client struct {
	Api     *gsrpc.SubstrateAPI
	Meta    *types.Metadata
	Genesis types.Hash
	Key     *signature.KeyringPair
}

Client is a container for all the components required to submit extrinsics TODO: Perhaps this would benefit an interface so we can interchange Connection and a client like this

func CreateClient

func CreateClient(key *signature.KeyringPair, endpoint string) (*Client, error)

func (*Client) AddRelayer

func (c *Client) AddRelayer(relayer types.AccountID) error

func (*Client) GetDepositNonce

func (c *Client) GetDepositNonce(chain msg.ChainId) (uint64, error)

func (*Client) InitiateHashTransfer

func (c *Client) InitiateHashTransfer(hash types.Hash, destId msg.ChainId) error

func (*Client) InitiateNativeTransfer

func (c *Client) InitiateNativeTransfer(amount types.U128, recipient []byte, destId msg.ChainId) error

func (*Client) InitiateNonFungibleTransfer

func (c *Client) InitiateNonFungibleTransfer(tokenId types.U256, recipient []byte, destId msg.ChainId) error

func (*Client) LatestBlock

func (c *Client) LatestBlock() (uint64, error)

func (*Client) MintErc721

func (c *Client) MintErc721(tokenId *big.Int, metadata []byte, recipient *signature.KeyringPair) error

func (*Client) NewAddRelayerCall

func (c *Client) NewAddRelayerCall(relayer types.AccountID) (types.Call, error)

func (*Client) NewNativeTransferCall

func (c *Client) NewNativeTransferCall(amount types.U128, recipient []byte, destId msg.ChainId) (types.Call, error)

func (*Client) NewRegisterResourceCall

func (c *Client) NewRegisterResourceCall(id msg.ResourceId, method string) (types.Call, error)

func (*Client) NewSetRelayerThresholdCall

func (c *Client) NewSetRelayerThresholdCall(threshold types.U32) (types.Call, error)

func (*Client) NewSudoCall

func (c *Client) NewSudoCall(call types.Call) (types.Call, error)

func (*Client) NewWhitelistChainCall

func (c *Client) NewWhitelistChainCall(id msg.ChainId) (types.Call, error)

func (*Client) OwnerOf

func (c *Client) OwnerOf(tokenId *big.Int) (types.AccountID, error)

func (*Client) RegisterResource

func (c *Client) RegisterResource(id msg.ResourceId, method string) error

func (*Client) SetRelayerThreshold

func (c *Client) SetRelayerThreshold(threshold types.U32) error

func (*Client) WhitelistChain

func (c *Client) WhitelistChain(id msg.ChainId) error

type Erc721Token

type Erc721Token struct {
	Id       types.U256
	Metadata types.Bytes
}

func GetErc721Token

func GetErc721Token(client *Client, id types.U256) (*Erc721Token, error)

type EventErc721Burned

type EventErc721Burned struct {
	Phase   types.Phase
	TokenId types.AccountID
	Topics  []types.Hash
}

type EventErc721Minted

type EventErc721Minted struct {
	Phase   types.Phase
	Owner   types.AccountID
	TokenId types.U256
	Topics  []types.Hash
}

type EventErc721Transferred

type EventErc721Transferred struct {
	Phase   types.Phase
	From    types.AccountID
	To      types.AccountID
	TokenId types.U256
	Topics  []types.Hash
}

type EventExampleRemark

type EventExampleRemark struct {
	Phase  types.Phase
	Hash   types.Hash
	Topics []types.Hash
}

type EventFeeChanged

type EventFeeChanged struct {
	Phase    types.Phase
	Key      types.Hash
	NewPrice types.U128
	Topics   []types.Hash
}

EventFeeChanged is emitted when a fee for a given key is changed.

type EventMultiAccountRemoved

type EventMultiAccountRemoved struct {
	Phase  types.Phase
	Who    types.AccountID
	Topics []types.Hash
}

EventMultiAccountRemoved is emitted when a multi account has been removed. First param is the multisig account.

type EventMultiAccountUpdated

type EventMultiAccountUpdated struct {
	Phase  types.Phase
	Who    types.AccountID
	Topics []types.Hash
}

EventMultiAccountUpdated is emitted when a multi account has been updated. First param is the multisig account.

type EventMultisigApproval

type EventMultisigApproval struct {
	Phase     types.Phase
	Who       types.AccountID
	TimePoint TimePoint
	ID        types.AccountID
	Topics    []types.Hash
}

EventMultisigApproval is emitted when a multisig operation has been approved by someone. First param is the account that is approving, third is the multisig account.

type EventMultisigCancelled

type EventMultisigCancelled struct {
	Phase     types.Phase
	Who       types.AccountID
	TimePoint TimePoint
	ID        types.AccountID
	Topics    []types.Hash
}

EventMultisigCancelled is emitted when a multisig operation has been cancelled by someone. First param is the account that is approving, third is the multisig account.

type EventMultisigExecuted

type EventMultisigExecuted struct {
	Phase     types.Phase
	Who       types.AccountID
	TimePoint TimePoint
	ID        types.AccountID
	Result    types.DispatchResult
	Topics    []types.Hash
}

EventMultisigExecuted is emitted when a multisig operation has been executed by someone. First param is the account that is approving, third is the multisig account.

type EventNFTDeposited

type EventNFTDeposited struct {
	Phase  types.Phase
	Asset  types.Hash
	Topics []types.Hash
}

EventNFTDeposited is emitted when NFT is ready to be deposited to other chain.

type EventNewMultiAccount

type EventNewMultiAccount struct {
	Phase   types.Phase
	Who, ID types.AccountID
	Topics  []types.Hash
}

EventNewMultiAccount is emitted when a multi account has been created. First param is the account that created it, second is the multisig account.

type EventNewMultisig

type EventNewMultisig struct {
	Phase   types.Phase
	Who, ID types.AccountID
	Topics  []types.Hash
}

EventNewMultisig is emitted when a new multisig operation has begun. First param is the account that is approving, second is the multisig account.

type EventNftTransferred

type EventNftTransferred struct {
	Phase      types.Phase
	RegistryId RegistryId
	AssetId    AssetId
	Who        types.AccountID
	Topics     []types.Hash
}

EventNftTransferred is emitted when the ownership of the asset has been transferred to the account

type EventRadClaimsClaimed

type EventRadClaimsClaimed struct {
	Phase  types.Phase
	Who    types.AccountID
	Value  types.U128
	Topics []types.Hash
}

EventRadClaimsClaimed is emitted when RAD Tokens have been claimed

type EventRadClaimsRootHashStored

type EventRadClaimsRootHashStored struct {
	Phase    types.Phase
	RootHash types.Hash
	Topics   []types.Hash
}

EventRadClaimsRootHashStored is emitted when RootHash has been stored for the correspondent RAD Claims batch

type EventRegistryMint

type EventRegistryMint struct {
	Phase      types.Phase
	RegistryId RegistryId
	TokenId    TokenId
	Topics     []types.Hash
}

EventRegistryMint is emitted when successfully minting an NFT

type EventRegistryRegistryCreated

type EventRegistryRegistryCreated struct {
	Phase      types.Phase
	RegistryId RegistryId
	Topics     []types.Hash
}

EventRegistryRegistryCreated is emitted when successfully creating a NFT registry

type EventRegistryTmp

type EventRegistryTmp struct {
	Phase  types.Phase
	Hash   types.Hash
	Topics []types.Hash
}

EventRegistryTmp is emitted only for testing

type EventTreasuryMinting

type EventTreasuryMinting struct {
	Phase  types.Phase
	Who    types.AccountID
	Topics []types.Hash
}

type Events

type Events struct {
	types.EventRecords
	events.Events
	Erc721_Minted                    []EventErc721Minted                   //nolint:stylecheck,golint
	Erc721_Transferred               []EventErc721Transferred              //nolint:stylecheck,golint
	Erc721_Burned                    []EventErc721Burned                   //nolint:stylecheck,golint
	Example_Remark                   []EventExampleRemark                  //nolint:stylecheck,golint
	Nfts_DepositAsset                []EventNFTDeposited                   //nolint:stylecheck,golint
	Council_Proposed                 []types.EventCollectiveProposed       //nolint:stylecheck,golint
	Council_Voted                    []types.EventCollectiveVoted          //nolint:stylecheck,golint
	Council_Approved                 []types.EventCollectiveApproved       //nolint:stylecheck,golint
	Council_Disapproved              []types.EventCollectiveDisapproved    //nolint:stylecheck,golint
	Council_Executed                 []types.EventCollectiveExecuted       //nolint:stylecheck,golint
	Council_MemberExecuted           []types.EventCollectiveMemberExecuted //nolint:stylecheck,golint
	Council_Closed                   []types.EventCollectiveClosed         //nolint:stylecheck,golint
	Fees_FeeChanged                  []EventFeeChanged                     //nolint:stylecheck,golint
	MultiAccount_NewMultiAccount     []EventNewMultiAccount                //nolint:stylecheck,golint
	MultiAccount_MultiAccountUpdated []EventMultiAccountUpdated            //nolint:stylecheck,golint
	MultiAccount_MultiAccountRemoved []EventMultiAccountRemoved            //nolint:stylecheck,golint
	MultiAccount_NewMultisig         []EventNewMultisig                    //nolint:stylecheck,golint
	MultiAccount_MultisigApproval    []EventMultisigApproval               //nolint:stylecheck,golint
	MultiAccount_MultisigExecuted    []EventMultisigExecuted               //nolint:stylecheck,golint
	MultiAccount_MultisigCancelled   []EventMultisigCancelled              //nolint:stylecheck,golint
	TreasuryReward_TreasuryMinting   []EventTreasuryMinting                //nolint:stylecheck,golint
	Nft_Transferred                  []EventNftTransferred                 //nolint:stylecheck,golint
	RadClaims_Claimed                []EventRadClaimsClaimed               //nolint:stylecheck,golint
	RadClaims_RootHashStored         []EventRadClaimsRootHashStored        //nolint:stylecheck,golint
	Registry_Mint                    []EventRegistryMint                   //nolint:stylecheck,golint
	Registry_RegistryCreated         []EventRegistryRegistryCreated        //nolint:stylecheck,golint
	Registry_RegistryTmp             []EventRegistryTmp                    //nolint:stylecheck,golint
}

type Method

type Method string

An available method on the substrate chain

var AddRelayerMethod Method = BridgePalletName + ".add_relayer"
var Erc721MintMethod Method = "Erc721.mint"
var ExampleMintErc721Method Method = "Example.mint_erc721"
var ExampleRemarkMethod Method = "Example.remark"
var ExampleTransferErc721Method Method = "Example.transfer_erc721"
var ExampleTransferHashMethod Method = "Example.transfer_hash"
var ExampleTransferMethod Method = "Example.transfer"
var ExampleTransferNativeMethod Method = "Example.transfer_native"
var SetResourceMethod Method = BridgePalletName + ".set_resource"
var SetThresholdMethod Method = BridgePalletName + ".set_threshold"
var SudoMethod Method = "Sudo.sudo"
var WhitelistChainMethod Method = BridgePalletName + ".whitelist_chain"

type RegistryId

type RegistryId types.H160

type TimePoint

type TimePoint struct {
	Height types.U32
	Index  types.U32
}

TimePoint contains height and index

type TokenId

type TokenId types.U256

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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