@gardenfi/core 2.5.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/{ccip-DSGVoxhU.cjs → ccip-DGrkijK3.cjs} +1 -1
  2. package/dist/{ccip-Bg3f6Dwh.js → ccip-DoKK2Eev.js} +1 -1
  3. package/dist/index-BB1moYTm.cjs +106 -0
  4. package/dist/index-dcGJN5tW.js +33698 -0
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +32 -39
  7. package/dist/src/index.d.ts +7 -12
  8. package/dist/src/lib/bitcoin/API.d.ts +3 -1
  9. package/dist/src/lib/bitcoin/bitcoinHtlc.d.ts +98 -0
  10. package/dist/src/lib/bitcoin/bitcoinhtlc.types.d.ts +53 -0
  11. package/dist/src/lib/bitcoin/provider/provider.d.ts +2 -1
  12. package/dist/src/lib/bitcoin/wallet/abstractWallet.d.ts +1 -1
  13. package/dist/src/lib/bitcoin/wallet/wallet.d.ts +1 -1
  14. package/dist/src/lib/bitcoin/wallet/wallet.interface.d.ts +1 -1
  15. package/dist/src/lib/constants.d.ts +4 -9
  16. package/dist/src/lib/evm/htlc/evmHTLC.d.ts +102 -102
  17. package/dist/src/lib/evm/htlc.types.d.ts +4 -4
  18. package/dist/src/lib/evm/relay/evmRelay.d.ts +9 -11
  19. package/dist/src/lib/evm/relay/htlcInitiate.d.ts +25 -0
  20. package/dist/src/lib/garden/cache/GardenCache.d.ts +45 -0
  21. package/dist/src/lib/garden/executor/executor.d.ts +26 -0
  22. package/dist/src/lib/garden/garden.d.ts +43 -52
  23. package/dist/src/lib/garden/garden.types.d.ts +70 -103
  24. package/dist/src/lib/garden/utils.d.ts +4 -0
  25. package/dist/src/lib/quote/quote.d.ts +8 -7
  26. package/dist/src/lib/quote/quote.types.d.ts +21 -13
  27. package/dist/src/lib/relayer/relayer.d.ts +9 -0
  28. package/dist/src/lib/solana/htlc/ISolanaHTLC.d.ts +4 -4
  29. package/dist/src/lib/solana/htlc/solanaHTLC.d.ts +7 -7
  30. package/dist/src/lib/solana/relayer/solanaRelay.d.ts +28 -35
  31. package/dist/src/lib/solana/solanaTypes.d.ts +6 -6
  32. package/dist/src/lib/starknet/htlc/starknetHTLC.d.ts +4 -4
  33. package/dist/src/lib/starknet/relay/starknetRelay.d.ts +9 -5
  34. package/dist/src/lib/starknet/starknetHTLC.types.d.ts +4 -4
  35. package/dist/src/lib/sui/htlc/suiHTLC.d.ts +7 -6
  36. package/dist/src/lib/sui/relay/suiRelay.d.ts +8 -5
  37. package/dist/src/lib/sui/suiHTLC.types.d.ts +4 -4
  38. package/dist/src/lib/switchOrAddNetwork.d.ts +5 -3
  39. package/dist/src/lib/utils.d.ts +38 -6
  40. package/package.json +4 -3
  41. package/dist/index-D-NHDZrP.js +0 -31936
  42. package/dist/index-s2tkcnpk.cjs +0 -105
  43. package/dist/src/lib/bitcoin/htlc.d.ts +0 -106
  44. package/dist/src/lib/blockNumberFetcher/blockNumber.d.ts +0 -15
  45. package/dist/src/lib/evm/relay/evmRelay.types.d.ts +0 -26
  46. package/dist/src/lib/garden/cache/executorCache.d.ts +0 -14
  47. package/dist/src/lib/orderStatus/orderStatusParser.d.ts +0 -37
  48. package/dist/src/lib/orderStatus/status.d.ts +0 -130
@@ -1,106 +0,0 @@
1
- import { IHTLCWallet } from '../htlc.interface';
2
- import { IBitcoinWallet } from './wallet/wallet.interface';
3
-
4
- export declare enum Leaf {
5
- REFUND = 0,
6
- REDEEM = 1,
7
- INSTANT_REFUND = 2
8
- }
9
- export declare class GardenHTLC implements IHTLCWallet {
10
- /**
11
- * Signer of the HTLC can be either the initiator or the redeemer
12
- */
13
- private signer;
14
- private secretHash;
15
- /**
16
- * redeemer's x-only public key without 02 or 03 prefix
17
- */
18
- private redeemerPubkey;
19
- /**
20
- * initiator's x-only public key without 02 or 03 prefix
21
- */
22
- private initiatorPubkey;
23
- private expiry;
24
- /**
25
- * NUMS internal key which blocks key path spending
26
- */
27
- private internalPubkey;
28
- private network;
29
- private initiateAmount;
30
- private utxoHashes?;
31
- /**
32
- * Note: redeemerAddress and initiatorAddress should be x-only public key without 02 or 03 prefix
33
- */
34
- private constructor();
35
- /**
36
- * Creates a GardenHTLC instance
37
- * @param signer Bitcoin wallet of the initiator or redeemer
38
- * @param secretHash 32 bytes secret hash
39
- * @param initiatorPubkey initiator's x-only public key without 02 or 03 prefix
40
- * @param redeemerPubkey redeemer's x-only public key without 02 or 03 prefix
41
- * @param expiry block height after which the funds can be refunded
42
- * @returns GardenHTLC instance
43
- *
44
- *
45
- * Note: When the signer is the initiator, only refund and instant refund can be done
46
- * When the signer is the redeemer, only redeem can be done
47
- */
48
- static from(signer: IBitcoinWallet, initiateAmount: number, secretHash: string, initiatorPubkey: string, redeemerPubkey: string, expiry: number, utxoHashes?: string[]): Promise<GardenHTLC>;
49
- /**
50
- * Generates a taproot address for receiving the funds
51
- */
52
- address(): string;
53
- /**
54
- * returns the address of the HTLC
55
- */
56
- id(): string;
57
- private _buildRawTx;
58
- /**
59
- * prevout script for the gardenHTLC address
60
- */
61
- private getOutputScript;
62
- init(fee?: number): Promise<string>;
63
- generateRedeemSACP(secret: string, receiver: string, fee?: number): Promise<string>;
64
- generateInstantRefundSACP(receiver: string): Promise<string>;
65
- generateInstantRefundSACPWithHash(hash: string[]): Promise<string[]>;
66
- /**
67
- * Instantly refunds the funds to the initiator given the counterparty's signatures and pubkey
68
- *
69
- * Note: If there are multiple UTXOs being spend, there should be a signature for each UTXO in counterPartySigs
70
- */
71
- instantRefund(counterPartySigs: {
72
- utxo: string;
73
- sig: string;
74
- }[], fee?: number): Promise<string>;
75
- /**
76
- * Reveals the secret and redeems the HTLC
77
- */
78
- redeem(secret: string, receiver?: string): Promise<string>;
79
- getRedeemHex(secret: string, receiver?: string): Promise<string>;
80
- /**
81
- * Refunds the funds back to the initiator if the expiry block height + 1 is reached
82
- */
83
- refund(receiver?: string, fee?: number): Promise<string>;
84
- /**
85
- * Given a list of UTXOs, checks if the HTLC can be refunded
86
- */
87
- private canRefund;
88
- /**
89
- * Given a leaf, generates the control block necessary for spending the leaf
90
- */
91
- private generateControlBlockFor;
92
- /**
93
- * Generates the hash of the leaf script
94
- * @param leaf Use leaf enum or pass 0 for refund, 1 for redeem, 2 for instant refund
95
- * @returns hash of the leaf script
96
- */
97
- leafHash(leaf: Leaf): Buffer;
98
- private refundLeaf;
99
- private redeemLeaf;
100
- private instantRefundLeaf;
101
- private leaves;
102
- /**
103
- * Generates the merkle proof for the leaf script
104
- */
105
- private generateMerkleProofFor;
106
- }
@@ -1,15 +0,0 @@
1
- import { Chain } from '@gardenfi/orderbook';
2
- import { Environment, AsyncResult } from '@gardenfi/utils';
3
-
4
- type Response = {
5
- [key in Chain]: number;
6
- };
7
- export interface IBlockNumberFetcher {
8
- fetchBlockNumbers(): AsyncResult<Response, string>;
9
- }
10
- export declare class BlockNumberFetcher implements IBlockNumberFetcher {
11
- private url;
12
- constructor(url: string, network: Environment);
13
- fetchBlockNumbers(): AsyncResult<Response, string>;
14
- }
15
- export {};
@@ -1,26 +0,0 @@
1
- import { MatchedOrder } from '@gardenfi/orderbook';
2
- import { AsyncResult, IStore } from '@gardenfi/utils';
3
- import { WalletClient } from 'viem';
4
-
5
- export type EVMRelayOpts = {
6
- store?: IStore;
7
- domain?: string;
8
- };
9
- export interface IEVMRelay {
10
- /**
11
- * Deposits funds to the EVM atomic swap contract using relay service.
12
- * Sends the signature to the relay service.
13
- * @param order Matched Order
14
- * @param currentL1BlockNumber Current L1 block number. Used to calculate the swap expiry.
15
- * @NOTE send the current block number of the L1 chain, if the order is on L2 chain (arbitrum).
16
- * @returns txHash of Initiation
17
- */
18
- init(walletClient: WalletClient, order: MatchedOrder): AsyncResult<string, string>;
19
- /**
20
- * Redeems funds from the EVM atomic swap contract using relay service.
21
- * Sends the secret to the relay service.
22
- * @param orderId Create order Id of the order
23
- * @param secret Secret of the HTLC generated when creating the order
24
- */
25
- redeem(orderId: string, secret: string): AsyncResult<string, string>;
26
- }
@@ -1,14 +0,0 @@
1
- import { MatchedOrder } from '@gardenfi/orderbook';
2
- import { IOrderExecutorCache, OrderActions, OrderCacheValue } from '../garden.types';
3
-
4
- export declare class ExecutorCache implements IOrderExecutorCache {
5
- private cache;
6
- set(order: MatchedOrder, action: OrderActions, txHash: string, utxo?: string): void;
7
- get(order: MatchedOrder, action: OrderActions): OrderCacheValue | null;
8
- remove(order: MatchedOrder, action: OrderActions): void;
9
- }
10
- export declare class Cache<T> {
11
- private cache;
12
- set(key: string, value: T): void;
13
- get(key: string): T | null;
14
- }
@@ -1,37 +0,0 @@
1
- import { MatchedOrder, Swap } from '@gardenfi/orderbook';
2
- import { OrderActions } from '../garden/garden.types';
3
- import { OrderStatus, SwapStatus } from './status';
4
-
5
- /**
6
- * Parse the order status based on the current block number and checks if its expired or initiated or redeemed or refunded
7
- * @param order Order object
8
- * @param sourceChainCurrentBlockNumber source chain current block number
9
- * @param destChainCurrentBlockNumber destination chain current block number
10
- * @note send the current block number of the L1 chain even if the order is on L2 chain.
11
- * @returns {OrderStatus} The status of the order
12
- */
13
- export declare const ParseOrderStatus: (order: MatchedOrder, sourceChainCurrentBlockNumber: number, destChainCurrentBlockNumber: number) => OrderStatus;
14
- /**
15
- * Parse the swap status based on the current block number and checks if its expired or initiated or redeemed or refunded
16
- * @param swap The swap object
17
- * @param currentBlockNumber
18
- */
19
- export declare const ParseSwapStatus: (swap: Swap, currentBlockNumber: number) => SwapStatus;
20
- /**
21
- * Parse the action to be performed on the.
22
- * @param order Order object
23
- * @param sourceChainCurrentBlockNumber source chain current block number
24
- * @param destChainCurrentBlockNumber destination chain current block number
25
- * @note send the current block number of the L1 chain even if the order is on L2 chain.
26
- * @returns {OrderActions} The action to be performed on the order
27
- */
28
- export declare const parseAction: (order: MatchedOrder, sourceChainCurrentBlockNumber: number, destChainCurrentBlockNumber: number) => OrderActions;
29
- /**
30
- * Parse the action to be performed on the order based on the order status.
31
- * @param status Order status
32
- * @returns {OrderActions} The action to be performed on the order
33
- */
34
- export declare const parseActionFromStatus: (status: OrderStatus) => OrderActions;
35
- export declare const isExpired: (unixTime: number, tillHours?: number) => boolean;
36
- export declare const filterDeadlineExpiredOrders: (orders: MatchedOrder[]) => MatchedOrder[];
37
- export declare const isOrderExpired: (order: MatchedOrder) => boolean;
@@ -1,130 +0,0 @@
1
- /**
2
- * Order statuses
3
- */
4
- export declare enum OrderStatus {
5
- /**
6
- * - Order is created
7
- * - Waiting for match
8
- */
9
- Created = "Created",
10
- /**
11
- * - Order is matched
12
- * - User has to initiate
13
- */
14
- Matched = "Matched",
15
- /**
16
- * - User initiate tx detected on-chain but not confirmed
17
- */
18
- InitiateDetected = "InitiateDetected",
19
- /**
20
- * - User initiated
21
- * - Waiting for counter party to initiate
22
- */
23
- Initiated = "Initiated",
24
- /**
25
- * - Counter party initiate tx detected on-chain but not confirmed
26
- */
27
- CounterPartyInitiateDetected = "CounterPartyInitiateDetected",
28
- /**
29
- * - Counter party initiated
30
- * - User has to redeem
31
- */
32
- CounterPartyInitiated = "CounterPartyInitiated",
33
- /**
34
- * - User redeem tx detected on-chain but not confirmed
35
- */
36
- RedeemDetected = "RedeemDetected",
37
- /**
38
- * - User redeemed
39
- * - Counter party has to redeem
40
- * - We also consider user redemption as completed order.
41
- */
42
- Redeemed = "Redeemed",
43
- /**
44
- * - Counter party redeem tx detected on-chain but not confirmed
45
- */
46
- CounterPartyRedeemDetected = "CounterPartyRedeemDetected",
47
- /**
48
- * - Counter party redeemed
49
- * - Order is completed
50
- */
51
- CounterPartyRedeemed = "CounterPartyRedeemed",
52
- /**
53
- * - Counter party redeemed
54
- * - Order is completed
55
- */
56
- Completed = "Completed",
57
- /**
58
- * - The counterparty's swap has expired, and they will refund their funds.
59
- * - The user can no longer redeem the funds. The user must wait for their swap to expire and then refund their funds.
60
- * - Typically, in our system, the counterparty's swap expires in 24 hours, and the user's swap expires in 48 hours.
61
- */
62
- CounterPartySwapExpired = "CounterPartySwapExpired",
63
- /**
64
- * - The user's swap has expired, and they have to refund their funds.
65
- * - The user's expiry only happens after counterparty's expiry.
66
- * - Typically, in our system, the counterparty's swap expires in 24 hours, and the user's swap expires in 48 hours.
67
- */
68
- Expired = "Expired",
69
- /**
70
- * - User refund tx detected on-chain but not confirmed
71
- */
72
- RefundDetected = "RefundDetected",
73
- /**
74
- * - User refunded
75
- * - User can only refund if their swap has expired
76
- */
77
- Refunded = "Refunded",
78
- /**
79
- * - Counter party refund tx detected on-chain but not confirmed
80
- */
81
- CounterPartyRefundDetected = "CounterPartyRefundDetected",
82
- /**
83
- * - Counter party refunded
84
- */
85
- CounterPartyRefunded = "CounterPartyRefunded",
86
- /**
87
- * - Order is cancelled
88
- */
89
- Cancelled = "Cancelled",
90
- /**
91
- * - DeadLine exceeded
92
- * - Initiate not detected before 1 hour of deadline or initiate not confirmed before 12 hours of deadline
93
- */
94
- DeadLineExceeded = "DeadLineExceeded"
95
- }
96
- export declare enum SwapStatus {
97
- /**
98
- * - Swap is idle
99
- */
100
- Idle = "Idle",
101
- /**
102
- * - Initiate tx detected on-chain but not confirmed
103
- */
104
- InitiateDetected = "InitiateDetected",
105
- /**
106
- * - Swap is initiated
107
- */
108
- Initiated = "Initiated",
109
- /**
110
- * - Redeem tx detected on-chain but not confirmed
111
- */
112
- RedeemDetected = "RedeemDetected",
113
- /**
114
- * - Redeemed
115
- */
116
- Redeemed = "Redeemed",
117
- /**
118
- * - Refund tx detected on-chain but not confirmed
119
- */
120
- RefundDetected = "RefundDetected",
121
- /**
122
- * - Refunded
123
- */
124
- Refunded = "Refunded",
125
- /**
126
- * - Swap is expired.
127
- * - Should refund.
128
- */
129
- Expired = "Expired"
130
- }