@sig-net/midnight-contract-deploy 0.18.0 → 0.20.0-rc.1
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/dist/deploy-signet-contract.d.ts +1 -1
- package/dist/deploy-signet-contract.d.ts.map +1 -1
- package/dist/deploy-signet-contract.js +1 -1
- package/dist/deploy-signet-contract.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/plumbing/deploy.d.ts +6 -5
- package/dist/plumbing/deploy.d.ts.map +1 -1
- package/dist/plumbing/deploy.js +18 -14
- package/dist/plumbing/deploy.js.map +1 -1
- package/dist/plumbing/env.d.ts +21 -0
- package/dist/plumbing/env.d.ts.map +1 -0
- package/dist/plumbing/env.js +31 -0
- package/dist/plumbing/env.js.map +1 -0
- package/dist/plumbing/funding.d.ts +12 -3
- package/dist/plumbing/funding.d.ts.map +1 -1
- package/dist/plumbing/funding.js +20 -6
- package/dist/plumbing/funding.js.map +1 -1
- package/dist/plumbing/midnight-node-config.d.ts +11 -1
- package/dist/plumbing/midnight-node-config.d.ts.map +1 -1
- package/dist/plumbing/midnight-node-config.js +25 -10
- package/dist/plumbing/midnight-node-config.js.map +1 -1
- package/dist/plumbing/network-id.d.ts +1 -0
- package/dist/plumbing/network-id.d.ts.map +1 -1
- package/dist/plumbing/network-id.js +3 -1
- package/dist/plumbing/network-id.js.map +1 -1
- package/dist/plumbing/seed.d.ts +13 -2
- package/dist/plumbing/seed.d.ts.map +1 -1
- package/dist/plumbing/seed.js +27 -8
- package/dist/plumbing/seed.js.map +1 -1
- package/dist/plumbing/wallet.d.ts +24 -8
- package/dist/plumbing/wallet.d.ts.map +1 -1
- package/dist/plumbing/wallet.js +28 -12
- package/dist/plumbing/wallet.js.map +1 -1
- package/dist/signet-contract-binding.d.ts +1 -0
- package/dist/signet-contract-binding.d.ts.map +1 -1
- package/dist/signet-contract-binding.js +1 -0
- package/dist/signet-contract-binding.js.map +1 -1
- package/package.json +8 -7
|
@@ -15,7 +15,7 @@ export interface SignetContractDeployment {
|
|
|
15
15
|
* @param env - Environment map providing `DEPLOYER_SEED` and the shared
|
|
16
16
|
* Midnight node configuration (see `getMidnightNodeConfig`).
|
|
17
17
|
* @returns The deployed contract address and deploy transaction id.
|
|
18
|
-
* @throws If the deployer wallet holds no funds or submission fails.
|
|
18
|
+
* @throws {Error} If the deployer wallet holds no funds or submission fails.
|
|
19
19
|
*/
|
|
20
20
|
export declare function deploySignetContract(env?: Record<string, string | undefined>): Promise<SignetContractDeployment>;
|
|
21
21
|
//# sourceMappingURL=deploy-signet-contract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-signet-contract.d.ts","sourceRoot":"","sources":["../src/deploy-signet-contract.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"deploy-signet-contract.d.ts","sourceRoot":"","sources":["../src/deploy-signet-contract.ts"],"names":[],"mappings":"AAaA,OAAO,EAGL,KAAK,qBAAqB,EAE3B,MAAM,sBAAsB,CAAC;AAM9B,8DAA8D;AAC9D,MAAM,WAAW,wBAAwB;IACvC,2DAA2D;IAC3D,eAAe,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,IAAI,EAAE,qBAAqB,CAAC;CAC7B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,OAAO,CAAC,wBAAwB,CAAC,CAqCnC"}
|
|
@@ -17,7 +17,7 @@ import { createSignetContractPrivateState, signetContractCompiledContract, } fro
|
|
|
17
17
|
* @param env - Environment map providing `DEPLOYER_SEED` and the shared
|
|
18
18
|
* Midnight node configuration (see `getMidnightNodeConfig`).
|
|
19
19
|
* @returns The deployed contract address and deploy transaction id.
|
|
20
|
-
* @throws If the deployer wallet holds no funds or submission fails.
|
|
20
|
+
* @throws {Error} If the deployer wallet holds no funds or submission fails.
|
|
21
21
|
*/
|
|
22
22
|
export async function deploySignetContract(env = process.env) {
|
|
23
23
|
const deployConfig = getDeployConfig(env);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-signet-contract.js","sourceRoot":"","sources":["../src/deploy-signet-contract.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,0EAA0E;AAC1E,0EAA0E;AAC1E,uEAAuE;AACvE,mEAAmE;AACnE,sEAAsE;AACtE,6DAA6D;AAE7D,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iBAAiB,EACjB,yBAAyB,
|
|
1
|
+
{"version":3,"file":"deploy-signet-contract.js","sourceRoot":"","sources":["../src/deploy-signet-contract.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,0EAA0E;AAC1E,0EAA0E;AAC1E,uEAAuE;AACvE,mEAAmE;AACnE,sEAAsE;AACtE,6DAA6D;AAE7D,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EAEzB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,gCAAgC,EAChC,8BAA8B,GAC/B,MAAM,8BAA8B,CAAC;AAUtC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,GAAG,GAAuC,OAAO,CAAC,GAAG;IAErD,MAAM,YAAY,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,EAAE,SAAS,EAAE,GAAG,YAAY,CAAC,kBAAkB,CAAC;IAEtD,MAAM,WAAW,GAAG,iBAAiB,CAAC,YAAY,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IAE5E,OAAO,CAAC,GAAG,CACT,gCAAgC,SAAS,KAAK,YAAY,CAAC,kBAAkB,CAAC,OAAO,GAAG,CACzF,CAAC;IAEF,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,MAAM,sBAAsB,CAC5D,WAAW,EACX,YAAY,CAAC,kBAAkB,EAC/B,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;QACtB,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAE5B,MAAM,iBAAiB,GAAG,MAAM,sBAAsB,CACpD,8BAA8B,EAC9B,SAAS,EACT,WAAW,CAAC,kBAAkB,CAAC,aAAa,EAC5C,gCAAgC,EAAE,CACnC,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,kCAAkC,iBAAiB,CAAC,eAAe,EAAE,CAAC,CAAC;QAEnF,MAAM,aAAa,GAAG,MAAM,yBAAyB,CACnD,MAAM,EACN,WAAW,EACX,iBAAiB,CAAC,qBAAqB,CACxC,CAAC;QACF,OAAO,EAAE,eAAe,EAAE,iBAAiB,CAAC,eAAe,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;IACrF,CAAC,CACF,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,CAAC,+BAA+B,eAAe,EAAE,CAAC,CAAC;IAE9D,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;AACnC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export * from "./deploy-signet-contract.ts";
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./plumbing/
|
|
2
|
+
export * from "./plumbing/deploy.ts";
|
|
3
|
+
export * from "./plumbing/env.ts";
|
|
4
|
+
export * from "./plumbing/funding.ts";
|
|
4
5
|
export * from "./plumbing/midnight-node-config.ts";
|
|
6
|
+
export * from "./plumbing/network-id.ts";
|
|
5
7
|
export * from "./plumbing/seed.ts";
|
|
6
8
|
export * from "./plumbing/wallet.ts";
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./plumbing/funding.ts";
|
|
9
|
+
export * from "./signet-contract-binding.ts";
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
// build/submit) the flow is built from. The plumbing is generic on purpose —
|
|
6
6
|
// any contract package's deploy script composes it.
|
|
7
7
|
export * from "./deploy-signet-contract.js";
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./plumbing/
|
|
8
|
+
export * from "./plumbing/deploy.js";
|
|
9
|
+
export * from "./plumbing/env.js";
|
|
10
|
+
export * from "./plumbing/funding.js";
|
|
10
11
|
export * from "./plumbing/midnight-node-config.js";
|
|
12
|
+
export * from "./plumbing/network-id.js";
|
|
11
13
|
export * from "./plumbing/seed.js";
|
|
12
14
|
export * from "./plumbing/wallet.js";
|
|
13
|
-
export * from "./
|
|
14
|
-
export * from "./plumbing/funding.js";
|
|
15
|
+
export * from "./signet-contract-binding.js";
|
|
15
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,2EAA2E;AAC3E,0EAA0E;AAC1E,oEAAoE;AACpE,6EAA6E;AAC7E,oDAAoD;AAEpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,2EAA2E;AAC3E,0EAA0E;AAC1E,oEAAoE;AACpE,6EAA6E;AAC7E,oDAAoD;AAEpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CompiledContract, Contract } from "@midnight-ntwrk/compact-js/effect";
|
|
1
|
+
import { CompiledContract, type Contract } from "@midnight-ntwrk/compact-js/effect";
|
|
2
2
|
import type { FacadeState } from "@midnightntwrk/wallet-sdk-facade";
|
|
3
3
|
import { type Types } from "effect";
|
|
4
4
|
import { type MidnightNodeConfig } from "./midnight-node-config.ts";
|
|
@@ -10,6 +10,7 @@ export interface DeployConfig {
|
|
|
10
10
|
/** Seed (hex or mnemonic) of the wallet that funds & signs the deploy. */
|
|
11
11
|
readonly deployerSeed: string;
|
|
12
12
|
}
|
|
13
|
+
/** Seed of the local standalone stack's pre-funded genesis mint wallet. */
|
|
13
14
|
export declare const GENESIS_MINT_WALLET_SEED = "0000000000000000000000000000000000000000000000000000000000000001";
|
|
14
15
|
/**
|
|
15
16
|
* Read a {@link DeployConfig} from the environment. Node config comes from
|
|
@@ -19,7 +20,7 @@ export declare const GENESIS_MINT_WALLET_SEED = "0000000000000000000000000000000
|
|
|
19
20
|
*
|
|
20
21
|
* @param env - The environment to read from; defaults to `process.env`.
|
|
21
22
|
* @returns The resolved deploy configuration.
|
|
22
|
-
* @throws If a deployed network lacks a valid funded `DEPLOYER_SEED` (see
|
|
23
|
+
* @throws {Error} If a deployed network lacks a valid funded `DEPLOYER_SEED` (see
|
|
23
24
|
* {@link resolveDeployerSeed}).
|
|
24
25
|
*/
|
|
25
26
|
export declare function getDeployConfig(env?: Record<string, string | undefined>): DeployConfig;
|
|
@@ -66,7 +67,7 @@ export declare function makeVacantCompiledContract<C extends Contract.Contract<P
|
|
|
66
67
|
*
|
|
67
68
|
* @param contractAddress - The 32-byte contract address in hex.
|
|
68
69
|
* @returns The `{ bytes }` reference.
|
|
69
|
-
* @throws If the address is not 32 bytes of hex.
|
|
70
|
+
* @throws {Error} If the address is not 32 bytes of hex.
|
|
70
71
|
*/
|
|
71
72
|
export declare function contractAddressToReference(contractAddress: string): {
|
|
72
73
|
bytes: Uint8Array;
|
|
@@ -84,7 +85,7 @@ export declare function contractAddressToReference(contractAddress: string): {
|
|
|
84
85
|
* @param initialPrivateState - The private state the constructor (and its witnesses, if any) runs against.
|
|
85
86
|
* @param constructorArgs - The contract's constructor arguments, statically typed per contract.
|
|
86
87
|
* @returns The deterministic contract address plus the serialized unproven transaction.
|
|
87
|
-
* @throws If the constructor traps, or the verifier keys are missing from the
|
|
88
|
+
* @throws {Error} If the constructor traps, or the verifier keys are missing from the
|
|
88
89
|
* compiled assets (run `compile:zk` — the default `--skip-zk` output has none).
|
|
89
90
|
*/
|
|
90
91
|
export declare function buildDeployTransaction<C extends Contract.Contract<PS>, PS>(compiledContract: CompiledContract.CompiledContract<C, PS>, networkId: NetworkId, coinPublicKeyHex: string, initialPrivateState: PS, ...constructorArgs: Contract.Contract.InitializeParameters<C>): Promise<DeployTransaction>;
|
|
@@ -93,7 +94,7 @@ export declare function buildDeployTransaction<C extends Contract.Contract<PS>,
|
|
|
93
94
|
* paid in DUST, which only generates on NIGHT registered for dust generation.
|
|
94
95
|
*
|
|
95
96
|
* @param state - The synced facade state to inspect (see `withSyncedWalletFacade` in wallet.ts).
|
|
96
|
-
* @throws If the deployer's spendable DUST balance is zero.
|
|
97
|
+
* @throws {Error} If the deployer's spendable DUST balance is zero.
|
|
97
98
|
*/
|
|
98
99
|
export declare function assertDeployerFunded(state: FacadeState): void;
|
|
99
100
|
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/plumbing/deploy.ts"],"names":[],"mappings":"AAQA,OAAO,
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/plumbing/deploy.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,gBAAgB,EAChB,KAAK,QAAQ,EAEd,MAAM,mCAAmC,CAAC;AAK3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAG3D,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAA4B,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE3E,2GAA2G;AAC3G,MAAM,WAAW,YAAY;IAC3B,iFAAiF;IACjF,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAChD,0EAA0E;IAC1E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAID,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,qEAC+B,CAAC;AAgDrE;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,YAAY,CAMd;AAED,gGAAgG;AAChG,MAAM,WAAW,iBAAiB;IAChC,iFAAiF;IACjF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,0FAA0F;IAC1F,QAAQ,CAAC,qBAAqB,EAAE,U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AQ7D"}
|
package/dist/plumbing/deploy.js
CHANGED
|
@@ -5,16 +5,18 @@
|
|
|
5
5
|
// implementations, initial private state — stays in the contract package's own
|
|
6
6
|
// deploy.ts and arrives here through the type parameters.
|
|
7
7
|
import { NodeContext } from "@effect/platform-node";
|
|
8
|
-
import { CompiledContract,
|
|
8
|
+
import { CompiledContract, ContractExecutable, } from "@midnight-ntwrk/compact-js/effect";
|
|
9
9
|
import { ZKFileConfiguration } from "@midnight-ntwrk/compact-js-node/effect";
|
|
10
|
-
import * as ledger from "@midnightntwrk/ledger-v9";
|
|
11
|
-
import * as Configuration from "@midnight-ntwrk/platform-js/effect/Configuration";
|
|
12
10
|
import * as CoinPublicKey from "@midnight-ntwrk/platform-js/effect/CoinPublicKey";
|
|
11
|
+
import * as Configuration from "@midnight-ntwrk/platform-js/effect/Configuration";
|
|
12
|
+
import * as ledger from "@midnightntwrk/ledger-v9";
|
|
13
13
|
import { Effect, Layer, Option } from "effect";
|
|
14
|
-
import {
|
|
14
|
+
import { envOrUndefined } from "./env.js";
|
|
15
|
+
import { getFaucetUrl, getMidnightNodeConfig, } from "./midnight-node-config.js";
|
|
15
16
|
import { isLocalStandaloneNetwork } from "./network-id.js";
|
|
16
17
|
// Pre-funded genesis wallet of the local standalone stack — the default
|
|
17
18
|
// deployer for development, and the ONLY network where it holds funds.
|
|
19
|
+
/** Seed of the local standalone stack's pre-funded genesis mint wallet. */
|
|
18
20
|
export const GENESIS_MINT_WALLET_SEED = "0000000000000000000000000000000000000000000000000000000000000001";
|
|
19
21
|
// True when `seed` is the genesis mint seed in hex form (0x-optional,
|
|
20
22
|
// case-insensitive). A mnemonic never matches. Used to reject the genesis
|
|
@@ -31,17 +33,19 @@ function isGenesisSeed(seed) {
|
|
|
31
33
|
* @param env - The environment to read `DEPLOYER_SEED` from.
|
|
32
34
|
* @param networkId - The network the deploy targets.
|
|
33
35
|
* @returns The seed (hex or mnemonic) that funds & signs deploys.
|
|
34
|
-
* @throws If a deployed network has no `DEPLOYER_SEED`, or it is set to the
|
|
36
|
+
* @throws {Error} If a deployed network has no `DEPLOYER_SEED`, or it is set to the
|
|
35
37
|
* (unfunded-here) genesis mint seed.
|
|
36
38
|
*/
|
|
37
39
|
function resolveDeployerSeed(env, networkId) {
|
|
38
|
-
const provided = env
|
|
40
|
+
const provided = envOrUndefined(env, "DEPLOYER_SEED");
|
|
39
41
|
if (isLocalStandaloneNetwork(networkId)) {
|
|
40
|
-
return provided
|
|
42
|
+
return provided ?? GENESIS_MINT_WALLET_SEED;
|
|
41
43
|
}
|
|
42
44
|
const faucet = getFaucetUrl(env, networkId);
|
|
43
|
-
const fundHint = faucet
|
|
44
|
-
|
|
45
|
+
const fundHint = faucet
|
|
46
|
+
? `fund a wallet via ${faucet}`
|
|
47
|
+
: "fund a wallet via the network's faucet";
|
|
48
|
+
if (provided === undefined) {
|
|
45
49
|
throw new Error(`DEPLOYER_SEED is required on "${networkId}": the genesis mint seed only holds funds on the local ` +
|
|
46
50
|
`standalone chain. Set DEPLOYER_SEED (hex or mnemonic) to a funded wallet: ${fundHint}.`);
|
|
47
51
|
}
|
|
@@ -59,7 +63,7 @@ function resolveDeployerSeed(env, networkId) {
|
|
|
59
63
|
*
|
|
60
64
|
* @param env - The environment to read from; defaults to `process.env`.
|
|
61
65
|
* @returns The resolved deploy configuration.
|
|
62
|
-
* @throws If a deployed network lacks a valid funded `DEPLOYER_SEED` (see
|
|
66
|
+
* @throws {Error} If a deployed network lacks a valid funded `DEPLOYER_SEED` (see
|
|
63
67
|
* {@link resolveDeployerSeed}).
|
|
64
68
|
*/
|
|
65
69
|
export function getDeployConfig(env = process.env) {
|
|
@@ -113,7 +117,7 @@ export function makeVacantCompiledContract(tag, ctor, managedDirPath) {
|
|
|
113
117
|
*
|
|
114
118
|
* @param contractAddress - The 32-byte contract address in hex.
|
|
115
119
|
* @returns The `{ bytes }` reference.
|
|
116
|
-
* @throws If the address is not 32 bytes of hex.
|
|
120
|
+
* @throws {Error} If the address is not 32 bytes of hex.
|
|
117
121
|
*/
|
|
118
122
|
export function contractAddressToReference(contractAddress) {
|
|
119
123
|
const hex = contractAddress.startsWith("0x") ? contractAddress.slice(2) : contractAddress;
|
|
@@ -141,7 +145,7 @@ const DEPLOY_TTL_MS = 30 * 60 * 1000;
|
|
|
141
145
|
* @param initialPrivateState - The private state the constructor (and its witnesses, if any) runs against.
|
|
142
146
|
* @param constructorArgs - The contract's constructor arguments, statically typed per contract.
|
|
143
147
|
* @returns The deterministic contract address plus the serialized unproven transaction.
|
|
144
|
-
* @throws If the constructor traps, or the verifier keys are missing from the
|
|
148
|
+
* @throws {Error} If the constructor traps, or the verifier keys are missing from the
|
|
145
149
|
* compiled assets (run `compile:zk` — the default `--skip-zk` output has none).
|
|
146
150
|
*/
|
|
147
151
|
export async function buildDeployTransaction(compiledContract, networkId, coinPublicKeyHex, initialPrivateState, ...constructorArgs) {
|
|
@@ -173,14 +177,14 @@ export async function buildDeployTransaction(compiledContract, networkId, coinPu
|
|
|
173
177
|
* paid in DUST, which only generates on NIGHT registered for dust generation.
|
|
174
178
|
*
|
|
175
179
|
* @param state - The synced facade state to inspect (see `withSyncedWalletFacade` in wallet.ts).
|
|
176
|
-
* @throws If the deployer's spendable DUST balance is zero.
|
|
180
|
+
* @throws {Error} If the deployer's spendable DUST balance is zero.
|
|
177
181
|
*/
|
|
178
182
|
export function assertDeployerFunded(state) {
|
|
179
183
|
const dust = state.dust.balance(new Date());
|
|
180
184
|
if (dust > 0n)
|
|
181
185
|
return;
|
|
182
186
|
const night = Object.values(state.unshielded.balances).reduce((sum, value) => sum + value, 0n);
|
|
183
|
-
throw new Error(`deployer wallet has no DUST to pay fees (NIGHT balance: ${night}). ` +
|
|
187
|
+
throw new Error(`deployer wallet has no DUST to pay fees (NIGHT balance: ${String(night)}). ` +
|
|
184
188
|
"Fund the wallet with NIGHT and register it for dust generation, then retry.");
|
|
185
189
|
}
|
|
186
190
|
//# sourceMappingURL=deploy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/plumbing/deploy.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,yEAAyE;AACzE,0EAA0E;AAC1E,+EAA+E;AAC/E,+EAA+E;AAC/E,0DAA0D;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/plumbing/deploy.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,yEAAyE;AACzE,0EAA0E;AAC1E,+EAA+E;AAC/E,+EAA+E;AAC/E,0DAA0D;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,gBAAgB,EAEhB,kBAAkB,GACnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,KAAK,aAAa,MAAM,kDAAkD,CAAC;AAClF,OAAO,KAAK,aAAa,MAAM,kDAAkD,CAAC;AAClF,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EACL,YAAY,EACZ,qBAAqB,GAEtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAkB,MAAM,iBAAiB,CAAC;AAU3E,wEAAwE;AACxE,uEAAuE;AACvE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,wBAAwB,GACnC,kEAAkE,CAAC;AAErE,sEAAsE;AACtE,0EAA0E;AAC1E,oDAAoD;AACpD,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,WAAW,EA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,CAAC;IACzF,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,mBAAmB,CACxD,SAAS,EACT,SAAS,EACT,SAAS,EACT,MAAM,CACP,CAAC;IAEF,OAAO;QACL,eAAe,EAAE,MAAM,CAAC,OAAO;QAC/B,qBAAqB,EAAE,WAAW,CAAC,SAAS,EAAE;KAC/C,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAkB;IACrD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAC5C,IAAI,IAAI,GAAG,EAAE;QAAE,OAAO;IACtB,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/F,MAAM,IAAI,KAAK,CACb,2DAA2D,MAAM,CAAC,KAAK,CAAC,KAAK;QAC3E,6EAA6E,CAChF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read an environment variable, treating blank as unset.
|
|
3
|
+
*
|
|
4
|
+
* Pairs with `??` at the call site: `envOrUndefined(env, "X") ?? fallback`
|
|
5
|
+
* falls through for a missing AND for a blank variable, which `env.X ?? y`
|
|
6
|
+
* would not.
|
|
7
|
+
*
|
|
8
|
+
* @param env - The environment to read.
|
|
9
|
+
* @param name - The variable to read.
|
|
10
|
+
* @returns The trimmed value, or undefined when unset or blank.
|
|
11
|
+
*/
|
|
12
|
+
export declare function envOrUndefined(env: Record<string, string | undefined>, name: string): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Narrow a possibly-blank string to undefined, for values already read out of
|
|
15
|
+
* the environment. The non-lookup counterpart of {@link envOrUndefined}.
|
|
16
|
+
*
|
|
17
|
+
* @param value - The raw value, possibly blank or absent.
|
|
18
|
+
* @returns The trimmed value, or undefined when absent or blank.
|
|
19
|
+
*/
|
|
20
|
+
export declare function blankAsUndefined(value: string | undefined): string | undefined;
|
|
21
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/plumbing/env.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACvC,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAGpB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAG9E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Environment-variable reading shared by the config resolvers. A variable set
|
|
2
|
+
// to whitespace or the empty string means UNSET everywhere in this workspace,
|
|
3
|
+
// so every reader funnels through here rather than relying on `||`'s
|
|
4
|
+
// falsiness, which cannot say whether "" was intended.
|
|
5
|
+
/**
|
|
6
|
+
* Read an environment variable, treating blank as unset.
|
|
7
|
+
*
|
|
8
|
+
* Pairs with `??` at the call site: `envOrUndefined(env, "X") ?? fallback`
|
|
9
|
+
* falls through for a missing AND for a blank variable, which `env.X ?? y`
|
|
10
|
+
* would not.
|
|
11
|
+
*
|
|
12
|
+
* @param env - The environment to read.
|
|
13
|
+
* @param name - The variable to read.
|
|
14
|
+
* @returns The trimmed value, or undefined when unset or blank.
|
|
15
|
+
*/
|
|
16
|
+
export function envOrUndefined(env, name) {
|
|
17
|
+
const raw = env[name]?.trim();
|
|
18
|
+
return raw === undefined || raw === "" ? undefined : raw;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Narrow a possibly-blank string to undefined, for values already read out of
|
|
22
|
+
* the environment. The non-lookup counterpart of {@link envOrUndefined}.
|
|
23
|
+
*
|
|
24
|
+
* @param value - The raw value, possibly blank or absent.
|
|
25
|
+
* @returns The trimmed value, or undefined when absent or blank.
|
|
26
|
+
*/
|
|
27
|
+
export function blankAsUndefined(value) {
|
|
28
|
+
const trimmed = value?.trim();
|
|
29
|
+
return trimmed === undefined || trimmed === "" ? undefined : trimmed;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/plumbing/env.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,qEAAqE;AACrE,uDAAuD;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAuC,EACvC,IAAY;IAEZ,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IAC9B,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;AAC3D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAyB;IACxD,MAAM,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAC9B,OAAO,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC"}
|
|
@@ -26,7 +26,12 @@ export declare function deriveWalletAddresses(seed: string, config: MidnightNode
|
|
|
26
26
|
* @returns The synced {@link AccountFunding}.
|
|
27
27
|
*/
|
|
28
28
|
export declare function readAccountFunding(config: MidnightNodeConfig, seed: string): Promise<AccountFunding>;
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* A wallet is fee-ready when it holds NIGHT and that NIGHT has generated spendable dust.
|
|
31
|
+
*
|
|
32
|
+
* @param funding - The wallet's measured funding.
|
|
33
|
+
* @returns Whether the wallet can pay fees right now.
|
|
34
|
+
*/
|
|
30
35
|
export declare function isFeeReady(funding: AccountFunding): boolean;
|
|
31
36
|
/**
|
|
32
37
|
* The root wallet holds no funds on a deployed network until its NIGHT
|
|
@@ -36,6 +41,10 @@ export declare function isFeeReady(funding: AccountFunding): boolean;
|
|
|
36
41
|
export declare class RootUnfundedError extends Error {
|
|
37
42
|
readonly nightAddress: string;
|
|
38
43
|
readonly faucetUrl: string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* @param nightAddress - The NIGHT receive address that needs funding.
|
|
46
|
+
* @param faucetUrl - The network's faucet, when one is known.
|
|
47
|
+
*/
|
|
39
48
|
constructor(nightAddress: string, faucetUrl: string | undefined);
|
|
40
49
|
}
|
|
41
50
|
/**
|
|
@@ -54,7 +63,7 @@ export declare class RootUnfundedError extends Error {
|
|
|
54
63
|
* @param rootSeed - The root wallet seed.
|
|
55
64
|
* @param faucetUrl - The network's faucet URL for the underfunded message.
|
|
56
65
|
* @returns The root's fee-ready funding snapshot.
|
|
57
|
-
* @throws {
|
|
66
|
+
* @throws {RootUnfundedError} If root holds no NIGHT, or if no dust
|
|
58
67
|
* appears in time after registration.
|
|
59
68
|
*/
|
|
60
69
|
export declare function assertRootFunded(config: MidnightNodeConfig, rootSeed: string, faucetUrl: string | undefined): Promise<AccountFunding>;
|
|
@@ -70,7 +79,7 @@ export declare function assertRootFunded(config: MidnightNodeConfig, rootSeed: s
|
|
|
70
79
|
* @param childSeed - The child wallet's seed.
|
|
71
80
|
* @param amount - NIGHT to transfer when the child holds none, in base units.
|
|
72
81
|
* @returns The child's post-funding snapshot.
|
|
73
|
-
* @throws If root cannot cover the transfer, or dust never appears in time.
|
|
82
|
+
* @throws {Error} If root cannot cover the transfer, or dust never appears in time.
|
|
74
83
|
*/
|
|
75
84
|
export declare function fundChildFromRoot(config: MidnightNodeConfig, rootSeed: string, childSeed: string, amount: bigint): Promise<AccountFunding>;
|
|
76
85
|
//# sourceMappingURL=funding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"funding.d.ts","sourceRoot":"","sources":["../../src/plumbing/funding.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,
|
|
1
|
+
{"version":3,"file":"funding.d.ts","sourceRoot":"","sources":["../../src/plumbing/funding.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAOL,KAAK,eAAe,EAErB,MAAM,aAAa,CAAC;AAErB,8FAA8F;AAC9F,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAYD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,eAAe,CAE/F;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,cAAc,CAAC,CAUzB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAE3D;AAED;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAMxC,QAAQ,CAAC,YAAY,EAAE,MAAM;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IANxC;;;OAGG;IACH,YACW,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAAG,SAAS,EASvC;CACF;AASD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,OAAO,CAAC,cAAc,CAAC,CAqBzB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CAsCzB"}
|
package/dist/plumbing/funding.js
CHANGED
|
@@ -11,7 +11,12 @@
|
|
|
11
11
|
// per-child amount, and prints addresses lives in the integration-tests setup.
|
|
12
12
|
import { isLocalStandaloneNetwork } from "./network-id.js";
|
|
13
13
|
import { deriveAccountKeys, deriveAddresses, registerNightForDustGeneration, transferNight, waitForSpendableDust, withSyncedWalletFacade, } from "./wallet.js";
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Sum a wallet's unshielded NIGHT across its UTXOs, in base units.
|
|
16
|
+
*
|
|
17
|
+
* @param state - The synced wallet facade state to total.
|
|
18
|
+
* @returns The wallet's total unshielded NIGHT in base units.
|
|
19
|
+
*/
|
|
15
20
|
function totalNight(state) {
|
|
16
21
|
return Object.values(state.unshielded.balances).reduce((sum, value) => sum + value, 0n);
|
|
17
22
|
}
|
|
@@ -36,13 +41,18 @@ export function deriveWalletAddresses(seed, config) {
|
|
|
36
41
|
export async function readAccountFunding(config, seed) {
|
|
37
42
|
const keys = deriveAccountKeys(seed, config.networkId);
|
|
38
43
|
const addresses = deriveAddresses(keys, config.networkId);
|
|
39
|
-
return withSyncedWalletFacade(keys, config,
|
|
44
|
+
return withSyncedWalletFacade(keys, config, (_facade, state) => Promise.resolve({
|
|
40
45
|
addresses,
|
|
41
46
|
night: totalNight(state),
|
|
42
47
|
dust: state.dust.balance(new Date()),
|
|
43
48
|
}));
|
|
44
49
|
}
|
|
45
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* A wallet is fee-ready when it holds NIGHT and that NIGHT has generated spendable dust.
|
|
52
|
+
*
|
|
53
|
+
* @param funding - The wallet's measured funding.
|
|
54
|
+
* @returns Whether the wallet can pay fees right now.
|
|
55
|
+
*/
|
|
46
56
|
export function isFeeReady(funding) {
|
|
47
57
|
return funding.night > 0n && funding.dust > 0n;
|
|
48
58
|
}
|
|
@@ -54,6 +64,10 @@ export function isFeeReady(funding) {
|
|
|
54
64
|
export class RootUnfundedError extends Error {
|
|
55
65
|
nightAddress;
|
|
56
66
|
faucetUrl;
|
|
67
|
+
/**
|
|
68
|
+
* @param nightAddress - The NIGHT receive address that needs funding.
|
|
69
|
+
* @param faucetUrl - The network's faucet, when one is known.
|
|
70
|
+
*/
|
|
57
71
|
constructor(nightAddress, faucetUrl) {
|
|
58
72
|
const where = faucetUrl ? `at ${faucetUrl}` : "via the network's faucet";
|
|
59
73
|
super(`root wallet holds no NIGHT. Fund it ${where}, then rerun.\n` +
|
|
@@ -86,7 +100,7 @@ const GENESIS_INDEX_TIMEOUT_MS = 120_000;
|
|
|
86
100
|
* @param rootSeed - The root wallet seed.
|
|
87
101
|
* @param faucetUrl - The network's faucet URL for the underfunded message.
|
|
88
102
|
* @returns The root's fee-ready funding snapshot.
|
|
89
|
-
* @throws {
|
|
103
|
+
* @throws {RootUnfundedError} If root holds no NIGHT, or if no dust
|
|
90
104
|
* appears in time after registration.
|
|
91
105
|
*/
|
|
92
106
|
export async function assertRootFunded(config, rootSeed, faucetUrl) {
|
|
@@ -123,13 +137,13 @@ export async function assertRootFunded(config, rootSeed, faucetUrl) {
|
|
|
123
137
|
* @param childSeed - The child wallet's seed.
|
|
124
138
|
* @param amount - NIGHT to transfer when the child holds none, in base units.
|
|
125
139
|
* @returns The child's post-funding snapshot.
|
|
126
|
-
* @throws If root cannot cover the transfer, or dust never appears in time.
|
|
140
|
+
* @throws {Error} If root cannot cover the transfer, or dust never appears in time.
|
|
127
141
|
*/
|
|
128
142
|
export async function fundChildFromRoot(config, rootSeed, childSeed, amount) {
|
|
129
143
|
const rootKeys = deriveAccountKeys(rootSeed, config.networkId);
|
|
130
144
|
const childKeys = deriveAccountKeys(childSeed, config.networkId);
|
|
131
145
|
const childAddresses = deriveAddresses(childKeys, config.networkId);
|
|
132
|
-
const before = await withSyncedWalletFacade(childKeys, config,
|
|
146
|
+
const before = await withSyncedWalletFacade(childKeys, config, (_f, s) => Promise.resolve(totalNight(s)));
|
|
133
147
|
if (before === 0n) {
|
|
134
148
|
await withSyncedWalletFacade(rootKeys, config, async (rootFacade, rootState) => {
|
|
135
149
|
await transferNight(rootFacade, rootKeys, rootState, childAddresses.unshielded, config.networkId, amount);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"funding.js","sourceRoot":"","sources":["../../src/plumbing/funding.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,0EAA0E;AAC1E,0EAA0E;AAC1E,4EAA4E;AAC5E,4EAA4E;AAC5E,yDAAyD;AACzD,EAAE;AACF,0EAA0E;AAC1E,0EAA0E;AAC1E,+EAA+E;AAG/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EACL,iBAAiB,EACjB,eAAe,
|
|
1
|
+
{"version":3,"file":"funding.js","sourceRoot":"","sources":["../../src/plumbing/funding.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,0EAA0E;AAC1E,0EAA0E;AAC1E,4EAA4E;AAC5E,4EAA4E;AAC5E,yDAAyD;AACzD,EAAE;AACF,0EAA0E;AAC1E,0EAA0E;AAC1E,+EAA+E;AAG/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EACL,iBAAiB,EACjB,eAAe,EAEf,8BAA8B,EAC9B,aAAa,EACb,oBAAoB,EAEpB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAYrB;;;;;GAKG;AACH,SAAS,UAAU,CAAC,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/** A network's four service endpoints, without the network id itself. */
|
|
15
16
|
export type Endpoints = Omit<MidnightNodeConfig, "networkId">;
|
|
17
|
+
/** Endpoint of the locally run proof server. */
|
|
16
18
|
export declare const LOCAL_PROOF_SERVER = "http://127.0.0.1:6300";
|
|
19
|
+
/** Baseline endpoints per network, before any environment override. */
|
|
17
20
|
export declare const DEFAULT_ENDPOINTS: Record<NetworkId, Endpoints>;
|
|
21
|
+
/** Known faucet URLs per network, used to build the fund-your-wallet hint. */
|
|
18
22
|
export declare const FAUCET_URLS: Partial<Record<NetworkId, string>>;
|
|
19
23
|
/**
|
|
20
24
|
* The faucet URL to show in underfunded-wallet hints: `MIDNIGHT_FAUCET_URL`
|
|
@@ -26,6 +30,10 @@ export declare const FAUCET_URLS: Partial<Record<NetworkId, string>>;
|
|
|
26
30
|
* @returns The faucet URL, or undefined when none is known.
|
|
27
31
|
*/
|
|
28
32
|
export declare function getFaucetUrl(env: Record<string, string | undefined>, networkId: NetworkId): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* @param indexerUrl - The indexer's HTTP GraphQL endpoint.
|
|
35
|
+
* @returns The same endpoint over ws(s), with the `/ws` segment appended.
|
|
36
|
+
*/
|
|
29
37
|
export declare function indexerWsUrlFromIndexerUrl(indexerUrl: string): string;
|
|
30
38
|
/**
|
|
31
39
|
* Read a {@link MidnightNodeConfig} from the environment. With nothing set
|
|
@@ -43,7 +51,9 @@ export declare function indexerWsUrlFromIndexerUrl(indexerUrl: string): string;
|
|
|
43
51
|
* derived from it instead of keeping the baseline host.
|
|
44
52
|
* 3. Every resolved endpoint must be non-empty.
|
|
45
53
|
*
|
|
46
|
-
* @
|
|
54
|
+
* @param env - The environment to read; defaults to `process.env`.
|
|
55
|
+
* @returns The fully resolved node config.
|
|
56
|
+
* @throws {Error} If `NETWORK_ID` is unknown, or an endpoint resolves empty (blank
|
|
47
57
|
* default and no environment override).
|
|
48
58
|
*/
|
|
49
59
|
export declare function getMidnightNodeConfig(env?: Record<string, string | undefined>): MidnightNodeConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midnight-node-config.d.ts","sourceRoot":"","sources":["../../src/plumbing/midnight-node-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"midnight-node-config.d.ts","sourceRoot":"","sources":["../../src/plumbing/midnight-node-config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B;AAED,yEAAyE;AACzE,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;AAI9D,gDAAgD;AAChD,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAI1D,uEAAuE;AACvE,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,SAAS,EAAE,SAAS,CAuC1D,CAAC;AASF,8EAA8E;AAC9E,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAM,CAAC;AAElE;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACvC,SAAS,EAAE,SAAS,GACnB,MAAM,GAAG,SAAS,CAEpB;AAID;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAKrE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,kBAAkB,CA4CpB"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
// Midnight node connection config — everything needed to talk to one Midnight
|
|
2
|
+
import { envOrUndefined } from "./env.js";
|
|
2
3
|
import { MidnightNetwork, NETWORK_IDS } from "./network-id.js";
|
|
3
4
|
// The proof server sees private witness data, so it is always run locally
|
|
4
5
|
// rather than against a remote host.
|
|
6
|
+
/** Endpoint of the locally run proof server. */
|
|
5
7
|
export const LOCAL_PROOF_SERVER = "http://127.0.0.1:6300";
|
|
6
8
|
// Default endpoints per network. Undeployed is the local standalone stack
|
|
7
9
|
// (Docker containers) run during development.
|
|
10
|
+
/** Baseline endpoints per network, before any environment override. */
|
|
8
11
|
export const DEFAULT_ENDPOINTS = {
|
|
9
12
|
[MidnightNetwork.Undeployed]: {
|
|
10
13
|
indexerUrl: "http://127.0.0.1:8088/api/v3/graphql",
|
|
@@ -52,6 +55,7 @@ export const DEFAULT_ENDPOINTS = {
|
|
|
52
55
|
// {@link getFaucetUrl}); without it the hint degrades to a generic "fund via
|
|
53
56
|
// the network's faucet". The public *.midnight.network faucet URLs are
|
|
54
57
|
// omitted until confirmed.
|
|
58
|
+
/** Known faucet URLs per network, used to build the fund-your-wallet hint. */
|
|
55
59
|
export const FAUCET_URLS = {};
|
|
56
60
|
/**
|
|
57
61
|
* The faucet URL to show in underfunded-wallet hints: `MIDNIGHT_FAUCET_URL`
|
|
@@ -63,10 +67,14 @@ export const FAUCET_URLS = {};
|
|
|
63
67
|
* @returns The faucet URL, or undefined when none is known.
|
|
64
68
|
*/
|
|
65
69
|
export function getFaucetUrl(env, networkId) {
|
|
66
|
-
return env
|
|
70
|
+
return envOrUndefined(env, "MIDNIGHT_FAUCET_URL") ?? FAUCET_URLS[networkId];
|
|
67
71
|
}
|
|
68
72
|
// Derive the indexer WebSocket URL from the indexer HTTP URL: swap the scheme
|
|
69
73
|
// to ws(s) and append the "/ws" path segment the indexer expects.
|
|
74
|
+
/**
|
|
75
|
+
* @param indexerUrl - The indexer's HTTP GraphQL endpoint.
|
|
76
|
+
* @returns The same endpoint over ws(s), with the `/ws` segment appended.
|
|
77
|
+
*/
|
|
70
78
|
export function indexerWsUrlFromIndexerUrl(indexerUrl) {
|
|
71
79
|
const url = new URL(indexerUrl);
|
|
72
80
|
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
@@ -89,24 +97,31 @@ export function indexerWsUrlFromIndexerUrl(indexerUrl) {
|
|
|
89
97
|
* derived from it instead of keeping the baseline host.
|
|
90
98
|
* 3. Every resolved endpoint must be non-empty.
|
|
91
99
|
*
|
|
92
|
-
* @
|
|
100
|
+
* @param env - The environment to read; defaults to `process.env`.
|
|
101
|
+
* @returns The fully resolved node config.
|
|
102
|
+
* @throws {Error} If `NETWORK_ID` is unknown, or an endpoint resolves empty (blank
|
|
93
103
|
* default and no environment override).
|
|
94
104
|
*/
|
|
95
105
|
export function getMidnightNodeConfig(env = process.env) {
|
|
96
|
-
const networkId = env
|
|
97
|
-
|
|
106
|
+
const networkId = envOrUndefined(env, "NETWORK_ID") ?? MidnightNetwork.Undeployed;
|
|
107
|
+
// NetworkId widens the enum with the SDK's bare-string type, so the baseline
|
|
108
|
+
// lookup can miss. Both failures name the same fix, so they share a throw.
|
|
109
|
+
const defaults = DEFAULT_ENDPOINTS[networkId];
|
|
110
|
+
if (!NETWORK_IDS.includes(networkId) || defaults === undefined) {
|
|
98
111
|
throw new Error(`Invalid NETWORK_ID "${networkId}" — expected one of: ${NETWORK_IDS.join(", ")}.`);
|
|
99
112
|
}
|
|
100
|
-
const
|
|
101
|
-
const indexerUrl =
|
|
102
|
-
const indexerWsUrl = env
|
|
103
|
-
(
|
|
113
|
+
const indexerOverride = envOrUndefined(env, "MIDNIGHT_NODE_INDEXER_URL");
|
|
114
|
+
const indexerUrl = indexerOverride ?? defaults.indexerUrl;
|
|
115
|
+
const indexerWsUrl = envOrUndefined(env, "MIDNIGHT_NODE_INDEXER_WS_URL") ??
|
|
116
|
+
(indexerOverride === undefined
|
|
117
|
+
? defaults.indexerWsUrl
|
|
118
|
+
: indexerWsUrlFromIndexerUrl(indexerUrl));
|
|
104
119
|
const config = {
|
|
105
120
|
networkId,
|
|
106
121
|
indexerUrl,
|
|
107
122
|
indexerWsUrl,
|
|
108
|
-
nodeUrl: env
|
|
109
|
-
proofServerUrl: env
|
|
123
|
+
nodeUrl: envOrUndefined(env, "MIDNIGHT_NODE_URL") ?? defaults.nodeUrl,
|
|
124
|
+
proofServerUrl: envOrUndefined(env, "MIDNIGHT_NODE_PROOF_SERVER_URL") ?? defaults.proofServerUrl,
|
|
110
125
|
};
|
|
111
126
|
// A blank default means the network's endpoints are not published in this
|
|
112
127
|
// repo (stagenet) — the environment must supply them, so fail with the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midnight-node-config.js","sourceRoot":"","sources":["../../src/plumbing/midnight-node-config.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E,OAAO,EAAE,eAAe,EAAE,WAAW,EAAkB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"midnight-node-config.js","sourceRoot":"","sources":["../../src/plumbing/midnight-node-config.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAkB,MAAM,iBAAiB,CAAC;AAmB/E,0EAA0E;AAC1E,qCAAqC;AACrC,gDAAgD;AAChD,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AAE1D,0EAA0E;AAC1E,8CAA8C;AAC9C,uEAAuE;AACvE,MAAM,CAAC,MAAM,iBAAiB,GAAiC;IAC7D,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE;QAC5B,UAAU,EAAE,sCAAsC;QAClD,YAAY,EAAE,uCAAuC;QACrD,OAAO,EAAE,uBAAuB;QAChC,cAAc,EAAE,kB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C,OAAO;QACrE,cAAc,EACZ,cAAc,CAAC,GAAG,EAAE,gCAAgC,CAAC,IAAI,QAAQ,CAAC,cAAc;KACnF,CAAC;IAEF,0EAA0E;IAC1E,uEAAuE;IACvE,0BAA0B;IAC1B,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACvD,IAAI,CAAC,MAAM,CAAC,UAAU;QAAE,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAClE,IAAI,CAAC,MAAM,CAAC,YAAY;QAAE,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;IACvE,IAAI,CAAC,MAAM,CAAC,cAAc;QAAE,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IAC3E,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,YAAY,SAAS,kDAAkD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YAC1F,6CAA6C,CAChD,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { MidnightNetwork } from "@sig-net/midnight";
|
|
|
3
3
|
export { MidnightNetwork };
|
|
4
4
|
/** A Midnight network id: the SDK's bare-string type plus the named networks. */
|
|
5
5
|
export type NetworkId = MidnightSDKNetworkId | MidnightNetwork;
|
|
6
|
+
/** Every known network id, for runtime validation and iteration. */
|
|
6
7
|
export declare const NETWORK_IDS: readonly NetworkId[];
|
|
7
8
|
/**
|
|
8
9
|
* Whether a network's genesis mint wallet is pre-funded. TRUE only for the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-id.d.ts","sourceRoot":"","sources":["../../src/plumbing/network-id.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,IAAI,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,iFAAiF;AACjF,MAAM,MAAM,SAAS,GAAG,oBAAoB,GAAG,eAAe,CAAC;AAG/D,eAAO,MAAM,WAAW,EAAE,SAAS,SAAS,EAAmC,CAAC;AAEhF;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"network-id.d.ts","sourceRoot":"","sources":["../../src/plumbing/network-id.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,IAAI,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,iFAAiF;AACjF,MAAM,MAAM,SAAS,GAAG,oBAAoB,GAAG,eAAe,CAAC;AAG/D,oEAAoE;AACpE,eAAO,MAAM,WAAW,EAAE,SAAS,SAAS,EAAmC,CAAC;AAEhF;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAGtE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MidnightNetwork } from "@sig-net/midnight";
|
|
2
2
|
export { MidnightNetwork };
|
|
3
3
|
// All known network ids, for runtime validation and iteration.
|
|
4
|
+
/** Every known network id, for runtime validation and iteration. */
|
|
4
5
|
export const NETWORK_IDS = Object.values(MidnightNetwork);
|
|
5
6
|
/**
|
|
6
7
|
* Whether a network's genesis mint wallet is pre-funded. TRUE only for the
|
|
@@ -14,6 +15,7 @@ export const NETWORK_IDS = Object.values(MidnightNetwork);
|
|
|
14
15
|
* @returns Whether the genesis mint wallet holds spendable funds here.
|
|
15
16
|
*/
|
|
16
17
|
export function isLocalStandaloneNetwork(networkId) {
|
|
17
|
-
|
|
18
|
+
const undeployed = MidnightNetwork.Undeployed;
|
|
19
|
+
return networkId === undeployed;
|
|
18
20
|
}
|
|
19
21
|
//# sourceMappingURL=network-id.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-id.js","sourceRoot":"","sources":["../../src/plumbing/network-id.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,CAAC;AAK3B,+DAA+D;AAC/D,MAAM,CAAC,MAAM,WAAW,GAAyB,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AAEhF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,wBAAwB,CAAC,SAAoB;
|
|
1
|
+
{"version":3,"file":"network-id.js","sourceRoot":"","sources":["../../src/plumbing/network-id.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,CAAC;AAK3B,+DAA+D;AAC/D,oEAAoE;AACpE,MAAM,CAAC,MAAM,WAAW,GAAyB,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AAEhF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,wBAAwB,CAAC,SAAoB;IAC3D,MAAM,UAAU,GAAc,eAAe,CAAC,UAAU,CAAC;IACzD,OAAO,SAAS,KAAK,UAAU,CAAC;AAClC,CAAC"}
|
package/dist/plumbing/seed.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare const SeedFormat: {
|
|
|
3
3
|
readonly Mnemonic: "mnemonic";
|
|
4
4
|
readonly Hex: "hex";
|
|
5
5
|
};
|
|
6
|
+
/** The form a seed was supplied in. */
|
|
6
7
|
export type SeedFormat = (typeof SeedFormat)[keyof typeof SeedFormat];
|
|
7
8
|
/** Where a parsed seed came from, including its normalised hex form. */
|
|
8
9
|
export interface DerivationSource {
|
|
@@ -13,18 +14,28 @@ export interface DerivationSource {
|
|
|
13
14
|
seedHex: string;
|
|
14
15
|
seedBytes: number;
|
|
15
16
|
}
|
|
17
|
+
/** Thrown when an input is neither a valid hex seed nor a BIP-39 mnemonic. */
|
|
16
18
|
export declare class ParseError extends Error {
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* Parse `input` as a hex seed (16–64 bytes, optional 0x prefix) or a BIP-39
|
|
20
22
|
* mnemonic (run through PBKDF2 to its 64-byte seed). Throws {@link ParseError}
|
|
21
23
|
* when it is neither.
|
|
24
|
+
*
|
|
25
|
+
* @param input - The hex seed or mnemonic to parse.
|
|
26
|
+
* @returns The seed bytes and a record of how they were supplied.
|
|
27
|
+
* @throws {ParseError} If the input is neither form, or a hex seed is outside
|
|
28
|
+
* 16 to 64 bytes.
|
|
22
29
|
*/
|
|
23
30
|
export declare function parseSeed(input: string): {
|
|
24
31
|
seed: Uint8Array;
|
|
25
32
|
source: DerivationSource;
|
|
26
33
|
};
|
|
27
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Generate a fresh random 24-word BIP-39 mnemonic (256 bits of entropy).
|
|
36
|
+
*
|
|
37
|
+
* @returns The generated mnemonic.
|
|
38
|
+
*/
|
|
28
39
|
export declare function generateMnemonic(): string;
|
|
29
40
|
/**
|
|
30
41
|
* Generate a fresh random 32-byte seed as lowercase hex (no `0x` prefix).
|
|
@@ -46,7 +57,7 @@ export declare function generateHexSeed(): string;
|
|
|
46
57
|
* @param env - The environment to read from.
|
|
47
58
|
* @param fallbackSeed - The wallet seed (hex or mnemonic) used as the identity when `env[envVar]` is unset.
|
|
48
59
|
* @returns The 32-byte secret key.
|
|
49
|
-
* @throws If `env[envVar]` is set but not 32 bytes of hex, or if it is unset
|
|
60
|
+
* @throws {ParseError} If `env[envVar]` is set but not 32 bytes of hex, or if it is unset
|
|
50
61
|
* and `fallbackSeed` does not parse to exactly 32 bytes (e.g. a mnemonic).
|
|
51
62
|
*/
|
|
52
63
|
export declare function parseIdentitySecretKey(envVar: string, env: Record<string, string | undefined>, fallbackSeed: string): Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../src/plumbing/seed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../../src/plumbing/seed.ts"],"names":[],"mappings":"AAYA,gFAAgF;AAChF,eAAO,MAAM,UAAU;aACrB,QAAQ,EAAE,UAAU;aACpB,GAAG,EAAE,KAAK;CACF,CAAC;AACX,uCAAuC;AACvC,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEtE,wEAAwE;AACxE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,UAAU,CAAC;IACnB,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,8EAA8E;AAC9E,qBAAa,UAAW,SAAQ,KAAK;CAAG;AAExC;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAiCvF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EACvC,YAAY,EAAE,MAAM,GACnB,UAAU,CAiBZ"}
|
package/dist/plumbing/seed.js
CHANGED
|
@@ -4,18 +4,25 @@
|
|
|
4
4
|
import { randomBytes } from "node:crypto";
|
|
5
5
|
import * as bip39 from "@scure/bip39";
|
|
6
6
|
import { wordlist as english } from "@scure/bip39/wordlists/english.js";
|
|
7
|
+
import { hexToBytes } from "@sig-net/midnight";
|
|
7
8
|
const toHex = (bytes) => Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
8
9
|
/** How the input seed was supplied. (Const object + union — see network.ts.) */
|
|
9
10
|
export const SeedFormat = {
|
|
10
11
|
Mnemonic: "mnemonic",
|
|
11
12
|
Hex: "hex",
|
|
12
13
|
};
|
|
14
|
+
/** Thrown when an input is neither a valid hex seed nor a BIP-39 mnemonic. */
|
|
13
15
|
export class ParseError extends Error {
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* Parse `input` as a hex seed (16–64 bytes, optional 0x prefix) or a BIP-39
|
|
17
19
|
* mnemonic (run through PBKDF2 to its 64-byte seed). Throws {@link ParseError}
|
|
18
20
|
* when it is neither.
|
|
21
|
+
*
|
|
22
|
+
* @param input - The hex seed or mnemonic to parse.
|
|
23
|
+
* @returns The seed bytes and a record of how they were supplied.
|
|
24
|
+
* @throws {ParseError} If the input is neither form, or a hex seed is outside
|
|
25
|
+
* 16 to 64 bytes.
|
|
19
26
|
*/
|
|
20
27
|
export function parseSeed(input) {
|
|
21
28
|
const trimmed = input.trim();
|
|
@@ -26,10 +33,13 @@ export function parseSeed(input) {
|
|
|
26
33
|
if (looksHex) {
|
|
27
34
|
const bytes = compact.length / 2;
|
|
28
35
|
if (bytes < 16 || bytes > 64) {
|
|
29
|
-
throw new ParseError(`Hex seed must be 16–64 bytes; got ${bytes}.`);
|
|
36
|
+
throw new ParseError(`Hex seed must be 16–64 bytes; got ${String(bytes)}.`);
|
|
30
37
|
}
|
|
31
|
-
const seed =
|
|
32
|
-
return {
|
|
38
|
+
const seed = hexToBytes(compact);
|
|
39
|
+
return {
|
|
40
|
+
seed,
|
|
41
|
+
source: { format: SeedFormat.Hex, seedHex: compact.toLowerCase(), seedBytes: bytes },
|
|
42
|
+
};
|
|
33
43
|
}
|
|
34
44
|
const words = trimmed.split(/\s+/);
|
|
35
45
|
if (!bip39.validateMnemonic(words.join(" "), english)) {
|
|
@@ -38,10 +48,19 @@ export function parseSeed(input) {
|
|
|
38
48
|
const seed = bip39.mnemonicToSeedSync(words.join(" "));
|
|
39
49
|
return {
|
|
40
50
|
seed,
|
|
41
|
-
source: {
|
|
51
|
+
source: {
|
|
52
|
+
format: SeedFormat.Mnemonic,
|
|
53
|
+
words: words.length,
|
|
54
|
+
seedHex: toHex(seed),
|
|
55
|
+
seedBytes: seed.length,
|
|
56
|
+
},
|
|
42
57
|
};
|
|
43
58
|
}
|
|
44
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Generate a fresh random 24-word BIP-39 mnemonic (256 bits of entropy).
|
|
61
|
+
*
|
|
62
|
+
* @returns The generated mnemonic.
|
|
63
|
+
*/
|
|
45
64
|
export function generateMnemonic() {
|
|
46
65
|
return bip39.generateMnemonic(english, 256);
|
|
47
66
|
}
|
|
@@ -67,7 +86,7 @@ export function generateHexSeed() {
|
|
|
67
86
|
* @param env - The environment to read from.
|
|
68
87
|
* @param fallbackSeed - The wallet seed (hex or mnemonic) used as the identity when `env[envVar]` is unset.
|
|
69
88
|
* @returns The 32-byte secret key.
|
|
70
|
-
* @throws If `env[envVar]` is set but not 32 bytes of hex, or if it is unset
|
|
89
|
+
* @throws {ParseError} If `env[envVar]` is set but not 32 bytes of hex, or if it is unset
|
|
71
90
|
* and `fallbackSeed` does not parse to exactly 32 bytes (e.g. a mnemonic).
|
|
72
91
|
*/
|
|
73
92
|
export function parseIdentitySecretKey(envVar, env, fallbackSeed) {
|
|
@@ -77,11 +96,11 @@ export function parseIdentitySecretKey(envVar, env, fallbackSeed) {
|
|
|
77
96
|
if (!/^[0-9a-fA-F]{64}$/.test(hex)) {
|
|
78
97
|
throw new ParseError(`${envVar} must be exactly 32 bytes of hex`);
|
|
79
98
|
}
|
|
80
|
-
return
|
|
99
|
+
return hexToBytes(hex);
|
|
81
100
|
}
|
|
82
101
|
const { seed } = parseSeed(fallbackSeed);
|
|
83
102
|
if (seed.length !== 32) {
|
|
84
|
-
throw new ParseError(`The fallback seed parses to ${seed.length} bytes; the identity secret needs exactly 32. ` +
|
|
103
|
+
throw new ParseError(`The fallback seed parses to ${String(seed.length)} bytes; the identity secret needs exactly 32. ` +
|
|
85
104
|
`Set ${envVar} explicitly.`);
|
|
86
105
|
}
|
|
87
106
|
return seed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.js","sourceRoot":"","sources":["../../src/plumbing/seed.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,yEAAyE;AACzE,4EAA4E;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"seed.js","sourceRoot":"","sources":["../../src/plumbing/seed.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,yEAAyE;AACzE,4EAA4E;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,KAAK,GAAG,CAAC,KAAiB,EAAE,EAAE,CAClC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAErE,gFAAgF;AAChF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,KAAK;CACF,CAAC;AAcX,8EAA8E;AAC9E,MAAM,OAAO,UAAW,SAAQ,KAAK;CAAG;AAExC;;;;;;;;;GAS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
2
|
-
import {
|
|
2
|
+
import { type FacadeState, type TransactionIdentifier, WalletFacade } from "@midnightntwrk/wallet-sdk-facade";
|
|
3
3
|
import { type UnshieldedKeystore } from "@midnightntwrk/wallet-sdk-unshielded-wallet";
|
|
4
4
|
import type { MidnightNodeConfig } from "./midnight-node-config.ts";
|
|
5
5
|
import type { NetworkId } from "./network-id.ts";
|
|
6
|
-
export type { FacadeState, TransactionIdentifier, WalletFacade } from "@midnightntwrk/wallet-sdk-facade";
|
|
6
|
+
export type { FacadeState, TransactionIdentifier, WalletFacade, } from "@midnightntwrk/wallet-sdk-facade";
|
|
7
7
|
export type { EncPublicKey } from "@midnightntwrk/ledger-v9";
|
|
8
8
|
/** The live key material for one account. Reused for signing / balancing. */
|
|
9
9
|
export interface AccountKeys {
|
|
@@ -49,13 +49,29 @@ export interface WalletFacadeOptions {
|
|
|
49
49
|
/**
|
|
50
50
|
* Parse a seed and derive the three role keys (Zswap / NightExternal / Dust).
|
|
51
51
|
* Pure crypto — no network. This is the step that exercises the ledger WASM.
|
|
52
|
+
*
|
|
53
|
+
* @param seed - The wallet seed, as hex or a BIP-39 mnemonic.
|
|
54
|
+
* @param networkId - The network the unshielded keystore is bound to.
|
|
55
|
+
* @returns The Zswap, Dust and unshielded role keys.
|
|
56
|
+
* @throws {Error} If the seed is rejected by the HD wallet or key derivation fails.
|
|
52
57
|
*/
|
|
53
58
|
export declare function deriveAccountKeys(seed: string, networkId: NetworkId): AccountKeys;
|
|
54
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Compute the three bech32m addresses from the keys. Pure — no network.
|
|
61
|
+
*
|
|
62
|
+
* @param keys - The derived role keys.
|
|
63
|
+
* @param networkId - The network the addresses are encoded for.
|
|
64
|
+
* @returns The wallet's unshielded, shielded and dust addresses.
|
|
65
|
+
*/
|
|
55
66
|
export declare function deriveAddresses(keys: AccountKeys, networkId: NetworkId): WalletAddresses;
|
|
56
67
|
/**
|
|
57
68
|
* Wire up the WalletFacade for the given keys + connection config. This only
|
|
58
69
|
* constructs the three sub-wallets — it does NOT start syncing.
|
|
70
|
+
*
|
|
71
|
+
* @param keys - The derived role keys the facade drives.
|
|
72
|
+
* @param config - The endpoints the facade connects to.
|
|
73
|
+
* @param options - Facade tuning; see {@link WalletFacadeOptions}.
|
|
74
|
+
* @returns The constructed facade, not yet syncing.
|
|
59
75
|
*/
|
|
60
76
|
export declare function initialiseWalletFacade(keys: AccountKeys, config: MidnightNodeConfig, options?: WalletFacadeOptions): Promise<WalletFacade>;
|
|
61
77
|
/**
|
|
@@ -67,7 +83,7 @@ export declare function initialiseWalletFacade(keys: AccountKeys, config: Midnig
|
|
|
67
83
|
* @param keys - The key material of the same wallet, for balancing and signing.
|
|
68
84
|
* @param serializedTransaction - The unproven transaction bytes.
|
|
69
85
|
* @returns The submitted transaction's identifier.
|
|
70
|
-
* @throws If the wallet cannot cover fees, proving fails, or the node rejects the transaction.
|
|
86
|
+
* @throws {Error} If the wallet cannot cover fees, proving fails, or the node rejects the transaction.
|
|
71
87
|
*/
|
|
72
88
|
export declare function submitUnprovenTransaction(facade: WalletFacade, keys: AccountKeys, serializedTransaction: Uint8Array): Promise<TransactionIdentifier>;
|
|
73
89
|
/**
|
|
@@ -85,7 +101,7 @@ export declare function submitUnprovenTransaction(facade: WalletFacade, keys: Ac
|
|
|
85
101
|
* @param networkId - The network both wallets live on (decodes the address).
|
|
86
102
|
* @param amount - NIGHT to send, in base units.
|
|
87
103
|
* @returns The submitted transaction's identifier.
|
|
88
|
-
* @throws If the sender holds no unshielded NIGHT, or balancing/proving/submission fails.
|
|
104
|
+
* @throws {Error} If the sender holds no unshielded NIGHT, or balancing/proving/submission fails.
|
|
89
105
|
*/
|
|
90
106
|
export declare function transferNight(facade: WalletFacade, keys: AccountKeys, state: FacadeState, toUnshieldedAddress: string, networkId: NetworkId, amount: bigint): Promise<TransactionIdentifier>;
|
|
91
107
|
/**
|
|
@@ -99,7 +115,7 @@ export declare function transferNight(facade: WalletFacade, keys: AccountKeys, s
|
|
|
99
115
|
* @param keys - The key material of the same wallet; its unshielded keystore signs the registration.
|
|
100
116
|
* @param state - The synced facade state to read the NIGHT UTXOs from.
|
|
101
117
|
* @returns How many NIGHT UTXOs this call registered (0 = nothing unregistered, including no NIGHT at all).
|
|
102
|
-
* @throws If the node rejects the registration transaction.
|
|
118
|
+
* @throws {Error} If the node rejects the registration transaction.
|
|
103
119
|
*/
|
|
104
120
|
export declare function registerNightForDustGeneration(facade: WalletFacade, keys: AccountKeys, state: FacadeState): Promise<number>;
|
|
105
121
|
/**
|
|
@@ -110,7 +126,7 @@ export declare function registerNightForDustGeneration(facade: WalletFacade, key
|
|
|
110
126
|
* @param facade - A started wallet facade.
|
|
111
127
|
* @param timeoutMs - Give-up deadline in milliseconds.
|
|
112
128
|
* @returns The first positive dust balance observed.
|
|
113
|
-
* @throws If no dust appears within `timeoutMs`.
|
|
129
|
+
* @throws {Error} If no dust appears within `timeoutMs`.
|
|
114
130
|
*/
|
|
115
131
|
export declare function waitForSpendableDust(facade: WalletFacade, timeoutMs?: number): Promise<bigint>;
|
|
116
132
|
/**
|
|
@@ -123,7 +139,7 @@ export declare function waitForSpendableDust(facade: WalletFacade, timeoutMs?: n
|
|
|
123
139
|
* @param fn - Work to run with the live facade; receives the synced state for balance checks.
|
|
124
140
|
* @param options - Optional facade tuning knobs (see {@link WalletFacadeOptions}).
|
|
125
141
|
* @returns Whatever `fn` returns.
|
|
126
|
-
* @throws Whatever {@link initialiseWalletFacade}, the facade start/sync, or `fn` throws.
|
|
142
|
+
* @throws {Error} Whatever {@link initialiseWalletFacade}, the facade start/sync, or `fn` throws.
|
|
127
143
|
*/
|
|
128
144
|
export declare function withSyncedWalletFacade<T>(keys: AccountKeys, config: MidnightNodeConfig, fn: (facade: WalletFacade, state: FacadeState) => Promise<T>, options?: WalletFacadeOptions): Promise<T>;
|
|
129
145
|
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/plumbing/wallet.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/plumbing/wallet.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAC;AAWnD,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,qBAAqB,EAE1B,YAAY,EACb,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAGL,KAAK,kBAAkB,EAExB,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAKjD,YAAY,EACV,WAAW,EACX,qBAAqB,EACrB,YAAY,GACb,MAAM,kCAAkC,CAAC;AAI1C,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,kBAAkB,EAAE,MAAM,CAAC,eAAe,CAAC;IAC3C,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC;IACpC,kBAAkB,EAAE,kBAAkB,CAAC;CACxC;AAED,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,+BAA+B,kBAAsB,CAAC;AAKnE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,WAAW,CAqBjF;AAED;;;;;;GAMG;AAC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,13 @@
|
|
|
3
3
|
// encoding and WalletFacade wiring. Pure crypto + facade construction — no
|
|
4
4
|
// network I/O happens here (the facade connects only when started).
|
|
5
5
|
import * as ledger from "@midnightntwrk/ledger-v9";
|
|
6
|
-
import {
|
|
6
|
+
import { InMemoryTransactionHistoryStorage } from "@midnightntwrk/wallet-sdk-abstractions";
|
|
7
|
+
import { DustAddress, MidnightBech32m, ShieldedAddress, ShieldedCoinPublicKey, ShieldedEncryptionPublicKey, UnshieldedAddress, } from "@midnightntwrk/wallet-sdk-address-format";
|
|
8
|
+
import { DustWallet } from "@midnightntwrk/wallet-sdk-dust-wallet";
|
|
7
9
|
import { mergeWalletEntries, WalletEntrySchema, WalletFacade, } from "@midnightntwrk/wallet-sdk-facade";
|
|
10
|
+
import { HDWallet, Roles } from "@midnightntwrk/wallet-sdk-hd";
|
|
8
11
|
import { ShieldedWallet } from "@midnightntwrk/wallet-sdk-shielded";
|
|
9
|
-
import { DustWallet } from "@midnightntwrk/wallet-sdk-dust-wallet";
|
|
10
12
|
import { createKeystore, PublicKey as UnshieldedPublicKey, UnshieldedWallet, } from "@midnightntwrk/wallet-sdk-unshielded-wallet";
|
|
11
|
-
import { InMemoryTransactionHistoryStorage } from "@midnightntwrk/wallet-sdk-abstractions";
|
|
12
|
-
import { DustAddress, MidnightBech32m, ShieldedAddress, ShieldedCoinPublicKey, ShieldedEncryptionPublicKey, UnshieldedAddress, } from "@midnightntwrk/wallet-sdk-address-format";
|
|
13
13
|
import { parseSeed } from "./seed.js";
|
|
14
14
|
/**
|
|
15
15
|
* Default `additionalFeeOverhead` the facade balances transactions with: it
|
|
@@ -32,6 +32,11 @@ const FEE_BLOCKS_MARGIN = 5;
|
|
|
32
32
|
/**
|
|
33
33
|
* Parse a seed and derive the three role keys (Zswap / NightExternal / Dust).
|
|
34
34
|
* Pure crypto — no network. This is the step that exercises the ledger WASM.
|
|
35
|
+
*
|
|
36
|
+
* @param seed - The wallet seed, as hex or a BIP-39 mnemonic.
|
|
37
|
+
* @param networkId - The network the unshielded keystore is bound to.
|
|
38
|
+
* @returns The Zswap, Dust and unshielded role keys.
|
|
39
|
+
* @throws {Error} If the seed is rejected by the HD wallet or key derivation fails.
|
|
35
40
|
*/
|
|
36
41
|
export function deriveAccountKeys(seed, networkId) {
|
|
37
42
|
const { seed: seedBytes } = parseSeed(seed);
|
|
@@ -50,7 +55,13 @@ export function deriveAccountKeys(seed, networkId) {
|
|
|
50
55
|
const unshieldedKeystore = createKeystore({ kind: "schnorr", secret: derived.keys[Roles.NightExternal] }, networkId);
|
|
51
56
|
return { shieldedSecretKeys, dustSecretKey, unshieldedKeystore };
|
|
52
57
|
}
|
|
53
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Compute the three bech32m addresses from the keys. Pure — no network.
|
|
60
|
+
*
|
|
61
|
+
* @param keys - The derived role keys.
|
|
62
|
+
* @param networkId - The network the addresses are encoded for.
|
|
63
|
+
* @returns The wallet's unshielded, shielded and dust addresses.
|
|
64
|
+
*/
|
|
54
65
|
export function deriveAddresses(keys, networkId) {
|
|
55
66
|
const shieldedAddr = new ShieldedAddress(ShieldedCoinPublicKey.fromHexString(keys.shieldedSecretKeys.coinPublicKey), ShieldedEncryptionPublicKey.fromHexString(keys.shieldedSecretKeys.encryptionPublicKey));
|
|
56
67
|
return {
|
|
@@ -62,6 +73,11 @@ export function deriveAddresses(keys, networkId) {
|
|
|
62
73
|
/**
|
|
63
74
|
* Wire up the WalletFacade for the given keys + connection config. This only
|
|
64
75
|
* constructs the three sub-wallets — it does NOT start syncing.
|
|
76
|
+
*
|
|
77
|
+
* @param keys - The derived role keys the facade drives.
|
|
78
|
+
* @param config - The endpoints the facade connects to.
|
|
79
|
+
* @param options - Facade tuning; see {@link WalletFacadeOptions}.
|
|
80
|
+
* @returns The constructed facade, not yet syncing.
|
|
65
81
|
*/
|
|
66
82
|
export function initialiseWalletFacade(keys, config, options = {}) {
|
|
67
83
|
return WalletFacade.init({
|
|
@@ -96,7 +112,7 @@ const RECIPE_TTL_MS = 30 * 60 * 1000;
|
|
|
96
112
|
* @param keys - The key material of the same wallet, for balancing and signing.
|
|
97
113
|
* @param serializedTransaction - The unproven transaction bytes.
|
|
98
114
|
* @returns The submitted transaction's identifier.
|
|
99
|
-
* @throws If the wallet cannot cover fees, proving fails, or the node rejects the transaction.
|
|
115
|
+
* @throws {Error} If the wallet cannot cover fees, proving fails, or the node rejects the transaction.
|
|
100
116
|
*/
|
|
101
117
|
export async function submitUnprovenTransaction(facade, keys, serializedTransaction) {
|
|
102
118
|
// Deserialize back into the ledger UnprovenTransaction the facade balances.
|
|
@@ -122,7 +138,7 @@ export async function submitUnprovenTransaction(facade, keys, serializedTransact
|
|
|
122
138
|
* @param networkId - The network both wallets live on (decodes the address).
|
|
123
139
|
* @param amount - NIGHT to send, in base units.
|
|
124
140
|
* @returns The submitted transaction's identifier.
|
|
125
|
-
* @throws If the sender holds no unshielded NIGHT, or balancing/proving/submission fails.
|
|
141
|
+
* @throws {Error} If the sender holds no unshielded NIGHT, or balancing/proving/submission fails.
|
|
126
142
|
*/
|
|
127
143
|
export async function transferNight(facade, keys, state, toUnshieldedAddress, networkId, amount) {
|
|
128
144
|
const nightTokenType = Object.keys(state.unshielded.balances)[0];
|
|
@@ -146,7 +162,7 @@ export async function transferNight(facade, keys, state, toUnshieldedAddress, ne
|
|
|
146
162
|
* @param keys - The key material of the same wallet; its unshielded keystore signs the registration.
|
|
147
163
|
* @param state - The synced facade state to read the NIGHT UTXOs from.
|
|
148
164
|
* @returns How many NIGHT UTXOs this call registered (0 = nothing unregistered, including no NIGHT at all).
|
|
149
|
-
* @throws If the node rejects the registration transaction.
|
|
165
|
+
* @throws {Error} If the node rejects the registration transaction.
|
|
150
166
|
*/
|
|
151
167
|
export async function registerNightForDustGeneration(facade, keys, state) {
|
|
152
168
|
const unregistered = state.unshielded.availableCoins.filter((coin) => !coin.meta.registeredForDustGeneration);
|
|
@@ -171,7 +187,7 @@ const DUST_POLL_INTERVAL_MS = 5_000;
|
|
|
171
187
|
* @param facade - A started wallet facade.
|
|
172
188
|
* @param timeoutMs - Give-up deadline in milliseconds.
|
|
173
189
|
* @returns The first positive dust balance observed.
|
|
174
|
-
* @throws If no dust appears within `timeoutMs`.
|
|
190
|
+
* @throws {Error} If no dust appears within `timeoutMs`.
|
|
175
191
|
*/
|
|
176
192
|
export async function waitForSpendableDust(facade, timeoutMs = 300_000) {
|
|
177
193
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -181,7 +197,7 @@ export async function waitForSpendableDust(facade, timeoutMs = 300_000) {
|
|
|
181
197
|
if (dust > 0n)
|
|
182
198
|
return dust;
|
|
183
199
|
if (Date.now() >= deadline) {
|
|
184
|
-
throw new Error(`no spendable DUST after ${timeoutMs} ms — is the wallet's NIGHT registered for dust generation?`);
|
|
200
|
+
throw new Error(`no spendable DUST after ${String(timeoutMs)} ms — is the wallet's NIGHT registered for dust generation?`);
|
|
185
201
|
}
|
|
186
202
|
await new Promise((resolve) => setTimeout(resolve, DUST_POLL_INTERVAL_MS));
|
|
187
203
|
}
|
|
@@ -196,7 +212,7 @@ export async function waitForSpendableDust(facade, timeoutMs = 300_000) {
|
|
|
196
212
|
* @param fn - Work to run with the live facade; receives the synced state for balance checks.
|
|
197
213
|
* @param options - Optional facade tuning knobs (see {@link WalletFacadeOptions}).
|
|
198
214
|
* @returns Whatever `fn` returns.
|
|
199
|
-
* @throws Whatever {@link initialiseWalletFacade}, the facade start/sync, or `fn` throws.
|
|
215
|
+
* @throws {Error} Whatever {@link initialiseWalletFacade}, the facade start/sync, or `fn` throws.
|
|
200
216
|
*/
|
|
201
217
|
export async function withSyncedWalletFacade(keys, config, fn, options = {}) {
|
|
202
218
|
const facade = await initialiseWalletFacade(keys, config, options);
|
|
@@ -206,7 +222,7 @@ export async function withSyncedWalletFacade(keys, config, fn, options = {}) {
|
|
|
206
222
|
return await fn(facade, state);
|
|
207
223
|
}
|
|
208
224
|
finally {
|
|
209
|
-
await facade.stop().catch(() =>
|
|
225
|
+
await facade.stop().catch(() => undefined);
|
|
210
226
|
}
|
|
211
227
|
}
|
|
212
228
|
//# sourceMappingURL=wallet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/plumbing/wallet.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,2EAA2E;AAC3E,oEAAoE;AACpE,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/plumbing/wallet.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,2EAA2E;AAC3E,oEAAoE;AACpE,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EACL,WAAW,EACX,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,2BAA2B,EAC3B,iBAAiB,GAClB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAEL,kBAAkB,EAElB,iBAAiB,EACjB,YAAY,GACb,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EACL,cAAc,EACd,SAAS,IAAI,mBAAmB,EAEhC,gBAAgB,GACjB,MAAM,6CAA6C,CAAC;AAIrD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AA4BtC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,eAAmB,CAAC;AAEnE,yEAAyE;AACzE,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAgB5B;;;;;;;;GAQG;AACH,MAAM,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AC,CAAC;IAC7E,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,IAAiB,EACjB,MAA0B,EAC1B,EAA4D,EAC5D,OAAO,GAAwB,EAAE;IAEjC,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAChE,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,kBAAkB,EAAE,CAAC;QAChD,OAAO,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Contract, createSignetContractPrivateState, type SignetContractPrivateState } from "@sig-net/midnight-contract";
|
|
2
|
+
/** Absolute path of the signet contract's `managed/` zk config root. */
|
|
2
3
|
export declare const signetContractManagedPath: string;
|
|
3
4
|
/**
|
|
4
5
|
* The signet-contract compact-js compiled-contract binding: generated module
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-contract-binding.d.ts","sourceRoot":"","sources":["../src/signet-contract-binding.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,QAAQ,EACR,gCAAgC,EAChC,KAAK,0BAA0B,EAChC,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"signet-contract-binding.d.ts","sourceRoot":"","sources":["../src/signet-contract-binding.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,QAAQ,EACR,gCAAgC,EAChC,KAAK,0BAA0B,EAChC,MAAM,4BAA4B,CAAC;AAcpC,wEAAwE;AACxE,eAAO,MAAM,yBAAyB,QAGrC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,oOAGc,CAAC;AAI1D,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
|
|
@@ -16,6 +16,7 @@ import { makeVacantCompiledContract } from "./plumbing/deploy.js";
|
|
|
16
16
|
// needs `yarn compile:zk` output first). createRequire rather than
|
|
17
17
|
// `import.meta.resolve` because vitest's module runner does not implement
|
|
18
18
|
// the latter; the CJS resolver honors the same exports map.
|
|
19
|
+
/** Absolute path of the signet contract's `managed/` zk config root. */
|
|
19
20
|
export const signetContractManagedPath = join(dirname(createRequire(import.meta.url).resolve("@sig-net/midnight-contract")), "managed");
|
|
20
21
|
/**
|
|
21
22
|
* The signet-contract compact-js compiled-contract binding: generated module
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signet-contract-binding.js","sourceRoot":"","sources":["../src/signet-contract-binding.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yEAAyE;AACzE,wEAAwE;AACxE,mDAAmD;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EACL,QAAQ,EACR,gCAAgC,GAEjC,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"signet-contract-binding.js","sourceRoot":"","sources":["../src/signet-contract-binding.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yEAAyE;AACzE,wEAAwE;AACxE,mDAAmD;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EACL,QAAQ,EACR,gCAAgC,GAEjC,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE,6EAA6E;AAC7E,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,mEAAmE;AACnE,0EAA0E;AAC1E,4DAA4D;AAC5D,wEAAwE;AACxE,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAC3C,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAC,EAC7E,SAAS,CACV,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,0BAA0B,CAGtE,iBAAiB,EAAE,QAAQ,EAAE,yBAAyB,CAAC,CAAC;AAE1D,4EAA4E;AAC5E,4CAA4C;AAC5C,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sig-net/midnight-contract-deploy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0-rc.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sig-net/midnight-integration",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@effect/platform-node": "^0.107.0",
|
|
40
|
-
"@midnight-ntwrk/compact-js": "2.5.5-rc.
|
|
41
|
-
"@midnight-ntwrk/compact-js-node": "2.5.5-rc.
|
|
42
|
-
"@midnight-ntwrk/midnight-js": "5.0.0-beta.
|
|
40
|
+
"@midnight-ntwrk/compact-js": "2.5.5-rc.7",
|
|
41
|
+
"@midnight-ntwrk/compact-js-node": "2.5.5-rc.7",
|
|
42
|
+
"@midnight-ntwrk/midnight-js": "5.0.0-beta.6",
|
|
43
43
|
"@midnight-ntwrk/platform-js": "^3.0.0",
|
|
44
44
|
"@midnightntwrk/ledger-v9": "1.0.0-rc.3",
|
|
45
45
|
"@midnightntwrk/wallet-sdk-abstractions": "3.0.0-beta.0",
|
|
@@ -50,14 +50,15 @@
|
|
|
50
50
|
"@midnightntwrk/wallet-sdk-shielded": "4.0.0-beta.2",
|
|
51
51
|
"@midnightntwrk/wallet-sdk-unshielded-wallet": "4.0.0-beta.2",
|
|
52
52
|
"@scure/bip39": "^2.2.0",
|
|
53
|
-
"@sig-net/midnight": "^0.
|
|
54
|
-
"@sig-net/midnight-contract": "^0.
|
|
53
|
+
"@sig-net/midnight": "^0.20.0-rc.1",
|
|
54
|
+
"@sig-net/midnight-contract": "^0.20.0-rc.1",
|
|
55
55
|
"effect": "^3.21.4"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/node": "^26.1.0",
|
|
59
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
59
60
|
"tsx": "^4.23.0",
|
|
60
|
-
"typescript": "^
|
|
61
|
+
"typescript": "^7.0.2",
|
|
61
62
|
"vitest": "^4.1.9"
|
|
62
63
|
},
|
|
63
64
|
"main": "./dist/index.js",
|