@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.
- package/build/chains/convert.d.ts +7 -0
- package/build/chains/convert.js +109 -0
- package/build/chains/convert.js.map +1 -0
- package/build/chains/handler.js +1 -1
- package/build/chains/handler.js.map +1 -1
- package/build/chains/index.d.ts +1 -0
- package/build/chains/index.js +1 -0
- package/build/chains/index.js.map +1 -1
- package/build/chains/messages.d.ts +1 -1
- package/build/chains/service.d.ts +3 -9
- package/build/chains/service.js +45 -79
- package/build/chains/service.js.map +1 -1
- package/build/chains-ui/service.d.ts +2 -2
- package/build/chains-ui/service.js +5 -6
- package/build/chains-ui/service.js.map +1 -1
- package/build/chains-update/service.js +2 -2
- package/build/chains-update/service.js.map +1 -1
- package/build/keyring/handler.js +21 -15
- package/build/keyring/handler.js.map +1 -1
- package/build/keyring/service.d.ts +0 -1
- package/build/keyring/service.js +103 -78
- package/build/keyring/service.js.map +1 -1
- package/build/keyring-bitcoin/service.js +2 -2
- package/build/keyring-bitcoin/service.js.map +1 -1
- package/build/keyring-cosmos/service.js +31 -18
- package/build/keyring-cosmos/service.js.map +1 -1
- package/build/keyring-ethereum/service.js +19 -19
- package/build/keyring-ethereum/service.js.map +1 -1
- package/build/keyring-ledger/service.js +8 -7
- package/build/keyring-ledger/service.js.map +1 -1
- package/build/keyring-starknet/service.js +7 -7
- package/build/keyring-starknet/service.js.map +1 -1
- package/build/manage-view-asset-token/service.d.ts +1 -2
- package/build/manage-view-asset-token/service.js +2 -2
- package/build/manage-view-asset-token/service.js.map +1 -1
- package/build/permission/service.d.ts +1 -2
- package/build/permission/service.js +2 -2
- package/build/permission/service.js.map +1 -1
- package/build/recent-send-history/service.d.ts +4 -4
- package/build/recent-send-history/service.js +101 -73
- package/build/recent-send-history/service.js.map +1 -1
- package/build/secret-wasm/service.d.ts +3 -3
- package/build/secret-wasm/service.js +29 -29
- package/build/secret-wasm/service.js.map +1 -1
- package/build/token-cw20/service.d.ts +6 -6
- package/build/token-cw20/service.js +28 -21
- package/build/token-cw20/service.js.map +1 -1
- package/build/token-erc20/service.d.ts +2 -3
- package/build/token-erc20/service.js +10 -15
- package/build/token-erc20/service.js.map +1 -1
- package/build/token-scan/service.js +27 -23
- package/build/token-scan/service.js.map +1 -1
- package/build/tx/service.d.ts +1 -0
- package/build/tx/service.js +41 -10
- package/build/tx/service.js.map +1 -1
- package/build/tx-ethereum/service.js +5 -9
- package/build/tx-ethereum/service.js.map +1 -1
- package/build/tx-executor/service.js +2 -7
- package/build/tx-executor/service.js.map +1 -1
- package/build/tx-executor/types.d.ts +7 -1
- package/build/tx-executor/types.js.map +1 -1
- package/build/tx-executor/utils/evm.d.ts +2 -2
- package/build/tx-executor/utils/evm.js +75 -26
- package/build/tx-executor/utils/evm.js.map +1 -1
- package/package.json +13 -13
- package/src/chains/convert.ts +126 -0
- package/src/chains/handler.ts +1 -1
- package/src/chains/index.ts +1 -0
- package/src/chains/messages.ts +1 -1
- package/src/chains/service.ts +64 -97
- package/src/chains-ui/service.ts +8 -7
- package/src/chains-update/service.ts +2 -2
- package/src/keyring/handler.ts +34 -19
- package/src/keyring/service.ts +137 -96
- package/src/keyring-bitcoin/service.ts +2 -2
- package/src/keyring-cosmos/service.ts +46 -18
- package/src/keyring-ethereum/service.ts +24 -17
- package/src/keyring-ledger/service.ts +10 -10
- package/src/keyring-starknet/service.ts +7 -7
- package/src/manage-view-asset-token/service.ts +2 -3
- package/src/permission/service.ts +3 -7
- package/src/recent-send-history/service.ts +141 -95
- package/src/secret-wasm/service.ts +39 -45
- package/src/token-cw20/service.ts +36 -30
- package/src/token-erc20/service.ts +15 -18
- package/src/token-scan/service.ts +34 -21
- package/src/tx/service.ts +60 -12
- package/src/tx-ethereum/service.ts +8 -8
- package/src/tx-executor/service.ts +4 -6
- package/src/tx-executor/types.ts +9 -1
- package/src/tx-executor/utils/evm.ts +92 -32
- package/tsconfig.check.json +2 -0
|
@@ -31,9 +31,9 @@ import {
|
|
|
31
31
|
import { Buffer } from "buffer/";
|
|
32
32
|
import {
|
|
33
33
|
AppCurrency,
|
|
34
|
-
ChainInfo,
|
|
35
34
|
EthTxReceipt,
|
|
36
35
|
EthTxStatus,
|
|
36
|
+
ModularChainInfo,
|
|
37
37
|
} from "@keplr-wallet/types";
|
|
38
38
|
import { CoinPretty } from "@keplr-wallet/unit";
|
|
39
39
|
import { id } from "@ethersproject/hash";
|
|
@@ -310,24 +310,28 @@ export class RecentSendHistoryService {
|
|
|
310
310
|
},
|
|
311
311
|
shouldLegacyTrack: boolean = false
|
|
312
312
|
): Promise<Uint8Array> {
|
|
313
|
-
const
|
|
314
|
-
this.chainsService.
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
313
|
+
const sourceModularChainInfo =
|
|
314
|
+
this.chainsService.getModularChainInfoOrThrow(sourceChainId);
|
|
315
|
+
const sourceBech32Prefix =
|
|
316
|
+
sourceModularChainInfo.type === "cosmos" ||
|
|
317
|
+
sourceModularChainInfo.type === "ethermint"
|
|
318
|
+
? sourceModularChainInfo.cosmos.bech32Config?.bech32PrefixAccAddr
|
|
319
|
+
: undefined;
|
|
320
|
+
Bech32Address.validate(sender, sourceBech32Prefix);
|
|
319
321
|
|
|
320
|
-
const
|
|
321
|
-
this.chainsService.
|
|
322
|
+
const destModularChainInfo =
|
|
323
|
+
this.chainsService.getModularChainInfoOrThrow(destinationChainId);
|
|
322
324
|
if (recipient.startsWith("0x")) {
|
|
323
325
|
if (!recipient.match(/^0x[0-9A-Fa-f]*$/) || recipient.length !== 42) {
|
|
324
326
|
throw new Error("Recipient address is not valid hex address");
|
|
325
327
|
}
|
|
326
328
|
} else {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
329
|
+
const destBech32Prefix =
|
|
330
|
+
destModularChainInfo.type === "cosmos" ||
|
|
331
|
+
destModularChainInfo.type === "ethermint"
|
|
332
|
+
? destModularChainInfo.cosmos.bech32Config?.bech32PrefixAccAddr
|
|
333
|
+
: undefined;
|
|
334
|
+
Bech32Address.validate(recipient, destBech32Prefix);
|
|
331
335
|
}
|
|
332
336
|
|
|
333
337
|
const txHash = await this.txService.sendTx(sourceChainId, tx, mode, {
|
|
@@ -449,14 +453,16 @@ export class RecentSendHistoryService {
|
|
|
449
453
|
},
|
|
450
454
|
shouldLegacyTrack: boolean = false
|
|
451
455
|
): Promise<Uint8Array> {
|
|
452
|
-
const
|
|
453
|
-
this.chainsService.
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
456
|
+
const sourceModularChainInfo =
|
|
457
|
+
this.chainsService.getModularChainInfoOrThrow(sourceChainId);
|
|
458
|
+
const sourceBech32Prefix =
|
|
459
|
+
sourceModularChainInfo.type === "cosmos" ||
|
|
460
|
+
sourceModularChainInfo.type === "ethermint"
|
|
461
|
+
? sourceModularChainInfo.cosmos.bech32Config?.bech32PrefixAccAddr
|
|
462
|
+
: undefined;
|
|
463
|
+
Bech32Address.validate(sender, sourceBech32Prefix);
|
|
458
464
|
|
|
459
|
-
this.chainsService.
|
|
465
|
+
this.chainsService.getModularChainInfoOrThrow(destinationChainId);
|
|
460
466
|
|
|
461
467
|
const txHash = await this.txService.sendTx(sourceChainId, tx, mode, {
|
|
462
468
|
silent,
|
|
@@ -635,17 +641,19 @@ export class RecentSendHistoryService {
|
|
|
635
641
|
|
|
636
642
|
getRecentIBCHistories(): IBCHistory[] {
|
|
637
643
|
return Array.from(this.recentIBCHistoryMap.values()).filter((history) => {
|
|
638
|
-
if (!this.chainsService.
|
|
644
|
+
if (!this.chainsService.hasModularChainInfo(history.chainId)) {
|
|
639
645
|
return false;
|
|
640
646
|
}
|
|
641
647
|
|
|
642
|
-
if (!this.chainsService.
|
|
648
|
+
if (!this.chainsService.hasModularChainInfo(history.destinationChainId)) {
|
|
643
649
|
return false;
|
|
644
650
|
}
|
|
645
651
|
|
|
646
652
|
if (
|
|
647
653
|
history.ibcHistory.some((history) => {
|
|
648
|
-
return !this.chainsService.
|
|
654
|
+
return !this.chainsService.hasModularChainInfo(
|
|
655
|
+
history.counterpartyChainId
|
|
656
|
+
);
|
|
649
657
|
})
|
|
650
658
|
) {
|
|
651
659
|
return false;
|
|
@@ -816,10 +824,10 @@ export class RecentSendHistoryService {
|
|
|
816
824
|
history.notified = true;
|
|
817
825
|
});
|
|
818
826
|
|
|
819
|
-
const
|
|
827
|
+
const modularChainInfo = this.chainsService.getModularChainInfo(
|
|
820
828
|
history.destinationChainId
|
|
821
829
|
);
|
|
822
|
-
if (
|
|
830
|
+
if (modularChainInfo) {
|
|
823
831
|
if ("swapType" in history) {
|
|
824
832
|
if (history.resAmount.length > 0) {
|
|
825
833
|
const amount = history.resAmount[history.resAmount.length - 1];
|
|
@@ -845,7 +853,7 @@ export class RecentSendHistoryService {
|
|
|
845
853
|
iconRelativeUrl: "assets/logo-256.png",
|
|
846
854
|
title: "IBC Swap Succeeded",
|
|
847
855
|
message: `${assetsText.join(", ")} received on ${
|
|
848
|
-
|
|
856
|
+
modularChainInfo.chainName
|
|
849
857
|
}`,
|
|
850
858
|
});
|
|
851
859
|
}
|
|
@@ -873,7 +881,7 @@ export class RecentSendHistoryService {
|
|
|
873
881
|
iconRelativeUrl: "assets/logo-256.png",
|
|
874
882
|
title: "IBC Transfer Succeeded",
|
|
875
883
|
message: `${assetsText.join(", ")} sent to ${
|
|
876
|
-
|
|
884
|
+
modularChainInfo.chainName
|
|
877
885
|
}`,
|
|
878
886
|
});
|
|
879
887
|
}
|
|
@@ -925,13 +933,13 @@ export class RecentSendHistoryService {
|
|
|
925
933
|
onError: () => void;
|
|
926
934
|
}): void => {
|
|
927
935
|
const { chainId, txHash, onSuccess, onPending, onFailed, onError } = params;
|
|
928
|
-
const
|
|
929
|
-
if (!
|
|
936
|
+
const modularChainInfo = this.chainsService.getModularChainInfo(chainId);
|
|
937
|
+
if (!modularChainInfo) {
|
|
930
938
|
onFailed();
|
|
931
939
|
return;
|
|
932
940
|
}
|
|
933
941
|
|
|
934
|
-
this.resolveTxExecutionStatus(
|
|
942
|
+
this.resolveTxExecutionStatus(modularChainInfo, chainId, txHash)
|
|
935
943
|
.then((status) => {
|
|
936
944
|
switch (status) {
|
|
937
945
|
case "success":
|
|
@@ -954,18 +962,20 @@ export class RecentSendHistoryService {
|
|
|
954
962
|
};
|
|
955
963
|
|
|
956
964
|
protected async resolveTxExecutionStatus(
|
|
957
|
-
|
|
965
|
+
modularChainInfo: ModularChainInfo,
|
|
958
966
|
chainId: string,
|
|
959
967
|
txHash: string
|
|
960
968
|
): Promise<"success" | "failed" | "pending" | "error"> {
|
|
961
969
|
if (this.chainsService.isEvmChain(chainId)) {
|
|
962
|
-
|
|
963
|
-
|
|
970
|
+
if (
|
|
971
|
+
modularChainInfo.type !== "evm" &&
|
|
972
|
+
modularChainInfo.type !== "ethermint"
|
|
973
|
+
) {
|
|
964
974
|
return Promise.resolve("error");
|
|
965
975
|
}
|
|
966
976
|
|
|
967
977
|
const res = await requestEthTxReceipt({
|
|
968
|
-
rpc:
|
|
978
|
+
rpc: modularChainInfo.evm.rpc,
|
|
969
979
|
txHash,
|
|
970
980
|
origin,
|
|
971
981
|
});
|
|
@@ -985,7 +995,17 @@ export class RecentSendHistoryService {
|
|
|
985
995
|
return "failed";
|
|
986
996
|
}
|
|
987
997
|
|
|
988
|
-
|
|
998
|
+
if (
|
|
999
|
+
modularChainInfo.type !== "cosmos" &&
|
|
1000
|
+
modularChainInfo.type !== "ethermint"
|
|
1001
|
+
) {
|
|
1002
|
+
return Promise.resolve("error");
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
const txTracer = new TendermintTxTracer(
|
|
1006
|
+
modularChainInfo.cosmos.rpc,
|
|
1007
|
+
"/websocket"
|
|
1008
|
+
);
|
|
989
1009
|
txTracer.addEventListener("error", () => {
|
|
990
1010
|
txTracer.close();
|
|
991
1011
|
});
|
|
@@ -1040,8 +1060,8 @@ export class RecentSendHistoryService {
|
|
|
1040
1060
|
onFulfill,
|
|
1041
1061
|
} = params;
|
|
1042
1062
|
|
|
1043
|
-
const
|
|
1044
|
-
if (!
|
|
1063
|
+
const modularChainInfo = this.chainsService.getModularChainInfo(chainId);
|
|
1064
|
+
if (!modularChainInfo) {
|
|
1045
1065
|
onFulfill();
|
|
1046
1066
|
return;
|
|
1047
1067
|
}
|
|
@@ -1065,8 +1085,16 @@ export class RecentSendHistoryService {
|
|
|
1065
1085
|
return;
|
|
1066
1086
|
}
|
|
1067
1087
|
|
|
1088
|
+
if (
|
|
1089
|
+
modularChainInfo.type !== "cosmos" &&
|
|
1090
|
+
modularChainInfo.type !== "ethermint"
|
|
1091
|
+
) {
|
|
1092
|
+
onFulfill();
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1068
1096
|
this.traceCosmosTransactionResult({
|
|
1069
|
-
|
|
1097
|
+
rpc: modularChainInfo.cosmos.rpc,
|
|
1070
1098
|
txHash,
|
|
1071
1099
|
recipient,
|
|
1072
1100
|
onResult,
|
|
@@ -1075,14 +1103,14 @@ export class RecentSendHistoryService {
|
|
|
1075
1103
|
}
|
|
1076
1104
|
|
|
1077
1105
|
protected traceCosmosTransactionResult(params: {
|
|
1078
|
-
|
|
1106
|
+
rpc: string;
|
|
1079
1107
|
txHash: string;
|
|
1080
1108
|
recipient: string;
|
|
1081
1109
|
onResult: (resAmount: { amount: string; denom: string }[]) => void;
|
|
1082
1110
|
onFulfill: () => void;
|
|
1083
1111
|
}) {
|
|
1084
|
-
const {
|
|
1085
|
-
const txTracer = new TendermintTxTracer(
|
|
1112
|
+
const { rpc, txHash, recipient, onResult, onFulfill } = params;
|
|
1113
|
+
const txTracer = new TendermintTxTracer(rpc, "/websocket");
|
|
1086
1114
|
txTracer.addEventListener("error", () => onFulfill());
|
|
1087
1115
|
txTracer
|
|
1088
1116
|
.queryTx({
|
|
@@ -1128,28 +1156,24 @@ export class RecentSendHistoryService {
|
|
|
1128
1156
|
const { chainId, txHash, recipient, targetDenom, onResult, onFulfill } =
|
|
1129
1157
|
params;
|
|
1130
1158
|
|
|
1131
|
-
const
|
|
1132
|
-
if (!
|
|
1159
|
+
const modularChainInfo = this.chainsService.getModularChainInfo(chainId);
|
|
1160
|
+
if (!modularChainInfo) {
|
|
1133
1161
|
onResult({ success: false });
|
|
1134
1162
|
onFulfill();
|
|
1135
1163
|
return;
|
|
1136
1164
|
}
|
|
1137
1165
|
|
|
1138
|
-
if (
|
|
1166
|
+
if (
|
|
1167
|
+
modularChainInfo.type !== "evm" &&
|
|
1168
|
+
modularChainInfo.type !== "ethermint"
|
|
1169
|
+
) {
|
|
1139
1170
|
onResult({ success: false, error: "Not an EVM chain" });
|
|
1140
1171
|
onFulfill();
|
|
1141
1172
|
return;
|
|
1142
1173
|
}
|
|
1143
1174
|
|
|
1144
|
-
const evmInfo = chainInfo.evm;
|
|
1145
|
-
if (!evmInfo) {
|
|
1146
|
-
onResult({ success: false });
|
|
1147
|
-
onFulfill();
|
|
1148
|
-
return;
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
1175
|
requestEthTxReceipt({
|
|
1152
|
-
rpc:
|
|
1176
|
+
rpc: modularChainInfo.evm.rpc,
|
|
1153
1177
|
txHash,
|
|
1154
1178
|
origin,
|
|
1155
1179
|
})
|
|
@@ -1161,7 +1185,7 @@ export class RecentSendHistoryService {
|
|
|
1161
1185
|
}
|
|
1162
1186
|
|
|
1163
1187
|
requestEthTxTrace({
|
|
1164
|
-
rpc:
|
|
1188
|
+
rpc: modularChainInfo.evm.rpc,
|
|
1165
1189
|
txHash,
|
|
1166
1190
|
origin,
|
|
1167
1191
|
}).then((traceRes) => {
|
|
@@ -1382,17 +1406,17 @@ export class RecentSendHistoryService {
|
|
|
1382
1406
|
|
|
1383
1407
|
getRecentSkipHistories(): SkipHistory[] {
|
|
1384
1408
|
return Array.from(this.recentSkipHistoryMap.values()).filter((history) => {
|
|
1385
|
-
if (!this.chainsService.
|
|
1409
|
+
if (!this.chainsService.hasModularChainInfo(history.chainId)) {
|
|
1386
1410
|
return false;
|
|
1387
1411
|
}
|
|
1388
1412
|
|
|
1389
|
-
if (!this.chainsService.
|
|
1413
|
+
if (!this.chainsService.hasModularChainInfo(history.destinationChainId)) {
|
|
1390
1414
|
return false;
|
|
1391
1415
|
}
|
|
1392
1416
|
|
|
1393
1417
|
if (
|
|
1394
1418
|
history.simpleRoute.some((route) => {
|
|
1395
|
-
return !this.chainsService.
|
|
1419
|
+
return !this.chainsService.hasModularChainInfo(route.chainId);
|
|
1396
1420
|
})
|
|
1397
1421
|
) {
|
|
1398
1422
|
return false;
|
|
@@ -1866,10 +1890,10 @@ export class RecentSendHistoryService {
|
|
|
1866
1890
|
return;
|
|
1867
1891
|
}
|
|
1868
1892
|
|
|
1869
|
-
const
|
|
1893
|
+
const modularChainInfo = this.chainsService.getModularChainInfo(
|
|
1870
1894
|
history.destinationChainId
|
|
1871
1895
|
);
|
|
1872
|
-
if (!
|
|
1896
|
+
if (!modularChainInfo) {
|
|
1873
1897
|
onFulfill();
|
|
1874
1898
|
return;
|
|
1875
1899
|
}
|
|
@@ -2412,8 +2436,9 @@ export class RecentSendHistoryService {
|
|
|
2412
2436
|
return;
|
|
2413
2437
|
}
|
|
2414
2438
|
|
|
2415
|
-
const
|
|
2416
|
-
|
|
2439
|
+
const modularChainInfo =
|
|
2440
|
+
this.chainsService.getModularChainInfo(targetChainId);
|
|
2441
|
+
if (!modularChainInfo) {
|
|
2417
2442
|
onFulfill();
|
|
2418
2443
|
return;
|
|
2419
2444
|
}
|
|
@@ -2457,17 +2482,17 @@ export class RecentSendHistoryService {
|
|
|
2457
2482
|
getRecentSwapV2Histories(): SwapV2History[] {
|
|
2458
2483
|
return Array.from(this.recentSwapV2HistoryMap.values()).filter(
|
|
2459
2484
|
(history) => {
|
|
2460
|
-
if (!this.chainsService.
|
|
2485
|
+
if (!this.chainsService.hasModularChainInfo(history.fromChainId)) {
|
|
2461
2486
|
return false;
|
|
2462
2487
|
}
|
|
2463
2488
|
|
|
2464
|
-
if (!this.chainsService.
|
|
2489
|
+
if (!this.chainsService.hasModularChainInfo(history.toChainId)) {
|
|
2465
2490
|
return false;
|
|
2466
2491
|
}
|
|
2467
2492
|
|
|
2468
2493
|
if (
|
|
2469
2494
|
history.simpleRoute.some((route) => {
|
|
2470
|
-
return !this.chainsService.
|
|
2495
|
+
return !this.chainsService.hasModularChainInfo(route.chainId);
|
|
2471
2496
|
})
|
|
2472
2497
|
) {
|
|
2473
2498
|
return false;
|
|
@@ -2526,8 +2551,10 @@ export class RecentSendHistoryService {
|
|
|
2526
2551
|
return;
|
|
2527
2552
|
}
|
|
2528
2553
|
|
|
2529
|
-
const
|
|
2530
|
-
|
|
2554
|
+
const modularChainInfo = this.chainsService.getModularChainInfo(
|
|
2555
|
+
history.toChainId
|
|
2556
|
+
);
|
|
2557
|
+
if (!modularChainInfo) {
|
|
2531
2558
|
return;
|
|
2532
2559
|
}
|
|
2533
2560
|
|
|
@@ -2560,7 +2587,9 @@ export class RecentSendHistoryService {
|
|
|
2560
2587
|
this.notification.create({
|
|
2561
2588
|
iconRelativeUrl: "assets/logo-256.png",
|
|
2562
2589
|
title: "Swap Succeeded",
|
|
2563
|
-
message: `${assetsText.join(", ")} received on ${
|
|
2590
|
+
message: `${assetsText.join(", ")} received on ${
|
|
2591
|
+
modularChainInfo.chainName
|
|
2592
|
+
}`,
|
|
2564
2593
|
});
|
|
2565
2594
|
}
|
|
2566
2595
|
|
|
@@ -2959,13 +2988,20 @@ export class RecentSendHistoryService {
|
|
|
2959
2988
|
onError,
|
|
2960
2989
|
} = params;
|
|
2961
2990
|
|
|
2962
|
-
const
|
|
2963
|
-
if (
|
|
2991
|
+
const modularChainInfo = this.chainsService.getModularChainInfo(chainId);
|
|
2992
|
+
if (
|
|
2993
|
+
!modularChainInfo ||
|
|
2994
|
+
(modularChainInfo.type !== "cosmos" &&
|
|
2995
|
+
modularChainInfo.type !== "ethermint")
|
|
2996
|
+
) {
|
|
2964
2997
|
onFulfill();
|
|
2965
2998
|
return;
|
|
2966
2999
|
}
|
|
2967
3000
|
|
|
2968
|
-
const txTracer = new TendermintTxTracer(
|
|
3001
|
+
const txTracer = new TendermintTxTracer(
|
|
3002
|
+
modularChainInfo.cosmos.rpc,
|
|
3003
|
+
"/websocket"
|
|
3004
|
+
);
|
|
2969
3005
|
txTracer.addEventListener("close", onClose);
|
|
2970
3006
|
txTracer.addEventListener("error", onError);
|
|
2971
3007
|
|
|
@@ -3071,26 +3107,26 @@ export class RecentSendHistoryService {
|
|
|
3071
3107
|
);
|
|
3072
3108
|
if (targetChannel !== undefined && targetChannel.sequence !== undefined) {
|
|
3073
3109
|
const targetSequence = targetChannel.sequence;
|
|
3074
|
-
const
|
|
3110
|
+
const prevChain = (() => {
|
|
3075
3111
|
const targetChannelIndex = ibcHistory.findIndex(
|
|
3076
3112
|
(h) => h === targetChannel
|
|
3077
3113
|
);
|
|
3078
3114
|
if (targetChannelIndex < 0) {
|
|
3079
3115
|
return undefined;
|
|
3080
3116
|
}
|
|
3081
|
-
|
|
3082
|
-
|
|
3117
|
+
const prevChainId =
|
|
3118
|
+
targetChannelIndex === 0
|
|
3119
|
+
? sourceChainId
|
|
3120
|
+
: ibcHistory[targetChannelIndex - 1].counterpartyChainId;
|
|
3121
|
+
const m = this.chainsService.getModularChainInfo(prevChainId);
|
|
3122
|
+
if (m && (m.type === "cosmos" || m.type === "ethermint")) {
|
|
3123
|
+
return { chainId: m.chainId, rpc: m.cosmos.rpc };
|
|
3083
3124
|
}
|
|
3084
|
-
return
|
|
3085
|
-
ibcHistory[targetChannelIndex - 1].counterpartyChainId
|
|
3086
|
-
);
|
|
3125
|
+
return undefined;
|
|
3087
3126
|
})();
|
|
3088
3127
|
|
|
3089
|
-
if (
|
|
3090
|
-
const txTracer = new TendermintTxTracer(
|
|
3091
|
-
prevChainInfo.rpc,
|
|
3092
|
-
"/websocket"
|
|
3093
|
-
);
|
|
3128
|
+
if (prevChain) {
|
|
3129
|
+
const txTracer = new TendermintTxTracer(prevChain.rpc, "/websocket");
|
|
3094
3130
|
txTracer.addEventListener("close", onClose);
|
|
3095
3131
|
txTracer.addEventListener("error", onError);
|
|
3096
3132
|
txTracer
|
|
@@ -3166,7 +3202,7 @@ export class RecentSendHistoryService {
|
|
|
3166
3202
|
);
|
|
3167
3203
|
|
|
3168
3204
|
swapContext.setSwapRefundInfo?.({
|
|
3169
|
-
chainId:
|
|
3205
|
+
chainId: prevChain.chainId,
|
|
3170
3206
|
amount: refunded,
|
|
3171
3207
|
});
|
|
3172
3208
|
|
|
@@ -3400,8 +3436,13 @@ export class RecentSendHistoryService {
|
|
|
3400
3436
|
prevChainId = sourceChainId;
|
|
3401
3437
|
}
|
|
3402
3438
|
if (prevChainId) {
|
|
3403
|
-
const
|
|
3404
|
-
|
|
3439
|
+
const prevModularChainInfo =
|
|
3440
|
+
this.chainsService.getModularChainInfo(prevChainId);
|
|
3441
|
+
if (
|
|
3442
|
+
prevModularChainInfo &&
|
|
3443
|
+
(prevModularChainInfo.type === "cosmos" ||
|
|
3444
|
+
prevModularChainInfo.type === "ethermint")
|
|
3445
|
+
) {
|
|
3405
3446
|
const queryEvents: any = {
|
|
3406
3447
|
// acknowledge_packet과는 다르게 timeout_packet은 이전의 체인의 이벤트로부터만 알 수 있다.
|
|
3407
3448
|
// 방법이 없기 때문에 여기서 이전의 체인으로부터 subscribe를 해서 이벤트를 받아야 한다.
|
|
@@ -3413,7 +3454,7 @@ export class RecentSendHistoryService {
|
|
|
3413
3454
|
};
|
|
3414
3455
|
|
|
3415
3456
|
const txTracer = new TendermintTxTracer(
|
|
3416
|
-
|
|
3457
|
+
prevModularChainInfo.cosmos.rpc,
|
|
3417
3458
|
"/websocket"
|
|
3418
3459
|
);
|
|
3419
3460
|
registerClosable(txTracer);
|
|
@@ -3487,11 +3528,15 @@ export class RecentSendHistoryService {
|
|
|
3487
3528
|
}
|
|
3488
3529
|
const sequence = targetChannel.sequence;
|
|
3489
3530
|
|
|
3490
|
-
const
|
|
3531
|
+
const counterpartyModularChainInfo = this.chainsService.getModularChainInfo(
|
|
3491
3532
|
targetChannel.counterpartyChainId
|
|
3492
3533
|
);
|
|
3493
3534
|
|
|
3494
|
-
if (
|
|
3535
|
+
if (
|
|
3536
|
+
!counterpartyModularChainInfo ||
|
|
3537
|
+
(counterpartyModularChainInfo.type !== "cosmos" &&
|
|
3538
|
+
counterpartyModularChainInfo.type !== "ethermint")
|
|
3539
|
+
) {
|
|
3495
3540
|
onFulfill();
|
|
3496
3541
|
return;
|
|
3497
3542
|
}
|
|
@@ -3503,7 +3548,7 @@ export class RecentSendHistoryService {
|
|
|
3503
3548
|
};
|
|
3504
3549
|
|
|
3505
3550
|
const txTracer = new TendermintTxTracer(
|
|
3506
|
-
|
|
3551
|
+
counterpartyModularChainInfo.cosmos.rpc,
|
|
3507
3552
|
"/websocket"
|
|
3508
3553
|
);
|
|
3509
3554
|
txTracer.addEventListener("close", onClose);
|
|
@@ -3533,7 +3578,9 @@ export class RecentSendHistoryService {
|
|
|
3533
3578
|
|
|
3534
3579
|
const tx = matchedTx || txs[0];
|
|
3535
3580
|
|
|
3536
|
-
|
|
3581
|
+
runInAction(() => {
|
|
3582
|
+
targetChannel.completed = true;
|
|
3583
|
+
});
|
|
3537
3584
|
|
|
3538
3585
|
let resAmount: { amount: string; denom: string }[] | undefined;
|
|
3539
3586
|
const receiverIndex = targetChannelIndex + 1;
|
|
@@ -3604,15 +3651,14 @@ export class RecentSendHistoryService {
|
|
|
3604
3651
|
// 예를 들어, source chain -> osmosis (swap) -> destination chain으로 이동하는 경우,
|
|
3605
3652
|
// osmosis에서 IBC wrapped token이 destination chain으로 전송되고,
|
|
3606
3653
|
// destination chain에서 IBC wrapped token을 unwrap하는 케이스가 있을 수 있다.
|
|
3607
|
-
const
|
|
3608
|
-
destinationAsset.chainId
|
|
3609
|
-
);
|
|
3654
|
+
const destinationModularChainInfo =
|
|
3655
|
+
this.chainsService.getModularChainInfo(destinationAsset.chainId);
|
|
3610
3656
|
|
|
3611
|
-
if (
|
|
3657
|
+
if (destinationModularChainInfo) {
|
|
3612
3658
|
onDynamicHopDetected({
|
|
3613
3659
|
portId: "transfer", // CHECK: transfer를 하드코딩해도 되는지 확인
|
|
3614
3660
|
channelId: lastSendPacket.srcChannel,
|
|
3615
|
-
counterpartyChainId:
|
|
3661
|
+
counterpartyChainId: destinationModularChainInfo.chainId,
|
|
3616
3662
|
sequence: lastSendPacket.sequence,
|
|
3617
3663
|
dstChannelId: lastSendPacket.dstChannel,
|
|
3618
3664
|
packetData: lastSendPacket.packetData,
|
|
@@ -4416,8 +4462,8 @@ export class RecentSendHistoryService {
|
|
|
4416
4462
|
// ============================================================================
|
|
4417
4463
|
// Chain removed handler
|
|
4418
4464
|
// ============================================================================
|
|
4419
|
-
protected readonly onChainRemoved = (
|
|
4420
|
-
const chainIdentifier = ChainIdHelper.parse(
|
|
4465
|
+
protected readonly onChainRemoved = (chainId: string) => {
|
|
4466
|
+
const chainIdentifier = ChainIdHelper.parse(chainId).identifier;
|
|
4421
4467
|
try {
|
|
4422
4468
|
this.removeIBCHistoriesByChainIdentifier(chainIdentifier);
|
|
4423
4469
|
this.removeSkipHistoriesByChainIdentifier(chainIdentifier);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { EnigmaUtils } from "./enigma-utils";
|
|
2
2
|
import { ChainsService } from "../chains";
|
|
3
3
|
import { KVStore } from "@keplr-wallet/common";
|
|
4
|
-
import { ChainInfo } from "@keplr-wallet/types";
|
|
5
4
|
import { ChainIdHelper } from "@keplr-wallet/cosmos";
|
|
6
5
|
import { Buffer } from "buffer/";
|
|
7
6
|
import { KeyRingCosmosService } from "../keyring-cosmos";
|
|
@@ -54,12 +53,22 @@ export class SecretWasmService {
|
|
|
54
53
|
this.cacheEnigmaUtils = new Map();
|
|
55
54
|
};
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
protected getCosmosRest(chainId: string): string {
|
|
57
|
+
const modularChainInfo =
|
|
58
|
+
this.chainsService.getModularChainInfoOrThrow(chainId);
|
|
59
|
+
if (
|
|
60
|
+
modularChainInfo.type !== "cosmos" &&
|
|
61
|
+
modularChainInfo.type !== "ethermint"
|
|
62
|
+
) {
|
|
63
|
+
throw new Error(`Not a cosmos chain: ${chainId}`);
|
|
64
|
+
}
|
|
65
|
+
return modularChainInfo.cosmos.rest;
|
|
66
|
+
}
|
|
61
67
|
|
|
62
|
-
|
|
68
|
+
async getPubkey(chainId: string): Promise<Uint8Array> {
|
|
69
|
+
const rest = this.getCosmosRest(chainId);
|
|
70
|
+
const seed = await this.getSeed(chainId);
|
|
71
|
+
const utils = this.getEnigmaUtils(chainId, rest, seed);
|
|
63
72
|
return utils.pubkey;
|
|
64
73
|
}
|
|
65
74
|
|
|
@@ -67,11 +76,9 @@ export class SecretWasmService {
|
|
|
67
76
|
chainId: string,
|
|
68
77
|
nonce: Uint8Array
|
|
69
78
|
): Promise<Uint8Array> {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const utils = this.getEnigmaUtils(chainInfo, seed);
|
|
79
|
+
const rest = this.getCosmosRest(chainId);
|
|
80
|
+
const seed = await this.getSeed(chainId);
|
|
81
|
+
const utils = this.getEnigmaUtils(chainId, rest, seed);
|
|
75
82
|
return utils.getTxEncryptionKey(nonce);
|
|
76
83
|
}
|
|
77
84
|
|
|
@@ -81,16 +88,9 @@ export class SecretWasmService {
|
|
|
81
88
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
82
89
|
msg: object
|
|
83
90
|
): Promise<Uint8Array> {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// Otherwise, it will lost the encryption/decryption key if Keplr is uninstalled or local storage is cleared.
|
|
88
|
-
// For now, use the signature of some string to generate the seed.
|
|
89
|
-
// It need to more research.
|
|
90
|
-
const seed = await this.getSeed(chainInfo);
|
|
91
|
-
|
|
92
|
-
const utils = this.getEnigmaUtils(chainInfo, seed);
|
|
93
|
-
|
|
91
|
+
const rest = this.getCosmosRest(chainId);
|
|
92
|
+
const seed = await this.getSeed(chainId);
|
|
93
|
+
const utils = this.getEnigmaUtils(chainId, rest, seed);
|
|
94
94
|
return await utils.encrypt(contractCodeHash, msg);
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -99,52 +99,46 @@ export class SecretWasmService {
|
|
|
99
99
|
ciphertext: Uint8Array,
|
|
100
100
|
nonce: Uint8Array
|
|
101
101
|
): Promise<Uint8Array> {
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// Otherwise, it will lost the encryption/decryption key if Keplr is uninstalled or local storage is cleared.
|
|
106
|
-
// For now, use the signature of some string to generate the seed.
|
|
107
|
-
// It need to more research.
|
|
108
|
-
const seed = await this.getSeed(chainInfo);
|
|
109
|
-
|
|
110
|
-
const utils = this.getEnigmaUtils(chainInfo, seed);
|
|
111
|
-
|
|
102
|
+
const rest = this.getCosmosRest(chainId);
|
|
103
|
+
const seed = await this.getSeed(chainId);
|
|
104
|
+
const utils = this.getEnigmaUtils(chainId, rest, seed);
|
|
112
105
|
return await utils.decrypt(ciphertext, nonce);
|
|
113
106
|
}
|
|
114
107
|
|
|
115
|
-
private getEnigmaUtils(
|
|
116
|
-
|
|
108
|
+
private getEnigmaUtils(
|
|
109
|
+
chainId: string,
|
|
110
|
+
rest: string,
|
|
111
|
+
seed: Uint8Array
|
|
112
|
+
): EnigmaUtils {
|
|
113
|
+
const key = `${chainId}-${Buffer.from(seed).toString("hex")}`;
|
|
117
114
|
|
|
118
115
|
if (this.cacheEnigmaUtils.has(key)) {
|
|
119
116
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
120
117
|
return this.cacheEnigmaUtils.get(key)!;
|
|
121
118
|
}
|
|
122
119
|
|
|
123
|
-
const utils = new EnigmaUtils(
|
|
120
|
+
const utils = new EnigmaUtils(rest, seed, rest);
|
|
124
121
|
this.cacheEnigmaUtils.set(key, utils);
|
|
125
122
|
|
|
126
123
|
return utils;
|
|
127
124
|
}
|
|
128
125
|
|
|
129
|
-
protected async getSeed(
|
|
130
|
-
const key = await this.keyRingCosmosService.getKeySelected(
|
|
131
|
-
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
return await this.getSeedInner(chainInfo, key);
|
|
126
|
+
protected async getSeed(chainId: string): Promise<Uint8Array> {
|
|
127
|
+
const key = await this.keyRingCosmosService.getKeySelected(chainId);
|
|
128
|
+
return await this.getSeedInner(chainId, key);
|
|
135
129
|
}
|
|
136
130
|
|
|
137
131
|
protected async getSeedInner(
|
|
138
|
-
|
|
132
|
+
chainId: string,
|
|
139
133
|
key: {
|
|
140
134
|
readonly bech32Address: string;
|
|
141
135
|
readonly isNanoLedger: boolean;
|
|
142
136
|
readonly isKeystone: boolean;
|
|
143
137
|
}
|
|
144
138
|
): Promise<Uint8Array> {
|
|
145
|
-
const cacheKey = `seed-${
|
|
146
|
-
|
|
147
|
-
}
|
|
139
|
+
const cacheKey = `seed-${ChainIdHelper.parse(chainId).identifier}-${
|
|
140
|
+
key.bech32Address
|
|
141
|
+
}`;
|
|
148
142
|
|
|
149
143
|
const cached = this.seedMap.get(cacheKey);
|
|
150
144
|
if (cached) {
|
|
@@ -160,7 +154,7 @@ export class SecretWasmService {
|
|
|
160
154
|
|
|
161
155
|
return Hash.sha256(
|
|
162
156
|
await this.keyRingCosmosService.legacySignArbitraryInternal(
|
|
163
|
-
|
|
157
|
+
chainId,
|
|
164
158
|
"Create Keplr Secret encryption key. Only approve requests by Keplr."
|
|
165
159
|
)
|
|
166
160
|
);
|