-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[native-bridge] - add coins dynamically (#16904)
## Description New APIs : `register_foreign_token<T>(self: &mut Bridge, tc: TreasuryCap<T>, uc: UpgradeCap, metadata: &CoinMetadata<T>)` for registering new foreign token type New system message: added new `AddSuiToken` message for validators to approve new tokens addition to the bridge Notable changes: added BridgeTokenMetadata to treasury which contains token information Removed `notional_values` from bridge limiter, token value is now stored in the treasury in the `BridgeTokenMetadata` Removed bridged token packages (BTC, ETH, USDT, and USDC) from framework Added bridged tokens packages to `bridge/move/tokens` Added new token registration to `TestCluster` changed all static reference of token id and names with id_token_map obtained from `BridgeSummary` ## Test Plan How did you test the new or updated feature? --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes --------- Co-authored-by: longbowlu <[email protected]> Co-authored-by: Dario Russi <[email protected]>
- Loading branch information
1 parent
e31b3e9
commit 7c690e9
Showing
46 changed files
with
2,034 additions
and
1,466 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "BridgedBTC" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
MoveStdlib = { local = "../../../../crates/sui-framework/packages/move-stdlib" } | ||
Sui = { local = "../../../../crates/sui-framework/packages/sui-framework" } | ||
|
||
[addresses] | ||
bridged_btc = "0x0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module bridged_btc::btc { | ||
use std::option; | ||
|
||
use sui::coin; | ||
use sui::transfer; | ||
use sui::tx_context; | ||
use sui::tx_context::TxContext; | ||
|
||
struct BTC has drop {} | ||
|
||
const DECIMAL: u8 = 8; | ||
|
||
fun init(otw: BTC, ctx: &mut TxContext) { | ||
let (treasury_cap, metadata) = coin::create_currency( | ||
otw, | ||
DECIMAL, | ||
b"BTC", | ||
b"Bitcoin", | ||
b"Bridged Bitcoin token", | ||
option::none(), | ||
ctx | ||
); | ||
transfer::public_freeze_object(metadata); | ||
transfer::public_transfer(treasury_cap, tx_context::sender(ctx)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "BridgedETH" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
MoveStdlib = { local = "../../../../crates/sui-framework/packages/move-stdlib" } | ||
Sui = { local = "../../../../crates/sui-framework/packages/sui-framework" } | ||
|
||
[addresses] | ||
bridged_eth = "0x0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module bridged_eth::eth { | ||
use std::option; | ||
|
||
use sui::coin; | ||
use sui::transfer; | ||
use sui::tx_context; | ||
use sui::tx_context::TxContext; | ||
|
||
struct ETH has drop {} | ||
|
||
const DECIMAL: u8 = 8; | ||
|
||
fun init(otw: ETH, ctx: &mut TxContext) { | ||
let (treasury_cap, metadata) = coin::create_currency( | ||
otw, | ||
DECIMAL, | ||
b"ETH", | ||
b"Ethereum", | ||
b"Bridged Ethereum token", | ||
option::none(), | ||
ctx | ||
); | ||
transfer::public_freeze_object(metadata); | ||
transfer::public_transfer(treasury_cap, tx_context::sender(ctx)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "BridgedUSDC" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
MoveStdlib = { local = "../../../../crates/sui-framework/packages/move-stdlib" } | ||
Sui = { local = "../../../../crates/sui-framework/packages/sui-framework" } | ||
|
||
[addresses] | ||
bridged_usdc = "0x0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module bridged_usdc::usdc { | ||
use std::option; | ||
|
||
use sui::coin; | ||
use sui::transfer; | ||
use sui::tx_context; | ||
use sui::tx_context::TxContext; | ||
|
||
struct USDC has drop {} | ||
|
||
const DECIMAL: u8 = 6; | ||
|
||
fun init(otw: USDC, ctx: &mut TxContext) { | ||
let (treasury_cap, metadata) = coin::create_currency( | ||
otw, | ||
DECIMAL, | ||
b"USDC", | ||
b"USD Coin", | ||
b"Bridged USD Coin token", | ||
option::none(), | ||
ctx | ||
); | ||
transfer::public_freeze_object(metadata); | ||
transfer::public_transfer(treasury_cap, tx_context::sender(ctx)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "BridgedUSDT" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
MoveStdlib = { local = "../../../../crates/sui-framework/packages/move-stdlib" } | ||
Sui = { local = "../../../../crates/sui-framework/packages/sui-framework" } | ||
|
||
[addresses] | ||
bridged_usdt = "0x0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module bridged_usdt::usdt { | ||
use std::option; | ||
|
||
use sui::coin; | ||
use sui::transfer; | ||
use sui::tx_context; | ||
use sui::tx_context::TxContext; | ||
|
||
struct USDT has drop {} | ||
|
||
const DECIMAL: u8 = 6; | ||
|
||
fun init(otw: USDT, ctx: &mut TxContext) { | ||
let (treasury_cap, metadata) = coin::create_currency( | ||
otw, | ||
DECIMAL, | ||
b"USDT", | ||
b"Tether", | ||
b"Bridged Tether token", | ||
option::none(), | ||
ctx | ||
); | ||
transfer::public_freeze_object(metadata); | ||
transfer::public_transfer(treasury_cap, tx_context::sender(ctx)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.