@thruputchain/client 0.25.0 → 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 +1 -1
- package/README.md +58 -40
- package/dist/{actions-DxJZ3yIv.cjs → actions-CXx6qzsv.cjs} +161 -5
- package/dist/actions-CXx6qzsv.cjs.map +1 -0
- package/dist/{actions-CdFSUTO2.js → actions-QHgiCqT6.js} +139 -7
- package/dist/actions-QHgiCqT6.js.map +1 -0
- package/dist/actions.cjs +6 -2
- package/dist/actions.d.cts +4 -4
- package/dist/actions.d.ts +4 -4
- package/dist/actions.js +3 -3
- package/dist/artifact-BM_MVzhL.d.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-BxB6ktQd.d.cts → client-JixxskeH.d.cts} +58 -2
- package/dist/client-JixxskeH.d.cts.map +1 -0
- package/dist/{client-BxB6ktQd.d.ts → client-JixxskeH.d.ts} +58 -2
- package/dist/client-JixxskeH.d.ts.map +1 -0
- package/dist/{codec-CX-19jac.js → codec-BHKoSaOP.js} +1426 -50
- package/dist/{codec-CX-19jac.js.map → codec-BHKoSaOP.js.map} +1 -1
- package/dist/{codec-B7HJjMzI.cjs → codec-C3OlYm98.cjs} +1426 -50
- package/dist/{codec-B7HJjMzI.cjs.map → codec-C3OlYm98.cjs.map} +1 -1
- package/dist/{contract-D0wCFcAN.cjs → contract-C7T2H2Oi.cjs} +742 -333
- package/dist/contract-C7T2H2Oi.cjs.map +1 -0
- package/dist/{contract-BpxjDMHw.js → contract-DzvyyFCI.js} +712 -345
- package/dist/contract-DzvyyFCI.js.map +1 -0
- package/dist/contract.cjs +6 -1
- package/dist/contract.d.cts +4 -3
- package/dist/contract.d.ts +4 -3
- package/dist/contract.js +2 -2
- package/dist/contracts.cjs +3 -3
- package/dist/contracts.d.cts +3 -3
- package/dist/contracts.d.ts +3 -3
- package/dist/contracts.js +3 -3
- package/dist/{dev_wallet-C9eMQROk.js → dev_wallet-CSMA1PCt.js} +2 -2
- package/dist/{dev_wallet-C9eMQROk.js.map → dev_wallet-CSMA1PCt.js.map} +1 -1
- package/dist/{dev_wallet-BXWK5KR6.cjs → dev_wallet-GX-NCAFk.cjs} +2 -2
- package/dist/{dev_wallet-BXWK5KR6.cjs.map → dev_wallet-GX-NCAFk.cjs.map} +1 -1
- package/dist/{execution-DyxaIG4v.d.cts → execution-DYqPDn4O.d.cts} +3 -3
- package/dist/{execution-DyxaIG4v.d.cts.map → execution-DYqPDn4O.d.cts.map} +1 -1
- package/dist/{execution-CRDyKu45.d.ts → execution-Dj6E4B_b.d.ts} +3 -3
- package/dist/{execution-CRDyKu45.d.ts.map → execution-Dj6E4B_b.d.ts.map} +1 -1
- package/dist/index-1-rFirYe.d.cts +90 -0
- package/dist/index-1-rFirYe.d.cts.map +1 -0
- package/dist/{index-BZ0O5jZG.d.cts → index-BraLWObY.d.cts} +3 -2
- package/dist/{index-BZ0O5jZG.d.cts.map → index-BraLWObY.d.cts.map} +1 -1
- package/dist/{index-sAzHHayu.d.ts → index-ByvV2UF6.d.ts} +3 -2
- package/dist/{index-sAzHHayu.d.ts.map → index-ByvV2UF6.d.ts.map} +1 -1
- package/dist/{index-DOEBWXY2.d.cts → index-CG2WRtGa.d.cts} +31 -4
- package/dist/index-CG2WRtGa.d.cts.map +1 -0
- package/dist/{index-C-M-4jMR.d.cts → index-CVrhB9Dr.d.cts} +4 -4
- package/dist/{index-C-M-4jMR.d.cts.map → index-CVrhB9Dr.d.cts.map} +1 -1
- package/dist/{index-C97zw2rk.d.ts → index-D89ur7mO.d.ts} +31 -4
- package/dist/index-D89ur7mO.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-CXuO2Zjx.d.ts → index-dJ65V8se.d.ts} +4 -4
- package/dist/{index-CXuO2Zjx.d.ts.map → index-dJ65V8se.d.ts.map} +1 -1
- package/dist/index.cjs +20 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -53
- package/dist/index.js.map +1 -1
- package/dist/{readError-BVbfTMLv.cjs → readError-AoNjzW75.cjs} +2 -2
- package/dist/{readError-BVbfTMLv.cjs.map → readError-AoNjzW75.cjs.map} +1 -1
- package/dist/{readError-Dn_XN98x.js → readError-CZPYcW__.js} +2 -2
- package/dist/{readError-Dn_XN98x.js.map → readError-CZPYcW__.js.map} +1 -1
- package/dist/{readViews-BKJtE5J3.d.cts → readViews-DJyqc7im.d.cts} +14 -4
- package/dist/readViews-DJyqc7im.d.cts.map +1 -0
- package/dist/{readViews-C_FX8wby.d.ts → readViews-DQoaUORa.d.ts} +14 -4
- package/dist/readViews-DQoaUORa.d.ts.map +1 -0
- package/dist/{sendInvocation-C4ruTC-9.js → sendInvocation-BwabRa2N.js} +5 -5
- package/dist/{sendInvocation-C4ruTC-9.js.map → sendInvocation-BwabRa2N.js.map} +1 -1
- package/dist/{sendInvocation-2EZanZZr.cjs → sendInvocation-qO8AZcmU.cjs} +5 -5
- package/dist/{sendInvocation-2EZanZZr.cjs.map → sendInvocation-qO8AZcmU.cjs.map} +1 -1
- package/dist/signed-op.cjs +2 -2
- package/dist/signed-op.d.cts +1 -1
- package/dist/signed-op.d.ts +1 -1
- package/dist/signed-op.js +2 -2
- package/dist/{signedOp-x4fakrr4.js → signedOp-C52gOgpR.js} +3 -3
- package/dist/{signedOp-x4fakrr4.js.map → signedOp-C52gOgpR.js.map} +1 -1
- package/dist/{signedOp-Bluo0OAd.cjs → signedOp-oqAXEqmE.cjs} +3 -3
- package/dist/{signedOp-Bluo0OAd.cjs.map → signedOp-oqAXEqmE.cjs.map} +1 -1
- package/dist/{signed_op-BzVbBgv4.js → signed_op-BokEDWr-.js} +2 -2
- package/dist/{signed_op-BzVbBgv4.js.map → signed_op-BokEDWr-.js.map} +1 -1
- package/dist/{signed_op-DFgQ2yFj.d.ts → signed_op-C4lY_TCc.d.ts} +3 -3
- package/dist/{signed_op-DFgQ2yFj.d.ts.map → signed_op-C4lY_TCc.d.ts.map} +1 -1
- package/dist/{signed_op-LwxrDud8.d.cts → signed_op-DX5WuyEh.d.cts} +3 -3
- package/dist/{signed_op-LwxrDud8.d.cts.map → signed_op-DX5WuyEh.d.cts.map} +1 -1
- package/dist/{signed_op-z_8fqAi1.cjs → signed_op-q8KKSm5e.cjs} +2 -2
- package/dist/{signed_op-z_8fqAi1.cjs.map → signed_op-q8KKSm5e.cjs.map} +1 -1
- package/dist/{transport-DqyoNtUy.js → transport-CBFwAIIv.js} +31 -4
- package/dist/transport-CBFwAIIv.js.map +1 -0
- package/dist/{transport-B-P16rs6.cjs → transport-tWxKhXUt.cjs} +31 -4
- package/dist/transport-tWxKhXUt.cjs.map +1 -0
- package/dist/transport.cjs +3 -3
- package/dist/transport.d.cts +3 -3
- package/dist/transport.d.ts +3 -3
- package/dist/transport.js +3 -3
- package/dist/{wallet-CwWPYoHF.js → wallet-7RELuTkf.js} +3 -3
- package/dist/{wallet-CwWPYoHF.js.map → wallet-7RELuTkf.js.map} +1 -1
- package/dist/{wallet-Bthapk8i.cjs → wallet-T_JazXRc.cjs} +3 -3
- package/dist/{wallet-Bthapk8i.cjs.map → wallet-T_JazXRc.cjs.map} +1 -1
- package/dist/wallet.cjs +2 -2
- package/dist/wallet.d.cts +2 -2
- package/dist/wallet.d.ts +2 -2
- package/dist/wallet.js +2 -2
- package/package.json +4 -4
- package/dist/actions-CdFSUTO2.js.map +0 -1
- package/dist/actions-DxJZ3yIv.cjs.map +0 -1
- package/dist/client-BxB6ktQd.d.cts.map +0 -1
- package/dist/client-BxB6ktQd.d.ts.map +0 -1
- package/dist/contract-BpxjDMHw.js.map +0 -1
- package/dist/contract-D0wCFcAN.cjs.map +0 -1
- package/dist/index-BuPQcAK2.d.ts +0 -23
- package/dist/index-BuPQcAK2.d.ts.map +0 -1
- package/dist/index-C97zw2rk.d.ts.map +0 -1
- package/dist/index-DOEBWXY2.d.cts.map +0 -1
- package/dist/index-uQqRk9Ww.d.cts +0 -23
- package/dist/index-uQqRk9Ww.d.cts.map +0 -1
- package/dist/readViews-BKJtE5J3.d.cts.map +0 -1
- package/dist/readViews-C_FX8wby.d.ts.map +0 -1
- package/dist/transport-B-P16rs6.cjs.map +0 -1
- package/dist/transport-DqyoNtUy.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright
|
|
189
|
+
Copyright 2026 Stellar Development Foundation
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# @thruputchain/client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@thruputchain/client)
|
|
4
|
+
[](https://github.com/thruputchain/thruput-sdk-ts/actions/workflows/ci.yml)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
[Website](https://www.thruput.network/) ·
|
|
8
|
+
[Developer docs](https://www.thruput.network/docs/) ·
|
|
9
|
+
[Community discussions](https://github.com/thruputchain/thruput-docs/discussions) ·
|
|
10
|
+
[Discord: #thruput](https://discord.com/channels/897514728459468821/1564948118162898954)
|
|
11
|
+
([join server](https://discord.gg/stellardev))
|
|
12
|
+
|
|
13
|
+
TypeScript client for the [Thruput](https://www.thruput.network/) blockchain.
|
|
4
14
|
|
|
5
15
|
It provides typed JSON-RPC actions, transaction construction and signing,
|
|
6
16
|
HTTP and mock transports, and generated contract bindings. Generated methods
|
|
@@ -14,14 +24,14 @@ named topic filters, and receipt extraction.
|
|
|
14
24
|
npm install @thruputchain/client
|
|
15
25
|
```
|
|
16
26
|
|
|
17
|
-
Requires Node.js 22.12.0 or newer.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
Requires Node.js 22.12.0 or newer. The package and its `@thruputchain/*`
|
|
28
|
+
dependencies are published to the public npm registry, so installs need no
|
|
29
|
+
authentication. If you previously pointed the `@thruputchain` scope at GitHub
|
|
30
|
+
Packages, remove that override from your `.npmrc`.
|
|
21
31
|
|
|
22
32
|
## Usage
|
|
23
33
|
|
|
24
|
-
This checkout pins RPC wire format **14.
|
|
34
|
+
This checkout pins RPC wire format **14.4.0**. Block queries require a compatible
|
|
25
35
|
RPC server and a node with the block-query index. RPC addresses, public keys,
|
|
26
36
|
validator IDs and hashes use unprefixed, case-sensitive base58. Opaque payloads
|
|
27
37
|
(including signed transactions, calldata, return data, storage keys, raw event
|
|
@@ -53,6 +63,30 @@ const tip = await client.getChainTip();
|
|
|
53
63
|
console.log(tip.blockHeight.toString(), toBase58(tip.blockHash));
|
|
54
64
|
```
|
|
55
65
|
|
|
66
|
+
### Discover a wallet or contract
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { getEffectiveContractSpec } from "@thruputchain/client/actions";
|
|
70
|
+
import { addressFromBase58 } from "@thruputchain/client";
|
|
71
|
+
|
|
72
|
+
const result = await getEffectiveContractSpec(client, {
|
|
73
|
+
address: addressFromBase58("<base58-address>"),
|
|
74
|
+
context: "root",
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`getContractDeployment` reads explicit deployments only. `getEffectiveContract`
|
|
79
|
+
also resolves the configured network default for undeployed root invocations.
|
|
80
|
+
Use `context: "nested"` to exclude that fallback. Selection does not prove
|
|
81
|
+
authorization, execution, or historical code identity. Transaction-local
|
|
82
|
+
deployments are not part of this committed-state reading.
|
|
83
|
+
|
|
84
|
+
The spec helper validates the selected artifact's full hash, type, and size.
|
|
85
|
+
RV32 specs are artifact-bound. A recognized native DefaultWallet returns the
|
|
86
|
+
shared `nativeInterface`, which is a built-in description, not an artifact-bound
|
|
87
|
+
spec or proof of runtime code. Missing artifact data throws instead of reporting
|
|
88
|
+
contract absence.
|
|
89
|
+
|
|
56
90
|
### Read a committed block
|
|
57
91
|
|
|
58
92
|
```ts
|
|
@@ -714,7 +748,7 @@ helpers, generated standard contracts, signers, and standalone actions.
|
|
|
714
748
|
- `src/types/rpc.ts` — typed RPC request/response shapes.
|
|
715
749
|
- `specs/native-openrpc.json` — Rust-owned native OpenRPC snapshot; `scripts/regen-openrpc.sh` refreshes it with recorded provenance. `npm run rpc:check` verifies generated codecs and types; `src/rpc/client.test.ts` checks every method’s named params and results.
|
|
716
750
|
- `docs/api/` — generated TypeDoc output from `npm run docs` (ignored by git; see [API docs](#api-docs)).
|
|
717
|
-
- `Caddyfile` and `Staticfile` — configure the
|
|
751
|
+
- `Caddyfile` and `Staticfile` — configure the static host that serves the generated `docs/api/`; they are not part of the published package.
|
|
718
752
|
|
|
719
753
|
## Subpath exports
|
|
720
754
|
|
|
@@ -789,35 +823,16 @@ The API reference is generated from the package's public entry points, matching
|
|
|
789
823
|
|
|
790
824
|
## Developing
|
|
791
825
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
The `@thruputchain/*` dependencies are hosted on GitHub Packages, which
|
|
795
|
-
requires a GitHub token even to download — a plain `npm install` on a fresh
|
|
796
|
-
machine fails with `401 Unauthorized` from `npm.pkg.github.com`. To set up
|
|
797
|
-
auth using the `gh` CLI:
|
|
826
|
+
Use Node.js 24 (see `.nvmrc`) and npm. Every dependency installs anonymously
|
|
827
|
+
from the public npm registry:
|
|
798
828
|
|
|
799
829
|
```sh
|
|
800
|
-
|
|
801
|
-
gh auth refresh -h github.com -s read:packages
|
|
830
|
+
npm ci
|
|
802
831
|
```
|
|
803
832
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
```
|
|
809
|
-
@thruputchain:registry=https://npm.pkg.github.com
|
|
810
|
-
//npm.pkg.github.com/:_authToken=${GH_NPM_TOKEN}
|
|
811
|
-
```
|
|
812
|
-
|
|
813
|
-
And run installs with the token pulled from gh's keychain:
|
|
814
|
-
|
|
815
|
-
```sh
|
|
816
|
-
GH_NPM_TOKEN="$(gh auth token)" npm install
|
|
817
|
-
```
|
|
818
|
-
|
|
819
|
-
If you forget the prefix, npm fails with `Failed to replace env in config` —
|
|
820
|
-
that's your reminder.
|
|
833
|
+
Before opening a pull request, run the checks listed under
|
|
834
|
+
[Scripts](#scripts); CI runs the same set. Report vulnerabilities as described
|
|
835
|
+
in [SECURITY.md](SECURITY.md), not through public issues.
|
|
821
836
|
|
|
822
837
|
## Scripts
|
|
823
838
|
|
|
@@ -841,13 +856,14 @@ keys, network hashes and transaction hashes use case-sensitive, unprefixed
|
|
|
841
856
|
base58. Transaction and signed-transaction XDR remain canonical `0x` hex,
|
|
842
857
|
with binary signatures intact.
|
|
843
858
|
|
|
844
|
-
Run on Linux with Node 24. CI installs the
|
|
859
|
+
Run on Linux with Node 24. CI installs the `thruput` CLI crate from crates.io and the public devnode
|
|
845
860
|
artifact pinned in
|
|
846
861
|
[`scripts/integration-versions.json`](scripts/integration-versions.json): CLI
|
|
847
|
-
0.
|
|
848
|
-
CLI; it does not verify a packaged CLI bundle. Locally, install that CLI version
|
|
849
|
-
`
|
|
850
|
-
devnode when no runtime override is
|
|
862
|
+
0.44.0, devnode 0.1.32 and wire 14.4.0. CI qualification uses the crate-built
|
|
863
|
+
CLI; it does not verify a packaged CLI bundle. Locally, install that CLI version
|
|
864
|
+
with `cargo install thruput@0.44.0 --locked` or set `THRUPUT_CLI` to its
|
|
865
|
+
executable. The harness installs the pinned devnode when no runtime override is
|
|
866
|
+
supplied.
|
|
851
867
|
|
|
852
868
|
```sh
|
|
853
869
|
npm run test:integration
|
|
@@ -928,9 +944,11 @@ replacement transaction or automatic funding repeat.
|
|
|
928
944
|
|
|
929
945
|
## Publishing
|
|
930
946
|
|
|
931
|
-
The manual release workflow
|
|
947
|
+
The manual release workflow publishes to public npm and defaults to dry-run.
|
|
932
948
|
See [RELEASING.md](RELEASING.md) for authentication, release order, and retries.
|
|
933
|
-
Repository installs retain GitHub Packages during the first npm release;
|
|
934
|
-
consumer registry settings and lockfiles switch after all seven packages exist.
|
|
935
949
|
|
|
936
950
|
Published versions are immutable. Use a new version for each release.
|
|
951
|
+
|
|
952
|
+
## License
|
|
953
|
+
|
|
954
|
+
[Apache License 2.0](LICENSE). Copyright 2026 Stellar Development Foundation.
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
const require_contract = require("./contract-
|
|
2
|
-
const require_codec = require("./codec-
|
|
1
|
+
const require_contract = require("./contract-C7T2H2Oi.cjs");
|
|
2
|
+
const require_codec = require("./codec-C3OlYm98.cjs");
|
|
3
3
|
const require_hex = require("./hex-DkGpiZ5e.cjs");
|
|
4
|
-
const require_readError = require("./readError-
|
|
5
|
-
const require_sendInvocation = require("./sendInvocation-
|
|
4
|
+
const require_readError = require("./readError-AoNjzW75.cjs");
|
|
5
|
+
const require_sendInvocation = require("./sendInvocation-qO8AZcmU.cjs");
|
|
6
|
+
const require_dev_wallet = require("./dev_wallet-GX-NCAFk.cjs");
|
|
6
7
|
let _thruputchain_protocol = require("@thruputchain/protocol");
|
|
8
|
+
let _noble_hashes_sha2_js = require("@noble/hashes/sha2.js");
|
|
7
9
|
//#region src/actions/public/requestAirdrop.ts
|
|
8
10
|
/** Funding stopped without permission to call the faucet again. */
|
|
9
11
|
var FundingObservationError = class extends Error {
|
|
@@ -275,6 +277,136 @@ function iterateTransactionsByBlock(client, query, options = {}) {
|
|
|
275
277
|
}, options);
|
|
276
278
|
}
|
|
277
279
|
//#endregion
|
|
280
|
+
//#region src/actions/public/getContractSpec.ts
|
|
281
|
+
/**
|
|
282
|
+
* Resolve a current deployment and verify its embedded spec against its hash.
|
|
283
|
+
* Missing artifacts and invalid responses throw; neither means no deployment.
|
|
284
|
+
* The snapshot does not establish which implementation produced historical events.
|
|
285
|
+
*/
|
|
286
|
+
async function getContractSpec(client, request, options) {
|
|
287
|
+
client.requireMethods(["getContractDeployment", "getContractArtifact"]);
|
|
288
|
+
const address = new Uint8Array(request.address);
|
|
289
|
+
const result = await client.getContractDeployment({ address }, options);
|
|
290
|
+
if (!require_contract.bytesEqual(address, result.address)) throw new require_contract.ContractVerificationError("Contract deployment address mismatch");
|
|
291
|
+
if (result.deployment === null) return {
|
|
292
|
+
...result,
|
|
293
|
+
artifactSpec: null
|
|
294
|
+
};
|
|
295
|
+
return {
|
|
296
|
+
...result,
|
|
297
|
+
artifactSpec: await readDeploymentSpec(client, result.deployment, options)
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
/** Shared identity validation for explicit deployments and effective contract selection. */
|
|
301
|
+
async function readDeploymentSpec(client, deployment, options) {
|
|
302
|
+
const artifact = await client.getContractArtifact({ hash: deployment.hash }, options);
|
|
303
|
+
if (!require_contract.bytesEqual(artifact.hash, deployment.hash)) throw new require_contract.ContractVerificationError("Contract artifact response hash mismatch");
|
|
304
|
+
const artifactSpec = require_contract.readContractArtifactSpec(artifact.contractXdr, (0, _thruputchain_protocol.sha256Hash)(deployment.hash));
|
|
305
|
+
const contract = (0, _thruputchain_protocol.deserialize)(artifact.contractXdr, _thruputchain_protocol.codec.Contract);
|
|
306
|
+
const size = contract.contract_type === _thruputchain_protocol.ContractType.kRv32 ? contract.rv32_contract.data.length : 0;
|
|
307
|
+
if (contract.contract_type !== deployment.contractType || size !== deployment.size) throw new require_contract.ContractVerificationError("Contract artifact does not match deployment metadata");
|
|
308
|
+
return artifactSpec;
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/actions/public/getEffectiveContractSpec.ts
|
|
312
|
+
const nativeWalletHash = require_contract.hashContract({
|
|
313
|
+
contract_type: _thruputchain_protocol.ContractType.kNative,
|
|
314
|
+
native_contract_id: _thruputchain_protocol.HogexecPrecompiledNativeContracts.kNativeContractDefaultWallet
|
|
315
|
+
});
|
|
316
|
+
/**
|
|
317
|
+
* Discover current contract selection without inferring authorization or historical identity.
|
|
318
|
+
* Root context allows the chain-configured fallback; nested excludes that fallback.
|
|
319
|
+
* Transaction-local deployments are outside this committed-state reading.
|
|
320
|
+
*/
|
|
321
|
+
async function getEffectiveContractSpec(client, request, options) {
|
|
322
|
+
client.requireMethods(["getEffectiveContract", "getContractArtifact"]);
|
|
323
|
+
const address = new Uint8Array(request.address);
|
|
324
|
+
const context = request.context;
|
|
325
|
+
const result = await client.getEffectiveContract({
|
|
326
|
+
address,
|
|
327
|
+
context
|
|
328
|
+
}, options);
|
|
329
|
+
if (!require_contract.bytesEqual(address, result.address) || result.context !== context) throw new require_contract.ContractVerificationError("Effective contract request identity mismatch");
|
|
330
|
+
if (result.selection instanceof require_codec.UnsupportedRpcValue) throw new require_readError.RpcCompatibilityError("Unsupported effective contract selection");
|
|
331
|
+
if (result.selection === null) return {
|
|
332
|
+
...result,
|
|
333
|
+
artifactSpec: null,
|
|
334
|
+
nativeInterface: null
|
|
335
|
+
};
|
|
336
|
+
if (context === "nested" && result.selection.source === "networkDefault") throw new require_contract.ContractVerificationError("Network default cannot apply to a nested invocation");
|
|
337
|
+
const contract = result.selection.contract;
|
|
338
|
+
const artifactSpec = await readDeploymentSpec(client, contract, options);
|
|
339
|
+
const nativeInterface = artifactSpec.kind === "native" && require_contract.bytesEqual(contract.hash, nativeWalletHash) ? {
|
|
340
|
+
name: "DefaultWallet",
|
|
341
|
+
spec: require_dev_wallet.spec$1
|
|
342
|
+
} : null;
|
|
343
|
+
return {
|
|
344
|
+
...result,
|
|
345
|
+
artifactSpec,
|
|
346
|
+
nativeInterface
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/actions/public/decodeWalletRequests.ts
|
|
351
|
+
/**
|
|
352
|
+
* Interpret a known DefaultWallet root using built-in binding descriptors.
|
|
353
|
+
* Call only after identifying the root as DefaultWallet; matching selectors
|
|
354
|
+
* alone do not establish wallet identity. Malformed recognized inputs throw.
|
|
355
|
+
*/
|
|
356
|
+
function decodeDefaultWalletRequests(root) {
|
|
357
|
+
if (require_contract.bytesEqual(root.entrypoint, require_dev_wallet.DefaultWallet.v0_1.execute.entrypoint)) {
|
|
358
|
+
const { calls } = require_dev_wallet.DefaultWallet.v0_1.execute.decodeArgs(root.calldata);
|
|
359
|
+
return {
|
|
360
|
+
wrapper: "DefaultWallet.execute",
|
|
361
|
+
requestedCalls: calls.map((call) => ({
|
|
362
|
+
invoked_address: call.target,
|
|
363
|
+
entrypoint: (0, _thruputchain_protocol.contractEntrypointID)(call.entrypoint),
|
|
364
|
+
gas_limit: (0, _thruputchain_protocol.gasAmount)(call.gas_limit),
|
|
365
|
+
calldata: (0, _thruputchain_protocol.calldata)(call.calldata)
|
|
366
|
+
}))
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
if (require_contract.bytesEqual(root.entrypoint, require_dev_wallet.DefaultWallet.v0_1.deploy.entrypoint)) {
|
|
370
|
+
const args = require_dev_wallet.DefaultWallet.v0_1.deploy.decodeArgs(root.calldata);
|
|
371
|
+
const init = args.initializer;
|
|
372
|
+
return {
|
|
373
|
+
wrapper: "DefaultWallet.deploy",
|
|
374
|
+
requestedCalls: init ? [{
|
|
375
|
+
invoked_address: require_contract.deriveContractAddress(root.invoked_address, (0, _thruputchain_protocol.sha256Hash)(args.nonce), (0, _thruputchain_protocol.sha256Hash)(args.contractHash)),
|
|
376
|
+
entrypoint: (0, _thruputchain_protocol.contractEntrypointID)(init.entrypoint),
|
|
377
|
+
gas_limit: (0, _thruputchain_protocol.gasAmount)(init.gas_limit),
|
|
378
|
+
calldata: (0, _thruputchain_protocol.calldata)(init.calldata)
|
|
379
|
+
}] : []
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region src/actions/public/readTransactionInput.ts
|
|
386
|
+
/**
|
|
387
|
+
* Read and authenticate a retained Transaction, including its root invocation.
|
|
388
|
+
* Unavailable does not prove nonexecution. A matching body hash authenticates
|
|
389
|
+
* neither signatures nor the reported block height, and does not imply success.
|
|
390
|
+
*/
|
|
391
|
+
async function readTransactionInput(client, request, options) {
|
|
392
|
+
client.requireMethods(["getTransactionInput"]);
|
|
393
|
+
const hash = new Uint8Array(request.transactionHash);
|
|
394
|
+
const result = await client.getTransactionInput({ transactionHash: hash }, options);
|
|
395
|
+
if (result instanceof require_codec.UnsupportedRpcValue || result.status === "unavailable") return result;
|
|
396
|
+
try {
|
|
397
|
+
if (result.transactionXdr.length > 4 * 1024 * 1024) throw new Error("Transaction input exceeds 4 MiB");
|
|
398
|
+
if (!require_contract.bytesEqual(result.transactionHash, hash) || !require_contract.bytesEqual((0, _noble_hashes_sha2_js.sha256)(result.transactionXdr), hash)) throw new Error("Retained transaction input hash mismatch");
|
|
399
|
+
const transaction = (0, _thruputchain_protocol.deserialize)(result.transactionXdr, _thruputchain_protocol.codec.Transaction);
|
|
400
|
+
if (!require_contract.bytesEqual((0, _thruputchain_protocol.serialize)(transaction, _thruputchain_protocol.codec.Transaction), result.transactionXdr)) throw new Error("Noncanonical Transaction XDR");
|
|
401
|
+
return {
|
|
402
|
+
...result,
|
|
403
|
+
transaction
|
|
404
|
+
};
|
|
405
|
+
} catch (cause) {
|
|
406
|
+
throw new require_contract.ContractVerificationError(cause instanceof Error ? cause.message : "Invalid transaction input", { cause });
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
//#endregion
|
|
278
410
|
//#region src/actions/wallet/sendTransaction.ts
|
|
279
411
|
/**
|
|
280
412
|
* Serialize and submit once through the native RPC boundary.
|
|
@@ -305,12 +437,30 @@ Object.defineProperty(exports, "HistoryWalkError", {
|
|
|
305
437
|
return HistoryWalkError;
|
|
306
438
|
}
|
|
307
439
|
});
|
|
440
|
+
Object.defineProperty(exports, "decodeDefaultWalletRequests", {
|
|
441
|
+
enumerable: true,
|
|
442
|
+
get: function() {
|
|
443
|
+
return decodeDefaultWalletRequests;
|
|
444
|
+
}
|
|
445
|
+
});
|
|
308
446
|
Object.defineProperty(exports, "getContractEvents", {
|
|
309
447
|
enumerable: true,
|
|
310
448
|
get: function() {
|
|
311
449
|
return getContractEvents;
|
|
312
450
|
}
|
|
313
451
|
});
|
|
452
|
+
Object.defineProperty(exports, "getContractSpec", {
|
|
453
|
+
enumerable: true,
|
|
454
|
+
get: function() {
|
|
455
|
+
return getContractSpec;
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
Object.defineProperty(exports, "getEffectiveContractSpec", {
|
|
459
|
+
enumerable: true,
|
|
460
|
+
get: function() {
|
|
461
|
+
return getEffectiveContractSpec;
|
|
462
|
+
}
|
|
463
|
+
});
|
|
314
464
|
Object.defineProperty(exports, "iterateEventPages", {
|
|
315
465
|
enumerable: true,
|
|
316
466
|
get: function() {
|
|
@@ -329,6 +479,12 @@ Object.defineProperty(exports, "iterateTransactionsByRootAddress", {
|
|
|
329
479
|
return iterateTransactionsByRootAddress;
|
|
330
480
|
}
|
|
331
481
|
});
|
|
482
|
+
Object.defineProperty(exports, "readTransactionInput", {
|
|
483
|
+
enumerable: true,
|
|
484
|
+
get: function() {
|
|
485
|
+
return readTransactionInput;
|
|
486
|
+
}
|
|
487
|
+
});
|
|
332
488
|
Object.defineProperty(exports, "readViews", {
|
|
333
489
|
enumerable: true,
|
|
334
490
|
get: function() {
|
|
@@ -354,4 +510,4 @@ Object.defineProperty(exports, "sendTransaction", {
|
|
|
354
510
|
}
|
|
355
511
|
});
|
|
356
512
|
|
|
357
|
-
//# sourceMappingURL=actions-
|
|
513
|
+
//# sourceMappingURL=actions-CXx6qzsv.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions-CXx6qzsv.cjs","names":["beforeDeadline","RpcCompatibilityError","UnsupportedRpcValue","waitForTransactionReceipt","NativeRpcError","TransactionExecutionError","TransactionReceiptObservationError","ContractDecodeError","toHex0x","ContractDecodeError","bytesEqual","ContractVerificationError","readContractArtifactSpec","codec","ContractType","hashContract","ContractType","HogexecPrecompiledNativeContracts","bytesEqual","ContractVerificationError","UnsupportedRpcValue","RpcCompatibilityError","defaultWalletSpec","bytesEqual","DefaultWallet","deriveContractAddress","UnsupportedRpcValue","bytesEqual","codec","ContractVerificationError","createSubmissionEvidence","codec","TransactionObservationError"],"sources":["../src/actions/public/requestAirdrop.ts","../src/actions/public/getContractEvents.ts","../src/actions/public/historyWalk.ts","../src/actions/public/iterateEventPages.ts","../src/actions/public/readViews.ts","../src/actions/public/iterateTransactionPages.ts","../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"],"sourcesContent":["import type { RpcClient } from \"../../rpc/client.js\";\nimport { NativeRpcError } from \"../../rpc/errorReader.js\";\nimport { RpcCompatibilityError } from \"../../rpc/client.js\";\nimport { UnsupportedRpcValue } from \"../../rpc/codec.js\";\nimport type { TransportRequestOptions } from \"../../transport/types.js\";\nimport type {\n AirdropAttemptRequest,\n AirdropResponse,\n AirdropSucceeded,\n} from \"../../types/rpc.js\";\nimport {\n waitForTransactionReceipt,\n TransactionReceiptObservationError,\n type KnownCommitment,\n} from \"./waitForTransactionReceipt.js\";\nimport {\n TransactionExecutionError,\n assertTransactionSuccess,\n} from \"../../wallet/execution.js\";\nimport { beforeDeadline, validateTimer } from \"../deadline.js\";\n\nexport interface RequestAirdropOptions {\n readonly recipient: Uint8Array;\n readonly clientNonce?: Uint8Array;\n readonly expectedNetworkHash?: Uint8Array;\n readonly timeoutMs?: number;\n readonly signal?: AbortSignal;\n}\n/** Funding stopped without permission to call the faucet again. */\nexport class FundingObservationError extends Error {\n constructor(\n readonly request: AirdropAttemptRequest & { networkHash: Uint8Array },\n readonly lastResponse: AirdropResponse | undefined,\n cause: unknown,\n readonly knownCommitment?: KnownCommitment,\n ) {\n super(\"Funding observation stopped\", { cause });\n this.name = \"FundingObservationError\";\n }\n}\n/** Perform exactly one faucet call. It neither polls nor repeats an ambiguous attempt. */\nexport async function requestAirdropAttempt(\n client: Pick<RpcClient, \"faucet_requestAirdrop\">,\n request: AirdropAttemptRequest,\n options: TransportRequestOptions = {},\n): Promise<AirdropResponse> {\n return client.faucet_requestAirdrop(request, options);\n}\n/** Call the faucet once, then observe a returned pending hash using read-only calls. */\nexport async function requestAirdrop(\n client: RpcClient,\n options: RequestAirdropOptions,\n): Promise<AirdropSucceeded> {\n const timeoutMs = options.timeoutMs ?? 60000;\n validateTimer(timeoutMs, \"timeoutMs\");\n const request = {\n recipient: new Uint8Array(options.recipient),\n clientNonce: options.clientNonce\n ? new Uint8Array(options.clientNonce)\n : crypto.getRandomValues(new Uint8Array(16)),\n networkHash: new Uint8Array(\n options.expectedNetworkHash ?? client.discovery.network.networkHash,\n ),\n };\n if (\n request.recipient.length !== 32 ||\n request.networkHash.length !== 32 ||\n request.clientNonce.length < 1 ||\n request.clientNonce.length > 32\n )\n throw new RangeError(\n \"Funding requires 32-byte addresses/hashes and a 1–32 byte nonce\",\n );\n client.requireMethods([\n \"faucet_requestAirdrop\",\n \"getNetworkInfo\",\n \"getTransactionReceipt\",\n \"getTransactionStatus\",\n ]);\n const deadline = performance.now() + timeoutMs;\n let lastResponse: AirdropResponse | undefined;\n const timeout = () => new Error(\"Funding observation timed out\");\n const run = <T>(operation: (signal: AbortSignal) => Promise<T>) =>\n beforeDeadline(operation, deadline, options.signal, timeout);\n try {\n const network = await run((signal) =>\n client.getNetworkInfo({}, { signal }),\n );\n if (network.networkHash.some((v, i) => v !== request.networkHash[i]))\n throw new RpcCompatibilityError(\n \"Funding endpoint network does not match\",\n );\n lastResponse = await run((signal) =>\n requestAirdropAttempt(\n client,\n { recipient: request.recipient, clientNonce: request.clientNonce },\n { signal },\n ),\n );\n if (lastResponse instanceof UnsupportedRpcValue) throw lastResponse;\n if (lastResponse.attemptStatus === \"succeeded\") {\n if (lastResponse.execution instanceof UnsupportedRpcValue)\n throw lastResponse.execution;\n return lastResponse;\n }\n if (!lastResponse.transactionHash)\n throw new Error(\"Pending funding did not identify a transaction\");\n const receipt = await waitForTransactionReceipt(\n client,\n lastResponse.transactionHash,\n {\n expectedNetworkHash: request.networkHash,\n timeoutMs: Math.max(0, deadline - performance.now()),\n signal: options.signal,\n },\n );\n assertTransactionSuccess(receipt);\n return {\n attemptStatus: \"succeeded\",\n recipient: lastResponse.recipient,\n rawAmount: lastResponse.rawAmount,\n transactionHash: receipt.transactionHash,\n blockHeight: receipt.blockHeight,\n execution: receipt.execution,\n };\n } catch (cause) {\n const nativeReceipt =\n cause instanceof NativeRpcError &&\n cause.decoded.classification === \"known\" &&\n \"receipt\" in cause.decoded.data\n ? cause.decoded.data.receipt\n : undefined;\n const committedResult =\n cause instanceof TransactionExecutionError\n ? cause.receipt\n : (nativeReceipt ??\n (!(lastResponse instanceof UnsupportedRpcValue) &&\n lastResponse?.attemptStatus === \"succeeded\"\n ? lastResponse\n : undefined));\n throw new FundingObservationError(\n request,\n lastResponse,\n cause,\n cause instanceof TransactionReceiptObservationError\n ? cause.knownCommitment\n : committedResult\n ? {\n networkHash: request.networkHash.slice(),\n transactionHash: new Uint8Array(committedResult.transactionHash),\n blockHeight: committedResult.blockHeight,\n }\n : undefined,\n );\n }\n}\n","import type {\n ContractEvent,\n ContractEventFilterInput,\n DecodedContractEvent,\n} from \"../../contract/event.js\";\nimport { ContractDecodeError } from \"../../contract/errors.js\";\nimport type { TransportRequestOptions } from \"../../transport/types.js\";\nimport type {\n EmittedEvent,\n EventPage,\n EventQuery,\n IdentifiedEvent,\n} from \"../../types/rpc.js\";\nimport type { RpcClient } from \"../../rpc/client.js\";\n\n/** One generated event descriptor with named filters and ordinary page controls. */\nexport type ContractEventQuery<\n TName extends string,\n TTopics,\n TFields,\n TFilter,\n> = (EventQuery extends infer Q\n ? Q extends EventQuery\n ? Omit<Q, \"filters\">\n : never\n : never) &\n ContractEventFilterInput<NoInfer<TFilter>> & {\n event: ContractEvent<TName, TTopics, TFields, TFilter>;\n };\n\n/** A decoded event with its emitter, transaction, and position in history. */\nexport type IdentifiedContractEvent<\n TName extends string,\n TTopics,\n TFields,\n> = DecodedContractEvent<TName, TTopics, TFields> &\n Omit<IdentifiedEvent, \"event\"> &\n Pick<EmittedEvent, \"address\">;\n\n/** One decoded event page, retaining the RPC cursor and indexer bounds. */\nexport type ContractEventPage<TName extends string, TTopics, TFields> = Omit<\n EventPage,\n \"events\"\n> & {\n events: IdentifiedContractEvent<TName, TTopics, TFields>[];\n};\n\n/**\n * Fetch exactly one page using a generated event's filter and decoder.\n *\n * No additional pages are fetched. Pass the returned cursor into the next call\n * with the same filters. Malformed events and unexpected signatures throw\n * ContractDecodeError rather than silently disappearing from the page.\n *\n * @example\n * ```ts\n * const page = await getContractEvents(client, {\n * event: thruput_erc20_if.v0_1.events.TransferEvent,\n * addresses: [tokenAddress],\n * topics: { to: accountAddress },\n * start: { order: \"ascending\", anchor: { kind: \"atBeginning\" } },\n * limit: 20,\n * }, { signal });\n * ```\n */\nexport async function getContractEvents<\n TName extends string,\n TTopics,\n TFields,\n TFilter,\n>(\n client: Pick<RpcClient, \"getEvents\">,\n query: ContractEventQuery<TName, TTopics, TFields, TFilter>,\n options?: TransportRequestOptions,\n): Promise<ContractEventPage<TName, TTopics, TFields>> {\n options?.signal?.throwIfAborted();\n const { event, addresses, topics, ...pageQuery } = query;\n const page = await client.getEvents(\n {\n ...pageQuery,\n filters: [event.filter({ addresses, topics })],\n },\n options,\n );\n return {\n ...page,\n events: page.events.map(({ event: raw, ...identity }) => {\n const decoded = event.decode(raw);\n if (decoded === null) {\n throw new ContractDecodeError(\n \"Event query returned an unexpected event signature\",\n );\n }\n return { ...decoded, ...identity, address: raw.address };\n }),\n };\n}\n","import type { TransportRequestOptions } from \"../../transport/types.js\";\nimport type {\n EventPage,\n TransactionRefPage,\n IterationOrder,\n HistoryStart,\n} from \"../../types/rpc.js\";\nimport { toHex0x } from \"../hex.js\";\n\n/** Returned only after the caller resumes past the terminal page. Persist with processed data. */\nexport interface HistoryCompletion {\n readonly watermarkBlockHeight: bigint;\n /** Ascending range fully consumed; absent for descending or an anchor above the watermark. */\n readonly completedThroughBlockHeight?: bigint;\n}\nexport class HistoryWalkError extends Error {\n constructor(\n message: string,\n readonly page: EventPage | TransactionRefPage,\n ) {\n super(message);\n this.name = \"HistoryWalkError\";\n }\n}\ntype Key = readonly [bigint, string, number];\nconst compare = (a: Key, b: Key) => {\n for (let i = 0; i < 3; i++) {\n if (a[i]! < b[i]!) return -1;\n if (a[i]! > b[i]!) return 1;\n }\n return 0;\n};\n/** Shared cross-page checks; single-page shape, filter and identity checks belong to RpcClient. */\nexport async function* walkHistory<P extends EventPage | TransactionRefPage>(\n fetch: (cursor: string | undefined) => Promise<P>,\n kind: \"events\" | \"transactions\",\n scope:\n | { start: HistoryStart }\n | { blockHeight: bigint; order: IterationOrder },\n options: TransportRequestOptions,\n): AsyncGenerator<P, HistoryCompletion | void, unknown> {\n const order = \"start\" in scope ? scope.start.order : scope.order;\n let cursor: string | undefined,\n watermark: bigint | undefined,\n lowerBound: bigint | undefined,\n upperBound: bigint | undefined,\n last: Key | undefined;\n const cursors = new Set<string>(),\n identities = new Set<string>();\n for (;;) {\n options.signal?.throwIfAborted();\n const page = await fetch(cursor);\n options.signal?.throwIfAborted();\n const fail = (message: string): never => {\n throw new HistoryWalkError(message, page);\n };\n const rows =\n kind === \"events\"\n ? (page as EventPage).events\n : (page as TransactionRefPage).transactions;\n if (watermark === undefined) {\n watermark = page.latestIndexedBlockHeight;\n lowerBound =\n \"start\" in scope &&\n order === \"ascending\" &&\n scope.start.anchor.kind === \"atHeight\"\n ? scope.start.anchor.blockHeight\n : page.oldestIndexedBlockHeight;\n upperBound =\n \"start\" in scope &&\n order === \"descending\" &&\n scope.start.anchor.kind === \"atHeight\" &&\n scope.start.anchor.blockHeight < watermark\n ? scope.start.anchor.blockHeight\n : watermark;\n }\n if (\"blockHeight\" in scope) {\n if (\n scope.blockHeight < page.oldestIndexedBlockHeight ||\n scope.blockHeight > page.latestIndexedBlockHeight\n )\n fail(\"Requested block is outside current indexed coverage\");\n } else {\n if (page.latestIndexedBlockHeight < watermark)\n fail(\"History coverage regressed below the initial watermark\");\n if (page.oldestIndexedBlockHeight > lowerBound!)\n fail(\"History retention no longer covers the requested range\");\n }\n for (const row of rows) {\n if (\n \"blockHeight\" in scope\n ? row.blockHeight !== scope.blockHeight\n : row.blockHeight > upperBound! || row.blockHeight < lowerBound!\n )\n fail(\"History row is outside the fixed walk scope\");\n const hash = toHex0x(row.transactionHash),\n sequence =\n kind === \"events\"\n ? (row as EventPage[\"events\"][number]).sequenceNumber\n : 0;\n const identity = kind === \"events\" ? `${hash}/${sequence}` : hash;\n if (identities.has(identity))\n fail(\"History returned a duplicate identity across pages\");\n const key: Key = [row.blockHeight, hash, sequence];\n if (\n last &&\n (order === \"ascending\"\n ? compare(last, key) >= 0\n : compare(last, key) <= 0)\n )\n fail(\"History order did not advance across pages\");\n identities.add(identity);\n last = key;\n }\n // Capture cursor before the caller can mutate the yielded page.\n const next = page.nextCursor;\n if (next !== null) {\n if (cursors.has(next))\n fail(\"History returned a repeated pagination cursor\");\n cursors.add(next);\n }\n yield page;\n if (next === null) {\n options.signal?.throwIfAborted();\n if (\"blockHeight\" in scope) return;\n return {\n watermarkBlockHeight: watermark,\n ...(order === \"ascending\" && lowerBound! <= watermark\n ? { completedThroughBlockHeight: watermark }\n : {}),\n };\n }\n cursor = next;\n }\n}\n","import type { RpcClient } from \"../../rpc/client.js\";\nimport type { TransportRequestOptions } from \"../../transport/types.js\";\nimport type { EventPage, EventQuery } from \"../../types/rpc.js\";\nimport { walkHistory, type HistoryCompletion } from \"./historyWalk.js\";\nexport type EventWalkQuery = Extract<EventQuery, { start: unknown }>;\n/** Start a fixed event range. Saved opaque cursors remain available through getEvents. */\nexport function iterateEventPages(\n client: Pick<RpcClient, \"getEvents\">,\n query: EventWalkQuery,\n options: TransportRequestOptions = {},\n): AsyncGenerator<EventPage, HistoryCompletion, unknown> {\n const snapshot = structuredClone(query);\n if (!snapshot.start || snapshot.cursor !== undefined)\n throw new TypeError(\"Event walks require an explicit start\");\n return walkHistory(\n (cursor) =>\n client.getEvents(\n cursor === undefined\n ? snapshot\n : { filters: snapshot.filters, limit: snapshot.limit, cursor },\n options,\n ),\n \"events\",\n { start: snapshot.start },\n options,\n ) as AsyncGenerator<EventPage, HistoryCompletion, unknown>;\n}\n","import type { RpcClient } from \"../../rpc/client.js\";\nimport type {\n ContractViewRequest,\n ContractViewOutcome,\n ContractException,\n} from \"../../contract/method.js\";\nimport type { TransportRequestOptions } from \"../../transport/types.js\";\nimport { ContractDecodeError } from \"../../contract/errors.js\";\n\n/** Typed calls and an optional minimum committed height for one snapshot read. */\nexport interface ReadViewsRequest<\n TCalls extends readonly ContractViewRequest[],\n> {\n calls: TCalls;\n minStateBlockHeight?: bigint;\n}\n\n/** Ordered typed outcomes, preserving each tuple position's return and exception types. */\nexport interface ReadViewsResponse<\n TCalls extends readonly ContractViewRequest[],\n> {\n stateBlockHeight: bigint;\n results: {\n [K in keyof TCalls]: TCalls[K] extends ContractViewRequest<infer R, infer E>\n ? ContractViewOutcome<R, ContractException<E>>\n : never;\n };\n}\n\n/**\n * Read generated method requests against one shared committed snapshot.\n * Contract aborts and faults are outcomes. Transport, freshness, and decoding\n * failures reject the group. Calls are never split or emulated with separate views.\n *\n * @example\n * ```ts\n * const result = await client.readViews({ calls: [\n * ERC20.v0_1.totalSupply.viewRequest({ address: token }),\n * ERC20.v0_1.getBalanceOf.viewRequest({ address: token, args: { addr: owner } }),\n * ] });\n * ```\n */\nexport async function readViews<\n const TCalls extends readonly ContractViewRequest[],\n>(\n client: Pick<RpcClient, \"simulateInvocations\">,\n request: ReadViewsRequest<TCalls>,\n options?: TransportRequestOptions,\n): Promise<ReadViewsResponse<TCalls>> {\n options?.signal?.throwIfAborted();\n // Retain the decoder order across the asynchronous request even if the caller\n // later edits its array. simulateInvocations serializes the byte inputs before yielding.\n const calls = request.calls.map((call) => {\n if (\"minStateBlockHeight\" in call) {\n throw new TypeError(\n \"Set minStateBlockHeight on readViews, not on a prepared call\",\n );\n }\n return {\n request: call.request,\n name: call.method.name,\n decode: call.method.decodeViewOutcome,\n };\n });\n const response = await client.simulateInvocations(\n {\n invocations: calls.map((call) => call.request),\n ...(request.minStateBlockHeight === undefined\n ? {}\n : { minStateBlockHeight: request.minStateBlockHeight }),\n },\n options,\n );\n const results = calls.map((call, index) => {\n try {\n return call.decode({\n ...response.results[index]!,\n stateBlockHeight: response.stateBlockHeight,\n });\n } catch (cause) {\n throw new ContractDecodeError(\n `Failed to decode readViews result ${index} (${call.name})`,\n { cause },\n );\n }\n });\n // simulateInvocations validates the exact count; each position uses its retained decoder.\n return {\n stateBlockHeight: response.stateBlockHeight,\n results: results as ReadViewsResponse<TCalls>[\"results\"],\n };\n}\n","import type { RpcClient } from \"../../rpc/client.js\";\nimport type { TransportRequestOptions } from \"../../transport/types.js\";\nimport type {\n RootAddressTransactionQuery,\n BlockTransactionQuery,\n TransactionRefPage,\n} from \"../../types/rpc.js\";\nimport { walkHistory, type HistoryCompletion } from \"./historyWalk.js\";\nexport type RootAddressWalkQuery = Extract<\n RootAddressTransactionQuery,\n { start: unknown }\n>;\nexport type BlockTransactionWalkQuery = Extract<\n BlockTransactionQuery,\n { start: unknown }\n>;\n/** Transactions sent by this root address; incoming transfers use token events. */\nexport function iterateTransactionsByRootAddress(\n client: Pick<RpcClient, \"getTransactionsByRootAddress\">,\n query: RootAddressWalkQuery,\n options: TransportRequestOptions = {},\n): AsyncGenerator<TransactionRefPage, HistoryCompletion, unknown> {\n const snapshot = structuredClone(query);\n if (!snapshot.start || snapshot.cursor !== undefined)\n throw new TypeError(\"Root-address walks require an explicit start\");\n return walkHistory(\n (cursor) =>\n client.getTransactionsByRootAddress(\n cursor === undefined\n ? snapshot\n : { address: snapshot.address, limit: snapshot.limit, cursor },\n options,\n ),\n \"transactions\",\n { start: snapshot.start },\n options,\n ) as AsyncGenerator<TransactionRefPage, HistoryCompletion, unknown>;\n}\n/** Walk one covered block. Completion never establishes a whole-chain checkpoint. */\nexport function iterateTransactionsByBlock(\n client: Pick<RpcClient, \"getTransactionsByBlock\">,\n query: BlockTransactionWalkQuery,\n options: TransportRequestOptions = {},\n): AsyncGenerator<TransactionRefPage, void, unknown> {\n const snapshot = structuredClone(query);\n if (!snapshot.start || snapshot.cursor !== undefined)\n throw new TypeError(\"Block walks require an explicit start\");\n return walkHistory(\n (cursor) =>\n client.getTransactionsByBlock(\n cursor === undefined\n ? snapshot\n : {\n blockHeight: snapshot.blockHeight,\n limit: snapshot.limit,\n cursor,\n },\n options,\n ),\n \"transactions\",\n { blockHeight: snapshot.blockHeight, order: snapshot.start.order },\n options,\n ) as AsyncGenerator<TransactionRefPage, void, unknown>;\n}\n","import {\n codec,\n ContractType,\n deserialize,\n sha256Hash,\n} from \"@thruputchain/protocol\";\nimport {\n readContractArtifactSpec,\n type ContractArtifactSpec,\n} from \"../../contract/artifact.js\";\nimport { bytesEqual } from \"../../contract/event.js\";\nimport { ContractVerificationError } from \"../../contract/errors.js\";\nimport type { RpcClient } from \"../../rpc/client.js\";\nimport type {\n RpcContractDeployment,\n RpcContractDeploymentResult,\n} from \"../../rpc/generated.js\";\nimport type { TransportRequestOptions } from \"../../transport/types.js\";\n\n/** Snapshot deployment evidence and its authenticated metadata, if deployed. */\nexport interface ContractSpecResult extends RpcContractDeploymentResult {\n artifactSpec: ContractArtifactSpec | null;\n}\n\n/**\n * Resolve a current deployment and verify its embedded spec against its hash.\n * Missing artifacts and invalid responses throw; neither means no deployment.\n * The snapshot does not establish which implementation produced historical events.\n */\nexport async function getContractSpec(\n client: RpcClient,\n request: { address: Uint8Array },\n options?: TransportRequestOptions,\n): Promise<ContractSpecResult> {\n client.requireMethods([\"getContractDeployment\", \"getContractArtifact\"]);\n const address = new Uint8Array(request.address);\n const result = await client.getContractDeployment({ address }, options);\n if (!bytesEqual(address, result.address))\n throw new ContractVerificationError(\"Contract deployment address mismatch\");\n if (result.deployment === null) return { ...result, artifactSpec: null };\n return {\n ...result,\n artifactSpec: await readDeploymentSpec(client, result.deployment, options),\n };\n}\n\n/** Shared identity validation for explicit deployments and effective contract selection. */\nexport async function readDeploymentSpec(\n client: RpcClient,\n deployment: RpcContractDeployment,\n options?: TransportRequestOptions,\n): Promise<ContractArtifactSpec> {\n const artifact = await client.getContractArtifact(\n { hash: deployment.hash },\n options,\n );\n if (!bytesEqual(artifact.hash, deployment.hash))\n throw new ContractVerificationError(\n \"Contract artifact response hash mismatch\",\n );\n const artifactSpec = readContractArtifactSpec(\n artifact.contractXdr,\n sha256Hash(deployment.hash),\n );\n const contract = deserialize(artifact.contractXdr, codec.Contract);\n const size =\n contract.contract_type === ContractType.kRv32\n ? contract.rv32_contract.data.length\n : 0;\n if (\n contract.contract_type !== deployment.contractType ||\n size !== deployment.size\n ) {\n throw new ContractVerificationError(\n \"Contract artifact does not match deployment metadata\",\n );\n }\n return artifactSpec;\n}\n","import {\n ContractType,\n HogexecPrecompiledNativeContracts,\n} from \"@thruputchain/protocol\";\nimport { hashContract } from \"../../contract/hash.js\";\nimport { bytesEqual } from \"../../contract/event.js\";\nimport { ContractVerificationError } from \"../../contract/errors.js\";\nimport type { ContractArtifactSpec } from \"../../contract/artifact.js\";\nimport { spec as defaultWalletSpec } from \"../../contracts/default_wallet.js\";\nimport type { ContractSpec } from \"../../contract/spec.js\";\nimport { RpcCompatibilityError, type RpcClient } from \"../../rpc/client.js\";\nimport type { RpcEffectiveContractResult } from \"../../rpc/generated.js\";\nimport { UnsupportedRpcValue } from \"../../rpc/codec.js\";\nimport type { TransportRequestOptions } from \"../../transport/types.js\";\nimport { readDeploymentSpec } from \"./getContractSpec.js\";\n\nconst nativeWalletHash = hashContract({\n contract_type: ContractType.kNative,\n native_contract_id:\n HogexecPrecompiledNativeContracts.kNativeContractDefaultWallet,\n});\n\nexport interface EffectiveContractSpecResult extends RpcEffectiveContractResult {\n artifactSpec: ContractArtifactSpec | null;\n /** Recognized native interface; not artifact-bound or proof of runtime code. */\n nativeInterface: { name: \"DefaultWallet\"; spec: ContractSpec } | null;\n}\n\n/**\n * Discover current contract selection without inferring authorization or historical identity.\n * Root context allows the chain-configured fallback; nested excludes that fallback.\n * Transaction-local deployments are outside this committed-state reading.\n */\nexport async function getEffectiveContractSpec(\n client: RpcClient,\n request: { address: Uint8Array; context: \"root\" | \"nested\" },\n options?: TransportRequestOptions,\n): Promise<EffectiveContractSpecResult> {\n client.requireMethods([\"getEffectiveContract\", \"getContractArtifact\"]);\n const address = new Uint8Array(request.address);\n const context = request.context;\n const result = await client.getEffectiveContract(\n { address, context },\n options,\n );\n if (!bytesEqual(address, result.address) || result.context !== context)\n throw new ContractVerificationError(\n \"Effective contract request identity mismatch\",\n );\n if (result.selection instanceof UnsupportedRpcValue)\n throw new RpcCompatibilityError(\"Unsupported effective contract selection\");\n if (result.selection === null)\n return { ...result, artifactSpec: null, nativeInterface: null };\n if (context === \"nested\" && result.selection.source === \"networkDefault\")\n throw new ContractVerificationError(\n \"Network default cannot apply to a nested invocation\",\n );\n const contract = result.selection.contract;\n const artifactSpec = await readDeploymentSpec(client, contract, options);\n const nativeInterface =\n artifactSpec.kind === \"native\" &&\n bytesEqual(contract.hash, nativeWalletHash)\n ? { name: \"DefaultWallet\" as const, spec: defaultWalletSpec }\n : null;\n return { ...result, artifactSpec, nativeInterface };\n}\n","import {\n contractEntrypointID,\n gasAmount,\n calldata,\n sha256Hash,\n type Invocation,\n} from \"@thruputchain/protocol\";\nimport { DefaultWallet } from \"../../contracts/default_wallet.js\";\nimport { bytesEqual } from \"../../contract/event.js\";\nimport { deriveContractAddress } from \"../../derivation/contractAddress.js\";\n\n/** Requested child invocations, never proof of execution or child outputs. */\nexport interface WalletRequests {\n wrapper: \"DefaultWallet.execute\" | \"DefaultWallet.deploy\";\n requestedCalls: Invocation[];\n}\n\n/**\n * Interpret a known DefaultWallet root using built-in binding descriptors.\n * Call only after identifying the root as DefaultWallet; matching selectors\n * alone do not establish wallet identity. Malformed recognized inputs throw.\n */\nexport function decodeDefaultWalletRequests(\n root: Invocation,\n): WalletRequests | null {\n if (bytesEqual(root.entrypoint, DefaultWallet.v0_1.execute.entrypoint)) {\n const { calls } = DefaultWallet.v0_1.execute.decodeArgs(root.calldata);\n return {\n wrapper: \"DefaultWallet.execute\",\n requestedCalls: calls.map((call) => ({\n invoked_address: call.target,\n entrypoint: contractEntrypointID(call.entrypoint),\n gas_limit: gasAmount(call.gas_limit),\n calldata: calldata(call.calldata),\n })),\n };\n }\n if (bytesEqual(root.entrypoint, DefaultWallet.v0_1.deploy.entrypoint)) {\n const args = DefaultWallet.v0_1.deploy.decodeArgs(root.calldata);\n const init = args.initializer;\n return {\n wrapper: \"DefaultWallet.deploy\",\n requestedCalls: init\n ? [\n {\n invoked_address: deriveContractAddress(\n root.invoked_address,\n sha256Hash(args.nonce),\n sha256Hash(args.contractHash),\n ),\n entrypoint: contractEntrypointID(init.entrypoint),\n gas_limit: gasAmount(init.gas_limit),\n calldata: calldata(init.calldata),\n },\n ]\n : [],\n };\n }\n return null;\n}\n","import { sha256 } from \"@noble/hashes/sha2.js\";\nimport {\n codec,\n deserialize,\n serialize,\n type Transaction,\n} from \"@thruputchain/protocol\";\nimport { bytesEqual } from \"../../contract/event.js\";\nimport { ContractVerificationError } from \"../../contract/errors.js\";\nimport type { RpcClient } from \"../../rpc/client.js\";\nimport { UnsupportedRpcValue } from \"../../rpc/codec.js\";\nimport type { TransportRequestOptions } from \"../../transport/types.js\";\n\n/** Canonical retained input verified against the requested public transaction hash. */\nexport type VerifiedTransactionInput =\n | {\n status: \"available\";\n transactionHash: Uint8Array;\n blockHeight: bigint;\n transactionXdr: Uint8Array;\n transaction: Transaction;\n }\n | { status: \"unavailable\" }\n | UnsupportedRpcValue;\n\n/**\n * Read and authenticate a retained Transaction, including its root invocation.\n * Unavailable does not prove nonexecution. A matching body hash authenticates\n * neither signatures nor the reported block height, and does not imply success.\n */\nexport async function readTransactionInput(\n client: RpcClient,\n request: { transactionHash: Uint8Array },\n options?: TransportRequestOptions,\n): Promise<VerifiedTransactionInput> {\n client.requireMethods([\"getTransactionInput\"]);\n const hash = new Uint8Array(request.transactionHash);\n const result = await client.getTransactionInput(\n { transactionHash: hash },\n options,\n );\n if (result instanceof UnsupportedRpcValue || result.status === \"unavailable\")\n return result;\n try {\n if (result.transactionXdr.length > 4 * 1024 * 1024)\n throw new Error(\"Transaction input exceeds 4 MiB\");\n if (\n !bytesEqual(result.transactionHash, hash) ||\n !bytesEqual(sha256(result.transactionXdr), hash)\n ) {\n throw new Error(\"Retained transaction input hash mismatch\");\n }\n const transaction = deserialize(result.transactionXdr, codec.Transaction);\n if (\n !bytesEqual(\n serialize(transaction, codec.Transaction),\n result.transactionXdr,\n )\n ) {\n throw new Error(\"Noncanonical Transaction XDR\");\n }\n return { ...result, transaction };\n } catch (cause) {\n throw new ContractVerificationError(\n cause instanceof Error ? cause.message : \"Invalid transaction input\",\n { cause },\n );\n }\n}\n","import {\n serialize,\n codec,\n sha256Hash,\n type SignedTransaction,\n type SHA256Hash,\n} from \"@thruputchain/protocol\";\nimport type { RpcClient } from \"../../rpc/client.js\";\nimport type { TransportRequestOptions } from \"../../transport/types.js\";\nimport {\n assertTransactionAdmission,\n createSubmissionEvidence,\n TransactionObservationError,\n} from \"../../wallet/execution.js\";\n\n/**\n * Serialize and submit once through the native RPC boundary.\n * Unknown admission throws TransactionObservationError with the signed bytes and\n * destination discovery network; that network does not prove the signing network\n * of an already-signed envelope. RPC and transport failures propagate unchanged.\n */\nexport async function sendTransaction(\n client: Pick<RpcClient, \"sendTransaction\" | \"discovery\">,\n signedTx: SignedTransaction,\n options?: TransportRequestOptions,\n): Promise<SHA256Hash> {\n const evidence = createSubmissionEvidence(\n serialize(signedTx, codec.SignedTransaction),\n client.discovery.network.networkHash,\n );\n const result = await client.sendTransaction(\n { signedTransaction: evidence.signedTransaction },\n options,\n );\n try {\n assertTransactionAdmission(result);\n } catch (cause) {\n throw new TransactionObservationError(\n evidence,\n cause,\n undefined,\n undefined,\n \"submission\",\n );\n }\n return sha256Hash(result.transactionHash);\n}\n"],"mappings":";;;;;;;;;;AA6BA,IAAa,0BAAb,cAA6C,MAAM;CAEtC;CACA;CAEA;CAJX,YACE,SACA,cACA,OACA,iBACA;EACA,MAAM,+BAA+B,EAAE,MAAM,CAAC;EALrC,KAAA,UAAA;EACA,KAAA,eAAA;EAEA,KAAA,kBAAA;EAGT,KAAK,OAAO;CACd;AACF;;AAEA,eAAsB,sBACpB,QACA,SACA,UAAmC,CAAC,GACV;CAC1B,OAAO,OAAO,sBAAsB,SAAS,OAAO;AACtD;;AAEA,eAAsB,eACpB,QACA,SAC2B;CAC3B,MAAM,YAAY,QAAQ,aAAa;CACvC,uBAAA,cAAc,WAAW,WAAW;CACpC,MAAM,UAAU;EACd,WAAW,IAAI,WAAW,QAAQ,SAAS;EAC3C,aAAa,QAAQ,cACjB,IAAI,WAAW,QAAQ,WAAW,IAClC,OAAO,gBAAgB,IAAI,WAAW,EAAE,CAAC;EAC7C,aAAa,IAAI,WACf,QAAQ,uBAAuB,OAAO,UAAU,QAAQ,WAC1D;CACF;CACA,IACE,QAAQ,UAAU,WAAW,MAC7B,QAAQ,YAAY,WAAW,MAC/B,QAAQ,YAAY,SAAS,KAC7B,QAAQ,YAAY,SAAS,IAE7B,MAAM,IAAI,WACR,iEACF;CACF,OAAO,eAAe;EACpB;EACA;EACA;EACA;CACF,CAAC;CACD,MAAM,WAAW,YAAY,IAAI,IAAI;CACrC,IAAI;CACJ,MAAM,gCAAgB,IAAI,MAAM,+BAA+B;CAC/D,MAAM,OAAU,cACdA,uBAAAA,eAAe,WAAW,UAAU,QAAQ,QAAQ,OAAO;CAC7D,IAAI;EAIF,KAAI,MAHkB,KAAK,WACzB,OAAO,eAAe,CAAC,G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9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as UnsupportedRpcValue } from "./codec-
|
|
1
|
+
import { E as ContractVerificationError, T as ContractDecodeError, a as readContractArtifactSpec, i as deriveContractAddress, o as bytesEqual, u as hashContract } from "./contract-DzvyyFCI.js";
|
|
2
|
+
import { r as UnsupportedRpcValue } from "./codec-BHKoSaOP.js";
|
|
3
3
|
import { i as toHex0x } from "./hex-DIcaALXL.js";
|
|
4
|
-
import { i as NativeRpcError, n as RpcCompatibilityError } from "./readError-
|
|
5
|
-
import { E as validateTimer, T as beforeDeadline, d as assertTransactionSuccess, f as createSubmissionEvidence, o as TransactionExecutionError, s as TransactionObservationError, u as assertTransactionAdmission, w as waitForTransactionReceipt, x as TransactionReceiptObservationError } from "./sendInvocation-
|
|
6
|
-
import {
|
|
4
|
+
import { i as NativeRpcError, n as RpcCompatibilityError } from "./readError-CZPYcW__.js";
|
|
5
|
+
import { E as validateTimer, T as beforeDeadline, d as assertTransactionSuccess, f as createSubmissionEvidence, o as TransactionExecutionError, s as TransactionObservationError, u as assertTransactionAdmission, w as waitForTransactionReceipt, x as TransactionReceiptObservationError } from "./sendInvocation-BwabRa2N.js";
|
|
6
|
+
import { a as spec, r as DefaultWallet } from "./dev_wallet-CSMA1PCt.js";
|
|
7
|
+
import { ContractType, HogexecPrecompiledNativeContracts, calldata, codec, contractEntrypointID, deserialize, gasAmount, serialize, sha256Hash } from "@thruputchain/protocol";
|
|
8
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
7
9
|
//#region src/actions/public/requestAirdrop.ts
|
|
8
10
|
/** Funding stopped without permission to call the faucet again. */
|
|
9
11
|
var FundingObservationError = class extends Error {
|
|
@@ -275,6 +277,136 @@ function iterateTransactionsByBlock(client, query, options = {}) {
|
|
|
275
277
|
}, options);
|
|
276
278
|
}
|
|
277
279
|
//#endregion
|
|
280
|
+
//#region src/actions/public/getContractSpec.ts
|
|
281
|
+
/**
|
|
282
|
+
* Resolve a current deployment and verify its embedded spec against its hash.
|
|
283
|
+
* Missing artifacts and invalid responses throw; neither means no deployment.
|
|
284
|
+
* The snapshot does not establish which implementation produced historical events.
|
|
285
|
+
*/
|
|
286
|
+
async function getContractSpec(client, request, options) {
|
|
287
|
+
client.requireMethods(["getContractDeployment", "getContractArtifact"]);
|
|
288
|
+
const address = new Uint8Array(request.address);
|
|
289
|
+
const result = await client.getContractDeployment({ address }, options);
|
|
290
|
+
if (!bytesEqual(address, result.address)) throw new ContractVerificationError("Contract deployment address mismatch");
|
|
291
|
+
if (result.deployment === null) return {
|
|
292
|
+
...result,
|
|
293
|
+
artifactSpec: null
|
|
294
|
+
};
|
|
295
|
+
return {
|
|
296
|
+
...result,
|
|
297
|
+
artifactSpec: await readDeploymentSpec(client, result.deployment, options)
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
/** Shared identity validation for explicit deployments and effective contract selection. */
|
|
301
|
+
async function readDeploymentSpec(client, deployment, options) {
|
|
302
|
+
const artifact = await client.getContractArtifact({ hash: deployment.hash }, options);
|
|
303
|
+
if (!bytesEqual(artifact.hash, deployment.hash)) throw new ContractVerificationError("Contract artifact response hash mismatch");
|
|
304
|
+
const artifactSpec = readContractArtifactSpec(artifact.contractXdr, sha256Hash(deployment.hash));
|
|
305
|
+
const contract = deserialize(artifact.contractXdr, codec.Contract);
|
|
306
|
+
const size = contract.contract_type === ContractType.kRv32 ? contract.rv32_contract.data.length : 0;
|
|
307
|
+
if (contract.contract_type !== deployment.contractType || size !== deployment.size) throw new ContractVerificationError("Contract artifact does not match deployment metadata");
|
|
308
|
+
return artifactSpec;
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/actions/public/getEffectiveContractSpec.ts
|
|
312
|
+
const nativeWalletHash = hashContract({
|
|
313
|
+
contract_type: ContractType.kNative,
|
|
314
|
+
native_contract_id: HogexecPrecompiledNativeContracts.kNativeContractDefaultWallet
|
|
315
|
+
});
|
|
316
|
+
/**
|
|
317
|
+
* Discover current contract selection without inferring authorization or historical identity.
|
|
318
|
+
* Root context allows the chain-configured fallback; nested excludes that fallback.
|
|
319
|
+
* Transaction-local deployments are outside this committed-state reading.
|
|
320
|
+
*/
|
|
321
|
+
async function getEffectiveContractSpec(client, request, options) {
|
|
322
|
+
client.requireMethods(["getEffectiveContract", "getContractArtifact"]);
|
|
323
|
+
const address = new Uint8Array(request.address);
|
|
324
|
+
const context = request.context;
|
|
325
|
+
const result = await client.getEffectiveContract({
|
|
326
|
+
address,
|
|
327
|
+
context
|
|
328
|
+
}, options);
|
|
329
|
+
if (!bytesEqual(address, result.address) || result.context !== context) throw new ContractVerificationError("Effective contract request identity mismatch");
|
|
330
|
+
if (result.selection instanceof UnsupportedRpcValue) throw new RpcCompatibilityError("Unsupported effective contract selection");
|
|
331
|
+
if (result.selection === null) return {
|
|
332
|
+
...result,
|
|
333
|
+
artifactSpec: null,
|
|
334
|
+
nativeInterface: null
|
|
335
|
+
};
|
|
336
|
+
if (context === "nested" && result.selection.source === "networkDefault") throw new ContractVerificationError("Network default cannot apply to a nested invocation");
|
|
337
|
+
const contract = result.selection.contract;
|
|
338
|
+
const artifactSpec = await readDeploymentSpec(client, contract, options);
|
|
339
|
+
const nativeInterface = artifactSpec.kind === "native" && bytesEqual(contract.hash, nativeWalletHash) ? {
|
|
340
|
+
name: "DefaultWallet",
|
|
341
|
+
spec
|
|
342
|
+
} : null;
|
|
343
|
+
return {
|
|
344
|
+
...result,
|
|
345
|
+
artifactSpec,
|
|
346
|
+
nativeInterface
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/actions/public/decodeWalletRequests.ts
|
|
351
|
+
/**
|
|
352
|
+
* Interpret a known DefaultWallet root using built-in binding descriptors.
|
|
353
|
+
* Call only after identifying the root as DefaultWallet; matching selectors
|
|
354
|
+
* alone do not establish wallet identity. Malformed recognized inputs throw.
|
|
355
|
+
*/
|
|
356
|
+
function decodeDefaultWalletRequests(root) {
|
|
357
|
+
if (bytesEqual(root.entrypoint, DefaultWallet.v0_1.execute.entrypoint)) {
|
|
358
|
+
const { calls } = DefaultWallet.v0_1.execute.decodeArgs(root.calldata);
|
|
359
|
+
return {
|
|
360
|
+
wrapper: "DefaultWallet.execute",
|
|
361
|
+
requestedCalls: calls.map((call) => ({
|
|
362
|
+
invoked_address: call.target,
|
|
363
|
+
entrypoint: contractEntrypointID(call.entrypoint),
|
|
364
|
+
gas_limit: gasAmount(call.gas_limit),
|
|
365
|
+
calldata: calldata(call.calldata)
|
|
366
|
+
}))
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
if (bytesEqual(root.entrypoint, DefaultWallet.v0_1.deploy.entrypoint)) {
|
|
370
|
+
const args = DefaultWallet.v0_1.deploy.decodeArgs(root.calldata);
|
|
371
|
+
const init = args.initializer;
|
|
372
|
+
return {
|
|
373
|
+
wrapper: "DefaultWallet.deploy",
|
|
374
|
+
requestedCalls: init ? [{
|
|
375
|
+
invoked_address: deriveContractAddress(root.invoked_address, sha256Hash(args.nonce), sha256Hash(args.contractHash)),
|
|
376
|
+
entrypoint: contractEntrypointID(init.entrypoint),
|
|
377
|
+
gas_limit: gasAmount(init.gas_limit),
|
|
378
|
+
calldata: calldata(init.calldata)
|
|
379
|
+
}] : []
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region src/actions/public/readTransactionInput.ts
|
|
386
|
+
/**
|
|
387
|
+
* Read and authenticate a retained Transaction, including its root invocation.
|
|
388
|
+
* Unavailable does not prove nonexecution. A matching body hash authenticates
|
|
389
|
+
* neither signatures nor the reported block height, and does not imply success.
|
|
390
|
+
*/
|
|
391
|
+
async function readTransactionInput(client, request, options) {
|
|
392
|
+
client.requireMethods(["getTransactionInput"]);
|
|
393
|
+
const hash = new Uint8Array(request.transactionHash);
|
|
394
|
+
const result = await client.getTransactionInput({ transactionHash: hash }, options);
|
|
395
|
+
if (result instanceof UnsupportedRpcValue || result.status === "unavailable") return result;
|
|
396
|
+
try {
|
|
397
|
+
if (result.transactionXdr.length > 4 * 1024 * 1024) throw new Error("Transaction input exceeds 4 MiB");
|
|
398
|
+
if (!bytesEqual(result.transactionHash, hash) || !bytesEqual(sha256(result.transactionXdr), hash)) throw new Error("Retained transaction input hash mismatch");
|
|
399
|
+
const transaction = deserialize(result.transactionXdr, codec.Transaction);
|
|
400
|
+
if (!bytesEqual(serialize(transaction, codec.Transaction), result.transactionXdr)) throw new Error("Noncanonical Transaction XDR");
|
|
401
|
+
return {
|
|
402
|
+
...result,
|
|
403
|
+
transaction
|
|
404
|
+
};
|
|
405
|
+
} catch (cause) {
|
|
406
|
+
throw new ContractVerificationError(cause instanceof Error ? cause.message : "Invalid transaction input", { cause });
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
//#endregion
|
|
278
410
|
//#region src/actions/wallet/sendTransaction.ts
|
|
279
411
|
/**
|
|
280
412
|
* Serialize and submit once through the native RPC boundary.
|
|
@@ -293,6 +425,6 @@ async function sendTransaction(client, signedTx, options) {
|
|
|
293
425
|
return sha256Hash(result.transactionHash);
|
|
294
426
|
}
|
|
295
427
|
//#endregion
|
|
296
|
-
export {
|
|
428
|
+
export { getContractSpec as a, readViews as c, getContractEvents as d, FundingObservationError as f, getEffectiveContractSpec as i, iterateEventPages as l, requestAirdropAttempt as m, readTransactionInput as n, iterateTransactionsByBlock as o, requestAirdrop as p, decodeDefaultWalletRequests as r, iterateTransactionsByRootAddress as s, sendTransaction as t, HistoryWalkError as u };
|
|
297
429
|
|
|
298
|
-
//# sourceMappingURL=actions-
|
|
430
|
+
//# sourceMappingURL=actions-QHgiCqT6.js.map
|