work in progress by Dan Connolly
In the Agoric architecture, a JavaScript dialect is used to write secure smart contracts using object capabilities. In the RChain architecture, Rholang is used likewise.
Section 3. INTERPRETING CAPABILITIES of Policies as Types sketches compiling JavaScript to RHO-calculus.
js2rho
is an exploration into the feasibility of taking smart contracts
written in JavaScript and compiling them to Rholang for interoperability
with RChain.
note: tested with nodejs 13.12.0
git clone https://github.com/rchain-community/js2rho.git
cd js2rho
npm install
npm test
js2rho.js is based on estree / esprima.
To install ~350K of essential dependencies without ~50M of typescript tooling, use:
npm install --only=prod
For the Jessie dialect, we have a parser and abstract syntax tree (AST) as a scala sum-of-products type.
sbt console
scala> tinyses.TestSimpleParser.main(Array())
/home/connolly/projects/tinyses2rho
trying statement at CharSequenceReader('[', ...)
trying block at CharSequenceReader('[', ...)
block --> [1.1] failure: '{' expected but '[' found
...
We're evaluating escalima for await syntax.
Another RChain interoperability approach is to use waterken / Q style message passing between TinySES and RChain nodes.
Scala should provide a good platform to explore the hypothesis that Jessie can be easily statically typed.
A "fuzzer" to generate arbitrary Jessie programs should be straightforward using property testing libraries.
See also bounty issue 427.