@thruputchain/client 0.0.0-stage → 0.26.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/LICENSE +201 -0
- package/README.md +953 -2
- package/dist/actions-CXx6qzsv.cjs +513 -0
- package/dist/actions-CXx6qzsv.cjs.map +1 -0
- package/dist/actions-QHgiCqT6.js +430 -0
- package/dist/actions-QHgiCqT6.js.map +1 -0
- package/dist/actions.cjs +23 -0
- package/dist/actions.d.cts +4 -0
- package/dist/actions.d.ts +4 -0
- package/dist/actions.js +3 -0
- package/dist/artifact-BM_MVzhL.d.cts +35 -0
- package/dist/artifact-BM_MVzhL.d.cts.map +1 -0
- package/dist/artifact-BM_MVzhL.d.ts +35 -0
- package/dist/artifact-BM_MVzhL.d.ts.map +1 -0
- package/dist/client-JixxskeH.d.cts +746 -0
- package/dist/client-JixxskeH.d.cts.map +1 -0
- package/dist/client-JixxskeH.d.ts +746 -0
- package/dist/client-JixxskeH.d.ts.map +1 -0
- package/dist/codec-BHKoSaOP.js +9506 -0
- package/dist/codec-BHKoSaOP.js.map +1 -0
- package/dist/codec-C3OlYm98.cjs +9566 -0
- package/dist/codec-C3OlYm98.cjs.map +1 -0
- package/dist/contract-C7T2H2Oi.cjs +1628 -0
- package/dist/contract-C7T2H2Oi.cjs.map +1 -0
- package/dist/contract-DzvyyFCI.js +1472 -0
- package/dist/contract-DzvyyFCI.js.map +1 -0
- package/dist/contract.cjs +63 -0
- package/dist/contract.d.cts +4 -0
- package/dist/contract.d.ts +4 -0
- package/dist/contract.js +2 -0
- package/dist/contracts.cjs +1050 -0
- package/dist/contracts.cjs.map +1 -0
- package/dist/contracts.d.cts +397 -0
- package/dist/contracts.d.cts.map +1 -0
- package/dist/contracts.d.ts +397 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +1030 -0
- package/dist/contracts.js.map +1 -0
- package/dist/dev_wallet-CSMA1PCt.js +497 -0
- package/dist/dev_wallet-CSMA1PCt.js.map +1 -0
- package/dist/dev_wallet-GX-NCAFk.cjs +530 -0
- package/dist/dev_wallet-GX-NCAFk.cjs.map +1 -0
- package/dist/domainSeparator-B_vU_zUD.cjs +102 -0
- package/dist/domainSeparator-B_vU_zUD.cjs.map +1 -0
- package/dist/domainSeparator-CBCvxIj-.js +79 -0
- package/dist/domainSeparator-CBCvxIj-.js.map +1 -0
- package/dist/execution-DYqPDn4O.d.cts +227 -0
- package/dist/execution-DYqPDn4O.d.cts.map +1 -0
- package/dist/execution-Dj6E4B_b.d.ts +227 -0
- package/dist/execution-Dj6E4B_b.d.ts.map +1 -0
- package/dist/hex-DIcaALXL.js +112 -0
- package/dist/hex-DIcaALXL.js.map +1 -0
- package/dist/hex-DkGpiZ5e.cjs +189 -0
- package/dist/hex-DkGpiZ5e.cjs.map +1 -0
- package/dist/index--5LsCotr.d.ts +192 -0
- package/dist/index--5LsCotr.d.ts.map +1 -0
- package/dist/index-1-rFirYe.d.cts +90 -0
- package/dist/index-1-rFirYe.d.cts.map +1 -0
- package/dist/index-B5KqSHeL.d.cts +192 -0
- package/dist/index-B5KqSHeL.d.cts.map +1 -0
- package/dist/index-BraLWObY.d.cts +164 -0
- package/dist/index-BraLWObY.d.cts.map +1 -0
- package/dist/index-ByNNqY7S.d.cts +83 -0
- package/dist/index-ByNNqY7S.d.cts.map +1 -0
- package/dist/index-ByvV2UF6.d.ts +164 -0
- package/dist/index-ByvV2UF6.d.ts.map +1 -0
- package/dist/index-CG2WRtGa.d.cts +164 -0
- package/dist/index-CG2WRtGa.d.cts.map +1 -0
- package/dist/index-CIHK7Ew9.d.cts +303 -0
- package/dist/index-CIHK7Ew9.d.cts.map +1 -0
- package/dist/index-CIHK7Ew9.d.ts +303 -0
- package/dist/index-CIHK7Ew9.d.ts.map +1 -0
- package/dist/index-CVrhB9Dr.d.cts +263 -0
- package/dist/index-CVrhB9Dr.d.cts.map +1 -0
- package/dist/index-D89ur7mO.d.ts +164 -0
- package/dist/index-D89ur7mO.d.ts.map +1 -0
- package/dist/index-DzrLv3EA.d.cts +82 -0
- package/dist/index-DzrLv3EA.d.cts.map +1 -0
- package/dist/index-DzrLv3EA.d.ts +82 -0
- package/dist/index-DzrLv3EA.d.ts.map +1 -0
- package/dist/index-SV-inhhO.d.ts +90 -0
- package/dist/index-SV-inhhO.d.ts.map +1 -0
- package/dist/index-dJ65V8se.d.ts +263 -0
- package/dist/index-dJ65V8se.d.ts.map +1 -0
- package/dist/index-fdTURpBk.d.ts +83 -0
- package/dist/index-fdTURpBk.d.ts.map +1 -0
- package/dist/index.cjs +445 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +174 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +189 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.cjs +101 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.cts +2 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.js +76 -0
- package/dist/provider.js.map +1 -0
- package/dist/readError-AoNjzW75.cjs +604 -0
- package/dist/readError-AoNjzW75.cjs.map +1 -0
- package/dist/readError-CZPYcW__.js +551 -0
- package/dist/readError-CZPYcW__.js.map +1 -0
- package/dist/readViews-DJyqc7im.d.cts +604 -0
- package/dist/readViews-DJyqc7im.d.cts.map +1 -0
- package/dist/readViews-DQoaUORa.d.ts +604 -0
- package/dist/readViews-DQoaUORa.d.ts.map +1 -0
- package/dist/rolldown-runtime-D6vf50IK.cjs +28 -0
- package/dist/sendInvocation-BwabRa2N.js +505 -0
- package/dist/sendInvocation-BwabRa2N.js.map +1 -0
- package/dist/sendInvocation-qO8AZcmU.cjs +661 -0
- package/dist/sendInvocation-qO8AZcmU.cjs.map +1 -0
- package/dist/sign-BewmV_EL.cjs +139 -0
- package/dist/sign-BewmV_EL.cjs.map +1 -0
- package/dist/sign-DVIRyW8Y.js +122 -0
- package/dist/sign-DVIRyW8Y.js.map +1 -0
- package/dist/sign-Ve0eetRO.d.ts +48 -0
- package/dist/sign-Ve0eetRO.d.ts.map +1 -0
- package/dist/sign-eUT0iGQG.d.cts +48 -0
- package/dist/sign-eUT0iGQG.d.cts.map +1 -0
- package/dist/signed-op.cjs +9 -0
- package/dist/signed-op.d.cts +3 -0
- package/dist/signed-op.d.ts +3 -0
- package/dist/signed-op.js +3 -0
- package/dist/signedOp-C52gOgpR.js +166 -0
- package/dist/signedOp-C52gOgpR.js.map +1 -0
- package/dist/signedOp-oqAXEqmE.cjs +183 -0
- package/dist/signedOp-oqAXEqmE.cjs.map +1 -0
- package/dist/signed_op-BokEDWr-.js +154 -0
- package/dist/signed_op-BokEDWr-.js.map +1 -0
- package/dist/signed_op-C4lY_TCc.d.ts +58 -0
- package/dist/signed_op-C4lY_TCc.d.ts.map +1 -0
- package/dist/signed_op-DX5WuyEh.d.cts +58 -0
- package/dist/signed_op-DX5WuyEh.d.cts.map +1 -0
- package/dist/signed_op-q8KKSm5e.cjs +175 -0
- package/dist/signed_op-q8KKSm5e.cjs.map +1 -0
- package/dist/signers-BFP84wJP.cjs +137 -0
- package/dist/signers-BFP84wJP.cjs.map +1 -0
- package/dist/signers-CzOSedwJ.js +120 -0
- package/dist/signers-CzOSedwJ.js.map +1 -0
- package/dist/signers.cjs +5 -0
- package/dist/signers.d.cts +3 -0
- package/dist/signers.d.ts +3 -0
- package/dist/signers.js +2 -0
- package/dist/size-506oTE28.js +91 -0
- package/dist/size-506oTE28.js.map +1 -0
- package/dist/size-OAFfOthl.cjs +108 -0
- package/dist/size-OAFfOthl.cjs.map +1 -0
- package/dist/transaction-CwkQxQOx.js +24 -0
- package/dist/transaction-CwkQxQOx.js.map +1 -0
- package/dist/transaction-DrSrCJ5y.cjs +47 -0
- package/dist/transaction-DrSrCJ5y.cjs.map +1 -0
- package/dist/transaction.cjs +13 -0
- package/dist/transaction.d.cts +3 -0
- package/dist/transaction.d.ts +3 -0
- package/dist/transaction.js +4 -0
- package/dist/transactionHash-CO9ajbvU.js +24 -0
- package/dist/transactionHash-CO9ajbvU.js.map +1 -0
- package/dist/transactionHash-D5yf4KoL.cjs +29 -0
- package/dist/transactionHash-D5yf4KoL.cjs.map +1 -0
- package/dist/transport-CBFwAIIv.js +261 -0
- package/dist/transport-CBFwAIIv.js.map +1 -0
- package/dist/transport-tWxKhXUt.cjs +279 -0
- package/dist/transport-tWxKhXUt.cjs.map +1 -0
- package/dist/transport.cjs +19 -0
- package/dist/transport.d.cts +3 -0
- package/dist/transport.d.ts +3 -0
- package/dist/transport.js +4 -0
- package/dist/types-BE40oD_Q.d.cts +18 -0
- package/dist/types-BE40oD_Q.d.cts.map +1 -0
- package/dist/types-BE40oD_Q.d.ts +18 -0
- package/dist/types-BE40oD_Q.d.ts.map +1 -0
- package/dist/validation-4w-vDGAi.cjs +543 -0
- package/dist/validation-4w-vDGAi.cjs.map +1 -0
- package/dist/validation-eXATmgO0.js +411 -0
- package/dist/validation-eXATmgO0.js.map +1 -0
- package/dist/wallet-7RELuTkf.js +667 -0
- package/dist/wallet-7RELuTkf.js.map +1 -0
- package/dist/wallet-T_JazXRc.cjs +709 -0
- package/dist/wallet-T_JazXRc.cjs.map +1 -0
- package/dist/wallet.cjs +27 -0
- package/dist/wallet.d.cts +3 -0
- package/dist/wallet.d.ts +3 -0
- package/dist/wallet.js +3 -0
- package/package.json +122 -4
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { t as Signer } from "./types-BE40oD_Q.js";
|
|
2
|
+
import { BlockHeight, ContractAddress, NetworkHash } from "@thruputchain/protocol";
|
|
3
|
+
import { FixedBytes } from "@thruputchain/xdr";
|
|
4
|
+
import { ContractTypeDef } from "@thruputchain/contract-spec";
|
|
5
|
+
|
|
6
|
+
//#region src/signedOp/operation.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Wire form of a signed operation: the `Operation` struct of the
|
|
9
|
+
* `thruput-signed-op-if` interface, in the shape generated bindings give it.
|
|
10
|
+
*
|
|
11
|
+
* The network hash, the verifying contract, and the signing key are covered
|
|
12
|
+
* by the signature but deliberately absent here. The verifying contract
|
|
13
|
+
* supplies the first two from its own syscalls and checks the signature
|
|
14
|
+
* against the key it holds, so a submitter can name neither the network or
|
|
15
|
+
* contract a signature was meant for nor the key it is checked against.
|
|
16
|
+
*
|
|
17
|
+
* `block_expiry_height` and `nonce` are the chain's `Uniquifier`, in its
|
|
18
|
+
* field order, so their encoding is byte for byte a transaction's.
|
|
19
|
+
*/
|
|
20
|
+
interface Operation {
|
|
21
|
+
/** Last block height (inclusive) at which the operation may execute. */
|
|
22
|
+
block_expiry_height: bigint;
|
|
23
|
+
/**
|
|
24
|
+
* Chosen by the signer: any value, as long as the pair
|
|
25
|
+
* `(nonce, block_expiry_height)` has not been consumed at the verifying
|
|
26
|
+
* contract. There is no ordering. Consumed pairs are the contract's, not
|
|
27
|
+
* the key's, so where several keys sign for one contract, draw nonces at
|
|
28
|
+
* random ({@link randomNonce}) rather than counting; a lone key may do
|
|
29
|
+
* either.
|
|
30
|
+
*/
|
|
31
|
+
nonce: bigint;
|
|
32
|
+
/** CXS encoding of the payload value. */
|
|
33
|
+
body: Uint8Array;
|
|
34
|
+
}
|
|
35
|
+
/** An {@link Operation} and the Ed25519 signature over its preimage. */
|
|
36
|
+
interface SignedOperation {
|
|
37
|
+
readonly op: Operation;
|
|
38
|
+
readonly signature: FixedBytes<64>;
|
|
39
|
+
}
|
|
40
|
+
/** What a signer supplies to produce one operation. */
|
|
41
|
+
interface SignedOperationRequest<TBody> {
|
|
42
|
+
/** Hash of the network the operation is valid on. */
|
|
43
|
+
readonly network: NetworkHash;
|
|
44
|
+
/** Address of the contract that will verify and act on the operation. */
|
|
45
|
+
readonly verifyingContract: ContractAddress;
|
|
46
|
+
/** Last block height (inclusive) at which the operation may execute. */
|
|
47
|
+
readonly blockExpiryHeight: bigint;
|
|
48
|
+
/**
|
|
49
|
+
* Signer-chosen replay guard; see {@link Operation.nonce}. Nothing on
|
|
50
|
+
* chain needs reading to pick one: {@link randomNonce} is always safe.
|
|
51
|
+
*/
|
|
52
|
+
readonly nonce: bigint;
|
|
53
|
+
/** The payload value, in the field shape generated bindings use. */
|
|
54
|
+
readonly body: TBody;
|
|
55
|
+
}
|
|
56
|
+
/** Signing helpers bound to one payload type. */
|
|
57
|
+
interface SignedOperationType<TBody> {
|
|
58
|
+
/**
|
|
59
|
+
* Declared name of the payload type: the `declared` segment of its spec id.
|
|
60
|
+
* {@link SignedOperationType.typeDef} carries the full id.
|
|
61
|
+
*/
|
|
62
|
+
readonly typeName: string;
|
|
63
|
+
/** The payload type's spec definition, as bound into every preimage. */
|
|
64
|
+
readonly typeDef: ContractTypeDef;
|
|
65
|
+
/** CXS-encode a payload value the way the contract decodes it. */
|
|
66
|
+
encodeBody(body: TBody): Uint8Array;
|
|
67
|
+
/** The bytes a signature over `request` covers. */
|
|
68
|
+
preimage(request: SignedOperationRequest<TBody>): Uint8Array;
|
|
69
|
+
/** Encode, sign, and package `request` for the verifying contract. */
|
|
70
|
+
sign(signer: Signer, request: SignedOperationRequest<TBody>): Promise<SignedOperation>;
|
|
71
|
+
}
|
|
72
|
+
/** Options for {@link defineSignedOperation}. */
|
|
73
|
+
interface DefineSignedOperationOptions {
|
|
74
|
+
/**
|
|
75
|
+
* Type definitions the payload type is resolved against: a generated
|
|
76
|
+
* binding's `spec.type_defs`, which carries the payload type and every type
|
|
77
|
+
* it references.
|
|
78
|
+
*/
|
|
79
|
+
readonly typeDefs: readonly ContractTypeDef[];
|
|
80
|
+
/**
|
|
81
|
+
* The payload type: either its name as declared with `#[contract_type]`
|
|
82
|
+
* (the `declared` segment of its spec id), which must name exactly one of
|
|
83
|
+
* `typeDefs`, or its full spec id, which selects one type even when another
|
|
84
|
+
* crate or module declares the same name.
|
|
85
|
+
*/
|
|
86
|
+
readonly typeName: string | ContractTypeSelector;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Every segment of a payload type's spec id, as plain strings. A
|
|
90
|
+
* `ContractSpecId` taken from a generated spec is assignable to it.
|
|
91
|
+
*/
|
|
92
|
+
interface ContractTypeSelector {
|
|
93
|
+
readonly crate_name: string;
|
|
94
|
+
readonly major: string;
|
|
95
|
+
readonly module_path: string;
|
|
96
|
+
readonly declared: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A uniformly random `u64` for {@link Operation.nonce}.
|
|
100
|
+
*
|
|
101
|
+
* Consumed `(nonce, block_expiry_height)` pairs are scoped to the verifying
|
|
102
|
+
* contract, not to the signing key, so a random nonce is the choice that
|
|
103
|
+
* stays safe when several keys sign for one contract; a lone key may count
|
|
104
|
+
* instead. Draws from the platform's `crypto.getRandomValues`.
|
|
105
|
+
*/
|
|
106
|
+
declare function randomNonce(): bigint;
|
|
107
|
+
/**
|
|
108
|
+
* Bind signing helpers to a `#[contract_type]` payload.
|
|
109
|
+
*
|
|
110
|
+
* A signed operation authorizes an on-chain action off-chain, so the signer
|
|
111
|
+
* need not submit the transaction: the pattern behind permits, session keys,
|
|
112
|
+
* and delegated wallet actions. The verifying contract embeds
|
|
113
|
+
* `thruput_signed_op::SignedOpReplayCache` and checks the operation with
|
|
114
|
+
* `consume::<Payload>` against the key it holds; this is the client half,
|
|
115
|
+
* producing the `Operation` and signature that contract expects.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* import {
|
|
120
|
+
* defineSignedOperation,
|
|
121
|
+
* randomNonce,
|
|
122
|
+
* } from "@thruputchain/client/signed-op";
|
|
123
|
+
* import { spec, MyWallet, type my_wallet } from "./generated/my_wallet.js";
|
|
124
|
+
*
|
|
125
|
+
* const transfer = defineSignedOperation<my_wallet.v0_1.Transfer>({
|
|
126
|
+
* typeDefs: spec.type_defs,
|
|
127
|
+
* typeName: "Transfer",
|
|
128
|
+
* });
|
|
129
|
+
* const { op, signature } = await transfer.sign(signer, {
|
|
130
|
+
* network: networkHash,
|
|
131
|
+
* verifyingContract: walletAddress,
|
|
132
|
+
* blockExpiryHeight: currentHeight + 100n,
|
|
133
|
+
* nonce: randomNonce(),
|
|
134
|
+
* body: { to: recipient, amount: 42n },
|
|
135
|
+
* });
|
|
136
|
+
* // `op` and `signature` are the arguments of the contract's submit entrypoint.
|
|
137
|
+
* const invocation = MyWallet.v0_1.submit.invocation(walletAddress, gasLimit, {
|
|
138
|
+
* op,
|
|
139
|
+
* signature,
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @throws If `typeName` selects none, or more than one, of `typeDefs`.
|
|
144
|
+
*/
|
|
145
|
+
declare function defineSignedOperation<TBody>(options: DefineSignedOperationOptions): SignedOperationType<TBody>;
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/signedOp/preimage.d.ts
|
|
148
|
+
/** Everything a signed-operation signature commits to. */
|
|
149
|
+
interface SignedOperationPreimage {
|
|
150
|
+
/** Hash of the network the operation is valid on. */
|
|
151
|
+
readonly network: NetworkHash;
|
|
152
|
+
/** Address of the contract entitled to act on the operation. */
|
|
153
|
+
readonly verifyingContract: ContractAddress;
|
|
154
|
+
/**
|
|
155
|
+
* Spec definition of the payload type, as a generated binding ships it in
|
|
156
|
+
* `spec.type_defs`. Part of the signed bytes, so a signature over one
|
|
157
|
+
* payload type is never a signature over another with the same encoding.
|
|
158
|
+
*/
|
|
159
|
+
readonly typeDef: ContractTypeDef;
|
|
160
|
+
/** Last block height (inclusive) at which the operation may execute. */
|
|
161
|
+
readonly blockExpiryHeight: BlockHeight;
|
|
162
|
+
/**
|
|
163
|
+
* Signer-chosen value that, with `blockExpiryHeight`, the verifying
|
|
164
|
+
* contract consumes exactly once.
|
|
165
|
+
*/
|
|
166
|
+
readonly nonce: bigint;
|
|
167
|
+
/** CXS encoding of the payload value. */
|
|
168
|
+
readonly body: Uint8Array;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* The message a signed-operation signature covers:
|
|
172
|
+
*
|
|
173
|
+
* ```text
|
|
174
|
+
* cxs(DomainSeparator("SignedOp")) || network || verifyingContract
|
|
175
|
+
* || cxs(typeDef) || cxs(uniquifier) || body
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* where `cxs(uniquifier)` is `cxs(blockExpiryHeight) || cxs(nonce)`: the
|
|
179
|
+
* chain's own `Uniquifier` encoding, so the replay pair is spelled the way a
|
|
180
|
+
* transaction spells its own. The result is signed directly, like
|
|
181
|
+
* {@link transactionSignaturePreimage}; Ed25519 does its own hashing. It must
|
|
182
|
+
* match the Rust `thruput_domain_separator::SignedOp::preimage` byte for
|
|
183
|
+
* byte, or the verifying contract rejects the signature. Only the first 74
|
|
184
|
+
* bytes are fixed-width: the uniquifier's two fields are CXS varints.
|
|
185
|
+
*
|
|
186
|
+
* {@link defineSignedOperation} calls this after encoding the payload; reach
|
|
187
|
+
* for it directly only when the payload is already CXS bytes.
|
|
188
|
+
*/
|
|
189
|
+
declare function signedOperationPreimage(preimage: SignedOperationPreimage): Uint8Array;
|
|
190
|
+
//#endregion
|
|
191
|
+
export { Operation as a, SignedOperationType as c, DefineSignedOperationOptions as i, defineSignedOperation as l, signedOperationPreimage as n, SignedOperation as o, ContractTypeSelector as r, SignedOperationRequest as s, SignedOperationPreimage as t, randomNonce as u };
|
|
192
|
+
//# sourceMappingURL=index--5LsCotr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index--5LsCotr.d.ts","names":[],"sources":["../src/signedOp/operation.ts","../src/signedOp/preimage.ts"],"mappings":";;;;;;;;;AAmCA;;;;;;;;;AAakB;UAbD,SAAA;EAiBe;EAf9B,mBAAA;EAiB8B;;;;;;AAAA;AAIhC;EAZE,KAAA;EAYqC;EAVrC,IAAA,EAAM,UAAU;AAAA;;UAID,eAAA;EAAA,SACN,EAAA,EAAI,SAAA;EAAA,SACJ,SAAA,EAAW,UAAU;AAAA;;UAIf,sBAAA;EAIa;EAAA,SAFnB,OAAA,EAAS,WAAA;EAST;EAAA,SAPA,iBAAA,EAA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Ot as TransportRequestOptions, Tt as UnsupportedRpcValue, t as RpcClient } from "./client-JixxskeH.cjs";
|
|
2
|
+
import { Ot as ContractSpec, k as CoreThruputClient } from "./readViews-DJyqc7im.cjs";
|
|
3
|
+
import { t as ContractArtifactSpec } from "./artifact-BM_MVzhL.cjs";
|
|
4
|
+
import { F as WalletAccount, a as SubmissionEvidence, k as PrepareTransactionRequest } from "./execution-DYqPDn4O.cjs";
|
|
5
|
+
import { Invocation, NetworkHash, SHA256Hash, SignedTransaction, Transaction } from "@thruputchain/protocol";
|
|
6
|
+
|
|
7
|
+
//#region src/actions/public/getContractSpec.d.ts
|
|
8
|
+
/** Snapshot deployment evidence and its authenticated metadata, if deployed. */
|
|
9
|
+
interface ContractSpecResult extends RpcContractDeploymentResult {
|
|
10
|
+
artifactSpec: ContractArtifactSpec | null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a current deployment and verify its embedded spec against its hash.
|
|
14
|
+
* Missing artifacts and invalid responses throw; neither means no deployment.
|
|
15
|
+
* The snapshot does not establish which implementation produced historical events.
|
|
16
|
+
*/
|
|
17
|
+
declare function getContractSpec(client: RpcClient, request: {
|
|
18
|
+
address: Uint8Array;
|
|
19
|
+
}, options?: TransportRequestOptions): Promise<ContractSpecResult>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/actions/public/getEffectiveContractSpec.d.ts
|
|
22
|
+
interface EffectiveContractSpecResult extends RpcEffectiveContractResult {
|
|
23
|
+
artifactSpec: ContractArtifactSpec | null;
|
|
24
|
+
/** Recognized native interface; not artifact-bound or proof of runtime code. */
|
|
25
|
+
nativeInterface: {
|
|
26
|
+
name: "DefaultWallet";
|
|
27
|
+
spec: ContractSpec;
|
|
28
|
+
} | null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Discover current contract selection without inferring authorization or historical identity.
|
|
32
|
+
* Root context allows the chain-configured fallback; nested excludes that fallback.
|
|
33
|
+
* Transaction-local deployments are outside this committed-state reading.
|
|
34
|
+
*/
|
|
35
|
+
declare function getEffectiveContractSpec(client: RpcClient, request: {
|
|
36
|
+
address: Uint8Array;
|
|
37
|
+
context: "root" | "nested";
|
|
38
|
+
}, options?: TransportRequestOptions): Promise<EffectiveContractSpecResult>;
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/actions/public/decodeWalletRequests.d.ts
|
|
41
|
+
/** Requested child invocations, never proof of execution or child outputs. */
|
|
42
|
+
interface WalletRequests {
|
|
43
|
+
wrapper: "DefaultWallet.execute" | "DefaultWallet.deploy";
|
|
44
|
+
requestedCalls: Invocation[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Interpret a known DefaultWallet root using built-in binding descriptors.
|
|
48
|
+
* Call only after identifying the root as DefaultWallet; matching selectors
|
|
49
|
+
* alone do not establish wallet identity. Malformed recognized inputs throw.
|
|
50
|
+
*/
|
|
51
|
+
declare function decodeDefaultWalletRequests(root: Invocation): WalletRequests | null;
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/actions/public/readTransactionInput.d.ts
|
|
54
|
+
/** Canonical retained input verified against the requested public transaction hash. */
|
|
55
|
+
type VerifiedTransactionInput = {
|
|
56
|
+
status: "available";
|
|
57
|
+
transactionHash: Uint8Array;
|
|
58
|
+
blockHeight: bigint;
|
|
59
|
+
transactionXdr: Uint8Array;
|
|
60
|
+
transaction: Transaction;
|
|
61
|
+
} | {
|
|
62
|
+
status: "unavailable";
|
|
63
|
+
} | UnsupportedRpcValue;
|
|
64
|
+
/**
|
|
65
|
+
* Read and authenticate a retained Transaction, including its root invocation.
|
|
66
|
+
* Unavailable does not prove nonexecution. A matching body hash authenticates
|
|
67
|
+
* neither signatures nor the reported block height, and does not imply success.
|
|
68
|
+
*/
|
|
69
|
+
declare function readTransactionInput(client: RpcClient, request: {
|
|
70
|
+
transactionHash: Uint8Array;
|
|
71
|
+
}, options?: TransportRequestOptions): Promise<VerifiedTransactionInput>;
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/actions/wallet/sendTransaction.d.ts
|
|
74
|
+
/**
|
|
75
|
+
* Serialize and submit once through the native RPC boundary.
|
|
76
|
+
* Unknown admission throws TransactionObservationError with the signed bytes and
|
|
77
|
+
* destination discovery network; that network does not prove the signing network
|
|
78
|
+
* of an already-signed envelope. RPC and transport failures propagate unchanged.
|
|
79
|
+
*/
|
|
80
|
+
declare function sendTransaction(client: Pick<RpcClient, "sendTransaction" | "discovery">, signedTx: SignedTransaction, options?: TransportRequestOptions): Promise<SHA256Hash>;
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/actions/wallet/sendInvocation.d.ts
|
|
83
|
+
/** Prepare, sign, and submit one explicit root invocation. */
|
|
84
|
+
declare function sendInvocation(client: Pick<CoreThruputClient, "getChainTip" | "sendTransaction" | "requireMethods" | "discovery">, account: WalletAccount, networkHash: NetworkHash, request: PrepareTransactionRequest, controls?: {
|
|
85
|
+
signal?: AbortSignal;
|
|
86
|
+
onSigned?: (evidence: SubmissionEvidence) => void | Promise<void>;
|
|
87
|
+
}): Promise<SHA256Hash>;
|
|
88
|
+
//#endregion
|
|
89
|
+
export { WalletRequests as a, getEffectiveContractSpec as c, readTransactionInput as i, ContractSpecResult as l, sendTransaction as n, decodeDefaultWalletRequests as o, VerifiedTransactionInput as r, EffectiveContractSpecResult as s, sendInvocation as t, getContractSpec as u };
|
|
90
|
+
//# sourceMappingURL=index-1-rFirYe.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-1-rFirYe.d.cts","names":[],"sources":["../src/actions/public/getContractSpec.ts","../src/actions/public/getEffectiveContractSpec.ts","../src/actions/public/decodeWalletRequests.ts","../src/actions/public/readTransactionInput.ts","../src/actions/wallet/sendTransaction.ts","../src/actions/wallet/sendInvocation.ts"],"mappings":";;;;;;;;UAoBiB,kBAAA,SAA2B,2BAA2B;EACrE,YAAA,EAAc,oBAAA;AAAA;;;;;;iBAQM,eAAA,CACpB,MAAA,EAAQ,SAA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{ t as Signer } from "./types-BE40oD_Q.cjs";
|
|
2
|
+
import { BlockHeight, ContractAddress, NetworkHash } from "@thruputchain/protocol";
|
|
3
|
+
import { FixedBytes } from "@thruputchain/xdr";
|
|
4
|
+
import { ContractTypeDef } from "@thruputchain/contract-spec";
|
|
5
|
+
|
|
6
|
+
//#region src/signedOp/operation.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Wire form of a signed operation: the `Operation` struct of the
|
|
9
|
+
* `thruput-signed-op-if` interface, in the shape generated bindings give it.
|
|
10
|
+
*
|
|
11
|
+
* The network hash, the verifying contract, and the signing key are covered
|
|
12
|
+
* by the signature but deliberately absent here. The verifying contract
|
|
13
|
+
* supplies the first two from its own syscalls and checks the signature
|
|
14
|
+
* against the key it holds, so a submitter can name neither the network or
|
|
15
|
+
* contract a signature was meant for nor the key it is checked against.
|
|
16
|
+
*
|
|
17
|
+
* `block_expiry_height` and `nonce` are the chain's `Uniquifier`, in its
|
|
18
|
+
* field order, so their encoding is byte for byte a transaction's.
|
|
19
|
+
*/
|
|
20
|
+
interface Operation {
|
|
21
|
+
/** Last block height (inclusive) at which the operation may execute. */
|
|
22
|
+
block_expiry_height: bigint;
|
|
23
|
+
/**
|
|
24
|
+
* Chosen by the signer: any value, as long as the pair
|
|
25
|
+
* `(nonce, block_expiry_height)` has not been consumed at the verifying
|
|
26
|
+
* contract. There is no ordering. Consumed pairs are the contract's, not
|
|
27
|
+
* the key's, so where several keys sign for one contract, draw nonces at
|
|
28
|
+
* random ({@link randomNonce}) rather than counting; a lone key may do
|
|
29
|
+
* either.
|
|
30
|
+
*/
|
|
31
|
+
nonce: bigint;
|
|
32
|
+
/** CXS encoding of the payload value. */
|
|
33
|
+
body: Uint8Array;
|
|
34
|
+
}
|
|
35
|
+
/** An {@link Operation} and the Ed25519 signature over its preimage. */
|
|
36
|
+
interface SignedOperation {
|
|
37
|
+
readonly op: Operation;
|
|
38
|
+
readonly signature: FixedBytes<64>;
|
|
39
|
+
}
|
|
40
|
+
/** What a signer supplies to produce one operation. */
|
|
41
|
+
interface SignedOperationRequest<TBody> {
|
|
42
|
+
/** Hash of the network the operation is valid on. */
|
|
43
|
+
readonly network: NetworkHash;
|
|
44
|
+
/** Address of the contract that will verify and act on the operation. */
|
|
45
|
+
readonly verifyingContract: ContractAddress;
|
|
46
|
+
/** Last block height (inclusive) at which the operation may execute. */
|
|
47
|
+
readonly blockExpiryHeight: bigint;
|
|
48
|
+
/**
|
|
49
|
+
* Signer-chosen replay guard; see {@link Operation.nonce}. Nothing on
|
|
50
|
+
* chain needs reading to pick one: {@link randomNonce} is always safe.
|
|
51
|
+
*/
|
|
52
|
+
readonly nonce: bigint;
|
|
53
|
+
/** The payload value, in the field shape generated bindings use. */
|
|
54
|
+
readonly body: TBody;
|
|
55
|
+
}
|
|
56
|
+
/** Signing helpers bound to one payload type. */
|
|
57
|
+
interface SignedOperationType<TBody> {
|
|
58
|
+
/**
|
|
59
|
+
* Declared name of the payload type: the `declared` segment of its spec id.
|
|
60
|
+
* {@link SignedOperationType.typeDef} carries the full id.
|
|
61
|
+
*/
|
|
62
|
+
readonly typeName: string;
|
|
63
|
+
/** The payload type's spec definition, as bound into every preimage. */
|
|
64
|
+
readonly typeDef: ContractTypeDef;
|
|
65
|
+
/** CXS-encode a payload value the way the contract decodes it. */
|
|
66
|
+
encodeBody(body: TBody): Uint8Array;
|
|
67
|
+
/** The bytes a signature over `request` covers. */
|
|
68
|
+
preimage(request: SignedOperationRequest<TBody>): Uint8Array;
|
|
69
|
+
/** Encode, sign, and package `request` for the verifying contract. */
|
|
70
|
+
sign(signer: Signer, request: SignedOperationRequest<TBody>): Promise<SignedOperation>;
|
|
71
|
+
}
|
|
72
|
+
/** Options for {@link defineSignedOperation}. */
|
|
73
|
+
interface DefineSignedOperationOptions {
|
|
74
|
+
/**
|
|
75
|
+
* Type definitions the payload type is resolved against: a generated
|
|
76
|
+
* binding's `spec.type_defs`, which carries the payload type and every type
|
|
77
|
+
* it references.
|
|
78
|
+
*/
|
|
79
|
+
readonly typeDefs: readonly ContractTypeDef[];
|
|
80
|
+
/**
|
|
81
|
+
* The payload type: either its name as declared with `#[contract_type]`
|
|
82
|
+
* (the `declared` segment of its spec id), which must name exactly one of
|
|
83
|
+
* `typeDefs`, or its full spec id, which selects one type even when another
|
|
84
|
+
* crate or module declares the same name.
|
|
85
|
+
*/
|
|
86
|
+
readonly typeName: string | ContractTypeSelector;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Every segment of a payload type's spec id, as plain strings. A
|
|
90
|
+
* `ContractSpecId` taken from a generated spec is assignable to it.
|
|
91
|
+
*/
|
|
92
|
+
interface ContractTypeSelector {
|
|
93
|
+
readonly crate_name: string;
|
|
94
|
+
readonly major: string;
|
|
95
|
+
readonly module_path: string;
|
|
96
|
+
readonly declared: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A uniformly random `u64` for {@link Operation.nonce}.
|
|
100
|
+
*
|
|
101
|
+
* Consumed `(nonce, block_expiry_height)` pairs are scoped to the verifying
|
|
102
|
+
* contract, not to the signing key, so a random nonce is the choice that
|
|
103
|
+
* stays safe when several keys sign for one contract; a lone key may count
|
|
104
|
+
* instead. Draws from the platform's `crypto.getRandomValues`.
|
|
105
|
+
*/
|
|
106
|
+
declare function randomNonce(): bigint;
|
|
107
|
+
/**
|
|
108
|
+
* Bind signing helpers to a `#[contract_type]` payload.
|
|
109
|
+
*
|
|
110
|
+
* A signed operation authorizes an on-chain action off-chain, so the signer
|
|
111
|
+
* need not submit the transaction: the pattern behind permits, session keys,
|
|
112
|
+
* and delegated wallet actions. The verifying contract embeds
|
|
113
|
+
* `thruput_signed_op::SignedOpReplayCache` and checks the operation with
|
|
114
|
+
* `consume::<Payload>` against the key it holds; this is the client half,
|
|
115
|
+
* producing the `Operation` and signature that contract expects.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* import {
|
|
120
|
+
* defineSignedOperation,
|
|
121
|
+
* randomNonce,
|
|
122
|
+
* } from "@thruputchain/client/signed-op";
|
|
123
|
+
* import { spec, MyWallet, type my_wallet } from "./generated/my_wallet.js";
|
|
124
|
+
*
|
|
125
|
+
* const transfer = defineSignedOperation<my_wallet.v0_1.Transfer>({
|
|
126
|
+
* typeDefs: spec.type_defs,
|
|
127
|
+
* typeName: "Transfer",
|
|
128
|
+
* });
|
|
129
|
+
* const { op, signature } = await transfer.sign(signer, {
|
|
130
|
+
* network: networkHash,
|
|
131
|
+
* verifyingContract: walletAddress,
|
|
132
|
+
* blockExpiryHeight: currentHeight + 100n,
|
|
133
|
+
* nonce: randomNonce(),
|
|
134
|
+
* body: { to: recipient, amount: 42n },
|
|
135
|
+
* });
|
|
136
|
+
* // `op` and `signature` are the arguments of the contract's submit entrypoint.
|
|
137
|
+
* const invocation = MyWallet.v0_1.submit.invocation(walletAddress, gasLimit, {
|
|
138
|
+
* op,
|
|
139
|
+
* signature,
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @throws If `typeName` selects none, or more than one, of `typeDefs`.
|
|
144
|
+
*/
|
|
145
|
+
declare function defineSignedOperation<TBody>(options: DefineSignedOperationOptions): SignedOperationType<TBody>;
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/signedOp/preimage.d.ts
|
|
148
|
+
/** Everything a signed-operation signature commits to. */
|
|
149
|
+
interface SignedOperationPreimage {
|
|
150
|
+
/** Hash of the network the operation is valid on. */
|
|
151
|
+
readonly network: NetworkHash;
|
|
152
|
+
/** Address of the contract entitled to act on the operation. */
|
|
153
|
+
readonly verifyingContract: ContractAddress;
|
|
154
|
+
/**
|
|
155
|
+
* Spec definition of the payload type, as a generated binding ships it in
|
|
156
|
+
* `spec.type_defs`. Part of the signed bytes, so a signature over one
|
|
157
|
+
* payload type is never a signature over another with the same encoding.
|
|
158
|
+
*/
|
|
159
|
+
readonly typeDef: ContractTypeDef;
|
|
160
|
+
/** Last block height (inclusive) at which the operation may execute. */
|
|
161
|
+
readonly blockExpiryHeight: BlockHeight;
|
|
162
|
+
/**
|
|
163
|
+
* Signer-chosen value that, with `blockExpiryHeight`, the verifying
|
|
164
|
+
* contract consumes exactly once.
|
|
165
|
+
*/
|
|
166
|
+
readonly nonce: bigint;
|
|
167
|
+
/** CXS encoding of the payload value. */
|
|
168
|
+
readonly body: Uint8Array;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* The message a signed-operation signature covers:
|
|
172
|
+
*
|
|
173
|
+
* ```text
|
|
174
|
+
* cxs(DomainSeparator("SignedOp")) || network || verifyingContract
|
|
175
|
+
* || cxs(typeDef) || cxs(uniquifier) || body
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* where `cxs(uniquifier)` is `cxs(blockExpiryHeight) || cxs(nonce)`: the
|
|
179
|
+
* chain's own `Uniquifier` encoding, so the replay pair is spelled the way a
|
|
180
|
+
* transaction spells its own. The result is signed directly, like
|
|
181
|
+
* {@link transactionSignaturePreimage}; Ed25519 does its own hashing. It must
|
|
182
|
+
* match the Rust `thruput_domain_separator::SignedOp::preimage` byte for
|
|
183
|
+
* byte, or the verifying contract rejects the signature. Only the first 74
|
|
184
|
+
* bytes are fixed-width: the uniquifier's two fields are CXS varints.
|
|
185
|
+
*
|
|
186
|
+
* {@link defineSignedOperation} calls this after encoding the payload; reach
|
|
187
|
+
* for it directly only when the payload is already CXS bytes.
|
|
188
|
+
*/
|
|
189
|
+
declare function signedOperationPreimage(preimage: SignedOperationPreimage): Uint8Array;
|
|
190
|
+
//#endregion
|
|
191
|
+
export { Operation as a, SignedOperationType as c, DefineSignedOperationOptions as i, defineSignedOperation as l, signedOperationPreimage as n, SignedOperation as o, ContractTypeSelector as r, SignedOperationRequest as s, SignedOperationPreimage as t, randomNonce as u };
|
|
192
|
+
//# sourceMappingURL=index-B5KqSHeL.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-B5KqSHeL.d.c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WAET,iBAAA,EAAmB,eAAA;EDkBJ;;;;;EAAA,SCZf,OAAA,EAAS,eAAA;EDyBZ;EAAA,SCvBG,iBAAA,EAAmB,WAAA;EDuBZ;AAIlB;;;EAJkB,SClBP,KAAA;EDuBA;EAAA,SCrBA,IAAA,EAAM,UAAA;AAAA;;;ADsBe;AAIhC;;;;;;;;;;;;;;;;iBCJgB,uBAAA,CACd,QAAA,EAAU,uBAAA,GACT,UAAU"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { Dt as Transport, Et as RpcParams, Ot as TransportRequestOptions, R as RpcErrorData, Tt as UnsupportedRpcValue } from "./client-JixxskeH.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/transport/http.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Error thrown when a JSON-RPC response contains an `error` object.
|
|
6
|
+
*
|
|
7
|
+
* Malformed envelopes throw `RpcResponseError`, preserving the raw reply.
|
|
8
|
+
*/
|
|
9
|
+
declare class JsonRpcError extends Error {
|
|
10
|
+
/** JSON-RPC numeric error code. */
|
|
11
|
+
code: number;
|
|
12
|
+
/** Optional JSON-RPC error data returned by the gateway. */
|
|
13
|
+
data?: unknown;
|
|
14
|
+
/** JSON-RPC method associated with the failed request, when known. */
|
|
15
|
+
method?: string;
|
|
16
|
+
/** Complete original JSON-RPC error object, including additive fields. */
|
|
17
|
+
readonly raw: unknown;
|
|
18
|
+
readonly rpcMessage: string;
|
|
19
|
+
constructor(code: number, message: string, data?: unknown, method?: string, raw?: unknown);
|
|
20
|
+
}
|
|
21
|
+
/** Error thrown when an HTTP response has a non-successful status. */
|
|
22
|
+
declare class HttpResponseError extends Error {
|
|
23
|
+
readonly endpoint?: string | undefined;
|
|
24
|
+
readonly method?: string | undefined;
|
|
25
|
+
readonly status: number;
|
|
26
|
+
readonly statusText: string;
|
|
27
|
+
constructor(status: number, statusText: string, endpoint?: string | undefined, method?: string | undefined);
|
|
28
|
+
}
|
|
29
|
+
/** Network failure with sanitized endpoint and method context. */
|
|
30
|
+
declare class HttpRequestError extends TypeError {
|
|
31
|
+
readonly endpoint: string;
|
|
32
|
+
readonly method: string;
|
|
33
|
+
constructor(endpoint: string, method: string, cause: unknown);
|
|
34
|
+
}
|
|
35
|
+
/** Limits for opt-in HTTP JSON-RPC batching. */
|
|
36
|
+
interface HttpBatchOptions {
|
|
37
|
+
/** Maximum calls per HTTP request (1–1,000). Defaults to 100. Full batches send immediately. */
|
|
38
|
+
maxSize?: number;
|
|
39
|
+
/** Scheduling window in milliseconds (0–2,147,483,647). Defaults to a zero-delay timer. */
|
|
40
|
+
waitMs?: number;
|
|
41
|
+
}
|
|
42
|
+
/** Options for {@link HttpTransport}. */
|
|
43
|
+
interface HttpTransportOptions {
|
|
44
|
+
/** Additional HTTP headers to include with each JSON-RPC request. */
|
|
45
|
+
headers?: Record<string, string>;
|
|
46
|
+
/** Custom `fetch` implementation, useful for tests or non-standard runtimes. */
|
|
47
|
+
fetch?: typeof fetch;
|
|
48
|
+
/** Abort the request, including response-body reading, with a TimeoutError after this many milliseconds. */
|
|
49
|
+
timeoutMs?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Group concurrent calls into JSON-RPC arrays. Disabled by default.
|
|
52
|
+
* `true` uses 100 calls and a zero-delay scheduling window.
|
|
53
|
+
*
|
|
54
|
+
* Requires an endpoint that accepts JSON-RPC arrays. Even one queued call
|
|
55
|
+
* is sent as an array. Responses are matched by ID, not response order.
|
|
56
|
+
* RPC errors reject their own calls; HTTP failures affect the whole batch.
|
|
57
|
+
* No retries or fallback requests are made, including for submissions.
|
|
58
|
+
*
|
|
59
|
+
* Batching provides no shared snapshot, execution order, or atomicity.
|
|
60
|
+
* Await dependent calls separately. Slow calls can delay other results.
|
|
61
|
+
* Cancelling one call rejects it without cancelling its peers; cancelling
|
|
62
|
+
* every call aborts the HTTP request. Cancellation cannot undo submitted work.
|
|
63
|
+
* `timeoutMs` starts at dispatch and covers reading the response body;
|
|
64
|
+
* the scheduling window is additional to that timeout.
|
|
65
|
+
*/
|
|
66
|
+
batch?: boolean | HttpBatchOptions;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* JSON-RPC 2.0 transport over HTTP POST.
|
|
70
|
+
*
|
|
71
|
+
* `HttpTransport` handles request IDs, JSON-RPC envelopes, optional custom
|
|
72
|
+
* headers, optional timeout cancellation, and conversion of JSON-RPC error
|
|
73
|
+
* responses into {@link JsonRpcError}.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { HttpTransport } from "@thruputchain/client/transport";
|
|
78
|
+
*
|
|
79
|
+
* const transport = new HttpTransport("http://127.0.0.1:9545", {
|
|
80
|
+
* timeoutMs: 10_000,
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* const tip = await transport.request("getChainTip");
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare class HttpTransport implements Transport {
|
|
87
|
+
#private;
|
|
88
|
+
/** Create an HTTP transport for a Thruput JSON-RPC endpoint URL. */
|
|
89
|
+
constructor(url: string, options?: HttpTransportOptions);
|
|
90
|
+
/** Send one JSON-RPC request and return the decoded `result` value. */
|
|
91
|
+
request<T = unknown>(method: string, params?: RpcParams, options?: TransportRequestOptions): Promise<T>;
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/transport/mock.d.ts
|
|
95
|
+
/** Deterministic native RPC transport for examples; it does not execute contract code. */
|
|
96
|
+
declare class MockTransport implements Transport {
|
|
97
|
+
#private;
|
|
98
|
+
request<T = unknown>(method: string, params?: RpcParams, options?: TransportRequestOptions): Promise<T>;
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/transport/readError.d.ts
|
|
102
|
+
/** Infrastructure failure classification; retry budgets remain with the caller. */
|
|
103
|
+
type ReadErrorKind = "transient" | "permanent" | "cancelled" | "unknown";
|
|
104
|
+
/**
|
|
105
|
+
* Classify an infrastructure read failure without replacing the original error.
|
|
106
|
+
*
|
|
107
|
+
* Pass the caller's signal to distinguish explicit cancellation from a transport
|
|
108
|
+
* timeout. Plain Error wrappers are inspected through their causes; domain errors
|
|
109
|
+
* and unrecognized failures remain unknown. A bare TypeError is not evidence of
|
|
110
|
+
* a network failure. Custom transports should use HttpRequestError for that case.
|
|
111
|
+
* Transaction-not-found remains operation-specific rather than a general retry.
|
|
112
|
+
* This classification never authorizes transaction resubmission.
|
|
113
|
+
*/
|
|
114
|
+
declare function classifyReadError(error: unknown, options?: TransportRequestOptions): ReadErrorKind;
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/transport/txInvalidDetail.d.ts
|
|
117
|
+
/** A validated native admission bound violation. Unknown details remain on the raw error. */
|
|
118
|
+
type TxInvalidDetail = Exclude<NonNullable<Extract<RpcErrorData, {
|
|
119
|
+
kind: "transactionInvalid";
|
|
120
|
+
}>["detail"]>, UnsupportedRpcValue>;
|
|
121
|
+
/** Read known transaction-bound evidence without inferring retry permission. */
|
|
122
|
+
declare function txInvalidDetail(error: unknown): TxInvalidDetail | null;
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/rpc/errors.d.ts
|
|
125
|
+
/** Native causes. Codes alone never grant write retry permission. */
|
|
126
|
+
declare const NativeRpcErrorCode: {
|
|
127
|
+
readonly BackendDataInvalid: -32054;
|
|
128
|
+
readonly BackendTimeout: -32051;
|
|
129
|
+
readonly BackendUnavailable: -32050;
|
|
130
|
+
readonly ContractArtifactUnavailable: -32014;
|
|
131
|
+
readonly FundingAttemptStopped: -32030;
|
|
132
|
+
readonly HistoryUnavailable: -32013;
|
|
133
|
+
readonly InvalidParams: -32602;
|
|
134
|
+
readonly LocalFundingUnresolved: -32031;
|
|
135
|
+
readonly Overloaded: -32053;
|
|
136
|
+
readonly StateHeightUnavailable: -32012;
|
|
137
|
+
readonly TransactionInvalid: -32000;
|
|
138
|
+
readonly TransactionRejected: -32001;
|
|
139
|
+
};
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/rpc/errorReader.d.ts
|
|
142
|
+
type DecodedRpcError = {
|
|
143
|
+
classification: "known";
|
|
144
|
+
data: RpcErrorData;
|
|
145
|
+
raw: unknown;
|
|
146
|
+
} | {
|
|
147
|
+
classification: "unclassified";
|
|
148
|
+
raw: unknown;
|
|
149
|
+
};
|
|
150
|
+
/** A native RPC failure retains the transport error and a conservative typed interpretation. */
|
|
151
|
+
declare class NativeRpcError extends JsonRpcError {
|
|
152
|
+
readonly decoded: DecodedRpcError;
|
|
153
|
+
constructor(error: JsonRpcError, method: string, expectedTransactionHash?: Uint8Array);
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/transport/responseError.d.ts
|
|
157
|
+
/** Malformed JSON-RPC reply after dispatch. Raw data is retained; write outcome is unknown. */
|
|
158
|
+
declare class RpcResponseError extends Error {
|
|
159
|
+
readonly raw: unknown;
|
|
160
|
+
constructor(message: string, raw: unknown);
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
export { TxInvalidDetail as a, classifyReadError as c, HttpRequestError as d, HttpResponseError as f, JsonRpcError as h, NativeRpcErrorCode as i, MockTransport as l, HttpTransportOptions as m, DecodedRpcError as n, txInvalidDetail as o, HttpTransport as p, NativeRpcError as r, ReadErrorKind as s, RpcResponseError as t, HttpBatchOptions as u };
|
|
164
|
+
//# sourceMappingURL=index-BraLWObY.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BraLWObY.d.cts","names":[],"sources":["../src/transport/http.ts","../src/transport/mock.ts","../src/transport/readError.ts","../src/transport/txInvalidDetail.ts","../src/rpc/errors.ts","../src/rpc/errorReader.ts","../src/transport/responseError.ts"],"mappings":";;;;;AASA;;;cAAa,YAAA,SAAqB,KAAK;EAAL;EAEhC,IAAA;EAGA;EAAA,IAAA;EAMS;EAHT,MAAA;;WAGS,GAAA;EAAA,SACA,UAAA;cAGP,IAAA,UACA,OAAA,UACA,IAAA,YACA,MAAA,WACA,GAAA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