@swapkit/wallet-keystore 1.4.5 → 1.5.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/chunk-7r0bsnk5.js +6 -0
- package/dist/chunk-7r0bsnk5.js.map +141 -0
- package/dist/chunk-nm00d52v.js +4 -0
- package/dist/chunk-nm00d52v.js.map +9 -0
- package/dist/index.js +8 -8
- package/dist/index.js.map +4 -4
- package/package.json +8 -8
- package/src/helpers.ts +1 -0
- package/src/keystore.ts +22 -4
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.
|
|
9
|
-
"@swapkit/toolbox-substrate": "1.3.
|
|
10
|
-
"@swapkit/toolbox-utxo": "1.2.
|
|
4
|
+
"@swapkit/helpers": "2.3.0",
|
|
5
|
+
"@swapkit/toolbox-cosmos": "1.8.0",
|
|
6
|
+
"@swapkit/toolbox-evm": "1.8.0",
|
|
7
|
+
"@swapkit/toolbox-radix": "1.2.28",
|
|
8
|
+
"@swapkit/toolbox-solana": "1.4.0",
|
|
9
|
+
"@swapkit/toolbox-substrate": "1.3.12",
|
|
10
|
+
"@swapkit/toolbox-utxo": "1.2.12",
|
|
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.5.0"
|
|
38
38
|
}
|
package/src/helpers.ts
CHANGED
package/src/keystore.ts
CHANGED
|
@@ -2,13 +2,17 @@ import {
|
|
|
2
2
|
type AssetValue,
|
|
3
3
|
Chain,
|
|
4
4
|
type ConnectWalletParams,
|
|
5
|
+
CosmosChains,
|
|
5
6
|
type DerivationPathArray,
|
|
7
|
+
EVMChains,
|
|
6
8
|
NetworkDerivationPath,
|
|
9
|
+
UTXOChains,
|
|
7
10
|
WalletOption,
|
|
8
11
|
type WalletTxParams,
|
|
9
12
|
type Witness,
|
|
10
13
|
derivationPathToString,
|
|
11
14
|
ensureEVMApiKeys,
|
|
15
|
+
filterSupportedChains,
|
|
12
16
|
getRPCUrl,
|
|
13
17
|
setRequestClientConfig,
|
|
14
18
|
updatedLastIndex,
|
|
@@ -21,7 +25,14 @@ import type {
|
|
|
21
25
|
UTXOWalletTransferParams,
|
|
22
26
|
} from "@swapkit/toolbox-utxo";
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
const KEYSTORE_SUPPORTED_CHAINS = [
|
|
29
|
+
...EVMChains,
|
|
30
|
+
...UTXOChains,
|
|
31
|
+
...CosmosChains,
|
|
32
|
+
Chain.Polkadot,
|
|
33
|
+
Chain.Chainflip,
|
|
34
|
+
Chain.Solana,
|
|
35
|
+
] as const;
|
|
25
36
|
|
|
26
37
|
type KeystoreOptions = {
|
|
27
38
|
ethplorerApiKey?: string;
|
|
@@ -57,7 +68,8 @@ const getWalletMethodsForChain = async ({
|
|
|
57
68
|
case Chain.Ethereum:
|
|
58
69
|
case Chain.Optimism:
|
|
59
70
|
case Chain.Polygon: {
|
|
60
|
-
const {
|
|
71
|
+
const { getProvider, getToolboxByChain } = await import("@swapkit/toolbox-evm");
|
|
72
|
+
const { HDNodeWallet } = await import("ethers");
|
|
61
73
|
|
|
62
74
|
const keys = ensureEVMApiKeys({ chain, covalentApiKey, ethplorerApiKey });
|
|
63
75
|
const provider = getProvider(chain, rpcUrl);
|
|
@@ -202,13 +214,19 @@ function connectKeystore({
|
|
|
202
214
|
config: { thorswapApiKey, covalentApiKey, ethplorerApiKey, blockchairApiKey, stagenet },
|
|
203
215
|
}: ConnectWalletParams) {
|
|
204
216
|
return async function connectKeystore(
|
|
205
|
-
chains:
|
|
217
|
+
chains: Chain[],
|
|
206
218
|
phrase: string,
|
|
207
219
|
derivationPathMapOrIndex?: { [chain in Chain]?: DerivationPathArray } | number,
|
|
208
220
|
) {
|
|
209
221
|
setRequestClientConfig({ apiKey: thorswapApiKey });
|
|
210
222
|
|
|
211
|
-
const
|
|
223
|
+
const supportedChains = filterSupportedChains(
|
|
224
|
+
chains,
|
|
225
|
+
KEYSTORE_SUPPORTED_CHAINS,
|
|
226
|
+
WalletOption.KEYSTORE,
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
const promises = supportedChains.map(async (chain) => {
|
|
212
230
|
const derivationPathIndex =
|
|
213
231
|
typeof derivationPathMapOrIndex === "number" ? derivationPathMapOrIndex : 0;
|
|
214
232
|
|