-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #605 from enkryptcom/develop
Release: v2.2.0
- Loading branch information
Showing
23 changed files
with
263 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
]; | ||
const newSwaps: NetworkNames[] = []; | ||
|
||
export { newNetworks, newSwaps }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
packages/extension/src/providers/ethereum/libs/assets-handlers/blockscout.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`; | ||
|
||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/extension/src/providers/ethereum/networks/5ire.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/extension/src/providers/ethereum/networks/form.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
3 changes: 3 additions & 0 deletions
3
packages/extension/src/providers/ethereum/networks/icons/5ire.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
packages/extension/src/providers/ethereum/networks/syscoin/nevm-testnet.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.