Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-assethub
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Apr 2, 2024
2 parents c2bc3e2 + 5ff4758 commit 81981f1
Show file tree
Hide file tree
Showing 26 changed files with 57 additions and 40 deletions.
1 change: 1 addition & 0 deletions packages/extension/configs/rollup.config.base.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const base = {
replace({
preventAssignment: true,
__VERSION__: JSON.stringify(packageJson.version),
__IS_OPERA__: process.env.BROWSER === "opera-edge",
}),
typescript(),
commonjs(),
Expand Down
1 change: 1 addition & 0 deletions packages/extension/configs/testNullCompiler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const noop = () => 1;
global.__VERSION__ = "test";
global.__IS_OPERA__ = false;
require.extensions[".css"] = noop;
require.extensions[".scss"] = noop;
require.extensions[".png"] = noop;
Expand Down
4 changes: 2 additions & 2 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@enkryptcom/extension",
"version": "1.36.0",
"version": "1.37.1",
"private": true,
"scripts": {
"zip": "cd dist; zip -r release.zip *;",
"build:chrome": "cross-env BROWSER='chrome' vue-cli-service build && yarn build:rollup",
"build:operaedge": "cross-env BROWSER='opera-edge' vue-cli-service build && yarn build:rollup",
"build:operaedge": "cross-env BROWSER='opera-edge' vue-cli-service build && cross-env BROWSER='opera-edge' yarn build:rollup",
"build:firefox": "cross-env BROWSER='firefox' vue-cli-service build && yarn build:rollup && node configs/get-system-info.js",
"lint": "vue-cli-service lint --fix",
"build:rollup": "cross-env minify=on rollup --config configs/rollup.config.contentscript.mjs && cross-env minify=on rollup --config configs/rollup.config.inject.mjs",
Expand Down
7 changes: 5 additions & 2 deletions packages/extension/src/libs/metrics/amplitude.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { init, track, Types } from "@amplitude/analytics-browser";
import { init, track, Types, setOptOut } from "@amplitude/analytics-browser";
import { detectBrowser, detectOS } from "@action/utils/browser";
import SettingsState from "../settings-state";

Expand Down Expand Up @@ -32,7 +32,7 @@ class Metrics {
instanceName: process.env.IS_DEV
? "enkrypt-extension-dev"
: "enkrypt-extension",
optOut: false,
optOut: !set.isMetricsEnabled,
serverUrl: process.env.IS_DEV
? "https://analytics-enkrypt-dev.mewwallet.dev/record"
: "https://analytics-enkrypt.mewwallet.dev/record",
Expand Down Expand Up @@ -63,6 +63,9 @@ class Metrics {
}
);
}
setOptOut(val: boolean) {
setOptOut(val);
}
}

export default Metrics;
12 changes: 12 additions & 0 deletions packages/extension/src/libs/metrics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
NFTEventType,
NetworkChangeEvents,
SendEventType,
SettingEventType,
SwapEventType,
} from "./types";

Expand Down Expand Up @@ -68,11 +69,22 @@ const trackDAppsEvents = (
) => {
metrics.track("dapps", { event, ...options });
};

const optOutofMetrics = (optOut: boolean) => {
metrics.setOptOut(false);
metrics.track("settings", {
event: SettingEventType.OptOut,
value: optOut ? 1 : 0,
});
metrics.setOptOut(optOut);
};

export {
trackNetworkSelected,
trackSwapEvents,
trackBuyEvents,
trackSendEvents,
trackNFTEvents,
trackDAppsEvents,
optOutofMetrics,
};
4 changes: 4 additions & 0 deletions packages/extension/src/libs/metrics/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ export enum NFTEventType {
export enum DAppsEventType {
DAppsOpen = "dapps_open",
}

export enum SettingEventType {
OptOut = "opt_out",
}
1 change: 0 additions & 1 deletion packages/extension/src/libs/nft-handlers/simplehash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default async (
[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))
Expand Down
1 change: 1 addition & 0 deletions packages/extension/src/libs/settings-state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class SettingsState {
const settings: EnkryptSettingsType = {
installedTimestamp: 0,
randomUserID: "",
isMetricsEnabled: true,
};
return merge(settings, state);
}
Expand Down
1 change: 1 addition & 0 deletions packages/extension/src/libs/settings-state/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface BtcSettingsType {
export interface EnkryptSettingsType {
installedTimestamp: number;
randomUserID: string;
isMetricsEnabled: boolean;
}
export interface SettingsType {
evm: EVMSettingsType;
Expand Down
3 changes: 3 additions & 0 deletions packages/extension/src/providers/ethereum/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ const injectDocument = (
const provider = new Provider(options);
const proxiedProvider = new Proxy(provider, ProxyHandler);
document["enkrypt"]["providers"][options.name] = provider;
if (__IS_OPERA__) {
document[options.name] = proxiedProvider; // Opera expects you to inject immediatly and their wallet switcher will handle conflicts
}
options
.sendMessageHandler(
ProviderName.enkrypt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { NetworkNames } from "@enkryptcom/types";

const NetworkEndpoints: Record<string, string> = {
[NetworkNames.Ethereum]: "https://api.etherscan.io/",
[NetworkNames.Goerli]: "https://api-goerli.etherscan.io/",
[NetworkNames.Binance]: "https://api.bscscan.com/",
[NetworkNames.Matic]: "https://api.polygonscan.com/",
[NetworkNames.Moonbeam]: "https://api-moonbeam.moonscan.io/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { NetworkNames } from "@enkryptcom/types";
const NetworkEndpoints = {
[NetworkNames.Ethereum]: "https://nodes.mewapi.io/rpc/eth",
[NetworkNames.Sepolia]: "https://nodes.mewapi.io/rpc/sepolia",
[NetworkNames.Goerli]: "https://nodes.mewapi.io/rpc/goerli",
[NetworkNames.EthereumClassic]: "https://nodes.mewapi.io/rpc/etc",
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const formTestnetOptions: EvmNetworkOptions = {
currencyName: "ETH",
currencyNameLong: "Ethereum",
node: "wss://testnet-rpc.form.network/ws",
icon: require("./icons/eth.svg"),
icon: require("./icons/form.png"),
activityHandler: wrapActivityHandler(EtherscanActivity),
};

Expand Down
25 changes: 0 additions & 25 deletions packages/extension/src/providers/ethereum/networks/goerli.ts

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions packages/extension/src/providers/ethereum/networks/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ethNode from "./eth";
import goerliNode from "./goerli";
import etcNode from "./etc";
import maticNode from "./matic";
import maticZkNode from "./maticzk";
Expand Down Expand Up @@ -35,7 +34,6 @@ import formTestnet from "./form-testnet";
import artheraTestNode from "./aat";

export default {
goerli: goerliNode,
sepolia: sepoliaNode,
ethereum: ethNode,
etc: etcNode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const defaultSettings = {
enkrypt: {
installedTimestamp: 0,
randomUserID: "",
isMetricsEnabled: true,
},
manifestVersion: 3,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const defaultSettings = {
enkrypt: {
installedTimestamp: 0,
randomUserID: "",
isMetricsEnabled: true,
},
manifestVersion: 3,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const tempWindow: EnkryptWindow = {
enkrypt: {
installedTimestamp: 0,
randomUserID: "",
isMetricsEnabled: true,
},
manifestVersion: 3,
},
Expand Down
1 change: 1 addition & 0 deletions packages/extension/src/types/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
declare module "*.vue";
declare module "vue3-lottie";
declare const __VERSION__: string;
declare const __IS_OPERA__: boolean;
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
<p>Enable Enkrypt act like Unisat wallet for dapps</p>
</div>

<settings-switch
title="Disable Amplitude Events"
:is-checked="!isMetricsEnabled"
@update:check="toggleMetricsEnabled"
/>
<div class="settings__label">
<p>
MEW uses Amplitude events to improve Enkrypt. No identifiable
information is collected.
</p>
</div>

<!-- <base-select
:select="selecTimer"
title="Auto-lock timer"
Expand All @@ -58,16 +70,19 @@ import SettingsInnerHeader from "@action/views/settings/components/settings-inne
import SettingsSwitch from "@action/views/settings/components/settings-switch.vue";
import SettingsState from "@/libs/settings-state";
import { SettingsType } from "@/libs/settings-state/types";
import { optOutofMetrics } from "@/libs/metrics";
const settingsState = new SettingsState();
const isEthereumDisabled = ref(false);
const isPolkadotjsDisabled = ref(false);
const isUnisatEnabled = ref(true);
const isMetricsEnabled = ref(true);
onMounted(async () => {
const allSettings: SettingsType = await settingsState.getAllSettings();
isEthereumDisabled.value = allSettings.evm.inject.disabled;
isPolkadotjsDisabled.value = !allSettings.substrate.injectPolkadotjs;
isUnisatEnabled.value = allSettings.btc.injectUnisat;
isMetricsEnabled.value = allSettings.enkrypt.isMetricsEnabled;
});
const toggleEthereumDisable = async (isChecked: boolean) => {
const evmSettings = await settingsState.getEVMSettings();
Expand All @@ -87,6 +102,12 @@ const toggleUnisatEnable = async (isChecked: boolean) => {
btcSettings.injectUnisat = isChecked;
await settingsState.setBtcSettings(btcSettings);
};
const toggleMetricsEnabled = async (isChecked: boolean) => {
const enkryptSettings = await settingsState.getEnkryptSettings();
enkryptSettings.isMetricsEnabled = !isChecked;
await settingsState.setEnkryptSettings(enkryptSettings);
optOutofMetrics(isChecked);
};
</script>

<style lang="less">
Expand Down
1 change: 0 additions & 1 deletion packages/hw-wallets/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const ledgerAppNames = {
[NetworkNames.Binance]: "Ethereum",
[NetworkNames.Rootstock]: "RSK",
[NetworkNames.EthereumClassic]: "Ethereum Classic",
[NetworkNames.Goerli]: "Ethereum",
[NetworkNames.Acala]: "Acala",
[NetworkNames.Kusama]: "Kusama",
[NetworkNames.Polkadot]: "Polkadot",
Expand Down
1 change: 0 additions & 1 deletion packages/hw-wallets/src/ledger/ethereum/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ const supportedPaths = {
bip44Paths.ethereumLedger,
bip44Paths.ethereumLedgerLive,
],
[NetworkNames.Goerli]: [bip44Paths.ethereumTestnetLedger],
};
export { supportedPaths };
1 change: 0 additions & 1 deletion packages/hw-wallets/src/trezor/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const supportedPaths = {
[NetworkNames.Avalanche]: [bip44Paths.ethereum],
[NetworkNames.Binance]: [bip44Paths.ethereum],
[NetworkNames.EthereumClassic]: [bip44Paths.ethereumClassic],
[NetworkNames.Goerli]: [bip44Paths.ethereumTestnet],
[NetworkNames.Rootstock]: [bip44Paths.rootstock],
};
export { supportedPaths };
2 changes: 1 addition & 1 deletion packages/swap/tests/rango.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe("Rango Provider", () => {
);
expect(quote?.fromTokenAmount.toString()).to.be.eq(amount.toString());
expect(quote?.toTokenAmount.gtn(0)).to.be.eq(true);
expect(quote?.additionalNativeFees.eqn(0)).to.be.eq(true);
expect(quote?.additionalNativeFees.eqn(0)).to.be.eq(false);
const swap = await rango.getSwap(quote!.quote);
expect(swap?.transactions.length).to.be.eq(1);
}).timeout(25000);
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export enum NetworkNames {
Okc = "OKT",
Binance = "BNB",
EthereumClassic = "ETC",
Goerli = "GOERLI",
Sepolia = "SEPOLIA",
Matic = "MATIC",
MaticZK = "MATICZK",
Expand Down

1 comment on commit 81981f1

@github-actions
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.