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

docs(neon-domain): Update docs for release #356

Merged
merged 1 commit into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 23 additions & 0 deletions docs/api/plugin/domain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
id: domain
title: neon-domain
---

The `domain` module is available as the plugin `@cityofzion/neon-domain`.

```js
import _Neon from "@cityofzion/neon-js";
import domainPlugin from "@cityofzion/neon-domain";

const Neon = domainPlugin(_Neon);

const provider = Neon.domain.nns.instance("NnsContractAddress");
const blockchainAddress = provider.resolveDomain(
mainNetRpcUrl,
"myaddress.neo"
);
```

The module's purpose is to integrate the common functionality of translating a human-readable address to a blockchain address.

This package is not included in `neon-js` by default. Consumers are required to include this package in by themselves.
17 changes: 17 additions & 0 deletions docs/changelog/latest.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ id: latest
title: Changelog (v4)
---

4.2.0
=====

- Neon-domain

- Ability to resolve human-friendly addresses into blockchain addresses through the invocation of domain contracts.

- Dependencies

- Dependencies are updated to latest. `bignumberjs` is not upgraded due to it being a major version jump.

- Fixes

- Fix ScriptBuilder's integer not emitted as two's complement.
- Use typing packages available for `bn.js` and `elliptic`.
- Fix `getVersion` in RPC Client not parsing response properly.

4.1.3
=====

Expand Down
4 changes: 3 additions & 1 deletion docs/changelog/v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ id: v3
title: Changelog (v3)
---

3.11.6
3.11.7
======

- Fixes

- Fix balance calculation after applying transaction.
- Remove applyTx call from Balance.calculate.
- fix getVersion parsing.
- Fix typings for `buildMultiSig`.
- Fix ScriptBuilder's integer not emitted as two's complement.

3.11.0
======
Expand Down
18 changes: 17 additions & 1 deletion packages/neon-domain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,25 @@ yarn i @cityofzion/neon-domain

```js
const neonCore = require("@cityofzion/neon-core");
const domainPlugin = require("@cityofzion/neon-api");
const domainPlugin = require("@cityofzion/neon-domain");

const neonJs = domainPlugin(neonCore);

module.exports = neonJs;
```

## API

In order to use the resolver, you must first create an instance of it using the scripthash:

```js
const provider = neonJs.domain.nns.instance(contractScriptHash);
```

The resolver interface is defined in `provider/common.ts`.

You can resolve a domain by providing a rpc node url and the domain:

```js
const blockchainAddress = provider.resolveDomain(rpcUrl, "myaddress.neo");
```
11 changes: 0 additions & 11 deletions packages/neon-domain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@
"test:integration": "jest /packages/.*/__integration__/.*",
"test:unit": "jest /packages/.*/__tests__/.*"
},
"devDependencies": {
"@types/jest": "^23.1.0",
"cross-env": "^5.2.0",
"jest": "^23.1.0",
"prettier": "^1.12.1",
"rimraf": "^2.6.2",
"ts-jest": "^23.0.1",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.14.0",
"typescript": "^3.0.1"
},
"peerDependencies": {
"@cityofzion/neon-core": "^4.0.0"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/neon-domain/src/provider/NeoNS/class.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { logging } from "@cityofzion/neon-core";
import { DomainProvider } from "../common";
import { resolveDomain } from "./core";

const log = logging.default("neon-domain");

export class NeoNS {
export class NeoNS implements DomainProvider {
private contract: string;

public get name() {
Expand Down
5 changes: 2 additions & 3 deletions packages/neon-domain/src/provider/NeoNS/core.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { logging, u, rpc, sc, wallet } from "@cityofzion/neon-core";
import { logging, rpc, sc, u } from "@cityofzion/neon-core";

const log = logging.default("neon-domain");

const operation = "resolve";

/**
* Resolve a domain to a public address.
* Resolve a domain to a public address.
* @param url - URL of an NEO RPC service.
* @param contract - the contract used to resolve
* @param domain - the domain to resolve.
Expand Down Expand Up @@ -44,5 +44,4 @@ export async function resolveDomain(
const res = await rpc.Query.invokeScript(script).execute(url);

return rpc.StringParser(res.result.stack[0]);

}
4 changes: 4 additions & 0 deletions packages/neon-domain/src/provider/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface DomainProvider {
readonly name: string;
resolveDomain(url: string, domain: string): Promise<string>;
}
7 changes: 6 additions & 1 deletion website/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@
"api/core/settings",
"api/core/logging"
],
"Plugin Modules": ["api/plugin/api", "api/plugin/nep5"]
"Plugin Modules": [
"api/plugin/api",
"api/plugin/nep5",
"api/plugin/nep9",
"api/plugin/domain"
]
},
"changelog": {
"Latest": ["changelog/latest"],
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@
dependencies:
"@types/bn.js" "*"

"@types/jest@^23.3.9":
"@types/jest@^23.1.0", "@types/jest@^23.3.9":
version "23.3.9"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-23.3.9.tgz#c16b55186ee73ae65e001fbee69d392c51337ad1"
integrity sha512-wNMwXSUcwyYajtbayfPp55tSayuDVU6PfY5gzvRSj80UvxdXEJOVPnUVajaOp7NgXLm+1e2ZDLULmpsU9vDvQw==
Expand Down Expand Up @@ -4093,7 +4093,7 @@ jest-worker@^23.2.0:
dependencies:
merge-stream "^1.0.1"

jest@^23.6.0:
jest@^23.1.0, jest@^23.6.0:
version "23.6.0"
resolved "https://registry.yarnpkg.com/jest/-/jest-23.6.0.tgz#ad5835e923ebf6e19e7a1d7529a432edfee7813d"
integrity sha512-lWzcd+HSiqeuxyhG+EnZds6iO3Y3ZEnMrfZq/OTGvF/C+Z4fPMCdhWTGSAiO2Oym9rbEXfwddHhh6jqrTF3+Lw==
Expand Down Expand Up @@ -5470,7 +5470,7 @@ preserve@^0.2.0:
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
integrity sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=

prettier@^1.15.2:
prettier@^1.12.1, prettier@^1.15.2:
version "1.15.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.15.2.tgz#d31abe22afa4351efa14c7f8b94b58bb7452205e"
integrity sha512-YgPLFFA0CdKL4Eg2IHtUSjzj/BWgszDHiNQAe0VAIBse34148whfdzLagRL+QiKS+YfK5ftB6X4v/MBw8yCoug==
Expand Down Expand Up @@ -6639,7 +6639,7 @@ trim-right@^1.0.1:
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=

ts-jest@^23.10.4:
ts-jest@^23.0.1, ts-jest@^23.10.4:
version "23.10.4"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-23.10.4.tgz#a7a953f55c9165bcaa90ff91014a178e87fe0df8"
integrity sha512-oV/wBwGUS7olSk/9yWMiSIJWbz5xO4zhftnY3gwv6s4SMg6WHF1m8XZNBvQOKQRiTAexZ9754Z13dxBq3Zgssw==
Expand Down Expand Up @@ -6669,7 +6669,7 @@ tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==

tslint-config-prettier@^1.16.0:
tslint-config-prettier@^1.14.0, tslint-config-prettier@^1.16.0:
version "1.16.0"
resolved "https://registry.yarnpkg.com/tslint-config-prettier/-/tslint-config-prettier-1.16.0.tgz#4627d0e2639554d89210e480093c381b5186963f"
integrity sha512-zu6RAcpBtqdvhT6KpBh9kRPYATjOf9BnRi718kNqVKFjEgSE4rFrPprFju1YJrkOa3RbtbWI1ZSuLd2NBX1MDw==
Expand Down Expand Up @@ -6728,7 +6728,7 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@^3.1.6:
typescript@^3.0.1, typescript@^3.1.6:
version "3.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.6.tgz#b6543a83cfc8c2befb3f4c8fba6896f5b0c9be68"
integrity sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==
Expand Down