diff --git a/.gitignore b/.gitignore index 973c858fa9514..7eacacd9667b6 100644 --- a/.gitignore +++ b/.gitignore @@ -138,3 +138,8 @@ test_indexer_grpc/* # ignore boogie bpl boogie.bpl + +# ingore .movement or .aptos dirs and configs +**/.movement +**/.aptos +**/config.yaml \ No newline at end of file diff --git a/aptos-move/framework/aptos-framework/doc/atomic_bridge.md b/aptos-move/framework/aptos-framework/doc/atomic_bridge.md index 2c36f8755ac1a..0ae26c38c1584 100644 --- a/aptos-move/framework/aptos-framework/doc/atomic_bridge.md +++ b/aptos-move/framework/aptos-framework/doc/atomic_bridge.md @@ -1,183 +1,36 @@ - + -# Module `0x1::atomic_bridge_store` +# Module `0x1::atomic_bridge` -- [Struct `AddressPair`](#0x1_atomic_bridge_store_AddressPair) -- [Resource `SmartTableWrapper`](#0x1_atomic_bridge_store_SmartTableWrapper) -- [Struct `BridgeTransferDetails`](#0x1_atomic_bridge_store_BridgeTransferDetails) -- [Resource `Nonce`](#0x1_atomic_bridge_store_Nonce) +- [Resource `AptosCoinBurnCapability`](#0x1_atomic_bridge_AptosCoinBurnCapability) +- [Resource `AptosCoinMintCapability`](#0x1_atomic_bridge_AptosCoinMintCapability) +- [Resource `AptosFABurnCapabilities`](#0x1_atomic_bridge_AptosFABurnCapabilities) +- [Resource `AptosFAMintCapabilities`](#0x1_atomic_bridge_AptosFAMintCapabilities) - [Constants](#@Constants_0) -- [Function `initialize`](#0x1_atomic_bridge_store_initialize) -- [Function `now`](#0x1_atomic_bridge_store_now) -- [Function `create_time_lock`](#0x1_atomic_bridge_store_create_time_lock) -- [Function `create_details`](#0x1_atomic_bridge_store_create_details) -- [Function `add`](#0x1_atomic_bridge_store_add) -- [Function `assert_min_time_lock`](#0x1_atomic_bridge_store_assert_min_time_lock) -- [Function `assert_pending`](#0x1_atomic_bridge_store_assert_pending) -- [Function `assert_valid_hash_lock`](#0x1_atomic_bridge_store_assert_valid_hash_lock) -- [Function `assert_valid_bridge_transfer_id`](#0x1_atomic_bridge_store_assert_valid_bridge_transfer_id) -- [Function `create_hashlock`](#0x1_atomic_bridge_store_create_hashlock) -- [Function `assert_correct_hash_lock`](#0x1_atomic_bridge_store_assert_correct_hash_lock) -- [Function `assert_timed_out_lock`](#0x1_atomic_bridge_store_assert_timed_out_lock) -- [Function `assert_within_timelock`](#0x1_atomic_bridge_store_assert_within_timelock) -- [Function `complete`](#0x1_atomic_bridge_store_complete) -- [Function `cancel`](#0x1_atomic_bridge_store_cancel) -- [Function `complete_details`](#0x1_atomic_bridge_store_complete_details) -- [Function `complete_transfer`](#0x1_atomic_bridge_store_complete_transfer) -- [Function `cancel_details`](#0x1_atomic_bridge_store_cancel_details) -- [Function `cancel_transfer`](#0x1_atomic_bridge_store_cancel_transfer) -- [Function `bridge_transfer_id`](#0x1_atomic_bridge_store_bridge_transfer_id) -- [Function `get_bridge_transfer_details_initiator`](#0x1_atomic_bridge_store_get_bridge_transfer_details_initiator) -- [Function `get_bridge_transfer_details_counterparty`](#0x1_atomic_bridge_store_get_bridge_transfer_details_counterparty) -- [Function `get_bridge_transfer_details`](#0x1_atomic_bridge_store_get_bridge_transfer_details) -- [Specification](#@Specification_1) - - [Function `initialize`](#@Specification_1_initialize) - - [Function `create_time_lock`](#@Specification_1_create_time_lock) - - [Function `create_details`](#@Specification_1_create_details) - - [Function `add`](#@Specification_1_add) - - [Function `create_hashlock`](#@Specification_1_create_hashlock) - - [Function `complete`](#@Specification_1_complete) - - [Function `cancel`](#@Specification_1_cancel) - - [Function `complete_details`](#@Specification_1_complete_details) - - [Function `complete_transfer`](#@Specification_1_complete_transfer) - - [Function `cancel_details`](#@Specification_1_cancel_details) - - -
use 0x1::aptos_hash;
-use 0x1::bcs;
-use 0x1::ethereum;
-use 0x1::features;
-use 0x1::smart_table;
-use 0x1::system_addresses;
-use 0x1::timestamp;
-use 0x1::vector;
-
-
-
-
-
-
-## Struct `AddressPair`
-
-
-
-struct AddressPair<Initiator: store, Recipient: store> has copy, store
-
-
-
-
-initiator: Initiator
-recipient: Recipient
-struct SmartTableWrapper<K, V> has store, key
-
-
-
-
-inner: smart_table::SmartTable<K, V>
-struct BridgeTransferDetails<Initiator: store, Recipient: store> has copy, store
+use 0x1::aptos_coin;
+use 0x1::coin;
+use 0x1::fungible_asset;
-
-Fields
-
-
-
--
-
addresses: atomic_bridge_store::AddressPair<Initiator, Recipient>
-
--
-
-
--
-
amount: u64
-
--
-
-
--
-
hash_lock: vector<u8>
-
--
-
-
--
-
time_lock: u64
-
--
-
-
--
-
state: u8
-
--
-
-
-
-
-
-
-
-
+
-## Resource `Nonce`
+## Resource `AptosCoinBurnCapability`
-struct Nonce has key
+struct AptosCoinBurnCapability has key
@@ -188,7 +41,7 @@ Details on the transfer
-
-
inner: u64
+burn_cap: coin::BurnCapability<aptos_coin::AptosCoin>
-
@@ -198,413 +51,120 @@ Details on the transfer
-
-
-## Constants
-
-
-
-
-
-
-
const MAX_U64: u64 = 18446744073709551615;
-
-
-
-
-
-
-
-
-const EATOMIC_BRIDGE_NOT_ENABLED: u64 = 9;
-
-
-
-
-
-
-
-
-const CANCELLED_TRANSACTION: u8 = 3;
-
-
-
-
-
-
-
-
-const COMPLETED_TRANSACTION: u8 = 2;
-
-
-
-
-
-
-
-
-const EEXPIRED: u64 = 3;
-
-
-
-
-
-
-
-
-const EINVALID_BRIDGE_TRANSFER_ID: u64 = 8;
-
-
-
-
-
-
-
-
-const EINVALID_HASH_LOCK: u64 = 5;
-
-
-
-
-
-
-Error codes
-
-
-const EINVALID_PRE_IMAGE: u64 = 1;
-
-
-
-
-
-
-
-
-const EINVALID_TIME_LOCK: u64 = 6;
-
-
-
-
-
-
-
-
-const ENOT_EXPIRED: u64 = 4;
-
-
-
-
-
-
-
-
-const ENOT_PENDING_TRANSACTION: u64 = 2;
-
-
-
-
-
-
-
-
-const EZERO_AMOUNT: u64 = 7;
-
-
-
-
-
-
-Minimum time lock of 1 second
-
-
-const MIN_TIME_LOCK: u64 = 1;
-
-
-
-
-
-
-Transaction states
-
-
-const PENDING_TRANSACTION: u8 = 1;
-
-
-
-
-
-
-## Function `initialize`
-
-Initializes the initiators and counterparties tables and nonce.
-
-@param aptos_framework The signer for Aptos framework.
-
-
-public fun initialize(aptos_framework: &signer)
-
-
-
-
-
-Implementation
-
-
-public fun initialize(aptos_framework: &signer) {
- system_addresses::assert_aptos_framework(aptos_framework);
- move_to(aptos_framework, Nonce {
- inner: 0,
- });
-
- let initiators = SmartTableWrapper<vector<u8>, BridgeTransferDetails<address, EthereumAddress>> {
- inner: smart_table::new(),
- };
-
- move_to(aptos_framework, initiators);
-
- let counterparties = SmartTableWrapper<vector<u8>, BridgeTransferDetails<EthereumAddress, address>> {
- inner: smart_table::new(),
- };
-
- move_to(aptos_framework, counterparties);
-}
-
-
-
-
-
-
-
-
-## Function `now`
-
-Returns the current time in seconds.
-
-@return Current timestamp in seconds.
-
-
-fun now(): u64
-
-
-
-
-
-Implementation
-
-
-fun now() : u64 {
- timestamp::now_seconds()
-}
-
-
-
-
-
-
-
-
-## Function `create_time_lock`
-
-Creates a time lock by adding a duration to the current time.
-
-@param lock The duration to lock.
-@return The calculated time lock.
-@abort If lock is not above MIN_TIME_LOCK
-
-
-public(friend) fun create_time_lock(time_lock: u64): u64
-
-
-
-
-
-Implementation
-
-
-public(friend) fun create_time_lock(time_lock: u64) : u64 {
- assert_min_time_lock(time_lock);
- now() + time_lock
-}
-
-
-
-
-
-
-
-
-## Function `create_details`
-
-Creates bridge transfer details with validation.
-
-@param initiator The initiating party of the transfer.
-@param recipient The receiving party of the transfer.
-@param amount The amount to be transferred.
-@param hash_lock The hash lock for the transfer.
-@param time_lock The time lock for the transfer.
-@return A BridgeTransferDetails
object.
-@abort If the amount is zero or locks are invalid.
-
-
-public(friend) fun create_details<Initiator: store, Recipient: store>(initiator: Initiator, recipient: Recipient, amount: u64, hash_lock: vector<u8>, time_lock: u64): atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>
-
-
-
-
-
-Implementation
-
-
-public(friend) fun create_details<Initiator: store, Recipient: store>(initiator: Initiator, recipient: Recipient, amount: u64, hash_lock: vector<u8>, time_lock: u64)
- : BridgeTransferDetails<Initiator, Recipient> {
- assert!(amount > 0, EZERO_AMOUNT);
- assert_valid_hash_lock(&hash_lock);
- time_lock = create_time_lock(time_lock);
-
- BridgeTransferDetails {
- addresses: AddressPair {
- initiator,
- recipient
- },
- amount,
- hash_lock,
- time_lock,
- state: PENDING_TRANSACTION,
- }
-}
-
-
-
-
-
-
-
-
-## Function `add`
+
-Record details of a transfer
+## Resource `AptosCoinMintCapability`
-@param bridge_transfer_id Bridge transfer ID.
-@param details The bridge transfer details
-public(friend) fun add<Initiator: store, Recipient: store>(bridge_transfer_id: vector<u8>, details: atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
+struct AptosCoinMintCapability has key
-Implementation
-
+Fields
-public(friend) fun add<Initiator: store, Recipient: store>(bridge_transfer_id: vector<u8>, details: BridgeTransferDetails<Initiator, Recipient>) acquires SmartTableWrapper {
- assert!(features::abort_atomic_bridge_enabled(), EATOMIC_BRIDGE_NOT_ENABLED);
- assert_valid_bridge_transfer_id(&bridge_transfer_id);
- let table = borrow_global_mut<SmartTableWrapper<vector<u8>, BridgeTransferDetails<Initiator, Recipient>>>(@aptos_framework);
- smart_table::add(&mut table.inner, bridge_transfer_id, details);
-}
-
+
+-
+
mint_cap: coin::MintCapability<aptos_coin::AptosCoin>
+
+-
+
+
-
-
-## Function `assert_min_time_lock`
+
-Asserts that the time lock is valid.
+## Resource `AptosFABurnCapabilities`
-@param time_lock
-@abort If the time lock is invalid.
-fun assert_min_time_lock(time_lock: u64)
+struct AptosFABurnCapabilities has key
-Implementation
+Fields
-fun assert_min_time_lock(time_lock: u64) {
- assert!(time_lock >= MIN_TIME_LOCK, EINVALID_TIME_LOCK);
-}
-
+
+-
+
burn_ref: fungible_asset::BurnRef
+
+-
+
+
-
-
-## Function `assert_pending`
+
-Asserts that the details state is pending.
+## Resource `AptosFAMintCapabilities`
-@param details The bridge transfer details to check.
-@abort If the state is not pending.
-fun assert_pending<Initiator: store, Recipient: store>(details: &atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
+struct AptosFAMintCapabilities has key
-Implementation
+Fields
-fun assert_pending<Initiator: store, Recipient: store>(details: &BridgeTransferDetails<Initiator, Recipient>) {
- assert!(details.state == PENDING_TRANSACTION, ENOT_PENDING_TRANSACTION)
-}
-
+
+-
+
burn_ref: fungible_asset::MintRef
+
+-
+
+
-
+
-## Function `assert_valid_hash_lock`
+## Constants
-Asserts that the hash lock is valid.
-@param hash_lock The hash lock to validate.
-@abort If the hash lock is invalid.
+
-fun assert_valid_hash_lock(hash_lock: &vector<u8>)
+
+const EATOMIC_BRIDGE_NOT_ENABLED: u64 = 1;
-
-Implementation
+
-fun assert_valid_hash_lock(hash_lock: &vector<u8>) {
- assert!(vector::length(hash_lock) == 32, EINVALID_HASH_LOCK);
-}
-
+const EATOMIC_BRIDGE_DISABLED: u64 = 198461;
+
-
-
+
-## Function `assert_valid_bridge_transfer_id`
+## Function `initialize`
-Asserts that the bridge transfer ID is valid.
+Initializes the atomic bridge by setting up necessary configurations.
-@param bridge_transfer_id The bridge transfer ID to validate.
-@abort If the ID is invalid.
+@param aptos_framework The signer representing the Aptos framework.
-public(friend) fun assert_valid_bridge_transfer_id(bridge_transfer_id: &vector<u8>)
+public fun initialize(_aptos_framework: &signer)
@@ -613,8 +173,8 @@ Asserts that the bridge transfer ID is valid.
Implementation
-public(friend) fun assert_valid_bridge_transfer_id(bridge_transfer_id: &vector<u8>) {
- assert!(vector::length(bridge_transfer_id) == 32, EINVALID_BRIDGE_TRANSFER_ID);
+public fun initialize(_aptos_framework: &signer) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -622,17 +182,17 @@ Asserts that the bridge transfer ID is valid.
-
+
-## Function `create_hashlock`
+## Function `store_aptos_coin_burn_cap`
-Creates a hash lock from a pre-image.
+Stores the burn capability for AptosCoin, converting to a fungible asset reference if the feature is enabled.
-@param pre_image The pre-image to hash.
-@return The generated hash lock.
+@param aptos_framework The signer representing the Aptos framework.
+@param burn_cap The burn capability for AptosCoin.
-public(friend) fun create_hashlock(pre_image: vector<u8>): vector<u8>
+public fun store_aptos_coin_burn_cap(_aptos_framework: &signer, _burn_cap: coin::BurnCapability<aptos_coin::AptosCoin>)
@@ -641,9 +201,8 @@ Creates a hash lock from a pre-image.
Implementation
-public(friend) fun create_hashlock(pre_image: vector<u8>) : vector<u8> {
- assert!(vector::length(&pre_image) > 0, EINVALID_PRE_IMAGE);
- keccak256(pre_image)
+public fun store_aptos_coin_burn_cap(_aptos_framework: &signer, _burn_cap: BurnCapability<AptosCoin>) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -651,18 +210,17 @@ Creates a hash lock from a pre-image.
-
+
-## Function `assert_correct_hash_lock`
+## Function `store_aptos_coin_mint_cap`
-Asserts that the hash lock matches the expected value.
+Stores the mint capability for AptosCoin.
-@param details The bridge transfer details.
-@param hash_lock The hash lock to compare.
-@abort If the hash lock is incorrect.
+@param aptos_framework The signer representing the Aptos framework.
+@param mint_cap The mint capability for AptosCoin.
-fun assert_correct_hash_lock<Initiator: store, Recipient: store>(details: &atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>, hash_lock: vector<u8>)
+public fun store_aptos_coin_mint_cap(_aptos_framework: &signer, _mint_cap: coin::MintCapability<aptos_coin::AptosCoin>)
@@ -671,8 +229,8 @@ Asserts that the hash lock matches the expected value.
Implementation
-fun assert_correct_hash_lock<Initiator: store, Recipient: store>(details: &BridgeTransferDetails<Initiator, Recipient>, hash_lock: vector<u8>) {
- assert!(&hash_lock == &details.hash_lock, EINVALID_PRE_IMAGE);
+public fun store_aptos_coin_mint_cap(_aptos_framework: &signer, _mint_cap: MintCapability<AptosCoin>) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -680,17 +238,18 @@ Asserts that the hash lock matches the expected value.
-
+
-## Function `assert_timed_out_lock`
+## Function `mint`
-Asserts that the time lock has expired.
+Mints a specified amount of AptosCoin to a recipient's address.
-@param details The bridge transfer details.
-@abort If the time lock has not expired.
+@param recipient The address of the recipient to mint coins to.
+@param amount The amount of AptosCoin to mint.
+@abort If the mint capability is not available.
-fun assert_timed_out_lock<Initiator: store, Recipient: store>(details: &atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
+public(friend) fun mint(_recipient: address, _amount: u64)
@@ -699,8 +258,8 @@ Asserts that the time lock has expired.
Implementation
-fun assert_timed_out_lock<Initiator: store, Recipient: store>(details: &BridgeTransferDetails<Initiator, Recipient>) {
- assert!(now() > details.time_lock, ENOT_EXPIRED);
+public(friend) fun mint(_recipient: address, _amount: u64) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -708,17 +267,18 @@ Asserts that the time lock has expired.
-
+
-## Function `assert_within_timelock`
+## Function `burn`
-Asserts we are still within the timelock.
+Burns a specified amount of AptosCoin from an address.
-@param details The bridge transfer details.
-@abort If the time lock has expired.
+@param from The address from which to burn AptosCoin.
+@param amount The amount of AptosCoin to burn.
+@abort If the burn capability is not available.
-fun assert_within_timelock<Initiator: store, Recipient: store>(details: &atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
+public(friend) fun burn(_from: address, _amount: u64)
@@ -727,8 +287,8 @@ Asserts we are still within the timelock.
Implementation
-fun assert_within_timelock<Initiator: store, Recipient: store>(details: &BridgeTransferDetails<Initiator, Recipient>) {
- assert!(!(now() > details.time_lock), EEXPIRED);
+public(friend) fun burn(_from: address, _amount: u64) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -736,824 +296,741 @@ Asserts we are still within the timelock.
-
-
-## Function `complete`
-
-Completes the bridge transfer.
-@param details The bridge transfer details to complete.
+
-fun complete<Initiator: store, Recipient: store>(details: &mut atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
-
+# Module `0x1::atomic_bridge_store`
-
-Implementation
+- [Struct `AddressPair`](#0x1_atomic_bridge_store_AddressPair)
+- [Resource `SmartTableWrapper`](#0x1_atomic_bridge_store_SmartTableWrapper)
+- [Struct `BridgeTransferDetails`](#0x1_atomic_bridge_store_BridgeTransferDetails)
+- [Resource `Nonce`](#0x1_atomic_bridge_store_Nonce)
+- [Constants](#@Constants_0)
+- [Function `initialize`](#0x1_atomic_bridge_store_initialize)
+- [Function `now`](#0x1_atomic_bridge_store_now)
+- [Function `create_time_lock`](#0x1_atomic_bridge_store_create_time_lock)
+- [Function `create_details`](#0x1_atomic_bridge_store_create_details)
+- [Function `add`](#0x1_atomic_bridge_store_add)
+- [Function `assert_min_time_lock`](#0x1_atomic_bridge_store_assert_min_time_lock)
+- [Function `assert_pending`](#0x1_atomic_bridge_store_assert_pending)
+- [Function `assert_valid_hash_lock`](#0x1_atomic_bridge_store_assert_valid_hash_lock)
+- [Function `assert_valid_bridge_transfer_id`](#0x1_atomic_bridge_store_assert_valid_bridge_transfer_id)
+- [Function `create_hashlock`](#0x1_atomic_bridge_store_create_hashlock)
+- [Function `assert_correct_hash_lock`](#0x1_atomic_bridge_store_assert_correct_hash_lock)
+- [Function `assert_timed_out_lock`](#0x1_atomic_bridge_store_assert_timed_out_lock)
+- [Function `assert_within_timelock`](#0x1_atomic_bridge_store_assert_within_timelock)
+- [Function `complete`](#0x1_atomic_bridge_store_complete)
+- [Function `cancel`](#0x1_atomic_bridge_store_cancel)
+- [Function `complete_details`](#0x1_atomic_bridge_store_complete_details)
+- [Function `complete_transfer`](#0x1_atomic_bridge_store_complete_transfer)
+- [Function `cancel_details`](#0x1_atomic_bridge_store_cancel_details)
+- [Function `cancel_transfer`](#0x1_atomic_bridge_store_cancel_transfer)
+- [Function `bridge_transfer_id`](#0x1_atomic_bridge_store_bridge_transfer_id)
+- [Function `get_bridge_transfer_details_initiator`](#0x1_atomic_bridge_store_get_bridge_transfer_details_initiator)
+- [Function `get_bridge_transfer_details_counterparty`](#0x1_atomic_bridge_store_get_bridge_transfer_details_counterparty)
+- [Function `get_bridge_transfer_details`](#0x1_atomic_bridge_store_get_bridge_transfer_details)
-fun complete<Initiator: store, Recipient: store>(details: &mut BridgeTransferDetails<Initiator, Recipient>) {
- details.state = COMPLETED_TRANSACTION;
-}
+use 0x1::ethereum;
+use 0x1::smart_table;
+use 0x1::timestamp;
-
-
-
-
-## Function `cancel`
+
-Cancels the bridge transfer.
+## Struct `AddressPair`
-@param details The bridge transfer details to cancel.
-fun cancel<Initiator: store, Recipient: store>(details: &mut atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
+struct AddressPair<Initiator: store, Recipient: store> has copy, store
-Implementation
+Fields
-fun cancel<Initiator: store, Recipient: store>(details: &mut BridgeTransferDetails<Initiator, Recipient>) {
- details.state = CANCELLED_TRANSACTION;
-}
-
+
+-
+
initiator: Initiator
+
+-
+
+
+-
+
recipient: Recipient
+
+-
+
+
-
-
-## Function `complete_details`
+
-Validates and completes a bridge transfer by confirming the hash lock and state.
+## Resource `SmartTableWrapper`
-@param hash_lock The hash lock used to validate the transfer.
-@param details The mutable reference to the bridge transfer details to be completed.
-@return A tuple containing the recipient and the amount of the transfer.
-@abort If the hash lock is invalid, the transfer is not pending, or the hash lock does not match.
+A smart table wrapper
-fun complete_details<Initiator: store, Recipient: copy, store>(hash_lock: vector<u8>, details: &mut atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>): (Recipient, u64)
+struct SmartTableWrapper<K, V> has store, key
-Implementation
-
-
-fun complete_details<Initiator: store, Recipient: store + copy>(hash_lock: vector<u8>, details: &mut BridgeTransferDetails<Initiator, Recipient>) : (Recipient, u64) {
- assert_valid_hash_lock(&hash_lock);
- assert_pending(details);
- assert_correct_hash_lock(details, hash_lock);
- assert_within_timelock(details);
+Fields
- complete(details);
- (details.addresses.recipient, details.amount)
-}
-
+
+-
+
inner: smart_table::SmartTable<K, V>
+
+-
+
+
-
-
-## Function `complete_transfer`
+
-Completes a bridge transfer by validating the hash lock and updating the transfer state.
+## Struct `BridgeTransferDetails`
-@param bridge_transfer_id The ID of the bridge transfer to complete.
-@param hash_lock The hash lock used to validate the transfer.
-@return A tuple containing the recipient of the transfer and the amount transferred.
-@abort If the bridge transfer details are not found or if the completion checks in complete_details
fail.
+Details on the transfer
-public(friend) fun complete_transfer<Initiator: store, Recipient: copy, store>(bridge_transfer_id: vector<u8>, hash_lock: vector<u8>): (Recipient, u64)
+struct BridgeTransferDetails<Initiator: store, Recipient: store> has copy, store
-Implementation
+Fields
-public(friend) fun complete_transfer<Initiator: store, Recipient: copy + store>(bridge_transfer_id: vector<u8>, hash_lock: vector<u8>) : (Recipient, u64) acquires SmartTableWrapper {
- assert!(features::abort_atomic_bridge_enabled(), EATOMIC_BRIDGE_NOT_ENABLED);
+
+-
+
addresses: atomic_bridge_store::AddressPair<Initiator, Recipient>
+
+-
+
+
+-
+
amount: u64
+
+-
- let table = borrow_global_mut<SmartTableWrapper<vector<u8>, BridgeTransferDetails<Initiator, Recipient>>>(@aptos_framework);
+
+-
+
hash_lock: vector<u8>
+
+-
- let details = smart_table::borrow_mut(
- &mut table.inner,
- bridge_transfer_id);
+
+-
+
time_lock: u64
+
+-
- complete_details<Initiator, Recipient>(hash_lock, details)
-}
-
+
+-
+
state: u8
+
+-
+
+
-
-
-## Function `cancel_details`
+
-Cancels a pending bridge transfer if the time lock has expired.
+## Resource `Nonce`
-@param details A mutable reference to the bridge transfer details to be canceled.
-@return A tuple containing the initiator of the transfer and the amount to be refunded.
-@abort If the transfer is not in a pending state or the time lock has not expired.
-fun cancel_details<Initiator: copy, store, Recipient: store>(details: &mut atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>): (Initiator, u64)
+struct Nonce has key
-Implementation
-
-
-fun cancel_details<Initiator: store + copy, Recipient: store>(details: &mut BridgeTransferDetails<Initiator, Recipient>) : (Initiator, u64) {
- assert_pending(details);
- assert_timed_out_lock(details);
+Fields
- cancel(details);
- (details.addresses.initiator, details.amount)
-}
-
+
+-
+
inner: u64
+
+-
+
+
-
-
-## Function `cancel_transfer`
+
-Cancels a bridge transfer if it is pending and the time lock has expired.
+## Constants
-@param bridge_transfer_id The ID of the bridge transfer to cancel.
-@return A tuple containing the initiator of the transfer and the amount to be refunded.
-@abort If the bridge transfer details are not found or if the cancellation conditions in cancel_details
fail.
+
-public(friend) fun cancel_transfer<Initiator: copy, store, Recipient: store>(bridge_transfer_id: vector<u8>): (Initiator, u64)
-
+const MAX_U64: u64 = 18446744073709551615;
+
-
-Implementation
-public(friend) fun cancel_transfer<Initiator: store + copy, Recipient: store>(bridge_transfer_id: vector<u8>) : (Initiator, u64) acquires SmartTableWrapper {
- assert!(features::abort_atomic_bridge_enabled(), EATOMIC_BRIDGE_NOT_ENABLED);
+
- let table = borrow_global_mut<SmartTableWrapper<vector<u8>, BridgeTransferDetails<Initiator, Recipient>>>(@aptos_framework);
- let details = smart_table::borrow_mut(
- &mut table.inner,
- bridge_transfer_id);
- cancel_details<Initiator, Recipient>(details)
-}
+const EATOMIC_BRIDGE_NOT_ENABLED: u64 = 9;
-
-
-
-
-## Function `bridge_transfer_id`
-
-Generates a unique bridge transfer ID based on transfer details and nonce.
+
-@param details The bridge transfer details.
-@return The generated bridge transfer ID.
-public(friend) fun bridge_transfer_id<Initiator: store, Recipient: store>(details: &atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>): vector<u8>
+const EATOMIC_BRIDGE_DISABLED: u64 = 198461;
-
-Implementation
+
-public(friend) fun bridge_transfer_id<Initiator: store, Recipient: store>(details: &BridgeTransferDetails<Initiator, Recipient>) : vector<u8> acquires Nonce {
- let nonce = borrow_global_mut<Nonce>(@aptos_framework);
- let combined_bytes = vector::empty<u8>();
- vector::append(&mut combined_bytes, bcs::to_bytes(&details.addresses.initiator));
- vector::append(&mut combined_bytes, bcs::to_bytes(&details.addresses.recipient));
- vector::append(&mut combined_bytes, details.hash_lock);
- if (nonce.inner == MAX_U64) {
- nonce.inner = 0; // Wrap around to 0 if at maximum value
- } else {
- nonce.inner = nonce.inner + 1; // Safe to increment without overflow
- };
- vector::append(&mut combined_bytes, bcs::to_bytes(&nonce.inner));
-
- keccak256(combined_bytes)
-}
+
+const CANCELLED_TRANSACTION: u8 = 3;
-
+
-
-## Function `get_bridge_transfer_details_initiator`
-Gets initiator bridge transfer details given a bridge transfer ID
+const COMPLETED_TRANSACTION: u8 = 2;
+
-@param bridge_transfer_id A 32-byte vector of unsigned 8-bit integers.
-@return A BridgeTransferDetails
struct.
-@abort If there is no transfer in the atomic bridge store.
-#[view]
-public fun get_bridge_transfer_details_initiator(bridge_transfer_id: vector<u8>): atomic_bridge_store::BridgeTransferDetails<address, ethereum::EthereumAddress>
-
+
-
-Implementation
+const EEXPIRED: u64 = 3;
+
-public fun get_bridge_transfer_details_initiator(
- bridge_transfer_id: vector<u8>
-): BridgeTransferDetails<address, EthereumAddress> acquires SmartTableWrapper {
- get_bridge_transfer_details(bridge_transfer_id)
-}
-
+
-
-
+const EINVALID_BRIDGE_TRANSFER_ID: u64 = 8;
+
-## Function `get_bridge_transfer_details_counterparty`
-Gets counterparty bridge transfer details given a bridge transfer ID
-@param bridge_transfer_id A 32-byte vector of unsigned 8-bit integers.
-@return A BridgeTransferDetails
struct.
-@abort If there is no transfer in the atomic bridge store.
+
-#[view]
-public fun get_bridge_transfer_details_counterparty(bridge_transfer_id: vector<u8>): atomic_bridge_store::BridgeTransferDetails<ethereum::EthereumAddress, address>
-
+const EINVALID_HASH_LOCK: u64 = 5;
+
-
-Implementation
+
-public fun get_bridge_transfer_details_counterparty(
- bridge_transfer_id: vector<u8>
-): BridgeTransferDetails<EthereumAddress, address> acquires SmartTableWrapper {
- get_bridge_transfer_details(bridge_transfer_id)
-}
-
+Error codes
+const EINVALID_PRE_IMAGE: u64 = 1;
+
-
-
-## Function `get_bridge_transfer_details`
+
-fun get_bridge_transfer_details<Initiator: copy, store, Recipient: copy, store>(bridge_transfer_id: vector<u8>): atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>
+const EINVALID_TIME_LOCK: u64 = 6;
-
-Implementation
-
+
-fun get_bridge_transfer_details<Initiator: store + copy, Recipient: store + copy>(bridge_transfer_id: vector<u8>
-): BridgeTransferDetails<Initiator, Recipient> acquires SmartTableWrapper {
- let table = borrow_global<SmartTableWrapper<vector<u8>, BridgeTransferDetails<Initiator, Recipient>>>(@aptos_framework);
- let details_ref = smart_table::borrow(
- &table.inner,
- bridge_transfer_id
- );
- *details_ref
-}
+const ENOT_EXPIRED: u64 = 4;
-
-
-
-
-## Specification
+
-
-### Function `initialize`
+const ENOT_PENDING_TRANSACTION: u64 = 2;
+
-public fun initialize(aptos_framework: &signer)
-
+
-let addr = signer::address_of(aptos_framework);
-ensures exists<Nonce>(addr);
-ensures exists<SmartTableWrapper<vector<u8>, BridgeTransferDetails<address, EthereumAddress>>>(addr);
-ensures exists<SmartTableWrapper<vector<u8>, BridgeTransferDetails<EthereumAddress, address>>>(addr);
+const EZERO_AMOUNT: u64 = 7;
+
-
+Minimum time lock of 1 second
-schema TimeLockAbortsIf {
- time_lock: u64;
- aborts_if time_lock < MIN_TIME_LOCK;
- aborts_if !exists<CurrentTimeMicroseconds>(@aptos_framework);
- aborts_if time_lock > MAX_U64 - timestamp::spec_now_seconds();
-}
+const MIN_TIME_LOCK: u64 = 1;
-
+
-### Function `create_time_lock`
+Transaction states
-public(friend) fun create_time_lock(time_lock: u64): u64
+const PENDING_TRANSACTION: u8 = 1;
+
-include TimeLockAbortsIf;
-ensures result == timestamp::spec_now_seconds() + time_lock;
-
+## Function `initialize`
+Initializes the initiators and counterparties tables and nonce.
-If the sum of now()
and lock
does not overflow, the result is the sum of now()
and lock
.
+@param aptos_framework The signer for Aptos framework.
-ensures (timestamp::spec_now_seconds() + time_lock <= 0xFFFFFFFFFFFFFFFF) ==> result == timestamp::spec_now_seconds() + time_lock;
+public fun initialize(_aptos_framework: &signer)
-
-
-### Function `create_details`
+
+Implementation
-public(friend) fun create_details<Initiator: store, Recipient: store>(initiator: Initiator, recipient: Recipient, amount: u64, hash_lock: vector<u8>, time_lock: u64): atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>
+public fun initialize(_aptos_framework: &signer) {
+ abort EATOMIC_BRIDGE_DISABLED
+}
+
-include TimeLockAbortsIf;
-aborts_if amount == 0;
-aborts_if len(hash_lock) != 32;
-ensures result == BridgeTransferDetails<Initiator, Recipient> {
- addresses: AddressPair<Initiator, Recipient> {
- initiator,
- recipient
- },
- amount,
- hash_lock,
- time_lock: timestamp::spec_now_seconds() + time_lock,
- state: PENDING_TRANSACTION,
-};
-
-
+
+## Function `now`
+Returns the current time in seconds.
-
+@return Current timestamp in seconds.
-schema AddAbortsIf<T> {
- bridge_transfer_id: vector<u8>;
- table: SmartTable<vector<u8>, T>;
- aborts_if len(bridge_transfer_id) != 32;
- aborts_if smart_table::spec_contains(table, bridge_transfer_id);
- aborts_if !features::spec_is_enabled(features::ATOMIC_BRIDGE);
-}
+fun now(): u64
-
-
-### Function `add`
+
+Implementation
-public(friend) fun add<Initiator: store, Recipient: store>(bridge_transfer_id: vector<u8>, details: atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
+fun now() : u64 {
+ timestamp::now_seconds()
+}
+
-let table = global<SmartTableWrapper<vector<u8>, BridgeTransferDetails<Initiator, Recipient>>>(@aptos_framework).inner;
-include AddAbortsIf<BridgeTransferDetails<Initiator, Recipient>>;
-aborts_if !exists<SmartTableWrapper<vector<u8>, BridgeTransferDetails<Initiator, Recipient>>>(@aptos_framework);
-aborts_if smart_table::spec_contains(table, bridge_transfer_id);
-ensures smart_table::spec_contains(global<SmartTableWrapper<vector<u8>, BridgeTransferDetails<Initiator, Recipient>>>(@aptos_framework).inner, bridge_transfer_id);
-ensures smart_table::spec_len(global<SmartTableWrapper<vector<u8>, BridgeTransferDetails<Initiator, Recipient>>>(@aptos_framework).inner) ==
- old(smart_table::spec_len(global<SmartTableWrapper<vector<u8>, BridgeTransferDetails<Initiator, Recipient>>>(@aptos_framework).inner)) + 1;
-
-
+
+## Function `create_time_lock`
+Creates a time lock by adding a duration to the current time.
-
+@param lock The duration to lock.
+@return The calculated time lock.
+@abort If lock is not above MIN_TIME_LOCK
-schema HashLockAbortsIf {
- hash_lock: vector<u8>;
- aborts_if len(hash_lock) != 32;
-}
+public(friend) fun create_time_lock(_time_lock: u64): u64
-
-
+
+Implementation
-schema BridgetTransferDetailsAbortsIf<Initiator, Recipient> {
- hash_lock: vector<u8>;
- details: BridgeTransferDetails<Initiator, Recipient>;
- include HashLockAbortsIf;
- aborts_if timestamp::spec_now_seconds() > details.time_lock;
- aborts_if !exists<CurrentTimeMicroseconds>(@aptos_framework);
- aborts_if details.state != PENDING_TRANSACTION;
- aborts_if details.hash_lock != hash_lock;
+public(friend) fun create_time_lock(_time_lock: u64) : u64 {
+ abort EATOMIC_BRIDGE_DISABLED
}
-
-
-### Function `create_hashlock`
+
+
-public(friend) fun create_hashlock(pre_image: vector<u8>): vector<u8>
-
+## Function `create_details`
+Creates bridge transfer details with validation.
+@param initiator The initiating party of the transfer.
+@param recipient The receiving party of the transfer.
+@param amount The amount to be transferred.
+@param hash_lock The hash lock for the transfer.
+@param time_lock The time lock for the transfer.
+@return A BridgeTransferDetails
object.
+@abort If the amount is zero or locks are invalid.
-aborts_if len(pre_image) == 0;
+public(friend) fun create_details<Initiator: store, Recipient: store>(_initiator: Initiator, _recipient: Recipient, _amount: u64, _hash_lock: vector<u8>, _time_lock: u64): atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>
-
-
-### Function `complete`
+
+Implementation
-fun complete<Initiator: store, Recipient: store>(details: &mut atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
+public(friend) fun create_details<Initiator: store, Recipient: store>(_initiator: Initiator, _recipient: Recipient, _amount: u64, _hash_lock: vector<u8>, _time_lock: u64)
+ : BridgeTransferDetails<Initiator, Recipient> {
+ abort EATOMIC_BRIDGE_DISABLED
+}
+
-requires details.state == PENDING_TRANSACTION;
-ensures details.state == COMPLETED_TRANSACTION;
-
-
+
+## Function `add`
-
+Record details of a transfer
-### Function `cancel`
+@param bridge_transfer_id Bridge transfer ID.
+@param details The bridge transfer details
-fun cancel<Initiator: store, Recipient: store>(details: &mut atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
+public(friend) fun add<Initiator: store, Recipient: store>(_bridge_transfer_id: vector<u8>, _details: atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
+
+Implementation
-requires details.state == PENDING_TRANSACTION;
-ensures details.state == CANCELLED_TRANSACTION;
-
+public(friend) fun add<Initiator: store, Recipient: store>(_bridge_transfer_id: vector<u8>, _details: BridgeTransferDetails<Initiator, Recipient>) {
+ abort EATOMIC_BRIDGE_DISABLED
+}
+
-
-### Function `complete_details`
+
+
-fun complete_details<Initiator: store, Recipient: copy, store>(hash_lock: vector<u8>, details: &mut atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>): (Recipient, u64)
-
+## Function `assert_min_time_lock`
+Asserts that the time lock is valid.
+@param time_lock
+@abort If the time lock is invalid.
-include BridgetTransferDetailsAbortsIf<Initiator, Recipient>;
+fun assert_min_time_lock(_time_lock: u64)
-
-
-### Function `complete_transfer`
+
+Implementation
-public(friend) fun complete_transfer<Initiator: store, Recipient: copy, store>(bridge_transfer_id: vector<u8>, hash_lock: vector<u8>): (Recipient, u64)
+fun assert_min_time_lock(_time_lock: u64) {
+ assert!(_time_lock >= MIN_TIME_LOCK, EINVALID_TIME_LOCK);
+}
+
-let table = global<SmartTableWrapper<vector<u8>, BridgeTransferDetails<Initiator, Recipient>>>(@aptos_framework).inner;
-aborts_if !features::spec_is_enabled(features::ATOMIC_BRIDGE);
-aborts_if !exists<SmartTableWrapper<vector<u8>, BridgeTransferDetails<Initiator, Recipient>>>(@aptos_framework);
-aborts_if !smart_table::spec_contains(table, bridge_transfer_id);
-let details = smart_table::spec_get(table, bridge_transfer_id);
-include BridgetTransferDetailsAbortsIf<Initiator, Recipient>;
-
-
+
+## Function `assert_pending`
+Asserts that the details state is pending.
-
+@param details The bridge transfer details to check.
+@abort If the state is not pending.
-schema AbortBridgetTransferDetailsAbortsIf<Initiator, Recipient> {
- details: BridgeTransferDetails<Initiator, Recipient>;
- aborts_if details.state != PENDING_TRANSACTION;
- aborts_if !(timestamp::spec_now_seconds() > details.time_lock);
- aborts_if !exists<CurrentTimeMicroseconds>(@aptos_framework);
- ensures details.state == CANCELLED_TRANSACTION;
-}
+fun assert_pending<Initiator: store, Recipient: store>(_details: &atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
-
-
-### Function `cancel_details`
+
+Implementation
-fun cancel_details<Initiator: copy, store, Recipient: store>(details: &mut atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>): (Initiator, u64)
+fun assert_pending<Initiator: store, Recipient: store>(_details: &BridgeTransferDetails<Initiator, Recipient>) {
+ assert!(_details.state == PENDING_TRANSACTION, ENOT_PENDING_TRANSACTION)
+}
+
-include AbortBridgetTransferDetailsAbortsIf<Initiator, Recipient>;
-
+
+## Function `assert_valid_hash_lock`
+Asserts that the hash lock is valid.
-
+@param hash_lock The hash lock to validate.
+@abort If the hash lock is invalid.
-# Module `0x1::atomic_bridge_configuration`
+fun assert_valid_hash_lock(_hash_lock: &vector<u8>)
+
-- [Resource `BridgeConfig`](#0x1_atomic_bridge_configuration_BridgeConfig)
-- [Struct `BridgeConfigOperatorUpdated`](#0x1_atomic_bridge_configuration_BridgeConfigOperatorUpdated)
-- [Struct `InitiatorTimeLockUpdated`](#0x1_atomic_bridge_configuration_InitiatorTimeLockUpdated)
-- [Struct `CounterpartyTimeLockUpdated`](#0x1_atomic_bridge_configuration_CounterpartyTimeLockUpdated)
-- [Constants](#@Constants_0)
-- [Function `initialize`](#0x1_atomic_bridge_configuration_initialize)
-- [Function `update_bridge_operator`](#0x1_atomic_bridge_configuration_update_bridge_operator)
-- [Function `set_initiator_time_lock_duration`](#0x1_atomic_bridge_configuration_set_initiator_time_lock_duration)
-- [Function `set_counterparty_time_lock_duration`](#0x1_atomic_bridge_configuration_set_counterparty_time_lock_duration)
-- [Function `initiator_timelock_duration`](#0x1_atomic_bridge_configuration_initiator_timelock_duration)
-- [Function `counterparty_timelock_duration`](#0x1_atomic_bridge_configuration_counterparty_timelock_duration)
-- [Function `bridge_operator`](#0x1_atomic_bridge_configuration_bridge_operator)
-- [Function `assert_is_caller_operator`](#0x1_atomic_bridge_configuration_assert_is_caller_operator)
-- [Specification](#@Specification_1)
- - [Function `initialize`](#@Specification_1_initialize)
- - [Function `update_bridge_operator`](#@Specification_1_update_bridge_operator)
+
+Implementation
-use 0x1::event;
-use 0x1::signer;
-use 0x1::system_addresses;
+
+fun assert_valid_hash_lock(_hash_lock: &vector<u8>) {
+ assert!(vector::length(_hash_lock) == 32, EINVALID_HASH_LOCK);
+}
-
+
-## Resource `BridgeConfig`
+
+
+## Function `assert_valid_bridge_transfer_id`
+
+Asserts that the bridge transfer ID is valid.
+@param bridge_transfer_id The bridge transfer ID to validate.
+@abort If the ID is invalid.
-struct BridgeConfig has key
+public(friend) fun assert_valid_bridge_transfer_id(_bridge_transfer_id: &vector<u8>)
-Fields
-
-
-
--
-
bridge_operator: address
-
--
+
Implementation
-
--
-
initiator_time_lock: u64
-
--
-
--
-
counterparty_time_lock: u64
-
--
+
public(friend) fun assert_valid_bridge_transfer_id(_bridge_transfer_id: &vector<u8>) {
+ assert!(vector::length(_bridge_transfer_id) == 32, EINVALID_BRIDGE_TRANSFER_ID);
+}
+
-
-
-
+
-## Struct `BridgeConfigOperatorUpdated`
+## Function `create_hashlock`
-Event emitted when the bridge operator is updated.
+Creates a hash lock from a pre-image.
+@param pre_image The pre-image to hash.
+@return The generated hash lock.
-#[event]
-struct BridgeConfigOperatorUpdated has drop, store
+
+public(friend) fun create_hashlock(_pre_image: vector<u8>): vector<u8>
-Fields
-
+Implementation
-
--
-
old_operator: address
-
--
-
--
-
new_operator: address
-
--
+
public(friend) fun create_hashlock(_pre_image: vector<u8>) : vector<u8> {
+ abort EATOMIC_BRIDGE_DISABLED
+}
+
-
-
-
+
-## Struct `InitiatorTimeLockUpdated`
+## Function `assert_correct_hash_lock`
-Event emitted when the initiator time lock has been updated.
+Asserts that the hash lock matches the expected value.
+
+@param details The bridge transfer details.
+@param hash_lock The hash lock to compare.
+@abort If the hash lock is incorrect.
-#[event]
-struct InitiatorTimeLockUpdated has drop, store
+fun assert_correct_hash_lock<Initiator: store, Recipient: store>(_details: &atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>, _hash_lock: vector<u8>)
-Fields
+Implementation
-
--
-
time_lock: u64
-
--
+
fun assert_correct_hash_lock<Initiator: store, Recipient: store>(_details: &BridgeTransferDetails<Initiator, Recipient>, _hash_lock: vector<u8>) {
+ assert!(&_hash_lock == &_details.hash_lock, EINVALID_PRE_IMAGE);
+}
+
-
-
-
+
-## Struct `CounterpartyTimeLockUpdated`
+## Function `assert_timed_out_lock`
-Event emitted when the initiator time lock has been updated.
+Asserts that the time lock has expired.
+@param details The bridge transfer details.
+@abort If the time lock has not expired.
-#[event]
-struct CounterpartyTimeLockUpdated has drop, store
+
+fun assert_timed_out_lock<Initiator: store, Recipient: store>(_details: &atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
-Fields
+Implementation
-
--
-
time_lock: u64
-
--
+
fun assert_timed_out_lock<Initiator: store, Recipient: store>(_details: &BridgeTransferDetails<Initiator, Recipient>) {
+ assert!(now() > _details.time_lock, ENOT_EXPIRED);
+}
+
-
-
-
+
-## Constants
+## Function `assert_within_timelock`
+Asserts we are still within the timelock.
-
+@param details The bridge transfer details.
+@abort If the time lock has expired.
-Counterparty time lock duration is 24 hours in seconds
+
+fun assert_within_timelock<Initiator: store, Recipient: store>(_details: &atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
+
-const COUNTERPARTY_TIME_LOCK_DUARTION: u64 = 86400;
+
+
+Implementation
+
+
+fun assert_within_timelock<Initiator: store, Recipient: store>(_details: &BridgeTransferDetails<Initiator, Recipient>) {
+ assert!(!(now() > _details.time_lock), EEXPIRED);
+}
-
+
-Error code for invalid bridge operator
+
+## Function `complete`
-const EINVALID_BRIDGE_OPERATOR: u64 = 1;
-
+Completes the bridge transfer.
+@param details The bridge transfer details to complete.
-
+fun complete<Initiator: store, Recipient: store>(_details: &mut atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
+
-Initiator time lock duration is 48 hours in seconds
-const INITIATOR_TIME_LOCK_DUARTION: u64 = 172800;
+
+Implementation
+
+
+fun complete<Initiator: store, Recipient: store>(_details: &mut BridgeTransferDetails<Initiator, Recipient>) {
+ _details.state = COMPLETED_TRANSACTION;
+}
-
+
-## Function `initialize`
+
-Initializes the bridge configuration with Aptos framework as the bridge operator.
+## Function `cancel`
-@param aptos_framework The signer representing the Aptos framework.
+Cancels the bridge transfer.
+
+@param details The bridge transfer details to cancel.
-public fun initialize(aptos_framework: &signer)
+fun cancel<Initiator: store, Recipient: store>(_details: &mut atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>)
@@ -1562,14 +1039,8 @@ Initializes the bridge configuration with Aptos framework as the bridge operator
Implementation
-public fun initialize(aptos_framework: &signer) {
- system_addresses::assert_aptos_framework(aptos_framework);
- let bridge_config = BridgeConfig {
- bridge_operator: signer::address_of(aptos_framework),
- initiator_time_lock: INITIATOR_TIME_LOCK_DUARTION,
- counterparty_time_lock: COUNTERPARTY_TIME_LOCK_DUARTION,
- };
- move_to(aptos_framework, bridge_config);
+fun cancel<Initiator: store, Recipient: store>(_details: &mut BridgeTransferDetails<Initiator, Recipient>) {
+ _details.state = CANCELLED_TRANSACTION;
}
@@ -1577,18 +1048,19 @@ Initializes the bridge configuration with Aptos framework as the bridge operator
-
+
-## Function `update_bridge_operator`
+## Function `complete_details`
-Updates the bridge operator, requiring governance validation.
+Validates and completes a bridge transfer by confirming the hash lock and state.
-@param aptos_framework The signer representing the Aptos framework.
-@param new_operator The new address to be set as the bridge operator.
-@abort If the current operator is the same as the new operator.
+@param hash_lock The hash lock used to validate the transfer.
+@param details The mutable reference to the bridge transfer details to be completed.
+@return A tuple containing the recipient and the amount of the transfer.
+@abort If the hash lock is invalid, the transfer is not pending, or the hash lock does not match.
-public fun update_bridge_operator(aptos_framework: &signer, new_operator: address)
+fun complete_details<Initiator: store, Recipient: copy, store>(_hash_lock: vector<u8>, _details: &mut atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>): (Recipient, u64)
@@ -1597,21 +1069,15 @@ Updates the bridge operator, requiring governance validation.
Implementation
-public fun update_bridge_operator(aptos_framework: &signer, new_operator: address
-) acquires BridgeConfig {
- system_addresses::assert_aptos_framework(aptos_framework);
- let bridge_config = borrow_global_mut<BridgeConfig>(@aptos_framework);
- let old_operator = bridge_config.bridge_operator;
- assert!(old_operator != new_operator, EINVALID_BRIDGE_OPERATOR);
+fun complete_details<Initiator: store, Recipient: store + copy>(_hash_lock: vector<u8>, _details: &mut BridgeTransferDetails<Initiator, Recipient>) : (Recipient, u64) {
+ assert_valid_hash_lock(&_hash_lock);
+ assert_pending(_details);
+ assert_correct_hash_lock(_details, _hash_lock);
+ assert_within_timelock(_details);
- bridge_config.bridge_operator = new_operator;
+ complete(_details);
- event::emit(
- BridgeConfigOperatorUpdated {
- old_operator,
- new_operator,
- },
- );
+ (_details.addresses.recipient, _details.amount)
}
@@ -1619,13 +1085,19 @@ Updates the bridge operator, requiring governance validation.
-
+
-## Function `set_initiator_time_lock_duration`
+## Function `complete_transfer`
+
+Completes a bridge transfer by validating the hash lock and updating the transfer state.
+@param bridge_transfer_id The ID of the bridge transfer to complete.
+@param hash_lock The hash lock used to validate the transfer.
+@return A tuple containing the recipient of the transfer and the amount transferred.
+@abort If the bridge transfer details are not found or if the completion checks in complete_details
fail.
-public fun set_initiator_time_lock_duration(aptos_framework: &signer, time_lock: u64)
+public(friend) fun complete_transfer<Initiator: store, Recipient: copy, store>(_bridge_transfer_id: vector<u8>, _hash_lock: vector<u8>): (Recipient, u64)
@@ -1634,16 +1106,8 @@ Updates the bridge operator, requiring governance validation.
Implementation
-public fun set_initiator_time_lock_duration(aptos_framework: &signer, time_lock: u64
-) acquires BridgeConfig {
- system_addresses::assert_aptos_framework(aptos_framework);
- borrow_global_mut<BridgeConfig>(@aptos_framework).initiator_time_lock = time_lock;
-
- event::emit(
- InitiatorTimeLockUpdated {
- time_lock
- },
- );
+public(friend) fun complete_transfer<Initiator: store, Recipient: copy + store>(_bridge_transfer_id: vector<u8>, _hash_lock: vector<u8>) : (Recipient, u64) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -1651,13 +1115,18 @@ Updates the bridge operator, requiring governance validation.
-
+
-## Function `set_counterparty_time_lock_duration`
+## Function `cancel_details`
+
+Cancels a pending bridge transfer if the time lock has expired.
+@param details A mutable reference to the bridge transfer details to be canceled.
+@return A tuple containing the initiator of the transfer and the amount to be refunded.
+@abort If the transfer is not in a pending state or the time lock has not expired.
-public fun set_counterparty_time_lock_duration(aptos_framework: &signer, time_lock: u64)
+fun cancel_details<Initiator: copy, store, Recipient: store>(_details: &mut atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>): (Initiator, u64)
@@ -1666,16 +1135,13 @@ Updates the bridge operator, requiring governance validation.
Implementation
-public fun set_counterparty_time_lock_duration(aptos_framework: &signer, time_lock: u64
-) acquires BridgeConfig {
- system_addresses::assert_aptos_framework(aptos_framework);
- borrow_global_mut<BridgeConfig>(@aptos_framework).counterparty_time_lock = time_lock;
+fun cancel_details<Initiator: store + copy, Recipient: store>(_details: &mut BridgeTransferDetails<Initiator, Recipient>) : (Initiator, u64) {
+ assert_pending(_details);
+ assert_timed_out_lock(_details);
+
+ cancel(_details);
- event::emit(
- CounterpartyTimeLockUpdated {
- time_lock
- },
- );
+ (_details.addresses.initiator, _details.amount)
}
@@ -1683,14 +1149,18 @@ Updates the bridge operator, requiring governance validation.
-
+
-## Function `initiator_timelock_duration`
+## Function `cancel_transfer`
+Cancels a bridge transfer if it is pending and the time lock has expired.
+
+@param bridge_transfer_id The ID of the bridge transfer to cancel.
+@return A tuple containing the initiator of the transfer and the amount to be refunded.
+@abort If the bridge transfer details are not found or if the cancellation conditions in cancel_details
fail.
-#[view]
-public fun initiator_timelock_duration(): u64
+public(friend) fun cancel_transfer<Initiator: copy, store, Recipient: store>(_bridge_transfer_id: vector<u8>): (Initiator, u64)
@@ -1699,8 +1169,8 @@ Updates the bridge operator, requiring governance validation.
Implementation
-public fun initiator_timelock_duration() : u64 acquires BridgeConfig {
- borrow_global<BridgeConfig>(@aptos_framework).initiator_time_lock
+public(friend) fun cancel_transfer<Initiator: store + copy, Recipient: store>(_bridge_transfer_id: vector<u8>) : (Initiator, u64) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -1708,14 +1178,17 @@ Updates the bridge operator, requiring governance validation.
-
+
-## Function `counterparty_timelock_duration`
+## Function `bridge_transfer_id`
+Generates a unique bridge transfer ID based on transfer details and nonce.
+@param details The bridge transfer details.
+@return The generated bridge transfer ID.
-#[view]
-public fun counterparty_timelock_duration(): u64
+
+public(friend) fun bridge_transfer_id<Initiator: store, Recipient: store>(_details: &atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>): vector<u8>
@@ -1724,8 +1197,8 @@ Updates the bridge operator, requiring governance validation.
Implementation
-public fun counterparty_timelock_duration() : u64 acquires BridgeConfig {
- borrow_global<BridgeConfig>(@aptos_framework).counterparty_time_lock
+public(friend) fun bridge_transfer_id<Initiator: store, Recipient: store>(_details: &BridgeTransferDetails<Initiator, Recipient>) : vector<u8> {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -1733,17 +1206,19 @@ Updates the bridge operator, requiring governance validation.
-
+
-## Function `bridge_operator`
+## Function `get_bridge_transfer_details_initiator`
-Retrieves the address of the current bridge operator.
+Gets initiator bridge transfer details given a bridge transfer ID
-@return The address of the current bridge operator.
+@param bridge_transfer_id A 32-byte vector of unsigned 8-bit integers.
+@return A BridgeTransferDetails
struct.
+@abort If there is no transfer in the atomic bridge store.
#[view]
-public fun bridge_operator(): address
+public fun get_bridge_transfer_details_initiator(_bridge_transfer_id: vector<u8>): atomic_bridge_store::BridgeTransferDetails<address, ethereum::EthereumAddress>
@@ -1752,8 +1227,10 @@ Retrieves the address of the current bridge operator.
Implementation
-public fun bridge_operator(): address acquires BridgeConfig {
- borrow_global_mut<BridgeConfig>(@aptos_framework).bridge_operator
+public fun get_bridge_transfer_details_initiator(
+ _bridge_transfer_id: vector<u8>
+): BridgeTransferDetails<address, EthereumAddress> {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -1761,17 +1238,19 @@ Retrieves the address of the current bridge operator.
-
+
-## Function `assert_is_caller_operator`
+## Function `get_bridge_transfer_details_counterparty`
-Asserts that the caller is the current bridge operator.
+Gets counterparty bridge transfer details given a bridge transfer ID
-@param caller The signer whose authority is being checked.
-@abort If the caller is not the current bridge operator.
+@param bridge_transfer_id A 32-byte vector of unsigned 8-bit integers.
+@return A BridgeTransferDetails
struct.
+@abort If there is no transfer in the atomic bridge store.
-public(friend) fun assert_is_caller_operator(caller: &signer)
+#[view]
+public fun get_bridge_transfer_details_counterparty(_bridge_transfer_id: vector<u8>): atomic_bridge_store::BridgeTransferDetails<ethereum::EthereumAddress, address>
@@ -1780,9 +1259,10 @@ Asserts that the caller is the current bridge operator.
Implementation
-public(friend) fun assert_is_caller_operator(caller: &signer
-) acquires BridgeConfig {
- assert!(borrow_global<BridgeConfig>(@aptos_framework).bridge_operator == signer::address_of(caller), EINVALID_BRIDGE_OPERATOR);
+public fun get_bridge_transfer_details_counterparty(
+ _bridge_transfer_id: vector<u8>
+): BridgeTransferDetails<EthereumAddress, address> {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -1790,84 +1270,106 @@ Asserts that the caller is the current bridge operator.
-
+
+
+## Function `get_bridge_transfer_details`
+
-## Specification
+
+fun get_bridge_transfer_details<Initiator: copy, store, Recipient: copy, store>(_bridge_transfer_id: vector<u8>): atomic_bridge_store::BridgeTransferDetails<Initiator, Recipient>
+
-
-### Function `initialize`
+
+Implementation
-public fun initialize(aptos_framework: &signer)
+fun get_bridge_transfer_details<Initiator: store + copy, Recipient: store + copy>(_bridge_transfer_id: vector<u8>
+): BridgeTransferDetails<Initiator, Recipient> {
+ abort EATOMIC_BRIDGE_DISABLED
+}
+
+
-aborts_if !system_addresses::is_aptos_framework_address(signer::address_of(aptos_framework));
-aborts_if exists<BridgeConfig>(signer::address_of(aptos_framework));
-ensures global<BridgeConfig>(signer::address_of(aptos_framework)).bridge_operator == signer::address_of(aptos_framework);
-
+
+
+# Module `0x1::atomic_bridge_configuration`
+
+
+
+- [Resource `BridgeConfig`](#0x1_atomic_bridge_configuration_BridgeConfig)
+- [Struct `BridgeConfigOperatorUpdated`](#0x1_atomic_bridge_configuration_BridgeConfigOperatorUpdated)
+- [Struct `InitiatorTimeLockUpdated`](#0x1_atomic_bridge_configuration_InitiatorTimeLockUpdated)
+- [Struct `CounterpartyTimeLockUpdated`](#0x1_atomic_bridge_configuration_CounterpartyTimeLockUpdated)
+- [Constants](#@Constants_0)
+- [Function `initialize`](#0x1_atomic_bridge_configuration_initialize)
+- [Function `update_bridge_operator`](#0x1_atomic_bridge_configuration_update_bridge_operator)
+- [Function `set_initiator_time_lock_duration`](#0x1_atomic_bridge_configuration_set_initiator_time_lock_duration)
+- [Function `set_counterparty_time_lock_duration`](#0x1_atomic_bridge_configuration_set_counterparty_time_lock_duration)
+- [Function `initiator_timelock_duration`](#0x1_atomic_bridge_configuration_initiator_timelock_duration)
+- [Function `counterparty_timelock_duration`](#0x1_atomic_bridge_configuration_counterparty_timelock_duration)
+- [Function `bridge_operator`](#0x1_atomic_bridge_configuration_bridge_operator)
+- [Function `assert_is_caller_operator`](#0x1_atomic_bridge_configuration_assert_is_caller_operator)
-
+
-### Function `update_bridge_operator`
-public fun update_bridge_operator(aptos_framework: &signer, new_operator: address)
-
+
+## Resource `BridgeConfig`
-aborts_if !system_addresses::is_aptos_framework_address(signer::address_of(aptos_framework));
-aborts_if !exists<BridgeConfig>(signer::address_of(aptos_framework));
-aborts_if global<BridgeConfig>(signer::address_of(aptos_framework)).bridge_operator == new_operator;
-ensures global<BridgeConfig>(signer::address_of(aptos_framework)).bridge_operator == new_operator;
+struct BridgeConfig has key
-
-
-# Module `0x1::atomic_bridge`
+
+Fields
+
+-
+
bridge_operator: address
+
+-
-- [Resource `AptosCoinBurnCapability`](#0x1_atomic_bridge_AptosCoinBurnCapability)
-- [Resource `AptosCoinMintCapability`](#0x1_atomic_bridge_AptosCoinMintCapability)
-- [Resource `AptosFABurnCapabilities`](#0x1_atomic_bridge_AptosFABurnCapabilities)
-- [Resource `AptosFAMintCapabilities`](#0x1_atomic_bridge_AptosFAMintCapabilities)
-- [Constants](#@Constants_0)
-- [Function `initialize`](#0x1_atomic_bridge_initialize)
-- [Function `store_aptos_coin_burn_cap`](#0x1_atomic_bridge_store_aptos_coin_burn_cap)
-- [Function `store_aptos_coin_mint_cap`](#0x1_atomic_bridge_store_aptos_coin_mint_cap)
-- [Function `mint`](#0x1_atomic_bridge_mint)
-- [Function `burn`](#0x1_atomic_bridge_burn)
+
+-
+
initiator_time_lock: u64
+
+-
+
+-
+
counterparty_time_lock: u64
+
+-
-
use 0x1::aptos_coin;
-use 0x1::atomic_bridge_configuration;
-use 0x1::atomic_bridge_store;
-use 0x1::coin;
-use 0x1::features;
-use 0x1::fungible_asset;
-use 0x1::system_addresses;
-
+
+
+
-
+
-## Resource `AptosCoinBurnCapability`
+## Struct `BridgeConfigOperatorUpdated`
+Event emitted when the bridge operator is updated.
-struct AptosCoinBurnCapability has key
+#[event]
+struct BridgeConfigOperatorUpdated has drop, store
@@ -1878,7 +1380,13 @@ Asserts that the caller is the current bridge operator.
-
-
burn_cap: coin::BurnCapability<aptos_coin::AptosCoin>
+old_operator: address
+
+-
+
+
+-
+
new_operator: address
-
@@ -1888,13 +1396,15 @@ Asserts that the caller is the current bridge operator.
-
+
-## Resource `AptosCoinMintCapability`
+## Struct `InitiatorTimeLockUpdated`
+Event emitted when the initiator time lock has been updated.
-
struct AptosCoinMintCapability has key
+#[event]
+struct InitiatorTimeLockUpdated has drop, store
@@ -1905,7 +1415,7 @@ Asserts that the caller is the current bridge operator.
-
-
mint_cap: coin::MintCapability<aptos_coin::AptosCoin>
+time_lock: u64
-
@@ -1915,13 +1425,15 @@ Asserts that the caller is the current bridge operator.
-
+
-## Resource `AptosFABurnCapabilities`
+## Struct `CounterpartyTimeLockUpdated`
+Event emitted when the initiator time lock has been updated.
-
struct AptosFABurnCapabilities has key
+#[event]
+struct CounterpartyTimeLockUpdated has drop, store
@@ -1932,7 +1444,7 @@ Asserts that the caller is the current bridge operator.
-
-
burn_ref: fungible_asset::BurnRef
+time_lock: u64
-
@@ -1942,57 +1454,61 @@ Asserts that the caller is the current bridge operator.
-
+
-## Resource `AptosFAMintCapabilities`
+## Constants
+
-
struct AptosFAMintCapabilities has key
+Error code for atomic bridge disabled
+
+
+const EATOMIC_BRIDGE_DISABLED: u64 = 2;
-
-Fields
+
+Counterparty time lock duration is 24 hours in seconds
-
--
-
burn_ref: fungible_asset::MintRef
-
--
-
-
+const COUNTERPARTY_TIME_LOCK_DUARTION: u64 = 86400;
+
-
-
+
-## Constants
+Error code for invalid bridge operator
-
+const EINVALID_BRIDGE_OPERATOR: u64 = 1;
+
-const EATOMIC_BRIDGE_NOT_ENABLED: u64 = 1;
+
+
+Initiator time lock duration is 48 hours in seconds
+
+
+const INITIATOR_TIME_LOCK_DUARTION: u64 = 172800;
-
+
## Function `initialize`
-Initializes the atomic bridge by setting up necessary configurations.
+Initializes the bridge configuration with Aptos framework as the bridge operator.
@param aptos_framework The signer representing the Aptos framework.
-public fun initialize(aptos_framework: &signer)
+public fun initialize(_aptos_framework: &signer)
@@ -2001,9 +1517,8 @@ Initializes the atomic bridge by setting up necessary configurations.
Implementation
-public fun initialize(aptos_framework: &signer) {
- atomic_bridge_configuration::initialize(aptos_framework);
- atomic_bridge_store::initialize(aptos_framework);
+public fun initialize(_aptos_framework: &signer) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -2011,17 +1526,18 @@ Initializes the atomic bridge by setting up necessary configurations.
-
+
-## Function `store_aptos_coin_burn_cap`
+## Function `update_bridge_operator`
-Stores the burn capability for AptosCoin, converting to a fungible asset reference if the feature is enabled.
+Updates the bridge operator, requiring governance validation.
@param aptos_framework The signer representing the Aptos framework.
-@param burn_cap The burn capability for AptosCoin.
+@param new_operator The new address to be set as the bridge operator.
+@abort If the current operator is the same as the new operator.
-public fun store_aptos_coin_burn_cap(aptos_framework: &signer, burn_cap: coin::BurnCapability<aptos_coin::AptosCoin>)
+public fun update_bridge_operator(_aptos_framework: &signer, _new_operator: address)
@@ -2030,14 +1546,9 @@ Stores the burn capability for AptosCoin, converting to a fungible asset referen
Implementation
-public fun store_aptos_coin_burn_cap(aptos_framework: &signer, burn_cap: BurnCapability<AptosCoin>) {
- system_addresses::assert_aptos_framework(aptos_framework);
- if (features::operations_default_to_fa_apt_store_enabled()) {
- let burn_ref = coin::convert_and_take_paired_burn_ref(burn_cap);
- move_to(aptos_framework, AptosFABurnCapabilities { burn_ref });
- } else {
- move_to(aptos_framework, AptosCoinBurnCapability { burn_cap })
- }
+public fun update_bridge_operator(_aptos_framework: &signer, _new_operator: address
+) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -2045,17 +1556,13 @@ Stores the burn capability for AptosCoin, converting to a fungible asset referen
-
-
-## Function `store_aptos_coin_mint_cap`
+
-Stores the mint capability for AptosCoin.
+## Function `set_initiator_time_lock_duration`
-@param aptos_framework The signer representing the Aptos framework.
-@param mint_cap The mint capability for AptosCoin.
-public fun store_aptos_coin_mint_cap(aptos_framework: &signer, mint_cap: coin::MintCapability<aptos_coin::AptosCoin>)
+public fun set_initiator_time_lock_duration(_aptos_framework: &signer, _time_lock: u64)
@@ -2064,9 +1571,9 @@ Stores the mint capability for AptosCoin.
Implementation
-public fun store_aptos_coin_mint_cap(aptos_framework: &signer, mint_cap: MintCapability<AptosCoin>) {
- system_addresses::assert_aptos_framework(aptos_framework);
- move_to(aptos_framework, AptosCoinMintCapability { mint_cap })
+public fun set_initiator_time_lock_duration(_aptos_framework: &signer, _time_lock: u64
+) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -2074,18 +1581,39 @@ Stores the mint capability for AptosCoin.
-
+
-## Function `mint`
+## Function `set_counterparty_time_lock_duration`
-Mints a specified amount of AptosCoin to a recipient's address.
-@param recipient The address of the recipient to mint coins to.
-@param amount The amount of AptosCoin to mint.
-@abort If the mint capability is not available.
+
+public fun set_counterparty_time_lock_duration(_aptos_framework: &signer, _time_lock: u64)
+
+
+
+
+
+Implementation
+
+
+public fun set_counterparty_time_lock_duration(_aptos_framework: &signer, _time_lock: u64
+) {
+ abort EATOMIC_BRIDGE_DISABLED
+}
+
+
+
+
+
+
+
+
+## Function `initiator_timelock_duration`
+
-public(friend) fun mint(recipient: address, amount: u64)
+#[view]
+public fun initiator_timelock_duration(): u64
@@ -2094,13 +1622,33 @@ Mints a specified amount of AptosCoin to a recipient's address.
Implementation
-public(friend) fun mint(recipient: address, amount: u64) acquires AptosCoinMintCapability {
- assert!(features::abort_atomic_bridge_enabled(), EATOMIC_BRIDGE_NOT_ENABLED);
+public fun initiator_timelock_duration() : u64 {
+ abort EATOMIC_BRIDGE_DISABLED
+}
+
+
+
+
+
+
+
+
+## Function `counterparty_timelock_duration`
+
+
- coin::deposit(recipient, coin::mint(
- amount,
- &borrow_global<AptosCoinMintCapability>(@aptos_framework).mint_cap
- ));
+#[view]
+public fun counterparty_timelock_duration(): u64
+
+
+
+
+
+Implementation
+
+
+public fun counterparty_timelock_duration() : u64 {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -2108,18 +1656,17 @@ Mints a specified amount of AptosCoin to a recipient's address.
-
+
-## Function `burn`
+## Function `bridge_operator`
-Burns a specified amount of AptosCoin from an address.
+Retrieves the address of the current bridge operator.
-@param from The address from which to burn AptosCoin.
-@param amount The amount of AptosCoin to burn.
-@abort If the burn capability is not available.
+@return The address of the current bridge operator.
-public(friend) fun burn(from: address, amount: u64)
+#[view]
+public fun bridge_operator(): address
@@ -2128,14 +1675,37 @@ Burns a specified amount of AptosCoin from an address.
Implementation
-public(friend) fun burn(from: address, amount: u64) acquires AptosCoinBurnCapability {
- assert!(features::abort_atomic_bridge_enabled(), EATOMIC_BRIDGE_NOT_ENABLED);
+public fun bridge_operator(): address {
+ abort EATOMIC_BRIDGE_DISABLED
+}
+
+
+
+
+
+
+
+
+## Function `assert_is_caller_operator`
+
+Asserts that the caller is the current bridge operator.
+
+@param caller The signer whose authority is being checked.
+@abort If the caller is not the current bridge operator.
+
+
+public(friend) fun assert_is_caller_operator(_caller: &signer)
+
+
+
+
+
+Implementation
+
- coin::burn_from(
- from,
- amount,
- &borrow_global<AptosCoinBurnCapability>(@aptos_framework).burn_cap,
- );
+public(friend) fun assert_is_caller_operator(_caller: &signer
+) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -2155,6 +1725,7 @@ Burns a specified amount of AptosCoin from an address.
- [Struct `BridgeTransferCompletedEvent`](#0x1_atomic_bridge_counterparty_BridgeTransferCompletedEvent)
- [Struct `BridgeTransferCancelledEvent`](#0x1_atomic_bridge_counterparty_BridgeTransferCancelledEvent)
- [Resource `BridgeCounterpartyEvents`](#0x1_atomic_bridge_counterparty_BridgeCounterpartyEvents)
+- [Constants](#@Constants_0)
- [Function `initialize`](#0x1_atomic_bridge_counterparty_initialize)
- [Function `lock_bridge_transfer_assets`](#0x1_atomic_bridge_counterparty_lock_bridge_transfer_assets)
- [Function `complete_bridge_transfer`](#0x1_atomic_bridge_counterparty_complete_bridge_transfer)
@@ -2162,10 +1733,6 @@ Burns a specified amount of AptosCoin from an address.
use 0x1::account;
-use 0x1::atomic_bridge;
-use 0x1::atomic_bridge_configuration;
-use 0x1::atomic_bridge_store;
-use 0x1::ethereum;
use 0x1::event;
@@ -2334,6 +1901,20 @@ This struct will store the event handles for bridge events.
+
+
+## Constants
+
+
+
+
+
+
+const EATOMIC_BRIDGE_DISABLED: u64 = 198461;
+
+
+
+
## Function `initialize`
@@ -2379,7 +1960,7 @@ Locks assets for a bridge transfer by the initiator.
@abort If the caller is not the bridge operator.
-public entry fun lock_bridge_transfer_assets(caller: &signer, initiator: vector<u8>, bridge_transfer_id: vector<u8>, hash_lock: vector<u8>, recipient: address, amount: u64)
+public entry fun lock_bridge_transfer_assets(_caller: &signer, _initiator: vector<u8>, _bridge_transfer_id: vector<u8>, _hash_lock: vector<u8>, _recipient: address, _amount: u64)
@@ -2389,40 +1970,14 @@ Locks assets for a bridge transfer by the initiator.
public entry fun lock_bridge_transfer_assets (
- caller: &signer,
- initiator: vector<u8>,
- bridge_transfer_id: vector<u8>,
- hash_lock: vector<u8>,
- recipient: address,
- amount: u64
-) acquires BridgeCounterpartyEvents {
- atomic_bridge_configuration::assert_is_caller_operator(caller);
- let ethereum_address = ethereum::ethereum_address_no_eip55(initiator);
- let time_lock = atomic_bridge_configuration::counterparty_timelock_duration();
- let details = atomic_bridge_store::create_details(
- ethereum_address,
- recipient,
- amount,
- hash_lock,
- time_lock
- );
-
- // bridge_store::add_counterparty(bridge_transfer_id, details);
- atomic_bridge_store::add(bridge_transfer_id, details);
-
- let bridge_events = borrow_global_mut<BridgeCounterpartyEvents>(@aptos_framework);
-
- event::emit_event(
- &mut bridge_events.bridge_transfer_locked_events,
- BridgeTransferLockedEvent {
- bridge_transfer_id,
- initiator,
- recipient,
- amount,
- hash_lock,
- time_lock,
- },
- );
+ _caller: &signer,
+ _initiator: vector<u8>,
+ _bridge_transfer_id: vector<u8>,
+ _hash_lock: vector<u8>,
+ _recipient: address,
+ _amount: u64
+) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -2441,7 +1996,7 @@ Completes a bridge transfer by revealing the pre-image.
@abort If the caller is not the bridge operator or the hash lock validation fails.
-public entry fun complete_bridge_transfer(bridge_transfer_id: vector<u8>, pre_image: vector<u8>)
+public entry fun complete_bridge_transfer(_bridge_transfer_id: vector<u8>, _pre_image: vector<u8>)
@@ -2451,25 +2006,10 @@ Completes a bridge transfer by revealing the pre-image.
public entry fun complete_bridge_transfer (
- bridge_transfer_id: vector<u8>,
- pre_image: vector<u8>,
-) acquires BridgeCounterpartyEvents {
- let (recipient, amount) = atomic_bridge_store::complete_transfer<EthereumAddress, address>(
- bridge_transfer_id,
- create_hashlock(pre_image)
- );
-
- // Mint, fails silently
- atomic_bridge::mint(recipient, amount);
-
- let bridge_counterparty_events = borrow_global_mut<BridgeCounterpartyEvents>(@aptos_framework);
- event::emit_event(
- &mut bridge_counterparty_events.bridge_transfer_completed_events,
- BridgeTransferCompletedEvent {
- bridge_transfer_id,
- pre_image,
- },
- );
+ _bridge_transfer_id: vector<u8>,
+ _pre_image: vector<u8>,
+) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -2488,7 +2028,7 @@ Aborts a bridge transfer if the time lock has expired.
@abort If the caller is not the bridge operator or if the time lock has not expired.
-public entry fun abort_bridge_transfer(caller: &signer, bridge_transfer_id: vector<u8>)
+public entry fun abort_bridge_transfer(_caller: &signer, _bridge_transfer_id: vector<u8>)
@@ -2498,20 +2038,10 @@ Aborts a bridge transfer if the time lock has expired.
public entry fun abort_bridge_transfer (
- caller: &signer,
- bridge_transfer_id: vector<u8>
-) acquires BridgeCounterpartyEvents {
- atomic_bridge_configuration::assert_is_caller_operator(caller);
-
- atomic_bridge_store::cancel_transfer<EthereumAddress, address>(bridge_transfer_id);
-
- let bridge_counterparty_events = borrow_global_mut<BridgeCounterpartyEvents>(@aptos_framework);
- event::emit_event(
- &mut bridge_counterparty_events.bridge_transfer_cancelled_events,
- BridgeTransferCancelledEvent {
- bridge_transfer_id,
- },
- );
+ _caller: &signer,
+ _bridge_transfer_id: vector<u8>
+) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -2531,19 +2061,14 @@ Aborts a bridge transfer if the time lock has expired.
- [Struct `BridgeTransferCompletedEvent`](#0x1_atomic_bridge_initiator_BridgeTransferCompletedEvent)
- [Struct `BridgeTransferRefundedEvent`](#0x1_atomic_bridge_initiator_BridgeTransferRefundedEvent)
- [Resource `BridgeInitiatorEvents`](#0x1_atomic_bridge_initiator_BridgeInitiatorEvents)
+- [Constants](#@Constants_0)
- [Function `initialize`](#0x1_atomic_bridge_initiator_initialize)
- [Function `initiate_bridge_transfer`](#0x1_atomic_bridge_initiator_initiate_bridge_transfer)
- [Function `complete_bridge_transfer`](#0x1_atomic_bridge_initiator_complete_bridge_transfer)
- [Function `refund_bridge_transfer`](#0x1_atomic_bridge_initiator_refund_bridge_transfer)
-use 0x1::account;
-use 0x1::atomic_bridge;
-use 0x1::atomic_bridge_configuration;
-use 0x1::atomic_bridge_store;
-use 0x1::ethereum;
-use 0x1::event;
-use 0x1::signer;
+use 0x1::event;
@@ -2708,6 +2233,20 @@ This struct will store the event handles for bridge events.
+
+
+## Constants
+
+
+
+
+
+
+const EATOMIC_BRIDGE_DISABLED: u64 = 198461;
+
+
+
+
## Function `initialize`
@@ -2715,7 +2254,7 @@ This struct will store the event handles for bridge events.
Initializes the module and stores the EventHandle
s in the resource.
-public fun initialize(aptos_framework: &signer)
+public fun initialize(_aptos_framework: &signer)
@@ -2724,12 +2263,8 @@ Initializes the module and stores the EventHandle
s in the resource.
Implementation
-public fun initialize(aptos_framework: &signer) {
- move_to(aptos_framework, BridgeInitiatorEvents {
- bridge_transfer_initiated_events: account::new_event_handle<BridgeTransferInitiatedEvent>(aptos_framework),
- bridge_transfer_completed_events: account::new_event_handle<BridgeTransferCompletedEvent>(aptos_framework),
- bridge_transfer_refunded_events: account::new_event_handle<BridgeTransferRefundedEvent>(aptos_framework),
- });
+public fun initialize(_aptos_framework: &signer) {
+
}
@@ -2746,7 +2281,7 @@ Anyone can initiate a bridge transfer from the source chain
The amount is burnt from the initiator
-public entry fun initiate_bridge_transfer(initiator: &signer, recipient: vector<u8>, hash_lock: vector<u8>, amount: u64)
+public entry fun initiate_bridge_transfer(_initiator: &signer, _recipient: vector<u8>, _hash_lock: vector<u8>, _amount: u64)
@@ -2756,39 +2291,12 @@ The amount is burnt from the initiator
public entry fun initiate_bridge_transfer(
- initiator: &signer,
- recipient: vector<u8>,
- hash_lock: vector<u8>,
- amount: u64
-) acquires BridgeInitiatorEvents {
- let ethereum_address = ethereum::ethereum_address_no_eip55(recipient);
- let initiator_address = signer::address_of(initiator);
- let time_lock = atomic_bridge_configuration::initiator_timelock_duration();
-
- let details =
- atomic_bridge_store::create_details(
- initiator_address,
- ethereum_address, amount,
- hash_lock,
- time_lock
- );
-
- let bridge_transfer_id = bridge_transfer_id(&details);
- atomic_bridge_store::add(bridge_transfer_id, details);
- atomic_bridge::burn(initiator_address, amount);
-
- let bridge_initiator_events = borrow_global_mut<BridgeInitiatorEvents>(@aptos_framework);
- event::emit_event(
- &mut bridge_initiator_events.bridge_transfer_initiated_events,
- BridgeTransferInitiatedEvent {
- bridge_transfer_id,
- initiator: initiator_address,
- recipient,
- amount,
- hash_lock,
- time_lock
- },
- );
+ _initiator: &signer,
+ _recipient: vector<u8>,
+ _hash_lock: vector<u8>,
+ _amount: u64
+) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -2803,7 +2311,7 @@ The amount is burnt from the initiator
Bridge operator can complete the transfer
-public entry fun complete_bridge_transfer(caller: &signer, bridge_transfer_id: vector<u8>, pre_image: vector<u8>)
+public entry fun complete_bridge_transfer(_caller: &signer, _bridge_transfer_id: vector<u8>, _pre_image: vector<u8>)
@@ -2813,21 +2321,11 @@ Bridge operator can complete the transfer
public entry fun complete_bridge_transfer (
- caller: &signer,
- bridge_transfer_id: vector<u8>,
- pre_image: vector<u8>,
-) acquires BridgeInitiatorEvents {
- assert_is_caller_operator(caller);
- let (_, _) = atomic_bridge_store::complete_transfer<address, EthereumAddress>(bridge_transfer_id, create_hashlock(pre_image));
-
- let bridge_initiator_events = borrow_global_mut<BridgeInitiatorEvents>(@aptos_framework);
- event::emit_event(
- &mut bridge_initiator_events.bridge_transfer_completed_events,
- BridgeTransferCompletedEvent {
- bridge_transfer_id,
- pre_image,
- },
- );
+ _caller: &signer,
+ _bridge_transfer_id: vector<u8>,
+ _pre_image: vector<u8>,
+) {
+ abort EATOMIC_BRIDGE_DISABLED
}
@@ -2842,7 +2340,7 @@ Bridge operator can complete the transfer
Anyone can refund the transfer on the source chain once time lock has passed
-public entry fun refund_bridge_transfer(_caller: &signer, bridge_transfer_id: vector<u8>)
+public entry fun refund_bridge_transfer(_caller: &signer, _bridge_transfer_id: vector<u8>)
@@ -2853,18 +2351,9 @@ Anyone can refund the transfer on the source chain once time lock has passed
public entry fun refund_bridge_transfer (
_caller: &signer,
- bridge_transfer_id: vector<u8>,
-) acquires BridgeInitiatorEvents {
- let (receiver, amount) = atomic_bridge_store::cancel_transfer<address, EthereumAddress>(bridge_transfer_id);
- atomic_bridge::mint(receiver, amount);
-
- let bridge_initiator_events = borrow_global_mut<BridgeInitiatorEvents>(@aptos_framework);
- event::emit_event(
- &mut bridge_initiator_events.bridge_transfer_refunded_events,
- BridgeTransferRefundedEvent {
- bridge_transfer_id,
- },
- );
+ _bridge_transfer_id: vector<u8>,
+) {
+ abort EATOMIC_BRIDGE_DISABLED
}
diff --git a/aptos-move/framework/aptos-framework/doc/native_bridge.md b/aptos-move/framework/aptos-framework/doc/native_bridge.md
index bc7c86d56ef71..49295ee9ff0ba 100644
--- a/aptos-move/framework/aptos-framework/doc/native_bridge.md
+++ b/aptos-move/framework/aptos-framework/doc/native_bridge.md
@@ -59,20 +59,12 @@
- [Function `test_normalize_u64_to_32_bytes_helper`](#0x1_native_bridge_test_normalize_u64_to_32_bytes_helper)
-use 0x1::account;
-use 0x1::aptos_coin;
-use 0x1::aptos_hash;
-use 0x1::bcs;
+use 0x1::aptos_coin;
use 0x1::coin;
use 0x1::ethereum;
use 0x1::event;
-use 0x1::features;
use 0x1::fungible_asset;
-use 0x1::signer;
use 0x1::smart_table;
-use 0x1::system_addresses;
-use 0x1::timestamp;
-use 0x1::vector;
@@ -804,7 +796,7 @@ Details on the outbound transfer
Initializes the module and stores the EventHandle
s in the resource.
-public fun initialize(aptos_framework: &signer)
+public fun initialize(_aptos_framework: &signer)
@@ -813,59 +805,8 @@ Initializes the module and stores the EventHandle
s in the resource.
Implementation
-public fun initialize(aptos_framework: &signer) {
- system_addresses::assert_aptos_framework(aptos_framework);
+public fun initialize(_aptos_framework: &signer) {
- let bridge_config = BridgeConfig {
- bridge_relayer: signer::address_of(aptos_framework),
- insurance_fund: signer::address_of(aptos_framework),
- insurance_budget_divider: 4,
- bridge_fee: 40_000_000_000,
- };
- move_to(aptos_framework, bridge_config);
-
- // Ensure the nonce is not already initialized
- assert!(
- !exists<Nonce>(signer::address_of(aptos_framework)),
- 2
- );
-
- // Create the Nonce resource with an initial value of 0
- move_to<Nonce>(aptos_framework, Nonce {
- value: 0
- });
-
-
- move_to(aptos_framework, BridgeEvents {
- bridge_transfer_initiated_events: account::new_event_handle<BridgeTransferInitiatedEvent>(aptos_framework),
- bridge_transfer_completed_events: account::new_event_handle<BridgeTransferCompletedEvent>(aptos_framework),
- });
- system_addresses::assert_aptos_framework(aptos_framework);
-
- let outbound_rate_limit_budget = OutboundRateLimitBudget {
- day: smart_table::new(),
- };
-
- move_to(aptos_framework, outbound_rate_limit_budget);
-
-
- let inbound_rate_limit_budget = InboundRateLimitBudget {
- day: smart_table::new(),
- };
-
- move_to(aptos_framework, inbound_rate_limit_budget);
-
- let nonces_to_details = SmartTableWrapper<u64, OutboundTransfer> {
- inner: smart_table::new(),
- };
-
- move_to(aptos_framework, nonces_to_details);
-
- let ids_to_inbound_nonces = SmartTableWrapper<vector<u8>, u64> {
- inner: smart_table::new(),
- };
-
- move_to(aptos_framework, ids_to_inbound_nonces);
}
@@ -888,7 +829,7 @@ How BCS works: https://github.com/zefchain/bcs?tab=readme-ov-file#booleans-and-i
[0x00, 0x00, ..., 0x00, 0x12, 0x34, 0x56, 0x78, 0xab, 0xcd, 0xef, 0x00]
-public(friend) fun normalize_u64_to_32_bytes(value: &u64): vector<u8>
+public(friend) fun normalize_u64_to_32_bytes(_value: &u64): vector<u8>
@@ -897,11 +838,8 @@ How BCS works: https://github.com/zefchain/bcs?tab=readme-ov-file#booleans-and-i
Implementation
-public(friend) fun normalize_u64_to_32_bytes(value: &u64): vector<u8> {
- let r = bcs::to_bytes(&(*value as u256));
- // BCS returns the bytes in reverse order, so we reverse the result.
- vector::reverse(&mut r);
- r
+public(friend) fun normalize_u64_to_32_bytes(_value: &u64): vector<u8> {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -918,7 +856,7 @@ Checks if a bridge transfer ID is associated with an inbound nonce.
@return true
if the ID is associated with an existing inbound nonce, false
otherwise.
-public(friend) fun is_inbound_nonce_set(bridge_transfer_id: vector<u8>): bool
+public(friend) fun is_inbound_nonce_set(_bridge_transfer_id: vector<u8>): bool
@@ -927,9 +865,8 @@ Checks if a bridge transfer ID is associated with an inbound nonce.
Implementation
-public(friend) fun is_inbound_nonce_set(bridge_transfer_id: vector<u8>): bool acquires SmartTableWrapper {
- let table = borrow_global<SmartTableWrapper<vector<u8>, u64>>(@aptos_framework);
- smart_table::contains(&table.inner, bridge_transfer_id)
+public(friend) fun is_inbound_nonce_set(_bridge_transfer_id: vector<u8>): bool {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -951,7 +888,7 @@ Creates bridge transfer details with validation.
@abort If the amount is zero or locks are invalid.
-public(friend) fun create_details(initiator: address, recipient: ethereum::EthereumAddress, amount: u64, nonce: u64): native_bridge::OutboundTransfer
+public(friend) fun create_details(_initiator: address, _recipient: ethereum::EthereumAddress, _amount: u64, _nonce: u64): native_bridge::OutboundTransfer
@@ -960,24 +897,9 @@ Creates bridge transfer details with validation.
Implementation
-public(friend) fun create_details(initiator: address, recipient: EthereumAddress, amount: u64, nonce: u64)
+public(friend) fun create_details(_initiator: address, _recipient: EthereumAddress, _amount: u64, _nonce: u64)
: OutboundTransfer {
- assert!(amount > 0, EZERO_AMOUNT);
-
- // Create a bridge transfer ID algorithmically
- let combined_bytes = vector::empty<u8>();
- vector::append(&mut combined_bytes, bcs::to_bytes(&initiator));
- vector::append(&mut combined_bytes, bcs::to_bytes(&recipient));
- vector::append(&mut combined_bytes, bcs::to_bytes(&amount));
- vector::append(&mut combined_bytes, bcs::to_bytes(&nonce));
- let bridge_transfer_id = keccak256(combined_bytes);
-
- OutboundTransfer {
- bridge_transfer_id,
- initiator,
- recipient,
- amount,
- }
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -995,7 +917,7 @@ Record details of an initiated transfer for quick lookup of details, mapping bri
@param details The bridge transfer details
-public(friend) fun add(nonce: u64, details: native_bridge::OutboundTransfer)
+public(friend) fun add(_nonce: u64, _details: native_bridge::OutboundTransfer)
@@ -1004,11 +926,8 @@ Record details of an initiated transfer for quick lookup of details, mapping bri
Implementation
-public(friend) fun add(nonce: u64, details: OutboundTransfer) acquires SmartTableWrapper {
- assert!(features::abort_native_bridge_enabled(), ENATIVE_BRIDGE_NOT_ENABLED);
-
- let table = borrow_global_mut<SmartTableWrapper<u64, OutboundTransfer>>(@aptos_framework);
- smart_table::add(&mut table.inner, nonce, details);
+public(friend) fun add(_nonce: u64, _details: OutboundTransfer) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1026,7 +945,7 @@ Record details of a completed transfer, mapping bridge transfer ID to inbound no
@param details The bridge transfer details
-public(friend) fun set_bridge_transfer_id_to_inbound_nonce(bridge_transfer_id: vector<u8>, inbound_nonce: u64)
+public(friend) fun set_bridge_transfer_id_to_inbound_nonce(_bridge_transfer_id: vector<u8>, _inbound_nonce: u64)
@@ -1035,12 +954,8 @@ Record details of a completed transfer, mapping bridge transfer ID to inbound no
Implementation
-public(friend) fun set_bridge_transfer_id_to_inbound_nonce(bridge_transfer_id: vector<u8>, inbound_nonce: u64) acquires SmartTableWrapper {
- assert!(features::abort_native_bridge_enabled(), ENATIVE_BRIDGE_NOT_ENABLED);
-
- assert_valid_bridge_transfer_id(&bridge_transfer_id);
- let table = borrow_global_mut<SmartTableWrapper<vector<u8>, u64>>(@aptos_framework);
- smart_table::add(&mut table.inner, bridge_transfer_id, inbound_nonce);
+public(friend) fun set_bridge_transfer_id_to_inbound_nonce(_bridge_transfer_id: vector<u8>, _inbound_nonce: u64) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1058,7 +973,7 @@ Asserts that the bridge transfer ID is valid.
@abort If the ID is invalid.
-public(friend) fun assert_valid_bridge_transfer_id(bridge_transfer_id: &vector<u8>)
+public(friend) fun assert_valid_bridge_transfer_id(_bridge_transfer_id: &vector<u8>)
@@ -1067,8 +982,8 @@ Asserts that the bridge transfer ID is valid.
Implementation
-public(friend) fun assert_valid_bridge_transfer_id(bridge_transfer_id: &vector<u8>) {
- assert!(vector::length(bridge_transfer_id) == 32, EINVALID_BRIDGE_TRANSFER_ID);
+public(friend) fun assert_valid_bridge_transfer_id(_bridge_transfer_id: &vector<u8>) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1086,7 +1001,7 @@ Generates a unique outbound bridge transfer ID based on transfer details and non
@return The generated bridge transfer ID.
-public(friend) fun bridge_transfer_id(initiator: address, recipient: ethereum::EthereumAddress, amount: u64, nonce: u64): vector<u8>
+public(friend) fun bridge_transfer_id(_initiator: address, _recipient: ethereum::EthereumAddress, _amount: u64, _nonce: u64): vector<u8>
@@ -1095,19 +1010,8 @@ Generates a unique outbound bridge transfer ID based on transfer details and non
Implementation
-public(friend) fun bridge_transfer_id(initiator: address, recipient: EthereumAddress, amount: u64, nonce: u64) : vector<u8> {
- // Serialize each param
- let initiator_bytes = bcs::to_bytes<address>(&initiator);
- let recipient_bytes = ethereum::get_inner_ethereum_address(recipient);
- let amount_bytes = normalize_u64_to_32_bytes(&amount);
- let nonce_bytes = normalize_u64_to_32_bytes(&nonce);
- //Contatenate then hash and return bridge transfer ID
- let combined_bytes = vector::empty<u8>();
- vector::append(&mut combined_bytes, initiator_bytes);
- vector::append(&mut combined_bytes, recipient_bytes);
- vector::append(&mut combined_bytes, amount_bytes);
- vector::append(&mut combined_bytes, nonce_bytes);
- keccak256(combined_bytes)
+public(friend) fun bridge_transfer_id(_initiator: address, _recipient: EthereumAddress, _amount: u64, _nonce: u64) : vector<u8> {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1134,8 +1038,8 @@ Retrieves the address of the current bridge relayer.
Implementation
-public fun bridge_relayer(): address acquires BridgeConfig {
- borrow_global_mut<BridgeConfig>(@aptos_framework).bridge_relayer
+public fun bridge_relayer(): address {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1162,8 +1066,8 @@ Retrieves the address of the current insurance fund.
Implementation
-public fun insurance_fund(): address acquires BridgeConfig {
- borrow_global_mut<BridgeConfig>(@aptos_framework).insurance_fund
+public fun insurance_fund(): address {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1190,8 +1094,8 @@ Retrieves the current insurance budget divider.
Implementation
-public fun insurance_budget_divider(): u64 acquires BridgeConfig {
- borrow_global_mut<BridgeConfig>(@aptos_framework).insurance_budget_divider
+public fun insurance_budget_divider(): u64 {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1218,8 +1122,8 @@ Retrieves the current bridge fee.
Implementation
-public fun bridge_fee(): u64 acquires BridgeConfig {
- borrow_global_mut<BridgeConfig>(@aptos_framework).bridge_fee
+public fun bridge_fee(): u64 {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1238,7 +1142,7 @@ Gets the bridge transfer details (get_bridge_transfer_details_from_nonce(nonce: u64): native_bridge::OutboundTransfer
+public fun get_bridge_transfer_details_from_nonce(_nonce: u64): native_bridge::OutboundTransfer
@@ -1247,14 +1151,8 @@ Gets the bridge transfer details (get_bridge_transfer_details_from_nonce(nonce: u64): OutboundTransfer acquires SmartTableWrapper {
- let table = borrow_global<SmartTableWrapper<u64, OutboundTransfer>>(@aptos_framework);
-
- // Check if the nonce exists in the table
- assert!(smart_table::contains(&table.inner, nonce), ENONCE_NOT_FOUND);
-
- // If it exists, return the associated `OutboundTransfer` details
- *smart_table::borrow(&table.inner, nonce)
+public fun get_bridge_transfer_details_from_nonce(_nonce: u64): OutboundTransfer {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1273,7 +1171,7 @@ Gets inbound nonce
from bridge_transfer_id
#[view]
-public fun get_inbound_nonce_from_bridge_transfer_id(bridge_transfer_id: vector<u8>): u64
+public fun get_inbound_nonce_from_bridge_transfer_id(_bridge_transfer_id: vector<u8>): u64
@@ -1282,14 +1180,8 @@ Gets inbound nonce
from bridge_transfer_id
Implementation
-public fun get_inbound_nonce_from_bridge_transfer_id(bridge_transfer_id: vector<u8>): u64 acquires SmartTableWrapper {
- let table = borrow_global<SmartTableWrapper<vector<u8>, u64>>(@aptos_framework);
-
- // Check if the nonce exists in the table
- assert!(smart_table::contains(&table.inner, bridge_transfer_id), ENONCE_NOT_FOUND);
-
- // If it exists, return the associated nonce
- *smart_table::borrow(&table.inner, bridge_transfer_id)
+public fun get_inbound_nonce_from_bridge_transfer_id(_bridge_transfer_id: vector<u8>): u64 {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1313,10 +1205,8 @@ Increment and get the current nonce
Implementation
-fun increment_and_get_nonce(): u64 acquires Nonce {
- let nonce_ref = borrow_global_mut<Nonce>(@aptos_framework);
- nonce_ref.value = nonce_ref.value + 1;
- nonce_ref.value
+fun increment_and_get_nonce(): u64 {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1334,7 +1224,7 @@ Stores the burn capability for AptosCoin, converting to a fungible asset referen
@param burn_cap The burn capability for AptosCoin.
-public fun store_aptos_coin_burn_cap(aptos_framework: &signer, burn_cap: coin::BurnCapability<aptos_coin::AptosCoin>)
+public fun store_aptos_coin_burn_cap(_aptos_framework: &signer, _burn_cap: coin::BurnCapability<aptos_coin::AptosCoin>)
@@ -1343,14 +1233,8 @@ Stores the burn capability for AptosCoin, converting to a fungible asset referen
Implementation
-public fun store_aptos_coin_burn_cap(aptos_framework: &signer, burn_cap: BurnCapability<AptosCoin>) {
- system_addresses::assert_aptos_framework(aptos_framework);
- if (features::operations_default_to_fa_apt_store_enabled()) {
- let burn_ref = coin::convert_and_take_paired_burn_ref(burn_cap);
- move_to(aptos_framework, AptosFABurnCapabilities { burn_ref });
- } else {
- move_to(aptos_framework, AptosCoinBurnCapability { burn_cap })
- }
+public fun store_aptos_coin_burn_cap(_aptos_framework: &signer, _burn_cap: BurnCapability<AptosCoin>) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1368,7 +1252,7 @@ Stores the mint capability for AptosCoin.
@param mint_cap The mint capability for AptosCoin.
-public fun store_aptos_coin_mint_cap(aptos_framework: &signer, mint_cap: coin::MintCapability<aptos_coin::AptosCoin>)
+public fun store_aptos_coin_mint_cap(_aptos_framework: &signer, _mint_cap: coin::MintCapability<aptos_coin::AptosCoin>)
@@ -1377,9 +1261,8 @@ Stores the mint capability for AptosCoin.
Implementation
-public fun store_aptos_coin_mint_cap(aptos_framework: &signer, mint_cap: MintCapability<AptosCoin>) {
- system_addresses::assert_aptos_framework(aptos_framework);
- move_to(aptos_framework, AptosCoinMintCapability { mint_cap })
+public fun store_aptos_coin_mint_cap(_aptos_framework: &signer, _mint_cap: MintCapability<AptosCoin>) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1398,7 +1281,7 @@ Mints a specified amount of AptosCoin to a recipient's address.
@param amount The amount of AptosCoin to mint.
-public fun mint_to(aptos_framework: &signer, recipient: address, amount: u64)
+public fun mint_to(_aptos_framework: &signer, _recipient: address, _amount: u64)
@@ -1407,9 +1290,8 @@ Mints a specified amount of AptosCoin to a recipient's address.
Implementation
-public fun mint_to(aptos_framework: &signer, recipient: address, amount: u64) acquires AptosCoinMintCapability {
- system_addresses::assert_aptos_framework(aptos_framework);
- mint_internal(recipient, amount);
+public fun mint_to(_aptos_framework: &signer, _recipient: address, _amount: u64) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1428,7 +1310,7 @@ Mints a specified amount of AptosCoin to a recipient's address.
@abort If the mint capability is not available.
-public(friend) fun mint(recipient: address, amount: u64)
+public(friend) fun mint(_recipient: address, _amount: u64)
@@ -1437,10 +1319,8 @@ Mints a specified amount of AptosCoin to a recipient's address.
Implementation
-public(friend) fun mint(recipient: address, amount: u64) acquires AptosCoinMintCapability {
- assert!(features::abort_native_bridge_enabled(), ENATIVE_BRIDGE_NOT_ENABLED);
-
- mint_internal(recipient, amount);
+public(friend) fun mint(_recipient: address, _amount: u64) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1458,7 +1338,7 @@ Mints a specified amount of AptosCoin to a recipient's address.
@param amount The amount of AptosCoin to mint.
-fun mint_internal(recipient: address, amount: u64)
+fun mint_internal(_recipient: address, _amount: u64)
@@ -1467,11 +1347,8 @@ Mints a specified amount of AptosCoin to a recipient's address.
Implementation
-fun mint_internal(recipient: address, amount: u64) acquires AptosCoinMintCapability {
- coin::deposit(recipient, coin::mint(
- amount,
- &borrow_global<AptosCoinMintCapability>(@aptos_framework).mint_cap
- ));
+fun mint_internal(_recipient: address, _amount: u64) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1491,7 +1368,7 @@ Burns a specified amount of AptosCoin from an address.
@abort If the burn capability is not available.
-public fun burn_from(aptos_framework: &signer, from: address, amount: u64)
+public fun burn_from(_aptos_framework: &signer, _from: address, _amount: u64)
@@ -1500,9 +1377,8 @@ Burns a specified amount of AptosCoin from an address.
Implementation
-public fun burn_from(aptos_framework: &signer, from: address, amount: u64) acquires AptosCoinBurnCapability {
- system_addresses::assert_aptos_framework(aptos_framework);
- burn_internal(from, amount);
+public fun burn_from(_aptos_framework: &signer, _from: address, _amount: u64) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1521,7 +1397,7 @@ Burns a specified amount of AptosCoin from an address.
@abort If the burn capability is not available.
-public(friend) fun burn(from: address, amount: u64)
+public(friend) fun burn(_from: address, _amount: u64)
@@ -1530,10 +1406,8 @@ Burns a specified amount of AptosCoin from an address.
Implementation
-public(friend) fun burn(from: address, amount: u64) acquires AptosCoinBurnCapability {
- assert!(features::abort_native_bridge_enabled(), ENATIVE_BRIDGE_NOT_ENABLED);
-
- burn_internal(from, amount);
+public(friend) fun burn(_from: address, _amount: u64) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1551,7 +1425,7 @@ Burns a specified amount of AptosCoin from an address.
@param amount The amount of AptosCoin to burn.
-fun burn_internal(from: address, amount: u64)
+fun burn_internal(_from: address, _amount: u64)
@@ -1560,12 +1434,8 @@ Burns a specified amount of AptosCoin from an address.
Implementation
-fun burn_internal(from: address, amount: u64) acquires AptosCoinBurnCapability {
- coin::burn_from(
- from,
- amount,
- &borrow_global<AptosCoinBurnCapability>(@aptos_framework).burn_cap,
- );
+fun burn_internal(_from: address, _amount: u64) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1585,7 +1455,7 @@ The amount is burnt from the initiator and the module-level nonce is incremented
@param amount The amount of assets to be locked.
-public entry fun initiate_bridge_transfer(initiator: &signer, recipient: vector<u8>, amount: u64)
+public entry fun initiate_bridge_transfer(_initiator: &signer, _recipient: vector<u8>, _amount: u64)
@@ -1595,55 +1465,11 @@ The amount is burnt from the initiator and the module-level nonce is incremented
public entry fun initiate_bridge_transfer(
- initiator: &signer,
- recipient: vector<u8>,
- amount: u64
-) acquires BridgeEvents, Nonce, AptosCoinBurnCapability, AptosCoinMintCapability, SmartTableWrapper, OutboundRateLimitBudget, BridgeConfig {
- let initiator_address = signer::address_of(initiator);
- let ethereum_address = ethereum::ethereum_address_20_bytes(recipient);
-
- // Ensure the amount is enough for the bridge fee and charge for it
- let new_amount = charge_bridge_fee(amount);
-
- assert_outbound_rate_limit_budget_not_exceeded(new_amount);
-
- // Increment and retrieve the nonce
- let nonce = increment_and_get_nonce();
-
- // Create bridge transfer details
- let details = create_details(
- initiator_address,
- ethereum_address,
- new_amount,
- nonce
- );
-
- let bridge_transfer_id = bridge_transfer_id(
- initiator_address,
- ethereum_address,
- new_amount,
- nonce
- );
-
- // Add the transfer details to storage
- add(nonce, details);
-
- // Burn the amount from the initiator
- burn_internal(initiator_address, amount);
-
- let bridge_events = borrow_global_mut<BridgeEvents>(@aptos_framework);
-
- // Emit an event with nonce
- event::emit_event(
- &mut bridge_events.bridge_transfer_initiated_events,
- BridgeTransferInitiatedEvent {
- bridge_transfer_id,
- initiator: initiator_address,
- recipient,
- amount: new_amount,
- nonce,
- }
- );
+ _initiator: &signer,
+ _recipient: vector<u8>,
+ _amount: u64
+) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1666,7 +1492,7 @@ Completes a bridge transfer on the destination chain.
@abort If the caller is not the bridge relayer or the transfer has already been processed.
-public entry fun complete_bridge_transfer(caller: &signer, bridge_transfer_id: vector<u8>, initiator: vector<u8>, recipient: address, amount: u64, nonce: u64)
+public entry fun complete_bridge_transfer(_caller: &signer, _bridge_transfer_id: vector<u8>, _initiator: vector<u8>, _recipient: address, _amount: u64, _nonce: u64)
@@ -1676,53 +1502,14 @@ Completes a bridge transfer on the destination chain.
public entry fun complete_bridge_transfer(
- caller: &signer,
- bridge_transfer_id: vector<u8>,
- initiator: vector<u8>,
- recipient: address,
- amount: u64,
- nonce: u64
-) acquires BridgeEvents, AptosCoinMintCapability, SmartTableWrapper, InboundRateLimitBudget, BridgeConfig {
- // Ensure the caller is the bridge relayer
- assert_is_caller_relayer(caller);
- assert_inbound_rate_limit_budget_not_exceeded(amount);
-
- // Check if the bridge transfer ID is already associated with an inbound nonce
- let inbound_nonce_exists = is_inbound_nonce_set(bridge_transfer_id);
- assert!(!inbound_nonce_exists, ETRANSFER_ALREADY_PROCESSED);
- assert!(nonce > 0, EINVALID_NONCE);
-
- // Validate the bridge_transfer_id by reconstructing the hash
- let recipient_bytes = bcs::to_bytes(&recipient);
- let amount_bytes = normalize_u64_to_32_bytes(&amount);
- let nonce_bytes = normalize_u64_to_32_bytes(&nonce);
-
- let combined_bytes = vector::empty<u8>();
- vector::append(&mut combined_bytes, initiator);
- vector::append(&mut combined_bytes, recipient_bytes);
- vector::append(&mut combined_bytes, amount_bytes);
- vector::append(&mut combined_bytes, nonce_bytes);
-
- assert!(keccak256(combined_bytes) == bridge_transfer_id, EINVALID_BRIDGE_TRANSFER_ID);
-
- // Record the transfer as completed by associating the bridge_transfer_id with the inbound nonce
- set_bridge_transfer_id_to_inbound_nonce(bridge_transfer_id, nonce);
-
- // Mint to the recipient
- mint_internal(recipient, amount);
-
- // Emit the event
- let bridge_events = borrow_global_mut<BridgeEvents>(@aptos_framework);
- event::emit_event(
- &mut bridge_events.bridge_transfer_completed_events,
- BridgeTransferCompletedEvent {
- bridge_transfer_id,
- initiator,
- recipient,
- amount,
- nonce,
- },
- );
+ _caller: &signer,
+ _bridge_transfer_id: vector<u8>,
+ _initiator: vector<u8>,
+ _recipient: address,
+ _amount: u64,
+ _nonce: u64
+) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1741,7 +1528,7 @@ Charge bridge fee to the initiate bridge transfer.
@return The new amount after deducting the bridge fee.
-fun charge_bridge_fee(amount: u64): u64
+fun charge_bridge_fee(_amount: u64): u64
@@ -1750,13 +1537,8 @@ Charge bridge fee to the initiate bridge transfer.
Implementation
-fun charge_bridge_fee(amount: u64) : u64 acquires AptosCoinMintCapability, BridgeConfig {
- let bridge_fee = bridge_fee();
- let bridge_relayer = bridge_relayer();
- assert!(amount > bridge_fee, EINVALID_AMOUNT);
- let new_amount = amount - bridge_fee;
- mint_internal(bridge_relayer, bridge_fee);
- new_amount
+fun charge_bridge_fee(_amount: u64): u64 {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1775,7 +1557,7 @@ Updates the bridge relayer, requiring governance validation.
@abort If the current relayer is the same as the new relayer.
-public fun update_bridge_relayer(aptos_framework: &signer, new_relayer: address)
+public fun update_bridge_relayer(_aptos_framework: &signer, _new_relayer: address)
@@ -1784,21 +1566,8 @@ Updates the bridge relayer, requiring governance validation.
Implementation
-public fun update_bridge_relayer(aptos_framework: &signer, new_relayer: address
-) acquires BridgeConfig {
- system_addresses::assert_aptos_framework(aptos_framework);
- let bridge_config = borrow_global_mut<BridgeConfig>(@aptos_framework);
- let old_relayer = bridge_config.bridge_relayer;
- assert!(old_relayer != new_relayer, EINVALID_BRIDGE_RELAYER);
-
- bridge_config.bridge_relayer = new_relayer;
-
- event::emit(
- BridgeConfigRelayerUpdated {
- old_relayer,
- new_relayer,
- },
- );
+public fun update_bridge_relayer(_aptos_framework: &signer, _new_relayer: address) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1817,7 +1586,7 @@ Updates the bridge fee, requiring relayer validation.
@abort If the new bridge fee is the same as the old bridge fee.
-public entry fun update_bridge_fee(relayer: &signer, new_bridge_fee: u64)
+public entry fun update_bridge_fee(_relayer: &signer, _new_bridge_fee: u64)
@@ -1826,20 +1595,8 @@ Updates the bridge fee, requiring relayer validation.
Implementation
-public entry fun update_bridge_fee(relayer: &signer, new_bridge_fee: u64
-) acquires BridgeConfig {
- assert_is_caller_relayer(relayer);
- let bridge_config = borrow_global_mut<BridgeConfig>(@aptos_framework);
- let old_bridge_fee = bridge_config.bridge_fee;
- assert!(old_bridge_fee != new_bridge_fee, ESAME_FEE);
- bridge_config.bridge_fee = new_bridge_fee;
-
- event::emit(
- BridgeFeeChangedEvent {
- old_bridge_fee,
- new_bridge_fee,
- },
- );
+public entry fun update_bridge_fee(_relayer: &signer, _new_bridge_fee: u64) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1858,7 +1615,7 @@ Updates the insurance fund, requiring governance validation.
@abort If the new insurance fund is the same as the old insurance fund.
-public entry fun update_insurance_fund(aptos_framework: &signer, new_insurance_fund: address)
+public entry fun update_insurance_fund(_aptos_framework: &signer, _new_insurance_fund: address)
@@ -1867,20 +1624,8 @@ Updates the insurance fund, requiring governance validation.
Implementation
-public entry fun update_insurance_fund(aptos_framework: &signer, new_insurance_fund: address
-) acquires BridgeConfig {
- system_addresses::assert_aptos_framework(aptos_framework);
- let bridge_config = borrow_global_mut<BridgeConfig>(@aptos_framework);
- let old_insurance_fund = bridge_config.insurance_fund;
- assert!(old_insurance_fund != new_insurance_fund, EINVALID_VALUE);
- bridge_config.insurance_fund = new_insurance_fund;
-
- event::emit(
- BridgeInsuranceFundChangedEvent {
- old_insurance_fund,
- new_insurance_fund,
- },
- );
+public entry fun update_insurance_fund(_aptos_framework: &signer, _new_insurance_fund: address) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1899,7 +1644,7 @@ Updates the insurance budget divider, requiring governance validation.
@abort If the new insurance budget divider is the same as the old insurance budget divider.
-public entry fun update_insurance_budget_divider(aptos_framework: &signer, new_insurance_budget_divider: u64)
+public entry fun update_insurance_budget_divider(_aptos_framework: &signer, _new_insurance_budget_divider: u64)
@@ -1908,25 +1653,8 @@ Updates the insurance budget divider, requiring governance validation.
Implementation
-public entry fun update_insurance_budget_divider(aptos_framework: &signer, new_insurance_budget_divider: u64
-) acquires BridgeConfig {
- system_addresses::assert_aptos_framework(aptos_framework);
- // Ensure the new insurance budget divider is greater than 1 and different from the old one
- // Assumes symmetric Insurance Funds on both L1 and L2
- assert!(new_insurance_budget_divider > 1, EINVALID_VALUE);
-
- let bridge_config = borrow_global_mut<BridgeConfig>(@aptos_framework);
- let old_insurance_budget_divider = bridge_config.insurance_budget_divider;
- assert!(old_insurance_budget_divider != new_insurance_budget_divider, EINVALID_VALUE);
-
- bridge_config.insurance_budget_divider = new_insurance_budget_divider;
-
- event::emit(
- BridgeInsuranceBudgetDividerChangedEvent {
- old_insurance_budget_divider,
- new_insurance_budget_divider,
- },
- );
+public entry fun update_insurance_budget_divider(_aptos_framework: &signer, _new_insurance_budget_divider: u64) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1944,7 +1672,7 @@ Asserts that the caller is the current bridge relayer.
@abort If the caller is not the current bridge relayer.
-public(friend) fun assert_is_caller_relayer(caller: &signer)
+public(friend) fun assert_is_caller_relayer(_caller: &signer)
@@ -1953,9 +1681,8 @@ Asserts that the caller is the current bridge relayer.
Implementation
-public(friend) fun assert_is_caller_relayer(caller: &signer
-) acquires BridgeConfig {
- assert!(borrow_global<BridgeConfig>(@aptos_framework).bridge_relayer == signer::address_of(caller), EINVALID_BRIDGE_RELAYER);
+public(friend) fun assert_is_caller_relayer(_caller: &signer) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -1972,7 +1699,7 @@ Asserts that the rate limit budget is not exceeded.
@param amount The amount to be transferred.
-fun assert_outbound_rate_limit_budget_not_exceeded(amount: u64)
+fun assert_outbound_rate_limit_budget_not_exceeded(_amount: u64)
@@ -1981,16 +1708,8 @@ Asserts that the rate limit budget is not exceeded.
Implementation
-fun assert_outbound_rate_limit_budget_not_exceeded(amount: u64) acquires OutboundRateLimitBudget, BridgeConfig {
- let insurance_fund = borrow_global<BridgeConfig>(@aptos_framework).insurance_fund;
- let insurance_budget_divider = borrow_global<BridgeConfig>(@aptos_framework).insurance_budget_divider;
- let table = borrow_global_mut<OutboundRateLimitBudget>(@aptos_framework);
-
- let day = timestamp::now_seconds() / 86400;
- let current_budget = smart_table::borrow_mut_with_default(&mut table.day, day, 0);
- smart_table::upsert(&mut table.day, day, *current_budget + amount);
- let rate_limit = coin::balance<AptosCoin>(insurance_fund) / insurance_budget_divider;
- assert!(*smart_table::borrow(&table.day, day) < rate_limit, ERATE_LIMIT_EXCEEDED);
+fun assert_outbound_rate_limit_budget_not_exceeded(_amount: u64) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -2007,7 +1726,7 @@ Asserts that the rate limit budget is not exceeded.
@param amount The amount to be transferred.
-fun assert_inbound_rate_limit_budget_not_exceeded(amount: u64)
+fun assert_inbound_rate_limit_budget_not_exceeded(_amount: u64)
@@ -2016,16 +1735,8 @@ Asserts that the rate limit budget is not exceeded.
Implementation
-fun assert_inbound_rate_limit_budget_not_exceeded(amount: u64) acquires InboundRateLimitBudget, BridgeConfig {
- let insurance_fund = borrow_global<BridgeConfig>(@aptos_framework).insurance_fund;
- let insurance_budget_divider = borrow_global<BridgeConfig>(@aptos_framework).insurance_budget_divider;
- let table = borrow_global_mut<InboundRateLimitBudget>(@aptos_framework);
-
- let day = timestamp::now_seconds() / 86400;
- let current_budget = smart_table::borrow_mut_with_default(&mut table.day, day, 0);
- smart_table::upsert(&mut table.day, day, *current_budget + amount);
- let rate_limit = coin::balance<AptosCoin>(insurance_fund) / insurance_budget_divider;
- assert!(*smart_table::borrow(&table.day, day) < rate_limit, ERATE_LIMIT_EXCEEDED);
+fun assert_inbound_rate_limit_budget_not_exceeded(_amount: u64) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
@@ -2040,7 +1751,7 @@ Asserts that the rate limit budget is not exceeded.
Test serialization of u64 to 32 bytes
-fun test_normalize_u64_to_32_bytes_helper(x: u64, expected: vector<u8>)
+fun test_normalize_u64_to_32_bytes_helper(_x: u64, _expected: vector<u8>)
@@ -2049,10 +1760,8 @@ Test serialization of u64 to 32 bytes
Implementation
-fun test_normalize_u64_to_32_bytes_helper(x: u64, expected: vector<u8>) {
- let r = normalize_u64_to_32_bytes(&x);
- assert!(vector::length(&r) == 32, 0);
- assert!(r == expected, 0);
+fun test_normalize_u64_to_32_bytes_helper(_x: u64, _expected: vector<u8>) {
+ abort ENATIVE_BRIDGE_NOT_ENABLED
}
diff --git a/aptos-move/framework/cached-packages/src/aptos_framework_sdk_builder.rs b/aptos-move/framework/cached-packages/src/aptos_framework_sdk_builder.rs
index 4fc3a0b4fa1c4..cdb47a1e73427 100644
--- a/aptos-move/framework/cached-packages/src/aptos_framework_sdk_builder.rs
+++ b/aptos-move/framework/cached-packages/src/aptos_framework_sdk_builder.rs
@@ -286,22 +286,22 @@ pub enum EntryFunctionCall {
/// @param bridge_transfer_id The unique identifier for the bridge transfer.
/// @abort If the caller is not the bridge operator or if the time lock has not expired.
AtomicBridgeCounterpartyAbortBridgeTransfer {
- bridge_transfer_id: Vec,
+ _bridge_transfer_id: Vec,
},
/// Bridge operator can complete the transfer
AtomicBridgeInitiatorCompleteBridgeTransfer {
- bridge_transfer_id: Vec,
- pre_image: Vec,
+ _bridge_transfer_id: Vec,
+ _pre_image: Vec,
},
/// Initiate a bridge transfer of ETH from Movement to the base layer
/// Anyone can initiate a bridge transfer from the source chain
/// The amount is burnt from the initiator
AtomicBridgeInitiatorInitiateBridgeTransfer {
- recipient: Vec,
- hash_lock: Vec,
- amount: u64,
+ _recipient: Vec,
+ _hash_lock: Vec,
+ _amount: u64,
},
/// Locks assets for a bridge transfer by the initiator.
@@ -315,16 +315,16 @@ pub enum EntryFunctionCall {
/// @param amount The amount of assets to be locked.
/// @abort If the caller is not the bridge operator.
AtomicBridgeCounterpartyLockBridgeTransferAssets {
- initiator: Vec