Skip to content

Commit

Permalink
add gasProfile() method to run Move gas profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmaayan committed Nov 18, 2024
1 parent 0e487fd commit c1190d0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ All notable changes to the Aptos TypeScript SDK will be captured in this file. T

# Unreleased

- Add `gasProfile` function to `Move` class to allow for gas profiling of Aptos Move functions

# 1.33.0 (2024-11-13)

- Allow optional provision of public keys in transaction simulation
- Update the multisig v2 example to demonstrate a new way to pre-check a multisig payload before it is created on-chain

# 1.32.1 (2024-11-11)

- Add support for Firebase issuers in the `updateFederatedKeylessJwkSetTransaction` function
- [`Breaking`] Revert new `scriptComposer` api in transactionSubmission api to allower SDK callers to invoke multiple Move functions inside a same transaction and compose the calls dynamically.

Expand Down
15 changes: 15 additions & 0 deletions examples/typescript/local_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ async function stopLocalNode() {
}
}

async function profileGas() {
try {
console.log("running gas profiling");
await move.gasProfile({
network: "mainnet",
transactionId: "1702334345",
});
} catch (error) {
console.error("error running gas profiling", error);
}
}

async function run() {
// start the localnet
await runLocalNode();
Expand All @@ -182,6 +194,9 @@ async function run() {

// stop the localnet
await stopLocalNode();

// run gas profiling
await profileGas();
}

run();
16 changes: 16 additions & 0 deletions src/cli/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,22 @@ export class Move {
return this.runCommand(cliArgs, showStdout);
}

async gasProfile(args: {
network: string;
transactionId: string;
extraArguments?: Array<string>;
showStdout?: boolean;
}): Promise<{ output: string; result?: any }> {
const { network, transactionId, extraArguments, showStdout } = args;
const cliArgs = ["aptos", "move", "replay", "--profile-gas", "--network", network, "--txn-id", transactionId];

if (extraArguments) {
cliArgs.push(...extraArguments);
}

return this.runCommand(cliArgs, showStdout);
}

/**
* Run a command with the specified arguments and return the output.
*
Expand Down

0 comments on commit c1190d0

Please sign in to comment.