@thruputchain/client 0.27.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 +120 -22
- package/dist/{actions-DK_XBeVy.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-Cu8Qv94_.js → contract-BOlNskwd.js} +235 -87
- package/dist/contract-BOlNskwd.js.map +1 -0
- package/dist/{contract-DPm2BJTu.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-BcvX_xT4.cjs → dev_wallet-BVChhV6j.cjs} +85 -6
- package/dist/dev_wallet-BVChhV6j.cjs.map +1 -0
- package/dist/{dev_wallet-B5R5JJaw.js → dev_wallet-D9LuPZ-h.js} +84 -5
- package/dist/dev_wallet-D9LuPZ-h.js.map +1 -0
- package/dist/{execution-C8oQgpO3.d.cts → execution-pSt6k620.d.cts} +23 -50
- package/dist/execution-pSt6k620.d.cts.map +1 -0
- package/dist/{execution-DsZzqv_C.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-rrP1HJ2Z.d.cts → index-B1efA-Y_.d.ts} +24 -21
- package/dist/index-B1efA-Y_.d.ts.map +1 -0
- package/dist/{index-Zaz-e8Sy.d.ts → index-BGmH_Sm7.d.cts} +12 -62
- package/dist/index-BGmH_Sm7.d.cts.map +1 -0
- package/dist/{index-CHnfHuQo.d.ts → index-BZ5j5P5d.d.ts} +11 -9
- package/dist/index-BZ5j5P5d.d.ts.map +1 -0
- package/dist/{index-BmQN3jAS.d.cts → index-BfYEEVHm.d.cts} +3 -13
- package/dist/index-BfYEEVHm.d.cts.map +1 -0
- package/dist/{index-CuzB95QT.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-hqEnT64w.d.ts → index-Btl_jMCT.d.ts} +3 -13
- package/dist/index-Btl_jMCT.d.ts.map +1 -0
- package/dist/{index-C3qDR1J5.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-CKqC9N4o.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-BOjoJjC5.js → readError-B3Rz7rgs.js} +673 -56
- package/dist/readError-B3Rz7rgs.js.map +1 -0
- package/dist/{codec-C4LJ0g8v.cjs → readError-COcEDNoZ.cjs} +677 -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-BDUZhfJn.cjs → signedOp-CVyeJ5ig.cjs} +3 -3
- package/dist/{signedOp-BDUZhfJn.cjs.map → signedOp-CVyeJ5ig.cjs.map} +1 -1
- package/dist/{signedOp-Kx8u8_3I.js → signedOp-D6WYZG9j.js} +3 -3
- package/dist/{signedOp-Kx8u8_3I.js.map → signedOp-D6WYZG9j.js.map} +1 -1
- package/dist/{signed_op-CAcYYRm6.cjs → signed_op-BBsDKOlD.cjs} +4 -4
- package/dist/{signed_op-CAcYYRm6.cjs.map → signed_op-BBsDKOlD.cjs.map} +1 -1
- package/dist/{signed_op-BrLxDrDb.d.cts → signed_op-BvbOHWKK.d.ts} +3 -3
- package/dist/{signed_op-DbRq3_Hb.d.ts.map → signed_op-BvbOHWKK.d.ts.map} +1 -1
- package/dist/{signed_op-DbRq3_Hb.d.ts → signed_op-DoHFpSH4.d.cts} +3 -3
- package/dist/{signed_op-BrLxDrDb.d.cts.map → signed_op-DoHFpSH4.d.cts.map} +1 -1
- package/dist/{signed_op-Dxn7-lRu.js → signed_op-h9X9-vBL.js} +3 -3
- package/dist/{signed_op-Dxn7-lRu.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-5wt9wLG3.js → wallet-NlZiI4-3.js} +161 -77
- package/dist/wallet-NlZiI4-3.js.map +1 -0
- package/dist/{wallet-Blh7oas7.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-1LmkZcfS.js +0 -430
- package/dist/actions-1LmkZcfS.js.map +0 -1
- package/dist/actions-DK_XBeVy.cjs.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-DocSdzOL.d.cts +0 -790
- package/dist/client-DocSdzOL.d.cts.map +0 -1
- package/dist/client-DocSdzOL.d.ts +0 -790
- package/dist/client-DocSdzOL.d.ts.map +0 -1
- package/dist/codec-BOjoJjC5.js.map +0 -1
- package/dist/codec-C4LJ0g8v.cjs.map +0 -1
- package/dist/contract-Cu8Qv94_.js.map +0 -1
- package/dist/contract-DPm2BJTu.cjs.map +0 -1
- package/dist/dev_wallet-B5R5JJaw.js.map +0 -1
- package/dist/dev_wallet-BcvX_xT4.cjs.map +0 -1
- package/dist/execution-C8oQgpO3.d.cts.map +0 -1
- package/dist/execution-DsZzqv_C.d.ts.map +0 -1
- package/dist/index-BmQN3jAS.d.cts.map +0 -1
- package/dist/index-C3qDR1J5.d.cts.map +0 -1
- package/dist/index-CHnfHuQo.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-CKqC9N4o.d.ts.map +0 -1
- package/dist/index-CuzB95QT.d.cts.map +0 -1
- package/dist/index-Zaz-e8Sy.d.ts.map +0 -1
- package/dist/index-hqEnT64w.d.ts.map +0 -1
- package/dist/index-rrP1HJ2Z.d.cts.map +0 -1
- package/dist/readError-Cz3bveZa.cjs +0 -622
- package/dist/readError-Cz3bveZa.cjs.map +0 -1
- package/dist/readError-Z5zuylri.js +0 -569
- package/dist/readError-Z5zuylri.js.map +0 -1
- package/dist/readViews-BvMHbiaF.d.ts +0 -609
- package/dist/readViews-BvMHbiaF.d.ts.map +0 -1
- package/dist/readViews-CQOY5v4o.d.cts +0 -609
- package/dist/readViews-CQOY5v4o.d.cts.map +0 -1
- package/dist/sendInvocation-8TEMrJ_M.cjs +0 -661
- package/dist/sendInvocation-8TEMrJ_M.cjs.map +0 -1
- package/dist/sendInvocation-CkeMyLk1.js +0 -505
- package/dist/sendInvocation-CkeMyLk1.js.map +0 -1
- package/dist/transport-DqlfAsuH.cjs +0 -279
- package/dist/transport-DqlfAsuH.cjs.map +0 -1
- package/dist/transport-PstrCcBv.js +0 -261
- package/dist/transport-PstrCcBv.js.map +0 -1
- package/dist/validation-4w-vDGAi.cjs.map +0 -1
- package/dist/validation-eXATmgO0.js.map +0 -1
- package/dist/wallet-5wt9wLG3.js.map +0 -1
- package/dist/wallet-Blh7oas7.cjs.map +0 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as UnsupportedRpcValue, o as ThruputError, s as isThruputError, t as parseDecimal } from "./decimal-CoHOISys.js";
|
|
2
|
+
import { g as toBase58, i as toHex0x, n as fromHex0x, s as fixedFromBase58 } from "./hex-B8D-jBgz.js";
|
|
3
|
+
import { t as hashSignedTransaction } from "./transactionHash-CO9ajbvU.js";
|
|
4
|
+
import { codec, deserialize } from "@thruputchain/protocol";
|
|
2
5
|
//#region src/rpc/schema.json
|
|
3
6
|
var schema_default = {
|
|
4
7
|
schemas: {
|
|
@@ -357,6 +360,14 @@ var schema_default = {
|
|
|
357
360
|
"required": ["order"],
|
|
358
361
|
"type": "object"
|
|
359
362
|
},
|
|
363
|
+
"BlockTimeStep": {
|
|
364
|
+
"properties": {
|
|
365
|
+
"nextBlockTimepoint": { "$ref": "#/components/schemas/DecimalTimePoint" },
|
|
366
|
+
"stepNanoseconds": { "$ref": "#/components/schemas/DecimalU64" }
|
|
367
|
+
},
|
|
368
|
+
"required": ["nextBlockTimepoint"],
|
|
369
|
+
"type": "object"
|
|
370
|
+
},
|
|
360
371
|
"ChainConfig": {
|
|
361
372
|
"properties": {
|
|
362
373
|
"execution": { "$ref": "#/components/schemas/ExecutionConfig" },
|
|
@@ -2103,6 +2114,22 @@ var schema_default = {
|
|
|
2103
2114
|
"result": { "$ref": "#/components/schemas/BlockClock" },
|
|
2104
2115
|
"paged": false
|
|
2105
2116
|
},
|
|
2117
|
+
"dev_setBlockTimeStep": {
|
|
2118
|
+
"params": {
|
|
2119
|
+
"type": "object",
|
|
2120
|
+
"additionalProperties": false,
|
|
2121
|
+
"properties": { "stepNanoseconds": {
|
|
2122
|
+
"maxLength": 20,
|
|
2123
|
+
"pattern": "^(0|[1-9][0-9]*)(?![\\s\\S])",
|
|
2124
|
+
"type": "string",
|
|
2125
|
+
"x-integer-maximum": "18446744073709551615",
|
|
2126
|
+
"x-integer-minimum": "0"
|
|
2127
|
+
} },
|
|
2128
|
+
"required": []
|
|
2129
|
+
},
|
|
2130
|
+
"result": { "$ref": "#/components/schemas/BlockTimeStep" },
|
|
2131
|
+
"paged": false
|
|
2132
|
+
},
|
|
2106
2133
|
"dev_setBlockDriver": {
|
|
2107
2134
|
"params": {
|
|
2108
2135
|
"type": "object",
|
|
@@ -10631,6 +10658,296 @@ var schema_default = {
|
|
|
10631
10658
|
}
|
|
10632
10659
|
}
|
|
10633
10660
|
],
|
|
10661
|
+
"dev_setBlockTimeStep": [
|
|
10662
|
+
{
|
|
10663
|
+
"code": -32602,
|
|
10664
|
+
"schema": {
|
|
10665
|
+
"oneOf": [{
|
|
10666
|
+
"properties": {
|
|
10667
|
+
"kind": {
|
|
10668
|
+
"const": "invalidParams",
|
|
10669
|
+
"type": "string"
|
|
10670
|
+
},
|
|
10671
|
+
"path": {
|
|
10672
|
+
"pattern": "^(?:/(?:[^~/]|~[01])*)*(?![\\s\\S])",
|
|
10673
|
+
"type": "string"
|
|
10674
|
+
},
|
|
10675
|
+
"reason": { "type": "string" }
|
|
10676
|
+
},
|
|
10677
|
+
"required": ["kind"],
|
|
10678
|
+
"type": "object",
|
|
10679
|
+
"x-forbidden": [
|
|
10680
|
+
"admission",
|
|
10681
|
+
"transactionHash",
|
|
10682
|
+
"signedTransaction",
|
|
10683
|
+
"observation",
|
|
10684
|
+
"receipt",
|
|
10685
|
+
"cause",
|
|
10686
|
+
"serviceCode",
|
|
10687
|
+
"error"
|
|
10688
|
+
]
|
|
10689
|
+
}],
|
|
10690
|
+
"x-tag": "kind"
|
|
10691
|
+
}
|
|
10692
|
+
},
|
|
10693
|
+
{
|
|
10694
|
+
"code": -32050,
|
|
10695
|
+
"schema": {
|
|
10696
|
+
"oneOf": [{
|
|
10697
|
+
"properties": {
|
|
10698
|
+
"admission": {
|
|
10699
|
+
"enum": [
|
|
10700
|
+
"notAttempted",
|
|
10701
|
+
"rejected",
|
|
10702
|
+
"unknown"
|
|
10703
|
+
],
|
|
10704
|
+
"type": "string"
|
|
10705
|
+
},
|
|
10706
|
+
"error": {
|
|
10707
|
+
"properties": {
|
|
10708
|
+
"code": {
|
|
10709
|
+
"maximum": 2147483647,
|
|
10710
|
+
"minimum": -2147483648,
|
|
10711
|
+
"type": "integer"
|
|
10712
|
+
},
|
|
10713
|
+
"source": {
|
|
10714
|
+
"anyOf": [{
|
|
10715
|
+
"enum": [
|
|
10716
|
+
"auth",
|
|
10717
|
+
"scheduler",
|
|
10718
|
+
"executor",
|
|
10719
|
+
"other"
|
|
10720
|
+
],
|
|
10721
|
+
"type": "string"
|
|
10722
|
+
}],
|
|
10723
|
+
"x-extensible": true
|
|
10724
|
+
}
|
|
10725
|
+
},
|
|
10726
|
+
"required": ["source", "code"],
|
|
10727
|
+
"type": "object"
|
|
10728
|
+
},
|
|
10729
|
+
"kind": {
|
|
10730
|
+
"const": "backendUnavailable",
|
|
10731
|
+
"type": "string"
|
|
10732
|
+
},
|
|
10733
|
+
"retryAfterMs": {
|
|
10734
|
+
"maxLength": 20,
|
|
10735
|
+
"pattern": "^(0|[1-9][0-9]*)(?![\\s\\S])",
|
|
10736
|
+
"type": "string",
|
|
10737
|
+
"x-integer-maximum": "18446744073709551615",
|
|
10738
|
+
"x-integer-minimum": "0"
|
|
10739
|
+
},
|
|
10740
|
+
"serviceCode": {
|
|
10741
|
+
"maxLength": 128,
|
|
10742
|
+
"minLength": 1,
|
|
10743
|
+
"type": "string"
|
|
10744
|
+
},
|
|
10745
|
+
"transactionHash": {
|
|
10746
|
+
"maxLength": 45,
|
|
10747
|
+
"minLength": 32,
|
|
10748
|
+
"pattern": "^[1-9A-HJ-NP-Za-km-z]+$",
|
|
10749
|
+
"type": "string",
|
|
10750
|
+
"x-base58-bytes": 32
|
|
10751
|
+
}
|
|
10752
|
+
},
|
|
10753
|
+
"required": ["kind"],
|
|
10754
|
+
"type": "object",
|
|
10755
|
+
"x-forbidden": [
|
|
10756
|
+
"admission",
|
|
10757
|
+
"transactionHash",
|
|
10758
|
+
"signedTransaction",
|
|
10759
|
+
"observation",
|
|
10760
|
+
"receipt",
|
|
10761
|
+
"cause",
|
|
10762
|
+
"serviceCode",
|
|
10763
|
+
"error"
|
|
10764
|
+
]
|
|
10765
|
+
}],
|
|
10766
|
+
"x-tag": "kind"
|
|
10767
|
+
}
|
|
10768
|
+
},
|
|
10769
|
+
{
|
|
10770
|
+
"code": -32051,
|
|
10771
|
+
"schema": {
|
|
10772
|
+
"oneOf": [{
|
|
10773
|
+
"properties": {
|
|
10774
|
+
"admission": {
|
|
10775
|
+
"enum": [
|
|
10776
|
+
"notAttempted",
|
|
10777
|
+
"rejected",
|
|
10778
|
+
"unknown"
|
|
10779
|
+
],
|
|
10780
|
+
"type": "string"
|
|
10781
|
+
},
|
|
10782
|
+
"kind": {
|
|
10783
|
+
"const": "backendTimeout",
|
|
10784
|
+
"type": "string"
|
|
10785
|
+
},
|
|
10786
|
+
"retryAfterMs": {
|
|
10787
|
+
"maxLength": 20,
|
|
10788
|
+
"pattern": "^(0|[1-9][0-9]*)(?![\\s\\S])",
|
|
10789
|
+
"type": "string",
|
|
10790
|
+
"x-integer-maximum": "18446744073709551615",
|
|
10791
|
+
"x-integer-minimum": "0"
|
|
10792
|
+
},
|
|
10793
|
+
"transactionHash": {
|
|
10794
|
+
"maxLength": 45,
|
|
10795
|
+
"minLength": 32,
|
|
10796
|
+
"pattern": "^[1-9A-HJ-NP-Za-km-z]+$",
|
|
10797
|
+
"type": "string",
|
|
10798
|
+
"x-base58-bytes": 32
|
|
10799
|
+
}
|
|
10800
|
+
},
|
|
10801
|
+
"required": ["kind"],
|
|
10802
|
+
"type": "object",
|
|
10803
|
+
"x-forbidden": [
|
|
10804
|
+
"admission",
|
|
10805
|
+
"transactionHash",
|
|
10806
|
+
"signedTransaction",
|
|
10807
|
+
"observation",
|
|
10808
|
+
"receipt",
|
|
10809
|
+
"cause",
|
|
10810
|
+
"serviceCode",
|
|
10811
|
+
"error"
|
|
10812
|
+
]
|
|
10813
|
+
}],
|
|
10814
|
+
"x-tag": "kind"
|
|
10815
|
+
}
|
|
10816
|
+
},
|
|
10817
|
+
{
|
|
10818
|
+
"code": -32053,
|
|
10819
|
+
"schema": {
|
|
10820
|
+
"oneOf": [{
|
|
10821
|
+
"properties": {
|
|
10822
|
+
"admission": {
|
|
10823
|
+
"enum": [
|
|
10824
|
+
"notAttempted",
|
|
10825
|
+
"rejected",
|
|
10826
|
+
"unknown"
|
|
10827
|
+
],
|
|
10828
|
+
"type": "string"
|
|
10829
|
+
},
|
|
10830
|
+
"error": {
|
|
10831
|
+
"properties": {
|
|
10832
|
+
"code": {
|
|
10833
|
+
"maximum": 2147483647,
|
|
10834
|
+
"minimum": -2147483648,
|
|
10835
|
+
"type": "integer"
|
|
10836
|
+
},
|
|
10837
|
+
"source": {
|
|
10838
|
+
"anyOf": [{
|
|
10839
|
+
"enum": [
|
|
10840
|
+
"auth",
|
|
10841
|
+
"scheduler",
|
|
10842
|
+
"executor",
|
|
10843
|
+
"other"
|
|
10844
|
+
],
|
|
10845
|
+
"type": "string"
|
|
10846
|
+
}],
|
|
10847
|
+
"x-extensible": true
|
|
10848
|
+
}
|
|
10849
|
+
},
|
|
10850
|
+
"required": ["source", "code"],
|
|
10851
|
+
"type": "object"
|
|
10852
|
+
},
|
|
10853
|
+
"kind": {
|
|
10854
|
+
"const": "overloaded",
|
|
10855
|
+
"type": "string"
|
|
10856
|
+
},
|
|
10857
|
+
"retryAfterMs": {
|
|
10858
|
+
"maxLength": 20,
|
|
10859
|
+
"pattern": "^(0|[1-9][0-9]*)(?![\\s\\S])",
|
|
10860
|
+
"type": "string",
|
|
10861
|
+
"x-integer-maximum": "18446744073709551615",
|
|
10862
|
+
"x-integer-minimum": "0"
|
|
10863
|
+
},
|
|
10864
|
+
"transactionHash": {
|
|
10865
|
+
"maxLength": 45,
|
|
10866
|
+
"minLength": 32,
|
|
10867
|
+
"pattern": "^[1-9A-HJ-NP-Za-km-z]+$",
|
|
10868
|
+
"type": "string",
|
|
10869
|
+
"x-base58-bytes": 32
|
|
10870
|
+
}
|
|
10871
|
+
},
|
|
10872
|
+
"required": ["kind"],
|
|
10873
|
+
"type": "object",
|
|
10874
|
+
"x-forbidden": [
|
|
10875
|
+
"admission",
|
|
10876
|
+
"transactionHash",
|
|
10877
|
+
"signedTransaction",
|
|
10878
|
+
"observation",
|
|
10879
|
+
"receipt",
|
|
10880
|
+
"cause",
|
|
10881
|
+
"serviceCode",
|
|
10882
|
+
"error"
|
|
10883
|
+
]
|
|
10884
|
+
}],
|
|
10885
|
+
"x-tag": "kind"
|
|
10886
|
+
}
|
|
10887
|
+
},
|
|
10888
|
+
{
|
|
10889
|
+
"code": -32054,
|
|
10890
|
+
"schema": {
|
|
10891
|
+
"oneOf": [{
|
|
10892
|
+
"properties": {
|
|
10893
|
+
"admission": {
|
|
10894
|
+
"enum": [
|
|
10895
|
+
"notAttempted",
|
|
10896
|
+
"rejected",
|
|
10897
|
+
"unknown"
|
|
10898
|
+
],
|
|
10899
|
+
"type": "string"
|
|
10900
|
+
},
|
|
10901
|
+
"kind": {
|
|
10902
|
+
"const": "backendDataInvalid",
|
|
10903
|
+
"type": "string"
|
|
10904
|
+
},
|
|
10905
|
+
"observation": {
|
|
10906
|
+
"properties": {
|
|
10907
|
+
"blockHeight": {
|
|
10908
|
+
"maxLength": 19,
|
|
10909
|
+
"pattern": "^(0|[1-9][0-9]*)(?![\\s\\S])",
|
|
10910
|
+
"type": "string",
|
|
10911
|
+
"x-integer-maximum": "9223372036854775807",
|
|
10912
|
+
"x-integer-minimum": "0"
|
|
10913
|
+
},
|
|
10914
|
+
"transactionHash": {
|
|
10915
|
+
"maxLength": 45,
|
|
10916
|
+
"minLength": 32,
|
|
10917
|
+
"pattern": "^[1-9A-HJ-NP-Za-km-z]+$",
|
|
10918
|
+
"type": "string",
|
|
10919
|
+
"x-base58-bytes": 32
|
|
10920
|
+
}
|
|
10921
|
+
},
|
|
10922
|
+
"required": ["transactionHash", "blockHeight"],
|
|
10923
|
+
"type": "object"
|
|
10924
|
+
},
|
|
10925
|
+
"reason": { "type": "string" },
|
|
10926
|
+
"transactionHash": {
|
|
10927
|
+
"maxLength": 45,
|
|
10928
|
+
"minLength": 32,
|
|
10929
|
+
"pattern": "^[1-9A-HJ-NP-Za-km-z]+$",
|
|
10930
|
+
"type": "string",
|
|
10931
|
+
"x-base58-bytes": 32
|
|
10932
|
+
}
|
|
10933
|
+
},
|
|
10934
|
+
"required": ["kind"],
|
|
10935
|
+
"type": "object",
|
|
10936
|
+
"x-forbidden": [
|
|
10937
|
+
"admission",
|
|
10938
|
+
"transactionHash",
|
|
10939
|
+
"signedTransaction",
|
|
10940
|
+
"observation",
|
|
10941
|
+
"receipt",
|
|
10942
|
+
"cause",
|
|
10943
|
+
"serviceCode",
|
|
10944
|
+
"error"
|
|
10945
|
+
]
|
|
10946
|
+
}],
|
|
10947
|
+
"x-tag": "kind"
|
|
10948
|
+
}
|
|
10949
|
+
}
|
|
10950
|
+
],
|
|
10634
10951
|
"dev_setBlockDriver": [
|
|
10635
10952
|
{
|
|
10636
10953
|
"code": -32602,
|
|
@@ -10791,55 +11108,30 @@ var schema_default = {
|
|
|
10791
11108
|
}
|
|
10792
11109
|
};
|
|
10793
11110
|
//#endregion
|
|
10794
|
-
//#region src/
|
|
10795
|
-
const
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
|
|
10799
|
-
|
|
10800
|
-
const parsed = BigInt(value);
|
|
10801
|
-
if (parsed < minimum || parsed > maximum) throw new RangeError(`Invalid ${field}: expected an integer from ${minimum} to ${maximum}`);
|
|
10802
|
-
return parsed;
|
|
10803
|
-
}
|
|
10804
|
-
/** Serialize a caller-owned bigint without passing through a JavaScript number. */
|
|
10805
|
-
function serializeHeight(value) {
|
|
10806
|
-
if (typeof value !== "bigint" || value < 0n || value > I64_MAX) throw new RangeError("height must be a non-negative int64 bigint");
|
|
10807
|
-
return value.toString();
|
|
11111
|
+
//#region src/rpc/localError.ts
|
|
11112
|
+
const localErrors = /* @__PURE__ */ new WeakSet();
|
|
11113
|
+
/** Record an error that the client raised before dispatch. */
|
|
11114
|
+
function markLocalError(error) {
|
|
11115
|
+
localErrors.add(error);
|
|
11116
|
+
return error;
|
|
10808
11117
|
}
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
return
|
|
11118
|
+
/** True only for an error recorded by {@link markLocalError}. */
|
|
11119
|
+
function isLocalError(error) {
|
|
11120
|
+
return typeof error === "object" && error !== null && localErrors.has(error);
|
|
10812
11121
|
}
|
|
10813
11122
|
//#endregion
|
|
10814
11123
|
//#region src/rpc/codec.ts
|
|
10815
|
-
/** An unfamiliar variant is data, never success, absence, or retry permission. */
|
|
10816
|
-
var UnsupportedRpcValue = class {
|
|
10817
|
-
raw;
|
|
10818
|
-
unsupported = true;
|
|
10819
|
-
constructor(raw) {
|
|
10820
|
-
this.raw = raw;
|
|
10821
|
-
}
|
|
10822
|
-
};
|
|
10823
11124
|
/** Malformed known result data, with the complete original result retained. */
|
|
10824
|
-
|
|
10825
|
-
path
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
this.raw = raw;
|
|
10831
|
-
this.name = "RpcDecodingError";
|
|
10832
|
-
}
|
|
10833
|
-
};
|
|
11125
|
+
function rpcValueInvalid(path, raw) {
|
|
11126
|
+
return new ThruputError("rpcValueInvalid", `Invalid native RPC value at ${path}`, { context: {
|
|
11127
|
+
path,
|
|
11128
|
+
raw
|
|
11129
|
+
} });
|
|
11130
|
+
}
|
|
10834
11131
|
/** Invalid local input. The transport was not called; this is not retry permission. */
|
|
10835
|
-
|
|
10836
|
-
path;
|
|
10837
|
-
|
|
10838
|
-
super(`${message} at ${path}`);
|
|
10839
|
-
this.path = path;
|
|
10840
|
-
this.name = "RpcRequestValidationError";
|
|
10841
|
-
}
|
|
10842
|
-
};
|
|
11132
|
+
function rpcRequestInvalid(path, message = "Invalid native RPC request") {
|
|
11133
|
+
return markLocalError(new ThruputError("rpcRequestInvalid", `${message} at ${path}`, { context: { path } }));
|
|
11134
|
+
}
|
|
10843
11135
|
const catalog = schema_default;
|
|
10844
11136
|
const rpcPageMethods = new Set(Object.entries(catalog.methods).filter(([, m]) => m.paged).map(([name]) => name));
|
|
10845
11137
|
const patterns = /* @__PURE__ */ new Map();
|
|
@@ -10852,13 +11144,20 @@ function matches(pattern, text) {
|
|
|
10852
11144
|
return regex.test(text);
|
|
10853
11145
|
}
|
|
10854
11146
|
const rpcMethodNames = Object.freeze(Object.keys(catalog.methods));
|
|
10855
|
-
function record(value) {
|
|
11147
|
+
function record$1(value) {
|
|
10856
11148
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
10857
11149
|
}
|
|
11150
|
+
/** Cheap internal decode failure; each boundary converts it to a `ThruputError` once. */
|
|
11151
|
+
var SchemaMismatch = class {
|
|
11152
|
+
path;
|
|
11153
|
+
constructor(path) {
|
|
11154
|
+
this.path = path;
|
|
11155
|
+
}
|
|
11156
|
+
};
|
|
10858
11157
|
/** The codec implements only the schema forms emitted by the pinned Rust owner. */
|
|
10859
11158
|
function convert(s, value, encode, path) {
|
|
10860
11159
|
const fail = () => {
|
|
10861
|
-
throw new
|
|
11160
|
+
throw new SchemaMismatch(path);
|
|
10862
11161
|
};
|
|
10863
11162
|
if (s.$ref) {
|
|
10864
11163
|
const name = s.$ref.split("/").at(-1);
|
|
@@ -10889,7 +11188,7 @@ function convert(s, value, encode, path) {
|
|
|
10889
11188
|
if (variants) {
|
|
10890
11189
|
const tag = s["x-tag"];
|
|
10891
11190
|
if (tag) {
|
|
10892
|
-
if (!record(value) || typeof value[tag] !== "string") return fail();
|
|
11191
|
+
if (!record$1(value) || typeof value[tag] !== "string") return fail();
|
|
10893
11192
|
const variant = variants.find((v) => v.properties[tag].const === value[tag]);
|
|
10894
11193
|
if (variant) return convert(variant, value, encode, path);
|
|
10895
11194
|
if (!encode && s["x-extensible"]) return new UnsupportedRpcValue(value);
|
|
@@ -10898,7 +11197,7 @@ function convert(s, value, encode, path) {
|
|
|
10898
11197
|
for (const variant of variants) try {
|
|
10899
11198
|
return convert(variant, value, encode, path);
|
|
10900
11199
|
} catch (error) {
|
|
10901
|
-
if (!(error instanceof
|
|
11200
|
+
if (!(error instanceof SchemaMismatch)) throw error;
|
|
10902
11201
|
}
|
|
10903
11202
|
if (!encode && s["x-extensible"] && typeof value === "string") return new UnsupportedRpcValue(value);
|
|
10904
11203
|
return fail();
|
|
@@ -10920,7 +11219,7 @@ function convert(s, value, encode, path) {
|
|
|
10920
11219
|
}
|
|
10921
11220
|
if (s.type === "null") return value === null ? null : fail();
|
|
10922
11221
|
if (s.type === "object") {
|
|
10923
|
-
if (!record(value) || value instanceof Uint8Array) return fail();
|
|
11222
|
+
if (!record$1(value) || value instanceof Uint8Array) return fail();
|
|
10924
11223
|
const properties = s.properties ?? {};
|
|
10925
11224
|
if (s["x-forbidden"]?.some((k) => Object.hasOwn(value, k))) return fail();
|
|
10926
11225
|
for (const [field, required] of Object.entries(s.dependencies ?? {})) if (Object.hasOwn(value, field) && required.some((k) => !Object.hasOwn(value, k))) return fail();
|
|
@@ -10959,10 +11258,10 @@ function encodeRequest(method, value) {
|
|
|
10959
11258
|
if (!entry) throw new Error(`Unknown native RPC method ${method}`);
|
|
10960
11259
|
try {
|
|
10961
11260
|
const encoded = convert(entry.params, value, true, "/params");
|
|
10962
|
-
if (entry.paged && Object.hasOwn(encoded, "start") === Object.hasOwn(encoded, "cursor")) throw new
|
|
11261
|
+
if (entry.paged && Object.hasOwn(encoded, "start") === Object.hasOwn(encoded, "cursor")) throw new SchemaMismatch("/params");
|
|
10963
11262
|
return encoded;
|
|
10964
11263
|
} catch (error) {
|
|
10965
|
-
if (error instanceof
|
|
11264
|
+
if (error instanceof SchemaMismatch) throw rpcRequestInvalid(error.path);
|
|
10966
11265
|
throw error;
|
|
10967
11266
|
}
|
|
10968
11267
|
}
|
|
@@ -10972,17 +11271,335 @@ function decodeResult(method, value) {
|
|
|
10972
11271
|
try {
|
|
10973
11272
|
return convert(entry.result, value, false, "/result");
|
|
10974
11273
|
} catch (error) {
|
|
10975
|
-
if (error instanceof
|
|
11274
|
+
if (error instanceof SchemaMismatch) throw rpcValueInvalid(error.path, value);
|
|
10976
11275
|
throw error;
|
|
10977
11276
|
}
|
|
10978
11277
|
}
|
|
10979
11278
|
/** Method/code membership and structural evidence; relational identity checks live in the reader. */
|
|
10980
11279
|
function decodeErrorData(method, code, value) {
|
|
10981
11280
|
const entry = catalog.errors[method]?.find((entry) => entry.code === code);
|
|
10982
|
-
if (!entry) throw
|
|
10983
|
-
|
|
11281
|
+
if (!entry) throw rpcValueInvalid("/error", value);
|
|
11282
|
+
try {
|
|
11283
|
+
return convert(entry.schema, value, false, "/error/data");
|
|
11284
|
+
} catch (error) {
|
|
11285
|
+
if (error instanceof SchemaMismatch) throw rpcValueInvalid(error.path, value);
|
|
11286
|
+
throw error;
|
|
11287
|
+
}
|
|
11288
|
+
}
|
|
11289
|
+
//#endregion
|
|
11290
|
+
//#region src/rpc/errorReader.ts
|
|
11291
|
+
const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
11292
|
+
const equal$1 = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
|
|
11293
|
+
/**
|
|
11294
|
+
* Classifies method-specific causes without granting retries. Unknown, malformed,
|
|
11295
|
+
* or contradictory evidence stays unclassified with the complete raw error.
|
|
11296
|
+
* Supply the locally computed/requested hash to bind admission or observation evidence.
|
|
11297
|
+
*/
|
|
11298
|
+
function decodeRpcError(method, raw, expectedTransactionHash) {
|
|
11299
|
+
const unclassified = () => ({
|
|
11300
|
+
classification: "unclassified",
|
|
11301
|
+
raw
|
|
11302
|
+
});
|
|
11303
|
+
if (!record(raw) || typeof raw.code !== "number" || !Number.isInteger(raw.code) || raw.code < -2147483648 || raw.code > 2147483647 || typeof raw.message !== "string") return unclassified();
|
|
11304
|
+
try {
|
|
11305
|
+
const data = decodeErrorData(method, raw.code, raw.data);
|
|
11306
|
+
if (!validFunding(data)) return unclassified();
|
|
11307
|
+
if (expectedTransactionHash) {
|
|
11308
|
+
if (method === "sendTransaction" && "transactionHash" in data && data.transactionHash && !equal$1(data.transactionHash, expectedTransactionHash)) return unclassified();
|
|
11309
|
+
if (method === "getTransactionReceipt" && "observation" in data && data.observation && !equal$1(data.observation.transactionHash, expectedTransactionHash)) return unclassified();
|
|
11310
|
+
}
|
|
11311
|
+
return {
|
|
11312
|
+
classification: "known",
|
|
11313
|
+
data,
|
|
11314
|
+
raw
|
|
11315
|
+
};
|
|
11316
|
+
} catch (error) {
|
|
11317
|
+
if (isThruputError(error, "rpcValueInvalid")) return unclassified();
|
|
11318
|
+
throw error;
|
|
11319
|
+
}
|
|
11320
|
+
}
|
|
11321
|
+
function validFunding(data) {
|
|
11322
|
+
if (data.kind !== "fundingAttemptStopped" && data.kind !== "localFundingUnresolved") return true;
|
|
11323
|
+
if (data.signedTransaction) try {
|
|
11324
|
+
if (!data.transactionHash || !equal$1(hashSignedTransaction(deserialize(data.signedTransaction, codec.SignedTransaction)), data.transactionHash)) return false;
|
|
11325
|
+
} catch {
|
|
11326
|
+
return false;
|
|
11327
|
+
}
|
|
11328
|
+
if (data.kind === "fundingAttemptStopped") return !data.receipt || !!data.transactionHash && equal$1(data.receipt.transactionHash, data.transactionHash);
|
|
11329
|
+
if (data.cause) {
|
|
11330
|
+
if (!validFunding(data.cause)) return false;
|
|
11331
|
+
if (data.cause.transactionHash && !equal$1(data.cause.transactionHash, data.transactionHash)) return false;
|
|
11332
|
+
if (data.cause.signedTransaction && !equal$1(data.cause.signedTransaction, data.signedTransaction)) return false;
|
|
11333
|
+
}
|
|
11334
|
+
return true;
|
|
11335
|
+
}
|
|
11336
|
+
/**
|
|
11337
|
+
* Wrap a JSON-RPC error from a native method. Keep the complete raw error and a
|
|
11338
|
+
* conservative typed reading; unknown or contradictory evidence is `unrecognized`.
|
|
11339
|
+
*/
|
|
11340
|
+
function nativeRpcError(error, method, expectedTransactionHash) {
|
|
11341
|
+
const raw = record(error.raw) ? error.raw : {
|
|
11342
|
+
...typeof error.code === "number" ? { code: error.code } : {},
|
|
11343
|
+
...typeof error.rpcMessage === "string" ? { message: error.rpcMessage } : {},
|
|
11344
|
+
...error.data === void 0 ? {} : { data: error.data }
|
|
11345
|
+
};
|
|
11346
|
+
const decoded = decodeRpcError(method, raw, expectedTransactionHash);
|
|
11347
|
+
return new ThruputError("nativeRpcError", `${method}: ${error.rpcMessage} (RPC ${error.code})`, { context: {
|
|
11348
|
+
code: error.code,
|
|
11349
|
+
rpcMessage: error.rpcMessage,
|
|
11350
|
+
method,
|
|
11351
|
+
raw,
|
|
11352
|
+
...decoded.classification === "known" ? {
|
|
11353
|
+
kind: decoded.data.kind,
|
|
11354
|
+
data: decoded.data
|
|
11355
|
+
} : { kind: "unrecognized" }
|
|
11356
|
+
} });
|
|
11357
|
+
}
|
|
11358
|
+
//#endregion
|
|
11359
|
+
//#region src/rpc/client.ts
|
|
11360
|
+
/**
|
|
11361
|
+
* The endpoint, network, or method set does not match what the client requires.
|
|
11362
|
+
* Raised by a local check, so it proves that the request was not dispatched.
|
|
11363
|
+
*/
|
|
11364
|
+
function rpcIncompatible(kind, message) {
|
|
11365
|
+
return markLocalError(new ThruputError("rpcIncompatible", message, { context: { kind } }));
|
|
11366
|
+
}
|
|
11367
|
+
const equal = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
|
|
11368
|
+
/**
|
|
11369
|
+
* Connect a native wire-14 client. This layer reads once or sends once; it does
|
|
11370
|
+
* not sign, poll, retry, refresh discovery on failure, or switch wire formats.
|
|
11371
|
+
* Unknown response variants are UnsupportedRpcValue objects retaining raw data.
|
|
11372
|
+
*/
|
|
11373
|
+
async function createRpcClient(options) {
|
|
11374
|
+
const transport = options.transport;
|
|
11375
|
+
const expected = options.expectedNetworkHash ? new Uint8Array(options.expectedNetworkHash) : void 0;
|
|
11376
|
+
if (expected && expected.length !== 32) throw new RangeError("expectedNetworkHash must have 32 bytes");
|
|
11377
|
+
const required = [...options.requiredMethods ?? []];
|
|
11378
|
+
let discovery;
|
|
11379
|
+
let configured = /* @__PURE__ */ new Set();
|
|
11380
|
+
const requireMethods = (methods) => {
|
|
11381
|
+
for (const method of methods) if (!configured.has(method)) throw rpcIncompatible("method", `Endpoint does not advertise ${method}`);
|
|
11382
|
+
};
|
|
11383
|
+
const requestOnce = async (method, params, control, hash) => {
|
|
11384
|
+
try {
|
|
11385
|
+
return await transport.request(method, params, control);
|
|
11386
|
+
} catch (error) {
|
|
11387
|
+
if (isThruputError(error, "rpcError")) throw nativeRpcError(error.context, method, hash);
|
|
11388
|
+
throw error;
|
|
11389
|
+
}
|
|
11390
|
+
};
|
|
11391
|
+
const read = async (method, control) => decodeResult(method, await requestOnce(method, {}, control));
|
|
11392
|
+
const refreshDiscovery = async (control) => {
|
|
11393
|
+
const version = await read("getVersionInfo", control);
|
|
11394
|
+
if (!/^14\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/.test(version.wireFormat)) throw rpcIncompatible("wireVersion", `Unsupported RPC wire format ${version.wireFormat}`);
|
|
11395
|
+
const methods = new Set(version.supportedMethods);
|
|
11396
|
+
for (const method of [
|
|
11397
|
+
"getVersionInfo",
|
|
11398
|
+
"getNetworkInfo",
|
|
11399
|
+
...required
|
|
11400
|
+
]) if (!methods.has(method)) throw rpcIncompatible("method", `Endpoint does not advertise ${method}`);
|
|
11401
|
+
const network = await read("getNetworkInfo", control);
|
|
11402
|
+
const wanted = expected ?? discovery?.network.networkHash;
|
|
11403
|
+
if (wanted && !equal(wanted, network.networkHash)) throw rpcIncompatible("network", "RPC network identity does not match");
|
|
11404
|
+
const limits = methods.has("getServerLimits") ? await read("getServerLimits", control) : void 0;
|
|
11405
|
+
discovery = {
|
|
11406
|
+
version,
|
|
11407
|
+
network,
|
|
11408
|
+
...limits ? { limits } : {}
|
|
11409
|
+
};
|
|
11410
|
+
configured = methods;
|
|
11411
|
+
return structuredClone(discovery);
|
|
11412
|
+
};
|
|
11413
|
+
await refreshDiscovery({ signal: options.signal });
|
|
11414
|
+
const methods = Object.fromEntries(rpcMethodNames.map((name) => [name, async (request = {}, control) => {
|
|
11415
|
+
const method = name;
|
|
11416
|
+
control?.signal?.throwIfAborted();
|
|
11417
|
+
requireMethods([method]);
|
|
11418
|
+
const params = encodeRequest(method, request);
|
|
11419
|
+
const input = structuredClone(request);
|
|
11420
|
+
const limits = discovery.limits;
|
|
11421
|
+
checkLimits(method, input, limits);
|
|
11422
|
+
let submittedHash;
|
|
11423
|
+
if (method === "sendTransaction") try {
|
|
11424
|
+
submittedHash = hashSignedTransaction(deserialize(input.signedTransaction, codec.SignedTransaction));
|
|
11425
|
+
} catch {
|
|
11426
|
+
throw rpcRequestInvalid("/params/signedTransaction", "Invalid signed transaction XDR");
|
|
11427
|
+
}
|
|
11428
|
+
const raw = await requestOnce(method, params, control, submittedHash ?? (method === "getTransactionReceipt" ? input.transactionHash : void 0));
|
|
11429
|
+
const result = decodeResult(method, raw);
|
|
11430
|
+
checkResult(method, input, result, raw, submittedHash, limits, discovery.network.networkHash);
|
|
11431
|
+
return result;
|
|
11432
|
+
}]));
|
|
11433
|
+
return Object.defineProperty(Object.assign(methods, {
|
|
11434
|
+
refreshDiscovery,
|
|
11435
|
+
requireMethods
|
|
11436
|
+
}), "discovery", {
|
|
11437
|
+
get: () => structuredClone(discovery),
|
|
11438
|
+
enumerable: true
|
|
11439
|
+
});
|
|
11440
|
+
}
|
|
11441
|
+
function checkLimits(method, input, limits) {
|
|
11442
|
+
if (rpcPageMethods.has(method)) {
|
|
11443
|
+
if (!limits) throw rpcIncompatible("limits", "History calls require advertised server limits");
|
|
11444
|
+
const cap = method === "getEvents" ? limits.maxEventsPerPage : limits.maxTransactionsPerPage;
|
|
11445
|
+
if (input.limit !== void 0 && input.limit > cap) throw rpcRequestInvalid("/params/limit", `limit exceeds endpoint cap ${cap}`);
|
|
11446
|
+
if (typeof input.cursor === "string" && BigInt((input.cursor.length - 2) / 2) > limits.maxCursorBytes) throw rpcRequestInvalid("/params/cursor", "cursor exceeds endpoint cap");
|
|
11447
|
+
}
|
|
11448
|
+
if (method === "simulateInvocation" || method === "simulateInvocations") {
|
|
11449
|
+
if (!limits) throw rpcIncompatible("limits", "Simulation calls require advertised server limits");
|
|
11450
|
+
const calls = method === "simulateInvocation" ? [input] : input.invocations;
|
|
11451
|
+
let gas = 0n, bytes = 0;
|
|
11452
|
+
for (const call of calls) {
|
|
11453
|
+
const callGas = call.gasLimit;
|
|
11454
|
+
if (callGas !== void 0 && callGas > limits.maxSimulationGas) throw rpcRequestInvalid("/params/gasLimit", "gasLimit exceeds endpoint cap");
|
|
11455
|
+
const size = call.calldata.length;
|
|
11456
|
+
if (BigInt(size) > limits.maxSimulationCalldataBytes) throw rpcRequestInvalid("/params/calldata", "calldata exceeds endpoint cap");
|
|
11457
|
+
gas += callGas ?? limits.maxSimulationGas;
|
|
11458
|
+
bytes += size;
|
|
11459
|
+
}
|
|
11460
|
+
if (method === "simulateInvocations") {
|
|
11461
|
+
const batch = limits.simulationBatch;
|
|
11462
|
+
if (!batch) throw rpcIncompatible("limits", "Batch simulation limits are unavailable");
|
|
11463
|
+
if (calls.length > batch.maxInvocations || bytes > batch.maxCalldataBytes || gas > batch.maxGas) throw rpcRequestInvalid("/params/invocations", "simulation batch exceeds endpoint cap");
|
|
11464
|
+
}
|
|
11465
|
+
}
|
|
11466
|
+
}
|
|
11467
|
+
/**
|
|
11468
|
+
* Local block and time results must match their own request: a pinned
|
|
11469
|
+
* timepoint comes back exactly, a multi-block request returns `count`
|
|
11470
|
+
* blocks, a step change reports the requested step (none when cleared), and a
|
|
11471
|
+
* mode change reports the requested mode and interval.
|
|
11472
|
+
*/
|
|
11473
|
+
function checkBlockControlResult(method, input, value, invalid) {
|
|
11474
|
+
if (method === "dev_produceBlock") {
|
|
11475
|
+
const block = value;
|
|
11476
|
+
if (block.blockHeight <= 0n || input.blockTimepoint !== void 0 && block.blockTimepoint !== input.blockTimepoint) invalid();
|
|
11477
|
+
}
|
|
11478
|
+
if (method === "dev_produceBlocks" && value.blocks.length !== input.count) invalid();
|
|
11479
|
+
if (method === "dev_setNextBlockTimepoint" && value.nextBlockTimepoint !== input.blockTimepoint) invalid();
|
|
11480
|
+
if (method === "dev_setBlockTimeStep" && value.stepNanoseconds !== input.stepNanoseconds) invalid();
|
|
11481
|
+
if (method === "dev_setBlockDriver") {
|
|
11482
|
+
const status = value;
|
|
11483
|
+
if (typeof status.mode === "string" && status.mode !== input.mode || input.intervalMilliseconds !== void 0 && status.intervalMilliseconds !== input.intervalMilliseconds) invalid();
|
|
11484
|
+
}
|
|
11485
|
+
}
|
|
11486
|
+
function checkResult(method, input, value, raw, submittedHash, limits, networkHash) {
|
|
11487
|
+
const invalid = () => {
|
|
11488
|
+
throw rpcValueInvalid("/result", raw);
|
|
11489
|
+
};
|
|
11490
|
+
if (value === null) return;
|
|
11491
|
+
const result = value;
|
|
11492
|
+
if (method === "getTransactionReceipt" && !equal(result.transactionHash, input.transactionHash) || submittedHash && !equal(result.transactionHash, submittedHash)) invalid();
|
|
11493
|
+
if (method === "getBlockByHeight" && (result.blockHeight <= 0n || result.blockHeight !== input.blockHeight || !equal(result.networkHash, networkHash))) invalid();
|
|
11494
|
+
if ((method === "getBalance" || method === "getRegisteredAuth") && !equal(result.address, input.address)) invalid();
|
|
11495
|
+
if (method === "simulateInvocations" && result.results.length !== input.invocations.length) invalid();
|
|
11496
|
+
if ((method === "simulateInvocation" || method === "simulateInvocations") && input.minStateBlockHeight !== void 0 && result.stateBlockHeight < input.minStateBlockHeight) invalid();
|
|
11497
|
+
if (method === "dev_fundAccount") {
|
|
11498
|
+
const funding = value;
|
|
11499
|
+
try {
|
|
11500
|
+
if (!equal(funding.recipient, input.recipient) || funding.rawAmount !== input.rawAmount || !equal(funding.transactionHash, hashSignedTransaction(deserialize(funding.signedTransaction, codec.SignedTransaction)))) invalid();
|
|
11501
|
+
} catch {
|
|
11502
|
+
invalid();
|
|
11503
|
+
}
|
|
11504
|
+
}
|
|
11505
|
+
checkBlockControlResult(method, input, value, invalid);
|
|
11506
|
+
if (method === "faucet_requestAirdrop" && "recipient" in result && !equal(result.recipient, input.recipient)) invalid();
|
|
11507
|
+
if (!rpcPageMethods.has(method)) return;
|
|
11508
|
+
const page = value;
|
|
11509
|
+
const entries = method === "getEvents" ? page.events : page.transactions;
|
|
11510
|
+
const cap = method === "getEvents" ? limits.maxEventsPerPage : limits.maxTransactionsPerPage;
|
|
11511
|
+
if (page.oldestIndexedBlockHeight > page.latestIndexedBlockHeight || entries.length > (input.limit ?? Math.min(50, cap)) || page.nextCursor !== null && (page.nextCursor === input.cursor || BigInt((page.nextCursor.length - 2) / 2) > limits.maxCursorBytes)) invalid();
|
|
11512
|
+
if (entries.some((entry) => entry.blockHeight < page.oldestIndexedBlockHeight || entry.blockHeight > page.latestIndexedBlockHeight)) invalid();
|
|
11513
|
+
const start = input.start;
|
|
11514
|
+
if (method === "getTransactionsByBlock") {
|
|
11515
|
+
if (page.oldestIndexedBlockHeight < 1n || !entries.length && page.nextCursor !== null || input.cursor !== void 0 && (input.blockHeight < page.oldestIndexedBlockHeight || input.blockHeight > page.latestIndexedBlockHeight) || entries.some((entry) => entry.blockHeight !== input.blockHeight)) invalid();
|
|
11516
|
+
} else if (start?.anchor.kind === "atHeight") {
|
|
11517
|
+
const anchor = start.anchor.blockHeight;
|
|
11518
|
+
if (anchor < page.oldestIndexedBlockHeight || entries.some((entry) => start.order === "ascending" ? entry.blockHeight < anchor : entry.blockHeight > anchor)) invalid();
|
|
11519
|
+
}
|
|
11520
|
+
const identities = /* @__PURE__ */ new Set();
|
|
11521
|
+
const keys = [];
|
|
11522
|
+
for (const [index, entry] of entries.entries()) {
|
|
11523
|
+
const event = method === "getEvents" ? page.events[index] : void 0;
|
|
11524
|
+
const hash = toHex0x(entry.transactionHash);
|
|
11525
|
+
const sequence = event?.sequenceNumber ?? 0;
|
|
11526
|
+
const identity = method === "getEvents" ? `${hash}/${sequence}` : hash;
|
|
11527
|
+
if (identities.has(identity)) invalid();
|
|
11528
|
+
identities.add(identity);
|
|
11529
|
+
keys.push([
|
|
11530
|
+
entry.blockHeight,
|
|
11531
|
+
hash,
|
|
11532
|
+
sequence
|
|
11533
|
+
]);
|
|
11534
|
+
if (event && !input.filters.some((filter) => filter.addresses.some((address) => equal(address, event.event.address)) && [
|
|
11535
|
+
"topic0",
|
|
11536
|
+
"topic1",
|
|
11537
|
+
"topic2"
|
|
11538
|
+
].every((key, i) => {
|
|
11539
|
+
const values = filter.topics?.[key];
|
|
11540
|
+
return !values?.length || !!event.event.topics[i] && values.some((topic) => equal(topic, event.event.topics[i]));
|
|
11541
|
+
}))) invalid();
|
|
11542
|
+
}
|
|
11543
|
+
const compare = (left, right) => {
|
|
11544
|
+
for (let i = 0; i < 3; i++) {
|
|
11545
|
+
if (left[i] < right[i]) return -1;
|
|
11546
|
+
if (left[i] > right[i]) return 1;
|
|
11547
|
+
}
|
|
11548
|
+
return 0;
|
|
11549
|
+
};
|
|
11550
|
+
const asc = keys.every((key, i) => i === 0 || compare(keys[i - 1], key) < 0);
|
|
11551
|
+
const desc = keys.every((key, i) => i === 0 || compare(keys[i - 1], key) > 0);
|
|
11552
|
+
if (!(start ? start.order === "ascending" ? asc : desc : asc || desc)) invalid();
|
|
11553
|
+
}
|
|
11554
|
+
//#endregion
|
|
11555
|
+
//#region src/transport/readError.ts
|
|
11556
|
+
/**
|
|
11557
|
+
* Classify an infrastructure read failure without replacing the original error.
|
|
11558
|
+
*
|
|
11559
|
+
* Pass the caller's signal to distinguish explicit cancellation from a transport
|
|
11560
|
+
* timeout. Plain Error wrappers are inspected through their causes; other
|
|
11561
|
+
* `ThruputError` codes and unrecognized failures remain unknown. A bare TypeError
|
|
11562
|
+
* is not evidence of a network failure. Custom transports should throw code
|
|
11563
|
+
* `httpRequestFailed` for that case. Transaction-not-found remains
|
|
11564
|
+
* operation-specific rather than a general retry. This classification never
|
|
11565
|
+
* authorizes transaction resubmission.
|
|
11566
|
+
*/
|
|
11567
|
+
function classifyReadError(error, options = {}) {
|
|
11568
|
+
if (options.signal?.aborted) return "cancelled";
|
|
11569
|
+
const seen = /* @__PURE__ */ new Set();
|
|
11570
|
+
while (error !== null && typeof error === "object" && !seen.has(error)) {
|
|
11571
|
+
seen.add(error);
|
|
11572
|
+
if (isThruputError(error, "httpRequestFailed")) return "transient";
|
|
11573
|
+
if (isThruputError(error, "httpResponseError")) return [
|
|
11574
|
+
408,
|
|
11575
|
+
429,
|
|
11576
|
+
500,
|
|
11577
|
+
502,
|
|
11578
|
+
503,
|
|
11579
|
+
504
|
|
11580
|
+
].includes(error.context.status) ? "transient" : "permanent";
|
|
11581
|
+
if (isThruputError(error, "nativeRpcError")) switch (error.context.kind) {
|
|
11582
|
+
case "backendUnavailable":
|
|
11583
|
+
case "stateHeightUnavailable":
|
|
11584
|
+
case "backendTimeout":
|
|
11585
|
+
case "overloaded": return "transient";
|
|
11586
|
+
case "invalidParams":
|
|
11587
|
+
case "invalidCursor":
|
|
11588
|
+
case "transactionInvalid":
|
|
11589
|
+
case "transactionRejected":
|
|
11590
|
+
case "historyUnavailable": return "permanent";
|
|
11591
|
+
default: return "unknown";
|
|
11592
|
+
}
|
|
11593
|
+
if ("name" in error) {
|
|
11594
|
+
if (error.name === "TimeoutError") return "transient";
|
|
11595
|
+
if (error.name === "AbortError") return "cancelled";
|
|
11596
|
+
}
|
|
11597
|
+
if (!(error instanceof Error) || error.constructor !== Error) return "unknown";
|
|
11598
|
+
error = error.cause;
|
|
11599
|
+
}
|
|
11600
|
+
return "unknown";
|
|
10984
11601
|
}
|
|
10985
11602
|
//#endregion
|
|
10986
|
-
export {
|
|
11603
|
+
export { isLocalError as i, createRpcClient as n, rpcIncompatible as r, classifyReadError as t };
|
|
10987
11604
|
|
|
10988
|
-
//# sourceMappingURL=
|
|
11605
|
+
//# sourceMappingURL=readError-B3Rz7rgs.js.map
|