mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
initial implementation
This commit is contained in:
parent
f5fb06020d
commit
afb5788861
@ -10,6 +10,7 @@ const NonceTracker = require('./nonce-tracker')
|
|||||||
const txUtils = require('./lib/util')
|
const txUtils = require('./lib/util')
|
||||||
const cleanErrorStack = require('../../lib/cleanErrorStack')
|
const cleanErrorStack = require('../../lib/cleanErrorStack')
|
||||||
const log = require('loglevel')
|
const log = require('loglevel')
|
||||||
|
const recipientBlackListChecker = require('./lib/recipient-blacklist-checker')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Transaction Controller is an aggregate of sub-controllers and trackers
|
Transaction Controller is an aggregate of sub-controllers and trackers
|
||||||
@ -157,8 +158,11 @@ class TransactionController extends EventEmitter {
|
|||||||
let txMeta = this.txStateManager.generateTxMeta({ txParams: normalizedTxParams })
|
let txMeta = this.txStateManager.generateTxMeta({ txParams: normalizedTxParams })
|
||||||
this.addTx(txMeta)
|
this.addTx(txMeta)
|
||||||
this.emit('newUnapprovedTx', txMeta)
|
this.emit('newUnapprovedTx', txMeta)
|
||||||
// add default tx params
|
|
||||||
try {
|
try {
|
||||||
|
// check whether recipient account is public
|
||||||
|
await recipientBlackListChecker.checkAccount(txMeta.metamaskNetworkId, normalizedTxParams.to)
|
||||||
|
// add default tx params
|
||||||
txMeta = await this.addTxGasDefaults(txMeta)
|
txMeta = await this.addTxGasDefaults(txMeta)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
const KeyringController = require('eth-keyring-controller')
|
||||||
|
|
||||||
|
/** @module*/
|
||||||
|
module.exports = {
|
||||||
|
checkAccount,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param networkId {number}
|
||||||
|
@param account {string}
|
||||||
|
@returns {array}
|
||||||
|
*/
|
||||||
|
async function checkAccount (networkId, account) {
|
||||||
|
|
||||||
|
// mainnet's network id === 1
|
||||||
|
if (networkId !== 1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const damnedMnemonic = 'candy maple cake sugar pudding cream honey rich smooth crumble sweet treat'
|
||||||
|
const keyringController = new KeyringController({})
|
||||||
|
const Keyring = keyringController.getKeyringClassForType('HD Key Tree')
|
||||||
|
const opts = {
|
||||||
|
mnemonic: damnedMnemonic,
|
||||||
|
numberOfAccounts: 10,
|
||||||
|
}
|
||||||
|
|
||||||
|
const accountToCheck = account.toLowerCase()
|
||||||
|
const keyring = new Keyring(opts)
|
||||||
|
const damnedAccounts = await keyring.getAccounts()
|
||||||
|
for (let i = 0; i < damnedAccounts.length; i++) {
|
||||||
|
if (damnedAccounts[i].toLowerCase() === accountToCheck) {
|
||||||
|
throw new Error('this is a public account')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user