Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9b90c6a
Bump hosted-git-info from 2.6.0 to 2.8.9
dependabot[bot] Sep 26, 2022
db7caba
Bump css-loader from 6.0.0 to 6.7.1
dependabot[bot] Sep 26, 2022
12847ca
Bump sass-loader from 7.0.3 to 13.0.2
dependabot[bot] Sep 26, 2022
1671e1b
Migrate to manifest v3
nibbles83 Sep 29, 2022
77f81b1
Update to metrixjs-wallet to 0.3.0
nibbles83 Sep 30, 2022
9b7a98f
Remove scriptworker, can no longer launch in seperate worker
nibbles83 Sep 30, 2022
3d3ad9c
Cleanup and version increment
nibbles83 Sep 30, 2022
6b89b0d
replace deprecated extension with runtime
nibbles83 Sep 30, 2022
a755167
Merge pull request #89 from TheLindaProjectInc/chromemanifestv3
nibbles83 Sep 30, 2022
37a0406
Merge pull request #84 from TheLindaProjectInc/dependabot/npm_and_yar…
nibbles83 Sep 30, 2022
820e28b
Bump y18n from 3.2.1 to 3.2.2
dependabot[bot] Sep 30, 2022
f21086e
Merge pull request #86 from TheLindaProjectInc/dependabot/npm_and_yar…
nibbles83 Oct 3, 2022
fb38e93
Merge pull request #85 from TheLindaProjectInc/dependabot/npm_and_yar…
nibbles83 Oct 3, 2022
70a3ab0
Merge pull request #90 from TheLindaProjectInc/dependabot/npm_and_yar…
nibbles83 Oct 3, 2022
5a6dd13
Bump minimist from 1.2.0 to 1.2.6
dependabot[bot] Oct 3, 2022
e6e4dc5
Bump postcss-flexbugs-fixes from 3.3.1 to 5.0.1
dependabot[bot] Oct 3, 2022
e44b48d
Merge pull request #63 from TheLindaProjectInc/dependabot/npm_and_yar…
nibbles83 Oct 3, 2022
e2bea4f
Merge pull request #92 from TheLindaProjectInc/dependabot/npm_and_yar…
nibbles83 Oct 3, 2022
c4c8337
Bump ts-loader from 9.0.0 to 9.4.1
dependabot[bot] Oct 3, 2022
5ccdf3e
Merge pull request #93 from TheLindaProjectInc/dependabot/npm_and_yar…
nibbles83 Oct 3, 2022
af5c9ba
Bump @types/chrome from 0.0.196 to 0.0.197
dependabot[bot] Oct 3, 2022
556201e
Bump @types/lodash from 4.14.185 to 4.14.186
dependabot[bot] Oct 3, 2022
4e4a349
Merge pull request #95 from TheLindaProjectInc/dependabot/npm_and_yar…
nibbles83 Oct 3, 2022
0838450
Merge pull request #96 from TheLindaProjectInc/dependabot/npm_and_yar…
nibbles83 Oct 3, 2022
2bc0cd9
Bump classnames and @types/classnames
dependabot[bot] Oct 3, 2022
32837b9
Merge pull request #97 from TheLindaProjectInc/dependabot/npm_and_yar…
nibbles83 Oct 3, 2022
4eb284e
Bump postcss-loader from 5.0.0 to 7.0.1
dependabot[bot] Oct 3, 2022
fc8a047
Merge pull request #99 from TheLindaProjectInc/dependabot/npm_and_yar…
nibbles83 Oct 3, 2022
0ba942f
Remove unused chrome-call
nibbles83 Oct 3, 2022
139342e
Bump react-router-dom from 6.3.0 to 6.6.1
dependabot[bot] Dec 26, 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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.eslintrc.js
scryptworker.js
service_worker.js
global.css
en_US.json
logo.svg
Expand Down
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog

## 1.0.6

- Migrate to metrixjs-wallet 0.3.0
- Upgrade webpack to 5.74
- Move to Extension manifest v3 and rework to service_worker
- Upgrade whole host of dependancies
- Change loading screen to rotating circle, the scrolling bar was freezing due to thread lock.
24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "metrimask",
"version": "1.0.6",
"private": true,
"scripts": {
"clean": "rm -rf dist",
Expand All @@ -14,8 +15,8 @@
"devDependencies": {
"@ceoimon/typed-css-modules": "^0.1.0",
"@material-ui/core": "4.0.2",
"@types/chrome": "^0.0.196",
"@types/classnames": "^2.2.4",
"@types/chrome": "^0.0.197",
"@types/classnames": "^2.3.1",
"@types/prop-types": "^15.5.3",
"@types/react": "18.0.0",
"@types/react-dom": "18.0.0",
Expand All @@ -24,7 +25,7 @@
"@typescript-eslint/parser": "^5.37.0",
"autoprefixer": "^9.8.8",
"copy-webpack-plugin": "^5.1.2",
"css-loader": "6.0.0",
"css-loader": "6.7.1",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
Expand All @@ -37,13 +38,13 @@
"mini-css-extract-plugin": "^2.6.1",
"node-polyfill-webpack-plugin": "^2.0.1",
"node-sass": "^7.0.1",
"postcss-flexbugs-fixes": "^3.3.0",
"postcss-loader": "5.0.0",
"postcss-flexbugs-fixes": "^5.0.1",
"postcss-loader": "7.0.1",
"postcss-modules": "4.3.1",
"react-router-dom": "6",
"sass-loader": "^7.0.3",
"sass-loader": "^13.0.2",
"style-loader": "3.0.0",
"ts-loader": "9.0.0",
"ts-loader": "9.4.1",
"typescript": "4.2",
"uglifyjs-webpack-plugin": "^1.2.7",
"url-loader": "^4.1.1",
Expand All @@ -56,7 +57,7 @@
"@material-ui/icons": "4.0.1",
"@types/deep-equal": "^1.0.1",
"@types/history": "^5.0.0",
"@types/lodash": "^4.14.185",
"@types/lodash": "^4.14.186",
"@types/qrcode.react": "^1.0.2",
"@types/scryptsy": "^2.0.0",
"@types/secp256k1": "^4.0.3",
Expand All @@ -65,16 +66,17 @@
"bip39": "^3.0.4",
"bitcoinjs-lib": "4.0.5",
"bitcoinjs-message": "^2.2.0",
"chrome-call": "^3.0.0",
"classnames": "^2.2.6",
"classnames": "^2.3.2",
"deep-equal": "^2.0.5",
"fetch-absolute": "^1.0.0",
"follow-redirects": "1.14.8",
"metrixjs-wallet": "^0.2.20",
"metrixjs-wallet": "^0.3.0",
"mobx": "^5.15.7",
"mobx-react": "^5.2.3",
"mobx-react-router": "^4.1.0",
"moment": "^2.29.4",
"mweb3": "^1.0.0",
"node-fetch": "2",
"qrcode.react": "^3.1.0",
"react": "18.0.0",
"react-dom": "18.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/background/controllers/accountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export default class AccountController extends IController {
*/
private startPolling = async () => {
if (!this.getInfoInterval) {
this.getInfoInterval = window.setInterval(() => {
this.getInfoInterval = self.setInterval(() => {
this.getWalletInfo();
}, AccountController.GET_INFO_INTERVAL_MS);
}
Expand All @@ -433,8 +433,8 @@ export default class AccountController extends IController {
*/
try {
const rates = {
[TRANSACTION_SPEED.FAST]: 225000000,
[TRANSACTION_SPEED.NORMAL]: 225000000,
[TRANSACTION_SPEED.FAST]: 1000000000,
[TRANSACTION_SPEED.NORMAL]: 500000000,
[TRANSACTION_SPEED.SLOW]: 225000000,
};
const feeRate = rates[transactionSpeed]; // satoshi/byte; 1000000 satoshi/byte == 10 MRX/KB
Expand Down
76 changes: 56 additions & 20 deletions src/background/controllers/cryptoController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isEmpty, split } from 'lodash';

import scrypt from 'scryptsy';
import MetriMaskController from '.';
import IController from './iController';
import { STORAGE } from '../../constants';
Expand Down Expand Up @@ -49,7 +49,7 @@ export default class CryptoController extends IController {
public generateAppSaltIfNecessary = () => {
try {
if (!this.appSalt) {
const appSalt: Uint8Array = window.crypto.getRandomValues(new Uint8Array(16)) ;
const appSalt: Uint8Array = self.crypto.getRandomValues(new Uint8Array(16)) ;
this.appSalt = appSalt;
chrome.storage.local.set(
{ [STORAGE.APP_SALT]: appSalt.toString() },
Expand All @@ -69,28 +69,64 @@ export default class CryptoController extends IController {
throw Error('appSalt should not be empty');
}


// FIXME this causes the loading screen to "freeze"
try {
const saltBuffer = Buffer.from(this.appSalt);
const { N, r, p } = CryptoController.SCRYPT_PARAMS_PW;
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const derivedKey = scrypt(password, saltBuffer, N, r, p, 64);
this.passwordHash = derivedKey.toString('hex');
finish();
} catch (err) {
console.log({ err });
}


/*
* Create a web worker for the scrypt key derivation, so that it doesn't freeze the loading screen ui.
* File path relative to post bundling of webpack. worker-loader node module did not work for me,
* possibly a compatibility issue with chrome.
*/
let sww;
if (typeof(sww) === 'undefined') {
sww = new Worker('./scryptworker.js');

sww.postMessage({
password,
salt: this.appSalt,
scryptParams: CryptoController.SCRYPT_PARAMS_PW,
});

sww.onmessage = (e) => {
if (e.data.err) {
throw Error('scrypt failed to calculate derivedKey');
}
this.passwordHash = e.data.passwordHash;
finish();
};
}
// let sww;
// if (typeof(sww) === 'undefined') {
// sww = new self.Worker(
// // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
// self.URL.createObjectURL(new Blob(['('+this.worker_function.toString()+')()'], {type: 'text/javascript'})));
// // sww = new Worker('./scryptworker.js');

// sww.postMessage({
// password,
// salt: this.appSalt,
// scryptParams: CryptoController.SCRYPT_PARAMS_PW,
// });

// sww.onmessage = (e) => {
// if (e.data.err) {
// throw Error('scrypt failed to calculate derivedKey');
// }
// this.passwordHash = e.data.passwordHash;
// finish();
// };
// }
};

// public worker_function = () => {
// onmessage = (e) => {
// const ctx: Worker = self as any;
// try {
// const password = e.data.password;
// const salt = e.data.salt;
// // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
// const saltBuffer = Buffer.from(salt);
// const { N, r, p } = e.data.scryptParams;
// // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
// const derivedKey = scrypt(password, saltBuffer, N, r, p, 64);
// const passwordHash = derivedKey.toString('hex');
// ctx.postMessage({ passwordHash });
// } catch (err) {
// ctx.postMessage({ err });
// }
// };
// };
}
10 changes: 5 additions & 5 deletions src/background/controllers/externalController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios from 'axios';
const fetch = require('node-fetch');

import MetriMaskController from '.';
import IController from './iController';
Expand Down Expand Up @@ -30,7 +30,7 @@ export default class ExternalController extends IController {
public startPolling = async () => {
await this.getMetrixPrice();
if (!this.getPriceInterval) {
this.getPriceInterval = window.setInterval(() => {
this.getPriceInterval = self.setInterval(() => {
this.getMetrixPrice();
}, ExternalController.GET_PRICE_INTERVAL_MS);
}
Expand All @@ -51,9 +51,9 @@ export default class ExternalController extends IController {
*/
private getMetrixPrice = async () => {
try {
// const jsonObj = await axios.get('https://api.coinmarketcap.com/v2/ticker/1684/');
const jsonObj = await axios.get('https://api.coingecko.com/api/v3/simple/price?ids=linda&vs_currencies=USD');
this.metrixPriceUSD = jsonObj.data.linda.usd;
const resjsonObj = await fetch('https://api.coingecko.com/api/v3/simple/price?ids=linda&vs_currencies=USD');
const jsonObj = await resjsonObj.json();
this.metrixPriceUSD = jsonObj.linda.usd;

if (this.main.account.loggedInAccount
&& this.main.account.loggedInAccount.wallet
Expand Down
2 changes: 1 addition & 1 deletion src/background/controllers/mrc721Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class Mrc721Controller extends IController {
public startPolling = async () => {
this.getBalances();
if (!this.getBalancesInterval) {
this.getBalancesInterval = window.setInterval(() => {
this.getBalancesInterval = self.setInterval(() => {
this.getBalances();
}, Mrc721Controller.GET_BALANCES_INTERVAL_MS);
}
Expand Down
17 changes: 10 additions & 7 deletions src/background/controllers/onInstallController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ export default class OnInstallController extends IController {
private refreshTab(tab: chrome.tabs.Tab) {
// Tells the content script to post a msg to the inpage window letting it know that MetriMask
// was installed or updated.
chrome.tabs.executeScript(tab.id!, {code:
`window.postMessage(
{
message: { type: 'METRIMASK_INSTALLED_OR_UPDATED' }
},
'*'
)`,
chrome.scripting.executeScript({
target: {tabId: tab.id!, allFrames: true},
func: () => {
window.postMessage(
{
message: { type: 'METRIMASK_INSTALLED_OR_UPDATED' }
},
'*'
);
},
});
}
}
2 changes: 1 addition & 1 deletion src/background/controllers/sessionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class SessionController extends IController {
// Check if session logout is enabled
if (this.sessionLogoutInterval > 0) {
// Logout from bgp after interval
this.sessionTimeout = window.setTimeout(() => {
this.sessionTimeout = self.setTimeout(() => {
this.clearSession();
this.main.crypto.resetPasswordHash();
console.log('Session cleared');
Expand Down
2 changes: 1 addition & 1 deletion src/background/controllers/tokenController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class TokenController extends IController {
public startPolling = async () => {
this.getBalances();
if (!this.getBalancesInterval) {
this.getBalancesInterval = window.setInterval(() => {
this.getBalancesInterval = self.setInterval(() => {
this.getBalances();
}, TokenController.GET_BALANCES_INTERVAL_MS);
}
Expand Down
2 changes: 1 addition & 1 deletion src/background/controllers/transactionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class TransactionController extends IController {
private startPolling = async () => {
await this.fetchFirst();
if (!this.getTransactionsInterval) {
this.getTransactionsInterval = window.setInterval(() => {
this.getTransactionsInterval = self.setInterval(() => {
this.refreshTransactions();
}, TransactionController.GET_TX_INTERVAL_MS);
}
Expand Down
2 changes: 1 addition & 1 deletion src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import MetriMaskController from './controllers';

// Add instance to window for debugging
const controller = new MetriMaskController();
Object.assign(window, { controller });
Object.assign(chrome.windows.getCurrent, { controller });
15 changes: 0 additions & 15 deletions src/background/workers/scryptworker.js

This file was deleted.

22 changes: 11 additions & 11 deletions src/contentscript/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@ const injectStylesheet = (src: string) => {
};

export const injectAllScripts = async () => {
await injectScript(chrome.extension.getURL('commons.all.js')).then(async () => {
await injectScript(chrome.extension.getURL('commons.exclude-background.js'));
await injectScript(chrome.extension.getURL('commons.exclude-contentscript.js'));
await injectScript(chrome.extension.getURL('commons.exclude-popup.js'));
await injectScript(chrome.extension.getURL('commons.background-inpage.js'));
await injectScript(chrome.extension.getURL('commons.contentscript-inpage.js'));
await injectScript(chrome.extension.getURL('commons.popup-inpage.js'));
await injectScript(chrome.extension.getURL('inpage.js'));
await injectScript(chrome.runtime.getURL('commons.all.js')).then(async () => {
await injectScript(chrome.runtime.getURL('commons.exclude-background.js'));
await injectScript(chrome.runtime.getURL('commons.exclude-contentscript.js'));
await injectScript(chrome.runtime.getURL('commons.exclude-popup.js'));
await injectScript(chrome.runtime.getURL('commons.background-inpage.js'));
await injectScript(chrome.runtime.getURL('commons.contentscript-inpage.js'));
await injectScript(chrome.runtime.getURL('commons.popup-inpage.js'));
await injectScript(chrome.runtime.getURL('inpage.js'));

// Pass the Chrome extension absolute URL of the Sign Transaction dialog to the Inpage
const signTxUrl = chrome.extension.getURL('sign-tx.html');
const signTxUrl = chrome.runtime.getURL('sign-tx.html');
postWindowMessage(TARGET_NAME.INPAGE, {
type: API_TYPE.SIGN_TX_URL_RESOLVED,
payload: { url: signTxUrl },
});

// Pass the Chrome extension absolute URL of the Sign Message dialog to the Inpage
const signMessageUrl = chrome.extension.getURL('sign-message.html');
const signMessageUrl = chrome.runtime.getURL('sign-message.html');
postWindowMessage(TARGET_NAME.INPAGE, {
type: API_TYPE.SIGN_MESSAGE_URL_RESOLVED,
payload: { url: signMessageUrl },
});
});

injectStylesheet(chrome.extension.getURL('css/modal.css'));
injectStylesheet(chrome.runtime.getURL('css/modal.css'));
};
Loading