@0xpolygonid/js-sdk 1.4.0 → 1.4.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.
@@ -31,7 +31,7 @@ class ProofService {
31
31
  this._identityWallet = _identityWallet;
32
32
  this._credentialWallet = _credentialWallet;
33
33
  this._stateStorage = _stateStorage;
34
- this._prover = new prover_1.NativeProver(_circuitStorage);
34
+ this._prover = opts?.prover ?? new prover_1.NativeProver(_circuitStorage);
35
35
  this._ldOptions = { ...opts, documentLoader: opts?.documentLoader ?? (0, schema_processor_1.cacheLoader)(opts) };
36
36
  }
37
37
  /** {@inheritdoc IProofService.verifyProof} */
@@ -63,7 +63,23 @@ class OnChainZKPVerifier {
63
63
  ],
64
64
  zkProof.proof.pi_c.slice(0, 2)
65
65
  ];
66
- const tx = await contract.submitZKPResponse(...payload);
66
+ const feeData = await provider.getFeeData();
67
+ const maxFeePerGas = chainConfig.maxFeePerGas
68
+ ? BigInt(chainConfig.maxFeePerGas)
69
+ : feeData.maxFeePerGas;
70
+ const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
71
+ ? BigInt(chainConfig.maxPriorityFeePerGas)
72
+ : feeData.maxPriorityFeePerGas;
73
+ const gasLimit = await contract.submitZKPResponse.estimateGas(...payload);
74
+ const txData = await contract.submitZKPResponse.populateTransaction(...payload);
75
+ const request = {
76
+ to: txData.to,
77
+ data: txData.data,
78
+ gasLimit,
79
+ maxFeePerGas,
80
+ maxPriorityFeePerGas
81
+ };
82
+ const tx = await ethSigner.sendTransaction(request);
67
83
  const txnReceipt = await tx.wait();
68
84
  if (!txnReceipt) {
69
85
  throw new Error(`transaction: ${tx.hash} failed to mined`);
@@ -70,8 +70,23 @@ class EthStateStorage {
70
70
  ],
71
71
  proof.proof.pi_c.slice(0, 2)
72
72
  ];
73
- await contract.transitState.estimateGas(...payload);
74
- const tx = await contract.transitState(...payload);
73
+ const feeData = await this.provider.getFeeData();
74
+ const maxFeePerGas = exports.defaultEthConnectionConfig.maxFeePerGas
75
+ ? BigInt(exports.defaultEthConnectionConfig.maxFeePerGas)
76
+ : feeData.maxFeePerGas;
77
+ const maxPriorityFeePerGas = exports.defaultEthConnectionConfig.maxPriorityFeePerGas
78
+ ? BigInt(exports.defaultEthConnectionConfig.maxPriorityFeePerGas)
79
+ : feeData.maxPriorityFeePerGas;
80
+ const gasLimit = await contract.transitState.estimateGas(...payload);
81
+ const txData = await contract.transitState.populateTransaction(...payload);
82
+ const request = {
83
+ to: txData.to,
84
+ data: txData.data,
85
+ gasLimit,
86
+ maxFeePerGas,
87
+ maxPriorityFeePerGas
88
+ };
89
+ const tx = await signer.sendTransaction(request);
75
90
  const txnReceipt = await tx.wait();
76
91
  if (!txnReceipt) {
77
92
  throw new Error(`transaction: ${tx.hash} failed to mined`);
@@ -28,7 +28,7 @@ export class ProofService {
28
28
  this._identityWallet = _identityWallet;
29
29
  this._credentialWallet = _credentialWallet;
30
30
  this._stateStorage = _stateStorage;
31
- this._prover = new NativeProver(_circuitStorage);
31
+ this._prover = opts?.prover ?? new NativeProver(_circuitStorage);
32
32
  this._ldOptions = { ...opts, documentLoader: opts?.documentLoader ?? cacheLoader(opts) };
33
33
  }
34
34
  /** {@inheritdoc IProofService.verifyProof} */
@@ -57,7 +57,23 @@ export class OnChainZKPVerifier {
57
57
  ],
58
58
  zkProof.proof.pi_c.slice(0, 2)
59
59
  ];
60
- const tx = await contract.submitZKPResponse(...payload);
60
+ const feeData = await provider.getFeeData();
61
+ const maxFeePerGas = chainConfig.maxFeePerGas
62
+ ? BigInt(chainConfig.maxFeePerGas)
63
+ : feeData.maxFeePerGas;
64
+ const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
65
+ ? BigInt(chainConfig.maxPriorityFeePerGas)
66
+ : feeData.maxPriorityFeePerGas;
67
+ const gasLimit = await contract.submitZKPResponse.estimateGas(...payload);
68
+ const txData = await contract.submitZKPResponse.populateTransaction(...payload);
69
+ const request = {
70
+ to: txData.to,
71
+ data: txData.data,
72
+ gasLimit,
73
+ maxFeePerGas,
74
+ maxPriorityFeePerGas
75
+ };
76
+ const tx = await ethSigner.sendTransaction(request);
61
77
  const txnReceipt = await tx.wait();
62
78
  if (!txnReceipt) {
63
79
  throw new Error(`transaction: ${tx.hash} failed to mined`);
@@ -64,8 +64,23 @@ export class EthStateStorage {
64
64
  ],
65
65
  proof.proof.pi_c.slice(0, 2)
66
66
  ];
67
- await contract.transitState.estimateGas(...payload);
68
- const tx = await contract.transitState(...payload);
67
+ const feeData = await this.provider.getFeeData();
68
+ const maxFeePerGas = defaultEthConnectionConfig.maxFeePerGas
69
+ ? BigInt(defaultEthConnectionConfig.maxFeePerGas)
70
+ : feeData.maxFeePerGas;
71
+ const maxPriorityFeePerGas = defaultEthConnectionConfig.maxPriorityFeePerGas
72
+ ? BigInt(defaultEthConnectionConfig.maxPriorityFeePerGas)
73
+ : feeData.maxPriorityFeePerGas;
74
+ const gasLimit = await contract.transitState.estimateGas(...payload);
75
+ const txData = await contract.transitState.populateTransaction(...payload);
76
+ const request = {
77
+ to: txData.to,
78
+ data: txData.data,
79
+ gasLimit,
80
+ maxFeePerGas,
81
+ maxPriorityFeePerGas
82
+ };
83
+ const tx = await signer.sendTransaction(request);
69
84
  const txnReceipt = await tx.wait();
70
85
  if (!txnReceipt) {
71
86
  throw new Error(`transaction: ${tx.hash} failed to mined`);
@@ -4,6 +4,7 @@ import { CircuitId, Query, TreeState } from '../circuits';
4
4
  import { ICredentialWallet } from '../credentials';
5
5
  import { IIdentityWallet } from '../identity';
6
6
  import { W3CCredential } from '../verifiable';
7
+ import { IZKProver } from './prover';
7
8
  import { Options } from '@iden3/js-jsonld-merklization';
8
9
  import { ZKProof } from '@iden3/js-jwz';
9
10
  import { Signer } from 'ethers';
@@ -24,6 +25,12 @@ export interface DIDProfileMetadata {
24
25
  authProfileNonce: number;
25
26
  credentialSubjectProfileNonce: number;
26
27
  }
28
+ /**
29
+ * List of options to customize ProofService
30
+ */
31
+ export type ProofServiceOptions = Options & {
32
+ prover?: IZKProver;
33
+ };
27
34
  export interface IProofService {
28
35
  /**
29
36
  * Verification of zkp proof for given circuit id
@@ -97,7 +104,7 @@ export declare class ProofService implements IProofService {
97
104
  * @param {ICircuitStorage} _circuitStorage - circuit storage to load proving / verification files
98
105
  * @param {IStateStorage} _stateStorage - state storage to get GIST proof / publish state
99
106
  */
100
- constructor(_identityWallet: IIdentityWallet, _credentialWallet: ICredentialWallet, _circuitStorage: ICircuitStorage, _stateStorage: IStateStorage, opts?: Options);
107
+ constructor(_identityWallet: IIdentityWallet, _credentialWallet: ICredentialWallet, _circuitStorage: ICircuitStorage, _stateStorage: IStateStorage, opts?: ProofServiceOptions);
101
108
  /** {@inheritdoc IProofService.verifyProof} */
102
109
  verifyProof(zkp: ZKProof, circuitId: CircuitId): Promise<boolean>;
103
110
  /** {@inheritdoc IProofService.generateProof} */
@@ -14,6 +14,8 @@ export interface EthConnectionConfig {
14
14
  defaultGasLimit: number;
15
15
  minGasPrice?: string;
16
16
  maxGasPrice?: string;
17
+ maxFeePerGas?: string;
18
+ maxPriorityFeePerGas?: string;
17
19
  confirmationBlockCount: number;
18
20
  confirmationTimeout: number;
19
21
  contractAddress: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xpolygonid/js-sdk",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "SDK to work with Polygon ID",
5
5
  "main": "dist/node/cjs/index.js",
6
6
  "module": "dist/node/esm/index.js",