Skip to content

Commit

Permalink
fix: corrected examples and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
kolhapuresatyajeet committed Oct 16, 2023
1 parent a8c53e9 commit 9c8e240
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 64 deletions.
24 changes: 16 additions & 8 deletions sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,31 @@ Note: if your don't pass any parameter (e.g. `pnpm portal findBy`)`, some defaul
```shell
pnpm portal findonebyid '0x34798a866f52949208e67fb57ad36244024c50c0'

pnpm portal findby
pnpm portal findby '{\"ownerName\": \"Satya\"}'

pnpm portal simulateattest '{\"portalAddress\": \"0x34798a866f52949208e67fb57ad36244024c50c0\", \"attestationPayload\" : { \"schemaId\": \"0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738\", \"expirationDate\": \"1693583329\", \"subject\": \"0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47\", \"attestationData\": [{ \"isBuidler\": \"true\" }]}, \"validationPayloads\": []}'
pnpm portal simulateattest '{\"portalAddress\": \"0x34798a866f52949208e67fb57ad36244024c50c0\", \"attestationPayload\" : { \"schemaId\": \"0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738\", \"expirationDate\": 1693583329, \"subject\": \"0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47\", \"attestationData\": [{ \"isBuidler\": true }]}, \"validationPayloads\": []}'

pnpm portal attest '{\"portalAddress\": \"0x34798a866f52949208e67fb57ad36244024c50c0\", \"attestationPayload\" : { \"schemaId\": \"0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738\", \"expirationDate\": \"1693583329\", \"subject\": \"0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47\", \"attestationData\": [{ \"isBuidler\": \"true\" }]}, \"validationPayloads\": []}'
pnpm portal attest '{\"portalAddress\": \"0x34798a866f52949208e67fb57ad36244024c50c0\", \"attestationPayload\" : { \"schemaId\": \"0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738\", \"expirationDate\": 1693583329, \"subject\": \"0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47\", \"attestationData\": [{ \"isBuidler\": true }]}, \"validationPayloads\": []}'

pnpm portal simulaterevoke '{\"portalAddress\": \"0x34798a866f52949208e67fb57ad36244024c50c0\", \"attestationId\" : \"0x000000000000000000000000000000000000000000000000000000000000109b\" }'
pnpm portal simulateBulkAttest '{\"portalAddress\": \"0x34798a866f52949208e67fb57ad36244024c50c0\", \"attestationPayloads\" : [{ \"schemaId\": \"0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738\", \"expirationDate\": 1693583329, \"subject\": \"0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47\", \"attestationData\": [{ \"isBuidler\": true }]},{ \"schemaId\": \"0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738\", \"expirationDate\": 1693583329, \"subject\": \"0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47\", \"attestationData\": [{ \"isBuidler\": true }]}], \"validationPayloads\": [[],[]]}'

pnpm portal revoke '{\"portalAddress\": \"0x34798a866f52949208e67fb57ad36244024c50c0\", \"attestationId\" : \"0x000000000000000000000000000000000000000000000000000000000000109b\" }'
pnpm portal bulkAttest '{\"portalAddress\": \"0x34798a866f52949208e67fb57ad36244024c50c0\", \"attestationPayloads\" : [{ \"schemaId\": \"0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738\", \"expirationDate\": 1693583329, \"subject\": \"0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47\", \"attestationData\": [{ \"isBuidler\": true }]},{ \"schemaId\": \"0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738\", \"expirationDate\": 1693583329, \"subject\": \"0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47\", \"attestationData\": [{ \"isBuidler\": true }]}], \"validationPayloads\": [[],[]]}'

pnpm portal simulaterevoke '{\"portalAddress\": \"0x34798a866f52949208e67fb57ad36244024c50c0\", \"attestationId\" : \"0x00000000000000000000000000000000000000000000000000000000000010a8\" }'

pnpm portal revoke '{\"portalAddress\": \"0x34798a866f52949208e67fb57ad36244024c50c0\", \"attestationId\" : \"0x00000000000000000000000000000000000000000000000000000000000010a8\" }'

pnpm portal simulateBulkRevoke '{\"portalAddress\": \"0x34798a866f52949208e67fb57ad36244024c50c0\", \"attestationIds\" : [\"0x00000000000000000000000000000000000000000000000000000000000010a7\", \"0x00000000000000000000000000000000000000000000000000000000000010a6\"] }'

pnpm portal bulkRevoke '{\"portalAddress\": \"0x34798a866f52949208e67fb57ad36244024c50c0\", \"attestationIds\" : [\"0x00000000000000000000000000000000000000000000000000000000000010a7\", \"0x00000000000000000000000000000000000000000000000000000000000010a6\"] }'
```

### Attestation examples

```shell
pnpm attestation findonebyid "0x000000000000000000000000000000000000000000000000000000000000109b"

pnpm attestation findby
pnpm attestation findby '{\"portal\": \"0x34798a866f52949208e67fb57ad36244024c50c0\"}'

pnpm attestation getRelatedAttestations "0x0000000000000000000000000000000000000000000000000000000000000001"
```
Expand All @@ -206,15 +214,15 @@ pnpm attestation getRelatedAttestations "0x0000000000000000000000000000000000000
```shell
pnpm module findonebyid "0x4bb8769e18f1518c35be8405d43d7cc07ecf501c"

pnpm module findby
pnpm module findby '{\"name\": \"Msg Sender Module\"}'
```

### Schema examples

```shell
pnpm schema findonebyid "0xce2647ed39aa89e6d1528a56deb6c30667ed2aae1ec2378ec3140c0c5d98a61e"

pnpm schema findby
pnpm schema findby '{\"description\": \"Gitcoin Passport Score\"}'
```

## Other operations
Expand Down
128 changes: 72 additions & 56 deletions sdk/examples/portal/portalExamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export default class PortalExamples {
const portalAddress = params?.portalAddress
? (params.portalAddress as Address)
: "0xeea25bc2ec56cae601df33b8fc676673285e12cc";
const attestationData = params?.attestationData ?? {
const attestationPayload = params?.attestationPayload ?? {
schemaId: "0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738",
expirationDate: 1693583329,
subject: "0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47",
attestationData: [{ isBuidler: true }],
};
const validationPayloads = params?.validationPayloads ?? [];
console.log(await this.veraxSdk.portal.simulateAttest(portalAddress, attestationData, validationPayloads));
console.log(await this.veraxSdk.portal.simulateAttest(portalAddress, attestationPayload, validationPayloads));
}

if (methodName.toLowerCase() == "attest" || methodName == "") {
Expand All @@ -40,60 +40,66 @@ export default class PortalExamples {
const portalAddress = params?.portalAddress
? (params.portalAddress as Address)
: "0xeea25bc2ec56cae601df33b8fc676673285e12cc";
const attestationData = params?.attestationData ?? {
const attestationPayload = params?.attestationPayload ?? {
schemaId: "0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738",
expirationDate: 1693583329,
subject: "0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47",
attestationData: [{ isBuidler: true }],
};
const validationPayloads = params?.validationPayloads ?? [];
console.log(await this.veraxSdk.portal.attest(portalAddress, attestationData, validationPayloads));
console.log(await this.veraxSdk.portal.attest(portalAddress, attestationPayload, validationPayloads));
}

if (methodName.toLowerCase() == "simulateBulkAttest".toLowerCase() || methodName == "") {
let params;
if (argv !== "") params = JSON.parse(argv);
const portalAddress = params?.portalAddress
? (params.portalAddress as Address)
: "0xeea25bc2ec56cae601df33b8fc676673285e12cc";

const attestationPayloads = params?.attestationPayloads ?? [
{
schemaId: "0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738",
expirationDate: 1693583329,
subject: "0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47",
attestationData: [{ isBuidler: true }],
},
{
schemaId: "0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738",
expirationDate: 1693583329,
subject: "0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47",
attestationData: [{ isBuidler: true }],
},
];
const validationPayloads = params?.validationPayloads ?? [[], []];
console.log(
await this.veraxSdk.portal.simulateBulkAttest(
"0x34798a866f52949208e67fb57ad36244024c50c0",
[
{
schemaId: "0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738",
expirationDate: 1693583329,
subject: "0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47",
attestationData: [{ isBuidler: true }],
},
{
schemaId: "0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738",
expirationDate: 1693583329,
subject: "0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47",
attestationData: [{ isBuidler: true }],
},
],
[],
),
await this.veraxSdk.portal.simulateBulkAttest(portalAddress, attestationPayloads, validationPayloads),
);
}

if (methodName.toLowerCase() == "bulkAttest".toLowerCase() || methodName == "") {
console.log(
await this.veraxSdk.portal.bulkAttest(
"0x34798a866f52949208e67fb57ad36244024c50c0",
[
{
schemaId: "0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738",
expirationDate: 1693583329,
subject: "0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47",
attestationData: [{ isBuidler: true }],
},
{
schemaId: "0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738",
expirationDate: 1693583329,
subject: "0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47",
attestationData: [{ isBuidler: false }],
},
],
[[], []],
),
);
let params;
if (argv !== "") params = JSON.parse(argv);
const portalAddress = params?.portalAddress
? (params.portalAddress as Address)
: "0xeea25bc2ec56cae601df33b8fc676673285e12cc";

const attestationPayloads = params?.attestationPayloads ?? [
{
schemaId: "0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738",
expirationDate: 1693583329,
subject: "0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47",
attestationData: [{ isBuidler: true }],
},
{
schemaId: "0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738",
expirationDate: 1693583329,
subject: "0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47",
attestationData: [{ isBuidler: true }],
},
];
const validationPayloads = params?.validationPayloads ?? [[], []];
console.log(await this.veraxSdk.portal.bulkAttest(portalAddress, attestationPayloads, validationPayloads));
}

if (methodName.toLowerCase() == "replace" || methodName == "") console.log(await this.veraxSdk.portal.replace());
Expand All @@ -120,21 +126,31 @@ export default class PortalExamples {
console.log(await this.veraxSdk.portal.simulateRevoke(portalAddress, attestationId));
}

if (methodName.toLowerCase() == "simulateBulkRevoke".toLowerCase() || methodName == "")
console.log(
await this.veraxSdk.portal.simulateBulkRevoke("0x34798a866f52949208e67fb57ad36244024c50c0", [
"0x00000000000000000000000000000000000000000000000000000000000010a0",
"0x00000000000000000000000000000000000000000000000000000000000010a1",
]),
);
if (methodName.toLowerCase() == "simulateBulkRevoke".toLowerCase() || methodName == "") {
let params;
if (argv !== "") params = JSON.parse(argv);
const portalAddress = params?.portalAddress
? (params.portalAddress as Address)
: "0xeea25bc2ec56cae601df33b8fc676673285e12cc";
const attestationIds = params?.attestationIds ?? [
"0x00000000000000000000000000000000000000000000000000000000000010a0",
"0x00000000000000000000000000000000000000000000000000000000000010a1",
];
console.log(await this.veraxSdk.portal.simulateBulkRevoke(portalAddress, attestationIds));
}

if (methodName.toLowerCase() == "bulkRevoke".toLowerCase() || methodName == "")
console.log(
await this.veraxSdk.portal.bulkRevoke("0x34798a866f52949208e67fb57ad36244024c50c0", [
"0x00000000000000000000000000000000000000000000000000000000000010a0",
"0x00000000000000000000000000000000000000000000000000000000000010a1",
]),
);
if (methodName.toLowerCase() == "bulkRevoke".toLowerCase() || methodName == "") {
let params;
if (argv !== "") params = JSON.parse(argv);
const portalAddress = params?.portalAddress
? (params.portalAddress as Address)
: "0xeea25bc2ec56cae601df33b8fc676673285e12cc";
const attestationIds = params?.attestationIds ?? [
"0x00000000000000000000000000000000000000000000000000000000000010a0",
"0x00000000000000000000000000000000000000000000000000000000000010a1",
];
console.log(await this.veraxSdk.portal.bulkRevoke(portalAddress, attestationIds));
}

if (methodName.toLowerCase() == "massImport".toLowerCase() || methodName == "")
console.log(await this.veraxSdk.portal.massImport());
Expand Down

0 comments on commit 9c8e240

Please sign in to comment.