Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var dest = datastream.datasource.getDestination();
if (e) {
datastream.isBusy = false;
throw e;
} else {
if (response === undefined) {
let hasData = datastream.hasData;
datastream.isBusy = false;
if( hasData )
datastream.request_value_refresh();
return;
}
for (var i = 0; i < response.length; i++) {
var dval = cbor.decodeFirstSync(response[i]);
var log = dval.value;
var timestamp = dval.timestamp;
// try {
// log = cbor.decodeFirstSync(log);
// // if (debug) console.log(log);
// } catch(e) {
// console.log("WARN! Error decoding data.. ", log)
// }
// }
//console.log("Before log transform:", log);
entry = {
log: datastream.transformer(log, datastream),
time_stamp: timestamp
const _applySet = (context, address, name, value) => (possibleAddressValues) => {
let stateValueRep = possibleAddressValues[address]
let stateValue
if (stateValueRep && stateValueRep.length > 0) {
stateValue = cbor.decodeFirstSync(stateValueRep)
if (stateValue[name]) {
throw new InvalidTransaction(
`Verb is "set" but Name already in state, Name: ${name} Value: ${stateValue[name]}`)
}
}
// 'set' passes checks so store it in the state
if (!stateValue) {
stateValue = {}
}
stateValue[name] = value
return _setEntry(context, address, stateValue)
}
export function decodeDietCBOR(hexstr: string) {
const buf = hexToBuf(hexstr)
return cbor.decodeFirstSync(addCBORMapDelimiters(buf))
}
let cborDecode = function(bytecode)
{
let cborLength = bytecode[bytecode.length - 2] * 0x100 + bytecode[bytecode.length - 1]
return cbor.decodeFirstSync(new Buffer(bytecode.slice(bytecode.length - 2 - cborLength, -2)))
}
let cborDecode = function(bytecode)
{
let cborLength = bytecode[bytecode.length - 2] * 0x100 + bytecode[bytecode.length - 1]
return cbor.decodeFirstSync(new Buffer(bytecode.slice(bytecode.length - 2 - cborLength, -2)))
}
export function decodeDietCBOR(hexstr: string) {
const buf = hexToBuf(hexstr)
return cbor.decodeFirstSync(addCBORMapDelimiters(buf))
}
export const decodeDietCBOR = (data: any): any => {
return cbor.decodeFirstSync(autoAddMapDelimiters(data))
}
const _applyOperator = (verb, op) => (context, address, name, value) => (possibleAddressValues) => {
let stateValueRep = possibleAddressValues[address]
if (!stateValueRep || stateValueRep.length === 0) {
throw new InvalidTransaction(`Verb is ${verb} but Name is not in state`)
}
let stateValue = cbor.decodeFirstSync(stateValueRep)
if (stateValue[name] == null || stateValue[name] == undefined) {
throw new InvalidTransaction(`Verb is ${verb} but Name is not in state`)
}
const result = op(stateValue[name], value)
if (result < MIN_VALUE) {
throw new InvalidTransaction(
`Verb is ${verb}, but result would be less than ${MIN_VALUE}`)
}
if (result > MAX_VALUE) {
throw new InvalidTransaction(
`Verb is ${verb}, but result would be greater than ${MAX_VALUE}`)
}