Skip to content

Commit

Permalink
Consistent case fields(camelCase v.s snake_case) in checkpoint.ts and…
Browse files Browse the repository at this point in the history
… faucet.ts (MystenLabs#9054)

Change names of fields in checkpoint and faucet files of ts-sdk to
camelCase.
Add `#[serde(rename_all = "camelCase")]` to corresponding files in
sui-types.
  • Loading branch information
danaiballa authored Mar 10, 2023
1 parent 22df132 commit 9b60bf7
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .changeset/witty-baboons-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@mysten/sui.js": minor
---

Change all snake_case fields in checkpoint.ts and faucet.ts to camelCase
6 changes: 3 additions & 3 deletions apps/explorer/src/pages/checkpoints/CheckpointDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,23 @@ function CheckpointDetail() {
<Text variant="p1/medium" color="steel-darker">
{
data.epochRollingGasCostSummary
.computation_cost
.computationCost
}
</Text>
</DescriptionItem>
<DescriptionItem title="Storage Fee">
<Text variant="p1/medium" color="steel-darker">
{
data.epochRollingGasCostSummary
.storage_cost
.storageCost
}
</Text>
</DescriptionItem>
<DescriptionItem title="Storage Rebate">
<Text variant="p1/medium" color="steel-darker">
{
data.epochRollingGasCostSummary
.storage_rebate
.storageRebate
}
</Text>
</DescriptionItem>
Expand Down
4 changes: 2 additions & 2 deletions apps/wallet/src/ui/app/shared/faucet/useFaucetMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export function useFaucetMutation() {
if (!address) {
throw new Error('Failed, wallet address not found.');
}
const { error, transferred_gas_objects } =
const { error, transferredGasObjects } =
await api.requestSuiFromFaucet(address);
if (error) {
throw new Error(error);
}
return transferred_gas_objects.reduce(
return transferredGasObjects.reduce(
(total, { amount }) => total + amount,
0
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,48 @@ expression: common_costs_actual
---
{
"MergeCoin": {
"computation_cost": 176,
"storage_cost": 42,
"storage_rebate": 0
"computationCost": 176,
"storageCost": 42,
"storageRebate": 0
},
"Publish": {
"computation_cost": 646,
"storage_cost": 140,
"storage_rebate": 0
"computationCost": 646,
"storageCost": 140,
"storageRebate": 0
},
"SharedCounterAssertValue": {
"computation_cost": 212,
"storage_cost": 42,
"storage_rebate": 21
"computationCost": 212,
"storageCost": 42,
"storageRebate": 21
},
"SharedCounterCreate": {
"computation_cost": 216,
"storage_cost": 42,
"storage_rebate": 0
"computationCost": 216,
"storageCost": 42,
"storageRebate": 0
},
"SharedCounterIncrement": {
"computation_cost": 212,
"storage_cost": 42,
"storage_rebate": 21
"computationCost": 212,
"storageCost": 42,
"storageRebate": 21
},
"SplitCoin": {
"computation_cost": 290,
"storage_cost": 105,
"storage_rebate": 0
"computationCost": 290,
"storageCost": 105,
"storageRebate": 0
},
"TransferPortionSuiCoin": {
"computation_cost": 139,
"storage_cost": 42,
"storage_rebate": 0
"computationCost": 139,
"storageCost": 42,
"storageRebate": 0
},
"TransferWholeCoin": {
"computation_cost": 151,
"storage_cost": 42,
"storage_rebate": 0
"computationCost": 151,
"storageCost": 42,
"storageRebate": 0
},
"TransferWholeSuiCoin": {
"computation_cost": 131,
"storage_cost": 21,
"storage_rebate": 0
"computationCost": 131,
"storageCost": 21,
"storageRebate": 0
}
}
6 changes: 3 additions & 3 deletions crates/sui-open-rpc/spec/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,9 @@
"networkTotalTransactions": 792385,
"previousDigest": "EnRQXe1hDGAJCFyF2ds2GmPHdvf9V6yxf24LisEsDkYt",
"epochRollingGasCostSummary": {
"computation_cost": 0,
"storage_cost": 0,
"storage_rebate": 0
"computationCost": 0,
"storageCost": 0,
"storageRebate": 0
},
"timestampMs": 1676911928,
"endOfEpochData": null,
Expand Down
1 change: 1 addition & 0 deletions crates/sui-types/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ macro_rules! ok_or_gas_balance_error {
}

#[derive(Eq, PartialEq, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct GasCostSummary {
pub computation_cost: u64,
pub storage_cost: u64,
Expand Down
12 changes: 6 additions & 6 deletions sdk/typescript/src/types/checkpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
import { TransactionDigest, TransactionEffectsDigest } from './common';

export const GasCostSummary = object({
computation_cost: number(),
storage_cost: number(),
storage_rebate: number(),
computationCost: number(),
storageCost: number(),
storageRebate: number(),
});
export type GasCostSummary = Infer<typeof GasCostSummary>;

Expand All @@ -36,9 +36,9 @@ export const CheckpointCommitment = union([ECMHLiveObjectSetDigest]);
export type CheckpointCommitment = Infer<typeof CheckpointCommitment>;

export const EndOfEpochData = object({
next_epoch_committee: array(tuple([string(), number()])),
next_epoch_protocol_version: number(),
checkpoint_commitments: array(CheckpointCommitment),
nextEpochCommittee: array(tuple([string(), number()])),
nextEpochProtocolVersion: number(),
checkpointCommitments: array(CheckpointCommitment),
});
export type EndOfEpochData = Infer<typeof EndOfEpochData>;

Expand Down
4 changes: 2 additions & 2 deletions sdk/typescript/src/types/faucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { TransactionDigest, ObjectId } from './common';
export type FaucetCoinInfo = {
amount: number;
id: ObjectId;
transfer_tx_digest: TransactionDigest;
transferTxDigest: TransactionDigest;
};

export type FaucetResponse = {
transferred_gas_objects: FaucetCoinInfo[];
transferredGasObjects: FaucetCoinInfo[];
error: string | null;
};

0 comments on commit 9b60bf7

Please sign in to comment.