@atomiqlabs/chain-solana 13.5.13 → 13.5.14
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/LICENSE +201 -201
- package/README.md +73 -73
- package/dist/index.d.ts +81 -81
- package/dist/index.js +102 -102
- package/dist/node/index.d.ts +9 -9
- package/dist/node/index.js +13 -13
- package/dist/solana/SolanaChainType.d.ts +15 -15
- package/dist/solana/SolanaChainType.js +2 -2
- package/dist/solana/SolanaChains.d.ts +12 -12
- package/dist/solana/SolanaChains.js +45 -45
- package/dist/solana/SolanaInitializer.d.ts +94 -94
- package/dist/solana/SolanaInitializer.js +174 -174
- package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +222 -222
- package/dist/solana/btcrelay/SolanaBtcRelay.js +455 -455
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.d.ts +84 -84
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.js +70 -70
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.d.ts +92 -92
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.js +109 -109
- package/dist/solana/btcrelay/program/programIdl.json +671 -671
- package/dist/solana/chain/SolanaAction.d.ts +26 -26
- package/dist/solana/chain/SolanaAction.js +87 -87
- package/dist/solana/chain/SolanaChainInterface.d.ts +224 -224
- package/dist/solana/chain/SolanaChainInterface.js +275 -275
- package/dist/solana/chain/SolanaModule.d.ts +14 -14
- package/dist/solana/chain/SolanaModule.js +13 -13
- package/dist/solana/chain/modules/SolanaAddresses.d.ts +8 -8
- package/dist/solana/chain/modules/SolanaAddresses.js +22 -22
- package/dist/solana/chain/modules/SolanaBlocks.d.ts +32 -32
- package/dist/solana/chain/modules/SolanaBlocks.js +78 -78
- package/dist/solana/chain/modules/SolanaEvents.d.ts +68 -68
- package/dist/solana/chain/modules/SolanaEvents.js +238 -238
- package/dist/solana/chain/modules/SolanaFees.d.ts +189 -189
- package/dist/solana/chain/modules/SolanaFees.js +434 -434
- package/dist/solana/chain/modules/SolanaSignatures.d.ts +24 -24
- package/dist/solana/chain/modules/SolanaSignatures.js +39 -39
- package/dist/solana/chain/modules/SolanaSlots.d.ts +33 -33
- package/dist/solana/chain/modules/SolanaSlots.js +72 -72
- package/dist/solana/chain/modules/SolanaTokens.d.ts +123 -123
- package/dist/solana/chain/modules/SolanaTokens.js +242 -242
- package/dist/solana/chain/modules/SolanaTransactions.d.ts +149 -149
- package/dist/solana/chain/modules/SolanaTransactions.js +445 -445
- package/dist/solana/connection/ConnectionWithRetries.d.ts +35 -35
- package/dist/solana/connection/ConnectionWithRetries.js +86 -71
- package/dist/solana/events/SolanaChainEvents.d.ts +45 -45
- package/dist/solana/events/SolanaChainEvents.js +108 -108
- package/dist/solana/events/SolanaChainEventsBrowser.d.ts +205 -205
- package/dist/solana/events/SolanaChainEventsBrowser.js +404 -404
- package/dist/solana/program/SolanaProgramBase.d.ts +73 -73
- package/dist/solana/program/SolanaProgramBase.js +54 -54
- package/dist/solana/program/SolanaProgramModule.d.ts +8 -8
- package/dist/solana/program/SolanaProgramModule.js +11 -11
- package/dist/solana/program/modules/SolanaProgramEvents.d.ts +53 -53
- package/dist/solana/program/modules/SolanaProgramEvents.js +117 -117
- package/dist/solana/swaps/SolanaSwapData.d.ts +333 -333
- package/dist/solana/swaps/SolanaSwapData.js +535 -535
- package/dist/solana/swaps/SolanaSwapModule.d.ts +11 -11
- package/dist/solana/swaps/SolanaSwapModule.js +12 -12
- package/dist/solana/swaps/SolanaSwapProgram.d.ts +376 -376
- package/dist/solana/swaps/SolanaSwapProgram.js +769 -769
- package/dist/solana/swaps/SwapTypeEnum.d.ts +11 -11
- package/dist/solana/swaps/SwapTypeEnum.js +43 -43
- package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +95 -95
- package/dist/solana/swaps/modules/SolanaDataAccount.js +232 -232
- package/dist/solana/swaps/modules/SolanaLpVault.d.ts +69 -69
- package/dist/solana/swaps/modules/SolanaLpVault.js +171 -171
- package/dist/solana/swaps/modules/SwapClaim.d.ts +126 -126
- package/dist/solana/swaps/modules/SwapClaim.js +294 -294
- package/dist/solana/swaps/modules/SwapInit.d.ts +213 -213
- package/dist/solana/swaps/modules/SwapInit.js +658 -658
- package/dist/solana/swaps/modules/SwapRefund.d.ts +87 -87
- package/dist/solana/swaps/modules/SwapRefund.js +293 -293
- package/dist/solana/swaps/programIdl.json +945 -945
- package/dist/solana/swaps/programTypes.d.ts +943 -943
- package/dist/solana/swaps/programTypes.js +945 -945
- package/dist/solana/swaps/v1/programIdl.json +945 -945
- package/dist/solana/swaps/v1/programTypes.d.ts +943 -943
- package/dist/solana/swaps/v1/programTypes.js +945 -945
- package/dist/solana/swaps/v2/programIdl.json +952 -952
- package/dist/solana/swaps/v2/programTypes.d.ts +950 -950
- package/dist/solana/swaps/v2/programTypes.js +952 -952
- package/dist/solana/wallet/SolanaKeypairWallet.d.ts +29 -29
- package/dist/solana/wallet/SolanaKeypairWallet.js +50 -50
- package/dist/solana/wallet/SolanaSigner.d.ts +30 -30
- package/dist/solana/wallet/SolanaSigner.js +30 -30
- package/dist/utils/Utils.d.ts +58 -58
- package/dist/utils/Utils.js +170 -170
- package/node/index.d.ts +1 -1
- package/node/index.js +3 -3
- package/package.json +46 -46
- package/src/index.ts +87 -87
- package/src/node/index.ts +9 -9
- package/src/solana/SolanaChainType.ts +32 -32
- package/src/solana/SolanaChains.ts +46 -46
- package/src/solana/SolanaInitializer.ts +278 -278
- package/src/solana/btcrelay/SolanaBtcRelay.ts +615 -615
- package/src/solana/btcrelay/headers/SolanaBtcHeader.ts +116 -116
- package/src/solana/btcrelay/headers/SolanaBtcStoredHeader.ts +148 -148
- package/src/solana/btcrelay/program/programIdl.json +670 -670
- package/src/solana/chain/SolanaAction.ts +109 -109
- package/src/solana/chain/SolanaChainInterface.ts +404 -404
- package/src/solana/chain/SolanaModule.ts +20 -20
- package/src/solana/chain/modules/SolanaAddresses.ts +20 -20
- package/src/solana/chain/modules/SolanaBlocks.ts +89 -89
- package/src/solana/chain/modules/SolanaEvents.ts +271 -271
- package/src/solana/chain/modules/SolanaFees.ts +522 -522
- package/src/solana/chain/modules/SolanaSignatures.ts +39 -39
- package/src/solana/chain/modules/SolanaSlots.ts +85 -85
- package/src/solana/chain/modules/SolanaTokens.ts +300 -300
- package/src/solana/chain/modules/SolanaTransactions.ts +503 -503
- package/src/solana/connection/ConnectionWithRetries.ts +113 -96
- package/src/solana/events/SolanaChainEvents.ts +127 -127
- package/src/solana/events/SolanaChainEventsBrowser.ts +495 -495
- package/src/solana/program/SolanaProgramBase.ts +119 -119
- package/src/solana/program/SolanaProgramModule.ts +15 -15
- package/src/solana/program/modules/SolanaProgramEvents.ts +157 -157
- package/src/solana/swaps/SolanaSwapData.ts +735 -735
- package/src/solana/swaps/SolanaSwapModule.ts +19 -19
- package/src/solana/swaps/SolanaSwapProgram.ts +1074 -1074
- package/src/solana/swaps/SwapTypeEnum.ts +30 -30
- package/src/solana/swaps/modules/SolanaDataAccount.ts +302 -302
- package/src/solana/swaps/modules/SolanaLpVault.ts +208 -208
- package/src/solana/swaps/modules/SwapClaim.ts +387 -387
- package/src/solana/swaps/modules/SwapInit.ts +785 -785
- package/src/solana/swaps/modules/SwapRefund.ts +353 -353
- package/src/solana/swaps/v1/programIdl.json +944 -944
- package/src/solana/swaps/v1/programTypes.ts +1885 -1885
- package/src/solana/swaps/v2/programIdl.json +951 -951
- package/src/solana/swaps/v2/programTypes.ts +1899 -1899
- package/src/solana/wallet/SolanaKeypairWallet.ts +56 -56
- package/src/solana/wallet/SolanaSigner.ts +43 -43
- package/src/utils/Utils.ts +194 -194
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import { BaseTokenType, BitcoinNetwork, BitcoinRpc, ChainData, ChainInitializer, IStorageManager, StorageObject } from "@atomiqlabs/base";
|
|
2
|
-
import { Connection } from "@solana/web3.js";
|
|
3
|
-
import { StoredDataAccount } from "./swaps/modules/SolanaDataAccount";
|
|
4
|
-
import { SolanaRetryPolicy } from "./chain/SolanaChainInterface";
|
|
5
|
-
import { SolanaFees } from "./chain/modules/SolanaFees";
|
|
6
|
-
import { SolanaChainType } from "./SolanaChainType";
|
|
7
|
-
/**
|
|
8
|
-
* Token assets available on Solana
|
|
9
|
-
* @category Chain Interface
|
|
10
|
-
*/
|
|
11
|
-
export type SolanaAssetsType = BaseTokenType<"WBTC" | "USDC" | "USDT" | "SOL" | "BONK">;
|
|
12
|
-
/**
|
|
13
|
-
* Configuration options for initializing Solana chain
|
|
14
|
-
* @category Chain Interface
|
|
15
|
-
*/
|
|
16
|
-
export type SolanaSwapperOptions = {
|
|
17
|
-
/**
|
|
18
|
-
* RPC url or {@link Connection} object to use for Solana network access
|
|
19
|
-
*/
|
|
20
|
-
rpcUrl: string | Connection;
|
|
21
|
-
/**
|
|
22
|
-
* Storage backend to use for storing ephemeral data submission accounts, i.e. accounts that are used
|
|
23
|
-
* to submit large amount of data to an instruction that would otherwise be bigger than the transaction
|
|
24
|
-
* size limit - used for submitting bitcoin transaction proofs for PrTLC swaps
|
|
25
|
-
*/
|
|
26
|
-
dataAccountStorage?: IStorageManager<StoredDataAccount>;
|
|
27
|
-
/**
|
|
28
|
-
* Retry policy to be used for Solana RPC calls and transaction submission
|
|
29
|
-
*/
|
|
30
|
-
retryPolicy?: SolanaRetryPolicy;
|
|
31
|
-
/**
|
|
32
|
-
* Optional Solana program address of the BTC Relay contract, uses the canonical deployment by default
|
|
33
|
-
*/
|
|
34
|
-
btcRelayContract?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Optional Solana program address of the Swap contract, uses the canonical deployment by default
|
|
37
|
-
*/
|
|
38
|
-
swapContract?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Solana fee API to use for fetching Solana network fees
|
|
41
|
-
*/
|
|
42
|
-
fees?: SolanaFees;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Initialize Solana chain integration using the v1 as the default version of the contracts
|
|
46
|
-
*
|
|
47
|
-
* @param options Options for initializing the Solana chain
|
|
48
|
-
* @param bitcoinRpc Bitcoin RPC to use for bitcoin read access
|
|
49
|
-
* @param network Bitcoin network to use - determines Solana program addresses to use by default
|
|
50
|
-
* @param storageCtor Storage constructor used to create storage backend for ephemeral data submission accounts,
|
|
51
|
-
* i.e. accounts that are used to submit large amount of data to an instruction that would otherwise be bigger
|
|
52
|
-
* than the transaction size limit - used for submitting bitcoin transaction proofs for PrTLC swaps
|
|
53
|
-
*
|
|
54
|
-
* @category Chain Interface
|
|
55
|
-
*/
|
|
56
|
-
export declare function initializeSolana(options: SolanaSwapperOptions, bitcoinRpc: BitcoinRpc<any>, network: BitcoinNetwork, storageCtor: <T extends StorageObject>(name: string) => IStorageManager<T>): ChainData<SolanaChainType<"v1">>;
|
|
57
|
-
/**
|
|
58
|
-
* Initialize Solana chain integration using the new v2 version as the default version of the contracts
|
|
59
|
-
*
|
|
60
|
-
* @param options Options for initializing the Solana chain
|
|
61
|
-
* @param bitcoinRpc Bitcoin RPC to use for bitcoin read access
|
|
62
|
-
* @param network Bitcoin network to use - determines Solana program addresses to use by default
|
|
63
|
-
* @param storageCtor Storage constructor used to create storage backend for ephemeral data submission accounts,
|
|
64
|
-
* i.e. accounts that are used to submit large amount of data to an instruction that would otherwise be bigger
|
|
65
|
-
* than the transaction size limit - used for submitting bitcoin transaction proofs for PrTLC swaps
|
|
66
|
-
*
|
|
67
|
-
* @category Chain Interface
|
|
68
|
-
*/
|
|
69
|
-
export declare function initializeSolanaV2(options: SolanaSwapperOptions, bitcoinRpc: BitcoinRpc<any>, network: BitcoinNetwork, storageCtor: <T extends StorageObject>(name: string) => IStorageManager<T>): ChainData<SolanaChainType<"v2">>;
|
|
70
|
-
/**
|
|
71
|
-
* Type definition for the Solana chain initializer
|
|
72
|
-
*
|
|
73
|
-
* @category Chain Interface
|
|
74
|
-
*/
|
|
75
|
-
export type SolanaInitializerType<Version extends "v1" | "v2" = "v1"> = ChainInitializer<SolanaSwapperOptions, SolanaChainType<Version>, SolanaAssetsType>;
|
|
76
|
-
/**
|
|
77
|
-
* Solana chain initializer instance, used in the SwapperFactory constructor in the SDK library
|
|
78
|
-
*
|
|
79
|
-
* Uses the legacy v1 version of the contract as the default exported version, this doesn't support the new
|
|
80
|
-
* v2 lightning network flow, use the {@link SolanaInitializerV2} to initialize the SDK with the v2
|
|
81
|
-
* contracts as the default, which do have an explicit support for new lightning network swap flow
|
|
82
|
-
*
|
|
83
|
-
* @category Chain Interface
|
|
84
|
-
*/
|
|
85
|
-
export declare const SolanaInitializer: SolanaInitializerType<"v1">;
|
|
86
|
-
/**
|
|
87
|
-
* Solana chain initializer instance, used in the SwapperFactory constructor in the SDK library
|
|
88
|
-
*
|
|
89
|
-
* Uses the new v2 version of the contracts as default exported version, supported the new lightning network
|
|
90
|
-
* swap flow.
|
|
91
|
-
*
|
|
92
|
-
* @category Chain Interface
|
|
93
|
-
*/
|
|
94
|
-
export declare const SolanaInitializerV2: SolanaInitializerType<"v2">;
|
|
1
|
+
import { BaseTokenType, BitcoinNetwork, BitcoinRpc, ChainData, ChainInitializer, IStorageManager, StorageObject } from "@atomiqlabs/base";
|
|
2
|
+
import { Connection } from "@solana/web3.js";
|
|
3
|
+
import { StoredDataAccount } from "./swaps/modules/SolanaDataAccount";
|
|
4
|
+
import { SolanaRetryPolicy } from "./chain/SolanaChainInterface";
|
|
5
|
+
import { SolanaFees } from "./chain/modules/SolanaFees";
|
|
6
|
+
import { SolanaChainType } from "./SolanaChainType";
|
|
7
|
+
/**
|
|
8
|
+
* Token assets available on Solana
|
|
9
|
+
* @category Chain Interface
|
|
10
|
+
*/
|
|
11
|
+
export type SolanaAssetsType = BaseTokenType<"WBTC" | "USDC" | "USDT" | "SOL" | "BONK">;
|
|
12
|
+
/**
|
|
13
|
+
* Configuration options for initializing Solana chain
|
|
14
|
+
* @category Chain Interface
|
|
15
|
+
*/
|
|
16
|
+
export type SolanaSwapperOptions = {
|
|
17
|
+
/**
|
|
18
|
+
* RPC url or {@link Connection} object to use for Solana network access
|
|
19
|
+
*/
|
|
20
|
+
rpcUrl: string | Connection;
|
|
21
|
+
/**
|
|
22
|
+
* Storage backend to use for storing ephemeral data submission accounts, i.e. accounts that are used
|
|
23
|
+
* to submit large amount of data to an instruction that would otherwise be bigger than the transaction
|
|
24
|
+
* size limit - used for submitting bitcoin transaction proofs for PrTLC swaps
|
|
25
|
+
*/
|
|
26
|
+
dataAccountStorage?: IStorageManager<StoredDataAccount>;
|
|
27
|
+
/**
|
|
28
|
+
* Retry policy to be used for Solana RPC calls and transaction submission
|
|
29
|
+
*/
|
|
30
|
+
retryPolicy?: SolanaRetryPolicy;
|
|
31
|
+
/**
|
|
32
|
+
* Optional Solana program address of the BTC Relay contract, uses the canonical deployment by default
|
|
33
|
+
*/
|
|
34
|
+
btcRelayContract?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Optional Solana program address of the Swap contract, uses the canonical deployment by default
|
|
37
|
+
*/
|
|
38
|
+
swapContract?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Solana fee API to use for fetching Solana network fees
|
|
41
|
+
*/
|
|
42
|
+
fees?: SolanaFees;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Initialize Solana chain integration using the v1 as the default version of the contracts
|
|
46
|
+
*
|
|
47
|
+
* @param options Options for initializing the Solana chain
|
|
48
|
+
* @param bitcoinRpc Bitcoin RPC to use for bitcoin read access
|
|
49
|
+
* @param network Bitcoin network to use - determines Solana program addresses to use by default
|
|
50
|
+
* @param storageCtor Storage constructor used to create storage backend for ephemeral data submission accounts,
|
|
51
|
+
* i.e. accounts that are used to submit large amount of data to an instruction that would otherwise be bigger
|
|
52
|
+
* than the transaction size limit - used for submitting bitcoin transaction proofs for PrTLC swaps
|
|
53
|
+
*
|
|
54
|
+
* @category Chain Interface
|
|
55
|
+
*/
|
|
56
|
+
export declare function initializeSolana(options: SolanaSwapperOptions, bitcoinRpc: BitcoinRpc<any>, network: BitcoinNetwork, storageCtor: <T extends StorageObject>(name: string) => IStorageManager<T>): ChainData<SolanaChainType<"v1">>;
|
|
57
|
+
/**
|
|
58
|
+
* Initialize Solana chain integration using the new v2 version as the default version of the contracts
|
|
59
|
+
*
|
|
60
|
+
* @param options Options for initializing the Solana chain
|
|
61
|
+
* @param bitcoinRpc Bitcoin RPC to use for bitcoin read access
|
|
62
|
+
* @param network Bitcoin network to use - determines Solana program addresses to use by default
|
|
63
|
+
* @param storageCtor Storage constructor used to create storage backend for ephemeral data submission accounts,
|
|
64
|
+
* i.e. accounts that are used to submit large amount of data to an instruction that would otherwise be bigger
|
|
65
|
+
* than the transaction size limit - used for submitting bitcoin transaction proofs for PrTLC swaps
|
|
66
|
+
*
|
|
67
|
+
* @category Chain Interface
|
|
68
|
+
*/
|
|
69
|
+
export declare function initializeSolanaV2(options: SolanaSwapperOptions, bitcoinRpc: BitcoinRpc<any>, network: BitcoinNetwork, storageCtor: <T extends StorageObject>(name: string) => IStorageManager<T>): ChainData<SolanaChainType<"v2">>;
|
|
70
|
+
/**
|
|
71
|
+
* Type definition for the Solana chain initializer
|
|
72
|
+
*
|
|
73
|
+
* @category Chain Interface
|
|
74
|
+
*/
|
|
75
|
+
export type SolanaInitializerType<Version extends "v1" | "v2" = "v1"> = ChainInitializer<SolanaSwapperOptions, SolanaChainType<Version>, SolanaAssetsType>;
|
|
76
|
+
/**
|
|
77
|
+
* Solana chain initializer instance, used in the SwapperFactory constructor in the SDK library
|
|
78
|
+
*
|
|
79
|
+
* Uses the legacy v1 version of the contract as the default exported version, this doesn't support the new
|
|
80
|
+
* v2 lightning network flow, use the {@link SolanaInitializerV2} to initialize the SDK with the v2
|
|
81
|
+
* contracts as the default, which do have an explicit support for new lightning network swap flow
|
|
82
|
+
*
|
|
83
|
+
* @category Chain Interface
|
|
84
|
+
*/
|
|
85
|
+
export declare const SolanaInitializer: SolanaInitializerType<"v1">;
|
|
86
|
+
/**
|
|
87
|
+
* Solana chain initializer instance, used in the SwapperFactory constructor in the SDK library
|
|
88
|
+
*
|
|
89
|
+
* Uses the new v2 version of the contracts as default exported version, supported the new lightning network
|
|
90
|
+
* swap flow.
|
|
91
|
+
*
|
|
92
|
+
* @category Chain Interface
|
|
93
|
+
*/
|
|
94
|
+
export declare const SolanaInitializerV2: SolanaInitializerType<"v2">;
|
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SolanaInitializerV2 = exports.SolanaInitializer = exports.initializeSolanaV2 = exports.initializeSolana = void 0;
|
|
4
|
-
const base_1 = require("@atomiqlabs/base");
|
|
5
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
-
const SolanaChainInterface_1 = require("./chain/SolanaChainInterface");
|
|
7
|
-
const SolanaFees_1 = require("./chain/modules/SolanaFees");
|
|
8
|
-
const SolanaBtcRelay_1 = require("./btcrelay/SolanaBtcRelay");
|
|
9
|
-
const SolanaChains_1 = require("./SolanaChains");
|
|
10
|
-
const SolanaSwapProgram_1 = require("./swaps/SolanaSwapProgram");
|
|
11
|
-
const SolanaChainEventsBrowser_1 = require("./events/SolanaChainEventsBrowser");
|
|
12
|
-
const SolanaSwapData_1 = require("./swaps/SolanaSwapData");
|
|
13
|
-
const chainId = "SOLANA";
|
|
14
|
-
const SolanaAssets = {
|
|
15
|
-
WBTC: {
|
|
16
|
-
address: "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh",
|
|
17
|
-
decimals: 8
|
|
18
|
-
},
|
|
19
|
-
USDC: {
|
|
20
|
-
address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
21
|
-
decimals: 6
|
|
22
|
-
},
|
|
23
|
-
USDT: {
|
|
24
|
-
address: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
|
|
25
|
-
decimals: 6
|
|
26
|
-
},
|
|
27
|
-
SOL: {
|
|
28
|
-
address: "So11111111111111111111111111111111111111112",
|
|
29
|
-
decimals: 9
|
|
30
|
-
},
|
|
31
|
-
BONK: {
|
|
32
|
-
address: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
|
|
33
|
-
decimals: 5
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Initialize Solana chain integration
|
|
38
|
-
*
|
|
39
|
-
* @param version
|
|
40
|
-
* @param options Options for initializing the Solana chain
|
|
41
|
-
* @param bitcoinRpc Bitcoin RPC to use for bitcoin read access
|
|
42
|
-
* @param network Bitcoin network to use - determines Solana program addresses to use by default
|
|
43
|
-
* @param storageCtor Storage constructor used to create storage backend for ephemeral data submission accounts,
|
|
44
|
-
* i.e. accounts that are used to submit large amount of data to an instruction that would otherwise be bigger
|
|
45
|
-
* than the transaction size limit - used for submitting bitcoin transaction proofs for PrTLC swaps
|
|
46
|
-
*
|
|
47
|
-
* @category Chain Interface
|
|
48
|
-
*/
|
|
49
|
-
function _initializeSolana(version, options, bitcoinRpc, network, storageCtor) {
|
|
50
|
-
const connection = typeof (options.rpcUrl) === "string" ?
|
|
51
|
-
new web3_js_1.Connection(options.rpcUrl) :
|
|
52
|
-
options.rpcUrl;
|
|
53
|
-
const Fees = options.fees ?? new SolanaFees_1.SolanaFees(connection, 200000, 4, 100);
|
|
54
|
-
const chainInterface = new SolanaChainInterface_1.SolanaChainInterface(connection, options.retryPolicy ?? { transactionResendInterval: 1000 }, Fees);
|
|
55
|
-
const versionedContracts = {};
|
|
56
|
-
if (options.btcRelayContract || options.swapContract) {
|
|
57
|
-
// Initialize only that version
|
|
58
|
-
const btcRelayContractAddress = options.btcRelayContract ?? SolanaChains_1.SolanaChains[network]?.addresses[version]?.btcRelayContract;
|
|
59
|
-
const swapContractAddress = options.swapContract ?? SolanaChains_1.SolanaChains[network]?.addresses[version]?.swapContract;
|
|
60
|
-
if (btcRelayContractAddress == null)
|
|
61
|
-
throw new Error(`Unsupported bitcoin network for Solana, using default version ${version}: ${base_1.BitcoinNetwork[network]}, please pass a custom deployment btc relay program address!`);
|
|
62
|
-
if (swapContractAddress == null)
|
|
63
|
-
throw new Error(`Unsupported bitcoin network for Solana, using default version ${version}: ${base_1.BitcoinNetwork[network]}, please pass a custom deployment swap program address!`);
|
|
64
|
-
const btcRelay = new SolanaBtcRelay_1.SolanaBtcRelay(chainInterface, bitcoinRpc, btcRelayContractAddress);
|
|
65
|
-
const swapContract = new SolanaSwapProgram_1.SolanaSwapProgram(chainInterface, btcRelay, options.dataAccountStorage || storageCtor("solAccounts"), swapContractAddress, network, version);
|
|
66
|
-
versionedContracts[version] = {
|
|
67
|
-
btcRelay,
|
|
68
|
-
swapContract: swapContract,
|
|
69
|
-
swapDataConstructor: version === "v1" ? SolanaSwapData_1.SolanaSwapDataV1 : SolanaSwapData_1.SolanaSwapDataV2,
|
|
70
|
-
spvVaultContract: null,
|
|
71
|
-
spvVaultDataConstructor: null,
|
|
72
|
-
spvVaultWithdrawalDataConstructor: null
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
// Initialize all versions
|
|
77
|
-
const solanaChainData = SolanaChains_1.SolanaChains[network];
|
|
78
|
-
if (solanaChainData == null)
|
|
79
|
-
throw new Error(`Unsupported bitcoin network for Solana: ${base_1.BitcoinNetwork[network]}, please pass a custom deployment program addresses!`);
|
|
80
|
-
for (let _version in solanaChainData.addresses) {
|
|
81
|
-
const version = _version;
|
|
82
|
-
const btcRelay = new SolanaBtcRelay_1.SolanaBtcRelay(chainInterface, bitcoinRpc, solanaChainData.addresses[version].btcRelayContract);
|
|
83
|
-
const swapContract = new SolanaSwapProgram_1.SolanaSwapProgram(chainInterface, btcRelay, options.dataAccountStorage || storageCtor("solAccounts"), solanaChainData.addresses[version].swapContract, network, version);
|
|
84
|
-
versionedContracts[version] = {
|
|
85
|
-
btcRelay,
|
|
86
|
-
swapContract: swapContract,
|
|
87
|
-
swapDataConstructor: version === "v1" ? SolanaSwapData_1.SolanaSwapDataV1 : SolanaSwapData_1.SolanaSwapDataV2,
|
|
88
|
-
spvVaultContract: null,
|
|
89
|
-
spvVaultDataConstructor: null,
|
|
90
|
-
spvVaultWithdrawalDataConstructor: null
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
const chainEvents = new SolanaChainEventsBrowser_1.SolanaChainEventsBrowser(connection, versionedContracts);
|
|
95
|
-
const defaults = versionedContracts[version];
|
|
96
|
-
if (defaults == null)
|
|
97
|
-
throw new Error(`Unsupported bitcoin network for Solana, using default version ${version}: ${base_1.BitcoinNetwork[network]}, please pass a custom deployment program addresses!`);
|
|
98
|
-
return {
|
|
99
|
-
chainId,
|
|
100
|
-
chainInterface,
|
|
101
|
-
btcRelay: defaults.btcRelay,
|
|
102
|
-
swapContract: defaults.swapContract,
|
|
103
|
-
chainEvents,
|
|
104
|
-
swapDataConstructor: defaults.swapDataConstructor,
|
|
105
|
-
spvVaultContract: defaults.spvVaultContract,
|
|
106
|
-
spvVaultDataConstructor: defaults.spvVaultDataConstructor,
|
|
107
|
-
spvVaultWithdrawalDataConstructor: defaults.spvVaultWithdrawalDataConstructor,
|
|
108
|
-
defaultVersion: version,
|
|
109
|
-
versions: versionedContracts
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Initialize Solana chain integration using the v1 as the default version of the contracts
|
|
114
|
-
*
|
|
115
|
-
* @param options Options for initializing the Solana chain
|
|
116
|
-
* @param bitcoinRpc Bitcoin RPC to use for bitcoin read access
|
|
117
|
-
* @param network Bitcoin network to use - determines Solana program addresses to use by default
|
|
118
|
-
* @param storageCtor Storage constructor used to create storage backend for ephemeral data submission accounts,
|
|
119
|
-
* i.e. accounts that are used to submit large amount of data to an instruction that would otherwise be bigger
|
|
120
|
-
* than the transaction size limit - used for submitting bitcoin transaction proofs for PrTLC swaps
|
|
121
|
-
*
|
|
122
|
-
* @category Chain Interface
|
|
123
|
-
*/
|
|
124
|
-
function initializeSolana(options, bitcoinRpc, network, storageCtor) {
|
|
125
|
-
return _initializeSolana("v1", options, bitcoinRpc, network, storageCtor);
|
|
126
|
-
}
|
|
127
|
-
exports.initializeSolana = initializeSolana;
|
|
128
|
-
/**
|
|
129
|
-
* Initialize Solana chain integration using the new v2 version as the default version of the contracts
|
|
130
|
-
*
|
|
131
|
-
* @param options Options for initializing the Solana chain
|
|
132
|
-
* @param bitcoinRpc Bitcoin RPC to use for bitcoin read access
|
|
133
|
-
* @param network Bitcoin network to use - determines Solana program addresses to use by default
|
|
134
|
-
* @param storageCtor Storage constructor used to create storage backend for ephemeral data submission accounts,
|
|
135
|
-
* i.e. accounts that are used to submit large amount of data to an instruction that would otherwise be bigger
|
|
136
|
-
* than the transaction size limit - used for submitting bitcoin transaction proofs for PrTLC swaps
|
|
137
|
-
*
|
|
138
|
-
* @category Chain Interface
|
|
139
|
-
*/
|
|
140
|
-
function initializeSolanaV2(options, bitcoinRpc, network, storageCtor) {
|
|
141
|
-
return _initializeSolana("v2", options, bitcoinRpc, network, storageCtor);
|
|
142
|
-
}
|
|
143
|
-
exports.initializeSolanaV2 = initializeSolanaV2;
|
|
144
|
-
/**
|
|
145
|
-
* Solana chain initializer instance, used in the SwapperFactory constructor in the SDK library
|
|
146
|
-
*
|
|
147
|
-
* Uses the legacy v1 version of the contract as the default exported version, this doesn't support the new
|
|
148
|
-
* v2 lightning network flow, use the {@link SolanaInitializerV2} to initialize the SDK with the v2
|
|
149
|
-
* contracts as the default, which do have an explicit support for new lightning network swap flow
|
|
150
|
-
*
|
|
151
|
-
* @category Chain Interface
|
|
152
|
-
*/
|
|
153
|
-
exports.SolanaInitializer = {
|
|
154
|
-
chainId,
|
|
155
|
-
chainType: null,
|
|
156
|
-
initializer: initializeSolana,
|
|
157
|
-
tokens: SolanaAssets,
|
|
158
|
-
options: null
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* Solana chain initializer instance, used in the SwapperFactory constructor in the SDK library
|
|
162
|
-
*
|
|
163
|
-
* Uses the new v2 version of the contracts as default exported version, supported the new lightning network
|
|
164
|
-
* swap flow.
|
|
165
|
-
*
|
|
166
|
-
* @category Chain Interface
|
|
167
|
-
*/
|
|
168
|
-
exports.SolanaInitializerV2 = {
|
|
169
|
-
chainId,
|
|
170
|
-
chainType: null,
|
|
171
|
-
initializer: initializeSolanaV2,
|
|
172
|
-
tokens: SolanaAssets,
|
|
173
|
-
options: null
|
|
174
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolanaInitializerV2 = exports.SolanaInitializer = exports.initializeSolanaV2 = exports.initializeSolana = void 0;
|
|
4
|
+
const base_1 = require("@atomiqlabs/base");
|
|
5
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
+
const SolanaChainInterface_1 = require("./chain/SolanaChainInterface");
|
|
7
|
+
const SolanaFees_1 = require("./chain/modules/SolanaFees");
|
|
8
|
+
const SolanaBtcRelay_1 = require("./btcrelay/SolanaBtcRelay");
|
|
9
|
+
const SolanaChains_1 = require("./SolanaChains");
|
|
10
|
+
const SolanaSwapProgram_1 = require("./swaps/SolanaSwapProgram");
|
|
11
|
+
const SolanaChainEventsBrowser_1 = require("./events/SolanaChainEventsBrowser");
|
|
12
|
+
const SolanaSwapData_1 = require("./swaps/SolanaSwapData");
|
|
13
|
+
const chainId = "SOLANA";
|
|
14
|
+
const SolanaAssets = {
|
|
15
|
+
WBTC: {
|
|
16
|
+
address: "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh",
|
|
17
|
+
decimals: 8
|
|
18
|
+
},
|
|
19
|
+
USDC: {
|
|
20
|
+
address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
21
|
+
decimals: 6
|
|
22
|
+
},
|
|
23
|
+
USDT: {
|
|
24
|
+
address: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
|
|
25
|
+
decimals: 6
|
|
26
|
+
},
|
|
27
|
+
SOL: {
|
|
28
|
+
address: "So11111111111111111111111111111111111111112",
|
|
29
|
+
decimals: 9
|
|
30
|
+
},
|
|
31
|
+
BONK: {
|
|
32
|
+
address: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
|
|
33
|
+
decimals: 5
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Initialize Solana chain integration
|
|
38
|
+
*
|
|
39
|
+
* @param version
|
|
40
|
+
* @param options Options for initializing the Solana chain
|
|
41
|
+
* @param bitcoinRpc Bitcoin RPC to use for bitcoin read access
|
|
42
|
+
* @param network Bitcoin network to use - determines Solana program addresses to use by default
|
|
43
|
+
* @param storageCtor Storage constructor used to create storage backend for ephemeral data submission accounts,
|
|
44
|
+
* i.e. accounts that are used to submit large amount of data to an instruction that would otherwise be bigger
|
|
45
|
+
* than the transaction size limit - used for submitting bitcoin transaction proofs for PrTLC swaps
|
|
46
|
+
*
|
|
47
|
+
* @category Chain Interface
|
|
48
|
+
*/
|
|
49
|
+
function _initializeSolana(version, options, bitcoinRpc, network, storageCtor) {
|
|
50
|
+
const connection = typeof (options.rpcUrl) === "string" ?
|
|
51
|
+
new web3_js_1.Connection(options.rpcUrl) :
|
|
52
|
+
options.rpcUrl;
|
|
53
|
+
const Fees = options.fees ?? new SolanaFees_1.SolanaFees(connection, 200000, 4, 100);
|
|
54
|
+
const chainInterface = new SolanaChainInterface_1.SolanaChainInterface(connection, options.retryPolicy ?? { transactionResendInterval: 1000 }, Fees);
|
|
55
|
+
const versionedContracts = {};
|
|
56
|
+
if (options.btcRelayContract || options.swapContract) {
|
|
57
|
+
// Initialize only that version
|
|
58
|
+
const btcRelayContractAddress = options.btcRelayContract ?? SolanaChains_1.SolanaChains[network]?.addresses[version]?.btcRelayContract;
|
|
59
|
+
const swapContractAddress = options.swapContract ?? SolanaChains_1.SolanaChains[network]?.addresses[version]?.swapContract;
|
|
60
|
+
if (btcRelayContractAddress == null)
|
|
61
|
+
throw new Error(`Unsupported bitcoin network for Solana, using default version ${version}: ${base_1.BitcoinNetwork[network]}, please pass a custom deployment btc relay program address!`);
|
|
62
|
+
if (swapContractAddress == null)
|
|
63
|
+
throw new Error(`Unsupported bitcoin network for Solana, using default version ${version}: ${base_1.BitcoinNetwork[network]}, please pass a custom deployment swap program address!`);
|
|
64
|
+
const btcRelay = new SolanaBtcRelay_1.SolanaBtcRelay(chainInterface, bitcoinRpc, btcRelayContractAddress);
|
|
65
|
+
const swapContract = new SolanaSwapProgram_1.SolanaSwapProgram(chainInterface, btcRelay, options.dataAccountStorage || storageCtor("solAccounts"), swapContractAddress, network, version);
|
|
66
|
+
versionedContracts[version] = {
|
|
67
|
+
btcRelay,
|
|
68
|
+
swapContract: swapContract,
|
|
69
|
+
swapDataConstructor: version === "v1" ? SolanaSwapData_1.SolanaSwapDataV1 : SolanaSwapData_1.SolanaSwapDataV2,
|
|
70
|
+
spvVaultContract: null,
|
|
71
|
+
spvVaultDataConstructor: null,
|
|
72
|
+
spvVaultWithdrawalDataConstructor: null
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// Initialize all versions
|
|
77
|
+
const solanaChainData = SolanaChains_1.SolanaChains[network];
|
|
78
|
+
if (solanaChainData == null)
|
|
79
|
+
throw new Error(`Unsupported bitcoin network for Solana: ${base_1.BitcoinNetwork[network]}, please pass a custom deployment program addresses!`);
|
|
80
|
+
for (let _version in solanaChainData.addresses) {
|
|
81
|
+
const version = _version;
|
|
82
|
+
const btcRelay = new SolanaBtcRelay_1.SolanaBtcRelay(chainInterface, bitcoinRpc, solanaChainData.addresses[version].btcRelayContract);
|
|
83
|
+
const swapContract = new SolanaSwapProgram_1.SolanaSwapProgram(chainInterface, btcRelay, options.dataAccountStorage || storageCtor("solAccounts"), solanaChainData.addresses[version].swapContract, network, version);
|
|
84
|
+
versionedContracts[version] = {
|
|
85
|
+
btcRelay,
|
|
86
|
+
swapContract: swapContract,
|
|
87
|
+
swapDataConstructor: version === "v1" ? SolanaSwapData_1.SolanaSwapDataV1 : SolanaSwapData_1.SolanaSwapDataV2,
|
|
88
|
+
spvVaultContract: null,
|
|
89
|
+
spvVaultDataConstructor: null,
|
|
90
|
+
spvVaultWithdrawalDataConstructor: null
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const chainEvents = new SolanaChainEventsBrowser_1.SolanaChainEventsBrowser(connection, versionedContracts);
|
|
95
|
+
const defaults = versionedContracts[version];
|
|
96
|
+
if (defaults == null)
|
|
97
|
+
throw new Error(`Unsupported bitcoin network for Solana, using default version ${version}: ${base_1.BitcoinNetwork[network]}, please pass a custom deployment program addresses!`);
|
|
98
|
+
return {
|
|
99
|
+
chainId,
|
|
100
|
+
chainInterface,
|
|
101
|
+
btcRelay: defaults.btcRelay,
|
|
102
|
+
swapContract: defaults.swapContract,
|
|
103
|
+
chainEvents,
|
|
104
|
+
swapDataConstructor: defaults.swapDataConstructor,
|
|
105
|
+
spvVaultContract: defaults.spvVaultContract,
|
|
106
|
+
spvVaultDataConstructor: defaults.spvVaultDataConstructor,
|
|
107
|
+
spvVaultWithdrawalDataConstructor: defaults.spvVaultWithdrawalDataConstructor,
|
|
108
|
+
defaultVersion: version,
|
|
109
|
+
versions: versionedContracts
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Initialize Solana chain integration using the v1 as the default version of the contracts
|
|
114
|
+
*
|
|
115
|
+
* @param options Options for initializing the Solana chain
|
|
116
|
+
* @param bitcoinRpc Bitcoin RPC to use for bitcoin read access
|
|
117
|
+
* @param network Bitcoin network to use - determines Solana program addresses to use by default
|
|
118
|
+
* @param storageCtor Storage constructor used to create storage backend for ephemeral data submission accounts,
|
|
119
|
+
* i.e. accounts that are used to submit large amount of data to an instruction that would otherwise be bigger
|
|
120
|
+
* than the transaction size limit - used for submitting bitcoin transaction proofs for PrTLC swaps
|
|
121
|
+
*
|
|
122
|
+
* @category Chain Interface
|
|
123
|
+
*/
|
|
124
|
+
function initializeSolana(options, bitcoinRpc, network, storageCtor) {
|
|
125
|
+
return _initializeSolana("v1", options, bitcoinRpc, network, storageCtor);
|
|
126
|
+
}
|
|
127
|
+
exports.initializeSolana = initializeSolana;
|
|
128
|
+
/**
|
|
129
|
+
* Initialize Solana chain integration using the new v2 version as the default version of the contracts
|
|
130
|
+
*
|
|
131
|
+
* @param options Options for initializing the Solana chain
|
|
132
|
+
* @param bitcoinRpc Bitcoin RPC to use for bitcoin read access
|
|
133
|
+
* @param network Bitcoin network to use - determines Solana program addresses to use by default
|
|
134
|
+
* @param storageCtor Storage constructor used to create storage backend for ephemeral data submission accounts,
|
|
135
|
+
* i.e. accounts that are used to submit large amount of data to an instruction that would otherwise be bigger
|
|
136
|
+
* than the transaction size limit - used for submitting bitcoin transaction proofs for PrTLC swaps
|
|
137
|
+
*
|
|
138
|
+
* @category Chain Interface
|
|
139
|
+
*/
|
|
140
|
+
function initializeSolanaV2(options, bitcoinRpc, network, storageCtor) {
|
|
141
|
+
return _initializeSolana("v2", options, bitcoinRpc, network, storageCtor);
|
|
142
|
+
}
|
|
143
|
+
exports.initializeSolanaV2 = initializeSolanaV2;
|
|
144
|
+
/**
|
|
145
|
+
* Solana chain initializer instance, used in the SwapperFactory constructor in the SDK library
|
|
146
|
+
*
|
|
147
|
+
* Uses the legacy v1 version of the contract as the default exported version, this doesn't support the new
|
|
148
|
+
* v2 lightning network flow, use the {@link SolanaInitializerV2} to initialize the SDK with the v2
|
|
149
|
+
* contracts as the default, which do have an explicit support for new lightning network swap flow
|
|
150
|
+
*
|
|
151
|
+
* @category Chain Interface
|
|
152
|
+
*/
|
|
153
|
+
exports.SolanaInitializer = {
|
|
154
|
+
chainId,
|
|
155
|
+
chainType: null,
|
|
156
|
+
initializer: initializeSolana,
|
|
157
|
+
tokens: SolanaAssets,
|
|
158
|
+
options: null
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Solana chain initializer instance, used in the SwapperFactory constructor in the SDK library
|
|
162
|
+
*
|
|
163
|
+
* Uses the new v2 version of the contracts as default exported version, supported the new lightning network
|
|
164
|
+
* swap flow.
|
|
165
|
+
*
|
|
166
|
+
* @category Chain Interface
|
|
167
|
+
*/
|
|
168
|
+
exports.SolanaInitializerV2 = {
|
|
169
|
+
chainId,
|
|
170
|
+
chainType: null,
|
|
171
|
+
initializer: initializeSolanaV2,
|
|
172
|
+
tokens: SolanaAssets,
|
|
173
|
+
options: null
|
|
174
|
+
};
|