Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/pda #2

Merged
merged 28 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d3602fa
feat: completed all pda query and test cases for same
Siddharth9890 Oct 31, 2023
c17a95b
feat: completed remaining methods for pda class
Siddharth9890 Oct 31, 2023
73df0ed
Merge branch 'main' into feat/PDA
Siddharth9890 Nov 2, 2023
747903c
chore: folder rename
Siddharth9890 Nov 2, 2023
08977e2
Merge branch 'main' into feat/PDA
Siddharth9890 Nov 2, 2023
5f89b58
chore: renaming tests file
Siddharth9890 Nov 2, 2023
779b020
chore: small change in error handling
Siddharth9890 Nov 2, 2023
9504d1d
Merge branch 'main' into feat/PDA
Siddharth9890 Nov 5, 2023
dda46c1
fix: ran linter on code
Siddharth9890 Nov 5, 2023
e3a2662
test: revert fetch backup file?
Siddharth9890 Nov 5, 2023
e719af5
revert: custom fetch file deleted
Siddharth9890 Nov 5, 2023
d2d162f
chore: rename PDA=> pda
Siddharth9890 Nov 8, 2023
3625838
chore: added error handler
Siddharth9890 Nov 16, 2023
0944a49
chore: added filter to remove transactions query for now
Siddharth9890 Nov 16, 2023
9deaaaa
chore: modified tests again
Siddharth9890 Nov 17, 2023
191cdd7
chore: everything working except get pdas
Siddharth9890 Nov 20, 2023
3cdeea4
chore: git not working on folder change
Siddharth9890 Nov 20, 2023
a893a7f
chore:revert last change
Siddharth9890 Nov 20, 2023
90cf3a3
feat: testing env on gh actions
Siddharth9890 Nov 20, 2023
03e2084
chore: testing env for mesh
Siddharth9890 Nov 20, 2023
71018b2
chore: testing mesh secret #2
Siddharth9890 Nov 20, 2023
89f34a2
chore: testing mesh env #3
Siddharth9890 Nov 20, 2023
2d940b9
Merge branch 'main' into feat/PDA
Siddharth9890 Nov 20, 2023
9e33879
chore: adding remaining env
Siddharth9890 Nov 20, 2023
57a656b
chore: final env settings
Siddharth9890 Nov 20, 2023
67978e4
chore: revert run command gh action
Siddharth9890 Nov 20, 2023
2cbb6b4
chore: fixed linter error
Siddharth9890 Nov 21, 2023
3b694d7
chore: removed console.log
Siddharth9890 Nov 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build PR
name: Run Eslint & Test cases

on:
pull_request:
Expand All @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install pnpm
run: npm install -g pnpm@7.33.5
- name: Install Project Dependencies
Expand All @@ -20,3 +20,7 @@ jobs:
run: pnpm mesh build
- name: Test project
run: pnpm test
env:
DATAMODEL_ID: ${{ secrets.DATAMODEL_ID }}
BEARER_TOKEN: ${{ secrets.BEARER_TOKEN }}
API_KEY: ${{ secrets.API_KEY }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules/
.mesh/
.mesh/
.vscode/
.env
10 changes: 7 additions & 3 deletions .meshrc.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
sources:
- name: MyGraphQLApi
- name: GatewaySDK
handler:
graphql:
endpoint: https://develop.protocol.mygateway.xyz/v1/graphql
method: 'POST'
useGETForQueries: false
transforms:
- filterSchema:
mode: bare
filters:
- Query.!transaction
- Query.!transactions

customFetch: ./custom-fetch.ts

Expand Down
16 changes: 0 additions & 16 deletions custom-fetch-backup.ts

This file was deleted.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
"@graphql-mesh/cli": "^0.87.14",
"@graphql-mesh/graphql": "^0.95.7",
"@graphql-mesh/runtime": "^0.96.11",
"@graphql-mesh/transform-filter-schema": "^0.96.0",
"@types/node": "^20.8.4",
"@whatwg-node/fetch": "^0.9.13",
"graphql": "^16.8.1"
},
"devDependencies": {
"@types/jest": "^29.5.7",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"dotenv": "^16.3.1",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard-with-typescript": "^39.1.1",
Expand Down
32 changes: 27 additions & 5 deletions pnpm-lock.yaml

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

15 changes: 0 additions & 15 deletions src/Auth.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/Gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { getMeshSDK, Sdk } from '../.mesh';
import { PDA } from './pda/pda';

export class Gateway {
// public auth: Auth;
public pda: PDA;
private sdk: Sdk;

Expand All @@ -12,7 +11,6 @@ export class Gateway {
apiKey,
token,
});
// this.auth = new Auth();
this.pda = new PDA(this.sdk);
}
}
28 changes: 0 additions & 28 deletions src/pda/PDA.ts

This file was deleted.

151 changes: 151 additions & 0 deletions src/pda/pda.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import {
CreatePDAInput,
Sdk,
FilterPDAInput,
UpdatePDAInput,
} from '../../.mesh';
import { PDAFilter, PDAStatus } from '../types';
import { errorHandler } from '../utils/errorHandler';

export class PDA {
private sdk: Sdk;

constructor(sdk: Sdk) {
this.sdk = sdk;
}

/**
* The function `getPDA` is an asynchronous function that takes an `id` parameter and returns a
* Promise that resolves to a `PDA_queryQuery` object.
* @param {string} id - A string representing the ID of the PDA that you
* want to query.
* @returns The function `getPda` is returning a Promise that resolves to a `PDA_queryQuery` object.
*/
async getPDA(id: string) {
try {
return await this.sdk.PDA_query({ id });
} catch (error) {
throw new Error(errorHandler(error));
}
}

/**
* The function `getPDACount` is an asynchronous function that retrieves the count of PDAs
* based on an optional filter.
* @param {FilterPDAInput} [filter] - The `filter` parameter is an optional input that allows you to
* specify criteria for filtering the PDAs before counting them. It is
* of type `FilterPDAInput`.
* @returns a Promise that resolves to a number.
*/
async getPDACount(filter?: FilterPDAInput) {
try {
return (await this.sdk.PDACount_query({ filter })).PDACount;
} catch (error) {
throw new Error(errorHandler(error));
}
}

/**
* The function `getPDAs` retrieves PDAs based on the provided filter, order, skip, and take
* parameters.
* @param {PDAFilter} - - `filter`: An object that contains filter criteria for the query.
* @returns a Promise that resolves to a value of type PDAs_queryQuery.
*/
async getPDAs({ filter, order, skip, take }: PDAFilter) {
try {
return await this.sdk.PDAs_query({ filter, order, skip, take });
} catch (error) {
throw new Error(errorHandler(error));
}
}

/**
* The function `getIssuedPDAs` retrieves issued PDAs based on the provided filter, order, skip, and
* take parameters.
* @param {PDAFilter} - - `filter`: An object that contains filter criteria for the query. It is
* used to specify conditions that the returned PDAs must meet.
* @returns a Promise that resolves to an object of type `issuedPDAs_queryQuery`.
*/
async getIssuedPDAs({ filter, order, skip, take }: PDAFilter) {
try {
return await this.sdk.issuedPDAs_query({ filter, order, skip, take });
} catch (error) {
throw new Error(errorHandler(error));
}
}

/**
* The function `getIssuedPDAsCount` is an asynchronous function that retrieves the count of issued
* PDAs based on an optional filter.
* @param {FilterPDAInput} [filter] - The `filter` parameter is an optional input that allows you to
* specify criteria for filtering the issued PDAs. It is of type `FilterPDAInput`.
* @returns a Promise that resolves to a number.
*/
async getIssuedPDAsCount(filter?: FilterPDAInput) {
try {
return (await this.sdk.issuedPDAsCount_query({ filter })).issuedPDAsCount;
} catch (error) {
throw new Error(errorHandler(error));
}
}

/**
* The function `myPDACount` is an asynchronous function that returns the count of myPDAs based on an
* optional filter.
* @param {FilterPDAInput} [filter] - The `filter` parameter is an optional input that can be used to
* filter the results of the query. It is of type `FilterPDAInput`.
* @returns a Promise that resolves to a number.
*/
async myPDACount(filter?: FilterPDAInput) {
try {
return (await this.sdk.myPDACount_query({ filter })).myPDACount;
} catch (error) {
throw new Error(errorHandler(error));
}
}

/**
* The function `changePDAStatus` is an asynchronous function that takes an `id` and a `status` as
* parameters and returns a Promise that resolves to a `changePDAStatus_mutationMutation` object.
* @param - - `id`: The ID of the PDA whose status needs to be changed.
* @returns a Promise that resolves to a `changePDAStatus_mutationMutation` object.
*/
async changePDAStatus({ id, status }: { id: string; status: PDAStatus }) {
try {
return await this.sdk.changePDAStatus_mutation({ input: { id, status } });
} catch (error) {
throw new Error(errorHandler(error));
}
}

/**
* The function creates a PDA using the provided input and returns the result.
* @param {CreatePDAInput} pdaInput - The `pdaInput` parameter is an object that contains the input
* data for creating a PDA . It is of type `CreatePDAInput`.
* @returns the result of the `createPDA_mutation` method call, which is a Promise.
*/
async createPDA(pdaInput: CreatePDAInput) {
try {
return await this.sdk.createPDA_mutation({ input: pdaInput });
} catch (error) {
throw new Error(errorHandler(error));
}
}

/**
* The function `updatePDA` updates a PDA using the provided input and returns
* the result of the mutation.
* @param {UpdatePDAInput} updatedPDA - The parameter `updatedPDA` is of type `UpdatePDAInput`. It is
* an input object that contains the data to update a PDA. The specific
* properties and their types within `UpdatePDAInput` would depend on the implementation of the
* `updatePDA_m
* @returns a Promise that resolves to an object of type `updatePDA_mutationMutation`.
*/
async updatePDA(updatedPDA: UpdatePDAInput) {
try {
return await this.sdk.updatePDA_mutation({ input: updatedPDA });
} catch (error) {
throw new Error(errorHandler(error));
}
}
}
Loading