@0xpolygonid/js-sdk 1.4.2 → 1.5.0

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.
@@ -1,4 +1,4 @@
1
- import { BytesHelper, checkBigIntInField, Claim, DID, IdPosition, MerklizedRootPosition as MerklizedRootPosition$1, Id, SchemaHash, ClaimOptions, buildDIDType, DidMethod, Blockchain, NetworkId, getUnixTimestamp } from '@iden3/js-iden3-core';
1
+ import { BytesHelper, checkBigIntInField, Claim, DID, IdPosition, MerklizedRootPosition as MerklizedRootPosition$1, Id, SchemaHash, ClaimOptions, buildDIDType, getChainId, DidMethod, Blockchain, NetworkId, getUnixTimestamp } from '@iden3/js-iden3-core';
2
2
  import * as jsIden3Core from '@iden3/js-iden3-core';
3
3
  export { jsIden3Core as core };
4
4
  import { Merklizer, Path, getDocumentLoader } from '@iden3/js-jsonld-merklization';
@@ -57657,478 +57657,6 @@ class EthStateStorage {
57657
57657
  }
57658
57658
  }
57659
57659
 
57660
- /**
57661
- * Object containing chain IDs for various blockchains and networks.
57662
- * @type { [key: string]: number }
57663
- */
57664
- const CHAIN_IDS = {
57665
- eth: 1,
57666
- 'eth:main': 1,
57667
- 'eth:goerli': 5,
57668
- 'eth:sepolia': 11155111,
57669
- polygon: 137,
57670
- 'polygon:main': 137,
57671
- 'polygon:mumbai': 80001,
57672
- zkevm: 1101,
57673
- 'zkevm:main': 1101,
57674
- 'zkevm:test': 1442
57675
- };
57676
- /**
57677
- * Object containing default networks for DIDs.
57678
- * @type { [key: string]: number }
57679
- */
57680
- const DEFAULT_NETWORKS = {
57681
- ethr: 1,
57682
- polygonid: 137
57683
- };
57684
- /**
57685
- * Registers a new chain ID for a blockchain and network combination.
57686
- * @param {string} blockchain - The blockchain name.
57687
- * @param {number} chainId - The chain ID to be registered.
57688
- * @param {string} network - The network name.
57689
- * @beta This API will change in the future.
57690
- * @example
57691
- * registerChainId('eth', 3, 'ropsten');
57692
- */
57693
- const registerChainId = (blockchain, chainId, network) => {
57694
- if (network) {
57695
- blockchain += `:${network}`;
57696
- }
57697
- CHAIN_IDS[blockchain] = chainId;
57698
- };
57699
- /**
57700
- * Gets the chain ID for a given blockchain and network combination.
57701
- * If the chain ID is not found, 0 will be returned.
57702
- * @param {string} blockchain - The blockchain name.
57703
- * @param {string} network - The network name.
57704
- * @returns {number} The chain ID for the specified blockchain and network.
57705
- * @throws {Error} Throws an error if the chainId not found.
57706
- * @beta This API will change in the future.
57707
- * @example
57708
- * const chainId = getChainId('ethr', eth', 'main');
57709
- * // chainId will be 1
57710
- */
57711
- const getChainId = (blockchain, network) => {
57712
- if (network) {
57713
- blockchain += `:${network}`;
57714
- }
57715
- const chainId = CHAIN_IDS[blockchain];
57716
- if (!chainId) {
57717
- throw new Error(`chainId not found for ${blockchain}`);
57718
- }
57719
- return chainId;
57720
- };
57721
- /**
57722
- * Registers a default chain ID for methodId.
57723
- * @param {string} blockchain - The blockchain name.
57724
- * @param {number} chainId - The chain ID to be registered.
57725
- * @param {string} network - The network name.
57726
- * @beta This API will change in the future.
57727
- * @example
57728
- * registerChainId('polygonid', 137);
57729
- */
57730
- const registerDefaultNetworkForMethodId = (methodId, chainId) => {
57731
- DEFAULT_NETWORKS[methodId] = chainId;
57732
- };
57733
- /**
57734
- * Gets the chain ID for a given methodId.
57735
- * If the chain ID is not found, 0 will be returned.
57736
- * @param {string} methodId - The blockchain name.
57737
- * @returns {number} The chain ID for the specified blockchain and network.
57738
- * @throws {Error} Throws an error if the chainId not found.
57739
- * @beta This API will change in the future.
57740
- * @example
57741
- * const chainId = getChainId('polygonid');
57742
- * // chainId will be 137
57743
- */
57744
- const getDefaultNetworkForMethodId = (methodId) => {
57745
- const chainId = DEFAULT_NETWORKS[methodId];
57746
- if (!chainId) {
57747
- throw new Error(`chainId not found for ${methodId}`);
57748
- }
57749
- return chainId;
57750
- };
57751
- /**
57752
- * Gets the chain ID for a given methodId, blockchain and network combination.
57753
- * @param {string} methodId - The blockchain name.
57754
- * @param {string} blockchain - The blockchain name.
57755
- * @param {string} network - The network name.
57756
- * @returns {number} The chain ID for the specified blockchain and network.
57757
- * @beta This API will change in the future.
57758
- */
57759
- const getChainIdByDIDsParts = (methodId, blockchain, network) => {
57760
- if (!blockchain) {
57761
- return getDefaultNetworkForMethodId(methodId);
57762
- }
57763
- return getChainId(blockchain, network);
57764
- };
57765
-
57766
- var abi = [
57767
- {
57768
- anonymous: false,
57769
- inputs: [
57770
- {
57771
- indexed: true,
57772
- internalType: "address",
57773
- name: "previousOwner",
57774
- type: "address"
57775
- },
57776
- {
57777
- indexed: true,
57778
- internalType: "address",
57779
- name: "newOwner",
57780
- type: "address"
57781
- }
57782
- ],
57783
- name: "OwnershipTransferred",
57784
- type: "event"
57785
- },
57786
- {
57787
- inputs: [
57788
- ],
57789
- name: "REQUESTS_RETURN_LIMIT",
57790
- outputs: [
57791
- {
57792
- internalType: "uint256",
57793
- name: "",
57794
- type: "uint256"
57795
- }
57796
- ],
57797
- stateMutability: "view",
57798
- type: "function"
57799
- },
57800
- {
57801
- inputs: [
57802
- {
57803
- internalType: "uint64",
57804
- name: "requestId",
57805
- type: "uint64"
57806
- }
57807
- ],
57808
- name: "getZKPRequest",
57809
- outputs: [
57810
- {
57811
- components: [
57812
- {
57813
- internalType: "string",
57814
- name: "metadata",
57815
- type: "string"
57816
- },
57817
- {
57818
- internalType: "contract ICircuitValidator",
57819
- name: "validator",
57820
- type: "address"
57821
- },
57822
- {
57823
- internalType: "bytes",
57824
- name: "data",
57825
- type: "bytes"
57826
- }
57827
- ],
57828
- internalType: "struct IZKPVerifier.ZKPRequest",
57829
- name: "",
57830
- type: "tuple"
57831
- }
57832
- ],
57833
- stateMutability: "view",
57834
- type: "function"
57835
- },
57836
- {
57837
- inputs: [
57838
- {
57839
- internalType: "uint256",
57840
- name: "startIndex",
57841
- type: "uint256"
57842
- },
57843
- {
57844
- internalType: "uint256",
57845
- name: "length",
57846
- type: "uint256"
57847
- }
57848
- ],
57849
- name: "getZKPRequests",
57850
- outputs: [
57851
- {
57852
- components: [
57853
- {
57854
- internalType: "string",
57855
- name: "metadata",
57856
- type: "string"
57857
- },
57858
- {
57859
- internalType: "contract ICircuitValidator",
57860
- name: "validator",
57861
- type: "address"
57862
- },
57863
- {
57864
- internalType: "bytes",
57865
- name: "data",
57866
- type: "bytes"
57867
- }
57868
- ],
57869
- internalType: "struct IZKPVerifier.ZKPRequest[]",
57870
- name: "",
57871
- type: "tuple[]"
57872
- }
57873
- ],
57874
- stateMutability: "view",
57875
- type: "function"
57876
- },
57877
- {
57878
- inputs: [
57879
- ],
57880
- name: "getZKPRequestsCount",
57881
- outputs: [
57882
- {
57883
- internalType: "uint256",
57884
- name: "",
57885
- type: "uint256"
57886
- }
57887
- ],
57888
- stateMutability: "view",
57889
- type: "function"
57890
- },
57891
- {
57892
- inputs: [
57893
- ],
57894
- name: "owner",
57895
- outputs: [
57896
- {
57897
- internalType: "address",
57898
- name: "",
57899
- type: "address"
57900
- }
57901
- ],
57902
- stateMutability: "view",
57903
- type: "function"
57904
- },
57905
- {
57906
- inputs: [
57907
- {
57908
- internalType: "address",
57909
- name: "",
57910
- type: "address"
57911
- },
57912
- {
57913
- internalType: "uint64",
57914
- name: "",
57915
- type: "uint64"
57916
- }
57917
- ],
57918
- name: "proofs",
57919
- outputs: [
57920
- {
57921
- internalType: "bool",
57922
- name: "",
57923
- type: "bool"
57924
- }
57925
- ],
57926
- stateMutability: "view",
57927
- type: "function"
57928
- },
57929
- {
57930
- inputs: [
57931
- ],
57932
- name: "renounceOwnership",
57933
- outputs: [
57934
- ],
57935
- stateMutability: "nonpayable",
57936
- type: "function"
57937
- },
57938
- {
57939
- inputs: [
57940
- {
57941
- internalType: "uint64",
57942
- name: "requestId",
57943
- type: "uint64"
57944
- }
57945
- ],
57946
- name: "requestIdExists",
57947
- outputs: [
57948
- {
57949
- internalType: "bool",
57950
- name: "",
57951
- type: "bool"
57952
- }
57953
- ],
57954
- stateMutability: "view",
57955
- type: "function"
57956
- },
57957
- {
57958
- inputs: [
57959
- {
57960
- internalType: "uint64",
57961
- name: "requestId",
57962
- type: "uint64"
57963
- },
57964
- {
57965
- components: [
57966
- {
57967
- internalType: "string",
57968
- name: "metadata",
57969
- type: "string"
57970
- },
57971
- {
57972
- internalType: "contract ICircuitValidator",
57973
- name: "validator",
57974
- type: "address"
57975
- },
57976
- {
57977
- internalType: "bytes",
57978
- name: "data",
57979
- type: "bytes"
57980
- }
57981
- ],
57982
- internalType: "struct IZKPVerifier.ZKPRequest",
57983
- name: "request",
57984
- type: "tuple"
57985
- }
57986
- ],
57987
- name: "setZKPRequest",
57988
- outputs: [
57989
- ],
57990
- stateMutability: "nonpayable",
57991
- type: "function"
57992
- },
57993
- {
57994
- inputs: [
57995
- {
57996
- internalType: "uint64",
57997
- name: "requestId",
57998
- type: "uint64"
57999
- },
58000
- {
58001
- internalType: "uint256[]",
58002
- name: "inputs",
58003
- type: "uint256[]"
58004
- },
58005
- {
58006
- internalType: "uint256[2]",
58007
- name: "a",
58008
- type: "uint256[2]"
58009
- },
58010
- {
58011
- internalType: "uint256[2][2]",
58012
- name: "b",
58013
- type: "uint256[2][2]"
58014
- },
58015
- {
58016
- internalType: "uint256[2]",
58017
- name: "c",
58018
- type: "uint256[2]"
58019
- }
58020
- ],
58021
- name: "submitZKPResponse",
58022
- outputs: [
58023
- ],
58024
- stateMutability: "nonpayable",
58025
- type: "function"
58026
- },
58027
- {
58028
- inputs: [
58029
- {
58030
- internalType: "address",
58031
- name: "newOwner",
58032
- type: "address"
58033
- }
58034
- ],
58035
- name: "transferOwnership",
58036
- outputs: [
58037
- ],
58038
- stateMutability: "nonpayable",
58039
- type: "function"
58040
- }
58041
- ];
58042
-
58043
- /**
58044
- * OnChainZKPVerifier is a class that allows to interact with the OnChainZKPVerifier contract
58045
- * and submitZKPResponse.
58046
- *
58047
- * @beta
58048
- * @class OnChainZKPVerifier
58049
- */
58050
- class OnChainZKPVerifier {
58051
- /**
58052
- *
58053
- * Creates an instance of OnChainZKPVerifier.
58054
- * @beta
58055
- * @param {EthConnectionConfig[]} - array of ETH configs
58056
- */
58057
- constructor(_configs) {
58058
- this._configs = _configs;
58059
- /**
58060
- * solidity identifier for function signature:
58061
- * function submitZKPResponse(uint64 requestId, uint256[] calldata inputs,
58062
- * uint256[2] calldata a, uint256[2][2] calldata b, uint256[2] calldata c) public
58063
- */
58064
- this._supportedMethodId = 'b68967e2';
58065
- }
58066
- /**
58067
- * Submit ZKP Responses to OnChainZKPVerifier contract.
58068
- * @beta
58069
- * @param {Signer} ethSigner - tx signer
58070
- * @param {txData} ContractInvokeTransactionData - transaction data
58071
- * @param {ZeroKnowledgeProofResponse[]} zkProofResponses - zkProofResponses
58072
- * @returns {Promise<Map<string, ZeroKnowledgeProofResponse>>} - map of transaction hash - ZeroKnowledgeProofResponse
58073
- */
58074
- async submitZKPResponse(ethSigner, txData, zkProofResponses) {
58075
- const chainConfig = this._configs.find((i) => i.chainId == txData.chain_id);
58076
- if (!chainConfig) {
58077
- throw new Error(`config for chain id ${txData.chain_id} was not found`);
58078
- }
58079
- if (txData.method_id.replace('0x', '') !== this._supportedMethodId) {
58080
- throw new Error(`submit doesn't implement requested method id. Only '0x${this._supportedMethodId}' is supported.`);
58081
- }
58082
- const provider = new JsonRpcProvider(chainConfig.url, chainConfig.chainId);
58083
- const verifierContract = new Contract(txData.contract_address, abi, provider);
58084
- ethSigner = ethSigner.connect(provider);
58085
- const contract = verifierContract.connect(ethSigner);
58086
- const response = new Map();
58087
- for (const zkProof of zkProofResponses) {
58088
- const requestID = zkProof.id;
58089
- const inputs = zkProof.pub_signals;
58090
- const payload = [
58091
- requestID,
58092
- inputs,
58093
- zkProof.proof.pi_a.slice(0, 2),
58094
- [
58095
- [zkProof.proof.pi_b[0][1], zkProof.proof.pi_b[0][0]],
58096
- [zkProof.proof.pi_b[1][1], zkProof.proof.pi_b[1][0]]
58097
- ],
58098
- zkProof.proof.pi_c.slice(0, 2)
58099
- ];
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);
58117
- const txnReceipt = await tx.wait();
58118
- if (!txnReceipt) {
58119
- throw new Error(`transaction: ${tx.hash} failed to mined`);
58120
- }
58121
- const status = txnReceipt.status;
58122
- const txnHash = txnReceipt.hash;
58123
- if (!status) {
58124
- throw new Error(`transaction: ${txnHash} failed to mined`);
58125
- }
58126
- response.set(txnHash, zkProof);
58127
- }
58128
- return response;
58129
- }
58130
- }
58131
-
58132
57660
  /**
58133
57661
  * OnChainIssuer is a class that allows to interact with the onchain contract
58134
57662
  * and build the revocation status.
@@ -59500,6 +59028,372 @@ class IdentityWallet {
59500
59028
  }
59501
59029
  }
59502
59030
 
59031
+ var abi = [
59032
+ {
59033
+ anonymous: false,
59034
+ inputs: [
59035
+ {
59036
+ indexed: true,
59037
+ internalType: "address",
59038
+ name: "previousOwner",
59039
+ type: "address"
59040
+ },
59041
+ {
59042
+ indexed: true,
59043
+ internalType: "address",
59044
+ name: "newOwner",
59045
+ type: "address"
59046
+ }
59047
+ ],
59048
+ name: "OwnershipTransferred",
59049
+ type: "event"
59050
+ },
59051
+ {
59052
+ inputs: [
59053
+ ],
59054
+ name: "REQUESTS_RETURN_LIMIT",
59055
+ outputs: [
59056
+ {
59057
+ internalType: "uint256",
59058
+ name: "",
59059
+ type: "uint256"
59060
+ }
59061
+ ],
59062
+ stateMutability: "view",
59063
+ type: "function"
59064
+ },
59065
+ {
59066
+ inputs: [
59067
+ {
59068
+ internalType: "uint64",
59069
+ name: "requestId",
59070
+ type: "uint64"
59071
+ }
59072
+ ],
59073
+ name: "getZKPRequest",
59074
+ outputs: [
59075
+ {
59076
+ components: [
59077
+ {
59078
+ internalType: "string",
59079
+ name: "metadata",
59080
+ type: "string"
59081
+ },
59082
+ {
59083
+ internalType: "contract ICircuitValidator",
59084
+ name: "validator",
59085
+ type: "address"
59086
+ },
59087
+ {
59088
+ internalType: "bytes",
59089
+ name: "data",
59090
+ type: "bytes"
59091
+ }
59092
+ ],
59093
+ internalType: "struct IZKPVerifier.ZKPRequest",
59094
+ name: "",
59095
+ type: "tuple"
59096
+ }
59097
+ ],
59098
+ stateMutability: "view",
59099
+ type: "function"
59100
+ },
59101
+ {
59102
+ inputs: [
59103
+ {
59104
+ internalType: "uint256",
59105
+ name: "startIndex",
59106
+ type: "uint256"
59107
+ },
59108
+ {
59109
+ internalType: "uint256",
59110
+ name: "length",
59111
+ type: "uint256"
59112
+ }
59113
+ ],
59114
+ name: "getZKPRequests",
59115
+ outputs: [
59116
+ {
59117
+ components: [
59118
+ {
59119
+ internalType: "string",
59120
+ name: "metadata",
59121
+ type: "string"
59122
+ },
59123
+ {
59124
+ internalType: "contract ICircuitValidator",
59125
+ name: "validator",
59126
+ type: "address"
59127
+ },
59128
+ {
59129
+ internalType: "bytes",
59130
+ name: "data",
59131
+ type: "bytes"
59132
+ }
59133
+ ],
59134
+ internalType: "struct IZKPVerifier.ZKPRequest[]",
59135
+ name: "",
59136
+ type: "tuple[]"
59137
+ }
59138
+ ],
59139
+ stateMutability: "view",
59140
+ type: "function"
59141
+ },
59142
+ {
59143
+ inputs: [
59144
+ ],
59145
+ name: "getZKPRequestsCount",
59146
+ outputs: [
59147
+ {
59148
+ internalType: "uint256",
59149
+ name: "",
59150
+ type: "uint256"
59151
+ }
59152
+ ],
59153
+ stateMutability: "view",
59154
+ type: "function"
59155
+ },
59156
+ {
59157
+ inputs: [
59158
+ ],
59159
+ name: "owner",
59160
+ outputs: [
59161
+ {
59162
+ internalType: "address",
59163
+ name: "",
59164
+ type: "address"
59165
+ }
59166
+ ],
59167
+ stateMutability: "view",
59168
+ type: "function"
59169
+ },
59170
+ {
59171
+ inputs: [
59172
+ {
59173
+ internalType: "address",
59174
+ name: "",
59175
+ type: "address"
59176
+ },
59177
+ {
59178
+ internalType: "uint64",
59179
+ name: "",
59180
+ type: "uint64"
59181
+ }
59182
+ ],
59183
+ name: "proofs",
59184
+ outputs: [
59185
+ {
59186
+ internalType: "bool",
59187
+ name: "",
59188
+ type: "bool"
59189
+ }
59190
+ ],
59191
+ stateMutability: "view",
59192
+ type: "function"
59193
+ },
59194
+ {
59195
+ inputs: [
59196
+ ],
59197
+ name: "renounceOwnership",
59198
+ outputs: [
59199
+ ],
59200
+ stateMutability: "nonpayable",
59201
+ type: "function"
59202
+ },
59203
+ {
59204
+ inputs: [
59205
+ {
59206
+ internalType: "uint64",
59207
+ name: "requestId",
59208
+ type: "uint64"
59209
+ }
59210
+ ],
59211
+ name: "requestIdExists",
59212
+ outputs: [
59213
+ {
59214
+ internalType: "bool",
59215
+ name: "",
59216
+ type: "bool"
59217
+ }
59218
+ ],
59219
+ stateMutability: "view",
59220
+ type: "function"
59221
+ },
59222
+ {
59223
+ inputs: [
59224
+ {
59225
+ internalType: "uint64",
59226
+ name: "requestId",
59227
+ type: "uint64"
59228
+ },
59229
+ {
59230
+ components: [
59231
+ {
59232
+ internalType: "string",
59233
+ name: "metadata",
59234
+ type: "string"
59235
+ },
59236
+ {
59237
+ internalType: "contract ICircuitValidator",
59238
+ name: "validator",
59239
+ type: "address"
59240
+ },
59241
+ {
59242
+ internalType: "bytes",
59243
+ name: "data",
59244
+ type: "bytes"
59245
+ }
59246
+ ],
59247
+ internalType: "struct IZKPVerifier.ZKPRequest",
59248
+ name: "request",
59249
+ type: "tuple"
59250
+ }
59251
+ ],
59252
+ name: "setZKPRequest",
59253
+ outputs: [
59254
+ ],
59255
+ stateMutability: "nonpayable",
59256
+ type: "function"
59257
+ },
59258
+ {
59259
+ inputs: [
59260
+ {
59261
+ internalType: "uint64",
59262
+ name: "requestId",
59263
+ type: "uint64"
59264
+ },
59265
+ {
59266
+ internalType: "uint256[]",
59267
+ name: "inputs",
59268
+ type: "uint256[]"
59269
+ },
59270
+ {
59271
+ internalType: "uint256[2]",
59272
+ name: "a",
59273
+ type: "uint256[2]"
59274
+ },
59275
+ {
59276
+ internalType: "uint256[2][2]",
59277
+ name: "b",
59278
+ type: "uint256[2][2]"
59279
+ },
59280
+ {
59281
+ internalType: "uint256[2]",
59282
+ name: "c",
59283
+ type: "uint256[2]"
59284
+ }
59285
+ ],
59286
+ name: "submitZKPResponse",
59287
+ outputs: [
59288
+ ],
59289
+ stateMutability: "nonpayable",
59290
+ type: "function"
59291
+ },
59292
+ {
59293
+ inputs: [
59294
+ {
59295
+ internalType: "address",
59296
+ name: "newOwner",
59297
+ type: "address"
59298
+ }
59299
+ ],
59300
+ name: "transferOwnership",
59301
+ outputs: [
59302
+ ],
59303
+ stateMutability: "nonpayable",
59304
+ type: "function"
59305
+ }
59306
+ ];
59307
+
59308
+ /**
59309
+ * OnChainZKPVerifier is a class that allows to interact with the OnChainZKPVerifier contract
59310
+ * and submitZKPResponse.
59311
+ *
59312
+ * @beta
59313
+ * @class OnChainZKPVerifier
59314
+ */
59315
+ class OnChainZKPVerifier {
59316
+ /**
59317
+ *
59318
+ * Creates an instance of OnChainZKPVerifier.
59319
+ * @beta
59320
+ * @param {EthConnectionConfig[]} - array of ETH configs
59321
+ */
59322
+ constructor(_configs) {
59323
+ this._configs = _configs;
59324
+ /**
59325
+ * solidity identifier for function signature:
59326
+ * function submitZKPResponse(uint64 requestId, uint256[] calldata inputs,
59327
+ * uint256[2] calldata a, uint256[2][2] calldata b, uint256[2] calldata c) public
59328
+ */
59329
+ this._supportedMethodId = 'b68967e2';
59330
+ }
59331
+ /**
59332
+ * Submit ZKP Responses to OnChainZKPVerifier contract.
59333
+ * @beta
59334
+ * @param {Signer} ethSigner - tx signer
59335
+ * @param {txData} ContractInvokeTransactionData - transaction data
59336
+ * @param {ZeroKnowledgeProofResponse[]} zkProofResponses - zkProofResponses
59337
+ * @returns {Promise<Map<string, ZeroKnowledgeProofResponse>>} - map of transaction hash - ZeroKnowledgeProofResponse
59338
+ */
59339
+ async submitZKPResponse(ethSigner, txData, zkProofResponses) {
59340
+ const chainConfig = this._configs.find((i) => i.chainId == txData.chain_id);
59341
+ if (!chainConfig) {
59342
+ throw new Error(`config for chain id ${txData.chain_id} was not found`);
59343
+ }
59344
+ if (txData.method_id.replace('0x', '') !== this._supportedMethodId) {
59345
+ throw new Error(`submit doesn't implement requested method id. Only '0x${this._supportedMethodId}' is supported.`);
59346
+ }
59347
+ const provider = new JsonRpcProvider(chainConfig.url, chainConfig.chainId);
59348
+ const verifierContract = new Contract(txData.contract_address, abi, provider);
59349
+ ethSigner = ethSigner.connect(provider);
59350
+ const contract = verifierContract.connect(ethSigner);
59351
+ const response = new Map();
59352
+ for (const zkProof of zkProofResponses) {
59353
+ const requestID = zkProof.id;
59354
+ const inputs = zkProof.pub_signals;
59355
+ const payload = [
59356
+ requestID,
59357
+ inputs,
59358
+ zkProof.proof.pi_a.slice(0, 2),
59359
+ [
59360
+ [zkProof.proof.pi_b[0][1], zkProof.proof.pi_b[0][0]],
59361
+ [zkProof.proof.pi_b[1][1], zkProof.proof.pi_b[1][0]]
59362
+ ],
59363
+ zkProof.proof.pi_c.slice(0, 2)
59364
+ ];
59365
+ const feeData = await provider.getFeeData();
59366
+ const maxFeePerGas = chainConfig.maxFeePerGas
59367
+ ? BigInt(chainConfig.maxFeePerGas)
59368
+ : feeData.maxFeePerGas;
59369
+ const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
59370
+ ? BigInt(chainConfig.maxPriorityFeePerGas)
59371
+ : feeData.maxPriorityFeePerGas;
59372
+ const gasLimit = await contract.submitZKPResponse.estimateGas(...payload);
59373
+ const txData = await contract.submitZKPResponse.populateTransaction(...payload);
59374
+ const request = {
59375
+ to: txData.to,
59376
+ data: txData.data,
59377
+ gasLimit,
59378
+ maxFeePerGas,
59379
+ maxPriorityFeePerGas
59380
+ };
59381
+ const tx = await ethSigner.sendTransaction(request);
59382
+ const txnReceipt = await tx.wait();
59383
+ if (!txnReceipt) {
59384
+ throw new Error(`transaction: ${tx.hash} failed to mined`);
59385
+ }
59386
+ const status = txnReceipt.status;
59387
+ const txnHash = txnReceipt.hash;
59388
+ if (!status) {
59389
+ throw new Error(`transaction: ${txnHash} failed to mined`);
59390
+ }
59391
+ response.set(txnHash, zkProof);
59392
+ }
59393
+ return response;
59394
+ }
59395
+ }
59396
+
59503
59397
  /**
59504
59398
  * search errors
59505
59399
  *
@@ -62078,5 +61972,5 @@ class ContractRequestHandler {
62078
61972
  }
62079
61973
  }
62080
61974
 
62081
- export { AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AuthHandler, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CHAIN_IDS, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DEFAULT_NETWORKS, DIDDocumentJSONSchema, DataPrepareHandlerFunc, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, Iden3SparseMerkleTreeProof, IdentityStorage, IdentityWallet, InMemoryDataSource, InMemoryMerkleTreeStorage, InMemoryPrivateKeyStore, IndexedDBDataSource, IndexedDBPrivateKeyStore, IssuerResolver, JSON_SCHEMA_VALIDATORS_REGISTRY, JWSPacker, JsonSchemaValidator, KMS, KmsKeyType, LDParser, LocalStoragePrivateKeyStore, MerkleTreeIndexedDBStorage, MerkleTreeLocalStorage, MerkleTreeType, MerklizedRootPosition, NativeProver, OnChainResolver, OnChainZKPVerifier, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, Query, QueryOperators, RHSResolver, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, ZKPPacker, bJJSignatureFromHexString, base58ToBytes, base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, buildQueryPath, buildTreeState, byteDecoder, byteEncoder, bytesToBase58, bytesToBase64, bytesToBase64url, bytesToHex$1 as bytesToHex, cacheLoader, checkDataInField, comparatorOptions, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaimsMerklization, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fillSlot, generateProfileDID, getChainId, getChainIdByDIDsParts, getDefaultNetworkForMethodId, getNodeAuxValue, getProperties, hexToBytes$1 as hexToBytes, isGenesisState, isGenesisStateId, isIssuerGenesis, keyPath, prepareCircuitArrayValues, prepareSiblingsStr, pushHashesToRHS, registerChainId, registerDefaultNetworkForMethodId, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, verifiablePresentationFromCred };
61975
+ export { AbstractPrivateKeyStore, AgentResolver, AtomicQueryMTPV2Inputs, AtomicQueryMTPV2OnChainInputs, AtomicQueryMTPV2OnChainPubSignals, AtomicQueryMTPV2PubSignals, AtomicQuerySigV2Inputs, AtomicQuerySigV2OnChainCircuitInputs, AtomicQuerySigV2OnChainInputs, AtomicQuerySigV2OnChainPubSignals, AtomicQuerySigV2PubSignals, AuthHandler, AuthV2Inputs, AuthV2PubSignals, BJJSignatureProof2021, BaseConfig, BjjProvider, BrowserDataSource, CircuitClaim, CircuitError, CircuitId, CircuitStorage, ContractRequestHandler, CredentialStatusResolverRegistry, CredentialStatusType, CredentialStorage, CredentialWallet, DIDDocumentJSONSchema, DataPrepareHandlerFunc, ErrorEmptyAuthClaimNonRevProof, ErrorEmptyAuthClaimProof, ErrorEmptyChallengeSignature, ErrorEmptyClaimNonRevProof, ErrorEmptyClaimProof, ErrorEmptyClaimSignature, ErrorEmptyIssuerAuthClaimNonRevProof, ErrorEmptyIssuerAuthClaimProof, ErrorUserStateInRelayClaimProof, EthStateStorage, FSCircuitStorage, FetchHandler, FilterQuery, Iden3SparseMerkleTreeProof, IdentityStorage, IdentityWallet, InMemoryDataSource, InMemoryMerkleTreeStorage, InMemoryPrivateKeyStore, IndexedDBDataSource, IndexedDBPrivateKeyStore, IssuerResolver, JSON_SCHEMA_VALIDATORS_REGISTRY, JWSPacker, JsonSchemaValidator, KMS, KmsKeyType, LDParser, LocalStoragePrivateKeyStore, MerkleTreeIndexedDBStorage, MerkleTreeLocalStorage, MerkleTreeType, MerklizedRootPosition, NativeProver, OnChainResolver, OnChainZKPVerifier, Operators, constants as PROTOCOL_CONSTANTS, PackageManager, Parser, PlainPacker, ProofNode, ProofPurpose, ProofService, ProofType, Query, QueryOperators, RHSResolver, Scalar, SearchError, Sec256k1Provider, StandardJSONCredentialsQueryFilter, StateTransitionInputs, StateTransitionPubSignals, SubjectPosition, ValueProof, Vector, VerifiableConstants, VerificationHandlerFunc, W3CCredential, ZKPPacker, bJJSignatureFromHexString, base58ToBytes, base64ToBytes, base64UrlToBytes, bigIntArrayToStringArray, buildQueryPath, buildTreeState, byteDecoder, byteEncoder, bytesToBase58, bytesToBase64, bytesToBase64url, bytesToHex$1 as bytesToHex, cacheLoader, checkDataInField, comparatorOptions, createSchemaHash, createVerifiablePresentation, credentialSubjectKey, dataFillsSlot, decodeBase64url, defaultEthConnectionConfig, defaultMTLevels, defaultMTLevelsClaimsMerklization, defaultMTLevelsOnChain, defaultValueArraySize, defineMerklizedRootPosition, encodeBase64url, existenceToInt, extractProof, extractPublicKeyBytes, factoryComparer, fieldToByteArray, fillSlot, generateProfileDID, getNodeAuxValue, getProperties, hexToBytes$1 as hexToBytes, isGenesisState, isGenesisStateId, isIssuerGenesis, keyPath, prepareCircuitArrayValues, prepareSiblingsStr, pushHashesToRHS, resolvePath, resolveVerificationMethods, strMTHex, stringByPath, subjectPositionIndex, swapEndianness, toClaimNonRevStatus, toGISTProof, toRevocationStatus, verifiablePresentationFromCred };
62082
61976
  //# sourceMappingURL=index.js.map