Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong type for comment key #2250

Merged
merged 6 commits into from
Dec 17, 2019
Merged
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
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()
i1skn marked this conversation as resolved.
Show resolved Hide resolved
// 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