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 | ChainId |
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 | ChainId |
prop | Box<<T as Config>::Proposal> |
Python¶
call = substrate.compose_call(
'ChainBridge', 'eval_vote_state', {
'nonce': 'u64',
'prop': 'Call',
'src_id': 'u8',
}
)
redistribute_fees¶
Redistributes accumulated fees between relayers.
Attributes¶
No attributes
Python¶
call = substrate.compose_call(
'ChainBridge', 'redistribute_fees', {}
)
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 | ChainId |
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_fee¶
Sets fee for chain id.
After that the transfers will get the fee from runtime storage. # <weight> - O(1) write # </weight>
Attributes¶
Name | Type |
---|---|
chain_id | ChainId |
fee | T::Balance |
Python¶
call = substrate.compose_call(
'ChainBridge', 'set_fee', {'chain_id': 'u8', 'fee': 'u128'}
)
set_min_nonce¶
Sets minimal deposit nonce for chain id
# <weight> - O(1) lookup and insert # </weight>
Attributes¶
Name | Type |
---|---|
chain_id | ChainId |
min_nonce | DepositNonce |
Python¶
call = substrate.compose_call(
'ChainBridge', 'set_min_nonce', {'chain_id': 'u8', 'min_nonce': 'u64'}
)
set_proposal_lifetime¶
Sets proposal lifetime.
This lifetime is used for determine how many blocks have relays to votes for deposit. # <weight> - O(1) write # </weight>
Attributes¶
Name | Type |
---|---|
lifetime | T::BlockNumber |
Python¶
call = substrate.compose_call(
'ChainBridge', 'set_proposal_lifetime', {'lifetime': 'u32'}
)
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'}
)
toggle_chain¶
Sets transfers allowability.
This param is used for determine transfers possibility for chain. # <weight> - O(1) write # </weight>
Attributes¶
Name | Type |
---|---|
chain_id | ChainId |
enabled | bool |
Python¶
call = substrate.compose_call(
'ChainBridge', 'toggle_chain', {'chain_id': 'u8', 'enabled': 'bool'}
)
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 | ChainId |
fee | T::Balance |
Python¶
call = substrate.compose_call(
'ChainBridge', 'whitelist_chain', {'fee': 'u128', 'id': 'u8'}
)
Events¶
ChainToggled¶
Allowability transfers for the chain has changed. [chain_id, enabled]
Attributes¶
Name | Type | Composition |
---|---|---|
None | ChainId |
u8 |
None | bool |
bool |
ChainWhitelisted¶
Chain now available for transfers. [chain_id]
Attributes¶
Name | Type | Composition |
---|---|---|
None | ChainId |
u8 |
FeeChanged¶
Fee for chain has changed. [chain_id, fee]
Attributes¶
Name | Type | Composition |
---|---|---|
None | ChainId |
u8 |
None | T::Balance |
u128 |
FungibleTransfer¶
FunglibleTransfer is for relaying fungibles. [dest_id, nonce, resource_id, amount, recipient]
Attributes¶
Name | Type | Composition |
---|---|---|
None | ChainId |
u8 |
None | DepositNonce |
u64 |
None | ResourceId |
[u8; 32] |
None | U256 |
scale_info::72 |
None | Vec<u8> |
Bytes |
GenericTransfer¶
GenericTransfer is for a generic data payload. [dest_id, nonce, resource_id, metadata]
Attributes¶
Name | Type | Composition |
---|---|---|
None | ChainId |
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 | ChainId |
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. [dest_id, nonce]
Attributes¶
Name | Type | Composition |
---|---|---|
None | ChainId |
u8 |
None | DepositNonce |
u64 |
ProposalFailed¶
Execution of call failed. [dest_id, nonce]
Attributes¶
Name | Type | Composition |
---|---|---|
None | ChainId |
u8 |
None | DepositNonce |
u64 |
ProposalLifetimeChanged¶
Proposal lifetime has changed. [lifetime]
Attributes¶
Name | Type | Composition |
---|---|---|
None | T::BlockNumber |
u32 |
ProposalRejected¶
Voting rejected a proposal. [dest_id, nonce]
Attributes¶
Name | Type | Composition |
---|---|---|
None | ChainId |
u8 |
None | DepositNonce |
u64 |
ProposalSucceeded¶
Execution of call succeeded. [dest_id, nonce]
Attributes¶
Name | Type | Composition |
---|---|---|
None | ChainId |
u8 |
None | DepositNonce |
u64 |
RelayerAdded¶
Relayer added to set. [who]
Attributes¶
Name | Type | Composition |
---|---|---|
None | T::AccountId |
AccountId |
RelayerRemoved¶
Relayer removed from set. [who]
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. [dest_id, nonce, who]
Attributes¶
Name | Type | Composition |
---|---|---|
None | ChainId |
u8 |
None | DepositNonce |
u64 |
None | T::AccountId |
AccountId |
VoteFor¶
Vote submitted in favour of proposal. [dest_id, nonce, who]
Attributes¶
Name | Type | Composition |
---|---|---|
None | ChainId |
u8 |
None | DepositNonce |
u64 |
None | T::AccountId |
AccountId |
Storage functions¶
ChainNonces¶
All whitelisted chains and their respective transaction counts.
Python¶
result = substrate.query(
'ChainBridge', 'ChainNonces', ['u8']
)
Return value¶
'u64'
DisabledChains¶
Permission to voting and making transfers.
Python¶
result = substrate.query(
'ChainBridge', 'DisabledChains', ['u8']
)
Return value¶
()
Fees¶
Fee to charge for a bridge transfer S->E.
Python¶
result = substrate.query(
'ChainBridge', 'Fees', ['u8']
)
Return value¶
'u128'
MinDepositNonce¶
Minimal allowed value for deposit nonce per chain id
Python¶
result = substrate.query(
'ChainBridge', 'MinDepositNonce', ['u8']
)
Return value¶
'u64'
ProposalLifetime¶
Time in blocks for relays voting
Python¶
result = substrate.query(
'ChainBridge', 'ProposalLifetime', []
)
Return value¶
'u32'
RelayerCount¶
Number of relayers in set.
Python¶
result = substrate.query(
'ChainBridge', 'RelayerCount', []
)
Return value¶
'u32'
RelayerThreshold¶
Number of votes required for a proposal to execute.
Python¶
result = substrate.query(
'ChainBridge', 'RelayerThreshold', []
)
Return value¶
'u32'
Relayers¶
Tracks current relayer set.
Python¶
result = substrate.query(
'ChainBridge', 'Relayers', ['AccountId']
)
Return value¶
'bool'
Resources¶
Utilized by the bridge software to map resource IDs to actual methods.
Python¶
result = substrate.query(
'ChainBridge', 'Resources', ['[u8; 32]']
)
Return value¶
'Bytes'
Votes¶
All known proposals. The key is the hash of the call and the deposit ID, to ensure it's unique.
Python¶
result = substrate.query(
'ChainBridge', 'Votes', ['u8', ('u64', 'Call')]
)
Return value¶
{
'expiry': 'u32',
'status': ('Initiated', 'Approved', 'Rejected'),
'votes_against': ['AccountId'],
'votes_for': ['AccountId'],
}
Constants¶
ChainIdentity¶
The identifier for this chain. This must be unique and must not collide with existing IDs within a set of bridged chains.
Value¶
7
Python¶
constant = substrate.get_constant('ChainBridge', 'ChainIdentity')
Errors¶
AllowabilityEqual¶
Bridge transfers to this chain have equal allowability
ChainAlreadyWhitelisted¶
Chain has already been enabled
ChainNotWhitelisted¶
Interactions with this chain is not permitted
DisabledChain¶
Bridge transfers to this chain are disabled
InvalidChainId¶
Provided chain Id is not valid
InvalidFee¶
Fee cannot be less than 0
InvalidProposalLifetime¶
Proposal lifetime cannot be equal 0
InvalidThreshold¶
Relayer threshold cannot be 0
MinimalNonce¶
Minimal nonce check not passed
MustBeRelayer¶
Protected operation, must be performed by relayer
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