expose web3.metamask.watchAsset

This commit is contained in:
Esteban MIno 2018-08-22 18:14:10 -03:00
parent 153731e462
commit 56bed3f1bc
1 changed files with 17 additions and 0 deletions

View File

@ -14,6 +14,23 @@ function setupDappAutoReload (web3, observable) {
console.warn('MetaMask: web3 will be deprecated in the near future in favor of the ethereumProvider \nhttps://github.com/MetaMask/faq/blob/master/detecting_metamask.md#web3-deprecation')
hasBeenWarned = true
}
// setup wallet
if (key === 'metamask') {
return {
watchAsset: (params) => {
return new Promise((resolve, reject) => {
web3.currentProvider.sendAsync({
jsonrpc: '2.0',
method: 'metamask_watchAsset',
params,
}, (err, res) => {
if (err) reject(err)
resolve(res)
})
})
},
}
}
// get the time of use
lastTimeUsed = Date.now()
// return value normally