From 5078ebb62ac85eb428ee214baa15f5a204e90d39 Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Tue, 8 Oct 2024 05:19:55 -0400 Subject: [PATCH] refactor(gas_service)!: rename versioned module to GasService_v0 (#168) --- move/gas_service/sources/gas_service.move | 12 +++++----- .../sources/versioned/gas_service_v0.move | 22 +++++++++---------- .../interface_gas_service_gas_service_v0.json | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/move/gas_service/sources/gas_service.move b/move/gas_service/sources/gas_service.move index 3184e48a..12f9e3bb 100644 --- a/move/gas_service/sources/gas_service.move +++ b/move/gas_service/sources/gas_service.move @@ -1,6 +1,6 @@ module gas_service::gas_service; -use gas_service::gas_service_v0::{Self, GasServiceV0}; +use gas_service::gas_service_v0::{Self, GasService_v0}; use std::ascii::{Self, String}; use sui::address; use sui::coin::Coin; @@ -87,9 +87,9 @@ fun init(ctx: &mut TxContext) { macro fun value_mut( $self: &GasService, $function_name: vector, -): &mut GasServiceV0 { +): &mut GasService_v0 { let gas_service = $self; - let value = gas_service.inner.load_value_mut(); + let value = gas_service.inner.load_value_mut(); value.version_control().check(VERSION, ascii::string($function_name)); value } @@ -204,9 +204,9 @@ fun version_control(): VersionControl { use sui::coin; #[test_only] -macro fun value($self: &GasService): &GasServiceV0 { +macro fun value($self: &GasService): &GasService_v0 { let gas_service = $self; - gas_service.inner.load_value() + gas_service.inner.load_value() } #[test_only] @@ -233,7 +233,7 @@ fun new(ctx: &mut TxContext): (GasService, GasCollectorCap) { fun destroy(self: GasService) { let GasService { id, inner } = self; id.delete(); - let data = inner.destroy(); + let data = inner.destroy(); data.destroy_for_testing(); } diff --git a/move/gas_service/sources/versioned/gas_service_v0.move b/move/gas_service/sources/versioned/gas_service_v0.move index 0a818f6e..400ad3d4 100644 --- a/move/gas_service/sources/versioned/gas_service_v0.move +++ b/move/gas_service/sources/versioned/gas_service_v0.move @@ -8,7 +8,7 @@ use version_control::version_control::VersionControl; // ------- // Structs // ------- -public struct GasServiceV0 has store { +public struct GasService_v0 has store { balance: Balance, version_control: VersionControl, } @@ -16,23 +16,23 @@ public struct GasServiceV0 has store { // ----------------- // Package Functions // ----------------- -public(package) fun new(version_control: VersionControl): GasServiceV0 { - GasServiceV0 { +public(package) fun new(version_control: VersionControl): GasService_v0 { + GasService_v0 { balance: balance::zero(), version_control, } } -public(package) fun version_control(self: &GasServiceV0): &VersionControl { +public(package) fun version_control(self: &GasService_v0): &VersionControl { &self.version_control } -public(package) fun put(self: &mut GasServiceV0, coin: Coin) { +public(package) fun put(self: &mut GasService_v0, coin: Coin) { coin::put(&mut self.balance, coin); } public(package) fun take( - self: &mut GasServiceV0, + self: &mut GasService_v0, amount: u64, ctx: &mut TxContext, ): Coin { @@ -43,22 +43,22 @@ public(package) fun take( // Test Only // --------- #[test_only] -public fun version_control_mut(self: &mut GasServiceV0): &mut VersionControl { +public fun version_control_mut(self: &mut GasService_v0): &mut VersionControl { &mut self.version_control } #[test_only] -public fun balance(self: &GasServiceV0): &Balance { +public fun balance(self: &GasService_v0): &Balance { &self.balance } #[test_only] -public fun balance_mut(self: &mut GasServiceV0): &mut Balance { +public fun balance_mut(self: &mut GasService_v0): &mut Balance { &mut self.balance } #[test_only] -public fun destroy_for_testing(self: GasServiceV0) { - let GasServiceV0 { balance, version_control: _ } = self; +public fun destroy_for_testing(self: GasService_v0) { + let GasService_v0 { balance, version_control: _ } = self; balance.destroy_for_testing(); } diff --git a/test/testdata/interface_gas_service_gas_service_v0.json b/test/testdata/interface_gas_service_gas_service_v0.json index 9a2a14dd..61d7b6f1 100644 --- a/test/testdata/interface_gas_service_gas_service_v0.json +++ b/test/testdata/interface_gas_service_gas_service_v0.json @@ -1,7 +1,7 @@ { "structs": { - "GasServiceV0": { - "name": "GasServiceV0", + "GasService_v0": { + "name": "GasService_v0", "abilities": [ "store" ],