@0xpolygonid/js-sdk 1.4.0 → 1.4.2
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.
- package/dist/browser/esm/index.js +77 -46
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +77 -46
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/credentials/status/reverse-sparse-merkle-tree.js +4 -3
- package/dist/node/cjs/proof/proof-service.js +1 -1
- package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +17 -1
- package/dist/node/cjs/storage/blockchain/state.js +17 -2
- package/dist/node/esm/credentials/status/reverse-sparse-merkle-tree.js +4 -3
- package/dist/node/esm/proof/proof-service.js +1 -1
- package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +17 -1
- package/dist/node/esm/storage/blockchain/state.js +17 -2
- package/dist/types/proof/proof-service.d.ts +8 -1
- package/dist/types/storage/blockchain/state.d.ts +2 -0
- package/package.json +1 -1
|
@@ -57732,8 +57732,23 @@ var PolygonIdSdk = (function (exports) {
|
|
|
57732
57732
|
],
|
|
57733
57733
|
proof.proof.pi_c.slice(0, 2)
|
|
57734
57734
|
];
|
|
57735
|
-
await
|
|
57736
|
-
const
|
|
57735
|
+
const feeData = await this.provider.getFeeData();
|
|
57736
|
+
const maxFeePerGas = defaultEthConnectionConfig.maxFeePerGas
|
|
57737
|
+
? BigInt(defaultEthConnectionConfig.maxFeePerGas)
|
|
57738
|
+
: feeData.maxFeePerGas;
|
|
57739
|
+
const maxPriorityFeePerGas = defaultEthConnectionConfig.maxPriorityFeePerGas
|
|
57740
|
+
? BigInt(defaultEthConnectionConfig.maxPriorityFeePerGas)
|
|
57741
|
+
: feeData.maxPriorityFeePerGas;
|
|
57742
|
+
const gasLimit = await contract.transitState.estimateGas(...payload);
|
|
57743
|
+
const txData = await contract.transitState.populateTransaction(...payload);
|
|
57744
|
+
const request = {
|
|
57745
|
+
to: txData.to,
|
|
57746
|
+
data: txData.data,
|
|
57747
|
+
gasLimit,
|
|
57748
|
+
maxFeePerGas,
|
|
57749
|
+
maxPriorityFeePerGas
|
|
57750
|
+
};
|
|
57751
|
+
const tx = await signer.sendTransaction(request);
|
|
57737
57752
|
const txnReceipt = await tx.wait();
|
|
57738
57753
|
if (!txnReceipt) {
|
|
57739
57754
|
throw new Error(`transaction: ${tx.hash} failed to mined`);
|
|
@@ -58213,7 +58228,23 @@ var PolygonIdSdk = (function (exports) {
|
|
|
58213
58228
|
],
|
|
58214
58229
|
zkProof.proof.pi_c.slice(0, 2)
|
|
58215
58230
|
];
|
|
58216
|
-
const
|
|
58231
|
+
const feeData = await provider.getFeeData();
|
|
58232
|
+
const maxFeePerGas = chainConfig.maxFeePerGas
|
|
58233
|
+
? BigInt(chainConfig.maxFeePerGas)
|
|
58234
|
+
: feeData.maxFeePerGas;
|
|
58235
|
+
const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
|
|
58236
|
+
? BigInt(chainConfig.maxPriorityFeePerGas)
|
|
58237
|
+
: feeData.maxPriorityFeePerGas;
|
|
58238
|
+
const gasLimit = await contract.submitZKPResponse.estimateGas(...payload);
|
|
58239
|
+
const txData = await contract.submitZKPResponse.populateTransaction(...payload);
|
|
58240
|
+
const request = {
|
|
58241
|
+
to: txData.to,
|
|
58242
|
+
data: txData.data,
|
|
58243
|
+
gasLimit,
|
|
58244
|
+
maxFeePerGas,
|
|
58245
|
+
maxPriorityFeePerGas
|
|
58246
|
+
};
|
|
58247
|
+
const tx = await ethSigner.sendTransaction(request);
|
|
58217
58248
|
const txnReceipt = await tx.wait();
|
|
58218
58249
|
if (!txnReceipt) {
|
|
58219
58250
|
throw new Error(`transaction: ${tx.hash} failed to mined`);
|
|
@@ -58356,6 +58387,45 @@ var PolygonIdSdk = (function (exports) {
|
|
|
58356
58387
|
}
|
|
58357
58388
|
}
|
|
58358
58389
|
|
|
58390
|
+
/**
|
|
58391
|
+
* IssuerResolver is a class that allows to interact with the issuer's http endpoint to get revocation status.
|
|
58392
|
+
*
|
|
58393
|
+
* @public
|
|
58394
|
+
* @class IssuerResolver
|
|
58395
|
+
*/
|
|
58396
|
+
class IssuerResolver {
|
|
58397
|
+
/**
|
|
58398
|
+
* resolve is a method to resolve a credential status directly from the issuer.
|
|
58399
|
+
*
|
|
58400
|
+
* @public
|
|
58401
|
+
* @param {CredentialStatus} credentialStatus - credential status to resolve
|
|
58402
|
+
* @param {CredentialStatusResolveOptions} credentialStatusResolveOptions - options for resolver
|
|
58403
|
+
* @returns `{Promise<RevocationStatus>}`
|
|
58404
|
+
*/
|
|
58405
|
+
async resolve(credentialStatus) {
|
|
58406
|
+
const revStatusResp = await fetch(credentialStatus.id);
|
|
58407
|
+
const revStatus = await revStatusResp.json();
|
|
58408
|
+
return toRevocationStatus(revStatus);
|
|
58409
|
+
}
|
|
58410
|
+
}
|
|
58411
|
+
/**
|
|
58412
|
+
* toRevocationStatus is a result of fetching credential status with type SparseMerkleTreeProof converts to RevocationStatus
|
|
58413
|
+
*
|
|
58414
|
+
* @param {RevocationStatusResponse} { issuer, mtp }
|
|
58415
|
+
* @returns {RevocationStatus} RevocationStatus
|
|
58416
|
+
*/
|
|
58417
|
+
const toRevocationStatus = ({ issuer, mtp }) => {
|
|
58418
|
+
const p = Kt$1.fromJSON({
|
|
58419
|
+
nodeAux: mtp.node_aux,
|
|
58420
|
+
existence: mtp.existence,
|
|
58421
|
+
siblings: mtp.siblings
|
|
58422
|
+
});
|
|
58423
|
+
return {
|
|
58424
|
+
mtp: p,
|
|
58425
|
+
issuer
|
|
58426
|
+
};
|
|
58427
|
+
};
|
|
58428
|
+
|
|
58359
58429
|
/**
|
|
58360
58430
|
* ProofNode is a partial Reverse Hash Service result
|
|
58361
58431
|
* it contains the current node hash and its children
|
|
@@ -58449,13 +58519,13 @@ var PolygonIdSdk = (function (exports) {
|
|
|
58449
58519
|
catch (e) {
|
|
58450
58520
|
if (credentialStatus?.statusIssuer?.type === exports.CredentialStatusType.SparseMerkleTreeProof) {
|
|
58451
58521
|
try {
|
|
58452
|
-
return await
|
|
58522
|
+
return await new IssuerResolver().resolve(credentialStatus.statusIssuer);
|
|
58453
58523
|
}
|
|
58454
58524
|
catch (e) {
|
|
58455
|
-
throw new Error(`can't fetch revocation status from backup endpoint`);
|
|
58525
|
+
throw new Error(`can't fetch revocation status from backup endpoint: ${e?.message}`);
|
|
58456
58526
|
}
|
|
58457
58527
|
}
|
|
58458
|
-
throw new Error(`can't fetch revocation status`);
|
|
58528
|
+
throw new Error(`can't fetch revocation status: ${e?.message}`);
|
|
58459
58529
|
}
|
|
58460
58530
|
}
|
|
58461
58531
|
/**
|
|
@@ -58638,45 +58708,6 @@ var PolygonIdSdk = (function (exports) {
|
|
|
58638
58708
|
return id.toString() === idFromState.bigInt().toString();
|
|
58639
58709
|
}
|
|
58640
58710
|
|
|
58641
|
-
/**
|
|
58642
|
-
* IssuerResolver is a class that allows to interact with the issuer's http endpoint to get revocation status.
|
|
58643
|
-
*
|
|
58644
|
-
* @public
|
|
58645
|
-
* @class IssuerResolver
|
|
58646
|
-
*/
|
|
58647
|
-
class IssuerResolver {
|
|
58648
|
-
/**
|
|
58649
|
-
* resolve is a method to resolve a credential status directly from the issuer.
|
|
58650
|
-
*
|
|
58651
|
-
* @public
|
|
58652
|
-
* @param {CredentialStatus} credentialStatus - credential status to resolve
|
|
58653
|
-
* @param {CredentialStatusResolveOptions} credentialStatusResolveOptions - options for resolver
|
|
58654
|
-
* @returns `{Promise<RevocationStatus>}`
|
|
58655
|
-
*/
|
|
58656
|
-
async resolve(credentialStatus) {
|
|
58657
|
-
const revStatusResp = await fetch(credentialStatus.id);
|
|
58658
|
-
const revStatus = await revStatusResp.json();
|
|
58659
|
-
return toRevocationStatus(revStatus);
|
|
58660
|
-
}
|
|
58661
|
-
}
|
|
58662
|
-
/**
|
|
58663
|
-
* toRevocationStatus is a result of fetching credential status with type SparseMerkleTreeProof converts to RevocationStatus
|
|
58664
|
-
*
|
|
58665
|
-
* @param {RevocationStatusResponse} { issuer, mtp }
|
|
58666
|
-
* @returns {RevocationStatus} RevocationStatus
|
|
58667
|
-
*/
|
|
58668
|
-
const toRevocationStatus = ({ issuer, mtp }) => {
|
|
58669
|
-
const p = Kt$1.fromJSON({
|
|
58670
|
-
nodeAux: mtp.node_aux,
|
|
58671
|
-
existence: mtp.existence,
|
|
58672
|
-
siblings: mtp.siblings
|
|
58673
|
-
});
|
|
58674
|
-
return {
|
|
58675
|
-
mtp: p,
|
|
58676
|
-
issuer
|
|
58677
|
-
};
|
|
58678
|
-
};
|
|
58679
|
-
|
|
58680
58711
|
/**
|
|
58681
58712
|
* CredentialStatusResolverRegistry is a registry of CredentialStatusResolver
|
|
58682
58713
|
*
|
|
@@ -81590,7 +81621,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
81590
81621
|
this._identityWallet = _identityWallet;
|
|
81591
81622
|
this._credentialWallet = _credentialWallet;
|
|
81592
81623
|
this._stateStorage = _stateStorage;
|
|
81593
|
-
this._prover = new NativeProver(_circuitStorage);
|
|
81624
|
+
this._prover = opts?.prover ?? new NativeProver(_circuitStorage);
|
|
81594
81625
|
this._ldOptions = { ...opts, documentLoader: opts?.documentLoader ?? cacheLoader(opts) };
|
|
81595
81626
|
}
|
|
81596
81627
|
/** {@inheritdoc IProofService.verifyProof} */
|