@swapkit/wallet-keystore 1.4.6 → 1.5.1

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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@scure/bip39": "1.3.0",
4
- "@swapkit/helpers": "2.2.1",
5
- "@swapkit/toolbox-cosmos": "1.7.3",
6
- "@swapkit/toolbox-evm": "1.7.11",
7
- "@swapkit/toolbox-radix": "1.2.27",
8
- "@swapkit/toolbox-solana": "1.3.12",
9
- "@swapkit/toolbox-substrate": "1.3.11",
10
- "@swapkit/toolbox-utxo": "1.2.11",
4
+ "@swapkit/helpers": "2.3.1",
5
+ "@swapkit/toolbox-cosmos": "1.8.1",
6
+ "@swapkit/toolbox-evm": "1.8.1",
7
+ "@swapkit/toolbox-radix": "1.2.29",
8
+ "@swapkit/toolbox-solana": "1.4.1",
9
+ "@swapkit/toolbox-substrate": "1.3.13",
10
+ "@swapkit/toolbox-utxo": "1.2.13",
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.4.6"
37
+ "version": "1.5.1"
38
38
  }
package/src/helpers.ts CHANGED
@@ -30,6 +30,7 @@ const blake256 = (initData: Buffer | string): string => {
30
30
  let data = initData;
31
31
 
32
32
  if (!(data instanceof Buffer)) {
33
+ // @ts-ignore
33
34
  data = Buffer.from(data, "hex");
34
35
  }
35
36
 
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
- type KeystoreSupportedChain = Exclude<Chain, Chain.Fiat | Chain.Radix>;
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 { HDNodeWallet, getProvider, getToolboxByChain } = await import("@swapkit/toolbox-evm");
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: KeystoreSupportedChain[],
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 promises = chains.map(async (chain) => {
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