From d04fcdd42ef08e2ec6ad6aaf2932c682dbcd929e Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Tue, 14 May 2024 03:33:02 -0400 Subject: [PATCH] feat(gas-service): add method to collect gas (#26) --- .../sources/gas_service/gas_service.move | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/move/gas_service/sources/gas_service/gas_service.move b/move/gas_service/sources/gas_service/gas_service.move index 9d744e8e..bb8e4266 100644 --- a/move/gas_service/sources/gas_service/gas_service.move +++ b/move/gas_service/sources/gas_service/gas_service.move @@ -14,23 +14,23 @@ module gas_service::gas_service { balance: Balance, } - public struct RefunderCap has key, store { + public struct GasCollectorCap has key, store { id: UID, } public struct NativeGasPaidForContractCall has copy, drop { - sender: address, - destination_chain: String, - destination_address: String, - payload_hash: address, + sender: address, + destination_chain: String, + destination_address: String, + payload_hash: address, value: u64, refund_address: address, } public struct NativeGasAdded has copy, drop { - tx_hash: address, + tx_hash: address, log_index: u64, - value: u64, + value: u64, refund_address: address, } @@ -40,7 +40,7 @@ module gas_service::gas_service { balance: balance::zero(), }); - transfer::public_transfer(RefunderCap { + transfer::public_transfer(GasCollectorCap { id: object::new(ctx), }, ctx.sender()); } @@ -85,10 +85,10 @@ module gas_service::gas_service { }); } - public fun refund(self: &mut GasService, _: &RefunderCap, receiver: address, amount: u64, ctx: &mut TxContext) { + public fun refund(self: &mut GasService, _: &GasCollectorCap, receiver: address, amount: u64, ctx: &mut TxContext) { transfer::public_transfer( coin::take(&mut self.balance, amount, ctx), receiver, ) } -} \ No newline at end of file +}