diff --git a/.env b/.env index 12fbf6e279..d51a806139 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -TAG=v5.0.0-rc.3 -COMPILER_TAG=v4.0.0-rc5 +TAG=v5.0.0-rc.5 +COMPILER_TAG=v4.0.0 diff --git a/es/ae/aens.js b/es/ae/aens.js index 7834b2b2ce..16a205e2fd 100644 --- a/es/ae/aens.js +++ b/es/ae/aens.js @@ -28,7 +28,7 @@ import * as R from 'ramda' import { encodeBase58Check, salt } from '../utils/crypto' -import { commitmentHash, isNameValid, getMinimumNameFee } from '../tx/builder/helpers' +import { commitmentHash, isNameValid, getMinimumNameFee, classify } from '../tx/builder/helpers' import Ae from './' import { CLIENT_TTL, NAME_FEE, NAME_TTL } from '../tx/builder/schema' @@ -76,33 +76,6 @@ async function revoke (nameId, options = {}) { return this.send(nameRevokeTx, opt) } -/** - * What kind of a hash is this? If it begins with 'ak_' it is an - * account key, if with 'ok_' it's an oracle key. - * - * @param s - the hash. - * returns the type, or throws an exception if type not found. - */ -function classify (s) { - const keys = { - ak: 'account_pubkey', - ok: 'oracle_pubkey', - ct: 'contract_pubkey', - ch: 'channel' - } - - if (!s.match(/^[a-z]{2}_.+/)) { - throw Error('Not a valid hash') - } - - const klass = s.substr(0, 2) - if (klass in keys) { - return keys[klass] - } else { - throw Error(`Unknown class ${klass}`) - } -} - /** * Update an aens entry * @instance @@ -193,7 +166,7 @@ async function claim (name, salt, options = {}) { })) const result = await this.send(claimTx, opt) - if (opt.vsn === 1 || name.length - 4 > 12) { + if (opt.vsn === 1 || name.split('.')[0].length > 12) { delete opt.vsn const nameInter = this.Chain.defaults.waitMined ? await this.aensQuery(name, opt) : {} return Object.assign(result, nameInter) diff --git a/es/tx/builder/helpers.js b/es/tx/builder/helpers.js index 2320e3253c..0af3323854 100644 --- a/es/tx/builder/helpers.js +++ b/es/tx/builder/helpers.js @@ -97,7 +97,7 @@ export function formatSalt (salt) { */ export function produceNameId (name) { const namespace = R.last(name.split('.')) - if (namespace === 'aet') return encode(hash(name.toLowerCase()), 'nm') + if (namespace === 'chain') return encode(hash(name.toLowerCase()), 'nm') return encode(nameHash(name), 'nm') } @@ -115,7 +115,7 @@ export function produceNameId (name) { */ export function commitmentHash (name, salt = createSalt()) { const namespace = R.last(name.split('.')) - if (namespace === 'aet') return `cm_${encodeBase58Check(hash(Buffer.concat([Buffer.from(name), formatSalt(salt)])))}` + if (namespace === 'chain') return `cm_${encodeBase58Check(hash(Buffer.concat([Buffer.from(name), formatSalt(salt)])))}` return `cm_${encodeBase58Check(hash(Buffer.concat([nameHash(name.toLowerCase()), formatSalt(salt)])))}` } @@ -248,6 +248,33 @@ export function isNameValid (name, throwError = true) { return true } +/** + * What kind of a hash is this? If it begins with 'ak_' it is an + * account key, if with 'ok_' it's an oracle key. + * + * @param s - the hash. + * returns the type, or throws an exception if type not found. + */ +export function classify (s) { + const keys = { + ak: 'account_pubkey', + ok: 'oracle_pubkey', + ct: 'contract_pubkey', + ch: 'channel' + } + + if (!s.match(/^[a-z]{2}_.+/)) { + throw Error('Not a valid hash') + } + + const klass = s.substr(0, 2) + if (klass in keys) { + return keys[klass] + } else { + throw Error(`Unknown class ${klass}`) + } +} + /** * Get the minimum name fee for a domain * @function @@ -293,5 +320,6 @@ export default { createSalt, buildHash, isNameValid, - produceNameId + produceNameId, + classify } diff --git a/es/tx/builder/schema.js b/es/tx/builder/schema.js index eff1aefe8d..92d1f76110 100644 --- a/es/tx/builder/schema.js +++ b/es/tx/builder/schema.js @@ -17,7 +17,7 @@ export const VSN_2 = 2 export const TX_TTL = 0 // # AENS -export const AENS_NAME_DOMAINS = ['aet', 'test'] +export const AENS_NAME_DOMAINS = ['chain', 'test'] export const NAME_TTL = 500 // # max number of block into the future that the name is going to be available // # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update diff --git a/test/integration/aens.js b/test/integration/aens.js index 11800953cf..5b0199c843 100644 --- a/test/integration/aens.js +++ b/test/integration/aens.js @@ -52,8 +52,8 @@ describe('Aens', function () { const { version } = aens.getNodeInfo() const [majorVersion] = version.split('.') nameAuctionsSupported = +majorVersion === 5 && version !== '5.0.0-rc.1' - name = randomName(13, nameAuctionsSupported ? '.aet' : '.test') // 13 name length doesn't trigger auction - name2 = randomName(13, nameAuctionsSupported ? '.aet' : '.test') + name = randomName(13, nameAuctionsSupported ? '.chain' : '.test') // 13 name length doesn't trigger auction + name2 = randomName(13, nameAuctionsSupported ? '.chain' : '.test') }) const lima = fn => async () => nameAuctionsSupported ? fn() : undefined @@ -152,7 +152,7 @@ describe('Aens', function () { it('claims names', lima(async () => { const current = await aens.address() const onAccount = aens.addresses().find(acc => acc !== current) - const name = randomName(12, '.aet') + const name = randomName(12, '.chain') const preclaim = await aens.aensPreclaim(name) preclaim.should.be.an('object')