@gardenfi/core 3.0.5 → 3.0.6-beta.10

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.
@@ -14,6 +14,9 @@ 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';
17
20
 
18
21
  export type SwapParams = {
19
22
  /**
@@ -44,6 +47,14 @@ export type SwapParams = {
44
47
  * Addresses for the order.
45
48
  */
46
49
  addresses?: Partial<Record<BlockchainType, string>>;
50
+ /**
51
+ * Address for source chain.
52
+ */
53
+ sourceAddress?: string;
54
+ /**
55
+ * Address for destination chain.
56
+ */
57
+ destinationAddress?: string;
47
58
  /**
48
59
  * Integrator fee for the order.
49
60
  */
@@ -144,6 +155,9 @@ export type GardenHTLCModules = {
144
155
  solana?: ISolanaHTLC;
145
156
  sui?: ISuiHTLC;
146
157
  bitcoin?: IBitcoinHTLC;
158
+ tron?: ITronHTLC;
159
+ litecoin?: IBitcoinHTLC;
160
+ alpen_signet?: IBitcoinHTLC;
147
161
  };
148
162
  export type GardenWalletModules = {
149
163
  evm?: WalletClient;
@@ -151,6 +165,7 @@ export type GardenWalletModules = {
151
165
  solana?: AnchorProvider;
152
166
  sui?: WalletWithRequiredFeatures | Ed25519Keypair;
153
167
  bitcoin?: IBitcoinWallet;
168
+ tron?: TronWeb | Adapter;
154
169
  };
155
170
  export type GardenConfigWithWallets = GardenCoreConfig & {
156
171
  wallets?: GardenWalletModules;
@@ -164,4 +179,6 @@ export type ResponseTypeMap = {
164
179
  [BlockchainType.starknet]: StarknetOrderResponse;
165
180
  [BlockchainType.solana]: SolanaOrderResponse;
166
181
  [BlockchainType.sui]: SuiOrderResponse;
182
+ [BlockchainType.litecoin]: BitcoinOrderResponse;
183
+ [BlockchainType.alpen_signet]: BitcoinOrderResponse;
167
184
  };
@@ -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 { AffiliateFee, 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,6 +39,7 @@ 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;
@@ -54,7 +55,6 @@ export declare const getAssetInfoFromOrder: (order: string, url: Url) => Promise
54
55
  tokenAddress: string;
55
56
  }, string>>;
56
57
  export declare const validateAmount: (amount: string) => Err<string> | Ok<BigNumber>;
57
- export declare const withDefaultAffiliateFees: (list: AffiliateFee[] | undefined) => AffiliateFee[];
58
58
  /**
59
59
  *
60
60
  * @param blockchainType
@@ -68,6 +68,7 @@ export declare const getAddresses: (blockchainType: BlockchainType, htlcs: Garde
68
68
  * @returns AsyncResult<void, string>
69
69
  */
70
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>>;
71
72
  export declare const isAlreadyInitiatedError: (error: unknown) => boolean;
72
73
  export declare const executeWithRelayerRetries: ({ attempt, wallet, maxAttempts, baseDelayMs, }: ExecuteWithRelayerRetriesArgs) => Promise<string | null>;
73
74
  export {};
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@gardenfi/core",
3
- "version": "3.0.5",
3
+ "version": "3.0.6-beta.10",
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,20 +28,23 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@coral-xyz/anchor": "^0.31.1",
31
- "@gardenfi/orderbook": "3.0.4",
31
+ "@gardenfi/orderbook": "3.0.5-beta.7",
32
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",
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
45
  "starknet": "7.6.4",
44
46
  "tiny-secp256k1": "^2.2.3",
47
+ "tronweb": "^6.0.4",
45
48
  "varuint-bitcoin": "^1.1.2",
46
49
  "yup": "^1.4.0"
47
50
  },
@@ -53,4 +56,4 @@
53
56
  "vitest": "^1.6.0"
54
57
  },
55
58
  "sideEffects": false
56
- }
59
+ }