@show-karma/karma-gap-sdk 0.4.15 → 0.4.16

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 (188) hide show
  1. package/.cursorrules +43 -0
  2. package/core/abi/AirdropNFT.json +1 -1
  3. package/core/abi/Allo.json +860 -860
  4. package/core/abi/AlloRegistry.json +578 -578
  5. package/core/abi/CommunityResolverABI.json +506 -506
  6. package/core/abi/Donations.json +251 -251
  7. package/core/abi/EAS.json +1 -1
  8. package/core/abi/MultiAttester.json +746 -746
  9. package/core/abi/ProjectResolver.json +574 -574
  10. package/core/abi/SchemaRegistry.json +1 -1
  11. package/core/abi/index.ts +21 -0
  12. package/core/class/AllGapSchemas.ts +21 -0
  13. package/core/class/Attestation.ts +429 -0
  14. package/core/class/Fetcher.ts +224 -0
  15. package/core/class/GAP.ts +481 -0
  16. package/core/class/GapSchema.ts +93 -0
  17. package/core/class/Gelato/{Gelato.js → Gelato.ts} +23 -0
  18. package/core/class/GrantProgramRegistry/Allo.ts +188 -0
  19. package/core/class/GrantProgramRegistry/AlloRegistry.ts +101 -0
  20. package/core/class/GraphQL/AxiosGQL.ts +29 -0
  21. package/core/class/GraphQL/EASClient.ts +34 -0
  22. package/core/class/GraphQL/GapEasClient.ts +869 -0
  23. package/core/class/Schema.ts +659 -0
  24. package/core/class/SchemaError.ts +42 -0
  25. package/core/class/contract/GapContract.ts +457 -0
  26. package/core/class/entities/Community.ts +148 -0
  27. package/core/class/entities/ContributorProfile.ts +108 -0
  28. package/core/class/entities/Grant.ts +321 -0
  29. package/core/class/entities/GrantUpdate.ts +187 -0
  30. package/core/class/entities/MemberOf.ts +52 -0
  31. package/core/class/entities/Milestone.ts +898 -0
  32. package/core/class/entities/Project.ts +672 -0
  33. package/core/class/entities/ProjectImpact.ts +170 -0
  34. package/core/class/entities/ProjectMilestone.ts +254 -0
  35. package/core/class/entities/ProjectPointer.ts +39 -0
  36. package/core/class/entities/ProjectUpdate.ts +176 -0
  37. package/core/class/entities/Track.ts +32 -0
  38. package/core/class/karma-indexer/GapIndexerClient.ts +383 -0
  39. package/core/class/karma-indexer/api/GapIndexerApi.ts +446 -0
  40. package/core/class/karma-indexer/api/types.ts +313 -0
  41. package/core/class/remote-storage/IpfsStorage.ts +76 -0
  42. package/core/class/remote-storage/RemoteStorage.ts +65 -0
  43. package/core/class/types/allo.ts +93 -0
  44. package/core/class/types/attestations.ts +223 -0
  45. package/core/consts.ts +775 -0
  46. package/core/scripts/create-grant.ts +102 -0
  47. package/core/scripts/create-program.ts +43 -0
  48. package/core/scripts/create-schemas.ts +65 -0
  49. package/core/scripts/deploy.ts +65 -0
  50. package/core/scripts/index.ts +1 -0
  51. package/core/scripts/milestone-multi-grants.ts +125 -0
  52. package/core/shared/types.ts +13 -0
  53. package/core/types.ts +224 -0
  54. package/core/utils/gelato/send-gelato-txn.ts +114 -0
  55. package/core/utils/gelato/sponsor-handler.ts +77 -0
  56. package/core/utils/gelato/watch-gelato-txn.ts +67 -0
  57. package/core/utils/get-date.ts +3 -0
  58. package/core/utils/get-ipfs-data.ts +13 -0
  59. package/core/utils/get-web3-provider.ts +18 -0
  60. package/core/utils/gql-queries.ts +133 -0
  61. package/core/utils/map-filter.ts +21 -0
  62. package/core/utils/serialize-bigint.ts +7 -0
  63. package/core/utils/to-unix.ts +18 -0
  64. package/create-community-example.ts +119 -0
  65. package/csv-upload/README.md +74 -0
  66. package/csv-upload/config.ts +41 -0
  67. package/csv-upload/example.csv +2 -0
  68. package/csv-upload/keys.example.json +8 -0
  69. package/csv-upload/scripts/run.ts +417 -0
  70. package/csv-upload/types.ts +39 -0
  71. package/docs/.gitkeep +0 -0
  72. package/docs/images/attestation-architecture.png +0 -0
  73. package/docs/images/dfd-get-projects.png +0 -0
  74. package/gap-schema.yaml +155 -0
  75. package/milestone-workflow-example.ts +353 -0
  76. package/package.json +45 -39
  77. package/readme.md +872 -0
  78. package/schemas/.gitkeep +0 -0
  79. package/schemas/GAP-schemas-1692135812877.json +33 -0
  80. package/test-file-indexer-api.ts +25 -0
  81. package/tsconfig.json +26 -0
  82. package/core/abi/index.d.ts +0 -1114
  83. package/core/abi/index.js +0 -26
  84. package/core/class/AllGapSchemas.d.ts +0 -9
  85. package/core/class/AllGapSchemas.js +0 -19
  86. package/core/class/Attestation.d.ts +0 -173
  87. package/core/class/Attestation.js +0 -333
  88. package/core/class/Fetcher.d.ts +0 -175
  89. package/core/class/Fetcher.js +0 -13
  90. package/core/class/GAP.d.ts +0 -254
  91. package/core/class/GAP.js +0 -289
  92. package/core/class/GapSchema.d.ts +0 -34
  93. package/core/class/GapSchema.js +0 -62
  94. package/core/class/GrantProgramRegistry/Allo.d.ts +0 -17
  95. package/core/class/GrantProgramRegistry/Allo.js +0 -137
  96. package/core/class/GrantProgramRegistry/AlloRegistry.d.ts +0 -15
  97. package/core/class/GrantProgramRegistry/AlloRegistry.js +0 -70
  98. package/core/class/GraphQL/AxiosGQL.d.ts +0 -6
  99. package/core/class/GraphQL/AxiosGQL.js +0 -25
  100. package/core/class/GraphQL/EASClient.d.ts +0 -16
  101. package/core/class/GraphQL/EASClient.js +0 -26
  102. package/core/class/GraphQL/GapEasClient.d.ts +0 -71
  103. package/core/class/GraphQL/GapEasClient.js +0 -451
  104. package/core/class/GraphQL/index.js +0 -19
  105. package/core/class/Schema.d.ts +0 -233
  106. package/core/class/Schema.js +0 -488
  107. package/core/class/SchemaError.d.ts +0 -30
  108. package/core/class/SchemaError.js +0 -39
  109. package/core/class/contract/GapContract.d.ts +0 -102
  110. package/core/class/contract/GapContract.js +0 -285
  111. package/core/class/entities/Community.d.ts +0 -34
  112. package/core/class/entities/Community.js +0 -109
  113. package/core/class/entities/ContributorProfile.d.ts +0 -41
  114. package/core/class/entities/ContributorProfile.js +0 -69
  115. package/core/class/entities/Grant.d.ts +0 -54
  116. package/core/class/entities/Grant.js +0 -223
  117. package/core/class/entities/GrantUpdate.d.ts +0 -40
  118. package/core/class/entities/GrantUpdate.js +0 -114
  119. package/core/class/entities/MemberOf.d.ts +0 -11
  120. package/core/class/entities/MemberOf.js +0 -33
  121. package/core/class/entities/Milestone.d.ts +0 -168
  122. package/core/class/entities/Milestone.js +0 -657
  123. package/core/class/entities/Project.d.ts +0 -92
  124. package/core/class/entities/Project.js +0 -418
  125. package/core/class/entities/ProjectImpact.d.ts +0 -50
  126. package/core/class/entities/ProjectImpact.js +0 -112
  127. package/core/class/entities/ProjectMilestone.d.ts +0 -60
  128. package/core/class/entities/ProjectMilestone.js +0 -174
  129. package/core/class/entities/ProjectPointer.d.ts +0 -12
  130. package/core/class/entities/ProjectPointer.js +0 -22
  131. package/core/class/entities/ProjectUpdate.d.ts +0 -50
  132. package/core/class/entities/ProjectUpdate.js +0 -110
  133. package/core/class/entities/Track.d.ts +0 -16
  134. package/core/class/entities/Track.js +0 -21
  135. package/core/class/entities/index.js +0 -26
  136. package/core/class/index.js +0 -26
  137. package/core/class/karma-indexer/GapIndexerClient.d.ts +0 -66
  138. package/core/class/karma-indexer/GapIndexerClient.js +0 -207
  139. package/core/class/karma-indexer/api/GapIndexerApi.d.ts +0 -73
  140. package/core/class/karma-indexer/api/GapIndexerApi.js +0 -256
  141. package/core/class/karma-indexer/api/types.d.ts +0 -295
  142. package/core/class/karma-indexer/api/types.js +0 -2
  143. package/core/class/remote-storage/IpfsStorage.d.ts +0 -23
  144. package/core/class/remote-storage/IpfsStorage.js +0 -56
  145. package/core/class/remote-storage/RemoteStorage.d.ts +0 -41
  146. package/core/class/remote-storage/RemoteStorage.js +0 -38
  147. package/core/class/types/allo.d.ts +0 -78
  148. package/core/class/types/allo.js +0 -2
  149. package/core/class/types/attestations.d.ts +0 -168
  150. package/core/class/types/attestations.js +0 -66
  151. package/core/consts.d.ts +0 -48
  152. package/core/consts.js +0 -641
  153. package/core/index.js +0 -24
  154. package/core/shared/types.d.ts +0 -6
  155. package/core/shared/types.js +0 -2
  156. package/core/types.d.ts +0 -131
  157. package/core/types.js +0 -13
  158. package/core/utils/gelato/index.js +0 -19
  159. package/core/utils/gelato/send-gelato-txn.d.ts +0 -55
  160. package/core/utils/gelato/send-gelato-txn.js +0 -100
  161. package/core/utils/gelato/sponsor-handler.d.ts +0 -9
  162. package/core/utils/gelato/sponsor-handler.js +0 -60
  163. package/core/utils/gelato/watch-gelato-txn.d.ts +0 -7
  164. package/core/utils/gelato/watch-gelato-txn.js +0 -63
  165. package/core/utils/get-date.d.ts +0 -1
  166. package/core/utils/get-date.js +0 -7
  167. package/core/utils/get-ipfs-data.d.ts +0 -1
  168. package/core/utils/get-ipfs-data.js +0 -20
  169. package/core/utils/get-web3-provider.d.ts +0 -2
  170. package/core/utils/get-web3-provider.js +0 -18
  171. package/core/utils/gql-queries.d.ts +0 -12
  172. package/core/utils/gql-queries.js +0 -90
  173. package/core/utils/index.js +0 -23
  174. package/core/utils/map-filter.d.ts +0 -8
  175. package/core/utils/map-filter.js +0 -20
  176. package/core/utils/serialize-bigint.d.ts +0 -1
  177. package/core/utils/serialize-bigint.js +0 -8
  178. package/core/utils/to-unix.d.ts +0 -1
  179. package/core/utils/to-unix.js +0 -25
  180. package/index.js +0 -17
  181. /package/core/class/GraphQL/{index.d.ts → index.ts} +0 -0
  182. /package/core/class/entities/{index.d.ts → index.ts} +0 -0
  183. /package/core/class/{index.d.ts → index.ts} +0 -0
  184. /package/core/{index.d.ts → index.ts} +0 -0
  185. /package/core/utils/gelato/{index.d.ts → index.ts} +0 -0
  186. /package/core/utils/{index.d.ts → index.ts} +0 -0
  187. /package/{core/class/Gelato/Gelato.d.ts → csv-upload/.gitkeep} +0 -0
  188. /package/{index.d.ts → index.ts} +0 -0
@@ -1 +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" } } } }
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,21 @@
1
+ import AirdropNFT from "./AirdropNFT.json";
2
+ import Allo from "./Allo.json";
3
+ import AlloRegistry from "./AlloRegistry.json";
4
+ import CommunityResolverABI from "./CommunityResolverABI.json";
5
+ import Donations from "./Donations.json";
6
+ import EAS from "./EAS.json";
7
+ import MultiAttester from "./MultiAttester.json";
8
+ import ProjectResolver from "./ProjectResolver.json";
9
+ import SchemaRegistry from "./SchemaRegistry.json";
10
+
11
+ export const abis = {
12
+ AirdropNFT,
13
+ Allo,
14
+ AlloRegistry,
15
+ CommunityResolverABI,
16
+ Donations,
17
+ EAS,
18
+ MultiAttester,
19
+ ProjectResolver,
20
+ SchemaRegistry,
21
+ };
@@ -0,0 +1,21 @@
1
+ import { MountEntities, Networks } from "../../core/consts";
2
+ import { SchemaInterface, TNetwork, TSchemaName } from "../types";
3
+ import { GAP } from "./GAP";
4
+ import { GapSchema } from "./GapSchema";
5
+
6
+ export class AllGapSchemas {
7
+ public allSchemas: { [network: string]: SchemaInterface<TSchemaName>[] } = {};
8
+
9
+ constructor() {
10
+ Object.keys(Networks).forEach((network) => {
11
+ this.allSchemas[network] = Object.values(
12
+ MountEntities(Networks[network])
13
+ );
14
+ });
15
+ }
16
+
17
+ findSchema(name: TSchemaName, network: TNetwork) {
18
+ const schema = this.allSchemas[network].find((s) => s.name === name);
19
+ return new GapSchema(schema, GAP.getInstance({ network }), false, false);
20
+ }
21
+ }
@@ -0,0 +1,429 @@
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
+ import { IpfsStorage } from "./remote-storage/IpfsStorage";
24
+ import { AttestationWithTx } from "./types/attestations";
25
+
26
+ export interface AttestationArgs<T = unknown, S extends Schema = Schema> {
27
+ data: T | string;
28
+ schema: S;
29
+ uid?: Hex;
30
+ refUID?: Hex;
31
+ attester?: Hex;
32
+ recipient: Hex;
33
+ revoked?: boolean;
34
+ revocationTime?: Date | number;
35
+ createdAt?: Date | number;
36
+ chainID?: number;
37
+ }
38
+
39
+ /**
40
+ * Represents the EAS Attestation and provides methods to manage attestations.
41
+ * @example
42
+ *
43
+ * ```ts
44
+ * const grantee = new Attestation({
45
+ * schema: Schema.get("Grantee", "network-name"), // Use this.schema.gap.findSchema("SchemaName") if using default GAP schemas
46
+ * data: { grantee: true },
47
+ * uid: "0xabc123",
48
+ * });
49
+ *
50
+ * const granteeDetails = new Attestation({
51
+ * schema: Schema.get("GranteeDetails", "optimism"),
52
+ * data: {
53
+ * name: "John Doe",
54
+ * description: "A description",
55
+ * imageURL: "https://example.com/image.png",
56
+ * },
57
+ * uid: "0xab234"
58
+ * );
59
+ *
60
+ * // Return the refferenced attestation
61
+ * const ref = granteeDetails.reference<Grantee>();
62
+ *
63
+ * // Revoke attestation
64
+ * granteeDetails.revoke();
65
+ *
66
+ * // Get attestation data from a decoded JSON string.
67
+ * granteeDetails.fromDecodedSchema(granteeDetails.data);
68
+ * ```
69
+ */
70
+ export class Attestation<T = unknown, S extends Schema = GapSchema>
71
+ implements AttestationArgs<T, S>
72
+ {
73
+ readonly schema: S;
74
+ private _data: T;
75
+
76
+ protected _uid: Hex;
77
+ readonly refUID?: Hex;
78
+ readonly attester?: Hex;
79
+ readonly recipient: Hex;
80
+ readonly revoked?: boolean;
81
+ readonly revocationTime?: Date;
82
+ readonly createdAt: Date;
83
+ private _chainID: number;
84
+
85
+ private _reference?: Attestation;
86
+
87
+ constructor(args: AttestationArgs<T, S>) {
88
+ this.schema = args.schema;
89
+
90
+ this._data = this.fromDecodedSchema(args.data);
91
+
92
+ this.setValues(this._data);
93
+ this._uid = args.uid || nullRef;
94
+ this.refUID = args.refUID || nullRef;
95
+ this.attester = args.attester;
96
+ this.recipient = args.recipient;
97
+ this.revoked = args.revoked;
98
+ this.revocationTime = getDate(args.revocationTime);
99
+ this.createdAt = getDate(args.createdAt || Date.now() / 1000);
100
+ this._chainID = args.chainID || Networks[this.schema.gap.network].chainId;
101
+ }
102
+
103
+ /**
104
+ * Encodes the schema.
105
+ * @returns
106
+ */
107
+ encodeSchema(schema: SchemaItem[]) {
108
+ return this.schema.encode(schema);
109
+ }
110
+
111
+ /**
112
+ * Sets a field in the schema.
113
+ */
114
+ setValue<K extends keyof T>(key: K, value: SchemaValue) {
115
+ this.schema.setValue(key as string, value);
116
+ }
117
+
118
+ /**
119
+ * Set attestation values to be uploaded.
120
+ * @param values
121
+ */
122
+ setValues(values: T) {
123
+ const isJsonSchema = this.schema.isJsonSchema();
124
+ if (isJsonSchema) this.schema.setValue("json", JSON.stringify(values));
125
+ this._data = values;
126
+
127
+ Object.entries(values).forEach(([key, value]) => {
128
+ this[key] = value;
129
+ if (!isJsonSchema) this.setValue(key as keyof T, value.value || value);
130
+ });
131
+ }
132
+
133
+ /**
134
+ * Returns the referenced attestation
135
+ */
136
+ reference<Ref = unknown, RefSchema extends Schema = Schema>() {
137
+ return this._reference as Attestation<Ref, RefSchema>;
138
+ }
139
+
140
+ /**
141
+ * Returns the attestation data as a JSON string.
142
+ * @param data
143
+ * @returns
144
+ */
145
+ fromDecodedSchema(data: T | JSONStr): T {
146
+ return typeof data === "string"
147
+ ? Attestation.fromDecodedSchema<T>(data)
148
+ : data;
149
+ }
150
+
151
+ /**
152
+ * Revokes this attestation.
153
+ * @param eas
154
+ * @param signer
155
+ * @returns
156
+ */
157
+ async revoke(
158
+ signer: SignerOrProvider,
159
+ callback?: Function
160
+ ): Promise<AttestationWithTx> {
161
+ try {
162
+ callback?.("preparing");
163
+ const { tx } = await GapContract.multiRevoke(signer, [
164
+ {
165
+ data: [
166
+ {
167
+ uid: this.uid,
168
+ value: 0n,
169
+ },
170
+ ],
171
+ schema: this.schema.uid,
172
+ },
173
+ ]).then((res) => {
174
+ callback?.("confirmed");
175
+ return res;
176
+ });
177
+ return { tx, uids: [this.uid] };
178
+ } catch (error) {
179
+ console.error(error);
180
+ throw new SchemaError(
181
+ "REVOKE_ERROR",
182
+ "Error revoking attestation.",
183
+ error
184
+ );
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Attests the data using the specified signer and schema.
190
+ * @param signer - The signer or provider to use for attestation.
191
+ * @param args - Additional arguments to pass to the schema's `attest` method.
192
+ * @returns A Promise that resolves to the UID of the attestation.
193
+ * @throws An `AttestationError` if an error occurs during attestation.
194
+ */
195
+ async attest(
196
+ signer: SignerOrProvider,
197
+ ...args: unknown[]
198
+ ): Promise<AttestationWithTx> {
199
+ const callback =
200
+ typeof args[args.length - 1] === "function"
201
+ ? (args.pop() as (status: string) => void)
202
+ : null;
203
+ console.log(`Attesting ${this.schema.name}`);
204
+ try {
205
+ const { tx, uids } = await this.schema.attest<T>({
206
+ data: this.data,
207
+ to: this.recipient,
208
+ refUID: this.refUID,
209
+ signer,
210
+ callback: callback,
211
+ });
212
+
213
+ this._uid = uids[0];
214
+ console.log(`Attested ${this.schema.name} with UID ${this.uid}`);
215
+ return { tx, uids };
216
+ } catch (error) {
217
+ console.error(error);
218
+ throw new AttestationError(
219
+ "ATTEST_ERROR",
220
+ "Error during attestation.",
221
+ error
222
+ );
223
+ }
224
+ }
225
+
226
+ /**
227
+ * Validates the payload.
228
+ *
229
+ * If an attestation should have anything
230
+ * specifically explicit, it should be implemented in
231
+ * order to avoid errors.
232
+ * @returns
233
+ */
234
+ protected assertPayload() {
235
+ return true;
236
+ }
237
+
238
+ /**
239
+ * Get the multi attestation payload for the referred index.
240
+ *
241
+ * The index should be the array position this payload wants
242
+ * to reference.
243
+ *
244
+ * E.g:
245
+ *
246
+ * 1. Project is index 0;
247
+ * 2. Project details is index 1;
248
+ * 3. Grant is index 2;
249
+ * 4. Grant details is index 3;
250
+ * 5. Milestone is index 4;
251
+ *
252
+ * `[Project, projectDetails, grant, grantDetails, milestone]`
253
+ *
254
+ * -> Project.payloadFor(0); // refs itself (no effect)
255
+ *
256
+ * -> project.details.payloadFor(0); // ref project
257
+ *
258
+ * -> grant.payloadFor(0); // ref project
259
+ *
260
+ * -> grant.details.payloadFor(2); // ref grant
261
+ *
262
+ * -> milestone.payloadFor(2); // ref grant
263
+ *
264
+ *
265
+ * @param refIdx
266
+ * @returns [Encoded payload, Raw payload]
267
+ */
268
+ async payloadFor(refIdx: number): Promise<{
269
+ payload: MultiAttestData;
270
+ raw: MultiAttestData;
271
+ }> {
272
+ this.assertPayload();
273
+
274
+ if (this.schema.isJsonSchema()) {
275
+ if ((this as any).type) {
276
+ (this._data as T & { type: string }).type = (this as any).type;
277
+ this.schema.setValue("json", JSON.stringify(this._data));
278
+ }
279
+ }
280
+
281
+ const payload = (encode = true): MultiAttestData => ({
282
+ uid: nullRef,
283
+ refIdx,
284
+ multiRequest: {
285
+ schema: this.schema.uid,
286
+ data: [
287
+ {
288
+ refUID: this.refUID,
289
+ expirationTime: 0n,
290
+ revocable: this.schema.revocable || true,
291
+ value: 0n,
292
+ data: (encode ? this.schema.encode() : this.schema.schema) as any,
293
+ recipient: this.recipient,
294
+ },
295
+ ],
296
+ },
297
+ });
298
+ return {
299
+ payload: payload(),
300
+ raw: payload(false),
301
+ };
302
+ }
303
+
304
+ /**
305
+ * Returns an Attestation instance from a JSON decoded schema.
306
+ * @param data
307
+ * @returns
308
+ */
309
+ static fromDecodedSchema<T>(data: JSONStr): T {
310
+ try {
311
+ const parsed: SchemaDecodedItem[] = JSON.parse(data);
312
+
313
+ if (data.length < 2 && !/\{.*\}/gim.test(data)) return {} as T;
314
+ if (parsed.length === 1 && parsed[0].name === "json") {
315
+ const { value } = parsed[0];
316
+ return (
317
+ typeof value.value === "string"
318
+ ? JSON.parse(value.value)
319
+ : value.value
320
+ ) as T;
321
+ }
322
+
323
+ if (parsed && Array.isArray(parsed)) {
324
+ return parsed.reduce((acc, curr) => {
325
+ const { value } = curr.value;
326
+ if (curr.type.includes("uint")) {
327
+ acc[curr.name] = ["string", "bigint"].includes(typeof value)
328
+ ? BigInt(value as any)
329
+ : Number(value);
330
+ } else acc[curr.name] = value;
331
+ return acc;
332
+ }, {}) as T;
333
+ }
334
+
335
+ throw new SchemaError(
336
+ "INVALID_DATA",
337
+ "Data must be a valid JSON array string."
338
+ );
339
+ } catch (error) {
340
+ console.error(error);
341
+ throw new SchemaError(
342
+ "INVALID_DATA",
343
+ "Data must be a valid JSON string.",
344
+ error
345
+ );
346
+ }
347
+ }
348
+
349
+ /**
350
+ * Transform attestation interface-based into class-based.
351
+ */
352
+ static fromInterface<T extends Attestation = Attestation>(
353
+ attestations: IAttestation[],
354
+ network: TNetwork
355
+ ) {
356
+ const result: T[] = [];
357
+ attestations.forEach((attestation) => {
358
+ try {
359
+ const schema = Schema.get(attestation.schemaId, network);
360
+ result.push(
361
+ <T>new Attestation({
362
+ ...attestation,
363
+ schema,
364
+ chainID: Networks[network].chainId,
365
+ data: attestation.decodedDataJson,
366
+ })
367
+ );
368
+ } catch (e) {
369
+ console.log(e);
370
+ }
371
+ });
372
+ return result;
373
+ }
374
+
375
+ /**
376
+ * Asserts if schema is valid.
377
+ * > Does not check refUID if `strict = false`. To check refUID use `Schema.validate()`
378
+ * @param args
379
+ */
380
+ protected assert(args: AttestationArgs, strict = false) {
381
+ const { schema, uid } = args;
382
+
383
+ if (!schema || !(schema instanceof Schema)) {
384
+ throw new SchemaError("MISSING_FIELD", "Schema must be an array.");
385
+ }
386
+
387
+ if (!uid) {
388
+ throw new SchemaError("MISSING_FIELD", "Schema uid is required");
389
+ }
390
+
391
+ if (strict) Schema.validate(this.schema.gap.network);
392
+ }
393
+
394
+ get chainID() {
395
+ return this._chainID;
396
+ }
397
+
398
+ get data(): T {
399
+ return this._data;
400
+ }
401
+
402
+ get uid() {
403
+ return this._uid;
404
+ }
405
+
406
+ set uid(uid: Hex) {
407
+ this._uid = uid;
408
+ }
409
+
410
+ /**
411
+ * Create attestation to serve as Attestation data.
412
+ * @param data Data to attest
413
+ * @param schema selected schema
414
+ * @param from attester
415
+ * @param to recipient
416
+ * @returns
417
+ */
418
+ static factory<T = unknown>(data: T, schema: Schema, from: Hex, to: Hex) {
419
+ return new Attestation({
420
+ data: data,
421
+ recipient: to,
422
+ attester: from,
423
+ schema,
424
+ uid: "0x0",
425
+ createdAt: new Date(),
426
+ chainID: Networks[schema.gap.network].chainId,
427
+ });
428
+ }
429
+ }