Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var caller = this;
var stripped = signed.substring(2, signed.length)
var byteSig = new Buffer(Buffer.from(stripped, 'hex'));
console.log(byteSig.toString('base64'))
const byteschannelID = Buffer.alloc(4);
byteschannelID.writeUInt32BE(this.channelHelper.getChannelId(), 0);
let requestObject = ({"channelId":byteschannelID, "signature":byteSig})
const requestHeaders = {}
const packageName = 'escrow'
const serviceName = 'PaymentChannelStateService'
const methodName = 'GetChannelState'
const Service = Root.fromJSON(serviceStateJSON).lookup(serviceName);
const serviceObject = Service.create(rpcImpl(this.channelHelper.getEndpoint(), packageName, serviceName, methodName, requestHeaders), false, false)
return new Promise(function(resolve, reject) {
grpcRequest(serviceObject, methodName, requestObject)
.then(response => {
if(typeof response.currentSignedAmount !== 'undefined') {
console.log("Setting currentSignedAmount " + response.currentSignedAmount);
let buffer = Buffer.from(response.currentSignedAmount);
const currentSignedAmount = buffer.readUIntBE(0, response.currentSignedAmount.length);
if(typeof currentSignedAmount !== 'undefined') {
caller.channelHelper.setCurrentSignedAmount(currentSignedAmount);
const nonceBuffer = Buffer.from(response.currentNonce);
caller.channelHelper.setNonce(nonceBuffer.readUIntBE(0, response.currentNonce.length));
console.log("Nonce " + nonceBuffer.readUIntBE(0, response.currentNonce.length));
}
this.props.agent.contractInstance.validateJobInvocation(this.state.jobAddress, v, r, s, {from: this.props.account}).then(validateJob => {
console.log('job invocation validation returned: ' + validateJob[0]);
const requestHeaders = { "snet-job-address": this.state.jobAddress, "snet-job-signature": signature }
const requestObject = params
const serviceSpecJSON = Root.fromJSON(this.props.serviceSpec[0])
const packageName = Object.keys(serviceSpecJSON.nested)
.find(key =>
typeof serviceSpecJSON.nested[key] === "object" &&
hasOwnDefinedProperty(serviceSpecJSON.nested[key], "nested")
)
if (this.props.serviceEncoding === "json") {
grpcJSONRequest(this.props.agent.endpoint, packageName, serviceName, methodName, requestHeaders, requestObject)
.then(response => {
this.setState(() => ({ "jobResult": response }))
this.nextJobStep()
})
.catch(console.error)
} else if (this.props.serviceEncoding === "proto") {
const Service = serviceSpecJSON.lookup(serviceName)
const serviceObject = Service.create(rpcImpl(this.props.agent.endpoint, packageName, serviceName, methodName, requestHeaders), false, false)
import { Root, Type, INamespace } from 'protobufjs'
import * as PoetProto from './Proto.json'
const poetProtoRoot = Root.fromJSON(PoetProto as INamespace)
export const ClaimProto = poetProtoRoot.lookup('Poet.Claim') as Type
export const AttributeProto = poetProtoRoot.lookup('Poet.Attribute') as Type
window.setProtoMessage = function setProtoMessage(value){
document.getElementById("loading_container").style.display = "none";
document.getElementById('annotate_viz').style.display = 'block';
var root = Root.fromJSON(messageFormat);
const ParcelMessage = root.lookupType("TuriCreate.Annotation.Specification.Parcel");
const buffer = Uint8Array.from(atob(value), c => c.charCodeAt(0));
var decoded = ParcelMessage.decode(buffer);
if (decoded.hasOwnProperty('metadata')) {
component_rendered = ReactDOM.render(, document.getElementById('annotate_viz'));
spec_type = SpecType.annotate;
} else if(decoded.hasOwnProperty('data')) {
for (var i = 0; i < decoded["data"]["data"].length; i++) {
const row_index = decoded["data"]["data"][i]["rowIndex"];
const type = decoded["data"]["data"][i]["images"][0]["type"];
const data = decoded["data"]["data"][i]["images"][0]["imgData"];
const width = decoded["data"]["data"][i]["images"][0]["width"];
const height = decoded["data"]["data"][i]["images"][0]["height"];
export function loadProtos() {
return Root.fromJSON(PROTO_DATA);
}
getHelper = (start, end, type) => {
const root = Root.fromJSON(messageFormat);
const ParcelMessage = root.lookupType("TuriCreate.Annotation.Specification.ClientRequest");
const payload = {"getter": {"type": type, "start": start, "end": end}};
const err = ParcelMessage.verify(payload);
if (err)
throw Error(err);
const message = ParcelMessage.create(payload);
const buffer = ParcelMessage.encode(message).finish();
const encoded = btoa(String.fromCharCode.apply(null, buffer));
if (window.navigator.platform == 'MacIntel') {
window.webkit.messageHandlers["scriptHandler"].postMessage({status: 'writeProtoBuf', message: encoded});
} else {
window.postMessageToNativeClient(encoded);
}
}
.then(serviceSpec => new Promise(function(resolve) {
const serviceSpecJSON = Root.fromJSON(serviceSpec[0]);
caller.setServiceSpec(serviceSpecJSON)
resolve();
}));
}
import { Root, Type, INamespace } from 'protobufjs'
import { PoetProto } from './PoetProtoJson'
const poetProtoRoot = Root.fromJSON(PoetProto as INamespace)
export const ClaimProto = poetProtoRoot.lookup('Poet.Claim') as Type
export const AttributeProto = poetProtoRoot.lookup('Poet.Attribute') as Type
import { Root, Type, INamespace } from 'protobufjs'
import * as PoetProto from './PoetProto.json'
const poetProtoRoot = Root.fromJSON(PoetProto as INamespace)
export const ClaimProto = poetProtoRoot.lookup('Poet.Claim') as Type
export const AttributeProto = poetProtoRoot.lookup('Poet.Attribute') as Type