Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import '@babel/polyfill';
import Neon, { api, u } from '@cityofzion/neon-js';
import { scriptHash, localHost } from './blockchain/config';
const client = Neon.create.rpcClient(localHost);
const s2h = u.str2hexstring;
const store_key = u.str2hexstring('post.')+u.int2hex(1);
/* (async function main() {
queryBlockchain(store_key).then((result) => {
console.log(result);
}).catch((e) => {
console.log(e);
});
})(); */
export default function queryBlockchain(key) {
const query = Neon.create.query({
'method': 'getstorage',
'params': [
scriptHash,
key
]
async function resolveNameService(url) {
const { host, pathname } = url;
const endpoint = await getRPCEndpoint(NOS_TESTNET);
const client = new rpc.RPCClient(endpoint);
const storageKey = u.str2hexstring(`${host}.target`);
const response = await client.getStorage(NS_SCRIPT_HASH, storageKey);
if (!response) {
throw new Error('Not found.');
}
const target = u.hexstring2str(response);
return `${target}${pathname}`;
}
type ${'string'} ${() => u.str2hexstring(arg)}
type ${'number'} ${() => u.int2hex(arg)}
export const encode = (value) => u.str2hexstring(value);
export const decode = (value) => u.hexstring2str(value);