Skip to content

Commit

Permalink
Fix wrong type for comment key (#2250)
Browse files Browse the repository at this point in the history
  • Loading branch information
i1skn authored Dec 17, 2019
1 parent 9ab55eb commit d905c82
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/mobile/src/identity/commentKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { contractKit } from 'src/web3/contracts'

export async function getCommentKey(address: string): Promise<Buffer | null> {
const accountsWrapper: AccountsWrapper = await contractKit.contracts.getAccounts()

const hexString = (await accountsWrapper.getDataEncryptionKey(address)).join()
// getDataEncryptionKey actually returns a string instead of an array
const hexString = [await accountsWrapper.getDataEncryptionKey(address)].join()
// No comment key -> empty string returned from getDEK. This is expected for old addresses created before comment encryption change
if (!hexString) {
return null
Expand Down
4 changes: 2 additions & 2 deletions packages/mobile/src/identity/verification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ const mockAttestationsWrapperPartlyVerified = {
}

const mockAccountsWrapper = {
getWalletAddress: jest.fn(() => mockAccount),
getDataEncryptionKey: jest.fn(() => [mockPublicDEK]),
getWalletAddress: jest.fn(() => Promise.resolve(mockAccount)),
getDataEncryptionKey: jest.fn(() => Promise.resolve(mockPublicDEK)),
}

describe('Start Verification Saga', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/mobile/src/identity/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,8 @@ async function isAccountUpToDate(
) {
const [currentWalletAddress, currentDEK] = await Promise.all([
accountsWrapper.getWalletAddress(address),
accountsWrapper.getDataEncryptionKey(address),
// getDataEncryptionKey actually returns a string instead of an array
accountsWrapper.getDataEncryptionKey(address).then((key) => [key]),
])
return (
eqAddress(currentWalletAddress, address) && currentDEK && eqAddress(currentDEK.join(), dataKey)
Expand Down

0 comments on commit d905c82

Please sign in to comment.