@qntx/wallet-engine 0.4.0 → 0.6.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/LICENSE-APACHE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 QuantX
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # @qntx/wallet-engine
2
+
3
+ App-side controllers over a [`@qntx/wallet`](https://www.npmjs.com/package/@qntx/wallet) `Wallet`:
4
+ the account tree, Spark payments, zaps, encrypted metadata sync and cloud backup. Controllers
5
+ expose Zustand stores; every I/O dependency (`fetch`, randomness, clock, storage, relays, cloud)
6
+ is injected. The engine never holds signing keys — every wallet-owned outflow goes through the
7
+ enclave's per-operation approval.
8
+
9
+ Peer dependencies: the exact `@qntx/wallet` release, `@qntx/spark` `^0.5.0` and
10
+ `@qntx/nostr` `^0.15.0`.
11
+
12
+ ```bash
13
+ npm install @qntx/wallet-engine @qntx/wallet @qntx/wallet-worker @qntx/spark @qntx/nostr
14
+ ```
15
+
16
+ ```ts
17
+ import { createWalletEngine } from "@qntx/wallet-engine";
18
+ import { openIndexedDbEngineStore } from "@qntx/wallet-engine/idb";
19
+
20
+ const random = (n: number) => crypto.getRandomValues(new Uint8Array(n));
21
+ const engine = createWalletEngine({
22
+ wallet, // from createWebWallet / createNodeWallet / createNativeWallet
23
+ sparkNetwork: "mainnet",
24
+ fetch: globalThis.fetch.bind(globalThis),
25
+ random,
26
+ now: () => Date.now(),
27
+ logger: { warn: (message, error) => console.warn(message, error) },
28
+ openStore: async () =>
29
+ openIndexedDbEngineStore({
30
+ name: "app-engine",
31
+ dataKey: await wallet.dataKeys.get("wallet-db"),
32
+ random,
33
+ }),
34
+ });
35
+ ```
36
+
37
+ The engine follows the wallet's lock state: unlocking opens the encrypted `EngineStore` and starts
38
+ the selected account group; locking flushes pending writes, closes every Spark client and clears
39
+ in-memory state.
40
+
41
+ ## Surface
42
+
43
+ - `engine.accounts` — `AccountTreeController`: wallets and account groups, selection, names,
44
+ hidden groups, Spark group discovery and social identity bindings.
45
+ - `engine.spark` — `SparkController`: balances, history, sends, Lightning receives and
46
+ cooperative exits for the selected group.
47
+ - `engine.payments` — `parse` (pure, never throws), `resolve` (LNURL lookups) and `pay`, which
48
+ routes a parsed option to Spark, Lightning or a Bitcoin withdrawal after validation and before
49
+ approval. Typed `PayResult` per payment kind.
50
+ - `engine.zaps` — `prepare` signs the NIP-57 request with any `NostrSigner` and fetches the
51
+ invoice; `pay` pays it from the built-in Spark wallet. External wallets may pay
52
+ `prepared.invoice` themselves and validate the receipt against `receiptPubkey`.
53
+ - `engine.metaSync` — NIP-78 (kind 30078) metadata documents, NIP-44 encrypted to the wallet's
54
+ group-0 Nostr identity; pull before publish, per-entry last-writer-wins.
55
+ - `engine.backup` — `BackupController` over an injected `CloudStore`.
56
+
57
+ ## React Native hosts
58
+
59
+ The engine runs on the RN main runtime (Hermes) with no polyfills. Verified on 2026-11-02 in an
60
+ iOS simulator Release build and on 2026-11-03 in an Android API 30 emulator Release build (both
61
+ RN 0.88.0, Expo 58, Hermes), with and without `react-native-quick-crypto`'s `install()`, using a
62
+ hardware-factor wallet: engine
63
+ creation, the gateway's `/v1/networks`, a Sepolia balance read, a send request prepared and
64
+ rejected, signet and Solana devnet reads through the gateway, `payments.parse`, and a lock that
65
+ invalidates open requests.
66
+
67
+ What the host must provide:
68
+
69
+ - `random`: a CSPRNG, injected as an option. Hermes has no `crypto.getRandomValues`, so use a native
70
+ source such as `react-native-quick-crypto`'s `randomBytes`:
71
+ `random: (n) => new Uint8Array(randomBytes(n))`.
72
+ - Nothing else. `globalThis.crypto`, `crypto.subtle` and `Buffer` are all absent in that run and
73
+ not needed; `fetch`, `TextEncoder`, `URL`, `AbortSignal.timeout` and `structuredClone` are built in.
74
+
75
+ A host that already calls `install()` from `react-native-quick-crypto` (as Meowl does) also works;
76
+ the same smoke passes with those globals installed.
77
+
78
+ ## License
79
+
80
+ MIT OR Apache-2.0
@@ -0,0 +1,284 @@
1
+ import * as z from "zod/mini";
2
+ //#region src/gateway/contract/primitives.ts
3
+ const INSTALL_ID_HEADER = "x-install-id";
4
+ const PROVIDERS_HEADER = "x-gateway-providers";
5
+ /** 128 random bits as lowercase hex — generated once per install, unrelated to wallet secrets. */
6
+ const installId = z.string().check(z.regex(/^[0-9a-f]{32}$/));
7
+ /** CAIP-2 chain id: `namespace:reference`. */
8
+ const caip2 = z.string().check(z.regex(/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}$/));
9
+ const GATEWAY_ERRORS = [
10
+ "invalid-request",
11
+ "unknown-network",
12
+ "not-found",
13
+ "rate-limited",
14
+ "unavailable",
15
+ "internal"
16
+ ];
17
+ const gatewayError = z.object({ error: z.enum(GATEWAY_ERRORS) });
18
+ //#endregion
19
+ //#region src/gateway/contract/endpoint.ts
20
+ /** One gateway route: its verb, versioned path template, and request/response schemas. */
21
+ function endpoint(method, path, request, response) {
22
+ return {
23
+ method,
24
+ path,
25
+ request,
26
+ response
27
+ };
28
+ }
29
+ /** `value` typed by `schema`, or `undefined` when it does not satisfy it. */
30
+ function parseWith(schema, value) {
31
+ const result = z.safeParse(schema, value);
32
+ return result.success ? result.data : void 0;
33
+ }
34
+ /** Whether `value` satisfies `schema` — lets consumers validate without importing zod. */
35
+ function accepts(schema, value) {
36
+ return z.safeParse(schema, value).success;
37
+ }
38
+ //#endregion
39
+ //#region src/gateway/contract/health.ts
40
+ const healthRequest = z.undefined();
41
+ const healthResponse = z.object({ status: z.literal("ok") });
42
+ const health = endpoint("GET", "/v1/health", healthRequest, healthResponse);
43
+ //#endregion
44
+ //#region src/gateway/contract/rpc.ts
45
+ /** One JSON-RPC call plus nothing else: batches may carry at most this many entries. */
46
+ const RPC_BATCH_MAX = 20;
47
+ /** Read-only EVM methods plus `eth_sendRawTransaction`. Anything not listed is rejected. */
48
+ const EVM_RPC_METHODS = [
49
+ "eth_blobBaseFee",
50
+ "eth_blockNumber",
51
+ "eth_call",
52
+ "eth_chainId",
53
+ "eth_createAccessList",
54
+ "eth_estimateGas",
55
+ "eth_feeHistory",
56
+ "eth_gasPrice",
57
+ "eth_getBalance",
58
+ "eth_getBlockByHash",
59
+ "eth_getBlockByNumber",
60
+ "eth_getBlockReceipts",
61
+ "eth_getBlockTransactionCountByHash",
62
+ "eth_getBlockTransactionCountByNumber",
63
+ "eth_getCode",
64
+ "eth_getProof",
65
+ "eth_getStorageAt",
66
+ "eth_getTransactionByBlockHashAndIndex",
67
+ "eth_getTransactionByBlockNumberAndIndex",
68
+ "eth_getTransactionByHash",
69
+ "eth_getTransactionCount",
70
+ "eth_getTransactionReceipt",
71
+ "eth_maxPriorityFeePerGas",
72
+ "eth_sendRawTransaction",
73
+ "net_version",
74
+ "web3_clientVersion"
75
+ ];
76
+ /** Read-only Solana methods plus `sendTransaction`. Anything not listed is rejected. */
77
+ const SOLANA_RPC_METHODS = [
78
+ "getAccountInfo",
79
+ "getBalance",
80
+ "getBlock",
81
+ "getBlockHeight",
82
+ "getBlockTime",
83
+ "getEpochInfo",
84
+ "getFeeForMessage",
85
+ "getGenesisHash",
86
+ "getLatestBlockhash",
87
+ "getMinimumBalanceForRentExemption",
88
+ "getMultipleAccounts",
89
+ "getRecentPrioritizationFees",
90
+ "getSignatureStatuses",
91
+ "getSignaturesForAddress",
92
+ "getSlot",
93
+ "getTokenAccountBalance",
94
+ "getTokenAccountsByOwner",
95
+ "getTokenSupply",
96
+ "getTransaction",
97
+ "getVersion",
98
+ "isBlockhashValid",
99
+ "sendTransaction",
100
+ "simulateTransaction"
101
+ ];
102
+ const jsonRpcId = z.union([
103
+ z.string(),
104
+ z.number(),
105
+ z.null()
106
+ ]);
107
+ const jsonRpcParams = z.optional(z.union([z.array(z.unknown()), z.record(z.string(), z.unknown())]));
108
+ const callSchema = (method) => z.object({
109
+ jsonrpc: z.literal("2.0"),
110
+ id: jsonRpcId,
111
+ method,
112
+ params: jsonRpcParams
113
+ });
114
+ const bodySchema = (call) => z.union([call, z.array(call).check(z.minLength(1), z.maxLength(20))]);
115
+ /** Method-agnostic wire shape of a call or batch (the gateway narrows by family). */
116
+ const rpcRequest = bodySchema(callSchema(z.string()));
117
+ const evmRpcRequest = bodySchema(callSchema(z.enum(EVM_RPC_METHODS)));
118
+ const solanaRpcRequest = bodySchema(callSchema(z.enum(SOLANA_RPC_METHODS)));
119
+ const successResponse = z.object({
120
+ jsonrpc: z.literal("2.0"),
121
+ id: jsonRpcId,
122
+ result: z.unknown()
123
+ });
124
+ const errorResponse = z.object({
125
+ jsonrpc: z.literal("2.0"),
126
+ id: jsonRpcId,
127
+ error: z.object({
128
+ code: z.int(),
129
+ message: z.string(),
130
+ data: z.optional(z.unknown())
131
+ })
132
+ });
133
+ const jsonRpcResponse = z.union([successResponse, errorResponse]);
134
+ const rpcResponse = z.union([jsonRpcResponse, z.array(jsonRpcResponse)]);
135
+ const rpc = endpoint("POST", "/v1/rpc/:caip2", rpcRequest, rpcResponse);
136
+ /** The JSON-RPC URL path for one network. */
137
+ const rpcPath = (caip2) => rpc.path.replace(":caip2", caip2);
138
+ //#endregion
139
+ //#region src/gateway/contract/esplora.ts
140
+ const HEX64 = "[0-9a-f]{64}";
141
+ /** The Esplora surface the engine uses; every other path is rejected. */
142
+ const ESPLORA_ROUTES = [
143
+ {
144
+ method: "GET",
145
+ pattern: /^\/block-height\/\d{1,10}$/
146
+ },
147
+ {
148
+ method: "GET",
149
+ pattern: /^\/fee-estimates$/
150
+ },
151
+ {
152
+ method: "GET",
153
+ pattern: new RegExp(`^/scripthash/${HEX64}/txs$`)
154
+ },
155
+ {
156
+ method: "GET",
157
+ pattern: new RegExp(`^/scripthash/${HEX64}/utxo$`)
158
+ },
159
+ {
160
+ method: "GET",
161
+ pattern: new RegExp(`^/tx/${HEX64}/hex$`)
162
+ },
163
+ {
164
+ method: "GET",
165
+ pattern: new RegExp(`^/tx/${HEX64}/status$`)
166
+ },
167
+ {
168
+ method: "POST",
169
+ pattern: /^\/tx$/
170
+ }
171
+ ];
172
+ /** `path` is the Esplora path after `/v1/esplora/:caip2`, with a leading slash and no query. */
173
+ const esploraPathAllowed = (method, path) => ESPLORA_ROUTES.some((route) => route.method === method && route.pattern.test(path));
174
+ const esploraGet = endpoint("GET", "/v1/esplora/:caip2/*", z.undefined(), z.unknown());
175
+ /** The Esplora base path for one network; allow-listed paths are appended to it. */
176
+ const esploraBasePath = (caip2) => esploraGet.path.replace(":caip2", caip2).replace(/\/\*$/, "");
177
+ const esploraPost = endpoint("POST", "/v1/esplora/:caip2/tx", z.string(), z.string());
178
+ //#endregion
179
+ //#region src/networks/registry.ts
180
+ const entry = (chainId, name, symbol, testnet, _source) => ({
181
+ id: `eip155:${chainId}`,
182
+ chainId,
183
+ name,
184
+ symbol,
185
+ decimals: 18,
186
+ testnet,
187
+ family: "evm",
188
+ multicall3: "0xcA11bde05977b3631167028862bE2a173976CA11"
189
+ });
190
+ const NETWORKS = [
191
+ entry(1, "Ethereum", "ETH", false, "https://ethereum.org/en/developers/docs/networks/"),
192
+ entry(8453, "Base", "ETH", false, "https://docs.base.org/docs/network-information"),
193
+ entry(42161, "Arbitrum One", "ETH", false, "https://docs.arbitrum.io/for-devs/dev-tools-and-resources/chain-info"),
194
+ entry(10, "OP Mainnet", "ETH", false, "https://docs.optimism.io/chain/networks"),
195
+ entry(137, "Polygon", "POL", false, "https://docs.polygon.technology/pos/reference/rpc-endpoints/"),
196
+ entry(56, "BNB Smart Chain", "BNB", false, "https://docs.bnbchain.org/bnb-smart-chain/developers/json_rpc/"),
197
+ entry(999, "HyperEVM", "HYPE", false, "https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm"),
198
+ entry(43114, "Avalanche C-Chain", "AVAX", false, "https://build.avax.network/docs/tooling/rpc-providers"),
199
+ entry(11155111, "Sepolia", "ETH", true, "https://ethereum.org/en/developers/docs/networks/"),
200
+ entry(84532, "Base Sepolia", "ETH", true, "https://docs.base.org/docs/network-information"),
201
+ entry(421614, "Arbitrum Sepolia", "ETH", true, "https://docs.arbitrum.io/for-devs/dev-tools-and-resources/chain-info"),
202
+ entry(11155420, "OP Sepolia", "ETH", true, "https://docs.optimism.io/chain/networks"),
203
+ entry(80002, "Polygon Amoy", "POL", true, "https://docs.polygon.technology/pos/reference/rpc-endpoints/"),
204
+ entry(97, "BNB Smart Chain Testnet", "tBNB", true, "https://docs.bnbchain.org/bnb-smart-chain/developers/json_rpc/"),
205
+ entry(998, "HyperEVM Testnet", "HYPE", true, "https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm"),
206
+ entry(43113, "Avalanche Fuji", "AVAX", true, "https://build.avax.network/docs/tooling/rpc-providers")
207
+ ];
208
+ const networkById = (id) => [
209
+ ...NETWORKS,
210
+ ...SOLANA_NETWORKS,
211
+ ...BITCOIN_NETWORKS
212
+ ].find((n) => n.id === id);
213
+ const BITCOIN_NETWORKS = [
214
+ {
215
+ id: "bip122:000000000019d6689c085ae165831e93",
216
+ chainId: 0,
217
+ name: "Bitcoin",
218
+ symbol: "BTC",
219
+ decimals: 8,
220
+ testnet: false,
221
+ family: "bitcoin",
222
+ genesisHash: "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
223
+ },
224
+ {
225
+ id: "bip122:00000000da84f2bafbbc53dee25a72ae",
226
+ chainId: 0,
227
+ name: "Bitcoin Testnet4",
228
+ symbol: "tBTC",
229
+ decimals: 8,
230
+ testnet: true,
231
+ family: "bitcoin",
232
+ genesisHash: "00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043"
233
+ },
234
+ {
235
+ id: "bip122:00000008819873e925422c1ff0f99f7c",
236
+ chainId: 0,
237
+ name: "Bitcoin Signet",
238
+ symbol: "sBTC",
239
+ decimals: 8,
240
+ testnet: true,
241
+ family: "bitcoin",
242
+ genesisHash: "00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6"
243
+ },
244
+ {
245
+ id: "bip122:0f9188f13cb7b2c71f2a335e3a4fc328",
246
+ chainId: 0,
247
+ name: "Bitcoin Regtest",
248
+ symbol: "rBTC",
249
+ decimals: 8,
250
+ testnet: true,
251
+ family: "bitcoin",
252
+ genesisHash: "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"
253
+ }
254
+ ];
255
+ const SOLANA_NETWORKS = [{
256
+ id: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
257
+ chainId: 0,
258
+ name: "Solana",
259
+ symbol: "SOL",
260
+ decimals: 9,
261
+ testnet: false,
262
+ family: "solana",
263
+ genesisHash: "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d"
264
+ }, {
265
+ id: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
266
+ chainId: 0,
267
+ name: "Solana Devnet",
268
+ symbol: "SOL",
269
+ decimals: 9,
270
+ testnet: true,
271
+ family: "solana",
272
+ genesisHash: "EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG"
273
+ }];
274
+ //#endregion
275
+ //#region src/gateway/contract/served.ts
276
+ const servedNetworksRequest = z.undefined();
277
+ /** The networks the gateway actually serves, in its configured order. */
278
+ const servedNetworksResponse = z.object({ networks: z.array(caip2) });
279
+ const servedNetworks = endpoint("GET", "/v1/networks", servedNetworksRequest, servedNetworksResponse);
280
+ const networksPath = servedNetworks.path;
281
+ //#endregion
282
+ export { parseWith as A, rpcResponse as C, healthResponse as D, healthRequest as E, gatewayError as F, installId as I, INSTALL_ID_HEADER as M, PROVIDERS_HEADER as N, accepts as O, caip2 as P, rpcRequest as S, health as T, evmRpcRequest as _, BITCOIN_NETWORKS as a, rpc as b, networkById as c, esploraGet as d, esploraPathAllowed as f, SOLANA_RPC_METHODS as g, RPC_BATCH_MAX as h, servedNetworksResponse as i, GATEWAY_ERRORS as j, endpoint as k, ESPLORA_ROUTES as l, EVM_RPC_METHODS as m, servedNetworks as n, NETWORKS as o, esploraPost as p, servedNetworksRequest as r, SOLANA_NETWORKS as s, networksPath as t, esploraBasePath as u, jsonRpcId as v, solanaRpcRequest as w, rpcPath as x, jsonRpcResponse as y };
283
+
284
+ //# sourceMappingURL=contract-D5pguqiZ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-D5pguqiZ.mjs","names":[],"sources":["../src/gateway/contract/primitives.ts","../src/gateway/contract/endpoint.ts","../src/gateway/contract/health.ts","../src/gateway/contract/rpc.ts","../src/gateway/contract/esplora.ts","../src/networks/registry.ts","../src/gateway/contract/served.ts"],"sourcesContent":["import * as z from \"zod/mini\";\n\nexport const INSTALL_ID_HEADER = \"x-install-id\";\nexport const PROVIDERS_HEADER = \"x-gateway-providers\";\n\n/** 128 random bits as lowercase hex — generated once per install, unrelated to wallet secrets. */\nexport const installId = z.string().check(z.regex(/^[0-9a-f]{32}$/));\n\n/** CAIP-2 chain id: `namespace:reference`. */\nexport const caip2 = z.string().check(z.regex(/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}$/));\n\nexport type Caip2 = z.infer<typeof caip2>;\nexport type InstallId = z.infer<typeof installId>;\n\nexport const GATEWAY_ERRORS = [\n \"invalid-request\",\n \"unknown-network\",\n \"not-found\",\n \"rate-limited\",\n \"unavailable\",\n \"internal\",\n] as const;\n\nexport const gatewayError = z.object({ error: z.enum(GATEWAY_ERRORS) });\n\nexport type GatewayErrorCode = (typeof GATEWAY_ERRORS)[number];\n","import * as z from \"zod/mini\";\n\nexport type HttpMethod = \"GET\" | \"POST\" | \"DELETE\";\n\nexport type Endpoint<Req extends z.ZodMiniType, Res extends z.ZodMiniType> = {\n readonly method: HttpMethod;\n readonly path: string;\n readonly request: Req;\n readonly response: Res;\n};\n\n/** One gateway route: its verb, versioned path template, and request/response schemas. */\nexport function endpoint<Req extends z.ZodMiniType, Res extends z.ZodMiniType>(\n method: HttpMethod,\n path: `/v1/${string}`,\n request: Req,\n response: Res,\n): Endpoint<Req, Res> {\n return { method, path, request, response };\n}\n\n/** `value` typed by `schema`, or `undefined` when it does not satisfy it. */\nexport function parseWith<S extends z.ZodMiniType>(\n schema: S,\n value: unknown,\n): z.output<S> | undefined {\n const result = z.safeParse(schema, value);\n return result.success ? result.data : undefined;\n}\n\n/** Whether `value` satisfies `schema` — lets consumers validate without importing zod. */\nexport function accepts(schema: z.ZodMiniType, value: unknown): boolean {\n return z.safeParse(schema, value).success;\n}\n","import * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\n\nexport const healthRequest = z.undefined();\nexport const healthResponse = z.object({ status: z.literal(\"ok\") });\n\nexport const health = endpoint(\"GET\", \"/v1/health\", healthRequest, healthResponse);\n","import * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\n\n/** One JSON-RPC call plus nothing else: batches may carry at most this many entries. */\nexport const RPC_BATCH_MAX = 20;\n\n/** Read-only EVM methods plus `eth_sendRawTransaction`. Anything not listed is rejected. */\nexport const EVM_RPC_METHODS = [\n \"eth_blobBaseFee\",\n \"eth_blockNumber\",\n \"eth_call\",\n \"eth_chainId\",\n \"eth_createAccessList\",\n \"eth_estimateGas\",\n \"eth_feeHistory\",\n \"eth_gasPrice\",\n \"eth_getBalance\",\n \"eth_getBlockByHash\",\n \"eth_getBlockByNumber\",\n \"eth_getBlockReceipts\",\n \"eth_getBlockTransactionCountByHash\",\n \"eth_getBlockTransactionCountByNumber\",\n \"eth_getCode\",\n \"eth_getProof\",\n \"eth_getStorageAt\",\n \"eth_getTransactionByBlockHashAndIndex\",\n \"eth_getTransactionByBlockNumberAndIndex\",\n \"eth_getTransactionByHash\",\n \"eth_getTransactionCount\",\n \"eth_getTransactionReceipt\",\n \"eth_maxPriorityFeePerGas\",\n \"eth_sendRawTransaction\",\n \"net_version\",\n \"web3_clientVersion\",\n] as const;\n\n/** Read-only Solana methods plus `sendTransaction`. Anything not listed is rejected. */\nexport const SOLANA_RPC_METHODS = [\n \"getAccountInfo\",\n \"getBalance\",\n \"getBlock\",\n \"getBlockHeight\",\n \"getBlockTime\",\n \"getEpochInfo\",\n \"getFeeForMessage\",\n \"getGenesisHash\",\n \"getLatestBlockhash\",\n \"getMinimumBalanceForRentExemption\",\n \"getMultipleAccounts\",\n \"getRecentPrioritizationFees\",\n \"getSignatureStatuses\",\n \"getSignaturesForAddress\",\n \"getSlot\",\n \"getTokenAccountBalance\",\n \"getTokenAccountsByOwner\",\n \"getTokenSupply\",\n \"getTransaction\",\n \"getVersion\",\n \"isBlockhashValid\",\n \"sendTransaction\",\n \"simulateTransaction\",\n] as const;\n\nexport type EvmRpcMethod = (typeof EVM_RPC_METHODS)[number];\nexport type SolanaRpcMethod = (typeof SOLANA_RPC_METHODS)[number];\n\nexport const jsonRpcId = z.union([z.string(), z.number(), z.null()]);\n\nconst jsonRpcParams = z.optional(\n z.union([z.array(z.unknown()), z.record(z.string(), z.unknown())]),\n);\n\nconst callSchema = <M extends z.ZodMiniType<string>>(method: M) =>\n z.object({ jsonrpc: z.literal(\"2.0\"), id: jsonRpcId, method, params: jsonRpcParams });\n\nconst bodySchema = <C extends z.ZodMiniType>(call: C) =>\n z.union([call, z.array(call).check(z.minLength(1), z.maxLength(RPC_BATCH_MAX))]);\n\n/** Method-agnostic wire shape of a call or batch (the gateway narrows by family). */\nexport const rpcRequest = bodySchema(callSchema(z.string()));\n\nexport const evmRpcRequest = bodySchema(callSchema(z.enum(EVM_RPC_METHODS)));\nexport const solanaRpcRequest = bodySchema(callSchema(z.enum(SOLANA_RPC_METHODS)));\n\nconst successResponse = z.object({\n jsonrpc: z.literal(\"2.0\"),\n id: jsonRpcId,\n result: z.unknown(),\n});\nconst errorResponse = z.object({\n jsonrpc: z.literal(\"2.0\"),\n id: jsonRpcId,\n error: z.object({ code: z.int(), message: z.string(), data: z.optional(z.unknown()) }),\n});\n\nexport const jsonRpcResponse = z.union([successResponse, errorResponse]);\nexport const rpcResponse = z.union([jsonRpcResponse, z.array(jsonRpcResponse)]);\n\nexport const rpc = endpoint(\"POST\", \"/v1/rpc/:caip2\", rpcRequest, rpcResponse);\n\n/** The JSON-RPC URL path for one network. */\nexport const rpcPath = (caip2: string): string => rpc.path.replace(\":caip2\", caip2);\n","import * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\n\nconst HEX64 = \"[0-9a-f]{64}\";\n\ntype EsploraRoute = { readonly method: \"GET\" | \"POST\"; readonly pattern: RegExp };\n\n/** The Esplora surface the engine uses; every other path is rejected. */\nexport const ESPLORA_ROUTES: ReadonlyArray<EsploraRoute> = [\n { method: \"GET\", pattern: /^\\/block-height\\/\\d{1,10}$/ },\n { method: \"GET\", pattern: /^\\/fee-estimates$/ },\n { method: \"GET\", pattern: new RegExp(`^/scripthash/${HEX64}/txs$`) },\n { method: \"GET\", pattern: new RegExp(`^/scripthash/${HEX64}/utxo$`) },\n { method: \"GET\", pattern: new RegExp(`^/tx/${HEX64}/hex$`) },\n { method: \"GET\", pattern: new RegExp(`^/tx/${HEX64}/status$`) },\n { method: \"POST\", pattern: /^\\/tx$/ },\n];\n\n/** `path` is the Esplora path after `/v1/esplora/:caip2`, with a leading slash and no query. */\nexport const esploraPathAllowed = (method: string, path: string): boolean =>\n ESPLORA_ROUTES.some((route) => route.method === method && route.pattern.test(path));\n\nexport const esploraGet = endpoint(\"GET\", \"/v1/esplora/:caip2/*\", z.undefined(), z.unknown());\n\n/** The Esplora base path for one network; allow-listed paths are appended to it. */\nexport const esploraBasePath = (caip2: string): string =>\n esploraGet.path.replace(\":caip2\", caip2).replace(/\\/\\*$/, \"\");\nexport const esploraPost = endpoint(\"POST\", \"/v1/esplora/:caip2/tx\", z.string(), z.string());\n","/**\n * Built-in EVM network registry: the 8 mainnets from chains.mdx plus their main testnets. Each\n * chain id was checked against the chain's official documentation (source URL per entry).\n * Signing-time chainId always comes from this table, never from an RPC endpoint.\n */\n\nexport type NetworkInfo = {\n readonly id: string; // CAIP-2 eip155:<chainId>\n readonly chainId: number;\n readonly name: string;\n readonly symbol: string;\n readonly multicall3?: string;\n /** CAIP-2 family — `solana:<ref>` networks are validated against genesis-hash, not chainId. */\n readonly family: \"evm\" | \"solana\" | \"bitcoin\";\n readonly genesisHash?: string;\n readonly decimals: number;\n readonly testnet: boolean;\n};\n\nconst entry = (\n chainId: number,\n name: string,\n symbol: string,\n testnet: boolean,\n _source: string,\n): NetworkInfo => ({\n id: `eip155:${chainId}`,\n chainId,\n name,\n symbol,\n decimals: 18,\n testnet,\n family: \"evm\",\n // Canonical Multicall3 — https://github.com/mds1/multicall3 deployments (all entries below).\n multicall3: \"0xcA11bde05977b3631167028862bE2a173976CA11\",\n});\n\nexport const NETWORKS: ReadonlyArray<NetworkInfo> = [\n // https://chainlist.org + https://ethereum.org (Ethereum mainnet chainId 1)\n entry(1, \"Ethereum\", \"ETH\", false, \"https://ethereum.org/en/developers/docs/networks/\"),\n // https://docs.base.org — Base Sepolia 84532\n entry(8453, \"Base\", \"ETH\", false, \"https://docs.base.org/docs/network-information\"),\n // https://docs.arbitrum.io — Arbitrum Sepolia 421614\n entry(\n 42161,\n \"Arbitrum One\",\n \"ETH\",\n false,\n \"https://docs.arbitrum.io/for-devs/dev-tools-and-resources/chain-info\",\n ),\n // https://docs.optimism.io — OP Sepolia 11155420\n entry(10, \"OP Mainnet\", \"ETH\", false, \"https://docs.optimism.io/chain/networks\"),\n // https://docs.polygon.technology — Amoy 80002\n entry(\n 137,\n \"Polygon\",\n \"POL\",\n false,\n \"https://docs.polygon.technology/pos/reference/rpc-endpoints/\",\n ),\n // https://docs.bnbchain.org — BSC testnet 97\n entry(\n 56,\n \"BNB Smart Chain\",\n \"BNB\",\n false,\n \"https://docs.bnbchain.org/bnb-smart-chain/developers/json_rpc/\",\n ),\n // https://hyperliquid.gitbook.io — HyperEVM testnet 998\n entry(\n 999,\n \"HyperEVM\",\n \"HYPE\",\n false,\n \"https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm\",\n ),\n // https://build.avax.network — Fuji 43113\n entry(\n 43114,\n \"Avalanche C-Chain\",\n \"AVAX\",\n false,\n \"https://build.avax.network/docs/tooling/rpc-providers\",\n ),\n entry(11155111, \"Sepolia\", \"ETH\", true, \"https://ethereum.org/en/developers/docs/networks/\"),\n entry(84532, \"Base Sepolia\", \"ETH\", true, \"https://docs.base.org/docs/network-information\"),\n entry(\n 421614,\n \"Arbitrum Sepolia\",\n \"ETH\",\n true,\n \"https://docs.arbitrum.io/for-devs/dev-tools-and-resources/chain-info\",\n ),\n entry(11155420, \"OP Sepolia\", \"ETH\", true, \"https://docs.optimism.io/chain/networks\"),\n entry(\n 80002,\n \"Polygon Amoy\",\n \"POL\",\n true,\n \"https://docs.polygon.technology/pos/reference/rpc-endpoints/\",\n ),\n entry(\n 97,\n \"BNB Smart Chain Testnet\",\n \"tBNB\",\n true,\n \"https://docs.bnbchain.org/bnb-smart-chain/developers/json_rpc/\",\n ),\n entry(\n 998,\n \"HyperEVM Testnet\",\n \"HYPE\",\n true,\n \"https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm\",\n ),\n entry(\n 43113,\n \"Avalanche Fuji\",\n \"AVAX\",\n true,\n \"https://build.avax.network/docs/tooling/rpc-providers\",\n ),\n];\n\nexport const networkById = (id: string): NetworkInfo | undefined =>\n [...NETWORKS, ...SOLANA_NETWORKS, ...BITCOIN_NETWORKS].find((n) => n.id === id);\nexport const BITCOIN_NETWORKS: ReadonlyArray<NetworkInfo> = [\n {\n id: \"bip122:000000000019d6689c085ae165831e93\",\n chainId: 0,\n name: \"Bitcoin\",\n symbol: \"BTC\",\n decimals: 8,\n testnet: false,\n family: \"bitcoin\",\n genesisHash: \"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f\",\n },\n {\n id: \"bip122:00000000da84f2bafbbc53dee25a72ae\",\n chainId: 0,\n name: \"Bitcoin Testnet4\",\n symbol: \"tBTC\",\n decimals: 8,\n testnet: true,\n family: \"bitcoin\",\n genesisHash: \"00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043\",\n },\n {\n id: \"bip122:00000008819873e925422c1ff0f99f7c\",\n chainId: 0,\n name: \"Bitcoin Signet\",\n symbol: \"sBTC\",\n decimals: 8,\n testnet: true,\n family: \"bitcoin\",\n genesisHash: \"00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6\",\n },\n {\n id: \"bip122:0f9188f13cb7b2c71f2a335e3a4fc328\",\n chainId: 0,\n name: \"Bitcoin Regtest\",\n symbol: \"rBTC\",\n decimals: 8,\n testnet: true,\n family: \"bitcoin\",\n genesisHash: \"0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206\",\n },\n];\n\nexport const SOLANA_NETWORKS: ReadonlyArray<NetworkInfo> = [\n {\n id: \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\",\n chainId: 0,\n name: \"Solana\",\n symbol: \"SOL\",\n decimals: 9,\n testnet: false,\n family: \"solana\",\n // https://solana.com/docs/references/clusters (mainnet genesis hash)\n genesisHash: \"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d\",\n },\n {\n id: \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\",\n chainId: 0,\n name: \"Solana Devnet\",\n symbol: \"SOL\",\n decimals: 9,\n testnet: true,\n family: \"solana\",\n genesisHash: \"EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG\",\n },\n];\n","import * as z from \"zod/mini\";\n\nimport { endpoint } from \"./endpoint.ts\";\nimport { caip2 } from \"./primitives.ts\";\n\nexport const servedNetworksRequest = z.undefined();\n/** The networks the gateway actually serves, in its configured order. */\nexport const servedNetworksResponse = z.object({ networks: z.array(caip2) });\n\nexport const servedNetworks = endpoint(\n \"GET\",\n \"/v1/networks\",\n servedNetworksRequest,\n servedNetworksResponse,\n);\n\nexport const networksPath: string = servedNetworks.path;\n"],"mappings":";;AAEA,MAAa,oBAAoB;AACjC,MAAa,mBAAmB;;AAGhC,MAAa,YAAY,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,gBAAgB,CAAC;;AAGnE,MAAa,QAAQ,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAKrF,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,CAAC;;;;ACXtE,SAAgB,SACd,QACA,MACA,SACA,UACoB;CACpB,OAAO;EAAE;EAAQ;EAAM;EAAS;CAAS;AAC3C;;AAGA,SAAgB,UACd,QACA,OACyB;CACzB,MAAM,SAAS,EAAE,UAAU,QAAQ,KAAK;CACxC,OAAO,OAAO,UAAU,OAAO,OAAO,KAAA;AACx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