-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TS] Updated the gas fee payer example to adopt the new API #9499
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -16,6 +16,7 @@ import { | |||
} from "aptos"; | |||
import { NODE_URL, FAUCET_URL } from "./common"; | |||
import { assert } from "console"; | |||
import * as Gen from "../../src/generated"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0xmaayan , is there a better way to import this than using a relative path like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can import 'Type' and then use it 'Type.'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied. Thank you!
Great! A lot simpler :D Would be nice to have alice and bob's balance tracked from before and after and then print out the gas fees so you can see that Alice's balance didn't change and Bob's did, in the same amount as the gas fees paid: const aliceBalanceBefore = await getBalance(alice);
const bobBalanceBefore = await getBalance(bob);
console.log(`Alice's balance: ${aliceBalanceBefore} octas`);
console.log(`Bob's balance: ${bobBalanceBefore} octas`);
// ... submit tx
const response = await client.waitForTransactionWithResult(txnHash, { checkSuccess: true });
const { gas_used, gas_unit_price } = response as any;
// ... print token amt
// Check that Alice did not pay the fee, but Bob did.
const aliceBalanceAfter = await getBalance(alice);
const bobBalanceAfter = await getBalance(bob);
console.log(`Alice's balance: ${aliceBalanceAfter} octas`);
console.log(`Bob's balance: ${bobBalanceAfter} octas`);
console.log(
"\n=== Check Bob and Alice's balance changes ===\n" +
`Alice's balance change: ${aliceBalanceBefore - aliceBalanceAfter} octas\n` +
`Bob's balance change: ${bobBalanceBefore - bobBalanceAfter} octas\n` +
`The gas fees were: ${gas_used * gas_unit_price} octas`,
); |
9454da4
to
3101f80
Compare
3101f80
to
f50909d
Compare
- Updated the gas fee payer example to adopt the new API of aptos SDK v. 1.17.0 - Simplifies the flow significantly
f50909d
to
da71f7b
Compare
Thank you for the nice suggestion! I updated it to display the gas fee usage per transaction! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
- Updated the gas fee payer example to adopt the new API of aptos SDK v. 1.17.0 - Simplifies the flow significantly
Description
Test Plan
pnpm run gas_fee_payer