Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallet fixes #3

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/config/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const ENDPOINTS = {
ETHEREUM: {
MAIN: 'mainnet',
TEST: 'goerli',
},
ECLIPSE: {
DEV: 'testnet.dev2',
TEST: 'testnet.dev2',
}
};

Expand Down
21 changes: 20 additions & 1 deletion src/config/explorers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,31 @@ const SOLANA_EXPLORERS = {
},
};



const EXPLORERS = {
SOLANA: {
mainnet: SOLANA_EXPLORERS,
'mainnet-beta': SOLANA_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: {
Expand All @@ -38,12 +56,13 @@ const EXPLORERS = {
},
},
},

};

const DEFAULT_EXPLORERS = {
SOLANA: 'SOLSCAN',
ETHEREUM: 'ETHERSCAN',
ECLIPSE: 'EXPLORER',
};

export { EXPLORERS, DEFAULT_EXPLORERS };
3 changes: 2 additions & 1 deletion src/eclipse-wallet-adapter/constants/blockchains.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const SOLANA = 'solana';
const ECLIPSE = 'eclipse';
const ETHEREUM = 'ethereum';

module.exports = { SOLANA, ETHEREUM };
module.exports = { SOLANA, ETHEREUM, ECLIPSE };
2 changes: 1 addition & 1 deletion src/eclipse-wallet-adapter/constants/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 2 additions & 0 deletions src/eclipse-wallet-adapter/constants/token-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -27,5 +28,6 @@ module.exports = {
USDC_ADDRESS,
BTC_LOGO,
ETH_ADDRESS,
ETH_LOGO,
ME_PROGRAM_ID
};
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/eclipse-wallet-adapter/services/network-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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,
};
};
Expand Down
4 changes: 2 additions & 2 deletions src/eclipse-wallet-adapter/services/switch-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const jsonData = {
}
}
},
"solana-testnet": {
"eclipse-testnet": {
"enable": true,
"sections": {
"overview": {
Expand Down Expand Up @@ -171,7 +171,7 @@ const jsonData = {
}
}
},
"solana-devnet": {
"eclipse-devnet": {
"enable": true,
"sections": {
"overview": {
Expand Down
15 changes: 9 additions & 6 deletions src/eclipse-wallet-adapter/services/token-decorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Adapter/AdapterPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Nfts/NftsDetailPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/pages/Wallet/components/NetworkSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const getNetworkIcon = ({ blockchain }) => {
case BLOCKCHAINS.ETHEREUM:
return IconEthereumVector;
case BLOCKCHAINS.SOLANA:
case BLOCKCHAINS.ECLIPSE:
return IconSolanaVector;
default:
return IconSalmon;
Expand Down
2 changes: 1 addition & 1 deletion src/translations/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down