Skip to content

Commit

Permalink
Merge pull request #618 from enkryptcom/devop/fix-new-networks
Browse files Browse the repository at this point in the history
fix: new networks automatic pinning
  • Loading branch information
olgakup authored Feb 18, 2025
2 parents 2d1f27d + 26cf299 commit 8a35cde
Show file tree
Hide file tree
Showing 29 changed files with 4,231 additions and 4,234 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
"prepare": "husky"
},
"devDependencies": {
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@swc/core": "^1.9.2",
"concurrently": "^9.1.0",
"husky": "^9.1.6",
"@commitlint/cli": "^19.7.1",
"@commitlint/config-conventional": "^19.7.1",
"@swc/core": "^1.10.14",
"concurrently": "^9.1.2",
"husky": "^9.1.7",
"node-notifier": "^10.0.1",
"nodemon": "^3.1.7",
"nodemon": "^3.1.9",
"ultra-runner": "^3.10.5"
},
"resolutions": {
Expand Down
18 changes: 9 additions & 9 deletions packages/extension-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,28 @@
],
"dependencies": {
"nanoevents": "^9.1.0",
"serialize-error": "11.0.3",
"serialize-error": "12.0.0",
"tiny-uid": "^1.1.2",
"webextension-polyfill": "^0.12.0"
},
"devDependencies": {
"@types/node": "^22.9.0",
"@types/node": "^22.13.1",
"@types/webextension-polyfill": "^0.12.1",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"bumpp": "^9.8.1",
"eslint": "^9.14.0",
"bumpp": "^10.0.2",
"eslint": "^9.20.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-module-resolver": "^1.5.0",
"prettier": "^3.3.3",
"prettier": "^3.4.2",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"tsup": "^8.3.5",
"type-fest": "^4.26.1",
"typescript": "^5.6.3",
"typescript-eslint": "8.14.0"
"tsup": "^8.3.6",
"type-fest": "^4.33.0",
"typescript": "^5.7.3",
"typescript-eslint": "8.23.0"
}
}
4 changes: 4 additions & 0 deletions packages/extension/configs/vite/empty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const readFileSync = () => {};
const writeFileSync = () => {};

export { readFileSync, writeFileSync };
14 changes: 7 additions & 7 deletions packages/extension/configs/vite/transform-manifest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CrxPlugin } from '@crxjs/vite-plugin'
import { CrxPlugin } from '@crxjs/vite-plugin';

function transFormManifest(): CrxPlugin {
return {
Expand All @@ -17,15 +17,15 @@ function transFormManifest(): CrxPlugin {
js: ['vendor/trezor-content-script.js'],
run_at: 'document_start',
},
] as any
] as any;
if (process.env.BROWSER !== 'opera') {
manifest.content_scripts?.push({
matches: ['file://*/*', 'http://*/*', 'https://*/*'],
js: ['scripts/inject.js'],
run_at: 'document_start',
all_frames: false,
world: 'MAIN',
} as any)
} as any);
}
manifest.web_accessible_resources?.push({
resources: [
Expand All @@ -35,9 +35,9 @@ function transFormManifest(): CrxPlugin {
],
use_dynamic_url: false,
matches: ['file://*/*', 'http://*/*', 'https://*/*'],
})
return manifest
});
return manifest;
},
}
};
}
export default transFormManifest
export default transFormManifest;
122 changes: 61 additions & 61 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@enkryptcom/extension",
"version": "2.2.0",
"version": "2.3.0",
"private": true,
"type": "module",
"scripts": {
Expand All @@ -23,7 +23,7 @@
"watch:firefox": "yarn prebuild && cross-env BROWSER='firefox' vite"
},
"dependencies": {
"@amplitude/analytics-browser": "^2.11.9",
"@amplitude/analytics-browser": "^2.11.11",
"@enkryptcom/extension-bridge": "workspace:^",
"@enkryptcom/hw-wallets": "workspace:^",
"@enkryptcom/keyring": "workspace:^",
Expand All @@ -35,51 +35,51 @@
"@ethereumjs/common": "^4.4.0",
"@ethereumjs/tx": "^5.4.0",
"@ethereumjs/util": "^9.1.0",
"@kadena/client": "^1.15.0",
"@kadena/pactjs-cli": "^1.15.0",
"@ethereumjs/wallet": "^2.0.4",
"@kadena/client": "^1.16.0",
"@kadena/pactjs-cli": "^1.16.0",
"@ledgerhq/hw-transport-webusb": "^6.29.4",
"@metamask/eth-sig-util": "^7.0.3",
"@metaplex-foundation/mpl-bubblegum": "^4.2.1",
"@metaplex-foundation/umi": "^0.9.2",
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
"@polkadot/api": "^14.3.1",
"@polkadot/extension-inject": "^0.56.2",
"@polkadot/keyring": "^13.2.3",
"@polkadot/rpc-provider": "^14.3.1",
"@polkadot/types": "^14.3.1",
"@polkadot/types-known": "^14.3.1",
"@polkadot/ui-shared": "^3.11.3",
"@polkadot/util": "^13.2.3",
"@metamask/eth-sig-util": "^8.2.0",
"@metaplex-foundation/mpl-bubblegum": "^4.3.1",
"@metaplex-foundation/umi": "^1.0.0",
"@metaplex-foundation/umi-bundle-defaults": "^1.0.0",
"@polkadot/api": "^15.5.2",
"@polkadot/extension-inject": "^0.58.3",
"@polkadot/keyring": "^13.3.1",
"@polkadot/rpc-provider": "^15.5.2",
"@polkadot/types": "^15.5.2",
"@polkadot/types-known": "^15.5.2",
"@polkadot/ui-shared": "^3.12.1",
"@polkadot/util": "^13.3.1",
"@polkadot/wasm-crypto": "^7.4.1",
"@solana-developers/helpers": "^2.5.6",
"@solana/spl-token": "^0.4.9",
"@solana/wallet-standard-features": "^1.2.0",
"@solana/web3.js": "^1.95.4",
"@wallet-standard/base": "^0.0.0-20240703212708",
"@solana-developers/helpers": "^2.7.0",
"@solana/spl-token": "^0.4.12",
"@solana/wallet-standard-features": "^1.3.0",
"@solana/web3.js": "^1.98.0",
"@wallet-standard/base": "^1.1.0",
"add": "^2.0.6",
"bignumber.js": "^9.1.2",
"bip39": "^3.1.0",
"bitcoinjs-lib": "^6.1.6",
"bitcoinjs-lib": "^6.1.7",
"bs58": "^6.0.0",
"concurrently": "^9.1.0",
"echarts": "^5.5.1",
"concurrently": "^9.1.2",
"echarts": "^5.6.0",
"ethereum-cryptography": "^2.2.1",
"ethereumjs-abi": "^0.6.8",
"ethereumjs-wallet": "^1.0.2",
"eventemitter3": "^5.0.1",
"lodash": "^4.17.21",
"memoize-one": "^6.0.0",
"moment": "^2.30.1",
"nanoevents": "^9.1.0",
"pact-lang-api": "^4.3.6",
"pinia": "^2.2.6",
"pinia": "^2.3.1",
"qrcode.vue": "^3.6.0",
"switch-ts": "^1.1.1",
"url-parse": "^1.5.10",
"uuid": "^10.0.0",
"vue": "^3.5.12",
"uuid": "^11.0.5",
"vue": "^3.5.13",
"vue-echarts": "7.0.3",
"vue-router": "^4.4.5",
"vue-router": "^4.5.0",
"vue3-lottie": "^3.3.1",
"vuedraggable": "^4.1.0",
"web3-eth": "^1.10.4",
Expand All @@ -88,55 +88,55 @@
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"@crxjs/vite-plugin": "^2.0.0-beta.26",
"@rollup/plugin-commonjs": "^28.0.1",
"@crxjs/vite-plugin": "^2.0.0-beta.31",
"@rollup/plugin-commonjs": "^28.0.2",
"@rollup/plugin-inject": "^5.0.5",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-replace": "^6.0.1",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-replace": "^6.0.2",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.1",
"@rollup/plugin-typescript": "^12.1.2",
"@tsconfig/node20": "^20.1.4",
"@types/bs58": "^4.0.4",
"@types/chrome": "^0.0.280",
"@types/chrome": "^0.0.302",
"@types/ethereumjs-abi": "^0.6.5",
"@types/events": "^3.0.3",
"@types/fs-extra": "^11.0.4",
"@types/less": "^3.0.6",
"@types/lodash": "^4.17.13",
"@types/node": "^22.9.0",
"@types/less": "^3.0.8",
"@types/lodash": "^4.17.15",
"@types/node": "^22.13.1",
"@types/url-parse": "^1.4.11",
"@types/utf-8-validate": "^5.0.2",
"@types/uuid": "^10.0.0",
"@types/wif": "^2.0.5",
"@types/zxcvbn": "^4.4.5",
"@vitejs/plugin-vue": "^5.1.5",
"@vue/eslint-config-prettier": "^10.1.0",
"@vue/eslint-config-typescript": "^14.1.3",
"@vue/tsconfig": "^0.6.0",
"@vueuse/core": "^11.2.0",
"@vitejs/plugin-vue": "^5.2.1",
"@vue/eslint-config-prettier": "^10.2.0",
"@vue/eslint-config-typescript": "^14.3.0",
"@vue/tsconfig": "^0.7.0",
"@vueuse/core": "^12.5.0",
"cross-env": "^7.0.3",
"eslint": "^9.14.0",
"eslint-plugin-vue": "^9.31.0",
"fs-extra": "^11.2.0",
"jsdom": "^25.0.1",
"less": "^4.2.0",
"eslint": "^9.20.0",
"eslint-plugin-vue": "^9.32.0",
"fs-extra": "^11.3.0",
"jsdom": "^26.0.0",
"less": "^4.2.2",
"less-loader": "^12.2.0",
"npm-run-all2": "^6.2.6",
"prettier": "^3.3.3",
"npm-run-all2": "^7.0.2",
"prettier": "^3.4.2",
"rimraf": "^6.0.1",
"rollup": "^4.25.0",
"rollup-plugin-visualizer": "^5.12.0",
"semver": "^7.6.3",
"systeminformation": "^5.23.5",
"tsup": "^8.3.5",
"typescript": "~5.6.3",
"rollup": "^4.34.6",
"rollup-plugin-visualizer": "^5.14.0",
"semver": "^7.7.1",
"systeminformation": "^5.25.11",
"tsup": "^8.3.6",
"typescript": "~5.7.3",
"url": "^0.11.4",
"vite": "^5.4.11",
"vite-plugin-node-polyfills": "0.17.0",
"vite-tsconfig-paths": "^5.1.2",
"vitest": "^2.1.4",
"vue-tsc": "^2.1.10",
"vite": "^6.1.0",
"vite-plugin-node-polyfills": "0.23.0",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.0.5",
"vue-tsc": "^2.2.0",
"webextension-polyfill": "^0.12.0"
},
"installConfig": {
Expand Down
44 changes: 0 additions & 44 deletions packages/extension/src/libs/networks-state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import BrowserStorage from '../common/browser-storage';
import { POPULAR_NAMES } from '../utils/networks';
import { InternalStorageNamespace } from '@/types/provider';
import { IState, StorageKeys, NetworkStorageElement } from './types';
import { newNetworks, newSwaps } from '@/providers/common/libs/new-features';

class NetworksState {
private storage: BrowserStorage;
Expand Down Expand Up @@ -53,47 +52,6 @@ class NetworksState {
await this.setState(state);
}

/**
* Inserts networks with new features.
*
* This method first retrieves the current state and checks if the networks
* have been updated to the latest version. If the state and networks are defined,
* it filters out the networks that are not in the predefined list of networks with new features.
* It then maps the filtered networks to a new network item and inserts them into the valid networks.
* The new networks are inserted at the 6th index, or at the end if there are fewer than 6 networks.
* The state is then updated with the new networks and the latest version.
*/
async insertNetworksWithNewFeatures(): Promise<void> {
const state: IState | undefined = await this.getState();
if (
state &&
state.networks &&
state.newNetworksVersion !== __PACKAGE_VERSION__
) {
let validNetworks = state.networks;
const netsWithFeatures = [
...new Set([...newNetworks, ...newSwaps]),
].sort();
const filteredNets = netsWithFeatures.filter(n => {
for (const vn of validNetworks) if (vn.name === n) return false;
return true;
});
const fnetworkItem = filteredNets.map(name => {
return {
name,
};
});
const insertIdx = validNetworks.length > 5 ? 5 : validNetworks.length;
validNetworks = validNetworks
.slice(0, insertIdx)
.concat(fnetworkItem, validNetworks.slice(insertIdx));
state.networks = validNetworks;
state.newNetworksVersion = __PACKAGE_VERSION__ as string;
state.newUsedFeatures = { networks: [], swap: [] };
await this.setState(state);
}
}

async setUsedFeature(feature: 'networks' | 'swap', networkName: string) {
const state: IState | undefined = await this.getState();
if (state) {
Expand Down Expand Up @@ -127,7 +85,6 @@ class NetworksState {
* @returns {Promise<string[]>} A promise that resolves to an array of active network names.
*/
async getPinnedNetworkNames(): Promise<string[]> {
await this.insertNetworksWithNewFeatures();
const state: IState | undefined = await this.getState();
if (state && state.networks) {
const validNetworks = state.networks;
Expand All @@ -139,7 +96,6 @@ class NetworksState {
}

async getEnabledTestNetworks(): Promise<string[]> {
await this.insertNetworksWithNewFeatures();
const state: IState | undefined = await this.getState();
if (state && state.enabledTestNetworks) {
const validNetworks = state.enabledTestNetworks;
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/providers/ethereum/networks/ftm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const ftmOptions: EvmNetworkOptions = {
isTestNetwork: false,
currencyName: 'FTM',
currencyNameLong: 'Fantom',
node: 'https://rpc.ankr.com/fantom/',
node: 'wss://fantom-rpc.publicnode.com',
icon,
coingeckoID: 'fantom',
coingeckoPlatform: CoingeckoPlatform.Fantom,
Expand Down
3 changes: 1 addition & 2 deletions packages/extension/src/ui/action/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import Vue3Lottie from 'vue3-lottie';
global.WeakMap = WeakMap;

if (import.meta.env.DEV) {
globalThis.__ENKRYPT_DEBUG_LOG_CONF__ = import.meta.env.VITE_DEBUG_LOG
globalThis.__ENKRYPT_DEBUG_LOG_CONF__ = import.meta.env.VITE_DEBUG_LOG;
}


const app = createApp(App);

app.use(router).use(Vue3Lottie, { name: 'vue3lottie' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { computed, PropType, ref } from 'vue';
import ImportAccountHeader from '../components/import-account-header.vue';
import BaseInput from '@action/components/base-input/index.vue';
import BaseButton from '@action/components/base-button/index.vue';
import Wallet, { thirdparty } from 'ethereumjs-wallet';
import { Wallet, thirdparty } from '@ethereumjs/wallet';
import type { KeyringPair$Json } from '@polkadot/keyring/types';
import { BaseNetwork } from '@/types/base-network';
import { ProviderName } from '@/types/provider';
Expand Down Expand Up @@ -113,7 +113,7 @@ const unlock = async () => {
props.keystorePassword,
);
const newAddress = `0x${wallet.getAddress().toString('hex')}`;
const newAddress = wallet.getAddressString();
if (await keyring.accountAlreadyAdded(newAddress)) {
error.value = 'This account has already been added';
Expand Down
Loading

0 comments on commit 8a35cde

Please sign in to comment.