Skip to content

Commit

Permalink
chore(License): added LICENSE file, updated README, and cleaned up `t…
Browse files Browse the repository at this point in the history
…est` folder (#21)
  • Loading branch information
gaballard authored Nov 2, 2022
1 parent c6354c1 commit 6512eea
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 166 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Ripple Labs, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
66 changes: 48 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@ This TypeScript SDK provides a [CCXT-compatible API](https://docs.ccxt.com/en/la

A Python version of this SDK is available [here](https://github.com/AktaryTech/xrpl-dex-sdk-python).

## Getting Started
## Installation

### Prerequisites
This package requires [NodeJS v16](https://nodejs.org/en/blog/release/v16.16.0/) or later.

Make sure you have the following installed on your system:

- NodeJS v16 (lts/gallium)
- Yarn

We recommend using [`nvm`](https://github.com/nvm-sh/nvm) to manage your NodeJS installations. If `nvm` is installed, type `nvm use` in the SDK's root folder to automatically switch to the proper Node version.
> NOTE: We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage your NodeJS installations. If `nvm` is installed, type `nvm use` in the SDK's root folder to automatically switch to the proper Node version.
### Installation
### From NPM

Add the SDK as a dependency in your app:
Add the SDK package to your project:

```
$ yarn add xrpl-dex-sdk
$ npm install -S xrpl-dex-sdk
```

#### From Source
### From Source

Make sure you have the following installed on your system:

- NodeJS v16 (lts/gallium)
- Yarn

Clone the repo, install dependencies, and build the SDK:

```
$ git clone https://github.com/[ORG_LINK_HERE]/xrpl-dex-sdk.git
$ git clone https://github.com/AktaryTech/xrpl-dex-sdk.git
$ cd xrpl-dex-sdk
$ yarn
$ yarn build
Expand All @@ -36,7 +38,7 @@ The compiled SDK will be in the `/dist` folder.

## Usage

To use the SDK, import it into your script and initialize it:
To use the SDK, import it into your script and create a new SDK instance:

```typescript
import { SDK, OrderSide, OrderType, Wallet } from 'xrpl-dex-sdk';
Expand Down Expand Up @@ -64,7 +66,7 @@ Currency codes, market symbols, and Order/Trade IDs are strings that follow the

#### Placing an Order

The following example places an Order to buy 20 TST tokens, issued by the wallet at `rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd`, at a price of 1.5 XRP each:
The following example places an Order to buy 20 TST tokens, issued by the account at `rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd`, at a price of 1.5 XRP each:

```typescript
import { SDK, OrderSide, OrderType, Wallet } from 'xrpl-dex-sdk';
Expand Down Expand Up @@ -98,7 +100,7 @@ example();

It produces the following output:

```json
```
{
...,
"status": "open",
Expand All @@ -121,7 +123,7 @@ It produces the following output:

## Methods

See the full SDK documentation [here](https://github.com/AktaryTech/xrpl-dex-sdk/tree/main/docs), or run `yarn docs` to generate the documentation locally.
For full SDK documentation, load [`docs/index.html`](docs/index.html) in your browser. Run `yarn docs:build` to re-generate documentation.

## Further Reading

Expand All @@ -130,8 +132,36 @@ See the full SDK documentation [here](https://github.com/AktaryTech/xrpl-dex-sdk
- [General Documentation](https://docs.ccxt.com/en/latest/index.html)
- [Unified API](https://docs.ccxt.com/en/latest/manual.html#unified-api)

### XRPL Ledger
### XRP Ledger

- [General Documentation](https://xrpl.org/concepts.html)
- [Decentralized Exchange](https://xrpl.org/decentralized-exchange.html)
- [dEX Tutorial](https://xrpl.org/trade-in-the-decentralized-exchange.html)

## Contributing

Pull requests, issues and comments are welcome! Make sure to add tests for new features and bug fixes.

## Contact

For questions, suggestions, etc, you can reach the maintainer at [info@aktarytech.com](mailto:info@aktarytech.com).

## License

The software is distributed under the MIT license. See [LICENSE](https://github.com/AktaryTech/xrpl-dex-sdk/blob/main/LICENSE) for details.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this library by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.

## Disclaimer

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

## Copyright

Copyright © 2022 Ripple Labs, Inc.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
"name": "xrpl-dex-sdk",
"version": "1.0.0",
"description": "TypeScript SDK for interacting with the XRPL decentralized exchange",
"license": "UNLICENSED",
"license": "MIT",
"repository": "https://github.com/AktaryTech/xrpl-dex-sdk.git",
"author": "AktaryTech <info@aktarytech.com>",
"maintainers": [
"AktaryTech <info@aktarytech.com>"
],
"main": "src/index.ts",
"scripts": {
"build": "tsc",
"watch": "yarn build --watch",
"clean": "rm -rf dist",
"test": "DEBUG=xrpl-dex-sdk nyc mocha --config=test/.mocharc.json --exit",
"test": "nyc mocha --config=test/.mocharc.json --exit",
"test:watch": "TS_NODE_PROJECT=./tsconfig.json mocha --config=test/.mocharc.json --watch --reporter dot",
"format": "prettier --write '{src,test}/**/*.ts",
"lint": "eslint . --ext .ts --max-warnings 0",
Expand Down
8 changes: 5 additions & 3 deletions src/models/ccxt/Balances.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
/**
* CCXT Balances
*
* @link https://docs.ccxt.com/en/latest/manual.html?#account-balance
* @see {@link https://docs.ccxt.com/en/latest/manual.html?#account-balance | CCXT Balances} for more information.
*/
import { Readable } from 'stream';
import { CurrencyCode } from '../common';

/**
* @category Streams
*/
export type BalanceStream = Readable;
export type BalanceStream = Readable;

/**
* @category CCXT
*
* @link https://docs.ccxt.com/en/latest/manual.html?#balance-structure
* @see {@link https://docs.ccxt.com/en/latest/manual.html?#balance-structure | Balance} for more information.
*
* @attribute
*/
export interface Balance {
// Money, available for trading, by currency (as float string)
Expand Down
71 changes: 0 additions & 71 deletions test/fees.js

This file was deleted.

27 changes: 0 additions & 27 deletions test/sdk.ts

This file was deleted.

62 changes: 17 additions & 45 deletions test/setupClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,66 +36,38 @@ async function setupMockRippledConnectionForBroadcast(
): Promise<void> {
return new Promise<void>(async (resolve, reject) => {
try {
// const servers = ports.map((port) => `ws://localhost:${port}`);
// eslint-disable-next-line max-len -- Too many rules to disable
// eslint-disable-next-line @typescript-eslint/promise-function-async, @typescript-eslint/no-unsafe-return -- Typing is too complicated, not an async function
// testcase.mocks = ports.map((port) => createMockRippled(port));
testcase.mockRippled = createMockRippled(ports[0]);
// testcase.client = new BroadcastClient(servers);
// testcase.client.connect().then(resolve).catch(reject);
testcase.sellerSdk = new SDK({
walletSecret: addresses.AKT_SELLER_SECRET,
websocketsUrl: `ws://localhost:${ports[0]}`,
});
await testcase.sellerSdk.connect();
testcase.buyerSdk = new SDK({
walletSecret: addresses.AKT_BUYER_SECRET,
websocketsUrl: `ws://localhost:${ports[0]}`,
});
await testcase.buyerSdk.connect();
testcase.buyerSdk = new SDK({
walletSecret: addresses.TST_BUYER_SECRET,
websocketsUrl: `ws://localhost:${ports[0]}`,
});
await testcase.buyerSdk.connect();
// testcase.sellerSdk = new SDK({
// walletSecret: addresses.AKT_SELLER_SECRET,
// websocketsUrl: `ws://localhost:${ports[0]}`,
// });
// await testcase.sellerSdk.connect();
// testcase.buyerSdk = new SDK({
// walletSecret: addresses.AKT_BUYER_SECRET,
// websocketsUrl: `ws://localhost:${ports[0]}`,
// });
// await testcase.buyerSdk.connect();
// testcase.buyerSdk = new SDK({
// walletSecret: addresses.TST_BUYER_SECRET,
// websocketsUrl: `ws://localhost:${ports[0]}`,
// });
// await testcase.buyerSdk.connect();
resolve();
} catch (err: unknown) {
reject(err);
}
});
}

async function setupClient(this: unknown): Promise<void> {
return getFreePort().then(async (port) => {
return setupMockRippledConnection(this, port);
});
}

async function setupBroadcast(this: unknown): Promise<void> {
export async function setupBroadcast(this: unknown): Promise<void> {
return Promise.all([getFreePort()]).then(async (ports) => {
return setupMockRippledConnectionForBroadcast(this, ports);
});
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Typing is too complicated
async function teardownClient(this: any, done: () => void): Promise<void> {
await this.sellerSdk.disconnect();
await this.buyerSdk.disconnect();
this.client
.disconnect()
.then(() => {
// eslint-disable-next-line no-negated-condition -- Easier to read with negation
if (this.mockRippled != null) {
this.mockRippled.close();
} else {
this.mocks.forEach((mock: { close: () => void }) => mock.close());
}
setImmediate(done);
})
.catch(done);
}

export { setupClient, teardownClient, setupBroadcast, createMockRippled };
export { createMockRippled };

/**
* Remote Client
Expand Down

0 comments on commit 6512eea

Please sign in to comment.