fabcotech / rchain-multisig

MIT License
2 stars 1 forks source link

please use idomatic rholang: contract objName(@"methodName", args..., ret) #5

Open dckc opened 2 years ago

dckc commented 2 years ago

Compare:

  for (@("PUBLIC_READ", return) <= entryCh) {

vs. the established pattern from the core dev team:

  contract helloWorld(@name) = {

-- https://github.com/rchain/rchain/blob/dev/rholang/examples/tut-hello.rho

    contract MultiSigRevVault(@"makeSealerUnsealer", ret) = {

-- https://github.com/rchain/rchain/blob/dev/casper/src/main/resources/MultiSigRevVault.rho

Why not use contract? Why not use scala/JavaScript/Java/Smalltalk style CamelCase for naming?

fabcotech commented 2 years ago

This pattern allows us to listen on specific actions, on the same channel (that is exposed to registry).

 for (@("ACTION_A", return) <= entryCh) {...}
 for (@("ACTION_B", parameter1, return) <= entryCh) {...}
 for (@("ACTION_C", parameter1, parameter2, return) <= entryCh) {...}

Please explain how you would do it with the following pattern/syntax:

contract helloWorld(@name) = {...}
dckc commented 2 years ago

I already gave such an example, no?

    contract MultiSigRevVault(@"makeSealerUnsealer", ret) = {
fabcotech commented 2 years ago

Yes but then, let's say you have 3 contract like this one, how do you expose the 3 to the registry (eg: external rholang executions).

In our case it is as simple as this :

 for (@("ACTION_A", return) <= entryCh) {...}
 for (@("ACTION_B", parameter1, return) <= entryCh) {...}
 for (@("ACTION_C", parameter1, parameter2, return) <= entryCh) {...}
 insertArbitrary!(bundle+{*entryCh}, *entryUriCh) |

To call it from external rholang execution you just do that :

  registryLookup!(`rho:id:abcdef`, *entryCh) |
  for (entry <- entryCh) { entry!(("ACTION_A", *returnCh)) }
dckc commented 2 years ago

Yes but then, let's say you have 3 contract like this one, how do you expose the 3 to the registry (eg: external rholang executions).

Again, I already gave an example of how to do this. The one MultiSigRevVault name is exported to the registry, and the several contract processes match on the method name in the 1st arg.

    contract MultiSigRevVault(@"makeSealerUnsealer", ret) = {
//...

    } |

    contract MultiSigRevVault(@"deployerAuthKey", deployerId, ret) = {
// ...
}
fabcotech commented 2 years ago

ok Now I get it thanks !

dckc commented 2 years ago

Cool! I'd like to keep this open as a request to migrate to this idiomatic style.