@sig-net/midnight-contract-deploy 0.21.0-rc.2 → 0.21.0-rc.6
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 +8 -0
- package/dist/deploy-signet-contract.d.ts +7 -2
- package/dist/deploy-signet-contract.d.ts.map +1 -1
- package/dist/deploy-signet-contract.js +11 -4
- package/dist/deploy-signet-contract.js.map +1 -1
- package/dist/plumbing/deploy.d.ts +0 -22
- package/dist/plumbing/deploy.d.ts.map +1 -1
- package/dist/plumbing/deploy.js +0 -36
- package/dist/plumbing/deploy.js.map +1 -1
- package/dist/plumbing/funding.d.ts +44 -17
- package/dist/plumbing/funding.d.ts.map +1 -1
- package/dist/plumbing/funding.js +62 -24
- package/dist/plumbing/funding.js.map +1 -1
- package/dist/plumbing/midnight-node-config.d.ts +15 -9
- package/dist/plumbing/midnight-node-config.d.ts.map +1 -1
- package/dist/plumbing/midnight-node-config.js +26 -46
- package/dist/plumbing/midnight-node-config.js.map +1 -1
- package/dist/plumbing/wallet.d.ts +2 -1
- package/dist/plumbing/wallet.d.ts.map +1 -1
- package/dist/plumbing/wallet.js +49 -3
- package/dist/plumbing/wallet.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -32,6 +32,14 @@ const { contractAddress, txId } = await deploySignetContract(process.env);
|
|
|
32
32
|
|
|
33
33
|
The generic plumbing (network config, wallets, funding, transaction submission) is exported from the package root as well, for deploy scripts of other Compact contracts.
|
|
34
34
|
|
|
35
|
+
## Deploying from CI
|
|
36
|
+
|
|
37
|
+
The [sig-net/midnight-integration](https://github.com/sig-net/midnight-integration) repository deploys the singleton through its manually dispatched `deploy` workflow, which picks a network and a release tag and runs this flow on a runner with a local proof server.
|
|
38
|
+
|
|
39
|
+
- **The wallet needs faucet-funded NIGHT and nothing else.** The flow registers that NIGHT for dust generation and waits for the first spendable DUST, so a freshly funded seed works on the first run. A run whose wallet holds no NIGHT yet fails printing the wallet's NIGHT receive address (`mn_addr…`) and the network's faucet URL, ready to paste into the faucet.
|
|
40
|
+
- **The deployed address is recorded by a bot PR.** The workflow writes it into the `signetContractAddresses` table of [`@sig-net/midnight`](https://www.npmjs.com/package/@sig-net/midnight) and opens a pull request, so a human reviews the address before it ships to npm consumers.
|
|
41
|
+
- **A deploy sets NO contract maintenance authority.** The maintenance signing key is sampled and dropped, so a deployed contract can never be updated: every run creates a fresh, permanent contract instance, and moving forward means a new deployment while the existing contracts stay exactly as they are.
|
|
42
|
+
|
|
35
43
|
## Documentation
|
|
36
44
|
|
|
37
45
|
The deployed contract is the singleton of the [sign bidirectional flow](https://github.com/sig-net/midnight-integration/blob/main/README.md#sign-bidirectional-flow), documented in the [sig-net/midnight-integration README](https://github.com/sig-net/midnight-integration/blob/main/README.md).
|
|
@@ -10,12 +10,17 @@ export interface SignetContractDeployment {
|
|
|
10
10
|
* Deploy the signet contract: read config from `env`, build and prove the
|
|
11
11
|
* deploy transaction and submit it through a synced wallet. Progress is
|
|
12
12
|
* logged to the console. The contract takes no constructor arguments. Any
|
|
13
|
-
* funded wallet can deploy
|
|
13
|
+
* funded wallet can deploy, and nothing about the deployer is sealed. The wallet
|
|
14
|
+
* needs NIGHT only: {@link ensureFeeReady} registers it for dust generation
|
|
15
|
+
* and waits for the first spendable DUST when the wallet has none yet.
|
|
14
16
|
*
|
|
15
17
|
* @param env - Environment map providing `DEPLOYER_SEED` and the shared
|
|
16
18
|
* Midnight node configuration (see `getMidnightNodeConfig`).
|
|
17
19
|
* @returns The deployed contract address and deploy transaction id.
|
|
18
|
-
* @throws {
|
|
20
|
+
* @throws {WalletUnfundedError} If the deployer wallet holds neither NIGHT
|
|
21
|
+
* nor DUST: the error carries the wallet's NIGHT receive address to fund.
|
|
22
|
+
* @throws {Error} If no spendable DUST appears after registering the wallet's
|
|
23
|
+
* NIGHT, or submission fails.
|
|
19
24
|
*/
|
|
20
25
|
export declare function deploySignetContract(env?: Record<string, string | undefined>): Promise<SignetContractDeployment>;
|
|
21
26
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"deploy-signet-contract.d.ts","sourceRoot":"","sources":["../src/deploy-signet-contract.ts"],"names":[],"mappings":"AAWA,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;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,OAAO,CAAC,wBAAwB,CAAC,CAqCnC"}
|
|
@@ -5,19 +5,26 @@
|
|
|
5
5
|
// events: verification is the reader's job). Requires the contract
|
|
6
6
|
// package's compiled assets to carry keys (its published dist/managed
|
|
7
7
|
// always does; an in-repo checkout needs `yarn compile:zk`).
|
|
8
|
-
import {
|
|
8
|
+
import { buildDeployTransaction, getDeployConfig } from "./plumbing/deploy.js";
|
|
9
|
+
import { ensureFeeReady } from "./plumbing/funding.js";
|
|
10
|
+
import { getFaucetUrl } from "./plumbing/midnight-node-config.js";
|
|
9
11
|
import { deriveAccountKeys, submitUnprovenTransaction, withSyncedWalletFacade, } from "./plumbing/wallet.js";
|
|
10
12
|
import { createSignetContractPrivateState, signetContractCompiledContract, } from "./signet-contract-binding.js";
|
|
11
13
|
/**
|
|
12
14
|
* Deploy the signet contract: read config from `env`, build and prove the
|
|
13
15
|
* deploy transaction and submit it through a synced wallet. Progress is
|
|
14
16
|
* logged to the console. The contract takes no constructor arguments. Any
|
|
15
|
-
* funded wallet can deploy
|
|
17
|
+
* funded wallet can deploy, and nothing about the deployer is sealed. The wallet
|
|
18
|
+
* needs NIGHT only: {@link ensureFeeReady} registers it for dust generation
|
|
19
|
+
* and waits for the first spendable DUST when the wallet has none yet.
|
|
16
20
|
*
|
|
17
21
|
* @param env - Environment map providing `DEPLOYER_SEED` and the shared
|
|
18
22
|
* Midnight node configuration (see `getMidnightNodeConfig`).
|
|
19
23
|
* @returns The deployed contract address and deploy transaction id.
|
|
20
|
-
* @throws {
|
|
24
|
+
* @throws {WalletUnfundedError} If the deployer wallet holds neither NIGHT
|
|
25
|
+
* nor DUST: the error carries the wallet's NIGHT receive address to fund.
|
|
26
|
+
* @throws {Error} If no spendable DUST appears after registering the wallet's
|
|
27
|
+
* NIGHT, or submission fails.
|
|
21
28
|
*/
|
|
22
29
|
export async function deploySignetContract(env = process.env) {
|
|
23
30
|
const deployConfig = getDeployConfig(env);
|
|
@@ -25,7 +32,7 @@ export async function deploySignetContract(env = process.env) {
|
|
|
25
32
|
const accountKeys = deriveAccountKeys(deployConfig.deployerSeed, networkId);
|
|
26
33
|
console.log(`deploying signet-contract to ${networkId} (${deployConfig.midnightNodeConfig.nodeUrl})`);
|
|
27
34
|
const { contractAddress, txId } = await withSyncedWalletFacade(accountKeys, deployConfig.midnightNodeConfig, async (facade, state) => {
|
|
28
|
-
|
|
35
|
+
await ensureFeeReady(facade, accountKeys, state, networkId, getFaucetUrl(env, networkId));
|
|
29
36
|
const deployTransaction = await buildDeployTransaction(signetContractCompiledContract, networkId, accountKeys.shieldedSecretKeys.coinPublicKey, createSignetContractPrivateState());
|
|
30
37
|
console.log(`contract address (pre-submit): ${deployTransaction.contractAddress}`);
|
|
31
38
|
const submittedTxId = await submitUnprovenTransaction(facade, accountKeys, deployTransaction.serializedTransaction);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-signet-contract.js","sourceRoot":"","sources":["../src/deploy-signet-contract.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,0EAA0E;AAC1E,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GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;QAE1F,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"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CompiledContract, type Contract } from "@midnight-ntwrk/compact-js/effect";
|
|
2
|
-
import type { FacadeState } from "@midnightntwrk/wallet-sdk-facade";
|
|
3
2
|
import { type Types } from "effect";
|
|
4
3
|
import { type MidnightNodeConfig } from "./midnight-node-config.ts";
|
|
5
4
|
import { type NetworkId } from "./network-id.ts";
|
|
@@ -59,19 +58,6 @@ export declare function makeCompiledContract<C extends Contract.Contract<PS>, PS
|
|
|
59
58
|
* @returns The fully-bound {@link CompiledContract.CompiledContract}, ready for {@link buildDeployTransaction}.
|
|
60
59
|
*/
|
|
61
60
|
export declare function makeVacantCompiledContract<C extends Contract.Contract<PS>, PS>(tag: string, ctor: Types.Ctor<C>, managedDirPath: string): CompiledContract.CompiledContract<C, PS>;
|
|
62
|
-
/**
|
|
63
|
-
* Convert a contract address (hex, optional `0x`) into the reference shape a
|
|
64
|
-
* Compact contract-typed constructor arg expects: `{ bytes: Uint8Array(32) }`.
|
|
65
|
-
* Deploy scripts use this to seal a cross-contract reference (e.g. the
|
|
66
|
-
* central signet contract) read from the environment.
|
|
67
|
-
*
|
|
68
|
-
* @param contractAddress - The 32-byte contract address in hex.
|
|
69
|
-
* @returns The `{ bytes }` reference.
|
|
70
|
-
* @throws {Error} If the address is not 32 bytes of hex.
|
|
71
|
-
*/
|
|
72
|
-
export declare function contractAddressToReference(contractAddress: string): {
|
|
73
|
-
bytes: Uint8Array;
|
|
74
|
-
};
|
|
75
61
|
/**
|
|
76
62
|
* Build an UNPROVEN contract-deploy transaction: run the Compact constructor
|
|
77
63
|
* with `constructorArgs`, attach the verifier keys from the compiled assets,
|
|
@@ -89,12 +75,4 @@ export declare function contractAddressToReference(contractAddress: string): {
|
|
|
89
75
|
* compiled assets (run `compile:zk` — the default `--skip-zk` output has none).
|
|
90
76
|
*/
|
|
91
77
|
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>;
|
|
92
|
-
/**
|
|
93
|
-
* Fail fast when the deployer wallet cannot pay for a transaction: fees are
|
|
94
|
-
* paid in DUST, which only generates on NIGHT registered for dust generation.
|
|
95
|
-
*
|
|
96
|
-
* @param state - The synced facade state to inspect (see `withSyncedWalletFacade` in wallet.ts).
|
|
97
|
-
* @throws {Error} If the deployer's spendable DUST balance is zero.
|
|
98
|
-
*/
|
|
99
|
-
export declare function assertDeployerFunded(state: FacadeState): void;
|
|
100
78
|
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/plumbing/deploy.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,gBAAgB,EAChB,KAAK,QAAQ,EAEd,MAAM,mCAAm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;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,EAC5E,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EACnB,cAAc,EAAE,MAAM,GACrB,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,CAI1C;AAKD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,SAAS,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,EAC9E,gBAAgB,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,EAC1D,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,MAAM,EACxB,mBAAmB,EAAE,EAAE,EACvB,GAAG,eAAe,EAAE,QAAQ,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAC5D,OAAO,CAAC,iBAAiB,CAAC,CA0C5B"}
|
package/dist/plumbing/deploy.js
CHANGED
|
@@ -109,27 +109,6 @@ export function makeVacantCompiledContract(tag, ctor, managedDirPath) {
|
|
|
109
109
|
const vacant = CompiledContract.withVacantWitnesses(base);
|
|
110
110
|
return CompiledContract.withCompiledFileAssets(vacant, managedDirPath);
|
|
111
111
|
}
|
|
112
|
-
/**
|
|
113
|
-
* Convert a contract address (hex, optional `0x`) into the reference shape a
|
|
114
|
-
* Compact contract-typed constructor arg expects: `{ bytes: Uint8Array(32) }`.
|
|
115
|
-
* Deploy scripts use this to seal a cross-contract reference (e.g. the
|
|
116
|
-
* central signet contract) read from the environment.
|
|
117
|
-
*
|
|
118
|
-
* @param contractAddress - The 32-byte contract address in hex.
|
|
119
|
-
* @returns The `{ bytes }` reference.
|
|
120
|
-
* @throws {Error} If the address is not 32 bytes of hex.
|
|
121
|
-
*/
|
|
122
|
-
export function contractAddressToReference(contractAddress) {
|
|
123
|
-
const hex = contractAddress.startsWith("0x") ? contractAddress.slice(2) : contractAddress;
|
|
124
|
-
if (!/^[0-9a-fA-F]{64}$/.test(hex)) {
|
|
125
|
-
throw new Error(`not a 32-byte contract address in hex: "${contractAddress}"`);
|
|
126
|
-
}
|
|
127
|
-
const bytes = new Uint8Array(32);
|
|
128
|
-
for (let i = 0; i < 32; i++) {
|
|
129
|
-
bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
130
|
-
}
|
|
131
|
-
return { bytes };
|
|
132
|
-
}
|
|
133
112
|
// How long the deploy intent stays valid before it must be re-built.
|
|
134
113
|
const DEPLOY_TTL_MS = 30 * 60 * 1000;
|
|
135
114
|
/**
|
|
@@ -172,19 +151,4 @@ export async function buildDeployTransaction(compiledContract, networkId, coinPu
|
|
|
172
151
|
serializedTransaction: transaction.serialize(),
|
|
173
152
|
};
|
|
174
153
|
}
|
|
175
|
-
/**
|
|
176
|
-
* Fail fast when the deployer wallet cannot pay for a transaction: fees are
|
|
177
|
-
* paid in DUST, which only generates on NIGHT registered for dust generation.
|
|
178
|
-
*
|
|
179
|
-
* @param state - The synced facade state to inspect (see `withSyncedWalletFacade` in wallet.ts).
|
|
180
|
-
* @throws {Error} If the deployer's spendable DUST balance is zero.
|
|
181
|
-
*/
|
|
182
|
-
export function assertDeployerFunded(state) {
|
|
183
|
-
const dust = state.dust.balance(new Date());
|
|
184
|
-
if (dust > 0n)
|
|
185
|
-
return;
|
|
186
|
-
const night = Object.values(state.unshielded.balances).reduce((sum, value) => sum + value, 0n);
|
|
187
|
-
throw new Error(`deployer wallet has no DUST to pay fees (NIGHT balance: ${String(night)}). ` +
|
|
188
|
-
"Fund the wallet with NIGHT and register it for dust generation, then retry.");
|
|
189
|
-
}
|
|
190
154
|
//# sourceMappingURL=deploy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/plumbing/deploy.ts"],"names":[],"mappings":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AgB,CAAC;SACtC,UAAU,CAAC,mBAAmB,EAAE,GAAG,eAAe,CAAC;SACnD,IAAI,CACH,MAAM,CAAC,OAAO,CACZ,mBAAmB,CAAC,KAAK,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC,CACpF,EACD,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,EACjC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAC1B,CACJ,CAAC;IAEF,yEAAyE;IACzE,0EAA0E;IAC1E,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC,WAAW,CACpD,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,CAC9C,CAAC;IAEF,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MidnightNodeConfig } from "./midnight-node-config.ts";
|
|
2
|
-
import { type
|
|
2
|
+
import { type NetworkId } from "./network-id.ts";
|
|
3
|
+
import { type AccountKeys, type FacadeState, type WalletAddresses, type WalletFacade } from "./wallet.ts";
|
|
3
4
|
/** A wallet's synced funding snapshot: its addresses and NIGHT/DUST balances (base units). */
|
|
4
5
|
export interface AccountFunding {
|
|
5
6
|
/** The wallet's three bech32m addresses (network-prefixed). */
|
|
@@ -34,11 +35,13 @@ export declare function readAccountFunding(config: MidnightNodeConfig, seed: str
|
|
|
34
35
|
*/
|
|
35
36
|
export declare function isFeeReady(funding: AccountFunding): boolean;
|
|
36
37
|
/**
|
|
37
|
-
*
|
|
38
|
-
* receive address is
|
|
39
|
-
*
|
|
38
|
+
* A wallet holds no NIGHT and no DUST, so it cannot pay fees until its NIGHT
|
|
39
|
+
* receive address is funded (on a deployed network, via the network's
|
|
40
|
+
* faucet). Thrown by {@link ensureFeeReady} and {@link assertRootFunded},
|
|
41
|
+
* carrying the exact address and faucet URL to act on, so a setup pipeline
|
|
42
|
+
* can STOP printing them.
|
|
40
43
|
*/
|
|
41
|
-
export declare class
|
|
44
|
+
export declare class WalletUnfundedError extends Error {
|
|
42
45
|
readonly nightAddress: string;
|
|
43
46
|
readonly faucetUrl: string | undefined;
|
|
44
47
|
/**
|
|
@@ -47,32 +50,56 @@ export declare class RootUnfundedError extends Error {
|
|
|
47
50
|
*/
|
|
48
51
|
constructor(nightAddress: string, faucetUrl: string | undefined);
|
|
49
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Bring one wallet to fee-ready and return its spendable DUST balance. Fees
|
|
55
|
+
* are paid in DUST, which only generates on NIGHT registered for dust
|
|
56
|
+
* generation, so every unregistered NIGHT UTXO the wallet holds is registered
|
|
57
|
+
* here first, whatever its current dust: a faucet top-up or transfer change
|
|
58
|
+
* arrives unregistered, and leaving it so while older dust lasts would let
|
|
59
|
+
* the wallet's dust generation shrink with every spend. Then a wallet with
|
|
60
|
+
* spendable dust returns it, and one without waits until its first dust
|
|
61
|
+
* appears (a few blocks). The facade must be started and synced, and `state`
|
|
62
|
+
* must be its synced state (see `withSyncedWalletFacade` in wallet.ts).
|
|
63
|
+
*
|
|
64
|
+
* @param facade - A started wallet facade for `keys`, which submits the registration.
|
|
65
|
+
* @param keys - The key material of the same wallet. Its keystore signs the registration.
|
|
66
|
+
* @param state - The synced facade state the balances and NIGHT UTXOs are read from.
|
|
67
|
+
* @param networkId - The network the wallet lives on, which prefixes the
|
|
68
|
+
* NIGHT receive address the no-NIGHT error prints for faucet funding.
|
|
69
|
+
* @param faucetUrl - The network's faucet for the no-NIGHT hint, when one is known.
|
|
70
|
+
* @returns The wallet's spendable DUST balance, always positive.
|
|
71
|
+
* @throws {WalletUnfundedError} If the wallet holds neither NIGHT nor DUST.
|
|
72
|
+
* @throws {Error} If no dust appears in time after registration (see
|
|
73
|
+
* {@link waitForSpendableDust}).
|
|
74
|
+
*/
|
|
75
|
+
export declare function ensureFeeReady(facade: WalletFacade, keys: AccountKeys, state: FacadeState, networkId: NetworkId, faucetUrl?: string): Promise<bigint>;
|
|
50
76
|
/**
|
|
51
77
|
* Ensure the root wallet is fee-ready, returning its snapshot. Root holds no
|
|
52
78
|
* NIGHT on a deployed network before faucet funding, so this throws
|
|
53
|
-
* {@link
|
|
79
|
+
* {@link WalletUnfundedError} (NIGHT address + faucet URL) when NIGHT is zero.
|
|
54
80
|
* On the local standalone chain, where genesis funds root by construction, a
|
|
55
81
|
* zero balance is instead retried until the indexer catches up (see
|
|
56
|
-
* {@link GENESIS_INDEX_TIMEOUT_MS}).
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* no DUST to spend.
|
|
82
|
+
* {@link GENESIS_INDEX_TIMEOUT_MS}). Root pays the children's funding
|
|
83
|
+
* transfers in DUST, so with NIGHT proven present it finishes through
|
|
84
|
+
* {@link ensureFeeReady}: a faucet-funded root needs its NIGHT registered for
|
|
85
|
+
* dust generation before it holds any spendable DUST.
|
|
61
86
|
*
|
|
62
87
|
* @param config - The stack the root wallet connects to.
|
|
63
88
|
* @param rootSeed - The root wallet seed.
|
|
64
89
|
* @param faucetUrl - The network's faucet URL for the underfunded message.
|
|
65
90
|
* @returns The root's fee-ready funding snapshot.
|
|
66
|
-
* @throws {
|
|
67
|
-
*
|
|
91
|
+
* @throws {WalletUnfundedError} If root holds no NIGHT.
|
|
92
|
+
* @throws {Error} If no dust appears in time after registration (see
|
|
93
|
+
* {@link waitForSpendableDust}): root is funded but not yet fee-ready, so
|
|
94
|
+
* this is a plain error, not a funding stop.
|
|
68
95
|
*/
|
|
69
96
|
export declare function assertRootFunded(config: MidnightNodeConfig, rootSeed: string, faucetUrl: string | undefined): Promise<AccountFunding>;
|
|
70
97
|
/**
|
|
71
98
|
* Bring one child wallet to fee-ready by topping it up from root: if it holds
|
|
72
|
-
* no NIGHT, transfer `amount` from root and wait for the child to see it
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
99
|
+
* no NIGHT, transfer `amount` from root and wait for the child to see it, then
|
|
100
|
+
* finish through {@link ensureFeeReady}. A child that already holds NIGHT but
|
|
101
|
+
* no dust yet is only registered and waited on (no transfer). Call only for a
|
|
102
|
+
* child that is not already fee-ready.
|
|
76
103
|
*
|
|
77
104
|
* @param config - The stack both wallets connect to.
|
|
78
105
|
* @param rootSeed - The funding wallet's seed.
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"funding.d.ts","sourceRoot":"","sources":["../../src/plumbing/funding.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAA4B,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EACL,KAAK,WAAW,EAGhB,KAAK,WAAW,EAIhB,KAAK,eAAe,EACpB,KAAK,YAAY,EAElB,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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 +57,13 @@ export function isFeeReady(funding) {
|
|
|
57
57
|
return funding.night > 0n && funding.dust > 0n;
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
61
|
-
* receive address is
|
|
62
|
-
*
|
|
60
|
+
* A wallet holds no NIGHT and no DUST, so it cannot pay fees until its NIGHT
|
|
61
|
+
* receive address is funded (on a deployed network, via the network's
|
|
62
|
+
* faucet). Thrown by {@link ensureFeeReady} and {@link assertRootFunded},
|
|
63
|
+
* carrying the exact address and faucet URL to act on, so a setup pipeline
|
|
64
|
+
* can STOP printing them.
|
|
63
65
|
*/
|
|
64
|
-
export class
|
|
66
|
+
export class WalletUnfundedError extends Error {
|
|
65
67
|
nightAddress;
|
|
66
68
|
faucetUrl;
|
|
67
69
|
/**
|
|
@@ -70,14 +72,52 @@ export class RootUnfundedError extends Error {
|
|
|
70
72
|
*/
|
|
71
73
|
constructor(nightAddress, faucetUrl) {
|
|
72
74
|
const where = faucetUrl ? `at ${faucetUrl}` : "via the network's faucet";
|
|
73
|
-
super(`
|
|
75
|
+
super(`wallet holds no NIGHT and so cannot generate the DUST that pays fees. Fund it ${where}, then retry.\n` +
|
|
74
76
|
` NIGHT address: ${nightAddress}` +
|
|
75
77
|
(faucetUrl ? `\n faucet: ${faucetUrl}` : ""));
|
|
76
78
|
this.nightAddress = nightAddress;
|
|
77
79
|
this.faucetUrl = faucetUrl;
|
|
78
|
-
this.name = "
|
|
80
|
+
this.name = "WalletUnfundedError";
|
|
79
81
|
}
|
|
80
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Bring one wallet to fee-ready and return its spendable DUST balance. Fees
|
|
85
|
+
* are paid in DUST, which only generates on NIGHT registered for dust
|
|
86
|
+
* generation, so every unregistered NIGHT UTXO the wallet holds is registered
|
|
87
|
+
* here first, whatever its current dust: a faucet top-up or transfer change
|
|
88
|
+
* arrives unregistered, and leaving it so while older dust lasts would let
|
|
89
|
+
* the wallet's dust generation shrink with every spend. Then a wallet with
|
|
90
|
+
* spendable dust returns it, and one without waits until its first dust
|
|
91
|
+
* appears (a few blocks). The facade must be started and synced, and `state`
|
|
92
|
+
* must be its synced state (see `withSyncedWalletFacade` in wallet.ts).
|
|
93
|
+
*
|
|
94
|
+
* @param facade - A started wallet facade for `keys`, which submits the registration.
|
|
95
|
+
* @param keys - The key material of the same wallet. Its keystore signs the registration.
|
|
96
|
+
* @param state - The synced facade state the balances and NIGHT UTXOs are read from.
|
|
97
|
+
* @param networkId - The network the wallet lives on, which prefixes the
|
|
98
|
+
* NIGHT receive address the no-NIGHT error prints for faucet funding.
|
|
99
|
+
* @param faucetUrl - The network's faucet for the no-NIGHT hint, when one is known.
|
|
100
|
+
* @returns The wallet's spendable DUST balance, always positive.
|
|
101
|
+
* @throws {WalletUnfundedError} If the wallet holds neither NIGHT nor DUST.
|
|
102
|
+
* @throws {Error} If no dust appears in time after registration (see
|
|
103
|
+
* {@link waitForSpendableDust}).
|
|
104
|
+
*/
|
|
105
|
+
export async function ensureFeeReady(facade, keys, state, networkId, faucetUrl) {
|
|
106
|
+
const dust = state.dust.balance(new Date());
|
|
107
|
+
if (totalNight(state) === 0n) {
|
|
108
|
+
if (dust > 0n)
|
|
109
|
+
return dust;
|
|
110
|
+
throw new WalletUnfundedError(deriveAddresses(keys, networkId).unshielded, faucetUrl);
|
|
111
|
+
}
|
|
112
|
+
const registered = await registerNightForDustGeneration(facade, keys, state);
|
|
113
|
+
if (registered > 0) {
|
|
114
|
+
console.log(`registered ${String(registered)} NIGHT UTXO(s) for dust generation`);
|
|
115
|
+
}
|
|
116
|
+
if (dust > 0n)
|
|
117
|
+
return dust;
|
|
118
|
+
console.log("waiting for spendable DUST...");
|
|
119
|
+
return waitForSpendableDust(facade);
|
|
120
|
+
}
|
|
81
121
|
// A freshly composed local stack has a window where the indexer reports a
|
|
82
122
|
// synced (empty) state before it has indexed the genesis block that funds the
|
|
83
123
|
// genesis mint wallet — so a zero root balance there means "not indexed yet",
|
|
@@ -87,21 +127,22 @@ const GENESIS_INDEX_TIMEOUT_MS = 120_000;
|
|
|
87
127
|
/**
|
|
88
128
|
* Ensure the root wallet is fee-ready, returning its snapshot. Root holds no
|
|
89
129
|
* NIGHT on a deployed network before faucet funding, so this throws
|
|
90
|
-
* {@link
|
|
130
|
+
* {@link WalletUnfundedError} (NIGHT address + faucet URL) when NIGHT is zero.
|
|
91
131
|
* On the local standalone chain, where genesis funds root by construction, a
|
|
92
132
|
* zero balance is instead retried until the indexer catches up (see
|
|
93
|
-
* {@link GENESIS_INDEX_TIMEOUT_MS}).
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* no DUST to spend.
|
|
133
|
+
* {@link GENESIS_INDEX_TIMEOUT_MS}). Root pays the children's funding
|
|
134
|
+
* transfers in DUST, so with NIGHT proven present it finishes through
|
|
135
|
+
* {@link ensureFeeReady}: a faucet-funded root needs its NIGHT registered for
|
|
136
|
+
* dust generation before it holds any spendable DUST.
|
|
98
137
|
*
|
|
99
138
|
* @param config - The stack the root wallet connects to.
|
|
100
139
|
* @param rootSeed - The root wallet seed.
|
|
101
140
|
* @param faucetUrl - The network's faucet URL for the underfunded message.
|
|
102
141
|
* @returns The root's fee-ready funding snapshot.
|
|
103
|
-
* @throws {
|
|
104
|
-
*
|
|
142
|
+
* @throws {WalletUnfundedError} If root holds no NIGHT.
|
|
143
|
+
* @throws {Error} If no dust appears in time after registration (see
|
|
144
|
+
* {@link waitForSpendableDust}): root is funded but not yet fee-ready, so
|
|
145
|
+
* this is a plain error, not a funding stop.
|
|
105
146
|
*/
|
|
106
147
|
export async function assertRootFunded(config, rootSeed, faucetUrl) {
|
|
107
148
|
const keys = deriveAccountKeys(rootSeed, config.networkId);
|
|
@@ -117,20 +158,18 @@ export async function assertRootFunded(config, rootSeed, faucetUrl) {
|
|
|
117
158
|
}
|
|
118
159
|
}
|
|
119
160
|
if (night === 0n) {
|
|
120
|
-
throw new
|
|
161
|
+
throw new WalletUnfundedError(addresses.unshielded, faucetUrl);
|
|
121
162
|
}
|
|
122
|
-
await
|
|
123
|
-
const dustNow = state.dust.balance(new Date());
|
|
124
|
-
const dust = dustNow > 0n ? dustNow : await waitForSpendableDust(facade);
|
|
163
|
+
const dust = await ensureFeeReady(facade, keys, state, config.networkId, faucetUrl);
|
|
125
164
|
return { addresses, night, dust };
|
|
126
165
|
});
|
|
127
166
|
}
|
|
128
167
|
/**
|
|
129
168
|
* Bring one child wallet to fee-ready by topping it up from root: if it holds
|
|
130
|
-
* no NIGHT, transfer `amount` from root and wait for the child to see it
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
169
|
+
* no NIGHT, transfer `amount` from root and wait for the child to see it, then
|
|
170
|
+
* finish through {@link ensureFeeReady}. A child that already holds NIGHT but
|
|
171
|
+
* no dust yet is only registered and waited on (no transfer). Call only for a
|
|
172
|
+
* child that is not already fee-ready.
|
|
134
173
|
*
|
|
135
174
|
* @param config - The stack both wallets connect to.
|
|
136
175
|
* @param rootSeed - The funding wallet's seed.
|
|
@@ -159,8 +198,7 @@ export async function fundChildFromRoot(config, rootSeed, childSeed, amount) {
|
|
|
159
198
|
if (totalNight(state) === 0n) {
|
|
160
199
|
throw new Error(`child wallet ${childAddresses.unshielded} shows no NIGHT after funding from root`);
|
|
161
200
|
}
|
|
162
|
-
await
|
|
163
|
-
const dust = await waitForSpendableDust(childFacade);
|
|
201
|
+
const dust = await ensureFeeReady(childFacade, childKeys, state, config.networkId);
|
|
164
202
|
return { addresses: childAddresses, night: totalNight(state), dust };
|
|
165
203
|
});
|
|
166
204
|
}
|
|
@@ -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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AAE,SAAS,EAAE,EAAE;YAC7E,MAAM,aAAa,CACjB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,cAAc,CAAC,UAAU,EACzB,MAAM,CAAC,SAAS,EAChB,MAAM,CACP,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;QACjF,0EAA0E;QAC1E,IAAI,KAAK,GAAG,UAAU,CAAC;QACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YACxD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;YAC3D,KAAK,GAAG,MAAM,WAAW,CAAC,kBAAkB,EAAE,CAAC;QACjD,CAAC;QACD,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,gBAAgB,cAAc,CAAC,UAAU,yCAAyC,CACnF,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACnF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -18,7 +18,15 @@ export type Endpoints = Omit<MidnightNodeConfig, "networkId">;
|
|
|
18
18
|
export declare const LOCAL_PROOF_SERVER = "http://127.0.0.1:6300";
|
|
19
19
|
/** Baseline endpoints per network, before any environment override. */
|
|
20
20
|
export declare const DEFAULT_ENDPOINTS: Record<NetworkId, Endpoints>;
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Faucet URLs per test network, for the fund-your-wallet hint: stagenet's
|
|
23
|
+
* own faucet, and the Nethermind-hosted Midnight faucets for preview and
|
|
24
|
+
* preprod. Mainnet carries real value and has no faucet, and the local
|
|
25
|
+
* standalone chain funds via genesis, so neither has an entry. The
|
|
26
|
+
* MIDNIGHT_FAUCET_URL environment variable overrides any entry and supplies
|
|
27
|
+
* one where there is none (see {@link getFaucetUrl}), and without either the
|
|
28
|
+
* hint degrades to a generic "fund via the network's faucet".
|
|
29
|
+
*/
|
|
22
30
|
export declare const FAUCET_URLS: Partial<Record<NetworkId, string>>;
|
|
23
31
|
/**
|
|
24
32
|
* The faucet URL to show in underfunded-wallet hints: `MIDNIGHT_FAUCET_URL`
|
|
@@ -36,10 +44,10 @@ export declare function getFaucetUrl(env: Record<string, string | undefined>, ne
|
|
|
36
44
|
*/
|
|
37
45
|
export declare function indexerWsUrlFromIndexerUrl(indexerUrl: string): string;
|
|
38
46
|
/**
|
|
39
|
-
* Read a {@link MidnightNodeConfig} from the environment.
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
47
|
+
* Read a {@link MidnightNodeConfig} from the environment. Every network has
|
|
48
|
+
* complete built-in endpoints, so with nothing set this yields the local
|
|
49
|
+
* "undeployed" stack, and `NETWORK_ID` alone is enough to reach a deployed
|
|
50
|
+
* network.
|
|
43
51
|
*
|
|
44
52
|
* Parse flow:
|
|
45
53
|
* 1. `NETWORK_ID` (default "undeployed", validated against {@link NETWORK_IDS})
|
|
@@ -48,13 +56,11 @@ export declare function indexerWsUrlFromIndexerUrl(indexerUrl: string): string;
|
|
|
48
56
|
* `MIDNIGHT_NODE_URL`, `MIDNIGHT_NODE_INDEXER_URL`,
|
|
49
57
|
* `MIDNIGHT_NODE_INDEXER_WS_URL`, `MIDNIGHT_NODE_PROOF_SERVER_URL`.
|
|
50
58
|
* When the indexer URL is overridden without a WS override, the WS URL is
|
|
51
|
-
* derived from it
|
|
52
|
-
* 3. Every resolved endpoint must be non-empty.
|
|
59
|
+
* derived from it, keeping the pair on one host.
|
|
53
60
|
*
|
|
54
61
|
* @param env - The environment to read; defaults to `process.env`.
|
|
55
62
|
* @returns The fully resolved node config.
|
|
56
|
-
* @throws {Error} If `NETWORK_ID` is unknown
|
|
57
|
-
* default and no environment override).
|
|
63
|
+
* @throws {Error} If `NETWORK_ID` is unknown.
|
|
58
64
|
*/
|
|
59
65
|
export declare function getMidnightNodeConfig(env?: Record<string, string | undefined>): MidnightNodeConfig;
|
|
60
66
|
//# sourceMappingURL=midnight-node-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAiC1D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAI1D,CAAC;AAEF;;;;;;;;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;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,kBAAkB,CA2BpB"}
|
|
@@ -15,18 +15,12 @@ export const DEFAULT_ENDPOINTS = {
|
|
|
15
15
|
nodeUrl: "http://127.0.0.1:9944",
|
|
16
16
|
proofServerUrl: LOCAL_PROOF_SERVER,
|
|
17
17
|
},
|
|
18
|
-
// Stagenet
|
|
19
|
-
//
|
|
20
|
-
// getMidnightNodeConfig REQUIRES for this network:
|
|
21
|
-
// MIDNIGHT_NODE_URL — node RPC
|
|
22
|
-
// MIDNIGHT_NODE_INDEXER_URL — indexer GraphQL over HTTP (the WS
|
|
23
|
-
// twin derives from it when unset)
|
|
24
|
-
// MIDNIGHT_NODE_INDEXER_WS_URL — indexer GraphQL over WebSocket
|
|
25
|
-
// The proof server stays local (it sees private witness data).
|
|
18
|
+
// Stagenet runs the v4 indexer API, so its indexer paths differ from the
|
|
19
|
+
// v3 paths of the *.midnight.network networks below.
|
|
26
20
|
[MidnightNetwork.Stagenet]: {
|
|
27
|
-
indexerUrl: "",
|
|
28
|
-
indexerWsUrl: "",
|
|
29
|
-
nodeUrl: "",
|
|
21
|
+
indexerUrl: "https://indexer.stagenet.shielded.tools/api/v4/graphql",
|
|
22
|
+
indexerWsUrl: "wss://indexer.stagenet.shielded.tools/api/v4/graphql/ws",
|
|
23
|
+
nodeUrl: "https://rpc.stagenet.shielded.tools",
|
|
30
24
|
proofServerUrl: LOCAL_PROOF_SERVER,
|
|
31
25
|
},
|
|
32
26
|
[MidnightNetwork.Preview]: {
|
|
@@ -48,15 +42,20 @@ export const DEFAULT_ENDPOINTS = {
|
|
|
48
42
|
proofServerUrl: LOCAL_PROOF_SERVER,
|
|
49
43
|
},
|
|
50
44
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Faucet URLs per test network, for the fund-your-wallet hint: stagenet's
|
|
47
|
+
* own faucet, and the Nethermind-hosted Midnight faucets for preview and
|
|
48
|
+
* preprod. Mainnet carries real value and has no faucet, and the local
|
|
49
|
+
* standalone chain funds via genesis, so neither has an entry. The
|
|
50
|
+
* MIDNIGHT_FAUCET_URL environment variable overrides any entry and supplies
|
|
51
|
+
* one where there is none (see {@link getFaucetUrl}), and without either the
|
|
52
|
+
* hint degrades to a generic "fund via the network's faucet".
|
|
53
|
+
*/
|
|
54
|
+
export const FAUCET_URLS = {
|
|
55
|
+
[MidnightNetwork.Stagenet]: "https://faucet.stagenet.shielded.tools",
|
|
56
|
+
[MidnightNetwork.Preview]: "https://midnight-tmnight-preview.nethermind.dev",
|
|
57
|
+
[MidnightNetwork.Preprod]: "https://midnight-tmnight-preprod.nethermind.dev",
|
|
58
|
+
};
|
|
60
59
|
/**
|
|
61
60
|
* The faucet URL to show in underfunded-wallet hints: `MIDNIGHT_FAUCET_URL`
|
|
62
61
|
* from the environment when set, else the network's {@link FAUCET_URLS}
|
|
@@ -82,10 +81,10 @@ export function indexerWsUrlFromIndexerUrl(indexerUrl) {
|
|
|
82
81
|
return url.toString();
|
|
83
82
|
}
|
|
84
83
|
/**
|
|
85
|
-
* Read a {@link MidnightNodeConfig} from the environment.
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
84
|
+
* Read a {@link MidnightNodeConfig} from the environment. Every network has
|
|
85
|
+
* complete built-in endpoints, so with nothing set this yields the local
|
|
86
|
+
* "undeployed" stack, and `NETWORK_ID` alone is enough to reach a deployed
|
|
87
|
+
* network.
|
|
89
88
|
*
|
|
90
89
|
* Parse flow:
|
|
91
90
|
* 1. `NETWORK_ID` (default "undeployed", validated against {@link NETWORK_IDS})
|
|
@@ -94,13 +93,11 @@ export function indexerWsUrlFromIndexerUrl(indexerUrl) {
|
|
|
94
93
|
* `MIDNIGHT_NODE_URL`, `MIDNIGHT_NODE_INDEXER_URL`,
|
|
95
94
|
* `MIDNIGHT_NODE_INDEXER_WS_URL`, `MIDNIGHT_NODE_PROOF_SERVER_URL`.
|
|
96
95
|
* When the indexer URL is overridden without a WS override, the WS URL is
|
|
97
|
-
* derived from it
|
|
98
|
-
* 3. Every resolved endpoint must be non-empty.
|
|
96
|
+
* derived from it, keeping the pair on one host.
|
|
99
97
|
*
|
|
100
98
|
* @param env - The environment to read; defaults to `process.env`.
|
|
101
99
|
* @returns The fully resolved node config.
|
|
102
|
-
* @throws {Error} If `NETWORK_ID` is unknown
|
|
103
|
-
* default and no environment override).
|
|
100
|
+
* @throws {Error} If `NETWORK_ID` is unknown.
|
|
104
101
|
*/
|
|
105
102
|
export function getMidnightNodeConfig(env = process.env) {
|
|
106
103
|
const networkId = envOrUndefined(env, "NETWORK_ID") ?? MidnightNetwork.Undeployed;
|
|
@@ -116,29 +113,12 @@ export function getMidnightNodeConfig(env = process.env) {
|
|
|
116
113
|
(indexerOverride === undefined
|
|
117
114
|
? defaults.indexerWsUrl
|
|
118
115
|
: indexerWsUrlFromIndexerUrl(indexerUrl));
|
|
119
|
-
|
|
116
|
+
return {
|
|
120
117
|
networkId,
|
|
121
118
|
indexerUrl,
|
|
122
119
|
indexerWsUrl,
|
|
123
120
|
nodeUrl: envOrUndefined(env, "MIDNIGHT_NODE_URL") ?? defaults.nodeUrl,
|
|
124
121
|
proofServerUrl: envOrUndefined(env, "MIDNIGHT_NODE_PROOF_SERVER_URL") ?? defaults.proofServerUrl,
|
|
125
122
|
};
|
|
126
|
-
// A blank default means the network's endpoints are not published in this
|
|
127
|
-
// repo (stagenet) — the environment must supply them, so fail with the
|
|
128
|
-
// exact variables to set.
|
|
129
|
-
const missing = [];
|
|
130
|
-
if (!config.nodeUrl)
|
|
131
|
-
missing.push("MIDNIGHT_NODE_URL");
|
|
132
|
-
if (!config.indexerUrl)
|
|
133
|
-
missing.push("MIDNIGHT_NODE_INDEXER_URL");
|
|
134
|
-
if (!config.indexerWsUrl)
|
|
135
|
-
missing.push("MIDNIGHT_NODE_INDEXER_WS_URL");
|
|
136
|
-
if (!config.proofServerUrl)
|
|
137
|
-
missing.push("MIDNIGHT_NODE_PROOF_SERVER_URL");
|
|
138
|
-
if (missing.length > 0) {
|
|
139
|
-
throw new Error(`network "${networkId}" has no built-in endpoints in this repo — set ${missing.join(", ")} ` +
|
|
140
|
-
`in the environment (or the repo-root .env).`);
|
|
141
|
-
}
|
|
142
|
-
return config;
|
|
143
123
|
}
|
|
144
124
|
//# sourceMappingURL=midnight-node-config.js.map
|
|
@@ -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,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,kBAAkB;KACnC;IACD,
|
|
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,kBAAkB;KACnC;IACD,yEAAyE;IACzE,qDAAqD;IACrD,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;QAC1B,UAAU,EA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declare function initialiseWalletFacade(keys: AccountKeys, config: Midnig
|
|
|
84
84
|
* @param keys - The key material of the same wallet, for balancing and signing.
|
|
85
85
|
* @param serializedTransaction - The unproven transaction bytes.
|
|
86
86
|
* @returns The submitted transaction's identifier.
|
|
87
|
-
* @throws {Error} If the wallet cannot cover fees
|
|
87
|
+
* @throws {Error} If the wallet still cannot cover fees after the balancing retry
|
|
88
|
+
* budget, proving fails, or the node rejects the transaction.
|
|
88
89
|
*/
|
|
89
90
|
export declare function submitUnprovenTransaction(facade: WalletFacade, keys: AccountKeys, serializedTransaction: Uint8Array): Promise<TransactionIdentifier>;
|
|
90
91
|
/**
|
|
@@ -1 +1 @@
|
|
|
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,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M,CAAC,CAiBjB;AAMD;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,YAAY,EACpB,SAAS,SAAU,GAClB,OAAO,CAAC,MAAM,CAAC,CAajB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAC5C,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,kBAAkB,EAC1B,EAAE,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EAC5D,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,CAAC,CAAC,CAWZ"}
|
package/dist/plumbing/wallet.js
CHANGED
|
@@ -104,6 +104,46 @@ export function initialiseWalletFacade(keys, config, options = {}) {
|
|
|
104
104
|
}
|
|
105
105
|
// Recipes (balancing plans for submitted transactions) expire 30 min out.
|
|
106
106
|
const RECIPE_TTL_MS = 30 * 60 * 1000;
|
|
107
|
+
// Balancing throws Wallet.InsufficientFunds ("could not balance dust") while
|
|
108
|
+
// the paying wallet's DUST is still generating: a young local chain accrues
|
|
109
|
+
// it block by block from the genesis NIGHT, and a freshly registered wallet
|
|
110
|
+
// on a deployed network starts from its first few units. Building the recipe
|
|
111
|
+
// costs no proving, so it is retried in place until the wallet covers the
|
|
112
|
+
// fee. A wallet with nothing to generate from fails fast in ensureFeeReady
|
|
113
|
+
// (funding.ts) before any of this, so the bounded retry cannot mask real
|
|
114
|
+
// underfunding.
|
|
115
|
+
const BALANCE_RETRY_INTERVAL_MS = 15_000;
|
|
116
|
+
const BALANCE_RETRY_TIMEOUT_MS = 6 * 60 * 1000;
|
|
117
|
+
/**
|
|
118
|
+
* Run a recipe-building call, retrying while it fails for lack of DUST. Each
|
|
119
|
+
* retry first waits for the facade to report itself synced again, so the
|
|
120
|
+
* balancer works from the chain tip rather than the view the last attempt
|
|
121
|
+
* failed on.
|
|
122
|
+
*
|
|
123
|
+
* @param facade - The started facade `build` balances with.
|
|
124
|
+
* @param build - The balancing call to (re)attempt.
|
|
125
|
+
* @returns The recipe `build` resolves to.
|
|
126
|
+
* @throws {Error} The last error once {@link BALANCE_RETRY_TIMEOUT_MS} is
|
|
127
|
+
* spent, or immediately for any error other than insufficient dust.
|
|
128
|
+
*/
|
|
129
|
+
async function balanceWhileDustGenerates(facade, build) {
|
|
130
|
+
const deadline = Date.now() + BALANCE_RETRY_TIMEOUT_MS;
|
|
131
|
+
for (;;) {
|
|
132
|
+
try {
|
|
133
|
+
return await build();
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
const message = String(error);
|
|
137
|
+
const insufficientDust = message.includes("InsufficientFunds") || message.includes("could not balance dust");
|
|
138
|
+
if (!insufficientDust || Date.now() >= deadline)
|
|
139
|
+
throw error;
|
|
140
|
+
console.log(`the wallet cannot cover the fee yet (DUST still generating), retrying in ${String(BALANCE_RETRY_INTERVAL_MS / 1000)}s`);
|
|
141
|
+
await new Promise((resolve) => setTimeout(resolve, BALANCE_RETRY_INTERVAL_MS));
|
|
142
|
+
const state = await facade.waitForSyncedState();
|
|
143
|
+
console.log(`wallet resynced, spendable DUST: ${String(state.dust.balance(new Date()))}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
107
147
|
/**
|
|
108
148
|
* Balance, sign, prove and submit a serialized unproven transaction (e.g. a
|
|
109
149
|
* contract deploy built by `buildDeployTransaction` in deploy.ts). Proving
|
|
@@ -113,15 +153,19 @@ const RECIPE_TTL_MS = 30 * 60 * 1000;
|
|
|
113
153
|
* @param keys - The key material of the same wallet, for balancing and signing.
|
|
114
154
|
* @param serializedTransaction - The unproven transaction bytes.
|
|
115
155
|
* @returns The submitted transaction's identifier.
|
|
116
|
-
* @throws {Error} If the wallet cannot cover fees
|
|
156
|
+
* @throws {Error} If the wallet still cannot cover fees after the balancing retry
|
|
157
|
+
* budget, proving fails, or the node rejects the transaction.
|
|
117
158
|
*/
|
|
118
159
|
export async function submitUnprovenTransaction(facade, keys, serializedTransaction) {
|
|
119
160
|
// Deserialize back into the ledger UnprovenTransaction the facade balances.
|
|
120
161
|
const tx = ledger.Transaction.deserialize("signature", "pre-proof", "pre-binding", serializedTransaction);
|
|
121
162
|
// Balance (add dust/fee inputs) → sign those inputs → finalize (prove) → submit.
|
|
122
|
-
|
|
163
|
+
console.log("balancing and signing transaction...");
|
|
164
|
+
const recipe = await balanceWhileDustGenerates(facade, () => facade.balanceUnprovenTransaction(tx, { shieldedSecretKeys: keys.shieldedSecretKeys, dustSecretKey: keys.dustSecretKey }, { ttl: new Date(Date.now() + RECIPE_TTL_MS) }));
|
|
123
165
|
const signed = await facade.signRecipe(recipe, keys.unshieldedKeystore.signDataAsync);
|
|
166
|
+
console.log("proving transaction (proof server, can take minutes)...");
|
|
124
167
|
const finalized = await facade.finalizeRecipe(signed);
|
|
168
|
+
console.log("submitting transaction...");
|
|
125
169
|
return facade.submitTransaction(finalized);
|
|
126
170
|
}
|
|
127
171
|
/**
|
|
@@ -147,7 +191,7 @@ export async function transferNight(facade, keys, state, toUnshieldedAddress, ne
|
|
|
147
191
|
throw new Error("funder wallet holds no unshielded NIGHT to transfer");
|
|
148
192
|
}
|
|
149
193
|
const receiverAddress = MidnightBech32m.parse(toUnshieldedAddress).decode(UnshieldedAddress, networkId);
|
|
150
|
-
const recipe = await facade.transferTransaction([{ type: "unshielded", outputs: [{ type: nightTokenType, receiverAddress, amount }] }], { shieldedSecretKeys: keys.shieldedSecretKeys, dustSecretKey: keys.dustSecretKey }, { ttl: new Date(Date.now() + RECIPE_TTL_MS), payFees: true });
|
|
194
|
+
const recipe = await balanceWhileDustGenerates(facade, () => facade.transferTransaction([{ type: "unshielded", outputs: [{ type: nightTokenType, receiverAddress, amount }] }], { shieldedSecretKeys: keys.shieldedSecretKeys, dustSecretKey: keys.dustSecretKey }, { ttl: new Date(Date.now() + RECIPE_TTL_MS), payFees: true }));
|
|
151
195
|
const signed = await facade.signRecipe(recipe, keys.unshieldedKeystore.signDataAsync);
|
|
152
196
|
const finalized = await facade.finalizeRecipe(signed);
|
|
153
197
|
return facade.submitTransaction(finalized);
|
|
@@ -219,7 +263,9 @@ export async function withSyncedWalletFacade(keys, config, fn, options = {}) {
|
|
|
219
263
|
const facade = await initialiseWalletFacade(keys, config, options);
|
|
220
264
|
await facade.start(keys.shieldedSecretKeys, keys.dustSecretKey);
|
|
221
265
|
try {
|
|
266
|
+
console.log(`syncing wallet (indexer: ${config.indexerUrl})...`);
|
|
222
267
|
const state = await facade.waitForSyncedState();
|
|
268
|
+
console.log("wallet synced");
|
|
223
269
|
return await fn(facade, state);
|
|
224
270
|
}
|
|
225
271
|
finally {
|
|
@@ -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,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;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,+B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": "@sig-net/midnight-contract-deploy",
|
|
3
|
-
"version": "0.21.0-rc.
|
|
3
|
+
"version": "0.21.0-rc.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sig-net/midnight-integration",
|
|
@@ -50,8 +50,8 @@
|
|
|
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.21.0-rc.
|
|
54
|
-
"@sig-net/midnight-contract": "^0.21.0-rc.
|
|
53
|
+
"@sig-net/midnight": "^0.21.0-rc.6",
|
|
54
|
+
"@sig-net/midnight-contract": "^0.21.0-rc.6",
|
|
55
55
|
"effect": "^3.21.4"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|