@lendasat/lendaswap-sdk-pure 0.2.21-preview.0 → 0.2.21

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 (205) hide show
  1. package/dist/api/client.d.ts.map +1 -1
  2. package/dist/api/client.js +4 -1
  3. package/dist/api/client.js.map +1 -1
  4. package/dist/version.d.ts +4 -0
  5. package/dist/version.d.ts.map +1 -0
  6. package/dist/version.js +6 -0
  7. package/dist/version.js.map +1 -0
  8. package/package.json +4 -1
  9. package/dist/price-feed.d.ts +0 -124
  10. package/dist/price-feed.d.ts.map +0 -1
  11. package/dist/price-feed.js +0 -178
  12. package/dist/price-feed.js.map +0 -1
  13. package/dist/src/api/client.d.ts +0 -31
  14. package/dist/src/api/client.d.ts.map +0 -1
  15. package/dist/src/api/client.js +0 -12
  16. package/dist/src/api/client.js.map +0 -1
  17. package/dist/src/arkade.d.ts +0 -36
  18. package/dist/src/arkade.d.ts.map +0 -1
  19. package/dist/src/arkade.js +0 -68
  20. package/dist/src/arkade.js.map +0 -1
  21. package/dist/src/client.d.ts +0 -760
  22. package/dist/src/client.d.ts.map +0 -1
  23. package/dist/src/client.js +0 -2169
  24. package/dist/src/client.js.map +0 -1
  25. package/dist/src/create/arkade.d.ts +0 -34
  26. package/dist/src/create/arkade.d.ts.map +0 -1
  27. package/dist/src/create/arkade.js +0 -76
  28. package/dist/src/create/arkade.js.map +0 -1
  29. package/dist/src/create/bitcoin-to-arkade.d.ts +0 -36
  30. package/dist/src/create/bitcoin-to-arkade.d.ts.map +0 -1
  31. package/dist/src/create/bitcoin-to-arkade.js +0 -69
  32. package/dist/src/create/bitcoin-to-arkade.js.map +0 -1
  33. package/dist/src/create/bitcoin.d.ts +0 -31
  34. package/dist/src/create/bitcoin.d.ts.map +0 -1
  35. package/dist/src/create/bitcoin.js +0 -67
  36. package/dist/src/create/bitcoin.js.map +0 -1
  37. package/dist/src/create/evm-to-arkade.d.ts +0 -34
  38. package/dist/src/create/evm-to-arkade.d.ts.map +0 -1
  39. package/dist/src/create/evm-to-arkade.js +0 -69
  40. package/dist/src/create/evm-to-arkade.js.map +0 -1
  41. package/dist/src/create/evm-to-bitcoin.d.ts +0 -35
  42. package/dist/src/create/evm-to-bitcoin.d.ts.map +0 -1
  43. package/dist/src/create/evm-to-bitcoin.js +0 -71
  44. package/dist/src/create/evm-to-bitcoin.js.map +0 -1
  45. package/dist/src/create/evm-to-lightning.d.ts +0 -34
  46. package/dist/src/create/evm-to-lightning.d.ts.map +0 -1
  47. package/dist/src/create/evm-to-lightning.js +0 -66
  48. package/dist/src/create/evm-to-lightning.js.map +0 -1
  49. package/dist/src/create/index.d.ts +0 -19
  50. package/dist/src/create/index.d.ts.map +0 -1
  51. package/dist/src/create/index.js +0 -18
  52. package/dist/src/create/index.js.map +0 -1
  53. package/dist/src/create/lightning.d.ts +0 -31
  54. package/dist/src/create/lightning.d.ts.map +0 -1
  55. package/dist/src/create/lightning.js +0 -72
  56. package/dist/src/create/lightning.js.map +0 -1
  57. package/dist/src/create/types.d.ts +0 -247
  58. package/dist/src/create/types.d.ts.map +0 -1
  59. package/dist/src/create/types.js +0 -5
  60. package/dist/src/create/types.js.map +0 -1
  61. package/dist/src/delegate.d.ts +0 -62
  62. package/dist/src/delegate.d.ts.map +0 -1
  63. package/dist/src/delegate.js +0 -284
  64. package/dist/src/delegate.js.map +0 -1
  65. package/dist/src/esplora.d.ts +0 -41
  66. package/dist/src/esplora.d.ts.map +0 -1
  67. package/dist/src/esplora.js +0 -47
  68. package/dist/src/esplora.js.map +0 -1
  69. package/dist/src/evm/coordinator.d.ts +0 -247
  70. package/dist/src/evm/coordinator.d.ts.map +0 -1
  71. package/dist/src/evm/coordinator.js +0 -414
  72. package/dist/src/evm/coordinator.js.map +0 -1
  73. package/dist/src/evm/htlc.d.ts +0 -238
  74. package/dist/src/evm/htlc.d.ts.map +0 -1
  75. package/dist/src/evm/htlc.js +0 -278
  76. package/dist/src/evm/htlc.js.map +0 -1
  77. package/dist/src/evm/index.d.ts +0 -9
  78. package/dist/src/evm/index.d.ts.map +0 -1
  79. package/dist/src/evm/index.js +0 -9
  80. package/dist/src/evm/index.js.map +0 -1
  81. package/dist/src/evm/signing.d.ts +0 -30
  82. package/dist/src/evm/signing.d.ts.map +0 -1
  83. package/dist/src/evm/signing.js +0 -91
  84. package/dist/src/evm/signing.js.map +0 -1
  85. package/dist/src/generated/api.d.ts +0 -2736
  86. package/dist/src/generated/api.d.ts.map +0 -1
  87. package/dist/src/generated/api.js +0 -6
  88. package/dist/src/generated/api.js.map +0 -1
  89. package/dist/src/index.d.ts +0 -18
  90. package/dist/src/index.d.ts.map +0 -1
  91. package/dist/src/index.js +0 -24
  92. package/dist/src/index.js.map +0 -1
  93. package/dist/src/node.d.ts +0 -19
  94. package/dist/src/node.d.ts.map +0 -1
  95. package/dist/src/node.js +0 -19
  96. package/dist/src/node.js.map +0 -1
  97. package/dist/src/price-calculations.d.ts +0 -109
  98. package/dist/src/price-calculations.d.ts.map +0 -1
  99. package/dist/src/price-calculations.js +0 -135
  100. package/dist/src/price-calculations.js.map +0 -1
  101. package/dist/src/redeem/arkade.d.ts +0 -65
  102. package/dist/src/redeem/arkade.d.ts.map +0 -1
  103. package/dist/src/redeem/arkade.js +0 -217
  104. package/dist/src/redeem/arkade.js.map +0 -1
  105. package/dist/src/redeem/ethereum.d.ts +0 -52
  106. package/dist/src/redeem/ethereum.d.ts.map +0 -1
  107. package/dist/src/redeem/ethereum.js +0 -206
  108. package/dist/src/redeem/ethereum.js.map +0 -1
  109. package/dist/src/redeem/gasless.d.ts +0 -41
  110. package/dist/src/redeem/gasless.d.ts.map +0 -1
  111. package/dist/src/redeem/gasless.js +0 -71
  112. package/dist/src/redeem/gasless.js.map +0 -1
  113. package/dist/src/redeem/index.d.ts +0 -49
  114. package/dist/src/redeem/index.d.ts.map +0 -1
  115. package/dist/src/redeem/index.js +0 -189
  116. package/dist/src/redeem/index.js.map +0 -1
  117. package/dist/src/redeem/types.d.ts +0 -126
  118. package/dist/src/redeem/types.d.ts.map +0 -1
  119. package/dist/src/redeem/types.js +0 -36
  120. package/dist/src/redeem/types.js.map +0 -1
  121. package/dist/src/refund/arkade.d.ts +0 -62
  122. package/dist/src/refund/arkade.d.ts.map +0 -1
  123. package/dist/src/refund/arkade.js +0 -212
  124. package/dist/src/refund/arkade.js.map +0 -1
  125. package/dist/src/refund/index.d.ts +0 -10
  126. package/dist/src/refund/index.d.ts.map +0 -1
  127. package/dist/src/refund/index.js +0 -10
  128. package/dist/src/refund/index.js.map +0 -1
  129. package/dist/src/refund/onchain.d.ts +0 -137
  130. package/dist/src/refund/onchain.d.ts.map +0 -1
  131. package/dist/src/refund/onchain.js +0 -366
  132. package/dist/src/refund/onchain.js.map +0 -1
  133. package/dist/src/signer/index.d.ts +0 -106
  134. package/dist/src/signer/index.d.ts.map +0 -1
  135. package/dist/src/signer/index.js +0 -179
  136. package/dist/src/signer/index.js.map +0 -1
  137. package/dist/src/storage/idb.d.ts +0 -70
  138. package/dist/src/storage/idb.d.ts.map +0 -1
  139. package/dist/src/storage/idb.js +0 -236
  140. package/dist/src/storage/idb.js.map +0 -1
  141. package/dist/src/storage/index.d.ts +0 -152
  142. package/dist/src/storage/index.d.ts.map +0 -1
  143. package/dist/src/storage/index.js +0 -98
  144. package/dist/src/storage/index.js.map +0 -1
  145. package/dist/src/storage/sqlite.d.ts +0 -95
  146. package/dist/src/storage/sqlite.d.ts.map +0 -1
  147. package/dist/src/storage/sqlite.js +0 -206
  148. package/dist/src/storage/sqlite.js.map +0 -1
  149. package/dist/src/storage/types.d.ts +0 -57
  150. package/dist/src/storage/types.d.ts.map +0 -1
  151. package/dist/src/storage/types.js +0 -9
  152. package/dist/src/storage/types.js.map +0 -1
  153. package/dist/src/tokens.d.ts +0 -29
  154. package/dist/src/tokens.d.ts.map +0 -1
  155. package/dist/src/tokens.js +0 -89
  156. package/dist/src/tokens.js.map +0 -1
  157. package/dist/src/usd-price.d.ts +0 -34
  158. package/dist/src/usd-price.d.ts.map +0 -1
  159. package/dist/src/usd-price.js +0 -83
  160. package/dist/src/usd-price.js.map +0 -1
  161. package/dist/tests/api-client.test.d.ts +0 -2
  162. package/dist/tests/api-client.test.d.ts.map +0 -1
  163. package/dist/tests/api-client.test.js +0 -86
  164. package/dist/tests/api-client.test.js.map +0 -1
  165. package/dist/tests/client.test.d.ts +0 -2
  166. package/dist/tests/client.test.d.ts.map +0 -1
  167. package/dist/tests/client.test.js +0 -150
  168. package/dist/tests/client.test.js.map +0 -1
  169. package/dist/tests/index.test.d.ts +0 -2
  170. package/dist/tests/index.test.d.ts.map +0 -1
  171. package/dist/tests/index.test.js +0 -8
  172. package/dist/tests/index.test.js.map +0 -1
  173. package/dist/tests/onchain-refund.test.d.ts +0 -2
  174. package/dist/tests/onchain-refund.test.d.ts.map +0 -1
  175. package/dist/tests/onchain-refund.test.js +0 -279
  176. package/dist/tests/onchain-refund.test.js.map +0 -1
  177. package/dist/tests/signer.test.d.ts +0 -2
  178. package/dist/tests/signer.test.d.ts.map +0 -1
  179. package/dist/tests/signer.test.js +0 -92
  180. package/dist/tests/signer.test.js.map +0 -1
  181. package/dist/tests/sqlite-storage.test.d.ts +0 -2
  182. package/dist/tests/sqlite-storage.test.d.ts.map +0 -1
  183. package/dist/tests/sqlite-storage.test.js +0 -160
  184. package/dist/tests/sqlite-storage.test.js.map +0 -1
  185. package/dist/tests/storage.test.d.ts +0 -2
  186. package/dist/tests/storage.test.d.ts.map +0 -1
  187. package/dist/tests/storage.test.js +0 -184
  188. package/dist/tests/storage.test.js.map +0 -1
  189. package/dist/tsconfig.tsbuildinfo +0 -1
  190. package/dist/usdt0-bridge/bridge.d.ts +0 -82
  191. package/dist/usdt0-bridge/bridge.d.ts.map +0 -1
  192. package/dist/usdt0-bridge/bridge.js +0 -56
  193. package/dist/usdt0-bridge/bridge.js.map +0 -1
  194. package/dist/usdt0-bridge/chains.d.ts +0 -41
  195. package/dist/usdt0-bridge/chains.d.ts.map +0 -1
  196. package/dist/usdt0-bridge/chains.js +0 -117
  197. package/dist/usdt0-bridge/chains.js.map +0 -1
  198. package/dist/usdt0-bridge/layerzero-tracker.d.ts +0 -34
  199. package/dist/usdt0-bridge/layerzero-tracker.d.ts.map +0 -1
  200. package/dist/usdt0-bridge/layerzero-tracker.js +0 -86
  201. package/dist/usdt0-bridge/layerzero-tracker.js.map +0 -1
  202. package/dist/usdt0-bridge/oft-abi.d.ts +0 -145
  203. package/dist/usdt0-bridge/oft-abi.d.ts.map +0 -1
  204. package/dist/usdt0-bridge/oft-abi.js +0 -117
  205. package/dist/usdt0-bridge/oft-abi.js.map +0 -1
@@ -1,217 +0,0 @@
1
- /**
2
- * Arkade (off-chain) VHTLC claim implementation.
3
- *
4
- * This module provides VHTLC claim functionality for Arkade swaps.
5
- * When a swap is funded by the server (EVM-to-Arkade direction),
6
- * the user can claim their BTC by revealing the preimage.
7
- *
8
- * The VHTLC uses a Taproot output with multiple spending paths. For claims,
9
- * we use the `claim` script path which requires revealing the preimage.
10
- */
11
- import { buildOffchainTx, ConditionWitness, CSVMultisigTapscript, networks, RestArkProvider, RestIndexerProvider, SingleKey, setArkPsbtField, Transaction, VHTLC, } from "@arkade-os/sdk";
12
- import { ripemd160 } from "@noble/hashes/ripemd160";
13
- import { sha256 } from "@noble/hashes/sha256";
14
- import { base64, hex } from "@scure/base";
15
- /** Default Arkade server URL by network */
16
- const DEFAULT_ARKADE_URLS = {
17
- bitcoin: "https://arkade.computer",
18
- mainnet: "https://arkade.computer",
19
- signet: "https://mutinynet.arkade.sh",
20
- mutinynet: "https://mutinynet.arkade.sh",
21
- };
22
- /**
23
- * Maps network strings from the API to Arkade NetworkName.
24
- */
25
- function getNetworkName(network) {
26
- switch (network.toLowerCase()) {
27
- case "mainnet":
28
- case "bitcoin":
29
- return "bitcoin";
30
- case "testnet":
31
- return "testnet";
32
- case "signet":
33
- return "signet";
34
- case "mutinynet":
35
- return "mutinynet";
36
- case "regtest":
37
- return "regtest";
38
- default:
39
- throw new Error(`Unknown network: ${network}`);
40
- }
41
- }
42
- /**
43
- * Get network HRP prefix for Ark addresses.
44
- */
45
- function getNetworkHrp(networkName) {
46
- const network = networks[networkName];
47
- return network.hrp;
48
- }
49
- /**
50
- * Convert seconds to RelativeTimelock format.
51
- */
52
- function secondsToTimelock(seconds) {
53
- return {
54
- type: "seconds",
55
- value: BigInt(seconds),
56
- };
57
- }
58
- /**
59
- * Parse public key, handling both compressed (33-byte) and x-only (32-byte) formats.
60
- * Returns x-only (32-byte) format.
61
- */
62
- function parseXOnlyPubKey(pubKeyHex) {
63
- const bytes = hex.decode(pubKeyHex);
64
- if (bytes.length === 33) {
65
- // Compressed pubkey, strip the prefix byte
66
- return bytes.slice(1);
67
- }
68
- if (bytes.length === 32) {
69
- // Already x-only
70
- return bytes;
71
- }
72
- throw new Error(`Invalid public key length: expected 32 or 33, got ${bytes.length}`);
73
- }
74
- /**
75
- * Claim a VHTLC swap by revealing the preimage.
76
- *
77
- * This function:
78
- * 1. Constructs the VHTLC with the same parameters as the original swap
79
- * 2. Connects to the Arkade server
80
- * 3. Fetches spendable VTXOs at the VHTLC address
81
- * 4. Builds an offchain transaction using the claim script path
82
- * 5. Signs and submits the transaction (with preimage in witness)
83
- * 6. Finalizes the transaction
84
- *
85
- * @param params - The claim parameters
86
- * @returns The claim result with transaction ID and amount
87
- * @throws Error if the claim fails
88
- */
89
- export async function buildArkadeClaim(params) {
90
- const { userSecretKey, userPubKey, lendaswapPubKey, arkadeServerPubKey, preimage, preimageHash, vhtlcAddress, refundLocktime, unilateralClaimDelay, unilateralRefundDelay, unilateralRefundWithoutReceiverDelay, destinationAddress, network, arkadeServerUrl, } = params;
91
- console.log(`Arkade claim params: ${JSON.stringify(params, null, 2)}`);
92
- // Parse keys
93
- // For claim: user is RECEIVER, lendaswap is SENDER
94
- const userPkBytes = parseXOnlyPubKey(userPubKey);
95
- const lendaswapPkBytes = parseXOnlyPubKey(lendaswapPubKey);
96
- const serverPkBytes = parseXOnlyPubKey(arkadeServerPubKey);
97
- // Parse preimage and compute hash
98
- const preimageBytes = hex.decode(preimage);
99
- if (preimageBytes.length !== 32) {
100
- throw new Error(`Invalid preimage length: expected 32, got ${preimageBytes.length}`);
101
- }
102
- // Compute preimage hash: SHA256 -> RIPEMD160 (HASH160)
103
- const sha256Hash = sha256(preimageBytes);
104
- const preimageHashBytes = ripemd160(sha256Hash);
105
- const preimageHashBytesString = hex.encode(preimageHashBytes);
106
- if (preimageHashBytesString !== hex.encode(ripemd160(hex.decode(preimageHash)))) {
107
- throw new Error(`Preimage hash are not equal. '${hex.encode(ripemd160(hex.decode(preimageHash)))}' vs ${preimageHashBytesString}'`);
108
- }
109
- // Determine Arkade server URL
110
- const networkName = getNetworkName(network);
111
- const serverUrl = arkadeServerUrl ?? DEFAULT_ARKADE_URLS[networkName];
112
- if (!serverUrl) {
113
- throw new Error(`No Arkade server URL configured for network: ${networkName}`);
114
- }
115
- // Create Arkade providers
116
- const arkProvider = new RestArkProvider(serverUrl);
117
- const indexerProvider = new RestIndexerProvider(serverUrl);
118
- // Get server info
119
- const serverInfo = await arkProvider.getInfo();
120
- // Construct VHTLC with the same parameters as the original swap
121
- // For claim: lendaswap is the SENDER, user is the RECEIVER
122
- const vhtlc = new VHTLC.Script({
123
- sender: lendaswapPkBytes,
124
- receiver: userPkBytes,
125
- server: serverPkBytes,
126
- preimageHash: preimageHashBytes,
127
- refundLocktime: BigInt(refundLocktime),
128
- unilateralClaimDelay: secondsToTimelock(unilateralClaimDelay),
129
- unilateralRefundDelay: secondsToTimelock(unilateralRefundDelay),
130
- unilateralRefundWithoutReceiverDelay: secondsToTimelock(unilateralRefundWithoutReceiverDelay),
131
- });
132
- // Get network HRP and verify computed VHTLC address
133
- const hrp = getNetworkHrp(networkName);
134
- const computedAddress = vhtlc.address(hrp, serverPkBytes);
135
- const computedAddressStr = computedAddress.encode();
136
- // Verify address matches expected
137
- if (computedAddressStr !== vhtlcAddress) {
138
- throw new Error(`Computed VHTLC address (${computedAddressStr}) does not match expected (${vhtlcAddress})`);
139
- }
140
- // Fetch VTXOs at the VHTLC address
141
- const vhtlcPkScript = hex.encode(vhtlc.pkScript);
142
- const { vtxos } = await indexerProvider.getVtxos({
143
- scripts: [vhtlcPkScript],
144
- spendableOnly: true,
145
- });
146
- if (vtxos.length === 0) {
147
- const { vtxos: allVtxos } = await indexerProvider.getVtxos({
148
- scripts: [vhtlcPkScript],
149
- });
150
- console.log(`All VTXOs at address: ${JSON.stringify(allVtxos, null, 2)}`);
151
- throw new Error("No spendable VTXOs found at the VHTLC address");
152
- }
153
- // Calculate total amount
154
- const totalAmount = vtxos.reduce((acc, v) => acc + BigInt(v.value), 0n);
155
- if (totalAmount === 0n) {
156
- throw new Error("Total VTXO amount is zero");
157
- }
158
- // Get the claim TapLeafScript (this is the key difference from refund)
159
- const claimLeafScript = vhtlc.claim();
160
- // Encode the VHTLC tap tree
161
- const tapTree = vhtlc.encode();
162
- // Decode the server's checkpoint tapscript
163
- const checkpointTapscript = CSVMultisigTapscript.decode(hex.decode(serverInfo.checkpointTapscript));
164
- // Build inputs for offchain transaction
165
- // Include the preimage in the witness data
166
- const inputs = vtxos.map((v) => ({
167
- txid: v.txid,
168
- vout: v.vout,
169
- value: v.value,
170
- tapTree: tapTree,
171
- tapLeafScript: claimLeafScript,
172
- // The preimage will be added to the witness during signing
173
- witnessData: preimageBytes,
174
- }));
175
- // Parse destination address
176
- const { ArkAddress } = await import("@arkade-os/sdk");
177
- const destAddr = ArkAddress.decode(destinationAddress);
178
- const destPkScript = destAddr.pkScript;
179
- // Build outputs
180
- const outputs = [
181
- {
182
- script: destPkScript,
183
- amount: totalAmount,
184
- },
185
- ];
186
- console.log(`Claiming ${totalAmount} sats to ${destinationAddress}`);
187
- // Build the offchain transaction
188
- const { arkTx, checkpoints } = buildOffchainTx(inputs, outputs, checkpointTapscript);
189
- // Create signer from user's secret key
190
- const signer = SingleKey.fromHex(userSecretKey);
191
- const computedPk = await signer.xOnlyPublicKey();
192
- if (hex.encode(userPkBytes) !== hex.encode(computedPk)) {
193
- throw new Error(`Signing with wrong key? ${hex.encode(userPkBytes)} vs ${hex.encode(computedPk)}`);
194
- }
195
- // Sign the ark transaction
196
- setArkPsbtField(arkTx, 0, ConditionWitness, [preimageBytes]);
197
- const signedArkTx = await signer.sign(arkTx);
198
- // Submit the transaction to the Arkade server
199
- const signedArkTxBase64 = base64.encode(signedArkTx.toPSBT());
200
- const { arkTxid, signedCheckpointTxs } = await arkProvider.submitTx(signedArkTxBase64, checkpoints.map((cp) => base64.encode(cp.toPSBT())));
201
- // Sign and finalize checkpoint transactions
202
- const finalCheckpoints = await Promise.all(signedCheckpointTxs.map(async (c) => {
203
- const tx = Transaction.fromPSBT(base64.decode(c));
204
- setArkPsbtField(tx, 0, ConditionWitness, [preimageBytes]);
205
- const signedCheckpoint = await signer.sign(tx, [0]);
206
- return base64.encode(signedCheckpoint.toPSBT());
207
- }));
208
- console.log(`Checkpoint transactions signed`);
209
- // Finalize the transaction
210
- await arkProvider.finalizeTx(arkTxid, finalCheckpoints);
211
- console.log(`Arkade claim finalized: ${arkTxid}`);
212
- return {
213
- txId: arkTxid,
214
- claimAmount: totalAmount,
215
- };
216
- }
217
- //# sourceMappingURL=arkade.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arkade.js","sourceRoot":"","sources":["../../../src/redeem/arkade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAGL,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EAGpB,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,WAAW,EACX,KAAK,GACN,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAE1C,2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ACxD,OAAO,CAAC,GAAG,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;IAElD,OAAO;QACL,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,WAAW;KACzB,CAAC;AACJ,CAAC"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Ethereum claim logic with contract call data encoding.
3
- *
4
- * EVM claims use the HTLCErc20 contract's redeem() function which requires
5
- * all original swap parameters for verification.
6
- */
7
- import type { GetSwapResponse } from "../api/client.js";
8
- import type { ClaimResult } from "./types.js";
9
- /**
10
- * Builds the claim data for an EVM swap (Ethereum, Polygon, or Arbitrum).
11
- *
12
- * The HTLCErc20 contract requires all original swap parameters for verification:
13
- * - preimage: The secret whose SHA-256 hash matches the preimageHash
14
- * - amount: Token amount that was locked
15
- * - token: ERC20 token address that was locked
16
- * - sender: Address that created the swap (server)
17
- * - timelock: Unix timestamp after which sender can refund
18
- *
19
- * @param id - The UUID of the swap (not used in contract call, kept for reference).
20
- * @param secret - The preimage/secret (32-byte hex string, with or without 0x prefix).
21
- * @param swap - The swap response from the API.
22
- * @param chain - The target chain for the claim.
23
- * @returns A ClaimResult with the EVM claim data.
24
- */
25
- export declare function buildEthereumClaimData(id: string, secret: string, swap: GetSwapResponse, chain: "polygon" | "arbitrum" | "ethereum"): ClaimResult;
26
- /**
27
- * Encodes call data for the redeem(bytes32,uint256,address,address,uint256) function.
28
- *
29
- * Function selector: keccak256("redeem(bytes32,uint256,address,address,uint256)")[0:4]
30
- *
31
- * @param preimage - The preimage/secret as a bytes32 hex string
32
- * @param amount - The token amount
33
- * @param token - The ERC20 token address
34
- * @param sender - The swap sender (server) address
35
- * @param timelock - The refund timelock
36
- * @returns The encoded call data as a hex string with 0x prefix
37
- */
38
- export declare function encodeRedeemCallData(preimage: string, amount: bigint, token: string, sender: string, timelock: bigint): string;
39
- /**
40
- * Encodes call data for the legacy claimSwap(bytes32,bytes32) function.
41
- * @deprecated Use encodeRedeemCallData instead for HTLCErc20 v2 contracts.
42
- */
43
- export declare function encodeClaimSwapCallData(swapId: string, secret: string): string;
44
- /**
45
- * Converts a UUID to a bytes32 hex string.
46
- * Removes dashes and right-pads with zeros to make 32 bytes.
47
- *
48
- * @param uuid - UUID string (e.g., "550e8400-e29b-41d4-a716-446655440000")
49
- * @returns 64-character hex string (without 0x prefix)
50
- */
51
- export declare function uuidToBytes32(uuid: string): string;
52
- //# sourceMappingURL=ethereum.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ethereum.d.ts","sourceRoot":"","sources":["../../../src/redeem/ethereum.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,eAAe,EACrB,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,GACzC,WAAW,CAyDb;AAgDD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,MAAM,CAmBR;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,MAAM,CAUR;AAyCD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkBlD"}
@@ -1,206 +0,0 @@
1
- /**
2
- * Ethereum claim logic with contract call data encoding.
3
- *
4
- * EVM claims use the HTLCErc20 contract's redeem() function which requires
5
- * all original swap parameters for verification.
6
- */
7
- /**
8
- * Builds the claim data for an EVM swap (Ethereum, Polygon, or Arbitrum).
9
- *
10
- * The HTLCErc20 contract requires all original swap parameters for verification:
11
- * - preimage: The secret whose SHA-256 hash matches the preimageHash
12
- * - amount: Token amount that was locked
13
- * - token: ERC20 token address that was locked
14
- * - sender: Address that created the swap (server)
15
- * - timelock: Unix timestamp after which sender can refund
16
- *
17
- * @param id - The UUID of the swap (not used in contract call, kept for reference).
18
- * @param secret - The preimage/secret (32-byte hex string, with or without 0x prefix).
19
- * @param swap - The swap response from the API.
20
- * @param chain - The target chain for the claim.
21
- * @returns A ClaimResult with the EVM claim data.
22
- */
23
- export function buildEthereumClaimData(id, secret, swap, chain) {
24
- const contractAddress = getEvmHtlcAddress(swap);
25
- if (!contractAddress) {
26
- return {
27
- success: false,
28
- message: "Could not find HTLC contract address in swap response.",
29
- chain,
30
- };
31
- }
32
- // Extract swap parameters needed for redeem()
33
- const params = getRedeemParams(swap);
34
- if (!params) {
35
- return {
36
- success: false,
37
- message: "Could not extract redeem parameters from swap response. Missing amount, token, sender, or timelock.",
38
- chain,
39
- };
40
- }
41
- // Normalize the secret - strip any double 0x prefix first
42
- let normalizedSecret = secret;
43
- while (normalizedSecret.startsWith("0x0x")) {
44
- normalizedSecret = normalizedSecret.slice(2);
45
- }
46
- normalizedSecret = normalizedSecret.startsWith("0x")
47
- ? normalizedSecret
48
- : `0x${normalizedSecret}`;
49
- // Encode the call data for redeem(bytes32,uint256,address,address,uint256)
50
- const callData = encodeRedeemCallData(normalizedSecret, params.amount, params.token, params.sender, params.timelock);
51
- return {
52
- success: true,
53
- message: `${chain.charAt(0).toUpperCase() + chain.slice(1)} claims require manual execution. Use the provided call data to submit the transaction.`,
54
- chain,
55
- ethereumClaimData: {
56
- contractAddress,
57
- callData,
58
- swapId: id, // Keep for reference (not used in contract)
59
- secret: normalizedSecret,
60
- functionSignature: "redeem(bytes32 preimage, uint256 amount, address token, address sender, uint256 timelock)",
61
- // Additional params for manual construction
62
- amount: params.amount,
63
- token: params.token,
64
- sender: params.sender,
65
- timelock: params.timelock,
66
- },
67
- };
68
- }
69
- /**
70
- * Extracts redeem parameters from a swap response.
71
- *
72
- * Note: Lightning-to-EVM and Arkade-to-EVM swaps use the gasless claim path
73
- * and don't go through this function.
74
- */
75
- function getRedeemParams(swap) {
76
- // BTC-to-EVM swaps (BtcToEvmSwapResponse) - legacy type
77
- if ("htlc_address_evm" in swap) {
78
- // These swaps use different field names - not supported for manual redeem
79
- return undefined;
80
- }
81
- // EVM swaps with the newer field structure
82
- // Check for the fields we need
83
- const evmSwap = swap;
84
- if (evmSwap.evm_expected_sats !== undefined &&
85
- evmSwap.wbtc_address &&
86
- evmSwap.server_evm_address &&
87
- evmSwap.evm_refund_locktime !== undefined) {
88
- return {
89
- amount: BigInt(evmSwap.evm_expected_sats),
90
- token: evmSwap.wbtc_address,
91
- sender: evmSwap.server_evm_address,
92
- timelock: BigInt(evmSwap.evm_refund_locktime),
93
- };
94
- }
95
- return undefined;
96
- }
97
- /**
98
- * Encodes call data for the redeem(bytes32,uint256,address,address,uint256) function.
99
- *
100
- * Function selector: keccak256("redeem(bytes32,uint256,address,address,uint256)")[0:4]
101
- *
102
- * @param preimage - The preimage/secret as a bytes32 hex string
103
- * @param amount - The token amount
104
- * @param token - The ERC20 token address
105
- * @param sender - The swap sender (server) address
106
- * @param timelock - The refund timelock
107
- * @returns The encoded call data as a hex string with 0x prefix
108
- */
109
- export function encodeRedeemCallData(preimage, amount, token, sender, timelock) {
110
- // Function selector for redeem(bytes32,uint256,address,address,uint256)
111
- // keccak256("redeem(bytes32,uint256,address,address,uint256)") = 0xb31597ad
112
- const selector = "0xb31597ad";
113
- // Normalize preimage to 32 bytes (64 hex chars)
114
- const normalizedPreimage = normalizeBytes32(preimage);
115
- // Encode amount as uint256 (32 bytes, left-padded)
116
- const encodedAmount = amount.toString(16).padStart(64, "0");
117
- // Encode addresses as 32 bytes (left-padded with zeros)
118
- const encodedToken = normalizeAddress(token);
119
- const encodedSender = normalizeAddress(sender);
120
- // Encode timelock as uint256 (32 bytes, left-padded)
121
- const encodedTimelock = timelock.toString(16).padStart(64, "0");
122
- return `${selector}${normalizedPreimage}${encodedAmount}${encodedToken}${encodedSender}${encodedTimelock}`;
123
- }
124
- /**
125
- * Encodes call data for the legacy claimSwap(bytes32,bytes32) function.
126
- * @deprecated Use encodeRedeemCallData instead for HTLCErc20 v2 contracts.
127
- */
128
- export function encodeClaimSwapCallData(swapId, secret) {
129
- // Function selector for claimSwap(bytes32,bytes32)
130
- // keccak256("claimSwap(bytes32,bytes32)") = 0x84cc315b...
131
- const selector = "0x84cc315b";
132
- // Normalize inputs - remove 0x prefix if present and ensure 64 chars (32 bytes)
133
- const normalizedSwapId = normalizeBytes32(swapId);
134
- const normalizedSecret = normalizeBytes32(secret);
135
- return `${selector}${normalizedSwapId}${normalizedSecret}`;
136
- }
137
- /**
138
- * Normalizes a hex string to a 32-byte (64 character) representation.
139
- * Left-pads with zeros (for secrets/hashes).
140
- *
141
- * @param input - Hex string
142
- * @returns 64-character hex string (without 0x prefix)
143
- */
144
- function normalizeBytes32(input) {
145
- // Remove 0x prefix if present
146
- let hex = input.startsWith("0x") ? input.slice(2) : input;
147
- // Pad to 64 characters (32 bytes) if needed - left pad for hashes
148
- if (hex.length < 64) {
149
- hex = hex.padStart(64, "0");
150
- }
151
- // Truncate if longer (shouldn't happen for valid inputs)
152
- if (hex.length > 64) {
153
- hex = hex.slice(0, 64);
154
- }
155
- return hex.toLowerCase();
156
- }
157
- /**
158
- * Normalizes an Ethereum address to a 32-byte (64 character) representation.
159
- * Left-pads with zeros (addresses are 20 bytes, need 12 bytes of padding).
160
- *
161
- * @param address - Ethereum address (with or without 0x prefix)
162
- * @returns 64-character hex string (without 0x prefix)
163
- */
164
- function normalizeAddress(address) {
165
- // Remove 0x prefix if present
166
- const hex = address.startsWith("0x") ? address.slice(2) : address;
167
- // Addresses are 20 bytes (40 hex chars), pad to 32 bytes (64 hex chars)
168
- return hex.padStart(64, "0").toLowerCase();
169
- }
170
- /**
171
- * Converts a UUID to a bytes32 hex string.
172
- * Removes dashes and right-pads with zeros to make 32 bytes.
173
- *
174
- * @param uuid - UUID string (e.g., "550e8400-e29b-41d4-a716-446655440000")
175
- * @returns 64-character hex string (without 0x prefix)
176
- */
177
- export function uuidToBytes32(uuid) {
178
- // Remove dashes and 0x prefix if present
179
- let hex = uuid.replace(/-/g, "");
180
- if (hex.startsWith("0x")) {
181
- hex = hex.slice(2);
182
- }
183
- // Right-pad to 64 characters (32 bytes)
184
- if (hex.length < 64) {
185
- hex = hex.padEnd(64, "0");
186
- }
187
- // Truncate if longer (shouldn't happen for valid UUIDs)
188
- if (hex.length > 64) {
189
- hex = hex.slice(0, 64);
190
- }
191
- return hex.toLowerCase();
192
- }
193
- /**
194
- * Gets the EVM HTLC contract address from a swap response.
195
- *
196
- * @param swap - The swap response
197
- * @returns The HTLC contract address or undefined if not found
198
- */
199
- function getEvmHtlcAddress(swap) {
200
- // Other EVM swap types use evm_htlc_address
201
- if ("evm_htlc_address" in swap) {
202
- return swap.evm_htlc_address;
203
- }
204
- return undefined;
205
- }
206
- //# sourceMappingURL=ethereum.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../../../src/redeem/ethereum.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,sBAAsB,CACpC,EAAU,EACV,MAAc,EACd,IAAqB,EACrB,KAA0C;IAE1C,MAAM,eAAe,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,wDAAwD;YACjE,KAAK;SACN,CAAC;IACJ,CAAC;IAED,8CAA8C;IAC9C,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EACL,qGAAqG;YACvG,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IACxC,yCAAyC;IACzC,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACjC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IAED,wCAAwC;IACxC,IAAI,GAAG,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACpB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,wDAAwD;IACxD,IAAI,GAAG,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACpB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,IAAqB;IAC9C,4CAA4C;IAC5C,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;QAC/B,OAAQ,IAAqC,CAAC,gBAAgB,CAAC;IACjE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -1,41 +0,0 @@
1
- /**
2
- * Gasless claim logic.
3
- *
4
- * Claims are submitted via the server's claim-gasless endpoint which
5
- * uses the HTLCCoordinator contract for gasless execution.
6
- */
7
- import type { ArkadeToEvmSwapResponse, LightningToEvmSwapResponse } from "../api/client.js";
8
- import type { ClaimGaslessResult } from "./types.js";
9
- /** Swap types that support gasless claiming */
10
- export type GaslessSwapResponse = ArkadeToEvmSwapResponse | LightningToEvmSwapResponse;
11
- /** Parameters for a gasless claim */
12
- export interface GaslessClaimParams {
13
- /** Base URL for the API (e.g. "https://api.lendaswap.com") */
14
- baseUrl: string;
15
- /** The swap preimage/secret (hex, with or without 0x prefix) */
16
- preimage: string;
17
- /** The secret key for EVM signing (raw bytes) */
18
- secretKey: Uint8Array;
19
- /** The swap data from the server */
20
- swap: GaslessSwapResponse;
21
- /** The EVM address where tokens should be sent */
22
- destination: string;
23
- /** Pre-fetched DEX calldata (for non-WBTC targets) */
24
- dexCalldata?: {
25
- to: string;
26
- data: string;
27
- value: string;
28
- };
29
- }
30
- /**
31
- * Claims an Arkade-to-EVM swap gaslessly via the server.
32
- *
33
- * Builds the EIP-712 digest, signs it with the provided secret key,
34
- * and sends the signature + secret to the server. The server submits
35
- * the `coordinator.redeemAndExecute` transaction.
36
- *
37
- * @param params - All data needed for the gasless claim.
38
- * @returns The gasless claim result with transaction hash.
39
- */
40
- export declare function claimViaGasless(params: GaslessClaimParams): Promise<ClaimGaslessResult>;
41
- //# sourceMappingURL=gasless.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gasless.d.ts","sourceRoot":"","sources":["../../../src/redeem/gasless.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,+CAA+C;AAC/C,MAAM,MAAM,mBAAmB,GAC3B,uBAAuB,GACvB,0BAA0B,CAAC;AAE/B,qCAAqC;AACrC,MAAM,WAAW,kBAAkB;IACjC,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,SAAS,EAAE,UAAU,CAAC;IACtB,oCAAoC;IACpC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,WAAW,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3D;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAgE7B"}
@@ -1,71 +0,0 @@
1
- /**
2
- * Gasless claim logic.
3
- *
4
- * Claims are submitted via the server's claim-gasless endpoint which
5
- * uses the HTLCCoordinator contract for gasless execution.
6
- */
7
- import { buildRedeemDigest, signEvmDigest } from "../evm";
8
- /**
9
- * Claims an Arkade-to-EVM swap gaslessly via the server.
10
- *
11
- * Builds the EIP-712 digest, signs it with the provided secret key,
12
- * and sends the signature + secret to the server. The server submits
13
- * the `coordinator.redeemAndExecute` transaction.
14
- *
15
- * @param params - All data needed for the gasless claim.
16
- * @returns The gasless claim result with transaction hash.
17
- */
18
- export async function claimViaGasless(params) {
19
- const { baseUrl, preimage, secretKey, swap, destination, dexCalldata } = params;
20
- const secretHex = preimage.startsWith("0x") ? preimage : `0x${preimage}`;
21
- const wbtcAddress = swap.wbtc_address;
22
- const amount = BigInt(swap.evm_expected_sats);
23
- // target_token.token_id contains the ERC-20 contract address for the final token
24
- const targetTokenAddress = String(swap.target_token.token_id);
25
- // Check if target token differs from WBTC (meaning a DEX swap is needed)
26
- const needsDexSwap = targetTokenAddress.toLowerCase() !== wbtcAddress.toLowerCase();
27
- // sweepToken: if there's a DEX swap, sweep the target token; otherwise sweep WBTC
28
- const sweepToken = needsDexSwap ? targetTokenAddress : wbtcAddress;
29
- // Build EIP-712 digest
30
- const digest = buildRedeemDigest({
31
- htlcAddress: swap.evm_htlc_address,
32
- chainId: swap.evm_chain_id,
33
- preimage: secretHex,
34
- amount,
35
- token: wbtcAddress,
36
- sender: swap.server_evm_address,
37
- timelock: swap.evm_refund_locktime,
38
- caller: swap.evm_coordinator_address,
39
- destination,
40
- sweepToken,
41
- // TODO: this is the slippage protection. I guess it shouldn't be 0
42
- minAmountOut: 0n,
43
- });
44
- // Sign with the swap's internally derived EVM key
45
- const sig = signEvmDigest(secretKey, digest);
46
- // Send to server with DEX calldata if applicable
47
- const response = await fetch(`${baseUrl}/swap/${swap.id}/claim-gasless`, {
48
- method: "POST",
49
- headers: { "Content-Type": "application/json" },
50
- body: JSON.stringify({
51
- secret: secretHex,
52
- destination,
53
- v: sig.v,
54
- r: sig.r,
55
- s: sig.s,
56
- dex_calldata: needsDexSwap ? dexCalldata : undefined,
57
- }),
58
- });
59
- if (!response.ok) {
60
- const errorText = await response.text();
61
- throw new Error(`Gasless claim failed (${response.status}): ${errorText}`);
62
- }
63
- const result = await response.json();
64
- return {
65
- id: result.id,
66
- status: result.status,
67
- txHash: result.tx_hash,
68
- message: result.message,
69
- };
70
- }
71
- //# sourceMappingURL=gasless.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gasless.js","sourceRoot":"","sources":["../../../src/redeem/gasless.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAwB1D;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAA0B;IAE1B,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,GACpE,MAAM,CAAC;IAET,MAAM,SAAS,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;IAEzE,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAE9C,iFAAiF;IACjF,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAE9D,yEAAyE;IACzE,MAAM,YAAY,GAChB,kBAAkB,CAAC,WAAW,EAAE,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC;IAEjE,kFAAkF;IAClF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