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

Update keyrings and switch to using getAppKey #45

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ class KeyringController extends EventEmitter {
// This method signs tx and returns a promise for
// TX Manager to update the state after signing

signTransaction (ethTx, _fromAddress, opts = {}) {
signTransaction (ethTx, _fromAddress) {
const fromAddress = normalizeAddress(_fromAddress)
return this.getKeyringForAccount(fromAddress)
.then((keyring) => {
return keyring.signTransaction(fromAddress, ethTx, opts)
return keyring.signTransaction(fromAddress, ethTx)
})
}

Expand All @@ -309,11 +309,11 @@ class KeyringController extends EventEmitter {
// returns Promise(@buffer rawSig)
//
// Attempts to sign the provided @object msgParams.
signMessage (msgParams, opts = {}) {
signMessage (msgParams) {
const address = normalizeAddress(msgParams.from)
return this.getKeyringForAccount(address)
.then((keyring) => {
return keyring.signMessage(address, msgParams.data, opts)
return keyring.signMessage(address, msgParams.data)
})
}

Expand All @@ -324,11 +324,11 @@ class KeyringController extends EventEmitter {
//
// Attempts to sign the provided @object msgParams.
// Prefixes the hash before signing as per the new geth behavior.
signPersonalMessage (msgParams, opts = {}) {
signPersonalMessage (msgParams) {
const address = normalizeAddress(msgParams.from)
return this.getKeyringForAccount(address)
.then((keyring) => {
return keyring.signPersonalMessage(address, msgParams.data, opts)
return keyring.signPersonalMessage(address, msgParams.data)
})
}

Expand All @@ -354,7 +354,7 @@ class KeyringController extends EventEmitter {
if (!('exportAccount' in keyring)) {
throw new Error(`The keyring for address ${_address} does not support exporting.`)
}
return keyring.exportAccount(address, { withAppKeyOrigin: origin })
return keyring.getAppKey(address, origin)
}

// PRIVATE METHODS
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"bip39": "^2.4.0",
"bluebird": "^3.5.0",
"browser-passworder": "^2.0.3",
"eth-hd-keyring": "^3.4.0",
"eth-hd-keyring": "^4.0.0",
"eth-sig-util": "^1.4.0",
"eth-simple-keyring": "^3.4.0",
"eth-simple-keyring": "^4.0.0",
"ethereumjs-util": "^5.1.2",
"loglevel": "^1.5.0",
"obs-store": "^4.0.3"
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ describe('KeyringController', () => {

const privateAppKey = await keyringController.exportAppKeyForAddress(address, 'someapp.origin.io')

const wallet = Wallet.fromPrivateKey(ethUtil.toBuffer('0x' + privateAppKey))
const wallet = Wallet.fromPrivateKey(ethUtil.toBuffer('0x' + privateAppKey.toString('hex')))
const recoveredAddress = '0x' + wallet.getAddress().toString('hex')

assert.equal(recoveredAddress, appKeyAddress, 'Exported the appropriate private key')
assert.notEqual(privateAppKey, privateKey)
assert.notEqual(privateAppKey, '0x' + privateAppKey.toString('hex'))
})
})

Expand Down