@atomiqlabs/chain-evm 1.1.7 → 1.1.9
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/chains/alpen/AlpenChainType.d.ts +14 -0
- package/dist/chains/alpen/AlpenChainType.js +2 -0
- package/dist/chains/alpen/AlpenInitializer.d.ts +30 -0
- package/dist/chains/alpen/AlpenInitializer.js +128 -0
- package/dist/chains/botanix/BotanixInitializer.js +1 -1
- package/dist/chains/citrea/CitreaInitializer.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
- package/src/chains/alpen/AlpenChainType.ts +30 -0
- package/src/chains/alpen/AlpenInitializer.ts +178 -0
- package/src/chains/botanix/BotanixInitializer.ts +1 -1
- package/src/chains/citrea/CitreaInitializer.ts +1 -1
- package/src/index.ts +3 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChainType } from "@atomiqlabs/base";
|
|
2
|
+
import { EVMPreFetchVerification } from "../../evm/swaps/modules/EVMSwapInit";
|
|
3
|
+
import { EVMTx } from "../../evm/chain/modules/EVMTransactions";
|
|
4
|
+
import { EVMSigner } from "../../evm/wallet/EVMSigner";
|
|
5
|
+
import { EVMSwapData } from "../../evm/swaps/EVMSwapData";
|
|
6
|
+
import { EVMChainInterface } from "../../evm/chain/EVMChainInterface";
|
|
7
|
+
import { EVMChainEventsBrowser } from "../../evm/events/EVMChainEventsBrowser";
|
|
8
|
+
import { EVMSpvVaultData } from "../../evm/spv_swap/EVMSpvVaultData";
|
|
9
|
+
import { EVMSpvWithdrawalData } from "../../evm/spv_swap/EVMSpvWithdrawalData";
|
|
10
|
+
import { EVMSwapContract } from "../../evm/swaps/EVMSwapContract";
|
|
11
|
+
import { EVMBtcRelay } from "../../evm/btcrelay/EVMBtcRelay";
|
|
12
|
+
import { EVMSpvVaultContract } from "../../evm/spv_swap/EVMSpvVaultContract";
|
|
13
|
+
import { Signer } from "ethers";
|
|
14
|
+
export type AlpenChainType = ChainType<"ALPEN", never, EVMPreFetchVerification, EVMTx, EVMSigner, Signer, EVMSwapData, EVMSwapContract<"ALPEN">, EVMChainInterface<"ALPEN">, EVMChainEventsBrowser, EVMBtcRelay<any>, EVMSpvVaultData, EVMSpvWithdrawalData, EVMSpvVaultContract<"ALPEN">>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseTokenType, BitcoinNetwork, BitcoinRpc, ChainData, ChainInitializer, ChainSwapType } from "@atomiqlabs/base";
|
|
2
|
+
import { JsonRpcApiProvider } from "ethers";
|
|
3
|
+
import { EVMConfiguration, EVMRetryPolicy } from "../../evm/chain/EVMChainInterface";
|
|
4
|
+
import { EVMFees } from "../../evm/chain/modules/EVMFees";
|
|
5
|
+
import { AlpenChainType } from "./AlpenChainType";
|
|
6
|
+
export type AlpenAssetsType = BaseTokenType<"ABTC">;
|
|
7
|
+
export declare const AlpenAssets: AlpenAssetsType;
|
|
8
|
+
export type AlpenOptions = {
|
|
9
|
+
rpcUrl: string | JsonRpcApiProvider;
|
|
10
|
+
retryPolicy?: EVMRetryPolicy;
|
|
11
|
+
chainType?: "MAINNET" | "TESTNET";
|
|
12
|
+
swapContract?: string;
|
|
13
|
+
btcRelayContract?: string;
|
|
14
|
+
btcRelayDeploymentHeight?: number;
|
|
15
|
+
spvVaultContract?: string;
|
|
16
|
+
spvVaultDeploymentHeight?: number;
|
|
17
|
+
handlerContracts?: {
|
|
18
|
+
refund?: {
|
|
19
|
+
timelock?: string;
|
|
20
|
+
};
|
|
21
|
+
claim?: {
|
|
22
|
+
[type in ChainSwapType]?: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
fees?: EVMFees;
|
|
26
|
+
evmConfig?: Omit<EVMConfiguration, "safeBlockTag" | "finalizedBlockTag">;
|
|
27
|
+
};
|
|
28
|
+
export declare function initializeAlpen(options: AlpenOptions, bitcoinRpc: BitcoinRpc<any>, network: BitcoinNetwork): ChainData<AlpenChainType>;
|
|
29
|
+
export type AlpenInitializerType = ChainInitializer<AlpenOptions, AlpenChainType, AlpenAssetsType>;
|
|
30
|
+
export declare const AlpenInitializer: AlpenInitializerType;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AlpenInitializer = exports.initializeAlpen = exports.AlpenAssets = void 0;
|
|
4
|
+
const base_1 = require("@atomiqlabs/base");
|
|
5
|
+
const ethers_1 = require("ethers");
|
|
6
|
+
const EVMChainInterface_1 = require("../../evm/chain/EVMChainInterface");
|
|
7
|
+
const EVMFees_1 = require("../../evm/chain/modules/EVMFees");
|
|
8
|
+
const EVMBtcRelay_1 = require("../../evm/btcrelay/EVMBtcRelay");
|
|
9
|
+
const EVMSwapContract_1 = require("../../evm/swaps/EVMSwapContract");
|
|
10
|
+
const EVMSpvVaultContract_1 = require("../../evm/spv_swap/EVMSpvVaultContract");
|
|
11
|
+
const EVMChainEventsBrowser_1 = require("../../evm/events/EVMChainEventsBrowser");
|
|
12
|
+
const EVMSwapData_1 = require("../../evm/swaps/EVMSwapData");
|
|
13
|
+
const EVMSpvVaultData_1 = require("../../evm/spv_swap/EVMSpvVaultData");
|
|
14
|
+
const EVMSpvWithdrawalData_1 = require("../../evm/spv_swap/EVMSpvWithdrawalData");
|
|
15
|
+
const AlpenChainIds = {
|
|
16
|
+
MAINNET: -1,
|
|
17
|
+
TESTNET: 2892
|
|
18
|
+
};
|
|
19
|
+
const AlpenContractAddresses = {
|
|
20
|
+
MAINNET: {
|
|
21
|
+
executionContract: "",
|
|
22
|
+
swapContract: "",
|
|
23
|
+
btcRelayContract: "",
|
|
24
|
+
btcRelayDeploymentHeight: 0,
|
|
25
|
+
spvVaultContract: "",
|
|
26
|
+
spvVaultDeploymentHeight: 0,
|
|
27
|
+
handlerContracts: {
|
|
28
|
+
refund: {
|
|
29
|
+
timelock: ""
|
|
30
|
+
},
|
|
31
|
+
claim: {
|
|
32
|
+
[base_1.ChainSwapType.HTLC]: "",
|
|
33
|
+
[base_1.ChainSwapType.CHAIN_TXID]: "",
|
|
34
|
+
[base_1.ChainSwapType.CHAIN]: "",
|
|
35
|
+
[base_1.ChainSwapType.CHAIN_NONCED]: ""
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
TESTNET: {
|
|
40
|
+
executionContract: "0xc98Ef084d3911C8447DBbE4dDa18bC2c9bB0584e",
|
|
41
|
+
swapContract: "0x59A54378B6bA9C21ba66487C6A701D702baDEabE",
|
|
42
|
+
btcRelayContract: "0x5bb0C725939cB825d1322A99a3FeB570097628c3",
|
|
43
|
+
btcRelayDeploymentHeight: 1424534,
|
|
44
|
+
spvVaultContract: "0x8A44f1995a54fD976c904Cccf9EbaB49c3182eb3",
|
|
45
|
+
spvVaultDeploymentHeight: 1424536,
|
|
46
|
+
handlerContracts: {
|
|
47
|
+
refund: {
|
|
48
|
+
timelock: "0xe8be24CF21341c9567664009a8a82C9Dc1eE90D6"
|
|
49
|
+
},
|
|
50
|
+
claim: {
|
|
51
|
+
[base_1.ChainSwapType.HTLC]: "0x32EB4DbDdC31e19ba908fecc7cae03F0d04F01Fa",
|
|
52
|
+
[base_1.ChainSwapType.CHAIN_TXID]: "0xaB2D14745362B26a732dD8B7F95daAE3D2914bBF",
|
|
53
|
+
[base_1.ChainSwapType.CHAIN]: "0x2920EE496693A5027249a027A6FD3F643E743745",
|
|
54
|
+
[base_1.ChainSwapType.CHAIN_NONCED]: "0x3887B02217726bB36958Dd595e57293fB63D5082"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.AlpenAssets = {
|
|
60
|
+
ABTC: {
|
|
61
|
+
address: "0x0000000000000000000000000000000000000000",
|
|
62
|
+
decimals: 18,
|
|
63
|
+
displayDecimals: 8
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
function initializeAlpen(options, bitcoinRpc, network) {
|
|
67
|
+
if (options.chainType == null) {
|
|
68
|
+
switch (network) {
|
|
69
|
+
case base_1.BitcoinNetwork.MAINNET:
|
|
70
|
+
options.chainType = "MAINNET";
|
|
71
|
+
break;
|
|
72
|
+
case base_1.BitcoinNetwork.TESTNET:
|
|
73
|
+
options.chainType = "TESTNET";
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const defaultContractAddresses = AlpenContractAddresses[options.chainType];
|
|
78
|
+
const chainId = AlpenChainIds[options.chainType];
|
|
79
|
+
const provider = typeof (options.rpcUrl) === "string" ?
|
|
80
|
+
(options.rpcUrl.startsWith("ws")
|
|
81
|
+
? new ethers_1.WebSocketProvider(options.rpcUrl, { name: "Botanix", chainId })
|
|
82
|
+
: new ethers_1.JsonRpcProvider(options.rpcUrl, { name: "Botanix", chainId })) :
|
|
83
|
+
options.rpcUrl;
|
|
84
|
+
const Fees = options.fees ?? new EVMFees_1.EVMFees(provider, 2n * 1000000000n, 100000n);
|
|
85
|
+
const chainInterface = new EVMChainInterface_1.EVMChainInterface("ALPEN", chainId, provider, {
|
|
86
|
+
safeBlockTag: "latest",
|
|
87
|
+
finalizedBlockTag: "latest",
|
|
88
|
+
maxLogsBlockRange: options?.evmConfig?.maxLogsBlockRange ?? 950,
|
|
89
|
+
maxLogTopics: options?.evmConfig?.maxLogTopics ?? 64,
|
|
90
|
+
maxParallelLogRequests: options?.evmConfig?.maxParallelLogRequests ?? 5,
|
|
91
|
+
maxParallelCalls: options?.evmConfig?.maxParallelCalls ?? 5,
|
|
92
|
+
useAccessLists: options?.evmConfig?.useAccessLists,
|
|
93
|
+
defaultAccessListAddresses: options?.evmConfig?.defaultAccessListAddresses
|
|
94
|
+
}, options.retryPolicy, Fees);
|
|
95
|
+
const btcRelay = new EVMBtcRelay_1.EVMBtcRelay(chainInterface, bitcoinRpc, network, options.btcRelayContract ?? defaultContractAddresses.btcRelayContract, options.btcRelayDeploymentHeight ?? defaultContractAddresses.btcRelayDeploymentHeight);
|
|
96
|
+
const swapContract = new EVMSwapContract_1.EVMSwapContract(chainInterface, btcRelay, options.swapContract ?? defaultContractAddresses.swapContract, {
|
|
97
|
+
refund: {
|
|
98
|
+
...defaultContractAddresses.handlerContracts.refund,
|
|
99
|
+
...options?.handlerContracts?.refund
|
|
100
|
+
},
|
|
101
|
+
claim: {
|
|
102
|
+
...defaultContractAddresses.handlerContracts.claim,
|
|
103
|
+
...options?.handlerContracts?.claim
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
const spvVaultContract = new EVMSpvVaultContract_1.EVMSpvVaultContract(chainInterface, btcRelay, bitcoinRpc, options.spvVaultContract ?? defaultContractAddresses.spvVaultContract, options.spvVaultDeploymentHeight ?? defaultContractAddresses.spvVaultDeploymentHeight);
|
|
107
|
+
const chainEvents = new EVMChainEventsBrowser_1.EVMChainEventsBrowser(chainInterface, swapContract, spvVaultContract);
|
|
108
|
+
return {
|
|
109
|
+
chainId: "ALPEN",
|
|
110
|
+
btcRelay,
|
|
111
|
+
chainInterface,
|
|
112
|
+
swapContract,
|
|
113
|
+
chainEvents,
|
|
114
|
+
swapDataConstructor: EVMSwapData_1.EVMSwapData,
|
|
115
|
+
spvVaultContract,
|
|
116
|
+
spvVaultDataConstructor: EVMSpvVaultData_1.EVMSpvVaultData,
|
|
117
|
+
spvVaultWithdrawalDataConstructor: EVMSpvWithdrawalData_1.EVMSpvWithdrawalData
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
exports.initializeAlpen = initializeAlpen;
|
|
121
|
+
;
|
|
122
|
+
exports.AlpenInitializer = {
|
|
123
|
+
chainId: "ALPEN",
|
|
124
|
+
chainType: null,
|
|
125
|
+
initializer: initializeAlpen,
|
|
126
|
+
tokens: exports.AlpenAssets,
|
|
127
|
+
options: null
|
|
128
|
+
};
|
|
@@ -81,7 +81,7 @@ function initializeBotanix(options, bitcoinRpc, network) {
|
|
|
81
81
|
? new ethers_1.WebSocketProvider(options.rpcUrl, { name: "Botanix", chainId })
|
|
82
82
|
: new ethers_1.JsonRpcProvider(options.rpcUrl, { name: "Botanix", chainId })) :
|
|
83
83
|
options.rpcUrl;
|
|
84
|
-
const Fees = options.fees ?? new EVMFees_1.EVMFees(provider, 2n * 1000000000n,
|
|
84
|
+
const Fees = options.fees ?? new EVMFees_1.EVMFees(provider, 2n * 1000000000n, 100000n);
|
|
85
85
|
const chainInterface = new EVMChainInterface_1.EVMChainInterface("BOTANIX", chainId, provider, {
|
|
86
86
|
safeBlockTag: "finalized",
|
|
87
87
|
finalizedBlockTag: "finalized",
|
|
@@ -87,7 +87,7 @@ function initializeCitrea(options, bitcoinRpc, network) {
|
|
|
87
87
|
? new ethers_1.WebSocketProvider(options.rpcUrl, { name: "Citrea", chainId })
|
|
88
88
|
: new ethers_1.JsonRpcProvider(options.rpcUrl, { name: "Citrea", chainId })) :
|
|
89
89
|
options.rpcUrl;
|
|
90
|
-
const Fees = options.fees ?? new CitreaFees_1.CitreaFees(provider, 2n * 1000000000n,
|
|
90
|
+
const Fees = options.fees ?? new CitreaFees_1.CitreaFees(provider, 2n * 1000000000n, 100000n);
|
|
91
91
|
const chainInterface = new EVMChainInterface_1.EVMChainInterface("CITREA", chainId, provider, {
|
|
92
92
|
safeBlockTag: "latest",
|
|
93
93
|
finalizedBlockTag: "safe",
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export * from "./chains/citrea/CitreaChainType";
|
|
|
39
39
|
export * from "./chains/citrea/CitreaFees";
|
|
40
40
|
export * from "./chains/botanix/BotanixInitializer";
|
|
41
41
|
export * from "./chains/botanix/BotanixChainType";
|
|
42
|
+
export * from "./chains/alpen/AlpenInitializer";
|
|
43
|
+
export * from "./chains/alpen/AlpenChainType";
|
|
42
44
|
export * from "./evm/providers/JsonRpcProviderWithRetries";
|
|
43
45
|
export * from "./evm/providers/WebSocketProviderWithRetries";
|
|
44
46
|
export * from "./evm/providers/ReconnectingWebSocketProvider";
|
package/dist/index.js
CHANGED
|
@@ -55,6 +55,8 @@ __exportStar(require("./chains/citrea/CitreaChainType"), exports);
|
|
|
55
55
|
__exportStar(require("./chains/citrea/CitreaFees"), exports);
|
|
56
56
|
__exportStar(require("./chains/botanix/BotanixInitializer"), exports);
|
|
57
57
|
__exportStar(require("./chains/botanix/BotanixChainType"), exports);
|
|
58
|
+
__exportStar(require("./chains/alpen/AlpenInitializer"), exports);
|
|
59
|
+
__exportStar(require("./chains/alpen/AlpenChainType"), exports);
|
|
58
60
|
__exportStar(require("./evm/providers/JsonRpcProviderWithRetries"), exports);
|
|
59
61
|
__exportStar(require("./evm/providers/WebSocketProviderWithRetries"), exports);
|
|
60
62
|
__exportStar(require("./evm/providers/ReconnectingWebSocketProvider"), exports);
|
package/package.json
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {ChainType} from "@atomiqlabs/base";
|
|
2
|
+
import {EVMPreFetchVerification} from "../../evm/swaps/modules/EVMSwapInit";
|
|
3
|
+
import {EVMTx} from "../../evm/chain/modules/EVMTransactions";
|
|
4
|
+
import {EVMSigner} from "../../evm/wallet/EVMSigner";
|
|
5
|
+
import {EVMSwapData} from "../../evm/swaps/EVMSwapData";
|
|
6
|
+
import {EVMChainInterface} from "../../evm/chain/EVMChainInterface";
|
|
7
|
+
import {EVMChainEventsBrowser} from "../../evm/events/EVMChainEventsBrowser";
|
|
8
|
+
import { EVMSpvVaultData } from "../../evm/spv_swap/EVMSpvVaultData";
|
|
9
|
+
import { EVMSpvWithdrawalData } from "../../evm/spv_swap/EVMSpvWithdrawalData";
|
|
10
|
+
import {EVMSwapContract} from "../../evm/swaps/EVMSwapContract";
|
|
11
|
+
import {EVMBtcRelay} from "../../evm/btcrelay/EVMBtcRelay";
|
|
12
|
+
import {EVMSpvVaultContract} from "../../evm/spv_swap/EVMSpvVaultContract";
|
|
13
|
+
import {Signer} from "ethers";
|
|
14
|
+
|
|
15
|
+
export type AlpenChainType = ChainType<
|
|
16
|
+
"ALPEN",
|
|
17
|
+
never,
|
|
18
|
+
EVMPreFetchVerification,
|
|
19
|
+
EVMTx,
|
|
20
|
+
EVMSigner,
|
|
21
|
+
Signer,
|
|
22
|
+
EVMSwapData,
|
|
23
|
+
EVMSwapContract<"ALPEN">,
|
|
24
|
+
EVMChainInterface<"ALPEN">,
|
|
25
|
+
EVMChainEventsBrowser,
|
|
26
|
+
EVMBtcRelay<any>,
|
|
27
|
+
EVMSpvVaultData,
|
|
28
|
+
EVMSpvWithdrawalData,
|
|
29
|
+
EVMSpvVaultContract<"ALPEN">
|
|
30
|
+
>;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import {BaseTokenType, BitcoinNetwork, BitcoinRpc, ChainData, ChainInitializer, ChainSwapType} from "@atomiqlabs/base";
|
|
2
|
+
import {JsonRpcApiProvider, JsonRpcProvider, WebSocketProvider} from "ethers";
|
|
3
|
+
import {EVMChainInterface, EVMConfiguration, EVMRetryPolicy} from "../../evm/chain/EVMChainInterface";
|
|
4
|
+
import {EVMFees} from "../../evm/chain/modules/EVMFees";
|
|
5
|
+
import {EVMBtcRelay} from "../../evm/btcrelay/EVMBtcRelay";
|
|
6
|
+
import {EVMSwapContract} from "../../evm/swaps/EVMSwapContract";
|
|
7
|
+
import {EVMSpvVaultContract} from "../../evm/spv_swap/EVMSpvVaultContract";
|
|
8
|
+
import {EVMChainEventsBrowser} from "../../evm/events/EVMChainEventsBrowser";
|
|
9
|
+
import {EVMSwapData} from "../../evm/swaps/EVMSwapData";
|
|
10
|
+
import {EVMSpvVaultData} from "../../evm/spv_swap/EVMSpvVaultData";
|
|
11
|
+
import {EVMSpvWithdrawalData} from "../../evm/spv_swap/EVMSpvWithdrawalData";
|
|
12
|
+
import {AlpenChainType} from "./AlpenChainType";
|
|
13
|
+
|
|
14
|
+
const AlpenChainIds = {
|
|
15
|
+
MAINNET: -1,
|
|
16
|
+
TESTNET: 2892
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const AlpenContractAddresses = {
|
|
20
|
+
MAINNET: {
|
|
21
|
+
executionContract: "",
|
|
22
|
+
swapContract: "",
|
|
23
|
+
btcRelayContract: "",
|
|
24
|
+
btcRelayDeploymentHeight: 0,
|
|
25
|
+
spvVaultContract: "",
|
|
26
|
+
spvVaultDeploymentHeight: 0,
|
|
27
|
+
handlerContracts: {
|
|
28
|
+
refund: {
|
|
29
|
+
timelock: ""
|
|
30
|
+
},
|
|
31
|
+
claim: {
|
|
32
|
+
[ChainSwapType.HTLC]: "",
|
|
33
|
+
[ChainSwapType.CHAIN_TXID]: "",
|
|
34
|
+
[ChainSwapType.CHAIN]: "",
|
|
35
|
+
[ChainSwapType.CHAIN_NONCED]: ""
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
TESTNET: {
|
|
40
|
+
executionContract: "0xc98Ef084d3911C8447DBbE4dDa18bC2c9bB0584e",
|
|
41
|
+
swapContract: "0x59A54378B6bA9C21ba66487C6A701D702baDEabE",
|
|
42
|
+
btcRelayContract: "0x5bb0C725939cB825d1322A99a3FeB570097628c3",
|
|
43
|
+
btcRelayDeploymentHeight: 1424534,
|
|
44
|
+
spvVaultContract: "0x8A44f1995a54fD976c904Cccf9EbaB49c3182eb3",
|
|
45
|
+
spvVaultDeploymentHeight: 1424536,
|
|
46
|
+
handlerContracts: {
|
|
47
|
+
refund: {
|
|
48
|
+
timelock: "0xe8be24CF21341c9567664009a8a82C9Dc1eE90D6"
|
|
49
|
+
},
|
|
50
|
+
claim: {
|
|
51
|
+
[ChainSwapType.HTLC]: "0x32EB4DbDdC31e19ba908fecc7cae03F0d04F01Fa",
|
|
52
|
+
[ChainSwapType.CHAIN_TXID]: "0xaB2D14745362B26a732dD8B7F95daAE3D2914bBF",
|
|
53
|
+
[ChainSwapType.CHAIN]: "0x2920EE496693A5027249a027A6FD3F643E743745",
|
|
54
|
+
[ChainSwapType.CHAIN_NONCED]: "0x3887B02217726bB36958Dd595e57293fB63D5082"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type AlpenAssetsType = BaseTokenType<"ABTC">;
|
|
61
|
+
export const AlpenAssets: AlpenAssetsType = {
|
|
62
|
+
ABTC: {
|
|
63
|
+
address: "0x0000000000000000000000000000000000000000",
|
|
64
|
+
decimals: 18,
|
|
65
|
+
displayDecimals: 8
|
|
66
|
+
}
|
|
67
|
+
} as const;
|
|
68
|
+
|
|
69
|
+
export type AlpenOptions = {
|
|
70
|
+
rpcUrl: string | JsonRpcApiProvider,
|
|
71
|
+
retryPolicy?: EVMRetryPolicy,
|
|
72
|
+
chainType?: "MAINNET" | "TESTNET",
|
|
73
|
+
|
|
74
|
+
swapContract?: string,
|
|
75
|
+
btcRelayContract?: string,
|
|
76
|
+
btcRelayDeploymentHeight?: number,
|
|
77
|
+
spvVaultContract?: string,
|
|
78
|
+
spvVaultDeploymentHeight?: number,
|
|
79
|
+
handlerContracts?: {
|
|
80
|
+
refund?: {
|
|
81
|
+
timelock?: string
|
|
82
|
+
},
|
|
83
|
+
claim?: {
|
|
84
|
+
[type in ChainSwapType]?: string
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
fees?: EVMFees,
|
|
89
|
+
|
|
90
|
+
evmConfig?: Omit<EVMConfiguration, "safeBlockTag" | "finalizedBlockTag">
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function initializeAlpen(
|
|
94
|
+
options: AlpenOptions,
|
|
95
|
+
bitcoinRpc: BitcoinRpc<any>,
|
|
96
|
+
network: BitcoinNetwork
|
|
97
|
+
): ChainData<AlpenChainType> {
|
|
98
|
+
if(options.chainType==null) {
|
|
99
|
+
switch (network) {
|
|
100
|
+
case BitcoinNetwork.MAINNET:
|
|
101
|
+
options.chainType = "MAINNET";
|
|
102
|
+
break;
|
|
103
|
+
case BitcoinNetwork.TESTNET:
|
|
104
|
+
options.chainType = "TESTNET";
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const defaultContractAddresses = AlpenContractAddresses[options.chainType];
|
|
110
|
+
const chainId = AlpenChainIds[options.chainType];
|
|
111
|
+
|
|
112
|
+
const provider = typeof(options.rpcUrl)==="string" ?
|
|
113
|
+
(
|
|
114
|
+
options.rpcUrl.startsWith("ws")
|
|
115
|
+
? new WebSocketProvider(options.rpcUrl, {name: "Botanix", chainId})
|
|
116
|
+
: new JsonRpcProvider(options.rpcUrl, {name: "Botanix", chainId})
|
|
117
|
+
):
|
|
118
|
+
options.rpcUrl;
|
|
119
|
+
|
|
120
|
+
const Fees = options.fees ?? new EVMFees(provider, 2n * 1_000_000_000n, 100_000n);
|
|
121
|
+
|
|
122
|
+
const chainInterface = new EVMChainInterface("ALPEN", chainId, provider, {
|
|
123
|
+
safeBlockTag: "latest",
|
|
124
|
+
finalizedBlockTag: "latest",
|
|
125
|
+
maxLogsBlockRange: options?.evmConfig?.maxLogsBlockRange ?? 950,
|
|
126
|
+
maxLogTopics: options?.evmConfig?.maxLogTopics ?? 64,
|
|
127
|
+
maxParallelLogRequests: options?.evmConfig?.maxParallelLogRequests ?? 5,
|
|
128
|
+
maxParallelCalls: options?.evmConfig?.maxParallelCalls ?? 5,
|
|
129
|
+
useAccessLists: options?.evmConfig?.useAccessLists,
|
|
130
|
+
defaultAccessListAddresses: options?.evmConfig?.defaultAccessListAddresses
|
|
131
|
+
}, options.retryPolicy, Fees);
|
|
132
|
+
|
|
133
|
+
const btcRelay = new EVMBtcRelay(
|
|
134
|
+
chainInterface, bitcoinRpc, network, options.btcRelayContract ?? defaultContractAddresses.btcRelayContract,
|
|
135
|
+
options.btcRelayDeploymentHeight ?? defaultContractAddresses.btcRelayDeploymentHeight
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const swapContract = new EVMSwapContract(
|
|
139
|
+
chainInterface, btcRelay, options.swapContract ?? defaultContractAddresses.swapContract, {
|
|
140
|
+
refund: {
|
|
141
|
+
...defaultContractAddresses.handlerContracts.refund,
|
|
142
|
+
...options?.handlerContracts?.refund
|
|
143
|
+
},
|
|
144
|
+
claim: {
|
|
145
|
+
...defaultContractAddresses.handlerContracts.claim,
|
|
146
|
+
...options?.handlerContracts?.claim
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const spvVaultContract = new EVMSpvVaultContract(
|
|
152
|
+
chainInterface, btcRelay, bitcoinRpc, options.spvVaultContract ?? defaultContractAddresses.spvVaultContract,
|
|
153
|
+
options.spvVaultDeploymentHeight ?? defaultContractAddresses.spvVaultDeploymentHeight
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
const chainEvents = new EVMChainEventsBrowser(chainInterface, swapContract, spvVaultContract);
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
chainId: "ALPEN",
|
|
160
|
+
btcRelay,
|
|
161
|
+
chainInterface,
|
|
162
|
+
swapContract,
|
|
163
|
+
chainEvents,
|
|
164
|
+
swapDataConstructor: EVMSwapData,
|
|
165
|
+
spvVaultContract,
|
|
166
|
+
spvVaultDataConstructor: EVMSpvVaultData,
|
|
167
|
+
spvVaultWithdrawalDataConstructor: EVMSpvWithdrawalData
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export type AlpenInitializerType = ChainInitializer<AlpenOptions, AlpenChainType, AlpenAssetsType>;
|
|
172
|
+
export const AlpenInitializer: AlpenInitializerType = {
|
|
173
|
+
chainId: "ALPEN",
|
|
174
|
+
chainType: null as AlpenChainType,
|
|
175
|
+
initializer: initializeAlpen,
|
|
176
|
+
tokens: AlpenAssets,
|
|
177
|
+
options: null as AlpenOptions
|
|
178
|
+
} as const;
|
|
@@ -117,7 +117,7 @@ export function initializeBotanix(
|
|
|
117
117
|
):
|
|
118
118
|
options.rpcUrl;
|
|
119
119
|
|
|
120
|
-
const Fees = options.fees ?? new EVMFees(provider, 2n * 1_000_000_000n,
|
|
120
|
+
const Fees = options.fees ?? new EVMFees(provider, 2n * 1_000_000_000n, 100_000n);
|
|
121
121
|
|
|
122
122
|
const chainInterface = new EVMChainInterface("BOTANIX", chainId, provider, {
|
|
123
123
|
safeBlockTag: "finalized",
|
|
@@ -123,7 +123,7 @@ export function initializeCitrea(
|
|
|
123
123
|
):
|
|
124
124
|
options.rpcUrl;
|
|
125
125
|
|
|
126
|
-
const Fees = options.fees ?? new CitreaFees(provider, 2n * 1_000_000_000n,
|
|
126
|
+
const Fees = options.fees ?? new CitreaFees(provider, 2n * 1_000_000_000n, 100_000n);
|
|
127
127
|
|
|
128
128
|
const chainInterface = new EVMChainInterface("CITREA", chainId, provider, {
|
|
129
129
|
safeBlockTag: "latest",
|
package/src/index.ts
CHANGED
|
@@ -48,6 +48,9 @@ export * from "./chains/citrea/CitreaFees";
|
|
|
48
48
|
export * from "./chains/botanix/BotanixInitializer";
|
|
49
49
|
export * from "./chains/botanix/BotanixChainType";
|
|
50
50
|
|
|
51
|
+
export * from "./chains/alpen/AlpenInitializer";
|
|
52
|
+
export * from "./chains/alpen/AlpenChainType";
|
|
53
|
+
|
|
51
54
|
export * from "./evm/providers/JsonRpcProviderWithRetries";
|
|
52
55
|
export * from "./evm/providers/WebSocketProviderWithRetries";
|
|
53
56
|
export * from "./evm/providers/ReconnectingWebSocketProvider";
|