-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: qedit-develop
Are you sure you want to change the base?
Changes from all commits
8cdf34e
ab81df0
c1914de
a6b5d30
985e52d
8997bd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
- Add api key to `qedit.env.js` | ||
- Run `yarn start` | ||
|
||
Original Metamask [README.md](./README-Metamask.md) file |
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"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,8 @@ function defineAndRunBuildTasks() { | |
skipStats, | ||
} = parseArgv(); | ||
|
||
const browserPlatforms = ['firefox', 'chrome', 'brave', 'opera']; | ||
// const browserPlatforms = ['firefox', 'chrome', 'brave', 'opera']; | ||
const browserPlatforms = ['chrome']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
|
||
const browserVersionMap = getBrowserVersionMap(browserPlatforms); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
window.qedit = { | ||
apiKey: '', | ||
}; |
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); | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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, | ||
|
@@ -658,6 +672,7 @@ export const initialState = { | |
error: null, | ||
// Warning to display on the address field | ||
warning: null, | ||
qeditSecurityCheck: QeditAddrSecStatus.INITIAL, | ||
}, | ||
}; | ||
|
||
|
@@ -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 | ||
|
@@ -1585,6 +1609,7 @@ export function updateRecipient({ address, nickname }) { | |
nickname: nickname || nicknameFromAddressBookEntryOrAccountName, | ||
}), | ||
); | ||
await dispatch(qeditSecurityCheckStatus()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()); | ||
}; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!!