@show-karma/karma-gap-sdk 0.3.2 → 0.3.4

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 (70) hide show
  1. package/config/keys.example.json +6 -0
  2. package/core/abi/EAS.json +1 -0
  3. package/core/abi/SchemaRegistry.json +1 -0
  4. package/core/class/Attestation.ts +402 -0
  5. package/core/class/Fetcher.ts +202 -0
  6. package/core/class/GAP.d.ts +3 -1
  7. package/core/class/GAP.js +5 -2
  8. package/core/class/GAP.ts +398 -0
  9. package/core/class/GapSchema.ts +90 -0
  10. package/core/class/Gelato/Gelato.ts +286 -0
  11. package/core/class/GraphQL/AxiosGQL.ts +29 -0
  12. package/core/class/GraphQL/EASClient.ts +34 -0
  13. package/core/class/GraphQL/GapEasClient.ts +845 -0
  14. package/core/class/GraphQL/index.ts +3 -0
  15. package/core/class/Schema.ts +609 -0
  16. package/core/class/SchemaError.ts +36 -0
  17. package/core/class/contract/GapContract.js +2 -2
  18. package/core/class/contract/GapContract.ts +353 -0
  19. package/core/class/entities/Community.ts +115 -0
  20. package/core/class/entities/Grant.ts +309 -0
  21. package/core/class/entities/MemberOf.ts +42 -0
  22. package/core/class/entities/Milestone.ts +269 -0
  23. package/core/class/entities/Project.ts +370 -0
  24. package/core/class/entities/index.ts +5 -0
  25. package/core/class/index.ts +10 -0
  26. package/core/class/karma-indexer/GapIndexerClient.ts +245 -0
  27. package/core/class/remote-storage/IpfsStorage.ts +51 -0
  28. package/core/class/remote-storage/RemoteStorage.ts +65 -0
  29. package/core/class/types/attestations.ts +158 -0
  30. package/core/consts.js +1 -1
  31. package/core/consts.ts +282 -0
  32. package/core/index.ts +7 -0
  33. package/core/scripts/deploy.ts +67 -0
  34. package/core/scripts/index.ts +1 -0
  35. package/core/types.ts +186 -0
  36. package/core/utils/gelato/index.ts +3 -0
  37. package/core/utils/gelato/send-gelato-txn.ts +114 -0
  38. package/core/utils/gelato/sponsor-handler.ts +77 -0
  39. package/core/utils/gelato/watch-gelato-txn.ts +67 -0
  40. package/core/utils/get-date.ts +3 -0
  41. package/core/utils/get-ipfs-data.ts +13 -0
  42. package/core/utils/get-web3-provider.ts +20 -0
  43. package/core/utils/gql-queries.ts +133 -0
  44. package/core/utils/index.ts +7 -0
  45. package/core/utils/map-filter.ts +21 -0
  46. package/core/utils/serialize-bigint.ts +7 -0
  47. package/core/utils/to-unix.ts +18 -0
  48. package/csv-upload/.gitkeep +0 -0
  49. package/csv-upload/example.csv +2 -0
  50. package/csv-upload/scripts/run.ts +193 -0
  51. package/docs/.gitkeep +0 -0
  52. package/docs/images/attestation-architecture.png +0 -0
  53. package/docs/images/dfd-get-projects.png +0 -0
  54. package/index.ts +1 -0
  55. package/package.json +1 -1
  56. package/readme.md +39 -34
  57. package/schemas/.gitkeep +0 -0
  58. package/schemas/GAP-schemas-1692135812877.json +33 -0
  59. package/test-file.ts +92 -0
  60. package/tsconfig.json +26 -0
  61. package/core/class/AttestationIPFS.d.ts +0 -7
  62. package/core/class/AttestationIPFS.js +0 -10
  63. package/core/class/GraphQL/Fetcher.d.ts +0 -132
  64. package/core/class/GraphQL/Fetcher.js +0 -7
  65. package/core/class/GraphQL/GAPFetcher.d.ts +0 -160
  66. package/core/class/GraphQL/GAPFetcher.js +0 -516
  67. package/core/class/IPFS/IPFS.d.ts +0 -13
  68. package/core/class/IPFS/IPFS.js +0 -24
  69. package/core/class/contract/MultiAttest.d.ts +0 -10
  70. package/core/class/contract/MultiAttest.js +0 -19
@@ -0,0 +1 @@
1
+ {"address": "0xA7b39296258348C78294F95B872b282326A97BDF","abi": [{"inputs": [],"name": "AlreadyExists","type": "error"},{"anonymous": false,"inputs": [{"indexed": true,"internalType": "bytes32","name": "uid","type": "bytes32"},{"indexed": false,"internalType": "address","name": "registerer","type": "address"}],"name": "Registered","type": "event"},{"inputs": [],"name": "VERSION","outputs": [{"internalType": "string","name": "","type": "string"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "bytes32","name": "uid","type": "bytes32"}],"name": "getSchema","outputs": [{"components": [{"internalType": "bytes32","name": "uid","type": "bytes32"},{"internalType": "contract ISchemaResolver","name": "resolver","type": "address"},{"internalType": "bool","name": "revocable","type": "bool"},{"internalType": "string","name": "schema","type": "string"}],"internalType": "struct SchemaRecord","name": "","type": "tuple"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "string","name": "schema","type": "string"},{"internalType": "contract ISchemaResolver","name": "resolver","type": "address"},{"internalType": "bool","name": "revocable","type": "bool"}],"name": "register","outputs": [{"internalType": "bytes32","name": "","type": "bytes32"}],"stateMutability": "nonpayable","type": "function"}],"transactionHash": "0x9eaa9c685585e12e62b5e323a6a29e81de392a4134cc45a543d1b824ee71d1ec","receipt": {"to": null,"from": "0x2bF22CAe1dc34f265cAE03F6ff419177b4f4FBb3","contractAddress": "0xA7b39296258348C78294F95B872b282326A97BDF","transactionIndex": 15,"gasUsed": "477737","logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","blockHash": "0xf78aba9bfc59ea3b77dc9458655cfaf523e78fed42e9f460c678d64413a5560a","transactionHash": "0x9eaa9c685585e12e62b5e323a6a29e81de392a4134cc45a543d1b824ee71d1ec","logs": [],"blockNumber": 16756726,"cumulativeGasUsed": "2318891","status": 1,"byzantium": true},"args": [],"numDeployments": 1,"solcInputHash": "f4b7f486d6c32786b7e8d2904f9f6cf8","metadata": "{\"compiler\":{\"version\":\"0.8.18+commit.87f61d96\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AlreadyExists\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"uid\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"registerer\",\"type\":\"address\"}],\"name\":\"Registered\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"VERSION\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"uid\",\"type\":\"bytes32\"}],\"name\":\"getSchema\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"uid\",\"type\":\"bytes32\"},{\"internalType\":\"contract ISchemaResolver\",\"name\":\"resolver\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"revocable\",\"type\":\"bool\"},{\"internalType\":\"string\",\"name\":\"schema\",\"type\":\"string\"}],\"internalType\":\"struct SchemaRecord\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"schema\",\"type\":\"string\"},{\"internalType\":\"contract ISchemaResolver\",\"name\":\"resolver\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"revocable\",\"type\":\"bool\"}],\"name\":\"register\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"Registered(bytes32,address)\":{\"details\":\"Emitted when a new schema has been registered\",\"params\":{\"registerer\":\"The address of the account used to register the schema.\",\"uid\":\"The schema UID.\"}}},\"kind\":\"dev\",\"methods\":{\"getSchema(bytes32)\":{\"details\":\"Returns an existing schema by UID\",\"params\":{\"uid\":\"The UID of the schema to retrieve.\"},\"returns\":{\"_0\":\"The schema data members.\"}},\"register(string,address,bool)\":{\"details\":\"Submits and reserves a new schema\",\"params\":{\"resolver\":\"An optional schema resolver.\",\"revocable\":\"Whether the schema allows revocations explicitly.\",\"schema\":\"The schema data schema.\"},\"returns\":{\"_0\":\"The UID of the new schema.\"}}},\"title\":\"The global schema registry.\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/SchemaRegistry.sol\":\"SchemaRegistry\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[],\"viaIR\":true},\"sources\":{\"contracts/ISchemaRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport { ISchemaResolver } from \\\"./resolver/ISchemaResolver.sol\\\";\\n\\n/**\\n * @title A struct representing a record for a submitted schema.\\n */\\nstruct SchemaRecord {\\nbytes32 uid; // The unique identifier of the schema.\\nISchemaResolver resolver; // Optional schema resolver.\\nbool revocable; // Whether the schema allows revocations explicitly.\\nstring schema; // Custom specification of the schema (e.g., an ABI).\\n}\\n\\n/**\\n * @title The global schema registry interface.\\n */\\ninterface ISchemaRegistry {\\n/**\\n * @dev Emitted when a new schema has been registered\\n *\\n * @param uid The schema UID.\\n * @param registerer The address of the account used to register the schema.\\n */\\nevent Registered(bytes32 indexed uid, address registerer);\\n\\n/**\\n * @dev Submits and reserves a new schema\\n *\\n * @param schema The schema data schema.\\n * @param resolver An optional schema resolver.\\n * @param revocable Whether the schema allows revocations explicitly.\\n *\\n * @return The UID of the new schema.\\n */\\nfunction register(string calldata schema, ISchemaResolver resolver, bool revocable) external returns (bytes32);\\n\\n/**\\n * @dev Returns an existing schema by UID\\n *\\n * @param uid The UID of the schema to retrieve.\\n *\\n * @return The schema data members.\\n */\\nfunction getSchema(bytes32 uid) external view returns (SchemaRecord memory);\\n}\\n\",\"keccak256\":\"0xef47e449dd02bd034e26b1dea505ce533906f8462fc674c938ed0e872a68d640\",\"license\":\"MIT\"},\"contracts/SchemaRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.19;\\n\\nimport { EMPTY_UID } from \\\"./Types.sol\\\";\\nimport { ISchemaRegistry, SchemaRecord } from \\\"./ISchemaRegistry.sol\\\";\\n\\nimport { ISchemaResolver } from \\\"./resolver/ISchemaResolver.sol\\\";\\n\\n/**\\n * @title The global schema registry.\\n */\\ncontract SchemaRegistry is ISchemaRegistry {\\nerror AlreadyExists();\\n\\n// The version of the contract.\\nstring public constant VERSION = \\\"0.26\\\";\\n\\n// The global mapping between schema records and their IDs.\\nmapping(bytes32 uid => SchemaRecord schemaRecord) private _registry;\\n\\n/**\\n * @inheritdoc ISchemaRegistry\\n */\\nfunction register(string calldata schema, ISchemaResolver resolver, bool revocable) external returns (bytes32) {\\nSchemaRecord memory schemaRecord = SchemaRecord({\\nuid: EMPTY_UID,\\nschema: schema,\\nresolver: resolver,\\nrevocable: revocable\\n});\\n\\nbytes32 uid = _getUID(schemaRecord);\\nif (_registry[uid].uid != EMPTY_UID) {\\nrevert AlreadyExists();\\n}\\n\\nschemaRecord.uid = uid;\\n_registry[uid] = schemaRecord;\\n\\nemit Registered(uid, msg.sender);\\n\\nreturn uid;\\n}\\n\\n/**\\n * @inheritdoc ISchemaRegistry\\n */\\nfunction getSchema(bytes32 uid) external view returns (SchemaRecord memory) {\\nreturn _registry[uid];\\n}\\n\\n/**\\n * @dev Calculates a UID for a given schema.\\n *\\n * @param schemaRecord The input schema.\\n *\\n * @return schema UID.\\n */\\nfunction _getUID(SchemaRecord memory schemaRecord) private pure returns (bytes32) {\\nreturn keccak256(abi.encodePacked(schemaRecord.schema, schemaRecord.resolver, schemaRecord.revocable));\\n}\\n}\\n\",\"keccak256\":\"0x11ca856573f1b53530d27d40b0a5629a5c591957e221a1b4b8eae2b2053f168b\",\"license\":\"MIT\"},\"contracts/Types.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.19;\\n\\n// A representation of an empty/uninitialized UID.\\nbytes32 constant EMPTY_UID = 0;\\n\\n/**\\n * @dev A struct representing EIP712 signature data.\\n */\\nstruct EIP712Signature {\\nuint8 v; // The recovery ID.\\nbytes32 r; // The x-coordinate of the nonce R.\\nbytes32 s; // The signature data.\\n}\\n\\n/**\\n * @dev A struct representing a single attestation.\\n */\\nstruct Attestation {\\nbytes32 uid; // A unique identifier of the attestation.\\nbytes32 schema; // The unique identifier of the schema.\\nuint64 time; // The time when the attestation was created (Unix timestamp).\\nuint64 expirationTime; // The time when the attestation expires (Unix timestamp).\\nuint64 revocationTime; // The time when the attestation was revoked (Unix timestamp).\\nbytes32 refUID; // The UID of the related attestation.\\naddress recipient; // The recipient of the attestation.\\naddress attester; // The attester/sender of the attestation.\\nbool revocable; // Whether the attestation is revocable.\\nbytes data; // Custom attestation data.\\n}\\n\",\"keccak256\":\"0x547096b5cb7bfad9591bdc520705f8110534cd040ed0f7a0ba8d83ea4a565b45\",\"license\":\"MIT\"},\"contracts/resolver/ISchemaResolver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport { Attestation } from \\\"../Types.sol\\\";\\n\\n/**\\n * @title The interface of an optional schema resolver.\\n */\\ninterface ISchemaResolver {\\n/**\\n * @dev Returns whether the resolver supports ETH transfers.\\n */\\nfunction isPayable() external pure returns (bool);\\n\\n/**\\n * @dev Processes an attestation and verifies whether it's valid.\\n *\\n * @param attestation The new attestation.\\n *\\n * @return Whether the attestation is valid.\\n */\\nfunction attest(Attestation calldata attestation) external payable returns (bool);\\n\\n/**\\n * @dev Processes multiple attestations and verifies whether they are valid.\\n *\\n * @param attestations The new attestations.\\n * @param values Explicit ETH amounts which were sent with each attestation.\\n *\\n * @return Whether all the attestations are valid.\\n */\\nfunction multiAttest(\\nAttestation[] calldata attestations,\\nuint256[] calldata values\\n) external payable returns (bool);\\n\\n/**\\n * @dev Processes an attestation revocation and verifies if it can be revoked.\\n *\\n * @param attestation The existing attestation to be revoked.\\n *\\n * @return Whether the attestation can be revoked.\\n */\\nfunction revoke(Attestation calldata attestation) external payable returns (bool);\\n\\n/**\\n * @dev Processes revocation of multiple attestation and verifies they can be revoked.\\n *\\n * @param attestations The existing attestations to be revoked.\\n * @param values Explicit ETH amounts which were sent with each revocation.\\n *\\n * @return Whether the attestations can be revoked.\\n */\\nfunction multiRevoke(\\nAttestation[] calldata attestations,\\nuint256[] calldata values\\n) external payable returns (bool);\\n}\\n\",\"keccak256\":\"0x0f3a75c28cdb91fa9227a6eef183379ecea2b6bf38db52795b5c4e6af79299e8\",\"license\":\"MIT\"}},\"version\":1}","bytecode": "0x60808060405234610016576107b8908161001c8239f35b600080fdfe60806040908082526004918236101561001757600080fd5b600091823560e01c90816360d7a2781461029757508063a2ea7c6e146101045763ffa1ad741461004657600080fd5b3461010057817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610100578051918183019083821067ffffffffffffffff8311176100d45750926100d093825282527f302e323600000000000000000000000000000000000000000000000000000000602083015251918291602083526020830190610689565b0390f35b806041867f4e487b71000000000000000000000000000000000000000000000000000000006024945252fd5b5080fd5b503461010057602092837ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610293576060808351610144816106cc565b85815285878201528585820152015235825281835280822090805191610169836106cc565b805483526001918282015491868501600273ffffffffffffffffffffffffffffffffffffffff92838616835260ff8589019660a01c16151586520188845196898354936101b585610758565b808b52948381169081156102505750600114610214575b50505050506101e1856100d097980386610717565b606087019485528251978897818952519088015251169085015251151560608401525160808084015260a0830190610689565b908094939b50528983205b82841061023d575050508501909601956101e1886100d087386101cc565b80548985018c0152928a0192810161021f565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016858c01525050505090151560051b86010196506101e1886100d087386101cc565b8280fd5b92939050346106625760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126106625780359067ffffffffffffffff80831161065e573660238401121561065e57828201359181831161065a57366024848601011161065a576024359673ffffffffffffffffffffffffffffffffffffffff9182891680990361010057604435978815158099036102935761033b816106cc565b8281526020998a8201908152888201998a52885197848c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe099818b601f83011601610386908d610717565b808c5280828d019460240185378b0101528b6060840199808b5283518d5115158d519384938185019687915180926103bd92610666565b84019260601b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000169083015260f81b6034820152036015810182526035016104059082610717565b519020998a8552848c5289852054610632579082918b600294528b8652858d528a8620925183556001968784019251167fffffffffffffffffffffff00000000000000000000000000000000000000000074ff000000000000000000000000000000000000000084549351151560a01b1692161717905501955190815194851161060657506104948654610758565b601f81116105c0575b508891601f8511600114610545578495509084939492919361051a575b50507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff91921b9260031b1c19161790555b817f7d917fcbc9a29a9705ff9936ffa599500e4fd902e4486bae317414fe967b307c848351338152a251908152f35b015191507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff386104ba565b9294849081168785528a8520945b8b888383106105a95750505010610572575b505050811b0190556104eb565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c19169055388080610565565b868601518855909601959485019487935001610553565b868352898320601f860160051c8101918b87106105fc575b601f0160051c019084905b8281106105f157505061049d565b8481550184906105e3565b90915081906105d8565b8260416024927f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b838a517f23369fa6000000000000000000000000000000000000000000000000000000008152fd5b8680fd5b8580fd5b8380fd5b60005b8381106106795750506000910152565b8181015183820152602001610669565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f6020936106c581518092818752878088019101610666565b0116010190565b6080810190811067ffffffffffffffff8211176106e857604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176106e857604052565b90600182811c921680156107a1575b602083101461077257565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b91607f169161076756fea164736f6c6343000812000a","deployedBytecode": "0x60806040908082526004918236101561001757600080fd5b600091823560e01c90816360d7a2781461029757508063a2ea7c6e146101045763ffa1ad741461004657600080fd5b3461010057817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610100578051918183019083821067ffffffffffffffff8311176100d45750926100d093825282527f302e323600000000000000000000000000000000000000000000000000000000602083015251918291602083526020830190610689565b0390f35b806041867f4e487b71000000000000000000000000000000000000000000000000000000006024945252fd5b5080fd5b503461010057602092837ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610293576060808351610144816106cc565b85815285878201528585820152015235825281835280822090805191610169836106cc565b805483526001918282015491868501600273ffffffffffffffffffffffffffffffffffffffff92838616835260ff8589019660a01c16151586520188845196898354936101b585610758565b808b52948381169081156102505750600114610214575b50505050506101e1856100d097980386610717565b606087019485528251978897818952519088015251169085015251151560608401525160808084015260a0830190610689565b908094939b50528983205b82841061023d575050508501909601956101e1886100d087386101cc565b80548985018c0152928a0192810161021f565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016858c01525050505090151560051b86010196506101e1886100d087386101cc565b8280fd5b92939050346106625760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126106625780359067ffffffffffffffff80831161065e573660238401121561065e57828201359181831161065a57366024848601011161065a576024359673ffffffffffffffffffffffffffffffffffffffff9182891680990361010057604435978815158099036102935761033b816106cc565b8281526020998a8201908152888201998a52885197848c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe099818b601f83011601610386908d610717565b808c5280828d019460240185378b0101528b6060840199808b5283518d5115158d519384938185019687915180926103bd92610666565b84019260601b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000169083015260f81b6034820152036015810182526035016104059082610717565b519020998a8552848c5289852054610632579082918b600294528b8652858d528a8620925183556001968784019251167fffffffffffffffffffffff00000000000000000000000000000000000000000074ff000000000000000000000000000000000000000084549351151560a01b1692161717905501955190815194851161060657506104948654610758565b601f81116105c0575b508891601f8511600114610545578495509084939492919361051a575b50507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff91921b9260031b1c19161790555b817f7d917fcbc9a29a9705ff9936ffa599500e4fd902e4486bae317414fe967b307c848351338152a251908152f35b015191507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff386104ba565b9294849081168785528a8520945b8b888383106105a95750505010610572575b505050811b0190556104eb565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c19169055388080610565565b868601518855909601959485019487935001610553565b868352898320601f860160051c8101918b87106105fc575b601f0160051c019084905b8281106105f157505061049d565b8481550184906105e3565b90915081906105d8565b8260416024927f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b838a517f23369fa6000000000000000000000000000000000000000000000000000000008152fd5b8680fd5b8580fd5b8380fd5b60005b8381106106795750506000910152565b8181015183820152602001610669565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f6020936106c581518092818752878088019101610666565b0116010190565b6080810190811067ffffffffffffffff8211176106e857604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176106e857604052565b90600182811c921680156107a1575b602083101461077257565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b91607f169161076756fea164736f6c6343000812000a","devdoc": {"events": {"Registered(bytes32,address)": {"details": "Emitted when a new schema has been registered","params": {"registerer": "The address of the account used to register the schema.","uid": "The schema UID."}}},"kind": "dev","methods": {"getSchema(bytes32)": {"details": "Returns an existing schema by UID","params": {"uid": "The UID of the schema to retrieve."},"returns": {"_0": "The schema data members."}},"register(string,address,bool)": {"details": "Submits and reserves a new schema","params": {"resolver": "An optional schema resolver.","revocable": "Whether the schema allows revocations explicitly.","schema": "The schema data schema."},"returns": {"_0": "The UID of the new schema."}}},"title": "The global schema registry.","version": 1},"userdoc": {"kind": "user","methods": {},"version": 1},"storageLayout": {"storage": [{"astId": 5366,"contract": "contracts/SchemaRegistry.sol:SchemaRegistry","label": "_registry","offset": 0,"slot": "0","type": "t_mapping(t_bytes32,t_struct(SchemaRecord)5313_storage)"}],"types": {"t_bool": {"encoding": "inplace","label": "bool","numberOfBytes": "1"},"t_bytes32": {"encoding": "inplace","label": "bytes32","numberOfBytes": "32"},"t_contract(ISchemaResolver)5553": {"encoding": "inplace","label": "contract ISchemaResolver","numberOfBytes": "20"},"t_mapping(t_bytes32,t_struct(SchemaRecord)5313_storage)": {"encoding": "mapping","key": "t_bytes32","label": "mapping(bytes32 => struct SchemaRecord)","numberOfBytes": "32","value": "t_struct(SchemaRecord)5313_storage"},"t_string_storage": {"encoding": "bytes","label": "string","numberOfBytes": "32"},"t_struct(SchemaRecord)5313_storage": {"encoding": "inplace","label": "struct SchemaRecord","members": [{"astId": 5305,"contract": "contracts/SchemaRegistry.sol:SchemaRegistry","label": "uid","offset": 0,"slot": "0","type": "t_bytes32"},{"astId": 5308,"contract": "contracts/SchemaRegistry.sol:SchemaRegistry","label": "resolver","offset": 0,"slot": "1","type": "t_contract(ISchemaResolver)5553"},{"astId": 5310,"contract": "contracts/SchemaRegistry.sol:SchemaRegistry","label": "revocable","offset": 20,"slot": "1","type": "t_bool"},{"astId": 5312,"contract": "contracts/SchemaRegistry.sol:SchemaRegistry","label": "schema","offset": 0,"slot": "2","type": "t_string_storage"}],"numberOfBytes": "96"}}}}
@@ -0,0 +1,402 @@
1
+ import {
2
+ Hex,
3
+ IAttestation,
4
+ JSONStr,
5
+ MultiAttestData,
6
+ MultiAttestPayload,
7
+ SignerOrProvider,
8
+ TNetwork,
9
+ TSchemaName,
10
+ } from '../types';
11
+ import { Schema } from './Schema';
12
+ import { AttestationError, SchemaError } from './SchemaError';
13
+ import {
14
+ SchemaDecodedItem,
15
+ SchemaItem,
16
+ SchemaValue,
17
+ } from '@ethereum-attestation-service/eas-sdk';
18
+ import { getDate } from '../utils/get-date';
19
+ import { GAP } from './GAP';
20
+ import { GapSchema } from './GapSchema';
21
+ import { Networks, nullRef } from '../consts';
22
+ import { GapContract } from './contract/GapContract';
23
+
24
+ export interface AttestationArgs<T = unknown, S extends Schema = Schema> {
25
+ data: T | string;
26
+ schema: S;
27
+ uid?: Hex;
28
+ refUID?: Hex;
29
+ attester?: Hex;
30
+ recipient: Hex;
31
+ revoked?: boolean;
32
+ revocationTime?: Date | number;
33
+ createdAt?: Date | number;
34
+ chainID?: number;
35
+ }
36
+
37
+ /**
38
+ * Represents the EAS Attestation and provides methods to manage attestations.
39
+ * @example
40
+ *
41
+ * ```ts
42
+ * const grantee = new Attestation({
43
+ * schema: Schema.get("Grantee", "network-name"), // Use this.schema.gap.findSchema("SchemaName") if using default GAP schemas
44
+ * data: { grantee: true },
45
+ * uid: "0xabc123",
46
+ * });
47
+ *
48
+ * const granteeDetails = new Attestation({
49
+ * schema: Schema.get("GranteeDetails", "optimism"),
50
+ * data: {
51
+ * name: "John Doe",
52
+ * description: "A description",
53
+ * imageURL: "https://example.com/image.png",
54
+ * },
55
+ * uid: "0xab234"
56
+ * );
57
+ *
58
+ * // Return the refferenced attestation
59
+ * const ref = granteeDetails.reference<Grantee>();
60
+ *
61
+ * // Revoke attestation
62
+ * granteeDetails.revoke();
63
+ *
64
+ * // Get attestation data from a decoded JSON string.
65
+ * granteeDetails.fromDecodedSchema(granteeDetails.data);
66
+ * ```
67
+ */
68
+ export class Attestation<T = unknown, S extends Schema = GapSchema>
69
+ implements AttestationArgs<T, S>
70
+ {
71
+ readonly schema: S;
72
+ private _data: T;
73
+
74
+ protected _uid: Hex;
75
+ readonly refUID?: Hex;
76
+ readonly attester?: Hex;
77
+ readonly recipient: Hex;
78
+ readonly revoked?: boolean;
79
+ readonly revocationTime?: Date;
80
+ readonly createdAt: Date;
81
+ private _chainID: number;
82
+
83
+ private _reference?: Attestation;
84
+
85
+ constructor(args: AttestationArgs<T, S>) {
86
+ this.schema = args.schema;
87
+
88
+ this._data = this.fromDecodedSchema(args.data);
89
+
90
+ this.setValues(this._data);
91
+ this._uid = args.uid || nullRef;
92
+ this.refUID = args.refUID || nullRef;
93
+ this.attester = args.attester;
94
+ this.recipient = args.recipient;
95
+ this.revoked = args.revoked;
96
+ this.revocationTime = getDate(args.revocationTime);
97
+ this.createdAt = getDate(args.createdAt || Date.now() / 1000);
98
+ this._chainID = args.chainID || Networks[this.schema.gap.network].chainId;
99
+ }
100
+
101
+ /**
102
+ * Encodes the schema.
103
+ * @returns
104
+ */
105
+ encodeSchema(schema: SchemaItem[]) {
106
+ return this.schema.encode(schema);
107
+ }
108
+
109
+ /**
110
+ * Sets a field in the schema.
111
+ */
112
+ setValue<K extends keyof T>(key: K, value: SchemaValue) {
113
+ this.schema.setValue(key as string, value);
114
+ }
115
+
116
+ /**
117
+ * Set attestation values to be uploaded.
118
+ * @param values
119
+ */
120
+ setValues(values: T) {
121
+ const isJsonSchema = this.schema.isJsonSchema();
122
+ if (isJsonSchema) this.schema.setValue('json', JSON.stringify(values));
123
+ this._data = values;
124
+
125
+ Object.entries(values).forEach(([key, value]) => {
126
+ this[key] = value;
127
+ if (!isJsonSchema) this.setValue(key as keyof T, value.value || value);
128
+ });
129
+ }
130
+
131
+ /**
132
+ * Returns the referenced attestation
133
+ */
134
+ reference<Ref = unknown, RefSchema extends Schema = Schema>() {
135
+ return this._reference as Attestation<Ref, RefSchema>;
136
+ }
137
+
138
+ /**
139
+ * Returns the attestation data as a JSON string.
140
+ * @param data
141
+ * @returns
142
+ */
143
+ fromDecodedSchema(data: T | JSONStr): T {
144
+ return typeof data === 'string'
145
+ ? Attestation.fromDecodedSchema<T>(data)
146
+ : data;
147
+ }
148
+
149
+ /**
150
+ * Revokes this attestation.
151
+ * @param eas
152
+ * @param signer
153
+ * @returns
154
+ */
155
+ revoke(signer: SignerOrProvider) {
156
+ try {
157
+ return GapContract.multiRevoke(signer, [
158
+ {
159
+ data: [
160
+ {
161
+ uid: this.uid,
162
+ value: 0n,
163
+ },
164
+ ],
165
+ schema: this.schema.uid,
166
+ },
167
+ ]);
168
+ } catch (error) {
169
+ console.error(error);
170
+ throw new SchemaError('REVOKE_ERROR', 'Error revoking attestation.');
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Attests the data using the specified signer and schema.
176
+ * @param signer - The signer or provider to use for attestation.
177
+ * @param args - Additional arguments to pass to the schema's `attest` method.
178
+ * @returns A Promise that resolves to the UID of the attestation.
179
+ * @throws An `AttestationError` if an error occurs during attestation.
180
+ */
181
+ async attest(signer: SignerOrProvider, ...args: unknown[]) {
182
+ console.log(`Attesting ${this.schema.name}`);
183
+ try {
184
+ const uid = await this.schema.attest<T>({
185
+ data: this.data,
186
+ to: this.recipient,
187
+ refUID: this.refUID,
188
+ signer,
189
+ });
190
+ this._uid = uid;
191
+ console.log(`Attested ${this.schema.name} with UID ${uid}`);
192
+ } catch (error) {
193
+ console.error(error);
194
+ throw new AttestationError('ATTEST_ERROR', 'Error during attestation.');
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Validates the payload.
200
+ *
201
+ * If an attestation should have anything
202
+ * specifically explicit, it should be implemented in
203
+ * order to avoid errors.
204
+ * @returns
205
+ */
206
+ protected assertPayload() {
207
+ return true;
208
+ }
209
+
210
+ /**
211
+ * Get the multi attestation payload for the referred index.
212
+ *
213
+ * The index should be the array position this payload wants
214
+ * to reference.
215
+ *
216
+ * E.g:
217
+ *
218
+ * 1. Project is index 0;
219
+ * 2. Project details is index 1;
220
+ * 3. Grant is index 2;
221
+ * 4. Grant details is index 3;
222
+ * 5. Milestone is index 4;
223
+ *
224
+ * `[Project, projectDetails, grant, grantDetails, milestone]`
225
+ *
226
+ * -> Project.payloadFor(0); // refs itself (no effect)
227
+ *
228
+ * -> project.details.payloadFor(0); // ref project
229
+ *
230
+ * -> grant.payloadFor(0); // ref project
231
+ *
232
+ * -> grant.details.payloadFor(2); // ref grant
233
+ *
234
+ * -> milestone.payloadFor(2); // ref grant
235
+ *
236
+ *
237
+ * @param refIdx
238
+ * @returns [Encoded payload, Raw payload]
239
+ */
240
+ async payloadFor(refIdx: number): Promise<{
241
+ payload: MultiAttestData;
242
+ raw: MultiAttestData;
243
+ }> {
244
+ this.assertPayload();
245
+
246
+ if (this.schema.isJsonSchema()) {
247
+ const { remoteClient } = GAP;
248
+ if (remoteClient) {
249
+ const cid = await remoteClient.save(this._data, this.schema.name);
250
+ const encodedData = remoteClient.encode(cid);
251
+ this.schema.setValue('json', JSON.stringify(encodedData));
252
+ }
253
+ }
254
+
255
+ const payload = (encode = true): MultiAttestData => ({
256
+ uid: nullRef,
257
+ refIdx,
258
+ multiRequest: {
259
+ schema: this.schema.uid,
260
+ data: [
261
+ {
262
+ refUID: this.refUID,
263
+ expirationTime: 0n,
264
+ revocable: this.schema.revocable || true,
265
+ value: 0n,
266
+ data: (encode ? this.schema.encode() : this.schema.schema) as any,
267
+ recipient: this.recipient,
268
+ },
269
+ ],
270
+ },
271
+ });
272
+ return {
273
+ payload: payload(),
274
+ raw: payload(false),
275
+ };
276
+ }
277
+
278
+ /**
279
+ * Returns an Attestation instance from a JSON decoded schema.
280
+ * @param data
281
+ * @returns
282
+ */
283
+ static fromDecodedSchema<T>(data: JSONStr): T {
284
+ try {
285
+ const parsed: SchemaDecodedItem[] = JSON.parse(data);
286
+
287
+ if (data.length < 2 && !/\{.*\}/gim.test(data)) return {} as T;
288
+ if (parsed.length === 1 && parsed[0].name === 'json') {
289
+ const { value } = parsed[0];
290
+ return (
291
+ typeof value.value === 'string'
292
+ ? JSON.parse(value.value)
293
+ : value.value
294
+ ) as T;
295
+ }
296
+
297
+ if (parsed && Array.isArray(parsed)) {
298
+ return parsed.reduce((acc, curr) => {
299
+ const { value } = curr.value;
300
+ if (curr.type.includes('uint')) {
301
+ acc[curr.name] = ['string', 'bigint'].includes(typeof value)
302
+ ? BigInt(value as any)
303
+ : Number(value);
304
+ } else acc[curr.name] = value;
305
+ return acc;
306
+ }, {}) as T;
307
+ }
308
+
309
+ throw new SchemaError(
310
+ 'INVALID_DATA',
311
+ 'Data must be a valid JSON array string.'
312
+ );
313
+ } catch (error) {
314
+ console.error(error);
315
+ throw new SchemaError(
316
+ 'INVALID_DATA',
317
+ 'Data must be a valid JSON string.'
318
+ );
319
+ }
320
+ }
321
+
322
+ /**
323
+ * Transform attestation interface-based into class-based.
324
+ */
325
+ static fromInterface<T extends Attestation = Attestation>(
326
+ attestations: IAttestation[],
327
+ network: TNetwork
328
+ ) {
329
+ const result: T[] = [];
330
+ attestations.forEach((attestation) => {
331
+ try {
332
+ const schema = Schema.get(attestation.schemaId, network);
333
+ result.push(
334
+ <T>new Attestation({
335
+ ...attestation,
336
+ schema,
337
+ chainID: Networks[network].chainId,
338
+ data: attestation.decodedDataJson,
339
+ })
340
+ );
341
+ } catch (e) {
342
+ console.log(e);
343
+ }
344
+ });
345
+ return result;
346
+ }
347
+
348
+ /**
349
+ * Asserts if schema is valid.
350
+ * > Does not check refUID if `strict = false`. To check refUID use `Schema.validate()`
351
+ * @param args
352
+ */
353
+ protected assert(args: AttestationArgs, strict = false) {
354
+ const { schema, uid } = args;
355
+
356
+ if (!schema || !(schema instanceof Schema)) {
357
+ throw new SchemaError('MISSING_FIELD', 'Schema must be an array.');
358
+ }
359
+
360
+ if (!uid) {
361
+ throw new SchemaError('MISSING_FIELD', 'Schema uid is required');
362
+ }
363
+
364
+ if (strict) Schema.validate(this.schema.gap.network);
365
+ }
366
+
367
+ get chainID() {
368
+ return this._chainID;
369
+ }
370
+
371
+ get data(): T {
372
+ return this._data;
373
+ }
374
+
375
+ get uid() {
376
+ return this._uid;
377
+ }
378
+
379
+ set uid(uid: Hex) {
380
+ this._uid = uid;
381
+ }
382
+
383
+ /**
384
+ * Create attestation to serve as Attestation data.
385
+ * @param data Data to attest
386
+ * @param schema selected schema
387
+ * @param from attester
388
+ * @param to recipient
389
+ * @returns
390
+ */
391
+ static factory<T = unknown>(data: T, schema: Schema, from: Hex, to: Hex) {
392
+ return new Attestation({
393
+ data: data,
394
+ recipient: to,
395
+ attester: from,
396
+ schema,
397
+ uid: '0x0',
398
+ createdAt: new Date(),
399
+ chainID: Networks[schema.gap.network].chainId,
400
+ });
401
+ }
402
+ }
@@ -0,0 +1,202 @@
1
+ import { Hex, IAttestation, TSchemaName } from 'core/types';
2
+ import { Attestation } from './Attestation';
3
+ import { Community, Grant, MemberOf, Milestone, Project } from './entities';
4
+ import { Grantee } from './types/attestations';
5
+ import { AxiosGQL } from './GraphQL/AxiosGQL';
6
+ import { GAP } from './GAP';
7
+
8
+ export abstract class Fetcher extends AxiosGQL {
9
+ protected gap: GAP;
10
+
11
+ constructor(url: string) {
12
+ super(url);
13
+ }
14
+
15
+ set gapInstance(gap: GAP) {
16
+ this.gap = gap;
17
+ }
18
+
19
+ /**
20
+ * Fetch a single attestation by its UID.
21
+ * @param uid
22
+ */
23
+ abstract attestation<T = unknown>(uid: Hex): Promise<Attestation<T>>;
24
+
25
+ /**
26
+ * Fetch attestations of a schema.
27
+ * @param schemaName
28
+ * @param search if set, will search decodedDataJson by the value.
29
+ * @returns
30
+ */
31
+ abstract attestations(
32
+ schemaName: TSchemaName,
33
+ search?: string
34
+ ): Promise<IAttestation[]>;
35
+
36
+ /**
37
+ * Fetch attestations of a schema.
38
+ * @param schemaName
39
+ * @param recipient
40
+ * @returns
41
+ */
42
+ abstract attestationsOf(
43
+ schemaName: TSchemaName,
44
+ recipient: Hex
45
+ ): Promise<IAttestation[]>;
46
+
47
+ /**
48
+ * Fetch attestations of a schema for a specific recipient.
49
+ * @param schemaName
50
+ * @param recipient
51
+ * @returns
52
+ */
53
+ abstract attestationsTo(
54
+ schemaName: TSchemaName,
55
+ recipient: Hex
56
+ ): Promise<IAttestation[]>;
57
+
58
+ /**
59
+ * Fetch all available communities with details and grantees uids.
60
+ *
61
+ * If search is defined, will try to find communities by the search string.
62
+ * @param search
63
+ * @returns
64
+ */
65
+ abstract communities(search?: string): Promise<Community[]>;
66
+
67
+ /**
68
+ * Fetch all available communities with details for a grantee;
69
+ *
70
+ * If search is defined, will try to find communities by the search string.
71
+ * @param address grantee address
72
+ * @param withGrants if true, will get community grants.
73
+ * @returns
74
+ */
75
+ abstract communitiesOf(
76
+ address: Hex,
77
+ withGrants?: boolean
78
+ ): Promise<Community[]>;
79
+
80
+ /**
81
+ * Fetch a set of communities by their ids.
82
+ * @param uids
83
+ * @returns
84
+ */
85
+ abstract communitiesByIds(uids: Hex[]): Promise<Community[]>;
86
+
87
+ /**
88
+ * Fetch a community by its name with details, grants and milestones.
89
+ *
90
+ * It is possible that the resulted community is not the one you are looking for.
91
+ * @param name
92
+ * @returns
93
+ */
94
+ abstract communityBySlug(slug: string): Promise<Community>;
95
+
96
+ /**
97
+ * Fetch a community by its id. This method will also return the
98
+ * community details and projects.
99
+ */
100
+ abstract communityById(uid: Hex): Promise<Community>;
101
+
102
+ /**
103
+ * Fetch a project by its id.
104
+ * @param uid
105
+ * @returns
106
+ */
107
+ abstract projectById(uid: Hex): Promise<Project>;
108
+
109
+ /**
110
+ * Fetch a project by its slug.
111
+ * @param slug
112
+ * @returns
113
+ */
114
+ abstract projectBySlug(slug: string): Promise<Project>;
115
+
116
+ /**
117
+ * Search projects by name. This method will return a list of projects
118
+ * __Must be implemented by the indexer__
119
+ * @param query
120
+ */
121
+ abstract searchProjects(query: string): Promise<Project[]>;
122
+
123
+ /**
124
+ * Fetch projects with details and members.
125
+ * @param name if set, will search by the name.
126
+ * @returns
127
+ */
128
+ abstract projects(name?: string): Promise<Project[]>;
129
+
130
+ /**
131
+ * Fetch projects with details and members.
132
+ * @param grantee the public address of the grantee
133
+ * @returns
134
+ */
135
+ abstract projectsOf(grantee: Hex): Promise<Project[]>;
136
+
137
+ /**
138
+ * Fetch Grantee with details and projects.
139
+ * @param address
140
+ * @param withProjects if true, will get grantee project details.
141
+ * @returns
142
+ */
143
+ abstract grantee(address: Hex): Promise<Grantee>;
144
+
145
+ /**
146
+ * Fetch all Grantees with details.
147
+ * @returns
148
+ */
149
+ abstract grantees(): Promise<Grantee[]>;
150
+
151
+ /**
152
+ * Fetches the grantes related to a grantee address (recipient).
153
+ * @param grantee grantee address
154
+ * @returns
155
+ */
156
+ abstract grantsOf(grantee: Hex, withCommunity?: boolean): Promise<Grant[]>;
157
+
158
+ /**
159
+ * Fetch grants for an array of projects with milestones.
160
+ * @param projects
161
+ * @returns
162
+ */
163
+ abstract grantsFor(
164
+ projects: Project[],
165
+ withCommunity?: boolean
166
+ ): Promise<Grant[]>;
167
+
168
+ /**
169
+ * Fetch a grants that belongs to a community.
170
+ * @param uid community uid
171
+ * @returns
172
+ */
173
+ abstract grantsByCommunity(uid: Hex);
174
+
175
+ /**
176
+ * Fetch all milestones related to an array of Grants.
177
+ * @param grants
178
+ * @returns
179
+ */
180
+ abstract milestonesOf(grants: Grant[]): Promise<Milestone[]>;
181
+
182
+ /**
183
+ * Bulk fetch members with details of an array of Projects.
184
+ * @param projects
185
+ * @returns
186
+ */
187
+ abstract membersOf(projects: Project[]): Promise<MemberOf[]>;
188
+
189
+ /**
190
+ * Check if a name is already in use.
191
+ * @param slug
192
+ * @returns
193
+ */
194
+ abstract slugExists(slug: string): Promise<boolean>;
195
+
196
+ /**
197
+ * Get grants for a project by an external uid
198
+ * > Works only for the indexed projects
199
+ * @param projectExtId
200
+ */
201
+ abstract grantsForExtProject(projectExtId: string): Promise<Grant[]>;
202
+ }
@@ -205,7 +205,9 @@ export declare class GAP extends Facade {
205
205
  * Get the multicall contract
206
206
  * @param signer
207
207
  */
208
- static getProjectResolver(signer: SignerOrProvider, chainId?: number): ethers.Contract;
208
+ static getProjectResolver(signer: SignerOrProvider & {
209
+ getChainId?: () => Promise<number>;
210
+ }, chainId?: number): Promise<ethers.Contract>;
209
211
  get schemas(): GapSchema[];
210
212
  /**
211
213
  * Defined if the transactions will be gasless or not.
package/core/class/GAP.js CHANGED
@@ -186,9 +186,12 @@ class GAP extends types_1.Facade {
186
186
  * Get the multicall contract
187
187
  * @param signer
188
188
  */
189
- static getProjectResolver(signer, chainId) {
189
+ static async getProjectResolver(signer, chainId) {
190
+ const currentChainId = chainId ||
191
+ Number((await signer.provider.getNetwork())?.chainId ||
192
+ (await signer.getChainId()));
190
193
  const provider = chainId ? (0, get_web3_provider_1.getWeb3Provider)(chainId) : signer;
191
- const network = Object.values(consts_1.Networks).find((n) => +n.chainId === Number(chainId));
194
+ const network = Object.values(consts_1.Networks).find((n) => +n.chainId === Number(currentChainId));
192
195
  const address = network.contracts.projectResolver;
193
196
  return new ethers_1.ethers.Contract(address, ProjectResolver_json_1.default, provider);
194
197
  }