Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function readDefinition(definition: AstDefinition): Uint8Array {
debug("definition %o", definition);
switch(CodecUtils.Definition.typeClass(definition))
{
case "rational":
let numericalValue: BN = CodecUtils.Definition.rationalValue(definition);
return CodecUtils.Conversion.toBytes(numericalValue, CodecUtils.EVM.WORD_SIZE);
//you may be wondering, why do we not just use definition.value here,
//like we do below? answer: because if this isn't a literal, that may not
//exist
case "stringliteral":
return CodecUtils.Conversion.toBytes(definition.hexValue);
default:
//unfortunately, other types of constants are just too complicated to
//handle right now. sorry.
debug("unsupported constant definition type");
throw new DecodingError(
{
kind: "UnsupportedConstantError",
definition
}
);
export function readDefinition(definition: AstDefinition): Uint8Array {
debug("definition %o", definition);
switch(CodecUtils.Definition.typeClass(definition))
{
case "rational":
let numericalValue: BN = CodecUtils.Definition.rationalValue(definition);
return CodecUtils.Conversion.toBytes(numericalValue, CodecUtils.EVM.WORD_SIZE);
//you may be wondering, why do we not just use definition.value here,
//like we do below? answer: because if this isn't a literal, that may not
//exist
case "stringliteral":
return CodecUtils.Conversion.toBytes(definition.hexValue);
default:
//unfortunately, other types of constants are just too complicated to
//handle right now. sorry.
debug("unsupported constant definition type");
throw new DecodingError(
{
kind: "UnsupportedConstantError",