@keplr-wallet/background 0.13.13 → 0.13.15-rc.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.
Files changed (92) hide show
  1. package/build/chains/convert.d.ts +7 -0
  2. package/build/chains/convert.js +109 -0
  3. package/build/chains/convert.js.map +1 -0
  4. package/build/chains/handler.js +1 -1
  5. package/build/chains/handler.js.map +1 -1
  6. package/build/chains/index.d.ts +1 -0
  7. package/build/chains/index.js +1 -0
  8. package/build/chains/index.js.map +1 -1
  9. package/build/chains/messages.d.ts +1 -1
  10. package/build/chains/service.d.ts +3 -9
  11. package/build/chains/service.js +45 -79
  12. package/build/chains/service.js.map +1 -1
  13. package/build/chains-ui/service.d.ts +2 -2
  14. package/build/chains-ui/service.js +5 -6
  15. package/build/chains-ui/service.js.map +1 -1
  16. package/build/chains-update/service.js +2 -2
  17. package/build/chains-update/service.js.map +1 -1
  18. package/build/keyring/handler.js +21 -15
  19. package/build/keyring/handler.js.map +1 -1
  20. package/build/keyring/service.d.ts +0 -1
  21. package/build/keyring/service.js +103 -78
  22. package/build/keyring/service.js.map +1 -1
  23. package/build/keyring-bitcoin/service.js +2 -2
  24. package/build/keyring-bitcoin/service.js.map +1 -1
  25. package/build/keyring-cosmos/service.js +31 -18
  26. package/build/keyring-cosmos/service.js.map +1 -1
  27. package/build/keyring-ethereum/service.js +19 -19
  28. package/build/keyring-ethereum/service.js.map +1 -1
  29. package/build/keyring-ledger/service.js +8 -7
  30. package/build/keyring-ledger/service.js.map +1 -1
  31. package/build/keyring-starknet/service.js +7 -7
  32. package/build/keyring-starknet/service.js.map +1 -1
  33. package/build/manage-view-asset-token/service.d.ts +1 -2
  34. package/build/manage-view-asset-token/service.js +2 -2
  35. package/build/manage-view-asset-token/service.js.map +1 -1
  36. package/build/permission/service.d.ts +1 -2
  37. package/build/permission/service.js +2 -2
  38. package/build/permission/service.js.map +1 -1
  39. package/build/recent-send-history/service.d.ts +4 -4
  40. package/build/recent-send-history/service.js +101 -73
  41. package/build/recent-send-history/service.js.map +1 -1
  42. package/build/secret-wasm/service.d.ts +3 -3
  43. package/build/secret-wasm/service.js +29 -29
  44. package/build/secret-wasm/service.js.map +1 -1
  45. package/build/token-cw20/service.d.ts +6 -6
  46. package/build/token-cw20/service.js +28 -21
  47. package/build/token-cw20/service.js.map +1 -1
  48. package/build/token-erc20/service.d.ts +2 -3
  49. package/build/token-erc20/service.js +10 -15
  50. package/build/token-erc20/service.js.map +1 -1
  51. package/build/token-scan/service.js +27 -23
  52. package/build/token-scan/service.js.map +1 -1
  53. package/build/tx/service.d.ts +1 -0
  54. package/build/tx/service.js +41 -10
  55. package/build/tx/service.js.map +1 -1
  56. package/build/tx-ethereum/service.js +5 -9
  57. package/build/tx-ethereum/service.js.map +1 -1
  58. package/build/tx-executor/service.js +2 -7
  59. package/build/tx-executor/service.js.map +1 -1
  60. package/build/tx-executor/types.d.ts +7 -1
  61. package/build/tx-executor/types.js.map +1 -1
  62. package/build/tx-executor/utils/evm.d.ts +2 -2
  63. package/build/tx-executor/utils/evm.js +75 -26
  64. package/build/tx-executor/utils/evm.js.map +1 -1
  65. package/package.json +13 -13
  66. package/src/chains/convert.ts +126 -0
  67. package/src/chains/handler.ts +1 -1
  68. package/src/chains/index.ts +1 -0
  69. package/src/chains/messages.ts +1 -1
  70. package/src/chains/service.ts +64 -97
  71. package/src/chains-ui/service.ts +8 -7
  72. package/src/chains-update/service.ts +2 -2
  73. package/src/keyring/handler.ts +34 -19
  74. package/src/keyring/service.ts +137 -96
  75. package/src/keyring-bitcoin/service.ts +2 -2
  76. package/src/keyring-cosmos/service.ts +46 -18
  77. package/src/keyring-ethereum/service.ts +24 -17
  78. package/src/keyring-ledger/service.ts +10 -10
  79. package/src/keyring-starknet/service.ts +7 -7
  80. package/src/manage-view-asset-token/service.ts +2 -3
  81. package/src/permission/service.ts +3 -7
  82. package/src/recent-send-history/service.ts +141 -95
  83. package/src/secret-wasm/service.ts +39 -45
  84. package/src/token-cw20/service.ts +36 -30
  85. package/src/token-erc20/service.ts +15 -18
  86. package/src/token-scan/service.ts +34 -21
  87. package/src/tx/service.ts +60 -12
  88. package/src/tx-ethereum/service.ts +8 -8
  89. package/src/tx-executor/service.ts +4 -6
  90. package/src/tx-executor/types.ts +9 -1
  91. package/src/tx-executor/utils/evm.ts +92 -32
  92. package/tsconfig.check.json +2 -0
@@ -12,6 +12,7 @@ import {
12
12
  EthereumSignResponse,
13
13
  EthSignType,
14
14
  JsonRpcResponse,
15
+ isEthSignChain,
15
16
  } from "@keplr-wallet/types";
16
17
  import { Bech32Address } from "@keplr-wallet/cosmos";
17
18
  import { Buffer } from "buffer/";
@@ -84,19 +85,30 @@ export class KeyRingEthereumService {
84
85
  message: Uint8Array,
85
86
  signType: EthSignType
86
87
  ): Promise<EthereumSignResponse> {
87
- const chainInfo = this.chainsService.getChainInfoOrThrow(chainId);
88
- if (chainInfo.hideInUI) {
88
+ const modularChainInfo =
89
+ this.chainsService.getModularChainInfoOrThrow(chainId);
90
+ if (modularChainInfo.hideInUI) {
89
91
  throw new Error("Can't sign for hidden chain");
90
92
  }
91
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
92
- const evmInfo = ChainsService.getEVMInfo(chainInfo);
93
- const forceEVMLedger = chainInfo.features?.includes(
94
- "force-enable-evm-ledger"
95
- );
96
-
97
- if (!isEthermintLike && !evmInfo) {
93
+ if (!isEthSignChain(modularChainInfo)) {
98
94
  throw new Error("Not ethermint like and EVM chain");
99
95
  }
96
+ const forceEVMLedger = (() => {
97
+ if (
98
+ modularChainInfo.type === "cosmos" ||
99
+ modularChainInfo.type === "ethermint"
100
+ ) {
101
+ return modularChainInfo.cosmos.features?.includes(
102
+ "force-enable-evm-ledger"
103
+ );
104
+ }
105
+ if (modularChainInfo.type === "evm") {
106
+ return modularChainInfo.evm.features?.includes(
107
+ "force-enable-evm-ledger"
108
+ );
109
+ }
110
+ return false;
111
+ })();
100
112
 
101
113
  const keyInfo = this.keyRingService.getKeyInfo(vaultId);
102
114
  if (!keyInfo) {
@@ -341,14 +353,9 @@ export class KeyRingEthereumService {
341
353
  message: Uint8Array,
342
354
  signType: EthSignType
343
355
  ): Promise<EthereumSignResponse> {
344
- const chainInfo = this.chainsService.getChainInfoOrThrow(chainId);
345
- // if (chainInfo.hideInUI) {
346
- // throw new Error("Can't sign for hidden chain");
347
- // }
348
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
349
- const evmInfo = ChainsService.getEVMInfo(chainInfo);
350
-
351
- if (!isEthermintLike && !evmInfo) {
356
+ const modularChainInfo =
357
+ this.chainsService.getModularChainInfoOrThrow(chainId);
358
+ if (!isEthSignChain(modularChainInfo)) {
352
359
  throw new Error("Not ethermint like and EVM chain");
353
360
  }
354
361
 
@@ -2,8 +2,7 @@ import { PlainObject, Vault } from "../vault";
2
2
  import { Buffer } from "buffer/";
3
3
  import { PubKeySecp256k1, PubKeyStarknet } from "@keplr-wallet/crypto";
4
4
  import { KeplrError } from "@keplr-wallet/router";
5
- import { ModularChainInfo } from "@keplr-wallet/types";
6
- import { KeyRingService } from "../keyring";
5
+ import { ModularChainInfo, isEthSignChain } from "@keplr-wallet/types";
7
6
  import { Network as BitcoinNetwork } from "bitcoinjs-lib";
8
7
  import { PubKeyBitcoinCompatible } from "@keplr-wallet/crypto";
9
8
  import { Descriptor } from "../keyring-bitcoin";
@@ -46,21 +45,22 @@ export class KeyRingLedgerService {
46
45
  _coinType: number,
47
46
  modularChainInfo: ModularChainInfo
48
47
  ): PubKeySecp256k1 {
49
- if ("starknet" in modularChainInfo) {
48
+ if (modularChainInfo.type === "starknet") {
50
49
  throw new Error(
51
50
  "'getPubKeyStarknet' should be called for Starknet chain"
52
51
  );
53
52
  }
54
- if (!("cosmos" in modularChainInfo)) {
55
- // TODO: 나중에 starknet을 어떻게 지원할지 생각해본다.
53
+ if (
54
+ modularChainInfo.type !== "cosmos" &&
55
+ modularChainInfo.type !== "ethermint" &&
56
+ modularChainInfo.type !== "evm"
57
+ ) {
56
58
  throw new Error("Chain is not a cosmos chain");
57
59
  }
58
60
 
59
61
  let app = "Cosmos";
60
62
 
61
- const isEthermintLike = KeyRingService.isEthermintLike(
62
- modularChainInfo.cosmos
63
- );
63
+ const isEthermintLike = isEthSignChain(modularChainInfo);
64
64
  if (isEthermintLike) {
65
65
  app = "Ethereum";
66
66
  if (!vault.insensitive[app]) {
@@ -100,7 +100,7 @@ export class KeyRingLedgerService {
100
100
  vault: Vault,
101
101
  modularChainInfo: ModularChainInfo
102
102
  ): PubKeyStarknet {
103
- if (!("starknet" in modularChainInfo)) {
103
+ if (modularChainInfo.type !== "starknet") {
104
104
  throw new Error("'modularChainInfo' should have Starknet chain info");
105
105
  }
106
106
 
@@ -127,7 +127,7 @@ export class KeyRingLedgerService {
127
127
  network: BitcoinNetwork,
128
128
  modularChainInfo: ModularChainInfo
129
129
  ): PubKeyBitcoinCompatible {
130
- if (!("bitcoin" in modularChainInfo)) {
130
+ if (modularChainInfo.type !== "bitcoin") {
131
131
  throw new Error("'modularChainInfo' should have Bitcoin chain info");
132
132
  }
133
133
 
@@ -85,7 +85,7 @@ export class KeyRingStarknetService {
85
85
  }
86
86
  const modularChainInfo =
87
87
  this.chainsService.getModularChainInfoOrThrow(chainId);
88
- if (!("starknet" in modularChainInfo)) {
88
+ if (modularChainInfo.type !== "starknet") {
89
89
  throw new Error("Chain is not a starknet chain");
90
90
  }
91
91
  return new RpcProvider({
@@ -164,7 +164,7 @@ export class KeyRingStarknetService {
164
164
  yHigh: Uint8Array;
165
165
  }> {
166
166
  const chainInfo = this.chainsService.getModularChainInfoOrThrow(chainId);
167
- if (!("starknet" in chainInfo)) {
167
+ if (chainInfo.type !== "starknet") {
168
168
  throw new Error("Chain is not a starknet chain");
169
169
  }
170
170
 
@@ -251,7 +251,7 @@ export class KeyRingStarknetService {
251
251
 
252
252
  const modularChainInfo =
253
253
  this.chainsService.getModularChainInfoOrThrow(currentChainId);
254
- if (!("starknet" in modularChainInfo)) {
254
+ if (modularChainInfo.type !== "starknet") {
255
255
  throw new Error("Chain is not a starknet chain");
256
256
  }
257
257
 
@@ -269,7 +269,7 @@ export class KeyRingStarknetService {
269
269
 
270
270
  const modularChainInfo =
271
271
  this.chainsService.getModularChainInfoOrThrow(currentChainId);
272
- if (!("starknet" in modularChainInfo)) {
272
+ if (modularChainInfo.type !== "starknet") {
273
273
  throw new Error("Chain is not a starknet chain");
274
274
  }
275
275
 
@@ -354,7 +354,7 @@ export class KeyRingStarknetService {
354
354
 
355
355
  const newCurrentChainInfo =
356
356
  this.chainsService.getModularChainInfo(newCurrentChainId);
357
- if (!newCurrentChainInfo || !("starknet" in newCurrentChainInfo)) {
357
+ if (!newCurrentChainInfo || newCurrentChainInfo.type !== "starknet") {
358
358
  return false;
359
359
  }
360
360
 
@@ -437,7 +437,7 @@ export class KeyRingStarknetService {
437
437
  const currentChainId = this.forceGetCurrentChainId(origin, chainId);
438
438
  const modularChainInfo =
439
439
  this.chainsService.getModularChainInfoOrThrow(currentChainId);
440
- if (!("starknet" in modularChainInfo)) {
440
+ if (modularChainInfo.type !== "starknet") {
441
441
  throw new Error("Chain is not a starknet chain");
442
442
  }
443
443
 
@@ -488,7 +488,7 @@ export class KeyRingStarknetService {
488
488
  const currentChainId = this.forceGetCurrentChainId(origin, chainId);
489
489
  const modularChainInfo =
490
490
  this.chainsService.getModularChainInfoOrThrow(currentChainId);
491
- if (!("starknet" in modularChainInfo)) {
491
+ if (modularChainInfo.type !== "starknet") {
492
492
  throw new Error("Chain is not a starknet chain");
493
493
  }
494
494
 
@@ -13,7 +13,6 @@ import { computedFn } from "mobx-utils";
13
13
  import { ChainIdHelper } from "@keplr-wallet/cosmos";
14
14
  import { ChainsUIService } from "../chains-ui";
15
15
  import { ChainsService } from "../chains";
16
- import { ChainInfo } from "@keplr-wallet/types";
17
16
  import { VaultService } from "../vault";
18
17
 
19
18
  const DISABLED_VIEW_ASSET_TOKEN_MAP_KEY = "disabledViewAssetTokenMap";
@@ -99,10 +98,10 @@ export class ManageViewAssetTokenService {
99
98
  });
100
99
  };
101
100
 
102
- protected readonly onChainRemoved = (chainInfo: ChainInfo) => {
101
+ protected readonly onChainRemoved = (chainId: string) => {
103
102
  //이상하긴 하지만 ChainsUIService과 비슷하게 처리 하도록 구현
104
103
  //해서 다른 vault에서 체인을 삭제하면 전체 vault에서 삭제됨
105
- const chainIdentifier = ChainIdHelper.parse(chainInfo.chainId).identifier;
104
+ const chainIdentifier = ChainIdHelper.parse(chainId).identifier;
106
105
  const vaultIds = this.disabledViewAssetTokenMap.keys();
107
106
  runInAction(() => {
108
107
  for (const vaultId of vaultIds) {
@@ -11,11 +11,7 @@ import {
11
11
  } from "./types";
12
12
  import { KVStore } from "@keplr-wallet/common";
13
13
  import { ChainsService } from "../chains";
14
- import {
15
- ChainInfo,
16
- GENESIS_HASH_TO_NETWORK,
17
- GenesisHash,
18
- } from "@keplr-wallet/types";
14
+ import { GENESIS_HASH_TO_NETWORK, GenesisHash } from "@keplr-wallet/types";
19
15
  import { action, autorun, makeObservable, observable, runInAction } from "mobx";
20
16
  import { migrate } from "./migrate";
21
17
  import { computedFn } from "mobx-utils";
@@ -150,8 +146,8 @@ export class PermissionService {
150
146
  });
151
147
  }
152
148
 
153
- protected readonly onChainRemoved = (chainInfo: ChainInfo) => {
154
- this.removeAllPermissions(chainInfo.chainId);
149
+ protected readonly onChainRemoved = (chainId: string) => {
150
+ this.removeAllPermissions(chainId);
155
151
  };
156
152
 
157
153
  getAllPermissionDataPerOrigin(): AllPermissionDataPerOrigin {