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

devop: new networks #603

Merged
merged 16 commits into from
Jan 29, 2025
Merged
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Enkrypt is a web3 wallet built from the ground up to support the multi-chain fut
- Shiden
- Shiden EVM
- Sepolia
- Syscoin
- Syscoin NEVM
- Telos EVM
- Unique
- Vara Network
Expand All @@ -108,6 +108,7 @@ Enkrypt is a web3 wallet built from the ground up to support the multi-chain fut
- ZChains
- zkSync
- zkSync Goerli
- 5ireChain
- More coming soon!

Looking to add your project? [Contact us!](https://mewwallet.typeform.com/enkrypt-inquiry?typeform-source=www.enkrypt.com)
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@enkryptcom/extension",
"version": "2.1.0",
"version": "2.2.0",
"private": true,
"type": "module",
"scripts": {
Expand Down
7 changes: 6 additions & 1 deletion packages/extension/src/providers/common/libs/new-features.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { NetworkNames } from '@enkryptcom/types';

const newNetworks = [NetworkNames.Bitrock, NetworkNames.Fraxtal];
const newNetworks = [
NetworkNames.Form,
NetworkNames.Rollux,
NetworkNames.SyscoinNEVM,
NetworkNames.Fire,
];
kvhnuke marked this conversation as resolved.
Show resolved Hide resolved
const newSwaps: NetworkNames[] = [];

export { newNetworks, newSwaps };
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ const NetworkEndpoints: Record<string, string> = {
[NetworkNames.Base]: 'https://api.basescan.org/',
[NetworkNames.Celo]: 'https://explorer.celo.org/mainnet/',
[NetworkNames.FormTestnet]: 'https://testnet-explorer.form.network/',
[NetworkNames.Form]: 'https://explorer.form.network/',
[NetworkNames.ArtheraTest]: 'https://explorer-test.arthera.net/',
[NetworkNames.Arthera]: 'https://explorer.arthera.net/',
[NetworkNames.SyscoinTest]: 'https://tanenbaum.io/',
[NetworkNames.Syscoin]: 'https://explorer.syscoin.org/',
[NetworkNames.SyscoinNEVMTest]: 'https://explorer.tanenbaum.io/',
[NetworkNames.SyscoinNEVM]: 'https://explorer.syscoin.org/',
[NetworkNames.RolluxTest]: 'https://rollux.tanenbaum.io/',
[NetworkNames.Rollux]: 'https://explorer.rollux.com/',
[NetworkNames.Blast]: 'https://api.blastscan.io/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { EvmNetwork } from '../../types/evm-network';
import { getKnownNetworkTokens } from './token-lists';
import { CoingeckoPlatform, NetworkNames } from '@enkryptcom/types';
import { NATIVE_TOKEN_ADDRESS } from '../common';
import getBlockscoutBalances from './blockscout';
import getTomoBalances from './tomochain';
import getSolBalances from './solanachain';
import { CoinGeckoTokenMarket } from '@/libs/market-data/types';
Expand Down Expand Up @@ -120,9 +121,13 @@ const supportedNetworks: Record<SupportedNetworkNames, SupportedNetwork> = {
tbName: 'shib',
cgPlatform: CoingeckoPlatform.Shibarium,
},
[NetworkNames.SyscoinNEVM]: {
cgPlatform: CoingeckoPlatform.Syscoin,
bsEndpoint: true,
},
[NetworkNames.Rollux]: {
tbName: 'rollux',
cgPlatform: CoingeckoPlatform.Rollux,
bsEndpoint: true,
},
[NetworkNames.Telos]: {
tbName: 'tlos',
Expand Down Expand Up @@ -191,6 +196,8 @@ const getTokens = (
return getTomoBalances(chain, address);
} else if (chain === NetworkNames.Solana) {
return getSolBalances(network, address);
} else if (supportedNetworks[chain].bsEndpoint) {
return getBlockscoutBalances(chain, address);
}
let url = '';
if (chain === NetworkNames.Ethereum || chain === NetworkNames.Binance)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { SupportedNetworkNames, TokenBalance } from './types/tokenbalance-mew';
import { NetworkEndpoints } from '@/providers/ethereum/libs/activity-handlers/providers/etherscan/configs';
import { NATIVE_TOKEN_ADDRESS } from '../common';
import { numberToHex } from 'web3-utils';

interface TokenBalanceType {
token: string;
quantity: string;
error?: unknown;
}

interface TokenResponseItem {
token: {
address: string;
decimals: string;
name: string;
symbol: string;
};
value: string;
}

interface TokenResponse {
items: TokenResponseItem[];
}

const getBlockscoutBalances = (
chain: SupportedNetworkNames,
address: string,
): Promise<TokenBalance[]> => {
const encodedAddress = encodeURIComponent(address);
const nativeTokenUrl = `${NetworkEndpoints[chain]}api/v2/addresses/${encodedAddress}`;
const tokenBalancesUrl = `${NetworkEndpoints[chain]}api/v2/addresses/${encodedAddress}/tokens?type=ERC-20`;
kvhnuke marked this conversation as resolved.
Show resolved Hide resolved

return Promise.all([
fetch(nativeTokenUrl).then(res => res.json()),
fetch(tokenBalancesUrl).then(res => res.json()),
])
.then(([nativeResponse, tokenResponse]: [any, TokenResponse]) => {
if (!nativeResponse?.coin_balance || !tokenResponse?.items) {
return Promise.reject('Error fetching balance data');
}

if (Number.isNaN(Number(nativeResponse.coin_balance))) {
return Promise.reject('Invalid native token balance');
}

// Map native token balance
const nativeBalance: TokenBalanceType = {
token: NATIVE_TOKEN_ADDRESS,
quantity: nativeResponse.coin_balance,
};

// Map token balances
const tokenBalances: TokenBalanceType[] = Array.isArray(
tokenResponse?.items,
)
? tokenResponse.items
.filter(
item =>
item?.token?.address &&
typeof item.token.address === 'string' &&
item.value !== undefined,
)
.map(item => ({
token: item.token.address.toLowerCase(),
quantity: item.value,
}))
: [];

// Merge native token and token balances
const allBalances = [nativeBalance, ...tokenBalances];

// Convert to TokenBalance format
return allBalances.map(tb => ({
contract: tb.token,
balance: numberToHex(tb.quantity), // Convert to hex format
}));
})
.catch(error => {
console.error('Error fetching balances:', error);
return [
{
contract: NATIVE_TOKEN_ADDRESS,
balance: '0x0',
},
];
});
};

export default getBlockscoutBalances;
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { CoingeckoPlatform, NetworkNames } from '@enkryptcom/types';
import { CGToken, SupportedNetworkNames } from './types/tokenbalance-mew';
const TOKEN_FETCH_TTL = 1000 * 60 * 60;
const TokenList: Record<SupportedNetworkNames, string> = {
[NetworkNames.SyscoinNEVM]: `https://tokens.coingecko.com/${CoingeckoPlatform.Syscoin}/all.json`,
[NetworkNames.Rollux]: `https://tokens.coingecko.com/${CoingeckoPlatform.Rollux}/all.json`,
Comment on lines +6 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove duplicate Rollux entry.

The Rollux network has two entries in the TokenList:

  1. Line 7: [NetworkNames.Rollux]
  2. Line 27: [NetworkNames.Rollux]

Please remove one of the duplicate entries.

[NetworkNames.Binance]: `https://tokens.coingecko.com/${CoingeckoPlatform.Binance}/all.json`,
[NetworkNames.Ethereum]: `https://tokens.coingecko.com/${CoingeckoPlatform.Ethereum}/all.json`,
[NetworkNames.Matic]: `https://tokens.coingecko.com/${CoingeckoPlatform.Matic}/all.json`,
Expand All @@ -26,7 +28,6 @@ const TokenList: Record<SupportedNetworkNames, string> = {
[NetworkNames.Celo]: `https://tokens.coingecko.com/${CoingeckoPlatform.Celo}/all.json`,
[NetworkNames.TomoChain]: `https://tokens.coingecko.com/${CoingeckoPlatform.TomoChain}/all.json`,
[NetworkNames.Shibarium]: `https://tokens.coingecko.com/${CoingeckoPlatform.Shibarium}/all.json`,
[NetworkNames.Rollux]: `https://tokens.coingecko.com/${CoingeckoPlatform.Rollux}/all.json`,
[NetworkNames.Telos]: `https://tokens.coingecko.com/${CoingeckoPlatform.Telos}/all.json`,
[NetworkNames.Blast]: `https://tokens.coingecko.com/${CoingeckoPlatform.Blast}/all.json`,
[NetworkNames.Sanko]: `https://tokens.coingecko.com/${CoingeckoPlatform.Sanko}/all.json`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ export interface TokenBalance {
balance: string;
}
export interface SupportedNetwork {
tbName: string;
tbName?: string;
cgPlatform?: string;
bsEndpoint?: boolean;
}
export interface CGToken {
chainId: `0x${string}`;
Expand Down Expand Up @@ -50,6 +51,7 @@ export type SupportedNetworkNames =
| NetworkNames.Celo
| NetworkNames.ZkSync
| NetworkNames.Telos
| NetworkNames.SyscoinNEVM
| NetworkNames.Rollux
| NetworkNames.Sanko
| NetworkNames.Degen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ class Transaction {
const { isFeeMarketNetwork, feeHistory } = await this.web3
.getFeeHistory(6, 'latest', GAS_PERCENTILES)
.then(history => ({
isFeeMarketNetwork: !!latestBlock.baseFeePerGas,
isFeeMarketNetwork:
!!latestBlock.baseFeePerGas && history.baseFeePerGas.length !== 0,
feeHistory: history,
}))
.catch(() => ({
Expand Down
24 changes: 24 additions & 0 deletions packages/extension/src/providers/ethereum/networks/5ire.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import icon from './icons/5ire.svg';
import wrapActivityHandler from '@/libs/activity-state/wrap-activity-handler';
import { NetworkNames } from '@enkryptcom/types';
import { EvmNetwork, EvmNetworkOptions } from '../types/evm-network';

const fireOptions: EvmNetworkOptions = {
name: NetworkNames.Fire,
name_long: '5ire Chain',
homePage: 'https://www.5ire.org',
blockExplorerTX: 'https://5irescan.io/tx/[[txHash]]',
blockExplorerAddr: 'https://5irescan.io/address/[[address]]',
chainID: '0x3e3',
isTestNetwork: false,
currencyName: '5IRE',
currencyNameLong: '5ire',
node: 'https://rpc.5ire.network',
icon,
coingeckoID: '5ire',
activityHandler: wrapActivityHandler(() => Promise.resolve([])),
};

const fire = new EvmNetwork(fireOptions);

export default fire;
1 change: 0 additions & 1 deletion packages/extension/src/providers/ethereum/networks/bsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import icon from './icons/bsc.svg';
import { CoingeckoPlatform, NetworkNames } from '@enkryptcom/types';
import { EvmNetwork, EvmNetworkOptions } from '../types/evm-network';
import assetsInfoHandler from '@/providers/ethereum/libs/assets-handlers/assetinfo-mew';
import { EtherscanActivity } from '../libs/activity-handlers';
import wrapActivityHandler from '@/libs/activity-state/wrap-activity-handler';
import shNFTHandler from '@/libs/nft-handlers/simplehash';

Expand Down
24 changes: 24 additions & 0 deletions packages/extension/src/providers/ethereum/networks/form.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import icon from './icons/form.png';
import { NetworkNames } from '@enkryptcom/types';
import { EvmNetwork, EvmNetworkOptions } from '../types/evm-network';
import wrapActivityHandler from '@/libs/activity-state/wrap-activity-handler';
import { EtherscanActivity } from '../libs/activity-handlers';

const formOptions: EvmNetworkOptions = {
name: NetworkNames.Form,
name_long: 'Form Mainnet',
homePage: 'https://docs.form.network',
blockExplorerTX: 'https://explorer.form.network/tx/[[txHash]]',
blockExplorerAddr: 'https://explorer.form.network/address/[[address]]',
chainID: '0x1de',
isTestNetwork: false,
currencyName: 'ETH',
currencyNameLong: 'Ethereum',
node: 'wss://rpc.form.network/ws',
icon,
activityHandler: wrapActivityHandler(EtherscanActivity),
};

const form = new EvmNetwork(formOptions);

export default form;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 10 additions & 6 deletions packages/extension/src/providers/ethereum/networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ import celoNode from './celo';
import shibNode from './shib';
import artheraNode from './aa';
import formTestnet from './form-testnet';
import formNode from './form';
import artheraTestNode from './aat';
import syscoinTestNode from './tsys';
import syscoinNode from './sys';
import rolluxTestNode from './trlx';
import rolluxNode from './rlx';
import syscoinNEVMTestNode from './syscoin/nevm-testnet';
import syscoinNEVMNode from './syscoin/nevm';
import rolluxTestNode from './syscoin/rollux-testnet';
import rolluxNode from './syscoin/rollux';
import cagaAnkara from './cagaAnkara';
import telosNode from './tlos';
import blastNode from './blast';
Expand All @@ -61,6 +62,7 @@ import cotiDevnetNode from './coti-devnet';
import holeskyNode from './holesky';
import bitrockNode from './bitrock';
import fraxtalNode from './fraxtal';
import _5ireNode from './5ire';

export default {
sepolia: sepoliaNode,
Expand Down Expand Up @@ -107,9 +109,10 @@ export default {
shib: shibNode,
arthera: artheraNode,
formTestnet: formTestnet,
form: formNode,
artheraTest: artheraTestNode,
syscoinTest: syscoinTestNode,
syscoin: syscoinNode,
syscoinNEVMTest: syscoinNEVMTestNode,
syscoinNEVM: syscoinNEVMNode,
rolluxTest: rolluxTestNode,
rollux: rolluxNode,
cagaAnkara: cagaAnkara,
Expand All @@ -135,4 +138,5 @@ export default {
holesky: holeskyNode,
bitrock: bitrockNode,
frax: fraxtalNode,
'5ire': _5ireNode,
};
26 changes: 0 additions & 26 deletions packages/extension/src/providers/ethereum/networks/sys.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import icon from '../icons/tsys_nevm.svg';
import { NetworkNames } from '@enkryptcom/types';
import { EvmNetwork, EvmNetworkOptions } from '../../types/evm-network';
import { EtherscanActivity } from '../../libs/activity-handlers';
import wrapActivityHandler from '@/libs/activity-state/wrap-activity-handler';

const syscoinNEVMTestOptions: EvmNetworkOptions = {
name: NetworkNames.SyscoinNEVMTest,
name_long: 'Syscoin NEVM Testnet',
homePage: 'https://www.syscoin.org/',
blockExplorerTX: 'https://explorer.tanenbaum.io/tx/[[txHash]]',
blockExplorerAddr: 'https://explorer.tanenbaum.io/address/[[address]]',
chainID: '0x1644',
isTestNetwork: true,
currencyName: 'TSYS',
currencyNameLong: 'Test Syscoin',
node: 'wss://rpc.tanenbaum.io/wss',
icon,
buyLink: 'https://faucet.syscoin.org',
activityHandler: wrapActivityHandler(EtherscanActivity),
};

const syscoinNEVMTest = new EvmNetwork(syscoinNEVMTestOptions);

export default syscoinNEVMTest;
Loading
Loading