weiroll / weiroll.js

A high-level javascript transpiler for weiroll
https://weiroll.github.io/weiroll.js/
MIT License
53 stars 10 forks source link

Support fixed arrays and tuples #35

Closed PeterMPhillips closed 1 year ago

PeterMPhillips commented 2 years ago

Hi all. This PR adds fixes for https://github.com/weiroll/weiroll.js/pull/34 and https://github.com/weiroll/weiroll/issues/56. It checks whether the array/tuple is fixed size or dynamic. If it's fixed, the parameter's value is broken up into 32 byte chunks and set as individual values in the state array. I've added some tests to confirm the functionality.

As far as I can tell this only works for literal values, if I attempt to pass a return value into an array or tuple I get this error: Error: invalid BigNumber value... since we're passing a ReturnValue object into the contract's function instead of a BigNumber. I suspect this requires further changes to the Contract type provided by planner.ts. Although I'm unsure what exactly is needed to fix this. Should I make this a separate issue or would you like it resolve in this PR?