2019-12-03 15:52:01 +01:00
|
|
|
const fakeWallet = {
|
2016-10-21 22:11:30 +02:00
|
|
|
privKey: '0x123456788890abcdef',
|
|
|
|
address: '0xfedcba0987654321',
|
|
|
|
}
|
|
|
|
const type = 'Simple Key Pair'
|
|
|
|
|
2020-01-09 04:34:58 +01:00
|
|
|
export default class MockSimpleKeychain {
|
2016-10-21 22:11:30 +02:00
|
|
|
|
2019-11-20 01:03:20 +01: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) {
|
2019-12-03 15:52:01 +01:00
|
|
|
for (let 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)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|