@gardenfi/core 2.1.3-beta.2 → 2.1.3-beta.21

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,4 +1,4 @@
1
- import { Environment } from '@gardenfi/utils';
1
+ import { Environment, Network } from '@gardenfi/utils';
2
2
 
3
3
  export type Api = {
4
4
  orderbook: string;
@@ -9,3 +9,4 @@ export type Api = {
9
9
  starknetRelay: string;
10
10
  };
11
11
  export declare const API: Record<Environment, Api>;
12
+ export declare const DEFAULT_NODE_URL: Record<Network, string>;
@@ -0,0 +1,310 @@
1
+ export declare const nativeHTLCAbi: readonly [{
2
+ readonly inputs: readonly [{
3
+ readonly internalType: "string";
4
+ readonly name: "name";
5
+ readonly type: "string";
6
+ }, {
7
+ readonly internalType: "string";
8
+ readonly name: "version";
9
+ readonly type: "string";
10
+ }];
11
+ readonly stateMutability: "nonpayable";
12
+ readonly type: "constructor";
13
+ }, {
14
+ readonly inputs: readonly [];
15
+ readonly name: "InvalidShortString";
16
+ readonly type: "error";
17
+ }, {
18
+ readonly inputs: readonly [];
19
+ readonly name: "NativeHTLC__DuplicateOrder";
20
+ readonly type: "error";
21
+ }, {
22
+ readonly inputs: readonly [];
23
+ readonly name: "NativeHTLC__IncorrectFundsRecieved";
24
+ readonly type: "error";
25
+ }, {
26
+ readonly inputs: readonly [];
27
+ readonly name: "NativeHTLC__IncorrectSecret";
28
+ readonly type: "error";
29
+ }, {
30
+ readonly inputs: readonly [];
31
+ readonly name: "NativeHTLC__InsufficientBalance";
32
+ readonly type: "error";
33
+ }, {
34
+ readonly inputs: readonly [];
35
+ readonly name: "NativeHTLC__InvalidRedeemerSignature";
36
+ readonly type: "error";
37
+ }, {
38
+ readonly inputs: readonly [];
39
+ readonly name: "NativeHTLC__OrderFulfilled";
40
+ readonly type: "error";
41
+ }, {
42
+ readonly inputs: readonly [];
43
+ readonly name: "NativeHTLC__OrderNotExpired";
44
+ readonly type: "error";
45
+ }, {
46
+ readonly inputs: readonly [];
47
+ readonly name: "NativeHTLC__OrderNotInitiated";
48
+ readonly type: "error";
49
+ }, {
50
+ readonly inputs: readonly [];
51
+ readonly name: "NativeHTLC__SameInitiatorAndRedeemer";
52
+ readonly type: "error";
53
+ }, {
54
+ readonly inputs: readonly [];
55
+ readonly name: "NativeHTLC__ZeroAddressInitiator";
56
+ readonly type: "error";
57
+ }, {
58
+ readonly inputs: readonly [];
59
+ readonly name: "NativeHTLC__ZeroAddressRedeemer";
60
+ readonly type: "error";
61
+ }, {
62
+ readonly inputs: readonly [];
63
+ readonly name: "NativeHTLC__ZeroAmount";
64
+ readonly type: "error";
65
+ }, {
66
+ readonly inputs: readonly [];
67
+ readonly name: "NativeHTLC__ZeroTimelock";
68
+ readonly type: "error";
69
+ }, {
70
+ readonly inputs: readonly [{
71
+ readonly internalType: "string";
72
+ readonly name: "str";
73
+ readonly type: "string";
74
+ }];
75
+ readonly name: "StringTooLong";
76
+ readonly type: "error";
77
+ }, {
78
+ readonly anonymous: false;
79
+ readonly inputs: readonly [];
80
+ readonly name: "EIP712DomainChanged";
81
+ readonly type: "event";
82
+ }, {
83
+ readonly anonymous: false;
84
+ readonly inputs: readonly [{
85
+ readonly indexed: true;
86
+ readonly internalType: "bytes32";
87
+ readonly name: "orderID";
88
+ readonly type: "bytes32";
89
+ }, {
90
+ readonly indexed: true;
91
+ readonly internalType: "bytes32";
92
+ readonly name: "secretHash";
93
+ readonly type: "bytes32";
94
+ }, {
95
+ readonly indexed: false;
96
+ readonly internalType: "uint256";
97
+ readonly name: "amount";
98
+ readonly type: "uint256";
99
+ }];
100
+ readonly name: "Initiated";
101
+ readonly type: "event";
102
+ }, {
103
+ readonly anonymous: false;
104
+ readonly inputs: readonly [{
105
+ readonly indexed: true;
106
+ readonly internalType: "bytes32";
107
+ readonly name: "orderID";
108
+ readonly type: "bytes32";
109
+ }, {
110
+ readonly indexed: true;
111
+ readonly internalType: "bytes32";
112
+ readonly name: "secretHash";
113
+ readonly type: "bytes32";
114
+ }, {
115
+ readonly indexed: false;
116
+ readonly internalType: "bytes";
117
+ readonly name: "secret";
118
+ readonly type: "bytes";
119
+ }];
120
+ readonly name: "Redeemed";
121
+ readonly type: "event";
122
+ }, {
123
+ readonly anonymous: false;
124
+ readonly inputs: readonly [{
125
+ readonly indexed: true;
126
+ readonly internalType: "bytes32";
127
+ readonly name: "orderID";
128
+ readonly type: "bytes32";
129
+ }];
130
+ readonly name: "Refunded";
131
+ readonly type: "event";
132
+ }, {
133
+ readonly inputs: readonly [];
134
+ readonly name: "eip712Domain";
135
+ readonly outputs: readonly [{
136
+ readonly internalType: "bytes1";
137
+ readonly name: "fields";
138
+ readonly type: "bytes1";
139
+ }, {
140
+ readonly internalType: "string";
141
+ readonly name: "name";
142
+ readonly type: "string";
143
+ }, {
144
+ readonly internalType: "string";
145
+ readonly name: "version";
146
+ readonly type: "string";
147
+ }, {
148
+ readonly internalType: "uint256";
149
+ readonly name: "chainId";
150
+ readonly type: "uint256";
151
+ }, {
152
+ readonly internalType: "address";
153
+ readonly name: "verifyingContract";
154
+ readonly type: "address";
155
+ }, {
156
+ readonly internalType: "bytes32";
157
+ readonly name: "salt";
158
+ readonly type: "bytes32";
159
+ }, {
160
+ readonly internalType: "uint256[]";
161
+ readonly name: "extensions";
162
+ readonly type: "uint256[]";
163
+ }];
164
+ readonly stateMutability: "view";
165
+ readonly type: "function";
166
+ }, {
167
+ readonly inputs: readonly [{
168
+ readonly internalType: "address payable";
169
+ readonly name: "redeemer";
170
+ readonly type: "address";
171
+ }, {
172
+ readonly internalType: "uint256";
173
+ readonly name: "timelock";
174
+ readonly type: "uint256";
175
+ }, {
176
+ readonly internalType: "uint256";
177
+ readonly name: "amount";
178
+ readonly type: "uint256";
179
+ }, {
180
+ readonly internalType: "bytes32";
181
+ readonly name: "secretHash";
182
+ readonly type: "bytes32";
183
+ }];
184
+ readonly name: "initiate";
185
+ readonly outputs: readonly [];
186
+ readonly stateMutability: "payable";
187
+ readonly type: "function";
188
+ }, {
189
+ readonly inputs: readonly [{
190
+ readonly internalType: "address payable";
191
+ readonly name: "initiator";
192
+ readonly type: "address";
193
+ }, {
194
+ readonly internalType: "address payable";
195
+ readonly name: "redeemer";
196
+ readonly type: "address";
197
+ }, {
198
+ readonly internalType: "uint256";
199
+ readonly name: "timelock";
200
+ readonly type: "uint256";
201
+ }, {
202
+ readonly internalType: "uint256";
203
+ readonly name: "amount";
204
+ readonly type: "uint256";
205
+ }, {
206
+ readonly internalType: "bytes32";
207
+ readonly name: "secretHash";
208
+ readonly type: "bytes32";
209
+ }];
210
+ readonly name: "initiateOnBehalf";
211
+ readonly outputs: readonly [];
212
+ readonly stateMutability: "payable";
213
+ readonly type: "function";
214
+ }, {
215
+ readonly inputs: readonly [{
216
+ readonly internalType: "bytes32";
217
+ readonly name: "orderID";
218
+ readonly type: "bytes32";
219
+ }, {
220
+ readonly internalType: "bytes";
221
+ readonly name: "signature";
222
+ readonly type: "bytes";
223
+ }];
224
+ readonly name: "instantRefund";
225
+ readonly outputs: readonly [];
226
+ readonly stateMutability: "nonpayable";
227
+ readonly type: "function";
228
+ }, {
229
+ readonly inputs: readonly [{
230
+ readonly internalType: "bytes32";
231
+ readonly name: "orderID";
232
+ readonly type: "bytes32";
233
+ }];
234
+ readonly name: "instantRefundDigest";
235
+ readonly outputs: readonly [{
236
+ readonly internalType: "bytes32";
237
+ readonly name: "";
238
+ readonly type: "bytes32";
239
+ }];
240
+ readonly stateMutability: "view";
241
+ readonly type: "function";
242
+ }, {
243
+ readonly inputs: readonly [{
244
+ readonly internalType: "bytes32";
245
+ readonly name: "";
246
+ readonly type: "bytes32";
247
+ }];
248
+ readonly name: "orders";
249
+ readonly outputs: readonly [{
250
+ readonly internalType: "bool";
251
+ readonly name: "isFulfilled";
252
+ readonly type: "bool";
253
+ }, {
254
+ readonly internalType: "address payable";
255
+ readonly name: "initiator";
256
+ readonly type: "address";
257
+ }, {
258
+ readonly internalType: "address payable";
259
+ readonly name: "redeemer";
260
+ readonly type: "address";
261
+ }, {
262
+ readonly internalType: "uint256";
263
+ readonly name: "initiatedAt";
264
+ readonly type: "uint256";
265
+ }, {
266
+ readonly internalType: "uint256";
267
+ readonly name: "timelock";
268
+ readonly type: "uint256";
269
+ }, {
270
+ readonly internalType: "uint256";
271
+ readonly name: "amount";
272
+ readonly type: "uint256";
273
+ }];
274
+ readonly stateMutability: "view";
275
+ readonly type: "function";
276
+ }, {
277
+ readonly inputs: readonly [{
278
+ readonly internalType: "bytes32";
279
+ readonly name: "orderID";
280
+ readonly type: "bytes32";
281
+ }, {
282
+ readonly internalType: "bytes";
283
+ readonly name: "secret";
284
+ readonly type: "bytes";
285
+ }];
286
+ readonly name: "redeem";
287
+ readonly outputs: readonly [];
288
+ readonly stateMutability: "nonpayable";
289
+ readonly type: "function";
290
+ }, {
291
+ readonly inputs: readonly [{
292
+ readonly internalType: "bytes32";
293
+ readonly name: "orderID";
294
+ readonly type: "bytes32";
295
+ }];
296
+ readonly name: "refund";
297
+ readonly outputs: readonly [];
298
+ readonly stateMutability: "nonpayable";
299
+ readonly type: "function";
300
+ }, {
301
+ readonly inputs: readonly [];
302
+ readonly name: "token";
303
+ readonly outputs: readonly [{
304
+ readonly internalType: "address";
305
+ readonly name: "";
306
+ readonly type: "address";
307
+ }];
308
+ readonly stateMutability: "view";
309
+ readonly type: "function";
310
+ }];
@@ -10,6 +10,9 @@ export declare class EvmRelay implements IEVMHTLC {
10
10
  constructor(url: string | Url, wallet: WalletClient, auth: IAuth);
11
11
  get htlcActorAddress(): string;
12
12
  initiate(order: MatchedOrder): AsyncResult<string, string>;
13
+ private getTokenAddress;
14
+ private _initiateOnNativeHTLC;
15
+ private _initiateOnErc20HTLC;
13
16
  redeem(order: MatchedOrder, secret: string): AsyncResult<string, string>;
14
17
  refund(): AsyncResult<string, string>;
15
18
  }
@@ -1,4 +1,6 @@
1
- import { AccountInterface } from 'starknet';
1
+ import { AccountInterface, RpcProvider } from 'starknet';
2
2
  import { AsyncResult } from '@catalogfi/utils';
3
3
 
4
- export declare const checkAllowanceAndApprove: (account: AccountInterface, tokenAddress: string, htlcAddress: string, amount: bigint, nodeUrl: string) => AsyncResult<string, string>;
4
+ export declare const checkAllowanceAndApprove: (account: AccountInterface, tokenAddress: string, htlcAddress: string, amount: bigint, starknetProvider: RpcProvider) => AsyncResult<string, string>;
5
+ export declare const checkAllowance: (accountAddress: string, tokenAddress: string, htlcAddress: string, starknetProvider: RpcProvider) => AsyncResult<bigint, string>;
6
+ export declare const isAllowanceSufficient: (accountAddress: string, tokenAddress: string, htlcAddress: string, starknetProvider: RpcProvider, amount: bigint) => AsyncResult<boolean, string>;
@@ -1,12 +1,13 @@
1
1
  import { MatchedOrder } from '@gardenfi/orderbook';
2
2
  import { AsyncResult } from '@catalogfi/utils';
3
3
  import { Account, CallData } from 'starknet';
4
+ import { Network } from '@gardenfi/utils';
4
5
  import { IStarknetHTLC } from '../starknetHTLC.types';
5
6
 
6
7
  export declare class StarknetHTLC implements IStarknetHTLC {
7
- private nodeUrl;
8
8
  private account;
9
- constructor(account: Account, nodeUrl?: string);
9
+ private starknetProvider;
10
+ constructor(account: Account, nodeUrl?: string, network?: Network);
10
11
  get htlcActorAddress(): string;
11
12
  private getHTLCContract;
12
13
  /**
@@ -1,16 +1,18 @@
1
1
  import { AccountInterface } from 'starknet';
2
2
  import { MatchedOrder } from '@gardenfi/orderbook';
3
3
  import { AsyncResult } from '@catalogfi/utils';
4
- import { Url } from '@gardenfi/utils';
4
+ import { Network, Url } from '@gardenfi/utils';
5
5
  import { IStarknetHTLC } from '../starknetHTLC.types';
6
6
 
7
7
  export declare class StarknetRelay implements IStarknetHTLC {
8
8
  private url;
9
- private nodeUrl;
10
9
  private account;
11
- constructor(relayerUrl: string | Url, account: AccountInterface, nodeUrl?: string);
10
+ private starknetProvider;
11
+ constructor(relayerUrl: string | Url, account: AccountInterface, network: Network, nodeUrl?: string);
12
12
  get htlcActorAddress(): string;
13
13
  initiate(order: MatchedOrder): AsyncResult<string, string>;
14
+ private approveAndInitiate;
15
+ private initiateRelay;
14
16
  redeem(order: MatchedOrder, secret: string): AsyncResult<string, string>;
15
17
  refund(): AsyncResult<string, string>;
16
18
  }
@@ -1,5 +1,5 @@
1
1
  import { Chain as viemChain } from 'viem/chains';
2
- import { Chain, EvmChain } from '@gardenfi/orderbook';
2
+ import { EvmChain } from '@gardenfi/orderbook';
3
3
  import { WalletClient } from 'viem';
4
4
  import { AsyncResult } from '@catalogfi/utils';
5
5
 
@@ -12,7 +12,7 @@ export declare const evmToViemChainMap: Record<EvmChain, viemChain>;
12
12
  * @param walletClient
13
13
  * @returns new walletClient with updated chain
14
14
  */
15
- export declare const switchOrAddNetwork: (chain: Chain, walletClient: WalletClient) => AsyncResult<{
15
+ export declare const switchOrAddNetwork: (chain: EvmChain, walletClient: WalletClient) => AsyncResult<{
16
16
  message: string;
17
17
  walletClient: WalletClient;
18
18
  }, string>;
@@ -24,4 +24,5 @@ export declare const isValidBitcoinPubKey: (pubKey: string) => boolean;
24
24
  export declare const constructOrderPair: (sourceChain: Chain, sourceAsset: string, destChain: Chain, destAsset: string) => string;
25
25
  export declare function validateBTCAddress(address: string, networkType: Environment): boolean;
26
26
  export declare const getBitcoinNetwork: (network: Environment) => BitcoinNetwork;
27
- export declare const formatStarknetSignature: (value: Signature) => import('@gardenfi/utils').Result<string[], never> | import('@gardenfi/utils').Result<never, string>;
27
+ export declare const isHexString: (value: string) => boolean;
28
+ export declare const formatStarknetSignature: (sig: Signature) => import('@gardenfi/utils').Result<string[], never> | import('@gardenfi/utils').Result<never, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/core",
3
- "version": "2.1.3-beta.2",
3
+ "version": "2.1.3-beta.21",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",
@@ -27,8 +27,8 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@catalogfi/wallets": "^0.2.59",
30
- "@gardenfi/orderbook": "2.1.2",
31
- "@gardenfi/utils": "2.1.2",
30
+ "@gardenfi/orderbook": "2.1.2-beta.10",
31
+ "@gardenfi/utils": "2.1.2-beta.8",
32
32
  "bignumber.js": "^9.1.2",
33
33
  "bitcoinjs-lib": "^6.1.6",
34
34
  "starknet": "6.23.1",