@gardenfi/core 2.0.25 → 2.1.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.
@@ -1,16 +1,13 @@
1
1
  import { ISecretManager } from './../secretManager/secretManager.types';
2
2
  import { AsyncResult } from '@catalogfi/utils';
3
- import { GardenEvents, GardenProps, IGardenJS, SwapParams } from './garden.types';
3
+ import { GardenEvents, IGardenJS, SwapParams, GardenConfigWithHTLCs, GardenConfigWithWallets } from './garden.types';
4
4
  import { IOrderbook, MatchedOrder } from '@gardenfi/orderbook';
5
- import { Environment, EventBroker, IAuth } from '@gardenfi/utils';
5
+ import { EventBroker, IAuth, DigestKey } from '@gardenfi/utils';
6
6
  import { IQuote } from '../quote/quote.types';
7
7
  import { IBitcoinWallet } from '@catalogfi/wallets';
8
8
  import { IBlockNumberFetcher } from '../blockNumberFetcher/blockNumber';
9
9
  import { IEVMHTLC } from '../evm/htlc.types';
10
- import { DigestKey } from './digestKey/digestKey';
11
- import { WalletClient } from 'viem';
12
10
  import { IStarknetHTLC } from '../starknet/starknetHTLC.types';
13
- import { Account } from 'starknet';
14
11
 
15
12
  export declare class Garden extends EventBroker<GardenEvents> implements IGardenJS {
16
13
  private environment;
@@ -18,7 +15,6 @@ export declare class Garden extends EventBroker<GardenEvents> implements IGarden
18
15
  private _orderbook;
19
16
  private _quote;
20
17
  private getOrderThreshold;
21
- private _orderbookUrl;
22
18
  private _auth;
23
19
  private orderExecutorCache;
24
20
  private _blockNumberFetcher;
@@ -28,16 +24,9 @@ export declare class Garden extends EventBroker<GardenEvents> implements IGarden
28
24
  private _btcWallet;
29
25
  private bitcoinRedeemCache;
30
26
  private _digestKey;
31
- constructor(config: GardenProps);
32
- static from(config: {
33
- environment: Environment;
34
- digestKey: string;
35
- wallets: {
36
- evm: WalletClient;
37
- starknet: Account;
38
- };
39
- }): Garden;
40
- get orderbookUrl(): string;
27
+ private _api;
28
+ constructor(config: GardenConfigWithHTLCs);
29
+ static fromWallets(config: GardenConfigWithWallets): Garden;
41
30
  get evmHTLC(): IEVMHTLC | undefined;
42
31
  get starknetHTLC(): IStarknetHTLC | undefined;
43
32
  get quote(): IQuote;
@@ -1,14 +1,16 @@
1
1
  import { AsyncResult } from '@catalogfi/utils';
2
2
  import { Asset, IOrderbook, MatchedOrder } from '@gardenfi/orderbook';
3
3
  import { OrderStatus } from '../orderStatus/status';
4
- import { Environment, EventBroker, IAuth } from '@gardenfi/utils';
4
+ import { Environment, EventBroker, IAuth, DigestKey } from '@gardenfi/utils';
5
5
  import { ISecretManager } from '../secretManager/secretManager.types';
6
6
  import { IQuote } from '../quote/quote.types';
7
7
  import { IBlockNumberFetcher } from '../blockNumberFetcher/blockNumber';
8
8
  import { IBitcoinWallet } from '@catalogfi/wallets';
9
9
  import { IEVMHTLC } from '../evm/htlc.types';
10
- import { DigestKey } from './digestKey/digestKey';
11
10
  import { IStarknetHTLC } from '../starknet/starknetHTLC.types';
11
+ import { AccountInterface } from 'starknet';
12
+ import { WalletClient } from 'viem';
13
+ import { Api } from '../constants';
12
14
 
13
15
  export type SwapParams = {
14
16
  /**
@@ -79,11 +81,6 @@ export interface IGardenJS extends EventBroker<GardenEvents> {
79
81
  * @returns {Promise<() => void>} A promise that resolves to a function to cancel the execution.
80
82
  */
81
83
  execute(): Promise<() => void>;
82
- /**
83
- * The URL of the orderbook.
84
- * @readonly
85
- */
86
- get orderbookUrl(): string;
87
84
  /**
88
85
  * The EVM relay.
89
86
  * @readonly
@@ -140,19 +137,29 @@ export interface IOrderExecutorCache {
140
137
  get(order: MatchedOrder, action: OrderActions): OrderCacheValue | null;
141
138
  remove(order: MatchedOrder, action: OrderActions): void;
142
139
  }
143
- export type GardenProps = {
144
- environment: Environment;
145
- digestKey: string;
146
- api?: string;
140
+ export type GardenCoreConfig = {
141
+ environment: Environment | Api;
142
+ digestKey: string | DigestKey;
147
143
  secretManager?: ISecretManager;
144
+ auth?: IAuth;
148
145
  orderbook?: IOrderbook;
149
146
  quote?: IQuote;
150
147
  blockNumberFetcher?: IBlockNumberFetcher;
148
+ };
149
+ export type GardenHTLCModules = {
151
150
  htlc: {
152
151
  evm?: IEVMHTLC;
153
152
  starknet?: IStarknetHTLC;
154
153
  };
155
154
  };
155
+ export type GardenWalletModules = {
156
+ wallets: {
157
+ evm?: WalletClient;
158
+ starknet?: AccountInterface;
159
+ };
160
+ };
161
+ export type GardenConfigWithWallets = GardenCoreConfig & GardenWalletModules;
162
+ export type GardenConfigWithHTLCs = GardenCoreConfig & GardenHTLCModules;
156
163
  /**
157
164
  * Actions that can be performed on the order.
158
165
  */
@@ -1,4 +1,4 @@
1
- import { Account } from 'starknet';
1
+ import { AccountInterface } from 'starknet';
2
2
  import { AsyncResult } from '@catalogfi/utils';
3
3
 
4
- export declare const checkAllowanceAndApprove: (account: Account, tokenAddress: string, htlcAddress: string, amount: bigint, nodeUrl: string) => AsyncResult<string, string>;
4
+ export declare const checkAllowanceAndApprove: (account: AccountInterface, tokenAddress: string, htlcAddress: string, amount: bigint, nodeUrl: string) => AsyncResult<string, string>;
@@ -1,4 +1,4 @@
1
- import { Account } from 'starknet';
1
+ import { AccountInterface } from 'starknet';
2
2
  import { MatchedOrder } from '@gardenfi/orderbook';
3
3
  import { AsyncResult } from '@catalogfi/utils';
4
4
  import { Url } from '@gardenfi/utils';
@@ -8,7 +8,7 @@ export declare class StarknetRelay implements IStarknetHTLC {
8
8
  private url;
9
9
  private nodeUrl;
10
10
  private account;
11
- constructor(relayerUrl: string | Url, account: Account, nodeUrl?: string);
11
+ constructor(relayerUrl: string | Url, account: AccountInterface, nodeUrl?: string);
12
12
  get htlcActorAddress(): string;
13
13
  initiate(order: MatchedOrder): AsyncResult<string, string>;
14
14
  redeem(order: MatchedOrder, secret: string): AsyncResult<string, string>;
@@ -3,6 +3,8 @@ import { Chain, EvmChain } from '@gardenfi/orderbook';
3
3
  import { WalletClient } from 'viem';
4
4
  import { AsyncResult } from '@catalogfi/utils';
5
5
 
6
+ export declare const hyperliquidTestnet: viemChain;
7
+ export declare const hyperliquid: viemChain;
6
8
  export declare const evmToViemChainMap: Record<EvmChain, viemChain>;
7
9
  /**
8
10
  * Switches or adds a network to the wallet
@@ -12,12 +12,12 @@ export declare function assert(condition: boolean, message: string): void;
12
12
  /**
13
13
  * concat the leaf version, the length of the script, and the script itself
14
14
  */
15
- export declare function serializeScript(leafScript: Buffer): Buffer;
15
+ export declare function serializeScript(leafScript: Buffer): Buffer<ArrayBuffer>;
16
16
  /**
17
17
  * concat the length of the script and the script itself
18
18
  */
19
19
  export declare function prefixScriptLength(s: Buffer): Buffer;
20
- export declare function sortLeaves(leaf1: Buffer, leaf2: Buffer): Buffer[];
20
+ export declare function sortLeaves(leaf1: Buffer, leaf2: Buffer): Buffer<ArrayBufferLike>[];
21
21
  export declare const toXOnly: (pubKey: string) => string;
22
22
  export declare const isValidBitcoinPubKey: (pubKey: string) => boolean;
23
23
  export declare const constructOrderPair: (sourceChain: Chain, sourceAsset: string, destChain: Chain, destAsset: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/core",
3
- "version": "2.0.25",
3
+ "version": "2.1.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",
@@ -27,11 +27,10 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@catalogfi/wallets": "^0.2.59",
30
- "@gardenfi/orderbook": "^2.0.9",
31
- "@gardenfi/utils": "^2.0.6",
30
+ "@gardenfi/orderbook": "2.1.1",
31
+ "@gardenfi/utils": "2.1.1",
32
32
  "bignumber.js": "^9.1.2",
33
33
  "bitcoinjs-lib": "^6.1.6",
34
- "crypto-browserify": "^3.12.1",
35
34
  "starknet": "6.23.1",
36
35
  "tiny-secp256k1": "^2.2.3",
37
36
  "varuint-bitcoin": "^1.1.2",
@@ -1,11 +0,0 @@
1
- export declare class DigestKey {
2
- private _digestKey;
3
- private _userId;
4
- constructor(digestKey: string);
5
- static from(digestKey: string): import('@catalogfi/utils').Result<never, string> | import('@catalogfi/utils').Result<DigestKey, never>;
6
- static generateRandom(): import('@catalogfi/utils').Result<never, string> | import('@catalogfi/utils').Result<DigestKey, never>;
7
- private static isValidPrivateKey;
8
- private static generateRandomDigestKey;
9
- get digestKey(): string;
10
- get userId(): string;
11
- }