conseiljs
Advanced tools
Comparing version 5.0.3-beta.2 to 5.0.3-beta.3
import { KeyStore, Signer } from '../../../types/ExternalInterfaces'; | ||
export declare namespace CryptonomicNameServiceHelper { | ||
function verifyDestination(server: string, address: string): Promise<boolean>; | ||
function registerName(server: string, signer: Signer, keystore: KeyStore, contract: string, name: string, resolver: string, registrationPeriod: number, registrationFee: number, operationFee: number, freight?: number, gas?: number): Promise<string>; | ||
function transferNameOwnership(server: string, signer: Signer, keystore: KeyStore, contract: string, name: string, newNameOwner: string, fee: number, freight?: number, gas?: number): Promise<string>; | ||
function updateResolver(server: string, signer: Signer, keystore: KeyStore, contract: string, name: string, resolver: string, fee: number, freight?: number, gas?: number): Promise<string>; | ||
function commitName(server: string, signer: Signer, keystore: KeyStore, contract: string, name: string, nonce: number, operationFee: number, freight?: number, gas?: number): Promise<string>; | ||
function registerName(server: string, signer: Signer, keystore: KeyStore, contract: string, name: string, nonce: number, registrationPeriod: number, registrationFee: number, operationFee: number, freight?: number, gas?: number): Promise<string>; | ||
function updateRegistrationPeriod(server: string, signer: Signer, keystore: KeyStore, contract: string, name: string, newRegistrationPeriod: number, registrationFee: number, operationFee: number, freight?: number, gas?: number): Promise<string>; | ||
function setPrimaryName(server: string, signer: Signer, keystore: KeyStore, contract: string, name: string, fee: number, freight?: number, gas?: number): Promise<string>; | ||
function deleteName(server: string, signer: Signer, keystore: KeyStore, contract: string, name: string, fee: number, freight?: number, gas?: number): Promise<string>; | ||
function getNameForAddress(server: string, mapid: number, address: string): Promise<any>; | ||
function getNameInfo(server: string, mapid: number, name: string): Promise<any>; | ||
function getSimpleStorage(server: string, contract: string): Promise<{ | ||
nameMap: number; | ||
addressMap: number; | ||
manager: string; | ||
interval: number; | ||
maxDuration: number; | ||
intervalFee: number; | ||
}>; | ||
function getNameForAddress(server: string, mapid: number, address: string): Promise<string>; | ||
function getNameInfo(server: string, mapid: number, name: string): Promise<NameServiceRecord>; | ||
function getSimpleStorage(server: string, contract: string): Promise<NameServiceStorage>; | ||
} | ||
export interface NameServiceStorage { | ||
addressMap: number; | ||
commitmentMap: number; | ||
manager: string; | ||
interval: number; | ||
maxCommitTime: number; | ||
maxDuration: number; | ||
minCommitTime: number; | ||
nameMap: number; | ||
intervalFee: number; | ||
} | ||
export interface NameServiceRecord { | ||
name: string; | ||
modified: boolean; | ||
owner: string; | ||
registeredAt: Date; | ||
registrationPeriod: number; | ||
} |
@@ -25,2 +25,3 @@ "use strict"; | ||
const TezosContractUtils_1 = require("./TezosContractUtils"); | ||
const TezosChainTypes_1 = require("../../../types/tezos/TezosChainTypes"); | ||
var CryptonomicNameServiceHelper; | ||
@@ -34,7 +35,10 @@ (function (CryptonomicNameServiceHelper) { | ||
CryptonomicNameServiceHelper.verifyDestination = verifyDestination; | ||
function registerName(server, signer, keystore, contract, name, resolver, registrationPeriod, registrationFee, operationFee, freight, gas) { | ||
function commitName(server, signer, keystore, contract, name, nonce, operationFee, freight, gas) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const parameters = `(Pair ${registrationPeriod} (Pair "${name}" "${resolver}"))`; | ||
const commitRecord = `(Pair "${name}" (Pair ${nonce} 0x${TezosMessageUtil_1.TezosMessageUtils.writeAddress(keystore.publicKeyHash)}))`; | ||
const packedCommit = TezosMessageUtil_1.TezosMessageUtils.writePackedData(commitRecord, 'record', TezosChainTypes_1.TezosParameterFormat.Michelson); | ||
const hashedCommit = TezosMessageUtil_1.TezosMessageUtils.simpleHash(Buffer.from(packedCommit, 'hex'), 32); | ||
const parameters = `0x${hashedCommit.toString('hex')}`; | ||
if (!freight || !gas) { | ||
const cost = yield TezosNodeWriter_1.TezosNodeWriter.testContractInvocationOperation(server, 'main', keystore, contract, registrationFee, operationFee, 6000, 500000, 'registerName', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
const cost = yield TezosNodeWriter_1.TezosNodeWriter.testContractInvocationOperation(server, 'main', keystore, contract, 0, operationFee, 6000, 500000, 'commit', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
if (!freight) { | ||
@@ -47,12 +51,12 @@ freight = Number(cost['storageCost']) || 0; | ||
} | ||
const nodeResult = yield TezosNodeWriter_1.TezosNodeWriter.sendContractInvocationOperation(server, signer, keystore, contract, registrationFee, operationFee, 6000, 300000, 'registerName', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
const nodeResult = yield TezosNodeWriter_1.TezosNodeWriter.sendContractInvocationOperation(server, signer, keystore, contract, 0, operationFee, 6000, 300000, 'commit', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
return TezosContractUtils_1.TezosContractUtils.clearRPCOperationGroupHash(nodeResult.operationGroupID); | ||
}); | ||
} | ||
CryptonomicNameServiceHelper.registerName = registerName; | ||
function transferNameOwnership(server, signer, keystore, contract, name, newNameOwner, fee, freight, gas) { | ||
CryptonomicNameServiceHelper.commitName = commitName; | ||
function registerName(server, signer, keystore, contract, name, nonce, registrationPeriod, registrationFee, operationFee, freight, gas) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const parameters = `(Pair "${name}" "${newNameOwner}")`; | ||
const parameters = `(Pair ${registrationPeriod} (Pair "${name}" ${nonce}))`; | ||
if (!freight || !gas) { | ||
const cost = yield TezosNodeWriter_1.TezosNodeWriter.testContractInvocationOperation(server, 'main', keystore, contract, 0, fee, 1000, 100000, 'transferNameOwnership', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
const cost = yield TezosNodeWriter_1.TezosNodeWriter.testContractInvocationOperation(server, 'main', keystore, contract, registrationFee, operationFee, 6000, 500000, 'registerName', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
if (!freight) { | ||
@@ -65,12 +69,12 @@ freight = Number(cost['storageCost']) || 0; | ||
} | ||
const nodeResult = yield TezosNodeWriter_1.TezosNodeWriter.sendContractInvocationOperation(server, signer, keystore, contract, 0, fee, freight, gas, 'transferNameOwnership', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
const nodeResult = yield TezosNodeWriter_1.TezosNodeWriter.sendContractInvocationOperation(server, signer, keystore, contract, registrationFee, operationFee, 6000, 300000, 'registerName', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
return TezosContractUtils_1.TezosContractUtils.clearRPCOperationGroupHash(nodeResult.operationGroupID); | ||
}); | ||
} | ||
CryptonomicNameServiceHelper.transferNameOwnership = transferNameOwnership; | ||
function updateResolver(server, signer, keystore, contract, name, resolver, fee, freight, gas) { | ||
CryptonomicNameServiceHelper.registerName = registerName; | ||
function updateRegistrationPeriod(server, signer, keystore, contract, name, newRegistrationPeriod, registrationFee, operationFee, freight, gas) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const parameters = `(Pair "${name}" "${resolver}")`; | ||
const parameters = `(Pair "${name}" ${newRegistrationPeriod})`; | ||
if (!freight || !gas) { | ||
const cost = yield TezosNodeWriter_1.TezosNodeWriter.testContractInvocationOperation(server, 'main', keystore, contract, 0, fee, 1000, 100000, 'updateResolver', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
const cost = yield TezosNodeWriter_1.TezosNodeWriter.testContractInvocationOperation(server, 'main', keystore, contract, registrationFee, operationFee, 1000, 100000, 'updateRegistrationPeriod', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
if (!freight) { | ||
@@ -83,12 +87,12 @@ freight = Number(cost['storageCost']) || 0; | ||
} | ||
const nodeResult = yield TezosNodeWriter_1.TezosNodeWriter.sendContractInvocationOperation(server, signer, keystore, contract, 0, fee, freight, gas, 'updateResolver', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
const nodeResult = yield TezosNodeWriter_1.TezosNodeWriter.sendContractInvocationOperation(server, signer, keystore, contract, registrationFee, operationFee, freight, gas, 'updateRegistrationPeriod', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
return TezosContractUtils_1.TezosContractUtils.clearRPCOperationGroupHash(nodeResult.operationGroupID); | ||
}); | ||
} | ||
CryptonomicNameServiceHelper.updateResolver = updateResolver; | ||
function updateRegistrationPeriod(server, signer, keystore, contract, name, newRegistrationPeriod, registrationFee, operationFee, freight, gas) { | ||
CryptonomicNameServiceHelper.updateRegistrationPeriod = updateRegistrationPeriod; | ||
function setPrimaryName(server, signer, keystore, contract, name, fee, freight, gas) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const parameters = `(Pair "${name}" ${newRegistrationPeriod})`; | ||
const parameters = `"${name}"`; | ||
if (!freight || !gas) { | ||
const cost = yield TezosNodeWriter_1.TezosNodeWriter.testContractInvocationOperation(server, 'main', keystore, contract, registrationFee, operationFee, 1000, 100000, 'updateRegistrationPeriod', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
const cost = yield TezosNodeWriter_1.TezosNodeWriter.testContractInvocationOperation(server, 'main', keystore, contract, 0, fee, 1000, 100000, 'setPrimaryName', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
if (!freight) { | ||
@@ -101,7 +105,7 @@ freight = Number(cost['storageCost']) || 0; | ||
} | ||
const nodeResult = yield TezosNodeWriter_1.TezosNodeWriter.sendContractInvocationOperation(server, signer, keystore, contract, registrationFee, operationFee, freight, gas, 'updateRegistrationPeriod', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
const nodeResult = yield TezosNodeWriter_1.TezosNodeWriter.sendContractInvocationOperation(server, signer, keystore, contract, 0, fee, freight, gas, 'deleteName', parameters, TezosTypes.TezosParameterFormat.Michelson); | ||
return TezosContractUtils_1.TezosContractUtils.clearRPCOperationGroupHash(nodeResult.operationGroupID); | ||
}); | ||
} | ||
CryptonomicNameServiceHelper.updateRegistrationPeriod = updateRegistrationPeriod; | ||
CryptonomicNameServiceHelper.setPrimaryName = setPrimaryName; | ||
function deleteName(server, signer, keystore, contract, name, fee, freight, gas) { | ||
@@ -127,4 +131,8 @@ return __awaiter(this, void 0, void 0, function* () { | ||
const packedKey = TezosMessageUtil_1.TezosMessageUtils.encodeBigMapKey(Buffer.from(TezosMessageUtil_1.TezosMessageUtils.writePackedData(address, 'address'), 'hex')); | ||
const mapResult = yield TezosNodeReader_1.TezosNodeReader.getValueForBigMapKey(server, mapid, packedKey); | ||
return jsonpath_plus_1.JSONPath({ path: '$.string', json: mapResult })[0]; | ||
try { | ||
const mapResult = yield TezosNodeReader_1.TezosNodeReader.getValueForBigMapKey(server, mapid, packedKey); | ||
return jsonpath_plus_1.JSONPath({ path: '$.string', json: mapResult })[0]; | ||
} | ||
catch (_a) { } | ||
return ''; | ||
}); | ||
@@ -138,8 +146,7 @@ } | ||
return { | ||
name, | ||
owner: jsonpath_plus_1.JSONPath({ path: '$.args[0].args[1].args[1].string', json: mapResult })[0], | ||
resolver: jsonpath_plus_1.JSONPath({ path: '$.args[1].args[1].args[1].string', json: mapResult })[0], | ||
registeredAt: new Date(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[0].string', json: mapResult })[0]), | ||
registrationPeriod: jsonpath_plus_1.JSONPath({ path: '$.args[1].args[1].args[0].int', json: mapResult })[0], | ||
modified: Boolean(jsonpath_plus_1.JSONPath({ path: '$.args[0].args[0].prim', json: mapResult })[0]) | ||
name: jsonpath_plus_1.JSONPath({ path: '$.args[0].args[1].string', json: mapResult })[0], | ||
modified: Boolean(jsonpath_plus_1.JSONPath({ path: '$.args[0].args[0].prim', json: mapResult })[0]), | ||
owner: jsonpath_plus_1.JSONPath({ path: '$.args[1].args[0].string', json: mapResult })[0], | ||
registeredAt: new Date(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[1].args[0].string', json: mapResult })[0]), | ||
registrationPeriod: jsonpath_plus_1.JSONPath({ path: '$.args[1].args[1].args[1].int', json: mapResult })[0] | ||
}; | ||
@@ -153,8 +160,11 @@ }); | ||
return { | ||
addressMap: Number(jsonpath_plus_1.JSONPath({ path: '$.args[0].args[0].int', json: storageResult })[0]), | ||
nameMap: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[1].args[0].int', json: storageResult })[0]), | ||
addressMap: Number(jsonpath_plus_1.JSONPath({ path: '$.args[0].args[0].args[0].int', json: storageResult })[0]), | ||
commitmentMap: Number(jsonpath_plus_1.JSONPath({ path: '$.args[0].args[0].args[1].int', json: storageResult })[0]), | ||
manager: jsonpath_plus_1.JSONPath({ path: '$.args[0].args[1].args[0].string', json: storageResult })[0], | ||
interval: Number(jsonpath_plus_1.JSONPath({ path: '$.args[0].args[1].args[1].int', json: storageResult })[0]), | ||
maxDuration: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[0].int', json: storageResult })[0]), | ||
intervalFee: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[1].args[1].int', json: storageResult })[0]) | ||
maxCommitTime: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[0].args[0].int', json: storageResult })[0]), | ||
maxDuration: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[0].args[1].int', json: storageResult })[0]), | ||
minCommitTime: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[1].args[0].int', json: storageResult })[0]), | ||
nameMap: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[1].args[1].args[0].int', json: storageResult })[0]), | ||
intervalFee: Number(jsonpath_plus_1.JSONPath({ path: '$.args[1].args[1].args[1].args[1].int', json: storageResult })[0]) | ||
}; | ||
@@ -161,0 +171,0 @@ }); |
{ | ||
"name": "conseiljs", | ||
"version": "5.0.3-beta.2", | ||
"version": "5.0.3-beta.3", | ||
"description": "Client-side library for dApp development.", | ||
@@ -88,3 +88,3 @@ "browser": "dist/index-web.js", | ||
"chai-as-promised": "7.1.1", | ||
"conseiljs-softsigner": "5.0.2-beta.3", | ||
"conseiljs-softsigner": "5.0.3-beta.0", | ||
"copyfiles": "2.3.0", | ||
@@ -91,0 +91,0 @@ "coveralls": "3.1.0", |
Sorry, the diff of this file is not supported yet
692464
6667