Expression is a data-model structure that allows to build simple or complex expressions that are evaluated to something at runtime in Iroha.
TODO: show expression examples
Currently Expression implementation in TypeScript is completely dynamic and cannot guarantee that built Expression will not fail to evaluate at runtime. However, I think that evaluation mechanism is pretty determined, and Expression can be described as type-strong discriminated unions, thus, it is possible to develop a type that will compute the resulting type of an expression based on its shape.
I think this feature requires, first of all, improvement of @scale-codec/definition-compiler so it will generate enum factories that builds a concrete enum variant instead of telling TypeScript that build value is any of variants:
This change will allow to give TypeScript precise information about the built enums.
Secondly, iroha-javascript should provide:
export type EvaluateExpression<E extends Expression> = ... // evaluation prediction
Finally, there should be convenient builders that leverate this util type and will allow to build instructions with checked expressions, which should give a huve DX improvement.
Expression
is a data-model structure that allows to build simple or complex expressions that are evaluated to something at runtime in Iroha.TODO: show expression examples
Currently
Expression
implementation in TypeScript is completely dynamic and cannot guarantee that builtExpression
will not fail to evaluate at runtime. However, I think that evaluation mechanism is pretty determined, andExpression
can be described as type-strong discriminated unions, thus, it is possible to develop a type that will compute the resulting type of an expression based on its shape.I think this feature requires, first of all, improvement of
@scale-codec/definition-compiler
so it will generate enum factories that builds a concrete enum variant instead of telling TypeScript that build value is any of variants:This change will allow to give TypeScript precise information about the built enums.
Secondly,
iroha-javascript
should provide:Finally, there should be convenient builders that leverate this util type and will allow to build instructions with checked expressions, which should give a huve DX improvement.
Related issue in Java SDK: