From a151a7e1a1f9671cd25b8c0bbbaf305c37406d89 Mon Sep 17 00:00:00 2001 From: Nicole O'Brien Date: Fri, 23 Feb 2024 10:57:12 +0000 Subject: [PATCH 1/8] temp: initial work --- .../views/ConnectedChainsDrawer.svelte | 2 + .../account-summary/AccountSummaryPane.svelte | 10 +-- .../components/AccountEvmChainSummary.svelte | 13 ++-- .../default-chain-configurations.constant.ts | 66 ++++++++++++------- .../constants/default-coin-type.constant.ts | 1 + .../core/network/enums/evm-chain-id.enum.ts | 1 + .../enums/supported-network-id.enum.ts | 1 + ...ildPersistedNetworkFromNodeInfoResponse.ts | 3 +- .../utils/getDefaultPersistedNetwork.ts | 3 +- 9 files changed, 60 insertions(+), 40 deletions(-) diff --git a/packages/desktop/views/dashboard/drawers/network-config/views/ConnectedChainsDrawer.svelte b/packages/desktop/views/dashboard/drawers/network-config/views/ConnectedChainsDrawer.svelte index 193ac500e5..992f2499c6 100644 --- a/packages/desktop/views/dashboard/drawers/network-config/views/ConnectedChainsDrawer.svelte +++ b/packages/desktop/views/dashboard/drawers/network-config/views/ConnectedChainsDrawer.svelte @@ -11,6 +11,8 @@ export let drawerRouter: Router + $: console.log($network.getChains()) + function onL1NetworkCardClick(): void { $networkConfigRouter.goTo(NetworkConfigRoute.NetworkSettings) } diff --git a/packages/desktop/views/dashboard/wallet/panes/account-summary/AccountSummaryPane.svelte b/packages/desktop/views/dashboard/wallet/panes/account-summary/AccountSummaryPane.svelte index 4359fa79fe..bc02cd0705 100644 --- a/packages/desktop/views/dashboard/wallet/panes/account-summary/AccountSummaryPane.svelte +++ b/packages/desktop/views/dashboard/wallet/panes/account-summary/AccountSummaryPane.svelte @@ -7,12 +7,12 @@ export let account: IAccountState const stardustNetworkId = getActiveNetworkId() - const evmChainNetworkId = $network.getChains()[0]?.getConfiguration()?.id + const chains = $network.getChains() - import { getNetwork, NetworkHealth, NetworkId } from '@core/network' import { getAddressFromAccountForNetwork, IAccountState } from '@core/account' - import { formatTokenAmountBestMatch, ITokenWithBalance } from '@core/token' import { formatCurrency } from '@core/i18n' import { getFiatValueFromTokenAmount } from '@core/market/actions' + import { IChain, NetworkHealth, NetworkId } from '@core/network' + import { ownedNfts, selectedAccountNfts } from '@core/nfts/stores' + import { formatTokenAmountBestMatch, ITokenWithBalance } from '@core/token' import { selectedAccountTokens } from '@core/token/stores' - import AccountNetworkSummary from './AccountNetworkSummary.svelte' import type { IAccountNetworkSummaryProps } from '../interfaces' - import { ownedNfts, selectedAccountNfts } from '@core/nfts/stores' + import AccountNetworkSummary from './AccountNetworkSummary.svelte' export let account: IAccountState - export let networkId: NetworkId + export let chain: IChain + + $: networkId = chain?.getConfiguration()?.id as NetworkId let props: IAccountNetworkSummaryProps | undefined $: $selectedAccountTokens, $selectedAccountNfts, account, (props = buildAccountEvmChainSummaryProps()) function buildAccountEvmChainSummaryProps(): IAccountNetworkSummaryProps | undefined { - const chain = getNetwork()?.getChain(networkId) const tokens = $selectedAccountTokens?.[networkId] const evmChainBaseToken: ITokenWithBalance = tokens?.baseCoin const tokenBalance = formatTokenAmountBestMatch( diff --git a/packages/shared/src/lib/core/network/constants/default-chain-configurations.constant.ts b/packages/shared/src/lib/core/network/constants/default-chain-configurations.constant.ts index 5193fce118..66448c66b3 100644 --- a/packages/shared/src/lib/core/network/constants/default-chain-configurations.constant.ts +++ b/packages/shared/src/lib/core/network/constants/default-chain-configurations.constant.ts @@ -2,29 +2,45 @@ import { DEFAULT_COIN_TYPE } from '../constants' import { ChainType, EvmChainId, NetworkNamespace, StardustNetworkId, SupportedNetworkId } from '../enums' import { ChainConfiguration } from '../types' -export const DEFAULT_CHAIN_CONFIGURATIONS: Readonly<{ [id in StardustNetworkId]?: ChainConfiguration }> = { - [SupportedNetworkId.Shimmer]: { - id: SupportedNetworkId.ShimmerEvm, - type: ChainType.Iscp, - name: 'Shimmer EVM', - chainId: EvmChainId.ShimmerEvm, - namespace: NetworkNamespace.Evm, - coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.ShimmerEvm], - aliasAddress: 'smr1prxvwqvwf7nru5q5xvh5thwg54zsm2y4wfnk6yk56hj3exxkg92mx20wl3s', - rpcEndpoint: 'https://json-rpc.evm.shimmer.network/', - apiEndpoint: 'https://api.evm.shimmer.network/', - explorerUrl: 'https://explorer.evm.shimmer.network/', - }, - [SupportedNetworkId.Testnet]: { - id: SupportedNetworkId.TestnetEvm, - type: ChainType.Iscp, - name: 'Testnet EVM', - chainId: EvmChainId.TestnetEvm, - namespace: NetworkNamespace.Evm, - coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.TestnetEvm], - aliasAddress: 'rms1ppp00k5mmd2m8my8ukkp58nd3rskw6rx8l09aj35984k74uuc5u2cywn3ex', - rpcEndpoint: 'https://json-rpc.evm.testnet.shimmer.network/', - apiEndpoint: 'https://api.evm.testnet.shimmer.network/', - explorerUrl: 'https://explorer.evm.testnet.shimmer.network/', - }, +export const DEFAULT_CHAIN_CONFIGURATIONS: Readonly<{ [id in StardustNetworkId]?: ChainConfiguration[] }> = { + [SupportedNetworkId.Shimmer]: [ + { + id: SupportedNetworkId.ShimmerEvm, + type: ChainType.Iscp, + name: 'Shimmer EVM', + chainId: EvmChainId.ShimmerEvm, + namespace: NetworkNamespace.Evm, + coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.ShimmerEvm], + aliasAddress: 'smr1prxvwqvwf7nru5q5xvh5thwg54zsm2y4wfnk6yk56hj3exxkg92mx20wl3s', + rpcEndpoint: 'https://json-rpc.evm.shimmer.network/', + apiEndpoint: 'https://api.evm.shimmer.network/', + explorerUrl: 'https://explorer.evm.shimmer.network/', + }, + ], + [SupportedNetworkId.Testnet]: [ + { + id: SupportedNetworkId.TestnetEvm, + type: ChainType.Iscp, + name: 'Testnet EVM', + chainId: EvmChainId.TestnetEvm, + namespace: NetworkNamespace.Evm, + coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.TestnetEvm], + aliasAddress: 'rms1ppp00k5mmd2m8my8ukkp58nd3rskw6rx8l09aj35984k74uuc5u2cywn3ex', + rpcEndpoint: 'https://json-rpc.evm.testnet.shimmer.network/', + apiEndpoint: 'https://api.evm.testnet.shimmer.network/', + explorerUrl: 'https://explorer.evm.testnet.shimmer.network/', + }, + { + id: SupportedNetworkId.TestnetKycEvm, + type: ChainType.Iscp, + name: 'Testnet KYC EVM', + chainId: EvmChainId.TestnetKycEvm, + namespace: NetworkNamespace.Evm, + coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.TestnetKycEvm], + aliasAddress: 'rms1pzhlaz2aalpsktkqacayyl2xr6s3rsa5h69lmc7mleq4wnaryejkgnprd6k', + rpcEndpoint: 'https://fpgaonkrwz.dune.spyce5.com/wasp/api/', + apiEndpoint: 'https://fpgaonkrwz.dune.spyce5.com/wasp/api/', + explorerUrl: undefined, + }, + ], } diff --git a/packages/shared/src/lib/core/network/constants/default-coin-type.constant.ts b/packages/shared/src/lib/core/network/constants/default-coin-type.constant.ts index 006d9ff222..84e143afca 100644 --- a/packages/shared/src/lib/core/network/constants/default-coin-type.constant.ts +++ b/packages/shared/src/lib/core/network/constants/default-coin-type.constant.ts @@ -11,4 +11,5 @@ export const DEFAULT_COIN_TYPE: Readonly<{ [id in SupportedNetworkId]: number }> [SupportedNetworkId.Testnet]: TEST_COIN_TYPE, [SupportedNetworkId.ShimmerEvm]: ETHEREUM_COIN_TYPE, [SupportedNetworkId.TestnetEvm]: ETHEREUM_COIN_TYPE, + [SupportedNetworkId.TestnetKycEvm]: ETHEREUM_COIN_TYPE, } diff --git a/packages/shared/src/lib/core/network/enums/evm-chain-id.enum.ts b/packages/shared/src/lib/core/network/enums/evm-chain-id.enum.ts index f08d509b71..16fd1e6cce 100644 --- a/packages/shared/src/lib/core/network/enums/evm-chain-id.enum.ts +++ b/packages/shared/src/lib/core/network/enums/evm-chain-id.enum.ts @@ -1,4 +1,5 @@ export enum EvmChainId { ShimmerEvm = '148', TestnetEvm = '1073', + TestnetKycEvm = '1074', } diff --git a/packages/shared/src/lib/core/network/enums/supported-network-id.enum.ts b/packages/shared/src/lib/core/network/enums/supported-network-id.enum.ts index 3bb8372fa1..35c06109ff 100644 --- a/packages/shared/src/lib/core/network/enums/supported-network-id.enum.ts +++ b/packages/shared/src/lib/core/network/enums/supported-network-id.enum.ts @@ -11,6 +11,7 @@ export enum StardustNetworkId { export enum EvmNetworkId { ShimmerEvm = `${NetworkNamespace.Evm}:${EvmChainId.ShimmerEvm}`, TestnetEvm = `${NetworkNamespace.Evm}:${EvmChainId.TestnetEvm}`, + TestnetKycEvm = `${NetworkNamespace.Evm}:${EvmChainId.TestnetKycEvm}`, } export const SupportedNetworkId = { ...StardustNetworkId, ...EvmNetworkId } diff --git a/packages/shared/src/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts b/packages/shared/src/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts index a070a817b6..258ec0c951 100644 --- a/packages/shared/src/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts +++ b/packages/shared/src/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts @@ -15,8 +15,7 @@ export function buildPersistedNetworkFromNodeInfoResponse( const name = DEFAULT_NETWORK_METADATA[id]?.name ?? networkName ?? localize('general.unknown') const _coinType = coinType ?? DEFAULT_COIN_TYPE[id] ?? TEST_COIN_TYPE - const configuration = DEFAULT_CHAIN_CONFIGURATIONS?.[id] - const chainConfigurations = configuration ? [configuration] : [] + const chainConfigurations = DEFAULT_CHAIN_CONFIGURATIONS?.[id] ?? [] return { id, name, diff --git a/packages/shared/src/lib/core/network/utils/getDefaultPersistedNetwork.ts b/packages/shared/src/lib/core/network/utils/getDefaultPersistedNetwork.ts index f6a5462ce3..5176e14e74 100644 --- a/packages/shared/src/lib/core/network/utils/getDefaultPersistedNetwork.ts +++ b/packages/shared/src/lib/core/network/utils/getDefaultPersistedNetwork.ts @@ -4,8 +4,7 @@ import { IPersistedNetwork } from '../interfaces' export function getDefaultPersistedNetwork(networkId: NetworkId): IPersistedNetwork { const network = structuredClone(DEFAULT_NETWORK_METADATA?.[networkId]) - const configuration = structuredClone(DEFAULT_CHAIN_CONFIGURATIONS?.[networkId]) - const chainConfigurations = configuration ? [configuration] : [] + const chainConfigurations = structuredClone(DEFAULT_CHAIN_CONFIGURATIONS?.[networkId]) ?? [] if (network) { return { ...network, From a4fed7346d40f40991d4ec45ad0c07ec23d96d3d Mon Sep 17 00:00:00 2001 From: Nicole O'Brien Date: Fri, 23 Feb 2024 12:46:01 +0000 Subject: [PATCH 2/8] Update test app chain config Co-authored-by: Tuditi --- .../network-config/views/ConnectedChainsDrawer.svelte | 2 -- .../constants/default-chain-configurations.constant.ts | 6 +++--- .../shared/src/lib/core/network/enums/evm-chain-id.enum.ts | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/desktop/views/dashboard/drawers/network-config/views/ConnectedChainsDrawer.svelte b/packages/desktop/views/dashboard/drawers/network-config/views/ConnectedChainsDrawer.svelte index 992f2499c6..193ac500e5 100644 --- a/packages/desktop/views/dashboard/drawers/network-config/views/ConnectedChainsDrawer.svelte +++ b/packages/desktop/views/dashboard/drawers/network-config/views/ConnectedChainsDrawer.svelte @@ -11,8 +11,6 @@ export let drawerRouter: Router - $: console.log($network.getChains()) - function onL1NetworkCardClick(): void { $networkConfigRouter.goTo(NetworkConfigRoute.NetworkSettings) } diff --git a/packages/shared/src/lib/core/network/constants/default-chain-configurations.constant.ts b/packages/shared/src/lib/core/network/constants/default-chain-configurations.constant.ts index 66448c66b3..15b6633c4a 100644 --- a/packages/shared/src/lib/core/network/constants/default-chain-configurations.constant.ts +++ b/packages/shared/src/lib/core/network/constants/default-chain-configurations.constant.ts @@ -37,9 +37,9 @@ export const DEFAULT_CHAIN_CONFIGURATIONS: Readonly<{ [id in StardustNetworkId]? chainId: EvmChainId.TestnetKycEvm, namespace: NetworkNamespace.Evm, coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.TestnetKycEvm], - aliasAddress: 'rms1pzhlaz2aalpsktkqacayyl2xr6s3rsa5h69lmc7mleq4wnaryejkgnprd6k', - rpcEndpoint: 'https://fpgaonkrwz.dune.spyce5.com/wasp/api/', - apiEndpoint: 'https://fpgaonkrwz.dune.spyce5.com/wasp/api/', + aliasAddress: 'rms1pqva79scq8k0dz0hdhjvwh0v80pya4z66egruvkssdkxc3fmzy2z60adm9x', + rpcEndpoint: 'https://fervent-lichterman.dune.spyce5.com/wasp/api/', + apiEndpoint: 'https://fervent-lichterman.dune.spyce5.com/wasp/api/', explorerUrl: undefined, }, ], diff --git a/packages/shared/src/lib/core/network/enums/evm-chain-id.enum.ts b/packages/shared/src/lib/core/network/enums/evm-chain-id.enum.ts index 16fd1e6cce..0563323b70 100644 --- a/packages/shared/src/lib/core/network/enums/evm-chain-id.enum.ts +++ b/packages/shared/src/lib/core/network/enums/evm-chain-id.enum.ts @@ -1,5 +1,5 @@ export enum EvmChainId { ShimmerEvm = '148', TestnetEvm = '1073', - TestnetKycEvm = '1074', + TestnetKycEvm = '54432', } From c257f2a1b7360cf626a543bb506840db3d50ccbd Mon Sep 17 00:00:00 2001 From: Nicole O'Brien Date: Fri, 23 Feb 2024 13:00:48 +0000 Subject: [PATCH 3/8] fix: calculate gas price in glow --- .../src/lib/core/layer-2/helpers/calculateGasFeeInGlow.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/shared/src/lib/core/layer-2/helpers/calculateGasFeeInGlow.ts b/packages/shared/src/lib/core/layer-2/helpers/calculateGasFeeInGlow.ts index a4a32e44e9..44c0efefff 100644 --- a/packages/shared/src/lib/core/layer-2/helpers/calculateGasFeeInGlow.ts +++ b/packages/shared/src/lib/core/layer-2/helpers/calculateGasFeeInGlow.ts @@ -4,8 +4,9 @@ import { Converter } from '@core/utils' export function calculateGasFeeInGlow(gasAmount: BigIntLike, gasPriceInWei: BigIntLike | undefined): bigint { if (gasAmount && gasPriceInWei) { - const gasPriceInGlow = BigInt(Number(gasPriceInWei)) / WEI_PER_GLOW - return Converter.bigIntLikeToBigInt(gasAmount) * gasPriceInGlow + const totalPriceInWei = Converter.bigIntLikeToBigInt(gasAmount) * Converter.bigIntLikeToBigInt(gasPriceInWei) + const totalPriceInGlow = totalPriceInWei / WEI_PER_GLOW + return totalPriceInGlow } else { return BigInt(0) } From 3a71c77e711c7e3cb1878fd5e47c9b89e1601856 Mon Sep 17 00:00:00 2001 From: Tuditi Date: Tue, 9 Apr 2024 16:33:20 +0200 Subject: [PATCH 4/8] feat: add chainId --- .../views/components/AddIscpChainForm.svelte | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/desktop/views/dashboard/drawers/network-config/views/components/AddIscpChainForm.svelte b/packages/desktop/views/dashboard/drawers/network-config/views/components/AddIscpChainForm.svelte index bb9c4691d8..b50934b93c 100644 --- a/packages/desktop/views/dashboard/drawers/network-config/views/components/AddIscpChainForm.svelte +++ b/packages/desktop/views/dashboard/drawers/network-config/views/components/AddIscpChainForm.svelte @@ -9,6 +9,7 @@ NetworkId, EvmChainId, NetworkNamespace, + getNetwork, } from '@core/network' import { activeProfile } from '@core/profile/stores' import { getNetworkHrp } from '@core/profile/actions' @@ -23,7 +24,8 @@ let aliasAddressError = '' let rpcEndpointError = '' let explorerUrlError = '' - $: submitDisabled = !chain.name || !chain.aliasAddress || !chain.rpcEndpoint + const chainIdError = '' + $: submitDisabled = !chain.name || !chain.id || !chain.aliasAddress || !chain.rpcEndpoint const chain: IIscpChainConfiguration = { type: ChainType.Iscp, @@ -93,16 +95,24 @@ function onSubmitClick(): void { resetErrors() validate() - const hasError = !!nameError || !!aliasAddressError || !!rpcEndpointError || !!explorerUrlError - if (!hasError) { - // TODO: https://github.com/iotaledger/firefly/issues/6375 + const hasError = + !!nameError || !!aliasAddressError || !!rpcEndpointError || !!chainIdError || !!explorerUrlError + if (hasError) { + return } + getNetwork()?.addChain(chain) }
+ From 8c417f000f099616e1c1e0da42e9d87c03bcef8e Mon Sep 17 00:00:00 2001 From: Tuditi Date: Tue, 9 Apr 2024 17:38:39 +0200 Subject: [PATCH 5/8] ui: rebrand form --- .../views/AddChainDrawer.svelte | 4 +--- .../views/ConnectedChainsDrawer.svelte | 21 ++++++++--------- .../views/components/AddIscpChainForm.svelte | 23 +++++++++---------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/packages/desktop/views/dashboard/drawers/network-config/views/AddChainDrawer.svelte b/packages/desktop/views/dashboard/drawers/network-config/views/AddChainDrawer.svelte index ec557da678..e789b65c34 100644 --- a/packages/desktop/views/dashboard/drawers/network-config/views/AddChainDrawer.svelte +++ b/packages/desktop/views/dashboard/drawers/network-config/views/AddChainDrawer.svelte @@ -9,7 +9,5 @@ - - - + diff --git a/packages/desktop/views/dashboard/drawers/network-config/views/ConnectedChainsDrawer.svelte b/packages/desktop/views/dashboard/drawers/network-config/views/ConnectedChainsDrawer.svelte index 193ac500e5..e8388b2b1d 100644 --- a/packages/desktop/views/dashboard/drawers/network-config/views/ConnectedChainsDrawer.svelte +++ b/packages/desktop/views/dashboard/drawers/network-config/views/ConnectedChainsDrawer.svelte @@ -1,13 +1,12 @@ - - - + + - - - From e6357eee5bf4d6a202a74eecfbb4fd068b408231 Mon Sep 17 00:00:00 2001 From: Tuditi Date: Wed, 10 Apr 2024 11:14:48 +0200 Subject: [PATCH 6/8] chore: cleanup form --- .../views/AddChainDrawer.svelte | 9 +++++- .../views/components/AddIscpChainForm.svelte | 31 ++++++------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/packages/desktop/views/dashboard/drawers/network-config/views/AddChainDrawer.svelte b/packages/desktop/views/dashboard/drawers/network-config/views/AddChainDrawer.svelte index e789b65c34..f9be38eaa6 100644 --- a/packages/desktop/views/dashboard/drawers/network-config/views/AddChainDrawer.svelte +++ b/packages/desktop/views/dashboard/drawers/network-config/views/AddChainDrawer.svelte @@ -4,10 +4,17 @@ import { Router } from '@core/router' import { NetworkConfigRoute } from '../' import { AddIscpChainForm } from './components' + import { Button } from '@bloomwalletio/ui' export let drawerRouter: Router + + let form: AddIscpChainForm + let disabled: boolean - + +
+
diff --git a/packages/desktop/views/dashboard/drawers/network-config/views/components/AddIscpChainForm.svelte b/packages/desktop/views/dashboard/drawers/network-config/views/components/AddIscpChainForm.svelte index a93c0ed5d6..00bef08ece 100644 --- a/packages/desktop/views/dashboard/drawers/network-config/views/components/AddIscpChainForm.svelte +++ b/packages/desktop/views/dashboard/drawers/network-config/views/components/AddIscpChainForm.svelte @@ -14,17 +14,19 @@ import { activeProfile } from '@core/profile/stores' import { getNetworkHrp } from '@core/profile/actions' import { isValidHexAddress, isValidHttpsUrl, validateBech32Address } from '@core/utils' - import { Button, TextInput } from '@bloomwalletio/ui' + import { TextInput } from '@bloomwalletio/ui' + + export let disabled: boolean = false const localeKey = 'views.dashboard.drawers.networkConfig.chain' - const isBusy = false let nameError = '' let aliasAddressError = '' let rpcEndpointError = '' let explorerUrlError = '' const chainIdError = '' - $: submitDisabled = !chain.name || !chain.id || !chain.aliasAddress || !chain.rpcEndpoint + + $: disabled = !chain.name || !chain.id || !chain.aliasAddress || !chain.rpcEndpoint const chain: IIscpChainConfiguration = { type: ChainType.Iscp, @@ -35,6 +37,7 @@ aliasAddress: '', rpcEndpoint: '', apiEndpoint: '', + explorerUrl: '', coinType: ETHEREUM_COIN_TYPE, } @@ -91,7 +94,7 @@ explorerUrlError = '' } - function onSubmitClick(): void { + export function onSubmitClick(): void { resetErrors() validate() const hasError = @@ -105,38 +108,22 @@ - - + + -