rchain-community / rchain-api

An API for rchain dapps to communicate with the blockchain
Other
22 stars 12 forks source link

URIs not expressible in RHOCore #50

Closed JoshOrndorff closed 5 years ago

JoshOrndorff commented 5 years ago

Some relevant context is in #17 An example of the problem this creates is

const rholangCode = rho`
new lookup(\`rho:registry:lookup\`), registerCh in {
  lookup!(\`URI\`, *registerCh)|

  for (registerForStatus <- registerCh){
    registerForStatus!(${req.params.name}, ${req.query.sig}, ${req.query.pubKey}, "bogusReturn")
  }
}
`.replace("URI", uri) //TODO Do this better

This is really more of a problem with the design of rhocore. I guess our options are.

  1. Figure out a way to express uris in RHOCore and implement it
  2. Figure out a work around so the hack is in the API rather than each dApp
  3. Do nothing and let dApps write code like the example above.
dckc commented 5 years ago

I'm starting to lean toward expressing URIs in RHOCore using some constructor. There's a standard URL constructor that seems to work:

new URL('rho:id:wdwc36f4ixa6xacck3ddepmgueum7zueuczgthcqp6771kdu8jogm8')

Likewise byte arrays as Uint8Array.

And GPrivate from RhoTypes.

dckc commented 5 years ago

Supporting GPrivate in toRholang would be tricky... one way to do it would be to assume the rholang code to create is in a scope where the GPrivate is bound to a variable. We'd need an additional environment parameter that maps GPrivate values to variable names.

dckc commented 5 years ago

See:

I could / should separate these from work on proxying and payment, but I haven't done so yet.

dckc commented 5 years ago

The environment stuff for GPrivate turned out to be not needed.