centchain

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrCentChainTransaction is a generic error type to be used for CentChain errors
	ErrCentChainTransaction = errors.Error("error on centchain tx layer")

	// ErrNonceTooLow nonce is too low
	ErrNonceTooLow = errors.Error("Priority is too low")

	// ErrInvalidTransaction wrapper for a general error
	// Used sometimes as stale extrinsic (nonce too low)
	ErrInvalidTransaction = errors.Error("Invalid Transaction")
)
View Source
const (
	// ErrExtrinsic is a generic error type to be used for cent-chain errors
	ErrExtrinsic = errors.Error("error on cent-chain tx layer")

	// ErrBlockNotReady error when block is not ready yet
	ErrBlockNotReady = errors.Error("required result to be 32 bytes, but got 0")
)
View Source
const (
	// ExtrinsicStatusTaskName contains the name of the task
	ExtrinsicStatusTaskName string = "ExtrinsicStatusTaskName"

	// TransactionExtHashParam contains the name of the parameter
	TransactionExtHashParam string = "ExtHashParam"

	// TransactionFromBlockParam contains the name of the parameter
	TransactionFromBlockParam string = "FromBlockParam"

	// TransactionExtSignatureParam contains the name of the parameter
	TransactionExtSignatureParam string = "ExtSignatureParam"

	// TransactionAccountParam contains the name  of the account
	TransactionAccountParam string = "Account ID"
)
View Source
const BootstrappedCentChainClient string = "BootstrappedCentChainClient"

BootstrappedCentChainClient is a key to mapped client in bootstrap context.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {

	// Call allows to make a read operation
	Call(result interface{}, method string, args ...interface{}) error

	// GetMetadataLatest returns latest metadata from the centrifuge chain.
	GetMetadataLatest() (*types.Metadata, error)

	// SubmitExtrinsic signs the given call with the provided KeyRingPair and submits an extrinsic.
	// Returns transaction hash, latest block number before extrinsic submission, and signature attached with the extrinsic.
	SubmitExtrinsic(ctx context.Context, meta *types.Metadata, c types.Call, krp signature.KeyringPair) (txHash types.Hash, bn types.BlockNumber, sig types.MultiSignature, err error)

	// SubmitAndWatch returns function that submits and watches an extrinsic, implements transaction.Submitter
	SubmitAndWatch(ctx context.Context, meta *types.Metadata, c types.Call, krp signature.KeyringPair) func(accountID identity.DID, jobID jobs.JobID, jobMan jobs.Manager, errOut chan<- error)
}

API exposes required functions to interact with Centrifuge Chain.

func NewAPI

func NewAPI(sapi SubstrateAPI, config Config, queueSrv *queue.Server) API

NewAPI returns a new centrifuge chain api.

type Bootstrapper

type Bootstrapper struct{}

Bootstrapper implements bootstrap.Bootstrapper.

func (Bootstrapper) Bootstrap

func (Bootstrapper) Bootstrap(context map[string]interface{}) error

Bootstrap initialises centchain client.

type Config

type Config interface {
	GetCentChainIntervalRetry() time.Duration
	GetCentChainMaxRetries() int
	GetCentChainAccount() (acc config.CentChainAccount, err error)
}

Config defines functions to get centchain details

type EventChainWhitelisted

type EventChainWhitelisted struct {
	Phase       types.Phase
	Destination types.U8
	Topics      []types.Hash
}

EventChainWhitelisted is emitted when a new chain has been whitelisted to interact with the bridge

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 EventFungibleTransfer

type EventFungibleTransfer struct {
	Phase        types.Phase
	Destination  types.U8
	DepositNonce types.U64
	ResourceID   types.Bytes32
	Amount       types.U32
	Recipient    types.Bytes
	Topics       []types.Hash
}

EventFungibleTransfer is emitted when a bridge fungible token transfer is executed

type EventGenericTransfer

type EventGenericTransfer struct {
	Phase        types.Phase
	Destination  types.U8
	DepositNonce types.U64
	ResourceID   types.Bytes32
	Metadata     types.Bytes
	Topics       []types.Hash
}

EventGenericTransfer is emitted when a bridge generic transfer is executed

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 EventNonFungibleTransfer

type EventNonFungibleTransfer struct {
	Phase        types.Phase
	Destination  types.U8
	DepositNonce types.U64
	ResourceID   types.Bytes32
	TokenID      types.Bytes
	Recipient    types.Bytes
	Metadata     types.Bytes
	Topics       []types.Hash
}

EventNonFungibleTransfer is emitted when a bridge non fungible token transfer is executed

type EventRelayerAdded

type EventRelayerAdded struct {
	Phase   types.Phase
	Relayer types.AccountID
	Topics  []types.Hash
}

EventRelayerAdded is emitted when a new bridge relayer has been whitelisted

type EventRelayerThresholdChanged

type EventRelayerThresholdChanged struct {
	Phase     types.Phase
	Threshold types.U32
	Topics    []types.Hash
}

EventRelayerThresholdChanged is emitted when the relayer threshold is changed

type Events

type Events struct {
	types.EventRecords
	ChainBridge_FungibleTransfer        []EventFungibleTransfer               //nolint:stylecheck,golint
	ChainBridge_NonFungibleTransfer     []EventNonFungibleTransfer            //nolint:stylecheck,golint
	ChainBridge_GenericTransfer         []EventGenericTransfer                //nolint:stylecheck,golint
	ChainBridge_ChainWhitelisted        []EventChainWhitelisted               //nolint:stylecheck,golint
	ChainBridge_RelayerAdded            []EventRelayerAdded                   //nolint:stylecheck,golint
	ChainBridge_RelayerThresholdChanged []EventRelayerThresholdChanged        //nolint:stylecheck,golint
	Nfts_DepositAsset                   []EventNFTDeposited                   //nolint:stylecheck,golint
	Council_Proposed                    []types.EventCollectiveProposed       //nolint:stylecheck,golint
	Council_Voted                       []types.EventCollectiveProposed       //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
}

Events holds the default events and custom events for centrifuge chain

type ExtrinsicStatusTask

type ExtrinsicStatusTask struct {
	jobsv1.BaseTask
	// contains filtered or unexported fields
}

ExtrinsicStatusTask struct for the task to check a cent-chain transaction

func NewExtrinsicStatusTask

func NewExtrinsicStatusTask(
	intervalRetry time.Duration,
	maxRetries int,
	txService jobs.Manager,
	getBlockHash func(blockNumber uint64) (types.Hash, error),
	getBlock func(blockHash types.Hash) (*types.SignedBlock, error),
	getMetadataLatest func() (*types.Metadata, error),
	getStorage func(key types.StorageKey, target interface{}, blockHash types.Hash) error,
) *ExtrinsicStatusTask

NewExtrinsicStatusTask returns a the struct for the task

func (*ExtrinsicStatusTask) Copy

Copy returns a new instance of extrinsicStatusTask

func (*ExtrinsicStatusTask) ParseKwargs

func (est *ExtrinsicStatusTask) ParseKwargs(kwargs map[string]interface{}) (err error)

ParseKwargs - define a method to parse gocelery params

func (*ExtrinsicStatusTask) RunTask

func (est *ExtrinsicStatusTask) RunTask() (resp interface{}, err error)

RunTask calls listens to events from cent-chain client related to extrinsicStatusTask and records result.

func (*ExtrinsicStatusTask) TaskTypeName

func (est *ExtrinsicStatusTask) TaskTypeName() string

TaskTypeName returns ExtrinsicStatusTaskName

type SubstrateAPI

type SubstrateAPI interface {
	GetMetadataLatest() (*types.Metadata, error)
	Call(result interface{}, method string, args ...interface{}) error
	GetBlockHash(blockNumber uint64) (types.Hash, error)
	GetBlockLatest() (*types.SignedBlock, error)
	GetRuntimeVersionLatest() (*types.RuntimeVersion, error)
	GetClient() client.Client
	GetStorageLatest(key types.StorageKey, target interface{}) error
	GetStorage(key types.StorageKey, target interface{}, blockHash types.Hash) error
	GetBlock(blockHash types.Hash) (*types.SignedBlock, error)
}

SubstrateAPI exposes Substrate API functions

type TimePoint

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

TimePoint contains height and index

Jump to

Keyboard shortcuts

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