-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add example calls for all the methods the SDK will implement (#…
…268) Co-authored-by: Satyajeet Kolhapure <[email protected]>
- Loading branch information
1 parent
1be2180
commit 6f0f3a1
Showing
23 changed files
with
214 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import VeraxSdk from "../../src/VeraxSdk"; | ||
|
||
export default class AttestationExamples { | ||
private veraxSdk: VeraxSdk; | ||
constructor(_veraxSdk: VeraxSdk) { | ||
this.veraxSdk = _veraxSdk; | ||
} | ||
async run(methodName: string = "") { | ||
if (methodName.toLowerCase() == "findOneById".toLowerCase() || methodName == "") | ||
console.log( | ||
await this.veraxSdk.attestation.findOneById( | ||
"0x00000000000000000000000000000000000000000000000000000000000007b5", | ||
), | ||
); | ||
if (methodName.toLowerCase() == "findBy".toLowerCase() || methodName == "") | ||
console.log( | ||
await this.veraxSdk.attestation.findBy({ | ||
schemaId: "0xd1664d97bd195df77e3d5fe78c1737ab3adaa38bbe52a680d1aa30fa51f186ba", | ||
}), | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import VeraxSdk from "../../src/VeraxSdk"; | ||
import AttestationExamples from "./attestationExamples"; | ||
|
||
const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_TESTNET); | ||
|
||
await new AttestationExamples(veraxSdk).run(process.argv[2]); |
This file was deleted.
Oops, something went wrong.
3 changes: 2 additions & 1 deletion
3
sdk/examples/attestation/findBy.ts → sdk/examples/module/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import VeraxSdk from "../../src/VeraxSdk"; | ||
import ModuleExamples from "./moduleExamples"; | ||
|
||
const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_TESTNET); | ||
|
||
console.log(await veraxSdk.attestation.findBy()); | ||
await new ModuleExamples(veraxSdk).run(process.argv[2]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import VeraxSdk from "../../src/VeraxSdk"; | ||
|
||
export default class ModuleExamples { | ||
private veraxSdk: VeraxSdk; | ||
constructor(_veraxSdk: VeraxSdk) { | ||
this.veraxSdk = _veraxSdk; | ||
} | ||
async run(methodName: string = "") { | ||
if (methodName.toLowerCase() == "findOneById".toLowerCase() || methodName == "") | ||
console.log(await this.veraxSdk.module.findOneById("0xf75be6f9418710fd516fa82afb3aad07e11a0f1b")); | ||
|
||
if (methodName.toLowerCase() == "findBy".toLowerCase() || methodName == "") | ||
console.log(await this.veraxSdk.module.findBy({ name: "SchemaCheckerModule" })); | ||
|
||
if (methodName.toLowerCase() == "register" || methodName == "") console.log(await this.veraxSdk.module.register()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import VeraxSdk from "../../src/VeraxSdk"; | ||
import PortalExamples from "./portalExamples"; | ||
|
||
const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_TESTNET); | ||
|
||
console.log(await veraxSdk.portal.findBy()); | ||
await new PortalExamples(veraxSdk).run(process.argv[2]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import VeraxSdk from "../../src/VeraxSdk"; | ||
|
||
export default class PortalExamples { | ||
private veraxSdk: VeraxSdk; | ||
constructor(_veraxSdk: VeraxSdk) { | ||
this.veraxSdk = _veraxSdk; | ||
} | ||
async run(methodName: string = "") { | ||
if (methodName.toLowerCase() == "findOneById".toLowerCase() || methodName == "") | ||
console.log(await this.veraxSdk.portal.findOneById("0x1495341ab1019798dd08976f4a3e5ab0e095510b")); | ||
|
||
if (methodName.toLowerCase() == "findBy".toLowerCase() || methodName == "") | ||
console.log(await this.veraxSdk.portal.findBy({ ownerName: "Clique" })); | ||
|
||
if (methodName.toLowerCase() == "attest" || methodName == "") console.log(await this.veraxSdk.portal.attest()); | ||
|
||
if (methodName.toLowerCase() == "bulkAttest".toLowerCase() || methodName == "") | ||
console.log(await this.veraxSdk.portal.bulkAttest()); | ||
|
||
if (methodName.toLowerCase() == "replace" || methodName == "") console.log(await this.veraxSdk.portal.replace()); | ||
|
||
if (methodName.toLowerCase() == "revoke" || methodName == "") console.log(await this.veraxSdk.portal.revoke()); | ||
|
||
if (methodName.toLowerCase() == "bulkRevoke".toLowerCase() || methodName == "") | ||
console.log(await this.veraxSdk.portal.bulkRevoke()); | ||
|
||
if (methodName.toLowerCase() == "massImport".toLowerCase() || methodName == "") | ||
console.log(await this.veraxSdk.portal.massImport()); | ||
|
||
if (methodName.toLowerCase() == "register" || methodName == "") console.log(await this.veraxSdk.portal.register()); | ||
|
||
if (methodName.toLowerCase() == "clone" || methodName == "") console.log(await this.veraxSdk.portal.clone()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import VeraxSdk from "../../src/VeraxSdk"; | ||
import PortalExamples from "./schemaExamples"; | ||
|
||
const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_TESTNET); | ||
|
||
console.log(await veraxSdk.module.findBy()); | ||
await new PortalExamples(veraxSdk).run(process.argv[2]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import VeraxSdk from "../../src/VeraxSdk"; | ||
|
||
export default class SchemaExamples { | ||
private veraxSdk: VeraxSdk; | ||
constructor(_veraxSdk: VeraxSdk) { | ||
this.veraxSdk = _veraxSdk; | ||
} | ||
async run(methodName: string = "") { | ||
if (methodName.toLowerCase() == "findOneById".toLowerCase() || methodName == "") | ||
console.log( | ||
await this.veraxSdk.schema.findOneById("0x01f031da36192c34057c764239eb77bb6ec8ebfb808f72a7bb172f37a5bec31f"), | ||
); | ||
|
||
if (methodName.toLowerCase() == "findBy".toLowerCase() || methodName == "") | ||
console.log(await this.veraxSdk.schema.findBy({ name: "Relationship" })); | ||
|
||
if (methodName.toLowerCase() == "create" || methodName == "") console.log(await this.veraxSdk.schema.create()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import { Module } from "../types"; | ||
import BaseDataMapper from "./BaseDataMapper"; | ||
|
||
export default class ModuleDataMapper extends BaseDataMapper { | ||
export default class ModuleDataMapper extends BaseDataMapper<Module> { | ||
typeName = "module"; | ||
gqlInterface = `{ | ||
id | ||
moduleAddress | ||
name | ||
description | ||
}`; | ||
|
||
async register() { | ||
throw new Error("Not implemented"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,48 @@ | ||
import { Chain } from "viem"; | ||
import { Chain, Address } from "viem"; | ||
|
||
export interface Conf { | ||
chain: Chain; | ||
subgraphUrl: string; | ||
portalRegistryAddress: `0x${string}`; | ||
moduleRegistryAddress: `0x${string}`; | ||
schemaRegistryAddress: `0x${string}`; | ||
attestationRegistryAddress: `0x${string}`; | ||
portalRegistryAddress: Address; | ||
moduleRegistryAddress: Address; | ||
schemaRegistryAddress: Address; | ||
attestationRegistryAddress: Address; | ||
} | ||
|
||
export type Attestation = { | ||
attestationId: string; // The unique identifier of the attestation. | ||
schemaId: string; // The identifier of the schema this attestation adheres to. | ||
replacedBy: string | null; // Whether the attestation was replaced by a new one. | ||
Address: string; // The address issuing the attestation to the subject. | ||
Address: string; // The id of the portal that created the attestation. | ||
attestedDate: number; // The date the attestation is issued. | ||
expirationDate: number; // The expiration date of the attestation. | ||
revocationDate: number | null; // The date when the attestation was revoked. | ||
version: number; // Version of the registry when the attestation was created. | ||
revoked: boolean; // Whether the attestation is revoked or not. | ||
subject: string; // The ID of the attestee, EVM address, DID, URL etc. | ||
attestationData: string; // The attestation data. | ||
}; | ||
|
||
export type Schema = { | ||
name: string; // The name of the schema. | ||
description: string; // A description of the schema. | ||
context: string; // The context of the schema. | ||
schema: string; // The schema definition. | ||
}; | ||
|
||
export type Portal = { | ||
id: Address; // The unique identifier of the portal (address). | ||
ownerAddress: Address; // The address of the owner of this portal. | ||
modules: Address[]; // Addresses of modules implemented by the portal. | ||
isRevocable: boolean; // Whether attestations issued can be revoked. | ||
name: string; // The name of the portal. | ||
description: string; // A description of the portal. | ||
ownerName: string; // The name of the owner of this portal. | ||
}; | ||
|
||
export type Module = { | ||
moduleAddress: Address; // The address of the module. | ||
name: string; // The name of the module. | ||
description: string; // A description of the module. | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export function stringifyWhereClause(whereClauseObj: Record<string, unknown>) { | ||
const json = JSON.stringify(whereClauseObj); | ||
return json.replace(/"([^"]+)":/g, "$1:"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters