Skip to content

Commit

Permalink
fix: throw an error when a did document update failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Harasz committed Jun 23, 2022
1 parent 42e3973 commit e7c1ae9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/errors/error-messages.ts
Expand Up @@ -31,4 +31,5 @@ export enum ERROR_MESSAGES {
ONCHAIN_ROLE_SUBJECT_AGREEMENT_NOT_SPECIFIED = 'On-chain role subject agreement not specified',
REVOKE_CLAIM_MISSING_PARAMETERS = 'Revoke claim missing parameters. Required one of: claimId or claim',
REVOKE_CLAIM_NOT_FOUND = 'Could not find claim to revoke',
DID_DOCUMENT_NOT_UPDATED = 'DID Document was not updated',
}
6 changes: 5 additions & 1 deletion src/modules/claims/claims.service.ts
Expand Up @@ -719,11 +719,15 @@ export class ClaimsService {
hashAlg: 'SHA256',
},
};
await this._didRegistry.updateDocument({
const isDocUpdated = await this._didRegistry.updateDocument({
didAttribute: DIDAttribute.ServicePoint,
data,
did: sub,
});

if (!isDocUpdated) {
throw new Error(ERROR_MESSAGES.DID_DOCUMENT_NOT_UPDATED);
}
}
return url;
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/did-registry/did-registry.service.ts
@@ -1,4 +1,4 @@
import { Wallet, providers } from 'ethers';
import { Wallet, providers, BigNumber } from 'ethers';
import { CID } from 'multiformats/cid';
import { KeyType } from '@ew-did-registry/keys';
import { JWT } from '@ew-did-registry/jwt';
Expand Down Expand Up @@ -341,7 +341,7 @@ export class DidRegistry {

const update = await didDocument.update(didAttribute, updateData, validity);

return Boolean(update);
return update._hex !== BigNumber.from(0)._hex;
}

/**
Expand Down

0 comments on commit e7c1ae9

Please sign in to comment.