@gardenfi/core 3.0.7 → 3.0.8-beta.3

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.
@@ -3,6 +3,7 @@ import { IGardenJS, SwapParams, GardenConfigWithHTLCs, GardenConfigWithWallets,
3
3
  import { BlockchainType, CreateOrderRequest, CreateOrderResponse, Orderbook } from '@gardenfi/orderbook';
4
4
  import { IAuth, DigestKey, AsyncResult } from '@gardenfi/utils';
5
5
  import { IQuote } from '../quote/quote.types';
6
+ import { OrderCreationStatus } from '../constants';
6
7
  import { Executor } from './executor/executor';
7
8
 
8
9
  export declare class Garden extends Orderbook implements IGardenJS {
@@ -37,6 +38,8 @@ export declare class Garden extends Orderbook implements IGardenJS {
37
38
  readonly solana: import('../..').ISolanaHTLC | undefined;
38
39
  readonly sui: import('../sui/suiHTLC.types').ISuiHTLC | undefined;
39
40
  readonly bitcoin: import('../bitcoin/bitcoinhtlc.types').IBitcoinHTLC | undefined;
41
+ readonly tron: import('../tron/tronHTLC.types').ITronHTLC | undefined;
42
+ readonly xrpl: import('../..').IXrplHTLC | undefined;
40
43
  };
41
44
  get quote(): IQuote;
42
45
  get secretManager(): ISecretManager;
@@ -47,9 +50,10 @@ export declare class Garden extends Orderbook implements IGardenJS {
47
50
  /**
48
51
  * Creates an order for a swap operation and initiates the HTLC on the source chain.
49
52
  * @param params SwapParams
53
+ * @param onProgress Callback for order creation and initiation status
50
54
  * @returns AsyncResult<Order, string>
51
55
  */
52
- createSwap(params: SwapParams): AsyncResult<CreateOrderResponse | string, string>;
56
+ createSwap(params: SwapParams, onProgress?: (status: OrderCreationStatus) => void): AsyncResult<CreateOrderResponse | string, string>;
53
57
  createOrder<T extends BlockchainType>(arg: CreateOrderRequest | SwapParams): AsyncResult<CreateOrderResponse<T>, string>;
54
58
  private validateAndFillParams;
55
59
  private _getAddresses;
@@ -1,4 +1,4 @@
1
- import { AffiliateFee, AssetLike, BitcoinOrderResponse, BlockchainType, EvmOrderResponse, IOrderbook, Order, OrderAction, OrderStatus, SolanaOrderResponse, StarknetOrderResponse, SuiOrderResponse, CreateOrderResponse } from '@gardenfi/orderbook';
1
+ import { AffiliateFee, AssetLike, BitcoinOrderResponse, BlockchainType, EvmOrderResponse, IOrderbook, Order, OrderAction, OrderStatus, SolanaOrderResponse, StarknetOrderResponse, SuiOrderResponse, XrplOrderResponse, CreateOrderResponse } from '@gardenfi/orderbook';
2
2
  import { ApiKey, AsyncResult, IAuth, Network, DigestKey } from '@gardenfi/utils';
3
3
  import { ISecretManager } from '../secretManager/secretManager.types';
4
4
  import { IQuote } from '../quote/quote.types';
@@ -9,11 +9,17 @@ import { WalletClient } from 'viem';
9
9
  import { IBitcoinWallet } from '../bitcoin/wallet/wallet.interface';
10
10
  import { ISolanaHTLC } from '../solana/htlc/ISolanaHTLC';
11
11
  import { AnchorProvider } from '@coral-xyz/anchor';
12
- import { Api } from '../constants';
12
+ import { Api, OrderCreationStatus } from '../constants';
13
13
  import { ISuiHTLC } from '../sui/suiHTLC.types';
14
14
  import { WalletWithRequiredFeatures } from '@mysten/wallet-standard';
15
15
  import { IBitcoinHTLC } from '../bitcoin/bitcoinhtlc.types';
16
16
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
17
+ import { ITronHTLC } from '../tron/tronHTLC.types';
18
+ import { Adapter } from '@tronweb3/tronwallet-abstract-adapter';
19
+ import { TronWeb } from 'tronweb';
20
+ import { IXrplHTLC } from '../xrpl/xrplHTLC.types';
21
+ import { Wallet as XrplWallet } from 'xrpl';
22
+ import { vanilla as CrossmarkSDK } from '@crossmarkio/sdk';
17
23
 
18
24
  export type SwapParams = {
19
25
  /**
@@ -44,6 +50,14 @@ export type SwapParams = {
44
50
  * Addresses for the order.
45
51
  */
46
52
  addresses?: Partial<Record<BlockchainType, string>>;
53
+ /**
54
+ * Address for source chain.
55
+ */
56
+ sourceAddress?: string;
57
+ /**
58
+ * Address for destination chain.
59
+ */
60
+ destinationAddress?: string;
47
61
  /**
48
62
  * Integrator fee for the order.
49
63
  */
@@ -70,9 +84,10 @@ export interface IGardenJS extends IOrderbook {
70
84
  /**
71
85
  * Create Order
72
86
  * @param {SwapParams} params - The parameters for creating the order.
87
+ * @param {SwapProgressCallback} onProgress - Optional callback for progress messages: 'order created', 'order initiating', 'order initiated'.
73
88
  * @returns {AsyncResult<string, string>} The result of the swap operation.
74
89
  */
75
- createSwap(params: SwapParams): AsyncResult<CreateOrderResponse | string, string>;
90
+ createSwap(params: SwapParams, onProgress?: (status: OrderCreationStatus) => void): AsyncResult<CreateOrderResponse | string, string>;
76
91
  /**
77
92
  * The current quote.
78
93
  * @readonly
@@ -144,6 +159,10 @@ export type GardenHTLCModules = {
144
159
  solana?: ISolanaHTLC;
145
160
  sui?: ISuiHTLC;
146
161
  bitcoin?: IBitcoinHTLC;
162
+ tron?: ITronHTLC;
163
+ xrpl?: IXrplHTLC;
164
+ litecoin?: IBitcoinHTLC;
165
+ alpen_signet?: IBitcoinHTLC;
147
166
  };
148
167
  export type GardenWalletModules = {
149
168
  evm?: WalletClient;
@@ -151,6 +170,8 @@ export type GardenWalletModules = {
151
170
  solana?: AnchorProvider;
152
171
  sui?: WalletWithRequiredFeatures | Ed25519Keypair;
153
172
  bitcoin?: IBitcoinWallet;
173
+ tron?: TronWeb | Adapter;
174
+ xrpl?: XrplWallet | CrossmarkSDK;
154
175
  };
155
176
  export type GardenConfigWithWallets = GardenCoreConfig & {
156
177
  wallets?: GardenWalletModules;
@@ -164,4 +185,8 @@ export type ResponseTypeMap = {
164
185
  [BlockchainType.starknet]: StarknetOrderResponse;
165
186
  [BlockchainType.solana]: SolanaOrderResponse;
166
187
  [BlockchainType.sui]: SuiOrderResponse;
188
+ [BlockchainType.tron]: EvmOrderResponse;
189
+ [BlockchainType.xrpl]: XrplOrderResponse;
190
+ [BlockchainType.litecoin]: BitcoinOrderResponse;
191
+ [BlockchainType.alpen_signet]: BitcoinOrderResponse;
167
192
  };
@@ -1,6 +1,6 @@
1
1
  export declare const starknetHtlcABI: ({
2
- name: string;
3
2
  type: string;
3
+ name: string;
4
4
  interface_name: string;
5
5
  members?: undefined;
6
6
  items?: undefined;
@@ -8,8 +8,8 @@ export declare const starknetHtlcABI: ({
8
8
  kind?: undefined;
9
9
  variants?: undefined;
10
10
  } | {
11
- name: string;
12
11
  type: string;
12
+ name: string;
13
13
  members: {
14
14
  name: string;
15
15
  type: string;
@@ -20,34 +20,28 @@ export declare const starknetHtlcABI: ({
20
20
  kind?: undefined;
21
21
  variants?: undefined;
22
22
  } | {
23
- name: string;
24
23
  type: string;
25
- items: ({
26
- name: string;
24
+ name: string;
25
+ items: {
27
26
  type: string;
28
- inputs: never[];
29
- outputs: {
30
- type: string;
31
- }[];
32
- state_mutability: string;
33
- } | {
34
27
  name: string;
35
- type: string;
36
28
  inputs: {
37
29
  name: string;
38
30
  type: string;
39
31
  }[];
40
- outputs: never[];
32
+ outputs: {
33
+ type: string;
34
+ }[];
41
35
  state_mutability: string;
42
- })[];
36
+ }[];
43
37
  interface_name?: undefined;
44
38
  members?: undefined;
45
39
  inputs?: undefined;
46
40
  kind?: undefined;
47
41
  variants?: undefined;
48
42
  } | {
49
- name: string;
50
43
  type: string;
44
+ name: string;
51
45
  inputs: {
52
46
  name: string;
53
47
  type: string;
@@ -58,26 +52,26 @@ export declare const starknetHtlcABI: ({
58
52
  kind?: undefined;
59
53
  variants?: undefined;
60
54
  } | {
61
- kind: string;
62
- name: string;
63
55
  type: string;
56
+ name: string;
57
+ kind: string;
64
58
  members: {
65
- kind: string;
66
59
  name: string;
67
60
  type: string;
61
+ kind: string;
68
62
  }[];
69
63
  interface_name?: undefined;
70
64
  items?: undefined;
71
65
  inputs?: undefined;
72
66
  variants?: undefined;
73
67
  } | {
74
- kind: string;
75
- name: string;
76
68
  type: string;
69
+ name: string;
70
+ kind: string;
77
71
  variants: {
78
- kind: string;
79
72
  name: string;
80
73
  type: string;
74
+ kind: string;
81
75
  }[];
82
76
  interface_name?: undefined;
83
77
  members?: undefined;
@@ -0,0 +1,46 @@
1
+ export declare const tronHtlcAbi: ({
2
+ inputs: never[];
3
+ stateMutability: string;
4
+ type: string;
5
+ name?: undefined;
6
+ anonymous?: undefined;
7
+ outputs?: undefined;
8
+ } | {
9
+ inputs: {
10
+ internalType: string;
11
+ name: string;
12
+ type: string;
13
+ }[];
14
+ name: string;
15
+ type: string;
16
+ stateMutability?: undefined;
17
+ anonymous?: undefined;
18
+ outputs?: undefined;
19
+ } | {
20
+ anonymous: boolean;
21
+ inputs: {
22
+ indexed: boolean;
23
+ internalType: string;
24
+ name: string;
25
+ type: string;
26
+ }[];
27
+ name: string;
28
+ type: string;
29
+ stateMutability?: undefined;
30
+ outputs?: undefined;
31
+ } | {
32
+ inputs: {
33
+ internalType: string;
34
+ name: string;
35
+ type: string;
36
+ }[];
37
+ name: string;
38
+ outputs: {
39
+ internalType: string;
40
+ name: string;
41
+ type: string;
42
+ }[];
43
+ stateMutability: string;
44
+ type: string;
45
+ anonymous?: undefined;
46
+ })[];
@@ -0,0 +1,32 @@
1
+ import { Order, EvmOrderResponse } from '@gardenfi/orderbook';
2
+ import { AsyncResult, IAuth, Network, Url } from '@gardenfi/utils';
3
+ import { ITronHTLC } from '../tronHTLC.types';
4
+ import { TronWeb } from 'tronweb';
5
+ import { Adapter } from '@tronweb3/tronwallet-abstract-adapter';
6
+
7
+ export declare class TronRelay implements ITronHTLC {
8
+ private url;
9
+ private auth;
10
+ private tronweb;
11
+ private wallet;
12
+ private relayer;
13
+ constructor(relayerUrl: string | Url, network: Network, auth: IAuth, wallet: TronWeb | Adapter);
14
+ get htlcActorAddress(): string;
15
+ initiate(order: Order | EvmOrderResponse): AsyncResult<string, string>;
16
+ private initiateDirectContractCall;
17
+ private executeApprovalTransaction;
18
+ /**
19
+ * Unified method to execute contract calls with signing and broadcasting
20
+ */
21
+ private executeContractCall;
22
+ /**
23
+ * Unified signing method
24
+ */
25
+ private signTransaction;
26
+ /**
27
+ * Wait for transaction confirmation on-chain
28
+ */
29
+ private waitForTransactionConfirmation;
30
+ redeem(order: Order, secret: string): AsyncResult<string, string>;
31
+ refund(): AsyncResult<string, string>;
32
+ }
@@ -0,0 +1,28 @@
1
+ import { Order, EvmOrderResponse } from '@gardenfi/orderbook';
2
+ import { AsyncResult } from '@gardenfi/utils';
3
+
4
+ export interface ITronHTLC {
5
+ /**
6
+ * The address of the HTLC actor.
7
+ */
8
+ get htlcActorAddress(): string;
9
+ /**
10
+ * Initiates the HTLC by sending funds to the HTLC contract.
11
+ * @param order - The matched order.
12
+ * @returns A promise resolving to the transaction hash of the initiation.
13
+ */
14
+ initiate(order: Order | EvmOrderResponse): AsyncResult<string, string>;
15
+ /**
16
+ * Redeems funds from the HTLC contract to the actor's address.
17
+ * @param order - The matched order.
18
+ * @param secret - The secret required to unlock the htlc.
19
+ * @returns A promise resolving to the transaction hash of the redemption.
20
+ */
21
+ redeem(order: Order, secret: string): AsyncResult<string, string>;
22
+ /**
23
+ * Refunds funds from the HTLC contract back to the actor's address upon expiration.
24
+ * @param order - The matched order.
25
+ * @returns A promise resolving to the transaction hash of the refund.
26
+ */
27
+ refund(order: Order): AsyncResult<string, string>;
28
+ }
@@ -0,0 +1 @@
1
+ export declare function toBytes32Hex(value: string): string;
@@ -1,5 +1,5 @@
1
- import { AsyncResult, Environment, Err, Ok, Url, Network } from '@gardenfi/utils';
2
- import { BlockchainType, Chain } from '@gardenfi/orderbook';
1
+ import { AsyncResult, Environment, Err, Ok, Url, Network, IAuth } from '@gardenfi/utils';
2
+ import { BlockchainType, Chain, Order } from '@gardenfi/orderbook';
3
3
  import { WalletClient } from 'viem';
4
4
  import { Signature } from 'starknet';
5
5
  import { Api } from './constants';
@@ -39,11 +39,12 @@ export declare const toXOnly: (pubKey: string) => string;
39
39
  export declare const isValidBitcoinPubKey: (pubKey: string) => boolean;
40
40
  export declare const constructOrderPair: (sourceChain: Chain, sourceAsset: string, destChain: Chain, destAsset: string) => string;
41
41
  export declare function validateBTCAddress(address: string, networkType: Environment): boolean;
42
+ export declare function validateLTCAddress(address: string, networkType: Environment): boolean;
42
43
  export declare function generateOutputs(output: Buffer, count: number): Buffer[];
43
44
  export declare const getBitcoinNetworkFromEnvironment: (network: Network) => BitcoinNetwork;
44
45
  export declare const getBitcoinNetworkFromNetwork: (network: Network) => bitcoin.networks.Network;
45
46
  export declare const isHexString: (value: string) => boolean;
46
- export declare const formatStarknetSignature: (sig: Signature) => Err<string> | Ok<string[]>;
47
+ export declare const formatStarknetSignature: (sig: Signature) => Err<string> | Ok<string> | Ok<string[]>;
47
48
  export declare function reversify(val: string): Buffer;
48
49
  export declare function isErrorWithMessage(err: unknown): err is {
49
50
  message: string;
@@ -67,6 +68,7 @@ export declare const getAddresses: (blockchainType: BlockchainType, htlcs: Garde
67
68
  * @returns AsyncResult<void, string>
68
69
  */
69
70
  export declare const validateHTLCForSwap: (blockchainType: BlockchainType, htlcs: GardenHTLCModules) => Promise<AsyncResult<void, string>>;
71
+ export declare function redeemOrderThroughRelayer(order: Order, secret: string, auth: IAuth, url: Url): Promise<AsyncResult<string, string>>;
70
72
  export declare const isAlreadyInitiatedError: (error: unknown) => boolean;
71
73
  export declare const executeWithRelayerRetries: ({ attempt, wallet, maxAttempts, baseDelayMs, }: ExecuteWithRelayerRetriesArgs) => Promise<string | null>;
72
74
  export {};
File without changes
@@ -0,0 +1,32 @@
1
+ import { Order, XrplOrderResponse } from '@gardenfi/orderbook';
2
+ import { AsyncResult } from '@gardenfi/utils';
3
+ import { EscrowCancel, EscrowCreate, EscrowFinish, Wallet as XrplWallet } from 'xrpl';
4
+ import { vanilla as CrossmarkSDK } from '@crossmarkio/sdk';
5
+
6
+ export type SupportedWallet = XrplWallet | CrossmarkSDK;
7
+ export type SupportedTx = EscrowCreate | EscrowFinish | EscrowCancel;
8
+ export interface IXrplHTLC {
9
+ /**
10
+ * The address of the HTLC actor.
11
+ */
12
+ get htlcActorAddress(): string;
13
+ /**
14
+ * Initiates the HTLC by sending funds to the HTLC contract.
15
+ * @param order - The matched order.
16
+ * @returns A promise resolving to the transaction hash of the initiation.
17
+ */
18
+ initiate(order: Order | XrplOrderResponse): AsyncResult<string, string>;
19
+ /**
20
+ * Redeems funds from the HTLC contract to the actor's address.
21
+ * @param order - The matched order.
22
+ * @param secret - The secret required to unlock the htlc.
23
+ * @returns A promise resolving to the transaction hash of the redemption.
24
+ */
25
+ redeem(order: Order, secret: string): AsyncResult<string, string>;
26
+ /**
27
+ * Refunds funds from the HTLC contract back to the actor's address upon expiration.
28
+ * @param order - The matched order.
29
+ * @returns A promise resolving to the transaction hash of the refund.
30
+ */
31
+ refund(order: Order): AsyncResult<string, string>;
32
+ }
@@ -0,0 +1,26 @@
1
+ import { Order, XrplOrderResponse } from '@gardenfi/orderbook';
2
+ import { AsyncResult, IAuth, Network, Url } from '@gardenfi/utils';
3
+ import { IXrplHTLC, SupportedWallet } from './xrplHTLC.types';
4
+
5
+ export declare class XrplRelay implements IXrplHTLC {
6
+ private url;
7
+ private auth;
8
+ private client;
9
+ private wallet;
10
+ private relayer;
11
+ constructor(relayerUrl: string | Url, network: Network, auth: IAuth, wallet: SupportedWallet);
12
+ private isXrplWallet;
13
+ private isCrossmarkWallet;
14
+ get htlcActorAddress(): string;
15
+ initiate(order: Order | XrplOrderResponse): AsyncResult<string, string>;
16
+ private initiateFromOrderResponse;
17
+ private initiateFromOrder;
18
+ redeem(order: Order, secret: string): AsyncResult<string, string>;
19
+ refund(): AsyncResult<string, string>;
20
+ private submitTransaction;
21
+ private signPreparedTransaction;
22
+ /**
23
+ * Builds the condition string from hash (ASN.1 DER encoding)
24
+ */
25
+ private buildCondition;
26
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@gardenfi/core",
3
- "version": "3.0.7",
3
+ "version": "3.0.8-beta.3",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",
7
7
  "test": "vitest run",
8
8
  "dev": "vite build --watch",
9
- "link": "yarn link"
9
+ "link": "bun link"
10
10
  },
11
11
  "files": [
12
12
  "dist"
@@ -28,21 +28,25 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@coral-xyz/anchor": "^0.31.1",
31
- "@gardenfi/orderbook": "3.0.5",
32
- "@gardenfi/utils": "3.0.0",
31
+ "@gardenfi/orderbook": "3.0.6-beta.2",
32
+ "@gardenfi/utils": "3.0.0-beta.4",
33
33
  "@mysten/signers": "^0.3.4",
34
34
  "@mysten/sui": "^1.37.1",
35
35
  "@mysten/wallet-standard": "^0.16.9",
36
36
  "@solana/spl-token": "^0.4.13",
37
+ "@tronweb3/tronwallet-abstract-adapter": "^1.1.9",
37
38
  "bignumber.js": "^9.1.2",
38
39
  "bip32": "^4.0.0",
39
40
  "bip39": "^3.1.0",
40
41
  "bitcoinjs-lib": "^6.1.5",
42
+ "bitcore-lib-ltc": "^10.10.5",
41
43
  "ecpair": "^2.1.0",
42
44
  "node-cache": "^5.1.2",
43
- "starknet": "7.6.4",
45
+ "starknet": "8.0.0",
44
46
  "tiny-secp256k1": "^2.2.3",
47
+ "tronweb": "^6.0.4",
45
48
  "varuint-bitcoin": "^1.1.2",
49
+ "xrpl": "^4.5.0",
46
50
  "yup": "^1.4.0"
47
51
  },
48
52
  "devDependencies": {
@@ -53,4 +57,4 @@
53
57
  "vitest": "^1.6.0"
54
58
  },
55
59
  "sideEffects": false
56
- }
60
+ }