From 556c0265d9d65f1d55e3a1d2bb2edebda38d53c2 Mon Sep 17 00:00:00 2001 From: Satyajeet Kolhapure Date: Fri, 15 Nov 2024 11:07:22 +0000 Subject: [PATCH] fixed review comments --- contracts/src/ModuleRegistry.sol | 2 +- contracts/src/PortalRegistry.sol | 1 + contracts/src/SchemaRegistry.sol | 2 +- sdk/doc/cli-examples.md | 4 -- sdk/examples/module/moduleExamples.ts | 5 -- sdk/examples/schema/schemaExamples.ts | 5 -- sdk/src/dataMapper/ModuleDataMapper.ts | 24 +++----- sdk/src/dataMapper/PortalDataMapper.ts | 4 ++ sdk/src/dataMapper/SchemaDataMapper.ts | 6 +- sdk/src/dataMapper/UtilsDataMapper.test.ts | 71 ---------------------- sdk/src/dataMapper/UtilsDataMapper.ts | 33 ---------- 11 files changed, 16 insertions(+), 141 deletions(-) diff --git a/contracts/src/ModuleRegistry.sol b/contracts/src/ModuleRegistry.sol index f2ad6e1e..c0e2bcce 100644 --- a/contracts/src/ModuleRegistry.sol +++ b/contracts/src/ModuleRegistry.sol @@ -21,7 +21,7 @@ contract ModuleRegistry is OwnableUpgradeable { IRouter public router; /// @dev The list of Modules, accessed by their address mapping(address id => Module module) public modules; - /// @dev The list of Module addresses + /// @dev Deprecated: The `moduleAddresses` variable is no longer used. It was used to store the modules addresses. address[] public moduleAddresses; /// @notice Error thrown when an invalid Router address is given diff --git a/contracts/src/PortalRegistry.sol b/contracts/src/PortalRegistry.sol index 2f684173..c8da6fea 100644 --- a/contracts/src/PortalRegistry.sol +++ b/contracts/src/PortalRegistry.sol @@ -23,6 +23,7 @@ contract PortalRegistry is OwnableUpgradeable { mapping(address issuerAddress => bool isIssuer) private issuers; + /// @dev Deprecated: The `portalAddresses` variable is no longer used. It was used to store the portals addresses. address[] private portalAddresses; bool private isTestnet; diff --git a/contracts/src/SchemaRegistry.sol b/contracts/src/SchemaRegistry.sol index b077c9d3..42d418dc 100644 --- a/contracts/src/SchemaRegistry.sol +++ b/contracts/src/SchemaRegistry.sol @@ -16,7 +16,7 @@ contract SchemaRegistry is OwnableUpgradeable { IRouter public router; /// @dev The list of Schemas, accessed by their ID mapping(bytes32 id => Schema schema) private schemas; - /// @dev The list of Schema IDs + /// @dev Deprecated: The `schemaIds` variable is no longer used. It was used to store the ids of schemas. bytes32[] public schemaIds; /// @dev Associates a Schema ID with the address of the Issuer who created it mapping(bytes32 id => address issuer) private schemasIssuers; diff --git a/sdk/doc/cli-examples.md b/sdk/doc/cli-examples.md index 24a492f3..f89d5d6f 100644 --- a/sdk/doc/cli-examples.md +++ b/sdk/doc/cli-examples.md @@ -117,8 +117,6 @@ pnpm module isRegistered "0x8DcC1F7e746D6071Eb3ee9012aFB6c707bFf82a5" - pnpm module getModuleAddress 0 - pnpm module getModule "0x8DcC1F7e746D6071Eb3ee9012aFB6c707bFf82a5" ``` @@ -151,8 +149,6 @@ pnpm schema getSchemasNumber pnpm schema isRegistered "0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738" - - pnpm schema getSchemaIds 0 ``` diff --git a/sdk/examples/module/moduleExamples.ts b/sdk/examples/module/moduleExamples.ts index 2bbe9ff6..1f1d99c5 100644 --- a/sdk/examples/module/moduleExamples.ts +++ b/sdk/examples/module/moduleExamples.ts @@ -182,11 +182,6 @@ export default class ModuleExamples { console.log(await this.veraxSdk.module.isRegistered(moduleAddress)); } - if (methodName.toLowerCase() == "getModuleAddress".toLowerCase() || methodName == "") { - const index: number = argv === "" ? 0 : (argv as unknown as number); - console.log(await this.veraxSdk.module.getModuleAddress(index)); - } - if (methodName.toLowerCase() == "getModule".toLowerCase() || methodName == "") { const moduleAddress: Address = argv === "" ? "0x8DcC1F7e746D6071Eb3ee9012aFB6c707bFf82a5" : (argv as Address); console.log(await this.veraxSdk.module.getModule(moduleAddress)); diff --git a/sdk/examples/schema/schemaExamples.ts b/sdk/examples/schema/schemaExamples.ts index af390758..7f001ddd 100644 --- a/sdk/examples/schema/schemaExamples.ts +++ b/sdk/examples/schema/schemaExamples.ts @@ -93,10 +93,5 @@ export default class SchemaExamples { argv === "" ? "0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738" : argv; console.log(await this.veraxSdk.schema.isRegistered(schemaId)); } - - if (methodName.toLowerCase() == "getSchemaIds".toLowerCase() || methodName == "") { - const index: number = argv === "" ? 0 : (argv as unknown as number); - console.log(await this.veraxSdk.schema.getSchemaIds(index)); - } } } diff --git a/sdk/src/dataMapper/ModuleDataMapper.ts b/sdk/src/dataMapper/ModuleDataMapper.ts index 0e0bddd5..a2f34187 100644 --- a/sdk/src/dataMapper/ModuleDataMapper.ts +++ b/sdk/src/dataMapper/ModuleDataMapper.ts @@ -18,7 +18,7 @@ export default class ModuleDataMapper extends BaseDataMapper ({ decode: jest.fn(), })); -jest.mock("../utils/graphClientHelper", () => ({ - subgraphCall: jest.fn(), -})); - describe("UtilsDataMapper", () => { let utilsDataMapper: UtilsDataMapper; const mockConf: Conf = { @@ -35,57 +30,6 @@ describe("UtilsDataMapper", () => { utilsDataMapper = new UtilsDataMapper(mockConf, mockWeb3Client, mockVeraxSdk, mockWalletClient); }); - describe("getModulesNumber", () => { - it("should return the modules counter from subgraph", async () => { - const mockModulesCount = 10; - (subgraphCall as jest.Mock).mockResolvedValue({ - data: { data: { counters: [{ modules: mockModulesCount }] } }, - status: 200, - }); - - const result = await utilsDataMapper.getModulesNumber(); - expect(result).toBe(mockModulesCount); - expect(subgraphCall).toHaveBeenCalledWith( - `query get_module_counter { counters { modules } }`, - mockConf.subgraphUrl, - ); - }); - }); - - describe("getPortalsCount", () => { - it("should return the portals counter from subgraph", async () => { - const mockPortalsCount = 5; - (subgraphCall as jest.Mock).mockResolvedValue({ - data: { data: { counters: [{ portals: mockPortalsCount }] } }, - status: 200, - }); - - const result = await utilsDataMapper.getPortalsCount(); - expect(result).toBe(mockPortalsCount); - expect(subgraphCall).toHaveBeenCalledWith( - `query get_portal_counter { counters { portals } }`, - mockConf.subgraphUrl, - ); - }); - }); - - describe("getSchemasNumber", () => { - it("should return the schemas counter from subgraph", async () => { - const mockSchemasCount = 7; - (subgraphCall as jest.Mock).mockResolvedValue({ - data: { data: { counters: [{ schemas: mockSchemasCount }] } }, - status: 200, - }); - - const result = await utilsDataMapper.getSchemasNumber(); - expect(result).toBe(mockSchemasCount); - expect(subgraphCall).toHaveBeenCalledWith( - `query get_schema_counter { counters { schemas } }`, - mockConf.subgraphUrl, - ); - }); - }); - describe("getVersionNumber", () => { it("should call web3Client to get the version number", async () => { const mockVersion = "1.0.0"; @@ -101,21 +45,6 @@ describe("UtilsDataMapper", () => { }); }); - describe("getAttestationIdCounter", () => { - it("should call web3Client to get the attestation ID counter", async () => { - const mockCounter = 100; - (mockWeb3Client.readContract as jest.Mock).mockResolvedValue(mockCounter); - - const result = await utilsDataMapper.getAttestationIdCounter(); - expect(result).toBe(mockCounter); - expect(mockWeb3Client.readContract).toHaveBeenCalledWith({ - abi: abiAttestationRegistry, - address: mockConf.attestationRegistryAddress, - functionName: "getAttestationIdCounter", - }); - }); - }); - describe("encode", () => { it("should call encode with correct arguments", () => { const schema = "schema"; diff --git a/sdk/src/dataMapper/UtilsDataMapper.ts b/sdk/src/dataMapper/UtilsDataMapper.ts index 70b95146..5af46928 100644 --- a/sdk/src/dataMapper/UtilsDataMapper.ts +++ b/sdk/src/dataMapper/UtilsDataMapper.ts @@ -2,7 +2,6 @@ import BaseDataMapper from "./BaseDataMapper"; import { abiAttestationRegistry } from "../abi/AttestationRegistry"; import { decode, encode } from "../utils/abiCoder"; import { Hex } from "viem"; -import { subgraphCall } from "../utils/graphClientHelper"; export default class UtilsDataMapper extends BaseDataMapper { typeName = "counter"; @@ -13,18 +12,6 @@ export default class UtilsDataMapper extends BaseDataMapper