Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit b27e211

Browse files
committed
Add provider-engine provider supporting signing
1 parent bc1f289 commit b27e211

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

provider-engine.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict'
2+
3+
const inherits = require('util').inherits
4+
const HookedWalletEthTxSubprovider = require('web3-provider-engine/subproviders/hooked-wallet-ethtx')
5+
6+
module.exports = WalletSubprovider
7+
8+
inherits(WalletSubprovider, HookedWalletEthTxSubprovider)
9+
10+
function WalletSubprovider (wallet, opts) {
11+
opts.getAccounts = function (cb) {
12+
cb(null, [ wallet.getAddressesString() ])
13+
}
14+
15+
opts.getPrivateKey = function (address, cb) {
16+
if (address !== wallet.getAddressString()) {
17+
return cb('Account not found')
18+
}
19+
20+
cb(null, wallet.getPrivateKey())
21+
}
22+
23+
WalletSubprovider.super_.call(this, opts)
24+
}

0 commit comments

Comments
 (0)