Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f9ee4cb
chore: setup and password check install
andrewdahn Apr 13, 2022
78eae00
devop: add password strength check
andrewdahn Apr 13, 2022
2703f2b
devop: mnemonic phrases
andrewdahn Apr 14, 2022
fcda140
devop: recovery phrase
andrewdahn Apr 15, 2022
2f87da9
revert: revert .yarnrc.yml
andrewdahn Apr 15, 2022
7816c83
devop: replace .yarn
andrewdahn Apr 15, 2022
64d8498
chore: new yarn lock
andrewdahn Apr 15, 2022
2169cc3
Merge branch 'develop' of https://github.com/enkryptcom/enKrypt into …
andrewdahn Apr 15, 2022
83d075f
chore: install bip39 and uninstall mew keystore package
andrewdahn Apr 15, 2022
dc7e2ef
devop: use bip39
andrewdahn Apr 15, 2022
2fd89fe
devop: recovery phrase check
andrewdahn Apr 15, 2022
d09083a
devop: valid mnemonic and check phrases
andrewdahn Apr 16, 2022
081db3f
chore: remove package lock
andrewdahn Apr 16, 2022
d99b0ac
devop: add proptype
andrewdahn Apr 16, 2022
81675c5
Merge branch 'develop' of https://github.com/enkryptcom/enKrypt into …
andrewdahn Apr 20, 2022
6a501c6
devop: fix warnings
andrewdahn Apr 20, 2022
367124c
devop: 🔧 add acala/dot assets handler
kvhnuke Apr 21, 2022
d8929c0
Merge pull request #11 from enkryptcom/feature/lock-screen-dev
kvhnuke Apr 21, 2022
d3b8dae
feat: ✨ add unlock wallet
kvhnuke Apr 21, 2022
c28aa06
Merge pull request #9 from enkryptcom/feature/add-account-dev
kvhnuke Apr 21, 2022
e5a06b5
feat: ✨ add accounts
kvhnuke Apr 25, 2022
d4757dc
devop: 🔧 register background handlers first
kvhnuke Apr 25, 2022
a053fc2
devop: 🔧 merge develop
kvhnuke Apr 25, 2022
a6db5c1
Merge pull request #6 from enkryptcom/wallet-phrase
kvhnuke Apr 25, 2022
9f13e56
devop: 🔧 develop swap
mihailpolev Apr 29, 2022
2e09bea
feat: ✨ add Swap views
mihailpolev May 5, 2022
b749ba3
Merge branch 'feature/ui-updates' of github.com:enkryptcom/enKrypt in…
mihailpolev May 5, 2022
54d9023
devop: 🔧 fix swap and send
mihailpolev May 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/extension-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
"nanoevents": "^6.0.2",
"serialize-error": "9.1.0",
"tiny-uid": "^1.1.1",
"webextension-polyfill": "^0.8.0"
"webextension-polyfill": "^0.9.0"
},
"devDependencies": {
"@antfu/eslint-config": "^0.16.1",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.1.0",
"@types/node": "^17.0.17",
"@types/webextension-polyfill": "^0.8.2",
"@types/webextension-polyfill": "^0.8.3",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"bumpp": "^7.1.1",
Expand Down
9 changes: 6 additions & 3 deletions packages/extension-bridge/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ const initIntercoms = () => {
routeMessage(message);
});
port.onDisconnect.addListener(() => {
connectToBackgroundWithDisconnect();
port = null;
initIntercoms();
});
};
connectToBackgroundWithDisconnect();
Expand All @@ -157,7 +158,8 @@ const initIntercoms = () => {
routeMessage(message);
});
port.onDisconnect.addListener(() => {
connectToBackgroundWithDisconnect();
port = null;
initIntercoms();
});
};
connectToBackgroundWithDisconnect();
Expand All @@ -175,7 +177,8 @@ const initIntercoms = () => {
routeMessage(message);
});
port.onDisconnect.addListener(() => {
connectToBackgroundWithDisconnect();
port = null;
initIntercoms();
});
};
connectToBackgroundWithDisconnect();
Expand Down
6 changes: 4 additions & 2 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"watch-vue": "vue-cli-service build --watch --no-clean"
},
"dependencies": {
"@acala-network/api": "^4.1.1",
"@enkryptcom/extension-bridge": "^0.0.1",
"@enkryptcom/keyring": "^0.0.1",
"@enkryptcom/request": "^0.0.1",
Expand All @@ -29,6 +30,7 @@
"@types/lodash": "^4.14.182",
"add": "^2.0.6",
"bignumber.js": "^9.0.2",
"bip39": "^3.0.4",
"chai": "^4.3.6",
"concurrently": "^7.0.0",
"core-js": "^3.21.0",
Expand All @@ -45,7 +47,7 @@
"vue3-lottie": "^2.1.0",
"web3": "^1.7.3",
"web3-utils": "^1.7.3",
"yarn": "^1.22.18"
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"@polkadot/api": "^8.0.2",
Expand Down Expand Up @@ -88,7 +90,7 @@
"tsconfig-paths": "^3.12.0",
"typescript": "^4.5.5",
"url": "^0.11.0",
"webextension-polyfill": "^0.8.0"
"webextension-polyfill": "^0.9.0"
},
"installConfig": {
"hoistingLimits": "none"
Expand Down
76 changes: 46 additions & 30 deletions packages/extension/src/libs/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
InternalOnMessageResponse,
Message,
} from "@/types/messenger";
import { KeyRecord, RPCRequestType } from "@enkryptcom/types";
import { KeyRecord, KeyRecordAdd, RPCRequestType } from "@enkryptcom/types";
import { getCustomError } from "../error";
import KeyRingBase from "../keyring/keyring";
import { sendToWindow } from "@/libs/messenger/extension";
Expand Down Expand Up @@ -36,20 +36,6 @@ class BackgroundHandler {
[ProviderName.ethereum]: EthereumProvider,
[ProviderName.polkadot]: PolkadotProvider,
};
// this.#keyring
// .generate("test pass")
// .then(() => {
// console.log("keyring created");
// })
// .catch(console.error);
// this.#keyring.unlock("test pass").then(() => {
// this.#keyring.addEthereumAddress("abc").then((key) => {
// console.log("added", key);
// });
// this.#keyring.addPolkadotAddress("def1").then((key) => {
// console.log("added", key);
// });
// });
}
async init(): Promise<void> {
const allPersistentEvents = await this.#persistentEvents.getAllEvents();
Expand Down Expand Up @@ -191,27 +177,57 @@ class BackgroundHandler {
return Promise.resolve({
result: JSON.stringify(this.#keyring.isLocked()),
});
} else if (message.method === InternalMethods.sendToTab) {
const actionMsg = msg as any as ActionSendMessage;
if (
actionMsg.provider &&
actionMsg.tabId &&
this.#tabProviders[actionMsg.provider][actionMsg.tabId]
) {
this.#tabProviders[actionMsg.provider][
actionMsg.tabId
].sendNotification(
JSON.stringify(message.params?.length ? message.params[0] : {})
);
return Promise.resolve({
result: JSON.stringify(true),
});
} else {
return Promise.resolve({
result: JSON.stringify(false),
});
}
} else if (
message.method === InternalMethods.getNewAccount ||
message.method === InternalMethods.saveNewAccount
) {
if (!message.params || message.params.length < 1)
return Promise.resolve({
error: getCustomError("background: invalid params for new account"),
});
const method =
message.method === InternalMethods.getNewAccount
? "getNewAccount"
: "saveNewAccount";
const keyrecord = message.params[0] as KeyRecordAdd;
return this.#keyring
[method](keyrecord)
.then((res) => {
return {
result: JSON.stringify(res),
};
})
.catch((e) => {
return {
error: getCustomError(e.message),
};
});
} else {
return Promise.resolve({
error: getCustomError(`background: unknown method: ${message.method}`),
});
}
}
actionHandler(msg: Message): Promise<InternalOnMessageResponse> {
const actionMsg = msg as any as ActionSendMessage;
if (this.#tabProviders[actionMsg.provider][actionMsg.tabId]) {
this.#tabProviders[actionMsg.provider][actionMsg.tabId].sendNotification(
actionMsg.message
);
return Promise.resolve({
result: JSON.stringify(true),
});
} else {
return Promise.resolve({
result: JSON.stringify(false),
});
}
}
}

export default BackgroundHandler;
28 changes: 16 additions & 12 deletions packages/extension/src/libs/keyring/keyring.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import KeyRing from "@enkryptcom/keyring";
import { InternalStorageNamespace } from "@/types/provider";
import BrowserStorage from "../common/browser-storage";
import { KeyRecord, SignerType, SignOptions } from "@enkryptcom/types";
import {
KeyRecord,
KeyRecordAdd,
SignerType,
SignOptions,
} from "@enkryptcom/types";
export class KeyRingBase {
#keyring: KeyRing;
constructor() {
Expand All @@ -11,19 +16,18 @@ export class KeyRingBase {
generate(password: string): Promise<void> {
return this.#keyring.init(password);
}
addEthereumAddress(name: string): Promise<KeyRecord> {
return this.#keyring.createAndSaveKey({
type: SignerType.secp256k1,
basePath: "m/44'/60'/0'/0",
name: name,
getNewAccount(options: {
basePath: string;
type: SignerType;
}): Promise<KeyRecord> {
return this.#keyring.createKey({
name: "",
basePath: options.basePath,
type: options.type,
});
}
addPolkadotAddress(name: string): Promise<KeyRecord> {
return this.#keyring.createAndSaveKey({
type: SignerType.sr25519,
basePath: "//",
name: name,
});
saveNewAccount(options: KeyRecordAdd): Promise<KeyRecord> {
return this.#keyring.createAndSaveKey(options);
}
sign(
hexMessage: `0x${string}`,
Expand Down
2 changes: 0 additions & 2 deletions packages/extension/src/libs/sparkline/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ export default class Sparkline {
100
);
});
console.log(this._values);
this._viewBoxHeight = 100;
this._viewBoxWidth = 100;
console.log(this._values.length, "----------------");
}

public get d(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import {
SupportedNetwork,
TokenBalance,
} from "./types/tokenbalance-mew";
import MarketData from "../market-data";
import cacheFetch from "../cache-fetch";
import { fromBase } from "../utils/units";
import MarketData from "@/libs/market-data";
import cacheFetch from "@/libs/cache-fetch";
import { fromBase } from "@/libs/utils/units";
import { toBN } from "web3-utils";
import BigNumber from "bignumber.js";
import {
formatFiatValue,
formatFloatingPointValue,
} from "../utils/number-formatter";
} from "@/libs/utils/number-formatter";
import API from "@/providers/ethereum/libs/api";
import Sparkline from "../sparkline";
import Sparkline from "@/libs/sparkline";
import { EthereumNodeType } from "@/providers/ethereum/types";
const API_ENPOINT = "https://tokenbalance.mewapi.io/";
const NATIVE_CONTRACT = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
Expand Down Expand Up @@ -114,7 +114,7 @@ export default (network: NodeType, address: string): Promise<AssetsType[]> => {
sparkline: new Sparkline(market.sparkline_in_7d.price, 25)
.dataUri,
priceChangePercentage:
market.price_change_percentage_7d_in_currency,
market.price_change_percentage_7d_in_currency || 0,
};
if (address !== NATIVE_CONTRACT) assets.push(asset);
else nativeAsset = asset;
Expand All @@ -123,8 +123,8 @@ export default (network: NodeType, address: string): Promise<AssetsType[]> => {
}
}
assets.sort((a, b) => {
if (a.balanceUSD > b.balanceUSD) return 1;
else if (a.balanceUSD < b.balanceUSD) return -1;
if (a.balanceUSD < b.balanceUSD) return 1;
else if (a.balanceUSD > b.balanceUSD) return -1;
else return 0;
});
assets.unshift(nativeAsset as AssetsType);
Expand Down
3 changes: 2 additions & 1 deletion packages/extension/src/providers/ethereum/networks/bsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { toChecksumAddress } from "ethereumjs-util";
import API from "../libs/api";
import { EthereumNodeType } from "../types";
import createIcon from "../libs/blockies";
import tokenbalanceMew from "@/libs/assets-handlers/tokenbalance-mew";
import tokenbalanceMew from "@/providers/ethereum/libs/assets-handlers/tokenbalance-mew";
const bscNode: EthereumNodeType = {
name: "BNB",
name_long: "BNB Chain",
Expand All @@ -23,6 +23,7 @@ const bscNode: EthereumNodeType = {
coingeckoID: "binancecoin",
identicon: createIcon,
assetsHandler: tokenbalanceMew,
basePath: "m/44'/714'",
};
bscNode.api = async () => {
const api = new API(bscNode.node);
Expand Down
1 change: 1 addition & 0 deletions packages/extension/src/providers/ethereum/networks/etc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const etcNode: EthereumNodeType = {
provider: ProviderName.ethereum,
coingeckoID: "ethereum-classic",
identicon: createIcon,
basePath: "m/44'/61'/0'/0",
};
etcNode.api = async () => {
const api = new API(etcNode.node);
Expand Down
3 changes: 2 additions & 1 deletion packages/extension/src/providers/ethereum/networks/eth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import tokenbalanceMew from "@/libs/assets-handlers/tokenbalance-mew";
import tokenbalanceMew from "@/providers/ethereum/libs/assets-handlers/tokenbalance-mew";
import rarible from "@/libs/nft-handlers/rarible";
import { ProviderName } from "@/types/provider";
import { SignerType } from "@enkryptcom/types";
Expand All @@ -25,6 +25,7 @@ const ethNode: EthereumNodeType = {
NFTHandler: rarible,
identicon: createIcon,
assetsHandler: tokenbalanceMew,
basePath: "m/44'/60'/0'/0",
};
ethNode.api = async () => {
const api = new API(ethNode.node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const goerliNode: EthereumNodeType = {
displayAddress: (address: string) => toChecksumAddress(address),
provider: ProviderName.ethereum,
identicon: createIcon,
basePath: "m/44'/60'/0'/0",
};
goerliNode.api = async () => {
const api = new API(goerliNode.node);
Expand Down
1 change: 1 addition & 0 deletions packages/extension/src/providers/ethereum/networks/kov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const kovanNode: EthereumNodeType = {
displayAddress: (address: string) => toChecksumAddress(address),
provider: ProviderName.ethereum,
identicon: createIcon,
basePath: "m/44'/60'/0'/0",
};
kovanNode.api = async () => {
const api = new API(kovanNode.node);
Expand Down
3 changes: 2 additions & 1 deletion packages/extension/src/providers/ethereum/networks/matic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { toChecksumAddress } from "ethereumjs-util";
import API from "../libs/api";
import { EthereumNodeType } from "../types";
import createIcon from "../libs/blockies";
import tokenbalanceMew from "@/libs/assets-handlers/tokenbalance-mew";
import tokenbalanceMew from "@/providers/ethereum/libs/assets-handlers/tokenbalance-mew";
const maticNode: EthereumNodeType = {
name: "MATIC",
name_long: "Polygon (Matic)",
Expand All @@ -25,6 +25,7 @@ const maticNode: EthereumNodeType = {
NFTHandler: rarible,
identicon: createIcon,
assetsHandler: tokenbalanceMew,
basePath: "m/44'/60'/0'/0",
};
maticNode.api = async () => {
const api = new API(maticNode.node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const moonbeamNode: EthereumNodeType = {
provider: ProviderName.ethereum,
coingeckoID: "moonbeam",
identicon: createIcon,
basePath: "m/44'/60'/0'/0",
};
moonbeamNode.api = async () => {
const api = new API(moonbeamNode.node);
Expand Down
1 change: 1 addition & 0 deletions packages/extension/src/providers/ethereum/networks/rin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const rinkebyNode: EthereumNodeType = {
displayAddress: (address: string) => toChecksumAddress(address),
provider: ProviderName.ethereum,
identicon: createIcon,
basePath: "m/44'/60'/0'/0",
};
rinkebyNode.api = async () => {
const api = new API(rinkebyNode.node);
Expand Down
1 change: 1 addition & 0 deletions packages/extension/src/providers/ethereum/networks/rop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const ropstenNode: EthereumNodeType = {
displayAddress: (address: string) => toChecksumAddress(address),
provider: ProviderName.ethereum,
identicon: createIcon,
basePath: "m/44'/60'/0'/0",
};
ropstenNode.api = async () => {
const api = new API(ropstenNode.node);
Expand Down
1 change: 1 addition & 0 deletions packages/extension/src/providers/polkadot/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const injectDocument = (
const provider = new Provider(options);
document.injectedWeb3 = document.injectedWeb3 || {};
document.injectedWeb3["enkrypt"] = provider;
document.injectedWeb3["polkadot-js"] = provider;
document["enkrypt"]["providers"][options.name] = provider;
};

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading