Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.param = exports.scriptHashToAddress = void 0;
var _bs = _interopRequireDefault(require("bs58"));
var _neonJs = require("@cityofzion/neon-js");
var _config = require("./../config");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Module imports
var hash256 = _neonJs.u.hash256; // Config
/**
* Converts a script hash, returned from the Neoblog smart contract, to an address
* @param {string} scriptHash Hash to convert
* @returns {string} converted address
*/
var scriptHashToAddress = function scriptHashToAddress(scriptHash) {
var shaChecksum = hash256(_config.ADDR_VERSION + scriptHash).substr(0, 8);
return _bs.default.encode(Buffer.from(_config.ADDR_VERSION + scriptHash + shaChecksum, "hex"));
};
exports.scriptHashToAddress = scriptHashToAddress;
var param = {
string: function string(c) {
return _neonJs.sc.ContractParam.string(c);
},
registerAsset(assetID)
{
try {
let account = new wallet.Account('KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr');
let intents = [{
assetId: Neon.CONST.ASSET_ID.GAS,
value: new Neon.u.Fixed8(1), // I gueesed this :)
scriptHash: '60a7ed582c6885addf1f9bec7e413d01abe54f1a'
}];
// the interesting part: what do we want to do :)
let invoke = {
scriptHash: '60a7ed582c6885addf1f9bec7e413d01abe54f1a',
operation: 'register',
args: [
'asdsd'.hexEncode(),
const lookup = async (query) => {
if (isNOS(query)) {
return { query, target: 'welcome.html' };
} if (isLocal(query)) {
return { query, target: `http://${query}` };
} else {
const storageKey = Neon.u.str2hexstring(`${query}.target`);
const response = await client.getStorage(NS_SCRIPT_HASH, storageKey);
if (response) {
const target = Neon.u.hexstring2str(response);
return { query, target };
}
// TODO: Show an error in the status if target not found??
return { query, target: null };
}
};
const lookup = async (query) => {
if (isNOS(query)) {
return { query, target: 'welcome.html' };
} if (isLocal(query)) {
return { query, target: `http://${query}` };
} else {
const storageKey = Neon.u.str2hexstring(`${query}.target`);
const response = await client.getStorage(NS_SCRIPT_HASH, storageKey);
if (response) {
const target = Neon.u.hexstring2str(response);
return { query, target };
}
// TODO: Show an error in the status if target not found??
return { query, target: null };
}
};
value: true
});
exports.getAddressFromUserId = exports.getUserData = exports.getArticleData = exports.getArticle = exports.getLatestPost = exports.getLatest = exports.getBestRPCNode = void 0;
var _neonJs = require("@cityofzion/neon-js");
var _binascii = require("binascii");
var _neo = require("./../../helpers/neo");
var _conversion = require("./../../helpers/conversion");
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _next(value) { step("next", value); } function _throw(err) { step("throw", err); } _next(); }); }; }
var s2h = _neonJs.u.str2hexstring,
i2h = _neonJs.u.int2hex,
h2s = _neonJs.u.hexstring2str;
var getBestRPCNode =
/*#__PURE__*/
function () {
var _ref = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(host) {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return api.neonDB.getRPCEndpoint(host);
case 2:
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getAddressFromUserId = exports.getUserData = exports.getArticleData = exports.getArticle = exports.getLatestPost = exports.getLatest = exports.getBestRPCNode = void 0;
var _neonJs = require("@cityofzion/neon-js");
var _binascii = require("binascii");
var _neo = require("./../../helpers/neo");
var _conversion = require("./../../helpers/conversion");
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _next(value) { step("next", value); } function _throw(err) { step("throw", err); } _next(); }); }; }
var s2h = _neonJs.u.str2hexstring,
i2h = _neonJs.u.int2hex,
h2s = _neonJs.u.hexstring2str;
var getBestRPCNode =
/*#__PURE__*/
function () {
var _ref = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(host) {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return api.neonDB.getRPCEndpoint(host);