Skip to content

Commit

Permalink
feat: added signature generation using wallet service
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth9890 committed Jul 3, 2024
1 parent a94db30 commit 88a91d2
Show file tree
Hide file tree
Showing 12 changed files with 341 additions and 291 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"@graphql-typed-document-node/core": "^3.2.0",
"@solana/web3.js": "^1.93.1",
"axios": "^1.7.2",
"bs58": "^6.0.0",
"canonicalize": "^2.0.0",
"encoding": "^0.1.13",
"ethers": "^5.7.2",
Expand Down
15 changes: 0 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 4 additions & 12 deletions scripts/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,12 @@ function processFile(inputFile, outputFile) {

const filesToProcess = [
{
input: 'dist/gatewaySdk/sources/GatewayV2/index.d.ts',
output: 'dist/gatewaySdk/sources/GatewayV2/index.d.ts',
input: 'dist/gatewaySdk/sources/Gateway/index.d.ts',
output: 'dist/gatewaySdk/sources/Gateway/index.d.ts',
},
{
input: 'dist/gatewaySdk/sources/GatewayV2/types.d.ts',
output: 'dist/gatewaySdk/sources/GatewayV2/types.d.ts',
},
{
input: 'dist/gatewaySdk/sources/GatewayV3/index.d.ts',
output: 'dist/gatewaySdk/sources/GatewayV3/index.d.ts',
},
{
input: 'dist/gatewaySdk/sources/GatewayV3/types.d.ts',
output: 'dist/gatewaySdk/sources/GatewayV3/types.d.ts',
input: 'dist/gatewaySdk/sources/Gateway/types.d.ts',
output: 'dist/gatewaySdk/sources/Gateway/types.d.ts',
},
];

Expand Down
34 changes: 27 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,33 @@ export class Gateway {
}

private initializeModules(validationService: ValidationService) {
// this.activity = new Activity(this.sdk, validationService);
// this.auth = new Auth(this.sdk, validationService);
// this.dataModel = new DataModel(this.sdk, validationService);
// this.organization = new Organization(this.sdk, validationService);
this.activity = new Activity(this.sdk, validationService);
this.auth = new Auth(this.sdk, validationService);
this.dataModel = new DataModel(
this.sdk,
validationService,
this.config,
this.wallet,
);
this.organization = new Organization(
this.sdk,
validationService,
this.config,
this.wallet,
);
this.pda = new PDA(this.sdk, validationService, this.config, this.wallet);
// this.proof = new Proof(this.sdk, validationService);
// this.request = new Request(this.sdk, validationService);
// this.user = new User(this.sdk, validationService);
this.proof = new Proof(
this.sdk,
validationService,
this.config,
this.wallet,
);
this.request = new Request(
this.sdk,
validationService,
this.config,
this.wallet,
);
this.user = new User(this.sdk, validationService);
}
}
14 changes: 7 additions & 7 deletions src/modules/activity/activity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
Sdk,
activitiesCount_queryQueryVariables,
activities_queryQueryVariables,
activitiesCountQueryQueryVariables,
activitiesQueryQueryVariables,
} from '../../../gatewaySdk/sources/Gateway';
import { errorHandler } from '../../helpers/helper';
import { ValidationService } from '../../services/validator-service';
Expand All @@ -26,23 +26,23 @@ export class Activity {
async getActivity(id: string) {
try {
this.validationService.validateString(id);
return await this.sdk.activity_query({ id: id });
return await this.sdk.activityQuery({ id: id });
} catch (error) {
throw new Error(errorHandler(error));
}
}

async getActivities(variables?: activities_queryQueryVariables) {
async getActivities(variables?: activitiesQueryQueryVariables) {
try {
return await this.sdk.activities_query(variables);
return await this.sdk.activitiesQuery(variables);
} catch (error) {
throw new Error(errorHandler(error));
}
}

async getActivityCount(variables?: activitiesCount_queryQueryVariables) {
async getActivityCount(variables?: activitiesCountQueryQueryVariables) {
try {
return await this.sdk.activitiesCount_query(variables);
return await this.sdk.activitiesCountQuery(variables);
} catch (error) {
throw new Error(errorHandler(error));
}
Expand Down
70 changes: 44 additions & 26 deletions src/modules/data-model/data-model.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,55 @@
import {
FilterDataModelInput,
Sdk,
dataModels_queryQueryVariables,
CreateDataModelInput,
DataModelBody,
dataModelsQueryQueryVariables,
} from '../../../gatewaySdk/sources/Gateway';
import { Config } from '../../common/types';
import { errorHandler } from '../../helpers/helper';
import { ValidationService } from '../../services/validator-service';
import { WalletService } from '../../services/wallet-service';

export class DataModel {
private sdk: Sdk;
private validationService: ValidationService;
private wallet: WalletService;
private config: Config;

constructor(sdk: Sdk, validationService: ValidationService) {
constructor(
sdk: Sdk,
validationService: ValidationService,
config: Config,
wallet: WalletService,
) {
this.sdk = sdk;
this.validationService = validationService;
this.wallet = wallet;
this.config = config;
}

/**
* The function `createModelInput` is an asynchronous function that takes a `CreateDataModelInput`
* object as input and returns a promise that resolves to a `createDataModel_mutationMutation` object.
* @param {CreateDataModelInput} createModelInput - The `createModelInput` parameter is of type
* `CreateDataModelInput`. It is an input object that contains the data needed to create a new data
* The function `createDataModelBody` is an asynchronous function that takes a `CreateDataModelInput`
* object as input and returns a promise that resolves to a `createDataModelMutation` object.
* @param {CreateDataModelInput} createDataModelBody - The `createDataModelBody` parameter is of type
* `DataModelBody`. It is an input object that contains the data needed to create a new data
* model.
* @returns a Promise that resolves to a value of type `createDataModel_mutationMutation`.
* @returns a Promise that resolves to a value of type `createDataModelMutation`.
*/
public async createDataModel(createModelInput: CreateDataModelInput) {
public async createDataModel(createDataModelBody: DataModelBody) {
try {
this.validationService.validateObjectProperties(createModelInput.data);
this.validationService.validateObjectProperties(createDataModelBody);
const { signature, signingKey } =
await this.wallet.signMessage(createDataModelBody);

return await this.sdk.createDataModel_mutation({
input: createModelInput,
return await this.sdk.createDataModelMutation({
input: {
data: createDataModelBody,
signature,
signingKey,
signingCipher: this.config.walletType,
},
});
} catch (error: any) {
} catch (error) {
throw new Error(errorHandler(error));
}
}
Expand All @@ -46,7 +64,7 @@ export class DataModel {
public async getDataModel(id: string) {
try {
this.validationService.validateUUID(id);
return await this.sdk.dataModel_query({ id });
return await this.sdk.dataModelQuery({ id });
} catch (error) {
throw new Error(errorHandler(error));
}
Expand All @@ -55,14 +73,14 @@ export class DataModel {
/**
* The function `getDataModels` is an asynchronous function that queries data models and returns the
* result.
* @param {dataModels_queryQueryVariables} dataModel - The `dataModel` parameter is an object that
* contains variables for the `dataModels_query` query. It is of type `dataModels_queryQueryVariables`.
* @returns The `getDataModels` function is returning the result of the `dataModels_query` function
* @param {dataModelsQueryQueryVariables} variables - The `dataModel` parameter is an object that
* contains variables for the `dataModelsQuery` query. It is of type `dataModelsQueryQueryVariables`.
* @returns The `getDataModels` function is returning the result of the `dataModelsQuery` function
* call.
*/
public async getDataModels(variables?: dataModels_queryQueryVariables) {
public async getDataModels(variables?: dataModelsQueryQueryVariables) {
try {
return await this.sdk.dataModels_query(variables);
return await this.sdk.dataModelsQuery(variables);
} catch (error) {
console.log(error);
throw new Error(errorHandler(error));
Expand All @@ -81,7 +99,7 @@ export class DataModel {
*/
public async getDataModelsCount(filterVariables?: FilterDataModelInput) {
try {
return await this.sdk.dataModelsCount_query({
return await this.sdk.dataModelsCountQuery({
filter: filterVariables,
});
} catch (error: any) {
Expand All @@ -97,7 +115,7 @@ export class DataModel {
*/
public async getDataModelsMetaData() {
try {
return await this.sdk.dataModelsMetadata_query();
return await this.sdk.dataModelsMetadataQuery();
} catch (error: any) {
throw new Error(errorHandler(error));
}
Expand All @@ -106,12 +124,12 @@ export class DataModel {
/**
* The function `getIssuersByDataModel` retrieves issuers based on a given data model ID using an SDK.
* @param {string} id - A string representing the ID of the data model.
* @returns the result of the `issuersByDataModel_query` method call.
* @returns the result of the `issuersByDataModelQuery` method call.
*/
public async getIssuersByDataModel(id: string) {
try {
this.validationService.validateUUID(id);
return await this.sdk.issuersByDataModel_query({ id: id });
return await this.sdk.issuersByDataModelQuery({ id: id });
} catch (error: any) {
throw new Error(errorHandler(error));
}
Expand All @@ -127,7 +145,7 @@ export class DataModel {
public async getIssuersByDataModelCount(dataModelId: string) {
try {
this.validationService.validateUUID(dataModelId);
return await this.sdk.issuersByDataModelCount_query({ id: dataModelId });
return await this.sdk.issuersByDataModelCountQuery({ id: dataModelId });
} catch (error: any) {
throw new Error(errorHandler(error));
}
Expand All @@ -138,12 +156,12 @@ export class DataModel {
* data model ID.
* @param {string} dataModelId - The dataModelId parameter is a string that represents the identifier
* of a data model. It is used to query the total number of issuers associated with that data model.
* @returns the result of the `getTotalofIssuersByDataModel_query` method call.
* @returns the result of the `getTotalofIssuersByDataModelQuery` method call.
*/
public async getTotalofIssuersByDataModel(dataModelId: string) {
try {
this.validationService.validateUUID(dataModelId);
return await this.sdk.getTotalofIssuersByDataModel_query({ dataModelId });
return await this.sdk.getTotalofIssuersByDataModelQuery({ dataModelId });
} catch (error: any) {
throw new Error(errorHandler(error));
}
Expand Down
Loading

0 comments on commit 88a91d2

Please sign in to comment.