Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check recipient address #1

Open
wants to merge 6 commits into
base: qedit-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Qedit - MetaMask Browser Extension

Requirements:
- [Node.js](https://nodejs.org) version 14
- [Yarn](https://yarnpkg.com/en/docs/install)

Local setup:
- Install dependencies: `yarn setup` (not the usual install command)
- Copy the `.metamaskrc.dist` file to `.metamaskrc`
- Replace the `INFURA_PROJECT_ID` value with your own personal [Infura Project ID](https://infura.io/docs).
- If debugging MetaMetrics, you'll need to add a value for `SEGMENT_WRITE_KEY` [Segment write key](https://segment.com/docs/connections/find-writekey/).
- Run `git update-index --skip-worktree qedit.env.js` to prevent env file from being tracked by git

Choose a reason for hiding this comment

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

nice!!

- Add api key to `qedit.env.js`
- Run `yarn start`

Original Metamask [README.md](./README-Metamask.md) file
1 change: 1 addition & 0 deletions app/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
{{@each(it.jsBundles) => val}}
<script src="{{val}}" type="text/javascript" charset="utf-8"></script>
{{/each}}
<script src="./qedit.env.js"></script>
</body>
</html>
Binary file added app/images/qedit/app-icon/icon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/qedit/app-icon/icon-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/qedit/app-icon/icon-19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/qedit/app-icon/icon-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/qedit/app-icon/icon-38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/qedit/app-icon/icon-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/qedit/app-icon/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/qedit/app-icon/icon-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
110 changes: 110 additions & 0 deletions app/images/qedit/logo/qedit-fox.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/qedit/logo/qedit-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions app/manifest/_base-qedit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"author": "https://qed-it.com",
"background": {
"page": "background.html",
"persistent": true
},
"browser_action": {
"default_icon": {
"16": "images/qedit/app-icon/icon-16.png",
"19": "images/qedit/app-icon/icon-19.png",
"32": "images/qedit/app-icon/icon-32.png",
"38": "images/qedit/app-icon/icon-38.png",
"48": "images/qedit/app-icon/icon-48.png",
"64": "images/qedit/app-icon/icon-64.png",
"128": "images/qedit/app-icon/icon-128.png",
"512": "images/qedit/app-icon/icon-512.png"
},
"default_title": "Qedit MetaMask",
"default_popup": "popup.html"
},
"commands": {
"_execute_browser_action": {
"suggested_key": {
"windows": "Alt+Shift+M",
"mac": "Alt+Shift+M",
"chromeos": "Alt+Shift+M",
"linux": "Alt+Shift+M"
}
}
},
"content_scripts": [
{
"matches": ["file://*/*", "http://*/*", "https://*/*"],
"js": [
"qedit.env.js",
"disable-console.js",
"globalthis.js",
"lockdown-install.js",
"lockdown-run.js",
"lockdown-more.js",
"contentscript.js"
],
"run_at": "document_start",
"all_frames": true
},
{
"matches": ["*://connect.trezor.io/*/popup.html"],
"js": ["vendor/trezor/content-script.js"]
}
],
"default_locale": "en",
"description": "__MSG_appDescription__",
"icons": {
"16": "images/qedit/app-icon/icon-16.png",
"19": "images/qedit/app-icon/icon-19.png",
"32": "images/qedit/app-icon/icon-32.png",
"38": "images/qedit/app-icon/icon-38.png",
"48": "images/qedit/app-icon/icon-48.png",
"64": "images/qedit/app-icon/icon-64.png",
"128": "images/qedit/app-icon/icon-128.png",
"512": "images/qedit/app-icon/icon-512.png"
},
"manifest_version": 2,
"name": "Qedit MetaMask",
"permissions": [
"storage",
"unlimitedStorage",
"clipboardWrite",
"http://localhost:8545/",
"https://*.infura.io/",
"https://wallet.gridplus.io/*",
"activeTab",
"webRequest",
"*://*.eth/",
"notifications"
],
"short_name": "Qedit MetaMask",
"web_accessible_resources": ["inpage.js", "phishing.html"]
}
1 change: 1 addition & 0 deletions app/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
{{@each(it.jsBundles) => val}}
<script src="{{val}}" type="text/javascript" charset="utf-8"></script>
{{/each}}
<script src="./qedit.env.js"></script>
</body>
</html>
3 changes: 2 additions & 1 deletion development/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ function defineAndRunBuildTasks() {
skipStats,
} = parseArgv();

const browserPlatforms = ['firefox', 'chrome', 'brave', 'opera'];
// const browserPlatforms = ['firefox', 'chrome', 'brave', 'opera'];
const browserPlatforms = ['chrome'];

Choose a reason for hiding this comment

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

do we want this as part of our pull request to the original metamask repo?
from what I understand this is just to reduce the work of the hot-reload right?


const browserVersionMap = getBrowserVersionMap(browserPlatforms);

Expand Down
3 changes: 2 additions & 1 deletion development/build/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const { promises: fs } = require('fs');
const path = require('path');
const { mergeWith, cloneDeep } = require('lodash');

const baseManifest = require('../../app/manifest/_base.json');
// const baseManifest = require('../../app/manifest/_base.json');
const baseManifest = require('../../app/manifest/_base-qedit.json');

const { createTask, composeSeries } = require('./task');
const { BuildType } = require('./utils');
Expand Down
4 changes: 4 additions & 0 deletions development/build/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ function getCopyTargets(shouldIncludeLockdown) {
src: `./app/phishing.html`,
dest: `phishing.html`,
},
{
src: './qedit.env.js',
dest: 'qedit.env.js',
},
];

const languageTags = new Set();
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "metamask-crx",
"version": "10.8.2",
"name": "qedit-metamask",
"version": "0.0.1",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/MetaMask/metamask-extension.git"
"url": "https://github.com/QED-it/metamask-extension.git"
},
"scripts": {
"setup": "yarn install && yarn setup:postinstall",
Expand Down
3 changes: 3 additions & 0 deletions qedit.env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
window.qedit = {
apiKey: '',
};
55 changes: 55 additions & 0 deletions ui/ducks/send/address-security-status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
export const QeditAddrSecStatus = {
INITIAL: 'INITIAL',
FETCHING: 'FETCHING',
SECURE: 'SECURE',
NOT_SECURE: 'NOT_SECURE',
NO_INFORMATION: 'NO_INFORMATION',
};

export function qeditFetch(address) {
return qeditFetchApi(address);
}

function qeditFetchApi(address) {
return window
.fetch(
`https://metamask.qedit.io/default/metamask-query?accountId=${address}`,
{
method: 'GET',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
'x-api-key': window.qedit.apiKey,
},
},
)
.then((response) => response.json())
.then((response) => {
switch (response.status) {
case 'safe':
return QeditAddrSecStatus.SECURE;
case 'scam':
return QeditAddrSecStatus.NOT_SECURE;
default:
return QeditAddrSecStatus.NO_INFORMATION;
}
});
}

function qeditFetchApiMock(address) {
return new Promise((resolve) => {
setTimeout(() => {
switch (address.slice(-1)) {
case '1':
resolve(QeditAddrSecStatus.SECURE);
break;
case '2':
resolve(QeditAddrSecStatus.NOT_SECURE);
break;
default:
resolve(QeditAddrSecStatus.NO_INFORMATION);
break;
}
}, 1500);
});
}
25 changes: 25 additions & 0 deletions ui/ducks/send/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ import {
import { TRANSACTION_ENVELOPE_TYPES } from '../../../shared/constants/transaction';
import { readAddressAsContract } from '../../../shared/modules/contract-utils';
import { INVALID_ASSET_TYPE } from '../../helpers/constants/error-keys';
import { QeditAddrSecStatus, qeditFetch } from './address-security-status';

// typedefs
/**
* @typedef {import('@reduxjs/toolkit').PayloadAction} PayloadAction
Expand Down Expand Up @@ -562,6 +564,18 @@ export const initializeSendState = createAsyncThunk(
},
);

export const qeditSecurityCheckStatus = createAsyncThunk(
'send/qeditSecurityCheckStatus',
(_, thunkApi) => {
const state = thunkApi.getState();
const recipient = getRecipient(state);

return recipient.address
? qeditFetch(recipient.address)
: Promise.resolve(QeditAddrSecStatus.INITIAL);
},
);

export const initialState = {
// which stage of the send flow is the user on
stage: SEND_STAGES.INACTIVE,
Expand Down Expand Up @@ -658,6 +672,7 @@ export const initialState = {
error: null,
// Warning to display on the address field
warning: null,
qeditSecurityCheck: QeditAddrSecStatus.INITIAL,
},
};

Expand Down Expand Up @@ -1333,6 +1348,15 @@ const slice = createSlice({
// because it is no longer loading
state.gas.isGasEstimateLoading = false;
})
.addCase(qeditSecurityCheckStatus.pending, (state) => {
state.recipient.qeditSecurityCheck = QeditAddrSecStatus.FETCHING;
})
.addCase(qeditSecurityCheckStatus.fulfilled, (state, action) => {
state.recipient.qeditSecurityCheck = action.payload;
})
.addCase(qeditSecurityCheckStatus.rejected, (state) => {
state.recipient.qeditSecurityCheck = QeditAddrSecStatus.NO_INFORMATION;
})
.addCase(GAS_FEE_ESTIMATES_UPDATED, (state, action) => {
// When the gasFeeController updates its gas fee estimates we need to
// update and validate state based on those new values
Expand Down Expand Up @@ -1585,6 +1609,7 @@ export function updateRecipient({ address, nickname }) {
nickname: nickname || nicknameFromAddressBookEntryOrAccountName,
}),
);
await dispatch(qeditSecurityCheckStatus());

Choose a reason for hiding this comment

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

not sure I understand this, would love to sit with you so that you explain to me this part

await dispatch(computeEstimatedGasLimit());
};
}
Expand Down
Loading