@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,6 +1,6 @@
1
1
  import { AnchorProvider } from '@coral-xyz/anchor';
2
2
  import { ISolanaHTLC } from './ISolanaHTLC';
3
- import { MatchedOrder } from '@gardenfi/orderbook';
3
+ import { Order } from '@gardenfi/orderbook';
4
4
  import { AsyncResult } from '@gardenfi/utils';
5
5
 
6
6
  /**
@@ -30,27 +30,27 @@ export declare class SolanaHTLC implements ISolanaHTLC {
30
30
  get htlcActorAddress(): string;
31
31
  /**
32
32
  * Initiates a swap by creating a new swap account and locking funds.
33
- * @param {MatchedOrder} order - The matched order containing swap details
33
+ * @param {Order} order - The matched order containing swap details
34
34
  * @returns {Promise<AsyncResult<string, string>>} A promise that resolves to either:
35
35
  * - Ok with the transaction ID on success
36
36
  * - Err with an error message on failure
37
37
  */
38
- initiate(order: MatchedOrder): AsyncResult<string, string>;
38
+ initiate(order: Order): AsyncResult<string, string>;
39
39
  /**
40
40
  * Redeems a swap by providing the secret.
41
- * @param {MatchedOrder} order - Matched order object containing swap details
41
+ * @param {Order} order - Matched order object containing swap details
42
42
  * @param {string} secret - Secret key in hex format
43
43
  * @returns {AsyncResult<string, string>} A promise that resolves to either:
44
44
  * - Ok with the transaction ID on success
45
45
  * - Err with an error message on failure
46
46
  */
47
- redeem(order: MatchedOrder, secret: string): AsyncResult<string, string>;
47
+ redeem(order: Order, secret: string): AsyncResult<string, string>;
48
48
  /**
49
49
  * Refunds the swap back to the initiator.
50
- * @param {MatchedOrder} order - Matched order object
50
+ * @param {Order} order - Matched order object
51
51
  * @returns {AsyncResult<string, string>} A promise that resolves to either:
52
52
  * - Ok with the transaction ID on success
53
53
  * - Err with an error message on failure
54
54
  */
55
- refund(order: MatchedOrder): AsyncResult<string, string>;
55
+ refund(order: Order): AsyncResult<string, string>;
56
56
  }
@@ -1,7 +1,7 @@
1
1
  import { AnchorProvider } from '@coral-xyz/anchor';
2
- import { AsyncResult, Url } from '@gardenfi/utils';
2
+ import { AsyncResult, IAuth, Url, Network } from '@gardenfi/utils';
3
3
  import { ISolanaHTLC } from '../htlc/ISolanaHTLC';
4
- import { MatchedOrder } from '@gardenfi/orderbook';
4
+ import { Order, SolanaOrderResponse } from '@gardenfi/orderbook';
5
5
 
6
6
  /**
7
7
  * A Relay is an endpoint that submits the transaction on-chain on one's behalf, paying any fees.
@@ -18,18 +18,25 @@ export declare class SolanaRelay implements ISolanaHTLC {
18
18
  private splProgram?;
19
19
  private nativeProgram?;
20
20
  private relayer;
21
+ private auth;
22
+ private relayerClient;
21
23
  /**
22
24
  * Creates a new instance of SolanaRelay.
23
25
  * @param {AnchorProvider} provider - An abstraction of RPC connection and a Wallet
24
26
  * @param {Url} endpoint - API endpoint of the relayer node
25
- * @param {string} relayer - On-chain address of the relayer in base58 format
26
- * @param {string} splProgramAddress - On-chain address of the SPL token swap program
27
- * @param {string} nativeProgramAddress - On-chain address of the native token swap program
27
+ * @param {Network} network - Chain network for selecting default relayer and program addresses
28
+ * @param {IAuth} auth - Auth provider for relayer endpoints
29
+ * @param {object} [overrides] - Optional overrides for relayer/program addresses
30
+ * @param {string} [overrides.relayer] - Custom relayer address (base58)
31
+ * @param {{native?: string; spl?: string}} [overrides.programAddress] - Custom program addresses
28
32
  * @throws {Error} If any required parameters are missing or invalid
29
33
  */
30
- constructor(provider: AnchorProvider, url: Url, relayer: string, programAddress: {
31
- native?: string;
32
- spl?: string;
34
+ constructor(provider: AnchorProvider, url: Url, network: Network, auth: IAuth, overrides?: {
35
+ relayer?: string;
36
+ programAddress?: {
37
+ native?: string;
38
+ spl?: string;
39
+ };
33
40
  });
34
41
  /**
35
42
  * Gets the on-chain address of the current user's wallet.
@@ -38,12 +45,14 @@ export declare class SolanaRelay implements ISolanaHTLC {
38
45
  */
39
46
  get htlcActorAddress(): string;
40
47
  /**
41
- * Determines if the given order is for a native Solana token (SOL).
42
- * @param {MatchedOrder} order - The matched order to check
43
- * @returns {boolean} True if it's a native token, false if it's an SPL token
44
- * @private
48
+ * Initiates a swap by creating a new swap account and locking funds.
49
+ * Automatically detects whether to use SPL or native token handling.
50
+ * @param {Order} order - The matched order containing swap details
51
+ * @returns {Promise<AsyncResult<string, string>>} A promise that resolves to either:
52
+ * - Ok with the transaction ID on success
53
+ * - Err with an error message on failure
45
54
  */
46
- private isNativeToken;
55
+ initiate(order: Order | SolanaOrderResponse): AsyncResult<string, string>;
47
56
  /**
48
57
  * Sends a transaction via the relayer for SPL tokens.
49
58
  * @param {web3.Transaction} transaction - The transaction to send
@@ -57,24 +66,16 @@ export declare class SolanaRelay implements ISolanaHTLC {
57
66
  /**
58
67
  * Initiates a swap directly via HTLC (without relayer).
59
68
  * @param {web3.Transaction} transaction - The transaction to send
60
- * @param {MatchedOrder} order - The matched order
69
+ * @param {Order} order - The matched order
61
70
  * @returns {Promise<AsyncResult<string, string>>} A promise that resolves to either:
62
71
  * - Ok with the transaction ID on success
63
72
  * - Err with an error message on failure
64
73
  * @private
65
74
  */
66
75
  private initiateViaHTLC;
67
- /**
68
- * Creates a PDA (Program Derived Address) for the swap account.
69
- * @param {Buffer} secretHash - The secret hash buffer
70
- * @param {web3.PublicKey} programId - The program ID to use for PDA derivation
71
- * @returns {web3.PublicKey} The derived PDA
72
- * @private
73
- */
74
- private createSwapPDA;
75
76
  /**
76
77
  * Initiates a swap for SPL tokens.
77
- * @param {MatchedOrder} order - The matched order containing swap details
78
+ * @param {Order} order - The matched order containing swap details
78
79
  * @returns {Promise<AsyncResult<string, string>>} A promise that resolves to either:
79
80
  * - Ok with the transaction ID on success
80
81
  * - Err with an error message on failure
@@ -83,31 +84,23 @@ export declare class SolanaRelay implements ISolanaHTLC {
83
84
  private initiateSplSwap;
84
85
  /**
85
86
  * Initiates a swap for native tokens (SOL).
86
- * @param {MatchedOrder} order - The matched order containing swap details
87
+ * @param {Order} order - The matched order containing swap details
87
88
  * @returns {Promise<AsyncResult<string, string>>} A promise that resolves to either:
88
89
  * - Ok with the transaction ID on success
89
90
  * - Err with an error message on failure
90
91
  * @private
91
92
  */
92
93
  private initiateNativeSwap;
93
- /**
94
- * Initiates a swap by creating a new swap account and locking funds.
95
- * Automatically detects whether to use SPL or native token handling.
96
- * @param {MatchedOrder} order - The matched order containing swap details
97
- * @returns {Promise<AsyncResult<string, string>>} A promise that resolves to either:
98
- * - Ok with the transaction ID on success
99
- * - Err with an error message on failure
100
- */
101
- initiate(order: MatchedOrder): AsyncResult<string, string>;
94
+ private initiateWithCreateOrderResponse;
102
95
  /**
103
96
  * Redeems a swap by providing the secret.
104
- * @param {MatchedOrder} order - Matched order object containing swap details
97
+ * @param {Order} order - Matched order object containing swap details
105
98
  * @param {string} secret - Secret key in hex format
106
99
  * @returns {Promise<AsyncResult<string, string>>} A promise that resolves to either:
107
100
  * - Ok with the transaction ID on success
108
101
  * - Err with an error message on failure
109
102
  */
110
- redeem(order: MatchedOrder, secret: string): AsyncResult<string, string>;
103
+ redeem(order: Order, secret: string): AsyncResult<string, string>;
111
104
  /**
112
105
  * DO NOT CALL THIS FUNCTION. Refund is automatically taken care of by the relayer!
113
106
  * This method exists only to satisfy the ISolanaHTLC interface but is not intended for direct use.
@@ -1,5 +1,5 @@
1
- import { web3, BN } from '@coral-xyz/anchor';
2
- import { MatchedOrder } from '@gardenfi/orderbook';
1
+ import { web3 } from '@coral-xyz/anchor';
2
+ import { Order } from '@gardenfi/orderbook';
3
3
 
4
4
  /**
5
5
  * A Swap configuration in Solana
@@ -8,8 +8,8 @@ export declare class SwapConfig {
8
8
  swapId: number[];
9
9
  redeemer: web3.PublicKey;
10
10
  secretHash: number[];
11
- amount: BN;
12
- expiresIn: BN;
11
+ amount: BigNumber;
12
+ expiresIn: BigNumber;
13
13
  /**
14
14
  * @param swapId - A Unique 32-bit ID to represent this configuration in hex
15
15
  * @param redeemer - The Solana address of redeemer in base58
@@ -20,9 +20,9 @@ export declare class SwapConfig {
20
20
  constructor(swapId: string, redeemer: string, secretHash: string, amount: bigint, expiresIn: number);
21
21
  /**
22
22
  * Constructs a SwapConfig from a matched order object with Solana as a source swap
23
- * @param order - The MatchedOrder with a Solana as source swap
23
+ * @param order - The Order with a Solana as source swap
24
24
  */
25
- static from(order: MatchedOrder): SwapConfig;
25
+ static from(order: Order): SwapConfig;
26
26
  }
27
27
  /**
28
28
  * Checks whether given secret is a valid 32 byte hex string.
@@ -1,4 +1,4 @@
1
- import { MatchedOrder } from '@gardenfi/orderbook';
1
+ import { Order } from '@gardenfi/orderbook';
2
2
  import { Account, CallData } from 'starknet';
3
3
  import { AsyncResult, Network } from '@gardenfi/utils';
4
4
  import { IStarknetHTLC } from '../starknetHTLC.types';
@@ -14,7 +14,7 @@ export declare class StarknetHTLC implements IStarknetHTLC {
14
14
  * @param order Order to initiate HTLC for
15
15
  * @returns Transaction ID
16
16
  */
17
- initiate(order: MatchedOrder): AsyncResult<string, string>;
17
+ initiate(order: Order): AsyncResult<string, string>;
18
18
  callData: CallData;
19
19
  /**
20
20
  * Redeems the HTLC
@@ -23,12 +23,12 @@ export declare class StarknetHTLC implements IStarknetHTLC {
23
23
  * @param secret Secret to redeem HTLC with
24
24
  * @returns Transaction ID
25
25
  */
26
- redeem(order: MatchedOrder, secret: string): AsyncResult<string, string>;
26
+ redeem(order: Order, secret: string): AsyncResult<string, string>;
27
27
  /**
28
28
  * Refunds the HTLC
29
29
  *
30
30
  * @param order Order to refund HTLC for
31
31
  * @returns Refund transaction ID
32
32
  */
33
- refund(order: MatchedOrder): AsyncResult<string, string>;
33
+ refund(order: Order): AsyncResult<string, string>;
34
34
  }
@@ -1,6 +1,6 @@
1
1
  import { AccountInterface } from 'starknet';
2
- import { MatchedOrder } from '@gardenfi/orderbook';
3
- import { AsyncResult, Network, Url } from '@gardenfi/utils';
2
+ import { Order, StarknetOrderResponse } from '@gardenfi/orderbook';
3
+ import { AsyncResult, IAuth, Network, Url } from '@gardenfi/utils';
4
4
  import { IStarknetHTLC } from '../starknetHTLC.types';
5
5
 
6
6
  export declare class StarknetRelay implements IStarknetHTLC {
@@ -8,11 +8,15 @@ export declare class StarknetRelay implements IStarknetHTLC {
8
8
  private account;
9
9
  private starknetProvider;
10
10
  private chainId;
11
- constructor(relayerUrl: string | Url, account: AccountInterface, network: Network, nodeUrl?: string);
11
+ private auth;
12
+ private relayer;
13
+ constructor(relayerUrl: string | Url, account: AccountInterface, network: Network, auth: IAuth, nodeUrl?: string);
12
14
  get htlcActorAddress(): string;
13
- initiate(order: MatchedOrder): AsyncResult<string, string>;
15
+ initiate(order: Order | StarknetOrderResponse): AsyncResult<string, string>;
14
16
  private approveAndInitiate;
15
17
  private initiateRelay;
16
- redeem(order: MatchedOrder, secret: string): AsyncResult<string, string>;
18
+ redeem(order: Order, secret: string): AsyncResult<string, string>;
19
+ executeApprovalTransaction(order: StarknetOrderResponse): AsyncResult<string, string>;
20
+ initiateWithCreateOrderResponse(order: StarknetOrderResponse): AsyncResult<string, string>;
17
21
  refund(): AsyncResult<string, string>;
18
22
  }
@@ -1,4 +1,4 @@
1
- import { MatchedOrder } from '@gardenfi/orderbook';
1
+ import { Order, StarknetOrderResponse } from '@gardenfi/orderbook';
2
2
  import { AsyncResult } from '@gardenfi/utils';
3
3
 
4
4
  export interface IStarknetHTLC {
@@ -11,18 +11,18 @@ export interface IStarknetHTLC {
11
11
  * @param order - The matched order.
12
12
  * @returns A promise resolving to the transaction hash of the initiation.
13
13
  */
14
- initiate(order: MatchedOrder): AsyncResult<string, string>;
14
+ initiate(order: Order | StarknetOrderResponse): AsyncResult<string, string>;
15
15
  /**
16
16
  * Redeems funds from the HTLC contract to the actor's address.
17
17
  * @param order - The matched order.
18
18
  * @param secret - The secret required to unlock the htlc.
19
19
  * @returns A promise resolving to the transaction hash of the redemption.
20
20
  */
21
- redeem(order: MatchedOrder, secret: string): AsyncResult<string, string>;
21
+ redeem(order: Order, secret: string): AsyncResult<string, string>;
22
22
  /**
23
23
  * Refunds funds from the HTLC contract back to the actor's address upon expiration.
24
24
  * @param order - The matched order.
25
25
  * @returns A promise resolving to the transaction hash of the refund.
26
26
  */
27
- refund(order: MatchedOrder): AsyncResult<string, string>;
27
+ refund(order: Order): AsyncResult<string, string>;
28
28
  }
@@ -1,5 +1,5 @@
1
- import { MatchedOrder } from '@gardenfi/orderbook';
2
- import { AsyncResult, Network } from '@gardenfi/utils';
1
+ import { Order } from '@gardenfi/orderbook';
2
+ import { AsyncResult, Url, Network } from '@gardenfi/utils';
3
3
  import { ISuiHTLC } from '../suiHTLC.types';
4
4
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
5
5
  import { WalletWithRequiredFeatures } from '@mysten/wallet-standard';
@@ -8,14 +8,15 @@ export declare class SuiHTLC implements ISuiHTLC {
8
8
  private client;
9
9
  private account;
10
10
  private network;
11
- constructor(account: WalletWithRequiredFeatures | Ed25519Keypair, network: Network);
11
+ private url;
12
+ constructor(account: WalletWithRequiredFeatures | Ed25519Keypair, network: Network, url: Url);
12
13
  get htlcActorAddress(): string;
13
14
  /**
14
15
  * Initiates the HTLC
15
16
  * @param order Order to initiate HTLC for
16
17
  * @returns Transaction ID
17
18
  */
18
- initiate(order: MatchedOrder): AsyncResult<string, string>;
19
+ initiate(order: Order): AsyncResult<string, string>;
19
20
  /**
20
21
  * Redeems the HTLC
21
22
  *
@@ -23,12 +24,12 @@ export declare class SuiHTLC implements ISuiHTLC {
23
24
  * @param secret Secret to redeem HTLC with
24
25
  * @returns Transaction ID
25
26
  */
26
- redeem(order: MatchedOrder, secret: string): AsyncResult<string, string>;
27
+ redeem(order: Order, secret: string): AsyncResult<string, string>;
27
28
  /**
28
29
  * Refunds the HTLC
29
30
  *
30
31
  * @param order Order to refund HTLC for
31
32
  * @returns Refund transaction ID
32
33
  */
33
- refund(order: MatchedOrder): AsyncResult<string, string>;
34
+ refund(order: Order): AsyncResult<string, string>;
34
35
  }
@@ -1,5 +1,5 @@
1
- import { MatchedOrder } from '@gardenfi/orderbook';
2
- import { AsyncResult, Network, Url } from '@gardenfi/utils';
1
+ import { Order, SuiOrderResponse } from '@gardenfi/orderbook';
2
+ import { AsyncResult, IAuth, Network, Url } from '@gardenfi/utils';
3
3
  import { ISuiHTLC } from '../suiHTLC.types';
4
4
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
5
5
  import { WalletWithRequiredFeatures } from '@mysten/wallet-standard';
@@ -9,9 +9,12 @@ export declare class SuiRelay implements ISuiHTLC {
9
9
  private url;
10
10
  private account;
11
11
  private network;
12
- constructor(relayerUrl: string | Url, account: WalletWithRequiredFeatures | Ed25519Keypair, network: Network);
12
+ private auth;
13
+ private relayer;
14
+ constructor(relayerUrl: string | Url, account: WalletWithRequiredFeatures | Ed25519Keypair, network: Network, auth: IAuth);
13
15
  get htlcActorAddress(): string;
14
- initiate(order: MatchedOrder): AsyncResult<string, string>;
15
- redeem(order: MatchedOrder, secret: string): AsyncResult<string, string>;
16
+ initiate(order: Order | SuiOrderResponse): AsyncResult<string, string>;
17
+ private initiateWithCreateOrderResponse;
18
+ redeem(order: Order, secret: string): AsyncResult<string, string>;
16
19
  refund(): AsyncResult<string, string>;
17
20
  }
@@ -1,4 +1,4 @@
1
- import { MatchedOrder } from '@gardenfi/orderbook';
1
+ import { Order, SuiOrderResponse } from '@gardenfi/orderbook';
2
2
  import { AsyncResult } from '@gardenfi/utils';
3
3
 
4
4
  export interface ISuiHTLC {
@@ -11,18 +11,18 @@ export interface ISuiHTLC {
11
11
  * @param order - The matched order.
12
12
  * @returns A promise resolving to the transaction hash of the initiation.
13
13
  */
14
- initiate(order: MatchedOrder): AsyncResult<string, string>;
14
+ initiate(order: Order | SuiOrderResponse): AsyncResult<string, string>;
15
15
  /**
16
16
  * Redeems funds from the HTLC contract to the actor's address.
17
17
  * @param order - The matched order.
18
18
  * @param secret - The secret required to unlock the htlc.
19
19
  * @returns A promise resolving to the transaction hash of the redemption.
20
20
  */
21
- redeem(order: MatchedOrder, secret: string): AsyncResult<string, string>;
21
+ redeem(order: Order, secret: string): AsyncResult<string, string>;
22
22
  /**
23
23
  * Refunds funds from the HTLC contract back to the actor's address upon expiration.
24
24
  * @param order - The matched order.
25
25
  * @returns A promise resolving to the transaction hash of the refund.
26
26
  */
27
- refund(order: MatchedOrder): AsyncResult<string, string>;
27
+ refund(order: Order): AsyncResult<string, string>;
28
28
  }
@@ -1,19 +1,21 @@
1
1
  import { Chain as viemChain } from 'viem/chains';
2
- import { EvmChain } from '@gardenfi/orderbook';
2
+ import { EVMChains } from '@gardenfi/orderbook';
3
3
  import { WalletClient } from 'viem';
4
4
  import { AsyncResult } from '@gardenfi/utils';
5
5
 
6
6
  export declare const botanixMainnet: viemChain;
7
7
  export declare const hyperliquidTestnet: viemChain;
8
8
  export declare const hyperliquid: viemChain;
9
- export declare const evmToViemChainMap: Record<EvmChain, viemChain>;
9
+ export declare const alpenTestnet: viemChain;
10
+ export declare const evmToViemChainMap: Record<EVMChains, viemChain>;
11
+ export declare const getChainNameFromChainId: (chainId: number) => EVMChains | null;
10
12
  /**
11
13
  * Switches or adds a network to the wallet
12
14
  * @param chain Garden supported chain
13
15
  * @param walletClient
14
16
  * @returns new walletClient with updated chain
15
17
  */
16
- export declare const switchOrAddNetwork: (chain: EvmChain, walletClient: WalletClient) => AsyncResult<{
18
+ export declare const switchOrAddNetwork: (chain: EVMChains, walletClient: WalletClient) => AsyncResult<{
17
19
  message: string;
18
20
  walletClient: WalletClient;
19
21
  }, string>;
@@ -1,18 +1,26 @@
1
- import { Environment, Err, Ok } from '@gardenfi/utils';
2
- import { Chain } from '@gardenfi/orderbook';
1
+ import { AsyncResult, Environment, Err, Ok, Url, Network } from '@gardenfi/utils';
2
+ import { AffiliateFee, BlockchainType, Chain } from '@gardenfi/orderbook';
3
+ import { WalletClient } from 'viem';
3
4
  import { Signature } from 'starknet';
4
5
  import { Api } from './constants';
5
- import { ApiConfig } from './garden/garden.types';
6
+ import { ApiConfig, GardenHTLCModules } from './garden/garden.types';
6
7
  import { BitcoinNetwork } from './bitcoin/provider/provider.interface';
7
8
  import { IBaseWallet } from './bitcoin/wallet/baseWallet';
8
9
  import { web3 } from '@coral-xyz/anchor';
9
10
 
11
+ import * as bitcoin from 'bitcoinjs-lib';
12
+ type ExecuteWithRelayerRetriesArgs = {
13
+ attempt: () => AsyncResult<string, string>;
14
+ wallet: WalletClient;
15
+ maxAttempts?: number;
16
+ baseDelayMs?: number;
17
+ };
10
18
  export declare function resolveApiConfig(env: ApiConfig): {
11
19
  api: Api;
12
- environment: Environment;
20
+ network: Network;
13
21
  };
14
22
  export declare const computeSecret: (fromChain: Chain, toChain: Chain, wallets: Partial<Record<Chain, IBaseWallet>>, nonce: number) => Promise<string>;
15
- export declare const isFromChainBitcoin: (chain: Chain) => chain is "bitcoin" | "bitcoin_testnet" | "bitcoin_regtest";
23
+ export declare const isFromChainBitcoin: (chain: Chain) => chain is "bitcoin_regtest" | "bitcoin_testnet" | "bitcoin";
16
24
  /**
17
25
  * Given a hex string or a buffer, return the x-only pubkey. (removes y coordinate the prefix)
18
26
  */
@@ -31,7 +39,9 @@ export declare const toXOnly: (pubKey: string) => string;
31
39
  export declare const isValidBitcoinPubKey: (pubKey: string) => boolean;
32
40
  export declare const constructOrderPair: (sourceChain: Chain, sourceAsset: string, destChain: Chain, destAsset: string) => string;
33
41
  export declare function validateBTCAddress(address: string, networkType: Environment): boolean;
34
- export declare const getBitcoinNetwork: (network: Environment) => BitcoinNetwork;
42
+ export declare function generateOutputs(output: Buffer, count: number): Buffer[];
43
+ export declare const getBitcoinNetworkFromEnvironment: (network: Network) => BitcoinNetwork;
44
+ export declare const getBitcoinNetworkFromNetwork: (network: Network) => bitcoin.networks.Network;
35
45
  export declare const isHexString: (value: string) => boolean;
36
46
  export declare const formatStarknetSignature: (sig: Signature) => Err<string> | Ok<string[]>;
37
47
  export declare function reversify(val: string): Buffer;
@@ -39,3 +49,25 @@ export declare function isErrorWithMessage(err: unknown): err is {
39
49
  message: string;
40
50
  };
41
51
  export declare const waitForSolanaTxConfirmation: (connection: web3.Connection, txHash: string) => Promise<boolean>;
52
+ export declare const getAssetInfoFromOrder: (order: string, url: Url) => Promise<AsyncResult<{
53
+ htlcAddress: string;
54
+ tokenAddress: string;
55
+ }, string>>;
56
+ export declare const validateAmount: (amount: string) => Err<string> | Ok<BigNumber>;
57
+ export declare const withDefaultAffiliateFees: (list: AffiliateFee[] | undefined) => AffiliateFee[];
58
+ /**
59
+ *
60
+ * @param blockchainType
61
+ * @param htlcs
62
+ * @returns
63
+ */
64
+ export declare const getAddresses: (blockchainType: BlockchainType, htlcs: GardenHTLCModules) => Promise<Err<string> | Ok<string>>;
65
+ /**
66
+ * Validates that HTLCs are available for the required blockchain types for swap initiation
67
+ * @param blockchainType The blockchain type to check
68
+ * @returns AsyncResult<void, string>
69
+ */
70
+ export declare const validateHTLCForSwap: (blockchainType: BlockchainType, htlcs: GardenHTLCModules) => Promise<AsyncResult<void, string>>;
71
+ export declare const isAlreadyInitiatedError: (error: unknown) => boolean;
72
+ export declare const executeWithRelayerRetries: ({ attempt, wallet, maxAttempts, baseDelayMs, }: ExecuteWithRelayerRetriesArgs) => Promise<string | null>;
73
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/core",
3
- "version": "2.5.3",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",
@@ -28,8 +28,8 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@coral-xyz/anchor": "^0.31.1",
31
- "@gardenfi/orderbook": "2.5.3",
32
- "@gardenfi/utils": "2.5.3",
31
+ "@gardenfi/orderbook": "3.0.0",
32
+ "@gardenfi/utils": "3.0.0",
33
33
  "@mysten/signers": "^0.3.4",
34
34
  "@mysten/sui": "^1.37.1",
35
35
  "@mysten/wallet-standard": "^0.16.9",
@@ -39,6 +39,7 @@
39
39
  "bip39": "^3.1.0",
40
40
  "bitcoinjs-lib": "^6.1.5",
41
41
  "ecpair": "^2.1.0",
42
+ "node-cache": "^5.1.2",
42
43
  "starknet": "7.6.4",
43
44
  "tiny-secp256k1": "^2.2.3",
44
45
  "varuint-bitcoin": "^1.1.2",