@atomiqlabs/sdk 4.0.0-beta.1 → 4.0.0-beta.3
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/SwapperFactory.js +32 -19
- package/package.json +3 -3
- package/src/SwapperFactory.ts +37 -23
package/dist/SwapperFactory.js
CHANGED
|
@@ -5,6 +5,35 @@ const base_1 = require("@atomiqlabs/base");
|
|
|
5
5
|
const sdk_lib_1 = require("@atomiqlabs/sdk-lib");
|
|
6
6
|
const SmartChainAssets_1 = require("./SmartChainAssets");
|
|
7
7
|
const LocalStorageManager_1 = require("./storage/LocalStorageManager");
|
|
8
|
+
const registries = {
|
|
9
|
+
[base_1.BitcoinNetwork.MAINNET]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-mainnet.json?ref=main",
|
|
10
|
+
[base_1.BitcoinNetwork.TESTNET]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry.json?ref=main",
|
|
11
|
+
[base_1.BitcoinNetwork.TESTNET4]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-testnet4.json?ref=main"
|
|
12
|
+
};
|
|
13
|
+
const trustedIntermediaries = {
|
|
14
|
+
[base_1.BitcoinNetwork.MAINNET]: "https://node3.gethopa.com:34100",
|
|
15
|
+
[base_1.BitcoinNetwork.TESTNET]: "https://node3.gethopa.com:24100"
|
|
16
|
+
};
|
|
17
|
+
const mempoolUrls = {
|
|
18
|
+
[base_1.BitcoinNetwork.MAINNET]: [
|
|
19
|
+
"https://mempool.space/api/",
|
|
20
|
+
"https://mempool.fra.mempool.space/api/",
|
|
21
|
+
"https://mempool.va1.mempool.space/api/",
|
|
22
|
+
"https://mempool.tk7.mempool.space/api/"
|
|
23
|
+
],
|
|
24
|
+
[base_1.BitcoinNetwork.TESTNET]: [
|
|
25
|
+
"https://mempool.space/testnet/api/",
|
|
26
|
+
"https://mempool.fra.mempool.space/testnet/api/",
|
|
27
|
+
"https://mempool.va1.mempool.space/testnet/api/",
|
|
28
|
+
"https://mempool.tk7.mempool.space/testnet/api/"
|
|
29
|
+
],
|
|
30
|
+
[base_1.BitcoinNetwork.TESTNET4]: [
|
|
31
|
+
"https://mempool.space/testnet4/api/",
|
|
32
|
+
"https://mempool.fra.mempool.space/testnet4/api/",
|
|
33
|
+
"https://mempool.va1.mempool.space/testnet4/api/",
|
|
34
|
+
"https://mempool.tk7.mempool.space/testnet4/api/"
|
|
35
|
+
]
|
|
36
|
+
};
|
|
8
37
|
class SwapperFactory {
|
|
9
38
|
constructor(initializers) {
|
|
10
39
|
this.initializers = initializers;
|
|
@@ -36,25 +65,9 @@ class SwapperFactory {
|
|
|
36
65
|
newSwapper(options) {
|
|
37
66
|
options.bitcoinNetwork ?? (options.bitcoinNetwork = base_1.BitcoinNetwork.MAINNET);
|
|
38
67
|
options.storagePrefix ?? (options.storagePrefix = "atomiqsdk-" + options.bitcoinNetwork + "-");
|
|
39
|
-
options.defaultTrustedIntermediaryUrl ?? (options.defaultTrustedIntermediaryUrl = options.bitcoinNetwork
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
options.registryUrl ?? (options.registryUrl = options.bitcoinNetwork === base_1.BitcoinNetwork.MAINNET ?
|
|
43
|
-
"https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-mainnet.json?ref=main" :
|
|
44
|
-
"https://api.github.com/repos/adambor/SolLightning-registry/contents/registry.json?ref=main");
|
|
45
|
-
const mempoolApi = options.mempoolApi ?? new sdk_lib_1.MempoolApi(options.bitcoinNetwork === base_1.BitcoinNetwork.TESTNET ?
|
|
46
|
-
[
|
|
47
|
-
"https://mempool.space/testnet/api/",
|
|
48
|
-
"https://mempool.fra.mempool.space/testnet/api/",
|
|
49
|
-
"https://mempool.va1.mempool.space/testnet/api/",
|
|
50
|
-
"https://mempool.tk7.mempool.space/testnet/api/"
|
|
51
|
-
] :
|
|
52
|
-
[
|
|
53
|
-
"https://mempool.space/api/",
|
|
54
|
-
"https://mempool.fra.mempool.space/api/",
|
|
55
|
-
"https://mempool.va1.mempool.space/api/",
|
|
56
|
-
"https://mempool.tk7.mempool.space/api/"
|
|
57
|
-
]);
|
|
68
|
+
options.defaultTrustedIntermediaryUrl ?? (options.defaultTrustedIntermediaryUrl = trustedIntermediaries[options.bitcoinNetwork]);
|
|
69
|
+
options.registryUrl ?? (options.registryUrl = registries[options.bitcoinNetwork]);
|
|
70
|
+
const mempoolApi = options.mempoolApi ?? new sdk_lib_1.MempoolApi(mempoolUrls[options.bitcoinNetwork]);
|
|
58
71
|
const bitcoinRpc = new sdk_lib_1.MempoolBitcoinRpc(mempoolApi);
|
|
59
72
|
const pricingAssets = [];
|
|
60
73
|
Object.keys(SmartChainAssets_1.SmartChainAssets).forEach((ticker) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomiqlabs/sdk",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.3",
|
|
4
4
|
"description": "atomiq labs SDK for cross-chain swaps between smart chains and bitcoin",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types:": "./dist/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"author": "adambor",
|
|
22
22
|
"license": "ISC",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@atomiqlabs/base": "^9.0.0-beta.
|
|
25
|
-
"@atomiqlabs/sdk-lib": "^13.0.0-beta.
|
|
24
|
+
"@atomiqlabs/base": "^9.0.0-beta.2",
|
|
25
|
+
"@atomiqlabs/sdk-lib": "^13.0.0-beta.12"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "22.13.5",
|
package/src/SwapperFactory.ts
CHANGED
|
@@ -70,6 +70,38 @@ export type MultichainSwapperOptions<T extends readonly ChainInitializer<any, an
|
|
|
70
70
|
getPriceFn?: CustomPriceFunction
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
const registries = {
|
|
74
|
+
[BitcoinNetwork.MAINNET]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-mainnet.json?ref=main",
|
|
75
|
+
[BitcoinNetwork.TESTNET]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry.json?ref=main",
|
|
76
|
+
[BitcoinNetwork.TESTNET4]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-testnet4.json?ref=main"
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const trustedIntermediaries = {
|
|
80
|
+
[BitcoinNetwork.MAINNET]: "https://node3.gethopa.com:34100",
|
|
81
|
+
[BitcoinNetwork.TESTNET]: "https://node3.gethopa.com:24100"
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const mempoolUrls = {
|
|
85
|
+
[BitcoinNetwork.MAINNET]: [
|
|
86
|
+
"https://mempool.space/api/",
|
|
87
|
+
"https://mempool.fra.mempool.space/api/",
|
|
88
|
+
"https://mempool.va1.mempool.space/api/",
|
|
89
|
+
"https://mempool.tk7.mempool.space/api/"
|
|
90
|
+
],
|
|
91
|
+
[BitcoinNetwork.TESTNET]: [
|
|
92
|
+
"https://mempool.space/testnet/api/",
|
|
93
|
+
"https://mempool.fra.mempool.space/testnet/api/",
|
|
94
|
+
"https://mempool.va1.mempool.space/testnet/api/",
|
|
95
|
+
"https://mempool.tk7.mempool.space/testnet/api/"
|
|
96
|
+
],
|
|
97
|
+
[BitcoinNetwork.TESTNET4]: [
|
|
98
|
+
"https://mempool.space/testnet4/api/",
|
|
99
|
+
"https://mempool.fra.mempool.space/testnet4/api/",
|
|
100
|
+
"https://mempool.va1.mempool.space/testnet4/api/",
|
|
101
|
+
"https://mempool.tk7.mempool.space/testnet4/api/"
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
|
|
73
105
|
export class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]> {
|
|
74
106
|
|
|
75
107
|
Tokens: GetAllTokens<T> & {
|
|
@@ -112,29 +144,11 @@ export class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]
|
|
|
112
144
|
options.bitcoinNetwork ??= BitcoinNetwork.MAINNET as any;
|
|
113
145
|
options.storagePrefix ??= "atomiqsdk-"+options.bitcoinNetwork+"-";
|
|
114
146
|
|
|
115
|
-
options.defaultTrustedIntermediaryUrl ??= options.bitcoinNetwork
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
options.
|
|
120
|
-
"https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-mainnet.json?ref=main" :
|
|
121
|
-
"https://api.github.com/repos/adambor/SolLightning-registry/contents/registry.json?ref=main";
|
|
122
|
-
|
|
123
|
-
const mempoolApi = options.mempoolApi ?? new MempoolApi(
|
|
124
|
-
options.bitcoinNetwork===BitcoinNetwork.TESTNET ?
|
|
125
|
-
[
|
|
126
|
-
"https://mempool.space/testnet/api/",
|
|
127
|
-
"https://mempool.fra.mempool.space/testnet/api/",
|
|
128
|
-
"https://mempool.va1.mempool.space/testnet/api/",
|
|
129
|
-
"https://mempool.tk7.mempool.space/testnet/api/"
|
|
130
|
-
] :
|
|
131
|
-
[
|
|
132
|
-
"https://mempool.space/api/",
|
|
133
|
-
"https://mempool.fra.mempool.space/api/",
|
|
134
|
-
"https://mempool.va1.mempool.space/api/",
|
|
135
|
-
"https://mempool.tk7.mempool.space/api/"
|
|
136
|
-
]
|
|
137
|
-
);
|
|
147
|
+
options.defaultTrustedIntermediaryUrl ??= trustedIntermediaries[options.bitcoinNetwork];
|
|
148
|
+
|
|
149
|
+
options.registryUrl ??= registries[options.bitcoinNetwork];
|
|
150
|
+
|
|
151
|
+
const mempoolApi = options.mempoolApi ?? new MempoolApi(mempoolUrls[options.bitcoinNetwork]);
|
|
138
152
|
const bitcoinRpc = new MempoolBitcoinRpc(mempoolApi);
|
|
139
153
|
|
|
140
154
|
const pricingAssets: (RedundantSwapPriceAssets<ToMultichain<T>>[number] & {ticker: string, name: string})[] = [];
|