Skip to content

Commit

Permalink
refactor(gas_service)!: rename versioned module to GasService_v0 (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth authored Oct 8, 2024
1 parent ab20e4b commit 5078ebb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions move/gas_service/sources/gas_service.move
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -87,9 +87,9 @@ fun init(ctx: &mut TxContext) {
macro fun value_mut(
$self: &GasService,
$function_name: vector<u8>,
): &mut GasServiceV0 {
): &mut GasService_v0 {
let gas_service = $self;
let value = gas_service.inner.load_value_mut<GasServiceV0>();
let value = gas_service.inner.load_value_mut<GasService_v0>();
value.version_control().check(VERSION, ascii::string($function_name));
value
}
Expand Down Expand Up @@ -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<GasServiceV0>()
gas_service.inner.load_value<GasService_v0>()
}

#[test_only]
Expand All @@ -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<GasServiceV0>();
let data = inner.destroy<GasService_v0>();
data.destroy_for_testing();
}

Expand Down
22 changes: 11 additions & 11 deletions move/gas_service/sources/versioned/gas_service_v0.move
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ use version_control::version_control::VersionControl;
// -------
// Structs
// -------
public struct GasServiceV0 has store {
public struct GasService_v0 has store {
balance: Balance<SUI>,
version_control: VersionControl,
}

// -----------------
// 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<SUI>(),
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<SUI>) {
public(package) fun put(self: &mut GasService_v0, coin: Coin<SUI>) {
coin::put(&mut self.balance, coin);
}

public(package) fun take(
self: &mut GasServiceV0,
self: &mut GasService_v0,
amount: u64,
ctx: &mut TxContext,
): Coin<SUI> {
Expand All @@ -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<SUI> {
public fun balance(self: &GasService_v0): &Balance<SUI> {
&self.balance
}

#[test_only]
public fun balance_mut(self: &mut GasServiceV0): &mut Balance<SUI> {
public fun balance_mut(self: &mut GasService_v0): &mut Balance<SUI> {
&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();
}
4 changes: 2 additions & 2 deletions test/testdata/interface_gas_service_gas_service_v0.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"structs": {
"GasServiceV0": {
"name": "GasServiceV0",
"GasService_v0": {
"name": "GasService_v0",
"abilities": [
"store"
],
Expand Down

0 comments on commit 5078ebb

Please sign in to comment.