-
Notifications
You must be signed in to change notification settings - Fork 42
[clijs] add receipt command #855
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import type { ProcessedReceipt } from "@nilfoundation/niljs"; | ||
| import { BaseCommand } from "../base.js"; | ||
| import { hexArg } from "../types.js"; | ||
|
|
||
| export default class ReceiptCommand extends BaseCommand { | ||
| static override description = "Retrieve a receipt from the cluster"; | ||
|
|
||
| static override examples = ["<%= config.bin %> <%= command.id %>"]; | ||
|
|
||
| static args = { | ||
| hash: hexArg({ | ||
| name: "hash", | ||
| required: true, | ||
| description: "transaction hash", | ||
| }), | ||
| }; | ||
|
|
||
| async run(): Promise<ProcessedReceipt | null> { | ||
| const { args, flags } = await this.parse(ReceiptCommand); | ||
|
|
||
| if (!this.rpcClient) { | ||
| throw new Error("RPC client is not initialized"); | ||
| } | ||
|
|
||
| const res = await this.rpcClient.getTransactionReceiptByHash(args.hash); | ||
| if (flags.quiet) { | ||
| this.log(res as unknown as string); | ||
| } else { | ||
| this.log("Receipt data:", res as unknown as string); | ||
| } | ||
| return res; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import type { Hex, ProcessedReceipt } from "@nilfoundation/niljs"; | ||
| import { describe, expect } from "vitest"; | ||
| import { CliTest } from "../setup.js"; | ||
|
|
||
| // To run this test you need to run the nild: | ||
| // nild run --http-port 8529 | ||
| describe("receipt:get_receipt", () => { | ||
| CliTest("tests getting receipts", async ({ runCommand, smartAccount }) => { | ||
| const txHash = ( | ||
| await runCommand([ | ||
| "smart-account", | ||
| "send-tokens", | ||
| smartAccount.address, | ||
| "--amount", | ||
| "100", | ||
| "--feeCredit", | ||
| 10_000_000_000_000 as unknown as string, | ||
| ]) | ||
| ).result as Hex; | ||
| expect(txHash).toBeTruthy(); | ||
|
|
||
| const r = (await runCommand(["receipt", txHash])).result as ProcessedReceipt; | ||
| expect(r.success).toBeTruthy(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's also check that
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed. also fixed for the regarding output: I haven't found an easy way to get it. inb4:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this approach work?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did some research, and found out that without
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. The documentation for
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,4 +43,7 @@ export async function topUp({ | |
| }, | ||
| client, | ||
| ); | ||
|
|
||
| client.closeConnection(); | ||
| faucetClient.closeConnection(); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.