Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Commit

Permalink
Merge 94e3143 into 5191c9e
Browse files Browse the repository at this point in the history
  • Loading branch information
garatortiz committed Jul 20, 2018
2 parents 5191c9e + 94e3143 commit 99d6e45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion server/routes/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const signBankAccount = (req, res) => {
const accessToken = await accountsController.getAccessToken(token)

const bankAccount = await accountsController.getBankAccount(accessToken, accountId)
const hash = web3.utils.sha3(ethAccount + Buffer.from(bankAccount.account).toString('hex'))
const hash = web3.utils.soliditySha3(
ethAccount +
Buffer.from(bankAccount.account).toString('hex') +
Buffer.from(bankAccount.institution).toString('hex')
)
const { v, r, s } = web3.eth.accounts.sign(hash, PRIVATE_KEY)
return res.send({ bankAccount, v, r, s })
} catch (e) {
Expand Down
7 changes: 5 additions & 2 deletions server/tests/accounts.route.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const mockBankAccount = {
bankAccount: {
account: '9900009606',
account_id: 'vzeNDwK7KQIm4yEog683uElbp9GRLEFXGK98D',
institution: 'Bank One',
routing: '011401533',
wire_routing: '021000021'
}
Expand All @@ -31,14 +32,16 @@ jest.mock('../controllers/accounts', () => ({
}),
getBankAccount: jest.fn((accessToken, accountId) => {
if (accessToken === mockAccessToken && accountId === mockBankAccounts.numbers.ach[0].account_id)
return mockBankAccounts.numbers.ach[0]
return mockBankAccount.bankAccount
throw new Error('There was an error getting the transaction data')
})
}))
jest.mock('web3', () =>
jest.fn().mockImplementation(() => ({
utils: {
sha3: jest.fn(() => '0xc20eab54de62a1151b630cc74fdfc40cf58e919325e294aa124a6ec3b52f542f')
soliditySha3: jest.fn(
() => '0xc20eab54de62a1151b630cc74fdfc40cf58e919325e294aa124a6ec3b52f542f'
)
},
eth: {
accounts: {
Expand Down

0 comments on commit 99d6e45

Please sign in to comment.