1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 18:41:38 +01:00
metamask-extension/test/lib/mock-simple-keychain.js

39 lines
708 B
JavaScript
Raw Normal View History

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 }
2017-05-04 23:35:10 +02:00
constructor (opts) {
this.type = type
this.opts = opts || {}
this.wallets = []
}
2017-05-04 23:35:10 +02:00
serialize () {
return [ fakeWallet.privKey ]
}
2017-05-04 23:35:10 +02:00
deserialize (data) {
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++) {
this.wallets.push(fakeWallet)
}
}
2017-05-04 23:35:10 +02:00
getAccounts () {
return this.wallets.map(w => w.address)
}
}