@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
|
@@ -57601,8 +57601,23 @@ class EthStateStorage {
|
|
|
57601
57601
|
],
|
|
57602
57602
|
proof.proof.pi_c.slice(0, 2)
|
|
57603
57603
|
];
|
|
57604
|
-
await
|
|
57605
|
-
const
|
|
57604
|
+
const feeData = await this.provider.getFeeData();
|
|
57605
|
+
const maxFeePerGas = defaultEthConnectionConfig.maxFeePerGas
|
|
57606
|
+
? BigInt(defaultEthConnectionConfig.maxFeePerGas)
|
|
57607
|
+
: feeData.maxFeePerGas;
|
|
57608
|
+
const maxPriorityFeePerGas = defaultEthConnectionConfig.maxPriorityFeePerGas
|
|
57609
|
+
? BigInt(defaultEthConnectionConfig.maxPriorityFeePerGas)
|
|
57610
|
+
: feeData.maxPriorityFeePerGas;
|
|
57611
|
+
const gasLimit = await contract.transitState.estimateGas(...payload);
|
|
57612
|
+
const txData = await contract.transitState.populateTransaction(...payload);
|
|
57613
|
+
const request = {
|
|
57614
|
+
to: txData.to,
|
|
57615
|
+
data: txData.data,
|
|
57616
|
+
gasLimit,
|
|
57617
|
+
maxFeePerGas,
|
|
57618
|
+
maxPriorityFeePerGas
|
|
57619
|
+
};
|
|
57620
|
+
const tx = await signer.sendTransaction(request);
|
|
57606
57621
|
const txnReceipt = await tx.wait();
|
|
57607
57622
|
if (!txnReceipt) {
|
|
57608
57623
|
throw new Error(`transaction: ${tx.hash} failed to mined`);
|
|
@@ -58082,7 +58097,23 @@ class OnChainZKPVerifier {
|
|
|
58082
58097
|
],
|
|
58083
58098
|
zkProof.proof.pi_c.slice(0, 2)
|
|
58084
58099
|
];
|
|
58085
|
-
const
|
|
58100
|
+
const feeData = await provider.getFeeData();
|
|
58101
|
+
const maxFeePerGas = chainConfig.maxFeePerGas
|
|
58102
|
+
? BigInt(chainConfig.maxFeePerGas)
|
|
58103
|
+
: feeData.maxFeePerGas;
|
|
58104
|
+
const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
|
|
58105
|
+
? BigInt(chainConfig.maxPriorityFeePerGas)
|
|
58106
|
+
: feeData.maxPriorityFeePerGas;
|
|
58107
|
+
const gasLimit = await contract.submitZKPResponse.estimateGas(...payload);
|
|
58108
|
+
const txData = await contract.submitZKPResponse.populateTransaction(...payload);
|
|
58109
|
+
const request = {
|
|
58110
|
+
to: txData.to,
|
|
58111
|
+
data: txData.data,
|
|
58112
|
+
gasLimit,
|
|
58113
|
+
maxFeePerGas,
|
|
58114
|
+
maxPriorityFeePerGas
|
|
58115
|
+
};
|
|
58116
|
+
const tx = await ethSigner.sendTransaction(request);
|
|
58086
58117
|
const txnReceipt = await tx.wait();
|
|
58087
58118
|
if (!txnReceipt) {
|
|
58088
58119
|
throw new Error(`transaction: ${tx.hash} failed to mined`);
|
|
@@ -58225,6 +58256,45 @@ class OnChainResolver {
|
|
|
58225
58256
|
}
|
|
58226
58257
|
}
|
|
58227
58258
|
|
|
58259
|
+
/**
|
|
58260
|
+
* IssuerResolver is a class that allows to interact with the issuer's http endpoint to get revocation status.
|
|
58261
|
+
*
|
|
58262
|
+
* @public
|
|
58263
|
+
* @class IssuerResolver
|
|
58264
|
+
*/
|
|
58265
|
+
class IssuerResolver {
|
|
58266
|
+
/**
|
|
58267
|
+
* resolve is a method to resolve a credential status directly from the issuer.
|
|
58268
|
+
*
|
|
58269
|
+
* @public
|
|
58270
|
+
* @param {CredentialStatus} credentialStatus - credential status to resolve
|
|
58271
|
+
* @param {CredentialStatusResolveOptions} credentialStatusResolveOptions - options for resolver
|
|
58272
|
+
* @returns `{Promise<RevocationStatus>}`
|
|
58273
|
+
*/
|
|
58274
|
+
async resolve(credentialStatus) {
|
|
58275
|
+
const revStatusResp = await fetch(credentialStatus.id);
|
|
58276
|
+
const revStatus = await revStatusResp.json();
|
|
58277
|
+
return toRevocationStatus(revStatus);
|
|
58278
|
+
}
|
|
58279
|
+
}
|
|
58280
|
+
/**
|
|
58281
|
+
* toRevocationStatus is a result of fetching credential status with type SparseMerkleTreeProof converts to RevocationStatus
|
|
58282
|
+
*
|
|
58283
|
+
* @param {RevocationStatusResponse} { issuer, mtp }
|
|
58284
|
+
* @returns {RevocationStatus} RevocationStatus
|
|
58285
|
+
*/
|
|
58286
|
+
const toRevocationStatus = ({ issuer, mtp }) => {
|
|
58287
|
+
const p = Proof.fromJSON({
|
|
58288
|
+
nodeAux: mtp.node_aux,
|
|
58289
|
+
existence: mtp.existence,
|
|
58290
|
+
siblings: mtp.siblings
|
|
58291
|
+
});
|
|
58292
|
+
return {
|
|
58293
|
+
mtp: p,
|
|
58294
|
+
issuer
|
|
58295
|
+
};
|
|
58296
|
+
};
|
|
58297
|
+
|
|
58228
58298
|
/**
|
|
58229
58299
|
* ProofNode is a partial Reverse Hash Service result
|
|
58230
58300
|
* it contains the current node hash and its children
|
|
@@ -58318,13 +58388,13 @@ class RHSResolver {
|
|
|
58318
58388
|
catch (e) {
|
|
58319
58389
|
if (credentialStatus?.statusIssuer?.type === CredentialStatusType.SparseMerkleTreeProof) {
|
|
58320
58390
|
try {
|
|
58321
|
-
return await
|
|
58391
|
+
return await new IssuerResolver().resolve(credentialStatus.statusIssuer);
|
|
58322
58392
|
}
|
|
58323
58393
|
catch (e) {
|
|
58324
|
-
throw new Error(`can't fetch revocation status from backup endpoint`);
|
|
58394
|
+
throw new Error(`can't fetch revocation status from backup endpoint: ${e?.message}`);
|
|
58325
58395
|
}
|
|
58326
58396
|
}
|
|
58327
|
-
throw new Error(`can't fetch revocation status`);
|
|
58397
|
+
throw new Error(`can't fetch revocation status: ${e?.message}`);
|
|
58328
58398
|
}
|
|
58329
58399
|
}
|
|
58330
58400
|
/**
|
|
@@ -58507,45 +58577,6 @@ function isGenesisStateId(id, state, type) {
|
|
|
58507
58577
|
return id.toString() === idFromState.bigInt().toString();
|
|
58508
58578
|
}
|
|
58509
58579
|
|
|
58510
|
-
/**
|
|
58511
|
-
* IssuerResolver is a class that allows to interact with the issuer's http endpoint to get revocation status.
|
|
58512
|
-
*
|
|
58513
|
-
* @public
|
|
58514
|
-
* @class IssuerResolver
|
|
58515
|
-
*/
|
|
58516
|
-
class IssuerResolver {
|
|
58517
|
-
/**
|
|
58518
|
-
* resolve is a method to resolve a credential status directly from the issuer.
|
|
58519
|
-
*
|
|
58520
|
-
* @public
|
|
58521
|
-
* @param {CredentialStatus} credentialStatus - credential status to resolve
|
|
58522
|
-
* @param {CredentialStatusResolveOptions} credentialStatusResolveOptions - options for resolver
|
|
58523
|
-
* @returns `{Promise<RevocationStatus>}`
|
|
58524
|
-
*/
|
|
58525
|
-
async resolve(credentialStatus) {
|
|
58526
|
-
const revStatusResp = await fetch(credentialStatus.id);
|
|
58527
|
-
const revStatus = await revStatusResp.json();
|
|
58528
|
-
return toRevocationStatus(revStatus);
|
|
58529
|
-
}
|
|
58530
|
-
}
|
|
58531
|
-
/**
|
|
58532
|
-
* toRevocationStatus is a result of fetching credential status with type SparseMerkleTreeProof converts to RevocationStatus
|
|
58533
|
-
*
|
|
58534
|
-
* @param {RevocationStatusResponse} { issuer, mtp }
|
|
58535
|
-
* @returns {RevocationStatus} RevocationStatus
|
|
58536
|
-
*/
|
|
58537
|
-
const toRevocationStatus = ({ issuer, mtp }) => {
|
|
58538
|
-
const p = Proof.fromJSON({
|
|
58539
|
-
nodeAux: mtp.node_aux,
|
|
58540
|
-
existence: mtp.existence,
|
|
58541
|
-
siblings: mtp.siblings
|
|
58542
|
-
});
|
|
58543
|
-
return {
|
|
58544
|
-
mtp: p,
|
|
58545
|
-
issuer
|
|
58546
|
-
};
|
|
58547
|
-
};
|
|
58548
|
-
|
|
58549
58580
|
/**
|
|
58550
58581
|
* CredentialStatusResolverRegistry is a registry of CredentialStatusResolver
|
|
58551
58582
|
*
|
|
@@ -60699,7 +60730,7 @@ class ProofService {
|
|
|
60699
60730
|
this._identityWallet = _identityWallet;
|
|
60700
60731
|
this._credentialWallet = _credentialWallet;
|
|
60701
60732
|
this._stateStorage = _stateStorage;
|
|
60702
|
-
this._prover = new NativeProver(_circuitStorage);
|
|
60733
|
+
this._prover = opts?.prover ?? new NativeProver(_circuitStorage);
|
|
60703
60734
|
this._ldOptions = { ...opts, documentLoader: opts?.documentLoader ?? cacheLoader(opts) };
|
|
60704
60735
|
}
|
|
60705
60736
|
/** {@inheritdoc IProofService.verifyProof} */
|