@gardenfi/core 2.1.5-beta.1 → 2.1.5-beta.2

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,5 +0,0 @@
1
- export declare const SolanaRelayerAddress: {
2
- readonly mainnet: "";
3
- readonly testnet: "ANUVKxeqaec3bf4DVPqLTnG1PT3Fng56wPcE7LXAb46Q";
4
- readonly localnet: "AKnL4NNf3DGWZJS6cPknBuEGnVsV4A4m5tgebLHaRSZ9";
5
- };
@@ -1,28 +0,0 @@
1
- import { MatchedOrder } from '@gardenfi/orderbook';
2
- import { AsyncResult } from '@catalogfi/utils';
3
-
4
- export interface ISolanaHTLC {
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: MatchedOrder): 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: MatchedOrder, 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: MatchedOrder): AsyncResult<string, string>;
28
- }
@@ -1,56 +0,0 @@
1
- import { AnchorProvider } from '@coral-xyz/anchor';
2
- import { ISolanaHTLC } from './ISolanaHTLC';
3
- import { MatchedOrder } from '@gardenfi/orderbook';
4
- import { AsyncResult } from '@catalogfi/utils';
5
-
6
- /**
7
- * SolanaHTLC is an implementation of ISolanaHTLC that performs atomic swaps directly on-chain.
8
- * As such, fees will be deducted from the initiator.
9
- * To use a relayer that pays fees on behalf, see SolanaRelay
10
- */
11
- export declare class SolanaHTLC implements ISolanaHTLC {
12
- private provider;
13
- /**
14
- * The on-chain Program Derived Address (PDA) that facilitates this swap.
15
- * Stores the swap state (initiator, redeemer, secrethash etc) and escrows the tokens.
16
- */
17
- private swapAccount?;
18
- private program;
19
- /**
20
- * Creates a new instance of SolanaHTLC.
21
- * @param {AnchorProvider} provider - Solana Provider (abstraction of RPC connection and a Wallet)
22
- * @throws {Error} If provider is not provided
23
- */
24
- constructor(provider: AnchorProvider);
25
- /**
26
- * Gets the on-chain address of the atomic swap program.
27
- * @returns {string} The program's on-chain address in base58 format
28
- * @throws {Error} If no program ID is found
29
- */
30
- get htlcActorAddress(): string;
31
- /**
32
- * Initiates a swap by creating a new swap account and locking funds.
33
- * @param {MatchedOrder} order - The matched order containing swap details
34
- * @returns {Promise<AsyncResult<string, string>>} A promise that resolves to either:
35
- * - Ok with the transaction ID on success
36
- * - Err with an error message on failure
37
- */
38
- initiate(order: MatchedOrder): AsyncResult<string, string>;
39
- /**
40
- * Redeems a swap by providing the secret.
41
- * @param {MatchedOrder} order - Matched order object containing swap details
42
- * @param {string} secret - Secret key in hex format
43
- * @returns {AsyncResult<string, string>} A promise that resolves to either:
44
- * - Ok with the transaction ID on success
45
- * - Err with an error message on failure
46
- */
47
- redeem(order: MatchedOrder, secret: string): AsyncResult<string, string>;
48
- /**
49
- * Refunds the swap back to the initiator.
50
- * @param {MatchedOrder} order - Matched order object
51
- * @returns {AsyncResult<string, string>} A promise that resolves to either:
52
- * - Ok with the transaction ID on success
53
- * - Err with an error message on failure
54
- */
55
- refund(order: MatchedOrder): AsyncResult<string, string>;
56
- }
@@ -1,395 +0,0 @@
1
- /**
2
- * Program IDL in camelCase format in order to be used in JS/TS.
3
- *
4
- * Note that this is only a type helper and is not the actual IDL. The original
5
- * IDL can be found at `target/idl/solana_native_swaps.json`.
6
- */
7
- export type SolanaNativeSwaps = {
8
- "address": "6eksgdCnSjUaGQWZ6iYvauv1qzvYPF33RTGTM1ZuyENx";
9
- "metadata": {
10
- "name": "solanaNativeSwaps";
11
- "version": "0.2.0";
12
- "spec": "0.1.0";
13
- "description": "Created with Anchor";
14
- };
15
- "instructions": [
16
- {
17
- "name": "initiate";
18
- "discriminator": [
19
- 5,
20
- 63,
21
- 123,
22
- 113,
23
- 153,
24
- 75,
25
- 148,
26
- 14
27
- ];
28
- "accounts": [
29
- {
30
- "name": "swapAccount";
31
- "writable": true;
32
- "pda": {
33
- "seeds": [
34
- {
35
- "kind": "const";
36
- "value": [
37
- 115,
38
- 119,
39
- 97,
40
- 112,
41
- 95,
42
- 97,
43
- 99,
44
- 99,
45
- 111,
46
- 117,
47
- 110,
48
- 116
49
- ];
50
- },
51
- {
52
- "kind": "arg";
53
- "path": "secretHash";
54
- }
55
- ];
56
- };
57
- },
58
- {
59
- "name": "initiator";
60
- "docs": [
61
- "Initiator must sign this transaction."
62
- ];
63
- "writable": true;
64
- "signer": true;
65
- },
66
- {
67
- "name": "systemProgram";
68
- "address": "11111111111111111111111111111111";
69
- }
70
- ];
71
- "args": [
72
- {
73
- "name": "amountLamports";
74
- "type": "u64";
75
- },
76
- {
77
- "name": "expiresInSlots";
78
- "type": "u64";
79
- },
80
- {
81
- "name": "redeemer";
82
- "type": "pubkey";
83
- },
84
- {
85
- "name": "secretHash";
86
- "type": {
87
- "array": [
88
- "u8",
89
- 32
90
- ];
91
- };
92
- }
93
- ];
94
- },
95
- {
96
- "name": "instantRefund";
97
- "discriminator": [
98
- 211,
99
- 202,
100
- 103,
101
- 41,
102
- 183,
103
- 147,
104
- 59,
105
- 251
106
- ];
107
- "accounts": [
108
- {
109
- "name": "swapAccount";
110
- "writable": true;
111
- },
112
- {
113
- "name": "initiator";
114
- "writable": true;
115
- },
116
- {
117
- "name": "redeemer";
118
- "docs": [
119
- "Redeemer must sign this transaction."
120
- ];
121
- "signer": true;
122
- }
123
- ];
124
- "args": [];
125
- },
126
- {
127
- "name": "redeem";
128
- "discriminator": [
129
- 184,
130
- 12,
131
- 86,
132
- 149,
133
- 70,
134
- 196,
135
- 97,
136
- 225
137
- ];
138
- "accounts": [
139
- {
140
- "name": "swapAccount";
141
- "writable": true;
142
- },
143
- {
144
- "name": "redeemer";
145
- "writable": true;
146
- }
147
- ];
148
- "args": [
149
- {
150
- "name": "secret";
151
- "type": {
152
- "array": [
153
- "u8",
154
- 32
155
- ];
156
- };
157
- }
158
- ];
159
- },
160
- {
161
- "name": "refund";
162
- "discriminator": [
163
- 2,
164
- 96,
165
- 183,
166
- 251,
167
- 63,
168
- 208,
169
- 46,
170
- 46
171
- ];
172
- "accounts": [
173
- {
174
- "name": "swapAccount";
175
- "writable": true;
176
- },
177
- {
178
- "name": "refundee";
179
- "writable": true;
180
- }
181
- ];
182
- "args": [];
183
- }
184
- ];
185
- "accounts": [
186
- {
187
- "name": "swapAccount";
188
- "discriminator": [
189
- 53,
190
- 126,
191
- 9,
192
- 14,
193
- 14,
194
- 197,
195
- 105,
196
- 182
197
- ];
198
- }
199
- ];
200
- "events": [
201
- {
202
- "name": "initiated";
203
- "discriminator": [
204
- 6,
205
- 108,
206
- 212,
207
- 91,
208
- 67,
209
- 60,
210
- 207,
211
- 221
212
- ];
213
- },
214
- {
215
- "name": "instantRefunded";
216
- "discriminator": [
217
- 220,
218
- 50,
219
- 18,
220
- 207,
221
- 183,
222
- 232,
223
- 218,
224
- 25
225
- ];
226
- },
227
- {
228
- "name": "redeemed";
229
- "discriminator": [
230
- 14,
231
- 29,
232
- 183,
233
- 71,
234
- 31,
235
- 165,
236
- 107,
237
- 38
238
- ];
239
- },
240
- {
241
- "name": "refunded";
242
- "discriminator": [
243
- 35,
244
- 103,
245
- 149,
246
- 246,
247
- 196,
248
- 123,
249
- 221,
250
- 99
251
- ];
252
- }
253
- ];
254
- "errors": [
255
- {
256
- "code": 6000;
257
- "name": "invalidRedeemer";
258
- "msg": "The provided redeemer is not the intended recipient of the swap amount";
259
- },
260
- {
261
- "code": 6001;
262
- "name": "invalidRefundee";
263
- "msg": "The provided refundee is not the initiator of the given swap account";
264
- },
265
- {
266
- "code": 6002;
267
- "name": "invalidSecret";
268
- "msg": "The provided secret does not correspond to the secret hash in the PDA";
269
- },
270
- {
271
- "code": 6003;
272
- "name": "refundBeforeExpiry";
273
- "msg": "Attempt to perform a refund before expiry time";
274
- }
275
- ];
276
- "types": [
277
- {
278
- "name": "initiated";
279
- "type": {
280
- "kind": "struct";
281
- "fields": [
282
- {
283
- "name": "amountLamports";
284
- "type": "u64";
285
- },
286
- {
287
- "name": "expiresInSlots";
288
- "type": "u64";
289
- },
290
- {
291
- "name": "initiator";
292
- "type": "pubkey";
293
- },
294
- {
295
- "name": "redeemer";
296
- "type": "pubkey";
297
- },
298
- {
299
- "name": "secretHash";
300
- "type": {
301
- "array": [
302
- "u8",
303
- 32
304
- ];
305
- };
306
- }
307
- ];
308
- };
309
- },
310
- {
311
- "name": "instantRefunded";
312
- "type": {
313
- "kind": "struct";
314
- "fields": [
315
- {
316
- "name": "secretHash";
317
- "type": {
318
- "array": [
319
- "u8",
320
- 32
321
- ];
322
- };
323
- }
324
- ];
325
- };
326
- },
327
- {
328
- "name": "redeemed";
329
- "type": {
330
- "kind": "struct";
331
- "fields": [
332
- {
333
- "name": "secret";
334
- "type": {
335
- "array": [
336
- "u8",
337
- 32
338
- ];
339
- };
340
- }
341
- ];
342
- };
343
- },
344
- {
345
- "name": "refunded";
346
- "type": {
347
- "kind": "struct";
348
- "fields": [
349
- {
350
- "name": "secretHash";
351
- "type": {
352
- "array": [
353
- "u8",
354
- 32
355
- ];
356
- };
357
- }
358
- ];
359
- };
360
- },
361
- {
362
- "name": "swapAccount";
363
- "type": {
364
- "kind": "struct";
365
- "fields": [
366
- {
367
- "name": "amountLamports";
368
- "type": "u64";
369
- },
370
- {
371
- "name": "expirySlot";
372
- "type": "u64";
373
- },
374
- {
375
- "name": "initiator";
376
- "type": "pubkey";
377
- },
378
- {
379
- "name": "redeemer";
380
- "type": "pubkey";
381
- },
382
- {
383
- "name": "secretHash";
384
- "type": {
385
- "array": [
386
- "u8",
387
- 32
388
- ];
389
- };
390
- }
391
- ];
392
- };
393
- }
394
- ];
395
- };