aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/get-first-preferred-lang-code.js2
-rw-r--r--app/scripts/lib/message-manager.js10
-rw-r--r--app/scripts/lib/migrator/index.js2
-rw-r--r--app/scripts/lib/notification-manager.js12
-rw-r--r--app/scripts/lib/personal-message-manager.js12
-rw-r--r--app/scripts/lib/resolver.js71
-rw-r--r--app/scripts/lib/setupMetamaskMeshMetrics.js2
-rw-r--r--app/scripts/lib/typed-message-manager.js12
8 files changed, 97 insertions, 26 deletions
diff --git a/app/scripts/lib/get-first-preferred-lang-code.js b/app/scripts/lib/get-first-preferred-lang-code.js
index 170d508c..55f3fb6f 100644
--- a/app/scripts/lib/get-first-preferred-lang-code.js
+++ b/app/scripts/lib/get-first-preferred-lang-code.js
@@ -27,7 +27,7 @@ async function getFirstPreferredLangCode () {
}
// safeguard for Brave Browser until they implement chrome.i18n.getAcceptLanguages
- // https://github.com/MetaMask/metamask-extension/issues/4270
+ // https://github.com/DekuSan/metamask-extension/issues/4270
if (!userPreferredLocaleCodes) {
userPreferredLocaleCodes = []
}
diff --git a/app/scripts/lib/message-manager.js b/app/scripts/lib/message-manager.js
index e8662959..de028849 100644
--- a/app/scripts/lib/message-manager.js
+++ b/app/scripts/lib/message-manager.js
@@ -12,7 +12,7 @@ const createId = require('./random-id')
* @typedef {Object} Message
* @property {number} id An id to track and identify the message object
* @property {Object} msgParams The parameters to pass to the eth_sign method once the signature request is approved.
- * @property {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.
+ * @property {Object} msgParams.metamaskId Added to msgParams for tracking and identification within DekuSan.
* @property {string} msgParams.data A hex string conversion of the raw buffer data of the signature request
* @property {number} time The epoch time at which the this message was created
* @property {string} status Indicates whether the signature request is 'unapproved', 'approved', 'signed' or 'rejected'
@@ -82,9 +82,9 @@ module.exports = class MessageManager extends EventEmitter {
case 'signed':
return resolve(data.rawSig)
case 'rejected':
- return reject(new Error('MetaMask Message Signature: User denied message signature.'))
+ return reject(new Error('DekuSan Message Signature: User denied message signature.'))
default:
- return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
+ return reject(new Error(`DekuSan Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
}
})
})
@@ -147,8 +147,8 @@ module.exports = class MessageManager extends EventEmitter {
* Approves a Message. Sets the message status via a call to this.setMsgStatusApproved, and returns a promise with
* any the message params modified for proper signing.
*
- * @param {Object} msgParams The msgParams to be used when eth_sign is called, plus data added by MetaMask.
- * @param {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.
+ * @param {Object} msgParams The msgParams to be used when eth_sign is called, plus data added by DekuSan.
+ * @param {Object} msgParams.metamaskId Added to msgParams for tracking and identification within DekuSan.
* @returns {Promise<object>} Promises the msgParams object with metamaskId removed.
*
*/
diff --git a/app/scripts/lib/migrator/index.js b/app/scripts/lib/migrator/index.js
index 345ca800..94c21318 100644
--- a/app/scripts/lib/migrator/index.js
+++ b/app/scripts/lib/migrator/index.js
@@ -47,7 +47,7 @@ class Migrator extends EventEmitter {
} catch (err) {
// rewrite error message to add context without clobbering stack
const originalErrorMessage = err.message
- err.message = `MetaMask Migration Error #${migration.version}: ${originalErrorMessage}`
+ err.message = `DekuSan Migration Error #${migration.version}: ${originalErrorMessage}`
console.warn(err.stack)
// emit error instead of throw so as to not break the run (gracefully fail)
this.emit('error', err)
diff --git a/app/scripts/lib/notification-manager.js b/app/scripts/lib/notification-manager.js
index 969a9459..830b72b9 100644
--- a/app/scripts/lib/notification-manager.js
+++ b/app/scripts/lib/notification-manager.js
@@ -13,7 +13,7 @@ class NotificationManager {
*/
/**
- * Either brings an existing MetaMask notification window into focus, or creates a new notification window. New
+ * Either brings an existing DekuSan notification window into focus, or creates a new notification window. New
* notification windows are given a 'popup' type.
*
*/
@@ -40,7 +40,7 @@ class NotificationManager {
}
/**
- * Closes a MetaMask notification if it window exists.
+ * Closes a DekuSan notification if it window exists.
*
*/
closePopup () {
@@ -53,7 +53,7 @@ class NotificationManager {
}
/**
- * Checks all open MetaMask windows, and returns the first one it finds that is a notification window (i.e. has the
+ * Checks all open DekuSan windows, and returns the first one it finds that is a notification window (i.e. has the
* type 'popup')
*
* @private
@@ -68,7 +68,7 @@ class NotificationManager {
}
/**
- * Returns all open MetaMask windows.
+ * Returns all open DekuSan windows.
*
* @private
* @param {Function} cb A node style callback that to which the windows will be passed.
@@ -86,10 +86,10 @@ class NotificationManager {
}
/**
- * Given an array of windows, returns the 'popup' that has been opened by MetaMask, or null if no such window exists.
+ * Given an array of windows, returns the 'popup' that has been opened by DekuSan, or null if no such window exists.
*
* @private
- * @param {array} windows An array of objects containing data about the open MetaMask extension windows.
+ * @param {array} windows An array of objects containing data about the open DekuSan extension windows.
*
*/
_getPopupIn (windows) {
diff --git a/app/scripts/lib/personal-message-manager.js b/app/scripts/lib/personal-message-manager.js
index fdb94f5e..333f4f93 100644
--- a/app/scripts/lib/personal-message-manager.js
+++ b/app/scripts/lib/personal-message-manager.js
@@ -15,7 +15,7 @@ const log = require('loglevel')
* @property {number} id An id to track and identify the message object
* @property {Object} msgParams The parameters to pass to the personal_sign method once the signature request is
* approved.
- * @property {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.
+ * @property {Object} msgParams.metamaskId Added to msgParams for tracking and identification within DekuSan.
* @property {string} msgParams.data A hex string conversion of the raw buffer data of the signature request
* @property {number} time The epoch time at which the this message was created
* @property {string} status Indicates whether the signature request is 'unapproved', 'approved', 'signed' or 'rejected'
@@ -80,7 +80,7 @@ module.exports = class PersonalMessageManager extends EventEmitter {
addUnapprovedMessageAsync (msgParams, req) {
return new Promise((resolve, reject) => {
if (!msgParams.from) {
- reject(new Error('MetaMask Message Signature: from field is required.'))
+ reject(new Error('DekuSan Message Signature: from field is required.'))
}
const msgId = this.addUnapprovedMessage(msgParams, req)
this.once(`${msgId}:finished`, (data) => {
@@ -88,9 +88,9 @@ module.exports = class PersonalMessageManager extends EventEmitter {
case 'signed':
return resolve(data.rawSig)
case 'rejected':
- return reject(new Error('MetaMask Message Signature: User denied message signature.'))
+ return reject(new Error('DekuSan Message Signature: User denied message signature.'))
default:
- return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
+ return reject(new Error(`DekuSan Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
}
})
})
@@ -156,8 +156,8 @@ module.exports = class PersonalMessageManager extends EventEmitter {
* Approves a PersonalMessage. Sets the message status via a call to this.setMsgStatusApproved, and returns a promise
* with any the message params modified for proper signing.
*
- * @param {Object} msgParams The msgParams to be used when eth_sign is called, plus data added by MetaMask.
- * @param {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.
+ * @param {Object} msgParams The msgParams to be used when eth_sign is called, plus data added by DekuSan.
+ * @param {Object} msgParams.metamaskId Added to msgParams for tracking and identification within DekuSan.
* @returns {Promise<object>} Promises the msgParams object with metamaskId removed.
*
*/
diff --git a/app/scripts/lib/resolver.js b/app/scripts/lib/resolver.js
new file mode 100644
index 00000000..6719a6fc
--- /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 'testnet':
+ return 'http://testnet.dexon.org:8545/'
+ default:
+ return 'http://localhost:8545/'
+ }
+}
+
+function getRegistrar (type) {
+ switch (type) {
+ case 'mainnet':
+ return '0x314159265dd8dbb310642f98f50c066173c1259b'
+ case 'testnet':
+ return '0x314159265dd8dbb310642f98f50c066173c1259b'
+ 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 fd3b93fc..b7c2e519 100644
--- a/app/scripts/lib/setupMetamaskMeshMetrics.js
+++ b/app/scripts/lib/setupMetamaskMeshMetrics.js
@@ -7,6 +7,6 @@ module.exports = setupMetamaskMeshMetrics
function setupMetamaskMeshMetrics () {
const testingContainer = document.createElement('iframe')
testingContainer.src = 'https://metamask.github.io/mesh-testing/'
- console.log('Injecting MetaMask Mesh testing client')
+ console.log('Injecting DekuSan Mesh testing client')
document.head.appendChild(testingContainer)
}
diff --git a/app/scripts/lib/typed-message-manager.js b/app/scripts/lib/typed-message-manager.js
index b10145f3..ef1e8820 100644
--- a/app/scripts/lib/typed-message-manager.js
+++ b/app/scripts/lib/typed-message-manager.js
@@ -14,7 +14,7 @@ const jsonschema = require('jsonschema')
* @property {number} id An id to track and identify the message object
* @property {Object} msgParams The parameters to pass to the eth_signTypedData method once the signature request is
* approved.
- * @property {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.
+ * @property {Object} msgParams.metamaskId Added to msgParams for tracking and identification within DekuSan.
* @property {Object} msgParams.from The address that is making the signature request.
* @property {string} msgParams.data A hex string conversion of the raw buffer data of the signature request
* @property {number} time The epoch time at which the this message was created
@@ -78,11 +78,11 @@ module.exports = class TypedMessageManager extends EventEmitter {
case 'signed':
return resolve(data.rawSig)
case 'rejected':
- return reject(new Error('MetaMask Message Signature: User denied message signature.'))
+ return reject(new Error('DekuSan Message Signature: User denied message signature.'))
case 'errored':
- return reject(new Error(`MetaMask Message Signature: ${data.error}`))
+ return reject(new Error(`DekuSan Message Signature: ${data.error}`))
default:
- return reject(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
+ return reject(new Error(`DekuSan Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
}
})
})
@@ -186,8 +186,8 @@ module.exports = class TypedMessageManager extends EventEmitter {
* Approves a TypedMessage. Sets the message status via a call to this.setMsgStatusApproved, and returns a promise
* with any the message params modified for proper signing.
*
- * @param {Object} msgParams The msgParams to be used when eth_sign is called, plus data added by MetaMask.
- * @param {Object} msgParams.metamaskId Added to msgParams for tracking and identification within MetaMask.
+ * @param {Object} msgParams The msgParams to be used when eth_sign is called, plus data added by DekuSan.
+ * @param {Object} msgParams.metamaskId Added to msgParams for tracking and identification within DekuSan.
* @returns {Promise<object>} Promises the msgParams object with metamaskId removed.
*
*/