ChainBridge¶
Calls¶
acknowledge_proposal¶
Commits a vote in favour of the provided proposal.
If a proposal with the given nonce and source chain ID does not already exist, it will be created with an initial vote in favour from the caller.
# <weight> - weight of proposed call, regardless of whether execution is performed # </weight>
Attributes¶
Name | Type |
---|---|
nonce | DepositNonce |
src_id | BridgeChainId |
r_id | ResourceId |
call | Box<<T as Config>::Proposal> |
Python¶
call = substrate.compose_call(
'ChainBridge', 'acknowledge_proposal', {
'call': 'Call',
'nonce': 'u64',
'r_id': '[u8; 32]',
'src_id': 'u8',
}
)
add_relayer¶
Adds a new relayer to the relayer set.
# <weight> - O(1) lookup and insert # </weight>
Attributes¶
Name | Type |
---|---|
v | T::AccountId |
Python¶
call = substrate.compose_call(
'ChainBridge', 'add_relayer', {'v': 'AccountId'}
)
eval_vote_state¶
Evaluate the state of a proposal given the current vote threshold.
A proposal with enough votes will be either executed or cancelled, and the status will be updated accordingly.
# <weight> - weight of proposed call, regardless of whether execution is performed # </weight>
Attributes¶
Name | Type |
---|---|
nonce | DepositNonce |
src_id | BridgeChainId |
prop | Box<<T as Config>::Proposal> |
Python¶
call = substrate.compose_call(
'ChainBridge', 'eval_vote_state', {
'nonce': 'u64',
'prop': 'Call',
'src_id': 'u8',
}
)
reject_proposal¶
Commits a vote against a provided proposal.
# <weight> - Fixed, since execution of proposal should not be included # </weight>
Attributes¶
Name | Type |
---|---|
nonce | DepositNonce |
src_id | BridgeChainId |
r_id | ResourceId |
call | Box<<T as Config>::Proposal> |
Python¶
call = substrate.compose_call(
'ChainBridge', 'reject_proposal', {
'call': 'Call',
'nonce': 'u64',
'r_id': '[u8; 32]',
'src_id': 'u8',
}
)
remove_relayer¶
Removes an existing relayer from the set.
# <weight> - O(1) lookup and removal # </weight>
Attributes¶
Name | Type |
---|---|
v | T::AccountId |
Python¶
call = substrate.compose_call(
'ChainBridge', 'remove_relayer', {'v': 'AccountId'}
)
remove_resource¶
Removes a resource ID from the resource mapping.
After this call, bridge transfers with the associated resource ID will be rejected.
# <weight> - O(1) removal # </weight>
Attributes¶
Name | Type |
---|---|
id | ResourceId |
Python¶
call = substrate.compose_call(
'ChainBridge', 'remove_resource', {'id': '[u8; 32]'}
)
set_resource¶
Stores a method name on chain under an associated resource ID.
# <weight> - O(1) write # </weight>
Attributes¶
Name | Type |
---|---|
id | ResourceId |
method | Vec<u8> |
Python¶
call = substrate.compose_call(
'ChainBridge', 'set_resource', {'id': '[u8; 32]', 'method': 'Bytes'}
)
set_threshold¶
Sets the vote threshold for proposals.
This threshold is used to determine how many votes are required before a proposal is executed.
# <weight> - O(1) lookup and insert # </weight>
Attributes¶
Name | Type |
---|---|
threshold | u32 |
Python¶
call = substrate.compose_call(
'ChainBridge', 'set_threshold', {'threshold': 'u32'}
)
update_fee¶
Change extra bridge transfer fee that user should pay
# <weight> - O(1) lookup and insert # </weight>
Attributes¶
Name | Type |
---|---|
dest_id | BridgeChainId |
fee | BalanceOf<T> |
Python¶
call = substrate.compose_call(
'ChainBridge', 'update_fee', {'dest_id': 'u8', 'fee': 'u128'}
)
whitelist_chain¶
Enables a chain ID as a source or destination for a bridge transfer.
# <weight> - O(1) lookup and insert # </weight>
Attributes¶
Name | Type |
---|---|
id | BridgeChainId |
Python¶
call = substrate.compose_call(
'ChainBridge', 'whitelist_chain', {'id': 'u8'}
)
Events¶
ChainWhitelisted¶
Chain now available for transfers (chain_id)
Attributes¶
Name | Type | Composition |
---|---|---|
None | BridgeChainId |
u8 |
FeeUpdated¶
Update bridge transfer fee
Attributes¶
Name | Type | Composition |
---|---|---|
dest_id | BridgeChainId |
u8 |
fee | BalanceOf<T> |
u128 |
FungibleTransfer¶
FungibleTransfer is for relaying fungibles (dest_id, nonce, resource_id, amount, recipient)
Attributes¶
Name | Type | Composition |
---|---|---|
None | BridgeChainId |
u8 |
None | DepositNonce |
u64 |
None | ResourceId |
[u8; 32] |
None | u128 |
u128 |
None | Vec<u8> |
Bytes |
GenericTransfer¶
GenericTransfer is for a generic data payload (dest_id, nonce, resource_id, metadata)
Attributes¶
Name | Type | Composition |
---|---|---|
None | BridgeChainId |
u8 |
None | DepositNonce |
u64 |
None | ResourceId |
[u8; 32] |
None | Vec<u8> |
Bytes |
NonFungibleTransfer¶
NonFungibleTransfer is for relaying NFTs (dest_id, nonce, resource_id, token_id, recipient, metadata)
Attributes¶
Name | Type | Composition |
---|---|---|
None | BridgeChainId |
u8 |
None | DepositNonce |
u64 |
None | ResourceId |
[u8; 32] |
None | Vec<u8> |
Bytes |
None | Vec<u8> |
Bytes |
None | Vec<u8> |
Bytes |
ProposalApproved¶
Voting successful for a proposal
Attributes¶
Name | Type | Composition |
---|---|---|
None | BridgeChainId |
u8 |
None | DepositNonce |
u64 |
ProposalFailed¶
Execution of call failed
Attributes¶
Name | Type | Composition |
---|---|---|
None | BridgeChainId |
u8 |
None | DepositNonce |
u64 |
ProposalRejected¶
Voting rejected a proposal
Attributes¶
Name | Type | Composition |
---|---|---|
None | BridgeChainId |
u8 |
None | DepositNonce |
u64 |
ProposalSucceeded¶
Execution of call succeeded
Attributes¶
Name | Type | Composition |
---|---|---|
None | BridgeChainId |
u8 |
None | DepositNonce |
u64 |
RelayerAdded¶
Relayer added to set
Attributes¶
Name | Type | Composition |
---|---|---|
None | T::AccountId |
AccountId |
RelayerRemoved¶
Relayer removed from set
Attributes¶
Name | Type | Composition |
---|---|---|
None | T::AccountId |
AccountId |
RelayerThresholdChanged¶
Vote threshold has changed (new_threshold)
Attributes¶
Name | Type | Composition |
---|---|---|
None | u32 |
u32 |
VoteAgainst¶
Vot submitted against proposal
Attributes¶
Name | Type | Composition |
---|---|---|
None | BridgeChainId |
u8 |
None | DepositNonce |
u64 |
None | T::AccountId |
AccountId |
VoteFor¶
Vote submitted in favour of proposal
Attributes¶
Name | Type | Composition |
---|---|---|
None | BridgeChainId |
u8 |
None | DepositNonce |
u64 |
None | T::AccountId |
AccountId |
Storage functions¶
BridgeEvents¶
Python¶
result = substrate.query(
'ChainBridge', 'BridgeEvents', []
)
Return value¶
[
{
'FungibleTransfer': ('u8', 'u64', '[u8; 32]', 'u128', 'Bytes'),
'GenericTransfer': ('u8', 'u64', '[u8; 32]', 'Bytes'),
'NonFungibleTransfer': (
'u8',
'u64',
'[u8; 32]',
'Bytes',
'Bytes',
'Bytes',
),
},
]
BridgeFee¶
Python¶
result = substrate.query(
'ChainBridge', 'BridgeFee', ['u8']
)
Return value¶
'u128'
ChainNonces¶
Python¶
result = substrate.query(
'ChainBridge', 'ChainNonces', ['u8']
)
Return value¶
'u64'
RelayerCount¶
Python¶
result = substrate.query(
'ChainBridge', 'RelayerCount', []
)
Return value¶
'u32'
RelayerThreshold¶
Python¶
result = substrate.query(
'ChainBridge', 'RelayerThreshold', []
)
Return value¶
'u32'
Relayers¶
Python¶
result = substrate.query(
'ChainBridge', 'Relayers', ['AccountId']
)
Return value¶
'bool'
Resources¶
Python¶
result = substrate.query(
'ChainBridge', 'Resources', ['[u8; 32]']
)
Return value¶
'Bytes'
Votes¶
Python¶
result = substrate.query(
'ChainBridge', 'Votes', ['u8', ('u64', 'Call')]
)
Return value¶
{
'expiry': 'u32',
'status': ('Initiated', 'Approved', 'Rejected'),
'votes_against': ['AccountId'],
'votes_for': ['AccountId'],
}
Constants¶
BridgeChainId¶
The identifier for this chain. This must be unique and must not collide with existing IDs within a set of bridged chains.
Value¶
2
Python¶
constant = substrate.get_constant('ChainBridge', 'BridgeChainId')
ProposalLifetime¶
Value¶
50400
Python¶
constant = substrate.get_constant('ChainBridge', 'ProposalLifetime')
Errors¶
CannotPayAsFee¶
ChainAlreadyWhitelisted¶
Chain has already been enabled
ChainNotWhitelisted¶
Interactions with this chain is not permitted
FeeDoesNotExist¶
No fee with the ID was found
FeeTooExpensive¶
Too expensive fee for withdrawn asset
InsufficientBalance¶
Balance too low to withdraw
InvalidChainId¶
Provided chain Id is not valid
InvalidThreshold¶
Relayer threshold cannot be 0
MustBeRelayer¶
Protected operation, must be performed by relayer
NonceOverFlow¶
ProposalAlreadyComplete¶
Proposal has either failed or succeeded
ProposalAlreadyExists¶
A proposal with these parameters has already been submitted
ProposalDoesNotExist¶
No proposal with the ID was found
ProposalExpired¶
Lifetime of proposal has been exceeded
ProposalNotComplete¶
Cannot complete proposal, needs more votes
RelayerAlreadyExists¶
Relayer already in set
RelayerAlreadyVoted¶
Relayer has already submitted some vote for this proposal
RelayerInvalid¶
Provided accountId is not a relayer
ResourceDoesNotExist¶
Resource ID provided isn't mapped to anything
ThresholdNotSet¶
Relayer threshold not set