revert_transfer

@mount("ft4.crosschain.revert_transfer") operation revert_transfer(init_transfer_tx: gtx_transaction, init_tx_op_index: integer, last_tx: gtx_transaction, last_op_index: integer)(source)

Reverts a transfer that was initialized on this chain, after it has expired. If a crosschain transfer is to be rolled back after expiring and the assets are to be returned to the original sender, after the process of walking the path backwards until the source chain, then this operation should be called as the final step on the source chain to complete the rollback. When this operation is called, the assets are returned back to the original sender.

Throws "INVALID TRANSFER" if the transfer that is being unapplied was:

  • never initialized on this chain

  • already reverted on this chain

Throws "INPUT ERROR" if the input is malformed. This could be one of many different things:

  • arguments found in init_transfer_tx and last_tx do not match

  • last_tx has not been sent to the chain that comes after this one on the transfer hops

Throws"UNSUPPORTED LAST OP" if the operation found in last_tx at the given index is neither of the three supported operations:

  • unapply_transfer if the transfer was canceled or recalled, but it had more than one hop (i.e. it went from starting chain to target chain while going through at least another chain)

  • cancel_transfer if the transfer was canceled before being applied on the chain that came after the init chain

  • recall_unclaimed_transfer if the transfer was applied on the target chain, it was sent to a non-existing account, and it has expired

Throws "TRANSFER NOT EXPIRED" if the transfer being reverted did not expire

Throws if the init_tx_op_index does not point to init_transfer on init_transfer_tx

Throws if the required assets cannot be transferred. While this could throw in all cases of misconfiguration considered possible for init_transfer, to revert a transfer it must first have been applied. This means that the most probable scenario for the transfer of funds to fail is if the sender blockchain account balance is lower than amount.

Other cases considered possible for init_transfer are still possible, although unlikely. For example, the asset entity could have been deleted, which means that the asset is no longer registered on this chain.

Anyone can call this operation, but it needs to include an iccf_proof operation that unapply_transfer was performed on the previous chain.

Parameters

init_transfer_tx

the transaction containing the init_transfer operation which corresponds to the transfer to revert

init_tx_op_index

the index of the init_transfer operation in init_transfer_tx

last_tx

the last transaction in this transfer flow, as sent to the previous hop. Note that "previous" in this context refers to the chain at n + 1 in the hops array in relation to this blockchain, since we are walking the hops array backwards. It must contain one of the three supported operations described above.

last_op_index

the index of apply_transfer operation in last_tx

See also

core.crosschain.applied_transfers

to know more about the crosschain transfer workflow

core.crosschain.reverted_transfers

to know more about transfer reversal