From 47cfbc07d189bd326988324dc8e02eee17dda644 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 20 Dec 2023 10:57:34 -0800 Subject: [PATCH 1/2] additional config for eclipse networks --- src/config/endpoints.js | 4 ++++ src/config/explorers.js | 21 ++++++++++++++++++- .../constants/blockchains.js | 3 ++- .../factories/network-account-factory.js | 4 ++-- .../services/network-service.js | 8 +++---- .../services/switch-service.js | 4 ++-- src/pages/Adapter/AdapterPage.js | 2 +- src/pages/Nfts/NftsDetailPage.js | 2 +- .../Wallet/components/NetworkSelector.js | 1 + src/translations/en/translation.json | 2 +- 10 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/config/endpoints.js b/src/config/endpoints.js index 0a49f45f..d6beff11 100644 --- a/src/config/endpoints.js +++ b/src/config/endpoints.js @@ -7,6 +7,10 @@ const ENDPOINTS = { ETHEREUM: { MAIN: 'mainnet', TEST: 'goerli', + }, + ECLIPSE: { + DEV: 'testnet.dev2', + TEST: 'testnet.dev2', } }; diff --git a/src/config/explorers.js b/src/config/explorers.js index 01f8baaf..da0e0e78 100644 --- a/src/config/explorers.js +++ b/src/config/explorers.js @@ -17,6 +17,8 @@ const SOLANA_EXPLORERS = { }, }; + + const EXPLORERS = { SOLANA: { mainnet: SOLANA_EXPLORERS, @@ -24,6 +26,22 @@ const EXPLORERS = { testnet: SOLANA_EXPLORERS, devnet: SOLANA_EXPLORERS, }, + ECLIPSE: { + testnet: { + EXPLORER: { + name: 'Eclipse Explorer', + url: 'https://explorer.dev.eclipsenetwork.xyz/address/9RPEj9p4Xnd9eqEs6gJcWkU6FqbuRWPxqXmRvpasRein?cluster=testnet' + } + }, + devnet: { + EXPLORER: { + name: 'Eclipse Explorer', + url: 'https://explorer.dev.eclipsenetwork.xyz/address/9RPEj9p4Xnd9eqEs6gJcWkU6FqbuRWPxqXmRvpasRein?cluster=testnet' + } + } + + }, + ETHEREUM: { mainnet: { ETHERSCAN: { @@ -38,12 +56,13 @@ const EXPLORERS = { }, }, }, - + }; const DEFAULT_EXPLORERS = { SOLANA: 'SOLSCAN', ETHEREUM: 'ETHERSCAN', + ECLIPSE: 'EXPLORER', }; export { EXPLORERS, DEFAULT_EXPLORERS }; diff --git a/src/eclipse-wallet-adapter/constants/blockchains.js b/src/eclipse-wallet-adapter/constants/blockchains.js index bac7eb27..7b7f3338 100644 --- a/src/eclipse-wallet-adapter/constants/blockchains.js +++ b/src/eclipse-wallet-adapter/constants/blockchains.js @@ -1,4 +1,5 @@ const SOLANA = 'solana'; +const ECLIPSE = 'eclipse'; const ETHEREUM = 'ethereum'; -module.exports = { SOLANA, ETHEREUM }; +module.exports = { SOLANA, ETHEREUM, ECLIPSE }; diff --git a/src/eclipse-wallet-adapter/factories/network-account-factory.js b/src/eclipse-wallet-adapter/factories/network-account-factory.js index 7d5bd976..755312cd 100644 --- a/src/eclipse-wallet-adapter/factories/network-account-factory.js +++ b/src/eclipse-wallet-adapter/factories/network-account-factory.js @@ -2,13 +2,13 @@ const { create: createEthereum } = require('./ethereum-account-factory'); const { create: createSolana } = require('./solana-account-factory'); -const { ETHEREUM, SOLANA } = require('../constants/blockchains'); +const { ETHEREUM, SOLANA, ECLIPSE } = require('../constants/blockchains'); const create = async ({ network, mnemonic, index = 0 }) => { switch (network.blockchain) { case ETHEREUM: return createEthereum({ network, mnemonic, index }); - case SOLANA: + case SOLANA, ECLIPSE: return createSolana({ network, mnemonic, index }); default: return null; diff --git a/src/eclipse-wallet-adapter/services/network-service.js b/src/eclipse-wallet-adapter/services/network-service.js index 4eb0dde0..7c36714b 100644 --- a/src/eclipse-wallet-adapter/services/network-service.js +++ b/src/eclipse-wallet-adapter/services/network-service.js @@ -2,8 +2,8 @@ let promise; const networkData = [ { - id: 'solana-devnet', - blockchain: 'solana', + id: 'eclipse-devnet', + blockchain: 'eclipse', environment: 'devnet', name: 'Eclipse Devnet', icon: 'https://assets-cdn.trustwallet.com/blockchains/solana/info/logo.png', @@ -16,8 +16,8 @@ const networkData = [ }, }, { - id: 'solana-testnet', - blockchain: 'solana', + id: 'eclipse-testnet', + blockchain: 'eclipse', environment: 'devnet', name: 'Eclipse Testnet', icon: 'https://assets-cdn.trustwallet.com/blockchains/solana/info/logo.png', diff --git a/src/eclipse-wallet-adapter/services/switch-service.js b/src/eclipse-wallet-adapter/services/switch-service.js index 83bd78e9..7ae78ed5 100644 --- a/src/eclipse-wallet-adapter/services/switch-service.js +++ b/src/eclipse-wallet-adapter/services/switch-service.js @@ -129,7 +129,7 @@ const jsonData = { } } }, - "solana-testnet": { + "eclipse-testnet": { "enable": true, "sections": { "overview": { @@ -171,7 +171,7 @@ const jsonData = { } } }, - "solana-devnet": { + "eclipse-devnet": { "enable": true, "sections": { "overview": { diff --git a/src/pages/Adapter/AdapterPage.js b/src/pages/Adapter/AdapterPage.js index e2b39c88..6490e47b 100644 --- a/src/pages/Adapter/AdapterPage.js +++ b/src/pages/Adapter/AdapterPage.js @@ -19,7 +19,7 @@ const AdapterPage = () => { if (loading) { const switches = await getSwitches(); const isEnabled = ({ id }) => switches[id]?.enable; - const isSolana = ({ blockchain }) => blockchain === BLOCKCHAINS.SOLANA; + const isSolana = ({ blockchain }) => [BLOCKCHAINS.SOLANA, BLOCKCHAINS.ECLIPSE].includes(blockchain); const solanaNetworks = (await getNetworks()) .filter(isSolana) .filter(isEnabled); diff --git a/src/pages/Nfts/NftsDetailPage.js b/src/pages/Nfts/NftsDetailPage.js index b3f38074..1d142f75 100644 --- a/src/pages/Nfts/NftsDetailPage.js +++ b/src/pages/Nfts/NftsDetailPage.js @@ -81,7 +81,7 @@ const NftsDetailPage = ({ params, t }) => { if (nft) { setNftDetail(nft); } - if (activeBlockchainAccount.network.blockchain === BLOCKCHAINS.SOLANA) { + if ([BLOCKCHAINS.SOLANA, BLOCKCHAINS.ECLIPSE].includes(activeBlockchainAccount.network.blockchain)) { const listed = await activeBlockchainAccount.getListedNfts(); setListedInfo(listed.find(l => l.token_address === params.id)); setListedLoaded(true); diff --git a/src/pages/Wallet/components/NetworkSelector.js b/src/pages/Wallet/components/NetworkSelector.js index 2ddd6ce8..3671b5b9 100644 --- a/src/pages/Wallet/components/NetworkSelector.js +++ b/src/pages/Wallet/components/NetworkSelector.js @@ -40,6 +40,7 @@ const getNetworkIcon = ({ blockchain }) => { case BLOCKCHAINS.ETHEREUM: return IconEthereumVector; case BLOCKCHAINS.SOLANA: + case BLOCKCHAINS.ECLIPSE: return IconSolanaVector; default: return IconSalmon; diff --git a/src/translations/en/translation.json b/src/translations/en/translation.json index 811a77c2..165917a1 100644 --- a/src/translations/en/translation.json +++ b/src/translations/en/translation.json @@ -6,7 +6,7 @@ "address": "Address", "to": "To", "name_or_address": "Name or \"{{token}}\" Address", - "recipient_s_address": "RecipientĀ“s \"{{token}}\" Address", + "recipient_s_address": "Recipient's \"{{token}}\" Address", "seed_phrase": "Seed Phrase", "private_key": "Private Key", "balance": "Balance", From 7f64ba8e10aa73f69c4646fd51d402644eeb3a26 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 3 Jan 2024 08:41:10 -0800 Subject: [PATCH 2/2] make wallet compatible with new server --- .../constants/environment.js | 2 +- .../constants/token-constants.js | 2 ++ .../services/solana/solana-balance-service.js | 4 ++-- .../services/token-decorator.js | 15 +++++++++------ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/eclipse-wallet-adapter/constants/environment.js b/src/eclipse-wallet-adapter/constants/environment.js index daabc12b..6ed56b8e 100644 --- a/src/eclipse-wallet-adapter/constants/environment.js +++ b/src/eclipse-wallet-adapter/constants/environment.js @@ -11,7 +11,7 @@ switch (salmonEnv) { break; case 'test': case 'local': - apiUrl = 'http://localhost:3000/local'; + apiUrl = 'http://localhost:8083'; break; case 'main': apiUrl = 'https://bo0q5g7ie1.execute-api.us-east-1.amazonaws.com/main'; diff --git a/src/eclipse-wallet-adapter/constants/token-constants.js b/src/eclipse-wallet-adapter/constants/token-constants.js index ebe97604..542d3a15 100644 --- a/src/eclipse-wallet-adapter/constants/token-constants.js +++ b/src/eclipse-wallet-adapter/constants/token-constants.js @@ -4,6 +4,7 @@ const SOL_DECIMALS = 6; const SOL_SYMBOL = 'ETH'; const SOL_NAME = 'Eclipse'; const SOL_LOGO = 'https://i.imgur.com/y0JEPfQ.png'; +const ETH_LOGO = 'https://assets-cdn.trustwallet.com/blockchains/ethereum/info/logo.png' const SOL_ADDRESS = 'So11111111111111111111111111111111111111112'; const USDC_ADDRESS = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'; @@ -27,5 +28,6 @@ module.exports = { USDC_ADDRESS, BTC_LOGO, ETH_ADDRESS, + ETH_LOGO, ME_PROGRAM_ID }; diff --git a/src/eclipse-wallet-adapter/services/solana/solana-balance-service.js b/src/eclipse-wallet-adapter/services/solana/solana-balance-service.js index 9f7becd3..a16c334d 100644 --- a/src/eclipse-wallet-adapter/services/solana/solana-balance-service.js +++ b/src/eclipse-wallet-adapter/services/solana/solana-balance-service.js @@ -5,7 +5,7 @@ const { SOL_DECIMALS, SOL_SYMBOL, SOL_NAME, - SOL_LOGO, + ETH_LOGO, SOL_ADDRESS, } = require('../../constants/token-constants'); const { getLast24HoursChange } = require('../common-balance-service'); @@ -23,7 +23,7 @@ const getSolanaBalance = async (connection, publicKey) => { uiAmount: uiAmount, symbol: SOL_SYMBOL, name: SOL_NAME, - logo: SOL_LOGO, + logo: ETH_LOGO, address: SOL_ADDRESS, }; }; diff --git a/src/eclipse-wallet-adapter/services/token-decorator.js b/src/eclipse-wallet-adapter/services/token-decorator.js index ab396eef..0c54f603 100644 --- a/src/eclipse-wallet-adapter/services/token-decorator.js +++ b/src/eclipse-wallet-adapter/services/token-decorator.js @@ -8,16 +8,19 @@ const decorateBalanceList = async (items, tokens) => { }; const decorateBalancePrices = async (items, prices) => { + const prices_a = [prices].flat(); const result = items.map((item) => { const price = item.symbol - ? prices?.find((t) => t.id == item.coingeckoId) || - prices?.find((t) => t.symbol.toUpperCase() == item.symbol.toUpperCase()) + ? prices_a?.find((t) => t.id == item.coingeckoId) || + prices_a?.find((t) => t.symbol.toUpperCase() == item.symbol.toUpperCase()) : null; - const usdBalance = price?.usdPrice ? item.uiAmount * price.usdPrice : null; + + const usd_price = price?.market_data?.current_price?.usd + const usdBalance = usd_price ? item.uiAmount * usd_price : null; const last24HoursChange = getLast24HoursChange(price, usdBalance); return { ...item, - usdPrice: price ? price.usdPrice : null, + usdPrice: price ? usd_price : null, usdBalance, last24HoursChange, }; @@ -26,11 +29,11 @@ const decorateBalancePrices = async (items, prices) => { }; const getLast24HoursChange = (price, usdBalance) => { - if (price?.perc24HoursChange === undefined || price?.perc24HoursChange === null) { + if (price?.price_change_24h === undefined || price?.price_change_24h === null) { return null; } - const perc = price.perc24HoursChange; + const perc = price.price_change_24h; const prevBalance = (1 - perc / 100) * usdBalance; const usd = usdBalance - prevBalance; return {