@gardenfi/core 2.1.14 → 2.2.0
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-CQkMVqmN.cjs → ccip-B4Z6_o5z.cjs} +1 -1
- package/dist/{ccip-DgpQO1MZ.js → ccip-cu_e7Kb7.js} +1 -1
- package/dist/index-CslSAu9n.js +26584 -0
- package/dist/index-aGo-Fuz8.cjs +84 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +25 -21
- package/dist/src/index.d.ts +4 -1
- package/dist/src/lib/constants.d.ts +6 -0
- package/dist/src/lib/garden/garden.d.ts +11 -1
- package/dist/src/lib/garden/garden.types.d.ts +12 -1
- package/dist/src/lib/solana/htlc/ISolanaHTLC.d.ts +28 -0
- package/dist/src/lib/solana/htlc/solanaHTLC.d.ts +56 -0
- package/dist/src/lib/solana/idl/solana_native_swaps.d.ts +299 -0
- package/dist/src/lib/solana/idl/solana_native_swaps.json.d.ts +296 -0
- package/dist/src/lib/solana/relayer/solanaRelay.d.ts +71 -0
- package/dist/src/lib/solana/solanaTypes.d.ts +31 -0
- package/dist/src/lib/utils.d.ts +2 -0
- package/package.json +5 -3
- package/dist/index-BwOLJ71D.cjs +0 -75
- package/dist/index-CAqXP6qV.js +0 -24196
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-aGo-Fuz8.cjs");exports.API=e.API;exports.BlockNumberFetcher=e.BlockNumberFetcher;exports.EvmRelay=e.EvmRelay;exports.Garden=e.Garden;exports.OrderActions=e.OrderActions;exports.OrderStatus=e.OrderStatus;exports.ParseOrderStatus=e.ParseOrderStatus;exports.ParseSwapStatus=e.ParseSwapStatus;exports.Quote=e.Quote;exports.STARKNET_CONFIG=e.STARKNET_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.SwapStatus=e.SwapStatus;exports.botanix=e.botanixMainnet;exports.constructOrderPair=e.constructOrderPair;exports.evmToViemChainMap=e.evmToViemChainMap;exports.filterDeadlineExpiredOrders=e.filterDeadlineExpiredOrders;exports.hyperliquid=e.hyperliquid;exports.hyperliquidTestnet=e.hyperliquidTestnet;exports.isExpired=e.isExpired;exports.parseAction=e.parseAction;exports.parseActionFromStatus=e.parseActionFromStatus;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,30 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { J as e, m as r, E as t, G as o, O as d, n as i, P as n, q as l, Q as S, K as p, v as u, k as A, j as c, L as O, h as m, S as y, o as C, I as T, w as h, A as P, t as k, F as v, D as w, r as x, p as E, u as R, z as F, M as N, C as f, y as g, x as q } from "./index-CslSAu9n.js";
|
|
2
2
|
export {
|
|
3
3
|
e as API,
|
|
4
4
|
r as BlockNumberFetcher,
|
|
5
5
|
t as EvmRelay,
|
|
6
|
-
|
|
6
|
+
o as Garden,
|
|
7
7
|
d as OrderActions,
|
|
8
|
-
|
|
8
|
+
i as OrderStatus,
|
|
9
9
|
n as ParseOrderStatus,
|
|
10
|
-
|
|
10
|
+
l as ParseSwapStatus,
|
|
11
11
|
S as Quote,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
O as
|
|
17
|
-
m as
|
|
12
|
+
p as STARKNET_CONFIG,
|
|
13
|
+
u as SecretManager,
|
|
14
|
+
A as SolanaHTLC,
|
|
15
|
+
c as SolanaRelay,
|
|
16
|
+
O as SolanaRelayerAddress,
|
|
17
|
+
m as StarknetHTLC,
|
|
18
|
+
y as StarknetRelay,
|
|
19
|
+
C as SwapStatus,
|
|
20
|
+
T as botanix,
|
|
18
21
|
h as constructOrderPair,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
P as evmToViemChainMap,
|
|
23
|
+
k as filterDeadlineExpiredOrders,
|
|
24
|
+
v as hyperliquid,
|
|
25
|
+
w as hyperliquidTestnet,
|
|
26
|
+
x as isExpired,
|
|
27
|
+
E as parseAction,
|
|
28
|
+
R as parseActionFromStatus,
|
|
29
|
+
F as resolveApiConfig,
|
|
30
|
+
N as solanaProgramAddress,
|
|
31
|
+
f as switchOrAddNetwork,
|
|
32
|
+
g as toXOnly,
|
|
33
|
+
q as validateBTCAddress
|
|
30
34
|
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export type { IEVMHTLC } from './lib/evm/htlc.types';
|
|
|
7
7
|
export { StarknetRelay } from './lib/starknet/relay/starknetRelay';
|
|
8
8
|
export type { IStarknetHTLC } from './lib/starknet/starknetHTLC.types';
|
|
9
9
|
export { StarknetHTLC } from './lib/starknet/htlc/starknetHTLC';
|
|
10
|
+
export { SolanaRelay } from './lib/solana/relayer/solanaRelay';
|
|
11
|
+
export type { ISolanaHTLC } from './lib/solana/htlc/ISolanaHTLC';
|
|
12
|
+
export { SolanaHTLC } from './lib/solana/htlc/solanaHTLC';
|
|
10
13
|
export { BlockNumberFetcher } from './lib/blockNumberFetcher/blockNumber';
|
|
11
14
|
export type { IBlockNumberFetcher } from './lib/blockNumberFetcher/blockNumber';
|
|
12
15
|
export { OrderStatus, SwapStatus } from './lib/orderStatus/status';
|
|
@@ -17,4 +20,4 @@ export { Quote } from './lib/quote/quote';
|
|
|
17
20
|
export type { IQuote, QuoteResponse, Strategies, } from './lib/quote/quote.types';
|
|
18
21
|
export { constructOrderPair, validateBTCAddress, toXOnly, resolveApiConfig, } from './lib/utils';
|
|
19
22
|
export { evmToViemChainMap, switchOrAddNetwork, hyperliquidTestnet, hyperliquid, botanixMainnet as botanix, } from './lib/switchOrAddNetwork';
|
|
20
|
-
export { API, STARKNET_CONFIG } from './lib/constants';
|
|
23
|
+
export { API, STARKNET_CONFIG, SolanaRelayerAddress, solanaProgramAddress, } from './lib/constants';
|
|
@@ -7,12 +7,18 @@ export type Api = {
|
|
|
7
7
|
info: string;
|
|
8
8
|
evmRelay: string;
|
|
9
9
|
starknetRelay: string;
|
|
10
|
+
solanaRelay: string;
|
|
10
11
|
};
|
|
11
12
|
export declare const API: Record<Environment, Api>;
|
|
12
13
|
export declare const STARKNET_CONFIG: Record<Network, {
|
|
13
14
|
chainId: string;
|
|
14
15
|
nodeUrl: string;
|
|
15
16
|
}>;
|
|
17
|
+
export declare const SolanaRelayerAddress: Record<Network, string>;
|
|
18
|
+
export declare const solanaProgramAddress: {
|
|
19
|
+
mainnet: string;
|
|
20
|
+
staging: string;
|
|
21
|
+
};
|
|
16
22
|
export declare const DEFAULT_AFFILIATE_ASSET: {
|
|
17
23
|
chain: "base";
|
|
18
24
|
asset: "0xeae7721d779276eb0f5837e2fe260118724a2ba4";
|
|
@@ -8,6 +8,7 @@ import { IBitcoinWallet } from '@catalogfi/wallets';
|
|
|
8
8
|
import { IBlockNumberFetcher } from '../blockNumberFetcher/blockNumber';
|
|
9
9
|
import { IEVMHTLC } from '../evm/htlc.types';
|
|
10
10
|
import { IStarknetHTLC } from '../starknet/starknetHTLC.types';
|
|
11
|
+
import { ISolanaHTLC } from '../solana/htlc/ISolanaHTLC';
|
|
11
12
|
|
|
12
13
|
export declare class Garden extends EventBroker<GardenEvents> implements IGardenJS {
|
|
13
14
|
private environment;
|
|
@@ -21,6 +22,7 @@ export declare class Garden extends EventBroker<GardenEvents> implements IGarden
|
|
|
21
22
|
private refundSacpCache;
|
|
22
23
|
private _evmHTLC;
|
|
23
24
|
private _starknetHTLC;
|
|
25
|
+
private _solanaHTLC;
|
|
24
26
|
private _btcWallet;
|
|
25
27
|
private bitcoinRedeemCache;
|
|
26
28
|
private _digestKey;
|
|
@@ -29,13 +31,20 @@ export declare class Garden extends EventBroker<GardenEvents> implements IGarden
|
|
|
29
31
|
static fromWallets(config: GardenConfigWithWallets): Garden;
|
|
30
32
|
get evmHTLC(): IEVMHTLC | undefined;
|
|
31
33
|
get starknetHTLC(): IStarknetHTLC | undefined;
|
|
34
|
+
get solanaHTLC(): ISolanaHTLC | undefined;
|
|
32
35
|
get quote(): IQuote;
|
|
33
|
-
get btcWallet(): IBitcoinWallet;
|
|
36
|
+
get btcWallet(): IBitcoinWallet | undefined;
|
|
34
37
|
get orderbook(): IOrderbook;
|
|
35
38
|
get blockNumberFetcher(): IBlockNumberFetcher;
|
|
36
39
|
get secretManager(): ISecretManager;
|
|
37
40
|
get auth(): IAuth;
|
|
38
41
|
get digestKey(): DigestKey;
|
|
42
|
+
/**
|
|
43
|
+
* This method takes in the `SwapParams` and returns a placed order
|
|
44
|
+
* It internally calls `getAttestedQuote`, `createOrder` and `pollOrder`
|
|
45
|
+
* @param swapParams
|
|
46
|
+
* @returns MatchedOrder
|
|
47
|
+
*/
|
|
39
48
|
swap(params: SwapParams): AsyncResult<MatchedOrder, string>;
|
|
40
49
|
private withDefaultAffiliateFees;
|
|
41
50
|
private validateAndFillParams;
|
|
@@ -43,6 +52,7 @@ export declare class Garden extends EventBroker<GardenEvents> implements IGarden
|
|
|
43
52
|
private validateAmount;
|
|
44
53
|
private pollOrder;
|
|
45
54
|
execute(interval?: number): Promise<() => void>;
|
|
55
|
+
private solRedeem;
|
|
46
56
|
private evmRedeem;
|
|
47
57
|
private starknetRedeem;
|
|
48
58
|
private btcRedeem;
|
|
@@ -5,12 +5,14 @@ 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
|
-
import { IBitcoinWallet } from '@catalogfi/wallets';
|
|
8
|
+
import { BitcoinWallet, IBitcoinWallet } from '@catalogfi/wallets';
|
|
9
9
|
import { IEVMHTLC } from '../evm/htlc.types';
|
|
10
10
|
import { IStarknetHTLC } from '../starknet/starknetHTLC.types';
|
|
11
11
|
import { AccountInterface } from 'starknet';
|
|
12
12
|
import { WalletClient } from 'viem';
|
|
13
13
|
import { Api } from '../constants';
|
|
14
|
+
import { ISolanaHTLC } from '../solana/htlc/ISolanaHTLC';
|
|
15
|
+
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
14
16
|
|
|
15
17
|
export type SwapParams = {
|
|
16
18
|
/**
|
|
@@ -95,6 +97,11 @@ export interface IGardenJS extends EventBroker<GardenEvents> {
|
|
|
95
97
|
* @readonly
|
|
96
98
|
*/
|
|
97
99
|
get starknetHTLC(): IStarknetHTLC | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* The Solana relay.
|
|
102
|
+
* @readonly
|
|
103
|
+
*/
|
|
104
|
+
get solanaHTLC(): ISolanaHTLC | undefined;
|
|
98
105
|
/**
|
|
99
106
|
* The current quote.
|
|
100
107
|
* @readonly
|
|
@@ -152,17 +159,21 @@ export type GardenCoreConfig = {
|
|
|
152
159
|
orderbook?: IOrderbook;
|
|
153
160
|
quote?: IQuote;
|
|
154
161
|
blockNumberFetcher?: IBlockNumberFetcher;
|
|
162
|
+
btcWallet?: BitcoinWallet;
|
|
163
|
+
solanaProgramAddress?: string;
|
|
155
164
|
};
|
|
156
165
|
export type GardenHTLCModules = {
|
|
157
166
|
htlc: {
|
|
158
167
|
evm?: IEVMHTLC;
|
|
159
168
|
starknet?: IStarknetHTLC;
|
|
169
|
+
solana?: ISolanaHTLC;
|
|
160
170
|
};
|
|
161
171
|
};
|
|
162
172
|
export type GardenWalletModules = {
|
|
163
173
|
wallets: {
|
|
164
174
|
evm?: WalletClient;
|
|
165
175
|
starknet?: AccountInterface;
|
|
176
|
+
solana?: AnchorProvider;
|
|
166
177
|
};
|
|
167
178
|
};
|
|
168
179
|
export type GardenConfigWithWallets = GardenCoreConfig & GardenWalletModules;
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
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: '2bag6xpshpvPe7SJ9nSDLHpxqhEAoHPGpEkjNSv7gxoF';
|
|
9
|
+
metadata: {
|
|
10
|
+
name: 'solanaNativeSwaps';
|
|
11
|
+
version: '0.3.0';
|
|
12
|
+
spec: '0.1.0';
|
|
13
|
+
description: 'Created with Anchor';
|
|
14
|
+
};
|
|
15
|
+
instructions: [
|
|
16
|
+
{
|
|
17
|
+
name: 'initiate';
|
|
18
|
+
discriminator: [5, 63, 123, 113, 153, 75, 148, 14];
|
|
19
|
+
accounts: [
|
|
20
|
+
{
|
|
21
|
+
name: 'swapAccount';
|
|
22
|
+
writable: true;
|
|
23
|
+
pda: {
|
|
24
|
+
seeds: [
|
|
25
|
+
{
|
|
26
|
+
kind: 'const';
|
|
27
|
+
value: [115, 119, 97, 112, 95, 97, 99, 99, 111, 117, 110, 116];
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
kind: 'account';
|
|
31
|
+
path: 'initiator';
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
kind: 'arg';
|
|
35
|
+
path: 'secretHash';
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'initiator';
|
|
42
|
+
docs: ['Initiator must sign this transaction'];
|
|
43
|
+
writable: true;
|
|
44
|
+
signer: true;
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'systemProgram';
|
|
48
|
+
address: '11111111111111111111111111111111';
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
args: [
|
|
52
|
+
{
|
|
53
|
+
name: 'amountLamports';
|
|
54
|
+
type: 'u64';
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'expiresInSlots';
|
|
58
|
+
type: 'u64';
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'redeemer';
|
|
62
|
+
type: 'pubkey';
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'secretHash';
|
|
66
|
+
type: {
|
|
67
|
+
array: ['u8', 32];
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'instantRefund';
|
|
74
|
+
discriminator: [211, 202, 103, 41, 183, 147, 59, 251];
|
|
75
|
+
accounts: [
|
|
76
|
+
{
|
|
77
|
+
name: 'swapAccount';
|
|
78
|
+
writable: true;
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'initiator';
|
|
82
|
+
writable: true;
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'redeemer';
|
|
86
|
+
docs: ['Redeemer must sign this transaction'];
|
|
87
|
+
signer: true;
|
|
88
|
+
}
|
|
89
|
+
];
|
|
90
|
+
args: [];
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'redeem';
|
|
94
|
+
discriminator: [184, 12, 86, 149, 70, 196, 97, 225];
|
|
95
|
+
accounts: [
|
|
96
|
+
{
|
|
97
|
+
name: 'swapAccount';
|
|
98
|
+
writable: true;
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'initiator';
|
|
102
|
+
docs: [
|
|
103
|
+
'This is included here for the PDA rent refund using the `close` attribute above'
|
|
104
|
+
];
|
|
105
|
+
writable: true;
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'redeemer';
|
|
109
|
+
writable: true;
|
|
110
|
+
}
|
|
111
|
+
];
|
|
112
|
+
args: [
|
|
113
|
+
{
|
|
114
|
+
name: 'secret';
|
|
115
|
+
type: {
|
|
116
|
+
array: ['u8', 32];
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
];
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'refund';
|
|
123
|
+
discriminator: [2, 96, 183, 251, 63, 208, 46, 46];
|
|
124
|
+
accounts: [
|
|
125
|
+
{
|
|
126
|
+
name: 'swapAccount';
|
|
127
|
+
writable: true;
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'initiator';
|
|
131
|
+
writable: true;
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
args: [];
|
|
135
|
+
}
|
|
136
|
+
];
|
|
137
|
+
accounts: [
|
|
138
|
+
{
|
|
139
|
+
name: 'swapAccount';
|
|
140
|
+
discriminator: [53, 126, 9, 14, 14, 197, 105, 182];
|
|
141
|
+
}
|
|
142
|
+
];
|
|
143
|
+
events: [
|
|
144
|
+
{
|
|
145
|
+
name: 'initiated';
|
|
146
|
+
discriminator: [6, 108, 212, 91, 67, 60, 207, 221];
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'instantRefunded';
|
|
150
|
+
discriminator: [220, 50, 18, 207, 183, 232, 218, 25];
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: 'redeemed';
|
|
154
|
+
discriminator: [14, 29, 183, 71, 31, 165, 107, 38];
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: 'refunded';
|
|
158
|
+
discriminator: [35, 103, 149, 246, 196, 123, 221, 99];
|
|
159
|
+
}
|
|
160
|
+
];
|
|
161
|
+
errors: [
|
|
162
|
+
{
|
|
163
|
+
code: 6000;
|
|
164
|
+
name: 'invalidInitiator';
|
|
165
|
+
msg: 'The provided initiator is not the original initiator of this swap account';
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
code: 6001;
|
|
169
|
+
name: 'invalidRedeemer';
|
|
170
|
+
msg: 'The provided redeemer is not the original redeemer of this swap amount';
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
code: 6002;
|
|
174
|
+
name: 'invalidSecret';
|
|
175
|
+
msg: 'The provided secret does not correspond to the secret hash in the swap account';
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
code: 6003;
|
|
179
|
+
name: 'refundBeforeExpiry';
|
|
180
|
+
msg: 'Attempt to perform a refund before expiry time';
|
|
181
|
+
}
|
|
182
|
+
];
|
|
183
|
+
types: [
|
|
184
|
+
{
|
|
185
|
+
name: 'initiated';
|
|
186
|
+
type: {
|
|
187
|
+
kind: 'struct';
|
|
188
|
+
fields: [
|
|
189
|
+
{
|
|
190
|
+
name: 'amountLamports';
|
|
191
|
+
type: 'u64';
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: 'expiresInSlots';
|
|
195
|
+
type: 'u64';
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: 'initiator';
|
|
199
|
+
type: 'pubkey';
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: 'redeemer';
|
|
203
|
+
type: 'pubkey';
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: 'secretHash';
|
|
207
|
+
type: {
|
|
208
|
+
array: ['u8', 32];
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
];
|
|
212
|
+
};
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: 'instantRefunded';
|
|
216
|
+
type: {
|
|
217
|
+
kind: 'struct';
|
|
218
|
+
fields: [
|
|
219
|
+
{
|
|
220
|
+
name: 'initiator';
|
|
221
|
+
type: 'pubkey';
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: 'secretHash';
|
|
225
|
+
type: {
|
|
226
|
+
array: ['u8', 32];
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
];
|
|
230
|
+
};
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
name: 'redeemed';
|
|
234
|
+
type: {
|
|
235
|
+
kind: 'struct';
|
|
236
|
+
fields: [
|
|
237
|
+
{
|
|
238
|
+
name: 'initiator';
|
|
239
|
+
type: 'pubkey';
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: 'secret';
|
|
243
|
+
type: {
|
|
244
|
+
array: ['u8', 32];
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
];
|
|
248
|
+
};
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
name: 'refunded';
|
|
252
|
+
type: {
|
|
253
|
+
kind: 'struct';
|
|
254
|
+
fields: [
|
|
255
|
+
{
|
|
256
|
+
name: 'initiator';
|
|
257
|
+
type: 'pubkey';
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: 'secretHash';
|
|
261
|
+
type: {
|
|
262
|
+
array: ['u8', 32];
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
];
|
|
266
|
+
};
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: 'swapAccount';
|
|
270
|
+
type: {
|
|
271
|
+
kind: 'struct';
|
|
272
|
+
fields: [
|
|
273
|
+
{
|
|
274
|
+
name: 'amountLamports';
|
|
275
|
+
type: 'u64';
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
name: 'expirySlot';
|
|
279
|
+
type: 'u64';
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
name: 'initiator';
|
|
283
|
+
type: 'pubkey';
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
name: 'redeemer';
|
|
287
|
+
type: 'pubkey';
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: 'secretHash';
|
|
291
|
+
type: {
|
|
292
|
+
array: ['u8', 32];
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
];
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
];
|
|
299
|
+
};
|