Skip to content

Commit

Permalink
fix(utils): test
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Jun 9, 2022
1 parent e081472 commit dfba6f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 5 additions & 4 deletions __tests__/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export default (testContext: {
})

it('should map identifier keys to did doc', async () => {
const ethereumAddress = `0xb09b66026ba5909a7cfe99b76875431d2b8d5190`
const did = `did:ethr:0x4:${ethereumAddress}`
const account = `0xb09b66026ba5909a7cfe99b76875431d2b8d5190`
const did = `did:ethr:0x4:${account}`
const controllerKeyId = `${did}#controller`
await agent.didManagerImport({
did,
Expand All @@ -40,8 +40,9 @@ export default (testContext: {
type: 'Secp256k1',
kms: 'web3',
privateKeyHex: '',
publicKeyHex: '',
meta: {
ethereumAddress,
account,
provider: 'metamask',
algorithms: [
'eth_signMessage',
Expand All @@ -53,7 +54,7 @@ export default (testContext: {

const identifier = await agent.didManagerGet({ did })
const extendedKeys = await mapIdentifierKeysToDoc(identifier, 'verificationMethod', { agent })
expect(extendedKeys[0].meta.verificationMethod?.blockchainAccountId?.toLocaleLowerCase()).toEqual(`${ethereumAddress}@eip155:4`)
expect(extendedKeys[0].meta.verificationMethod?.blockchainAccountId?.toLocaleLowerCase()).toEqual(`${account}@eip155:4`)

})
})
Expand Down
5 changes: 2 additions & 3 deletions packages/utils/src/did-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function compareBlockchainAccountId(localKey: IKey, verificationMethod: _Normali
return false
}
let vmEthAddr = getEthereumAddress(verificationMethod)
if (localKey.meta?.ethereumAddress) {
return vmEthAddr === localKey.meta?.ethereumAddress
if (localKey.meta?.account) {
return vmEthAddr === localKey.meta?.account
}
const computedAddr = computeAddress('0x' + localKey.publicKeyHex).toLowerCase()
return computedAddr === vmEthAddr
Expand Down Expand Up @@ -88,7 +88,6 @@ export async function mapIdentifierKeysToDoc(
context: IAgentContext<IResolver>,
): Promise<_ExtendedIKey[]> {
const didDocument = await resolveDidOrThrow(identifier.did, context)

// dereference all key agreement keys from DID document and normalize
const documentKeys: _NormalizedVerificationMethod[] = await dereferenceDidKeys(
didDocument,
Expand Down

0 comments on commit dfba6f4

Please sign in to comment.