Module-level declarations

Types

Link copied to clipboard

Represents a crosschain transfer that has been applied on this chain.

When a transfer is going from chain A to C, passing through chain B, this is what will happen on the chains:

  • init_transfer gets called on chain A

  • crosschain_transfer_history_entry is created for this transfer on chain A

  • pending_transfer is created for this transfer on chain A

  • apply_transfer is called on chain B

  • applied_transfer is created for this transfer on chain B

  • apply_transfer is called on chain C

  • crosschain_transfer_history_entry is created for this transfer on chain C

  • applied_transfer is created for this transfer on chain C

  • complete_transfer is called on chain A

  • pending_transfer created in step 3 on chain A is removed

Chain A is the "init chain", chain B and C are "hops". Chain C is also the "target chain" for this transfer.

Link copied to clipboard

The origin of a crosschain asset that can be used on this chain.

An asset can be issued on this chain, or a different one. If it is issued on a different chain, it's considered a crosschain asset, and it will have an asset_origin linked to it.

An asset has an asset_origin iff it is a crosschain asset.

The origin of the asset might be different from the issuing chain, although in many cases it will be the same. The origin chain represents a chain that is providing the assets to this chain, considered its parent. Assets can only be transferred from a parent to a child chain and vice versa, and only one parent chain can exist for a given asset. Different assets can have different origins.

When this chain sends assets to chains that are not the parent chain (children), it will keep track of the balance of each child chain through blockchain account entities; the children chain cannot send assets among themselves - they must send them through the parent chain. On the other hand, children chains will not keep track of the parent chain balance.

Link copied to clipboard

Represents a crosschain transfer that has been canceled.

A cross-chain transfer that is past its deadline can be canceled if it never was applied (with apply_transfer on the last chain). To do so, cancel_transfer needs to be called (instead of apply_transfer) on the chain that would be next in the flow.

For example, if a chain going A -> B -> C expired after init_transfer and never got applied on chain B, cancel_transfer must be called on chain B. If it instead expired after applying it on chain B, it must be canceled on chain C.

Link copied to clipboard

Represents a crosschain transfer that has been initialized.

This entity will be created on the starting chain, and it will be deleted when the transfer is completed (by calling complete_transfer on the starting chain) or when it is reverted (by calling revert_transfer on the starting chain).

Link copied to clipboard

Represents a crosschain transfer that has been recalled.

A cross-chain transfer can be used to register accounts if the chain was configured to do so. If it is possible, the transfer must be "claimed" on the end chain by using the correct register account strategy. This will end upregistering the account, moving the funds to it, and removing any funds that should be consumed on account registration, if applicable.

For example, if a chain going A -> B -> C has been sent to an account which does not exist on chain C, chain C will consider that transfer to be aimed at registering that account. There will be no way for the user that sent the funds to retrieve them until the expiration date. After the transfer has expired, if the account wasn't registered, the user that sent the funds will be able to call recall_unclaimed_transfer on chain C; the transfer must then be unapplied on chain B and reverted on chain A.

Link copied to clipboard

Represents a crosschain transfer that has been reverted.

A cross-chain transfer that is past its deadline must be recalled or canceled. If there are intermediate chains where the transfer was applied, it must be unapplied there, and then it can be reverted on the initial chain.

For example, if a chain going A -> B -> C got cancelled or recalled on chain C, it must be unapplied on chain B, then reverted on chain A.

Link copied to clipboard

Represents a crosschain transfer that has been unapplied.

A cross-chain transfer that is past its deadline must be recalled or canceled. After doing so, unapply_transfer needs to be called on all chains where the transfer was applied before reverting it on the starting chain.

For example, if a chain going A -> B -> C -> D got cancelled or recalled on chain D, it must be unapplied on chain C, then on chain B, then reverted on chain A.

Properties

Link copied to clipboard
val ACCOUNT_TYPE_BLOCKCHAIN: text = "FT4_BLOCKCHAIN"

The account type for blockchain accounts.

These accounts represent the balance of chains that are downstream of this one, in the scheme of crosschain transfers.

  • If tokens are sent to that chain, its account balance is increased.

  • If tokens are received from that chain, its account balance is decreased.

  • If tokens are sent to or received from an upstream chain, its account balance is not modified.

Functions

Link copied to clipboard
@extendable function after_apply_transfer(sender_blockchain_rid: byte_array, sender_account_id: byte_array, recipient_id: byte_array, asset: asset, amount: big_integer, hop_index: integer, is_final: boolean, applied_transfers: applied_transfers)

Extendable function that allows the developer to add more functionality to the apply_transfer function, after the transfer is applied.

This allows, for example, to check that any condition is met after the transfer is applied on this chain.

If this function throws, the transfer will not be applied.

Throws when any extension of this function throws.

Link copied to clipboard
@extendable function after_init_transfer(sender: account, recipient_id: byte_array, asset: asset, amount: big_integer, hops: list<byte_array>, deadline: integer, pending_transfer: pending_transfer)

Extendable function that allows the developer to add more functionality to the init_transfer function, after the transfer is initialised.

This allows, for example, to check that any condition is met after the transfer is initialised.

If this function throws, the transfer will not be initialized.

Throws when any extension of this function throws.

Link copied to clipboard
@extendable function before_apply_transfer(sender_blockchain_rid: byte_array, sender_account_id: byte_array, recipient_id: byte_array, asset: asset, amount: big_integer, hop_index: integer, is_final: boolean)

Extendable function that allows the developer to add more functionality to the apply_transfer function, before the transfer is applied.

This allows, for example,to check that any condition is met before the transfer is applied on this chain.

If this function throws, the transfer will not be applied.

Throws when any extension of this function throws.

Link copied to clipboard
@extendable function before_init_transfer(sender: account, recipient_id: byte_array, asset: asset, amount: big_integer, hops: list<byte_array>, deadline: integer)

Extendable function that allows the developer to add more functionality to the init_transfer function, before the transfer is initialised.

This allows, for example, to check that any condition is met before the transfer is initialised.

If this function throws, the transfer will not be initialized.

Throws when any extension of this function throws.

Link copied to clipboard
@extendable function create_on_crosschain_transfer(sender_blockchain_rid: byte_array, sender_id: byte_array, recipient_id: byte_array, asset: asset, amount: big_integer)

The crosschain equivalent of core.assets.create_on_internal_transfer.

Throws if any extension of this function throws.

Link copied to clipboard
function ensure_blockchain_account(blockchain_rid: byte_array): account

Returns the blockchain account with the given ID, creating it if needed.

Can only be called from an operation.

Throws when an account with given ID exists, but the type is not ACCOUNT_TYPE_BLOCKCHAIN.

Link copied to clipboard
function get_last_pending_transfer_for_account(sender_id: byte_array, target_blockchain_rid: byte_array, recipient_id: byte_array, asset_id: byte_array, amount: big_integer): (tx_data: byte_array, op_index: integer, account_id: byte_array)?

Retrieves only the last transfer that was not yet completed, based on the parameters specified.

Link copied to clipboard
function get_paginated_pending_transfers(account_id: byte_array, page_size: integer?, page_cursor: text?): list<pagination_result>

Retrieves all transfers that were not yet completed, paginated.

Link copied to clipboard
function is_blockchain(account_id: byte_array): boolean

Whether a certain account is a blockchain account

Link copied to clipboard

Returns whether crosschain transfers can be used to create new accounts. Developers should not generally extend this function, as it is handled by the account registration module. Importing the corresponding module should be enough.

Throws if any extension of this function throws.

Link copied to clipboard
@extendable function recall_on_crosschain_transfer(sender_blockchain_rid: byte_array, sender_id: byte_array, transfer_tx_rid: byte_array, transfer_op_index: integer)

The crosschain equivalent of core.assets.recall_on_internal_transfer.

Throws if any extension of this function throws.