@0xpolygonid/js-sdk 1.23.0 → 1.24.1

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.
Files changed (56) hide show
  1. package/dist/browser/esm/index.js +3103 -358
  2. package/dist/browser/esm/index.js.map +1 -1
  3. package/dist/browser/umd/index.js +3106 -356
  4. package/dist/browser/umd/index.js.map +1 -1
  5. package/dist/node/cjs/credentials/credential-wallet.js +11 -78
  6. package/dist/node/cjs/credentials/index.js +1 -0
  7. package/dist/node/cjs/credentials/status/did-resolver-revocation.js +21 -0
  8. package/dist/node/cjs/iden3comm/handlers/fetch.js +32 -0
  9. package/dist/node/cjs/iden3comm/handlers/payment.js +38 -13
  10. package/dist/node/cjs/storage/blockchain/abi/ERC20.json +1 -0
  11. package/dist/node/cjs/storage/blockchain/did-resolver-readonly-storage.js +72 -0
  12. package/dist/node/cjs/storage/blockchain/{erc20-permit-sig.js → erc20-helper.js} +14 -1
  13. package/dist/node/cjs/storage/blockchain/index.js +3 -1
  14. package/dist/node/cjs/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.js +245 -0
  15. package/dist/node/cjs/storage/blockchain/onchain-issuer.js +82 -0
  16. package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +38 -34
  17. package/dist/node/cjs/storage/interfaces/index.js +1 -0
  18. package/dist/node/cjs/storage/interfaces/onchain-issuer.js +2 -0
  19. package/dist/node/cjs/utils/did-helper.js +3 -3
  20. package/dist/node/cjs/verifiable/constants.js +1 -0
  21. package/dist/node/cjs/verifiable/credential.js +86 -0
  22. package/dist/node/esm/credentials/credential-wallet.js +12 -79
  23. package/dist/node/esm/credentials/index.js +1 -0
  24. package/dist/node/esm/credentials/status/did-resolver-revocation.js +17 -0
  25. package/dist/node/esm/iden3comm/handlers/fetch.js +32 -0
  26. package/dist/node/esm/iden3comm/handlers/payment.js +38 -14
  27. package/dist/node/esm/storage/blockchain/abi/ERC20.json +1 -0
  28. package/dist/node/esm/storage/blockchain/did-resolver-readonly-storage.js +68 -0
  29. package/dist/node/esm/storage/blockchain/{erc20-permit-sig.js → erc20-helper.js} +14 -2
  30. package/dist/node/esm/storage/blockchain/index.js +3 -1
  31. package/dist/node/esm/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.js +241 -0
  32. package/dist/node/esm/storage/blockchain/onchain-issuer.js +78 -0
  33. package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +38 -34
  34. package/dist/node/esm/storage/interfaces/index.js +1 -0
  35. package/dist/node/esm/storage/interfaces/onchain-issuer.js +1 -0
  36. package/dist/node/esm/utils/did-helper.js +3 -3
  37. package/dist/node/esm/verifiable/constants.js +1 -0
  38. package/dist/node/esm/verifiable/credential.js +88 -2
  39. package/dist/types/credentials/credential-wallet.d.ts +0 -6
  40. package/dist/types/credentials/index.d.ts +1 -0
  41. package/dist/types/credentials/models.d.ts +8 -0
  42. package/dist/types/credentials/status/did-resolver-revocation.d.ts +7 -0
  43. package/dist/types/iden3comm/handlers/fetch.d.ts +8 -0
  44. package/dist/types/iden3comm/handlers/payment.d.ts +3 -2
  45. package/dist/types/storage/blockchain/did-resolver-readonly-storage.d.ts +16 -0
  46. package/dist/types/storage/blockchain/{erc20-permit-sig.d.ts → erc20-helper.d.ts} +8 -1
  47. package/dist/types/storage/blockchain/index.d.ts +3 -1
  48. package/dist/types/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.d.ts +66 -0
  49. package/dist/types/storage/blockchain/onchain-issuer.d.ts +40 -0
  50. package/dist/types/storage/blockchain/onchain-zkp-verifier.d.ts +11 -12
  51. package/dist/types/storage/entities/state.d.ts +2 -0
  52. package/dist/types/storage/interfaces/index.d.ts +1 -0
  53. package/dist/types/storage/interfaces/onchain-issuer.d.ts +12 -0
  54. package/dist/types/verifiable/constants.d.ts +1 -0
  55. package/dist/types/verifiable/credential.d.ts +15 -2
  56. package/package.json +3 -2
@@ -1,4 +1,4 @@
1
- import { DID, buildDIDType, Id as Id$1, genesisFromEthAddress, BytesHelper, checkBigIntInField, Claim, SchemaHash, ClaimOptions, MerklizedRootPosition as MerklizedRootPosition$1, IdPosition, getChainId, getUnixTimestamp, ChainIds, getDateFromUnixTimestamp, DidMethod, Blockchain, NetworkId } from '@iden3/js-iden3-core';
1
+ import { DID, buildDIDType, Id as Id$1, genesisFromEthAddress, BytesHelper, checkBigIntInField, Claim, SchemaHash, getChainId, ClaimOptions, MerklizedRootPosition as MerklizedRootPosition$1, IdPosition, getDateFromUnixTimestamp, chainIDfromDID, getUnixTimestamp, ChainIds, DidMethod, Blockchain, NetworkId } from '@iden3/js-iden3-core';
2
2
  import * as jsIden3Core from '@iden3/js-iden3-core';
3
3
  export { jsIden3Core as core };
4
4
  import { Path, Merklizer, getDocumentLoader } from '@iden3/js-jsonld-merklization';
@@ -1343,7 +1343,7 @@ const validateDIDDocumentAuth = async (did, resolverURL, state) => {
1343
1343
  }
1344
1344
  };
1345
1345
  const resolveDIDDocumentAuth = async (did, resolveURL, state) => {
1346
- let url = `${resolveURL}/${did.string().replace(/:/g, '%3A')}`;
1346
+ let url = `${resolveURL}/${encodeURIComponent(did.string())}`;
1347
1347
  if (state) {
1348
1348
  url += `?state=${state.hex()}`;
1349
1349
  }
@@ -1359,11 +1359,11 @@ function emptyStateDID(did) {
1359
1359
  return emptyDID;
1360
1360
  }
1361
1361
  const resolveDidDocument = async (did, resolverUrl, opts) => {
1362
- let didString = did.string().replace(/:/g, '%3A');
1362
+ let didString = encodeURIComponent(did.string());
1363
1363
  // for gist resolve we have to `hide` user did (look into resolver implementation)
1364
1364
  const isGistRequest = opts?.gist && !opts.state;
1365
1365
  if (isGistRequest) {
1366
- didString = emptyStateDID(did).string();
1366
+ didString = encodeURIComponent(emptyStateDID(did).string());
1367
1367
  }
1368
1368
  let url = `${resolverUrl}/1.0/identifiers/${didString}`;
1369
1369
  if (opts?.signature) {
@@ -5398,7 +5398,7 @@ const coerce = o => {
5398
5398
  throw new Error('Unknown type, must be binary type');
5399
5399
  };
5400
5400
  const fromString$1 = str => new TextEncoder().encode(str);
5401
- const toString$1 = b => new TextDecoder().decode(b);
5401
+ const toString$2 = b => new TextDecoder().decode(b);
5402
5402
 
5403
5403
  class Encoder {
5404
5404
  constructor(name, prefix, baseEncode) {
@@ -5555,7 +5555,7 @@ const rfc4648$2 = ({name, prefix, bitsPerChar, alphabet}) => {
5555
5555
  const identity$1 = from({
5556
5556
  prefix: '\0',
5557
5557
  name: 'identity',
5558
- encode: buf => toString$1(buf),
5558
+ encode: buf => toString$2(buf),
5559
5559
  decode: str => fromString$1(str)
5560
5560
  });
5561
5561
 
@@ -5919,7 +5919,7 @@ function fromString(string, encoding = 'utf8') {
5919
5919
  return base.decoder.decode(`${ base.prefix }${ string }`);
5920
5920
  }
5921
5921
 
5922
- function toString(array, encoding = 'utf8') {
5922
+ function toString$1(array, encoding = 'utf8') {
5923
5923
  const base = BASES[encoding];
5924
5924
  if (!base) {
5925
5925
  throw new Error(`Unsupported encoding "${ encoding }"`);
@@ -6313,19 +6313,19 @@ const constants$2 = [
6313
6313
  ];
6314
6314
 
6315
6315
  /** @type {Record<BaseName,Base>} */
6316
- const names$1 = constants$2.reduce((prev, tupple) => {
6316
+ const names$2 = constants$2.reduce((prev, tupple) => {
6317
6317
  prev[tupple[0]] = new Base(tupple[0], tupple[1], tupple[2], tupple[3]);
6318
6318
  return prev
6319
6319
  }, /** @type {Record<BaseName,Base>} */({}));
6320
6320
 
6321
6321
  /** @type {Record<BaseCode,Base>} */
6322
6322
  const codes = constants$2.reduce((prev, tupple) => {
6323
- prev[tupple[1]] = names$1[tupple[0]];
6323
+ prev[tupple[1]] = names$2[tupple[0]];
6324
6324
  return prev
6325
6325
  }, /** @type {Record<BaseCode,Base>} */({}));
6326
6326
 
6327
6327
  var constants_1 = {
6328
- names: names$1,
6328
+ names: names$2,
6329
6329
  codes
6330
6330
  };
6331
6331
 
@@ -7097,7 +7097,7 @@ function genBech32(encoding) {
7097
7097
  const bech32 = /* @__PURE__ */ genBech32('bech32');
7098
7098
 
7099
7099
  const u8a$2 = {
7100
- toString,
7100
+ toString: toString$1,
7101
7101
  fromString,
7102
7102
  concat: concat$2
7103
7103
  };
@@ -7295,7 +7295,7 @@ function sha256$2(payload) {
7295
7295
  const keccak = keccak_256$1;
7296
7296
  function toEthereumAddress(hexPublicKey) {
7297
7297
  const hashInput = fromString(hexPublicKey.slice(2), 'base16');
7298
- return `0x${toString(keccak(hashInput).slice(-20), 'base16')}`;
7298
+ return `0x${toString$1(keccak(hashInput).slice(-20), 'base16')}`;
7299
7299
  }
7300
7300
 
7301
7301
  /**
@@ -7827,6 +7827,7 @@ var SupportedCurrencies;
7827
7827
  SupportedCurrencies["ETH_WEI"] = "ETHWEI";
7828
7828
  SupportedCurrencies["ETH_GWEI"] = "ETHGWEI";
7829
7829
  SupportedCurrencies["MATIC"] = "MATIC";
7830
+ SupportedCurrencies["POL"] = "POL";
7830
7831
  SupportedCurrencies["USDT"] = "USDT";
7831
7832
  SupportedCurrencies["USDC"] = "USDC";
7832
7833
  })(SupportedCurrencies || (SupportedCurrencies = {}));
@@ -19899,6 +19900,92 @@ class W3CCredential {
19899
19900
  this.credentialSubject = {};
19900
19901
  this.issuer = '';
19901
19902
  }
19903
+ /**
19904
+ *
19905
+ * @param issuer - DID of the issuer
19906
+ * @param request - Credential request
19907
+ * @returns - W3C Credential
19908
+ */
19909
+ static fromCredentialRequest(issuer, request) {
19910
+ if (!request.id) {
19911
+ throw new Error('Credential id is required');
19912
+ }
19913
+ if (!request.context) {
19914
+ throw new Error('Credential context is required');
19915
+ }
19916
+ const context = [
19917
+ VerifiableConstants.JSONLD_SCHEMA.W3C_CREDENTIAL_2018,
19918
+ VerifiableConstants.JSONLD_SCHEMA.IDEN3_CREDENTIAL,
19919
+ ...request.context
19920
+ ];
19921
+ const credentialType = [
19922
+ VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_CREDENTIAL,
19923
+ request.type
19924
+ ];
19925
+ const credentialSubject = request.credentialSubject;
19926
+ credentialSubject['type'] = request.type;
19927
+ const cr = new W3CCredential();
19928
+ cr.id = request.id;
19929
+ cr['@context'] = context;
19930
+ cr.type = credentialType;
19931
+ cr.credentialSubject = credentialSubject;
19932
+ cr.issuer = issuer.string();
19933
+ cr.credentialSchema = {
19934
+ id: request.credentialSchema,
19935
+ type: VerifiableConstants.JSON_SCHEMA_VALIDATOR
19936
+ };
19937
+ cr.credentialStatus = W3CCredential.buildCredentialStatus(request, issuer);
19938
+ request.expiration && (cr.expirationDate = new Date(request.expiration).toISOString());
19939
+ request.refreshService && (cr.refreshService = request.refreshService);
19940
+ request.displayMethod && (cr.displayMethod = request.displayMethod);
19941
+ request.issuanceDate && (cr.issuanceDate = new Date(request.issuanceDate).toISOString());
19942
+ return cr;
19943
+ }
19944
+ /**
19945
+ * Builds credential status
19946
+ * @param {CredentialRequest} request
19947
+ * @returns `CredentialStatus`
19948
+ */
19949
+ static buildCredentialStatus(request, issuer) {
19950
+ const credentialStatus = {
19951
+ id: request.revocationOpts.id,
19952
+ type: request.revocationOpts.type,
19953
+ revocationNonce: request.revocationOpts.nonce
19954
+ };
19955
+ switch (request.revocationOpts.type) {
19956
+ case CredentialStatusType.SparseMerkleTreeProof:
19957
+ return {
19958
+ ...credentialStatus,
19959
+ id: `${credentialStatus.id.replace(/\/$/, '')}/${credentialStatus.revocationNonce}`
19960
+ };
19961
+ case CredentialStatusType.Iden3ReverseSparseMerkleTreeProof:
19962
+ return {
19963
+ ...credentialStatus,
19964
+ id: request.revocationOpts.issuerState
19965
+ ? `${credentialStatus.id.replace(/\/$/, '')}/node?state=${request.revocationOpts.issuerState}`
19966
+ : `${credentialStatus.id.replace(/\/$/, '')}`
19967
+ };
19968
+ case CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023: {
19969
+ const issuerId = DID.idFromDID(issuer);
19970
+ const chainId = getChainId(DID.blockchainFromId(issuerId), DID.networkIdFromId(issuerId));
19971
+ const searchParams = [
19972
+ ['revocationNonce', request.revocationOpts.nonce?.toString() || ''],
19973
+ ['contractAddress', `${chainId}:${request.revocationOpts.id}`],
19974
+ ['state', request.revocationOpts.issuerState || '']
19975
+ ]
19976
+ .filter(([, value]) => Boolean(value))
19977
+ .map(([key, value]) => `${key}=${value}`)
19978
+ .join('&');
19979
+ return {
19980
+ ...credentialStatus,
19981
+ // `[did]:[methodid]:[chain]:[network]:[id]/credentialStatus?(revocationNonce=value)&[contractAddress=[chainID]:[contractAddress]]&(state=issuerState)`
19982
+ id: `${issuer.string()}/credentialStatus?${searchParams}`
19983
+ };
19984
+ }
19985
+ default:
19986
+ return credentialStatus;
19987
+ }
19988
+ }
19902
19989
  toJSON() {
19903
19990
  return {
19904
19991
  ...this,
@@ -22275,16 +22362,16 @@ var util = {};
22275
22362
 
22276
22363
  } (util));
22277
22364
 
22278
- var names = {};
22365
+ var names$1 = {};
22279
22366
 
22280
22367
  var hasRequiredNames;
22281
22368
 
22282
22369
  function requireNames () {
22283
- if (hasRequiredNames) return names;
22370
+ if (hasRequiredNames) return names$1;
22284
22371
  hasRequiredNames = 1;
22285
- Object.defineProperty(names, "__esModule", { value: true });
22372
+ Object.defineProperty(names$1, "__esModule", { value: true });
22286
22373
  const codegen_1 = requireCodegen();
22287
- const names$1 = {
22374
+ const names = {
22288
22375
  // validation function arguments
22289
22376
  data: new codegen_1.Name("data"),
22290
22377
  // args passed from referencing schema
@@ -22307,9 +22394,9 @@ function requireNames () {
22307
22394
  jsonLen: new codegen_1.Name("jsonLen"),
22308
22395
  jsonPart: new codegen_1.Name("jsonPart"),
22309
22396
  };
22310
- names.default = names$1;
22397
+ names$1.default = names;
22311
22398
 
22312
- return names;
22399
+ return names$1;
22313
22400
  }
22314
22401
 
22315
22402
  var hasRequiredErrors;
@@ -30743,8 +30830,8 @@ function zeroPadBytes(data, length) {
30743
30830
  *
30744
30831
  * @_subsection: api/utils:Math Helpers [about-maths]
30745
30832
  */
30746
- const BN_0$8 = BigInt(0);
30747
- const BN_1$3 = BigInt(1);
30833
+ const BN_0$9 = BigInt(0);
30834
+ const BN_1$4 = BigInt(1);
30748
30835
  //const BN_Max256 = (BN_1 << BigInt(256)) - BN_1;
30749
30836
  // IEEE 754 support 53-bits of mantissa
30750
30837
  const maxValue = 0x1fffffffffffff;
@@ -30757,13 +30844,13 @@ const maxValue = 0x1fffffffffffff;
30757
30844
  function fromTwos(_value, _width) {
30758
30845
  const value = getUint(_value, "value");
30759
30846
  const width = BigInt(getNumber(_width, "width"));
30760
- assert((value >> width) === BN_0$8, "overflow", "NUMERIC_FAULT", {
30847
+ assert((value >> width) === BN_0$9, "overflow", "NUMERIC_FAULT", {
30761
30848
  operation: "fromTwos", fault: "overflow", value: _value
30762
30849
  });
30763
30850
  // Top bit set; treat as a negative value
30764
- if (value >> (width - BN_1$3)) {
30765
- const mask = (BN_1$3 << width) - BN_1$3;
30766
- return -(((~value) & mask) + BN_1$3);
30851
+ if (value >> (width - BN_1$4)) {
30852
+ const mask = (BN_1$4 << width) - BN_1$4;
30853
+ return -(((~value) & mask) + BN_1$4);
30767
30854
  }
30768
30855
  return value;
30769
30856
  }
@@ -30776,14 +30863,14 @@ function fromTwos(_value, _width) {
30776
30863
  function toTwos(_value, _width) {
30777
30864
  let value = getBigInt(_value, "value");
30778
30865
  const width = BigInt(getNumber(_width, "width"));
30779
- const limit = (BN_1$3 << (width - BN_1$3));
30780
- if (value < BN_0$8) {
30866
+ const limit = (BN_1$4 << (width - BN_1$4));
30867
+ if (value < BN_0$9) {
30781
30868
  value = -value;
30782
30869
  assert(value <= limit, "too low", "NUMERIC_FAULT", {
30783
30870
  operation: "toTwos", fault: "overflow", value: _value
30784
30871
  });
30785
- const mask = (BN_1$3 << width) - BN_1$3;
30786
- return ((~value) & mask) + BN_1$3;
30872
+ const mask = (BN_1$4 << width) - BN_1$4;
30873
+ return ((~value) & mask) + BN_1$4;
30787
30874
  }
30788
30875
  else {
30789
30876
  assert(value < limit, "too high", "NUMERIC_FAULT", {
@@ -30798,7 +30885,7 @@ function toTwos(_value, _width) {
30798
30885
  function mask(_value, _bits) {
30799
30886
  const value = getUint(_value, "value");
30800
30887
  const bits = BigInt(getNumber(_bits, "bits"));
30801
- return value & ((BN_1$3 << bits) - BN_1$3);
30888
+ return value & ((BN_1$4 << bits) - BN_1$4);
30802
30889
  }
30803
30890
  /**
30804
30891
  * Gets a BigInt from %%value%%. If it is an invalid value for
@@ -30833,7 +30920,7 @@ function getBigInt(value, name) {
30833
30920
  */
30834
30921
  function getUint(value, name) {
30835
30922
  const result = getBigInt(value, name);
30836
- assert(result >= BN_0$8, "unsigned value cannot be negative", "NUMERIC_FAULT", {
30923
+ assert(result >= BN_0$9, "unsigned value cannot be negative", "NUMERIC_FAULT", {
30837
30924
  fault: "overflow", operation: "getUint", value
30838
30925
  });
30839
30926
  return result;
@@ -30919,7 +31006,7 @@ function toBeHex(_value, _width) {
30919
31006
  */
30920
31007
  function toBeArray(_value) {
30921
31008
  const value = getUint(_value, "value");
30922
- if (value === BN_0$8) {
31009
+ if (value === BN_0$9) {
30923
31010
  return new Uint8Array([]);
30924
31011
  }
30925
31012
  let hex = value.toString(16);
@@ -32151,6 +32238,526 @@ function wait(delay) {
32151
32238
  return new Promise((resolve) => setTimeout(resolve, delay));
32152
32239
  }
32153
32240
 
32241
+ /**
32242
+ * The **FixedNumber** class permits using values with decimal places,
32243
+ * using fixed-pont math.
32244
+ *
32245
+ * Fixed-point math is still based on integers under-the-hood, but uses an
32246
+ * internal offset to store fractional components below, and each operation
32247
+ * corrects for this after each operation.
32248
+ *
32249
+ * @_section: api/utils/fixed-point-math:Fixed-Point Maths [about-fixed-point-math]
32250
+ */
32251
+ const BN_N1 = BigInt(-1);
32252
+ const BN_0$8 = BigInt(0);
32253
+ const BN_1$3 = BigInt(1);
32254
+ const BN_5 = BigInt(5);
32255
+ const _guard$3 = {};
32256
+ // Constant to pull zeros from for multipliers
32257
+ let Zeros$1 = "0000";
32258
+ while (Zeros$1.length < 80) {
32259
+ Zeros$1 += Zeros$1;
32260
+ }
32261
+ // Returns a string "1" followed by decimal "0"s
32262
+ function getTens(decimals) {
32263
+ let result = Zeros$1;
32264
+ while (result.length < decimals) {
32265
+ result += result;
32266
+ }
32267
+ return BigInt("1" + result.substring(0, decimals));
32268
+ }
32269
+ function checkValue(val, format, safeOp) {
32270
+ const width = BigInt(format.width);
32271
+ if (format.signed) {
32272
+ const limit = (BN_1$3 << (width - BN_1$3));
32273
+ assert(safeOp == null || (val >= -limit && val < limit), "overflow", "NUMERIC_FAULT", {
32274
+ operation: safeOp, fault: "overflow", value: val
32275
+ });
32276
+ if (val > BN_0$8) {
32277
+ val = fromTwos(mask(val, width), width);
32278
+ }
32279
+ else {
32280
+ val = -fromTwos(mask(-val, width), width);
32281
+ }
32282
+ }
32283
+ else {
32284
+ const limit = (BN_1$3 << width);
32285
+ assert(safeOp == null || (val >= 0 && val < limit), "overflow", "NUMERIC_FAULT", {
32286
+ operation: safeOp, fault: "overflow", value: val
32287
+ });
32288
+ val = (((val % limit) + limit) % limit) & (limit - BN_1$3);
32289
+ }
32290
+ return val;
32291
+ }
32292
+ function getFormat(value) {
32293
+ if (typeof (value) === "number") {
32294
+ value = `fixed128x${value}`;
32295
+ }
32296
+ let signed = true;
32297
+ let width = 128;
32298
+ let decimals = 18;
32299
+ if (typeof (value) === "string") {
32300
+ // Parse the format string
32301
+ if (value === "fixed") ;
32302
+ else if (value === "ufixed") {
32303
+ signed = false;
32304
+ }
32305
+ else {
32306
+ const match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
32307
+ assertArgument(match, "invalid fixed format", "format", value);
32308
+ signed = (match[1] !== "u");
32309
+ width = parseInt(match[2]);
32310
+ decimals = parseInt(match[3]);
32311
+ }
32312
+ }
32313
+ else if (value) {
32314
+ // Extract the values from the object
32315
+ const v = value;
32316
+ const check = (key, type, defaultValue) => {
32317
+ if (v[key] == null) {
32318
+ return defaultValue;
32319
+ }
32320
+ assertArgument(typeof (v[key]) === type, "invalid fixed format (" + key + " not " + type + ")", "format." + key, v[key]);
32321
+ return v[key];
32322
+ };
32323
+ signed = check("signed", "boolean", signed);
32324
+ width = check("width", "number", width);
32325
+ decimals = check("decimals", "number", decimals);
32326
+ }
32327
+ assertArgument((width % 8) === 0, "invalid FixedNumber width (not byte aligned)", "format.width", width);
32328
+ assertArgument(decimals <= 80, "invalid FixedNumber decimals (too large)", "format.decimals", decimals);
32329
+ const name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals);
32330
+ return { signed, width, decimals, name };
32331
+ }
32332
+ function toString(val, decimals) {
32333
+ let negative = "";
32334
+ if (val < BN_0$8) {
32335
+ negative = "-";
32336
+ val *= BN_N1;
32337
+ }
32338
+ let str = val.toString();
32339
+ // No decimal point for whole values
32340
+ if (decimals === 0) {
32341
+ return (negative + str);
32342
+ }
32343
+ // Pad out to the whole component (including a whole digit)
32344
+ while (str.length <= decimals) {
32345
+ str = Zeros$1 + str;
32346
+ }
32347
+ // Insert the decimal point
32348
+ const index = str.length - decimals;
32349
+ str = str.substring(0, index) + "." + str.substring(index);
32350
+ // Trim the whole component (leaving at least one 0)
32351
+ while (str[0] === "0" && str[1] !== ".") {
32352
+ str = str.substring(1);
32353
+ }
32354
+ // Trim the decimal component (leaving at least one 0)
32355
+ while (str[str.length - 1] === "0" && str[str.length - 2] !== ".") {
32356
+ str = str.substring(0, str.length - 1);
32357
+ }
32358
+ return (negative + str);
32359
+ }
32360
+ /**
32361
+ * A FixedNumber represents a value over its [[FixedFormat]]
32362
+ * arithmetic field.
32363
+ *
32364
+ * A FixedNumber can be used to perform math, losslessly, on
32365
+ * values which have decmial places.
32366
+ *
32367
+ * A FixedNumber has a fixed bit-width to store values in, and stores all
32368
+ * values internally by multiplying the value by 10 raised to the power of
32369
+ * %%decimals%%.
32370
+ *
32371
+ * If operations are performed that cause a value to grow too high (close to
32372
+ * positive infinity) or too low (close to negative infinity), the value
32373
+ * is said to //overflow//.
32374
+ *
32375
+ * For example, an 8-bit signed value, with 0 decimals may only be within
32376
+ * the range ``-128`` to ``127``; so ``-128 - 1`` will overflow and become
32377
+ * ``127``. Likewise, ``127 + 1`` will overflow and become ``-127``.
32378
+ *
32379
+ * Many operation have a normal and //unsafe// variant. The normal variant
32380
+ * will throw a [[NumericFaultError]] on any overflow, while the //unsafe//
32381
+ * variant will silently allow overflow, corrupting its value value.
32382
+ *
32383
+ * If operations are performed that cause a value to become too small
32384
+ * (close to zero), the value loses precison and is said to //underflow//.
32385
+ *
32386
+ * For example, an value with 1 decimal place may store a number as small
32387
+ * as ``0.1``, but the value of ``0.1 / 2`` is ``0.05``, which cannot fit
32388
+ * into 1 decimal place, so underflow occurs which means precision is lost
32389
+ * and the value becomes ``0``.
32390
+ *
32391
+ * Some operations have a normal and //signalling// variant. The normal
32392
+ * variant will silently ignore underflow, while the //signalling// variant
32393
+ * will thow a [[NumericFaultError]] on underflow.
32394
+ */
32395
+ class FixedNumber {
32396
+ /**
32397
+ * The specific fixed-point arithmetic field for this value.
32398
+ */
32399
+ format;
32400
+ #format;
32401
+ // The actual value (accounting for decimals)
32402
+ #val;
32403
+ // A base-10 value to multiple values by to maintain the magnitude
32404
+ #tens;
32405
+ /**
32406
+ * This is a property so console.log shows a human-meaningful value.
32407
+ *
32408
+ * @private
32409
+ */
32410
+ _value;
32411
+ // Use this when changing this file to get some typing info,
32412
+ // but then switch to any to mask the internal type
32413
+ //constructor(guard: any, value: bigint, format: _FixedFormat) {
32414
+ /**
32415
+ * @private
32416
+ */
32417
+ constructor(guard, value, format) {
32418
+ assertPrivate(guard, _guard$3, "FixedNumber");
32419
+ this.#val = value;
32420
+ this.#format = format;
32421
+ const _value = toString(value, format.decimals);
32422
+ defineProperties(this, { format: format.name, _value });
32423
+ this.#tens = getTens(format.decimals);
32424
+ }
32425
+ /**
32426
+ * If true, negative values are permitted, otherwise only
32427
+ * positive values and zero are allowed.
32428
+ */
32429
+ get signed() { return this.#format.signed; }
32430
+ /**
32431
+ * The number of bits available to store the value.
32432
+ */
32433
+ get width() { return this.#format.width; }
32434
+ /**
32435
+ * The number of decimal places in the fixed-point arithment field.
32436
+ */
32437
+ get decimals() { return this.#format.decimals; }
32438
+ /**
32439
+ * The value as an integer, based on the smallest unit the
32440
+ * [[decimals]] allow.
32441
+ */
32442
+ get value() { return this.#val; }
32443
+ #checkFormat(other) {
32444
+ assertArgument(this.format === other.format, "incompatible format; use fixedNumber.toFormat", "other", other);
32445
+ }
32446
+ #checkValue(val, safeOp) {
32447
+ /*
32448
+ const width = BigInt(this.width);
32449
+ if (this.signed) {
32450
+ const limit = (BN_1 << (width - BN_1));
32451
+ assert(safeOp == null || (val >= -limit && val < limit), "overflow", "NUMERIC_FAULT", {
32452
+ operation: <string>safeOp, fault: "overflow", value: val
32453
+ });
32454
+
32455
+ if (val > BN_0) {
32456
+ val = fromTwos(mask(val, width), width);
32457
+ } else {
32458
+ val = -fromTwos(mask(-val, width), width);
32459
+ }
32460
+
32461
+ } else {
32462
+ const masked = mask(val, width);
32463
+ assert(safeOp == null || (val >= 0 && val === masked), "overflow", "NUMERIC_FAULT", {
32464
+ operation: <string>safeOp, fault: "overflow", value: val
32465
+ });
32466
+ val = masked;
32467
+ }
32468
+ */
32469
+ val = checkValue(val, this.#format, safeOp);
32470
+ return new FixedNumber(_guard$3, val, this.#format);
32471
+ }
32472
+ #add(o, safeOp) {
32473
+ this.#checkFormat(o);
32474
+ return this.#checkValue(this.#val + o.#val, safeOp);
32475
+ }
32476
+ /**
32477
+ * Returns a new [[FixedNumber]] with the result of %%this%% added
32478
+ * to %%other%%, ignoring overflow.
32479
+ */
32480
+ addUnsafe(other) { return this.#add(other); }
32481
+ /**
32482
+ * Returns a new [[FixedNumber]] with the result of %%this%% added
32483
+ * to %%other%%. A [[NumericFaultError]] is thrown if overflow
32484
+ * occurs.
32485
+ */
32486
+ add(other) { return this.#add(other, "add"); }
32487
+ #sub(o, safeOp) {
32488
+ this.#checkFormat(o);
32489
+ return this.#checkValue(this.#val - o.#val, safeOp);
32490
+ }
32491
+ /**
32492
+ * Returns a new [[FixedNumber]] with the result of %%other%% subtracted
32493
+ * from %%this%%, ignoring overflow.
32494
+ */
32495
+ subUnsafe(other) { return this.#sub(other); }
32496
+ /**
32497
+ * Returns a new [[FixedNumber]] with the result of %%other%% subtracted
32498
+ * from %%this%%. A [[NumericFaultError]] is thrown if overflow
32499
+ * occurs.
32500
+ */
32501
+ sub(other) { return this.#sub(other, "sub"); }
32502
+ #mul(o, safeOp) {
32503
+ this.#checkFormat(o);
32504
+ return this.#checkValue((this.#val * o.#val) / this.#tens, safeOp);
32505
+ }
32506
+ /**
32507
+ * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
32508
+ * by %%other%%, ignoring overflow and underflow (precision loss).
32509
+ */
32510
+ mulUnsafe(other) { return this.#mul(other); }
32511
+ /**
32512
+ * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
32513
+ * by %%other%%. A [[NumericFaultError]] is thrown if overflow
32514
+ * occurs.
32515
+ */
32516
+ mul(other) { return this.#mul(other, "mul"); }
32517
+ /**
32518
+ * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
32519
+ * by %%other%%. A [[NumericFaultError]] is thrown if overflow
32520
+ * occurs or if underflow (precision loss) occurs.
32521
+ */
32522
+ mulSignal(other) {
32523
+ this.#checkFormat(other);
32524
+ const value = this.#val * other.#val;
32525
+ assert((value % this.#tens) === BN_0$8, "precision lost during signalling mul", "NUMERIC_FAULT", {
32526
+ operation: "mulSignal", fault: "underflow", value: this
32527
+ });
32528
+ return this.#checkValue(value / this.#tens, "mulSignal");
32529
+ }
32530
+ #div(o, safeOp) {
32531
+ assert(o.#val !== BN_0$8, "division by zero", "NUMERIC_FAULT", {
32532
+ operation: "div", fault: "divide-by-zero", value: this
32533
+ });
32534
+ this.#checkFormat(o);
32535
+ return this.#checkValue((this.#val * this.#tens) / o.#val, safeOp);
32536
+ }
32537
+ /**
32538
+ * Returns a new [[FixedNumber]] with the result of %%this%% divided
32539
+ * by %%other%%, ignoring underflow (precision loss). A
32540
+ * [[NumericFaultError]] is thrown if overflow occurs.
32541
+ */
32542
+ divUnsafe(other) { return this.#div(other); }
32543
+ /**
32544
+ * Returns a new [[FixedNumber]] with the result of %%this%% divided
32545
+ * by %%other%%, ignoring underflow (precision loss). A
32546
+ * [[NumericFaultError]] is thrown if overflow occurs.
32547
+ */
32548
+ div(other) { return this.#div(other, "div"); }
32549
+ /**
32550
+ * Returns a new [[FixedNumber]] with the result of %%this%% divided
32551
+ * by %%other%%. A [[NumericFaultError]] is thrown if underflow
32552
+ * (precision loss) occurs.
32553
+ */
32554
+ divSignal(other) {
32555
+ assert(other.#val !== BN_0$8, "division by zero", "NUMERIC_FAULT", {
32556
+ operation: "div", fault: "divide-by-zero", value: this
32557
+ });
32558
+ this.#checkFormat(other);
32559
+ const value = (this.#val * this.#tens);
32560
+ assert((value % other.#val) === BN_0$8, "precision lost during signalling div", "NUMERIC_FAULT", {
32561
+ operation: "divSignal", fault: "underflow", value: this
32562
+ });
32563
+ return this.#checkValue(value / other.#val, "divSignal");
32564
+ }
32565
+ /**
32566
+ * Returns a comparison result between %%this%% and %%other%%.
32567
+ *
32568
+ * This is suitable for use in sorting, where ``-1`` implies %%this%%
32569
+ * is smaller, ``1`` implies %%this%% is larger and ``0`` implies
32570
+ * both are equal.
32571
+ */
32572
+ cmp(other) {
32573
+ let a = this.value, b = other.value;
32574
+ // Coerce a and b to the same magnitude
32575
+ const delta = this.decimals - other.decimals;
32576
+ if (delta > 0) {
32577
+ b *= getTens(delta);
32578
+ }
32579
+ else if (delta < 0) {
32580
+ a *= getTens(-delta);
32581
+ }
32582
+ // Comnpare
32583
+ if (a < b) {
32584
+ return -1;
32585
+ }
32586
+ if (a > b) {
32587
+ return 1;
32588
+ }
32589
+ return 0;
32590
+ }
32591
+ /**
32592
+ * Returns true if %%other%% is equal to %%this%%.
32593
+ */
32594
+ eq(other) { return this.cmp(other) === 0; }
32595
+ /**
32596
+ * Returns true if %%other%% is less than to %%this%%.
32597
+ */
32598
+ lt(other) { return this.cmp(other) < 0; }
32599
+ /**
32600
+ * Returns true if %%other%% is less than or equal to %%this%%.
32601
+ */
32602
+ lte(other) { return this.cmp(other) <= 0; }
32603
+ /**
32604
+ * Returns true if %%other%% is greater than to %%this%%.
32605
+ */
32606
+ gt(other) { return this.cmp(other) > 0; }
32607
+ /**
32608
+ * Returns true if %%other%% is greater than or equal to %%this%%.
32609
+ */
32610
+ gte(other) { return this.cmp(other) >= 0; }
32611
+ /**
32612
+ * Returns a new [[FixedNumber]] which is the largest **integer**
32613
+ * that is less than or equal to %%this%%.
32614
+ *
32615
+ * The decimal component of the result will always be ``0``.
32616
+ */
32617
+ floor() {
32618
+ let val = this.#val;
32619
+ if (this.#val < BN_0$8) {
32620
+ val -= this.#tens - BN_1$3;
32621
+ }
32622
+ val = (this.#val / this.#tens) * this.#tens;
32623
+ return this.#checkValue(val, "floor");
32624
+ }
32625
+ /**
32626
+ * Returns a new [[FixedNumber]] which is the smallest **integer**
32627
+ * that is greater than or equal to %%this%%.
32628
+ *
32629
+ * The decimal component of the result will always be ``0``.
32630
+ */
32631
+ ceiling() {
32632
+ let val = this.#val;
32633
+ if (this.#val > BN_0$8) {
32634
+ val += this.#tens - BN_1$3;
32635
+ }
32636
+ val = (this.#val / this.#tens) * this.#tens;
32637
+ return this.#checkValue(val, "ceiling");
32638
+ }
32639
+ /**
32640
+ * Returns a new [[FixedNumber]] with the decimal component
32641
+ * rounded up on ties at %%decimals%% places.
32642
+ */
32643
+ round(decimals) {
32644
+ if (decimals == null) {
32645
+ decimals = 0;
32646
+ }
32647
+ // Not enough precision to not already be rounded
32648
+ if (decimals >= this.decimals) {
32649
+ return this;
32650
+ }
32651
+ const delta = this.decimals - decimals;
32652
+ const bump = BN_5 * getTens(delta - 1);
32653
+ let value = this.value + bump;
32654
+ const tens = getTens(delta);
32655
+ value = (value / tens) * tens;
32656
+ checkValue(value, this.#format, "round");
32657
+ return new FixedNumber(_guard$3, value, this.#format);
32658
+ }
32659
+ /**
32660
+ * Returns true if %%this%% is equal to ``0``.
32661
+ */
32662
+ isZero() { return (this.#val === BN_0$8); }
32663
+ /**
32664
+ * Returns true if %%this%% is less than ``0``.
32665
+ */
32666
+ isNegative() { return (this.#val < BN_0$8); }
32667
+ /**
32668
+ * Returns the string representation of %%this%%.
32669
+ */
32670
+ toString() { return this._value; }
32671
+ /**
32672
+ * Returns a float approximation.
32673
+ *
32674
+ * Due to IEEE 754 precission (or lack thereof), this function
32675
+ * can only return an approximation and most values will contain
32676
+ * rounding errors.
32677
+ */
32678
+ toUnsafeFloat() { return parseFloat(this.toString()); }
32679
+ /**
32680
+ * Return a new [[FixedNumber]] with the same value but has had
32681
+ * its field set to %%format%%.
32682
+ *
32683
+ * This will throw if the value cannot fit into %%format%%.
32684
+ */
32685
+ toFormat(format) {
32686
+ return FixedNumber.fromString(this.toString(), format);
32687
+ }
32688
+ /**
32689
+ * Creates a new [[FixedNumber]] for %%value%% divided by
32690
+ * %%decimal%% places with %%format%%.
32691
+ *
32692
+ * This will throw a [[NumericFaultError]] if %%value%% (once adjusted
32693
+ * for %%decimals%%) cannot fit in %%format%%, either due to overflow
32694
+ * or underflow (precision loss).
32695
+ */
32696
+ static fromValue(_value, _decimals, _format) {
32697
+ const decimals = (_decimals == null) ? 0 : getNumber(_decimals);
32698
+ const format = getFormat(_format);
32699
+ let value = getBigInt(_value, "value");
32700
+ const delta = decimals - format.decimals;
32701
+ if (delta > 0) {
32702
+ const tens = getTens(delta);
32703
+ assert((value % tens) === BN_0$8, "value loses precision for format", "NUMERIC_FAULT", {
32704
+ operation: "fromValue", fault: "underflow", value: _value
32705
+ });
32706
+ value /= tens;
32707
+ }
32708
+ else if (delta < 0) {
32709
+ value *= getTens(-delta);
32710
+ }
32711
+ checkValue(value, format, "fromValue");
32712
+ return new FixedNumber(_guard$3, value, format);
32713
+ }
32714
+ /**
32715
+ * Creates a new [[FixedNumber]] for %%value%% with %%format%%.
32716
+ *
32717
+ * This will throw a [[NumericFaultError]] if %%value%% cannot fit
32718
+ * in %%format%%, either due to overflow or underflow (precision loss).
32719
+ */
32720
+ static fromString(_value, _format) {
32721
+ const match = _value.match(/^(-?)([0-9]*)\.?([0-9]*)$/);
32722
+ assertArgument(match && (match[2].length + match[3].length) > 0, "invalid FixedNumber string value", "value", _value);
32723
+ const format = getFormat(_format);
32724
+ let whole = (match[2] || "0"), decimal = (match[3] || "");
32725
+ // Pad out the decimals
32726
+ while (decimal.length < format.decimals) {
32727
+ decimal += Zeros$1;
32728
+ }
32729
+ // Check precision is safe
32730
+ assert(decimal.substring(format.decimals).match(/^0*$/), "too many decimals for format", "NUMERIC_FAULT", {
32731
+ operation: "fromString", fault: "underflow", value: _value
32732
+ });
32733
+ // Remove extra padding
32734
+ decimal = decimal.substring(0, format.decimals);
32735
+ const value = BigInt(match[1] + whole + decimal);
32736
+ checkValue(value, format, "fromString");
32737
+ return new FixedNumber(_guard$3, value, format);
32738
+ }
32739
+ /**
32740
+ * Creates a new [[FixedNumber]] with the big-endian representation
32741
+ * %%value%% with %%format%%.
32742
+ *
32743
+ * This will throw a [[NumericFaultError]] if %%value%% cannot fit
32744
+ * in %%format%% due to overflow.
32745
+ */
32746
+ static fromBytes(_value, _format) {
32747
+ let value = toBigInt(getBytes(_value, "value"));
32748
+ const format = getFormat(_format);
32749
+ if (format.signed) {
32750
+ value = fromTwos(value, format.width);
32751
+ }
32752
+ checkValue(value, format, "fromBytes");
32753
+ return new FixedNumber(_guard$3, value, format);
32754
+ }
32755
+ }
32756
+ //const f1 = FixedNumber.fromString("12.56", "fixed16x2");
32757
+ //const f2 = FixedNumber.fromString("0.3", "fixed16x2");
32758
+ //console.log(f1.divSignal(f2));
32759
+ //const BUMP = FixedNumber.from("0.5");
32760
+
32154
32761
  //See: https://github.com/ethereum/wiki/wiki/RLP
32155
32762
  function hexlifyByte(value) {
32156
32763
  let result = value.toString(16);
@@ -32275,6 +32882,62 @@ function encodeRlp(object) {
32275
32882
  return result;
32276
32883
  }
32277
32884
 
32885
+ /**
32886
+ * Most interactions with Ethereum requires integer values, which use
32887
+ * the smallest magnitude unit.
32888
+ *
32889
+ * For example, imagine dealing with dollars and cents. Since dollars
32890
+ * are divisible, non-integer values are possible, such as ``$10.77``.
32891
+ * By using the smallest indivisible unit (i.e. cents), the value can
32892
+ * be kept as the integer ``1077``.
32893
+ *
32894
+ * When receiving decimal input from the user (as a decimal string),
32895
+ * the value should be converted to an integer and when showing a user
32896
+ * a value, the integer value should be converted to a decimal string.
32897
+ *
32898
+ * This creates a clear distinction, between values to be used by code
32899
+ * (integers) and values used for display logic to users (decimals).
32900
+ *
32901
+ * The native unit in Ethereum, //ether// is divisible to 18 decimal places,
32902
+ * where each individual unit is called a //wei//.
32903
+ *
32904
+ * @_subsection api/utils:Unit Conversion [about-units]
32905
+ */
32906
+ const names = [
32907
+ "wei",
32908
+ "kwei",
32909
+ "mwei",
32910
+ "gwei",
32911
+ "szabo",
32912
+ "finney",
32913
+ "ether",
32914
+ ];
32915
+ /**
32916
+ * Converts the //decimal string// %%value%% to a BigInt, assuming
32917
+ * %%unit%% decimal places. The %%unit%% may the number of decimal places
32918
+ * or the name of a unit (e.g. ``"gwei"`` for 9 decimal places).
32919
+ */
32920
+ function parseUnits$1(value, unit) {
32921
+ assertArgument(typeof (value) === "string", "value must be a string", "value", value);
32922
+ let decimals = 18;
32923
+ if (typeof (unit) === "string") {
32924
+ const index = names.indexOf(unit);
32925
+ assertArgument(index >= 0, "invalid unit", "unit", unit);
32926
+ decimals = 3 * index;
32927
+ }
32928
+ else if (unit != null) {
32929
+ decimals = getNumber(unit, "unit");
32930
+ }
32931
+ return FixedNumber.fromString(value, { decimals, width: 512 }).value;
32932
+ }
32933
+ /**
32934
+ * Converts the //decimal string// %%ether%% to a BigInt, using 18
32935
+ * decimal places.
32936
+ */
32937
+ function parseEther(ether) {
32938
+ return parseUnits$1(ether, 18);
32939
+ }
32940
+
32278
32941
  /**
32279
32942
  * @_ignore:
32280
32943
  */
@@ -53459,23 +54122,8 @@ class OnChainZKPVerifier {
53459
54122
  constructor(_configs, _opts) {
53460
54123
  this._configs = _configs;
53461
54124
  this._opts = _opts;
53462
- /**
53463
- * supported circuits
53464
- */
53465
- this._supportedCircuits = [
53466
- CircuitId.AtomicQueryMTPV2OnChain,
53467
- CircuitId.AtomicQuerySigV2OnChain,
53468
- CircuitId.AtomicQueryV3OnChain
53469
- ];
53470
- /**
53471
- * abi coder to encode/decode structures to solidity bytes
53472
- */
53473
- this._abiCoder = new AbiCoder();
53474
54125
  }
53475
- /**
53476
- * {@inheritDoc IOnChainZKPVerifier.prepareTxArgsSubmitV1}
53477
- */
53478
- async prepareTxArgsSubmitV1(txData, zkProofResponse) {
54126
+ static async prepareTxArgsSubmitV1(txData, zkProofResponse) {
53479
54127
  if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitZKPResponseV1) {
53480
54128
  throw new Error(`prepareTxArgsSubmitV1 function doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV1}' is supported.`);
53481
54129
  }
@@ -53493,6 +54141,12 @@ class OnChainZKPVerifier {
53493
54141
  ];
53494
54142
  return payload;
53495
54143
  }
54144
+ /**
54145
+ * {@inheritDoc IOnChainZKPVerifier.prepareTxArgsSubmitV1}
54146
+ */
54147
+ async prepareTxArgsSubmitV1(txData, zkProofResponse) {
54148
+ return OnChainZKPVerifier.prepareTxArgsSubmitV1(txData, zkProofResponse);
54149
+ }
53496
54150
  /**
53497
54151
  * {@inheritDoc IOnChainZKPVerifier.submitZKPResponse}
53498
54152
  */
@@ -53582,13 +54236,10 @@ class OnChainZKPVerifier {
53582
54236
  const { txnHash } = await transactionService.sendTransactionRequest(ethSigner, request);
53583
54237
  return new Map().set(txnHash, zkProofResponses);
53584
54238
  }
53585
- async prepareTxArgsSubmitV2(txData, zkProofResponses) {
54239
+ static async prepareTxArgsSubmitV2(resolverUrl, txData, zkProofResponses) {
53586
54240
  if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitZKPResponseV2) {
53587
54241
  throw new Error(`submit cross chain doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV2}' is supported.`);
53588
54242
  }
53589
- if (!this._opts?.didResolverUrl) {
53590
- throw new Error(`did resolver url required for crosschain verification`);
53591
- }
53592
54243
  const gistUpdateArr = [];
53593
54244
  const stateUpdateArr = [];
53594
54245
  const payload = [];
@@ -53613,7 +54264,9 @@ class OnChainZKPVerifier {
53613
54264
  continue;
53614
54265
  }
53615
54266
  gistUpdateResolutionsPending.push(JSON.stringify(gist));
53616
- gistUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(DID.parseFromId(gist.id), this._opts.didResolverUrl, { gist: gist.root }));
54267
+ gistUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(DID.parseFromId(gist.id), resolverUrl, {
54268
+ gist: gist.root
54269
+ }));
53617
54270
  }
53618
54271
  const stateUpdateResolutions = [];
53619
54272
  for (const state of stateInfo.states) {
@@ -53622,7 +54275,7 @@ class OnChainZKPVerifier {
53622
54275
  continue;
53623
54276
  }
53624
54277
  stateUpdateResolutionsPending.push(JSON.stringify(state));
53625
- stateUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(DID.parseFromId(state.id), this._opts.didResolverUrl, {
54278
+ stateUpdateResolutions.push(this.resolveDidDocumentEip712MessageAndSignature(DID.parseFromId(state.id), resolverUrl, {
53626
54279
  state: state.state
53627
54280
  }));
53628
54281
  }
@@ -53656,10 +54309,16 @@ class OnChainZKPVerifier {
53656
54309
  const crossChainProofs = this.packCrossChainProofs(gistUpdateArr, stateUpdateArr);
53657
54310
  return [payload, crossChainProofs];
53658
54311
  }
53659
- packZkpProof(inputs, a, b, c) {
53660
- return this._abiCoder.encode(['uint256[] inputs', 'uint256[2]', 'uint256[2][2]', 'uint256[2]'], [inputs, a, b, c]);
54312
+ async prepareTxArgsSubmitV2(txData, zkProofResponses) {
54313
+ if (!this._opts?.didResolverUrl) {
54314
+ throw new Error(`did resolver url required for crosschain verification`);
54315
+ }
54316
+ return OnChainZKPVerifier.prepareTxArgsSubmitV2(this._opts.didResolverUrl, txData, zkProofResponses);
53661
54317
  }
53662
- packCrossChainProofs(gistUpdateArr, stateUpdateArr) {
54318
+ static packZkpProof(inputs, a, b, c) {
54319
+ return new AbiCoder().encode(['uint256[] inputs', 'uint256[2]', 'uint256[2][2]', 'uint256[2]'], [inputs, a, b, c]);
54320
+ }
54321
+ static packCrossChainProofs(gistUpdateArr, stateUpdateArr) {
53663
54322
  const proofs = [];
53664
54323
  for (const globalStateUpdate of gistUpdateArr) {
53665
54324
  proofs.push({
@@ -53673,10 +54332,10 @@ class OnChainZKPVerifier {
53673
54332
  proof: this.packIdentityStateMsg(stateUpdate)
53674
54333
  });
53675
54334
  }
53676
- return this._abiCoder.encode(['tuple(' + 'string proofType,' + 'bytes proof' + ')[]'], [proofs]);
54335
+ return new AbiCoder().encode(['tuple(' + 'string proofType,' + 'bytes proof' + ')[]'], [proofs]);
53677
54336
  }
53678
- packGlobalStateMsg(msg) {
53679
- return this._abiCoder.encode([
54337
+ static packGlobalStateMsg(msg) {
54338
+ return new AbiCoder().encode([
53680
54339
  'tuple(' +
53681
54340
  'tuple(' +
53682
54341
  'uint256 timestamp,' +
@@ -53688,8 +54347,8 @@ class OnChainZKPVerifier {
53688
54347
  ')'
53689
54348
  ], [msg]);
53690
54349
  }
53691
- packIdentityStateMsg(msg) {
53692
- return this._abiCoder.encode([
54350
+ static packIdentityStateMsg(msg) {
54351
+ return new AbiCoder().encode([
53693
54352
  'tuple(' +
53694
54353
  'tuple(' +
53695
54354
  'uint256 timestamp,' +
@@ -53701,10 +54360,10 @@ class OnChainZKPVerifier {
53701
54360
  ')'
53702
54361
  ], [msg]);
53703
54362
  }
53704
- packMetadatas(metas) {
53705
- return this._abiCoder.encode(['tuple(' + 'string key,' + 'bytes value' + ')[]'], [metas]);
54363
+ static packMetadatas(metas) {
54364
+ return new AbiCoder().encode(['tuple(' + 'string key,' + 'bytes value' + ')[]'], [metas]);
53706
54365
  }
53707
- getOnChainGistRootStatePubSignals(onChainCircuitId, inputs) {
54366
+ static getOnChainGistRootStatePubSignals(onChainCircuitId, inputs) {
53708
54367
  let atomicQueryPubSignals;
53709
54368
  switch (onChainCircuitId) {
53710
54369
  case CircuitId.AtomicQueryMTPV2OnChain:
@@ -53721,7 +54380,7 @@ class OnChainZKPVerifier {
53721
54380
  atomicQueryPubSignals.pubSignalsUnmarshal(encodedInputs);
53722
54381
  return atomicQueryPubSignals.getStatesInfo();
53723
54382
  }
53724
- async resolveDidDocumentEip712MessageAndSignature(did, resolverUrl, opts) {
54383
+ static async resolveDidDocumentEip712MessageAndSignature(did, resolverUrl, opts) {
53725
54384
  const didDoc = await resolveDidDocument(did, resolverUrl, {
53726
54385
  ...opts,
53727
54386
  signature: DIDDocumentSignature.EthereumEip712Signature2021
@@ -53754,6 +54413,14 @@ class OnChainZKPVerifier {
53754
54413
  };
53755
54414
  }
53756
54415
  }
54416
+ /**
54417
+ * supported circuits
54418
+ */
54419
+ OnChainZKPVerifier._supportedCircuits = [
54420
+ CircuitId.AtomicQueryMTPV2OnChain,
54421
+ CircuitId.AtomicQuerySigV2OnChain,
54422
+ CircuitId.AtomicQueryV3OnChain
54423
+ ];
53757
54424
 
53758
54425
  var abi$1 = [
53759
54426
  {
@@ -54127,31 +54794,2279 @@ class OnChainRevocationStorage {
54127
54794
  var abi = [
54128
54795
  {
54129
54796
  inputs: [
54797
+ {
54798
+ internalType: "uint256",
54799
+ name: "_userId",
54800
+ type: "uint256"
54801
+ },
54802
+ {
54803
+ internalType: "uint256",
54804
+ name: "_credentialId",
54805
+ type: "uint256"
54806
+ }
54130
54807
  ],
54131
- name: "ECDSAInvalidSignature",
54132
- type: "error"
54808
+ name: "getCredential",
54809
+ outputs: [
54810
+ {
54811
+ components: [
54812
+ {
54813
+ internalType: "uint256",
54814
+ name: "id",
54815
+ type: "uint256"
54816
+ },
54817
+ {
54818
+ internalType: "string[]",
54819
+ name: "context",
54820
+ type: "string[]"
54821
+ },
54822
+ {
54823
+ internalType: "string",
54824
+ name: "_type",
54825
+ type: "string"
54826
+ },
54827
+ {
54828
+ internalType: "uint64",
54829
+ name: "issuanceDate",
54830
+ type: "uint64"
54831
+ },
54832
+ {
54833
+ components: [
54834
+ {
54835
+ internalType: "string",
54836
+ name: "id",
54837
+ type: "string"
54838
+ },
54839
+ {
54840
+ internalType: "string",
54841
+ name: "_type",
54842
+ type: "string"
54843
+ }
54844
+ ],
54845
+ internalType: "struct INonMerklizedIssuer.CredentialSchema",
54846
+ name: "credentialSchema",
54847
+ type: "tuple"
54848
+ },
54849
+ {
54850
+ components: [
54851
+ {
54852
+ internalType: "string",
54853
+ name: "id",
54854
+ type: "string"
54855
+ },
54856
+ {
54857
+ internalType: "string",
54858
+ name: "_type",
54859
+ type: "string"
54860
+ }
54861
+ ],
54862
+ internalType: "struct INonMerklizedIssuer.DisplayMethod",
54863
+ name: "displayMethod",
54864
+ type: "tuple"
54865
+ }
54866
+ ],
54867
+ internalType: "struct INonMerklizedIssuer.CredentialData",
54868
+ name: "",
54869
+ type: "tuple"
54870
+ },
54871
+ {
54872
+ internalType: "uint256[8]",
54873
+ name: "",
54874
+ type: "uint256[8]"
54875
+ },
54876
+ {
54877
+ components: [
54878
+ {
54879
+ internalType: "string",
54880
+ name: "key",
54881
+ type: "string"
54882
+ },
54883
+ {
54884
+ internalType: "uint256",
54885
+ name: "value",
54886
+ type: "uint256"
54887
+ },
54888
+ {
54889
+ internalType: "bytes",
54890
+ name: "rawValue",
54891
+ type: "bytes"
54892
+ }
54893
+ ],
54894
+ internalType: "struct INonMerklizedIssuer.SubjectField[]",
54895
+ name: "",
54896
+ type: "tuple[]"
54897
+ }
54898
+ ],
54899
+ stateMutability: "view",
54900
+ type: "function"
54133
54901
  },
54134
54902
  {
54135
54903
  inputs: [
54904
+ ],
54905
+ name: "getCredentialAdapterVersion",
54906
+ outputs: [
54136
54907
  {
54137
- internalType: "uint256",
54138
- name: "length",
54139
- type: "uint256"
54908
+ internalType: "string",
54909
+ name: "",
54910
+ type: "string"
54140
54911
  }
54141
54912
  ],
54142
- name: "ECDSAInvalidSignatureLength",
54143
- type: "error"
54913
+ stateMutability: "view",
54914
+ type: "function"
54144
54915
  },
54145
54916
  {
54146
54917
  inputs: [
54147
54918
  {
54148
- internalType: "bytes32",
54149
- name: "s",
54150
- type: "bytes32"
54919
+ internalType: "uint256",
54920
+ name: "_userId",
54921
+ type: "uint256"
54151
54922
  }
54152
54923
  ],
54153
- name: "ECDSAInvalidSignatureS",
54154
- type: "error"
54924
+ name: "getUserCredentialIds",
54925
+ outputs: [
54926
+ {
54927
+ internalType: "uint256[]",
54928
+ name: "",
54929
+ type: "uint256[]"
54930
+ }
54931
+ ],
54932
+ stateMutability: "view",
54933
+ type: "function"
54934
+ }
54935
+ ];
54936
+
54937
+ /* Autogenerated file. Do not edit manually. */
54938
+ /* tslint:disable */
54939
+ /* eslint-disable */
54940
+ const _abi = [
54941
+ {
54942
+ inputs: [],
54943
+ name: 'CREDENTIAL_ADAPTER_VERSION',
54944
+ outputs: [
54945
+ {
54946
+ internalType: 'string',
54947
+ name: '',
54948
+ type: 'string'
54949
+ }
54950
+ ],
54951
+ stateMutability: 'view',
54952
+ type: 'function'
54953
+ },
54954
+ {
54955
+ inputs: [
54956
+ {
54957
+ internalType: 'uint256',
54958
+ name: 'claimIndexHash',
54959
+ type: 'uint256'
54960
+ }
54961
+ ],
54962
+ name: 'getClaimProof',
54963
+ outputs: [
54964
+ {
54965
+ components: [
54966
+ {
54967
+ internalType: 'uint256',
54968
+ name: 'root',
54969
+ type: 'uint256'
54970
+ },
54971
+ {
54972
+ internalType: 'bool',
54973
+ name: 'existence',
54974
+ type: 'bool'
54975
+ },
54976
+ {
54977
+ internalType: 'uint256[]',
54978
+ name: 'siblings',
54979
+ type: 'uint256[]'
54980
+ },
54981
+ {
54982
+ internalType: 'uint256',
54983
+ name: 'index',
54984
+ type: 'uint256'
54985
+ },
54986
+ {
54987
+ internalType: 'uint256',
54988
+ name: 'value',
54989
+ type: 'uint256'
54990
+ },
54991
+ {
54992
+ internalType: 'bool',
54993
+ name: 'auxExistence',
54994
+ type: 'bool'
54995
+ },
54996
+ {
54997
+ internalType: 'uint256',
54998
+ name: 'auxIndex',
54999
+ type: 'uint256'
55000
+ },
55001
+ {
55002
+ internalType: 'uint256',
55003
+ name: 'auxValue',
55004
+ type: 'uint256'
55005
+ }
55006
+ ],
55007
+ internalType: 'struct SmtLib.Proof',
55008
+ name: '',
55009
+ type: 'tuple'
55010
+ }
55011
+ ],
55012
+ stateMutability: 'view',
55013
+ type: 'function'
55014
+ },
55015
+ {
55016
+ inputs: [
55017
+ {
55018
+ internalType: 'uint256',
55019
+ name: 'claimIndexHash',
55020
+ type: 'uint256'
55021
+ },
55022
+ {
55023
+ internalType: 'uint256',
55024
+ name: 'root',
55025
+ type: 'uint256'
55026
+ }
55027
+ ],
55028
+ name: 'getClaimProofByRoot',
55029
+ outputs: [
55030
+ {
55031
+ components: [
55032
+ {
55033
+ internalType: 'uint256',
55034
+ name: 'root',
55035
+ type: 'uint256'
55036
+ },
55037
+ {
55038
+ internalType: 'bool',
55039
+ name: 'existence',
55040
+ type: 'bool'
55041
+ },
55042
+ {
55043
+ internalType: 'uint256[]',
55044
+ name: 'siblings',
55045
+ type: 'uint256[]'
55046
+ },
55047
+ {
55048
+ internalType: 'uint256',
55049
+ name: 'index',
55050
+ type: 'uint256'
55051
+ },
55052
+ {
55053
+ internalType: 'uint256',
55054
+ name: 'value',
55055
+ type: 'uint256'
55056
+ },
55057
+ {
55058
+ internalType: 'bool',
55059
+ name: 'auxExistence',
55060
+ type: 'bool'
55061
+ },
55062
+ {
55063
+ internalType: 'uint256',
55064
+ name: 'auxIndex',
55065
+ type: 'uint256'
55066
+ },
55067
+ {
55068
+ internalType: 'uint256',
55069
+ name: 'auxValue',
55070
+ type: 'uint256'
55071
+ }
55072
+ ],
55073
+ internalType: 'struct SmtLib.Proof',
55074
+ name: '',
55075
+ type: 'tuple'
55076
+ }
55077
+ ],
55078
+ stateMutability: 'view',
55079
+ type: 'function'
55080
+ },
55081
+ {
55082
+ inputs: [
55083
+ {
55084
+ internalType: 'uint256',
55085
+ name: 'claimIndexHash',
55086
+ type: 'uint256'
55087
+ }
55088
+ ],
55089
+ name: 'getClaimProofWithStateInfo',
55090
+ outputs: [
55091
+ {
55092
+ components: [
55093
+ {
55094
+ internalType: 'uint256',
55095
+ name: 'root',
55096
+ type: 'uint256'
55097
+ },
55098
+ {
55099
+ internalType: 'bool',
55100
+ name: 'existence',
55101
+ type: 'bool'
55102
+ },
55103
+ {
55104
+ internalType: 'uint256[]',
55105
+ name: 'siblings',
55106
+ type: 'uint256[]'
55107
+ },
55108
+ {
55109
+ internalType: 'uint256',
55110
+ name: 'index',
55111
+ type: 'uint256'
55112
+ },
55113
+ {
55114
+ internalType: 'uint256',
55115
+ name: 'value',
55116
+ type: 'uint256'
55117
+ },
55118
+ {
55119
+ internalType: 'bool',
55120
+ name: 'auxExistence',
55121
+ type: 'bool'
55122
+ },
55123
+ {
55124
+ internalType: 'uint256',
55125
+ name: 'auxIndex',
55126
+ type: 'uint256'
55127
+ },
55128
+ {
55129
+ internalType: 'uint256',
55130
+ name: 'auxValue',
55131
+ type: 'uint256'
55132
+ }
55133
+ ],
55134
+ internalType: 'struct SmtLib.Proof',
55135
+ name: '',
55136
+ type: 'tuple'
55137
+ },
55138
+ {
55139
+ components: [
55140
+ {
55141
+ internalType: 'uint256',
55142
+ name: 'state',
55143
+ type: 'uint256'
55144
+ },
55145
+ {
55146
+ internalType: 'uint256',
55147
+ name: 'claimsRoot',
55148
+ type: 'uint256'
55149
+ },
55150
+ {
55151
+ internalType: 'uint256',
55152
+ name: 'revocationsRoot',
55153
+ type: 'uint256'
55154
+ },
55155
+ {
55156
+ internalType: 'uint256',
55157
+ name: 'rootsRoot',
55158
+ type: 'uint256'
55159
+ }
55160
+ ],
55161
+ internalType: 'struct IdentityLib.StateInfo',
55162
+ name: '',
55163
+ type: 'tuple'
55164
+ }
55165
+ ],
55166
+ stateMutability: 'view',
55167
+ type: 'function'
55168
+ },
55169
+ {
55170
+ inputs: [],
55171
+ name: 'getClaimsTreeRoot',
55172
+ outputs: [
55173
+ {
55174
+ internalType: 'uint256',
55175
+ name: '',
55176
+ type: 'uint256'
55177
+ }
55178
+ ],
55179
+ stateMutability: 'view',
55180
+ type: 'function'
55181
+ },
55182
+ {
55183
+ inputs: [
55184
+ {
55185
+ internalType: 'uint256',
55186
+ name: '_userId',
55187
+ type: 'uint256'
55188
+ },
55189
+ {
55190
+ internalType: 'uint256',
55191
+ name: '_credentialId',
55192
+ type: 'uint256'
55193
+ }
55194
+ ],
55195
+ name: 'getCredential',
55196
+ outputs: [
55197
+ {
55198
+ components: [
55199
+ {
55200
+ internalType: 'uint256',
55201
+ name: 'id',
55202
+ type: 'uint256'
55203
+ },
55204
+ {
55205
+ internalType: 'string[]',
55206
+ name: 'context',
55207
+ type: 'string[]'
55208
+ },
55209
+ {
55210
+ internalType: 'string',
55211
+ name: '_type',
55212
+ type: 'string'
55213
+ },
55214
+ {
55215
+ internalType: 'uint64',
55216
+ name: 'issuanceDate',
55217
+ type: 'uint64'
55218
+ },
55219
+ {
55220
+ components: [
55221
+ {
55222
+ internalType: 'string',
55223
+ name: 'id',
55224
+ type: 'string'
55225
+ },
55226
+ {
55227
+ internalType: 'string',
55228
+ name: '_type',
55229
+ type: 'string'
55230
+ }
55231
+ ],
55232
+ internalType: 'struct INonMerklizedIssuer.CredentialSchema',
55233
+ name: 'credentialSchema',
55234
+ type: 'tuple'
55235
+ },
55236
+ {
55237
+ components: [
55238
+ {
55239
+ internalType: 'string',
55240
+ name: 'id',
55241
+ type: 'string'
55242
+ },
55243
+ {
55244
+ internalType: 'string',
55245
+ name: '_type',
55246
+ type: 'string'
55247
+ }
55248
+ ],
55249
+ internalType: 'struct INonMerklizedIssuer.DisplayMethod',
55250
+ name: 'displayMethod',
55251
+ type: 'tuple'
55252
+ }
55253
+ ],
55254
+ internalType: 'struct INonMerklizedIssuer.CredentialData',
55255
+ name: '',
55256
+ type: 'tuple'
55257
+ },
55258
+ {
55259
+ internalType: 'uint256[8]',
55260
+ name: '',
55261
+ type: 'uint256[8]'
55262
+ },
55263
+ {
55264
+ components: [
55265
+ {
55266
+ internalType: 'string',
55267
+ name: 'key',
55268
+ type: 'string'
55269
+ },
55270
+ {
55271
+ internalType: 'uint256',
55272
+ name: 'value',
55273
+ type: 'uint256'
55274
+ },
55275
+ {
55276
+ internalType: 'bytes',
55277
+ name: 'rawValue',
55278
+ type: 'bytes'
55279
+ }
55280
+ ],
55281
+ internalType: 'struct INonMerklizedIssuer.SubjectField[]',
55282
+ name: '',
55283
+ type: 'tuple[]'
55284
+ }
55285
+ ],
55286
+ stateMutability: 'view',
55287
+ type: 'function'
55288
+ },
55289
+ {
55290
+ inputs: [],
55291
+ name: 'getCredentialAdapterVersion',
55292
+ outputs: [
55293
+ {
55294
+ internalType: 'string',
55295
+ name: '',
55296
+ type: 'string'
55297
+ }
55298
+ ],
55299
+ stateMutability: 'pure',
55300
+ type: 'function'
55301
+ },
55302
+ {
55303
+ inputs: [],
55304
+ name: 'getId',
55305
+ outputs: [
55306
+ {
55307
+ internalType: 'uint256',
55308
+ name: '',
55309
+ type: 'uint256'
55310
+ }
55311
+ ],
55312
+ stateMutability: 'view',
55313
+ type: 'function'
55314
+ },
55315
+ {
55316
+ inputs: [],
55317
+ name: 'getIsOldStateGenesis',
55318
+ outputs: [
55319
+ {
55320
+ internalType: 'bool',
55321
+ name: '',
55322
+ type: 'bool'
55323
+ }
55324
+ ],
55325
+ stateMutability: 'view',
55326
+ type: 'function'
55327
+ },
55328
+ {
55329
+ inputs: [],
55330
+ name: 'getLatestPublishedClaimsRoot',
55331
+ outputs: [
55332
+ {
55333
+ internalType: 'uint256',
55334
+ name: '',
55335
+ type: 'uint256'
55336
+ }
55337
+ ],
55338
+ stateMutability: 'view',
55339
+ type: 'function'
55340
+ },
55341
+ {
55342
+ inputs: [],
55343
+ name: 'getLatestPublishedRevocationsRoot',
55344
+ outputs: [
55345
+ {
55346
+ internalType: 'uint256',
55347
+ name: '',
55348
+ type: 'uint256'
55349
+ }
55350
+ ],
55351
+ stateMutability: 'view',
55352
+ type: 'function'
55353
+ },
55354
+ {
55355
+ inputs: [],
55356
+ name: 'getLatestPublishedRootsRoot',
55357
+ outputs: [
55358
+ {
55359
+ internalType: 'uint256',
55360
+ name: '',
55361
+ type: 'uint256'
55362
+ }
55363
+ ],
55364
+ stateMutability: 'view',
55365
+ type: 'function'
55366
+ },
55367
+ {
55368
+ inputs: [],
55369
+ name: 'getLatestPublishedState',
55370
+ outputs: [
55371
+ {
55372
+ internalType: 'uint256',
55373
+ name: '',
55374
+ type: 'uint256'
55375
+ }
55376
+ ],
55377
+ stateMutability: 'view',
55378
+ type: 'function'
55379
+ },
55380
+ {
55381
+ inputs: [
55382
+ {
55383
+ internalType: 'uint64',
55384
+ name: 'revocationNonce',
55385
+ type: 'uint64'
55386
+ }
55387
+ ],
55388
+ name: 'getRevocationProof',
55389
+ outputs: [
55390
+ {
55391
+ components: [
55392
+ {
55393
+ internalType: 'uint256',
55394
+ name: 'root',
55395
+ type: 'uint256'
55396
+ },
55397
+ {
55398
+ internalType: 'bool',
55399
+ name: 'existence',
55400
+ type: 'bool'
55401
+ },
55402
+ {
55403
+ internalType: 'uint256[]',
55404
+ name: 'siblings',
55405
+ type: 'uint256[]'
55406
+ },
55407
+ {
55408
+ internalType: 'uint256',
55409
+ name: 'index',
55410
+ type: 'uint256'
55411
+ },
55412
+ {
55413
+ internalType: 'uint256',
55414
+ name: 'value',
55415
+ type: 'uint256'
55416
+ },
55417
+ {
55418
+ internalType: 'bool',
55419
+ name: 'auxExistence',
55420
+ type: 'bool'
55421
+ },
55422
+ {
55423
+ internalType: 'uint256',
55424
+ name: 'auxIndex',
55425
+ type: 'uint256'
55426
+ },
55427
+ {
55428
+ internalType: 'uint256',
55429
+ name: 'auxValue',
55430
+ type: 'uint256'
55431
+ }
55432
+ ],
55433
+ internalType: 'struct SmtLib.Proof',
55434
+ name: '',
55435
+ type: 'tuple'
55436
+ }
55437
+ ],
55438
+ stateMutability: 'view',
55439
+ type: 'function'
55440
+ },
55441
+ {
55442
+ inputs: [
55443
+ {
55444
+ internalType: 'uint64',
55445
+ name: 'revocationNonce',
55446
+ type: 'uint64'
55447
+ },
55448
+ {
55449
+ internalType: 'uint256',
55450
+ name: 'root',
55451
+ type: 'uint256'
55452
+ }
55453
+ ],
55454
+ name: 'getRevocationProofByRoot',
55455
+ outputs: [
55456
+ {
55457
+ components: [
55458
+ {
55459
+ internalType: 'uint256',
55460
+ name: 'root',
55461
+ type: 'uint256'
55462
+ },
55463
+ {
55464
+ internalType: 'bool',
55465
+ name: 'existence',
55466
+ type: 'bool'
55467
+ },
55468
+ {
55469
+ internalType: 'uint256[]',
55470
+ name: 'siblings',
55471
+ type: 'uint256[]'
55472
+ },
55473
+ {
55474
+ internalType: 'uint256',
55475
+ name: 'index',
55476
+ type: 'uint256'
55477
+ },
55478
+ {
55479
+ internalType: 'uint256',
55480
+ name: 'value',
55481
+ type: 'uint256'
55482
+ },
55483
+ {
55484
+ internalType: 'bool',
55485
+ name: 'auxExistence',
55486
+ type: 'bool'
55487
+ },
55488
+ {
55489
+ internalType: 'uint256',
55490
+ name: 'auxIndex',
55491
+ type: 'uint256'
55492
+ },
55493
+ {
55494
+ internalType: 'uint256',
55495
+ name: 'auxValue',
55496
+ type: 'uint256'
55497
+ }
55498
+ ],
55499
+ internalType: 'struct SmtLib.Proof',
55500
+ name: '',
55501
+ type: 'tuple'
55502
+ }
55503
+ ],
55504
+ stateMutability: 'view',
55505
+ type: 'function'
55506
+ },
55507
+ {
55508
+ inputs: [
55509
+ {
55510
+ internalType: 'uint64',
55511
+ name: 'revocationNonce',
55512
+ type: 'uint64'
55513
+ }
55514
+ ],
55515
+ name: 'getRevocationProofWithStateInfo',
55516
+ outputs: [
55517
+ {
55518
+ components: [
55519
+ {
55520
+ internalType: 'uint256',
55521
+ name: 'root',
55522
+ type: 'uint256'
55523
+ },
55524
+ {
55525
+ internalType: 'bool',
55526
+ name: 'existence',
55527
+ type: 'bool'
55528
+ },
55529
+ {
55530
+ internalType: 'uint256[]',
55531
+ name: 'siblings',
55532
+ type: 'uint256[]'
55533
+ },
55534
+ {
55535
+ internalType: 'uint256',
55536
+ name: 'index',
55537
+ type: 'uint256'
55538
+ },
55539
+ {
55540
+ internalType: 'uint256',
55541
+ name: 'value',
55542
+ type: 'uint256'
55543
+ },
55544
+ {
55545
+ internalType: 'bool',
55546
+ name: 'auxExistence',
55547
+ type: 'bool'
55548
+ },
55549
+ {
55550
+ internalType: 'uint256',
55551
+ name: 'auxIndex',
55552
+ type: 'uint256'
55553
+ },
55554
+ {
55555
+ internalType: 'uint256',
55556
+ name: 'auxValue',
55557
+ type: 'uint256'
55558
+ }
55559
+ ],
55560
+ internalType: 'struct SmtLib.Proof',
55561
+ name: '',
55562
+ type: 'tuple'
55563
+ },
55564
+ {
55565
+ components: [
55566
+ {
55567
+ internalType: 'uint256',
55568
+ name: 'state',
55569
+ type: 'uint256'
55570
+ },
55571
+ {
55572
+ internalType: 'uint256',
55573
+ name: 'claimsRoot',
55574
+ type: 'uint256'
55575
+ },
55576
+ {
55577
+ internalType: 'uint256',
55578
+ name: 'revocationsRoot',
55579
+ type: 'uint256'
55580
+ },
55581
+ {
55582
+ internalType: 'uint256',
55583
+ name: 'rootsRoot',
55584
+ type: 'uint256'
55585
+ }
55586
+ ],
55587
+ internalType: 'struct IdentityLib.StateInfo',
55588
+ name: '',
55589
+ type: 'tuple'
55590
+ }
55591
+ ],
55592
+ stateMutability: 'view',
55593
+ type: 'function'
55594
+ },
55595
+ {
55596
+ inputs: [
55597
+ {
55598
+ internalType: 'uint256',
55599
+ name: 'id',
55600
+ type: 'uint256'
55601
+ },
55602
+ {
55603
+ internalType: 'uint64',
55604
+ name: 'nonce',
55605
+ type: 'uint64'
55606
+ }
55607
+ ],
55608
+ name: 'getRevocationStatus',
55609
+ outputs: [
55610
+ {
55611
+ components: [
55612
+ {
55613
+ components: [
55614
+ {
55615
+ internalType: 'uint256',
55616
+ name: 'state',
55617
+ type: 'uint256'
55618
+ },
55619
+ {
55620
+ internalType: 'uint256',
55621
+ name: 'claimsTreeRoot',
55622
+ type: 'uint256'
55623
+ },
55624
+ {
55625
+ internalType: 'uint256',
55626
+ name: 'revocationTreeRoot',
55627
+ type: 'uint256'
55628
+ },
55629
+ {
55630
+ internalType: 'uint256',
55631
+ name: 'rootOfRoots',
55632
+ type: 'uint256'
55633
+ }
55634
+ ],
55635
+ internalType: 'struct IOnchainCredentialStatusResolver.IdentityStateRoots',
55636
+ name: 'issuer',
55637
+ type: 'tuple'
55638
+ },
55639
+ {
55640
+ components: [
55641
+ {
55642
+ internalType: 'uint256',
55643
+ name: 'root',
55644
+ type: 'uint256'
55645
+ },
55646
+ {
55647
+ internalType: 'bool',
55648
+ name: 'existence',
55649
+ type: 'bool'
55650
+ },
55651
+ {
55652
+ internalType: 'uint256[]',
55653
+ name: 'siblings',
55654
+ type: 'uint256[]'
55655
+ },
55656
+ {
55657
+ internalType: 'uint256',
55658
+ name: 'index',
55659
+ type: 'uint256'
55660
+ },
55661
+ {
55662
+ internalType: 'uint256',
55663
+ name: 'value',
55664
+ type: 'uint256'
55665
+ },
55666
+ {
55667
+ internalType: 'bool',
55668
+ name: 'auxExistence',
55669
+ type: 'bool'
55670
+ },
55671
+ {
55672
+ internalType: 'uint256',
55673
+ name: 'auxIndex',
55674
+ type: 'uint256'
55675
+ },
55676
+ {
55677
+ internalType: 'uint256',
55678
+ name: 'auxValue',
55679
+ type: 'uint256'
55680
+ }
55681
+ ],
55682
+ internalType: 'struct IOnchainCredentialStatusResolver.Proof',
55683
+ name: 'mtp',
55684
+ type: 'tuple'
55685
+ }
55686
+ ],
55687
+ internalType: 'struct IOnchainCredentialStatusResolver.CredentialStatus',
55688
+ name: '',
55689
+ type: 'tuple'
55690
+ }
55691
+ ],
55692
+ stateMutability: 'view',
55693
+ type: 'function'
55694
+ },
55695
+ {
55696
+ inputs: [
55697
+ {
55698
+ internalType: 'uint256',
55699
+ name: 'id',
55700
+ type: 'uint256'
55701
+ },
55702
+ {
55703
+ internalType: 'uint256',
55704
+ name: 'state',
55705
+ type: 'uint256'
55706
+ },
55707
+ {
55708
+ internalType: 'uint64',
55709
+ name: 'nonce',
55710
+ type: 'uint64'
55711
+ }
55712
+ ],
55713
+ name: 'getRevocationStatusByIdAndState',
55714
+ outputs: [
55715
+ {
55716
+ components: [
55717
+ {
55718
+ components: [
55719
+ {
55720
+ internalType: 'uint256',
55721
+ name: 'state',
55722
+ type: 'uint256'
55723
+ },
55724
+ {
55725
+ internalType: 'uint256',
55726
+ name: 'claimsTreeRoot',
55727
+ type: 'uint256'
55728
+ },
55729
+ {
55730
+ internalType: 'uint256',
55731
+ name: 'revocationTreeRoot',
55732
+ type: 'uint256'
55733
+ },
55734
+ {
55735
+ internalType: 'uint256',
55736
+ name: 'rootOfRoots',
55737
+ type: 'uint256'
55738
+ }
55739
+ ],
55740
+ internalType: 'struct IOnchainCredentialStatusResolver.IdentityStateRoots',
55741
+ name: 'issuer',
55742
+ type: 'tuple'
55743
+ },
55744
+ {
55745
+ components: [
55746
+ {
55747
+ internalType: 'uint256',
55748
+ name: 'root',
55749
+ type: 'uint256'
55750
+ },
55751
+ {
55752
+ internalType: 'bool',
55753
+ name: 'existence',
55754
+ type: 'bool'
55755
+ },
55756
+ {
55757
+ internalType: 'uint256[]',
55758
+ name: 'siblings',
55759
+ type: 'uint256[]'
55760
+ },
55761
+ {
55762
+ internalType: 'uint256',
55763
+ name: 'index',
55764
+ type: 'uint256'
55765
+ },
55766
+ {
55767
+ internalType: 'uint256',
55768
+ name: 'value',
55769
+ type: 'uint256'
55770
+ },
55771
+ {
55772
+ internalType: 'bool',
55773
+ name: 'auxExistence',
55774
+ type: 'bool'
55775
+ },
55776
+ {
55777
+ internalType: 'uint256',
55778
+ name: 'auxIndex',
55779
+ type: 'uint256'
55780
+ },
55781
+ {
55782
+ internalType: 'uint256',
55783
+ name: 'auxValue',
55784
+ type: 'uint256'
55785
+ }
55786
+ ],
55787
+ internalType: 'struct IOnchainCredentialStatusResolver.Proof',
55788
+ name: 'mtp',
55789
+ type: 'tuple'
55790
+ }
55791
+ ],
55792
+ internalType: 'struct IOnchainCredentialStatusResolver.CredentialStatus',
55793
+ name: '',
55794
+ type: 'tuple'
55795
+ }
55796
+ ],
55797
+ stateMutability: 'view',
55798
+ type: 'function'
55799
+ },
55800
+ {
55801
+ inputs: [],
55802
+ name: 'getRevocationsTreeRoot',
55803
+ outputs: [
55804
+ {
55805
+ internalType: 'uint256',
55806
+ name: '',
55807
+ type: 'uint256'
55808
+ }
55809
+ ],
55810
+ stateMutability: 'view',
55811
+ type: 'function'
55812
+ },
55813
+ {
55814
+ inputs: [
55815
+ {
55816
+ internalType: 'uint256',
55817
+ name: 'rootsTreeRoot',
55818
+ type: 'uint256'
55819
+ }
55820
+ ],
55821
+ name: 'getRootProof',
55822
+ outputs: [
55823
+ {
55824
+ components: [
55825
+ {
55826
+ internalType: 'uint256',
55827
+ name: 'root',
55828
+ type: 'uint256'
55829
+ },
55830
+ {
55831
+ internalType: 'bool',
55832
+ name: 'existence',
55833
+ type: 'bool'
55834
+ },
55835
+ {
55836
+ internalType: 'uint256[]',
55837
+ name: 'siblings',
55838
+ type: 'uint256[]'
55839
+ },
55840
+ {
55841
+ internalType: 'uint256',
55842
+ name: 'index',
55843
+ type: 'uint256'
55844
+ },
55845
+ {
55846
+ internalType: 'uint256',
55847
+ name: 'value',
55848
+ type: 'uint256'
55849
+ },
55850
+ {
55851
+ internalType: 'bool',
55852
+ name: 'auxExistence',
55853
+ type: 'bool'
55854
+ },
55855
+ {
55856
+ internalType: 'uint256',
55857
+ name: 'auxIndex',
55858
+ type: 'uint256'
55859
+ },
55860
+ {
55861
+ internalType: 'uint256',
55862
+ name: 'auxValue',
55863
+ type: 'uint256'
55864
+ }
55865
+ ],
55866
+ internalType: 'struct SmtLib.Proof',
55867
+ name: '',
55868
+ type: 'tuple'
55869
+ }
55870
+ ],
55871
+ stateMutability: 'view',
55872
+ type: 'function'
55873
+ },
55874
+ {
55875
+ inputs: [
55876
+ {
55877
+ internalType: 'uint256',
55878
+ name: 'claimsTreeRoot',
55879
+ type: 'uint256'
55880
+ },
55881
+ {
55882
+ internalType: 'uint256',
55883
+ name: 'root',
55884
+ type: 'uint256'
55885
+ }
55886
+ ],
55887
+ name: 'getRootProofByRoot',
55888
+ outputs: [
55889
+ {
55890
+ components: [
55891
+ {
55892
+ internalType: 'uint256',
55893
+ name: 'root',
55894
+ type: 'uint256'
55895
+ },
55896
+ {
55897
+ internalType: 'bool',
55898
+ name: 'existence',
55899
+ type: 'bool'
55900
+ },
55901
+ {
55902
+ internalType: 'uint256[]',
55903
+ name: 'siblings',
55904
+ type: 'uint256[]'
55905
+ },
55906
+ {
55907
+ internalType: 'uint256',
55908
+ name: 'index',
55909
+ type: 'uint256'
55910
+ },
55911
+ {
55912
+ internalType: 'uint256',
55913
+ name: 'value',
55914
+ type: 'uint256'
55915
+ },
55916
+ {
55917
+ internalType: 'bool',
55918
+ name: 'auxExistence',
55919
+ type: 'bool'
55920
+ },
55921
+ {
55922
+ internalType: 'uint256',
55923
+ name: 'auxIndex',
55924
+ type: 'uint256'
55925
+ },
55926
+ {
55927
+ internalType: 'uint256',
55928
+ name: 'auxValue',
55929
+ type: 'uint256'
55930
+ }
55931
+ ],
55932
+ internalType: 'struct SmtLib.Proof',
55933
+ name: '',
55934
+ type: 'tuple'
55935
+ }
55936
+ ],
55937
+ stateMutability: 'view',
55938
+ type: 'function'
55939
+ },
55940
+ {
55941
+ inputs: [
55942
+ {
55943
+ internalType: 'uint256',
55944
+ name: 'rootsTreeRoot',
55945
+ type: 'uint256'
55946
+ }
55947
+ ],
55948
+ name: 'getRootProofWithStateInfo',
55949
+ outputs: [
55950
+ {
55951
+ components: [
55952
+ {
55953
+ internalType: 'uint256',
55954
+ name: 'root',
55955
+ type: 'uint256'
55956
+ },
55957
+ {
55958
+ internalType: 'bool',
55959
+ name: 'existence',
55960
+ type: 'bool'
55961
+ },
55962
+ {
55963
+ internalType: 'uint256[]',
55964
+ name: 'siblings',
55965
+ type: 'uint256[]'
55966
+ },
55967
+ {
55968
+ internalType: 'uint256',
55969
+ name: 'index',
55970
+ type: 'uint256'
55971
+ },
55972
+ {
55973
+ internalType: 'uint256',
55974
+ name: 'value',
55975
+ type: 'uint256'
55976
+ },
55977
+ {
55978
+ internalType: 'bool',
55979
+ name: 'auxExistence',
55980
+ type: 'bool'
55981
+ },
55982
+ {
55983
+ internalType: 'uint256',
55984
+ name: 'auxIndex',
55985
+ type: 'uint256'
55986
+ },
55987
+ {
55988
+ internalType: 'uint256',
55989
+ name: 'auxValue',
55990
+ type: 'uint256'
55991
+ }
55992
+ ],
55993
+ internalType: 'struct SmtLib.Proof',
55994
+ name: '',
55995
+ type: 'tuple'
55996
+ },
55997
+ {
55998
+ components: [
55999
+ {
56000
+ internalType: 'uint256',
56001
+ name: 'state',
56002
+ type: 'uint256'
56003
+ },
56004
+ {
56005
+ internalType: 'uint256',
56006
+ name: 'claimsRoot',
56007
+ type: 'uint256'
56008
+ },
56009
+ {
56010
+ internalType: 'uint256',
56011
+ name: 'revocationsRoot',
56012
+ type: 'uint256'
56013
+ },
56014
+ {
56015
+ internalType: 'uint256',
56016
+ name: 'rootsRoot',
56017
+ type: 'uint256'
56018
+ }
56019
+ ],
56020
+ internalType: 'struct IdentityLib.StateInfo',
56021
+ name: '',
56022
+ type: 'tuple'
56023
+ }
56024
+ ],
56025
+ stateMutability: 'view',
56026
+ type: 'function'
56027
+ },
56028
+ {
56029
+ inputs: [
56030
+ {
56031
+ internalType: 'uint256',
56032
+ name: 'state',
56033
+ type: 'uint256'
56034
+ }
56035
+ ],
56036
+ name: 'getRootsByState',
56037
+ outputs: [
56038
+ {
56039
+ components: [
56040
+ {
56041
+ internalType: 'uint256',
56042
+ name: 'claimsRoot',
56043
+ type: 'uint256'
56044
+ },
56045
+ {
56046
+ internalType: 'uint256',
56047
+ name: 'revocationsRoot',
56048
+ type: 'uint256'
56049
+ },
56050
+ {
56051
+ internalType: 'uint256',
56052
+ name: 'rootsRoot',
56053
+ type: 'uint256'
56054
+ }
56055
+ ],
56056
+ internalType: 'struct IdentityLib.Roots',
56057
+ name: '',
56058
+ type: 'tuple'
56059
+ }
56060
+ ],
56061
+ stateMutability: 'view',
56062
+ type: 'function'
56063
+ },
56064
+ {
56065
+ inputs: [],
56066
+ name: 'getRootsTreeRoot',
56067
+ outputs: [
56068
+ {
56069
+ internalType: 'uint256',
56070
+ name: '',
56071
+ type: 'uint256'
56072
+ }
56073
+ ],
56074
+ stateMutability: 'view',
56075
+ type: 'function'
56076
+ },
56077
+ {
56078
+ inputs: [],
56079
+ name: 'getSmtDepth',
56080
+ outputs: [
56081
+ {
56082
+ internalType: 'uint256',
56083
+ name: '',
56084
+ type: 'uint256'
56085
+ }
56086
+ ],
56087
+ stateMutability: 'pure',
56088
+ type: 'function'
56089
+ },
56090
+ {
56091
+ inputs: [
56092
+ {
56093
+ internalType: 'uint256',
56094
+ name: '_userId',
56095
+ type: 'uint256'
56096
+ }
56097
+ ],
56098
+ name: 'getUserCredentialIds',
56099
+ outputs: [
56100
+ {
56101
+ internalType: 'uint256[]',
56102
+ name: '',
56103
+ type: 'uint256[]'
56104
+ }
56105
+ ],
56106
+ stateMutability: 'view',
56107
+ type: 'function'
56108
+ },
56109
+ {
56110
+ inputs: [
56111
+ {
56112
+ internalType: 'address',
56113
+ name: '_stateContractAddr',
56114
+ type: 'address'
56115
+ },
56116
+ {
56117
+ internalType: 'bytes2',
56118
+ name: 'idType',
56119
+ type: 'bytes2'
56120
+ }
56121
+ ],
56122
+ name: 'initialize',
56123
+ outputs: [],
56124
+ stateMutability: 'nonpayable',
56125
+ type: 'function'
56126
+ },
56127
+ {
56128
+ inputs: [
56129
+ {
56130
+ internalType: 'bytes4',
56131
+ name: 'interfaceId',
56132
+ type: 'bytes4'
56133
+ }
56134
+ ],
56135
+ name: 'supportsInterface',
56136
+ outputs: [
56137
+ {
56138
+ internalType: 'bool',
56139
+ name: '',
56140
+ type: 'bool'
56141
+ }
56142
+ ],
56143
+ stateMutability: 'view',
56144
+ type: 'function'
56145
+ }
56146
+ ];
56147
+ class NonMerklizedIssuerBase__factory {
56148
+ static abi = _abi;
56149
+ static createInterface() {
56150
+ return new Interface(_abi);
56151
+ }
56152
+ static connect(address, runner) {
56153
+ return new Contract(address, _abi, runner);
56154
+ }
56155
+ }
56156
+
56157
+ var NonMerklizedIssuerInterfaces;
56158
+ (function (NonMerklizedIssuerInterfaces) {
56159
+ NonMerklizedIssuerInterfaces["InterfaceDetection"] = "0x01ffc9a7";
56160
+ NonMerklizedIssuerInterfaces["InterfaceNonMerklizedIssuer"] = "0x58874949";
56161
+ NonMerklizedIssuerInterfaces["InterfaceGetCredential"] = "0x5d1ca631";
56162
+ })(NonMerklizedIssuerInterfaces || (NonMerklizedIssuerInterfaces = {}));
56163
+ var ValueHashes;
56164
+ (function (ValueHashes) {
56165
+ ValueHashes["BooleanTrue"] = "18586133768512220936620570745912940619677854269274689475585506675881198879027";
56166
+ ValueHashes["BooleanFalse"] = "19014214495641488759237505126948346942972912379615652741039992445865937985820";
56167
+ })(ValueHashes || (ValueHashes = {}));
56168
+ /**
56169
+ * `OnchainNonMerklizedIssuerAdapter` provides functionality to interact with a non-merklized on-chain credential issuer.
56170
+ * This adapter enables interface detection, credential retrieval, and conversion to the W3C Verifiable Credential format.
56171
+ *
56172
+ * @public
56173
+ * @beta
56174
+ * @class OnchainNonMerklizedIssuerAdapter
56175
+ */
56176
+ class OnchainNonMerklizedIssuerAdapter {
56177
+ /**
56178
+ * Initializes an instance of `OnchainNonMerklizedIssuerAdapter`.
56179
+ *
56180
+ * @param ethConnectionConfig The configuration for the Ethereum connection.
56181
+ * @param issuerDid The decentralized identifier (DID) of the issuer.
56182
+ * @param merklizationOptions Optional settings for merklization.
56183
+ */
56184
+ constructor(ethConnectionConfig, issuerDid, options) {
56185
+ if (!ethConnectionConfig.chainId) {
56186
+ throw new Error('Chain ID is required');
56187
+ }
56188
+ this._chainId = ethConnectionConfig.chainId;
56189
+ this._contractAddress = getAddress(hexlify(Id$1.ethAddressFromId(DID.idFromDID(issuerDid))));
56190
+ this._contract = NonMerklizedIssuerBase__factory.connect(this._contractAddress, new JsonRpcProvider(ethConnectionConfig.url));
56191
+ this._issuerDid = issuerDid;
56192
+ this._merklizationOptions = options?.merklizationOptions;
56193
+ }
56194
+ /**
56195
+ * Checks if the contract supports required interfaces.
56196
+ * Throws an error if any required interface is unsupported.
56197
+ *
56198
+ * @throws Error - If required interfaces are not supported.
56199
+ */
56200
+ async isInterfaceSupported() {
56201
+ const supportedInterfaces = [
56202
+ {
56203
+ name: 'Interface detection ERC-165',
56204
+ value: NonMerklizedIssuerInterfaces.InterfaceDetection
56205
+ },
56206
+ {
56207
+ name: 'Interface non-merklized issuer',
56208
+ value: NonMerklizedIssuerInterfaces.InterfaceNonMerklizedIssuer
56209
+ },
56210
+ {
56211
+ name: 'Interface get credential',
56212
+ value: NonMerklizedIssuerInterfaces.InterfaceGetCredential
56213
+ }
56214
+ ];
56215
+ const unsupportedInterfaces = await Promise.all(supportedInterfaces.map(async (interfaceObj) => {
56216
+ const isSupported = await this._contract.supportsInterface(interfaceObj.value);
56217
+ return isSupported ? null : interfaceObj.name;
56218
+ }));
56219
+ const unsupportedInterfacesFiltered = unsupportedInterfaces.filter((interfaceName) => interfaceName !== null);
56220
+ if (unsupportedInterfacesFiltered.length > 0) {
56221
+ throw new Error(`Unsupported interfaces: ${unsupportedInterfacesFiltered.join(', ')}`);
56222
+ }
56223
+ }
56224
+ /**
56225
+ * Retrieves a credential from the on-chain non-merklized contract.
56226
+ * @param userId The user's core.Id.
56227
+ * @param credentialId The unique identifier of the credential.
56228
+ */
56229
+ async getCredential(userId, credentialId) {
56230
+ const [credentialData, coreClaimBigInts, credentialSubjectFields] = await this._contract.getCredential(userId.bigInt(), credentialId);
56231
+ return { credentialData, coreClaimBigInts, credentialSubjectFields };
56232
+ }
56233
+ /**
56234
+ * Retrieves the credential IDs of a user.
56235
+ * @param userId The user's core.Id.
56236
+ * @returns An array of credential IDs.
56237
+ */
56238
+ async getUserCredentialsIds(userId) {
56239
+ return this._contract.getUserCredentialIds(userId.bigInt());
56240
+ }
56241
+ /**
56242
+ * Converts on-chain credential to a verifiable credential.
56243
+ *
56244
+ * @param credentialData Data structure of the credential from the contract.
56245
+ * @param coreClaimBigInts Claim data in bigint format.
56246
+ * @param credentialSubjectFields Subject fields of the credential.
56247
+ */
56248
+ async convertOnChainInfoToW3CCredential(credentialData, coreClaimBigInts, credentialSubjectFields) {
56249
+ const c = new Claim().unMarshalJson(JSON.stringify(coreClaimBigInts.map((b) => b.toString())));
56250
+ const credentialSubject = await this.convertCredentialSubject(c, credentialData.context, credentialData._type, credentialSubjectFields);
56251
+ const credentialRequest = {
56252
+ id: this.credentialId(credentialData.id),
56253
+ credentialSchema: credentialData.credentialSchema.id,
56254
+ type: credentialData._type,
56255
+ credentialSubject: credentialSubject,
56256
+ expiration: c.getExpirationDate()?.getTime(),
56257
+ displayMethod: this.convertDisplayMethod(credentialData.displayMethod),
56258
+ context: credentialData.context,
56259
+ revocationOpts: {
56260
+ id: this._contractAddress,
56261
+ nonce: Number(c.getRevocationNonce()),
56262
+ type: CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023
56263
+ },
56264
+ issuanceDate: getDateFromUnixTimestamp(Number(credentialData.issuanceDate)).getTime()
56265
+ };
56266
+ const existenceProof = await this.existenceProof(c);
56267
+ const w3c = W3CCredential.fromCredentialRequest(this._issuerDid, credentialRequest);
56268
+ w3c.proof = [existenceProof];
56269
+ return w3c;
56270
+ }
56271
+ credentialId(id) {
56272
+ return `urn:iden3:onchain:${this._chainId}:${this._contractAddress}:${id}`;
56273
+ }
56274
+ async convertCredentialSubject(coreClaim, contractContexts, credentialType, credentialSubjectFields) {
56275
+ const contractContextsStr = JSON.stringify({
56276
+ '@context': contractContexts
56277
+ });
56278
+ const credentialSubject = {};
56279
+ for (const f of credentialSubjectFields) {
56280
+ const dataType = await Path.newTypeFromContext(contractContextsStr, `${credentialType}.${f.key}`, this._merklizationOptions);
56281
+ switch (dataType) {
56282
+ case XSDNS.Boolean: {
56283
+ switch (f.rawValue.toString()) {
56284
+ case ValueHashes.BooleanTrue:
56285
+ credentialSubject[f.key] = true;
56286
+ break;
56287
+ case ValueHashes.BooleanFalse:
56288
+ credentialSubject[f.key] = false;
56289
+ break;
56290
+ }
56291
+ break;
56292
+ }
56293
+ case (XSDNS.PositiveInteger):
56294
+ {
56295
+ credentialSubject[f.key] = f.value.toString();
56296
+ break;
56297
+ }
56298
+ case XSDNS.Integer: {
56299
+ credentialSubject[f.key] = Number(f.value);
56300
+ break;
56301
+ }
56302
+ case XSDNS.String: {
56303
+ this.validateSourceValue(dataType, f.value, f.rawValue);
56304
+ credentialSubject[f.key] = f.rawValue;
56305
+ break;
56306
+ }
56307
+ case XSDNS.DateTime: {
56308
+ const timestamp = BigInt(f.rawValue);
56309
+ const sourceTimestamp = getDateFromUnixTimestamp(Number(timestamp)).toISOString();
56310
+ this.validateSourceValue(dataType, f.value, sourceTimestamp);
56311
+ credentialSubject[f.key] = sourceTimestamp;
56312
+ break;
56313
+ }
56314
+ case XSDNS.Double: {
56315
+ const rawFloat = Number(f.rawValue);
56316
+ this.validateSourceValue(dataType, f.value, rawFloat);
56317
+ credentialSubject[f.key] = rawFloat;
56318
+ break;
56319
+ }
56320
+ default: {
56321
+ throw new Error(`Unsupported data type ${dataType}`);
56322
+ }
56323
+ }
56324
+ }
56325
+ credentialSubject['type'] = credentialType;
56326
+ const subjectId = coreClaim.getId();
56327
+ const subjectDid = DID.parseFromId(subjectId);
56328
+ credentialSubject['id'] = subjectDid.string();
56329
+ return credentialSubject;
56330
+ }
56331
+ async existenceProof(coreClaim) {
56332
+ const [mtpProof, stateInfo] = await this._contract.getClaimProofWithStateInfo(coreClaim.hIndex());
56333
+ if (!mtpProof.existence) {
56334
+ throw new Error('Claim does not exist');
56335
+ }
56336
+ const latestStateHash = Hash$2.fromBigInt(stateInfo.state);
56337
+ const latestClaimsOfRootHash = Hash$2.fromBigInt(stateInfo.claimsRoot);
56338
+ const latestRevocationOfRootHash = Hash$2.fromBigInt(stateInfo.revocationsRoot);
56339
+ const latestRootsOfRootHash = Hash$2.fromBigInt(stateInfo.rootsRoot);
56340
+ const p = new Proof({
56341
+ siblings: mtpProof.siblings.map((s) => Hash$2.fromBigInt(s)),
56342
+ existence: mtpProof.existence,
56343
+ nodeAux: mtpProof.auxExistence
56344
+ ? {
56345
+ key: Hash$2.fromBigInt(mtpProof.auxIndex),
56346
+ value: Hash$2.fromBigInt(mtpProof.auxValue)
56347
+ }
56348
+ : undefined
56349
+ });
56350
+ return new Iden3SparseMerkleTreeProof({
56351
+ issuerData: {
56352
+ id: this._issuerDid,
56353
+ state: {
56354
+ value: latestStateHash,
56355
+ claimsTreeRoot: latestClaimsOfRootHash,
56356
+ revocationTreeRoot: latestRevocationOfRootHash,
56357
+ rootOfRoots: latestRootsOfRootHash
56358
+ }
56359
+ },
56360
+ mtp: p,
56361
+ coreClaim: coreClaim
56362
+ });
56363
+ }
56364
+ async validateSourceValue(dataType, originHash, source) {
56365
+ const sourceHash = await Merklizer.hashValue(dataType, source);
56366
+ if (sourceHash !== originHash) {
56367
+ throw new Error(`Invalid source value for ${dataType} type`);
56368
+ }
56369
+ }
56370
+ convertDisplayMethod(onchainDisplayMethod) {
56371
+ if (!onchainDisplayMethod.id || !onchainDisplayMethod._type) {
56372
+ return undefined;
56373
+ }
56374
+ switch (onchainDisplayMethod._type) {
56375
+ case DisplayMethodType.Iden3BasicDisplayMethodV1: {
56376
+ return {
56377
+ id: onchainDisplayMethod.id,
56378
+ type: DisplayMethodType.Iden3BasicDisplayMethodV1
56379
+ };
56380
+ }
56381
+ default: {
56382
+ throw new Error(`Unsupported display method type ${onchainDisplayMethod._type}`);
56383
+ }
56384
+ }
56385
+ }
56386
+ }
56387
+
56388
+ /**
56389
+ * Represents an adapter for interacting with on-chain issuers.
56390
+ *
56391
+ * @public
56392
+ * @beta
56393
+ * @class OnchainIssuer
56394
+ */
56395
+ class OnchainIssuer {
56396
+ /**
56397
+ * Initializes an instance of `Adapter`.
56398
+ * @param config The configuration for the Ethereum connection.
56399
+ * @param merklizationOptions Optional settings for merklization.
56400
+ */
56401
+ constructor(config, options) {
56402
+ this._ethConnectionConfig = config;
56403
+ this._onchainIssuerOptions = options;
56404
+ }
56405
+ /**
56406
+ * Retrieves a credential from the on-chain issuer.
56407
+ * @param issuerDID The issuer's core.DID.
56408
+ * @param userId The user's core.Id.
56409
+ * @param credentialId The unique identifier of the credential.
56410
+ */
56411
+ async getCredential(issuerDID, userDID, credentialId) {
56412
+ const { contract, connection } = this.getContractConnection(issuerDID);
56413
+ const response = await contract.getCredentialAdapterVersion();
56414
+ switch (response) {
56415
+ case '0.0.1': {
56416
+ const adapter = new OnchainNonMerklizedIssuerAdapter(connection, issuerDID, {
56417
+ merklizationOptions: this._onchainIssuerOptions?.merklizationOptions
56418
+ });
56419
+ await adapter.isInterfaceSupported();
56420
+ const { credentialData, coreClaimBigInts, credentialSubjectFields } = await adapter.getCredential(DID.idFromDID(userDID), credentialId);
56421
+ return await adapter.convertOnChainInfoToW3CCredential(credentialData, coreClaimBigInts, credentialSubjectFields);
56422
+ }
56423
+ default:
56424
+ throw new Error(`Unsupported adapter version ${response}`);
56425
+ }
56426
+ }
56427
+ /**
56428
+ * Retrieves the credential identifiers for a user from the on-chain issuer.
56429
+ * @param issuerDID The issuer's core.DID.
56430
+ * @param userId The user's core.Id.
56431
+ */
56432
+ async getUserCredentialIds(issuerDID, userDID) {
56433
+ const { contract, connection } = this.getContractConnection(issuerDID);
56434
+ const response = await contract.getCredentialAdapterVersion();
56435
+ switch (response) {
56436
+ case '0.0.1': {
56437
+ const adapter = new OnchainNonMerklizedIssuerAdapter(connection, issuerDID, {
56438
+ merklizationOptions: this._onchainIssuerOptions?.merklizationOptions
56439
+ });
56440
+ await adapter.isInterfaceSupported();
56441
+ return await adapter.getUserCredentialsIds(DID.idFromDID(userDID));
56442
+ }
56443
+ default:
56444
+ throw new Error(`Unsupported adapter version ${response}`);
56445
+ }
56446
+ }
56447
+ getContractConnection(did) {
56448
+ const issuerId = DID.idFromDID(did);
56449
+ const chainId = chainIDfromDID(did);
56450
+ const contractAddress = getAddress(hexlify(Id$1.ethAddressFromId(issuerId)));
56451
+ const connection = this._ethConnectionConfig.find((c) => c.chainId === chainId);
56452
+ if (!connection) {
56453
+ throw new Error(`No connection found for chain ID ${chainId}`);
56454
+ }
56455
+ if (!connection.url) {
56456
+ throw new Error(`No URL found for chain ID ${chainId}`);
56457
+ }
56458
+ const contract = new Contract(contractAddress, abi, new JsonRpcProvider(connection.url));
56459
+ return { contract, connection };
56460
+ }
56461
+ }
56462
+
56463
+ class DidResolverStateReadonlyStorage {
56464
+ constructor(resolverUrl) {
56465
+ this.resolverUrl = resolverUrl;
56466
+ }
56467
+ async getLatestStateById(id) {
56468
+ return this.getStateInfo(id);
56469
+ }
56470
+ async getStateInfoByIdAndState(id, state) {
56471
+ return this.getStateInfo(id, state);
56472
+ }
56473
+ async getGISTProof(id) {
56474
+ const { didDocument } = await resolveDidDocument(DID.parseFromId(Id$1.fromBigInt(id)), this.resolverUrl);
56475
+ const { global } = this.getIden3StateInfo2023(didDocument);
56476
+ if (!global) {
56477
+ throw new Error('GIST root not found');
56478
+ }
56479
+ const { proof } = global;
56480
+ if (!proof) {
56481
+ throw new Error('GIST proof not found');
56482
+ }
56483
+ return {
56484
+ root: global.root,
56485
+ existence: proof.existence,
56486
+ siblings: proof.siblings?.map((sibling) => BigInt(sibling)),
56487
+ index: BigInt(0),
56488
+ value: BigInt(0),
56489
+ auxExistence: !!proof.node_aux,
56490
+ auxIndex: proof.node_aux ? BigInt(proof.node_aux.key) : BigInt(0),
56491
+ auxValue: proof.node_aux ? BigInt(proof.node_aux.value) : BigInt(0)
56492
+ };
56493
+ }
56494
+ async getGISTRootInfo(root, userId) {
56495
+ const { didDocument } = await resolveDidDocument(DID.parseFromId(Id$1.fromBigInt(userId)), this.resolverUrl, {
56496
+ gist: Hash$2.fromBigInt(root)
56497
+ });
56498
+ const { global } = this.getIden3StateInfo2023(didDocument);
56499
+ if (!global) {
56500
+ throw new Error('GIST root not found');
56501
+ }
56502
+ return global;
56503
+ }
56504
+ getRpcProvider() {
56505
+ return new JsonRpcProvider();
56506
+ }
56507
+ publishState() {
56508
+ throw new Error('publishState method not implemented.');
56509
+ }
56510
+ publishStateGeneric() {
56511
+ throw new Error('publishStateGeneric method not implemented.');
56512
+ }
56513
+ async getStateInfo(id, state) {
56514
+ const opts = state ? { state: Hash$2.fromBigInt(state) } : undefined;
56515
+ const { didDocument } = await resolveDidDocument(DID.parseFromId(Id$1.fromBigInt(id)), this.resolverUrl, opts);
56516
+ const { info } = this.getIden3StateInfo2023(didDocument);
56517
+ return { ...info };
56518
+ }
56519
+ getIden3StateInfo2023(didDocument) {
56520
+ const vm = didDocument.verificationMethod?.find((i) => i.type === 'Iden3StateInfo2023');
56521
+ if (!vm) {
56522
+ throw new Error('Iden3StateInfo2023 verification method not found');
56523
+ }
56524
+ return vm;
56525
+ }
56526
+ }
56527
+
56528
+ var permitAbi = [
56529
+ {
56530
+ inputs: [
56531
+ ],
56532
+ name: "ECDSAInvalidSignature",
56533
+ type: "error"
56534
+ },
56535
+ {
56536
+ inputs: [
56537
+ {
56538
+ internalType: "uint256",
56539
+ name: "length",
56540
+ type: "uint256"
56541
+ }
56542
+ ],
56543
+ name: "ECDSAInvalidSignatureLength",
56544
+ type: "error"
56545
+ },
56546
+ {
56547
+ inputs: [
56548
+ {
56549
+ internalType: "bytes32",
56550
+ name: "s",
56551
+ type: "bytes32"
56552
+ }
56553
+ ],
56554
+ name: "ECDSAInvalidSignatureS",
56555
+ type: "error"
56556
+ },
56557
+ {
56558
+ inputs: [
56559
+ {
56560
+ internalType: "address",
56561
+ name: "spender",
56562
+ type: "address"
56563
+ },
56564
+ {
56565
+ internalType: "uint256",
56566
+ name: "allowance",
56567
+ type: "uint256"
56568
+ },
56569
+ {
56570
+ internalType: "uint256",
56571
+ name: "needed",
56572
+ type: "uint256"
56573
+ }
56574
+ ],
56575
+ name: "ERC20InsufficientAllowance",
56576
+ type: "error"
56577
+ },
56578
+ {
56579
+ inputs: [
56580
+ {
56581
+ internalType: "address",
56582
+ name: "sender",
56583
+ type: "address"
56584
+ },
56585
+ {
56586
+ internalType: "uint256",
56587
+ name: "balance",
56588
+ type: "uint256"
56589
+ },
56590
+ {
56591
+ internalType: "uint256",
56592
+ name: "needed",
56593
+ type: "uint256"
56594
+ }
56595
+ ],
56596
+ name: "ERC20InsufficientBalance",
56597
+ type: "error"
56598
+ },
56599
+ {
56600
+ inputs: [
56601
+ {
56602
+ internalType: "address",
56603
+ name: "approver",
56604
+ type: "address"
56605
+ }
56606
+ ],
56607
+ name: "ERC20InvalidApprover",
56608
+ type: "error"
56609
+ },
56610
+ {
56611
+ inputs: [
56612
+ {
56613
+ internalType: "address",
56614
+ name: "receiver",
56615
+ type: "address"
56616
+ }
56617
+ ],
56618
+ name: "ERC20InvalidReceiver",
56619
+ type: "error"
56620
+ },
56621
+ {
56622
+ inputs: [
56623
+ {
56624
+ internalType: "address",
56625
+ name: "sender",
56626
+ type: "address"
56627
+ }
56628
+ ],
56629
+ name: "ERC20InvalidSender",
56630
+ type: "error"
56631
+ },
56632
+ {
56633
+ inputs: [
56634
+ {
56635
+ internalType: "address",
56636
+ name: "spender",
56637
+ type: "address"
56638
+ }
56639
+ ],
56640
+ name: "ERC20InvalidSpender",
56641
+ type: "error"
56642
+ },
56643
+ {
56644
+ inputs: [
56645
+ {
56646
+ internalType: "uint256",
56647
+ name: "deadline",
56648
+ type: "uint256"
56649
+ }
56650
+ ],
56651
+ name: "ERC2612ExpiredSignature",
56652
+ type: "error"
56653
+ },
56654
+ {
56655
+ inputs: [
56656
+ {
56657
+ internalType: "address",
56658
+ name: "signer",
56659
+ type: "address"
56660
+ },
56661
+ {
56662
+ internalType: "address",
56663
+ name: "owner",
56664
+ type: "address"
56665
+ }
56666
+ ],
56667
+ name: "ERC2612InvalidSigner",
56668
+ type: "error"
56669
+ },
56670
+ {
56671
+ inputs: [
56672
+ {
56673
+ internalType: "address",
56674
+ name: "account",
56675
+ type: "address"
56676
+ },
56677
+ {
56678
+ internalType: "uint256",
56679
+ name: "currentNonce",
56680
+ type: "uint256"
56681
+ }
56682
+ ],
56683
+ name: "InvalidAccountNonce",
56684
+ type: "error"
56685
+ },
56686
+ {
56687
+ inputs: [
56688
+ ],
56689
+ name: "InvalidShortString",
56690
+ type: "error"
56691
+ },
56692
+ {
56693
+ inputs: [
56694
+ {
56695
+ internalType: "string",
56696
+ name: "str",
56697
+ type: "string"
56698
+ }
56699
+ ],
56700
+ name: "StringTooLong",
56701
+ type: "error"
56702
+ },
56703
+ {
56704
+ anonymous: false,
56705
+ inputs: [
56706
+ {
56707
+ indexed: true,
56708
+ internalType: "address",
56709
+ name: "owner",
56710
+ type: "address"
56711
+ },
56712
+ {
56713
+ indexed: true,
56714
+ internalType: "address",
56715
+ name: "spender",
56716
+ type: "address"
56717
+ },
56718
+ {
56719
+ indexed: false,
56720
+ internalType: "uint256",
56721
+ name: "value",
56722
+ type: "uint256"
56723
+ }
56724
+ ],
56725
+ name: "Approval",
56726
+ type: "event"
56727
+ },
56728
+ {
56729
+ anonymous: false,
56730
+ inputs: [
56731
+ ],
56732
+ name: "EIP712DomainChanged",
56733
+ type: "event"
56734
+ },
56735
+ {
56736
+ anonymous: false,
56737
+ inputs: [
56738
+ {
56739
+ indexed: true,
56740
+ internalType: "address",
56741
+ name: "from",
56742
+ type: "address"
56743
+ },
56744
+ {
56745
+ indexed: true,
56746
+ internalType: "address",
56747
+ name: "to",
56748
+ type: "address"
56749
+ },
56750
+ {
56751
+ indexed: false,
56752
+ internalType: "uint256",
56753
+ name: "value",
56754
+ type: "uint256"
56755
+ }
56756
+ ],
56757
+ name: "Transfer",
56758
+ type: "event"
56759
+ },
56760
+ {
56761
+ inputs: [
56762
+ ],
56763
+ name: "DOMAIN_SEPARATOR",
56764
+ outputs: [
56765
+ {
56766
+ internalType: "bytes32",
56767
+ name: "",
56768
+ type: "bytes32"
56769
+ }
56770
+ ],
56771
+ stateMutability: "view",
56772
+ type: "function"
56773
+ },
56774
+ {
56775
+ inputs: [
56776
+ {
56777
+ internalType: "address",
56778
+ name: "owner",
56779
+ type: "address"
56780
+ },
56781
+ {
56782
+ internalType: "address",
56783
+ name: "spender",
56784
+ type: "address"
56785
+ }
56786
+ ],
56787
+ name: "allowance",
56788
+ outputs: [
56789
+ {
56790
+ internalType: "uint256",
56791
+ name: "",
56792
+ type: "uint256"
56793
+ }
56794
+ ],
56795
+ stateMutability: "view",
56796
+ type: "function"
56797
+ },
56798
+ {
56799
+ inputs: [
56800
+ {
56801
+ internalType: "address",
56802
+ name: "spender",
56803
+ type: "address"
56804
+ },
56805
+ {
56806
+ internalType: "uint256",
56807
+ name: "value",
56808
+ type: "uint256"
56809
+ }
56810
+ ],
56811
+ name: "approve",
56812
+ outputs: [
56813
+ {
56814
+ internalType: "bool",
56815
+ name: "",
56816
+ type: "bool"
56817
+ }
56818
+ ],
56819
+ stateMutability: "nonpayable",
56820
+ type: "function"
56821
+ },
56822
+ {
56823
+ inputs: [
56824
+ {
56825
+ internalType: "address",
56826
+ name: "account",
56827
+ type: "address"
56828
+ }
56829
+ ],
56830
+ name: "balanceOf",
56831
+ outputs: [
56832
+ {
56833
+ internalType: "uint256",
56834
+ name: "",
56835
+ type: "uint256"
56836
+ }
56837
+ ],
56838
+ stateMutability: "view",
56839
+ type: "function"
56840
+ },
56841
+ {
56842
+ inputs: [
56843
+ ],
56844
+ name: "decimals",
56845
+ outputs: [
56846
+ {
56847
+ internalType: "uint8",
56848
+ name: "",
56849
+ type: "uint8"
56850
+ }
56851
+ ],
56852
+ stateMutability: "view",
56853
+ type: "function"
56854
+ },
56855
+ {
56856
+ inputs: [
56857
+ ],
56858
+ name: "eip712Domain",
56859
+ outputs: [
56860
+ {
56861
+ internalType: "bytes1",
56862
+ name: "fields",
56863
+ type: "bytes1"
56864
+ },
56865
+ {
56866
+ internalType: "string",
56867
+ name: "name",
56868
+ type: "string"
56869
+ },
56870
+ {
56871
+ internalType: "string",
56872
+ name: "version",
56873
+ type: "string"
56874
+ },
56875
+ {
56876
+ internalType: "uint256",
56877
+ name: "chainId",
56878
+ type: "uint256"
56879
+ },
56880
+ {
56881
+ internalType: "address",
56882
+ name: "verifyingContract",
56883
+ type: "address"
56884
+ },
56885
+ {
56886
+ internalType: "bytes32",
56887
+ name: "salt",
56888
+ type: "bytes32"
56889
+ },
56890
+ {
56891
+ internalType: "uint256[]",
56892
+ name: "extensions",
56893
+ type: "uint256[]"
56894
+ }
56895
+ ],
56896
+ stateMutability: "view",
56897
+ type: "function"
56898
+ },
56899
+ {
56900
+ inputs: [
56901
+ ],
56902
+ name: "name",
56903
+ outputs: [
56904
+ {
56905
+ internalType: "string",
56906
+ name: "",
56907
+ type: "string"
56908
+ }
56909
+ ],
56910
+ stateMutability: "view",
56911
+ type: "function"
56912
+ },
56913
+ {
56914
+ inputs: [
56915
+ {
56916
+ internalType: "address",
56917
+ name: "owner",
56918
+ type: "address"
56919
+ }
56920
+ ],
56921
+ name: "nonces",
56922
+ outputs: [
56923
+ {
56924
+ internalType: "uint256",
56925
+ name: "",
56926
+ type: "uint256"
56927
+ }
56928
+ ],
56929
+ stateMutability: "view",
56930
+ type: "function"
56931
+ },
56932
+ {
56933
+ inputs: [
56934
+ {
56935
+ internalType: "address",
56936
+ name: "owner",
56937
+ type: "address"
56938
+ },
56939
+ {
56940
+ internalType: "address",
56941
+ name: "spender",
56942
+ type: "address"
56943
+ },
56944
+ {
56945
+ internalType: "uint256",
56946
+ name: "value",
56947
+ type: "uint256"
56948
+ },
56949
+ {
56950
+ internalType: "uint256",
56951
+ name: "deadline",
56952
+ type: "uint256"
56953
+ },
56954
+ {
56955
+ internalType: "uint8",
56956
+ name: "v",
56957
+ type: "uint8"
56958
+ },
56959
+ {
56960
+ internalType: "bytes32",
56961
+ name: "r",
56962
+ type: "bytes32"
56963
+ },
56964
+ {
56965
+ internalType: "bytes32",
56966
+ name: "s",
56967
+ type: "bytes32"
56968
+ }
56969
+ ],
56970
+ name: "permit",
56971
+ outputs: [
56972
+ ],
56973
+ stateMutability: "nonpayable",
56974
+ type: "function"
56975
+ },
56976
+ {
56977
+ inputs: [
56978
+ ],
56979
+ name: "symbol",
56980
+ outputs: [
56981
+ {
56982
+ internalType: "string",
56983
+ name: "",
56984
+ type: "string"
56985
+ }
56986
+ ],
56987
+ stateMutability: "view",
56988
+ type: "function"
56989
+ },
56990
+ {
56991
+ inputs: [
56992
+ ],
56993
+ name: "totalSupply",
56994
+ outputs: [
56995
+ {
56996
+ internalType: "uint256",
56997
+ name: "",
56998
+ type: "uint256"
56999
+ }
57000
+ ],
57001
+ stateMutability: "view",
57002
+ type: "function"
57003
+ },
57004
+ {
57005
+ inputs: [
57006
+ {
57007
+ internalType: "address",
57008
+ name: "to",
57009
+ type: "address"
57010
+ },
57011
+ {
57012
+ internalType: "uint256",
57013
+ name: "value",
57014
+ type: "uint256"
57015
+ }
57016
+ ],
57017
+ name: "transfer",
57018
+ outputs: [
57019
+ {
57020
+ internalType: "bool",
57021
+ name: "",
57022
+ type: "bool"
57023
+ }
57024
+ ],
57025
+ stateMutability: "nonpayable",
57026
+ type: "function"
57027
+ },
57028
+ {
57029
+ inputs: [
57030
+ {
57031
+ internalType: "address",
57032
+ name: "from",
57033
+ type: "address"
57034
+ },
57035
+ {
57036
+ internalType: "address",
57037
+ name: "to",
57038
+ type: "address"
57039
+ },
57040
+ {
57041
+ internalType: "uint256",
57042
+ name: "value",
57043
+ type: "uint256"
57044
+ }
57045
+ ],
57046
+ name: "transferFrom",
57047
+ outputs: [
57048
+ {
57049
+ internalType: "bool",
57050
+ name: "",
57051
+ type: "bool"
57052
+ }
57053
+ ],
57054
+ stateMutability: "nonpayable",
57055
+ type: "function"
57056
+ }
57057
+ ];
57058
+
57059
+ var erc20Abi = [
57060
+ {
57061
+ inputs: [
57062
+ {
57063
+ internalType: "uint256",
57064
+ name: "initialSupply",
57065
+ type: "uint256"
57066
+ }
57067
+ ],
57068
+ stateMutability: "nonpayable",
57069
+ type: "constructor"
54155
57070
  },
54156
57071
  {
54157
57072
  inputs: [
@@ -54239,66 +57154,6 @@ var abi = [
54239
57154
  name: "ERC20InvalidSpender",
54240
57155
  type: "error"
54241
57156
  },
54242
- {
54243
- inputs: [
54244
- {
54245
- internalType: "uint256",
54246
- name: "deadline",
54247
- type: "uint256"
54248
- }
54249
- ],
54250
- name: "ERC2612ExpiredSignature",
54251
- type: "error"
54252
- },
54253
- {
54254
- inputs: [
54255
- {
54256
- internalType: "address",
54257
- name: "signer",
54258
- type: "address"
54259
- },
54260
- {
54261
- internalType: "address",
54262
- name: "owner",
54263
- type: "address"
54264
- }
54265
- ],
54266
- name: "ERC2612InvalidSigner",
54267
- type: "error"
54268
- },
54269
- {
54270
- inputs: [
54271
- {
54272
- internalType: "address",
54273
- name: "account",
54274
- type: "address"
54275
- },
54276
- {
54277
- internalType: "uint256",
54278
- name: "currentNonce",
54279
- type: "uint256"
54280
- }
54281
- ],
54282
- name: "InvalidAccountNonce",
54283
- type: "error"
54284
- },
54285
- {
54286
- inputs: [
54287
- ],
54288
- name: "InvalidShortString",
54289
- type: "error"
54290
- },
54291
- {
54292
- inputs: [
54293
- {
54294
- internalType: "string",
54295
- name: "str",
54296
- type: "string"
54297
- }
54298
- ],
54299
- name: "StringTooLong",
54300
- type: "error"
54301
- },
54302
57157
  {
54303
57158
  anonymous: false,
54304
57159
  inputs: [
@@ -54324,13 +57179,6 @@ var abi = [
54324
57179
  name: "Approval",
54325
57180
  type: "event"
54326
57181
  },
54327
- {
54328
- anonymous: false,
54329
- inputs: [
54330
- ],
54331
- name: "EIP712DomainChanged",
54332
- type: "event"
54333
- },
54334
57182
  {
54335
57183
  anonymous: false,
54336
57184
  inputs: [
@@ -54356,20 +57204,6 @@ var abi = [
54356
57204
  name: "Transfer",
54357
57205
  type: "event"
54358
57206
  },
54359
- {
54360
- inputs: [
54361
- ],
54362
- name: "DOMAIN_SEPARATOR",
54363
- outputs: [
54364
- {
54365
- internalType: "bytes32",
54366
- name: "",
54367
- type: "bytes32"
54368
- }
54369
- ],
54370
- stateMutability: "view",
54371
- type: "function"
54372
- },
54373
57207
  {
54374
57208
  inputs: [
54375
57209
  {
@@ -54451,50 +57285,6 @@ var abi = [
54451
57285
  stateMutability: "view",
54452
57286
  type: "function"
54453
57287
  },
54454
- {
54455
- inputs: [
54456
- ],
54457
- name: "eip712Domain",
54458
- outputs: [
54459
- {
54460
- internalType: "bytes1",
54461
- name: "fields",
54462
- type: "bytes1"
54463
- },
54464
- {
54465
- internalType: "string",
54466
- name: "name",
54467
- type: "string"
54468
- },
54469
- {
54470
- internalType: "string",
54471
- name: "version",
54472
- type: "string"
54473
- },
54474
- {
54475
- internalType: "uint256",
54476
- name: "chainId",
54477
- type: "uint256"
54478
- },
54479
- {
54480
- internalType: "address",
54481
- name: "verifyingContract",
54482
- type: "address"
54483
- },
54484
- {
54485
- internalType: "bytes32",
54486
- name: "salt",
54487
- type: "bytes32"
54488
- },
54489
- {
54490
- internalType: "uint256[]",
54491
- name: "extensions",
54492
- type: "uint256[]"
54493
- }
54494
- ],
54495
- stateMutability: "view",
54496
- type: "function"
54497
- },
54498
57288
  {
54499
57289
  inputs: [
54500
57290
  ],
@@ -54509,69 +57299,6 @@ var abi = [
54509
57299
  stateMutability: "view",
54510
57300
  type: "function"
54511
57301
  },
54512
- {
54513
- inputs: [
54514
- {
54515
- internalType: "address",
54516
- name: "owner",
54517
- type: "address"
54518
- }
54519
- ],
54520
- name: "nonces",
54521
- outputs: [
54522
- {
54523
- internalType: "uint256",
54524
- name: "",
54525
- type: "uint256"
54526
- }
54527
- ],
54528
- stateMutability: "view",
54529
- type: "function"
54530
- },
54531
- {
54532
- inputs: [
54533
- {
54534
- internalType: "address",
54535
- name: "owner",
54536
- type: "address"
54537
- },
54538
- {
54539
- internalType: "address",
54540
- name: "spender",
54541
- type: "address"
54542
- },
54543
- {
54544
- internalType: "uint256",
54545
- name: "value",
54546
- type: "uint256"
54547
- },
54548
- {
54549
- internalType: "uint256",
54550
- name: "deadline",
54551
- type: "uint256"
54552
- },
54553
- {
54554
- internalType: "uint8",
54555
- name: "v",
54556
- type: "uint8"
54557
- },
54558
- {
54559
- internalType: "bytes32",
54560
- name: "r",
54561
- type: "bytes32"
54562
- },
54563
- {
54564
- internalType: "bytes32",
54565
- name: "s",
54566
- type: "bytes32"
54567
- }
54568
- ],
54569
- name: "permit",
54570
- outputs: [
54571
- ],
54572
- stateMutability: "nonpayable",
54573
- type: "function"
54574
- },
54575
57302
  {
54576
57303
  inputs: [
54577
57304
  ],
@@ -54666,10 +57393,11 @@ var abi = [
54666
57393
  * @returns {Promise<PaymentRequestMessage>}
54667
57394
  */
54668
57395
  async function getPermitSignature(signer, tokenAddress, spender, value, deadline) {
54669
- const erc20PermitContract = new Contract(tokenAddress, abi, signer);
57396
+ const erc20PermitContract = new Contract(tokenAddress, permitAbi, signer);
54670
57397
  const nonce = await erc20PermitContract.nonces(await signer.getAddress());
54671
57398
  const domainData = await erc20PermitContract.eip712Domain();
54672
57399
  const domain = {
57400
+ name: domainData[1],
54673
57401
  version: domainData[2],
54674
57402
  chainId: domainData[3],
54675
57403
  verifyingContract: tokenAddress
@@ -54692,6 +57420,16 @@ async function getPermitSignature(signer, tokenAddress, spender, value, deadline
54692
57420
  };
54693
57421
  return signer.signTypedData(domain, types, message);
54694
57422
  }
57423
+ /**
57424
+ * @beta
57425
+ * getERC20Decimals is a function to retrieve the number of decimals of an ERC20 token
57426
+ * @param {string} tokenAddress - Token address
57427
+ * @param {ethers.ContractRunner} runner - Contract runner
57428
+ */
57429
+ async function getERC20Decimals(tokenAddress, runner) {
57430
+ const erc20Contract = new Contract(tokenAddress, erc20Abi, runner);
57431
+ return erc20Contract.decimals();
57432
+ }
54695
57433
 
54696
57434
  /**
54697
57435
  * Type of MerkleTree
@@ -56370,6 +59108,24 @@ class Iden3SmtRhsCredentialStatusPublisher {
56370
59108
  }
56371
59109
  }
56372
59110
 
59111
+ class DidDocumentCredentialStatusResolver {
59112
+ constructor(didResolverUrl) {
59113
+ this.didResolverUrl = didResolverUrl;
59114
+ }
59115
+ async resolve(credentialStatus, opts) {
59116
+ if (!opts?.issuerDID) {
59117
+ throw new Error('IssuerDID is not set in options');
59118
+ }
59119
+ const url = `${this.didResolverUrl}/1.0/credential-status/${encodeURIComponent(opts.issuerDID.string())}`;
59120
+ const resp = await fetch(url, {
59121
+ method: 'POST',
59122
+ body: JSON.stringify(credentialStatus)
59123
+ });
59124
+ const data = await resp.json();
59125
+ return data;
59126
+ }
59127
+ }
59128
+
56373
59129
  /**
56374
59130
  *
56375
59131
  * Wallet instance is a wrapper of CRUD logic for W3C credentials,
@@ -56396,40 +59152,18 @@ class CredentialWallet {
56396
59152
  if (!schema.$metadata.uris['jsonLdContext']) {
56397
59153
  throw new Error('jsonLdContext is missing is the schema');
56398
59154
  }
56399
- request.context = request.context ?? [];
56400
- if (request.displayMethod?.type === DisplayMethodType.Iden3BasicDisplayMethodV1 &&
56401
- !request.context.includes(VerifiableConstants.JSONLD_SCHEMA.IDEN3_DISPLAY_METHOD)) {
56402
- request.context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN3_DISPLAY_METHOD);
56403
- }
56404
- const context = [
56405
- VerifiableConstants.JSONLD_SCHEMA.W3C_CREDENTIAL_2018,
56406
- ...request.context,
56407
- VerifiableConstants.JSONLD_SCHEMA.IDEN3_CREDENTIAL,
56408
- schema.$metadata.uris['jsonLdContext']
56409
- ];
56410
- const credentialType = [
56411
- VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_CREDENTIAL,
56412
- request.type
56413
- ];
56414
- const expirationDate = !request.expiration || request.expiration == 0 ? null : request.expiration;
56415
- const credentialSubject = request.credentialSubject;
56416
- credentialSubject['type'] = request.type;
56417
- const cr = new W3CCredential();
56418
- cr.id = `urn:${v4()}`;
56419
- cr['@context'] = context;
56420
- cr.type = credentialType;
56421
- cr.expirationDate = expirationDate ? new Date(expirationDate * 1000).toISOString() : undefined;
56422
- cr.refreshService = request.refreshService;
56423
- cr.displayMethod = request.displayMethod;
56424
- cr.issuanceDate = new Date().toISOString();
56425
- cr.credentialSubject = credentialSubject;
56426
- cr.issuer = issuer.string();
56427
- cr.credentialSchema = {
56428
- id: request.credentialSchema,
56429
- type: VerifiableConstants.JSON_SCHEMA_VALIDATOR
56430
- };
56431
- cr.credentialStatus = this.buildCredentialStatus(request, issuer);
56432
- return cr;
59155
+ // do copy of request to avoid mutation
59156
+ const r = { ...request };
59157
+ r.context = r.context ?? [];
59158
+ if (r.displayMethod?.type === DisplayMethodType.Iden3BasicDisplayMethodV1 &&
59159
+ !r.context.includes(VerifiableConstants.JSONLD_SCHEMA.IDEN3_DISPLAY_METHOD)) {
59160
+ r.context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN3_DISPLAY_METHOD);
59161
+ }
59162
+ r.context.push(schema.$metadata.uris['jsonLdContext']);
59163
+ r.expiration = r.expiration ? r.expiration * 1000 : undefined;
59164
+ r.id = r.id ? r.id : `urn:${v4()}`;
59165
+ r.issuanceDate = r.issuanceDate ? r.issuanceDate * 1000 : Date.now();
59166
+ return W3CCredential.fromCredentialRequest(issuer, r);
56433
59167
  };
56434
59168
  // if no credential status resolvers are provided
56435
59169
  // register default issuer resolver
@@ -56499,51 +59233,6 @@ class CredentialWallet {
56499
59233
  }
56500
59234
  return statusResolver.resolve(credStatus, credentialStatusResolveOptions);
56501
59235
  }
56502
- /**
56503
- * Builds credential status
56504
- * @param {CredentialRequest} request
56505
- * @returns `CredentialStatus`
56506
- */
56507
- buildCredentialStatus(request, issuer) {
56508
- const credentialStatus = {
56509
- id: request.revocationOpts.id,
56510
- type: request.revocationOpts.type,
56511
- revocationNonce: request.revocationOpts.nonce
56512
- };
56513
- switch (request.revocationOpts.type) {
56514
- case CredentialStatusType.SparseMerkleTreeProof:
56515
- return {
56516
- ...credentialStatus,
56517
- id: `${credentialStatus.id.replace(/\/$/, '')}/${credentialStatus.revocationNonce}`
56518
- };
56519
- case CredentialStatusType.Iden3ReverseSparseMerkleTreeProof:
56520
- return {
56521
- ...credentialStatus,
56522
- id: request.revocationOpts.issuerState
56523
- ? `${credentialStatus.id.replace(/\/$/, '')}/node?state=${request.revocationOpts.issuerState}`
56524
- : `${credentialStatus.id.replace(/\/$/, '')}`
56525
- };
56526
- case CredentialStatusType.Iden3OnchainSparseMerkleTreeProof2023: {
56527
- const issuerId = DID.idFromDID(issuer);
56528
- const chainId = getChainId(DID.blockchainFromId(issuerId), DID.networkIdFromId(issuerId));
56529
- const searchParams = [
56530
- ['revocationNonce', request.revocationOpts.nonce?.toString() || ''],
56531
- ['contractAddress', `${chainId}:${request.revocationOpts.id}`],
56532
- ['state', request.revocationOpts.issuerState || '']
56533
- ]
56534
- .filter(([, value]) => Boolean(value))
56535
- .map(([key, value]) => `${key}=${value}`)
56536
- .join('&');
56537
- return {
56538
- ...credentialStatus,
56539
- // `[did]:[methodid]:[chain]:[network]:[id]/credentialStatus?(revocationNonce=value)&[contractAddress=[chainID]:[contractAddress]]&(state=issuerState)`
56540
- id: `${issuer.string()}/credentialStatus?${searchParams}`
56541
- };
56542
- }
56543
- default:
56544
- return credentialStatus;
56545
- }
56546
- }
56547
59236
  /**
56548
59237
  * {@inheritDoc ICredentialWallet.findById}
56549
59238
  */
@@ -58520,10 +61209,34 @@ class FetchHandler extends AbstractMessageHandler {
58520
61209
  return this.handleFetchRequest(message);
58521
61210
  case PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ISSUANCE_RESPONSE_MESSAGE_TYPE:
58522
61211
  return this.handleIssuanceResponseMsg(message);
61212
+ case PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE: {
61213
+ const result = await this.handleOnchainOfferMessage(message);
61214
+ if (Array.isArray(result)) {
61215
+ const credWallet = this.opts?.credentialWallet;
61216
+ if (!credWallet)
61217
+ throw new Error('Credential wallet is not provided');
61218
+ await credWallet.saveAll(result);
61219
+ return null;
61220
+ }
61221
+ return result;
61222
+ }
58523
61223
  default:
58524
61224
  return super.handle(message, ctx);
58525
61225
  }
58526
61226
  }
61227
+ async handleOnchainOfferMessage(offerMessage) {
61228
+ if (!this.opts?.onchainIssuer) {
61229
+ throw new Error('onchain issuer is not provided');
61230
+ }
61231
+ const credentials = [];
61232
+ for (const credentialInfo of offerMessage.body.credentials) {
61233
+ const issuerDID = DID.parse(offerMessage.from);
61234
+ const userDID = DID.parse(offerMessage.to);
61235
+ const credential = await this.opts.onchainIssuer.getCredential(issuerDID, userDID, BigInt(credentialInfo.id));
61236
+ credentials.push(credential);
61237
+ }
61238
+ return credentials;
61239
+ }
58527
61240
  async handleOfferMessage(offerMessage, ctx) {
58528
61241
  if (!ctx.mediaType) {
58529
61242
  ctx.mediaType = MediaType.ZKPMessage;
@@ -58608,6 +61321,14 @@ class FetchHandler extends AbstractMessageHandler {
58608
61321
  }
58609
61322
  throw new Error('invalid protocol message response');
58610
61323
  }
61324
+ /**
61325
+ * Handles only messages with credentials/1.0/onchain-offer type
61326
+ * @beta
61327
+ */
61328
+ async handleOnchainOffer(offer) {
61329
+ const offerMessage = await FetchHandler.unpackMessage(this._packerMgr, offer, PROTOCOL_MESSAGE_TYPE.CREDENTIAL_ONCHAIN_OFFER_MESSAGE_TYPE);
61330
+ return this.handleOnchainOfferMessage(offerMessage);
61331
+ }
58611
61332
  async handleFetchRequest(msgRequest) {
58612
61333
  if (!msgRequest.to) {
58613
61334
  throw new Error("failed request. empty 'to' field");
@@ -59261,19 +61982,20 @@ function createPaymentRequest(sender, receiver, agent, payments, opts) {
59261
61982
  return request;
59262
61983
  }
59263
61984
  async function verifyEIP712TypedData(data, resolver) {
61985
+ const convertedAmount = await convertPaymentAmount(data.amount, data.currency);
59264
61986
  const paymentData = data.type === PaymentRequestDataType.Iden3PaymentRailsRequestV1
59265
61987
  ? {
59266
61988
  recipient: data.recipient,
59267
- amount: data.amount,
59268
- expirationDate: new Date(data.expirationDate).getTime(),
61989
+ amount: convertedAmount,
61990
+ expirationDate: getUnixTimestamp(new Date(data.expirationDate)),
59269
61991
  nonce: data.nonce,
59270
61992
  metadata: '0x'
59271
61993
  }
59272
61994
  : {
59273
61995
  tokenAddress: data.tokenAddress,
59274
61996
  recipient: data.recipient,
59275
- amount: data.amount,
59276
- expirationDate: new Date(data.expirationDate).getTime(),
61997
+ amount: convertedAmount,
61998
+ expirationDate: getUnixTimestamp(new Date(data.expirationDate)),
59277
61999
  nonce: data.nonce,
59278
62000
  metadata: '0x'
59279
62001
  };
@@ -59296,6 +62018,30 @@ async function verifyEIP712TypedData(data, resolver) {
59296
62018
  }
59297
62019
  throw new Error(`failed request. no matching verificationMethod`);
59298
62020
  }
62021
+ async function convertPaymentAmount(amount, currency) {
62022
+ let convertedAmount = 0n;
62023
+ switch (currency) {
62024
+ case SupportedCurrencies.ETH:
62025
+ case SupportedCurrencies.POL:
62026
+ case SupportedCurrencies.MATIC:
62027
+ convertedAmount = parseEther(amount.toString());
62028
+ break;
62029
+ case SupportedCurrencies.ETH_WEI:
62030
+ convertedAmount = parseUnits$1(amount.toString(), 'wei');
62031
+ break;
62032
+ case SupportedCurrencies.ETH_GWEI:
62033
+ convertedAmount = parseUnits$1(amount.toString(), 'gwei');
62034
+ break;
62035
+ case SupportedCurrencies.USDC:
62036
+ case SupportedCurrencies.USDT: {
62037
+ convertedAmount = parseUnits$1(amount.toString(), 6);
62038
+ break;
62039
+ }
62040
+ default:
62041
+ throw new Error(`failed request. unsupported currency ${currency}`);
62042
+ }
62043
+ return convertedAmount;
62044
+ }
59299
62045
  /**
59300
62046
  * @beta
59301
62047
  * createPayment is a function to create protocol payment message
@@ -59493,26 +62239,25 @@ class PaymentHandler extends AbstractMessageHandler {
59493
62239
  if (type === PaymentRequestDataType.Iden3PaymentRailsERC20RequestV1 && !tokenAddress) {
59494
62240
  throw new Error(`failed request. no token address for currency ${currency}`);
59495
62241
  }
59496
- const expirationTime = expirationDate
59497
- ? new Date(expirationDate).getTime()
59498
- : new Date(new Date().setHours(new Date().getHours() + 1)).getTime();
62242
+ const expirationDateRequired = expirationDate ?? new Date(new Date().setHours(new Date().getHours() + 1));
59499
62243
  const typeUrl = `https://schema.iden3.io/core/json/${type}.json`;
59500
62244
  const typesFetchResult = await fetch(typeUrl);
59501
62245
  const types = await typesFetchResult.json();
59502
62246
  delete types.EIP712Domain;
62247
+ const convertedAmount = await convertPaymentAmount(amount, currency);
59503
62248
  const paymentData = type === PaymentRequestDataType.Iden3PaymentRailsRequestV1
59504
62249
  ? {
59505
62250
  recipient,
59506
- amount,
59507
- expirationDate: expirationTime,
62251
+ amount: convertedAmount,
62252
+ expirationDate: getUnixTimestamp(expirationDateRequired),
59508
62253
  nonce,
59509
62254
  metadata: '0x'
59510
62255
  }
59511
62256
  : {
59512
62257
  tokenAddress,
59513
62258
  recipient,
59514
- amount,
59515
- expirationDate: expirationTime,
62259
+ amount: convertedAmount,
62260
+ expirationDate: getUnixTimestamp(expirationDateRequired),
59516
62261
  nonce,
59517
62262
  metadata: '0x'
59518
62263
  };
@@ -59546,7 +62291,7 @@ class PaymentHandler extends AbstractMessageHandler {
59546
62291
  recipient,
59547
62292
  amount: amount.toString(),
59548
62293
  currency,
59549
- expirationDate: new Date(expirationTime).toISOString(),
62294
+ expirationDate: expirationDateRequired.toISOString(),
59550
62295
  nonce: nonce.toString(),
59551
62296
  metadata: '0x',
59552
62297
  proof
@@ -61672,5 +64417,5 @@ class IdentityWallet {
61672
64417
  }
61673
64418
  }
61674
64419
 
61675
- export { AbstractMessageHandler, AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AtomicQueryV3Inputs, AtomicQueryV3OnChainInputs, AtomicQueryV3OnChainPubSignals, AtomicQueryV3PubSignals, AuthHandler, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialOfferStatus, CredentialProposalHandler, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DIDDocumentSignature, DataPrepareHandlerFunc, DisplayMethodType, Ed25519Provider, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, FunctionSignatures, Iden3OnchainSmtCredentialStatusPublisher, Iden3SmtRhsCredentialStatusPublisher, Iden3SparseMerkleTreeProof, IdentityStorage, IdentityWallet, InMemoryDataSource, InMemoryMerkleTreeStorage, InMemoryPrivateKeyStore, IndexedDBDataSource, IndexedDBPrivateKeyStore, InputGenerator, IssuerResolver, JSON_SCHEMA_VALIDATORS_REGISTRY, JWSPacker, JsonSchemaValidator, KMS, KmsKeyType, LDParser, LinkedMultiQueryInputs, LinkedMultiQueryPubSignals, LocalStoragePrivateKeyStore, MerkleTreeIndexedDBStorage, MerkleTreeLocalStorage, MerkleTreeType, MerklizedRootPosition, MessageBus, MessageHandler, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PaymentFeatures, PaymentHandler, PaymentRequestDataType, PaymentType, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, SupportedCurrencies, SupportedPaymentProofType, TransactionService, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildAccept, buildDIDFromEthPubKey, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58$1 as bytesToBase58, bytesToBase64, bytesToBase64url$1 as bytesToBase64url, bytesToHex$3 as bytesToHex, cacheLoader, calculateCoreSchemaHash, calculateQueryHashV2, calculateQueryHashV3, checkCircuitOperator, checkCircuitQueriesLength, checkDataInField, checkQueryRequest, circuitValidator, comparatorOptions, createAuthorizationRequest, createAuthorizationRequestWithMessage, createPayment, createPaymentRequest, createProposal, createProposalRequest, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url$1 as decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaim, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fieldValueFromVerifiablePresentation, fillCoreClaimSlot, fillSlot, findCredentialType, findValue, generateProfileDID, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getPermitSignature, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$3 as hexToBytes, isEthereumIdentity, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, parseAcceptProfile, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, processZeroKnowledgeProofRequests, pushHashesToRHS, resolveDIDDocumentAuth, resolveDidDocument, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateDisclosureNativeSDSupport, validateDisclosureV2Circuit, validateEmptyCredentialSubjectNoopNativeSupport, validateEmptyCredentialSubjectV2Circuit, validateOperators, validateTreeState, verifyEIP712TypedData, verifyExpiresTime, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
64420
+ export { AbstractMessageHandler, AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AtomicQueryV3Inputs, AtomicQueryV3OnChainInputs, AtomicQueryV3OnChainPubSignals, AtomicQueryV3PubSignals, AuthHandler, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialOfferStatus, CredentialProposalHandler, CredentialStatusPublisherRegistry, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DIDDocumentSignature, DataPrepareHandlerFunc, DidDocumentCredentialStatusResolver, DidResolverStateReadonlyStorage, DisplayMethodType, Ed25519Provider, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, FunctionSignatures, Iden3OnchainSmtCredentialStatusPublisher, Iden3SmtRhsCredentialStatusPublisher, Iden3SparseMerkleTreeProof, IdentityStorage, IdentityWallet, InMemoryDataSource, InMemoryMerkleTreeStorage, InMemoryPrivateKeyStore, IndexedDBDataSource, IndexedDBPrivateKeyStore, InputGenerator, IssuerResolver, JSON_SCHEMA_VALIDATORS_REGISTRY, JWSPacker, JsonSchemaValidator, KMS, KmsKeyType, LDParser, LinkedMultiQueryInputs, LinkedMultiQueryPubSignals, LocalStoragePrivateKeyStore, MerkleTreeIndexedDBStorage, MerkleTreeLocalStorage, MerkleTreeType, MerklizedRootPosition, MessageBus, MessageHandler, NativeProver, OnChainResolver, OnChainRevocationStorage, OnChainZKPVerifier, OnchainIssuer, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PaymentFeatures, PaymentHandler, PaymentRequestDataType, PaymentType, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, PubSignalsVerifier, Query, QueryOperators, RHSResolver, RefreshHandler, RefreshServiceType, RevocationStatusHandler, SDK_EVENTS, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, SupportedCurrencies, SupportedPaymentProofType, TransactionService, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, XSDNS, ZKPPacker, availableTypesOperators, base58ToBytes$1 as base58ToBytes, base64ToBytes$1 as base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, bigIntCompare, buildAccept, buildDIDFromEthPubKey, buildFieldPath, buildTreeState, buildVerifierId, byteDecoder, byteEncoder, bytesToBase58$1 as bytesToBase58, bytesToBase64, bytesToBase64url$1 as bytesToBase64url, bytesToHex$3 as bytesToHex, cacheLoader, calculateCoreSchemaHash, calculateQueryHashV2, calculateQueryHashV3, checkCircuitOperator, checkCircuitQueriesLength, checkDataInField, checkQueryRequest, circuitValidator, comparatorOptions, convertPaymentAmount, createAuthorizationRequest, createAuthorizationRequestWithMessage, createPayment, createPaymentRequest, createProposal, createProposalRequest, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url$1 as decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaim, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fieldValueFromVerifiablePresentation, fillCoreClaimSlot, fillSlot, findCredentialType, findValue, generateProfileDID, getERC20Decimals, getFieldSlotIndex, getKMSIdByAuthCredential, getNodeAuxValue, getNodesRepresentation, getOperatorNameByValue, getPermitSignature, getProperties, getSerializationAttrFromContext, getSerializationAttrFromParsedContext, getUserDIDFromCredential, hexToBytes$3 as hexToBytes, isEthereumIdentity, isGenesisState, isGenesisStateId, isIssuerGenesis, isValidOperation, keyPath, mergeObjects, parseAcceptProfile, parseCoreClaimSlots, parseCredentialSubject, parseQueriesMetadata, parseQueryMetadata, parseSerializationAttr, prepareCircuitArrayValues, prepareSiblingsStr, processZeroKnowledgeProofRequests, pushHashesToRHS, resolveDIDDocumentAuth, resolveDidDocument, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, transformQueryValueToBigInts, userStateError, validateDIDDocumentAuth, validateDisclosureNativeSDSupport, validateDisclosureV2Circuit, validateEmptyCredentialSubjectNoopNativeSupport, validateEmptyCredentialSubjectV2Circuit, validateOperators, validateTreeState, verifyEIP712TypedData, verifyExpiresTime, verifyFieldValueInclusionNativeExistsSupport, verifyFieldValueInclusionV2, witnessBuilder };
61676
64421
  //# sourceMappingURL=index.js.map