2016-10-21 22:11:30 +02:00
|
|
|
var fakeWallet = {
|
|
|
|
privKey: '0x123456788890abcdef',
|
|
|
|
address: '0xfedcba0987654321',
|
|
|
|
}
|
|
|
|
const type = 'Simple Key Pair'
|
|
|
|
|
|
|
|
module.exports = class MockSimpleKeychain {
|
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
static type () { return type }
|
2016-10-21 22:11:30 +02:00
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
constructor (opts) {
|
2016-10-21 22:11:30 +02:00
|
|
|
this.type = type
|
|
|
|
this.opts = opts || {}
|
|
|
|
this.wallets = []
|
|
|
|
}
|
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
serialize () {
|
2016-10-21 22:11:30 +02:00
|
|
|
return [ fakeWallet.privKey ]
|
|
|
|
}
|
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
deserialize (data) {
|
2016-10-21 22:11:30 +02:00
|
|
|
if (!Array.isArray(data)) {
|
|
|
|
throw new Error('Simple keychain deserialize requires a privKey array.')
|
|
|
|
}
|
|
|
|
this.wallets = [ fakeWallet ]
|
|
|
|
}
|
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
addAccounts (n = 1) {
|
|
|
|
for (var i = 0; i < n; i++) {
|
2016-10-21 22:11:30 +02:00
|
|
|
this.wallets.push(fakeWallet)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-04 23:35:10 +02:00
|
|
|
getAccounts () {
|
2016-10-21 22:11:30 +02:00
|
|
|
return this.wallets.map(w => w.address)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|