@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
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
// Contract deployment using the official Midnight SDK provider chain.
|
|
2
|
+
// Follows mn-tui's deployManagedContract pattern. See NOTICE for attribution.
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { join, basename, resolve as resolvePath } from 'node:path';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import * as Rx from 'rxjs';
|
|
8
|
+
import * as ledger from '@midnight-ntwrk/ledger-v8';
|
|
9
|
+
import { setNetworkId } from '@midnight-ntwrk/midnight-js/network-id';
|
|
10
|
+
import { NodeZkConfigProvider } from '@midnight-ntwrk/midnight-js-node-zk-config-provider';
|
|
11
|
+
import { indexerPublicDataProvider } from '@midnight-ntwrk/midnight-js-indexer-public-data-provider';
|
|
12
|
+
import { levelPrivateStateProvider } from '@midnight-ntwrk/midnight-js-level-private-state-provider';
|
|
13
|
+
import { HDWallet, Roles } from '@midnightntwrk/wallet-sdk/hd';
|
|
14
|
+
import { createKeystore } from '@midnightntwrk/wallet-sdk/unshielded';
|
|
15
|
+
import { homedir } from 'node:os';
|
|
16
|
+
import { resolveProverConfig } from '../types/network.js';
|
|
17
|
+
import { createProofProvider, ensureProverReady } from '../proof/provider.js';
|
|
18
|
+
import { WalletError } from '../types/errors.js';
|
|
19
|
+
function toWsUrl(url) {
|
|
20
|
+
return url.replace(/^https:/, 'wss:').replace(/^http:/, 'ws:');
|
|
21
|
+
}
|
|
22
|
+
/** Walk an error's cause chain and Effect TaggedError fields to find the real reason */
|
|
23
|
+
function extractErrorDetails(err, depth = 0) {
|
|
24
|
+
if (!err || depth > 5)
|
|
25
|
+
return '';
|
|
26
|
+
const parts = [];
|
|
27
|
+
// Effect TaggedError stores fields as own properties (cause, _tag, message, etc.)
|
|
28
|
+
const obj = err;
|
|
29
|
+
if (obj._tag && obj._tag !== 'SubmissionError') {
|
|
30
|
+
parts.push(`[${obj._tag}]`);
|
|
31
|
+
}
|
|
32
|
+
// Standard Error.cause (ES2022)
|
|
33
|
+
const cause = obj.cause;
|
|
34
|
+
if (cause) {
|
|
35
|
+
if (cause instanceof Error) {
|
|
36
|
+
parts.push(cause.message);
|
|
37
|
+
const nested = extractErrorDetails(cause, depth + 1);
|
|
38
|
+
if (nested)
|
|
39
|
+
parts.push(nested);
|
|
40
|
+
}
|
|
41
|
+
else if (typeof cause === 'object') {
|
|
42
|
+
// Effect errors: check for message, _tag, or stringify
|
|
43
|
+
const c = cause;
|
|
44
|
+
if (c._tag)
|
|
45
|
+
parts.push(`[${c._tag}]`);
|
|
46
|
+
if (c.message && typeof c.message === 'string')
|
|
47
|
+
parts.push(c.message);
|
|
48
|
+
if (c.reason && typeof c.reason === 'string')
|
|
49
|
+
parts.push(c.reason);
|
|
50
|
+
const nested = extractErrorDetails(cause, depth + 1);
|
|
51
|
+
if (nested)
|
|
52
|
+
parts.push(nested);
|
|
53
|
+
// If nothing extracted, try JSON
|
|
54
|
+
if (parts.length === 0) {
|
|
55
|
+
try {
|
|
56
|
+
parts.push(JSON.stringify(cause).slice(0, 500));
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
/* skip */
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
parts.push(String(cause));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Some SDK errors use 'error' or 'reason' fields
|
|
68
|
+
if (obj.error && typeof obj.error === 'string')
|
|
69
|
+
parts.push(obj.error);
|
|
70
|
+
if (obj.reason && typeof obj.reason === 'string' && !parts.includes(obj.reason))
|
|
71
|
+
parts.push(obj.reason);
|
|
72
|
+
// Node/RPC errors often carry a numeric `code` and a `data` payload with the
|
|
73
|
+
// real rejection reason (e.g. a runtime/pool error). Capture them directly.
|
|
74
|
+
if (typeof obj.code === 'string' || typeof obj.code === 'number')
|
|
75
|
+
parts.push(`code=${obj.code}`);
|
|
76
|
+
if (obj.data !== undefined) {
|
|
77
|
+
const d = typeof obj.data === 'string' ? obj.data : safeJson(obj.data);
|
|
78
|
+
if (d)
|
|
79
|
+
parts.push(`data=${d}`);
|
|
80
|
+
}
|
|
81
|
+
// Last resort at the top level: dump own property names (captures
|
|
82
|
+
// non-enumerable Error fields and opaque SDK/RPC payloads the structured
|
|
83
|
+
// walk missed) so a generic "submission error" still yields a real reason.
|
|
84
|
+
if (depth === 0 && parts.length === 0) {
|
|
85
|
+
const raw = safeJson(Object.fromEntries(Object.getOwnPropertyNames(obj)
|
|
86
|
+
.filter((k) => k !== 'stack')
|
|
87
|
+
.map((k) => [k, obj[k]])));
|
|
88
|
+
if (raw && raw !== '{}')
|
|
89
|
+
parts.push(`raw=${raw.slice(0, 600)}`);
|
|
90
|
+
}
|
|
91
|
+
return parts.filter(Boolean).join(' — ');
|
|
92
|
+
}
|
|
93
|
+
function safeJson(value) {
|
|
94
|
+
try {
|
|
95
|
+
return JSON.stringify(value, (_k, v) => (typeof v === 'bigint' ? v.toString() : v)) ?? '';
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return '';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export async function deployContract(options) {
|
|
102
|
+
const { artifact, walletKeys, seedHex, network, syncedWallet, witnessPath: rawWitnessPath, projectDir, timeoutMs = 120_000, onProgress, args: constructorArgs = [], initialPrivateState = {}, } = options;
|
|
103
|
+
const witnessPath = rawWitnessPath?.trim();
|
|
104
|
+
const prover = resolveProverConfig(network);
|
|
105
|
+
await ensureProverReady(prover);
|
|
106
|
+
// Resolve SDK packages and handle WASM class identity mismatches (CWE-706).
|
|
107
|
+
// compact-js creates WASM objects (ContractMaintenanceAuthority, etc.) from our
|
|
108
|
+
// tree's onchain-runtime-v3, but the contract module validates them against the
|
|
109
|
+
// project's copy. Since WASM classes hold pointers into separate linear memories,
|
|
110
|
+
// we can't just bypass instanceof — we must serialize/deserialize across trees.
|
|
111
|
+
const projRoot = projectDir?.trim() || resolvePath(artifact.path, '..', '..');
|
|
112
|
+
const projRequire = createRequire(resolvePath(projRoot, 'node_modules', '_virtual.js'));
|
|
113
|
+
// Patch WASM class setters to bridge cross-tree identity mismatches (CWE-706).
|
|
114
|
+
// When compact-js (from our tree) creates WASM objects and assigns them to
|
|
115
|
+
// ContractState (from the project's tree), _assertClass fails because the
|
|
116
|
+
// classes come from different WASM instantiations with separate linear memories.
|
|
117
|
+
// We intercept setters to serialize incoming objects and deserialize them through
|
|
118
|
+
// the project's WASM module, converting pointers to the correct memory space.
|
|
119
|
+
const patchedProperties = [];
|
|
120
|
+
try {
|
|
121
|
+
const projRuntime = projRequire('@midnight-ntwrk/onchain-runtime-v3');
|
|
122
|
+
// Map: [HostPrototype, propertyName, ExpectedWASMClass]
|
|
123
|
+
// Only maintenanceAuthority crosses tree boundaries — setOperation receives
|
|
124
|
+
// objects from the same tree since they come from contractState.operation().
|
|
125
|
+
const settersToProxy = [
|
|
126
|
+
['ContractState', 'maintenanceAuthority', 'ContractMaintenanceAuthority'],
|
|
127
|
+
];
|
|
128
|
+
for (const [hostClass, prop, expectedClass] of settersToProxy) {
|
|
129
|
+
const proto = projRuntime[hostClass]?.prototype;
|
|
130
|
+
const ExpectedKlass = projRuntime[expectedClass];
|
|
131
|
+
if (!proto || !ExpectedKlass)
|
|
132
|
+
continue;
|
|
133
|
+
const desc = Object.getOwnPropertyDescriptor(proto, prop);
|
|
134
|
+
if (!desc?.set || !desc.configurable)
|
|
135
|
+
continue;
|
|
136
|
+
const origSetter = desc.set;
|
|
137
|
+
patchedProperties.push({ proto, prop, desc });
|
|
138
|
+
Object.defineProperty(proto, prop, {
|
|
139
|
+
get: desc.get,
|
|
140
|
+
set(value) {
|
|
141
|
+
if (value instanceof ExpectedKlass) {
|
|
142
|
+
return origSetter.call(this, value);
|
|
143
|
+
}
|
|
144
|
+
// Cross-tree: serialize → deserialize into project's WASM memory
|
|
145
|
+
if (typeof value?.serialize === 'function' && typeof ExpectedKlass.deserialize === 'function') {
|
|
146
|
+
const converted = ExpectedKlass.deserialize(value.serialize());
|
|
147
|
+
return origSetter.call(this, converted);
|
|
148
|
+
}
|
|
149
|
+
return origSetter.call(this, value);
|
|
150
|
+
},
|
|
151
|
+
configurable: true,
|
|
152
|
+
enumerable: desc.enumerable,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
// Project doesn't have onchain-runtime-v3 — no patching needed
|
|
158
|
+
}
|
|
159
|
+
let CompiledContract;
|
|
160
|
+
let sdkDeployContract;
|
|
161
|
+
try {
|
|
162
|
+
CompiledContract = projRequire('@midnight-ntwrk/compact-js').CompiledContract;
|
|
163
|
+
sdkDeployContract = projRequire('@midnight-ntwrk/midnight-js/contracts').deployContract;
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
const cjs = await import('@midnight-ntwrk/compact-js');
|
|
167
|
+
const contracts = await import('@midnight-ntwrk/midnight-js/contracts');
|
|
168
|
+
CompiledContract = cjs.CompiledContract;
|
|
169
|
+
sdkDeployContract = contracts.deployContract;
|
|
170
|
+
}
|
|
171
|
+
setNetworkId(network.id);
|
|
172
|
+
// Resolve typed key bundle: prefer pre-derived walletKeys (daemon
|
|
173
|
+
// path), fall back to deriving from seedHex (existing in-process
|
|
174
|
+
// CLI path). See docs/spec/wallet-service/05-key-management.md D-KM-3.
|
|
175
|
+
let shieldedSecretKeys;
|
|
176
|
+
let dustSecretKey;
|
|
177
|
+
let nightExternalKey;
|
|
178
|
+
if (walletKeys) {
|
|
179
|
+
shieldedSecretKeys = walletKeys.shieldedSecretKeys;
|
|
180
|
+
dustSecretKey = walletKeys.dustSecretKey;
|
|
181
|
+
nightExternalKey = walletKeys.nightExternalKey;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
if (!seedHex) {
|
|
185
|
+
throw new WalletError('WALLET_ERROR', 'deployContract requires either walletKeys or seedHex');
|
|
186
|
+
}
|
|
187
|
+
const hdWallet = HDWallet.fromSeed(Buffer.from(seedHex, 'hex'));
|
|
188
|
+
if (hdWallet.type !== 'seedOk')
|
|
189
|
+
throw new WalletError('WALLET_ERROR', 'Invalid seed');
|
|
190
|
+
const keyResult = hdWallet.hdWallet
|
|
191
|
+
.selectAccount(0)
|
|
192
|
+
.selectRoles([Roles.Zswap, Roles.NightExternal, Roles.Dust])
|
|
193
|
+
.deriveKeysAt(0);
|
|
194
|
+
if (keyResult.type !== 'keysDerived')
|
|
195
|
+
throw new WalletError('WALLET_ERROR', 'Key derivation failed');
|
|
196
|
+
hdWallet.hdWallet.clear();
|
|
197
|
+
shieldedSecretKeys = ledger.ZswapSecretKeys.fromSeed(keyResult.keys[Roles.Zswap]);
|
|
198
|
+
dustSecretKey = ledger.DustSecretKey.fromSeed(keyResult.keys[Roles.Dust]);
|
|
199
|
+
nightExternalKey = keyResult.keys[Roles.NightExternal];
|
|
200
|
+
}
|
|
201
|
+
const keystore = createKeystore(nightExternalKey, network.id);
|
|
202
|
+
// Build wallet provider from facade (same as mn-tui's buildWalletProvider)
|
|
203
|
+
if (!syncedWallet?.facade) {
|
|
204
|
+
throw new WalletError('WALLET_ERROR', 'Wallet must be synced before deploying. Unlock and wait for sync.');
|
|
205
|
+
}
|
|
206
|
+
const facade = syncedWallet.facade;
|
|
207
|
+
// Wait for isSynced, then wait for dust balance to stabilize.
|
|
208
|
+
// The facade can report isSynced before the dust wallet finishes reconciling
|
|
209
|
+
// its UTXO set from cache, causing balanceUnboundTransaction to fail.
|
|
210
|
+
const state = await Rx.firstValueFrom(facade.state().pipe(Rx.tap((() => {
|
|
211
|
+
let lastPct = -1;
|
|
212
|
+
return (s) => {
|
|
213
|
+
try {
|
|
214
|
+
const dp = s.dust?.progress;
|
|
215
|
+
if (dp && !dp.isStrictlyComplete?.()) {
|
|
216
|
+
const pct = dp.highestRelevantWalletIndex > 0n
|
|
217
|
+
? Math.round(Number((dp.appliedIndex * 100n) / dp.highestRelevantWalletIndex))
|
|
218
|
+
: 0;
|
|
219
|
+
if (pct !== lastPct) {
|
|
220
|
+
lastPct = pct;
|
|
221
|
+
onProgress?.(`Dust sync: ${pct}%`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch { }
|
|
226
|
+
};
|
|
227
|
+
})()), Rx.filter((s) => {
|
|
228
|
+
// Dust must be fully synced — InvalidDustSpendProof (error 170) if tree root is stale.
|
|
229
|
+
try {
|
|
230
|
+
const unDone = s.unshielded?.progress?.isStrictlyComplete?.() === true;
|
|
231
|
+
const dustDone = s.dust?.progress?.isStrictlyComplete?.() === true;
|
|
232
|
+
if (unDone && dustDone)
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
catch { }
|
|
236
|
+
return s.isSynced === true;
|
|
237
|
+
}),
|
|
238
|
+
// After isSynced, wait for two consecutive emissions with the same dust balance
|
|
239
|
+
Rx.bufferCount(2, 1), Rx.filter(([a, b]) => {
|
|
240
|
+
try {
|
|
241
|
+
const dustA = a.dust?.balance?.(new Date()) ?? 0n;
|
|
242
|
+
const dustB = b.dust?.balance?.(new Date()) ?? 0n;
|
|
243
|
+
return dustA === dustB;
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
return true;
|
|
247
|
+
} // If dust isn't available, don't block forever
|
|
248
|
+
}), Rx.map(([, b]) => b)));
|
|
249
|
+
const coinPublicKey = state.shielded.coinPublicKey.toHexString();
|
|
250
|
+
const encPublicKey = state.shielded.encryptionPublicKey.toHexString();
|
|
251
|
+
const unshieldedAddr = keystore.getBech32Address().toString();
|
|
252
|
+
const walletProvider = {
|
|
253
|
+
getCoinPublicKey: () => coinPublicKey,
|
|
254
|
+
getEncryptionPublicKey: () => encPublicKey,
|
|
255
|
+
async balanceTx(tx, ttl) {
|
|
256
|
+
const recipe = await facade.balanceUnboundTransaction(tx, { shieldedSecretKeys, dustSecretKey }, { ttl: ttl ?? new Date(Date.now() + 30 * 60_000) });
|
|
257
|
+
// Sign unshielded transaction intents
|
|
258
|
+
const signFn = (payload) => keystore.signData(payload);
|
|
259
|
+
signTransactionIntents(recipe.baseTransaction, signFn, 'proof');
|
|
260
|
+
if (recipe.balancingTransaction) {
|
|
261
|
+
signTransactionIntents(recipe.balancingTransaction, signFn, 'pre-proof');
|
|
262
|
+
}
|
|
263
|
+
return facade.finalizeRecipe(recipe);
|
|
264
|
+
},
|
|
265
|
+
submitTx: async (tx) => {
|
|
266
|
+
return facade.submitTransaction(tx);
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
// Build contract providers (same as mn-tui's buildContractProviders)
|
|
270
|
+
const managedDir = artifact.path;
|
|
271
|
+
const contractName = basename(managedDir);
|
|
272
|
+
const indexerHttpUrl = network.indexerUrl;
|
|
273
|
+
const indexerWsUrl = toWsUrl(indexerHttpUrl) + '/ws';
|
|
274
|
+
const zkCfgProvider = new NodeZkConfigProvider(managedDir);
|
|
275
|
+
const levelDbDir = join(homedir(), '.moth', 'level-db', network.id, encPublicKey.slice(0, 16));
|
|
276
|
+
const providers = {
|
|
277
|
+
privateStateProvider: levelPrivateStateProvider({
|
|
278
|
+
midnightDbName: levelDbDir,
|
|
279
|
+
privateStateStoreName: contractName + '-state',
|
|
280
|
+
privateStoragePasswordProvider: () => unshieldedAddr,
|
|
281
|
+
accountId: unshieldedAddr,
|
|
282
|
+
}),
|
|
283
|
+
publicDataProvider: indexerPublicDataProvider(indexerHttpUrl, indexerWsUrl),
|
|
284
|
+
zkConfigProvider: zkCfgProvider,
|
|
285
|
+
proofProvider: createProofProvider(prover, zkCfgProvider.asKeyMaterialProvider()),
|
|
286
|
+
walletProvider,
|
|
287
|
+
midnightProvider: walletProvider,
|
|
288
|
+
};
|
|
289
|
+
// Load contract module
|
|
290
|
+
const contractJs = join(managedDir, 'contract', 'index.js');
|
|
291
|
+
if (!existsSync(contractJs)) {
|
|
292
|
+
throw new WalletError('INVALID_INPUT', `No compiled contract at ${contractJs}`);
|
|
293
|
+
}
|
|
294
|
+
const contractModule = await import(pathToFileURL(contractJs).href);
|
|
295
|
+
// Build CompiledContract using the .pipe() pattern
|
|
296
|
+
let compiledContract;
|
|
297
|
+
if (witnessPath) {
|
|
298
|
+
const witMod = await import(pathToFileURL(witnessPath).href);
|
|
299
|
+
// Support multiple witness export patterns:
|
|
300
|
+
// 1. export default (walletProvider) => ({ localSecretKey: ... }) — factory function
|
|
301
|
+
// 2. export default { localSecretKey: ... } — plain object
|
|
302
|
+
// 3. export const witnesses = { localSecretKey: ... } — named export
|
|
303
|
+
let witnessObj;
|
|
304
|
+
if (typeof witMod.default === 'function') {
|
|
305
|
+
witnessObj = witMod.default(walletProvider);
|
|
306
|
+
}
|
|
307
|
+
else if (witMod.default && typeof witMod.default === 'object') {
|
|
308
|
+
witnessObj = witMod.default;
|
|
309
|
+
}
|
|
310
|
+
else if (witMod.witnesses && typeof witMod.witnesses === 'object') {
|
|
311
|
+
witnessObj = witMod.witnesses;
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
throw new WalletError('INVALID_INPUT', 'Witness file must export default (function or object) or a named "witnesses" export');
|
|
315
|
+
}
|
|
316
|
+
compiledContract = CompiledContract.make(contractName, contractModule.Contract).pipe(CompiledContract.withWitnesses(witnessObj), CompiledContract.withCompiledFileAssets(managedDir));
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
compiledContract = CompiledContract.make(contractName, contractModule.Contract).pipe(CompiledContract.withVacantWitnesses, CompiledContract.withCompiledFileAssets(managedDir));
|
|
320
|
+
}
|
|
321
|
+
onProgress?.('proving');
|
|
322
|
+
try {
|
|
323
|
+
const deployOptions = {
|
|
324
|
+
compiledContract,
|
|
325
|
+
privateStateId: contractName + 'State',
|
|
326
|
+
initialPrivateState,
|
|
327
|
+
};
|
|
328
|
+
// Only include `args` when the constructor actually takes arguments — the SDK's
|
|
329
|
+
// options type narrows to a variant without an `args` field for no-arg constructors.
|
|
330
|
+
if (constructorArgs.length > 0) {
|
|
331
|
+
deployOptions.args = constructorArgs;
|
|
332
|
+
}
|
|
333
|
+
const deployed = await sdkDeployContract(providers, deployOptions);
|
|
334
|
+
const contractAddress = deployed.deployTxData.public.contractAddress;
|
|
335
|
+
onProgress?.('deployed');
|
|
336
|
+
return {
|
|
337
|
+
hash: deployed.deployTxData?.public?.txId ?? '',
|
|
338
|
+
status: 'SUCCESS',
|
|
339
|
+
blockHash: deployed.deployTxData?.public?.blockHash ?? null,
|
|
340
|
+
blockHeight: deployed.deployTxData?.public?.blockHeight ?? null,
|
|
341
|
+
contractAddress,
|
|
342
|
+
fees: null,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
catch (err) {
|
|
346
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
347
|
+
// Surface the full error chain — SDK errors (Effect TaggedErrors, nested causes) bury details
|
|
348
|
+
const details = extractErrorDetails(err);
|
|
349
|
+
const detail = details ? `Deploy failed: ${msg} — ${details}` : `Deploy failed: ${msg}`;
|
|
350
|
+
const walletErr = new WalletError('WALLET_ERROR', detail);
|
|
351
|
+
if (err instanceof Error && err.stack)
|
|
352
|
+
walletErr.originalStack = err.stack;
|
|
353
|
+
throw walletErr;
|
|
354
|
+
}
|
|
355
|
+
finally {
|
|
356
|
+
// Restore original WASM setters
|
|
357
|
+
for (const { proto, prop, desc } of patchedProperties) {
|
|
358
|
+
try {
|
|
359
|
+
Object.defineProperty(proto, prop, desc);
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
/* best effort */
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
/** Sign unshielded transaction intents (same as mn-tui's signTransactionIntents) */
|
|
368
|
+
function signTransactionIntents(tx, signFn, proofMarker) {
|
|
369
|
+
if (!tx.intents || tx.intents.size === 0)
|
|
370
|
+
return;
|
|
371
|
+
for (const segment of tx.intents.keys()) {
|
|
372
|
+
const intent = tx.intents.get(segment);
|
|
373
|
+
if (!intent)
|
|
374
|
+
continue;
|
|
375
|
+
const cloned = ledger.Intent.deserialize('signature', proofMarker, 'pre-binding', intent.serialize());
|
|
376
|
+
const signature = signFn(cloned.signatureData(segment));
|
|
377
|
+
if (cloned.fallibleUnshieldedOffer) {
|
|
378
|
+
const sigs = cloned.fallibleUnshieldedOffer.inputs.map((_, i) => cloned.fallibleUnshieldedOffer.signatures.at(i) ?? signature);
|
|
379
|
+
cloned.fallibleUnshieldedOffer = cloned.fallibleUnshieldedOffer.addSignatures(sigs);
|
|
380
|
+
}
|
|
381
|
+
if (cloned.guaranteedUnshieldedOffer) {
|
|
382
|
+
const sigs = cloned.guaranteedUnshieldedOffer.inputs.map((_, i) => cloned.guaranteedUnshieldedOffer.signatures.at(i) ?? signature);
|
|
383
|
+
cloned.guaranteedUnshieldedOffer = cloned.guaranteedUnshieldedOffer.addSignatures(sigs);
|
|
384
|
+
}
|
|
385
|
+
tx.intents.set(segment, cloned);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
//# sourceMappingURL=deploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/contract/deploy.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,8EAA8E;AAE9E,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AAC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AAG,MAAM,CAAC,yBAAyB,CAAC,MAAM,CAAC,GAAG,CACtD,CAAC,CAAM,EAAE,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,yBAAyB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,CACtF,CAAC;YACF,MAAM,CAAC,yBAAyB,GAAG,MAAM,CAAC,yBAAyB,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC1F,CAAC;QACD,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { DerivedKeys, WalletKeys } from '../types/wallet.js';
|
|
2
|
+
import type { NetworkConfig } from '../types/network.js';
|
|
3
|
+
import type { TransactionResult } from '../types/transaction.js';
|
|
4
|
+
import type { SyncedWallet } from '../sync/wallet-sync.js';
|
|
5
|
+
/** Directory of the compiled moth-ft artifact bundled with this package. */
|
|
6
|
+
export declare const FUNGIBLE_TOKEN_ARTIFACT_DIR: string;
|
|
7
|
+
export interface DeployFungibleTokenOptions {
|
|
8
|
+
walletKeys: WalletKeys;
|
|
9
|
+
network: NetworkConfig;
|
|
10
|
+
syncedWallet: SyncedWallet;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
onProgress?: (stage: string) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Deploy the bundled fungible-token issuer contract. The returned
|
|
16
|
+
* `TransactionResult.contractAddress` is the address to mint against.
|
|
17
|
+
*/
|
|
18
|
+
export declare function deployFungibleToken(options: DeployFungibleTokenOptions): Promise<TransactionResult>;
|
|
19
|
+
export interface MintFungibleTokenOptions {
|
|
20
|
+
/** Address of a deployed moth-ft contract. */
|
|
21
|
+
contractAddress: string;
|
|
22
|
+
/**
|
|
23
|
+
* Bech32m recipient address. A shielded address (`mn_shield-addr…`) when
|
|
24
|
+
* `shielded` is true, otherwise an unshielded user address (`mn_addr…`).
|
|
25
|
+
*/
|
|
26
|
+
recipientAddress: string;
|
|
27
|
+
amount: bigint;
|
|
28
|
+
shielded: boolean;
|
|
29
|
+
keys: DerivedKeys;
|
|
30
|
+
walletKeys: WalletKeys;
|
|
31
|
+
network: NetworkConfig;
|
|
32
|
+
syncedWallet: SyncedWallet;
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Mint `amount` ledger tokens of a deployed moth-ft contract to `recipientAddress`.
|
|
37
|
+
* Calls `mintShielded` or `mintUnshielded` depending on `shielded`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function mintFungibleToken(options: MintFungibleTokenOptions): Promise<TransactionResult>;
|
|
40
|
+
//# sourceMappingURL=fungible-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fungible-token.d.ts","sourceRoot":"","sources":["../../src/contract/fungible-token.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI3D,4EAA4E;AAC5E,eAAO,MAAM,2BAA2B,QAAmD,CAAC;AAO5F,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,aAAa,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAWzG;AAED,MAAM,WAAW,wBAAwB;IACvC,8CAA8C;IAC9C,eAAe,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,aAAa,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAoBrG"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Bundled minimal fungible-token issuer (moth-ft).
|
|
2
|
+
//
|
|
3
|
+
// Lets the wallet auto-deploy a token contract and mint ledger tokens (shielded
|
|
4
|
+
// or unshielded) to a target recipient without the user supplying a compiled
|
|
5
|
+
// artifact. The compiled artifact ships in this package at
|
|
6
|
+
// `contracts/moth-ft/managed` and is resolved relative to this module so it
|
|
7
|
+
// works from both `src` (tsx/vitest) and `dist` (published) layouts.
|
|
8
|
+
//
|
|
9
|
+
// The contract exposes two circuits (see contracts/moth-ft/moth-ft.compact):
|
|
10
|
+
// mintShielded(recipient: { bytes }, value: bigint) -> ShieldedCoinInfo
|
|
11
|
+
// mintUnshielded(recipient: { bytes }, value: bigint) -> token color bytes
|
|
12
|
+
// It has no witnesses, no constructor args, and initial private state `{}`.
|
|
13
|
+
import { fileURLToPath } from 'node:url';
|
|
14
|
+
import { dirname, resolve } from 'node:path';
|
|
15
|
+
import { MidnightBech32m, ShieldedAddress, UnshieldedAddress, } from '@midnightntwrk/wallet-sdk/address-format';
|
|
16
|
+
import { setNetworkId } from '@midnight-ntwrk/midnight-js/network-id';
|
|
17
|
+
import { loadContractArtifact } from './artifact-loader.js';
|
|
18
|
+
import { deployContract } from './deploy.js';
|
|
19
|
+
import { callCircuit } from './call.js';
|
|
20
|
+
import { InvalidInputError } from '../types/errors.js';
|
|
21
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
/** Directory of the compiled moth-ft artifact bundled with this package. */
|
|
23
|
+
export const FUNGIBLE_TOKEN_ARTIFACT_DIR = resolve(HERE, '../../contracts/moth-ft/managed');
|
|
24
|
+
// Resolve the SDK's onchain-runtime from this package's tree so the WASM class
|
|
25
|
+
// identities line up with the bundled artifact (see the CWE-706 handling in
|
|
26
|
+
// deploy.ts). The package root is two levels up from src/contract or dist/contract.
|
|
27
|
+
const FUNGIBLE_TOKEN_PROJECT_DIR = resolve(HERE, '../..');
|
|
28
|
+
/**
|
|
29
|
+
* Deploy the bundled fungible-token issuer contract. The returned
|
|
30
|
+
* `TransactionResult.contractAddress` is the address to mint against.
|
|
31
|
+
*/
|
|
32
|
+
export async function deployFungibleToken(options) {
|
|
33
|
+
const artifact = await loadContractArtifact(FUNGIBLE_TOKEN_ARTIFACT_DIR);
|
|
34
|
+
return deployContract({
|
|
35
|
+
artifact,
|
|
36
|
+
walletKeys: options.walletKeys,
|
|
37
|
+
network: options.network,
|
|
38
|
+
syncedWallet: options.syncedWallet,
|
|
39
|
+
projectDir: FUNGIBLE_TOKEN_PROJECT_DIR,
|
|
40
|
+
timeoutMs: options.timeoutMs,
|
|
41
|
+
onProgress: options.onProgress,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Mint `amount` ledger tokens of a deployed moth-ft contract to `recipientAddress`.
|
|
46
|
+
* Calls `mintShielded` or `mintUnshielded` depending on `shielded`.
|
|
47
|
+
*/
|
|
48
|
+
export async function mintFungibleToken(options) {
|
|
49
|
+
const { contractAddress, recipientAddress, amount, shielded, network } = options;
|
|
50
|
+
setNetworkId(network.id);
|
|
51
|
+
const recipient = shielded
|
|
52
|
+
? decodeShieldedRecipient(recipientAddress, network.id)
|
|
53
|
+
: decodeUnshieldedRecipient(recipientAddress, network.id);
|
|
54
|
+
return callCircuit({
|
|
55
|
+
contractAddress,
|
|
56
|
+
circuitName: shielded ? 'mintShielded' : 'mintUnshielded',
|
|
57
|
+
args: [recipient, amount],
|
|
58
|
+
keys: options.keys,
|
|
59
|
+
walletKeys: options.walletKeys,
|
|
60
|
+
network,
|
|
61
|
+
artifactPath: FUNGIBLE_TOKEN_ARTIFACT_DIR,
|
|
62
|
+
syncedWallet: options.syncedWallet,
|
|
63
|
+
projectDir: FUNGIBLE_TOKEN_PROJECT_DIR,
|
|
64
|
+
timeoutMs: options.timeoutMs,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// Decode a shielded bech32m address to the contract's `{ bytes }` recipient arg
|
|
68
|
+
// (the zswap coin public key). Field access mirrors the execution-verified path.
|
|
69
|
+
function decodeShieldedRecipient(address, networkId) {
|
|
70
|
+
try {
|
|
71
|
+
const decoded = MidnightBech32m.parse(address).decode(ShieldedAddress, networkId);
|
|
72
|
+
return { bytes: new Uint8Array(decoded.coinPublicKey.data) };
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
throw new InvalidInputError(`Invalid shielded recipient address for minting (expected mn_shield-addr…): ${err instanceof Error ? err.message : String(err)}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Decode an unshielded bech32m user address to the contract's `{ bytes }` recipient arg.
|
|
79
|
+
function decodeUnshieldedRecipient(address, networkId) {
|
|
80
|
+
try {
|
|
81
|
+
const decoded = MidnightBech32m.parse(address).decode(UnshieldedAddress, networkId);
|
|
82
|
+
return { bytes: new Uint8Array(decoded.data) };
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
throw new InvalidInputError(`Invalid unshielded recipient address for minting (expected mn_addr…): ${err instanceof Error ? err.message : String(err)}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=fungible-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fungible-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AC,EAAE,CAAC;IAC5G,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,iBAAiB,CACzB,8EAA8E,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACjI,CAAC;IACJ,CAAC;AACH,CAAC;AAED,yFAAyF;AACzF,SAAS,yBAAyB,CAAC,OAAe,EAAE,SAAiB;IACnE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,iBAAiB,EAAE,SAAkB,CAAC,CAAC;QAC7F,OAAO,EAAE,KAAK,EAAE,IAAI,UAAU,CAAE,OAAgC,CAAC,IAAI,CAAC,EAAE,CAAC;IAC3E,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,iBAAiB,CACzB,yEAAyE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAC5H,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ResolveInitialPrivateStateOptions {
|
|
2
|
+
/** Optional verbose logger for surfacing which private-state source was used. */
|
|
3
|
+
onVerbose?: (message: string) => void;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Resolve the initial private state to run a contract's constructor against.
|
|
7
|
+
*
|
|
8
|
+
* Precedence (first match wins):
|
|
9
|
+
* 1. `privateStateFlag` — JSON or @file.json, parsed with the same convention as `--args`
|
|
10
|
+
* 2. the witness module's zero-arg `makeInitialPrivateState()` factory, if exported
|
|
11
|
+
* 3. the witness module's plain `initialPrivateState` export, if present
|
|
12
|
+
* 4. `{}` (preserves the no-private-state default)
|
|
13
|
+
*
|
|
14
|
+
* @param privateStateFlag Raw value of the `--private-state` flag (JSON or `@file.json`).
|
|
15
|
+
* @param witnessPath Absolute path to the witness JS module, if `--witnesses` was given.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveInitialPrivateState(privateStateFlag: string | undefined, witnessPath: string | undefined, options?: ResolveInitialPrivateStateOptions): Promise<unknown>;
|
|
18
|
+
//# sourceMappingURL=initial-private-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initial-private-state.d.ts","sourceRoot":"","sources":["../../src/contract/initial-private-state.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iCAAiC;IAChD,iFAAiF;IACjF,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,0BAA0B,CAC9C,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,OAAO,GAAE,iCAAsC,GAC9C,OAAO,CAAC,OAAO,CAAC,CAmClB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { pathToFileURL } from 'node:url';
|
|
2
|
+
import { parseArgs } from './args-parser.js';
|
|
3
|
+
import { InvalidInputError } from '../types/errors.js';
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the initial private state to run a contract's constructor against.
|
|
6
|
+
*
|
|
7
|
+
* Precedence (first match wins):
|
|
8
|
+
* 1. `privateStateFlag` — JSON or @file.json, parsed with the same convention as `--args`
|
|
9
|
+
* 2. the witness module's zero-arg `makeInitialPrivateState()` factory, if exported
|
|
10
|
+
* 3. the witness module's plain `initialPrivateState` export, if present
|
|
11
|
+
* 4. `{}` (preserves the no-private-state default)
|
|
12
|
+
*
|
|
13
|
+
* @param privateStateFlag Raw value of the `--private-state` flag (JSON or `@file.json`).
|
|
14
|
+
* @param witnessPath Absolute path to the witness JS module, if `--witnesses` was given.
|
|
15
|
+
*/
|
|
16
|
+
export async function resolveInitialPrivateState(privateStateFlag, witnessPath, options = {}) {
|
|
17
|
+
if (privateStateFlag) {
|
|
18
|
+
return parseArgs(privateStateFlag);
|
|
19
|
+
}
|
|
20
|
+
if (!witnessPath) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
let witnessModule;
|
|
24
|
+
try {
|
|
25
|
+
witnessModule = (await import(pathToFileURL(witnessPath).href));
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
throw new InvalidInputError(`Failed to load witness module at ${witnessPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
29
|
+
}
|
|
30
|
+
const makeInitialPrivateState = witnessModule.makeInitialPrivateState;
|
|
31
|
+
if (makeInitialPrivateState !== undefined) {
|
|
32
|
+
if (typeof makeInitialPrivateState !== 'function') {
|
|
33
|
+
throw new InvalidInputError(`Witness module ${witnessPath} exports "makeInitialPrivateState" but it is not a function.`);
|
|
34
|
+
}
|
|
35
|
+
options.onVerbose?.('Using initial private state from witness module makeInitialPrivateState()');
|
|
36
|
+
return makeInitialPrivateState();
|
|
37
|
+
}
|
|
38
|
+
if (witnessModule.initialPrivateState !== undefined) {
|
|
39
|
+
options.onVerbose?.('Using initial private state from witness module initialPrivateState export');
|
|
40
|
+
return witnessModule.initialPrivateState;
|
|
41
|
+
}
|
|
42
|
+
return {};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=initial-private-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initial-private-state.js","sourceRoot":"","sources":["../../src/contract/initial-private-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAOvD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,gBAAoC,EACpC,WAA+B,EAC/B,UAA6C,EAAE;IAE/C,I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