@swapkit/wallet-keystore 1.5.12 → 1.6.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/index.js +8 -11
- package/dist/index.js.map +4 -4
- package/package.json +8 -8
- package/src/keystore.ts +23 -6
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
3
|
"@scure/bip39": "1.3.0",
|
|
4
|
-
"@swapkit/helpers": "2.
|
|
5
|
-
"@swapkit/toolbox-cosmos": "1.
|
|
6
|
-
"@swapkit/toolbox-evm": "1.
|
|
7
|
-
"@swapkit/toolbox-radix": "1.2.
|
|
8
|
-
"@swapkit/toolbox-solana": "1.4.
|
|
9
|
-
"@swapkit/toolbox-substrate": "1.3.
|
|
10
|
-
"@swapkit/toolbox-utxo": "1.
|
|
4
|
+
"@swapkit/helpers": "2.5.0",
|
|
5
|
+
"@swapkit/toolbox-cosmos": "1.9.0",
|
|
6
|
+
"@swapkit/toolbox-evm": "1.9.0",
|
|
7
|
+
"@swapkit/toolbox-radix": "1.2.34",
|
|
8
|
+
"@swapkit/toolbox-solana": "1.4.6",
|
|
9
|
+
"@swapkit/toolbox-substrate": "1.3.19",
|
|
10
|
+
"@swapkit/toolbox-utxo": "1.3.0",
|
|
11
11
|
"blakejs": "1.2.1",
|
|
12
12
|
"micro-key-producer": "0.7.1"
|
|
13
13
|
},
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
},
|
|
35
35
|
"type": "module",
|
|
36
36
|
"types": "./src/index.ts",
|
|
37
|
-
"version": "1.
|
|
37
|
+
"version": "1.6.0"
|
|
38
38
|
}
|
package/src/keystore.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type AssetValue,
|
|
3
3
|
Chain,
|
|
4
|
+
type ChainApis,
|
|
4
5
|
type ConnectWalletParams,
|
|
5
6
|
CosmosChains,
|
|
6
7
|
type DerivationPathArray,
|
|
@@ -11,9 +12,9 @@ import {
|
|
|
11
12
|
type WalletTxParams,
|
|
12
13
|
type Witness,
|
|
13
14
|
derivationPathToString,
|
|
14
|
-
ensureEVMApiKeys,
|
|
15
15
|
filterSupportedChains,
|
|
16
16
|
getRPCUrl,
|
|
17
|
+
pickEvmApiKey,
|
|
17
18
|
setRequestClientConfig,
|
|
18
19
|
updatedLastIndex,
|
|
19
20
|
} from "@swapkit/helpers";
|
|
@@ -42,7 +43,7 @@ type KeystoreOptions = {
|
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
type Params = KeystoreOptions & {
|
|
45
|
-
|
|
46
|
+
apis?: ChainApis;
|
|
46
47
|
rpcUrl?: string;
|
|
47
48
|
chain: Chain;
|
|
48
49
|
phrase: string;
|
|
@@ -50,7 +51,7 @@ type Params = KeystoreOptions & {
|
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
const getWalletMethodsForChain = async ({
|
|
53
|
-
|
|
54
|
+
apis,
|
|
54
55
|
rpcUrl,
|
|
55
56
|
chain,
|
|
56
57
|
phrase,
|
|
@@ -71,16 +72,25 @@ const getWalletMethodsForChain = async ({
|
|
|
71
72
|
const { getProvider, getToolboxByChain } = await import("@swapkit/toolbox-evm");
|
|
72
73
|
const { HDNodeWallet } = await import("ethers");
|
|
73
74
|
|
|
74
|
-
const
|
|
75
|
+
const api = apis?.[chain];
|
|
76
|
+
|
|
77
|
+
const apiKey = pickEvmApiKey({
|
|
78
|
+
chain,
|
|
79
|
+
nonEthApiKey: covalentApiKey,
|
|
80
|
+
ethApiKey: ethplorerApiKey,
|
|
81
|
+
});
|
|
75
82
|
const provider = getProvider(chain, rpcUrl);
|
|
76
83
|
const wallet = HDNodeWallet.fromPhrase(phrase).connect(provider);
|
|
77
|
-
const params = {
|
|
84
|
+
const params = { api, apiKey, provider, signer: wallet };
|
|
78
85
|
|
|
79
86
|
return { address: wallet.address, walletMethods: getToolboxByChain(chain)(params) };
|
|
80
87
|
}
|
|
81
88
|
|
|
82
89
|
case Chain.BitcoinCash: {
|
|
83
90
|
const { BCHToolbox } = await import("@swapkit/toolbox-utxo");
|
|
91
|
+
|
|
92
|
+
const api = apis?.[chain];
|
|
93
|
+
|
|
84
94
|
const toolbox = BCHToolbox({ rpcUrl, apiKey: blockchairApiKey, apiClient: api });
|
|
85
95
|
const keys = await toolbox.createKeysForPath({ phrase, derivationPath });
|
|
86
96
|
const address = toolbox.getAddressFromKeys(keys);
|
|
@@ -112,6 +122,8 @@ const getWalletMethodsForChain = async ({
|
|
|
112
122
|
case Chain.Litecoin: {
|
|
113
123
|
const { getToolboxByChain } = await import("@swapkit/toolbox-utxo");
|
|
114
124
|
|
|
125
|
+
const api = apis?.[chain];
|
|
126
|
+
|
|
115
127
|
const toolbox = getToolboxByChain(chain)({
|
|
116
128
|
rpcUrl,
|
|
117
129
|
apiKey: blockchairApiKey,
|
|
@@ -138,6 +150,9 @@ const getWalletMethodsForChain = async ({
|
|
|
138
150
|
case Chain.Cosmos:
|
|
139
151
|
case Chain.Kujira: {
|
|
140
152
|
const { getToolboxByChain } = await import("@swapkit/toolbox-cosmos");
|
|
153
|
+
|
|
154
|
+
const api = apis?.[chain];
|
|
155
|
+
|
|
141
156
|
const toolbox = getToolboxByChain(chain)({ server: api, stagenet });
|
|
142
157
|
const address = await toolbox.getAddressFromMnemonic(phrase);
|
|
143
158
|
const signer = await toolbox.getSigner(phrase);
|
|
@@ -151,6 +166,8 @@ const getWalletMethodsForChain = async ({
|
|
|
151
166
|
case Chain.THORChain: {
|
|
152
167
|
const { getToolboxByChain } = await import("@swapkit/toolbox-cosmos");
|
|
153
168
|
|
|
169
|
+
const api = apis?.[chain];
|
|
170
|
+
|
|
154
171
|
const toolbox = getToolboxByChain(chain)({ server: api, stagenet });
|
|
155
172
|
const signer = await toolbox.getSigner(phrase);
|
|
156
173
|
const address = await toolbox.getAddressFromMnemonic(phrase);
|
|
@@ -251,7 +268,7 @@ function connectKeystore({
|
|
|
251
268
|
const { address, walletMethods } = await getWalletMethodsForChain({
|
|
252
269
|
derivationPath,
|
|
253
270
|
chain,
|
|
254
|
-
|
|
271
|
+
apis,
|
|
255
272
|
rpcUrl: rpcUrls[chain],
|
|
256
273
|
covalentApiKey,
|
|
257
274
|
ethplorerApiKey,
|