@gardenfi/core 3.0.6 → 3.0.7-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-B3rC4a4B.cjs → ccip-C8VlkDwe.cjs} +1 -1
- package/dist/{ccip-CEYa5LHY.js → ccip-jpK2iyjO.js} +1 -1
- package/dist/{index-i5Tm5x54.js → index-Bs4peea5.js} +5811 -5581
- package/dist/{index-D8ji0NGd.cjs → index-SDqBa2QJ.cjs} +47 -47
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/src/lib/constants.d.ts +1 -0
- package/dist/src/lib/garden/executor/executor.d.ts +1 -0
- package/dist/src/lib/garden/garden.d.ts +1 -0
- package/dist/src/lib/garden/garden.types.d.ts +5 -0
- package/dist/src/lib/tron/abi/tronHtlcABI.d.ts +46 -0
- package/dist/src/lib/tron/relayer/tronRelay.d.ts +32 -0
- package/dist/src/lib/tron/tronHTLC.types.d.ts +28 -0
- package/dist/src/lib/tron/utils.d.ts +1 -0
- package/dist/src/lib/utils.d.ts +3 -2
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-SDqBa2QJ.cjs");exports.API=e.API;exports.BitcoinNetwork=e.BitcoinNetwork;exports.BitcoinProvider=e.BitcoinProvider;exports.BitcoinWallet=e.BitcoinWallet;exports.DEFAULT_AFFILIATE_ASSET=e.DEFAULT_AFFILIATE_ASSET;exports.EvmRelay=e.EvmRelay;exports.Garden=e.Garden;exports.Quote=e.Quote;exports.STARKNET_CONFIG=e.STARKNET_CONFIG;exports.SUI_CONFIG=e.SUI_CONFIG;exports.SecretManager=e.SecretManager;exports.SolanaHTLC=e.SolanaHTLC;exports.SolanaRelay=e.SolanaRelay;exports.SolanaRelayerAddress=e.SolanaRelayerAddress;exports.StarknetHTLC=e.StarknetHTLC;exports.StarknetRelay=e.StarknetRelay;exports.alpenTestnet=e.alpenTestnet;exports.botanixMainnet=e.botanixMainnet;exports.checkStarknetAlloance=e.checkAllowance;exports.checkStarknetAllowanceAndApprove=e.checkAllowanceAndApprove;exports.constructOrderPair=e.constructOrderPair;exports.evmToViemChainMap=e.evmToViemChainMap;exports.getChainNameFromChainId=e.getChainNameFromChainId;exports.hyperliquid=e.hyperliquid;exports.hyperliquidTestnet=e.hyperliquidTestnet;exports.isStarknetAllowanceSufficient=e.isAllowanceSufficient;exports.resolveApiConfig=e.resolveApiConfig;exports.solanaProgramAddress=e.solanaProgramAddress;exports.switchOrAddNetwork=e.switchOrAddNetwork;exports.toXOnly=e.toXOnly;exports.validateBTCAddress=e.validateBTCAddress;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as s, D as t, F as n, I as r, J as o, E as i, G as l, Q as A, L as d, M as c, m as S, k as T, j as k, N as C, h, S as p, A as m, u as y, p as I, n as v, q as F, w as N, x as u, y as w, z as E, o as O, r as L, O as R, C as f, t as g, v as B } from "./index-
|
|
1
|
+
import { K as s, D as t, F as n, I as r, J as o, E as i, G as l, Q as A, L as d, M as c, m as S, k as T, j as k, N as C, h, S as p, A as m, u as y, p as I, n as v, q as F, w as N, x as u, y as w, z as E, o as O, r as L, O as R, C as f, t as g, v as B } from "./index-Bs4peea5.js";
|
|
2
2
|
export {
|
|
3
3
|
s as API,
|
|
4
4
|
t as BitcoinNetwork,
|
|
@@ -37,6 +37,7 @@ export declare class Garden extends Orderbook implements IGardenJS {
|
|
|
37
37
|
readonly solana: import('../..').ISolanaHTLC | undefined;
|
|
38
38
|
readonly sui: import('../sui/suiHTLC.types').ISuiHTLC | undefined;
|
|
39
39
|
readonly bitcoin: import('../bitcoin/bitcoinhtlc.types').IBitcoinHTLC | undefined;
|
|
40
|
+
readonly tron: import('../tron/tronHTLC.types').ITronHTLC | undefined;
|
|
40
41
|
};
|
|
41
42
|
get quote(): IQuote;
|
|
42
43
|
get secretManager(): ISecretManager;
|
|
@@ -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
|
/**
|
|
@@ -144,6 +147,7 @@ export type GardenHTLCModules = {
|
|
|
144
147
|
solana?: ISolanaHTLC;
|
|
145
148
|
sui?: ISuiHTLC;
|
|
146
149
|
bitcoin?: IBitcoinHTLC;
|
|
150
|
+
tron?: ITronHTLC;
|
|
147
151
|
};
|
|
148
152
|
export type GardenWalletModules = {
|
|
149
153
|
evm?: WalletClient;
|
|
@@ -151,6 +155,7 @@ export type GardenWalletModules = {
|
|
|
151
155
|
solana?: AnchorProvider;
|
|
152
156
|
sui?: WalletWithRequiredFeatures | Ed25519Keypair;
|
|
153
157
|
bitcoin?: IBitcoinWallet;
|
|
158
|
+
tron?: TronWeb | Adapter;
|
|
154
159
|
};
|
|
155
160
|
export type GardenConfigWithWallets = GardenCoreConfig & {
|
|
156
161
|
wallets?: GardenWalletModules;
|
|
@@ -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;
|
package/dist/src/lib/utils.d.ts
CHANGED
|
@@ -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';
|
|
@@ -67,6 +67,7 @@ export declare const getAddresses: (blockchainType: BlockchainType, htlcs: Garde
|
|
|
67
67
|
* @returns AsyncResult<void, string>
|
|
68
68
|
*/
|
|
69
69
|
export declare const validateHTLCForSwap: (blockchainType: BlockchainType, htlcs: GardenHTLCModules) => Promise<AsyncResult<void, string>>;
|
|
70
|
+
export declare function redeemOrderThroughRelayer(order: Order, secret: string, auth: IAuth, url: Url): Promise<AsyncResult<string, string>>;
|
|
70
71
|
export declare const isAlreadyInitiatedError: (error: unknown) => boolean;
|
|
71
72
|
export declare const executeWithRelayerRetries: ({ attempt, wallet, maxAttempts, baseDelayMs, }: ExecuteWithRelayerRetriesArgs) => Promise<string | null>;
|
|
72
73
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gardenfi/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "vite build",
|
|
@@ -28,12 +28,13 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@coral-xyz/anchor": "^0.31.1",
|
|
31
|
-
"@gardenfi/orderbook": "3.0.5",
|
|
31
|
+
"@gardenfi/orderbook": "3.0.5-beta.4",
|
|
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",
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"node-cache": "^5.1.2",
|
|
43
44
|
"starknet": "7.6.4",
|
|
44
45
|
"tiny-secp256k1": "^2.2.3",
|
|
46
|
+
"tronweb": "^6.0.4",
|
|
45
47
|
"varuint-bitcoin": "^1.1.2",
|
|
46
48
|
"yup": "^1.4.0"
|
|
47
49
|
},
|