aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorDan Finlay <542863+danfinlay@users.noreply.github.com>2018-08-08 02:31:42 +0800
committerGitHub <noreply@github.com>2018-08-08 02:31:42 +0800
commit0601df9dae488d997277bb6b52c28df27546e27c (patch)
treeae33a0c4610b9a9e865c797258232542a72f57b6 /app/scripts/lib
parent4598554fea7b9435e5cbecc4735c479ffbadf37e (diff)
parentf6490a2a6eda943a374c01df5884acb07ba28869 (diff)
downloadtangerine-wallet-browser-0601df9dae488d997277bb6b52c28df27546e27c.tar
tangerine-wallet-browser-0601df9dae488d997277bb6b52c28df27546e27c.tar.gz
tangerine-wallet-browser-0601df9dae488d997277bb6b52c28df27546e27c.tar.bz2
tangerine-wallet-browser-0601df9dae488d997277bb6b52c28df27546e27c.tar.lz
tangerine-wallet-browser-0601df9dae488d997277bb6b52c28df27546e27c.tar.xz
tangerine-wallet-browser-0601df9dae488d997277bb6b52c28df27546e27c.tar.zst
tangerine-wallet-browser-0601df9dae488d997277bb6b52c28df27546e27c.zip
Merge pull request #4954 from MetaMask/v4.9.0
V4.9.0
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/cleanErrorStack.js2
-rw-r--r--app/scripts/lib/contracts/registrar.js1
-rw-r--r--app/scripts/lib/contracts/resolver.js2
-rw-r--r--app/scripts/lib/createErrorMiddleware.js2
-rw-r--r--app/scripts/lib/createStreamSink.js2
-rw-r--r--app/scripts/lib/diagnostics-reporter.js6
-rw-r--r--app/scripts/lib/extractEthjsErrorMessage.js4
-rw-r--r--app/scripts/lib/get-first-preferred-lang-code.js2
-rw-r--r--app/scripts/lib/getObjStructure.js6
-rw-r--r--app/scripts/lib/inpage-provider.js5
-rw-r--r--app/scripts/lib/ipfsContent.js44
-rw-r--r--app/scripts/lib/local-store.js12
-rw-r--r--app/scripts/lib/notification-manager.js10
-rw-r--r--app/scripts/lib/port-stream.js2
-rw-r--r--app/scripts/lib/reportFailedTxToSentry.js2
-rw-r--r--app/scripts/lib/resolver.js71
-rw-r--r--app/scripts/lib/setupMetamaskMeshMetrics.js2
-rw-r--r--app/scripts/lib/setupRaven.js22
-rw-r--r--app/scripts/lib/util.js2
19 files changed, 164 insertions, 35 deletions
diff --git a/app/scripts/lib/cleanErrorStack.js b/app/scripts/lib/cleanErrorStack.js
index fe1bfb0ce..8adf55db7 100644
--- a/app/scripts/lib/cleanErrorStack.js
+++ b/app/scripts/lib/cleanErrorStack.js
@@ -3,7 +3,7 @@
* @param {Error} err - error
* @returns {Error} Error with clean stack trace.
*/
-function cleanErrorStack(err){
+function cleanErrorStack (err) {
var name = err.name
name = (name === undefined) ? 'Error' : String(name)
diff --git a/app/scripts/lib/contracts/registrar.js b/app/scripts/lib/contracts/registrar.js
new file mode 100644
index 000000000..99ca24458
--- /dev/null
+++ b/app/scripts/lib/contracts/registrar.js
@@ -0,0 +1 @@
+module.exports = [{'constant': true, 'inputs': [{'name': 'node', 'type': 'bytes32'}], 'name': 'resolver', 'outputs': [{'name': '', 'type': 'address'}], 'payable': false, 'type': 'function'}, {'constant': true, 'inputs': [{'name': 'node', 'type': 'bytes32'}], 'name': 'owner', 'outputs': [{'name': '', 'type': 'address'}], 'payable': false, 'type': 'function'}, {'constant': false, 'inputs': [{'name': 'node', 'type': 'bytes32'}, {'name': 'label', 'type': 'bytes32'}, {'name': 'owner', 'type': 'address'}], 'name': 'setSubnodeOwner', 'outputs': [], 'payable': false, 'type': 'function'}, {'constant': false, 'inputs': [{'name': 'node', 'type': 'bytes32'}, {'name': 'ttl', 'type': 'uint64'}], 'name': 'setTTL', 'outputs': [], 'payable': false, 'type': 'function'}, {'constant': true, 'inputs': [{'name': 'node', 'type': 'bytes32'}], 'name': 'ttl', 'outputs': [{'name': '', 'type': 'uint64'}], 'payable': false, 'type': 'function'}, {'constant': false, 'inputs': [{'name': 'node', 'type': 'bytes32'}, {'name': 'resolver', 'type': 'address'}], 'name': 'setResolver', 'outputs': [], 'payable': false, 'type': 'function'}, {'constant': false, 'inputs': [{'name': 'node', 'type': 'bytes32'}, {'name': 'owner', 'type': 'address'}], 'name': 'setOwner', 'outputs': [], 'payable': false, 'type': 'function'}, {'anonymous': false, 'inputs': [{'indexed': true, 'name': 'node', 'type': 'bytes32'}, {'indexed': false, 'name': 'owner', 'type': 'address'}], 'name': 'Transfer', 'type': 'event'}, {'anonymous': false, 'inputs': [{'indexed': true, 'name': 'node', 'type': 'bytes32'}, {'indexed': true, 'name': 'label', 'type': 'bytes32'}, {'indexed': false, 'name': 'owner', 'type': 'address'}], 'name': 'NewOwner', 'type': 'event'}, {'anonymous': false, 'inputs': [{'indexed': true, 'name': 'node', 'type': 'bytes32'}, {'indexed': false, 'name': 'resolver', 'type': 'address'}], 'name': 'NewResolver', 'type': 'event'}, {'anonymous': false, 'inputs': [{'indexed': true, 'name': 'node', 'type': 'bytes32'}, {'indexed': false, 'name': 'ttl', 'type': 'uint64'}], 'name': 'NewTTL', 'type': 'event'}]
diff --git a/app/scripts/lib/contracts/resolver.js b/app/scripts/lib/contracts/resolver.js
new file mode 100644
index 000000000..1bf3f90ce
--- /dev/null
+++ b/app/scripts/lib/contracts/resolver.js
@@ -0,0 +1,2 @@
+module.exports =
+[{'constant': true, 'inputs': [{'name': 'interfaceID', 'type': 'bytes4'}], 'name': 'supportsInterface', 'outputs': [{'name': '', 'type': 'bool'}], 'payable': false, 'type': 'function'}, {'constant': true, 'inputs': [{'name': 'node', 'type': 'bytes32'}, {'name': 'contentTypes', 'type': 'uint256'}], 'name': 'ABI', 'outputs': [{'name': 'contentType', 'type': 'uint256'}, {'name': 'data', 'type': 'bytes'}], 'payable': false, 'type': 'function'}, {'constant': false, 'inputs': [{'name': 'node', 'type': 'bytes32'}, {'name': 'x', 'type': 'bytes32'}, {'name': 'y', 'type': 'bytes32'}], 'name': 'setPubkey', 'outputs': [], 'payable': false, 'type': 'function'}, {'constant': true, 'inputs': [{'name': 'node', 'type': 'bytes32'}], 'name': 'content', 'outputs': [{'name': 'ret', 'type': 'bytes32'}], 'payable': false, 'type': 'function'}, {'constant': true, 'inputs': [{'name': 'node', 'type': 'bytes32'}], 'name': 'addr', 'outputs': [{'name': 'ret', 'type': 'address'}], 'payable': false, 'type': 'function'}, {'constant': false, 'inputs': [{'name': 'node', 'type': 'bytes32'}, {'name': 'contentType', 'type': 'uint256'}, {'name': 'data', 'type': 'bytes'}], 'name': 'setABI', 'outputs': [], 'payable': false, 'type': 'function'}, {'constant': true, 'inputs': [{'name': 'node', 'type': 'bytes32'}], 'name': 'name', 'outputs': [{'name': 'ret', 'type': 'string'}], 'payable': false, 'type': 'function'}, {'constant': false, 'inputs': [{'name': 'node', 'type': 'bytes32'}, {'name': 'name', 'type': 'string'}], 'name': 'setName', 'outputs': [], 'payable': false, 'type': 'function'}, {'constant': false, 'inputs': [{'name': 'node', 'type': 'bytes32'}, {'name': 'hash', 'type': 'bytes32'}], 'name': 'setContent', 'outputs': [], 'payable': false, 'type': 'function'}, {'constant': true, 'inputs': [{'name': 'node', 'type': 'bytes32'}], 'name': 'pubkey', 'outputs': [{'name': 'x', 'type': 'bytes32'}, {'name': 'y', 'type': 'bytes32'}], 'payable': false, 'type': 'function'}, {'constant': false, 'inputs': [{'name': 'node', 'type': 'bytes32'}, {'name': 'addr', 'type': 'address'}], 'name': 'setAddr', 'outputs': [], 'payable': false, 'type': 'function'}, {'inputs': [{'name': 'ensAddr', 'type': 'address'}], 'payable': false, 'type': 'constructor'}, {'anonymous': false, 'inputs': [{'indexed': true, 'name': 'node', 'type': 'bytes32'}, {'indexed': false, 'name': 'a', 'type': 'address'}], 'name': 'AddrChanged', 'type': 'event'}, {'anonymous': false, 'inputs': [{'indexed': true, 'name': 'node', 'type': 'bytes32'}, {'indexed': false, 'name': 'hash', 'type': 'bytes32'}], 'name': 'ContentChanged', 'type': 'event'}, {'anonymous': false, 'inputs': [{'indexed': true, 'name': 'node', 'type': 'bytes32'}, {'indexed': false, 'name': 'name', 'type': 'string'}], 'name': 'NameChanged', 'type': 'event'}, {'anonymous': false, 'inputs': [{'indexed': true, 'name': 'node', 'type': 'bytes32'}, {'indexed': true, 'name': 'contentType', 'type': 'uint256'}], 'name': 'ABIChanged', 'type': 'event'}, {'anonymous': false, 'inputs': [{'indexed': true, 'name': 'node', 'type': 'bytes32'}, {'indexed': false, 'name': 'x', 'type': 'bytes32'}, {'indexed': false, 'name': 'y', 'type': 'bytes32'}], 'name': 'PubkeyChanged', 'type': 'event'}]
diff --git a/app/scripts/lib/createErrorMiddleware.js b/app/scripts/lib/createErrorMiddleware.js
index c70beddfd..7f6a4bd73 100644
--- a/app/scripts/lib/createErrorMiddleware.js
+++ b/app/scripts/lib/createErrorMiddleware.js
@@ -64,4 +64,4 @@ function createErrorMiddleware ({ override = true } = {}) {
}
}
-module.exports = createErrorMiddleware \ No newline at end of file
+module.exports = createErrorMiddleware
diff --git a/app/scripts/lib/createStreamSink.js b/app/scripts/lib/createStreamSink.js
index cf9416fea..b93dbc089 100644
--- a/app/scripts/lib/createStreamSink.js
+++ b/app/scripts/lib/createStreamSink.js
@@ -4,7 +4,7 @@ const promiseToCallback = require('promise-to-callback')
module.exports = createStreamSink
-function createStreamSink(asyncWriteFn, _opts) {
+function createStreamSink (asyncWriteFn, _opts) {
return new AsyncWritableStream(asyncWriteFn, _opts)
}
diff --git a/app/scripts/lib/diagnostics-reporter.js b/app/scripts/lib/diagnostics-reporter.js
index aa4ca6e26..569eb3268 100644
--- a/app/scripts/lib/diagnostics-reporter.js
+++ b/app/scripts/lib/diagnostics-reporter.js
@@ -5,7 +5,7 @@ class DiagnosticsReporter {
this.version = version
}
- async reportOrphans(orphans) {
+ async reportOrphans (orphans) {
try {
return await this.submit({
accounts: Object.keys(orphans),
@@ -19,7 +19,7 @@ class DiagnosticsReporter {
}
}
- async reportMultipleKeyrings(rawKeyrings) {
+ async reportMultipleKeyrings (rawKeyrings) {
try {
const keyrings = await Promise.all(rawKeyrings.map(async (keyring, index) => {
return {
@@ -55,7 +55,7 @@ class DiagnosticsReporter {
}
-function postData(data) {
+function postData (data) {
const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts'
return fetch(uri, {
body: JSON.stringify(data), // must match 'Content-Type' header
diff --git a/app/scripts/lib/extractEthjsErrorMessage.js b/app/scripts/lib/extractEthjsErrorMessage.js
index 0f100756f..4891075c3 100644
--- a/app/scripts/lib/extractEthjsErrorMessage.js
+++ b/app/scripts/lib/extractEthjsErrorMessage.js
@@ -10,13 +10,13 @@ module.exports = extractEthjsErrorMessage
*
* @param {string} errorMessage The error message to parse
* @returns {string} Returns an error message, either the same as was passed, or the ending message portion of an isEthjsRpcError
- *
+ *
* @example
* // returns 'Transaction Failed: replacement transaction underpriced'
* extractEthjsErrorMessage(`Error: [ethjs-rpc] rpc error with payload {"id":3947817945380,"jsonrpc":"2.0","params":["0xf8eb8208708477359400830398539406012c8cf97bead5deae237070f9587f8e7a266d80b8843d7d3f5a0000000000000000000000000000000000000000000000000000000000081d1a000000000000000000000000000000000000000000000000001ff973cafa800000000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000003f48025a04c32a9b630e0d9e7ff361562d850c86b7a884908135956a7e4a336fa0300d19ca06830776423f25218e8d19b267161db526e66895567147015b1f3fc47aef9a3c7"],"method":"eth_sendRawTransaction"} Error: replacement transaction underpriced`)
*
*/
-function extractEthjsErrorMessage(errorMessage) {
+function extractEthjsErrorMessage (errorMessage) {
const isEthjsRpcError = errorMessage.includes(ethJsRpcSlug)
if (isEthjsRpcError) {
const payloadAndError = errorMessage.slice(ethJsRpcSlug.length)
diff --git a/app/scripts/lib/get-first-preferred-lang-code.js b/app/scripts/lib/get-first-preferred-lang-code.js
index 41a886d74..170d508c1 100644
--- a/app/scripts/lib/get-first-preferred-lang-code.js
+++ b/app/scripts/lib/get-first-preferred-lang-code.js
@@ -28,7 +28,7 @@ async function getFirstPreferredLangCode () {
// safeguard for Brave Browser until they implement chrome.i18n.getAcceptLanguages
// https://github.com/MetaMask/metamask-extension/issues/4270
- if (!userPreferredLocaleCodes){
+ if (!userPreferredLocaleCodes) {
userPreferredLocaleCodes = []
}
diff --git a/app/scripts/lib/getObjStructure.js b/app/scripts/lib/getObjStructure.js
index 52250d3fb..9c92879fb 100644
--- a/app/scripts/lib/getObjStructure.js
+++ b/app/scripts/lib/getObjStructure.js
@@ -18,12 +18,12 @@ module.exports = getObjStructure
* Creates an object that represents the structure of the given object. It replaces all values with the result of their
* type.
*
- * @param {object} obj The object for which a 'structure' will be returned. Usually a plain object and not a class.
+ * @param {object} obj The object for which a 'structure' will be returned. Usually a plain object and not a class.
* @returns {object} The "mapped" version of a deep clone of the passed object, with each non-object property value
* replaced with the javascript type of that value.
*
*/
-function getObjStructure(obj) {
+function getObjStructure (obj) {
const structure = clone(obj)
return deepMap(structure, (value) => {
return value === null ? 'null' : typeof value
@@ -38,7 +38,7 @@ function getObjStructure(obj) {
* @param {Function} visit The modifier to apply to each non-object property value
* @returns {object} The modified object
*/
-function deepMap(target = {}, visit) {
+function deepMap (target = {}, visit) {
Object.entries(target).forEach(([key, value]) => {
if (typeof value === 'object' && value !== null) {
target[key] = deepMap(value, visit)
diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js
index 4e65f0a23..6ef511453 100644
--- a/app/scripts/lib/inpage-provider.js
+++ b/app/scripts/lib/inpage-provider.js
@@ -54,6 +54,11 @@ function MetamaskInpageProvider (connectionStream) {
// also remap ids inbound and outbound
MetamaskInpageProvider.prototype.sendAsync = function (payload, cb) {
const self = this
+
+ if (payload.method === 'eth_signTypedData') {
+ console.warn('MetaMask: This experimental version of eth_signTypedData will be deprecated in the next release in favor of the standard as defined in EIP-712. See https://git.io/fNzPl for more information on the new standard.')
+ }
+
self.rpcEngine.handle(payload, cb)
}
diff --git a/app/scripts/lib/ipfsContent.js b/app/scripts/lib/ipfsContent.js
new file mode 100644
index 000000000..5222151ea
--- /dev/null
+++ b/app/scripts/lib/ipfsContent.js
@@ -0,0 +1,44 @@
+const extension = require('extensionizer')
+const resolver = require('./resolver.js')
+
+module.exports = function (provider) {
+ function ipfsContent (details) {
+ const name = details.url.substring(7, details.url.length - 1)
+ let clearTime = null
+ extension.tabs.getSelected(null, tab => {
+ extension.tabs.update(tab.id, { url: 'loading.html' })
+
+ clearTime = setTimeout(() => {
+ return extension.tabs.update(tab.id, { url: '404.html' })
+ }, 60000)
+
+ resolver.resolve(name, provider).then(ipfsHash => {
+ clearTimeout(clearTime)
+ let url = 'https://ipfs.infura.io/ipfs/' + ipfsHash
+ return fetch(url, { method: 'HEAD' }).then(response => response.status).then(statusCode => {
+ if (statusCode !== 200) return extension.tabs.update(tab.id, { url: '404.html' })
+ extension.tabs.update(tab.id, { url: url })
+ })
+ .catch(err => {
+ url = 'https://ipfs.infura.io/ipfs/' + ipfsHash
+ extension.tabs.update(tab.id, {url: url})
+ return err
+ })
+ })
+ .catch(err => {
+ clearTimeout(clearTime)
+ const url = err === 'unsupport' ? 'unsupport' : 'error'
+ extension.tabs.update(tab.id, {url: `${url}.html?name=${name}`})
+ })
+ })
+ return { cancel: true }
+ }
+
+ extension.webRequest.onBeforeRequest.addListener(ipfsContent, {urls: ['*://*.eth/', '*://*.test/']})
+
+ return {
+ remove () {
+ extension.webRequest.onBeforeRequest.removeListener(ipfsContent)
+ },
+ }
+}
diff --git a/app/scripts/lib/local-store.js b/app/scripts/lib/local-store.js
index 139ff86bd..fbcba09cd 100644
--- a/app/scripts/lib/local-store.js
+++ b/app/scripts/lib/local-store.js
@@ -8,7 +8,7 @@ module.exports = class ExtensionStore {
/**
* @constructor
*/
- constructor() {
+ constructor () {
this.isSupported = !!(extension.storage.local)
if (!this.isSupported) {
log.error('Storage local API not available.')
@@ -19,7 +19,7 @@ module.exports = class ExtensionStore {
* Returns all of the keys currently saved
* @return {Promise<*>}
*/
- async get() {
+ async get () {
if (!this.isSupported) return undefined
const result = await this._get()
// extension.storage.local always returns an obj
@@ -36,7 +36,7 @@ module.exports = class ExtensionStore {
* @param {object} state - The state to set
* @return {Promise<void>}
*/
- async set(state) {
+ async set (state) {
return this._set(state)
}
@@ -45,7 +45,7 @@ module.exports = class ExtensionStore {
* @private
* @return {object} the key-value map from local storage
*/
- _get() {
+ _get () {
const local = extension.storage.local
return new Promise((resolve, reject) => {
local.get(null, (/** @type {any} */ result) => {
@@ -65,7 +65,7 @@ module.exports = class ExtensionStore {
* @return {Promise<void>}
* @private
*/
- _set(obj) {
+ _set (obj) {
const local = extension.storage.local
return new Promise((resolve, reject) => {
local.set(obj, () => {
@@ -85,6 +85,6 @@ module.exports = class ExtensionStore {
* @param {object} obj - The object to check
* @returns {boolean}
*/
-function isEmpty(obj) {
+function isEmpty (obj) {
return Object.keys(obj).length === 0
}
diff --git a/app/scripts/lib/notification-manager.js b/app/scripts/lib/notification-manager.js
index 5dfb42078..969a9459a 100644
--- a/app/scripts/lib/notification-manager.js
+++ b/app/scripts/lib/notification-manager.js
@@ -26,13 +26,15 @@ class NotificationManager {
// bring focus to existing chrome popup
extension.windows.update(popup.id, { focused: true })
} else {
+ const cb = (currentPopup) => { this._popupId = currentPopup.id }
// create new notification popup
- extension.windows.create({
+ const creation = extension.windows.create({
url: 'notification.html',
type: 'popup',
width,
height,
- })
+ }, cb)
+ creation && creation.then && creation.then(cb)
}
})
}
@@ -84,7 +86,7 @@ class NotificationManager {
}
/**
- * Given an array of windows, returns the first that has a 'popup' type, or null if no such window exists.
+ * Given an array of windows, returns the 'popup' that has been opened by MetaMask, or null if no such window exists.
*
* @private
* @param {array} windows An array of objects containing data about the open MetaMask extension windows.
@@ -93,7 +95,7 @@ class NotificationManager {
_getPopupIn (windows) {
return windows ? windows.find((win) => {
// Returns notification popup
- return (win && win.type === 'popup')
+ return (win && win.type === 'popup' && win.id === this._popupId)
}) : null
}
diff --git a/app/scripts/lib/port-stream.js b/app/scripts/lib/port-stream.js
index 5c4224fd9..fd65d94f3 100644
--- a/app/scripts/lib/port-stream.js
+++ b/app/scripts/lib/port-stream.js
@@ -58,7 +58,7 @@ PortDuplexStream.prototype._read = noop
/**
* Called internally when data should be written to
* this writable stream.
- *
+ *
* @private
* @param {*} msg Arbitrary object to write
* @param {string} encoding Encoding to use when writing payload
diff --git a/app/scripts/lib/reportFailedTxToSentry.js b/app/scripts/lib/reportFailedTxToSentry.js
index e09f4f1f8..df5661e59 100644
--- a/app/scripts/lib/reportFailedTxToSentry.js
+++ b/app/scripts/lib/reportFailedTxToSentry.js
@@ -7,7 +7,7 @@ module.exports = reportFailedTxToSentry
// for sending to sentry
//
-function reportFailedTxToSentry({ raven, txMeta }) {
+function reportFailedTxToSentry ({ raven, txMeta }) {
const errorMessage = 'Transaction Failed: ' + extractEthjsErrorMessage(txMeta.err.message)
raven.captureMessage(errorMessage, {
// "extra" key is required by Sentry
diff --git a/app/scripts/lib/resolver.js b/app/scripts/lib/resolver.js
new file mode 100644
index 000000000..ff0fed161
--- /dev/null
+++ b/app/scripts/lib/resolver.js
@@ -0,0 +1,71 @@
+const namehash = require('eth-ens-namehash')
+const multihash = require('multihashes')
+const HttpProvider = require('ethjs-provider-http')
+const Eth = require('ethjs-query')
+const EthContract = require('ethjs-contract')
+const registrarAbi = require('./contracts/registrar')
+const resolverAbi = require('./contracts/resolver')
+
+function ens (name, provider) {
+ const eth = new Eth(new HttpProvider(getProvider(provider.type)))
+ const hash = namehash.hash(name)
+ const contract = new EthContract(eth)
+ const Registrar = contract(registrarAbi).at(getRegistrar(provider.type))
+ return new Promise((resolve, reject) => {
+ if (provider.type === 'mainnet' || provider.type === 'ropsten') {
+ Registrar.resolver(hash).then((address) => {
+ if (address === '0x0000000000000000000000000000000000000000') {
+ reject(null)
+ } else {
+ const Resolver = contract(resolverAbi).at(address['0'])
+ return Resolver.content(hash)
+ }
+ }).then((contentHash) => {
+ if (contentHash['0'] === '0x0000000000000000000000000000000000000000000000000000000000000000') reject(null)
+ if (contentHash.ret !== '0x') {
+ const hex = contentHash['0'].substring(2)
+ const buf = multihash.fromHexString(hex)
+ resolve(multihash.toB58String(multihash.encode(buf, 'sha2-256')))
+ } else {
+ reject(null)
+ }
+ })
+ } else {
+ return reject('unsupport')
+ }
+ })
+}
+
+function getProvider (type) {
+ switch (type) {
+ case 'mainnet':
+ return 'https://mainnet.infura.io/'
+ case 'ropsten':
+ return 'https://ropsten.infura.io/'
+ default:
+ return 'http://localhost:8545/'
+ }
+}
+
+function getRegistrar (type) {
+ switch (type) {
+ case 'mainnet':
+ return '0x314159265dd8dbb310642f98f50c066173c1259b'
+ case 'ropsten':
+ return '0x112234455c3a32fd11230c42e7bccd4a84e02010'
+ default:
+ return '0x0000000000000000000000000000000000000000'
+ }
+}
+
+module.exports.resolve = function (name, provider) {
+ const path = name.split('.')
+ const topLevelDomain = path[path.length - 1]
+ if (topLevelDomain === 'eth' || topLevelDomain === 'test') {
+ return ens(name, provider)
+ } else {
+ return new Promise((resolve, reject) => {
+ reject(null)
+ })
+ }
+}
diff --git a/app/scripts/lib/setupMetamaskMeshMetrics.js b/app/scripts/lib/setupMetamaskMeshMetrics.js
index 02690a948..fd3b93fc4 100644
--- a/app/scripts/lib/setupMetamaskMeshMetrics.js
+++ b/app/scripts/lib/setupMetamaskMeshMetrics.js
@@ -4,7 +4,7 @@ module.exports = setupMetamaskMeshMetrics
/**
* Injects an iframe into the current document for testing
*/
-function setupMetamaskMeshMetrics() {
+function setupMetamaskMeshMetrics () {
const testingContainer = document.createElement('iframe')
testingContainer.src = 'https://metamask.github.io/mesh-testing/'
console.log('Injecting MetaMask Mesh testing client')
diff --git a/app/scripts/lib/setupRaven.js b/app/scripts/lib/setupRaven.js
index 77aefb00a..e657e278f 100644
--- a/app/scripts/lib/setupRaven.js
+++ b/app/scripts/lib/setupRaven.js
@@ -7,9 +7,11 @@ const DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496'
module.exports = setupRaven
// Setup raven / sentry remote error reporting
-function setupRaven(opts) {
- const { release } = opts
+function setupRaven (opts) {
+ const { releaseVersion } = opts
let ravenTarget
+ // detect brave
+ const isBrave = Boolean(window.chrome.ipcRenderer)
if (METAMASK_DEBUG) {
console.log('Setting up Sentry Remote Error Reporting: DEV')
@@ -20,9 +22,11 @@ function setupRaven(opts) {
}
const client = Raven.config(ravenTarget, {
- release,
- transport: function(opts) {
+ releaseVersion,
+ transport: function (opts) {
+ opts.data.extra.isBrave = isBrave
const report = opts.data
+
try {
// handle error-like non-error exceptions
rewriteErrorLikeExceptions(report)
@@ -42,7 +46,7 @@ function setupRaven(opts) {
return Raven
}
-function rewriteErrorLikeExceptions(report) {
+function rewriteErrorLikeExceptions (report) {
// handle errors that lost their error-ness in serialization (e.g. dnode)
rewriteErrorMessages(report, (errorMessage) => {
if (!errorMessage.includes('Non-Error exception captured with keys:')) return errorMessage
@@ -51,7 +55,7 @@ function rewriteErrorLikeExceptions(report) {
})
}
-function simplifyErrorMessages(report) {
+function simplifyErrorMessages (report) {
rewriteErrorMessages(report, (errorMessage) => {
// simplify ethjs error messages
errorMessage = extractEthjsErrorMessage(errorMessage)
@@ -64,7 +68,7 @@ function simplifyErrorMessages(report) {
})
}
-function rewriteErrorMessages(report, rewriteFn) {
+function rewriteErrorMessages (report, rewriteFn) {
// rewrite top level message
if (report.message) report.message = rewriteFn(report.message)
// rewrite each exception message
@@ -75,7 +79,7 @@ function rewriteErrorMessages(report, rewriteFn) {
}
}
-function rewriteReportUrls(report) {
+function rewriteReportUrls (report) {
// update request url
report.request.url = toMetamaskUrl(report.request.url)
// update exception stack trace
@@ -88,7 +92,7 @@ function rewriteReportUrls(report) {
}
}
-function toMetamaskUrl(origUrl) {
+function toMetamaskUrl (origUrl) {
const filePath = origUrl.split(location.origin)[1]
if (!filePath) return origUrl
const metamaskUrl = `metamask${filePath}`
diff --git a/app/scripts/lib/util.js b/app/scripts/lib/util.js
index 431d1e59c..51e9036cc 100644
--- a/app/scripts/lib/util.js
+++ b/app/scripts/lib/util.js
@@ -28,7 +28,7 @@ function getStack () {
*
*/
const getEnvironmentType = (url = window.location.href) => {
- if (url.match(/popup.html(?:\?.+)*$/)) {
+ if (url.match(/popup.html(?:#.*)*$/)) {
return ENVIRONMENT_TYPE_POPUP
} else if (url.match(/home.html(?:\?.+)*$/) || url.match(/home.html(?:#.*)*$/)) {
return ENVIRONMENT_TYPE_FULLSCREEN