Skip to content

Commit

Permalink
fix: Rename clone to deployDefaultPortal
Browse files Browse the repository at this point in the history
  • Loading branch information
alainncls committed Oct 23, 2023
1 parent e4943ed commit b6d70d9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 44 deletions.
4 changes: 2 additions & 2 deletions sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ pnpm portal simulateRegister '{\"id\":\"0xD39c439cD3Ae5E1F3c7d13985aDAC908462849

pnpm portal register '{\"id\":\"0xD39c439cD3Ae5E1F3c7d13985aDAC90846284904\",\"name\":\"test\",\"description\":\"example\",\"isRevocable\":true,\"ownerName\":\"test\"}'

pnpm portal simulateClone '{\"modules\":[],\"name\":\"test\",\"description\":\"example\",\"isRevocable\":true,\"ownerName\":\"test\"}'
pnpm portal simulateDeployDefaultPortal '{\"modules\":[],\"name\":\"test\",\"description\":\"example\",\"isRevocable\":true,\"ownerName\":\"test\"}'

pnpm portal clone '{\"modules\":[],\"name\":\"test\",\"description\":\"example\",\"isRevocable\":true,\"ownerName\":\"test\"}'
pnpm portal deployDefaultPortal '{\"modules\":[],\"name\":\"test\",\"description\":\"example\",\"isRevocable\":true,\"ownerName\":\"test\"}'

pnpm portal getPortalByAddress '{\"portalAddress\":\"0x8b833796869b5debb9b06370d6d47016f0d7973b\"}'

Expand Down
17 changes: 6 additions & 11 deletions sdk/examples/portal/portalExamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ export default class PortalExamples {
console.log(await this.veraxSdk.portal.bulkRevoke(portalAddress, attestationIds));
}

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

if (methodName.toLowerCase() == "simulateRegister".toLowerCase() || methodName == "") {
let params;
if (argv !== "") params = JSON.parse(argv);
Expand All @@ -181,7 +178,7 @@ export default class PortalExamples {
console.log(await this.veraxSdk.portal.register(id, name, description, isRevocable, ownerName));
}

if (methodName.toLowerCase() == "simulateClone".toLowerCase() || methodName == "") {
if (methodName.toLowerCase() == "simulateDeployDefaultPortal".toLowerCase() || methodName == "") {
let params;
if (argv !== "") params = JSON.parse(argv);
const { modules, name, description, isRevocable, ownerName } = params ?? {
Expand All @@ -191,10 +188,12 @@ export default class PortalExamples {
isRevocable: true,
ownerName: "test",
};
console.log(await this.veraxSdk.portal.simulateClone(modules, name, description, isRevocable, ownerName));
console.log(
await this.veraxSdk.portal.simulateDeployDefaultPortal(modules, name, description, isRevocable, ownerName),
);
}

if (methodName.toLowerCase() == "clone".toLowerCase() || methodName == "") {
if (methodName.toLowerCase() == "deployDefaultPortal".toLowerCase() || methodName == "") {
let params;
if (argv !== "") params = JSON.parse(argv);
const { modules, name, description, isRevocable, ownerName } = params ?? {
Expand All @@ -204,7 +203,7 @@ export default class PortalExamples {
isRevocable: true,
ownerName: "test",
};
console.log(await this.veraxSdk.portal.clone(modules, name, description, isRevocable, ownerName));
console.log(await this.veraxSdk.portal.deployDefaultPortal(modules, name, description, isRevocable, ownerName));
}

if (methodName.toLowerCase() == "getPortalByAddress".toLowerCase() || methodName == "") {
Expand All @@ -224,9 +223,5 @@ export default class PortalExamples {
: "0x8b833796869b5debb9b06370d6d47016f0d7973b";
console.log(await this.veraxSdk.portal.isPortalRegistered(portalAddress));
}

if (methodName.toLowerCase() == "getPortalsCount".toLocaleLowerCase() || methodName == "") {
console.log(await this.veraxSdk.portal.getPortalsCount());
}
}
}
50 changes: 19 additions & 31 deletions sdk/src/dataMapper/PortalDataMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt

async attest(portalAddress: Address, attestationPayload: AttestationPayload, validationPayloads: string[]) {
const request = await this.simulateAttest(portalAddress, attestationPayload, validationPayloads);
const hash: Hash = await this.walletClient.writeContract(request);

console.log(`Transaction sent with hash ${hash}`);

return hash;
return await this.executeTransaction(request);
}

async simulateBulkAttest(
Expand Down Expand Up @@ -85,11 +81,7 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt

async bulkAttest(portalAddress: Address, attestationPayloads: AttestationPayload[], validationPayloads: string[][]) {
const request = await this.simulateBulkAttest(portalAddress, attestationPayloads, validationPayloads);
const hash: Hash = await this.walletClient.writeContract(request);

console.log(`Transaction sent with hash ${hash}`);

return hash;
return await this.executeTransaction(request);
}

async replace() {
Expand All @@ -114,11 +106,7 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt

async revoke(portalAddress: Address, attestationId: string) {
const request = await this.simulateRevoke(portalAddress, attestationId);
const hash: Hash = await this.walletClient.writeContract(request);

console.log(`Transaction sent with hash ${hash}`);

return hash;
return await this.executeTransaction(request);
}

async simulateBulkRevoke(portalAddress: Address, attestationIds: string[]) {
Expand All @@ -139,15 +127,7 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt

async bulkRevoke(portalAddress: Address, attestationIds: string[]) {
const request = await this.simulateBulkRevoke(portalAddress, attestationIds);
const hash: Hash = await this.walletClient.writeContract(request);

console.log(`Transaction sent with hash ${hash}`);

return hash;
}

async massImport() {
throw new Error("Not implemented");
return await this.executeTransaction(request);
}

async simulateRegister(id: Address, name: string, description: string, isRevocable: boolean, ownerName: string) {
Expand All @@ -159,7 +139,13 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt
return await this.executeTransaction(request);
}

async simulateClone(modules: Address[], name: string, description: string, isRevocable: boolean, ownerName: string) {
async simulateDeployDefaultPortal(
modules: Address[],
name: string,
description: string,
isRevocable: boolean,
ownerName: string,
) {
return this.simulatePortalRegistryContract("deployDefaultPortal", [
modules,
name,
Expand All @@ -169,8 +155,14 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt
]);
}

async clone(modules: Address[], name: string, description: string, isRevocable: boolean, ownerName: string) {
const request = await this.simulateClone(modules, name, description, isRevocable, ownerName);
async deployDefaultPortal(
modules: Address[],
name: string,
description: string,
isRevocable: boolean,
ownerName: string,
) {
const request = await this.simulateDeployDefaultPortal(modules, name, description, isRevocable, ownerName);
return await this.executeTransaction(request);
}

Expand All @@ -182,10 +174,6 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt
return await this.executePortalRegistryReadMethod("isRegistered", [id]);
}

async getPortalsCount() {
return await this.executePortalRegistryReadMethod("getPortalsCount", []);
}

private async executePortalRegistryReadMethod(functionName: string, args: unknown[]) {
return await this.web3Client.readContract({
abi: abiPortalRegistry,
Expand Down

0 comments on commit b6d70d9

Please sign in to comment.