@gibs/bridge-sdk 1.10.1 → 1.13.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 (122) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +234 -432
  3. package/dist/abis.d.ts +1 -0
  4. package/dist/abis.js +3 -0
  5. package/dist/bridge-limits.d.ts +103 -0
  6. package/dist/bridge-limits.js +84 -0
  7. package/dist/{src/chain-info.d.ts → chain-info.d.ts} +66 -27
  8. package/dist/{src/chain-info.js → chain-info.js} +106 -46
  9. package/dist/chain-names.d.ts +160 -0
  10. package/dist/chain-names.js +200 -0
  11. package/dist/chains.d.ts +65 -0
  12. package/dist/chains.js +284 -0
  13. package/dist/config.d.ts +216 -0
  14. package/dist/{src/config.js → config.js} +151 -44
  15. package/dist/consolidated-quote.d.ts +554 -0
  16. package/dist/consolidated-quote.js +773 -0
  17. package/dist/destination-calldata.d.ts +118 -0
  18. package/dist/destination-calldata.js +152 -0
  19. package/dist/ecosystems.d.ts +217 -0
  20. package/dist/ecosystems.js +288 -0
  21. package/dist/hyperliquid-execution.d.ts +152 -0
  22. package/dist/hyperliquid-execution.js +168 -0
  23. package/dist/image-links.d.ts +117 -0
  24. package/dist/image-links.js +142 -0
  25. package/dist/index.d.ts +20 -0
  26. package/dist/index.js +20 -0
  27. package/dist/lifi-execution-guard.d.ts +199 -0
  28. package/dist/lifi-execution-guard.js +400 -0
  29. package/dist/near-intents-conformance.d.ts +85 -0
  30. package/dist/near-intents-conformance.js +329 -0
  31. package/dist/near-intents-route.d.ts +47 -0
  32. package/dist/near-intents-route.js +265 -0
  33. package/dist/near-intents.d.ts +524 -0
  34. package/dist/near-intents.js +1055 -0
  35. package/dist/origin-deposit.d.ts +326 -0
  36. package/dist/origin-deposit.js +68 -0
  37. package/dist/pre-quote.d.ts +198 -0
  38. package/dist/pre-quote.js +175 -0
  39. package/dist/prices.d.ts +107 -0
  40. package/dist/prices.js +162 -0
  41. package/dist/providers.d.ts +221 -0
  42. package/dist/providers.js +157 -0
  43. package/dist/quote-fees.d.ts +102 -0
  44. package/dist/quote-fees.js +195 -0
  45. package/dist/referral.d.ts +77 -0
  46. package/dist/referral.js +72 -0
  47. package/dist/relay-currencies.d.ts +47 -0
  48. package/dist/relay-currencies.js +89 -0
  49. package/dist/relay-quote.d.ts +301 -0
  50. package/dist/relay-quote.js +983 -0
  51. package/dist/route-steps.d.ts +138 -0
  52. package/dist/route-steps.js +305 -0
  53. package/dist/routing/amounts.d.ts +80 -0
  54. package/dist/routing/amounts.js +120 -0
  55. package/dist/routing/candidate-route.d.ts +43 -0
  56. package/dist/routing/candidate-route.js +45 -0
  57. package/dist/routing/candidate.d.ts +237 -0
  58. package/dist/routing/candidate.js +96 -0
  59. package/dist/routing/carriers/ask-answer.d.ts +58 -0
  60. package/dist/routing/carriers/omnibridge.d.ts +137 -0
  61. package/dist/routing/carriers/omnibridge.js +419 -0
  62. package/dist/routing/carriers/pulsex.d.ts +111 -0
  63. package/dist/routing/carriers/pulsex.js +404 -0
  64. package/dist/routing/carriers/wrap.d.ts +25 -0
  65. package/dist/routing/carriers/wrap.js +115 -0
  66. package/dist/routing/composed-route-quality.d.ts +103 -0
  67. package/dist/routing/composed-route-quality.js +108 -0
  68. package/dist/routing/entry-chain-anchor.d.ts +88 -0
  69. package/dist/routing/entry-chain-anchor.js +55 -0
  70. package/dist/routing/format.d.ts +31 -0
  71. package/dist/routing/format.js +58 -0
  72. package/dist/routing/index.d.ts +34 -0
  73. package/dist/routing/index.js +42 -0
  74. package/dist/routing/producers.d.ts +770 -0
  75. package/dist/routing/producers.js +1564 -0
  76. package/dist/routing/providers.d.ts +26 -0
  77. package/dist/routing/providers.js +38 -0
  78. package/dist/routing/route-data.d.ts +355 -0
  79. package/dist/routing/route-data.js +1 -0
  80. package/dist/routing/search/compose.d.ts +168 -0
  81. package/dist/routing/search/compose.js +98 -0
  82. package/dist/routing/search/graph.d.ts +639 -0
  83. package/dist/routing/search/graph.js +445 -0
  84. package/dist/routing/search/plan-route-data.d.ts +244 -0
  85. package/dist/routing/search/plan-route-data.js +767 -0
  86. package/dist/routing/search/score.d.ts +324 -0
  87. package/dist/routing/search/score.js +400 -0
  88. package/dist/routing/usd-value.d.ts +17 -0
  89. package/dist/routing/usd-value.js +25 -0
  90. package/dist/settings.d.ts +692 -0
  91. package/dist/{src/settings.js → settings.js} +338 -71
  92. package/dist/ton-execution.d.ts +117 -0
  93. package/dist/ton-execution.js +247 -0
  94. package/dist/tron-execution.d.ts +146 -0
  95. package/dist/tron-execution.js +239 -0
  96. package/dist/{src/types.d.ts → types.d.ts} +8 -1
  97. package/dist/types.js +1 -0
  98. package/package.json +210 -23
  99. package/dist/src/abis.d.ts +0 -384
  100. package/dist/src/abis.js +0 -68
  101. package/dist/src/chains.d.ts +0 -6
  102. package/dist/src/chains.js +0 -86
  103. package/dist/src/config.d.ts +0 -136
  104. package/dist/src/image-links.d.ts +0 -41
  105. package/dist/src/image-links.js +0 -45
  106. package/dist/src/index.d.ts +0 -8
  107. package/dist/src/index.js +0 -8
  108. package/dist/src/settings.d.ts +0 -357
  109. package/dist/tsconfig.tsbuildinfo +0 -1
  110. package/src/abis.ts +0 -70
  111. package/src/chain-info.ts +0 -464
  112. package/src/chains.ts +0 -88
  113. package/src/config.ts +0 -480
  114. package/src/fee-type.ts +0 -14
  115. package/src/image-links.ts +0 -61
  116. package/src/index.ts +0 -8
  117. package/src/settings.ts +0 -898
  118. package/src/types.ts +0 -48
  119. package/tsconfig.json +0 -16
  120. /package/dist/{src/fee-type.d.ts → fee-type.d.ts} +0 -0
  121. /package/dist/{src/fee-type.js → fee-type.js} +0 -0
  122. /package/dist/{src/types.js → routing/carriers/ask-answer.js} +0 -0
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Chain identifiers and their human-readable display names, in one place.
3
+ *
4
+ * This module exists to break an import cycle. `relay-quote.ts` imports the
5
+ * step normalizers from `route-steps.ts`, and `route-steps.ts` needs to name
6
+ * Relay's non-Ethereum chains when it labels a leg. Holding the shared lookup
7
+ * here lets both import it without either importing the other.
8
+ *
9
+ * Names are spelled out in full — these strings are shown to someone choosing
10
+ * where their funds leave from, so "The Open Network", never "TON".
11
+ */
12
+ /**
13
+ * Relay's numeric chain identifiers for the non-Ethereum-Virtual-Machine origin
14
+ * chains this bridge supports. These are Relay's OWN identifiers, distinct from
15
+ * any native chain id, and are required verbatim as the request's
16
+ * `originChainId`.
17
+ *
18
+ * Source: https://api.relay.link/chains, where each entry's `vmType` names the
19
+ * ecosystem and each is reported `depositEnabled`.
20
+ */
21
+ export declare const relayChainIds: {
22
+ /** Relay's chain id for Solana mainnet (virtual-machine type `svm`). */
23
+ readonly solana: 792703809;
24
+ /**
25
+ * Relay's chain id for Eclipse (virtual-machine type `svm`) — a SECOND chain
26
+ * in the Solana ecosystem, sharing Solana's address encoding, deposit shape
27
+ * and native-asset sentinel while being a different network with a different
28
+ * native asset (Ether, not Sol).
29
+ *
30
+ * Quotable, but see the guard in the interface's Solana signer: sharing an
31
+ * ecosystem means sharing a wallet adapter, and that adapter is bound to ONE
32
+ * Solana network at a time. A deposit for this chain must never be signed
33
+ * against a connection pointed at Solana.
34
+ */
35
+ readonly eclipse: 9286185;
36
+ /** Relay's chain id for Bitcoin mainnet (virtual-machine type `bvm`). */
37
+ readonly bitcoin: 8253038;
38
+ /** Relay's chain id for Tron mainnet (virtual-machine type `tvm`). */
39
+ readonly tron: 728126428;
40
+ /** Relay's chain id for The Open Network (virtual-machine type `tonvm`). */
41
+ readonly ton: 224235520;
42
+ /**
43
+ * Relay's chain id for Hyperliquid (virtual-machine type `hypevm`).
44
+ *
45
+ * BEWARE: 1337 is also the default chain id of a local Ganache development
46
+ * node, so this is the one Relay identifier that can collide with a real
47
+ * Ethereum Virtual Machine chain a developer might be running. Treating a
48
+ * local test chain as Hyperliquid would route it down the HyperCore deposit
49
+ * path, so never feed a local development chain id through
50
+ * `ecosystemByChainId`.
51
+ */
52
+ readonly hyperliquid: 1337;
53
+ };
54
+ /**
55
+ * Chain identifiers for origin chains a reader PAYS BY HAND.
56
+ *
57
+ * WHAT MAKES THESE DIFFERENT FROM EVERY OTHER CHAIN HERE. Every identifier
58
+ * above names a chain this interface can connect a wallet to and sign on.
59
+ * These name chains it cannot. There is no connector, no signer and no
60
+ * transaction: the provider issues an address, the reader sends an ordinary
61
+ * transfer to it from any wallet or any exchange, and the provider's own
62
+ * watcher reports the arrival. The chain identifier exists so the route layer
63
+ * can NAME the chain, price it and draw it — nothing more.
64
+ *
65
+ * THE NUMBERS ARE DERIVED, NOT INVENTED, and the derivation is written down
66
+ * because a chain identifier typed from memory is a hypothesis every later
67
+ * reader will trust. Each is the chain's registered SLIP-0044 coin type with
68
+ * the hardened bit set, exactly as a BIP-44 derivation path writes it:
69
+ * `0x80000000 + coinType`. That puts them above every chain identifier in
70
+ * public use, so one can never collide with a real Ethereum chain and be
71
+ * mistaken for one — which is the failure that matters, because an Ethereum
72
+ * chain has a wallet and would be handed a payload to sign.
73
+ *
74
+ * They are LOCAL identifiers and never travel on a wire. NEAR Intents names
75
+ * Zcash `zec`; `chainIdByNearIntentsChain` is where the two are reconciled.
76
+ */
77
+ export declare const depositAddressChainIds: {
78
+ /** Zcash mainnet. SLIP-0044 coin type 133, hardened: 0x80000000 + 133. */
79
+ readonly zcash: 2147483781;
80
+ };
81
+ /**
82
+ * One member per pay-by-hand origin chain — the union every table keyed by a
83
+ * pay-by-hand chain must be typed against.
84
+ *
85
+ * WHY THIS UNION, NOT `number`. `DepositAddressDeposit`'s own doc says the same
86
+ * shape will serve Zcash, Dogecoin, Litecoin and the XRP Ledger alike, so a
87
+ * second member is coming. A table typed `Record<number, X>` or
88
+ * `Map<number, X>` accepts a member of {@link depositAddressChainIds} being
89
+ * missing silently; a table typed `Record<DepositAddressChain, X>` cannot
90
+ * compile until every member has an entry. The dangerous table this protects
91
+ * is the ecosystem lookup in `relay-quote.ts`: a miss there makes a pay-by-hand
92
+ * chain read as an Ethereum chain, which has a wallet, a signer and a
93
+ * transaction.
94
+ */
95
+ export type DepositAddressChain = keyof typeof depositAddressChainIds;
96
+ /**
97
+ * Whether a chain identifier names a chain this interface CANNOT SIGN ON.
98
+ *
99
+ * The one predicate every surface asks before offering a wallet. A chain that
100
+ * answers true has no connector, so anything that would connect, switch
101
+ * networks, estimate gas or compose a transaction for it is wrong — the reader
102
+ * is shown an address to pay instead.
103
+ *
104
+ * @param chainId - a chain identifier
105
+ * @returns whether the reader pays this chain by hand
106
+ */
107
+ export declare const isDepositAddressChain: (chainId: number) => boolean;
108
+ /**
109
+ * Display names for Relay's non-Ethereum origin chains.
110
+ *
111
+ * An ecosystem label is NOT a chain name, and using one as a name is actively
112
+ * wrong: `svm` holds both Solana and Eclipse, so labelling by ecosystem renders
113
+ * Eclipse as "Solana" — a different network, shown to someone choosing where
114
+ * their funds leave from. Keyed by chain id for exactly that reason.
115
+ */
116
+ export declare const relayChainNames: Map<number, string>;
117
+ /**
118
+ * Registers display names for chains this module does not know about.
119
+ *
120
+ * Call once during startup, before anything renders. Entries are merged, and a
121
+ * name declared in `virtualMachineChainNames` above WINS over a registered one:
122
+ * the local table is deliberate ("Binance Smart Chain", not the registry's
123
+ * "BNB Smart Chain"), and a registry that happens to disagree must not quietly
124
+ * rename a chain the product has already named.
125
+ *
126
+ * @param entries - chain id and display name pairs
127
+ */
128
+ export declare const registerChainNames: (entries: Iterable<readonly [number, string]>) => void;
129
+ /**
130
+ * Returns a human-readable chain name for the given chain id, covering both
131
+ * Ethereum-Virtual-Machine chains and Relay's non-Ethereum pseudo identifiers.
132
+ *
133
+ * Falls back to the numeric id stringified when the chain is not known — better
134
+ * to show "chain 999" than to silently drop the leg that traverses it.
135
+ *
136
+ * @param chainId - a decimal chain id, Relay's identifier included
137
+ * @returns the display name, or `chain <id>` when unknown
138
+ */
139
+ export declare const chainDisplayName: (chainId: number) => string;
140
+ /**
141
+ * The name this module KNOWS for a chain, or null when it knows none.
142
+ *
143
+ * Same lookup as {@link chainDisplayName} without the placeholder, so a caller
144
+ * with a better fallback of its own can reach one. {@link chainDisplayName} is
145
+ * defined in terms of this, which is the point: the two can never disagree
146
+ * about which chains are known.
147
+ *
148
+ * WHY A CALLER WOULD WANT THIS. The network chips in the token picker have a
149
+ * second name to fall back on — the aggregator's own chain list, which reaches
150
+ * chains this registry has never been told about and says "Unknown network"
151
+ * rather than printing a bare number. Choosing between the two used to be done
152
+ * by comparing `chainDisplayName`'s answer against the literal string
153
+ * `chain <id>`, which is a caller reaching into another function's fallback
154
+ * format: rename the placeholder here and that comparison quietly stops
155
+ * matching, leaving every unknown chain labelled with its number.
156
+ *
157
+ * @param chainId - a decimal chain id, Relay's identifiers included
158
+ * @returns the display name, or null when the chain is not known here
159
+ */
160
+ export declare const knownChainName: (chainId: number) => string | null;
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Chain identifiers and their human-readable display names, in one place.
3
+ *
4
+ * This module exists to break an import cycle. `relay-quote.ts` imports the
5
+ * step normalizers from `route-steps.ts`, and `route-steps.ts` needs to name
6
+ * Relay's non-Ethereum chains when it labels a leg. Holding the shared lookup
7
+ * here lets both import it without either importing the other.
8
+ *
9
+ * Names are spelled out in full — these strings are shown to someone choosing
10
+ * where their funds leave from, so "The Open Network", never "TON".
11
+ */
12
+ /**
13
+ * Relay's numeric chain identifiers for the non-Ethereum-Virtual-Machine origin
14
+ * chains this bridge supports. These are Relay's OWN identifiers, distinct from
15
+ * any native chain id, and are required verbatim as the request's
16
+ * `originChainId`.
17
+ *
18
+ * Source: https://api.relay.link/chains, where each entry's `vmType` names the
19
+ * ecosystem and each is reported `depositEnabled`.
20
+ */
21
+ export const relayChainIds = {
22
+ /** Relay's chain id for Solana mainnet (virtual-machine type `svm`). */
23
+ solana: 792703809,
24
+ /**
25
+ * Relay's chain id for Eclipse (virtual-machine type `svm`) — a SECOND chain
26
+ * in the Solana ecosystem, sharing Solana's address encoding, deposit shape
27
+ * and native-asset sentinel while being a different network with a different
28
+ * native asset (Ether, not Sol).
29
+ *
30
+ * Quotable, but see the guard in the interface's Solana signer: sharing an
31
+ * ecosystem means sharing a wallet adapter, and that adapter is bound to ONE
32
+ * Solana network at a time. A deposit for this chain must never be signed
33
+ * against a connection pointed at Solana.
34
+ */
35
+ eclipse: 9286185,
36
+ /** Relay's chain id for Bitcoin mainnet (virtual-machine type `bvm`). */
37
+ bitcoin: 8253038,
38
+ /** Relay's chain id for Tron mainnet (virtual-machine type `tvm`). */
39
+ tron: 728126428,
40
+ /** Relay's chain id for The Open Network (virtual-machine type `tonvm`). */
41
+ ton: 224235520,
42
+ /**
43
+ * Relay's chain id for Hyperliquid (virtual-machine type `hypevm`).
44
+ *
45
+ * BEWARE: 1337 is also the default chain id of a local Ganache development
46
+ * node, so this is the one Relay identifier that can collide with a real
47
+ * Ethereum Virtual Machine chain a developer might be running. Treating a
48
+ * local test chain as Hyperliquid would route it down the HyperCore deposit
49
+ * path, so never feed a local development chain id through
50
+ * `ecosystemByChainId`.
51
+ */
52
+ hyperliquid: 1337,
53
+ };
54
+ /**
55
+ * Chain identifiers for origin chains a reader PAYS BY HAND.
56
+ *
57
+ * WHAT MAKES THESE DIFFERENT FROM EVERY OTHER CHAIN HERE. Every identifier
58
+ * above names a chain this interface can connect a wallet to and sign on.
59
+ * These name chains it cannot. There is no connector, no signer and no
60
+ * transaction: the provider issues an address, the reader sends an ordinary
61
+ * transfer to it from any wallet or any exchange, and the provider's own
62
+ * watcher reports the arrival. The chain identifier exists so the route layer
63
+ * can NAME the chain, price it and draw it — nothing more.
64
+ *
65
+ * THE NUMBERS ARE DERIVED, NOT INVENTED, and the derivation is written down
66
+ * because a chain identifier typed from memory is a hypothesis every later
67
+ * reader will trust. Each is the chain's registered SLIP-0044 coin type with
68
+ * the hardened bit set, exactly as a BIP-44 derivation path writes it:
69
+ * `0x80000000 + coinType`. That puts them above every chain identifier in
70
+ * public use, so one can never collide with a real Ethereum chain and be
71
+ * mistaken for one — which is the failure that matters, because an Ethereum
72
+ * chain has a wallet and would be handed a payload to sign.
73
+ *
74
+ * They are LOCAL identifiers and never travel on a wire. NEAR Intents names
75
+ * Zcash `zec`; `chainIdByNearIntentsChain` is where the two are reconciled.
76
+ */
77
+ export const depositAddressChainIds = {
78
+ /** Zcash mainnet. SLIP-0044 coin type 133, hardened: 0x80000000 + 133. */
79
+ zcash: 2_147_483_781,
80
+ };
81
+ /**
82
+ * Display names for the chains a reader pays by hand, one entry per member of
83
+ * {@link DepositAddressChain}. Typed on the union rather than on `number` so a
84
+ * chain added to {@link depositAddressChainIds} without a name here is a
85
+ * compile error, not a blank badge.
86
+ */
87
+ const depositAddressChainNamesByChain = {
88
+ zcash: 'Zcash',
89
+ };
90
+ /** {@link depositAddressChainNamesByChain}, keyed by chain id for lookup. */
91
+ const depositAddressChainNames = new Map(Object.keys(depositAddressChainIds).map((chain) => [
92
+ depositAddressChainIds[chain],
93
+ depositAddressChainNamesByChain[chain],
94
+ ]));
95
+ /**
96
+ * Whether a chain identifier names a chain this interface CANNOT SIGN ON.
97
+ *
98
+ * The one predicate every surface asks before offering a wallet. A chain that
99
+ * answers true has no connector, so anything that would connect, switch
100
+ * networks, estimate gas or compose a transaction for it is wrong — the reader
101
+ * is shown an address to pay instead.
102
+ *
103
+ * @param chainId - a chain identifier
104
+ * @returns whether the reader pays this chain by hand
105
+ */
106
+ export const isDepositAddressChain = (chainId) => depositAddressChainNames.has(chainId);
107
+ /**
108
+ * Display names for Relay's non-Ethereum origin chains.
109
+ *
110
+ * An ecosystem label is NOT a chain name, and using one as a name is actively
111
+ * wrong: `svm` holds both Solana and Eclipse, so labelling by ecosystem renders
112
+ * Eclipse as "Solana" — a different network, shown to someone choosing where
113
+ * their funds leave from. Keyed by chain id for exactly that reason.
114
+ */
115
+ export const relayChainNames = new Map([
116
+ [relayChainIds.solana, 'Solana'],
117
+ [relayChainIds.eclipse, 'Eclipse'],
118
+ [relayChainIds.bitcoin, 'Bitcoin'],
119
+ [relayChainIds.tron, 'Tron'],
120
+ [relayChainIds.ton, 'The Open Network'],
121
+ [relayChainIds.hyperliquid, 'Hyperliquid'],
122
+ ]);
123
+ /**
124
+ * Display names for the Ethereum-Virtual-Machine chains a route can traverse.
125
+ * Only the chains this bridge actually routes through need an entry; anything
126
+ * else falls back to its numeric identifier rather than being dropped.
127
+ */
128
+ const virtualMachineChainNames = new Map([
129
+ [1, 'Ethereum'],
130
+ [56, 'Binance Smart Chain'],
131
+ [369, 'PulseChain'],
132
+ [943, 'PulseChain Testnet V4'],
133
+ [42161, 'Arbitrum One'],
134
+ [11155111, 'Sepolia'],
135
+ ]);
136
+ /**
137
+ * Names registered at startup from the wider chain registry.
138
+ *
139
+ * This package cannot import that registry — it sits below the client that
140
+ * holds it — but it must still be the ONE place a chain name is decided. The
141
+ * alternative was what this replaced: three resolvers, each with different
142
+ * coverage, so the same chain read as "Base" beside one element, "chain 8453"
143
+ * beside another, and vanished entirely from a third. A reader hovering two
144
+ * parts of the same row saw two different answers.
145
+ */
146
+ const registeredChainNames = new Map();
147
+ /**
148
+ * Registers display names for chains this module does not know about.
149
+ *
150
+ * Call once during startup, before anything renders. Entries are merged, and a
151
+ * name declared in `virtualMachineChainNames` above WINS over a registered one:
152
+ * the local table is deliberate ("Binance Smart Chain", not the registry's
153
+ * "BNB Smart Chain"), and a registry that happens to disagree must not quietly
154
+ * rename a chain the product has already named.
155
+ *
156
+ * @param entries - chain id and display name pairs
157
+ */
158
+ export const registerChainNames = (entries) => {
159
+ for (const [chainId, name] of entries) {
160
+ if (!name)
161
+ continue;
162
+ registeredChainNames.set(chainId, name);
163
+ }
164
+ };
165
+ /**
166
+ * Returns a human-readable chain name for the given chain id, covering both
167
+ * Ethereum-Virtual-Machine chains and Relay's non-Ethereum pseudo identifiers.
168
+ *
169
+ * Falls back to the numeric id stringified when the chain is not known — better
170
+ * to show "chain 999" than to silently drop the leg that traverses it.
171
+ *
172
+ * @param chainId - a decimal chain id, Relay's identifier included
173
+ * @returns the display name, or `chain <id>` when unknown
174
+ */
175
+ export const chainDisplayName = (chainId) => knownChainName(chainId) ?? `chain ${chainId}`;
176
+ /**
177
+ * The name this module KNOWS for a chain, or null when it knows none.
178
+ *
179
+ * Same lookup as {@link chainDisplayName} without the placeholder, so a caller
180
+ * with a better fallback of its own can reach one. {@link chainDisplayName} is
181
+ * defined in terms of this, which is the point: the two can never disagree
182
+ * about which chains are known.
183
+ *
184
+ * WHY A CALLER WOULD WANT THIS. The network chips in the token picker have a
185
+ * second name to fall back on — the aggregator's own chain list, which reaches
186
+ * chains this registry has never been told about and says "Unknown network"
187
+ * rather than printing a bare number. Choosing between the two used to be done
188
+ * by comparing `chainDisplayName`'s answer against the literal string
189
+ * `chain <id>`, which is a caller reaching into another function's fallback
190
+ * format: rename the placeholder here and that comparison quietly stops
191
+ * matching, leaving every unknown chain labelled with its number.
192
+ *
193
+ * @param chainId - a decimal chain id, Relay's identifiers included
194
+ * @returns the display name, or null when the chain is not known here
195
+ */
196
+ export const knownChainName = (chainId) => virtualMachineChainNames.get(chainId) ??
197
+ relayChainNames.get(chainId) ??
198
+ depositAddressChainNames.get(chainId) ??
199
+ registeredChainNames.get(chainId) ??
200
+ null;
@@ -0,0 +1,65 @@
1
+ import type { ChainsMetadata } from './types.js';
2
+ /**
3
+ * all of the chains that are enabled in this dapp
4
+ * and their corresponding useful metadata
5
+ *
6
+ * Every entry below sets `name` explicitly to `chainDisplayName(...)` rather
7
+ * than trusting the spread-in viem chain object or typing a string here. Two
8
+ * hand-typed copies of the same name is exactly how chain 943 once read as
9
+ * "PulseChain Testnet V4" in the resolver and "Pulsechain V4" here — one
10
+ * string, two spellings, and only one of them got fixed. Routing every name
11
+ * through `chainDisplayName` leaves nothing to drift a second time.
12
+ *
13
+ * Each `logoURI` is a getter, not a string fixed at import time, so a later
14
+ * `setImageRoot` call (from `image-links.ts`) changes every chain logo. Spread
15
+ * an entry (`{ ...chainsMetadata[chain] }`) and the copy holds the URL as it
16
+ * was at that moment.
17
+ */
18
+ export declare const chainsMetadata: ChainsMetadata;
19
+ /**
20
+ * Every chain this bridge itself carries funds across, in the order the
21
+ * metadata declares them.
22
+ *
23
+ * Read from {@link chainsMetadata} rather than typed out, for the reason the
24
+ * whole table above gives: a second hand-written list is how one chain ends up
25
+ * present in one place and missing from another. A control that offers the
26
+ * reader a network to add or remove reads this, so a chain added to the
27
+ * metadata appears in that control without anybody remembering to add it.
28
+ *
29
+ * This is NOT every chain a route can traverse. An aggregator reaches dozens
30
+ * more, and `chain-names.ts` can name them. These five are the ones the
31
+ * transfers archive holds records for.
32
+ */
33
+ export declare const bridgeNetworkChainIds: readonly number[];
34
+ /**
35
+ * The chain identifiers this product treats as TEST networks.
36
+ *
37
+ * THE FLAG IS VIEM'S AND IT IS CHECKED FOR `true`, NOT FOR TRUTHINESS. Each
38
+ * entry above spreads a viem chain definition, and viem sets `testnet: true` on
39
+ * Sepolia and on PulseChain Testnet V4, `testnet: false` on PulseChain, and
40
+ * omits the key entirely on Ethereum and on Binance Smart Chain. So the value
41
+ * has three states, and only one of them is a claim. Testing for `=== true`
42
+ * means a chain whose definition says nothing is treated as a real network —
43
+ * which is the safe direction, because the cost of failing to hide a test
44
+ * network is an extra row and the cost of hiding a real one is a reader who
45
+ * cannot find their money.
46
+ *
47
+ * WHY NOT DERIVE IT FROM THE BRIDGE KEYS. `validBridgeKeys(isProd)` in
48
+ * `config.ts` splits the same five chains into a mainnet set and a testnet set,
49
+ * and subtracting one from the other would give the same two identifiers today.
50
+ * It would also give the wrong answer the moment a real chain gains a pathway
51
+ * that is still behind the testnet switch — the key list records what is
52
+ * ENABLED, and this records what a chain IS. Two different questions.
53
+ *
54
+ * `buildFullChainIdSet` in the interface already gates the pickers on the same
55
+ * flag, and `tokenLists.ts` gates the synthesized native assets on it. This is
56
+ * that decision written down once so a third reader does not restate it.
57
+ */
58
+ export declare const testNetworkChainIds: ReadonlySet<number>;
59
+ /**
60
+ * Whether one chain is a test network.
61
+ *
62
+ * @param chainId - a decimal chain id
63
+ * @returns true only when the chain's own definition claims it is a test network
64
+ */
65
+ export declare const isTestNetwork: (chainId: number) => boolean;