@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,391 +0,0 @@
1
- declare const _default: {
2
- "address": "6eksgdCnSjUaGQWZ6iYvauv1qzvYPF33RTGTM1ZuyENx",
3
- "metadata": {
4
- "name": "solana_native_swaps",
5
- "version": "0.2.0",
6
- "spec": "0.1.0",
7
- "description": "Created with Anchor"
8
- },
9
- "instructions": [
10
- {
11
- "name": "initiate",
12
- "discriminator": [
13
- 5,
14
- 63,
15
- 123,
16
- 113,
17
- 153,
18
- 75,
19
- 148,
20
- 14
21
- ],
22
- "accounts": [
23
- {
24
- "name": "swap_account",
25
- "writable": true,
26
- "pda": {
27
- "seeds": [
28
- {
29
- "kind": "const",
30
- "value": [
31
- 115,
32
- 119,
33
- 97,
34
- 112,
35
- 95,
36
- 97,
37
- 99,
38
- 99,
39
- 111,
40
- 117,
41
- 110,
42
- 116
43
- ]
44
- },
45
- {
46
- "kind": "arg",
47
- "path": "secret_hash"
48
- }
49
- ]
50
- }
51
- },
52
- {
53
- "name": "initiator",
54
- "docs": [
55
- "Initiator must sign this transaction."
56
- ],
57
- "writable": true,
58
- "signer": true
59
- },
60
- {
61
- "name": "system_program",
62
- "address": "11111111111111111111111111111111"
63
- }
64
- ],
65
- "args": [
66
- {
67
- "name": "amount_lamports",
68
- "type": "u64"
69
- },
70
- {
71
- "name": "expires_in_slots",
72
- "type": "u64"
73
- },
74
- {
75
- "name": "redeemer",
76
- "type": "pubkey"
77
- },
78
- {
79
- "name": "secret_hash",
80
- "type": {
81
- "array": [
82
- "u8",
83
- 32
84
- ]
85
- }
86
- }
87
- ]
88
- },
89
- {
90
- "name": "instant_refund",
91
- "discriminator": [
92
- 211,
93
- 202,
94
- 103,
95
- 41,
96
- 183,
97
- 147,
98
- 59,
99
- 251
100
- ],
101
- "accounts": [
102
- {
103
- "name": "swap_account",
104
- "writable": true
105
- },
106
- {
107
- "name": "initiator",
108
- "writable": true
109
- },
110
- {
111
- "name": "redeemer",
112
- "docs": [
113
- "Redeemer must sign this transaction."
114
- ],
115
- "signer": true
116
- }
117
- ],
118
- "args": []
119
- },
120
- {
121
- "name": "redeem",
122
- "discriminator": [
123
- 184,
124
- 12,
125
- 86,
126
- 149,
127
- 70,
128
- 196,
129
- 97,
130
- 225
131
- ],
132
- "accounts": [
133
- {
134
- "name": "swap_account",
135
- "writable": true
136
- },
137
- {
138
- "name": "redeemer",
139
- "writable": true
140
- }
141
- ],
142
- "args": [
143
- {
144
- "name": "secret",
145
- "type": {
146
- "array": [
147
- "u8",
148
- 32
149
- ]
150
- }
151
- }
152
- ]
153
- },
154
- {
155
- "name": "refund",
156
- "discriminator": [
157
- 2,
158
- 96,
159
- 183,
160
- 251,
161
- 63,
162
- 208,
163
- 46,
164
- 46
165
- ],
166
- "accounts": [
167
- {
168
- "name": "swap_account",
169
- "writable": true
170
- },
171
- {
172
- "name": "refundee",
173
- "writable": true
174
- }
175
- ],
176
- "args": []
177
- }
178
- ],
179
- "accounts": [
180
- {
181
- "name": "SwapAccount",
182
- "discriminator": [
183
- 53,
184
- 126,
185
- 9,
186
- 14,
187
- 14,
188
- 197,
189
- 105,
190
- 182
191
- ]
192
- }
193
- ],
194
- "events": [
195
- {
196
- "name": "Initiated",
197
- "discriminator": [
198
- 6,
199
- 108,
200
- 212,
201
- 91,
202
- 67,
203
- 60,
204
- 207,
205
- 221
206
- ]
207
- },
208
- {
209
- "name": "InstantRefunded",
210
- "discriminator": [
211
- 220,
212
- 50,
213
- 18,
214
- 207,
215
- 183,
216
- 232,
217
- 218,
218
- 25
219
- ]
220
- },
221
- {
222
- "name": "Redeemed",
223
- "discriminator": [
224
- 14,
225
- 29,
226
- 183,
227
- 71,
228
- 31,
229
- 165,
230
- 107,
231
- 38
232
- ]
233
- },
234
- {
235
- "name": "Refunded",
236
- "discriminator": [
237
- 35,
238
- 103,
239
- 149,
240
- 246,
241
- 196,
242
- 123,
243
- 221,
244
- 99
245
- ]
246
- }
247
- ],
248
- "errors": [
249
- {
250
- "code": 6000,
251
- "name": "InvalidRedeemer",
252
- "msg": "The provided redeemer is not the intended recipient of the swap amount"
253
- },
254
- {
255
- "code": 6001,
256
- "name": "InvalidRefundee",
257
- "msg": "The provided refundee is not the initiator of the given swap account"
258
- },
259
- {
260
- "code": 6002,
261
- "name": "InvalidSecret",
262
- "msg": "The provided secret does not correspond to the secret hash in the PDA"
263
- },
264
- {
265
- "code": 6003,
266
- "name": "RefundBeforeExpiry",
267
- "msg": "Attempt to perform a refund before expiry time"
268
- }
269
- ],
270
- "types": [
271
- {
272
- "name": "Initiated",
273
- "type": {
274
- "kind": "struct",
275
- "fields": [
276
- {
277
- "name": "amount_lamports",
278
- "type": "u64"
279
- },
280
- {
281
- "name": "expires_in_slots",
282
- "type": "u64"
283
- },
284
- {
285
- "name": "initiator",
286
- "type": "pubkey"
287
- },
288
- {
289
- "name": "redeemer",
290
- "type": "pubkey"
291
- },
292
- {
293
- "name": "secret_hash",
294
- "type": {
295
- "array": [
296
- "u8",
297
- 32
298
- ]
299
- }
300
- }
301
- ]
302
- }
303
- },
304
- {
305
- "name": "InstantRefunded",
306
- "type": {
307
- "kind": "struct",
308
- "fields": [
309
- {
310
- "name": "secret_hash",
311
- "type": {
312
- "array": [
313
- "u8",
314
- 32
315
- ]
316
- }
317
- }
318
- ]
319
- }
320
- },
321
- {
322
- "name": "Redeemed",
323
- "type": {
324
- "kind": "struct",
325
- "fields": [
326
- {
327
- "name": "secret",
328
- "type": {
329
- "array": [
330
- "u8",
331
- 32
332
- ]
333
- }
334
- }
335
- ]
336
- }
337
- },
338
- {
339
- "name": "Refunded",
340
- "type": {
341
- "kind": "struct",
342
- "fields": [
343
- {
344
- "name": "secret_hash",
345
- "type": {
346
- "array": [
347
- "u8",
348
- 32
349
- ]
350
- }
351
- }
352
- ]
353
- }
354
- },
355
- {
356
- "name": "SwapAccount",
357
- "type": {
358
- "kind": "struct",
359
- "fields": [
360
- {
361
- "name": "amount_lamports",
362
- "type": "u64"
363
- },
364
- {
365
- "name": "expiry_slot",
366
- "type": "u64"
367
- },
368
- {
369
- "name": "initiator",
370
- "type": "pubkey"
371
- },
372
- {
373
- "name": "redeemer",
374
- "type": "pubkey"
375
- },
376
- {
377
- "name": "secret_hash",
378
- "type": {
379
- "array": [
380
- "u8",
381
- 32
382
- ]
383
- }
384
- }
385
- ]
386
- }
387
- }
388
- ]
389
- };
390
-
391
- export default _default;
@@ -1,70 +0,0 @@
1
- import { AnchorProvider } from '@coral-xyz/anchor';
2
- import { AsyncResult } from '@catalogfi/utils';
3
- import { URL } from 'url';
4
- import { ISolanaHTLC } from '../htlc/ISolanaHTLC';
5
- import { MatchedOrder } from '@gardenfi/orderbook';
6
-
7
- /**
8
- * A Relay is an endpoint that submits the transaction on-chain on one's behalf, paying any fees.
9
- * SolanaRelay is one such implementation performs the atomic swaps through a given relayer url.
10
- */
11
- export declare class SolanaRelay implements ISolanaHTLC {
12
- private provider;
13
- private endpoint;
14
- /**
15
- * The on-chain Program Derived Address (PDA) that facilitates this swap.
16
- * A PDA represents an on-chain memory space. It can store SOL too and is owned by a program (that derived it).
17
- * This PDA stores the swap state (initiator, redeemer, secrethash etc) on-chain and also escrows the SOL.
18
- */
19
- private swapAccount?;
20
- private program;
21
- private relayer;
22
- /**
23
- * Creates a new instance of SolanaRelay.
24
- * @param {AnchorProvider} provider - An abstraction of RPC connection and a Wallet
25
- * @param {URL} endpoint - API endpoint of the relayer node
26
- * @param {string} relayer - On-chain address of the relayer in base58 format
27
- * @throws {Error} If any required parameters are missing or invalid
28
- */
29
- constructor(provider: AnchorProvider, endpoint: URL, relayer: string);
30
- /**
31
- * Gets the on-chain address of the atomic swap program.
32
- * @returns {string} The program's on-chain address in base58 format
33
- * @throws {Error} If no program ID is found
34
- */
35
- get htlcActorAddress(): string;
36
- /**
37
- * Sends a transaction via the relayer.
38
- * @param {web3.Transaction} transaction - The transaction to send
39
- * @returns {Promise<AsyncResult<string, string>>} A promise that resolves to either:
40
- * - Ok with the transaction ID on success
41
- * - Err with an error message on failure
42
- * @private
43
- */
44
- private sendViaRelayer;
45
- /**
46
- * Initiates a swap by creating a new swap account and locking funds.
47
- * @param {MatchedOrder} order - The matched order containing swap details
48
- * @returns {Promise<AsyncResult<string, string>>} A promise that resolves to either:
49
- * - Ok with the transaction ID on success
50
- * - Err with an error message on failure
51
- */
52
- initiate(order: MatchedOrder): AsyncResult<string, string>;
53
- /**
54
- * Redeems a swap by providing the secret.
55
- * @param {MatchedOrder} order - Matched order object containing swap details
56
- * @param {string} secret - Secret key in hex format
57
- * @returns {Promise<AsyncResult<string, string>>} A promise that resolves to either:
58
- * - Ok with the transaction ID on success
59
- * - Err with an error message on failure
60
- */
61
- redeem(order: MatchedOrder, secret: string): AsyncResult<string, string>;
62
- /**
63
- * DO NOT CALL THIS FUNCTION. Refund is automatically taken care of by the relayer!
64
- * This method exists only to satisfy the ISolanaHTLC interface but is not intended for direct use.
65
- * @param order - Matched order object
66
- * @returns {AsyncResult<string, string>} Always returns an error message
67
- * @deprecated This function should never be called directly
68
- */
69
- refund(order: MatchedOrder): AsyncResult<string, string>;
70
- }
@@ -1,31 +0,0 @@
1
- import { web3, BN } from '@coral-xyz/anchor';
2
- import { MatchedOrder } from '@gardenfi/orderbook';
3
-
4
- /**
5
- * A Swap configuration in Solana
6
- */
7
- export declare class SwapConfig {
8
- swapId: number[];
9
- redeemer: web3.PublicKey;
10
- secretHash: number[];
11
- amount: BN;
12
- expiresIn: BN;
13
- /**
14
- * @param swapId - A Unique 32-bit ID to represent this configuration in hex
15
- * @param redeemer - The Solana address of redeemer in base58
16
- * @param secretHash - The 32-bit Secret Hash used for this Swap in hex
17
- * @param amount - The Swap amount in lowest denomination
18
- * @param expiresIn - The number of Slots in which the Swap should expire. (1 Solana Slot = 400 ms)
19
- */
20
- constructor(swapId: string, redeemer: string, secretHash: string, amount: bigint, expiresIn: number);
21
- /**
22
- * Constructs a SwapConfig from a matched order object with Solana as a source swap
23
- * @param order - The MatchedOrder with a Solana as source swap
24
- */
25
- static from(order: MatchedOrder): SwapConfig;
26
- }
27
- /**
28
- * Checks whether given secret is a valid 32 byte hex string.
29
- * @returns Validated and decoded secret
30
- */
31
- export declare function validateSecret(secret: string): number[];