@toon-protocol/rig 3.6.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -153
- package/dist/{chunk-HJDPM37T.js → chunk-7VCVR4GK.js} +12 -8
- package/dist/{chunk-HJDPM37T.js.map → chunk-7VCVR4GK.js.map} +1 -1
- package/dist/chunk-CDSFVZDV.js +290 -0
- package/dist/chunk-CDSFVZDV.js.map +1 -0
- package/dist/{chunk-B5ISARMU.js → chunk-GVXBUL3C.js} +15 -2
- package/dist/chunk-GVXBUL3C.js.map +1 -0
- package/dist/chunk-LTFMPOHU.js +194 -0
- package/dist/chunk-LTFMPOHU.js.map +1 -0
- package/dist/{chunk-2KJJ7LSO.js → chunk-NCEMQUPA.js} +40 -2
- package/dist/chunk-NCEMQUPA.js.map +1 -0
- package/dist/{chunk-LCYCKWAT.js → chunk-YZRR2UO6.js} +86 -5
- package/dist/chunk-YZRR2UO6.js.map +1 -0
- package/dist/cli/rig.js +631 -568
- package/dist/cli/rig.js.map +1 -1
- package/dist/index.d.ts +10 -115
- package/dist/index.js +16 -122
- package/dist/index.js.map +1 -1
- package/dist/{publisher-BFcnZeJI.d.ts → publisher-DMJ06cuL.d.ts} +98 -2
- package/dist/standalone/index.d.ts +241 -438
- package/dist/standalone/index.js +19 -11
- package/dist/standalone-mode-KTYRTUS6.js +390 -0
- package/dist/standalone-mode-KTYRTUS6.js.map +1 -0
- package/package.json +7 -5
- package/dist/chunk-2KJJ7LSO.js.map +0 -1
- package/dist/chunk-B5ISARMU.js.map +0 -1
- package/dist/chunk-IZ6KLYQ6.js +0 -724
- package/dist/chunk-IZ6KLYQ6.js.map +0 -1
- package/dist/chunk-LCYCKWAT.js.map +0 -1
- package/dist/chunk-PWNZWQOH.js +0 -404
- package/dist/chunk-PWNZWQOH.js.map +0 -1
- package/dist/chunk-UZZ2RN7A.js +0 -469
- package/dist/chunk-UZZ2RN7A.js.map +0 -1
- package/dist/network-bootstrap-27FYE3N7.js +0 -40
- package/dist/network-bootstrap-27FYE3N7.js.map +0 -1
- package/dist/standalone-mode-5MNNJC2D.js +0 -928
- package/dist/standalone-mode-5MNNJC2D.js.map +0 -1
package/dist/chunk-UZZ2RN7A.js
DELETED
|
@@ -1,469 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
queryRelay
|
|
3
|
-
} from "./chunk-2KJJ7LSO.js";
|
|
4
|
-
|
|
5
|
-
// src/standalone/network-bootstrap.ts
|
|
6
|
-
import {
|
|
7
|
-
CHAIN_PRESETS,
|
|
8
|
-
GenesisPeerLoader,
|
|
9
|
-
isEventExpired,
|
|
10
|
-
parseIlpPeerInfo,
|
|
11
|
-
resolveClientNetwork
|
|
12
|
-
} from "@toon-protocol/core";
|
|
13
|
-
var ILP_PEER_INFO_KIND = 10032;
|
|
14
|
-
var DISCOVERY_TIMEOUT_MS = 5e3;
|
|
15
|
-
function parseRoutes(content) {
|
|
16
|
-
try {
|
|
17
|
-
const parsed = JSON.parse(content);
|
|
18
|
-
const routes = parsed.routes;
|
|
19
|
-
if (typeof routes !== "object" || routes === null) return void 0;
|
|
20
|
-
const { publish, store } = routes;
|
|
21
|
-
const out = {
|
|
22
|
-
...typeof publish === "string" && publish.length > 0 ? { publish } : {},
|
|
23
|
-
...typeof store === "string" && store.length > 0 ? { store } : {}
|
|
24
|
-
};
|
|
25
|
-
return out.publish || out.store ? out : void 0;
|
|
26
|
-
} catch {
|
|
27
|
-
return void 0;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function parseRoutePrices(content) {
|
|
31
|
-
try {
|
|
32
|
-
const parsed = JSON.parse(content);
|
|
33
|
-
const raw = parsed.routePrices;
|
|
34
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
35
|
-
return void 0;
|
|
36
|
-
}
|
|
37
|
-
const out = {};
|
|
38
|
-
for (const [address, price] of Object.entries(
|
|
39
|
-
raw
|
|
40
|
-
)) {
|
|
41
|
-
if (address.length > 0 && typeof price === "string" && /^\d+$/.test(price)) {
|
|
42
|
-
out[address] = price;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return Object.keys(out).length > 0 ? out : void 0;
|
|
46
|
-
} catch {
|
|
47
|
-
return void 0;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function parseCapabilities(content) {
|
|
51
|
-
try {
|
|
52
|
-
const parsed = JSON.parse(content);
|
|
53
|
-
if (!Array.isArray(parsed.capabilities)) return void 0;
|
|
54
|
-
const out = [];
|
|
55
|
-
for (const entry of parsed.capabilities) {
|
|
56
|
-
if (typeof entry !== "object" || entry === null) continue;
|
|
57
|
-
const { capability, address, price } = entry;
|
|
58
|
-
if (typeof capability === "string" && typeof address === "string" && address.length > 0 && typeof price === "string" && /^\d+$/.test(price)) {
|
|
59
|
-
out.push({ capability, address, price });
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return out.length > 0 ? out : void 0;
|
|
63
|
-
} catch {
|
|
64
|
-
return void 0;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function parseMinaTokenIds(content) {
|
|
68
|
-
try {
|
|
69
|
-
const parsed = JSON.parse(content);
|
|
70
|
-
const map = parsed.minaTokenIds;
|
|
71
|
-
if (typeof map !== "object" || map === null || Array.isArray(map)) {
|
|
72
|
-
return void 0;
|
|
73
|
-
}
|
|
74
|
-
const out = {};
|
|
75
|
-
for (const [chain, tokenId] of Object.entries(map)) {
|
|
76
|
-
if (typeof tokenId === "string" && /^\d+$/.test(tokenId)) {
|
|
77
|
-
out[chain] = tokenId;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return Object.keys(out).length > 0 ? out : void 0;
|
|
81
|
-
} catch {
|
|
82
|
-
return void 0;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function parseChainRpcUrls(content) {
|
|
86
|
-
try {
|
|
87
|
-
const parsed = JSON.parse(content);
|
|
88
|
-
const map = parsed.chainRpcUrls;
|
|
89
|
-
if (typeof map !== "object" || map === null || Array.isArray(map)) {
|
|
90
|
-
return void 0;
|
|
91
|
-
}
|
|
92
|
-
const out = {};
|
|
93
|
-
for (const [chain, url] of Object.entries(map)) {
|
|
94
|
-
if (typeof url === "string" && /^(https?|wss?):\/\//.test(url)) {
|
|
95
|
-
out[chain] = url;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return Object.keys(out).length > 0 ? out : void 0;
|
|
99
|
-
} catch {
|
|
100
|
-
return void 0;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async function discoverAnnouncedPeers(relayUrl, options = {}) {
|
|
104
|
-
const factory = options.webSocketFactory ?? defaultDiscoveryWebSocketFactory();
|
|
105
|
-
const events = await queryRelay(
|
|
106
|
-
relayUrl,
|
|
107
|
-
{ kinds: [ILP_PEER_INFO_KIND], limit: 100 },
|
|
108
|
-
options.timeoutMs ?? DISCOVERY_TIMEOUT_MS,
|
|
109
|
-
factory
|
|
110
|
-
);
|
|
111
|
-
const latestByAuthor = /* @__PURE__ */ new Map();
|
|
112
|
-
for (const event of events) {
|
|
113
|
-
if (event.kind !== ILP_PEER_INFO_KIND) continue;
|
|
114
|
-
const prev = latestByAuthor.get(event.pubkey);
|
|
115
|
-
if (!prev || event.created_at > prev.created_at) {
|
|
116
|
-
latestByAuthor.set(event.pubkey, event);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
const peers = [];
|
|
120
|
-
for (const event of latestByAuthor.values()) {
|
|
121
|
-
if (isEventExpired(event)) {
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
let info;
|
|
125
|
-
try {
|
|
126
|
-
info = parseIlpPeerInfo(event);
|
|
127
|
-
} catch {
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
const routes = parseRoutes(event.content);
|
|
131
|
-
const capabilities = parseCapabilities(event.content);
|
|
132
|
-
const routePrices = parseRoutePrices(event.content);
|
|
133
|
-
const minaTokenIds = parseMinaTokenIds(event.content);
|
|
134
|
-
const chainRpcUrls = parseChainRpcUrls(event.content);
|
|
135
|
-
peers.push({
|
|
136
|
-
pubkey: event.pubkey,
|
|
137
|
-
info,
|
|
138
|
-
...routes ? { routes } : {},
|
|
139
|
-
...capabilities ? { capabilities } : {},
|
|
140
|
-
...routePrices ? { routePrices } : {},
|
|
141
|
-
...minaTokenIds ? { minaTokenIds } : {},
|
|
142
|
-
...chainRpcUrls ? { chainRpcUrls } : {},
|
|
143
|
-
createdAt: event.created_at
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
return peers;
|
|
147
|
-
}
|
|
148
|
-
function defaultDiscoveryWebSocketFactory() {
|
|
149
|
-
return (url) => {
|
|
150
|
-
const ctor = globalThis.WebSocket;
|
|
151
|
-
if (!ctor) {
|
|
152
|
-
throw new Error(
|
|
153
|
-
"No global WebSocket constructor (Node >= 22 required) for announce discovery"
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
return new ctor(url);
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function pickPaymentPeer(peers, seedPubkeys) {
|
|
160
|
-
const seeded = peers.filter((p) => seedPubkeys.includes(p.pubkey));
|
|
161
|
-
if (seeded.length > 0) {
|
|
162
|
-
return seeded.sort((a, b) => b.createdAt - a.createdAt)[0];
|
|
163
|
-
}
|
|
164
|
-
const payable = peers.filter(
|
|
165
|
-
(p) => (p.info.httpEndpoint || p.info.btpEndpoint) && p.info.settlementAddresses && Object.keys(p.info.settlementAddresses).length > 0
|
|
166
|
-
);
|
|
167
|
-
if (payable.length === 0) return void 0;
|
|
168
|
-
const publishEdges = payable.filter(
|
|
169
|
-
(p) => p.routes?.publish !== void 0 && p.routes.publish === p.info.ilpAddress
|
|
170
|
-
);
|
|
171
|
-
const pool = publishEdges.length > 0 ? publishEdges : payable;
|
|
172
|
-
return pool.sort((a, b) => b.createdAt - a.createdAt)[0];
|
|
173
|
-
}
|
|
174
|
-
function evmChainIdOf(chain) {
|
|
175
|
-
const parts = chain.split(":");
|
|
176
|
-
if (parts[0] !== "evm") return void 0;
|
|
177
|
-
const raw = parts.length >= 3 ? parts[2] : parts[1];
|
|
178
|
-
const id = Number.parseInt(raw ?? "", 10);
|
|
179
|
-
return Number.isNaN(id) ? void 0 : id;
|
|
180
|
-
}
|
|
181
|
-
function evmPresetForChain(chain) {
|
|
182
|
-
const id = evmChainIdOf(chain);
|
|
183
|
-
if (id === void 0) return void 0;
|
|
184
|
-
for (const preset of Object.values(CHAIN_PRESETS)) {
|
|
185
|
-
if (preset.chainId === id) {
|
|
186
|
-
return {
|
|
187
|
-
rpcUrl: preset.rpcUrl,
|
|
188
|
-
usdcAddress: preset.usdcAddress,
|
|
189
|
-
tokenNetworkAddress: preset.tokenNetworkAddress
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return void 0;
|
|
194
|
-
}
|
|
195
|
-
function solanaPresetForChain(chain) {
|
|
196
|
-
const [family, cluster] = chain.split(":");
|
|
197
|
-
if (family !== "solana" || !cluster) return void 0;
|
|
198
|
-
const tier = cluster === "mainnet-beta" ? "mainnet" : cluster === "devnet" ? "devnet" : cluster === "testnet" ? "testnet" : void 0;
|
|
199
|
-
if (!tier) return void 0;
|
|
200
|
-
const presets = resolveClientNetwork(tier);
|
|
201
|
-
const rpcUrl = presets.chainRpcUrls[chain];
|
|
202
|
-
const tokenMint = presets.preferredTokens[chain];
|
|
203
|
-
const programId = presets.solanaChannel && presets.supportedChains.includes(chain) ? presets.solanaChannel.programId : void 0;
|
|
204
|
-
if (!rpcUrl && !tokenMint && !programId) return void 0;
|
|
205
|
-
return {
|
|
206
|
-
...rpcUrl ? { rpcUrl } : {},
|
|
207
|
-
...tokenMint ? { tokenMint } : {},
|
|
208
|
-
...programId ? { programId } : {}
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
function minaPresetForChain(chain) {
|
|
212
|
-
const [family, network] = chain.split(":");
|
|
213
|
-
if (family !== "mina" || !network) return void 0;
|
|
214
|
-
const tier = network === "mainnet" ? "mainnet" : network === "devnet" ? "devnet" : void 0;
|
|
215
|
-
if (!tier) return void 0;
|
|
216
|
-
const presets = resolveClientNetwork(tier);
|
|
217
|
-
const mina = presets.minaChannel;
|
|
218
|
-
if (!mina) return void 0;
|
|
219
|
-
const tokenId = mina.tokenId;
|
|
220
|
-
return {
|
|
221
|
-
...mina.graphqlUrl ? { graphqlUrl: mina.graphqlUrl } : {},
|
|
222
|
-
...mina.zkAppAddress ? { zkAppAddress: mina.zkAppAddress } : {},
|
|
223
|
-
...tokenId ? { tokenId } : {},
|
|
224
|
-
...mina.networkId ? { networkId: mina.networkId } : {}
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
function resolveChainSettlement(chain, explicit, announce) {
|
|
228
|
-
const family = chain.split(":")[0] ?? chain;
|
|
229
|
-
const evmPreset = family === "evm" ? evmPresetForChain(chain) : void 0;
|
|
230
|
-
const solPreset = family === "solana" ? solanaPresetForChain(chain) : void 0;
|
|
231
|
-
const minaPreset = family === "mina" ? minaPresetForChain(chain) : void 0;
|
|
232
|
-
const rpcUrl = explicit.chainRpcUrls?.[chain] ?? // The live deployment's advertised RPC beats the baked preset default: a
|
|
233
|
-
// preset RPC can be a stale/broken endpoint (e.g. Base Sepolia's
|
|
234
|
-
// sepolia.base.org fails setTotalDeposit) while the announce carries the
|
|
235
|
-
// deployment's known-good URL. Same drift lesson as #103.
|
|
236
|
-
announce?.chainRpcUrls?.[chain] ?? evmPreset?.rpcUrl ?? solPreset?.rpcUrl ?? // For Mina the "RPC" is the GraphQL endpoint (non-deployment-specific).
|
|
237
|
-
minaPreset?.graphqlUrl;
|
|
238
|
-
const tokenAddress = explicit.preferredTokens?.[chain] ?? announce?.info.preferredTokens?.[chain] ?? (evmPreset?.usdcAddress || void 0) ?? solPreset?.tokenMint;
|
|
239
|
-
const tokenNetwork = family === "evm" ? explicit.tokenNetworks?.[chain] ?? announce?.info.tokenNetworks?.[chain] ?? (evmPreset?.tokenNetworkAddress || void 0) : void 0;
|
|
240
|
-
const programId = family === "solana" ? explicit.tokenNetworks?.[chain] ?? announce?.info.tokenNetworks?.[chain] ?? solPreset?.programId : void 0;
|
|
241
|
-
const zkAppAddress = family === "mina" ? explicit.tokenNetworks?.[chain] ?? announce?.info.tokenNetworks?.[chain] ?? minaPreset?.zkAppAddress : void 0;
|
|
242
|
-
const minaTokenId = family === "mina" ? announce?.minaTokenIds?.[chain] ?? minaPreset?.tokenId : void 0;
|
|
243
|
-
const networkId = family === "mina" ? minaPreset?.networkId ?? (chain.split(":")[1] === "mainnet" ? "mainnet" : "devnet") : void 0;
|
|
244
|
-
return {
|
|
245
|
-
chain,
|
|
246
|
-
family,
|
|
247
|
-
...rpcUrl ? { rpcUrl } : {},
|
|
248
|
-
...tokenAddress ? { tokenAddress } : {},
|
|
249
|
-
...tokenNetwork ? { tokenNetwork } : {},
|
|
250
|
-
...programId ? { programId } : {},
|
|
251
|
-
...zkAppAddress ? { zkAppAddress } : {},
|
|
252
|
-
...minaTokenId ? { minaTokenId } : {},
|
|
253
|
-
...networkId ? { networkId } : {}
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
var TokenNetworkUnderivableError = class extends Error {
|
|
257
|
-
constructor(chain, announce, relayUrl) {
|
|
258
|
-
const announceRef = announce ? `the kind:10032 announce from ${announce.pubkey.slice(0, 16)}\u2026 on ${relayUrl}` : `no kind:10032 announce was found on ${relayUrl}`;
|
|
259
|
-
super(
|
|
260
|
-
`cannot derive the TokenNetwork contract for settlement chain "${chain}": ${announceRef} carries no tokenNetworks["${chain}"], and no built-in chain preset matches its chain id \u2014 add tokenNetworks["${chain}"] to the client config (or pick another chain via TOON_CLIENT_CHAIN / the chain config field)`
|
|
261
|
-
);
|
|
262
|
-
this.name = "TokenNetworkUnderivableError";
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
var SolanaChannelUnderivableError = class extends Error {
|
|
266
|
-
constructor(chain, missing, announce, relayUrl) {
|
|
267
|
-
const announceRef = announce ? `the kind:10032 announce from ${announce.pubkey.slice(0, 16)}\u2026 on ${relayUrl} does not carry them` : `no kind:10032 announce was found on ${relayUrl}`;
|
|
268
|
-
super(
|
|
269
|
-
`cannot derive the Solana channel parameters for settlement chain "${chain}" (missing: ${missing.join(", ")}): ${announceRef}, and no built-in preset covers this cluster \u2014 add a solanaChannel { rpcUrl, programId, tokenMint } object to the client config (or set tokenNetworks["${chain}"] = <program id>, preferredTokens["${chain}"] = <mint>, chainRpcUrls["${chain}"]), or pick another chain via TOON_CLIENT_CHAIN / the chain config field`
|
|
270
|
-
);
|
|
271
|
-
this.name = "SolanaChannelUnderivableError";
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
var MinaChannelUnderivableError = class extends Error {
|
|
275
|
-
constructor(chain, missing, announce, relayUrl) {
|
|
276
|
-
const announceRef = announce ? `the kind:10032 announce from ${announce.pubkey.slice(0, 16)}\u2026 on ${relayUrl} does not carry them` : `no kind:10032 announce was found on ${relayUrl}`;
|
|
277
|
-
super(
|
|
278
|
-
`cannot derive the Mina channel parameters for settlement chain "${chain}" (missing: ${missing.join(", ")}): ${announceRef}, and no built-in preset covers this network \u2014 add a minaChannel { graphqlUrl, zkAppAddress, tokenId, networkId } object to the client config (or set tokenNetworks["${chain}"] = <zkApp address> and chainRpcUrls["${chain}"] = <graphql url>), or pick another chain via TOON_CLIENT_CHAIN / the chain config field`
|
|
279
|
-
);
|
|
280
|
-
this.name = "MinaChannelUnderivableError";
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
async function selectSettlementChain(options) {
|
|
284
|
-
const { explicitChain, announcedChains } = options;
|
|
285
|
-
if (explicitChain) {
|
|
286
|
-
if (explicitChain.includes(":")) {
|
|
287
|
-
if (!announcedChains.includes(explicitChain)) {
|
|
288
|
-
const chainId = evmChainIdOf(explicitChain);
|
|
289
|
-
const equivalent = chainId !== void 0 ? announcedChains.find((c) => evmChainIdOf(c) === chainId) : void 0;
|
|
290
|
-
if (equivalent) {
|
|
291
|
-
return {
|
|
292
|
-
chain: equivalent,
|
|
293
|
-
reason: "explicit",
|
|
294
|
-
detail: `chain ${explicitChain} set by config \u2192 announced spelling ${equivalent} (same EVM chain id ${chainId})`
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
return {
|
|
299
|
-
chain: explicitChain,
|
|
300
|
-
reason: "explicit",
|
|
301
|
-
detail: `chain ${explicitChain} set by config`
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
const familyMatch = announcedChains.find(
|
|
305
|
-
(c) => (c.split(":")[0] ?? c) === explicitChain
|
|
306
|
-
);
|
|
307
|
-
if (!familyMatch) {
|
|
308
|
-
throw new Error(
|
|
309
|
-
`configured chain family "${explicitChain}" is not announced by the payment peer (announced: ${announcedChains.join(", ") || "none"}) \u2014 set a full chain id (e.g. "evm:31337") to force it`
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
return {
|
|
313
|
-
chain: familyMatch,
|
|
314
|
-
reason: "explicit",
|
|
315
|
-
detail: `chain family "${explicitChain}" set by config \u2192 ${familyMatch}`
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
const live = (options.records ?? []).filter((r) => !r.closed && announcedChains.includes(r.chain)).sort((a, b) => b.lastUsedAt.localeCompare(a.lastUsedAt));
|
|
319
|
-
const persisted = live[0];
|
|
320
|
-
if (persisted) {
|
|
321
|
-
return {
|
|
322
|
-
chain: persisted.chain,
|
|
323
|
-
reason: "persisted-channel",
|
|
324
|
-
detail: `existing payment channel on ${persisted.chain} (rig channel map)`
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
const evmChains = announcedChains.filter((c) => c.startsWith("evm:"));
|
|
328
|
-
for (const chain of announcedChains) {
|
|
329
|
-
const family = chain.split(":")[0];
|
|
330
|
-
let probe;
|
|
331
|
-
let owner;
|
|
332
|
-
if (family === "evm") {
|
|
333
|
-
probe = options.probeBalance;
|
|
334
|
-
owner = options.evmAddress;
|
|
335
|
-
} else if (family === "solana") {
|
|
336
|
-
probe = options.probeSolanaBalance;
|
|
337
|
-
owner = options.solanaAddress;
|
|
338
|
-
}
|
|
339
|
-
if (!probe || !owner) continue;
|
|
340
|
-
const settlement = options.resolveSettlement(chain);
|
|
341
|
-
if (!settlement.rpcUrl || !settlement.tokenAddress) continue;
|
|
342
|
-
try {
|
|
343
|
-
const balance = await probe({
|
|
344
|
-
rpcUrl: settlement.rpcUrl,
|
|
345
|
-
tokenAddress: settlement.tokenAddress,
|
|
346
|
-
owner
|
|
347
|
-
});
|
|
348
|
-
if (balance > 0n) {
|
|
349
|
-
return {
|
|
350
|
-
chain,
|
|
351
|
-
reason: "funded",
|
|
352
|
-
detail: `wallet holds ${balance} token base units on ${chain}`
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
} catch {
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
const fallback = evmChains[0] ?? announcedChains[0];
|
|
359
|
-
if (!fallback) {
|
|
360
|
-
throw new Error(
|
|
361
|
-
"the payment peer announces no settlement chains \u2014 cannot select a chain for paid writes (set supportedChains/chain in the client config)"
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
return {
|
|
365
|
-
chain: fallback,
|
|
366
|
-
reason: "default",
|
|
367
|
-
detail: evmChains[0] ? `first EVM chain announced by the payment peer` : `first chain announced by the payment peer (no EVM chain announced)`
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
var BALANCE_OF_SELECTOR = "0x70a08231";
|
|
371
|
-
async function evmTokenBalance(args) {
|
|
372
|
-
const fetchImpl = args.fetchImpl ?? fetch;
|
|
373
|
-
const owner = args.owner.replace(/^0x/, "").toLowerCase().padStart(64, "0");
|
|
374
|
-
const controller = new AbortController();
|
|
375
|
-
const timer = setTimeout(() => controller.abort(), args.timeoutMs ?? 5e3);
|
|
376
|
-
try {
|
|
377
|
-
const res = await fetchImpl(args.rpcUrl, {
|
|
378
|
-
method: "POST",
|
|
379
|
-
headers: { "content-type": "application/json" },
|
|
380
|
-
body: JSON.stringify({
|
|
381
|
-
jsonrpc: "2.0",
|
|
382
|
-
id: 1,
|
|
383
|
-
method: "eth_call",
|
|
384
|
-
params: [
|
|
385
|
-
{ to: args.tokenAddress, data: `${BALANCE_OF_SELECTOR}${owner}` },
|
|
386
|
-
"latest"
|
|
387
|
-
]
|
|
388
|
-
}),
|
|
389
|
-
signal: controller.signal
|
|
390
|
-
});
|
|
391
|
-
if (!res.ok) {
|
|
392
|
-
throw new Error(`eth_call failed: HTTP ${res.status}`);
|
|
393
|
-
}
|
|
394
|
-
const body = await res.json();
|
|
395
|
-
if (typeof body.result !== "string") {
|
|
396
|
-
throw new Error(`eth_call failed: ${body.error?.message ?? "no result"}`);
|
|
397
|
-
}
|
|
398
|
-
return BigInt(body.result === "0x" ? "0x0" : body.result);
|
|
399
|
-
} finally {
|
|
400
|
-
clearTimeout(timer);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
async function solanaTokenBalance(args) {
|
|
404
|
-
const fetchImpl = args.fetchImpl ?? fetch;
|
|
405
|
-
const controller = new AbortController();
|
|
406
|
-
const timer = setTimeout(() => controller.abort(), args.timeoutMs ?? 5e3);
|
|
407
|
-
try {
|
|
408
|
-
const res = await fetchImpl(args.rpcUrl, {
|
|
409
|
-
method: "POST",
|
|
410
|
-
headers: { "content-type": "application/json" },
|
|
411
|
-
body: JSON.stringify({
|
|
412
|
-
jsonrpc: "2.0",
|
|
413
|
-
id: 1,
|
|
414
|
-
method: "getTokenAccountsByOwner",
|
|
415
|
-
params: [
|
|
416
|
-
args.owner,
|
|
417
|
-
{ mint: args.tokenAddress },
|
|
418
|
-
{ encoding: "jsonParsed" }
|
|
419
|
-
]
|
|
420
|
-
}),
|
|
421
|
-
signal: controller.signal
|
|
422
|
-
});
|
|
423
|
-
if (!res.ok) {
|
|
424
|
-
throw new Error(`getTokenAccountsByOwner failed: HTTP ${res.status}`);
|
|
425
|
-
}
|
|
426
|
-
const body = await res.json();
|
|
427
|
-
const accounts = body.result?.value;
|
|
428
|
-
if (!Array.isArray(accounts)) {
|
|
429
|
-
throw new Error(
|
|
430
|
-
`getTokenAccountsByOwner failed: ${body.error?.message ?? "no result"}`
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
let total = 0n;
|
|
434
|
-
for (const account of accounts) {
|
|
435
|
-
const amount = account?.account?.data?.parsed?.info?.tokenAmount?.amount;
|
|
436
|
-
if (typeof amount === "string") total += BigInt(amount);
|
|
437
|
-
}
|
|
438
|
-
return total;
|
|
439
|
-
} finally {
|
|
440
|
-
clearTimeout(timer);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
function loadGenesisSeed() {
|
|
444
|
-
return GenesisPeerLoader.loadGenesisPeers()[0];
|
|
445
|
-
}
|
|
446
|
-
function genesisSeedPubkeys() {
|
|
447
|
-
return GenesisPeerLoader.loadGenesisPeers().map((p) => p.pubkey);
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
export {
|
|
451
|
-
ILP_PEER_INFO_KIND,
|
|
452
|
-
DISCOVERY_TIMEOUT_MS,
|
|
453
|
-
discoverAnnouncedPeers,
|
|
454
|
-
pickPaymentPeer,
|
|
455
|
-
evmChainIdOf,
|
|
456
|
-
evmPresetForChain,
|
|
457
|
-
solanaPresetForChain,
|
|
458
|
-
minaPresetForChain,
|
|
459
|
-
resolveChainSettlement,
|
|
460
|
-
TokenNetworkUnderivableError,
|
|
461
|
-
SolanaChannelUnderivableError,
|
|
462
|
-
MinaChannelUnderivableError,
|
|
463
|
-
selectSettlementChain,
|
|
464
|
-
evmTokenBalance,
|
|
465
|
-
solanaTokenBalance,
|
|
466
|
-
loadGenesisSeed,
|
|
467
|
-
genesisSeedPubkeys
|
|
468
|
-
};
|
|
469
|
-
//# sourceMappingURL=chunk-UZZ2RN7A.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/standalone/network-bootstrap.ts"],"sourcesContent":["/**\n * Network bootstrap for the standalone (embedded-client) rig path (#264):\n * resolve the payment topology — uplink, ILP destinations/routes, settlement\n * chain and its on-chain parameters — from the network itself instead of\n * hand-fed constants.\n *\n * Sources, in strict precedence order (first hit wins, per field):\n *\n * 1. EXPLICIT USER CONFIG — env vars / shared client-config file fields.\n * 2. LIVE kind:10032 ANNOUNCE — the payment peer's `IlpPeerInfo` event\n * discovered on the relay-origin (the relay the paid command resolved\n * via `rig remote`, i.e. what the user pointed rig at). The announce\n * carries `btpEndpoint`/`httpEndpoint` (uplink), `ilpAddress` (channel\n * anchor), `supportedChains` + `settlementAddresses` (settlement), and\n * the out-of-band `routes` map (`{publish, store}` ILP destinations).\n * 3. GENESIS SEED — `@toon-protocol/core`'s committed genesis peer seed\n * (core >= 3.1.1 ships the live devnet apex), the offline fallback when\n * the relay is unreachable or serves no valid announce.\n *\n * Chain-level parameters the announce does NOT carry (EVM TokenNetwork\n * contract, token address, RPC URL) are derived per selected chain:\n * explicit config > announce (`tokenNetworks`/`preferredTokens`, when a peer\n * announces them) > core's deterministic chain presets (`CHAIN_PRESETS`,\n * matched by chain id — e.g. `evm:31337` is the Foundry/anvil deploy whose\n * TOON contract addresses are deterministic; `evm:base:84532` and\n * `solana:devnet` are the public networks the TOON devnet settles on since\n * the zone's self-hosted chain nodes were retired, 2026-07).\n *\n * Settlement-chain selection (#260 root cause 4) — simple and predictable:\n *\n * 1. EXPLICIT — `TOON_CLIENT_CHAIN` env / `chain` config field (family or\n * full chain id), or the first entry of an explicit `supportedChains`.\n * 2. PERSISTED CHANNEL — the chain of the most recently used live channel\n * recorded for this identity in the #262 channel map (a channel there\n * means collateral is already locked on that chain).\n * 3. FUNDED — the first announced chain (EVM or Solana, in announce\n * order) where the identity's token balance is > 0 (one `eth_call` /\n * `getTokenAccountsByOwner` per candidate).\n * 4. DEFAULT — the first EVM chain the peer announces (else the first\n * announced chain), with a printed rationale.\n *\n * This module is pure Node + `@toon-protocol/core` (rig's own core 3.x —\n * distinct from the embedded client's internal core; see\n * `../cli/standalone-mode.ts` for the coexistence note).\n */\n\nimport {\n CHAIN_PRESETS,\n GenesisPeerLoader,\n isEventExpired,\n parseIlpPeerInfo,\n resolveClientNetwork,\n type GenesisPeer,\n type IlpPeerInfo,\n} from '@toon-protocol/core';\nimport {\n queryRelay,\n type NostrEvent,\n type WebSocketFactory,\n} from '../remote-state.js';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** kind:10032 — ILP peer info announcement (mirrors core's constant). */\nexport const ILP_PEER_INFO_KIND = 10032;\n\n/** Publish/store ILP route hints riding out-of-band in announce content. */\nexport interface AnnouncedRoutes {\n publish?: string;\n store?: string;\n}\n\n/**\n * One announced capability with its FLAT route price (out-of-band\n * `capabilities` content field, e.g. `{capability:'os.publish',\n * address:'g.proxy.relay', price:'1000'}`). The connector (≥3.34.6) gates\n * every paid packet at the destination route's price: a balance-proof claim\n * advancing the channel by less is rejected (F06), so per-packet fees to\n * `address` must be floored at `price`.\n */\nexport interface AnnouncedCapability {\n /** Capability name, e.g. `os.publish` / `os.store`. */\n capability: string;\n /** ILP destination address the capability (and its price) applies to. */\n address: string;\n /** Flat per-packet price, base-unit non-negative integer string. */\n price: string;\n}\n\n/** One schema-valid, unexpired kind:10032 announce seen on the relay. */\nexport interface AnnouncedPeer {\n /** Announcing identity (event author, hex). */\n pubkey: string;\n /**\n * Parsed + validated `IlpPeerInfo` (rig's core 3.x parser), widened with\n * the optional operator-notice field (toon-protocol/toon#183, #78).\n * `notice` is typed `unknown`, not a schema field: the installed core's\n * `parseIlpPeerInfo` builds its result field by field, so `notice` only\n * appears here once core publishes it (see `./notice.ts`'s module doc for\n * that status). `./notice.ts` validates the value as untrusted input\n * either way.\n */\n info: IlpPeerInfo & { notice?: unknown };\n /** Out-of-band `routes` content field, when present and well-formed. */\n routes?: AnnouncedRoutes;\n /** Out-of-band `capabilities` content field (route prices), when valid. */\n capabilities?: AnnouncedCapability[];\n /**\n * Out-of-band `routePrices` map (ILP address → base-unit price string) —\n * the shape the live connector publishes, alongside/instead of\n * `capabilities`. Each node prices its OWN routes, so the store route's\n * price comes from the store node's announce, not the payment peer's.\n */\n routePrices?: Record<string, string>;\n /**\n * Out-of-band `minaTokenIds` content field: chain id → Mina token id\n * (decimal string). The zkApp address for a Mina channel already rides the\n * standard `tokenNetworks` map (mirroring Solana's program id), but the Mina\n * token id — the deployment-specific fungible-token discriminator a custom\n * USDC channel opens on — has no home in core's kind:10032 wire schema, so\n * the connector advertises it here (a content ride-along, like `routes`).\n * Absent for native-MINA settlement (token id defaults to '1' downstream).\n */\n minaTokenIds?: Record<string, string>;\n /**\n * Out-of-band `chainRpcUrls` content field: chain id → JSON-RPC / GraphQL\n * endpoint the deployment KNOWS works for that chain. Core's baked chain\n * presets carry a default RPC per chain, but a baked default can be a stale\n * or broken endpoint (e.g. Base Sepolia's `sepolia.base.org` load balancer\n * fails openChannel→setTotalDeposit with InvalidChannelState) — the same\n * stale-constant failure mode as the base-sepolia preset bug (#103). So the\n * live deployment advertises its OWN working RPC here and the client prefers\n * it over the preset (see {@link resolveChainSettlement}). A content\n * ride-along, like `routes` — core's kind:10032 wire schema is unchanged.\n */\n chainRpcUrls?: Record<string, string>;\n /** Announce timestamp (freshness tiebreaker). */\n createdAt: number;\n}\n\n/** Per-chain settlement parameters resolved for the embedded client. */\nexport interface ChainSettlement {\n /** Chain id as announced/configured, e.g. `evm:31337`. */\n chain: string;\n /** `evm` | `solana` | `mina` | … (first chain-id segment). */\n family: string;\n /** JSON-RPC / GraphQL endpoint, when derivable. */\n rpcUrl?: string;\n /** Preferred token (USDC / SPL mint) address, when derivable. */\n tokenAddress?: string;\n /** EVM TokenNetwork contract, when derivable (EVM only). */\n tokenNetwork?: string;\n /** Solana payment-channel program id, when derivable (Solana only). */\n programId?: string;\n /** Mina payment-channel zkApp address, when derivable (Mina only). */\n zkAppAddress?: string;\n /** Mina token id (decimal string), when derivable (Mina only). */\n minaTokenId?: string;\n /** Mina network id for the account/Schnorr prefix (Mina only). */\n networkId?: 'devnet' | 'mainnet';\n}\n\n/** Why a settlement chain was selected (documented rule, in order). */\nexport type ChainSelectionReason =\n | 'explicit'\n | 'persisted-channel'\n | 'funded'\n | 'default';\n\n/** The selected settlement chain plus its rationale. */\nexport interface ChainSelection {\n chain: string;\n reason: ChainSelectionReason;\n /** One human-readable line explaining the pick. */\n detail: string;\n}\n\n// ---------------------------------------------------------------------------\n// Announce discovery\n// ---------------------------------------------------------------------------\n\n/** Default bounded wait for the kind:10032 relay query. */\nexport const DISCOVERY_TIMEOUT_MS = 5000;\n\nfunction parseRoutes(content: string): AnnouncedRoutes | undefined {\n try {\n const parsed = JSON.parse(content) as { routes?: unknown };\n const routes = parsed.routes;\n if (typeof routes !== 'object' || routes === null) return undefined;\n const { publish, store } = routes as Record<string, unknown>;\n const out: AnnouncedRoutes = {\n ...(typeof publish === 'string' && publish.length > 0 ? { publish } : {}),\n ...(typeof store === 'string' && store.length > 0 ? { store } : {}),\n };\n return out.publish || out.store ? out : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Parse the announce's `routePrices` map (ILP address → base-unit price\n * string), the shape the live connector actually publishes.\n *\n * This is a SEPARATE surface from `capabilities`, not a rename of it: the\n * connector emits `routePrices` on every kind:10032 while `capabilities` is\n * the older, richer array carrying a capability name alongside the price.\n * A fleet publishing only `routePrices` left the price floor unset, which\n * the store route surfaces as `F03 - claim rejected: advances value by 0,\n * less than this route's price` — the floor exists precisely so a\n * bytes-derived fee that rounds to nothing is lifted to what the route\n * charges. Values are validated like every other announced amount.\n */\nfunction parseRoutePrices(\n content: string\n): Record<string, string> | undefined {\n try {\n const parsed = JSON.parse(content) as { routePrices?: unknown };\n const raw = parsed.routePrices;\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {\n return undefined;\n }\n const out: Record<string, string> = {};\n for (const [address, price] of Object.entries(\n raw as Record<string, unknown>\n )) {\n if (address.length > 0 && typeof price === 'string' && /^\\d+$/.test(price)) {\n out[address] = price;\n }\n }\n return Object.keys(out).length > 0 ? out : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Parse the announce's out-of-band `capabilities` array (route prices).\n * Malformed entries are skipped; a `price` must be a non-negative integer\n * string (the same base-unit serialization every other announced amount\n * uses). Returns undefined when nothing valid is present.\n */\nfunction parseCapabilities(content: string): AnnouncedCapability[] | undefined {\n try {\n const parsed = JSON.parse(content) as { capabilities?: unknown };\n if (!Array.isArray(parsed.capabilities)) return undefined;\n const out: AnnouncedCapability[] = [];\n for (const entry of parsed.capabilities) {\n if (typeof entry !== 'object' || entry === null) continue;\n const { capability, address, price } = entry as Record<string, unknown>;\n if (\n typeof capability === 'string' &&\n typeof address === 'string' &&\n address.length > 0 &&\n typeof price === 'string' &&\n /^\\d+$/.test(price)\n ) {\n out.push({ capability, address, price });\n }\n }\n return out.length > 0 ? out : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Parse the announce's out-of-band `minaTokenIds` map (chain id → Mina token\n * id decimal string). Non-string / non-decimal entries are skipped; keys are\n * accepted verbatim (they are matched against the selected chain id later).\n * Returns undefined when nothing valid is present.\n */\nfunction parseMinaTokenIds(content: string): Record<string, string> | undefined {\n try {\n const parsed = JSON.parse(content) as { minaTokenIds?: unknown };\n const map = parsed.minaTokenIds;\n if (typeof map !== 'object' || map === null || Array.isArray(map)) {\n return undefined;\n }\n const out: Record<string, string> = {};\n for (const [chain, tokenId] of Object.entries(map as Record<string, unknown>)) {\n if (typeof tokenId === 'string' && /^\\d+$/.test(tokenId)) {\n out[chain] = tokenId;\n }\n }\n return Object.keys(out).length > 0 ? out : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Parse the announce's out-of-band `chainRpcUrls` map (chain id → RPC/GraphQL\n * endpoint). Non-string / non-http(s) entries are skipped; keys are accepted\n * verbatim (matched against the selected chain id later). Returns undefined\n * when nothing valid is present.\n */\nfunction parseChainRpcUrls(content: string): Record<string, string> | undefined {\n try {\n const parsed = JSON.parse(content) as { chainRpcUrls?: unknown };\n const map = parsed.chainRpcUrls;\n if (typeof map !== 'object' || map === null || Array.isArray(map)) {\n return undefined;\n }\n const out: Record<string, string> = {};\n for (const [chain, url] of Object.entries(map as Record<string, unknown>)) {\n if (typeof url === 'string' && /^(https?|wss?):\\/\\//.test(url)) {\n out[chain] = url;\n }\n }\n return Object.keys(out).length > 0 ? out : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Query `relayUrl` for kind:10032 announces and return the latest\n * schema-valid, unexpired announce per author. Invalid/expired events are\n * skipped silently (the relay serves plenty of non-peer 10032 experiments).\n */\nexport async function discoverAnnouncedPeers(\n relayUrl: string,\n options: {\n timeoutMs?: number;\n webSocketFactory?: WebSocketFactory;\n } = {}\n): Promise<AnnouncedPeer[]> {\n const factory =\n options.webSocketFactory ?? defaultDiscoveryWebSocketFactory();\n const events = await queryRelay(\n relayUrl,\n { kinds: [ILP_PEER_INFO_KIND], limit: 100 },\n options.timeoutMs ?? DISCOVERY_TIMEOUT_MS,\n factory\n );\n\n const latestByAuthor = new Map<string, NostrEvent>();\n for (const event of events) {\n if (event.kind !== ILP_PEER_INFO_KIND) continue;\n const prev = latestByAuthor.get(event.pubkey);\n if (!prev || event.created_at > prev.created_at) {\n latestByAuthor.set(event.pubkey, event);\n }\n }\n\n const peers: AnnouncedPeer[] = [];\n for (const event of latestByAuthor.values()) {\n if (isEventExpired(event as Parameters<typeof isEventExpired>[0])) {\n continue;\n }\n let info: IlpPeerInfo;\n try {\n info = parseIlpPeerInfo(event as Parameters<typeof parseIlpPeerInfo>[0]);\n } catch {\n continue; // not a schema-valid IlpPeerInfo announce\n }\n const routes = parseRoutes(event.content);\n const capabilities = parseCapabilities(event.content);\n const routePrices = parseRoutePrices(event.content);\n const minaTokenIds = parseMinaTokenIds(event.content);\n const chainRpcUrls = parseChainRpcUrls(event.content);\n peers.push({\n pubkey: event.pubkey,\n info,\n ...(routes ? { routes } : {}),\n ...(capabilities ? { capabilities } : {}),\n ...(routePrices ? { routePrices } : {}),\n ...(minaTokenIds ? { minaTokenIds } : {}),\n ...(chainRpcUrls ? { chainRpcUrls } : {}),\n createdAt: event.created_at,\n });\n }\n return peers;\n}\n\nfunction defaultDiscoveryWebSocketFactory(): WebSocketFactory {\n return (url) => {\n const ctor = (\n globalThis as {\n WebSocket?: new (url: string) => ReturnType<WebSocketFactory>;\n }\n ).WebSocket;\n if (!ctor) {\n throw new Error(\n 'No global WebSocket constructor (Node >= 22 required) for announce discovery'\n );\n }\n return new ctor(url);\n };\n}\n\n/**\n * Pick THE payment peer among discovered announces:\n *\n * 1. the announce authored by a genesis-seed pubkey (the committed apex\n * identity — the strongest signal),\n * 2. else an announce that can actually take paid writes: has an uplink\n * endpoint AND `settlementAddresses`, preferring one whose own\n * `ilpAddress` is its `routes.publish` (the publish edge — that is\n * where rig pays first),\n * 3. freshest `created_at` breaks remaining ties.\n */\nexport function pickPaymentPeer(\n peers: AnnouncedPeer[],\n seedPubkeys: readonly string[]\n): AnnouncedPeer | undefined {\n const seeded = peers.filter((p) => seedPubkeys.includes(p.pubkey));\n if (seeded.length > 0) {\n return seeded.sort((a, b) => b.createdAt - a.createdAt)[0];\n }\n\n const payable = peers.filter(\n (p) =>\n (p.info.httpEndpoint || p.info.btpEndpoint) &&\n p.info.settlementAddresses &&\n Object.keys(p.info.settlementAddresses).length > 0\n );\n if (payable.length === 0) return undefined;\n const publishEdges = payable.filter(\n (p) => p.routes?.publish !== undefined && p.routes.publish === p.info.ilpAddress\n );\n const pool = publishEdges.length > 0 ? publishEdges : payable;\n return pool.sort((a, b) => b.createdAt - a.createdAt)[0];\n}\n\n// ---------------------------------------------------------------------------\n// Per-chain settlement derivation\n// ---------------------------------------------------------------------------\n\n/** Numeric chain id of an `evm:<id>` / `evm:<name>:<id>` chain key. */\nexport function evmChainIdOf(chain: string): number | undefined {\n const parts = chain.split(':');\n if (parts[0] !== 'evm') return undefined;\n const raw = parts.length >= 3 ? parts[2] : parts[1];\n const id = Number.parseInt(raw ?? '', 10);\n return Number.isNaN(id) ? undefined : id;\n}\n\n/**\n * Core chain preset matching an EVM chain key by numeric chain id. Presets\n * carry the DETERMINISTIC TOON contract addresses per chain (e.g. the\n * `anvil` 31337 Foundry deploy), which is what makes `tokenNetwork`\n * derivable without the announce carrying it. Base Sepolia (84532) resolves\n * from core's `base-sepolia` preset directly (>=3.1.1 carries the current\n * public 6-decimal USDC + TokenNetwork; the earlier stale addresses that this\n * function used to correct locally are gone).\n */\nexport function evmPresetForChain(chain: string):\n | { rpcUrl: string; usdcAddress: string; tokenNetworkAddress: string }\n | undefined {\n const id = evmChainIdOf(chain);\n if (id === undefined) return undefined;\n for (const preset of Object.values(CHAIN_PRESETS)) {\n if (preset.chainId === id) {\n return {\n rpcUrl: preset.rpcUrl,\n usdcAddress: preset.usdcAddress,\n tokenNetworkAddress: preset.tokenNetworkAddress,\n };\n }\n }\n return undefined;\n}\n\n/**\n * Public-cluster Solana preset matching a `solana:<cluster>` chain key. Draws\n * from core's client network presets (`resolveClientNetwork`) — the same\n * tables the daemon and townhouse resolve — so the deployed public-devnet\n * program/mint and the mainnet-beta RPC + Circle USDC mint come from ONE\n * source. `programId` is present only where the TOON payment-channel program\n * is actually deployed (public devnet today; mainnet-beta once deployed).\n * Announce-provided values and explicit config always take precedence over\n * these presets (see {@link resolveChainSettlement}) — that precedence is\n * what protected the devnet's former self-hosted validator, whose regenerated\n * program id rode the announce (retired 2026-07; the devnet now settles on\n * the public clusters).\n */\nexport function solanaPresetForChain(chain: string):\n | { rpcUrl?: string; tokenMint?: string; programId?: string }\n | undefined {\n const [family, cluster] = chain.split(':');\n if (family !== 'solana' || !cluster) return undefined;\n const tier =\n cluster === 'mainnet-beta'\n ? 'mainnet'\n : cluster === 'devnet'\n ? 'devnet'\n : cluster === 'testnet'\n ? 'testnet'\n : undefined;\n if (!tier) return undefined;\n const presets = resolveClientNetwork(tier);\n // Look up by the exact chain key: the `testnet` tier resolves to the\n // deployed `solana:devnet` cluster, so `solana:testnet` correctly finds\n // nothing (TOON has no deployment on Solana's testnet cluster).\n const rpcUrl = presets.chainRpcUrls[chain];\n const tokenMint = presets.preferredTokens[chain];\n const programId =\n presets.solanaChannel && presets.supportedChains.includes(chain)\n ? presets.solanaChannel.programId\n : undefined;\n if (!rpcUrl && !tokenMint && !programId) return undefined;\n return {\n ...(rpcUrl ? { rpcUrl } : {}),\n ...(tokenMint ? { tokenMint } : {}),\n ...(programId ? { programId } : {}),\n };\n}\n\n/**\n * Public-network Mina preset matching a `mina:<network>` chain key. Draws from\n * core's client network presets (`resolveClientNetwork`) — the SAME tables the\n * daemon and townhouse resolve — so the deployed devnet graphqlUrl and network\n * id come from ONE source.\n *\n * IMPORTANT — the preset supplies only the NON-deployment-specific defaults\n * (`graphqlUrl`, `networkId`): the public minascan endpoint and the network id\n * derivable from the chain key. It also carries the preset's `zkAppAddress`\n * (and, in a future core release, a `tokenId`) as an OFFLINE-ONLY fallback, but\n * the payment-channel zkApp and the custom-token id are DEPLOYMENT-specific and\n * go stale on redeploy — exactly the drift that produced the stale\n * base-sepolia/solana bug (#103). So the live announce (which advertises the\n * deployment's own zkApp via `tokenNetworks` and its token id via\n * `minaTokenIds`) ALWAYS takes precedence over these preset values in\n * {@link resolveChainSettlement}. `undefined` for non-`mina:*` chains and for\n * networks with no deployed TOON zkApp (e.g. `mina:mainnet`).\n */\nexport function minaPresetForChain(chain: string):\n | {\n graphqlUrl?: string;\n zkAppAddress?: string;\n tokenId?: string;\n networkId?: 'devnet' | 'mainnet';\n }\n | undefined {\n const [family, network] = chain.split(':');\n if (family !== 'mina' || !network) return undefined;\n // Mina has no separate `testnet` network — the deployment is on `mina:devnet`\n // (the core `testnet` tier resolves to the same devnet zkApp, so `mina:testnet`\n // is not a real chain and must resolve to nothing, mirroring `solana:testnet`).\n const tier =\n network === 'mainnet' ? 'mainnet' : network === 'devnet' ? 'devnet' : undefined;\n if (!tier) return undefined;\n const presets = resolveClientNetwork(tier);\n const mina = presets.minaChannel;\n if (!mina) return undefined;\n // Core >= 3.1.1's `minaChannel` carries { graphqlUrl, zkAppAddress,\n // networkId }; a `tokenId` field is read opportunistically so a future core\n // release can add it without a client change (announce still wins).\n const tokenId = (mina as { tokenId?: string }).tokenId;\n return {\n ...(mina.graphqlUrl ? { graphqlUrl: mina.graphqlUrl } : {}),\n ...(mina.zkAppAddress ? { zkAppAddress: mina.zkAppAddress } : {}),\n ...(tokenId ? { tokenId } : {}),\n ...(mina.networkId ? { networkId: mina.networkId } : {}),\n };\n}\n\n/** Explicit per-chain maps from the shared client-config file. */\nexport interface ExplicitChainConfig {\n chainRpcUrls?: Record<string, string>;\n preferredTokens?: Record<string, string>;\n tokenNetworks?: Record<string, string>;\n}\n\n/**\n * Resolve one chain's settlement parameters: explicit config > announce >\n * core chain preset. Fields stay undefined when no source covers them —\n * callers decide whether that is fatal (see\n * {@link TokenNetworkUnderivableError} /\n * {@link SolanaChannelUnderivableError}).\n *\n * For `solana:*` chains the chain-keyed maps carry the SPL analogues: the\n * `preferredTokens` entry is the token mint, and the `tokenNetworks` entry is\n * the payment-channel PROGRAM id (the map is chain-keyed settlement-contract\n * addressing — TokenNetwork contract on EVM, channel program on Solana),\n * surfaced as {@link ChainSettlement.programId}.\n */\nexport function resolveChainSettlement(\n chain: string,\n explicit: ExplicitChainConfig,\n announce?: AnnouncedPeer\n): ChainSettlement {\n const family = chain.split(':')[0] ?? chain;\n const evmPreset = family === 'evm' ? evmPresetForChain(chain) : undefined;\n const solPreset = family === 'solana' ? solanaPresetForChain(chain) : undefined;\n const minaPreset = family === 'mina' ? minaPresetForChain(chain) : undefined;\n\n const rpcUrl =\n explicit.chainRpcUrls?.[chain] ??\n // The live deployment's advertised RPC beats the baked preset default: a\n // preset RPC can be a stale/broken endpoint (e.g. Base Sepolia's\n // sepolia.base.org fails setTotalDeposit) while the announce carries the\n // deployment's known-good URL. Same drift lesson as #103.\n announce?.chainRpcUrls?.[chain] ??\n evmPreset?.rpcUrl ??\n solPreset?.rpcUrl ??\n // For Mina the \"RPC\" is the GraphQL endpoint (non-deployment-specific).\n minaPreset?.graphqlUrl;\n const tokenAddress =\n explicit.preferredTokens?.[chain] ??\n announce?.info.preferredTokens?.[chain] ??\n (evmPreset?.usdcAddress || undefined) ??\n solPreset?.tokenMint;\n const tokenNetwork =\n family === 'evm'\n ? (explicit.tokenNetworks?.[chain] ??\n announce?.info.tokenNetworks?.[chain] ??\n (evmPreset?.tokenNetworkAddress || undefined))\n : undefined;\n const programId =\n family === 'solana'\n ? (explicit.tokenNetworks?.[chain] ??\n announce?.info.tokenNetworks?.[chain] ??\n solPreset?.programId)\n : undefined;\n // Mina: the settlement-contract slot (`tokenNetworks`, chain-keyed) carries\n // the payment-channel zkApp address — the announce advertises it exactly as\n // Solana advertises its program id. The token id rides the out-of-band\n // `minaTokenIds` content map. Both prefer explicit config > announce > the\n // (drift-prone) preset fallback; the graphqlUrl/networkId come from the\n // preset (or the derived chain key).\n const zkAppAddress =\n family === 'mina'\n ? (explicit.tokenNetworks?.[chain] ??\n announce?.info.tokenNetworks?.[chain] ??\n minaPreset?.zkAppAddress)\n : undefined;\n const minaTokenId =\n family === 'mina'\n ? (announce?.minaTokenIds?.[chain] ?? minaPreset?.tokenId)\n : undefined;\n const networkId =\n family === 'mina'\n ? (minaPreset?.networkId ??\n (chain.split(':')[1] === 'mainnet' ? 'mainnet' : 'devnet'))\n : undefined;\n\n return {\n chain,\n family,\n ...(rpcUrl ? { rpcUrl } : {}),\n ...(tokenAddress ? { tokenAddress } : {}),\n ...(tokenNetwork ? { tokenNetwork } : {}),\n ...(programId ? { programId } : {}),\n ...(zkAppAddress ? { zkAppAddress } : {}),\n ...(minaTokenId ? { minaTokenId } : {}),\n ...(networkId ? { networkId } : {}),\n };\n}\n\n/** An EVM chain was selected but its TokenNetwork cannot be derived. */\nexport class TokenNetworkUnderivableError extends Error {\n constructor(chain: string, announce: AnnouncedPeer | undefined, relayUrl: string) {\n const announceRef = announce\n ? `the kind:10032 announce from ${announce.pubkey.slice(0, 16)}… on ${relayUrl}`\n : `no kind:10032 announce was found on ${relayUrl}`;\n super(\n `cannot derive the TokenNetwork contract for settlement chain ` +\n `\"${chain}\": ${announceRef} carries no tokenNetworks[\"${chain}\"], ` +\n `and no built-in chain preset matches its chain id — add ` +\n `tokenNetworks[\"${chain}\"] to the client config (or pick another ` +\n `chain via TOON_CLIENT_CHAIN / the chain config field)`\n );\n this.name = 'TokenNetworkUnderivableError';\n }\n}\n\n/**\n * A Solana chain was selected but its channel parameters cannot be derived.\n * The missing pieces are named so the error is directly actionable: a\n * `solanaChannel` config object always works; the chain-keyed maps\n * (`tokenNetworks` = program id, `preferredTokens` = mint,\n * `chainRpcUrls` = RPC) work per-chain.\n */\nexport class SolanaChannelUnderivableError extends Error {\n constructor(\n chain: string,\n missing: string[],\n announce: AnnouncedPeer | undefined,\n relayUrl: string\n ) {\n const announceRef = announce\n ? `the kind:10032 announce from ${announce.pubkey.slice(0, 16)}… on ${relayUrl} does not carry them`\n : `no kind:10032 announce was found on ${relayUrl}`;\n super(\n `cannot derive the Solana channel parameters for settlement chain ` +\n `\"${chain}\" (missing: ${missing.join(', ')}): ${announceRef}, and ` +\n `no built-in preset covers this cluster — add a solanaChannel ` +\n `{ rpcUrl, programId, tokenMint } object to the client config (or ` +\n `set tokenNetworks[\"${chain}\"] = <program id>, ` +\n `preferredTokens[\"${chain}\"] = <mint>, chainRpcUrls[\"${chain}\"]), ` +\n `or pick another chain via TOON_CLIENT_CHAIN / the chain config field`\n );\n this.name = 'SolanaChannelUnderivableError';\n }\n}\n\n/**\n * A Mina chain was selected but its channel parameters cannot be derived. The\n * missing pieces are named so the error is directly actionable: an explicit\n * `minaChannel` config object always works; the live announce normally\n * supplies the zkApp (`tokenNetworks[\"mina:…\"]`) and token id\n * (`minaTokenIds[\"mina:…\"]`), while the graphqlUrl comes from a core preset.\n */\nexport class MinaChannelUnderivableError extends Error {\n constructor(\n chain: string,\n missing: string[],\n announce: AnnouncedPeer | undefined,\n relayUrl: string\n ) {\n const announceRef = announce\n ? `the kind:10032 announce from ${announce.pubkey.slice(0, 16)}… on ${relayUrl} does not carry them`\n : `no kind:10032 announce was found on ${relayUrl}`;\n super(\n `cannot derive the Mina channel parameters for settlement chain ` +\n `\"${chain}\" (missing: ${missing.join(', ')}): ${announceRef}, and ` +\n `no built-in preset covers this network — add a minaChannel ` +\n `{ graphqlUrl, zkAppAddress, tokenId, networkId } object to the client ` +\n `config (or set tokenNetworks[\"${chain}\"] = <zkApp address> and ` +\n `chainRpcUrls[\"${chain}\"] = <graphql url>), or pick another chain via ` +\n `TOON_CLIENT_CHAIN / the chain config field`\n );\n this.name = 'MinaChannelUnderivableError';\n }\n}\n\n// ---------------------------------------------------------------------------\n// Settlement-chain selection (#260 root cause 4)\n// ---------------------------------------------------------------------------\n\n/** The slice of a #262 channel-map record chain selection consumes. */\nexport interface ChannelRecordLike {\n chain: string;\n lastUsedAt: string;\n /** True when the withdraw flow closed/settled the channel. */\n closed: boolean;\n}\n\n/** Async token-balance probe (injectable; default is a raw `eth_call`). */\nexport type EvmBalanceProbe = (args: {\n rpcUrl: string;\n tokenAddress: string;\n owner: string;\n}) => Promise<bigint>;\n\n/**\n * Async SPL token-balance probe (injectable; default is a raw\n * `getTokenAccountsByOwner`). `tokenAddress` is the SPL mint and `owner`\n * the identity's base58 Solana address — the same argument shape as\n * {@link EvmBalanceProbe} so both feed the one funded-chain loop.\n */\nexport type SolanaBalanceProbe = (args: {\n rpcUrl: string;\n tokenAddress: string;\n owner: string;\n}) => Promise<bigint>;\n\nexport interface SelectChainOptions {\n /**\n * Explicit chain choice: full chain id (`evm:31337`), a family\n * (`evm` | `solana` | `mina`) matched against announced chains, or the\n * first entry of an explicit `supportedChains` config.\n */\n explicitChain?: string;\n /** Chains the payment peer announces (announce order preserved). */\n announcedChains: readonly string[];\n /** #262 channel-map records for this identity (any anchor). */\n records?: readonly ChannelRecordLike[];\n /** Identity's EVM address (funded-chain probe, `evm:*` candidates). */\n evmAddress?: string;\n /**\n * Identity's base58 Solana address (funded-chain probe, `solana:*`\n * candidates). Absent (e.g. the identity's Ed25519 key could not be\n * derived) means Solana chains are simply not probed.\n */\n solanaAddress?: string;\n /** Per-chain settlement resolver (for RPC/token of probe candidates). */\n resolveSettlement: (chain: string) => ChainSettlement;\n /** EVM balance probe; probe errors just skip the candidate. */\n probeBalance?: EvmBalanceProbe;\n /** Solana balance probe; probe errors just skip the candidate. */\n probeSolanaBalance?: SolanaBalanceProbe;\n}\n\n/**\n * Select the settlement chain per the documented rule: explicit >\n * persisted channel > funded chain (EVM + Solana, in announce order) >\n * first announced EVM chain.\n */\nexport async function selectSettlementChain(\n options: SelectChainOptions\n): Promise<ChainSelection> {\n const { explicitChain, announcedChains } = options;\n\n // 1 — explicit config always wins (even when the peer does not announce\n // it: the user may know better than a stale announce).\n if (explicitChain) {\n if (explicitChain.includes(':')) {\n // Chain negotiation is an EXACT string intersection: a full chain id\n // spelled differently from the announce for the SAME EVM chain\n // (`evm:base:84532` vs announced `evm:84532`) would strand the pin and\n // let negotiation fall through to another chain entirely. Align an\n // explicit EVM chain id to the announced spelling (same rule the\n // configured-supportedChains path applies).\n if (!announcedChains.includes(explicitChain)) {\n const chainId = evmChainIdOf(explicitChain);\n const equivalent =\n chainId !== undefined\n ? announcedChains.find((c) => evmChainIdOf(c) === chainId)\n : undefined;\n if (equivalent) {\n return {\n chain: equivalent,\n reason: 'explicit',\n detail:\n `chain ${explicitChain} set by config → announced spelling ` +\n `${equivalent} (same EVM chain id ${chainId})`,\n };\n }\n }\n return {\n chain: explicitChain,\n reason: 'explicit',\n detail: `chain ${explicitChain} set by config`,\n };\n }\n const familyMatch = announcedChains.find(\n (c) => (c.split(':')[0] ?? c) === explicitChain\n );\n if (!familyMatch) {\n throw new Error(\n `configured chain family \"${explicitChain}\" is not announced by the ` +\n `payment peer (announced: ${announcedChains.join(', ') || 'none'}) — ` +\n 'set a full chain id (e.g. \"evm:31337\") to force it'\n );\n }\n return {\n chain: familyMatch,\n reason: 'explicit',\n detail: `chain family \"${explicitChain}\" set by config → ${familyMatch}`,\n };\n }\n\n // 2 — a live persisted channel means collateral is already locked there.\n const live = (options.records ?? [])\n .filter((r) => !r.closed && announcedChains.includes(r.chain))\n .sort((a, b) => b.lastUsedAt.localeCompare(a.lastUsedAt));\n const persisted = live[0];\n if (persisted) {\n return {\n chain: persisted.chain,\n reason: 'persisted-channel',\n detail: `existing payment channel on ${persisted.chain} (rig channel map)`,\n };\n }\n\n // 3 — first announced chain where the identity holds tokens, probing\n // EVM and Solana candidates in ANNOUNCE ORDER (the peer's stated\n // preference breaks a both-funded tie). Families without an address or\n // probe are skipped, as are candidates whose RPC/token are underivable.\n const evmChains = announcedChains.filter((c) => c.startsWith('evm:'));\n for (const chain of announcedChains) {\n const family = chain.split(':')[0];\n let probe: EvmBalanceProbe | SolanaBalanceProbe | undefined;\n let owner: string | undefined;\n if (family === 'evm') {\n probe = options.probeBalance;\n owner = options.evmAddress;\n } else if (family === 'solana') {\n probe = options.probeSolanaBalance;\n owner = options.solanaAddress;\n }\n if (!probe || !owner) continue;\n const settlement = options.resolveSettlement(chain);\n if (!settlement.rpcUrl || !settlement.tokenAddress) continue;\n try {\n const balance = await probe({\n rpcUrl: settlement.rpcUrl,\n tokenAddress: settlement.tokenAddress,\n owner,\n });\n if (balance > 0n) {\n return {\n chain,\n reason: 'funded',\n detail: `wallet holds ${balance} token base units on ${chain}`,\n };\n }\n } catch {\n // Unreachable RPC / bad token — not a candidate; fall through.\n }\n }\n\n // 4 — predictable default: the first EVM chain the peer announces.\n const fallback = evmChains[0] ?? announcedChains[0];\n if (!fallback) {\n throw new Error(\n 'the payment peer announces no settlement chains — cannot select a ' +\n 'chain for paid writes (set supportedChains/chain in the client config)'\n );\n }\n return {\n chain: fallback,\n reason: 'default',\n detail: evmChains[0]\n ? `first EVM chain announced by the payment peer`\n : `first chain announced by the payment peer (no EVM chain announced)`,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Default balance probes (raw JSON-RPC, no extra deps)\n// ---------------------------------------------------------------------------\n\n/** ERC-20 `balanceOf(address)` selector. */\nconst BALANCE_OF_SELECTOR = '0x70a08231';\n\n/**\n * Read an ERC-20 balance with one raw `eth_call` (keeps the probe free of\n * viem — the embedded client is not started yet when selection runs).\n */\nexport async function evmTokenBalance(args: {\n rpcUrl: string;\n tokenAddress: string;\n owner: string;\n fetchImpl?: typeof fetch;\n timeoutMs?: number;\n}): Promise<bigint> {\n const fetchImpl = args.fetchImpl ?? fetch;\n const owner = args.owner.replace(/^0x/, '').toLowerCase().padStart(64, '0');\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), args.timeoutMs ?? 5000);\n try {\n const res = await fetchImpl(args.rpcUrl, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'eth_call',\n params: [\n { to: args.tokenAddress, data: `${BALANCE_OF_SELECTOR}${owner}` },\n 'latest',\n ],\n }),\n signal: controller.signal,\n });\n if (!res.ok) {\n throw new Error(`eth_call failed: HTTP ${res.status}`);\n }\n const body = (await res.json()) as { result?: unknown; error?: { message?: string } };\n if (typeof body.result !== 'string') {\n throw new Error(`eth_call failed: ${body.error?.message ?? 'no result'}`);\n }\n return BigInt(body.result === '0x' ? '0x0' : body.result);\n } finally {\n clearTimeout(timer);\n }\n}\n\n/**\n * Read an SPL token balance with one raw `getTokenAccountsByOwner` call\n * (keeps the probe free of @solana/web3.js — the embedded client is not\n * started yet when selection runs). `tokenAddress` is the mint; balances\n * are summed across all of the owner's token accounts for that mint (an\n * owner can hold the mint in more than one account).\n */\nexport async function solanaTokenBalance(args: {\n rpcUrl: string;\n tokenAddress: string;\n owner: string;\n fetchImpl?: typeof fetch;\n timeoutMs?: number;\n}): Promise<bigint> {\n const fetchImpl = args.fetchImpl ?? fetch;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), args.timeoutMs ?? 5000);\n try {\n const res = await fetchImpl(args.rpcUrl, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'getTokenAccountsByOwner',\n params: [\n args.owner,\n { mint: args.tokenAddress },\n { encoding: 'jsonParsed' },\n ],\n }),\n signal: controller.signal,\n });\n if (!res.ok) {\n throw new Error(`getTokenAccountsByOwner failed: HTTP ${res.status}`);\n }\n const body = (await res.json()) as {\n result?: { value?: unknown };\n error?: { message?: string };\n };\n const accounts = body.result?.value;\n if (!Array.isArray(accounts)) {\n throw new Error(\n `getTokenAccountsByOwner failed: ${body.error?.message ?? 'no result'}`\n );\n }\n let total = 0n;\n for (const account of accounts) {\n const amount = (\n account as {\n account?: {\n data?: {\n parsed?: { info?: { tokenAmount?: { amount?: unknown } } };\n };\n };\n }\n )?.account?.data?.parsed?.info?.tokenAmount?.amount;\n if (typeof amount === 'string') total += BigInt(amount);\n }\n return total;\n } finally {\n clearTimeout(timer);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Genesis seed access (rig's own core 3.x — live devnet apex since core 3.x)\n// ---------------------------------------------------------------------------\n\n/** The committed genesis peer seed (first entry), if any. */\nexport function loadGenesisSeed(): GenesisPeer | undefined {\n return GenesisPeerLoader.loadGenesisPeers()[0];\n}\n\n/** All committed genesis-seed pubkeys (announce-selection preference). */\nexport function genesisSeedPubkeys(): string[] {\n return GenesisPeerLoader.loadGenesisPeers().map((p) => p.pubkey);\n}\n"],"mappings":";;;;;AA8CA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAYA,IAAM,qBAAqB;AAsH3B,IAAM,uBAAuB;AAEpC,SAAS,YAAY,SAA8C;AACjE,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,OAAO;AACjC,UAAM,SAAS,OAAO;AACtB,QAAI,OAAO,WAAW,YAAY,WAAW,KAAM,QAAO;AAC1D,UAAM,EAAE,SAAS,MAAM,IAAI;AAC3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,QAAI,CAAC,MAAM,QAAQ,QAAQ,GAAG;AAC5B,YAAM,IAAI;AAAA,QACR,mCAAmC,KAAK,OAAO,WAAW,WAAW;AAAA,MACvE;AAAA,IACF;AACA,QAAI,QAAQ;AACZ,eAAW,WAAW,UAAU;AAC9B,YAAM,SACJ,SAOC,SAAS,MAAM,QAAQ,MAAM,aAAa;AAC7C,UAAI,OAAO,WAAW,SAAU,UAAS,OAAO,MAAM;AAAA,IACxD;AACA,WAAO;AAAA,EACT,UAAE;AACA,iBAAa,KAAK;AAAA,EACpB;AACF;AAOO,SAAS,kBAA2C;AACzD,SAAO,kBAAkB,iBAAiB,EAAE,CAAC;AAC/C;AAGO,SAAS,qBAA+B;AAC7C,SAAO,kBAAkB,iBAAiB,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM;AACjE;","names":[]}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DISCOVERY_TIMEOUT_MS,
|
|
3
|
-
ILP_PEER_INFO_KIND,
|
|
4
|
-
MinaChannelUnderivableError,
|
|
5
|
-
SolanaChannelUnderivableError,
|
|
6
|
-
TokenNetworkUnderivableError,
|
|
7
|
-
discoverAnnouncedPeers,
|
|
8
|
-
evmChainIdOf,
|
|
9
|
-
evmPresetForChain,
|
|
10
|
-
evmTokenBalance,
|
|
11
|
-
genesisSeedPubkeys,
|
|
12
|
-
loadGenesisSeed,
|
|
13
|
-
minaPresetForChain,
|
|
14
|
-
pickPaymentPeer,
|
|
15
|
-
resolveChainSettlement,
|
|
16
|
-
selectSettlementChain,
|
|
17
|
-
solanaPresetForChain,
|
|
18
|
-
solanaTokenBalance
|
|
19
|
-
} from "./chunk-UZZ2RN7A.js";
|
|
20
|
-
import "./chunk-2KJJ7LSO.js";
|
|
21
|
-
export {
|
|
22
|
-
DISCOVERY_TIMEOUT_MS,
|
|
23
|
-
ILP_PEER_INFO_KIND,
|
|
24
|
-
MinaChannelUnderivableError,
|
|
25
|
-
SolanaChannelUnderivableError,
|
|
26
|
-
TokenNetworkUnderivableError,
|
|
27
|
-
discoverAnnouncedPeers,
|
|
28
|
-
evmChainIdOf,
|
|
29
|
-
evmPresetForChain,
|
|
30
|
-
evmTokenBalance,
|
|
31
|
-
genesisSeedPubkeys,
|
|
32
|
-
loadGenesisSeed,
|
|
33
|
-
minaPresetForChain,
|
|
34
|
-
pickPaymentPeer,
|
|
35
|
-
resolveChainSettlement,
|
|
36
|
-
selectSettlementChain,
|
|
37
|
-
solanaPresetForChain,
|
|
38
|
-
solanaTokenBalance
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=network-bootstrap-27FYE3N7.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|