diff --git a/package.json b/package.json index 6651ea34a..253d9e7c6 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "devDependencies": { "@commitlint/cli": "^17.6.6", "@commitlint/config-conventional": "^17.6.6", - "@swc/core": "^1.3.68", + "@swc/core": "^1.3.70", "concurrently": "^7.6.0", "devmoji": "^2.3.0", "husky": "^8.0.3", diff --git a/packages/extension-bridge/package.json b/packages/extension-bridge/package.json index 5ace0eab0..2ec52a0df 100644 --- a/packages/extension-bridge/package.json +++ b/packages/extension-bridge/package.json @@ -47,7 +47,7 @@ "@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/parser": "^5.62.0", "bumpp": "^8.2.1", - "eslint": "^8.44.0", + "eslint": "^8.45.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-prettier": "^8.8.0", "eslint-import-resolver-alias": "^1.1.2", diff --git a/packages/extension/package.json b/packages/extension/package.json index 235f483b7..90bfe915c 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -1,6 +1,6 @@ { "name": "@enkryptcom/extension", - "version": "1.23.0", + "version": "1.24.0", "private": true, "scripts": { "zip": "cd dist; zip -r release.zip *;", @@ -29,7 +29,7 @@ "@enkryptcom/utils": "workspace:^", "@ethereumjs/common": "^3.2.0", "@ethereumjs/tx": "^4.2.0", - "@ledgerhq/hw-transport-webusb": "^6.27.16", + "@ledgerhq/hw-transport-webusb": "^6.27.17", "@metamask/eth-sig-util": "^6.0.0", "@types/chrome": "^0.0.241", "@types/events": "^3.0.0", @@ -45,7 +45,7 @@ "chai": "^4.3.7", "concurrently": "^7.6.0", "core-js": "^3.31.1", - "echarts": "^5.4.2", + "echarts": "^5.4.3", "ethereumjs-abi": "^0.6.8", "ethereumjs-util": "^7.1.5", "ethereumjs-wallet": "^1.0.2", @@ -100,7 +100,7 @@ "buffer": "^6.0.3", "cross-env": "^7.0.3", "crypto-browserify": "^3.12.0", - "eslint": "^8.44.0", + "eslint": "^8.45.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-vue": "^8.7.1", diff --git a/packages/extension/src/libs/dapp-list/index.ts b/packages/extension/src/libs/dapp-list/index.ts index 2cf16c213..ad1dbeb8a 100644 --- a/packages/extension/src/libs/dapp-list/index.ts +++ b/packages/extension/src/libs/dapp-list/index.ts @@ -59,6 +59,12 @@ const lists: Partial> = { "https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/dapps/klay.json", [NetworkNames.Aurora]: "https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/dapps/aurora.json", + [NetworkNames.Base]: + "https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/dapps/base.json", + [NetworkNames.Celo]: + "https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/dapps/celo.json", + [NetworkNames.MaticZK]: + "https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/dapps/matic-zkevm.json", }; export default lists; diff --git a/packages/extension/src/libs/nft-handlers/rarible.ts b/packages/extension/src/libs/nft-handlers/rarible.ts index 6aadcead9..c405dfb37 100644 --- a/packages/extension/src/libs/nft-handlers/rarible.ts +++ b/packages/extension/src/libs/nft-handlers/rarible.ts @@ -45,7 +45,7 @@ const getBestImageURL = (content: NFTContent[]) => { cont.representation === pri && !cont.url.includes("rarible.mypinata.cloud") ) - return cont.url; + return `https://img.mewapi.io/?image=${cont.url}`; } } return ""; diff --git a/packages/extension/src/libs/nft-handlers/simplehash.ts b/packages/extension/src/libs/nft-handlers/simplehash.ts index d20067ccd..0024df628 100644 --- a/packages/extension/src/libs/nft-handlers/simplehash.ts +++ b/packages/extension/src/libs/nft-handlers/simplehash.ts @@ -5,6 +5,11 @@ import { NetworkNames } from "@enkryptcom/types"; import { SHNFTType, SHResponse } from "./types/simplehash"; const SH_ENDPOINT = "https://partners.mewapi.io/nfts/"; const CACHE_TTL = 60 * 1000; +const getExternalURL = (network: NodeType, contract: string, id: string) => { + if (network.name === NetworkNames.Gnosis) + return `https://niftyfair.io/gc/asset/${contract}/${id}/`; + return ""; +}; export default async ( network: NodeType, address: string @@ -15,6 +20,11 @@ export default async ( [NetworkNames.Arbitrum]: "arbitrum", [NetworkNames.Gnosis]: "gnosis", [NetworkNames.Avalanche]: "avalanche", + [NetworkNames.MaticZK]: "polygon-zkevm", + [NetworkNames.ZkSync]: "zksync-era", + [NetworkNames.ZkSyncGoerli]: "zksync-era-testnet", + [NetworkNames.Goerli]: "ethereum-goerli", + [NetworkNames.Base]: "base", }; if (!Object.keys(supportedNetworks).includes(network.name)) throw new Error("Simplehash: network not supported"); @@ -40,14 +50,20 @@ export default async ( if (!allItems || !allItems.length) return []; const collections: Record = {}; allItems.forEach((item) => { - if (!item.image_url || !item.collection.image_url) return; + if ( + (!item.image_url && !item.previews.image_medium_url) || + !item.collection.image_url + ) + return; if (collections[item.contract_address]) { const tItem: NFTItem = { contract: item.contract_address, id: item.token_id, - image: item.image_url, + image: item.image_url || item.previews.image_medium_url, name: item.name, - url: item.external_url, + url: + item.external_url || + getExternalURL(network, item.contract_address, item.token_id), }; collections[item.contract_address].items.push(tItem); } else { @@ -60,9 +76,11 @@ export default async ( { contract: item.contract_address, id: item.token_id, - image: item.image_url, + image: item.image_url || item.previews.image_medium_url, name: item.name, - url: item.external_url, + url: + item.external_url || + getExternalURL(network, item.contract_address, item.token_id), }, ], }; diff --git a/packages/extension/src/providers/bitcoin/networks/bitcoin-testnet.ts b/packages/extension/src/providers/bitcoin/networks/bitcoin-testnet.ts index 6235735dd..1093e9357 100644 --- a/packages/extension/src/providers/bitcoin/networks/bitcoin-testnet.ts +++ b/packages/extension/src/providers/bitcoin/networks/bitcoin-testnet.ts @@ -19,7 +19,6 @@ const bitcoinOptions: BitcoinNetworkOptions = { currencyNameLong: "Test Bitcoin", icon: require("./icons/tbtc.svg"), decimals: 8, - gradient: "#F7931A", node: "https://api.blockchain.info/haskoin-store/btc-testnet/", activityHandler: wrapActivityHandler(haskoinHandler), basePath: "m/49'/1'/0'/0", diff --git a/packages/extension/src/providers/bitcoin/networks/bitcoin.ts b/packages/extension/src/providers/bitcoin/networks/bitcoin.ts index ca1b40e7e..d895acae0 100644 --- a/packages/extension/src/providers/bitcoin/networks/bitcoin.ts +++ b/packages/extension/src/providers/bitcoin/networks/bitcoin.ts @@ -18,7 +18,6 @@ const bitcoinOptions: BitcoinNetworkOptions = { currencyNameLong: "Bitcoin", icon: require("./icons/btc.svg"), decimals: 8, - gradient: "#F7931A", node: "https://api.blockchain.info/haskoin-store/btc/", coingeckoID: "bitcoin", activityHandler: wrapActivityHandler(haskoinHandler), diff --git a/packages/extension/src/providers/bitcoin/types/bitcoin-network.ts b/packages/extension/src/providers/bitcoin/types/bitcoin-network.ts index b4a4b325b..7867c650c 100644 --- a/packages/extension/src/providers/bitcoin/types/bitcoin-network.ts +++ b/packages/extension/src/providers/bitcoin/types/bitcoin-network.ts @@ -31,7 +31,6 @@ export interface BitcoinNetworkOptions { currencyNameLong: string; icon: string; decimals: number; - gradient: string; node: string; coingeckoID?: string; basePath: string; diff --git a/packages/extension/src/providers/common/ui/send-transaction/send-input-amount.vue b/packages/extension/src/providers/common/ui/send-transaction/send-input-amount.vue index 93b1ebc42..a0df84c6b 100644 --- a/packages/extension/src/providers/common/ui/send-transaction/send-input-amount.vue +++ b/packages/extension/src/providers/common/ui/send-transaction/send-input-amount.vue @@ -15,7 +15,11 @@ ${{ $filters.formatFiatValue(fiatEquivalent).value }} - + Max @@ -49,6 +53,10 @@ const props = defineProps({ type: String, default: "", }, + showMax: { + type: Boolean, + default: true, + }, }); const fiatEquivalent = computed(() => { return new BigNumber(props.fiatValue).times(props.amount).toString(); diff --git a/packages/extension/src/providers/ethereum/inject.ts b/packages/extension/src/providers/ethereum/inject.ts index 52085b56b..d8b47bb81 100644 --- a/packages/extension/src/providers/ethereum/inject.ts +++ b/packages/extension/src/providers/ethereum/inject.ts @@ -19,6 +19,7 @@ import { EXTENSION_VERSION } from "@/configs/constants"; import { SettingsType } from "@/libs/settings-state/types"; import { EnkryptWindow } from "@/types/globals"; import { v4 as randomUUID } from "uuid"; +import { InternalMethods } from "@/types/messenger"; export class Provider extends EventEmitter implements ProviderInterface { chainId: string | null; @@ -144,11 +145,17 @@ const injectDocument = ( options: ProviderOptions ): void => { const provider = new Provider(options); - const globalSettings: SettingsType = document.enkrypt.settings; const proxiedProvider = new Proxy(provider, ProxyHandler); - if (!globalSettings.evm.inject.disabled) - document[options.name] = proxiedProvider; //proxy is needed due to web3js 1.3.0 callbackify issue. Used in superrare document["enkrypt"]["providers"][options.name] = provider; + options + .sendMessageHandler( + ProviderName.enkrypt, + JSON.stringify({ method: InternalMethods.getSettings, params: [] }) + ) + .then((settings: SettingsType) => { + if (!settings.evm.inject.disabled) + document[options.name] = proxiedProvider; //proxy is needed due to web3js 1.3.0 callbackify issue. Used in superrare + }); const ENKRYPT_UUID_V4 = randomUUID(); // EIP-6963 const eip6963AnnounceProvider = () => { diff --git a/packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts b/packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts index be3a854cc..ec3d6e760 100644 --- a/packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts +++ b/packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts @@ -42,6 +42,9 @@ const NetworkEndpoints: Record = { [NetworkNames.Fantom]: "https://api.ftmscan.com/", [NetworkNames.Aurora]: "https://explorer.mainnet.aurora.dev/", [NetworkNames.PuppyNet]: "https://puppyscan.shib.io/", + [NetworkNames.MaticZK]: "https://api-zkevm.polygonscan.com/", + [NetworkNames.Base]: "https://api.basescan.org/", + [NetworkNames.Celo]: "https://explorer.celo.org/mainnet/", }; export { NetworkEndpoints }; diff --git a/packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts b/packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts index bbab36401..15520b763 100644 --- a/packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts +++ b/packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts @@ -20,8 +20,8 @@ import { EvmNetwork } from "../../types/evm-network"; import { getKnownNetworkTokens } from "./token-lists"; import { CoingeckoPlatform, NetworkNames } from "@enkryptcom/types"; import { NATIVE_TOKEN_ADDRESS } from "../common"; -import getZKSyncBalances from "./zksync"; import getTomoBalances from "./tomochain"; +import { CoinGeckoTokenMarket } from "@/libs/market-data/types"; const API_ENPOINT = "https://tokenbalance.mewapi.io/"; const API_ENPOINT2 = "https://partners.mewapi.io/balances/"; @@ -95,15 +95,21 @@ const supportedNetworks: Record = { tbName: "aurora", cgPlatform: CoingeckoPlatform.Aurora, }, - [NetworkNames.TomoChain]: { - tbName: "", - cgPlatform: CoingeckoPlatform.TomoChain, + [NetworkNames.ZkSync]: { + tbName: "era", + cgPlatform: CoingeckoPlatform.Zksync, }, - [NetworkNames.ZkSyncGoerli]: { - tbName: "", + [NetworkNames.MaticZK]: { + tbName: "pze", + cgPlatform: CoingeckoPlatform.MaticZK, }, - [NetworkNames.ZkSync]: { + [NetworkNames.Celo]: { + tbName: "celo", + cgPlatform: CoingeckoPlatform.Celo, + }, + [NetworkNames.TomoChain]: { tbName: "", + cgPlatform: CoingeckoPlatform.TomoChain, }, }; @@ -111,9 +117,6 @@ const getTokens = ( chain: SupportedNetworkNames, address: string ): Promise => { - if (chain === NetworkNames.ZkSyncGoerli || chain === NetworkNames.ZkSync) { - return getZKSyncBalances(chain, address); - } if (chain === NetworkNames.TomoChain) { return getTomoBalances(chain, address); } @@ -165,7 +168,10 @@ export default ( ), supportedNetworks[networkName].cgPlatform as CoingeckoPlatform ) - : tokens.reduce((obj, cur) => ({ ...obj, [cur.contract]: null }), {}); + : tokens.reduce( + (obj, cur) => ({ ...obj, [cur.contract]: null }), + {} as Record + ); if (network.coingeckoID) { const nativeMarket = await marketData.getMarketData([ network.coingeckoID, diff --git a/packages/extension/src/providers/ethereum/libs/assets-handlers/token-lists.ts b/packages/extension/src/providers/ethereum/libs/assets-handlers/token-lists.ts index bd5fc2b6e..49da949bd 100644 --- a/packages/extension/src/providers/ethereum/libs/assets-handlers/token-lists.ts +++ b/packages/extension/src/providers/ethereum/libs/assets-handlers/token-lists.ts @@ -6,6 +6,7 @@ const TokenList: Record = { [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`, + [NetworkNames.MaticZK]: `https://tokens.coingecko.com/${CoingeckoPlatform.MaticZK}/all.json`, [NetworkNames.AstarEVM]: `https://tokens.coingecko.com/${CoingeckoPlatform.Astar}/all.json`, [NetworkNames.Okc]: `https://tokens.coingecko.com/${CoingeckoPlatform.Okc}/all.json`, [NetworkNames.Optimism]: `https://tokens.coingecko.com/${CoingeckoPlatform.Optimism}/all.json`, @@ -14,14 +15,14 @@ const TokenList: Record = { [NetworkNames.ShidenEVM]: `https://tokens.coingecko.com/${CoingeckoPlatform.Shiden}/all.json`, [NetworkNames.Canto]: `https://tokens.coingecko.com/${CoingeckoPlatform.Canto}/all.json`, [NetworkNames.Rootstock]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/tokenlists/rsk.json`, - [NetworkNames.ZkSyncGoerli]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/tokenlists/zksyncgoerli.json`, - [NetworkNames.ZkSync]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/tokenlists/zksync.json`, + [NetworkNames.ZkSync]: `https://tokens.coingecko.com/${CoingeckoPlatform.Zksync}/all.json`, [NetworkNames.Arbitrum]: `https://tokens.coingecko.com/${CoingeckoPlatform.Arbitrum}/all.json`, [NetworkNames.Gnosis]: `https://tokens.coingecko.com/${CoingeckoPlatform.Gnosis}/all.json`, [NetworkNames.Avalanche]: `https://tokens.coingecko.com/${CoingeckoPlatform.Avalanche}/all.json`, [NetworkNames.Fantom]: `https://tokens.coingecko.com/${CoingeckoPlatform.Fantom}/all.json`, [NetworkNames.Klaytn]: `https://tokens.coingecko.com/${CoingeckoPlatform.Klaytn}/all.json`, [NetworkNames.Aurora]: `https://tokens.coingecko.com/${CoingeckoPlatform.Aurora}/all.json`, + [NetworkNames.Celo]: `https://tokens.coingecko.com/${CoingeckoPlatform.Celo}/all.json`, [NetworkNames.TomoChain]: `https://tokens.coingecko.com/${CoingeckoPlatform.TomoChain}/all.json`, }; diff --git a/packages/extension/src/providers/ethereum/libs/assets-handlers/types/tokenbalance-mew.ts b/packages/extension/src/providers/ethereum/libs/assets-handlers/types/tokenbalance-mew.ts index 7ce991ad5..542e91097 100644 --- a/packages/extension/src/providers/ethereum/libs/assets-handlers/types/tokenbalance-mew.ts +++ b/packages/extension/src/providers/ethereum/libs/assets-handlers/types/tokenbalance-mew.ts @@ -43,6 +43,7 @@ export type SupportedNetworkNames = | NetworkNames.Fantom | NetworkNames.Klaytn | NetworkNames.Aurora - | NetworkNames.ZkSyncGoerli - | NetworkNames.ZkSync - | NetworkNames.TomoChain; + | NetworkNames.TomoChain + | NetworkNames.MaticZK + | NetworkNames.Celo + | NetworkNames.ZkSync; diff --git a/packages/extension/src/providers/ethereum/libs/assets-handlers/zksync.ts b/packages/extension/src/providers/ethereum/libs/assets-handlers/zksync.ts deleted file mode 100644 index 92cf57f57..000000000 --- a/packages/extension/src/providers/ethereum/libs/assets-handlers/zksync.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { NetworkNames } from "@enkryptcom/types"; -import { - SupportedNetworkNames, - TokenBalance, - ZkSyncBalanceType, -} from "./types/tokenbalance-mew"; -import { NetworkEndpoints } from "../activity-handlers/providers/etherscan/configs"; -import { NATIVE_TOKEN_ADDRESS } from "../common"; -import { numberToHex, toBN } from "web3-utils"; - -const ZKGoerli_ENDPOINT = NetworkEndpoints[NetworkNames.ZkSyncGoerli]; -const ZKSync_ENDPOINT = NetworkEndpoints[NetworkNames.ZkSync]; - -const getBalances = (chain: SupportedNetworkNames, address: string) => { - const endpoint = - chain === NetworkNames.ZkSyncGoerli ? ZKGoerli_ENDPOINT : ZKSync_ENDPOINT; - return fetch( - `${endpoint}api?module=account&action=tokenlist&address=${address}` - ) - .then((res) => res.json()) - .then((json) => { - if (json.status === "0" && json.result === null) - return Promise.reject( - `TOKENBALANCE-MEW: ${JSON.stringify(json.message)}` - ); - else { - const results: ZkSyncBalanceType[] = json.result; - const retVal: TokenBalance[] = []; - const zksyncNativeAddress = - "0x000000000000000000000000000000000000800a"; - results.forEach((bal) => { - retVal.push({ - contract: - bal.contractAddress === zksyncNativeAddress - ? NATIVE_TOKEN_ADDRESS - : bal.contractAddress, - balance: numberToHex(toBN(bal.balance)), - }); - }); - const isNativeAvailable = json.result.length - ? json.result.find((i: any) => i.contract === NATIVE_TOKEN_ADDRESS) - : false; - if (!isNativeAvailable) { - retVal.push({ - contract: NATIVE_TOKEN_ADDRESS, - balance: "0x0", - }); - } - return retVal; - } - }); -}; - -export default getBalances; diff --git a/packages/extension/src/providers/ethereum/libs/common.ts b/packages/extension/src/providers/ethereum/libs/common.ts index 0b5888004..e7bb1792f 100644 --- a/packages/extension/src/providers/ethereum/libs/common.ts +++ b/packages/extension/src/providers/ethereum/libs/common.ts @@ -1,2 +1,5 @@ +import { NetworkNames } from "@enkryptcom/types"; + const NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; -export { NATIVE_TOKEN_ADDRESS }; +const MAX_UNAVAILABLE_NETWORKS = [NetworkNames.Optimism]; +export { NATIVE_TOKEN_ADDRESS, MAX_UNAVAILABLE_NETWORKS }; diff --git a/packages/extension/src/providers/ethereum/libs/transaction/gas-utils.ts b/packages/extension/src/providers/ethereum/libs/transaction/gas-utils.ts index dc756ed08..9326670eb 100644 --- a/packages/extension/src/providers/ethereum/libs/transaction/gas-utils.ts +++ b/packages/extension/src/providers/ethereum/libs/transaction/gas-utils.ts @@ -12,6 +12,7 @@ const FAST_MULTIPLIER = 1.1428571428571; const FASTEST_CONST = 64285714285.7; const FASTEST_MULTIPLIER = 1.21828571429; const LIMITER = 25000000000; +const GAS_PERCENTILES = [25, 50, 75, 90]; const getEconomy = (gasPrice: string): BN => { return toBN(gasPrice); @@ -62,7 +63,7 @@ const getGasBasedOnType = ( } }; const getMinPriorityFee = (): BN => { - return toBN(toWei("1.25", "gwei")); + return toBN(toWei("0.1", "gwei")); }; const getPriorityFeeAvg = (arr: BN[]): BN => { const sum = arr.reduce((a, v) => a.add(v)); @@ -113,9 +114,11 @@ const formatFeeHistory = ( number: blockNum, baseFeePerGas: blockBaseFee, gasUsedRatio: feeHistory.gasUsedRatio[index], - priorityFeePerGas: feeHistory.reward[index] - .map((x) => toBN(x)) - .sort((a, b) => a.sub(b).toNumber()), + priorityFeePerGas: feeHistory.reward + ? feeHistory.reward[index] + .map((x) => toBN(x)) + .sort((a, b) => a.sub(b).toNumber()) + : GAS_PERCENTILES.map(() => toBN(0)), }); blockNum += 1; index += 1; @@ -181,4 +184,5 @@ export { getGasBasedOnType, FeeDescriptions, formatFeeHistory, + GAS_PERCENTILES, }; diff --git a/packages/extension/src/providers/ethereum/libs/transaction/index.ts b/packages/extension/src/providers/ethereum/libs/transaction/index.ts index bfb6343e8..c63ef57d5 100644 --- a/packages/extension/src/providers/ethereum/libs/transaction/index.ts +++ b/packages/extension/src/providers/ethereum/libs/transaction/index.ts @@ -10,6 +10,7 @@ import { import { GasPriceTypes } from "@/providers/common/types"; import { numberToHex, toBN } from "web3-utils"; import { + GAS_PERCENTILES, formatFeeHistory, getBaseFeeBasedOnType, getGasBasedOnType, @@ -71,25 +72,39 @@ class Transaction { const { isFeeMarketNetwork, baseFeePerGas } = await this.web3 .getBlock("pending", false) .then((block) => { - return { - isFeeMarketNetwork: !!block.baseFeePerGas, - baseFeePerGas: block.baseFeePerGas?.toString(), - }; + if (block) { + return { + isFeeMarketNetwork: !!block.baseFeePerGas, + baseFeePerGas: block.baseFeePerGas?.toString(), + }; + } + // some networks such as zksync era pending block is null + return this.web3.getBlock("latest", false).then((block) => { + return { + isFeeMarketNetwork: !!block.baseFeePerGas, + baseFeePerGas: block.baseFeePerGas?.toString(), + }; + }); }); const gasPrice = await this.web3.getGasPrice(); const nonce = await this.web3.getTransactionCount(this.tx.from, "pending"); if (!isFeeMarketNetwork) { + const gasLimit = + this.tx.gasLimit || + (numberToHex(await this.estimateGas()) as `0x${string}`); const legacyTx: FinalizedLegacyEthereumTransaction = { to: this.tx.to || undefined, chainId: this.tx.chainId, data: this.tx.data || "0x", from: this.tx.from, - gasLimit: - this.tx.gasLimit || - (numberToHex(await this.estimateGas()) as `0x${string}`), - gasPrice: numberToHex( - getGasBasedOnType(gasPrice, options.gasPriceType) - ) as `0x${string}`, + gasLimit, + gasPrice: !options.totalGasPrice + ? (numberToHex( + getGasBasedOnType(gasPrice, options.gasPriceType) + ) as `0x${string}`) + : (numberToHex( + options.totalGasPrice.div(toBN(gasLimit)) + ) as `0x${string}`), nonce: this.tx.nonce || (numberToHex(nonce) as `0x${string}`), value: this.tx.value || "0x0", }; @@ -101,8 +116,8 @@ class Transaction { } else { const feeHistory = await this.web3.getFeeHistory( 6, - "pending", - [25, 50, 75, 90] + "latest", + GAS_PERCENTILES ); const formattedFeeHistory = formatFeeHistory(feeHistory); const feeMarket = this.getFeeMarketGasInfo( @@ -110,19 +125,26 @@ class Transaction { formattedFeeHistory, options.gasPriceType ); + const gasLimit = + this.tx.gasLimit || + (numberToHex(await this.estimateGas()) as `0x${string}`); + const maxFeePerGas = !options.totalGasPrice + ? feeMarket.maxFeePerGas + : options.totalGasPrice.div(toBN(gasLimit)); + const maxPriorityFeePerGas = feeMarket.maxPriorityFeePerGas; const feeMarketTx: FinalizedFeeMarketEthereumTransaction = { to: this.tx.to || undefined, chainId: this.tx.chainId, data: this.tx.data || "0x", from: this.tx.from, - gasLimit: - this.tx.gasLimit || - (numberToHex(await this.estimateGas()) as `0x${string}`), + gasLimit, nonce: this.tx.nonce || (numberToHex(nonce) as `0x${string}`), value: this.tx.value || "0x0", - maxFeePerGas: numberToHex(feeMarket.maxFeePerGas) as `0x${string}`, + maxFeePerGas: numberToHex(maxFeePerGas) as `0x${string}`, maxPriorityFeePerGas: numberToHex( - feeMarket.maxPriorityFeePerGas + maxPriorityFeePerGas.gt(maxFeePerGas) + ? maxFeePerGas + : maxPriorityFeePerGas ) as `0x${string}`, type: "0x02", accessList: this.tx.accessList || [], diff --git a/packages/extension/src/providers/ethereum/libs/transaction/types.ts b/packages/extension/src/providers/ethereum/libs/transaction/types.ts index 2308983b2..b911706dd 100644 --- a/packages/extension/src/providers/ethereum/libs/transaction/types.ts +++ b/packages/extension/src/providers/ethereum/libs/transaction/types.ts @@ -75,6 +75,7 @@ export interface DecodedTx { export interface TransactionOptions { gasPriceType: GasPriceTypes; + totalGasPrice?: BN; } export interface DataDecodeResponse { decoded: boolean; diff --git a/packages/extension/src/providers/ethereum/networks/arb.ts b/packages/extension/src/providers/ethereum/networks/arb.ts index 0007586ac..05e0b4378 100644 --- a/packages/extension/src/providers/ethereum/networks/arb.ts +++ b/packages/extension/src/providers/ethereum/networks/arb.ts @@ -17,7 +17,6 @@ const arbOptions: EvmNetworkOptions = { currencyNameLong: "Ethereum", node: "wss://nodes.mewapi.io/ws/arb", icon: require("./icons/arbitrum.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", coingeckoID: "ethereum", coingeckoPlatform: CoingeckoPlatform.Arbitrum, assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/astr.ts b/packages/extension/src/providers/ethereum/networks/astr.ts index f2fae3aa8..2bf014460 100644 --- a/packages/extension/src/providers/ethereum/networks/astr.ts +++ b/packages/extension/src/providers/ethereum/networks/astr.ts @@ -16,7 +16,6 @@ const astrOptions: EvmNetworkOptions = { currencyNameLong: "Astar", node: "wss://astar.public.blastapi.io/", icon: require("./icons/astr.png"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", coingeckoID: "astar", coingeckoPlatform: CoingeckoPlatform.Astar, assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/aurora.ts b/packages/extension/src/providers/ethereum/networks/aurora.ts index 486abbdbf..351ad63e0 100644 --- a/packages/extension/src/providers/ethereum/networks/aurora.ts +++ b/packages/extension/src/providers/ethereum/networks/aurora.ts @@ -16,7 +16,6 @@ const auroraOptions: EvmNetworkOptions = { currencyNameLong: "Ethereum", node: "https://mainnet.aurora.dev", icon: require("./icons/aurora.png"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", coingeckoID: "ethereum", coingeckoPlatform: CoingeckoPlatform.Aurora, assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/avax.ts b/packages/extension/src/providers/ethereum/networks/avax.ts index 08910e012..f4ddbf790 100644 --- a/packages/extension/src/providers/ethereum/networks/avax.ts +++ b/packages/extension/src/providers/ethereum/networks/avax.ts @@ -17,7 +17,6 @@ const avaxOptions: EvmNetworkOptions = { currencyNameLong: "Avalanche", node: "https://api.avax.network/ext/bc/C/rpc", icon: require("./icons/avax.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", coingeckoID: "avalanche-2", coingeckoPlatform: CoingeckoPlatform.Avalanche, assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/base.ts b/packages/extension/src/providers/ethereum/networks/base.ts new file mode 100644 index 000000000..c310b544e --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/base.ts @@ -0,0 +1,27 @@ +import { CoingeckoPlatform, NetworkNames } from "@enkryptcom/types"; +import { EvmNetwork, EvmNetworkOptions } from "../types/evm-network"; +import shNFTHandler from "@/libs/nft-handlers/simplehash"; +import { EtherscanActivity } from "../libs/activity-handlers"; +import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; + +const baseOptions: EvmNetworkOptions = { + name: NetworkNames.Base, + name_long: "Base", + homePage: "https://base.org", + blockExplorerTX: "https://basescan.org/tx/[[txHash]]", + blockExplorerAddr: "https://basescan.org/address/[[address]]", + chainID: "0x2105", + isTestNetwork: false, + currencyName: "ETH", + currencyNameLong: "Ethereum", + node: "wss://nodes.mewapi.io/ws/base", + icon: require("./icons/base.svg"), + coingeckoID: "ethereum", + coingeckoPlatform: CoingeckoPlatform.Base, + NFTHandler: shNFTHandler, + activityHandler: wrapActivityHandler(EtherscanActivity), +}; + +const base = new EvmNetwork(baseOptions); + +export default base; diff --git a/packages/extension/src/providers/ethereum/networks/bsc.ts b/packages/extension/src/providers/ethereum/networks/bsc.ts index d3f424564..e9dd2e4f2 100644 --- a/packages/extension/src/providers/ethereum/networks/bsc.ts +++ b/packages/extension/src/providers/ethereum/networks/bsc.ts @@ -17,7 +17,6 @@ const bscOptions: EvmNetworkOptions = { currencyNameLong: "Binance", node: "wss://nodes.mewapi.io/ws/bsc", icon: require("./icons/bsc.svg"), - gradient: "#F0B90B", coingeckoID: "binancecoin", coingeckoPlatform: CoingeckoPlatform.Binance, basePath: "m/44'/714'", diff --git a/packages/extension/src/providers/ethereum/networks/canto.ts b/packages/extension/src/providers/ethereum/networks/canto.ts index a74b30760..194ac12e7 100644 --- a/packages/extension/src/providers/ethereum/networks/canto.ts +++ b/packages/extension/src/providers/ethereum/networks/canto.ts @@ -16,7 +16,6 @@ const cantoOptions: EvmNetworkOptions = { currencyNameLong: "Canto", node: "https://canto.gravitychain.io/", icon: require("./icons/canto.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", coingeckoID: "canto", coingeckoPlatform: CoingeckoPlatform.Canto, assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/celo.ts b/packages/extension/src/providers/ethereum/networks/celo.ts new file mode 100644 index 000000000..0985531c9 --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/celo.ts @@ -0,0 +1,27 @@ +import { CoingeckoPlatform, 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"; +import assetsInfoHandler from "@/providers/ethereum/libs/assets-handlers/assetinfo-mew"; + +const celoOptions: EvmNetworkOptions = { + name: NetworkNames.Celo, + name_long: "Celo", + homePage: "https://celo.org/", + blockExplorerTX: "https://explorer.celo.org/mainnet/tx/[[txHash]]", + blockExplorerAddr: "https://explorer.celo.org/mainnet/address/[[address]]", + chainID: "0xa4ec", + isTestNetwork: false, + currencyName: "CELO", + currencyNameLong: "Celo", + node: "https://forno.celo.org", + icon: require("./icons/celo.svg"), + coingeckoID: "celo", + coingeckoPlatform: CoingeckoPlatform.Celo, + assetsInfoHandler, + activityHandler: wrapActivityHandler(EtherscanActivity), +}; + +const celo = new EvmNetwork(celoOptions); + +export default celo; diff --git a/packages/extension/src/providers/ethereum/networks/edg.ts b/packages/extension/src/providers/ethereum/networks/edg.ts index d2259bad9..822c11465 100644 --- a/packages/extension/src/providers/ethereum/networks/edg.ts +++ b/packages/extension/src/providers/ethereum/networks/edg.ts @@ -15,7 +15,6 @@ const edgOptions: EvmNetworkOptions = { currencyNameLong: "Edgeware", node: "wss://edgeware.jelliedowl.net", icon: require("./icons/edgeware.svg"), - gradient: "#000000", coingeckoID: "edgeware", coingeckoPlatform: CoingeckoPlatform.Edgeware, activityHandler: wrapActivityHandler(EtherscanActivity), diff --git a/packages/extension/src/providers/ethereum/networks/etc.ts b/packages/extension/src/providers/ethereum/networks/etc.ts index e060efe37..a592ce51a 100644 --- a/packages/extension/src/providers/ethereum/networks/etc.ts +++ b/packages/extension/src/providers/ethereum/networks/etc.ts @@ -15,7 +15,6 @@ const etcOptions: EvmNetworkOptions = { currencyNameLong: "Ethereum Classic", node: "wss://nodes.mewapi.io/ws/etc", icon: require("./icons/etc.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", basePath: "m/44'/61'/0'/0", coingeckoID: "ethereum-classic", coingeckoPlatform: CoingeckoPlatform.EthereumClassic, diff --git a/packages/extension/src/providers/ethereum/networks/eth.ts b/packages/extension/src/providers/ethereum/networks/eth.ts index 29f8821bb..5d591f744 100644 --- a/packages/extension/src/providers/ethereum/networks/eth.ts +++ b/packages/extension/src/providers/ethereum/networks/eth.ts @@ -17,7 +17,6 @@ const ethOptions: EvmNetworkOptions = { currencyNameLong: "Ethereum", node: "wss://nodes.mewapi.io/ws/eth", icon: require("./icons/eth.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", coingeckoID: "ethereum", coingeckoPlatform: CoingeckoPlatform.Ethereum, NFTHandler: mewNFTHandler, diff --git a/packages/extension/src/providers/ethereum/networks/ftm.ts b/packages/extension/src/providers/ethereum/networks/ftm.ts index 60d662069..247a76c00 100644 --- a/packages/extension/src/providers/ethereum/networks/ftm.ts +++ b/packages/extension/src/providers/ethereum/networks/ftm.ts @@ -16,7 +16,6 @@ const ftmOptions: EvmNetworkOptions = { currencyNameLong: "Fantom", node: "https://rpc.ankr.com/fantom/", icon: require("./icons/ftm.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", coingeckoID: "fantom", coingeckoPlatform: CoingeckoPlatform.Fantom, assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/glmr.ts b/packages/extension/src/providers/ethereum/networks/glmr.ts index a0ed28b03..bd749671f 100644 --- a/packages/extension/src/providers/ethereum/networks/glmr.ts +++ b/packages/extension/src/providers/ethereum/networks/glmr.ts @@ -16,7 +16,6 @@ const moonbeamOptions: EvmNetworkOptions = { currencyNameLong: "Moonbeam", node: "wss://wss.api.moonbeam.network/", icon: require("./icons/moonbeam.svg"), - gradient: "#53CBC9", coingeckoID: "moonbeam", coingeckoPlatform: CoingeckoPlatform.Moonbeam, assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/gno.ts b/packages/extension/src/providers/ethereum/networks/gno.ts index 4052b08d7..2664d407e 100644 --- a/packages/extension/src/providers/ethereum/networks/gno.ts +++ b/packages/extension/src/providers/ethereum/networks/gno.ts @@ -17,7 +17,6 @@ const gnoOptions: EvmNetworkOptions = { currencyNameLong: "DAI", node: "https://rpc.gnosischain.com", icon: require("./icons/gno.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", coingeckoID: "dai", coingeckoPlatform: CoingeckoPlatform.Gnosis, assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/goerli.ts b/packages/extension/src/providers/ethereum/networks/goerli.ts index b66ca0da0..13fadb1e2 100644 --- a/packages/extension/src/providers/ethereum/networks/goerli.ts +++ b/packages/extension/src/providers/ethereum/networks/goerli.ts @@ -2,6 +2,7 @@ import { NetworkNames } from "@enkryptcom/types"; import { EvmNetwork, EvmNetworkOptions } from "../types/evm-network"; import { RivetActivity } from "../libs/activity-handlers"; import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; +import shNFTHandler from "@/libs/nft-handlers/simplehash"; const goerliOptions: EvmNetworkOptions = { name: NetworkNames.Goerli, @@ -15,7 +16,7 @@ const goerliOptions: EvmNetworkOptions = { currencyNameLong: "Goerli", node: "wss://nodes.mewapi.io/ws/goerli", icon: require("./icons/eth.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", + NFTHandler: shNFTHandler, activityHandler: wrapActivityHandler(RivetActivity), }; diff --git a/packages/extension/src/providers/ethereum/networks/icons/base.svg b/packages/extension/src/providers/ethereum/networks/icons/base.svg new file mode 100644 index 000000000..f9f6a5ca3 --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/icons/base.svg @@ -0,0 +1,531 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/extension/src/providers/ethereum/networks/icons/celo.svg b/packages/extension/src/providers/ethereum/networks/icons/celo.svg new file mode 100644 index 000000000..4a06f6f73 --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/icons/celo.svg @@ -0,0 +1,16 @@ + + +Artboard 1 + + + + diff --git a/packages/extension/src/providers/ethereum/networks/icons/eth.svg b/packages/extension/src/providers/ethereum/networks/icons/eth.svg index 8202464ea..abfff247e 100644 --- a/packages/extension/src/providers/ethereum/networks/icons/eth.svg +++ b/packages/extension/src/providers/ethereum/networks/icons/eth.svg @@ -1,29 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/packages/extension/src/providers/ethereum/networks/index.ts b/packages/extension/src/providers/ethereum/networks/index.ts index f86617ea7..18ddb41c0 100644 --- a/packages/extension/src/providers/ethereum/networks/index.ts +++ b/packages/extension/src/providers/ethereum/networks/index.ts @@ -2,6 +2,7 @@ import ethNode from "./eth"; import goerliNode from "./goerli"; import etcNode from "./etc"; import maticNode from "./matic"; +import maticZkNode from "./maticzk"; import bscNode from "./bsc"; import moonbeamNode from "./glmr"; import moonriverNode from "./movr"; @@ -26,6 +27,8 @@ import klayNode from "./klay"; import auroraNode from "./aurora"; import puppyNode from "./puppy"; import sepoliaNode from "./sepolia"; +import baseNode from "./base"; +import celoNode from "./celo"; export default { goerli: goerliNode, @@ -33,6 +36,7 @@ export default { ethereum: ethNode, etc: etcNode, matic: maticNode, + maticzk: maticZkNode, bsc: bscNode, moonbeam: moonbeamNode, moonriver: moonriverNode, @@ -65,4 +69,6 @@ export default { klaytn: klayNode, aurora: auroraNode, puppy: puppyNode, + base: baseNode, + celo: celoNode, }; diff --git a/packages/extension/src/providers/ethereum/networks/karura.ts b/packages/extension/src/providers/ethereum/networks/karura.ts index b8d334971..4955bc9e1 100644 --- a/packages/extension/src/providers/ethereum/networks/karura.ts +++ b/packages/extension/src/providers/ethereum/networks/karura.ts @@ -15,7 +15,6 @@ const karuraOptions: EvmNetworkOptions = { currencyNameLong: "Karura", node: "wss://eth-rpc-karura.aca-api.network/ws", icon: require("./icons/karura-evm.svg"), - gradient: "linear-gradient(330.21deg, #E40C5B -26.31%, #FF4C3B 88.17%)", coingeckoID: "karura", coingeckoPlatform: CoingeckoPlatform.Karura, activityHandler: wrapActivityHandler(EtherscanActivity), diff --git a/packages/extension/src/providers/ethereum/networks/klay.ts b/packages/extension/src/providers/ethereum/networks/klay.ts index 199778a63..28425aeeb 100644 --- a/packages/extension/src/providers/ethereum/networks/klay.ts +++ b/packages/extension/src/providers/ethereum/networks/klay.ts @@ -15,7 +15,6 @@ const klayOptions: EvmNetworkOptions = { currencyNameLong: "Klaytn", node: "https://public-en-cypress.klaytn.net", icon: require("./icons/klaytn.png"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", coingeckoID: "klay-token", coingeckoPlatform: CoingeckoPlatform.Klaytn, assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/matic.ts b/packages/extension/src/providers/ethereum/networks/matic.ts index b5b9e8858..1304c2384 100644 --- a/packages/extension/src/providers/ethereum/networks/matic.ts +++ b/packages/extension/src/providers/ethereum/networks/matic.ts @@ -7,7 +7,7 @@ import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; const maticOptions: EvmNetworkOptions = { name: NetworkNames.Matic, - name_long: "Polygon (Matic)", + name_long: "Polygon", homePage: "https://polygonscan.com/", blockExplorerTX: "https://polygonscan.com/tx/[[txHash]]", blockExplorerAddr: "https://polygonscan.com/address/[[address]]", @@ -17,7 +17,6 @@ const maticOptions: EvmNetworkOptions = { currencyNameLong: "Polygon Matic", node: "wss://nodes.mewapi.io/ws/matic", icon: require("./icons/matic.svg"), - gradient: "#7B3FE4", coingeckoID: "matic-network", coingeckoPlatform: CoingeckoPlatform.Matic, NFTHandler: RaribleNFTHandler, diff --git a/packages/extension/src/providers/ethereum/networks/maticzk.ts b/packages/extension/src/providers/ethereum/networks/maticzk.ts new file mode 100644 index 000000000..07a6e45db --- /dev/null +++ b/packages/extension/src/providers/ethereum/networks/maticzk.ts @@ -0,0 +1,29 @@ +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"; + +const maticOptions: EvmNetworkOptions = { + name: NetworkNames.MaticZK, + name_long: "Polygon | zkEVM", + homePage: "https://zkevm.polygonscan.com/", + blockExplorerTX: "https://zkevm.polygonscan.com/tx/[[txHash]]", + blockExplorerAddr: "https://zkevm.polygonscan.com/address/[[address]]", + chainID: "0x44d", + isTestNetwork: false, + currencyName: "MATIC", + currencyNameLong: "Polygon Matic", + node: "wss://nodes.mewapi.io/ws/maticzk", + icon: require("./icons/matic.svg"), + coingeckoID: "matic-network", + coingeckoPlatform: CoingeckoPlatform.MaticZK, + NFTHandler: shNFTHandler, + assetsInfoHandler, + activityHandler: wrapActivityHandler(EtherscanActivity), +}; + +const matic = new EvmNetwork(maticOptions); + +export default matic; diff --git a/packages/extension/src/providers/ethereum/networks/movr.ts b/packages/extension/src/providers/ethereum/networks/movr.ts index 8b4cec181..802edc8aa 100644 --- a/packages/extension/src/providers/ethereum/networks/movr.ts +++ b/packages/extension/src/providers/ethereum/networks/movr.ts @@ -16,7 +16,6 @@ const moonriverOptions: EvmNetworkOptions = { currencyNameLong: "Moonriver", node: "wss://wss.api.moonriver.moonbeam.network", icon: require("./icons/moonriver.svg"), - gradient: "linear-gradient(180deg, #F2B705 0%, #53CBC8 100%)", coingeckoID: "moonriver", coingeckoPlatform: CoingeckoPlatform.Moonriver, assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/okc.ts b/packages/extension/src/providers/ethereum/networks/okc.ts index 5348efcce..bdc1ce782 100644 --- a/packages/extension/src/providers/ethereum/networks/okc.ts +++ b/packages/extension/src/providers/ethereum/networks/okc.ts @@ -16,7 +16,6 @@ const okcOptions: EvmNetworkOptions = { currencyNameLong: "OKX Chain", node: "https://exchainrpc.okex.org", icon: require("./icons/okc.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", coingeckoID: "oec-token", coingeckoPlatform: CoingeckoPlatform.Okc, assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/ontevm.ts b/packages/extension/src/providers/ethereum/networks/ontevm.ts index 8e60df0a3..823f50766 100644 --- a/packages/extension/src/providers/ethereum/networks/ontevm.ts +++ b/packages/extension/src/providers/ethereum/networks/ontevm.ts @@ -13,7 +13,6 @@ const ontEVMOptions: EvmNetworkOptions = { isTestNetwork: false, currencyName: "ONG", currencyNameLong: "Ontology", - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", node: "https://dappnode1.ont.io:10339", icon: require("./icons/ont-evm.png"), coingeckoID: "ontology", diff --git a/packages/extension/src/providers/ethereum/networks/op.ts b/packages/extension/src/providers/ethereum/networks/op.ts index 2fc311160..1bdab079c 100644 --- a/packages/extension/src/providers/ethereum/networks/op.ts +++ b/packages/extension/src/providers/ethereum/networks/op.ts @@ -17,7 +17,6 @@ const opOptions: EvmNetworkOptions = { currencyNameLong: "Ethereum", node: "wss://nodes.mewapi.io/ws/op", icon: require("./icons/op.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", coingeckoID: "ethereum", coingeckoPlatform: CoingeckoPlatform.Optimism, assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/puppy.ts b/packages/extension/src/providers/ethereum/networks/puppy.ts index d57a35144..d434945ee 100644 --- a/packages/extension/src/providers/ethereum/networks/puppy.ts +++ b/packages/extension/src/providers/ethereum/networks/puppy.ts @@ -15,7 +15,6 @@ const pupOptions: EvmNetworkOptions = { currencyNameLong: "BONE", node: "https://puppynet.shibrpc.com", icon: require("./icons/shiba-inu.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", activityHandler: wrapActivityHandler(EtherscanActivity), }; diff --git a/packages/extension/src/providers/ethereum/networks/rsk.ts b/packages/extension/src/providers/ethereum/networks/rsk.ts index 6da3d98df..c07c52fcf 100644 --- a/packages/extension/src/providers/ethereum/networks/rsk.ts +++ b/packages/extension/src/providers/ethereum/networks/rsk.ts @@ -19,7 +19,6 @@ const rootstockOptions: EvmNetworkOptions = { node: "wss://public-node.rsk.co/websocket", icon: require("./icons/rootstock.svg"), basePath: "m/44'/137'/0'/0", - gradient: "#7B3FE4", coingeckoID: CoingeckoPlatform.Rootstock, coingeckoPlatform: CoingeckoPlatform.Rootstock, activityHandler: wrapActivityHandler(EtherscanActivity), diff --git a/packages/extension/src/providers/ethereum/networks/sdn.ts b/packages/extension/src/providers/ethereum/networks/sdn.ts index a01028330..91ff4c27e 100644 --- a/packages/extension/src/providers/ethereum/networks/sdn.ts +++ b/packages/extension/src/providers/ethereum/networks/sdn.ts @@ -16,7 +16,6 @@ const sdnOptions: EvmNetworkOptions = { currencyNameLong: "Shiden", node: "wss://shiden.public.blastapi.io", icon: require("./icons/sdn.png"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", coingeckoID: "shiden", coingeckoPlatform: CoingeckoPlatform.Shiden, assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/sepolia.ts b/packages/extension/src/providers/ethereum/networks/sepolia.ts index 794143cd1..f7466c56a 100644 --- a/packages/extension/src/providers/ethereum/networks/sepolia.ts +++ b/packages/extension/src/providers/ethereum/networks/sepolia.ts @@ -15,7 +15,6 @@ const goerliOptions: EvmNetworkOptions = { currencyNameLong: "Sepolia", node: "wss://nodes.mewapi.io/ws/sepolia", icon: require("./icons/eth.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", activityHandler: wrapActivityHandler(RivetActivity), }; diff --git a/packages/extension/src/providers/ethereum/networks/skale/skale-base.ts b/packages/extension/src/providers/ethereum/networks/skale/skale-base.ts index 54ea18177..3b7892c15 100644 --- a/packages/extension/src/providers/ethereum/networks/skale/skale-base.ts +++ b/packages/extension/src/providers/ethereum/networks/skale/skale-base.ts @@ -225,7 +225,6 @@ export function createSkaleEvmNetwork( params.isTestNetwork ? "staging-v3" : "mainnet" }.skalenodes.com/v1/ws/${params.chainName}`, icon: require(`../icons/${params.icon ?? "skl.png"}`), - gradient: "#7B3FE4", coingeckoID: "skale", coingeckoPlatform: CoingeckoPlatform.SKALE, assetsInfoHandler: getAssetHandler(assets), diff --git a/packages/extension/src/providers/ethereum/networks/tomo.ts b/packages/extension/src/providers/ethereum/networks/tomo.ts index 3b51e83d5..88970c263 100644 --- a/packages/extension/src/providers/ethereum/networks/tomo.ts +++ b/packages/extension/src/providers/ethereum/networks/tomo.ts @@ -16,7 +16,6 @@ const tomoOptions: EvmNetworkOptions = { currencyNameLong: "TomoChain", node: "wss://ws.tomochain.com", icon: require("./icons/tomo.png"), - gradient: "#00e8b4", coingeckoID: "tomochain", basePath: "m/44'/889'/0'/0", assetsInfoHandler, diff --git a/packages/extension/src/providers/ethereum/networks/zkgoerli.ts b/packages/extension/src/providers/ethereum/networks/zkgoerli.ts index ae6b084fc..ee8b74aca 100644 --- a/packages/extension/src/providers/ethereum/networks/zkgoerli.ts +++ b/packages/extension/src/providers/ethereum/networks/zkgoerli.ts @@ -2,7 +2,7 @@ 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"; -import assetsInfoHandler from "@/providers/ethereum/libs/assets-handlers/assetinfo-mew"; +import shNFTHandler from "@/libs/nft-handlers/simplehash"; const zkgoerliOptions: EvmNetworkOptions = { name: NetworkNames.ZkSyncGoerli, @@ -14,10 +14,9 @@ const zkgoerliOptions: EvmNetworkOptions = { isTestNetwork: true, currencyName: "GöETH", currencyNameLong: "zkSync Goerli", - node: "wss://zksync2-testnet.zksync.dev/ws", + node: "wss://testnet.era.zksync.dev/ws", icon: require("./icons/zksync.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", - assetsInfoHandler, + NFTHandler: shNFTHandler, activityHandler: wrapActivityHandler(EtherscanActivity), }; diff --git a/packages/extension/src/providers/ethereum/networks/zksync.ts b/packages/extension/src/providers/ethereum/networks/zksync.ts index 60ef67622..5dbb4005c 100644 --- a/packages/extension/src/providers/ethereum/networks/zksync.ts +++ b/packages/extension/src/providers/ethereum/networks/zksync.ts @@ -3,6 +3,7 @@ import { EvmNetwork, EvmNetworkOptions } from "../types/evm-network"; import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; import { EtherscanActivity } from "../libs/activity-handlers"; import assetsInfoHandler from "@/providers/ethereum/libs/assets-handlers/assetinfo-mew"; +import shNFTHandler from "@/libs/nft-handlers/simplehash"; const zkSyncOptions: EvmNetworkOptions = { name: NetworkNames.ZkSync, @@ -14,12 +15,13 @@ const zkSyncOptions: EvmNetworkOptions = { isTestNetwork: false, currencyName: "ETH", currencyNameLong: "zkSync ETH", - node: "https://zksync2-mainnet.zksync.io", + node: "wss://mainnet.era.zksync.io/ws", icon: require("./icons/zksync.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", coingeckoID: "ethereum", coingeckoPlatform: CoingeckoPlatform.Zksync, + NFTHandler: shNFTHandler, assetsInfoHandler, + activityHandler: wrapActivityHandler(EtherscanActivity), }; diff --git a/packages/extension/src/providers/ethereum/tests/ethereum.events.mocha.ts b/packages/extension/src/providers/ethereum/tests/ethereum.events.mocha.ts index e65e439a7..aa98bc1ea 100644 --- a/packages/extension/src/providers/ethereum/tests/ethereum.events.mocha.ts +++ b/packages/extension/src/providers/ethereum/tests/ethereum.events.mocha.ts @@ -4,15 +4,32 @@ import EthereumInject from "../inject"; import { MessageMethod, EmitEvent } from "../types"; import { OnMessageResponse } from "@enkryptcom/types"; import { EnkryptWindow } from "@/types/globals"; +import { InternalMethods } from "@/types/messenger"; +const defaultSettings = { + evm: { + inject: { + disabled: false, + timestamp: 0, + }, + }, + substrate: { + injectPolkadotjs: false, + }, + manifestVersion: 3, +}; const providerSendMessage = async ( provider: ProviderName, message: string ): Promise => { + if (JSON.parse(message).method === InternalMethods.getSettings) { + return defaultSettings as unknown as OnMessageResponse; + } return { result: `dummy-response-${provider}-${message}`, }; }; + const options = { name: ProviderName.ethereum, type: ProviderType.evm, @@ -21,17 +38,7 @@ const options = { const tempWindow: EnkryptWindow = { enkrypt: { providers: {}, - settings: { - evm: { - inject: { - disabled: false, - timestamp: 0, - }, - }, - substrate: { - injectPolkadotjs: false, - }, - }, + settings: defaultSettings, }, // eslint-disable-next-line @typescript-eslint/no-empty-function addEventListener: () => {}, @@ -43,6 +50,7 @@ const tempWindow: EnkryptWindow = { describe("Test injected Ethereum", () => { it("should have default values", async () => { EthereumInject(tempWindow, options); + await new Promise((r) => setTimeout(r, 500)); const provider = tempWindow[ProviderName.ethereum] as EthereumProvider; expect(provider.name).to.equal(ProviderName.ethereum); expect(provider.chainId).to.equal(null); diff --git a/packages/extension/src/providers/ethereum/tests/ethereum.requests.mocha.ts b/packages/extension/src/providers/ethereum/tests/ethereum.requests.mocha.ts index 04b90bb52..588444f04 100644 --- a/packages/extension/src/providers/ethereum/tests/ethereum.requests.mocha.ts +++ b/packages/extension/src/providers/ethereum/tests/ethereum.requests.mocha.ts @@ -5,6 +5,20 @@ import { EthereumRequest } from "../types"; import { OnMessageResponse } from "@enkryptcom/types"; import { getError } from "@/libs/error"; import { EnkryptWindow } from "@/types/globals"; +import { InternalMethods } from "@/types/messenger"; + +const defaultSettings = { + evm: { + inject: { + disabled: false, + timestamp: 0, + }, + }, + substrate: { + injectPolkadotjs: false, + }, + manifestVersion: 3, +}; const requestHandler = (request: string): OnMessageResponse => { const req = JSON.parse(request) as EthereumRequest; @@ -28,6 +42,9 @@ const providerSendMessage = async ( provider: ProviderName, message: string ): Promise => { + if (JSON.parse(message).method === InternalMethods.getSettings) { + return defaultSettings as unknown as OnMessageResponse; + } if (provider === ProviderName.ethereum) { const res = requestHandler(message); if (res.error) return Promise.reject(JSON.parse(res.error)); @@ -42,17 +59,7 @@ const options = { const tempWindow: EnkryptWindow = { enkrypt: { providers: {}, - settings: { - evm: { - inject: { - disabled: false, - timestamp: 0, - }, - }, - substrate: { - injectPolkadotjs: false, - }, - }, + settings: defaultSettings, }, // eslint-disable-next-line @typescript-eslint/no-empty-function addEventListener: () => {}, @@ -64,6 +71,7 @@ const tempWindow: EnkryptWindow = { describe("Test Ethereum reponses", () => { it("should send proper responses", async () => { EthereumInject(tempWindow, options); + await new Promise((r) => setTimeout(r, 500)); const provider = tempWindow[ProviderName.ethereum] as EthereumProvider; expect(await provider.request({ method: "eth_chainId" })).to.equal("0x1"); await provider.request({ method: "eth_requestAccounts" }).catch((e) => { diff --git a/packages/extension/src/providers/ethereum/types/custom-evm-network.ts b/packages/extension/src/providers/ethereum/types/custom-evm-network.ts index 2be4c9d33..dad1c6c52 100644 --- a/packages/extension/src/providers/ethereum/types/custom-evm-network.ts +++ b/packages/extension/src/providers/ethereum/types/custom-evm-network.ts @@ -22,7 +22,6 @@ export class CustomEvmNetwork extends EvmNetwork { const evmNetworkOptions: EvmNetworkOptions = { ...options, icon: require("../networks/icons/eth.svg"), - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", activityHandler: wrapActivityHandler(() => Promise.resolve([])), blockExplorerAddr: options.blockExplorerAddr ?? "https://www.enkrypt.com/", diff --git a/packages/extension/src/providers/ethereum/types/evm-network.ts b/packages/extension/src/providers/ethereum/types/evm-network.ts index a0d99b83d..2f461e5e5 100644 --- a/packages/extension/src/providers/ethereum/types/evm-network.ts +++ b/packages/extension/src/providers/ethereum/types/evm-network.ts @@ -33,7 +33,6 @@ export interface EvmNetworkOptions { currencyNameLong: string; node: string; icon: string; - gradient: string; coingeckoID?: string; coingeckoPlatform?: CoingeckoPlatform; basePath?: string; diff --git a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue index 480a6110f..c3ca6b1f7 100644 --- a/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue +++ b/packages/extension/src/providers/ethereum/ui/send-transaction/index.vue @@ -75,6 +75,7 @@ ({}), }, }); + const loadingAsset = new Erc20Token({ icon: props.network.icon, symbol: "Loading", @@ -217,6 +222,12 @@ const addressFrom = ref( const addressTo = ref(""); const isLoadingAssets = ref(true); +const showMax = computed(() => { + if (selectedAsset.value.contract !== NATIVE_TOKEN_ADDRESS) return true; + if (MAX_UNAVAILABLE_NETWORKS.includes(props.network.name)) return false; + return true; +}); + const nativeBalance = computed(() => { const accountIndex = props.accountInfo.activeAccounts.findIndex( (acc) => acc.address === addressFrom.value @@ -355,9 +366,7 @@ const setBaseCosts = () => { }, web3 ); - setTransactionFees(tx).then(() => { - if (isMaxSelected.value) setMaxValue(); - }); + updateTransactionFees(tx); }; const fetchAssets = () => { accountAssets.value = []; @@ -395,9 +404,20 @@ const isInputsValid = computed(() => { return true; }); -watch([isInputsValid, amount, addressTo, selectedAsset], () => { +const updateTransactionFees = (tx: Transaction) => { + if (isMaxSelected.value) { + amount.value = ""; + } + setTransactionFees(tx).then(() => { + if (isMaxSelected.value) { + amount.value = + parseFloat(assetMaxValue.value) < 0 ? "0" : assetMaxValue.value; + } + }); +}; +watch([isInputsValid, addressTo, selectedAsset], () => { if (isInputsValid.value) { - setTransactionFees(Tx.value); + updateTransactionFees(Tx.value); } }); @@ -437,8 +457,7 @@ const assetMaxValue = computed(() => { }); const setMaxValue = () => { isMaxSelected.value = true; - amount.value = - parseFloat(assetMaxValue.value) < 0 ? "0" : assetMaxValue.value; + updateTransactionFees(Tx.value); }; const inputAddressFrom = (text: string) => { addressFrom.value = text; @@ -491,10 +510,10 @@ const inputAmount = (inputAmount: string) => { if (inputAmount === "") { inputAmount = "0"; } - const inputAmountBn = new BigNumber(inputAmount); isMaxSelected.value = false; amount.value = inputAmountBn.lt(0) ? "0" : inputAmountBn.toFixed(); + updateTransactionFees(Tx.value); }; const toggleSelectFee = () => { @@ -504,7 +523,7 @@ const toggleSelectFee = () => { const selectFee = (type: GasPriceTypes) => { selectedFee.value = type; isOpenSelectFee.value = false; - if (isMaxSelected.value) setMaxValue(); + if (isMaxSelected.value) updateTransactionFees(Tx.value); }; const sendAction = async () => { diff --git a/packages/extension/src/providers/ethereum/ui/send-transaction/verify-transaction/index.vue b/packages/extension/src/providers/ethereum/ui/send-transaction/verify-transaction/index.vue index 1cfddea00..4f6518721 100644 --- a/packages/extension/src/providers/ethereum/ui/send-transaction/verify-transaction/index.vue +++ b/packages/extension/src/providers/ethereum/ui/send-transaction/verify-transaction/index.vue @@ -104,6 +104,8 @@ import CustomScrollbar from "@action/components/custom-scrollbar/index.vue"; import broadcastTx from "@/providers/ethereum/libs/tx-broadcaster"; import { BaseNetwork } from "@/types/base-network"; import { bigIntToHex } from "@ethereumjs/util"; +import { toBN } from "web3-utils"; +import { toBase } from "@enkryptcom/utils"; const KeyRing = new PublicKeyRing(); const route = useRoute(); @@ -160,7 +162,12 @@ const sendAction = async () => { }; const activityState = new ActivityState(); await tx - .getFinalizedTransaction({ gasPriceType: txData.gasPriceType }) + .getFinalizedTransaction({ + gasPriceType: txData.gasPriceType, + totalGasPrice: toBN( + toBase(txData.gasFee.nativeValue, network.value.decimals) + ), + }) .then(async (finalizedTx) => { const onHash = (hash: string) => { activityState.addActivities( diff --git a/packages/extension/src/providers/polkadot/inject.ts b/packages/extension/src/providers/polkadot/inject.ts index 2a879c3ac..e661e3f87 100644 --- a/packages/extension/src/providers/polkadot/inject.ts +++ b/packages/extension/src/providers/polkadot/inject.ts @@ -15,6 +15,7 @@ import { InjectedSendMessageHandler } from "./types"; import { OnMessageResponse, RPCRequestType } from "@enkryptcom/types"; import { SettingsType } from "@/libs/settings-state/types"; import { EnkryptWindow } from "@/types/globals"; +import { InternalMethods } from "@/types/messenger"; let sendMessageHandler: InjectedSendMessageHandler; const messagerRouter = new MessageRouter(); export class Provider @@ -91,9 +92,18 @@ const injectDocument = ( const provider = new Provider(options); document.injectedWeb3 = document.injectedWeb3 || {}; document.injectedWeb3["enkrypt"] = new Proxy(provider, ProxyHandler); - const globalSettings: SettingsType = document.enkrypt.settings; - if (globalSettings.substrate.injectPolkadotjs) - document.injectedWeb3["polkadot-js"] = new Proxy(provider, ProxyHandler); + options + .sendMessageHandler( + ProviderName.enkrypt, + JSON.stringify({ method: InternalMethods.getSettings, params: [] }) + ) + .then((settings: SettingsType) => { + if (!settings.substrate.injectPolkadotjs) + document.injectedWeb3["polkadot-js"] = new Proxy( + provider, + ProxyHandler + ); + }); document["enkrypt"]["providers"][options.name] = provider; }; diff --git a/packages/extension/src/providers/polkadot/networks/acala/acala.ts b/packages/extension/src/providers/polkadot/networks/acala/acala.ts index 4ebaa0017..613ef8c8e 100644 --- a/packages/extension/src/providers/polkadot/networks/acala/acala.ts +++ b/packages/extension/src/providers/polkadot/networks/acala/acala.ts @@ -21,8 +21,6 @@ const acalaOptions: SubstrateNetworkOptions = { icon: require("../icons/acala.svg"), decimals: 12, prefix: 12, - gradient: - "linear-gradient(326.87deg, #645AFF 12.53%, #E40C5B 50.89%, #FF4C3B 89.24%)", node: "wss://acala-rpc-1.aca-api.network/", coingeckoID: "acala", coingeckoPlatform: CoingeckoPlatform.Acala, diff --git a/packages/extension/src/providers/polkadot/networks/acala/karura.ts b/packages/extension/src/providers/polkadot/networks/acala/karura.ts index 42be71096..d5c4a0f17 100644 --- a/packages/extension/src/providers/polkadot/networks/acala/karura.ts +++ b/packages/extension/src/providers/polkadot/networks/acala/karura.ts @@ -21,7 +21,6 @@ const karuraOptions: SubstrateNetworkOptions = { decimals: 12, prefix: 8, node: "wss://karura-rpc-3.aca-api.network/ws", - gradient: "linear-gradient(330.21deg, #E40C5B -26.31%, #FF4C3B 88.17%)", coingeckoID: "karura", coingeckoPlatform: CoingeckoPlatform.Karura, genesisHash: diff --git a/packages/extension/src/providers/polkadot/networks/astar/astar.ts b/packages/extension/src/providers/polkadot/networks/astar/astar.ts index bc6d1ce42..33a458edd 100644 --- a/packages/extension/src/providers/polkadot/networks/astar/astar.ts +++ b/packages/extension/src/providers/polkadot/networks/astar/astar.ts @@ -21,8 +21,6 @@ const astarOptions: SubstrateNetworkOptions = { icon: require("../icons/astar.png"), decimals: 18, prefix: 5, - gradient: - "linear-gradient(326.87deg, #645AFF 12.53%, #E40C5B 50.89%, #FF4C3B 89.24%)", node: "wss://astar.api.onfinality.io/public-ws", coingeckoID: "astar", coingeckoPlatform: CoingeckoPlatform.Astar, diff --git a/packages/extension/src/providers/polkadot/networks/astar/shiden.ts b/packages/extension/src/providers/polkadot/networks/astar/shiden.ts index a222b6422..576372f62 100644 --- a/packages/extension/src/providers/polkadot/networks/astar/shiden.ts +++ b/packages/extension/src/providers/polkadot/networks/astar/shiden.ts @@ -21,8 +21,6 @@ const shidenOptions: SubstrateNetworkOptions = { icon: require("../icons/shiden.png"), decimals: 18, prefix: 5, - gradient: - "linear-gradient(326.87deg, #645AFF 12.53%, #E40C5B 50.89%, #FF4C3B 89.24%)", node: "wss://shiden.api.onfinality.io/public-ws", coingeckoID: "shiden", coingeckoPlatform: CoingeckoPlatform.Shiden, diff --git a/packages/extension/src/providers/polkadot/networks/bifrost/kusama.ts b/packages/extension/src/providers/polkadot/networks/bifrost/kusama.ts index 7751dab15..c3e3007d3 100644 --- a/packages/extension/src/providers/polkadot/networks/bifrost/kusama.ts +++ b/packages/extension/src/providers/polkadot/networks/bifrost/kusama.ts @@ -21,8 +21,6 @@ const bifrostKusamaOptions: SubstrateNetworkOptions = { icon: require("../icons/bifrost.svg"), decimals: 12, prefix: 6, - gradient: - "linear-gradient(326.87deg, #5a25f0 12.53%, #5a25f0 50.89%, #5a25f0 89.24%)", node: "wss://bifrost-rpc.liebi.com/ws", coingeckoID: "bifrost-native-coin", coingeckoPlatform: CoingeckoPlatform.Bifrost, diff --git a/packages/extension/src/providers/polkadot/networks/bifrost/polkadot.ts b/packages/extension/src/providers/polkadot/networks/bifrost/polkadot.ts index 4984c8d2e..976e9bd71 100644 --- a/packages/extension/src/providers/polkadot/networks/bifrost/polkadot.ts +++ b/packages/extension/src/providers/polkadot/networks/bifrost/polkadot.ts @@ -21,8 +21,6 @@ const bifrostPolkadotOptions: SubstrateNetworkOptions = { icon: require("../icons/bifrost.svg"), decimals: 12, prefix: 6, - gradient: - "linear-gradient(326.87deg, #5a25f0 12.53%, #5a25f0 50.89%, #5a25f0 89.24%)", node: "wss://hk.p.bifrost-rpc.liebi.com/ws", coingeckoID: "bifrost-native-coin", coingeckoPlatform: CoingeckoPlatform.Bifrost, diff --git a/packages/extension/src/providers/polkadot/networks/edgeware.ts b/packages/extension/src/providers/polkadot/networks/edgeware.ts index bbd594f0f..29e50aaa2 100644 --- a/packages/extension/src/providers/polkadot/networks/edgeware.ts +++ b/packages/extension/src/providers/polkadot/networks/edgeware.ts @@ -19,7 +19,6 @@ const edgewareOptions: SubstrateNetworkOptions = { icon: require("./icons/edgeware.svg"), decimals: 18, prefix: 7, - gradient: "#000000", node: "wss://edgeware.jelliedowl.net", coingeckoID: "edgeware", coingeckoPlatform: CoingeckoPlatform.Edgeware, diff --git a/packages/extension/src/providers/polkadot/networks/kusama.ts b/packages/extension/src/providers/polkadot/networks/kusama.ts index 40b4424a7..b69cd9231 100644 --- a/packages/extension/src/providers/polkadot/networks/kusama.ts +++ b/packages/extension/src/providers/polkadot/networks/kusama.ts @@ -19,7 +19,6 @@ const ksmOptions: SubstrateNetworkOptions = { icon: require("./icons/kusama.svg"), decimals: 12, prefix: 2, - gradient: "#000000", node: "wss://kusama-rpc.polkadot.io/", coingeckoID: "kusama", coingeckoPlatform: CoingeckoPlatform.Kusama, diff --git a/packages/extension/src/providers/polkadot/networks/pendulum/amplitude.ts b/packages/extension/src/providers/polkadot/networks/pendulum/amplitude.ts index 8dc9908d2..a0860097a 100644 --- a/packages/extension/src/providers/polkadot/networks/pendulum/amplitude.ts +++ b/packages/extension/src/providers/polkadot/networks/pendulum/amplitude.ts @@ -20,7 +20,6 @@ const amplitudeOptions: SubstrateNetworkOptions = { icon: require("../icons/amplitude.svg"), decimals: 12, prefix: 57, - gradient: "#E6007A", node: "wss://rpc-amplitude.pendulumchain.tech", genesisHash: "0xcceae7f3b9947cdb67369c026ef78efa5f34a08fe5808d373c04421ecf4f1aaf", diff --git a/packages/extension/src/providers/polkadot/networks/pendulum/pendulum.ts b/packages/extension/src/providers/polkadot/networks/pendulum/pendulum.ts index dc4cf84ae..1fa734e5e 100644 --- a/packages/extension/src/providers/polkadot/networks/pendulum/pendulum.ts +++ b/packages/extension/src/providers/polkadot/networks/pendulum/pendulum.ts @@ -20,7 +20,6 @@ const pendulumOptions: SubstrateNetworkOptions = { icon: require("../icons/pendulum.svg"), decimals: 12, prefix: 56, - gradient: "#E6007A", node: "wss://rpc-pendulum.prd.pendulumchain.tech", genesisHash: "0x5d3c298622d5634ed019bf61ea4b71655030015bde9beb0d6a24743714462c86", diff --git a/packages/extension/src/providers/polkadot/networks/polkadot.ts b/packages/extension/src/providers/polkadot/networks/polkadot.ts index e24b8da74..0d63b2cd0 100644 --- a/packages/extension/src/providers/polkadot/networks/polkadot.ts +++ b/packages/extension/src/providers/polkadot/networks/polkadot.ts @@ -19,7 +19,6 @@ const polkadotOptions: SubstrateNetworkOptions = { icon: require("./icons/polkadot.svg"), decimals: 10, prefix: 0, - gradient: "#E6007A", node: "wss://rpc.polkadot.io/", coingeckoID: "polkadot", coingeckoPlatform: CoingeckoPlatform.Polkadot, diff --git a/packages/extension/src/providers/polkadot/networks/unique/opal.ts b/packages/extension/src/providers/polkadot/networks/unique/opal.ts index 710c542f7..ec2afb1b4 100644 --- a/packages/extension/src/providers/polkadot/networks/unique/opal.ts +++ b/packages/extension/src/providers/polkadot/networks/unique/opal.ts @@ -19,7 +19,6 @@ const opalOptions: SubstrateNetworkOptions = { icon: require("../icons/opal.svg"), decimals: 18, prefix: 42, - gradient: "#0CB6B8", node: "wss://ws-opal.unique.network", genesisHash: "0xc87870ef90a438d574b8e320f17db372c50f62beb52e479c8ff6ee5b460670b9", diff --git a/packages/extension/src/providers/polkadot/networks/unique/quartz.ts b/packages/extension/src/providers/polkadot/networks/unique/quartz.ts index 131cad1b6..e39ab05c5 100644 --- a/packages/extension/src/providers/polkadot/networks/unique/quartz.ts +++ b/packages/extension/src/providers/polkadot/networks/unique/quartz.ts @@ -18,7 +18,6 @@ const quartzOptions: SubstrateNetworkOptions = { icon: require("../icons/quartz.svg"), decimals: 18, prefix: 255, - gradient: "#FF4D6A", node: "wss://ws-quartz.unique.network", coingeckoID: "quartz", coingeckoPlatform: CoingeckoPlatform.Quartz, diff --git a/packages/extension/src/providers/polkadot/networks/unique/unique.ts b/packages/extension/src/providers/polkadot/networks/unique/unique.ts index f7c4b0a8c..b5b8e9aa1 100644 --- a/packages/extension/src/providers/polkadot/networks/unique/unique.ts +++ b/packages/extension/src/providers/polkadot/networks/unique/unique.ts @@ -18,7 +18,6 @@ const uniqueOptions: SubstrateNetworkOptions = { icon: require("../icons/unique.svg"), decimals: 18, prefix: 7391, - gradient: "#00BFFF", node: "wss://ws.unique.network", coingeckoID: "unique-network", coingeckoPlatform: CoingeckoPlatform.Unique, diff --git a/packages/extension/src/providers/polkadot/networks/vara.ts b/packages/extension/src/providers/polkadot/networks/vara.ts index c259d9729..90c6cd293 100644 --- a/packages/extension/src/providers/polkadot/networks/vara.ts +++ b/packages/extension/src/providers/polkadot/networks/vara.ts @@ -19,7 +19,6 @@ const varaOptions: SubstrateNetworkOptions = { icon: require("./icons/vara.svg"), decimals: 12, prefix: 137, - gradient: "#0ed3a3", node: "wss://rpc.vara-network.io", genesisHash: "0xfe1b4c55fd4d668101126434206571a7838a8b6b93a6d1b95d607e78e6c53763", diff --git a/packages/extension/src/providers/polkadot/networks/westend.ts b/packages/extension/src/providers/polkadot/networks/westend.ts index 51ef1b9f6..bb621835f 100644 --- a/packages/extension/src/providers/polkadot/networks/westend.ts +++ b/packages/extension/src/providers/polkadot/networks/westend.ts @@ -19,7 +19,6 @@ const wndOptions: SubstrateNetworkOptions = { icon: require("./icons/westend.svg"), decimals: 12, prefix: 42, - gradient: "linear-gradient(180deg, #C549FF 0%, #684CFF 100%)", node: "wss://westend-rpc.dwellir.com", genesisHash: "0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e", diff --git a/packages/extension/src/providers/polkadot/types/substrate-network.ts b/packages/extension/src/providers/polkadot/types/substrate-network.ts index cb9ff5bf4..c597163b3 100644 --- a/packages/extension/src/providers/polkadot/types/substrate-network.ts +++ b/packages/extension/src/providers/polkadot/types/substrate-network.ts @@ -31,7 +31,6 @@ export interface SubstrateNetworkOptions { icon: string; decimals: number; prefix: number; - gradient: string; node: string; coingeckoID?: string; coingeckoPlatform?: CoingeckoPlatform; diff --git a/packages/extension/src/scripts/contentscript.ts b/packages/extension/src/scripts/contentscript.ts index 19d9f8d5f..a9380a190 100644 --- a/packages/extension/src/scripts/contentscript.ts +++ b/packages/extension/src/scripts/contentscript.ts @@ -1,22 +1,17 @@ import browser from "webextension-polyfill"; -import { - setContentScriptNamespace, - sendToBackgroundFromCS, -} from "@/libs/messenger/extension"; -import { InjectedIDs, InternalMethods } from "@/types/messenger"; -import { ProviderName } from "@/types/provider"; +import { setContentScriptNamespace } from "@/libs/messenger/extension"; +import { InjectedIDs } from "@/types/messenger"; setContentScriptNamespace(); -function injectScript(settings: string) { - settings = encodeURIComponent(settings); +function injectScript() { try { const injectURL = browser.runtime.getURL("scripts/inject.js"); const container = document.head || document.documentElement; const scriptTag = document.createElement("script"); scriptTag.setAttribute("async", "false"); - scriptTag.src = `${injectURL}?settings=${settings}`; + scriptTag.src = injectURL; scriptTag.id = InjectedIDs.main; scriptTag.onload = function () { - console.info("Hello from the content-script"); + console.info("Enkrypt: Hello from CS"); container.removeChild(scriptTag); }; container.insertBefore(scriptTag, container.children[0]); @@ -25,11 +20,5 @@ function injectScript(settings: string) { console.error("Enkrypt: Provider injection failed.", error); } } -sendToBackgroundFromCS({ - message: JSON.stringify({ method: InternalMethods.getSettings, params: [] }), - provider: ProviderName.enkrypt, -}).then((res) => { - if (res.result) { - injectScript(res.result); - } -}); + +injectScript(); diff --git a/packages/extension/src/scripts/inject.ts b/packages/extension/src/scripts/inject.ts index 6f6f3e835..cc1a98631 100644 --- a/packages/extension/src/scripts/inject.ts +++ b/packages/extension/src/scripts/inject.ts @@ -8,15 +8,32 @@ import EthereumProvider from "@/providers/ethereum/inject"; import PolkadotProvider from "@/providers/polkadot/inject"; import BitcoinProvider from "@/providers/bitcoin/inject"; -import { InternalMethods, InjectedIDs } from "@/types/messenger"; +import { InternalMethods } from "@/types/messenger"; + setWindowNamespace(); (window as Window).enkrypt = { providers: {}, settings: {}, }; -const script = document.getElementById(InjectedIDs.main) as HTMLScriptElement; -const scriptURL = new URL(script.src); -window.enkrypt.settings = JSON.parse(scriptURL.searchParams.get("settings")!); +const loadInjectedProviders = () => { + EthereumProvider(window, { + name: ProviderName.ethereum, + type: ProviderType.evm, + sendMessageHandler: providerSendMessage, + }); + PolkadotProvider(window, { + name: ProviderName.polkadot, + type: ProviderType.substrate, + sendMessageHandler: providerSendMessage, + }); + BitcoinProvider(window, { + name: ProviderName.bitcoin, + type: ProviderType.bitcoin, + sendMessageHandler: providerSendMessage, + }); +}; + +loadInjectedProviders(); windowOnMessage(async (msg): Promise => { window["enkrypt"]["providers"][msg.provider].handleMessage(msg.message); @@ -33,19 +50,4 @@ window.addEventListener("beforeunload", () => { JSON.stringify({ method: InternalMethods.newWindowUnload }) ); }); -console.info("hello from injected code"); -EthereumProvider(window, { - name: ProviderName.ethereum, - type: ProviderType.evm, - sendMessageHandler: providerSendMessage, -}); -PolkadotProvider(window, { - name: ProviderName.polkadot, - type: ProviderType.substrate, - sendMessageHandler: providerSendMessage, -}); -BitcoinProvider(window, { - name: ProviderName.bitcoin, - type: ProviderType.bitcoin, - sendMessageHandler: providerSendMessage, -}); +console.info("Enkrypt: Hello from IN"); diff --git a/packages/extension/src/types/base-network.ts b/packages/extension/src/types/base-network.ts index 837db891c..dbfd51fd5 100644 --- a/packages/extension/src/types/base-network.ts +++ b/packages/extension/src/types/base-network.ts @@ -19,7 +19,6 @@ export interface BaseNetworkOptions { icon: string; decimals: number; signer: SignerType[]; - gradient: string; node: string; displayAddress: (address: string, chainId?: BNLike) => string; provider: ProviderName; @@ -42,7 +41,6 @@ export abstract class BaseNetwork { public currencyNameLong: string; public icon: string; public signer: SignerType[]; - public gradient: string; public node: string; public displayAddress: (address: string, chainId?: BNLike) => string; public provider: ProviderName; @@ -67,7 +65,6 @@ export abstract class BaseNetwork { this.currencyName = options.currencyName; this.icon = options.icon; this.signer = options.signer; - this.gradient = options.gradient; this.node = options.node; this.displayAddress = options.displayAddress; this.provider = options.provider; diff --git a/packages/extension/src/types/provider.ts b/packages/extension/src/types/provider.ts index acbb0dc0a..4ff1c9206 100644 --- a/packages/extension/src/types/provider.ts +++ b/packages/extension/src/types/provider.ts @@ -154,7 +154,6 @@ export interface NodeType { currencyName: string; icon: any; signer: SignerType[]; - gradient: string; node: string; displayAddress: (address: string) => string; api?: () => Promise; diff --git a/packages/extension/src/ui/action/App.vue b/packages/extension/src/ui/action/App.vue index dfd3a5499..f1996f7de 100644 --- a/packages/extension/src/ui/action/App.vue +++ b/packages/extension/src/ui/action/App.vue @@ -16,6 +16,7 @@ :search-input="searchInput" @update:order="updateNetworkOrder" @update:network="setNetwork" + @update:gradient="updateGradient" />