diff --git a/Cargo.lock b/Cargo.lock index 9c07a61c74d44..f83ae6e4a098d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -131,6 +131,21 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + [[package]] name = "allocative" version = "0.3.3" @@ -3704,7 +3719,7 @@ dependencies = [ "aptos-types", "flate2", "futures", - "httpmock", + "httpmock 0.6.8", "once_cell", "prometheus", "rand 0.7.3", @@ -3742,7 +3757,7 @@ dependencies = [ "flate2", "futures", "gcp-bigquery-client", - "httpmock", + "httpmock 0.6.8", "jsonwebtoken", "once_cell", "prometheus", @@ -4553,6 +4568,16 @@ dependencies = [ "ansi_term", ] +[[package]] +name = "async-attributes" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" +dependencies = [ + "quote", + "syn 1.0.109", +] + [[package]] name = "async-channel" version = "1.9.0" @@ -4577,6 +4602,19 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "async-compression" +version = "0.4.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a89bce6054c720275ac2432fbba080a66a2106a44a1b804553930ca6909f4e0" +dependencies = [ + "compression-codecs", + "compression-core", + "futures-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "async-executor" version = "1.8.0" @@ -4735,6 +4773,7 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" dependencies = [ + "async-attributes", "async-channel 1.9.0", "async-global-executor", "async-io 1.13.0", @@ -5365,6 +5404,27 @@ dependencies = [ "serde_with", ] +[[package]] +name = "brotli" +version = "8.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bd8b9603c7aa97359dbd97ecf258968c95f3adddd6db2f7e7a5bef101c84560" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + [[package]] name = "bstr" version = "0.2.17" @@ -5918,6 +5978,24 @@ dependencies = [ "tokio-util 0.7.10", ] +[[package]] +name = "compression-codecs" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef8a506ec4b81c460798f572caead636d57d3d7e940f998160f52bd254bf2d23" +dependencies = [ + "brotli", + "compression-core", + "flate2", + "memchr", +] + +[[package]] +name = "compression-core" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e47641d3deaf41fb1538ac1f54735925e275eaf3bf4d55c81b137fba797e5cbb" + [[package]] name = "concurrent-queue" version = "2.4.0" @@ -7654,7 +7732,7 @@ checksum = "e29e5681dc8556fb9df1409e95eae050e12e8776394313da3546dcb8cf390c73" dependencies = [ "az", "bytemuck", - "half 1.8.2", + "half 2.2.1", "typenum", ] @@ -8063,6 +8141,25 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "ggp-balance-alert-bot" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "chrono", + "httpmock 0.7.0", + "hyper", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "tracing-subscriber 0.3.18", + "url", +] + [[package]] name = "ghash" version = "0.5.0" @@ -8688,6 +8785,34 @@ dependencies = [ "url", ] +[[package]] +name = "httpmock" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08ec9586ee0910472dec1a1f0f8acf52f0fdde93aea74d70d4a3107b4be0fd5b" +dependencies = [ + "assert-json-diff", + "async-object-pool", + "async-std", + "async-trait", + "base64 0.21.6", + "basic-cookies", + "crossbeam-utils", + "form_urlencoded", + "futures-util", + "hyper", + "lazy_static", + "levenshtein", + "log", + "regex", + "serde", + "serde_json", + "serde_regex", + "similar", + "tokio", + "url", +] + [[package]] name = "humansize" version = "2.1.3" @@ -8720,7 +8845,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.5", "tokio", "tower-service", "tracing", @@ -10181,7 +10306,7 @@ dependencies = [ "codespan-reporting", "colored", "datatest-stable", - "httpmock", + "httpmock 0.6.8", "move-binary-format", "move-bytecode-viewer", "move-command-line-common", @@ -13247,6 +13372,7 @@ version = "0.11.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" dependencies = [ + "async-compression", "base64 0.21.6", "bytes", "cookie 0.16.2", @@ -16144,7 +16270,7 @@ dependencies = [ "errno", "js-sys", "libc", - "rustix 0.37.27", + "rustix 0.38.28", "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", "winapi 0.3.9", diff --git a/Cargo.toml b/Cargo.toml index 8c0c58c45c078..932fe992c8dcc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,7 @@ members = [ "consensus/consensus-types", "consensus/safety-rules", "crates/aptos", + "crates/ggp-balance-alert-bot", "crates/aptos-admin-service", "crates/aptos-api-tester", "crates/aptos-bcs-utils", 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 EventHandles 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 EventHandles 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/delegation_pool.md b/aptos-move/framework/aptos-framework/doc/delegation_pool.md
index 9ce29ab22430e..28df0d408e9c0 100644
--- a/aptos-move/framework/aptos-framework/doc/delegation_pool.md
+++ b/aptos-move/framework/aptos-framework/doc/delegation_pool.md
@@ -1639,6 +1639,15 @@ The function is disabled or hasn't been enabled.
+
+
+
+
+const MODULE_SALT: vector<u8> = [97, 112, 116, 111, 115, 95, 102, 114, 97, 109, 101, 119, 111, 114, 107, 58, 58, 100, 101, 108, 101, 103, 97, 116, 105, 111, 110, 95, 112, 111, 111, 108];
+
+
+
+
The account is not the operator of the stake pool.
@@ -1937,15 +1946,6 @@ This constraint is not enforced on inactive pools as they only allow redeems
-
-
-
-
-const MODULE_SALT: vector<u8> = [97, 112, 116, 111, 115, 95, 102, 114, 97, 109, 101, 119, 111, 114, 107, 58, 58, 100, 101, 108, 101, 103, 97, 116, 105, 111, 110, 95, 112, 111, 111, 108];
-
-
-
-
Special shareholder temporarily owning the add_stake fees charged during this epoch.
diff --git a/aptos-move/framework/aptos-framework/doc/governed_gas_pool.md b/aptos-move/framework/aptos-framework/doc/governed_gas_pool.md
index 1420628935966..f306a613584c6 100644
--- a/aptos-move/framework/aptos-framework/doc/governed_gas_pool.md
+++ b/aptos-move/framework/aptos-framework/doc/governed_gas_pool.md
@@ -5,21 +5,28 @@
+- [Struct `WithdrawStakingRewardEvent`](#0x1_governed_gas_pool_WithdrawStakingRewardEvent)
- [Resource `GovernedGasPool`](#0x1_governed_gas_pool_GovernedGasPool)
+- [Resource `GovernedGasPoolExtension`](#0x1_governed_gas_pool_GovernedGasPoolExtension)
- [Constants](#@Constants_0)
- [Function `primary_fungible_store_address`](#0x1_governed_gas_pool_primary_fungible_store_address)
- [Function `create_resource_account_seed`](#0x1_governed_gas_pool_create_resource_account_seed)
- [Function `initialize`](#0x1_governed_gas_pool_initialize)
+- [Function `initialize_governed_gas_pool_extension`](#0x1_governed_gas_pool_initialize_governed_gas_pool_extension)
- [Function `init_module`](#0x1_governed_gas_pool_init_module)
- [Function `governed_gas_signer`](#0x1_governed_gas_pool_governed_gas_signer)
- [Function `governed_gas_pool_address`](#0x1_governed_gas_pool_governed_gas_pool_address)
+- [Function `get_treasury_deposited`](#0x1_governed_gas_pool_get_treasury_deposited)
- [Function `fund`](#0x1_governed_gas_pool_fund)
- [Function `deposit`](#0x1_governed_gas_pool_deposit)
- [Function `deposit_from`](#0x1_governed_gas_pool_deposit_from)
- [Function `deposit_from_fungible_store`](#0x1_governed_gas_pool_deposit_from_fungible_store)
- [Function `deposit_gas_fee`](#0x1_governed_gas_pool_deposit_gas_fee)
- [Function `deposit_gas_fee_v2`](#0x1_governed_gas_pool_deposit_gas_fee_v2)
+- [Function `deposit_treasury`](#0x1_governed_gas_pool_deposit_treasury)
- [Function `get_balance`](#0x1_governed_gas_pool_get_balance)
+- [Function `withdraw_staking_reward`](#0x1_governed_gas_pool_withdraw_staking_reward)
+- [Function `register_coin`](#0x1_governed_gas_pool_register_coin)
- [Specification](#@Specification_1)
- [Function `initialize`](#@Specification_1_initialize)
- [Function `fund`](#@Specification_1_fund)
@@ -31,6 +38,7 @@
use 0x1::aptos_account;
use 0x1::aptos_coin;
use 0x1::coin;
+use 0x1::event;
use 0x1::features;
use 0x1::fungible_asset;
use 0x1::object;
@@ -41,6 +49,34 @@
+
+
+## Struct `WithdrawStakingRewardEvent`
+
+Event emitted when token are withdraw from the pool
+
+
+struct WithdrawStakingRewardEvent has drop, store
+
+
+
+
+
+Fields
+
+
+
+-
+
amount: u64
+
+-
+
+
+
+
+
+
+
## Resource `GovernedGasPool`
@@ -68,6 +104,40 @@ Internally, this is a simply wrapper around a resource account.
+
+
+
+
+## Resource `GovernedGasPoolExtension`
+
+Contains added variable needed for the GovernedGasPool staking reward update.
+
+
+struct GovernedGasPoolExtension has key
+
+
+
+
+
+Fields
+
+
+
+-
+
deposited_treasury_counter: u64
+
+-
+
+
+-
+
withdraw_staking_reward_events: event::EventHandle<governed_gas_pool::WithdrawStakingRewardEvent>
+
+-
+
+
+
+
+
@@ -181,6 +251,49 @@ Initializes the governed gas pool around a resource account creation seed.
move_to(aptos_framework, GovernedGasPool{
signer_capability: governed_gas_pool_signer_cap,
});
+
+ move_to(aptos_framework, GovernedGasPoolExtension{
+ deposited_treasury_counter: 0,
+ withdraw_staking_reward_events: account::new_event_handle<WithdrawStakingRewardEvent>(aptos_framework),
+ });
+}
+
+
+
+
+
+
+
+
+## Function `initialize_governed_gas_pool_extension`
+
+Initializes the governed gas pool extension alone.
+@param aptos_framework The signer of the aptos_framework module.
+
+
+public entry fun initialize_governed_gas_pool_extension(aptos_framework: &signer)
+
+
+
+
+
+Implementation
+
+
+public entry fun initialize_governed_gas_pool_extension(
+ aptos_framework: &signer,
+) {
+ system_addresses::assert_aptos_framework(aptos_framework);
+
+ // return if the governed gas extension has already been initialized
+ if (exists<GovernedGasPoolExtension>(signer::address_of(aptos_framework))) {
+ return
+ };
+
+ move_to(aptos_framework, GovernedGasPoolExtension{
+ deposited_treasury_counter: 0,
+ withdraw_staking_reward_events: account::new_event_handle<WithdrawStakingRewardEvent>(aptos_framework),
+ });
}
@@ -268,6 +381,32 @@ Gets the address of the governed gas pool.
+
+
+
+
+## Function `get_treasury_deposited`
+
+Return the amount of treasury deposited.
+
+
+#[view]
+public fun get_treasury_deposited(): u64
+
+
+
+
+
+Implementation
+
+
+public fun get_treasury_deposited(): u64 acquires GovernedGasPoolExtension {
+ borrow_global<GovernedGasPoolExtension>(@aptos_framework).deposited_treasury_counter
+}
+
+
+
+
@@ -445,7 +584,7 @@ Deposits gas fees into the governed gas pool.
public(friend) fun deposit_gas_fee_v2(gas_payer: address, gas_fee: u64) acquires GovernedGasPool {
- if (features::operations_default_to_fa_apt_store_enabled()) {
+ if (features::operations_default_to_fa_apt_store_enabled()) {
deposit_from_fungible_store(gas_payer, gas_fee);
} else {
deposit_from<AptosCoin>(gas_payer, gas_fee);
@@ -455,6 +594,37 @@ Deposits gas fees into the governed gas pool.
+
+
+
+
+## Function `deposit_treasury`
+
+Deposits from the treasury account. Treasury deposit are recorded.
+@param treasury_account The address of the account that paid the treasury.
+@param amount The amount of treasury to be deposited.
+
+
+public entry fun deposit_treasury(treasury_account: &signer, amount: u64)
+
+
+
+
+
+Implementation
+
+
+public entry fun deposit_treasury(treasury_account: &signer, amount: u64) acquires GovernedGasPool, GovernedGasPoolExtension {
+ let treasury_account_address = signer::address_of(treasury_account);
+ deposit_from<AptosCoin>(treasury_account_address, amount);
+
+ let ggp = borrow_global_mut<GovernedGasPoolExtension>(@aptos_framework);
+ ggp.deposited_treasury_counter = ggp.deposited_treasury_counter + amount;
+}
+
+
+
+
@@ -483,6 +653,78 @@ Gets the balance of a specified coin type in the governed gas pool.
+
+
+
+
+## Function `withdraw_staking_reward`
+
+Withdraws coins from the governed gas pool.
+
+This function allows friend modules to withdraw a specified amount of a given
+CoinType from the governed gas pool. It uses the internal signer of the
+governed gas pool to authorize the withdrawal.
+
+@param amount The amount of coins to withdraw from the pool.
+@return A Coin<CoinType> resource containing the withdrawn amount.
+
+
+public(friend) fun withdraw_staking_reward<CoinType>(amount: u64): coin::Coin<CoinType>
+
+
+
+
+
+Implementation
+
+
+public(friend) fun withdraw_staking_reward<CoinType>(
+ amount: u64
+): Coin<CoinType> acquires GovernedGasPool, GovernedGasPoolExtension {
+ let balance = get_balance<CoinType>();
+ assert!(balance >= amount, 0); // insufficient balance
+ let ggpv2 = borrow_global_mut<GovernedGasPoolExtension>(@aptos_framework);
+
+ event::emit_event(
+ &mut ggpv2.withdraw_staking_reward_events,
+ WithdrawStakingRewardEvent {
+ amount,
+ },
+ );
+
+ // Withdraw reward coin.
+ coin::withdraw<CoinType>(&governed_gas_signer(), amount)
+}
+
+
+
+
+
+
+
+
+## Function `register_coin`
+
+Register Aptos coin with Governed gas signer.
+
+
+public(friend) fun register_coin<CoinType>()
+
+
+
+
+
+Implementation
+
+
+public(friend) fun register_coin<CoinType>() acquires GovernedGasPool {
+ let s = governed_gas_signer();
+ coin::register<CoinType>(&s);
+}
+
+
+
+
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 EventHandles 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 EventHandles 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/aptos-framework/doc/object.md b/aptos-move/framework/aptos-framework/doc/object.md
index ef2998c62b846..f9483be738737 100644
--- a/aptos-move/framework/aptos-framework/doc/object.md
+++ b/aptos-move/framework/aptos-framework/doc/object.md
@@ -624,7 +624,7 @@ Exceeds maximum nesting for an object transfer.
-
+
The caller does not have ownership permissions
@@ -2227,7 +2227,8 @@ Return true if ungated transfer is allowed.
Return the current owner.
-public fun owner<T: key>(object: object::Object<T>): address
+#[view]
+public fun owner<T: key>(object: object::Object<T>): address
@@ -2256,7 +2257,8 @@ Return the current owner.
Return true if the provided address is the current owner.
-public fun is_owner<T: key>(object: object::Object<T>, owner: address): bool
+#[view]
+public fun is_owner<T: key>(object: object::Object<T>, owner: address): bool
@@ -2281,7 +2283,8 @@ Return true if the provided address is the current owner.
Return true if the provided address has indirect or direct ownership of the provided object.
-public fun owns<T: key>(object: object::Object<T>, owner: address): bool
+#[view]
+public fun owns<T: key>(object: object::Object<T>, owner: address): bool
@@ -2331,7 +2334,8 @@ Returns the root owner of an object. As objects support nested ownership, it can
to determine the identity of the starting point of ownership.
-public fun root_owner<T: key>(object: object::Object<T>): address
+#[view]
+public fun root_owner<T: key>(object: object::Object<T>): address
@@ -3303,7 +3307,8 @@ to determine the identity of the starting point of ownership.
### Function `owner`
-public fun owner<T: key>(object: object::Object<T>): address
+#[view]
+public fun owner<T: key>(object: object::Object<T>): address
@@ -3320,7 +3325,8 @@ to determine the identity of the starting point of ownership.
### Function `is_owner`
-public fun is_owner<T: key>(object: object::Object<T>, owner: address): bool
+#[view]
+public fun is_owner<T: key>(object: object::Object<T>, owner: address): bool
@@ -3337,7 +3343,8 @@ to determine the identity of the starting point of ownership.
### Function `owns`
-public fun owns<T: key>(object: object::Object<T>, owner: address): bool
+#[view]
+public fun owns<T: key>(object: object::Object<T>, owner: address): bool
@@ -3358,7 +3365,8 @@ to determine the identity of the starting point of ownership.
### Function `root_owner`
-public fun root_owner<T: key>(object: object::Object<T>): address
+#[view]
+public fun root_owner<T: key>(object: object::Object<T>): address
diff --git a/aptos-move/framework/aptos-framework/doc/stake.md b/aptos-move/framework/aptos-framework/doc/stake.md
index 5a199ef91f69d..e07e80ebef505 100644
--- a/aptos-move/framework/aptos-framework/doc/stake.md
+++ b/aptos-move/framework/aptos-framework/doc/stake.md
@@ -177,6 +177,7 @@ or if their stake drops below the min required, they would get removed at the en
use 0x1::event;
use 0x1::features;
use 0x1::fixed_point64;
+use 0x1::governed_gas_pool;
use 0x1::math64;
use 0x1::option;
use 0x1::reconfiguration_state;
@@ -3664,8 +3665,7 @@ power.
Implementation
-public(friend) fun on_new_epoch(
-) acquires StakePool, AptosCoinCapabilities, ValidatorConfig, ValidatorPerformance, ValidatorSet, ValidatorFees {
+public(friend) fun on_new_epoch() acquires StakePool, AptosCoinCapabilities, ValidatorConfig, ValidatorPerformance, ValidatorSet, ValidatorFees {
let validator_set = borrow_global_mut<ValidatorSet>(@aptos_framework);
let config = staking_config::get();
let validator_perf = borrow_global_mut<ValidatorPerformance>(@aptos_framework);
@@ -4225,7 +4225,7 @@ Calculate the rewards amount.
## Function `distribute_rewards`
-Mint rewards corresponding to current epoch's stake and num_successful_votes.
+Get rewards from the Governed Gas Pool corresponding to current epoch's stake and num_successful_votes.
fun distribute_rewards(stake: &mut coin::Coin<aptos_coin::AptosCoin>, num_successful_proposals: u64, num_total_proposals: u64, rewards_rate: u64, rewards_rate_denominator: u64): u64
@@ -4257,8 +4257,12 @@ Mint rewards corresponding to current epoch's if (rewards_amount > 0) {
- let mint_cap = &borrow_global<AptosCoinCapabilities>(@aptos_framework).mint_cap;
- let rewards = coin::mint(rewards_amount, mint_cap);
+ let rewards = if (features::stake_reward_using_treasury_enabled()) {
+ governed_gas_pool::withdraw_staking_reward<AptosCoin>(rewards_amount)
+ } else {
+ let mint_cap = &borrow_global<AptosCoinCapabilities>(@aptos_framework).mint_cap;
+ coin::mint(rewards_amount, mint_cap)
+ };
coin::merge(stake, rewards);
};
rewards_amount
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..e361f6682921a 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,
- bridge_transfer_id: Vec,
- hash_lock: Vec,
- recipient: AccountAddress,
- amount: u64,
+ _initiator: Vec,
+ _bridge_transfer_id: Vec,
+ _hash_lock: Vec,
+ _recipient: AccountAddress,
+ _amount: u64,
},
/// Anyone can refund the transfer on the source chain once time lock has passed
AtomicBridgeInitiatorRefundBridgeTransfer {
- bridge_transfer_id: Vec,
+ _bridge_transfer_id: Vec,
},
/// Same as `publish_package` but as an entry function which can be called as a transaction. Because
@@ -479,6 +479,17 @@ pub enum EntryFunctionCall {
amount: u64,
},
+ /// Deposits from the treasury account. Treasury deposit are recorded.
+ /// @param treasury_account The address of the account that paid the treasury.
+ /// @param amount The amount of treasury to be deposited.
+ GovernedGasPoolDepositTreasury {
+ amount: u64,
+ },
+
+ /// Initializes the governed gas pool extension alone.
+ /// @param aptos_framework The signer of the aptos_framework module.
+ GovernedGasPoolInitializeGovernedGasPoolExtension {},
+
/// Withdraw an `amount` of coin `CoinType` from `account` and burn it.
ManagedCoinBurn {
coin_type: TypeTag,
@@ -724,11 +735,11 @@ pub enum EntryFunctionCall {
/// @param nonce The unique nonce for the transfer.
/// @abort If the caller is not the bridge relayer or the transfer has already been processed.
NativeBridgeCompleteBridgeTransfer {
- bridge_transfer_id: Vec,
- initiator: Vec,
- recipient: AccountAddress,
- amount: u64,
- nonce: u64,
+ _bridge_transfer_id: Vec,
+ _initiator: Vec,
+ _recipient: AccountAddress,
+ _amount: u64,
+ _nonce: u64,
},
/// Initiate a bridge transfer of MOVE from Movement to Ethereum
@@ -738,8 +749,8 @@ pub enum EntryFunctionCall {
/// @param recipient The address of the recipient on the Aptos blockchain.
/// @param amount The amount of assets to be locked.
NativeBridgeInitiateBridgeTransfer {
- recipient: Vec,
- amount: u64,
+ _recipient: Vec,
+ _amount: u64,
},
/// Updates the bridge fee, requiring relayer validation.
@@ -748,7 +759,7 @@ pub enum EntryFunctionCall {
/// @param new_bridge_fee The new bridge fee to be set.
/// @abort If the new bridge fee is the same as the old bridge fee.
NativeBridgeUpdateBridgeFee {
- new_bridge_fee: u64,
+ _new_bridge_fee: u64,
},
/// Updates the insurance budget divider, requiring governance validation.
@@ -757,7 +768,7 @@ pub enum EntryFunctionCall {
/// @param new_insurance_budget_divider The new insurance budget divider to be set.
/// @abort If the new insurance budget divider is the same as the old insurance budget divider.
NativeBridgeUpdateInsuranceBudgetDivider {
- new_insurance_budget_divider: u64,
+ _new_insurance_budget_divider: u64,
},
/// Updates the insurance fund, requiring governance validation.
@@ -766,7 +777,7 @@ pub enum EntryFunctionCall {
/// @param new_insurance_fund The new insurance fund to be set.
/// @abort If the new insurance fund is the same as the old insurance fund.
NativeBridgeUpdateInsuranceFund {
- new_insurance_fund: AccountAddress,
+ _new_insurance_fund: AccountAddress,
},
/// Entry function that can be used to transfer, if allow_ungated_transfer is set true.
@@ -1268,34 +1279,34 @@ impl EntryFunctionCall {
proposal_id,
should_pass,
} => aptos_governance_vote(stake_pool, proposal_id, should_pass),
- AtomicBridgeCounterpartyAbortBridgeTransfer { bridge_transfer_id } => {
- atomic_bridge_counterparty_abort_bridge_transfer(bridge_transfer_id)
- },
+ AtomicBridgeCounterpartyAbortBridgeTransfer {
+ _bridge_transfer_id,
+ } => atomic_bridge_counterparty_abort_bridge_transfer(_bridge_transfer_id),
AtomicBridgeInitiatorCompleteBridgeTransfer {
- bridge_transfer_id,
- pre_image,
- } => atomic_bridge_initiator_complete_bridge_transfer(bridge_transfer_id, pre_image),
+ _bridge_transfer_id,
+ _pre_image,
+ } => atomic_bridge_initiator_complete_bridge_transfer(_bridge_transfer_id, _pre_image),
AtomicBridgeInitiatorInitiateBridgeTransfer {
- recipient,
- hash_lock,
- amount,
- } => atomic_bridge_initiator_initiate_bridge_transfer(recipient, hash_lock, amount),
+ _recipient,
+ _hash_lock,
+ _amount,
+ } => atomic_bridge_initiator_initiate_bridge_transfer(_recipient, _hash_lock, _amount),
AtomicBridgeCounterpartyLockBridgeTransferAssets {
- initiator,
- bridge_transfer_id,
- hash_lock,
- recipient,
- amount,
+ _initiator,
+ _bridge_transfer_id,
+ _hash_lock,
+ _recipient,
+ _amount,
} => atomic_bridge_counterparty_lock_bridge_transfer_assets(
- initiator,
- bridge_transfer_id,
- hash_lock,
- recipient,
- amount,
+ _initiator,
+ _bridge_transfer_id,
+ _hash_lock,
+ _recipient,
+ _amount,
),
- AtomicBridgeInitiatorRefundBridgeTransfer { bridge_transfer_id } => {
- atomic_bridge_initiator_refund_bridge_transfer(bridge_transfer_id)
- },
+ AtomicBridgeInitiatorRefundBridgeTransfer {
+ _bridge_transfer_id,
+ } => atomic_bridge_initiator_refund_bridge_transfer(_bridge_transfer_id),
CodePublishPackageTxn {
metadata_serialized,
code,
@@ -1388,6 +1399,10 @@ impl EntryFunctionCall {
pool_address,
amount,
} => delegation_pool_withdraw(pool_address, amount),
+ GovernedGasPoolDepositTreasury { amount } => governed_gas_pool_deposit_treasury(amount),
+ GovernedGasPoolInitializeGovernedGasPoolExtension {} => {
+ governed_gas_pool_initialize_governed_gas_pool_extension()
+ },
ManagedCoinBurn { coin_type, amount } => managed_coin_burn(coin_type, amount),
ManagedCoinInitialize {
coin_type,
@@ -1553,30 +1568,31 @@ impl EntryFunctionCall {
approved,
} => multisig_account_vote_transanction(multisig_account, sequence_number, approved),
NativeBridgeCompleteBridgeTransfer {
- bridge_transfer_id,
- initiator,
- recipient,
- amount,
- nonce,
+ _bridge_transfer_id,
+ _initiator,
+ _recipient,
+ _amount,
+ _nonce,
} => native_bridge_complete_bridge_transfer(
- bridge_transfer_id,
- initiator,
- recipient,
- amount,
- nonce,
+ _bridge_transfer_id,
+ _initiator,
+ _recipient,
+ _amount,
+ _nonce,
),
- NativeBridgeInitiateBridgeTransfer { recipient, amount } => {
- native_bridge_initiate_bridge_transfer(recipient, amount)
- },
- NativeBridgeUpdateBridgeFee { new_bridge_fee } => {
- native_bridge_update_bridge_fee(new_bridge_fee)
+ NativeBridgeInitiateBridgeTransfer {
+ _recipient,
+ _amount,
+ } => native_bridge_initiate_bridge_transfer(_recipient, _amount),
+ NativeBridgeUpdateBridgeFee { _new_bridge_fee } => {
+ native_bridge_update_bridge_fee(_new_bridge_fee)
},
NativeBridgeUpdateInsuranceBudgetDivider {
- new_insurance_budget_divider,
- } => native_bridge_update_insurance_budget_divider(new_insurance_budget_divider),
- NativeBridgeUpdateInsuranceFund { new_insurance_fund } => {
- native_bridge_update_insurance_fund(new_insurance_fund)
- },
+ _new_insurance_budget_divider,
+ } => native_bridge_update_insurance_budget_divider(_new_insurance_budget_divider),
+ NativeBridgeUpdateInsuranceFund {
+ _new_insurance_fund,
+ } => native_bridge_update_insurance_fund(_new_insurance_fund),
ObjectTransferCall { object, to } => object_transfer_call(object, to),
ObjectCodeDeploymentPublish {
metadata_serialized,
@@ -2461,7 +2477,7 @@ pub fn aptos_governance_vote(
/// @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.
pub fn atomic_bridge_counterparty_abort_bridge_transfer(
- bridge_transfer_id: Vec,
+ _bridge_transfer_id: Vec,
) -> TransactionPayload {
TransactionPayload::EntryFunction(EntryFunction::new(
ModuleId::new(
@@ -2473,14 +2489,14 @@ pub fn atomic_bridge_counterparty_abort_bridge_transfer(
),
ident_str!("abort_bridge_transfer").to_owned(),
vec![],
- vec![bcs::to_bytes(&bridge_transfer_id).unwrap()],
+ vec![bcs::to_bytes(&_bridge_transfer_id).unwrap()],
))
}
/// Bridge operator can complete the transfer
pub fn atomic_bridge_initiator_complete_bridge_transfer(
- bridge_transfer_id: Vec,
- pre_image: Vec,
+ _bridge_transfer_id: Vec,
+ _pre_image: Vec,
) -> TransactionPayload {
TransactionPayload::EntryFunction(EntryFunction::new(
ModuleId::new(
@@ -2493,8 +2509,8 @@ pub fn atomic_bridge_initiator_complete_bridge_transfer(
ident_str!("complete_bridge_transfer").to_owned(),
vec![],
vec![
- bcs::to_bytes(&bridge_transfer_id).unwrap(),
- bcs::to_bytes(&pre_image).unwrap(),
+ bcs::to_bytes(&_bridge_transfer_id).unwrap(),
+ bcs::to_bytes(&_pre_image).unwrap(),
],
))
}
@@ -2503,9 +2519,9 @@ pub fn atomic_bridge_initiator_complete_bridge_transfer(
/// Anyone can initiate a bridge transfer from the source chain
/// The amount is burnt from the initiator
pub fn atomic_bridge_initiator_initiate_bridge_transfer(
- recipient: Vec,
- hash_lock: Vec