@gardenfi/core 3.0.7-beta.1 → 3.0.8-beta.1
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/{ccip-jpK2iyjO.js → ccip-DIaoe4OH.js} +1 -1
- package/dist/{ccip-C8VlkDwe.cjs → ccip-rfAqgfGh.cjs} +1 -1
- package/dist/{index-Bs4peea5.js → index-Cbo-609y.js} +14191 -12778
- package/dist/index-DlhJwfjq.cjs +104 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +30 -25
- package/dist/src/index.d.ts +4 -2
- package/dist/src/lib/constants.d.ts +6 -0
- package/dist/src/lib/evm/htlc/evmHTLC.d.ts +62 -62
- package/dist/src/lib/garden/executor/executor.d.ts +1 -0
- package/dist/src/lib/garden/garden.d.ts +4 -1
- package/dist/src/lib/garden/garden.types.d.ts +23 -3
- package/dist/src/lib/starknet/abi/starknetHtlcABI.d.ts +15 -21
- package/dist/src/lib/utils.d.ts +2 -1
- package/dist/src/lib/xrpl/xrplHTLC.d.ts +0 -0
- package/dist/src/lib/xrpl/xrplHTLC.types.d.ts +32 -0
- package/dist/src/lib/xrpl/xrplRelay.d.ts +26 -0
- package/package.json +8 -6
- package/dist/index-SDqBa2QJ.cjs +0 -106
|
@@ -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 {
|
|
@@ -38,6 +39,7 @@ export declare class Garden extends Orderbook implements IGardenJS {
|
|
|
38
39
|
readonly sui: import('../sui/suiHTLC.types').ISuiHTLC | undefined;
|
|
39
40
|
readonly bitcoin: import('../bitcoin/bitcoinhtlc.types').IBitcoinHTLC | undefined;
|
|
40
41
|
readonly tron: import('../tron/tronHTLC.types').ITronHTLC | undefined;
|
|
42
|
+
readonly xrpl: import('../..').IXrplHTLC | undefined;
|
|
41
43
|
};
|
|
42
44
|
get quote(): IQuote;
|
|
43
45
|
get secretManager(): ISecretManager;
|
|
@@ -48,9 +50,10 @@ export declare class Garden extends Orderbook implements IGardenJS {
|
|
|
48
50
|
/**
|
|
49
51
|
* Creates an order for a swap operation and initiates the HTLC on the source chain.
|
|
50
52
|
* @param params SwapParams
|
|
53
|
+
* @param onProgress Callback for order creation and initiation status
|
|
51
54
|
* @returns AsyncResult<Order, string>
|
|
52
55
|
*/
|
|
53
|
-
createSwap(params: SwapParams): AsyncResult<CreateOrderResponse | string, string>;
|
|
56
|
+
createSwap(params: SwapParams, onProgress?: (status: OrderCreationStatus) => void): AsyncResult<CreateOrderResponse | string, string>;
|
|
54
57
|
createOrder<T extends BlockchainType>(arg: CreateOrderRequest | SwapParams): AsyncResult<CreateOrderResponse<T>, string>;
|
|
55
58
|
private validateAndFillParams;
|
|
56
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,7 +9,7 @@ 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';
|
|
@@ -17,6 +17,9 @@ import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
|
17
17
|
import { ITronHTLC } from '../tron/tronHTLC.types';
|
|
18
18
|
import { Adapter } from '@tronweb3/tronwallet-abstract-adapter';
|
|
19
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';
|
|
20
23
|
|
|
21
24
|
export type SwapParams = {
|
|
22
25
|
/**
|
|
@@ -47,6 +50,14 @@ export type SwapParams = {
|
|
|
47
50
|
* Addresses for the order.
|
|
48
51
|
*/
|
|
49
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;
|
|
50
61
|
/**
|
|
51
62
|
* Integrator fee for the order.
|
|
52
63
|
*/
|
|
@@ -73,9 +84,10 @@ export interface IGardenJS extends IOrderbook {
|
|
|
73
84
|
/**
|
|
74
85
|
* Create Order
|
|
75
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'.
|
|
76
88
|
* @returns {AsyncResult<string, string>} The result of the swap operation.
|
|
77
89
|
*/
|
|
78
|
-
createSwap(params: SwapParams): AsyncResult<CreateOrderResponse | string, string>;
|
|
90
|
+
createSwap(params: SwapParams, onProgress?: (status: OrderCreationStatus) => void): AsyncResult<CreateOrderResponse | string, string>;
|
|
79
91
|
/**
|
|
80
92
|
* The current quote.
|
|
81
93
|
* @readonly
|
|
@@ -148,6 +160,9 @@ export type GardenHTLCModules = {
|
|
|
148
160
|
sui?: ISuiHTLC;
|
|
149
161
|
bitcoin?: IBitcoinHTLC;
|
|
150
162
|
tron?: ITronHTLC;
|
|
163
|
+
xrpl?: IXrplHTLC;
|
|
164
|
+
litecoin?: IBitcoinHTLC;
|
|
165
|
+
alpen_signet?: IBitcoinHTLC;
|
|
151
166
|
};
|
|
152
167
|
export type GardenWalletModules = {
|
|
153
168
|
evm?: WalletClient;
|
|
@@ -156,6 +171,7 @@ export type GardenWalletModules = {
|
|
|
156
171
|
sui?: WalletWithRequiredFeatures | Ed25519Keypair;
|
|
157
172
|
bitcoin?: IBitcoinWallet;
|
|
158
173
|
tron?: TronWeb | Adapter;
|
|
174
|
+
xrpl?: XrplWallet | CrossmarkSDK;
|
|
159
175
|
};
|
|
160
176
|
export type GardenConfigWithWallets = GardenCoreConfig & {
|
|
161
177
|
wallets?: GardenWalletModules;
|
|
@@ -169,4 +185,8 @@ export type ResponseTypeMap = {
|
|
|
169
185
|
[BlockchainType.starknet]: StarknetOrderResponse;
|
|
170
186
|
[BlockchainType.solana]: SolanaOrderResponse;
|
|
171
187
|
[BlockchainType.sui]: SuiOrderResponse;
|
|
188
|
+
[BlockchainType.tron]: EvmOrderResponse;
|
|
189
|
+
[BlockchainType.xrpl]: XrplOrderResponse;
|
|
190
|
+
[BlockchainType.litecoin]: BitcoinOrderResponse;
|
|
191
|
+
[BlockchainType.alpen_signet]: BitcoinOrderResponse;
|
|
172
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
|
-
|
|
26
|
-
|
|
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:
|
|
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;
|
package/dist/src/lib/utils.d.ts
CHANGED
|
@@ -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;
|
|
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.
|
|
3
|
+
"version": "3.0.8-beta.1",
|
|
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": "
|
|
9
|
+
"link": "bun link"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist"
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@coral-xyz/anchor": "^0.31.1",
|
|
31
|
-
"@gardenfi/orderbook": "3.0.
|
|
32
|
-
"@gardenfi/utils": "3.0.0",
|
|
31
|
+
"@gardenfi/orderbook": "3.0.6-beta.1",
|
|
32
|
+
"@gardenfi/utils": "3.0.0-beta.3",
|
|
33
33
|
"@mysten/signers": "^0.3.4",
|
|
34
34
|
"@mysten/sui": "^1.37.1",
|
|
35
35
|
"@mysten/wallet-standard": "^0.16.9",
|
|
@@ -39,12 +39,14 @@
|
|
|
39
39
|
"bip32": "^4.0.0",
|
|
40
40
|
"bip39": "^3.1.0",
|
|
41
41
|
"bitcoinjs-lib": "^6.1.5",
|
|
42
|
+
"bitcore-lib-ltc": "^10.10.5",
|
|
42
43
|
"ecpair": "^2.1.0",
|
|
43
44
|
"node-cache": "^5.1.2",
|
|
44
|
-
"starknet": "
|
|
45
|
+
"starknet": "8.0.0",
|
|
45
46
|
"tiny-secp256k1": "^2.2.3",
|
|
46
47
|
"tronweb": "^6.0.4",
|
|
47
48
|
"varuint-bitcoin": "^1.1.2",
|
|
49
|
+
"xrpl": "^4.5.0",
|
|
48
50
|
"yup": "^1.4.0"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
@@ -55,4 +57,4 @@
|
|
|
55
57
|
"vitest": "^1.6.0"
|
|
56
58
|
},
|
|
57
59
|
"sideEffects": false
|
|
58
|
-
}
|
|
60
|
+
}
|