diff --git a/.changeset/fair-dots-explode.md b/.changeset/fair-dots-explode.md new file mode 100644 index 00000000..1a624436 --- /dev/null +++ b/.changeset/fair-dots-explode.md @@ -0,0 +1,5 @@ +--- +'@axelar-network/axelar-cgp-sui': minor +--- + +Paying for gas now requires the message ticket instead of the call information. diff --git a/move/example/Move.toml b/move/example/Move.toml index e988646d..71a64333 100644 --- a/move/example/Move.toml +++ b/move/example/Move.toml @@ -5,8 +5,8 @@ edition = "2024.beta" [dependencies] Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.35.2" } -AxelarGateway = { local = "../axelar_gateway" } GasService = { local = "../gas_service" } +AxelarGateway = { local = "../axelar_gateway" } Utils = { local = "../utils" } VersionControl = { local = "../version_control" } ITS = { local = "../its" } diff --git a/move/example/sources/gmp/gmp.move b/move/example/sources/gmp/gmp.move index 06408989..c95cce56 100644 --- a/move/example/sources/gmp/gmp.move +++ b/move/example/sources/gmp/gmp.move @@ -77,20 +77,19 @@ public fun send_call( coin: Coin, params: vector, ) { - gas_service.pay_gas( - coin, - sui::object::id_address(&singleton.channel), - destination_chain, - destination_address, - payload, - refund_address, - params, - ); + let message_ticket = gateway::prepare_message( &singleton.channel, destination_chain, destination_address, payload, + ); + + gas_service.pay_gas( + &message_ticket, + coin, + refund_address, + params, ); gateway.send_message(message_ticket); diff --git a/move/example/sources/its/its.move b/move/example/sources/its/its.move index 48f0b94a..ca1b2806 100644 --- a/move/example/sources/its/its.move +++ b/move/example/sources/its/its.move @@ -267,11 +267,8 @@ fun pay_gas_and_send_message( gas_params: vector, ) { gas_service.pay_gas( + &message_ticket, gas, - message_ticket.source_id(), - message_ticket.destination_chain(), - message_ticket.destination_address(), - message_ticket.payload(), refund_address, gas_params, ); diff --git a/move/gas_service/Move.lock b/move/gas_service/Move.lock index f9b3f51b..16161b14 100644 --- a/move/gas_service/Move.lock +++ b/move/gas_service/Move.lock @@ -2,13 +2,25 @@ [move] version = 3 -manifest_digest = "C29AEC3A18805EA1C5A2FCA5811D6AAD6BE44E394A8FDF0B02FB34D3409F4D3E" -deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600" +manifest_digest = "C04CC08DC1212FBCB4F5A869F32A9607A3C3E3586BC3BEFC0C0F1DBD3CE563CE" +deps_digest = "060AD7E57DFB13104F21BE5F5C3759D03F0553FC3229247D9A7A6B45F50D03A3" dependencies = [ + { id = "AxelarGateway", name = "AxelarGateway" }, { id = "Sui", name = "Sui" }, { id = "VersionControl", name = "VersionControl" }, ] +[[move.package]] +id = "AxelarGateway" +source = { local = "../axelar_gateway" } + +dependencies = [ + { id = "MoveStdlib", name = "MoveStdlib" }, + { id = "Sui", name = "Sui" }, + { id = "Utils", name = "Utils" }, + { id = "VersionControl", name = "VersionControl" }, +] + [[move.package]] id = "MoveStdlib" source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet-v1.35.2", subdir = "crates/sui-framework/packages/move-stdlib" } @@ -21,6 +33,14 @@ dependencies = [ { id = "MoveStdlib", name = "MoveStdlib" }, ] +[[move.package]] +id = "Utils" +source = { local = "../utils" } + +dependencies = [ + { id = "Sui", name = "Sui" }, +] + [[move.package]] id = "VersionControl" source = { local = "../version_control" } diff --git a/move/gas_service/Move.toml b/move/gas_service/Move.toml index 1e804f9b..c83e94eb 100644 --- a/move/gas_service/Move.toml +++ b/move/gas_service/Move.toml @@ -6,6 +6,7 @@ edition = "2024.beta" [dependencies] Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.35.2" } VersionControl = { local = "../version_control" } +AxelarGateway = { local = "../axelar_gateway" } [addresses] gas_service = "0xa2" diff --git a/move/gas_service/sources/gas_service.move b/move/gas_service/sources/gas_service.move index 9bee412a..c27a5659 100644 --- a/move/gas_service/sources/gas_service.move +++ b/move/gas_service/sources/gas_service.move @@ -1,5 +1,6 @@ module gas_service::gas_service; +use axelar_gateway::message_ticket::MessageTicket; use gas_service::gas_service_v0::{Self, GasService_v0}; use std::ascii::{Self, String}; use sui::coin::Coin; @@ -71,22 +72,16 @@ macro fun value_mut( /// setting the sender as the channel ID. public fun pay_gas( self: &mut GasService, + message_ticket: &MessageTicket, coin: Coin, - sender: address, - destination_chain: String, - destination_address: String, - payload: vector, refund_address: address, params: vector, ) { self .value_mut!(b"pay_gas") .pay_gas( + message_ticket, coin, - sender, - destination_chain, - destination_address, - payload, refund_address, params, ); @@ -220,14 +215,22 @@ fun test_pay_gas() { let digest = ctx.digest(); let value = (((digest[0] as u16) << 8) | (digest[1] as u16) as u64) + 1; let c: Coin = coin::mint_for_testing(value, ctx); + let channel = axelar_gateway::channel::new(ctx); + let destination_chain = b"destination chain".to_ascii_string(); + let destination_address = b"destination address".to_ascii_string(); + let payload = b"payload"; + + let ticket = axelar_gateway::gateway::prepare_message( + &channel, + destination_chain, + destination_address, + payload, + ); service.pay_gas( + &ticket, c, ctx.sender(), - std::ascii::string(b"destination chain"), - std::ascii::string(b"destination address"), - vector[], - ctx.sender(), vector[], ); @@ -235,6 +238,8 @@ fun test_pay_gas() { cap.destroy_cap(); service.destroy(); + channel.destroy(); + sui::test_utils::destroy(ticket); } #[test] diff --git a/move/gas_service/sources/versioned/gas_service_v0.move b/move/gas_service/sources/versioned/gas_service_v0.move index c1bcd83a..84a676d5 100644 --- a/move/gas_service/sources/versioned/gas_service_v0.move +++ b/move/gas_service/sources/versioned/gas_service_v0.move @@ -1,5 +1,6 @@ module gas_service::gas_service_v0; +use axelar_gateway::message_ticket::MessageTicket; use gas_service::events; use std::ascii::String; use sui::address; @@ -33,23 +34,22 @@ public(package) fun version_control(self: &GasService_v0): &VersionControl { public(package) fun pay_gas( self: &mut GasService_v0, + message_ticket: &MessageTicket, coin: Coin, - sender: address, - destination_chain: String, - destination_address: String, - payload: vector, refund_address: address, params: vector, ) { let coin_value = coin.value(); self.put(coin); - let payload_hash = address::from_bytes(keccak256(&payload)); + let payload_hash = address::from_bytes( + keccak256(&message_ticket.payload()), + ); events::gas_paid( - sender, - destination_chain, - destination_address, + message_ticket.source_id(), + message_ticket.destination_chain(), + message_ticket.destination_address(), payload_hash, coin_value, refund_address,