From 7d3ee9b7142d963a768c49089a644b35f2d9d6b4 Mon Sep 17 00:00:00 2001 From: Satyajeet Kolhapure <77279246+satyajeetkolhapure@users.noreply.github.com> Date: Wed, 22 Nov 2023 13:33:51 +0000 Subject: [PATCH] fix: Export our own types through the SDK (#402) Co-authored-by: Satyajeet Kolhapure --- explorer/src/App.tsx | 2 +- sdk/README.md | 2 +- sdk/examples/attestation/attestationExamples.ts | 2 +- sdk/examples/attestation/index.ts | 2 +- sdk/examples/module/index.ts | 2 +- sdk/examples/module/moduleExamples.ts | 2 +- sdk/examples/portal/index.ts | 2 +- sdk/examples/portal/portalExamples.ts | 2 +- sdk/examples/schema/index.ts | 2 +- sdk/examples/schema/schemaExamples.ts | 2 +- sdk/examples/utils/decode.ts | 2 +- sdk/examples/utils/encode.ts | 2 +- sdk/examples/utils/getAttestationIdCounter.ts | 2 +- sdk/examples/utils/getModulesNumber.ts | 2 +- sdk/examples/utils/getPortalsCount.ts | 2 +- sdk/examples/utils/getRelatedAttestation.ts | 2 +- sdk/examples/utils/getSchemasNumber.ts | 2 +- sdk/examples/utils/getVersionNumber.ts | 2 +- sdk/package.json | 4 ++-- sdk/src/VeraxSdk.ts | 4 +++- sdk/src/dataMapper/BaseDataMapper.ts | 2 +- sdk/src/types/{index.d.ts => index.ts} | 5 +++-- sdk/test/integration/Attestation.integration.test.ts | 2 +- sdk/test/integration/Module.integration.test.ts | 2 +- sdk/test/integration/Portal.integration.test.ts | 2 +- sdk/test/integration/Schema.integration.test.ts | 2 +- sdk/tsconfig.build.json | 4 ++++ 27 files changed, 35 insertions(+), 28 deletions(-) rename sdk/src/types/{index.d.ts => index.ts} (95%) create mode 100644 sdk/tsconfig.build.json diff --git a/explorer/src/App.tsx b/explorer/src/App.tsx index 41ed8bff..3e50d8cf 100644 --- a/explorer/src/App.tsx +++ b/explorer/src/App.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import veraxLogo from "./assets/verax-logo-circle.svg"; import "./App.css"; import { ConnectKitButton } from "connectkit"; -import VeraxSdk from "@verax-attestation-registry/verax-sdk"; +import { VeraxSdk } from "@verax-attestation-registry/verax-sdk"; function App() { // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/sdk/README.md b/sdk/README.md index 1ac8bd6c..3546600b 100644 --- a/sdk/README.md +++ b/sdk/README.md @@ -32,7 +32,7 @@ var VeraxSdk = require("@verax-attestation-registry/verax-sdk"); ```typescript // TypeScript -import VeraxSdk from "@verax-attestation-registry/verax-sdk"; +import { VeraxSdk } from "@verax-attestation-registry/verax-sdk"; ``` ### 2. Instantiate VeraxSdk diff --git a/sdk/examples/attestation/attestationExamples.ts b/sdk/examples/attestation/attestationExamples.ts index 80d0d0d4..0df73c96 100644 --- a/sdk/examples/attestation/attestationExamples.ts +++ b/sdk/examples/attestation/attestationExamples.ts @@ -1,5 +1,5 @@ import { Address } from "viem"; -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; export default class AttestationExamples { private veraxSdk: VeraxSdk; diff --git a/sdk/examples/attestation/index.ts b/sdk/examples/attestation/index.ts index 26dd98e8..284ce467 100644 --- a/sdk/examples/attestation/index.ts +++ b/sdk/examples/attestation/index.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; import AttestationExamples from "./attestationExamples"; let argv: string | null | undefined = process.argv[3] as string; diff --git a/sdk/examples/module/index.ts b/sdk/examples/module/index.ts index a29d84da..67564eff 100644 --- a/sdk/examples/module/index.ts +++ b/sdk/examples/module/index.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; import ModuleExamples from "./moduleExamples"; let argv: string | null | undefined = process.argv[3] as string; diff --git a/sdk/examples/module/moduleExamples.ts b/sdk/examples/module/moduleExamples.ts index d102c914..aa43a703 100644 --- a/sdk/examples/module/moduleExamples.ts +++ b/sdk/examples/module/moduleExamples.ts @@ -1,5 +1,5 @@ import { Address } from "viem"; -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; export default class ModuleExamples { private veraxSdk: VeraxSdk; diff --git a/sdk/examples/portal/index.ts b/sdk/examples/portal/index.ts index 446eca30..10afb2fb 100644 --- a/sdk/examples/portal/index.ts +++ b/sdk/examples/portal/index.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; import PortalExamples from "./portalExamples"; let argv: string | null | undefined = process.argv[3] as string; diff --git a/sdk/examples/portal/portalExamples.ts b/sdk/examples/portal/portalExamples.ts index 4742be59..d7862962 100644 --- a/sdk/examples/portal/portalExamples.ts +++ b/sdk/examples/portal/portalExamples.ts @@ -1,5 +1,5 @@ import { Address } from "viem"; -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; export default class PortalExamples { private veraxSdk: VeraxSdk; diff --git a/sdk/examples/schema/index.ts b/sdk/examples/schema/index.ts index 12c0862a..0eef26db 100644 --- a/sdk/examples/schema/index.ts +++ b/sdk/examples/schema/index.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; import PortalExamples from "./schemaExamples"; let argv: string | null | undefined = process.argv[3] as string; diff --git a/sdk/examples/schema/schemaExamples.ts b/sdk/examples/schema/schemaExamples.ts index f7d93288..c3d081ce 100644 --- a/sdk/examples/schema/schemaExamples.ts +++ b/sdk/examples/schema/schemaExamples.ts @@ -1,5 +1,5 @@ import { Address } from "viem"; -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; export default class SchemaExamples { private veraxSdk: VeraxSdk; diff --git a/sdk/examples/utils/decode.ts b/sdk/examples/utils/decode.ts index 901ed506..bb254f7a 100644 --- a/sdk/examples/utils/decode.ts +++ b/sdk/examples/utils/decode.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_TESTNET); diff --git a/sdk/examples/utils/encode.ts b/sdk/examples/utils/encode.ts index d7c9cc70..48f62256 100644 --- a/sdk/examples/utils/encode.ts +++ b/sdk/examples/utils/encode.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_TESTNET); diff --git a/sdk/examples/utils/getAttestationIdCounter.ts b/sdk/examples/utils/getAttestationIdCounter.ts index 0ac7543a..c1cfdfa4 100644 --- a/sdk/examples/utils/getAttestationIdCounter.ts +++ b/sdk/examples/utils/getAttestationIdCounter.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_TESTNET); diff --git a/sdk/examples/utils/getModulesNumber.ts b/sdk/examples/utils/getModulesNumber.ts index 9accdfdb..bd91bdb5 100644 --- a/sdk/examples/utils/getModulesNumber.ts +++ b/sdk/examples/utils/getModulesNumber.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_TESTNET); diff --git a/sdk/examples/utils/getPortalsCount.ts b/sdk/examples/utils/getPortalsCount.ts index 3ad39d5a..403a7a5c 100644 --- a/sdk/examples/utils/getPortalsCount.ts +++ b/sdk/examples/utils/getPortalsCount.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_TESTNET); diff --git a/sdk/examples/utils/getRelatedAttestation.ts b/sdk/examples/utils/getRelatedAttestation.ts index 55fdf8fb..39297726 100644 --- a/sdk/examples/utils/getRelatedAttestation.ts +++ b/sdk/examples/utils/getRelatedAttestation.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_TESTNET); diff --git a/sdk/examples/utils/getSchemasNumber.ts b/sdk/examples/utils/getSchemasNumber.ts index 50b39ebb..edcf7fa7 100644 --- a/sdk/examples/utils/getSchemasNumber.ts +++ b/sdk/examples/utils/getSchemasNumber.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_TESTNET); diff --git a/sdk/examples/utils/getVersionNumber.ts b/sdk/examples/utils/getVersionNumber.ts index 0db375eb..d5ed78bf 100644 --- a/sdk/examples/utils/getVersionNumber.ts +++ b/sdk/examples/utils/getVersionNumber.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_TESTNET); diff --git a/sdk/package.json b/sdk/package.json index bf1bc589..ce5ca379 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@verax-attestation-registry/verax-sdk", - "version": "0.0.13", + "version": "0.0.14", "description": "Verax Attestation Registry SDK to interact with the subgraph and the contracts", "keywords": [ "linea-attestation-registry", @@ -23,7 +23,7 @@ "scripts": { "attestation": "ts-node examples/attestation/index.ts", "clean": "rm -rf ./lib", - "build": "pnpm run clean && tsc", + "build": "pnpm run clean && tsc --p ./tsconfig.build.json", "prepack": "npm run build", "publish:public": "pnpm publish --access public --no-git-checks", "module": "ts-node examples/module/index.ts", diff --git a/sdk/src/VeraxSdk.ts b/sdk/src/VeraxSdk.ts index c7479433..76e1fd5b 100644 --- a/sdk/src/VeraxSdk.ts +++ b/sdk/src/VeraxSdk.ts @@ -9,6 +9,8 @@ import { PrivateKeyAccount, privateKeyToAccount } from "viem/accounts"; import { Conf } from "./types"; import { SDKMode } from "./utils/constants"; +export * from "./types"; + let account: PrivateKeyAccount | Address; if (typeof window === "undefined") { @@ -23,7 +25,7 @@ if (typeof window === "undefined") { }); } -export default class VeraxSdk { +export class VeraxSdk { static DEFAULT_LINEA_MAINNET: Conf = { chain: linea, mode: SDKMode.BACKEND, diff --git a/sdk/src/dataMapper/BaseDataMapper.ts b/sdk/src/dataMapper/BaseDataMapper.ts index 35d7a52c..029131d4 100644 --- a/sdk/src/dataMapper/BaseDataMapper.ts +++ b/sdk/src/dataMapper/BaseDataMapper.ts @@ -1,7 +1,7 @@ import { PublicClient, WalletClient } from "viem"; import { Conf } from "../types"; import { OrderDirection } from "../../.graphclient"; -import VeraxSdk from "../VeraxSdk"; +import { VeraxSdk } from "../VeraxSdk"; import { stringifyWhereClause } from "../utils/graphClientHelper"; import axios from "axios"; diff --git a/sdk/src/types/index.d.ts b/sdk/src/types/index.ts similarity index 95% rename from sdk/src/types/index.d.ts rename to sdk/src/types/index.ts index ac1b32f6..f34f55b4 100644 --- a/sdk/src/types/index.d.ts +++ b/sdk/src/types/index.ts @@ -1,4 +1,5 @@ -import { Address, Chain, EthereumProvider } from "viem"; +import { Address, Chain, EIP1193Provider } from "viem"; +import { SDKMode } from "../utils/constants"; export interface Conf { chain: Chain; @@ -71,6 +72,6 @@ export type OnChainModule = { declare global { interface Window { - ethereum: EthereumProvider; + ethereum: EIP1193Provider; } } diff --git a/sdk/test/integration/Attestation.integration.test.ts b/sdk/test/integration/Attestation.integration.test.ts index 74e81c7f..460a1907 100644 --- a/sdk/test/integration/Attestation.integration.test.ts +++ b/sdk/test/integration/Attestation.integration.test.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; describe("AttestationDataMapper", () => { let veraxSdk: VeraxSdk; diff --git a/sdk/test/integration/Module.integration.test.ts b/sdk/test/integration/Module.integration.test.ts index 92ee7936..0c74af6a 100644 --- a/sdk/test/integration/Module.integration.test.ts +++ b/sdk/test/integration/Module.integration.test.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; describe("ModuleDataMapper", () => { let veraxSdk: VeraxSdk; diff --git a/sdk/test/integration/Portal.integration.test.ts b/sdk/test/integration/Portal.integration.test.ts index bdfff73d..f764daa2 100644 --- a/sdk/test/integration/Portal.integration.test.ts +++ b/sdk/test/integration/Portal.integration.test.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; describe("PortalDataMapper", () => { let veraxSdk: VeraxSdk; diff --git a/sdk/test/integration/Schema.integration.test.ts b/sdk/test/integration/Schema.integration.test.ts index 291ff04a..0978d070 100644 --- a/sdk/test/integration/Schema.integration.test.ts +++ b/sdk/test/integration/Schema.integration.test.ts @@ -1,4 +1,4 @@ -import VeraxSdk from "../../src/VeraxSdk"; +import { VeraxSdk } from "../../src/VeraxSdk"; describe("SchemaDataMapper", () => { let veraxSdk: VeraxSdk; diff --git a/sdk/tsconfig.build.json b/sdk/tsconfig.build.json new file mode 100644 index 00000000..27722617 --- /dev/null +++ b/sdk/tsconfig.build.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "exclude": ["test"] +}