How to use the protobufjs/light.Root function in protobufjs

To help you get started, we’ve selected a few protobufjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github berty / berty / client / packages / bridge / service / api / node / service.js View on Github external
import pbjs from 'protobufjs/light'
import jsonDescriptor from './service.pb.json'

// create daemon service
const root = pbjs.Root.fromJSON(jsonDescriptor)
export const ServiceName = 'berty.node.Service'
export const service = root.lookup(ServiceName)
github medibloc / panacea-js-old / test / local / transaction / payload.js View on Github external
const genPayloadPb = (payload, type) => {
  const root = protobuf.Root.fromJSON(jsonDescriptor);
  const PayloadTarget = root.lookupType(type);
  const message = PayloadTarget.create(payload);
  return PayloadTarget.encode(message).finish().toString('hex');
};
github berty / berty / client / react-native / app / bridge / service / index.js View on Github external
const exportPbJson = (jsonDescriptor, ServiceName) => {
  const pbFromJson = pbjs.Root.fromJSON(jsonDescriptor)
  return pbFromJson.lookup(ServiceName)
}
github medibloc / panacea-js-old / src / utils / proto.js View on Github external
const recoverFromPayload = (payload, type, jsonDescriptor) => {
  const payloadBuf = binary.from(payload, 'hex');
  const root = protobuf.Root.fromJSON(jsonDescriptor);
  const PayloadTarget = root.lookupType(type.charAt(0).toUpperCase() + type.slice(1));
  const payloadMessage = PayloadTarget.decode(payloadBuf);
  return PayloadTarget.toObject(payloadMessage, {
    enums: String,
    longs: Number,
  });
};
github berty / berty / client / packages / bridge / service / entity / message.js View on Github external
import pbjs from 'protobufjs/light'
import jsonDescriptor from './message.pb.json'

const root = pbjs.Root.fromJSON(jsonDescriptor)
export const Message = root.lookup('berty.entity.Message')
export default Message
github berty / berty / client / packages / bridge / service / entity / kind.js View on Github external
import pbjs from 'protobufjs/light'
import jsonDescriptor from './kind.pb.json'

const root = pbjs.Root.fromJSON(jsonDescriptor)
export const Kind = root.lookup('berty.entity.Kind')
export default Kind
github berty / berty / client / packages / bridge / service / entity / event.js View on Github external
import pbjs from 'protobufjs/light'
import jsonDescriptor from './event.pb.json'

const root = pbjs.Root.fromJSON(jsonDescriptor)
export const Event = root.lookup('berty.entity.Event')
export default Event