Skip to content

Commit

Permalink
fix: async/await handling
Browse files Browse the repository at this point in the history
  • Loading branch information
alainncls committed Oct 23, 2023
1 parent 0c502c7 commit 2d07e0f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions sdk/src/dataMapper/SchemaDataMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,55 +16,55 @@ export default class SchemaDataMapper extends BaseDataMapper<Schema, Schema_filt
}`;

async simulateUpdateRouter(routerAddress: Address) {
return await this.simulateContract("updateRouter", [routerAddress]);
return this.simulateContract("updateRouter", [routerAddress]);
}

async updateRouter(routerAddress: Address) {
const request = await this.simulateUpdateRouter(routerAddress);
return await this.executeTransaction(request);
return this.executeTransaction(request);
}

async simulateCreate(name: string, description: string, context: string, schemaString: string) {
return await this.simulateContract("createSchema", [name, description, context, schemaString]);
return this.simulateContract("createSchema", [name, description, context, schemaString]);
}

async create(name: string, description: string, context: string, schemaString: string) {
const request = await this.simulateCreate(name, description, context, schemaString);
return await this.executeTransaction(request);
return this.executeTransaction(request);
}

async simulateUpdateContext(schemaId: string, context: string) {
return await this.simulateContract("updateContext", [schemaId, context]);
return this.simulateContract("updateContext", [schemaId, context]);
}

async updateContext(schemaId: string, context: string) {
const request = await this.simulateUpdateContext(schemaId, context);
return await this.executeTransaction(request);
return this.executeTransaction(request);
}

async getIdFromSchemaString(schema: string) {
return await this.executeReadMethod("getIdFromSchemaString", [schema]);
return this.executeReadMethod("getIdFromSchemaString", [schema]);
}

async getSchema(schemaId: string) {
return await this.executeReadMethod("getSchema", [schemaId]);
return this.executeReadMethod("getSchema", [schemaId]);
}

async getSchemasNumber() {
return await this.executeReadMethod("getSchemasNumber", []);
return this.executeReadMethod("getSchemasNumber", []);
}

async isRegistered(schemaId: string) {
return await this.executeReadMethod("isRegistered", [schemaId]);
return this.executeReadMethod("isRegistered", [schemaId]);
}

async getSchemaIds(index: number) {
return await this.executeReadMethod("schemaIds", [index]);
return this.executeReadMethod("schemaIds", [index]);
}

// TODO: Use correct type for args
private async executeReadMethod(functionName: string, args: unknown[]) {
return await this.web3Client.readContract({
return this.web3Client.readContract({
abi: abiSchemaRegistry,
address: this.conf.schemaRegistryAddress,
functionName,
Expand Down

0 comments on commit 2d07e0f

Please sign in to comment.