near-runtime-ts icon indicating copy to clipboard operation
near-runtime-ts copied to clipboard

Make storage a namespace to prevent allocation

Open willemneal opened this issue 5 years ago • 2 comments

storage class had no internal state so allocation wasted space and gas.

Also added assemblyscript types reference in types file.

willemneal avatar Feb 05 '20 17:02 willemneal

@willemneal the allocation of one object doesn't really add any meaningful overhead.

I'd prefer we keep this as class as it's then easier to switch to a model where you can inject any Storage object (including fake one for tests), though it requires abstract methods support landing in AS.

vgrichina avatar Feb 05 '20 20:02 vgrichina

I think that the best way to mock the storage is at the API level. And while it is minimal overhead, it's still extra gas for every contract that uses this.

willemneal avatar Feb 05 '20 20:02 willemneal