Skip to content

Commit

Permalink
Merge pull request #19 from ellcrys/dev
Browse files Browse the repository at this point in the history
Fixed Missing Bearer Token & Updated Readme
  • Loading branch information
ncodes committed Mar 28, 2019
2 parents 1044692 + 9374b72 commit fd4c039
Show file tree
Hide file tree
Showing 32 changed files with 846 additions and 270 deletions.
139 changes: 87 additions & 52 deletions README.md
@@ -1,84 +1,119 @@
# Spell
# Spell - Ellcrys Javascript API

The official Node.js binding for the Elld JSON-RPC 2.0 Service! This library provides the ability to query or mutate the state and configuration an Ellcrys blockchain client.
Spell is a Javascript API which provides access to the JSON-RPC 2.0 API service exposed by ELLD node. It allows a user to perform actions such as constructing and sending transactions, fetching transactions and blocks and managing a local or remote Ellcrys node. You need to have access to a running Ellcrys node to use this library.

The full documentation can be found [here](https://ellcrys.github.io/spell)

## Installation

```
### Node

```sh
npm install @ellcrys/spell
```

## Initialization
### Yarn

```sh
yarn add @ellcrys/spell
```

## Usage

To begin using the library, you must first create a Spell instance and provide connection information that will enable the client connect to the JSON-RPC 2.0 service.

To begin using the client, you must first create a Spell instance and provide connection information that will enable the client connect to the JSON-RPC 2.0 service.
```javascript
import Spell from "@ellcrys/spell";

```js
// Create a Spell Instance
const spell = new Spell();

// Configure the client to be able
// to make calls to a node's RPC service
spell.provideClient({
// The RPC address of an Elld node
// Provide connection options to a local or remote Ellcrys node
const resp = spell.provideClient({
host: "127.0.0.1",
// The RPC port of an Elld node
port: 8999,
// Optional: RPC username to access private endpoints
username: "admin",
// Optional: RPC password to access private endpoints
password: "secret",
username: "admin", // optional
password: "secret", // optional
});

// spell.provideClient returns a promise that is resolved
// when the node responds to an initial ping message.
resp.then(async () => {
// do something with spell
const basic = await spell.node.basic();
console.log(basic);
}).catch(console.error);
```

`provideClient` will attempt to call `rpc_echo` to test the connection; It will return a rejected promise if it failed to successfully reach the node.
Once `spell` has been initialized with a valid node connection information. You can start accessing the RPC methods. You can get the balance of an account like this:

```javascript
spell.ell.getBalance("e2763...").then((bal) => {
console.log(bal); // "20.00"
});
```

## Calling An RPC Method
## Calling RPC Methods

Spell closely replicates the same namespace-based structure used to organize the RPC methods in Elld. For example, RPC methods on Elld are named and addressed in the following format:
Spell closely replicates the same namespace-based structure used to organize the JSON-RPC 2.0 methods of an Ellcrys node. For example, RPC methods are named and addressed in the following format:

```
```txt
{namespace}_{method}
Where:
- namespace: The group name a method belongs to
- namespace: The group name a method belongs to.
- method: Is the name of the method.
```

All supported namespaces can be accessed from the spell instance like this:
A method `getBalance` of a namespace `ell` can be accessed like this:

```js
spell.namespace.method();
```javascript
spell.ell.getBalance(...)
```

## Get A Node's Basic Information

We will demonstrate how to call an RPC method by getting the basic information of the provisioned node.

```js
// Get a node's basic information. The JSON-RPC 2.0 method is
// `node_basic`
spell.node.basic();

// Output:
/*
{
buildCommit: '599bc716098869a0d2a15431447c65823c207e3f',
buildDate: '2019-01-19T21:57:50Z',
buildVersion: '0.1.6-alpha.2',
goVersion: 'go1.10.4',
id: '12D3KooWKAEhd4DXGPeN71FeSC1ih86Ym2izpoPueaCrME8xu8UM',
mode: 'production',
name: 'deeply-suitable-fowl',
netVersion: '0001',
syncing: false,
tipBlockDifficulty: '0x215915d',
tipBlockHash: '0x1cf3109273187d2c42ad077fc7b491eae8a4fd1878ef9ec74f0d12d4843a9168',
tipBlockHeight: '0x45d9',
tipBlockTotalDifficulty: '0xb60329599c'
}
*/
## TypeScript Support

The library includes TypeScript types within it. You can use spell like this:

```javascript
import Spell from "@ellcrys/spell";
```

## Documentation

See API Reference [here](https://ellcrys.github.io/spell)
Find the complete documentation [here](https://ellcrys.github.io/spell)

## Contributing

We appreciate contributions. They help move us faster and improve the quality of the project. Please follow this steps to contribute:

- Fork this repository and clone it locally.
`git clone https://github.com/ellcrys/spell`
- Add the remote upstream
`git remote add upstream git://github.com/ellcrys/spell`
- Pull upstream changes
`git fetch upstream`
- Create a new branch to work on. Create your branch from `dev`.
- Add your changes, add or adapt tests, run linter and generate doc.
- Push your branch to your fork.
- Create a pull request targeting the `dev` branch.

### Requirements

- [Node.js](https://nodejs.org/)
- npm
- Typescript

### Commands

```sh
npm i // Install dependencies
npm run ts-watch // Watch and compile TypeScript files into `lib`
npm run gen-docs // Re-generate documentation
npm run test // Runs all tests
```

## Useful Links

- [Discord Community](https://discord.gg/QH2n2hT)
- [Gitter](https://gitter.im/ellnet)
- [Ellcrys Documentation](https://docs.ellcrys.org)
2 changes: 1 addition & 1 deletion docs/assets/js/search.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/classes/auth.auth-1.html
Expand Up @@ -133,7 +133,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/namespaces/auth.ts#L13">namespaces/auth.ts:13</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/namespaces/auth.ts#L13">namespaces/auth.ts:13</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -166,7 +166,7 @@ <h3><span class="tsd-flag ts-flagProtected">Protected</span> client</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="namespace.namespace-1.html">Namespace</a>.<a href="namespace.namespace-1.html#client">client</a></p>
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/namespaces/namespace.ts#L14">namespaces/namespace.ts:14</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/namespaces/namespace.ts#L14">namespaces/namespace.ts:14</a></li>
</ul>
</aside>
</section>
Expand All @@ -183,7 +183,7 @@ <h3>authenticate</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/namespaces/auth.ts#L34">namespaces/auth.ts:34</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/namespaces/auth.ts#L34">namespaces/auth.ts:34</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down
12 changes: 6 additions & 6 deletions docs/classes/ell.ell-1.html
Expand Up @@ -136,7 +136,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/namespaces/ell.ts#L16">namespaces/ell.ts:16</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/namespaces/ell.ts#L16">namespaces/ell.ts:16</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -169,7 +169,7 @@ <h3><span class="tsd-flag ts-flagProtected">Protected</span> client</h3>
<aside class="tsd-sources">
<p>Inherited from <a href="namespace.namespace-1.html">Namespace</a>.<a href="namespace.namespace-1.html#client">client</a></p>
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/namespaces/namespace.ts#L14">namespaces/namespace.ts:14</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/namespaces/namespace.ts#L14">namespaces/namespace.ts:14</a></li>
</ul>
</aside>
</section>
Expand All @@ -186,7 +186,7 @@ <h3>balance</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/namespaces/ell.ts#L76">namespaces/ell.ts:76</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/namespaces/ell.ts#L76">namespaces/ell.ts:76</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -214,7 +214,7 @@ <h3>get<wbr>Balance</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/namespaces/ell.ts#L56">namespaces/ell.ts:56</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/namespaces/ell.ts#L56">namespaces/ell.ts:56</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -248,7 +248,7 @@ <h3>send</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/namespaces/ell.ts#L35">namespaces/ell.ts:35</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/namespaces/ell.ts#L35">namespaces/ell.ts:35</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -284,7 +284,7 @@ <h3>send<wbr>Raw</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/namespaces/ell.ts#L88">namespaces/ell.ts:88</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/namespaces/ell.ts#L88">namespaces/ell.ts:88</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down
10 changes: 5 additions & 5 deletions docs/classes/key.address.html
Expand Up @@ -121,7 +121,7 @@ <h3><span class="tsd-flag ts-flagPrivate">Private</span> address</h3>
<div class="tsd-signature tsd-kind-icon">address<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L377">key.ts:377</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L377">key.ts:377</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -151,7 +151,7 @@ <h3>to<wbr>String</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L384">key.ts:384</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L384">key.ts:384</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -173,7 +173,7 @@ <h3><span class="tsd-flag ts-flagStatic">Static</span> from</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L362">key.ts:362</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L362">key.ts:362</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -212,7 +212,7 @@ <h3><span class="tsd-flag ts-flagStatic">Static</span> get<wbr>Validation<wbr>Er
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L337">key.ts:337</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L337">key.ts:337</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -258,7 +258,7 @@ <h3><span class="tsd-flag ts-flagStatic">Static</span> is<wbr>Valid</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L313">key.ts:313</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L313">key.ts:313</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down
18 changes: 9 additions & 9 deletions docs/classes/key.hdkey.html
Expand Up @@ -135,7 +135,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L434">key.ts:434</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L434">key.ts:434</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -180,7 +180,7 @@ <h3><span class="tsd-flag ts-flagPrivate">Private</span> m<wbr>Chain<wbr>Code</h
<div class="tsd-signature tsd-kind-icon">m<wbr>Chain<wbr>Code<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Buffer</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L434">key.ts:434</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L434">key.ts:434</a></li>
</ul>
</aside>
</section>
Expand All @@ -190,7 +190,7 @@ <h3><span class="tsd-flag ts-flagPrivate">Private</span> m<wbr>Key</h3>
<div class="tsd-signature tsd-kind-icon">m<wbr>Key<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Buffer</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L433">key.ts:433</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L433">key.ts:433</a></li>
</ul>
</aside>
</section>
Expand All @@ -207,7 +207,7 @@ <h3>chain<wbr>Code</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L463">key.ts:463</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L463">key.ts:463</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -234,7 +234,7 @@ <h3>ckd</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L476">key.ts:476</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L476">key.ts:476</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -282,7 +282,7 @@ <h3>derive</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L496">key.ts:496</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L496">key.ts:496</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -319,7 +319,7 @@ <h3>key</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L453">key.ts:453</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L453">key.ts:453</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -346,7 +346,7 @@ <h3>private<wbr>Key</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L523">key.ts:523</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L523">key.ts:523</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -374,7 +374,7 @@ <h3><span class="tsd-flag ts-flagStatic">Static</span> from<wbr>Master<wbr>Seed<
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/106af17/src/lib/key.ts#L425">key.ts:425</a></li>
<li>Defined in <a href="https://github.com/ellcrys/spell.js/blob/cda6112/src/lib/key.ts#L425">key.ts:425</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down

0 comments on commit fd4c039

Please sign in to comment.