Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add register_coin_with_cap function #251

Merged
merged 5 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hungry-days-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@axelar-network/axelar-cgp-sui': patch
---

Support mint/burn token register mode in Example module
22 changes: 21 additions & 1 deletion move/example/sources/its/its.move
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module example::its {
};
use relayer_discovery::{discovery::RelayerDiscovery, transaction::{Self, Transaction}};
use std::{ascii::{Self, String}, type_name};
use sui::{address, clock::Clock, coin::{CoinMetadata, Coin}, event, hex, sui::SUI};
use sui::{address, clock::Clock, coin::{CoinMetadata, Coin, TreasuryCap}, event, hex, sui::SUI};

// -------
// Structs
Expand Down Expand Up @@ -136,6 +136,26 @@ module example::its {
)
}

/// Registers a coin with the Interchain Token Service (ITS), using the provided `TreasuryCap` to manage the coin.
/// The `TreasuryCap` gives the ITS control over minting and burning of this coin.
public fun register_coin_with_cap<TOKEN>(
its: &mut InterchainTokenService,
coin_metadata: &CoinMetadata<TOKEN>,
treasury_cap: TreasuryCap<TOKEN>,
): TokenId {
let coin_info = coin_info::from_info<TOKEN>(
coin_metadata.get_name(),
coin_metadata.get_symbol(),
coin_metadata.get_decimals(),
);
let coin_management = coin_management::new_with_cap(treasury_cap);

its.register_coin(
coin_info,
coin_management,
)
}

public fun deploy_remote_interchain_token<TOKEN>(
its: &mut InterchainTokenService,
gateway: &mut Gateway,
Expand Down
10 changes: 10 additions & 0 deletions test/testdata/interface_example_its.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@
"coin_metadata#0#0": "&CoinMetadata<TOKEN>"
},
"returnType": "TokenId"
},
"register_coin_with_cap<TOKEN>": {
"name": "register_coin_with_cap<TOKEN>",
"visibility": "public",
"params": {
"its#0#0": "&mut InterchainTokenService",
"coin_metadata#0#0": "&CoinMetadata<TOKEN>",
"treasury_cap#0#0": "TreasuryCap<TOKEN>"
},
"returnType": "TokenId"
}
}
}