@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
@@ -13,7 +13,7 @@ import {
13
13
  PubKeySecp256k1,
14
14
  PubKeyStarknet,
15
15
  } from "@keplr-wallet/crypto";
16
- import { ChainsService } from "../chains";
16
+ import { ChainsService, convertModularChainInfoToChainInfo } from "../chains";
17
17
  import { action, autorun, makeObservable, observable, runInAction } from "mobx";
18
18
  import { KVStore } from "@keplr-wallet/common";
19
19
  import { Bech32Address, ChainIdHelper } from "@keplr-wallet/cosmos";
@@ -22,6 +22,7 @@ import {
22
22
  ChainInfo,
23
23
  ModularChainInfo,
24
24
  SignPsbtOptions,
25
+ isEthSignChain,
25
26
  } from "@keplr-wallet/types";
26
27
  import { Buffer } from "buffer/";
27
28
  import * as Legacy from "./legacy";
@@ -464,18 +465,18 @@ export class KeyRingService {
464
465
  hasEthereum = true;
465
466
  }
466
467
 
467
- for (const chainInfo of this.chainsService.getChainInfos()) {
468
- if (checkChainDisabled(chainInfo.chainId)) {
468
+ for (const mci of this.chainsService.getModularChainInfos()) {
469
+ if (checkChainDisabled(mci.chainId)) {
469
470
  continue;
470
471
  }
471
472
 
472
- if (KeyRingService.isEthermintLike(chainInfo) && !hasEthereum) {
473
+ if (isEthSignChain(mci) && !hasEthereum) {
473
474
  continue;
474
475
  }
475
476
 
476
477
  this.migrations.chainsUIService.enableChain(
477
478
  vaultId,
478
- chainInfo.chainId
479
+ mci.chainId
479
480
  );
480
481
  }
481
482
 
@@ -504,19 +505,16 @@ export class KeyRingService {
504
505
  password
505
506
  );
506
507
 
507
- for (const chainInfo of this.chainsService.getChainInfos()) {
508
- if (checkChainDisabled(chainInfo.chainId)) {
508
+ for (const mci of this.chainsService.getModularChainInfos()) {
509
+ if (checkChainDisabled(mci.chainId)) {
509
510
  continue;
510
511
  }
511
512
 
512
- if (KeyRingService.isEthermintLike(chainInfo)) {
513
+ if (isEthSignChain(mci)) {
513
514
  continue;
514
515
  }
515
516
 
516
- this.migrations.chainsUIService.enableChain(
517
- vaultId,
518
- chainInfo.chainId
519
- );
517
+ this.migrations.chainsUIService.enableChain(vaultId, mci.chainId);
520
518
  }
521
519
 
522
520
  if (
@@ -632,7 +630,10 @@ export class KeyRingService {
632
630
  const modularChainInfo =
633
631
  this.chainsService.getModularChainInfoOrThrow(chainId);
634
632
 
635
- if ("cosmos" in modularChainInfo) {
633
+ if (
634
+ modularChainInfo.type === "cosmos" ||
635
+ modularChainInfo.type === "ethermint"
636
+ ) {
636
637
  const chainInfo = modularChainInfo.cosmos;
637
638
  if (
638
639
  chainInfo.bip44.coinType !== coinType &&
@@ -643,14 +644,14 @@ export class KeyRingService {
643
644
  throw new Error("Coin type is not associated to chain");
644
645
  }
645
646
  }
646
- if ("starknet" in modularChainInfo) {
647
+ if (modularChainInfo.type === "starknet") {
647
648
  // TODO: starknet에서는 일단 코인타입을 9004로 고정해서 쓴다.
648
649
  // 일단은 임시조치인데 나중에 다른 방식으로 바뀔수도 있다.
649
650
  if (coinType !== 9004) {
650
651
  throw new Error("Coin type is not associated to chain");
651
652
  }
652
653
  }
653
- if ("bitcoin" in modularChainInfo) {
654
+ if (modularChainInfo.type === "bitcoin") {
654
655
  const chainInfo = modularChainInfo.bitcoin;
655
656
  if (chainInfo.bip44.coinType !== coinType) {
656
657
  throw new Error("Coin type is not associated to chain");
@@ -728,16 +729,21 @@ export class KeyRingService {
728
729
 
729
730
  // Finalize coin type if only one coin type exists.
730
731
  const coinTypes: Record<string, number | undefined> = {};
731
- const chainInfos = this.chainsService.getChainInfos();
732
- for (const chainInfo of chainInfos) {
732
+ for (const modularChainInfo of this.chainsService.getModularChainInfos()) {
733
733
  if (
734
- !chainInfo.alternativeBIP44s ||
735
- chainInfo.alternativeBIP44s.length === 0
734
+ modularChainInfo.type === "cosmos" ||
735
+ modularChainInfo.type === "ethermint"
736
736
  ) {
737
- const coinTypeTag = `keyRing-${
738
- ChainIdHelper.parse(chainInfo.chainId).identifier
739
- }-coinType`;
740
- coinTypes[coinTypeTag] = chainInfo.bip44.coinType;
737
+ const cosmosInfo = modularChainInfo.cosmos;
738
+ if (
739
+ !cosmosInfo.alternativeBIP44s ||
740
+ cosmosInfo.alternativeBIP44s.length === 0
741
+ ) {
742
+ const coinTypeTag = `keyRing-${
743
+ ChainIdHelper.parse(modularChainInfo.chainId).identifier
744
+ }-coinType`;
745
+ coinTypes[coinTypeTag] = cosmosInfo.bip44.coinType;
746
+ }
741
747
  }
742
748
  }
743
749
 
@@ -824,16 +830,21 @@ export class KeyRingService {
824
830
 
825
831
  // Finalize coin type if only one coin type exists.
826
832
  const coinTypes: Record<string, number | undefined> = {};
827
- const chainInfos = this.chainsService.getChainInfos();
828
- for (const chainInfo of chainInfos) {
833
+ for (const modularChainInfo of this.chainsService.getModularChainInfos()) {
829
834
  if (
830
- !chainInfo.alternativeBIP44s ||
831
- chainInfo.alternativeBIP44s.length === 0
835
+ modularChainInfo.type === "cosmos" ||
836
+ modularChainInfo.type === "ethermint"
832
837
  ) {
833
- const coinTypeTag = `keyRing-${
834
- ChainIdHelper.parse(chainInfo.chainId).identifier
835
- }-coinType`;
836
- coinTypes[coinTypeTag] = chainInfo.bip44.coinType;
838
+ const cosmosInfo = modularChainInfo.cosmos;
839
+ if (
840
+ !cosmosInfo.alternativeBIP44s ||
841
+ cosmosInfo.alternativeBIP44s.length === 0
842
+ ) {
843
+ const coinTypeTag = `keyRing-${
844
+ ChainIdHelper.parse(modularChainInfo.chainId).identifier
845
+ }-coinType`;
846
+ coinTypes[coinTypeTag] = cosmosInfo.bip44.coinType;
847
+ }
837
848
  }
838
849
  }
839
850
 
@@ -1168,11 +1179,14 @@ export class KeyRingService {
1168
1179
 
1169
1180
  const purpose =
1170
1181
  (() => {
1171
- if ("cosmos" in modularChainInfo) {
1182
+ if (
1183
+ modularChainInfo.type === "cosmos" ||
1184
+ modularChainInfo.type === "ethermint"
1185
+ ) {
1172
1186
  return modularChainInfo.cosmos.bip44.purpose;
1173
1187
  }
1174
1188
 
1175
- if ("bitcoin" in modularChainInfo) {
1189
+ if (modularChainInfo.type === "bitcoin") {
1176
1190
  return modularChainInfo.bitcoin.bip44.purpose;
1177
1191
  }
1178
1192
  })() ?? DEFAULT_BIP44_PURPOSE;
@@ -1186,17 +1200,24 @@ export class KeyRingService {
1186
1200
  return vault.insensitive[coinTypeTag] as number;
1187
1201
  }
1188
1202
 
1189
- if ("cosmos" in modularChainInfo) {
1203
+ if (
1204
+ modularChainInfo.type === "cosmos" ||
1205
+ modularChainInfo.type === "ethermint"
1206
+ ) {
1190
1207
  return modularChainInfo.cosmos.bip44.coinType;
1191
1208
  }
1192
1209
 
1193
1210
  // TODO: starknet에서는 일단 코인타입을 9004로 고정해서 쓴다.
1194
1211
  // 일단은 임시조치인데 나중에 다른 방식으로 바뀔수도 있다.
1195
- if ("starknet" in modularChainInfo) {
1212
+ if (modularChainInfo.type === "starknet") {
1196
1213
  return 9004;
1197
1214
  }
1198
1215
 
1199
- if ("bitcoin" in modularChainInfo) {
1216
+ if (modularChainInfo.type === "evm") {
1217
+ return 60;
1218
+ }
1219
+
1220
+ if (modularChainInfo.type === "bitcoin") {
1200
1221
  return modularChainInfo.bitcoin.bip44.coinType;
1201
1222
  }
1202
1223
 
@@ -1241,7 +1262,7 @@ export class KeyRingService {
1241
1262
 
1242
1263
  const purpose =
1243
1264
  (() => {
1244
- if ("bitcoin" in modularChainInfo) {
1265
+ if (modularChainInfo.type === "bitcoin") {
1245
1266
  return modularChainInfo.bitcoin.bip44.purpose;
1246
1267
  }
1247
1268
  })() ?? DEFAULT_BIP44_PURPOSE;
@@ -1255,7 +1276,7 @@ export class KeyRingService {
1255
1276
  return vault.insensitive[coinTypeTag] as number;
1256
1277
  }
1257
1278
 
1258
- if ("bitcoin" in modularChainInfo) {
1279
+ if (modularChainInfo.type === "bitcoin") {
1259
1280
  return modularChainInfo.bitcoin.bip44.coinType;
1260
1281
  }
1261
1282
 
@@ -1284,7 +1305,10 @@ export class KeyRingService {
1284
1305
  const modularChainInfo =
1285
1306
  this.chainsService.getModularChainInfoOrThrow(chainId);
1286
1307
 
1287
- if ("cosmos" in modularChainInfo) {
1308
+ if (
1309
+ modularChainInfo.type === "cosmos" ||
1310
+ modularChainInfo.type === "ethermint"
1311
+ ) {
1288
1312
  if (
1289
1313
  modularChainInfo.cosmos.bip44.coinType !== coinType &&
1290
1314
  !(modularChainInfo.cosmos.alternativeBIP44s ?? []).find(
@@ -1293,13 +1317,13 @@ export class KeyRingService {
1293
1317
  ) {
1294
1318
  throw new Error("Coin type is not associated to chain");
1295
1319
  }
1296
- } else if ("starknet" in modularChainInfo) {
1320
+ } else if (modularChainInfo.type === "starknet") {
1297
1321
  // TODO: starknet에서는 일단 코인타입을 9004로 고정해서 쓴다.
1298
1322
  // 일단은 임시조치인데 나중에 다른 방식으로 바뀔수도 있다.
1299
1323
  if (coinType !== 9004) {
1300
1324
  throw new Error("Coin type is not associated to chain");
1301
1325
  }
1302
- } else if ("bitcoin" in modularChainInfo) {
1326
+ } else if (modularChainInfo.type === "bitcoin") {
1303
1327
  if (modularChainInfo.bitcoin.bip44.coinType !== coinType) {
1304
1328
  throw new Error("Coin type is not associated to chain");
1305
1329
  }
@@ -1354,17 +1378,23 @@ export class KeyRingService {
1354
1378
 
1355
1379
  const purpose =
1356
1380
  (() => {
1357
- if ("cosmos" in modularChainInfo) {
1381
+ if (
1382
+ modularChainInfo.type === "cosmos" ||
1383
+ modularChainInfo.type === "ethermint"
1384
+ ) {
1358
1385
  return modularChainInfo.cosmos.bip44.purpose;
1359
1386
  }
1360
1387
 
1361
- if ("bitcoin" in modularChainInfo) {
1388
+ if (modularChainInfo.type === "bitcoin") {
1362
1389
  return modularChainInfo.bitcoin.bip44.purpose;
1363
1390
  }
1364
1391
  })() ?? DEFAULT_BIP44_PURPOSE;
1365
1392
 
1366
1393
  const coinType = (() => {
1367
- if ("cosmos" in modularChainInfo) {
1394
+ if (
1395
+ modularChainInfo.type === "cosmos" ||
1396
+ modularChainInfo.type === "ethermint"
1397
+ ) {
1368
1398
  const coinTypeTag = `keyRing-${
1369
1399
  ChainIdHelper.parse(chainId).identifier
1370
1400
  }-coinType`;
@@ -1374,11 +1404,13 @@ export class KeyRingService {
1374
1404
  }
1375
1405
 
1376
1406
  return modularChainInfo.cosmos.bip44.coinType;
1377
- } else if ("starknet" in modularChainInfo) {
1407
+ } else if (modularChainInfo.type === "starknet") {
1378
1408
  // TODO: starknet에서는 일단 코인타입을 9004로 고정해서 쓴다.
1379
1409
  // 일단은 임시조치인데 나중에 다른 방식으로 바뀔수도 있다.
1380
1410
  return 9004;
1381
- } else if ("bitcoin" in modularChainInfo) {
1411
+ } else if (modularChainInfo.type === "evm") {
1412
+ return 60;
1413
+ } else if (modularChainInfo.type === "bitcoin") {
1382
1414
  return modularChainInfo.bitcoin.bip44.coinType;
1383
1415
  } else {
1384
1416
  throw new Error("Can't determine default coin type");
@@ -1448,13 +1480,13 @@ export class KeyRingService {
1448
1480
 
1449
1481
  const purpose =
1450
1482
  (() => {
1451
- if ("bitcoin" in modularChainInfo) {
1483
+ if (modularChainInfo.type === "bitcoin") {
1452
1484
  return modularChainInfo.bitcoin.bip44.purpose;
1453
1485
  }
1454
1486
  })() ?? DEFAULT_BIP44_PURPOSE;
1455
1487
 
1456
1488
  const coinType = (() => {
1457
- if ("bitcoin" in modularChainInfo) {
1489
+ if (modularChainInfo.type === "bitcoin") {
1458
1490
  return modularChainInfo.bitcoin.bip44.coinType;
1459
1491
  }
1460
1492
 
@@ -1744,9 +1776,9 @@ export class KeyRingService {
1744
1776
  [identifier: string]: number;
1745
1777
  } = {};
1746
1778
 
1747
- for (const chainInfo of this.chainsService.getChainInfos()) {
1779
+ for (const modularChainInfo of this.chainsService.getModularChainInfos()) {
1748
1780
  const identifier = ChainIdHelper.parse(
1749
- chainInfo.chainId
1781
+ modularChainInfo.chainId
1750
1782
  ).identifier;
1751
1783
  const coinTypeTag = `keyRing-${identifier}-coinType`;
1752
1784
  if (keyInfo.insensitive[coinTypeTag] != null) {
@@ -1867,18 +1899,22 @@ export class KeyRingService {
1867
1899
  this.chainsUIService.enabledModularChainInfosForVault(keyInfo.id);
1868
1900
  // TODO: 다른 체인도 지원하기
1869
1901
  const chainInfos = modularChainInfos
1870
- .filter((c) => "cosmos" in c)
1871
- .map((c) => {
1872
- if (!("cosmos" in c)) {
1873
- throw new Error("Unsupported chain");
1874
- }
1875
- return c.cosmos;
1902
+ .filter(
1903
+ (c) =>
1904
+ c.type === "cosmos" ||
1905
+ c.type === "ethermint" ||
1906
+ c.type === "evm"
1907
+ )
1908
+ .flatMap((c) => {
1909
+ const ci = convertModularChainInfoToChainInfo(c);
1910
+ return ci ? [ci] : [];
1876
1911
  });
1877
1912
 
1878
1913
  let evmEnabled = false;
1879
- for (const chainInfo of chainInfos) {
1880
- if (KeyRingService.isEthermintLike(chainInfo)) {
1914
+ for (const c of modularChainInfos) {
1915
+ if (isEthSignChain(c)) {
1881
1916
  evmEnabled = true;
1917
+ break;
1882
1918
  }
1883
1919
  }
1884
1920
  if (!evmEnabled && !ignoreChainEnabled) {
@@ -1927,58 +1963,71 @@ export class KeyRingService {
1927
1963
  })();
1928
1964
 
1929
1965
  if (!isHex) {
1930
- let targetChainInfos: ChainInfo[] = (() => {
1966
+ const targetModularChainInfos: ModularChainInfo[] = (() => {
1931
1967
  const i = searchText.indexOf("1");
1932
1968
  if (i < 0) {
1933
1969
  return [];
1934
1970
  }
1935
1971
  const prefix = searchText.slice(0, i);
1936
- const result: ChainInfo[] = [];
1937
- for (const chainInfo of this.chainsService.getChainInfos()) {
1938
- if (chainInfo.bech32Config?.bech32PrefixAccAddr === prefix) {
1939
- result.push(chainInfo);
1972
+ const result: ModularChainInfo[] = [];
1973
+ for (const modularChainInfo of this.chainsService.getModularChainInfos()) {
1974
+ if (
1975
+ (modularChainInfo.type === "cosmos" ||
1976
+ modularChainInfo.type === "ethermint") &&
1977
+ modularChainInfo.cosmos.bech32Config?.bech32PrefixAccAddr ===
1978
+ prefix
1979
+ ) {
1980
+ result.push(modularChainInfo);
1940
1981
  }
1941
1982
  }
1942
1983
  return result;
1943
1984
  })();
1944
1985
 
1945
1986
  bech32AddressSearchKeyInfos = keyInfos.filter((keyInfo) => {
1987
+ let filteredModularChainInfos = targetModularChainInfos;
1946
1988
  if (!ignoreChainEnabled) {
1947
- targetChainInfos = targetChainInfos.filter((chainInfo) => {
1948
- return this.chainsUIService.isEnabled(
1949
- keyInfo.id,
1950
- chainInfo.chainId
1951
- );
1952
- });
1989
+ filteredModularChainInfos = filteredModularChainInfos.filter(
1990
+ (m) => {
1991
+ return this.chainsUIService.isEnabled(keyInfo.id, m.chainId);
1992
+ }
1993
+ );
1953
1994
  }
1954
1995
 
1955
1996
  const chainInfos = (() => {
1956
1997
  if (ignoreChainEnabled) {
1957
- return this.chainsService.getChainInfos();
1998
+ return this.chainsService
1999
+ .getModularChainInfos()
2000
+ .filter((c) => c.type === "cosmos" || c.type === "ethermint")
2001
+ .flatMap((c) => {
2002
+ const ci = convertModularChainInfoToChainInfo(c);
2003
+ return ci ? [ci] : [];
2004
+ });
2005
+ }
2006
+ if (filteredModularChainInfos.length > 0) {
2007
+ return filteredModularChainInfos.flatMap((c) => {
2008
+ const ci = convertModularChainInfoToChainInfo(c);
2009
+ return ci ? [ci] : [];
2010
+ });
1958
2011
  }
1959
- return targetChainInfos.length > 0
1960
- ? targetChainInfos
1961
- : (() => {
1962
- const modularChainInfos =
1963
- this.chainsUIService.enabledModularChainInfosForVault(
1964
- keyInfo.id
1965
- );
1966
- // TODO: 다른 체인도 지원하기
1967
- return modularChainInfos
1968
- .filter((c) => "cosmos" in c)
1969
- .map((c) => {
1970
- if (!("cosmos" in c)) {
1971
- throw new Error("Unsupported chain");
1972
- }
1973
- return c.cosmos;
1974
- });
1975
- })();
2012
+ const modularChainInfos =
2013
+ this.chainsUIService.enabledModularChainInfosForVault(keyInfo.id);
2014
+ // TODO: 다른 체인도 지원하기
2015
+ return modularChainInfos
2016
+ .filter((c) => c.type === "cosmos" || c.type === "ethermint")
2017
+ .flatMap((c) => {
2018
+ const ci = convertModularChainInfoToChainInfo(c);
2019
+ return ci ? [ci] : [];
2020
+ });
1976
2021
  })();
1977
2022
 
1978
2023
  for (const chainInfo of chainInfos) {
1979
2024
  for (const [key, value] of Object.entries(keyInfo.insensitive)) {
1980
2025
  try {
1981
- const isEVM = KeyRingService.isEthermintLike(chainInfo);
2026
+ const isEVM = isEthSignChain(
2027
+ this.chainsService.getModularChainInfoOrThrow(
2028
+ chainInfo.chainId
2029
+ )
2030
+ );
1982
2031
 
1983
2032
  const hexAddress =
1984
2033
  KeyRingService.getAddressHexStringFromKeyInfo(
@@ -2140,12 +2189,4 @@ export class KeyRingService {
2140
2189
  throw new Error("Invalid address index in hd path");
2141
2190
  }
2142
2191
  }
2143
-
2144
- static isEthermintLike(chainInfo: ChainInfo): boolean {
2145
- return (
2146
- chainInfo.bip44.coinType === 60 ||
2147
- !!chainInfo.features?.includes("eth-address-gen") ||
2148
- !!chainInfo.features?.includes("eth-key-sign")
2149
- );
2150
- }
2151
2192
  }
@@ -140,7 +140,7 @@ export class KeyRingBitcoinService {
140
140
  derivationPath?: string;
141
141
  }> {
142
142
  const chainInfo = this.chainsService.getModularChainInfoOrThrow(chainId);
143
- if (!("bitcoin" in chainInfo)) {
143
+ if (chainInfo.type !== "bitcoin") {
144
144
  throw new KeplrError("keyring", 221, "Chain is not a bitcoin chain");
145
145
  }
146
146
 
@@ -500,7 +500,7 @@ export class KeyRingBitcoinService {
500
500
 
501
501
  private getNetworkConfig(chainId: string) {
502
502
  const chainInfo = this.chainsService.getModularChainInfoOrThrow(chainId);
503
- if (!("bitcoin" in chainInfo)) {
503
+ if (chainInfo.type !== "bitcoin") {
504
504
  throw new KeplrError("keyring", 221, "Chain is not a bitcoin chain");
505
505
  }
506
506
 
@@ -10,6 +10,7 @@ import {
10
10
  StdFee,
11
11
  StdSignature,
12
12
  StdSignDoc,
13
+ isEthSignChain,
13
14
  } from "@keplr-wallet/types";
14
15
  import { APP_PORT, Env, KeplrError } from "@keplr-wallet/router";
15
16
  import {
@@ -119,8 +120,9 @@ export class KeyRingCosmosService {
119
120
 
120
121
  const pubKey = await this.keyRingService.getPubKey(chainId, vaultId);
121
122
 
122
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
123
- const evmInfo = ChainsService.getEVMInfo(chainInfo);
123
+ const modularChainInfo =
124
+ this.chainsService.getModularChainInfoOrThrow(chainId);
125
+ const isEthermintLike = isEthSignChain(modularChainInfo);
124
126
  const forceEVMLedger = chainInfo.features?.includes(
125
127
  "force-enable-evm-ledger"
126
128
  );
@@ -137,7 +139,7 @@ export class KeyRingCosmosService {
137
139
  }
138
140
 
139
141
  const address = (() => {
140
- if (isEthermintLike || evmInfo !== undefined) {
142
+ if (isEthermintLike) {
141
143
  return pubKey.getEthAddress();
142
144
  }
143
145
 
@@ -176,7 +178,9 @@ export class KeyRingCosmosService {
176
178
  coinTypes.push(...chainInfo.alternativeBIP44s.map((alt) => alt.coinType));
177
179
  }
178
180
 
179
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
181
+ const modularChainInfo =
182
+ this.chainsService.getModularChainInfoOrThrow(chainId);
183
+ const isEthermintLike = isEthSignChain(modularChainInfo);
180
184
 
181
185
  const res: {
182
186
  coinType: number;
@@ -250,7 +254,9 @@ export class KeyRingCosmosService {
250
254
  if (chainInfo.hideInUI) {
251
255
  throw new Error("Can't sign for hidden chain");
252
256
  }
253
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
257
+ const modularChainInfo =
258
+ this.chainsService.getModularChainInfoOrThrow(chainId);
259
+ const isEthermintLike = isEthSignChain(modularChainInfo);
254
260
  const forceEVMLedger = chainInfo.features?.includes(
255
261
  "force-enable-evm-ledger"
256
262
  );
@@ -391,7 +397,9 @@ export class KeyRingCosmosService {
391
397
  // if (chainInfo.hideInUI) {
392
398
  // throw new Error("Can't sign for hidden chain");
393
399
  // }
394
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
400
+ const modularChainInfo =
401
+ this.chainsService.getModularChainInfoOrThrow(chainId);
402
+ const isEthermintLike = isEthSignChain(modularChainInfo);
395
403
 
396
404
  const keyInfo = this.keyRingService.getKeyInfo(vaultId);
397
405
  if (!keyInfo) {
@@ -477,7 +485,9 @@ export class KeyRingCosmosService {
477
485
 
478
486
  const vaultId = this.keyRingService.selectedVaultId;
479
487
 
480
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
488
+ const modularChainInfo =
489
+ this.chainsService.getModularChainInfoOrThrow(chainId);
490
+ const isEthermintLike = isEthSignChain(modularChainInfo);
481
491
  const forceEVMLedger = chainInfo.features?.includes(
482
492
  "force-enable-evm-ledger"
483
493
  );
@@ -580,7 +590,9 @@ export class KeyRingCosmosService {
580
590
 
581
591
  const vaultId = this.keyRingService.selectedVaultId;
582
592
 
583
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
593
+ const modularChainInfo =
594
+ this.chainsService.getModularChainInfoOrThrow(chainId);
595
+ const isEthermintLike = isEthSignChain(modularChainInfo);
584
596
  const forceEVMLedger = chainInfo.features?.includes(
585
597
  "force-enable-evm-ledger"
586
598
  );
@@ -717,7 +729,9 @@ export class KeyRingCosmosService {
717
729
 
718
730
  const vaultId = this.keyRingService.selectedVaultId;
719
731
 
720
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
732
+ const modularChainInfo =
733
+ this.chainsService.getModularChainInfoOrThrow(chainId);
734
+ const isEthermintLike = isEthSignChain(modularChainInfo);
721
735
  const forceEVMLedger = chainInfo.features?.includes(
722
736
  "force-enable-evm-ledger"
723
737
  );
@@ -839,7 +853,9 @@ export class KeyRingCosmosService {
839
853
  if (chainInfo.hideInUI) {
840
854
  throw new Error("Can't sign for hidden chain");
841
855
  }
842
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
856
+ const modularChainInfo =
857
+ this.chainsService.getModularChainInfoOrThrow(chainId);
858
+ const isEthermintLike = isEthSignChain(modularChainInfo);
843
859
  const forceEVMLedger = chainInfo.features?.includes(
844
860
  "force-enable-evm-ledger"
845
861
  );
@@ -938,7 +954,9 @@ export class KeyRingCosmosService {
938
954
  if (chainInfo.hideInUI) {
939
955
  throw new Error("Can't sign for hidden chain");
940
956
  }
941
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
957
+ const modularChainInfo =
958
+ this.chainsService.getModularChainInfoOrThrow(chainId);
959
+ const isEthermintLike = isEthSignChain(modularChainInfo);
942
960
  const forceEVMLedger = chainInfo.features?.includes(
943
961
  "force-enable-evm-ledger"
944
962
  );
@@ -1362,7 +1380,9 @@ export class KeyRingCosmosService {
1362
1380
  signDoc: SignDoc
1363
1381
  ): Promise<DirectSignResponse> {
1364
1382
  const chainInfo = this.chainsService.getChainInfoOrThrow(chainId);
1365
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
1383
+ const modularChainInfo =
1384
+ this.chainsService.getModularChainInfoOrThrow(chainId);
1385
+ const isEthermintLike = isEthSignChain(modularChainInfo);
1366
1386
 
1367
1387
  const keyInfo = this.keyRingService.getKeyInfo(vaultId);
1368
1388
  if (!keyInfo) {
@@ -1437,7 +1457,9 @@ export class KeyRingCosmosService {
1437
1457
  if (chainInfo.hideInUI) {
1438
1458
  throw new Error("Can't sign for hidden chain");
1439
1459
  }
1440
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
1460
+ const modularChainInfo =
1461
+ this.chainsService.getModularChainInfoOrThrow(chainId);
1462
+ const isEthermintLike = isEthSignChain(modularChainInfo);
1441
1463
  const forceEVMLedger = chainInfo.features?.includes(
1442
1464
  "force-enable-evm-ledger"
1443
1465
  );
@@ -1575,7 +1597,9 @@ export class KeyRingCosmosService {
1575
1597
  signature: StdSignature
1576
1598
  ): Promise<boolean> {
1577
1599
  const chainInfo = this.chainsService.getChainInfoOrThrow(chainId);
1578
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
1600
+ const modularChainInfo =
1601
+ this.chainsService.getModularChainInfoOrThrow(chainId);
1602
+ const isEthermintLike = isEthSignChain(modularChainInfo);
1579
1603
 
1580
1604
  const key = await this.getKey(vaultId, chainId);
1581
1605
  const bech32Prefix = chainInfo.bech32Config?.bech32PrefixAccAddr ?? "";
@@ -1646,7 +1670,9 @@ export class KeyRingCosmosService {
1646
1670
  if (chainInfo.hideInUI) {
1647
1671
  throw new Error("Can't sign for hidden chain");
1648
1672
  }
1649
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
1673
+ const modularChainInfo =
1674
+ this.chainsService.getModularChainInfoOrThrow(chainId);
1675
+ const isEthermintLike = isEthSignChain(modularChainInfo);
1650
1676
  const forceEVMLedger = chainInfo.features?.includes(
1651
1677
  "force-enable-evm-ledger"
1652
1678
  );
@@ -1799,7 +1825,9 @@ export class KeyRingCosmosService {
1799
1825
  const vaultId = this.keyRingService.selectedVaultId;
1800
1826
 
1801
1827
  const chainInfo = this.chainsService.getChainInfoOrThrow(chainId);
1802
- const isEthermintLike = KeyRingService.isEthermintLike(chainInfo);
1828
+ const modularChainInfo =
1829
+ this.chainsService.getModularChainInfoOrThrow(chainId);
1830
+ const isEthermintLike = isEthSignChain(modularChainInfo);
1803
1831
  const forceEVMLedger = chainInfo.features?.includes(
1804
1832
  "force-enable-evm-ledger"
1805
1833
  );
@@ -1967,8 +1995,8 @@ export class KeyRingCosmosService {
1967
1995
 
1968
1996
  const ownerBech32 = Bech32Address.fromBech32(owner);
1969
1997
  for (const accountInfo of interactionInfo.accountInfos) {
1970
- const isEthermintLike = KeyRingService.isEthermintLike(
1971
- this.chainsService.getChainInfoOrThrow(accountInfo.chainId)
1998
+ const isEthermintLike = isEthSignChain(
1999
+ this.chainsService.getModularChainInfoOrThrow(accountInfo.chainId)
1972
2000
  );
1973
2001
 
1974
2002
  if (