@0xpolygonid/js-sdk 1.10.2 → 1.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -297,10 +297,7 @@ class PubSignalsVerifier {
297
297
  }
298
298
  };
299
299
  this.checkStateExistenceForId = async (userId, userState) => {
300
- const { latest } = await this.resolve(userId, userState.bigInt());
301
- if (!latest) {
302
- throw exports.userStateError;
303
- }
300
+ await this.resolve(userId, userState.bigInt());
304
301
  };
305
302
  this.checkGlobalState = async (state, id) => {
306
303
  return this.rootResolve(state.bigInt(), id.bigInt());
@@ -393,7 +390,9 @@ class PubSignalsVerifier {
393
390
  contractState = await this._stateStorage.getStateInfoByIdAndState(idBigInt, state);
394
391
  }
395
392
  catch (e) {
396
- if (e.errorArgs[0] === 'State does not exist') {
393
+ const stateNotExistErr = (e?.errorArgs ?? [])[0];
394
+ const errMsg = stateNotExistErr || e.message;
395
+ if (errMsg === 'State does not exist') {
397
396
  if (isGenesis) {
398
397
  return {
399
398
  latest: true,
@@ -417,7 +416,11 @@ class PubSignalsVerifier {
417
416
  transitionTimestamp: contractState.replacedAtTimestamp.toString()
418
417
  };
419
418
  }
420
- return { latest: true, transitionTimestamp: 0 };
419
+ return {
420
+ latest: !contractState.replacedAtTimestamp ||
421
+ contractState.replacedAtTimestamp.toString() === zeroInt.toString(),
422
+ transitionTimestamp: contractState.replacedAtTimestamp?.toString() ?? 0
423
+ };
421
424
  }
422
425
  async rootResolve(state, id) {
423
426
  let globalStateInfo;
@@ -294,10 +294,7 @@ export class PubSignalsVerifier {
294
294
  }
295
295
  };
296
296
  this.checkStateExistenceForId = async (userId, userState) => {
297
- const { latest } = await this.resolve(userId, userState.bigInt());
298
- if (!latest) {
299
- throw userStateError;
300
- }
297
+ await this.resolve(userId, userState.bigInt());
301
298
  };
302
299
  this.checkGlobalState = async (state, id) => {
303
300
  return this.rootResolve(state.bigInt(), id.bigInt());
@@ -390,7 +387,9 @@ export class PubSignalsVerifier {
390
387
  contractState = await this._stateStorage.getStateInfoByIdAndState(idBigInt, state);
391
388
  }
392
389
  catch (e) {
393
- if (e.errorArgs[0] === 'State does not exist') {
390
+ const stateNotExistErr = (e?.errorArgs ?? [])[0];
391
+ const errMsg = stateNotExistErr || e.message;
392
+ if (errMsg === 'State does not exist') {
394
393
  if (isGenesis) {
395
394
  return {
396
395
  latest: true,
@@ -414,7 +413,11 @@ export class PubSignalsVerifier {
414
413
  transitionTimestamp: contractState.replacedAtTimestamp.toString()
415
414
  };
416
415
  }
417
- return { latest: true, transitionTimestamp: 0 };
416
+ return {
417
+ latest: !contractState.replacedAtTimestamp ||
418
+ contractState.replacedAtTimestamp.toString() === zeroInt.toString(),
419
+ transitionTimestamp: contractState.replacedAtTimestamp?.toString() ?? 0
420
+ };
418
421
  }
419
422
  async rootResolve(state, id) {
420
423
  let globalStateInfo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xpolygonid/js-sdk",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "description": "SDK to work with Polygon ID",
5
5
  "main": "dist/node/cjs/index.js",
6
6
  "module": "dist/node/esm/index.js",