Skip to content

Commit 09f12f5

Browse files
authored
Merge pull request #1646 from chainapsis/Thunnini/KEPLR-1390
chainIdentifier cannot be nested in the {chainIdentifier}-{version} format
2 parents a326b63 + f3f29b3 commit 09f12f5

File tree

2 files changed

+13
-3
lines changed
  • apps/extension/src/pages/setting/advanced/delete-suggest-chain
  • packages/chain-validator/src

2 files changed

+13
-3
lines changed

apps/extension/src/pages/setting/advanced/delete-suggest-chain/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ export const SettingGeneralDeleteSuggestChainPage: FunctionComponent = observer(
4949
key={chainInfo.chainIdentifier}
5050
chainInfo={chainInfo}
5151
onClickClose={async () => {
52-
await chainStore.removeChainInfo(
53-
chainInfo.chainIdentifier
54-
);
52+
// 여기서 chain identifier를 쓰면 안되고 꼭 chainId를 써야함
53+
await chainStore.removeChainInfo(chainInfo.chainId);
5554

5655
dispatchGlobalEventExceptSelf(
5756
"keplr_suggested_chain_removed"

packages/chain-validator/src/schema.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import { SupportedChainFeatures } from "./feature";
1414

1515
import Joi, { ObjectSchema } from "joi";
16+
import { ChainIdHelper } from "@keplr-wallet/cosmos";
1617

1718
export const CurrencySchema = Joi.object<
1819
Currency & {
@@ -281,6 +282,16 @@ export const ChainInfoSchema = Joi.object<ChainInfo>({
281282
hideInUI: Joi.boolean(),
282283
isTestnet: Joi.boolean(),
283284
}).custom((value: ChainInfo) => {
285+
const chainIdentifier1 = ChainIdHelper.parse(value.chainId);
286+
if (chainIdentifier1.version !== 0) {
287+
const chainIdentifier2 = ChainIdHelper.parse(chainIdentifier1.identifier);
288+
if (chainIdentifier1.identifier !== chainIdentifier2.identifier) {
289+
throw new Error(
290+
`chainIdentifier cannot be nested in the {chainIdentifier}-{version} format (chainId: ${value.chainId}, chainIdentifier: ${chainIdentifier1.identifier})`
291+
);
292+
}
293+
}
294+
284295
if (value.nodeProvider) {
285296
if (!value.nodeProvider.email && !value.nodeProvider.discord) {
286297
throw new Error("email or discord should be provided");

0 commit comments

Comments
 (0)