o1-labs/o1js

Collection of DEVEX improvements

Trivo25 opened this issue · 3 comments

collection of things that come to my mind while talking to people at the hackathon

  • conditional set of on-chain state
  • improved and easier to use branching and switch logic (it gets messy very easily)

nice feedback! setIf() is straight-forward to add at least.

maybe some dynamic array methods for the branching?

We dont type check state fields, or at least we dont throw a helpful error message

eg

 @state(Field) playerA = State<PublicKey>();

should be

 @state(PublicKey) playerA = State<PublicKey>();

but results in a weird error

TypeError: x.toBigInt is not a function
    at Function.toValue (file:///Users/trivo/Downloads/zk-dice-roll/contracts/node_modules/o1js/dist/node/lib/provable/field.js:882:18)
    at file:///Users/trivo/Downloads/zk-dice-roll/contracts/node_modules/o1js/dist/node/bindings/lib/from-layout.js:365:48
    at Object.map (file:///Users/trivo/Downloads/zk-dice-roll/contracts/node_modules/o1js/dist/node/bindings/lib/from-layout.js:423:20)
    at genericLayoutFold (file:///Users/trivo/Downloads/zk-dice-roll/contracts/node_modules/o1js/dist/node/bindings/lib/from-layout.js:418:17)
    at genericLayoutFold (file:///Users/trivo/Downloads/zk-dice-roll/contracts/node_modules/o1js/dist/node/bindings/lib/from-layout.js:395:28)
    at file:///Users/trivo/Downloads/zk-dice-roll/contracts/node_modules/o1js/dist/node/bindings/lib/from-layout.js:384:35
    at Array.map (<anonymous>)
    ```

We could fix that with types on the decorator!