2016-03-25 00:18:01 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const inherits = require('util').inherits
|
|
|
|
const HookedWalletEthTxSubprovider = require('web3-provider-engine/subproviders/hooked-wallet-ethtx')
|
|
|
|
|
|
|
|
module.exports = WalletSubprovider
|
|
|
|
|
|
|
|
inherits(WalletSubprovider, HookedWalletEthTxSubprovider)
|
|
|
|
|
|
|
|
function WalletSubprovider (wallet, opts) {
|
|
|
|
opts.getAccounts = function (cb) {
|
2017-06-24 12:46:19 +00:00
|
|
|
cb(null, [ wallet.getAddressString() ])
|
2016-03-25 00:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
opts.getPrivateKey = function (address, cb) {
|
|
|
|
if (address !== wallet.getAddressString()) {
|
2017-09-28 10:25:14 +00:00
|
|
|
cb(new Error('Account not found'))
|
|
|
|
} else {
|
|
|
|
cb(null, wallet.getPrivateKey())
|
2016-03-25 00:18:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WalletSubprovider.super_.call(this, opts)
|
|
|
|
}
|