@thru/sdk 0.2.35 → 0.2.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
Account,
|
|
34
34
|
Block,
|
|
35
35
|
ChainEvent,
|
|
36
|
+
ConsensusStatus,
|
|
36
37
|
Transaction,
|
|
37
38
|
TransactionStatusSnapshot,
|
|
38
39
|
} from "@thru/sdk";
|
|
@@ -51,19 +52,26 @@ const account: Account = await thru.accounts.get("taExampleAddress...");
|
|
|
51
52
|
console.log(account.meta?.balance);
|
|
52
53
|
|
|
53
54
|
// Build, sign, submit, and track a transaction
|
|
54
|
-
const { rawTransaction
|
|
55
|
+
const { rawTransaction } = await thru.transactions.buildAndSign({
|
|
55
56
|
feePayer: {
|
|
56
57
|
publicKey: "taFeePayerAddress...",
|
|
57
58
|
privateKey: feePayerSecretKeyBytes,
|
|
58
59
|
},
|
|
59
60
|
program: programIdentifierBytes,
|
|
60
61
|
});
|
|
61
|
-
await thru.transactions.send(rawTransaction);
|
|
62
62
|
|
|
63
|
-
//
|
|
64
|
-
for await (const update of thru.
|
|
63
|
+
// Submit and track with one RPC so no live tracking update can be missed.
|
|
64
|
+
for await (const update of thru.transactions.sendAndTrack(rawTransaction, {
|
|
65
|
+
timeoutMs: 60_000,
|
|
66
|
+
})) {
|
|
65
67
|
console.log(update.status, update.executionResult?.consumedComputeUnits);
|
|
66
|
-
if (
|
|
68
|
+
if (
|
|
69
|
+
update.executionResult ||
|
|
70
|
+
update.consensusStatus === ConsensusStatus.FINALIZED ||
|
|
71
|
+
update.consensusStatus === ConsensusStatus.CLUSTER_EXECUTED
|
|
72
|
+
) {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
67
75
|
}
|
|
68
76
|
```
|
|
69
77
|
|
|
@@ -270,7 +278,8 @@ for await (const { event } of thru.streaming.streamEvents()) {
|
|
|
270
278
|
console.log((event as ChainEvent).timestampNs);
|
|
271
279
|
}
|
|
272
280
|
|
|
273
|
-
// Transaction tracking
|
|
281
|
+
// Transaction tracking for an existing signature. This is a live stream; when
|
|
282
|
+
// submitting a raw transaction yourself, prefer transactions.sendAndTrack().
|
|
274
283
|
for await (const update of thru.streaming.trackTransaction(signature)) {
|
|
275
284
|
console.log(update.status, update.executionResult?.consumedComputeUnits);
|
|
276
285
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|