Skip to content

Commit

Permalink
update credStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratap2018 committed Aug 12, 2024
1 parent 6d635a0 commit af59a73
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/credential/services/credential.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,7 @@ export class CredentialService {

await this.txnService.sendVCTxn(credentialStatus, proof, appMenemonic);

const registredCredential = await this.registrationStatus(
credentialId,
appDetail,
);
const registredCredential = await this.registrationStatus(credentialId);
Logger.log('Registred Credential', registredCredential);
} catch (e) {
Logger.error(
Expand All @@ -488,27 +485,28 @@ export class CredentialService {
return { transactionHash: registeredVC?.transactionHash };
}

async registrationStatus(credId, appDetail) {
async registrationStatus(credId) {
return new Promise((resolve, reject) => {
const interval = 5000; // Interval in milliseconds (e.g., 5000ms = 5 seconds)
const maxAttempts = 12; // Maximum number of attempts before rejecting
const maxAttempts = 20; // Maximum number of attempts before rejecting
let attempts = 0;

const intervalId = setInterval(async () => {
attempts++;

try {
// Assume resolveCredential is a method that checks the status and returns a response
const response = await this.resolveCredential(
credId,
appDetail,
false,
const response = await fetch(
this.config.get('HID_NETWORK_API') +
'/hypersign-protocol/hidnode/ssi/credential/' +
credId,
);

if (response.credentialDocument) {
if (response.status == 200) {
const resp = await response.json();
// Assuming status 200 means success
clearInterval(intervalId); // Stop the interval
resolve(response); // Resolve the promise with the successful response
resolve(resp); // Resolve the promise with the successful response
} else {
console.log(
`Attempt ${attempts}: Status not successful, retrying...`,
Expand Down

0 comments on commit af59a73

Please sign in to comment.