@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,263 @@
|
|
|
1
|
+
import { Ot as TransportRequestOptions } from "./client-JixxskeH.cjs";
|
|
2
|
+
import { $t as WaitForTransactionReceiptOptions, E as AirdropActions, Kt as RequestAirdropOptions, a as ContractCall, k as CoreThruputClient, sn as AirdropSucceeded, un as BalanceResponse } from "./readViews-DJyqc7im.cjs";
|
|
3
|
+
import { F as WalletAccount, N as PubkeyAccount, P as SourceAddressAccount, T as DeploymentOptions, _ as WalletBatchExecutionRequest, a as SubmissionEvidence, k as PrepareTransactionRequest, r as ExecutionResult, t as CallResults, v as WalletExecutionRequest, w as ContractDeployment, y as WalletInvocationAdapter } from "./execution-DYqPDn4O.cjs";
|
|
4
|
+
import { A as WalletProvider, D as SubmitTransactionResult, E as SignTransactionResult, O as WalletAccount$1, k as WalletCapabilities } from "./index-CIHK7Ew9.cjs";
|
|
5
|
+
import { ContractAddress, GasAmount, NetworkHash, SHA256Hash, SignedTransaction, Transaction } from "@thruputchain/protocol";
|
|
6
|
+
|
|
7
|
+
//#region src/wallet/providerClient.d.ts
|
|
8
|
+
/** Root options and ordered calls for atomic provider-wallet execution. */
|
|
9
|
+
type PrepareBatchExecutionRequest = WalletBatchExecutionRequest & Omit<PrepareExecutionRequest, "invocation">;
|
|
10
|
+
/** Exact signed evidence available before broadcasting. Persist on the original network. */
|
|
11
|
+
interface PendingWalletTransaction extends SignTransactionResult {
|
|
12
|
+
readonly account: WalletAccount$1;
|
|
13
|
+
readonly networkHash: string;
|
|
14
|
+
}
|
|
15
|
+
/** Lifecycle controls. Cancellation can prevent dispatch; it never cancels a broadcast already sent. */
|
|
16
|
+
interface ProviderExecutionOptions {
|
|
17
|
+
/** Await durable application persistence before submitting; rejection prevents broadcast. */
|
|
18
|
+
onSigned: (pending: PendingWalletTransaction) => void | Promise<void>;
|
|
19
|
+
/** Shared submission/receipt budget after signing and persistence; network identity is pinned. */
|
|
20
|
+
wait?: WaitForTransactionReceiptOptions;
|
|
21
|
+
}
|
|
22
|
+
/** Typed calls executed atomically through DefaultWallet. */
|
|
23
|
+
interface ExecuteCallsRequest<T extends readonly ContractCall[]> {
|
|
24
|
+
calls: T;
|
|
25
|
+
gasLimit: GasAmount;
|
|
26
|
+
contractsToDeploy?: PrepareExecutionRequest["contractsToDeploy"];
|
|
27
|
+
expiryBlocks?: bigint;
|
|
28
|
+
}
|
|
29
|
+
/** External wallet binding. Network hash uses unprefixed, case-sensitive base58. */
|
|
30
|
+
interface CreateProviderWalletClientOptions {
|
|
31
|
+
/**
|
|
32
|
+
* RPC client connected to and verified against the application's expected network.
|
|
33
|
+
* A validated client identity must match `networkHash`; an unqualified
|
|
34
|
+
* CoreThruputClient requires the caller to verify its RPC network separately.
|
|
35
|
+
*/
|
|
36
|
+
client: CoreThruputClient;
|
|
37
|
+
/** Live external provider with an already authorized session. */
|
|
38
|
+
provider: WalletProvider;
|
|
39
|
+
/** Wire pubkey account from the provider subpath, snapshotted at construction. */
|
|
40
|
+
account: WalletAccount$1;
|
|
41
|
+
/** Trusted application network identity: 32-byte base58; must match the session exactly. */
|
|
42
|
+
networkHash: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Explicit prepare/sign/persist/submit flow without access to a raw signer.
|
|
46
|
+
* Allows one in-flight operation; concurrent calls fail with code -32002. Checks
|
|
47
|
+
* `getSession` before each operation and permanently invalidates on every `change`,
|
|
48
|
+
* a failed session read, or a mismatched session. Dispose and recreate after a
|
|
49
|
+
* change or reconnect; there is no automatic reconnect or retry.
|
|
50
|
+
*
|
|
51
|
+
* @see https://docs.thruput.network/tools/wallet-integration/
|
|
52
|
+
*/
|
|
53
|
+
interface ProviderWalletClient {
|
|
54
|
+
/** Prepare a root deployment, preserving the explicit signing boundary. */
|
|
55
|
+
prepareDeployment(deployment: ContractDeployment, options: DeploymentOptions): Promise<Transaction>;
|
|
56
|
+
/** Persist approved evidence, deploy once, and verify the committed address. */
|
|
57
|
+
deployContractAndWait(deployment: ContractDeployment, options: DeploymentOptions, controls: ProviderExecutionOptions): Promise<ExecutionResult & {
|
|
58
|
+
address: import("@thruputchain/protocol").ContractAddress;
|
|
59
|
+
}>;
|
|
60
|
+
/** Prepare, sign, persist, submit once, then observe a successful receipt. */
|
|
61
|
+
executeAndWait(request: PrepareExecutionRequest, options: ProviderExecutionOptions): Promise<ExecutionResult>;
|
|
62
|
+
/** Execute an ordered atomic batch and decode typed child results. */
|
|
63
|
+
executeCallsAndWait<T extends readonly ContractCall[]>(request: ExecuteCallsRequest<T>, options: ProviderExecutionOptions): Promise<ExecutionResult & {
|
|
64
|
+
values: CallResults<T>;
|
|
65
|
+
}>;
|
|
66
|
+
/** Read fresh account/network capabilities; only 4200 falls back to unsupported. */
|
|
67
|
+
getCapabilities(): Promise<WalletCapabilities>;
|
|
68
|
+
/** Prepare one atomic batch after checking support. Does not sign or submit. */
|
|
69
|
+
prepareBatchExecution(request: PrepareBatchExecutionRequest): Promise<Transaction>;
|
|
70
|
+
/**
|
|
71
|
+
* Prepare a transaction using the default-wallet wrapper and existing nonce and
|
|
72
|
+
* expiry handling. Generates a random transaction nonce when none is supplied;
|
|
73
|
+
* this is separate from the account-derivation nonce. Snapshots input before
|
|
74
|
+
* asynchronous work and enforces the unsigned size bound. Does not sign or submit.
|
|
75
|
+
*/
|
|
76
|
+
prepareExecution(request: PrepareExecutionRequest): Promise<Transaction>;
|
|
77
|
+
/**
|
|
78
|
+
* Request approval and sign without broadcasting. Snapshots the unsigned bytes,
|
|
79
|
+
* checks the account claim, and verifies exact bytes, strict network-bound
|
|
80
|
+
* signature, and canonical hash with {@link verifySignTransactionResult}.
|
|
81
|
+
* Once a new request passes local transaction and account-claim validation, it
|
|
82
|
+
* clears the previous approval before awaiting the session or provider. Failure
|
|
83
|
+
* or user rejection does not restore that approval. Only the latest successfully
|
|
84
|
+
* verified result can be submitted; invalid provider results invalidate the adapter.
|
|
85
|
+
* Await durable persistence of the result,
|
|
86
|
+
* account, and network before calling {@link submitTransaction}.
|
|
87
|
+
*/
|
|
88
|
+
signTransaction(transaction: Transaction): Promise<SignTransactionResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Submit the exact signed bytes and hash of this adapter's latest approval.
|
|
91
|
+
* Consumes approval before requesting broadcast, including when that request
|
|
92
|
+
* fails; the adapter never retries. Returns a broadcast acknowledgement, not an
|
|
93
|
+
* execution receipt, and verifies its hash against the approved result.
|
|
94
|
+
*
|
|
95
|
+
* Treat a submit failure as potentially broadcast. Keep the previously persisted
|
|
96
|
+
* hash and query status/receipt on the original network; do not automatically
|
|
97
|
+
* prepare, sign, or execute a replacement transaction. A timeout, session change,
|
|
98
|
+
* or invalid response can occur after broadcast. See the factory's persistence example.
|
|
99
|
+
*/
|
|
100
|
+
submitTransaction(signed: SignTransactionResult): Promise<SubmitTransactionResult>;
|
|
101
|
+
/**
|
|
102
|
+
* Idempotently unsubscribe and permanently invalidate this adapter, clearing its
|
|
103
|
+
* approval. Does not revoke provider permission or cancel pending requests.
|
|
104
|
+
* A late response cannot reactivate the adapter. Use provider `disconnect` to
|
|
105
|
+
* revoke permission; create a new adapter for a later authorized session.
|
|
106
|
+
*/
|
|
107
|
+
dispose(): void;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Synchronously bind a pubkey provider account without modifying the RPC client.
|
|
111
|
+
* Does not connect or request permission: first await provider `connect` and
|
|
112
|
+
* validate its session. Snapshots account/network configuration, validates account
|
|
113
|
+
* derivation and any validated client network identity, and subscribes to changes.
|
|
114
|
+
* Supply the application's trusted expected network hash, not a value adopted from
|
|
115
|
+
* the wallet. The RPC client must be connected to and verified against that same
|
|
116
|
+
* network. Every native client carries a discovered network identity, checked here.
|
|
117
|
+
* See {@link ProviderWalletClient} for invalidation and concurrency rules.
|
|
118
|
+
* Providers own signing UI deadlines. Execution controls bound submission and
|
|
119
|
+
* observation after signing; they cannot cancel a broadcast already sent.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* Await an application-owned `onSigned` callback to durably save the signed result
|
|
123
|
+
* and its original account/network before broadcasting. If saving fails, submission
|
|
124
|
+
* is never requested.
|
|
125
|
+
* `expectedNetworkHash` comes from trusted application configuration, and `client`
|
|
126
|
+
* must already be connected to and verified against that network.
|
|
127
|
+
*
|
|
128
|
+
* ```ts
|
|
129
|
+
* import type { CoreThruputClient } from "@thruputchain/client";
|
|
130
|
+
* import {
|
|
131
|
+
* parseWalletSession,
|
|
132
|
+
* parseWalletNetworkHash,
|
|
133
|
+
* type SignTransactionResult,
|
|
134
|
+
* type WalletAccount,
|
|
135
|
+
* type WalletProvider,
|
|
136
|
+
* } from "@thruputchain/client/provider";
|
|
137
|
+
* import {
|
|
138
|
+
* createProviderWalletClient,
|
|
139
|
+
* type PrepareExecutionRequest,
|
|
140
|
+
* } from "@thruputchain/client/wallet";
|
|
141
|
+
*
|
|
142
|
+
* async function sendWithWallet(
|
|
143
|
+
* client: CoreThruputClient,
|
|
144
|
+
* provider: WalletProvider,
|
|
145
|
+
* expectedNetworkHash: string,
|
|
146
|
+
* request: PrepareExecutionRequest,
|
|
147
|
+
* onSigned: (pending: SignTransactionResult & {
|
|
148
|
+
* account: WalletAccount;
|
|
149
|
+
* networkHash: string;
|
|
150
|
+
* }) => Promise<void>,
|
|
151
|
+
* ) {
|
|
152
|
+
* const networkHash = parseWalletNetworkHash(expectedNetworkHash);
|
|
153
|
+
* const session = parseWalletSession(await provider.request({ method: "connect" }));
|
|
154
|
+
* if (session.networkHash !== networkHash) {
|
|
155
|
+
* throw new Error("Wallet network does not match the application network");
|
|
156
|
+
* }
|
|
157
|
+
* const account = session.accounts[0];
|
|
158
|
+
* if (!account) throw new Error("No authorized account");
|
|
159
|
+
* const wallet = createProviderWalletClient({
|
|
160
|
+
* client, provider, account, networkHash,
|
|
161
|
+
* });
|
|
162
|
+
* try {
|
|
163
|
+
* const transaction = await wallet.prepareExecution(request);
|
|
164
|
+
* const signed = await wallet.signTransaction(transaction);
|
|
165
|
+
* await onSigned({ ...signed, account, networkHash });
|
|
166
|
+
* // On submit failure, recover using the saved hash and original network.
|
|
167
|
+
* return await wallet.submitTransaction(signed);
|
|
168
|
+
* } finally {
|
|
169
|
+
* wallet.dispose();
|
|
170
|
+
* }
|
|
171
|
+
* }
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @see https://docs.thruput.network/tools/wallet-integration/
|
|
175
|
+
* @see https://docs.thruput.network/tools/wallet-provider/
|
|
176
|
+
*/
|
|
177
|
+
declare function createProviderWalletClient(options: CreateProviderWalletClientOptions): ProviderWalletClient;
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/wallet/client.d.ts
|
|
180
|
+
/** Wallet airdrop options with the bound account as the default recipient. */
|
|
181
|
+
type WalletRequestAirdropOptions = Omit<RequestAirdropOptions, "recipient"> & {
|
|
182
|
+
readonly recipient?: ContractAddress;
|
|
183
|
+
};
|
|
184
|
+
/** Signer-bound transaction and account actions. */
|
|
185
|
+
interface WalletActions<TAccount extends WalletAccount = WalletAccount> {
|
|
186
|
+
readonly account: TAccount;
|
|
187
|
+
getBalance(request?: {
|
|
188
|
+
address?: Uint8Array;
|
|
189
|
+
}, options?: TransportRequestOptions): Promise<BalanceResponse>;
|
|
190
|
+
prepareTransaction(request: PrepareTransactionRequest): Promise<Transaction>;
|
|
191
|
+
signTransaction(transaction: Transaction): Promise<SignedTransaction>;
|
|
192
|
+
sendInvocation(request: PrepareTransactionRequest): Promise<SHA256Hash>;
|
|
193
|
+
/** Prepare explicit funding, deployment and optional initialization in one root. */
|
|
194
|
+
prepareDeployment(deployment: ContractDeployment, options: DeploymentOptions): Promise<Transaction>;
|
|
195
|
+
/** Submit deployment and return its predicted address before commitment. */
|
|
196
|
+
deployContract(deployment: ContractDeployment, options: DeploymentOptions): Promise<{
|
|
197
|
+
transactionHash: SHA256Hash;
|
|
198
|
+
address: ContractAddress;
|
|
199
|
+
}>;
|
|
200
|
+
/** Deploy, wait for success and verify the returned address. */
|
|
201
|
+
deployContractAndWait(deployment: ContractDeployment, options: DeploymentOptions, wait?: WaitForTransactionReceiptOptions): Promise<ExecutionResult & {
|
|
202
|
+
address: ContractAddress;
|
|
203
|
+
}>;
|
|
204
|
+
}
|
|
205
|
+
/** Transaction options accepted when wrapping an inner wallet invocation. */
|
|
206
|
+
type PrepareExecutionRequest<TRequest extends WalletExecutionRequest = WalletExecutionRequest> = TRequest & Omit<PrepareTransactionRequest, "invocation">;
|
|
207
|
+
/** Wallet-contract wrapping actions available when an adapter is configured. */
|
|
208
|
+
interface WalletExecutionActions<TRequest extends WalletExecutionRequest = WalletExecutionRequest> {
|
|
209
|
+
prepareExecution(request: PrepareExecutionRequest<TRequest>): Promise<Transaction>;
|
|
210
|
+
execute(request: PrepareExecutionRequest<TRequest>): Promise<SHA256Hash>;
|
|
211
|
+
/** Submit and require a successful committed receipt. */
|
|
212
|
+
executeAndWait(request: PrepareExecutionRequest<TRequest>, options?: WaitForTransactionReceiptOptions): Promise<ExecutionResult>;
|
|
213
|
+
/** Execute typed calls atomically and decode their ordered return values. */
|
|
214
|
+
executeCallsAndWait<T extends readonly ContractCall[]>(request: ExecuteCallsRequest<T>, options?: WaitForTransactionReceiptOptions): Promise<ExecutionResult & {
|
|
215
|
+
values: CallResults<T>;
|
|
216
|
+
}>;
|
|
217
|
+
}
|
|
218
|
+
/** Account-defaulted funding available when the underlying client supports it. */
|
|
219
|
+
interface WalletAirdropActions {
|
|
220
|
+
requestAirdrop(options?: WalletRequestAirdropOptions): Promise<AirdropSucceeded>;
|
|
221
|
+
}
|
|
222
|
+
/** Existing client methods plus signer-bound wallet actions. */
|
|
223
|
+
type WalletClient<TClient extends CoreThruputClient, TAccount extends WalletAccount = WalletAccount> = Omit<TClient, "getBalance" | "requestAirdrop" | "account" | "prepareTransaction" | "signTransaction" | "sendInvocation" | "prepareExecution" | "execute"> & WalletActions<TAccount> & (TClient extends AirdropActions ? WalletAirdropActions : object);
|
|
224
|
+
/** Wallet client with adapter-aware inner invocation execution. */
|
|
225
|
+
type ExecutableWalletClient<TClient extends CoreThruputClient, TAccount extends WalletAccount = WalletAccount, TRequest extends WalletExecutionRequest = WalletExecutionRequest> = WalletClient<TClient, TAccount> & WalletExecutionActions<TRequest>;
|
|
226
|
+
/** Signing-network input inferred from whether a client has validated identity. */
|
|
227
|
+
type WalletNetworkOptions<TClient extends CoreThruputClient> = TClient extends {
|
|
228
|
+
readonly network: {
|
|
229
|
+
readonly networkHash: Uint8Array;
|
|
230
|
+
};
|
|
231
|
+
} ? {
|
|
232
|
+
readonly networkHash?: never;
|
|
233
|
+
} : {
|
|
234
|
+
/** Signing network required when the client has no validated identity. */readonly networkHash: NetworkHash;
|
|
235
|
+
};
|
|
236
|
+
/** Decorate an existing client with signer-bound wallet behavior. */
|
|
237
|
+
declare function createWalletClient<TClient extends CoreThruputClient, TAccount extends WalletAccount, TRequest extends WalletExecutionRequest>(options: {
|
|
238
|
+
readonly client: TClient;
|
|
239
|
+
readonly account: TAccount;
|
|
240
|
+
readonly onSigned?: (submission: SubmissionEvidence) => void | Promise<void>;
|
|
241
|
+
readonly invocationAdapter: WalletInvocationAdapter<TRequest>;
|
|
242
|
+
} & WalletNetworkOptions<TClient>): ExecutableWalletClient<TClient, TAccount, TRequest>;
|
|
243
|
+
declare function createWalletClient<TClient extends CoreThruputClient, TAccount extends PubkeyAccount>(options: {
|
|
244
|
+
readonly client: TClient;
|
|
245
|
+
readonly account: TAccount;
|
|
246
|
+
readonly onSigned?: (submission: SubmissionEvidence) => void | Promise<void>;
|
|
247
|
+
readonly invocationAdapter?: undefined;
|
|
248
|
+
} & WalletNetworkOptions<TClient>): ExecutableWalletClient<TClient, TAccount>;
|
|
249
|
+
declare function createWalletClient<TClient extends CoreThruputClient, TAccount extends SourceAddressAccount>(options: {
|
|
250
|
+
readonly client: TClient;
|
|
251
|
+
readonly account: TAccount;
|
|
252
|
+
readonly onSigned?: (submission: SubmissionEvidence) => void | Promise<void>;
|
|
253
|
+
readonly invocationAdapter?: undefined;
|
|
254
|
+
} & WalletNetworkOptions<TClient>): WalletClient<TClient, TAccount>;
|
|
255
|
+
declare function createWalletClient<TClient extends CoreThruputClient, TAccount extends WalletAccount>(options: {
|
|
256
|
+
readonly client: TClient;
|
|
257
|
+
readonly account: TAccount;
|
|
258
|
+
readonly onSigned?: (submission: SubmissionEvidence) => void | Promise<void>;
|
|
259
|
+
readonly invocationAdapter?: undefined;
|
|
260
|
+
} & WalletNetworkOptions<TClient>): WalletClient<TClient, TAccount>;
|
|
261
|
+
//#endregion
|
|
262
|
+
export { WalletClient as a, WalletRequestAirdropOptions as c, ExecuteCallsRequest as d, PendingWalletTransaction as f, createProviderWalletClient as g, ProviderWalletClient as h, WalletAirdropActions as i, createWalletClient as l, ProviderExecutionOptions as m, PrepareExecutionRequest as n, WalletExecutionActions as o, PrepareBatchExecutionRequest as p, WalletActions as r, WalletNetworkOptions as s, ExecutableWalletClient as t, CreateProviderWalletClientOptions as u };
|
|
263
|
+
//# sourceMappingURL=index-CVrhB9Dr.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CVrhB9Dr.d.cts","names":[],"sources":["../src/wallet/providerClient.ts","../src/wallet/client.ts"],"mappings":";;;;;;;;KA+DY,4BAAA,GAA+B,2BAAA,GACzC,IAAA,CAAK,uBAAA;;UAGU,wBAAA,SAAiC,qBAAqB;EAAA,SAC5D,OAAA,EAAS,eAAA;EAAA,SACT,WAAA;AAAA;;UAIM,wBAAA;EATa;EAW5B,QAAA,GAAW,OAAA,EAAS,wBAAA,YAAoC,OAAA;EARzC;EAUf,IAAA,GAAO,gCAAA;AAAA;;UAIQ,mBAAA,oBAAuC,YAAA;EACtD,KAAA,EAAO,CAAA;EACP,QAAA,EAAU,SAAA;EACV,iBAAA,GAAoB,uBAAA;EACpB,YAAA;AAAA;AAZF;AAAA,UAgBiB,iCAAA;;;;;;EAMf,MAAA,EAAQ,iBAAA;EApBR;EAsBA,QAAA,EAAU,cAAA;EAtBC;EAwBX,OAAA,EAAS,eAAA;EAtBT;EAwBA,WAAA;AAAA;AAxBuC;AAIzC;;;;;;;;AAJyC,UAoCxB,oBAAA;EAhCoB;EAkCnC,iBAAA,CACE,UAAA,EAAY,kBAAA,EACZ,OAAA,EAAS,iBAAA,GACR,OAAA,CAAQ,WAAA;EApCX;EAsCA,qBAAA,CACE,UAAA,EAAY,kBAAA,EACZ,OAAA,EAAS,iBAAA,EACT,QAAA,EAAU,wBAAA,GACT,OAAA,CACD,eAAA;IACE,OAAA,mCAA0C,eAAA;EAAA;EA1C9C;EA8CA,cAAA,CACE,OAAA,EAAS,uBAAA,EACT,OAAA,EAAS,wBAAA,GACR,OAA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AAA,IACxB,YAAA,CAAa,OAAA,EAAS,QAAA"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { A as ThruputClient, Ft as ContractTypeDef, Ot as ContractSpec, Pt as ContractType$1, l as ContractMethod, y as ContractViewOptions } from "./readViews-DQoaUORa.js";
|
|
2
|
+
import { Calldata, Contract, ContractAddress, Invocation, SHA256Hash } from "@thruputchain/protocol";
|
|
3
|
+
import { FixedArray, FixedBytes as FixedBytes$1, XdrCodec, fixedArray as fixedArray$1, fixedBytes as fixedBytes$1 } from "@thruputchain/xdr";
|
|
4
|
+
|
|
5
|
+
//#region src/contract/encode.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Resolve a contract-spec type into the XDR/CXS codec used to encode values.
|
|
8
|
+
*
|
|
9
|
+
* Pass `namedCodecs` when resolving named structs, enums, or unions from a
|
|
10
|
+
* contract spec. Build that map with {@link buildNamedCodecs}.
|
|
11
|
+
*/
|
|
12
|
+
declare function resolveCodec(ty: ContractType$1, namedCodecs?: Record<string, XdrCodec<unknown>>): XdrCodec<unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* Encode method arguments into contract calldata using a contract spec.
|
|
15
|
+
*
|
|
16
|
+
* Use this when constructing invocations from a spec without generated
|
|
17
|
+
* TypeScript bindings. Generated descriptors use their own resolved codecs.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const namedCodecs = buildNamedCodecs(spec.type_defs);
|
|
22
|
+
* const calldata = encodeCalldata(
|
|
23
|
+
* spec,
|
|
24
|
+
* "Counter",
|
|
25
|
+
* "increment",
|
|
26
|
+
* [1n],
|
|
27
|
+
* namedCodecs,
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare function encodeCalldata(spec: ContractSpec, interfaceName: string, methodName: string, args: unknown[], namedCodecs: Record<string, XdrCodec<unknown>>): Calldata;
|
|
32
|
+
/**
|
|
33
|
+
* Decode contract calldata into an object keyed by argument name.
|
|
34
|
+
*
|
|
35
|
+
* This is primarily useful for tooling, tests, and debugging generated
|
|
36
|
+
* invocations.
|
|
37
|
+
*/
|
|
38
|
+
declare function decodeCalldata(spec: ContractSpec, interfaceName: string, methodName: string, data: Uint8Array, namedCodecs: Record<string, XdrCodec<unknown>>): Record<string, unknown>;
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/contract/specMethod.d.ts
|
|
41
|
+
/** A declared exception decoded from a spec without generated value types. */
|
|
42
|
+
interface SpecDeclaredException {
|
|
43
|
+
kind: "declared";
|
|
44
|
+
selector: bigint;
|
|
45
|
+
name: string | null;
|
|
46
|
+
value: unknown;
|
|
47
|
+
}
|
|
48
|
+
/** A call interpreted using the supplied spec, not evidence of code execution. */
|
|
49
|
+
interface SpecDecodedCall {
|
|
50
|
+
interfaceName: string;
|
|
51
|
+
interfaceVersion: string;
|
|
52
|
+
methodName: string;
|
|
53
|
+
args: Record<string, unknown> | undefined;
|
|
54
|
+
method: ContractMethod<Record<string, unknown> | void, unknown, SpecDeclaredException>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Decode a selector and arguments with the generated-binding codecs.
|
|
58
|
+
* Unknown selectors return null; malformed known inputs throw. The caller must
|
|
59
|
+
* establish the spec's identity. A current spec does not prove historical code.
|
|
60
|
+
*/
|
|
61
|
+
declare function createContractCallDecoder(spec: ContractSpec): (invocation: Pick<Invocation, "entrypoint" | "calldata">) => SpecDecodedCall | null;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/contract/codegen.d.ts
|
|
64
|
+
/**
|
|
65
|
+
* Build codecs for named contract-spec types.
|
|
66
|
+
*
|
|
67
|
+
* The returned map is required by {@link encodeCalldata},
|
|
68
|
+
* {@link decodeCalldata}, and {@link resolveCodec} whenever a method argument
|
|
69
|
+
* references a named struct, enum, or union. It is keyed by
|
|
70
|
+
* {@link specIdKey} of each type's spec id.
|
|
71
|
+
*
|
|
72
|
+
* @throws If two definitions share a spec id.
|
|
73
|
+
*/
|
|
74
|
+
declare function buildNamedCodecs(typeDefs: ContractTypeDef[]): Record<string, XdrCodec<unknown>>;
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/contract/hash.d.ts
|
|
77
|
+
/**
|
|
78
|
+
* Return the network identity of a protocol contract.
|
|
79
|
+
*
|
|
80
|
+
* The hash covers the canonical encoded `Contract`, including its type and
|
|
81
|
+
* payload framing. Hashing only the raw artifact bytes produces a different
|
|
82
|
+
* value and therefore a different derived address.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* import {
|
|
87
|
+
* deriveContractAddress,
|
|
88
|
+
* hashContract,
|
|
89
|
+
* } from "@thruputchain/client";
|
|
90
|
+
*
|
|
91
|
+
* const contractHash = hashContract(contract);
|
|
92
|
+
* const address = deriveContractAddress(wallet, deploymentNonce, contractHash);
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
declare function hashContract(contract: Contract): SHA256Hash;
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/derivation/contractAddress.d.ts
|
|
98
|
+
/**
|
|
99
|
+
* The on-chain address a deployment produces:
|
|
100
|
+
* `sha256(txs(ContractDeploymentHashPreimage))` over the deployer, nonce, and
|
|
101
|
+
* contract hash.
|
|
102
|
+
*/
|
|
103
|
+
declare function deriveContractAddress(deployer: ContractAddress, nonce: SHA256Hash, contractHash: SHA256Hash): ContractAddress;
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/contract/errors.d.ts
|
|
106
|
+
/** Error raised when contract bytes do not match their declared ABI type. */
|
|
107
|
+
declare class ContractDecodeError extends Error {
|
|
108
|
+
constructor(message: string, options?: ErrorOptions);
|
|
109
|
+
}
|
|
110
|
+
/** Retrieved bytes or response metadata failed identity/canonical validation. */
|
|
111
|
+
declare class ContractVerificationError extends Error {
|
|
112
|
+
constructor(message: string, options?: ErrorOptions);
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/contract/signedToken.d.ts
|
|
116
|
+
declare const signedTokenPreimageBrand: unique symbol;
|
|
117
|
+
/**
|
|
118
|
+
* A signed auth token as it appears in contract arguments and return values.
|
|
119
|
+
*
|
|
120
|
+
* On the wire a token occupies no calldata bytes: the runtime passes its
|
|
121
|
+
* handle out of band, and only contracts can mint or consume one. A client
|
|
122
|
+
* therefore only ever sees a placeholder, which this type is. `TPreimage`
|
|
123
|
+
* records the token's declared preimage type for documentation; no preimage
|
|
124
|
+
* is ever available off chain.
|
|
125
|
+
*/
|
|
126
|
+
interface SignedToken<TPreimage = unknown> {
|
|
127
|
+
readonly kind: "signedToken";
|
|
128
|
+
readonly [signedTokenPreimageBrand]?: TPreimage;
|
|
129
|
+
}
|
|
130
|
+
/** The placeholder standing in for a signed auth token. */
|
|
131
|
+
declare function signedToken<TPreimage = unknown>(): SignedToken<TPreimage>;
|
|
132
|
+
/** Whether `value` is a signed-token placeholder. */
|
|
133
|
+
declare function isSignedToken(value: unknown): value is SignedToken;
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/contract/instance.d.ts
|
|
136
|
+
/** A method descriptor with address/client defaults bound for reads and calls. */
|
|
137
|
+
type BoundContractMethod<A, R, E> = Omit<ContractMethod<A, R, E>, "view" | "viewOutcome" | "viewRequest" | "call"> & {
|
|
138
|
+
viewRequest(options: Omit<Parameters<ContractMethod<A, R, E>["viewRequest"]>[0], "address">): ReturnType<ContractMethod<A, R, E>["viewRequest"]>;
|
|
139
|
+
view(options: Omit<ContractViewOptions<A>, "client" | "address">): ReturnType<ContractMethod<A, R, E>["view"]>;
|
|
140
|
+
viewOutcome(options: Omit<ContractViewOptions<A>, "client" | "address">): ReturnType<ContractMethod<A, R, E>["viewOutcome"]>;
|
|
141
|
+
call(options: Omit<Parameters<ContractMethod<A, R, E>["call"]>[0], "address">): ReturnType<ContractMethod<A, R, E>["call"]>;
|
|
142
|
+
};
|
|
143
|
+
/** Bound methods inferred from a generated interface object. */
|
|
144
|
+
type ContractInstance<T> = { [K in keyof T]: T[K] extends ContractMethod<infer A, infer R, infer E> ? BoundContractMethod<A, R, E> : never };
|
|
145
|
+
/**
|
|
146
|
+
* Bind a generated interface to an address and public client.
|
|
147
|
+
* Views preserve heights and events and accept cancellation and minimum-height
|
|
148
|
+
* constraints. A minimum height is a freshness floor; use readViews when several
|
|
149
|
+
* results must come from the same snapshot.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* const token = getContract({ binding: ERC20.v0_1, address, client });
|
|
154
|
+
* const balance = await token.getBalanceOf.view({ args: { addr: owner }, signal });
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare function getContract<T extends Record<string, ContractMethod<any, unknown, unknown>>>(options: {
|
|
158
|
+
binding: T;
|
|
159
|
+
address: ContractAddress;
|
|
160
|
+
client: Pick<ThruputClient, "simulateInvocation">;
|
|
161
|
+
}): ContractInstance<T>;
|
|
162
|
+
//#endregion
|
|
163
|
+
export { SpecDecodedCall as _, BoundContractMethod as a, encodeCalldata as b, SignedToken as c, ContractDecodeError as d, ContractVerificationError as f, SpecDeclaredException as g, buildNamedCodecs as h, fixedBytes$1 as i, isSignedToken as l, hashContract as m, FixedBytes$1 as n, ContractInstance as o, deriveContractAddress as p, fixedArray$1 as r, getContract as s, FixedArray as t, signedToken as u, createContractCallDecoder as v, resolveCodec as x, decodeCalldata as y };
|
|
164
|
+
//# sourceMappingURL=index-D89ur7mO.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-D89ur7mO.d.ts","names":[],"sources":["../src/contract/encode.ts","../src/contract/specMethod.ts","../src/contract/codegen.ts","../src/contract/hash.ts","../src/derivation/contractAddress.ts","../src/contract/errors.ts","../src/contract/signedToken.ts","../src/contract/instance.ts"],"mappings":";;;;;;AAuKA;;;;;iBAAgB,YAAA,CACd,EAAA,EAAI,cAAA,EACJ,WAAA,GAAc,MAAA,SAAe,QAAA,aAC5B,QAAA;;;;;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CAAe,CAAA,EAAG,CAAA,EAAG,CAAA;EAGrB,WAAA,CACE,OAAA,EAAS,IAAA,CACP,UAAA,CAAW,cAAA,CAAe,CAAA,EAAG,CAAA,EAAG,CAAA,mCAGjC,UAAA,CAAW,cAAA,CAAe,CAAA,EAAG,CAAA,EAAG,CAAA;EACnC,IAAA,CACE,OAAA,EAAS,IAAA,CAAK,mBAAA,CAAoB,CAAA,2BACjC,UAAA,CAAW,cAAA,CAAe,CAAA,EAAG,CAAA,EAAG,CAAA;EACnC,WAAA,CACE,OAAA,EAAS,IAAA,CAAK,mBAAA,CAAoB,CAAA,2BACjC,UAAA,CAAW,cAAA,CAAe,CAAA,EAAG,CAAA,EAAG,CAAA;EACnC,IAAA,CACE,OAAA,EAAS,IAAA,CAAK,UAAA,CAAW,cAAA,CAAe,CAAA,EAAG,CAAA,EAAG,CAAA,4BAC7C,UAAA,CAAW,cAAA,CAAe,CAAA,EAAG,CAAA,EAAG,CAAA;AAAA;;KAIzB,gBAAA,oBACE,CAAA,GAAI,CAAA,CAAE,CAAA,UAAW,cAAA,8BACzB,mBAAA,CAAoB,CAAA,EAAG,CAAA,EAAG,CAAA;;;;;;;;;AP6IrB;AAoKX;;;iBOjSgB,WAAA,WAEJ,MAAA,SAAe,cAAA,0BACzB,OAAA;EACA,OAAA,EAAS,CAAA;EACT,OAAA,EAAS,eAAA;EACT,MAAA,EAAQ,IAAA,CAAK,aAAA;AAAA,IACX,gBAAA,CAAiB,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { AuthClaim, Calldata, Contract, ContractAddress, ContractEntrypointID, CryptographicScheme, GasAmount, Invocation, NetworkHash, SignedTransaction, Transaction, Uniquifier } from "@thruputchain/protocol";
|
|
2
|
+
|
|
3
|
+
//#region src/transaction/build.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Build an invocation object from already-typed protocol values.
|
|
6
|
+
*
|
|
7
|
+
* Generated contract bindings usually call this helper for you. Use it directly
|
|
8
|
+
* when constructing a low-level invocation without generated bindings.
|
|
9
|
+
*/
|
|
10
|
+
declare function createInvocation(params: {
|
|
11
|
+
invoked_address: ContractAddress;
|
|
12
|
+
entrypoint: ContractEntrypointID;
|
|
13
|
+
gas_limit: GasAmount;
|
|
14
|
+
calldata: Calldata;
|
|
15
|
+
}): Invocation;
|
|
16
|
+
/**
|
|
17
|
+
* Build an unsigned transaction from an invocation and authorization metadata.
|
|
18
|
+
*
|
|
19
|
+
* The returned transaction must be signed with {@link signTransaction} before it
|
|
20
|
+
* can be submitted to a Thruput JSON-RPC gateway.
|
|
21
|
+
*/
|
|
22
|
+
declare function createTransaction(params: {
|
|
23
|
+
invocation: Invocation;
|
|
24
|
+
uniquifier: Uniquifier;
|
|
25
|
+
contracts_to_deploy: Contract[];
|
|
26
|
+
auth_claim: AuthClaim;
|
|
27
|
+
}): Transaction;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/transaction/serialize.d.ts
|
|
30
|
+
/** Serialize an unsigned transaction to its canonical protocol bytes. */
|
|
31
|
+
declare function serializeTransaction(tx: Transaction): Uint8Array;
|
|
32
|
+
/** Decode an unsigned transaction from canonical protocol bytes. */
|
|
33
|
+
declare function deserializeTransaction(data: Uint8Array): Transaction;
|
|
34
|
+
/** Serialize a signed transaction to the bytes accepted by the JSON-RPC API. */
|
|
35
|
+
declare function serializeSignedTransaction(stx: SignedTransaction): Uint8Array;
|
|
36
|
+
/** Decode a signed transaction from canonical protocol bytes. */
|
|
37
|
+
declare function deserializeSignedTransaction(data: Uint8Array): SignedTransaction;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/transaction/preimage.d.ts
|
|
40
|
+
/**
|
|
41
|
+
* The message every transaction signature covers:
|
|
42
|
+
*
|
|
43
|
+
* ```text
|
|
44
|
+
* cxs(DomainSeparator("Transaction")) || networkHash || txs(tx)
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* The domain separator keeps a transaction signature from being reinterpreted
|
|
48
|
+
* as a signature over some other object whose encoding a transaction could be
|
|
49
|
+
* made to imitate. The network hash binds the signature to a single network, so
|
|
50
|
+
* a transaction signed for one chain cannot be replayed on another that happens
|
|
51
|
+
* to carry the same address with the same auth data.
|
|
52
|
+
*
|
|
53
|
+
* Note the two encodings: the prefix is CXS, which is how a `DomainSeparator`
|
|
54
|
+
* is encoded everywhere, while the transaction itself is classic XDR. The
|
|
55
|
+
* network hash is a fixed 32-byte opaque, whose CXS and XDR encodings are
|
|
56
|
+
* identical, so it is written verbatim.
|
|
57
|
+
*
|
|
58
|
+
* The result is signed directly — Ed25519 does its own hashing, so there is no
|
|
59
|
+
* pre-hash here. It must match the C++ validator's
|
|
60
|
+
* `hogd::transaction_signature_preimage` and the Rust
|
|
61
|
+
* `thruput_domain_separator::transaction_signature_preimage` byte for byte,
|
|
62
|
+
* or every signature is rejected.
|
|
63
|
+
*
|
|
64
|
+
* {@link signTransaction} calls this; reach for it directly only when handing
|
|
65
|
+
* bytes to a signer this package does not drive.
|
|
66
|
+
*/
|
|
67
|
+
declare function transactionSignaturePreimage(networkHash: NetworkHash, tx: Transaction): Uint8Array;
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/transaction/size.d.ts
|
|
70
|
+
/**
|
|
71
|
+
* Bytes a `kPubkeySignature` signed envelope adds to the unsigned transaction:
|
|
72
|
+
* the one-entry signature vector (count, key ID, signature) and the present
|
|
73
|
+
* `pubkey_claim_key` option holding the key.
|
|
74
|
+
*
|
|
75
|
+
* Reserve this much when bounding an unsigned transaction against a
|
|
76
|
+
* signed-transaction size limit: 116 bytes for Ed25519 and 5,284 bytes for
|
|
77
|
+
* ML-DSA-65 (a 3,309-byte signature and a 1,952-byte key).
|
|
78
|
+
*/
|
|
79
|
+
declare function pubkeySignatureEnvelopeBytes(scheme: CryptographicScheme): number;
|
|
80
|
+
//#endregion
|
|
81
|
+
export { serializeSignedTransaction as a, createTransaction as c, deserializeTransaction as i, transactionSignaturePreimage as n, serializeTransaction as o, deserializeSignedTransaction as r, createInvocation as s, pubkeySignatureEnvelopeBytes as t };
|
|
82
|
+
//# sourceMappingURL=index-DzrLv3EA.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DzrLv3EA.d.cts","names":[],"sources":["../src/transaction/build.ts","../src/transaction/serialize.ts","../src/transaction/preimage.ts","../src/transaction/size.ts"],"mappings":";;;;;;AAkBA;;;iBAAgB,gBAAA,CAAiB,MAAA;EAC/B,eAAA,EAAiB,eAAA;EACjB,UAAA,EAAY,oBAAA;EACZ,SAAA,EAAW,SAAA;EACX,QAAA,EAAU,QAAA;AAAA,IACR,UAAA;;;;;;;iBAeY,iBAAA,CAAkB,MAAA;EAChC,UAAA,EAAY,UAAA;EACZ,UAAA,EAAY,UAAA;EACZ,mBAAA,EAAqB,QAAA;EACrB,UAAA,EAAY,SAAA;AAAA,IACV,WAAA;;;;iBCvCY,oBAAA,CAAqB,EAAA,EAAI,WAAA,GAAc,UAAU;;iBAKjD,sBAAA,CAAuB,IAAA,EAAM,UAAA,GAAa,WAAW;;iBAKrD,0BAAA,CAA2B,GAAA,EAAK,iBAAA,GAAoB,UAAU;;iBAK9D,4BAAA,CACd,IAAA,EAAM,UAAA,GACL,iBAAiB;;;;;;ADHpB;;;;;;;;;;;;;;;;;;;;;AAKc;AAed;;iBEPgB,4BAAA,CACd,WAAA,EAAa,WAAA,EACb,EAAA,EAAI,WAAA,GACH,UAAA;;;;;;AFhBH;;;;;;iBGMgB,4BAAA,CACd,MAA2B,EAAnB,mBAAmB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { AuthClaim, Calldata, Contract, ContractAddress, ContractEntrypointID, CryptographicScheme, GasAmount, Invocation, NetworkHash, SignedTransaction, Transaction, Uniquifier } from "@thruputchain/protocol";
|
|
2
|
+
|
|
3
|
+
//#region src/transaction/build.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Build an invocation object from already-typed protocol values.
|
|
6
|
+
*
|
|
7
|
+
* Generated contract bindings usually call this helper for you. Use it directly
|
|
8
|
+
* when constructing a low-level invocation without generated bindings.
|
|
9
|
+
*/
|
|
10
|
+
declare function createInvocation(params: {
|
|
11
|
+
invoked_address: ContractAddress;
|
|
12
|
+
entrypoint: ContractEntrypointID;
|
|
13
|
+
gas_limit: GasAmount;
|
|
14
|
+
calldata: Calldata;
|
|
15
|
+
}): Invocation;
|
|
16
|
+
/**
|
|
17
|
+
* Build an unsigned transaction from an invocation and authorization metadata.
|
|
18
|
+
*
|
|
19
|
+
* The returned transaction must be signed with {@link signTransaction} before it
|
|
20
|
+
* can be submitted to a Thruput JSON-RPC gateway.
|
|
21
|
+
*/
|
|
22
|
+
declare function createTransaction(params: {
|
|
23
|
+
invocation: Invocation;
|
|
24
|
+
uniquifier: Uniquifier;
|
|
25
|
+
contracts_to_deploy: Contract[];
|
|
26
|
+
auth_claim: AuthClaim;
|
|
27
|
+
}): Transaction;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/transaction/serialize.d.ts
|
|
30
|
+
/** Serialize an unsigned transaction to its canonical protocol bytes. */
|
|
31
|
+
declare function serializeTransaction(tx: Transaction): Uint8Array;
|
|
32
|
+
/** Decode an unsigned transaction from canonical protocol bytes. */
|
|
33
|
+
declare function deserializeTransaction(data: Uint8Array): Transaction;
|
|
34
|
+
/** Serialize a signed transaction to the bytes accepted by the JSON-RPC API. */
|
|
35
|
+
declare function serializeSignedTransaction(stx: SignedTransaction): Uint8Array;
|
|
36
|
+
/** Decode a signed transaction from canonical protocol bytes. */
|
|
37
|
+
declare function deserializeSignedTransaction(data: Uint8Array): SignedTransaction;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/transaction/preimage.d.ts
|
|
40
|
+
/**
|
|
41
|
+
* The message every transaction signature covers:
|
|
42
|
+
*
|
|
43
|
+
* ```text
|
|
44
|
+
* cxs(DomainSeparator("Transaction")) || networkHash || txs(tx)
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* The domain separator keeps a transaction signature from being reinterpreted
|
|
48
|
+
* as a signature over some other object whose encoding a transaction could be
|
|
49
|
+
* made to imitate. The network hash binds the signature to a single network, so
|
|
50
|
+
* a transaction signed for one chain cannot be replayed on another that happens
|
|
51
|
+
* to carry the same address with the same auth data.
|
|
52
|
+
*
|
|
53
|
+
* Note the two encodings: the prefix is CXS, which is how a `DomainSeparator`
|
|
54
|
+
* is encoded everywhere, while the transaction itself is classic XDR. The
|
|
55
|
+
* network hash is a fixed 32-byte opaque, whose CXS and XDR encodings are
|
|
56
|
+
* identical, so it is written verbatim.
|
|
57
|
+
*
|
|
58
|
+
* The result is signed directly — Ed25519 does its own hashing, so there is no
|
|
59
|
+
* pre-hash here. It must match the C++ validator's
|
|
60
|
+
* `hogd::transaction_signature_preimage` and the Rust
|
|
61
|
+
* `thruput_domain_separator::transaction_signature_preimage` byte for byte,
|
|
62
|
+
* or every signature is rejected.
|
|
63
|
+
*
|
|
64
|
+
* {@link signTransaction} calls this; reach for it directly only when handing
|
|
65
|
+
* bytes to a signer this package does not drive.
|
|
66
|
+
*/
|
|
67
|
+
declare function transactionSignaturePreimage(networkHash: NetworkHash, tx: Transaction): Uint8Array;
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/transaction/size.d.ts
|
|
70
|
+
/**
|
|
71
|
+
* Bytes a `kPubkeySignature` signed envelope adds to the unsigned transaction:
|
|
72
|
+
* the one-entry signature vector (count, key ID, signature) and the present
|
|
73
|
+
* `pubkey_claim_key` option holding the key.
|
|
74
|
+
*
|
|
75
|
+
* Reserve this much when bounding an unsigned transaction against a
|
|
76
|
+
* signed-transaction size limit: 116 bytes for Ed25519 and 5,284 bytes for
|
|
77
|
+
* ML-DSA-65 (a 3,309-byte signature and a 1,952-byte key).
|
|
78
|
+
*/
|
|
79
|
+
declare function pubkeySignatureEnvelopeBytes(scheme: CryptographicScheme): number;
|
|
80
|
+
//#endregion
|
|
81
|
+
export { serializeSignedTransaction as a, createTransaction as c, deserializeTransaction as i, transactionSignaturePreimage as n, serializeTransaction as o, deserializeSignedTransaction as r, createInvocation as s, pubkeySignatureEnvelopeBytes as t };
|
|
82
|
+
//# sourceMappingURL=index-DzrLv3EA.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DzrLv3EA.d.ts","names":[],"sources":["../src/transaction/build.ts","../src/transaction/serialize.ts","../src/transaction/preimage.ts","../src/transaction/size.ts"],"mappings":";;;;;;AAkBA;;;iBAAgB,gBAAA,CAAiB,MAAA;EAC/B,eAAA,EAAiB,eAAA;EACjB,UAAA,EAAY,oBAAA;EACZ,SAAA,EAAW,SAAA;EACX,QAAA,EAAU,QAAA;AAAA,IACR,UAAA;;;;;;;iBAeY,iBAAA,CAAkB,MAAA;EAChC,UAAA,EAAY,UAAA;EACZ,UAAA,EAAY,UAAA;EACZ,mBAAA,EAAqB,QAAA;EACrB,UAAA,EAAY,SAAA;AAAA,IACV,WAAA;;;;iBCvCY,oBAAA,CAAqB,EAAA,EAAI,WAAA,GAAc,UAAU;;iBAKjD,sBAAA,CAAuB,IAAA,EAAM,UAAA,GAAa,WAAW;;iBAKrD,0BAAA,CAA2B,GAAA,EAAK,iBAAA,GAAoB,UAAU;;iBAK9D,4BAAA,CACd,IAAA,EAAM,UAAA,GACL,iBAAiB;;;;;;ADHpB;;;;;;;;;;;;;;;;;;;;;AAKc;AAed;;iBEPgB,4BAAA,CACd,WAAA,EAAa,WAAA,EACb,EAAA,EAAI,WAAA,GACH,UAAA;;;;;;AFhBH;;;;;;iBGMgB,4BAAA,CACd,MAA2B,EAAnB,mBAAmB"}
|