@parity/product-deploy 0.7.28-rc.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.
Files changed (109) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +233 -0
  3. package/assets/environments.json +313 -0
  4. package/bin/bulletin-bootstrap +84 -0
  5. package/bin/bulletin-deploy +429 -0
  6. package/dist/bug-report.d.ts +29 -0
  7. package/dist/bug-report.js +27 -0
  8. package/dist/chunk-2VAUMZB2.js +284 -0
  9. package/dist/chunk-43HLT335.js +232 -0
  10. package/dist/chunk-5VZQ2KSU.js +231 -0
  11. package/dist/chunk-ADNBLFDP.js +225 -0
  12. package/dist/chunk-BMAEWZYV.js +24 -0
  13. package/dist/chunk-C2TS5MER.js +64 -0
  14. package/dist/chunk-DNXH4QTI.js +2336 -0
  15. package/dist/chunk-FZWJV5AD.js +231 -0
  16. package/dist/chunk-GZD2UFLR.js +8 -0
  17. package/dist/chunk-HOTQDYHD.js +219 -0
  18. package/dist/chunk-IDYGYIMH.js +207 -0
  19. package/dist/chunk-KHVTYIIX.js +146 -0
  20. package/dist/chunk-KJH2T5TQ.js +172 -0
  21. package/dist/chunk-KOSF5FDO.js +49 -0
  22. package/dist/chunk-LZJMVPYW.js +156 -0
  23. package/dist/chunk-MFTODIIT.js +725 -0
  24. package/dist/chunk-MMAZFJDG.js +91 -0
  25. package/dist/chunk-NF2FL4ZO.js +164 -0
  26. package/dist/chunk-OITUIM2E.js +524 -0
  27. package/dist/chunk-P6CHOMN3.js +2368 -0
  28. package/dist/chunk-QMYW3D6E.js +316 -0
  29. package/dist/chunk-QTZNULSH.js +185 -0
  30. package/dist/chunk-RI3ZLNPN.js +71 -0
  31. package/dist/chunk-S7EM5VMW.js +108 -0
  32. package/dist/chunk-T7EEVWNU.js +32 -0
  33. package/dist/chunk-UPWEOGLQ.js +37 -0
  34. package/dist/chunk-ZOC4GITL.js +13 -0
  35. package/dist/chunk-ZYVGHDMU.js +117 -0
  36. package/dist/chunk-probe.d.ts +37 -0
  37. package/dist/chunk-probe.js +18 -0
  38. package/dist/chunker.d.ts +8 -0
  39. package/dist/chunker.js +10 -0
  40. package/dist/deploy.d.ts +299 -0
  41. package/dist/deploy.js +96 -0
  42. package/dist/dotns.d.ts +506 -0
  43. package/dist/dotns.js +101 -0
  44. package/dist/environments.d.ts +104 -0
  45. package/dist/environments.js +23 -0
  46. package/dist/errors.d.ts +6 -0
  47. package/dist/errors.js +8 -0
  48. package/dist/gh-pages-mirror.d.ts +76 -0
  49. package/dist/gh-pages-mirror.js +30 -0
  50. package/dist/incremental-stats.d.ts +69 -0
  51. package/dist/incremental-stats.js +10 -0
  52. package/dist/index.d.ts +23 -0
  53. package/dist/index.js +146 -0
  54. package/dist/manifest/byte-budget.d.ts +46 -0
  55. package/dist/manifest/byte-budget.js +14 -0
  56. package/dist/manifest/config-load.d.ts +36 -0
  57. package/dist/manifest/config-load.js +10 -0
  58. package/dist/manifest/publish.d.ts +54 -0
  59. package/dist/manifest/publish.js +23 -0
  60. package/dist/manifest/schema.d.ts +29 -0
  61. package/dist/manifest/schema.js +10 -0
  62. package/dist/manifest/types.d.ts +90 -0
  63. package/dist/manifest/types.js +6 -0
  64. package/dist/manifest-embed.d.ts +18 -0
  65. package/dist/manifest-embed.js +9 -0
  66. package/dist/manifest-fetch.d.ts +32 -0
  67. package/dist/manifest-fetch.js +21 -0
  68. package/dist/manifest-roundtrip.d.ts +15 -0
  69. package/dist/manifest-roundtrip.js +55 -0
  70. package/dist/manifest.d.ts +44 -0
  71. package/dist/manifest.js +20 -0
  72. package/dist/memory-report.d.ts +95 -0
  73. package/dist/memory-report.js +17 -0
  74. package/dist/merkle.d.ts +50 -0
  75. package/dist/merkle.js +33 -0
  76. package/dist/personhood/bind-paid-alias.d.ts +43 -0
  77. package/dist/personhood/bind-paid-alias.js +10 -0
  78. package/dist/personhood/bind-personal-id.d.ts +55 -0
  79. package/dist/personhood/bind-personal-id.js +12 -0
  80. package/dist/personhood/bootstrap.d.ts +85 -0
  81. package/dist/personhood/bootstrap.js +245 -0
  82. package/dist/personhood/claim-pgas.d.ts +61 -0
  83. package/dist/personhood/claim-pgas.js +12 -0
  84. package/dist/personhood/constants.d.ts +23 -0
  85. package/dist/personhood/constants.js +22 -0
  86. package/dist/personhood/encoding.d.ts +49 -0
  87. package/dist/personhood/encoding.js +24 -0
  88. package/dist/personhood/hashing.d.ts +4 -0
  89. package/dist/personhood/hashing.js +8 -0
  90. package/dist/personhood/member-key.d.ts +12 -0
  91. package/dist/personhood/member-key.js +10 -0
  92. package/dist/personhood/people-client.d.ts +14 -0
  93. package/dist/personhood/people-client.js +48 -0
  94. package/dist/personhood/reprove.d.ts +43 -0
  95. package/dist/personhood/reprove.js +225 -0
  96. package/dist/pool.d.ts +51 -0
  97. package/dist/pool.js +30 -0
  98. package/dist/run-state.d.ts +22 -0
  99. package/dist/run-state.js +20 -0
  100. package/dist/telemetry.d.ts +56 -0
  101. package/dist/telemetry.js +71 -0
  102. package/dist/version-check.d.ts +38 -0
  103. package/dist/version-check.js +30 -0
  104. package/docs/bootstrap.md +49 -0
  105. package/docs/e2e-bootstrap.md +154 -0
  106. package/docs/telemetry.md +62 -0
  107. package/docs/testing.md +44 -0
  108. package/package.json +82 -0
  109. package/tools/release-retry-wrapper.mjs +74 -0
@@ -0,0 +1,524 @@
1
+ import {
2
+ NonRetryableError
3
+ } from "./chunk-ZOC4GITL.js";
4
+
5
+ // src/environments.ts
6
+ import * as fs from "fs/promises";
7
+ import { fileURLToPath } from "url";
8
+
9
+ // assets/environments.json
10
+ var environments_default = {
11
+ environments: [
12
+ {
13
+ id: "preview",
14
+ name: "Preview",
15
+ network: "testnet",
16
+ description: "Product Preview net, used by Product Teams",
17
+ backend: "https://polkadot-app-stg.parity.io/",
18
+ ipfs: "https://previewnet.substrate.dev",
19
+ autoAccountMapping: true,
20
+ bulletinAuthorizeV2: true,
21
+ registerStorageDeposit: 2e12,
22
+ contracts: {
23
+ DOTNS_PROTOCOL_REGISTRY: "0xc07A2F24387DA27283CD87b9F24573b74C9e0c9b",
24
+ DOTNS_REGISTRAR: "0x6c40817cdb96Ab57A4d9E9fa21D0eEa8307BDDE8",
25
+ DOTNS_REGISTRAR_CONTROLLER: "0x732C38082CFAebed505A46e4e2D6414154694580",
26
+ DOTNS_REGISTRY: "0xE6c0fB6D5492666144A8a4a015E25a98ACa604cA",
27
+ DOTNS_POP_CONTROLLER: "0xfE1e25E8d521CaaA8055301CA61Ec3557263Ca76",
28
+ DOTNS_RESOLVER: "0x5E174c960F5276Bd0387F200cE42f98fe927E220",
29
+ DOTNS_CONTENT_RESOLVER: "0x108376A5B6DDc6BE3201C94Fd169BE444f220076",
30
+ DOTNS_REVERSE_RESOLVER: "0xd5C3dcC7CE44593fEB1D72017A3539c4dB14e54a",
31
+ DOTNS_POP_RESOLVER: "0x29Ace5d2C57109c82A30Db175e645880572c6369",
32
+ DOTNS_NAME_ESCROW: "0x034b072eB8AF5cEfd820390bfe239bD911174ad2",
33
+ POP_RULES: "0x5f2Dd23Ee3ceD39B293701ccE8355DdDd83Cd324",
34
+ STORE_FACTORY: "0x9C38DFec452391696a8f0D3daFE71F7Eb29e08f8",
35
+ LABEL_STORE_BEACON: "0x6B609A89Fec9898B441E17f1618670bdD08c437e",
36
+ USER_STORE_BEACON: "0xbeb79e8BB2bC610822e8748e5439B9D890d88FF5"
37
+ }
38
+ },
39
+ {
40
+ id: "paseo-next",
41
+ name: "Paseo Next",
42
+ network: "testnet",
43
+ badge: "Testflight",
44
+ description: "Production testnet for Polkadot App Testflight",
45
+ backend: "https://identity-backend.parity-testnet.parity.io",
46
+ ipfs: "https://paseo-ipfs.polkadot.io",
47
+ uptimeUrl: "https://stats.uptimerobot.com/LISM1LRA8m"
48
+ },
49
+ {
50
+ id: "paseo-review",
51
+ name: "Paseo Review",
52
+ network: "testnet",
53
+ description: "Used for App Store review builds",
54
+ backend: "https://identity-backend-review.parity-testnet.parity.io",
55
+ ipfs: "https://paseo-bulletin-review-ipfs.polkadot.io",
56
+ uptimeUrl: "https://stats.uptimerobot.com/bckl1cu0AO"
57
+ },
58
+ {
59
+ id: "paseo-next-v2",
60
+ name: "Paseo Next v2",
61
+ network: "testnet",
62
+ description: "Next iteration of the Paseo Next testnet",
63
+ backend: "https://identity-backend-next.parity-testnet.parity.io",
64
+ ipfs: "https://paseo-bulletin-next-ipfs.polkadot.io",
65
+ docsUrl: "https://sre.teleport.parity.io/environments/paseo-next/",
66
+ autoAccountMapping: true,
67
+ bulletinAuthorizeV2: true,
68
+ nativeToEthRatio: 1e8,
69
+ registerStorageDeposit: 2e12,
70
+ popSelfServe: {
71
+ sudoEnvLabel: "Next V2",
72
+ faucetUrl: "https://faucet.polkadot.io/?parachain=1500",
73
+ personhoodFaucetUrl: "https://sudo.personhood.dev/personhood-faucet",
74
+ dotnsBootstrapUrl: "https://sudo.personhood.dev/dotns-bootstrap",
75
+ stateAwareGuidance: true
76
+ },
77
+ contracts: {
78
+ DOTNS_PROTOCOL_REGISTRY: "0x5Caef84563fc980178e28417414aa65bA32f6B4e",
79
+ DOTNS_REGISTRAR: "0x885b8085bA92A31c4ef52076f77379E647ECC399",
80
+ DOTNS_REGISTRAR_CONTROLLER: "0x320b72c6e70D5a631d835FfD95915B288b26E6Be",
81
+ DOTNS_REGISTRY: "0x8877344A885682523B4613779C95688ed7037BfD",
82
+ DOTNS_POP_CONTROLLER: "0xaC8A28b60832E6E22bC19bD9Ee273C008576Bde4",
83
+ ROOT_GATEWAY_DISPATCHER: "0xF470Dd693ED557b33f8775476776532D99Fb60d9",
84
+ DOTNS_RESOLVER: "0x0cCdfea1a5E62DE116BF6cA79D397798d49e351E",
85
+ DOTNS_CONTENT_RESOLVER: "0x2c9FF5D9136DBE5814C7B4FDbeDC15273a776663",
86
+ DOTNS_REVERSE_RESOLVER: "0x025D5c4b10bD9723DeA2F4518aeD5B761DE08CDc",
87
+ DOTNS_POP_RESOLVER: "0xB992e74cBeaf1Fd71310f85D1944d3A0c15C4c73",
88
+ DOTNS_NAME_ESCROW: "0x6F7068c04487a90BFB42b128B84231c252b3017a",
89
+ POP_RULES: "0x2002C1c15b88632Ad01c7770f6EbE1Ca05c8472E",
90
+ STORE_FACTORY: "0x0DE5De70d61cc6b44B45d6595afDe8dB9b55bc31",
91
+ LABEL_STORE_BEACON: "0xD033F7Ada687E8BC776928AB239505F9f0479Ce7",
92
+ USER_STORE_BEACON: "0x7eD9b7D137Fa535965048F93b3B0248fEd2fcd32",
93
+ PUBLISHER: "0x1307fc02d308f879a16b1ae3a49b4927aed53649"
94
+ }
95
+ },
96
+ {
97
+ id: "polkadot",
98
+ name: "Polkadot",
99
+ network: "mainnet",
100
+ description: "Polkadot mainnet",
101
+ autoAccountMapping: true
102
+ },
103
+ {
104
+ id: "kusama",
105
+ name: "Kusama",
106
+ network: "mainnet",
107
+ description: "Kusama canary network",
108
+ autoAccountMapping: true
109
+ }
110
+ ],
111
+ chains: [
112
+ {
113
+ id: "relay",
114
+ name: "Relay",
115
+ endpoints: {
116
+ preview: {
117
+ wss: "wss://previewnet.substrate.dev/relay/alice"
118
+ },
119
+ "paseo-next": {
120
+ wss: "wss://paseo-rpc.n.dwellir.com",
121
+ uptimeUrl: "https://stats.uptimerobot.com/UrEXbl6Xyt"
122
+ },
123
+ "paseo-review": {
124
+ wss: "wss://paseo-rpc.n.dwellir.com",
125
+ uptimeUrl: "https://stats.uptimerobot.com/UrEXbl6Xyt"
126
+ },
127
+ "paseo-next-v2": {
128
+ wss: "wss://paseo-rpc.n.dwellir.com",
129
+ uptimeUrl: "https://stats.uptimerobot.com/UrEXbl6Xyt"
130
+ },
131
+ polkadot: {
132
+ wss: [
133
+ "wss://polkadot-rpc.n.dwellir.com",
134
+ "wss://polkadot.ibp.network",
135
+ "wss://polkadot.dotters.network",
136
+ "wss://rpc.polkadot.io"
137
+ ]
138
+ },
139
+ kusama: {
140
+ wss: [
141
+ "wss://kusama-rpc.n.dwellir.com",
142
+ "wss://kusama.ibp.network",
143
+ "wss://kusama.dotters.network",
144
+ "wss://kusama-rpc.polkadot.io"
145
+ ]
146
+ }
147
+ }
148
+ },
149
+ {
150
+ id: "asset-hub",
151
+ name: "Asset Hub",
152
+ endpoints: {
153
+ preview: {
154
+ wss: "wss://previewnet.substrate.dev/asset-hub",
155
+ parachainId: 1e3
156
+ },
157
+ "paseo-next": {
158
+ wss: "wss://asset-hub-paseo-rpc.n.dwellir.com",
159
+ parachainId: 1e3,
160
+ uptimeUrl: "https://stats.uptimerobot.com/UrEXbl6Xyt"
161
+ },
162
+ "paseo-review": {
163
+ wss: "wss://asset-hub-paseo-rpc.n.dwellir.com",
164
+ parachainId: 1e3,
165
+ uptimeUrl: "https://stats.uptimerobot.com/UrEXbl6Xyt"
166
+ },
167
+ "paseo-next-v2": {
168
+ wss: "wss://paseo-asset-hub-next-rpc.polkadot.io",
169
+ parachainId: 1500
170
+ },
171
+ polkadot: {
172
+ wss: [
173
+ "wss://asset-hub-polkadot-rpc.n.dwellir.com",
174
+ "wss://asset-hub-polkadot.ibp.network",
175
+ "wss://asset-hub-polkadot.dotters.network",
176
+ "wss://polkadot-asset-hub-rpc.polkadot.io"
177
+ ],
178
+ parachainId: 1e3
179
+ },
180
+ kusama: {
181
+ wss: [
182
+ "wss://asset-hub-kusama-rpc.n.dwellir.com",
183
+ "wss://asset-hub-kusama.ibp.network",
184
+ "wss://asset-hub-kusama.dotters.network",
185
+ "wss://kusama-asset-hub-rpc.polkadot.io"
186
+ ],
187
+ parachainId: 1e3
188
+ }
189
+ }
190
+ },
191
+ {
192
+ id: "bridge-hub",
193
+ name: "Bridge Hub",
194
+ endpoints: {
195
+ polkadot: {
196
+ wss: [
197
+ "wss://bridge-hub-polkadot-rpc.n.dwellir.com",
198
+ "wss://bridge-hub-polkadot.ibp.network",
199
+ "wss://bridge-hub-polkadot.dotters.network",
200
+ "wss://polkadot-bridge-hub-rpc.polkadot.io"
201
+ ],
202
+ parachainId: 1002
203
+ },
204
+ kusama: {
205
+ wss: [
206
+ "wss://bridge-hub-kusama-rpc.n.dwellir.com",
207
+ "wss://bridge-hub-kusama.ibp.network",
208
+ "wss://bridge-hub-kusama.dotters.network",
209
+ "wss://kusama-bridge-hub-rpc.polkadot.io"
210
+ ],
211
+ parachainId: 1002
212
+ }
213
+ }
214
+ },
215
+ {
216
+ id: "collectives",
217
+ name: "Collectives",
218
+ endpoints: {
219
+ polkadot: {
220
+ wss: [
221
+ "wss://collectives-polkadot-rpc.n.dwellir.com",
222
+ "wss://collectives-polkadot.ibp.network",
223
+ "wss://collectives-polkadot.dotters.network",
224
+ "wss://polkadot-collectives-rpc.polkadot.io"
225
+ ],
226
+ parachainId: 1001
227
+ }
228
+ }
229
+ },
230
+ {
231
+ id: "coretime",
232
+ name: "Coretime",
233
+ endpoints: {
234
+ polkadot: {
235
+ wss: [
236
+ "wss://coretime-polkadot-rpc.n.dwellir.com",
237
+ "wss://coretime-polkadot.ibp.network",
238
+ "wss://coretime-polkadot.dotters.network",
239
+ "wss://polkadot-coretime-rpc.polkadot.io"
240
+ ],
241
+ parachainId: 1005
242
+ },
243
+ kusama: {
244
+ wss: [
245
+ "wss://coretime-kusama-rpc.n.dwellir.com",
246
+ "wss://coretime-kusama.ibp.network",
247
+ "wss://coretime-kusama.dotters.network",
248
+ "wss://kusama-coretime-rpc.polkadot.io"
249
+ ],
250
+ parachainId: 1005
251
+ }
252
+ }
253
+ },
254
+ {
255
+ id: "people",
256
+ name: "People",
257
+ endpoints: {
258
+ preview: {
259
+ wss: "wss://previewnet.substrate.dev/people",
260
+ parachainId: 1004
261
+ },
262
+ "paseo-next": {
263
+ wss: "wss://paseo-people-next-rpc.polkadot.io",
264
+ parachainId: 5140,
265
+ uptimeUrl: "https://stats.uptimerobot.com/LISM1LRA8m"
266
+ },
267
+ "paseo-review": {
268
+ wss: "wss://paseo-people-review-rpc.polkadot.io",
269
+ parachainId: 5167,
270
+ uptimeUrl: "https://stats.uptimerobot.com/bckl1cu0AO"
271
+ },
272
+ "paseo-next-v2": {
273
+ wss: "wss://paseo-people-next-system-rpc.polkadot.io",
274
+ parachainId: 1502
275
+ },
276
+ polkadot: {
277
+ wss: [
278
+ "wss://people-polkadot-rpc.n.dwellir.com",
279
+ "wss://people-polkadot.ibp.network",
280
+ "wss://people-polkadot.dotters.network",
281
+ "wss://polkadot-people-rpc.polkadot.io"
282
+ ],
283
+ parachainId: 1004
284
+ },
285
+ kusama: {
286
+ wss: [
287
+ "wss://people-kusama-rpc.n.dwellir.com",
288
+ "wss://people-kusama.ibp.network",
289
+ "wss://people-kusama.dotters.network",
290
+ "wss://kusama-people-rpc.polkadot.io"
291
+ ],
292
+ parachainId: 1004
293
+ }
294
+ }
295
+ },
296
+ {
297
+ id: "bulletin",
298
+ name: "Bulletin",
299
+ endpoints: {
300
+ preview: {
301
+ wss: "wss://previewnet.substrate.dev/bulletin",
302
+ parachainId: 2487
303
+ },
304
+ "paseo-next": {
305
+ wss: "wss://paseo-bulletin-rpc.polkadot.io",
306
+ parachainId: 5118,
307
+ uptimeUrl: "https://stats.uptimerobot.com/LISM1LRA8m"
308
+ },
309
+ "paseo-review": {
310
+ wss: "wss://paseo-bulletin-review-rpc.polkadot.io",
311
+ parachainId: 5168,
312
+ uptimeUrl: "https://stats.uptimerobot.com/bckl1cu0AO"
313
+ },
314
+ "paseo-next-v2": {
315
+ wss: "wss://paseo-bulletin-next-rpc.polkadot.io",
316
+ parachainId: 1501
317
+ }
318
+ }
319
+ }
320
+ ],
321
+ source: "https://docs.google.com/document/d/1xQoAmWDpbjhuXKT79DTNKFzv7ZkFr5npjo0BvrxXDIw"
322
+ };
323
+
324
+ // src/environments.ts
325
+ var DEFAULT_ENV_ID = "paseo-next-v2";
326
+ var HARDCODED_FALLBACK = {
327
+ environments: [
328
+ {
329
+ id: "paseo-next-v2",
330
+ name: "Paseo Next v2",
331
+ network: "testnet",
332
+ description: "Next iteration of the Paseo Next testnet (hardcoded fallback)",
333
+ popSelfServe: {
334
+ sudoEnvLabel: "Next V2",
335
+ faucetUrl: "https://faucet.polkadot.io/?parachain=1500",
336
+ personhoodFaucetUrl: "https://sudo.personhood.dev/personhood-faucet",
337
+ dotnsBootstrapUrl: "https://sudo.personhood.dev/dotns-bootstrap",
338
+ stateAwareGuidance: true
339
+ }
340
+ }
341
+ ],
342
+ chains: [
343
+ {
344
+ id: "bulletin",
345
+ name: "Bulletin",
346
+ endpoints: {
347
+ "paseo-next-v2": {
348
+ wss: "wss://paseo-bulletin-next-rpc.polkadot.io",
349
+ parachainId: 1501
350
+ }
351
+ }
352
+ },
353
+ {
354
+ id: "asset-hub",
355
+ name: "Asset Hub",
356
+ endpoints: {
357
+ "paseo-next-v2": {
358
+ wss: "wss://paseo-asset-hub-next-rpc.polkadot.io",
359
+ parachainId: 1500
360
+ }
361
+ }
362
+ }
363
+ ]
364
+ };
365
+ function defaultBundledPath() {
366
+ return fileURLToPath(new URL("../assets/environments.json", import.meta.url));
367
+ }
368
+ var EVM_ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/i;
369
+ var ZERO_ADDRESS = "0x" + "0".repeat(40);
370
+ function isValidContractAddress(addr) {
371
+ return typeof addr === "string" && EVM_ADDRESS_RE.test(addr) && addr.toLowerCase() !== ZERO_ADDRESS;
372
+ }
373
+ function validateContractAddresses(contracts, envId) {
374
+ for (const [name, addr] of Object.entries(contracts)) {
375
+ if (!isValidContractAddress(addr)) {
376
+ throw new Error(
377
+ `Invalid contract address for ${name} in environment ${envId}: ${addr}. Check assets/environments.json against https://github.com/paritytech/dotns#deployments`
378
+ );
379
+ }
380
+ }
381
+ }
382
+ function isValidDoc(value) {
383
+ if (!value || typeof value !== "object") return false;
384
+ const v = value;
385
+ return Array.isArray(v.environments) && Array.isArray(v.chains);
386
+ }
387
+ async function readBundled(bundledPath, capture) {
388
+ try {
389
+ const raw = await fs.readFile(bundledPath, "utf8");
390
+ const parsed = JSON.parse(raw);
391
+ return isValidDoc(parsed) ? parsed : null;
392
+ } catch (err) {
393
+ capture(err);
394
+ return null;
395
+ }
396
+ }
397
+ async function loadEnvironments(opts = {}) {
398
+ const bundledPath = opts.bundledPath ?? defaultBundledPath();
399
+ const warn = opts.warn ?? ((msg) => console.error(msg));
400
+ const capture = opts.capture ?? (() => {
401
+ });
402
+ const bundled = await readBundled(bundledPath, capture);
403
+ if (bundled) return { doc: bundled, source: "bundled" };
404
+ if (isValidDoc(environments_default)) {
405
+ return { doc: environments_default, source: "bundled" };
406
+ }
407
+ warn("bulletin-deploy: bundled environments.json unavailable; using hardcoded paseo-next-v2 fallback");
408
+ return { doc: HARDCODED_FALLBACK, source: "hardcoded-fallback" };
409
+ }
410
+ function normalizeWss(value) {
411
+ if (value === void 0) return [];
412
+ return Array.isArray(value) ? value.slice() : [value];
413
+ }
414
+ function levenshtein(a, b) {
415
+ if (a === b) return 0;
416
+ const m = a.length, n = b.length;
417
+ if (m === 0) return n;
418
+ if (n === 0) return m;
419
+ let prev = new Array(n + 1);
420
+ let curr = new Array(n + 1);
421
+ for (let j = 0; j <= n; j++) prev[j] = j;
422
+ for (let i = 1; i <= m; i++) {
423
+ curr[0] = i;
424
+ for (let j = 1; j <= n; j++) {
425
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
426
+ curr[j] = Math.min(curr[j - 1] + 1, prev[j] + 1, prev[j - 1] + cost);
427
+ }
428
+ [prev, curr] = [curr, prev];
429
+ }
430
+ return prev[n];
431
+ }
432
+ function suggestEnv(envId, doc) {
433
+ let best = null;
434
+ for (const env of doc.environments) {
435
+ const d = levenshtein(envId.toLowerCase(), env.id.toLowerCase());
436
+ if (best === null || d < best.dist) best = { id: env.id, dist: d };
437
+ }
438
+ if (best && best.dist <= Math.max(2, Math.floor(envId.length / 3))) {
439
+ return best.id;
440
+ }
441
+ return null;
442
+ }
443
+ function resolveEndpoints(doc, envId) {
444
+ const env = doc.environments.find((e) => e.id === envId);
445
+ if (!env) {
446
+ const valid = doc.environments.map((e) => e.id).join(", ");
447
+ const hint = suggestEnv(envId, doc);
448
+ const suffix = hint ? ` Did you mean '${hint}'?` : "";
449
+ throw new NonRetryableError(
450
+ `Unknown environment '${envId}'. Valid: ${valid}.${suffix}`
451
+ );
452
+ }
453
+ const bulletinChain = doc.chains.find((c) => c.id === "bulletin");
454
+ const assetHubChain = doc.chains.find((c) => c.id === "asset-hub");
455
+ const bulletin = normalizeWss(bulletinChain?.endpoints?.[envId]?.wss);
456
+ const assetHub = normalizeWss(assetHubChain?.endpoints?.[envId]?.wss);
457
+ if (bulletin.length === 0) {
458
+ throw new NonRetryableError(
459
+ `Bulletin chain not yet available on environment '${envId}'. The selected environment has no bulletin endpoint in https://github.com/paritytech/triangle-status/blob/main/environments.json. Pick a testnet (paseo-next-v2, paseo-next, paseo-review, previewnet) or wait for the mainnet rollout.`
460
+ );
461
+ }
462
+ if (assetHub.length === 0) {
463
+ throw new NonRetryableError(
464
+ `Asset Hub endpoint missing for environment '${envId}'. Check https://github.com/paritytech/triangle-status/blob/main/environments.json.`
465
+ );
466
+ }
467
+ return {
468
+ bulletin,
469
+ assetHub,
470
+ network: env.network,
471
+ envName: env.name,
472
+ ipfs: env.ipfs,
473
+ autoAccountMapping: env.autoAccountMapping ?? false,
474
+ bulletinAuthorizeV2: env.bulletinAuthorizeV2 ?? false,
475
+ contracts: env.contracts ?? {},
476
+ nativeToEthRatio: BigInt(env.nativeToEthRatio ?? 1e6),
477
+ ...env.registerStorageDeposit !== void 0 ? { registerStorageDeposit: BigInt(env.registerStorageDeposit) } : {}
478
+ };
479
+ }
480
+ function getPopSelfServeConfig(doc, envId) {
481
+ return doc.environments.find((e) => e.id === envId)?.popSelfServe ?? null;
482
+ }
483
+ function listEnvironments(doc) {
484
+ const bulletinChain = doc.chains.find((c) => c.id === "bulletin");
485
+ return doc.environments.map((env) => {
486
+ const ep = bulletinChain?.endpoints?.[env.id];
487
+ const hasBulletin = !!ep && normalizeWss(ep.wss).length > 0;
488
+ return {
489
+ id: env.id,
490
+ name: env.name,
491
+ network: env.network,
492
+ hasBulletin,
493
+ description: env.description ?? ""
494
+ };
495
+ });
496
+ }
497
+ function formatEnvironmentTable(rows) {
498
+ const headers = ["ID", "Name", "Network", "Bulletin?", "Description"];
499
+ const data = rows.map((r) => [
500
+ r.id,
501
+ r.name,
502
+ r.network,
503
+ r.hasBulletin ? "yes" : "no",
504
+ r.description
505
+ ]);
506
+ const widths = headers.map(
507
+ (h, i) => Math.max(h.length, ...data.map((row) => row[i].length))
508
+ );
509
+ const fmtRow = (row) => row.map((cell, i) => cell.padEnd(widths[i])).join(" ");
510
+ const sep = widths.map((w) => "-".repeat(w)).join(" ");
511
+ return [fmtRow(headers), sep, ...data.map(fmtRow)].join("\n");
512
+ }
513
+
514
+ export {
515
+ DEFAULT_ENV_ID,
516
+ defaultBundledPath,
517
+ isValidContractAddress,
518
+ validateContractAddresses,
519
+ loadEnvironments,
520
+ resolveEndpoints,
521
+ getPopSelfServeConfig,
522
+ listEnvironments,
523
+ formatEnvironmentTable
524
+ };