@thruputchain/client 0.28.0 → 0.29.0
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 +112 -17
- package/dist/{actions-B5-CjpEF.cjs → actions-B2gV8Vzr.cjs} +297 -73
- package/dist/actions-B2gV8Vzr.cjs.map +1 -0
- package/dist/actions-UEYKD22C.js +653 -0
- package/dist/actions-UEYKD22C.js.map +1 -0
- package/dist/actions.cjs +4 -8
- package/dist/actions.d.cts +4 -4
- package/dist/actions.d.ts +4 -4
- package/dist/actions.js +3 -3
- package/dist/{artifact-BM_MVzhL.d.ts → artifact-RIAPVmVX.d.cts} +4 -3
- package/dist/artifact-RIAPVmVX.d.cts.map +1 -0
- package/dist/{artifact-BM_MVzhL.d.cts → artifact-RIAPVmVX.d.ts} +4 -3
- package/dist/artifact-RIAPVmVX.d.ts.map +1 -0
- package/dist/{contract-D77iA2iY.js → contract-BOlNskwd.js} +235 -87
- package/dist/contract-BOlNskwd.js.map +1 -0
- package/dist/{contract-DSu2UPPm.cjs → contract-D_vxUudr.cjs} +281 -109
- package/dist/contract-D_vxUudr.cjs.map +1 -0
- package/dist/contract.cjs +1 -5
- package/dist/contract.d.cts +4 -4
- package/dist/contract.d.ts +4 -4
- package/dist/contract.js +2 -2
- package/dist/contracts.cjs +5 -5
- package/dist/contracts.d.cts +19 -4
- package/dist/contracts.d.cts.map +1 -1
- package/dist/contracts.d.ts +19 -4
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +4 -4
- package/dist/decimal-BX7abv5J.cjs +171 -0
- package/dist/decimal-BX7abv5J.cjs.map +1 -0
- package/dist/decimal-CoHOISys.js +124 -0
- package/dist/decimal-CoHOISys.js.map +1 -0
- package/dist/{dev_wallet-CAbOSrak.cjs → dev_wallet-BVChhV6j.cjs} +85 -6
- package/dist/dev_wallet-BVChhV6j.cjs.map +1 -0
- package/dist/{dev_wallet-CU3RpQLm.js → dev_wallet-D9LuPZ-h.js} +84 -5
- package/dist/dev_wallet-D9LuPZ-h.js.map +1 -0
- package/dist/{execution-J5jkXhV1.d.cts → execution-pSt6k620.d.cts} +23 -50
- package/dist/execution-pSt6k620.d.cts.map +1 -0
- package/dist/{execution-XJ0iwFaX.d.ts → execution-uiuFPV0d.d.ts} +23 -50
- package/dist/execution-uiuFPV0d.d.ts.map +1 -0
- package/dist/{hex-DIcaALXL.js → hex-B8D-jBgz.js} +2 -2
- package/dist/{hex-DIcaALXL.js.map → hex-B8D-jBgz.js.map} +1 -1
- package/dist/{hex-DkGpiZ5e.cjs → hex-CSDZ9d6z.cjs} +2 -2
- package/dist/{hex-DkGpiZ5e.cjs.map → hex-CSDZ9d6z.cjs.map} +1 -1
- package/dist/{index-soFVQX9j.d.cts → index-B1efA-Y_.d.ts} +24 -21
- package/dist/index-B1efA-Y_.d.ts.map +1 -0
- package/dist/{index-C3HVRvQd.d.ts → index-BGmH_Sm7.d.cts} +12 -62
- package/dist/index-BGmH_Sm7.d.cts.map +1 -0
- package/dist/{index-Bb01ytjJ.d.ts → index-BZ5j5P5d.d.ts} +11 -9
- package/dist/index-BZ5j5P5d.d.ts.map +1 -0
- package/dist/{index-CedOvhGY.d.cts → index-BfYEEVHm.d.cts} +3 -13
- package/dist/index-BfYEEVHm.d.cts.map +1 -0
- package/dist/{index-CtjWsAXV.d.cts → index-BhOeIyrZ.d.cts} +11 -9
- package/dist/index-BhOeIyrZ.d.cts.map +1 -0
- package/dist/{index-B5KqSHeL.d.cts → index-BsvYcU_Y.d.cts} +2 -2
- package/dist/{index-B5KqSHeL.d.cts.map → index-BsvYcU_Y.d.cts.map} +1 -1
- package/dist/{index-DeS1S0m-.d.ts → index-Btl_jMCT.d.ts} +3 -13
- package/dist/index-Btl_jMCT.d.ts.map +1 -0
- package/dist/{index-CtjZ61tl.d.cts → index-CG-q0j9w.d.ts} +12 -62
- package/dist/index-CG-q0j9w.d.ts.map +1 -0
- package/dist/index-CPtBvHE8.d.ts +145 -0
- package/dist/index-CPtBvHE8.d.ts.map +1 -0
- package/dist/{index-DfmDUk5Y.d.ts → index-DBKsOzCN.d.cts} +24 -21
- package/dist/index-DBKsOzCN.d.cts.map +1 -0
- package/dist/index-Xre-0Jka.d.cts +145 -0
- package/dist/index-Xre-0Jka.d.cts.map +1 -0
- package/dist/index.cjs +39 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -17
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +12 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -38
- package/dist/index.js.map +1 -1
- package/dist/provider.cjs +3 -3
- package/dist/provider.cjs.map +1 -1
- package/dist/provider.d.cts +2 -1
- package/dist/provider.d.ts +2 -1
- package/dist/provider.js +3 -3
- package/dist/provider.js.map +1 -1
- package/dist/{codec-Bxlt1gKO.js → readError-B3Rz7rgs.js} +359 -56
- package/dist/readError-B3Rz7rgs.js.map +1 -0
- package/dist/{codec-BcK8ASsg.cjs → readError-COcEDNoZ.cjs} +363 -96
- package/dist/readError-COcEDNoZ.cjs.map +1 -0
- package/dist/requestAirdrop-DBCOST2B.d.ts +1818 -0
- package/dist/requestAirdrop-DBCOST2B.d.ts.map +1 -0
- package/dist/requestAirdrop-T1eVn3l5.d.cts +1818 -0
- package/dist/requestAirdrop-T1eVn3l5.d.cts.map +1 -0
- package/dist/sendInvocation-185ZJrta.cjs +583 -0
- package/dist/sendInvocation-185ZJrta.cjs.map +1 -0
- package/dist/sendInvocation-DBaNWhr3.js +439 -0
- package/dist/sendInvocation-DBaNWhr3.js.map +1 -0
- package/dist/signed-op.cjs +2 -2
- package/dist/signed-op.d.cts +2 -2
- package/dist/signed-op.d.ts +1 -1
- package/dist/signed-op.js +2 -2
- package/dist/{signedOp-DAucp6xg.cjs → signedOp-CVyeJ5ig.cjs} +3 -3
- package/dist/{signedOp-DAucp6xg.cjs.map → signedOp-CVyeJ5ig.cjs.map} +1 -1
- package/dist/{signedOp-DpmUpH-e.js → signedOp-D6WYZG9j.js} +3 -3
- package/dist/{signedOp-DpmUpH-e.js.map → signedOp-D6WYZG9j.js.map} +1 -1
- package/dist/{signed_op-_lR85dn2.cjs → signed_op-BBsDKOlD.cjs} +4 -4
- package/dist/{signed_op-_lR85dn2.cjs.map → signed_op-BBsDKOlD.cjs.map} +1 -1
- package/dist/{signed_op-D2usgASc.d.cts → signed_op-BvbOHWKK.d.ts} +3 -3
- package/dist/{signed_op-zGq4eBo8.d.ts.map → signed_op-BvbOHWKK.d.ts.map} +1 -1
- package/dist/{signed_op-zGq4eBo8.d.ts → signed_op-DoHFpSH4.d.cts} +3 -3
- package/dist/{signed_op-D2usgASc.d.cts.map → signed_op-DoHFpSH4.d.cts.map} +1 -1
- package/dist/{signed_op-CwN-_CXw.js → signed_op-h9X9-vBL.js} +3 -3
- package/dist/{signed_op-CwN-_CXw.js.map → signed_op-h9X9-vBL.js.map} +1 -1
- package/dist/transport-BhWZxHcz.cjs +528 -0
- package/dist/transport-BhWZxHcz.cjs.map +1 -0
- package/dist/transport-EyDYuibb.js +504 -0
- package/dist/transport-EyDYuibb.js.map +1 -0
- package/dist/transport.cjs +6 -13
- package/dist/transport.d.cts +3 -3
- package/dist/transport.d.ts +3 -3
- package/dist/transport.js +4 -4
- package/dist/types-VYjJcTip.d.cts +161 -0
- package/dist/types-VYjJcTip.d.cts.map +1 -0
- package/dist/types-VYjJcTip.d.ts +161 -0
- package/dist/types-VYjJcTip.d.ts.map +1 -0
- package/dist/{validation-eXATmgO0.js → validation-BLQ64Dfh.js} +3 -3
- package/dist/validation-BLQ64Dfh.js.map +1 -0
- package/dist/{validation-4w-vDGAi.cjs → validation-CZqtmMLJ.cjs} +3 -3
- package/dist/validation-CZqtmMLJ.cjs.map +1 -0
- package/dist/{wallet-BNKgOXrF.js → wallet-NlZiI4-3.js} +161 -77
- package/dist/wallet-NlZiI4-3.js.map +1 -0
- package/dist/{wallet-7R5M_7h4.cjs → wallet-UvyXtxh5.cjs} +161 -77
- package/dist/wallet-UvyXtxh5.cjs.map +1 -0
- package/dist/wallet.cjs +2 -8
- package/dist/wallet.d.cts +4 -3
- package/dist/wallet.d.ts +4 -3
- package/dist/wallet.js +3 -3
- package/package.json +2 -2
- package/dist/actions-B5-CjpEF.cjs.map +0 -1
- package/dist/actions-C1SMLWO5.js +0 -430
- package/dist/actions-C1SMLWO5.js.map +0 -1
- package/dist/artifact-BM_MVzhL.d.cts.map +0 -1
- package/dist/artifact-BM_MVzhL.d.ts.map +0 -1
- package/dist/client-jOZxB8yW.d.cts +0 -798
- package/dist/client-jOZxB8yW.d.cts.map +0 -1
- package/dist/client-jOZxB8yW.d.ts +0 -798
- package/dist/client-jOZxB8yW.d.ts.map +0 -1
- package/dist/codec-BcK8ASsg.cjs.map +0 -1
- package/dist/codec-Bxlt1gKO.js.map +0 -1
- package/dist/contract-D77iA2iY.js.map +0 -1
- package/dist/contract-DSu2UPPm.cjs.map +0 -1
- package/dist/dev_wallet-CAbOSrak.cjs.map +0 -1
- package/dist/dev_wallet-CU3RpQLm.js.map +0 -1
- package/dist/execution-J5jkXhV1.d.cts.map +0 -1
- package/dist/execution-XJ0iwFaX.d.ts.map +0 -1
- package/dist/index-Bb01ytjJ.d.ts.map +0 -1
- package/dist/index-C3HVRvQd.d.ts.map +0 -1
- package/dist/index-CIHK7Ew9.d.cts +0 -303
- package/dist/index-CIHK7Ew9.d.cts.map +0 -1
- package/dist/index-CIHK7Ew9.d.ts +0 -303
- package/dist/index-CIHK7Ew9.d.ts.map +0 -1
- package/dist/index-CedOvhGY.d.cts.map +0 -1
- package/dist/index-CtjWsAXV.d.cts.map +0 -1
- package/dist/index-CtjZ61tl.d.cts.map +0 -1
- package/dist/index-DeS1S0m-.d.ts.map +0 -1
- package/dist/index-DfmDUk5Y.d.ts.map +0 -1
- package/dist/index-soFVQX9j.d.cts.map +0 -1
- package/dist/readError-CCVlmBhj.cjs +0 -624
- package/dist/readError-CCVlmBhj.cjs.map +0 -1
- package/dist/readError-D1dppovI.js +0 -571
- package/dist/readError-D1dppovI.js.map +0 -1
- package/dist/readViews-DbWELMMq.d.cts +0 -609
- package/dist/readViews-DbWELMMq.d.cts.map +0 -1
- package/dist/readViews-nV3jbpYc.d.ts +0 -609
- package/dist/readViews-nV3jbpYc.d.ts.map +0 -1
- package/dist/sendInvocation-Dsr9ij5P.cjs +0 -661
- package/dist/sendInvocation-Dsr9ij5P.cjs.map +0 -1
- package/dist/sendInvocation-tBmf8haQ.js +0 -505
- package/dist/sendInvocation-tBmf8haQ.js.map +0 -1
- package/dist/transport-5FPeNwuv.cjs +0 -279
- package/dist/transport-5FPeNwuv.cjs.map +0 -1
- package/dist/transport-IrhVlS4w.js +0 -261
- package/dist/transport-IrhVlS4w.js.map +0 -1
- package/dist/validation-4w-vDGAi.cjs.map +0 -1
- package/dist/validation-eXATmgO0.js.map +0 -1
- package/dist/wallet-7R5M_7h4.cjs.map +0 -1
- package/dist/wallet-BNKgOXrF.js.map +0 -1
|
@@ -0,0 +1,1818 @@
|
|
|
1
|
+
import { c as WalletProviderErrorCode } from "./types-VYjJcTip.cjs";
|
|
2
|
+
import { AuthClaim, ContractAddress, ContractEntrypointID, GasAmount, Invocation, NetworkHash } from "@thruputchain/protocol";
|
|
3
|
+
import { ContractArrayType, ContractEnumDef, ContractEnumVariant, ContractExceptionType, ContractField, ContractMethodEffect, ContractMethodEffect as ContractMethodEffect$1, ContractSpec as ContractSpec$1, ContractSpecId, ContractSpecId as ContractSpecId$1, ContractSpecInterface, ContractSpecMethod, ContractSpecString, ContractStructDef, ContractType, ContractTypeDef as ContractTypeDef$1, ContractTypeDefKind, ContractTypeKind, ContractUnionCase, ContractUnionCaseKind, ContractUnionCaseType, ContractUnionDef, ContractVectorType } from "@thruputchain/contract-spec";
|
|
4
|
+
import { XdrCodec } from "@thruputchain/xdr";
|
|
5
|
+
|
|
6
|
+
//#region src/rpc/unsupported.d.ts
|
|
7
|
+
/** An unfamiliar variant is data, never success, absence, or retry permission. */
|
|
8
|
+
declare class UnsupportedRpcValue {
|
|
9
|
+
readonly raw: unknown;
|
|
10
|
+
readonly unsupported = true;
|
|
11
|
+
constructor(raw: unknown);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Check for an {@link UnsupportedRpcValue} without `instanceof`, so a value
|
|
15
|
+
* from another copy of the package, such as the CJS build, also matches.
|
|
16
|
+
*/
|
|
17
|
+
declare function isUnsupportedRpcValue(value: unknown): value is UnsupportedRpcValue;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/rpc/generated.d.ts
|
|
20
|
+
type RpcActiveBlockDriverMode = "instant" | "interval" | "manual" | UnsupportedRpcValue;
|
|
21
|
+
type RpcAdmission = "accepted" | UnsupportedRpcValue;
|
|
22
|
+
type RpcAirdropAttempt = {
|
|
23
|
+
attemptStatus: "pending";
|
|
24
|
+
rawAmount: bigint;
|
|
25
|
+
recipient: RpcBase58_ContractAddress;
|
|
26
|
+
retryAfterSeconds: RpcDecimalU64;
|
|
27
|
+
transactionHash?: RpcTxHash;
|
|
28
|
+
} | {
|
|
29
|
+
attemptStatus: "succeeded";
|
|
30
|
+
blockHeight: bigint;
|
|
31
|
+
execution: RpcAirdropExecution;
|
|
32
|
+
rawAmount: bigint;
|
|
33
|
+
recipient: RpcBase58_ContractAddress;
|
|
34
|
+
transactionHash: RpcTxHash;
|
|
35
|
+
} | UnsupportedRpcValue;
|
|
36
|
+
type RpcAirdropExecution = {
|
|
37
|
+
result: "return";
|
|
38
|
+
returnData: Uint8Array;
|
|
39
|
+
} | UnsupportedRpcValue;
|
|
40
|
+
type RpcAscendingAnchor = {
|
|
41
|
+
kind: "atBeginning";
|
|
42
|
+
} | {
|
|
43
|
+
blockHeight: bigint;
|
|
44
|
+
kind: "atHeight";
|
|
45
|
+
};
|
|
46
|
+
type RpcAssumedAuth = {
|
|
47
|
+
accountNonce: bigint;
|
|
48
|
+
kind: "pubkeySignature";
|
|
49
|
+
pubkeyHash: RpcBase58_PublicKeyHash;
|
|
50
|
+
} | {
|
|
51
|
+
allowedKeys: number;
|
|
52
|
+
kind: "sourceAddress";
|
|
53
|
+
requiredWeight: number;
|
|
54
|
+
};
|
|
55
|
+
type RpcAuthConfiguration = {
|
|
56
|
+
requiredWeight: number;
|
|
57
|
+
signers: RpcAuthSigner[];
|
|
58
|
+
};
|
|
59
|
+
type RpcAuthSigner = {
|
|
60
|
+
keyId: number;
|
|
61
|
+
maxWeight: number;
|
|
62
|
+
publicKey: RpcPublicKey;
|
|
63
|
+
};
|
|
64
|
+
type RpcBalanceResult = {
|
|
65
|
+
address: RpcBase58_ContractAddress;
|
|
66
|
+
rawBalance: bigint;
|
|
67
|
+
stateBlockHeight: bigint;
|
|
68
|
+
};
|
|
69
|
+
type RpcBase58_ContractAddress = Uint8Array;
|
|
70
|
+
type RpcBase58_Ed25519PublicKey = Uint8Array;
|
|
71
|
+
type RpcBase58_PublicKeyHash = Uint8Array;
|
|
72
|
+
type RpcBase58_SHA256Hash = Uint8Array;
|
|
73
|
+
type RpcBase58_ValidatorID = Uint8Array;
|
|
74
|
+
type RpcBlockClock = {
|
|
75
|
+
nextBlockTimepoint: RpcDecimalTimePoint;
|
|
76
|
+
};
|
|
77
|
+
type RpcBlockDriverMode = "instant" | "interval" | "manual";
|
|
78
|
+
type RpcBlockDriverStatus = {
|
|
79
|
+
intervalMilliseconds: RpcDecimalU64;
|
|
80
|
+
mode: RpcActiveBlockDriverMode;
|
|
81
|
+
};
|
|
82
|
+
type RpcBlockInfo = {
|
|
83
|
+
blockHash: RpcBase58_SHA256Hash;
|
|
84
|
+
blockHeight: bigint;
|
|
85
|
+
blockTimepoint: RpcDecimalTimePoint;
|
|
86
|
+
configHash: RpcBase58_SHA256Hash;
|
|
87
|
+
eventsHash: RpcBase58_SHA256Hash;
|
|
88
|
+
networkHash: RpcBase58_SHA256Hash;
|
|
89
|
+
prevBlockHash: RpcBase58_SHA256Hash;
|
|
90
|
+
proposalTxsHash: RpcBase58_SHA256Hash;
|
|
91
|
+
proposer: RpcBase58_ValidatorID;
|
|
92
|
+
protocol: number;
|
|
93
|
+
storageHash: RpcBase58_SHA256Hash;
|
|
94
|
+
txsHash: RpcBase58_SHA256Hash;
|
|
95
|
+
upgrades: Uint8Array[];
|
|
96
|
+
};
|
|
97
|
+
type RpcBlockStart = {
|
|
98
|
+
order: RpcIterationOrder;
|
|
99
|
+
};
|
|
100
|
+
type RpcBlockTimeStep = {
|
|
101
|
+
nextBlockTimepoint: RpcDecimalTimePoint;
|
|
102
|
+
stepNanoseconds?: RpcDecimalU64;
|
|
103
|
+
};
|
|
104
|
+
type RpcChainConfig = {
|
|
105
|
+
execution?: RpcExecutionConfig;
|
|
106
|
+
stated: RpcConfigLimits;
|
|
107
|
+
};
|
|
108
|
+
type RpcChainTip = {
|
|
109
|
+
blockHash: RpcBase58_SHA256Hash;
|
|
110
|
+
blockHeight: bigint;
|
|
111
|
+
};
|
|
112
|
+
type RpcConfigLimits = {
|
|
113
|
+
maxAuthTokenDepth?: number;
|
|
114
|
+
maxAuthTokens?: number;
|
|
115
|
+
maxBytestringLen?: number;
|
|
116
|
+
maxCalldataLen?: number;
|
|
117
|
+
maxContractSizeBytes?: number;
|
|
118
|
+
maxCrossInvokeDepth?: number;
|
|
119
|
+
maxNewContractsPerTx?: number;
|
|
120
|
+
maxReturnBufferLen?: number;
|
|
121
|
+
maxRv32ArtifactVersion?: number;
|
|
122
|
+
maxRv32CodeBytes?: number;
|
|
123
|
+
maxRv32MemoryBytes?: number;
|
|
124
|
+
maxSavepointDepth?: number;
|
|
125
|
+
maxSha256Buffers?: number;
|
|
126
|
+
maxTxGas?: RpcDecimalU64;
|
|
127
|
+
minRv32ArtifactVersion?: number;
|
|
128
|
+
};
|
|
129
|
+
type RpcConflictCode = "exclusiveLock" | "typeMismatch" | "valueMismatch" | "boundsExceeded" | "overflow" | "replayProtection" | "queueConsumer" | "capacityExceeded" | "insufficientFunds" | "other" | UnsupportedRpcValue;
|
|
130
|
+
type RpcConflictDiagnostic = {
|
|
131
|
+
address: RpcBase58_ContractAddress;
|
|
132
|
+
code: RpcConflictCode;
|
|
133
|
+
key: Uint8Array;
|
|
134
|
+
};
|
|
135
|
+
type RpcContractArtifactResult = {
|
|
136
|
+
contractXdr: Uint8Array;
|
|
137
|
+
hash: RpcBase58_SHA256Hash;
|
|
138
|
+
};
|
|
139
|
+
type RpcContractDeployment = {
|
|
140
|
+
contractType: number;
|
|
141
|
+
hash: RpcBase58_SHA256Hash;
|
|
142
|
+
size: number;
|
|
143
|
+
};
|
|
144
|
+
type RpcContractDeploymentResult = {
|
|
145
|
+
address: RpcBase58_ContractAddress;
|
|
146
|
+
deployment: RpcContractDeployment | null;
|
|
147
|
+
stateBlockHeight: bigint;
|
|
148
|
+
};
|
|
149
|
+
type RpcContractRejectCode = "tooMany" | "blobTooLarge" | "notDeployable" | "duplicate" | "malformedArtifact" | "unsupportedFormat" | "unsupportedAbi" | "gasScheduleMismatch" | "memoryTooLarge" | "codeSizeInvalid" | "initialMemoryInvalid" | "digestMismatch" | "invalidProgram" | "other" | UnsupportedRpcValue;
|
|
150
|
+
type RpcDecimalTimePoint = bigint;
|
|
151
|
+
type RpcDecimalU64 = bigint;
|
|
152
|
+
type RpcDescendingAnchor = {
|
|
153
|
+
kind: "atEnd";
|
|
154
|
+
} | {
|
|
155
|
+
blockHeight: bigint;
|
|
156
|
+
kind: "atHeight";
|
|
157
|
+
};
|
|
158
|
+
type RpcEffectiveContract = {
|
|
159
|
+
contract: RpcContractDeployment;
|
|
160
|
+
source: "explicitDeployment";
|
|
161
|
+
} | {
|
|
162
|
+
contract: RpcContractDeployment;
|
|
163
|
+
source: "networkDefault";
|
|
164
|
+
} | UnsupportedRpcValue;
|
|
165
|
+
type RpcEffectiveContractResult = {
|
|
166
|
+
address: RpcBase58_ContractAddress;
|
|
167
|
+
context: RpcInvocationContext;
|
|
168
|
+
selection: RpcEffectiveContract | null;
|
|
169
|
+
stateBlockHeight: bigint;
|
|
170
|
+
};
|
|
171
|
+
type RpcEmittedEvent = {
|
|
172
|
+
address: RpcBase58_ContractAddress;
|
|
173
|
+
data: Uint8Array;
|
|
174
|
+
topics: Uint8Array[];
|
|
175
|
+
};
|
|
176
|
+
type RpcEventFilter = {
|
|
177
|
+
addresses: RpcBase58_ContractAddress[];
|
|
178
|
+
topics?: RpcTopicFilter;
|
|
179
|
+
};
|
|
180
|
+
type RpcEventPage = {
|
|
181
|
+
events: RpcIdentifiedEvent[];
|
|
182
|
+
latestIndexedBlockHeight: bigint;
|
|
183
|
+
nextCursor: string | null;
|
|
184
|
+
oldestIndexedBlockHeight: bigint;
|
|
185
|
+
};
|
|
186
|
+
type RpcExecutionConfig = {
|
|
187
|
+
configHash: RpcBase58_SHA256Hash;
|
|
188
|
+
effectiveLimits: RpcConfigLimits;
|
|
189
|
+
observedTip: RpcChainTip;
|
|
190
|
+
storageCosts: RpcStorageCosts;
|
|
191
|
+
};
|
|
192
|
+
type RpcFailureCause = {
|
|
193
|
+
conflict: RpcConflictDiagnostic;
|
|
194
|
+
kind: "dbConflict";
|
|
195
|
+
} | {
|
|
196
|
+
code: RpcContractRejectCode;
|
|
197
|
+
contractIndex: number;
|
|
198
|
+
kind: "contractRejected";
|
|
199
|
+
} | {
|
|
200
|
+
kind: "other";
|
|
201
|
+
} | UnsupportedRpcValue;
|
|
202
|
+
type RpcFundingSubmission = {
|
|
203
|
+
rawAmount: bigint;
|
|
204
|
+
recipient: RpcBase58_ContractAddress;
|
|
205
|
+
signedTransaction: Uint8Array;
|
|
206
|
+
transactionHash: RpcTxHash;
|
|
207
|
+
};
|
|
208
|
+
type RpcHistoryStart = {
|
|
209
|
+
anchor: RpcAscendingAnchor;
|
|
210
|
+
order: "ascending";
|
|
211
|
+
} | {
|
|
212
|
+
anchor: RpcDescendingAnchor;
|
|
213
|
+
order: "descending";
|
|
214
|
+
};
|
|
215
|
+
type RpcIdentifiedEvent = {
|
|
216
|
+
blockHeight: bigint;
|
|
217
|
+
event: RpcEmittedEvent;
|
|
218
|
+
sequenceNumber: number;
|
|
219
|
+
transactionHash: RpcTxHash;
|
|
220
|
+
};
|
|
221
|
+
type RpcInvocation = {
|
|
222
|
+
address: RpcBase58_ContractAddress;
|
|
223
|
+
assumedAuth?: RpcAssumedAuth;
|
|
224
|
+
calldata: Uint8Array;
|
|
225
|
+
caller?: RpcBase58_ContractAddress;
|
|
226
|
+
entrypoint: Uint8Array;
|
|
227
|
+
gasLimit?: bigint;
|
|
228
|
+
};
|
|
229
|
+
type RpcInvocationContext = "root" | "nested";
|
|
230
|
+
type RpcInvocationOutput = {
|
|
231
|
+
result: "return";
|
|
232
|
+
returnData: Uint8Array;
|
|
233
|
+
} | {
|
|
234
|
+
abortData: Uint8Array;
|
|
235
|
+
result: "abort";
|
|
236
|
+
} | {
|
|
237
|
+
result: "fault";
|
|
238
|
+
} | UnsupportedRpcValue;
|
|
239
|
+
type RpcInvocationResult = {
|
|
240
|
+
events: RpcEmittedEvent[];
|
|
241
|
+
gasUsed: RpcDecimalU64;
|
|
242
|
+
output: RpcInvocationOutput;
|
|
243
|
+
};
|
|
244
|
+
type RpcIterationOrder = "ascending" | "descending";
|
|
245
|
+
type RpcNetworkInfo = {
|
|
246
|
+
networkHash: RpcBase58_SHA256Hash;
|
|
247
|
+
};
|
|
248
|
+
type RpcPendingTransactionCount = {
|
|
249
|
+
count: RpcDecimalU64;
|
|
250
|
+
};
|
|
251
|
+
type RpcProducedBlock = {
|
|
252
|
+
blockHeight: bigint;
|
|
253
|
+
blockTimepoint: RpcDecimalTimePoint;
|
|
254
|
+
};
|
|
255
|
+
type RpcProducedBlocks = {
|
|
256
|
+
blocks: RpcProducedBlock[];
|
|
257
|
+
};
|
|
258
|
+
type RpcPublicKey = {
|
|
259
|
+
key: RpcBase58_Ed25519PublicKey;
|
|
260
|
+
scheme: "ed25519";
|
|
261
|
+
} | {
|
|
262
|
+
scheme: "unknown";
|
|
263
|
+
schemeId: number;
|
|
264
|
+
} | UnsupportedRpcValue;
|
|
265
|
+
type RpcReceiptExecution = {
|
|
266
|
+
result: "return";
|
|
267
|
+
returnData: Uint8Array;
|
|
268
|
+
} | {
|
|
269
|
+
abortData: Uint8Array;
|
|
270
|
+
result: "abort";
|
|
271
|
+
} | {
|
|
272
|
+
result: "fault";
|
|
273
|
+
} | {
|
|
274
|
+
result: "nonDeterministicError";
|
|
275
|
+
} | {
|
|
276
|
+
result: "failedGasSponsorship";
|
|
277
|
+
} | {
|
|
278
|
+
result: "other";
|
|
279
|
+
} | UnsupportedRpcValue;
|
|
280
|
+
type RpcRecentAttemptFailure = {
|
|
281
|
+
attemptBlockHeight: bigint;
|
|
282
|
+
cause: RpcFailureCause;
|
|
283
|
+
};
|
|
284
|
+
type RpcRegisteredAuthResult = {
|
|
285
|
+
address: RpcBase58_ContractAddress;
|
|
286
|
+
configuration: RpcAuthConfiguration | null;
|
|
287
|
+
stateBlockHeight: bigint;
|
|
288
|
+
};
|
|
289
|
+
type RpcSchedulerError = {
|
|
290
|
+
code: number;
|
|
291
|
+
source: RpcSchedulerErrorSource;
|
|
292
|
+
};
|
|
293
|
+
type RpcSchedulerErrorSource = "auth" | "scheduler" | "executor" | "other" | UnsupportedRpcValue;
|
|
294
|
+
type RpcSendTransactionResult = {
|
|
295
|
+
admission: RpcAdmission;
|
|
296
|
+
transactionHash: RpcTxHash;
|
|
297
|
+
};
|
|
298
|
+
type RpcServerLimits = {
|
|
299
|
+
maxCursorBytes: RpcDecimalU64;
|
|
300
|
+
maxEventsPerPage: number;
|
|
301
|
+
maxSimulationCalldataBytes: RpcDecimalU64;
|
|
302
|
+
maxSimulationGas: RpcDecimalU64;
|
|
303
|
+
maxTransactionsPerPage: number;
|
|
304
|
+
simulationBatch?: RpcSimulationBatchLimits;
|
|
305
|
+
};
|
|
306
|
+
type RpcSimulationBatchLimits = {
|
|
307
|
+
maxBackendResponseBytes: number;
|
|
308
|
+
maxCalldataBytes: number;
|
|
309
|
+
maxGas: RpcDecimalU64;
|
|
310
|
+
maxInvocations: number;
|
|
311
|
+
timeoutMs: RpcDecimalU64;
|
|
312
|
+
};
|
|
313
|
+
type RpcSimulationResult = {
|
|
314
|
+
events: RpcEmittedEvent[];
|
|
315
|
+
gasUsed: RpcDecimalU64;
|
|
316
|
+
output: RpcInvocationOutput;
|
|
317
|
+
stateBlockHeight: bigint;
|
|
318
|
+
};
|
|
319
|
+
type RpcSimulationResults = {
|
|
320
|
+
results: RpcInvocationResult[];
|
|
321
|
+
stateBlockHeight: bigint;
|
|
322
|
+
};
|
|
323
|
+
type RpcStorageCosts = {
|
|
324
|
+
authPerKeyCost: RpcDecimalU64;
|
|
325
|
+
balanceCost: RpcDecimalU64;
|
|
326
|
+
baseContractDeploymentCost: RpcDecimalU64;
|
|
327
|
+
baseDataItemCost: RpcDecimalU64;
|
|
328
|
+
bytestringCostPerByte: bigint;
|
|
329
|
+
contractDeploymentCostPerByte: RpcDecimalU64;
|
|
330
|
+
rcqCostPerEntry: RpcDecimalU64;
|
|
331
|
+
replayCacheCostPerEntry: RpcDecimalU64;
|
|
332
|
+
};
|
|
333
|
+
type RpcStorageItem = {
|
|
334
|
+
kind: "nonnegativeInt";
|
|
335
|
+
value: bigint;
|
|
336
|
+
} | {
|
|
337
|
+
bytes: Uint8Array;
|
|
338
|
+
kind: "bytestring";
|
|
339
|
+
} | {
|
|
340
|
+
kind: "authData";
|
|
341
|
+
} | {
|
|
342
|
+
kind: "retrocausalQueue";
|
|
343
|
+
} | {
|
|
344
|
+
kind: "replayCacheEntry";
|
|
345
|
+
} | {
|
|
346
|
+
contractType: number;
|
|
347
|
+
hash: RpcBase58_SHA256Hash;
|
|
348
|
+
kind: "deployedContract";
|
|
349
|
+
size: number;
|
|
350
|
+
} | {
|
|
351
|
+
kind: "unknown";
|
|
352
|
+
typeId: number;
|
|
353
|
+
} | UnsupportedRpcValue;
|
|
354
|
+
type RpcStorageResult = {
|
|
355
|
+
item: RpcStorageItem | null;
|
|
356
|
+
stateBlockHeight: bigint;
|
|
357
|
+
};
|
|
358
|
+
type RpcTopicFilter = {
|
|
359
|
+
topic0?: Uint8Array[];
|
|
360
|
+
topic1?: Uint8Array[];
|
|
361
|
+
topic2?: Uint8Array[];
|
|
362
|
+
};
|
|
363
|
+
type RpcTransactionInputResult = {
|
|
364
|
+
blockHeight: bigint;
|
|
365
|
+
status: "available";
|
|
366
|
+
transactionHash: RpcTxHash;
|
|
367
|
+
transactionXdr: Uint8Array;
|
|
368
|
+
} | {
|
|
369
|
+
status: "unavailable";
|
|
370
|
+
} | UnsupportedRpcValue;
|
|
371
|
+
type RpcTransactionReceipt = {
|
|
372
|
+
blockHeight: bigint;
|
|
373
|
+
events: RpcEmittedEvent[];
|
|
374
|
+
execution: RpcReceiptExecution;
|
|
375
|
+
gasUsed: RpcDecimalU64;
|
|
376
|
+
transactionHash: RpcTxHash;
|
|
377
|
+
};
|
|
378
|
+
type RpcTransactionRef = {
|
|
379
|
+
blockHeight: bigint;
|
|
380
|
+
transactionHash: RpcTxHash;
|
|
381
|
+
};
|
|
382
|
+
type RpcTransactionRefPage = {
|
|
383
|
+
latestIndexedBlockHeight: bigint;
|
|
384
|
+
nextCursor: string | null;
|
|
385
|
+
oldestIndexedBlockHeight: bigint;
|
|
386
|
+
transactions: RpcTransactionRef[];
|
|
387
|
+
};
|
|
388
|
+
type RpcTransactionStatus = {
|
|
389
|
+
recentFailure?: RpcRecentAttemptFailure;
|
|
390
|
+
status: "pending";
|
|
391
|
+
} | {
|
|
392
|
+
blockHeight: bigint;
|
|
393
|
+
status: "committed";
|
|
394
|
+
} | {
|
|
395
|
+
error: RpcSchedulerError;
|
|
396
|
+
recentFailure?: RpcRecentAttemptFailure;
|
|
397
|
+
status: "retry";
|
|
398
|
+
} | {
|
|
399
|
+
error: RpcSchedulerError;
|
|
400
|
+
recentFailure?: RpcRecentAttemptFailure;
|
|
401
|
+
status: "dropped";
|
|
402
|
+
} | {
|
|
403
|
+
attemptBlockHeight: bigint;
|
|
404
|
+
cause: RpcFailureCause;
|
|
405
|
+
status: "recentFailure";
|
|
406
|
+
} | {
|
|
407
|
+
status: "unknown";
|
|
408
|
+
} | {
|
|
409
|
+
status: "other";
|
|
410
|
+
} | UnsupportedRpcValue;
|
|
411
|
+
type RpcTxHash = RpcBase58_SHA256Hash;
|
|
412
|
+
type RpcVersionInfo = {
|
|
413
|
+
bundleManifestDigest?: string;
|
|
414
|
+
commitHash?: string;
|
|
415
|
+
implementation: string;
|
|
416
|
+
platformVersion?: string;
|
|
417
|
+
releaseVersion?: string;
|
|
418
|
+
supportedMethods: string[];
|
|
419
|
+
wireFormat: string;
|
|
420
|
+
};
|
|
421
|
+
interface RpcRequests {
|
|
422
|
+
getVersionInfo: {};
|
|
423
|
+
getNetworkInfo: {};
|
|
424
|
+
getChainTip: {};
|
|
425
|
+
getChainConfig: {};
|
|
426
|
+
getServerLimits: {};
|
|
427
|
+
sendTransaction: {
|
|
428
|
+
signedTransaction: Uint8Array;
|
|
429
|
+
};
|
|
430
|
+
getTransactionStatus: {
|
|
431
|
+
transactionHash: RpcTxHash;
|
|
432
|
+
};
|
|
433
|
+
getTransactionReceipt: {
|
|
434
|
+
transactionHash: RpcTxHash;
|
|
435
|
+
};
|
|
436
|
+
getTransactionInput: {
|
|
437
|
+
transactionHash: RpcTxHash;
|
|
438
|
+
};
|
|
439
|
+
simulateInvocation: {
|
|
440
|
+
address: RpcBase58_ContractAddress;
|
|
441
|
+
calldata: Uint8Array;
|
|
442
|
+
entrypoint: Uint8Array;
|
|
443
|
+
assumedAuth?: RpcAssumedAuth;
|
|
444
|
+
caller?: RpcBase58_ContractAddress;
|
|
445
|
+
gasLimit?: bigint;
|
|
446
|
+
minStateBlockHeight?: bigint;
|
|
447
|
+
};
|
|
448
|
+
simulateInvocations: {
|
|
449
|
+
invocations: RpcInvocation[];
|
|
450
|
+
minStateBlockHeight?: bigint;
|
|
451
|
+
};
|
|
452
|
+
getStorage: {
|
|
453
|
+
address: RpcBase58_ContractAddress;
|
|
454
|
+
key: Uint8Array;
|
|
455
|
+
};
|
|
456
|
+
getBalance: {
|
|
457
|
+
address: RpcBase58_ContractAddress;
|
|
458
|
+
};
|
|
459
|
+
getRegisteredAuth: {
|
|
460
|
+
address: RpcBase58_ContractAddress;
|
|
461
|
+
};
|
|
462
|
+
getContractDeployment: {
|
|
463
|
+
address: RpcBase58_ContractAddress;
|
|
464
|
+
};
|
|
465
|
+
getEffectiveContract: {
|
|
466
|
+
address: RpcBase58_ContractAddress;
|
|
467
|
+
context: RpcInvocationContext;
|
|
468
|
+
};
|
|
469
|
+
getContractArtifact: {
|
|
470
|
+
hash: RpcBase58_SHA256Hash;
|
|
471
|
+
};
|
|
472
|
+
getEvents: {
|
|
473
|
+
filters: RpcEventFilter[];
|
|
474
|
+
limit?: number;
|
|
475
|
+
} & ({
|
|
476
|
+
start: RpcHistoryStart;
|
|
477
|
+
cursor?: never;
|
|
478
|
+
} | {
|
|
479
|
+
cursor: string;
|
|
480
|
+
start?: never;
|
|
481
|
+
});
|
|
482
|
+
getTransactionsByRootAddress: {
|
|
483
|
+
address: RpcBase58_ContractAddress;
|
|
484
|
+
limit?: number;
|
|
485
|
+
} & ({
|
|
486
|
+
start: RpcHistoryStart;
|
|
487
|
+
cursor?: never;
|
|
488
|
+
} | {
|
|
489
|
+
cursor: string;
|
|
490
|
+
start?: never;
|
|
491
|
+
});
|
|
492
|
+
getBlockByHeight: {
|
|
493
|
+
blockHeight: bigint;
|
|
494
|
+
};
|
|
495
|
+
getTransactionsByBlock: {
|
|
496
|
+
blockHeight: bigint;
|
|
497
|
+
limit?: number;
|
|
498
|
+
} & ({
|
|
499
|
+
start: RpcBlockStart;
|
|
500
|
+
cursor?: never;
|
|
501
|
+
} | {
|
|
502
|
+
cursor: string;
|
|
503
|
+
start?: never;
|
|
504
|
+
});
|
|
505
|
+
faucet_requestAirdrop: {
|
|
506
|
+
clientNonce: Uint8Array;
|
|
507
|
+
recipient: RpcBase58_ContractAddress;
|
|
508
|
+
};
|
|
509
|
+
dev_fundAccount: {
|
|
510
|
+
clientNonce: Uint8Array;
|
|
511
|
+
faucet: RpcBase58_ContractAddress;
|
|
512
|
+
rawAmount: bigint;
|
|
513
|
+
recipient: RpcBase58_ContractAddress;
|
|
514
|
+
};
|
|
515
|
+
dev_getPendingTransactionCount: {};
|
|
516
|
+
dev_produceBlock: {
|
|
517
|
+
blockTimepoint?: RpcDecimalTimePoint;
|
|
518
|
+
};
|
|
519
|
+
dev_produceBlocks: {
|
|
520
|
+
count: number;
|
|
521
|
+
intervalNanoseconds?: bigint;
|
|
522
|
+
};
|
|
523
|
+
dev_setNextBlockTimepoint: {
|
|
524
|
+
blockTimepoint: RpcDecimalTimePoint;
|
|
525
|
+
};
|
|
526
|
+
dev_increaseTime: {
|
|
527
|
+
nanoseconds: bigint;
|
|
528
|
+
};
|
|
529
|
+
dev_setBlockTimeStep: {
|
|
530
|
+
stepNanoseconds?: bigint;
|
|
531
|
+
};
|
|
532
|
+
dev_setBlockDriver: {
|
|
533
|
+
mode: RpcBlockDriverMode;
|
|
534
|
+
intervalMilliseconds?: bigint;
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
interface RpcResults {
|
|
538
|
+
getVersionInfo: RpcVersionInfo;
|
|
539
|
+
getNetworkInfo: RpcNetworkInfo;
|
|
540
|
+
getChainTip: RpcChainTip;
|
|
541
|
+
getChainConfig: RpcChainConfig;
|
|
542
|
+
getServerLimits: RpcServerLimits;
|
|
543
|
+
sendTransaction: RpcSendTransactionResult;
|
|
544
|
+
getTransactionStatus: RpcTransactionStatus;
|
|
545
|
+
getTransactionReceipt: RpcTransactionReceipt | null;
|
|
546
|
+
getTransactionInput: RpcTransactionInputResult;
|
|
547
|
+
simulateInvocation: RpcSimulationResult;
|
|
548
|
+
simulateInvocations: RpcSimulationResults;
|
|
549
|
+
getStorage: RpcStorageResult;
|
|
550
|
+
getBalance: RpcBalanceResult;
|
|
551
|
+
getRegisteredAuth: RpcRegisteredAuthResult;
|
|
552
|
+
getContractDeployment: RpcContractDeploymentResult;
|
|
553
|
+
getEffectiveContract: RpcEffectiveContractResult;
|
|
554
|
+
getContractArtifact: RpcContractArtifactResult;
|
|
555
|
+
getEvents: RpcEventPage;
|
|
556
|
+
getTransactionsByRootAddress: RpcTransactionRefPage;
|
|
557
|
+
getBlockByHeight: RpcBlockInfo | null;
|
|
558
|
+
getTransactionsByBlock: RpcTransactionRefPage;
|
|
559
|
+
faucet_requestAirdrop: RpcAirdropAttempt;
|
|
560
|
+
dev_fundAccount: RpcFundingSubmission;
|
|
561
|
+
dev_getPendingTransactionCount: RpcPendingTransactionCount;
|
|
562
|
+
dev_produceBlock: RpcProducedBlock;
|
|
563
|
+
dev_produceBlocks: RpcProducedBlocks;
|
|
564
|
+
dev_setNextBlockTimepoint: RpcBlockClock;
|
|
565
|
+
dev_increaseTime: RpcBlockClock;
|
|
566
|
+
dev_setBlockTimeStep: RpcBlockTimeStep;
|
|
567
|
+
dev_setBlockDriver: RpcBlockDriverStatus;
|
|
568
|
+
}
|
|
569
|
+
type RpcErrorData = {
|
|
570
|
+
kind: "invalidParams";
|
|
571
|
+
path?: string;
|
|
572
|
+
reason?: string;
|
|
573
|
+
} | {
|
|
574
|
+
admission?: "notAttempted" | "rejected" | "unknown";
|
|
575
|
+
error?: {
|
|
576
|
+
code: number;
|
|
577
|
+
source: "auth" | "scheduler" | "executor" | "other" | UnsupportedRpcValue;
|
|
578
|
+
};
|
|
579
|
+
kind: "backendUnavailable";
|
|
580
|
+
retryAfterMs?: bigint;
|
|
581
|
+
serviceCode?: string;
|
|
582
|
+
transactionHash?: Uint8Array;
|
|
583
|
+
} | {
|
|
584
|
+
admission?: "notAttempted" | "rejected" | "unknown";
|
|
585
|
+
kind: "backendTimeout";
|
|
586
|
+
retryAfterMs?: bigint;
|
|
587
|
+
transactionHash?: Uint8Array;
|
|
588
|
+
} | {
|
|
589
|
+
admission?: "notAttempted" | "rejected" | "unknown";
|
|
590
|
+
error?: {
|
|
591
|
+
code: number;
|
|
592
|
+
source: "auth" | "scheduler" | "executor" | "other" | UnsupportedRpcValue;
|
|
593
|
+
};
|
|
594
|
+
kind: "overloaded";
|
|
595
|
+
retryAfterMs?: bigint;
|
|
596
|
+
transactionHash?: Uint8Array;
|
|
597
|
+
} | {
|
|
598
|
+
admission?: "notAttempted" | "rejected" | "unknown";
|
|
599
|
+
kind: "backendDataInvalid";
|
|
600
|
+
observation?: {
|
|
601
|
+
blockHeight: bigint;
|
|
602
|
+
transactionHash: Uint8Array;
|
|
603
|
+
};
|
|
604
|
+
reason?: string;
|
|
605
|
+
transactionHash?: Uint8Array;
|
|
606
|
+
} | {
|
|
607
|
+
admission: "notAttempted";
|
|
608
|
+
detail?: {
|
|
609
|
+
attached: number;
|
|
610
|
+
max: number;
|
|
611
|
+
reason: "tooManyContracts";
|
|
612
|
+
} | {
|
|
613
|
+
index: number;
|
|
614
|
+
maxBytes: number;
|
|
615
|
+
reason: "contractTooLarge";
|
|
616
|
+
sizeBytes: number;
|
|
617
|
+
} | {
|
|
618
|
+
firstIndex: number;
|
|
619
|
+
index: number;
|
|
620
|
+
reason: "duplicateContract";
|
|
621
|
+
} | {
|
|
622
|
+
index: number;
|
|
623
|
+
maxBytes: number;
|
|
624
|
+
memoryBytes: number;
|
|
625
|
+
reason: "rv32MemoryTooLarge";
|
|
626
|
+
} | {
|
|
627
|
+
codeBytes: number;
|
|
628
|
+
index: number;
|
|
629
|
+
maxBytes: number;
|
|
630
|
+
reason: "rv32CodeTooLarge";
|
|
631
|
+
} | {
|
|
632
|
+
gasLimit: bigint;
|
|
633
|
+
maxGas: bigint;
|
|
634
|
+
reason: "gasLimitTooHigh";
|
|
635
|
+
} | UnsupportedRpcValue;
|
|
636
|
+
kind: "transactionInvalid";
|
|
637
|
+
reason?: string;
|
|
638
|
+
transactionHash?: Uint8Array;
|
|
639
|
+
} | {
|
|
640
|
+
admission: "notAttempted" | "rejected";
|
|
641
|
+
error?: {
|
|
642
|
+
code: number;
|
|
643
|
+
source: "auth" | "scheduler" | "executor" | "other" | UnsupportedRpcValue;
|
|
644
|
+
};
|
|
645
|
+
kind: "transactionRejected";
|
|
646
|
+
reason?: string;
|
|
647
|
+
transactionHash?: Uint8Array;
|
|
648
|
+
} | {
|
|
649
|
+
kind: "stateHeightUnavailable";
|
|
650
|
+
observedStateBlockHeight: bigint;
|
|
651
|
+
requestedStateBlockHeight: bigint;
|
|
652
|
+
} | {
|
|
653
|
+
hash: Uint8Array;
|
|
654
|
+
kind: "contractArtifactUnavailable";
|
|
655
|
+
} | {
|
|
656
|
+
kind: "invalidCursor";
|
|
657
|
+
path?: string;
|
|
658
|
+
reason?: string;
|
|
659
|
+
} | {
|
|
660
|
+
kind: "historyUnavailable";
|
|
661
|
+
latestIndexedBlockHeight?: bigint;
|
|
662
|
+
oldestIndexedBlockHeight?: bigint;
|
|
663
|
+
reason?: string;
|
|
664
|
+
} | {
|
|
665
|
+
receipt?: {
|
|
666
|
+
blockHeight: bigint;
|
|
667
|
+
events: {
|
|
668
|
+
address: Uint8Array;
|
|
669
|
+
data: Uint8Array;
|
|
670
|
+
topics: Uint8Array[];
|
|
671
|
+
}[];
|
|
672
|
+
execution: {
|
|
673
|
+
result: "return";
|
|
674
|
+
returnData: Uint8Array;
|
|
675
|
+
} | {
|
|
676
|
+
abortData: Uint8Array;
|
|
677
|
+
result: "abort";
|
|
678
|
+
} | {
|
|
679
|
+
result: "fault";
|
|
680
|
+
} | {
|
|
681
|
+
result: "nonDeterministicError";
|
|
682
|
+
} | {
|
|
683
|
+
result: "failedGasSponsorship";
|
|
684
|
+
} | {
|
|
685
|
+
result: "other";
|
|
686
|
+
} | UnsupportedRpcValue;
|
|
687
|
+
gasUsed: bigint;
|
|
688
|
+
transactionHash: Uint8Array;
|
|
689
|
+
};
|
|
690
|
+
serviceCode?: string;
|
|
691
|
+
signedTransaction?: Uint8Array;
|
|
692
|
+
transactionHash?: Uint8Array;
|
|
693
|
+
kind: "fundingAttemptStopped";
|
|
694
|
+
} | {
|
|
695
|
+
cause?: {
|
|
696
|
+
receipt?: {
|
|
697
|
+
blockHeight: bigint;
|
|
698
|
+
events: {
|
|
699
|
+
address: Uint8Array;
|
|
700
|
+
data: Uint8Array;
|
|
701
|
+
topics: Uint8Array[];
|
|
702
|
+
}[];
|
|
703
|
+
execution: {
|
|
704
|
+
result: "return";
|
|
705
|
+
returnData: Uint8Array;
|
|
706
|
+
} | {
|
|
707
|
+
abortData: Uint8Array;
|
|
708
|
+
result: "abort";
|
|
709
|
+
} | {
|
|
710
|
+
result: "fault";
|
|
711
|
+
} | {
|
|
712
|
+
result: "nonDeterministicError";
|
|
713
|
+
} | {
|
|
714
|
+
result: "failedGasSponsorship";
|
|
715
|
+
} | {
|
|
716
|
+
result: "other";
|
|
717
|
+
} | UnsupportedRpcValue;
|
|
718
|
+
gasUsed: bigint;
|
|
719
|
+
transactionHash: Uint8Array;
|
|
720
|
+
};
|
|
721
|
+
serviceCode?: string;
|
|
722
|
+
signedTransaction?: Uint8Array;
|
|
723
|
+
transactionHash?: Uint8Array;
|
|
724
|
+
kind: "fundingAttemptStopped";
|
|
725
|
+
};
|
|
726
|
+
kind: "localFundingUnresolved";
|
|
727
|
+
signedTransaction: Uint8Array;
|
|
728
|
+
transactionHash: Uint8Array;
|
|
729
|
+
};
|
|
730
|
+
//#endregion
|
|
731
|
+
//#region src/types/rpc.d.ts
|
|
732
|
+
type AuthPublicKey = RpcPublicKey;
|
|
733
|
+
type AuthSigner = RpcAuthSigner;
|
|
734
|
+
type AddressAuthDataInfo = RpcAuthConfiguration;
|
|
735
|
+
type RegisteredAuthResult = RpcRegisteredAuthResult;
|
|
736
|
+
type NetworkInfo = RpcNetworkInfo;
|
|
737
|
+
type NetworkConfigParams = RpcConfigLimits;
|
|
738
|
+
type ChainConfig = RpcChainConfig;
|
|
739
|
+
type ExecutionConfig = RpcExecutionConfig;
|
|
740
|
+
type StorageCosts = RpcStorageCosts;
|
|
741
|
+
type SimulationBatchLimits = RpcSimulationBatchLimits;
|
|
742
|
+
type ServerLimits = RpcServerLimits;
|
|
743
|
+
type AirdropAttemptRequest = RpcRequests["faucet_requestAirdrop"];
|
|
744
|
+
type AirdropExecutionStatus = RpcAirdropExecution;
|
|
745
|
+
type AirdropPending = Extract<RpcAirdropAttempt, {
|
|
746
|
+
attemptStatus: "pending";
|
|
747
|
+
}>;
|
|
748
|
+
type AirdropSucceeded = Extract<RpcAirdropAttempt, {
|
|
749
|
+
attemptStatus: "succeeded";
|
|
750
|
+
}>;
|
|
751
|
+
type AirdropResponse = RpcAirdropAttempt;
|
|
752
|
+
type ChainTip = RpcChainTip;
|
|
753
|
+
type BalanceResponse = RpcBalanceResult;
|
|
754
|
+
type BlockInfo = RpcBlockInfo;
|
|
755
|
+
type VersionInfo = RpcVersionInfo;
|
|
756
|
+
/** Prepared descriptor reads retain .view conveniences while using native invocation shapes. */
|
|
757
|
+
type ViewCall = RpcInvocation;
|
|
758
|
+
type ViewRequest = RpcRequests["simulateInvocation"];
|
|
759
|
+
type ViewBatchRequest = RpcRequests["simulateInvocations"];
|
|
760
|
+
type ViewBatchResponse = RpcSimulationResults;
|
|
761
|
+
type ViewOutput = RpcInvocationOutput;
|
|
762
|
+
type ViewResponse = RpcSimulationResult;
|
|
763
|
+
type TransactionStatus = RpcTransactionStatus;
|
|
764
|
+
type SchedulerTransactionError = RpcSchedulerError;
|
|
765
|
+
type TransactionFailureCause = RpcFailureCause;
|
|
766
|
+
/** Best-effort failed-attempt evidence; it need not describe the current scheduler attempt. */
|
|
767
|
+
type RecentAttemptFailure = RpcRecentAttemptFailure;
|
|
768
|
+
type ContractRejectCode = RpcContractRejectCode;
|
|
769
|
+
type ConflictCode = RpcConflictCode;
|
|
770
|
+
type ConflictDiagnostic = RpcConflictDiagnostic;
|
|
771
|
+
type TransactionRef = RpcTransactionRef;
|
|
772
|
+
type TransactionRefPage = RpcTransactionRefPage;
|
|
773
|
+
type TransactionReceipt = RpcTransactionReceipt;
|
|
774
|
+
type EmittedEvent = RpcEmittedEvent;
|
|
775
|
+
type IdentifiedEvent = RpcIdentifiedEvent;
|
|
776
|
+
type EventPage = RpcEventPage;
|
|
777
|
+
type EventFilter = RpcEventFilter;
|
|
778
|
+
type HistoryStart = RpcHistoryStart;
|
|
779
|
+
type IterationOrder = RpcIterationOrder;
|
|
780
|
+
type EventQuery = RpcRequests["getEvents"];
|
|
781
|
+
type BlockTransactionQuery = RpcRequests["getTransactionsByBlock"];
|
|
782
|
+
type RootAddressTransactionQuery = RpcRequests["getTransactionsByRootAddress"];
|
|
783
|
+
type StorageItemInfo = RpcStorageItem;
|
|
784
|
+
type StorageItemRead = RpcStorageResult;
|
|
785
|
+
type FundAccountRequest = RpcRequests["dev_fundAccount"];
|
|
786
|
+
type FundAccountResponse = RpcFundingSubmission;
|
|
787
|
+
//#endregion
|
|
788
|
+
//#region src/actions/public/waitForTransactionReceipt.d.ts
|
|
789
|
+
interface KnownCommitment {
|
|
790
|
+
readonly networkHash: Uint8Array;
|
|
791
|
+
readonly transactionHash: Uint8Array;
|
|
792
|
+
readonly blockHeight: bigint;
|
|
793
|
+
}
|
|
794
|
+
interface WaitForTransactionReceiptOptions {
|
|
795
|
+
signal?: AbortSignal;
|
|
796
|
+
/** Verified before each observation; omission uses discovery's validated network. */
|
|
797
|
+
expectedNetworkHash?: Uint8Array;
|
|
798
|
+
knownCommitment?: KnownCommitment;
|
|
799
|
+
/** Observed status, including optional advisory attempt diagnostics. Never retry permission. */
|
|
800
|
+
onStatus?: (status: TransactionStatus) => void;
|
|
801
|
+
timeoutMs?: number;
|
|
802
|
+
pollingIntervalMs?: number;
|
|
803
|
+
}
|
|
804
|
+
/** Read-only capabilities used by commitment and receipt observation. */
|
|
805
|
+
type ReceiptObserver = Pick<RpcClient, "getNetworkInfo" | "getTransactionReceipt" | "getTransactionStatus" | "discovery" | "requireMethods">;
|
|
806
|
+
/**
|
|
807
|
+
* Return any committed receipt, including failed execution. Never sign or resubmit.
|
|
808
|
+
* When observation stops, throws code `transactionOutcomeUnknown` with
|
|
809
|
+
* `transaction.reason` set to why it stopped.
|
|
810
|
+
*/
|
|
811
|
+
declare function waitForTransactionReceipt(client: ReceiptObserver, transactionHash: Uint8Array, options?: WaitForTransactionReceiptOptions): Promise<TransactionReceipt>;
|
|
812
|
+
/** Observe commitment independently of receipt availability or execution success. */
|
|
813
|
+
declare function waitForCommitment(client: ReceiptObserver, transactionHash: Uint8Array, options?: WaitForTransactionReceiptOptions): Promise<KnownCommitment>;
|
|
814
|
+
//#endregion
|
|
815
|
+
//#region src/cluster.d.ts
|
|
816
|
+
/** Public Thruput Futurenet JSON-RPC endpoint. */
|
|
817
|
+
declare const FUTURENET_RPC_URL = "https://rpc.thruput.network";
|
|
818
|
+
/** @deprecated Use {@link FUTURENET_RPC_URL}. */
|
|
819
|
+
declare const DEVNET_RPC_URL = "https://rpc.thruput.network";
|
|
820
|
+
/** Default JSON-RPC endpoint for `thruput node`. */
|
|
821
|
+
declare const LOCALNET_RPC_URL = "http://127.0.0.1:9545";
|
|
822
|
+
/** Optional feature exposed by a Thruput cluster. */
|
|
823
|
+
type ClusterCapability = "airdrop";
|
|
824
|
+
/** Network identity and optional features expected at an RPC endpoint. */
|
|
825
|
+
interface Cluster<TCapabilities extends readonly ClusterCapability[] = readonly ClusterCapability[]> {
|
|
826
|
+
/** Optional human-readable cluster name. */
|
|
827
|
+
readonly name?: string;
|
|
828
|
+
/** Optional protocol network identity pin. */
|
|
829
|
+
readonly networkHash?: NetworkHash;
|
|
830
|
+
/** Default JSON-RPC endpoint, when the cluster has one. */
|
|
831
|
+
readonly rpcUrl?: string;
|
|
832
|
+
/** Optional RPC features expected to be available on the cluster. */
|
|
833
|
+
readonly capabilities: TCapabilities;
|
|
834
|
+
}
|
|
835
|
+
/** Whether every possible cluster descriptor declares an optional feature. */
|
|
836
|
+
type ClusterHasCapability<TCluster extends Cluster, TCapability extends ClusterCapability> = false extends (TCluster extends Cluster<infer TCapabilities> ? TCapabilities extends readonly ClusterCapability[] ? number extends TCapabilities["length"] ? false : TCapability extends TCapabilities[number] ? true : false : false : false) ? false : true;
|
|
837
|
+
/** Options shared by predefined cluster descriptors. */
|
|
838
|
+
interface PredefinedClusterOptions {
|
|
839
|
+
/** Override the cluster's default JSON-RPC endpoint. */
|
|
840
|
+
readonly rpcUrl?: string;
|
|
841
|
+
/** Pin the endpoint to one protocol signing network. */
|
|
842
|
+
readonly networkHash?: NetworkHash;
|
|
843
|
+
}
|
|
844
|
+
/** Define a reusable cluster while preserving its literal capability types. */
|
|
845
|
+
declare function defineCluster<const TCluster extends Cluster>(cluster: TCluster & {
|
|
846
|
+
readonly genesisHash?: never;
|
|
847
|
+
}): TCluster;
|
|
848
|
+
/** Define the canonical Thruput mainnet cluster. */
|
|
849
|
+
declare function mainnet(options?: PredefinedClusterOptions): Cluster<readonly []> & {
|
|
850
|
+
readonly name: "mainnet";
|
|
851
|
+
};
|
|
852
|
+
/** Define Futurenet, the resettable public development network, unpinned unless `networkHash` is supplied. */
|
|
853
|
+
declare function futurenet(options?: PredefinedClusterOptions): Cluster<readonly ["airdrop"]> & {
|
|
854
|
+
readonly name: "futurenet";
|
|
855
|
+
};
|
|
856
|
+
/**
|
|
857
|
+
* Compatibility alias for {@link futurenet}, retaining the legacy cluster name.
|
|
858
|
+
* @deprecated Use {@link futurenet}.
|
|
859
|
+
*/
|
|
860
|
+
declare function devnet(options?: PredefinedClusterOptions): Cluster<readonly ["airdrop"]> & {
|
|
861
|
+
readonly name: "devnet";
|
|
862
|
+
};
|
|
863
|
+
/** Define a local `thruput node` development network. */
|
|
864
|
+
declare function localnet(options?: PredefinedClusterOptions): Cluster<readonly ["airdrop"]> & {
|
|
865
|
+
readonly name: "localnet";
|
|
866
|
+
};
|
|
867
|
+
/** Assert that runtime network information matches a cluster descriptor. Throws code `networkMismatch`. */
|
|
868
|
+
declare function assertNetworkMatchesCluster(cluster: Cluster, actual: NetworkInfo): void;
|
|
869
|
+
//#endregion
|
|
870
|
+
//#region src/transport/types.d.ts
|
|
871
|
+
/**
|
|
872
|
+
* Minimal JSON-RPC transport contract used by all SDK actions.
|
|
873
|
+
*
|
|
874
|
+
* Implement this interface to plug the SDK into a custom runtime, test harness,
|
|
875
|
+
* or request pipeline. The transport is responsible for sending a JSON-RPC
|
|
876
|
+
* method name and named params object, then returning the raw decoded `result` value.
|
|
877
|
+
*
|
|
878
|
+
* Report failures with `ThruputError`, imported from `@thruputchain/client`, so
|
|
879
|
+
* native clients can classify them:
|
|
880
|
+
*
|
|
881
|
+
* - A JSON-RPC error object: code `rpcError`, with the complete object in
|
|
882
|
+
* `context.raw`. Without `raw`, the client rebuilds it from `code`,
|
|
883
|
+
* `rpcMessage`, and `data`.
|
|
884
|
+
* - A network failure: code `httpRequestFailed`.
|
|
885
|
+
* - A failed HTTP status: code `httpResponseError`.
|
|
886
|
+
* - A malformed reply: code `rpcResponseInvalid`.
|
|
887
|
+
*
|
|
888
|
+
* For cancellation, reject with `options.signal.reason` unchanged. For a
|
|
889
|
+
* deadline, reject with a `DOMException` named `TimeoutError`. The client passes
|
|
890
|
+
* any other value through unchanged and does not classify it, so a transaction
|
|
891
|
+
* that fails that way has outcome `unknown`.
|
|
892
|
+
*
|
|
893
|
+
* @example
|
|
894
|
+
* ```ts
|
|
895
|
+
* throw new ThruputError("rpcError", "getChainTip: Overloaded (RPC -32053)", {
|
|
896
|
+
* context: { code: -32053, rpcMessage: "Overloaded", method: "getChainTip", raw },
|
|
897
|
+
* });
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
interface Transport {
|
|
901
|
+
/**
|
|
902
|
+
* Send one JSON-RPC request and return the decoded `result` value.
|
|
903
|
+
*
|
|
904
|
+
* @typeParam T - Expected JSON-RPC result type before action-level parsing.
|
|
905
|
+
*/
|
|
906
|
+
request<T = unknown>(method: string, params?: RpcParams, options?: TransportRequestOptions): Promise<T>;
|
|
907
|
+
}
|
|
908
|
+
/** Per-request transport controls supported by built-in transports. */
|
|
909
|
+
interface TransportRequestOptions {
|
|
910
|
+
/**
|
|
911
|
+
* Cancel this request without affecting other requests on the same transport.
|
|
912
|
+
* Public reads accept these options as their final argument; generated view
|
|
913
|
+
* methods accept signal alongside their contract arguments.
|
|
914
|
+
*/
|
|
915
|
+
readonly signal?: AbortSignal;
|
|
916
|
+
}
|
|
917
|
+
/** Named native parameters; arrays remain accepted by the general JSON-RPC transport. */
|
|
918
|
+
type RpcParams = Record<string, unknown> | unknown[];
|
|
919
|
+
//#endregion
|
|
920
|
+
//#region src/actions/public/readViews.d.ts
|
|
921
|
+
/** Typed calls and an optional minimum committed height for one snapshot read. */
|
|
922
|
+
interface ReadViewsRequest<TCalls extends readonly ContractViewRequest[]> {
|
|
923
|
+
calls: TCalls;
|
|
924
|
+
minStateBlockHeight?: bigint;
|
|
925
|
+
}
|
|
926
|
+
/** Ordered typed outcomes, preserving each tuple position's return and exception types. */
|
|
927
|
+
interface ReadViewsResponse<TCalls extends readonly ContractViewRequest[]> {
|
|
928
|
+
stateBlockHeight: bigint;
|
|
929
|
+
results: { [K in keyof TCalls]: TCalls[K] extends ContractViewRequest<infer R, infer E> ? ContractViewOutcome<R, ContractException<E>> : never };
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Read generated method requests against one shared committed snapshot.
|
|
933
|
+
* Contract aborts and faults are outcomes. Transport, freshness, and decoding
|
|
934
|
+
* failures reject the group. Calls are never split or emulated with separate views.
|
|
935
|
+
*
|
|
936
|
+
* @example
|
|
937
|
+
* ```ts
|
|
938
|
+
* const result = await client.readViews({ calls: [
|
|
939
|
+
* ERC20.v0_1.totalSupply.viewRequest({ address: token }),
|
|
940
|
+
* ERC20.v0_1.getBalanceOf.viewRequest({ address: token, args: { addr: owner } }),
|
|
941
|
+
* ] });
|
|
942
|
+
* ```
|
|
943
|
+
*/
|
|
944
|
+
declare function readViews<const TCalls extends readonly ContractViewRequest[]>(client: Pick<RpcClient, "simulateInvocations">, request: ReadViewsRequest<TCalls>, options?: TransportRequestOptions): Promise<ReadViewsResponse<TCalls>>;
|
|
945
|
+
//#endregion
|
|
946
|
+
//#region src/contract/spec.d.ts
|
|
947
|
+
/**
|
|
948
|
+
* Lookup key for a named type: every segment of its spec id.
|
|
949
|
+
*
|
|
950
|
+
* Two types with the same declared name in different crates or modules are
|
|
951
|
+
* distinct, so named-codec maps from {@link buildNamedCodecs} are keyed by
|
|
952
|
+
* this rather than by `declared` alone. The encoding is injective; use
|
|
953
|
+
* {@link formatSpecId} for anything a person reads.
|
|
954
|
+
*/
|
|
955
|
+
declare function specIdKey(id: ContractSpecId): string;
|
|
956
|
+
/**
|
|
957
|
+
* Render a spec id for diagnostics as `module_path::declared (crate@major)`,
|
|
958
|
+
* the shape the Thruput CLI and spec tool print.
|
|
959
|
+
*/
|
|
960
|
+
declare function formatSpecId(id: Readonly<Record<keyof ContractSpecId, string>>): string;
|
|
961
|
+
//#endregion
|
|
962
|
+
//#region src/contract/codec.d.ts
|
|
963
|
+
/** Complete-input codec used by generated contract descriptors. */
|
|
964
|
+
interface ContractCodec<T> {
|
|
965
|
+
encode(value: T): Uint8Array;
|
|
966
|
+
decode(data: Uint8Array): T;
|
|
967
|
+
}
|
|
968
|
+
declare const contractCodecContextBrand: unique symbol;
|
|
969
|
+
/** Opaque named-codec context shared by one generated binding module. */
|
|
970
|
+
interface ContractCodecContext {
|
|
971
|
+
readonly [contractCodecContextBrand]: true;
|
|
972
|
+
}
|
|
973
|
+
/** Build the shared codec context for a generated binding module. */
|
|
974
|
+
declare function createContractCodecContext(typeDefs: readonly ContractTypeDef$1[]): ContractCodecContext;
|
|
975
|
+
//#endregion
|
|
976
|
+
//#region src/contract/event.d.ts
|
|
977
|
+
/** A generic event decoded from contract metadata. Hashed topics remain hashes. */
|
|
978
|
+
type SpecDecodedEvent = DecodedContractEvent<string, Record<string, unknown>, Record<string, unknown>>;
|
|
979
|
+
/**
|
|
980
|
+
* Build a decoder from a parsed spec using the same codecs as generated bindings.
|
|
981
|
+
* Unknown signatures return null; malformed known events throw. The caller must
|
|
982
|
+
* establish that this spec belongs to the contract that emitted the event.
|
|
983
|
+
*/
|
|
984
|
+
declare function createContractEventDecoder(spec: ContractSpec$1): (event: Pick<EmittedEvent, "topics" | "data">) => SpecDecodedEvent | null;
|
|
985
|
+
/** Ordered metadata for one declared event topic after the signature. */
|
|
986
|
+
interface ContractEventTopicMetadata {
|
|
987
|
+
name: string;
|
|
988
|
+
type: ContractType;
|
|
989
|
+
representation: "address" | "fixedBytes32" | "u32" | "u64" | "u128" | "u256" | "i32" | "i64" | "i128" | "i256" | "bool" | "hash";
|
|
990
|
+
}
|
|
991
|
+
/** Ordered metadata for one event payload field. */
|
|
992
|
+
interface ContractEventFieldMetadata {
|
|
993
|
+
name: string;
|
|
994
|
+
type: ContractType;
|
|
995
|
+
}
|
|
996
|
+
/** Runtime definition consumed by a generated event descriptor. */
|
|
997
|
+
interface ContractEventDefinition<TName extends string = string> {
|
|
998
|
+
name: TName;
|
|
999
|
+
signature: Uint8Array;
|
|
1000
|
+
topics: readonly ContractEventTopicMetadata[];
|
|
1001
|
+
fields: readonly ContractEventFieldMetadata[];
|
|
1002
|
+
codecs: ContractCodecContext;
|
|
1003
|
+
}
|
|
1004
|
+
/** One accepted direct-topic value or a non-empty OR constraint. */
|
|
1005
|
+
type ContractEventFilterValue<T> = T | {
|
|
1006
|
+
oneOf: readonly [T, ...T[]];
|
|
1007
|
+
};
|
|
1008
|
+
/** Generated named topic constraints plus required emitter addresses. */
|
|
1009
|
+
interface ContractEventFilterInput<TFilter> {
|
|
1010
|
+
addresses: readonly ContractAddress[];
|
|
1011
|
+
topics?: TFilter;
|
|
1012
|
+
}
|
|
1013
|
+
/** Emitter scope for receipt extraction. */
|
|
1014
|
+
interface ContractEventReceiptOptions {
|
|
1015
|
+
address: ContractAddress;
|
|
1016
|
+
}
|
|
1017
|
+
/** Canonical value returned by generated event decoders. */
|
|
1018
|
+
interface DecodedContractEvent<TName extends string, TTopics, TFields> {
|
|
1019
|
+
name: TName;
|
|
1020
|
+
topics: TTopics;
|
|
1021
|
+
fields: TFields;
|
|
1022
|
+
}
|
|
1023
|
+
/** Decoded receipt event retaining the emitting contract address. */
|
|
1024
|
+
type ContractReceiptEvent<TName extends string, TTopics, TFields> = DecodedContractEvent<TName, TTopics, TFields> & {
|
|
1025
|
+
address: ContractAddress;
|
|
1026
|
+
};
|
|
1027
|
+
/** Complete generated event API. */
|
|
1028
|
+
interface ContractEvent<TName extends string, TTopics, TFields, TFilter> {
|
|
1029
|
+
readonly signature: Uint8Array;
|
|
1030
|
+
decode(event: Pick<EmittedEvent, "topics" | "data">): DecodedContractEvent<TName, TTopics, TFields> | null;
|
|
1031
|
+
filter(input: ContractEventFilterInput<TFilter>): EventFilter;
|
|
1032
|
+
allFromReceipt(receipt: Pick<TransactionReceipt, "events">, options: ContractEventReceiptOptions): ContractReceiptEvent<TName, TTopics, TFields>[];
|
|
1033
|
+
singleFromReceipt(receipt: Pick<TransactionReceipt, "events">, options: ContractEventReceiptOptions): ContractReceiptEvent<TName, TTopics, TFields>;
|
|
1034
|
+
}
|
|
1035
|
+
/** Build one generated event descriptor from direct ABI metadata. */
|
|
1036
|
+
declare function defineContractEvent<const TName extends string, TTopics, TFields, TFilter>(definition: ContractEventDefinition<TName>): ContractEvent<TName, TTopics, TFields, TFilter>;
|
|
1037
|
+
/** Distinguish directly encoded indexed values from irreversible topic hashes. */
|
|
1038
|
+
declare function topicRepresentation(type: ContractType): ContractEventTopicMetadata["representation"];
|
|
1039
|
+
/** Compare public byte identifiers. This function is not constant-time. */
|
|
1040
|
+
declare function bytesEqual(left: Uint8Array | undefined, right: Uint8Array): boolean;
|
|
1041
|
+
//#endregion
|
|
1042
|
+
//#region src/actions/public/getContractEvents.d.ts
|
|
1043
|
+
/** One generated event descriptor with named filters and ordinary page controls. */
|
|
1044
|
+
type ContractEventQuery<TName extends string, TTopics, TFields, TFilter> = (EventQuery extends infer Q ? Q extends EventQuery ? Omit<Q, "filters"> : never : never) & ContractEventFilterInput<NoInfer<TFilter>> & {
|
|
1045
|
+
event: ContractEvent<TName, TTopics, TFields, TFilter>;
|
|
1046
|
+
};
|
|
1047
|
+
/** A decoded event with its emitter, transaction, and position in history. */
|
|
1048
|
+
type IdentifiedContractEvent<TName extends string, TTopics, TFields> = DecodedContractEvent<TName, TTopics, TFields> & Omit<IdentifiedEvent, "event"> & Pick<EmittedEvent, "address">;
|
|
1049
|
+
/** One decoded event page, retaining the RPC cursor and indexer bounds. */
|
|
1050
|
+
type ContractEventPage<TName extends string, TTopics, TFields> = Omit<EventPage, "events"> & {
|
|
1051
|
+
events: IdentifiedContractEvent<TName, TTopics, TFields>[];
|
|
1052
|
+
};
|
|
1053
|
+
/**
|
|
1054
|
+
* Fetch exactly one page using a generated event's filter and decoder.
|
|
1055
|
+
*
|
|
1056
|
+
* No additional pages are fetched. Pass the returned cursor into the next call
|
|
1057
|
+
* with the same filters. Malformed events and unexpected signatures throw
|
|
1058
|
+
* code `contractDecodeFailed` rather than silently disappearing from the page.
|
|
1059
|
+
*
|
|
1060
|
+
* @example
|
|
1061
|
+
* ```ts
|
|
1062
|
+
* const page = await getContractEvents(client, {
|
|
1063
|
+
* event: thruput_erc20_if.v0_1.events.TransferEvent,
|
|
1064
|
+
* addresses: [tokenAddress],
|
|
1065
|
+
* topics: { to: accountAddress },
|
|
1066
|
+
* start: { order: "ascending", anchor: { kind: "atBeginning" } },
|
|
1067
|
+
* limit: 20,
|
|
1068
|
+
* }, { signal });
|
|
1069
|
+
* ```
|
|
1070
|
+
*/
|
|
1071
|
+
declare function getContractEvents<TName extends string, TTopics, TFields, TFilter>(client: Pick<RpcClient, "getEvents">, query: ContractEventQuery<TName, TTopics, TFields, TFilter>, options?: TransportRequestOptions): Promise<ContractEventPage<TName, TTopics, TFields>>;
|
|
1072
|
+
//#endregion
|
|
1073
|
+
//#region src/actions/public/historyWalk.d.ts
|
|
1074
|
+
/** Returned only after the caller resumes past the terminal page. Persist with processed data. */
|
|
1075
|
+
interface HistoryCompletion {
|
|
1076
|
+
readonly watermarkBlockHeight: bigint;
|
|
1077
|
+
/** Ascending range fully consumed; absent for descending or an anchor above the watermark. */
|
|
1078
|
+
readonly completedThroughBlockHeight?: bigint;
|
|
1079
|
+
}
|
|
1080
|
+
//#endregion
|
|
1081
|
+
//#region src/actions/public/iterateTransactionPages.d.ts
|
|
1082
|
+
type RootAddressWalkQuery = Extract<RootAddressTransactionQuery, {
|
|
1083
|
+
start: unknown;
|
|
1084
|
+
}>;
|
|
1085
|
+
type BlockTransactionWalkQuery = Extract<BlockTransactionQuery, {
|
|
1086
|
+
start: unknown;
|
|
1087
|
+
}>;
|
|
1088
|
+
/** Transactions sent by this root address; incoming transfers use token events. */
|
|
1089
|
+
declare function iterateTransactionsByRootAddress(client: Pick<RpcClient, "getTransactionsByRootAddress">, query: RootAddressWalkQuery, options?: TransportRequestOptions): AsyncGenerator<TransactionRefPage, HistoryCompletion, unknown>;
|
|
1090
|
+
/** Walk one covered block. Completion never establishes a whole-chain checkpoint. */
|
|
1091
|
+
declare function iterateTransactionsByBlock(client: Pick<RpcClient, "getTransactionsByBlock">, query: BlockTransactionWalkQuery, options?: TransportRequestOptions): AsyncGenerator<TransactionRefPage, void, unknown>;
|
|
1092
|
+
//#endregion
|
|
1093
|
+
//#region src/actions/public/iterateEventPages.d.ts
|
|
1094
|
+
type EventWalkQuery = Extract<EventQuery, {
|
|
1095
|
+
start: unknown;
|
|
1096
|
+
}>;
|
|
1097
|
+
/** Start a fixed event range. Saved opaque cursors remain available through getEvents. */
|
|
1098
|
+
declare function iterateEventPages(client: Pick<RpcClient, "getEvents">, query: EventWalkQuery, options?: TransportRequestOptions): AsyncGenerator<EventPage, HistoryCompletion, unknown>;
|
|
1099
|
+
//#endregion
|
|
1100
|
+
//#region src/client.d.ts
|
|
1101
|
+
/** Native RPC methods plus workflows that never sign, replace or repeat writes. */
|
|
1102
|
+
interface CoreThruputClient extends RpcClient {
|
|
1103
|
+
iterateTransactionsByRootAddress(query: RootAddressWalkQuery, options?: TransportRequestOptions): AsyncGenerator<TransactionRefPage, HistoryCompletion, unknown>;
|
|
1104
|
+
iterateTransactionsByBlock(query: BlockTransactionWalkQuery, options?: TransportRequestOptions): AsyncGenerator<TransactionRefPage, void, unknown>;
|
|
1105
|
+
waitForTransactionReceipt(transactionHash: Uint8Array, options?: WaitForTransactionReceiptOptions): Promise<TransactionReceipt>;
|
|
1106
|
+
waitForCommitment(transactionHash: Uint8Array, options?: WaitForTransactionReceiptOptions): Promise<KnownCommitment>;
|
|
1107
|
+
readViews<const TCalls extends readonly ContractViewRequest[]>(request: ReadViewsRequest<TCalls>, options?: TransportRequestOptions): Promise<ReadViewsResponse<TCalls>>;
|
|
1108
|
+
getContractEvents<TName extends string, TTopics, TFields, TFilter>(query: ContractEventQuery<TName, TTopics, TFields, TFilter>, options?: TransportRequestOptions): Promise<ContractEventPage<TName, TTopics, TFields>>;
|
|
1109
|
+
iterateEventPages(query: EventWalkQuery, options?: TransportRequestOptions): AsyncGenerator<EventPage, HistoryCompletion, unknown>;
|
|
1110
|
+
}
|
|
1111
|
+
/** Optional one-call faucet workflow, gated by endpoint discovery. */
|
|
1112
|
+
interface AirdropActions {
|
|
1113
|
+
requestAirdrop(options: RequestAirdropOptions): Promise<AirdropSucceeded>;
|
|
1114
|
+
requestAirdropAttempt(request: AirdropAttemptRequest, options?: TransportRequestOptions): Promise<AirdropResponse>;
|
|
1115
|
+
}
|
|
1116
|
+
interface ThruputClient extends CoreThruputClient, AirdropActions {}
|
|
1117
|
+
type ConnectedThruputClient<TCluster extends Cluster = Cluster> = CoreThruputClient & {
|
|
1118
|
+
readonly cluster: TCluster & {
|
|
1119
|
+
readonly genesisHash?: never;
|
|
1120
|
+
};
|
|
1121
|
+
readonly network: NetworkInfo;
|
|
1122
|
+
} & (ClusterHasCapability<TCluster, "airdrop"> extends true ? AirdropActions : {});
|
|
1123
|
+
interface ThruputClientOptions {
|
|
1124
|
+
readonly transport: Transport;
|
|
1125
|
+
readonly cluster?: never;
|
|
1126
|
+
readonly requiredMethods?: readonly RpcMethod[];
|
|
1127
|
+
readonly signal?: AbortSignal;
|
|
1128
|
+
}
|
|
1129
|
+
interface ClusterThruputClientOptions<TCluster extends Cluster = Cluster> {
|
|
1130
|
+
readonly cluster: TCluster & {
|
|
1131
|
+
readonly genesisHash?: never;
|
|
1132
|
+
};
|
|
1133
|
+
readonly transport?: Transport;
|
|
1134
|
+
readonly requiredMethods?: readonly RpcMethod[];
|
|
1135
|
+
readonly signal?: AbortSignal;
|
|
1136
|
+
}
|
|
1137
|
+
/** Connect once, validate wire/network/capabilities, and bind native methods and workflows. */
|
|
1138
|
+
declare function createThruputClient<const TCluster extends Cluster>(options: ClusterThruputClientOptions<TCluster>): Promise<ConnectedThruputClient<TCluster>>;
|
|
1139
|
+
declare function createThruputClient(options: ThruputClientOptions): Promise<ThruputClient>;
|
|
1140
|
+
//#endregion
|
|
1141
|
+
//#region src/contract/method.d.ts
|
|
1142
|
+
/** Omit the argument position entirely for methods without arguments. */
|
|
1143
|
+
type MethodArgs<TArgs> = [TArgs] extends [void] ? [] : [args: TArgs];
|
|
1144
|
+
/** Successfully decoded contract view result and its snapshot metadata. */
|
|
1145
|
+
interface ContractView<T> {
|
|
1146
|
+
value: T;
|
|
1147
|
+
stateBlockHeight: bigint;
|
|
1148
|
+
gasUsed: bigint;
|
|
1149
|
+
events: EmittedEvent[];
|
|
1150
|
+
}
|
|
1151
|
+
/** Contract exception selector not declared by the generated interface. */
|
|
1152
|
+
interface UnknownContractException {
|
|
1153
|
+
kind: "unknown";
|
|
1154
|
+
selector: bigint;
|
|
1155
|
+
data: Uint8Array;
|
|
1156
|
+
}
|
|
1157
|
+
/** Declared exceptions plus a lossless fallback for unknown selectors. */
|
|
1158
|
+
type ContractException<TDeclared> = (TDeclared & {
|
|
1159
|
+
/** Symbolic enum case when available in the contract spec. */variant?: string;
|
|
1160
|
+
}) | UnknownContractException;
|
|
1161
|
+
/** Non-successful contract view outcome. */
|
|
1162
|
+
type ContractViewFailure<TException> = {
|
|
1163
|
+
kind: "unsupported";
|
|
1164
|
+
raw: ViewResponse;
|
|
1165
|
+
stateBlockHeight: bigint;
|
|
1166
|
+
gasUsed: bigint;
|
|
1167
|
+
events: EmittedEvent[];
|
|
1168
|
+
} | {
|
|
1169
|
+
kind: "abort";
|
|
1170
|
+
exception: TException;
|
|
1171
|
+
abortData: Uint8Array;
|
|
1172
|
+
stateBlockHeight: bigint;
|
|
1173
|
+
gasUsed: bigint;
|
|
1174
|
+
events: EmittedEvent[];
|
|
1175
|
+
} | {
|
|
1176
|
+
kind: "fault";
|
|
1177
|
+
stateBlockHeight: bigint;
|
|
1178
|
+
gasUsed: bigint;
|
|
1179
|
+
events: EmittedEvent[];
|
|
1180
|
+
};
|
|
1181
|
+
/** Typed return, abort, fault, or unsupported response from a contract view. */
|
|
1182
|
+
type ContractViewOutcome<TResult, TException> = ({
|
|
1183
|
+
kind: "return";
|
|
1184
|
+
} & ContractView<TResult>) | ContractViewFailure<TException>;
|
|
1185
|
+
/** Successfully decoded root return and its commitment metadata. */
|
|
1186
|
+
interface ContractReceipt<TResult> {
|
|
1187
|
+
value: TResult;
|
|
1188
|
+
transactionHash: Uint8Array;
|
|
1189
|
+
blockHeight: bigint;
|
|
1190
|
+
events: EmittedEvent[];
|
|
1191
|
+
}
|
|
1192
|
+
type ContractReceiptFailure<TException> = {
|
|
1193
|
+
transactionHash: Uint8Array;
|
|
1194
|
+
blockHeight: bigint;
|
|
1195
|
+
events: EmittedEvent[];
|
|
1196
|
+
} & ({
|
|
1197
|
+
kind: "abort";
|
|
1198
|
+
exception: TException;
|
|
1199
|
+
abortData: Uint8Array;
|
|
1200
|
+
} | {
|
|
1201
|
+
kind: "failure";
|
|
1202
|
+
execution: TransactionReceipt["execution"];
|
|
1203
|
+
} | {
|
|
1204
|
+
kind: "unsupported";
|
|
1205
|
+
raw: TransactionReceipt;
|
|
1206
|
+
});
|
|
1207
|
+
type ContractReceiptOutcome<TResult, TException> = ({
|
|
1208
|
+
kind: "return";
|
|
1209
|
+
} & ContractReceipt<TResult>) | ContractReceiptFailure<TException>;
|
|
1210
|
+
/** A typed failure that {@link ContractMethod.decodeError} reads from an error. */
|
|
1211
|
+
type ContractFailure<TException> = ContractViewFailure<TException> | ContractReceiptFailure<TException>;
|
|
1212
|
+
/** Generated method argument metadata in ABI order. */
|
|
1213
|
+
interface ContractArgumentMetadata {
|
|
1214
|
+
abiName: string;
|
|
1215
|
+
publicName: string;
|
|
1216
|
+
type: ContractType;
|
|
1217
|
+
}
|
|
1218
|
+
/** Generated declared exception metadata. */
|
|
1219
|
+
interface ContractExceptionMetadata {
|
|
1220
|
+
selector: bigint;
|
|
1221
|
+
name: string | null;
|
|
1222
|
+
type: ContractType;
|
|
1223
|
+
}
|
|
1224
|
+
/** Runtime definition consumed by a generated method descriptor. */
|
|
1225
|
+
interface ContractMethodDefinition {
|
|
1226
|
+
/** Author-declared whole-invocation effects; null or omission means unannotated. */
|
|
1227
|
+
effect?: ContractMethodEffect | null;
|
|
1228
|
+
/** Canonical interface name for diagnostics. */
|
|
1229
|
+
interfaceName?: string;
|
|
1230
|
+
/** Interface ABI version, not a deployed-code verification. */
|
|
1231
|
+
interfaceVersion?: string;
|
|
1232
|
+
/** Method name in the contract ABI. */
|
|
1233
|
+
abiName?: string;
|
|
1234
|
+
/** Method name in the TypeScript binding. */
|
|
1235
|
+
publicName?: string;
|
|
1236
|
+
entrypoint: ContractEntrypointID;
|
|
1237
|
+
args: readonly ContractArgumentMetadata[];
|
|
1238
|
+
returnType: ContractType;
|
|
1239
|
+
throws: readonly ContractExceptionMetadata[];
|
|
1240
|
+
codecs: ContractCodecContext;
|
|
1241
|
+
}
|
|
1242
|
+
/** Contract address and arguments shared by reads and transaction calls. */
|
|
1243
|
+
type ContractMethodInputs<TArgs> = {
|
|
1244
|
+
address: ContractAddress;
|
|
1245
|
+
} & ([TArgs] extends [void] ? {
|
|
1246
|
+
args?: never;
|
|
1247
|
+
} : {
|
|
1248
|
+
args: TArgs;
|
|
1249
|
+
});
|
|
1250
|
+
/** View options with an argument object only when the method requires one. */
|
|
1251
|
+
type ContractViewOptions<TArgs> = ContractMethodInputs<TArgs> & {
|
|
1252
|
+
/** Optional authorization assumed by the simulator, without signatures. */assumedAuth?: AuthClaim;
|
|
1253
|
+
client: Pick<ThruputClient, "simulateInvocation">;
|
|
1254
|
+
caller?: ContractAddress;
|
|
1255
|
+
/**
|
|
1256
|
+
* Minimum committed snapshot height. The SDK does not wait or retry. From
|
|
1257
|
+
* wire 14.6.1, the server waits up to 2 s for a floor at or below the
|
|
1258
|
+
* committed tip.
|
|
1259
|
+
*/
|
|
1260
|
+
minStateBlockHeight?: bigint; /** Cancel this read without affecting other requests on the same client. */
|
|
1261
|
+
signal?: AbortSignal;
|
|
1262
|
+
};
|
|
1263
|
+
/** Inputs to a typed, unsubmitted contract call. */
|
|
1264
|
+
type ContractCallOptions<TArgs> = ContractMethodInputs<TArgs> & {
|
|
1265
|
+
gasLimit: GasAmount;
|
|
1266
|
+
minStateBlockHeight?: never;
|
|
1267
|
+
};
|
|
1268
|
+
/** Inputs for an unsubmitted view, with arguments checked by the generated method. */
|
|
1269
|
+
type ContractViewRequestOptions<TArgs> = ContractMethodInputs<TArgs> & {
|
|
1270
|
+
assumedAuth?: AuthClaim;
|
|
1271
|
+
caller?: ContractAddress;
|
|
1272
|
+
minStateBlockHeight?: never;
|
|
1273
|
+
};
|
|
1274
|
+
/** Encoded view request retaining its generated outcome decoder. */
|
|
1275
|
+
interface ContractViewRequest<TResult = unknown, TException = unknown> {
|
|
1276
|
+
readonly minStateBlockHeight?: never;
|
|
1277
|
+
readonly request: ViewCall & {
|
|
1278
|
+
minStateBlockHeight?: never;
|
|
1279
|
+
};
|
|
1280
|
+
readonly method: Pick<ContractMethod<never, TResult, TException>, "name" | "decodeViewOutcome">;
|
|
1281
|
+
}
|
|
1282
|
+
/** An invocation retaining its return and exception decoders. */
|
|
1283
|
+
interface ContractCall<TResult = unknown, TException = unknown> {
|
|
1284
|
+
readonly invocation: Invocation;
|
|
1285
|
+
readonly method: Pick<ContractMethod<never, TResult, TException>, "decodeReturn" | "decodeException" | "decodeReceiptOutcome" | "name">;
|
|
1286
|
+
}
|
|
1287
|
+
/** Complete generated method API. */
|
|
1288
|
+
interface ContractMethod<TArgs, TResult, TDeclaredException> {
|
|
1289
|
+
/**
|
|
1290
|
+
* Author-declared effects, including nested calls. Pure excludes state/context
|
|
1291
|
+
* reads; read-only excludes application effects (including events); state-changing
|
|
1292
|
+
* means effects may occur. Null means unannotated and gives no read-only assurance.
|
|
1293
|
+
* These declarations are not compiler/runtime enforced and never restrict
|
|
1294
|
+
* invocation or view APIs.
|
|
1295
|
+
*/
|
|
1296
|
+
readonly effect: ContractMethodEffect | null;
|
|
1297
|
+
/** Qualified method name, or entrypoint when generated identity is absent. */
|
|
1298
|
+
readonly name: string;
|
|
1299
|
+
/** Prepare an independent read for readViews without performing I/O. */
|
|
1300
|
+
viewRequest(options: ContractViewRequestOptions<TArgs>): ContractViewRequest<TResult, TDeclaredException>;
|
|
1301
|
+
/** Build an unsubmitted call retaining typed decoding context. */
|
|
1302
|
+
call(options: ContractCallOptions<TArgs>): ContractCall<TResult, TDeclaredException>;
|
|
1303
|
+
readonly entrypoint: ContractEntrypointID;
|
|
1304
|
+
invocation(contract: ContractAddress, gasLimit: GasAmount, ...args: MethodArgs<TArgs>): Invocation;
|
|
1305
|
+
/**
|
|
1306
|
+
* Decode complete calldata using the generated public argument names.
|
|
1307
|
+
* Returns undefined for no-argument methods; rejects incomplete or trailing bytes.
|
|
1308
|
+
* Select the descriptor after checking the invocation's entrypoint. ABI decoding
|
|
1309
|
+
* does not verify the target contract's behavior.
|
|
1310
|
+
*
|
|
1311
|
+
* @example
|
|
1312
|
+
* ```ts
|
|
1313
|
+
* const { receiver, amount } = ERC20.v0_1.transfer.decodeArgs(invocation.calldata);
|
|
1314
|
+
* ```
|
|
1315
|
+
*/
|
|
1316
|
+
decodeArgs(data: Uint8Array): TArgs;
|
|
1317
|
+
/** Decode complete return data; reject incomplete or trailing bytes. */
|
|
1318
|
+
decodeReturn(data: Uint8Array): TResult;
|
|
1319
|
+
/** Decode abort data, preserving an unknown selector and its complete payload. */
|
|
1320
|
+
decodeException(data: Uint8Array): ContractException<TDeclaredException>;
|
|
1321
|
+
/** Decode a view response with the same semantics as view(). */
|
|
1322
|
+
decodeView(response: ViewResponse): ContractView<TResult>;
|
|
1323
|
+
/** Decode return, abort, fault, or unsupported data without throwing for a contract failure. */
|
|
1324
|
+
decodeViewOutcome(response: ViewResponse): ContractViewOutcome<TResult, ContractException<TDeclaredException>>;
|
|
1325
|
+
/**
|
|
1326
|
+
* Decode a receipt whose root invocation called this method; nested invocation
|
|
1327
|
+
* results are not inspected. A failed execution throws `contractCallFailed`;
|
|
1328
|
+
* an undecodable successful return throws `transactionResultUndecodable`.
|
|
1329
|
+
*/
|
|
1330
|
+
decodeReceipt(receipt: TransactionReceipt): ContractReceipt<TResult>;
|
|
1331
|
+
/**
|
|
1332
|
+
* Decode the outcome of a root invocation of this method; nested invocation
|
|
1333
|
+
* results are not inspected. An undecodable successful return throws
|
|
1334
|
+
* `transactionResultUndecodable`; malformed abort data throws
|
|
1335
|
+
* `contractDecodeFailed` with the receipt's `transaction` facts.
|
|
1336
|
+
*/
|
|
1337
|
+
decodeReceiptOutcome(receipt: TransactionReceipt): ContractReceiptOutcome<TResult, ContractException<TDeclaredException>>;
|
|
1338
|
+
/**
|
|
1339
|
+
* Read this method's typed failure from an error that `view`, `decodeView`, or
|
|
1340
|
+
* `decodeReceipt` threw (codes `contractViewFailed` and `contractCallFailed`).
|
|
1341
|
+
* Returns undefined for other errors, including failures of other methods.
|
|
1342
|
+
*
|
|
1343
|
+
* @example
|
|
1344
|
+
* ```ts
|
|
1345
|
+
* try {
|
|
1346
|
+
* await token.transfer.view({ client, address, args });
|
|
1347
|
+
* } catch (error) {
|
|
1348
|
+
* const failure = token.transfer.decodeError(error);
|
|
1349
|
+
* if (failure?.kind === "abort") console.log(failure.exception);
|
|
1350
|
+
* }
|
|
1351
|
+
* ```
|
|
1352
|
+
*/
|
|
1353
|
+
decodeError(error: unknown): ContractFailure<ContractException<TDeclaredException>> | undefined;
|
|
1354
|
+
view(options: ContractViewOptions<TArgs>): Promise<ContractView<TResult>>;
|
|
1355
|
+
viewOutcome(options: ContractViewOptions<TArgs>): Promise<ContractViewOutcome<TResult, ContractException<TDeclaredException>>>;
|
|
1356
|
+
}
|
|
1357
|
+
/** Build one generated method descriptor from direct ABI metadata. */
|
|
1358
|
+
declare function defineContractMethod<TArgs, TResult, TDeclaredException>(definition: ContractMethodDefinition): ContractMethod<TArgs, TResult, TDeclaredException>;
|
|
1359
|
+
//#endregion
|
|
1360
|
+
//#region src/errors/codes.d.ts
|
|
1361
|
+
/** Fields shared by JSON-RPC error contexts. */
|
|
1362
|
+
interface RpcErrorFields {
|
|
1363
|
+
/** JSON-RPC numeric error code. */
|
|
1364
|
+
readonly code: number;
|
|
1365
|
+
/** The `message` field of the JSON-RPC error object. */
|
|
1366
|
+
readonly rpcMessage: string;
|
|
1367
|
+
/** The `data` field of the JSON-RPC error object, when present. */
|
|
1368
|
+
readonly data?: unknown;
|
|
1369
|
+
/** JSON-RPC method of the failed request, when known. */
|
|
1370
|
+
readonly method?: string;
|
|
1371
|
+
/** Complete original JSON-RPC error object, including additive fields. */
|
|
1372
|
+
readonly raw: unknown;
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* A native RPC error. Narrow on `kind` to read typed `data`. The kind
|
|
1376
|
+
* `unrecognized` means the error was unknown, malformed, or contradicted the
|
|
1377
|
+
* request; `raw` keeps the complete original error.
|
|
1378
|
+
*/
|
|
1379
|
+
type NativeRpcErrorContext = Omit<RpcErrorFields, "data"> & {
|
|
1380
|
+
readonly method: string;
|
|
1381
|
+
} & ((RpcErrorData extends infer TData ? TData extends {
|
|
1382
|
+
kind: infer TKind;
|
|
1383
|
+
} ? {
|
|
1384
|
+
readonly kind: TKind;
|
|
1385
|
+
readonly data: TData;
|
|
1386
|
+
} : never : never) | {
|
|
1387
|
+
readonly kind: "unrecognized";
|
|
1388
|
+
readonly data?: undefined;
|
|
1389
|
+
});
|
|
1390
|
+
/**
|
|
1391
|
+
* What an `rpcIncompatible` error found:
|
|
1392
|
+
*
|
|
1393
|
+
* - `network`: the endpoint serves another network than the one expected.
|
|
1394
|
+
* - `method`: the endpoint does not advertise a method that the call needs.
|
|
1395
|
+
* - `wireVersion`: the endpoint uses an RPC wire format this client cannot read.
|
|
1396
|
+
* - `limits`: the endpoint does not advertise limits that the call needs.
|
|
1397
|
+
* - `commitment`: commitment heights for one transaction do not agree.
|
|
1398
|
+
*/
|
|
1399
|
+
type RpcIncompatibleKind = "network" | "method" | "wireVersion" | "limits" | "commitment";
|
|
1400
|
+
/** The app-layer context of a wallet provider error. */
|
|
1401
|
+
interface WalletErrorContext {
|
|
1402
|
+
/** The EIP-1193-style numeric code from the wallet provider wire contract. */
|
|
1403
|
+
readonly providerCode: WalletProviderErrorCode;
|
|
1404
|
+
}
|
|
1405
|
+
/** Context for errors that stop observation of a transaction. */
|
|
1406
|
+
interface TransactionOutcomeUnknownContext {
|
|
1407
|
+
/** Commitment that the client proved before it stopped, when known. */
|
|
1408
|
+
readonly knownCommitment?: KnownCommitment;
|
|
1409
|
+
/** The last status the node reported, when known. */
|
|
1410
|
+
readonly lastStatus?: TransactionStatus;
|
|
1411
|
+
/** The submission failure, when observation continued after it. */
|
|
1412
|
+
readonly submissionError?: unknown;
|
|
1413
|
+
}
|
|
1414
|
+
/** Context for {@link ThruputErrorContext.fundingStopped}. */
|
|
1415
|
+
interface FundingStoppedContext {
|
|
1416
|
+
readonly request: {
|
|
1417
|
+
readonly recipient: Uint8Array; /** Use the same nonce to reconcile this attempt. A new nonce can fund twice. */
|
|
1418
|
+
readonly clientNonce: Uint8Array;
|
|
1419
|
+
readonly networkHash: Uint8Array;
|
|
1420
|
+
};
|
|
1421
|
+
/** The last faucet response, when the faucet answered. */
|
|
1422
|
+
readonly lastResponse?: AirdropResponse;
|
|
1423
|
+
/** Commitment that the client proved before it stopped, when known. */
|
|
1424
|
+
readonly knownCommitment?: KnownCommitment;
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* The context type for each error code. Each property name is a code.
|
|
1428
|
+
*
|
|
1429
|
+
* Codes are stable. The client never renames or reuses a code, and never removes
|
|
1430
|
+
* a context field. It can add codes and optional fields.
|
|
1431
|
+
*
|
|
1432
|
+
* Codes use camelCase, like the native RPC error kinds. Node.js and ethers use
|
|
1433
|
+
* UPPER_SNAKE; this client keeps one style for all of its string unions.
|
|
1434
|
+
*
|
|
1435
|
+
* A code names its subject first, then what happened, for example
|
|
1436
|
+
* `transactionFailed` or `rpcValueInvalid`. When a code reports a term from a
|
|
1437
|
+
* standard, it keeps that term: `rpcError` is a JSON-RPC error object, and
|
|
1438
|
+
* `walletInvalidParams` is the JSON-RPC "Invalid params" error (-32602).
|
|
1439
|
+
*
|
|
1440
|
+
* Other packages can add codes through declaration merging:
|
|
1441
|
+
*
|
|
1442
|
+
* @example
|
|
1443
|
+
* ```ts
|
|
1444
|
+
* declare module "@thruputchain/client" {
|
|
1445
|
+
* interface ThruputErrorContext {
|
|
1446
|
+
* testkitRunFailed: { readonly step: string };
|
|
1447
|
+
* }
|
|
1448
|
+
* }
|
|
1449
|
+
* ```
|
|
1450
|
+
*/
|
|
1451
|
+
interface ThruputErrorContext {
|
|
1452
|
+
/** The receipt shows failed execution. Outcome `failed`. */
|
|
1453
|
+
transactionFailed: Record<string, never>;
|
|
1454
|
+
/** The receipt has an execution value this client does not support. Outcome `unknown`. */
|
|
1455
|
+
transactionOutcomeUnsupported: Record<string, never>;
|
|
1456
|
+
/** Execution succeeded, but its return data did not decode. Outcome `succeeded`. */
|
|
1457
|
+
transactionResultUndecodable: Record<string, never>;
|
|
1458
|
+
/** Execution succeeded, but the wallet does not keep child return data. Outcome `succeeded`. */
|
|
1459
|
+
transactionResultUnavailable: Record<string, never>;
|
|
1460
|
+
/** The client did not dispatch the signed transaction. Outcome `notSubmitted`. */
|
|
1461
|
+
transactionNotSubmitted: Record<string, never>;
|
|
1462
|
+
/**
|
|
1463
|
+
* Submission or observation stopped before the client knew the outcome.
|
|
1464
|
+
* Outcome `unknown`. Never resend; observe `transaction.hash`.
|
|
1465
|
+
*/
|
|
1466
|
+
transactionOutcomeUnknown: TransactionOutcomeUnknownContext;
|
|
1467
|
+
/** Submission returned an admission value this client does not support. Outcome `unknown`. */
|
|
1468
|
+
transactionAdmissionUnsupported: {
|
|
1469
|
+
readonly response: RpcSendTransactionResult;
|
|
1470
|
+
};
|
|
1471
|
+
/**
|
|
1472
|
+
* A faucet request stopped. `transaction` is present when the faucet
|
|
1473
|
+
* identified a transaction. Never call the faucet with a new nonce
|
|
1474
|
+
* automatically; reconcile with `context.request.clientNonce`. If the node
|
|
1475
|
+
* stopped the attempt but returned a successful receipt, the facts have
|
|
1476
|
+
* outcome `succeeded` and reason `nodeRejected`.
|
|
1477
|
+
*/
|
|
1478
|
+
fundingStopped: FundingStoppedContext;
|
|
1479
|
+
/** The endpoint returned a JSON-RPC error object. */
|
|
1480
|
+
rpcError: RpcErrorFields;
|
|
1481
|
+
/** A native RPC method returned an error. Narrow on `context.kind`. */
|
|
1482
|
+
nativeRpcError: NativeRpcErrorContext;
|
|
1483
|
+
/** The HTTP response had a status that is not successful. */
|
|
1484
|
+
httpResponseError: {
|
|
1485
|
+
readonly status: number;
|
|
1486
|
+
readonly statusText: string;
|
|
1487
|
+
readonly endpoint?: string;
|
|
1488
|
+
readonly method?: string;
|
|
1489
|
+
};
|
|
1490
|
+
/** The HTTP request failed in the network layer. The endpoint is the URL origin only. */
|
|
1491
|
+
httpRequestFailed: {
|
|
1492
|
+
readonly endpoint: string;
|
|
1493
|
+
readonly method: string;
|
|
1494
|
+
};
|
|
1495
|
+
/** The JSON-RPC reply was malformed. The write outcome of the request is unknown. */
|
|
1496
|
+
rpcResponseInvalid: {
|
|
1497
|
+
readonly raw: unknown;
|
|
1498
|
+
};
|
|
1499
|
+
/** A known RPC result value was malformed. */
|
|
1500
|
+
rpcValueInvalid: {
|
|
1501
|
+
readonly path: string;
|
|
1502
|
+
readonly raw: unknown;
|
|
1503
|
+
};
|
|
1504
|
+
/** A local RPC request value was invalid. The transport was not called. */
|
|
1505
|
+
rpcRequestInvalid: {
|
|
1506
|
+
readonly path: string;
|
|
1507
|
+
};
|
|
1508
|
+
/**
|
|
1509
|
+
* The endpoint, network, or method set does not match what the client
|
|
1510
|
+
* requires. Narrow on `context.kind`: for example, `network` means the
|
|
1511
|
+
* endpoint serves another network than the one expected. This is what
|
|
1512
|
+
* `createThruputClient` throws when a pinned cluster's network does not match.
|
|
1513
|
+
*/
|
|
1514
|
+
rpcIncompatible: {
|
|
1515
|
+
readonly kind: RpcIncompatibleKind;
|
|
1516
|
+
};
|
|
1517
|
+
/** The endpoint returned a value this client does not support. */
|
|
1518
|
+
rpcValueUnsupported: {
|
|
1519
|
+
readonly value: UnsupportedRpcValue;
|
|
1520
|
+
};
|
|
1521
|
+
/**
|
|
1522
|
+
* The network that you pass to `assertNetworkMatchesCluster` does not match
|
|
1523
|
+
* the cluster descriptor. `createThruputClient` reports a pinned network that
|
|
1524
|
+
* does not match as `rpcIncompatible` with `context.kind` `network`.
|
|
1525
|
+
*/
|
|
1526
|
+
networkMismatch: {
|
|
1527
|
+
readonly cluster: Cluster;
|
|
1528
|
+
readonly actual: NetworkInfo;
|
|
1529
|
+
};
|
|
1530
|
+
/** A contract view aborted, faulted, or returned an unsupported outcome. */
|
|
1531
|
+
contractViewFailed: {
|
|
1532
|
+
/** Qualified method name. */readonly method: string;
|
|
1533
|
+
readonly entrypoint: Uint8Array;
|
|
1534
|
+
readonly outcome: ContractViewFailure<unknown>;
|
|
1535
|
+
};
|
|
1536
|
+
/**
|
|
1537
|
+
* A root contract receipt did not produce a typed return. Has
|
|
1538
|
+
* `transaction` facts. Use the method's `decodeError` for the typed exception.
|
|
1539
|
+
* When the receipt shows success but the return is unsupported, the facts are
|
|
1540
|
+
* outcome `succeeded` with reason `resultUndecodable`.
|
|
1541
|
+
*/
|
|
1542
|
+
contractCallFailed: {
|
|
1543
|
+
/** Qualified method name. */readonly method: string;
|
|
1544
|
+
readonly entrypoint: Uint8Array;
|
|
1545
|
+
readonly outcome: ContractReceiptFailure<unknown>;
|
|
1546
|
+
};
|
|
1547
|
+
/** Contract bytes do not match their declared type. */
|
|
1548
|
+
contractDecodeFailed: Record<string, never>;
|
|
1549
|
+
/** Retrieved bytes or response metadata failed identity or canonical checks. */
|
|
1550
|
+
contractVerificationFailed: Record<string, never>;
|
|
1551
|
+
/** Provider code 4001: the user rejected the request. */
|
|
1552
|
+
userRejected: WalletErrorContext;
|
|
1553
|
+
/** Provider code 4100: unauthorized origin or account, stale session, or no matching approval. */
|
|
1554
|
+
walletUnauthorized: WalletErrorContext;
|
|
1555
|
+
/** Provider code 4200: the provider does not support the method. */
|
|
1556
|
+
walletMethodUnsupported: WalletErrorContext;
|
|
1557
|
+
/** Provider code 4900: the provider is disconnected or its transport is unavailable. */
|
|
1558
|
+
walletDisconnected: WalletErrorContext;
|
|
1559
|
+
/** Provider code 4901: the wallet network does not match. */
|
|
1560
|
+
walletNetworkMismatch: WalletErrorContext;
|
|
1561
|
+
/** Provider code -32602: invalid parameters, noncanonical encoding, or exceeded limits. */
|
|
1562
|
+
walletInvalidParams: WalletErrorContext;
|
|
1563
|
+
/** Provider code -32603: internal error or invalid provider result. */
|
|
1564
|
+
walletInternalError: WalletErrorContext;
|
|
1565
|
+
/** Provider code -32002: another operation is pending. */
|
|
1566
|
+
walletRequestPending: WalletErrorContext;
|
|
1567
|
+
/** `parseUnits` received a malformed amount or too many decimal places. */
|
|
1568
|
+
amountInvalid: {
|
|
1569
|
+
readonly kind: "malformed" | "precision";
|
|
1570
|
+
readonly decimals: number;
|
|
1571
|
+
};
|
|
1572
|
+
/** History pages broke ordering, cursor, or identity rules across pages. */
|
|
1573
|
+
historyWalkFailed: {
|
|
1574
|
+
readonly page: EventPage | TransactionRefPage;
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
/** A stable error code. */
|
|
1578
|
+
type ThruputErrorCode = keyof ThruputErrorContext & string;
|
|
1579
|
+
/**
|
|
1580
|
+
* Codes that always have `transaction` facts. After narrowing to one of these
|
|
1581
|
+
* codes, `error.transaction` is required.
|
|
1582
|
+
*/
|
|
1583
|
+
declare const transactionErrorCodes: readonly ["transactionFailed", "transactionOutcomeUnsupported", "transactionResultUndecodable", "transactionResultUnavailable", "transactionNotSubmitted", "transactionOutcomeUnknown", "transactionAdmissionUnsupported", "contractCallFailed"];
|
|
1584
|
+
/** A code that always has `transaction` facts. */
|
|
1585
|
+
type TransactionErrorCode = (typeof transactionErrorCodes)[number];
|
|
1586
|
+
//#endregion
|
|
1587
|
+
//#region src/transaction/submissionEvidence.d.ts
|
|
1588
|
+
/** Exact signed bytes, their transaction hash, and the signing network. */
|
|
1589
|
+
interface SubmissionEvidence {
|
|
1590
|
+
readonly signedTransaction: Uint8Array;
|
|
1591
|
+
readonly transactionHash: Uint8Array;
|
|
1592
|
+
readonly networkHash: Uint8Array;
|
|
1593
|
+
}
|
|
1594
|
+
/** Snapshot approved bytes before submission; accessor copies protect the retained record. */
|
|
1595
|
+
declare function createSubmissionEvidence(bytes: Uint8Array, network: Uint8Array): SubmissionEvidence;
|
|
1596
|
+
//#endregion
|
|
1597
|
+
//#region src/errors/transaction.d.ts
|
|
1598
|
+
/**
|
|
1599
|
+
* What the client knows about a transaction's execution.
|
|
1600
|
+
*
|
|
1601
|
+
* - `succeeded`: the receipt shows success. The error is about a later step.
|
|
1602
|
+
* - `failed`: the receipt shows failed execution.
|
|
1603
|
+
* - `notSubmitted`: this call did not dispatch the transaction.
|
|
1604
|
+
* - `unknown`: the client cannot know. **Never resend.** Observe `hash` instead.
|
|
1605
|
+
*
|
|
1606
|
+
* `notSubmitted` covers this call only. A request with an explicit nonce and
|
|
1607
|
+
* expiry signs to the same bytes each time, so an earlier call may have sent
|
|
1608
|
+
* them. The provider wallet remembers the hashes it sent and reports `unknown`
|
|
1609
|
+
* for them. The signer wallet does not, because a long-running process would
|
|
1610
|
+
* keep every hash. When you repeat such a request, observe its hash before you
|
|
1611
|
+
* treat it as unsent.
|
|
1612
|
+
*/
|
|
1613
|
+
type TransactionOutcome = (typeof transactionOutcomes)[number];
|
|
1614
|
+
/**
|
|
1615
|
+
* Why the operation stopped. Use it for messages and diagnostics; decide whether
|
|
1616
|
+
* to resend from {@link TransactionOutcome} only. The same reason can occur
|
|
1617
|
+
* with different outcomes: a timeout before dispatch is `notSubmitted`, and a
|
|
1618
|
+
* timeout during observation is `unknown`.
|
|
1619
|
+
*
|
|
1620
|
+
* | Reason | Meaning |
|
|
1621
|
+
* | --- | --- |
|
|
1622
|
+
* | `aborted` | The receipt shows a contract abort. |
|
|
1623
|
+
* | `faulted` | The receipt shows a fault. |
|
|
1624
|
+
* | `executionFailed` | The receipt shows another execution failure. The receipt has the exact result. |
|
|
1625
|
+
* | `resultUndecodable` | Execution succeeded, but its return data did not decode. |
|
|
1626
|
+
* | `resultUnavailable` | Execution succeeded, but the wallet does not keep child return data. |
|
|
1627
|
+
* | `cancelled` | The caller's signal was aborted. |
|
|
1628
|
+
* | `timeout` | The time budget ended. |
|
|
1629
|
+
* | `persistenceFailed` | The `onSigned` callback rejected, so the client did not submit. |
|
|
1630
|
+
* | `notDispatched` | This call did not send the request. With outcome `unknown`, an earlier call may have sent the same bytes. |
|
|
1631
|
+
* | `requestInvalid` | A local request or compatibility check failed before dispatch. |
|
|
1632
|
+
* | `nodeRejected` | The node answered `invalidParams`, `transactionInvalid`, or `transactionRejected`, or stopped a funding attempt. |
|
|
1633
|
+
* | `submissionFailed` | Submission failed in a way that does not prove the node did not receive the transaction. |
|
|
1634
|
+
* | `disconnected` | A transient network or node failure: during submission, or the last read before the time budget ended. |
|
|
1635
|
+
* | `statusUnknown` | The time budget ended, and the node's last status was `unknown` or unsupported. |
|
|
1636
|
+
* | `recentFailure` | The time budget ended, and the node's last status was `recentFailure`. |
|
|
1637
|
+
* | `networkChanged` | The observation endpoint reported a different network. |
|
|
1638
|
+
* | `commitmentConflict` | The node reported two commitment heights for one transaction. |
|
|
1639
|
+
* | `observationFailed` | A permanent read failure or an invalid response stopped observation. |
|
|
1640
|
+
* | `admissionUnsupported` | Submission returned an admission value this client does not support. |
|
|
1641
|
+
* | `outcomeUnsupported` | The receipt has an execution value this client does not support. |
|
|
1642
|
+
*/
|
|
1643
|
+
type TransactionReason = (typeof transactionReasons)[number];
|
|
1644
|
+
/** Every {@link TransactionOutcome}, for example to validate stored values. */
|
|
1645
|
+
declare const transactionOutcomes: readonly ["succeeded", "failed", "notSubmitted", "unknown"];
|
|
1646
|
+
/** Every {@link TransactionReason}, for example to validate stored values. */
|
|
1647
|
+
declare const transactionReasons: readonly ["aborted", "faulted", "executionFailed", "resultUndecodable", "resultUnavailable", "cancelled", "timeout", "persistenceFailed", "notDispatched", "requestInvalid", "nodeRejected", "submissionFailed", "disconnected", "statusUnknown", "recentFailure", "networkChanged", "commitmentConflict", "observationFailed", "admissionUnsupported", "outcomeUnsupported"];
|
|
1648
|
+
/**
|
|
1649
|
+
* Facts about one signed transaction, present on every {@link ThruputError}
|
|
1650
|
+
* that a transaction workflow raises after signing.
|
|
1651
|
+
*
|
|
1652
|
+
* @example
|
|
1653
|
+
* ```ts
|
|
1654
|
+
* try {
|
|
1655
|
+
* await wallet.executeAndWait(request);
|
|
1656
|
+
* } catch (error) {
|
|
1657
|
+
* if (isThruputError(error) && error.transaction?.outcome === "unknown") {
|
|
1658
|
+
* // Do not send it again. Save the hash and observe it later.
|
|
1659
|
+
* saveForLaterObservation(error.transaction.hash);
|
|
1660
|
+
* }
|
|
1661
|
+
* throw error;
|
|
1662
|
+
* }
|
|
1663
|
+
* ```
|
|
1664
|
+
*/
|
|
1665
|
+
interface TransactionFacts {
|
|
1666
|
+
/** Transaction hash, copied when the error is created. */
|
|
1667
|
+
readonly hash: Uint8Array;
|
|
1668
|
+
readonly outcome: TransactionOutcome;
|
|
1669
|
+
readonly reason: TransactionReason;
|
|
1670
|
+
/** The committed receipt, when the client has one. */
|
|
1671
|
+
readonly receipt?: TransactionReceipt;
|
|
1672
|
+
/** The exact signed bytes and network, when the client has them. */
|
|
1673
|
+
readonly submission?: SubmissionEvidence;
|
|
1674
|
+
}
|
|
1675
|
+
/** Input for {@link TransactionFacts}. */
|
|
1676
|
+
interface TransactionFactsInput {
|
|
1677
|
+
readonly hash: Uint8Array;
|
|
1678
|
+
readonly outcome: TransactionOutcome;
|
|
1679
|
+
readonly reason: TransactionReason;
|
|
1680
|
+
readonly receipt?: TransactionReceipt;
|
|
1681
|
+
readonly submission?: SubmissionEvidence;
|
|
1682
|
+
}
|
|
1683
|
+
//#endregion
|
|
1684
|
+
//#region src/errors/thruputError.d.ts
|
|
1685
|
+
/**
|
|
1686
|
+
* Options for a {@link ThruputError}. `context` is required when the code's
|
|
1687
|
+
* context has required fields.
|
|
1688
|
+
*/
|
|
1689
|
+
type ThruputErrorOptions<TCode extends ThruputErrorCode> = {
|
|
1690
|
+
readonly cause?: unknown;
|
|
1691
|
+
/**
|
|
1692
|
+
* Facts about the signed transaction. Required for each
|
|
1693
|
+
* {@link TransactionErrorCode}, and supplied on every error after signing.
|
|
1694
|
+
*/
|
|
1695
|
+
readonly transaction?: TransactionFactsInput;
|
|
1696
|
+
} & ({} extends ThruputErrorContext[TCode] ? {
|
|
1697
|
+
readonly context?: ThruputErrorContext[TCode];
|
|
1698
|
+
} : {
|
|
1699
|
+
readonly context: ThruputErrorContext[TCode];
|
|
1700
|
+
});
|
|
1701
|
+
/**
|
|
1702
|
+
* A {@link ThruputError} for one of the given codes, narrowable on `code`.
|
|
1703
|
+
* `transaction` is required for each {@link TransactionErrorCode}.
|
|
1704
|
+
*/
|
|
1705
|
+
type ThruputErrorOf<TCode extends ThruputErrorCode = ThruputErrorCode> = { [K in TCode]: K extends TransactionErrorCode ? ThruputError<K> & {
|
|
1706
|
+
readonly transaction: TransactionFacts;
|
|
1707
|
+
} : ThruputError<K> }[TCode];
|
|
1708
|
+
/**
|
|
1709
|
+
* The one error class of the client. Identify an error by its stable `code`
|
|
1710
|
+
* with {@link isThruputError}, and read typed data from `context`.
|
|
1711
|
+
*
|
|
1712
|
+
* The transaction workflows, such as `executeAndWait` and the `sendTransaction`
|
|
1713
|
+
* action, add `transaction` facts to every error after signing; raw RPC methods
|
|
1714
|
+
* do not. Use `transaction.outcome` to decide what to do: an `unknown` outcome
|
|
1715
|
+
* never permits a resend.
|
|
1716
|
+
*
|
|
1717
|
+
* The client's messages never include the message of a cause from your
|
|
1718
|
+
* callbacks or signers; read it from `cause`. A provider wallet's error message
|
|
1719
|
+
* is forwarded as the message of its named code. The error freezes
|
|
1720
|
+
* `context` and `transaction`, and copies `transaction.hash`; other byte arrays
|
|
1721
|
+
* are not copied.
|
|
1722
|
+
*
|
|
1723
|
+
* Custom transports and tests can construct this class too, for example
|
|
1724
|
+
* `new ThruputError("httpRequestFailed", message, { context, cause })`.
|
|
1725
|
+
*
|
|
1726
|
+
* @example
|
|
1727
|
+
* ```ts
|
|
1728
|
+
* try {
|
|
1729
|
+
* await ERC20.v0_1.getBalanceOf.view({
|
|
1730
|
+
* client,
|
|
1731
|
+
* address: tokenAddress,
|
|
1732
|
+
* args: { addr: accountAddress },
|
|
1733
|
+
* minStateBlockHeight: receipt.blockHeight,
|
|
1734
|
+
* });
|
|
1735
|
+
* } catch (error) {
|
|
1736
|
+
* if (isThruputError(error, "nativeRpcError") &&
|
|
1737
|
+
* error.context.kind === "stateHeightUnavailable") {
|
|
1738
|
+
* // Retry later.
|
|
1739
|
+
* }
|
|
1740
|
+
* throw error;
|
|
1741
|
+
* }
|
|
1742
|
+
* ```
|
|
1743
|
+
*/
|
|
1744
|
+
declare class ThruputError<TCode extends ThruputErrorCode = ThruputErrorCode> extends Error {
|
|
1745
|
+
readonly name: "ThruputError";
|
|
1746
|
+
readonly code: TCode;
|
|
1747
|
+
readonly context: ThruputErrorContext[TCode];
|
|
1748
|
+
readonly transaction?: TransactionFacts;
|
|
1749
|
+
constructor(code: TCode, message: string, ...[options]: {} extends ThruputErrorContext[TCode] ? [options?: ThruputErrorOptions<TCode>] : [options: ThruputErrorOptions<TCode>]);
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* Check whether a value is a {@link ThruputError}, and optionally whether it has
|
|
1753
|
+
* a given code. Checks `name` and `code`, not `instanceof`, so it works across
|
|
1754
|
+
* realms and with more than one copy of the package.
|
|
1755
|
+
*
|
|
1756
|
+
* @example
|
|
1757
|
+
* ```ts
|
|
1758
|
+
* if (isThruputError(error, "transactionFailed")) {
|
|
1759
|
+
* console.log(error.transaction.receipt);
|
|
1760
|
+
* }
|
|
1761
|
+
* ```
|
|
1762
|
+
*/
|
|
1763
|
+
declare function isThruputError<TCode extends ThruputErrorCode = ThruputErrorCode>(error: unknown, code?: TCode): error is ThruputErrorOf<TCode>;
|
|
1764
|
+
//#endregion
|
|
1765
|
+
//#region src/rpc/client.d.ts
|
|
1766
|
+
type RpcMethod = keyof RpcRequests;
|
|
1767
|
+
/**
|
|
1768
|
+
* Exact low-level operations. Each accepts one named object; a request whose
|
|
1769
|
+
* fields are all optional can be omitted and defaults to {}.
|
|
1770
|
+
* Cancellation options are always the second argument, including for empty requests:
|
|
1771
|
+
* `client.getChainTip({}, { signal })`.
|
|
1772
|
+
*/
|
|
1773
|
+
type RpcMethods = { [M in RpcMethod]: {} extends RpcRequests[M] ? (request?: RpcRequests[M], options?: TransportRequestOptions) => Promise<RpcResults[M]> : (request: RpcRequests[M], options?: TransportRequestOptions) => Promise<RpcResults[M]> };
|
|
1774
|
+
interface RpcDiscovery {
|
|
1775
|
+
version: RpcVersionInfo;
|
|
1776
|
+
network: RpcNetworkInfo;
|
|
1777
|
+
limits?: RpcServerLimits;
|
|
1778
|
+
}
|
|
1779
|
+
type RpcClient = RpcMethods & {
|
|
1780
|
+
/** Copy of the last explicitly refreshed, validated discovery snapshot. */readonly discovery: RpcDiscovery; /** Reads discovery again. Never repeats a failed write. */
|
|
1781
|
+
refreshDiscovery(options?: TransportRequestOptions): Promise<RpcDiscovery>; /** Check the configured methods before composing a multi-call workflow. */
|
|
1782
|
+
requireMethods(methods: readonly RpcMethod[]): void;
|
|
1783
|
+
};
|
|
1784
|
+
interface RpcClientOptions {
|
|
1785
|
+
transport: Transport;
|
|
1786
|
+
/** Required signing network, compared by bytes before the client is returned. */
|
|
1787
|
+
expectedNetworkHash?: Uint8Array;
|
|
1788
|
+
/** Methods needed by a composed workflow; partial development endpoints are supported. */
|
|
1789
|
+
requiredMethods?: readonly RpcMethod[];
|
|
1790
|
+
signal?: AbortSignal;
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Connect a native wire-14 client. This layer reads once or sends once; it does
|
|
1794
|
+
* not sign, poll, retry, refresh discovery on failure, or switch wire formats.
|
|
1795
|
+
* Unknown response variants are UnsupportedRpcValue objects retaining raw data.
|
|
1796
|
+
*/
|
|
1797
|
+
declare function createRpcClient(options: RpcClientOptions): Promise<RpcClient>;
|
|
1798
|
+
//#endregion
|
|
1799
|
+
//#region src/actions/public/requestAirdrop.d.ts
|
|
1800
|
+
interface RequestAirdropOptions {
|
|
1801
|
+
readonly recipient: Uint8Array;
|
|
1802
|
+
readonly clientNonce?: Uint8Array;
|
|
1803
|
+
readonly expectedNetworkHash?: Uint8Array;
|
|
1804
|
+
readonly timeoutMs?: number;
|
|
1805
|
+
readonly signal?: AbortSignal;
|
|
1806
|
+
}
|
|
1807
|
+
/** Perform exactly one faucet call. It neither polls nor repeats an ambiguous attempt. */
|
|
1808
|
+
declare function requestAirdropAttempt(client: Pick<RpcClient, "faucet_requestAirdrop">, request: AirdropAttemptRequest, options?: TransportRequestOptions): Promise<AirdropResponse>;
|
|
1809
|
+
/**
|
|
1810
|
+
* Call the faucet once, then observe a returned pending hash using read-only calls.
|
|
1811
|
+
* When funding stops, throws code `fundingStopped` without permission to call the
|
|
1812
|
+
* faucet again. `transaction` is present when the faucet identified a
|
|
1813
|
+
* transaction; reconcile with `context.request.clientNonce`.
|
|
1814
|
+
*/
|
|
1815
|
+
declare function requestAirdrop(client: RpcClient, options: RequestAirdropOptions): Promise<AirdropSucceeded>;
|
|
1816
|
+
//#endregion
|
|
1817
|
+
export { AirdropActions as $, NetworkConfigParams as $n, RpcDescendingAnchor as $r, ContractUnionDef as $t, WalletErrorContext as A, RpcSimulationBatchLimits as Ai, AirdropPending as An, RpcBalanceResult as Ar, topicRepresentation as At, ContractMethodInputs as B, RpcTransactionRefPage as Bi, ConflictCode as Bn, RpcBlockStart as Br, ContractSpec$1 as Bt, NativeRpcErrorContext as C, RpcRegisteredAuthResult as Ci, ReceiptObserver as Cn, RpcAdmission as Cr, ContractEventTopicMetadata as Ct, ThruputErrorContext as D, RpcSchedulerErrorSource as Di, AddressAuthDataInfo as Dn, RpcAssumedAuth as Dr, bytesEqual as Dt, ThruputErrorCode as E, RpcSchedulerError as Ei, waitForTransactionReceipt as En, RpcAscendingAnchor as Er, SpecDecodedEvent as Et, ContractException as F, RpcStorageResult as Fi, BalanceResponse as Fn, RpcBase58_ValidatorID as Fr, ContractEnumDef as Ft, ContractViewFailure as G, isUnsupportedRpcValue as Gi, EventPage as Gn, RpcConflictCode as Gr, ContractStructDef as Gt, ContractReceiptFailure as H, RpcTxHash as Hi, ContractRejectCode as Hn, RpcChainConfig as Hr, ContractSpecInterface as Ht, ContractExceptionMetadata as I, RpcTopicFilter as Ii, BlockInfo as In, RpcBlockClock as Ir, ContractEnumVariant as It, ContractViewRequest as J, FundAccountRequest as Jn, RpcContractDeployment as Jr, ContractTypeDefKind as Jt, ContractViewOptions as K, EventQuery as Kn, RpcConflictDiagnostic as Kr, ContractType as Kt, ContractFailure as L, RpcTransactionInputResult as Li, BlockTransactionQuery as Ln, RpcBlockDriverMode as Lr, ContractExceptionType as Lt, ContractArgumentMetadata as M, RpcSimulationResults as Mi, AirdropSucceeded as Mn, RpcBase58_Ed25519PublicKey as Mr, ContractCodecContext as Mt, ContractCall as N, RpcStorageCosts as Ni, AuthPublicKey as Nn, RpcBase58_PublicKeyHash as Nr, createContractCodecContext as Nt, TransactionErrorCode as O, RpcSendTransactionResult as Oi, AirdropAttemptRequest as On, RpcAuthConfiguration as Or, createContractEventDecoder as Ot, ContractCallOptions as P, RpcStorageItem as Pi, AuthSigner as Pn, RpcBase58_SHA256Hash as Pr, ContractArrayType as Pt, defineContractMethod as Q, IterationOrder as Qn, RpcDecimalU64 as Qr, ContractUnionCaseType as Qt, ContractMethod as R, RpcTransactionReceipt as Ri, ChainConfig as Rn, RpcBlockDriverStatus as Rr, ContractField as Rt, FundingStoppedContext as S, RpcRecentAttemptFailure as Si, KnownCommitment as Sn, RpcActiveBlockDriverMode as Sr, ContractEventReceiptOptions as St, RpcIncompatibleKind as T, RpcResults as Ti, waitForCommitment as Tn, RpcAirdropExecution as Tr, DecodedContractEvent as Tt, ContractReceiptOutcome as U, RpcVersionInfo as Ui, EmittedEvent as Un, RpcChainTip as Ur, ContractSpecMethod as Ut, ContractReceipt as V, RpcTransactionStatus as Vi, ConflictDiagnostic as Vn, RpcBlockTimeStep as Vr, ContractSpecId$1 as Vt, ContractView as W, UnsupportedRpcValue as Wi, EventFilter as Wn, RpcConfigLimits as Wr, ContractSpecString as Wt, MethodArgs as X, HistoryStart as Xn, RpcContractRejectCode as Xr, ContractUnionCase as Xt, ContractViewRequestOptions as Y, FundAccountResponse as Yn, RpcContractDeploymentResult as Yr, ContractTypeKind as Yt, UnknownContractException as Z, IdentifiedEvent as Zn, RpcDecimalTimePoint as Zr, ContractUnionCaseKind as Zt, TransactionReason as _, RpcPendingTransactionCount as _i, defineCluster as _n, ViewBatchResponse as _r, ContractEvent as _t, RpcClientOptions as a, RpcEventPage as ai, readViews as an, ServerLimits as ar, createThruputClient as at, SubmissionEvidence as b, RpcPublicKey as bi, localnet as bn, ViewRequest as br, ContractEventFilterInput as bt, RpcMethods as c, RpcFundingSubmission as ci, TransportRequestOptions as cn, StorageItemInfo as cr, BlockTransactionWalkQuery as ct, ThruputErrorOf as d, RpcInvocation as di, ClusterHasCapability as dn, TransactionReceipt as dr, iterateTransactionsByRootAddress as dt, RpcEffectiveContract as ei, ContractVectorType as en, NetworkInfo as er, ClusterThruputClientOptions as et, ThruputErrorOptions as f, RpcInvocationContext as fi, DEVNET_RPC_URL as fn, TransactionRef as fr, HistoryCompletion as ft, TransactionOutcome as g, RpcNetworkInfo as gi, assertNetworkMatchesCluster as gn, ViewBatchRequest as gr, getContractEvents as gt, TransactionFactsInput as h, RpcIterationOrder as hi, PredefinedClusterOptions as hn, VersionInfo as hr, IdentifiedContractEvent as ht, RpcClient as i, RpcEventFilter as ii, ReadViewsResponse as in, SchedulerTransactionError as ir, ThruputClientOptions as it, transactionErrorCodes as j, RpcSimulationResult as ji, AirdropResponse as jn, RpcBase58_ContractAddress as jr, ContractCodec as jt, TransactionOutcomeUnknownContext as k, RpcServerLimits as ki, AirdropExecutionStatus as kn, RpcAuthSigner as kr, defineContractEvent as kt, createRpcClient as l, RpcHistoryStart as li, Cluster as ln, StorageItemRead as lr, RootAddressWalkQuery as lt, TransactionFacts as m, RpcInvocationResult as mi, LOCALNET_RPC_URL as mn, TransactionStatus as mr, ContractEventQuery as mt, requestAirdrop as n, RpcEmittedEvent as ni, specIdKey as nn, RegisteredAuthResult as nr, CoreThruputClient as nt, RpcDiscovery as o, RpcExecutionConfig as oi, RpcParams as on, SimulationBatchLimits as or, EventWalkQuery as ot, isThruputError as p, RpcInvocationOutput as pi, FUTURENET_RPC_URL as pn, TransactionRefPage as pr, ContractEventPage as pt, ContractViewOutcome as q, ExecutionConfig as qn, RpcContractArtifactResult as qr, ContractTypeDef$1 as qt, requestAirdropAttempt as r, RpcErrorData as ri, ReadViewsRequest as rn, RootAddressTransactionQuery as rr, ThruputClient as rt, RpcMethod as s, RpcFailureCause as si, Transport as sn, StorageCosts as sr, iterateEventPages as st, RequestAirdropOptions as t, RpcEffectiveContractResult as ti, formatSpecId as tn, RecentAttemptFailure as tr, ConnectedThruputClient as tt, ThruputError as u, RpcIdentifiedEvent as ui, ClusterCapability as un, TransactionFailureCause as ur, iterateTransactionsByBlock as ut, transactionOutcomes as v, RpcProducedBlock as vi, devnet as vn, ViewCall as vr, ContractEventDefinition as vt, RpcErrorFields as w, RpcRequests as wi, WaitForTransactionReceiptOptions as wn, RpcAirdropAttempt as wr, ContractReceiptEvent as wt, createSubmissionEvidence as x, RpcReceiptExecution as xi, mainnet as xn, ViewResponse as xr, ContractEventFilterValue as xt, transactionReasons as y, RpcProducedBlocks as yi, futurenet as yn, ViewOutput as yr, ContractEventFieldMetadata as yt, ContractMethodDefinition as z, RpcTransactionRef as zi, ChainTip as zn, RpcBlockInfo as zr, ContractMethodEffect$1 as zt };
|
|
1818
|
+
//# sourceMappingURL=requestAirdrop-T1eVn3l5.d.cts.map
|