Skip to content

Commit

Permalink
Merge pull request #64 from Gateway-DAO/tests
Browse files Browse the repository at this point in the history
Tests
  • Loading branch information
R11manish authored Sep 13, 2024
2 parents bc47d1f + de67427 commit dd3a7b7
Show file tree
Hide file tree
Showing 85 changed files with 8,357 additions and 12,457 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ release.config.js
.husky/*
scripts/*
gatewaySdk/
src/testMutationsAndQuery.ts
src/testing.ts
src/common/types.ts
6 changes: 4 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ jobs:
run: pnpm install -D @semantic-release/changelog @semantic-release/git
- name: Lint
run: pnpm lint
- name: Build Graphql queries
run: pnpm generate:sdk
- name: Build REST API
run: pnpm generate
- name: Format code
run: pnpm format
- name: Test project
run: pnpm test
- name: Build
run: pnpm build
- name: Release
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
run: pnpm install
- name: Run Eslint
run: pnpm lint
- name: Build Graphql queries
run: pnpm generate:sdk
- name: Build REST API
run: pnpm generate
- name: Format code
run: pnpm format
- name: Test project
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ dist/
*.tgz
coverage/
.DS_STORE
gatewaySdk/
gatewaySdk/
src/testing.ts
2 changes: 1 addition & 1 deletion .husky/commit-msg
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
npx --no-install commitlint --edit "$1"
4 changes: 1 addition & 3 deletions .husky/pre-commit
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm lint-staged


pnpm lint-staged
182 changes: 160 additions & 22 deletions CHANGELOG.md

Large diffs are not rendered by default.

68 changes: 24 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ yarn add @gateway-dao/sdk

## Gateway Client

To setup the gateway client we will authenticate with a bearer-token and a Api key as follows
To setup the gateway client we will authenticate with a bearer-token,api key and wallet private key as follows

```typescript
import { Gateway } from '@gateway-dao/sdk';
Expand All @@ -52,9 +52,12 @@ const gateway = new Gateway({
apiKey: 'your-api-key',
token: 'your-token',
url: 'https://sandbox.protocol.mygateway.xyz/graphql',
walletPrivateKey: 'your-private-key', // store this in env file!
});
```

**The wallet private key is not send anywhere and is just used to sign messages on behalf of developer/organization using it. This way we minimize signature errors on protocol and provide smoother developer experience**

**Make sure you add token without Bearer as we add Bearer automatically when you make request. Else it will give you Unauthorized error even if your token is correct**
For example

Expand All @@ -66,6 +69,7 @@ const gateway = new Gateway({
token: 'Bearer your-token',
// wrong will not work just use token: 'your-token'
url: 'https://sandbox.protocol.mygateway.xyz/graphql',
walletPrivateKey: 'your-private-key', // store this in env file!
});
```

Expand All @@ -84,6 +88,7 @@ const gateway = new Gateway({
apiKey: 'your-api-key',
token: 'your-token',
url: 'https://sandbox.protocol.mygateway.xyz/graphql',
walletPrivateKey: 'your-private-key', // store this in env file!
});

async function main() {
Expand All @@ -109,7 +114,7 @@ async function main() {
main();
```

### Getting a Organization
### Creating a Organization

```typescript
import { Gateway } from '@gateway-dao/sdk';
Expand All @@ -118,6 +123,7 @@ const gateway = new Gateway({
apiKey: 'your-api-key',
token: 'your-token',
url: 'https://sandbox.protocol.mygateway.xyz/graphql',
walletPrivateKey: 'your-private-key', // store this in env file!
});

async function main() {
Expand All @@ -133,50 +139,12 @@ async function main() {
console.log(error); // Can log it for degugging
}
}

main();
```

### Create a Data request template

```typescript
import { Gateway } from '@gateway-dao/sdk';

const gateway = new Gateway({
apiKey: 'your-api-key',
token: 'your-token',
url: 'https://sandbox.protocol.mygateway.xyz/graphql',
});

async function main() {
try {
const { createDataRequestTemplate } =
await gateway.dataRequestTemplate.createDataRequestTemplate({
title: 'Create Data Request Template Example',
description: 'Lorem ipsum dolor sit amet.',
dataModels: [
{
id: 'uuid-here',
required: true,
claimValidations: {
type: 'object',
properties: {
gatewayUse: {
type: 'string',
},
},
required: ['gatewayUse'],
},
},
],
});
} catch (error) {
console.log(error); // Can log it for degugging
}
}
## More examples

main();
```
We have created a separate repository which have more [examples you can access it here](https://github.com/Gateway-DAO/sdk-scripts-example/)

## Error Handling

Expand All @@ -185,11 +153,23 @@ Incase of any protocol errors we will throw a custom message which is a string w

## License

The Gateway Javascript SDK is licensed under the [MIT License](https://github.com/Gateway-DAO/javascript-sdk/blob/main/LICENSE.md).
The Gateway Javascript SDK is licensed under the [MIT License](LICENSE).

## Contributing

If you want to support the active development of the SDK. [Please go through our Contribution guide](https://github.com/Gateway-DAO/gateway-js-sdk/blob/main/CONTRIBUTING.md)
If you want to support the active development of the SDK. [Please go through our Contribution guide](docs/CONTRIBUTING.md)

## Code of Conduct

Please read our [Code of Conduct](docs/CODE_OF_CONDUCT.md) before contributing or engaging in discussions.

## Security

If you discover a security vulnerability within this package, please open a ticket on Discord. All security vulnerabilities will be promptly addressed.

## Support

We are always here to help you. Please talk to us on [Discord](https://discord.gg/tgt3KjcHGs) for any queries.

[npm-image]: https://img.shields.io/npm/v/%40gateway-dao%2Fsdk.svg?style=flat
[npm-url]: https://www.npmjs.com/package/@gateway-dao/sdk
Expand Down
66 changes: 0 additions & 66 deletions __mocks__/auth.mock.ts

This file was deleted.

55 changes: 0 additions & 55 deletions __mocks__/dataModel.mock.ts

This file was deleted.

42 changes: 0 additions & 42 deletions __mocks__/dataRequestTemplate.mock.ts

This file was deleted.

Loading

0 comments on commit dd3a7b7

Please sign in to comment.