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

Methods for node HTTP routes: getNameByHash, getNameResource, getNameProof, grindName #11

Closed
wants to merge 2 commits into from
Closed
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
50 changes: 50 additions & 0 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,56 @@ class NodeClient extends Client {
return this.get('/');
}

/**
* Get nameinfo for a given name.
* @returns {Promise}g
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra g character here

*/

getNameInfo(name) {
assert(typeof name === 'string');
return this.get(`/info/name/${name}`);
}

/**
* Get nameinfo for a given name.
* @returns {Promise}
*/

getNameByHash(nameHash) {
assert(typeof nameHash === 'string');
return this.get(`/name/hash/${nameHash}`);
}

/**
* Get resource for a given name.
* @returns {Promise}
*/

getNameResource(name) {
assert(typeof name === 'string');
return this.get(`/resource/name/${name}`);
}

/**
* Get proof for a given name.
* @returns {Promise}
*/

getNameProof(name) {
assert(typeof name === 'string');
return this.get(`/proof/name/${name}`);
}

/**
* Grind a name.
* @returns {Promise}
*/

grindName(size) {
assert(typeof size === 'number');
return this.get(`/grind?size=${size}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query params can be passed in an object, so you would want something more like:

return this.get('/grind', { size })

}

/**
* Get coins that pertain to an address from the mempool or chain database.
* Takes into account spent coins in the mempool.
Expand Down