From dd8d17c2b1c833a48b6ae4eef31b291c52837b2d Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Mon, 8 Apr 2019 17:53:38 -0500 Subject: [PATCH 01/36] prune obsolete examples/payment --- examples/payment/aliceBobWallets.rho | 39 -------- examples/payment/assets.js | 15 --- examples/payment/sending.rho | 67 ------------- examples/payment/testPay.js | 138 --------------------------- 4 files changed, 259 deletions(-) delete mode 100644 examples/payment/aliceBobWallets.rho delete mode 100644 examples/payment/assets.js delete mode 100644 examples/payment/sending.rho delete mode 100644 examples/payment/testPay.js diff --git a/examples/payment/aliceBobWallets.rho b/examples/payment/aliceBobWallets.rho deleted file mode 100644 index 264e172..0000000 --- a/examples/payment/aliceBobWallets.rho +++ /dev/null @@ -1,39 +0,0 @@ -/** - * aliceBobWallets - simulate genesis where Alice has 100 REV. - * - * We assume the node is started with --has-faucet. - * This is something of a KLUDGE. The right way would be to - * put Alice's balance in wallets.txt. - */ -new - makeFaucetWallet, - exports(`export:`), // see loader.rho / loading.js - trace(`rho:io:stderr`) -in { - new walletCh in { - makeFaucetWallet!(100, - // Alice's public key - "ed25519", "288755c48c3951f89c5f0ffe885088dc0970fd935bc12adfdd81f81bb63d6219", - *walletCh) | - // - for (@[aliceWallet] <- walletCh) { - trace!({"aliceWallet": aliceWallet}) | - exports!(aliceWallet) - } - } | - - contract makeFaucetWallet(@amount, @algorithm, @pk, return) = { - new sysCh, faucetCh, lookup(`rho:registry:lookup`) in { - // This URI comes from SystemInstancesRegistry.rho. - lookup!(`rho:id:wdwc36f4ixa6xacck3ddepmgueum7zueuczgthcqp6771kdu8jogm8`, *sysCh) | - for(@(_, sys) <- sysCh) { - // This lookup requires that the node is started with --has-faucet - @sys!("lookup", "faucet", *faucetCh) | - for(faucet <- faucetCh) { - trace!({"faucet": *faucet}) | - faucet!(amount, algorithm, pk, *return) - } - } - } - } -} diff --git a/examples/payment/assets.js b/examples/payment/assets.js deleted file mode 100644 index e8f6c5c..0000000 --- a/examples/payment/assets.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * assets - treat text files as link-time artifacts. - * - * With respect to ocap discipline, we regard this as part of the - * module loading infrastructure rather than a run-time operation. - * - * An alternative implementation would be a pre-processor - * that in-lines the contents of the linked data as constants. - */ -const { readFileSync } = require('fs'); - -exports.link = link; -function link(name) { - return readFileSync(require.resolve(name), 'utf8'); -} diff --git a/examples/payment/sending.rho b/examples/payment/sending.rho deleted file mode 100644 index a7a1e92..0000000 --- a/examples/payment/sending.rho +++ /dev/null @@ -1,67 +0,0 @@ -/** - * sending - send REV from registered wallet to party identified by pk. - */ -new send, makePayeeWallet, - exports(`export:`), - trace(`rho:io:stderr`), - rl(`rho:registry:lookup`), - ri(`rho:registry:insertArbitrary`) -in { - exports!(*send) | - - // return: URI of wallet created for payee - contract send(@{walletURI /\ URI}, @{amount /\ Int}, - @{nonce /\ Int}, @{sig /\ String}, - @{payeePk /\ String}, - via, return) = { - new wCh, statusCh, pwCh, dCh in { - rl!(walletURI, *wCh) | - for (@wallet <- wCh) { - trace!({ - "wallet": wallet, - "secured args": [nonce, amount, *via], - "secured args bytes": [nonce, amount, *via].toByteArray() - }) | - - makePayeeWallet!(payeePk, *pwCh) | - - // ISSUE: if you pass in bytes rather than hex for sig, nothing comes back - @wallet!("transfer", amount, nonce, sig, *via, *statusCh) | - for(@status <- statusCh) { - trace!({"transfer status": status}) | - if (status == "Success") { - for(pmt <- via; @[payeeWallet] <- pwCh) { - trace!({"pmt": *pmt, "payee wallet": payeeWallet}) | // ISSUE: purses can go out of scope and get lost forever - @payeeWallet!("deposit", amount, *pmt, *dCh) | - for (@depositResult <- dCh) { - trace!({"deposit result": depositResult}) | - new ch in { ri!(payeeWallet, *ch) | for (@uri <- ch) { return!(uri) } } - } - } - } else { - trace!("lose!") - // TODO: return errors - } - } - } } - } | - - contract makePayeeWallet(@pk, return) = { - new sysCh, bwCh, revCh, emptyREVPurseCh in { - // See casper/src/main/rholang/SystemInstancesRegistry.rho - rl!(`rho:id:wdwc36f4ixa6xacck3ddepmgueum7zueuczgthcqp6771kdu8jogm8`, *sysCh) | - // See casper/src/main/rholang/BasicWallet.rho - rl!(`rho:id:3yicxut5xtx5tnmnneta7actof4yse3xangw4awzt8c8owqmddgyms`, *bwCh) | - for(@(_, sys) <- sysCh; @(_, BasicWallet) <- bwCh) { - @sys!("lookup", "rev", *revCh) | - for(rev <- revCh) { - rev!("makePurse", *emptyREVPurseCh) | - for(empty <- emptyREVPurseCh) { - trace!({"payee wallet": *return}) | - @BasicWallet!(*empty, "ed25519", pk, *return) - } - } - } - } - } -} diff --git a/examples/payment/testPay.js b/examples/payment/testPay.js deleted file mode 100644 index 7a021e1..0000000 --- a/examples/payment/testPay.js +++ /dev/null @@ -1,138 +0,0 @@ -/** Scenario: Alice pays Bob 10 REV. - -Alice has 100 REV at genesis. All she knows about Bob is his public key. - -ISSUE: should be: all she knows about Bob is his eth address. - -*/ -/* global require */ -// @flow - -const { URL } = require('url'); - -const { GPrivate } = require('../../protobuf/RhoTypes.js'); -const { - RNode, b2h, h2b, RHOCore, makeProxy, sendCall, keyPair, blake2b256Hash, -} = require('../..'); -const { link } = require('./assets'); -const { loadRhoModules, unforgeableWithId } = require('../../src/loading'); - -/*:: -import type { ModuleInfo } from '../../src/loading'; - */ - -const defaultDeployInfo = { - from: '0x1', - nonce: 0, - phloPrice: 1, - phloLimit: 100000, - sig: h2b(''), - sigAlgorithm: 'ed25519', - term: '', - timestamp: 0, -}; -const user = h2b('d72d0a7c0c9378b4874efbf871ae8089dd81f2ed3c54159fffeaba6e6fca4236'); // arbitrary - -const Scenario = { - amount: 10, - aliceKey: keyPair(h2b('f6664a95992958bbfeb7e6f50bbca2aa7bfd015aec79820caf362a3c874e9247')), - bobPk: keyPair(h2b('9217509f61d80a69627daad29796774d1b65d06e70762aa114e9aa534c0d76bb')).publicKey(), -}; - - -async function test({ rnode, clock }) { - const aliceWalletURI = await genesis({ rnode, clock }); - - const [sendMod] /*: ModuleInfo[] */ = await loadRhoModules( - [link('./sending.rho')], user, - { rnode, clock }, - ); - - await alicePaysBob({ aliceWalletURI, sendURI: sendMod.URI }, { rnode, clock }); -} - - -async function alicePaysBob({ aliceWalletURI, sendURI }, { rnode, clock }) { - const aliceWallet = makeProxy(aliceWalletURI, { user, ...defaultDeployInfo }, { rnode, clock }); - - const aliceBalance = await aliceWallet.getBalance(); - console.log({ aliceBalance }); - const aliceNonce = await aliceWallet.getNonce(); - if (!(typeof aliceNonce === 'number')) { throw new Error('expected number; got: ${typeof aliceNonce'); } - console.log({ aliceNonce }); - - const tPmt = clock().valueOf(); - - const bobWalletURI = await sendCall( - { - target: sendURI, - args: [aliceWalletURI, Scenario.amount, aliceNonce + 1, 'sigReplaced', Scenario.bobPk], - method: '', - }, - { ...defaultDeployInfo, user, timestamp: tPmt, term: '' }, - { rnode, predeclare: ['via'], fixArgs: signWith(Scenario.aliceKey) }, - ); - - if (!(bobWalletURI instanceof URL)) { throw new Error('expected URL'); } - console.log(`URI of wallet for Bob: ${String(bobWalletURI)}`); - - const bobWallet = makeProxy(bobWalletURI, { user, ...defaultDeployInfo }, { rnode, clock }); - - const bobBalance = await bobWallet.getBalance(); - console.log({ bobBalance }); - - const aliceBalanceAfter = await aliceWallet.getBalance(); - console.log({ aliceBalanceAfter }); -} - - -// Compute signature over [nonce, amount, retCh] as in BasicWallet.rho -function signWith(key) { - function basicWalletSig([payee, amount, nonce, _sig, pk], [dest] /*: GPrivate[]*/) { - // const sigHex = basicWalletSig(Scenario.aliceKey, Scenario.amount, aliceNonce + 1, viaId); - - console.log( - 'preview of unforgeable name needed for signing', - unforgeableWithId(dest.id), - ); - - const msg = RHOCore.toByteArray(RHOCore.fromJSData([nonce, amount, dest])); - - const sigHex = key.signBytesHex(blake2b256Hash(msg)); - console.log(`sign[${key.publicKey()}](${b2h(msg)}) = ${sigHex}`); - - return [payee, amount, nonce, sigHex, pk]; - } - return basicWalletSig; -} - - -async function genesis({ rnode, clock }) /*: Promise */ { - const [walletMod] /*: ModuleInfo[] */= await loadRhoModules( - [link('./aliceBobWallets.rho')], user, - { rnode, clock }, - ); - return walletMod.URI; -} - - -/*global module */ -if (require.main === module) { - /* global process */ - /* eslint-disable global-require */ - const endpoint = { - host: process.env.npm_config_host || 'localhost', - port: parseInt(process.env.npm_config_port || '40401', 10), - }; - const rnode = RNode(require('grpc'), endpoint); - - try { - test({ - rnode, - clock: () => new Date(), - }); - } catch (oops) { - console.error(oops); - process.exit(1); - } -} From 5283f9abdf85307ec464a97d960974de388f320a Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Mon, 8 Apr 2019 17:57:55 -0500 Subject: [PATCH 02/36] tools.rho: oops: export tweak --- rclient/src/tools.rho | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rclient/src/tools.rho b/rclient/src/tools.rho index 1375bd5..9c5614b 100644 --- a/rclient/src/tools.rho +++ b/rclient/src/tools.rho @@ -4,8 +4,8 @@ new Tools, RevVaultCh, - export, // ISSUE: rholang extension -// export(`export:`), // ISSUE: rholang extension +// export, // ISSUE: rholang extension + export(`export:`), // ISSUE: rholang extension trace(`rho:io:stderr`), lookup(`rho:registry:lookup`), insertArbitrary(`rho:registry:insertArbitrary`), From 1ce2a4395341563d34069c9737b9386f8f43ec83 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Mon, 8 Apr 2019 17:58:15 -0500 Subject: [PATCH 03/36] SignDeployment works with rclient register - no more defaultPayment sort of stuff - move pollAt, firstBlockData from loading to proxy - prune obsolete `rclient publish` --- index.js | 9 ++--- rclient/src/main.js | 96 ++++++++++++++------------------------------- src/loading.js | 85 +++++++++++++++++---------------------- src/proxy.js | 45 +++++++++++++++++++-- src/signing.js | 41 ++++++++++++++++++- test/testRNode.js | 21 ++++++---- test/testSigning.js | 30 +++++++++++++- 7 files changed, 191 insertions(+), 136 deletions(-) diff --git a/index.js b/index.js index fabcf0c..04e5fa5 100644 --- a/index.js +++ b/index.js @@ -22,11 +22,12 @@ import type { IRNode } from './src/rnodeAPI'; export type { IRNode }; */ -const { sendCall, makeProxy, callSource } = require('./src/proxy'); +const { sendCall, makeProxy, callSource, firstBlockData } = require('./src/proxy'); module.exports.sendCall = sendCall; module.exports.makeProxy = makeProxy; module.exports.callSource = callSource; +module.exports.firstBlockData = firstBlockData; const signing = require('./src/signing'); @@ -41,7 +42,7 @@ module.exports.keyPair = signing.keyPair; module.exports.verify = signing.verify; module.exports.b2h = signing.b2h; module.exports.h2b = signing.h2b; - +module.exports.SignDeployment = signing.SignDeployment; const hashing = require('./src/hashing.js'); @@ -55,7 +56,3 @@ module.exports.simplifiedBlake2b256Hash = hashing.simplifiedBlake2b256Hash; const { RevAddress } = require('./src/revAddress'); module.exports.RevAddress = RevAddress; - -const loading = require('./src/loading'); - -module.exports.firstBlockData = loading.firstBlockData; diff --git a/rclient/src/main.js b/rclient/src/main.js index ff5e54e..bf3a29c 100755 --- a/rclient/src/main.js +++ b/rclient/src/main.js @@ -10,8 +10,10 @@ const read = require('read'); const secp256k1 = require('secp256k1'); // ISSUE: push into rchain-api? const { docopt } = require('docopt'); const { - RNode, RHOCore, simplifiedKeccak256Hash, h2b, b2h, - keccak256Hash, keyPair, makeProxy, + RNode, RHOCore, + simplifiedKeccak256Hash, keccak256Hash, + h2b, b2h, keyPair, SignDeployment, + makeProxy, RevAddress, } = require('rchain-api'); const { loadRhoModules } = require('../../src/loading'); // ISSUE: path? @@ -33,7 +35,7 @@ Usage: rclient [options] transfer --from=LABEL --to=REVADDR AMOUNT rclient [options] sign LABEL [ --json ] DATAFILE rclient [options] deploy RHOLANG - rclient [options] register RHOMODULE... + rclient [options] register LABEL RHOMODULE... Options: keygen generate new secret key @@ -71,19 +73,6 @@ import type { SecretStorageV3, AES128CTR, SCrypt } from './secretStorage'; import type { ModuleInfo } from '../../src/loading'; // ISSUE: path? */ -const defaultDeployInfo = { - deployer: h2b('1111111111111111222222222222222233333333333333334444444444444444'), - from: '0x01', // TODO: cli arg - nonce: 1, - timestamp: -1, - // ISSUE: refine types so fields are optional in the right cases - term: 'syntax error', - sigAlgorithm: 'N/A', - sig: h2b(''), - phloLimit: 0, - phloPrice: 0, -}; - function ExitStatus(message) { this.message = message; @@ -122,16 +111,20 @@ async function main( const dur = argInt('--poll-interval'); const delay = i => mkPause(dur * i); - const priceInfo = () => ({ - ...defaultDeployInfo, - phloPrice: argInt('--phlo-price'), - phloLimit: argInt('--phlo-limit'), - }); + function payWith(key) { + return function payFor(d0) { + return SignDeployment.sign(key, { + ...d0, + phloPrice: argInt('--phlo-price'), + phloLimit: argInt('--phlo-limit'), + }); + }; + } async function ioTools() { const registry = FileStorage(argWr('--registry')); const toolsMod = await ensureLoaded('tools.rho', link('./tools.rho'), { registry }); - return { getpass, rnode, clock, delay, toolsMod, keyStore: argWr('--keystore') }; + return { getpass, rnode, clock, delay, toolsMod, registry, keyStore: argWr('--keystore') }; } if (cli.keygen) { @@ -146,29 +139,27 @@ async function main( await showPublic(cli.LABEL, { getpass, keyStore: argWr('--keystore') }); } else if (cli.genVault) { const io = await ioTools(); - await genVault(cli.LABEL, argInt('AMOUNT'), priceInfo(), io); + await genVault(cli.LABEL, argInt('AMOUNT'), payWith, io); } else if (cli.claim) { const io = await ioTools(); - await claimAccount(cli.LABEL, priceInfo(), io); + await claimAccount(cli.LABEL, payWith, io); } else if (cli.balance) { const io = await ioTools(); - await getBalance(cli.LABEL, priceInfo(), io); - } else if (cli.publish) { - const io = await ioTools(); - await publish(cli.LABEL, cli['--claimed'], priceInfo(), io); + await getBalance(cli.LABEL, payWith, io); } else if (cli.transfer) { const io = await ioTools(); - await transferPayment(argInt('AMOUNT'), cli['--from'], cli['--to'], priceInfo(), io); + await transferPayment(argInt('AMOUNT'), cli['--from'], cli['--to'], payWith, io); } else if (cli.sign) { const input = { data: argRd('DATAFILE'), json: cli['--json'] }; await signMessage(argWr('--keystore'), cli.LABEL, input, { getpass }); } else if (cli.deploy) { - await deploy(argRd('RHOLANG'), priceInfo(), where, { rnode, clock }) + await deploy(argRd('RHOLANG'), payWith, where, { rnode, clock }) .catch((err) => { console.error(err); throw err; }); } else if (cli.register) { + const registry = FileStorage(argWr('--registry')); await register( - cli.RHOMODULE.map(rd), priceInfo(), - { rnode, clock, delay, registry: FileStorage(argWr('--registry')) }, + cli.LABEL, cli.RHOMODULE.map(rd), payWith, + { getpass, rnode, clock, delay, registry, keyStore: argWr('--keystore') }, ); } } @@ -196,7 +187,10 @@ async function deploy(rholang, price, where, { rnode, clock }) { } -async function register(files, _price, { registry, rnode, clock, delay }) { +async function register( + label, files, payWith, + { registry, rnode, clock, delay, keyStore, getpass }, +) { // ISSUE: what to do when we restart the node? // how to check that we're talking to the same chain? async function check1(file) { @@ -215,9 +209,10 @@ async function register(files, _price, { registry, rnode, clock, delay }) { const toLoad = status.filter(({ mod }) => !mod); if (toLoad.length > 0) { console.log('loading:', toLoad.map(({ file }) => file.name())); - const { deployer } = defaultDeployInfo; + const privKey = await loadKey(keyStore, label, [], { getpass }); + const pmtKey = keyPair(privKey); const loaded = await ioOrExit( - loadRhoModules(toLoad.map(({ src }) => src), deployer, { rnode, clock, delay }), + loadRhoModules(toLoad.map(({ src }) => src), payWith(pmtKey), { rnode, clock, delay }), ); registry.set(collect(loaded.map((m, ix) => [toLoad[ix].srcHash, m]))); loaded.forEach((m, ix) => { @@ -433,37 +428,6 @@ async function getBalance(label, priceInfo, { keyStore, toolsMod, getpass, rnode console.log({ revAddr, balance, label }); } -async function publish(label, isClaimed, priceInfo, { keyStore, toolsMod, rnode, clock, getpass }) { - const privKey = await loadKey(keyStore, label, [], { getpass }); - const secPubKey = privateToPublic(privKey); // eth style secp256k1 - const ethAddr = `0x${b2h(pubToAddress(secPubKey))}`; - const edkey = keyPair(privKey); // ed25519 per nacl - - const nonce = clock().valueOf(); // ISSUE: cli arg? persist? - - const tools = makeProxy(toolsMod.URI, priceInfo, { rnode, clock }); - - let uri; - if (isClaimed) { - const toSign = await outcome(tools.prepareToPublish(b2h(secPubKey), nonce)); - const sig = edkey.signBytes(toSign); - - uri = await outcome(tools.publishClaimed(b2h(secPubKey), h2b(edkey.publicKey()), sig, nonce)); - } else { - const created = await outcome(tools.createWallet('secp256k1', b2h(secPubKey), nonce)); - if (!created.toSign) { throw new Error('expected toSign'); } - if (!created.uri) { throw new Error('expected uri'); } - const sig = edkey.signBytes(created.toSign); - // ISSUE: try WalletCheck access 1st to avoid clobbering. - // ISSUE: check target URI to avoid clobbering - uri = await outcome(tools.publishRegistered( - created.uri, h2b(edkey.publicKey()), sig, nonce, - )); - } - console.log({ uri: String(uri), ethAddr, label }); -} - - async function transferPayment( // ISSUE: paymentInfo confuses phloPrice and such with the REV we're sending here. amount, fromLabel, toAddr, paymentInfo, diff --git a/src/loading.js b/src/loading.js index 5a9ea37..9e6f761 100644 --- a/src/loading.js +++ b/src/loading.js @@ -5,20 +5,15 @@ const { URL } = require('url'); -const { Writer } = require('protobufjs'); -const { DataWithBlockInfo } = require('../protobuf/CasperMessage').coop.rchain.casper.protocol; - -const { b2h } = require('./signing'); -const RHOCore = require('./RHOCore'); -const { pollAt } = require('./proxy'); +const { h2b, keyPair, SignDeployment } = require('./signing'); +const { pollAt, firstBlockData } = require('./proxy'); const { link } = require('./assets'); const LOADER_TEMPLATE = link('./loader.rho'); -const defaultPayment = { from: '0x1', nonce: 0, phloPrice: 1, phloLimit: 100000 }; - /*:: +import type { DeployInfo } from '../protobuf/CasperMessage'; import type { IRNode } from '..'; interface LoadAccess { @@ -38,7 +33,7 @@ export type ModuleInfo = { exports.loadRhoModules = loadRhoModules; async function loadRhoModules( - sources /*: string[]*/, deployer /*: Uint8Array*/, + sources /*: string[]*/, payFor /*: DeployInfo => DeployInfo */, { rnode, clock, delay } /*: LoadAccess */, ) /*: Promise */ { let t1 = null; @@ -53,9 +48,10 @@ async function loadRhoModules( async function deploy1({ name, title, term }) { const timestamp = monotonicClock(); - const [chan] = await rnode.previewPrivateChannels({ user: deployer, timestamp }, 1); + const info = payFor({ term, timestamp }); + const [chan] = await rnode.previewPrivateChannels({ user: info.deployer, timestamp }, 1); console.log(`Deploying: ${title}\n`); - const deployResult = await rnode.doDeploy({ ...defaultPayment, deployer, term, timestamp }); + const deployResult = await rnode.doDeploy(info); console.log({ deployResult, name }); return { name, title, term, chan }; } @@ -67,6 +63,7 @@ async function loadRhoModules( console.log({ createdBlock, loading: deployed.map(({ name }) => name) }); async function register1({ name, title, term, chan }) /*: Promise */{ + console.log({ pollAt }); const found = await pollAt(chan, name, { rnode, delay }); const d = firstBlockData(found); if (!(d instanceof URL)) { throw new Error(`Expected URL; got: ${String(d)}`); } @@ -112,54 +109,42 @@ function moduleHeader(sourceCode) { } -/** - * Get printable form of unforgeable name, given id. - */ -exports.unforgeableWithId = unforgeableWithId; -function unforgeableWithId(id /*: Uint8Array */) { - const bytes = Writer.create().bytes(id).finish().slice(1); - return `Unforgeable(0x${b2h(bytes)})`; -} - -exports.prettyPrivate = prettyPrivate; -function prettyPrivate(par /*: IPar */) { - if (!(par.ids && par.ids.length && par.ids[0].id)) { throw new Error('expected GPrivate'); } - return unforgeableWithId(par.ids[0].id); -} - -exports.firstBlockData = firstBlockData; -function firstBlockData(blockResults /*: DataWithBlockInfo[] */) { - const _ = DataWithBlockInfo; // mark used - // console.log({ blockResults }); - if (!blockResults.length) { throw new Error('no blocks found'); } - return RHOCore.toJSData(firstBlockProcess(blockResults)); -} - - -// Get the first piece of data from listenForDataAtName -function firstBlockProcess(blockResults) { - // console.log('found:', JSON.stringify(blockResults, null, 2)); - const ea = [].concat(...blockResults.map(br => br.postBlockData)); - // console.log('ea: ', JSON.stringify(ea, null, 2)); - const good = ea.filter(it => it.exprs.length > 0 || it.bundles.length > 0 || it.ids.length > 0); - // console.log('good:'); - // console.log(JSON.stringify(good, null, 2)); - return good[0]; -} - - -function integrationTest(argv, { readFileSync }) { +async function integrationTest(argv, { readFileSync, clock, rnode, setTimeout }) { const sourceFileName = argv[2]; const src = readFileSync(sourceFileName, 'utf8'); const { name, title, term } = parseModule(src); console.log({ name, title }); console.log(term); + + const dur = 3 * 1000; + const delay = _i => new Promise((resolve) => { setTimeout(resolve, dur); }); + + const key = keyPair(h2b('11'.repeat(32))); + function payFor(d0 /*: DeployInfo*/) { + return SignDeployment.sign(key, { + ...d0, + phloPrice: 1, + phloLimit: 100000, + }); + } + + const sources = [src]; + return loadRhoModules(sources, payFor, { rnode, clock, delay }); } /*global module */ if (require.main === module) { - /* global process */ + /* global process, setTimeout */ /* eslint-disable global-require */ - integrationTest(process.argv, { readFileSync: require('fs').readFileSync }); + const grpc = require('grpc'); + const { RNode } = require('./rnodeAPI'); + const rnode = RNode(grpc, { host: 'localhost', port: 40401 }); + integrationTest(process.argv, { + readFileSync: require('fs').readFileSync, + clock: () => new Date(), + rnode, + setTimeout, + }) + .catch((oops) => { console.error(oops); }); } diff --git a/src/proxy.js b/src/proxy.js index 45f51fa..90c761d 100644 --- a/src/proxy.js +++ b/src/proxy.js @@ -1,9 +1,12 @@ /*global require, exports*/ // @flow +const { Writer } = require('protobufjs'); +const { DataWithBlockInfo } = require('../protobuf/CasperMessage').coop.rchain.casper.protocol; + +const { b2h } = require('./signing'); const { rhol, toJSData } = require('./RHOCore'); const { GPrivate } = require('../protobuf/RhoTypes.js'); -const { prettyPrivate } = require('./loading'); /*:: import type { IRNode, IDeployData } from './rnodeAPI'; @@ -124,9 +127,7 @@ async function sendCall( console.log({ deployResult }); const blockResults = await pollAt(returnChan, method || '?', { delay: opts.delay, rnode }); - const answerPar = blockResults[0].postBlockData[0]; - // console.log('answerPar', JSON.stringify(answerPar, null, 2)); - return toJSData(answerPar); + return firstBlockData(blockResults); } @@ -155,6 +156,42 @@ async function pollAt( } +/** + * Get printable form of unforgeable name, given id. + */ +exports.unforgeableWithId = unforgeableWithId; +function unforgeableWithId(id /*: Uint8Array */) { + const bytes = Writer.create().bytes(id).finish().slice(1); + return `Unforgeable(0x${b2h(bytes)})`; +} + +exports.prettyPrivate = prettyPrivate; +function prettyPrivate(par /*: IPar */) { + if (!(par.ids && par.ids.length && par.ids[0].id)) { throw new Error('expected GPrivate'); } + return unforgeableWithId(par.ids[0].id); +} + +exports.firstBlockData = firstBlockData; +function firstBlockData(blockResults /*: DataWithBlockInfo[] */) { + const _ = DataWithBlockInfo; // mark used + // console.log({ blockResults }); + if (!blockResults.length) { throw new Error('no blocks found'); } + return toJSData(firstBlockProcess(blockResults)); +} + + +// Get the first piece of data from listenForDataAtName +function firstBlockProcess(blockResults) { + // console.log('found:', JSON.stringify(blockResults, null, 2)); + const ea = [].concat(...blockResults.map(br => br.postBlockData)); + // console.log('ea: ', JSON.stringify(ea, null, 2)); + const good = ea.filter(it => it.exprs.length > 0 || it.bundles.length > 0 || it.ids.length > 0); + // console.log('good:'); + // console.log(JSON.stringify(good, null, 2)); + return good[0]; +} + + /** * Make a rholang term for looking up a target and calling a method. * diff --git a/src/signing.js b/src/signing.js index fab07f8..50e0080 100644 --- a/src/signing.js +++ b/src/signing.js @@ -12,6 +12,7 @@ export type Signature = Bytes; export type PrivateKey = Bytes; export type PublicKey = Bytes; +export type KeyPair = $Call; */ // ref https://nodejs.org/api/util.html#util_custom_inspection_functions_on_objects @@ -20,7 +21,10 @@ export type PublicKey = Bytes; const { sign } = require('tweetnacl'); // ocap discpline: "hiding" keyPair +const { DeployData } = require('../protobuf/CasperMessage').coop.rchain.casper.protocol; const { fromJSData, toByteArray } = require('./RHOCore'); +const { blake2b256Hash } = require('./hashing'); + /*:: import type { JsonExt } from './RHOCore'; */ @@ -104,11 +108,46 @@ function verify( message /*: Uint8Array*/, sig /*: Signature */, publicKey /*: PublicKey */, -) /*: Signature */ { +) /*: boolean */ { return sign.detached.verify(message, sig, publicKey); } +/** + * a port of casper/src/main/scala/coop/rchain/casper/SignDeployment.scala + * + * ISSUE: only ed25519 is supported. + */ +const SignDeployment = (() => { + const algName = 'ed25519'; + + const fill = deployData => (deployer, sig, sigAlgorithm) => ( + { ...deployData, deployer, sig, sigAlgorithm } + ); + + const clear = deployData => fill(deployData)(null, null, null); + + function signD(key /*: KeyPair */, deployData /*: DeployData*/)/*: DeployData*/ { + const toSign = DeployData.encode(clear(deployData)).finish(); + const hash = blake2b256Hash(toSign); + const signature = key.signBytes(hash); + + return fill(deployData)(h2b(key.publicKey()), signature, algName); + } + + function verifyD(deployData /*: DeployData*/)/*: boolean */ { + if (deployData.sigAlgorithm !== algName) { + throw new Error(`unsupported: ${deployData.sigAlgorithm}`); + } + const toVerify = DeployData.encode(clear(deployData)).finish(); + const hash = blake2b256Hash(toVerify); + return verify(hash, deployData.sig, deployData.deployer); + } + + return Object.freeze({ sign: signD, verify: verifyD }); +})(); +exports.SignDeployment = SignDeployment; + function integrationTest({ randomBytes }) { const seed = randomBytes(32); diff --git a/test/testRNode.js b/test/testRNode.js index c286f9f..d5775e8 100644 --- a/test/testRNode.js +++ b/test/testRNode.js @@ -2,7 +2,7 @@ const ttest = require('tape'); const api = require('../index'); -const { RNode, b2h, h2b } = api; +const { RNode, b2h, h2b, SignDeployment, keyPair } = api; const { sha256Hash, keccak256Hash, blake2b256Hash } = api; const { simplifiedSHA256Hash, simplifiedKeccak256Hash, simplifiedBlake2b256Hash } = api; @@ -38,6 +38,8 @@ function testRNode(suite2) { } +const defaultSec = h2b('b18e1d0045995ec3d010c387ccfeb984d783af8fbb0f40fa7db126d889f6dadd'); + function netTests({ grpc, clock, rng }) { const localNode = () => RNode(grpc, { host: 'localhost', port: 40401 }); @@ -69,7 +71,8 @@ function netTests({ grpc, clock, rng }) { const term = 'new test in { contract test(return) = { return!("test") } }'; const timestamp = clock().valueOf(); - localNode().doDeploy({ term, timestamp, ...payment() }, true).then((results) => { + const key = keyPair(defaultSec); + localNode().doDeploy(payFor({ term, timestamp }, key), true).then((results) => { test.equal(results.slice(0, 'Success'.length), 'Success'); test.end(); }); @@ -121,8 +124,9 @@ function runAndListen( term, returnChannel, timestamp, node, test = null, ) { + const key = keyPair(defaultSec); // console.log("run:", { term, returnChannel }); - return node.doDeploy({ term, timestamp, ...payment() }, true).then((results) => { + return node.doDeploy(payFor({ term, timestamp }, key), true).then((results) => { if (test) { test.equal(results.slice(0, 'Success'.length), 'Success'); } // Get the generated result from the channel @@ -137,13 +141,14 @@ function runAndListen( } -function payment(phloPrice = 1, phloLimit = 10000000) { - return { +function payFor(d0, key, phloPrice = 1, phloLimit = 10000000) { + const dout = SignDeployment.sign(key, { + ...d0, phloPrice, phloLimit, - from: '0x01', - nonce: 0, - }; + }); + // console.log({ valid: SignDeployment.verify(dout), sig: b2h(dout.sig) }); + return dout; } diff --git a/test/testSigning.js b/test/testSigning.js index dad3487..5eff23c 100644 --- a/test/testSigning.js +++ b/test/testSigning.js @@ -1,6 +1,7 @@ /*global require*/ const ttest = require('tape'); -const { keyPair, h2b, verify } = require('../index'); +const { DeployData } = require('../protobuf/CasperMessage').coop.rchain.casper.protocol; +const { keyPair, h2b, b2h, verify, SignDeployment } = require('..'); function testSigning() { const cases = { @@ -37,6 +38,33 @@ function testSigning() { test.end(); }; } + + ttest('sign deploy', (test) => { + const defaultSec = h2b('b18e1d0045995ec3d010c387ccfeb984d783af8fbb0f40fa7db126d889f6dadd'); + + const d0 /*: DeployData */ = { + term: 'new test in { contract test(return) = { return!("test") } }', + timestamp: 1554757703966, + phloPrice: 1, + phloLimit: 10000000, + }; + const toSign = DeployData.encode(d0).finish(); + test.equal( + b2h(toSign), + '123b6e6577207465737420696e207b20636f6e747261637420746573742872657475726e29203d207b2072657475726e212822746573742229207d207d189eb29ff69f2d38014080ade204', + ); + + const dout = SignDeployment.sign(keyPair(defaultSec), d0); + test.equal( + b2h(dout.sig), + 'b6e0c2077e3ae2794b7324b518b49a9aa597eb07207f84f6339db73aeb6852491b8a7e640fd17f88ee80b61e3d326ec87835feebbb7dacdeadf03f26deff350f', + ); + test.equal( + b2h(dout.deployer), + '77f48b59caeda77751ed138b0ec667ff50f8768c25d48309a8f386a2bad187fb', + ); + test.end(); + }); } testSigning(); From 2cd6fbcb98b642788a5f372d460af4834e447b8f Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Tue, 9 Apr 2019 22:03:03 -0500 Subject: [PATCH 04/36] API re-org in preparation for docs - b2h, h2b -> Hex.encode, Hex.decode - Hex -> HexStr - keyPair, verify -> Ed25519.keyPair, Ed25519.verify - firstBlockData -> Block.firstData - makeProxy -> RegistryProxy.makeProxy - blake2b256Hash -> Blake2b256.hash (likewise keccak, sha256) - simplifiedSHA256Hash -> RHOCore.wrapHash(SHA256.hash) --- index.js | 46 ++++++-------- rclient/src/main.js | 26 +++++--- rclient/src/rhoid.js | 8 +-- rclient/src/secretStorage.js | 6 +- rclient/src/sigTool.js | 8 ++- src/RHOCore.js | 53 +++++++++++++++- src/hashing.js | 97 ----------------------------- src/hex.js | 23 +++++++ src/loading.js | 10 +-- src/proxy.js | 45 +------------- src/revAddress.js | 8 +-- src/rnodeAPI.js | 60 ++++++++++++++++++ src/signing.js | 116 +++++++++++++++-------------------- test/RHOCore.test.js | 8 ++- test/proxy.test.js | 2 +- test/revAddressTest.js | 4 +- test/testRNode.js | 27 ++++---- test/testSigning.js | 13 ++-- 18 files changed, 271 insertions(+), 289 deletions(-) delete mode 100644 src/hashing.js create mode 100644 src/hex.js diff --git a/index.js b/index.js index 04e5fa5..480ea84 100644 --- a/index.js +++ b/index.js @@ -6,53 +6,45 @@ * [1]: https://github.com/rchain/mobile-process-calculi-for-blockchain/blob/master/enter-the-blockchain.rst */ -/* global require, exports, module */ +/* global require, exports */ // @flow const RHOCore = require('./src/RHOCore'); -module.exports.RHOCore = RHOCore; +exports.RHOCore = RHOCore; -const { RNode } = require('./src/rnodeAPI'); +const { RNode, SignDeployment, Block } = require('./src/rnodeAPI'); -module.exports.RNode = RNode; /*:: import type { IRNode } from './src/rnodeAPI'; export type { IRNode }; */ +exports.RNode = RNode; +exports.SignDeployment = SignDeployment; +exports.Block = Block; -const { sendCall, makeProxy, callSource, firstBlockData } = require('./src/proxy'); - -module.exports.sendCall = sendCall; -module.exports.makeProxy = makeProxy; -module.exports.callSource = callSource; -module.exports.firstBlockData = firstBlockData; - -const signing = require('./src/signing'); +exports.RegistryProxy = require('./src/proxy'); /*:: -export type Hex = Hex; -export type Bytes = Bytes; export type Signature = Signature; export type PrivateKey = PrivateKey; export type PublicKey = PublicKey; */ -module.exports.keyPair = signing.keyPair; -module.exports.verify = signing.verify; -module.exports.b2h = signing.b2h; -module.exports.h2b = signing.h2b; -module.exports.SignDeployment = signing.SignDeployment; +const { Ed25519, Blake2b256, SHA256, Keccak256 } = require('./src/signing'); + +exports.Ed25519 = Ed25519; +exports.Blake2b256 = Blake2b256; +exports.SHA256 = SHA256; +exports.Keccak256 = Keccak256; -const hashing = require('./src/hashing.js'); +/*:: +export type HexStr = HexStr; +export type Bytes = Bytes; +*/ -module.exports.sha256Hash = hashing.sha256Hash; -module.exports.keccak256Hash = hashing.keccak256Hash; -module.exports.blake2b256Hash = hashing.blake2b256Hash; -module.exports.simplifiedSHA256Hash = hashing.simplifiedSHA256Hash; -module.exports.simplifiedKeccak256Hash = hashing.simplifiedKeccak256Hash; -module.exports.simplifiedBlake2b256Hash = hashing.simplifiedBlake2b256Hash; +exports.Hex = require('./src/hex'); const { RevAddress } = require('./src/revAddress'); -module.exports.RevAddress = RevAddress; +exports.RevAddress = RevAddress; diff --git a/rclient/src/main.js b/rclient/src/main.js index bf3a29c..9c951cc 100755 --- a/rclient/src/main.js +++ b/rclient/src/main.js @@ -11,9 +11,9 @@ const secp256k1 = require('secp256k1'); // ISSUE: push into rchain-api? const { docopt } = require('docopt'); const { RNode, RHOCore, - simplifiedKeccak256Hash, keccak256Hash, - h2b, b2h, keyPair, SignDeployment, - makeProxy, + Keccak256, + Hex, Ed25519, SignDeployment, + RegistryProxy, RevAddress, } = require('rchain-api'); const { loadRhoModules } = require('../../src/loading'); // ISSUE: path? @@ -23,6 +23,10 @@ const { asPromise } = require('./asPromise'); const secretStorage = require('./secretStorage'); const { link } = require('./assets'); +const { makeProxy } = RegistryProxy; +const h2b = Hex.decode; +const b2h = Hex.encode; + const usage = ` Usage: rclient [options] keygen LABEL @@ -72,6 +76,8 @@ Options: import type { SecretStorageV3, AES128CTR, SCrypt } from './secretStorage'; import type { ModuleInfo } from '../../src/loading'; // ISSUE: path? + +import type { HexStr, PublicKey } from 'rchain-api'; */ function ExitStatus(message) { @@ -196,7 +202,7 @@ async function register( async function check1(file) { const src = await ioOrExit(file.readText()); - const srcHash = simplifiedKeccak256Hash(src); + const srcHash = RHOCore.wrapHash(Keccak256.hash)(src); const mods = await ioOrExit(registry.get(srcHash)); return { file, src, srcHash, mod: mods[srcHash] }; } @@ -210,7 +216,7 @@ async function register( if (toLoad.length > 0) { console.log('loading:', toLoad.map(({ file }) => file.name())); const privKey = await loadKey(keyStore, label, [], { getpass }); - const pmtKey = keyPair(privKey); + const pmtKey = Ed25519.keyPair(privKey); const loaded = await ioOrExit( loadRhoModules(toLoad.map(({ src }) => src), payWith(pmtKey), { rnode, clock, delay }), ); @@ -256,7 +262,7 @@ async function keygen(keyStore, label, { getpass, randomBytes, uuidv4 }) { uuidv4, ); await store.set({ [label]: item }); - const publicKey = keyPair(privKey).publicKey(); + const publicKey /*: HexStr */= Ed25519.keyPair(privKey).publicKey(); const revAddr = RevAddress.fromPublicKey(h2b(publicKey)).toString(); console.log({ label, revAddr, publicKey, keyStore: keyStore.readOnly().name(), status: 'saved' }); } @@ -359,14 +365,14 @@ function privateToPublic(privKey) { function pubToAddress(pubKey) { assert.equal(pubKey.length, 64); - return keccak256Hash(pubKey).slice(-20); + return Keccak256.hash(pubKey).slice(-20); } async function loadRevAddr(label, notice, { keyStore, getpass }) { try { const privKey = await loadKey(keyStore, label, notice, { getpass }); - const edKey = keyPair(privKey); // ed25519 + const edKey = Ed25519.keyPair(privKey); const revAddr = RevAddress.fromPublicKey(h2b(edKey.publicKey())).toString(); return { label, revAddr, publicKey: edKey.publicKey() }; } catch (err) { @@ -388,7 +394,7 @@ async function genVault( console.log({ revAddr, label, amount, result }); } -const rhoKeccakHash = data => keccak256Hash(RHOCore.toByteArray(RHOCore.fromJSData(data))); +const rhoKeccakHash = data => Keccak256.hash(RHOCore.toByteArray(RHOCore.fromJSData(data))); const sigDERHex = sigObj => b2h(secp256k1.signatureExport(sigObj.signature)); async function claimAccount(label, priceInfo, { keyStore, toolsMod, getpass, rnode, clock }) { @@ -466,7 +472,7 @@ async function outcome/*::*/(x /*:Promise*/) /*: Promise*/ { } async function ensureLoaded(name, src, { registry }) /*: ModuleInfo */ { - const srcHash = simplifiedKeccak256Hash(src); + const srcHash = RHOCore.wrapHash(Keccak256.hash)(src); const mods = await registry.get(srcHash); const mod = mods[srcHash]; if (!mod) { throw new ExitStatus(`rholang module not loaded: ${name}`); } diff --git a/rclient/src/rhoid.js b/rclient/src/rhoid.js index e6e2565..dc18169 100644 --- a/rclient/src/rhoid.js +++ b/rclient/src/rhoid.js @@ -8,7 +8,7 @@ https://github.com/rchain/rchain/blob/27f76eb02ab2d83bf2bc9cd766157c4723db0854/r // @flow /* global require, exports, module, Buffer */ -const { blake2b256Hash, b2h } = require('rchain-api'); +const { Blake2b256, Hex } = require('rchain-api'); const base32 = require('base32-encoding'); // human-oriented base-32 encoding by Zooko 2002 - 2009 @@ -21,10 +21,10 @@ const testCase = { function test(item) { const uri = pkURI(item.pk); - const hash = blake2b256Hash(item.pk); + const hash = Blake2b256.hash(item.pk); console.log({ pk: item.pk.toString('hex'), - hash: b2h(hash), + hash: Hex.encode(hash), uri, ok: uri === item.uri, }); @@ -39,7 +39,7 @@ function test(item) { */ exports.pkURI = pkURI; function pkURI(pk /*: Buffer*/) { - const hash = blake2b256Hash(pk); + const hash = Blake2b256.hash(pk); return buildURI(Buffer.from(hash)); } diff --git a/rclient/src/secretStorage.js b/rclient/src/secretStorage.js index c88b1e0..95d888a 100644 --- a/rclient/src/secretStorage.js +++ b/rclient/src/secretStorage.js @@ -9,7 +9,7 @@ const scrypt = require('scrypt.js'); // ISSUE: just use crypto.script? const crypto = require('crypto'); const assert = require('assert'); -const { keccak256Hash } = require('rchain-api'); +const { Keccak256 } = require('rchain-api'); /*:: @@ -88,7 +88,7 @@ function decrypt( toBuf(item.crypto.ciphertext), ]); // console.log('MAC Body', MACBody.toString('hex')); - const MAC = Buffer.from(keccak256Hash(MACBody)); + const MAC = Buffer.from(Keccak256.hash(MACBody)); // console.log('MAC', MAC.toString('hex')); const diff = MAC.compare(toBuf(item.crypto.mac)); // console.log('MAC diff?', diff); @@ -142,7 +142,7 @@ function encrypt( ciphertext, ]); // console.log('MAC Body', MACBody.toString('hex')); - const mac = Buffer.from(keccak256Hash(MACBody)).toString('hex'); + const mac = Buffer.from(Keccak256.hash(MACBody)).toString('hex'); // console.log('MAC', MAC.toString('hex')); const item = { diff --git a/rclient/src/sigTool.js b/rclient/src/sigTool.js index 1792e10..6565291 100644 --- a/rclient/src/sigTool.js +++ b/rclient/src/sigTool.js @@ -6,15 +6,17 @@ ISSUE: pretty much subsumed by secretStorage. prune nacl dependency too. */ /* global exports, require */ -const { b2h, h2b } = require('rchain-api'); +const { Hex } = require('rchain-api'); const def = Object.freeze; +const b2h = Hex.encode; +const h2b = Hex.decode; /*:: import nacl from 'tweetnacl'; import type { StorageArea } from './pathlib'; -import type { Hex, PublicKey } from 'rchain-api'; +import type { HexStr, PublicKey } from 'rchain-api'; // SigningKey is the format we use to save the key pair // with the secret key encrypted. @@ -25,7 +27,7 @@ export type SigningKey = { nonce: string, cipherText: string, }, - pubKey: Hex + pubKey: HexStr } export interface SigTool { diff --git a/src/RHOCore.js b/src/RHOCore.js index 8db0538..97ea817 100644 --- a/src/RHOCore.js +++ b/src/RHOCore.js @@ -3,11 +3,15 @@ const { URL } = require('url'); +const { Writer } = require('protobufjs'); // ISSUE: generated code isn't annotated. $FlowFixMe const { Par, GPrivate } = require('../protobuf/RhoTypes'); -// copied from signing.js to avoid circular imports -const b2h = bytes => Buffer.from(bytes).toString('hex'); +const hex = require('./hex'); + +/*:: +import type { HexStr, Bytes } from './hex'; +*/ exports.fromJSData = fromJSData; /** @@ -89,6 +93,34 @@ function toByteArray(termObj /*: IPar */) /*: Uint8Array */ { } +/** + * @memberof RHOCore + */ +exports.dataToBytes = dataToBytes; +function dataToBytes(data /*: JsonExt*/) /*: Uint8Array */ { + return toByteArray(fromJSData(data)); +} + + +/** + * @@@@Compute a Blake2b-256 hash for some Rholang-compatible data, then return the + * string representing a HEX-encoded hash + * + * @param jsData: JS Data compatible with Rholang, used to compute the hash + * @return HEX-formatted string representing the computed hash + * @throws Error if the js_data contains a non-Rholang data structure + * + * @memberof RHOCore + */ +exports.wrapHash = wrapHash; +function wrapHash( + hashFn /*: Uint8Array => Uint8Array */, +) /*: JsonExt => HexStr */ { + return function hashData(data /*: JsonExt*/) { + return hex.encode(hashFn(toByteArray(fromJSData(data)))); + }; +} + /*:: // "we can detail a direct representation of JSON into a @@ -232,7 +264,7 @@ function toRholang(par /*: IPar */) /*: string */ { return src(ex.g_string); } if (typeof ex.g_byte_array !== 'undefined' && ex.g_byte_array !== null) { - return `"${b2h(ex.g_byte_array)}".hexToBytes()`; + return `"${hex.encode(ex.g_byte_array)}".hexToBytes()`; } if (typeof ex.g_uri !== 'undefined' && ex.g_uri !== null) { const uri = ex.g_uri; @@ -267,6 +299,21 @@ function toRholang(par /*: IPar */) /*: string */ { } +/** + * Get printable form of unforgeable name, given id. + */ +exports.unforgeableWithId = unforgeableWithId; +function unforgeableWithId(id /*: Uint8Array */) { + const bytes = Writer.create().bytes(id).finish().slice(1); + return `Unforgeable(0x${hex.encode(bytes)})`; +} + +exports.prettyPrivate = prettyPrivate; +function prettyPrivate(par /*: IPar */) { + if (!(par.ids && par.ids.length && par.ids[0].id)) { throw new Error('expected GPrivate'); } + return unforgeableWithId(par.ids[0].id); +} + exports.rhol = rhol; /** * Template tag for RHOCore interpolation diff --git a/src/hashing.js b/src/hashing.js deleted file mode 100644 index 1f8ab09..0000000 --- a/src/hashing.js +++ /dev/null @@ -1,97 +0,0 @@ -/* global require, exports, Buffer */ -// @flow - -const blake2 = require('blake2'); -const crypto = require('crypto'); -const { keccak256 } = require('js-sha3'); -const RHOCore = require('./RHOCore'); -/*:: -import type { JsonExt } from './RHOCore'; -*/ - -exports.sha256Hash = sha256Hash; -/** - * Compute a SHA256 hash over some data, the way that it will be computed in Rholang - * - * @param serializedData: Uint8Array of serialized Rholang data, used to compute the hash - * @return Uint8Array of bytes representing the computed hash - */ -function sha256Hash(serializedData /*: Uint8Array*/) /*: Uint8Array*/ { - const sha256 = crypto.createHash('sha256'); - sha256.update(Buffer.from(serializedData)); - return Uint8Array.from(sha256.digest()); -} - -exports.keccak256Hash = keccak256Hash; -/** - * Compute a Keccak-256 hash over some data, the way that it will be computed in Rholang - * - * @param serializedData: Uint8Array of serialized Rholang data, used to compute the hash - * @return Uint8Array of bytes representing the computed hash - */ -function keccak256Hash(serializedData /*: Uint8Array*/) /*: Uint8Array*/ { - return new Uint8Array(keccak256.arrayBuffer(serializedData)); -} - - -exports.blake2b256Hash = blake2b256Hash; -/** - * Compute a Blake2b-256 hash over some data, the way that it will be computed in Rholang - * - * @param serializedData: Uint8Array of serialized Rholang data, used to compute the hash - * @return Uint8Array of bytes representing the computed hash - */ -function blake2b256Hash(serializedData /*: Uint8Array*/) /*: Uint8Array*/ { - const blake2b256 = blake2.createHash('blake2b', { digestLength: 32 }); - blake2b256.update(serializedData); - return Uint8Array.from(blake2b256.digest()); -} - - -exports.simplifiedSHA256Hash = simplifiedSHA256Hash; -/** - * Compute a SHA256 hash for some Rholang-compatible data, then return the - * string representing a HEX-encoded hash - * - * @param jsData: JS Data compatible with Rholang, used to compute the hash - * @return HEX-formatted string representing the computed hash - * @throws Error if the js_data contains a non-Rholang data structure - */ -function simplifiedSHA256Hash(jsData /*: JsonExt*/) /*: string */ { - const sha256 = crypto.createHash('sha256'); - const serializedData = RHOCore.toByteArray(RHOCore.fromJSData(jsData)); - sha256.update(Buffer.from(serializedData)); - return sha256.digest('hex'); -} - - -exports.simplifiedKeccak256Hash = simplifiedKeccak256Hash; -/** - * Compute a Keccak-256 hash for some Rholang-compatible data, then return the - * string representing a HEX-encoded hash - * - * @param jsData: JS Data compatible with Rholang, used to compute the hash - * @return HEX-formatted string representing the computed hash - * @throws Error if the js_data contains a non-Rholang data structure - */ -function simplifiedKeccak256Hash(jsData /*: JsonExt*/) /*: string */ { - const serializedData = RHOCore.toByteArray(RHOCore.fromJSData(jsData)); - return keccak256(serializedData); -} - - -exports.simplifiedBlake2b256Hash = simplifiedBlake2b256Hash; -/** - * Compute a Blake2b-256 hash for some Rholang-compatible data, then return the - * string representing a HEX-encoded hash - * - * @param jsData: JS Data compatible with Rholang, used to compute the hash - * @return HEX-formatted string representing the computed hash - * @throws Error if the js_data contains a non-Rholang data structure - */ -function simplifiedBlake2b256Hash(jsData /*: JsonExt*/) /*: string */ { - const blake2b256 = blake2.createHash('blake2b', { digestLength: 32 }); - const serializedData = RHOCore.toByteArray(RHOCore.fromJSData(jsData)); - blake2b256.update(serializedData); - return blake2b256.digest('hex'); -} diff --git a/src/hex.js b/src/hex.js new file mode 100644 index 0000000..ea843c2 --- /dev/null +++ b/src/hex.js @@ -0,0 +1,23 @@ +/* global exports, Buffer */ +// @flow + +/*:: +// ISSUE: opaque types? +export type HexStr = string; +export type Bytes = Uint8Array | Buffer; +*/ + +exports.encode = encode; +function encode/*:: */(bytes /*: T */) /*: string*/ { + return Buffer.from(bytes).toString('hex'); +} + +exports.fromBytes = fromBytes; +function fromBytes/*:: */(bytes /*: T */) /*: HexStr*/ { + return Buffer.from(bytes).toString('hex'); +} + +exports.decode = decode; +function decode/*:: */(hex /*: HexStr*/) /*: Bytes*/ { + return Buffer.from(hex, 'hex'); +} diff --git a/src/loading.js b/src/loading.js index 9e6f761..5cb7b86 100644 --- a/src/loading.js +++ b/src/loading.js @@ -5,8 +5,10 @@ const { URL } = require('url'); -const { h2b, keyPair, SignDeployment } = require('./signing'); -const { pollAt, firstBlockData } = require('./proxy'); +const Hex = require('./hex'); +const { Ed25519 } = require('./signing'); +const { pollAt } = require('./proxy'); +const { Block, SignDeployment } = require('./rnodeAPI'); const { link } = require('./assets'); @@ -65,7 +67,7 @@ async function loadRhoModules( async function register1({ name, title, term, chan }) /*: Promise */{ console.log({ pollAt }); const found = await pollAt(chan, name, { rnode, delay }); - const d = firstBlockData(found); + const d = Block.firstData(found); if (!(d instanceof URL)) { throw new Error(`Expected URL; got: ${String(d)}`); } const URI = d; console.log(`${name} registered at: ${String(URI)}`); @@ -119,7 +121,7 @@ async function integrationTest(argv, { readFileSync, clock, rnode, setTimeout }) const dur = 3 * 1000; const delay = _i => new Promise((resolve) => { setTimeout(resolve, dur); }); - const key = keyPair(h2b('11'.repeat(32))); + const key = Ed25519.keyPair(Hex.decode('11'.repeat(32))); function payFor(d0 /*: DeployInfo*/) { return SignDeployment.sign(key, { ...d0, diff --git a/src/proxy.js b/src/proxy.js index 90c761d..cb338e1 100644 --- a/src/proxy.js +++ b/src/proxy.js @@ -1,12 +1,9 @@ /*global require, exports*/ // @flow -const { Writer } = require('protobufjs'); -const { DataWithBlockInfo } = require('../protobuf/CasperMessage').coop.rchain.casper.protocol; - -const { b2h } = require('./signing'); -const { rhol, toJSData } = require('./RHOCore'); const { GPrivate } = require('../protobuf/RhoTypes.js'); +const { rhol, prettyPrivate } = require('./RHOCore'); +const { Block } = require('./rnodeAPI'); /*:: import type { IRNode, IDeployData } from './rnodeAPI'; @@ -127,7 +124,7 @@ async function sendCall( console.log({ deployResult }); const blockResults = await pollAt(returnChan, method || '?', { delay: opts.delay, rnode }); - return firstBlockData(blockResults); + return Block.firstData(blockResults); } @@ -156,42 +153,6 @@ async function pollAt( } -/** - * Get printable form of unforgeable name, given id. - */ -exports.unforgeableWithId = unforgeableWithId; -function unforgeableWithId(id /*: Uint8Array */) { - const bytes = Writer.create().bytes(id).finish().slice(1); - return `Unforgeable(0x${b2h(bytes)})`; -} - -exports.prettyPrivate = prettyPrivate; -function prettyPrivate(par /*: IPar */) { - if (!(par.ids && par.ids.length && par.ids[0].id)) { throw new Error('expected GPrivate'); } - return unforgeableWithId(par.ids[0].id); -} - -exports.firstBlockData = firstBlockData; -function firstBlockData(blockResults /*: DataWithBlockInfo[] */) { - const _ = DataWithBlockInfo; // mark used - // console.log({ blockResults }); - if (!blockResults.length) { throw new Error('no blocks found'); } - return toJSData(firstBlockProcess(blockResults)); -} - - -// Get the first piece of data from listenForDataAtName -function firstBlockProcess(blockResults) { - // console.log('found:', JSON.stringify(blockResults, null, 2)); - const ea = [].concat(...blockResults.map(br => br.postBlockData)); - // console.log('ea: ', JSON.stringify(ea, null, 2)); - const good = ea.filter(it => it.exprs.length > 0 || it.bundles.length > 0 || it.ids.length > 0); - // console.log('good:'); - // console.log(JSON.stringify(good, null, 2)); - return good[0]; -} - - /** * Make a rholang term for looking up a target and calling a method. * diff --git a/src/revAddress.js b/src/revAddress.js index 00dab23..8bfccc2 100644 --- a/src/revAddress.js +++ b/src/revAddress.js @@ -1,8 +1,8 @@ /* global require, exports, Buffer */ const base58 = require('bs58'); -const { blake2b256Hash } = require('./hashing'); -const { h2b } = require('./signing'); +const { Blake2b256 } = require('./signing'); +const h2b = require('./hex').decode; const checksumLength = 4; const keyLength = 32; @@ -50,7 +50,7 @@ exports.RevAddress = RevAddress; exports.fromPublicKey = fromPublicKey; function fromPublicKey(pk /*: PublicKey */) /*: RevAddr */ { if (keyLength !== pk.length) { throw new Error(`bad public key length: ${pk.length}`); } - const keyHash = blake2b256Hash(pk); + const keyHash = Blake2b256.hash(pk); const payload = concat(prefix, keyHash); const checksum = computeChecksum(payload); const s = base58.encode(Buffer.from(concat(payload, checksum))); @@ -66,7 +66,7 @@ function fromPublicKey(pk /*: PublicKey */) /*: RevAddr */ { } function computeChecksum(toCheck /*: Bytes */) /*: Bytes*/ { - return blake2b256Hash(toCheck).slice(0, checksumLength); + return Blake2b256.hash(toCheck).slice(0, checksumLength); } function concat(a, b) { diff --git a/src/rnodeAPI.js b/src/rnodeAPI.js index 8a22865..8d86739 100644 --- a/src/rnodeAPI.js +++ b/src/rnodeAPI.js @@ -17,12 +17,15 @@ const { BlockQueryResponse, BlockInfoWithoutTuplespace, DataWithBlockInfo, + DeployData, DeployServiceResponse, ListeningNameContinuationResponse, ListeningNameDataResponse, PrivateNamePreviewResponse, } = require('../protobuf/CasperMessage').coop.rchain.casper.protocol; const RHOCore = require('./RHOCore'); +const Hex = require('./hex'); +const { Blake2b256, Ed25519 } = require('./signing'); const def = obj => Object.freeze(obj); // cf. ocap design note @@ -38,6 +41,7 @@ const packageDefinition = protoLoader.loadSync( /*:: import grpcT from 'grpc'; import type { JsonExt } from './RHOCore'; +import type { KeyPair } from './signing'; type JSData = JsonExt; */ @@ -351,6 +355,62 @@ function getIdFromUnforgeableName(par /*: IPar */) /*: string */ { } +function firstBlockData(blockResults /*: DataWithBlockInfo[] */) { + const _ = DataWithBlockInfo; // mark used + // console.log({ blockResults }); + if (!blockResults.length) { throw new Error('no blocks found'); } + return RHOCore.toJSData(firstBlockProcess(blockResults)); +} +exports.Block = Object.freeze({ firstData: firstBlockData }); + + +// Get the first piece of data from listenForDataAtName +function firstBlockProcess(blockResults) { + // console.log('found:', JSON.stringify(blockResults, null, 2)); + const ea = [].concat(...blockResults.map(br => br.postBlockData)); + // console.log('ea: ', JSON.stringify(ea, null, 2)); + const good = ea.filter(it => it.exprs.length > 0 || it.bundles.length > 0 || it.ids.length > 0); + // console.log('good:'); + // console.log(JSON.stringify(good, null, 2)); + return good[0]; +} + + +/** + * a port of casper/src/main/scala/coop/rchain/casper/SignDeployment.scala + * + * ISSUE: only ed25519 is supported. + */ +const SignDeployment = (() => { + const algName = 'ed25519'; + + const fill = deployData => (deployer, sig, sigAlgorithm) => ( + { ...deployData, deployer, sig, sigAlgorithm } + ); + + const clear = deployData => fill(deployData)(null, null, null); + + function signD(key /*: KeyPair */, deployData /*: DeployData*/)/*: DeployData*/ { + const toSign = DeployData.encode(clear(deployData)).finish(); + const hash = Blake2b256.hash(toSign); + const signature = key.signBytes(hash); + + return fill(deployData)(Hex.decode(key.publicKey()), signature, algName); + } + + function verifyD(deployData /*: DeployData*/)/*: boolean */ { + if (deployData.sigAlgorithm !== algName) { + throw new Error(`unsupported: ${deployData.sigAlgorithm}`); + } + const toVerify = DeployData.encode(clear(deployData)).finish(); + const hash = Blake2b256.hash(toVerify); + return Ed25519.verify(hash, deployData.sig, deployData.deployer); + } + + return Object.freeze({ sign: signD, verify: verifyD }); +})(); +exports.SignDeployment = SignDeployment; + /* * Adapt callback-style API using Promises. * diff --git a/src/signing.js b/src/signing.js index 50e0080..d21a39f 100644 --- a/src/signing.js +++ b/src/signing.js @@ -5,9 +5,9 @@ /*:: +import type { HexStr, Bytes } from './hex'; + // ISSUE: opaque types? -export type Hex = string; -export type Bytes = Uint8Array | Buffer; export type Signature = Bytes; export type PrivateKey = Bytes; export type PublicKey = Bytes; @@ -19,40 +19,25 @@ export type KeyPair = $Call; // ack: https://stackoverflow.com/a/46870568 // const inspect = require('util').inspect; -const { sign } = require('tweetnacl'); // ocap discpline: "hiding" keyPair - -const { DeployData } = require('../protobuf/CasperMessage').coop.rchain.casper.protocol; -const { fromJSData, toByteArray } = require('./RHOCore'); -const { blake2b256Hash } = require('./hashing'); - -/*:: -import type { JsonExt } from './RHOCore'; -*/ +const crypto = require('crypto'); -function b2h/*:: */(bytes /*: T */) /*: string*/ { - return Buffer.from(bytes).toString('hex'); -} -function b2hx/*:: */(bytes /*: T */) /*: Hex*/ { - return Buffer.from(bytes).toString('hex'); -} -function h2b/*:: */(hex /*: Hex*/) /*: Bytes*/ { - return Buffer.from(hex, 'hex'); -} +const { sign } = require('tweetnacl'); // ocap discpline: "hiding" keyPair +const blake2 = require('blake2'); +const { keccak256 } = require('js-sha3'); -const t2b = text => Buffer.from(text); +const b2hx = require('./hex').fromBytes; const def = obj => Object.freeze(obj); // cf. ocap design note -exports.b2h = b2h; -exports.h2b = h2b; - -exports.keyPair = keyPair; /** * Build key pair from seed. + * * @param seed 32 bytes, as from crypto.randombytes(32) + * @memberof Ed25519 */ function keyPair(seed /*: PrivateKey */) { const key = sign.keyPair.fromSeed(seed); + const t2b = text => Buffer.from(text); // TODO const toString = () => ``; /** @@ -68,7 +53,7 @@ function keyPair(seed /*: PrivateKey */) { /** * @memberof keyPair */ - signBytesHex(bytes /*: Uint8Array*/) /*: Hex */ { return b2hx(signBytes(bytes)); }, + signBytesHex(bs /*: Uint8Array*/) /*: HexStr */ { return b2hx(signBytes(bs)); }, /** * @memberof keyPair */ @@ -76,33 +61,22 @@ function keyPair(seed /*: PrivateKey */) { /** * @memberof keyPair */ - signTextHex(text /*: string*/) /*: Hex */ { return b2hx(signBytes(t2b(text))); }, + signTextHex(text /*: string*/) /*: HexStr */ { return b2hx(signBytes(t2b(text))); }, /** * @memberof keyPair */ - publicKey() /*: Hex */ { return b2hx(key.publicKey); }, + publicKey() /*: HexStr */ { return b2hx(key.publicKey); }, - /** - * @memberof keyPair - */ - signData(data /*: JsonExt*/) /*: Signature */ { - return signBytes(toByteArray(fromJSData(data))); - }, - /** - * @memberof keyPair - */ - signDataHex(data /*: JsonExt*/) /*: Hex */ { - return b2hx(signBytes(toByteArray(fromJSData(data)))); - }, // TODO label: () => state.label, // TODO [inspect.custom]: toString }); } -exports.verify = verify; /** * Verify ed25519 signature + * + * @memberof Ed25519 */ function verify( message /*: Uint8Array*/, @@ -112,41 +86,47 @@ function verify( return sign.detached.verify(message, sig, publicKey); } +exports.Ed25519 = Object.freeze({ keyPair, verify }); +exports.SHA256 = Object.freeze({ hash: sha256Hash }); /** - * a port of casper/src/main/scala/coop/rchain/casper/SignDeployment.scala + * Compute a SHA256 hash over some data, the way that it will be computed in Rholang * - * ISSUE: only ed25519 is supported. + * @param serializedData: Uint8Array of serialized Rholang data, used to compute the hash + * @return Uint8Array of bytes representing the computed hash + * @memberof SHA256 */ -const SignDeployment = (() => { - const algName = 'ed25519'; - - const fill = deployData => (deployer, sig, sigAlgorithm) => ( - { ...deployData, deployer, sig, sigAlgorithm } - ); - - const clear = deployData => fill(deployData)(null, null, null); +function sha256Hash(serializedData /*: Uint8Array*/) /*: Uint8Array*/ { + const sha256 = crypto.createHash('sha256'); + sha256.update(Buffer.from(serializedData)); + return Uint8Array.from(sha256.digest()); +} - function signD(key /*: KeyPair */, deployData /*: DeployData*/)/*: DeployData*/ { - const toSign = DeployData.encode(clear(deployData)).finish(); - const hash = blake2b256Hash(toSign); - const signature = key.signBytes(hash); +/** + * Compute a Keccak-256 hash over some data, the way that it will be computed in Rholang + * + * @param serializedData: Uint8Array of serialized Rholang data, used to compute the hash + * @return Uint8Array of bytes representing the computed hash + */ +function keccak256Hash(serializedData /*: Uint8Array*/) /*: Uint8Array*/ { + return new Uint8Array(keccak256.arrayBuffer(serializedData)); +} +exports.Keccak256 = { hash: keccak256Hash }; - return fill(deployData)(h2b(key.publicKey()), signature, algName); - } - function verifyD(deployData /*: DeployData*/)/*: boolean */ { - if (deployData.sigAlgorithm !== algName) { - throw new Error(`unsupported: ${deployData.sigAlgorithm}`); - } - const toVerify = DeployData.encode(clear(deployData)).finish(); - const hash = blake2b256Hash(toVerify); - return verify(hash, deployData.sig, deployData.deployer); - } +exports.Blake2b256 = Object.freeze({ hash: blake2b256Hash }); +/** + * Compute a Blake2b-256 hash over some data, the way that it will be computed in Rholang + * + * @param serializedData: Uint8Array of serialized Rholang data, used to compute the hash + * @return Uint8Array of bytes representing the computed hash + */ +function blake2b256Hash(serializedData /*: Uint8Array*/) /*: Uint8Array*/ { + const blake2b256 = blake2.createHash('blake2b', { digestLength: 32 }); + blake2b256.update(serializedData); + return Uint8Array.from(blake2b256.digest()); +} - return Object.freeze({ sign: signD, verify: verifyD }); -})(); -exports.SignDeployment = SignDeployment; function integrationTest({ randomBytes }) { const seed = randomBytes(32); diff --git a/test/RHOCore.test.js b/test/RHOCore.test.js index 6a7b7e6..6537e07 100644 --- a/test/RHOCore.test.js +++ b/test/RHOCore.test.js @@ -4,7 +4,7 @@ const { URL } = require('url'); const ttest = require('tape'); -const { RHOCore, h2b, keyPair } = require('../index'); +const { RHOCore, Hex, Ed25519 } = require('..'); const { Par, GPrivate } = require('../protobuf/RhoTypes'); const testData = require('./RHOCoreSuite.json'); @@ -13,6 +13,8 @@ const testData = require('./RHOCoreSuite.json'); const likeLoad = { keepCase: true, longs: String, enums: String, defaults: true, oneofs: true }; function testRHOCore() { + const h2b = Hex.decode; + function rtest(item) { return (test) => { test.deepEqual(RHOCore.fromJSData(item.data), item.rho); @@ -92,11 +94,11 @@ function testRHOCore() { }, 'BasicWallet transfer signature': (test) => { const destid = h2b('476ec6197e7106e0f0c64fc4cc39e5439658f6b8540b95765496cfe01e92c6b4'); - const k1 = keyPair(h2b('f6664a95992958bbfeb7e6f50bbca2aa7bfd015aec79820caf362a3c874e9247')); + const k1 = Ed25519.keyPair(h2b('f6664a95992958bbfeb7e6f50bbca2aa7bfd015aec79820caf362a3c874e9247')); // BasicWallet.transfer signature is over these params: const [nonce, amount, dest] = [12, 100, GPrivate.fromObject({ id: destid })]; - const sig = k1.signData([nonce, amount, dest]); + const sig = Hex.decode(RHOCore.wrapHash(k1.signBytes)([nonce, amount, dest])); test.equal( rhol`new dest, status in { BasicWallet!("transfer", ${amount}, ${nonce}, ${sig}, dest, status) }`, 'new dest, status in { BasicWallet!("transfer", 100, 12, "6a6e8ea7d13ad1e7cd676eee62081f9c6b36cfaef4d41d533127a56e7f48ad1378ae93e59b05d73cf17ce55bedf6b201cd78f6ec8ef20dd1b919b5918cc72007".hexToBytes(), dest, status) }', diff --git a/test/proxy.test.js b/test/proxy.test.js index 74b189e..d378311 100644 --- a/test/proxy.test.js +++ b/test/proxy.test.js @@ -1,7 +1,7 @@ /* global require */ const { URL } = require('url'); const test = require('tape'); -const { callSource } = require('..'); +const { callSource } = require('..').RegistryProxy; test('callSource with no args', (t) => { t.equal(callSource({ target: new URL('x:'), method: 'm', args: [] }, {}), ` diff --git a/test/revAddressTest.js b/test/revAddressTest.js index 9f653aa..f8e0162 100644 --- a/test/revAddressTest.js +++ b/test/revAddressTest.js @@ -1,6 +1,6 @@ /* global require*/ const ttest = require('tape'); // ISSUE: separate tests -const { h2b, RevAddress } = require('..'); +const { Hex, RevAddress } = require('..'); const testCases = [ { @@ -20,7 +20,7 @@ const testCases = [ testCases.forEach((info) => { ttest(`RevAddress: ${info.label}`, (t) => { - t.equal(RevAddress.fromPublicKey(h2b(info.publicKey)).toString(), info.revAddress); + t.equal(RevAddress.fromPublicKey(Hex.decode(info.publicKey)).toString(), info.revAddress); t.end(); }); }); diff --git a/test/testRNode.js b/test/testRNode.js index d5775e8..55930db 100644 --- a/test/testRNode.js +++ b/test/testRNode.js @@ -2,9 +2,8 @@ const ttest = require('tape'); const api = require('../index'); -const { RNode, b2h, h2b, SignDeployment, keyPair } = api; -const { sha256Hash, keccak256Hash, blake2b256Hash } = api; -const { simplifiedSHA256Hash, simplifiedKeccak256Hash, simplifiedBlake2b256Hash } = api; +const { RNode, SignDeployment, RHOCore, Hex } = api; +const { Ed25519, SHA256, Keccak256, Blake2b256 } = api; /** @@ -38,7 +37,7 @@ function testRNode(suite2) { } -const defaultSec = h2b('b18e1d0045995ec3d010c387ccfeb984d783af8fbb0f40fa7db126d889f6dadd'); +const defaultSec = Hex.decode('b18e1d0045995ec3d010c387ccfeb984d783af8fbb0f40fa7db126d889f6dadd'); function netTests({ grpc, clock, rng }) { const localNode = () => RNode(grpc, { host: 'localhost', port: 40401 }); @@ -53,10 +52,10 @@ function netTests({ grpc, clock, rng }) { runAndListen(hashProc, returnChannel, clock().valueOf(), localNode(), test) .then((rholangHash) => { if (isNormalTest) { - const serializedData = h2b(config.txt); + const serializedData = Hex.decode(config.txt); test.deepEqual(fn(serializedData), Uint8Array.from(rholangHash.exprs[0].g_byte_array)); } else { - test.equal(fn('testtest'), b2h(rholangHash.exprs[0].g_byte_array)); + test.equal(fn('testtest'), Hex.encode(rholangHash.exprs[0].g_byte_array)); } test.end(); }) @@ -71,7 +70,7 @@ function netTests({ grpc, clock, rng }) { const term = 'new test in { contract test(return) = { return!("test") } }'; const timestamp = clock().valueOf(); - const key = keyPair(defaultSec); + const key = Ed25519.keyPair(defaultSec); localNode().doDeploy(payFor({ term, timestamp }, key), true).then((results) => { test.equal(results.slice(0, 'Success'.length), 'Success'); test.end(); @@ -98,22 +97,22 @@ function netTests({ grpc, clock, rng }) { }); }, 'simplified SHA256 hashing': (test) => { - hashTest(test, simplifiedSHA256Hash, 'sha256Hash', false); + hashTest(test, RHOCore.wrapHash(SHA256.hash), 'sha256hash', false); }, 'simplified Keccak256 hashing': (test) => { - hashTest(test, simplifiedKeccak256Hash, 'keccak256Hash', false); + hashTest(test, RHOCore.wrapHash(Keccak256.hash), 'keccak256hash', false); }, 'simplified Blake2b256 hashing': (test) => { - hashTest(test, simplifiedBlake2b256Hash, 'blake2b256Hash', false); + hashTest(test, RHOCore.wrapHash(Blake2b256.hash), 'blake2b256hash', false); }, 'normal SHA256 hashing': (test) => { - hashTest(test, sha256Hash, 'sha256Hash', true); + hashTest(test, SHA256.hash, 'SHA256.hash', true); }, 'normal Keccak256 hashing': (test) => { - hashTest(test, keccak256Hash, 'keccak256Hash', true); + hashTest(test, Keccak256.hash, 'keccak256.hash', true); }, 'normal Blake2b256 hashing': (test) => { - hashTest(test, blake2b256Hash, 'blake2b256Hash', true); + hashTest(test, Blake2b256.hash, 'Blake2b256.hash', true); }, }; } @@ -124,7 +123,7 @@ function runAndListen( term, returnChannel, timestamp, node, test = null, ) { - const key = keyPair(defaultSec); + const key = Ed25519.keyPair(defaultSec); // console.log("run:", { term, returnChannel }); return node.doDeploy(payFor({ term, timestamp }, key), true).then((results) => { if (test) { test.equal(results.slice(0, 'Success'.length), 'Success'); } diff --git a/test/testSigning.js b/test/testSigning.js index 5eff23c..0dabe47 100644 --- a/test/testSigning.js +++ b/test/testSigning.js @@ -1,7 +1,9 @@ /*global require*/ +// @flow + const ttest = require('tape'); const { DeployData } = require('../protobuf/CasperMessage').coop.rchain.casper.protocol; -const { keyPair, h2b, b2h, verify, SignDeployment } = require('..'); +const { Ed25519, Hex, SignDeployment } = require('..'); function testSigning() { const cases = { @@ -24,9 +26,12 @@ function testSigning() { Object.entries(cases).forEach(([desc, fn]) => ttest(desc, fn)); + const b2h = Hex.encode; + const h2b = Hex.decode; + function check(info) { return (test) => { - const pair1 = keyPair(h2b(info.seedHex)); + const pair1 = Ed25519.keyPair(h2b(info.seedHex)); test.deepEqual(info.pubKeyHex, pair1.publicKey()); @@ -34,7 +39,7 @@ function testSigning() { const sigHex = pair1.signBytesHex(message); test.deepEqual(info.sigHex, sigHex); - test.deepEqual(verify(message, h2b(info.sigHex), h2b(info.pubKeyHex)), true); + test.deepEqual(Ed25519.verify(message, h2b(info.sigHex), h2b(info.pubKeyHex)), true); test.end(); }; } @@ -54,7 +59,7 @@ function testSigning() { '123b6e6577207465737420696e207b20636f6e747261637420746573742872657475726e29203d207b2072657475726e212822746573742229207d207d189eb29ff69f2d38014080ade204', ); - const dout = SignDeployment.sign(keyPair(defaultSec), d0); + const dout = SignDeployment.sign(Ed25519.keyPair(defaultSec), d0); test.equal( b2h(dout.sig), 'b6e0c2077e3ae2794b7324b518b49a9aa597eb07207f84f6339db73aeb6852491b8a7e640fd17f88ee80b61e3d326ec87835feebbb7dacdeadf03f26deff350f', From 7c5a820e322ae28ac5a7e1f64bca351276188f9a Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Fri, 12 Apr 2019 08:40:20 -0500 Subject: [PATCH 05/36] document testAll fixes #38 --- .travis.yml | 4 +--- CONTRIBUTING.md | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index d34b2d8..41e310e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,4 @@ cache: - "node_modules" - "rclient/node_modules" script: - - npm test - - npm run flow-check - - npm run lint + - npm run check diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 38b914a..ca1649e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,15 +1,12 @@ # Code Conventions and Design Notes -All contributions should pass these checks (as noted in -`.travis.yml`): +As noted in `.travis.yml`, all contributions must pass `npm run check`, +which runs `test`, `lint`, etc. The `test` check is conventional unit tests. -```yaml - - npm test - - npm run flow-check - - npm run lint -``` +Contributions should also pass `npm run integrationTest`, which +requires a running validator node (see below). -The `test` check is conventional unit tests. +To run both the offline and online tests, use `npm run testAll`. ## Static Typechecking: flow @@ -22,15 +19,23 @@ does an incremental check. ## RChain Validator Node for Integration testing One way to provide a validator node for testing, provided you're OK -with the security risks around `--net host`, is: +with the security risks around `--net host`, is to first have +the node start up and generate some random validator keys: +```bash +docker run --rm --net host -v$HOME/.rnode:/var/lib/rnode \ + rchain/rnode run -s +``` + +Then grab one of the secret keys for use as a validator private key: ```bash -$ docker run --rm -it --net host coop.rchain/rnode:0.7.1 run -s +first_key=$(cat $(ls ~/.rnode/genesis/*.sk|head -1)) + +docker run --rm --net host -v$HOME/.rnode:/var/lib/rnode \ + rchain/rnode run -s --validator-private-key $first_key ``` -This presumes you've built `coop.rchain/rnode` per `DEVELOPER.md` in -rchain/rchain. ## Code Style: airbnb From a51cd4aaa49eaf8824adef1950ddc3525f70cda4 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Fri, 12 Apr 2019 11:32:10 -0500 Subject: [PATCH 06/36] protobuf: never mind messages.js --- protobuf/messages.js | 24759 ----------------------------------------- 1 file changed, 24759 deletions(-) delete mode 100644 protobuf/messages.js diff --git a/protobuf/messages.js b/protobuf/messages.js deleted file mode 100644 index b4fb343..0000000 --- a/protobuf/messages.js +++ /dev/null @@ -1,24759 +0,0 @@ -/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ -"use strict"; - -var $protobuf = require("protobufjs/minimal"); - -// Common aliases -var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; - -// Exported root namespace -var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); - -$root.coop = (function() { - - /** - * Namespace coop. - * @exports coop - * @namespace - */ - var coop = {}; - - coop.rchain = (function() { - - /** - * Namespace rchain. - * @memberof coop - * @namespace - */ - var rchain = {}; - - rchain.casper = (function() { - - /** - * Namespace casper. - * @memberof coop.rchain - * @namespace - */ - var casper = {}; - - casper.protocol = (function() { - - /** - * Namespace protocol. - * @memberof coop.rchain.casper - * @namespace - */ - var protocol = {}; - - protocol.DeployService = (function() { - - /** - * Constructs a new DeployService service. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a DeployService - * @extends $protobuf.rpc.Service - * @constructor - * @param {$protobuf.RPCImpl} rpcImpl RPC implementation - * @param {boolean} [requestDelimited=false] Whether requests are length-delimited - * @param {boolean} [responseDelimited=false] Whether responses are length-delimited - */ - function DeployService(rpcImpl, requestDelimited, responseDelimited) { - $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); - } - - (DeployService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = DeployService; - - /** - * Creates new DeployService service using the specified rpc implementation. - * @function create - * @memberof coop.rchain.casper.protocol.DeployService - * @static - * @param {$protobuf.RPCImpl} rpcImpl RPC implementation - * @param {boolean} [requestDelimited=false] Whether requests are length-delimited - * @param {boolean} [responseDelimited=false] Whether responses are length-delimited - * @returns {DeployService} RPC service. Useful where requests and/or responses are streamed. - */ - DeployService.create = function create(rpcImpl, requestDelimited, responseDelimited) { - return new this(rpcImpl, requestDelimited, responseDelimited); - }; - - /** - * Callback as used by {@link coop.rchain.casper.protocol.DeployService#doDeploy}. - * @memberof coop.rchain.casper.protocol.DeployService - * @typedef DoDeployCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {Either} [response] Either - */ - - /** - * Calls DoDeploy. - * @function doDeploy - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IDeployData} request DeployData message or plain object - * @param {coop.rchain.casper.protocol.DeployService.DoDeployCallback} callback Node-style callback called with the error, if any, and Either - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(DeployService.prototype.doDeploy = function doDeploy(request, callback) { - return this.rpcCall(doDeploy, $root.coop.rchain.casper.protocol.DeployData, $root.Either, request, callback); - }, "name", { value: "DoDeploy" }); - - /** - * Calls DoDeploy. - * @function doDeploy - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IDeployData} request DeployData message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link coop.rchain.casper.protocol.DeployService#createBlock}. - * @memberof coop.rchain.casper.protocol.DeployService - * @typedef createBlockCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {Either} [response] Either - */ - - /** - * Calls createBlock. - * @function createBlock - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {google.protobuf.IEmpty} request Empty message or plain object - * @param {coop.rchain.casper.protocol.DeployService.createBlockCallback} callback Node-style callback called with the error, if any, and Either - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(DeployService.prototype.createBlock = function createBlock(request, callback) { - return this.rpcCall(createBlock, $root.google.protobuf.Empty, $root.Either, request, callback); - }, "name", { value: "createBlock" }); - - /** - * Calls createBlock. - * @function createBlock - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {google.protobuf.IEmpty} request Empty message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link coop.rchain.casper.protocol.DeployService#showBlock}. - * @memberof coop.rchain.casper.protocol.DeployService - * @typedef showBlockCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {Either} [response] Either - */ - - /** - * Calls showBlock. - * @function showBlock - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IBlockQuery} request BlockQuery message or plain object - * @param {coop.rchain.casper.protocol.DeployService.showBlockCallback} callback Node-style callback called with the error, if any, and Either - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(DeployService.prototype.showBlock = function showBlock(request, callback) { - return this.rpcCall(showBlock, $root.coop.rchain.casper.protocol.BlockQuery, $root.Either, request, callback); - }, "name", { value: "showBlock" }); - - /** - * Calls showBlock. - * @function showBlock - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IBlockQuery} request BlockQuery message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link coop.rchain.casper.protocol.DeployService#visualizeDag}. - * @memberof coop.rchain.casper.protocol.DeployService - * @typedef visualizeDagCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {Either} [response] Either - */ - - /** - * Calls visualizeDag. - * @function visualizeDag - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IVisualizeDagQuery} request VisualizeDagQuery message or plain object - * @param {coop.rchain.casper.protocol.DeployService.visualizeDagCallback} callback Node-style callback called with the error, if any, and Either - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(DeployService.prototype.visualizeDag = function visualizeDag(request, callback) { - return this.rpcCall(visualizeDag, $root.coop.rchain.casper.protocol.VisualizeDagQuery, $root.Either, request, callback); - }, "name", { value: "visualizeDag" }); - - /** - * Calls visualizeDag. - * @function visualizeDag - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IVisualizeDagQuery} request VisualizeDagQuery message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link coop.rchain.casper.protocol.DeployService#showMainChain}. - * @memberof coop.rchain.casper.protocol.DeployService - * @typedef showMainChainCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {Either} [response] Either - */ - - /** - * Calls showMainChain. - * @function showMainChain - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IBlocksQuery} request BlocksQuery message or plain object - * @param {coop.rchain.casper.protocol.DeployService.showMainChainCallback} callback Node-style callback called with the error, if any, and Either - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(DeployService.prototype.showMainChain = function showMainChain(request, callback) { - return this.rpcCall(showMainChain, $root.coop.rchain.casper.protocol.BlocksQuery, $root.Either, request, callback); - }, "name", { value: "showMainChain" }); - - /** - * Calls showMainChain. - * @function showMainChain - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IBlocksQuery} request BlocksQuery message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link coop.rchain.casper.protocol.DeployService#showBlocks}. - * @memberof coop.rchain.casper.protocol.DeployService - * @typedef showBlocksCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {Either} [response] Either - */ - - /** - * Calls showBlocks. - * @function showBlocks - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IBlocksQuery} request BlocksQuery message or plain object - * @param {coop.rchain.casper.protocol.DeployService.showBlocksCallback} callback Node-style callback called with the error, if any, and Either - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(DeployService.prototype.showBlocks = function showBlocks(request, callback) { - return this.rpcCall(showBlocks, $root.coop.rchain.casper.protocol.BlocksQuery, $root.Either, request, callback); - }, "name", { value: "showBlocks" }); - - /** - * Calls showBlocks. - * @function showBlocks - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IBlocksQuery} request BlocksQuery message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link coop.rchain.casper.protocol.DeployService#listenForDataAtName}. - * @memberof coop.rchain.casper.protocol.DeployService - * @typedef listenForDataAtNameCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {Either} [response] Either - */ - - /** - * Calls listenForDataAtName. - * @function listenForDataAtName - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IDataAtNameQuery} request DataAtNameQuery message or plain object - * @param {coop.rchain.casper.protocol.DeployService.listenForDataAtNameCallback} callback Node-style callback called with the error, if any, and Either - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(DeployService.prototype.listenForDataAtName = function listenForDataAtName(request, callback) { - return this.rpcCall(listenForDataAtName, $root.coop.rchain.casper.protocol.DataAtNameQuery, $root.Either, request, callback); - }, "name", { value: "listenForDataAtName" }); - - /** - * Calls listenForDataAtName. - * @function listenForDataAtName - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IDataAtNameQuery} request DataAtNameQuery message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link coop.rchain.casper.protocol.DeployService#listenForContinuationAtName}. - * @memberof coop.rchain.casper.protocol.DeployService - * @typedef listenForContinuationAtNameCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {Either} [response] Either - */ - - /** - * Calls listenForContinuationAtName. - * @function listenForContinuationAtName - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IContinuationAtNameQuery} request ContinuationAtNameQuery message or plain object - * @param {coop.rchain.casper.protocol.DeployService.listenForContinuationAtNameCallback} callback Node-style callback called with the error, if any, and Either - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(DeployService.prototype.listenForContinuationAtName = function listenForContinuationAtName(request, callback) { - return this.rpcCall(listenForContinuationAtName, $root.coop.rchain.casper.protocol.ContinuationAtNameQuery, $root.Either, request, callback); - }, "name", { value: "listenForContinuationAtName" }); - - /** - * Calls listenForContinuationAtName. - * @function listenForContinuationAtName - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IContinuationAtNameQuery} request ContinuationAtNameQuery message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link coop.rchain.casper.protocol.DeployService#findBlockWithDeploy}. - * @memberof coop.rchain.casper.protocol.DeployService - * @typedef findBlockWithDeployCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {Either} [response] Either - */ - - /** - * Calls findBlockWithDeploy. - * @function findBlockWithDeploy - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IFindDeployInBlockQuery} request FindDeployInBlockQuery message or plain object - * @param {coop.rchain.casper.protocol.DeployService.findBlockWithDeployCallback} callback Node-style callback called with the error, if any, and Either - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(DeployService.prototype.findBlockWithDeploy = function findBlockWithDeploy(request, callback) { - return this.rpcCall(findBlockWithDeploy, $root.coop.rchain.casper.protocol.FindDeployInBlockQuery, $root.Either, request, callback); - }, "name", { value: "findBlockWithDeploy" }); - - /** - * Calls findBlockWithDeploy. - * @function findBlockWithDeploy - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IFindDeployInBlockQuery} request FindDeployInBlockQuery message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - /** - * Callback as used by {@link coop.rchain.casper.protocol.DeployService#previewPrivateNames}. - * @memberof coop.rchain.casper.protocol.DeployService - * @typedef previewPrivateNamesCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {Either} [response] Either - */ - - /** - * Calls previewPrivateNames. - * @function previewPrivateNames - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IPrivateNamePreviewQuery} request PrivateNamePreviewQuery message or plain object - * @param {coop.rchain.casper.protocol.DeployService.previewPrivateNamesCallback} callback Node-style callback called with the error, if any, and Either - * @returns {undefined} - * @variation 1 - */ - Object.defineProperty(DeployService.prototype.previewPrivateNames = function previewPrivateNames(request, callback) { - return this.rpcCall(previewPrivateNames, $root.coop.rchain.casper.protocol.PrivateNamePreviewQuery, $root.Either, request, callback); - }, "name", { value: "previewPrivateNames" }); - - /** - * Calls previewPrivateNames. - * @function previewPrivateNames - * @memberof coop.rchain.casper.protocol.DeployService - * @instance - * @param {coop.rchain.casper.protocol.IPrivateNamePreviewQuery} request PrivateNamePreviewQuery message or plain object - * @returns {Promise} Promise - * @variation 2 - */ - - return DeployService; - })(); - - protocol.DeployData = (function() { - - /** - * Properties of a DeployData. - * @memberof coop.rchain.casper.protocol - * @interface IDeployData - * @property {Uint8Array|null} [deployer] DeployData deployer - * @property {string|null} [term] DeployData term - * @property {number|Long|null} [timestamp] DeployData timestamp - * @property {Uint8Array|null} [sig] DeployData sig - * @property {string|null} [sigAlgorithm] DeployData sigAlgorithm - * @property {number|Long|null} [phloPrice] DeployData phloPrice - * @property {number|Long|null} [phloLimit] DeployData phloLimit - * @property {number|Long|null} [validAfterBlockNumber] DeployData validAfterBlockNumber - */ - - /** - * Constructs a new DeployData. - * @memberof coop.rchain.casper.protocol - * @classdesc Note: deploys are uniquely keyed by `user`, `timestamp`. - * - * **TODO**: details of signatures and payment. See RHOL-781 - * @implements IDeployData - * @constructor - * @param {coop.rchain.casper.protocol.IDeployData=} [properties] Properties to set - */ - function DeployData(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DeployData deployer. - * @member {Uint8Array} deployer - * @memberof coop.rchain.casper.protocol.DeployData - * @instance - */ - DeployData.prototype.deployer = $util.newBuffer([]); - - /** - * DeployData term. - * @member {string} term - * @memberof coop.rchain.casper.protocol.DeployData - * @instance - */ - DeployData.prototype.term = ""; - - /** - * DeployData timestamp. - * @member {number|Long} timestamp - * @memberof coop.rchain.casper.protocol.DeployData - * @instance - */ - DeployData.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * DeployData sig. - * @member {Uint8Array} sig - * @memberof coop.rchain.casper.protocol.DeployData - * @instance - */ - DeployData.prototype.sig = $util.newBuffer([]); - - /** - * DeployData sigAlgorithm. - * @member {string} sigAlgorithm - * @memberof coop.rchain.casper.protocol.DeployData - * @instance - */ - DeployData.prototype.sigAlgorithm = ""; - - /** - * DeployData phloPrice. - * @member {number|Long} phloPrice - * @memberof coop.rchain.casper.protocol.DeployData - * @instance - */ - DeployData.prototype.phloPrice = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * DeployData phloLimit. - * @member {number|Long} phloLimit - * @memberof coop.rchain.casper.protocol.DeployData - * @instance - */ - DeployData.prototype.phloLimit = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * DeployData validAfterBlockNumber. - * @member {number|Long} validAfterBlockNumber - * @memberof coop.rchain.casper.protocol.DeployData - * @instance - */ - DeployData.prototype.validAfterBlockNumber = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Creates a new DeployData instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.DeployData - * @static - * @param {coop.rchain.casper.protocol.IDeployData=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.DeployData} DeployData instance - */ - DeployData.create = function create(properties) { - return new DeployData(properties); - }; - - /** - * Encodes the specified DeployData message. Does not implicitly {@link coop.rchain.casper.protocol.DeployData.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.DeployData - * @static - * @param {coop.rchain.casper.protocol.IDeployData} message DeployData message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DeployData.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.deployer != null && message.hasOwnProperty("deployer")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.deployer); - if (message.term != null && message.hasOwnProperty("term")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.term); - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - writer.uint32(/* id 3, wireType 0 =*/24).int64(message.timestamp); - if (message.sig != null && message.hasOwnProperty("sig")) - writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.sig); - if (message.sigAlgorithm != null && message.hasOwnProperty("sigAlgorithm")) - writer.uint32(/* id 5, wireType 2 =*/42).string(message.sigAlgorithm); - if (message.phloPrice != null && message.hasOwnProperty("phloPrice")) - writer.uint32(/* id 7, wireType 0 =*/56).int64(message.phloPrice); - if (message.phloLimit != null && message.hasOwnProperty("phloLimit")) - writer.uint32(/* id 8, wireType 0 =*/64).int64(message.phloLimit); - if (message.validAfterBlockNumber != null && message.hasOwnProperty("validAfterBlockNumber")) - writer.uint32(/* id 10, wireType 0 =*/80).int64(message.validAfterBlockNumber); - return writer; - }; - - /** - * Encodes the specified DeployData message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.DeployData.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.DeployData - * @static - * @param {coop.rchain.casper.protocol.IDeployData} message DeployData message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DeployData.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a DeployData message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.DeployData - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.DeployData} DeployData - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DeployData.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.DeployData(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.deployer = reader.bytes(); - break; - case 2: - message.term = reader.string(); - break; - case 3: - message.timestamp = reader.int64(); - break; - case 4: - message.sig = reader.bytes(); - break; - case 5: - message.sigAlgorithm = reader.string(); - break; - case 7: - message.phloPrice = reader.int64(); - break; - case 8: - message.phloLimit = reader.int64(); - break; - case 10: - message.validAfterBlockNumber = reader.int64(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a DeployData message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.DeployData - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.DeployData} DeployData - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DeployData.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a DeployData message. - * @function verify - * @memberof coop.rchain.casper.protocol.DeployData - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - DeployData.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.deployer != null && message.hasOwnProperty("deployer")) - if (!(message.deployer && typeof message.deployer.length === "number" || $util.isString(message.deployer))) - return "deployer: buffer expected"; - if (message.term != null && message.hasOwnProperty("term")) - if (!$util.isString(message.term)) - return "term: string expected"; - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high))) - return "timestamp: integer|Long expected"; - if (message.sig != null && message.hasOwnProperty("sig")) - if (!(message.sig && typeof message.sig.length === "number" || $util.isString(message.sig))) - return "sig: buffer expected"; - if (message.sigAlgorithm != null && message.hasOwnProperty("sigAlgorithm")) - if (!$util.isString(message.sigAlgorithm)) - return "sigAlgorithm: string expected"; - if (message.phloPrice != null && message.hasOwnProperty("phloPrice")) - if (!$util.isInteger(message.phloPrice) && !(message.phloPrice && $util.isInteger(message.phloPrice.low) && $util.isInteger(message.phloPrice.high))) - return "phloPrice: integer|Long expected"; - if (message.phloLimit != null && message.hasOwnProperty("phloLimit")) - if (!$util.isInteger(message.phloLimit) && !(message.phloLimit && $util.isInteger(message.phloLimit.low) && $util.isInteger(message.phloLimit.high))) - return "phloLimit: integer|Long expected"; - if (message.validAfterBlockNumber != null && message.hasOwnProperty("validAfterBlockNumber")) - if (!$util.isInteger(message.validAfterBlockNumber) && !(message.validAfterBlockNumber && $util.isInteger(message.validAfterBlockNumber.low) && $util.isInteger(message.validAfterBlockNumber.high))) - return "validAfterBlockNumber: integer|Long expected"; - return null; - }; - - /** - * Creates a DeployData message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.DeployData - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.DeployData} DeployData - */ - DeployData.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.DeployData) - return object; - var message = new $root.coop.rchain.casper.protocol.DeployData(); - if (object.deployer != null) - if (typeof object.deployer === "string") - $util.base64.decode(object.deployer, message.deployer = $util.newBuffer($util.base64.length(object.deployer)), 0); - else if (object.deployer.length) - message.deployer = object.deployer; - if (object.term != null) - message.term = String(object.term); - if (object.timestamp != null) - if ($util.Long) - (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = false; - else if (typeof object.timestamp === "string") - message.timestamp = parseInt(object.timestamp, 10); - else if (typeof object.timestamp === "number") - message.timestamp = object.timestamp; - else if (typeof object.timestamp === "object") - message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber(); - if (object.sig != null) - if (typeof object.sig === "string") - $util.base64.decode(object.sig, message.sig = $util.newBuffer($util.base64.length(object.sig)), 0); - else if (object.sig.length) - message.sig = object.sig; - if (object.sigAlgorithm != null) - message.sigAlgorithm = String(object.sigAlgorithm); - if (object.phloPrice != null) - if ($util.Long) - (message.phloPrice = $util.Long.fromValue(object.phloPrice)).unsigned = false; - else if (typeof object.phloPrice === "string") - message.phloPrice = parseInt(object.phloPrice, 10); - else if (typeof object.phloPrice === "number") - message.phloPrice = object.phloPrice; - else if (typeof object.phloPrice === "object") - message.phloPrice = new $util.LongBits(object.phloPrice.low >>> 0, object.phloPrice.high >>> 0).toNumber(); - if (object.phloLimit != null) - if ($util.Long) - (message.phloLimit = $util.Long.fromValue(object.phloLimit)).unsigned = false; - else if (typeof object.phloLimit === "string") - message.phloLimit = parseInt(object.phloLimit, 10); - else if (typeof object.phloLimit === "number") - message.phloLimit = object.phloLimit; - else if (typeof object.phloLimit === "object") - message.phloLimit = new $util.LongBits(object.phloLimit.low >>> 0, object.phloLimit.high >>> 0).toNumber(); - if (object.validAfterBlockNumber != null) - if ($util.Long) - (message.validAfterBlockNumber = $util.Long.fromValue(object.validAfterBlockNumber)).unsigned = false; - else if (typeof object.validAfterBlockNumber === "string") - message.validAfterBlockNumber = parseInt(object.validAfterBlockNumber, 10); - else if (typeof object.validAfterBlockNumber === "number") - message.validAfterBlockNumber = object.validAfterBlockNumber; - else if (typeof object.validAfterBlockNumber === "object") - message.validAfterBlockNumber = new $util.LongBits(object.validAfterBlockNumber.low >>> 0, object.validAfterBlockNumber.high >>> 0).toNumber(); - return message; - }; - - /** - * Creates a plain object from a DeployData message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.DeployData - * @static - * @param {coop.rchain.casper.protocol.DeployData} message DeployData - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - DeployData.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if (options.bytes === String) - object.deployer = ""; - else { - object.deployer = []; - if (options.bytes !== Array) - object.deployer = $util.newBuffer(object.deployer); - } - object.term = ""; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.timestamp = options.longs === String ? "0" : 0; - if (options.bytes === String) - object.sig = ""; - else { - object.sig = []; - if (options.bytes !== Array) - object.sig = $util.newBuffer(object.sig); - } - object.sigAlgorithm = ""; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.phloPrice = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.phloPrice = options.longs === String ? "0" : 0; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.phloLimit = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.phloLimit = options.longs === String ? "0" : 0; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.validAfterBlockNumber = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.validAfterBlockNumber = options.longs === String ? "0" : 0; - } - if (message.deployer != null && message.hasOwnProperty("deployer")) - object.deployer = options.bytes === String ? $util.base64.encode(message.deployer, 0, message.deployer.length) : options.bytes === Array ? Array.prototype.slice.call(message.deployer) : message.deployer; - if (message.term != null && message.hasOwnProperty("term")) - object.term = message.term; - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (typeof message.timestamp === "number") - object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp; - else - object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber() : message.timestamp; - if (message.sig != null && message.hasOwnProperty("sig")) - object.sig = options.bytes === String ? $util.base64.encode(message.sig, 0, message.sig.length) : options.bytes === Array ? Array.prototype.slice.call(message.sig) : message.sig; - if (message.sigAlgorithm != null && message.hasOwnProperty("sigAlgorithm")) - object.sigAlgorithm = message.sigAlgorithm; - if (message.phloPrice != null && message.hasOwnProperty("phloPrice")) - if (typeof message.phloPrice === "number") - object.phloPrice = options.longs === String ? String(message.phloPrice) : message.phloPrice; - else - object.phloPrice = options.longs === String ? $util.Long.prototype.toString.call(message.phloPrice) : options.longs === Number ? new $util.LongBits(message.phloPrice.low >>> 0, message.phloPrice.high >>> 0).toNumber() : message.phloPrice; - if (message.phloLimit != null && message.hasOwnProperty("phloLimit")) - if (typeof message.phloLimit === "number") - object.phloLimit = options.longs === String ? String(message.phloLimit) : message.phloLimit; - else - object.phloLimit = options.longs === String ? $util.Long.prototype.toString.call(message.phloLimit) : options.longs === Number ? new $util.LongBits(message.phloLimit.low >>> 0, message.phloLimit.high >>> 0).toNumber() : message.phloLimit; - if (message.validAfterBlockNumber != null && message.hasOwnProperty("validAfterBlockNumber")) - if (typeof message.validAfterBlockNumber === "number") - object.validAfterBlockNumber = options.longs === String ? String(message.validAfterBlockNumber) : message.validAfterBlockNumber; - else - object.validAfterBlockNumber = options.longs === String ? $util.Long.prototype.toString.call(message.validAfterBlockNumber) : options.longs === Number ? new $util.LongBits(message.validAfterBlockNumber.low >>> 0, message.validAfterBlockNumber.high >>> 0).toNumber() : message.validAfterBlockNumber; - return object; - }; - - /** - * Converts this DeployData to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.DeployData - * @instance - * @returns {Object.} JSON object - */ - DeployData.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return DeployData; - })(); - - protocol.BlockRequest = (function() { - - /** - * Properties of a BlockRequest. - * @memberof coop.rchain.casper.protocol - * @interface IBlockRequest - * @property {string|null} [base16Hash] BlockRequest base16Hash - * @property {Uint8Array|null} [hash] BlockRequest hash - */ - - /** - * Constructs a new BlockRequest. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a BlockRequest. - * @implements IBlockRequest - * @constructor - * @param {coop.rchain.casper.protocol.IBlockRequest=} [properties] Properties to set - */ - function BlockRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BlockRequest base16Hash. - * @member {string} base16Hash - * @memberof coop.rchain.casper.protocol.BlockRequest - * @instance - */ - BlockRequest.prototype.base16Hash = ""; - - /** - * BlockRequest hash. - * @member {Uint8Array} hash - * @memberof coop.rchain.casper.protocol.BlockRequest - * @instance - */ - BlockRequest.prototype.hash = $util.newBuffer([]); - - /** - * Creates a new BlockRequest instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.BlockRequest - * @static - * @param {coop.rchain.casper.protocol.IBlockRequest=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.BlockRequest} BlockRequest instance - */ - BlockRequest.create = function create(properties) { - return new BlockRequest(properties); - }; - - /** - * Encodes the specified BlockRequest message. Does not implicitly {@link coop.rchain.casper.protocol.BlockRequest.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.BlockRequest - * @static - * @param {coop.rchain.casper.protocol.IBlockRequest} message BlockRequest message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockRequest.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.base16Hash != null && message.hasOwnProperty("base16Hash")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.base16Hash); - if (message.hash != null && message.hasOwnProperty("hash")) - writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.hash); - return writer; - }; - - /** - * Encodes the specified BlockRequest message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.BlockRequest.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.BlockRequest - * @static - * @param {coop.rchain.casper.protocol.IBlockRequest} message BlockRequest message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockRequest.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a BlockRequest message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.BlockRequest - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.BlockRequest} BlockRequest - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockRequest.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.BlockRequest(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.base16Hash = reader.string(); - break; - case 2: - message.hash = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a BlockRequest message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.BlockRequest - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.BlockRequest} BlockRequest - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockRequest.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a BlockRequest message. - * @function verify - * @memberof coop.rchain.casper.protocol.BlockRequest - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - BlockRequest.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.base16Hash != null && message.hasOwnProperty("base16Hash")) - if (!$util.isString(message.base16Hash)) - return "base16Hash: string expected"; - if (message.hash != null && message.hasOwnProperty("hash")) - if (!(message.hash && typeof message.hash.length === "number" || $util.isString(message.hash))) - return "hash: buffer expected"; - return null; - }; - - /** - * Creates a BlockRequest message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.BlockRequest - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.BlockRequest} BlockRequest - */ - BlockRequest.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.BlockRequest) - return object; - var message = new $root.coop.rchain.casper.protocol.BlockRequest(); - if (object.base16Hash != null) - message.base16Hash = String(object.base16Hash); - if (object.hash != null) - if (typeof object.hash === "string") - $util.base64.decode(object.hash, message.hash = $util.newBuffer($util.base64.length(object.hash)), 0); - else if (object.hash.length) - message.hash = object.hash; - return message; - }; - - /** - * Creates a plain object from a BlockRequest message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.BlockRequest - * @static - * @param {coop.rchain.casper.protocol.BlockRequest} message BlockRequest - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - BlockRequest.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.base16Hash = ""; - if (options.bytes === String) - object.hash = ""; - else { - object.hash = []; - if (options.bytes !== Array) - object.hash = $util.newBuffer(object.hash); - } - } - if (message.base16Hash != null && message.hasOwnProperty("base16Hash")) - object.base16Hash = message.base16Hash; - if (message.hash != null && message.hasOwnProperty("hash")) - object.hash = options.bytes === String ? $util.base64.encode(message.hash, 0, message.hash.length) : options.bytes === Array ? Array.prototype.slice.call(message.hash) : message.hash; - return object; - }; - - /** - * Converts this BlockRequest to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.BlockRequest - * @instance - * @returns {Object.} JSON object - */ - BlockRequest.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return BlockRequest; - })(); - - protocol.ForkChoiceTipRequest = (function() { - - /** - * Properties of a ForkChoiceTipRequest. - * @memberof coop.rchain.casper.protocol - * @interface IForkChoiceTipRequest - */ - - /** - * Constructs a new ForkChoiceTipRequest. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a ForkChoiceTipRequest. - * @implements IForkChoiceTipRequest - * @constructor - * @param {coop.rchain.casper.protocol.IForkChoiceTipRequest=} [properties] Properties to set - */ - function ForkChoiceTipRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Creates a new ForkChoiceTipRequest instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.ForkChoiceTipRequest - * @static - * @param {coop.rchain.casper.protocol.IForkChoiceTipRequest=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.ForkChoiceTipRequest} ForkChoiceTipRequest instance - */ - ForkChoiceTipRequest.create = function create(properties) { - return new ForkChoiceTipRequest(properties); - }; - - /** - * Encodes the specified ForkChoiceTipRequest message. Does not implicitly {@link coop.rchain.casper.protocol.ForkChoiceTipRequest.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.ForkChoiceTipRequest - * @static - * @param {coop.rchain.casper.protocol.IForkChoiceTipRequest} message ForkChoiceTipRequest message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ForkChoiceTipRequest.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - return writer; - }; - - /** - * Encodes the specified ForkChoiceTipRequest message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.ForkChoiceTipRequest.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.ForkChoiceTipRequest - * @static - * @param {coop.rchain.casper.protocol.IForkChoiceTipRequest} message ForkChoiceTipRequest message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ForkChoiceTipRequest.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ForkChoiceTipRequest message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.ForkChoiceTipRequest - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.ForkChoiceTipRequest} ForkChoiceTipRequest - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ForkChoiceTipRequest.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.ForkChoiceTipRequest(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ForkChoiceTipRequest message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.ForkChoiceTipRequest - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.ForkChoiceTipRequest} ForkChoiceTipRequest - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ForkChoiceTipRequest.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ForkChoiceTipRequest message. - * @function verify - * @memberof coop.rchain.casper.protocol.ForkChoiceTipRequest - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ForkChoiceTipRequest.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - return null; - }; - - /** - * Creates a ForkChoiceTipRequest message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.ForkChoiceTipRequest - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.ForkChoiceTipRequest} ForkChoiceTipRequest - */ - ForkChoiceTipRequest.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.ForkChoiceTipRequest) - return object; - return new $root.coop.rchain.casper.protocol.ForkChoiceTipRequest(); - }; - - /** - * Creates a plain object from a ForkChoiceTipRequest message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.ForkChoiceTipRequest - * @static - * @param {coop.rchain.casper.protocol.ForkChoiceTipRequest} message ForkChoiceTipRequest - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ForkChoiceTipRequest.toObject = function toObject() { - return {}; - }; - - /** - * Converts this ForkChoiceTipRequest to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.ForkChoiceTipRequest - * @instance - * @returns {Object.} JSON object - */ - ForkChoiceTipRequest.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ForkChoiceTipRequest; - })(); - - protocol.FindDeployInBlockQuery = (function() { - - /** - * Properties of a FindDeployInBlockQuery. - * @memberof coop.rchain.casper.protocol - * @interface IFindDeployInBlockQuery - * @property {Uint8Array|null} [user] FindDeployInBlockQuery user - * @property {number|Long|null} [timestamp] FindDeployInBlockQuery timestamp - */ - - /** - * Constructs a new FindDeployInBlockQuery. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a FindDeployInBlockQuery. - * @implements IFindDeployInBlockQuery - * @constructor - * @param {coop.rchain.casper.protocol.IFindDeployInBlockQuery=} [properties] Properties to set - */ - function FindDeployInBlockQuery(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * FindDeployInBlockQuery user. - * @member {Uint8Array} user - * @memberof coop.rchain.casper.protocol.FindDeployInBlockQuery - * @instance - */ - FindDeployInBlockQuery.prototype.user = $util.newBuffer([]); - - /** - * FindDeployInBlockQuery timestamp. - * @member {number|Long} timestamp - * @memberof coop.rchain.casper.protocol.FindDeployInBlockQuery - * @instance - */ - FindDeployInBlockQuery.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Creates a new FindDeployInBlockQuery instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.FindDeployInBlockQuery - * @static - * @param {coop.rchain.casper.protocol.IFindDeployInBlockQuery=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.FindDeployInBlockQuery} FindDeployInBlockQuery instance - */ - FindDeployInBlockQuery.create = function create(properties) { - return new FindDeployInBlockQuery(properties); - }; - - /** - * Encodes the specified FindDeployInBlockQuery message. Does not implicitly {@link coop.rchain.casper.protocol.FindDeployInBlockQuery.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.FindDeployInBlockQuery - * @static - * @param {coop.rchain.casper.protocol.IFindDeployInBlockQuery} message FindDeployInBlockQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - FindDeployInBlockQuery.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.user != null && message.hasOwnProperty("user")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.user); - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - writer.uint32(/* id 2, wireType 0 =*/16).int64(message.timestamp); - return writer; - }; - - /** - * Encodes the specified FindDeployInBlockQuery message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.FindDeployInBlockQuery.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.FindDeployInBlockQuery - * @static - * @param {coop.rchain.casper.protocol.IFindDeployInBlockQuery} message FindDeployInBlockQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - FindDeployInBlockQuery.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a FindDeployInBlockQuery message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.FindDeployInBlockQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.FindDeployInBlockQuery} FindDeployInBlockQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - FindDeployInBlockQuery.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.FindDeployInBlockQuery(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.user = reader.bytes(); - break; - case 2: - message.timestamp = reader.int64(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a FindDeployInBlockQuery message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.FindDeployInBlockQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.FindDeployInBlockQuery} FindDeployInBlockQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - FindDeployInBlockQuery.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a FindDeployInBlockQuery message. - * @function verify - * @memberof coop.rchain.casper.protocol.FindDeployInBlockQuery - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - FindDeployInBlockQuery.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.user != null && message.hasOwnProperty("user")) - if (!(message.user && typeof message.user.length === "number" || $util.isString(message.user))) - return "user: buffer expected"; - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high))) - return "timestamp: integer|Long expected"; - return null; - }; - - /** - * Creates a FindDeployInBlockQuery message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.FindDeployInBlockQuery - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.FindDeployInBlockQuery} FindDeployInBlockQuery - */ - FindDeployInBlockQuery.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.FindDeployInBlockQuery) - return object; - var message = new $root.coop.rchain.casper.protocol.FindDeployInBlockQuery(); - if (object.user != null) - if (typeof object.user === "string") - $util.base64.decode(object.user, message.user = $util.newBuffer($util.base64.length(object.user)), 0); - else if (object.user.length) - message.user = object.user; - if (object.timestamp != null) - if ($util.Long) - (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = false; - else if (typeof object.timestamp === "string") - message.timestamp = parseInt(object.timestamp, 10); - else if (typeof object.timestamp === "number") - message.timestamp = object.timestamp; - else if (typeof object.timestamp === "object") - message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber(); - return message; - }; - - /** - * Creates a plain object from a FindDeployInBlockQuery message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.FindDeployInBlockQuery - * @static - * @param {coop.rchain.casper.protocol.FindDeployInBlockQuery} message FindDeployInBlockQuery - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - FindDeployInBlockQuery.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if (options.bytes === String) - object.user = ""; - else { - object.user = []; - if (options.bytes !== Array) - object.user = $util.newBuffer(object.user); - } - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.timestamp = options.longs === String ? "0" : 0; - } - if (message.user != null && message.hasOwnProperty("user")) - object.user = options.bytes === String ? $util.base64.encode(message.user, 0, message.user.length) : options.bytes === Array ? Array.prototype.slice.call(message.user) : message.user; - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (typeof message.timestamp === "number") - object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp; - else - object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber() : message.timestamp; - return object; - }; - - /** - * Converts this FindDeployInBlockQuery to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.FindDeployInBlockQuery - * @instance - * @returns {Object.} JSON object - */ - FindDeployInBlockQuery.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return FindDeployInBlockQuery; - })(); - - protocol.BlockQuery = (function() { - - /** - * Properties of a BlockQuery. - * @memberof coop.rchain.casper.protocol - * @interface IBlockQuery - * @property {string|null} [hash] BlockQuery hash - */ - - /** - * Constructs a new BlockQuery. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a BlockQuery. - * @implements IBlockQuery - * @constructor - * @param {coop.rchain.casper.protocol.IBlockQuery=} [properties] Properties to set - */ - function BlockQuery(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BlockQuery hash. - * @member {string} hash - * @memberof coop.rchain.casper.protocol.BlockQuery - * @instance - */ - BlockQuery.prototype.hash = ""; - - /** - * Creates a new BlockQuery instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.BlockQuery - * @static - * @param {coop.rchain.casper.protocol.IBlockQuery=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.BlockQuery} BlockQuery instance - */ - BlockQuery.create = function create(properties) { - return new BlockQuery(properties); - }; - - /** - * Encodes the specified BlockQuery message. Does not implicitly {@link coop.rchain.casper.protocol.BlockQuery.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.BlockQuery - * @static - * @param {coop.rchain.casper.protocol.IBlockQuery} message BlockQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockQuery.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.hash != null && message.hasOwnProperty("hash")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.hash); - return writer; - }; - - /** - * Encodes the specified BlockQuery message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.BlockQuery.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.BlockQuery - * @static - * @param {coop.rchain.casper.protocol.IBlockQuery} message BlockQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockQuery.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a BlockQuery message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.BlockQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.BlockQuery} BlockQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockQuery.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.BlockQuery(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.hash = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a BlockQuery message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.BlockQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.BlockQuery} BlockQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockQuery.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a BlockQuery message. - * @function verify - * @memberof coop.rchain.casper.protocol.BlockQuery - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - BlockQuery.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.hash != null && message.hasOwnProperty("hash")) - if (!$util.isString(message.hash)) - return "hash: string expected"; - return null; - }; - - /** - * Creates a BlockQuery message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.BlockQuery - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.BlockQuery} BlockQuery - */ - BlockQuery.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.BlockQuery) - return object; - var message = new $root.coop.rchain.casper.protocol.BlockQuery(); - if (object.hash != null) - message.hash = String(object.hash); - return message; - }; - - /** - * Creates a plain object from a BlockQuery message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.BlockQuery - * @static - * @param {coop.rchain.casper.protocol.BlockQuery} message BlockQuery - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - BlockQuery.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.hash = ""; - if (message.hash != null && message.hasOwnProperty("hash")) - object.hash = message.hash; - return object; - }; - - /** - * Converts this BlockQuery to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.BlockQuery - * @instance - * @returns {Object.} JSON object - */ - BlockQuery.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return BlockQuery; - })(); - - protocol.BlocksQuery = (function() { - - /** - * Properties of a BlocksQuery. - * @memberof coop.rchain.casper.protocol - * @interface IBlocksQuery - * @property {number|null} [depth] BlocksQuery depth - */ - - /** - * Constructs a new BlocksQuery. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a BlocksQuery. - * @implements IBlocksQuery - * @constructor - * @param {coop.rchain.casper.protocol.IBlocksQuery=} [properties] Properties to set - */ - function BlocksQuery(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BlocksQuery depth. - * @member {number} depth - * @memberof coop.rchain.casper.protocol.BlocksQuery - * @instance - */ - BlocksQuery.prototype.depth = 0; - - /** - * Creates a new BlocksQuery instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.BlocksQuery - * @static - * @param {coop.rchain.casper.protocol.IBlocksQuery=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.BlocksQuery} BlocksQuery instance - */ - BlocksQuery.create = function create(properties) { - return new BlocksQuery(properties); - }; - - /** - * Encodes the specified BlocksQuery message. Does not implicitly {@link coop.rchain.casper.protocol.BlocksQuery.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.BlocksQuery - * @static - * @param {coop.rchain.casper.protocol.IBlocksQuery} message BlocksQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlocksQuery.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.depth != null && message.hasOwnProperty("depth")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.depth); - return writer; - }; - - /** - * Encodes the specified BlocksQuery message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.BlocksQuery.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.BlocksQuery - * @static - * @param {coop.rchain.casper.protocol.IBlocksQuery} message BlocksQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlocksQuery.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a BlocksQuery message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.BlocksQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.BlocksQuery} BlocksQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlocksQuery.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.BlocksQuery(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.depth = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a BlocksQuery message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.BlocksQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.BlocksQuery} BlocksQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlocksQuery.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a BlocksQuery message. - * @function verify - * @memberof coop.rchain.casper.protocol.BlocksQuery - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - BlocksQuery.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.depth != null && message.hasOwnProperty("depth")) - if (!$util.isInteger(message.depth)) - return "depth: integer expected"; - return null; - }; - - /** - * Creates a BlocksQuery message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.BlocksQuery - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.BlocksQuery} BlocksQuery - */ - BlocksQuery.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.BlocksQuery) - return object; - var message = new $root.coop.rchain.casper.protocol.BlocksQuery(); - if (object.depth != null) - message.depth = object.depth | 0; - return message; - }; - - /** - * Creates a plain object from a BlocksQuery message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.BlocksQuery - * @static - * @param {coop.rchain.casper.protocol.BlocksQuery} message BlocksQuery - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - BlocksQuery.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.depth = 0; - if (message.depth != null && message.hasOwnProperty("depth")) - object.depth = message.depth; - return object; - }; - - /** - * Converts this BlocksQuery to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.BlocksQuery - * @instance - * @returns {Object.} JSON object - */ - BlocksQuery.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return BlocksQuery; - })(); - - protocol.DataAtNameQuery = (function() { - - /** - * Properties of a DataAtNameQuery. - * @memberof coop.rchain.casper.protocol - * @interface IDataAtNameQuery - * @property {number|null} [depth] DataAtNameQuery depth - * @property {IPar|null} [name] DataAtNameQuery name - */ - - /** - * Constructs a new DataAtNameQuery. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a DataAtNameQuery. - * @implements IDataAtNameQuery - * @constructor - * @param {coop.rchain.casper.protocol.IDataAtNameQuery=} [properties] Properties to set - */ - function DataAtNameQuery(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DataAtNameQuery depth. - * @member {number} depth - * @memberof coop.rchain.casper.protocol.DataAtNameQuery - * @instance - */ - DataAtNameQuery.prototype.depth = 0; - - /** - * DataAtNameQuery name. - * @member {IPar|null|undefined} name - * @memberof coop.rchain.casper.protocol.DataAtNameQuery - * @instance - */ - DataAtNameQuery.prototype.name = null; - - /** - * Creates a new DataAtNameQuery instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.DataAtNameQuery - * @static - * @param {coop.rchain.casper.protocol.IDataAtNameQuery=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.DataAtNameQuery} DataAtNameQuery instance - */ - DataAtNameQuery.create = function create(properties) { - return new DataAtNameQuery(properties); - }; - - /** - * Encodes the specified DataAtNameQuery message. Does not implicitly {@link coop.rchain.casper.protocol.DataAtNameQuery.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.DataAtNameQuery - * @static - * @param {coop.rchain.casper.protocol.IDataAtNameQuery} message DataAtNameQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DataAtNameQuery.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.depth != null && message.hasOwnProperty("depth")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.depth); - if (message.name != null && message.hasOwnProperty("name")) - $root.Par.encode(message.name, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified DataAtNameQuery message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.DataAtNameQuery.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.DataAtNameQuery - * @static - * @param {coop.rchain.casper.protocol.IDataAtNameQuery} message DataAtNameQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DataAtNameQuery.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a DataAtNameQuery message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.DataAtNameQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.DataAtNameQuery} DataAtNameQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DataAtNameQuery.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.DataAtNameQuery(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.depth = reader.int32(); - break; - case 2: - message.name = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a DataAtNameQuery message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.DataAtNameQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.DataAtNameQuery} DataAtNameQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DataAtNameQuery.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a DataAtNameQuery message. - * @function verify - * @memberof coop.rchain.casper.protocol.DataAtNameQuery - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - DataAtNameQuery.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.depth != null && message.hasOwnProperty("depth")) - if (!$util.isInteger(message.depth)) - return "depth: integer expected"; - if (message.name != null && message.hasOwnProperty("name")) { - var error = $root.Par.verify(message.name); - if (error) - return "name." + error; - } - return null; - }; - - /** - * Creates a DataAtNameQuery message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.DataAtNameQuery - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.DataAtNameQuery} DataAtNameQuery - */ - DataAtNameQuery.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.DataAtNameQuery) - return object; - var message = new $root.coop.rchain.casper.protocol.DataAtNameQuery(); - if (object.depth != null) - message.depth = object.depth | 0; - if (object.name != null) { - if (typeof object.name !== "object") - throw TypeError(".coop.rchain.casper.protocol.DataAtNameQuery.name: object expected"); - message.name = $root.Par.fromObject(object.name); - } - return message; - }; - - /** - * Creates a plain object from a DataAtNameQuery message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.DataAtNameQuery - * @static - * @param {coop.rchain.casper.protocol.DataAtNameQuery} message DataAtNameQuery - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - DataAtNameQuery.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.depth = 0; - object.name = null; - } - if (message.depth != null && message.hasOwnProperty("depth")) - object.depth = message.depth; - if (message.name != null && message.hasOwnProperty("name")) - object.name = $root.Par.toObject(message.name, options); - return object; - }; - - /** - * Converts this DataAtNameQuery to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.DataAtNameQuery - * @instance - * @returns {Object.} JSON object - */ - DataAtNameQuery.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return DataAtNameQuery; - })(); - - protocol.ContinuationAtNameQuery = (function() { - - /** - * Properties of a ContinuationAtNameQuery. - * @memberof coop.rchain.casper.protocol - * @interface IContinuationAtNameQuery - * @property {number|null} [depth] ContinuationAtNameQuery depth - * @property {Array.|null} [names] ContinuationAtNameQuery names - */ - - /** - * Constructs a new ContinuationAtNameQuery. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a ContinuationAtNameQuery. - * @implements IContinuationAtNameQuery - * @constructor - * @param {coop.rchain.casper.protocol.IContinuationAtNameQuery=} [properties] Properties to set - */ - function ContinuationAtNameQuery(properties) { - this.names = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ContinuationAtNameQuery depth. - * @member {number} depth - * @memberof coop.rchain.casper.protocol.ContinuationAtNameQuery - * @instance - */ - ContinuationAtNameQuery.prototype.depth = 0; - - /** - * ContinuationAtNameQuery names. - * @member {Array.} names - * @memberof coop.rchain.casper.protocol.ContinuationAtNameQuery - * @instance - */ - ContinuationAtNameQuery.prototype.names = $util.emptyArray; - - /** - * Creates a new ContinuationAtNameQuery instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.ContinuationAtNameQuery - * @static - * @param {coop.rchain.casper.protocol.IContinuationAtNameQuery=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.ContinuationAtNameQuery} ContinuationAtNameQuery instance - */ - ContinuationAtNameQuery.create = function create(properties) { - return new ContinuationAtNameQuery(properties); - }; - - /** - * Encodes the specified ContinuationAtNameQuery message. Does not implicitly {@link coop.rchain.casper.protocol.ContinuationAtNameQuery.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.ContinuationAtNameQuery - * @static - * @param {coop.rchain.casper.protocol.IContinuationAtNameQuery} message ContinuationAtNameQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ContinuationAtNameQuery.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.depth != null && message.hasOwnProperty("depth")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.depth); - if (message.names != null && message.names.length) - for (var i = 0; i < message.names.length; ++i) - $root.Par.encode(message.names[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified ContinuationAtNameQuery message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.ContinuationAtNameQuery.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.ContinuationAtNameQuery - * @static - * @param {coop.rchain.casper.protocol.IContinuationAtNameQuery} message ContinuationAtNameQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ContinuationAtNameQuery.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ContinuationAtNameQuery message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.ContinuationAtNameQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.ContinuationAtNameQuery} ContinuationAtNameQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ContinuationAtNameQuery.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.ContinuationAtNameQuery(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.depth = reader.int32(); - break; - case 2: - if (!(message.names && message.names.length)) - message.names = []; - message.names.push($root.Par.decode(reader, reader.uint32())); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ContinuationAtNameQuery message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.ContinuationAtNameQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.ContinuationAtNameQuery} ContinuationAtNameQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ContinuationAtNameQuery.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ContinuationAtNameQuery message. - * @function verify - * @memberof coop.rchain.casper.protocol.ContinuationAtNameQuery - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ContinuationAtNameQuery.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.depth != null && message.hasOwnProperty("depth")) - if (!$util.isInteger(message.depth)) - return "depth: integer expected"; - if (message.names != null && message.hasOwnProperty("names")) { - if (!Array.isArray(message.names)) - return "names: array expected"; - for (var i = 0; i < message.names.length; ++i) { - var error = $root.Par.verify(message.names[i]); - if (error) - return "names." + error; - } - } - return null; - }; - - /** - * Creates a ContinuationAtNameQuery message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.ContinuationAtNameQuery - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.ContinuationAtNameQuery} ContinuationAtNameQuery - */ - ContinuationAtNameQuery.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.ContinuationAtNameQuery) - return object; - var message = new $root.coop.rchain.casper.protocol.ContinuationAtNameQuery(); - if (object.depth != null) - message.depth = object.depth | 0; - if (object.names) { - if (!Array.isArray(object.names)) - throw TypeError(".coop.rchain.casper.protocol.ContinuationAtNameQuery.names: array expected"); - message.names = []; - for (var i = 0; i < object.names.length; ++i) { - if (typeof object.names[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.ContinuationAtNameQuery.names: object expected"); - message.names[i] = $root.Par.fromObject(object.names[i]); - } - } - return message; - }; - - /** - * Creates a plain object from a ContinuationAtNameQuery message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.ContinuationAtNameQuery - * @static - * @param {coop.rchain.casper.protocol.ContinuationAtNameQuery} message ContinuationAtNameQuery - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ContinuationAtNameQuery.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.names = []; - if (options.defaults) - object.depth = 0; - if (message.depth != null && message.hasOwnProperty("depth")) - object.depth = message.depth; - if (message.names && message.names.length) { - object.names = []; - for (var j = 0; j < message.names.length; ++j) - object.names[j] = $root.Par.toObject(message.names[j], options); - } - return object; - }; - - /** - * Converts this ContinuationAtNameQuery to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.ContinuationAtNameQuery - * @instance - * @returns {Object.} JSON object - */ - ContinuationAtNameQuery.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ContinuationAtNameQuery; - })(); - - protocol.DeployServiceResponse = (function() { - - /** - * Properties of a DeployServiceResponse. - * @memberof coop.rchain.casper.protocol - * @interface IDeployServiceResponse - * @property {string|null} [message] DeployServiceResponse message - */ - - /** - * Constructs a new DeployServiceResponse. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a DeployServiceResponse. - * @implements IDeployServiceResponse - * @constructor - * @param {coop.rchain.casper.protocol.IDeployServiceResponse=} [properties] Properties to set - */ - function DeployServiceResponse(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DeployServiceResponse message. - * @member {string} message - * @memberof coop.rchain.casper.protocol.DeployServiceResponse - * @instance - */ - DeployServiceResponse.prototype.message = ""; - - /** - * Creates a new DeployServiceResponse instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.DeployServiceResponse - * @static - * @param {coop.rchain.casper.protocol.IDeployServiceResponse=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.DeployServiceResponse} DeployServiceResponse instance - */ - DeployServiceResponse.create = function create(properties) { - return new DeployServiceResponse(properties); - }; - - /** - * Encodes the specified DeployServiceResponse message. Does not implicitly {@link coop.rchain.casper.protocol.DeployServiceResponse.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.DeployServiceResponse - * @static - * @param {coop.rchain.casper.protocol.IDeployServiceResponse} message DeployServiceResponse message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DeployServiceResponse.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.message != null && message.hasOwnProperty("message")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.message); - return writer; - }; - - /** - * Encodes the specified DeployServiceResponse message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.DeployServiceResponse.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.DeployServiceResponse - * @static - * @param {coop.rchain.casper.protocol.IDeployServiceResponse} message DeployServiceResponse message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DeployServiceResponse.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a DeployServiceResponse message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.DeployServiceResponse - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.DeployServiceResponse} DeployServiceResponse - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DeployServiceResponse.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.DeployServiceResponse(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.message = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a DeployServiceResponse message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.DeployServiceResponse - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.DeployServiceResponse} DeployServiceResponse - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DeployServiceResponse.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a DeployServiceResponse message. - * @function verify - * @memberof coop.rchain.casper.protocol.DeployServiceResponse - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - DeployServiceResponse.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.message != null && message.hasOwnProperty("message")) - if (!$util.isString(message.message)) - return "message: string expected"; - return null; - }; - - /** - * Creates a DeployServiceResponse message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.DeployServiceResponse - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.DeployServiceResponse} DeployServiceResponse - */ - DeployServiceResponse.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.DeployServiceResponse) - return object; - var message = new $root.coop.rchain.casper.protocol.DeployServiceResponse(); - if (object.message != null) - message.message = String(object.message); - return message; - }; - - /** - * Creates a plain object from a DeployServiceResponse message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.DeployServiceResponse - * @static - * @param {coop.rchain.casper.protocol.DeployServiceResponse} message DeployServiceResponse - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - DeployServiceResponse.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.message = ""; - if (message.message != null && message.hasOwnProperty("message")) - object.message = message.message; - return object; - }; - - /** - * Converts this DeployServiceResponse to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.DeployServiceResponse - * @instance - * @returns {Object.} JSON object - */ - DeployServiceResponse.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return DeployServiceResponse; - })(); - - protocol.MaybeBlockMessage = (function() { - - /** - * Properties of a MaybeBlockMessage. - * @memberof coop.rchain.casper.protocol - * @interface IMaybeBlockMessage - * @property {coop.rchain.casper.protocol.IBlockMessage|null} [block] MaybeBlockMessage block - */ - - /** - * Constructs a new MaybeBlockMessage. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a MaybeBlockMessage. - * @implements IMaybeBlockMessage - * @constructor - * @param {coop.rchain.casper.protocol.IMaybeBlockMessage=} [properties] Properties to set - */ - function MaybeBlockMessage(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * MaybeBlockMessage block. - * @member {coop.rchain.casper.protocol.IBlockMessage|null|undefined} block - * @memberof coop.rchain.casper.protocol.MaybeBlockMessage - * @instance - */ - MaybeBlockMessage.prototype.block = null; - - /** - * Creates a new MaybeBlockMessage instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.MaybeBlockMessage - * @static - * @param {coop.rchain.casper.protocol.IMaybeBlockMessage=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.MaybeBlockMessage} MaybeBlockMessage instance - */ - MaybeBlockMessage.create = function create(properties) { - return new MaybeBlockMessage(properties); - }; - - /** - * Encodes the specified MaybeBlockMessage message. Does not implicitly {@link coop.rchain.casper.protocol.MaybeBlockMessage.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.MaybeBlockMessage - * @static - * @param {coop.rchain.casper.protocol.IMaybeBlockMessage} message MaybeBlockMessage message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - MaybeBlockMessage.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.block != null && message.hasOwnProperty("block")) - $root.coop.rchain.casper.protocol.BlockMessage.encode(message.block, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified MaybeBlockMessage message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.MaybeBlockMessage.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.MaybeBlockMessage - * @static - * @param {coop.rchain.casper.protocol.IMaybeBlockMessage} message MaybeBlockMessage message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - MaybeBlockMessage.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a MaybeBlockMessage message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.MaybeBlockMessage - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.MaybeBlockMessage} MaybeBlockMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - MaybeBlockMessage.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.MaybeBlockMessage(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.block = $root.coop.rchain.casper.protocol.BlockMessage.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a MaybeBlockMessage message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.MaybeBlockMessage - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.MaybeBlockMessage} MaybeBlockMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - MaybeBlockMessage.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a MaybeBlockMessage message. - * @function verify - * @memberof coop.rchain.casper.protocol.MaybeBlockMessage - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - MaybeBlockMessage.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.block != null && message.hasOwnProperty("block")) { - var error = $root.coop.rchain.casper.protocol.BlockMessage.verify(message.block); - if (error) - return "block." + error; - } - return null; - }; - - /** - * Creates a MaybeBlockMessage message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.MaybeBlockMessage - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.MaybeBlockMessage} MaybeBlockMessage - */ - MaybeBlockMessage.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.MaybeBlockMessage) - return object; - var message = new $root.coop.rchain.casper.protocol.MaybeBlockMessage(); - if (object.block != null) { - if (typeof object.block !== "object") - throw TypeError(".coop.rchain.casper.protocol.MaybeBlockMessage.block: object expected"); - message.block = $root.coop.rchain.casper.protocol.BlockMessage.fromObject(object.block); - } - return message; - }; - - /** - * Creates a plain object from a MaybeBlockMessage message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.MaybeBlockMessage - * @static - * @param {coop.rchain.casper.protocol.MaybeBlockMessage} message MaybeBlockMessage - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - MaybeBlockMessage.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.block = null; - if (message.block != null && message.hasOwnProperty("block")) - object.block = $root.coop.rchain.casper.protocol.BlockMessage.toObject(message.block, options); - return object; - }; - - /** - * Converts this MaybeBlockMessage to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.MaybeBlockMessage - * @instance - * @returns {Object.} JSON object - */ - MaybeBlockMessage.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return MaybeBlockMessage; - })(); - - protocol.BlockQueryResponse = (function() { - - /** - * Properties of a BlockQueryResponse. - * @memberof coop.rchain.casper.protocol - * @interface IBlockQueryResponse - * @property {coop.rchain.casper.protocol.IBlockInfo|null} [blockInfo] BlockQueryResponse blockInfo - */ - - /** - * Constructs a new BlockQueryResponse. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a BlockQueryResponse. - * @implements IBlockQueryResponse - * @constructor - * @param {coop.rchain.casper.protocol.IBlockQueryResponse=} [properties] Properties to set - */ - function BlockQueryResponse(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BlockQueryResponse blockInfo. - * @member {coop.rchain.casper.protocol.IBlockInfo|null|undefined} blockInfo - * @memberof coop.rchain.casper.protocol.BlockQueryResponse - * @instance - */ - BlockQueryResponse.prototype.blockInfo = null; - - /** - * Creates a new BlockQueryResponse instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.BlockQueryResponse - * @static - * @param {coop.rchain.casper.protocol.IBlockQueryResponse=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.BlockQueryResponse} BlockQueryResponse instance - */ - BlockQueryResponse.create = function create(properties) { - return new BlockQueryResponse(properties); - }; - - /** - * Encodes the specified BlockQueryResponse message. Does not implicitly {@link coop.rchain.casper.protocol.BlockQueryResponse.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.BlockQueryResponse - * @static - * @param {coop.rchain.casper.protocol.IBlockQueryResponse} message BlockQueryResponse message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockQueryResponse.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.blockInfo != null && message.hasOwnProperty("blockInfo")) - $root.coop.rchain.casper.protocol.BlockInfo.encode(message.blockInfo, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified BlockQueryResponse message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.BlockQueryResponse.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.BlockQueryResponse - * @static - * @param {coop.rchain.casper.protocol.IBlockQueryResponse} message BlockQueryResponse message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockQueryResponse.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a BlockQueryResponse message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.BlockQueryResponse - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.BlockQueryResponse} BlockQueryResponse - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockQueryResponse.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.BlockQueryResponse(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.blockInfo = $root.coop.rchain.casper.protocol.BlockInfo.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a BlockQueryResponse message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.BlockQueryResponse - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.BlockQueryResponse} BlockQueryResponse - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockQueryResponse.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a BlockQueryResponse message. - * @function verify - * @memberof coop.rchain.casper.protocol.BlockQueryResponse - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - BlockQueryResponse.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.blockInfo != null && message.hasOwnProperty("blockInfo")) { - var error = $root.coop.rchain.casper.protocol.BlockInfo.verify(message.blockInfo); - if (error) - return "blockInfo." + error; - } - return null; - }; - - /** - * Creates a BlockQueryResponse message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.BlockQueryResponse - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.BlockQueryResponse} BlockQueryResponse - */ - BlockQueryResponse.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.BlockQueryResponse) - return object; - var message = new $root.coop.rchain.casper.protocol.BlockQueryResponse(); - if (object.blockInfo != null) { - if (typeof object.blockInfo !== "object") - throw TypeError(".coop.rchain.casper.protocol.BlockQueryResponse.blockInfo: object expected"); - message.blockInfo = $root.coop.rchain.casper.protocol.BlockInfo.fromObject(object.blockInfo); - } - return message; - }; - - /** - * Creates a plain object from a BlockQueryResponse message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.BlockQueryResponse - * @static - * @param {coop.rchain.casper.protocol.BlockQueryResponse} message BlockQueryResponse - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - BlockQueryResponse.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.blockInfo = null; - if (message.blockInfo != null && message.hasOwnProperty("blockInfo")) - object.blockInfo = $root.coop.rchain.casper.protocol.BlockInfo.toObject(message.blockInfo, options); - return object; - }; - - /** - * Converts this BlockQueryResponse to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.BlockQueryResponse - * @instance - * @returns {Object.} JSON object - */ - BlockQueryResponse.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return BlockQueryResponse; - })(); - - protocol.VisualizeDagQuery = (function() { - - /** - * Properties of a VisualizeDagQuery. - * @memberof coop.rchain.casper.protocol - * @interface IVisualizeDagQuery - * @property {number|null} [depth] VisualizeDagQuery depth - * @property {boolean|null} [showJustificationLines] VisualizeDagQuery showJustificationLines - */ - - /** - * Constructs a new VisualizeDagQuery. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a VisualizeDagQuery. - * @implements IVisualizeDagQuery - * @constructor - * @param {coop.rchain.casper.protocol.IVisualizeDagQuery=} [properties] Properties to set - */ - function VisualizeDagQuery(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * VisualizeDagQuery depth. - * @member {number} depth - * @memberof coop.rchain.casper.protocol.VisualizeDagQuery - * @instance - */ - VisualizeDagQuery.prototype.depth = 0; - - /** - * VisualizeDagQuery showJustificationLines. - * @member {boolean} showJustificationLines - * @memberof coop.rchain.casper.protocol.VisualizeDagQuery - * @instance - */ - VisualizeDagQuery.prototype.showJustificationLines = false; - - /** - * Creates a new VisualizeDagQuery instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.VisualizeDagQuery - * @static - * @param {coop.rchain.casper.protocol.IVisualizeDagQuery=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.VisualizeDagQuery} VisualizeDagQuery instance - */ - VisualizeDagQuery.create = function create(properties) { - return new VisualizeDagQuery(properties); - }; - - /** - * Encodes the specified VisualizeDagQuery message. Does not implicitly {@link coop.rchain.casper.protocol.VisualizeDagQuery.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.VisualizeDagQuery - * @static - * @param {coop.rchain.casper.protocol.IVisualizeDagQuery} message VisualizeDagQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - VisualizeDagQuery.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.depth != null && message.hasOwnProperty("depth")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.depth); - if (message.showJustificationLines != null && message.hasOwnProperty("showJustificationLines")) - writer.uint32(/* id 2, wireType 0 =*/16).bool(message.showJustificationLines); - return writer; - }; - - /** - * Encodes the specified VisualizeDagQuery message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.VisualizeDagQuery.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.VisualizeDagQuery - * @static - * @param {coop.rchain.casper.protocol.IVisualizeDagQuery} message VisualizeDagQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - VisualizeDagQuery.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a VisualizeDagQuery message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.VisualizeDagQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.VisualizeDagQuery} VisualizeDagQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - VisualizeDagQuery.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.VisualizeDagQuery(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.depth = reader.int32(); - break; - case 2: - message.showJustificationLines = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a VisualizeDagQuery message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.VisualizeDagQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.VisualizeDagQuery} VisualizeDagQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - VisualizeDagQuery.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a VisualizeDagQuery message. - * @function verify - * @memberof coop.rchain.casper.protocol.VisualizeDagQuery - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - VisualizeDagQuery.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.depth != null && message.hasOwnProperty("depth")) - if (!$util.isInteger(message.depth)) - return "depth: integer expected"; - if (message.showJustificationLines != null && message.hasOwnProperty("showJustificationLines")) - if (typeof message.showJustificationLines !== "boolean") - return "showJustificationLines: boolean expected"; - return null; - }; - - /** - * Creates a VisualizeDagQuery message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.VisualizeDagQuery - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.VisualizeDagQuery} VisualizeDagQuery - */ - VisualizeDagQuery.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.VisualizeDagQuery) - return object; - var message = new $root.coop.rchain.casper.protocol.VisualizeDagQuery(); - if (object.depth != null) - message.depth = object.depth | 0; - if (object.showJustificationLines != null) - message.showJustificationLines = Boolean(object.showJustificationLines); - return message; - }; - - /** - * Creates a plain object from a VisualizeDagQuery message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.VisualizeDagQuery - * @static - * @param {coop.rchain.casper.protocol.VisualizeDagQuery} message VisualizeDagQuery - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - VisualizeDagQuery.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.depth = 0; - object.showJustificationLines = false; - } - if (message.depth != null && message.hasOwnProperty("depth")) - object.depth = message.depth; - if (message.showJustificationLines != null && message.hasOwnProperty("showJustificationLines")) - object.showJustificationLines = message.showJustificationLines; - return object; - }; - - /** - * Converts this VisualizeDagQuery to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.VisualizeDagQuery - * @instance - * @returns {Object.} JSON object - */ - VisualizeDagQuery.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return VisualizeDagQuery; - })(); - - protocol.VisualizeBlocksResponse = (function() { - - /** - * Properties of a VisualizeBlocksResponse. - * @memberof coop.rchain.casper.protocol - * @interface IVisualizeBlocksResponse - * @property {string|null} [content] VisualizeBlocksResponse content - */ - - /** - * Constructs a new VisualizeBlocksResponse. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a VisualizeBlocksResponse. - * @implements IVisualizeBlocksResponse - * @constructor - * @param {coop.rchain.casper.protocol.IVisualizeBlocksResponse=} [properties] Properties to set - */ - function VisualizeBlocksResponse(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * VisualizeBlocksResponse content. - * @member {string} content - * @memberof coop.rchain.casper.protocol.VisualizeBlocksResponse - * @instance - */ - VisualizeBlocksResponse.prototype.content = ""; - - /** - * Creates a new VisualizeBlocksResponse instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.VisualizeBlocksResponse - * @static - * @param {coop.rchain.casper.protocol.IVisualizeBlocksResponse=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.VisualizeBlocksResponse} VisualizeBlocksResponse instance - */ - VisualizeBlocksResponse.create = function create(properties) { - return new VisualizeBlocksResponse(properties); - }; - - /** - * Encodes the specified VisualizeBlocksResponse message. Does not implicitly {@link coop.rchain.casper.protocol.VisualizeBlocksResponse.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.VisualizeBlocksResponse - * @static - * @param {coop.rchain.casper.protocol.IVisualizeBlocksResponse} message VisualizeBlocksResponse message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - VisualizeBlocksResponse.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.content != null && message.hasOwnProperty("content")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.content); - return writer; - }; - - /** - * Encodes the specified VisualizeBlocksResponse message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.VisualizeBlocksResponse.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.VisualizeBlocksResponse - * @static - * @param {coop.rchain.casper.protocol.IVisualizeBlocksResponse} message VisualizeBlocksResponse message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - VisualizeBlocksResponse.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a VisualizeBlocksResponse message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.VisualizeBlocksResponse - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.VisualizeBlocksResponse} VisualizeBlocksResponse - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - VisualizeBlocksResponse.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.VisualizeBlocksResponse(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.content = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a VisualizeBlocksResponse message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.VisualizeBlocksResponse - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.VisualizeBlocksResponse} VisualizeBlocksResponse - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - VisualizeBlocksResponse.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a VisualizeBlocksResponse message. - * @function verify - * @memberof coop.rchain.casper.protocol.VisualizeBlocksResponse - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - VisualizeBlocksResponse.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.content != null && message.hasOwnProperty("content")) - if (!$util.isString(message.content)) - return "content: string expected"; - return null; - }; - - /** - * Creates a VisualizeBlocksResponse message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.VisualizeBlocksResponse - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.VisualizeBlocksResponse} VisualizeBlocksResponse - */ - VisualizeBlocksResponse.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.VisualizeBlocksResponse) - return object; - var message = new $root.coop.rchain.casper.protocol.VisualizeBlocksResponse(); - if (object.content != null) - message.content = String(object.content); - return message; - }; - - /** - * Creates a plain object from a VisualizeBlocksResponse message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.VisualizeBlocksResponse - * @static - * @param {coop.rchain.casper.protocol.VisualizeBlocksResponse} message VisualizeBlocksResponse - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - VisualizeBlocksResponse.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.content = ""; - if (message.content != null && message.hasOwnProperty("content")) - object.content = message.content; - return object; - }; - - /** - * Converts this VisualizeBlocksResponse to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.VisualizeBlocksResponse - * @instance - * @returns {Object.} JSON object - */ - VisualizeBlocksResponse.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return VisualizeBlocksResponse; - })(); - - protocol.ListeningNameDataResponse = (function() { - - /** - * Properties of a ListeningNameDataResponse. - * @memberof coop.rchain.casper.protocol - * @interface IListeningNameDataResponse - * @property {Array.|null} [blockResults] ListeningNameDataResponse blockResults - * @property {number|null} [length] ListeningNameDataResponse length - */ - - /** - * Constructs a new ListeningNameDataResponse. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a ListeningNameDataResponse. - * @implements IListeningNameDataResponse - * @constructor - * @param {coop.rchain.casper.protocol.IListeningNameDataResponse=} [properties] Properties to set - */ - function ListeningNameDataResponse(properties) { - this.blockResults = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListeningNameDataResponse blockResults. - * @member {Array.} blockResults - * @memberof coop.rchain.casper.protocol.ListeningNameDataResponse - * @instance - */ - ListeningNameDataResponse.prototype.blockResults = $util.emptyArray; - - /** - * ListeningNameDataResponse length. - * @member {number} length - * @memberof coop.rchain.casper.protocol.ListeningNameDataResponse - * @instance - */ - ListeningNameDataResponse.prototype.length = 0; - - /** - * Creates a new ListeningNameDataResponse instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.ListeningNameDataResponse - * @static - * @param {coop.rchain.casper.protocol.IListeningNameDataResponse=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.ListeningNameDataResponse} ListeningNameDataResponse instance - */ - ListeningNameDataResponse.create = function create(properties) { - return new ListeningNameDataResponse(properties); - }; - - /** - * Encodes the specified ListeningNameDataResponse message. Does not implicitly {@link coop.rchain.casper.protocol.ListeningNameDataResponse.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.ListeningNameDataResponse - * @static - * @param {coop.rchain.casper.protocol.IListeningNameDataResponse} message ListeningNameDataResponse message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ListeningNameDataResponse.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.blockResults != null && message.blockResults.length) - for (var i = 0; i < message.blockResults.length; ++i) - $root.coop.rchain.casper.protocol.DataWithBlockInfo.encode(message.blockResults[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.length != null && message.hasOwnProperty("length")) - writer.uint32(/* id 2, wireType 0 =*/16).int32(message.length); - return writer; - }; - - /** - * Encodes the specified ListeningNameDataResponse message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.ListeningNameDataResponse.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.ListeningNameDataResponse - * @static - * @param {coop.rchain.casper.protocol.IListeningNameDataResponse} message ListeningNameDataResponse message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ListeningNameDataResponse.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ListeningNameDataResponse message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.ListeningNameDataResponse - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.ListeningNameDataResponse} ListeningNameDataResponse - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ListeningNameDataResponse.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.ListeningNameDataResponse(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.blockResults && message.blockResults.length)) - message.blockResults = []; - message.blockResults.push($root.coop.rchain.casper.protocol.DataWithBlockInfo.decode(reader, reader.uint32())); - break; - case 2: - message.length = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ListeningNameDataResponse message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.ListeningNameDataResponse - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.ListeningNameDataResponse} ListeningNameDataResponse - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ListeningNameDataResponse.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ListeningNameDataResponse message. - * @function verify - * @memberof coop.rchain.casper.protocol.ListeningNameDataResponse - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ListeningNameDataResponse.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.blockResults != null && message.hasOwnProperty("blockResults")) { - if (!Array.isArray(message.blockResults)) - return "blockResults: array expected"; - for (var i = 0; i < message.blockResults.length; ++i) { - var error = $root.coop.rchain.casper.protocol.DataWithBlockInfo.verify(message.blockResults[i]); - if (error) - return "blockResults." + error; - } - } - if (message.length != null && message.hasOwnProperty("length")) - if (!$util.isInteger(message.length)) - return "length: integer expected"; - return null; - }; - - /** - * Creates a ListeningNameDataResponse message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.ListeningNameDataResponse - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.ListeningNameDataResponse} ListeningNameDataResponse - */ - ListeningNameDataResponse.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.ListeningNameDataResponse) - return object; - var message = new $root.coop.rchain.casper.protocol.ListeningNameDataResponse(); - if (object.blockResults) { - if (!Array.isArray(object.blockResults)) - throw TypeError(".coop.rchain.casper.protocol.ListeningNameDataResponse.blockResults: array expected"); - message.blockResults = []; - for (var i = 0; i < object.blockResults.length; ++i) { - if (typeof object.blockResults[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.ListeningNameDataResponse.blockResults: object expected"); - message.blockResults[i] = $root.coop.rchain.casper.protocol.DataWithBlockInfo.fromObject(object.blockResults[i]); - } - } - if (object.length != null) - message.length = object.length | 0; - return message; - }; - - /** - * Creates a plain object from a ListeningNameDataResponse message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.ListeningNameDataResponse - * @static - * @param {coop.rchain.casper.protocol.ListeningNameDataResponse} message ListeningNameDataResponse - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ListeningNameDataResponse.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.blockResults = []; - if (options.defaults) - object.length = 0; - if (message.blockResults && message.blockResults.length) { - object.blockResults = []; - for (var j = 0; j < message.blockResults.length; ++j) - object.blockResults[j] = $root.coop.rchain.casper.protocol.DataWithBlockInfo.toObject(message.blockResults[j], options); - } - if (message.length != null && message.hasOwnProperty("length")) - object.length = message.length; - return object; - }; - - /** - * Converts this ListeningNameDataResponse to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.ListeningNameDataResponse - * @instance - * @returns {Object.} JSON object - */ - ListeningNameDataResponse.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ListeningNameDataResponse; - })(); - - protocol.ListeningNameContinuationResponse = (function() { - - /** - * Properties of a ListeningNameContinuationResponse. - * @memberof coop.rchain.casper.protocol - * @interface IListeningNameContinuationResponse - * @property {Array.|null} [blockResults] ListeningNameContinuationResponse blockResults - * @property {number|null} [length] ListeningNameContinuationResponse length - */ - - /** - * Constructs a new ListeningNameContinuationResponse. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a ListeningNameContinuationResponse. - * @implements IListeningNameContinuationResponse - * @constructor - * @param {coop.rchain.casper.protocol.IListeningNameContinuationResponse=} [properties] Properties to set - */ - function ListeningNameContinuationResponse(properties) { - this.blockResults = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListeningNameContinuationResponse blockResults. - * @member {Array.} blockResults - * @memberof coop.rchain.casper.protocol.ListeningNameContinuationResponse - * @instance - */ - ListeningNameContinuationResponse.prototype.blockResults = $util.emptyArray; - - /** - * ListeningNameContinuationResponse length. - * @member {number} length - * @memberof coop.rchain.casper.protocol.ListeningNameContinuationResponse - * @instance - */ - ListeningNameContinuationResponse.prototype.length = 0; - - /** - * Creates a new ListeningNameContinuationResponse instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.ListeningNameContinuationResponse - * @static - * @param {coop.rchain.casper.protocol.IListeningNameContinuationResponse=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.ListeningNameContinuationResponse} ListeningNameContinuationResponse instance - */ - ListeningNameContinuationResponse.create = function create(properties) { - return new ListeningNameContinuationResponse(properties); - }; - - /** - * Encodes the specified ListeningNameContinuationResponse message. Does not implicitly {@link coop.rchain.casper.protocol.ListeningNameContinuationResponse.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.ListeningNameContinuationResponse - * @static - * @param {coop.rchain.casper.protocol.IListeningNameContinuationResponse} message ListeningNameContinuationResponse message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ListeningNameContinuationResponse.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.blockResults != null && message.blockResults.length) - for (var i = 0; i < message.blockResults.length; ++i) - $root.coop.rchain.casper.protocol.ContinuationsWithBlockInfo.encode(message.blockResults[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.length != null && message.hasOwnProperty("length")) - writer.uint32(/* id 2, wireType 0 =*/16).int32(message.length); - return writer; - }; - - /** - * Encodes the specified ListeningNameContinuationResponse message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.ListeningNameContinuationResponse.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.ListeningNameContinuationResponse - * @static - * @param {coop.rchain.casper.protocol.IListeningNameContinuationResponse} message ListeningNameContinuationResponse message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ListeningNameContinuationResponse.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ListeningNameContinuationResponse message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.ListeningNameContinuationResponse - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.ListeningNameContinuationResponse} ListeningNameContinuationResponse - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ListeningNameContinuationResponse.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.ListeningNameContinuationResponse(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.blockResults && message.blockResults.length)) - message.blockResults = []; - message.blockResults.push($root.coop.rchain.casper.protocol.ContinuationsWithBlockInfo.decode(reader, reader.uint32())); - break; - case 2: - message.length = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ListeningNameContinuationResponse message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.ListeningNameContinuationResponse - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.ListeningNameContinuationResponse} ListeningNameContinuationResponse - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ListeningNameContinuationResponse.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ListeningNameContinuationResponse message. - * @function verify - * @memberof coop.rchain.casper.protocol.ListeningNameContinuationResponse - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ListeningNameContinuationResponse.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.blockResults != null && message.hasOwnProperty("blockResults")) { - if (!Array.isArray(message.blockResults)) - return "blockResults: array expected"; - for (var i = 0; i < message.blockResults.length; ++i) { - var error = $root.coop.rchain.casper.protocol.ContinuationsWithBlockInfo.verify(message.blockResults[i]); - if (error) - return "blockResults." + error; - } - } - if (message.length != null && message.hasOwnProperty("length")) - if (!$util.isInteger(message.length)) - return "length: integer expected"; - return null; - }; - - /** - * Creates a ListeningNameContinuationResponse message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.ListeningNameContinuationResponse - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.ListeningNameContinuationResponse} ListeningNameContinuationResponse - */ - ListeningNameContinuationResponse.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.ListeningNameContinuationResponse) - return object; - var message = new $root.coop.rchain.casper.protocol.ListeningNameContinuationResponse(); - if (object.blockResults) { - if (!Array.isArray(object.blockResults)) - throw TypeError(".coop.rchain.casper.protocol.ListeningNameContinuationResponse.blockResults: array expected"); - message.blockResults = []; - for (var i = 0; i < object.blockResults.length; ++i) { - if (typeof object.blockResults[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.ListeningNameContinuationResponse.blockResults: object expected"); - message.blockResults[i] = $root.coop.rchain.casper.protocol.ContinuationsWithBlockInfo.fromObject(object.blockResults[i]); - } - } - if (object.length != null) - message.length = object.length | 0; - return message; - }; - - /** - * Creates a plain object from a ListeningNameContinuationResponse message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.ListeningNameContinuationResponse - * @static - * @param {coop.rchain.casper.protocol.ListeningNameContinuationResponse} message ListeningNameContinuationResponse - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ListeningNameContinuationResponse.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.blockResults = []; - if (options.defaults) - object.length = 0; - if (message.blockResults && message.blockResults.length) { - object.blockResults = []; - for (var j = 0; j < message.blockResults.length; ++j) - object.blockResults[j] = $root.coop.rchain.casper.protocol.ContinuationsWithBlockInfo.toObject(message.blockResults[j], options); - } - if (message.length != null && message.hasOwnProperty("length")) - object.length = message.length; - return object; - }; - - /** - * Converts this ListeningNameContinuationResponse to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.ListeningNameContinuationResponse - * @instance - * @returns {Object.} JSON object - */ - ListeningNameContinuationResponse.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ListeningNameContinuationResponse; - })(); - - protocol.DataWithBlockInfo = (function() { - - /** - * Properties of a DataWithBlockInfo. - * @memberof coop.rchain.casper.protocol - * @interface IDataWithBlockInfo - * @property {Array.|null} [postBlockData] DataWithBlockInfo postBlockData - * @property {coop.rchain.casper.protocol.IBlockInfoWithoutTuplespace|null} [block] DataWithBlockInfo block - */ - - /** - * Constructs a new DataWithBlockInfo. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a DataWithBlockInfo. - * @implements IDataWithBlockInfo - * @constructor - * @param {coop.rchain.casper.protocol.IDataWithBlockInfo=} [properties] Properties to set - */ - function DataWithBlockInfo(properties) { - this.postBlockData = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * DataWithBlockInfo postBlockData. - * @member {Array.} postBlockData - * @memberof coop.rchain.casper.protocol.DataWithBlockInfo - * @instance - */ - DataWithBlockInfo.prototype.postBlockData = $util.emptyArray; - - /** - * DataWithBlockInfo block. - * @member {coop.rchain.casper.protocol.IBlockInfoWithoutTuplespace|null|undefined} block - * @memberof coop.rchain.casper.protocol.DataWithBlockInfo - * @instance - */ - DataWithBlockInfo.prototype.block = null; - - /** - * Creates a new DataWithBlockInfo instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.DataWithBlockInfo - * @static - * @param {coop.rchain.casper.protocol.IDataWithBlockInfo=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.DataWithBlockInfo} DataWithBlockInfo instance - */ - DataWithBlockInfo.create = function create(properties) { - return new DataWithBlockInfo(properties); - }; - - /** - * Encodes the specified DataWithBlockInfo message. Does not implicitly {@link coop.rchain.casper.protocol.DataWithBlockInfo.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.DataWithBlockInfo - * @static - * @param {coop.rchain.casper.protocol.IDataWithBlockInfo} message DataWithBlockInfo message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DataWithBlockInfo.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.postBlockData != null && message.postBlockData.length) - for (var i = 0; i < message.postBlockData.length; ++i) - $root.Par.encode(message.postBlockData[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.block != null && message.hasOwnProperty("block")) - $root.coop.rchain.casper.protocol.BlockInfoWithoutTuplespace.encode(message.block, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified DataWithBlockInfo message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.DataWithBlockInfo.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.DataWithBlockInfo - * @static - * @param {coop.rchain.casper.protocol.IDataWithBlockInfo} message DataWithBlockInfo message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DataWithBlockInfo.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a DataWithBlockInfo message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.DataWithBlockInfo - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.DataWithBlockInfo} DataWithBlockInfo - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DataWithBlockInfo.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.DataWithBlockInfo(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.postBlockData && message.postBlockData.length)) - message.postBlockData = []; - message.postBlockData.push($root.Par.decode(reader, reader.uint32())); - break; - case 2: - message.block = $root.coop.rchain.casper.protocol.BlockInfoWithoutTuplespace.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a DataWithBlockInfo message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.DataWithBlockInfo - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.DataWithBlockInfo} DataWithBlockInfo - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DataWithBlockInfo.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a DataWithBlockInfo message. - * @function verify - * @memberof coop.rchain.casper.protocol.DataWithBlockInfo - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - DataWithBlockInfo.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.postBlockData != null && message.hasOwnProperty("postBlockData")) { - if (!Array.isArray(message.postBlockData)) - return "postBlockData: array expected"; - for (var i = 0; i < message.postBlockData.length; ++i) { - var error = $root.Par.verify(message.postBlockData[i]); - if (error) - return "postBlockData." + error; - } - } - if (message.block != null && message.hasOwnProperty("block")) { - var error = $root.coop.rchain.casper.protocol.BlockInfoWithoutTuplespace.verify(message.block); - if (error) - return "block." + error; - } - return null; - }; - - /** - * Creates a DataWithBlockInfo message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.DataWithBlockInfo - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.DataWithBlockInfo} DataWithBlockInfo - */ - DataWithBlockInfo.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.DataWithBlockInfo) - return object; - var message = new $root.coop.rchain.casper.protocol.DataWithBlockInfo(); - if (object.postBlockData) { - if (!Array.isArray(object.postBlockData)) - throw TypeError(".coop.rchain.casper.protocol.DataWithBlockInfo.postBlockData: array expected"); - message.postBlockData = []; - for (var i = 0; i < object.postBlockData.length; ++i) { - if (typeof object.postBlockData[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.DataWithBlockInfo.postBlockData: object expected"); - message.postBlockData[i] = $root.Par.fromObject(object.postBlockData[i]); - } - } - if (object.block != null) { - if (typeof object.block !== "object") - throw TypeError(".coop.rchain.casper.protocol.DataWithBlockInfo.block: object expected"); - message.block = $root.coop.rchain.casper.protocol.BlockInfoWithoutTuplespace.fromObject(object.block); - } - return message; - }; - - /** - * Creates a plain object from a DataWithBlockInfo message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.DataWithBlockInfo - * @static - * @param {coop.rchain.casper.protocol.DataWithBlockInfo} message DataWithBlockInfo - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - DataWithBlockInfo.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.postBlockData = []; - if (options.defaults) - object.block = null; - if (message.postBlockData && message.postBlockData.length) { - object.postBlockData = []; - for (var j = 0; j < message.postBlockData.length; ++j) - object.postBlockData[j] = $root.Par.toObject(message.postBlockData[j], options); - } - if (message.block != null && message.hasOwnProperty("block")) - object.block = $root.coop.rchain.casper.protocol.BlockInfoWithoutTuplespace.toObject(message.block, options); - return object; - }; - - /** - * Converts this DataWithBlockInfo to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.DataWithBlockInfo - * @instance - * @returns {Object.} JSON object - */ - DataWithBlockInfo.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return DataWithBlockInfo; - })(); - - protocol.ContinuationsWithBlockInfo = (function() { - - /** - * Properties of a ContinuationsWithBlockInfo. - * @memberof coop.rchain.casper.protocol - * @interface IContinuationsWithBlockInfo - * @property {Array.|null} [postBlockContinuations] ContinuationsWithBlockInfo postBlockContinuations - * @property {coop.rchain.casper.protocol.IBlockInfoWithoutTuplespace|null} [block] ContinuationsWithBlockInfo block - */ - - /** - * Constructs a new ContinuationsWithBlockInfo. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a ContinuationsWithBlockInfo. - * @implements IContinuationsWithBlockInfo - * @constructor - * @param {coop.rchain.casper.protocol.IContinuationsWithBlockInfo=} [properties] Properties to set - */ - function ContinuationsWithBlockInfo(properties) { - this.postBlockContinuations = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ContinuationsWithBlockInfo postBlockContinuations. - * @member {Array.} postBlockContinuations - * @memberof coop.rchain.casper.protocol.ContinuationsWithBlockInfo - * @instance - */ - ContinuationsWithBlockInfo.prototype.postBlockContinuations = $util.emptyArray; - - /** - * ContinuationsWithBlockInfo block. - * @member {coop.rchain.casper.protocol.IBlockInfoWithoutTuplespace|null|undefined} block - * @memberof coop.rchain.casper.protocol.ContinuationsWithBlockInfo - * @instance - */ - ContinuationsWithBlockInfo.prototype.block = null; - - /** - * Creates a new ContinuationsWithBlockInfo instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.ContinuationsWithBlockInfo - * @static - * @param {coop.rchain.casper.protocol.IContinuationsWithBlockInfo=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.ContinuationsWithBlockInfo} ContinuationsWithBlockInfo instance - */ - ContinuationsWithBlockInfo.create = function create(properties) { - return new ContinuationsWithBlockInfo(properties); - }; - - /** - * Encodes the specified ContinuationsWithBlockInfo message. Does not implicitly {@link coop.rchain.casper.protocol.ContinuationsWithBlockInfo.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.ContinuationsWithBlockInfo - * @static - * @param {coop.rchain.casper.protocol.IContinuationsWithBlockInfo} message ContinuationsWithBlockInfo message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ContinuationsWithBlockInfo.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.postBlockContinuations != null && message.postBlockContinuations.length) - for (var i = 0; i < message.postBlockContinuations.length; ++i) - $root.coop.rchain.casper.protocol.WaitingContinuationInfo.encode(message.postBlockContinuations[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.block != null && message.hasOwnProperty("block")) - $root.coop.rchain.casper.protocol.BlockInfoWithoutTuplespace.encode(message.block, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified ContinuationsWithBlockInfo message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.ContinuationsWithBlockInfo.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.ContinuationsWithBlockInfo - * @static - * @param {coop.rchain.casper.protocol.IContinuationsWithBlockInfo} message ContinuationsWithBlockInfo message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ContinuationsWithBlockInfo.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ContinuationsWithBlockInfo message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.ContinuationsWithBlockInfo - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.ContinuationsWithBlockInfo} ContinuationsWithBlockInfo - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ContinuationsWithBlockInfo.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.ContinuationsWithBlockInfo(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.postBlockContinuations && message.postBlockContinuations.length)) - message.postBlockContinuations = []; - message.postBlockContinuations.push($root.coop.rchain.casper.protocol.WaitingContinuationInfo.decode(reader, reader.uint32())); - break; - case 2: - message.block = $root.coop.rchain.casper.protocol.BlockInfoWithoutTuplespace.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ContinuationsWithBlockInfo message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.ContinuationsWithBlockInfo - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.ContinuationsWithBlockInfo} ContinuationsWithBlockInfo - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ContinuationsWithBlockInfo.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ContinuationsWithBlockInfo message. - * @function verify - * @memberof coop.rchain.casper.protocol.ContinuationsWithBlockInfo - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ContinuationsWithBlockInfo.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.postBlockContinuations != null && message.hasOwnProperty("postBlockContinuations")) { - if (!Array.isArray(message.postBlockContinuations)) - return "postBlockContinuations: array expected"; - for (var i = 0; i < message.postBlockContinuations.length; ++i) { - var error = $root.coop.rchain.casper.protocol.WaitingContinuationInfo.verify(message.postBlockContinuations[i]); - if (error) - return "postBlockContinuations." + error; - } - } - if (message.block != null && message.hasOwnProperty("block")) { - var error = $root.coop.rchain.casper.protocol.BlockInfoWithoutTuplespace.verify(message.block); - if (error) - return "block." + error; - } - return null; - }; - - /** - * Creates a ContinuationsWithBlockInfo message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.ContinuationsWithBlockInfo - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.ContinuationsWithBlockInfo} ContinuationsWithBlockInfo - */ - ContinuationsWithBlockInfo.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.ContinuationsWithBlockInfo) - return object; - var message = new $root.coop.rchain.casper.protocol.ContinuationsWithBlockInfo(); - if (object.postBlockContinuations) { - if (!Array.isArray(object.postBlockContinuations)) - throw TypeError(".coop.rchain.casper.protocol.ContinuationsWithBlockInfo.postBlockContinuations: array expected"); - message.postBlockContinuations = []; - for (var i = 0; i < object.postBlockContinuations.length; ++i) { - if (typeof object.postBlockContinuations[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.ContinuationsWithBlockInfo.postBlockContinuations: object expected"); - message.postBlockContinuations[i] = $root.coop.rchain.casper.protocol.WaitingContinuationInfo.fromObject(object.postBlockContinuations[i]); - } - } - if (object.block != null) { - if (typeof object.block !== "object") - throw TypeError(".coop.rchain.casper.protocol.ContinuationsWithBlockInfo.block: object expected"); - message.block = $root.coop.rchain.casper.protocol.BlockInfoWithoutTuplespace.fromObject(object.block); - } - return message; - }; - - /** - * Creates a plain object from a ContinuationsWithBlockInfo message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.ContinuationsWithBlockInfo - * @static - * @param {coop.rchain.casper.protocol.ContinuationsWithBlockInfo} message ContinuationsWithBlockInfo - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ContinuationsWithBlockInfo.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.postBlockContinuations = []; - if (options.defaults) - object.block = null; - if (message.postBlockContinuations && message.postBlockContinuations.length) { - object.postBlockContinuations = []; - for (var j = 0; j < message.postBlockContinuations.length; ++j) - object.postBlockContinuations[j] = $root.coop.rchain.casper.protocol.WaitingContinuationInfo.toObject(message.postBlockContinuations[j], options); - } - if (message.block != null && message.hasOwnProperty("block")) - object.block = $root.coop.rchain.casper.protocol.BlockInfoWithoutTuplespace.toObject(message.block, options); - return object; - }; - - /** - * Converts this ContinuationsWithBlockInfo to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.ContinuationsWithBlockInfo - * @instance - * @returns {Object.} JSON object - */ - ContinuationsWithBlockInfo.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ContinuationsWithBlockInfo; - })(); - - protocol.WaitingContinuationInfo = (function() { - - /** - * Properties of a WaitingContinuationInfo. - * @memberof coop.rchain.casper.protocol - * @interface IWaitingContinuationInfo - * @property {Array.|null} [postBlockPatterns] WaitingContinuationInfo postBlockPatterns - * @property {IPar|null} [postBlockContinuation] WaitingContinuationInfo postBlockContinuation - */ - - /** - * Constructs a new WaitingContinuationInfo. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a WaitingContinuationInfo. - * @implements IWaitingContinuationInfo - * @constructor - * @param {coop.rchain.casper.protocol.IWaitingContinuationInfo=} [properties] Properties to set - */ - function WaitingContinuationInfo(properties) { - this.postBlockPatterns = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * WaitingContinuationInfo postBlockPatterns. - * @member {Array.} postBlockPatterns - * @memberof coop.rchain.casper.protocol.WaitingContinuationInfo - * @instance - */ - WaitingContinuationInfo.prototype.postBlockPatterns = $util.emptyArray; - - /** - * WaitingContinuationInfo postBlockContinuation. - * @member {IPar|null|undefined} postBlockContinuation - * @memberof coop.rchain.casper.protocol.WaitingContinuationInfo - * @instance - */ - WaitingContinuationInfo.prototype.postBlockContinuation = null; - - /** - * Creates a new WaitingContinuationInfo instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.WaitingContinuationInfo - * @static - * @param {coop.rchain.casper.protocol.IWaitingContinuationInfo=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.WaitingContinuationInfo} WaitingContinuationInfo instance - */ - WaitingContinuationInfo.create = function create(properties) { - return new WaitingContinuationInfo(properties); - }; - - /** - * Encodes the specified WaitingContinuationInfo message. Does not implicitly {@link coop.rchain.casper.protocol.WaitingContinuationInfo.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.WaitingContinuationInfo - * @static - * @param {coop.rchain.casper.protocol.IWaitingContinuationInfo} message WaitingContinuationInfo message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - WaitingContinuationInfo.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.postBlockPatterns != null && message.postBlockPatterns.length) - for (var i = 0; i < message.postBlockPatterns.length; ++i) - $root.BindPattern.encode(message.postBlockPatterns[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.postBlockContinuation != null && message.hasOwnProperty("postBlockContinuation")) - $root.Par.encode(message.postBlockContinuation, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified WaitingContinuationInfo message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.WaitingContinuationInfo.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.WaitingContinuationInfo - * @static - * @param {coop.rchain.casper.protocol.IWaitingContinuationInfo} message WaitingContinuationInfo message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - WaitingContinuationInfo.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a WaitingContinuationInfo message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.WaitingContinuationInfo - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.WaitingContinuationInfo} WaitingContinuationInfo - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - WaitingContinuationInfo.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.WaitingContinuationInfo(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.postBlockPatterns && message.postBlockPatterns.length)) - message.postBlockPatterns = []; - message.postBlockPatterns.push($root.BindPattern.decode(reader, reader.uint32())); - break; - case 2: - message.postBlockContinuation = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a WaitingContinuationInfo message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.WaitingContinuationInfo - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.WaitingContinuationInfo} WaitingContinuationInfo - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - WaitingContinuationInfo.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a WaitingContinuationInfo message. - * @function verify - * @memberof coop.rchain.casper.protocol.WaitingContinuationInfo - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - WaitingContinuationInfo.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.postBlockPatterns != null && message.hasOwnProperty("postBlockPatterns")) { - if (!Array.isArray(message.postBlockPatterns)) - return "postBlockPatterns: array expected"; - for (var i = 0; i < message.postBlockPatterns.length; ++i) { - var error = $root.BindPattern.verify(message.postBlockPatterns[i]); - if (error) - return "postBlockPatterns." + error; - } - } - if (message.postBlockContinuation != null && message.hasOwnProperty("postBlockContinuation")) { - var error = $root.Par.verify(message.postBlockContinuation); - if (error) - return "postBlockContinuation." + error; - } - return null; - }; - - /** - * Creates a WaitingContinuationInfo message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.WaitingContinuationInfo - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.WaitingContinuationInfo} WaitingContinuationInfo - */ - WaitingContinuationInfo.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.WaitingContinuationInfo) - return object; - var message = new $root.coop.rchain.casper.protocol.WaitingContinuationInfo(); - if (object.postBlockPatterns) { - if (!Array.isArray(object.postBlockPatterns)) - throw TypeError(".coop.rchain.casper.protocol.WaitingContinuationInfo.postBlockPatterns: array expected"); - message.postBlockPatterns = []; - for (var i = 0; i < object.postBlockPatterns.length; ++i) { - if (typeof object.postBlockPatterns[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.WaitingContinuationInfo.postBlockPatterns: object expected"); - message.postBlockPatterns[i] = $root.BindPattern.fromObject(object.postBlockPatterns[i]); - } - } - if (object.postBlockContinuation != null) { - if (typeof object.postBlockContinuation !== "object") - throw TypeError(".coop.rchain.casper.protocol.WaitingContinuationInfo.postBlockContinuation: object expected"); - message.postBlockContinuation = $root.Par.fromObject(object.postBlockContinuation); - } - return message; - }; - - /** - * Creates a plain object from a WaitingContinuationInfo message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.WaitingContinuationInfo - * @static - * @param {coop.rchain.casper.protocol.WaitingContinuationInfo} message WaitingContinuationInfo - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - WaitingContinuationInfo.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.postBlockPatterns = []; - if (options.defaults) - object.postBlockContinuation = null; - if (message.postBlockPatterns && message.postBlockPatterns.length) { - object.postBlockPatterns = []; - for (var j = 0; j < message.postBlockPatterns.length; ++j) - object.postBlockPatterns[j] = $root.BindPattern.toObject(message.postBlockPatterns[j], options); - } - if (message.postBlockContinuation != null && message.hasOwnProperty("postBlockContinuation")) - object.postBlockContinuation = $root.Par.toObject(message.postBlockContinuation, options); - return object; - }; - - /** - * Converts this WaitingContinuationInfo to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.WaitingContinuationInfo - * @instance - * @returns {Object.} JSON object - */ - WaitingContinuationInfo.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return WaitingContinuationInfo; - })(); - - protocol.BlockInfoWithoutTuplespace = (function() { - - /** - * Properties of a BlockInfoWithoutTuplespace. - * @memberof coop.rchain.casper.protocol - * @interface IBlockInfoWithoutTuplespace - * @property {string|null} [blockHash] BlockInfoWithoutTuplespace blockHash - * @property {string|null} [blockSize] BlockInfoWithoutTuplespace blockSize - * @property {number|Long|null} [blockNumber] BlockInfoWithoutTuplespace blockNumber - * @property {number|Long|null} [version] BlockInfoWithoutTuplespace version - * @property {number|null} [deployCount] BlockInfoWithoutTuplespace deployCount - * @property {string|null} [tupleSpaceHash] BlockInfoWithoutTuplespace tupleSpaceHash - * @property {number|Long|null} [timestamp] BlockInfoWithoutTuplespace timestamp - * @property {number|null} [faultTolerance] BlockInfoWithoutTuplespace faultTolerance - * @property {string|null} [mainParentHash] BlockInfoWithoutTuplespace mainParentHash - * @property {Array.|null} [parentsHashList] BlockInfoWithoutTuplespace parentsHashList - * @property {string|null} [sender] BlockInfoWithoutTuplespace sender - */ - - /** - * Constructs a new BlockInfoWithoutTuplespace. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a BlockInfoWithoutTuplespace. - * @implements IBlockInfoWithoutTuplespace - * @constructor - * @param {coop.rchain.casper.protocol.IBlockInfoWithoutTuplespace=} [properties] Properties to set - */ - function BlockInfoWithoutTuplespace(properties) { - this.parentsHashList = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BlockInfoWithoutTuplespace blockHash. - * @member {string} blockHash - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @instance - */ - BlockInfoWithoutTuplespace.prototype.blockHash = ""; - - /** - * BlockInfoWithoutTuplespace blockSize. - * @member {string} blockSize - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @instance - */ - BlockInfoWithoutTuplespace.prototype.blockSize = ""; - - /** - * BlockInfoWithoutTuplespace blockNumber. - * @member {number|Long} blockNumber - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @instance - */ - BlockInfoWithoutTuplespace.prototype.blockNumber = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * BlockInfoWithoutTuplespace version. - * @member {number|Long} version - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @instance - */ - BlockInfoWithoutTuplespace.prototype.version = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * BlockInfoWithoutTuplespace deployCount. - * @member {number} deployCount - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @instance - */ - BlockInfoWithoutTuplespace.prototype.deployCount = 0; - - /** - * BlockInfoWithoutTuplespace tupleSpaceHash. - * @member {string} tupleSpaceHash - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @instance - */ - BlockInfoWithoutTuplespace.prototype.tupleSpaceHash = ""; - - /** - * BlockInfoWithoutTuplespace timestamp. - * @member {number|Long} timestamp - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @instance - */ - BlockInfoWithoutTuplespace.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * BlockInfoWithoutTuplespace faultTolerance. - * @member {number} faultTolerance - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @instance - */ - BlockInfoWithoutTuplespace.prototype.faultTolerance = 0; - - /** - * BlockInfoWithoutTuplespace mainParentHash. - * @member {string} mainParentHash - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @instance - */ - BlockInfoWithoutTuplespace.prototype.mainParentHash = ""; - - /** - * BlockInfoWithoutTuplespace parentsHashList. - * @member {Array.} parentsHashList - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @instance - */ - BlockInfoWithoutTuplespace.prototype.parentsHashList = $util.emptyArray; - - /** - * BlockInfoWithoutTuplespace sender. - * @member {string} sender - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @instance - */ - BlockInfoWithoutTuplespace.prototype.sender = ""; - - /** - * Creates a new BlockInfoWithoutTuplespace instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @static - * @param {coop.rchain.casper.protocol.IBlockInfoWithoutTuplespace=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.BlockInfoWithoutTuplespace} BlockInfoWithoutTuplespace instance - */ - BlockInfoWithoutTuplespace.create = function create(properties) { - return new BlockInfoWithoutTuplespace(properties); - }; - - /** - * Encodes the specified BlockInfoWithoutTuplespace message. Does not implicitly {@link coop.rchain.casper.protocol.BlockInfoWithoutTuplespace.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @static - * @param {coop.rchain.casper.protocol.IBlockInfoWithoutTuplespace} message BlockInfoWithoutTuplespace message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockInfoWithoutTuplespace.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.blockHash != null && message.hasOwnProperty("blockHash")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.blockHash); - if (message.blockSize != null && message.hasOwnProperty("blockSize")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.blockSize); - if (message.blockNumber != null && message.hasOwnProperty("blockNumber")) - writer.uint32(/* id 3, wireType 0 =*/24).int64(message.blockNumber); - if (message.version != null && message.hasOwnProperty("version")) - writer.uint32(/* id 4, wireType 0 =*/32).int64(message.version); - if (message.deployCount != null && message.hasOwnProperty("deployCount")) - writer.uint32(/* id 5, wireType 0 =*/40).int32(message.deployCount); - if (message.tupleSpaceHash != null && message.hasOwnProperty("tupleSpaceHash")) - writer.uint32(/* id 6, wireType 2 =*/50).string(message.tupleSpaceHash); - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - writer.uint32(/* id 7, wireType 0 =*/56).int64(message.timestamp); - if (message.faultTolerance != null && message.hasOwnProperty("faultTolerance")) - writer.uint32(/* id 8, wireType 5 =*/69).float(message.faultTolerance); - if (message.mainParentHash != null && message.hasOwnProperty("mainParentHash")) - writer.uint32(/* id 9, wireType 2 =*/74).string(message.mainParentHash); - if (message.parentsHashList != null && message.parentsHashList.length) - for (var i = 0; i < message.parentsHashList.length; ++i) - writer.uint32(/* id 10, wireType 2 =*/82).string(message.parentsHashList[i]); - if (message.sender != null && message.hasOwnProperty("sender")) - writer.uint32(/* id 11, wireType 2 =*/90).string(message.sender); - return writer; - }; - - /** - * Encodes the specified BlockInfoWithoutTuplespace message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.BlockInfoWithoutTuplespace.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @static - * @param {coop.rchain.casper.protocol.IBlockInfoWithoutTuplespace} message BlockInfoWithoutTuplespace message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockInfoWithoutTuplespace.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a BlockInfoWithoutTuplespace message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.BlockInfoWithoutTuplespace} BlockInfoWithoutTuplespace - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockInfoWithoutTuplespace.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.BlockInfoWithoutTuplespace(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.blockHash = reader.string(); - break; - case 2: - message.blockSize = reader.string(); - break; - case 3: - message.blockNumber = reader.int64(); - break; - case 4: - message.version = reader.int64(); - break; - case 5: - message.deployCount = reader.int32(); - break; - case 6: - message.tupleSpaceHash = reader.string(); - break; - case 7: - message.timestamp = reader.int64(); - break; - case 8: - message.faultTolerance = reader.float(); - break; - case 9: - message.mainParentHash = reader.string(); - break; - case 10: - if (!(message.parentsHashList && message.parentsHashList.length)) - message.parentsHashList = []; - message.parentsHashList.push(reader.string()); - break; - case 11: - message.sender = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a BlockInfoWithoutTuplespace message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.BlockInfoWithoutTuplespace} BlockInfoWithoutTuplespace - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockInfoWithoutTuplespace.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a BlockInfoWithoutTuplespace message. - * @function verify - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - BlockInfoWithoutTuplespace.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.blockHash != null && message.hasOwnProperty("blockHash")) - if (!$util.isString(message.blockHash)) - return "blockHash: string expected"; - if (message.blockSize != null && message.hasOwnProperty("blockSize")) - if (!$util.isString(message.blockSize)) - return "blockSize: string expected"; - if (message.blockNumber != null && message.hasOwnProperty("blockNumber")) - if (!$util.isInteger(message.blockNumber) && !(message.blockNumber && $util.isInteger(message.blockNumber.low) && $util.isInteger(message.blockNumber.high))) - return "blockNumber: integer|Long expected"; - if (message.version != null && message.hasOwnProperty("version")) - if (!$util.isInteger(message.version) && !(message.version && $util.isInteger(message.version.low) && $util.isInteger(message.version.high))) - return "version: integer|Long expected"; - if (message.deployCount != null && message.hasOwnProperty("deployCount")) - if (!$util.isInteger(message.deployCount)) - return "deployCount: integer expected"; - if (message.tupleSpaceHash != null && message.hasOwnProperty("tupleSpaceHash")) - if (!$util.isString(message.tupleSpaceHash)) - return "tupleSpaceHash: string expected"; - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high))) - return "timestamp: integer|Long expected"; - if (message.faultTolerance != null && message.hasOwnProperty("faultTolerance")) - if (typeof message.faultTolerance !== "number") - return "faultTolerance: number expected"; - if (message.mainParentHash != null && message.hasOwnProperty("mainParentHash")) - if (!$util.isString(message.mainParentHash)) - return "mainParentHash: string expected"; - if (message.parentsHashList != null && message.hasOwnProperty("parentsHashList")) { - if (!Array.isArray(message.parentsHashList)) - return "parentsHashList: array expected"; - for (var i = 0; i < message.parentsHashList.length; ++i) - if (!$util.isString(message.parentsHashList[i])) - return "parentsHashList: string[] expected"; - } - if (message.sender != null && message.hasOwnProperty("sender")) - if (!$util.isString(message.sender)) - return "sender: string expected"; - return null; - }; - - /** - * Creates a BlockInfoWithoutTuplespace message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.BlockInfoWithoutTuplespace} BlockInfoWithoutTuplespace - */ - BlockInfoWithoutTuplespace.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.BlockInfoWithoutTuplespace) - return object; - var message = new $root.coop.rchain.casper.protocol.BlockInfoWithoutTuplespace(); - if (object.blockHash != null) - message.blockHash = String(object.blockHash); - if (object.blockSize != null) - message.blockSize = String(object.blockSize); - if (object.blockNumber != null) - if ($util.Long) - (message.blockNumber = $util.Long.fromValue(object.blockNumber)).unsigned = false; - else if (typeof object.blockNumber === "string") - message.blockNumber = parseInt(object.blockNumber, 10); - else if (typeof object.blockNumber === "number") - message.blockNumber = object.blockNumber; - else if (typeof object.blockNumber === "object") - message.blockNumber = new $util.LongBits(object.blockNumber.low >>> 0, object.blockNumber.high >>> 0).toNumber(); - if (object.version != null) - if ($util.Long) - (message.version = $util.Long.fromValue(object.version)).unsigned = false; - else if (typeof object.version === "string") - message.version = parseInt(object.version, 10); - else if (typeof object.version === "number") - message.version = object.version; - else if (typeof object.version === "object") - message.version = new $util.LongBits(object.version.low >>> 0, object.version.high >>> 0).toNumber(); - if (object.deployCount != null) - message.deployCount = object.deployCount | 0; - if (object.tupleSpaceHash != null) - message.tupleSpaceHash = String(object.tupleSpaceHash); - if (object.timestamp != null) - if ($util.Long) - (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = false; - else if (typeof object.timestamp === "string") - message.timestamp = parseInt(object.timestamp, 10); - else if (typeof object.timestamp === "number") - message.timestamp = object.timestamp; - else if (typeof object.timestamp === "object") - message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber(); - if (object.faultTolerance != null) - message.faultTolerance = Number(object.faultTolerance); - if (object.mainParentHash != null) - message.mainParentHash = String(object.mainParentHash); - if (object.parentsHashList) { - if (!Array.isArray(object.parentsHashList)) - throw TypeError(".coop.rchain.casper.protocol.BlockInfoWithoutTuplespace.parentsHashList: array expected"); - message.parentsHashList = []; - for (var i = 0; i < object.parentsHashList.length; ++i) - message.parentsHashList[i] = String(object.parentsHashList[i]); - } - if (object.sender != null) - message.sender = String(object.sender); - return message; - }; - - /** - * Creates a plain object from a BlockInfoWithoutTuplespace message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @static - * @param {coop.rchain.casper.protocol.BlockInfoWithoutTuplespace} message BlockInfoWithoutTuplespace - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - BlockInfoWithoutTuplespace.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.parentsHashList = []; - if (options.defaults) { - object.blockHash = ""; - object.blockSize = ""; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.blockNumber = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.blockNumber = options.longs === String ? "0" : 0; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.version = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.version = options.longs === String ? "0" : 0; - object.deployCount = 0; - object.tupleSpaceHash = ""; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.timestamp = options.longs === String ? "0" : 0; - object.faultTolerance = 0; - object.mainParentHash = ""; - object.sender = ""; - } - if (message.blockHash != null && message.hasOwnProperty("blockHash")) - object.blockHash = message.blockHash; - if (message.blockSize != null && message.hasOwnProperty("blockSize")) - object.blockSize = message.blockSize; - if (message.blockNumber != null && message.hasOwnProperty("blockNumber")) - if (typeof message.blockNumber === "number") - object.blockNumber = options.longs === String ? String(message.blockNumber) : message.blockNumber; - else - object.blockNumber = options.longs === String ? $util.Long.prototype.toString.call(message.blockNumber) : options.longs === Number ? new $util.LongBits(message.blockNumber.low >>> 0, message.blockNumber.high >>> 0).toNumber() : message.blockNumber; - if (message.version != null && message.hasOwnProperty("version")) - if (typeof message.version === "number") - object.version = options.longs === String ? String(message.version) : message.version; - else - object.version = options.longs === String ? $util.Long.prototype.toString.call(message.version) : options.longs === Number ? new $util.LongBits(message.version.low >>> 0, message.version.high >>> 0).toNumber() : message.version; - if (message.deployCount != null && message.hasOwnProperty("deployCount")) - object.deployCount = message.deployCount; - if (message.tupleSpaceHash != null && message.hasOwnProperty("tupleSpaceHash")) - object.tupleSpaceHash = message.tupleSpaceHash; - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (typeof message.timestamp === "number") - object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp; - else - object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber() : message.timestamp; - if (message.faultTolerance != null && message.hasOwnProperty("faultTolerance")) - object.faultTolerance = options.json && !isFinite(message.faultTolerance) ? String(message.faultTolerance) : message.faultTolerance; - if (message.mainParentHash != null && message.hasOwnProperty("mainParentHash")) - object.mainParentHash = message.mainParentHash; - if (message.parentsHashList && message.parentsHashList.length) { - object.parentsHashList = []; - for (var j = 0; j < message.parentsHashList.length; ++j) - object.parentsHashList[j] = message.parentsHashList[j]; - } - if (message.sender != null && message.hasOwnProperty("sender")) - object.sender = message.sender; - return object; - }; - - /** - * Converts this BlockInfoWithoutTuplespace to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.BlockInfoWithoutTuplespace - * @instance - * @returns {Object.} JSON object - */ - BlockInfoWithoutTuplespace.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return BlockInfoWithoutTuplespace; - })(); - - protocol.BlockInfo = (function() { - - /** - * Properties of a BlockInfo. - * @memberof coop.rchain.casper.protocol - * @interface IBlockInfo - * @property {string|null} [blockHash] BlockInfo blockHash - * @property {string|null} [blockSize] BlockInfo blockSize - * @property {number|Long|null} [blockNumber] BlockInfo blockNumber - * @property {number|Long|null} [version] BlockInfo version - * @property {number|null} [deployCount] BlockInfo deployCount - * @property {string|null} [tupleSpaceHash] BlockInfo tupleSpaceHash - * @property {string|null} [tupleSpaceDump] BlockInfo tupleSpaceDump - * @property {number|Long|null} [timestamp] BlockInfo timestamp - * @property {number|null} [faultTolerance] BlockInfo faultTolerance - * @property {string|null} [mainParentHash] BlockInfo mainParentHash - * @property {Array.|null} [parentsHashList] BlockInfo parentsHashList - * @property {string|null} [sender] BlockInfo sender - * @property {string|null} [shardId] BlockInfo shardId - * @property {Array.|null} [bondsValidatorList] BlockInfo bondsValidatorList - * @property {Array.|null} [deployCost] BlockInfo deployCost - */ - - /** - * Constructs a new BlockInfo. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a BlockInfo. - * @implements IBlockInfo - * @constructor - * @param {coop.rchain.casper.protocol.IBlockInfo=} [properties] Properties to set - */ - function BlockInfo(properties) { - this.parentsHashList = []; - this.bondsValidatorList = []; - this.deployCost = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BlockInfo blockHash. - * @member {string} blockHash - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.blockHash = ""; - - /** - * BlockInfo blockSize. - * @member {string} blockSize - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.blockSize = ""; - - /** - * BlockInfo blockNumber. - * @member {number|Long} blockNumber - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.blockNumber = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * BlockInfo version. - * @member {number|Long} version - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.version = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * BlockInfo deployCount. - * @member {number} deployCount - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.deployCount = 0; - - /** - * BlockInfo tupleSpaceHash. - * @member {string} tupleSpaceHash - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.tupleSpaceHash = ""; - - /** - * BlockInfo tupleSpaceDump. - * @member {string} tupleSpaceDump - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.tupleSpaceDump = ""; - - /** - * BlockInfo timestamp. - * @member {number|Long} timestamp - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * BlockInfo faultTolerance. - * @member {number} faultTolerance - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.faultTolerance = 0; - - /** - * BlockInfo mainParentHash. - * @member {string} mainParentHash - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.mainParentHash = ""; - - /** - * BlockInfo parentsHashList. - * @member {Array.} parentsHashList - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.parentsHashList = $util.emptyArray; - - /** - * BlockInfo sender. - * @member {string} sender - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.sender = ""; - - /** - * BlockInfo shardId. - * @member {string} shardId - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.shardId = ""; - - /** - * BlockInfo bondsValidatorList. - * @member {Array.} bondsValidatorList - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.bondsValidatorList = $util.emptyArray; - - /** - * BlockInfo deployCost. - * @member {Array.} deployCost - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - */ - BlockInfo.prototype.deployCost = $util.emptyArray; - - /** - * Creates a new BlockInfo instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.BlockInfo - * @static - * @param {coop.rchain.casper.protocol.IBlockInfo=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.BlockInfo} BlockInfo instance - */ - BlockInfo.create = function create(properties) { - return new BlockInfo(properties); - }; - - /** - * Encodes the specified BlockInfo message. Does not implicitly {@link coop.rchain.casper.protocol.BlockInfo.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.BlockInfo - * @static - * @param {coop.rchain.casper.protocol.IBlockInfo} message BlockInfo message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockInfo.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.blockHash != null && message.hasOwnProperty("blockHash")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.blockHash); - if (message.blockSize != null && message.hasOwnProperty("blockSize")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.blockSize); - if (message.blockNumber != null && message.hasOwnProperty("blockNumber")) - writer.uint32(/* id 3, wireType 0 =*/24).int64(message.blockNumber); - if (message.version != null && message.hasOwnProperty("version")) - writer.uint32(/* id 4, wireType 0 =*/32).int64(message.version); - if (message.deployCount != null && message.hasOwnProperty("deployCount")) - writer.uint32(/* id 5, wireType 0 =*/40).int32(message.deployCount); - if (message.tupleSpaceHash != null && message.hasOwnProperty("tupleSpaceHash")) - writer.uint32(/* id 6, wireType 2 =*/50).string(message.tupleSpaceHash); - if (message.tupleSpaceDump != null && message.hasOwnProperty("tupleSpaceDump")) - writer.uint32(/* id 7, wireType 2 =*/58).string(message.tupleSpaceDump); - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - writer.uint32(/* id 8, wireType 0 =*/64).int64(message.timestamp); - if (message.faultTolerance != null && message.hasOwnProperty("faultTolerance")) - writer.uint32(/* id 9, wireType 5 =*/77).float(message.faultTolerance); - if (message.mainParentHash != null && message.hasOwnProperty("mainParentHash")) - writer.uint32(/* id 10, wireType 2 =*/82).string(message.mainParentHash); - if (message.parentsHashList != null && message.parentsHashList.length) - for (var i = 0; i < message.parentsHashList.length; ++i) - writer.uint32(/* id 11, wireType 2 =*/90).string(message.parentsHashList[i]); - if (message.sender != null && message.hasOwnProperty("sender")) - writer.uint32(/* id 12, wireType 2 =*/98).string(message.sender); - if (message.shardId != null && message.hasOwnProperty("shardId")) - writer.uint32(/* id 13, wireType 2 =*/106).string(message.shardId); - if (message.bondsValidatorList != null && message.bondsValidatorList.length) - for (var i = 0; i < message.bondsValidatorList.length; ++i) - writer.uint32(/* id 14, wireType 2 =*/114).string(message.bondsValidatorList[i]); - if (message.deployCost != null && message.deployCost.length) - for (var i = 0; i < message.deployCost.length; ++i) - writer.uint32(/* id 15, wireType 2 =*/122).string(message.deployCost[i]); - return writer; - }; - - /** - * Encodes the specified BlockInfo message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.BlockInfo.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.BlockInfo - * @static - * @param {coop.rchain.casper.protocol.IBlockInfo} message BlockInfo message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockInfo.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a BlockInfo message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.BlockInfo - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.BlockInfo} BlockInfo - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockInfo.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.BlockInfo(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.blockHash = reader.string(); - break; - case 2: - message.blockSize = reader.string(); - break; - case 3: - message.blockNumber = reader.int64(); - break; - case 4: - message.version = reader.int64(); - break; - case 5: - message.deployCount = reader.int32(); - break; - case 6: - message.tupleSpaceHash = reader.string(); - break; - case 7: - message.tupleSpaceDump = reader.string(); - break; - case 8: - message.timestamp = reader.int64(); - break; - case 9: - message.faultTolerance = reader.float(); - break; - case 10: - message.mainParentHash = reader.string(); - break; - case 11: - if (!(message.parentsHashList && message.parentsHashList.length)) - message.parentsHashList = []; - message.parentsHashList.push(reader.string()); - break; - case 12: - message.sender = reader.string(); - break; - case 13: - message.shardId = reader.string(); - break; - case 14: - if (!(message.bondsValidatorList && message.bondsValidatorList.length)) - message.bondsValidatorList = []; - message.bondsValidatorList.push(reader.string()); - break; - case 15: - if (!(message.deployCost && message.deployCost.length)) - message.deployCost = []; - message.deployCost.push(reader.string()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a BlockInfo message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.BlockInfo - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.BlockInfo} BlockInfo - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockInfo.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a BlockInfo message. - * @function verify - * @memberof coop.rchain.casper.protocol.BlockInfo - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - BlockInfo.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.blockHash != null && message.hasOwnProperty("blockHash")) - if (!$util.isString(message.blockHash)) - return "blockHash: string expected"; - if (message.blockSize != null && message.hasOwnProperty("blockSize")) - if (!$util.isString(message.blockSize)) - return "blockSize: string expected"; - if (message.blockNumber != null && message.hasOwnProperty("blockNumber")) - if (!$util.isInteger(message.blockNumber) && !(message.blockNumber && $util.isInteger(message.blockNumber.low) && $util.isInteger(message.blockNumber.high))) - return "blockNumber: integer|Long expected"; - if (message.version != null && message.hasOwnProperty("version")) - if (!$util.isInteger(message.version) && !(message.version && $util.isInteger(message.version.low) && $util.isInteger(message.version.high))) - return "version: integer|Long expected"; - if (message.deployCount != null && message.hasOwnProperty("deployCount")) - if (!$util.isInteger(message.deployCount)) - return "deployCount: integer expected"; - if (message.tupleSpaceHash != null && message.hasOwnProperty("tupleSpaceHash")) - if (!$util.isString(message.tupleSpaceHash)) - return "tupleSpaceHash: string expected"; - if (message.tupleSpaceDump != null && message.hasOwnProperty("tupleSpaceDump")) - if (!$util.isString(message.tupleSpaceDump)) - return "tupleSpaceDump: string expected"; - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high))) - return "timestamp: integer|Long expected"; - if (message.faultTolerance != null && message.hasOwnProperty("faultTolerance")) - if (typeof message.faultTolerance !== "number") - return "faultTolerance: number expected"; - if (message.mainParentHash != null && message.hasOwnProperty("mainParentHash")) - if (!$util.isString(message.mainParentHash)) - return "mainParentHash: string expected"; - if (message.parentsHashList != null && message.hasOwnProperty("parentsHashList")) { - if (!Array.isArray(message.parentsHashList)) - return "parentsHashList: array expected"; - for (var i = 0; i < message.parentsHashList.length; ++i) - if (!$util.isString(message.parentsHashList[i])) - return "parentsHashList: string[] expected"; - } - if (message.sender != null && message.hasOwnProperty("sender")) - if (!$util.isString(message.sender)) - return "sender: string expected"; - if (message.shardId != null && message.hasOwnProperty("shardId")) - if (!$util.isString(message.shardId)) - return "shardId: string expected"; - if (message.bondsValidatorList != null && message.hasOwnProperty("bondsValidatorList")) { - if (!Array.isArray(message.bondsValidatorList)) - return "bondsValidatorList: array expected"; - for (var i = 0; i < message.bondsValidatorList.length; ++i) - if (!$util.isString(message.bondsValidatorList[i])) - return "bondsValidatorList: string[] expected"; - } - if (message.deployCost != null && message.hasOwnProperty("deployCost")) { - if (!Array.isArray(message.deployCost)) - return "deployCost: array expected"; - for (var i = 0; i < message.deployCost.length; ++i) - if (!$util.isString(message.deployCost[i])) - return "deployCost: string[] expected"; - } - return null; - }; - - /** - * Creates a BlockInfo message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.BlockInfo - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.BlockInfo} BlockInfo - */ - BlockInfo.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.BlockInfo) - return object; - var message = new $root.coop.rchain.casper.protocol.BlockInfo(); - if (object.blockHash != null) - message.blockHash = String(object.blockHash); - if (object.blockSize != null) - message.blockSize = String(object.blockSize); - if (object.blockNumber != null) - if ($util.Long) - (message.blockNumber = $util.Long.fromValue(object.blockNumber)).unsigned = false; - else if (typeof object.blockNumber === "string") - message.blockNumber = parseInt(object.blockNumber, 10); - else if (typeof object.blockNumber === "number") - message.blockNumber = object.blockNumber; - else if (typeof object.blockNumber === "object") - message.blockNumber = new $util.LongBits(object.blockNumber.low >>> 0, object.blockNumber.high >>> 0).toNumber(); - if (object.version != null) - if ($util.Long) - (message.version = $util.Long.fromValue(object.version)).unsigned = false; - else if (typeof object.version === "string") - message.version = parseInt(object.version, 10); - else if (typeof object.version === "number") - message.version = object.version; - else if (typeof object.version === "object") - message.version = new $util.LongBits(object.version.low >>> 0, object.version.high >>> 0).toNumber(); - if (object.deployCount != null) - message.deployCount = object.deployCount | 0; - if (object.tupleSpaceHash != null) - message.tupleSpaceHash = String(object.tupleSpaceHash); - if (object.tupleSpaceDump != null) - message.tupleSpaceDump = String(object.tupleSpaceDump); - if (object.timestamp != null) - if ($util.Long) - (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = false; - else if (typeof object.timestamp === "string") - message.timestamp = parseInt(object.timestamp, 10); - else if (typeof object.timestamp === "number") - message.timestamp = object.timestamp; - else if (typeof object.timestamp === "object") - message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber(); - if (object.faultTolerance != null) - message.faultTolerance = Number(object.faultTolerance); - if (object.mainParentHash != null) - message.mainParentHash = String(object.mainParentHash); - if (object.parentsHashList) { - if (!Array.isArray(object.parentsHashList)) - throw TypeError(".coop.rchain.casper.protocol.BlockInfo.parentsHashList: array expected"); - message.parentsHashList = []; - for (var i = 0; i < object.parentsHashList.length; ++i) - message.parentsHashList[i] = String(object.parentsHashList[i]); - } - if (object.sender != null) - message.sender = String(object.sender); - if (object.shardId != null) - message.shardId = String(object.shardId); - if (object.bondsValidatorList) { - if (!Array.isArray(object.bondsValidatorList)) - throw TypeError(".coop.rchain.casper.protocol.BlockInfo.bondsValidatorList: array expected"); - message.bondsValidatorList = []; - for (var i = 0; i < object.bondsValidatorList.length; ++i) - message.bondsValidatorList[i] = String(object.bondsValidatorList[i]); - } - if (object.deployCost) { - if (!Array.isArray(object.deployCost)) - throw TypeError(".coop.rchain.casper.protocol.BlockInfo.deployCost: array expected"); - message.deployCost = []; - for (var i = 0; i < object.deployCost.length; ++i) - message.deployCost[i] = String(object.deployCost[i]); - } - return message; - }; - - /** - * Creates a plain object from a BlockInfo message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.BlockInfo - * @static - * @param {coop.rchain.casper.protocol.BlockInfo} message BlockInfo - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - BlockInfo.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) { - object.parentsHashList = []; - object.bondsValidatorList = []; - object.deployCost = []; - } - if (options.defaults) { - object.blockHash = ""; - object.blockSize = ""; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.blockNumber = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.blockNumber = options.longs === String ? "0" : 0; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.version = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.version = options.longs === String ? "0" : 0; - object.deployCount = 0; - object.tupleSpaceHash = ""; - object.tupleSpaceDump = ""; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.timestamp = options.longs === String ? "0" : 0; - object.faultTolerance = 0; - object.mainParentHash = ""; - object.sender = ""; - object.shardId = ""; - } - if (message.blockHash != null && message.hasOwnProperty("blockHash")) - object.blockHash = message.blockHash; - if (message.blockSize != null && message.hasOwnProperty("blockSize")) - object.blockSize = message.blockSize; - if (message.blockNumber != null && message.hasOwnProperty("blockNumber")) - if (typeof message.blockNumber === "number") - object.blockNumber = options.longs === String ? String(message.blockNumber) : message.blockNumber; - else - object.blockNumber = options.longs === String ? $util.Long.prototype.toString.call(message.blockNumber) : options.longs === Number ? new $util.LongBits(message.blockNumber.low >>> 0, message.blockNumber.high >>> 0).toNumber() : message.blockNumber; - if (message.version != null && message.hasOwnProperty("version")) - if (typeof message.version === "number") - object.version = options.longs === String ? String(message.version) : message.version; - else - object.version = options.longs === String ? $util.Long.prototype.toString.call(message.version) : options.longs === Number ? new $util.LongBits(message.version.low >>> 0, message.version.high >>> 0).toNumber() : message.version; - if (message.deployCount != null && message.hasOwnProperty("deployCount")) - object.deployCount = message.deployCount; - if (message.tupleSpaceHash != null && message.hasOwnProperty("tupleSpaceHash")) - object.tupleSpaceHash = message.tupleSpaceHash; - if (message.tupleSpaceDump != null && message.hasOwnProperty("tupleSpaceDump")) - object.tupleSpaceDump = message.tupleSpaceDump; - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (typeof message.timestamp === "number") - object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp; - else - object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber() : message.timestamp; - if (message.faultTolerance != null && message.hasOwnProperty("faultTolerance")) - object.faultTolerance = options.json && !isFinite(message.faultTolerance) ? String(message.faultTolerance) : message.faultTolerance; - if (message.mainParentHash != null && message.hasOwnProperty("mainParentHash")) - object.mainParentHash = message.mainParentHash; - if (message.parentsHashList && message.parentsHashList.length) { - object.parentsHashList = []; - for (var j = 0; j < message.parentsHashList.length; ++j) - object.parentsHashList[j] = message.parentsHashList[j]; - } - if (message.sender != null && message.hasOwnProperty("sender")) - object.sender = message.sender; - if (message.shardId != null && message.hasOwnProperty("shardId")) - object.shardId = message.shardId; - if (message.bondsValidatorList && message.bondsValidatorList.length) { - object.bondsValidatorList = []; - for (var j = 0; j < message.bondsValidatorList.length; ++j) - object.bondsValidatorList[j] = message.bondsValidatorList[j]; - } - if (message.deployCost && message.deployCost.length) { - object.deployCost = []; - for (var j = 0; j < message.deployCost.length; ++j) - object.deployCost[j] = message.deployCost[j]; - } - return object; - }; - - /** - * Converts this BlockInfo to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.BlockInfo - * @instance - * @returns {Object.} JSON object - */ - BlockInfo.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return BlockInfo; - })(); - - protocol.PrivateNamePreviewQuery = (function() { - - /** - * Properties of a PrivateNamePreviewQuery. - * @memberof coop.rchain.casper.protocol - * @interface IPrivateNamePreviewQuery - * @property {Uint8Array|null} [user] PrivateNamePreviewQuery user - * @property {number|Long|null} [timestamp] PrivateNamePreviewQuery timestamp - * @property {number|null} [nameQty] PrivateNamePreviewQuery nameQty - */ - - /** - * Constructs a new PrivateNamePreviewQuery. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a PrivateNamePreviewQuery. - * @implements IPrivateNamePreviewQuery - * @constructor - * @param {coop.rchain.casper.protocol.IPrivateNamePreviewQuery=} [properties] Properties to set - */ - function PrivateNamePreviewQuery(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * PrivateNamePreviewQuery user. - * @member {Uint8Array} user - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewQuery - * @instance - */ - PrivateNamePreviewQuery.prototype.user = $util.newBuffer([]); - - /** - * PrivateNamePreviewQuery timestamp. - * @member {number|Long} timestamp - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewQuery - * @instance - */ - PrivateNamePreviewQuery.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * PrivateNamePreviewQuery nameQty. - * @member {number} nameQty - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewQuery - * @instance - */ - PrivateNamePreviewQuery.prototype.nameQty = 0; - - /** - * Creates a new PrivateNamePreviewQuery instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewQuery - * @static - * @param {coop.rchain.casper.protocol.IPrivateNamePreviewQuery=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.PrivateNamePreviewQuery} PrivateNamePreviewQuery instance - */ - PrivateNamePreviewQuery.create = function create(properties) { - return new PrivateNamePreviewQuery(properties); - }; - - /** - * Encodes the specified PrivateNamePreviewQuery message. Does not implicitly {@link coop.rchain.casper.protocol.PrivateNamePreviewQuery.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewQuery - * @static - * @param {coop.rchain.casper.protocol.IPrivateNamePreviewQuery} message PrivateNamePreviewQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - PrivateNamePreviewQuery.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.user != null && message.hasOwnProperty("user")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.user); - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - writer.uint32(/* id 2, wireType 0 =*/16).int64(message.timestamp); - if (message.nameQty != null && message.hasOwnProperty("nameQty")) - writer.uint32(/* id 3, wireType 0 =*/24).int32(message.nameQty); - return writer; - }; - - /** - * Encodes the specified PrivateNamePreviewQuery message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.PrivateNamePreviewQuery.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewQuery - * @static - * @param {coop.rchain.casper.protocol.IPrivateNamePreviewQuery} message PrivateNamePreviewQuery message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - PrivateNamePreviewQuery.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a PrivateNamePreviewQuery message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.PrivateNamePreviewQuery} PrivateNamePreviewQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - PrivateNamePreviewQuery.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.PrivateNamePreviewQuery(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.user = reader.bytes(); - break; - case 2: - message.timestamp = reader.int64(); - break; - case 3: - message.nameQty = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a PrivateNamePreviewQuery message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewQuery - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.PrivateNamePreviewQuery} PrivateNamePreviewQuery - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - PrivateNamePreviewQuery.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a PrivateNamePreviewQuery message. - * @function verify - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewQuery - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - PrivateNamePreviewQuery.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.user != null && message.hasOwnProperty("user")) - if (!(message.user && typeof message.user.length === "number" || $util.isString(message.user))) - return "user: buffer expected"; - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high))) - return "timestamp: integer|Long expected"; - if (message.nameQty != null && message.hasOwnProperty("nameQty")) - if (!$util.isInteger(message.nameQty)) - return "nameQty: integer expected"; - return null; - }; - - /** - * Creates a PrivateNamePreviewQuery message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewQuery - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.PrivateNamePreviewQuery} PrivateNamePreviewQuery - */ - PrivateNamePreviewQuery.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.PrivateNamePreviewQuery) - return object; - var message = new $root.coop.rchain.casper.protocol.PrivateNamePreviewQuery(); - if (object.user != null) - if (typeof object.user === "string") - $util.base64.decode(object.user, message.user = $util.newBuffer($util.base64.length(object.user)), 0); - else if (object.user.length) - message.user = object.user; - if (object.timestamp != null) - if ($util.Long) - (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = false; - else if (typeof object.timestamp === "string") - message.timestamp = parseInt(object.timestamp, 10); - else if (typeof object.timestamp === "number") - message.timestamp = object.timestamp; - else if (typeof object.timestamp === "object") - message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber(); - if (object.nameQty != null) - message.nameQty = object.nameQty | 0; - return message; - }; - - /** - * Creates a plain object from a PrivateNamePreviewQuery message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewQuery - * @static - * @param {coop.rchain.casper.protocol.PrivateNamePreviewQuery} message PrivateNamePreviewQuery - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - PrivateNamePreviewQuery.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if (options.bytes === String) - object.user = ""; - else { - object.user = []; - if (options.bytes !== Array) - object.user = $util.newBuffer(object.user); - } - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.timestamp = options.longs === String ? "0" : 0; - object.nameQty = 0; - } - if (message.user != null && message.hasOwnProperty("user")) - object.user = options.bytes === String ? $util.base64.encode(message.user, 0, message.user.length) : options.bytes === Array ? Array.prototype.slice.call(message.user) : message.user; - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (typeof message.timestamp === "number") - object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp; - else - object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber() : message.timestamp; - if (message.nameQty != null && message.hasOwnProperty("nameQty")) - object.nameQty = message.nameQty; - return object; - }; - - /** - * Converts this PrivateNamePreviewQuery to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewQuery - * @instance - * @returns {Object.} JSON object - */ - PrivateNamePreviewQuery.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return PrivateNamePreviewQuery; - })(); - - protocol.PrivateNamePreviewResponse = (function() { - - /** - * Properties of a PrivateNamePreviewResponse. - * @memberof coop.rchain.casper.protocol - * @interface IPrivateNamePreviewResponse - * @property {Array.|null} [ids] PrivateNamePreviewResponse ids - */ - - /** - * Constructs a new PrivateNamePreviewResponse. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a PrivateNamePreviewResponse. - * @implements IPrivateNamePreviewResponse - * @constructor - * @param {coop.rchain.casper.protocol.IPrivateNamePreviewResponse=} [properties] Properties to set - */ - function PrivateNamePreviewResponse(properties) { - this.ids = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * PrivateNamePreviewResponse ids. - * @member {Array.} ids - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewResponse - * @instance - */ - PrivateNamePreviewResponse.prototype.ids = $util.emptyArray; - - /** - * Creates a new PrivateNamePreviewResponse instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewResponse - * @static - * @param {coop.rchain.casper.protocol.IPrivateNamePreviewResponse=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.PrivateNamePreviewResponse} PrivateNamePreviewResponse instance - */ - PrivateNamePreviewResponse.create = function create(properties) { - return new PrivateNamePreviewResponse(properties); - }; - - /** - * Encodes the specified PrivateNamePreviewResponse message. Does not implicitly {@link coop.rchain.casper.protocol.PrivateNamePreviewResponse.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewResponse - * @static - * @param {coop.rchain.casper.protocol.IPrivateNamePreviewResponse} message PrivateNamePreviewResponse message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - PrivateNamePreviewResponse.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.ids != null && message.ids.length) - for (var i = 0; i < message.ids.length; ++i) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.ids[i]); - return writer; - }; - - /** - * Encodes the specified PrivateNamePreviewResponse message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.PrivateNamePreviewResponse.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewResponse - * @static - * @param {coop.rchain.casper.protocol.IPrivateNamePreviewResponse} message PrivateNamePreviewResponse message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - PrivateNamePreviewResponse.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a PrivateNamePreviewResponse message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewResponse - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.PrivateNamePreviewResponse} PrivateNamePreviewResponse - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - PrivateNamePreviewResponse.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.PrivateNamePreviewResponse(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.ids && message.ids.length)) - message.ids = []; - message.ids.push(reader.bytes()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a PrivateNamePreviewResponse message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewResponse - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.PrivateNamePreviewResponse} PrivateNamePreviewResponse - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - PrivateNamePreviewResponse.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a PrivateNamePreviewResponse message. - * @function verify - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewResponse - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - PrivateNamePreviewResponse.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.ids != null && message.hasOwnProperty("ids")) { - if (!Array.isArray(message.ids)) - return "ids: array expected"; - for (var i = 0; i < message.ids.length; ++i) - if (!(message.ids[i] && typeof message.ids[i].length === "number" || $util.isString(message.ids[i]))) - return "ids: buffer[] expected"; - } - return null; - }; - - /** - * Creates a PrivateNamePreviewResponse message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewResponse - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.PrivateNamePreviewResponse} PrivateNamePreviewResponse - */ - PrivateNamePreviewResponse.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.PrivateNamePreviewResponse) - return object; - var message = new $root.coop.rchain.casper.protocol.PrivateNamePreviewResponse(); - if (object.ids) { - if (!Array.isArray(object.ids)) - throw TypeError(".coop.rchain.casper.protocol.PrivateNamePreviewResponse.ids: array expected"); - message.ids = []; - for (var i = 0; i < object.ids.length; ++i) - if (typeof object.ids[i] === "string") - $util.base64.decode(object.ids[i], message.ids[i] = $util.newBuffer($util.base64.length(object.ids[i])), 0); - else if (object.ids[i].length) - message.ids[i] = object.ids[i]; - } - return message; - }; - - /** - * Creates a plain object from a PrivateNamePreviewResponse message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewResponse - * @static - * @param {coop.rchain.casper.protocol.PrivateNamePreviewResponse} message PrivateNamePreviewResponse - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - PrivateNamePreviewResponse.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.ids = []; - if (message.ids && message.ids.length) { - object.ids = []; - for (var j = 0; j < message.ids.length; ++j) - object.ids[j] = options.bytes === String ? $util.base64.encode(message.ids[j], 0, message.ids[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.ids[j]) : message.ids[j]; - } - return object; - }; - - /** - * Converts this PrivateNamePreviewResponse to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.PrivateNamePreviewResponse - * @instance - * @returns {Object.} JSON object - */ - PrivateNamePreviewResponse.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return PrivateNamePreviewResponse; - })(); - - protocol.ApprovedBlockCandidate = (function() { - - /** - * Properties of an ApprovedBlockCandidate. - * @memberof coop.rchain.casper.protocol - * @interface IApprovedBlockCandidate - * @property {coop.rchain.casper.protocol.IBlockMessage|null} [block] ApprovedBlockCandidate block - * @property {number|null} [requiredSigs] ApprovedBlockCandidate requiredSigs - */ - - /** - * Constructs a new ApprovedBlockCandidate. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents an ApprovedBlockCandidate. - * @implements IApprovedBlockCandidate - * @constructor - * @param {coop.rchain.casper.protocol.IApprovedBlockCandidate=} [properties] Properties to set - */ - function ApprovedBlockCandidate(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ApprovedBlockCandidate block. - * @member {coop.rchain.casper.protocol.IBlockMessage|null|undefined} block - * @memberof coop.rchain.casper.protocol.ApprovedBlockCandidate - * @instance - */ - ApprovedBlockCandidate.prototype.block = null; - - /** - * ApprovedBlockCandidate requiredSigs. - * @member {number} requiredSigs - * @memberof coop.rchain.casper.protocol.ApprovedBlockCandidate - * @instance - */ - ApprovedBlockCandidate.prototype.requiredSigs = 0; - - /** - * Creates a new ApprovedBlockCandidate instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.ApprovedBlockCandidate - * @static - * @param {coop.rchain.casper.protocol.IApprovedBlockCandidate=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.ApprovedBlockCandidate} ApprovedBlockCandidate instance - */ - ApprovedBlockCandidate.create = function create(properties) { - return new ApprovedBlockCandidate(properties); - }; - - /** - * Encodes the specified ApprovedBlockCandidate message. Does not implicitly {@link coop.rchain.casper.protocol.ApprovedBlockCandidate.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.ApprovedBlockCandidate - * @static - * @param {coop.rchain.casper.protocol.IApprovedBlockCandidate} message ApprovedBlockCandidate message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ApprovedBlockCandidate.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.block != null && message.hasOwnProperty("block")) - $root.coop.rchain.casper.protocol.BlockMessage.encode(message.block, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.requiredSigs != null && message.hasOwnProperty("requiredSigs")) - writer.uint32(/* id 2, wireType 0 =*/16).int32(message.requiredSigs); - return writer; - }; - - /** - * Encodes the specified ApprovedBlockCandidate message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.ApprovedBlockCandidate.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.ApprovedBlockCandidate - * @static - * @param {coop.rchain.casper.protocol.IApprovedBlockCandidate} message ApprovedBlockCandidate message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ApprovedBlockCandidate.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an ApprovedBlockCandidate message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.ApprovedBlockCandidate - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.ApprovedBlockCandidate} ApprovedBlockCandidate - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ApprovedBlockCandidate.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.ApprovedBlockCandidate(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.block = $root.coop.rchain.casper.protocol.BlockMessage.decode(reader, reader.uint32()); - break; - case 2: - message.requiredSigs = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an ApprovedBlockCandidate message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.ApprovedBlockCandidate - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.ApprovedBlockCandidate} ApprovedBlockCandidate - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ApprovedBlockCandidate.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an ApprovedBlockCandidate message. - * @function verify - * @memberof coop.rchain.casper.protocol.ApprovedBlockCandidate - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ApprovedBlockCandidate.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.block != null && message.hasOwnProperty("block")) { - var error = $root.coop.rchain.casper.protocol.BlockMessage.verify(message.block); - if (error) - return "block." + error; - } - if (message.requiredSigs != null && message.hasOwnProperty("requiredSigs")) - if (!$util.isInteger(message.requiredSigs)) - return "requiredSigs: integer expected"; - return null; - }; - - /** - * Creates an ApprovedBlockCandidate message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.ApprovedBlockCandidate - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.ApprovedBlockCandidate} ApprovedBlockCandidate - */ - ApprovedBlockCandidate.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.ApprovedBlockCandidate) - return object; - var message = new $root.coop.rchain.casper.protocol.ApprovedBlockCandidate(); - if (object.block != null) { - if (typeof object.block !== "object") - throw TypeError(".coop.rchain.casper.protocol.ApprovedBlockCandidate.block: object expected"); - message.block = $root.coop.rchain.casper.protocol.BlockMessage.fromObject(object.block); - } - if (object.requiredSigs != null) - message.requiredSigs = object.requiredSigs | 0; - return message; - }; - - /** - * Creates a plain object from an ApprovedBlockCandidate message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.ApprovedBlockCandidate - * @static - * @param {coop.rchain.casper.protocol.ApprovedBlockCandidate} message ApprovedBlockCandidate - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ApprovedBlockCandidate.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.block = null; - object.requiredSigs = 0; - } - if (message.block != null && message.hasOwnProperty("block")) - object.block = $root.coop.rchain.casper.protocol.BlockMessage.toObject(message.block, options); - if (message.requiredSigs != null && message.hasOwnProperty("requiredSigs")) - object.requiredSigs = message.requiredSigs; - return object; - }; - - /** - * Converts this ApprovedBlockCandidate to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.ApprovedBlockCandidate - * @instance - * @returns {Object.} JSON object - */ - ApprovedBlockCandidate.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ApprovedBlockCandidate; - })(); - - protocol.UnapprovedBlock = (function() { - - /** - * Properties of an UnapprovedBlock. - * @memberof coop.rchain.casper.protocol - * @interface IUnapprovedBlock - * @property {coop.rchain.casper.protocol.IApprovedBlockCandidate|null} [candidate] UnapprovedBlock candidate - * @property {number|Long|null} [timestamp] UnapprovedBlock timestamp - * @property {number|Long|null} [duration] UnapprovedBlock duration - */ - - /** - * Constructs a new UnapprovedBlock. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents an UnapprovedBlock. - * @implements IUnapprovedBlock - * @constructor - * @param {coop.rchain.casper.protocol.IUnapprovedBlock=} [properties] Properties to set - */ - function UnapprovedBlock(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UnapprovedBlock candidate. - * @member {coop.rchain.casper.protocol.IApprovedBlockCandidate|null|undefined} candidate - * @memberof coop.rchain.casper.protocol.UnapprovedBlock - * @instance - */ - UnapprovedBlock.prototype.candidate = null; - - /** - * UnapprovedBlock timestamp. - * @member {number|Long} timestamp - * @memberof coop.rchain.casper.protocol.UnapprovedBlock - * @instance - */ - UnapprovedBlock.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * UnapprovedBlock duration. - * @member {number|Long} duration - * @memberof coop.rchain.casper.protocol.UnapprovedBlock - * @instance - */ - UnapprovedBlock.prototype.duration = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Creates a new UnapprovedBlock instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.UnapprovedBlock - * @static - * @param {coop.rchain.casper.protocol.IUnapprovedBlock=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.UnapprovedBlock} UnapprovedBlock instance - */ - UnapprovedBlock.create = function create(properties) { - return new UnapprovedBlock(properties); - }; - - /** - * Encodes the specified UnapprovedBlock message. Does not implicitly {@link coop.rchain.casper.protocol.UnapprovedBlock.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.UnapprovedBlock - * @static - * @param {coop.rchain.casper.protocol.IUnapprovedBlock} message UnapprovedBlock message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - UnapprovedBlock.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.candidate != null && message.hasOwnProperty("candidate")) - $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.encode(message.candidate, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - writer.uint32(/* id 2, wireType 0 =*/16).int64(message.timestamp); - if (message.duration != null && message.hasOwnProperty("duration")) - writer.uint32(/* id 3, wireType 0 =*/24).int64(message.duration); - return writer; - }; - - /** - * Encodes the specified UnapprovedBlock message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.UnapprovedBlock.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.UnapprovedBlock - * @static - * @param {coop.rchain.casper.protocol.IUnapprovedBlock} message UnapprovedBlock message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - UnapprovedBlock.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an UnapprovedBlock message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.UnapprovedBlock - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.UnapprovedBlock} UnapprovedBlock - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - UnapprovedBlock.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.UnapprovedBlock(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.candidate = $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.decode(reader, reader.uint32()); - break; - case 2: - message.timestamp = reader.int64(); - break; - case 3: - message.duration = reader.int64(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an UnapprovedBlock message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.UnapprovedBlock - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.UnapprovedBlock} UnapprovedBlock - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - UnapprovedBlock.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an UnapprovedBlock message. - * @function verify - * @memberof coop.rchain.casper.protocol.UnapprovedBlock - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - UnapprovedBlock.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.candidate != null && message.hasOwnProperty("candidate")) { - var error = $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.verify(message.candidate); - if (error) - return "candidate." + error; - } - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high))) - return "timestamp: integer|Long expected"; - if (message.duration != null && message.hasOwnProperty("duration")) - if (!$util.isInteger(message.duration) && !(message.duration && $util.isInteger(message.duration.low) && $util.isInteger(message.duration.high))) - return "duration: integer|Long expected"; - return null; - }; - - /** - * Creates an UnapprovedBlock message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.UnapprovedBlock - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.UnapprovedBlock} UnapprovedBlock - */ - UnapprovedBlock.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.UnapprovedBlock) - return object; - var message = new $root.coop.rchain.casper.protocol.UnapprovedBlock(); - if (object.candidate != null) { - if (typeof object.candidate !== "object") - throw TypeError(".coop.rchain.casper.protocol.UnapprovedBlock.candidate: object expected"); - message.candidate = $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.fromObject(object.candidate); - } - if (object.timestamp != null) - if ($util.Long) - (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = false; - else if (typeof object.timestamp === "string") - message.timestamp = parseInt(object.timestamp, 10); - else if (typeof object.timestamp === "number") - message.timestamp = object.timestamp; - else if (typeof object.timestamp === "object") - message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber(); - if (object.duration != null) - if ($util.Long) - (message.duration = $util.Long.fromValue(object.duration)).unsigned = false; - else if (typeof object.duration === "string") - message.duration = parseInt(object.duration, 10); - else if (typeof object.duration === "number") - message.duration = object.duration; - else if (typeof object.duration === "object") - message.duration = new $util.LongBits(object.duration.low >>> 0, object.duration.high >>> 0).toNumber(); - return message; - }; - - /** - * Creates a plain object from an UnapprovedBlock message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.UnapprovedBlock - * @static - * @param {coop.rchain.casper.protocol.UnapprovedBlock} message UnapprovedBlock - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - UnapprovedBlock.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.candidate = null; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.timestamp = options.longs === String ? "0" : 0; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.duration = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.duration = options.longs === String ? "0" : 0; - } - if (message.candidate != null && message.hasOwnProperty("candidate")) - object.candidate = $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.toObject(message.candidate, options); - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (typeof message.timestamp === "number") - object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp; - else - object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber() : message.timestamp; - if (message.duration != null && message.hasOwnProperty("duration")) - if (typeof message.duration === "number") - object.duration = options.longs === String ? String(message.duration) : message.duration; - else - object.duration = options.longs === String ? $util.Long.prototype.toString.call(message.duration) : options.longs === Number ? new $util.LongBits(message.duration.low >>> 0, message.duration.high >>> 0).toNumber() : message.duration; - return object; - }; - - /** - * Converts this UnapprovedBlock to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.UnapprovedBlock - * @instance - * @returns {Object.} JSON object - */ - UnapprovedBlock.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return UnapprovedBlock; - })(); - - protocol.Signature = (function() { - - /** - * Properties of a Signature. - * @memberof coop.rchain.casper.protocol - * @interface ISignature - * @property {Uint8Array|null} [publicKey] Signature publicKey - * @property {string|null} [algorithm] Signature algorithm - * @property {Uint8Array|null} [sig] Signature sig - */ - - /** - * Constructs a new Signature. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a Signature. - * @implements ISignature - * @constructor - * @param {coop.rchain.casper.protocol.ISignature=} [properties] Properties to set - */ - function Signature(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Signature publicKey. - * @member {Uint8Array} publicKey - * @memberof coop.rchain.casper.protocol.Signature - * @instance - */ - Signature.prototype.publicKey = $util.newBuffer([]); - - /** - * Signature algorithm. - * @member {string} algorithm - * @memberof coop.rchain.casper.protocol.Signature - * @instance - */ - Signature.prototype.algorithm = ""; - - /** - * Signature sig. - * @member {Uint8Array} sig - * @memberof coop.rchain.casper.protocol.Signature - * @instance - */ - Signature.prototype.sig = $util.newBuffer([]); - - /** - * Creates a new Signature instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.Signature - * @static - * @param {coop.rchain.casper.protocol.ISignature=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.Signature} Signature instance - */ - Signature.create = function create(properties) { - return new Signature(properties); - }; - - /** - * Encodes the specified Signature message. Does not implicitly {@link coop.rchain.casper.protocol.Signature.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.Signature - * @static - * @param {coop.rchain.casper.protocol.ISignature} message Signature message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Signature.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.publicKey != null && message.hasOwnProperty("publicKey")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.publicKey); - if (message.algorithm != null && message.hasOwnProperty("algorithm")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.algorithm); - if (message.sig != null && message.hasOwnProperty("sig")) - writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.sig); - return writer; - }; - - /** - * Encodes the specified Signature message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.Signature.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.Signature - * @static - * @param {coop.rchain.casper.protocol.ISignature} message Signature message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Signature.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Signature message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.Signature - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.Signature} Signature - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Signature.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.Signature(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.publicKey = reader.bytes(); - break; - case 2: - message.algorithm = reader.string(); - break; - case 3: - message.sig = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Signature message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.Signature - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.Signature} Signature - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Signature.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Signature message. - * @function verify - * @memberof coop.rchain.casper.protocol.Signature - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Signature.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.publicKey != null && message.hasOwnProperty("publicKey")) - if (!(message.publicKey && typeof message.publicKey.length === "number" || $util.isString(message.publicKey))) - return "publicKey: buffer expected"; - if (message.algorithm != null && message.hasOwnProperty("algorithm")) - if (!$util.isString(message.algorithm)) - return "algorithm: string expected"; - if (message.sig != null && message.hasOwnProperty("sig")) - if (!(message.sig && typeof message.sig.length === "number" || $util.isString(message.sig))) - return "sig: buffer expected"; - return null; - }; - - /** - * Creates a Signature message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.Signature - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.Signature} Signature - */ - Signature.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.Signature) - return object; - var message = new $root.coop.rchain.casper.protocol.Signature(); - if (object.publicKey != null) - if (typeof object.publicKey === "string") - $util.base64.decode(object.publicKey, message.publicKey = $util.newBuffer($util.base64.length(object.publicKey)), 0); - else if (object.publicKey.length) - message.publicKey = object.publicKey; - if (object.algorithm != null) - message.algorithm = String(object.algorithm); - if (object.sig != null) - if (typeof object.sig === "string") - $util.base64.decode(object.sig, message.sig = $util.newBuffer($util.base64.length(object.sig)), 0); - else if (object.sig.length) - message.sig = object.sig; - return message; - }; - - /** - * Creates a plain object from a Signature message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.Signature - * @static - * @param {coop.rchain.casper.protocol.Signature} message Signature - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Signature.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if (options.bytes === String) - object.publicKey = ""; - else { - object.publicKey = []; - if (options.bytes !== Array) - object.publicKey = $util.newBuffer(object.publicKey); - } - object.algorithm = ""; - if (options.bytes === String) - object.sig = ""; - else { - object.sig = []; - if (options.bytes !== Array) - object.sig = $util.newBuffer(object.sig); - } - } - if (message.publicKey != null && message.hasOwnProperty("publicKey")) - object.publicKey = options.bytes === String ? $util.base64.encode(message.publicKey, 0, message.publicKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.publicKey) : message.publicKey; - if (message.algorithm != null && message.hasOwnProperty("algorithm")) - object.algorithm = message.algorithm; - if (message.sig != null && message.hasOwnProperty("sig")) - object.sig = options.bytes === String ? $util.base64.encode(message.sig, 0, message.sig.length) : options.bytes === Array ? Array.prototype.slice.call(message.sig) : message.sig; - return object; - }; - - /** - * Converts this Signature to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.Signature - * @instance - * @returns {Object.} JSON object - */ - Signature.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Signature; - })(); - - protocol.BlockApproval = (function() { - - /** - * Properties of a BlockApproval. - * @memberof coop.rchain.casper.protocol - * @interface IBlockApproval - * @property {coop.rchain.casper.protocol.IApprovedBlockCandidate|null} [candidate] BlockApproval candidate - * @property {coop.rchain.casper.protocol.ISignature|null} [sig] BlockApproval sig - */ - - /** - * Constructs a new BlockApproval. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a BlockApproval. - * @implements IBlockApproval - * @constructor - * @param {coop.rchain.casper.protocol.IBlockApproval=} [properties] Properties to set - */ - function BlockApproval(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BlockApproval candidate. - * @member {coop.rchain.casper.protocol.IApprovedBlockCandidate|null|undefined} candidate - * @memberof coop.rchain.casper.protocol.BlockApproval - * @instance - */ - BlockApproval.prototype.candidate = null; - - /** - * BlockApproval sig. - * @member {coop.rchain.casper.protocol.ISignature|null|undefined} sig - * @memberof coop.rchain.casper.protocol.BlockApproval - * @instance - */ - BlockApproval.prototype.sig = null; - - /** - * Creates a new BlockApproval instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.BlockApproval - * @static - * @param {coop.rchain.casper.protocol.IBlockApproval=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.BlockApproval} BlockApproval instance - */ - BlockApproval.create = function create(properties) { - return new BlockApproval(properties); - }; - - /** - * Encodes the specified BlockApproval message. Does not implicitly {@link coop.rchain.casper.protocol.BlockApproval.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.BlockApproval - * @static - * @param {coop.rchain.casper.protocol.IBlockApproval} message BlockApproval message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockApproval.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.candidate != null && message.hasOwnProperty("candidate")) - $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.encode(message.candidate, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.sig != null && message.hasOwnProperty("sig")) - $root.coop.rchain.casper.protocol.Signature.encode(message.sig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified BlockApproval message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.BlockApproval.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.BlockApproval - * @static - * @param {coop.rchain.casper.protocol.IBlockApproval} message BlockApproval message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockApproval.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a BlockApproval message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.BlockApproval - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.BlockApproval} BlockApproval - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockApproval.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.BlockApproval(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.candidate = $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.decode(reader, reader.uint32()); - break; - case 2: - message.sig = $root.coop.rchain.casper.protocol.Signature.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a BlockApproval message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.BlockApproval - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.BlockApproval} BlockApproval - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockApproval.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a BlockApproval message. - * @function verify - * @memberof coop.rchain.casper.protocol.BlockApproval - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - BlockApproval.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.candidate != null && message.hasOwnProperty("candidate")) { - var error = $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.verify(message.candidate); - if (error) - return "candidate." + error; - } - if (message.sig != null && message.hasOwnProperty("sig")) { - var error = $root.coop.rchain.casper.protocol.Signature.verify(message.sig); - if (error) - return "sig." + error; - } - return null; - }; - - /** - * Creates a BlockApproval message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.BlockApproval - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.BlockApproval} BlockApproval - */ - BlockApproval.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.BlockApproval) - return object; - var message = new $root.coop.rchain.casper.protocol.BlockApproval(); - if (object.candidate != null) { - if (typeof object.candidate !== "object") - throw TypeError(".coop.rchain.casper.protocol.BlockApproval.candidate: object expected"); - message.candidate = $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.fromObject(object.candidate); - } - if (object.sig != null) { - if (typeof object.sig !== "object") - throw TypeError(".coop.rchain.casper.protocol.BlockApproval.sig: object expected"); - message.sig = $root.coop.rchain.casper.protocol.Signature.fromObject(object.sig); - } - return message; - }; - - /** - * Creates a plain object from a BlockApproval message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.BlockApproval - * @static - * @param {coop.rchain.casper.protocol.BlockApproval} message BlockApproval - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - BlockApproval.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.candidate = null; - object.sig = null; - } - if (message.candidate != null && message.hasOwnProperty("candidate")) - object.candidate = $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.toObject(message.candidate, options); - if (message.sig != null && message.hasOwnProperty("sig")) - object.sig = $root.coop.rchain.casper.protocol.Signature.toObject(message.sig, options); - return object; - }; - - /** - * Converts this BlockApproval to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.BlockApproval - * @instance - * @returns {Object.} JSON object - */ - BlockApproval.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return BlockApproval; - })(); - - protocol.ApprovedBlock = (function() { - - /** - * Properties of an ApprovedBlock. - * @memberof coop.rchain.casper.protocol - * @interface IApprovedBlock - * @property {coop.rchain.casper.protocol.IApprovedBlockCandidate|null} [candidate] ApprovedBlock candidate - * @property {Array.|null} [sigs] ApprovedBlock sigs - */ - - /** - * Constructs a new ApprovedBlock. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents an ApprovedBlock. - * @implements IApprovedBlock - * @constructor - * @param {coop.rchain.casper.protocol.IApprovedBlock=} [properties] Properties to set - */ - function ApprovedBlock(properties) { - this.sigs = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ApprovedBlock candidate. - * @member {coop.rchain.casper.protocol.IApprovedBlockCandidate|null|undefined} candidate - * @memberof coop.rchain.casper.protocol.ApprovedBlock - * @instance - */ - ApprovedBlock.prototype.candidate = null; - - /** - * ApprovedBlock sigs. - * @member {Array.} sigs - * @memberof coop.rchain.casper.protocol.ApprovedBlock - * @instance - */ - ApprovedBlock.prototype.sigs = $util.emptyArray; - - /** - * Creates a new ApprovedBlock instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.ApprovedBlock - * @static - * @param {coop.rchain.casper.protocol.IApprovedBlock=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.ApprovedBlock} ApprovedBlock instance - */ - ApprovedBlock.create = function create(properties) { - return new ApprovedBlock(properties); - }; - - /** - * Encodes the specified ApprovedBlock message. Does not implicitly {@link coop.rchain.casper.protocol.ApprovedBlock.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.ApprovedBlock - * @static - * @param {coop.rchain.casper.protocol.IApprovedBlock} message ApprovedBlock message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ApprovedBlock.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.candidate != null && message.hasOwnProperty("candidate")) - $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.encode(message.candidate, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.sigs != null && message.sigs.length) - for (var i = 0; i < message.sigs.length; ++i) - $root.coop.rchain.casper.protocol.Signature.encode(message.sigs[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified ApprovedBlock message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.ApprovedBlock.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.ApprovedBlock - * @static - * @param {coop.rchain.casper.protocol.IApprovedBlock} message ApprovedBlock message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ApprovedBlock.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an ApprovedBlock message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.ApprovedBlock - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.ApprovedBlock} ApprovedBlock - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ApprovedBlock.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.ApprovedBlock(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.candidate = $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.decode(reader, reader.uint32()); - break; - case 2: - if (!(message.sigs && message.sigs.length)) - message.sigs = []; - message.sigs.push($root.coop.rchain.casper.protocol.Signature.decode(reader, reader.uint32())); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an ApprovedBlock message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.ApprovedBlock - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.ApprovedBlock} ApprovedBlock - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ApprovedBlock.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an ApprovedBlock message. - * @function verify - * @memberof coop.rchain.casper.protocol.ApprovedBlock - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ApprovedBlock.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.candidate != null && message.hasOwnProperty("candidate")) { - var error = $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.verify(message.candidate); - if (error) - return "candidate." + error; - } - if (message.sigs != null && message.hasOwnProperty("sigs")) { - if (!Array.isArray(message.sigs)) - return "sigs: array expected"; - for (var i = 0; i < message.sigs.length; ++i) { - var error = $root.coop.rchain.casper.protocol.Signature.verify(message.sigs[i]); - if (error) - return "sigs." + error; - } - } - return null; - }; - - /** - * Creates an ApprovedBlock message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.ApprovedBlock - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.ApprovedBlock} ApprovedBlock - */ - ApprovedBlock.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.ApprovedBlock) - return object; - var message = new $root.coop.rchain.casper.protocol.ApprovedBlock(); - if (object.candidate != null) { - if (typeof object.candidate !== "object") - throw TypeError(".coop.rchain.casper.protocol.ApprovedBlock.candidate: object expected"); - message.candidate = $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.fromObject(object.candidate); - } - if (object.sigs) { - if (!Array.isArray(object.sigs)) - throw TypeError(".coop.rchain.casper.protocol.ApprovedBlock.sigs: array expected"); - message.sigs = []; - for (var i = 0; i < object.sigs.length; ++i) { - if (typeof object.sigs[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.ApprovedBlock.sigs: object expected"); - message.sigs[i] = $root.coop.rchain.casper.protocol.Signature.fromObject(object.sigs[i]); - } - } - return message; - }; - - /** - * Creates a plain object from an ApprovedBlock message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.ApprovedBlock - * @static - * @param {coop.rchain.casper.protocol.ApprovedBlock} message ApprovedBlock - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ApprovedBlock.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.sigs = []; - if (options.defaults) - object.candidate = null; - if (message.candidate != null && message.hasOwnProperty("candidate")) - object.candidate = $root.coop.rchain.casper.protocol.ApprovedBlockCandidate.toObject(message.candidate, options); - if (message.sigs && message.sigs.length) { - object.sigs = []; - for (var j = 0; j < message.sigs.length; ++j) - object.sigs[j] = $root.coop.rchain.casper.protocol.Signature.toObject(message.sigs[j], options); - } - return object; - }; - - /** - * Converts this ApprovedBlock to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.ApprovedBlock - * @instance - * @returns {Object.} JSON object - */ - ApprovedBlock.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ApprovedBlock; - })(); - - protocol.ApprovedBlockRequest = (function() { - - /** - * Properties of an ApprovedBlockRequest. - * @memberof coop.rchain.casper.protocol - * @interface IApprovedBlockRequest - * @property {string|null} [identifier] ApprovedBlockRequest identifier - */ - - /** - * Constructs a new ApprovedBlockRequest. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents an ApprovedBlockRequest. - * @implements IApprovedBlockRequest - * @constructor - * @param {coop.rchain.casper.protocol.IApprovedBlockRequest=} [properties] Properties to set - */ - function ApprovedBlockRequest(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ApprovedBlockRequest identifier. - * @member {string} identifier - * @memberof coop.rchain.casper.protocol.ApprovedBlockRequest - * @instance - */ - ApprovedBlockRequest.prototype.identifier = ""; - - /** - * Creates a new ApprovedBlockRequest instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.ApprovedBlockRequest - * @static - * @param {coop.rchain.casper.protocol.IApprovedBlockRequest=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.ApprovedBlockRequest} ApprovedBlockRequest instance - */ - ApprovedBlockRequest.create = function create(properties) { - return new ApprovedBlockRequest(properties); - }; - - /** - * Encodes the specified ApprovedBlockRequest message. Does not implicitly {@link coop.rchain.casper.protocol.ApprovedBlockRequest.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.ApprovedBlockRequest - * @static - * @param {coop.rchain.casper.protocol.IApprovedBlockRequest} message ApprovedBlockRequest message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ApprovedBlockRequest.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.identifier != null && message.hasOwnProperty("identifier")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.identifier); - return writer; - }; - - /** - * Encodes the specified ApprovedBlockRequest message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.ApprovedBlockRequest.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.ApprovedBlockRequest - * @static - * @param {coop.rchain.casper.protocol.IApprovedBlockRequest} message ApprovedBlockRequest message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ApprovedBlockRequest.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an ApprovedBlockRequest message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.ApprovedBlockRequest - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.ApprovedBlockRequest} ApprovedBlockRequest - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ApprovedBlockRequest.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.ApprovedBlockRequest(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.identifier = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an ApprovedBlockRequest message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.ApprovedBlockRequest - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.ApprovedBlockRequest} ApprovedBlockRequest - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ApprovedBlockRequest.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an ApprovedBlockRequest message. - * @function verify - * @memberof coop.rchain.casper.protocol.ApprovedBlockRequest - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ApprovedBlockRequest.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.identifier != null && message.hasOwnProperty("identifier")) - if (!$util.isString(message.identifier)) - return "identifier: string expected"; - return null; - }; - - /** - * Creates an ApprovedBlockRequest message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.ApprovedBlockRequest - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.ApprovedBlockRequest} ApprovedBlockRequest - */ - ApprovedBlockRequest.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.ApprovedBlockRequest) - return object; - var message = new $root.coop.rchain.casper.protocol.ApprovedBlockRequest(); - if (object.identifier != null) - message.identifier = String(object.identifier); - return message; - }; - - /** - * Creates a plain object from an ApprovedBlockRequest message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.ApprovedBlockRequest - * @static - * @param {coop.rchain.casper.protocol.ApprovedBlockRequest} message ApprovedBlockRequest - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ApprovedBlockRequest.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.identifier = ""; - if (message.identifier != null && message.hasOwnProperty("identifier")) - object.identifier = message.identifier; - return object; - }; - - /** - * Converts this ApprovedBlockRequest to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.ApprovedBlockRequest - * @instance - * @returns {Object.} JSON object - */ - ApprovedBlockRequest.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ApprovedBlockRequest; - })(); - - protocol.NoApprovedBlockAvailable = (function() { - - /** - * Properties of a NoApprovedBlockAvailable. - * @memberof coop.rchain.casper.protocol - * @interface INoApprovedBlockAvailable - * @property {string|null} [identifier] NoApprovedBlockAvailable identifier - * @property {string|null} [nodeIdentifer] NoApprovedBlockAvailable nodeIdentifer - */ - - /** - * Constructs a new NoApprovedBlockAvailable. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a NoApprovedBlockAvailable. - * @implements INoApprovedBlockAvailable - * @constructor - * @param {coop.rchain.casper.protocol.INoApprovedBlockAvailable=} [properties] Properties to set - */ - function NoApprovedBlockAvailable(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * NoApprovedBlockAvailable identifier. - * @member {string} identifier - * @memberof coop.rchain.casper.protocol.NoApprovedBlockAvailable - * @instance - */ - NoApprovedBlockAvailable.prototype.identifier = ""; - - /** - * NoApprovedBlockAvailable nodeIdentifer. - * @member {string} nodeIdentifer - * @memberof coop.rchain.casper.protocol.NoApprovedBlockAvailable - * @instance - */ - NoApprovedBlockAvailable.prototype.nodeIdentifer = ""; - - /** - * Creates a new NoApprovedBlockAvailable instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.NoApprovedBlockAvailable - * @static - * @param {coop.rchain.casper.protocol.INoApprovedBlockAvailable=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.NoApprovedBlockAvailable} NoApprovedBlockAvailable instance - */ - NoApprovedBlockAvailable.create = function create(properties) { - return new NoApprovedBlockAvailable(properties); - }; - - /** - * Encodes the specified NoApprovedBlockAvailable message. Does not implicitly {@link coop.rchain.casper.protocol.NoApprovedBlockAvailable.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.NoApprovedBlockAvailable - * @static - * @param {coop.rchain.casper.protocol.INoApprovedBlockAvailable} message NoApprovedBlockAvailable message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - NoApprovedBlockAvailable.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.identifier != null && message.hasOwnProperty("identifier")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.identifier); - if (message.nodeIdentifer != null && message.hasOwnProperty("nodeIdentifer")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.nodeIdentifer); - return writer; - }; - - /** - * Encodes the specified NoApprovedBlockAvailable message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.NoApprovedBlockAvailable.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.NoApprovedBlockAvailable - * @static - * @param {coop.rchain.casper.protocol.INoApprovedBlockAvailable} message NoApprovedBlockAvailable message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - NoApprovedBlockAvailable.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a NoApprovedBlockAvailable message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.NoApprovedBlockAvailable - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.NoApprovedBlockAvailable} NoApprovedBlockAvailable - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - NoApprovedBlockAvailable.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.NoApprovedBlockAvailable(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.identifier = reader.string(); - break; - case 2: - message.nodeIdentifer = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a NoApprovedBlockAvailable message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.NoApprovedBlockAvailable - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.NoApprovedBlockAvailable} NoApprovedBlockAvailable - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - NoApprovedBlockAvailable.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a NoApprovedBlockAvailable message. - * @function verify - * @memberof coop.rchain.casper.protocol.NoApprovedBlockAvailable - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - NoApprovedBlockAvailable.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.identifier != null && message.hasOwnProperty("identifier")) - if (!$util.isString(message.identifier)) - return "identifier: string expected"; - if (message.nodeIdentifer != null && message.hasOwnProperty("nodeIdentifer")) - if (!$util.isString(message.nodeIdentifer)) - return "nodeIdentifer: string expected"; - return null; - }; - - /** - * Creates a NoApprovedBlockAvailable message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.NoApprovedBlockAvailable - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.NoApprovedBlockAvailable} NoApprovedBlockAvailable - */ - NoApprovedBlockAvailable.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.NoApprovedBlockAvailable) - return object; - var message = new $root.coop.rchain.casper.protocol.NoApprovedBlockAvailable(); - if (object.identifier != null) - message.identifier = String(object.identifier); - if (object.nodeIdentifer != null) - message.nodeIdentifer = String(object.nodeIdentifer); - return message; - }; - - /** - * Creates a plain object from a NoApprovedBlockAvailable message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.NoApprovedBlockAvailable - * @static - * @param {coop.rchain.casper.protocol.NoApprovedBlockAvailable} message NoApprovedBlockAvailable - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - NoApprovedBlockAvailable.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.identifier = ""; - object.nodeIdentifer = ""; - } - if (message.identifier != null && message.hasOwnProperty("identifier")) - object.identifier = message.identifier; - if (message.nodeIdentifer != null && message.hasOwnProperty("nodeIdentifer")) - object.nodeIdentifer = message.nodeIdentifer; - return object; - }; - - /** - * Converts this NoApprovedBlockAvailable to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.NoApprovedBlockAvailable - * @instance - * @returns {Object.} JSON object - */ - NoApprovedBlockAvailable.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return NoApprovedBlockAvailable; - })(); - - protocol.BlockMessage = (function() { - - /** - * Properties of a BlockMessage. - * @memberof coop.rchain.casper.protocol - * @interface IBlockMessage - * @property {Uint8Array|null} [blockHash] BlockMessage blockHash - * @property {coop.rchain.casper.protocol.IHeader|null} [header] BlockMessage header - * @property {coop.rchain.casper.protocol.IBody|null} [body] BlockMessage body - * @property {Array.|null} [justifications] BlockMessage justifications - * @property {Uint8Array|null} [sender] BlockMessage sender - * @property {number|null} [seqNum] BlockMessage seqNum - * @property {Uint8Array|null} [sig] BlockMessage sig - * @property {string|null} [sigAlgorithm] BlockMessage sigAlgorithm - * @property {string|null} [shardId] BlockMessage shardId - * @property {Uint8Array|null} [extraBytes] BlockMessage extraBytes - */ - - /** - * Constructs a new BlockMessage. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a BlockMessage. - * @implements IBlockMessage - * @constructor - * @param {coop.rchain.casper.protocol.IBlockMessage=} [properties] Properties to set - */ - function BlockMessage(properties) { - this.justifications = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BlockMessage blockHash. - * @member {Uint8Array} blockHash - * @memberof coop.rchain.casper.protocol.BlockMessage - * @instance - */ - BlockMessage.prototype.blockHash = $util.newBuffer([]); - - /** - * BlockMessage header. - * @member {coop.rchain.casper.protocol.IHeader|null|undefined} header - * @memberof coop.rchain.casper.protocol.BlockMessage - * @instance - */ - BlockMessage.prototype.header = null; - - /** - * BlockMessage body. - * @member {coop.rchain.casper.protocol.IBody|null|undefined} body - * @memberof coop.rchain.casper.protocol.BlockMessage - * @instance - */ - BlockMessage.prototype.body = null; - - /** - * BlockMessage justifications. - * @member {Array.} justifications - * @memberof coop.rchain.casper.protocol.BlockMessage - * @instance - */ - BlockMessage.prototype.justifications = $util.emptyArray; - - /** - * BlockMessage sender. - * @member {Uint8Array} sender - * @memberof coop.rchain.casper.protocol.BlockMessage - * @instance - */ - BlockMessage.prototype.sender = $util.newBuffer([]); - - /** - * BlockMessage seqNum. - * @member {number} seqNum - * @memberof coop.rchain.casper.protocol.BlockMessage - * @instance - */ - BlockMessage.prototype.seqNum = 0; - - /** - * BlockMessage sig. - * @member {Uint8Array} sig - * @memberof coop.rchain.casper.protocol.BlockMessage - * @instance - */ - BlockMessage.prototype.sig = $util.newBuffer([]); - - /** - * BlockMessage sigAlgorithm. - * @member {string} sigAlgorithm - * @memberof coop.rchain.casper.protocol.BlockMessage - * @instance - */ - BlockMessage.prototype.sigAlgorithm = ""; - - /** - * BlockMessage shardId. - * @member {string} shardId - * @memberof coop.rchain.casper.protocol.BlockMessage - * @instance - */ - BlockMessage.prototype.shardId = ""; - - /** - * BlockMessage extraBytes. - * @member {Uint8Array} extraBytes - * @memberof coop.rchain.casper.protocol.BlockMessage - * @instance - */ - BlockMessage.prototype.extraBytes = $util.newBuffer([]); - - /** - * Creates a new BlockMessage instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.BlockMessage - * @static - * @param {coop.rchain.casper.protocol.IBlockMessage=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.BlockMessage} BlockMessage instance - */ - BlockMessage.create = function create(properties) { - return new BlockMessage(properties); - }; - - /** - * Encodes the specified BlockMessage message. Does not implicitly {@link coop.rchain.casper.protocol.BlockMessage.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.BlockMessage - * @static - * @param {coop.rchain.casper.protocol.IBlockMessage} message BlockMessage message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockMessage.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.blockHash != null && message.hasOwnProperty("blockHash")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.blockHash); - if (message.header != null && message.hasOwnProperty("header")) - $root.coop.rchain.casper.protocol.Header.encode(message.header, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.body != null && message.hasOwnProperty("body")) - $root.coop.rchain.casper.protocol.Body.encode(message.body, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.justifications != null && message.justifications.length) - for (var i = 0; i < message.justifications.length; ++i) - $root.coop.rchain.casper.protocol.Justification.encode(message.justifications[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.sender != null && message.hasOwnProperty("sender")) - writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.sender); - if (message.seqNum != null && message.hasOwnProperty("seqNum")) - writer.uint32(/* id 6, wireType 0 =*/48).int32(message.seqNum); - if (message.sig != null && message.hasOwnProperty("sig")) - writer.uint32(/* id 7, wireType 2 =*/58).bytes(message.sig); - if (message.sigAlgorithm != null && message.hasOwnProperty("sigAlgorithm")) - writer.uint32(/* id 8, wireType 2 =*/66).string(message.sigAlgorithm); - if (message.shardId != null && message.hasOwnProperty("shardId")) - writer.uint32(/* id 9, wireType 2 =*/74).string(message.shardId); - if (message.extraBytes != null && message.hasOwnProperty("extraBytes")) - writer.uint32(/* id 10, wireType 2 =*/82).bytes(message.extraBytes); - return writer; - }; - - /** - * Encodes the specified BlockMessage message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.BlockMessage.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.BlockMessage - * @static - * @param {coop.rchain.casper.protocol.IBlockMessage} message BlockMessage message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockMessage.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a BlockMessage message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.BlockMessage - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.BlockMessage} BlockMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockMessage.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.BlockMessage(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.blockHash = reader.bytes(); - break; - case 2: - message.header = $root.coop.rchain.casper.protocol.Header.decode(reader, reader.uint32()); - break; - case 3: - message.body = $root.coop.rchain.casper.protocol.Body.decode(reader, reader.uint32()); - break; - case 4: - if (!(message.justifications && message.justifications.length)) - message.justifications = []; - message.justifications.push($root.coop.rchain.casper.protocol.Justification.decode(reader, reader.uint32())); - break; - case 5: - message.sender = reader.bytes(); - break; - case 6: - message.seqNum = reader.int32(); - break; - case 7: - message.sig = reader.bytes(); - break; - case 8: - message.sigAlgorithm = reader.string(); - break; - case 9: - message.shardId = reader.string(); - break; - case 10: - message.extraBytes = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a BlockMessage message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.BlockMessage - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.BlockMessage} BlockMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockMessage.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a BlockMessage message. - * @function verify - * @memberof coop.rchain.casper.protocol.BlockMessage - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - BlockMessage.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.blockHash != null && message.hasOwnProperty("blockHash")) - if (!(message.blockHash && typeof message.blockHash.length === "number" || $util.isString(message.blockHash))) - return "blockHash: buffer expected"; - if (message.header != null && message.hasOwnProperty("header")) { - var error = $root.coop.rchain.casper.protocol.Header.verify(message.header); - if (error) - return "header." + error; - } - if (message.body != null && message.hasOwnProperty("body")) { - var error = $root.coop.rchain.casper.protocol.Body.verify(message.body); - if (error) - return "body." + error; - } - if (message.justifications != null && message.hasOwnProperty("justifications")) { - if (!Array.isArray(message.justifications)) - return "justifications: array expected"; - for (var i = 0; i < message.justifications.length; ++i) { - var error = $root.coop.rchain.casper.protocol.Justification.verify(message.justifications[i]); - if (error) - return "justifications." + error; - } - } - if (message.sender != null && message.hasOwnProperty("sender")) - if (!(message.sender && typeof message.sender.length === "number" || $util.isString(message.sender))) - return "sender: buffer expected"; - if (message.seqNum != null && message.hasOwnProperty("seqNum")) - if (!$util.isInteger(message.seqNum)) - return "seqNum: integer expected"; - if (message.sig != null && message.hasOwnProperty("sig")) - if (!(message.sig && typeof message.sig.length === "number" || $util.isString(message.sig))) - return "sig: buffer expected"; - if (message.sigAlgorithm != null && message.hasOwnProperty("sigAlgorithm")) - if (!$util.isString(message.sigAlgorithm)) - return "sigAlgorithm: string expected"; - if (message.shardId != null && message.hasOwnProperty("shardId")) - if (!$util.isString(message.shardId)) - return "shardId: string expected"; - if (message.extraBytes != null && message.hasOwnProperty("extraBytes")) - if (!(message.extraBytes && typeof message.extraBytes.length === "number" || $util.isString(message.extraBytes))) - return "extraBytes: buffer expected"; - return null; - }; - - /** - * Creates a BlockMessage message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.BlockMessage - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.BlockMessage} BlockMessage - */ - BlockMessage.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.BlockMessage) - return object; - var message = new $root.coop.rchain.casper.protocol.BlockMessage(); - if (object.blockHash != null) - if (typeof object.blockHash === "string") - $util.base64.decode(object.blockHash, message.blockHash = $util.newBuffer($util.base64.length(object.blockHash)), 0); - else if (object.blockHash.length) - message.blockHash = object.blockHash; - if (object.header != null) { - if (typeof object.header !== "object") - throw TypeError(".coop.rchain.casper.protocol.BlockMessage.header: object expected"); - message.header = $root.coop.rchain.casper.protocol.Header.fromObject(object.header); - } - if (object.body != null) { - if (typeof object.body !== "object") - throw TypeError(".coop.rchain.casper.protocol.BlockMessage.body: object expected"); - message.body = $root.coop.rchain.casper.protocol.Body.fromObject(object.body); - } - if (object.justifications) { - if (!Array.isArray(object.justifications)) - throw TypeError(".coop.rchain.casper.protocol.BlockMessage.justifications: array expected"); - message.justifications = []; - for (var i = 0; i < object.justifications.length; ++i) { - if (typeof object.justifications[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.BlockMessage.justifications: object expected"); - message.justifications[i] = $root.coop.rchain.casper.protocol.Justification.fromObject(object.justifications[i]); - } - } - if (object.sender != null) - if (typeof object.sender === "string") - $util.base64.decode(object.sender, message.sender = $util.newBuffer($util.base64.length(object.sender)), 0); - else if (object.sender.length) - message.sender = object.sender; - if (object.seqNum != null) - message.seqNum = object.seqNum | 0; - if (object.sig != null) - if (typeof object.sig === "string") - $util.base64.decode(object.sig, message.sig = $util.newBuffer($util.base64.length(object.sig)), 0); - else if (object.sig.length) - message.sig = object.sig; - if (object.sigAlgorithm != null) - message.sigAlgorithm = String(object.sigAlgorithm); - if (object.shardId != null) - message.shardId = String(object.shardId); - if (object.extraBytes != null) - if (typeof object.extraBytes === "string") - $util.base64.decode(object.extraBytes, message.extraBytes = $util.newBuffer($util.base64.length(object.extraBytes)), 0); - else if (object.extraBytes.length) - message.extraBytes = object.extraBytes; - return message; - }; - - /** - * Creates a plain object from a BlockMessage message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.BlockMessage - * @static - * @param {coop.rchain.casper.protocol.BlockMessage} message BlockMessage - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - BlockMessage.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.justifications = []; - if (options.defaults) { - if (options.bytes === String) - object.blockHash = ""; - else { - object.blockHash = []; - if (options.bytes !== Array) - object.blockHash = $util.newBuffer(object.blockHash); - } - object.header = null; - object.body = null; - if (options.bytes === String) - object.sender = ""; - else { - object.sender = []; - if (options.bytes !== Array) - object.sender = $util.newBuffer(object.sender); - } - object.seqNum = 0; - if (options.bytes === String) - object.sig = ""; - else { - object.sig = []; - if (options.bytes !== Array) - object.sig = $util.newBuffer(object.sig); - } - object.sigAlgorithm = ""; - object.shardId = ""; - if (options.bytes === String) - object.extraBytes = ""; - else { - object.extraBytes = []; - if (options.bytes !== Array) - object.extraBytes = $util.newBuffer(object.extraBytes); - } - } - if (message.blockHash != null && message.hasOwnProperty("blockHash")) - object.blockHash = options.bytes === String ? $util.base64.encode(message.blockHash, 0, message.blockHash.length) : options.bytes === Array ? Array.prototype.slice.call(message.blockHash) : message.blockHash; - if (message.header != null && message.hasOwnProperty("header")) - object.header = $root.coop.rchain.casper.protocol.Header.toObject(message.header, options); - if (message.body != null && message.hasOwnProperty("body")) - object.body = $root.coop.rchain.casper.protocol.Body.toObject(message.body, options); - if (message.justifications && message.justifications.length) { - object.justifications = []; - for (var j = 0; j < message.justifications.length; ++j) - object.justifications[j] = $root.coop.rchain.casper.protocol.Justification.toObject(message.justifications[j], options); - } - if (message.sender != null && message.hasOwnProperty("sender")) - object.sender = options.bytes === String ? $util.base64.encode(message.sender, 0, message.sender.length) : options.bytes === Array ? Array.prototype.slice.call(message.sender) : message.sender; - if (message.seqNum != null && message.hasOwnProperty("seqNum")) - object.seqNum = message.seqNum; - if (message.sig != null && message.hasOwnProperty("sig")) - object.sig = options.bytes === String ? $util.base64.encode(message.sig, 0, message.sig.length) : options.bytes === Array ? Array.prototype.slice.call(message.sig) : message.sig; - if (message.sigAlgorithm != null && message.hasOwnProperty("sigAlgorithm")) - object.sigAlgorithm = message.sigAlgorithm; - if (message.shardId != null && message.hasOwnProperty("shardId")) - object.shardId = message.shardId; - if (message.extraBytes != null && message.hasOwnProperty("extraBytes")) - object.extraBytes = options.bytes === String ? $util.base64.encode(message.extraBytes, 0, message.extraBytes.length) : options.bytes === Array ? Array.prototype.slice.call(message.extraBytes) : message.extraBytes; - return object; - }; - - /** - * Converts this BlockMessage to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.BlockMessage - * @instance - * @returns {Object.} JSON object - */ - BlockMessage.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return BlockMessage; - })(); - - protocol.BlockMetadataInternal = (function() { - - /** - * Properties of a BlockMetadataInternal. - * @memberof coop.rchain.casper.protocol - * @interface IBlockMetadataInternal - * @property {Uint8Array|null} [blockHash] BlockMetadataInternal blockHash - * @property {Array.|null} [parents] BlockMetadataInternal parents - * @property {Uint8Array|null} [sender] BlockMetadataInternal sender - * @property {Array.|null} [justifications] BlockMetadataInternal justifications - * @property {Array.|null} [bonds] BlockMetadataInternal bonds - * @property {number|Long|null} [blockNum] BlockMetadataInternal blockNum - * @property {number|null} [seqNum] BlockMetadataInternal seqNum - * @property {boolean|null} [invalid] BlockMetadataInternal invalid - */ - - /** - * Constructs a new BlockMetadataInternal. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a BlockMetadataInternal. - * @implements IBlockMetadataInternal - * @constructor - * @param {coop.rchain.casper.protocol.IBlockMetadataInternal=} [properties] Properties to set - */ - function BlockMetadataInternal(properties) { - this.parents = []; - this.justifications = []; - this.bonds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BlockMetadataInternal blockHash. - * @member {Uint8Array} blockHash - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @instance - */ - BlockMetadataInternal.prototype.blockHash = $util.newBuffer([]); - - /** - * BlockMetadataInternal parents. - * @member {Array.} parents - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @instance - */ - BlockMetadataInternal.prototype.parents = $util.emptyArray; - - /** - * BlockMetadataInternal sender. - * @member {Uint8Array} sender - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @instance - */ - BlockMetadataInternal.prototype.sender = $util.newBuffer([]); - - /** - * BlockMetadataInternal justifications. - * @member {Array.} justifications - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @instance - */ - BlockMetadataInternal.prototype.justifications = $util.emptyArray; - - /** - * BlockMetadataInternal bonds. - * @member {Array.} bonds - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @instance - */ - BlockMetadataInternal.prototype.bonds = $util.emptyArray; - - /** - * BlockMetadataInternal blockNum. - * @member {number|Long} blockNum - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @instance - */ - BlockMetadataInternal.prototype.blockNum = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * BlockMetadataInternal seqNum. - * @member {number} seqNum - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @instance - */ - BlockMetadataInternal.prototype.seqNum = 0; - - /** - * BlockMetadataInternal invalid. - * @member {boolean} invalid - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @instance - */ - BlockMetadataInternal.prototype.invalid = false; - - /** - * Creates a new BlockMetadataInternal instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @static - * @param {coop.rchain.casper.protocol.IBlockMetadataInternal=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.BlockMetadataInternal} BlockMetadataInternal instance - */ - BlockMetadataInternal.create = function create(properties) { - return new BlockMetadataInternal(properties); - }; - - /** - * Encodes the specified BlockMetadataInternal message. Does not implicitly {@link coop.rchain.casper.protocol.BlockMetadataInternal.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @static - * @param {coop.rchain.casper.protocol.IBlockMetadataInternal} message BlockMetadataInternal message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockMetadataInternal.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.blockHash != null && message.hasOwnProperty("blockHash")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.blockHash); - if (message.parents != null && message.parents.length) - for (var i = 0; i < message.parents.length; ++i) - writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.parents[i]); - if (message.sender != null && message.hasOwnProperty("sender")) - writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.sender); - if (message.justifications != null && message.justifications.length) - for (var i = 0; i < message.justifications.length; ++i) - $root.coop.rchain.casper.protocol.Justification.encode(message.justifications[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.bonds != null && message.bonds.length) - for (var i = 0; i < message.bonds.length; ++i) - $root.coop.rchain.casper.protocol.Bond.encode(message.bonds[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); - if (message.blockNum != null && message.hasOwnProperty("blockNum")) - writer.uint32(/* id 6, wireType 0 =*/48).int64(message.blockNum); - if (message.seqNum != null && message.hasOwnProperty("seqNum")) - writer.uint32(/* id 7, wireType 0 =*/56).int32(message.seqNum); - if (message.invalid != null && message.hasOwnProperty("invalid")) - writer.uint32(/* id 8, wireType 0 =*/64).bool(message.invalid); - return writer; - }; - - /** - * Encodes the specified BlockMetadataInternal message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.BlockMetadataInternal.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @static - * @param {coop.rchain.casper.protocol.IBlockMetadataInternal} message BlockMetadataInternal message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BlockMetadataInternal.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a BlockMetadataInternal message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.BlockMetadataInternal} BlockMetadataInternal - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockMetadataInternal.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.BlockMetadataInternal(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.blockHash = reader.bytes(); - break; - case 2: - if (!(message.parents && message.parents.length)) - message.parents = []; - message.parents.push(reader.bytes()); - break; - case 3: - message.sender = reader.bytes(); - break; - case 4: - if (!(message.justifications && message.justifications.length)) - message.justifications = []; - message.justifications.push($root.coop.rchain.casper.protocol.Justification.decode(reader, reader.uint32())); - break; - case 5: - if (!(message.bonds && message.bonds.length)) - message.bonds = []; - message.bonds.push($root.coop.rchain.casper.protocol.Bond.decode(reader, reader.uint32())); - break; - case 6: - message.blockNum = reader.int64(); - break; - case 7: - message.seqNum = reader.int32(); - break; - case 8: - message.invalid = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a BlockMetadataInternal message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.BlockMetadataInternal} BlockMetadataInternal - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BlockMetadataInternal.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a BlockMetadataInternal message. - * @function verify - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - BlockMetadataInternal.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.blockHash != null && message.hasOwnProperty("blockHash")) - if (!(message.blockHash && typeof message.blockHash.length === "number" || $util.isString(message.blockHash))) - return "blockHash: buffer expected"; - if (message.parents != null && message.hasOwnProperty("parents")) { - if (!Array.isArray(message.parents)) - return "parents: array expected"; - for (var i = 0; i < message.parents.length; ++i) - if (!(message.parents[i] && typeof message.parents[i].length === "number" || $util.isString(message.parents[i]))) - return "parents: buffer[] expected"; - } - if (message.sender != null && message.hasOwnProperty("sender")) - if (!(message.sender && typeof message.sender.length === "number" || $util.isString(message.sender))) - return "sender: buffer expected"; - if (message.justifications != null && message.hasOwnProperty("justifications")) { - if (!Array.isArray(message.justifications)) - return "justifications: array expected"; - for (var i = 0; i < message.justifications.length; ++i) { - var error = $root.coop.rchain.casper.protocol.Justification.verify(message.justifications[i]); - if (error) - return "justifications." + error; - } - } - if (message.bonds != null && message.hasOwnProperty("bonds")) { - if (!Array.isArray(message.bonds)) - return "bonds: array expected"; - for (var i = 0; i < message.bonds.length; ++i) { - var error = $root.coop.rchain.casper.protocol.Bond.verify(message.bonds[i]); - if (error) - return "bonds." + error; - } - } - if (message.blockNum != null && message.hasOwnProperty("blockNum")) - if (!$util.isInteger(message.blockNum) && !(message.blockNum && $util.isInteger(message.blockNum.low) && $util.isInteger(message.blockNum.high))) - return "blockNum: integer|Long expected"; - if (message.seqNum != null && message.hasOwnProperty("seqNum")) - if (!$util.isInteger(message.seqNum)) - return "seqNum: integer expected"; - if (message.invalid != null && message.hasOwnProperty("invalid")) - if (typeof message.invalid !== "boolean") - return "invalid: boolean expected"; - return null; - }; - - /** - * Creates a BlockMetadataInternal message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.BlockMetadataInternal} BlockMetadataInternal - */ - BlockMetadataInternal.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.BlockMetadataInternal) - return object; - var message = new $root.coop.rchain.casper.protocol.BlockMetadataInternal(); - if (object.blockHash != null) - if (typeof object.blockHash === "string") - $util.base64.decode(object.blockHash, message.blockHash = $util.newBuffer($util.base64.length(object.blockHash)), 0); - else if (object.blockHash.length) - message.blockHash = object.blockHash; - if (object.parents) { - if (!Array.isArray(object.parents)) - throw TypeError(".coop.rchain.casper.protocol.BlockMetadataInternal.parents: array expected"); - message.parents = []; - for (var i = 0; i < object.parents.length; ++i) - if (typeof object.parents[i] === "string") - $util.base64.decode(object.parents[i], message.parents[i] = $util.newBuffer($util.base64.length(object.parents[i])), 0); - else if (object.parents[i].length) - message.parents[i] = object.parents[i]; - } - if (object.sender != null) - if (typeof object.sender === "string") - $util.base64.decode(object.sender, message.sender = $util.newBuffer($util.base64.length(object.sender)), 0); - else if (object.sender.length) - message.sender = object.sender; - if (object.justifications) { - if (!Array.isArray(object.justifications)) - throw TypeError(".coop.rchain.casper.protocol.BlockMetadataInternal.justifications: array expected"); - message.justifications = []; - for (var i = 0; i < object.justifications.length; ++i) { - if (typeof object.justifications[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.BlockMetadataInternal.justifications: object expected"); - message.justifications[i] = $root.coop.rchain.casper.protocol.Justification.fromObject(object.justifications[i]); - } - } - if (object.bonds) { - if (!Array.isArray(object.bonds)) - throw TypeError(".coop.rchain.casper.protocol.BlockMetadataInternal.bonds: array expected"); - message.bonds = []; - for (var i = 0; i < object.bonds.length; ++i) { - if (typeof object.bonds[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.BlockMetadataInternal.bonds: object expected"); - message.bonds[i] = $root.coop.rchain.casper.protocol.Bond.fromObject(object.bonds[i]); - } - } - if (object.blockNum != null) - if ($util.Long) - (message.blockNum = $util.Long.fromValue(object.blockNum)).unsigned = false; - else if (typeof object.blockNum === "string") - message.blockNum = parseInt(object.blockNum, 10); - else if (typeof object.blockNum === "number") - message.blockNum = object.blockNum; - else if (typeof object.blockNum === "object") - message.blockNum = new $util.LongBits(object.blockNum.low >>> 0, object.blockNum.high >>> 0).toNumber(); - if (object.seqNum != null) - message.seqNum = object.seqNum | 0; - if (object.invalid != null) - message.invalid = Boolean(object.invalid); - return message; - }; - - /** - * Creates a plain object from a BlockMetadataInternal message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @static - * @param {coop.rchain.casper.protocol.BlockMetadataInternal} message BlockMetadataInternal - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - BlockMetadataInternal.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) { - object.parents = []; - object.justifications = []; - object.bonds = []; - } - if (options.defaults) { - if (options.bytes === String) - object.blockHash = ""; - else { - object.blockHash = []; - if (options.bytes !== Array) - object.blockHash = $util.newBuffer(object.blockHash); - } - if (options.bytes === String) - object.sender = ""; - else { - object.sender = []; - if (options.bytes !== Array) - object.sender = $util.newBuffer(object.sender); - } - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.blockNum = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.blockNum = options.longs === String ? "0" : 0; - object.seqNum = 0; - object.invalid = false; - } - if (message.blockHash != null && message.hasOwnProperty("blockHash")) - object.blockHash = options.bytes === String ? $util.base64.encode(message.blockHash, 0, message.blockHash.length) : options.bytes === Array ? Array.prototype.slice.call(message.blockHash) : message.blockHash; - if (message.parents && message.parents.length) { - object.parents = []; - for (var j = 0; j < message.parents.length; ++j) - object.parents[j] = options.bytes === String ? $util.base64.encode(message.parents[j], 0, message.parents[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.parents[j]) : message.parents[j]; - } - if (message.sender != null && message.hasOwnProperty("sender")) - object.sender = options.bytes === String ? $util.base64.encode(message.sender, 0, message.sender.length) : options.bytes === Array ? Array.prototype.slice.call(message.sender) : message.sender; - if (message.justifications && message.justifications.length) { - object.justifications = []; - for (var j = 0; j < message.justifications.length; ++j) - object.justifications[j] = $root.coop.rchain.casper.protocol.Justification.toObject(message.justifications[j], options); - } - if (message.bonds && message.bonds.length) { - object.bonds = []; - for (var j = 0; j < message.bonds.length; ++j) - object.bonds[j] = $root.coop.rchain.casper.protocol.Bond.toObject(message.bonds[j], options); - } - if (message.blockNum != null && message.hasOwnProperty("blockNum")) - if (typeof message.blockNum === "number") - object.blockNum = options.longs === String ? String(message.blockNum) : message.blockNum; - else - object.blockNum = options.longs === String ? $util.Long.prototype.toString.call(message.blockNum) : options.longs === Number ? new $util.LongBits(message.blockNum.low >>> 0, message.blockNum.high >>> 0).toNumber() : message.blockNum; - if (message.seqNum != null && message.hasOwnProperty("seqNum")) - object.seqNum = message.seqNum; - if (message.invalid != null && message.hasOwnProperty("invalid")) - object.invalid = message.invalid; - return object; - }; - - /** - * Converts this BlockMetadataInternal to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.BlockMetadataInternal - * @instance - * @returns {Object.} JSON object - */ - BlockMetadataInternal.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return BlockMetadataInternal; - })(); - - protocol.Header = (function() { - - /** - * Properties of a Header. - * @memberof coop.rchain.casper.protocol - * @interface IHeader - * @property {Array.|null} [parentsHashList] Header parentsHashList - * @property {Uint8Array|null} [postStateHash] Header postStateHash - * @property {Uint8Array|null} [deploysHash] Header deploysHash - * @property {number|Long|null} [timestamp] Header timestamp - * @property {number|Long|null} [version] Header version - * @property {number|null} [deployCount] Header deployCount - * @property {Uint8Array|null} [extraBytes] Header extraBytes - */ - - /** - * Constructs a new Header. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a Header. - * @implements IHeader - * @constructor - * @param {coop.rchain.casper.protocol.IHeader=} [properties] Properties to set - */ - function Header(properties) { - this.parentsHashList = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Header parentsHashList. - * @member {Array.} parentsHashList - * @memberof coop.rchain.casper.protocol.Header - * @instance - */ - Header.prototype.parentsHashList = $util.emptyArray; - - /** - * Header postStateHash. - * @member {Uint8Array} postStateHash - * @memberof coop.rchain.casper.protocol.Header - * @instance - */ - Header.prototype.postStateHash = $util.newBuffer([]); - - /** - * Header deploysHash. - * @member {Uint8Array} deploysHash - * @memberof coop.rchain.casper.protocol.Header - * @instance - */ - Header.prototype.deploysHash = $util.newBuffer([]); - - /** - * Header timestamp. - * @member {number|Long} timestamp - * @memberof coop.rchain.casper.protocol.Header - * @instance - */ - Header.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Header version. - * @member {number|Long} version - * @memberof coop.rchain.casper.protocol.Header - * @instance - */ - Header.prototype.version = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Header deployCount. - * @member {number} deployCount - * @memberof coop.rchain.casper.protocol.Header - * @instance - */ - Header.prototype.deployCount = 0; - - /** - * Header extraBytes. - * @member {Uint8Array} extraBytes - * @memberof coop.rchain.casper.protocol.Header - * @instance - */ - Header.prototype.extraBytes = $util.newBuffer([]); - - /** - * Creates a new Header instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.Header - * @static - * @param {coop.rchain.casper.protocol.IHeader=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.Header} Header instance - */ - Header.create = function create(properties) { - return new Header(properties); - }; - - /** - * Encodes the specified Header message. Does not implicitly {@link coop.rchain.casper.protocol.Header.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.Header - * @static - * @param {coop.rchain.casper.protocol.IHeader} message Header message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Header.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.parentsHashList != null && message.parentsHashList.length) - for (var i = 0; i < message.parentsHashList.length; ++i) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.parentsHashList[i]); - if (message.postStateHash != null && message.hasOwnProperty("postStateHash")) - writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.postStateHash); - if (message.deploysHash != null && message.hasOwnProperty("deploysHash")) - writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.deploysHash); - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - writer.uint32(/* id 5, wireType 0 =*/40).int64(message.timestamp); - if (message.version != null && message.hasOwnProperty("version")) - writer.uint32(/* id 6, wireType 0 =*/48).int64(message.version); - if (message.deployCount != null && message.hasOwnProperty("deployCount")) - writer.uint32(/* id 7, wireType 0 =*/56).int32(message.deployCount); - if (message.extraBytes != null && message.hasOwnProperty("extraBytes")) - writer.uint32(/* id 8, wireType 2 =*/66).bytes(message.extraBytes); - return writer; - }; - - /** - * Encodes the specified Header message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.Header.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.Header - * @static - * @param {coop.rchain.casper.protocol.IHeader} message Header message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Header.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Header message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.Header - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.Header} Header - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Header.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.Header(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.parentsHashList && message.parentsHashList.length)) - message.parentsHashList = []; - message.parentsHashList.push(reader.bytes()); - break; - case 2: - message.postStateHash = reader.bytes(); - break; - case 3: - message.deploysHash = reader.bytes(); - break; - case 5: - message.timestamp = reader.int64(); - break; - case 6: - message.version = reader.int64(); - break; - case 7: - message.deployCount = reader.int32(); - break; - case 8: - message.extraBytes = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Header message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.Header - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.Header} Header - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Header.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Header message. - * @function verify - * @memberof coop.rchain.casper.protocol.Header - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Header.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.parentsHashList != null && message.hasOwnProperty("parentsHashList")) { - if (!Array.isArray(message.parentsHashList)) - return "parentsHashList: array expected"; - for (var i = 0; i < message.parentsHashList.length; ++i) - if (!(message.parentsHashList[i] && typeof message.parentsHashList[i].length === "number" || $util.isString(message.parentsHashList[i]))) - return "parentsHashList: buffer[] expected"; - } - if (message.postStateHash != null && message.hasOwnProperty("postStateHash")) - if (!(message.postStateHash && typeof message.postStateHash.length === "number" || $util.isString(message.postStateHash))) - return "postStateHash: buffer expected"; - if (message.deploysHash != null && message.hasOwnProperty("deploysHash")) - if (!(message.deploysHash && typeof message.deploysHash.length === "number" || $util.isString(message.deploysHash))) - return "deploysHash: buffer expected"; - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high))) - return "timestamp: integer|Long expected"; - if (message.version != null && message.hasOwnProperty("version")) - if (!$util.isInteger(message.version) && !(message.version && $util.isInteger(message.version.low) && $util.isInteger(message.version.high))) - return "version: integer|Long expected"; - if (message.deployCount != null && message.hasOwnProperty("deployCount")) - if (!$util.isInteger(message.deployCount)) - return "deployCount: integer expected"; - if (message.extraBytes != null && message.hasOwnProperty("extraBytes")) - if (!(message.extraBytes && typeof message.extraBytes.length === "number" || $util.isString(message.extraBytes))) - return "extraBytes: buffer expected"; - return null; - }; - - /** - * Creates a Header message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.Header - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.Header} Header - */ - Header.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.Header) - return object; - var message = new $root.coop.rchain.casper.protocol.Header(); - if (object.parentsHashList) { - if (!Array.isArray(object.parentsHashList)) - throw TypeError(".coop.rchain.casper.protocol.Header.parentsHashList: array expected"); - message.parentsHashList = []; - for (var i = 0; i < object.parentsHashList.length; ++i) - if (typeof object.parentsHashList[i] === "string") - $util.base64.decode(object.parentsHashList[i], message.parentsHashList[i] = $util.newBuffer($util.base64.length(object.parentsHashList[i])), 0); - else if (object.parentsHashList[i].length) - message.parentsHashList[i] = object.parentsHashList[i]; - } - if (object.postStateHash != null) - if (typeof object.postStateHash === "string") - $util.base64.decode(object.postStateHash, message.postStateHash = $util.newBuffer($util.base64.length(object.postStateHash)), 0); - else if (object.postStateHash.length) - message.postStateHash = object.postStateHash; - if (object.deploysHash != null) - if (typeof object.deploysHash === "string") - $util.base64.decode(object.deploysHash, message.deploysHash = $util.newBuffer($util.base64.length(object.deploysHash)), 0); - else if (object.deploysHash.length) - message.deploysHash = object.deploysHash; - if (object.timestamp != null) - if ($util.Long) - (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = false; - else if (typeof object.timestamp === "string") - message.timestamp = parseInt(object.timestamp, 10); - else if (typeof object.timestamp === "number") - message.timestamp = object.timestamp; - else if (typeof object.timestamp === "object") - message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber(); - if (object.version != null) - if ($util.Long) - (message.version = $util.Long.fromValue(object.version)).unsigned = false; - else if (typeof object.version === "string") - message.version = parseInt(object.version, 10); - else if (typeof object.version === "number") - message.version = object.version; - else if (typeof object.version === "object") - message.version = new $util.LongBits(object.version.low >>> 0, object.version.high >>> 0).toNumber(); - if (object.deployCount != null) - message.deployCount = object.deployCount | 0; - if (object.extraBytes != null) - if (typeof object.extraBytes === "string") - $util.base64.decode(object.extraBytes, message.extraBytes = $util.newBuffer($util.base64.length(object.extraBytes)), 0); - else if (object.extraBytes.length) - message.extraBytes = object.extraBytes; - return message; - }; - - /** - * Creates a plain object from a Header message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.Header - * @static - * @param {coop.rchain.casper.protocol.Header} message Header - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Header.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.parentsHashList = []; - if (options.defaults) { - if (options.bytes === String) - object.postStateHash = ""; - else { - object.postStateHash = []; - if (options.bytes !== Array) - object.postStateHash = $util.newBuffer(object.postStateHash); - } - if (options.bytes === String) - object.deploysHash = ""; - else { - object.deploysHash = []; - if (options.bytes !== Array) - object.deploysHash = $util.newBuffer(object.deploysHash); - } - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.timestamp = options.longs === String ? "0" : 0; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.version = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.version = options.longs === String ? "0" : 0; - object.deployCount = 0; - if (options.bytes === String) - object.extraBytes = ""; - else { - object.extraBytes = []; - if (options.bytes !== Array) - object.extraBytes = $util.newBuffer(object.extraBytes); - } - } - if (message.parentsHashList && message.parentsHashList.length) { - object.parentsHashList = []; - for (var j = 0; j < message.parentsHashList.length; ++j) - object.parentsHashList[j] = options.bytes === String ? $util.base64.encode(message.parentsHashList[j], 0, message.parentsHashList[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.parentsHashList[j]) : message.parentsHashList[j]; - } - if (message.postStateHash != null && message.hasOwnProperty("postStateHash")) - object.postStateHash = options.bytes === String ? $util.base64.encode(message.postStateHash, 0, message.postStateHash.length) : options.bytes === Array ? Array.prototype.slice.call(message.postStateHash) : message.postStateHash; - if (message.deploysHash != null && message.hasOwnProperty("deploysHash")) - object.deploysHash = options.bytes === String ? $util.base64.encode(message.deploysHash, 0, message.deploysHash.length) : options.bytes === Array ? Array.prototype.slice.call(message.deploysHash) : message.deploysHash; - if (message.timestamp != null && message.hasOwnProperty("timestamp")) - if (typeof message.timestamp === "number") - object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp; - else - object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber() : message.timestamp; - if (message.version != null && message.hasOwnProperty("version")) - if (typeof message.version === "number") - object.version = options.longs === String ? String(message.version) : message.version; - else - object.version = options.longs === String ? $util.Long.prototype.toString.call(message.version) : options.longs === Number ? new $util.LongBits(message.version.low >>> 0, message.version.high >>> 0).toNumber() : message.version; - if (message.deployCount != null && message.hasOwnProperty("deployCount")) - object.deployCount = message.deployCount; - if (message.extraBytes != null && message.hasOwnProperty("extraBytes")) - object.extraBytes = options.bytes === String ? $util.base64.encode(message.extraBytes, 0, message.extraBytes.length) : options.bytes === Array ? Array.prototype.slice.call(message.extraBytes) : message.extraBytes; - return object; - }; - - /** - * Converts this Header to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.Header - * @instance - * @returns {Object.} JSON object - */ - Header.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Header; - })(); - - protocol.ProcessedDeploy = (function() { - - /** - * Properties of a ProcessedDeploy. - * @memberof coop.rchain.casper.protocol - * @interface IProcessedDeploy - * @property {coop.rchain.casper.protocol.IDeployData|null} [deploy] ProcessedDeploy deploy - * @property {IPCost|null} [cost] ProcessedDeploy cost - * @property {Array.|null} [log] ProcessedDeploy log - * @property {boolean|null} [errored] ProcessedDeploy errored - */ - - /** - * Constructs a new ProcessedDeploy. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a ProcessedDeploy. - * @implements IProcessedDeploy - * @constructor - * @param {coop.rchain.casper.protocol.IProcessedDeploy=} [properties] Properties to set - */ - function ProcessedDeploy(properties) { - this.log = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ProcessedDeploy deploy. - * @member {coop.rchain.casper.protocol.IDeployData|null|undefined} deploy - * @memberof coop.rchain.casper.protocol.ProcessedDeploy - * @instance - */ - ProcessedDeploy.prototype.deploy = null; - - /** - * ProcessedDeploy cost. - * @member {IPCost|null|undefined} cost - * @memberof coop.rchain.casper.protocol.ProcessedDeploy - * @instance - */ - ProcessedDeploy.prototype.cost = null; - - /** - * ProcessedDeploy log. - * @member {Array.} log - * @memberof coop.rchain.casper.protocol.ProcessedDeploy - * @instance - */ - ProcessedDeploy.prototype.log = $util.emptyArray; - - /** - * ProcessedDeploy errored. - * @member {boolean} errored - * @memberof coop.rchain.casper.protocol.ProcessedDeploy - * @instance - */ - ProcessedDeploy.prototype.errored = false; - - /** - * Creates a new ProcessedDeploy instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.ProcessedDeploy - * @static - * @param {coop.rchain.casper.protocol.IProcessedDeploy=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.ProcessedDeploy} ProcessedDeploy instance - */ - ProcessedDeploy.create = function create(properties) { - return new ProcessedDeploy(properties); - }; - - /** - * Encodes the specified ProcessedDeploy message. Does not implicitly {@link coop.rchain.casper.protocol.ProcessedDeploy.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.ProcessedDeploy - * @static - * @param {coop.rchain.casper.protocol.IProcessedDeploy} message ProcessedDeploy message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ProcessedDeploy.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.deploy != null && message.hasOwnProperty("deploy")) - $root.coop.rchain.casper.protocol.DeployData.encode(message.deploy, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.cost != null && message.hasOwnProperty("cost")) - $root.PCost.encode(message.cost, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.log != null && message.log.length) - for (var i = 0; i < message.log.length; ++i) - $root.coop.rchain.casper.protocol.Event.encode(message.log[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.errored != null && message.hasOwnProperty("errored")) - writer.uint32(/* id 4, wireType 0 =*/32).bool(message.errored); - return writer; - }; - - /** - * Encodes the specified ProcessedDeploy message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.ProcessedDeploy.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.ProcessedDeploy - * @static - * @param {coop.rchain.casper.protocol.IProcessedDeploy} message ProcessedDeploy message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ProcessedDeploy.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ProcessedDeploy message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.ProcessedDeploy - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.ProcessedDeploy} ProcessedDeploy - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ProcessedDeploy.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.ProcessedDeploy(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.deploy = $root.coop.rchain.casper.protocol.DeployData.decode(reader, reader.uint32()); - break; - case 2: - message.cost = $root.PCost.decode(reader, reader.uint32()); - break; - case 3: - if (!(message.log && message.log.length)) - message.log = []; - message.log.push($root.coop.rchain.casper.protocol.Event.decode(reader, reader.uint32())); - break; - case 4: - message.errored = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ProcessedDeploy message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.ProcessedDeploy - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.ProcessedDeploy} ProcessedDeploy - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ProcessedDeploy.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ProcessedDeploy message. - * @function verify - * @memberof coop.rchain.casper.protocol.ProcessedDeploy - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ProcessedDeploy.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.deploy != null && message.hasOwnProperty("deploy")) { - var error = $root.coop.rchain.casper.protocol.DeployData.verify(message.deploy); - if (error) - return "deploy." + error; - } - if (message.cost != null && message.hasOwnProperty("cost")) { - var error = $root.PCost.verify(message.cost); - if (error) - return "cost." + error; - } - if (message.log != null && message.hasOwnProperty("log")) { - if (!Array.isArray(message.log)) - return "log: array expected"; - for (var i = 0; i < message.log.length; ++i) { - var error = $root.coop.rchain.casper.protocol.Event.verify(message.log[i]); - if (error) - return "log." + error; - } - } - if (message.errored != null && message.hasOwnProperty("errored")) - if (typeof message.errored !== "boolean") - return "errored: boolean expected"; - return null; - }; - - /** - * Creates a ProcessedDeploy message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.ProcessedDeploy - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.ProcessedDeploy} ProcessedDeploy - */ - ProcessedDeploy.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.ProcessedDeploy) - return object; - var message = new $root.coop.rchain.casper.protocol.ProcessedDeploy(); - if (object.deploy != null) { - if (typeof object.deploy !== "object") - throw TypeError(".coop.rchain.casper.protocol.ProcessedDeploy.deploy: object expected"); - message.deploy = $root.coop.rchain.casper.protocol.DeployData.fromObject(object.deploy); - } - if (object.cost != null) { - if (typeof object.cost !== "object") - throw TypeError(".coop.rchain.casper.protocol.ProcessedDeploy.cost: object expected"); - message.cost = $root.PCost.fromObject(object.cost); - } - if (object.log) { - if (!Array.isArray(object.log)) - throw TypeError(".coop.rchain.casper.protocol.ProcessedDeploy.log: array expected"); - message.log = []; - for (var i = 0; i < object.log.length; ++i) { - if (typeof object.log[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.ProcessedDeploy.log: object expected"); - message.log[i] = $root.coop.rchain.casper.protocol.Event.fromObject(object.log[i]); - } - } - if (object.errored != null) - message.errored = Boolean(object.errored); - return message; - }; - - /** - * Creates a plain object from a ProcessedDeploy message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.ProcessedDeploy - * @static - * @param {coop.rchain.casper.protocol.ProcessedDeploy} message ProcessedDeploy - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ProcessedDeploy.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.log = []; - if (options.defaults) { - object.deploy = null; - object.cost = null; - object.errored = false; - } - if (message.deploy != null && message.hasOwnProperty("deploy")) - object.deploy = $root.coop.rchain.casper.protocol.DeployData.toObject(message.deploy, options); - if (message.cost != null && message.hasOwnProperty("cost")) - object.cost = $root.PCost.toObject(message.cost, options); - if (message.log && message.log.length) { - object.log = []; - for (var j = 0; j < message.log.length; ++j) - object.log[j] = $root.coop.rchain.casper.protocol.Event.toObject(message.log[j], options); - } - if (message.errored != null && message.hasOwnProperty("errored")) - object.errored = message.errored; - return object; - }; - - /** - * Converts this ProcessedDeploy to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.ProcessedDeploy - * @instance - * @returns {Object.} JSON object - */ - ProcessedDeploy.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ProcessedDeploy; - })(); - - protocol.Body = (function() { - - /** - * Properties of a Body. - * @memberof coop.rchain.casper.protocol - * @interface IBody - * @property {coop.rchain.casper.protocol.IRChainState|null} [state] Body state - * @property {Array.|null} [deploys] Body deploys - * @property {Uint8Array|null} [extraBytes] Body extraBytes - */ - - /** - * Constructs a new Body. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a Body. - * @implements IBody - * @constructor - * @param {coop.rchain.casper.protocol.IBody=} [properties] Properties to set - */ - function Body(properties) { - this.deploys = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Body state. - * @member {coop.rchain.casper.protocol.IRChainState|null|undefined} state - * @memberof coop.rchain.casper.protocol.Body - * @instance - */ - Body.prototype.state = null; - - /** - * Body deploys. - * @member {Array.} deploys - * @memberof coop.rchain.casper.protocol.Body - * @instance - */ - Body.prototype.deploys = $util.emptyArray; - - /** - * Body extraBytes. - * @member {Uint8Array} extraBytes - * @memberof coop.rchain.casper.protocol.Body - * @instance - */ - Body.prototype.extraBytes = $util.newBuffer([]); - - /** - * Creates a new Body instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.Body - * @static - * @param {coop.rchain.casper.protocol.IBody=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.Body} Body instance - */ - Body.create = function create(properties) { - return new Body(properties); - }; - - /** - * Encodes the specified Body message. Does not implicitly {@link coop.rchain.casper.protocol.Body.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.Body - * @static - * @param {coop.rchain.casper.protocol.IBody} message Body message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Body.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.state != null && message.hasOwnProperty("state")) - $root.coop.rchain.casper.protocol.RChainState.encode(message.state, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.deploys != null && message.deploys.length) - for (var i = 0; i < message.deploys.length; ++i) - $root.coop.rchain.casper.protocol.ProcessedDeploy.encode(message.deploys[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.extraBytes != null && message.hasOwnProperty("extraBytes")) - writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.extraBytes); - return writer; - }; - - /** - * Encodes the specified Body message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.Body.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.Body - * @static - * @param {coop.rchain.casper.protocol.IBody} message Body message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Body.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Body message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.Body - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.Body} Body - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Body.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.Body(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.state = $root.coop.rchain.casper.protocol.RChainState.decode(reader, reader.uint32()); - break; - case 2: - if (!(message.deploys && message.deploys.length)) - message.deploys = []; - message.deploys.push($root.coop.rchain.casper.protocol.ProcessedDeploy.decode(reader, reader.uint32())); - break; - case 3: - message.extraBytes = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Body message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.Body - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.Body} Body - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Body.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Body message. - * @function verify - * @memberof coop.rchain.casper.protocol.Body - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Body.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.state != null && message.hasOwnProperty("state")) { - var error = $root.coop.rchain.casper.protocol.RChainState.verify(message.state); - if (error) - return "state." + error; - } - if (message.deploys != null && message.hasOwnProperty("deploys")) { - if (!Array.isArray(message.deploys)) - return "deploys: array expected"; - for (var i = 0; i < message.deploys.length; ++i) { - var error = $root.coop.rchain.casper.protocol.ProcessedDeploy.verify(message.deploys[i]); - if (error) - return "deploys." + error; - } - } - if (message.extraBytes != null && message.hasOwnProperty("extraBytes")) - if (!(message.extraBytes && typeof message.extraBytes.length === "number" || $util.isString(message.extraBytes))) - return "extraBytes: buffer expected"; - return null; - }; - - /** - * Creates a Body message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.Body - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.Body} Body - */ - Body.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.Body) - return object; - var message = new $root.coop.rchain.casper.protocol.Body(); - if (object.state != null) { - if (typeof object.state !== "object") - throw TypeError(".coop.rchain.casper.protocol.Body.state: object expected"); - message.state = $root.coop.rchain.casper.protocol.RChainState.fromObject(object.state); - } - if (object.deploys) { - if (!Array.isArray(object.deploys)) - throw TypeError(".coop.rchain.casper.protocol.Body.deploys: array expected"); - message.deploys = []; - for (var i = 0; i < object.deploys.length; ++i) { - if (typeof object.deploys[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.Body.deploys: object expected"); - message.deploys[i] = $root.coop.rchain.casper.protocol.ProcessedDeploy.fromObject(object.deploys[i]); - } - } - if (object.extraBytes != null) - if (typeof object.extraBytes === "string") - $util.base64.decode(object.extraBytes, message.extraBytes = $util.newBuffer($util.base64.length(object.extraBytes)), 0); - else if (object.extraBytes.length) - message.extraBytes = object.extraBytes; - return message; - }; - - /** - * Creates a plain object from a Body message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.Body - * @static - * @param {coop.rchain.casper.protocol.Body} message Body - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Body.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.deploys = []; - if (options.defaults) { - object.state = null; - if (options.bytes === String) - object.extraBytes = ""; - else { - object.extraBytes = []; - if (options.bytes !== Array) - object.extraBytes = $util.newBuffer(object.extraBytes); - } - } - if (message.state != null && message.hasOwnProperty("state")) - object.state = $root.coop.rchain.casper.protocol.RChainState.toObject(message.state, options); - if (message.deploys && message.deploys.length) { - object.deploys = []; - for (var j = 0; j < message.deploys.length; ++j) - object.deploys[j] = $root.coop.rchain.casper.protocol.ProcessedDeploy.toObject(message.deploys[j], options); - } - if (message.extraBytes != null && message.hasOwnProperty("extraBytes")) - object.extraBytes = options.bytes === String ? $util.base64.encode(message.extraBytes, 0, message.extraBytes.length) : options.bytes === Array ? Array.prototype.slice.call(message.extraBytes) : message.extraBytes; - return object; - }; - - /** - * Converts this Body to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.Body - * @instance - * @returns {Object.} JSON object - */ - Body.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Body; - })(); - - protocol.Justification = (function() { - - /** - * Properties of a Justification. - * @memberof coop.rchain.casper.protocol - * @interface IJustification - * @property {Uint8Array|null} [validator] Justification validator - * @property {Uint8Array|null} [latestBlockHash] Justification latestBlockHash - */ - - /** - * Constructs a new Justification. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a Justification. - * @implements IJustification - * @constructor - * @param {coop.rchain.casper.protocol.IJustification=} [properties] Properties to set - */ - function Justification(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Justification validator. - * @member {Uint8Array} validator - * @memberof coop.rchain.casper.protocol.Justification - * @instance - */ - Justification.prototype.validator = $util.newBuffer([]); - - /** - * Justification latestBlockHash. - * @member {Uint8Array} latestBlockHash - * @memberof coop.rchain.casper.protocol.Justification - * @instance - */ - Justification.prototype.latestBlockHash = $util.newBuffer([]); - - /** - * Creates a new Justification instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.Justification - * @static - * @param {coop.rchain.casper.protocol.IJustification=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.Justification} Justification instance - */ - Justification.create = function create(properties) { - return new Justification(properties); - }; - - /** - * Encodes the specified Justification message. Does not implicitly {@link coop.rchain.casper.protocol.Justification.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.Justification - * @static - * @param {coop.rchain.casper.protocol.IJustification} message Justification message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Justification.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.validator != null && message.hasOwnProperty("validator")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.validator); - if (message.latestBlockHash != null && message.hasOwnProperty("latestBlockHash")) - writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.latestBlockHash); - return writer; - }; - - /** - * Encodes the specified Justification message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.Justification.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.Justification - * @static - * @param {coop.rchain.casper.protocol.IJustification} message Justification message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Justification.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Justification message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.Justification - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.Justification} Justification - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Justification.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.Justification(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.validator = reader.bytes(); - break; - case 2: - message.latestBlockHash = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Justification message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.Justification - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.Justification} Justification - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Justification.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Justification message. - * @function verify - * @memberof coop.rchain.casper.protocol.Justification - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Justification.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.validator != null && message.hasOwnProperty("validator")) - if (!(message.validator && typeof message.validator.length === "number" || $util.isString(message.validator))) - return "validator: buffer expected"; - if (message.latestBlockHash != null && message.hasOwnProperty("latestBlockHash")) - if (!(message.latestBlockHash && typeof message.latestBlockHash.length === "number" || $util.isString(message.latestBlockHash))) - return "latestBlockHash: buffer expected"; - return null; - }; - - /** - * Creates a Justification message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.Justification - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.Justification} Justification - */ - Justification.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.Justification) - return object; - var message = new $root.coop.rchain.casper.protocol.Justification(); - if (object.validator != null) - if (typeof object.validator === "string") - $util.base64.decode(object.validator, message.validator = $util.newBuffer($util.base64.length(object.validator)), 0); - else if (object.validator.length) - message.validator = object.validator; - if (object.latestBlockHash != null) - if (typeof object.latestBlockHash === "string") - $util.base64.decode(object.latestBlockHash, message.latestBlockHash = $util.newBuffer($util.base64.length(object.latestBlockHash)), 0); - else if (object.latestBlockHash.length) - message.latestBlockHash = object.latestBlockHash; - return message; - }; - - /** - * Creates a plain object from a Justification message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.Justification - * @static - * @param {coop.rchain.casper.protocol.Justification} message Justification - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Justification.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if (options.bytes === String) - object.validator = ""; - else { - object.validator = []; - if (options.bytes !== Array) - object.validator = $util.newBuffer(object.validator); - } - if (options.bytes === String) - object.latestBlockHash = ""; - else { - object.latestBlockHash = []; - if (options.bytes !== Array) - object.latestBlockHash = $util.newBuffer(object.latestBlockHash); - } - } - if (message.validator != null && message.hasOwnProperty("validator")) - object.validator = options.bytes === String ? $util.base64.encode(message.validator, 0, message.validator.length) : options.bytes === Array ? Array.prototype.slice.call(message.validator) : message.validator; - if (message.latestBlockHash != null && message.hasOwnProperty("latestBlockHash")) - object.latestBlockHash = options.bytes === String ? $util.base64.encode(message.latestBlockHash, 0, message.latestBlockHash.length) : options.bytes === Array ? Array.prototype.slice.call(message.latestBlockHash) : message.latestBlockHash; - return object; - }; - - /** - * Converts this Justification to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.Justification - * @instance - * @returns {Object.} JSON object - */ - Justification.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Justification; - })(); - - protocol.RChainState = (function() { - - /** - * Properties of a RChainState. - * @memberof coop.rchain.casper.protocol - * @interface IRChainState - * @property {Uint8Array|null} [preStateHash] RChainState preStateHash - * @property {Uint8Array|null} [postStateHash] RChainState postStateHash - * @property {Array.|null} [bonds] RChainState bonds - * @property {number|Long|null} [blockNumber] RChainState blockNumber - */ - - /** - * Constructs a new RChainState. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a RChainState. - * @implements IRChainState - * @constructor - * @param {coop.rchain.casper.protocol.IRChainState=} [properties] Properties to set - */ - function RChainState(properties) { - this.bonds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * RChainState preStateHash. - * @member {Uint8Array} preStateHash - * @memberof coop.rchain.casper.protocol.RChainState - * @instance - */ - RChainState.prototype.preStateHash = $util.newBuffer([]); - - /** - * RChainState postStateHash. - * @member {Uint8Array} postStateHash - * @memberof coop.rchain.casper.protocol.RChainState - * @instance - */ - RChainState.prototype.postStateHash = $util.newBuffer([]); - - /** - * RChainState bonds. - * @member {Array.} bonds - * @memberof coop.rchain.casper.protocol.RChainState - * @instance - */ - RChainState.prototype.bonds = $util.emptyArray; - - /** - * RChainState blockNumber. - * @member {number|Long} blockNumber - * @memberof coop.rchain.casper.protocol.RChainState - * @instance - */ - RChainState.prototype.blockNumber = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Creates a new RChainState instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.RChainState - * @static - * @param {coop.rchain.casper.protocol.IRChainState=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.RChainState} RChainState instance - */ - RChainState.create = function create(properties) { - return new RChainState(properties); - }; - - /** - * Encodes the specified RChainState message. Does not implicitly {@link coop.rchain.casper.protocol.RChainState.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.RChainState - * @static - * @param {coop.rchain.casper.protocol.IRChainState} message RChainState message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - RChainState.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.preStateHash != null && message.hasOwnProperty("preStateHash")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.preStateHash); - if (message.postStateHash != null && message.hasOwnProperty("postStateHash")) - writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.postStateHash); - if (message.bonds != null && message.bonds.length) - for (var i = 0; i < message.bonds.length; ++i) - $root.coop.rchain.casper.protocol.Bond.encode(message.bonds[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.blockNumber != null && message.hasOwnProperty("blockNumber")) - writer.uint32(/* id 4, wireType 0 =*/32).int64(message.blockNumber); - return writer; - }; - - /** - * Encodes the specified RChainState message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.RChainState.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.RChainState - * @static - * @param {coop.rchain.casper.protocol.IRChainState} message RChainState message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - RChainState.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a RChainState message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.RChainState - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.RChainState} RChainState - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - RChainState.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.RChainState(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.preStateHash = reader.bytes(); - break; - case 2: - message.postStateHash = reader.bytes(); - break; - case 3: - if (!(message.bonds && message.bonds.length)) - message.bonds = []; - message.bonds.push($root.coop.rchain.casper.protocol.Bond.decode(reader, reader.uint32())); - break; - case 4: - message.blockNumber = reader.int64(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a RChainState message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.RChainState - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.RChainState} RChainState - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - RChainState.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a RChainState message. - * @function verify - * @memberof coop.rchain.casper.protocol.RChainState - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - RChainState.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.preStateHash != null && message.hasOwnProperty("preStateHash")) - if (!(message.preStateHash && typeof message.preStateHash.length === "number" || $util.isString(message.preStateHash))) - return "preStateHash: buffer expected"; - if (message.postStateHash != null && message.hasOwnProperty("postStateHash")) - if (!(message.postStateHash && typeof message.postStateHash.length === "number" || $util.isString(message.postStateHash))) - return "postStateHash: buffer expected"; - if (message.bonds != null && message.hasOwnProperty("bonds")) { - if (!Array.isArray(message.bonds)) - return "bonds: array expected"; - for (var i = 0; i < message.bonds.length; ++i) { - var error = $root.coop.rchain.casper.protocol.Bond.verify(message.bonds[i]); - if (error) - return "bonds." + error; - } - } - if (message.blockNumber != null && message.hasOwnProperty("blockNumber")) - if (!$util.isInteger(message.blockNumber) && !(message.blockNumber && $util.isInteger(message.blockNumber.low) && $util.isInteger(message.blockNumber.high))) - return "blockNumber: integer|Long expected"; - return null; - }; - - /** - * Creates a RChainState message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.RChainState - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.RChainState} RChainState - */ - RChainState.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.RChainState) - return object; - var message = new $root.coop.rchain.casper.protocol.RChainState(); - if (object.preStateHash != null) - if (typeof object.preStateHash === "string") - $util.base64.decode(object.preStateHash, message.preStateHash = $util.newBuffer($util.base64.length(object.preStateHash)), 0); - else if (object.preStateHash.length) - message.preStateHash = object.preStateHash; - if (object.postStateHash != null) - if (typeof object.postStateHash === "string") - $util.base64.decode(object.postStateHash, message.postStateHash = $util.newBuffer($util.base64.length(object.postStateHash)), 0); - else if (object.postStateHash.length) - message.postStateHash = object.postStateHash; - if (object.bonds) { - if (!Array.isArray(object.bonds)) - throw TypeError(".coop.rchain.casper.protocol.RChainState.bonds: array expected"); - message.bonds = []; - for (var i = 0; i < object.bonds.length; ++i) { - if (typeof object.bonds[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.RChainState.bonds: object expected"); - message.bonds[i] = $root.coop.rchain.casper.protocol.Bond.fromObject(object.bonds[i]); - } - } - if (object.blockNumber != null) - if ($util.Long) - (message.blockNumber = $util.Long.fromValue(object.blockNumber)).unsigned = false; - else if (typeof object.blockNumber === "string") - message.blockNumber = parseInt(object.blockNumber, 10); - else if (typeof object.blockNumber === "number") - message.blockNumber = object.blockNumber; - else if (typeof object.blockNumber === "object") - message.blockNumber = new $util.LongBits(object.blockNumber.low >>> 0, object.blockNumber.high >>> 0).toNumber(); - return message; - }; - - /** - * Creates a plain object from a RChainState message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.RChainState - * @static - * @param {coop.rchain.casper.protocol.RChainState} message RChainState - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - RChainState.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.bonds = []; - if (options.defaults) { - if (options.bytes === String) - object.preStateHash = ""; - else { - object.preStateHash = []; - if (options.bytes !== Array) - object.preStateHash = $util.newBuffer(object.preStateHash); - } - if (options.bytes === String) - object.postStateHash = ""; - else { - object.postStateHash = []; - if (options.bytes !== Array) - object.postStateHash = $util.newBuffer(object.postStateHash); - } - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.blockNumber = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.blockNumber = options.longs === String ? "0" : 0; - } - if (message.preStateHash != null && message.hasOwnProperty("preStateHash")) - object.preStateHash = options.bytes === String ? $util.base64.encode(message.preStateHash, 0, message.preStateHash.length) : options.bytes === Array ? Array.prototype.slice.call(message.preStateHash) : message.preStateHash; - if (message.postStateHash != null && message.hasOwnProperty("postStateHash")) - object.postStateHash = options.bytes === String ? $util.base64.encode(message.postStateHash, 0, message.postStateHash.length) : options.bytes === Array ? Array.prototype.slice.call(message.postStateHash) : message.postStateHash; - if (message.bonds && message.bonds.length) { - object.bonds = []; - for (var j = 0; j < message.bonds.length; ++j) - object.bonds[j] = $root.coop.rchain.casper.protocol.Bond.toObject(message.bonds[j], options); - } - if (message.blockNumber != null && message.hasOwnProperty("blockNumber")) - if (typeof message.blockNumber === "number") - object.blockNumber = options.longs === String ? String(message.blockNumber) : message.blockNumber; - else - object.blockNumber = options.longs === String ? $util.Long.prototype.toString.call(message.blockNumber) : options.longs === Number ? new $util.LongBits(message.blockNumber.low >>> 0, message.blockNumber.high >>> 0).toNumber() : message.blockNumber; - return object; - }; - - /** - * Converts this RChainState to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.RChainState - * @instance - * @returns {Object.} JSON object - */ - RChainState.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return RChainState; - })(); - - protocol.Event = (function() { - - /** - * Properties of an Event. - * @memberof coop.rchain.casper.protocol - * @interface IEvent - * @property {coop.rchain.casper.protocol.IProduceEvent|null} [produce] Event produce - * @property {coop.rchain.casper.protocol.IConsumeEvent|null} [consume] Event consume - * @property {coop.rchain.casper.protocol.ICommEvent|null} [comm] Event comm - */ - - /** - * Constructs a new Event. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents an Event. - * @implements IEvent - * @constructor - * @param {coop.rchain.casper.protocol.IEvent=} [properties] Properties to set - */ - function Event(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Event produce. - * @member {coop.rchain.casper.protocol.IProduceEvent|null|undefined} produce - * @memberof coop.rchain.casper.protocol.Event - * @instance - */ - Event.prototype.produce = null; - - /** - * Event consume. - * @member {coop.rchain.casper.protocol.IConsumeEvent|null|undefined} consume - * @memberof coop.rchain.casper.protocol.Event - * @instance - */ - Event.prototype.consume = null; - - /** - * Event comm. - * @member {coop.rchain.casper.protocol.ICommEvent|null|undefined} comm - * @memberof coop.rchain.casper.protocol.Event - * @instance - */ - Event.prototype.comm = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Event event_instance. - * @member {"produce"|"consume"|"comm"|undefined} event_instance - * @memberof coop.rchain.casper.protocol.Event - * @instance - */ - Object.defineProperty(Event.prototype, "event_instance", { - get: $util.oneOfGetter($oneOfFields = ["produce", "consume", "comm"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * Creates a new Event instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.Event - * @static - * @param {coop.rchain.casper.protocol.IEvent=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.Event} Event instance - */ - Event.create = function create(properties) { - return new Event(properties); - }; - - /** - * Encodes the specified Event message. Does not implicitly {@link coop.rchain.casper.protocol.Event.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.Event - * @static - * @param {coop.rchain.casper.protocol.IEvent} message Event message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Event.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.produce != null && message.hasOwnProperty("produce")) - $root.coop.rchain.casper.protocol.ProduceEvent.encode(message.produce, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.consume != null && message.hasOwnProperty("consume")) - $root.coop.rchain.casper.protocol.ConsumeEvent.encode(message.consume, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.comm != null && message.hasOwnProperty("comm")) - $root.coop.rchain.casper.protocol.CommEvent.encode(message.comm, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified Event message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.Event.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.Event - * @static - * @param {coop.rchain.casper.protocol.IEvent} message Event message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Event.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an Event message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.Event - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.Event} Event - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Event.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.Event(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.produce = $root.coop.rchain.casper.protocol.ProduceEvent.decode(reader, reader.uint32()); - break; - case 2: - message.consume = $root.coop.rchain.casper.protocol.ConsumeEvent.decode(reader, reader.uint32()); - break; - case 3: - message.comm = $root.coop.rchain.casper.protocol.CommEvent.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an Event message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.Event - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.Event} Event - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Event.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an Event message. - * @function verify - * @memberof coop.rchain.casper.protocol.Event - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Event.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - var properties = {}; - if (message.produce != null && message.hasOwnProperty("produce")) { - properties.event_instance = 1; - { - var error = $root.coop.rchain.casper.protocol.ProduceEvent.verify(message.produce); - if (error) - return "produce." + error; - } - } - if (message.consume != null && message.hasOwnProperty("consume")) { - if (properties.event_instance === 1) - return "event_instance: multiple values"; - properties.event_instance = 1; - { - var error = $root.coop.rchain.casper.protocol.ConsumeEvent.verify(message.consume); - if (error) - return "consume." + error; - } - } - if (message.comm != null && message.hasOwnProperty("comm")) { - if (properties.event_instance === 1) - return "event_instance: multiple values"; - properties.event_instance = 1; - { - var error = $root.coop.rchain.casper.protocol.CommEvent.verify(message.comm); - if (error) - return "comm." + error; - } - } - return null; - }; - - /** - * Creates an Event message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.Event - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.Event} Event - */ - Event.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.Event) - return object; - var message = new $root.coop.rchain.casper.protocol.Event(); - if (object.produce != null) { - if (typeof object.produce !== "object") - throw TypeError(".coop.rchain.casper.protocol.Event.produce: object expected"); - message.produce = $root.coop.rchain.casper.protocol.ProduceEvent.fromObject(object.produce); - } - if (object.consume != null) { - if (typeof object.consume !== "object") - throw TypeError(".coop.rchain.casper.protocol.Event.consume: object expected"); - message.consume = $root.coop.rchain.casper.protocol.ConsumeEvent.fromObject(object.consume); - } - if (object.comm != null) { - if (typeof object.comm !== "object") - throw TypeError(".coop.rchain.casper.protocol.Event.comm: object expected"); - message.comm = $root.coop.rchain.casper.protocol.CommEvent.fromObject(object.comm); - } - return message; - }; - - /** - * Creates a plain object from an Event message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.Event - * @static - * @param {coop.rchain.casper.protocol.Event} message Event - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Event.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (message.produce != null && message.hasOwnProperty("produce")) { - object.produce = $root.coop.rchain.casper.protocol.ProduceEvent.toObject(message.produce, options); - if (options.oneofs) - object.event_instance = "produce"; - } - if (message.consume != null && message.hasOwnProperty("consume")) { - object.consume = $root.coop.rchain.casper.protocol.ConsumeEvent.toObject(message.consume, options); - if (options.oneofs) - object.event_instance = "consume"; - } - if (message.comm != null && message.hasOwnProperty("comm")) { - object.comm = $root.coop.rchain.casper.protocol.CommEvent.toObject(message.comm, options); - if (options.oneofs) - object.event_instance = "comm"; - } - return object; - }; - - /** - * Converts this Event to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.Event - * @instance - * @returns {Object.} JSON object - */ - Event.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Event; - })(); - - protocol.ProduceEvent = (function() { - - /** - * Properties of a ProduceEvent. - * @memberof coop.rchain.casper.protocol - * @interface IProduceEvent - * @property {Uint8Array|null} [channelsHash] ProduceEvent channelsHash - * @property {Uint8Array|null} [hash] ProduceEvent hash - * @property {number|null} [sequenceNumber] ProduceEvent sequenceNumber - */ - - /** - * Constructs a new ProduceEvent. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a ProduceEvent. - * @implements IProduceEvent - * @constructor - * @param {coop.rchain.casper.protocol.IProduceEvent=} [properties] Properties to set - */ - function ProduceEvent(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ProduceEvent channelsHash. - * @member {Uint8Array} channelsHash - * @memberof coop.rchain.casper.protocol.ProduceEvent - * @instance - */ - ProduceEvent.prototype.channelsHash = $util.newBuffer([]); - - /** - * ProduceEvent hash. - * @member {Uint8Array} hash - * @memberof coop.rchain.casper.protocol.ProduceEvent - * @instance - */ - ProduceEvent.prototype.hash = $util.newBuffer([]); - - /** - * ProduceEvent sequenceNumber. - * @member {number} sequenceNumber - * @memberof coop.rchain.casper.protocol.ProduceEvent - * @instance - */ - ProduceEvent.prototype.sequenceNumber = 0; - - /** - * Creates a new ProduceEvent instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.ProduceEvent - * @static - * @param {coop.rchain.casper.protocol.IProduceEvent=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.ProduceEvent} ProduceEvent instance - */ - ProduceEvent.create = function create(properties) { - return new ProduceEvent(properties); - }; - - /** - * Encodes the specified ProduceEvent message. Does not implicitly {@link coop.rchain.casper.protocol.ProduceEvent.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.ProduceEvent - * @static - * @param {coop.rchain.casper.protocol.IProduceEvent} message ProduceEvent message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ProduceEvent.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.channelsHash != null && message.hasOwnProperty("channelsHash")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.channelsHash); - if (message.hash != null && message.hasOwnProperty("hash")) - writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.hash); - if (message.sequenceNumber != null && message.hasOwnProperty("sequenceNumber")) - writer.uint32(/* id 3, wireType 0 =*/24).int32(message.sequenceNumber); - return writer; - }; - - /** - * Encodes the specified ProduceEvent message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.ProduceEvent.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.ProduceEvent - * @static - * @param {coop.rchain.casper.protocol.IProduceEvent} message ProduceEvent message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ProduceEvent.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ProduceEvent message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.ProduceEvent - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.ProduceEvent} ProduceEvent - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ProduceEvent.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.ProduceEvent(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.channelsHash = reader.bytes(); - break; - case 2: - message.hash = reader.bytes(); - break; - case 3: - message.sequenceNumber = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ProduceEvent message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.ProduceEvent - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.ProduceEvent} ProduceEvent - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ProduceEvent.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ProduceEvent message. - * @function verify - * @memberof coop.rchain.casper.protocol.ProduceEvent - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ProduceEvent.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.channelsHash != null && message.hasOwnProperty("channelsHash")) - if (!(message.channelsHash && typeof message.channelsHash.length === "number" || $util.isString(message.channelsHash))) - return "channelsHash: buffer expected"; - if (message.hash != null && message.hasOwnProperty("hash")) - if (!(message.hash && typeof message.hash.length === "number" || $util.isString(message.hash))) - return "hash: buffer expected"; - if (message.sequenceNumber != null && message.hasOwnProperty("sequenceNumber")) - if (!$util.isInteger(message.sequenceNumber)) - return "sequenceNumber: integer expected"; - return null; - }; - - /** - * Creates a ProduceEvent message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.ProduceEvent - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.ProduceEvent} ProduceEvent - */ - ProduceEvent.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.ProduceEvent) - return object; - var message = new $root.coop.rchain.casper.protocol.ProduceEvent(); - if (object.channelsHash != null) - if (typeof object.channelsHash === "string") - $util.base64.decode(object.channelsHash, message.channelsHash = $util.newBuffer($util.base64.length(object.channelsHash)), 0); - else if (object.channelsHash.length) - message.channelsHash = object.channelsHash; - if (object.hash != null) - if (typeof object.hash === "string") - $util.base64.decode(object.hash, message.hash = $util.newBuffer($util.base64.length(object.hash)), 0); - else if (object.hash.length) - message.hash = object.hash; - if (object.sequenceNumber != null) - message.sequenceNumber = object.sequenceNumber | 0; - return message; - }; - - /** - * Creates a plain object from a ProduceEvent message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.ProduceEvent - * @static - * @param {coop.rchain.casper.protocol.ProduceEvent} message ProduceEvent - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ProduceEvent.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if (options.bytes === String) - object.channelsHash = ""; - else { - object.channelsHash = []; - if (options.bytes !== Array) - object.channelsHash = $util.newBuffer(object.channelsHash); - } - if (options.bytes === String) - object.hash = ""; - else { - object.hash = []; - if (options.bytes !== Array) - object.hash = $util.newBuffer(object.hash); - } - object.sequenceNumber = 0; - } - if (message.channelsHash != null && message.hasOwnProperty("channelsHash")) - object.channelsHash = options.bytes === String ? $util.base64.encode(message.channelsHash, 0, message.channelsHash.length) : options.bytes === Array ? Array.prototype.slice.call(message.channelsHash) : message.channelsHash; - if (message.hash != null && message.hasOwnProperty("hash")) - object.hash = options.bytes === String ? $util.base64.encode(message.hash, 0, message.hash.length) : options.bytes === Array ? Array.prototype.slice.call(message.hash) : message.hash; - if (message.sequenceNumber != null && message.hasOwnProperty("sequenceNumber")) - object.sequenceNumber = message.sequenceNumber; - return object; - }; - - /** - * Converts this ProduceEvent to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.ProduceEvent - * @instance - * @returns {Object.} JSON object - */ - ProduceEvent.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ProduceEvent; - })(); - - protocol.ConsumeEvent = (function() { - - /** - * Properties of a ConsumeEvent. - * @memberof coop.rchain.casper.protocol - * @interface IConsumeEvent - * @property {Array.|null} [channelsHashes] ConsumeEvent channelsHashes - * @property {Uint8Array|null} [hash] ConsumeEvent hash - * @property {number|null} [sequenceNumber] ConsumeEvent sequenceNumber - */ - - /** - * Constructs a new ConsumeEvent. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a ConsumeEvent. - * @implements IConsumeEvent - * @constructor - * @param {coop.rchain.casper.protocol.IConsumeEvent=} [properties] Properties to set - */ - function ConsumeEvent(properties) { - this.channelsHashes = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ConsumeEvent channelsHashes. - * @member {Array.} channelsHashes - * @memberof coop.rchain.casper.protocol.ConsumeEvent - * @instance - */ - ConsumeEvent.prototype.channelsHashes = $util.emptyArray; - - /** - * ConsumeEvent hash. - * @member {Uint8Array} hash - * @memberof coop.rchain.casper.protocol.ConsumeEvent - * @instance - */ - ConsumeEvent.prototype.hash = $util.newBuffer([]); - - /** - * ConsumeEvent sequenceNumber. - * @member {number} sequenceNumber - * @memberof coop.rchain.casper.protocol.ConsumeEvent - * @instance - */ - ConsumeEvent.prototype.sequenceNumber = 0; - - /** - * Creates a new ConsumeEvent instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.ConsumeEvent - * @static - * @param {coop.rchain.casper.protocol.IConsumeEvent=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.ConsumeEvent} ConsumeEvent instance - */ - ConsumeEvent.create = function create(properties) { - return new ConsumeEvent(properties); - }; - - /** - * Encodes the specified ConsumeEvent message. Does not implicitly {@link coop.rchain.casper.protocol.ConsumeEvent.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.ConsumeEvent - * @static - * @param {coop.rchain.casper.protocol.IConsumeEvent} message ConsumeEvent message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ConsumeEvent.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.channelsHashes != null && message.channelsHashes.length) - for (var i = 0; i < message.channelsHashes.length; ++i) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.channelsHashes[i]); - if (message.hash != null && message.hasOwnProperty("hash")) - writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.hash); - if (message.sequenceNumber != null && message.hasOwnProperty("sequenceNumber")) - writer.uint32(/* id 3, wireType 0 =*/24).int32(message.sequenceNumber); - return writer; - }; - - /** - * Encodes the specified ConsumeEvent message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.ConsumeEvent.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.ConsumeEvent - * @static - * @param {coop.rchain.casper.protocol.IConsumeEvent} message ConsumeEvent message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ConsumeEvent.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ConsumeEvent message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.ConsumeEvent - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.ConsumeEvent} ConsumeEvent - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ConsumeEvent.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.ConsumeEvent(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.channelsHashes && message.channelsHashes.length)) - message.channelsHashes = []; - message.channelsHashes.push(reader.bytes()); - break; - case 2: - message.hash = reader.bytes(); - break; - case 3: - message.sequenceNumber = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ConsumeEvent message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.ConsumeEvent - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.ConsumeEvent} ConsumeEvent - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ConsumeEvent.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ConsumeEvent message. - * @function verify - * @memberof coop.rchain.casper.protocol.ConsumeEvent - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ConsumeEvent.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.channelsHashes != null && message.hasOwnProperty("channelsHashes")) { - if (!Array.isArray(message.channelsHashes)) - return "channelsHashes: array expected"; - for (var i = 0; i < message.channelsHashes.length; ++i) - if (!(message.channelsHashes[i] && typeof message.channelsHashes[i].length === "number" || $util.isString(message.channelsHashes[i]))) - return "channelsHashes: buffer[] expected"; - } - if (message.hash != null && message.hasOwnProperty("hash")) - if (!(message.hash && typeof message.hash.length === "number" || $util.isString(message.hash))) - return "hash: buffer expected"; - if (message.sequenceNumber != null && message.hasOwnProperty("sequenceNumber")) - if (!$util.isInteger(message.sequenceNumber)) - return "sequenceNumber: integer expected"; - return null; - }; - - /** - * Creates a ConsumeEvent message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.ConsumeEvent - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.ConsumeEvent} ConsumeEvent - */ - ConsumeEvent.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.ConsumeEvent) - return object; - var message = new $root.coop.rchain.casper.protocol.ConsumeEvent(); - if (object.channelsHashes) { - if (!Array.isArray(object.channelsHashes)) - throw TypeError(".coop.rchain.casper.protocol.ConsumeEvent.channelsHashes: array expected"); - message.channelsHashes = []; - for (var i = 0; i < object.channelsHashes.length; ++i) - if (typeof object.channelsHashes[i] === "string") - $util.base64.decode(object.channelsHashes[i], message.channelsHashes[i] = $util.newBuffer($util.base64.length(object.channelsHashes[i])), 0); - else if (object.channelsHashes[i].length) - message.channelsHashes[i] = object.channelsHashes[i]; - } - if (object.hash != null) - if (typeof object.hash === "string") - $util.base64.decode(object.hash, message.hash = $util.newBuffer($util.base64.length(object.hash)), 0); - else if (object.hash.length) - message.hash = object.hash; - if (object.sequenceNumber != null) - message.sequenceNumber = object.sequenceNumber | 0; - return message; - }; - - /** - * Creates a plain object from a ConsumeEvent message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.ConsumeEvent - * @static - * @param {coop.rchain.casper.protocol.ConsumeEvent} message ConsumeEvent - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ConsumeEvent.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.channelsHashes = []; - if (options.defaults) { - if (options.bytes === String) - object.hash = ""; - else { - object.hash = []; - if (options.bytes !== Array) - object.hash = $util.newBuffer(object.hash); - } - object.sequenceNumber = 0; - } - if (message.channelsHashes && message.channelsHashes.length) { - object.channelsHashes = []; - for (var j = 0; j < message.channelsHashes.length; ++j) - object.channelsHashes[j] = options.bytes === String ? $util.base64.encode(message.channelsHashes[j], 0, message.channelsHashes[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.channelsHashes[j]) : message.channelsHashes[j]; - } - if (message.hash != null && message.hasOwnProperty("hash")) - object.hash = options.bytes === String ? $util.base64.encode(message.hash, 0, message.hash.length) : options.bytes === Array ? Array.prototype.slice.call(message.hash) : message.hash; - if (message.sequenceNumber != null && message.hasOwnProperty("sequenceNumber")) - object.sequenceNumber = message.sequenceNumber; - return object; - }; - - /** - * Converts this ConsumeEvent to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.ConsumeEvent - * @instance - * @returns {Object.} JSON object - */ - ConsumeEvent.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ConsumeEvent; - })(); - - protocol.CommEvent = (function() { - - /** - * Properties of a CommEvent. - * @memberof coop.rchain.casper.protocol - * @interface ICommEvent - * @property {coop.rchain.casper.protocol.IConsumeEvent|null} [consume] CommEvent consume - * @property {Array.|null} [produces] CommEvent produces - */ - - /** - * Constructs a new CommEvent. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a CommEvent. - * @implements ICommEvent - * @constructor - * @param {coop.rchain.casper.protocol.ICommEvent=} [properties] Properties to set - */ - function CommEvent(properties) { - this.produces = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * CommEvent consume. - * @member {coop.rchain.casper.protocol.IConsumeEvent|null|undefined} consume - * @memberof coop.rchain.casper.protocol.CommEvent - * @instance - */ - CommEvent.prototype.consume = null; - - /** - * CommEvent produces. - * @member {Array.} produces - * @memberof coop.rchain.casper.protocol.CommEvent - * @instance - */ - CommEvent.prototype.produces = $util.emptyArray; - - /** - * Creates a new CommEvent instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.CommEvent - * @static - * @param {coop.rchain.casper.protocol.ICommEvent=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.CommEvent} CommEvent instance - */ - CommEvent.create = function create(properties) { - return new CommEvent(properties); - }; - - /** - * Encodes the specified CommEvent message. Does not implicitly {@link coop.rchain.casper.protocol.CommEvent.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.CommEvent - * @static - * @param {coop.rchain.casper.protocol.ICommEvent} message CommEvent message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - CommEvent.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.consume != null && message.hasOwnProperty("consume")) - $root.coop.rchain.casper.protocol.ConsumeEvent.encode(message.consume, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.produces != null && message.produces.length) - for (var i = 0; i < message.produces.length; ++i) - $root.coop.rchain.casper.protocol.ProduceEvent.encode(message.produces[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified CommEvent message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.CommEvent.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.CommEvent - * @static - * @param {coop.rchain.casper.protocol.ICommEvent} message CommEvent message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - CommEvent.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a CommEvent message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.CommEvent - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.CommEvent} CommEvent - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - CommEvent.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.CommEvent(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.consume = $root.coop.rchain.casper.protocol.ConsumeEvent.decode(reader, reader.uint32()); - break; - case 2: - if (!(message.produces && message.produces.length)) - message.produces = []; - message.produces.push($root.coop.rchain.casper.protocol.ProduceEvent.decode(reader, reader.uint32())); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a CommEvent message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.CommEvent - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.CommEvent} CommEvent - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - CommEvent.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a CommEvent message. - * @function verify - * @memberof coop.rchain.casper.protocol.CommEvent - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - CommEvent.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.consume != null && message.hasOwnProperty("consume")) { - var error = $root.coop.rchain.casper.protocol.ConsumeEvent.verify(message.consume); - if (error) - return "consume." + error; - } - if (message.produces != null && message.hasOwnProperty("produces")) { - if (!Array.isArray(message.produces)) - return "produces: array expected"; - for (var i = 0; i < message.produces.length; ++i) { - var error = $root.coop.rchain.casper.protocol.ProduceEvent.verify(message.produces[i]); - if (error) - return "produces." + error; - } - } - return null; - }; - - /** - * Creates a CommEvent message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.CommEvent - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.CommEvent} CommEvent - */ - CommEvent.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.CommEvent) - return object; - var message = new $root.coop.rchain.casper.protocol.CommEvent(); - if (object.consume != null) { - if (typeof object.consume !== "object") - throw TypeError(".coop.rchain.casper.protocol.CommEvent.consume: object expected"); - message.consume = $root.coop.rchain.casper.protocol.ConsumeEvent.fromObject(object.consume); - } - if (object.produces) { - if (!Array.isArray(object.produces)) - throw TypeError(".coop.rchain.casper.protocol.CommEvent.produces: array expected"); - message.produces = []; - for (var i = 0; i < object.produces.length; ++i) { - if (typeof object.produces[i] !== "object") - throw TypeError(".coop.rchain.casper.protocol.CommEvent.produces: object expected"); - message.produces[i] = $root.coop.rchain.casper.protocol.ProduceEvent.fromObject(object.produces[i]); - } - } - return message; - }; - - /** - * Creates a plain object from a CommEvent message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.CommEvent - * @static - * @param {coop.rchain.casper.protocol.CommEvent} message CommEvent - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - CommEvent.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.produces = []; - if (options.defaults) - object.consume = null; - if (message.consume != null && message.hasOwnProperty("consume")) - object.consume = $root.coop.rchain.casper.protocol.ConsumeEvent.toObject(message.consume, options); - if (message.produces && message.produces.length) { - object.produces = []; - for (var j = 0; j < message.produces.length; ++j) - object.produces[j] = $root.coop.rchain.casper.protocol.ProduceEvent.toObject(message.produces[j], options); - } - return object; - }; - - /** - * Converts this CommEvent to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.CommEvent - * @instance - * @returns {Object.} JSON object - */ - CommEvent.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return CommEvent; - })(); - - protocol.Bond = (function() { - - /** - * Properties of a Bond. - * @memberof coop.rchain.casper.protocol - * @interface IBond - * @property {Uint8Array|null} [validator] Bond validator - * @property {number|Long|null} [stake] Bond stake - */ - - /** - * Constructs a new Bond. - * @memberof coop.rchain.casper.protocol - * @classdesc Represents a Bond. - * @implements IBond - * @constructor - * @param {coop.rchain.casper.protocol.IBond=} [properties] Properties to set - */ - function Bond(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Bond validator. - * @member {Uint8Array} validator - * @memberof coop.rchain.casper.protocol.Bond - * @instance - */ - Bond.prototype.validator = $util.newBuffer([]); - - /** - * Bond stake. - * @member {number|Long} stake - * @memberof coop.rchain.casper.protocol.Bond - * @instance - */ - Bond.prototype.stake = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Creates a new Bond instance using the specified properties. - * @function create - * @memberof coop.rchain.casper.protocol.Bond - * @static - * @param {coop.rchain.casper.protocol.IBond=} [properties] Properties to set - * @returns {coop.rchain.casper.protocol.Bond} Bond instance - */ - Bond.create = function create(properties) { - return new Bond(properties); - }; - - /** - * Encodes the specified Bond message. Does not implicitly {@link coop.rchain.casper.protocol.Bond.verify|verify} messages. - * @function encode - * @memberof coop.rchain.casper.protocol.Bond - * @static - * @param {coop.rchain.casper.protocol.IBond} message Bond message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Bond.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.validator != null && message.hasOwnProperty("validator")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.validator); - if (message.stake != null && message.hasOwnProperty("stake")) - writer.uint32(/* id 2, wireType 0 =*/16).int64(message.stake); - return writer; - }; - - /** - * Encodes the specified Bond message, length delimited. Does not implicitly {@link coop.rchain.casper.protocol.Bond.verify|verify} messages. - * @function encodeDelimited - * @memberof coop.rchain.casper.protocol.Bond - * @static - * @param {coop.rchain.casper.protocol.IBond} message Bond message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Bond.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Bond message from the specified reader or buffer. - * @function decode - * @memberof coop.rchain.casper.protocol.Bond - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {coop.rchain.casper.protocol.Bond} Bond - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Bond.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.coop.rchain.casper.protocol.Bond(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.validator = reader.bytes(); - break; - case 2: - message.stake = reader.int64(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Bond message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof coop.rchain.casper.protocol.Bond - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {coop.rchain.casper.protocol.Bond} Bond - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Bond.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Bond message. - * @function verify - * @memberof coop.rchain.casper.protocol.Bond - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Bond.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.validator != null && message.hasOwnProperty("validator")) - if (!(message.validator && typeof message.validator.length === "number" || $util.isString(message.validator))) - return "validator: buffer expected"; - if (message.stake != null && message.hasOwnProperty("stake")) - if (!$util.isInteger(message.stake) && !(message.stake && $util.isInteger(message.stake.low) && $util.isInteger(message.stake.high))) - return "stake: integer|Long expected"; - return null; - }; - - /** - * Creates a Bond message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof coop.rchain.casper.protocol.Bond - * @static - * @param {Object.} object Plain object - * @returns {coop.rchain.casper.protocol.Bond} Bond - */ - Bond.fromObject = function fromObject(object) { - if (object instanceof $root.coop.rchain.casper.protocol.Bond) - return object; - var message = new $root.coop.rchain.casper.protocol.Bond(); - if (object.validator != null) - if (typeof object.validator === "string") - $util.base64.decode(object.validator, message.validator = $util.newBuffer($util.base64.length(object.validator)), 0); - else if (object.validator.length) - message.validator = object.validator; - if (object.stake != null) - if ($util.Long) - (message.stake = $util.Long.fromValue(object.stake)).unsigned = false; - else if (typeof object.stake === "string") - message.stake = parseInt(object.stake, 10); - else if (typeof object.stake === "number") - message.stake = object.stake; - else if (typeof object.stake === "object") - message.stake = new $util.LongBits(object.stake.low >>> 0, object.stake.high >>> 0).toNumber(); - return message; - }; - - /** - * Creates a plain object from a Bond message. Also converts values to other types if specified. - * @function toObject - * @memberof coop.rchain.casper.protocol.Bond - * @static - * @param {coop.rchain.casper.protocol.Bond} message Bond - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Bond.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if (options.bytes === String) - object.validator = ""; - else { - object.validator = []; - if (options.bytes !== Array) - object.validator = $util.newBuffer(object.validator); - } - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.stake = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.stake = options.longs === String ? "0" : 0; - } - if (message.validator != null && message.hasOwnProperty("validator")) - object.validator = options.bytes === String ? $util.base64.encode(message.validator, 0, message.validator.length) : options.bytes === Array ? Array.prototype.slice.call(message.validator) : message.validator; - if (message.stake != null && message.hasOwnProperty("stake")) - if (typeof message.stake === "number") - object.stake = options.longs === String ? String(message.stake) : message.stake; - else - object.stake = options.longs === String ? $util.Long.prototype.toString.call(message.stake) : options.longs === Number ? new $util.LongBits(message.stake.low >>> 0, message.stake.high >>> 0).toNumber() : message.stake; - return object; - }; - - /** - * Converts this Bond to JSON. - * @function toJSON - * @memberof coop.rchain.casper.protocol.Bond - * @instance - * @returns {Object.} JSON object - */ - Bond.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Bond; - })(); - - return protocol; - })(); - - return casper; - })(); - - return rchain; - })(); - - return coop; -})(); - -$root.Par = (function() { - - /** - * Properties of a Par. - * @exports IPar - * @interface IPar - * @property {Array.|null} [sends] Par sends - * @property {Array.|null} [receives] Par receives - * @property {Array.|null} [news] Par news - * @property {Array.|null} [exprs] Par exprs - * @property {Array.|null} [matches] Par matches - * @property {Array.|null} [ids] Par ids - * @property {Array.|null} [bundles] Par bundles - * @property {Array.|null} [connectives] Par connectives - * @property {Uint8Array|null} [locallyFree] Par locallyFree - * @property {boolean|null} [connective_used] Par connective_used - */ - - /** - * Constructs a new Par. - * @exports Par - * @classdesc Rholang process - * - * For example, `@0!(1) | @2!(3) | for(x <- @0) { Nil }` has two sends - * and one receive. - * - * The Nil process is a `Par` with no sends, receives, etc. - * @implements IPar - * @constructor - * @param {IPar=} [properties] Properties to set - */ - function Par(properties) { - this.sends = []; - this.receives = []; - this.news = []; - this.exprs = []; - this.matches = []; - this.ids = []; - this.bundles = []; - this.connectives = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Par sends. - * @member {Array.} sends - * @memberof Par - * @instance - */ - Par.prototype.sends = $util.emptyArray; - - /** - * Par receives. - * @member {Array.} receives - * @memberof Par - * @instance - */ - Par.prototype.receives = $util.emptyArray; - - /** - * Par news. - * @member {Array.} news - * @memberof Par - * @instance - */ - Par.prototype.news = $util.emptyArray; - - /** - * Par exprs. - * @member {Array.} exprs - * @memberof Par - * @instance - */ - Par.prototype.exprs = $util.emptyArray; - - /** - * Par matches. - * @member {Array.} matches - * @memberof Par - * @instance - */ - Par.prototype.matches = $util.emptyArray; - - /** - * Par ids. - * @member {Array.} ids - * @memberof Par - * @instance - */ - Par.prototype.ids = $util.emptyArray; - - /** - * Par bundles. - * @member {Array.} bundles - * @memberof Par - * @instance - */ - Par.prototype.bundles = $util.emptyArray; - - /** - * Par connectives. - * @member {Array.} connectives - * @memberof Par - * @instance - */ - Par.prototype.connectives = $util.emptyArray; - - /** - * Par locallyFree. - * @member {Uint8Array} locallyFree - * @memberof Par - * @instance - */ - Par.prototype.locallyFree = $util.newBuffer([]); - - /** - * Par connective_used. - * @member {boolean} connective_used - * @memberof Par - * @instance - */ - Par.prototype.connective_used = false; - - /** - * Creates a new Par instance using the specified properties. - * @function create - * @memberof Par - * @static - * @param {IPar=} [properties] Properties to set - * @returns {Par} Par instance - */ - Par.create = function create(properties) { - return new Par(properties); - }; - - /** - * Encodes the specified Par message. Does not implicitly {@link Par.verify|verify} messages. - * @function encode - * @memberof Par - * @static - * @param {IPar} message Par message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Par.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.sends != null && message.sends.length) - for (var i = 0; i < message.sends.length; ++i) - $root.Send.encode(message.sends[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.receives != null && message.receives.length) - for (var i = 0; i < message.receives.length; ++i) - $root.Receive.encode(message.receives[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.news != null && message.news.length) - for (var i = 0; i < message.news.length; ++i) - $root.New.encode(message.news[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.exprs != null && message.exprs.length) - for (var i = 0; i < message.exprs.length; ++i) - $root.Expr.encode(message.exprs[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); - if (message.matches != null && message.matches.length) - for (var i = 0; i < message.matches.length; ++i) - $root.Match.encode(message.matches[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); - if (message.ids != null && message.ids.length) - for (var i = 0; i < message.ids.length; ++i) - $root.GPrivate.encode(message.ids[i], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); - if (message.connectives != null && message.connectives.length) - for (var i = 0; i < message.connectives.length; ++i) - $root.Connective.encode(message.connectives[i], writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - writer.uint32(/* id 9, wireType 2 =*/74).bytes(message.locallyFree); - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - writer.uint32(/* id 10, wireType 0 =*/80).bool(message.connective_used); - if (message.bundles != null && message.bundles.length) - for (var i = 0; i < message.bundles.length; ++i) - $root.Bundle.encode(message.bundles[i], writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified Par message, length delimited. Does not implicitly {@link Par.verify|verify} messages. - * @function encodeDelimited - * @memberof Par - * @static - * @param {IPar} message Par message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Par.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Par message from the specified reader or buffer. - * @function decode - * @memberof Par - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {Par} Par - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Par.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Par(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.sends && message.sends.length)) - message.sends = []; - message.sends.push($root.Send.decode(reader, reader.uint32())); - break; - case 2: - if (!(message.receives && message.receives.length)) - message.receives = []; - message.receives.push($root.Receive.decode(reader, reader.uint32())); - break; - case 4: - if (!(message.news && message.news.length)) - message.news = []; - message.news.push($root.New.decode(reader, reader.uint32())); - break; - case 5: - if (!(message.exprs && message.exprs.length)) - message.exprs = []; - message.exprs.push($root.Expr.decode(reader, reader.uint32())); - break; - case 6: - if (!(message.matches && message.matches.length)) - message.matches = []; - message.matches.push($root.Match.decode(reader, reader.uint32())); - break; - case 7: - if (!(message.ids && message.ids.length)) - message.ids = []; - message.ids.push($root.GPrivate.decode(reader, reader.uint32())); - break; - case 11: - if (!(message.bundles && message.bundles.length)) - message.bundles = []; - message.bundles.push($root.Bundle.decode(reader, reader.uint32())); - break; - case 8: - if (!(message.connectives && message.connectives.length)) - message.connectives = []; - message.connectives.push($root.Connective.decode(reader, reader.uint32())); - break; - case 9: - message.locallyFree = reader.bytes(); - break; - case 10: - message.connective_used = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Par message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof Par - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {Par} Par - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Par.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Par message. - * @function verify - * @memberof Par - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Par.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.sends != null && message.hasOwnProperty("sends")) { - if (!Array.isArray(message.sends)) - return "sends: array expected"; - for (var i = 0; i < message.sends.length; ++i) { - var error = $root.Send.verify(message.sends[i]); - if (error) - return "sends." + error; - } - } - if (message.receives != null && message.hasOwnProperty("receives")) { - if (!Array.isArray(message.receives)) - return "receives: array expected"; - for (var i = 0; i < message.receives.length; ++i) { - var error = $root.Receive.verify(message.receives[i]); - if (error) - return "receives." + error; - } - } - if (message.news != null && message.hasOwnProperty("news")) { - if (!Array.isArray(message.news)) - return "news: array expected"; - for (var i = 0; i < message.news.length; ++i) { - var error = $root.New.verify(message.news[i]); - if (error) - return "news." + error; - } - } - if (message.exprs != null && message.hasOwnProperty("exprs")) { - if (!Array.isArray(message.exprs)) - return "exprs: array expected"; - for (var i = 0; i < message.exprs.length; ++i) { - var error = $root.Expr.verify(message.exprs[i]); - if (error) - return "exprs." + error; - } - } - if (message.matches != null && message.hasOwnProperty("matches")) { - if (!Array.isArray(message.matches)) - return "matches: array expected"; - for (var i = 0; i < message.matches.length; ++i) { - var error = $root.Match.verify(message.matches[i]); - if (error) - return "matches." + error; - } - } - if (message.ids != null && message.hasOwnProperty("ids")) { - if (!Array.isArray(message.ids)) - return "ids: array expected"; - for (var i = 0; i < message.ids.length; ++i) { - var error = $root.GPrivate.verify(message.ids[i]); - if (error) - return "ids." + error; - } - } - if (message.bundles != null && message.hasOwnProperty("bundles")) { - if (!Array.isArray(message.bundles)) - return "bundles: array expected"; - for (var i = 0; i < message.bundles.length; ++i) { - var error = $root.Bundle.verify(message.bundles[i]); - if (error) - return "bundles." + error; - } - } - if (message.connectives != null && message.hasOwnProperty("connectives")) { - if (!Array.isArray(message.connectives)) - return "connectives: array expected"; - for (var i = 0; i < message.connectives.length; ++i) { - var error = $root.Connective.verify(message.connectives[i]); - if (error) - return "connectives." + error; - } - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - if (!(message.locallyFree && typeof message.locallyFree.length === "number" || $util.isString(message.locallyFree))) - return "locallyFree: buffer expected"; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - if (typeof message.connective_used !== "boolean") - return "connective_used: boolean expected"; - return null; - }; - - /** - * Creates a Par message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof Par - * @static - * @param {Object.} object Plain object - * @returns {Par} Par - */ - Par.fromObject = function fromObject(object) { - if (object instanceof $root.Par) - return object; - var message = new $root.Par(); - if (object.sends) { - if (!Array.isArray(object.sends)) - throw TypeError(".Par.sends: array expected"); - message.sends = []; - for (var i = 0; i < object.sends.length; ++i) { - if (typeof object.sends[i] !== "object") - throw TypeError(".Par.sends: object expected"); - message.sends[i] = $root.Send.fromObject(object.sends[i]); - } - } - if (object.receives) { - if (!Array.isArray(object.receives)) - throw TypeError(".Par.receives: array expected"); - message.receives = []; - for (var i = 0; i < object.receives.length; ++i) { - if (typeof object.receives[i] !== "object") - throw TypeError(".Par.receives: object expected"); - message.receives[i] = $root.Receive.fromObject(object.receives[i]); - } - } - if (object.news) { - if (!Array.isArray(object.news)) - throw TypeError(".Par.news: array expected"); - message.news = []; - for (var i = 0; i < object.news.length; ++i) { - if (typeof object.news[i] !== "object") - throw TypeError(".Par.news: object expected"); - message.news[i] = $root.New.fromObject(object.news[i]); - } - } - if (object.exprs) { - if (!Array.isArray(object.exprs)) - throw TypeError(".Par.exprs: array expected"); - message.exprs = []; - for (var i = 0; i < object.exprs.length; ++i) { - if (typeof object.exprs[i] !== "object") - throw TypeError(".Par.exprs: object expected"); - message.exprs[i] = $root.Expr.fromObject(object.exprs[i]); - } - } - if (object.matches) { - if (!Array.isArray(object.matches)) - throw TypeError(".Par.matches: array expected"); - message.matches = []; - for (var i = 0; i < object.matches.length; ++i) { - if (typeof object.matches[i] !== "object") - throw TypeError(".Par.matches: object expected"); - message.matches[i] = $root.Match.fromObject(object.matches[i]); - } - } - if (object.ids) { - if (!Array.isArray(object.ids)) - throw TypeError(".Par.ids: array expected"); - message.ids = []; - for (var i = 0; i < object.ids.length; ++i) { - if (typeof object.ids[i] !== "object") - throw TypeError(".Par.ids: object expected"); - message.ids[i] = $root.GPrivate.fromObject(object.ids[i]); - } - } - if (object.bundles) { - if (!Array.isArray(object.bundles)) - throw TypeError(".Par.bundles: array expected"); - message.bundles = []; - for (var i = 0; i < object.bundles.length; ++i) { - if (typeof object.bundles[i] !== "object") - throw TypeError(".Par.bundles: object expected"); - message.bundles[i] = $root.Bundle.fromObject(object.bundles[i]); - } - } - if (object.connectives) { - if (!Array.isArray(object.connectives)) - throw TypeError(".Par.connectives: array expected"); - message.connectives = []; - for (var i = 0; i < object.connectives.length; ++i) { - if (typeof object.connectives[i] !== "object") - throw TypeError(".Par.connectives: object expected"); - message.connectives[i] = $root.Connective.fromObject(object.connectives[i]); - } - } - if (object.locallyFree != null) - if (typeof object.locallyFree === "string") - $util.base64.decode(object.locallyFree, message.locallyFree = $util.newBuffer($util.base64.length(object.locallyFree)), 0); - else if (object.locallyFree.length) - message.locallyFree = object.locallyFree; - if (object.connective_used != null) - message.connective_used = Boolean(object.connective_used); - return message; - }; - - /** - * Creates a plain object from a Par message. Also converts values to other types if specified. - * @function toObject - * @memberof Par - * @static - * @param {Par} message Par - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Par.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) { - object.sends = []; - object.receives = []; - object.news = []; - object.exprs = []; - object.matches = []; - object.ids = []; - object.connectives = []; - object.bundles = []; - } - if (options.defaults) { - if (options.bytes === String) - object.locallyFree = ""; - else { - object.locallyFree = []; - if (options.bytes !== Array) - object.locallyFree = $util.newBuffer(object.locallyFree); - } - object.connective_used = false; - } - if (message.sends && message.sends.length) { - object.sends = []; - for (var j = 0; j < message.sends.length; ++j) - object.sends[j] = $root.Send.toObject(message.sends[j], options); - } - if (message.receives && message.receives.length) { - object.receives = []; - for (var j = 0; j < message.receives.length; ++j) - object.receives[j] = $root.Receive.toObject(message.receives[j], options); - } - if (message.news && message.news.length) { - object.news = []; - for (var j = 0; j < message.news.length; ++j) - object.news[j] = $root.New.toObject(message.news[j], options); - } - if (message.exprs && message.exprs.length) { - object.exprs = []; - for (var j = 0; j < message.exprs.length; ++j) - object.exprs[j] = $root.Expr.toObject(message.exprs[j], options); - } - if (message.matches && message.matches.length) { - object.matches = []; - for (var j = 0; j < message.matches.length; ++j) - object.matches[j] = $root.Match.toObject(message.matches[j], options); - } - if (message.ids && message.ids.length) { - object.ids = []; - for (var j = 0; j < message.ids.length; ++j) - object.ids[j] = $root.GPrivate.toObject(message.ids[j], options); - } - if (message.connectives && message.connectives.length) { - object.connectives = []; - for (var j = 0; j < message.connectives.length; ++j) - object.connectives[j] = $root.Connective.toObject(message.connectives[j], options); - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - object.locallyFree = options.bytes === String ? $util.base64.encode(message.locallyFree, 0, message.locallyFree.length) : options.bytes === Array ? Array.prototype.slice.call(message.locallyFree) : message.locallyFree; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - object.connective_used = message.connective_used; - if (message.bundles && message.bundles.length) { - object.bundles = []; - for (var j = 0; j < message.bundles.length; ++j) - object.bundles[j] = $root.Bundle.toObject(message.bundles[j], options); - } - return object; - }; - - /** - * Converts this Par to JSON. - * @function toJSON - * @memberof Par - * @instance - * @returns {Object.} JSON object - */ - Par.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Par; -})(); - -$root.TaggedContinuation = (function() { - - /** - * Properties of a TaggedContinuation. - * @exports ITaggedContinuation - * @interface ITaggedContinuation - * @property {IParWithRandom|null} [par_body] TaggedContinuation par_body - * @property {number|Long|null} [scala_body_ref] TaggedContinuation scala_body_ref - */ - - /** - * Constructs a new TaggedContinuation. - * @exports TaggedContinuation - * @classdesc Either rholang code or code built in to the interpreter. - * @implements ITaggedContinuation - * @constructor - * @param {ITaggedContinuation=} [properties] Properties to set - */ - function TaggedContinuation(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * TaggedContinuation par_body. - * @member {IParWithRandom|null|undefined} par_body - * @memberof TaggedContinuation - * @instance - */ - TaggedContinuation.prototype.par_body = null; - - /** - * TaggedContinuation scala_body_ref. - * @member {number|Long} scala_body_ref - * @memberof TaggedContinuation - * @instance - */ - TaggedContinuation.prototype.scala_body_ref = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * TaggedContinuation tagged_cont. - * @member {"par_body"|"scala_body_ref"|undefined} tagged_cont - * @memberof TaggedContinuation - * @instance - */ - Object.defineProperty(TaggedContinuation.prototype, "tagged_cont", { - get: $util.oneOfGetter($oneOfFields = ["par_body", "scala_body_ref"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * Creates a new TaggedContinuation instance using the specified properties. - * @function create - * @memberof TaggedContinuation - * @static - * @param {ITaggedContinuation=} [properties] Properties to set - * @returns {TaggedContinuation} TaggedContinuation instance - */ - TaggedContinuation.create = function create(properties) { - return new TaggedContinuation(properties); - }; - - /** - * Encodes the specified TaggedContinuation message. Does not implicitly {@link TaggedContinuation.verify|verify} messages. - * @function encode - * @memberof TaggedContinuation - * @static - * @param {ITaggedContinuation} message TaggedContinuation message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - TaggedContinuation.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.par_body != null && message.hasOwnProperty("par_body")) - $root.ParWithRandom.encode(message.par_body, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.scala_body_ref != null && message.hasOwnProperty("scala_body_ref")) - writer.uint32(/* id 2, wireType 0 =*/16).int64(message.scala_body_ref); - return writer; - }; - - /** - * Encodes the specified TaggedContinuation message, length delimited. Does not implicitly {@link TaggedContinuation.verify|verify} messages. - * @function encodeDelimited - * @memberof TaggedContinuation - * @static - * @param {ITaggedContinuation} message TaggedContinuation message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - TaggedContinuation.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a TaggedContinuation message from the specified reader or buffer. - * @function decode - * @memberof TaggedContinuation - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {TaggedContinuation} TaggedContinuation - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - TaggedContinuation.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.TaggedContinuation(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.par_body = $root.ParWithRandom.decode(reader, reader.uint32()); - break; - case 2: - message.scala_body_ref = reader.int64(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a TaggedContinuation message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof TaggedContinuation - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {TaggedContinuation} TaggedContinuation - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - TaggedContinuation.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a TaggedContinuation message. - * @function verify - * @memberof TaggedContinuation - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - TaggedContinuation.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - var properties = {}; - if (message.par_body != null && message.hasOwnProperty("par_body")) { - properties.tagged_cont = 1; - { - var error = $root.ParWithRandom.verify(message.par_body); - if (error) - return "par_body." + error; - } - } - if (message.scala_body_ref != null && message.hasOwnProperty("scala_body_ref")) { - if (properties.tagged_cont === 1) - return "tagged_cont: multiple values"; - properties.tagged_cont = 1; - if (!$util.isInteger(message.scala_body_ref) && !(message.scala_body_ref && $util.isInteger(message.scala_body_ref.low) && $util.isInteger(message.scala_body_ref.high))) - return "scala_body_ref: integer|Long expected"; - } - return null; - }; - - /** - * Creates a TaggedContinuation message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof TaggedContinuation - * @static - * @param {Object.} object Plain object - * @returns {TaggedContinuation} TaggedContinuation - */ - TaggedContinuation.fromObject = function fromObject(object) { - if (object instanceof $root.TaggedContinuation) - return object; - var message = new $root.TaggedContinuation(); - if (object.par_body != null) { - if (typeof object.par_body !== "object") - throw TypeError(".TaggedContinuation.par_body: object expected"); - message.par_body = $root.ParWithRandom.fromObject(object.par_body); - } - if (object.scala_body_ref != null) - if ($util.Long) - (message.scala_body_ref = $util.Long.fromValue(object.scala_body_ref)).unsigned = false; - else if (typeof object.scala_body_ref === "string") - message.scala_body_ref = parseInt(object.scala_body_ref, 10); - else if (typeof object.scala_body_ref === "number") - message.scala_body_ref = object.scala_body_ref; - else if (typeof object.scala_body_ref === "object") - message.scala_body_ref = new $util.LongBits(object.scala_body_ref.low >>> 0, object.scala_body_ref.high >>> 0).toNumber(); - return message; - }; - - /** - * Creates a plain object from a TaggedContinuation message. Also converts values to other types if specified. - * @function toObject - * @memberof TaggedContinuation - * @static - * @param {TaggedContinuation} message TaggedContinuation - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - TaggedContinuation.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (message.par_body != null && message.hasOwnProperty("par_body")) { - object.par_body = $root.ParWithRandom.toObject(message.par_body, options); - if (options.oneofs) - object.tagged_cont = "par_body"; - } - if (message.scala_body_ref != null && message.hasOwnProperty("scala_body_ref")) { - if (typeof message.scala_body_ref === "number") - object.scala_body_ref = options.longs === String ? String(message.scala_body_ref) : message.scala_body_ref; - else - object.scala_body_ref = options.longs === String ? $util.Long.prototype.toString.call(message.scala_body_ref) : options.longs === Number ? new $util.LongBits(message.scala_body_ref.low >>> 0, message.scala_body_ref.high >>> 0).toNumber() : message.scala_body_ref; - if (options.oneofs) - object.tagged_cont = "scala_body_ref"; - } - return object; - }; - - /** - * Converts this TaggedContinuation to JSON. - * @function toJSON - * @memberof TaggedContinuation - * @instance - * @returns {Object.} JSON object - */ - TaggedContinuation.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return TaggedContinuation; -})(); - -$root.ParWithRandom = (function() { - - /** - * Properties of a ParWithRandom. - * @exports IParWithRandom - * @interface IParWithRandom - * @property {IPar|null} [body] ParWithRandom body - * @property {Uint8Array|null} [randomState] ParWithRandom randomState - */ - - /** - * Constructs a new ParWithRandom. - * @exports ParWithRandom - * @classdesc Rholang code along with the state of a split random number - * generator for generating new unforgeable names. - * @implements IParWithRandom - * @constructor - * @param {IParWithRandom=} [properties] Properties to set - */ - function ParWithRandom(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ParWithRandom body. - * @member {IPar|null|undefined} body - * @memberof ParWithRandom - * @instance - */ - ParWithRandom.prototype.body = null; - - /** - * ParWithRandom randomState. - * @member {Uint8Array} randomState - * @memberof ParWithRandom - * @instance - */ - ParWithRandom.prototype.randomState = $util.newBuffer([]); - - /** - * Creates a new ParWithRandom instance using the specified properties. - * @function create - * @memberof ParWithRandom - * @static - * @param {IParWithRandom=} [properties] Properties to set - * @returns {ParWithRandom} ParWithRandom instance - */ - ParWithRandom.create = function create(properties) { - return new ParWithRandom(properties); - }; - - /** - * Encodes the specified ParWithRandom message. Does not implicitly {@link ParWithRandom.verify|verify} messages. - * @function encode - * @memberof ParWithRandom - * @static - * @param {IParWithRandom} message ParWithRandom message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ParWithRandom.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.body != null && message.hasOwnProperty("body")) - $root.Par.encode(message.body, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.randomState != null && message.hasOwnProperty("randomState")) - writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.randomState); - return writer; - }; - - /** - * Encodes the specified ParWithRandom message, length delimited. Does not implicitly {@link ParWithRandom.verify|verify} messages. - * @function encodeDelimited - * @memberof ParWithRandom - * @static - * @param {IParWithRandom} message ParWithRandom message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ParWithRandom.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ParWithRandom message from the specified reader or buffer. - * @function decode - * @memberof ParWithRandom - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {ParWithRandom} ParWithRandom - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ParWithRandom.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ParWithRandom(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.body = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.randomState = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ParWithRandom message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof ParWithRandom - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {ParWithRandom} ParWithRandom - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ParWithRandom.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ParWithRandom message. - * @function verify - * @memberof ParWithRandom - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ParWithRandom.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.body != null && message.hasOwnProperty("body")) { - var error = $root.Par.verify(message.body); - if (error) - return "body." + error; - } - if (message.randomState != null && message.hasOwnProperty("randomState")) - if (!(message.randomState && typeof message.randomState.length === "number" || $util.isString(message.randomState))) - return "randomState: buffer expected"; - return null; - }; - - /** - * Creates a ParWithRandom message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof ParWithRandom - * @static - * @param {Object.} object Plain object - * @returns {ParWithRandom} ParWithRandom - */ - ParWithRandom.fromObject = function fromObject(object) { - if (object instanceof $root.ParWithRandom) - return object; - var message = new $root.ParWithRandom(); - if (object.body != null) { - if (typeof object.body !== "object") - throw TypeError(".ParWithRandom.body: object expected"); - message.body = $root.Par.fromObject(object.body); - } - if (object.randomState != null) - if (typeof object.randomState === "string") - $util.base64.decode(object.randomState, message.randomState = $util.newBuffer($util.base64.length(object.randomState)), 0); - else if (object.randomState.length) - message.randomState = object.randomState; - return message; - }; - - /** - * Creates a plain object from a ParWithRandom message. Also converts values to other types if specified. - * @function toObject - * @memberof ParWithRandom - * @static - * @param {ParWithRandom} message ParWithRandom - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ParWithRandom.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.body = null; - if (options.bytes === String) - object.randomState = ""; - else { - object.randomState = []; - if (options.bytes !== Array) - object.randomState = $util.newBuffer(object.randomState); - } - } - if (message.body != null && message.hasOwnProperty("body")) - object.body = $root.Par.toObject(message.body, options); - if (message.randomState != null && message.hasOwnProperty("randomState")) - object.randomState = options.bytes === String ? $util.base64.encode(message.randomState, 0, message.randomState.length) : options.bytes === Array ? Array.prototype.slice.call(message.randomState) : message.randomState; - return object; - }; - - /** - * Converts this ParWithRandom to JSON. - * @function toJSON - * @memberof ParWithRandom - * @instance - * @returns {Object.} JSON object - */ - ParWithRandom.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ParWithRandom; -})(); - -$root.PCost = (function() { - - /** - * Properties of a PCost. - * @exports IPCost - * @interface IPCost - * @property {number|Long|null} [cost] PCost cost - */ - - /** - * Constructs a new PCost. - * @exports PCost - * @classdesc Cost of the performed operations. - * @implements IPCost - * @constructor - * @param {IPCost=} [properties] Properties to set - */ - function PCost(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * PCost cost. - * @member {number|Long} cost - * @memberof PCost - * @instance - */ - PCost.prototype.cost = $util.Long ? $util.Long.fromBits(0,0,true) : 0; - - /** - * Creates a new PCost instance using the specified properties. - * @function create - * @memberof PCost - * @static - * @param {IPCost=} [properties] Properties to set - * @returns {PCost} PCost instance - */ - PCost.create = function create(properties) { - return new PCost(properties); - }; - - /** - * Encodes the specified PCost message. Does not implicitly {@link PCost.verify|verify} messages. - * @function encode - * @memberof PCost - * @static - * @param {IPCost} message PCost message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - PCost.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.cost != null && message.hasOwnProperty("cost")) - writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.cost); - return writer; - }; - - /** - * Encodes the specified PCost message, length delimited. Does not implicitly {@link PCost.verify|verify} messages. - * @function encodeDelimited - * @memberof PCost - * @static - * @param {IPCost} message PCost message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - PCost.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a PCost message from the specified reader or buffer. - * @function decode - * @memberof PCost - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {PCost} PCost - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - PCost.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.PCost(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.cost = reader.uint64(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a PCost message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof PCost - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {PCost} PCost - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - PCost.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a PCost message. - * @function verify - * @memberof PCost - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - PCost.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.cost != null && message.hasOwnProperty("cost")) - if (!$util.isInteger(message.cost) && !(message.cost && $util.isInteger(message.cost.low) && $util.isInteger(message.cost.high))) - return "cost: integer|Long expected"; - return null; - }; - - /** - * Creates a PCost message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof PCost - * @static - * @param {Object.} object Plain object - * @returns {PCost} PCost - */ - PCost.fromObject = function fromObject(object) { - if (object instanceof $root.PCost) - return object; - var message = new $root.PCost(); - if (object.cost != null) - if ($util.Long) - (message.cost = $util.Long.fromValue(object.cost)).unsigned = true; - else if (typeof object.cost === "string") - message.cost = parseInt(object.cost, 10); - else if (typeof object.cost === "number") - message.cost = object.cost; - else if (typeof object.cost === "object") - message.cost = new $util.LongBits(object.cost.low >>> 0, object.cost.high >>> 0).toNumber(true); - return message; - }; - - /** - * Creates a plain object from a PCost message. Also converts values to other types if specified. - * @function toObject - * @memberof PCost - * @static - * @param {PCost} message PCost - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - PCost.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - if ($util.Long) { - var long = new $util.Long(0, 0, true); - object.cost = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.cost = options.longs === String ? "0" : 0; - if (message.cost != null && message.hasOwnProperty("cost")) - if (typeof message.cost === "number") - object.cost = options.longs === String ? String(message.cost) : message.cost; - else - object.cost = options.longs === String ? $util.Long.prototype.toString.call(message.cost) : options.longs === Number ? new $util.LongBits(message.cost.low >>> 0, message.cost.high >>> 0).toNumber(true) : message.cost; - return object; - }; - - /** - * Converts this PCost to JSON. - * @function toJSON - * @memberof PCost - * @instance - * @returns {Object.} JSON object - */ - PCost.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return PCost; -})(); - -$root.ListParWithRandom = (function() { - - /** - * Properties of a ListParWithRandom. - * @exports IListParWithRandom - * @interface IListParWithRandom - * @property {Array.|null} [pars] ListParWithRandom pars - * @property {Uint8Array|null} [randomState] ListParWithRandom randomState - */ - - /** - * Constructs a new ListParWithRandom. - * @exports ListParWithRandom - * @classdesc Represents a ListParWithRandom. - * @implements IListParWithRandom - * @constructor - * @param {IListParWithRandom=} [properties] Properties to set - */ - function ListParWithRandom(properties) { - this.pars = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListParWithRandom pars. - * @member {Array.} pars - * @memberof ListParWithRandom - * @instance - */ - ListParWithRandom.prototype.pars = $util.emptyArray; - - /** - * ListParWithRandom randomState. - * @member {Uint8Array} randomState - * @memberof ListParWithRandom - * @instance - */ - ListParWithRandom.prototype.randomState = $util.newBuffer([]); - - /** - * Creates a new ListParWithRandom instance using the specified properties. - * @function create - * @memberof ListParWithRandom - * @static - * @param {IListParWithRandom=} [properties] Properties to set - * @returns {ListParWithRandom} ListParWithRandom instance - */ - ListParWithRandom.create = function create(properties) { - return new ListParWithRandom(properties); - }; - - /** - * Encodes the specified ListParWithRandom message. Does not implicitly {@link ListParWithRandom.verify|verify} messages. - * @function encode - * @memberof ListParWithRandom - * @static - * @param {IListParWithRandom} message ListParWithRandom message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ListParWithRandom.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.pars != null && message.pars.length) - for (var i = 0; i < message.pars.length; ++i) - $root.Par.encode(message.pars[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.randomState != null && message.hasOwnProperty("randomState")) - writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.randomState); - return writer; - }; - - /** - * Encodes the specified ListParWithRandom message, length delimited. Does not implicitly {@link ListParWithRandom.verify|verify} messages. - * @function encodeDelimited - * @memberof ListParWithRandom - * @static - * @param {IListParWithRandom} message ListParWithRandom message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ListParWithRandom.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ListParWithRandom message from the specified reader or buffer. - * @function decode - * @memberof ListParWithRandom - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {ListParWithRandom} ListParWithRandom - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ListParWithRandom.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ListParWithRandom(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.pars && message.pars.length)) - message.pars = []; - message.pars.push($root.Par.decode(reader, reader.uint32())); - break; - case 2: - message.randomState = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ListParWithRandom message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof ListParWithRandom - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {ListParWithRandom} ListParWithRandom - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ListParWithRandom.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ListParWithRandom message. - * @function verify - * @memberof ListParWithRandom - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ListParWithRandom.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.pars != null && message.hasOwnProperty("pars")) { - if (!Array.isArray(message.pars)) - return "pars: array expected"; - for (var i = 0; i < message.pars.length; ++i) { - var error = $root.Par.verify(message.pars[i]); - if (error) - return "pars." + error; - } - } - if (message.randomState != null && message.hasOwnProperty("randomState")) - if (!(message.randomState && typeof message.randomState.length === "number" || $util.isString(message.randomState))) - return "randomState: buffer expected"; - return null; - }; - - /** - * Creates a ListParWithRandom message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof ListParWithRandom - * @static - * @param {Object.} object Plain object - * @returns {ListParWithRandom} ListParWithRandom - */ - ListParWithRandom.fromObject = function fromObject(object) { - if (object instanceof $root.ListParWithRandom) - return object; - var message = new $root.ListParWithRandom(); - if (object.pars) { - if (!Array.isArray(object.pars)) - throw TypeError(".ListParWithRandom.pars: array expected"); - message.pars = []; - for (var i = 0; i < object.pars.length; ++i) { - if (typeof object.pars[i] !== "object") - throw TypeError(".ListParWithRandom.pars: object expected"); - message.pars[i] = $root.Par.fromObject(object.pars[i]); - } - } - if (object.randomState != null) - if (typeof object.randomState === "string") - $util.base64.decode(object.randomState, message.randomState = $util.newBuffer($util.base64.length(object.randomState)), 0); - else if (object.randomState.length) - message.randomState = object.randomState; - return message; - }; - - /** - * Creates a plain object from a ListParWithRandom message. Also converts values to other types if specified. - * @function toObject - * @memberof ListParWithRandom - * @static - * @param {ListParWithRandom} message ListParWithRandom - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ListParWithRandom.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.pars = []; - if (options.defaults) - if (options.bytes === String) - object.randomState = ""; - else { - object.randomState = []; - if (options.bytes !== Array) - object.randomState = $util.newBuffer(object.randomState); - } - if (message.pars && message.pars.length) { - object.pars = []; - for (var j = 0; j < message.pars.length; ++j) - object.pars[j] = $root.Par.toObject(message.pars[j], options); - } - if (message.randomState != null && message.hasOwnProperty("randomState")) - object.randomState = options.bytes === String ? $util.base64.encode(message.randomState, 0, message.randomState.length) : options.bytes === Array ? Array.prototype.slice.call(message.randomState) : message.randomState; - return object; - }; - - /** - * Converts this ListParWithRandom to JSON. - * @function toJSON - * @memberof ListParWithRandom - * @instance - * @returns {Object.} JSON object - */ - ListParWithRandom.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ListParWithRandom; -})(); - -$root.Var = (function() { - - /** - * Properties of a Var. - * @exports IVar - * @interface IVar - * @property {number|null} [bound_var] Var bound_var - * @property {number|null} [free_var] Var free_var - * @property {Var.IWildcardMsg|null} [wildcard] Var wildcard - */ - - /** - * Constructs a new Var. - * @exports Var - * @classdesc Represents a Var. - * @implements IVar - * @constructor - * @param {IVar=} [properties] Properties to set - */ - function Var(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Var bound_var. - * @member {number} bound_var - * @memberof Var - * @instance - */ - Var.prototype.bound_var = 0; - - /** - * Var free_var. - * @member {number} free_var - * @memberof Var - * @instance - */ - Var.prototype.free_var = 0; - - /** - * Var wildcard. - * @member {Var.IWildcardMsg|null|undefined} wildcard - * @memberof Var - * @instance - */ - Var.prototype.wildcard = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Var var_instance. - * @member {"bound_var"|"free_var"|"wildcard"|undefined} var_instance - * @memberof Var - * @instance - */ - Object.defineProperty(Var.prototype, "var_instance", { - get: $util.oneOfGetter($oneOfFields = ["bound_var", "free_var", "wildcard"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * Creates a new Var instance using the specified properties. - * @function create - * @memberof Var - * @static - * @param {IVar=} [properties] Properties to set - * @returns {Var} Var instance - */ - Var.create = function create(properties) { - return new Var(properties); - }; - - /** - * Encodes the specified Var message. Does not implicitly {@link Var.verify|verify} messages. - * @function encode - * @memberof Var - * @static - * @param {IVar} message Var message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Var.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.bound_var != null && message.hasOwnProperty("bound_var")) - writer.uint32(/* id 1, wireType 0 =*/8).sint32(message.bound_var); - if (message.free_var != null && message.hasOwnProperty("free_var")) - writer.uint32(/* id 2, wireType 0 =*/16).sint32(message.free_var); - if (message.wildcard != null && message.hasOwnProperty("wildcard")) - $root.Var.WildcardMsg.encode(message.wildcard, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified Var message, length delimited. Does not implicitly {@link Var.verify|verify} messages. - * @function encodeDelimited - * @memberof Var - * @static - * @param {IVar} message Var message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Var.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Var message from the specified reader or buffer. - * @function decode - * @memberof Var - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {Var} Var - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Var.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Var(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.bound_var = reader.sint32(); - break; - case 2: - message.free_var = reader.sint32(); - break; - case 3: - message.wildcard = $root.Var.WildcardMsg.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Var message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof Var - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {Var} Var - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Var.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Var message. - * @function verify - * @memberof Var - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Var.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - var properties = {}; - if (message.bound_var != null && message.hasOwnProperty("bound_var")) { - properties.var_instance = 1; - if (!$util.isInteger(message.bound_var)) - return "bound_var: integer expected"; - } - if (message.free_var != null && message.hasOwnProperty("free_var")) { - if (properties.var_instance === 1) - return "var_instance: multiple values"; - properties.var_instance = 1; - if (!$util.isInteger(message.free_var)) - return "free_var: integer expected"; - } - if (message.wildcard != null && message.hasOwnProperty("wildcard")) { - if (properties.var_instance === 1) - return "var_instance: multiple values"; - properties.var_instance = 1; - { - var error = $root.Var.WildcardMsg.verify(message.wildcard); - if (error) - return "wildcard." + error; - } - } - return null; - }; - - /** - * Creates a Var message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof Var - * @static - * @param {Object.} object Plain object - * @returns {Var} Var - */ - Var.fromObject = function fromObject(object) { - if (object instanceof $root.Var) - return object; - var message = new $root.Var(); - if (object.bound_var != null) - message.bound_var = object.bound_var | 0; - if (object.free_var != null) - message.free_var = object.free_var | 0; - if (object.wildcard != null) { - if (typeof object.wildcard !== "object") - throw TypeError(".Var.wildcard: object expected"); - message.wildcard = $root.Var.WildcardMsg.fromObject(object.wildcard); - } - return message; - }; - - /** - * Creates a plain object from a Var message. Also converts values to other types if specified. - * @function toObject - * @memberof Var - * @static - * @param {Var} message Var - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Var.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (message.bound_var != null && message.hasOwnProperty("bound_var")) { - object.bound_var = message.bound_var; - if (options.oneofs) - object.var_instance = "bound_var"; - } - if (message.free_var != null && message.hasOwnProperty("free_var")) { - object.free_var = message.free_var; - if (options.oneofs) - object.var_instance = "free_var"; - } - if (message.wildcard != null && message.hasOwnProperty("wildcard")) { - object.wildcard = $root.Var.WildcardMsg.toObject(message.wildcard, options); - if (options.oneofs) - object.var_instance = "wildcard"; - } - return object; - }; - - /** - * Converts this Var to JSON. - * @function toJSON - * @memberof Var - * @instance - * @returns {Object.} JSON object - */ - Var.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - Var.WildcardMsg = (function() { - - /** - * Properties of a WildcardMsg. - * @memberof Var - * @interface IWildcardMsg - */ - - /** - * Constructs a new WildcardMsg. - * @memberof Var - * @classdesc Represents a WildcardMsg. - * @implements IWildcardMsg - * @constructor - * @param {Var.IWildcardMsg=} [properties] Properties to set - */ - function WildcardMsg(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Creates a new WildcardMsg instance using the specified properties. - * @function create - * @memberof Var.WildcardMsg - * @static - * @param {Var.IWildcardMsg=} [properties] Properties to set - * @returns {Var.WildcardMsg} WildcardMsg instance - */ - WildcardMsg.create = function create(properties) { - return new WildcardMsg(properties); - }; - - /** - * Encodes the specified WildcardMsg message. Does not implicitly {@link Var.WildcardMsg.verify|verify} messages. - * @function encode - * @memberof Var.WildcardMsg - * @static - * @param {Var.IWildcardMsg} message WildcardMsg message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - WildcardMsg.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - return writer; - }; - - /** - * Encodes the specified WildcardMsg message, length delimited. Does not implicitly {@link Var.WildcardMsg.verify|verify} messages. - * @function encodeDelimited - * @memberof Var.WildcardMsg - * @static - * @param {Var.IWildcardMsg} message WildcardMsg message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - WildcardMsg.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a WildcardMsg message from the specified reader or buffer. - * @function decode - * @memberof Var.WildcardMsg - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {Var.WildcardMsg} WildcardMsg - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - WildcardMsg.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Var.WildcardMsg(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a WildcardMsg message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof Var.WildcardMsg - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {Var.WildcardMsg} WildcardMsg - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - WildcardMsg.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a WildcardMsg message. - * @function verify - * @memberof Var.WildcardMsg - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - WildcardMsg.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - return null; - }; - - /** - * Creates a WildcardMsg message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof Var.WildcardMsg - * @static - * @param {Object.} object Plain object - * @returns {Var.WildcardMsg} WildcardMsg - */ - WildcardMsg.fromObject = function fromObject(object) { - if (object instanceof $root.Var.WildcardMsg) - return object; - return new $root.Var.WildcardMsg(); - }; - - /** - * Creates a plain object from a WildcardMsg message. Also converts values to other types if specified. - * @function toObject - * @memberof Var.WildcardMsg - * @static - * @param {Var.WildcardMsg} message WildcardMsg - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - WildcardMsg.toObject = function toObject() { - return {}; - }; - - /** - * Converts this WildcardMsg to JSON. - * @function toJSON - * @memberof Var.WildcardMsg - * @instance - * @returns {Object.} JSON object - */ - WildcardMsg.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return WildcardMsg; - })(); - - return Var; -})(); - -$root.Bundle = (function() { - - /** - * Properties of a Bundle. - * @exports IBundle - * @interface IBundle - * @property {IPar|null} [body] Bundle body - * @property {boolean|null} [writeFlag] Bundle writeFlag - * @property {boolean|null} [readFlag] Bundle readFlag - */ - - /** - * Constructs a new Bundle. - * @exports Bundle - * @classdesc Nothing can be received from a (quoted) bundle with `readFlag = false`. - * Likeise nothing can be sent to a (quoted) bundle with `writeFlag = false`. - * - * If both flags are set to false, bundle allows only for equivalance check. - * @implements IBundle - * @constructor - * @param {IBundle=} [properties] Properties to set - */ - function Bundle(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Bundle body. - * @member {IPar|null|undefined} body - * @memberof Bundle - * @instance - */ - Bundle.prototype.body = null; - - /** - * Bundle writeFlag. - * @member {boolean} writeFlag - * @memberof Bundle - * @instance - */ - Bundle.prototype.writeFlag = false; - - /** - * Bundle readFlag. - * @member {boolean} readFlag - * @memberof Bundle - * @instance - */ - Bundle.prototype.readFlag = false; - - /** - * Creates a new Bundle instance using the specified properties. - * @function create - * @memberof Bundle - * @static - * @param {IBundle=} [properties] Properties to set - * @returns {Bundle} Bundle instance - */ - Bundle.create = function create(properties) { - return new Bundle(properties); - }; - - /** - * Encodes the specified Bundle message. Does not implicitly {@link Bundle.verify|verify} messages. - * @function encode - * @memberof Bundle - * @static - * @param {IBundle} message Bundle message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Bundle.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.body != null && message.hasOwnProperty("body")) - $root.Par.encode(message.body, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.writeFlag != null && message.hasOwnProperty("writeFlag")) - writer.uint32(/* id 2, wireType 0 =*/16).bool(message.writeFlag); - if (message.readFlag != null && message.hasOwnProperty("readFlag")) - writer.uint32(/* id 3, wireType 0 =*/24).bool(message.readFlag); - return writer; - }; - - /** - * Encodes the specified Bundle message, length delimited. Does not implicitly {@link Bundle.verify|verify} messages. - * @function encodeDelimited - * @memberof Bundle - * @static - * @param {IBundle} message Bundle message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Bundle.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Bundle message from the specified reader or buffer. - * @function decode - * @memberof Bundle - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {Bundle} Bundle - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Bundle.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Bundle(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.body = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.writeFlag = reader.bool(); - break; - case 3: - message.readFlag = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Bundle message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof Bundle - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {Bundle} Bundle - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Bundle.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Bundle message. - * @function verify - * @memberof Bundle - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Bundle.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.body != null && message.hasOwnProperty("body")) { - var error = $root.Par.verify(message.body); - if (error) - return "body." + error; - } - if (message.writeFlag != null && message.hasOwnProperty("writeFlag")) - if (typeof message.writeFlag !== "boolean") - return "writeFlag: boolean expected"; - if (message.readFlag != null && message.hasOwnProperty("readFlag")) - if (typeof message.readFlag !== "boolean") - return "readFlag: boolean expected"; - return null; - }; - - /** - * Creates a Bundle message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof Bundle - * @static - * @param {Object.} object Plain object - * @returns {Bundle} Bundle - */ - Bundle.fromObject = function fromObject(object) { - if (object instanceof $root.Bundle) - return object; - var message = new $root.Bundle(); - if (object.body != null) { - if (typeof object.body !== "object") - throw TypeError(".Bundle.body: object expected"); - message.body = $root.Par.fromObject(object.body); - } - if (object.writeFlag != null) - message.writeFlag = Boolean(object.writeFlag); - if (object.readFlag != null) - message.readFlag = Boolean(object.readFlag); - return message; - }; - - /** - * Creates a plain object from a Bundle message. Also converts values to other types if specified. - * @function toObject - * @memberof Bundle - * @static - * @param {Bundle} message Bundle - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Bundle.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.body = null; - object.writeFlag = false; - object.readFlag = false; - } - if (message.body != null && message.hasOwnProperty("body")) - object.body = $root.Par.toObject(message.body, options); - if (message.writeFlag != null && message.hasOwnProperty("writeFlag")) - object.writeFlag = message.writeFlag; - if (message.readFlag != null && message.hasOwnProperty("readFlag")) - object.readFlag = message.readFlag; - return object; - }; - - /** - * Converts this Bundle to JSON. - * @function toJSON - * @memberof Bundle - * @instance - * @returns {Object.} JSON object - */ - Bundle.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Bundle; -})(); - -$root.Send = (function() { - - /** - * Properties of a Send. - * @exports ISend - * @interface ISend - * @property {IPar|null} [chan] Send chan - * @property {Array.|null} [data] Send data - * @property {boolean|null} [persistent] Send persistent - * @property {Uint8Array|null} [locallyFree] Send locallyFree - * @property {boolean|null} [connective_used] Send connective_used - */ - - /** - * Constructs a new Send. - * @exports Send - * @classdesc A send is written `chan!(data)` or `chan!!(data)` for a persistent send. - * - * Upon send, all free variables in data are substituted with their values. - * @implements ISend - * @constructor - * @param {ISend=} [properties] Properties to set - */ - function Send(properties) { - this.data = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Send chan. - * @member {IPar|null|undefined} chan - * @memberof Send - * @instance - */ - Send.prototype.chan = null; - - /** - * Send data. - * @member {Array.} data - * @memberof Send - * @instance - */ - Send.prototype.data = $util.emptyArray; - - /** - * Send persistent. - * @member {boolean} persistent - * @memberof Send - * @instance - */ - Send.prototype.persistent = false; - - /** - * Send locallyFree. - * @member {Uint8Array} locallyFree - * @memberof Send - * @instance - */ - Send.prototype.locallyFree = $util.newBuffer([]); - - /** - * Send connective_used. - * @member {boolean} connective_used - * @memberof Send - * @instance - */ - Send.prototype.connective_used = false; - - /** - * Creates a new Send instance using the specified properties. - * @function create - * @memberof Send - * @static - * @param {ISend=} [properties] Properties to set - * @returns {Send} Send instance - */ - Send.create = function create(properties) { - return new Send(properties); - }; - - /** - * Encodes the specified Send message. Does not implicitly {@link Send.verify|verify} messages. - * @function encode - * @memberof Send - * @static - * @param {ISend} message Send message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Send.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.chan != null && message.hasOwnProperty("chan")) - $root.Par.encode(message.chan, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.data != null && message.data.length) - for (var i = 0; i < message.data.length; ++i) - $root.Par.encode(message.data[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.persistent != null && message.hasOwnProperty("persistent")) - writer.uint32(/* id 3, wireType 0 =*/24).bool(message.persistent); - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.locallyFree); - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - writer.uint32(/* id 6, wireType 0 =*/48).bool(message.connective_used); - return writer; - }; - - /** - * Encodes the specified Send message, length delimited. Does not implicitly {@link Send.verify|verify} messages. - * @function encodeDelimited - * @memberof Send - * @static - * @param {ISend} message Send message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Send.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Send message from the specified reader or buffer. - * @function decode - * @memberof Send - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {Send} Send - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Send.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Send(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.chan = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - if (!(message.data && message.data.length)) - message.data = []; - message.data.push($root.Par.decode(reader, reader.uint32())); - break; - case 3: - message.persistent = reader.bool(); - break; - case 5: - message.locallyFree = reader.bytes(); - break; - case 6: - message.connective_used = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Send message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof Send - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {Send} Send - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Send.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Send message. - * @function verify - * @memberof Send - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Send.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.chan != null && message.hasOwnProperty("chan")) { - var error = $root.Par.verify(message.chan); - if (error) - return "chan." + error; - } - if (message.data != null && message.hasOwnProperty("data")) { - if (!Array.isArray(message.data)) - return "data: array expected"; - for (var i = 0; i < message.data.length; ++i) { - var error = $root.Par.verify(message.data[i]); - if (error) - return "data." + error; - } - } - if (message.persistent != null && message.hasOwnProperty("persistent")) - if (typeof message.persistent !== "boolean") - return "persistent: boolean expected"; - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - if (!(message.locallyFree && typeof message.locallyFree.length === "number" || $util.isString(message.locallyFree))) - return "locallyFree: buffer expected"; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - if (typeof message.connective_used !== "boolean") - return "connective_used: boolean expected"; - return null; - }; - - /** - * Creates a Send message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof Send - * @static - * @param {Object.} object Plain object - * @returns {Send} Send - */ - Send.fromObject = function fromObject(object) { - if (object instanceof $root.Send) - return object; - var message = new $root.Send(); - if (object.chan != null) { - if (typeof object.chan !== "object") - throw TypeError(".Send.chan: object expected"); - message.chan = $root.Par.fromObject(object.chan); - } - if (object.data) { - if (!Array.isArray(object.data)) - throw TypeError(".Send.data: array expected"); - message.data = []; - for (var i = 0; i < object.data.length; ++i) { - if (typeof object.data[i] !== "object") - throw TypeError(".Send.data: object expected"); - message.data[i] = $root.Par.fromObject(object.data[i]); - } - } - if (object.persistent != null) - message.persistent = Boolean(object.persistent); - if (object.locallyFree != null) - if (typeof object.locallyFree === "string") - $util.base64.decode(object.locallyFree, message.locallyFree = $util.newBuffer($util.base64.length(object.locallyFree)), 0); - else if (object.locallyFree.length) - message.locallyFree = object.locallyFree; - if (object.connective_used != null) - message.connective_used = Boolean(object.connective_used); - return message; - }; - - /** - * Creates a plain object from a Send message. Also converts values to other types if specified. - * @function toObject - * @memberof Send - * @static - * @param {Send} message Send - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Send.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.data = []; - if (options.defaults) { - object.chan = null; - object.persistent = false; - if (options.bytes === String) - object.locallyFree = ""; - else { - object.locallyFree = []; - if (options.bytes !== Array) - object.locallyFree = $util.newBuffer(object.locallyFree); - } - object.connective_used = false; - } - if (message.chan != null && message.hasOwnProperty("chan")) - object.chan = $root.Par.toObject(message.chan, options); - if (message.data && message.data.length) { - object.data = []; - for (var j = 0; j < message.data.length; ++j) - object.data[j] = $root.Par.toObject(message.data[j], options); - } - if (message.persistent != null && message.hasOwnProperty("persistent")) - object.persistent = message.persistent; - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - object.locallyFree = options.bytes === String ? $util.base64.encode(message.locallyFree, 0, message.locallyFree.length) : options.bytes === Array ? Array.prototype.slice.call(message.locallyFree) : message.locallyFree; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - object.connective_used = message.connective_used; - return object; - }; - - /** - * Converts this Send to JSON. - * @function toJSON - * @memberof Send - * @instance - * @returns {Object.} JSON object - */ - Send.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Send; -})(); - -$root.ReceiveBind = (function() { - - /** - * Properties of a ReceiveBind. - * @exports IReceiveBind - * @interface IReceiveBind - * @property {Array.|null} [patterns] ReceiveBind patterns - * @property {IPar|null} [source] ReceiveBind source - * @property {IVar|null} [remainder] ReceiveBind remainder - * @property {number|null} [freeCount] ReceiveBind freeCount - */ - - /** - * Constructs a new ReceiveBind. - * @exports ReceiveBind - * @classdesc Represents a ReceiveBind. - * @implements IReceiveBind - * @constructor - * @param {IReceiveBind=} [properties] Properties to set - */ - function ReceiveBind(properties) { - this.patterns = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ReceiveBind patterns. - * @member {Array.} patterns - * @memberof ReceiveBind - * @instance - */ - ReceiveBind.prototype.patterns = $util.emptyArray; - - /** - * ReceiveBind source. - * @member {IPar|null|undefined} source - * @memberof ReceiveBind - * @instance - */ - ReceiveBind.prototype.source = null; - - /** - * ReceiveBind remainder. - * @member {IVar|null|undefined} remainder - * @memberof ReceiveBind - * @instance - */ - ReceiveBind.prototype.remainder = null; - - /** - * ReceiveBind freeCount. - * @member {number} freeCount - * @memberof ReceiveBind - * @instance - */ - ReceiveBind.prototype.freeCount = 0; - - /** - * Creates a new ReceiveBind instance using the specified properties. - * @function create - * @memberof ReceiveBind - * @static - * @param {IReceiveBind=} [properties] Properties to set - * @returns {ReceiveBind} ReceiveBind instance - */ - ReceiveBind.create = function create(properties) { - return new ReceiveBind(properties); - }; - - /** - * Encodes the specified ReceiveBind message. Does not implicitly {@link ReceiveBind.verify|verify} messages. - * @function encode - * @memberof ReceiveBind - * @static - * @param {IReceiveBind} message ReceiveBind message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ReceiveBind.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.patterns != null && message.patterns.length) - for (var i = 0; i < message.patterns.length; ++i) - $root.Par.encode(message.patterns[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.source != null && message.hasOwnProperty("source")) - $root.Par.encode(message.source, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.remainder != null && message.hasOwnProperty("remainder")) - $root.Var.encode(message.remainder, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.freeCount != null && message.hasOwnProperty("freeCount")) - writer.uint32(/* id 4, wireType 0 =*/32).int32(message.freeCount); - return writer; - }; - - /** - * Encodes the specified ReceiveBind message, length delimited. Does not implicitly {@link ReceiveBind.verify|verify} messages. - * @function encodeDelimited - * @memberof ReceiveBind - * @static - * @param {IReceiveBind} message ReceiveBind message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ReceiveBind.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ReceiveBind message from the specified reader or buffer. - * @function decode - * @memberof ReceiveBind - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {ReceiveBind} ReceiveBind - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ReceiveBind.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ReceiveBind(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.patterns && message.patterns.length)) - message.patterns = []; - message.patterns.push($root.Par.decode(reader, reader.uint32())); - break; - case 2: - message.source = $root.Par.decode(reader, reader.uint32()); - break; - case 3: - message.remainder = $root.Var.decode(reader, reader.uint32()); - break; - case 4: - message.freeCount = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ReceiveBind message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof ReceiveBind - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {ReceiveBind} ReceiveBind - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ReceiveBind.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ReceiveBind message. - * @function verify - * @memberof ReceiveBind - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ReceiveBind.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.patterns != null && message.hasOwnProperty("patterns")) { - if (!Array.isArray(message.patterns)) - return "patterns: array expected"; - for (var i = 0; i < message.patterns.length; ++i) { - var error = $root.Par.verify(message.patterns[i]); - if (error) - return "patterns." + error; - } - } - if (message.source != null && message.hasOwnProperty("source")) { - var error = $root.Par.verify(message.source); - if (error) - return "source." + error; - } - if (message.remainder != null && message.hasOwnProperty("remainder")) { - var error = $root.Var.verify(message.remainder); - if (error) - return "remainder." + error; - } - if (message.freeCount != null && message.hasOwnProperty("freeCount")) - if (!$util.isInteger(message.freeCount)) - return "freeCount: integer expected"; - return null; - }; - - /** - * Creates a ReceiveBind message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof ReceiveBind - * @static - * @param {Object.} object Plain object - * @returns {ReceiveBind} ReceiveBind - */ - ReceiveBind.fromObject = function fromObject(object) { - if (object instanceof $root.ReceiveBind) - return object; - var message = new $root.ReceiveBind(); - if (object.patterns) { - if (!Array.isArray(object.patterns)) - throw TypeError(".ReceiveBind.patterns: array expected"); - message.patterns = []; - for (var i = 0; i < object.patterns.length; ++i) { - if (typeof object.patterns[i] !== "object") - throw TypeError(".ReceiveBind.patterns: object expected"); - message.patterns[i] = $root.Par.fromObject(object.patterns[i]); - } - } - if (object.source != null) { - if (typeof object.source !== "object") - throw TypeError(".ReceiveBind.source: object expected"); - message.source = $root.Par.fromObject(object.source); - } - if (object.remainder != null) { - if (typeof object.remainder !== "object") - throw TypeError(".ReceiveBind.remainder: object expected"); - message.remainder = $root.Var.fromObject(object.remainder); - } - if (object.freeCount != null) - message.freeCount = object.freeCount | 0; - return message; - }; - - /** - * Creates a plain object from a ReceiveBind message. Also converts values to other types if specified. - * @function toObject - * @memberof ReceiveBind - * @static - * @param {ReceiveBind} message ReceiveBind - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ReceiveBind.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.patterns = []; - if (options.defaults) { - object.source = null; - object.remainder = null; - object.freeCount = 0; - } - if (message.patterns && message.patterns.length) { - object.patterns = []; - for (var j = 0; j < message.patterns.length; ++j) - object.patterns[j] = $root.Par.toObject(message.patterns[j], options); - } - if (message.source != null && message.hasOwnProperty("source")) - object.source = $root.Par.toObject(message.source, options); - if (message.remainder != null && message.hasOwnProperty("remainder")) - object.remainder = $root.Var.toObject(message.remainder, options); - if (message.freeCount != null && message.hasOwnProperty("freeCount")) - object.freeCount = message.freeCount; - return object; - }; - - /** - * Converts this ReceiveBind to JSON. - * @function toJSON - * @memberof ReceiveBind - * @instance - * @returns {Object.} JSON object - */ - ReceiveBind.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ReceiveBind; -})(); - -$root.BindPattern = (function() { - - /** - * Properties of a BindPattern. - * @exports IBindPattern - * @interface IBindPattern - * @property {Array.|null} [patterns] BindPattern patterns - * @property {IVar|null} [remainder] BindPattern remainder - * @property {number|null} [freeCount] BindPattern freeCount - */ - - /** - * Constructs a new BindPattern. - * @exports BindPattern - * @classdesc Represents a BindPattern. - * @implements IBindPattern - * @constructor - * @param {IBindPattern=} [properties] Properties to set - */ - function BindPattern(properties) { - this.patterns = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * BindPattern patterns. - * @member {Array.} patterns - * @memberof BindPattern - * @instance - */ - BindPattern.prototype.patterns = $util.emptyArray; - - /** - * BindPattern remainder. - * @member {IVar|null|undefined} remainder - * @memberof BindPattern - * @instance - */ - BindPattern.prototype.remainder = null; - - /** - * BindPattern freeCount. - * @member {number} freeCount - * @memberof BindPattern - * @instance - */ - BindPattern.prototype.freeCount = 0; - - /** - * Creates a new BindPattern instance using the specified properties. - * @function create - * @memberof BindPattern - * @static - * @param {IBindPattern=} [properties] Properties to set - * @returns {BindPattern} BindPattern instance - */ - BindPattern.create = function create(properties) { - return new BindPattern(properties); - }; - - /** - * Encodes the specified BindPattern message. Does not implicitly {@link BindPattern.verify|verify} messages. - * @function encode - * @memberof BindPattern - * @static - * @param {IBindPattern} message BindPattern message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BindPattern.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.patterns != null && message.patterns.length) - for (var i = 0; i < message.patterns.length; ++i) - $root.Par.encode(message.patterns[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.remainder != null && message.hasOwnProperty("remainder")) - $root.Var.encode(message.remainder, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.freeCount != null && message.hasOwnProperty("freeCount")) - writer.uint32(/* id 3, wireType 0 =*/24).int32(message.freeCount); - return writer; - }; - - /** - * Encodes the specified BindPattern message, length delimited. Does not implicitly {@link BindPattern.verify|verify} messages. - * @function encodeDelimited - * @memberof BindPattern - * @static - * @param {IBindPattern} message BindPattern message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BindPattern.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a BindPattern message from the specified reader or buffer. - * @function decode - * @memberof BindPattern - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {BindPattern} BindPattern - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BindPattern.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.BindPattern(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.patterns && message.patterns.length)) - message.patterns = []; - message.patterns.push($root.Par.decode(reader, reader.uint32())); - break; - case 2: - message.remainder = $root.Var.decode(reader, reader.uint32()); - break; - case 3: - message.freeCount = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a BindPattern message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof BindPattern - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {BindPattern} BindPattern - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BindPattern.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a BindPattern message. - * @function verify - * @memberof BindPattern - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - BindPattern.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.patterns != null && message.hasOwnProperty("patterns")) { - if (!Array.isArray(message.patterns)) - return "patterns: array expected"; - for (var i = 0; i < message.patterns.length; ++i) { - var error = $root.Par.verify(message.patterns[i]); - if (error) - return "patterns." + error; - } - } - if (message.remainder != null && message.hasOwnProperty("remainder")) { - var error = $root.Var.verify(message.remainder); - if (error) - return "remainder." + error; - } - if (message.freeCount != null && message.hasOwnProperty("freeCount")) - if (!$util.isInteger(message.freeCount)) - return "freeCount: integer expected"; - return null; - }; - - /** - * Creates a BindPattern message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof BindPattern - * @static - * @param {Object.} object Plain object - * @returns {BindPattern} BindPattern - */ - BindPattern.fromObject = function fromObject(object) { - if (object instanceof $root.BindPattern) - return object; - var message = new $root.BindPattern(); - if (object.patterns) { - if (!Array.isArray(object.patterns)) - throw TypeError(".BindPattern.patterns: array expected"); - message.patterns = []; - for (var i = 0; i < object.patterns.length; ++i) { - if (typeof object.patterns[i] !== "object") - throw TypeError(".BindPattern.patterns: object expected"); - message.patterns[i] = $root.Par.fromObject(object.patterns[i]); - } - } - if (object.remainder != null) { - if (typeof object.remainder !== "object") - throw TypeError(".BindPattern.remainder: object expected"); - message.remainder = $root.Var.fromObject(object.remainder); - } - if (object.freeCount != null) - message.freeCount = object.freeCount | 0; - return message; - }; - - /** - * Creates a plain object from a BindPattern message. Also converts values to other types if specified. - * @function toObject - * @memberof BindPattern - * @static - * @param {BindPattern} message BindPattern - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - BindPattern.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.patterns = []; - if (options.defaults) { - object.remainder = null; - object.freeCount = 0; - } - if (message.patterns && message.patterns.length) { - object.patterns = []; - for (var j = 0; j < message.patterns.length; ++j) - object.patterns[j] = $root.Par.toObject(message.patterns[j], options); - } - if (message.remainder != null && message.hasOwnProperty("remainder")) - object.remainder = $root.Var.toObject(message.remainder, options); - if (message.freeCount != null && message.hasOwnProperty("freeCount")) - object.freeCount = message.freeCount; - return object; - }; - - /** - * Converts this BindPattern to JSON. - * @function toJSON - * @memberof BindPattern - * @instance - * @returns {Object.} JSON object - */ - BindPattern.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return BindPattern; -})(); - -$root.ListBindPatterns = (function() { - - /** - * Properties of a ListBindPatterns. - * @exports IListBindPatterns - * @interface IListBindPatterns - * @property {Array.|null} [patterns] ListBindPatterns patterns - */ - - /** - * Constructs a new ListBindPatterns. - * @exports ListBindPatterns - * @classdesc Represents a ListBindPatterns. - * @implements IListBindPatterns - * @constructor - * @param {IListBindPatterns=} [properties] Properties to set - */ - function ListBindPatterns(properties) { - this.patterns = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ListBindPatterns patterns. - * @member {Array.} patterns - * @memberof ListBindPatterns - * @instance - */ - ListBindPatterns.prototype.patterns = $util.emptyArray; - - /** - * Creates a new ListBindPatterns instance using the specified properties. - * @function create - * @memberof ListBindPatterns - * @static - * @param {IListBindPatterns=} [properties] Properties to set - * @returns {ListBindPatterns} ListBindPatterns instance - */ - ListBindPatterns.create = function create(properties) { - return new ListBindPatterns(properties); - }; - - /** - * Encodes the specified ListBindPatterns message. Does not implicitly {@link ListBindPatterns.verify|verify} messages. - * @function encode - * @memberof ListBindPatterns - * @static - * @param {IListBindPatterns} message ListBindPatterns message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ListBindPatterns.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.patterns != null && message.patterns.length) - for (var i = 0; i < message.patterns.length; ++i) - $root.BindPattern.encode(message.patterns[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified ListBindPatterns message, length delimited. Does not implicitly {@link ListBindPatterns.verify|verify} messages. - * @function encodeDelimited - * @memberof ListBindPatterns - * @static - * @param {IListBindPatterns} message ListBindPatterns message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ListBindPatterns.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ListBindPatterns message from the specified reader or buffer. - * @function decode - * @memberof ListBindPatterns - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {ListBindPatterns} ListBindPatterns - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ListBindPatterns.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ListBindPatterns(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.patterns && message.patterns.length)) - message.patterns = []; - message.patterns.push($root.BindPattern.decode(reader, reader.uint32())); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ListBindPatterns message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof ListBindPatterns - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {ListBindPatterns} ListBindPatterns - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ListBindPatterns.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ListBindPatterns message. - * @function verify - * @memberof ListBindPatterns - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ListBindPatterns.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.patterns != null && message.hasOwnProperty("patterns")) { - if (!Array.isArray(message.patterns)) - return "patterns: array expected"; - for (var i = 0; i < message.patterns.length; ++i) { - var error = $root.BindPattern.verify(message.patterns[i]); - if (error) - return "patterns." + error; - } - } - return null; - }; - - /** - * Creates a ListBindPatterns message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof ListBindPatterns - * @static - * @param {Object.} object Plain object - * @returns {ListBindPatterns} ListBindPatterns - */ - ListBindPatterns.fromObject = function fromObject(object) { - if (object instanceof $root.ListBindPatterns) - return object; - var message = new $root.ListBindPatterns(); - if (object.patterns) { - if (!Array.isArray(object.patterns)) - throw TypeError(".ListBindPatterns.patterns: array expected"); - message.patterns = []; - for (var i = 0; i < object.patterns.length; ++i) { - if (typeof object.patterns[i] !== "object") - throw TypeError(".ListBindPatterns.patterns: object expected"); - message.patterns[i] = $root.BindPattern.fromObject(object.patterns[i]); - } - } - return message; - }; - - /** - * Creates a plain object from a ListBindPatterns message. Also converts values to other types if specified. - * @function toObject - * @memberof ListBindPatterns - * @static - * @param {ListBindPatterns} message ListBindPatterns - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ListBindPatterns.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.patterns = []; - if (message.patterns && message.patterns.length) { - object.patterns = []; - for (var j = 0; j < message.patterns.length; ++j) - object.patterns[j] = $root.BindPattern.toObject(message.patterns[j], options); - } - return object; - }; - - /** - * Converts this ListBindPatterns to JSON. - * @function toJSON - * @memberof ListBindPatterns - * @instance - * @returns {Object.} JSON object - */ - ListBindPatterns.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ListBindPatterns; -})(); - -$root.Receive = (function() { - - /** - * Properties of a Receive. - * @exports IReceive - * @interface IReceive - * @property {Array.|null} [binds] Receive binds - * @property {IPar|null} [body] Receive body - * @property {boolean|null} [persistent] Receive persistent - * @property {number|null} [bindCount] Receive bindCount - * @property {Uint8Array|null} [locallyFree] Receive locallyFree - * @property {boolean|null} [connective_used] Receive connective_used - */ - - /** - * Constructs a new Receive. - * @exports Receive - * @classdesc A receive is written `for(binds) { body }` - * i.e. `for(patterns <- source) { body }` - * or for a persistent recieve: `for(patterns <= source) { body }`. - * - * It's an error for free Variable to occur more than once in a pattern. - * @implements IReceive - * @constructor - * @param {IReceive=} [properties] Properties to set - */ - function Receive(properties) { - this.binds = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Receive binds. - * @member {Array.} binds - * @memberof Receive - * @instance - */ - Receive.prototype.binds = $util.emptyArray; - - /** - * Receive body. - * @member {IPar|null|undefined} body - * @memberof Receive - * @instance - */ - Receive.prototype.body = null; - - /** - * Receive persistent. - * @member {boolean} persistent - * @memberof Receive - * @instance - */ - Receive.prototype.persistent = false; - - /** - * Receive bindCount. - * @member {number} bindCount - * @memberof Receive - * @instance - */ - Receive.prototype.bindCount = 0; - - /** - * Receive locallyFree. - * @member {Uint8Array} locallyFree - * @memberof Receive - * @instance - */ - Receive.prototype.locallyFree = $util.newBuffer([]); - - /** - * Receive connective_used. - * @member {boolean} connective_used - * @memberof Receive - * @instance - */ - Receive.prototype.connective_used = false; - - /** - * Creates a new Receive instance using the specified properties. - * @function create - * @memberof Receive - * @static - * @param {IReceive=} [properties] Properties to set - * @returns {Receive} Receive instance - */ - Receive.create = function create(properties) { - return new Receive(properties); - }; - - /** - * Encodes the specified Receive message. Does not implicitly {@link Receive.verify|verify} messages. - * @function encode - * @memberof Receive - * @static - * @param {IReceive} message Receive message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Receive.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.binds != null && message.binds.length) - for (var i = 0; i < message.binds.length; ++i) - $root.ReceiveBind.encode(message.binds[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.body != null && message.hasOwnProperty("body")) - $root.Par.encode(message.body, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.persistent != null && message.hasOwnProperty("persistent")) - writer.uint32(/* id 3, wireType 0 =*/24).bool(message.persistent); - if (message.bindCount != null && message.hasOwnProperty("bindCount")) - writer.uint32(/* id 4, wireType 0 =*/32).int32(message.bindCount); - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - writer.uint32(/* id 6, wireType 2 =*/50).bytes(message.locallyFree); - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - writer.uint32(/* id 7, wireType 0 =*/56).bool(message.connective_used); - return writer; - }; - - /** - * Encodes the specified Receive message, length delimited. Does not implicitly {@link Receive.verify|verify} messages. - * @function encodeDelimited - * @memberof Receive - * @static - * @param {IReceive} message Receive message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Receive.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Receive message from the specified reader or buffer. - * @function decode - * @memberof Receive - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {Receive} Receive - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Receive.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Receive(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.binds && message.binds.length)) - message.binds = []; - message.binds.push($root.ReceiveBind.decode(reader, reader.uint32())); - break; - case 2: - message.body = $root.Par.decode(reader, reader.uint32()); - break; - case 3: - message.persistent = reader.bool(); - break; - case 4: - message.bindCount = reader.int32(); - break; - case 6: - message.locallyFree = reader.bytes(); - break; - case 7: - message.connective_used = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Receive message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof Receive - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {Receive} Receive - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Receive.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Receive message. - * @function verify - * @memberof Receive - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Receive.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.binds != null && message.hasOwnProperty("binds")) { - if (!Array.isArray(message.binds)) - return "binds: array expected"; - for (var i = 0; i < message.binds.length; ++i) { - var error = $root.ReceiveBind.verify(message.binds[i]); - if (error) - return "binds." + error; - } - } - if (message.body != null && message.hasOwnProperty("body")) { - var error = $root.Par.verify(message.body); - if (error) - return "body." + error; - } - if (message.persistent != null && message.hasOwnProperty("persistent")) - if (typeof message.persistent !== "boolean") - return "persistent: boolean expected"; - if (message.bindCount != null && message.hasOwnProperty("bindCount")) - if (!$util.isInteger(message.bindCount)) - return "bindCount: integer expected"; - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - if (!(message.locallyFree && typeof message.locallyFree.length === "number" || $util.isString(message.locallyFree))) - return "locallyFree: buffer expected"; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - if (typeof message.connective_used !== "boolean") - return "connective_used: boolean expected"; - return null; - }; - - /** - * Creates a Receive message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof Receive - * @static - * @param {Object.} object Plain object - * @returns {Receive} Receive - */ - Receive.fromObject = function fromObject(object) { - if (object instanceof $root.Receive) - return object; - var message = new $root.Receive(); - if (object.binds) { - if (!Array.isArray(object.binds)) - throw TypeError(".Receive.binds: array expected"); - message.binds = []; - for (var i = 0; i < object.binds.length; ++i) { - if (typeof object.binds[i] !== "object") - throw TypeError(".Receive.binds: object expected"); - message.binds[i] = $root.ReceiveBind.fromObject(object.binds[i]); - } - } - if (object.body != null) { - if (typeof object.body !== "object") - throw TypeError(".Receive.body: object expected"); - message.body = $root.Par.fromObject(object.body); - } - if (object.persistent != null) - message.persistent = Boolean(object.persistent); - if (object.bindCount != null) - message.bindCount = object.bindCount | 0; - if (object.locallyFree != null) - if (typeof object.locallyFree === "string") - $util.base64.decode(object.locallyFree, message.locallyFree = $util.newBuffer($util.base64.length(object.locallyFree)), 0); - else if (object.locallyFree.length) - message.locallyFree = object.locallyFree; - if (object.connective_used != null) - message.connective_used = Boolean(object.connective_used); - return message; - }; - - /** - * Creates a plain object from a Receive message. Also converts values to other types if specified. - * @function toObject - * @memberof Receive - * @static - * @param {Receive} message Receive - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Receive.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.binds = []; - if (options.defaults) { - object.body = null; - object.persistent = false; - object.bindCount = 0; - if (options.bytes === String) - object.locallyFree = ""; - else { - object.locallyFree = []; - if (options.bytes !== Array) - object.locallyFree = $util.newBuffer(object.locallyFree); - } - object.connective_used = false; - } - if (message.binds && message.binds.length) { - object.binds = []; - for (var j = 0; j < message.binds.length; ++j) - object.binds[j] = $root.ReceiveBind.toObject(message.binds[j], options); - } - if (message.body != null && message.hasOwnProperty("body")) - object.body = $root.Par.toObject(message.body, options); - if (message.persistent != null && message.hasOwnProperty("persistent")) - object.persistent = message.persistent; - if (message.bindCount != null && message.hasOwnProperty("bindCount")) - object.bindCount = message.bindCount; - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - object.locallyFree = options.bytes === String ? $util.base64.encode(message.locallyFree, 0, message.locallyFree.length) : options.bytes === Array ? Array.prototype.slice.call(message.locallyFree) : message.locallyFree; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - object.connective_used = message.connective_used; - return object; - }; - - /** - * Converts this Receive to JSON. - * @function toJSON - * @memberof Receive - * @instance - * @returns {Object.} JSON object - */ - Receive.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Receive; -})(); - -$root.New = (function() { - - /** - * Properties of a New. - * @exports INew - * @interface INew - * @property {number|null} [bindCount] New bindCount - * @property {IPar|null} [p] New p - * @property {Array.|null} [uri] New uri - * @property {Uint8Array|null} [locallyFree] New locallyFree - */ - - /** - * Constructs a new New. - * @exports New - * @classdesc Represents a New. - * @implements INew - * @constructor - * @param {INew=} [properties] Properties to set - */ - function New(properties) { - this.uri = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * New bindCount. - * @member {number} bindCount - * @memberof New - * @instance - */ - New.prototype.bindCount = 0; - - /** - * New p. - * @member {IPar|null|undefined} p - * @memberof New - * @instance - */ - New.prototype.p = null; - - /** - * New uri. - * @member {Array.} uri - * @memberof New - * @instance - */ - New.prototype.uri = $util.emptyArray; - - /** - * New locallyFree. - * @member {Uint8Array} locallyFree - * @memberof New - * @instance - */ - New.prototype.locallyFree = $util.newBuffer([]); - - /** - * Creates a new New instance using the specified properties. - * @function create - * @memberof New - * @static - * @param {INew=} [properties] Properties to set - * @returns {New} New instance - */ - New.create = function create(properties) { - return new New(properties); - }; - - /** - * Encodes the specified New message. Does not implicitly {@link New.verify|verify} messages. - * @function encode - * @memberof New - * @static - * @param {INew} message New message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - New.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.bindCount != null && message.hasOwnProperty("bindCount")) - writer.uint32(/* id 1, wireType 0 =*/8).sint32(message.bindCount); - if (message.p != null && message.hasOwnProperty("p")) - $root.Par.encode(message.p, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.uri != null && message.uri.length) - for (var i = 0; i < message.uri.length; ++i) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.uri[i]); - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.locallyFree); - return writer; - }; - - /** - * Encodes the specified New message, length delimited. Does not implicitly {@link New.verify|verify} messages. - * @function encodeDelimited - * @memberof New - * @static - * @param {INew} message New message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - New.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a New message from the specified reader or buffer. - * @function decode - * @memberof New - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {New} New - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - New.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.New(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.bindCount = reader.sint32(); - break; - case 2: - message.p = $root.Par.decode(reader, reader.uint32()); - break; - case 3: - if (!(message.uri && message.uri.length)) - message.uri = []; - message.uri.push(reader.string()); - break; - case 4: - message.locallyFree = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a New message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof New - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {New} New - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - New.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a New message. - * @function verify - * @memberof New - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - New.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.bindCount != null && message.hasOwnProperty("bindCount")) - if (!$util.isInteger(message.bindCount)) - return "bindCount: integer expected"; - if (message.p != null && message.hasOwnProperty("p")) { - var error = $root.Par.verify(message.p); - if (error) - return "p." + error; - } - if (message.uri != null && message.hasOwnProperty("uri")) { - if (!Array.isArray(message.uri)) - return "uri: array expected"; - for (var i = 0; i < message.uri.length; ++i) - if (!$util.isString(message.uri[i])) - return "uri: string[] expected"; - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - if (!(message.locallyFree && typeof message.locallyFree.length === "number" || $util.isString(message.locallyFree))) - return "locallyFree: buffer expected"; - return null; - }; - - /** - * Creates a New message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof New - * @static - * @param {Object.} object Plain object - * @returns {New} New - */ - New.fromObject = function fromObject(object) { - if (object instanceof $root.New) - return object; - var message = new $root.New(); - if (object.bindCount != null) - message.bindCount = object.bindCount | 0; - if (object.p != null) { - if (typeof object.p !== "object") - throw TypeError(".New.p: object expected"); - message.p = $root.Par.fromObject(object.p); - } - if (object.uri) { - if (!Array.isArray(object.uri)) - throw TypeError(".New.uri: array expected"); - message.uri = []; - for (var i = 0; i < object.uri.length; ++i) - message.uri[i] = String(object.uri[i]); - } - if (object.locallyFree != null) - if (typeof object.locallyFree === "string") - $util.base64.decode(object.locallyFree, message.locallyFree = $util.newBuffer($util.base64.length(object.locallyFree)), 0); - else if (object.locallyFree.length) - message.locallyFree = object.locallyFree; - return message; - }; - - /** - * Creates a plain object from a New message. Also converts values to other types if specified. - * @function toObject - * @memberof New - * @static - * @param {New} message New - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - New.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.uri = []; - if (options.defaults) { - object.bindCount = 0; - object.p = null; - if (options.bytes === String) - object.locallyFree = ""; - else { - object.locallyFree = []; - if (options.bytes !== Array) - object.locallyFree = $util.newBuffer(object.locallyFree); - } - } - if (message.bindCount != null && message.hasOwnProperty("bindCount")) - object.bindCount = message.bindCount; - if (message.p != null && message.hasOwnProperty("p")) - object.p = $root.Par.toObject(message.p, options); - if (message.uri && message.uri.length) { - object.uri = []; - for (var j = 0; j < message.uri.length; ++j) - object.uri[j] = message.uri[j]; - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - object.locallyFree = options.bytes === String ? $util.base64.encode(message.locallyFree, 0, message.locallyFree.length) : options.bytes === Array ? Array.prototype.slice.call(message.locallyFree) : message.locallyFree; - return object; - }; - - /** - * Converts this New to JSON. - * @function toJSON - * @memberof New - * @instance - * @returns {Object.} JSON object - */ - New.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return New; -})(); - -$root.MatchCase = (function() { - - /** - * Properties of a MatchCase. - * @exports IMatchCase - * @interface IMatchCase - * @property {IPar|null} [pattern] MatchCase pattern - * @property {IPar|null} [source] MatchCase source - * @property {number|null} [freeCount] MatchCase freeCount - */ - - /** - * Constructs a new MatchCase. - * @exports MatchCase - * @classdesc Represents a MatchCase. - * @implements IMatchCase - * @constructor - * @param {IMatchCase=} [properties] Properties to set - */ - function MatchCase(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * MatchCase pattern. - * @member {IPar|null|undefined} pattern - * @memberof MatchCase - * @instance - */ - MatchCase.prototype.pattern = null; - - /** - * MatchCase source. - * @member {IPar|null|undefined} source - * @memberof MatchCase - * @instance - */ - MatchCase.prototype.source = null; - - /** - * MatchCase freeCount. - * @member {number} freeCount - * @memberof MatchCase - * @instance - */ - MatchCase.prototype.freeCount = 0; - - /** - * Creates a new MatchCase instance using the specified properties. - * @function create - * @memberof MatchCase - * @static - * @param {IMatchCase=} [properties] Properties to set - * @returns {MatchCase} MatchCase instance - */ - MatchCase.create = function create(properties) { - return new MatchCase(properties); - }; - - /** - * Encodes the specified MatchCase message. Does not implicitly {@link MatchCase.verify|verify} messages. - * @function encode - * @memberof MatchCase - * @static - * @param {IMatchCase} message MatchCase message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - MatchCase.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.pattern != null && message.hasOwnProperty("pattern")) - $root.Par.encode(message.pattern, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.source != null && message.hasOwnProperty("source")) - $root.Par.encode(message.source, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.freeCount != null && message.hasOwnProperty("freeCount")) - writer.uint32(/* id 3, wireType 0 =*/24).int32(message.freeCount); - return writer; - }; - - /** - * Encodes the specified MatchCase message, length delimited. Does not implicitly {@link MatchCase.verify|verify} messages. - * @function encodeDelimited - * @memberof MatchCase - * @static - * @param {IMatchCase} message MatchCase message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - MatchCase.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a MatchCase message from the specified reader or buffer. - * @function decode - * @memberof MatchCase - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {MatchCase} MatchCase - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - MatchCase.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.MatchCase(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.pattern = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.source = $root.Par.decode(reader, reader.uint32()); - break; - case 3: - message.freeCount = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a MatchCase message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof MatchCase - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {MatchCase} MatchCase - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - MatchCase.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a MatchCase message. - * @function verify - * @memberof MatchCase - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - MatchCase.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.pattern != null && message.hasOwnProperty("pattern")) { - var error = $root.Par.verify(message.pattern); - if (error) - return "pattern." + error; - } - if (message.source != null && message.hasOwnProperty("source")) { - var error = $root.Par.verify(message.source); - if (error) - return "source." + error; - } - if (message.freeCount != null && message.hasOwnProperty("freeCount")) - if (!$util.isInteger(message.freeCount)) - return "freeCount: integer expected"; - return null; - }; - - /** - * Creates a MatchCase message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof MatchCase - * @static - * @param {Object.} object Plain object - * @returns {MatchCase} MatchCase - */ - MatchCase.fromObject = function fromObject(object) { - if (object instanceof $root.MatchCase) - return object; - var message = new $root.MatchCase(); - if (object.pattern != null) { - if (typeof object.pattern !== "object") - throw TypeError(".MatchCase.pattern: object expected"); - message.pattern = $root.Par.fromObject(object.pattern); - } - if (object.source != null) { - if (typeof object.source !== "object") - throw TypeError(".MatchCase.source: object expected"); - message.source = $root.Par.fromObject(object.source); - } - if (object.freeCount != null) - message.freeCount = object.freeCount | 0; - return message; - }; - - /** - * Creates a plain object from a MatchCase message. Also converts values to other types if specified. - * @function toObject - * @memberof MatchCase - * @static - * @param {MatchCase} message MatchCase - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - MatchCase.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.pattern = null; - object.source = null; - object.freeCount = 0; - } - if (message.pattern != null && message.hasOwnProperty("pattern")) - object.pattern = $root.Par.toObject(message.pattern, options); - if (message.source != null && message.hasOwnProperty("source")) - object.source = $root.Par.toObject(message.source, options); - if (message.freeCount != null && message.hasOwnProperty("freeCount")) - object.freeCount = message.freeCount; - return object; - }; - - /** - * Converts this MatchCase to JSON. - * @function toJSON - * @memberof MatchCase - * @instance - * @returns {Object.} JSON object - */ - MatchCase.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return MatchCase; -})(); - -$root.Match = (function() { - - /** - * Properties of a Match. - * @exports IMatch - * @interface IMatch - * @property {IPar|null} [target] Match target - * @property {Array.|null} [cases] Match cases - * @property {Uint8Array|null} [locallyFree] Match locallyFree - * @property {boolean|null} [connective_used] Match connective_used - */ - - /** - * Constructs a new Match. - * @exports Match - * @classdesc Represents a Match. - * @implements IMatch - * @constructor - * @param {IMatch=} [properties] Properties to set - */ - function Match(properties) { - this.cases = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Match target. - * @member {IPar|null|undefined} target - * @memberof Match - * @instance - */ - Match.prototype.target = null; - - /** - * Match cases. - * @member {Array.} cases - * @memberof Match - * @instance - */ - Match.prototype.cases = $util.emptyArray; - - /** - * Match locallyFree. - * @member {Uint8Array} locallyFree - * @memberof Match - * @instance - */ - Match.prototype.locallyFree = $util.newBuffer([]); - - /** - * Match connective_used. - * @member {boolean} connective_used - * @memberof Match - * @instance - */ - Match.prototype.connective_used = false; - - /** - * Creates a new Match instance using the specified properties. - * @function create - * @memberof Match - * @static - * @param {IMatch=} [properties] Properties to set - * @returns {Match} Match instance - */ - Match.create = function create(properties) { - return new Match(properties); - }; - - /** - * Encodes the specified Match message. Does not implicitly {@link Match.verify|verify} messages. - * @function encode - * @memberof Match - * @static - * @param {IMatch} message Match message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Match.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.target != null && message.hasOwnProperty("target")) - $root.Par.encode(message.target, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.cases != null && message.cases.length) - for (var i = 0; i < message.cases.length; ++i) - $root.MatchCase.encode(message.cases[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.locallyFree); - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - writer.uint32(/* id 5, wireType 0 =*/40).bool(message.connective_used); - return writer; - }; - - /** - * Encodes the specified Match message, length delimited. Does not implicitly {@link Match.verify|verify} messages. - * @function encodeDelimited - * @memberof Match - * @static - * @param {IMatch} message Match message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Match.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Match message from the specified reader or buffer. - * @function decode - * @memberof Match - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {Match} Match - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Match.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Match(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.target = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - if (!(message.cases && message.cases.length)) - message.cases = []; - message.cases.push($root.MatchCase.decode(reader, reader.uint32())); - break; - case 4: - message.locallyFree = reader.bytes(); - break; - case 5: - message.connective_used = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Match message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof Match - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {Match} Match - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Match.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Match message. - * @function verify - * @memberof Match - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Match.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.target != null && message.hasOwnProperty("target")) { - var error = $root.Par.verify(message.target); - if (error) - return "target." + error; - } - if (message.cases != null && message.hasOwnProperty("cases")) { - if (!Array.isArray(message.cases)) - return "cases: array expected"; - for (var i = 0; i < message.cases.length; ++i) { - var error = $root.MatchCase.verify(message.cases[i]); - if (error) - return "cases." + error; - } - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - if (!(message.locallyFree && typeof message.locallyFree.length === "number" || $util.isString(message.locallyFree))) - return "locallyFree: buffer expected"; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - if (typeof message.connective_used !== "boolean") - return "connective_used: boolean expected"; - return null; - }; - - /** - * Creates a Match message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof Match - * @static - * @param {Object.} object Plain object - * @returns {Match} Match - */ - Match.fromObject = function fromObject(object) { - if (object instanceof $root.Match) - return object; - var message = new $root.Match(); - if (object.target != null) { - if (typeof object.target !== "object") - throw TypeError(".Match.target: object expected"); - message.target = $root.Par.fromObject(object.target); - } - if (object.cases) { - if (!Array.isArray(object.cases)) - throw TypeError(".Match.cases: array expected"); - message.cases = []; - for (var i = 0; i < object.cases.length; ++i) { - if (typeof object.cases[i] !== "object") - throw TypeError(".Match.cases: object expected"); - message.cases[i] = $root.MatchCase.fromObject(object.cases[i]); - } - } - if (object.locallyFree != null) - if (typeof object.locallyFree === "string") - $util.base64.decode(object.locallyFree, message.locallyFree = $util.newBuffer($util.base64.length(object.locallyFree)), 0); - else if (object.locallyFree.length) - message.locallyFree = object.locallyFree; - if (object.connective_used != null) - message.connective_used = Boolean(object.connective_used); - return message; - }; - - /** - * Creates a plain object from a Match message. Also converts values to other types if specified. - * @function toObject - * @memberof Match - * @static - * @param {Match} message Match - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Match.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.cases = []; - if (options.defaults) { - object.target = null; - if (options.bytes === String) - object.locallyFree = ""; - else { - object.locallyFree = []; - if (options.bytes !== Array) - object.locallyFree = $util.newBuffer(object.locallyFree); - } - object.connective_used = false; - } - if (message.target != null && message.hasOwnProperty("target")) - object.target = $root.Par.toObject(message.target, options); - if (message.cases && message.cases.length) { - object.cases = []; - for (var j = 0; j < message.cases.length; ++j) - object.cases[j] = $root.MatchCase.toObject(message.cases[j], options); - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - object.locallyFree = options.bytes === String ? $util.base64.encode(message.locallyFree, 0, message.locallyFree.length) : options.bytes === Array ? Array.prototype.slice.call(message.locallyFree) : message.locallyFree; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - object.connective_used = message.connective_used; - return object; - }; - - /** - * Converts this Match to JSON. - * @function toJSON - * @memberof Match - * @instance - * @returns {Object.} JSON object - */ - Match.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Match; -})(); - -$root.Expr = (function() { - - /** - * Properties of an Expr. - * @exports IExpr - * @interface IExpr - * @property {boolean|null} [g_bool] Expr g_bool - * @property {number|Long|null} [g_int] Expr g_int - * @property {string|null} [g_string] Expr g_string - * @property {string|null} [g_uri] Expr g_uri - * @property {Uint8Array|null} [g_byte_array] Expr g_byte_array - * @property {IENot|null} [e_not_body] Expr e_not_body - * @property {IENeg|null} [e_neg_body] Expr e_neg_body - * @property {IEMult|null} [e_mult_body] Expr e_mult_body - * @property {IEDiv|null} [e_div_body] Expr e_div_body - * @property {IEPlus|null} [e_plus_body] Expr e_plus_body - * @property {IEMinus|null} [e_minus_body] Expr e_minus_body - * @property {IELt|null} [e_lt_body] Expr e_lt_body - * @property {IELte|null} [e_lte_body] Expr e_lte_body - * @property {IEGt|null} [e_gt_body] Expr e_gt_body - * @property {IEGte|null} [e_gte_body] Expr e_gte_body - * @property {IEEq|null} [e_eq_body] Expr e_eq_body - * @property {IENeq|null} [e_neq_body] Expr e_neq_body - * @property {IEAnd|null} [e_and_body] Expr e_and_body - * @property {IEOr|null} [e_or_body] Expr e_or_body - * @property {IEVar|null} [e_var_body] Expr e_var_body - * @property {IEList|null} [e_list_body] Expr e_list_body - * @property {IETuple|null} [e_tuple_body] Expr e_tuple_body - * @property {IESet|null} [e_set_body] Expr e_set_body - * @property {IEMap|null} [e_map_body] Expr e_map_body - * @property {IEMethod|null} [e_method_body] Expr e_method_body - * @property {IEMatches|null} [e_matches_body] Expr e_matches_body - * @property {IEPercentPercent|null} [e_percent_percent_body] Expr e_percent_percent_body - * @property {IEPlusPlus|null} [e_plus_plus_body] Expr e_plus_plus_body - * @property {IEMinusMinus|null} [e_minus_minus_body] Expr e_minus_minus_body - */ - - /** - * Constructs a new Expr. - * @exports Expr - * @classdesc Represents an Expr. - * @implements IExpr - * @constructor - * @param {IExpr=} [properties] Properties to set - */ - function Expr(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Expr g_bool. - * @member {boolean} g_bool - * @memberof Expr - * @instance - */ - Expr.prototype.g_bool = false; - - /** - * Expr g_int. - * @member {number|Long} g_int - * @memberof Expr - * @instance - */ - Expr.prototype.g_int = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Expr g_string. - * @member {string} g_string - * @memberof Expr - * @instance - */ - Expr.prototype.g_string = ""; - - /** - * Expr g_uri. - * @member {string} g_uri - * @memberof Expr - * @instance - */ - Expr.prototype.g_uri = ""; - - /** - * Expr g_byte_array. - * @member {Uint8Array} g_byte_array - * @memberof Expr - * @instance - */ - Expr.prototype.g_byte_array = $util.newBuffer([]); - - /** - * Expr e_not_body. - * @member {IENot|null|undefined} e_not_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_not_body = null; - - /** - * Expr e_neg_body. - * @member {IENeg|null|undefined} e_neg_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_neg_body = null; - - /** - * Expr e_mult_body. - * @member {IEMult|null|undefined} e_mult_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_mult_body = null; - - /** - * Expr e_div_body. - * @member {IEDiv|null|undefined} e_div_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_div_body = null; - - /** - * Expr e_plus_body. - * @member {IEPlus|null|undefined} e_plus_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_plus_body = null; - - /** - * Expr e_minus_body. - * @member {IEMinus|null|undefined} e_minus_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_minus_body = null; - - /** - * Expr e_lt_body. - * @member {IELt|null|undefined} e_lt_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_lt_body = null; - - /** - * Expr e_lte_body. - * @member {IELte|null|undefined} e_lte_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_lte_body = null; - - /** - * Expr e_gt_body. - * @member {IEGt|null|undefined} e_gt_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_gt_body = null; - - /** - * Expr e_gte_body. - * @member {IEGte|null|undefined} e_gte_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_gte_body = null; - - /** - * Expr e_eq_body. - * @member {IEEq|null|undefined} e_eq_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_eq_body = null; - - /** - * Expr e_neq_body. - * @member {IENeq|null|undefined} e_neq_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_neq_body = null; - - /** - * Expr e_and_body. - * @member {IEAnd|null|undefined} e_and_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_and_body = null; - - /** - * Expr e_or_body. - * @member {IEOr|null|undefined} e_or_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_or_body = null; - - /** - * Expr e_var_body. - * @member {IEVar|null|undefined} e_var_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_var_body = null; - - /** - * Expr e_list_body. - * @member {IEList|null|undefined} e_list_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_list_body = null; - - /** - * Expr e_tuple_body. - * @member {IETuple|null|undefined} e_tuple_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_tuple_body = null; - - /** - * Expr e_set_body. - * @member {IESet|null|undefined} e_set_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_set_body = null; - - /** - * Expr e_map_body. - * @member {IEMap|null|undefined} e_map_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_map_body = null; - - /** - * Expr e_method_body. - * @member {IEMethod|null|undefined} e_method_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_method_body = null; - - /** - * Expr e_matches_body. - * @member {IEMatches|null|undefined} e_matches_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_matches_body = null; - - /** - * Expr e_percent_percent_body. - * @member {IEPercentPercent|null|undefined} e_percent_percent_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_percent_percent_body = null; - - /** - * Expr e_plus_plus_body. - * @member {IEPlusPlus|null|undefined} e_plus_plus_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_plus_plus_body = null; - - /** - * Expr e_minus_minus_body. - * @member {IEMinusMinus|null|undefined} e_minus_minus_body - * @memberof Expr - * @instance - */ - Expr.prototype.e_minus_minus_body = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Expr expr_instance. - * @member {"g_bool"|"g_int"|"g_string"|"g_uri"|"g_byte_array"|"e_not_body"|"e_neg_body"|"e_mult_body"|"e_div_body"|"e_plus_body"|"e_minus_body"|"e_lt_body"|"e_lte_body"|"e_gt_body"|"e_gte_body"|"e_eq_body"|"e_neq_body"|"e_and_body"|"e_or_body"|"e_var_body"|"e_list_body"|"e_tuple_body"|"e_set_body"|"e_map_body"|"e_method_body"|"e_matches_body"|"e_percent_percent_body"|"e_plus_plus_body"|"e_minus_minus_body"|undefined} expr_instance - * @memberof Expr - * @instance - */ - Object.defineProperty(Expr.prototype, "expr_instance", { - get: $util.oneOfGetter($oneOfFields = ["g_bool", "g_int", "g_string", "g_uri", "g_byte_array", "e_not_body", "e_neg_body", "e_mult_body", "e_div_body", "e_plus_body", "e_minus_body", "e_lt_body", "e_lte_body", "e_gt_body", "e_gte_body", "e_eq_body", "e_neq_body", "e_and_body", "e_or_body", "e_var_body", "e_list_body", "e_tuple_body", "e_set_body", "e_map_body", "e_method_body", "e_matches_body", "e_percent_percent_body", "e_plus_plus_body", "e_minus_minus_body"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * Creates a new Expr instance using the specified properties. - * @function create - * @memberof Expr - * @static - * @param {IExpr=} [properties] Properties to set - * @returns {Expr} Expr instance - */ - Expr.create = function create(properties) { - return new Expr(properties); - }; - - /** - * Encodes the specified Expr message. Does not implicitly {@link Expr.verify|verify} messages. - * @function encode - * @memberof Expr - * @static - * @param {IExpr} message Expr message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Expr.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.g_bool != null && message.hasOwnProperty("g_bool")) - writer.uint32(/* id 1, wireType 0 =*/8).bool(message.g_bool); - if (message.g_int != null && message.hasOwnProperty("g_int")) - writer.uint32(/* id 2, wireType 0 =*/16).sint64(message.g_int); - if (message.g_string != null && message.hasOwnProperty("g_string")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.g_string); - if (message.g_uri != null && message.hasOwnProperty("g_uri")) - writer.uint32(/* id 4, wireType 2 =*/34).string(message.g_uri); - if (message.e_not_body != null && message.hasOwnProperty("e_not_body")) - $root.ENot.encode(message.e_not_body, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); - if (message.e_neg_body != null && message.hasOwnProperty("e_neg_body")) - $root.ENeg.encode(message.e_neg_body, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); - if (message.e_mult_body != null && message.hasOwnProperty("e_mult_body")) - $root.EMult.encode(message.e_mult_body, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); - if (message.e_div_body != null && message.hasOwnProperty("e_div_body")) - $root.EDiv.encode(message.e_div_body, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); - if (message.e_plus_body != null && message.hasOwnProperty("e_plus_body")) - $root.EPlus.encode(message.e_plus_body, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); - if (message.e_minus_body != null && message.hasOwnProperty("e_minus_body")) - $root.EMinus.encode(message.e_minus_body, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); - if (message.e_lt_body != null && message.hasOwnProperty("e_lt_body")) - $root.ELt.encode(message.e_lt_body, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); - if (message.e_lte_body != null && message.hasOwnProperty("e_lte_body")) - $root.ELte.encode(message.e_lte_body, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); - if (message.e_gt_body != null && message.hasOwnProperty("e_gt_body")) - $root.EGt.encode(message.e_gt_body, writer.uint32(/* id 13, wireType 2 =*/106).fork()).ldelim(); - if (message.e_gte_body != null && message.hasOwnProperty("e_gte_body")) - $root.EGte.encode(message.e_gte_body, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); - if (message.e_eq_body != null && message.hasOwnProperty("e_eq_body")) - $root.EEq.encode(message.e_eq_body, writer.uint32(/* id 15, wireType 2 =*/122).fork()).ldelim(); - if (message.e_neq_body != null && message.hasOwnProperty("e_neq_body")) - $root.ENeq.encode(message.e_neq_body, writer.uint32(/* id 16, wireType 2 =*/130).fork()).ldelim(); - if (message.e_and_body != null && message.hasOwnProperty("e_and_body")) - $root.EAnd.encode(message.e_and_body, writer.uint32(/* id 17, wireType 2 =*/138).fork()).ldelim(); - if (message.e_or_body != null && message.hasOwnProperty("e_or_body")) - $root.EOr.encode(message.e_or_body, writer.uint32(/* id 18, wireType 2 =*/146).fork()).ldelim(); - if (message.e_var_body != null && message.hasOwnProperty("e_var_body")) - $root.EVar.encode(message.e_var_body, writer.uint32(/* id 19, wireType 2 =*/154).fork()).ldelim(); - if (message.e_list_body != null && message.hasOwnProperty("e_list_body")) - $root.EList.encode(message.e_list_body, writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); - if (message.e_tuple_body != null && message.hasOwnProperty("e_tuple_body")) - $root.ETuple.encode(message.e_tuple_body, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); - if (message.e_set_body != null && message.hasOwnProperty("e_set_body")) - $root.ESet.encode(message.e_set_body, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); - if (message.e_map_body != null && message.hasOwnProperty("e_map_body")) - $root.EMap.encode(message.e_map_body, writer.uint32(/* id 23, wireType 2 =*/186).fork()).ldelim(); - if (message.e_method_body != null && message.hasOwnProperty("e_method_body")) - $root.EMethod.encode(message.e_method_body, writer.uint32(/* id 24, wireType 2 =*/194).fork()).ldelim(); - if (message.g_byte_array != null && message.hasOwnProperty("g_byte_array")) - writer.uint32(/* id 25, wireType 2 =*/202).bytes(message.g_byte_array); - if (message.e_matches_body != null && message.hasOwnProperty("e_matches_body")) - $root.EMatches.encode(message.e_matches_body, writer.uint32(/* id 27, wireType 2 =*/218).fork()).ldelim(); - if (message.e_percent_percent_body != null && message.hasOwnProperty("e_percent_percent_body")) - $root.EPercentPercent.encode(message.e_percent_percent_body, writer.uint32(/* id 28, wireType 2 =*/226).fork()).ldelim(); - if (message.e_plus_plus_body != null && message.hasOwnProperty("e_plus_plus_body")) - $root.EPlusPlus.encode(message.e_plus_plus_body, writer.uint32(/* id 29, wireType 2 =*/234).fork()).ldelim(); - if (message.e_minus_minus_body != null && message.hasOwnProperty("e_minus_minus_body")) - $root.EMinusMinus.encode(message.e_minus_minus_body, writer.uint32(/* id 30, wireType 2 =*/242).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified Expr message, length delimited. Does not implicitly {@link Expr.verify|verify} messages. - * @function encodeDelimited - * @memberof Expr - * @static - * @param {IExpr} message Expr message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Expr.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an Expr message from the specified reader or buffer. - * @function decode - * @memberof Expr - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {Expr} Expr - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Expr.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Expr(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.g_bool = reader.bool(); - break; - case 2: - message.g_int = reader.sint64(); - break; - case 3: - message.g_string = reader.string(); - break; - case 4: - message.g_uri = reader.string(); - break; - case 25: - message.g_byte_array = reader.bytes(); - break; - case 5: - message.e_not_body = $root.ENot.decode(reader, reader.uint32()); - break; - case 6: - message.e_neg_body = $root.ENeg.decode(reader, reader.uint32()); - break; - case 7: - message.e_mult_body = $root.EMult.decode(reader, reader.uint32()); - break; - case 8: - message.e_div_body = $root.EDiv.decode(reader, reader.uint32()); - break; - case 9: - message.e_plus_body = $root.EPlus.decode(reader, reader.uint32()); - break; - case 10: - message.e_minus_body = $root.EMinus.decode(reader, reader.uint32()); - break; - case 11: - message.e_lt_body = $root.ELt.decode(reader, reader.uint32()); - break; - case 12: - message.e_lte_body = $root.ELte.decode(reader, reader.uint32()); - break; - case 13: - message.e_gt_body = $root.EGt.decode(reader, reader.uint32()); - break; - case 14: - message.e_gte_body = $root.EGte.decode(reader, reader.uint32()); - break; - case 15: - message.e_eq_body = $root.EEq.decode(reader, reader.uint32()); - break; - case 16: - message.e_neq_body = $root.ENeq.decode(reader, reader.uint32()); - break; - case 17: - message.e_and_body = $root.EAnd.decode(reader, reader.uint32()); - break; - case 18: - message.e_or_body = $root.EOr.decode(reader, reader.uint32()); - break; - case 19: - message.e_var_body = $root.EVar.decode(reader, reader.uint32()); - break; - case 20: - message.e_list_body = $root.EList.decode(reader, reader.uint32()); - break; - case 21: - message.e_tuple_body = $root.ETuple.decode(reader, reader.uint32()); - break; - case 22: - message.e_set_body = $root.ESet.decode(reader, reader.uint32()); - break; - case 23: - message.e_map_body = $root.EMap.decode(reader, reader.uint32()); - break; - case 24: - message.e_method_body = $root.EMethod.decode(reader, reader.uint32()); - break; - case 27: - message.e_matches_body = $root.EMatches.decode(reader, reader.uint32()); - break; - case 28: - message.e_percent_percent_body = $root.EPercentPercent.decode(reader, reader.uint32()); - break; - case 29: - message.e_plus_plus_body = $root.EPlusPlus.decode(reader, reader.uint32()); - break; - case 30: - message.e_minus_minus_body = $root.EMinusMinus.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an Expr message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof Expr - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {Expr} Expr - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Expr.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an Expr message. - * @function verify - * @memberof Expr - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Expr.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - var properties = {}; - if (message.g_bool != null && message.hasOwnProperty("g_bool")) { - properties.expr_instance = 1; - if (typeof message.g_bool !== "boolean") - return "g_bool: boolean expected"; - } - if (message.g_int != null && message.hasOwnProperty("g_int")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - if (!$util.isInteger(message.g_int) && !(message.g_int && $util.isInteger(message.g_int.low) && $util.isInteger(message.g_int.high))) - return "g_int: integer|Long expected"; - } - if (message.g_string != null && message.hasOwnProperty("g_string")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - if (!$util.isString(message.g_string)) - return "g_string: string expected"; - } - if (message.g_uri != null && message.hasOwnProperty("g_uri")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - if (!$util.isString(message.g_uri)) - return "g_uri: string expected"; - } - if (message.g_byte_array != null && message.hasOwnProperty("g_byte_array")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - if (!(message.g_byte_array && typeof message.g_byte_array.length === "number" || $util.isString(message.g_byte_array))) - return "g_byte_array: buffer expected"; - } - if (message.e_not_body != null && message.hasOwnProperty("e_not_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.ENot.verify(message.e_not_body); - if (error) - return "e_not_body." + error; - } - } - if (message.e_neg_body != null && message.hasOwnProperty("e_neg_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.ENeg.verify(message.e_neg_body); - if (error) - return "e_neg_body." + error; - } - } - if (message.e_mult_body != null && message.hasOwnProperty("e_mult_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EMult.verify(message.e_mult_body); - if (error) - return "e_mult_body." + error; - } - } - if (message.e_div_body != null && message.hasOwnProperty("e_div_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EDiv.verify(message.e_div_body); - if (error) - return "e_div_body." + error; - } - } - if (message.e_plus_body != null && message.hasOwnProperty("e_plus_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EPlus.verify(message.e_plus_body); - if (error) - return "e_plus_body." + error; - } - } - if (message.e_minus_body != null && message.hasOwnProperty("e_minus_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EMinus.verify(message.e_minus_body); - if (error) - return "e_minus_body." + error; - } - } - if (message.e_lt_body != null && message.hasOwnProperty("e_lt_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.ELt.verify(message.e_lt_body); - if (error) - return "e_lt_body." + error; - } - } - if (message.e_lte_body != null && message.hasOwnProperty("e_lte_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.ELte.verify(message.e_lte_body); - if (error) - return "e_lte_body." + error; - } - } - if (message.e_gt_body != null && message.hasOwnProperty("e_gt_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EGt.verify(message.e_gt_body); - if (error) - return "e_gt_body." + error; - } - } - if (message.e_gte_body != null && message.hasOwnProperty("e_gte_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EGte.verify(message.e_gte_body); - if (error) - return "e_gte_body." + error; - } - } - if (message.e_eq_body != null && message.hasOwnProperty("e_eq_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EEq.verify(message.e_eq_body); - if (error) - return "e_eq_body." + error; - } - } - if (message.e_neq_body != null && message.hasOwnProperty("e_neq_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.ENeq.verify(message.e_neq_body); - if (error) - return "e_neq_body." + error; - } - } - if (message.e_and_body != null && message.hasOwnProperty("e_and_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EAnd.verify(message.e_and_body); - if (error) - return "e_and_body." + error; - } - } - if (message.e_or_body != null && message.hasOwnProperty("e_or_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EOr.verify(message.e_or_body); - if (error) - return "e_or_body." + error; - } - } - if (message.e_var_body != null && message.hasOwnProperty("e_var_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EVar.verify(message.e_var_body); - if (error) - return "e_var_body." + error; - } - } - if (message.e_list_body != null && message.hasOwnProperty("e_list_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EList.verify(message.e_list_body); - if (error) - return "e_list_body." + error; - } - } - if (message.e_tuple_body != null && message.hasOwnProperty("e_tuple_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.ETuple.verify(message.e_tuple_body); - if (error) - return "e_tuple_body." + error; - } - } - if (message.e_set_body != null && message.hasOwnProperty("e_set_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.ESet.verify(message.e_set_body); - if (error) - return "e_set_body." + error; - } - } - if (message.e_map_body != null && message.hasOwnProperty("e_map_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EMap.verify(message.e_map_body); - if (error) - return "e_map_body." + error; - } - } - if (message.e_method_body != null && message.hasOwnProperty("e_method_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EMethod.verify(message.e_method_body); - if (error) - return "e_method_body." + error; - } - } - if (message.e_matches_body != null && message.hasOwnProperty("e_matches_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EMatches.verify(message.e_matches_body); - if (error) - return "e_matches_body." + error; - } - } - if (message.e_percent_percent_body != null && message.hasOwnProperty("e_percent_percent_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EPercentPercent.verify(message.e_percent_percent_body); - if (error) - return "e_percent_percent_body." + error; - } - } - if (message.e_plus_plus_body != null && message.hasOwnProperty("e_plus_plus_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EPlusPlus.verify(message.e_plus_plus_body); - if (error) - return "e_plus_plus_body." + error; - } - } - if (message.e_minus_minus_body != null && message.hasOwnProperty("e_minus_minus_body")) { - if (properties.expr_instance === 1) - return "expr_instance: multiple values"; - properties.expr_instance = 1; - { - var error = $root.EMinusMinus.verify(message.e_minus_minus_body); - if (error) - return "e_minus_minus_body." + error; - } - } - return null; - }; - - /** - * Creates an Expr message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof Expr - * @static - * @param {Object.} object Plain object - * @returns {Expr} Expr - */ - Expr.fromObject = function fromObject(object) { - if (object instanceof $root.Expr) - return object; - var message = new $root.Expr(); - if (object.g_bool != null) - message.g_bool = Boolean(object.g_bool); - if (object.g_int != null) - if ($util.Long) - (message.g_int = $util.Long.fromValue(object.g_int)).unsigned = false; - else if (typeof object.g_int === "string") - message.g_int = parseInt(object.g_int, 10); - else if (typeof object.g_int === "number") - message.g_int = object.g_int; - else if (typeof object.g_int === "object") - message.g_int = new $util.LongBits(object.g_int.low >>> 0, object.g_int.high >>> 0).toNumber(); - if (object.g_string != null) - message.g_string = String(object.g_string); - if (object.g_uri != null) - message.g_uri = String(object.g_uri); - if (object.g_byte_array != null) - if (typeof object.g_byte_array === "string") - $util.base64.decode(object.g_byte_array, message.g_byte_array = $util.newBuffer($util.base64.length(object.g_byte_array)), 0); - else if (object.g_byte_array.length) - message.g_byte_array = object.g_byte_array; - if (object.e_not_body != null) { - if (typeof object.e_not_body !== "object") - throw TypeError(".Expr.e_not_body: object expected"); - message.e_not_body = $root.ENot.fromObject(object.e_not_body); - } - if (object.e_neg_body != null) { - if (typeof object.e_neg_body !== "object") - throw TypeError(".Expr.e_neg_body: object expected"); - message.e_neg_body = $root.ENeg.fromObject(object.e_neg_body); - } - if (object.e_mult_body != null) { - if (typeof object.e_mult_body !== "object") - throw TypeError(".Expr.e_mult_body: object expected"); - message.e_mult_body = $root.EMult.fromObject(object.e_mult_body); - } - if (object.e_div_body != null) { - if (typeof object.e_div_body !== "object") - throw TypeError(".Expr.e_div_body: object expected"); - message.e_div_body = $root.EDiv.fromObject(object.e_div_body); - } - if (object.e_plus_body != null) { - if (typeof object.e_plus_body !== "object") - throw TypeError(".Expr.e_plus_body: object expected"); - message.e_plus_body = $root.EPlus.fromObject(object.e_plus_body); - } - if (object.e_minus_body != null) { - if (typeof object.e_minus_body !== "object") - throw TypeError(".Expr.e_minus_body: object expected"); - message.e_minus_body = $root.EMinus.fromObject(object.e_minus_body); - } - if (object.e_lt_body != null) { - if (typeof object.e_lt_body !== "object") - throw TypeError(".Expr.e_lt_body: object expected"); - message.e_lt_body = $root.ELt.fromObject(object.e_lt_body); - } - if (object.e_lte_body != null) { - if (typeof object.e_lte_body !== "object") - throw TypeError(".Expr.e_lte_body: object expected"); - message.e_lte_body = $root.ELte.fromObject(object.e_lte_body); - } - if (object.e_gt_body != null) { - if (typeof object.e_gt_body !== "object") - throw TypeError(".Expr.e_gt_body: object expected"); - message.e_gt_body = $root.EGt.fromObject(object.e_gt_body); - } - if (object.e_gte_body != null) { - if (typeof object.e_gte_body !== "object") - throw TypeError(".Expr.e_gte_body: object expected"); - message.e_gte_body = $root.EGte.fromObject(object.e_gte_body); - } - if (object.e_eq_body != null) { - if (typeof object.e_eq_body !== "object") - throw TypeError(".Expr.e_eq_body: object expected"); - message.e_eq_body = $root.EEq.fromObject(object.e_eq_body); - } - if (object.e_neq_body != null) { - if (typeof object.e_neq_body !== "object") - throw TypeError(".Expr.e_neq_body: object expected"); - message.e_neq_body = $root.ENeq.fromObject(object.e_neq_body); - } - if (object.e_and_body != null) { - if (typeof object.e_and_body !== "object") - throw TypeError(".Expr.e_and_body: object expected"); - message.e_and_body = $root.EAnd.fromObject(object.e_and_body); - } - if (object.e_or_body != null) { - if (typeof object.e_or_body !== "object") - throw TypeError(".Expr.e_or_body: object expected"); - message.e_or_body = $root.EOr.fromObject(object.e_or_body); - } - if (object.e_var_body != null) { - if (typeof object.e_var_body !== "object") - throw TypeError(".Expr.e_var_body: object expected"); - message.e_var_body = $root.EVar.fromObject(object.e_var_body); - } - if (object.e_list_body != null) { - if (typeof object.e_list_body !== "object") - throw TypeError(".Expr.e_list_body: object expected"); - message.e_list_body = $root.EList.fromObject(object.e_list_body); - } - if (object.e_tuple_body != null) { - if (typeof object.e_tuple_body !== "object") - throw TypeError(".Expr.e_tuple_body: object expected"); - message.e_tuple_body = $root.ETuple.fromObject(object.e_tuple_body); - } - if (object.e_set_body != null) { - if (typeof object.e_set_body !== "object") - throw TypeError(".Expr.e_set_body: object expected"); - message.e_set_body = $root.ESet.fromObject(object.e_set_body); - } - if (object.e_map_body != null) { - if (typeof object.e_map_body !== "object") - throw TypeError(".Expr.e_map_body: object expected"); - message.e_map_body = $root.EMap.fromObject(object.e_map_body); - } - if (object.e_method_body != null) { - if (typeof object.e_method_body !== "object") - throw TypeError(".Expr.e_method_body: object expected"); - message.e_method_body = $root.EMethod.fromObject(object.e_method_body); - } - if (object.e_matches_body != null) { - if (typeof object.e_matches_body !== "object") - throw TypeError(".Expr.e_matches_body: object expected"); - message.e_matches_body = $root.EMatches.fromObject(object.e_matches_body); - } - if (object.e_percent_percent_body != null) { - if (typeof object.e_percent_percent_body !== "object") - throw TypeError(".Expr.e_percent_percent_body: object expected"); - message.e_percent_percent_body = $root.EPercentPercent.fromObject(object.e_percent_percent_body); - } - if (object.e_plus_plus_body != null) { - if (typeof object.e_plus_plus_body !== "object") - throw TypeError(".Expr.e_plus_plus_body: object expected"); - message.e_plus_plus_body = $root.EPlusPlus.fromObject(object.e_plus_plus_body); - } - if (object.e_minus_minus_body != null) { - if (typeof object.e_minus_minus_body !== "object") - throw TypeError(".Expr.e_minus_minus_body: object expected"); - message.e_minus_minus_body = $root.EMinusMinus.fromObject(object.e_minus_minus_body); - } - return message; - }; - - /** - * Creates a plain object from an Expr message. Also converts values to other types if specified. - * @function toObject - * @memberof Expr - * @static - * @param {Expr} message Expr - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Expr.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (message.g_bool != null && message.hasOwnProperty("g_bool")) { - object.g_bool = message.g_bool; - if (options.oneofs) - object.expr_instance = "g_bool"; - } - if (message.g_int != null && message.hasOwnProperty("g_int")) { - if (typeof message.g_int === "number") - object.g_int = options.longs === String ? String(message.g_int) : message.g_int; - else - object.g_int = options.longs === String ? $util.Long.prototype.toString.call(message.g_int) : options.longs === Number ? new $util.LongBits(message.g_int.low >>> 0, message.g_int.high >>> 0).toNumber() : message.g_int; - if (options.oneofs) - object.expr_instance = "g_int"; - } - if (message.g_string != null && message.hasOwnProperty("g_string")) { - object.g_string = message.g_string; - if (options.oneofs) - object.expr_instance = "g_string"; - } - if (message.g_uri != null && message.hasOwnProperty("g_uri")) { - object.g_uri = message.g_uri; - if (options.oneofs) - object.expr_instance = "g_uri"; - } - if (message.e_not_body != null && message.hasOwnProperty("e_not_body")) { - object.e_not_body = $root.ENot.toObject(message.e_not_body, options); - if (options.oneofs) - object.expr_instance = "e_not_body"; - } - if (message.e_neg_body != null && message.hasOwnProperty("e_neg_body")) { - object.e_neg_body = $root.ENeg.toObject(message.e_neg_body, options); - if (options.oneofs) - object.expr_instance = "e_neg_body"; - } - if (message.e_mult_body != null && message.hasOwnProperty("e_mult_body")) { - object.e_mult_body = $root.EMult.toObject(message.e_mult_body, options); - if (options.oneofs) - object.expr_instance = "e_mult_body"; - } - if (message.e_div_body != null && message.hasOwnProperty("e_div_body")) { - object.e_div_body = $root.EDiv.toObject(message.e_div_body, options); - if (options.oneofs) - object.expr_instance = "e_div_body"; - } - if (message.e_plus_body != null && message.hasOwnProperty("e_plus_body")) { - object.e_plus_body = $root.EPlus.toObject(message.e_plus_body, options); - if (options.oneofs) - object.expr_instance = "e_plus_body"; - } - if (message.e_minus_body != null && message.hasOwnProperty("e_minus_body")) { - object.e_minus_body = $root.EMinus.toObject(message.e_minus_body, options); - if (options.oneofs) - object.expr_instance = "e_minus_body"; - } - if (message.e_lt_body != null && message.hasOwnProperty("e_lt_body")) { - object.e_lt_body = $root.ELt.toObject(message.e_lt_body, options); - if (options.oneofs) - object.expr_instance = "e_lt_body"; - } - if (message.e_lte_body != null && message.hasOwnProperty("e_lte_body")) { - object.e_lte_body = $root.ELte.toObject(message.e_lte_body, options); - if (options.oneofs) - object.expr_instance = "e_lte_body"; - } - if (message.e_gt_body != null && message.hasOwnProperty("e_gt_body")) { - object.e_gt_body = $root.EGt.toObject(message.e_gt_body, options); - if (options.oneofs) - object.expr_instance = "e_gt_body"; - } - if (message.e_gte_body != null && message.hasOwnProperty("e_gte_body")) { - object.e_gte_body = $root.EGte.toObject(message.e_gte_body, options); - if (options.oneofs) - object.expr_instance = "e_gte_body"; - } - if (message.e_eq_body != null && message.hasOwnProperty("e_eq_body")) { - object.e_eq_body = $root.EEq.toObject(message.e_eq_body, options); - if (options.oneofs) - object.expr_instance = "e_eq_body"; - } - if (message.e_neq_body != null && message.hasOwnProperty("e_neq_body")) { - object.e_neq_body = $root.ENeq.toObject(message.e_neq_body, options); - if (options.oneofs) - object.expr_instance = "e_neq_body"; - } - if (message.e_and_body != null && message.hasOwnProperty("e_and_body")) { - object.e_and_body = $root.EAnd.toObject(message.e_and_body, options); - if (options.oneofs) - object.expr_instance = "e_and_body"; - } - if (message.e_or_body != null && message.hasOwnProperty("e_or_body")) { - object.e_or_body = $root.EOr.toObject(message.e_or_body, options); - if (options.oneofs) - object.expr_instance = "e_or_body"; - } - if (message.e_var_body != null && message.hasOwnProperty("e_var_body")) { - object.e_var_body = $root.EVar.toObject(message.e_var_body, options); - if (options.oneofs) - object.expr_instance = "e_var_body"; - } - if (message.e_list_body != null && message.hasOwnProperty("e_list_body")) { - object.e_list_body = $root.EList.toObject(message.e_list_body, options); - if (options.oneofs) - object.expr_instance = "e_list_body"; - } - if (message.e_tuple_body != null && message.hasOwnProperty("e_tuple_body")) { - object.e_tuple_body = $root.ETuple.toObject(message.e_tuple_body, options); - if (options.oneofs) - object.expr_instance = "e_tuple_body"; - } - if (message.e_set_body != null && message.hasOwnProperty("e_set_body")) { - object.e_set_body = $root.ESet.toObject(message.e_set_body, options); - if (options.oneofs) - object.expr_instance = "e_set_body"; - } - if (message.e_map_body != null && message.hasOwnProperty("e_map_body")) { - object.e_map_body = $root.EMap.toObject(message.e_map_body, options); - if (options.oneofs) - object.expr_instance = "e_map_body"; - } - if (message.e_method_body != null && message.hasOwnProperty("e_method_body")) { - object.e_method_body = $root.EMethod.toObject(message.e_method_body, options); - if (options.oneofs) - object.expr_instance = "e_method_body"; - } - if (message.g_byte_array != null && message.hasOwnProperty("g_byte_array")) { - object.g_byte_array = options.bytes === String ? $util.base64.encode(message.g_byte_array, 0, message.g_byte_array.length) : options.bytes === Array ? Array.prototype.slice.call(message.g_byte_array) : message.g_byte_array; - if (options.oneofs) - object.expr_instance = "g_byte_array"; - } - if (message.e_matches_body != null && message.hasOwnProperty("e_matches_body")) { - object.e_matches_body = $root.EMatches.toObject(message.e_matches_body, options); - if (options.oneofs) - object.expr_instance = "e_matches_body"; - } - if (message.e_percent_percent_body != null && message.hasOwnProperty("e_percent_percent_body")) { - object.e_percent_percent_body = $root.EPercentPercent.toObject(message.e_percent_percent_body, options); - if (options.oneofs) - object.expr_instance = "e_percent_percent_body"; - } - if (message.e_plus_plus_body != null && message.hasOwnProperty("e_plus_plus_body")) { - object.e_plus_plus_body = $root.EPlusPlus.toObject(message.e_plus_plus_body, options); - if (options.oneofs) - object.expr_instance = "e_plus_plus_body"; - } - if (message.e_minus_minus_body != null && message.hasOwnProperty("e_minus_minus_body")) { - object.e_minus_minus_body = $root.EMinusMinus.toObject(message.e_minus_minus_body, options); - if (options.oneofs) - object.expr_instance = "e_minus_minus_body"; - } - return object; - }; - - /** - * Converts this Expr to JSON. - * @function toJSON - * @memberof Expr - * @instance - * @returns {Object.} JSON object - */ - Expr.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Expr; -})(); - -$root.EList = (function() { - - /** - * Properties of a EList. - * @exports IEList - * @interface IEList - * @property {Array.|null} [ps] EList ps - * @property {Uint8Array|null} [locallyFree] EList locallyFree - * @property {boolean|null} [connective_used] EList connective_used - * @property {IVar|null} [remainder] EList remainder - */ - - /** - * Constructs a new EList. - * @exports EList - * @classdesc Represents a EList. - * @implements IEList - * @constructor - * @param {IEList=} [properties] Properties to set - */ - function EList(properties) { - this.ps = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EList ps. - * @member {Array.} ps - * @memberof EList - * @instance - */ - EList.prototype.ps = $util.emptyArray; - - /** - * EList locallyFree. - * @member {Uint8Array} locallyFree - * @memberof EList - * @instance - */ - EList.prototype.locallyFree = $util.newBuffer([]); - - /** - * EList connective_used. - * @member {boolean} connective_used - * @memberof EList - * @instance - */ - EList.prototype.connective_used = false; - - /** - * EList remainder. - * @member {IVar|null|undefined} remainder - * @memberof EList - * @instance - */ - EList.prototype.remainder = null; - - /** - * Creates a new EList instance using the specified properties. - * @function create - * @memberof EList - * @static - * @param {IEList=} [properties] Properties to set - * @returns {EList} EList instance - */ - EList.create = function create(properties) { - return new EList(properties); - }; - - /** - * Encodes the specified EList message. Does not implicitly {@link EList.verify|verify} messages. - * @function encode - * @memberof EList - * @static - * @param {IEList} message EList message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EList.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.ps != null && message.ps.length) - for (var i = 0; i < message.ps.length; ++i) - $root.Par.encode(message.ps[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.locallyFree); - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - writer.uint32(/* id 4, wireType 0 =*/32).bool(message.connective_used); - if (message.remainder != null && message.hasOwnProperty("remainder")) - $root.Var.encode(message.remainder, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EList message, length delimited. Does not implicitly {@link EList.verify|verify} messages. - * @function encodeDelimited - * @memberof EList - * @static - * @param {IEList} message EList message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EList.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EList message from the specified reader or buffer. - * @function decode - * @memberof EList - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EList} EList - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EList.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EList(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.ps && message.ps.length)) - message.ps = []; - message.ps.push($root.Par.decode(reader, reader.uint32())); - break; - case 3: - message.locallyFree = reader.bytes(); - break; - case 4: - message.connective_used = reader.bool(); - break; - case 5: - message.remainder = $root.Var.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EList message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EList - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EList} EList - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EList.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EList message. - * @function verify - * @memberof EList - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EList.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.ps != null && message.hasOwnProperty("ps")) { - if (!Array.isArray(message.ps)) - return "ps: array expected"; - for (var i = 0; i < message.ps.length; ++i) { - var error = $root.Par.verify(message.ps[i]); - if (error) - return "ps." + error; - } - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - if (!(message.locallyFree && typeof message.locallyFree.length === "number" || $util.isString(message.locallyFree))) - return "locallyFree: buffer expected"; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - if (typeof message.connective_used !== "boolean") - return "connective_used: boolean expected"; - if (message.remainder != null && message.hasOwnProperty("remainder")) { - var error = $root.Var.verify(message.remainder); - if (error) - return "remainder." + error; - } - return null; - }; - - /** - * Creates a EList message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EList - * @static - * @param {Object.} object Plain object - * @returns {EList} EList - */ - EList.fromObject = function fromObject(object) { - if (object instanceof $root.EList) - return object; - var message = new $root.EList(); - if (object.ps) { - if (!Array.isArray(object.ps)) - throw TypeError(".EList.ps: array expected"); - message.ps = []; - for (var i = 0; i < object.ps.length; ++i) { - if (typeof object.ps[i] !== "object") - throw TypeError(".EList.ps: object expected"); - message.ps[i] = $root.Par.fromObject(object.ps[i]); - } - } - if (object.locallyFree != null) - if (typeof object.locallyFree === "string") - $util.base64.decode(object.locallyFree, message.locallyFree = $util.newBuffer($util.base64.length(object.locallyFree)), 0); - else if (object.locallyFree.length) - message.locallyFree = object.locallyFree; - if (object.connective_used != null) - message.connective_used = Boolean(object.connective_used); - if (object.remainder != null) { - if (typeof object.remainder !== "object") - throw TypeError(".EList.remainder: object expected"); - message.remainder = $root.Var.fromObject(object.remainder); - } - return message; - }; - - /** - * Creates a plain object from a EList message. Also converts values to other types if specified. - * @function toObject - * @memberof EList - * @static - * @param {EList} message EList - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EList.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.ps = []; - if (options.defaults) { - if (options.bytes === String) - object.locallyFree = ""; - else { - object.locallyFree = []; - if (options.bytes !== Array) - object.locallyFree = $util.newBuffer(object.locallyFree); - } - object.connective_used = false; - object.remainder = null; - } - if (message.ps && message.ps.length) { - object.ps = []; - for (var j = 0; j < message.ps.length; ++j) - object.ps[j] = $root.Par.toObject(message.ps[j], options); - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - object.locallyFree = options.bytes === String ? $util.base64.encode(message.locallyFree, 0, message.locallyFree.length) : options.bytes === Array ? Array.prototype.slice.call(message.locallyFree) : message.locallyFree; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - object.connective_used = message.connective_used; - if (message.remainder != null && message.hasOwnProperty("remainder")) - object.remainder = $root.Var.toObject(message.remainder, options); - return object; - }; - - /** - * Converts this EList to JSON. - * @function toJSON - * @memberof EList - * @instance - * @returns {Object.} JSON object - */ - EList.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EList; -})(); - -$root.ETuple = (function() { - - /** - * Properties of a ETuple. - * @exports IETuple - * @interface IETuple - * @property {Array.|null} [ps] ETuple ps - * @property {Uint8Array|null} [locallyFree] ETuple locallyFree - * @property {boolean|null} [connective_used] ETuple connective_used - */ - - /** - * Constructs a new ETuple. - * @exports ETuple - * @classdesc Represents a ETuple. - * @implements IETuple - * @constructor - * @param {IETuple=} [properties] Properties to set - */ - function ETuple(properties) { - this.ps = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ETuple ps. - * @member {Array.} ps - * @memberof ETuple - * @instance - */ - ETuple.prototype.ps = $util.emptyArray; - - /** - * ETuple locallyFree. - * @member {Uint8Array} locallyFree - * @memberof ETuple - * @instance - */ - ETuple.prototype.locallyFree = $util.newBuffer([]); - - /** - * ETuple connective_used. - * @member {boolean} connective_used - * @memberof ETuple - * @instance - */ - ETuple.prototype.connective_used = false; - - /** - * Creates a new ETuple instance using the specified properties. - * @function create - * @memberof ETuple - * @static - * @param {IETuple=} [properties] Properties to set - * @returns {ETuple} ETuple instance - */ - ETuple.create = function create(properties) { - return new ETuple(properties); - }; - - /** - * Encodes the specified ETuple message. Does not implicitly {@link ETuple.verify|verify} messages. - * @function encode - * @memberof ETuple - * @static - * @param {IETuple} message ETuple message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ETuple.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.ps != null && message.ps.length) - for (var i = 0; i < message.ps.length; ++i) - $root.Par.encode(message.ps[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.locallyFree); - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - writer.uint32(/* id 4, wireType 0 =*/32).bool(message.connective_used); - return writer; - }; - - /** - * Encodes the specified ETuple message, length delimited. Does not implicitly {@link ETuple.verify|verify} messages. - * @function encodeDelimited - * @memberof ETuple - * @static - * @param {IETuple} message ETuple message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ETuple.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ETuple message from the specified reader or buffer. - * @function decode - * @memberof ETuple - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {ETuple} ETuple - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ETuple.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ETuple(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.ps && message.ps.length)) - message.ps = []; - message.ps.push($root.Par.decode(reader, reader.uint32())); - break; - case 3: - message.locallyFree = reader.bytes(); - break; - case 4: - message.connective_used = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ETuple message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof ETuple - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {ETuple} ETuple - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ETuple.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ETuple message. - * @function verify - * @memberof ETuple - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ETuple.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.ps != null && message.hasOwnProperty("ps")) { - if (!Array.isArray(message.ps)) - return "ps: array expected"; - for (var i = 0; i < message.ps.length; ++i) { - var error = $root.Par.verify(message.ps[i]); - if (error) - return "ps." + error; - } - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - if (!(message.locallyFree && typeof message.locallyFree.length === "number" || $util.isString(message.locallyFree))) - return "locallyFree: buffer expected"; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - if (typeof message.connective_used !== "boolean") - return "connective_used: boolean expected"; - return null; - }; - - /** - * Creates a ETuple message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof ETuple - * @static - * @param {Object.} object Plain object - * @returns {ETuple} ETuple - */ - ETuple.fromObject = function fromObject(object) { - if (object instanceof $root.ETuple) - return object; - var message = new $root.ETuple(); - if (object.ps) { - if (!Array.isArray(object.ps)) - throw TypeError(".ETuple.ps: array expected"); - message.ps = []; - for (var i = 0; i < object.ps.length; ++i) { - if (typeof object.ps[i] !== "object") - throw TypeError(".ETuple.ps: object expected"); - message.ps[i] = $root.Par.fromObject(object.ps[i]); - } - } - if (object.locallyFree != null) - if (typeof object.locallyFree === "string") - $util.base64.decode(object.locallyFree, message.locallyFree = $util.newBuffer($util.base64.length(object.locallyFree)), 0); - else if (object.locallyFree.length) - message.locallyFree = object.locallyFree; - if (object.connective_used != null) - message.connective_used = Boolean(object.connective_used); - return message; - }; - - /** - * Creates a plain object from a ETuple message. Also converts values to other types if specified. - * @function toObject - * @memberof ETuple - * @static - * @param {ETuple} message ETuple - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ETuple.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.ps = []; - if (options.defaults) { - if (options.bytes === String) - object.locallyFree = ""; - else { - object.locallyFree = []; - if (options.bytes !== Array) - object.locallyFree = $util.newBuffer(object.locallyFree); - } - object.connective_used = false; - } - if (message.ps && message.ps.length) { - object.ps = []; - for (var j = 0; j < message.ps.length; ++j) - object.ps[j] = $root.Par.toObject(message.ps[j], options); - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - object.locallyFree = options.bytes === String ? $util.base64.encode(message.locallyFree, 0, message.locallyFree.length) : options.bytes === Array ? Array.prototype.slice.call(message.locallyFree) : message.locallyFree; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - object.connective_used = message.connective_used; - return object; - }; - - /** - * Converts this ETuple to JSON. - * @function toJSON - * @memberof ETuple - * @instance - * @returns {Object.} JSON object - */ - ETuple.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ETuple; -})(); - -$root.ESet = (function() { - - /** - * Properties of a ESet. - * @exports IESet - * @interface IESet - * @property {Array.|null} [ps] ESet ps - * @property {Uint8Array|null} [locallyFree] ESet locallyFree - * @property {boolean|null} [connective_used] ESet connective_used - * @property {IVar|null} [remainder] ESet remainder - */ - - /** - * Constructs a new ESet. - * @exports ESet - * @classdesc Represents a ESet. - * @implements IESet - * @constructor - * @param {IESet=} [properties] Properties to set - */ - function ESet(properties) { - this.ps = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ESet ps. - * @member {Array.} ps - * @memberof ESet - * @instance - */ - ESet.prototype.ps = $util.emptyArray; - - /** - * ESet locallyFree. - * @member {Uint8Array} locallyFree - * @memberof ESet - * @instance - */ - ESet.prototype.locallyFree = $util.newBuffer([]); - - /** - * ESet connective_used. - * @member {boolean} connective_used - * @memberof ESet - * @instance - */ - ESet.prototype.connective_used = false; - - /** - * ESet remainder. - * @member {IVar|null|undefined} remainder - * @memberof ESet - * @instance - */ - ESet.prototype.remainder = null; - - /** - * Creates a new ESet instance using the specified properties. - * @function create - * @memberof ESet - * @static - * @param {IESet=} [properties] Properties to set - * @returns {ESet} ESet instance - */ - ESet.create = function create(properties) { - return new ESet(properties); - }; - - /** - * Encodes the specified ESet message. Does not implicitly {@link ESet.verify|verify} messages. - * @function encode - * @memberof ESet - * @static - * @param {IESet} message ESet message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ESet.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.ps != null && message.ps.length) - for (var i = 0; i < message.ps.length; ++i) - $root.Par.encode(message.ps[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.locallyFree); - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - writer.uint32(/* id 4, wireType 0 =*/32).bool(message.connective_used); - if (message.remainder != null && message.hasOwnProperty("remainder")) - $root.Var.encode(message.remainder, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified ESet message, length delimited. Does not implicitly {@link ESet.verify|verify} messages. - * @function encodeDelimited - * @memberof ESet - * @static - * @param {IESet} message ESet message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ESet.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ESet message from the specified reader or buffer. - * @function decode - * @memberof ESet - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {ESet} ESet - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ESet.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ESet(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.ps && message.ps.length)) - message.ps = []; - message.ps.push($root.Par.decode(reader, reader.uint32())); - break; - case 3: - message.locallyFree = reader.bytes(); - break; - case 4: - message.connective_used = reader.bool(); - break; - case 5: - message.remainder = $root.Var.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ESet message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof ESet - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {ESet} ESet - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ESet.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ESet message. - * @function verify - * @memberof ESet - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ESet.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.ps != null && message.hasOwnProperty("ps")) { - if (!Array.isArray(message.ps)) - return "ps: array expected"; - for (var i = 0; i < message.ps.length; ++i) { - var error = $root.Par.verify(message.ps[i]); - if (error) - return "ps." + error; - } - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - if (!(message.locallyFree && typeof message.locallyFree.length === "number" || $util.isString(message.locallyFree))) - return "locallyFree: buffer expected"; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - if (typeof message.connective_used !== "boolean") - return "connective_used: boolean expected"; - if (message.remainder != null && message.hasOwnProperty("remainder")) { - var error = $root.Var.verify(message.remainder); - if (error) - return "remainder." + error; - } - return null; - }; - - /** - * Creates a ESet message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof ESet - * @static - * @param {Object.} object Plain object - * @returns {ESet} ESet - */ - ESet.fromObject = function fromObject(object) { - if (object instanceof $root.ESet) - return object; - var message = new $root.ESet(); - if (object.ps) { - if (!Array.isArray(object.ps)) - throw TypeError(".ESet.ps: array expected"); - message.ps = []; - for (var i = 0; i < object.ps.length; ++i) { - if (typeof object.ps[i] !== "object") - throw TypeError(".ESet.ps: object expected"); - message.ps[i] = $root.Par.fromObject(object.ps[i]); - } - } - if (object.locallyFree != null) - if (typeof object.locallyFree === "string") - $util.base64.decode(object.locallyFree, message.locallyFree = $util.newBuffer($util.base64.length(object.locallyFree)), 0); - else if (object.locallyFree.length) - message.locallyFree = object.locallyFree; - if (object.connective_used != null) - message.connective_used = Boolean(object.connective_used); - if (object.remainder != null) { - if (typeof object.remainder !== "object") - throw TypeError(".ESet.remainder: object expected"); - message.remainder = $root.Var.fromObject(object.remainder); - } - return message; - }; - - /** - * Creates a plain object from a ESet message. Also converts values to other types if specified. - * @function toObject - * @memberof ESet - * @static - * @param {ESet} message ESet - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ESet.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.ps = []; - if (options.defaults) { - if (options.bytes === String) - object.locallyFree = ""; - else { - object.locallyFree = []; - if (options.bytes !== Array) - object.locallyFree = $util.newBuffer(object.locallyFree); - } - object.connective_used = false; - object.remainder = null; - } - if (message.ps && message.ps.length) { - object.ps = []; - for (var j = 0; j < message.ps.length; ++j) - object.ps[j] = $root.Par.toObject(message.ps[j], options); - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - object.locallyFree = options.bytes === String ? $util.base64.encode(message.locallyFree, 0, message.locallyFree.length) : options.bytes === Array ? Array.prototype.slice.call(message.locallyFree) : message.locallyFree; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - object.connective_used = message.connective_used; - if (message.remainder != null && message.hasOwnProperty("remainder")) - object.remainder = $root.Var.toObject(message.remainder, options); - return object; - }; - - /** - * Converts this ESet to JSON. - * @function toJSON - * @memberof ESet - * @instance - * @returns {Object.} JSON object - */ - ESet.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ESet; -})(); - -$root.EMap = (function() { - - /** - * Properties of a EMap. - * @exports IEMap - * @interface IEMap - * @property {Array.|null} [kvs] EMap kvs - * @property {Uint8Array|null} [locallyFree] EMap locallyFree - * @property {boolean|null} [connective_used] EMap connective_used - * @property {IVar|null} [remainder] EMap remainder - */ - - /** - * Constructs a new EMap. - * @exports EMap - * @classdesc Represents a EMap. - * @implements IEMap - * @constructor - * @param {IEMap=} [properties] Properties to set - */ - function EMap(properties) { - this.kvs = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EMap kvs. - * @member {Array.} kvs - * @memberof EMap - * @instance - */ - EMap.prototype.kvs = $util.emptyArray; - - /** - * EMap locallyFree. - * @member {Uint8Array} locallyFree - * @memberof EMap - * @instance - */ - EMap.prototype.locallyFree = $util.newBuffer([]); - - /** - * EMap connective_used. - * @member {boolean} connective_used - * @memberof EMap - * @instance - */ - EMap.prototype.connective_used = false; - - /** - * EMap remainder. - * @member {IVar|null|undefined} remainder - * @memberof EMap - * @instance - */ - EMap.prototype.remainder = null; - - /** - * Creates a new EMap instance using the specified properties. - * @function create - * @memberof EMap - * @static - * @param {IEMap=} [properties] Properties to set - * @returns {EMap} EMap instance - */ - EMap.create = function create(properties) { - return new EMap(properties); - }; - - /** - * Encodes the specified EMap message. Does not implicitly {@link EMap.verify|verify} messages. - * @function encode - * @memberof EMap - * @static - * @param {IEMap} message EMap message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EMap.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.kvs != null && message.kvs.length) - for (var i = 0; i < message.kvs.length; ++i) - $root.KeyValuePair.encode(message.kvs[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.locallyFree); - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - writer.uint32(/* id 4, wireType 0 =*/32).bool(message.connective_used); - if (message.remainder != null && message.hasOwnProperty("remainder")) - $root.Var.encode(message.remainder, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EMap message, length delimited. Does not implicitly {@link EMap.verify|verify} messages. - * @function encodeDelimited - * @memberof EMap - * @static - * @param {IEMap} message EMap message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EMap.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EMap message from the specified reader or buffer. - * @function decode - * @memberof EMap - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EMap} EMap - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EMap.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EMap(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.kvs && message.kvs.length)) - message.kvs = []; - message.kvs.push($root.KeyValuePair.decode(reader, reader.uint32())); - break; - case 3: - message.locallyFree = reader.bytes(); - break; - case 4: - message.connective_used = reader.bool(); - break; - case 5: - message.remainder = $root.Var.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EMap message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EMap - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EMap} EMap - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EMap.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EMap message. - * @function verify - * @memberof EMap - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EMap.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.kvs != null && message.hasOwnProperty("kvs")) { - if (!Array.isArray(message.kvs)) - return "kvs: array expected"; - for (var i = 0; i < message.kvs.length; ++i) { - var error = $root.KeyValuePair.verify(message.kvs[i]); - if (error) - return "kvs." + error; - } - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - if (!(message.locallyFree && typeof message.locallyFree.length === "number" || $util.isString(message.locallyFree))) - return "locallyFree: buffer expected"; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - if (typeof message.connective_used !== "boolean") - return "connective_used: boolean expected"; - if (message.remainder != null && message.hasOwnProperty("remainder")) { - var error = $root.Var.verify(message.remainder); - if (error) - return "remainder." + error; - } - return null; - }; - - /** - * Creates a EMap message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EMap - * @static - * @param {Object.} object Plain object - * @returns {EMap} EMap - */ - EMap.fromObject = function fromObject(object) { - if (object instanceof $root.EMap) - return object; - var message = new $root.EMap(); - if (object.kvs) { - if (!Array.isArray(object.kvs)) - throw TypeError(".EMap.kvs: array expected"); - message.kvs = []; - for (var i = 0; i < object.kvs.length; ++i) { - if (typeof object.kvs[i] !== "object") - throw TypeError(".EMap.kvs: object expected"); - message.kvs[i] = $root.KeyValuePair.fromObject(object.kvs[i]); - } - } - if (object.locallyFree != null) - if (typeof object.locallyFree === "string") - $util.base64.decode(object.locallyFree, message.locallyFree = $util.newBuffer($util.base64.length(object.locallyFree)), 0); - else if (object.locallyFree.length) - message.locallyFree = object.locallyFree; - if (object.connective_used != null) - message.connective_used = Boolean(object.connective_used); - if (object.remainder != null) { - if (typeof object.remainder !== "object") - throw TypeError(".EMap.remainder: object expected"); - message.remainder = $root.Var.fromObject(object.remainder); - } - return message; - }; - - /** - * Creates a plain object from a EMap message. Also converts values to other types if specified. - * @function toObject - * @memberof EMap - * @static - * @param {EMap} message EMap - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EMap.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.kvs = []; - if (options.defaults) { - if (options.bytes === String) - object.locallyFree = ""; - else { - object.locallyFree = []; - if (options.bytes !== Array) - object.locallyFree = $util.newBuffer(object.locallyFree); - } - object.connective_used = false; - object.remainder = null; - } - if (message.kvs && message.kvs.length) { - object.kvs = []; - for (var j = 0; j < message.kvs.length; ++j) - object.kvs[j] = $root.KeyValuePair.toObject(message.kvs[j], options); - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - object.locallyFree = options.bytes === String ? $util.base64.encode(message.locallyFree, 0, message.locallyFree.length) : options.bytes === Array ? Array.prototype.slice.call(message.locallyFree) : message.locallyFree; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - object.connective_used = message.connective_used; - if (message.remainder != null && message.hasOwnProperty("remainder")) - object.remainder = $root.Var.toObject(message.remainder, options); - return object; - }; - - /** - * Converts this EMap to JSON. - * @function toJSON - * @memberof EMap - * @instance - * @returns {Object.} JSON object - */ - EMap.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EMap; -})(); - -$root.EMethod = (function() { - - /** - * Properties of a EMethod. - * @exports IEMethod - * @interface IEMethod - * @property {string|null} [methodName] EMethod methodName - * @property {IPar|null} [target] EMethod target - * @property {Array.|null} ["arguments"] EMethod arguments - * @property {Uint8Array|null} [locallyFree] EMethod locallyFree - * @property {boolean|null} [connective_used] EMethod connective_used - */ - - /** - * Constructs a new EMethod. - * @exports EMethod - * @classdesc `target.method(arguments)` - * @implements IEMethod - * @constructor - * @param {IEMethod=} [properties] Properties to set - */ - function EMethod(properties) { - this["arguments"] = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EMethod methodName. - * @member {string} methodName - * @memberof EMethod - * @instance - */ - EMethod.prototype.methodName = ""; - - /** - * EMethod target. - * @member {IPar|null|undefined} target - * @memberof EMethod - * @instance - */ - EMethod.prototype.target = null; - - /** - * EMethod arguments. - * @member {Array.} arguments - * @memberof EMethod - * @instance - */ - EMethod.prototype["arguments"] = $util.emptyArray; - - /** - * EMethod locallyFree. - * @member {Uint8Array} locallyFree - * @memberof EMethod - * @instance - */ - EMethod.prototype.locallyFree = $util.newBuffer([]); - - /** - * EMethod connective_used. - * @member {boolean} connective_used - * @memberof EMethod - * @instance - */ - EMethod.prototype.connective_used = false; - - /** - * Creates a new EMethod instance using the specified properties. - * @function create - * @memberof EMethod - * @static - * @param {IEMethod=} [properties] Properties to set - * @returns {EMethod} EMethod instance - */ - EMethod.create = function create(properties) { - return new EMethod(properties); - }; - - /** - * Encodes the specified EMethod message. Does not implicitly {@link EMethod.verify|verify} messages. - * @function encode - * @memberof EMethod - * @static - * @param {IEMethod} message EMethod message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EMethod.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.methodName != null && message.hasOwnProperty("methodName")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.methodName); - if (message.target != null && message.hasOwnProperty("target")) - $root.Par.encode(message.target, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message["arguments"] != null && message["arguments"].length) - for (var i = 0; i < message["arguments"].length; ++i) - $root.Par.encode(message["arguments"][i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.locallyFree); - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - writer.uint32(/* id 6, wireType 0 =*/48).bool(message.connective_used); - return writer; - }; - - /** - * Encodes the specified EMethod message, length delimited. Does not implicitly {@link EMethod.verify|verify} messages. - * @function encodeDelimited - * @memberof EMethod - * @static - * @param {IEMethod} message EMethod message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EMethod.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EMethod message from the specified reader or buffer. - * @function decode - * @memberof EMethod - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EMethod} EMethod - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EMethod.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EMethod(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.methodName = reader.string(); - break; - case 2: - message.target = $root.Par.decode(reader, reader.uint32()); - break; - case 3: - if (!(message["arguments"] && message["arguments"].length)) - message["arguments"] = []; - message["arguments"].push($root.Par.decode(reader, reader.uint32())); - break; - case 5: - message.locallyFree = reader.bytes(); - break; - case 6: - message.connective_used = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EMethod message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EMethod - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EMethod} EMethod - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EMethod.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EMethod message. - * @function verify - * @memberof EMethod - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EMethod.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.methodName != null && message.hasOwnProperty("methodName")) - if (!$util.isString(message.methodName)) - return "methodName: string expected"; - if (message.target != null && message.hasOwnProperty("target")) { - var error = $root.Par.verify(message.target); - if (error) - return "target." + error; - } - if (message["arguments"] != null && message.hasOwnProperty("arguments")) { - if (!Array.isArray(message["arguments"])) - return "arguments: array expected"; - for (var i = 0; i < message["arguments"].length; ++i) { - var error = $root.Par.verify(message["arguments"][i]); - if (error) - return "arguments." + error; - } - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - if (!(message.locallyFree && typeof message.locallyFree.length === "number" || $util.isString(message.locallyFree))) - return "locallyFree: buffer expected"; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - if (typeof message.connective_used !== "boolean") - return "connective_used: boolean expected"; - return null; - }; - - /** - * Creates a EMethod message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EMethod - * @static - * @param {Object.} object Plain object - * @returns {EMethod} EMethod - */ - EMethod.fromObject = function fromObject(object) { - if (object instanceof $root.EMethod) - return object; - var message = new $root.EMethod(); - if (object.methodName != null) - message.methodName = String(object.methodName); - if (object.target != null) { - if (typeof object.target !== "object") - throw TypeError(".EMethod.target: object expected"); - message.target = $root.Par.fromObject(object.target); - } - if (object["arguments"]) { - if (!Array.isArray(object["arguments"])) - throw TypeError(".EMethod.arguments: array expected"); - message["arguments"] = []; - for (var i = 0; i < object["arguments"].length; ++i) { - if (typeof object["arguments"][i] !== "object") - throw TypeError(".EMethod.arguments: object expected"); - message["arguments"][i] = $root.Par.fromObject(object["arguments"][i]); - } - } - if (object.locallyFree != null) - if (typeof object.locallyFree === "string") - $util.base64.decode(object.locallyFree, message.locallyFree = $util.newBuffer($util.base64.length(object.locallyFree)), 0); - else if (object.locallyFree.length) - message.locallyFree = object.locallyFree; - if (object.connective_used != null) - message.connective_used = Boolean(object.connective_used); - return message; - }; - - /** - * Creates a plain object from a EMethod message. Also converts values to other types if specified. - * @function toObject - * @memberof EMethod - * @static - * @param {EMethod} message EMethod - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EMethod.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object["arguments"] = []; - if (options.defaults) { - object.methodName = ""; - object.target = null; - if (options.bytes === String) - object.locallyFree = ""; - else { - object.locallyFree = []; - if (options.bytes !== Array) - object.locallyFree = $util.newBuffer(object.locallyFree); - } - object.connective_used = false; - } - if (message.methodName != null && message.hasOwnProperty("methodName")) - object.methodName = message.methodName; - if (message.target != null && message.hasOwnProperty("target")) - object.target = $root.Par.toObject(message.target, options); - if (message["arguments"] && message["arguments"].length) { - object["arguments"] = []; - for (var j = 0; j < message["arguments"].length; ++j) - object["arguments"][j] = $root.Par.toObject(message["arguments"][j], options); - } - if (message.locallyFree != null && message.hasOwnProperty("locallyFree")) - object.locallyFree = options.bytes === String ? $util.base64.encode(message.locallyFree, 0, message.locallyFree.length) : options.bytes === Array ? Array.prototype.slice.call(message.locallyFree) : message.locallyFree; - if (message.connective_used != null && message.hasOwnProperty("connective_used")) - object.connective_used = message.connective_used; - return object; - }; - - /** - * Converts this EMethod to JSON. - * @function toJSON - * @memberof EMethod - * @instance - * @returns {Object.} JSON object - */ - EMethod.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EMethod; -})(); - -$root.KeyValuePair = (function() { - - /** - * Properties of a KeyValuePair. - * @exports IKeyValuePair - * @interface IKeyValuePair - * @property {IPar|null} [key] KeyValuePair key - * @property {IPar|null} [value] KeyValuePair value - */ - - /** - * Constructs a new KeyValuePair. - * @exports KeyValuePair - * @classdesc Represents a KeyValuePair. - * @implements IKeyValuePair - * @constructor - * @param {IKeyValuePair=} [properties] Properties to set - */ - function KeyValuePair(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * KeyValuePair key. - * @member {IPar|null|undefined} key - * @memberof KeyValuePair - * @instance - */ - KeyValuePair.prototype.key = null; - - /** - * KeyValuePair value. - * @member {IPar|null|undefined} value - * @memberof KeyValuePair - * @instance - */ - KeyValuePair.prototype.value = null; - - /** - * Creates a new KeyValuePair instance using the specified properties. - * @function create - * @memberof KeyValuePair - * @static - * @param {IKeyValuePair=} [properties] Properties to set - * @returns {KeyValuePair} KeyValuePair instance - */ - KeyValuePair.create = function create(properties) { - return new KeyValuePair(properties); - }; - - /** - * Encodes the specified KeyValuePair message. Does not implicitly {@link KeyValuePair.verify|verify} messages. - * @function encode - * @memberof KeyValuePair - * @static - * @param {IKeyValuePair} message KeyValuePair message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - KeyValuePair.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.key != null && message.hasOwnProperty("key")) - $root.Par.encode(message.key, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.value != null && message.hasOwnProperty("value")) - $root.Par.encode(message.value, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified KeyValuePair message, length delimited. Does not implicitly {@link KeyValuePair.verify|verify} messages. - * @function encodeDelimited - * @memberof KeyValuePair - * @static - * @param {IKeyValuePair} message KeyValuePair message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - KeyValuePair.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a KeyValuePair message from the specified reader or buffer. - * @function decode - * @memberof KeyValuePair - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {KeyValuePair} KeyValuePair - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - KeyValuePair.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.KeyValuePair(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.key = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.value = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a KeyValuePair message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof KeyValuePair - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {KeyValuePair} KeyValuePair - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - KeyValuePair.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a KeyValuePair message. - * @function verify - * @memberof KeyValuePair - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - KeyValuePair.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.key != null && message.hasOwnProperty("key")) { - var error = $root.Par.verify(message.key); - if (error) - return "key." + error; - } - if (message.value != null && message.hasOwnProperty("value")) { - var error = $root.Par.verify(message.value); - if (error) - return "value." + error; - } - return null; - }; - - /** - * Creates a KeyValuePair message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof KeyValuePair - * @static - * @param {Object.} object Plain object - * @returns {KeyValuePair} KeyValuePair - */ - KeyValuePair.fromObject = function fromObject(object) { - if (object instanceof $root.KeyValuePair) - return object; - var message = new $root.KeyValuePair(); - if (object.key != null) { - if (typeof object.key !== "object") - throw TypeError(".KeyValuePair.key: object expected"); - message.key = $root.Par.fromObject(object.key); - } - if (object.value != null) { - if (typeof object.value !== "object") - throw TypeError(".KeyValuePair.value: object expected"); - message.value = $root.Par.fromObject(object.value); - } - return message; - }; - - /** - * Creates a plain object from a KeyValuePair message. Also converts values to other types if specified. - * @function toObject - * @memberof KeyValuePair - * @static - * @param {KeyValuePair} message KeyValuePair - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - KeyValuePair.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.key = null; - object.value = null; - } - if (message.key != null && message.hasOwnProperty("key")) - object.key = $root.Par.toObject(message.key, options); - if (message.value != null && message.hasOwnProperty("value")) - object.value = $root.Par.toObject(message.value, options); - return object; - }; - - /** - * Converts this KeyValuePair to JSON. - * @function toJSON - * @memberof KeyValuePair - * @instance - * @returns {Object.} JSON object - */ - KeyValuePair.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return KeyValuePair; -})(); - -$root.EVar = (function() { - - /** - * Properties of a EVar. - * @exports IEVar - * @interface IEVar - * @property {IVar|null} [v] EVar v - */ - - /** - * Constructs a new EVar. - * @exports EVar - * @classdesc Represents a EVar. - * @implements IEVar - * @constructor - * @param {IEVar=} [properties] Properties to set - */ - function EVar(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EVar v. - * @member {IVar|null|undefined} v - * @memberof EVar - * @instance - */ - EVar.prototype.v = null; - - /** - * Creates a new EVar instance using the specified properties. - * @function create - * @memberof EVar - * @static - * @param {IEVar=} [properties] Properties to set - * @returns {EVar} EVar instance - */ - EVar.create = function create(properties) { - return new EVar(properties); - }; - - /** - * Encodes the specified EVar message. Does not implicitly {@link EVar.verify|verify} messages. - * @function encode - * @memberof EVar - * @static - * @param {IEVar} message EVar message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EVar.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.v != null && message.hasOwnProperty("v")) - $root.Var.encode(message.v, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EVar message, length delimited. Does not implicitly {@link EVar.verify|verify} messages. - * @function encodeDelimited - * @memberof EVar - * @static - * @param {IEVar} message EVar message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EVar.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EVar message from the specified reader or buffer. - * @function decode - * @memberof EVar - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EVar} EVar - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EVar.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EVar(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.v = $root.Var.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EVar message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EVar - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EVar} EVar - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EVar.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EVar message. - * @function verify - * @memberof EVar - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EVar.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.v != null && message.hasOwnProperty("v")) { - var error = $root.Var.verify(message.v); - if (error) - return "v." + error; - } - return null; - }; - - /** - * Creates a EVar message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EVar - * @static - * @param {Object.} object Plain object - * @returns {EVar} EVar - */ - EVar.fromObject = function fromObject(object) { - if (object instanceof $root.EVar) - return object; - var message = new $root.EVar(); - if (object.v != null) { - if (typeof object.v !== "object") - throw TypeError(".EVar.v: object expected"); - message.v = $root.Var.fromObject(object.v); - } - return message; - }; - - /** - * Creates a plain object from a EVar message. Also converts values to other types if specified. - * @function toObject - * @memberof EVar - * @static - * @param {EVar} message EVar - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EVar.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.v = null; - if (message.v != null && message.hasOwnProperty("v")) - object.v = $root.Var.toObject(message.v, options); - return object; - }; - - /** - * Converts this EVar to JSON. - * @function toJSON - * @memberof EVar - * @instance - * @returns {Object.} JSON object - */ - EVar.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EVar; -})(); - -$root.ENot = (function() { - - /** - * Properties of a ENot. - * @exports IENot - * @interface IENot - * @property {IPar|null} [p] ENot p - */ - - /** - * Constructs a new ENot. - * @exports ENot - * @classdesc Represents a ENot. - * @implements IENot - * @constructor - * @param {IENot=} [properties] Properties to set - */ - function ENot(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ENot p. - * @member {IPar|null|undefined} p - * @memberof ENot - * @instance - */ - ENot.prototype.p = null; - - /** - * Creates a new ENot instance using the specified properties. - * @function create - * @memberof ENot - * @static - * @param {IENot=} [properties] Properties to set - * @returns {ENot} ENot instance - */ - ENot.create = function create(properties) { - return new ENot(properties); - }; - - /** - * Encodes the specified ENot message. Does not implicitly {@link ENot.verify|verify} messages. - * @function encode - * @memberof ENot - * @static - * @param {IENot} message ENot message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ENot.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p != null && message.hasOwnProperty("p")) - $root.Par.encode(message.p, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified ENot message, length delimited. Does not implicitly {@link ENot.verify|verify} messages. - * @function encodeDelimited - * @memberof ENot - * @static - * @param {IENot} message ENot message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ENot.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ENot message from the specified reader or buffer. - * @function decode - * @memberof ENot - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {ENot} ENot - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ENot.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ENot(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ENot message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof ENot - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {ENot} ENot - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ENot.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ENot message. - * @function verify - * @memberof ENot - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ENot.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p != null && message.hasOwnProperty("p")) { - var error = $root.Par.verify(message.p); - if (error) - return "p." + error; - } - return null; - }; - - /** - * Creates a ENot message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof ENot - * @static - * @param {Object.} object Plain object - * @returns {ENot} ENot - */ - ENot.fromObject = function fromObject(object) { - if (object instanceof $root.ENot) - return object; - var message = new $root.ENot(); - if (object.p != null) { - if (typeof object.p !== "object") - throw TypeError(".ENot.p: object expected"); - message.p = $root.Par.fromObject(object.p); - } - return message; - }; - - /** - * Creates a plain object from a ENot message. Also converts values to other types if specified. - * @function toObject - * @memberof ENot - * @static - * @param {ENot} message ENot - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ENot.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.p = null; - if (message.p != null && message.hasOwnProperty("p")) - object.p = $root.Par.toObject(message.p, options); - return object; - }; - - /** - * Converts this ENot to JSON. - * @function toJSON - * @memberof ENot - * @instance - * @returns {Object.} JSON object - */ - ENot.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ENot; -})(); - -$root.ENeg = (function() { - - /** - * Properties of a ENeg. - * @exports IENeg - * @interface IENeg - * @property {IPar|null} [p] ENeg p - */ - - /** - * Constructs a new ENeg. - * @exports ENeg - * @classdesc Represents a ENeg. - * @implements IENeg - * @constructor - * @param {IENeg=} [properties] Properties to set - */ - function ENeg(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ENeg p. - * @member {IPar|null|undefined} p - * @memberof ENeg - * @instance - */ - ENeg.prototype.p = null; - - /** - * Creates a new ENeg instance using the specified properties. - * @function create - * @memberof ENeg - * @static - * @param {IENeg=} [properties] Properties to set - * @returns {ENeg} ENeg instance - */ - ENeg.create = function create(properties) { - return new ENeg(properties); - }; - - /** - * Encodes the specified ENeg message. Does not implicitly {@link ENeg.verify|verify} messages. - * @function encode - * @memberof ENeg - * @static - * @param {IENeg} message ENeg message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ENeg.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p != null && message.hasOwnProperty("p")) - $root.Par.encode(message.p, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified ENeg message, length delimited. Does not implicitly {@link ENeg.verify|verify} messages. - * @function encodeDelimited - * @memberof ENeg - * @static - * @param {IENeg} message ENeg message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ENeg.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ENeg message from the specified reader or buffer. - * @function decode - * @memberof ENeg - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {ENeg} ENeg - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ENeg.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ENeg(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ENeg message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof ENeg - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {ENeg} ENeg - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ENeg.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ENeg message. - * @function verify - * @memberof ENeg - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ENeg.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p != null && message.hasOwnProperty("p")) { - var error = $root.Par.verify(message.p); - if (error) - return "p." + error; - } - return null; - }; - - /** - * Creates a ENeg message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof ENeg - * @static - * @param {Object.} object Plain object - * @returns {ENeg} ENeg - */ - ENeg.fromObject = function fromObject(object) { - if (object instanceof $root.ENeg) - return object; - var message = new $root.ENeg(); - if (object.p != null) { - if (typeof object.p !== "object") - throw TypeError(".ENeg.p: object expected"); - message.p = $root.Par.fromObject(object.p); - } - return message; - }; - - /** - * Creates a plain object from a ENeg message. Also converts values to other types if specified. - * @function toObject - * @memberof ENeg - * @static - * @param {ENeg} message ENeg - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ENeg.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.p = null; - if (message.p != null && message.hasOwnProperty("p")) - object.p = $root.Par.toObject(message.p, options); - return object; - }; - - /** - * Converts this ENeg to JSON. - * @function toJSON - * @memberof ENeg - * @instance - * @returns {Object.} JSON object - */ - ENeg.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ENeg; -})(); - -$root.EMult = (function() { - - /** - * Properties of a EMult. - * @exports IEMult - * @interface IEMult - * @property {IPar|null} [p1] EMult p1 - * @property {IPar|null} [p2] EMult p2 - */ - - /** - * Constructs a new EMult. - * @exports EMult - * @classdesc Represents a EMult. - * @implements IEMult - * @constructor - * @param {IEMult=} [properties] Properties to set - */ - function EMult(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EMult p1. - * @member {IPar|null|undefined} p1 - * @memberof EMult - * @instance - */ - EMult.prototype.p1 = null; - - /** - * EMult p2. - * @member {IPar|null|undefined} p2 - * @memberof EMult - * @instance - */ - EMult.prototype.p2 = null; - - /** - * Creates a new EMult instance using the specified properties. - * @function create - * @memberof EMult - * @static - * @param {IEMult=} [properties] Properties to set - * @returns {EMult} EMult instance - */ - EMult.create = function create(properties) { - return new EMult(properties); - }; - - /** - * Encodes the specified EMult message. Does not implicitly {@link EMult.verify|verify} messages. - * @function encode - * @memberof EMult - * @static - * @param {IEMult} message EMult message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EMult.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EMult message, length delimited. Does not implicitly {@link EMult.verify|verify} messages. - * @function encodeDelimited - * @memberof EMult - * @static - * @param {IEMult} message EMult message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EMult.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EMult message from the specified reader or buffer. - * @function decode - * @memberof EMult - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EMult} EMult - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EMult.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EMult(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EMult message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EMult - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EMult} EMult - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EMult.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EMult message. - * @function verify - * @memberof EMult - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EMult.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a EMult message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EMult - * @static - * @param {Object.} object Plain object - * @returns {EMult} EMult - */ - EMult.fromObject = function fromObject(object) { - if (object instanceof $root.EMult) - return object; - var message = new $root.EMult(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".EMult.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".EMult.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a EMult message. Also converts values to other types if specified. - * @function toObject - * @memberof EMult - * @static - * @param {EMult} message EMult - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EMult.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this EMult to JSON. - * @function toJSON - * @memberof EMult - * @instance - * @returns {Object.} JSON object - */ - EMult.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EMult; -})(); - -$root.EDiv = (function() { - - /** - * Properties of a EDiv. - * @exports IEDiv - * @interface IEDiv - * @property {IPar|null} [p1] EDiv p1 - * @property {IPar|null} [p2] EDiv p2 - */ - - /** - * Constructs a new EDiv. - * @exports EDiv - * @classdesc Represents a EDiv. - * @implements IEDiv - * @constructor - * @param {IEDiv=} [properties] Properties to set - */ - function EDiv(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EDiv p1. - * @member {IPar|null|undefined} p1 - * @memberof EDiv - * @instance - */ - EDiv.prototype.p1 = null; - - /** - * EDiv p2. - * @member {IPar|null|undefined} p2 - * @memberof EDiv - * @instance - */ - EDiv.prototype.p2 = null; - - /** - * Creates a new EDiv instance using the specified properties. - * @function create - * @memberof EDiv - * @static - * @param {IEDiv=} [properties] Properties to set - * @returns {EDiv} EDiv instance - */ - EDiv.create = function create(properties) { - return new EDiv(properties); - }; - - /** - * Encodes the specified EDiv message. Does not implicitly {@link EDiv.verify|verify} messages. - * @function encode - * @memberof EDiv - * @static - * @param {IEDiv} message EDiv message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EDiv.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EDiv message, length delimited. Does not implicitly {@link EDiv.verify|verify} messages. - * @function encodeDelimited - * @memberof EDiv - * @static - * @param {IEDiv} message EDiv message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EDiv.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EDiv message from the specified reader or buffer. - * @function decode - * @memberof EDiv - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EDiv} EDiv - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EDiv.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EDiv(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EDiv message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EDiv - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EDiv} EDiv - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EDiv.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EDiv message. - * @function verify - * @memberof EDiv - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EDiv.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a EDiv message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EDiv - * @static - * @param {Object.} object Plain object - * @returns {EDiv} EDiv - */ - EDiv.fromObject = function fromObject(object) { - if (object instanceof $root.EDiv) - return object; - var message = new $root.EDiv(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".EDiv.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".EDiv.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a EDiv message. Also converts values to other types if specified. - * @function toObject - * @memberof EDiv - * @static - * @param {EDiv} message EDiv - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EDiv.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this EDiv to JSON. - * @function toJSON - * @memberof EDiv - * @instance - * @returns {Object.} JSON object - */ - EDiv.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EDiv; -})(); - -$root.EPlus = (function() { - - /** - * Properties of a EPlus. - * @exports IEPlus - * @interface IEPlus - * @property {IPar|null} [p1] EPlus p1 - * @property {IPar|null} [p2] EPlus p2 - */ - - /** - * Constructs a new EPlus. - * @exports EPlus - * @classdesc Represents a EPlus. - * @implements IEPlus - * @constructor - * @param {IEPlus=} [properties] Properties to set - */ - function EPlus(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EPlus p1. - * @member {IPar|null|undefined} p1 - * @memberof EPlus - * @instance - */ - EPlus.prototype.p1 = null; - - /** - * EPlus p2. - * @member {IPar|null|undefined} p2 - * @memberof EPlus - * @instance - */ - EPlus.prototype.p2 = null; - - /** - * Creates a new EPlus instance using the specified properties. - * @function create - * @memberof EPlus - * @static - * @param {IEPlus=} [properties] Properties to set - * @returns {EPlus} EPlus instance - */ - EPlus.create = function create(properties) { - return new EPlus(properties); - }; - - /** - * Encodes the specified EPlus message. Does not implicitly {@link EPlus.verify|verify} messages. - * @function encode - * @memberof EPlus - * @static - * @param {IEPlus} message EPlus message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EPlus.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EPlus message, length delimited. Does not implicitly {@link EPlus.verify|verify} messages. - * @function encodeDelimited - * @memberof EPlus - * @static - * @param {IEPlus} message EPlus message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EPlus.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EPlus message from the specified reader or buffer. - * @function decode - * @memberof EPlus - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EPlus} EPlus - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EPlus.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EPlus(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EPlus message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EPlus - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EPlus} EPlus - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EPlus.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EPlus message. - * @function verify - * @memberof EPlus - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EPlus.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a EPlus message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EPlus - * @static - * @param {Object.} object Plain object - * @returns {EPlus} EPlus - */ - EPlus.fromObject = function fromObject(object) { - if (object instanceof $root.EPlus) - return object; - var message = new $root.EPlus(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".EPlus.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".EPlus.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a EPlus message. Also converts values to other types if specified. - * @function toObject - * @memberof EPlus - * @static - * @param {EPlus} message EPlus - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EPlus.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this EPlus to JSON. - * @function toJSON - * @memberof EPlus - * @instance - * @returns {Object.} JSON object - */ - EPlus.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EPlus; -})(); - -$root.EMinus = (function() { - - /** - * Properties of a EMinus. - * @exports IEMinus - * @interface IEMinus - * @property {IPar|null} [p1] EMinus p1 - * @property {IPar|null} [p2] EMinus p2 - */ - - /** - * Constructs a new EMinus. - * @exports EMinus - * @classdesc Represents a EMinus. - * @implements IEMinus - * @constructor - * @param {IEMinus=} [properties] Properties to set - */ - function EMinus(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EMinus p1. - * @member {IPar|null|undefined} p1 - * @memberof EMinus - * @instance - */ - EMinus.prototype.p1 = null; - - /** - * EMinus p2. - * @member {IPar|null|undefined} p2 - * @memberof EMinus - * @instance - */ - EMinus.prototype.p2 = null; - - /** - * Creates a new EMinus instance using the specified properties. - * @function create - * @memberof EMinus - * @static - * @param {IEMinus=} [properties] Properties to set - * @returns {EMinus} EMinus instance - */ - EMinus.create = function create(properties) { - return new EMinus(properties); - }; - - /** - * Encodes the specified EMinus message. Does not implicitly {@link EMinus.verify|verify} messages. - * @function encode - * @memberof EMinus - * @static - * @param {IEMinus} message EMinus message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EMinus.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EMinus message, length delimited. Does not implicitly {@link EMinus.verify|verify} messages. - * @function encodeDelimited - * @memberof EMinus - * @static - * @param {IEMinus} message EMinus message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EMinus.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EMinus message from the specified reader or buffer. - * @function decode - * @memberof EMinus - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EMinus} EMinus - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EMinus.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EMinus(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EMinus message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EMinus - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EMinus} EMinus - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EMinus.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EMinus message. - * @function verify - * @memberof EMinus - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EMinus.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a EMinus message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EMinus - * @static - * @param {Object.} object Plain object - * @returns {EMinus} EMinus - */ - EMinus.fromObject = function fromObject(object) { - if (object instanceof $root.EMinus) - return object; - var message = new $root.EMinus(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".EMinus.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".EMinus.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a EMinus message. Also converts values to other types if specified. - * @function toObject - * @memberof EMinus - * @static - * @param {EMinus} message EMinus - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EMinus.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this EMinus to JSON. - * @function toJSON - * @memberof EMinus - * @instance - * @returns {Object.} JSON object - */ - EMinus.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EMinus; -})(); - -$root.ELt = (function() { - - /** - * Properties of a ELt. - * @exports IELt - * @interface IELt - * @property {IPar|null} [p1] ELt p1 - * @property {IPar|null} [p2] ELt p2 - */ - - /** - * Constructs a new ELt. - * @exports ELt - * @classdesc Represents a ELt. - * @implements IELt - * @constructor - * @param {IELt=} [properties] Properties to set - */ - function ELt(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ELt p1. - * @member {IPar|null|undefined} p1 - * @memberof ELt - * @instance - */ - ELt.prototype.p1 = null; - - /** - * ELt p2. - * @member {IPar|null|undefined} p2 - * @memberof ELt - * @instance - */ - ELt.prototype.p2 = null; - - /** - * Creates a new ELt instance using the specified properties. - * @function create - * @memberof ELt - * @static - * @param {IELt=} [properties] Properties to set - * @returns {ELt} ELt instance - */ - ELt.create = function create(properties) { - return new ELt(properties); - }; - - /** - * Encodes the specified ELt message. Does not implicitly {@link ELt.verify|verify} messages. - * @function encode - * @memberof ELt - * @static - * @param {IELt} message ELt message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ELt.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified ELt message, length delimited. Does not implicitly {@link ELt.verify|verify} messages. - * @function encodeDelimited - * @memberof ELt - * @static - * @param {IELt} message ELt message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ELt.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ELt message from the specified reader or buffer. - * @function decode - * @memberof ELt - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {ELt} ELt - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ELt.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ELt(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ELt message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof ELt - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {ELt} ELt - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ELt.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ELt message. - * @function verify - * @memberof ELt - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ELt.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a ELt message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof ELt - * @static - * @param {Object.} object Plain object - * @returns {ELt} ELt - */ - ELt.fromObject = function fromObject(object) { - if (object instanceof $root.ELt) - return object; - var message = new $root.ELt(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".ELt.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".ELt.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a ELt message. Also converts values to other types if specified. - * @function toObject - * @memberof ELt - * @static - * @param {ELt} message ELt - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ELt.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this ELt to JSON. - * @function toJSON - * @memberof ELt - * @instance - * @returns {Object.} JSON object - */ - ELt.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ELt; -})(); - -$root.ELte = (function() { - - /** - * Properties of a ELte. - * @exports IELte - * @interface IELte - * @property {IPar|null} [p1] ELte p1 - * @property {IPar|null} [p2] ELte p2 - */ - - /** - * Constructs a new ELte. - * @exports ELte - * @classdesc Represents a ELte. - * @implements IELte - * @constructor - * @param {IELte=} [properties] Properties to set - */ - function ELte(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ELte p1. - * @member {IPar|null|undefined} p1 - * @memberof ELte - * @instance - */ - ELte.prototype.p1 = null; - - /** - * ELte p2. - * @member {IPar|null|undefined} p2 - * @memberof ELte - * @instance - */ - ELte.prototype.p2 = null; - - /** - * Creates a new ELte instance using the specified properties. - * @function create - * @memberof ELte - * @static - * @param {IELte=} [properties] Properties to set - * @returns {ELte} ELte instance - */ - ELte.create = function create(properties) { - return new ELte(properties); - }; - - /** - * Encodes the specified ELte message. Does not implicitly {@link ELte.verify|verify} messages. - * @function encode - * @memberof ELte - * @static - * @param {IELte} message ELte message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ELte.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified ELte message, length delimited. Does not implicitly {@link ELte.verify|verify} messages. - * @function encodeDelimited - * @memberof ELte - * @static - * @param {IELte} message ELte message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ELte.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ELte message from the specified reader or buffer. - * @function decode - * @memberof ELte - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {ELte} ELte - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ELte.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ELte(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ELte message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof ELte - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {ELte} ELte - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ELte.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ELte message. - * @function verify - * @memberof ELte - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ELte.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a ELte message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof ELte - * @static - * @param {Object.} object Plain object - * @returns {ELte} ELte - */ - ELte.fromObject = function fromObject(object) { - if (object instanceof $root.ELte) - return object; - var message = new $root.ELte(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".ELte.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".ELte.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a ELte message. Also converts values to other types if specified. - * @function toObject - * @memberof ELte - * @static - * @param {ELte} message ELte - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ELte.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this ELte to JSON. - * @function toJSON - * @memberof ELte - * @instance - * @returns {Object.} JSON object - */ - ELte.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ELte; -})(); - -$root.EGt = (function() { - - /** - * Properties of a EGt. - * @exports IEGt - * @interface IEGt - * @property {IPar|null} [p1] EGt p1 - * @property {IPar|null} [p2] EGt p2 - */ - - /** - * Constructs a new EGt. - * @exports EGt - * @classdesc Represents a EGt. - * @implements IEGt - * @constructor - * @param {IEGt=} [properties] Properties to set - */ - function EGt(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EGt p1. - * @member {IPar|null|undefined} p1 - * @memberof EGt - * @instance - */ - EGt.prototype.p1 = null; - - /** - * EGt p2. - * @member {IPar|null|undefined} p2 - * @memberof EGt - * @instance - */ - EGt.prototype.p2 = null; - - /** - * Creates a new EGt instance using the specified properties. - * @function create - * @memberof EGt - * @static - * @param {IEGt=} [properties] Properties to set - * @returns {EGt} EGt instance - */ - EGt.create = function create(properties) { - return new EGt(properties); - }; - - /** - * Encodes the specified EGt message. Does not implicitly {@link EGt.verify|verify} messages. - * @function encode - * @memberof EGt - * @static - * @param {IEGt} message EGt message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EGt.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EGt message, length delimited. Does not implicitly {@link EGt.verify|verify} messages. - * @function encodeDelimited - * @memberof EGt - * @static - * @param {IEGt} message EGt message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EGt.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EGt message from the specified reader or buffer. - * @function decode - * @memberof EGt - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EGt} EGt - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EGt.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EGt(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EGt message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EGt - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EGt} EGt - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EGt.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EGt message. - * @function verify - * @memberof EGt - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EGt.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a EGt message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EGt - * @static - * @param {Object.} object Plain object - * @returns {EGt} EGt - */ - EGt.fromObject = function fromObject(object) { - if (object instanceof $root.EGt) - return object; - var message = new $root.EGt(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".EGt.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".EGt.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a EGt message. Also converts values to other types if specified. - * @function toObject - * @memberof EGt - * @static - * @param {EGt} message EGt - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EGt.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this EGt to JSON. - * @function toJSON - * @memberof EGt - * @instance - * @returns {Object.} JSON object - */ - EGt.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EGt; -})(); - -$root.EGte = (function() { - - /** - * Properties of a EGte. - * @exports IEGte - * @interface IEGte - * @property {IPar|null} [p1] EGte p1 - * @property {IPar|null} [p2] EGte p2 - */ - - /** - * Constructs a new EGte. - * @exports EGte - * @classdesc Represents a EGte. - * @implements IEGte - * @constructor - * @param {IEGte=} [properties] Properties to set - */ - function EGte(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EGte p1. - * @member {IPar|null|undefined} p1 - * @memberof EGte - * @instance - */ - EGte.prototype.p1 = null; - - /** - * EGte p2. - * @member {IPar|null|undefined} p2 - * @memberof EGte - * @instance - */ - EGte.prototype.p2 = null; - - /** - * Creates a new EGte instance using the specified properties. - * @function create - * @memberof EGte - * @static - * @param {IEGte=} [properties] Properties to set - * @returns {EGte} EGte instance - */ - EGte.create = function create(properties) { - return new EGte(properties); - }; - - /** - * Encodes the specified EGte message. Does not implicitly {@link EGte.verify|verify} messages. - * @function encode - * @memberof EGte - * @static - * @param {IEGte} message EGte message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EGte.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EGte message, length delimited. Does not implicitly {@link EGte.verify|verify} messages. - * @function encodeDelimited - * @memberof EGte - * @static - * @param {IEGte} message EGte message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EGte.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EGte message from the specified reader or buffer. - * @function decode - * @memberof EGte - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EGte} EGte - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EGte.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EGte(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EGte message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EGte - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EGte} EGte - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EGte.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EGte message. - * @function verify - * @memberof EGte - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EGte.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a EGte message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EGte - * @static - * @param {Object.} object Plain object - * @returns {EGte} EGte - */ - EGte.fromObject = function fromObject(object) { - if (object instanceof $root.EGte) - return object; - var message = new $root.EGte(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".EGte.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".EGte.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a EGte message. Also converts values to other types if specified. - * @function toObject - * @memberof EGte - * @static - * @param {EGte} message EGte - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EGte.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this EGte to JSON. - * @function toJSON - * @memberof EGte - * @instance - * @returns {Object.} JSON object - */ - EGte.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EGte; -})(); - -$root.EEq = (function() { - - /** - * Properties of a EEq. - * @exports IEEq - * @interface IEEq - * @property {IPar|null} [p1] EEq p1 - * @property {IPar|null} [p2] EEq p2 - */ - - /** - * Constructs a new EEq. - * @exports EEq - * @classdesc Represents a EEq. - * @implements IEEq - * @constructor - * @param {IEEq=} [properties] Properties to set - */ - function EEq(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EEq p1. - * @member {IPar|null|undefined} p1 - * @memberof EEq - * @instance - */ - EEq.prototype.p1 = null; - - /** - * EEq p2. - * @member {IPar|null|undefined} p2 - * @memberof EEq - * @instance - */ - EEq.prototype.p2 = null; - - /** - * Creates a new EEq instance using the specified properties. - * @function create - * @memberof EEq - * @static - * @param {IEEq=} [properties] Properties to set - * @returns {EEq} EEq instance - */ - EEq.create = function create(properties) { - return new EEq(properties); - }; - - /** - * Encodes the specified EEq message. Does not implicitly {@link EEq.verify|verify} messages. - * @function encode - * @memberof EEq - * @static - * @param {IEEq} message EEq message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EEq.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EEq message, length delimited. Does not implicitly {@link EEq.verify|verify} messages. - * @function encodeDelimited - * @memberof EEq - * @static - * @param {IEEq} message EEq message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EEq.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EEq message from the specified reader or buffer. - * @function decode - * @memberof EEq - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EEq} EEq - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EEq.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EEq(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EEq message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EEq - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EEq} EEq - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EEq.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EEq message. - * @function verify - * @memberof EEq - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EEq.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a EEq message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EEq - * @static - * @param {Object.} object Plain object - * @returns {EEq} EEq - */ - EEq.fromObject = function fromObject(object) { - if (object instanceof $root.EEq) - return object; - var message = new $root.EEq(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".EEq.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".EEq.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a EEq message. Also converts values to other types if specified. - * @function toObject - * @memberof EEq - * @static - * @param {EEq} message EEq - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EEq.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this EEq to JSON. - * @function toJSON - * @memberof EEq - * @instance - * @returns {Object.} JSON object - */ - EEq.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EEq; -})(); - -$root.ENeq = (function() { - - /** - * Properties of a ENeq. - * @exports IENeq - * @interface IENeq - * @property {IPar|null} [p1] ENeq p1 - * @property {IPar|null} [p2] ENeq p2 - */ - - /** - * Constructs a new ENeq. - * @exports ENeq - * @classdesc Represents a ENeq. - * @implements IENeq - * @constructor - * @param {IENeq=} [properties] Properties to set - */ - function ENeq(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ENeq p1. - * @member {IPar|null|undefined} p1 - * @memberof ENeq - * @instance - */ - ENeq.prototype.p1 = null; - - /** - * ENeq p2. - * @member {IPar|null|undefined} p2 - * @memberof ENeq - * @instance - */ - ENeq.prototype.p2 = null; - - /** - * Creates a new ENeq instance using the specified properties. - * @function create - * @memberof ENeq - * @static - * @param {IENeq=} [properties] Properties to set - * @returns {ENeq} ENeq instance - */ - ENeq.create = function create(properties) { - return new ENeq(properties); - }; - - /** - * Encodes the specified ENeq message. Does not implicitly {@link ENeq.verify|verify} messages. - * @function encode - * @memberof ENeq - * @static - * @param {IENeq} message ENeq message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ENeq.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified ENeq message, length delimited. Does not implicitly {@link ENeq.verify|verify} messages. - * @function encodeDelimited - * @memberof ENeq - * @static - * @param {IENeq} message ENeq message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ENeq.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ENeq message from the specified reader or buffer. - * @function decode - * @memberof ENeq - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {ENeq} ENeq - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ENeq.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ENeq(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ENeq message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof ENeq - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {ENeq} ENeq - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ENeq.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ENeq message. - * @function verify - * @memberof ENeq - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ENeq.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a ENeq message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof ENeq - * @static - * @param {Object.} object Plain object - * @returns {ENeq} ENeq - */ - ENeq.fromObject = function fromObject(object) { - if (object instanceof $root.ENeq) - return object; - var message = new $root.ENeq(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".ENeq.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".ENeq.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a ENeq message. Also converts values to other types if specified. - * @function toObject - * @memberof ENeq - * @static - * @param {ENeq} message ENeq - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ENeq.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this ENeq to JSON. - * @function toJSON - * @memberof ENeq - * @instance - * @returns {Object.} JSON object - */ - ENeq.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ENeq; -})(); - -$root.EAnd = (function() { - - /** - * Properties of a EAnd. - * @exports IEAnd - * @interface IEAnd - * @property {IPar|null} [p1] EAnd p1 - * @property {IPar|null} [p2] EAnd p2 - */ - - /** - * Constructs a new EAnd. - * @exports EAnd - * @classdesc Represents a EAnd. - * @implements IEAnd - * @constructor - * @param {IEAnd=} [properties] Properties to set - */ - function EAnd(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EAnd p1. - * @member {IPar|null|undefined} p1 - * @memberof EAnd - * @instance - */ - EAnd.prototype.p1 = null; - - /** - * EAnd p2. - * @member {IPar|null|undefined} p2 - * @memberof EAnd - * @instance - */ - EAnd.prototype.p2 = null; - - /** - * Creates a new EAnd instance using the specified properties. - * @function create - * @memberof EAnd - * @static - * @param {IEAnd=} [properties] Properties to set - * @returns {EAnd} EAnd instance - */ - EAnd.create = function create(properties) { - return new EAnd(properties); - }; - - /** - * Encodes the specified EAnd message. Does not implicitly {@link EAnd.verify|verify} messages. - * @function encode - * @memberof EAnd - * @static - * @param {IEAnd} message EAnd message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EAnd.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EAnd message, length delimited. Does not implicitly {@link EAnd.verify|verify} messages. - * @function encodeDelimited - * @memberof EAnd - * @static - * @param {IEAnd} message EAnd message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EAnd.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EAnd message from the specified reader or buffer. - * @function decode - * @memberof EAnd - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EAnd} EAnd - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EAnd.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EAnd(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EAnd message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EAnd - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EAnd} EAnd - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EAnd.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EAnd message. - * @function verify - * @memberof EAnd - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EAnd.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a EAnd message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EAnd - * @static - * @param {Object.} object Plain object - * @returns {EAnd} EAnd - */ - EAnd.fromObject = function fromObject(object) { - if (object instanceof $root.EAnd) - return object; - var message = new $root.EAnd(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".EAnd.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".EAnd.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a EAnd message. Also converts values to other types if specified. - * @function toObject - * @memberof EAnd - * @static - * @param {EAnd} message EAnd - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EAnd.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this EAnd to JSON. - * @function toJSON - * @memberof EAnd - * @instance - * @returns {Object.} JSON object - */ - EAnd.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EAnd; -})(); - -$root.EOr = (function() { - - /** - * Properties of a EOr. - * @exports IEOr - * @interface IEOr - * @property {IPar|null} [p1] EOr p1 - * @property {IPar|null} [p2] EOr p2 - */ - - /** - * Constructs a new EOr. - * @exports EOr - * @classdesc Represents a EOr. - * @implements IEOr - * @constructor - * @param {IEOr=} [properties] Properties to set - */ - function EOr(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EOr p1. - * @member {IPar|null|undefined} p1 - * @memberof EOr - * @instance - */ - EOr.prototype.p1 = null; - - /** - * EOr p2. - * @member {IPar|null|undefined} p2 - * @memberof EOr - * @instance - */ - EOr.prototype.p2 = null; - - /** - * Creates a new EOr instance using the specified properties. - * @function create - * @memberof EOr - * @static - * @param {IEOr=} [properties] Properties to set - * @returns {EOr} EOr instance - */ - EOr.create = function create(properties) { - return new EOr(properties); - }; - - /** - * Encodes the specified EOr message. Does not implicitly {@link EOr.verify|verify} messages. - * @function encode - * @memberof EOr - * @static - * @param {IEOr} message EOr message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EOr.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EOr message, length delimited. Does not implicitly {@link EOr.verify|verify} messages. - * @function encodeDelimited - * @memberof EOr - * @static - * @param {IEOr} message EOr message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EOr.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EOr message from the specified reader or buffer. - * @function decode - * @memberof EOr - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EOr} EOr - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EOr.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EOr(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EOr message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EOr - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EOr} EOr - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EOr.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EOr message. - * @function verify - * @memberof EOr - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EOr.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a EOr message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EOr - * @static - * @param {Object.} object Plain object - * @returns {EOr} EOr - */ - EOr.fromObject = function fromObject(object) { - if (object instanceof $root.EOr) - return object; - var message = new $root.EOr(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".EOr.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".EOr.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a EOr message. Also converts values to other types if specified. - * @function toObject - * @memberof EOr - * @static - * @param {EOr} message EOr - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EOr.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this EOr to JSON. - * @function toJSON - * @memberof EOr - * @instance - * @returns {Object.} JSON object - */ - EOr.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EOr; -})(); - -$root.EMatches = (function() { - - /** - * Properties of a EMatches. - * @exports IEMatches - * @interface IEMatches - * @property {IPar|null} [target] EMatches target - * @property {IPar|null} [pattern] EMatches pattern - */ - - /** - * Constructs a new EMatches. - * @exports EMatches - * @classdesc Represents a EMatches. - * @implements IEMatches - * @constructor - * @param {IEMatches=} [properties] Properties to set - */ - function EMatches(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EMatches target. - * @member {IPar|null|undefined} target - * @memberof EMatches - * @instance - */ - EMatches.prototype.target = null; - - /** - * EMatches pattern. - * @member {IPar|null|undefined} pattern - * @memberof EMatches - * @instance - */ - EMatches.prototype.pattern = null; - - /** - * Creates a new EMatches instance using the specified properties. - * @function create - * @memberof EMatches - * @static - * @param {IEMatches=} [properties] Properties to set - * @returns {EMatches} EMatches instance - */ - EMatches.create = function create(properties) { - return new EMatches(properties); - }; - - /** - * Encodes the specified EMatches message. Does not implicitly {@link EMatches.verify|verify} messages. - * @function encode - * @memberof EMatches - * @static - * @param {IEMatches} message EMatches message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EMatches.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.target != null && message.hasOwnProperty("target")) - $root.Par.encode(message.target, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.pattern != null && message.hasOwnProperty("pattern")) - $root.Par.encode(message.pattern, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EMatches message, length delimited. Does not implicitly {@link EMatches.verify|verify} messages. - * @function encodeDelimited - * @memberof EMatches - * @static - * @param {IEMatches} message EMatches message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EMatches.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EMatches message from the specified reader or buffer. - * @function decode - * @memberof EMatches - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EMatches} EMatches - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EMatches.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EMatches(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.target = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.pattern = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EMatches message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EMatches - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EMatches} EMatches - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EMatches.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EMatches message. - * @function verify - * @memberof EMatches - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EMatches.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.target != null && message.hasOwnProperty("target")) { - var error = $root.Par.verify(message.target); - if (error) - return "target." + error; - } - if (message.pattern != null && message.hasOwnProperty("pattern")) { - var error = $root.Par.verify(message.pattern); - if (error) - return "pattern." + error; - } - return null; - }; - - /** - * Creates a EMatches message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EMatches - * @static - * @param {Object.} object Plain object - * @returns {EMatches} EMatches - */ - EMatches.fromObject = function fromObject(object) { - if (object instanceof $root.EMatches) - return object; - var message = new $root.EMatches(); - if (object.target != null) { - if (typeof object.target !== "object") - throw TypeError(".EMatches.target: object expected"); - message.target = $root.Par.fromObject(object.target); - } - if (object.pattern != null) { - if (typeof object.pattern !== "object") - throw TypeError(".EMatches.pattern: object expected"); - message.pattern = $root.Par.fromObject(object.pattern); - } - return message; - }; - - /** - * Creates a plain object from a EMatches message. Also converts values to other types if specified. - * @function toObject - * @memberof EMatches - * @static - * @param {EMatches} message EMatches - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EMatches.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.target = null; - object.pattern = null; - } - if (message.target != null && message.hasOwnProperty("target")) - object.target = $root.Par.toObject(message.target, options); - if (message.pattern != null && message.hasOwnProperty("pattern")) - object.pattern = $root.Par.toObject(message.pattern, options); - return object; - }; - - /** - * Converts this EMatches to JSON. - * @function toJSON - * @memberof EMatches - * @instance - * @returns {Object.} JSON object - */ - EMatches.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EMatches; -})(); - -$root.EPercentPercent = (function() { - - /** - * Properties of a EPercentPercent. - * @exports IEPercentPercent - * @interface IEPercentPercent - * @property {IPar|null} [p1] EPercentPercent p1 - * @property {IPar|null} [p2] EPercentPercent p2 - */ - - /** - * Constructs a new EPercentPercent. - * @exports EPercentPercent - * @classdesc String interpolation - * - * `"Hello, {name}" %% {"name": "Bob"}` denotes `"Hello, Bob"` - * @implements IEPercentPercent - * @constructor - * @param {IEPercentPercent=} [properties] Properties to set - */ - function EPercentPercent(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EPercentPercent p1. - * @member {IPar|null|undefined} p1 - * @memberof EPercentPercent - * @instance - */ - EPercentPercent.prototype.p1 = null; - - /** - * EPercentPercent p2. - * @member {IPar|null|undefined} p2 - * @memberof EPercentPercent - * @instance - */ - EPercentPercent.prototype.p2 = null; - - /** - * Creates a new EPercentPercent instance using the specified properties. - * @function create - * @memberof EPercentPercent - * @static - * @param {IEPercentPercent=} [properties] Properties to set - * @returns {EPercentPercent} EPercentPercent instance - */ - EPercentPercent.create = function create(properties) { - return new EPercentPercent(properties); - }; - - /** - * Encodes the specified EPercentPercent message. Does not implicitly {@link EPercentPercent.verify|verify} messages. - * @function encode - * @memberof EPercentPercent - * @static - * @param {IEPercentPercent} message EPercentPercent message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EPercentPercent.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EPercentPercent message, length delimited. Does not implicitly {@link EPercentPercent.verify|verify} messages. - * @function encodeDelimited - * @memberof EPercentPercent - * @static - * @param {IEPercentPercent} message EPercentPercent message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EPercentPercent.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EPercentPercent message from the specified reader or buffer. - * @function decode - * @memberof EPercentPercent - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EPercentPercent} EPercentPercent - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EPercentPercent.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EPercentPercent(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EPercentPercent message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EPercentPercent - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EPercentPercent} EPercentPercent - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EPercentPercent.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EPercentPercent message. - * @function verify - * @memberof EPercentPercent - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EPercentPercent.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a EPercentPercent message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EPercentPercent - * @static - * @param {Object.} object Plain object - * @returns {EPercentPercent} EPercentPercent - */ - EPercentPercent.fromObject = function fromObject(object) { - if (object instanceof $root.EPercentPercent) - return object; - var message = new $root.EPercentPercent(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".EPercentPercent.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".EPercentPercent.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a EPercentPercent message. Also converts values to other types if specified. - * @function toObject - * @memberof EPercentPercent - * @static - * @param {EPercentPercent} message EPercentPercent - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EPercentPercent.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this EPercentPercent to JSON. - * @function toJSON - * @memberof EPercentPercent - * @instance - * @returns {Object.} JSON object - */ - EPercentPercent.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EPercentPercent; -})(); - -$root.EPlusPlus = (function() { - - /** - * Properties of a EPlusPlus. - * @exports IEPlusPlus - * @interface IEPlusPlus - * @property {IPar|null} [p1] EPlusPlus p1 - * @property {IPar|null} [p2] EPlusPlus p2 - */ - - /** - * Constructs a new EPlusPlus. - * @exports EPlusPlus - * @classdesc Represents a EPlusPlus. - * @implements IEPlusPlus - * @constructor - * @param {IEPlusPlus=} [properties] Properties to set - */ - function EPlusPlus(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EPlusPlus p1. - * @member {IPar|null|undefined} p1 - * @memberof EPlusPlus - * @instance - */ - EPlusPlus.prototype.p1 = null; - - /** - * EPlusPlus p2. - * @member {IPar|null|undefined} p2 - * @memberof EPlusPlus - * @instance - */ - EPlusPlus.prototype.p2 = null; - - /** - * Creates a new EPlusPlus instance using the specified properties. - * @function create - * @memberof EPlusPlus - * @static - * @param {IEPlusPlus=} [properties] Properties to set - * @returns {EPlusPlus} EPlusPlus instance - */ - EPlusPlus.create = function create(properties) { - return new EPlusPlus(properties); - }; - - /** - * Encodes the specified EPlusPlus message. Does not implicitly {@link EPlusPlus.verify|verify} messages. - * @function encode - * @memberof EPlusPlus - * @static - * @param {IEPlusPlus} message EPlusPlus message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EPlusPlus.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EPlusPlus message, length delimited. Does not implicitly {@link EPlusPlus.verify|verify} messages. - * @function encodeDelimited - * @memberof EPlusPlus - * @static - * @param {IEPlusPlus} message EPlusPlus message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EPlusPlus.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EPlusPlus message from the specified reader or buffer. - * @function decode - * @memberof EPlusPlus - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EPlusPlus} EPlusPlus - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EPlusPlus.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EPlusPlus(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EPlusPlus message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EPlusPlus - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EPlusPlus} EPlusPlus - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EPlusPlus.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EPlusPlus message. - * @function verify - * @memberof EPlusPlus - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EPlusPlus.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a EPlusPlus message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EPlusPlus - * @static - * @param {Object.} object Plain object - * @returns {EPlusPlus} EPlusPlus - */ - EPlusPlus.fromObject = function fromObject(object) { - if (object instanceof $root.EPlusPlus) - return object; - var message = new $root.EPlusPlus(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".EPlusPlus.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".EPlusPlus.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a EPlusPlus message. Also converts values to other types if specified. - * @function toObject - * @memberof EPlusPlus - * @static - * @param {EPlusPlus} message EPlusPlus - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EPlusPlus.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this EPlusPlus to JSON. - * @function toJSON - * @memberof EPlusPlus - * @instance - * @returns {Object.} JSON object - */ - EPlusPlus.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EPlusPlus; -})(); - -$root.EMinusMinus = (function() { - - /** - * Properties of a EMinusMinus. - * @exports IEMinusMinus - * @interface IEMinusMinus - * @property {IPar|null} [p1] EMinusMinus p1 - * @property {IPar|null} [p2] EMinusMinus p2 - */ - - /** - * Constructs a new EMinusMinus. - * @exports EMinusMinus - * @classdesc Represents a EMinusMinus. - * @implements IEMinusMinus - * @constructor - * @param {IEMinusMinus=} [properties] Properties to set - */ - function EMinusMinus(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EMinusMinus p1. - * @member {IPar|null|undefined} p1 - * @memberof EMinusMinus - * @instance - */ - EMinusMinus.prototype.p1 = null; - - /** - * EMinusMinus p2. - * @member {IPar|null|undefined} p2 - * @memberof EMinusMinus - * @instance - */ - EMinusMinus.prototype.p2 = null; - - /** - * Creates a new EMinusMinus instance using the specified properties. - * @function create - * @memberof EMinusMinus - * @static - * @param {IEMinusMinus=} [properties] Properties to set - * @returns {EMinusMinus} EMinusMinus instance - */ - EMinusMinus.create = function create(properties) { - return new EMinusMinus(properties); - }; - - /** - * Encodes the specified EMinusMinus message. Does not implicitly {@link EMinusMinus.verify|verify} messages. - * @function encode - * @memberof EMinusMinus - * @static - * @param {IEMinusMinus} message EMinusMinus message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EMinusMinus.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.p1 != null && message.hasOwnProperty("p1")) - $root.Par.encode(message.p1, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.p2 != null && message.hasOwnProperty("p2")) - $root.Par.encode(message.p2, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EMinusMinus message, length delimited. Does not implicitly {@link EMinusMinus.verify|verify} messages. - * @function encodeDelimited - * @memberof EMinusMinus - * @static - * @param {IEMinusMinus} message EMinusMinus message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EMinusMinus.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a EMinusMinus message from the specified reader or buffer. - * @function decode - * @memberof EMinusMinus - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EMinusMinus} EMinusMinus - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EMinusMinus.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EMinusMinus(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.p1 = $root.Par.decode(reader, reader.uint32()); - break; - case 2: - message.p2 = $root.Par.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a EMinusMinus message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EMinusMinus - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EMinusMinus} EMinusMinus - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EMinusMinus.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a EMinusMinus message. - * @function verify - * @memberof EMinusMinus - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EMinusMinus.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.p1 != null && message.hasOwnProperty("p1")) { - var error = $root.Par.verify(message.p1); - if (error) - return "p1." + error; - } - if (message.p2 != null && message.hasOwnProperty("p2")) { - var error = $root.Par.verify(message.p2); - if (error) - return "p2." + error; - } - return null; - }; - - /** - * Creates a EMinusMinus message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EMinusMinus - * @static - * @param {Object.} object Plain object - * @returns {EMinusMinus} EMinusMinus - */ - EMinusMinus.fromObject = function fromObject(object) { - if (object instanceof $root.EMinusMinus) - return object; - var message = new $root.EMinusMinus(); - if (object.p1 != null) { - if (typeof object.p1 !== "object") - throw TypeError(".EMinusMinus.p1: object expected"); - message.p1 = $root.Par.fromObject(object.p1); - } - if (object.p2 != null) { - if (typeof object.p2 !== "object") - throw TypeError(".EMinusMinus.p2: object expected"); - message.p2 = $root.Par.fromObject(object.p2); - } - return message; - }; - - /** - * Creates a plain object from a EMinusMinus message. Also converts values to other types if specified. - * @function toObject - * @memberof EMinusMinus - * @static - * @param {EMinusMinus} message EMinusMinus - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EMinusMinus.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.p1 = null; - object.p2 = null; - } - if (message.p1 != null && message.hasOwnProperty("p1")) - object.p1 = $root.Par.toObject(message.p1, options); - if (message.p2 != null && message.hasOwnProperty("p2")) - object.p2 = $root.Par.toObject(message.p2, options); - return object; - }; - - /** - * Converts this EMinusMinus to JSON. - * @function toJSON - * @memberof EMinusMinus - * @instance - * @returns {Object.} JSON object - */ - EMinusMinus.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EMinusMinus; -})(); - -$root.Connective = (function() { - - /** - * Properties of a Connective. - * @exports IConnective - * @interface IConnective - * @property {IConnectiveBody|null} [conn_and_body] Connective conn_and_body - * @property {IConnectiveBody|null} [conn_or_body] Connective conn_or_body - * @property {IPar|null} [conn_not_body] Connective conn_not_body - * @property {IVarRef|null} [var_ref_body] Connective var_ref_body - * @property {boolean|null} [conn_bool] Connective conn_bool - * @property {boolean|null} [conn_int] Connective conn_int - * @property {boolean|null} [conn_string] Connective conn_string - * @property {boolean|null} [conn_uri] Connective conn_uri - * @property {boolean|null} [conn_byte_array] Connective conn_byte_array - */ - - /** - * Constructs a new Connective. - * @exports Connective - * @classdesc Represents a Connective. - * @implements IConnective - * @constructor - * @param {IConnective=} [properties] Properties to set - */ - function Connective(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Connective conn_and_body. - * @member {IConnectiveBody|null|undefined} conn_and_body - * @memberof Connective - * @instance - */ - Connective.prototype.conn_and_body = null; - - /** - * Connective conn_or_body. - * @member {IConnectiveBody|null|undefined} conn_or_body - * @memberof Connective - * @instance - */ - Connective.prototype.conn_or_body = null; - - /** - * Connective conn_not_body. - * @member {IPar|null|undefined} conn_not_body - * @memberof Connective - * @instance - */ - Connective.prototype.conn_not_body = null; - - /** - * Connective var_ref_body. - * @member {IVarRef|null|undefined} var_ref_body - * @memberof Connective - * @instance - */ - Connective.prototype.var_ref_body = null; - - /** - * Connective conn_bool. - * @member {boolean} conn_bool - * @memberof Connective - * @instance - */ - Connective.prototype.conn_bool = false; - - /** - * Connective conn_int. - * @member {boolean} conn_int - * @memberof Connective - * @instance - */ - Connective.prototype.conn_int = false; - - /** - * Connective conn_string. - * @member {boolean} conn_string - * @memberof Connective - * @instance - */ - Connective.prototype.conn_string = false; - - /** - * Connective conn_uri. - * @member {boolean} conn_uri - * @memberof Connective - * @instance - */ - Connective.prototype.conn_uri = false; - - /** - * Connective conn_byte_array. - * @member {boolean} conn_byte_array - * @memberof Connective - * @instance - */ - Connective.prototype.conn_byte_array = false; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Connective connective_instance. - * @member {"conn_and_body"|"conn_or_body"|"conn_not_body"|"var_ref_body"|"conn_bool"|"conn_int"|"conn_string"|"conn_uri"|"conn_byte_array"|undefined} connective_instance - * @memberof Connective - * @instance - */ - Object.defineProperty(Connective.prototype, "connective_instance", { - get: $util.oneOfGetter($oneOfFields = ["conn_and_body", "conn_or_body", "conn_not_body", "var_ref_body", "conn_bool", "conn_int", "conn_string", "conn_uri", "conn_byte_array"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * Creates a new Connective instance using the specified properties. - * @function create - * @memberof Connective - * @static - * @param {IConnective=} [properties] Properties to set - * @returns {Connective} Connective instance - */ - Connective.create = function create(properties) { - return new Connective(properties); - }; - - /** - * Encodes the specified Connective message. Does not implicitly {@link Connective.verify|verify} messages. - * @function encode - * @memberof Connective - * @static - * @param {IConnective} message Connective message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Connective.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.conn_and_body != null && message.hasOwnProperty("conn_and_body")) - $root.ConnectiveBody.encode(message.conn_and_body, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.conn_or_body != null && message.hasOwnProperty("conn_or_body")) - $root.ConnectiveBody.encode(message.conn_or_body, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.conn_not_body != null && message.hasOwnProperty("conn_not_body")) - $root.Par.encode(message.conn_not_body, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.var_ref_body != null && message.hasOwnProperty("var_ref_body")) - $root.VarRef.encode(message.var_ref_body, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.conn_bool != null && message.hasOwnProperty("conn_bool")) - writer.uint32(/* id 5, wireType 0 =*/40).bool(message.conn_bool); - if (message.conn_int != null && message.hasOwnProperty("conn_int")) - writer.uint32(/* id 6, wireType 0 =*/48).bool(message.conn_int); - if (message.conn_string != null && message.hasOwnProperty("conn_string")) - writer.uint32(/* id 7, wireType 0 =*/56).bool(message.conn_string); - if (message.conn_uri != null && message.hasOwnProperty("conn_uri")) - writer.uint32(/* id 8, wireType 0 =*/64).bool(message.conn_uri); - if (message.conn_byte_array != null && message.hasOwnProperty("conn_byte_array")) - writer.uint32(/* id 9, wireType 0 =*/72).bool(message.conn_byte_array); - return writer; - }; - - /** - * Encodes the specified Connective message, length delimited. Does not implicitly {@link Connective.verify|verify} messages. - * @function encodeDelimited - * @memberof Connective - * @static - * @param {IConnective} message Connective message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Connective.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Connective message from the specified reader or buffer. - * @function decode - * @memberof Connective - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {Connective} Connective - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Connective.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Connective(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.conn_and_body = $root.ConnectiveBody.decode(reader, reader.uint32()); - break; - case 2: - message.conn_or_body = $root.ConnectiveBody.decode(reader, reader.uint32()); - break; - case 3: - message.conn_not_body = $root.Par.decode(reader, reader.uint32()); - break; - case 4: - message.var_ref_body = $root.VarRef.decode(reader, reader.uint32()); - break; - case 5: - message.conn_bool = reader.bool(); - break; - case 6: - message.conn_int = reader.bool(); - break; - case 7: - message.conn_string = reader.bool(); - break; - case 8: - message.conn_uri = reader.bool(); - break; - case 9: - message.conn_byte_array = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Connective message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof Connective - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {Connective} Connective - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Connective.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Connective message. - * @function verify - * @memberof Connective - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Connective.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - var properties = {}; - if (message.conn_and_body != null && message.hasOwnProperty("conn_and_body")) { - properties.connective_instance = 1; - { - var error = $root.ConnectiveBody.verify(message.conn_and_body); - if (error) - return "conn_and_body." + error; - } - } - if (message.conn_or_body != null && message.hasOwnProperty("conn_or_body")) { - if (properties.connective_instance === 1) - return "connective_instance: multiple values"; - properties.connective_instance = 1; - { - var error = $root.ConnectiveBody.verify(message.conn_or_body); - if (error) - return "conn_or_body." + error; - } - } - if (message.conn_not_body != null && message.hasOwnProperty("conn_not_body")) { - if (properties.connective_instance === 1) - return "connective_instance: multiple values"; - properties.connective_instance = 1; - { - var error = $root.Par.verify(message.conn_not_body); - if (error) - return "conn_not_body." + error; - } - } - if (message.var_ref_body != null && message.hasOwnProperty("var_ref_body")) { - if (properties.connective_instance === 1) - return "connective_instance: multiple values"; - properties.connective_instance = 1; - { - var error = $root.VarRef.verify(message.var_ref_body); - if (error) - return "var_ref_body." + error; - } - } - if (message.conn_bool != null && message.hasOwnProperty("conn_bool")) { - if (properties.connective_instance === 1) - return "connective_instance: multiple values"; - properties.connective_instance = 1; - if (typeof message.conn_bool !== "boolean") - return "conn_bool: boolean expected"; - } - if (message.conn_int != null && message.hasOwnProperty("conn_int")) { - if (properties.connective_instance === 1) - return "connective_instance: multiple values"; - properties.connective_instance = 1; - if (typeof message.conn_int !== "boolean") - return "conn_int: boolean expected"; - } - if (message.conn_string != null && message.hasOwnProperty("conn_string")) { - if (properties.connective_instance === 1) - return "connective_instance: multiple values"; - properties.connective_instance = 1; - if (typeof message.conn_string !== "boolean") - return "conn_string: boolean expected"; - } - if (message.conn_uri != null && message.hasOwnProperty("conn_uri")) { - if (properties.connective_instance === 1) - return "connective_instance: multiple values"; - properties.connective_instance = 1; - if (typeof message.conn_uri !== "boolean") - return "conn_uri: boolean expected"; - } - if (message.conn_byte_array != null && message.hasOwnProperty("conn_byte_array")) { - if (properties.connective_instance === 1) - return "connective_instance: multiple values"; - properties.connective_instance = 1; - if (typeof message.conn_byte_array !== "boolean") - return "conn_byte_array: boolean expected"; - } - return null; - }; - - /** - * Creates a Connective message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof Connective - * @static - * @param {Object.} object Plain object - * @returns {Connective} Connective - */ - Connective.fromObject = function fromObject(object) { - if (object instanceof $root.Connective) - return object; - var message = new $root.Connective(); - if (object.conn_and_body != null) { - if (typeof object.conn_and_body !== "object") - throw TypeError(".Connective.conn_and_body: object expected"); - message.conn_and_body = $root.ConnectiveBody.fromObject(object.conn_and_body); - } - if (object.conn_or_body != null) { - if (typeof object.conn_or_body !== "object") - throw TypeError(".Connective.conn_or_body: object expected"); - message.conn_or_body = $root.ConnectiveBody.fromObject(object.conn_or_body); - } - if (object.conn_not_body != null) { - if (typeof object.conn_not_body !== "object") - throw TypeError(".Connective.conn_not_body: object expected"); - message.conn_not_body = $root.Par.fromObject(object.conn_not_body); - } - if (object.var_ref_body != null) { - if (typeof object.var_ref_body !== "object") - throw TypeError(".Connective.var_ref_body: object expected"); - message.var_ref_body = $root.VarRef.fromObject(object.var_ref_body); - } - if (object.conn_bool != null) - message.conn_bool = Boolean(object.conn_bool); - if (object.conn_int != null) - message.conn_int = Boolean(object.conn_int); - if (object.conn_string != null) - message.conn_string = Boolean(object.conn_string); - if (object.conn_uri != null) - message.conn_uri = Boolean(object.conn_uri); - if (object.conn_byte_array != null) - message.conn_byte_array = Boolean(object.conn_byte_array); - return message; - }; - - /** - * Creates a plain object from a Connective message. Also converts values to other types if specified. - * @function toObject - * @memberof Connective - * @static - * @param {Connective} message Connective - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Connective.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (message.conn_and_body != null && message.hasOwnProperty("conn_and_body")) { - object.conn_and_body = $root.ConnectiveBody.toObject(message.conn_and_body, options); - if (options.oneofs) - object.connective_instance = "conn_and_body"; - } - if (message.conn_or_body != null && message.hasOwnProperty("conn_or_body")) { - object.conn_or_body = $root.ConnectiveBody.toObject(message.conn_or_body, options); - if (options.oneofs) - object.connective_instance = "conn_or_body"; - } - if (message.conn_not_body != null && message.hasOwnProperty("conn_not_body")) { - object.conn_not_body = $root.Par.toObject(message.conn_not_body, options); - if (options.oneofs) - object.connective_instance = "conn_not_body"; - } - if (message.var_ref_body != null && message.hasOwnProperty("var_ref_body")) { - object.var_ref_body = $root.VarRef.toObject(message.var_ref_body, options); - if (options.oneofs) - object.connective_instance = "var_ref_body"; - } - if (message.conn_bool != null && message.hasOwnProperty("conn_bool")) { - object.conn_bool = message.conn_bool; - if (options.oneofs) - object.connective_instance = "conn_bool"; - } - if (message.conn_int != null && message.hasOwnProperty("conn_int")) { - object.conn_int = message.conn_int; - if (options.oneofs) - object.connective_instance = "conn_int"; - } - if (message.conn_string != null && message.hasOwnProperty("conn_string")) { - object.conn_string = message.conn_string; - if (options.oneofs) - object.connective_instance = "conn_string"; - } - if (message.conn_uri != null && message.hasOwnProperty("conn_uri")) { - object.conn_uri = message.conn_uri; - if (options.oneofs) - object.connective_instance = "conn_uri"; - } - if (message.conn_byte_array != null && message.hasOwnProperty("conn_byte_array")) { - object.conn_byte_array = message.conn_byte_array; - if (options.oneofs) - object.connective_instance = "conn_byte_array"; - } - return object; - }; - - /** - * Converts this Connective to JSON. - * @function toJSON - * @memberof Connective - * @instance - * @returns {Object.} JSON object - */ - Connective.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Connective; -})(); - -$root.VarRef = (function() { - - /** - * Properties of a VarRef. - * @exports IVarRef - * @interface IVarRef - * @property {number|null} [index] VarRef index - * @property {number|null} [depth] VarRef depth - */ - - /** - * Constructs a new VarRef. - * @exports VarRef - * @classdesc Represents a VarRef. - * @implements IVarRef - * @constructor - * @param {IVarRef=} [properties] Properties to set - */ - function VarRef(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * VarRef index. - * @member {number} index - * @memberof VarRef - * @instance - */ - VarRef.prototype.index = 0; - - /** - * VarRef depth. - * @member {number} depth - * @memberof VarRef - * @instance - */ - VarRef.prototype.depth = 0; - - /** - * Creates a new VarRef instance using the specified properties. - * @function create - * @memberof VarRef - * @static - * @param {IVarRef=} [properties] Properties to set - * @returns {VarRef} VarRef instance - */ - VarRef.create = function create(properties) { - return new VarRef(properties); - }; - - /** - * Encodes the specified VarRef message. Does not implicitly {@link VarRef.verify|verify} messages. - * @function encode - * @memberof VarRef - * @static - * @param {IVarRef} message VarRef message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - VarRef.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.index != null && message.hasOwnProperty("index")) - writer.uint32(/* id 1, wireType 0 =*/8).sint32(message.index); - if (message.depth != null && message.hasOwnProperty("depth")) - writer.uint32(/* id 2, wireType 0 =*/16).sint32(message.depth); - return writer; - }; - - /** - * Encodes the specified VarRef message, length delimited. Does not implicitly {@link VarRef.verify|verify} messages. - * @function encodeDelimited - * @memberof VarRef - * @static - * @param {IVarRef} message VarRef message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - VarRef.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a VarRef message from the specified reader or buffer. - * @function decode - * @memberof VarRef - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {VarRef} VarRef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - VarRef.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.VarRef(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.index = reader.sint32(); - break; - case 2: - message.depth = reader.sint32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a VarRef message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof VarRef - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {VarRef} VarRef - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - VarRef.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a VarRef message. - * @function verify - * @memberof VarRef - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - VarRef.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.index != null && message.hasOwnProperty("index")) - if (!$util.isInteger(message.index)) - return "index: integer expected"; - if (message.depth != null && message.hasOwnProperty("depth")) - if (!$util.isInteger(message.depth)) - return "depth: integer expected"; - return null; - }; - - /** - * Creates a VarRef message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof VarRef - * @static - * @param {Object.} object Plain object - * @returns {VarRef} VarRef - */ - VarRef.fromObject = function fromObject(object) { - if (object instanceof $root.VarRef) - return object; - var message = new $root.VarRef(); - if (object.index != null) - message.index = object.index | 0; - if (object.depth != null) - message.depth = object.depth | 0; - return message; - }; - - /** - * Creates a plain object from a VarRef message. Also converts values to other types if specified. - * @function toObject - * @memberof VarRef - * @static - * @param {VarRef} message VarRef - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - VarRef.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.index = 0; - object.depth = 0; - } - if (message.index != null && message.hasOwnProperty("index")) - object.index = message.index; - if (message.depth != null && message.hasOwnProperty("depth")) - object.depth = message.depth; - return object; - }; - - /** - * Converts this VarRef to JSON. - * @function toJSON - * @memberof VarRef - * @instance - * @returns {Object.} JSON object - */ - VarRef.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return VarRef; -})(); - -$root.ConnectiveBody = (function() { - - /** - * Properties of a ConnectiveBody. - * @exports IConnectiveBody - * @interface IConnectiveBody - * @property {Array.|null} [ps] ConnectiveBody ps - */ - - /** - * Constructs a new ConnectiveBody. - * @exports ConnectiveBody - * @classdesc Represents a ConnectiveBody. - * @implements IConnectiveBody - * @constructor - * @param {IConnectiveBody=} [properties] Properties to set - */ - function ConnectiveBody(properties) { - this.ps = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ConnectiveBody ps. - * @member {Array.} ps - * @memberof ConnectiveBody - * @instance - */ - ConnectiveBody.prototype.ps = $util.emptyArray; - - /** - * Creates a new ConnectiveBody instance using the specified properties. - * @function create - * @memberof ConnectiveBody - * @static - * @param {IConnectiveBody=} [properties] Properties to set - * @returns {ConnectiveBody} ConnectiveBody instance - */ - ConnectiveBody.create = function create(properties) { - return new ConnectiveBody(properties); - }; - - /** - * Encodes the specified ConnectiveBody message. Does not implicitly {@link ConnectiveBody.verify|verify} messages. - * @function encode - * @memberof ConnectiveBody - * @static - * @param {IConnectiveBody} message ConnectiveBody message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ConnectiveBody.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.ps != null && message.ps.length) - for (var i = 0; i < message.ps.length; ++i) - $root.Par.encode(message.ps[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified ConnectiveBody message, length delimited. Does not implicitly {@link ConnectiveBody.verify|verify} messages. - * @function encodeDelimited - * @memberof ConnectiveBody - * @static - * @param {IConnectiveBody} message ConnectiveBody message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ConnectiveBody.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ConnectiveBody message from the specified reader or buffer. - * @function decode - * @memberof ConnectiveBody - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {ConnectiveBody} ConnectiveBody - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ConnectiveBody.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ConnectiveBody(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.ps && message.ps.length)) - message.ps = []; - message.ps.push($root.Par.decode(reader, reader.uint32())); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ConnectiveBody message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof ConnectiveBody - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {ConnectiveBody} ConnectiveBody - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ConnectiveBody.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ConnectiveBody message. - * @function verify - * @memberof ConnectiveBody - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ConnectiveBody.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.ps != null && message.hasOwnProperty("ps")) { - if (!Array.isArray(message.ps)) - return "ps: array expected"; - for (var i = 0; i < message.ps.length; ++i) { - var error = $root.Par.verify(message.ps[i]); - if (error) - return "ps." + error; - } - } - return null; - }; - - /** - * Creates a ConnectiveBody message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof ConnectiveBody - * @static - * @param {Object.} object Plain object - * @returns {ConnectiveBody} ConnectiveBody - */ - ConnectiveBody.fromObject = function fromObject(object) { - if (object instanceof $root.ConnectiveBody) - return object; - var message = new $root.ConnectiveBody(); - if (object.ps) { - if (!Array.isArray(object.ps)) - throw TypeError(".ConnectiveBody.ps: array expected"); - message.ps = []; - for (var i = 0; i < object.ps.length; ++i) { - if (typeof object.ps[i] !== "object") - throw TypeError(".ConnectiveBody.ps: object expected"); - message.ps[i] = $root.Par.fromObject(object.ps[i]); - } - } - return message; - }; - - /** - * Creates a plain object from a ConnectiveBody message. Also converts values to other types if specified. - * @function toObject - * @memberof ConnectiveBody - * @static - * @param {ConnectiveBody} message ConnectiveBody - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ConnectiveBody.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.ps = []; - if (message.ps && message.ps.length) { - object.ps = []; - for (var j = 0; j < message.ps.length; ++j) - object.ps[j] = $root.Par.toObject(message.ps[j], options); - } - return object; - }; - - /** - * Converts this ConnectiveBody to JSON. - * @function toJSON - * @memberof ConnectiveBody - * @instance - * @returns {Object.} JSON object - */ - ConnectiveBody.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return ConnectiveBody; -})(); - -$root.GPrivate = (function() { - - /** - * Properties of a GPrivate. - * @exports IGPrivate - * @interface IGPrivate - * @property {Uint8Array|null} [id] GPrivate id - */ - - /** - * Constructs a new GPrivate. - * @exports GPrivate - * @classdesc Represents a GPrivate. - * @implements IGPrivate - * @constructor - * @param {IGPrivate=} [properties] Properties to set - */ - function GPrivate(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * GPrivate id. - * @member {Uint8Array} id - * @memberof GPrivate - * @instance - */ - GPrivate.prototype.id = $util.newBuffer([]); - - /** - * Creates a new GPrivate instance using the specified properties. - * @function create - * @memberof GPrivate - * @static - * @param {IGPrivate=} [properties] Properties to set - * @returns {GPrivate} GPrivate instance - */ - GPrivate.create = function create(properties) { - return new GPrivate(properties); - }; - - /** - * Encodes the specified GPrivate message. Does not implicitly {@link GPrivate.verify|verify} messages. - * @function encode - * @memberof GPrivate - * @static - * @param {IGPrivate} message GPrivate message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - GPrivate.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.id != null && message.hasOwnProperty("id")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.id); - return writer; - }; - - /** - * Encodes the specified GPrivate message, length delimited. Does not implicitly {@link GPrivate.verify|verify} messages. - * @function encodeDelimited - * @memberof GPrivate - * @static - * @param {IGPrivate} message GPrivate message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - GPrivate.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a GPrivate message from the specified reader or buffer. - * @function decode - * @memberof GPrivate - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {GPrivate} GPrivate - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - GPrivate.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.GPrivate(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.id = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a GPrivate message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof GPrivate - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {GPrivate} GPrivate - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - GPrivate.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a GPrivate message. - * @function verify - * @memberof GPrivate - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - GPrivate.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.id != null && message.hasOwnProperty("id")) - if (!(message.id && typeof message.id.length === "number" || $util.isString(message.id))) - return "id: buffer expected"; - return null; - }; - - /** - * Creates a GPrivate message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof GPrivate - * @static - * @param {Object.} object Plain object - * @returns {GPrivate} GPrivate - */ - GPrivate.fromObject = function fromObject(object) { - if (object instanceof $root.GPrivate) - return object; - var message = new $root.GPrivate(); - if (object.id != null) - if (typeof object.id === "string") - $util.base64.decode(object.id, message.id = $util.newBuffer($util.base64.length(object.id)), 0); - else if (object.id.length) - message.id = object.id; - return message; - }; - - /** - * Creates a plain object from a GPrivate message. Also converts values to other types if specified. - * @function toObject - * @memberof GPrivate - * @static - * @param {GPrivate} message GPrivate - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - GPrivate.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - if (options.bytes === String) - object.id = ""; - else { - object.id = []; - if (options.bytes !== Array) - object.id = $util.newBuffer(object.id); - } - if (message.id != null && message.hasOwnProperty("id")) - object.id = options.bytes === String ? $util.base64.encode(message.id, 0, message.id.length) : options.bytes === Array ? Array.prototype.slice.call(message.id) : message.id; - return object; - }; - - /** - * Converts this GPrivate to JSON. - * @function toJSON - * @memberof GPrivate - * @instance - * @returns {Object.} JSON object - */ - GPrivate.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return GPrivate; -})(); - -$root.EitherAny = (function() { - - /** - * Properties of an EitherAny. - * @exports IEitherAny - * @interface IEitherAny - * @property {string|null} [type_url] EitherAny type_url - * @property {Uint8Array|null} [value] EitherAny value - */ - - /** - * Constructs a new EitherAny. - * @exports EitherAny - * @classdesc Represents an EitherAny. - * @implements IEitherAny - * @constructor - * @param {IEitherAny=} [properties] Properties to set - */ - function EitherAny(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EitherAny type_url. - * @member {string} type_url - * @memberof EitherAny - * @instance - */ - EitherAny.prototype.type_url = ""; - - /** - * EitherAny value. - * @member {Uint8Array} value - * @memberof EitherAny - * @instance - */ - EitherAny.prototype.value = $util.newBuffer([]); - - /** - * Creates a new EitherAny instance using the specified properties. - * @function create - * @memberof EitherAny - * @static - * @param {IEitherAny=} [properties] Properties to set - * @returns {EitherAny} EitherAny instance - */ - EitherAny.create = function create(properties) { - return new EitherAny(properties); - }; - - /** - * Encodes the specified EitherAny message. Does not implicitly {@link EitherAny.verify|verify} messages. - * @function encode - * @memberof EitherAny - * @static - * @param {IEitherAny} message EitherAny message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EitherAny.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.type_url != null && message.hasOwnProperty("type_url")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.type_url); - if (message.value != null && message.hasOwnProperty("value")) - writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.value); - return writer; - }; - - /** - * Encodes the specified EitherAny message, length delimited. Does not implicitly {@link EitherAny.verify|verify} messages. - * @function encodeDelimited - * @memberof EitherAny - * @static - * @param {IEitherAny} message EitherAny message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EitherAny.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an EitherAny message from the specified reader or buffer. - * @function decode - * @memberof EitherAny - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EitherAny} EitherAny - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EitherAny.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EitherAny(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.type_url = reader.string(); - break; - case 2: - message.value = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an EitherAny message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EitherAny - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EitherAny} EitherAny - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EitherAny.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an EitherAny message. - * @function verify - * @memberof EitherAny - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EitherAny.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.type_url != null && message.hasOwnProperty("type_url")) - if (!$util.isString(message.type_url)) - return "type_url: string expected"; - if (message.value != null && message.hasOwnProperty("value")) - if (!(message.value && typeof message.value.length === "number" || $util.isString(message.value))) - return "value: buffer expected"; - return null; - }; - - /** - * Creates an EitherAny message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EitherAny - * @static - * @param {Object.} object Plain object - * @returns {EitherAny} EitherAny - */ - EitherAny.fromObject = function fromObject(object) { - if (object instanceof $root.EitherAny) - return object; - var message = new $root.EitherAny(); - if (object.type_url != null) - message.type_url = String(object.type_url); - if (object.value != null) - if (typeof object.value === "string") - $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); - else if (object.value.length) - message.value = object.value; - return message; - }; - - /** - * Creates a plain object from an EitherAny message. Also converts values to other types if specified. - * @function toObject - * @memberof EitherAny - * @static - * @param {EitherAny} message EitherAny - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EitherAny.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.type_url = ""; - if (options.bytes === String) - object.value = ""; - else { - object.value = []; - if (options.bytes !== Array) - object.value = $util.newBuffer(object.value); - } - } - if (message.type_url != null && message.hasOwnProperty("type_url")) - object.type_url = message.type_url; - if (message.value != null && message.hasOwnProperty("value")) - object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; - return object; - }; - - /** - * Converts this EitherAny to JSON. - * @function toJSON - * @memberof EitherAny - * @instance - * @returns {Object.} JSON object - */ - EitherAny.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EitherAny; -})(); - -$root.EitherError = (function() { - - /** - * Properties of an EitherError. - * @exports IEitherError - * @interface IEitherError - * @property {Array.|null} [messages] EitherError messages - */ - - /** - * Constructs a new EitherError. - * @exports EitherError - * @classdesc Represents an EitherError. - * @implements IEitherError - * @constructor - * @param {IEitherError=} [properties] Properties to set - */ - function EitherError(properties) { - this.messages = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EitherError messages. - * @member {Array.} messages - * @memberof EitherError - * @instance - */ - EitherError.prototype.messages = $util.emptyArray; - - /** - * Creates a new EitherError instance using the specified properties. - * @function create - * @memberof EitherError - * @static - * @param {IEitherError=} [properties] Properties to set - * @returns {EitherError} EitherError instance - */ - EitherError.create = function create(properties) { - return new EitherError(properties); - }; - - /** - * Encodes the specified EitherError message. Does not implicitly {@link EitherError.verify|verify} messages. - * @function encode - * @memberof EitherError - * @static - * @param {IEitherError} message EitherError message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EitherError.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.messages != null && message.messages.length) - for (var i = 0; i < message.messages.length; ++i) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.messages[i]); - return writer; - }; - - /** - * Encodes the specified EitherError message, length delimited. Does not implicitly {@link EitherError.verify|verify} messages. - * @function encodeDelimited - * @memberof EitherError - * @static - * @param {IEitherError} message EitherError message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EitherError.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an EitherError message from the specified reader or buffer. - * @function decode - * @memberof EitherError - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EitherError} EitherError - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EitherError.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EitherError(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - if (!(message.messages && message.messages.length)) - message.messages = []; - message.messages.push(reader.string()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an EitherError message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EitherError - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EitherError} EitherError - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EitherError.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an EitherError message. - * @function verify - * @memberof EitherError - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EitherError.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.messages != null && message.hasOwnProperty("messages")) { - if (!Array.isArray(message.messages)) - return "messages: array expected"; - for (var i = 0; i < message.messages.length; ++i) - if (!$util.isString(message.messages[i])) - return "messages: string[] expected"; - } - return null; - }; - - /** - * Creates an EitherError message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EitherError - * @static - * @param {Object.} object Plain object - * @returns {EitherError} EitherError - */ - EitherError.fromObject = function fromObject(object) { - if (object instanceof $root.EitherError) - return object; - var message = new $root.EitherError(); - if (object.messages) { - if (!Array.isArray(object.messages)) - throw TypeError(".EitherError.messages: array expected"); - message.messages = []; - for (var i = 0; i < object.messages.length; ++i) - message.messages[i] = String(object.messages[i]); - } - return message; - }; - - /** - * Creates a plain object from an EitherError message. Also converts values to other types if specified. - * @function toObject - * @memberof EitherError - * @static - * @param {EitherError} message EitherError - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EitherError.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.messages = []; - if (message.messages && message.messages.length) { - object.messages = []; - for (var j = 0; j < message.messages.length; ++j) - object.messages[j] = message.messages[j]; - } - return object; - }; - - /** - * Converts this EitherError to JSON. - * @function toJSON - * @memberof EitherError - * @instance - * @returns {Object.} JSON object - */ - EitherError.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EitherError; -})(); - -$root.EitherSuccess = (function() { - - /** - * Properties of an EitherSuccess. - * @exports IEitherSuccess - * @interface IEitherSuccess - * @property {IEitherAny|null} [response] EitherSuccess response - */ - - /** - * Constructs a new EitherSuccess. - * @exports EitherSuccess - * @classdesc Represents an EitherSuccess. - * @implements IEitherSuccess - * @constructor - * @param {IEitherSuccess=} [properties] Properties to set - */ - function EitherSuccess(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * EitherSuccess response. - * @member {IEitherAny|null|undefined} response - * @memberof EitherSuccess - * @instance - */ - EitherSuccess.prototype.response = null; - - /** - * Creates a new EitherSuccess instance using the specified properties. - * @function create - * @memberof EitherSuccess - * @static - * @param {IEitherSuccess=} [properties] Properties to set - * @returns {EitherSuccess} EitherSuccess instance - */ - EitherSuccess.create = function create(properties) { - return new EitherSuccess(properties); - }; - - /** - * Encodes the specified EitherSuccess message. Does not implicitly {@link EitherSuccess.verify|verify} messages. - * @function encode - * @memberof EitherSuccess - * @static - * @param {IEitherSuccess} message EitherSuccess message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EitherSuccess.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.response != null && message.hasOwnProperty("response")) - $root.EitherAny.encode(message.response, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified EitherSuccess message, length delimited. Does not implicitly {@link EitherSuccess.verify|verify} messages. - * @function encodeDelimited - * @memberof EitherSuccess - * @static - * @param {IEitherSuccess} message EitherSuccess message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EitherSuccess.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an EitherSuccess message from the specified reader or buffer. - * @function decode - * @memberof EitherSuccess - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {EitherSuccess} EitherSuccess - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EitherSuccess.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EitherSuccess(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.response = $root.EitherAny.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an EitherSuccess message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof EitherSuccess - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {EitherSuccess} EitherSuccess - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EitherSuccess.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an EitherSuccess message. - * @function verify - * @memberof EitherSuccess - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EitherSuccess.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.response != null && message.hasOwnProperty("response")) { - var error = $root.EitherAny.verify(message.response); - if (error) - return "response." + error; - } - return null; - }; - - /** - * Creates an EitherSuccess message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof EitherSuccess - * @static - * @param {Object.} object Plain object - * @returns {EitherSuccess} EitherSuccess - */ - EitherSuccess.fromObject = function fromObject(object) { - if (object instanceof $root.EitherSuccess) - return object; - var message = new $root.EitherSuccess(); - if (object.response != null) { - if (typeof object.response !== "object") - throw TypeError(".EitherSuccess.response: object expected"); - message.response = $root.EitherAny.fromObject(object.response); - } - return message; - }; - - /** - * Creates a plain object from an EitherSuccess message. Also converts values to other types if specified. - * @function toObject - * @memberof EitherSuccess - * @static - * @param {EitherSuccess} message EitherSuccess - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EitherSuccess.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.response = null; - if (message.response != null && message.hasOwnProperty("response")) - object.response = $root.EitherAny.toObject(message.response, options); - return object; - }; - - /** - * Converts this EitherSuccess to JSON. - * @function toJSON - * @memberof EitherSuccess - * @instance - * @returns {Object.} JSON object - */ - EitherSuccess.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return EitherSuccess; -})(); - -$root.Either = (function() { - - /** - * Properties of an Either. - * @exports IEither - * @interface IEither - * @property {IEitherError|null} [error] Either error - * @property {IEitherSuccess|null} [success] Either success - */ - - /** - * Constructs a new Either. - * @exports Either - * @classdesc Represents an Either. - * @implements IEither - * @constructor - * @param {IEither=} [properties] Properties to set - */ - function Either(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Either error. - * @member {IEitherError|null|undefined} error - * @memberof Either - * @instance - */ - Either.prototype.error = null; - - /** - * Either success. - * @member {IEitherSuccess|null|undefined} success - * @memberof Either - * @instance - */ - Either.prototype.success = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Either content. - * @member {"error"|"success"|undefined} content - * @memberof Either - * @instance - */ - Object.defineProperty(Either.prototype, "content", { - get: $util.oneOfGetter($oneOfFields = ["error", "success"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * Creates a new Either instance using the specified properties. - * @function create - * @memberof Either - * @static - * @param {IEither=} [properties] Properties to set - * @returns {Either} Either instance - */ - Either.create = function create(properties) { - return new Either(properties); - }; - - /** - * Encodes the specified Either message. Does not implicitly {@link Either.verify|verify} messages. - * @function encode - * @memberof Either - * @static - * @param {IEither} message Either message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Either.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.error != null && message.hasOwnProperty("error")) - $root.EitherError.encode(message.error, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.success != null && message.hasOwnProperty("success")) - $root.EitherSuccess.encode(message.success, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified Either message, length delimited. Does not implicitly {@link Either.verify|verify} messages. - * @function encodeDelimited - * @memberof Either - * @static - * @param {IEither} message Either message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Either.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an Either message from the specified reader or buffer. - * @function decode - * @memberof Either - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {Either} Either - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Either.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Either(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.error = $root.EitherError.decode(reader, reader.uint32()); - break; - case 2: - message.success = $root.EitherSuccess.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an Either message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof Either - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {Either} Either - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Either.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an Either message. - * @function verify - * @memberof Either - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Either.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - var properties = {}; - if (message.error != null && message.hasOwnProperty("error")) { - properties.content = 1; - { - var error = $root.EitherError.verify(message.error); - if (error) - return "error." + error; - } - } - if (message.success != null && message.hasOwnProperty("success")) { - if (properties.content === 1) - return "content: multiple values"; - properties.content = 1; - { - var error = $root.EitherSuccess.verify(message.success); - if (error) - return "success." + error; - } - } - return null; - }; - - /** - * Creates an Either message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof Either - * @static - * @param {Object.} object Plain object - * @returns {Either} Either - */ - Either.fromObject = function fromObject(object) { - if (object instanceof $root.Either) - return object; - var message = new $root.Either(); - if (object.error != null) { - if (typeof object.error !== "object") - throw TypeError(".Either.error: object expected"); - message.error = $root.EitherError.fromObject(object.error); - } - if (object.success != null) { - if (typeof object.success !== "object") - throw TypeError(".Either.success: object expected"); - message.success = $root.EitherSuccess.fromObject(object.success); - } - return message; - }; - - /** - * Creates a plain object from an Either message. Also converts values to other types if specified. - * @function toObject - * @memberof Either - * @static - * @param {Either} message Either - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Either.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (message.error != null && message.hasOwnProperty("error")) { - object.error = $root.EitherError.toObject(message.error, options); - if (options.oneofs) - object.content = "error"; - } - if (message.success != null && message.hasOwnProperty("success")) { - object.success = $root.EitherSuccess.toObject(message.success, options); - if (options.oneofs) - object.content = "success"; - } - return object; - }; - - /** - * Converts this Either to JSON. - * @function toJSON - * @memberof Either - * @instance - * @returns {Object.} JSON object - */ - Either.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Either; -})(); - -$root.google = (function() { - - /** - * Namespace google. - * @exports google - * @namespace - */ - var google = {}; - - google.protobuf = (function() { - - /** - * Namespace protobuf. - * @memberof google - * @namespace - */ - var protobuf = {}; - - protobuf.Empty = (function() { - - /** - * Properties of an Empty. - * @memberof google.protobuf - * @interface IEmpty - */ - - /** - * Constructs a new Empty. - * @memberof google.protobuf - * @classdesc Represents an Empty. - * @implements IEmpty - * @constructor - * @param {google.protobuf.IEmpty=} [properties] Properties to set - */ - function Empty(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Creates a new Empty instance using the specified properties. - * @function create - * @memberof google.protobuf.Empty - * @static - * @param {google.protobuf.IEmpty=} [properties] Properties to set - * @returns {google.protobuf.Empty} Empty instance - */ - Empty.create = function create(properties) { - return new Empty(properties); - }; - - /** - * Encodes the specified Empty message. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. - * @function encode - * @memberof google.protobuf.Empty - * @static - * @param {google.protobuf.IEmpty} message Empty message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Empty.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - return writer; - }; - - /** - * Encodes the specified Empty message, length delimited. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. - * @function encodeDelimited - * @memberof google.protobuf.Empty - * @static - * @param {google.protobuf.IEmpty} message Empty message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Empty.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an Empty message from the specified reader or buffer. - * @function decode - * @memberof google.protobuf.Empty - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.Empty} Empty - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Empty.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Empty(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an Empty message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.protobuf.Empty - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.Empty} Empty - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Empty.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an Empty message. - * @function verify - * @memberof google.protobuf.Empty - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Empty.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - return null; - }; - - /** - * Creates an Empty message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.protobuf.Empty - * @static - * @param {Object.} object Plain object - * @returns {google.protobuf.Empty} Empty - */ - Empty.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.Empty) - return object; - return new $root.google.protobuf.Empty(); - }; - - /** - * Creates a plain object from an Empty message. Also converts values to other types if specified. - * @function toObject - * @memberof google.protobuf.Empty - * @static - * @param {google.protobuf.Empty} message Empty - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Empty.toObject = function toObject() { - return {}; - }; - - /** - * Converts this Empty to JSON. - * @function toJSON - * @memberof google.protobuf.Empty - * @instance - * @returns {Object.} JSON object - */ - Empty.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Empty; - })(); - - protobuf.Any = (function() { - - /** - * Properties of an Any. - * @memberof google.protobuf - * @interface IAny - * @property {string|null} [type_url] Any type_url - * @property {Uint8Array|null} [value] Any value - */ - - /** - * Constructs a new Any. - * @memberof google.protobuf - * @classdesc Represents an Any. - * @implements IAny - * @constructor - * @param {google.protobuf.IAny=} [properties] Properties to set - */ - function Any(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Any type_url. - * @member {string} type_url - * @memberof google.protobuf.Any - * @instance - */ - Any.prototype.type_url = ""; - - /** - * Any value. - * @member {Uint8Array} value - * @memberof google.protobuf.Any - * @instance - */ - Any.prototype.value = $util.newBuffer([]); - - /** - * Creates a new Any instance using the specified properties. - * @function create - * @memberof google.protobuf.Any - * @static - * @param {google.protobuf.IAny=} [properties] Properties to set - * @returns {google.protobuf.Any} Any instance - */ - Any.create = function create(properties) { - return new Any(properties); - }; - - /** - * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. - * @function encode - * @memberof google.protobuf.Any - * @static - * @param {google.protobuf.IAny} message Any message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Any.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.type_url != null && message.hasOwnProperty("type_url")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.type_url); - if (message.value != null && message.hasOwnProperty("value")) - writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.value); - return writer; - }; - - /** - * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. - * @function encodeDelimited - * @memberof google.protobuf.Any - * @static - * @param {google.protobuf.IAny} message Any message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Any.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an Any message from the specified reader or buffer. - * @function decode - * @memberof google.protobuf.Any - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.Any} Any - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Any.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Any(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.type_url = reader.string(); - break; - case 2: - message.value = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an Any message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.protobuf.Any - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.Any} Any - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Any.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an Any message. - * @function verify - * @memberof google.protobuf.Any - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Any.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.type_url != null && message.hasOwnProperty("type_url")) - if (!$util.isString(message.type_url)) - return "type_url: string expected"; - if (message.value != null && message.hasOwnProperty("value")) - if (!(message.value && typeof message.value.length === "number" || $util.isString(message.value))) - return "value: buffer expected"; - return null; - }; - - /** - * Creates an Any message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.protobuf.Any - * @static - * @param {Object.} object Plain object - * @returns {google.protobuf.Any} Any - */ - Any.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.Any) - return object; - var message = new $root.google.protobuf.Any(); - if (object.type_url != null) - message.type_url = String(object.type_url); - if (object.value != null) - if (typeof object.value === "string") - $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); - else if (object.value.length) - message.value = object.value; - return message; - }; - - /** - * Creates a plain object from an Any message. Also converts values to other types if specified. - * @function toObject - * @memberof google.protobuf.Any - * @static - * @param {google.protobuf.Any} message Any - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Any.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.type_url = ""; - if (options.bytes === String) - object.value = ""; - else { - object.value = []; - if (options.bytes !== Array) - object.value = $util.newBuffer(object.value); - } - } - if (message.type_url != null && message.hasOwnProperty("type_url")) - object.type_url = message.type_url; - if (message.value != null && message.hasOwnProperty("value")) - object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; - return object; - }; - - /** - * Converts this Any to JSON. - * @function toJSON - * @memberof google.protobuf.Any - * @instance - * @returns {Object.} JSON object - */ - Any.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Any; - })(); - - return protobuf; - })(); - - return google; -})(); - -module.exports = $root; From 027aca3deb4abd75b274a8038a2e9065ed5b1b5a Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Fri, 12 Apr 2019 11:35:13 -0500 Subject: [PATCH 07/36] API docs, reorg (esp. RholangCrypto) (WIP) API top level now fits in a short list: - RHOCore - RegistryProxy - RevAddress - Ed25519keyPair - RNode - RholangCrypto - SignDeployment - test doc examples with markdown-doctest - include markdown-doctest with test script - setup config - lint un-ignore pattern - fix README example - add ed25519Verify example - rnodeAPI: - deprecate listenForDataAtPublicName etc. - move unforgeable name manipulation to RHOCore - fix (documented) names of SignDeployment.sign, verify - send: fix error handling logic - proxy: leave rhoCall undocumented - factor out runRholang (WIP) - assets: leave link() undocumented - tests: add flow, lint; import api consistently - export type JsonExt --- .markdown-doctest-setup.js | 27 ++++ README.md | 12 +- index.js | 19 ++- package-lock.json | 263 ++++++++++++++++++++++++++++++++++- package.json | 7 +- rclient/src/main.js | 19 +-- rclient/src/rhoid.js | 8 +- rclient/src/secretStorage.js | 6 +- src/RHOCore.js | 32 ++++- src/assets.js | 2 + src/loading.js | 4 +- src/proxy.js | 29 +++- src/revAddress.js | 6 +- src/rnodeAPI.js | 60 ++++---- src/signing.js | 104 +++++++++----- test/RHOCore.test.js | 9 +- test/liveRHOCoreTest.js | 34 +++-- test/testRNode.js | 75 +++++----- test/testSigning.js | 10 +- 19 files changed, 561 insertions(+), 165 deletions(-) create mode 100644 .markdown-doctest-setup.js diff --git a/.markdown-doctest-setup.js b/.markdown-doctest-setup.js new file mode 100644 index 0000000..f241d15 --- /dev/null +++ b/.markdown-doctest-setup.js @@ -0,0 +1,27 @@ +/* global module, require */ + +const assert = require('assert'); +const rchain = require('.'); +const { RholangCrypto, RNode, Hex } = rchain; + +// mock enough of grpc +// ISSUE: refactor overlap with test/testRNode.js +function DeployService(_hostPort, _chan) { + return Object.freeze({ + doDeploy(_dd, _auto = false) { return 'Success!'; } + }); +} +const casper = { DeployService }; +const proto = { coop: { rchain: { casper: { protocol: casper } } } }; +const grpc = { + loadPackageDefinition(_d) { return proto; }, + credentials: { createInsecure() { } }, +}; + +module.exports = { + babel: false, + globals: { + RholangCrypto, RNode, Hex, grpc, + assert, + }, +}; diff --git a/README.md b/README.md index a38d788..379bc84 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,12 @@ doDeploy result: { success: true, message: 'Success!' } There are not yet nice truffle-style build tools, so you will probably deploy your code directly using the `rnode deploy` thin client or using RChain-API itself. ```javascript -const myNode = RNode('localhost', 40401); -rchain.doDeploy({ +const myNode = RNode(grpc, { host: 'localhost', port: 40401 }); +myNode.doDeploy({ term: '@"aliceUpdates"!("Having fun traveling!")', - timestamp: clock().valueOf(), - // from: '0x1', - // nonce: 0, + timestamp: new Date().valueOf(), + phloLimit: 1000000, + phloPrice: 1, }) ``` @@ -71,7 +71,7 @@ rchain.doDeploy({ ## License -Copyright 2018 RChain Cooperative +Copyright 2018-2019 RChain Cooperative Apache 2.0 License (See LICENSE.txt) diff --git a/index.js b/index.js index 480ea84..a912941 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,10 @@ const RHOCore = require('./src/RHOCore'); +/*:: +export type JsonExt = JsonExt; + */ + exports.RHOCore = RHOCore; @@ -24,19 +28,22 @@ exports.RNode = RNode; exports.SignDeployment = SignDeployment; exports.Block = Block; -exports.RegistryProxy = require('./src/proxy'); +/** + * Proxy method calls to registered RChain channels. + */ +const RegistryProxy = require('./src/proxy'); + +exports.RegistryProxy = RegistryProxy; /*:: export type Signature = Signature; export type PrivateKey = PrivateKey; export type PublicKey = PublicKey; */ -const { Ed25519, Blake2b256, SHA256, Keccak256 } = require('./src/signing'); +const { Ed25519keyPair, RholangCrypto } = require('./src/signing'); -exports.Ed25519 = Ed25519; -exports.Blake2b256 = Blake2b256; -exports.SHA256 = SHA256; -exports.Keccak256 = Keccak256; +exports.Ed25519keyPair = Ed25519keyPair; +exports.RholangCrypto = RholangCrypto; /*:: export type HexStr = HexStr; diff --git a/package-lock.json b/package-lock.json index 717bacc..7a16216 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "rchain-api", - "version": "0.9.1-beta.1", + "version": "0.9.1-beta.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -101,6 +101,12 @@ "through": ">=2.2.7 <3" } }, + "abbrev": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", + "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=", + "dev": true + }, "acorn": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", @@ -142,6 +148,13 @@ "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=", "dev": true }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true, + "optional": true + }, "ansi-escapes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", @@ -253,6 +266,12 @@ "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", "dev": true }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, "async-each": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", @@ -1088,6 +1107,38 @@ "semver": "^5.3.0" } }, + "babel-preset-es2015": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz", + "integrity": "sha1-1EBQ1rwsn+6nAqrzjXJ6AhBTiTk=", + "dev": true, + "requires": { + "babel-plugin-check-es2015-constants": "^6.22.0", + "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoping": "^6.24.1", + "babel-plugin-transform-es2015-classes": "^6.24.1", + "babel-plugin-transform-es2015-computed-properties": "^6.24.1", + "babel-plugin-transform-es2015-destructuring": "^6.22.0", + "babel-plugin-transform-es2015-duplicate-keys": "^6.24.1", + "babel-plugin-transform-es2015-for-of": "^6.22.0", + "babel-plugin-transform-es2015-function-name": "^6.24.1", + "babel-plugin-transform-es2015-literals": "^6.22.0", + "babel-plugin-transform-es2015-modules-amd": "^6.24.1", + "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", + "babel-plugin-transform-es2015-modules-systemjs": "^6.24.1", + "babel-plugin-transform-es2015-modules-umd": "^6.24.1", + "babel-plugin-transform-es2015-object-super": "^6.24.1", + "babel-plugin-transform-es2015-parameters": "^6.24.1", + "babel-plugin-transform-es2015-shorthand-properties": "^6.24.1", + "babel-plugin-transform-es2015-spread": "^6.22.0", + "babel-plugin-transform-es2015-sticky-regex": "^6.24.1", + "babel-plugin-transform-es2015-template-literals": "^6.22.0", + "babel-plugin-transform-es2015-typeof-symbol": "^6.22.0", + "babel-plugin-transform-es2015-unicode-regex": "^6.24.1", + "babel-plugin-transform-regenerator": "^6.24.1" + } + }, "babel-preset-flow": { "version": "6.23.0", "resolved": "https://registry.npmjs.org/babel-preset-flow/-/babel-preset-flow-6.23.0.tgz", @@ -1733,6 +1784,13 @@ "trim": "0.0.1" } }, + "commander": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", + "dev": true, + "optional": true + }, "component-emitter": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", @@ -2440,6 +2498,43 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, + "escodegen": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", + "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", + "dev": true, + "requires": { + "esprima": "^2.7.1", + "estraverse": "^1.9.1", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.2.0" + }, + "dependencies": { + "esprima": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", + "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", + "dev": true + }, + "estraverse": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", + "integrity": "sha1-r2fy3JIlgkFZUJJgkaQAXSnJu0Q=", + "dev": true + }, + "source-map": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", + "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", + "dev": true, + "optional": true, + "requires": { + "amdefine": ">=0.0.4" + } + } + } + }, "eslint": { "version": "4.19.1", "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz", @@ -4069,6 +4164,26 @@ } } }, + "handlebars": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.1.tgz", + "integrity": "sha512-3Zhi6C0euYZL5sM0Zcy7lInLXKQ+YLcF/olbN010mzGQ4XVm50JeyBnMqofHh696GrciGruC7kCcApPDJvVgwA==", + "dev": true, + "requires": { + "neo-async": "^2.6.0", + "optimist": "^0.6.1", + "source-map": "^0.6.1", + "uglify-js": "^3.1.4" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -4685,6 +4800,70 @@ "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", "dev": true }, + "istanbul": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", + "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", + "dev": true, + "requires": { + "abbrev": "1.0.x", + "async": "1.x", + "escodegen": "1.8.x", + "esprima": "2.7.x", + "glob": "^5.0.15", + "handlebars": "^4.0.1", + "js-yaml": "3.x", + "mkdirp": "0.5.x", + "nopt": "3.x", + "once": "1.x", + "resolve": "1.1.x", + "supports-color": "^3.1.0", + "which": "^1.1.1", + "wordwrap": "^1.0.0" + }, + "dependencies": { + "esprima": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", + "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", + "dev": true + }, + "glob": { + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "dev": true, + "requires": { + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "2 || 3", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, + "resolve": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "dev": true + }, + "supports-color": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", + "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "dev": true, + "requires": { + "has-flag": "^1.0.0" + } + } + } + }, "js-sha3": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", @@ -4897,6 +5076,35 @@ "object-visit": "^1.0.0" } }, + "markdown-doctest": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/markdown-doctest/-/markdown-doctest-0.9.1.tgz", + "integrity": "sha1-tRtu8rTiOfPxr0HAkdkC59yXLzo=", + "dev": true, + "requires": { + "babel-core": "^6.4.0", + "babel-preset-es2015": "^6.3.13", + "babel-preset-stage-0": "^6.5.0", + "chalk": "^1.1.1", + "glob": "^7.0.5", + "istanbul": "^0.4.3" + }, + "dependencies": { + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + } + } + }, "markdown-escapes": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.2.tgz", @@ -5212,6 +5420,21 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, + "neo-async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.0.tgz", + "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", + "dev": true + }, + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "dev": true, + "requires": { + "abbrev": "1" + } + }, "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", @@ -5377,6 +5600,24 @@ "mimic-fn": "^1.0.0" } }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "dev": true, + "requires": { + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" + }, + "dependencies": { + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + } + } + }, "optionator": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", @@ -6995,6 +7236,26 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "uglify-js": { + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.4.tgz", + "integrity": "sha512-GpKo28q/7Bm5BcX9vOu4S46FwisbPbAmkkqPnGIpKvKTM96I85N6XHQV+k4I6FA2wxgLhcsSyHoNhzucwCflvA==", + "dev": true, + "optional": true, + "requires": { + "commander": "~2.20.0", + "source-map": "~0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "optional": true + } + } + }, "unc-path-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", diff --git a/package.json b/package.json index 4b8194e..22acb7f 100644 --- a/package.json +++ b/package.json @@ -11,15 +11,15 @@ ], "postinstall": "cd rclient; npm install --no-package-lock", "testAll": "npm run check && npm run integrationTest", - "build:docs": "documentation build -f md --github --sort-order alpha index.js src/**.js --shallow -o docs/index.md", + "build:docs": "documentation build -f md --github --sort-order alpha index.js src/**.js --shallow -o docs/index.md && markdown-doctest", "doc-watch": "documentation serve --watch index.js src/**.js --shallow", "check": "npm run test && npm run lint && npm run flow-check", "test-jest": "jest", - "test": "tape test/**/*.js", + "test": "tape test/**/*.js && markdown-doctest", "integrationTest": "node test/testRNode.js --net && node test/liveRHOCoreTest.js && node test/liveRNodeTest.js", "flow-check": "flow check --from emacs", "flow-status": "flow status --from emacs", - "lint": "eslint *.js **/*.js --format unix --ignore-pattern interfaces/ --ignore-pattern node_modules/ --ignore-pattern protobuf/ --ignore-pattern **/*.test.js" + "lint": "eslint *.js **/*.js --format unix --ignore-pattern interfaces/ --ignore-pattern node_modules/ --ignore-pattern protobuf/ --ignore-pattern '!.markdown-doctest-setup.js'" }, "config": { "host": "localhost", @@ -61,6 +61,7 @@ "eslint-config-airbnb-base": "^13.0.0", "eslint-plugin-import": "^2.13.0", "flow-bin": "^0.81.0", + "markdown-doctest": "^0.9.1", "tape": "^4.10.1" }, "TODO": { diff --git a/rclient/src/main.js b/rclient/src/main.js index 9c951cc..913c5bb 100755 --- a/rclient/src/main.js +++ b/rclient/src/main.js @@ -11,8 +11,8 @@ const secp256k1 = require('secp256k1'); // ISSUE: push into rchain-api? const { docopt } = require('docopt'); const { RNode, RHOCore, - Keccak256, - Hex, Ed25519, SignDeployment, + RholangCrypto, + Hex, Ed25519keyPair, SignDeployment, RegistryProxy, RevAddress, } = require('rchain-api'); @@ -23,6 +23,7 @@ const { asPromise } = require('./asPromise'); const secretStorage = require('./secretStorage'); const { link } = require('./assets'); +const { keccak256Hash } = RholangCrypto; const { makeProxy } = RegistryProxy; const h2b = Hex.decode; const b2h = Hex.encode; @@ -202,7 +203,7 @@ async function register( async function check1(file) { const src = await ioOrExit(file.readText()); - const srcHash = RHOCore.wrapHash(Keccak256.hash)(src); + const srcHash = RHOCore.wrapHash(keccak256Hash)(src); const mods = await ioOrExit(registry.get(srcHash)); return { file, src, srcHash, mod: mods[srcHash] }; } @@ -216,7 +217,7 @@ async function register( if (toLoad.length > 0) { console.log('loading:', toLoad.map(({ file }) => file.name())); const privKey = await loadKey(keyStore, label, [], { getpass }); - const pmtKey = Ed25519.keyPair(privKey); + const pmtKey = Ed25519keyPair(privKey); const loaded = await ioOrExit( loadRhoModules(toLoad.map(({ src }) => src), payWith(pmtKey), { rnode, clock, delay }), ); @@ -262,7 +263,7 @@ async function keygen(keyStore, label, { getpass, randomBytes, uuidv4 }) { uuidv4, ); await store.set({ [label]: item }); - const publicKey /*: HexStr */= Ed25519.keyPair(privKey).publicKey(); + const publicKey /*: HexStr */= Ed25519keyPair(privKey).publicKey(); const revAddr = RevAddress.fromPublicKey(h2b(publicKey)).toString(); console.log({ label, revAddr, publicKey, keyStore: keyStore.readOnly().name(), status: 'saved' }); } @@ -365,14 +366,14 @@ function privateToPublic(privKey) { function pubToAddress(pubKey) { assert.equal(pubKey.length, 64); - return Keccak256.hash(pubKey).slice(-20); + return keccak256Hash(pubKey).slice(-20); } async function loadRevAddr(label, notice, { keyStore, getpass }) { try { const privKey = await loadKey(keyStore, label, notice, { getpass }); - const edKey = Ed25519.keyPair(privKey); + const edKey = Ed25519keyPair(privKey); const revAddr = RevAddress.fromPublicKey(h2b(edKey.publicKey())).toString(); return { label, revAddr, publicKey: edKey.publicKey() }; } catch (err) { @@ -394,7 +395,7 @@ async function genVault( console.log({ revAddr, label, amount, result }); } -const rhoKeccakHash = data => Keccak256.hash(RHOCore.toByteArray(RHOCore.fromJSData(data))); +const rhoKeccakHash = data => keccak256Hash(RHOCore.toByteArray(RHOCore.fromJSData(data))); const sigDERHex = sigObj => b2h(secp256k1.signatureExport(sigObj.signature)); async function claimAccount(label, priceInfo, { keyStore, toolsMod, getpass, rnode, clock }) { @@ -472,7 +473,7 @@ async function outcome/*::*/(x /*:Promise*/) /*: Promise*/ { } async function ensureLoaded(name, src, { registry }) /*: ModuleInfo */ { - const srcHash = RHOCore.wrapHash(Keccak256.hash)(src); + const srcHash = RHOCore.wrapHash(keccak256Hash)(src); const mods = await registry.get(srcHash); const mod = mods[srcHash]; if (!mod) { throw new ExitStatus(`rholang module not loaded: ${name}`); } diff --git a/rclient/src/rhoid.js b/rclient/src/rhoid.js index dc18169..1cd4dd1 100644 --- a/rclient/src/rhoid.js +++ b/rclient/src/rhoid.js @@ -8,9 +8,11 @@ https://github.com/rchain/rchain/blob/27f76eb02ab2d83bf2bc9cd766157c4723db0854/r // @flow /* global require, exports, module, Buffer */ -const { Blake2b256, Hex } = require('rchain-api'); +const { RholangCrypto, Hex } = require('rchain-api'); const base32 = require('base32-encoding'); +const { blake2b256Hash } = RholangCrypto; + // human-oriented base-32 encoding by Zooko 2002 - 2009 const zbase32 = buf => base32.stringify(buf, 'ybndrfg8ejkmcpqxot1uwisza345h769'); @@ -21,7 +23,7 @@ const testCase = { function test(item) { const uri = pkURI(item.pk); - const hash = Blake2b256.hash(item.pk); + const hash = blake2b256Hash(item.pk); console.log({ pk: item.pk.toString('hex'), hash: Hex.encode(hash), @@ -39,7 +41,7 @@ function test(item) { */ exports.pkURI = pkURI; function pkURI(pk /*: Buffer*/) { - const hash = Blake2b256.hash(pk); + const hash = blake2b256Hash(pk); return buildURI(Buffer.from(hash)); } diff --git a/rclient/src/secretStorage.js b/rclient/src/secretStorage.js index 95d888a..78675f2 100644 --- a/rclient/src/secretStorage.js +++ b/rclient/src/secretStorage.js @@ -9,7 +9,7 @@ const scrypt = require('scrypt.js'); // ISSUE: just use crypto.script? const crypto = require('crypto'); const assert = require('assert'); -const { Keccak256 } = require('rchain-api'); +const { keccak256Hash } = require('rchain-api').RholangCrypto; /*:: @@ -88,7 +88,7 @@ function decrypt( toBuf(item.crypto.ciphertext), ]); // console.log('MAC Body', MACBody.toString('hex')); - const MAC = Buffer.from(Keccak256.hash(MACBody)); + const MAC = Buffer.from(keccak256Hash(MACBody)); // console.log('MAC', MAC.toString('hex')); const diff = MAC.compare(toBuf(item.crypto.mac)); // console.log('MAC diff?', diff); @@ -142,7 +142,7 @@ function encrypt( ciphertext, ]); // console.log('MAC Body', MACBody.toString('hex')); - const mac = Buffer.from(Keccak256.hash(MACBody)).toString('hex'); + const mac = Buffer.from(keccak256Hash(MACBody)).toString('hex'); // console.log('MAC', MAC.toString('hex')); const item = { diff --git a/src/RHOCore.js b/src/RHOCore.js index 97ea817..a6cff65 100644 --- a/src/RHOCore.js +++ b/src/RHOCore.js @@ -138,7 +138,7 @@ function wrapHash( // as well as URLs. // The flow type is given below: export type JsonExt = - | JsonPrimitive + JsonPrimitive | JsonExtArray | JsonExtObject ; @@ -301,18 +301,40 @@ function toRholang(par /*: IPar */) /*: string */ { /** * Get printable form of unforgeable name, given id. + * + * @memberof RHOCore */ -exports.unforgeableWithId = unforgeableWithId; function unforgeableWithId(id /*: Uint8Array */) { const bytes = Writer.create().bytes(id).finish().slice(1); return `Unforgeable(0x${hex.encode(bytes)})`; } +exports.unforgeableWithId = unforgeableWithId; -exports.prettyPrivate = prettyPrivate; -function prettyPrivate(par /*: IPar */) { - if (!(par.ids && par.ids.length && par.ids[0].id)) { throw new Error('expected GPrivate'); } +function prettyPrivate(par /*: IPar */) /*: string */{ + if (!(par.ids && par.ids.length && par.ids[0].id)) { + return toRholang(par); + } return unforgeableWithId(par.ids[0].id); } +exports.prettyPrivate = prettyPrivate; + +exports.getIdFromUnforgeableName = getIdFromUnforgeableName; +/** + * Convert the ack channel into a HEX-formatted unforgeable name + * + * @param par: JSON-ish Par data: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto + * @return HEX-formatted string of unforgeable name's Id + * @throws Error if the Par does not represent an unforgeable name + * + * @memberof RHOCore + */ +function getIdFromUnforgeableName(par /*: IPar */) /*: string */ { + if (par.ids && par.ids.length === 1 && par.ids[0].id) { + return Buffer.from(par.ids[0].id).toString('hex'); + } + throw new Error('Provided Par object does not represent a single unforgeable name'); +} + exports.rhol = rhol; /** diff --git a/src/assets.js b/src/assets.js index e579589..e9943c2 100644 --- a/src/assets.js +++ b/src/assets.js @@ -9,6 +9,8 @@ exports.link = link; /** * link a string asset * + * @private + * * With respect to ocap discipline, we regard this as part of the * module loading infrastructure rather than a run-time operation. * diff --git a/src/loading.js b/src/loading.js index 5cb7b86..2ab5cd7 100644 --- a/src/loading.js +++ b/src/loading.js @@ -6,7 +6,7 @@ const { URL } = require('url'); const Hex = require('./hex'); -const { Ed25519 } = require('./signing'); +const { Ed25519keyPair } = require('./signing'); const { pollAt } = require('./proxy'); const { Block, SignDeployment } = require('./rnodeAPI'); @@ -121,7 +121,7 @@ async function integrationTest(argv, { readFileSync, clock, rnode, setTimeout }) const dur = 3 * 1000; const delay = _i => new Promise((resolve) => { setTimeout(resolve, dur); }); - const key = Ed25519.keyPair(Hex.decode('11'.repeat(32))); + const key = Ed25519keyPair(Hex.decode('11'.repeat(32))); function payFor(d0 /*: DeployInfo*/) { return SignDeployment.sign(key, { ...d0, diff --git a/src/proxy.js b/src/proxy.js index cb338e1..ac547ea 100644 --- a/src/proxy.js +++ b/src/proxy.js @@ -58,6 +58,8 @@ interface ProxyOpts extends SendOpts { * a call and listening for the response. * @param opts.unary: whether to use unary calling conventions. * @param opts.predeclare: names to pre-declare after `return` + * + * @memberof RegistryProxy */ exports.makeProxy = makeProxy; function makeProxy( @@ -86,6 +88,8 @@ function makeProxy( * @param opts.delay: an optional async function to call between sending * a call and listening for the response. * @param opts.unary: whether to use unary calling conventions. + * + * @memberof RegistryProxy */ exports.sendCall = sendCall; async function sendCall( @@ -119,11 +123,26 @@ async function sendCall( { target, method, args }, { ...opts, chanArgs }, ); - console.log({ deployData, note: 'placeholder term' }); + console.log(term); + return runRholang(term, returnChan, deployData, opts, method || '?'); +} + + +exports.runRholang = runRholang; +async function runRholang( + term /*: string */, + returnChan /*: IPar */, + deployData /*: $ReadOnly */, + opts /*: SendOpts */, + label /*: string */ = '', +) /**/ { + const { rnode } = opts; + //@@@@@@@this can't work with signed deploys + // console.log({ deployData, note: 'placeholder term' }); const deployResult = await rnode.doDeploy({ ...deployData, term }, true); - console.log({ deployResult }); + console.log({ deployResult }); // ISSUE: return block hash to caller? - const blockResults = await pollAt(returnChan, method || '?', { delay: opts.delay, rnode }); + const blockResults = await pollAt(returnChan, label, { delay: opts.delay, rnode }); return Block.firstData(blockResults); } @@ -160,6 +179,8 @@ async function pollAt( * @param opts * @param opts.unary: For better compositionality, JS args are combined into one * list arg on the rholang side. + * + * @memberof RegistryProxy */ exports.callSource = callSource; function callSource( @@ -182,6 +203,7 @@ function callSource( /** * Caller is responsible for converting pieces to rholang. * + * @private * @param m: message * @param m.target: a rholang URI expression: `rho:id:...` * @param m.method: [] or ["eat"] @@ -211,6 +233,5 @@ function rhoCall({ target, method, args }, predeclare, insertSigned) { } } `; - console.log(term); return term; } diff --git a/src/revAddress.js b/src/revAddress.js index 8bfccc2..2ab4c15 100644 --- a/src/revAddress.js +++ b/src/revAddress.js @@ -1,7 +1,7 @@ /* global require, exports, Buffer */ const base58 = require('bs58'); -const { Blake2b256 } = require('./signing'); +const { blake2b256Hash } = require('./signing').RholangCrypto; const h2b = require('./hex').decode; const checksumLength = 4; @@ -50,7 +50,7 @@ exports.RevAddress = RevAddress; exports.fromPublicKey = fromPublicKey; function fromPublicKey(pk /*: PublicKey */) /*: RevAddr */ { if (keyLength !== pk.length) { throw new Error(`bad public key length: ${pk.length}`); } - const keyHash = Blake2b256.hash(pk); + const keyHash = blake2b256Hash(pk); const payload = concat(prefix, keyHash); const checksum = computeChecksum(payload); const s = base58.encode(Buffer.from(concat(payload, checksum))); @@ -66,7 +66,7 @@ function fromPublicKey(pk /*: PublicKey */) /*: RevAddr */ { } function computeChecksum(toCheck /*: Bytes */) /*: Bytes*/ { - return Blake2b256.hash(toCheck).slice(0, checksumLength); + return blake2b256Hash(toCheck).slice(0, checksumLength); } function concat(a, b) { diff --git a/src/rnodeAPI.js b/src/rnodeAPI.js index 8d86739..fc5a586 100644 --- a/src/rnodeAPI.js +++ b/src/rnodeAPI.js @@ -25,7 +25,9 @@ const { } = require('../protobuf/CasperMessage').coop.rchain.casper.protocol; const RHOCore = require('./RHOCore'); const Hex = require('./hex'); -const { Blake2b256, Ed25519 } = require('./signing'); +const { RholangCrypto } = require('./signing'); + +const { blake2b256Hash, ed25519Verify } = RholangCrypto; const def = obj => Object.freeze(obj); // cf. ocap design note @@ -84,6 +86,7 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * @param d.deployer - public key (of validating node?) as in doDeploy * @param d.timestamp - timestamp (ms) as in doDeploy * @param nameQty - how many names to preview? (max: 1024) + * @memberof RNode */ async function previewPrivateIds( { user, timestamp } /*: $ReadOnly<{ user?: Uint8Array, timestamp?: number }> */, @@ -105,9 +108,10 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * @param d.user - public key (of validating node?) as in doDeploy * @param d.timestamp - timestamp (ms) as in doDeploy * @param nameQty - how many names to preview? (max: 1024) + * @memberof RNode */ function previewPrivateChannels( - { user, timestamp } /*: { user: Uint8Array, timestamp: number } */, + { user, timestamp } /*: $ReadOnly<{ user?: Uint8Array, timestamp?: number }> */, nameQty /*: number*/, ) /*: Promise */{ return previewPrivateIds({ user, timestamp }, nameQty) @@ -181,6 +185,7 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * @param nameObj: JSON-ish data: string, number, {}, [], ... * @return promise for [DataWithBlockInfo] * @throws Error if status is not Success + * @deprecated */ function listenForDataAtPublicName(nameObj /*: JSData */, depth /*: number */ = 1) { return listenForDataAtName(RHOCore.fromJSData(nameObj), depth); @@ -193,6 +198,7 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * @param nameId: Hex string representing an UnforgeableName's Id * @return promise for [DataWithBlockInfo] * @throws Error if status is not Success + * @deprecated */ function listenForDataAtPrivateName(nameId /*: string */, depth /*: number */ = 1) { // Convert the UnforgeableName into a byte array @@ -216,6 +222,7 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ par /*: IPar */, depth /*: number */ = 1, ) /*: Promise */ { + // console.log('listen', { par: JSON.stringify(par) }); const channelRequest = { depth, name: par, @@ -225,6 +232,7 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ ListeningNameDataResponse, send(f => client.listenForDataAtName(channelRequest, f)), ); + // console.log('listen', { response }); return response.blockResults; } @@ -236,6 +244,7 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * @param nameObjs a list of names (strings) * @return promise for ContinuationsWithBlockInfo * @throws Error if status is not Success + * @deprecated */ function listenForContinuationAtPublicName(nameObjs /*: string[] */, depth /*: number */ = 1) { return listenForContinuationAtName(nameObjs.map(RHOCore.fromJSData), depth); @@ -248,6 +257,7 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * @param nameIds a list hex strings representing the unforgeable names' Ids * @return promise for ContinuationsWithBlockInfo * @throws Error if status is not Success + * @deprecated */ function listenForContinuationAtPrivateName(nameIds /*: string[] */, depth /*: number */ = 1) { // Convert the UnforgeableNames into a byte arrays @@ -332,44 +342,32 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ listenForContinuationAtPublicName, getBlock, getAllBlocks, - getIdFromUnforgeableName, previewPrivateIds, previewPrivateChannels, }); } -exports.getIdFromUnforgeableName = getIdFromUnforgeableName; -/** - * Convert the ack channel into a HEX-formatted unforgeable name - * - * @param par: JSON-ish Par data: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto - * @return HEX-formatted string of unforgeable name's Id - * @throws Error if the Par does not represent an unforgeable name - */ -function getIdFromUnforgeableName(par /*: IPar */) /*: string */ { - if (par.ids && par.ids.length === 1 && par.ids[0].id) { - return Buffer.from(par.ids[0].id).toString('hex'); - } - throw new Error('Provided Par object does not represent a single unforgeable name'); -} - - function firstBlockData(blockResults /*: DataWithBlockInfo[] */) { const _ = DataWithBlockInfo; // mark used // console.log({ blockResults }); if (!blockResults.length) { throw new Error('no blocks found'); } return RHOCore.toJSData(firstBlockProcess(blockResults)); } -exports.Block = Object.freeze({ firstData: firstBlockData }); +exports.Block = Object.freeze({ + firstData: firstBlockData, + firstProcess: firstBlockProcess, +}); // Get the first piece of data from listenForDataAtName -function firstBlockProcess(blockResults) { +function firstBlockProcess(blockResults /*: DataWithBlockInfo[] */) { // console.log('found:', JSON.stringify(blockResults, null, 2)); const ea = [].concat(...blockResults.map(br => br.postBlockData)); // console.log('ea: ', JSON.stringify(ea, null, 2)); - const good = ea.filter(it => it.exprs.length > 0 || it.bundles.length > 0 || it.ids.length > 0); + const good = ea.filter(it => (it.exprs || []).length > 0 + || (it.bundles || []).length > 0 + || (it.ids || []).length > 0); // console.log('good:'); // console.log(JSON.stringify(good, null, 2)); return good[0]; @@ -390,21 +388,32 @@ const SignDeployment = (() => { const clear = deployData => fill(deployData)(null, null, null); + /** + * @name sign + * + * @memberof SignDeployment + */ function signD(key /*: KeyPair */, deployData /*: DeployData*/)/*: DeployData*/ { const toSign = DeployData.encode(clear(deployData)).finish(); - const hash = Blake2b256.hash(toSign); + const hash = blake2b256Hash(toSign); const signature = key.signBytes(hash); return fill(deployData)(Hex.decode(key.publicKey()), signature, algName); } + /** + * Verify Deployment + * @name verify + * + * @memberof SignDeployment + */ function verifyD(deployData /*: DeployData*/)/*: boolean */ { if (deployData.sigAlgorithm !== algName) { throw new Error(`unsupported: ${deployData.sigAlgorithm}`); } const toVerify = DeployData.encode(clear(deployData)).finish(); - const hash = Blake2b256.hash(toVerify); - return Ed25519.verify(hash, deployData.sig, deployData.deployer); + const hash = blake2b256Hash(toVerify); + return ed25519Verify(hash, deployData.sig, deployData.deployer); } return Object.freeze({ sign: signD, verify: verifyD }); @@ -425,6 +434,7 @@ function send/*:: */(calling /*: Callback => mixed*/) /*: Promise */{ const callback = (err, result) => { if (err) { reject(err); + return; } if (typeof result === 'undefined') { throw new TypeError('must give err or result'); } resolve(result); diff --git a/src/signing.js b/src/signing.js index d21a39f..45628d8 100644 --- a/src/signing.js +++ b/src/signing.js @@ -12,7 +12,7 @@ export type Signature = Bytes; export type PrivateKey = Bytes; export type PublicKey = Bytes; -export type KeyPair = $Call; +export type KeyPair = $Call; */ // ref https://nodejs.org/api/util.html#util_custom_inspection_functions_on_objects @@ -33,15 +33,15 @@ const def = obj => Object.freeze(obj); // cf. ocap design note * Build key pair from seed. * * @param seed 32 bytes, as from crypto.randombytes(32) - * @memberof Ed25519 + * */ -function keyPair(seed /*: PrivateKey */) { +function Ed25519keyPair(seed /*: PrivateKey */) { const key = sign.keyPair.fromSeed(seed); const t2b = text => Buffer.from(text); // TODO const toString = () => ``; /** - * @memberof keyPair + * @memberof Ed25519keyPair */ function signBytes(bytes /*: Uint8Array */) /*: Signature */ { return sign.detached(bytes, key.secretKey); @@ -51,19 +51,21 @@ function keyPair(seed /*: PrivateKey */) { // TODO toString, signBytes, /** - * @memberof keyPair + * @memberof Ed25519keyPair */ signBytesHex(bs /*: Uint8Array*/) /*: HexStr */ { return b2hx(signBytes(bs)); }, /** - * @memberof keyPair + * @memberof Ed25519keyPair */ signText(text /*: string*/) /*: Signature */ { return signBytes(t2b(text)); }, /** - * @memberof keyPair + * @memberof Ed25519keyPair */ signTextHex(text /*: string*/) /*: HexStr */ { return b2hx(signBytes(t2b(text))); }, /** - * @memberof keyPair + * ISSUE: if the caller wants the bytes, we go bytes -> hex -> bytes + * + * @memberof Ed25519keyPair */ publicKey() /*: HexStr */ { return b2hx(key.publicKey); }, @@ -71,67 +73,101 @@ function keyPair(seed /*: PrivateKey */) { // TODO [inspect.custom]: toString }); } +exports.Ed25519keyPair = Ed25519keyPair; /** * Verify ed25519 signature * - * @memberof Ed25519 + * @param message any number of bytes (TODO: test!) + * @param sig 64 byte ed25519 signature over message + * @param publicKey 32 byte ed25519 public key + * + * @return indicates whether the signature is valid + * + * @example + * + * const publicKey = Hex.decode( + * '288755c48c3951f89c5f0ffe885088dc0970fd935bc12adfdd81f81bb63d6219'); + * const message = Hex.decode( + * 'a6da46a1dc7ed715d4cd6472a736249a4d11142d160dbef9f20ae493de908c4e'); + * const sig = Hex.decode( + * 'd0a909078ce8b8706a641b07a0d4fe2108064813ce42009f108f89c2a3f4864a' + + * 'a1a510d6dfccad3b62cd610db0bfe82bcecb08d813997fa7df14972f56017e0b'); + * + * assert(RholangCrypto.ed25519Verify(message, sig, publicKey)); + * + * @memberof RholangCrypto */ -function verify( - message /*: Uint8Array*/, - sig /*: Signature */, - publicKey /*: PublicKey */, +function ed25519Verify( + message /*: Uint8Array */, + sig /*: Uint8Array */, + publicKey /*: Uint8Array */, ) /*: boolean */ { return sign.detached.verify(message, sig, publicKey); } -exports.Ed25519 = Object.freeze({ keyPair, verify }); -exports.SHA256 = Object.freeze({ hash: sha256Hash }); /** - * Compute a SHA256 hash over some data, the way that it will be computed in Rholang + * SHA-2 256 bit cryptographic hash function * - * @param serializedData: Uint8Array of serialized Rholang data, used to compute the hash - * @return Uint8Array of bytes representing the computed hash - * @memberof SHA256 + * @param input any number of bytes + * @return 256 bit (32 byte) hash + * + * @memberof RholangCrypto */ -function sha256Hash(serializedData /*: Uint8Array*/) /*: Uint8Array*/ { +function sha256Hash(input /*: Uint8Array*/) /*: Uint8Array*/ { const sha256 = crypto.createHash('sha256'); - sha256.update(Buffer.from(serializedData)); + sha256.update(Buffer.from(input)); return Uint8Array.from(sha256.digest()); } /** - * Compute a Keccak-256 hash over some data, the way that it will be computed in Rholang + * Keccak 256 bit cryptographic hash function (aka SHA-3) + * + * @param input any number of bytes + * @return 256 bit (32 byte) hash * - * @param serializedData: Uint8Array of serialized Rholang data, used to compute the hash - * @return Uint8Array of bytes representing the computed hash + * @memberof RholangCrypto */ -function keccak256Hash(serializedData /*: Uint8Array*/) /*: Uint8Array*/ { - return new Uint8Array(keccak256.arrayBuffer(serializedData)); +function keccak256Hash(input /*: Uint8Array*/) /*: Uint8Array*/ { + return new Uint8Array(keccak256.arrayBuffer(input)); } -exports.Keccak256 = { hash: keccak256Hash }; -exports.Blake2b256 = Object.freeze({ hash: blake2b256Hash }); /** - * Compute a Blake2b-256 hash over some data, the way that it will be computed in Rholang + * Blake2b 256 bit cryptographic hash function * - * @param serializedData: Uint8Array of serialized Rholang data, used to compute the hash - * @return Uint8Array of bytes representing the computed hash + * @param input any number of bytes + * @return 256 bit (32 byte) hash + * + * @memberof RholangCrypto */ -function blake2b256Hash(serializedData /*: Uint8Array*/) /*: Uint8Array*/ { +function blake2b256Hash(input /*: Uint8Array*/) /*: Uint8Array*/ { const blake2b256 = blake2.createHash('blake2b', { digestLength: 32 }); - blake2b256.update(serializedData); + blake2b256.update(input); return Uint8Array.from(blake2b256.digest()); } +/** + * Cryptographic functions from Rholang. + * + * refs: + * - [RChain Cryptography Specification][cspec] May 2018 + * - [rholang/examples/tut-hash-functions.rho][htut] Aug 2018 + * + * [cspec]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/112721930/Cryptography+Specification + * + * [htut]: https://github.com/rchain/rchain/blob/a582f94/rholang/examples/tut-hash-functions.rho + */ +const RholangCrypto = Object.freeze({ blake2b256Hash, sha256Hash, keccak256Hash, ed25519Verify }); +exports.RholangCrypto = RholangCrypto; + function integrationTest({ randomBytes }) { const seed = randomBytes(32); - const pair1 = keyPair(seed); + const pair1 = Ed25519keyPair(seed); // TODO console.log('inspect keyPair:', pair1); // TODO console.log('keyPair.toString():', pair1.toString()); console.log('public key:', pair1.publicKey()); diff --git a/test/RHOCore.test.js b/test/RHOCore.test.js index 6537e07..5db0589 100644 --- a/test/RHOCore.test.js +++ b/test/RHOCore.test.js @@ -1,17 +1,14 @@ -/* global require, test, expect */ +/* global require */ /* eslint-disable object-curly-newline */ const { URL } = require('url'); const ttest = require('tape'); -const { RHOCore, Hex, Ed25519 } = require('..'); +const { RHOCore, Hex, Ed25519keyPair } = require('..'); const { Par, GPrivate } = require('../protobuf/RhoTypes'); const testData = require('./RHOCoreSuite.json'); -// IOU docs... -const likeLoad = { keepCase: true, longs: String, enums: String, defaults: true, oneofs: true }; - function testRHOCore() { const h2b = Hex.decode; @@ -94,7 +91,7 @@ function testRHOCore() { }, 'BasicWallet transfer signature': (test) => { const destid = h2b('476ec6197e7106e0f0c64fc4cc39e5439658f6b8540b95765496cfe01e92c6b4'); - const k1 = Ed25519.keyPair(h2b('f6664a95992958bbfeb7e6f50bbca2aa7bfd015aec79820caf362a3c874e9247')); + const k1 = Ed25519keyPair(h2b('f6664a95992958bbfeb7e6f50bbca2aa7bfd015aec79820caf362a3c874e9247')); // BasicWallet.transfer signature is over these params: const [nonce, amount, dest] = [12, 100, GPrivate.fromObject({ id: destid })]; diff --git a/test/liveRHOCoreTest.js b/test/liveRHOCoreTest.js index 5581089..7d3cfc8 100644 --- a/test/liveRHOCoreTest.js +++ b/test/liveRHOCoreTest.js @@ -1,26 +1,27 @@ /** Test RHOCore test suite data against live node. */ +// @flow + /* global require, module, Buffer */ const ttest = require('tape'); -const { RNode, RHOCore, b2h } = require('../index'); +const { RNode, RHOCore, Hex } = require('..'); const testData = require('./RHOCoreSuite.json'); const { runAndListen } = require('./testRNode'); const { rhol } = RHOCore; +const b2h = Hex.encode; + +/*:: +type Item = { data: Object, hex: string }; + */ function integrationTest({ endpoint, grpc, clock, rng }) { console.log({ endpoint }); const node = RNode(grpc, endpoint); - function mapValues(obj, f) { - return Object.entries(obj).reduce( - (acc, [k, v]) => ({ [k]: f(v), ...acc }), {}, - ); - } - - function byteArrayTest(item) { + function byteArrayTest(item /*: Item*/) { return (test) => { const returnChannel = rng().toString(36).substring(7); const term = rhol` @@ -29,10 +30,13 @@ function integrationTest({ endpoint, grpc, clock, rng }) { test.comment({ term }); runAndListen(term, returnChannel, clock().valueOf(), node) - .then((par) => { - const bytes = par.exprs[0].g_byte_array; - test.comment({ actual: b2h(bytes), expected: item.hex }); - test.equal(b2h(bytes), item.hex); + .then((bytes) => { + test.equal(typeof bytes, 'object'); + test.ok(bytes instanceof Uint8Array); + if (bytes instanceof Uint8Array) { + test.comment({ actual: b2h(bytes), expected: item.hex }); + test.equal(b2h(bytes), item.hex); + } test.end(); }) .catch((oops) => { @@ -42,8 +46,10 @@ function integrationTest({ endpoint, grpc, clock, rng }) { }; } - Object.entries(mapValues(testData, byteArrayTest)) - .forEach(([desc, fn]) => ttest(desc, fn)); + Object.entries(testData).forEach(([desc, item]) => { + /* $FlowFixMe */ + ttest(desc, byteArrayTest(item)); + }); } diff --git a/test/testRNode.js b/test/testRNode.js index 55930db..00dd62d 100644 --- a/test/testRNode.js +++ b/test/testRNode.js @@ -1,10 +1,17 @@ /* global require, module, exports */ +// @flow + const ttest = require('tape'); -const api = require('../index'); +const api = require('..'); + +const { RNode, RegistryProxy, SignDeployment, RHOCore, Hex } = api; +const { RholangCrypto, Ed25519keyPair } = api; -const { RNode, SignDeployment, RHOCore, Hex } = api; -const { Ed25519, SHA256, Keccak256, Blake2b256 } = api; +const { sha256Hash, keccak256Hash, blake2b256Hash } = RholangCrypto; +/*:: +import type { JsonExt } from '..'; + */ /** * Run unit tests plus supplemental tests. @@ -42,25 +49,27 @@ const defaultSec = Hex.decode('b18e1d0045995ec3d010c387ccfeb984d783af8fbb0f40fa7 function netTests({ grpc, clock, rng }) { const localNode = () => RNode(grpc, { host: 'localhost', port: 40401 }); - function hashTest(test, fn, fname, isNormalTest = true) { + function hashTest(test, hashBytes, hashData, fname) { const returnChannel = rng().toString(36).substring(7); - const config = (isNormalTest) + const config = (hashBytes) ? { txt: 'deadbeef', func: 'hexToBytes' } : { txt: 'testtest', func: 'toByteArray' }; const hashProc = `@"${fname}"!("${config.txt}".${config.func}(), "${returnChannel}")`; runAndListen(hashProc, returnChannel, clock().valueOf(), localNode(), test) - .then((rholangHash) => { - if (isNormalTest) { - const serializedData = Hex.decode(config.txt); - test.deepEqual(fn(serializedData), Uint8Array.from(rholangHash.exprs[0].g_byte_array)); - } else { - test.equal(fn('testtest'), Hex.encode(rholangHash.exprs[0].g_byte_array)); + .then((value) => { + test.ok(value instanceof Uint8Array); + if (!(value instanceof Uint8Array)) { throw new Error(`Uint8array expected: ${value}`); } + if (hashBytes) { + const bs = Hex.decode(config.txt); + test.deepEqual(hashBytes(bs), value); + } else if (hashData) { + test.equal(hashData('testtest'), Hex.encode(value)); } test.end(); }) .catch((oops) => { - test.equal(oops, 0); + test.fail(oops.message); test.end(); }); } @@ -70,7 +79,7 @@ function netTests({ grpc, clock, rng }) { const term = 'new test in { contract test(return) = { return!("test") } }'; const timestamp = clock().valueOf(); - const key = Ed25519.keyPair(defaultSec); + const key = Ed25519keyPair(defaultSec); localNode().doDeploy(payFor({ term, timestamp }, key), true).then((results) => { test.equal(results.slice(0, 'Success'.length), 'Success'); test.end(); @@ -97,46 +106,38 @@ function netTests({ grpc, clock, rng }) { }); }, 'simplified SHA256 hashing': (test) => { - hashTest(test, RHOCore.wrapHash(SHA256.hash), 'sha256hash', false); + hashTest(test, null, RHOCore.wrapHash(sha256Hash), 'sha256Hash'); }, 'simplified Keccak256 hashing': (test) => { - hashTest(test, RHOCore.wrapHash(Keccak256.hash), 'keccak256hash', false); + hashTest(test, null, RHOCore.wrapHash(keccak256Hash), 'keccak256Hash'); }, 'simplified Blake2b256 hashing': (test) => { - hashTest(test, RHOCore.wrapHash(Blake2b256.hash), 'blake2b256hash', false); + hashTest(test, null, RHOCore.wrapHash(blake2b256Hash), 'blake2b256Hash'); }, 'normal SHA256 hashing': (test) => { - hashTest(test, SHA256.hash, 'SHA256.hash', true); + hashTest(test, sha256Hash, null, 'sha256Hash'); }, 'normal Keccak256 hashing': (test) => { - hashTest(test, Keccak256.hash, 'keccak256.hash', true); + hashTest(test, keccak256Hash, null, 'keccak256Hash'); }, 'normal Blake2b256 hashing': (test) => { - hashTest(test, Blake2b256.hash, 'Blake2b256.hash', true); + hashTest(test, blake2b256Hash, null, 'blake2b256Hash'); }, }; } exports.runAndListen = runAndListen; -function runAndListen( - term, returnChannel, timestamp, - node, test = null, -) { - const key = Ed25519.keyPair(defaultSec); - // console.log("run:", { term, returnChannel }); - return node.doDeploy(payFor({ term, timestamp }, key), true).then((results) => { - if (test) { test.equal(results.slice(0, 'Success'.length), 'Success'); } - - // Get the generated result from the channel - return node.listenForDataAtPublicName(returnChannel); - }).then((blockResults) => { - if (test) { test.notEqual(blockResults.length, 0); } - - const lastBlock = blockResults.slice(-1).pop(); - const lastDatum = lastBlock.postBlockData.slice(-1).pop(); - return lastDatum; - }); +async function runAndListen( + term /*: string */, returnChannel /*: string*/, timestamp /*: number*/, + node /*: any */, _test /*: any*/, // KLUDGE: any +) /*: Promise> */ { + const key = Ed25519keyPair(defaultSec); + + return RegistryProxy.runRholang( + term, RHOCore.fromJSData(returnChannel), payFor({ term, timestamp }, key), + { rnode: node }, + ); } diff --git a/test/testSigning.js b/test/testSigning.js index 0dabe47..30f6f24 100644 --- a/test/testSigning.js +++ b/test/testSigning.js @@ -3,7 +3,9 @@ const ttest = require('tape'); const { DeployData } = require('../protobuf/CasperMessage').coop.rchain.casper.protocol; -const { Ed25519, Hex, SignDeployment } = require('..'); +const { Ed25519keyPair, RholangCrypto, Hex, SignDeployment } = require('..'); + +const { ed25519Verify } = RholangCrypto; function testSigning() { const cases = { @@ -31,7 +33,7 @@ function testSigning() { function check(info) { return (test) => { - const pair1 = Ed25519.keyPair(h2b(info.seedHex)); + const pair1 = Ed25519keyPair(h2b(info.seedHex)); test.deepEqual(info.pubKeyHex, pair1.publicKey()); @@ -39,7 +41,7 @@ function testSigning() { const sigHex = pair1.signBytesHex(message); test.deepEqual(info.sigHex, sigHex); - test.deepEqual(Ed25519.verify(message, h2b(info.sigHex), h2b(info.pubKeyHex)), true); + test.deepEqual(ed25519Verify(message, h2b(info.sigHex), h2b(info.pubKeyHex)), true); test.end(); }; } @@ -59,7 +61,7 @@ function testSigning() { '123b6e6577207465737420696e207b20636f6e747261637420746573742872657475726e29203d207b2072657475726e212822746573742229207d207d189eb29ff69f2d38014080ade204', ); - const dout = SignDeployment.sign(Ed25519.keyPair(defaultSec), d0); + const dout = SignDeployment.sign(Ed25519keyPair(defaultSec), d0); test.equal( b2h(dout.sig), 'b6e0c2077e3ae2794b7324b518b49a9aa597eb07207f84f6339db73aeb6852491b8a7e640fd17f88ee80b61e3d326ec87835feebbb7dacdeadf03f26deff350f', From 0ba6581327e17ca4807191dacd1b97698769d7e3 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Fri, 12 Apr 2019 11:47:56 -0500 Subject: [PATCH 08/36] docs: re-build --- docs/index.md | 911 ++++++++++++++++++++++++-------------------------- 1 file changed, 445 insertions(+), 466 deletions(-) diff --git a/docs/index.md b/docs/index.md index f658011..df2d224 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,123 +2,192 @@ ### Table of Contents -- [blake2b256Hash][2] - - [Parameters][3] -- [callSource][4] - - [Parameters][5] -- [makeProxy][6] - - [Parameters][7] -- [sendCall][8] - - [Parameters][9] -- [RNode][10] - - [Parameters][11] - - [createBlock][12] - - [doDeploy][13] +- [RholangCrypto][2] + - [blake2b256Hash][3] + - [Parameters][4] + - [ed25519Verify][5] + - [Parameters][6] + - [Examples][7] + - [keccak256Hash][8] + - [Parameters][9] + - [sha256Hash][10] + - [Parameters][11] +- [RegistryProxy][12] + - [callSource][13] - [Parameters][14] - - [getAllBlocks][15] + - [makeProxy][15] - [Parameters][16] - - [getBlock][17] + - [sendCall][17] - [Parameters][18] - - [listenForContinuationAtName][19] - - [Parameters][20] - - [listenForContinuationAtPrivateName][21] - - [Parameters][22] - - [listenForContinuationAtPublicName][23] - - [Parameters][24] - - [listenForDataAtName][25] - - [Parameters][26] - - [listenForDataAtPrivateName][27] - - [Parameters][28] - - [listenForDataAtPublicName][29] - - [Parameters][30] -- [RHOCore][31] - - [fromJSData][32] +- [RNode][19] + - [Parameters][20] + - [createBlock][21] + - [doDeploy][22] + - [Parameters][23] + - [getAllBlocks][24] + - [Parameters][25] + - [getBlock][26] + - [Parameters][27] + - [listenForContinuationAtName][28] + - [Parameters][29] + - [listenForContinuationAtPrivateName][30] + - [Parameters][31] + - [listenForContinuationAtPublicName][32] - [Parameters][33] - - [rhol][34] + - [listenForDataAtName][34] - [Parameters][35] - - [toByteArray][36] + - [listenForDataAtPrivateName][36] - [Parameters][37] - - [toJSData][38] + - [listenForDataAtPublicName][38] - [Parameters][39] - - [toRholang][40] + - [previewPrivateChannels][40] - [Parameters][41] -- [RevAddress][42] - - [fromPublicKey][43] - - [Parameters][44] -- [getIdFromUnforgeableName][45] - - [Parameters][46] -- [keccak256Hash][47] - - [Parameters][48] -- [keyPair][49] - - [Parameters][50] - - [publicKey][51] - - [signBytes][52] + - [previewPrivateIds][42] + - [Parameters][43] +- [RHOCore][44] + - [dataToBytes][45] + - [fromJSData][46] + - [Parameters][47] + - [getIdFromUnforgeableName][48] + - [Parameters][49] + - [rhol][50] + - [Parameters][51] + - [toByteArray][52] - [Parameters][53] - - [signBytesHex][54] + - [toJSData][54] - [Parameters][55] - - [signData][56] + - [toRholang][56] - [Parameters][57] - - [signDataHex][58] + - [unforgeableWithId][58] - [Parameters][59] - - [signText][60] + - [wrapHash][60] - [Parameters][61] - - [signTextHex][62] - - [Parameters][63] -- [link][64] - - [Parameters][65] -- [previewPrivateChannels][66] - - [Parameters][67] -- [previewPrivateIds][68] - - [Parameters][69] -- [rhoCall][70] - - [Parameters][71] -- [sha256Hash][72] - - [Parameters][73] -- [simplifiedBlake2b256Hash][74] - - [Parameters][75] -- [simplifiedKeccak256Hash][76] - - [Parameters][77] -- [simplifiedSHA256Hash][78] - - [Parameters][79] -- [unforgeableWithId][80] -- [verify][81] - - [Parameters][82] - -## blake2b256Hash - -[src/hashing.js:44-48][83] - -Compute a Blake2b-256 hash over some data, the way that it will be computed in Rholang +- [Ed25519keyPair][62] + - [Parameters][63] + - [publicKey][64] + - [signBytes][65] + - [Parameters][66] + - [signBytesHex][67] + - [Parameters][68] + - [signText][69] + - [Parameters][70] + - [signTextHex][71] + - [Parameters][72] +- [RevAddress][73] + - [fromPublicKey][74] + - [Parameters][75] +- [SignDeployment][76] + - [sign][77] + - [verify][78] -### Parameters +## RholangCrypto + +[src/signing.js:163-163][79] + +Cryptographic functions from Rholang. + +refs: + +- [RChain Cryptography Specification][cspec] May 2018 +- [rholang/examples/tut-hash-functions.rho][htut] Aug 2018 + +[cspec]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/112721930/Cryptography+Specification + +[htut]: https://github.com/rchain/rchain/blob/a582f94/rholang/examples/tut-hash-functions.rho + +### blake2b256Hash + +[src/signing.js:146-150][80] + +Blake2b 256 bit cryptographic hash function + +#### Parameters + +- `input` **[Uint8Array][81]** any number of bytes + +Returns **[Uint8Array][81]** 256 bit (32 byte) hash -- `serializedData` **[Uint8Array][84]** : Uint8Array of serialized Rholang data, used to compute the hash +### ed25519Verify -Returns **[Uint8Array][84]** Uint8Array of bytes representing the computed hash +[src/signing.js:102-108][82] + +Verify ed25519 signature + +#### Parameters + +- `message` **[Uint8Array][81]** any number of bytes (TODO: test!) +- `sig` **[Uint8Array][81]** 64 byte ed25519 signature over message +- `publicKey` **[Uint8Array][81]** 32 byte ed25519 public key + +#### Examples + +```javascript +const publicKey = Hex.decode( + '288755c48c3951f89c5f0ffe885088dc0970fd935bc12adfdd81f81bb63d6219'); + const message = Hex.decode( + 'a6da46a1dc7ed715d4cd6472a736249a4d11142d160dbef9f20ae493de908c4e'); + const sig = Hex.decode( + 'd0a909078ce8b8706a641b07a0d4fe2108064813ce42009f108f89c2a3f4864a' + + 'a1a510d6dfccad3b62cd610db0bfe82bcecb08d813997fa7df14972f56017e0b'); + + assert(RholangCrypto.ed25519Verify(message, sig, publicKey)); +``` + +Returns **[boolean][83]** indicates whether the signature is valid + +### keccak256Hash + +[src/signing.js:133-135][84] + +Keccak 256 bit cryptographic hash function (aka SHA-3) + +#### Parameters -## callSource +- `input` **[Uint8Array][81]** any number of bytes -[src/proxy.js:155-155][85] +Returns **[Uint8Array][81]** 256 bit (32 byte) hash + +### sha256Hash + +[src/signing.js:119-123][85] + +SHA-2 256 bit cryptographic hash function + +#### Parameters + +- `input` **[Uint8Array][81]** any number of bytes + +Returns **[Uint8Array][81]** 256 bit (32 byte) hash + +## RegistryProxy + +[index.js:34-34][86] + +Proxy method calls to registered RChain channels. + +### callSource + +[src/proxy.js:185-185][87] Make a rholang term for looking up a target and calling a method. -### Parameters +#### Parameters - `msg` - `opts` - `opts.unary` : For better compositionality, JS args are combined into one list arg on the rholang side. -## makeProxy +### makeProxy -[src/proxy.js:64-64][86] +[src/proxy.js:64-64][88] Make an object that proxies method calls to registered RChain channels. For rholang calling conventions, see `callSource`. -### Parameters +#### Parameters - `target` : URI where channel is registered. - `deployData` : as in doDeploy (though term is ignored and replaced) @@ -130,15 +199,15 @@ For rholang calling conventions, see `callSource`. - `opts.unary` : whether to use unary calling conventions. - `opts.predeclare` : names to pre-declare after `return` -## sendCall +### sendCall -[src/proxy.js:92-92][87] +[src/proxy.js:94-94][89] Call a method on a registered RChain channel. For rholang calling conventions, see `callSource`. -### Parameters +#### Parameters - `target` : URI where channel is registered. - `deployData` : as in doDeploy (though term is ignored and replaced) @@ -150,28 +219,28 @@ For rholang calling conventions, see `callSource`. ## RNode -[src/rnodeAPI.js:64-335][88] +[src/rnodeAPI.js:70-348][90] Connect to an RChain node (RNode). ### Parameters - `grpc` **grpcT** access to the network: grpc instance from the node grpc package -- `endPoint` **{host: [string][89], port: [number][90]}** rnode gRPC service +- `endPoint` **{host: [string][91], port: [number][92]}** rnode gRPC service Returns **any** a thin wrapper around a gRPC client stub ### createBlock -[src/rnodeAPI.js:155-158][91] +[src/rnodeAPI.js:163-166][93] Creates a block on your node -Returns **[Promise][92]<[string][89]>** A promise for response message +Returns **[Promise][94]<[string][91]>** A promise for response message ### doDeploy -[src/rnodeAPI.js:132-148][93] +[src/rnodeAPI.js:140-156][95] Deploys a rholang term to a node @@ -187,35 +256,35 @@ Deploys a rholang term to a node - `deployData.phloLimit` - `deployData.phloPrice` - `deployData.validAfterBlockNumber` ???ISSUE??? -- `autoCreateBlock` **[boolean][94]** automatically create a new block after deploy transaction success +- `autoCreateBlock` **[boolean][83]** automatically create a new block after deploy transaction success -Returns **[Promise][92]<[string][89]>** A promise for messageISSUE: import / generate DeployData static type +Returns **[Promise][94]<[string][91]>** A promise for messageISSUE: import / generate DeployData static type ### getAllBlocks -[src/rnodeAPI.js:308-318][95] +[src/rnodeAPI.js:322-332][96] Retrieve the block summary for a series of blocks starting with the most recent, including the number of blocks specified by the block_depth #### Parameters -- `blockDepth` **[number][90]** : Number indicating the number of blocks to retrieve +- `blockDepth` **[number][92]** : Number indicating the number of blocks to retrieve - Throws **any** Error if blockDepth < 1 or no blocks were able to be retrieved -Returns **any** List of BlockInfoWithoutTuplespace structures for each block retrieved +Returns **[Promise][94]<BlockInfoWithoutTuplespace>** List of BlockInfoWithoutTuplespace structures for each block retrieved ### getBlock -[src/rnodeAPI.js:288-297][96] +[src/rnodeAPI.js:302-311][97] Retrieve a block with the tuplespace for a specific block hash #### Parameters -- `blockHash` **[string][89]** : String of the hash for the block being requested +- `blockHash` **[string][91]** : String of the hash for the block being requested - Throws **any** Error if the hash is blank or does not correspond to an existing block @@ -224,107 +293,158 @@ Returns **any** BlockInfo structure that will include all metadata and also incl ### listenForContinuationAtName -[src/rnodeAPI.js:267-278][97] +[src/rnodeAPI.js:281-292][98] Listen for a continuation at an individual name or JOINed set of names in the tuplespace #### Parameters -- `pars` **[Array][98]<IPar>** The names onwhich to listen -- `depth` **[number][90]** +- `pars` **[Array][99]<IPar>** The names onwhich to listen +- `depth` **[number][92]** - Throws **any** Error if status is not Success -Returns **[Promise][92]<ListeningNameContinuationResponse>** promise for DataWithBlockInfo +Returns **[Promise][94]<ListeningNameContinuationResponse>** promise for DataWithBlockInfo ### listenForContinuationAtPrivateName -[src/rnodeAPI.js:248-256][99] +[src/rnodeAPI.js:262-270][100] Listen for a continuation at an individual private name or JOINed set of private names in the tuplespace #### Parameters -- `nameIds` **[Array][98]<[string][89]>** a list hex strings representing the unforgeable names' Ids -- `depth` **[number][90]** (optional, default `1`) +- `nameIds` **[Array][99]<[string][91]>** a list hex strings representing the unforgeable names' Ids +- `depth` **[number][92]** (optional, default `1`) - Throws **any** Error if status is not Success Returns **any** promise for ContinuationsWithBlockInfo +**Meta** + +- **deprecated**: This is deprecated. + + ### listenForContinuationAtPublicName -[src/rnodeAPI.js:236-238][100] +[src/rnodeAPI.js:249-251][101] Listen for a continuation at an individual public name or JOINed set of public names in the tuplespace #### Parameters -- `nameObjs` **[Array][98]<[string][89]>** a list of names (strings) -- `depth` **[number][90]** (optional, default `1`) +- `nameObjs` **[Array][99]<[string][91]>** a list of names (strings) +- `depth` **[number][92]** (optional, default `1`) - Throws **any** Error if status is not Success Returns **any** promise for ContinuationsWithBlockInfo +**Meta** + +- **deprecated**: This is deprecated. + + ### listenForDataAtName -[src/rnodeAPI.js:211-225][101] +[src/rnodeAPI.js:221-237][102] Listen for data at a name in the RChain tuple-space. #### Parameters - `par` **IPar** : JSON-ish Par data. See protobuf/RhoTypes.proto -- `depth` **[number][90]** (optional, default `1`) +- `depth` **[number][92]** (optional, default `1`) - `blockDepth` : Number of blocks to look back in for the name to listen on - Throws **any** Error if status is not Success -Returns **[Promise][92]<[Array][98]<DataWithBlockInfo>>** : promise for DataWithBlockInfo\[] +Returns **[Promise][94]<[Array][99]<DataWithBlockInfo>>** : promise for DataWithBlockInfo\[] ### listenForDataAtPrivateName -[src/rnodeAPI.js:193-200][102] +[src/rnodeAPI.js:203-210][103] Listen for data at a PRIVATE name in the RChain tuple-space. #### Parameters -- `nameId` **[string][89]** : Hex string representing an UnforgeableName's Id -- `depth` **[number][90]** (optional, default `1`) +- `nameId` **[string][91]** : Hex string representing an UnforgeableName's Id +- `depth` **[number][92]** (optional, default `1`) - Throws **any** Error if status is not Success Returns **any** promise for [DataWithBlockInfo] +**Meta** + +- **deprecated**: This is deprecated. + + ### listenForDataAtPublicName -[src/rnodeAPI.js:181-183][103] +[src/rnodeAPI.js:190-192][104] Listen for data at a PUBLIC name in the RChain tuple-space. #### Parameters - `nameObj` **JSData** : JSON-ish data: string, number, {}, \[], ... -- `depth` **[number][90]** (optional, default `1`) +- `depth` **[number][92]** (optional, default `1`) - Throws **any** Error if status is not Success Returns **any** promise for [DataWithBlockInfo] +**Meta** + +- **deprecated**: This is deprecated. + + +### previewPrivateChannels + +[src/rnodeAPI.js:113-119][105] + +Ask rnode to compute top level private channels, given deploy parameters. + +#### Parameters + +- `d` **any** + - `d.user` public key (of validating node?) as in doDeploy + - `d.timestamp` timestamp (ms) as in doDeploy +- `nameQty` **[number][92]** how many names to preview? (max: 1024) + +Returns **[Promise][94]<[Array][99]<IPar>>** + +### previewPrivateIds + +[src/rnodeAPI.js:91-100][106] + +Ask rnode to compute ids of top level private names, given deploy parameters. + +#### Parameters + +- `d` **any** + - `d.timestamp` timestamp (ms) as in doDeploy + - `d.deployer` public key (of validating node?) as in doDeploy + - `d.user` +- `nameQty` **[number][92]** how many names to preview? (max: 1024) + +Returns **[Promise][94]<[Array][99]<[Buffer][107]>>** + ## RHOCore -[index.js:12-12][104] +[index.js:12-12][108] "we can detail a direct representation of JSON into a fragment of the rholang syntax referred to in the diagram @@ -332,9 +452,13 @@ below as RHOCore." -- \[Mobile process calculi for programming the blockchain[1] [1]: https://github.com/rchain/mobile-process-calculi-for-blockchain/blob/master/enter-the-blockchain.rst +### dataToBytes + +[src/RHOCore.js:99-99][109] + ### fromJSData -[src/RHOCore.js:23-78][105] +[src/RHOCore.js:27-82][110] Build Rholang expression from Javascript data. @@ -347,20 +471,35 @@ This is the inverse of `toJSData`. Returns **any** : A rholang term in Protobuf's JSON representation, i.e. `IPar` derived from RhoTypes.proto. +### getIdFromUnforgeableName + +[src/RHOCore.js:331-336][111] + +Convert the ack channel into a HEX-formatted unforgeable name + +#### Parameters + +- `par` **IPar** : JSON-ish Par data: [https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto][112] + + +- Throws **any** Error if the Par does not represent an unforgeable name + +Returns **[string][91]** HEX-formatted string of unforgeable name's Id + ### rhol -[src/RHOCore.js:276-286][106] +[src/RHOCore.js:345-355][113] Template tag for RHOCore interpolation #### Parameters -- `template` **[Array][98]<[string][89]>** -- `subs` **...[Array][98]<JsonExt<([URL][107] | GPrivate)>>** +- `template` **[Array][99]<[string][91]>** +- `subs` **...[Array][99]<JsonExt<([URL][114] | GPrivate)>>** ### toByteArray -[src/RHOCore.js:86-89][108] +[src/RHOCore.js:90-93][115] Turns a rholang term into a byte-array compatible with Rholang @@ -368,11 +507,11 @@ Turns a rholang term into a byte-array compatible with Rholang - `termObj` **IPar** -Returns **[Uint8Array][84]** +Returns **[Uint8Array][81]** ### toJSData -[src/RHOCore.js:137-201][109] +[src/RHOCore.js:169-233][116] Converts an RHOCore object back to JavaScript data @@ -380,11 +519,11 @@ Converts an RHOCore object back to JavaScript data - `par` **IPar** A RHOCore representation of a Rholang term -Returns **JsonExt<([URL][107] | GPrivate)>** JSON-serializable data +Returns **JsonExt<([URL][114] | GPrivate)>** JSON-serializable data ### toRholang -[src/RHOCore.js:214-267][110] +[src/RHOCore.js:246-299][117] Converts an RHOCore object into Rholang source form @@ -392,61 +531,34 @@ Converts an RHOCore object into Rholang source form - `par` **IPar** A RHOCore representation of a Rholang term -Returns **[string][89]** A rholang stringISSUE: Use intersection types to constrain par param further than IPar? +Returns **[string][91]** A rholang stringISSUE: Use intersection types to constrain par param further than IPar? -## RevAddress +### unforgeableWithId -[src/revAddress.js:34-34][111] +[src/RHOCore.js:307-310][118] -A RevAddress has a prefix, a keyHash, and a checksum. - -Use toString() to get base58 form. - -### fromPublicKey - -[src/revAddress.js:50-50][112] - -Compute REV Address +Get printable form of unforgeable name, given id. #### Parameters -- `pk` : ed25519 public key - -Returns **any** : RevAddressRefs: -[https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala][113] -[https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala#L16][114]- ISSUE: find RevAddress spec -- ISSUE: how to use tests as documentation? - -## getIdFromUnforgeableName +- `id` **[Uint8Array][81]** -[src/rnodeAPI.js:346-351][115] +### wrapHash -Convert the ack channel into a HEX-formatted unforgeable name - -### Parameters - -- `par` **IPar** : JSON-ish Par data: [https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto][116] - - -- Throws **any** Error if the Par does not represent an unforgeable name +[src/RHOCore.js:115-115][119] -Returns **[string][89]** HEX-formatted string of unforgeable name's Id - -## keccak256Hash - -[src/hashing.js:32-34][117] +#### Parameters -Compute a Keccak-256 hash over some data, the way that it will be computed in Rholang +- `jsData` : JS Data compatible with Rholang, used to compute the hash -### Parameters -- `serializedData` **[Uint8Array][84]** : Uint8Array of serialized Rholang data, used to compute the hash +- Throws **any** Error if the js_data contains a non-Rholang data structure -Returns **[Uint8Array][84]** Uint8Array of bytes representing the computed hash +Returns **any** HEX-formatted string representing the computed hash -## keyPair +## Ed25519keyPair -[src/signing.js:50-96][118] +[src/signing.js:38-75][120] Build key pair from seed. @@ -456,484 +568,351 @@ Build key pair from seed. ### publicKey -[src/signing.js:79-79][119] +[src/signing.js:70-70][121] + +ISSUE: if the caller wants the bytes, we go bytes -> hex -> bytes -Returns **Hex<PublicKey>** +Returns **HexStr<PublicKey>** ### signBytes -[src/signing.js:57-59][120] +[src/signing.js:46-48][122] #### Parameters -- `bytes` **[Uint8Array][84]** +- `bytes` **[Uint8Array][81]** Returns **Signature** ### signBytesHex -[src/signing.js:67-67][121] - -#### Parameters - -- `bytes` **[Uint8Array][84]** - -Returns **Hex<Signature>** - -### signData - -[src/signing.js:84-86][122] - -#### Parameters - -- `data` **JsonExt<([URL][107] | GPrivate)>** - -Returns **Signature** - -### signDataHex - -[src/signing.js:90-92][123] +[src/signing.js:56-56][123] #### Parameters -- `data` **JsonExt<([URL][107] | GPrivate)>** +- `bs` **[Uint8Array][81]** -Returns **Hex<Signature>** +Returns **HexStr<Signature>** ### signText -[src/signing.js:71-71][124] +[src/signing.js:60-60][124] #### Parameters -- `text` **[string][89]** +- `text` **[string][91]** Returns **Signature** ### signTextHex -[src/signing.js:75-75][125] +[src/signing.js:64-64][125] #### Parameters -- `text` **[string][89]** - -Returns **Hex<Signature>** - -## link +- `text` **[string][91]** -[src/assets.js:18-20][126] +Returns **HexStr<Signature>** -link a string asset - -With respect to ocap discipline, we regard this as part of the -module loading infrastructure rather than a run-time operation. - -An alternative implementation would be a pre-processor -that in-lines the contents of the linked data as constants. - -### Parameters - -- `name` **[string][89]** - -Returns **[string][89]** - -## previewPrivateChannels - -[src/rnodeAPI.js:105-111][127] - -Ask rnode to compute top level private channels, given deploy parameters. - -### Parameters - -- `d` **any** - - `d.user` public key (of validating node?) as in doDeploy - - `d.timestamp` timestamp (ms) as in doDeploy -- `nameQty` **[number][90]** how many names to preview? (max: 1024) - -Returns **[Promise][92]<[Array][98]<IPar>>** - -## previewPrivateIds - -[src/rnodeAPI.js:84-93][128] - -Ask rnode to compute ids of top level private names, given deploy parameters. - -### Parameters - -- `d` **any** - - `d.timestamp` timestamp (ms) as in doDeploy - - `d.deployer` public key (of validating node?) as in doDeploy - - `d.user` -- `nameQty` **[number][90]** how many names to preview? (max: 1024) - -Returns **[Promise][92]<[Array][98]<[Buffer][129]>>** - -## rhoCall - -[src/proxy.js:185-207][130] - -Caller is responsible for converting pieces to rholang. - -### Parameters - -- `m` **[Object][131]** : message - - `m.target` : a rholang URI expression: `rho:id:...` - - `m.method` : \[] or ["eat"] - - `m.args` : a list of rholang terms -- `predeclare` : names to pre-declare in addition to `return` - They are passed (deref'd to processes) to target - in reverse order. -- `insertSigned` : was `insertSigned` used to register the target? - -## sha256Hash - -[src/hashing.js:19-23][132] - -Compute a SHA256 hash over some data, the way that it will be computed in Rholang - -### Parameters - -- `serializedData` **[Uint8Array][84]** : Uint8Array of serialized Rholang data, used to compute the hash - -Returns **[Uint8Array][84]** Uint8Array of bytes representing the computed hash - -## simplifiedBlake2b256Hash - -[src/hashing.js:92-97][133] - -Compute a Blake2b-256 hash for some Rholang-compatible data, then return the -string representing a HEX-encoded hash - -### Parameters - -- `jsData` **JsonExt<([URL][107] | GPrivate)>** : JS Data compatible with Rholang, used to compute the hash - - -- Throws **any** Error if the js_data contains a non-Rholang data structure - -Returns **[string][89]** HEX-formatted string representing the computed hash - -## simplifiedKeccak256Hash - -[src/hashing.js:77-80][134] - -Compute a Keccak-256 hash for some Rholang-compatible data, then return the -string representing a HEX-encoded hash - -### Parameters - -- `jsData` **JsonExt<([URL][107] | GPrivate)>** : JS Data compatible with Rholang, used to compute the hash - - -- Throws **any** Error if the js_data contains a non-Rholang data structure - -Returns **[string][89]** HEX-formatted string representing the computed hash - -## simplifiedSHA256Hash - -[src/hashing.js:60-65][135] - -Compute a SHA256 hash for some Rholang-compatible data, then return the -string representing a HEX-encoded hash - -### Parameters +## RevAddress -- `jsData` **JsonExt<([URL][107] | GPrivate)>** : JS Data compatible with Rholang, used to compute the hash +[src/revAddress.js:34-34][126] +A RevAddress has a prefix, a keyHash, and a checksum. -- Throws **any** Error if the js_data contains a non-Rholang data structure +Use toString() to get base58 form. -Returns **[string][89]** HEX-formatted string representing the computed hash +### fromPublicKey -## unforgeableWithId +[src/revAddress.js:50-50][127] -[src/loading.js:117-117][136] +Compute REV Address -Get printable form of unforgeable name, given id. +#### Parameters -## verify +- `pk` : ed25519 public key -[src/signing.js:103-109][137] +Returns **any** : RevAddressRefs: +[https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala][128] +[https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala#L16][129]- ISSUE: find RevAddress spec +- ISSUE: how to use tests as documentation? -Verify ed25519 signature +## SignDeployment -### Parameters +[src/rnodeAPI.js:382-420][130] -- `message` **[Uint8Array][84]** -- `sig` **Signature** -- `publicKey` **PublicKey** +a port of casper/src/main/scala/coop/rchain/casper/SignDeployment.scala -Returns **Signature** +ISSUE: only ed25519 is supported. -[2]: #blake2b256hash +### sign -[3]: #parameters +[src/rnodeAPI.js:396-402][131] -[4]: #callsource +### verify -[5]: #parameters-1 +[src/rnodeAPI.js:410-417][132] -[6]: #makeproxy +Verify Deployment -[7]: #parameters-2 +[2]: #rholangcrypto -[8]: #sendcall +[3]: #blake2b256hash -[9]: #parameters-3 +[4]: #parameters -[10]: #rnode +[5]: #ed25519verify -[11]: #parameters-4 +[6]: #parameters-1 -[12]: #createblock +[7]: #examples -[13]: #dodeploy +[8]: #keccak256hash -[14]: #parameters-5 +[9]: #parameters-2 -[15]: #getallblocks +[10]: #sha256hash -[16]: #parameters-6 +[11]: #parameters-3 -[17]: #getblock +[12]: #registryproxy -[18]: #parameters-7 +[13]: #callsource -[19]: #listenforcontinuationatname +[14]: #parameters-4 -[20]: #parameters-8 +[15]: #makeproxy -[21]: #listenforcontinuationatprivatename +[16]: #parameters-5 -[22]: #parameters-9 +[17]: #sendcall -[23]: #listenforcontinuationatpublicname +[18]: #parameters-6 -[24]: #parameters-10 +[19]: #rnode -[25]: #listenfordataatname +[20]: #parameters-7 -[26]: #parameters-11 +[21]: #createblock -[27]: #listenfordataatprivatename +[22]: #dodeploy -[28]: #parameters-12 +[23]: #parameters-8 -[29]: #listenfordataatpublicname +[24]: #getallblocks -[30]: #parameters-13 +[25]: #parameters-9 -[31]: #rhocore +[26]: #getblock -[32]: #fromjsdata +[27]: #parameters-10 -[33]: #parameters-14 +[28]: #listenforcontinuationatname -[34]: #rhol +[29]: #parameters-11 -[35]: #parameters-15 +[30]: #listenforcontinuationatprivatename -[36]: #tobytearray +[31]: #parameters-12 -[37]: #parameters-16 +[32]: #listenforcontinuationatpublicname -[38]: #tojsdata +[33]: #parameters-13 -[39]: #parameters-17 +[34]: #listenfordataatname -[40]: #torholang +[35]: #parameters-14 -[41]: #parameters-18 +[36]: #listenfordataatprivatename -[42]: #revaddress +[37]: #parameters-15 -[43]: #frompublickey +[38]: #listenfordataatpublicname -[44]: #parameters-19 +[39]: #parameters-16 -[45]: #getidfromunforgeablename +[40]: #previewprivatechannels -[46]: #parameters-20 +[41]: #parameters-17 -[47]: #keccak256hash +[42]: #previewprivateids -[48]: #parameters-21 +[43]: #parameters-18 -[49]: #keypair +[44]: #rhocore -[50]: #parameters-22 +[45]: #datatobytes -[51]: #publickey +[46]: #fromjsdata -[52]: #signbytes +[47]: #parameters-19 -[53]: #parameters-23 +[48]: #getidfromunforgeablename -[54]: #signbyteshex +[49]: #parameters-20 -[55]: #parameters-24 +[50]: #rhol -[56]: #signdata +[51]: #parameters-21 -[57]: #parameters-25 +[52]: #tobytearray -[58]: #signdatahex +[53]: #parameters-22 -[59]: #parameters-26 +[54]: #tojsdata -[60]: #signtext +[55]: #parameters-23 -[61]: #parameters-27 +[56]: #torholang -[62]: #signtexthex +[57]: #parameters-24 -[63]: #parameters-28 +[58]: #unforgeablewithid -[64]: #link +[59]: #parameters-25 -[65]: #parameters-29 +[60]: #wraphash -[66]: #previewprivatechannels +[61]: #parameters-26 -[67]: #parameters-30 +[62]: #ed25519keypair -[68]: #previewprivateids +[63]: #parameters-27 -[69]: #parameters-31 +[64]: #publickey -[70]: #rhocall +[65]: #signbytes -[71]: #parameters-32 +[66]: #parameters-28 -[72]: #sha256hash +[67]: #signbyteshex -[73]: #parameters-33 +[68]: #parameters-29 -[74]: #simplifiedblake2b256hash +[69]: #signtext -[75]: #parameters-34 +[70]: #parameters-30 -[76]: #simplifiedkeccak256hash +[71]: #signtexthex -[77]: #parameters-35 +[72]: #parameters-31 -[78]: #simplifiedsha256hash +[73]: #revaddress -[79]: #parameters-36 +[74]: #frompublickey -[80]: #unforgeablewithid +[75]: #parameters-32 -[81]: #verify +[76]: #signdeployment -[82]: #parameters-37 +[77]: #sign -[83]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/hashing.js#L44-L48 "Source code on GitHub" +[78]: #verify -[84]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array +[79]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L163-L163 "Source code on GitHub" -[85]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/proxy.js#L155-L155 "Source code on GitHub" +[80]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L146-L150 "Source code on GitHub" -[86]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/proxy.js#L64-L64 "Source code on GitHub" +[81]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array -[87]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/proxy.js#L92-L92 "Source code on GitHub" +[82]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L102-L108 "Source code on GitHub" -[88]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L64-L335 "Source code on GitHub" +[83]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[89]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[84]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L133-L135 "Source code on GitHub" -[90]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[85]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L119-L123 "Source code on GitHub" -[91]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L155-L158 "Source code on GitHub" +[86]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/index.js#L34-L34 "Source code on GitHub" -[92]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise +[87]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/proxy.js#L185-L185 "Source code on GitHub" -[93]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L132-L148 "Source code on GitHub" +[88]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/proxy.js#L64-L64 "Source code on GitHub" -[94]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[89]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/proxy.js#L94-L94 "Source code on GitHub" -[95]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L308-L318 "Source code on GitHub" +[90]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L70-L348 "Source code on GitHub" -[96]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L288-L297 "Source code on GitHub" +[91]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[97]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L267-L278 "Source code on GitHub" +[92]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[98]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array +[93]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L163-L166 "Source code on GitHub" -[99]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L248-L256 "Source code on GitHub" +[94]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise -[100]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L236-L238 "Source code on GitHub" +[95]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L140-L156 "Source code on GitHub" -[101]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L211-L225 "Source code on GitHub" +[96]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L322-L332 "Source code on GitHub" -[102]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L193-L200 "Source code on GitHub" +[97]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L302-L311 "Source code on GitHub" -[103]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L181-L183 "Source code on GitHub" +[98]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L281-L292 "Source code on GitHub" -[104]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/index.js#L12-L12 "Source code on GitHub" +[99]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array -[105]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/RHOCore.js#L23-L78 "Source code on GitHub" +[100]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L262-L270 "Source code on GitHub" -[106]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/RHOCore.js#L276-L286 "Source code on GitHub" +[101]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L249-L251 "Source code on GitHub" -[107]: https://developer.mozilla.org/docs/Web/API/URL/URL +[102]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L221-L237 "Source code on GitHub" -[108]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/RHOCore.js#L86-L89 "Source code on GitHub" +[103]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L203-L210 "Source code on GitHub" -[109]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/RHOCore.js#L137-L201 "Source code on GitHub" +[104]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L190-L192 "Source code on GitHub" -[110]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/RHOCore.js#L214-L267 "Source code on GitHub" +[105]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L113-L119 "Source code on GitHub" -[111]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/revAddress.js#L34-L34 "Source code on GitHub" +[106]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L91-L100 "Source code on GitHub" -[112]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/revAddress.js#L50-L50 "Source code on GitHub" +[107]: https://nodejs.org/api/buffer.html -[113]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala +[108]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/index.js#L12-L12 "Source code on GitHub" -[114]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala#L16 +[109]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L99-L99 "Source code on GitHub" -[115]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L346-L351 "Source code on GitHub" +[110]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L27-L82 "Source code on GitHub" -[116]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto +[111]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L331-L336 "Source code on GitHub" -[117]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/hashing.js#L32-L34 "Source code on GitHub" +[112]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto -[118]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/signing.js#L50-L96 "Source code on GitHub" +[113]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L345-L355 "Source code on GitHub" -[119]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/signing.js#L79-L79 "Source code on GitHub" +[114]: https://developer.mozilla.org/docs/Web/API/URL/URL -[120]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/signing.js#L57-L59 "Source code on GitHub" +[115]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L90-L93 "Source code on GitHub" -[121]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/signing.js#L67-L67 "Source code on GitHub" +[116]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L169-L233 "Source code on GitHub" -[122]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/signing.js#L84-L86 "Source code on GitHub" +[117]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L246-L299 "Source code on GitHub" -[123]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/signing.js#L90-L92 "Source code on GitHub" +[118]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L307-L310 "Source code on GitHub" -[124]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/signing.js#L71-L71 "Source code on GitHub" +[119]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L115-L115 "Source code on GitHub" -[125]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/signing.js#L75-L75 "Source code on GitHub" +[120]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L38-L75 "Source code on GitHub" -[126]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/assets.js#L18-L20 "Source code on GitHub" +[121]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L70-L70 "Source code on GitHub" -[127]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L105-L111 "Source code on GitHub" +[122]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L46-L48 "Source code on GitHub" -[128]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/rnodeAPI.js#L84-L93 "Source code on GitHub" +[123]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L56-L56 "Source code on GitHub" -[129]: https://nodejs.org/api/buffer.html +[124]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L60-L60 "Source code on GitHub" -[130]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/proxy.js#L185-L207 "Source code on GitHub" +[125]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L64-L64 "Source code on GitHub" -[131]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[126]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/revAddress.js#L34-L34 "Source code on GitHub" -[132]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/hashing.js#L19-L23 "Source code on GitHub" +[127]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/revAddress.js#L50-L50 "Source code on GitHub" -[133]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/hashing.js#L92-L97 "Source code on GitHub" +[128]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala -[134]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/hashing.js#L77-L80 "Source code on GitHub" +[129]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala#L16 -[135]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/hashing.js#L60-L65 "Source code on GitHub" +[130]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L382-L420 "Source code on GitHub" -[136]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/loading.js#L117-L117 "Source code on GitHub" +[131]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L396-L402 "Source code on GitHub" -[137]: https://git@github.com/:dckc/RChain-API/blob/108ea6ddcbd7009f5a7deadfa88013d956bc2c0e/src/signing.js#L103-L109 "Source code on GitHub" +[132]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L410-L417 "Source code on GitHub" From be436cb04b7037b4bc5f6d8be48eecc6015c0d24 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Fri, 12 Apr 2019 12:44:56 -0500 Subject: [PATCH 09/36] update protobuf version doc --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 379bc84..ac678f1 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,13 @@ myNode.doDeploy({ [./docs/](./docs/index.md) +## RChain gRPC protobuf compatibility + +[protobuf][proto]: v0.9.1 bf1b2c6 Mar 28, 2019 + +[pro]: https://github.com/rchain/rchain/tree/bf1b2c6c6662515403c0a429e8c9fa25edd64638/models/src/main/protobuf + + ## Examples and Related Projects * [Nth Caller](https://github.com/JoshOrndorff/nth-caller-game) a minimal RChain-based dApp game that uses RChain-API * [Status](https://github.com/JoshOrndorff/RChain-Status) a moderately complex dapp that uses more RChain-API features as well as [RSign](https://github.com/dckc/RSign) @@ -66,9 +73,6 @@ myNode.doDeploy({ * [RSign](https://github.com/dckc/RSign) A chrome extension for generating client-side signatures akin to metamask * [node-client](https://github.com/rchain/rchain/tree/dev/node-client) A similar but less mature RChain API written in python -## RChain gRPC protobuf compatibility -* Commit hash [51d9323](https://github.com/rchain/rchain/tree/dev/models/src/main/protobuf) Jan 3, 2019 - ## License Copyright 2018-2019 RChain Cooperative From 265741932a6a06e6c314a6e5b24b030c12ce0dfc Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Fri, 12 Apr 2019 14:26:58 -0500 Subject: [PATCH 10/36] API re-org: REV story with RevAddress, SignDeployment --- .markdown-doctest-setup.js | 5 ++- index.js | 36 +++++++++++++++--- rclient/src/main.js | 6 +-- src/revAddress.js | 77 +++++++++++++++++++------------------- src/rnodeAPI.js | 19 ++++------ test/revAddressTest.js | 4 +- 6 files changed, 86 insertions(+), 61 deletions(-) diff --git a/.markdown-doctest-setup.js b/.markdown-doctest-setup.js index f241d15..bd1219b 100644 --- a/.markdown-doctest-setup.js +++ b/.markdown-doctest-setup.js @@ -2,7 +2,7 @@ const assert = require('assert'); const rchain = require('.'); -const { RholangCrypto, RNode, Hex } = rchain; +const { RNode, RholangCrypto, REV, Ed25519keyPair, Hex } = rchain; // mock enough of grpc // ISSUE: refactor overlap with test/testRNode.js @@ -21,7 +21,8 @@ const grpc = { module.exports = { babel: false, globals: { - RholangCrypto, RNode, Hex, grpc, + RholangCrypto, RNode, REV, Hex, Ed25519keyPair, + grpc, assert, }, }; diff --git a/index.js b/index.js index a912941..c14e892 100644 --- a/index.js +++ b/index.js @@ -19,15 +19,45 @@ exports.RHOCore = RHOCore; const { RNode, SignDeployment, Block } = require('./src/rnodeAPI'); +const { RevAddress } = require('./src/revAddress'); /*:: import type { IRNode } from './src/rnodeAPI'; export type { IRNode }; */ exports.RNode = RNode; -exports.SignDeployment = SignDeployment; exports.Block = Block; +/** + * REV transaction, vault support + * + * Refs: + * - [REV Vault](https://rchain.atlassian.net/wiki/spaces/CORE/pages/652640311/Wallet+proposal) + * + * @example + * // Suppose Alice generates a key pair. + * const aliceKey = Ed25519keyPair(Hex.decode('11'.repeat(32))); + * const alicePub = aliceKey.publicKey(); + * assert.equal(alicePub, 'd04ab232742bb4ab3a1368bd4615e4e6d0224ab71a016baf8520a332c9778737'); + * + * // She can then share her REV address. + * const aliceAddr = REV.RevAddress.fromPublicKey(Hex.decode(alicePub)); + * assert.equal(aliceAddr.toString(), '11112cFcjtrjwn7qCDvTLMu5jEvMSBN2qT1sBwQxDP9AyQCVi26xKZ'); + * + * // She can also sign deployments: + * const term = '@"world"!("Hello!")'; + * const timestamp = new Date('2019-04-12T17:59:29.274Z').valueOf(); + * const info = REV.SignDeployment.sign(aliceKey, { timestamp, term }); + * + * assert.deepEqual(info.deployer, Hex.decode(alicePub)); + * assert.equal(Hex.encode(info.sig).slice(0, 16), 'ebc47a0a923b7feb'); + * assert(REV.SignDeployment.verify(info)); + */ +const REV = { SignDeployment, RevAddress }; +exports.REV = REV; + +exports.SignDeployment = SignDeployment; + /** * Proxy method calls to registered RChain channels. */ @@ -51,7 +81,3 @@ export type Bytes = Bytes; */ exports.Hex = require('./src/hex'); - -const { RevAddress } = require('./src/revAddress'); - -exports.RevAddress = RevAddress; diff --git a/rclient/src/main.js b/rclient/src/main.js index 913c5bb..238ed28 100755 --- a/rclient/src/main.js +++ b/rclient/src/main.js @@ -10,11 +10,10 @@ const read = require('read'); const secp256k1 = require('secp256k1'); // ISSUE: push into rchain-api? const { docopt } = require('docopt'); const { - RNode, RHOCore, + RNode, RHOCore, REV, RholangCrypto, - Hex, Ed25519keyPair, SignDeployment, + Hex, Ed25519keyPair, RegistryProxy, - RevAddress, } = require('rchain-api'); const { loadRhoModules } = require('../../src/loading'); // ISSUE: path? @@ -23,6 +22,7 @@ const { asPromise } = require('./asPromise'); const secretStorage = require('./secretStorage'); const { link } = require('./assets'); +const { SignDeployment, RevAddress } = REV; const { keccak256Hash } = RholangCrypto; const { makeProxy } = RegistryProxy; const h2b = Hex.decode; diff --git a/src/revAddress.js b/src/revAddress.js index 2ab4c15..cf13f0b 100644 --- a/src/revAddress.js +++ b/src/revAddress.js @@ -1,4 +1,5 @@ /* global require, exports, Buffer */ +// @flow const base58 = require('bs58'); const { blake2b256Hash } = require('./signing').RholangCrypto; @@ -11,61 +12,59 @@ const version = '00'; const prefix = h2b(coinId + version); /*:: -type Bytes = Uint8Array; -type PublicKey = Bytes; // newtype? length? - -export type RevAddr = { +export interface IRevAddress { address: Address, toString: () => string, }; type Address = { - prefix: Bytes, - keyHash: Bytes, - checksum: Bytes, + prefix: Uint8Array, + keyHash: Uint8Array, + checksum: Uint8Array, }; */ /** - * A RevAddress has a prefix, a keyHash, and a checksum. + * A RevAddress refers to a REV vault. * - * Use toString() to get base58 form. - */ -const RevAddress = Object.freeze({ fromPublicKey }); -exports.RevAddress = RevAddress; - -/** - * Compute REV Address - * @memberof RevAddress - * @param pk: ed25519 public key - * @return: RevAddress + * Use `toString()` to get base58 form. * * Refs: - * https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala - * https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala#L16 + * - [RevAddress.scala](https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala) + * - [AddressTools.scala](https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala) * - * - ISSUE: find RevAddress spec - * - ISSUE: how to use tests as documentation? + * @memberof REV */ -exports.fromPublicKey = fromPublicKey; -function fromPublicKey(pk /*: PublicKey */) /*: RevAddr */ { - if (keyLength !== pk.length) { throw new Error(`bad public key length: ${pk.length}`); } - const keyHash = blake2b256Hash(pk); - const payload = concat(prefix, keyHash); - const checksum = computeChecksum(payload); - const s = base58.encode(Buffer.from(concat(payload, checksum))); +const RevAddress = (() => { + /** + * Compute REV Address from public key + * + * @param pk ed25519 public key + * + * @memberof REV.RevAddress + */ + function fromPublicKey(pk /*: Uint8Array */) /*: IRevAddress */ { + if (keyLength !== pk.length) { throw new Error(`bad public key length: ${pk.length}`); } + const keyHash = blake2b256Hash(pk); + const payload = concat(prefix, keyHash); + const checksum = computeChecksum(payload); + const s = base58.encode(Buffer.from(concat(payload, checksum))); - return Object.freeze({ - address: { - prefix, - keyHash, - checksum, - }, - toString: () => s, - }); -} + return Object.freeze({ + address: { + prefix, + keyHash, + checksum, + }, + toString: () => s, + }); + } + + return Object.freeze({ fromPublicKey }); +})(); +exports.RevAddress = RevAddress; -function computeChecksum(toCheck /*: Bytes */) /*: Bytes*/ { +function computeChecksum(toCheck /*: Uint8Array */) /*: Uint8Array */ { return blake2b256Hash(toCheck).slice(0, checksumLength); } diff --git a/src/rnodeAPI.js b/src/rnodeAPI.js index fc5a586..c4bd43f 100644 --- a/src/rnodeAPI.js +++ b/src/rnodeAPI.js @@ -375,9 +375,11 @@ function firstBlockProcess(blockResults /*: DataWithBlockInfo[] */) { /** - * a port of casper/src/main/scala/coop/rchain/casper/SignDeployment.scala + * a port of [casper/SignDeployment.scala](https://github.com/rchain/rchain/blob/9ae5825/casper/src/main/scala/coop/rchain/casper/SignDeployment.scala) * * ISSUE: only ed25519 is supported. + * + * @memberof REV */ const SignDeployment = (() => { const algName = 'ed25519'; @@ -389,11 +391,9 @@ const SignDeployment = (() => { const clear = deployData => fill(deployData)(null, null, null); /** - * @name sign - * - * @memberof SignDeployment + * @memberof REV.SignDeployment */ - function signD(key /*: KeyPair */, deployData /*: DeployData*/)/*: DeployData*/ { + function sign(key /*: KeyPair */, deployData /*: DeployData*/)/*: DeployData*/ { const toSign = DeployData.encode(clear(deployData)).finish(); const hash = blake2b256Hash(toSign); const signature = key.signBytes(hash); @@ -402,12 +402,9 @@ const SignDeployment = (() => { } /** - * Verify Deployment - * @name verify - * - * @memberof SignDeployment + * @memberof REV.SignDeployment */ - function verifyD(deployData /*: DeployData*/)/*: boolean */ { + function verify(deployData /*: DeployData*/)/*: boolean */ { if (deployData.sigAlgorithm !== algName) { throw new Error(`unsupported: ${deployData.sigAlgorithm}`); } @@ -416,7 +413,7 @@ const SignDeployment = (() => { return ed25519Verify(hash, deployData.sig, deployData.deployer); } - return Object.freeze({ sign: signD, verify: verifyD }); + return Object.freeze({ sign, verify }); })(); exports.SignDeployment = SignDeployment; diff --git a/test/revAddressTest.js b/test/revAddressTest.js index f8e0162..8577a64 100644 --- a/test/revAddressTest.js +++ b/test/revAddressTest.js @@ -1,6 +1,8 @@ /* global require*/ const ttest = require('tape'); // ISSUE: separate tests -const { Hex, RevAddress } = require('..'); +const { Hex, REV } = require('..'); + +const { RevAddress } = REV; const testCases = [ { From f197c9ae5b22b945c7d9021ca32bd0d4061f235e Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Fri, 12 Apr 2019 15:16:06 -0500 Subject: [PATCH 11/36] RholangCrypto story style doctest --- .markdown-doctest-setup.js | 6 +++--- src/signing.js | 43 +++++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/.markdown-doctest-setup.js b/.markdown-doctest-setup.js index bd1219b..4a12509 100644 --- a/.markdown-doctest-setup.js +++ b/.markdown-doctest-setup.js @@ -1,4 +1,4 @@ -/* global module, require */ +/* global module, require, Buffer */ const assert = require('assert'); const rchain = require('.'); @@ -21,8 +21,8 @@ const grpc = { module.exports = { babel: false, globals: { - RholangCrypto, RNode, REV, Hex, Ed25519keyPair, + assert, Buffer, grpc, - assert, + RholangCrypto, RNode, REV, Hex, Ed25519keyPair, }, }; diff --git a/src/signing.js b/src/signing.js index 45628d8..8b4b501 100644 --- a/src/signing.js +++ b/src/signing.js @@ -85,18 +85,6 @@ exports.Ed25519keyPair = Ed25519keyPair; * * @return indicates whether the signature is valid * - * @example - * - * const publicKey = Hex.decode( - * '288755c48c3951f89c5f0ffe885088dc0970fd935bc12adfdd81f81bb63d6219'); - * const message = Hex.decode( - * 'a6da46a1dc7ed715d4cd6472a736249a4d11142d160dbef9f20ae493de908c4e'); - * const sig = Hex.decode( - * 'd0a909078ce8b8706a641b07a0d4fe2108064813ce42009f108f89c2a3f4864a' + - * 'a1a510d6dfccad3b62cd610db0bfe82bcecb08d813997fa7df14972f56017e0b'); - * - * assert(RholangCrypto.ed25519Verify(message, sig, publicKey)); - * * @memberof RholangCrypto */ function ed25519Verify( @@ -150,15 +138,42 @@ function blake2b256Hash(input /*: Uint8Array*/) /*: Uint8Array*/ { } /** - * Cryptographic functions from Rholang. + * Cryptographic functions from Rholang + * * * refs: * - [RChain Cryptography Specification][cspec] May 2018 * - [rholang/examples/tut-hash-functions.rho][htut] Aug 2018 + * - [rholang/examples/tut-verify-channel.md][vtut] Aug 2018 * * [cspec]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/112721930/Cryptography+Specification - * * [htut]: https://github.com/rchain/rchain/blob/a582f94/rholang/examples/tut-hash-functions.rho + * [vtut]: https://github.com/rchain/rchain/blob/3c64ca3/rholang/examples/tut-verify-channel.md + * + * See also {@link #rhocorewraphash|RHOCore.wrapHash} + * + * @example + * // Suppose we have Nathan Hale's public key: + * const halePub = Hex.decode( + * 'd759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c48'); + * + * // And we are presented with a document that he purportedly signed: + * const doc = 'I regret that I have but one life to live for my country.'; + * const sig1 = Hex.decode( + * 'af42db4ae7a23ee182f7aabc3a73fa89834bc0daefab94d0f3e28c508557c3d3' + + * 'f06c67c28ebd2768ffa0b320330ec5089a9ae7519534fe70e9d06145d8caf40c'); + * + * // Signatures are conventionally computed over a document's hash. + * // In this case, we happen to know it's a Blake2b 256 bit hash: + * const digest = RholangCrypto.blake2b256Hash(Buffer.from(doc)); + * + * // Indeed, the signature is valid. + * assert(RholangCrypto.ed25519Verify(digest, sig1, halePub)); + * + * // If the signature is altered even slightly, validation fails: + * const sig2 = sig1; + * sig2[0] = 123; + * assert(!RholangCrypto.ed25519Verify(digest, sig2, halePub)); */ const RholangCrypto = Object.freeze({ blake2b256Hash, sha256Hash, keccak256Hash, ed25519Verify }); exports.RholangCrypto = RholangCrypto; From 47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Fri, 12 Apr 2019 15:17:17 -0500 Subject: [PATCH 12/36] docs: regenerate --- docs/index.md | 472 +++++++++++++++++++++++++++++--------------------- 1 file changed, 277 insertions(+), 195 deletions(-) diff --git a/docs/index.md b/docs/index.md index df2d224..688f24b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,11 +3,11 @@ ### Table of Contents - [RholangCrypto][2] - - [blake2b256Hash][3] - - [Parameters][4] - - [ed25519Verify][5] - - [Parameters][6] - - [Examples][7] + - [Examples][3] + - [blake2b256Hash][4] + - [Parameters][5] + - [ed25519Verify][6] + - [Parameters][7] - [keccak256Hash][8] - [Parameters][9] - [sha256Hash][10] @@ -73,101 +73,122 @@ - [Parameters][70] - [signTextHex][71] - [Parameters][72] -- [RevAddress][73] - - [fromPublicKey][74] - - [Parameters][75] -- [SignDeployment][76] - - [sign][77] - - [verify][78] +- [REV][73] + - [Examples][74] + - [RevAddress][75] + - [fromPublicKey][76] + - [Parameters][77] + - [SignDeployment][78] + - [sign][79] + - [Parameters][80] + - [verify][81] + - [Parameters][82] ## RholangCrypto -[src/signing.js:163-163][79] +[src/signing.js:178-178][83] -Cryptographic functions from Rholang. +Cryptographic functions from Rholang refs: - [RChain Cryptography Specification][cspec] May 2018 - [rholang/examples/tut-hash-functions.rho][htut] Aug 2018 +- [rholang/examples/tut-verify-channel.md][vtut] Aug 2018 [cspec]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/112721930/Cryptography+Specification [htut]: https://github.com/rchain/rchain/blob/a582f94/rholang/examples/tut-hash-functions.rho +[vtut]: https://github.com/rchain/rchain/blob/3c64ca3/rholang/examples/tut-verify-channel.md + +See also [RHOCore.wrapHash][84] + +### Examples + +```javascript +// Suppose we have Nathan Hale's public key: + const halePub = Hex.decode( + 'd759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c48'); + +// And we are presented with a document that he purportedly signed: +const doc = 'I regret that I have but one life to live for my country.'; +const sig1 = Hex.decode( + 'af42db4ae7a23ee182f7aabc3a73fa89834bc0daefab94d0f3e28c508557c3d3' + + 'f06c67c28ebd2768ffa0b320330ec5089a9ae7519534fe70e9d06145d8caf40c'); + +// Signatures are conventionally computed over a document's hash. +// In this case, we happen to know it's a Blake2b 256 bit hash: +const digest = RholangCrypto.blake2b256Hash(Buffer.from(doc)); + +// Indeed, the signature is valid. +assert(RholangCrypto.ed25519Verify(digest, sig1, halePub)); + +// If the signature is altered even slightly, validation fails: +const sig2 = sig1; +sig2[0] = 123; +assert(!RholangCrypto.ed25519Verify(digest, sig2, halePub)); +``` + ### blake2b256Hash -[src/signing.js:146-150][80] +[src/signing.js:134-138][85] Blake2b 256 bit cryptographic hash function #### Parameters -- `input` **[Uint8Array][81]** any number of bytes +- `input` **[Uint8Array][86]** any number of bytes -Returns **[Uint8Array][81]** 256 bit (32 byte) hash +Returns **[Uint8Array][86]** 256 bit (32 byte) hash ### ed25519Verify -[src/signing.js:102-108][82] +[src/signing.js:90-96][87] Verify ed25519 signature #### Parameters -- `message` **[Uint8Array][81]** any number of bytes (TODO: test!) -- `sig` **[Uint8Array][81]** 64 byte ed25519 signature over message -- `publicKey` **[Uint8Array][81]** 32 byte ed25519 public key - -#### Examples - -```javascript -const publicKey = Hex.decode( - '288755c48c3951f89c5f0ffe885088dc0970fd935bc12adfdd81f81bb63d6219'); - const message = Hex.decode( - 'a6da46a1dc7ed715d4cd6472a736249a4d11142d160dbef9f20ae493de908c4e'); - const sig = Hex.decode( - 'd0a909078ce8b8706a641b07a0d4fe2108064813ce42009f108f89c2a3f4864a' + - 'a1a510d6dfccad3b62cd610db0bfe82bcecb08d813997fa7df14972f56017e0b'); - - assert(RholangCrypto.ed25519Verify(message, sig, publicKey)); -``` +- `message` **[Uint8Array][86]** any number of bytes (TODO: test!) +- `sig` **[Uint8Array][86]** 64 byte ed25519 signature over message +- `publicKey` **[Uint8Array][86]** 32 byte ed25519 public key -Returns **[boolean][83]** indicates whether the signature is valid +Returns **[boolean][88]** indicates whether the signature is valid ### keccak256Hash -[src/signing.js:133-135][84] +[src/signing.js:121-123][89] Keccak 256 bit cryptographic hash function (aka SHA-3) #### Parameters -- `input` **[Uint8Array][81]** any number of bytes +- `input` **[Uint8Array][86]** any number of bytes -Returns **[Uint8Array][81]** 256 bit (32 byte) hash +Returns **[Uint8Array][86]** 256 bit (32 byte) hash ### sha256Hash -[src/signing.js:119-123][85] +[src/signing.js:107-111][90] SHA-2 256 bit cryptographic hash function #### Parameters -- `input` **[Uint8Array][81]** any number of bytes +- `input` **[Uint8Array][86]** any number of bytes -Returns **[Uint8Array][81]** 256 bit (32 byte) hash +Returns **[Uint8Array][86]** 256 bit (32 byte) hash ## RegistryProxy -[index.js:34-34][86] +[index.js:64-64][91] Proxy method calls to registered RChain channels. ### callSource -[src/proxy.js:185-185][87] +[src/proxy.js:185-185][92] Make a rholang term for looking up a target and calling a method. @@ -180,7 +201,7 @@ Make a rholang term for looking up a target and calling a method. ### makeProxy -[src/proxy.js:64-64][88] +[src/proxy.js:64-64][93] Make an object that proxies method calls to registered RChain channels. @@ -201,7 +222,7 @@ For rholang calling conventions, see `callSource`. ### sendCall -[src/proxy.js:94-94][89] +[src/proxy.js:94-94][94] Call a method on a registered RChain channel. @@ -219,28 +240,28 @@ For rholang calling conventions, see `callSource`. ## RNode -[src/rnodeAPI.js:70-348][90] +[src/rnodeAPI.js:70-348][95] Connect to an RChain node (RNode). ### Parameters - `grpc` **grpcT** access to the network: grpc instance from the node grpc package -- `endPoint` **{host: [string][91], port: [number][92]}** rnode gRPC service +- `endPoint` **{host: [string][96], port: [number][97]}** rnode gRPC service Returns **any** a thin wrapper around a gRPC client stub ### createBlock -[src/rnodeAPI.js:163-166][93] +[src/rnodeAPI.js:163-166][98] Creates a block on your node -Returns **[Promise][94]<[string][91]>** A promise for response message +Returns **[Promise][99]<[string][96]>** A promise for response message ### doDeploy -[src/rnodeAPI.js:140-156][95] +[src/rnodeAPI.js:140-156][100] Deploys a rholang term to a node @@ -256,35 +277,35 @@ Deploys a rholang term to a node - `deployData.phloLimit` - `deployData.phloPrice` - `deployData.validAfterBlockNumber` ???ISSUE??? -- `autoCreateBlock` **[boolean][83]** automatically create a new block after deploy transaction success +- `autoCreateBlock` **[boolean][88]** automatically create a new block after deploy transaction success -Returns **[Promise][94]<[string][91]>** A promise for messageISSUE: import / generate DeployData static type +Returns **[Promise][99]<[string][96]>** A promise for messageISSUE: import / generate DeployData static type ### getAllBlocks -[src/rnodeAPI.js:322-332][96] +[src/rnodeAPI.js:322-332][101] Retrieve the block summary for a series of blocks starting with the most recent, including the number of blocks specified by the block_depth #### Parameters -- `blockDepth` **[number][92]** : Number indicating the number of blocks to retrieve +- `blockDepth` **[number][97]** : Number indicating the number of blocks to retrieve - Throws **any** Error if blockDepth < 1 or no blocks were able to be retrieved -Returns **[Promise][94]<BlockInfoWithoutTuplespace>** List of BlockInfoWithoutTuplespace structures for each block retrieved +Returns **[Promise][99]<BlockInfoWithoutTuplespace>** List of BlockInfoWithoutTuplespace structures for each block retrieved ### getBlock -[src/rnodeAPI.js:302-311][97] +[src/rnodeAPI.js:302-311][102] Retrieve a block with the tuplespace for a specific block hash #### Parameters -- `blockHash` **[string][91]** : String of the hash for the block being requested +- `blockHash` **[string][96]** : String of the hash for the block being requested - Throws **any** Error if the hash is blank or does not correspond to an existing block @@ -293,32 +314,32 @@ Returns **any** BlockInfo structure that will include all metadata and also incl ### listenForContinuationAtName -[src/rnodeAPI.js:281-292][98] +[src/rnodeAPI.js:281-292][103] Listen for a continuation at an individual name or JOINed set of names in the tuplespace #### Parameters -- `pars` **[Array][99]<IPar>** The names onwhich to listen -- `depth` **[number][92]** +- `pars` **[Array][104]<IPar>** The names onwhich to listen +- `depth` **[number][97]** - Throws **any** Error if status is not Success -Returns **[Promise][94]<ListeningNameContinuationResponse>** promise for DataWithBlockInfo +Returns **[Promise][99]<ListeningNameContinuationResponse>** promise for DataWithBlockInfo ### listenForContinuationAtPrivateName -[src/rnodeAPI.js:262-270][100] +[src/rnodeAPI.js:262-270][105] Listen for a continuation at an individual private name or JOINed set of private names in the tuplespace #### Parameters -- `nameIds` **[Array][99]<[string][91]>** a list hex strings representing the unforgeable names' Ids -- `depth` **[number][92]** (optional, default `1`) +- `nameIds` **[Array][104]<[string][96]>** a list hex strings representing the unforgeable names' Ids +- `depth` **[number][97]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -332,15 +353,15 @@ Returns **any** promise for ContinuationsWithBlockInfo ### listenForContinuationAtPublicName -[src/rnodeAPI.js:249-251][101] +[src/rnodeAPI.js:249-251][106] Listen for a continuation at an individual public name or JOINed set of public names in the tuplespace #### Parameters -- `nameObjs` **[Array][99]<[string][91]>** a list of names (strings) -- `depth` **[number][92]** (optional, default `1`) +- `nameObjs` **[Array][104]<[string][96]>** a list of names (strings) +- `depth` **[number][97]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -354,31 +375,31 @@ Returns **any** promise for ContinuationsWithBlockInfo ### listenForDataAtName -[src/rnodeAPI.js:221-237][102] +[src/rnodeAPI.js:221-237][107] Listen for data at a name in the RChain tuple-space. #### Parameters - `par` **IPar** : JSON-ish Par data. See protobuf/RhoTypes.proto -- `depth` **[number][92]** (optional, default `1`) +- `depth` **[number][97]** (optional, default `1`) - `blockDepth` : Number of blocks to look back in for the name to listen on - Throws **any** Error if status is not Success -Returns **[Promise][94]<[Array][99]<DataWithBlockInfo>>** : promise for DataWithBlockInfo\[] +Returns **[Promise][99]<[Array][104]<DataWithBlockInfo>>** : promise for DataWithBlockInfo\[] ### listenForDataAtPrivateName -[src/rnodeAPI.js:203-210][103] +[src/rnodeAPI.js:203-210][108] Listen for data at a PRIVATE name in the RChain tuple-space. #### Parameters -- `nameId` **[string][91]** : Hex string representing an UnforgeableName's Id -- `depth` **[number][92]** (optional, default `1`) +- `nameId` **[string][96]** : Hex string representing an UnforgeableName's Id +- `depth` **[number][97]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -392,14 +413,14 @@ Returns **any** promise for [DataWithBlockInfo] ### listenForDataAtPublicName -[src/rnodeAPI.js:190-192][104] +[src/rnodeAPI.js:190-192][109] Listen for data at a PUBLIC name in the RChain tuple-space. #### Parameters - `nameObj` **JSData** : JSON-ish data: string, number, {}, \[], ... -- `depth` **[number][92]** (optional, default `1`) +- `depth` **[number][97]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -413,7 +434,7 @@ Returns **any** promise for [DataWithBlockInfo] ### previewPrivateChannels -[src/rnodeAPI.js:113-119][105] +[src/rnodeAPI.js:113-119][110] Ask rnode to compute top level private channels, given deploy parameters. @@ -422,13 +443,13 @@ Ask rnode to compute top level private channels, given deploy parameters. - `d` **any** - `d.user` public key (of validating node?) as in doDeploy - `d.timestamp` timestamp (ms) as in doDeploy -- `nameQty` **[number][92]** how many names to preview? (max: 1024) +- `nameQty` **[number][97]** how many names to preview? (max: 1024) -Returns **[Promise][94]<[Array][99]<IPar>>** +Returns **[Promise][99]<[Array][104]<IPar>>** ### previewPrivateIds -[src/rnodeAPI.js:91-100][106] +[src/rnodeAPI.js:91-100][111] Ask rnode to compute ids of top level private names, given deploy parameters. @@ -438,13 +459,13 @@ Ask rnode to compute ids of top level private names, given deploy parameters. - `d.timestamp` timestamp (ms) as in doDeploy - `d.deployer` public key (of validating node?) as in doDeploy - `d.user` -- `nameQty` **[number][92]** how many names to preview? (max: 1024) +- `nameQty` **[number][97]** how many names to preview? (max: 1024) -Returns **[Promise][94]<[Array][99]<[Buffer][107]>>** +Returns **[Promise][99]<[Array][104]<[Buffer][112]>>** ## RHOCore -[index.js:12-12][108] +[index.js:12-12][113] "we can detail a direct representation of JSON into a fragment of the rholang syntax referred to in the diagram @@ -454,11 +475,11 @@ below as RHOCore." -- \[Mobile process calculi for programming the blockchain[1] ### dataToBytes -[src/RHOCore.js:99-99][109] +[src/RHOCore.js:99-99][114] ### fromJSData -[src/RHOCore.js:27-82][110] +[src/RHOCore.js:27-82][115] Build Rholang expression from Javascript data. @@ -473,33 +494,33 @@ Returns **any** : A rholang term in Protobuf's JSON representation, ### getIdFromUnforgeableName -[src/RHOCore.js:331-336][111] +[src/RHOCore.js:331-336][116] Convert the ack channel into a HEX-formatted unforgeable name #### Parameters -- `par` **IPar** : JSON-ish Par data: [https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto][112] +- `par` **IPar** : JSON-ish Par data: [https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto][117] - Throws **any** Error if the Par does not represent an unforgeable name -Returns **[string][91]** HEX-formatted string of unforgeable name's Id +Returns **[string][96]** HEX-formatted string of unforgeable name's Id ### rhol -[src/RHOCore.js:345-355][113] +[src/RHOCore.js:345-355][118] Template tag for RHOCore interpolation #### Parameters -- `template` **[Array][99]<[string][91]>** -- `subs` **...[Array][99]<JsonExt<([URL][114] | GPrivate)>>** +- `template` **[Array][104]<[string][96]>** +- `subs` **...[Array][104]<JsonExt<([URL][119] | GPrivate)>>** ### toByteArray -[src/RHOCore.js:90-93][115] +[src/RHOCore.js:90-93][120] Turns a rholang term into a byte-array compatible with Rholang @@ -507,11 +528,11 @@ Turns a rholang term into a byte-array compatible with Rholang - `termObj` **IPar** -Returns **[Uint8Array][81]** +Returns **[Uint8Array][86]** ### toJSData -[src/RHOCore.js:169-233][116] +[src/RHOCore.js:169-233][121] Converts an RHOCore object back to JavaScript data @@ -519,11 +540,11 @@ Converts an RHOCore object back to JavaScript data - `par` **IPar** A RHOCore representation of a Rholang term -Returns **JsonExt<([URL][114] | GPrivate)>** JSON-serializable data +Returns **JsonExt<([URL][119] | GPrivate)>** JSON-serializable data ### toRholang -[src/RHOCore.js:246-299][117] +[src/RHOCore.js:246-299][122] Converts an RHOCore object into Rholang source form @@ -531,21 +552,21 @@ Converts an RHOCore object into Rholang source form - `par` **IPar** A RHOCore representation of a Rholang term -Returns **[string][91]** A rholang stringISSUE: Use intersection types to constrain par param further than IPar? +Returns **[string][96]** A rholang stringISSUE: Use intersection types to constrain par param further than IPar? ### unforgeableWithId -[src/RHOCore.js:307-310][118] +[src/RHOCore.js:307-310][123] Get printable form of unforgeable name, given id. #### Parameters -- `id` **[Uint8Array][81]** +- `id` **[Uint8Array][86]** ### wrapHash -[src/RHOCore.js:115-115][119] +[src/RHOCore.js:115-115][124] #### Parameters @@ -558,7 +579,7 @@ Returns **any** HEX-formatted string representing the computed hash ## Ed25519keyPair -[src/signing.js:38-75][120] +[src/signing.js:38-75][125] Build key pair from seed. @@ -568,7 +589,7 @@ Build key pair from seed. ### publicKey -[src/signing.js:70-70][121] +[src/signing.js:70-70][126] ISSUE: if the caller wants the bytes, we go bytes -> hex -> bytes @@ -576,96 +597,141 @@ Returns **HexStr<PublicKey>** ### signBytes -[src/signing.js:46-48][122] +[src/signing.js:46-48][127] #### Parameters -- `bytes` **[Uint8Array][81]** +- `bytes` **[Uint8Array][86]** Returns **Signature** ### signBytesHex -[src/signing.js:56-56][123] +[src/signing.js:56-56][128] #### Parameters -- `bs` **[Uint8Array][81]** +- `bs` **[Uint8Array][86]** Returns **HexStr<Signature>** ### signText -[src/signing.js:60-60][124] +[src/signing.js:60-60][129] #### Parameters -- `text` **[string][91]** +- `text` **[string][96]** Returns **Signature** ### signTextHex -[src/signing.js:64-64][125] +[src/signing.js:64-64][130] #### Parameters -- `text` **[string][91]** +- `text` **[string][96]** Returns **HexStr<Signature>** -## RevAddress +## REV -[src/revAddress.js:34-34][126] +[index.js:56-56][131] -A RevAddress has a prefix, a keyHash, and a checksum. +REV transaction, vault support -Use toString() to get base58 form. +Refs: -### fromPublicKey +- [REV Vault][132] -[src/revAddress.js:50-50][127] +### Examples -Compute REV Address +```javascript +// Suppose Alice generates a key pair. +const aliceKey = Ed25519keyPair(Hex.decode('11'.repeat(32))); +const alicePub = aliceKey.publicKey(); +assert.equal(alicePub, 'd04ab232742bb4ab3a1368bd4615e4e6d0224ab71a016baf8520a332c9778737'); + +// She can then share her REV address. +const aliceAddr = REV.RevAddress.fromPublicKey(Hex.decode(alicePub)); +assert.equal(aliceAddr.toString(), '11112cFcjtrjwn7qCDvTLMu5jEvMSBN2qT1sBwQxDP9AyQCVi26xKZ'); + +// She can also sign deployments: +const term = '@"world"!("Hello!")'; +const timestamp = new Date('2019-04-12T17:59:29.274Z').valueOf(); +const info = REV.SignDeployment.sign(aliceKey, { timestamp, term }); + +assert.deepEqual(info.deployer, Hex.decode(alicePub)); +assert.equal(Hex.encode(info.sig).slice(0, 16), 'ebc47a0a923b7feb'); +assert(REV.SignDeployment.verify(info)); +``` -#### Parameters +### RevAddress + +[src/revAddress.js:38-64][133] + +A RevAddress refers to a REV vault. + +Use `toString()` to get base58 form. + +Refs: + +- [RevAddress.scala][134] +- [AddressTools.scala][135] -- `pk` : ed25519 public key +#### fromPublicKey -Returns **any** : RevAddressRefs: -[https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala][128] -[https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala#L16][129]- ISSUE: find RevAddress spec -- ISSUE: how to use tests as documentation? +[src/revAddress.js:46-61][136] -## SignDeployment +Compute REV Address from public key -[src/rnodeAPI.js:382-420][130] +##### Parameters -a port of casper/src/main/scala/coop/rchain/casper/SignDeployment.scala +- `pk` **[Uint8Array][86]** ed25519 public key + +Returns **IRevAddress** + +### SignDeployment + +[src/rnodeAPI.js:384-417][137] + +a port of [casper/SignDeployment.scala][138] ISSUE: only ed25519 is supported. -### sign +#### sign + +[src/rnodeAPI.js:396-402][139] + +##### Parameters + +- `key` **KeyPair** +- `deployData` **DeployData** + +Returns **DeployData** + +#### verify -[src/rnodeAPI.js:396-402][131] +[src/rnodeAPI.js:407-414][140] -### verify +##### Parameters -[src/rnodeAPI.js:410-417][132] +- `deployData` **DeployData** -Verify Deployment +Returns **[boolean][88]** [2]: #rholangcrypto -[3]: #blake2b256hash +[3]: #examples -[4]: #parameters +[4]: #blake2b256hash -[5]: #ed25519verify +[5]: #parameters -[6]: #parameters-1 +[6]: #ed25519verify -[7]: #examples +[7]: #parameters-1 [8]: #keccak256hash @@ -797,122 +863,138 @@ Verify Deployment [72]: #parameters-31 -[73]: #revaddress +[73]: #rev + +[74]: #examples-1 + +[75]: #revaddress + +[76]: #frompublickey + +[77]: #parameters-32 + +[78]: #signdeployment + +[79]: #sign + +[80]: #parameters-33 + +[81]: #verify -[74]: #frompublickey +[82]: #parameters-34 -[75]: #parameters-32 +[83]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L178-L178 "Source code on GitHub" -[76]: #signdeployment +[84]: #rhocorewraphash -[77]: #sign +[85]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L134-L138 "Source code on GitHub" -[78]: #verify +[86]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array -[79]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L163-L163 "Source code on GitHub" +[87]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L90-L96 "Source code on GitHub" -[80]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L146-L150 "Source code on GitHub" +[88]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[81]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array +[89]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L121-L123 "Source code on GitHub" -[82]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L102-L108 "Source code on GitHub" +[90]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L107-L111 "Source code on GitHub" -[83]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[91]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/index.js#L64-L64 "Source code on GitHub" -[84]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L133-L135 "Source code on GitHub" +[92]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/proxy.js#L185-L185 "Source code on GitHub" -[85]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L119-L123 "Source code on GitHub" +[93]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/proxy.js#L64-L64 "Source code on GitHub" -[86]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/index.js#L34-L34 "Source code on GitHub" +[94]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/proxy.js#L94-L94 "Source code on GitHub" -[87]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/proxy.js#L185-L185 "Source code on GitHub" +[95]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L70-L348 "Source code on GitHub" -[88]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/proxy.js#L64-L64 "Source code on GitHub" +[96]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[89]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/proxy.js#L94-L94 "Source code on GitHub" +[97]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[90]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L70-L348 "Source code on GitHub" +[98]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L163-L166 "Source code on GitHub" -[91]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[99]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise -[92]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[100]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L140-L156 "Source code on GitHub" -[93]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L163-L166 "Source code on GitHub" +[101]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L322-L332 "Source code on GitHub" -[94]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise +[102]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L302-L311 "Source code on GitHub" -[95]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L140-L156 "Source code on GitHub" +[103]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L281-L292 "Source code on GitHub" -[96]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L322-L332 "Source code on GitHub" +[104]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array -[97]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L302-L311 "Source code on GitHub" +[105]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L262-L270 "Source code on GitHub" -[98]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L281-L292 "Source code on GitHub" +[106]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L249-L251 "Source code on GitHub" -[99]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array +[107]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L221-L237 "Source code on GitHub" -[100]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L262-L270 "Source code on GitHub" +[108]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L203-L210 "Source code on GitHub" -[101]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L249-L251 "Source code on GitHub" +[109]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L190-L192 "Source code on GitHub" -[102]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L221-L237 "Source code on GitHub" +[110]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L113-L119 "Source code on GitHub" -[103]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L203-L210 "Source code on GitHub" +[111]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L91-L100 "Source code on GitHub" -[104]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L190-L192 "Source code on GitHub" +[112]: https://nodejs.org/api/buffer.html -[105]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L113-L119 "Source code on GitHub" +[113]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/index.js#L12-L12 "Source code on GitHub" -[106]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L91-L100 "Source code on GitHub" +[114]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L99-L99 "Source code on GitHub" -[107]: https://nodejs.org/api/buffer.html +[115]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L27-L82 "Source code on GitHub" -[108]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/index.js#L12-L12 "Source code on GitHub" +[116]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L331-L336 "Source code on GitHub" -[109]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L99-L99 "Source code on GitHub" +[117]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto -[110]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L27-L82 "Source code on GitHub" +[118]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L345-L355 "Source code on GitHub" -[111]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L331-L336 "Source code on GitHub" +[119]: https://developer.mozilla.org/docs/Web/API/URL/URL -[112]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto +[120]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L90-L93 "Source code on GitHub" -[113]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L345-L355 "Source code on GitHub" +[121]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L169-L233 "Source code on GitHub" -[114]: https://developer.mozilla.org/docs/Web/API/URL/URL +[122]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L246-L299 "Source code on GitHub" -[115]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L90-L93 "Source code on GitHub" +[123]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L307-L310 "Source code on GitHub" -[116]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L169-L233 "Source code on GitHub" +[124]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L115-L115 "Source code on GitHub" -[117]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L246-L299 "Source code on GitHub" +[125]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L38-L75 "Source code on GitHub" -[118]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L307-L310 "Source code on GitHub" +[126]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L70-L70 "Source code on GitHub" -[119]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/RHOCore.js#L115-L115 "Source code on GitHub" +[127]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L46-L48 "Source code on GitHub" -[120]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L38-L75 "Source code on GitHub" +[128]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L56-L56 "Source code on GitHub" -[121]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L70-L70 "Source code on GitHub" +[129]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L60-L60 "Source code on GitHub" -[122]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L46-L48 "Source code on GitHub" +[130]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L64-L64 "Source code on GitHub" -[123]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L56-L56 "Source code on GitHub" +[131]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/index.js#L56-L56 "Source code on GitHub" -[124]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L60-L60 "Source code on GitHub" +[132]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/652640311/Wallet+proposal -[125]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/signing.js#L64-L64 "Source code on GitHub" +[133]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/revAddress.js#L38-L64 "Source code on GitHub" -[126]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/revAddress.js#L34-L34 "Source code on GitHub" +[134]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala -[127]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/revAddress.js#L50-L50 "Source code on GitHub" +[135]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala -[128]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala +[136]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/revAddress.js#L46-L61 "Source code on GitHub" -[129]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala#L16 +[137]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L384-L417 "Source code on GitHub" -[130]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L382-L420 "Source code on GitHub" +[138]: https://github.com/rchain/rchain/blob/9ae5825/casper/src/main/scala/coop/rchain/casper/SignDeployment.scala -[131]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L396-L402 "Source code on GitHub" +[139]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L396-L402 "Source code on GitHub" -[132]: https://git@github.com/:dckc/RChain-API/blob/7c5a820e322ae28ac5a7e1f64bca351276188f9a/src/rnodeAPI.js#L410-L417 "Source code on GitHub" +[140]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L407-L414 "Source code on GitHub" From 78534b50eab440cf4bc5a62d5fdf14cac389590c Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Fri, 12 Apr 2019 16:56:31 -0500 Subject: [PATCH 13/36] testRNode: catch connection failure etc. --- test/testRNode.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/testRNode.js b/test/testRNode.js index 00dd62d..59b0f3e 100644 --- a/test/testRNode.js +++ b/test/testRNode.js @@ -83,7 +83,8 @@ function netTests({ grpc, clock, rng }) { localNode().doDeploy(payFor({ term, timestamp }, key), true).then((results) => { test.equal(results.slice(0, 'Success'.length), 'Success'); test.end(); - }); + }) + .catch((oops) => { test.fail(oops.message); test.end(); }); }, 'test getAllBlocks': (test) => { const expected = [ @@ -96,14 +97,16 @@ function netTests({ grpc, clock, rng }) { test.equal(actual.length > 0, true); test.deepEqual(Object.keys(actual[0]), expected); test.end(); - }); + }) + .catch((oops) => { test.fail(oops.message); test.end(); }); }, 'get block by hash - error test': (test) => { const blockHash = 'thisshouldbreak'; localNode().getBlock(blockHash).catch((err) => { test.deepEqual(err.message, 'Error: Failure to find block with hash thisshouldbreak'); test.end(); - }); + }) + .catch((oops) => { test.fail(oops.message); test.end(); }); }, 'simplified SHA256 hashing': (test) => { hashTest(test, null, RHOCore.wrapHash(sha256Hash), 'sha256Hash'); From a94990524977b8d5fc316abd1dd0fa8d400b6b4c Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Fri, 12 Apr 2019 16:57:45 -0500 Subject: [PATCH 14/36] REV: add date to vault cite --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c14e892..1e7b3ee 100644 --- a/index.js +++ b/index.js @@ -32,7 +32,9 @@ exports.Block = Block; * REV transaction, vault support * * Refs: - * - [REV Vault](https://rchain.atlassian.net/wiki/spaces/CORE/pages/652640311/Wallet+proposal) + * - [REV Vault][vault] Feb 2019 + * + * [vault]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/652640311/Wallet+proposal * * @example * // Suppose Alice generates a key pair. From 3c3d4a3ab8984f38ac56e6010f85e6849509b626 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Fri, 12 Apr 2019 16:58:09 -0500 Subject: [PATCH 15/36] RNode: doctests --- .markdown-doctest-setup.js | 25 +++++++++++++++++++++- src/rnodeAPI.js | 43 ++++++++++++++++++++++++++++++++++---- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/.markdown-doctest-setup.js b/.markdown-doctest-setup.js index 4a12509..a91a25f 100644 --- a/.markdown-doctest-setup.js +++ b/.markdown-doctest-setup.js @@ -1,16 +1,36 @@ /* global module, require, Buffer */ const assert = require('assert'); + const rchain = require('.'); const { RNode, RholangCrypto, REV, Ed25519keyPair, Hex } = rchain; + // mock enough of grpc // ISSUE: refactor overlap with test/testRNode.js +const CasperMessage = require('./protobuf/CasperMessage'); +const { Either } = CasperMessage; +const { BlockInfoWithoutTuplespace } = CasperMessage.coop.rchain.casper.protocol; + function DeployService(_hostPort, _chan) { return Object.freeze({ - doDeploy(_dd, _auto = false) { return 'Success!'; } + doDeploy(_dd, _auto = false) { return 'Success!'; }, + showBlocks(_depth) { + const block4 = { value: BlockInfoWithoutTuplespace.encode({ blockNumber: 4 }).finish() }; + + return Object.freeze({ + on(name, handler) { + if (name === 'data') { + handler({ success: { response: block4 } }); + } else if (name === 'end') { + handler(); + } + } + }); + }, }); } + const casper = { DeployService }; const proto = { coop: { rchain: { casper: { protocol: casper } } } }; const grpc = { @@ -20,6 +40,9 @@ const grpc = { module.exports = { babel: false, + require: { + grpc: grpc, // ISSUE: live access at test time? + }, globals: { assert, Buffer, grpc, diff --git a/src/rnodeAPI.js b/src/rnodeAPI.js index c4bd43f..f2b6fb3 100644 --- a/src/rnodeAPI.js +++ b/src/rnodeAPI.js @@ -61,13 +61,47 @@ type Decoder = { decode(reader: Uint8Array): T }; exports.RNode = RNode; /** - * Connect to an RChain node (RNode). + * RChain node API client + * + * + * Methods are asynchronous; they return promises. Where + * CasperMessage.proto specifies an Either, this API + * resolves the promise on success or rejects it on failure. + * + * The promise may also reject for the usual gRPC reasons such as + * `UNAVAILABLE: Connect Failed`. + * + * Refs: + * - [Node API Specification][nodeAPI] May 2018 + * - [CasperMessage.proto][cAPI] v0.9.1 bf1b2c6 Mar 28, 2019 and dependencies such as + * - [RhoTypes.proto][rAPI] + * - [RChain Protocol Documentation][apidoc] + * + * [cAPI]: https://github.com/rchain/rchain/blob/bf1b2c6/models/src/main/protobuf/CasperMessage.proto + * [rAPI]: https://github.com/rchain/rchain/blob/bf1b2c6/models/src/main/protobuf/RhoTypes.proto + * [apidoc]: https://github.com/rchain/rchain/blob/dev/docs/rnode-api/index.md + * + * [nodeAPI]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/392462355/Node+API+Specification * * @param grpc access to the network: grpc instance from the node grpc package * @param endPoint rnode gRPC service * @return a thin wrapper around a gRPC client stub + * + * @example + * // Get current block info + * const grpc = require('grpc'); + * + * const rnode = RNode(grpc, { host: 'localhost', port: 40401 }); + * rnode.getAllBlocks().then((blocks) => { assert(blocks[0].blockNumber > 0); }); + * + * // Deploy a simple Rholang process, given a key to authorize payment. + * const term = '@"world"!("Hello!")'; + * const myKey = Ed25519keyPair(Hex.decode('11'.repeat(32))); + * const timestamp = new Date('2019-04-12T17:59:29.274Z').valueOf(); + * const info = REV.SignDeployment.sign(myKey, { timestamp, term, phloLimit: 10000, phloPrice: 1 }); + * rnode.doDeploy(info, true).then((message) => { assert(message.startsWith('Success')); }); */ -function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */) { +function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */) /*: IRNode */{ const { host, port } = endPoint; assert.ok(host, 'endPoint.host missing'); assert.ok(port, 'endPoint.port missing'); @@ -83,7 +117,7 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * Ask rnode to compute ids of top level private names, given deploy parameters. * * @param d - * @param d.deployer - public key (of validating node?) as in doDeploy + * @param d.user - public key as in doDeploy deployer * @param d.timestamp - timestamp (ms) as in doDeploy * @param nameQty - how many names to preview? (max: 1024) * @memberof RNode @@ -135,7 +169,8 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * @param autoCreateBlock automatically create a new block after deploy transaction success * @return A promise for message * - * ISSUE: import / generate DeployData static type + * @throws {Error} Could not deploy, casper instance was not available yet. + * @throws {Error} Missing / invalid / wrong size signature */ async function doDeploy(deployData /*: IDeployData */, autoCreateBlock /*: boolean*/ = false) /*: Promise*/ { From a6dc3777c396a0ae28cb3044f5e0c851df75ec41 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Fri, 12 Apr 2019 16:58:30 -0500 Subject: [PATCH 16/36] docs: index; add build:docs-html script --- docs/index.md | 611 +++++++++++++++++++++++++++----------------------- package.json | 1 + 2 files changed, 330 insertions(+), 282 deletions(-) diff --git a/docs/index.md b/docs/index.md index 688f24b..bd5a3f7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -21,72 +21,73 @@ - [Parameters][18] - [RNode][19] - [Parameters][20] - - [createBlock][21] - - [doDeploy][22] - - [Parameters][23] - - [getAllBlocks][24] - - [Parameters][25] - - [getBlock][26] - - [Parameters][27] - - [listenForContinuationAtName][28] - - [Parameters][29] - - [listenForContinuationAtPrivateName][30] - - [Parameters][31] - - [listenForContinuationAtPublicName][32] - - [Parameters][33] - - [listenForDataAtName][34] - - [Parameters][35] - - [listenForDataAtPrivateName][36] - - [Parameters][37] - - [listenForDataAtPublicName][38] - - [Parameters][39] - - [previewPrivateChannels][40] - - [Parameters][41] - - [previewPrivateIds][42] - - [Parameters][43] -- [RHOCore][44] - - [dataToBytes][45] - - [fromJSData][46] - - [Parameters][47] - - [getIdFromUnforgeableName][48] - - [Parameters][49] - - [rhol][50] - - [Parameters][51] - - [toByteArray][52] - - [Parameters][53] - - [toJSData][54] - - [Parameters][55] - - [toRholang][56] - - [Parameters][57] - - [unforgeableWithId][58] - - [Parameters][59] - - [wrapHash][60] - - [Parameters][61] -- [Ed25519keyPair][62] - - [Parameters][63] - - [publicKey][64] - - [signBytes][65] - - [Parameters][66] - - [signBytesHex][67] - - [Parameters][68] - - [signText][69] - - [Parameters][70] - - [signTextHex][71] - - [Parameters][72] -- [REV][73] - - [Examples][74] - - [RevAddress][75] - - [fromPublicKey][76] - - [Parameters][77] - - [SignDeployment][78] - - [sign][79] - - [Parameters][80] - - [verify][81] - - [Parameters][82] + - [Examples][21] + - [createBlock][22] + - [doDeploy][23] + - [Parameters][24] + - [getAllBlocks][25] + - [Parameters][26] + - [getBlock][27] + - [Parameters][28] + - [listenForContinuationAtName][29] + - [Parameters][30] + - [listenForContinuationAtPrivateName][31] + - [Parameters][32] + - [listenForContinuationAtPublicName][33] + - [Parameters][34] + - [listenForDataAtName][35] + - [Parameters][36] + - [listenForDataAtPrivateName][37] + - [Parameters][38] + - [listenForDataAtPublicName][39] + - [Parameters][40] + - [previewPrivateChannels][41] + - [Parameters][42] + - [previewPrivateIds][43] + - [Parameters][44] +- [RHOCore][45] + - [dataToBytes][46] + - [fromJSData][47] + - [Parameters][48] + - [getIdFromUnforgeableName][49] + - [Parameters][50] + - [rhol][51] + - [Parameters][52] + - [toByteArray][53] + - [Parameters][54] + - [toJSData][55] + - [Parameters][56] + - [toRholang][57] + - [Parameters][58] + - [unforgeableWithId][59] + - [Parameters][60] + - [wrapHash][61] + - [Parameters][62] +- [Ed25519keyPair][63] + - [Parameters][64] + - [publicKey][65] + - [signBytes][66] + - [Parameters][67] + - [signBytesHex][68] + - [Parameters][69] + - [signText][70] + - [Parameters][71] + - [signTextHex][72] + - [Parameters][73] +- [REV][74] + - [Examples][75] + - [RevAddress][76] + - [fromPublicKey][77] + - [Parameters][78] + - [SignDeployment][79] + - [sign][80] + - [Parameters][81] + - [verify][82] + - [Parameters][83] ## RholangCrypto -[src/signing.js:178-178][83] +[src/signing.js:178-178][84] Cryptographic functions from Rholang @@ -102,7 +103,7 @@ refs: [vtut]: https://github.com/rchain/rchain/blob/3c64ca3/rholang/examples/tut-verify-channel.md -See also [RHOCore.wrapHash][84] +See also [RHOCore.wrapHash][85] ### Examples @@ -132,63 +133,63 @@ assert(!RholangCrypto.ed25519Verify(digest, sig2, halePub)); ### blake2b256Hash -[src/signing.js:134-138][85] +[src/signing.js:134-138][86] Blake2b 256 bit cryptographic hash function #### Parameters -- `input` **[Uint8Array][86]** any number of bytes +- `input` **[Uint8Array][87]** any number of bytes -Returns **[Uint8Array][86]** 256 bit (32 byte) hash +Returns **[Uint8Array][87]** 256 bit (32 byte) hash ### ed25519Verify -[src/signing.js:90-96][87] +[src/signing.js:90-96][88] Verify ed25519 signature #### Parameters -- `message` **[Uint8Array][86]** any number of bytes (TODO: test!) -- `sig` **[Uint8Array][86]** 64 byte ed25519 signature over message -- `publicKey` **[Uint8Array][86]** 32 byte ed25519 public key +- `message` **[Uint8Array][87]** any number of bytes (TODO: test!) +- `sig` **[Uint8Array][87]** 64 byte ed25519 signature over message +- `publicKey` **[Uint8Array][87]** 32 byte ed25519 public key -Returns **[boolean][88]** indicates whether the signature is valid +Returns **[boolean][89]** indicates whether the signature is valid ### keccak256Hash -[src/signing.js:121-123][89] +[src/signing.js:121-123][90] Keccak 256 bit cryptographic hash function (aka SHA-3) #### Parameters -- `input` **[Uint8Array][86]** any number of bytes +- `input` **[Uint8Array][87]** any number of bytes -Returns **[Uint8Array][86]** 256 bit (32 byte) hash +Returns **[Uint8Array][87]** 256 bit (32 byte) hash ### sha256Hash -[src/signing.js:107-111][90] +[src/signing.js:107-111][91] SHA-2 256 bit cryptographic hash function #### Parameters -- `input` **[Uint8Array][86]** any number of bytes +- `input` **[Uint8Array][87]** any number of bytes -Returns **[Uint8Array][86]** 256 bit (32 byte) hash +Returns **[Uint8Array][87]** 256 bit (32 byte) hash ## RegistryProxy -[index.js:64-64][91] +[index.js:66-66][92] Proxy method calls to registered RChain channels. ### callSource -[src/proxy.js:185-185][92] +[src/proxy.js:185-185][93] Make a rholang term for looking up a target and calling a method. @@ -201,7 +202,7 @@ Make a rholang term for looking up a target and calling a method. ### makeProxy -[src/proxy.js:64-64][93] +[src/proxy.js:64-64][94] Make an object that proxies method calls to registered RChain channels. @@ -222,7 +223,7 @@ For rholang calling conventions, see `callSource`. ### sendCall -[src/proxy.js:94-94][94] +[src/proxy.js:94-94][95] Call a method on a registered RChain channel. @@ -240,28 +241,67 @@ For rholang calling conventions, see `callSource`. ## RNode -[src/rnodeAPI.js:70-348][95] +[src/rnodeAPI.js:104-383][96] -Connect to an RChain node (RNode). +RChain node API client + +Methods are asynchronous; they return promises. Where +CasperMessage.proto specifies an Either, this API +resolves the promise on success or rejects it on failure. + +The promise may also reject for the usual gRPC reasons such as +`UNAVAILABLE: Connect Failed`. + +Refs: + +- [Node API Specification][nodeapi] May 2018 +- [CasperMessage.proto][capi] v0.9.1 bf1b2c6 Mar 28, 2019 and dependencies such as + - [RhoTypes.proto][rapi] +- [RChain Protocol Documentation][apidoc] + +[capi]: https://github.com/rchain/rchain/blob/bf1b2c6/models/src/main/protobuf/CasperMessage.proto + +[rapi]: https://github.com/rchain/rchain/blob/bf1b2c6/models/src/main/protobuf/RhoTypes.proto + +[apidoc]: https://github.com/rchain/rchain/blob/dev/docs/rnode-api/index.md + +[nodeapi]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/392462355/Node+API+Specification ### Parameters - `grpc` **grpcT** access to the network: grpc instance from the node grpc package -- `endPoint` **{host: [string][96], port: [number][97]}** rnode gRPC service +- `endPoint` **{host: [string][97], port: [number][98]}** rnode gRPC service + +### Examples -Returns **any** a thin wrapper around a gRPC client stub +```javascript +// Get current block info +const grpc = require('grpc'); + +const rnode = RNode(grpc, { host: 'localhost', port: 40401 }); +rnode.getAllBlocks().then((blocks) => { assert(blocks[0].blockNumber > 0); }); + +// Deploy a simple Rholang process, given a key to authorize payment. +const term = '@"world"!("Hello!")'; +const myKey = Ed25519keyPair(Hex.decode('11'.repeat(32))); +const timestamp = new Date('2019-04-12T17:59:29.274Z').valueOf(); +const info = REV.SignDeployment.sign(myKey, { timestamp, term, phloLimit: 10000, phloPrice: 1 }); +rnode.doDeploy(info, true).then((message) => { assert(message.startsWith('Success')); }); +``` + +Returns **IRNode** a thin wrapper around a gRPC client stub ### createBlock -[src/rnodeAPI.js:163-166][98] +[src/rnodeAPI.js:198-201][99] Creates a block on your node -Returns **[Promise][99]<[string][96]>** A promise for response message +Returns **[Promise][100]<[string][97]>** A promise for response message ### doDeploy -[src/rnodeAPI.js:140-156][100] +[src/rnodeAPI.js:175-191][101] Deploys a rholang term to a node @@ -277,35 +317,39 @@ Deploys a rholang term to a node - `deployData.phloLimit` - `deployData.phloPrice` - `deployData.validAfterBlockNumber` ???ISSUE??? -- `autoCreateBlock` **[boolean][88]** automatically create a new block after deploy transaction success +- `autoCreateBlock` **[boolean][89]** automatically create a new block after deploy transaction success + + +- Throws **[Error][102]** Could not deploy, casper instance was not available yet. +- Throws **[Error][102]** Missing / invalid / wrong size signature -Returns **[Promise][99]<[string][96]>** A promise for messageISSUE: import / generate DeployData static type +Returns **[Promise][100]<[string][97]>** A promise for message ### getAllBlocks -[src/rnodeAPI.js:322-332][101] +[src/rnodeAPI.js:357-367][103] Retrieve the block summary for a series of blocks starting with the most recent, including the number of blocks specified by the block_depth #### Parameters -- `blockDepth` **[number][97]** : Number indicating the number of blocks to retrieve +- `blockDepth` **[number][98]** : Number indicating the number of blocks to retrieve - Throws **any** Error if blockDepth < 1 or no blocks were able to be retrieved -Returns **[Promise][99]<BlockInfoWithoutTuplespace>** List of BlockInfoWithoutTuplespace structures for each block retrieved +Returns **[Promise][100]<BlockInfoWithoutTuplespace>** List of BlockInfoWithoutTuplespace structures for each block retrieved ### getBlock -[src/rnodeAPI.js:302-311][102] +[src/rnodeAPI.js:337-346][104] Retrieve a block with the tuplespace for a specific block hash #### Parameters -- `blockHash` **[string][96]** : String of the hash for the block being requested +- `blockHash` **[string][97]** : String of the hash for the block being requested - Throws **any** Error if the hash is blank or does not correspond to an existing block @@ -314,32 +358,32 @@ Returns **any** BlockInfo structure that will include all metadata and also incl ### listenForContinuationAtName -[src/rnodeAPI.js:281-292][103] +[src/rnodeAPI.js:316-327][105] Listen for a continuation at an individual name or JOINed set of names in the tuplespace #### Parameters -- `pars` **[Array][104]<IPar>** The names onwhich to listen -- `depth` **[number][97]** +- `pars` **[Array][106]<IPar>** The names onwhich to listen +- `depth` **[number][98]** - Throws **any** Error if status is not Success -Returns **[Promise][99]<ListeningNameContinuationResponse>** promise for DataWithBlockInfo +Returns **[Promise][100]<ListeningNameContinuationResponse>** promise for DataWithBlockInfo ### listenForContinuationAtPrivateName -[src/rnodeAPI.js:262-270][105] +[src/rnodeAPI.js:297-305][107] Listen for a continuation at an individual private name or JOINed set of private names in the tuplespace #### Parameters -- `nameIds` **[Array][104]<[string][96]>** a list hex strings representing the unforgeable names' Ids -- `depth` **[number][97]** (optional, default `1`) +- `nameIds` **[Array][106]<[string][97]>** a list hex strings representing the unforgeable names' Ids +- `depth` **[number][98]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -353,15 +397,15 @@ Returns **any** promise for ContinuationsWithBlockInfo ### listenForContinuationAtPublicName -[src/rnodeAPI.js:249-251][106] +[src/rnodeAPI.js:284-286][108] Listen for a continuation at an individual public name or JOINed set of public names in the tuplespace #### Parameters -- `nameObjs` **[Array][104]<[string][96]>** a list of names (strings) -- `depth` **[number][97]** (optional, default `1`) +- `nameObjs` **[Array][106]<[string][97]>** a list of names (strings) +- `depth` **[number][98]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -375,31 +419,31 @@ Returns **any** promise for ContinuationsWithBlockInfo ### listenForDataAtName -[src/rnodeAPI.js:221-237][107] +[src/rnodeAPI.js:256-272][109] Listen for data at a name in the RChain tuple-space. #### Parameters - `par` **IPar** : JSON-ish Par data. See protobuf/RhoTypes.proto -- `depth` **[number][97]** (optional, default `1`) +- `depth` **[number][98]** (optional, default `1`) - `blockDepth` : Number of blocks to look back in for the name to listen on - Throws **any** Error if status is not Success -Returns **[Promise][99]<[Array][104]<DataWithBlockInfo>>** : promise for DataWithBlockInfo\[] +Returns **[Promise][100]<[Array][106]<DataWithBlockInfo>>** : promise for DataWithBlockInfo\[] ### listenForDataAtPrivateName -[src/rnodeAPI.js:203-210][108] +[src/rnodeAPI.js:238-245][110] Listen for data at a PRIVATE name in the RChain tuple-space. #### Parameters -- `nameId` **[string][96]** : Hex string representing an UnforgeableName's Id -- `depth` **[number][97]** (optional, default `1`) +- `nameId` **[string][97]** : Hex string representing an UnforgeableName's Id +- `depth` **[number][98]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -413,14 +457,14 @@ Returns **any** promise for [DataWithBlockInfo] ### listenForDataAtPublicName -[src/rnodeAPI.js:190-192][109] +[src/rnodeAPI.js:225-227][111] Listen for data at a PUBLIC name in the RChain tuple-space. #### Parameters - `nameObj` **JSData** : JSON-ish data: string, number, {}, \[], ... -- `depth` **[number][97]** (optional, default `1`) +- `depth` **[number][98]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -434,7 +478,7 @@ Returns **any** promise for [DataWithBlockInfo] ### previewPrivateChannels -[src/rnodeAPI.js:113-119][110] +[src/rnodeAPI.js:147-153][112] Ask rnode to compute top level private channels, given deploy parameters. @@ -443,29 +487,28 @@ Ask rnode to compute top level private channels, given deploy parameters. - `d` **any** - `d.user` public key (of validating node?) as in doDeploy - `d.timestamp` timestamp (ms) as in doDeploy -- `nameQty` **[number][97]** how many names to preview? (max: 1024) +- `nameQty` **[number][98]** how many names to preview? (max: 1024) -Returns **[Promise][99]<[Array][104]<IPar>>** +Returns **[Promise][100]<[Array][106]<IPar>>** ### previewPrivateIds -[src/rnodeAPI.js:91-100][111] +[src/rnodeAPI.js:125-134][113] Ask rnode to compute ids of top level private names, given deploy parameters. #### Parameters - `d` **any** + - `d.user` public key as in doDeploy deployer - `d.timestamp` timestamp (ms) as in doDeploy - - `d.deployer` public key (of validating node?) as in doDeploy - - `d.user` -- `nameQty` **[number][97]** how many names to preview? (max: 1024) +- `nameQty` **[number][98]** how many names to preview? (max: 1024) -Returns **[Promise][99]<[Array][104]<[Buffer][112]>>** +Returns **[Promise][100]<[Array][106]<[Buffer][114]>>** ## RHOCore -[index.js:12-12][113] +[index.js:12-12][115] "we can detail a direct representation of JSON into a fragment of the rholang syntax referred to in the diagram @@ -475,11 +518,11 @@ below as RHOCore." -- \[Mobile process calculi for programming the blockchain[1] ### dataToBytes -[src/RHOCore.js:99-99][114] +[src/RHOCore.js:99-99][116] ### fromJSData -[src/RHOCore.js:27-82][115] +[src/RHOCore.js:27-82][117] Build Rholang expression from Javascript data. @@ -494,33 +537,33 @@ Returns **any** : A rholang term in Protobuf's JSON representation, ### getIdFromUnforgeableName -[src/RHOCore.js:331-336][116] +[src/RHOCore.js:331-336][118] Convert the ack channel into a HEX-formatted unforgeable name #### Parameters -- `par` **IPar** : JSON-ish Par data: [https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto][117] +- `par` **IPar** : JSON-ish Par data: [https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto][119] - Throws **any** Error if the Par does not represent an unforgeable name -Returns **[string][96]** HEX-formatted string of unforgeable name's Id +Returns **[string][97]** HEX-formatted string of unforgeable name's Id ### rhol -[src/RHOCore.js:345-355][118] +[src/RHOCore.js:345-355][120] Template tag for RHOCore interpolation #### Parameters -- `template` **[Array][104]<[string][96]>** -- `subs` **...[Array][104]<JsonExt<([URL][119] | GPrivate)>>** +- `template` **[Array][106]<[string][97]>** +- `subs` **...[Array][106]<JsonExt<([URL][121] | GPrivate)>>** ### toByteArray -[src/RHOCore.js:90-93][120] +[src/RHOCore.js:90-93][122] Turns a rholang term into a byte-array compatible with Rholang @@ -528,11 +571,11 @@ Turns a rholang term into a byte-array compatible with Rholang - `termObj` **IPar** -Returns **[Uint8Array][86]** +Returns **[Uint8Array][87]** ### toJSData -[src/RHOCore.js:169-233][121] +[src/RHOCore.js:169-233][123] Converts an RHOCore object back to JavaScript data @@ -540,11 +583,11 @@ Converts an RHOCore object back to JavaScript data - `par` **IPar** A RHOCore representation of a Rholang term -Returns **JsonExt<([URL][119] | GPrivate)>** JSON-serializable data +Returns **JsonExt<([URL][121] | GPrivate)>** JSON-serializable data ### toRholang -[src/RHOCore.js:246-299][122] +[src/RHOCore.js:246-299][124] Converts an RHOCore object into Rholang source form @@ -552,21 +595,21 @@ Converts an RHOCore object into Rholang source form - `par` **IPar** A RHOCore representation of a Rholang term -Returns **[string][96]** A rholang stringISSUE: Use intersection types to constrain par param further than IPar? +Returns **[string][97]** A rholang stringISSUE: Use intersection types to constrain par param further than IPar? ### unforgeableWithId -[src/RHOCore.js:307-310][123] +[src/RHOCore.js:307-310][125] Get printable form of unforgeable name, given id. #### Parameters -- `id` **[Uint8Array][86]** +- `id` **[Uint8Array][87]** ### wrapHash -[src/RHOCore.js:115-115][124] +[src/RHOCore.js:115-115][126] #### Parameters @@ -579,7 +622,7 @@ Returns **any** HEX-formatted string representing the computed hash ## Ed25519keyPair -[src/signing.js:38-75][125] +[src/signing.js:38-75][127] Build key pair from seed. @@ -589,7 +632,7 @@ Build key pair from seed. ### publicKey -[src/signing.js:70-70][126] +[src/signing.js:70-70][128] ISSUE: if the caller wants the bytes, we go bytes -> hex -> bytes @@ -597,53 +640,55 @@ Returns **HexStr<PublicKey>** ### signBytes -[src/signing.js:46-48][127] +[src/signing.js:46-48][129] #### Parameters -- `bytes` **[Uint8Array][86]** +- `bytes` **[Uint8Array][87]** Returns **Signature** ### signBytesHex -[src/signing.js:56-56][128] +[src/signing.js:56-56][130] #### Parameters -- `bs` **[Uint8Array][86]** +- `bs` **[Uint8Array][87]** Returns **HexStr<Signature>** ### signText -[src/signing.js:60-60][129] +[src/signing.js:60-60][131] #### Parameters -- `text` **[string][96]** +- `text` **[string][97]** Returns **Signature** ### signTextHex -[src/signing.js:64-64][130] +[src/signing.js:64-64][132] #### Parameters -- `text` **[string][96]** +- `text` **[string][97]** Returns **HexStr<Signature>** ## REV -[index.js:56-56][131] +[index.js:58-58][133] REV transaction, vault support Refs: -- [REV Vault][132] +- [REV Vault][vault] Feb 2019 + +[vault]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/652640311/Wallet+proposal ### Examples @@ -669,7 +714,7 @@ assert(REV.SignDeployment.verify(info)); ### RevAddress -[src/revAddress.js:38-64][133] +[src/revAddress.js:38-64][134] A RevAddress refers to a REV vault. @@ -677,32 +722,32 @@ Use `toString()` to get base58 form. Refs: -- [RevAddress.scala][134] -- [AddressTools.scala][135] +- [RevAddress.scala][135] +- [AddressTools.scala][136] #### fromPublicKey -[src/revAddress.js:46-61][136] +[src/revAddress.js:46-61][137] Compute REV Address from public key ##### Parameters -- `pk` **[Uint8Array][86]** ed25519 public key +- `pk` **[Uint8Array][87]** ed25519 public key Returns **IRevAddress** ### SignDeployment -[src/rnodeAPI.js:384-417][137] +[src/rnodeAPI.js:419-452][138] -a port of [casper/SignDeployment.scala][138] +a port of [casper/SignDeployment.scala][139] ISSUE: only ed25519 is supported. #### sign -[src/rnodeAPI.js:396-402][139] +[src/rnodeAPI.js:431-437][140] ##### Parameters @@ -713,13 +758,13 @@ Returns **DeployData** #### verify -[src/rnodeAPI.js:407-414][140] +[src/rnodeAPI.js:442-449][141] ##### Parameters - `deployData` **DeployData** -Returns **[boolean][88]** +Returns **[boolean][89]** [2]: #rholangcrypto @@ -759,242 +804,244 @@ Returns **[boolean][88]** [20]: #parameters-7 -[21]: #createblock +[21]: #examples-1 + +[22]: #createblock -[22]: #dodeploy +[23]: #dodeploy -[23]: #parameters-8 +[24]: #parameters-8 -[24]: #getallblocks +[25]: #getallblocks -[25]: #parameters-9 +[26]: #parameters-9 -[26]: #getblock +[27]: #getblock -[27]: #parameters-10 +[28]: #parameters-10 -[28]: #listenforcontinuationatname +[29]: #listenforcontinuationatname -[29]: #parameters-11 +[30]: #parameters-11 -[30]: #listenforcontinuationatprivatename +[31]: #listenforcontinuationatprivatename -[31]: #parameters-12 +[32]: #parameters-12 -[32]: #listenforcontinuationatpublicname +[33]: #listenforcontinuationatpublicname -[33]: #parameters-13 +[34]: #parameters-13 -[34]: #listenfordataatname +[35]: #listenfordataatname -[35]: #parameters-14 +[36]: #parameters-14 -[36]: #listenfordataatprivatename +[37]: #listenfordataatprivatename -[37]: #parameters-15 +[38]: #parameters-15 -[38]: #listenfordataatpublicname +[39]: #listenfordataatpublicname -[39]: #parameters-16 +[40]: #parameters-16 -[40]: #previewprivatechannels +[41]: #previewprivatechannels -[41]: #parameters-17 +[42]: #parameters-17 -[42]: #previewprivateids +[43]: #previewprivateids -[43]: #parameters-18 +[44]: #parameters-18 -[44]: #rhocore +[45]: #rhocore -[45]: #datatobytes +[46]: #datatobytes -[46]: #fromjsdata +[47]: #fromjsdata -[47]: #parameters-19 +[48]: #parameters-19 -[48]: #getidfromunforgeablename +[49]: #getidfromunforgeablename -[49]: #parameters-20 +[50]: #parameters-20 -[50]: #rhol +[51]: #rhol -[51]: #parameters-21 +[52]: #parameters-21 -[52]: #tobytearray +[53]: #tobytearray -[53]: #parameters-22 +[54]: #parameters-22 -[54]: #tojsdata +[55]: #tojsdata -[55]: #parameters-23 +[56]: #parameters-23 -[56]: #torholang +[57]: #torholang -[57]: #parameters-24 +[58]: #parameters-24 -[58]: #unforgeablewithid +[59]: #unforgeablewithid -[59]: #parameters-25 +[60]: #parameters-25 -[60]: #wraphash +[61]: #wraphash -[61]: #parameters-26 +[62]: #parameters-26 -[62]: #ed25519keypair +[63]: #ed25519keypair -[63]: #parameters-27 +[64]: #parameters-27 -[64]: #publickey +[65]: #publickey -[65]: #signbytes +[66]: #signbytes -[66]: #parameters-28 +[67]: #parameters-28 -[67]: #signbyteshex +[68]: #signbyteshex -[68]: #parameters-29 +[69]: #parameters-29 -[69]: #signtext +[70]: #signtext -[70]: #parameters-30 +[71]: #parameters-30 -[71]: #signtexthex +[72]: #signtexthex -[72]: #parameters-31 +[73]: #parameters-31 -[73]: #rev +[74]: #rev -[74]: #examples-1 +[75]: #examples-2 -[75]: #revaddress +[76]: #revaddress -[76]: #frompublickey +[77]: #frompublickey -[77]: #parameters-32 +[78]: #parameters-32 -[78]: #signdeployment +[79]: #signdeployment -[79]: #sign +[80]: #sign -[80]: #parameters-33 +[81]: #parameters-33 -[81]: #verify +[82]: #verify -[82]: #parameters-34 +[83]: #parameters-34 -[83]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L178-L178 "Source code on GitHub" +[84]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L178-L178 "Source code on GitHub" -[84]: #rhocorewraphash +[85]: #rhocorewraphash -[85]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L134-L138 "Source code on GitHub" +[86]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L134-L138 "Source code on GitHub" -[86]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array +[87]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array -[87]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L90-L96 "Source code on GitHub" +[88]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L90-L96 "Source code on GitHub" -[88]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[89]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[89]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L121-L123 "Source code on GitHub" +[90]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L121-L123 "Source code on GitHub" -[90]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L107-L111 "Source code on GitHub" +[91]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L107-L111 "Source code on GitHub" -[91]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/index.js#L64-L64 "Source code on GitHub" +[92]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/index.js#L66-L66 "Source code on GitHub" -[92]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/proxy.js#L185-L185 "Source code on GitHub" +[93]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/proxy.js#L185-L185 "Source code on GitHub" -[93]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/proxy.js#L64-L64 "Source code on GitHub" +[94]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/proxy.js#L64-L64 "Source code on GitHub" -[94]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/proxy.js#L94-L94 "Source code on GitHub" +[95]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/proxy.js#L94-L94 "Source code on GitHub" -[95]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L70-L348 "Source code on GitHub" +[96]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L104-L383 "Source code on GitHub" -[96]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[97]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[97]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[98]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[98]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L163-L166 "Source code on GitHub" +[99]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L198-L201 "Source code on GitHub" -[99]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise +[100]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise -[100]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L140-L156 "Source code on GitHub" +[101]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L175-L191 "Source code on GitHub" -[101]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L322-L332 "Source code on GitHub" +[102]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error -[102]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L302-L311 "Source code on GitHub" +[103]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L357-L367 "Source code on GitHub" -[103]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L281-L292 "Source code on GitHub" +[104]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L337-L346 "Source code on GitHub" -[104]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array +[105]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L316-L327 "Source code on GitHub" -[105]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L262-L270 "Source code on GitHub" +[106]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array -[106]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L249-L251 "Source code on GitHub" +[107]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L297-L305 "Source code on GitHub" -[107]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L221-L237 "Source code on GitHub" +[108]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L284-L286 "Source code on GitHub" -[108]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L203-L210 "Source code on GitHub" +[109]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L256-L272 "Source code on GitHub" -[109]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L190-L192 "Source code on GitHub" +[110]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L238-L245 "Source code on GitHub" -[110]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L113-L119 "Source code on GitHub" +[111]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L225-L227 "Source code on GitHub" -[111]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L91-L100 "Source code on GitHub" +[112]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L147-L153 "Source code on GitHub" -[112]: https://nodejs.org/api/buffer.html +[113]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L125-L134 "Source code on GitHub" -[113]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/index.js#L12-L12 "Source code on GitHub" +[114]: https://nodejs.org/api/buffer.html -[114]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L99-L99 "Source code on GitHub" +[115]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/index.js#L12-L12 "Source code on GitHub" -[115]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L27-L82 "Source code on GitHub" +[116]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L99-L99 "Source code on GitHub" -[116]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L331-L336 "Source code on GitHub" +[117]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L27-L82 "Source code on GitHub" -[117]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto +[118]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L331-L336 "Source code on GitHub" -[118]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L345-L355 "Source code on GitHub" +[119]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto -[119]: https://developer.mozilla.org/docs/Web/API/URL/URL +[120]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L345-L355 "Source code on GitHub" -[120]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L90-L93 "Source code on GitHub" +[121]: https://developer.mozilla.org/docs/Web/API/URL/URL -[121]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L169-L233 "Source code on GitHub" +[122]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L90-L93 "Source code on GitHub" -[122]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L246-L299 "Source code on GitHub" +[123]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L169-L233 "Source code on GitHub" -[123]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L307-L310 "Source code on GitHub" +[124]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L246-L299 "Source code on GitHub" -[124]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/RHOCore.js#L115-L115 "Source code on GitHub" +[125]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L307-L310 "Source code on GitHub" -[125]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L38-L75 "Source code on GitHub" +[126]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L115-L115 "Source code on GitHub" -[126]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L70-L70 "Source code on GitHub" +[127]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L38-L75 "Source code on GitHub" -[127]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L46-L48 "Source code on GitHub" +[128]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L70-L70 "Source code on GitHub" -[128]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L56-L56 "Source code on GitHub" +[129]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L46-L48 "Source code on GitHub" -[129]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L60-L60 "Source code on GitHub" +[130]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L56-L56 "Source code on GitHub" -[130]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/signing.js#L64-L64 "Source code on GitHub" +[131]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L60-L60 "Source code on GitHub" -[131]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/index.js#L56-L56 "Source code on GitHub" +[132]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L64-L64 "Source code on GitHub" -[132]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/652640311/Wallet+proposal +[133]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/index.js#L58-L58 "Source code on GitHub" -[133]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/revAddress.js#L38-L64 "Source code on GitHub" +[134]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/revAddress.js#L38-L64 "Source code on GitHub" -[134]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala +[135]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala -[135]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala +[136]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala -[136]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/revAddress.js#L46-L61 "Source code on GitHub" +[137]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/revAddress.js#L46-L61 "Source code on GitHub" -[137]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L384-L417 "Source code on GitHub" +[138]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L419-L452 "Source code on GitHub" -[138]: https://github.com/rchain/rchain/blob/9ae5825/casper/src/main/scala/coop/rchain/casper/SignDeployment.scala +[139]: https://github.com/rchain/rchain/blob/9ae5825/casper/src/main/scala/coop/rchain/casper/SignDeployment.scala -[139]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L396-L402 "Source code on GitHub" +[140]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L431-L437 "Source code on GitHub" -[140]: https://git@github.com/:dckc/RChain-API/blob/f197c9ae5b22b945c7d9021ca32bd0d4061f235e/src/rnodeAPI.js#L407-L414 "Source code on GitHub" +[141]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L442-L449 "Source code on GitHub" diff --git a/package.json b/package.json index 22acb7f..21dd66d 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "postinstall": "cd rclient; npm install --no-package-lock", "testAll": "npm run check && npm run integrationTest", "build:docs": "documentation build -f md --github --sort-order alpha index.js src/**.js --shallow -o docs/index.md && markdown-doctest", + "build:docs-html": "documentation build -f html --github --sort-order alpha index.js src/**.js --shallow -o docs/", "doc-watch": "documentation serve --watch index.js src/**.js --shallow", "check": "npm run test && npm run lint && npm run flow-check", "test-jest": "jest", From 53847fc239b64eba4b90bdcb788fa1108f6b52ba Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 13 Apr 2019 13:40:53 -0500 Subject: [PATCH 17/36] rclient: prune obsolete claim code --- rclient/src/main.js | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/rclient/src/main.js b/rclient/src/main.js index 238ed28..3809d78 100755 --- a/rclient/src/main.js +++ b/rclient/src/main.js @@ -34,9 +34,7 @@ Usage: rclient [options] import LABEL JSONFILE rclient [options] info LABEL rclient [options] genVault LABEL AMOUNT - rclient [options] claim LABEL rclient [options] balance LABEL - rclient [options] publish [--claimed] LABEL rclient [options] transfer --from=LABEL --to=REVADDR AMOUNT rclient [options] sign LABEL [ --json ] DATAFILE rclient [options] deploy RHOLANG @@ -147,9 +145,6 @@ async function main( } else if (cli.genVault) { const io = await ioTools(); await genVault(cli.LABEL, argInt('AMOUNT'), payWith, io); - } else if (cli.claim) { - const io = await ioTools(); - await claimAccount(cli.LABEL, payWith, io); } else if (cli.balance) { const io = await ioTools(); await getBalance(cli.LABEL, payWith, io); @@ -395,36 +390,6 @@ async function genVault( console.log({ revAddr, label, amount, result }); } -const rhoKeccakHash = data => keccak256Hash(RHOCore.toByteArray(RHOCore.fromJSData(data))); -const sigDERHex = sigObj => b2h(secp256k1.signatureExport(sigObj.signature)); - -async function claimAccount(label, priceInfo, { keyStore, toolsMod, getpass, rnode, clock }) { - let privKey; - let pubKey; - let ethAddr; - try { - privKey = await loadKey(keyStore, label, [], { getpass }); - pubKey = privateToPublic(privKey); - ethAddr = `0x${b2h(pubToAddress(pubKey))}`; - // ISSUE: logging is not just FYI here; - // should be passed as an explicit capability. - console.log({ label, pubKey: b2h(pubKey), ethAddr }); - } catch (err) { - throw new ExitStatus(`cannot load public key: ${err.message}`); - } - - function fixArgs(args, [statusOut]) { - console.log({ args, statusOut }); - const out = [...args]; - out[2] = sigDERHex(secp256k1.sign(rhoKeccakHash([b2h(pubKey), statusOut]), privKey)); - return out; - } - const tools = makeProxy(toolsMod.URI, priceInfo, { rnode, clock, fixArgs, predeclare: ['s'] }); - const pk = await outcome(tools.claim(ethAddr, b2h(pubKey), 'sig goes here')); - - console.log({ ethAddr, pk }); -} - async function getBalance(label, priceInfo, { keyStore, toolsMod, getpass, rnode, clock, delay }) { const { revAddr } = await loadRevAddr(label, [], { keyStore, getpass }); From 3a562a3ea37112bb0eb944001bc0ae6f4cc0ed1c Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 13 Apr 2019 13:41:12 -0500 Subject: [PATCH 18/36] proxy: fix signed deploy handling --- rclient/src/main.js | 36 +++++++++++++++++++++--------------- src/loading.js | 3 ++- src/proxy.js | 27 ++++++++++++++++++--------- test/testRNode.js | 2 +- 4 files changed, 42 insertions(+), 26 deletions(-) diff --git a/rclient/src/main.js b/rclient/src/main.js index 3809d78..024df06 100755 --- a/rclient/src/main.js +++ b/rclient/src/main.js @@ -211,10 +211,9 @@ async function register( const toLoad = status.filter(({ mod }) => !mod); if (toLoad.length > 0) { console.log('loading:', toLoad.map(({ file }) => file.name())); - const privKey = await loadKey(keyStore, label, [], { getpass }); - const pmtKey = Ed25519keyPair(privKey); + const { signingKey } = await loadRevAddr(label, [], { keyStore, getpass }); const loaded = await ioOrExit( - loadRhoModules(toLoad.map(({ src }) => src), payWith(pmtKey), { rnode, clock, delay }), + loadRhoModules(toLoad.map(({ src }) => src), payWith(signingKey), { rnode, clock, delay }), ); registry.set(collect(loaded.map((m, ix) => [toLoad[ix].srcHash, m]))); loaded.forEach((m, ix) => { @@ -370,19 +369,22 @@ async function loadRevAddr(label, notice, { keyStore, getpass }) { const privKey = await loadKey(keyStore, label, notice, { getpass }); const edKey = Ed25519keyPair(privKey); const revAddr = RevAddress.fromPublicKey(h2b(edKey.publicKey())).toString(); - return { label, revAddr, publicKey: edKey.publicKey() }; + return { label, revAddr, signingKey: edKey, publicKey: edKey.publicKey() }; } catch (err) { throw new ExitStatus(`cannot load public key: ${err.message}`); } } async function genVault( - label, amount, priceInfo, + label, amount, payWith, { keyStore, getpass, toolsMod, rnode, clock, delay }, ) { - const { revAddr } = await loadRevAddr(label, [], { keyStore, getpass }); + const { revAddr, signingKey, publicKey } = await loadRevAddr(label, [], { keyStore, getpass }); - const tools = makeProxy(toolsMod.URI, priceInfo, { rnode, clock, delay }); + const tools = makeProxy( + toolsMod.URI, h2b(publicKey), payWith(signingKey), + { rnode, clock, delay }, + ); const result = await tools.genVault(revAddr, amount); if (result && typeof result === 'object' && typeof result.message === 'string') { throw new ExitStatus(`cannot generate vault: ${result.message}`); @@ -391,26 +393,30 @@ async function genVault( } -async function getBalance(label, priceInfo, { keyStore, toolsMod, getpass, rnode, clock, delay }) { - const { revAddr } = await loadRevAddr(label, [], { keyStore, getpass }); +async function getBalance(label, payWith, { keyStore, toolsMod, getpass, rnode, clock, delay }) { + const { revAddr, publicKey, signingKey } = await loadRevAddr(label, [], { keyStore, getpass }); - const tools = makeProxy(toolsMod.URI, priceInfo, { rnode, clock, delay }); + const tools = makeProxy( + toolsMod.URI, h2b(publicKey), payWith(signingKey), + { rnode, clock, delay }, + ); const balance = await tools.balance(revAddr); console.log({ revAddr, balance, label }); } async function transferPayment( - // ISSUE: paymentInfo confuses phloPrice and such with the REV we're sending here. - amount, fromLabel, toAddr, paymentInfo, + amount, fromLabel, toAddr, payWith, { keyStore, toolsMod, getpass, rnode, clock, delay }, ) { const notice = [[`send ${String(amount)} from ${fromLabel} to ${String(toAddr)}`]]; - const { revAddr, publicKey } = await loadRevAddr(fromLabel, notice, { keyStore, getpass }); + const { revAddr, publicKey, signingKey } = await loadRevAddr( + fromLabel, notice, + { keyStore, getpass }, + ); const tools = makeProxy( - toolsMod.URI, - { ...paymentInfo, deployer: h2b(publicKey) }, + toolsMod.URI, h2b(publicKey), payWith(signingKey), { rnode, clock, delay }, ); diff --git a/src/loading.js b/src/loading.js index 2ab5cd7..fca9a49 100644 --- a/src/loading.js +++ b/src/loading.js @@ -17,6 +17,7 @@ const LOADER_TEMPLATE = link('./loader.rho'); /*:: import type { DeployInfo } from '../protobuf/CasperMessage'; import type { IRNode } from '..'; +import type { PayFor } from './proxy'; interface LoadAccess { rnode: IRNode, @@ -35,7 +36,7 @@ export type ModuleInfo = { exports.loadRhoModules = loadRhoModules; async function loadRhoModules( - sources /*: string[]*/, payFor /*: DeployInfo => DeployInfo */, + sources /*: string[]*/, payFor /*: PayFor */, { rnode, clock, delay } /*: LoadAccess */, ) /*: Promise */ { let t1 = null; diff --git a/src/proxy.js b/src/proxy.js index ac547ea..ed1cad3 100644 --- a/src/proxy.js +++ b/src/proxy.js @@ -40,6 +40,11 @@ interface ProxyOpts extends SendOpts { clock: () => Date } +type PK = Uint8Array; +type Sig = Uint8Array; + +export type PayFor = T => T & { deployer: PK, sig: Sig }; + */ @@ -64,11 +69,12 @@ interface ProxyOpts extends SendOpts { exports.makeProxy = makeProxy; function makeProxy( target /*: URL */, - deployData /*: $ReadOnly */, + deployer /*: Uint8Array */, + payFor /*: PayFor */, opts /*: ProxyOpts */, ) /*: Receiver */{ const { clock } = opts; - const sendIt = msg => sendCall(msg, { ...deployData, timestamp: clock().valueOf() }, opts); + const sendIt = msg => sendCall(msg, clock().valueOf(), deployer, payFor, opts); return new Proxy({}, { get: (_, method) => (...args) => sendIt({ target, method, args }), // override set to make it read-only? @@ -94,7 +100,9 @@ function makeProxy( exports.sendCall = sendCall; async function sendCall( { target, method, args } /*: Message*/, - deployData /*: $ReadOnly */, + timestamp /*: number*/, + deployer /*: Uint8Array */, + payFor /*: PayFor*/, opts /*: SendOpts */, ) { const { rnode } = opts; @@ -105,7 +113,7 @@ async function sendCall( returnChan = opts.returnCh; } else { const chans /*: Buffer[] */ = await rnode.previewPrivateIds( - { user: deployData.deployer, timestamp: deployData.timestamp }, + { user: deployer, timestamp }, 1 + (opts.predeclare || []).length, ); // console.log({ chans: chans.map(b2h) }); @@ -124,22 +132,23 @@ async function sendCall( { ...opts, chanArgs }, ); console.log(term); - return runRholang(term, returnChan, deployData, opts, method || '?'); + return runRholang(term, timestamp, payFor, returnChan, opts, method || '?'); } exports.runRholang = runRholang; async function runRholang( term /*: string */, + timestamp /*: number */, + payFor /*: PayFor */, returnChan /*: IPar */, - deployData /*: $ReadOnly */, opts /*: SendOpts */, label /*: string */ = '', ) /**/ { const { rnode } = opts; - //@@@@@@@this can't work with signed deploys - // console.log({ deployData, note: 'placeholder term' }); - const deployResult = await rnode.doDeploy({ ...deployData, term }, true); + const deployData = payFor({ term, timestamp }); + // console.log('runRholang', { deployData, note: 'placeholder term' }); + const deployResult = await rnode.doDeploy(deployData, true); console.log({ deployResult }); // ISSUE: return block hash to caller? const blockResults = await pollAt(returnChan, label, { delay: opts.delay, rnode }); diff --git a/test/testRNode.js b/test/testRNode.js index 59b0f3e..166eddc 100644 --- a/test/testRNode.js +++ b/test/testRNode.js @@ -138,7 +138,7 @@ async function runAndListen( const key = Ed25519keyPair(defaultSec); return RegistryProxy.runRholang( - term, RHOCore.fromJSData(returnChannel), payFor({ term, timestamp }, key), + term, timestamp, info => payFor(info, key), RHOCore.fromJSData(returnChannel), { rnode: node }, ); } From d21c9aecab5da673576a3507d8e0869ee5017da5 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 13 Apr 2019 14:08:56 -0500 Subject: [PATCH 19/36] parse / validate REV addresses --- rclient/src/main.js | 6 ++++++ src/revAddress.js | 45 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/rclient/src/main.js b/rclient/src/main.js index 024df06..713a68d 100755 --- a/rclient/src/main.js +++ b/rclient/src/main.js @@ -410,6 +410,12 @@ async function transferPayment( { keyStore, toolsMod, getpass, rnode, clock, delay }, ) { const notice = [[`send ${String(amount)} from ${fromLabel} to ${String(toAddr)}`]]; + try { + RevAddress.parse(toAddr); + } catch (badAddr) { + throw new ExitStatus(`bad destination address: ${badAddr.message}`); + } + const { revAddr, publicKey, signingKey } = await loadRevAddr( fromLabel, notice, { keyStore, getpass }, diff --git a/src/revAddress.js b/src/revAddress.js index cf13f0b..cf56bdb 100644 --- a/src/revAddress.js +++ b/src/revAddress.js @@ -60,7 +60,46 @@ const RevAddress = (() => { }); } - return Object.freeze({ fromPublicKey }); + /** + * Parse REV Address + * + * @throws Error on ill-formed address + * @memberof REV.RevAddress + */ + function parse(address /*: string */) /*: IRevAddress */{ + function validateLength(bytes) { + if (bytes.length !== prefix.length + (256 / 8) + checksumLength) { + throw new Error('Invalid address length'); + } + } + + function validateChecksum(bytes) { + const checksumStart = prefix.length + (256 / 8); + const [payload, checksum] = splitAt(bytes, checksumStart); + + if (computeChecksum(payload) !== checksum) { throw new Error('Invalid checksum'); } + return [payload, checksum]; + } + + function parseKeyHash(payload) { + const [actualPrefix, keyHash] = splitAt(payload, prefix.length); + if (actualPrefix !== prefix) { throw new Error('Invalid prefix'); } + + return keyHash; + } + + const decodedAddress = base58.decode(address); + validateLength(decodedAddress); + const [payload, checksum] = validateChecksum(decodedAddress); + const keyHash = parseKeyHash(payload); + + return Object.freeze({ + address: { prefix, keyHash, checksum }, + toString: () => address, + }); + } + + return Object.freeze({ fromPublicKey, parse }); })(); exports.RevAddress = RevAddress; @@ -68,6 +107,10 @@ function computeChecksum(toCheck /*: Uint8Array */) /*: Uint8Array */ { return blake2b256Hash(toCheck).slice(0, checksumLength); } +function splitAt(bs, x) { + return [bs.slice(0, x), bs.slice(x)]; +} + function concat(a, b) { const out = new Uint8Array(a.length + b.length); out.set(a); From 7b676801261fdaed4f4fa47d39cf36ef47f2adb1 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 13 Apr 2019 14:17:18 -0500 Subject: [PATCH 20/36] example for RevAddress.parse --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index 1e7b3ee..618e3cd 100644 --- a/index.js +++ b/index.js @@ -54,6 +54,12 @@ exports.Block = Block; * assert.deepEqual(info.deployer, Hex.decode(alicePub)); * assert.equal(Hex.encode(info.sig).slice(0, 16), 'ebc47a0a923b7feb'); * assert(REV.SignDeployment.verify(info)); + * + * @example + * // We can check a REV address before deploying any code. + * assert.throws(() => { + * REV.RevAddress.parse('123'); + * }); */ const REV = { SignDeployment, RevAddress }; exports.REV = REV; From 39aac41fd41d56cffd06daa0716574507f276918 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 13 Apr 2019 14:17:39 -0500 Subject: [PATCH 21/36] docs: regenerate --- docs/index.md | 356 +++++++++++++++++++++++++++----------------------- 1 file changed, 193 insertions(+), 163 deletions(-) diff --git a/docs/index.md b/docs/index.md index bd5a3f7..1b1c786 100644 --- a/docs/index.md +++ b/docs/index.md @@ -79,15 +79,17 @@ - [RevAddress][76] - [fromPublicKey][77] - [Parameters][78] - - [SignDeployment][79] - - [sign][80] - - [Parameters][81] - - [verify][82] + - [parse][79] + - [Parameters][80] + - [SignDeployment][81] + - [sign][82] - [Parameters][83] + - [verify][84] + - [Parameters][85] ## RholangCrypto -[src/signing.js:178-178][84] +[src/signing.js:178-178][86] Cryptographic functions from Rholang @@ -103,7 +105,7 @@ refs: [vtut]: https://github.com/rchain/rchain/blob/3c64ca3/rholang/examples/tut-verify-channel.md -See also [RHOCore.wrapHash][85] +See also [RHOCore.wrapHash][87] ### Examples @@ -133,63 +135,63 @@ assert(!RholangCrypto.ed25519Verify(digest, sig2, halePub)); ### blake2b256Hash -[src/signing.js:134-138][86] +[src/signing.js:134-138][88] Blake2b 256 bit cryptographic hash function #### Parameters -- `input` **[Uint8Array][87]** any number of bytes +- `input` **[Uint8Array][89]** any number of bytes -Returns **[Uint8Array][87]** 256 bit (32 byte) hash +Returns **[Uint8Array][89]** 256 bit (32 byte) hash ### ed25519Verify -[src/signing.js:90-96][88] +[src/signing.js:90-96][90] Verify ed25519 signature #### Parameters -- `message` **[Uint8Array][87]** any number of bytes (TODO: test!) -- `sig` **[Uint8Array][87]** 64 byte ed25519 signature over message -- `publicKey` **[Uint8Array][87]** 32 byte ed25519 public key +- `message` **[Uint8Array][89]** any number of bytes (TODO: test!) +- `sig` **[Uint8Array][89]** 64 byte ed25519 signature over message +- `publicKey` **[Uint8Array][89]** 32 byte ed25519 public key -Returns **[boolean][89]** indicates whether the signature is valid +Returns **[boolean][91]** indicates whether the signature is valid ### keccak256Hash -[src/signing.js:121-123][90] +[src/signing.js:121-123][92] Keccak 256 bit cryptographic hash function (aka SHA-3) #### Parameters -- `input` **[Uint8Array][87]** any number of bytes +- `input` **[Uint8Array][89]** any number of bytes -Returns **[Uint8Array][87]** 256 bit (32 byte) hash +Returns **[Uint8Array][89]** 256 bit (32 byte) hash ### sha256Hash -[src/signing.js:107-111][91] +[src/signing.js:107-111][93] SHA-2 256 bit cryptographic hash function #### Parameters -- `input` **[Uint8Array][87]** any number of bytes +- `input` **[Uint8Array][89]** any number of bytes -Returns **[Uint8Array][87]** 256 bit (32 byte) hash +Returns **[Uint8Array][89]** 256 bit (32 byte) hash ## RegistryProxy -[index.js:66-66][92] +[index.js:72-72][94] Proxy method calls to registered RChain channels. ### callSource -[src/proxy.js:185-185][93] +[src/proxy.js:194-194][95] Make a rholang term for looking up a target and calling a method. @@ -202,7 +204,7 @@ Make a rholang term for looking up a target and calling a method. ### makeProxy -[src/proxy.js:64-64][94] +[src/proxy.js:69-69][96] Make an object that proxies method calls to registered RChain channels. @@ -223,7 +225,7 @@ For rholang calling conventions, see `callSource`. ### sendCall -[src/proxy.js:94-94][95] +[src/proxy.js:100-100][97] Call a method on a registered RChain channel. @@ -241,7 +243,7 @@ For rholang calling conventions, see `callSource`. ## RNode -[src/rnodeAPI.js:104-383][96] +[src/rnodeAPI.js:104-383][98] RChain node API client @@ -270,7 +272,7 @@ Refs: ### Parameters - `grpc` **grpcT** access to the network: grpc instance from the node grpc package -- `endPoint` **{host: [string][97], port: [number][98]}** rnode gRPC service +- `endPoint` **{host: [string][99], port: [number][100]}** rnode gRPC service ### Examples @@ -293,15 +295,15 @@ Returns **IRNode** a thin wrapper around a gRPC client stub ### createBlock -[src/rnodeAPI.js:198-201][99] +[src/rnodeAPI.js:198-201][101] Creates a block on your node -Returns **[Promise][100]<[string][97]>** A promise for response message +Returns **[Promise][102]<[string][99]>** A promise for response message ### doDeploy -[src/rnodeAPI.js:175-191][101] +[src/rnodeAPI.js:175-191][103] Deploys a rholang term to a node @@ -317,39 +319,39 @@ Deploys a rholang term to a node - `deployData.phloLimit` - `deployData.phloPrice` - `deployData.validAfterBlockNumber` ???ISSUE??? -- `autoCreateBlock` **[boolean][89]** automatically create a new block after deploy transaction success +- `autoCreateBlock` **[boolean][91]** automatically create a new block after deploy transaction success -- Throws **[Error][102]** Could not deploy, casper instance was not available yet. -- Throws **[Error][102]** Missing / invalid / wrong size signature +- Throws **[Error][104]** Could not deploy, casper instance was not available yet. +- Throws **[Error][104]** Missing / invalid / wrong size signature -Returns **[Promise][100]<[string][97]>** A promise for message +Returns **[Promise][102]<[string][99]>** A promise for message ### getAllBlocks -[src/rnodeAPI.js:357-367][103] +[src/rnodeAPI.js:357-367][105] Retrieve the block summary for a series of blocks starting with the most recent, including the number of blocks specified by the block_depth #### Parameters -- `blockDepth` **[number][98]** : Number indicating the number of blocks to retrieve +- `blockDepth` **[number][100]** : Number indicating the number of blocks to retrieve - Throws **any** Error if blockDepth < 1 or no blocks were able to be retrieved -Returns **[Promise][100]<BlockInfoWithoutTuplespace>** List of BlockInfoWithoutTuplespace structures for each block retrieved +Returns **[Promise][102]<BlockInfoWithoutTuplespace>** List of BlockInfoWithoutTuplespace structures for each block retrieved ### getBlock -[src/rnodeAPI.js:337-346][104] +[src/rnodeAPI.js:337-346][106] Retrieve a block with the tuplespace for a specific block hash #### Parameters -- `blockHash` **[string][97]** : String of the hash for the block being requested +- `blockHash` **[string][99]** : String of the hash for the block being requested - Throws **any** Error if the hash is blank or does not correspond to an existing block @@ -358,32 +360,32 @@ Returns **any** BlockInfo structure that will include all metadata and also incl ### listenForContinuationAtName -[src/rnodeAPI.js:316-327][105] +[src/rnodeAPI.js:316-327][107] Listen for a continuation at an individual name or JOINed set of names in the tuplespace #### Parameters -- `pars` **[Array][106]<IPar>** The names onwhich to listen -- `depth` **[number][98]** +- `pars` **[Array][108]<IPar>** The names onwhich to listen +- `depth` **[number][100]** - Throws **any** Error if status is not Success -Returns **[Promise][100]<ListeningNameContinuationResponse>** promise for DataWithBlockInfo +Returns **[Promise][102]<ListeningNameContinuationResponse>** promise for DataWithBlockInfo ### listenForContinuationAtPrivateName -[src/rnodeAPI.js:297-305][107] +[src/rnodeAPI.js:297-305][109] Listen for a continuation at an individual private name or JOINed set of private names in the tuplespace #### Parameters -- `nameIds` **[Array][106]<[string][97]>** a list hex strings representing the unforgeable names' Ids -- `depth` **[number][98]** (optional, default `1`) +- `nameIds` **[Array][108]<[string][99]>** a list hex strings representing the unforgeable names' Ids +- `depth` **[number][100]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -397,15 +399,15 @@ Returns **any** promise for ContinuationsWithBlockInfo ### listenForContinuationAtPublicName -[src/rnodeAPI.js:284-286][108] +[src/rnodeAPI.js:284-286][110] Listen for a continuation at an individual public name or JOINed set of public names in the tuplespace #### Parameters -- `nameObjs` **[Array][106]<[string][97]>** a list of names (strings) -- `depth` **[number][98]** (optional, default `1`) +- `nameObjs` **[Array][108]<[string][99]>** a list of names (strings) +- `depth` **[number][100]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -419,31 +421,31 @@ Returns **any** promise for ContinuationsWithBlockInfo ### listenForDataAtName -[src/rnodeAPI.js:256-272][109] +[src/rnodeAPI.js:256-272][111] Listen for data at a name in the RChain tuple-space. #### Parameters - `par` **IPar** : JSON-ish Par data. See protobuf/RhoTypes.proto -- `depth` **[number][98]** (optional, default `1`) +- `depth` **[number][100]** (optional, default `1`) - `blockDepth` : Number of blocks to look back in for the name to listen on - Throws **any** Error if status is not Success -Returns **[Promise][100]<[Array][106]<DataWithBlockInfo>>** : promise for DataWithBlockInfo\[] +Returns **[Promise][102]<[Array][108]<DataWithBlockInfo>>** : promise for DataWithBlockInfo\[] ### listenForDataAtPrivateName -[src/rnodeAPI.js:238-245][110] +[src/rnodeAPI.js:238-245][112] Listen for data at a PRIVATE name in the RChain tuple-space. #### Parameters -- `nameId` **[string][97]** : Hex string representing an UnforgeableName's Id -- `depth` **[number][98]** (optional, default `1`) +- `nameId` **[string][99]** : Hex string representing an UnforgeableName's Id +- `depth` **[number][100]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -457,14 +459,14 @@ Returns **any** promise for [DataWithBlockInfo] ### listenForDataAtPublicName -[src/rnodeAPI.js:225-227][111] +[src/rnodeAPI.js:225-227][113] Listen for data at a PUBLIC name in the RChain tuple-space. #### Parameters - `nameObj` **JSData** : JSON-ish data: string, number, {}, \[], ... -- `depth` **[number][98]** (optional, default `1`) +- `depth` **[number][100]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -478,7 +480,7 @@ Returns **any** promise for [DataWithBlockInfo] ### previewPrivateChannels -[src/rnodeAPI.js:147-153][112] +[src/rnodeAPI.js:147-153][114] Ask rnode to compute top level private channels, given deploy parameters. @@ -487,13 +489,13 @@ Ask rnode to compute top level private channels, given deploy parameters. - `d` **any** - `d.user` public key (of validating node?) as in doDeploy - `d.timestamp` timestamp (ms) as in doDeploy -- `nameQty` **[number][98]** how many names to preview? (max: 1024) +- `nameQty` **[number][100]** how many names to preview? (max: 1024) -Returns **[Promise][100]<[Array][106]<IPar>>** +Returns **[Promise][102]<[Array][108]<IPar>>** ### previewPrivateIds -[src/rnodeAPI.js:125-134][113] +[src/rnodeAPI.js:125-134][115] Ask rnode to compute ids of top level private names, given deploy parameters. @@ -502,13 +504,13 @@ Ask rnode to compute ids of top level private names, given deploy parameters. - `d` **any** - `d.user` public key as in doDeploy deployer - `d.timestamp` timestamp (ms) as in doDeploy -- `nameQty` **[number][98]** how many names to preview? (max: 1024) +- `nameQty` **[number][100]** how many names to preview? (max: 1024) -Returns **[Promise][100]<[Array][106]<[Buffer][114]>>** +Returns **[Promise][102]<[Array][108]<[Buffer][116]>>** ## RHOCore -[index.js:12-12][115] +[index.js:12-12][117] "we can detail a direct representation of JSON into a fragment of the rholang syntax referred to in the diagram @@ -518,11 +520,11 @@ below as RHOCore." -- \[Mobile process calculi for programming the blockchain[1] ### dataToBytes -[src/RHOCore.js:99-99][116] +[src/RHOCore.js:99-99][118] ### fromJSData -[src/RHOCore.js:27-82][117] +[src/RHOCore.js:27-82][119] Build Rholang expression from Javascript data. @@ -537,33 +539,33 @@ Returns **any** : A rholang term in Protobuf's JSON representation, ### getIdFromUnforgeableName -[src/RHOCore.js:331-336][118] +[src/RHOCore.js:331-336][120] Convert the ack channel into a HEX-formatted unforgeable name #### Parameters -- `par` **IPar** : JSON-ish Par data: [https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto][119] +- `par` **IPar** : JSON-ish Par data: [https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto][121] - Throws **any** Error if the Par does not represent an unforgeable name -Returns **[string][97]** HEX-formatted string of unforgeable name's Id +Returns **[string][99]** HEX-formatted string of unforgeable name's Id ### rhol -[src/RHOCore.js:345-355][120] +[src/RHOCore.js:345-355][122] Template tag for RHOCore interpolation #### Parameters -- `template` **[Array][106]<[string][97]>** -- `subs` **...[Array][106]<JsonExt<([URL][121] | GPrivate)>>** +- `template` **[Array][108]<[string][99]>** +- `subs` **...[Array][108]<JsonExt<([URL][123] | GPrivate)>>** ### toByteArray -[src/RHOCore.js:90-93][122] +[src/RHOCore.js:90-93][124] Turns a rholang term into a byte-array compatible with Rholang @@ -571,11 +573,11 @@ Turns a rholang term into a byte-array compatible with Rholang - `termObj` **IPar** -Returns **[Uint8Array][87]** +Returns **[Uint8Array][89]** ### toJSData -[src/RHOCore.js:169-233][123] +[src/RHOCore.js:169-233][125] Converts an RHOCore object back to JavaScript data @@ -583,11 +585,11 @@ Converts an RHOCore object back to JavaScript data - `par` **IPar** A RHOCore representation of a Rholang term -Returns **JsonExt<([URL][121] | GPrivate)>** JSON-serializable data +Returns **JsonExt<([URL][123] | GPrivate)>** JSON-serializable data ### toRholang -[src/RHOCore.js:246-299][124] +[src/RHOCore.js:246-299][126] Converts an RHOCore object into Rholang source form @@ -595,21 +597,21 @@ Converts an RHOCore object into Rholang source form - `par` **IPar** A RHOCore representation of a Rholang term -Returns **[string][97]** A rholang stringISSUE: Use intersection types to constrain par param further than IPar? +Returns **[string][99]** A rholang stringISSUE: Use intersection types to constrain par param further than IPar? ### unforgeableWithId -[src/RHOCore.js:307-310][125] +[src/RHOCore.js:307-310][127] Get printable form of unforgeable name, given id. #### Parameters -- `id` **[Uint8Array][87]** +- `id` **[Uint8Array][89]** ### wrapHash -[src/RHOCore.js:115-115][126] +[src/RHOCore.js:115-115][128] #### Parameters @@ -622,7 +624,7 @@ Returns **any** HEX-formatted string representing the computed hash ## Ed25519keyPair -[src/signing.js:38-75][127] +[src/signing.js:38-75][129] Build key pair from seed. @@ -632,7 +634,7 @@ Build key pair from seed. ### publicKey -[src/signing.js:70-70][128] +[src/signing.js:70-70][130] ISSUE: if the caller wants the bytes, we go bytes -> hex -> bytes @@ -640,47 +642,47 @@ Returns **HexStr<PublicKey>** ### signBytes -[src/signing.js:46-48][129] +[src/signing.js:46-48][131] #### Parameters -- `bytes` **[Uint8Array][87]** +- `bytes` **[Uint8Array][89]** Returns **Signature** ### signBytesHex -[src/signing.js:56-56][130] +[src/signing.js:56-56][132] #### Parameters -- `bs` **[Uint8Array][87]** +- `bs` **[Uint8Array][89]** Returns **HexStr<Signature>** ### signText -[src/signing.js:60-60][131] +[src/signing.js:60-60][133] #### Parameters -- `text` **[string][97]** +- `text` **[string][99]** Returns **Signature** ### signTextHex -[src/signing.js:64-64][132] +[src/signing.js:64-64][134] #### Parameters -- `text` **[string][97]** +- `text` **[string][99]** Returns **HexStr<Signature>** ## REV -[index.js:58-58][133] +[index.js:64-64][135] REV transaction, vault support @@ -712,9 +714,16 @@ assert.equal(Hex.encode(info.sig).slice(0, 16), 'ebc47a0a923b7feb'); assert(REV.SignDeployment.verify(info)); ``` +```javascript +// We can check a REV address before deploying any code. +assert.throws(() => { + REV.RevAddress.parse('123'); +}); +``` + ### RevAddress -[src/revAddress.js:38-64][134] +[src/revAddress.js:38-103][136] A RevAddress refers to a REV vault. @@ -722,32 +731,47 @@ Use `toString()` to get base58 form. Refs: -- [RevAddress.scala][135] -- [AddressTools.scala][136] +- [RevAddress.scala][137] +- [AddressTools.scala][138] #### fromPublicKey -[src/revAddress.js:46-61][137] +[src/revAddress.js:46-61][139] Compute REV Address from public key ##### Parameters -- `pk` **[Uint8Array][87]** ed25519 public key +- `pk` **[Uint8Array][89]** ed25519 public key + +Returns **IRevAddress** + +#### parse + +[src/revAddress.js:69-100][140] + +Parse REV Address + +##### Parameters + +- `address` **[string][99]** + + +- Throws **any** Error on ill-formed address Returns **IRevAddress** ### SignDeployment -[src/rnodeAPI.js:419-452][138] +[src/rnodeAPI.js:419-452][141] -a port of [casper/SignDeployment.scala][139] +a port of [casper/SignDeployment.scala][142] ISSUE: only ed25519 is supported. #### sign -[src/rnodeAPI.js:431-437][140] +[src/rnodeAPI.js:431-437][143] ##### Parameters @@ -758,13 +782,13 @@ Returns **DeployData** #### verify -[src/rnodeAPI.js:442-449][141] +[src/rnodeAPI.js:442-449][144] ##### Parameters - `deployData` **DeployData** -Returns **[boolean][89]** +Returns **[boolean][91]** [2]: #rholangcrypto @@ -920,128 +944,134 @@ Returns **[boolean][89]** [78]: #parameters-32 -[79]: #signdeployment +[79]: #parse -[80]: #sign +[80]: #parameters-33 -[81]: #parameters-33 +[81]: #signdeployment -[82]: #verify +[82]: #sign [83]: #parameters-34 -[84]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L178-L178 "Source code on GitHub" +[84]: #verify + +[85]: #parameters-35 + +[86]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L178-L178 "Source code on GitHub" + +[87]: #rhocorewraphash -[85]: #rhocorewraphash +[88]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L134-L138 "Source code on GitHub" -[86]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L134-L138 "Source code on GitHub" +[89]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array -[87]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array +[90]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L90-L96 "Source code on GitHub" -[88]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L90-L96 "Source code on GitHub" +[91]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[89]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[92]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L121-L123 "Source code on GitHub" -[90]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L121-L123 "Source code on GitHub" +[93]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L107-L111 "Source code on GitHub" -[91]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L107-L111 "Source code on GitHub" +[94]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/index.js#L72-L72 "Source code on GitHub" -[92]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/index.js#L66-L66 "Source code on GitHub" +[95]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/proxy.js#L194-L194 "Source code on GitHub" -[93]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/proxy.js#L185-L185 "Source code on GitHub" +[96]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/proxy.js#L69-L69 "Source code on GitHub" -[94]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/proxy.js#L64-L64 "Source code on GitHub" +[97]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/proxy.js#L100-L100 "Source code on GitHub" -[95]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/proxy.js#L94-L94 "Source code on GitHub" +[98]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L104-L383 "Source code on GitHub" -[96]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L104-L383 "Source code on GitHub" +[99]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[97]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[100]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[98]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[101]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L198-L201 "Source code on GitHub" -[99]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L198-L201 "Source code on GitHub" +[102]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise -[100]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise +[103]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L175-L191 "Source code on GitHub" -[101]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L175-L191 "Source code on GitHub" +[104]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error -[102]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error +[105]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L357-L367 "Source code on GitHub" -[103]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L357-L367 "Source code on GitHub" +[106]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L337-L346 "Source code on GitHub" -[104]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L337-L346 "Source code on GitHub" +[107]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L316-L327 "Source code on GitHub" -[105]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L316-L327 "Source code on GitHub" +[108]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array -[106]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array +[109]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L297-L305 "Source code on GitHub" -[107]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L297-L305 "Source code on GitHub" +[110]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L284-L286 "Source code on GitHub" -[108]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L284-L286 "Source code on GitHub" +[111]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L256-L272 "Source code on GitHub" -[109]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L256-L272 "Source code on GitHub" +[112]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L238-L245 "Source code on GitHub" -[110]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L238-L245 "Source code on GitHub" +[113]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L225-L227 "Source code on GitHub" -[111]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L225-L227 "Source code on GitHub" +[114]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L147-L153 "Source code on GitHub" -[112]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L147-L153 "Source code on GitHub" +[115]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L125-L134 "Source code on GitHub" -[113]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L125-L134 "Source code on GitHub" +[116]: https://nodejs.org/api/buffer.html -[114]: https://nodejs.org/api/buffer.html +[117]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/index.js#L12-L12 "Source code on GitHub" -[115]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/index.js#L12-L12 "Source code on GitHub" +[118]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L99-L99 "Source code on GitHub" -[116]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L99-L99 "Source code on GitHub" +[119]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L27-L82 "Source code on GitHub" -[117]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L27-L82 "Source code on GitHub" +[120]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L331-L336 "Source code on GitHub" -[118]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L331-L336 "Source code on GitHub" +[121]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto -[119]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto +[122]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L345-L355 "Source code on GitHub" -[120]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L345-L355 "Source code on GitHub" +[123]: https://developer.mozilla.org/docs/Web/API/URL/URL -[121]: https://developer.mozilla.org/docs/Web/API/URL/URL +[124]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L90-L93 "Source code on GitHub" -[122]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L90-L93 "Source code on GitHub" +[125]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L169-L233 "Source code on GitHub" -[123]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L169-L233 "Source code on GitHub" +[126]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L246-L299 "Source code on GitHub" -[124]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L246-L299 "Source code on GitHub" +[127]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L307-L310 "Source code on GitHub" -[125]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L307-L310 "Source code on GitHub" +[128]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L115-L115 "Source code on GitHub" -[126]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/RHOCore.js#L115-L115 "Source code on GitHub" +[129]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L38-L75 "Source code on GitHub" -[127]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L38-L75 "Source code on GitHub" +[130]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L70-L70 "Source code on GitHub" -[128]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L70-L70 "Source code on GitHub" +[131]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L46-L48 "Source code on GitHub" -[129]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L46-L48 "Source code on GitHub" +[132]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L56-L56 "Source code on GitHub" -[130]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L56-L56 "Source code on GitHub" +[133]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L60-L60 "Source code on GitHub" -[131]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L60-L60 "Source code on GitHub" +[134]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L64-L64 "Source code on GitHub" -[132]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/signing.js#L64-L64 "Source code on GitHub" +[135]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/index.js#L64-L64 "Source code on GitHub" -[133]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/index.js#L58-L58 "Source code on GitHub" +[136]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/revAddress.js#L38-L103 "Source code on GitHub" -[134]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/revAddress.js#L38-L64 "Source code on GitHub" +[137]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala -[135]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala +[138]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala -[136]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala +[139]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/revAddress.js#L46-L61 "Source code on GitHub" -[137]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/revAddress.js#L46-L61 "Source code on GitHub" +[140]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/revAddress.js#L69-L100 "Source code on GitHub" -[138]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L419-L452 "Source code on GitHub" +[141]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L419-L452 "Source code on GitHub" -[139]: https://github.com/rchain/rchain/blob/9ae5825/casper/src/main/scala/coop/rchain/casper/SignDeployment.scala +[142]: https://github.com/rchain/rchain/blob/9ae5825/casper/src/main/scala/coop/rchain/casper/SignDeployment.scala -[140]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L431-L437 "Source code on GitHub" +[143]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L431-L437 "Source code on GitHub" -[141]: https://git@github.com/:dckc/RChain-API/blob/47f9d33a3be9e5c2fd3f137b8c58b49ffdd8b0c3/src/rnodeAPI.js#L442-L449 "Source code on GitHub" +[144]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L442-L449 "Source code on GitHub" From eb1532a10afbebe1aec61e70baed3c27c262f860 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 13 Apr 2019 14:19:39 -0500 Subject: [PATCH 22/36] package.json: prune obsolete jest ref --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 21dd66d..9e83e07 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "build:docs-html": "documentation build -f html --github --sort-order alpha index.js src/**.js --shallow -o docs/", "doc-watch": "documentation serve --watch index.js src/**.js --shallow", "check": "npm run test && npm run lint && npm run flow-check", - "test-jest": "jest", "test": "tape test/**/*.js && markdown-doctest", "integrationTest": "node test/testRNode.js --net && node test/liveRHOCoreTest.js && node test/liveRNodeTest.js", "flow-check": "flow check --from emacs", From 6b127380d68fa6e8c5a95904eb1f4b70b80b52bd Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 13 Apr 2019 14:19:52 -0500 Subject: [PATCH 23/36] bump version to 0.9.2-beta.3 for API reorg --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e83e07..c6803a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rchain-api", - "version": "0.9.1-beta.2", + "version": "0.9.2-beta.3", "description": "RChain client for node.js", "main": "index.js", "scripts": { From 4cffba1d300b7a45b4fb90069f5826d7dde64df8 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 13 Apr 2019 15:10:54 -0500 Subject: [PATCH 24/36] CONTRIBUTING: struggles with extracting API docs are over --- CONTRIBUTING.md | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca1649e..bc958cb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,19 +82,9 @@ All of our protobuf encoding and decoding is done using [protobuf.js](https://gi ![protobuf.js diagram](https://camo.githubusercontent.com/f090df881cc6c82ecb7c5d09c9fad550fdfd153e/687474703a2f2f64636f64652e696f2f70726f746f6275662e6a732f746f6f6c7365742e737667) -## Struggles with extracting API doc -We don't use classes (TODO: cite explanation as to why not) -but neither of the relevant recipies seem to work: +## Extracting API doc -> Many libraries and frameworks have special 'class constructor -> methods' that accept an object as an input and return a class with -> that object's properties as prototype properties. - -https://github.com/documentationjs/documentation/blob/master/docs/RECIPES.md#class-factories-using-lends - - -We'd like to use these scripts in our `package.json`: - - "doc": "node ./node_modules/.bin/documentation build --github rnodeAPI.js -f html -o docs", - "doc-watch": "node ./node_modules/.bin/documentation serve --watch --github rnodeAPI.js" +We use [documentation.js](https://documentation.js.org/) to build API +docs (docs/index.md) from sources. Use the `docs-watch`, `build:docs`, +or `build:docs-html` npm scripts. From 9cc4bcc186f3c5c828c28a34b7eb3a4ced309a33 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 13 Apr 2019 15:11:32 -0500 Subject: [PATCH 25/36] factor grpcMock out of doctest-settings --- .markdown-doctest-setup.js | 55 +++++++++++--------------------------- test/testRNode.js | 42 +++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 47 deletions(-) diff --git a/.markdown-doctest-setup.js b/.markdown-doctest-setup.js index a91a25f..a563d30 100644 --- a/.markdown-doctest-setup.js +++ b/.markdown-doctest-setup.js @@ -3,49 +3,26 @@ const assert = require('assert'); const rchain = require('.'); +const { grpcMock } = require('./test/testRNode'); const { RNode, RholangCrypto, REV, Ed25519keyPair, Hex } = rchain; -// mock enough of grpc -// ISSUE: refactor overlap with test/testRNode.js -const CasperMessage = require('./protobuf/CasperMessage'); -const { Either } = CasperMessage; -const { BlockInfoWithoutTuplespace } = CasperMessage.coop.rchain.casper.protocol; +function config(env, grpcAccess) { + const grpc = env.NODE_ENV === 'production' ? grpcAccess() : grpcMock(); + console.log('doctest env:', env.NODE_ENV); -function DeployService(_hostPort, _chan) { - return Object.freeze({ - doDeploy(_dd, _auto = false) { return 'Success!'; }, - showBlocks(_depth) { - const block4 = { value: BlockInfoWithoutTuplespace.encode({ blockNumber: 4 }).finish() }; - - return Object.freeze({ - on(name, handler) { - if (name === 'data') { - handler({ success: { response: block4 } }); - } else if (name === 'end') { - handler(); - } - } - }); + return { + babel: false, + require: { + grpc: grpc, // ISSUE: live access at test time? + }, + globals: { + assert, Buffer, + grpc, + RholangCrypto, RNode, REV, Hex, Ed25519keyPair, }, - }); + }; } -const casper = { DeployService }; -const proto = { coop: { rchain: { casper: { protocol: casper } } } }; -const grpc = { - loadPackageDefinition(_d) { return proto; }, - credentials: { createInsecure() { } }, -}; - -module.exports = { - babel: false, - require: { - grpc: grpc, // ISSUE: live access at test time? - }, - globals: { - assert, Buffer, - grpc, - RholangCrypto, RNode, REV, Hex, Ed25519keyPair, - }, -}; +/* global process */ +module.exports = config(process.env, () => require('grpc')); diff --git a/test/testRNode.js b/test/testRNode.js index 166eddc..20aeefc 100644 --- a/test/testRNode.js +++ b/test/testRNode.js @@ -2,6 +2,10 @@ // @flow const ttest = require('tape'); +const CasperMessage = require('../protobuf/CasperMessage'); + +const { BlockInfoWithoutTuplespace } = CasperMessage.coop.rchain.casper.protocol; + const api = require('..'); const { RNode, RegistryProxy, SignDeployment, RHOCore, Hex } = api; @@ -19,14 +23,7 @@ import type { JsonExt } from '..'; * @param suite2: supplemental tests */ function testRNode(suite2) { - // mock enough of grpc - function DeployService(_hostPort, _chan) { } - const casper = { DeployService }; - const proto = { coop: { rchain: { casper: { protocol: casper } } } }; - const grpc0 = { - loadPackageDefinition(_d) { return proto; }, - credentials: { createInsecure() { } }, - }; + const grpc0 = grpcMock(); Object.entries({ 'args check': (test) => { @@ -154,6 +151,35 @@ function payFor(d0, key, phloPrice = 1, phloLimit = 10000000) { return dout; } +exports.grpcMock = grpcMock; +function grpcMock() { + function DeployService(_hostPort /*: Object */, _chan /*: Object */) { + return Object.freeze({ + doDeploy(_dd /*: Object */, _auto /*: boolean */ = false) { return 'Success!'; }, + showBlocks(_depth /*: number */) { + const block4 = { value: BlockInfoWithoutTuplespace.encode({ blockNumber: 4 }).finish() }; + + return Object.freeze({ + on(name /*: string */, handler /*: (...args: any[]) => void */) { + if (name === 'data') { + handler({ success: { response: block4 } }); + } else if (name === 'end') { + handler(); + } + }, + }); + }, + }); + } + + const casper = { DeployService }; + const proto = { coop: { rchain: { casper: { protocol: casper } } } }; + return Object.freeze({ + loadPackageDefinition(_d /*: Object */) { return proto; }, + credentials: { createInsecure() { } }, + }); +} + if (require.main === module) { // Access ambient stuff only when invoked as main module. From 5cc78f84d32b2e2c6803b3523c794b91882df66f Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 13 Apr 2019 15:12:13 -0500 Subject: [PATCH 26/36] README: link markup --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ac678f1..816a887 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ The [RChain Cooperative][1] is developing a decentralized, economically sustaina ## Quickstart ### Find an RChain node whose grpc endpoint you can use. -At the moment that likely means [running your own RNode](2). We're working on a community node at rnode-test.rhobot.net +At the moment that likely means [running your own RNode][2]. We're working on a community node at rnode-test.rhobot.net Make note of your RNode's hostname and gRPC port. If you're not sure, `localhost` and `40401` are good guesses. @@ -62,7 +62,7 @@ myNode.doDeploy({ [protobuf][proto]: v0.9.1 bf1b2c6 Mar 28, 2019 -[pro]: https://github.com/rchain/rchain/tree/bf1b2c6c6662515403c0a429e8c9fa25edd64638/models/src/main/protobuf +[proto]: https://github.com/rchain/rchain/tree/bf1b2c6c6662515403c0a429e8c9fa25edd64638/models/src/main/protobuf ## Examples and Related Projects From eeca5a42a3a5b4042bdc14b6bf0eb01580f309fa Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 13 Apr 2019 15:12:37 -0500 Subject: [PATCH 27/36] docs: regen --- docs/index.md | 90 +++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/docs/index.md b/docs/index.md index 1b1c786..3f396c6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -958,120 +958,120 @@ Returns **[boolean][91]** [85]: #parameters-35 -[86]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L178-L178 "Source code on GitHub" +[86]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L178-L178 "Source code on GitHub" [87]: #rhocorewraphash -[88]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L134-L138 "Source code on GitHub" +[88]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L134-L138 "Source code on GitHub" [89]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array -[90]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L90-L96 "Source code on GitHub" +[90]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L90-L96 "Source code on GitHub" [91]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[92]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L121-L123 "Source code on GitHub" +[92]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L121-L123 "Source code on GitHub" -[93]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L107-L111 "Source code on GitHub" +[93]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L107-L111 "Source code on GitHub" -[94]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/index.js#L72-L72 "Source code on GitHub" +[94]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/index.js#L72-L72 "Source code on GitHub" -[95]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/proxy.js#L194-L194 "Source code on GitHub" +[95]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/proxy.js#L194-L194 "Source code on GitHub" -[96]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/proxy.js#L69-L69 "Source code on GitHub" +[96]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/proxy.js#L69-L69 "Source code on GitHub" -[97]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/proxy.js#L100-L100 "Source code on GitHub" +[97]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/proxy.js#L100-L100 "Source code on GitHub" -[98]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L104-L383 "Source code on GitHub" +[98]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L104-L383 "Source code on GitHub" [99]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String [100]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[101]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L198-L201 "Source code on GitHub" +[101]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L198-L201 "Source code on GitHub" [102]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise -[103]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L175-L191 "Source code on GitHub" +[103]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L175-L191 "Source code on GitHub" [104]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error -[105]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L357-L367 "Source code on GitHub" +[105]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L357-L367 "Source code on GitHub" -[106]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L337-L346 "Source code on GitHub" +[106]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L337-L346 "Source code on GitHub" -[107]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L316-L327 "Source code on GitHub" +[107]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L316-L327 "Source code on GitHub" [108]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array -[109]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L297-L305 "Source code on GitHub" +[109]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L297-L305 "Source code on GitHub" -[110]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L284-L286 "Source code on GitHub" +[110]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L284-L286 "Source code on GitHub" -[111]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L256-L272 "Source code on GitHub" +[111]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L256-L272 "Source code on GitHub" -[112]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L238-L245 "Source code on GitHub" +[112]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L238-L245 "Source code on GitHub" -[113]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L225-L227 "Source code on GitHub" +[113]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L225-L227 "Source code on GitHub" -[114]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L147-L153 "Source code on GitHub" +[114]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L147-L153 "Source code on GitHub" -[115]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L125-L134 "Source code on GitHub" +[115]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L125-L134 "Source code on GitHub" [116]: https://nodejs.org/api/buffer.html -[117]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/index.js#L12-L12 "Source code on GitHub" +[117]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/index.js#L12-L12 "Source code on GitHub" -[118]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L99-L99 "Source code on GitHub" +[118]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L99-L99 "Source code on GitHub" -[119]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L27-L82 "Source code on GitHub" +[119]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L27-L82 "Source code on GitHub" -[120]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L331-L336 "Source code on GitHub" +[120]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L331-L336 "Source code on GitHub" [121]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto -[122]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L345-L355 "Source code on GitHub" +[122]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L345-L355 "Source code on GitHub" [123]: https://developer.mozilla.org/docs/Web/API/URL/URL -[124]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L90-L93 "Source code on GitHub" +[124]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L90-L93 "Source code on GitHub" -[125]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L169-L233 "Source code on GitHub" +[125]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L169-L233 "Source code on GitHub" -[126]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L246-L299 "Source code on GitHub" +[126]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L246-L299 "Source code on GitHub" -[127]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L307-L310 "Source code on GitHub" +[127]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L307-L310 "Source code on GitHub" -[128]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/RHOCore.js#L115-L115 "Source code on GitHub" +[128]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L115-L115 "Source code on GitHub" -[129]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L38-L75 "Source code on GitHub" +[129]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L38-L75 "Source code on GitHub" -[130]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L70-L70 "Source code on GitHub" +[130]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L70-L70 "Source code on GitHub" -[131]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L46-L48 "Source code on GitHub" +[131]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L46-L48 "Source code on GitHub" -[132]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L56-L56 "Source code on GitHub" +[132]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L56-L56 "Source code on GitHub" -[133]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L60-L60 "Source code on GitHub" +[133]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L60-L60 "Source code on GitHub" -[134]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/signing.js#L64-L64 "Source code on GitHub" +[134]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L64-L64 "Source code on GitHub" -[135]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/index.js#L64-L64 "Source code on GitHub" +[135]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/index.js#L64-L64 "Source code on GitHub" -[136]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/revAddress.js#L38-L103 "Source code on GitHub" +[136]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/revAddress.js#L38-L103 "Source code on GitHub" [137]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala [138]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala -[139]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/revAddress.js#L46-L61 "Source code on GitHub" +[139]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/revAddress.js#L46-L61 "Source code on GitHub" -[140]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/revAddress.js#L69-L100 "Source code on GitHub" +[140]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/revAddress.js#L69-L100 "Source code on GitHub" -[141]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L419-L452 "Source code on GitHub" +[141]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L419-L452 "Source code on GitHub" [142]: https://github.com/rchain/rchain/blob/9ae5825/casper/src/main/scala/coop/rchain/casper/SignDeployment.scala -[143]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L431-L437 "Source code on GitHub" +[143]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L431-L437 "Source code on GitHub" -[144]: https://git@github.com/:dckc/RChain-API/blob/d21c9aecab5da673576a3507d8e0869ee5017da5/src/rnodeAPI.js#L442-L449 "Source code on GitHub" +[144]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L442-L449 "Source code on GitHub" From 3773b3cbce0596cf6e05780c91a19427fabeea61 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 13 Apr 2019 15:58:27 -0500 Subject: [PATCH 28/36] udpate README; require('rchain-api') in examples --- .markdown-doctest-setup.js | 7 ++-- CONTRIBUTING.md | 2 +- README.md | 67 ++++++++++++++++++-------------------- index.js | 1 + src/rnodeAPI.js | 1 + src/signing.js | 1 + 6 files changed, 38 insertions(+), 41 deletions(-) diff --git a/.markdown-doctest-setup.js b/.markdown-doctest-setup.js index a563d30..a629fed 100644 --- a/.markdown-doctest-setup.js +++ b/.markdown-doctest-setup.js @@ -9,17 +9,16 @@ const { RNode, RholangCrypto, REV, Ed25519keyPair, Hex } = rchain; function config(env, grpcAccess) { const grpc = env.NODE_ENV === 'production' ? grpcAccess() : grpcMock(); - console.log('doctest env:', env.NODE_ENV); + console.log('doctest env:', env.NODE_ENV || 'dev'); return { babel: false, require: { - grpc: grpc, // ISSUE: live access at test time? + grpc: grpc, + 'rchain-api': { RholangCrypto, RNode, REV, Hex, Ed25519keyPair }, }, globals: { assert, Buffer, - grpc, - RholangCrypto, RNode, REV, Hex, Ed25519keyPair, }, }; } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bc958cb..1c15da9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ flow-check` script does a complete check and `npm run flow-status` does an incremental check. -## RChain Validator Node for Integration testing +0## RChain Validator Node for Integration testing One way to provide a validator node for testing, provided you're OK with the security risks around `--net host`, is to first have diff --git a/README.md b/README.md index 816a887..66749c3 100644 --- a/README.md +++ b/README.md @@ -8,49 +8,32 @@ The [RChain Cooperative][1] is developing a decentralized, economically sustaina ## Quickstart -### Find an RChain node whose grpc endpoint you can use. -At the moment that likely means [running your own RNode][2]. We're working on a community node at rnode-test.rhobot.net -Make note of your RNode's hostname and gRPC port. If you're not sure, `localhost` and `40401` are good guesses. +Install with `npm install rchain-community/rchain-api`. Then, with +rnode on `localhost`, you can get current block info: -[2]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/428376065/User+guide+for+running+RNode - -### Grab RChain-API -Clone this repository with eg `git clone https://github.com/JoshOrndorff/RChain-API` -And install dependencies with `npm install` +```js +const grpc = require('grpc'); +const { RNode, Ed25519keyPair, Hex, REV } = require('rchain-api'); -### (Recommended) Run the integration test +const rnode = RNode(grpc, { host: 'localhost', port: 40401 }); +rnode.getAllBlocks().then((blocks) => { assert(blocks[0].blockHash.length > 0); }); +``` -Run `rnodeAPI.js` with _host_ and _port_ arguments, as in: `node rnodeAPI.js rnode-test.rhobot.net 50000`. +If your node is a validator and you have a key to authorize payment, you can deploy code: -You should see something like: +```js +const grpc = require('grpc'); +const { RNode, Ed25519keyPair, Hex, REV } = require('rchain-api'); -``` -stuffToSign serialized { - "type": "Buffer", - "data": "0a300a110a0f2a031a01784a08000000000000000012112a051a036162634a0800000000000000002a0800000000000000004a080000000000000000" -} -... -doDeploy result: { success: true, message: 'Success!' } -@@createBlock(): { - "block": { - "blockHash": { - "type": "Buffer", - "data": "3c5d97e2627432026b6d4a17c8027afb95b72e8d08a936d785b58459eff5859e" -``` +const rnode = RNode(grpc, { host: 'localhost', port: 40401 }); -### Deploy contract to RNode -There are not yet nice truffle-style build tools, so you will probably deploy your code directly using the `rnode deploy` thin client or using RChain-API itself. - -```javascript -const myNode = RNode(grpc, { host: 'localhost', port: 40401 }); -myNode.doDeploy({ - term: '@"aliceUpdates"!("Having fun traveling!")', - timestamp: new Date().valueOf(), - phloLimit: 1000000, - phloPrice: 1, -}) +const term = '@"world"!("Hello!")'; +const myKey = Ed25519keyPair(Hex.decode('11'.repeat(32))); +const timestamp = new Date('2019-04-12T17:59:29.274Z').valueOf(); +const info = REV.SignDeployment.sign(myKey, { timestamp, term, phloLimit: 10000, phloPrice: 1 }); +rnode.doDeploy(info, true).then((message) => { assert(message.startsWith('Success')); }); ``` ## API @@ -58,7 +41,19 @@ myNode.doDeploy({ [./docs/](./docs/index.md) -## RChain gRPC protobuf compatibility +## Getting access to an RChain node + +Choices include: + + - [RChain testnet][testnet] nodes such as `node4.testnet.rchain-dev.tk` + - a community node at `rnode-test.rhobot.net` + - [running your own RNode][2] + +[testnet]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/678756429/RChain+public+testnet+information +[2]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/428376065/User+guide+for+running+RNode + + +### RChain gRPC protobuf compatibility [protobuf][proto]: v0.9.1 bf1b2c6 Mar 28, 2019 diff --git a/index.js b/index.js index 618e3cd..24ce839 100644 --- a/index.js +++ b/index.js @@ -38,6 +38,7 @@ exports.Block = Block; * * @example * // Suppose Alice generates a key pair. + * const { REV, Ed25519keyPair, Hex } = require('rchain-api'); * const aliceKey = Ed25519keyPair(Hex.decode('11'.repeat(32))); * const alicePub = aliceKey.publicKey(); * assert.equal(alicePub, 'd04ab232742bb4ab3a1368bd4615e4e6d0224ab71a016baf8520a332c9778737'); diff --git a/src/rnodeAPI.js b/src/rnodeAPI.js index f2b6fb3..0bb57ee 100644 --- a/src/rnodeAPI.js +++ b/src/rnodeAPI.js @@ -89,6 +89,7 @@ exports.RNode = RNode; * * @example * // Get current block info + * const { RNode, REV, Ed25519keyPair, Hex } = require('rchain-api'); * const grpc = require('grpc'); * * const rnode = RNode(grpc, { host: 'localhost', port: 40401 }); diff --git a/src/signing.js b/src/signing.js index 8b4b501..bce3130 100644 --- a/src/signing.js +++ b/src/signing.js @@ -154,6 +154,7 @@ function blake2b256Hash(input /*: Uint8Array*/) /*: Uint8Array*/ { * * @example * // Suppose we have Nathan Hale's public key: + * const { RholangCrypto, Hex } = require('rchain-api'); * const halePub = Hex.decode( * 'd759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c48'); * From e54b34e910f5e94dbc76bbe86f8e60e61754221d Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 13 Apr 2019 16:01:05 -0500 Subject: [PATCH 29/36] API docs: regen --- docs/index.md | 131 ++++++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 64 deletions(-) diff --git a/docs/index.md b/docs/index.md index 3f396c6..3b0723e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -89,7 +89,7 @@ ## RholangCrypto -[src/signing.js:178-178][86] +[src/signing.js:179-179][86] Cryptographic functions from Rholang @@ -111,6 +111,7 @@ See also [RHOCore.wrapHash][87] ```javascript // Suppose we have Nathan Hale's public key: + const { RholangCrypto, Hex } = require('rchain-api'); const halePub = Hex.decode( 'd759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c48'); @@ -185,7 +186,7 @@ Returns **[Uint8Array][89]** 256 bit (32 byte) hash ## RegistryProxy -[index.js:72-72][94] +[index.js:73-73][94] Proxy method calls to registered RChain channels. @@ -243,7 +244,7 @@ For rholang calling conventions, see `callSource`. ## RNode -[src/rnodeAPI.js:104-383][98] +[src/rnodeAPI.js:105-384][98] RChain node API client @@ -278,6 +279,7 @@ Refs: ```javascript // Get current block info +const { RNode, REV, Ed25519keyPair, Hex } = require('rchain-api'); const grpc = require('grpc'); const rnode = RNode(grpc, { host: 'localhost', port: 40401 }); @@ -295,7 +297,7 @@ Returns **IRNode** a thin wrapper around a gRPC client stub ### createBlock -[src/rnodeAPI.js:198-201][101] +[src/rnodeAPI.js:199-202][101] Creates a block on your node @@ -303,7 +305,7 @@ Returns **[Promise][102]<[string][99]>** A promise for response message ### doDeploy -[src/rnodeAPI.js:175-191][103] +[src/rnodeAPI.js:176-192][103] Deploys a rholang term to a node @@ -329,7 +331,7 @@ Returns **[Promise][102]<[string][99]>** A promise for message ### getAllBlocks -[src/rnodeAPI.js:357-367][105] +[src/rnodeAPI.js:358-368][105] Retrieve the block summary for a series of blocks starting with the most recent, including the number of blocks specified by the block_depth @@ -345,7 +347,7 @@ Returns **[Promise][102]<BlockInfoWithoutTuplespace>** List of BlockInfoWitho ### getBlock -[src/rnodeAPI.js:337-346][106] +[src/rnodeAPI.js:338-347][106] Retrieve a block with the tuplespace for a specific block hash @@ -360,7 +362,7 @@ Returns **any** BlockInfo structure that will include all metadata and also incl ### listenForContinuationAtName -[src/rnodeAPI.js:316-327][107] +[src/rnodeAPI.js:317-328][107] Listen for a continuation at an individual name or JOINed set of names in the tuplespace @@ -377,7 +379,7 @@ Returns **[Promise][102]<ListeningNameContinuationResponse>** promise for Dat ### listenForContinuationAtPrivateName -[src/rnodeAPI.js:297-305][109] +[src/rnodeAPI.js:298-306][109] Listen for a continuation at an individual private name or JOINed set of private names in the tuplespace @@ -399,7 +401,7 @@ Returns **any** promise for ContinuationsWithBlockInfo ### listenForContinuationAtPublicName -[src/rnodeAPI.js:284-286][110] +[src/rnodeAPI.js:285-287][110] Listen for a continuation at an individual public name or JOINed set of public names in the tuplespace @@ -421,7 +423,7 @@ Returns **any** promise for ContinuationsWithBlockInfo ### listenForDataAtName -[src/rnodeAPI.js:256-272][111] +[src/rnodeAPI.js:257-273][111] Listen for data at a name in the RChain tuple-space. @@ -438,7 +440,7 @@ Returns **[Promise][102]<[Array][108]<DataWithBlockInfo>>** : promise for ### listenForDataAtPrivateName -[src/rnodeAPI.js:238-245][112] +[src/rnodeAPI.js:239-246][112] Listen for data at a PRIVATE name in the RChain tuple-space. @@ -459,7 +461,7 @@ Returns **any** promise for [DataWithBlockInfo] ### listenForDataAtPublicName -[src/rnodeAPI.js:225-227][113] +[src/rnodeAPI.js:226-228][113] Listen for data at a PUBLIC name in the RChain tuple-space. @@ -480,7 +482,7 @@ Returns **any** promise for [DataWithBlockInfo] ### previewPrivateChannels -[src/rnodeAPI.js:147-153][114] +[src/rnodeAPI.js:148-154][114] Ask rnode to compute top level private channels, given deploy parameters. @@ -495,7 +497,7 @@ Returns **[Promise][102]<[Array][108]<IPar>>** ### previewPrivateIds -[src/rnodeAPI.js:125-134][115] +[src/rnodeAPI.js:126-135][115] Ask rnode to compute ids of top level private names, given deploy parameters. @@ -682,7 +684,7 @@ Returns **HexStr<Signature>** ## REV -[index.js:64-64][135] +[index.js:65-65][135] REV transaction, vault support @@ -696,6 +698,7 @@ Refs: ```javascript // Suppose Alice generates a key pair. +const { REV, Ed25519keyPair, Hex } = require('rchain-api'); const aliceKey = Ed25519keyPair(Hex.decode('11'.repeat(32))); const alicePub = aliceKey.publicKey(); assert.equal(alicePub, 'd04ab232742bb4ab3a1368bd4615e4e6d0224ab71a016baf8520a332c9778737'); @@ -763,7 +766,7 @@ Returns **IRevAddress** ### SignDeployment -[src/rnodeAPI.js:419-452][141] +[src/rnodeAPI.js:420-453][141] a port of [casper/SignDeployment.scala][142] @@ -771,7 +774,7 @@ ISSUE: only ed25519 is supported. #### sign -[src/rnodeAPI.js:431-437][143] +[src/rnodeAPI.js:432-438][143] ##### Parameters @@ -782,7 +785,7 @@ Returns **DeployData** #### verify -[src/rnodeAPI.js:442-449][144] +[src/rnodeAPI.js:443-450][144] ##### Parameters @@ -958,120 +961,120 @@ Returns **[boolean][91]** [85]: #parameters-35 -[86]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L178-L178 "Source code on GitHub" +[86]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L179-L179 "Source code on GitHub" [87]: #rhocorewraphash -[88]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L134-L138 "Source code on GitHub" +[88]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L134-L138 "Source code on GitHub" [89]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array -[90]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L90-L96 "Source code on GitHub" +[90]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L90-L96 "Source code on GitHub" [91]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[92]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L121-L123 "Source code on GitHub" +[92]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L121-L123 "Source code on GitHub" -[93]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L107-L111 "Source code on GitHub" +[93]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L107-L111 "Source code on GitHub" -[94]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/index.js#L72-L72 "Source code on GitHub" +[94]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/index.js#L73-L73 "Source code on GitHub" -[95]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/proxy.js#L194-L194 "Source code on GitHub" +[95]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/proxy.js#L194-L194 "Source code on GitHub" -[96]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/proxy.js#L69-L69 "Source code on GitHub" +[96]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/proxy.js#L69-L69 "Source code on GitHub" -[97]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/proxy.js#L100-L100 "Source code on GitHub" +[97]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/proxy.js#L100-L100 "Source code on GitHub" -[98]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L104-L383 "Source code on GitHub" +[98]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L105-L384 "Source code on GitHub" [99]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String [100]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[101]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L198-L201 "Source code on GitHub" +[101]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L199-L202 "Source code on GitHub" [102]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise -[103]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L175-L191 "Source code on GitHub" +[103]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L176-L192 "Source code on GitHub" [104]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error -[105]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L357-L367 "Source code on GitHub" +[105]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L358-L368 "Source code on GitHub" -[106]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L337-L346 "Source code on GitHub" +[106]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L338-L347 "Source code on GitHub" -[107]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L316-L327 "Source code on GitHub" +[107]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L317-L328 "Source code on GitHub" [108]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array -[109]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L297-L305 "Source code on GitHub" +[109]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L298-L306 "Source code on GitHub" -[110]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L284-L286 "Source code on GitHub" +[110]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L285-L287 "Source code on GitHub" -[111]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L256-L272 "Source code on GitHub" +[111]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L257-L273 "Source code on GitHub" -[112]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L238-L245 "Source code on GitHub" +[112]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L239-L246 "Source code on GitHub" -[113]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L225-L227 "Source code on GitHub" +[113]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L226-L228 "Source code on GitHub" -[114]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L147-L153 "Source code on GitHub" +[114]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L148-L154 "Source code on GitHub" -[115]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L125-L134 "Source code on GitHub" +[115]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L126-L135 "Source code on GitHub" [116]: https://nodejs.org/api/buffer.html -[117]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/index.js#L12-L12 "Source code on GitHub" +[117]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/index.js#L12-L12 "Source code on GitHub" -[118]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L99-L99 "Source code on GitHub" +[118]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L99-L99 "Source code on GitHub" -[119]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L27-L82 "Source code on GitHub" +[119]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L27-L82 "Source code on GitHub" -[120]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L331-L336 "Source code on GitHub" +[120]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L331-L336 "Source code on GitHub" [121]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto -[122]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L345-L355 "Source code on GitHub" +[122]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L345-L355 "Source code on GitHub" [123]: https://developer.mozilla.org/docs/Web/API/URL/URL -[124]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L90-L93 "Source code on GitHub" +[124]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L90-L93 "Source code on GitHub" -[125]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L169-L233 "Source code on GitHub" +[125]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L169-L233 "Source code on GitHub" -[126]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L246-L299 "Source code on GitHub" +[126]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L246-L299 "Source code on GitHub" -[127]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L307-L310 "Source code on GitHub" +[127]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L307-L310 "Source code on GitHub" -[128]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/RHOCore.js#L115-L115 "Source code on GitHub" +[128]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L115-L115 "Source code on GitHub" -[129]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L38-L75 "Source code on GitHub" +[129]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L38-L75 "Source code on GitHub" -[130]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L70-L70 "Source code on GitHub" +[130]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L70-L70 "Source code on GitHub" -[131]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L46-L48 "Source code on GitHub" +[131]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L46-L48 "Source code on GitHub" -[132]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L56-L56 "Source code on GitHub" +[132]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L56-L56 "Source code on GitHub" -[133]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L60-L60 "Source code on GitHub" +[133]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L60-L60 "Source code on GitHub" -[134]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/signing.js#L64-L64 "Source code on GitHub" +[134]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L64-L64 "Source code on GitHub" -[135]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/index.js#L64-L64 "Source code on GitHub" +[135]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/index.js#L65-L65 "Source code on GitHub" -[136]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/revAddress.js#L38-L103 "Source code on GitHub" +[136]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/revAddress.js#L38-L103 "Source code on GitHub" [137]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala [138]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala -[139]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/revAddress.js#L46-L61 "Source code on GitHub" +[139]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/revAddress.js#L46-L61 "Source code on GitHub" -[140]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/revAddress.js#L69-L100 "Source code on GitHub" +[140]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/revAddress.js#L69-L100 "Source code on GitHub" -[141]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L419-L452 "Source code on GitHub" +[141]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L420-L453 "Source code on GitHub" [142]: https://github.com/rchain/rchain/blob/9ae5825/casper/src/main/scala/coop/rchain/casper/SignDeployment.scala -[143]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L431-L437 "Source code on GitHub" +[143]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L432-L438 "Source code on GitHub" -[144]: https://git@github.com/:dckc/RChain-API/blob/5cc78f84d32b2e2c6803b3523c794b91882df66f/src/rnodeAPI.js#L442-L449 "Source code on GitHub" +[144]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L443-L450 "Source code on GitHub" From 241742bd36ca5f80463269622a4abcc8c790e71a Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sun, 14 Apr 2019 08:39:17 -0500 Subject: [PATCH 30/36] RHOCore doctest; re-export protobuf types (0.9.2-beta.4) --- .markdown-doctest-setup.js | 5 ++-- index.js | 55 ++++++++++++++++++++++++++++++++------ package.json | 2 +- 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/.markdown-doctest-setup.js b/.markdown-doctest-setup.js index a629fed..dd80a0d 100644 --- a/.markdown-doctest-setup.js +++ b/.markdown-doctest-setup.js @@ -4,7 +4,7 @@ const assert = require('assert'); const rchain = require('.'); const { grpcMock } = require('./test/testRNode'); -const { RNode, RholangCrypto, REV, Ed25519keyPair, Hex } = rchain; +const { RHOCore, RhoTypes, RNode, RholangCrypto, REV, Hex, Ed25519keyPair } = rchain; function config(env, grpcAccess) { @@ -14,8 +14,9 @@ function config(env, grpcAccess) { return { babel: false, require: { + url: require('url'), grpc: grpc, - 'rchain-api': { RholangCrypto, RNode, REV, Hex, Ed25519keyPair }, + 'rchain-api': { RHOCore, RhoTypes, RNode, RholangCrypto, REV, Hex, Ed25519keyPair }, }, globals: { assert, Buffer, diff --git a/index.js b/index.js index 24ce839..ac6c0d7 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,51 @@ -/** - * "we can detail a direct representation of JSON into a - * fragment of the rholang syntax referred to in the diagram - * below as RHOCore." -- [Mobile process calculi for programming the blockchain[1] - * - * [1]: https://github.com/rchain/mobile-process-calculi-for-blockchain/blob/master/enter-the-blockchain.rst - */ - /* global require, exports */ // @flow +/** + * Exchanging data between Rholang and JavaScript + * + * RChain uses gRPC and protobuf for its network + * protocol. [RhoTypes.proto][rAPI] gives the protobuf messages for + * Rholang. The main one is `Par`. + * + * The RHOCore mapping here is derived from Currin et. al but uses a + * differet mapping for object properties and includes more ground + * rholang types. + * + * **ISSUE**: Document support for unforgeable names. + * + * Refs: + * - [Mobile process calculi for programming the blockchain][1] + * Currin, Denman, Eykholt, Meredith Dec 2016 + * - [RhoTypes.proto][rAPI] v0.9.1 bf1b2c6 Mar 28, 2019 + * + * [1]: https://mobile-process-calculi-for-programming-the-new-blockchain.readthedocs.io/en/latest/enter-the-blockchain.html#from-data-storage-to-block-storage-in-the-rchain-model + * [rAPI]: https://github.com/rchain/rchain/blob/bf1b2c6/models/src/main/protobuf/RhoTypes.proto + * + * @example JSON to rholang and back + * + * const { RHOCore, RhoTypes } = require('rchain-api'); + * + * const data = [true, 1, 'abc', null, [1, 2, 3]]; + * + * const rhoProto = RHOCore.fromJSData(data); + * RhoTypes.Par.verify(rhoProto); + * assert.deepEqual(RHOCore.toJSData(rhoProto), data); + * + * assert.equal(RHOCore.toRholang(rhoProto), + * '[true, 1, "abc", Nil, [1, 2, 3]]'); + * + * @example Uri and ByteArray + * + * const { URL } = require('url'); + * const { RHOCore, Hex } = require('rchain-api'); + * + * const data = [new URL('rho:id:123'), Hex.decode('deadbeef')]; + * const rhoProto = RHOCore.fromJSData(data); + * assert.deepEqual(RHOCore.toJSData(rhoProto), data); + * assert.equal(RHOCore.toRholang(rhoProto), + * '[`rho:id:123`, "deadbeef".hexToBytes()]'); + */ const RHOCore = require('./src/RHOCore'); /*:: @@ -16,6 +53,7 @@ export type JsonExt = JsonExt; */ exports.RHOCore = RHOCore; +exports.RhoTypes = require('./protobuf/RhoTypes'); const { RNode, SignDeployment, Block } = require('./src/rnodeAPI'); @@ -27,6 +65,7 @@ export type { IRNode }; */ exports.RNode = RNode; exports.Block = Block; +exports.CasperMessage = require('./protobuf/CasperMessage'); /** * REV transaction, vault support diff --git a/package.json b/package.json index c6803a4..aa6b111 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rchain-api", - "version": "0.9.2-beta.3", + "version": "0.9.2-beta.4", "description": "RChain client for node.js", "main": "index.js", "scripts": { From 5878af2955efa512088affdac6411179701098b9 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sun, 14 Apr 2019 08:40:12 -0500 Subject: [PATCH 31/36] API docs: regen --- docs/index.md | 535 +++++++++++++++++++++++++++----------------------- 1 file changed, 293 insertions(+), 242 deletions(-) diff --git a/docs/index.md b/docs/index.md index 3b0723e..fc9036f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -46,50 +46,51 @@ - [previewPrivateIds][43] - [Parameters][44] - [RHOCore][45] - - [dataToBytes][46] - - [fromJSData][47] - - [Parameters][48] - - [getIdFromUnforgeableName][49] - - [Parameters][50] - - [rhol][51] - - [Parameters][52] - - [toByteArray][53] - - [Parameters][54] - - [toJSData][55] - - [Parameters][56] - - [toRholang][57] - - [Parameters][58] - - [unforgeableWithId][59] - - [Parameters][60] - - [wrapHash][61] - - [Parameters][62] -- [Ed25519keyPair][63] - - [Parameters][64] - - [publicKey][65] - - [signBytes][66] - - [Parameters][67] - - [signBytesHex][68] - - [Parameters][69] - - [signText][70] - - [Parameters][71] - - [signTextHex][72] - - [Parameters][73] -- [REV][74] - - [Examples][75] - - [RevAddress][76] - - [fromPublicKey][77] - - [Parameters][78] - - [parse][79] - - [Parameters][80] - - [SignDeployment][81] - - [sign][82] - - [Parameters][83] - - [verify][84] - - [Parameters][85] + - [Examples][46] + - [dataToBytes][47] + - [fromJSData][48] + - [Parameters][49] + - [getIdFromUnforgeableName][50] + - [Parameters][51] + - [rhol][52] + - [Parameters][53] + - [toByteArray][54] + - [Parameters][55] + - [toJSData][56] + - [Parameters][57] + - [toRholang][58] + - [Parameters][59] + - [unforgeableWithId][60] + - [Parameters][61] + - [wrapHash][62] + - [Parameters][63] +- [Ed25519keyPair][64] + - [Parameters][65] + - [publicKey][66] + - [signBytes][67] + - [Parameters][68] + - [signBytesHex][69] + - [Parameters][70] + - [signText][71] + - [Parameters][72] + - [signTextHex][73] + - [Parameters][74] +- [REV][75] + - [Examples][76] + - [RevAddress][77] + - [fromPublicKey][78] + - [Parameters][79] + - [parse][80] + - [Parameters][81] + - [SignDeployment][82] + - [sign][83] + - [Parameters][84] + - [verify][85] + - [Parameters][86] ## RholangCrypto -[src/signing.js:179-179][86] +[src/signing.js:179-179][87] Cryptographic functions from Rholang @@ -105,7 +106,7 @@ refs: [vtut]: https://github.com/rchain/rchain/blob/3c64ca3/rholang/examples/tut-verify-channel.md -See also [RHOCore.wrapHash][87] +See also [RHOCore.wrapHash][88] ### Examples @@ -136,63 +137,63 @@ assert(!RholangCrypto.ed25519Verify(digest, sig2, halePub)); ### blake2b256Hash -[src/signing.js:134-138][88] +[src/signing.js:134-138][89] Blake2b 256 bit cryptographic hash function #### Parameters -- `input` **[Uint8Array][89]** any number of bytes +- `input` **[Uint8Array][90]** any number of bytes -Returns **[Uint8Array][89]** 256 bit (32 byte) hash +Returns **[Uint8Array][90]** 256 bit (32 byte) hash ### ed25519Verify -[src/signing.js:90-96][90] +[src/signing.js:90-96][91] Verify ed25519 signature #### Parameters -- `message` **[Uint8Array][89]** any number of bytes (TODO: test!) -- `sig` **[Uint8Array][89]** 64 byte ed25519 signature over message -- `publicKey` **[Uint8Array][89]** 32 byte ed25519 public key +- `message` **[Uint8Array][90]** any number of bytes (TODO: test!) +- `sig` **[Uint8Array][90]** 64 byte ed25519 signature over message +- `publicKey` **[Uint8Array][90]** 32 byte ed25519 public key -Returns **[boolean][91]** indicates whether the signature is valid +Returns **[boolean][92]** indicates whether the signature is valid ### keccak256Hash -[src/signing.js:121-123][92] +[src/signing.js:121-123][93] Keccak 256 bit cryptographic hash function (aka SHA-3) #### Parameters -- `input` **[Uint8Array][89]** any number of bytes +- `input` **[Uint8Array][90]** any number of bytes -Returns **[Uint8Array][89]** 256 bit (32 byte) hash +Returns **[Uint8Array][90]** 256 bit (32 byte) hash ### sha256Hash -[src/signing.js:107-111][93] +[src/signing.js:107-111][94] SHA-2 256 bit cryptographic hash function #### Parameters -- `input` **[Uint8Array][89]** any number of bytes +- `input` **[Uint8Array][90]** any number of bytes -Returns **[Uint8Array][89]** 256 bit (32 byte) hash +Returns **[Uint8Array][90]** 256 bit (32 byte) hash ## RegistryProxy -[index.js:73-73][94] +[index.js:112-112][95] Proxy method calls to registered RChain channels. ### callSource -[src/proxy.js:194-194][95] +[src/proxy.js:194-194][96] Make a rholang term for looking up a target and calling a method. @@ -205,7 +206,7 @@ Make a rholang term for looking up a target and calling a method. ### makeProxy -[src/proxy.js:69-69][96] +[src/proxy.js:69-69][97] Make an object that proxies method calls to registered RChain channels. @@ -226,7 +227,7 @@ For rholang calling conventions, see `callSource`. ### sendCall -[src/proxy.js:100-100][97] +[src/proxy.js:100-100][98] Call a method on a registered RChain channel. @@ -244,7 +245,7 @@ For rholang calling conventions, see `callSource`. ## RNode -[src/rnodeAPI.js:105-384][98] +[src/rnodeAPI.js:105-384][99] RChain node API client @@ -273,7 +274,7 @@ Refs: ### Parameters - `grpc` **grpcT** access to the network: grpc instance from the node grpc package -- `endPoint` **{host: [string][99], port: [number][100]}** rnode gRPC service +- `endPoint` **{host: [string][100], port: [number][101]}** rnode gRPC service ### Examples @@ -297,15 +298,15 @@ Returns **IRNode** a thin wrapper around a gRPC client stub ### createBlock -[src/rnodeAPI.js:199-202][101] +[src/rnodeAPI.js:199-202][102] Creates a block on your node -Returns **[Promise][102]<[string][99]>** A promise for response message +Returns **[Promise][103]<[string][100]>** A promise for response message ### doDeploy -[src/rnodeAPI.js:176-192][103] +[src/rnodeAPI.js:176-192][104] Deploys a rholang term to a node @@ -321,39 +322,39 @@ Deploys a rholang term to a node - `deployData.phloLimit` - `deployData.phloPrice` - `deployData.validAfterBlockNumber` ???ISSUE??? -- `autoCreateBlock` **[boolean][91]** automatically create a new block after deploy transaction success +- `autoCreateBlock` **[boolean][92]** automatically create a new block after deploy transaction success -- Throws **[Error][104]** Could not deploy, casper instance was not available yet. -- Throws **[Error][104]** Missing / invalid / wrong size signature +- Throws **[Error][105]** Could not deploy, casper instance was not available yet. +- Throws **[Error][105]** Missing / invalid / wrong size signature -Returns **[Promise][102]<[string][99]>** A promise for message +Returns **[Promise][103]<[string][100]>** A promise for message ### getAllBlocks -[src/rnodeAPI.js:358-368][105] +[src/rnodeAPI.js:358-368][106] Retrieve the block summary for a series of blocks starting with the most recent, including the number of blocks specified by the block_depth #### Parameters -- `blockDepth` **[number][100]** : Number indicating the number of blocks to retrieve +- `blockDepth` **[number][101]** : Number indicating the number of blocks to retrieve - Throws **any** Error if blockDepth < 1 or no blocks were able to be retrieved -Returns **[Promise][102]<BlockInfoWithoutTuplespace>** List of BlockInfoWithoutTuplespace structures for each block retrieved +Returns **[Promise][103]<BlockInfoWithoutTuplespace>** List of BlockInfoWithoutTuplespace structures for each block retrieved ### getBlock -[src/rnodeAPI.js:338-347][106] +[src/rnodeAPI.js:338-347][107] Retrieve a block with the tuplespace for a specific block hash #### Parameters -- `blockHash` **[string][99]** : String of the hash for the block being requested +- `blockHash` **[string][100]** : String of the hash for the block being requested - Throws **any** Error if the hash is blank or does not correspond to an existing block @@ -362,32 +363,32 @@ Returns **any** BlockInfo structure that will include all metadata and also incl ### listenForContinuationAtName -[src/rnodeAPI.js:317-328][107] +[src/rnodeAPI.js:317-328][108] Listen for a continuation at an individual name or JOINed set of names in the tuplespace #### Parameters -- `pars` **[Array][108]<IPar>** The names onwhich to listen -- `depth` **[number][100]** +- `pars` **[Array][109]<IPar>** The names onwhich to listen +- `depth` **[number][101]** - Throws **any** Error if status is not Success -Returns **[Promise][102]<ListeningNameContinuationResponse>** promise for DataWithBlockInfo +Returns **[Promise][103]<ListeningNameContinuationResponse>** promise for DataWithBlockInfo ### listenForContinuationAtPrivateName -[src/rnodeAPI.js:298-306][109] +[src/rnodeAPI.js:298-306][110] Listen for a continuation at an individual private name or JOINed set of private names in the tuplespace #### Parameters -- `nameIds` **[Array][108]<[string][99]>** a list hex strings representing the unforgeable names' Ids -- `depth` **[number][100]** (optional, default `1`) +- `nameIds` **[Array][109]<[string][100]>** a list hex strings representing the unforgeable names' Ids +- `depth` **[number][101]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -401,15 +402,15 @@ Returns **any** promise for ContinuationsWithBlockInfo ### listenForContinuationAtPublicName -[src/rnodeAPI.js:285-287][110] +[src/rnodeAPI.js:285-287][111] Listen for a continuation at an individual public name or JOINed set of public names in the tuplespace #### Parameters -- `nameObjs` **[Array][108]<[string][99]>** a list of names (strings) -- `depth` **[number][100]** (optional, default `1`) +- `nameObjs` **[Array][109]<[string][100]>** a list of names (strings) +- `depth` **[number][101]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -423,31 +424,31 @@ Returns **any** promise for ContinuationsWithBlockInfo ### listenForDataAtName -[src/rnodeAPI.js:257-273][111] +[src/rnodeAPI.js:257-273][112] Listen for data at a name in the RChain tuple-space. #### Parameters - `par` **IPar** : JSON-ish Par data. See protobuf/RhoTypes.proto -- `depth` **[number][100]** (optional, default `1`) +- `depth` **[number][101]** (optional, default `1`) - `blockDepth` : Number of blocks to look back in for the name to listen on - Throws **any** Error if status is not Success -Returns **[Promise][102]<[Array][108]<DataWithBlockInfo>>** : promise for DataWithBlockInfo\[] +Returns **[Promise][103]<[Array][109]<DataWithBlockInfo>>** : promise for DataWithBlockInfo\[] ### listenForDataAtPrivateName -[src/rnodeAPI.js:239-246][112] +[src/rnodeAPI.js:239-246][113] Listen for data at a PRIVATE name in the RChain tuple-space. #### Parameters -- `nameId` **[string][99]** : Hex string representing an UnforgeableName's Id -- `depth` **[number][100]** (optional, default `1`) +- `nameId` **[string][100]** : Hex string representing an UnforgeableName's Id +- `depth` **[number][101]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -461,14 +462,14 @@ Returns **any** promise for [DataWithBlockInfo] ### listenForDataAtPublicName -[src/rnodeAPI.js:226-228][113] +[src/rnodeAPI.js:226-228][114] Listen for data at a PUBLIC name in the RChain tuple-space. #### Parameters - `nameObj` **JSData** : JSON-ish data: string, number, {}, \[], ... -- `depth` **[number][100]** (optional, default `1`) +- `depth` **[number][101]** (optional, default `1`) - Throws **any** Error if status is not Success @@ -482,7 +483,7 @@ Returns **any** promise for [DataWithBlockInfo] ### previewPrivateChannels -[src/rnodeAPI.js:148-154][114] +[src/rnodeAPI.js:148-154][115] Ask rnode to compute top level private channels, given deploy parameters. @@ -491,13 +492,13 @@ Ask rnode to compute top level private channels, given deploy parameters. - `d` **any** - `d.user` public key (of validating node?) as in doDeploy - `d.timestamp` timestamp (ms) as in doDeploy -- `nameQty` **[number][100]** how many names to preview? (max: 1024) +- `nameQty` **[number][101]** how many names to preview? (max: 1024) -Returns **[Promise][102]<[Array][108]<IPar>>** +Returns **[Promise][103]<[Array][109]<IPar>>** ### previewPrivateIds -[src/rnodeAPI.js:126-135][115] +[src/rnodeAPI.js:126-135][116] Ask rnode to compute ids of top level private names, given deploy parameters. @@ -506,27 +507,75 @@ Ask rnode to compute ids of top level private names, given deploy parameters. - `d` **any** - `d.user` public key as in doDeploy deployer - `d.timestamp` timestamp (ms) as in doDeploy -- `nameQty` **[number][100]** how many names to preview? (max: 1024) +- `nameQty` **[number][101]** how many names to preview? (max: 1024) -Returns **[Promise][102]<[Array][108]<[Buffer][116]>>** +Returns **[Promise][103]<[Array][109]<[Buffer][117]>>** ## RHOCore -[index.js:12-12][117] +[index.js:49-49][118] -"we can detail a direct representation of JSON into a -fragment of the rholang syntax referred to in the diagram -below as RHOCore." -- \[Mobile process calculi for programming the blockchain[1] +Exchanging data between Rholang and JavaScript -[1]: https://github.com/rchain/mobile-process-calculi-for-blockchain/blob/master/enter-the-blockchain.rst +RChain uses gRPC and protobuf for its network +protocol. [RhoTypes.proto][rapi] gives the protobuf messages for +Rholang. The main one is `Par`. + +The RHOCore mapping here is derived from Currin et. al but uses a +differet mapping for object properties and includes more ground +rholang types. + +**ISSUE**: Document support for unforgeable names. + +Refs: + +- [Mobile process calculi for programming the blockchain][1] + Currin, Denman, Eykholt, Meredith Dec 2016 +- [RhoTypes.proto][rapi] v0.9.1 bf1b2c6 Mar 28, 2019 + +[1]: https://mobile-process-calculi-for-programming-the-new-blockchain.readthedocs.io/en/latest/enter-the-blockchain.html#from-data-storage-to-block-storage-in-the-rchain-model + +[rapi]: https://github.com/rchain/rchain/blob/bf1b2c6/models/src/main/protobuf/RhoTypes.proto + +### Examples + +JSON to rholang and back + + +```javascript +const { RHOCore, RhoTypes } = require('rchain-api'); + +const data = [true, 1, 'abc', null, [1, 2, 3]]; + +const rhoProto = RHOCore.fromJSData(data); +RhoTypes.Par.verify(rhoProto); +assert.deepEqual(RHOCore.toJSData(rhoProto), data); + +assert.equal(RHOCore.toRholang(rhoProto), + '[true, 1, "abc", Nil, [1, 2, 3]]'); +``` + +Uri and ByteArray + + +```javascript +const { URL } = require('url'); +const { RHOCore, Hex } = require('rchain-api'); + +const data = [new URL('rho:id:123'), Hex.decode('deadbeef')]; +const rhoProto = RHOCore.fromJSData(data); +assert.deepEqual(RHOCore.toJSData(rhoProto), data); +assert.equal(RHOCore.toRholang(rhoProto), + '[`rho:id:123`, "deadbeef".hexToBytes()]'); +``` ### dataToBytes -[src/RHOCore.js:99-99][118] +[src/RHOCore.js:99-99][119] ### fromJSData -[src/RHOCore.js:27-82][119] +[src/RHOCore.js:27-82][120] Build Rholang expression from Javascript data. @@ -541,33 +590,33 @@ Returns **any** : A rholang term in Protobuf's JSON representation, ### getIdFromUnforgeableName -[src/RHOCore.js:331-336][120] +[src/RHOCore.js:331-336][121] Convert the ack channel into a HEX-formatted unforgeable name #### Parameters -- `par` **IPar** : JSON-ish Par data: [https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto][121] +- `par` **IPar** : JSON-ish Par data: [https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto][122] - Throws **any** Error if the Par does not represent an unforgeable name -Returns **[string][99]** HEX-formatted string of unforgeable name's Id +Returns **[string][100]** HEX-formatted string of unforgeable name's Id ### rhol -[src/RHOCore.js:345-355][122] +[src/RHOCore.js:345-355][123] Template tag for RHOCore interpolation #### Parameters -- `template` **[Array][108]<[string][99]>** -- `subs` **...[Array][108]<JsonExt<([URL][123] | GPrivate)>>** +- `template` **[Array][109]<[string][100]>** +- `subs` **...[Array][109]<JsonExt<([URL][124] | GPrivate)>>** ### toByteArray -[src/RHOCore.js:90-93][124] +[src/RHOCore.js:90-93][125] Turns a rholang term into a byte-array compatible with Rholang @@ -575,11 +624,11 @@ Turns a rholang term into a byte-array compatible with Rholang - `termObj` **IPar** -Returns **[Uint8Array][89]** +Returns **[Uint8Array][90]** ### toJSData -[src/RHOCore.js:169-233][125] +[src/RHOCore.js:169-233][126] Converts an RHOCore object back to JavaScript data @@ -587,11 +636,11 @@ Converts an RHOCore object back to JavaScript data - `par` **IPar** A RHOCore representation of a Rholang term -Returns **JsonExt<([URL][123] | GPrivate)>** JSON-serializable data +Returns **JsonExt<([URL][124] | GPrivate)>** JSON-serializable data ### toRholang -[src/RHOCore.js:246-299][126] +[src/RHOCore.js:246-299][127] Converts an RHOCore object into Rholang source form @@ -599,21 +648,21 @@ Converts an RHOCore object into Rholang source form - `par` **IPar** A RHOCore representation of a Rholang term -Returns **[string][99]** A rholang stringISSUE: Use intersection types to constrain par param further than IPar? +Returns **[string][100]** A rholang stringISSUE: Use intersection types to constrain par param further than IPar? ### unforgeableWithId -[src/RHOCore.js:307-310][127] +[src/RHOCore.js:307-310][128] Get printable form of unforgeable name, given id. #### Parameters -- `id` **[Uint8Array][89]** +- `id` **[Uint8Array][90]** ### wrapHash -[src/RHOCore.js:115-115][128] +[src/RHOCore.js:115-115][129] #### Parameters @@ -626,7 +675,7 @@ Returns **any** HEX-formatted string representing the computed hash ## Ed25519keyPair -[src/signing.js:38-75][129] +[src/signing.js:38-75][130] Build key pair from seed. @@ -636,7 +685,7 @@ Build key pair from seed. ### publicKey -[src/signing.js:70-70][130] +[src/signing.js:70-70][131] ISSUE: if the caller wants the bytes, we go bytes -> hex -> bytes @@ -644,47 +693,47 @@ Returns **HexStr<PublicKey>** ### signBytes -[src/signing.js:46-48][131] +[src/signing.js:46-48][132] #### Parameters -- `bytes` **[Uint8Array][89]** +- `bytes` **[Uint8Array][90]** Returns **Signature** ### signBytesHex -[src/signing.js:56-56][132] +[src/signing.js:56-56][133] #### Parameters -- `bs` **[Uint8Array][89]** +- `bs` **[Uint8Array][90]** Returns **HexStr<Signature>** ### signText -[src/signing.js:60-60][133] +[src/signing.js:60-60][134] #### Parameters -- `text` **[string][99]** +- `text` **[string][100]** Returns **Signature** ### signTextHex -[src/signing.js:64-64][134] +[src/signing.js:64-64][135] #### Parameters -- `text` **[string][99]** +- `text` **[string][100]** Returns **HexStr<Signature>** ## REV -[index.js:65-65][135] +[index.js:104-104][136] REV transaction, vault support @@ -726,7 +775,7 @@ assert.throws(() => { ### RevAddress -[src/revAddress.js:38-103][136] +[src/revAddress.js:38-103][137] A RevAddress refers to a REV vault. @@ -734,30 +783,30 @@ Use `toString()` to get base58 form. Refs: -- [RevAddress.scala][137] -- [AddressTools.scala][138] +- [RevAddress.scala][138] +- [AddressTools.scala][139] #### fromPublicKey -[src/revAddress.js:46-61][139] +[src/revAddress.js:46-61][140] Compute REV Address from public key ##### Parameters -- `pk` **[Uint8Array][89]** ed25519 public key +- `pk` **[Uint8Array][90]** ed25519 public key Returns **IRevAddress** #### parse -[src/revAddress.js:69-100][140] +[src/revAddress.js:69-100][141] Parse REV Address ##### Parameters -- `address` **[string][99]** +- `address` **[string][100]** - Throws **any** Error on ill-formed address @@ -766,15 +815,15 @@ Returns **IRevAddress** ### SignDeployment -[src/rnodeAPI.js:420-453][141] +[src/rnodeAPI.js:420-453][142] -a port of [casper/SignDeployment.scala][142] +a port of [casper/SignDeployment.scala][143] ISSUE: only ed25519 is supported. #### sign -[src/rnodeAPI.js:432-438][143] +[src/rnodeAPI.js:432-438][144] ##### Parameters @@ -785,13 +834,13 @@ Returns **DeployData** #### verify -[src/rnodeAPI.js:443-450][144] +[src/rnodeAPI.js:443-450][145] ##### Parameters - `deployData` **DeployData** -Returns **[boolean][91]** +Returns **[boolean][92]** [2]: #rholangcrypto @@ -881,200 +930,202 @@ Returns **[boolean][91]** [45]: #rhocore -[46]: #datatobytes +[46]: #examples-2 + +[47]: #datatobytes -[47]: #fromjsdata +[48]: #fromjsdata -[48]: #parameters-19 +[49]: #parameters-19 -[49]: #getidfromunforgeablename +[50]: #getidfromunforgeablename -[50]: #parameters-20 +[51]: #parameters-20 -[51]: #rhol +[52]: #rhol -[52]: #parameters-21 +[53]: #parameters-21 -[53]: #tobytearray +[54]: #tobytearray -[54]: #parameters-22 +[55]: #parameters-22 -[55]: #tojsdata +[56]: #tojsdata -[56]: #parameters-23 +[57]: #parameters-23 -[57]: #torholang +[58]: #torholang -[58]: #parameters-24 +[59]: #parameters-24 -[59]: #unforgeablewithid +[60]: #unforgeablewithid -[60]: #parameters-25 +[61]: #parameters-25 -[61]: #wraphash +[62]: #wraphash -[62]: #parameters-26 +[63]: #parameters-26 -[63]: #ed25519keypair +[64]: #ed25519keypair -[64]: #parameters-27 +[65]: #parameters-27 -[65]: #publickey +[66]: #publickey -[66]: #signbytes +[67]: #signbytes -[67]: #parameters-28 +[68]: #parameters-28 -[68]: #signbyteshex +[69]: #signbyteshex -[69]: #parameters-29 +[70]: #parameters-29 -[70]: #signtext +[71]: #signtext -[71]: #parameters-30 +[72]: #parameters-30 -[72]: #signtexthex +[73]: #signtexthex -[73]: #parameters-31 +[74]: #parameters-31 -[74]: #rev +[75]: #rev -[75]: #examples-2 +[76]: #examples-3 -[76]: #revaddress +[77]: #revaddress -[77]: #frompublickey +[78]: #frompublickey -[78]: #parameters-32 +[79]: #parameters-32 -[79]: #parse +[80]: #parse -[80]: #parameters-33 +[81]: #parameters-33 -[81]: #signdeployment +[82]: #signdeployment -[82]: #sign +[83]: #sign -[83]: #parameters-34 +[84]: #parameters-34 -[84]: #verify +[85]: #verify -[85]: #parameters-35 +[86]: #parameters-35 -[86]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L179-L179 "Source code on GitHub" +[87]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L179-L179 "Source code on GitHub" -[87]: #rhocorewraphash +[88]: #rhocorewraphash -[88]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L134-L138 "Source code on GitHub" +[89]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L134-L138 "Source code on GitHub" -[89]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array +[90]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array -[90]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L90-L96 "Source code on GitHub" +[91]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L90-L96 "Source code on GitHub" -[91]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[92]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[92]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L121-L123 "Source code on GitHub" +[93]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L121-L123 "Source code on GitHub" -[93]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L107-L111 "Source code on GitHub" +[94]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L107-L111 "Source code on GitHub" -[94]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/index.js#L73-L73 "Source code on GitHub" +[95]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/index.js#L112-L112 "Source code on GitHub" -[95]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/proxy.js#L194-L194 "Source code on GitHub" +[96]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/proxy.js#L194-L194 "Source code on GitHub" -[96]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/proxy.js#L69-L69 "Source code on GitHub" +[97]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/proxy.js#L69-L69 "Source code on GitHub" -[97]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/proxy.js#L100-L100 "Source code on GitHub" +[98]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/proxy.js#L100-L100 "Source code on GitHub" -[98]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L105-L384 "Source code on GitHub" +[99]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L105-L384 "Source code on GitHub" -[99]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[100]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[100]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[101]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[101]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L199-L202 "Source code on GitHub" +[102]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L199-L202 "Source code on GitHub" -[102]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise +[103]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise -[103]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L176-L192 "Source code on GitHub" +[104]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L176-L192 "Source code on GitHub" -[104]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error +[105]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error -[105]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L358-L368 "Source code on GitHub" +[106]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L358-L368 "Source code on GitHub" -[106]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L338-L347 "Source code on GitHub" +[107]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L338-L347 "Source code on GitHub" -[107]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L317-L328 "Source code on GitHub" +[108]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L317-L328 "Source code on GitHub" -[108]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array +[109]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array -[109]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L298-L306 "Source code on GitHub" +[110]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L298-L306 "Source code on GitHub" -[110]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L285-L287 "Source code on GitHub" +[111]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L285-L287 "Source code on GitHub" -[111]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L257-L273 "Source code on GitHub" +[112]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L257-L273 "Source code on GitHub" -[112]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L239-L246 "Source code on GitHub" +[113]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L239-L246 "Source code on GitHub" -[113]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L226-L228 "Source code on GitHub" +[114]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L226-L228 "Source code on GitHub" -[114]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L148-L154 "Source code on GitHub" +[115]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L148-L154 "Source code on GitHub" -[115]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L126-L135 "Source code on GitHub" +[116]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L126-L135 "Source code on GitHub" -[116]: https://nodejs.org/api/buffer.html +[117]: https://nodejs.org/api/buffer.html -[117]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/index.js#L12-L12 "Source code on GitHub" +[118]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/index.js#L49-L49 "Source code on GitHub" -[118]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L99-L99 "Source code on GitHub" +[119]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L99-L99 "Source code on GitHub" -[119]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L27-L82 "Source code on GitHub" +[120]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L27-L82 "Source code on GitHub" -[120]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L331-L336 "Source code on GitHub" +[121]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L331-L336 "Source code on GitHub" -[121]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto +[122]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto -[122]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L345-L355 "Source code on GitHub" +[123]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L345-L355 "Source code on GitHub" -[123]: https://developer.mozilla.org/docs/Web/API/URL/URL +[124]: https://developer.mozilla.org/docs/Web/API/URL/URL -[124]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L90-L93 "Source code on GitHub" +[125]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L90-L93 "Source code on GitHub" -[125]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L169-L233 "Source code on GitHub" +[126]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L169-L233 "Source code on GitHub" -[126]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L246-L299 "Source code on GitHub" +[127]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L246-L299 "Source code on GitHub" -[127]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L307-L310 "Source code on GitHub" +[128]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L307-L310 "Source code on GitHub" -[128]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/RHOCore.js#L115-L115 "Source code on GitHub" +[129]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L115-L115 "Source code on GitHub" -[129]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L38-L75 "Source code on GitHub" +[130]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L38-L75 "Source code on GitHub" -[130]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L70-L70 "Source code on GitHub" +[131]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L70-L70 "Source code on GitHub" -[131]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L46-L48 "Source code on GitHub" +[132]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L46-L48 "Source code on GitHub" -[132]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L56-L56 "Source code on GitHub" +[133]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L56-L56 "Source code on GitHub" -[133]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L60-L60 "Source code on GitHub" +[134]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L60-L60 "Source code on GitHub" -[134]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/signing.js#L64-L64 "Source code on GitHub" +[135]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L64-L64 "Source code on GitHub" -[135]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/index.js#L65-L65 "Source code on GitHub" +[136]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/index.js#L104-L104 "Source code on GitHub" -[136]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/revAddress.js#L38-L103 "Source code on GitHub" +[137]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/revAddress.js#L38-L103 "Source code on GitHub" -[137]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala +[138]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala -[138]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala +[139]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala -[139]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/revAddress.js#L46-L61 "Source code on GitHub" +[140]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/revAddress.js#L46-L61 "Source code on GitHub" -[140]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/revAddress.js#L69-L100 "Source code on GitHub" +[141]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/revAddress.js#L69-L100 "Source code on GitHub" -[141]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L420-L453 "Source code on GitHub" +[142]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L420-L453 "Source code on GitHub" -[142]: https://github.com/rchain/rchain/blob/9ae5825/casper/src/main/scala/coop/rchain/casper/SignDeployment.scala +[143]: https://github.com/rchain/rchain/blob/9ae5825/casper/src/main/scala/coop/rchain/casper/SignDeployment.scala -[143]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L432-L438 "Source code on GitHub" +[144]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L432-L438 "Source code on GitHub" -[144]: https://git@github.com/:dckc/RChain-API/blob/20d55088e791582ae03a1887ebacfb7737ea4e5e/src/rnodeAPI.js#L443-L450 "Source code on GitHub" +[145]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L443-L450 "Source code on GitHub" From 60ddae6dbf8edf7408cf7d5ba186727916108241 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sun, 14 Apr 2019 15:41:24 -0500 Subject: [PATCH 32/36] protobuf naming for showBlocks, showBlock, previewPrivateNames - RNode: - doDeploy etc. are instance methods, not static - un-document deprecated methods - tweak GRPCAccess type - punt previewPrivateChannels in favor of RHOCore.fromIds - testRNode: fix blockHash test (also in README) - update testProxy for signing; add @flow - docs/config.yml: toward API doc order - only in --serve, not in build yet - Hex: include in docs - un-export SignDeployment - makeProxy, sendCall: move exports out of the way so docs get flow types --- README.md | 3 ++- docs/config.yml | 8 ++++++ index.js | 10 ++++--- package.json | 4 +-- src/RHOCore.js | 12 +++++++++ src/hex.js | 30 +++++++++++++++++++-- src/loading.js | 3 ++- src/proxy.js | 6 ++--- src/rnodeAPI.js | 66 ++++++++++++++++++++++----------------------- test/testProxy.js | 60 ++++++++++++++++++++++++----------------- test/testRNode.js | 13 +++++---- test/testSigning.js | 4 +-- 12 files changed, 141 insertions(+), 78 deletions(-) create mode 100644 docs/config.yml diff --git a/README.md b/README.md index 66749c3..53a2827 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ const grpc = require('grpc'); const { RNode, Ed25519keyPair, Hex, REV } = require('rchain-api'); const rnode = RNode(grpc, { host: 'localhost', port: 40401 }); -rnode.getAllBlocks().then((blocks) => { assert(blocks[0].blockHash.length > 0); }); +rnode.showBlocks() + .then((blocks) => { assert.ok(blocks[0].blockHash); }); ``` If your node is a validator and you have a key to authorize payment, you can deploy code: diff --git a/docs/config.yml b/docs/config.yml new file mode 100644 index 0000000..1f94e17 --- /dev/null +++ b/docs/config.yml @@ -0,0 +1,8 @@ +toc: + - RNode + - RHOCore + - REV + - RholangCrypto + - RegistryProxy + - Ed25519keyPair + - Hex diff --git a/index.js b/index.js index ac6c0d7..f0e3637 100644 --- a/index.js +++ b/index.js @@ -104,8 +104,6 @@ exports.CasperMessage = require('./protobuf/CasperMessage'); const REV = { SignDeployment, RevAddress }; exports.REV = REV; -exports.SignDeployment = SignDeployment; - /** * Proxy method calls to registered RChain channels. */ @@ -128,4 +126,10 @@ export type HexStr = HexStr; export type Bytes = Bytes; */ -exports.Hex = require('./src/hex'); +/** + * Hex (base16) encoding and decoding + * @namespace + */ +const Hex = require('./src/hex'); + +exports.Hex = Hex; diff --git a/package.json b/package.json index aa6b111..ad85c83 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "testAll": "npm run check && npm run integrationTest", "build:docs": "documentation build -f md --github --sort-order alpha index.js src/**.js --shallow -o docs/index.md && markdown-doctest", "build:docs-html": "documentation build -f html --github --sort-order alpha index.js src/**.js --shallow -o docs/", - "doc-watch": "documentation serve --watch index.js src/**.js --shallow", - "check": "npm run test && npm run lint && npm run flow-check", + "doc-watch": "documentation serve --watch index.js --config docs/config.yml src/**.js --shallow", + "check": "npm run test && npm run build:docs && npm run lint && npm run flow-check", "test": "tape test/**/*.js && markdown-doctest", "integrationTest": "node test/testRNode.js --net && node test/liveRHOCoreTest.js && node test/liveRNodeTest.js", "flow-check": "flow check --from emacs", diff --git a/src/RHOCore.js b/src/RHOCore.js index a6cff65..ec27d14 100644 --- a/src/RHOCore.js +++ b/src/RHOCore.js @@ -81,6 +81,18 @@ function fromJSData(data /*: mixed */) /* : IPar */ { return recur(data); } +exports.fromIds = fromIds; +/** + * Turn unforgeable names from raw bytes to protobuf Par shape + * + * @async + * @memberof RHOCore + */ +async function fromIds(idsP /*: Promise */) /*: Promise */ { + const ids = await idsP; + return ids.map(id => ({ ids: [{ id }] })); +} + exports.toByteArray = toByteArray; /** diff --git a/src/hex.js b/src/hex.js index ea843c2..cd1e0b0 100644 --- a/src/hex.js +++ b/src/hex.js @@ -7,17 +7,43 @@ export type HexStr = string; export type Bytes = Uint8Array | Buffer; */ -exports.encode = encode; +/** + * A byte sequence + * + * @typedef { Uint8Array | Buffer } Bytes + * + * @memberof Hex + */ + +/** + * Hex (base16) encoding of a Bytes type + * + * @typedef { string } HexStr + * + * @memberof Hex + */ + +/** + * Encode bytes as hex string + * + * @memberof Hex + */ function encode/*:: */(bytes /*: T */) /*: string*/ { return Buffer.from(bytes).toString('hex'); } +exports.encode = encode; exports.fromBytes = fromBytes; function fromBytes/*:: */(bytes /*: T */) /*: HexStr*/ { return Buffer.from(bytes).toString('hex'); } -exports.decode = decode; +/** + * Decode hex string to bytes + * + * @memberof Hex + */ function decode/*:: */(hex /*: HexStr*/) /*: Bytes*/ { return Buffer.from(hex, 'hex'); } +exports.decode = decode; diff --git a/src/loading.js b/src/loading.js index fca9a49..715b6b9 100644 --- a/src/loading.js +++ b/src/loading.js @@ -9,6 +9,7 @@ const Hex = require('./hex'); const { Ed25519keyPair } = require('./signing'); const { pollAt } = require('./proxy'); const { Block, SignDeployment } = require('./rnodeAPI'); +const { fromIds } = require('./RHOCore'); const { link } = require('./assets'); @@ -52,7 +53,7 @@ async function loadRhoModules( async function deploy1({ name, title, term }) { const timestamp = monotonicClock(); const info = payFor({ term, timestamp }); - const [chan] = await rnode.previewPrivateChannels({ user: info.deployer, timestamp }, 1); + const [chan] = await fromIds(rnode.previewPrivateNames({ user: info.deployer, timestamp }, 1)); console.log(`Deploying: ${title}\n`); const deployResult = await rnode.doDeploy(info); console.log({ deployResult, name }); diff --git a/src/proxy.js b/src/proxy.js index ed1cad3..dba3a8d 100644 --- a/src/proxy.js +++ b/src/proxy.js @@ -66,7 +66,6 @@ export type PayFor = T => T & { deployer: PK, sig: Sig }; * * @memberof RegistryProxy */ -exports.makeProxy = makeProxy; function makeProxy( target /*: URL */, deployer /*: Uint8Array */, @@ -80,6 +79,7 @@ function makeProxy( // override set to make it read-only? }); } +exports.makeProxy = makeProxy; /** @@ -97,7 +97,6 @@ function makeProxy( * * @memberof RegistryProxy */ -exports.sendCall = sendCall; async function sendCall( { target, method, args } /*: Message*/, timestamp /*: number*/, @@ -112,7 +111,7 @@ async function sendCall( if (opts.fixArgs) { throw new Error('fixArgs not supported with returnCh'); } returnChan = opts.returnCh; } else { - const chans /*: Buffer[] */ = await rnode.previewPrivateIds( + const chans /*: Buffer[] */ = await rnode.previewPrivateNames( { user: deployer, timestamp }, 1 + (opts.predeclare || []).length, ); @@ -134,6 +133,7 @@ async function sendCall( console.log(term); return runRholang(term, timestamp, payFor, returnChan, opts, method || '?'); } +exports.sendCall = sendCall; exports.runRholang = runRholang; diff --git a/src/rnodeAPI.js b/src/rnodeAPI.js index 0bb57ee..891f924 100644 --- a/src/rnodeAPI.js +++ b/src/rnodeAPI.js @@ -41,7 +41,6 @@ const packageDefinition = protoLoader.loadSync( /*:: -import grpcT from 'grpc'; import type { JsonExt } from './RHOCore'; import type { KeyPair } from './signing'; @@ -50,7 +49,9 @@ type JSData = JsonExt; /*:: type EndPoint = { host: string, port: number }; -export type IRNode = $Call; +import GRPCAccess from 'grpc'; + +export type IRNode = $Call; export type IDeployData = coop$rchain$casper$protocol$IDeployData; type DeployService = coop$rchain$casper$protocol$DeployService; @@ -83,7 +84,7 @@ exports.RNode = RNode; * * [nodeAPI]: https://rchain.atlassian.net/wiki/spaces/CORE/pages/392462355/Node+API+Specification * - * @param grpc access to the network: grpc instance from the node grpc package + * @param grpc access make gRPC network calls * @param endPoint rnode gRPC service * @return a thin wrapper around a gRPC client stub * @@ -93,7 +94,7 @@ exports.RNode = RNode; * const grpc = require('grpc'); * * const rnode = RNode(grpc, { host: 'localhost', port: 40401 }); - * rnode.getAllBlocks().then((blocks) => { assert(blocks[0].blockNumber > 0); }); + * rnode.showBlocks().then((blocks) => { assert.ok(blocks[0].blockHash); }); * * // Deploy a simple Rholang process, given a key to authorize payment. * const term = '@"world"!("Hello!")'; @@ -102,7 +103,10 @@ exports.RNode = RNode; * const info = REV.SignDeployment.sign(myKey, { timestamp, term, phloLimit: 10000, phloPrice: 1 }); * rnode.doDeploy(info, true).then((message) => { assert(message.startsWith('Success')); }); */ -function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */) /*: IRNode */{ +function RNode( + grpc /*: GRPCAccess */, + endPoint /*: { host: string, port: number } */, +) /*: IRNode */ { const { host, port } = endPoint; assert.ok(host, 'endPoint.host missing'); assert.ok(port, 'endPoint.port missing'); @@ -117,13 +121,15 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ /** * Ask rnode to compute ids of top level private names, given deploy parameters. * - * @param d - * @param d.user - public key as in doDeploy deployer - * @param d.timestamp - timestamp (ms) as in doDeploy + * @param {Object} d + * @param {Uint8Array} d.user - public key as in `deployer` in `doDeploy` + * @param {number} d.timestamp - timestamp (ms) as in doDeploy * @param nameQty - how many names to preview? (max: 1024) + * @return a byte Buffer for each id * @memberof RNode + * @instance */ - async function previewPrivateIds( + async function previewPrivateNames( { user, timestamp } /*: $ReadOnly<{ user?: Uint8Array, timestamp?: number }> */, nameQty /*: number */, ) /*: Promise */{ @@ -136,26 +142,10 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ const idToPar = id => ({ ids: [{ id }] }); - /** - * Ask rnode to compute top level private channels, given deploy parameters. - * - * @param d - * @param d.user - public key (of validating node?) as in doDeploy - * @param d.timestamp - timestamp (ms) as in doDeploy - * @param nameQty - how many names to preview? (max: 1024) - * @memberof RNode - */ - function previewPrivateChannels( - { user, timestamp } /*: $ReadOnly<{ user?: Uint8Array, timestamp?: number }> */, - nameQty /*: number*/, - ) /*: Promise */{ - return previewPrivateIds({ user, timestamp }, nameQty) - .then(ids => ids.map(idToPar)); - } - /** * Deploys a rholang term to a node * @memberof RNode + * @instance * @param deployData a DeployData (cf CasperMessage.proto) * @param deployData.deployer public key * @param deployData.term A string of rholang code (for example @"world"!("Hello!") ) @@ -194,6 +184,7 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ /** * Creates a block on your node * @memberof RNode + * @instance * @return A promise for response message */ async function createBlock() /*: Promise*/ { @@ -218,10 +209,12 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * Listen for data at a PUBLIC name in the RChain tuple-space. * * @memberof RNode + * @instance * @param nameObj: JSON-ish data: string, number, {}, [], ... * @return promise for [DataWithBlockInfo] * @throws Error if status is not Success * @deprecated + * @ignore */ function listenForDataAtPublicName(nameObj /*: JSData */, depth /*: number */ = 1) { return listenForDataAtName(RHOCore.fromJSData(nameObj), depth); @@ -231,10 +224,12 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * Listen for data at a PRIVATE name in the RChain tuple-space. * * @memberof RNode + * @instance * @param nameId: Hex string representing an UnforgeableName's Id * @return promise for [DataWithBlockInfo] * @throws Error if status is not Success * @deprecated + * @ignore */ function listenForDataAtPrivateName(nameId /*: string */, depth /*: number */ = 1) { // Convert the UnforgeableName into a byte array @@ -249,6 +244,7 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * Listen for data at a name in the RChain tuple-space. * * @memberof RNode + * @instance * @param par: JSON-ish Par data. See protobuf/RhoTypes.proto * @param blockDepth: Number of blocks to look back in for the name to listen on * @return: promise for DataWithBlockInfo[] @@ -276,11 +272,11 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ /** * Listen for a continuation at an individual public name or * JOINed set of public names in the tuplespace - * @memberof RNode * @param nameObjs a list of names (strings) * @return promise for ContinuationsWithBlockInfo * @throws Error if status is not Success * @deprecated + * @ignore */ function listenForContinuationAtPublicName(nameObjs /*: string[] */, depth /*: number */ = 1) { return listenForContinuationAtName(nameObjs.map(RHOCore.fromJSData), depth); @@ -289,11 +285,11 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ /** * Listen for a continuation at an individual private name or * JOINed set of private names in the tuplespace - * @memberof RNode * @param nameIds a list hex strings representing the unforgeable names' Ids * @return promise for ContinuationsWithBlockInfo * @throws Error if status is not Success * @deprecated + * @ignore */ function listenForContinuationAtPrivateName(nameIds /*: string[] */, depth /*: number */ = 1) { // Convert the UnforgeableNames into a byte arrays @@ -310,6 +306,7 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * Listen for a continuation at an individual name or * JOINed set of names in the tuplespace * @memberof RNode + * @instance * @param pars The names onwhich to listen * @return promise for DataWithBlockInfo * @throws Error if status is not Success @@ -331,11 +328,12 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * Retrieve a block with the tuplespace for a specific block hash * * @memberof RNode + * @instance * @param blockHash: String of the hash for the block being requested * @return BlockInfo structure that will include all metadata and also includes Tuplespace * @throws Error if the hash is blank or does not correspond to an existing block */ - async function getBlock(blockHash /*: string */) { + async function showBlock(blockHash /*: string */) { if (blockHash.trim().length === 0 || blockHash === null || blockHash === undefined) { throw new Error('ERROR: blockHash is blank'); } if (typeof blockHash !== 'string') { throw new Error('ERROR: blockHash must be a string value'); } @@ -351,11 +349,12 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ * including the number of blocks specified by the block_depth * * @memberof RNode + * @instance * @param blockDepth: Number indicating the number of blocks to retrieve * @return List of BlockInfoWithoutTuplespace structures for each block retrieved * @throws Error if blockDepth < 1 or no blocks were able to be retrieved */ - function getAllBlocks(blockDepth /*: number */ = 1) /*: Promise */{ + function showBlocks(blockDepth /*: number */ = 1) /*: Promise */{ if (!Number.isInteger(blockDepth)) { throw new Error('ERROR: blockDepth must be an integer'); } if (blockDepth < 1) { throw new Error('ERROR: blockDepth parameter must be >= 1'); } return sendThenReceiveStream(client.showBlocks({ depth: blockDepth })) @@ -376,10 +375,9 @@ function RNode(grpc /*: grpcT */, endPoint /*: { host: string, port: number } */ listenForContinuationAtName, listenForContinuationAtPrivateName, listenForContinuationAtPublicName, - getBlock, - getAllBlocks, - previewPrivateIds, - previewPrivateChannels, + showBlock, + showBlocks, + previewPrivateNames, }); } diff --git a/test/testProxy.js b/test/testProxy.js index f66a9e0..3607bd6 100644 --- a/test/testProxy.js +++ b/test/testProxy.js @@ -1,17 +1,16 @@ /*global require, exports, Buffer*/ +// @flow -const { sendCall, makeProxy, RNode, h2b, firstBlockData } = require('..'); +const { URL } = require('url'); +const { RNode, Block, RHOCore, RegistryProxy, REV, Hex, Ed25519keyPair } = require('..'); const { link } = require('./assets'); -const { prettyPrivate } = require('../src/loading'); // ISSUE: cheating? + +const { sendCall, makeProxy } = RegistryProxy; +const { fromIds } = RHOCore; +const h2b = Hex.decode; const def = Object.freeze; const remoteContract = link('./target1.rho'); -const defaultPayment = { - from: '0x1', - nonce: 0, - phloPrice: 1, - phloLimit: 100000, -}; /** @@ -21,18 +20,17 @@ const defaultPayment = { async function test({ rnode, clock, deployer, setTimeout }) { const target = await remoteTarget({ rnode, clock, deployer }); - const timeout = clock().valueOf(); + const timestamp = clock().valueOf(); - const deployData = { deployer, timeout, ...defaultPayment }; - const delay = () => makeTimer(setTimeout)(500); + const delay = _i => makeTimer(setTimeout)(500); const ansToSend = await sendCall( { target, method: 'buy', args: ['orange', 20] }, - deployData, + timestamp, deployer, payFor, { rnode, clock, delay, unary: true }, ); console.log({ ansToSend }); - const targetProxy = makeProxy(target, deployData, { rnode, clock, delay, unary: true }); + const targetProxy = makeProxy(target, deployer, payFor, { rnode, clock, delay, unary: true }); const ansToProxy = await targetProxy.sell('banana', 20, 3); console.log({ ansToProxy }); @@ -49,34 +47,46 @@ function makeTimer(setTimeout) { /** * Get registry URI of object created in target1.rho. */ -async function remoteTarget({ rnode, clock, deployer }) { +async function remoteTarget({ rnode, clock, deployer }) /*: Promise */{ const timestamp = clock().valueOf(); - const deployTarget = { term: remoteContract, deployer, timestamp, ...defaultPayment }; - const [id1] = await rnode.previewPrivateIds({ user: deployer, timestamp }, 1); - const idToPar = id => ({ ids: [{ id }] }); - const targetCh = idToPar(id1); + const deployTarget = payFor({ term: remoteContract, timestamp }); + const [targetCh] = await fromIds(rnode.previewPrivateNames({ user: deployer, timestamp }, 1)); // console.log({ targetCh: JSON.stringify(targetCh) }); await rnode.doDeploy(deployTarget, true); - console.log(`remote: listening at return chan ${prettyPrivate(targetCh)}`); + console.log(`remote: listening at return chan ${RHOCore.prettyPrivate(targetCh)}`); const found = await rnode.listenForDataAtName(targetCh); // console.log('found:', JSON.stringify(found)); - const target = firstBlockData(found); + const target = Block.firstData(found); console.log({ target }); + if (!(target instanceof URL)) { throw new Error('expected URL'); } return target; } +const defaultSec = Hex.decode('b18e1d0045995ec3d010c387ccfeb984d783af8fbb0f40fa7db126d889f6dadd'); + +function payFor(d0, key, phloPrice = 1, phloLimit = 10000000) { + const dout = REV.SignDeployment.sign(Ed25519keyPair(defaultSec), { + ...d0, + phloPrice, + phloLimit, + }); + // console.log({ valid: SignDeployment.verify(dout), sig: b2h(dout.sig) }); + return dout; +} + + function mockRNode() { let nextAnswer = {}; - async function previewPrivateIds({ user, timestamp }, nameQty) { + async function previewPrivateNames({ user, timestamp }, nameQty) { const each = i => Buffer.from([(user.length * i + timestamp) % 51]); return [...Array(nameQty).keys()].map(each); } - async function doDeploy(deployData) { + async function doDeploy(deployData, _auto = false) { console.log('deploy: ', deployData); if (deployData.term.match(/rho:registry/)) { - nextAnswer = { exprs: [{ g_string: 'rho:id:123456' }] }; + nextAnswer = { exprs: [{ g_uri: 'rho:id:123456' }] }; } else { nextAnswer = { exprs: [{ g_int: '42' }] }; } @@ -87,7 +97,7 @@ function mockRNode() { // console.log('listen for data at', JSON.stringify(_name)); return [{ postBlockData: [nextAnswer] }]; } - return def({ previewPrivateIds, doDeploy, listenForDataAtName }); + return def({ previewPrivateNames, doDeploy, listenForDataAtName }); } /*global module, setTimeout */ @@ -114,7 +124,7 @@ if (require.main === module) { setTimeout, rnode, deployer: h2b('1122334455667788112233445566778811223344556677881122334455667788'), - clock: () => new Date().valueOf(), + clock: () => new Date(), }).catch((oops) => { console.error(oops); console.error(oops.stack); diff --git a/test/testRNode.js b/test/testRNode.js index 20aeefc..64b98a6 100644 --- a/test/testRNode.js +++ b/test/testRNode.js @@ -8,7 +8,7 @@ const { BlockInfoWithoutTuplespace } = CasperMessage.coop.rchain.casper.protocol const api = require('..'); -const { RNode, RegistryProxy, SignDeployment, RHOCore, Hex } = api; +const { RNode, RegistryProxy, REV, RHOCore, Hex } = api; const { RholangCrypto, Ed25519keyPair } = api; const { sha256Hash, keccak256Hash, blake2b256Hash } = RholangCrypto; @@ -83,13 +83,13 @@ function netTests({ grpc, clock, rng }) { }) .catch((oops) => { test.fail(oops.message); test.end(); }); }, - 'test getAllBlocks': (test) => { + 'test showBlocks': (test) => { const expected = [ 'parentsHashList', 'blockHash', 'blockSize', 'blockNumber', 'version', 'deployCount', 'tupleSpaceHash', 'timestamp', 'faultTolerance', 'mainParentHash', 'sender', ]; - localNode().getAllBlocks() + localNode().showBlocks() .then((actual) => { test.equal(actual.length > 0, true); test.deepEqual(Object.keys(actual[0]), expected); @@ -142,7 +142,7 @@ async function runAndListen( function payFor(d0, key, phloPrice = 1, phloLimit = 10000000) { - const dout = SignDeployment.sign(key, { + const dout = REV.SignDeployment.sign(key, { ...d0, phloPrice, phloLimit, @@ -157,7 +157,10 @@ function grpcMock() { return Object.freeze({ doDeploy(_dd /*: Object */, _auto /*: boolean */ = false) { return 'Success!'; }, showBlocks(_depth /*: number */) { - const block4 = { value: BlockInfoWithoutTuplespace.encode({ blockNumber: 4 }).finish() }; + const block4 = { + value: BlockInfoWithoutTuplespace + .encode({ blockHash: 'deadbeef' }).finish(), + }; return Object.freeze({ on(name /*: string */, handler /*: (...args: any[]) => void */) { diff --git a/test/testSigning.js b/test/testSigning.js index 30f6f24..80f2653 100644 --- a/test/testSigning.js +++ b/test/testSigning.js @@ -3,7 +3,7 @@ const ttest = require('tape'); const { DeployData } = require('../protobuf/CasperMessage').coop.rchain.casper.protocol; -const { Ed25519keyPair, RholangCrypto, Hex, SignDeployment } = require('..'); +const { Ed25519keyPair, RholangCrypto, Hex, REV } = require('..'); const { ed25519Verify } = RholangCrypto; @@ -61,7 +61,7 @@ function testSigning() { '123b6e6577207465737420696e207b20636f6e747261637420746573742872657475726e29203d207b2072657475726e212822746573742229207d207d189eb29ff69f2d38014080ade204', ); - const dout = SignDeployment.sign(Ed25519keyPair(defaultSec), d0); + const dout = REV.SignDeployment.sign(Ed25519keyPair(defaultSec), d0); test.equal( b2h(dout.sig), 'b6e0c2077e3ae2794b7324b518b49a9aa597eb07207f84f6339db73aeb6852491b8a7e640fd17f88ee80b61e3d326ec87835feebbb7dacdeadf03f26deff350f', From 02e191fb8a870894caac37fb8a79f000e08f0bac Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sun, 14 Apr 2019 15:47:49 -0500 Subject: [PATCH 33/36] API docs: regen --- docs/index.md | 801 ++++++++++++++++++++++++-------------------------- 1 file changed, 385 insertions(+), 416 deletions(-) diff --git a/docs/index.md b/docs/index.md index fc9036f..8c2af91 100644 --- a/docs/index.md +++ b/docs/index.md @@ -12,85 +12,84 @@ - [Parameters][9] - [sha256Hash][10] - [Parameters][11] -- [RegistryProxy][12] - - [callSource][13] - - [Parameters][14] - - [makeProxy][15] - - [Parameters][16] - - [sendCall][17] - - [Parameters][18] -- [RNode][19] - - [Parameters][20] - - [Examples][21] - - [createBlock][22] - - [doDeploy][23] - - [Parameters][24] - - [getAllBlocks][25] - - [Parameters][26] - - [getBlock][27] - - [Parameters][28] - - [listenForContinuationAtName][29] - - [Parameters][30] - - [listenForContinuationAtPrivateName][31] - - [Parameters][32] - - [listenForContinuationAtPublicName][33] - - [Parameters][34] - - [listenForDataAtName][35] - - [Parameters][36] - - [listenForDataAtPrivateName][37] - - [Parameters][38] - - [listenForDataAtPublicName][39] - - [Parameters][40] - - [previewPrivateChannels][41] - - [Parameters][42] - - [previewPrivateIds][43] - - [Parameters][44] -- [RHOCore][45] - - [Examples][46] - - [dataToBytes][47] - - [fromJSData][48] - - [Parameters][49] - - [getIdFromUnforgeableName][50] - - [Parameters][51] - - [rhol][52] - - [Parameters][53] - - [toByteArray][54] - - [Parameters][55] - - [toJSData][56] - - [Parameters][57] - - [toRholang][58] - - [Parameters][59] - - [unforgeableWithId][60] - - [Parameters][61] - - [wrapHash][62] - - [Parameters][63] -- [Ed25519keyPair][64] - - [Parameters][65] - - [publicKey][66] - - [signBytes][67] - - [Parameters][68] - - [signBytesHex][69] - - [Parameters][70] - - [signText][71] - - [Parameters][72] - - [signTextHex][73] - - [Parameters][74] -- [REV][75] - - [Examples][76] - - [RevAddress][77] - - [fromPublicKey][78] - - [Parameters][79] - - [parse][80] - - [Parameters][81] - - [SignDeployment][82] - - [sign][83] - - [Parameters][84] - - [verify][85] - - [Parameters][86] +- [Hex][12] + - [Bytes][13] + - [decode][14] + - [Parameters][15] + - [encode][16] + - [Parameters][17] + - [HexStr][18] +- [RegistryProxy][19] + - [callSource][20] + - [Parameters][21] + - [makeProxy][22] + - [Parameters][23] + - [sendCall][24] + - [Parameters][25] +- [RNode][26] + - [Parameters][27] + - [Examples][28] + - [createBlock][29] + - [doDeploy][30] + - [Parameters][31] + - [listenForContinuationAtName][32] + - [Parameters][33] + - [listenForDataAtName][34] + - [Parameters][35] + - [previewPrivateNames][36] + - [Parameters][37] + - [showBlock][38] + - [Parameters][39] + - [showBlocks][40] + - [Parameters][41] +- [RHOCore][42] + - [Examples][43] + - [dataToBytes][44] + - [fromIds][45] + - [Parameters][46] + - [fromJSData][47] + - [Parameters][48] + - [getIdFromUnforgeableName][49] + - [Parameters][50] + - [rhol][51] + - [Parameters][52] + - [toByteArray][53] + - [Parameters][54] + - [toJSData][55] + - [Parameters][56] + - [toRholang][57] + - [Parameters][58] + - [unforgeableWithId][59] + - [Parameters][60] + - [wrapHash][61] + - [Parameters][62] +- [Ed25519keyPair][63] + - [Parameters][64] + - [publicKey][65] + - [signBytes][66] + - [Parameters][67] + - [signBytesHex][68] + - [Parameters][69] + - [signText][70] + - [Parameters][71] + - [signTextHex][72] + - [Parameters][73] +- [REV][74] + - [Examples][75] + - [RevAddress][76] + - [fromPublicKey][77] + - [Parameters][78] + - [parse][79] + - [Parameters][80] + - [SignDeployment][81] + - [sign][82] + - [Parameters][83] + - [verify][84] + - [Parameters][85] ## RholangCrypto -[src/signing.js:179-179][87] +[src/signing.js:179-179][86] Cryptographic functions from Rholang @@ -106,7 +105,7 @@ refs: [vtut]: https://github.com/rchain/rchain/blob/3c64ca3/rholang/examples/tut-verify-channel.md -See also [RHOCore.wrapHash][88] +See also [RHOCore.wrapHash][87] ### Examples @@ -137,63 +136,109 @@ assert(!RholangCrypto.ed25519Verify(digest, sig2, halePub)); ### blake2b256Hash -[src/signing.js:134-138][89] +[src/signing.js:134-138][88] Blake2b 256 bit cryptographic hash function #### Parameters -- `input` **[Uint8Array][90]** any number of bytes +- `input` **[Uint8Array][89]** any number of bytes -Returns **[Uint8Array][90]** 256 bit (32 byte) hash +Returns **[Uint8Array][89]** 256 bit (32 byte) hash ### ed25519Verify -[src/signing.js:90-96][91] +[src/signing.js:90-96][90] Verify ed25519 signature #### Parameters -- `message` **[Uint8Array][90]** any number of bytes (TODO: test!) -- `sig` **[Uint8Array][90]** 64 byte ed25519 signature over message -- `publicKey` **[Uint8Array][90]** 32 byte ed25519 public key +- `message` **[Uint8Array][89]** any number of bytes (TODO: test!) +- `sig` **[Uint8Array][89]** 64 byte ed25519 signature over message +- `publicKey` **[Uint8Array][89]** 32 byte ed25519 public key -Returns **[boolean][92]** indicates whether the signature is valid +Returns **[boolean][91]** indicates whether the signature is valid ### keccak256Hash -[src/signing.js:121-123][93] +[src/signing.js:121-123][92] Keccak 256 bit cryptographic hash function (aka SHA-3) #### Parameters -- `input` **[Uint8Array][90]** any number of bytes +- `input` **[Uint8Array][89]** any number of bytes -Returns **[Uint8Array][90]** 256 bit (32 byte) hash +Returns **[Uint8Array][89]** 256 bit (32 byte) hash ### sha256Hash -[src/signing.js:107-111][94] +[src/signing.js:107-111][93] SHA-2 256 bit cryptographic hash function #### Parameters -- `input` **[Uint8Array][90]** any number of bytes +- `input` **[Uint8Array][89]** any number of bytes -Returns **[Uint8Array][90]** 256 bit (32 byte) hash +Returns **[Uint8Array][89]** 256 bit (32 byte) hash + +## Hex + +[index.js:133-133][94] + +Hex (base16) encoding and decoding + +### Bytes + +[src/hex.js:31-33][95] + +A byte sequence + +Type: ([Uint8Array][89] \| [Buffer][96]) + +### decode + +[src/hex.js:46-48][97] + +Decode hex string to bytes + +#### Parameters + +- `hex` **HexStr<T>** + +Returns **Bytes** + +### encode + +[src/hex.js:31-33][98] + +Encode bytes as hex string + +#### Parameters + +- `bytes` **T** + +Returns **[string][99]** + +### HexStr + +[src/hex.js:31-33][100] + +Hex (base16) encoding of a Bytes type + +Type: [string][99] ## RegistryProxy -[index.js:112-112][95] +[index.js:110-110][101] Proxy method calls to registered RChain channels. ### callSource -[src/proxy.js:194-194][96] +[src/proxy.js:194-194][102] Make a rholang term for looking up a target and calling a method. @@ -206,7 +251,7 @@ Make a rholang term for looking up a target and calling a method. ### makeProxy -[src/proxy.js:69-69][97] +[src/proxy.js:69-81][103] Make an object that proxies method calls to registered RChain channels. @@ -215,19 +260,23 @@ For rholang calling conventions, see `callSource`. #### Parameters -- `target` : URI where channel is registered. -- `deployData` : as in doDeploy (though term is ignored and replaced) -- `opts` +- `target` **[URL][104]** : URI where channel is registered. +- `deployer` **[Uint8Array][89]** +- `payFor` **PayFor<IDeployData>** +- `opts` **ProxyOpts** - `opts.rnode` : access to RChain node via gRPC - `opts.clock` : access to millisecond-resolution clock. - `opts.delay` : an optional async function to call between sending a call and listening for the response. - `opts.unary` : whether to use unary calling conventions. - `opts.predeclare` : names to pre-declare after `return` +- `deployData` : as in doDeploy (though term is ignored and replaced) + +Returns **Receiver** ### sendCall -[src/proxy.js:100-100][98] +[src/proxy.js:100-135][105] Call a method on a registered RChain channel. @@ -235,17 +284,24 @@ For rholang calling conventions, see `callSource`. #### Parameters -- `target` : URI where channel is registered. -- `deployData` : as in doDeploy (though term is ignored and replaced) -- `opts` +- `$0` **any** + - `$0.target` + - `$0.method` + - `$0.args` +- `timestamp` **[number][106]** +- `deployer` **[Uint8Array][89]** +- `payFor` **PayFor<IDeployData>** +- `opts` **SendOpts** - `opts.rnode` : access to RChain node via gRPC - `opts.delay` : an optional async function to call between sending a call and listening for the response. - `opts.unary` : whether to use unary calling conventions. +- `target` : URI where channel is registered. +- `deployData` : as in doDeploy (though term is ignored and replaced) ## RNode -[src/rnodeAPI.js:105-384][99] +[src/rnodeAPI.js:106-382][107] RChain node API client @@ -273,8 +329,8 @@ Refs: ### Parameters -- `grpc` **grpcT** access to the network: grpc instance from the node grpc package -- `endPoint` **{host: [string][100], port: [number][101]}** rnode gRPC service +- `grpc` **GRPCAccess** access make gRPC network calls +- `endPoint` **{host: [string][99], port: [number][106]}** rnode gRPC service ### Examples @@ -284,7 +340,7 @@ const { RNode, REV, Ed25519keyPair, Hex } = require('rchain-api'); const grpc = require('grpc'); const rnode = RNode(grpc, { host: 'localhost', port: 40401 }); -rnode.getAllBlocks().then((blocks) => { assert(blocks[0].blockNumber > 0); }); +rnode.showBlocks().then((blocks) => { assert.ok(blocks[0].blockHash); }); // Deploy a simple Rholang process, given a key to authorize payment. const term = '@"world"!("Hello!")'; @@ -298,15 +354,15 @@ Returns **IRNode** a thin wrapper around a gRPC client stub ### createBlock -[src/rnodeAPI.js:199-202][102] +[src/rnodeAPI.js:190-193][108] Creates a block on your node -Returns **[Promise][103]<[string][100]>** A promise for response message +Returns **[Promise][109]<[string][99]>** A promise for response message ### doDeploy -[src/rnodeAPI.js:176-192][104] +[src/rnodeAPI.js:166-182][110] Deploys a rholang term to a node @@ -322,198 +378,97 @@ Deploys a rholang term to a node - `deployData.phloLimit` - `deployData.phloPrice` - `deployData.validAfterBlockNumber` ???ISSUE??? -- `autoCreateBlock` **[boolean][92]** automatically create a new block after deploy transaction success - - -- Throws **[Error][105]** Could not deploy, casper instance was not available yet. -- Throws **[Error][105]** Missing / invalid / wrong size signature +- `autoCreateBlock` **[boolean][91]** automatically create a new block after deploy transaction success -Returns **[Promise][103]<[string][100]>** A promise for message - -### getAllBlocks - -[src/rnodeAPI.js:358-368][106] - -Retrieve the block summary for a series of blocks starting with the most recent, -including the number of blocks specified by the block_depth - -#### Parameters -- `blockDepth` **[number][101]** : Number indicating the number of blocks to retrieve - - -- Throws **any** Error if blockDepth < 1 or no blocks were able to be retrieved - -Returns **[Promise][103]<BlockInfoWithoutTuplespace>** List of BlockInfoWithoutTuplespace structures for each block retrieved - -### getBlock - -[src/rnodeAPI.js:338-347][107] - -Retrieve a block with the tuplespace for a specific block hash - -#### Parameters - -- `blockHash` **[string][100]** : String of the hash for the block being requested - - -- Throws **any** Error if the hash is blank or does not correspond to an existing block +- Throws **[Error][111]** Could not deploy, casper instance was not available yet. +- Throws **[Error][111]** Missing / invalid / wrong size signature -Returns **any** BlockInfo structure that will include all metadata and also includes Tuplespace +Returns **[Promise][109]<[string][99]>** A promise for message ### listenForContinuationAtName -[src/rnodeAPI.js:317-328][108] +[src/rnodeAPI.js:314-325][112] Listen for a continuation at an individual name or JOINed set of names in the tuplespace #### Parameters -- `pars` **[Array][109]<IPar>** The names onwhich to listen -- `depth` **[number][101]** +- `pars` **[Array][113]<IPar>** The names onwhich to listen +- `depth` **[number][106]** - Throws **any** Error if status is not Success -Returns **[Promise][103]<ListeningNameContinuationResponse>** promise for DataWithBlockInfo - -### listenForContinuationAtPrivateName - -[src/rnodeAPI.js:298-306][110] - -Listen for a continuation at an individual private name or -JOINed set of private names in the tuplespace - -#### Parameters - -- `nameIds` **[Array][109]<[string][100]>** a list hex strings representing the unforgeable names' Ids -- `depth` **[number][101]** (optional, default `1`) - - -- Throws **any** Error if status is not Success - -Returns **any** promise for ContinuationsWithBlockInfo - -**Meta** - -- **deprecated**: This is deprecated. - - -### listenForContinuationAtPublicName - -[src/rnodeAPI.js:285-287][111] - -Listen for a continuation at an individual public name or -JOINed set of public names in the tuplespace - -#### Parameters - -- `nameObjs` **[Array][109]<[string][100]>** a list of names (strings) -- `depth` **[number][101]** (optional, default `1`) - - -- Throws **any** Error if status is not Success - -Returns **any** promise for ContinuationsWithBlockInfo - -**Meta** - -- **deprecated**: This is deprecated. - +Returns **[Promise][109]<ListeningNameContinuationResponse>** promise for DataWithBlockInfo ### listenForDataAtName -[src/rnodeAPI.js:257-273][112] +[src/rnodeAPI.js:253-269][114] Listen for data at a name in the RChain tuple-space. #### Parameters - `par` **IPar** : JSON-ish Par data. See protobuf/RhoTypes.proto -- `depth` **[number][101]** (optional, default `1`) +- `depth` **[number][106]** (optional, default `1`) - `blockDepth` : Number of blocks to look back in for the name to listen on - Throws **any** Error if status is not Success -Returns **[Promise][103]<[Array][109]<DataWithBlockInfo>>** : promise for DataWithBlockInfo\[] +Returns **[Promise][109]<[Array][113]<DataWithBlockInfo>>** : promise for DataWithBlockInfo\[] -### listenForDataAtPrivateName +### previewPrivateNames -[src/rnodeAPI.js:239-246][113] +[src/rnodeAPI.js:132-141][115] -Listen for data at a PRIVATE name in the RChain tuple-space. +Ask rnode to compute ids of top level private names, given deploy parameters. #### Parameters -- `nameId` **[string][100]** : Hex string representing an UnforgeableName's Id -- `depth` **[number][101]** (optional, default `1`) - +- `d` **[Object][116]** + - `d.user` **[Uint8Array][89]** public key as in `deployer` in `doDeploy` + - `d.timestamp` **[number][106]** timestamp (ms) as in doDeploy +- `nameQty` **[number][106]** how many names to preview? (max: 1024) -- Throws **any** Error if status is not Success - -Returns **any** promise for [DataWithBlockInfo] - -**Meta** - -- **deprecated**: This is deprecated. +Returns **[Promise][109]<[Array][113]<[Buffer][96]>>** a byte Buffer for each id +### showBlock -### listenForDataAtPublicName +[src/rnodeAPI.js:336-345][117] -[src/rnodeAPI.js:226-228][114] - -Listen for data at a PUBLIC name in the RChain tuple-space. +Retrieve a block with the tuplespace for a specific block hash #### Parameters -- `nameObj` **JSData** : JSON-ish data: string, number, {}, \[], ... -- `depth` **[number][101]** (optional, default `1`) +- `blockHash` **[string][99]** : String of the hash for the block being requested -- Throws **any** Error if status is not Success - -Returns **any** promise for [DataWithBlockInfo] - -**Meta** - -- **deprecated**: This is deprecated. +- Throws **any** Error if the hash is blank or does not correspond to an existing block +Returns **any** BlockInfo structure that will include all metadata and also includes Tuplespace -### previewPrivateChannels +### showBlocks -[src/rnodeAPI.js:148-154][115] +[src/rnodeAPI.js:357-367][118] -Ask rnode to compute top level private channels, given deploy parameters. +Retrieve the block summary for a series of blocks starting with the most recent, +including the number of blocks specified by the block_depth #### Parameters -- `d` **any** - - `d.user` public key (of validating node?) as in doDeploy - - `d.timestamp` timestamp (ms) as in doDeploy -- `nameQty` **[number][101]** how many names to preview? (max: 1024) - -Returns **[Promise][103]<[Array][109]<IPar>>** +- `blockDepth` **[number][106]** : Number indicating the number of blocks to retrieve -### previewPrivateIds -[src/rnodeAPI.js:126-135][116] - -Ask rnode to compute ids of top level private names, given deploy parameters. - -#### Parameters - -- `d` **any** - - `d.user` public key as in doDeploy deployer - - `d.timestamp` timestamp (ms) as in doDeploy -- `nameQty` **[number][101]** how many names to preview? (max: 1024) +- Throws **any** Error if blockDepth < 1 or no blocks were able to be retrieved -Returns **[Promise][103]<[Array][109]<[Buffer][117]>>** +Returns **[Promise][109]<BlockInfoWithoutTuplespace>** List of BlockInfoWithoutTuplespace structures for each block retrieved ## RHOCore -[index.js:49-49][118] +[index.js:49-49][119] Exchanging data between Rholang and JavaScript @@ -571,11 +526,23 @@ assert.equal(RHOCore.toRholang(rhoProto), ### dataToBytes -[src/RHOCore.js:99-99][119] +[src/RHOCore.js:111-111][120] + +### fromIds + +[src/RHOCore.js:91-94][121] + +Turn unforgeable names from raw bytes to protobuf Par shape + +#### Parameters + +- `idsP` **[Promise][109]<[Array][113]<[Buffer][96]>>** + +Returns **[Promise][109]<[Array][113]<IPar>>** ### fromJSData -[src/RHOCore.js:27-82][120] +[src/RHOCore.js:27-82][122] Build Rholang expression from Javascript data. @@ -590,33 +557,33 @@ Returns **any** : A rholang term in Protobuf's JSON representation, ### getIdFromUnforgeableName -[src/RHOCore.js:331-336][121] +[src/RHOCore.js:343-348][123] Convert the ack channel into a HEX-formatted unforgeable name #### Parameters -- `par` **IPar** : JSON-ish Par data: [https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto][122] +- `par` **IPar** : JSON-ish Par data: [https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto][124] - Throws **any** Error if the Par does not represent an unforgeable name -Returns **[string][100]** HEX-formatted string of unforgeable name's Id +Returns **[string][99]** HEX-formatted string of unforgeable name's Id ### rhol -[src/RHOCore.js:345-355][123] +[src/RHOCore.js:357-367][125] Template tag for RHOCore interpolation #### Parameters -- `template` **[Array][109]<[string][100]>** -- `subs` **...[Array][109]<JsonExt<([URL][124] | GPrivate)>>** +- `template` **[Array][113]<[string][99]>** +- `subs` **...[Array][113]<JsonExt<([URL][104] | GPrivate)>>** ### toByteArray -[src/RHOCore.js:90-93][125] +[src/RHOCore.js:102-105][126] Turns a rholang term into a byte-array compatible with Rholang @@ -624,11 +591,11 @@ Turns a rholang term into a byte-array compatible with Rholang - `termObj` **IPar** -Returns **[Uint8Array][90]** +Returns **[Uint8Array][89]** ### toJSData -[src/RHOCore.js:169-233][126] +[src/RHOCore.js:181-245][127] Converts an RHOCore object back to JavaScript data @@ -636,11 +603,11 @@ Converts an RHOCore object back to JavaScript data - `par` **IPar** A RHOCore representation of a Rholang term -Returns **JsonExt<([URL][124] | GPrivate)>** JSON-serializable data +Returns **JsonExt<([URL][104] | GPrivate)>** JSON-serializable data ### toRholang -[src/RHOCore.js:246-299][127] +[src/RHOCore.js:258-311][128] Converts an RHOCore object into Rholang source form @@ -648,21 +615,21 @@ Converts an RHOCore object into Rholang source form - `par` **IPar** A RHOCore representation of a Rholang term -Returns **[string][100]** A rholang stringISSUE: Use intersection types to constrain par param further than IPar? +Returns **[string][99]** A rholang stringISSUE: Use intersection types to constrain par param further than IPar? ### unforgeableWithId -[src/RHOCore.js:307-310][128] +[src/RHOCore.js:319-322][129] Get printable form of unforgeable name, given id. #### Parameters -- `id` **[Uint8Array][90]** +- `id` **[Uint8Array][89]** ### wrapHash -[src/RHOCore.js:115-115][129] +[src/RHOCore.js:127-127][130] #### Parameters @@ -675,7 +642,7 @@ Returns **any** HEX-formatted string representing the computed hash ## Ed25519keyPair -[src/signing.js:38-75][130] +[src/signing.js:38-75][131] Build key pair from seed. @@ -685,7 +652,7 @@ Build key pair from seed. ### publicKey -[src/signing.js:70-70][131] +[src/signing.js:70-70][132] ISSUE: if the caller wants the bytes, we go bytes -> hex -> bytes @@ -693,47 +660,47 @@ Returns **HexStr<PublicKey>** ### signBytes -[src/signing.js:46-48][132] +[src/signing.js:46-48][133] #### Parameters -- `bytes` **[Uint8Array][90]** +- `bytes` **[Uint8Array][89]** Returns **Signature** ### signBytesHex -[src/signing.js:56-56][133] +[src/signing.js:56-56][134] #### Parameters -- `bs` **[Uint8Array][90]** +- `bs` **[Uint8Array][89]** Returns **HexStr<Signature>** ### signText -[src/signing.js:60-60][134] +[src/signing.js:60-60][135] #### Parameters -- `text` **[string][100]** +- `text` **[string][99]** Returns **Signature** ### signTextHex -[src/signing.js:64-64][135] +[src/signing.js:64-64][136] #### Parameters -- `text` **[string][100]** +- `text` **[string][99]** Returns **HexStr<Signature>** ## REV -[index.js:104-104][136] +[index.js:104-104][137] REV transaction, vault support @@ -775,7 +742,7 @@ assert.throws(() => { ### RevAddress -[src/revAddress.js:38-103][137] +[src/revAddress.js:38-103][138] A RevAddress refers to a REV vault. @@ -783,30 +750,30 @@ Use `toString()` to get base58 form. Refs: -- [RevAddress.scala][138] -- [AddressTools.scala][139] +- [RevAddress.scala][139] +- [AddressTools.scala][140] #### fromPublicKey -[src/revAddress.js:46-61][140] +[src/revAddress.js:46-61][141] Compute REV Address from public key ##### Parameters -- `pk` **[Uint8Array][90]** ed25519 public key +- `pk` **[Uint8Array][89]** ed25519 public key Returns **IRevAddress** #### parse -[src/revAddress.js:69-100][141] +[src/revAddress.js:69-100][142] Parse REV Address ##### Parameters -- `address` **[string][100]** +- `address` **[string][99]** - Throws **any** Error on ill-formed address @@ -815,15 +782,15 @@ Returns **IRevAddress** ### SignDeployment -[src/rnodeAPI.js:420-453][142] +[src/rnodeAPI.js:418-451][143] -a port of [casper/SignDeployment.scala][143] +a port of [casper/SignDeployment.scala][144] ISSUE: only ed25519 is supported. #### sign -[src/rnodeAPI.js:432-438][144] +[src/rnodeAPI.js:430-436][145] ##### Parameters @@ -834,13 +801,13 @@ Returns **DeployData** #### verify -[src/rnodeAPI.js:443-450][145] +[src/rnodeAPI.js:441-448][146] ##### Parameters - `deployData` **DeployData** -Returns **[boolean][92]** +Returns **[boolean][91]** [2]: #rholangcrypto @@ -862,270 +829,272 @@ Returns **[boolean][92]** [11]: #parameters-3 -[12]: #registryproxy +[12]: #hex + +[13]: #bytes -[13]: #callsource +[14]: #decode -[14]: #parameters-4 +[15]: #parameters-4 -[15]: #makeproxy +[16]: #encode -[16]: #parameters-5 +[17]: #parameters-5 -[17]: #sendcall +[18]: #hexstr -[18]: #parameters-6 +[19]: #registryproxy -[19]: #rnode +[20]: #callsource -[20]: #parameters-7 +[21]: #parameters-6 -[21]: #examples-1 +[22]: #makeproxy -[22]: #createblock +[23]: #parameters-7 -[23]: #dodeploy +[24]: #sendcall -[24]: #parameters-8 +[25]: #parameters-8 -[25]: #getallblocks +[26]: #rnode -[26]: #parameters-9 +[27]: #parameters-9 -[27]: #getblock +[28]: #examples-1 -[28]: #parameters-10 +[29]: #createblock -[29]: #listenforcontinuationatname +[30]: #dodeploy -[30]: #parameters-11 +[31]: #parameters-10 -[31]: #listenforcontinuationatprivatename +[32]: #listenforcontinuationatname -[32]: #parameters-12 +[33]: #parameters-11 -[33]: #listenforcontinuationatpublicname +[34]: #listenfordataatname -[34]: #parameters-13 +[35]: #parameters-12 -[35]: #listenfordataatname +[36]: #previewprivatenames -[36]: #parameters-14 +[37]: #parameters-13 -[37]: #listenfordataatprivatename +[38]: #showblock -[38]: #parameters-15 +[39]: #parameters-14 -[39]: #listenfordataatpublicname +[40]: #showblocks -[40]: #parameters-16 +[41]: #parameters-15 -[41]: #previewprivatechannels +[42]: #rhocore -[42]: #parameters-17 +[43]: #examples-2 -[43]: #previewprivateids +[44]: #datatobytes -[44]: #parameters-18 +[45]: #fromids -[45]: #rhocore +[46]: #parameters-16 -[46]: #examples-2 +[47]: #fromjsdata -[47]: #datatobytes +[48]: #parameters-17 -[48]: #fromjsdata +[49]: #getidfromunforgeablename -[49]: #parameters-19 +[50]: #parameters-18 -[50]: #getidfromunforgeablename +[51]: #rhol -[51]: #parameters-20 +[52]: #parameters-19 -[52]: #rhol +[53]: #tobytearray -[53]: #parameters-21 +[54]: #parameters-20 -[54]: #tobytearray +[55]: #tojsdata -[55]: #parameters-22 +[56]: #parameters-21 -[56]: #tojsdata +[57]: #torholang -[57]: #parameters-23 +[58]: #parameters-22 -[58]: #torholang +[59]: #unforgeablewithid -[59]: #parameters-24 +[60]: #parameters-23 -[60]: #unforgeablewithid +[61]: #wraphash -[61]: #parameters-25 +[62]: #parameters-24 -[62]: #wraphash +[63]: #ed25519keypair -[63]: #parameters-26 +[64]: #parameters-25 -[64]: #ed25519keypair +[65]: #publickey -[65]: #parameters-27 +[66]: #signbytes -[66]: #publickey +[67]: #parameters-26 -[67]: #signbytes +[68]: #signbyteshex -[68]: #parameters-28 +[69]: #parameters-27 -[69]: #signbyteshex +[70]: #signtext -[70]: #parameters-29 +[71]: #parameters-28 -[71]: #signtext +[72]: #signtexthex -[72]: #parameters-30 +[73]: #parameters-29 -[73]: #signtexthex +[74]: #rev -[74]: #parameters-31 +[75]: #examples-3 -[75]: #rev +[76]: #revaddress -[76]: #examples-3 +[77]: #frompublickey -[77]: #revaddress +[78]: #parameters-30 -[78]: #frompublickey +[79]: #parse -[79]: #parameters-32 +[80]: #parameters-31 -[80]: #parse +[81]: #signdeployment -[81]: #parameters-33 +[82]: #sign -[82]: #signdeployment +[83]: #parameters-32 -[83]: #sign +[84]: #verify -[84]: #parameters-34 +[85]: #parameters-33 -[85]: #verify +[86]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/signing.js#L179-L179 "Source code on GitHub" -[86]: #parameters-35 +[87]: #rhocorewraphash -[87]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L179-L179 "Source code on GitHub" +[88]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/signing.js#L134-L138 "Source code on GitHub" -[88]: #rhocorewraphash +[89]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array -[89]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L134-L138 "Source code on GitHub" +[90]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/signing.js#L90-L96 "Source code on GitHub" -[90]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array +[91]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[91]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L90-L96 "Source code on GitHub" +[92]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/signing.js#L121-L123 "Source code on GitHub" -[92]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[93]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/signing.js#L107-L111 "Source code on GitHub" -[93]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L121-L123 "Source code on GitHub" +[94]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/index.js#L133-L133 "Source code on GitHub" -[94]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L107-L111 "Source code on GitHub" +[95]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/hex.js#L10-L16 "Source code on GitHub" -[95]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/index.js#L112-L112 "Source code on GitHub" +[96]: https://nodejs.org/api/buffer.html -[96]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/proxy.js#L194-L194 "Source code on GitHub" +[97]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/hex.js#L46-L48 "Source code on GitHub" -[97]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/proxy.js#L69-L69 "Source code on GitHub" +[98]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/hex.js#L31-L33 "Source code on GitHub" -[98]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/proxy.js#L100-L100 "Source code on GitHub" +[99]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[99]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L105-L384 "Source code on GitHub" +[100]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/hex.js#L18-L24 "Source code on GitHub" -[100]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[101]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/index.js#L110-L110 "Source code on GitHub" -[101]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[102]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/proxy.js#L194-L194 "Source code on GitHub" -[102]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L199-L202 "Source code on GitHub" +[103]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/proxy.js#L69-L81 "Source code on GitHub" -[103]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise +[104]: https://developer.mozilla.org/docs/Web/API/URL/URL -[104]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L176-L192 "Source code on GitHub" +[105]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/proxy.js#L100-L135 "Source code on GitHub" -[105]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error +[106]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[106]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L358-L368 "Source code on GitHub" +[107]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/rnodeAPI.js#L106-L382 "Source code on GitHub" -[107]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L338-L347 "Source code on GitHub" +[108]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/rnodeAPI.js#L190-L193 "Source code on GitHub" -[108]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L317-L328 "Source code on GitHub" +[109]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise -[109]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array +[110]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/rnodeAPI.js#L166-L182 "Source code on GitHub" -[110]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L298-L306 "Source code on GitHub" +[111]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error -[111]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L285-L287 "Source code on GitHub" +[112]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/rnodeAPI.js#L314-L325 "Source code on GitHub" -[112]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L257-L273 "Source code on GitHub" +[113]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array -[113]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L239-L246 "Source code on GitHub" +[114]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/rnodeAPI.js#L253-L269 "Source code on GitHub" -[114]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L226-L228 "Source code on GitHub" +[115]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/rnodeAPI.js#L132-L141 "Source code on GitHub" -[115]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L148-L154 "Source code on GitHub" +[116]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[116]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L126-L135 "Source code on GitHub" +[117]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/rnodeAPI.js#L336-L345 "Source code on GitHub" -[117]: https://nodejs.org/api/buffer.html +[118]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/rnodeAPI.js#L357-L367 "Source code on GitHub" -[118]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/index.js#L49-L49 "Source code on GitHub" +[119]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/index.js#L49-L49 "Source code on GitHub" -[119]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L99-L99 "Source code on GitHub" +[120]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/RHOCore.js#L111-L111 "Source code on GitHub" -[120]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L27-L82 "Source code on GitHub" +[121]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/RHOCore.js#L91-L94 "Source code on GitHub" -[121]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L331-L336 "Source code on GitHub" +[122]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/RHOCore.js#L27-L82 "Source code on GitHub" -[122]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto +[123]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/RHOCore.js#L343-L348 "Source code on GitHub" -[123]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L345-L355 "Source code on GitHub" +[124]: https://github.com/rchain/rchain/blob/master/models/src/main/protobuf/RhoTypes.proto -[124]: https://developer.mozilla.org/docs/Web/API/URL/URL +[125]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/RHOCore.js#L357-L367 "Source code on GitHub" -[125]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L90-L93 "Source code on GitHub" +[126]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/RHOCore.js#L102-L105 "Source code on GitHub" -[126]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L169-L233 "Source code on GitHub" +[127]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/RHOCore.js#L181-L245 "Source code on GitHub" -[127]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L246-L299 "Source code on GitHub" +[128]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/RHOCore.js#L258-L311 "Source code on GitHub" -[128]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L307-L310 "Source code on GitHub" +[129]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/RHOCore.js#L319-L322 "Source code on GitHub" -[129]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/RHOCore.js#L115-L115 "Source code on GitHub" +[130]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/RHOCore.js#L127-L127 "Source code on GitHub" -[130]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L38-L75 "Source code on GitHub" +[131]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/signing.js#L38-L75 "Source code on GitHub" -[131]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L70-L70 "Source code on GitHub" +[132]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/signing.js#L70-L70 "Source code on GitHub" -[132]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L46-L48 "Source code on GitHub" +[133]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/signing.js#L46-L48 "Source code on GitHub" -[133]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L56-L56 "Source code on GitHub" +[134]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/signing.js#L56-L56 "Source code on GitHub" -[134]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L60-L60 "Source code on GitHub" +[135]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/signing.js#L60-L60 "Source code on GitHub" -[135]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/signing.js#L64-L64 "Source code on GitHub" +[136]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/signing.js#L64-L64 "Source code on GitHub" -[136]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/index.js#L104-L104 "Source code on GitHub" +[137]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/index.js#L104-L104 "Source code on GitHub" -[137]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/revAddress.js#L38-L103 "Source code on GitHub" +[138]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/revAddress.js#L38-L103 "Source code on GitHub" -[138]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala +[139]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/RevAddress.scala -[139]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala +[140]: https://github.com/rchain/rchain/blob/9ae5825/rholang/src/main/scala/coop/rchain/rholang/interpreter/util/AddressTools.scala -[140]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/revAddress.js#L46-L61 "Source code on GitHub" +[141]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/revAddress.js#L46-L61 "Source code on GitHub" -[141]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/revAddress.js#L69-L100 "Source code on GitHub" +[142]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/revAddress.js#L69-L100 "Source code on GitHub" -[142]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L420-L453 "Source code on GitHub" +[143]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/rnodeAPI.js#L418-L451 "Source code on GitHub" -[143]: https://github.com/rchain/rchain/blob/9ae5825/casper/src/main/scala/coop/rchain/casper/SignDeployment.scala +[144]: https://github.com/rchain/rchain/blob/9ae5825/casper/src/main/scala/coop/rchain/casper/SignDeployment.scala -[144]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L432-L438 "Source code on GitHub" +[145]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/rnodeAPI.js#L430-L436 "Source code on GitHub" -[145]: https://git@github.com/:dckc/RChain-API/blob/e54b34e910f5e94dbc76bbe86f8e60e61754221d/src/rnodeAPI.js#L443-L450 "Source code on GitHub" +[146]: https://git@github.com/:dckc/RChain-API/blob/5878af2955efa512088affdac6411179701098b9/src/rnodeAPI.js#L441-L448 "Source code on GitHub" From cc3e213c5f9073bd71f45ebc5e925432801e0c66 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Mon, 15 Apr 2019 23:14:38 -0400 Subject: [PATCH 34/36] Remove outdated interfaces file from flow config. --- .flowconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/.flowconfig b/.flowconfig index 853c6fd..2f6d0a4 100644 --- a/.flowconfig +++ b/.flowconfig @@ -3,7 +3,6 @@ [include] [libs] -interfaces/ protobuf/interfaces/ [lints] From 8e4f1d6b0503d1d9b075e7d18a7dc43fbe8f1233 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Mon, 15 Apr 2019 23:14:56 -0400 Subject: [PATCH 35/36] getBlock -> showBlock --- test/testRNode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testRNode.js b/test/testRNode.js index 64b98a6..f3de8ea 100644 --- a/test/testRNode.js +++ b/test/testRNode.js @@ -99,7 +99,7 @@ function netTests({ grpc, clock, rng }) { }, 'get block by hash - error test': (test) => { const blockHash = 'thisshouldbreak'; - localNode().getBlock(blockHash).catch((err) => { + localNode().showBlock(blockHash).catch((err) => { test.deepEqual(err.message, 'Error: Failure to find block with hash thisshouldbreak'); test.end(); }) From 86b3cb074a7a0956319a17cb9e527fc8cd419e36 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Mon, 15 Apr 2019 23:15:17 -0400 Subject: [PATCH 36/36] Update package lock to 0.9.2-beta.4 --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 7a16216..e61320a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "rchain-api", - "version": "0.9.1-beta.2", + "version": "0.9.2-beta.4", "lockfileVersion": 1, "requires": true, "dependencies": {