@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.
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +4 -1
- package/dist/api/client.js.map +1 -1
- package/dist/version.d.ts +4 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +4 -1
- package/dist/price-feed.d.ts +0 -124
- package/dist/price-feed.d.ts.map +0 -1
- package/dist/price-feed.js +0 -178
- package/dist/price-feed.js.map +0 -1
- package/dist/src/api/client.d.ts +0 -31
- package/dist/src/api/client.d.ts.map +0 -1
- package/dist/src/api/client.js +0 -12
- package/dist/src/api/client.js.map +0 -1
- package/dist/src/arkade.d.ts +0 -36
- package/dist/src/arkade.d.ts.map +0 -1
- package/dist/src/arkade.js +0 -68
- package/dist/src/arkade.js.map +0 -1
- package/dist/src/client.d.ts +0 -760
- package/dist/src/client.d.ts.map +0 -1
- package/dist/src/client.js +0 -2169
- package/dist/src/client.js.map +0 -1
- package/dist/src/create/arkade.d.ts +0 -34
- package/dist/src/create/arkade.d.ts.map +0 -1
- package/dist/src/create/arkade.js +0 -76
- package/dist/src/create/arkade.js.map +0 -1
- package/dist/src/create/bitcoin-to-arkade.d.ts +0 -36
- package/dist/src/create/bitcoin-to-arkade.d.ts.map +0 -1
- package/dist/src/create/bitcoin-to-arkade.js +0 -69
- package/dist/src/create/bitcoin-to-arkade.js.map +0 -1
- package/dist/src/create/bitcoin.d.ts +0 -31
- package/dist/src/create/bitcoin.d.ts.map +0 -1
- package/dist/src/create/bitcoin.js +0 -67
- package/dist/src/create/bitcoin.js.map +0 -1
- package/dist/src/create/evm-to-arkade.d.ts +0 -34
- package/dist/src/create/evm-to-arkade.d.ts.map +0 -1
- package/dist/src/create/evm-to-arkade.js +0 -69
- package/dist/src/create/evm-to-arkade.js.map +0 -1
- package/dist/src/create/evm-to-bitcoin.d.ts +0 -35
- package/dist/src/create/evm-to-bitcoin.d.ts.map +0 -1
- package/dist/src/create/evm-to-bitcoin.js +0 -71
- package/dist/src/create/evm-to-bitcoin.js.map +0 -1
- package/dist/src/create/evm-to-lightning.d.ts +0 -34
- package/dist/src/create/evm-to-lightning.d.ts.map +0 -1
- package/dist/src/create/evm-to-lightning.js +0 -66
- package/dist/src/create/evm-to-lightning.js.map +0 -1
- package/dist/src/create/index.d.ts +0 -19
- package/dist/src/create/index.d.ts.map +0 -1
- package/dist/src/create/index.js +0 -18
- package/dist/src/create/index.js.map +0 -1
- package/dist/src/create/lightning.d.ts +0 -31
- package/dist/src/create/lightning.d.ts.map +0 -1
- package/dist/src/create/lightning.js +0 -72
- package/dist/src/create/lightning.js.map +0 -1
- package/dist/src/create/types.d.ts +0 -247
- package/dist/src/create/types.d.ts.map +0 -1
- package/dist/src/create/types.js +0 -5
- package/dist/src/create/types.js.map +0 -1
- package/dist/src/delegate.d.ts +0 -62
- package/dist/src/delegate.d.ts.map +0 -1
- package/dist/src/delegate.js +0 -284
- package/dist/src/delegate.js.map +0 -1
- package/dist/src/esplora.d.ts +0 -41
- package/dist/src/esplora.d.ts.map +0 -1
- package/dist/src/esplora.js +0 -47
- package/dist/src/esplora.js.map +0 -1
- package/dist/src/evm/coordinator.d.ts +0 -247
- package/dist/src/evm/coordinator.d.ts.map +0 -1
- package/dist/src/evm/coordinator.js +0 -414
- package/dist/src/evm/coordinator.js.map +0 -1
- package/dist/src/evm/htlc.d.ts +0 -238
- package/dist/src/evm/htlc.d.ts.map +0 -1
- package/dist/src/evm/htlc.js +0 -278
- package/dist/src/evm/htlc.js.map +0 -1
- package/dist/src/evm/index.d.ts +0 -9
- package/dist/src/evm/index.d.ts.map +0 -1
- package/dist/src/evm/index.js +0 -9
- package/dist/src/evm/index.js.map +0 -1
- package/dist/src/evm/signing.d.ts +0 -30
- package/dist/src/evm/signing.d.ts.map +0 -1
- package/dist/src/evm/signing.js +0 -91
- package/dist/src/evm/signing.js.map +0 -1
- package/dist/src/generated/api.d.ts +0 -2736
- package/dist/src/generated/api.d.ts.map +0 -1
- package/dist/src/generated/api.js +0 -6
- package/dist/src/generated/api.js.map +0 -1
- package/dist/src/index.d.ts +0 -18
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -24
- package/dist/src/index.js.map +0 -1
- package/dist/src/node.d.ts +0 -19
- package/dist/src/node.d.ts.map +0 -1
- package/dist/src/node.js +0 -19
- package/dist/src/node.js.map +0 -1
- package/dist/src/price-calculations.d.ts +0 -109
- package/dist/src/price-calculations.d.ts.map +0 -1
- package/dist/src/price-calculations.js +0 -135
- package/dist/src/price-calculations.js.map +0 -1
- package/dist/src/redeem/arkade.d.ts +0 -65
- package/dist/src/redeem/arkade.d.ts.map +0 -1
- package/dist/src/redeem/arkade.js +0 -217
- package/dist/src/redeem/arkade.js.map +0 -1
- package/dist/src/redeem/ethereum.d.ts +0 -52
- package/dist/src/redeem/ethereum.d.ts.map +0 -1
- package/dist/src/redeem/ethereum.js +0 -206
- package/dist/src/redeem/ethereum.js.map +0 -1
- package/dist/src/redeem/gasless.d.ts +0 -41
- package/dist/src/redeem/gasless.d.ts.map +0 -1
- package/dist/src/redeem/gasless.js +0 -71
- package/dist/src/redeem/gasless.js.map +0 -1
- package/dist/src/redeem/index.d.ts +0 -49
- package/dist/src/redeem/index.d.ts.map +0 -1
- package/dist/src/redeem/index.js +0 -189
- package/dist/src/redeem/index.js.map +0 -1
- package/dist/src/redeem/types.d.ts +0 -126
- package/dist/src/redeem/types.d.ts.map +0 -1
- package/dist/src/redeem/types.js +0 -36
- package/dist/src/redeem/types.js.map +0 -1
- package/dist/src/refund/arkade.d.ts +0 -62
- package/dist/src/refund/arkade.d.ts.map +0 -1
- package/dist/src/refund/arkade.js +0 -212
- package/dist/src/refund/arkade.js.map +0 -1
- package/dist/src/refund/index.d.ts +0 -10
- package/dist/src/refund/index.d.ts.map +0 -1
- package/dist/src/refund/index.js +0 -10
- package/dist/src/refund/index.js.map +0 -1
- package/dist/src/refund/onchain.d.ts +0 -137
- package/dist/src/refund/onchain.d.ts.map +0 -1
- package/dist/src/refund/onchain.js +0 -366
- package/dist/src/refund/onchain.js.map +0 -1
- package/dist/src/signer/index.d.ts +0 -106
- package/dist/src/signer/index.d.ts.map +0 -1
- package/dist/src/signer/index.js +0 -179
- package/dist/src/signer/index.js.map +0 -1
- package/dist/src/storage/idb.d.ts +0 -70
- package/dist/src/storage/idb.d.ts.map +0 -1
- package/dist/src/storage/idb.js +0 -236
- package/dist/src/storage/idb.js.map +0 -1
- package/dist/src/storage/index.d.ts +0 -152
- package/dist/src/storage/index.d.ts.map +0 -1
- package/dist/src/storage/index.js +0 -98
- package/dist/src/storage/index.js.map +0 -1
- package/dist/src/storage/sqlite.d.ts +0 -95
- package/dist/src/storage/sqlite.d.ts.map +0 -1
- package/dist/src/storage/sqlite.js +0 -206
- package/dist/src/storage/sqlite.js.map +0 -1
- package/dist/src/storage/types.d.ts +0 -57
- package/dist/src/storage/types.d.ts.map +0 -1
- package/dist/src/storage/types.js +0 -9
- package/dist/src/storage/types.js.map +0 -1
- package/dist/src/tokens.d.ts +0 -29
- package/dist/src/tokens.d.ts.map +0 -1
- package/dist/src/tokens.js +0 -89
- package/dist/src/tokens.js.map +0 -1
- package/dist/src/usd-price.d.ts +0 -34
- package/dist/src/usd-price.d.ts.map +0 -1
- package/dist/src/usd-price.js +0 -83
- package/dist/src/usd-price.js.map +0 -1
- package/dist/tests/api-client.test.d.ts +0 -2
- package/dist/tests/api-client.test.d.ts.map +0 -1
- package/dist/tests/api-client.test.js +0 -86
- package/dist/tests/api-client.test.js.map +0 -1
- package/dist/tests/client.test.d.ts +0 -2
- package/dist/tests/client.test.d.ts.map +0 -1
- package/dist/tests/client.test.js +0 -150
- package/dist/tests/client.test.js.map +0 -1
- package/dist/tests/index.test.d.ts +0 -2
- package/dist/tests/index.test.d.ts.map +0 -1
- package/dist/tests/index.test.js +0 -8
- package/dist/tests/index.test.js.map +0 -1
- package/dist/tests/onchain-refund.test.d.ts +0 -2
- package/dist/tests/onchain-refund.test.d.ts.map +0 -1
- package/dist/tests/onchain-refund.test.js +0 -279
- package/dist/tests/onchain-refund.test.js.map +0 -1
- package/dist/tests/signer.test.d.ts +0 -2
- package/dist/tests/signer.test.d.ts.map +0 -1
- package/dist/tests/signer.test.js +0 -92
- package/dist/tests/signer.test.js.map +0 -1
- package/dist/tests/sqlite-storage.test.d.ts +0 -2
- package/dist/tests/sqlite-storage.test.d.ts.map +0 -1
- package/dist/tests/sqlite-storage.test.js +0 -160
- package/dist/tests/sqlite-storage.test.js.map +0 -1
- package/dist/tests/storage.test.d.ts +0 -2
- package/dist/tests/storage.test.d.ts.map +0 -1
- package/dist/tests/storage.test.js +0 -184
- package/dist/tests/storage.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/usdt0-bridge/bridge.d.ts +0 -82
- package/dist/usdt0-bridge/bridge.d.ts.map +0 -1
- package/dist/usdt0-bridge/bridge.js +0 -56
- package/dist/usdt0-bridge/bridge.js.map +0 -1
- package/dist/usdt0-bridge/chains.d.ts +0 -41
- package/dist/usdt0-bridge/chains.d.ts.map +0 -1
- package/dist/usdt0-bridge/chains.js +0 -117
- package/dist/usdt0-bridge/chains.js.map +0 -1
- package/dist/usdt0-bridge/layerzero-tracker.d.ts +0 -34
- package/dist/usdt0-bridge/layerzero-tracker.d.ts.map +0 -1
- package/dist/usdt0-bridge/layerzero-tracker.js +0 -86
- package/dist/usdt0-bridge/layerzero-tracker.js.map +0 -1
- package/dist/usdt0-bridge/oft-abi.d.ts +0 -145
- package/dist/usdt0-bridge/oft-abi.d.ts.map +0 -1
- package/dist/usdt0-bridge/oft-abi.js +0 -117
- package/dist/usdt0-bridge/oft-abi.js.map +0 -1
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Redeem module for Lendaswap swaps.
|
|
3
|
-
*
|
|
4
|
-
* Provides redeem/claim logic for completing swaps:
|
|
5
|
-
* - Server-side gasless claims for Arkade/Lightning-to-EVM swaps
|
|
6
|
-
* - Manual claiming with call data for other EVM swaps
|
|
7
|
-
* - Arkade VHTLC claiming for EVM-to-Arkade swaps
|
|
8
|
-
* - Coordinator redeemAndExecute for Arkade-to-EVM swaps
|
|
9
|
-
*/
|
|
10
|
-
import { type ClaimResult, type RedeemContext } from "./types.js";
|
|
11
|
-
export { type ArkadeClaimParams, type ArkadeClaimResult, buildArkadeClaim, } from "./arkade.js";
|
|
12
|
-
export { encodeClaimSwapCallData, uuidToBytes32 } from "./ethereum.js";
|
|
13
|
-
export { claimViaGasless, type GaslessClaimParams } from "./gasless.js";
|
|
14
|
-
export type { ArkadeClaimData, ClaimChain, ClaimGaslessResult, ClaimResult, CoordinatorClaimData, EthereumClaimData, RedeemContext, } from "./types.js";
|
|
15
|
-
export { getChainFromTokenId } from "./types.js";
|
|
16
|
-
/**
|
|
17
|
-
* Claims a swap by revealing the preimage.
|
|
18
|
-
*
|
|
19
|
-
* The claim method depends on the swap direction and target chain:
|
|
20
|
-
* - **Arkade/Lightning-to-EVM**: Server-side gasless claim via coordinator
|
|
21
|
-
* - **Other EVM swaps**: Returns call data for manual claiming
|
|
22
|
-
* - **Arkade**: Returns data needed for `buildArkadeClaim()`
|
|
23
|
-
*
|
|
24
|
-
* @param id - The UUID of the swap.
|
|
25
|
-
* @param secret - The preimage/secret (32-byte hex string, with or without 0x prefix).
|
|
26
|
-
* @param ctx - The context containing the API client and getSwap function.
|
|
27
|
-
* @param destination - (Optional) EVM address for receiving tokens. Required for Arkade-to-EVM
|
|
28
|
-
* swaps to fetch fresh DEX calldata.
|
|
29
|
-
* @returns A ClaimResult with the outcome.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```ts
|
|
33
|
-
* const result = await claim(swapId, storedSwap.preimage, ctx, "0x1234...");
|
|
34
|
-
* if (result.success) {
|
|
35
|
-
* if (result.coordinatorClaimData) {
|
|
36
|
-
* // Arkade/Lightning-to-EVM: gasless claim via server
|
|
37
|
-
* console.log("TX Hash:", result.txHash);
|
|
38
|
-
* } else if (result.chain === "arkade") {
|
|
39
|
-
* // Arkade claim needs user's keys
|
|
40
|
-
* await buildArkadeClaim({ ...result.arkadeClaimData, ... });
|
|
41
|
-
* } else {
|
|
42
|
-
* // Manual EVM claim
|
|
43
|
-
* console.log("Call data:", result.ethereumClaimData?.callData);
|
|
44
|
-
* }
|
|
45
|
-
* }
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export declare function claim(id: string, secret: string, ctx: RedeemContext, destination?: string): Promise<ClaimResult>;
|
|
49
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/redeem/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAEL,KAAK,WAAW,EAIhB,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAExE,YAAY,EACV,eAAe,EACf,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,KAAK,CACzB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,aAAa,EAClB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,WAAW,CAAC,CAkDtB"}
|
package/dist/src/redeem/index.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Redeem module for Lendaswap swaps.
|
|
3
|
-
*
|
|
4
|
-
* Provides redeem/claim logic for completing swaps:
|
|
5
|
-
* - Server-side gasless claims for Arkade/Lightning-to-EVM swaps
|
|
6
|
-
* - Manual claiming with call data for other EVM swaps
|
|
7
|
-
* - Arkade VHTLC claiming for EVM-to-Arkade swaps
|
|
8
|
-
* - Coordinator redeemAndExecute for Arkade-to-EVM swaps
|
|
9
|
-
*/
|
|
10
|
-
import { buildEthereumClaimData } from "./ethereum.js";
|
|
11
|
-
import { getChainFromTokenId, getClaimChainFromChainName, } from "./types.js";
|
|
12
|
-
// Re-export Arkade claim
|
|
13
|
-
export { buildArkadeClaim, } from "./arkade.js";
|
|
14
|
-
// Re-export utilities from ethereum module
|
|
15
|
-
export { encodeClaimSwapCallData, uuidToBytes32 } from "./ethereum.js";
|
|
16
|
-
// Re-export gasless claim
|
|
17
|
-
export { claimViaGasless } from "./gasless.js";
|
|
18
|
-
export { getChainFromTokenId } from "./types.js";
|
|
19
|
-
/**
|
|
20
|
-
* Claims a swap by revealing the preimage.
|
|
21
|
-
*
|
|
22
|
-
* The claim method depends on the swap direction and target chain:
|
|
23
|
-
* - **Arkade/Lightning-to-EVM**: Server-side gasless claim via coordinator
|
|
24
|
-
* - **Other EVM swaps**: Returns call data for manual claiming
|
|
25
|
-
* - **Arkade**: Returns data needed for `buildArkadeClaim()`
|
|
26
|
-
*
|
|
27
|
-
* @param id - The UUID of the swap.
|
|
28
|
-
* @param secret - The preimage/secret (32-byte hex string, with or without 0x prefix).
|
|
29
|
-
* @param ctx - The context containing the API client and getSwap function.
|
|
30
|
-
* @param destination - (Optional) EVM address for receiving tokens. Required for Arkade-to-EVM
|
|
31
|
-
* swaps to fetch fresh DEX calldata.
|
|
32
|
-
* @returns A ClaimResult with the outcome.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* const result = await claim(swapId, storedSwap.preimage, ctx, "0x1234...");
|
|
37
|
-
* if (result.success) {
|
|
38
|
-
* if (result.coordinatorClaimData) {
|
|
39
|
-
* // Arkade/Lightning-to-EVM: gasless claim via server
|
|
40
|
-
* console.log("TX Hash:", result.txHash);
|
|
41
|
-
* } else if (result.chain === "arkade") {
|
|
42
|
-
* // Arkade claim needs user's keys
|
|
43
|
-
* await buildArkadeClaim({ ...result.arkadeClaimData, ... });
|
|
44
|
-
* } else {
|
|
45
|
-
* // Manual EVM claim
|
|
46
|
-
* console.log("Call data:", result.ethereumClaimData?.callData);
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export async function claim(id, secret, ctx, destination) {
|
|
52
|
-
// Get the swap to determine target chain
|
|
53
|
-
const swap = await ctx.getSwap(id);
|
|
54
|
-
// Check if this is an arkade_to_evm swap (uses coordinator redeemAndExecute)
|
|
55
|
-
if ("direction" in swap && swap.direction === "arkade_to_evm") {
|
|
56
|
-
return buildCoordinatorClaimData(id, swap, ctx, destination);
|
|
57
|
-
}
|
|
58
|
-
// target_token may be a string (TokenId) or object (TokenInfo with chain + token_id)
|
|
59
|
-
const chain = typeof swap.target_token === "object" &&
|
|
60
|
-
swap.target_token !== null &&
|
|
61
|
-
"chain" in swap.target_token
|
|
62
|
-
? getClaimChainFromChainName(swap.target_token.chain)
|
|
63
|
-
: getChainFromTokenId(swap.target_token);
|
|
64
|
-
if (!chain) {
|
|
65
|
-
return {
|
|
66
|
-
success: false,
|
|
67
|
-
message: `Unknown target chain for token: ${JSON.stringify(swap.target_token)}. Cannot determine claim method.`,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
// Arkade claims return data for manual execution with user's keys
|
|
71
|
-
if (chain === "arkade") {
|
|
72
|
-
// For EVM-to-Arkade swaps, we need specific fields from the swap
|
|
73
|
-
// @ts-expect-error
|
|
74
|
-
const arkadeSwap = swap;
|
|
75
|
-
return buildArkadeClaimData(arkadeSwap);
|
|
76
|
-
}
|
|
77
|
-
// EVM claims (Ethereum, Polygon, Arbitrum) return data for manual execution
|
|
78
|
-
return buildEthereumClaimData(id, secret, swap, chain);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Builds the claim data for an Arkade-to-EVM swap (coordinator redeemAndExecute).
|
|
82
|
-
*
|
|
83
|
-
* The user must:
|
|
84
|
-
* 1. Build the EIP-712 digest using `buildRedeemDigest()` from `evm/coordinator`
|
|
85
|
-
* 2. Sign the digest with their EVM wallet
|
|
86
|
-
* 3. Build the transaction using `encodeRedeemAndExecute()`
|
|
87
|
-
* 4. Submit the transaction to the coordinator contract
|
|
88
|
-
*
|
|
89
|
-
* @param id - The swap ID
|
|
90
|
-
* @param swap - The swap response
|
|
91
|
-
* @param ctx - The redeem context with API client
|
|
92
|
-
* @param destination - Optional EVM address for receiving tokens. If provided and the swap
|
|
93
|
-
* involves a DEX swap (target != WBTC), fresh calldata is fetched.
|
|
94
|
-
*/
|
|
95
|
-
async function buildCoordinatorClaimData(id, swap, ctx, destination) {
|
|
96
|
-
// WBTC address from server response, fall back to well-known addresses
|
|
97
|
-
const WBTC_BY_CHAIN_ID = {
|
|
98
|
-
137: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6", // Polygon
|
|
99
|
-
1: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", // Ethereum
|
|
100
|
-
42161: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f", // Arbitrum
|
|
101
|
-
};
|
|
102
|
-
const wbtcAddress = swap.wbtc_address ?? WBTC_BY_CHAIN_ID[swap.evm_chain_id];
|
|
103
|
-
if (!wbtcAddress) {
|
|
104
|
-
return {
|
|
105
|
-
success: false,
|
|
106
|
-
message: `Cannot determine WBTC address for chain ID ${swap.evm_chain_id}`,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
// target_token.token_id contains the ERC-20 contract address for the final token
|
|
110
|
-
const targetTokenAddress = String(swap.target_token.token_id);
|
|
111
|
-
// Check if this swap involves a DEX swap (target token is different from WBTC)
|
|
112
|
-
const needsDexSwap = targetTokenAddress.toLowerCase() !== wbtcAddress.toLowerCase();
|
|
113
|
-
let dexCallData;
|
|
114
|
-
// Fetch fresh DEX calldata if destination is provided and swap needs DEX
|
|
115
|
-
if (destination && needsDexSwap) {
|
|
116
|
-
const response = await ctx.apiClient.GET("/swap/{id}/redeem-and-swap-calldata", {
|
|
117
|
-
params: {
|
|
118
|
-
path: { id },
|
|
119
|
-
query: { destination },
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
if (response.error) {
|
|
123
|
-
return {
|
|
124
|
-
success: false,
|
|
125
|
-
message: `Failed to fetch DEX calldata: ${response.error.error || "Unknown error"}`,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
if (response.data) {
|
|
129
|
-
dexCallData = {
|
|
130
|
-
to: response.data.dex_calldata.to,
|
|
131
|
-
data: response.data.dex_calldata.data,
|
|
132
|
-
value: response.data.dex_calldata.value,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
const coordinatorClaimData = {
|
|
137
|
-
htlcAddress: swap.evm_htlc_address,
|
|
138
|
-
coordinatorAddress: swap.evm_coordinator_address,
|
|
139
|
-
chainId: swap.evm_chain_id,
|
|
140
|
-
amount: swap.evm_expected_sats,
|
|
141
|
-
wbtcAddress,
|
|
142
|
-
sender: swap.server_evm_address,
|
|
143
|
-
timelock: swap.evm_refund_locktime,
|
|
144
|
-
dexCallData,
|
|
145
|
-
targetTokenAddress,
|
|
146
|
-
network: swap.network,
|
|
147
|
-
};
|
|
148
|
-
const message = destination
|
|
149
|
-
? "Arkade-to-EVM claims require EIP-712 signing. Use buildRedeemDigest() and encodeRedeemAndExecute() with the provided data."
|
|
150
|
-
: "Arkade-to-EVM claims require EIP-712 signing. Note: No destination provided - call claim() again with your EVM address to fetch fresh DEX calldata.";
|
|
151
|
-
return {
|
|
152
|
-
success: true,
|
|
153
|
-
message,
|
|
154
|
-
coordinatorClaimData,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Builds the claim data for an Arkade swap (EVM-to-Arkade direction).
|
|
159
|
-
*
|
|
160
|
-
* For Arkade claims, the user needs to call `buildArkadeClaim` with their
|
|
161
|
-
* secret key and destination address. This function extracts the necessary
|
|
162
|
-
* parameters from the swap response.
|
|
163
|
-
*/
|
|
164
|
-
function buildArkadeClaimData(swap) {
|
|
165
|
-
if (!swap.htlc_address_arkade) {
|
|
166
|
-
return {
|
|
167
|
-
success: false,
|
|
168
|
-
message: "Swap does not have an Arkade HTLC address.",
|
|
169
|
-
chain: "arkade",
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
const arkadeClaimData = {
|
|
173
|
-
lendaswapPubKey: swap.sender_pk,
|
|
174
|
-
arkadeServerPubKey: swap.server_pk,
|
|
175
|
-
vhtlcAddress: swap.htlc_address_arkade,
|
|
176
|
-
refundLocktime: swap.vhtlc_refund_locktime ?? 0,
|
|
177
|
-
unilateralClaimDelay: swap.unilateral_claim_delay ?? 0,
|
|
178
|
-
unilateralRefundDelay: swap.unilateral_refund_delay ?? 0,
|
|
179
|
-
unilateralRefundWithoutReceiverDelay: swap.unilateral_refund_without_receiver_delay ?? 0,
|
|
180
|
-
network: swap.network,
|
|
181
|
-
};
|
|
182
|
-
return {
|
|
183
|
-
success: true,
|
|
184
|
-
message: "Arkade claims require your secret key. Use buildArkadeClaim() with the provided data.",
|
|
185
|
-
chain: "arkade",
|
|
186
|
-
arkadeClaimData,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/redeem/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,sB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C;IAED,MAAM,eAAe,GAAoB;QACvC,eAAe,EAAE,IAAI,CAAC,SAAS;QAC/B,kBAAkB,EAAE,IAAI,CAAC,SAAS;QAClC,YAAY,EAAE,IAAI,CAAC,mBAAmB;QACtC,cAAc,EAAE,IAAI,CAAC,qBAAqB,IAAI,CAAC;QAC/C,oBAAoB,EAAE,IAAI,CAAC,sBAAsB,IAAI,CAAC;QACtD,qBAAqB,EAAE,IAAI,CAAC,uBAAuB,IAAI,CAAC;QACxD,oCAAoC,EAClC,IAAI,CAAC,wCAAwC,IAAI,CAAC;QACpD,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EACL,uFAAuF;QACzF,KAAK,EAAE,QAAQ;QACf,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types for redeem/claim operations.
|
|
3
|
-
*/
|
|
4
|
-
import type { ApiClient, GetSwapResponse } from "../api/client.js";
|
|
5
|
-
/** Supported chains for claiming */
|
|
6
|
-
export type ClaimChain = "polygon" | "arbitrum" | "ethereum" | "arkade";
|
|
7
|
-
/** Data needed for manual Ethereum claims */
|
|
8
|
-
export interface EthereumClaimData {
|
|
9
|
-
/** The HTLC contract address */
|
|
10
|
-
contractAddress: string;
|
|
11
|
-
/** The encoded call data for redeem() */
|
|
12
|
-
callData: string;
|
|
13
|
-
/** The swap ID (UUID, for reference only - not used in contract call) */
|
|
14
|
-
swapId: string;
|
|
15
|
-
/** The secret/preimage (bytes32) */
|
|
16
|
-
secret: string;
|
|
17
|
-
/** Human-readable function signature */
|
|
18
|
-
functionSignature: string;
|
|
19
|
-
/** Token amount locked in HTLC (for manual claim construction) */
|
|
20
|
-
amount?: bigint;
|
|
21
|
-
/** ERC20 token address (for manual claim construction) */
|
|
22
|
-
token?: string;
|
|
23
|
-
/** Sender address who created the HTLC (for manual claim construction) */
|
|
24
|
-
sender?: string;
|
|
25
|
-
/** Refund timelock timestamp (for manual claim construction) */
|
|
26
|
-
timelock?: bigint;
|
|
27
|
-
}
|
|
28
|
-
/** Data needed for Arkade-to-EVM coordinator claims (redeemAndExecute) */
|
|
29
|
-
export interface CoordinatorClaimData {
|
|
30
|
-
/** HTLCErc20 contract address (for EIP-712 domain) */
|
|
31
|
-
htlcAddress: string;
|
|
32
|
-
/** HTLCCoordinator contract address (target for redeemAndExecute) */
|
|
33
|
-
coordinatorAddress: string;
|
|
34
|
-
/** EVM chain ID */
|
|
35
|
-
chainId: number;
|
|
36
|
-
/** WBTC amount locked in the HTLC (evm_expected_sats) */
|
|
37
|
-
amount: number;
|
|
38
|
-
/** WBTC token address (derived from chain config or response) */
|
|
39
|
-
wbtcAddress: string;
|
|
40
|
-
/** HTLC sender (server's EVM address) */
|
|
41
|
-
sender: string;
|
|
42
|
-
/** EVM refund locktime (unix timestamp) */
|
|
43
|
-
timelock: number;
|
|
44
|
-
/** DEX swap calldata (null for WBTC-to-WBTC swaps) */
|
|
45
|
-
dexCallData?: {
|
|
46
|
-
to: string;
|
|
47
|
-
data: string;
|
|
48
|
-
value: string;
|
|
49
|
-
} | null;
|
|
50
|
-
/** Target token address (for sweepToken) */
|
|
51
|
-
targetTokenAddress: string;
|
|
52
|
-
/** Bitcoin network */
|
|
53
|
-
network: string;
|
|
54
|
-
}
|
|
55
|
-
/** Data needed for Arkade VHTLC claims */
|
|
56
|
-
export interface ArkadeClaimData {
|
|
57
|
-
/** Lendaswap's public key (SENDER in the VHTLC) */
|
|
58
|
-
lendaswapPubKey: string;
|
|
59
|
-
/** Arkade server's public key */
|
|
60
|
-
arkadeServerPubKey: string;
|
|
61
|
-
/** VHTLC address to claim from */
|
|
62
|
-
vhtlcAddress: string;
|
|
63
|
-
/** Refund locktime (unix timestamp) */
|
|
64
|
-
refundLocktime: number;
|
|
65
|
-
/** Unilateral claim delay in seconds */
|
|
66
|
-
unilateralClaimDelay: number;
|
|
67
|
-
/** Unilateral refund delay in seconds */
|
|
68
|
-
unilateralRefundDelay: number;
|
|
69
|
-
/** Unilateral refund without receiver delay in seconds */
|
|
70
|
-
unilateralRefundWithoutReceiverDelay: number;
|
|
71
|
-
/** Bitcoin network */
|
|
72
|
-
network: string;
|
|
73
|
-
}
|
|
74
|
-
/** Result of a claim operation */
|
|
75
|
-
export interface ClaimResult {
|
|
76
|
-
/** Whether the claim was successful */
|
|
77
|
-
success: boolean;
|
|
78
|
-
/** Human-readable message about the claim status */
|
|
79
|
-
message: string;
|
|
80
|
-
/** The chain the swap targets */
|
|
81
|
-
chain?: ClaimChain;
|
|
82
|
-
/** Task ID (deprecated, kept for backwards compatibility) */
|
|
83
|
-
taskId?: string;
|
|
84
|
-
/** Transaction hash */
|
|
85
|
-
txHash?: string;
|
|
86
|
-
/** Data for manual Ethereum claims */
|
|
87
|
-
ethereumClaimData?: EthereumClaimData;
|
|
88
|
-
/** Data for Arkade VHTLC claims */
|
|
89
|
-
arkadeClaimData?: ArkadeClaimData;
|
|
90
|
-
/** Data for Arkade-to-EVM coordinator claims (redeemAndExecute) */
|
|
91
|
-
coordinatorClaimData?: CoordinatorClaimData;
|
|
92
|
-
}
|
|
93
|
-
/** Result of a gasless claim via the server-side claim-gasless endpoint */
|
|
94
|
-
export interface ClaimGaslessResult {
|
|
95
|
-
/** Swap ID */
|
|
96
|
-
id: string;
|
|
97
|
-
/** Current swap status */
|
|
98
|
-
status: string;
|
|
99
|
-
/** Transaction hash of the redeemAndExecute call */
|
|
100
|
-
txHash: string;
|
|
101
|
-
/** Success message */
|
|
102
|
-
message: string;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Context passed to redeem functions.
|
|
106
|
-
*/
|
|
107
|
-
export interface RedeemContext {
|
|
108
|
-
/** The API client for making requests */
|
|
109
|
-
apiClient: ApiClient;
|
|
110
|
-
/** Function to get swap details */
|
|
111
|
-
getSwap: (id: string) => Promise<GetSwapResponse>;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Extracts the chain from a token ID.
|
|
115
|
-
*
|
|
116
|
-
* Token IDs follow the pattern: `{token}_{chain}` (e.g., "usdc_pol", "usdt_eth", "usdc_arb")
|
|
117
|
-
*
|
|
118
|
-
* @param tokenId - The token identifier
|
|
119
|
-
* @returns The chain or undefined if not recognized
|
|
120
|
-
*/
|
|
121
|
-
export declare function getChainFromTokenId(tokenId: string): ClaimChain | undefined;
|
|
122
|
-
/**
|
|
123
|
-
* Maps an API Chain name (e.g. "Polygon") to a ClaimChain (e.g. "polygon").
|
|
124
|
-
*/
|
|
125
|
-
export declare function getClaimChainFromChainName(chain: string): ClaimChain | undefined;
|
|
126
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/redeem/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnE,oCAAoC;AACpC,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;AAExE,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,gCAAgC;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,0EAA0E;AAC1E,MAAM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AChB,uBAAuB;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,mCAAmC;IACnC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,mEAAmE;IACnE,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED,2EAA2E;AAC3E,MAAM,WAAW,kBAAkB;IACjC,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,SAAS,EAAE,SAAS,CAAC;IACrB,mCAAmC;IACnC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;CACnD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAM3E;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,GACZ,UAAU,GAAG,SAAS,CAWxB"}
|
package/dist/src/redeem/types.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types for redeem/claim operations.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Extracts the chain from a token ID.
|
|
6
|
-
*
|
|
7
|
-
* Token IDs follow the pattern: `{token}_{chain}` (e.g., "usdc_pol", "usdt_eth", "usdc_arb")
|
|
8
|
-
*
|
|
9
|
-
* @param tokenId - The token identifier
|
|
10
|
-
* @returns The chain or undefined if not recognized
|
|
11
|
-
*/
|
|
12
|
-
export function getChainFromTokenId(tokenId) {
|
|
13
|
-
if (tokenId.endsWith("_pol"))
|
|
14
|
-
return "polygon";
|
|
15
|
-
if (tokenId.endsWith("_arb"))
|
|
16
|
-
return "arbitrum";
|
|
17
|
-
if (tokenId.endsWith("_eth"))
|
|
18
|
-
return "ethereum";
|
|
19
|
-
if (tokenId === "btc_arkade")
|
|
20
|
-
return "arkade";
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Maps an API Chain name (e.g. "Polygon") to a ClaimChain (e.g. "polygon").
|
|
25
|
-
*/
|
|
26
|
-
export function getClaimChainFromChainName(chain) {
|
|
27
|
-
const lower = chain.toLowerCase();
|
|
28
|
-
if (lower === "polygon" ||
|
|
29
|
-
lower === "arbitrum" ||
|
|
30
|
-
lower === "ethereum" ||
|
|
31
|
-
lower === "arkade") {
|
|
32
|
-
return lower;
|
|
33
|
-
}
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/redeem/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmHH;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/C,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,UAAU,CAAC;IAChD,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,UAAU,CAAC;IAChD,IAAI,OAAO,KAAK,YAAY;QAAE,OAAO,QAAQ,CAAC;IAC9C,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAa;IAEb,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAClC,IACE,KAAK,KAAK,SAAS;QACnB,KAAK,KAAK,UAAU;QACpB,KAAK,KAAK,UAAU;QACpB,KAAK,KAAK,QAAQ,EAClB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Arkade (off-chain) VHTLC refund implementation.
|
|
3
|
-
*
|
|
4
|
-
* This module provides VHTLC refund functionality for Arkade (btc_arkade) swaps.
|
|
5
|
-
* When a swap times out, users can reclaim their funds using this refund logic.
|
|
6
|
-
*
|
|
7
|
-
* The VHTLC uses a Taproot output with multiple spending paths. For refunds
|
|
8
|
-
* after the locktime, we use the `refundWithoutReceiver` script path.
|
|
9
|
-
*/
|
|
10
|
-
/** Parameters needed to build an Arkade refund */
|
|
11
|
-
export interface ArkadeRefundParams {
|
|
12
|
-
/** User's secret key (32-byte hex) for signing */
|
|
13
|
-
userSecretKey: string;
|
|
14
|
-
/** User's x-only public key (32-byte hex) - this is the sender in the VHTLC */
|
|
15
|
-
userPubKey: string;
|
|
16
|
-
/** Lendaswap's public key (33-byte compressed hex or 32-byte x-only) - this is the receiver */
|
|
17
|
-
lendaswapPubKey: string;
|
|
18
|
-
/** Arkade server's x-only public key (32-byte hex) */
|
|
19
|
-
arkadeServerPubKey: string;
|
|
20
|
-
/** Hash lock (32-byte hex, SHA256 of preimage) - we'll compute RIPEMD160(hashLock) */
|
|
21
|
-
hashLock: string;
|
|
22
|
-
/** VHTLC address to refund from */
|
|
23
|
-
vhtlcAddress: string;
|
|
24
|
-
/** Refund locktime (unix timestamp) */
|
|
25
|
-
refundLocktime: number;
|
|
26
|
-
/** Unilateral claim delay in seconds */
|
|
27
|
-
unilateralClaimDelay: number;
|
|
28
|
-
/** Unilateral refund delay in seconds */
|
|
29
|
-
unilateralRefundDelay: number;
|
|
30
|
-
/** Unilateral refund without receiver delay in seconds */
|
|
31
|
-
unilateralRefundWithoutReceiverDelay: number;
|
|
32
|
-
/** Destination Arkade address to receive refunded funds */
|
|
33
|
-
destinationAddress: string;
|
|
34
|
-
/** Bitcoin network (mainnet, signet, etc.) */
|
|
35
|
-
network: string;
|
|
36
|
-
/** Arkade server URL (optional, uses default based on network) */
|
|
37
|
-
arkadeServerUrl?: string;
|
|
38
|
-
}
|
|
39
|
-
/** Result of building an Arkade refund */
|
|
40
|
-
export interface ArkadeRefundResult {
|
|
41
|
-
/** Virtual transaction ID */
|
|
42
|
-
txId: string;
|
|
43
|
-
/** Amount refunded in satoshis */
|
|
44
|
-
refundAmount: bigint;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Refund a VHTLC swap after the locktime expires.
|
|
48
|
-
*
|
|
49
|
-
* This function:
|
|
50
|
-
* 1. Constructs the VHTLC with the same parameters as the original swap
|
|
51
|
-
* 2. Connects to the Arkade server
|
|
52
|
-
* 3. Fetches spendable VTXOs at the VHTLC address
|
|
53
|
-
* 4. Builds an offchain transaction using the refundWithoutReceiver script path
|
|
54
|
-
* 5. Signs and submits the transaction
|
|
55
|
-
* 6. Finalizes the transaction
|
|
56
|
-
*
|
|
57
|
-
* @param params - The refund parameters
|
|
58
|
-
* @returns The refund result with transaction ID and amount
|
|
59
|
-
* @throws Error if the refund fails
|
|
60
|
-
*/
|
|
61
|
-
export declare function buildArkadeRefund(params: ArkadeRefundParams): Promise<ArkadeRefundResult>;
|
|
62
|
-
//# sourceMappingURL=arkade.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arkade.d.ts","sourceRoot":"","sources":["../../../src/refund/arkade.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA2BH,kDAAkD;AAClD,MAAM,WAAW,kBAAkB;IACjC,kDAAkD;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,UAAU,EAAE,MAAM,CAAC;IACnB,+FAA+F;IAC/F,eAAe,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,sFAAsF;IACtF,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,yCAAyC;IACzC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,0DAA0D;IAC1D,oCAAoC,EAAE,MAAM,CAAC;IAC7C,2DAA2D;IAC3D,kBAAkB,EAAE,MAAM,CAAC;IAC3B,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IACjC,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;CACtB;AAgED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAqL7B"}
|