@thruputchain/client 0.28.0 → 0.30.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 +113 -18
- package/dist/actions-B7htk5FS.js +698 -0
- package/dist/actions-B7htk5FS.js.map +1 -0
- package/dist/actions-CIaI049y.cjs +788 -0
- package/dist/actions-CIaI049y.cjs.map +1 -0
- package/dist/actions.cjs +5 -8
- package/dist/actions.d.cts +4 -4
- package/dist/actions.d.ts +4 -4
- package/dist/actions.js +3 -3
- 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 +3 -4
- package/dist/contract.d.ts +3 -4
- package/dist/contract.js +2 -2
- package/dist/contracts.cjs +5 -5
- package/dist/contracts.d.cts +6 -74
- package/dist/contracts.d.cts.map +1 -1
- package/dist/contracts.d.ts +6 -74
- 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/default_wallet-DkqsCa5C.d.ts +90 -0
- package/dist/default_wallet-DkqsCa5C.d.ts.map +1 -0
- package/dist/default_wallet-Dqs4_iTD.d.cts +90 -0
- package/dist/default_wallet-Dqs4_iTD.d.cts.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-DeS1S0m-.d.ts → index-BmOG68Hd.d.ts} +39 -17
- package/dist/index-BmOG68Hd.d.ts.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-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-Bb01ytjJ.d.ts → index-Dtv_GV6M.d.ts} +40 -11
- package/dist/index-Dtv_GV6M.d.ts.map +1 -0
- package/dist/{index-CtjWsAXV.d.cts → index-JKm4TBlY.d.cts} +40 -11
- package/dist/index-JKm4TBlY.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-CedOvhGY.d.cts → index-ozfbEuYI.d.cts} +39 -17
- package/dist/index-ozfbEuYI.d.cts.map +1 -0
- package/dist/index.cjs +40 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -17
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +11 -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-zGq4eBo8.d.ts → signed_op-DHb4n2JO.d.cts} +3 -3
- package/dist/{signed_op-D2usgASc.d.cts.map → signed_op-DHb4n2JO.d.cts.map} +1 -1
- package/dist/{signed_op-D2usgASc.d.cts → signed_op-Dfa8WD0j.d.ts} +3 -3
- package/dist/{signed_op-zGq4eBo8.d.ts.map → signed_op-Dfa8WD0j.d.ts.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 +5 -5
- package/dist/actions-B5-CjpEF.cjs +0 -513
- 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 +0 -35
- package/dist/artifact-BM_MVzhL.d.cts.map +0 -1
- package/dist/artifact-BM_MVzhL.d.ts +0 -35
- 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
package/dist/contracts.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.cts","names":[],"sources":["../src/contracts/erc20.ts","../src/contracts/
|
|
1
|
+
{"version":3,"file":"contracts.d.cts","names":[],"sources":["../src/contracts/erc20.ts","../src/contracts/dev_wallet.ts","../src/contracts/erc20_permit.ts"],"mappings":";;;;;;;kBAmEiB,gBAAA;EAAA,UACE,IAAA;IAAA,UACE,KAAA;MAAA,KACH,UAAA;IAAA;IAAA,UAGG,MAAA;MAAA,UACE,oBAAA,SAA6B,oBAAA;QAG1C,KAAA,EAAO,aAAA,CAAc,eAAA;QACrB,OAAA,EAAS,aAAA,CAAc,eAAA;MAAA;QAEvB,UAAA;MAAA;MAAA,UAGa,0BAAA;QACf,KAAA,GAAQ,wBAAA,CAA8C,aAAA,CAAc,eAAA;QACpE,OAAA,GAAU,wBAAA,CAA8C,aAAA,CAAc,eAAA;MAAA;MAAA,UAGvD,oBAAA,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A,KACH,gBAAA;IAAA;EAAA;AAAA;AAAA,kBAKD,WAAA;EAAA,UACE,IAAA;IAAA,UACE,yBAAA;MACf,KAAA,EAAO,WAAA,CAAiC,YAAA,CAAa,iDAAA;IAAA;IAAA,KAE3C,2BAAA;IAAA,UAEK,2BAAA;MACf,KAAA,EAAO,WAAA,CAAiC,YAAA,CAAa,wCAAA;IAAA;IAAA,KAE3C,6BAAA;IAAA,UAEK,sBAAA;MACf,KAAA,EAAO,WAAA,CAAiC,YAAA,CAAa,wCAAA;MACrD,QAAA,EAAU,aAAA,CAAc,eAAA;MACxB,MAAA;IAAA;IAAA,KAEU,wBAAA;IAAA,KAEA,iBAAA;MAEN,IAAA;MACA,IAAA;MACA,QAAA;MACA,KAAA,EAAO,YAAA,CAAa,mDAAA;IAAA;MAGpB,IAAA;MACA,IAAA;MACA,QAAA;MACA,KAAA,EAAO,YAAA,CAAa,sCAAA;IAAA;IAAA,KAEd,SAAA,GACV,iBAAA,CAAuC,iBAAA;EAAA;AAAA;AAAA,cAIhC,MAAA,EAAM,YA8LlB;AAAA,cAMY,WAAA;EAAA;;;;;;cAkHA,kBAAA;EAAA;;;;;;;;;;;;;cAeA,uBAAA;EAAA;;;;;;;;;kBAYI,YAAA;EAAA,KACH,sCAAA,GACV,kBAAA,CAAiB,IAAA,CAAK,KAAA,CAAM,UAAA;EAAA,KAClB,iDAAA,GACV,uBAAA,CAAwB,IAAA,CAAK,oBAAA;EAAA,KACnB,wCAAA,GACV,uBAAA,CAAwB,IAAA,CAAK,WAAA;EAAA,KACnB,mDAAA,GACV,uBAAA,CAAwB,IAAA,CAAK,KAAA,CAAM,gBAAA;AAAA"}
|
package/dist/contracts.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as SignedToken, n as FixedBytes } from "./index-
|
|
3
|
-
import { n as
|
|
1
|
+
import { Bt as ContractSpec, F as ContractException, R as ContractMethod, Tt as DecodedContractEvent, _t as ContractEvent, xt as ContractEventFilterValue } from "./requestAirdrop-DBCOST2B.js";
|
|
2
|
+
import { c as SignedToken, n as FixedBytes } from "./index-BmOG68Hd.js";
|
|
3
|
+
import { n as default_wallet, r as spec, t as DefaultWallet } from "./default_wallet-DkqsCa5C.js";
|
|
4
|
+
import { n as spec$4, r as thruput_signed_op_if, t as SignedOp } from "./signed_op-Dfa8WD0j.js";
|
|
4
5
|
import * as __gh_protocol from "@thruputchain/protocol";
|
|
5
6
|
|
|
6
7
|
//#region src/contracts/erc20.d.ts
|
|
@@ -101,7 +102,7 @@ declare namespace ERC20 {
|
|
|
101
102
|
kind: "declared";
|
|
102
103
|
name: "ERC20Error";
|
|
103
104
|
selector: 0xf63c8b1f5e7e2fe0n;
|
|
104
|
-
value: __gh_codegen$
|
|
105
|
+
value: __gh_codegen$1.thruput_erc20_if$v0_1$error$ERC20Error;
|
|
105
106
|
};
|
|
106
107
|
type Exception = ContractException<DeclaredException>;
|
|
107
108
|
}
|
|
@@ -193,77 +194,8 @@ declare function decodeEvent(__gh_event: {
|
|
|
193
194
|
topics: globalThis.Uint8Array[];
|
|
194
195
|
data: globalThis.Uint8Array;
|
|
195
196
|
}): ERC20Event | null;
|
|
196
|
-
declare namespace __gh_codegen$2 {
|
|
197
|
-
type thruput_erc20_if$v0_1$error$ERC20Error = thruput_erc20_if.v0_1.error.ERC20Error;
|
|
198
|
-
}
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/contracts/default_wallet.d.ts
|
|
201
|
-
declare namespace default_wallet {
|
|
202
|
-
namespace v0_1 {
|
|
203
|
-
namespace $interface {
|
|
204
|
-
interface WalletCall {
|
|
205
|
-
target: __gh_protocol.ContractAddress;
|
|
206
|
-
entrypoint: FixedBytes<8>;
|
|
207
|
-
gas_limit: bigint;
|
|
208
|
-
calldata: globalThis.Uint8Array;
|
|
209
|
-
}
|
|
210
|
-
type WalletError = 1n | 2n | 3n | 4n | 5n | 6n | 7n;
|
|
211
|
-
interface WalletInitCall {
|
|
212
|
-
entrypoint: FixedBytes<8>;
|
|
213
|
-
gas_limit: bigint;
|
|
214
|
-
calldata: globalThis.Uint8Array;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
declare namespace DefaultWallet {
|
|
220
|
-
namespace v0_1 {
|
|
221
|
-
interface DeployArgs {
|
|
222
|
-
nonce: FixedBytes<32>;
|
|
223
|
-
contractHash: FixedBytes<32>;
|
|
224
|
-
amount: bigint;
|
|
225
|
-
initializer: __gh_codegen$1.default_wallet$v0_1$$interface$WalletInitCall | null;
|
|
226
|
-
}
|
|
227
|
-
type DeployResult = __gh_protocol.ContractAddress;
|
|
228
|
-
interface ExecuteArgs {
|
|
229
|
-
calls: __gh_codegen$1.default_wallet$v0_1$$interface$WalletCall[];
|
|
230
|
-
}
|
|
231
|
-
type ExecuteResult = globalThis.Uint8Array[];
|
|
232
|
-
type DeclaredException = {
|
|
233
|
-
kind: "declared";
|
|
234
|
-
name: "WalletError";
|
|
235
|
-
selector: 0x931d3297d37d1bdfn;
|
|
236
|
-
value: __gh_codegen$1.default_wallet$v0_1$$interface$WalletError;
|
|
237
|
-
};
|
|
238
|
-
type Exception = ContractException<DeclaredException>;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
declare const spec: ContractSpec;
|
|
242
|
-
declare const DefaultWallet: {
|
|
243
|
-
readonly v0_1: {
|
|
244
|
-
readonly deploy: ContractMethod<DefaultWallet.v0_1.DeployArgs, __gh_protocol.ContractAddress, DefaultWallet.v0_1.DeclaredException>;
|
|
245
|
-
readonly execute: ContractMethod<DefaultWallet.v0_1.ExecuteArgs, DefaultWallet.v0_1.ExecuteResult, DefaultWallet.v0_1.DeclaredException>;
|
|
246
|
-
};
|
|
247
|
-
};
|
|
248
|
-
declare const default_wallet: {
|
|
249
|
-
readonly v0_1: {
|
|
250
|
-
readonly $interface: {
|
|
251
|
-
readonly WalletError: {
|
|
252
|
-
readonly NotRootInvocation: 1n;
|
|
253
|
-
readonly InvalidAuthClaim: 2n;
|
|
254
|
-
readonly EmptyCallList: 3n;
|
|
255
|
-
readonly TooManyCalls: 4n;
|
|
256
|
-
readonly CallAborted: 5n;
|
|
257
|
-
readonly CallFaulted: 6n;
|
|
258
|
-
readonly ReturnDataTooLarge: 7n;
|
|
259
|
-
};
|
|
260
|
-
};
|
|
261
|
-
};
|
|
262
|
-
};
|
|
263
197
|
declare namespace __gh_codegen$1 {
|
|
264
|
-
type
|
|
265
|
-
type default_wallet$v0_1$$interface$WalletError = default_wallet.v0_1.$interface.WalletError;
|
|
266
|
-
type default_wallet$v0_1$$interface$WalletInitCall = default_wallet.v0_1.$interface.WalletInitCall;
|
|
198
|
+
type thruput_erc20_if$v0_1$error$ERC20Error = thruput_erc20_if.v0_1.error.ERC20Error;
|
|
267
199
|
}
|
|
268
200
|
//#endregion
|
|
269
201
|
//#region src/contracts/dev_wallet.d.ts
|
package/dist/contracts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","names":[],"sources":["../src/contracts/erc20.ts","../src/contracts/
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","names":[],"sources":["../src/contracts/erc20.ts","../src/contracts/dev_wallet.ts","../src/contracts/erc20_permit.ts"],"mappings":";;;;;;;kBAmEiB,gBAAA;EAAA,UACE,IAAA;IAAA,UACE,KAAA;MAAA,KACH,UAAA;IAAA;IAAA,UAGG,MAAA;MAAA,UACE,oBAAA,SAA6B,oBAAA;QAG1C,KAAA,EAAO,aAAA,CAAc,eAAA;QACrB,OAAA,EAAS,aAAA,CAAc,eAAA;MAAA;QAEvB,UAAA;MAAA;MAAA,UAGa,0BAAA;QACf,KAAA,GAAQ,wBAAA,CAA8C,aAAA,CAAc,eAAA;QACpE,OAAA,GAAU,wBAAA,CAA8C,aAAA,CAAc,eAAA;MAAA;MAAA,UAGvD,oBAAA,SAA6B,oBAAA;QAG1C,KAAA,EAAO,aAAA,CAAc,eAAA;QACrB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,UACE,IAAA;IAAA,UACE,yBAAA;MACf,KAAA,EAAO,WAAA,CAAiC,YAAA,CAAa,iDAAA;IAAA;IAAA,KAE3C,2BAAA;IAAA,UAEK,2BAAA;MACf,KAAA,EAAO,WAAA,CAAiC,YAAA,CAAa,wCAAA;IAAA;IAAA,KAE3C,6BAAA;IAAA,UAEK,sBAAA;MACf,KAAA,EAAO,WAAA,CAAiC,YAAA,CAAa,wCAAA;MACrD,QAAA,EAAU,aAAA,CAAc,eAAA;MACxB,MAAA;IAAA;IAAA,KAEU,wBAAA;IAAA,KAEA,iBAAA;MAEN,IAAA;MACA,IAAA;MACA,QAAA;MACA,KAAA,EAAO,YAAA,CAAa,mDAAA;IAAA;MAGpB,IAAA;MACA,IAAA;MACA,QAAA;MACA,KAAA,EAAO,YAAA,CAAa,sCAAA;IAAA;IAAA,KAEd,SAAA,GACV,iBAAA,CAAuC,iBAAA;EAAA;AAAA;AAAA,cAIhC,MAAA,EAAM,YA8LlB;AAAA,cAMY,WAAA;EAAA;;;;;;cAkHA,kBAAA;EAAA;;;;;;;;;;;;;cAeA,uBAAA;EAAA;;;;;;;;;kBAYI,YAAA;EAAA,KACH,sCAAA,GACV,kBAAA,CAAiB,IAAA,CAAK,KAAA,CAAM,UAAA;EAAA,KAClB,iDAAA,GACV,uBAAA,CAAwB,IAAA,CAAK,oBAAA;EAAA,KACnB,wCAAA,GACV,uBAAA,CAAwB,IAAA,CAAK,WAAA;EAAA,KACnB,mDAAA,GACV,uBAAA,CAAwB,IAAA,CAAK,KAAA,CAAM,gBAAA;AAAA"}
|
package/dist/contracts.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as defineContractEvent,
|
|
2
|
-
import { a as spec, i as default_wallet, n as spec$1, r as DefaultWallet, t as DevWallet } from "./dev_wallet-
|
|
3
|
-
import { n as spec$4, r as thruput_signed_op_if, t as SignedOp } from "./signed_op-
|
|
1
|
+
import { c as defineContractEvent, f as defineContractMethod, m as createContractCodecContext } from "./contract-BOlNskwd.js";
|
|
2
|
+
import { a as spec, i as default_wallet, n as spec$1, r as DefaultWallet, t as DevWallet } from "./dev_wallet-D9LuPZ-h.js";
|
|
3
|
+
import { n as spec$4, r as thruput_signed_op_if, t as SignedOp } from "./signed_op-h9X9-vBL.js";
|
|
4
|
+
import * as __gh_protocol_utils from "@thruputchain/protocol/utils";
|
|
4
5
|
import * as __gh_protocol from "@thruputchain/protocol";
|
|
5
6
|
import * as __gh_contract_spec from "@thruputchain/contract-spec";
|
|
6
|
-
import * as __gh_protocol_utils from "@thruputchain/protocol/utils";
|
|
7
7
|
//#region src/contracts/erc20.ts
|
|
8
8
|
const __gh_s$1 = __gh_contract_spec.contractSpecString;
|
|
9
9
|
const __gh_entrypoints$1 = {
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
//#region src/errors/codes.ts
|
|
2
|
+
/**
|
|
3
|
+
* Codes that always have `transaction` facts. After narrowing to one of these
|
|
4
|
+
* codes, `error.transaction` is required.
|
|
5
|
+
*/
|
|
6
|
+
const transactionErrorCodes = Object.freeze([
|
|
7
|
+
"transactionFailed",
|
|
8
|
+
"transactionOutcomeUnsupported",
|
|
9
|
+
"transactionResultUndecodable",
|
|
10
|
+
"transactionResultUnavailable",
|
|
11
|
+
"transactionNotSubmitted",
|
|
12
|
+
"transactionOutcomeUnknown",
|
|
13
|
+
"transactionAdmissionUnsupported",
|
|
14
|
+
"contractCallFailed"
|
|
15
|
+
]);
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/errors/thruputError.ts
|
|
18
|
+
/**
|
|
19
|
+
* The one error class of the client. Identify an error by its stable `code`
|
|
20
|
+
* with {@link isThruputError}, and read typed data from `context`.
|
|
21
|
+
*
|
|
22
|
+
* The transaction workflows, such as `executeAndWait` and the `sendTransaction`
|
|
23
|
+
* action, add `transaction` facts to every error after signing; raw RPC methods
|
|
24
|
+
* do not. Use `transaction.outcome` to decide what to do: an `unknown` outcome
|
|
25
|
+
* never permits a resend.
|
|
26
|
+
*
|
|
27
|
+
* The client's messages never include the message of a cause from your
|
|
28
|
+
* callbacks or signers; read it from `cause`. A provider wallet's error message
|
|
29
|
+
* is forwarded as the message of its named code. The error freezes
|
|
30
|
+
* `context` and `transaction`, and copies `transaction.hash`; other byte arrays
|
|
31
|
+
* are not copied.
|
|
32
|
+
*
|
|
33
|
+
* Custom transports and tests can construct this class too, for example
|
|
34
|
+
* `new ThruputError("httpRequestFailed", message, { context, cause })`.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* try {
|
|
39
|
+
* await ERC20.v0_1.getBalanceOf.view({
|
|
40
|
+
* client,
|
|
41
|
+
* address: tokenAddress,
|
|
42
|
+
* args: { addr: accountAddress },
|
|
43
|
+
* minStateBlockHeight: receipt.blockHeight,
|
|
44
|
+
* });
|
|
45
|
+
* } catch (error) {
|
|
46
|
+
* if (isThruputError(error, "nativeRpcError") &&
|
|
47
|
+
* error.context.kind === "stateHeightUnavailable") {
|
|
48
|
+
* // Retry later.
|
|
49
|
+
* }
|
|
50
|
+
* throw error;
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
var ThruputError = class extends Error {
|
|
55
|
+
name = "ThruputError";
|
|
56
|
+
code;
|
|
57
|
+
context;
|
|
58
|
+
constructor(code, message, ...[options = {}]) {
|
|
59
|
+
if (!options.transaction && transactionErrorCodes.includes(code)) throw new TypeError(`${code} requires transaction facts`);
|
|
60
|
+
super(message, "cause" in options ? { cause: options.cause } : void 0);
|
|
61
|
+
this.code = code;
|
|
62
|
+
this.context = Object.freeze({ ...options.context });
|
|
63
|
+
if (options.transaction) this.transaction = Object.freeze({
|
|
64
|
+
...options.transaction,
|
|
65
|
+
hash: new Uint8Array(options.transaction.hash)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Check whether a value is a {@link ThruputError}, and optionally whether it has
|
|
71
|
+
* a given code. Checks `name` and `code`, not `instanceof`, so it works across
|
|
72
|
+
* realms and with more than one copy of the package.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* if (isThruputError(error, "transactionFailed")) {
|
|
77
|
+
* console.log(error.transaction.receipt);
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
function isThruputError(error, code) {
|
|
82
|
+
return Object.prototype.toString.call(error) === "[object Error]" && error !== null && typeof error === "object" && "name" in error && error.name === "ThruputError" && "code" in error && typeof error.code === "string" && (code === void 0 || error.code === code);
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/rpc/unsupported.ts
|
|
86
|
+
/** An unfamiliar variant is data, never success, absence, or retry permission. */
|
|
87
|
+
var UnsupportedRpcValue = class {
|
|
88
|
+
raw;
|
|
89
|
+
unsupported = true;
|
|
90
|
+
constructor(raw) {
|
|
91
|
+
this.raw = raw;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Check for an {@link UnsupportedRpcValue} without `instanceof`, so a value
|
|
96
|
+
* from another copy of the package, such as the CJS build, also matches.
|
|
97
|
+
*/
|
|
98
|
+
function isUnsupportedRpcValue(value) {
|
|
99
|
+
return value !== null && typeof value === "object" && "unsupported" in value && value.unsupported === true && "raw" in value;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/actions/decimal.ts
|
|
103
|
+
const I64_MAX = (1n << 63n) - 1n;
|
|
104
|
+
const U64_MAX = (1n << 64n) - 1n;
|
|
105
|
+
/** Parse a canonical, range-checked decimal string. Numeric JSON is never accepted. */
|
|
106
|
+
function parseDecimal(value, field, minimum, maximum) {
|
|
107
|
+
if (typeof value !== "string" || value.length > Math.max(minimum.toString().length, maximum.toString().length) || !/^(0|-?[1-9][0-9]*)(?![\s\S])/.test(value)) throw new Error(`Invalid ${field}: expected a canonical decimal string`);
|
|
108
|
+
const parsed = BigInt(value);
|
|
109
|
+
if (parsed < minimum || parsed > maximum) throw new RangeError(`Invalid ${field}: expected an integer from ${minimum} to ${maximum}`);
|
|
110
|
+
return parsed;
|
|
111
|
+
}
|
|
112
|
+
/** Serialize a caller-owned bigint without passing through a JavaScript number. */
|
|
113
|
+
function serializeHeight(value) {
|
|
114
|
+
if (typeof value !== "bigint" || value < 0n || value > I64_MAX) throw new RangeError("height must be a non-negative int64 bigint");
|
|
115
|
+
return value.toString();
|
|
116
|
+
}
|
|
117
|
+
function serializeU64(value, field) {
|
|
118
|
+
if (typeof value !== "bigint" || value < 0n || value > U64_MAX) throw new RangeError(`${field} must be a uint64 bigint`);
|
|
119
|
+
return value.toString();
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
Object.defineProperty(exports, "ThruputError", {
|
|
123
|
+
enumerable: true,
|
|
124
|
+
get: function() {
|
|
125
|
+
return ThruputError;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(exports, "UnsupportedRpcValue", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
get: function() {
|
|
131
|
+
return UnsupportedRpcValue;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
Object.defineProperty(exports, "isThruputError", {
|
|
135
|
+
enumerable: true,
|
|
136
|
+
get: function() {
|
|
137
|
+
return isThruputError;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(exports, "isUnsupportedRpcValue", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: function() {
|
|
143
|
+
return isUnsupportedRpcValue;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
Object.defineProperty(exports, "parseDecimal", {
|
|
147
|
+
enumerable: true,
|
|
148
|
+
get: function() {
|
|
149
|
+
return parseDecimal;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
Object.defineProperty(exports, "serializeHeight", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
get: function() {
|
|
155
|
+
return serializeHeight;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
Object.defineProperty(exports, "serializeU64", {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
get: function() {
|
|
161
|
+
return serializeU64;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(exports, "transactionErrorCodes", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function() {
|
|
167
|
+
return transactionErrorCodes;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
//# sourceMappingURL=decimal-BX7abv5J.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimal-BX7abv5J.cjs","names":[],"sources":["../src/errors/codes.ts","../src/errors/thruputError.ts","../src/rpc/unsupported.ts","../src/actions/decimal.ts"],"sourcesContent":["import type { KnownCommitment } from \"../actions/public/waitForTransactionReceipt.js\";\nimport type { Cluster } from \"../cluster.js\";\nimport type {\n ContractReceiptFailure,\n ContractViewFailure,\n} from \"../contract/method.js\";\nimport type { WalletProviderErrorCode } from \"../provider/types.js\";\nimport type { UnsupportedRpcValue } from \"../rpc/codec.js\";\nimport type {\n RpcErrorData,\n RpcSendTransactionResult,\n} from \"../rpc/generated.js\";\nimport type {\n AirdropResponse,\n EventPage,\n NetworkInfo,\n TransactionRefPage,\n TransactionStatus,\n} from \"../types/rpc.js\";\n\n/** Fields shared by JSON-RPC error contexts. */\nexport interface RpcErrorFields {\n /** JSON-RPC numeric error code. */\n readonly code: number;\n /** The `message` field of the JSON-RPC error object. */\n readonly rpcMessage: string;\n /** The `data` field of the JSON-RPC error object, when present. */\n readonly data?: unknown;\n /** JSON-RPC method of the failed request, when known. */\n readonly method?: string;\n /** Complete original JSON-RPC error object, including additive fields. */\n readonly raw: unknown;\n}\n\n/**\n * A native RPC error. Narrow on `kind` to read typed `data`. The kind\n * `unrecognized` means the error was unknown, malformed, or contradicted the\n * request; `raw` keeps the complete original error.\n */\nexport type NativeRpcErrorContext = Omit<RpcErrorFields, \"data\"> & {\n readonly method: string;\n} & (\n | (RpcErrorData extends infer TData\n ? TData extends { kind: infer TKind }\n ? { readonly kind: TKind; readonly data: TData }\n : never\n : never)\n | { readonly kind: \"unrecognized\"; readonly data?: undefined }\n );\n\n/**\n * What an `rpcIncompatible` error found:\n *\n * - `network`: the endpoint serves another network than the one expected.\n * - `method`: the endpoint does not advertise a method that the call needs.\n * - `wireVersion`: the endpoint uses an RPC wire format this client cannot read.\n * - `limits`: the endpoint does not advertise limits that the call needs.\n * - `commitment`: commitment heights for one transaction do not agree.\n */\nexport type RpcIncompatibleKind =\n | \"network\"\n | \"method\"\n | \"wireVersion\"\n | \"limits\"\n | \"commitment\";\n\n/** The app-layer context of a wallet provider error. */\nexport interface WalletErrorContext {\n /** The EIP-1193-style numeric code from the wallet provider wire contract. */\n readonly providerCode: WalletProviderErrorCode;\n}\n\n/** Context for errors that stop observation of a transaction. */\nexport interface TransactionOutcomeUnknownContext {\n /** Commitment that the client proved before it stopped, when known. */\n readonly knownCommitment?: KnownCommitment;\n /** The last status the node reported, when known. */\n readonly lastStatus?: TransactionStatus;\n /** The submission failure, when observation continued after it. */\n readonly submissionError?: unknown;\n}\n\n/** Context for {@link ThruputErrorContext.fundingStopped}. */\nexport interface FundingStoppedContext {\n readonly request: {\n readonly recipient: Uint8Array;\n /** Use the same nonce to reconcile this attempt. A new nonce can fund twice. */\n readonly clientNonce: Uint8Array;\n readonly networkHash: Uint8Array;\n };\n /** The last faucet response, when the faucet answered. */\n readonly lastResponse?: AirdropResponse;\n /** Commitment that the client proved before it stopped, when known. */\n readonly knownCommitment?: KnownCommitment;\n}\n\n/**\n * The context type for each error code. Each property name is a code.\n *\n * Codes are stable. The client never renames or reuses a code, and never removes\n * a context field. It can add codes and optional fields.\n *\n * Codes use camelCase, like the native RPC error kinds. Node.js and ethers use\n * UPPER_SNAKE; this client keeps one style for all of its string unions.\n *\n * A code names its subject first, then what happened, for example\n * `transactionFailed` or `rpcValueInvalid`. When a code reports a term from a\n * standard, it keeps that term: `rpcError` is a JSON-RPC error object, and\n * `walletInvalidParams` is the JSON-RPC \"Invalid params\" error (-32602).\n *\n * Other packages can add codes through declaration merging:\n *\n * @example\n * ```ts\n * declare module \"@thruputchain/client\" {\n * interface ThruputErrorContext {\n * testkitRunFailed: { readonly step: string };\n * }\n * }\n * ```\n */\nexport interface ThruputErrorContext {\n // Transactions. See `transactionErrorCodes` for the codes that always have `transaction` facts.\n\n /** The receipt shows failed execution. Outcome `failed`. */\n transactionFailed: Record<string, never>;\n /** The receipt has an execution value this client does not support. Outcome `unknown`. */\n transactionOutcomeUnsupported: Record<string, never>;\n /** Execution succeeded, but its return data did not decode. Outcome `succeeded`. */\n transactionResultUndecodable: Record<string, never>;\n /** Execution succeeded, but the wallet does not keep child return data. Outcome `succeeded`. */\n transactionResultUnavailable: Record<string, never>;\n /** The client did not dispatch the signed transaction. Outcome `notSubmitted`. */\n transactionNotSubmitted: Record<string, never>;\n /**\n * Submission or observation stopped before the client knew the outcome.\n * Outcome `unknown`. Never resend; observe `transaction.hash`.\n */\n transactionOutcomeUnknown: TransactionOutcomeUnknownContext;\n /** Submission returned an admission value this client does not support. Outcome `unknown`. */\n transactionAdmissionUnsupported: {\n readonly response: RpcSendTransactionResult;\n };\n /**\n * A faucet request stopped. `transaction` is present when the faucet\n * identified a transaction. Never call the faucet with a new nonce\n * automatically; reconcile with `context.request.clientNonce`. If the node\n * stopped the attempt but returned a successful receipt, the facts have\n * outcome `succeeded` and reason `nodeRejected`.\n */\n fundingStopped: FundingStoppedContext;\n\n // JSON-RPC and transport.\n\n /** The endpoint returned a JSON-RPC error object. */\n rpcError: RpcErrorFields;\n /** A native RPC method returned an error. Narrow on `context.kind`. */\n nativeRpcError: NativeRpcErrorContext;\n /** The HTTP response had a status that is not successful. */\n httpResponseError: {\n readonly status: number;\n readonly statusText: string;\n readonly endpoint?: string;\n readonly method?: string;\n };\n /** The HTTP request failed in the network layer. The endpoint is the URL origin only. */\n httpRequestFailed: {\n readonly endpoint: string;\n readonly method: string;\n };\n /** The JSON-RPC reply was malformed. The write outcome of the request is unknown. */\n rpcResponseInvalid: { readonly raw: unknown };\n /** A known RPC result value was malformed. */\n rpcValueInvalid: { readonly path: string; readonly raw: unknown };\n /** A local RPC request value was invalid. The transport was not called. */\n rpcRequestInvalid: { readonly path: string };\n /**\n * The endpoint, network, or method set does not match what the client\n * requires. Narrow on `context.kind`: for example, `network` means the\n * endpoint serves another network than the one expected. This is what\n * `createThruputClient` throws when a pinned cluster's network does not match.\n */\n rpcIncompatible: { readonly kind: RpcIncompatibleKind };\n /** The endpoint returned a value this client does not support. */\n rpcValueUnsupported: { readonly value: UnsupportedRpcValue };\n /**\n * The network that you pass to `assertNetworkMatchesCluster` does not match\n * the cluster descriptor. `createThruputClient` reports a pinned network that\n * does not match as `rpcIncompatible` with `context.kind` `network`.\n */\n networkMismatch: {\n readonly cluster: Cluster;\n readonly actual: NetworkInfo;\n };\n\n // Contracts.\n\n /** A contract view aborted, faulted, or returned an unsupported outcome. */\n contractViewFailed: {\n /** Qualified method name. */\n readonly method: string;\n readonly entrypoint: Uint8Array;\n readonly outcome: ContractViewFailure<unknown>;\n };\n /**\n * A root contract receipt did not produce a typed return. Has\n * `transaction` facts. Use the method's `decodeError` for the typed exception.\n * When the receipt shows success but the return is unsupported, the facts are\n * outcome `succeeded` with reason `resultUndecodable`.\n */\n contractCallFailed: {\n /** Qualified method name. */\n readonly method: string;\n readonly entrypoint: Uint8Array;\n readonly outcome: ContractReceiptFailure<unknown>;\n };\n /** Contract bytes do not match their declared type. */\n contractDecodeFailed: Record<string, never>;\n /** Retrieved bytes or response metadata failed identity or canonical checks. */\n contractVerificationFailed: Record<string, never>;\n\n // Wallet providers. Each code maps one wire code from the wallet provider contract.\n\n /** Provider code 4001: the user rejected the request. */\n userRejected: WalletErrorContext;\n /** Provider code 4100: unauthorized origin or account, stale session, or no matching approval. */\n walletUnauthorized: WalletErrorContext;\n /** Provider code 4200: the provider does not support the method. */\n walletMethodUnsupported: WalletErrorContext;\n /** Provider code 4900: the provider is disconnected or its transport is unavailable. */\n walletDisconnected: WalletErrorContext;\n /** Provider code 4901: the wallet network does not match. */\n walletNetworkMismatch: WalletErrorContext;\n /** Provider code -32602: invalid parameters, noncanonical encoding, or exceeded limits. */\n walletInvalidParams: WalletErrorContext;\n /** Provider code -32603: internal error or invalid provider result. */\n walletInternalError: WalletErrorContext;\n /** Provider code -32002: another operation is pending. */\n walletRequestPending: WalletErrorContext;\n\n // Other.\n\n /** `parseUnits` received a malformed amount or too many decimal places. */\n amountInvalid: {\n readonly kind: \"malformed\" | \"precision\";\n readonly decimals: number;\n };\n /** History pages broke ordering, cursor, or identity rules across pages. */\n historyWalkFailed: { readonly page: EventPage | TransactionRefPage };\n}\n\n/** A stable error code. */\nexport type ThruputErrorCode = keyof ThruputErrorContext & string;\n\n/**\n * Codes that always have `transaction` facts. After narrowing to one of these\n * codes, `error.transaction` is required.\n */\nexport const transactionErrorCodes = Object.freeze([\n \"transactionFailed\",\n \"transactionOutcomeUnsupported\",\n \"transactionResultUndecodable\",\n \"transactionResultUnavailable\",\n \"transactionNotSubmitted\",\n \"transactionOutcomeUnknown\",\n \"transactionAdmissionUnsupported\",\n \"contractCallFailed\",\n] as const satisfies readonly ThruputErrorCode[]);\n\n/** A code that always has `transaction` facts. */\nexport type TransactionErrorCode = (typeof transactionErrorCodes)[number];\n","import {\n transactionErrorCodes,\n type ThruputErrorCode,\n type ThruputErrorContext,\n type TransactionErrorCode,\n} from \"./codes.js\";\nimport type { TransactionFacts, TransactionFactsInput } from \"./transaction.js\";\n\n/**\n * Options for a {@link ThruputError}. `context` is required when the code's\n * context has required fields.\n */\nexport type ThruputErrorOptions<TCode extends ThruputErrorCode> = {\n readonly cause?: unknown;\n /**\n * Facts about the signed transaction. Required for each\n * {@link TransactionErrorCode}, and supplied on every error after signing.\n */\n readonly transaction?: TransactionFactsInput;\n} & ({} extends ThruputErrorContext[TCode]\n ? { readonly context?: ThruputErrorContext[TCode] }\n : { readonly context: ThruputErrorContext[TCode] });\n\n/**\n * A {@link ThruputError} for one of the given codes, narrowable on `code`.\n * `transaction` is required for each {@link TransactionErrorCode}.\n */\nexport type ThruputErrorOf<TCode extends ThruputErrorCode = ThruputErrorCode> =\n {\n [K in TCode]: K extends TransactionErrorCode\n ? ThruputError<K> & { readonly transaction: TransactionFacts }\n : ThruputError<K>;\n }[TCode];\n\n/**\n * The one error class of the client. Identify an error by its stable `code`\n * with {@link isThruputError}, and read typed data from `context`.\n *\n * The transaction workflows, such as `executeAndWait` and the `sendTransaction`\n * action, add `transaction` facts to every error after signing; raw RPC methods\n * do not. Use `transaction.outcome` to decide what to do: an `unknown` outcome\n * never permits a resend.\n *\n * The client's messages never include the message of a cause from your\n * callbacks or signers; read it from `cause`. A provider wallet's error message\n * is forwarded as the message of its named code. The error freezes\n * `context` and `transaction`, and copies `transaction.hash`; other byte arrays\n * are not copied.\n *\n * Custom transports and tests can construct this class too, for example\n * `new ThruputError(\"httpRequestFailed\", message, { context, cause })`.\n *\n * @example\n * ```ts\n * try {\n * await ERC20.v0_1.getBalanceOf.view({\n * client,\n * address: tokenAddress,\n * args: { addr: accountAddress },\n * minStateBlockHeight: receipt.blockHeight,\n * });\n * } catch (error) {\n * if (isThruputError(error, \"nativeRpcError\") &&\n * error.context.kind === \"stateHeightUnavailable\") {\n * // Retry later.\n * }\n * throw error;\n * }\n * ```\n */\nexport class ThruputError<\n TCode extends ThruputErrorCode = ThruputErrorCode,\n> extends Error {\n override readonly name = \"ThruputError\" as const;\n readonly code: TCode;\n readonly context: ThruputErrorContext[TCode];\n // `declare` keeps an absent field from becoming an own `undefined` property.\n declare readonly transaction?: TransactionFacts;\n\n constructor(\n code: TCode,\n message: string,\n // Options can be left out only when the code needs no context.\n ...[\n options = {} as ThruputErrorOptions<TCode>,\n ]: {} extends ThruputErrorContext[TCode]\n ? [options?: ThruputErrorOptions<TCode>]\n : [options: ThruputErrorOptions<TCode>]\n ) {\n if (\n !options.transaction &&\n (transactionErrorCodes as readonly string[]).includes(code)\n )\n throw new TypeError(`${code} requires transaction facts`);\n super(message, \"cause\" in options ? { cause: options.cause } : undefined);\n this.code = code;\n this.context = Object.freeze({\n ...options.context,\n }) as ThruputErrorContext[TCode];\n // Copy the hash, the fact an app keeps to observe the transaction.\n if (options.transaction)\n this.transaction = Object.freeze({\n ...options.transaction,\n hash: new Uint8Array(options.transaction.hash),\n });\n }\n}\n\n/**\n * Check whether a value is a {@link ThruputError}, and optionally whether it has\n * a given code. Checks `name` and `code`, not `instanceof`, so it works across\n * realms and with more than one copy of the package.\n *\n * @example\n * ```ts\n * if (isThruputError(error, \"transactionFailed\")) {\n * console.log(error.transaction.receipt);\n * }\n * ```\n */\nexport function isThruputError<\n TCode extends ThruputErrorCode = ThruputErrorCode,\n>(error: unknown, code?: TCode): error is ThruputErrorOf<TCode> {\n return (\n // Error.isError would be realm-safe, but needs Node 24. Check the tag instead.\n Object.prototype.toString.call(error) === \"[object Error]\" &&\n error !== null &&\n typeof error === \"object\" &&\n \"name\" in error &&\n error.name === \"ThruputError\" &&\n \"code\" in error &&\n typeof error.code === \"string\" &&\n (code === undefined || error.code === code)\n );\n}\n","/** An unfamiliar variant is data, never success, absence, or retry permission. */\nexport class UnsupportedRpcValue {\n readonly unsupported = true;\n constructor(readonly raw: unknown) {}\n}\n\n/**\n * Check for an {@link UnsupportedRpcValue} without `instanceof`, so a value\n * from another copy of the package, such as the CJS build, also matches.\n */\nexport function isUnsupportedRpcValue(\n value: unknown,\n): value is UnsupportedRpcValue {\n return (\n value !== null &&\n typeof value === \"object\" &&\n \"unsupported\" in value &&\n value.unsupported === true &&\n \"raw\" in value\n );\n}\n","/** Bounds of protocol integers represented as decimal strings in public JSON. */\nexport const I64_MIN = -(1n << 63n);\nexport const I64_MAX = (1n << 63n) - 1n;\nexport const U64_MAX = (1n << 64n) - 1n;\nexport const I128_MAX = (1n << 127n) - 1n;\nexport const I128_MIN = -(1n << 127n);\nexport const U128_MAX = (1n << 128n) - 1n;\n\n/** Parse a canonical, range-checked decimal string. Numeric JSON is never accepted. */\nexport function parseDecimal(\n value: unknown,\n field: string,\n minimum: bigint,\n maximum: bigint,\n): bigint {\n if (\n typeof value !== \"string\" ||\n value.length >\n Math.max(minimum.toString().length, maximum.toString().length) ||\n !/^(0|-?[1-9][0-9]*)(?![\\s\\S])/.test(value)\n ) {\n throw new Error(`Invalid ${field}: expected a canonical decimal string`);\n }\n const parsed = BigInt(value);\n if (parsed < minimum || parsed > maximum) {\n throw new RangeError(\n `Invalid ${field}: expected an integer from ${minimum} to ${maximum}`,\n );\n }\n return parsed;\n}\n\nexport function parseHeight(value: unknown, field = \"height\"): bigint {\n return parseDecimal(value, field, I64_MIN, I64_MAX);\n}\n\nexport function parseU64(value: unknown, field: string): bigint {\n return parseDecimal(value, field, 0n, U64_MAX);\n}\n\n/** Serialize a caller-owned bigint without passing through a JavaScript number. */\nexport function serializeHeight(value: bigint): string {\n if (typeof value !== \"bigint\" || value < 0n || value > I64_MAX) {\n throw new RangeError(\"height must be a non-negative int64 bigint\");\n }\n return value.toString();\n}\n\nexport function serializeU64(value: bigint, field: string): string {\n if (typeof value !== \"bigint\" || value < 0n || value > U64_MAX) {\n throw new RangeError(`${field} must be a uint64 bigint`);\n }\n return value.toString();\n}\n"],"mappings":";;;;;AAkQA,MAAa,wBAAwB,OAAO,OAAO;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAgD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrMhD,IAAa,eAAb,cAEU,MAAM;CACd,OAAyB;CACzB;CACA;CAIA,YACE,MACA,SAEA,GAAG,CACD,UAAU,CAAC,IAIb;EACA,IACE,CAAC,QAAQ,eACR,sBAA4C,SAAS,IAAI,GAE1D,MAAM,IAAI,UAAU,GAAG,KAAK,4BAA4B;EAC1D,MAAM,SAAS,WAAW,UAAU,EAAE,OAAO,QAAQ,MAA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W,4CAA4C;CAEnE,OAAO,MAAM,SAAS;AACxB;AAEA,SAAgB,aAAa,OAAe,OAAuB;CACjE,IAAI,OAAO,UAAU,YAAY,QAAQ,MAAM,QAAQ,SACrD,MAAM,IAAI,WAAW,GAAG,MAAM,yBAAyB;CAEzD,OAAO,MAAM,SAAS;AACxB"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
//#region src/errors/codes.ts
|
|
2
|
+
/**
|
|
3
|
+
* Codes that always have `transaction` facts. After narrowing to one of these
|
|
4
|
+
* codes, `error.transaction` is required.
|
|
5
|
+
*/
|
|
6
|
+
const transactionErrorCodes = Object.freeze([
|
|
7
|
+
"transactionFailed",
|
|
8
|
+
"transactionOutcomeUnsupported",
|
|
9
|
+
"transactionResultUndecodable",
|
|
10
|
+
"transactionResultUnavailable",
|
|
11
|
+
"transactionNotSubmitted",
|
|
12
|
+
"transactionOutcomeUnknown",
|
|
13
|
+
"transactionAdmissionUnsupported",
|
|
14
|
+
"contractCallFailed"
|
|
15
|
+
]);
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/errors/thruputError.ts
|
|
18
|
+
/**
|
|
19
|
+
* The one error class of the client. Identify an error by its stable `code`
|
|
20
|
+
* with {@link isThruputError}, and read typed data from `context`.
|
|
21
|
+
*
|
|
22
|
+
* The transaction workflows, such as `executeAndWait` and the `sendTransaction`
|
|
23
|
+
* action, add `transaction` facts to every error after signing; raw RPC methods
|
|
24
|
+
* do not. Use `transaction.outcome` to decide what to do: an `unknown` outcome
|
|
25
|
+
* never permits a resend.
|
|
26
|
+
*
|
|
27
|
+
* The client's messages never include the message of a cause from your
|
|
28
|
+
* callbacks or signers; read it from `cause`. A provider wallet's error message
|
|
29
|
+
* is forwarded as the message of its named code. The error freezes
|
|
30
|
+
* `context` and `transaction`, and copies `transaction.hash`; other byte arrays
|
|
31
|
+
* are not copied.
|
|
32
|
+
*
|
|
33
|
+
* Custom transports and tests can construct this class too, for example
|
|
34
|
+
* `new ThruputError("httpRequestFailed", message, { context, cause })`.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* try {
|
|
39
|
+
* await ERC20.v0_1.getBalanceOf.view({
|
|
40
|
+
* client,
|
|
41
|
+
* address: tokenAddress,
|
|
42
|
+
* args: { addr: accountAddress },
|
|
43
|
+
* minStateBlockHeight: receipt.blockHeight,
|
|
44
|
+
* });
|
|
45
|
+
* } catch (error) {
|
|
46
|
+
* if (isThruputError(error, "nativeRpcError") &&
|
|
47
|
+
* error.context.kind === "stateHeightUnavailable") {
|
|
48
|
+
* // Retry later.
|
|
49
|
+
* }
|
|
50
|
+
* throw error;
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
var ThruputError = class extends Error {
|
|
55
|
+
name = "ThruputError";
|
|
56
|
+
code;
|
|
57
|
+
context;
|
|
58
|
+
constructor(code, message, ...[options = {}]) {
|
|
59
|
+
if (!options.transaction && transactionErrorCodes.includes(code)) throw new TypeError(`${code} requires transaction facts`);
|
|
60
|
+
super(message, "cause" in options ? { cause: options.cause } : void 0);
|
|
61
|
+
this.code = code;
|
|
62
|
+
this.context = Object.freeze({ ...options.context });
|
|
63
|
+
if (options.transaction) this.transaction = Object.freeze({
|
|
64
|
+
...options.transaction,
|
|
65
|
+
hash: new Uint8Array(options.transaction.hash)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Check whether a value is a {@link ThruputError}, and optionally whether it has
|
|
71
|
+
* a given code. Checks `name` and `code`, not `instanceof`, so it works across
|
|
72
|
+
* realms and with more than one copy of the package.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* if (isThruputError(error, "transactionFailed")) {
|
|
77
|
+
* console.log(error.transaction.receipt);
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
function isThruputError(error, code) {
|
|
82
|
+
return Object.prototype.toString.call(error) === "[object Error]" && error !== null && typeof error === "object" && "name" in error && error.name === "ThruputError" && "code" in error && typeof error.code === "string" && (code === void 0 || error.code === code);
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/rpc/unsupported.ts
|
|
86
|
+
/** An unfamiliar variant is data, never success, absence, or retry permission. */
|
|
87
|
+
var UnsupportedRpcValue = class {
|
|
88
|
+
raw;
|
|
89
|
+
unsupported = true;
|
|
90
|
+
constructor(raw) {
|
|
91
|
+
this.raw = raw;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Check for an {@link UnsupportedRpcValue} without `instanceof`, so a value
|
|
96
|
+
* from another copy of the package, such as the CJS build, also matches.
|
|
97
|
+
*/
|
|
98
|
+
function isUnsupportedRpcValue(value) {
|
|
99
|
+
return value !== null && typeof value === "object" && "unsupported" in value && value.unsupported === true && "raw" in value;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/actions/decimal.ts
|
|
103
|
+
const I64_MAX = (1n << 63n) - 1n;
|
|
104
|
+
const U64_MAX = (1n << 64n) - 1n;
|
|
105
|
+
/** Parse a canonical, range-checked decimal string. Numeric JSON is never accepted. */
|
|
106
|
+
function parseDecimal(value, field, minimum, maximum) {
|
|
107
|
+
if (typeof value !== "string" || value.length > Math.max(minimum.toString().length, maximum.toString().length) || !/^(0|-?[1-9][0-9]*)(?![\s\S])/.test(value)) throw new Error(`Invalid ${field}: expected a canonical decimal string`);
|
|
108
|
+
const parsed = BigInt(value);
|
|
109
|
+
if (parsed < minimum || parsed > maximum) throw new RangeError(`Invalid ${field}: expected an integer from ${minimum} to ${maximum}`);
|
|
110
|
+
return parsed;
|
|
111
|
+
}
|
|
112
|
+
/** Serialize a caller-owned bigint without passing through a JavaScript number. */
|
|
113
|
+
function serializeHeight(value) {
|
|
114
|
+
if (typeof value !== "bigint" || value < 0n || value > I64_MAX) throw new RangeError("height must be a non-negative int64 bigint");
|
|
115
|
+
return value.toString();
|
|
116
|
+
}
|
|
117
|
+
function serializeU64(value, field) {
|
|
118
|
+
if (typeof value !== "bigint" || value < 0n || value > U64_MAX) throw new RangeError(`${field} must be a uint64 bigint`);
|
|
119
|
+
return value.toString();
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { isUnsupportedRpcValue as a, transactionErrorCodes as c, UnsupportedRpcValue as i, serializeHeight as n, ThruputError as o, serializeU64 as r, isThruputError as s, parseDecimal as t };
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=decimal-CoHOISys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimal-CoHOISys.js","names":[],"sources":["../src/errors/codes.ts","../src/errors/thruputError.ts","../src/rpc/unsupported.ts","../src/actions/decimal.ts"],"sourcesContent":["import type { KnownCommitment } from \"../actions/public/waitForTransactionReceipt.js\";\nimport type { Cluster } from \"../cluster.js\";\nimport type {\n ContractReceiptFailure,\n ContractViewFailure,\n} from \"../contract/method.js\";\nimport type { WalletProviderErrorCode } from \"../provider/types.js\";\nimport type { UnsupportedRpcValue } from \"../rpc/codec.js\";\nimport type {\n RpcErrorData,\n RpcSendTransactionResult,\n} from \"../rpc/generated.js\";\nimport type {\n AirdropResponse,\n EventPage,\n NetworkInfo,\n TransactionRefPage,\n TransactionStatus,\n} from \"../types/rpc.js\";\n\n/** Fields shared by JSON-RPC error contexts. */\nexport interface RpcErrorFields {\n /** JSON-RPC numeric error code. */\n readonly code: number;\n /** The `message` field of the JSON-RPC error object. */\n readonly rpcMessage: string;\n /** The `data` field of the JSON-RPC error object, when present. */\n readonly data?: unknown;\n /** JSON-RPC method of the failed request, when known. */\n readonly method?: string;\n /** Complete original JSON-RPC error object, including additive fields. */\n readonly raw: unknown;\n}\n\n/**\n * A native RPC error. Narrow on `kind` to read typed `data`. The kind\n * `unrecognized` means the error was unknown, malformed, or contradicted the\n * request; `raw` keeps the complete original error.\n */\nexport type NativeRpcErrorContext = Omit<RpcErrorFields, \"data\"> & {\n readonly method: string;\n} & (\n | (RpcErrorData extends infer TData\n ? TData extends { kind: infer TKind }\n ? { readonly kind: TKind; readonly data: TData }\n : never\n : never)\n | { readonly kind: \"unrecognized\"; readonly data?: undefined }\n );\n\n/**\n * What an `rpcIncompatible` error found:\n *\n * - `network`: the endpoint serves another network than the one expected.\n * - `method`: the endpoint does not advertise a method that the call needs.\n * - `wireVersion`: the endpoint uses an RPC wire format this client cannot read.\n * - `limits`: the endpoint does not advertise limits that the call needs.\n * - `commitment`: commitment heights for one transaction do not agree.\n */\nexport type RpcIncompatibleKind =\n | \"network\"\n | \"method\"\n | \"wireVersion\"\n | \"limits\"\n | \"commitment\";\n\n/** The app-layer context of a wallet provider error. */\nexport interface WalletErrorContext {\n /** The EIP-1193-style numeric code from the wallet provider wire contract. */\n readonly providerCode: WalletProviderErrorCode;\n}\n\n/** Context for errors that stop observation of a transaction. */\nexport interface TransactionOutcomeUnknownContext {\n /** Commitment that the client proved before it stopped, when known. */\n readonly knownCommitment?: KnownCommitment;\n /** The last status the node reported, when known. */\n readonly lastStatus?: TransactionStatus;\n /** The submission failure, when observation continued after it. */\n readonly submissionError?: unknown;\n}\n\n/** Context for {@link ThruputErrorContext.fundingStopped}. */\nexport interface FundingStoppedContext {\n readonly request: {\n readonly recipient: Uint8Array;\n /** Use the same nonce to reconcile this attempt. A new nonce can fund twice. */\n readonly clientNonce: Uint8Array;\n readonly networkHash: Uint8Array;\n };\n /** The last faucet response, when the faucet answered. */\n readonly lastResponse?: AirdropResponse;\n /** Commitment that the client proved before it stopped, when known. */\n readonly knownCommitment?: KnownCommitment;\n}\n\n/**\n * The context type for each error code. Each property name is a code.\n *\n * Codes are stable. The client never renames or reuses a code, and never removes\n * a context field. It can add codes and optional fields.\n *\n * Codes use camelCase, like the native RPC error kinds. Node.js and ethers use\n * UPPER_SNAKE; this client keeps one style for all of its string unions.\n *\n * A code names its subject first, then what happened, for example\n * `transactionFailed` or `rpcValueInvalid`. When a code reports a term from a\n * standard, it keeps that term: `rpcError` is a JSON-RPC error object, and\n * `walletInvalidParams` is the JSON-RPC \"Invalid params\" error (-32602).\n *\n * Other packages can add codes through declaration merging:\n *\n * @example\n * ```ts\n * declare module \"@thruputchain/client\" {\n * interface ThruputErrorContext {\n * testkitRunFailed: { readonly step: string };\n * }\n * }\n * ```\n */\nexport interface ThruputErrorContext {\n // Transactions. See `transactionErrorCodes` for the codes that always have `transaction` facts.\n\n /** The receipt shows failed execution. Outcome `failed`. */\n transactionFailed: Record<string, never>;\n /** The receipt has an execution value this client does not support. Outcome `unknown`. */\n transactionOutcomeUnsupported: Record<string, never>;\n /** Execution succeeded, but its return data did not decode. Outcome `succeeded`. */\n transactionResultUndecodable: Record<string, never>;\n /** Execution succeeded, but the wallet does not keep child return data. Outcome `succeeded`. */\n transactionResultUnavailable: Record<string, never>;\n /** The client did not dispatch the signed transaction. Outcome `notSubmitted`. */\n transactionNotSubmitted: Record<string, never>;\n /**\n * Submission or observation stopped before the client knew the outcome.\n * Outcome `unknown`. Never resend; observe `transaction.hash`.\n */\n transactionOutcomeUnknown: TransactionOutcomeUnknownContext;\n /** Submission returned an admission value this client does not support. Outcome `unknown`. */\n transactionAdmissionUnsupported: {\n readonly response: RpcSendTransactionResult;\n };\n /**\n * A faucet request stopped. `transaction` is present when the faucet\n * identified a transaction. Never call the faucet with a new nonce\n * automatically; reconcile with `context.request.clientNonce`. If the node\n * stopped the attempt but returned a successful receipt, the facts have\n * outcome `succeeded` and reason `nodeRejected`.\n */\n fundingStopped: FundingStoppedContext;\n\n // JSON-RPC and transport.\n\n /** The endpoint returned a JSON-RPC error object. */\n rpcError: RpcErrorFields;\n /** A native RPC method returned an error. Narrow on `context.kind`. */\n nativeRpcError: NativeRpcErrorContext;\n /** The HTTP response had a status that is not successful. */\n httpResponseError: {\n readonly status: number;\n readonly statusText: string;\n readonly endpoint?: string;\n readonly method?: string;\n };\n /** The HTTP request failed in the network layer. The endpoint is the URL origin only. */\n httpRequestFailed: {\n readonly endpoint: string;\n readonly method: string;\n };\n /** The JSON-RPC reply was malformed. The write outcome of the request is unknown. */\n rpcResponseInvalid: { readonly raw: unknown };\n /** A known RPC result value was malformed. */\n rpcValueInvalid: { readonly path: string; readonly raw: unknown };\n /** A local RPC request value was invalid. The transport was not called. */\n rpcRequestInvalid: { readonly path: string };\n /**\n * The endpoint, network, or method set does not match what the client\n * requires. Narrow on `context.kind`: for example, `network` means the\n * endpoint serves another network than the one expected. This is what\n * `createThruputClient` throws when a pinned cluster's network does not match.\n */\n rpcIncompatible: { readonly kind: RpcIncompatibleKind };\n /** The endpoint returned a value this client does not support. */\n rpcValueUnsupported: { readonly value: UnsupportedRpcValue };\n /**\n * The network that you pass to `assertNetworkMatchesCluster` does not match\n * the cluster descriptor. `createThruputClient` reports a pinned network that\n * does not match as `rpcIncompatible` with `context.kind` `network`.\n */\n networkMismatch: {\n readonly cluster: Cluster;\n readonly actual: NetworkInfo;\n };\n\n // Contracts.\n\n /** A contract view aborted, faulted, or returned an unsupported outcome. */\n contractViewFailed: {\n /** Qualified method name. */\n readonly method: string;\n readonly entrypoint: Uint8Array;\n readonly outcome: ContractViewFailure<unknown>;\n };\n /**\n * A root contract receipt did not produce a typed return. Has\n * `transaction` facts. Use the method's `decodeError` for the typed exception.\n * When the receipt shows success but the return is unsupported, the facts are\n * outcome `succeeded` with reason `resultUndecodable`.\n */\n contractCallFailed: {\n /** Qualified method name. */\n readonly method: string;\n readonly entrypoint: Uint8Array;\n readonly outcome: ContractReceiptFailure<unknown>;\n };\n /** Contract bytes do not match their declared type. */\n contractDecodeFailed: Record<string, never>;\n /** Retrieved bytes or response metadata failed identity or canonical checks. */\n contractVerificationFailed: Record<string, never>;\n\n // Wallet providers. Each code maps one wire code from the wallet provider contract.\n\n /** Provider code 4001: the user rejected the request. */\n userRejected: WalletErrorContext;\n /** Provider code 4100: unauthorized origin or account, stale session, or no matching approval. */\n walletUnauthorized: WalletErrorContext;\n /** Provider code 4200: the provider does not support the method. */\n walletMethodUnsupported: WalletErrorContext;\n /** Provider code 4900: the provider is disconnected or its transport is unavailable. */\n walletDisconnected: WalletErrorContext;\n /** Provider code 4901: the wallet network does not match. */\n walletNetworkMismatch: WalletErrorContext;\n /** Provider code -32602: invalid parameters, noncanonical encoding, or exceeded limits. */\n walletInvalidParams: WalletErrorContext;\n /** Provider code -32603: internal error or invalid provider result. */\n walletInternalError: WalletErrorContext;\n /** Provider code -32002: another operation is pending. */\n walletRequestPending: WalletErrorContext;\n\n // Other.\n\n /** `parseUnits` received a malformed amount or too many decimal places. */\n amountInvalid: {\n readonly kind: \"malformed\" | \"precision\";\n readonly decimals: number;\n };\n /** History pages broke ordering, cursor, or identity rules across pages. */\n historyWalkFailed: { readonly page: EventPage | TransactionRefPage };\n}\n\n/** A stable error code. */\nexport type ThruputErrorCode = keyof ThruputErrorContext & string;\n\n/**\n * Codes that always have `transaction` facts. After narrowing to one of these\n * codes, `error.transaction` is required.\n */\nexport const transactionErrorCodes = Object.freeze([\n \"transactionFailed\",\n \"transactionOutcomeUnsupported\",\n \"transactionResultUndecodable\",\n \"transactionResultUnavailable\",\n \"transactionNotSubmitted\",\n \"transactionOutcomeUnknown\",\n \"transactionAdmissionUnsupported\",\n \"contractCallFailed\",\n] as const satisfies readonly ThruputErrorCode[]);\n\n/** A code that always has `transaction` facts. */\nexport type TransactionErrorCode = (typeof transactionErrorCodes)[number];\n","import {\n transactionErrorCodes,\n type ThruputErrorCode,\n type ThruputErrorContext,\n type TransactionErrorCode,\n} from \"./codes.js\";\nimport type { TransactionFacts, TransactionFactsInput } from \"./transaction.js\";\n\n/**\n * Options for a {@link ThruputError}. `context` is required when the code's\n * context has required fields.\n */\nexport type ThruputErrorOptions<TCode extends ThruputErrorCode> = {\n readonly cause?: unknown;\n /**\n * Facts about the signed transaction. Required for each\n * {@link TransactionErrorCode}, and supplied on every error after signing.\n */\n readonly transaction?: TransactionFactsInput;\n} & ({} extends ThruputErrorContext[TCode]\n ? { readonly context?: ThruputErrorContext[TCode] }\n : { readonly context: ThruputErrorContext[TCode] });\n\n/**\n * A {@link ThruputError} for one of the given codes, narrowable on `code`.\n * `transaction` is required for each {@link TransactionErrorCode}.\n */\nexport type ThruputErrorOf<TCode extends ThruputErrorCode = ThruputErrorCode> =\n {\n [K in TCode]: K extends TransactionErrorCode\n ? ThruputError<K> & { readonly transaction: TransactionFacts }\n : ThruputError<K>;\n }[TCode];\n\n/**\n * The one error class of the client. Identify an error by its stable `code`\n * with {@link isThruputError}, and read typed data from `context`.\n *\n * The transaction workflows, such as `executeAndWait` and the `sendTransaction`\n * action, add `transaction` facts to every error after signing; raw RPC methods\n * do not. Use `transaction.outcome` to decide what to do: an `unknown` outcome\n * never permits a resend.\n *\n * The client's messages never include the message of a cause from your\n * callbacks or signers; read it from `cause`. A provider wallet's error message\n * is forwarded as the message of its named code. The error freezes\n * `context` and `transaction`, and copies `transaction.hash`; other byte arrays\n * are not copied.\n *\n * Custom transports and tests can construct this class too, for example\n * `new ThruputError(\"httpRequestFailed\", message, { context, cause })`.\n *\n * @example\n * ```ts\n * try {\n * await ERC20.v0_1.getBalanceOf.view({\n * client,\n * address: tokenAddress,\n * args: { addr: accountAddress },\n * minStateBlockHeight: receipt.blockHeight,\n * });\n * } catch (error) {\n * if (isThruputError(error, \"nativeRpcError\") &&\n * error.context.kind === \"stateHeightUnavailable\") {\n * // Retry later.\n * }\n * throw error;\n * }\n * ```\n */\nexport class ThruputError<\n TCode extends ThruputErrorCode = ThruputErrorCode,\n> extends Error {\n override readonly name = \"ThruputError\" as const;\n readonly code: TCode;\n readonly context: ThruputErrorContext[TCode];\n // `declare` keeps an absent field from becoming an own `undefined` property.\n declare readonly transaction?: TransactionFacts;\n\n constructor(\n code: TCode,\n message: string,\n // Options can be left out only when the code needs no context.\n ...[\n options = {} as ThruputErrorOptions<TCode>,\n ]: {} extends ThruputErrorContext[TCode]\n ? [options?: ThruputErrorOptions<TCode>]\n : [options: ThruputErrorOptions<TCode>]\n ) {\n if (\n !options.transaction &&\n (transactionErrorCodes as readonly string[]).includes(code)\n )\n throw new TypeError(`${code} requires transaction facts`);\n super(message, \"cause\" in options ? { cause: options.cause } : undefined);\n this.code = code;\n this.context = Object.freeze({\n ...options.context,\n }) as ThruputErrorContext[TCode];\n // Copy the hash, the fact an app keeps to observe the transaction.\n if (options.transaction)\n this.transaction = Object.freeze({\n ...options.transaction,\n hash: new Uint8Array(options.transaction.hash),\n });\n }\n}\n\n/**\n * Check whether a value is a {@link ThruputError}, and optionally whether it has\n * a given code. Checks `name` and `code`, not `instanceof`, so it works across\n * realms and with more than one copy of the package.\n *\n * @example\n * ```ts\n * if (isThruputError(error, \"transactionFailed\")) {\n * console.log(error.transaction.receipt);\n * }\n * ```\n */\nexport function isThruputError<\n TCode extends ThruputErrorCode = ThruputErrorCode,\n>(error: unknown, code?: TCode): error is ThruputErrorOf<TCode> {\n return (\n // Error.isError would be realm-safe, but needs Node 24. Check the tag instead.\n Object.prototype.toString.call(error) === \"[object Error]\" &&\n error !== null &&\n typeof error === \"object\" &&\n \"name\" in error &&\n error.name === \"ThruputError\" &&\n \"code\" in error &&\n typeof error.code === \"string\" &&\n (code === undefined || error.code === code)\n );\n}\n","/** An unfamiliar variant is data, never success, absence, or retry permission. */\nexport class UnsupportedRpcValue {\n readonly unsupported = true;\n constructor(readonly raw: unknown) {}\n}\n\n/**\n * Check for an {@link UnsupportedRpcValue} without `instanceof`, so a value\n * from another copy of the package, such as the CJS build, also matches.\n */\nexport function isUnsupportedRpcValue(\n value: unknown,\n): value is UnsupportedRpcValue {\n return (\n value !== null &&\n typeof value === \"object\" &&\n \"unsupported\" in value &&\n value.unsupported === true &&\n \"raw\" in value\n );\n}\n","/** Bounds of protocol integers represented as decimal strings in public JSON. */\nexport const I64_MIN = -(1n << 63n);\nexport const I64_MAX = (1n << 63n) - 1n;\nexport const U64_MAX = (1n << 64n) - 1n;\nexport const I128_MAX = (1n << 127n) - 1n;\nexport const I128_MIN = -(1n << 127n);\nexport const U128_MAX = (1n << 128n) - 1n;\n\n/** Parse a canonical, range-checked decimal string. Numeric JSON is never accepted. */\nexport function parseDecimal(\n value: unknown,\n field: string,\n minimum: bigint,\n maximum: bigint,\n): bigint {\n if (\n typeof value !== \"string\" ||\n value.length >\n Math.max(minimum.toString().length, maximum.toString().length) ||\n !/^(0|-?[1-9][0-9]*)(?![\\s\\S])/.test(value)\n ) {\n throw new Error(`Invalid ${field}: expected a canonical decimal string`);\n }\n const parsed = BigInt(value);\n if (parsed < minimum || parsed > maximum) {\n throw new RangeError(\n `Invalid ${field}: expected an integer from ${minimum} to ${maximum}`,\n );\n }\n return parsed;\n}\n\nexport function parseHeight(value: unknown, field = \"height\"): bigint {\n return parseDecimal(value, field, I64_MIN, I64_MAX);\n}\n\nexport function parseU64(value: unknown, field: string): bigint {\n return parseDecimal(value, field, 0n, U64_MAX);\n}\n\n/** Serialize a caller-owned bigint without passing through a JavaScript number. */\nexport function serializeHeight(value: bigint): string {\n if (typeof value !== \"bigint\" || value < 0n || value > I64_MAX) {\n throw new RangeError(\"height must be a non-negative int64 bigint\");\n }\n return value.toString();\n}\n\nexport function serializeU64(value: bigint, field: string): string {\n if (typeof value !== \"bigint\" || value < 0n || value > U64_MAX) {\n throw new RangeError(`${field} must be a uint64 bigint`);\n }\n return value.toString();\n}\n"],"mappings":";;;;;AAkQA,MAAa,wBAAwB,OAAO,OAAO;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAgD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrMhD,IAAa,eAAb,cAEU,MAAM;CACd,OAAyB;CACzB;CACA;CAIA,YACE,MACA,SAEA,GAAG,CACD,UAAU,CAAC,IAIb;EACA,IACE,CAAC,QAAQ,eACR,sBAA4C,SAAS,IAAI,GAE1D,MAAM,IAAI,UAAU,GAAG,KAAK,4BAA4B;EAC1D,MAAM,SAAS,WAAW,UAAU,EAAE,OAAO,QAAQ,MAAM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,4CAA4C;CAEnE,OAAO,MAAM,SAAS;AACxB;AAEA,SAAgB,aAAa,OAAe,OAAuB;CACjE,IAAI,OAAO,UAAU,YAAY,QAAQ,MAAM,QAAQ,SACrD,MAAM,IAAI,WAAW,GAAG,MAAM,yBAAyB;CAEzD,OAAO,MAAM,SAAS;AACxB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Bt as ContractSpec, F as ContractException, R as ContractMethod } from "./requestAirdrop-DBCOST2B.js";
|
|
2
|
+
import { n as FixedBytes } from "./index-BmOG68Hd.js";
|
|
3
|
+
import * as __gh_protocol from "@thruputchain/protocol";
|
|
4
|
+
|
|
5
|
+
//#region src/contracts/default_wallet.d.ts
|
|
6
|
+
declare namespace default_wallet {
|
|
7
|
+
namespace v0_1 {
|
|
8
|
+
namespace $interface {
|
|
9
|
+
interface WalletCall {
|
|
10
|
+
target: __gh_protocol.ContractAddress;
|
|
11
|
+
entrypoint: FixedBytes<8>;
|
|
12
|
+
gas_limit: bigint;
|
|
13
|
+
calldata: globalThis.Uint8Array;
|
|
14
|
+
tokens: __gh_codegen.default_wallet$v0_1$$interface$WalletTokenRef[];
|
|
15
|
+
}
|
|
16
|
+
type WalletError = 1n | 2n | 3n | 4n | 5n | 6n | 7n | 8n | 9n;
|
|
17
|
+
interface WalletInitCall {
|
|
18
|
+
entrypoint: FixedBytes<8>;
|
|
19
|
+
gas_limit: bigint;
|
|
20
|
+
calldata: globalThis.Uint8Array;
|
|
21
|
+
}
|
|
22
|
+
type WalletTokenRef = {
|
|
23
|
+
case: "Minted";
|
|
24
|
+
value: readonly [bigint];
|
|
25
|
+
} | {
|
|
26
|
+
case: "Returned";
|
|
27
|
+
value: {
|
|
28
|
+
call: bigint;
|
|
29
|
+
index: bigint;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
declare namespace DefaultWallet {
|
|
36
|
+
namespace v0_1 {
|
|
37
|
+
interface DeployArgs {
|
|
38
|
+
nonce: FixedBytes<32>;
|
|
39
|
+
contractHash: FixedBytes<32>;
|
|
40
|
+
amount: bigint;
|
|
41
|
+
initializer: __gh_codegen.default_wallet$v0_1$$interface$WalletInitCall | null;
|
|
42
|
+
}
|
|
43
|
+
type DeployResult = __gh_protocol.ContractAddress;
|
|
44
|
+
interface ExecuteArgs {
|
|
45
|
+
mints: globalThis.Uint8Array[];
|
|
46
|
+
calls: __gh_codegen.default_wallet$v0_1$$interface$WalletCall[];
|
|
47
|
+
}
|
|
48
|
+
type ExecuteResult = globalThis.Uint8Array[];
|
|
49
|
+
type DeclaredException = {
|
|
50
|
+
kind: "declared";
|
|
51
|
+
name: "WalletError";
|
|
52
|
+
selector: 0x931d3297d37d1bdfn;
|
|
53
|
+
value: __gh_codegen.default_wallet$v0_1$$interface$WalletError;
|
|
54
|
+
};
|
|
55
|
+
type Exception = ContractException<DeclaredException>;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
declare const spec: ContractSpec;
|
|
59
|
+
declare const DefaultWallet: {
|
|
60
|
+
readonly v0_1: {
|
|
61
|
+
readonly deploy: ContractMethod<DefaultWallet.v0_1.DeployArgs, __gh_protocol.ContractAddress, DefaultWallet.v0_1.DeclaredException>;
|
|
62
|
+
readonly execute: ContractMethod<DefaultWallet.v0_1.ExecuteArgs, DefaultWallet.v0_1.ExecuteResult, DefaultWallet.v0_1.DeclaredException>;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
declare const default_wallet: {
|
|
66
|
+
readonly v0_1: {
|
|
67
|
+
readonly $interface: {
|
|
68
|
+
readonly WalletError: {
|
|
69
|
+
readonly NotRootInvocation: 1n;
|
|
70
|
+
readonly InvalidAuthClaim: 2n;
|
|
71
|
+
readonly EmptyCallList: 3n;
|
|
72
|
+
readonly TooManyCalls: 4n;
|
|
73
|
+
readonly CallAborted: 5n;
|
|
74
|
+
readonly CallFaulted: 6n;
|
|
75
|
+
readonly ReturnDataTooLarge: 7n;
|
|
76
|
+
readonly InvalidTokenRef: 8n;
|
|
77
|
+
readonly TokenAlreadyForwarded: 9n;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
declare namespace __gh_codegen {
|
|
83
|
+
type default_wallet$v0_1$$interface$WalletCall = default_wallet.v0_1.$interface.WalletCall;
|
|
84
|
+
type default_wallet$v0_1$$interface$WalletError = default_wallet.v0_1.$interface.WalletError;
|
|
85
|
+
type default_wallet$v0_1$$interface$WalletInitCall = default_wallet.v0_1.$interface.WalletInitCall;
|
|
86
|
+
type default_wallet$v0_1$$interface$WalletTokenRef = default_wallet.v0_1.$interface.WalletTokenRef;
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
export { default_wallet as n, spec as r, DefaultWallet as t };
|
|
90
|
+
//# sourceMappingURL=default_wallet-DkqsCa5C.d.ts.map
|