import type { HexString } from '.'; export type BigintStr = `${bigint}`; export interface MethodInfo { name: string; def: OverloadDesc; } export interface OverloadDesc { desc: string; args: ArgDef[]; offchain: boolean; returns: string; hidden: boolean; examples: string[]; } export interface ArgDef { name: string; type: string; desc: string; } export type SStmt = SAssign | SIf | SChain | SCallStmt | SReturn | SSchedule | SForwardTo | SGasless | SGasless712 | SStorage | SMetadata | SNop; export interface SAssign { type: 'assign' | 'assign-storage'; name: string; value: SExpr; } export interface SIf { type: 'if'; condition: SExpr; ifTrue: SStmt; ifFalse: SStmt; } export interface SChain { type: 'chain'; statements: SStmt[]; } export interface SCallStmt { type: 'call'; fn: MethodInfo; args: SExpr[]; } export interface SReturn { type: 'return'; value: SExpr; } export interface SSchedule { type: 'schedule'; execute: SStmt; } export interface SForwardTo { type: 'forward'; toVault: SExpr; execute: SStmt; } export interface SStorage { type: 'storage'; name: string; defaultValue: SExpr; } export interface SMetadata { type: 'metadata'; value: string; } export interface SNop { type: 'nop'; } export interface SGasless { type: 'gasless'; maxGas?: SExpr; } export interface SGasless712 { type: 'gasless712'; } export type SExpr = SQty | SRatio | SData | SBool | SFloat | STicker | SString | SVar | SBytes32 | SArray | SBinaryExpr | SUnaryExpr | SCallExpr | SFunctionExpr; export interface SQty { type: 'qty'; value: BigintStr; dataType: SType; } export interface SRatio { type: 'ratio'; numerator: BigintStr; denominator: BigintStr; dataType: SType; } export interface SData { type: 'data'; value: HexString; } export interface SBytes32 { type: 'bytes32'; value: HexString; } export interface SArray { type: 'array'; items: SExpr[]; } export interface SBool { type: 'bool'; value: boolean; } export interface SFloat { type: 'float'; value: number; } export interface STicker { type: 'ticker'; value: HexString; } export interface SString { type: 'string'; value: string; } export interface SVar { type: 'var'; name: string; dataType: SType; storageDefault?: SExpr; } export interface SBinaryExpr { type: 'binary'; left: SExpr; op: BinaryOp; right: SExpr; dataType: SType; } export interface SUnaryExpr { type: 'unary'; expr: SExpr; op: UnaryOp; dataType: SType; } export interface SCallExpr { type: 'call'; fn: MethodInfo; args: SExpr[]; dataType: SType; } export interface SFunctionExpr { type: 'function'; args: TFunctionArg[]; body: SStmt; } export type UnaryOp = UnaryOpEnum | UnaryOpStr; export declare enum UnaryOpEnum { Not = "!" } export type UnaryOpStr = UnaryOpEnum[keyof UnaryOpEnum]; export type BinaryOp = BinaryOpEnum | BinaryOpStr; export declare enum BinaryOpEnum { Add = "+", Mul = "*", Div = "/", Sub = "-", And = "&&", Or = "||", LT = "<", LTE = "<=", GT = ">", GTE = ">=", EQ = "==", NEQ = "!=" } export type BinaryOpStr = BinaryOpEnum[keyof BinaryOpEnum]; export type SType = TVoid | TBytes32 | TUnit | TBool | TQtyOf | TRatio | TConst | TFunction | TArray; export interface TVoid { type: 'void'; } export interface TBytes32 { type: 'bytes32'; } export interface TUnit { type: 'unit'; } export interface TBool { type: 'bool'; } export interface TFunction { type: 'function'; args: TFunctionArg[]; } export interface TFunctionArg { name: string; type: SType; } export interface TQtyOf { type: 'qtyOf'; token: HexString; } export interface TRatio { type: 'ratio'; weights: [HexString, number][]; } export interface TConst { type: 'const'; constType: ConstType; } export interface TArray { type: 'array'; items: SType[]; } export type ConstType = CData | CTicker | CString | CFloat; export interface CData { type: 'data'; } export interface CTicker { type: 'ticker'; token: HexString; } export interface CString { type: 'string'; } export interface CFloat { type: 'float'; }