Skip to content

Commit

Permalink
resolveName: Document verify option
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Apr 20, 2021
1 parent 315a78a commit ca86559
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/chain/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,19 @@ async function getName (name) {
* Resolve AENS name and return name hash
* @param {String} nameOrId
* @param {String} prefix
* @param {Boolean} verify
* @param {Boolean} resolveByNode
* @param {Object} [options]
* @param {Boolean} [options.verify] Enables resolving by node, needed for compatibility with `verify` option of other methods
* @param {Boolean} [options.resolveByNode] Enables pointer resolving using node (isn't more durable to resolve it on the node side?)
* @return {String} Address or AENS name hash
*/
async function resolveName (nameOrId, prefix, { verify = false, resolveByNode = false } = {}) {
async function resolveName (nameOrId, prefix, { verify, resolveByNode } = {}) {
if (!nameOrId || typeof nameOrId !== 'string') {
throw new Error('Invalid name or address. Should be a string')
}
const prefixes = Object.keys(NAME_ID_KEY)
if (!nameOrId || typeof nameOrId !== 'string') throw new Error('Invalid name or address. Should be a string')
if (!prefixes.includes(prefix)) throw new Error(`Invalid prefix ${prefix}. Should be one of [${prefixes}]`)
if (!prefixes.includes(prefix)) {
throw new Error(`Invalid prefix ${prefix}. Should be one of [${prefixes}]`)
}
if (assertedType(nameOrId, prefix, true)) return nameOrId

if (isNameValid(nameOrId)) {
Expand Down

0 comments on commit ca86559

Please sign in to comment.