Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
otherview committed Oct 23, 2023
1 parent c85c563 commit d914756
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
58 changes: 58 additions & 0 deletions tools/gateway-js/gateway-lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Obscuro Gateway JS

A JavaScript library for the gateway, providing streamlined access and functionalities for interacting with the Obscuro network.

## Table of Contents

- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Build](#build)
- [Contribute](#contribute)
- [License](#license)

## Features

- Seamless connection to Obscuro Network.
- Easy-to-use methods for joining and authenticating.
- External consumption support through CDN or NPM.

## Installation

To install `obscuro-gateway-js`, use npm:

\`\`\`bash
npm install obscuro-gateway-js
\`\`\`

## Usage

\`\`\`javascript

const Gateway = require('obscuro-gateway-js');

const gateway = new Gateway(httpURL, wsURL, provider);
await gateway.join();
await gateway.registerAccount(account);

\`\`\`

## Build

To build for development:

\`\`\`bash
npm run dev
\`\`\`

For production:

\`\`\`bash
npm run build
\`\`\`

The production build will be available for external consumption on GitHub Pages at `https://go-obscuro.github.io/obscuronet/gateway.bundle.js`.

## Contribute

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
2 changes: 1 addition & 1 deletion tools/gateway-js/gateway-lib/dist/gateway.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tools/gateway-js/gateway-lib/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Gateway {
}
}

async registerAccount(privateKey, address) {
async registerAccount(address) {
const message = `Register ${this.userID} for ${address.toLowerCase()}`;
let signature = ""

Expand Down
4 changes: 2 additions & 2 deletions tools/gateway-js/gateway-lib/gateway.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Gateway', () => {
request: jest.fn().mockResolvedValue("mockSignature")
})

const result = await gateway.registerAccount('privateKey', 'address');
const result = await gateway.registerAccount( 'address');

expect(result).toBe('Account registered');
});
Expand All @@ -54,6 +54,6 @@ describe('Gateway', () => {
request: jest.fn().mockRejectedValue(new Error('Signature error')),
})

await expect(gateway.registerAccount('privateKey', 'address')).rejects.toThrow('Failed to sign message. Error: Signature error');
await expect(gateway.registerAccount('address')).rejects.toThrow('Failed to sign message. Error: Signature error');
});
});

0 comments on commit d914756

Please sign in to comment.