Skip to content

Commit

Permalink
devop: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed May 6, 2024
2 parents 4603ad5 + a4e8e3f commit e479489
Show file tree
Hide file tree
Showing 112 changed files with 7,808 additions and 354 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Enkrypt is a web3 wallet built from the ground up to support the multi-chain fut
- Ontology
- Puppy Net
- Arthera
- Caga Ankara Testnet
- More coming soon!

Looking to add your project? [Contact us!](https://mewwallet.typeform.com/enkrypt-inquiry?typeform-source=www.enkrypt.com)
Expand Down
19 changes: 12 additions & 7 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
{
"name": "@enkryptcom/extension",
"version": "1.38.0",
"version": "1.39.0",
"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 && 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",
"build:safari": "cross-env BROWSER='safari' vue-cli-service build && yarn build:rollup",
"prebuild": "yarn kadena:prebuild",
"build:chrome": "yarn prebuild && cross-env BROWSER='chrome' vue-cli-service build && yarn build:rollup",
"build:firefox": "yarn prebuild && cross-env BROWSER='firefox' vue-cli-service build && yarn build:rollup && node configs/get-system-info.js",
"build:operaedge": "yarn prebuild && cross-env BROWSER='opera-edge' vue-cli-service build && cross-env BROWSER='opera-edge' yarn build:rollup",
"build:safari": "yarn prebuild && cross-env BROWSER='safari' vue-cli-service build && yarn build:rollup",
"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",
"inspectWebpack": "vue-cli-service inspect > webpack.log",
"kadena:prebuild": "pactjs contract-generate --contract=coin --api https://api.chainweb.com/chainweb/0.0/mainnet01/chain/1/pact",
"test": "ts-mocha --require ./configs/testNullCompiler.js --paths -p configs/tsconfig.test.json ./**/*.mocha.ts",
"watch": "rimraf dist && concurrently 'npm:watch-*(!firefox)'",
"watch:firefox": "concurrently 'npm:watch-*(!chrome)'",
"watch": "yarn prebuild && rimraf dist && concurrently 'npm:watch-*(!firefox)'",
"watch:firefox": "yarn prebuild && concurrently 'npm:watch-*(!chrome)'",
"watch-contentscript": "rollup --watch --config configs/rollup.config.contentscript.mjs",
"watch-inject": "rollup --watch --config configs/rollup.config.inject.mjs",
"watch-vue-chrome": "cross-env BROWSER='chrome' vue-cli-service build --watch --no-clean",
Expand All @@ -33,6 +35,7 @@
"@ethereumjs/common": "^4.3.0",
"@ethereumjs/tx": "^5.3.0",
"@ethereumjs/util": "^9.0.3",
"@kadena/client": "^1.2.0",
"@ledgerhq/hw-transport-webusb": "^6.28.5",
"@metamask/eth-sig-util": "^7.0.1",
"@rollup/plugin-replace": "^5.0.5",
Expand All @@ -58,6 +61,7 @@
"memoize-one": "^6.0.0",
"moment": "^2.30.1",
"nanoevents": "^9.0.0",
"pact-lang-api": "^4.3.6",
"pinia": "^2.1.7",
"qrcode.vue": "^3.4.1",
"switch-ts": "^1.1.1",
Expand All @@ -75,6 +79,7 @@
},
"devDependencies": {
"@babel/plugin-transform-class-static-block": "^7.24.1",
"@kadena/pactjs-cli": "^1.7.0",
"@polkadot/api": "^10.12.4",
"@polkadot/extension-inject": "^0.46.9",
"@polkadot/keyring": "^12.6.2",
Expand Down
1 change: 1 addition & 0 deletions packages/extension/src/libs/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class BackgroundHandler {
[ProviderName.ethereum]: {},
[ProviderName.polkadot]: {},
[ProviderName.bitcoin]: {},
[ProviderName.kadena]: {},
};
this.#providers = Providers;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/extension/src/libs/background/types.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import BitcoinProvider from "@/providers/bitcoin";
import type EthereumProvider from "@/providers/ethereum";
import type PolkadotProvider from "@/providers/polkadot";
import type KadenaProvider from "@/providers/kadena";

export interface TabProviderType {
[key: string]: Record<
number,
EthereumProvider | PolkadotProvider | BitcoinProvider
EthereumProvider | PolkadotProvider | BitcoinProvider | KadenaProvider
>;
}
export interface ProviderType {
[key: string]:
| typeof EthereumProvider
| typeof PolkadotProvider
| typeof BitcoinProvider;
| typeof BitcoinProvider
| typeof KadenaProvider;
}
export interface ExternalMessageOptions {
savePersistentEvents: boolean;
Expand Down
10 changes: 10 additions & 0 deletions packages/extension/src/libs/domain-state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ class DomainState {
if (state.selectedNetwork) return state.selectedNetwork;
return null;
}
async setSelectedSubNetwork(id: string): Promise<void> {
const state = await this.getState();
state.selectedSubNetworkId = id;
await this.setState(state);
}
async getSelectedSubNetWork(): Promise<string | null> {
const state = await this.getState();
if (state.selectedSubNetworkId) return state.selectedSubNetworkId;
return null;
}
async setSelectedAddress(address: string): Promise<void> {
const state = await this.getState();
state.selectedAddress = address;
Expand Down
1 change: 1 addition & 0 deletions packages/extension/src/libs/domain-state/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export enum StorageKeys {
}
export interface IState {
selectedNetwork?: string;
selectedSubNetworkId?: string;
selectedAddress?: string;
}
6 changes: 6 additions & 0 deletions packages/extension/src/libs/metrics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Metrics from "./amplitude";
import {
BuyEventType,
DAppsEventType,
GenericEvents,
NFTEventType,
NetworkChangeEvents,
SendEventType,
Expand All @@ -13,6 +14,10 @@ import {

const metrics = new Metrics();

const trackGenericEvents = (event: GenericEvents) => {
metrics.track("generic", { event });
};

const trackNetworkSelected = (
event: NetworkChangeEvents,
options: { provider: ProviderName; network: NetworkNames }
Expand Down Expand Up @@ -87,4 +92,5 @@ export {
trackNFTEvents,
trackDAppsEvents,
optOutofMetrics,
trackGenericEvents,
};
5 changes: 5 additions & 0 deletions packages/extension/src/libs/metrics/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export enum SwapEventType {
swapBack = "swap_back",
}

export enum GenericEvents {
login_success = "successful_login",
login_error = "login_error",
}

export enum NetworkChangeEvents {
NetworkChangePopup = "network_change_popup",
NetworkChangeAPI = "network_change_api",
Expand Down
62 changes: 42 additions & 20 deletions packages/extension/src/libs/utils/initialize-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,49 @@ import KeyRing from "@/libs/keyring/keyring";
import EthereumNetworks from "@/providers/ethereum/networks";
import PolkadotNetworks from "@/providers/polkadot/networks";
import BitcoinNetworks from "@/providers/bitcoin/networks";
import { WalletType } from "@enkryptcom/types";
export default async (mnemonic: string, password: string): Promise<void> => {
import KadenaNetworks from "@/providers/kadena/networks";
import { NetworkNames, WalletType } from "@enkryptcom/types";
import { getAccountsByNetworkName } from "@/libs/utils/accounts";
export const initAccounts = async (keyring: KeyRing) => {
const secp256k1btc = await getAccountsByNetworkName(NetworkNames.Bitcoin);
const secp256k1 = await getAccountsByNetworkName(NetworkNames.Ethereum);
const sr25519 = await getAccountsByNetworkName(NetworkNames.Polkadot);
const ed25519kda = await getAccountsByNetworkName(NetworkNames.Kadena);
if (secp256k1.length == 0)
await keyring.saveNewAccount({
basePath: EthereumNetworks.ethereum.basePath,
name: "EVM Account 1",
signerType: EthereumNetworks.ethereum.signer[0],
walletType: WalletType.mnemonic,
});
if (sr25519.length == 0)
await keyring.saveNewAccount({
basePath: PolkadotNetworks.polkadot.basePath,
name: "Substrate Account 1",
signerType: PolkadotNetworks.polkadot.signer[0],
walletType: WalletType.mnemonic,
});
if (secp256k1btc.length == 0)
await keyring.saveNewAccount({
basePath: BitcoinNetworks.bitcoin.basePath,
name: "Bitcoin Account 1",
signerType: BitcoinNetworks.bitcoin.signer[0],
walletType: WalletType.mnemonic,
});
if (ed25519kda.length == 0)
await keyring.saveNewAccount({
basePath: KadenaNetworks.kadena.basePath,
name: "Kadena Account 1",
signerType: KadenaNetworks.kadena.signer[0],
walletType: WalletType.mnemonic,
});
};
export const onboardInitializeWallets = async (
mnemonic: string,
password: string
): Promise<void> => {
const kr = new KeyRing();
await kr.init(mnemonic, password);
await kr.unlock(password);
await kr.saveNewAccount({
basePath: EthereumNetworks.ethereum.basePath,
name: "EVM Account 1",
signerType: EthereumNetworks.ethereum.signer[0],
walletType: WalletType.mnemonic,
});
await kr.saveNewAccount({
basePath: PolkadotNetworks.polkadot.basePath,
name: "Substrate Account 1",
signerType: PolkadotNetworks.polkadot.signer[0],
walletType: WalletType.mnemonic,
});
await kr.saveNewAccount({
basePath: BitcoinNetworks.bitcoin.basePath,
name: "Bitcoin Account 1",
signerType: BitcoinNetworks.bitcoin.signer[0],
walletType: WalletType.mnemonic,
});
await initAccounts(kr);
};
9 changes: 9 additions & 0 deletions packages/extension/src/libs/utils/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ import { NetworkNames } from "@enkryptcom/types";
import EthereumNetworks from "@/providers/ethereum/networks";
import PolkadotNetworks from "@/providers/polkadot/networks";
import BitcoinNetworks from "@/providers/bitcoin/networks";
import KadenaNetworks from "@/providers/kadena/networks";
import { BaseNetwork } from "@/types/base-network";
import CustomNetworksState from "../custom-networks-state";
import { CustomEvmNetwork } from "@/providers/ethereum/types/custom-evm-network";
import Ethereum from "@/providers/ethereum/networks/eth";
import Polkadot from "@/providers/polkadot/networks/polkadot";
import Bitcoin from "@/providers/bitcoin/networks/bitcoin";
import Kadena from "@/providers/kadena/networks/kadena";

const providerNetworks: Record<ProviderName, Record<string, BaseNetwork>> = {
[ProviderName.ethereum]: EthereumNetworks,
[ProviderName.polkadot]: PolkadotNetworks,
[ProviderName.bitcoin]: BitcoinNetworks,
[ProviderName.kadena]: KadenaNetworks,
[ProviderName.enkrypt]: {},
};
const getAllNetworks = async (): Promise<BaseNetwork[]> => {
Expand All @@ -26,6 +29,7 @@ const getAllNetworks = async (): Promise<BaseNetwork[]> => {
return (Object.values(EthereumNetworks) as BaseNetwork[])
.concat(Object.values(PolkadotNetworks) as BaseNetwork[])
.concat(Object.values(BitcoinNetworks) as BaseNetwork[])
.concat(Object.values(KadenaNetworks) as BaseNetwork[])
.concat(customNetworks);
};
const getNetworkByName = async (
Expand Down Expand Up @@ -53,10 +57,12 @@ const getProviderNetworkByName = async (
const DEFAULT_EVM_NETWORK_NAME = NetworkNames.Ethereum;
const DEFAULT_SUBSTRATE_NETWORK_NAME = NetworkNames.Polkadot;
const DEFAULT_BTC_NETWORK_NAME = NetworkNames.Bitcoin;
const DEFAULT_KADENA_NETWORK_NAME = NetworkNames.Kadena;

const DEFAULT_EVM_NETWORK = Ethereum;
const DEFAULT_SUBSTRATE_NETWORK = Polkadot;
const DEFAULT_BTC_NETWORK = Bitcoin;
const DEFAULT_KADENA_NETWORK = Kadena;

const POPULAR_NAMES = [
NetworkNames.Bitcoin,
Expand All @@ -66,6 +72,7 @@ const POPULAR_NAMES = [
NetworkNames.Binance,
NetworkNames.Rootstock,
NetworkNames.Optimism,
NetworkNames.Kadena,
];
export {
getAllNetworks,
Expand All @@ -78,4 +85,6 @@ export {
DEFAULT_EVM_NETWORK,
DEFAULT_SUBSTRATE_NETWORK,
DEFAULT_BTC_NETWORK,
DEFAULT_KADENA_NETWORK,
DEFAULT_KADENA_NETWORK_NAME,
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* refference: https://github.com/unisat-wallet/wallet-sdk/blob/master/src/message/bip322-simple.ts
* refference: https://github.com/bitcoinjs/varuint-bitcoin/blob/master/index.js
* reference: https://github.com/unisat-wallet/wallet-sdk/blob/master/src/message/bip322-simple.ts
* reference: https://github.com/bitcoinjs/varuint-bitcoin/blob/master/index.js
*/

import { BitcoinNetwork, PaymentType } from "../types/bitcoin-network";
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/providers/ethereum/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const injectDocument = (
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
document[options.name] = proxiedProvider; // Opera expects you to inject immediately and their wallet switcher will handle conflicts
}
options
.sendMessageHandler(
Expand Down
Loading

1 comment on commit e479489

@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.