@shieldedtech/moth-wallet 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -0
- package/dist/contract/args-parser.d.ts +29 -0
- package/dist/contract/args-parser.d.ts.map +1 -0
- package/dist/contract/args-parser.js +123 -0
- package/dist/contract/args-parser.js.map +1 -0
- package/dist/contract/artifact-loader.d.ts +26 -0
- package/dist/contract/artifact-loader.d.ts.map +1 -0
- package/dist/contract/artifact-loader.js +129 -0
- package/dist/contract/artifact-loader.js.map +1 -0
- package/dist/contract/call.d.ts +32 -0
- package/dist/contract/call.d.ts.map +1 -0
- package/dist/contract/call.js +245 -0
- package/dist/contract/call.js.map +1 -0
- package/dist/contract/deploy.d.ts +36 -0
- package/dist/contract/deploy.d.ts.map +1 -0
- package/dist/contract/deploy.js +388 -0
- package/dist/contract/deploy.js.map +1 -0
- package/dist/contract/fungible-token.d.ts +40 -0
- package/dist/contract/fungible-token.d.ts.map +1 -0
- package/dist/contract/fungible-token.js +88 -0
- package/dist/contract/fungible-token.js.map +1 -0
- package/dist/contract/initial-private-state.d.ts +18 -0
- package/dist/contract/initial-private-state.d.ts.map +1 -0
- package/dist/contract/initial-private-state.js +44 -0
- package/dist/contract/initial-private-state.js.map +1 -0
- package/dist/contract/maintenance.d.ts +72 -0
- package/dist/contract/maintenance.d.ts.map +1 -0
- package/dist/contract/maintenance.js +430 -0
- package/dist/contract/maintenance.js.map +1 -0
- package/dist/contract/state.d.ts +16 -0
- package/dist/contract/state.d.ts.map +1 -0
- package/dist/contract/state.js +18 -0
- package/dist/contract/state.js.map +1 -0
- package/dist/contract/witness-loader.d.ts +3 -0
- package/dist/contract/witness-loader.d.ts.map +1 -0
- package/dist/contract/witness-loader.js +27 -0
- package/dist/contract/witness-loader.js.map +1 -0
- package/dist/daemon/api-keys.d.ts +66 -0
- package/dist/daemon/api-keys.d.ts.map +1 -0
- package/dist/daemon/api-keys.js +222 -0
- package/dist/daemon/api-keys.js.map +1 -0
- package/dist/daemon/audit-log.d.ts +65 -0
- package/dist/daemon/audit-log.d.ts.map +1 -0
- package/dist/daemon/audit-log.js +73 -0
- package/dist/daemon/audit-log.js.map +1 -0
- package/dist/daemon/client.d.ts +63 -0
- package/dist/daemon/client.d.ts.map +1 -0
- package/dist/daemon/client.js +214 -0
- package/dist/daemon/client.js.map +1 -0
- package/dist/daemon/confirmation-queue.d.ts +46 -0
- package/dist/daemon/confirmation-queue.d.ts.map +1 -0
- package/dist/daemon/confirmation-queue.js +92 -0
- package/dist/daemon/confirmation-queue.js.map +1 -0
- package/dist/daemon/index.d.ts +23 -0
- package/dist/daemon/index.d.ts.map +1 -0
- package/dist/daemon/index.js +26 -0
- package/dist/daemon/index.js.map +1 -0
- package/dist/daemon/protocol.d.ts +40 -0
- package/dist/daemon/protocol.d.ts.map +1 -0
- package/dist/daemon/protocol.js +104 -0
- package/dist/daemon/protocol.js.map +1 -0
- package/dist/daemon/server.d.ts +158 -0
- package/dist/daemon/server.d.ts.map +1 -0
- package/dist/daemon/server.js +297 -0
- package/dist/daemon/server.js.map +1 -0
- package/dist/daemon/wallet-handlers.d.ts +37 -0
- package/dist/daemon/wallet-handlers.d.ts.map +1 -0
- package/dist/daemon/wallet-handlers.js +533 -0
- package/dist/daemon/wallet-handlers.js.map +1 -0
- package/dist/daemon/wallet-rpc-parsers.d.ts +14 -0
- package/dist/daemon/wallet-rpc-parsers.d.ts.map +1 -0
- package/dist/daemon/wallet-rpc-parsers.js +259 -0
- package/dist/daemon/wallet-rpc-parsers.js.map +1 -0
- package/dist/daemon/wallet-rpc-types.d.ts +138 -0
- package/dist/daemon/wallet-rpc-types.d.ts.map +1 -0
- package/dist/daemon/wallet-rpc-types.js +11 -0
- package/dist/daemon/wallet-rpc-types.js.map +1 -0
- package/dist/diagnostics/fs-timing-store.d.ts +29 -0
- package/dist/diagnostics/fs-timing-store.d.ts.map +1 -0
- package/dist/diagnostics/fs-timing-store.js +81 -0
- package/dist/diagnostics/fs-timing-store.js.map +1 -0
- package/dist/diagnostics/timings.d.ts +64 -0
- package/dist/diagnostics/timings.d.ts.map +1 -0
- package/dist/diagnostics/timings.js +100 -0
- package/dist/diagnostics/timings.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/network/indexer-client.d.ts +66 -0
- package/dist/network/indexer-client.d.ts.map +1 -0
- package/dist/network/indexer-client.js +112 -0
- package/dist/network/indexer-client.js.map +1 -0
- package/dist/network/node-client.d.ts +27 -0
- package/dist/network/node-client.d.ts.map +1 -0
- package/dist/network/node-client.js +94 -0
- package/dist/network/node-client.js.map +1 -0
- package/dist/proof/client.d.ts +15 -0
- package/dist/proof/client.d.ts.map +1 -0
- package/dist/proof/client.js +77 -0
- package/dist/proof/client.js.map +1 -0
- package/dist/proof/provider.d.ts +12 -0
- package/dist/proof/provider.d.ts.map +1 -0
- package/dist/proof/provider.js +96 -0
- package/dist/proof/provider.js.map +1 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +2 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/midnight-provider.d.ts +11 -0
- package/dist/providers/midnight-provider.d.ts.map +1 -0
- package/dist/providers/midnight-provider.js +30 -0
- package/dist/providers/midnight-provider.js.map +1 -0
- package/dist/storage/adapter.d.ts +8 -0
- package/dist/storage/adapter.d.ts.map +1 -0
- package/dist/storage/adapter.js +2 -0
- package/dist/storage/adapter.js.map +1 -0
- package/dist/storage/fs-adapter.d.ts +14 -0
- package/dist/storage/fs-adapter.d.ts.map +1 -0
- package/dist/storage/fs-adapter.js +126 -0
- package/dist/storage/fs-adapter.js.map +1 -0
- package/dist/storage/safe-path.d.ts +13 -0
- package/dist/storage/safe-path.d.ts.map +1 -0
- package/dist/storage/safe-path.js +35 -0
- package/dist/storage/safe-path.js.map +1 -0
- package/dist/sync/activity.d.ts +53 -0
- package/dist/sync/activity.d.ts.map +1 -0
- package/dist/sync/activity.js +92 -0
- package/dist/sync/activity.js.map +1 -0
- package/dist/sync/dust-registration-estimate.d.ts +54 -0
- package/dist/sync/dust-registration-estimate.d.ts.map +1 -0
- package/dist/sync/dust-registration-estimate.js +103 -0
- package/dist/sync/dust-registration-estimate.js.map +1 -0
- package/dist/sync/node-sync-store.d.ts +10 -0
- package/dist/sync/node-sync-store.d.ts.map +1 -0
- package/dist/sync/node-sync-store.js +42 -0
- package/dist/sync/node-sync-store.js.map +1 -0
- package/dist/sync/operations.d.ts +138 -0
- package/dist/sync/operations.d.ts.map +1 -0
- package/dist/sync/operations.js +395 -0
- package/dist/sync/operations.js.map +1 -0
- package/dist/sync/preseed-parts.d.ts +18 -0
- package/dist/sync/preseed-parts.d.ts.map +1 -0
- package/dist/sync/preseed-parts.js +33 -0
- package/dist/sync/preseed-parts.js.map +1 -0
- package/dist/sync/preseed.d.ts +95 -0
- package/dist/sync/preseed.d.ts.map +1 -0
- package/dist/sync/preseed.js +365 -0
- package/dist/sync/preseed.js.map +1 -0
- package/dist/sync/progress.d.ts +45 -0
- package/dist/sync/progress.d.ts.map +1 -0
- package/dist/sync/progress.js +51 -0
- package/dist/sync/progress.js.map +1 -0
- package/dist/sync/sdk-dedup.d.ts +53 -0
- package/dist/sync/sdk-dedup.d.ts.map +1 -0
- package/dist/sync/sdk-dedup.js +134 -0
- package/dist/sync/sdk-dedup.js.map +1 -0
- package/dist/sync/sync-store.d.ts +33 -0
- package/dist/sync/sync-store.d.ts.map +1 -0
- package/dist/sync/sync-store.js +45 -0
- package/dist/sync/sync-store.js.map +1 -0
- package/dist/sync/wallet-sync.d.ts +153 -0
- package/dist/sync/wallet-sync.d.ts.map +1 -0
- package/dist/sync/wallet-sync.js +943 -0
- package/dist/sync/wallet-sync.js.map +1 -0
- package/dist/types/errors.d.ts +18 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +33 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/exit-codes.d.ts +8 -0
- package/dist/types/exit-codes.d.ts.map +1 -0
- package/dist/types/exit-codes.js +7 -0
- package/dist/types/exit-codes.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/network.d.ts +65 -0
- package/dist/types/network.d.ts.map +1 -0
- package/dist/types/network.js +108 -0
- package/dist/types/network.js.map +1 -0
- package/dist/types/tokens.d.ts +3 -0
- package/dist/types/tokens.d.ts.map +1 -0
- package/dist/types/tokens.js +11 -0
- package/dist/types/tokens.js.map +1 -0
- package/dist/types/transaction.d.ts +13 -0
- package/dist/types/transaction.d.ts.map +1 -0
- package/dist/types/transaction.js +2 -0
- package/dist/types/transaction.js.map +1 -0
- package/dist/types/wallet.d.ts +82 -0
- package/dist/types/wallet.d.ts.map +1 -0
- package/dist/types/wallet.js +2 -0
- package/dist/types/wallet.js.map +1 -0
- package/dist/wallet/address-validate.d.ts +7 -0
- package/dist/wallet/address-validate.d.ts.map +1 -0
- package/dist/wallet/address-validate.js +28 -0
- package/dist/wallet/address-validate.js.map +1 -0
- package/dist/wallet/address.d.ts +32 -0
- package/dist/wallet/address.d.ts.map +1 -0
- package/dist/wallet/address.js +107 -0
- package/dist/wallet/address.js.map +1 -0
- package/dist/wallet/app-secret.d.ts +15 -0
- package/dist/wallet/app-secret.d.ts.map +1 -0
- package/dist/wallet/app-secret.js +45 -0
- package/dist/wallet/app-secret.js.map +1 -0
- package/dist/wallet/balance-format.d.ts +12 -0
- package/dist/wallet/balance-format.d.ts.map +1 -0
- package/dist/wallet/balance-format.js +51 -0
- package/dist/wallet/balance-format.js.map +1 -0
- package/dist/wallet/batch-transfer.d.ts +36 -0
- package/dist/wallet/batch-transfer.d.ts.map +1 -0
- package/dist/wallet/batch-transfer.js +93 -0
- package/dist/wallet/batch-transfer.js.map +1 -0
- package/dist/wallet/keystore.d.ts +16 -0
- package/dist/wallet/keystore.d.ts.map +1 -0
- package/dist/wallet/keystore.js +76 -0
- package/dist/wallet/keystore.js.map +1 -0
- package/dist/wallet/manager.d.ts +77 -0
- package/dist/wallet/manager.d.ts.map +1 -0
- package/dist/wallet/manager.js +474 -0
- package/dist/wallet/manager.js.map +1 -0
- package/dist/wallet/mnemonic.d.ts +5 -0
- package/dist/wallet/mnemonic.d.ts.map +1 -0
- package/dist/wallet/mnemonic.js +28 -0
- package/dist/wallet/mnemonic.js.map +1 -0
- package/dist/wallet/sign-message.d.ts +20 -0
- package/dist/wallet/sign-message.d.ts.map +1 -0
- package/dist/wallet/sign-message.js +58 -0
- package/dist/wallet/sign-message.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @shieldedtech/moth-wallet
|
|
2
|
+
|
|
3
|
+
The isomorphic core engine of [Moth](https://github.com/shieldedtech/moth-wallet), a wallet tool
|
|
4
|
+
for the [Midnight Network](https://midnight.network). This package contains all wallet logic with
|
|
5
|
+
zero platform-specific imports: HD key derivation, encrypted keystores, network/indexer/proving
|
|
6
|
+
providers, background sync, and transaction building (deploy, call, transfer, mint, DUST).
|
|
7
|
+
|
|
8
|
+
The `cli`, `browser`, and `tui` packages are thin platform shells around this core.
|
|
9
|
+
|
|
10
|
+
> **Experimental — use at your own risk.** This is unaudited software provided AS-IS with no
|
|
11
|
+
> warranty, for development and testing only. Do not use it with real funds on mainnet.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @shieldedtech/moth-wallet
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { WalletManager, FilesystemStorageAdapter } from '@shieldedtech/moth-wallet';
|
|
23
|
+
|
|
24
|
+
// WalletManager persists encrypted keystores via a StorageAdapter
|
|
25
|
+
// (FilesystemStorageAdapter defaults to ~/.moth).
|
|
26
|
+
const wallets = new WalletManager(new FilesystemStorageAdapter());
|
|
27
|
+
|
|
28
|
+
// Generate a wallet — returns its info plus the freshly generated 24-word mnemonic.
|
|
29
|
+
const info = await wallets.generate('dev', 'passphrase', 'preview');
|
|
30
|
+
console.log(info.addresses.nightExternal.bech32m.preview);
|
|
31
|
+
|
|
32
|
+
// Unlock to derive keys for signing; lock() zeroes key material from memory.
|
|
33
|
+
const unlocked = await wallets.unlock('dev', 'passphrase');
|
|
34
|
+
// ... build and submit transactions ...
|
|
35
|
+
unlocked.lock();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Key entry points exported from the package root include `WalletManager`, `generateMnemonic24`,
|
|
39
|
+
`startWalletSync`, `sendTokens`, `deployContract`, `callCircuit`, `queryContractState`,
|
|
40
|
+
`loadContractArtifact`, `IndexerClient`, `JsonRpcNodeClient`, `ProofClient`,
|
|
41
|
+
`createProvingProvider`, `TransactionBuilder`, and `DEFAULT_NETWORKS`.
|
|
42
|
+
|
|
43
|
+
## Modules
|
|
44
|
+
|
|
45
|
+
| Area | What it covers |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| `wallet/` | HD derivation (BIP-44 `m/44'/2400'`), keystore encryption, mnemonics, balance |
|
|
48
|
+
| `network/` | JSON-RPC node client, GraphQL indexer client |
|
|
49
|
+
| `transaction/` | Transaction builder — deploy, call, transfer, mint, DUST |
|
|
50
|
+
| `proof/` | Selectable proof-server and local WASM providers |
|
|
51
|
+
| `sync/` | Background wallet sync with genesis-reset detection |
|
|
52
|
+
| `contract/` | Artifact/witness loading, args parsing, state queries, maintenance |
|
|
53
|
+
| `storage/` | `StorageAdapter` interface + filesystem implementation |
|
|
54
|
+
|
|
55
|
+
## Documentation
|
|
56
|
+
|
|
57
|
+
See the [project README](https://github.com/shieldedtech/moth-wallet#readme) for full
|
|
58
|
+
architecture, the security model, and end-to-end examples.
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
Apache-2.0 — see [LICENSE](https://github.com/shieldedtech/moth-wallet/blob/main/LICENSE).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse circuit or constructor arguments from a string.
|
|
3
|
+
* Supports:
|
|
4
|
+
* - Inline JSON: '{"amount": 100}' or '[100, "0x1a2b..."]'
|
|
5
|
+
* - File reference: '@path/to/args.json' (prefix with @)
|
|
6
|
+
*
|
|
7
|
+
* Bytes<N> convention: any JSON string matching /^0x[0-9a-fA-F]+$/ is converted to a
|
|
8
|
+
* `Uint8Array` of the decoded bytes (e.g. "0x00112233" -> Uint8Array[0x00,0x11,0x22,0x33]).
|
|
9
|
+
* This applies recursively to strings found anywhere in the parsed structure (object
|
|
10
|
+
* values, array elements, nested objects). Strings that don't match the pattern —
|
|
11
|
+
* including plain "0x" with no digits — are left untouched as ordinary strings.
|
|
12
|
+
*
|
|
13
|
+
* Uint/Field bigint convention: any JSON string matching /^-?\d+n$/ (e.g. "5000000n") is
|
|
14
|
+
* converted to a `bigint` (e.g. 5000000n). This is required for any numeric constructor or
|
|
15
|
+
* circuit argument whose Compact type is `Uint<..>` or `Field` — the compact-runtime JS
|
|
16
|
+
* boundary expects `bigint`, not `number`, for these. Plain JSON numbers (no quotes, no "n"
|
|
17
|
+
* suffix) are left as JS `number` for backward compatibility.
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseArgs(input: string): Promise<unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* Normalize a parsed `parseArgs()` result into a positional argument array, the shape
|
|
22
|
+
* expected by both `submitCallTx`'s `args` and `deployContract`'s `args` (constructor
|
|
23
|
+
* arguments). Mirrors the convention already used by the `call` command:
|
|
24
|
+
* - `undefined` / `{}` (no args given) -> `[]`
|
|
25
|
+
* - an array -> used as-is (already positional)
|
|
26
|
+
* - any other single value -> wrapped in a one-element array
|
|
27
|
+
*/
|
|
28
|
+
export declare function toPositionalArgs(parsed: unknown): unknown[];
|
|
29
|
+
//# sourceMappingURL=args-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args-parser.d.ts","sourceRoot":"","sources":["../../src/contract/args-parser.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAuB/D;AAyDD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,CAO3D"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { InvalidInputError } from '../types/errors.js';
|
|
3
|
+
// Matches a JSON string value representing a hex-encoded byte string, e.g. "0x1a2b3c...".
|
|
4
|
+
// Used to let circuit/constructor arguments express Compact `Bytes<N>` values in JSON.
|
|
5
|
+
const HEX_BYTES_PATTERN = /^0x[0-9a-fA-F]+$/;
|
|
6
|
+
// Matches a JSON string value representing a bigint literal, e.g. "5000000n" or "-1n".
|
|
7
|
+
// Used to let circuit/constructor arguments express Compact `Uint<..>`/`Field` values in JSON.
|
|
8
|
+
// JSON has no native integer-vs-bigint distinction (JSON.parse always produces `number` for
|
|
9
|
+
// numeric literals), but the compact-runtime JS boundary requires an exact `bigint` for these
|
|
10
|
+
// parameter types — passing a `number` (even one that looks like the right value) is a type
|
|
11
|
+
// error at proving time, not merely a range check. A bare JSON number (e.g. `5000000`) is left
|
|
12
|
+
// as a JS `number`, preserving existing behavior; only a quoted string with a trailing "n"
|
|
13
|
+
// (mirroring the JS bigint-literal suffix) is converted to `bigint`.
|
|
14
|
+
const BIGINT_PATTERN = /^-?\d+n$/;
|
|
15
|
+
/**
|
|
16
|
+
* Parse circuit or constructor arguments from a string.
|
|
17
|
+
* Supports:
|
|
18
|
+
* - Inline JSON: '{"amount": 100}' or '[100, "0x1a2b..."]'
|
|
19
|
+
* - File reference: '@path/to/args.json' (prefix with @)
|
|
20
|
+
*
|
|
21
|
+
* Bytes<N> convention: any JSON string matching /^0x[0-9a-fA-F]+$/ is converted to a
|
|
22
|
+
* `Uint8Array` of the decoded bytes (e.g. "0x00112233" -> Uint8Array[0x00,0x11,0x22,0x33]).
|
|
23
|
+
* This applies recursively to strings found anywhere in the parsed structure (object
|
|
24
|
+
* values, array elements, nested objects). Strings that don't match the pattern —
|
|
25
|
+
* including plain "0x" with no digits — are left untouched as ordinary strings.
|
|
26
|
+
*
|
|
27
|
+
* Uint/Field bigint convention: any JSON string matching /^-?\d+n$/ (e.g. "5000000n") is
|
|
28
|
+
* converted to a `bigint` (e.g. 5000000n). This is required for any numeric constructor or
|
|
29
|
+
* circuit argument whose Compact type is `Uint<..>` or `Field` — the compact-runtime JS
|
|
30
|
+
* boundary expects `bigint`, not `number`, for these. Plain JSON numbers (no quotes, no "n"
|
|
31
|
+
* suffix) are left as JS `number` for backward compatibility.
|
|
32
|
+
*/
|
|
33
|
+
export async function parseArgs(input) {
|
|
34
|
+
if (!input || input.trim() === '') {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
const trimmed = input.trim();
|
|
38
|
+
// File reference: starts with @
|
|
39
|
+
if (trimmed.startsWith('@')) {
|
|
40
|
+
const filePath = trimmed.slice(1);
|
|
41
|
+
try {
|
|
42
|
+
const content = await readFile(filePath, 'utf-8');
|
|
43
|
+
return parseJsonSafe(content, filePath);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
if (err.code === 'ENOENT') {
|
|
47
|
+
throw new InvalidInputError(`Arguments file not found: ${filePath}`);
|
|
48
|
+
}
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Inline JSON
|
|
53
|
+
return parseJsonSafe(trimmed, 'inline');
|
|
54
|
+
}
|
|
55
|
+
function parseJsonSafe(content, source) {
|
|
56
|
+
try {
|
|
57
|
+
return reviveTypedValues(JSON.parse(content));
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
if (err instanceof InvalidInputError)
|
|
61
|
+
throw err;
|
|
62
|
+
// SECURITY: Do not include file content in error messages (CWE-209).
|
|
63
|
+
throw new InvalidInputError(`Invalid JSON in arguments (source: ${source}). Check syntax and try again.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Recursively convert typed-string values into their richer JS representations:
|
|
68
|
+
* - hex strings (/^0x[0-9a-fA-F]+$/) -> Uint8Array (Bytes<N> convention)
|
|
69
|
+
* - bigint-literal strings (/^-?\d+n$/) -> bigint (Uint<..>/Field convention)
|
|
70
|
+
* Other strings, and all non-string values, are left untouched.
|
|
71
|
+
*/
|
|
72
|
+
function reviveTypedValues(value) {
|
|
73
|
+
if (typeof value === 'string') {
|
|
74
|
+
if (HEX_BYTES_PATTERN.test(value)) {
|
|
75
|
+
return hexToBytes(value);
|
|
76
|
+
}
|
|
77
|
+
if (BIGINT_PATTERN.test(value)) {
|
|
78
|
+
return BigInt(value.slice(0, -1));
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
if (Array.isArray(value)) {
|
|
83
|
+
return value.map(reviveTypedValues);
|
|
84
|
+
}
|
|
85
|
+
if (value && typeof value === 'object') {
|
|
86
|
+
const out = {};
|
|
87
|
+
for (const [key, val] of Object.entries(value)) {
|
|
88
|
+
out[key] = reviveTypedValues(val);
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
function hexToBytes(hex) {
|
|
95
|
+
const digits = hex.slice(2);
|
|
96
|
+
if (digits.length % 2 !== 0) {
|
|
97
|
+
throw new InvalidInputError(`Invalid hex byte string "${hex}": must have an even number of hex digits.`);
|
|
98
|
+
}
|
|
99
|
+
const bytes = new Uint8Array(digits.length / 2);
|
|
100
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
101
|
+
bytes[i] = Number.parseInt(digits.substring(i * 2, i * 2 + 2), 16);
|
|
102
|
+
}
|
|
103
|
+
return bytes;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Normalize a parsed `parseArgs()` result into a positional argument array, the shape
|
|
107
|
+
* expected by both `submitCallTx`'s `args` and `deployContract`'s `args` (constructor
|
|
108
|
+
* arguments). Mirrors the convention already used by the `call` command:
|
|
109
|
+
* - `undefined` / `{}` (no args given) -> `[]`
|
|
110
|
+
* - an array -> used as-is (already positional)
|
|
111
|
+
* - any other single value -> wrapped in a one-element array
|
|
112
|
+
*/
|
|
113
|
+
export function toPositionalArgs(parsed) {
|
|
114
|
+
if (parsed === undefined)
|
|
115
|
+
return [];
|
|
116
|
+
if (Array.isArray(parsed))
|
|
117
|
+
return parsed;
|
|
118
|
+
if (typeof parsed === 'object' && parsed !== null && Object.keys(parsed).length === 0) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
return [parsed];
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=args-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args-parser.js","sourceRoot":"","sources":["../../src/contract/args-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,0FAA0F;AAC1F,uFAAuF;AACvF,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAE7C,uFAAuF;AACvF,+FAA+F;AAC/F,4FAA4F;AAC5F,8FAA8F;AAC9F,4FAA4F;AAC5F,+FAA+F;AAC/F,2FAA2F;AAC3F,qEAAqE;AACrE,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAAa;IAC3C,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAClC,OAAO,EA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AC,EAAE,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAe;IAC9C,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACpC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IACzC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtF,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface ContractArtifact {
|
|
2
|
+
/** The managed/ directory path (the root passed by the user) */
|
|
3
|
+
readonly path: string;
|
|
4
|
+
/** Path to the contract/ subdirectory containing index.js */
|
|
5
|
+
readonly contractDir: string;
|
|
6
|
+
readonly circuits: string[];
|
|
7
|
+
readonly contractModule: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Load a compiled Compact contract from a managed/ directory.
|
|
11
|
+
*
|
|
12
|
+
* Accepts the path output by `compact compile`:
|
|
13
|
+
* managed/
|
|
14
|
+
* ├── contract/ ← contains index.js (the contract module)
|
|
15
|
+
* │ ├── index.js
|
|
16
|
+
* │ ├── index.d.ts
|
|
17
|
+
* │ └── index.js.map
|
|
18
|
+
* ├── keys/ ← prover/verifier keys
|
|
19
|
+
* ├── zkir/ ← zero-knowledge IR
|
|
20
|
+
* └── compiler/
|
|
21
|
+
*
|
|
22
|
+
* Also accepts the contract/ subdirectory directly, or a directory
|
|
23
|
+
* containing .js files at the root (legacy/simple layout).
|
|
24
|
+
*/
|
|
25
|
+
export declare function loadContractArtifact(rawPath: string): Promise<ContractArtifact>;
|
|
26
|
+
//# sourceMappingURL=artifact-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-loader.d.ts","sourceRoot":"","sources":["../../src/contract/artifact-loader.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA6CrF"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { readdir, readFile, stat } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { InvalidInputError } from '../types/errors.js';
|
|
4
|
+
/**
|
|
5
|
+
* Load a compiled Compact contract from a managed/ directory.
|
|
6
|
+
*
|
|
7
|
+
* Accepts the path output by `compact compile`:
|
|
8
|
+
* managed/
|
|
9
|
+
* ├── contract/ ← contains index.js (the contract module)
|
|
10
|
+
* │ ├── index.js
|
|
11
|
+
* │ ├── index.d.ts
|
|
12
|
+
* │ └── index.js.map
|
|
13
|
+
* ├── keys/ ← prover/verifier keys
|
|
14
|
+
* ├── zkir/ ← zero-knowledge IR
|
|
15
|
+
* └── compiler/
|
|
16
|
+
*
|
|
17
|
+
* Also accepts the contract/ subdirectory directly, or a directory
|
|
18
|
+
* containing .js files at the root (legacy/simple layout).
|
|
19
|
+
*/
|
|
20
|
+
export async function loadContractArtifact(rawPath) {
|
|
21
|
+
const artifactPath = rawPath.trim();
|
|
22
|
+
// Verify directory exists
|
|
23
|
+
try {
|
|
24
|
+
const s = await stat(artifactPath);
|
|
25
|
+
if (!s.isDirectory()) {
|
|
26
|
+
throw new InvalidInputError(`Not a directory: ${artifactPath}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
if (err.code === 'ENOENT') {
|
|
31
|
+
throw new InvalidInputError(`Artifact directory not found: ${artifactPath}`);
|
|
32
|
+
}
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
// Strategy 1: managed/ directory with contract/ subdirectory
|
|
36
|
+
const contractSubdir = join(artifactPath, 'contract');
|
|
37
|
+
try {
|
|
38
|
+
const contractStat = await stat(contractSubdir);
|
|
39
|
+
if (contractStat.isDirectory()) {
|
|
40
|
+
return await loadFromContractDir(artifactPath, contractSubdir);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch { /* no contract/ subdir — try other strategies */ }
|
|
44
|
+
// Strategy 2: The user passed the contract/ directory directly
|
|
45
|
+
const entries = await readdir(artifactPath);
|
|
46
|
+
if (entries.includes('index.js') || entries.includes('index.cjs') || entries.includes('index.mjs')) {
|
|
47
|
+
// User pointed directly at the contract/ directory — parent is the managed/ dir
|
|
48
|
+
const parentDir = join(artifactPath, '..');
|
|
49
|
+
return await loadFromContractDir(parentDir, artifactPath);
|
|
50
|
+
}
|
|
51
|
+
// Strategy 3: Legacy — .js file at root
|
|
52
|
+
const jsFile = entries.find((e) => e.endsWith('.cjs') || e.endsWith('.mjs') || e.endsWith('.js'));
|
|
53
|
+
if (jsFile) {
|
|
54
|
+
return await loadModuleAt(artifactPath, join(artifactPath, jsFile));
|
|
55
|
+
}
|
|
56
|
+
throw new InvalidInputError(`No contract module found in ${artifactPath}. ` +
|
|
57
|
+
`Expected a managed/ directory from compact compile output ` +
|
|
58
|
+
`(with contract/index.js inside), or a directory with a .js file.`);
|
|
59
|
+
}
|
|
60
|
+
async function loadFromContractDir(managedDir, contractDir) {
|
|
61
|
+
const entries = await readdir(contractDir);
|
|
62
|
+
const indexFile = entries.find((e) => e === 'index.js' || e === 'index.cjs' || e === 'index.mjs');
|
|
63
|
+
if (!indexFile) {
|
|
64
|
+
throw new InvalidInputError(`No index.js found in ${contractDir}. Expected compact compile output.`);
|
|
65
|
+
}
|
|
66
|
+
const artifact = await loadModuleAt(managedDir, join(contractDir, indexFile));
|
|
67
|
+
return { ...artifact, contractDir };
|
|
68
|
+
}
|
|
69
|
+
async function loadModuleAt(basePath, modulePath) {
|
|
70
|
+
let contractModule;
|
|
71
|
+
try {
|
|
72
|
+
const moduleUrl = new URL(`file://${modulePath}`);
|
|
73
|
+
contractModule = await import(moduleUrl.href);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
throw new InvalidInputError(`Failed to load contract module at ${modulePath}: ${err}`);
|
|
77
|
+
}
|
|
78
|
+
const circuits = await extractCircuitNames(basePath, contractModule);
|
|
79
|
+
return {
|
|
80
|
+
path: basePath,
|
|
81
|
+
contractDir: join(modulePath, '..'),
|
|
82
|
+
circuits,
|
|
83
|
+
contractModule,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Resolve the contract's circuit names. Preference order:
|
|
88
|
+
*
|
|
89
|
+
* 1. `<artifact>/compiler/contract-info.json` — the authoritative
|
|
90
|
+
* list emitted by the Compact compiler. Modern artifacts (>= 0.31)
|
|
91
|
+
* ship this, with each entry's `name` field carrying the
|
|
92
|
+
* user-facing circuit name. Use this whenever it exists.
|
|
93
|
+
* 2. A `circuits` map on the contract module (legacy / hand-rolled
|
|
94
|
+
* artifacts).
|
|
95
|
+
* 3. A `circuits` map on `module.default` (CJS shim).
|
|
96
|
+
* 4. Module-level named exports as a last resort. This branch is
|
|
97
|
+
* fragile because modern Compact contracts export `Contract`,
|
|
98
|
+
* `ledger`, `pureCircuits`, `contractReferenceLocations` —
|
|
99
|
+
* none of which are real circuit names — but it remains for
|
|
100
|
+
* artifacts that predate `contract-info.json`.
|
|
101
|
+
*/
|
|
102
|
+
async function extractCircuitNames(basePath, module) {
|
|
103
|
+
try {
|
|
104
|
+
const infoPath = join(basePath, 'compiler', 'contract-info.json');
|
|
105
|
+
const raw = await readFile(infoPath, 'utf-8');
|
|
106
|
+
const info = JSON.parse(raw);
|
|
107
|
+
if (Array.isArray(info.circuits)) {
|
|
108
|
+
const names = info.circuits
|
|
109
|
+
.map((c) => c?.name)
|
|
110
|
+
.filter((n) => typeof n === 'string' && n.length > 0);
|
|
111
|
+
if (names.length > 0)
|
|
112
|
+
return names;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
/* fall through to module-introspection fallbacks */
|
|
117
|
+
}
|
|
118
|
+
if (module.circuits && typeof module.circuits === 'object') {
|
|
119
|
+
return Object.keys(module.circuits);
|
|
120
|
+
}
|
|
121
|
+
if (module.default && typeof module.default === 'object') {
|
|
122
|
+
const def = module.default;
|
|
123
|
+
if (def.circuits && typeof def.circuits === 'object') {
|
|
124
|
+
return Object.keys(def.circuits);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return Object.keys(module).filter(key => key !== 'default' && key !== '__esModule');
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=artifact-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-loader.js","sourceRoot":"","sources":["../../src/contract/artifact-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAWvD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAe;IACxD,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IACpC,0BAA0B;IAC1B,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,Y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AAC;QACzD,MAAM,GAAG,GAAG,MAAM,CAAC,OAAkC,CAAC;QACtD,IAAI,GAAG,CAAC,QAAQ,IAAI,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACrD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAC/B,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,YAAY,CACjD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { TransactionResult } from '../types/transaction.js';
|
|
2
|
+
import { type NetworkConfig } from '../types/network.js';
|
|
3
|
+
import type { DerivedKeys } from '../types/wallet.js';
|
|
4
|
+
import type { WalletKeys } from '../sync/operations.js';
|
|
5
|
+
import type { WitnessProvider } from './witness-loader.js';
|
|
6
|
+
import type { SyncedWallet } from '../sync/wallet-sync.js';
|
|
7
|
+
export interface CallOptions {
|
|
8
|
+
contractAddress: string;
|
|
9
|
+
circuitName: string;
|
|
10
|
+
args: unknown;
|
|
11
|
+
keys: DerivedKeys;
|
|
12
|
+
/** Pre-derived typed key bundle. Preferred over `seedHex` when
|
|
13
|
+
* available — the daemon path passes this so the raw seed never
|
|
14
|
+
* has to enter the contract module. See
|
|
15
|
+
* docs/spec/wallet-service/05-key-management.md D-KM-3. */
|
|
16
|
+
walletKeys?: WalletKeys;
|
|
17
|
+
/** BIP-39 hex seed. Required only when `walletKeys` is not supplied
|
|
18
|
+
* — kept for the in-process CLI path that still works in terms of
|
|
19
|
+
* the seed. */
|
|
20
|
+
seedHex?: string;
|
|
21
|
+
witnesses?: WitnessProvider;
|
|
22
|
+
network: NetworkConfig;
|
|
23
|
+
/** Path to compiled contract artifact — required for circuit execution and proof generation */
|
|
24
|
+
artifactPath: string;
|
|
25
|
+
/** A synced wallet facade — required for balancing transactions */
|
|
26
|
+
syncedWallet?: SyncedWallet;
|
|
27
|
+
/** Project directory for resolving SDK dependencies */
|
|
28
|
+
projectDir?: string;
|
|
29
|
+
timeoutMs?: number;
|
|
30
|
+
}
|
|
31
|
+
export declare function callCircuit(options: CallOptions): Promise<TransactionResult>;
|
|
32
|
+
//# sourceMappingURL=call.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../../src/contract/call.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAsB,KAAK,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAYtD,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAEzD,MAAM,WAAW,WAAW;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,WAAW,CAAC;IAClB;;;gEAG4D;IAC5D,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;oBAEgB;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,OAAO,EAAE,aAAa,CAAC;IACvB,+FAA+F;IAC/F,YAAY,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAoBlF"}
|