From 673c00049df87a5891628281ef73f32307517e14 Mon Sep 17 00:00:00 2001 From: Francisco Gamundi Date: Wed, 5 Jul 2023 04:53:58 +0200 Subject: [PATCH 1/4] Get isEthereum from chain properties --- packages/react-api/src/Api.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/react-api/src/Api.tsx b/packages/react-api/src/Api.tsx index d3295c4478d2..15dd64e1bfcb 100644 --- a/packages/react-api/src/Api.tsx +++ b/packages/react-api/src/Api.tsx @@ -106,13 +106,14 @@ function makeCreateLink (baseApiUrl: string, isElectron: boolean): (path: string } async function retrieve (api: ApiPromise, injectedPromise: Promise): Promise { - const [systemChain, systemChainType, systemName, systemVersion, injectedAccounts] = await Promise.all([ + const [systemChain, systemChainType, systemName, systemVersion, properties, injectedAccounts] = await Promise.all([ api.rpc.system.chain(), api.rpc.system.chainType ? api.rpc.system.chainType() : Promise.resolve(statics.registry.createType('ChainType', 'Live')), api.rpc.system.name(), api.rpc.system.version(), + api.rpc.system.properties(), getInjectedAccounts(injectedPromise) ]); @@ -121,9 +122,10 @@ async function retrieve (api: ApiPromise, injectedPromise: Promise').toString(), systemChainType, @@ -142,7 +144,7 @@ async function loadOnReady (api: ApiPromise, endpoint: LinkOption | null, inject : settings.prefix; const tokenSymbol = properties.tokenSymbol.unwrapOr([formatBalance.getDefaults().unit, ...DEFAULT_AUX]); const tokenDecimals = properties.tokenDecimals.unwrapOr([DEFAULT_DECIMALS]); - const isEthereum = ethereumChains.includes(api.runtimeVersion.specName.toString()); + const isEthereum = properties.isEthereum.unwrapOr(ethereumChains.includes(api.runtimeVersion.specName.toString())); const isDevelopment = (systemChainType.isDevelopment || systemChainType.isLocal || isTestChain(systemChain)); console.log(`chain: ${systemChain} (${systemChainType.toString()}), ${stringify(properties)}`); From d21303c2da4ee98cac28784cfb94cb73d3c56f82 Mon Sep 17 00:00:00 2001 From: Francisco Gamundi Date: Mon, 10 Jul 2023 16:15:42 +0200 Subject: [PATCH 2/4] Set isEthereum in registry --- packages/react-api/src/Api.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/react-api/src/Api.tsx b/packages/react-api/src/Api.tsx index 15dd64e1bfcb..d56362cbf7ec 100644 --- a/packages/react-api/src/Api.tsx +++ b/packages/react-api/src/Api.tsx @@ -125,7 +125,7 @@ async function retrieve (api: ApiPromise, injectedPromise: Promise').toString(), systemChainType, @@ -144,7 +144,9 @@ async function loadOnReady (api: ApiPromise, endpoint: LinkOption | null, inject : settings.prefix; const tokenSymbol = properties.tokenSymbol.unwrapOr([formatBalance.getDefaults().unit, ...DEFAULT_AUX]); const tokenDecimals = properties.tokenDecimals.unwrapOr([DEFAULT_DECIMALS]); - const isEthereum = properties.isEthereum.unwrapOr(ethereumChains.includes(api.runtimeVersion.specName.toString())); + const isEthereum = properties.isEthereum.isSome + ? properties.isEthereum.unwrap().isTrue + : ethereumChains.includes(api.runtimeVersion.specName.toString()); const isDevelopment = (systemChainType.isDevelopment || systemChainType.isLocal || isTestChain(systemChain)); console.log(`chain: ${systemChain} (${systemChainType.toString()}), ${stringify(properties)}`); @@ -152,6 +154,7 @@ async function loadOnReady (api: ApiPromise, endpoint: LinkOption | null, inject // explicitly override the ss58Format as specified statics.registry.setChainProperties( statics.registry.createType('ChainProperties', { + isEthereum, ss58Format, tokenDecimals, tokenSymbol From eb22972e6971b9e2469d4f9f27a0a3bea3d68a39 Mon Sep 17 00:00:00 2001 From: Francisco Gamundi Date: Fri, 1 Sep 2023 05:07:28 +0200 Subject: [PATCH 3/4] Update with latest api changes --- packages/react-api/src/Api.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/react-api/src/Api.tsx b/packages/react-api/src/Api.tsx index 3f6ca934f04c..2b6a90622e97 100644 --- a/packages/react-api/src/Api.tsx +++ b/packages/react-api/src/Api.tsx @@ -122,7 +122,7 @@ async function retrieve (api: ApiPromise, injectedPromise: Promise Date: Fri, 1 Sep 2023 05:32:05 +0200 Subject: [PATCH 4/4] Lint --- packages/react-api/src/Api.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/react-api/src/Api.tsx b/packages/react-api/src/Api.tsx index 2b6a90622e97..31f0ff260d05 100644 --- a/packages/react-api/src/Api.tsx +++ b/packages/react-api/src/Api.tsx @@ -106,14 +106,13 @@ function makeCreateLink (baseApiUrl: string, isElectron: boolean): (path: string } async function retrieve (api: ApiPromise, injectedPromise: Promise): Promise { - const [systemChain, systemChainType, systemName, systemVersion, properties, injectedAccounts] = await Promise.all([ + const [systemChain, systemChainType, systemName, systemVersion, injectedAccounts] = await Promise.all([ api.rpc.system.chain(), api.rpc.system.chainType ? api.rpc.system.chainType() : Promise.resolve(statics.registry.createType('ChainType', 'Live')), api.rpc.system.name(), api.rpc.system.version(), - api.rpc.system.properties(), getInjectedAccounts(injectedPromise) ]);