///
import { Account as AccountSDK, AssetDef, LogicSig, SSCSchemaConfig, TxnEncodedObj } from "algosdk";
import * as z from 'zod';
import { Add, Addr, Arg, Byte, Bytec, Bytecblock, Div, Int, Len, Mul, Pragma, Sub } from "./interpreter/opcode-list";
import { TxnFields } from "./lib/constants";
import type { IStack } from "./lib/stack";
import type { ASADefSchema, ASADefsSchema } from "./types-input";
export declare type Operator = Len | Add | Sub | Mul | Div | Arg | Bytecblock | Bytec | Addr | Int | Byte | Pragma;
export declare type AppArgs = Array;
export declare type StackElem = bigint | Uint8Array;
export declare type TEALStack = IStack;
export interface Txn extends TxnEncodedObj {
txID: string;
}
export declare type TxField = keyof typeof TxnFields[2];
export declare enum TxnType {
unknown = "0",
pay = "1",
keyreg = "2",
acfg = "3",
axfer = "4",
afrz = "5",
appl = "6"
}
export declare enum GlobalField {
MinTxnFee = 0,
MinBalance = 1,
MaxTxnLife = 2,
ZeroAddress = 3,
GroupSize = 4,
LogicSigVersion = 5,
Round = 6,
LatestTimestamp = 7,
CurrentApplicationID = 8
}
export declare enum EncodingType {
BASE64 = 0,
BASE32 = 1,
HEX = 2,
UTF8 = 3
}
export declare type AccountAddress = string;
export interface AccountsMap {
[addr: string]: StoreAccountI;
}
export declare type RuntimeAccountMap = Map;
export interface State {
accounts: Map;
globalApps: Map;
assetDefs: Map;
}
export interface Context {
state: State;
tx: Txn;
gtxs: Txn[];
args: Uint8Array[];
getAccount: (address: string) => StoreAccountI;
getAssetAccount: (assetId: number) => StoreAccountI;
getApp: (appId: number, line?: number) => SSCAttributesM;
transferAlgo: (txnParam: AlgoTransferParam) => void;
deductFee: (sender: AccountAddress, index: number) => void;
transferAsset: (txnParam: AssetTransferParam) => void;
modifyAsset: (assetId: number, fields: AssetModFields) => void;
freezeAsset: (assetId: number, freezeTarget: string, freezeState: boolean) => void;
revokeAsset: (recipient: string, assetID: number, revocationTarget: string, amount: bigint) => void;
destroyAsset: (assetId: number) => void;
deleteApp: (appId: number) => void;
closeApp: (sender: AccountAddress, appId: number) => void;
processTransactions: (txnParams: ExecParams[]) => void;
}
export interface AssetHoldingM {
amount: bigint;
'asset-id': number;
creator: string;
'is-frozen': boolean;
}
export interface AppLocalStateM {
id: number;
'key-value': Map;
schema: SSCSchemaConfig;
}
export interface SSCAttributesM {
'approval-program': string;
'clear-state-program': string;
creator: string;
'global-state': Map;
'global-state-schema': SSCSchemaConfig;
'local-state-schema': SSCSchemaConfig;
}
export interface CreatedAppM {
id: number;
attributes: SSCAttributesM;
}
export interface StoreAccountI {
address: string;
assets: Map;
amount: bigint;
minBalance: number;
appsLocalState: Map;
appsTotalSchema: SSCSchemaConfig;
createdApps: Map;
createdAssets: Map;
account: AccountSDK;
balance: () => bigint;
getApp: (appId: number) => SSCAttributesM | undefined;
getAppFromLocal: (appId: number) => AppLocalStateM | undefined;
addApp: (appId: number, params: SSCDeploymentFlags, approvalProgram: string, clearProgram: string) => CreatedAppM;
getAssetDef: (assetId: number) => AssetDef | undefined;
getAssetHolding: (assetId: number) => AssetHoldingM | undefined;
addAsset: (assetId: number, name: string, asadef: ASADef) => AssetDef;
modifyAsset: (assetId: number, fields: AssetModFields) => void;
setFreezeState: (assetId: number, state: boolean) => void;
destroyAsset: (assetId: number) => void;
optInToApp: (appId: number, appParams: SSCAttributesM) => void;
optInToASA: (assetIndex: number, assetHolding: AssetHoldingM) => void;
deleteApp: (appId: number) => void;
closeApp: (appId: number) => void;
getLocalState: (appId: number, key: Uint8Array | string) => StackElem | undefined;
setLocalState: (appId: number, key: Uint8Array | string, value: StackElem, line?: number) => AppLocalStateM;
getGlobalState: (appId: number, key: Uint8Array | string) => StackElem | undefined;
setGlobalState: (appId: number, key: Uint8Array | string, value: StackElem, line?: number) => void;
}
export declare enum TxnOnComplete {
NoOp = "0",
OptIn = "1",
CloseOut = "2",
ClearState = "3",
UpdateApplication = "4",
DeleteApplication = "5"
}
export declare enum ExecutionMode {
STATELESS = 0,
STATEFUL = 1
}
export interface TxParams {
/**
* feePerByte or totalFee is used to set the appropriate transaction fee parameter.
* If both are set then totalFee takes precedence.
* NOTE: SDK expects`fee: number` and boolean `flatFee`. But the API expects only one
* on parameter: `fee`. Here, we define feePerByte and totalFee - both as numberic
* parameters. We think that this is more explicit. */
feePerByte?: number;
totalFee?: number;
firstValid?: number;
validRounds?: number;
lease?: Uint8Array;
note?: string;
noteb64?: string;
closeRemainderTo?: AccountAddress;
rekeyTo?: AccountAddress;
}
/**
* Stateful Smart contract flags for specifying sender and schema */
export interface SSCDeploymentFlags extends SSCOptionalFlags {
sender: AccountSDK;
localInts: number;
localBytes: number;
globalInts: number;
globalBytes: number;
}
/**
* Stateful smart contract transaction optional parameters (accounts, args..). */
export interface SSCOptionalFlags {
appArgs?: Array;
accounts?: string[];
foreignApps?: number[];
foreignAssets?: number[];
note?: Uint8Array;
lease?: Uint8Array;
}
export declare type ExecParams = AlgoTransferParam | AssetTransferParam | SSCCallsParam | ModifyAssetParam | FreezeAssetParam | RevokeAssetParam | DestroyAssetParam;
export declare enum SignType {
SecretKey = 0,
LogicSignature = 1
}
export declare enum TransactionType {
TransferAlgo = 0,
TransferAsset = 1,
ModifyAsset = 2,
FreezeAsset = 3,
RevokeAsset = 4,
DestroyAsset = 5,
CallNoOpSSC = 6,
ClearSSC = 7,
CloseSSC = 8,
DeleteSSC = 9
}
export interface Sign {
sign: SignType;
lsig?: LogicSig;
}
export interface ModifyAssetParam extends Sign {
type: TransactionType.ModifyAsset;
fromAccount: AccountSDK;
assetID: number;
fields: AssetModFields;
payFlags: TxParams;
}
export interface FreezeAssetParam extends Sign {
type: TransactionType.FreezeAsset;
fromAccount: AccountSDK;
assetID: number;
freezeTarget: AccountAddress;
freezeState: boolean;
payFlags: TxParams;
}
export interface RevokeAssetParam extends Sign {
type: TransactionType.RevokeAsset;
fromAccount: AccountSDK;
recipient: AccountAddress;
assetID: number;
revocationTarget: AccountAddress;
amount: number | bigint;
payFlags: TxParams;
}
export interface DestroyAssetParam extends Sign {
type: TransactionType.DestroyAsset;
fromAccount: AccountSDK;
assetID: number;
payFlags: TxParams;
}
export interface AlgoTransferParam extends Sign {
type: TransactionType.TransferAlgo;
fromAccount: AccountSDK;
toAccountAddr: AccountAddress;
amountMicroAlgos: number | bigint;
payFlags: TxParams;
}
export interface AssetTransferParam extends Sign {
type: TransactionType.TransferAsset;
fromAccount: AccountSDK;
toAccountAddr: AccountAddress;
amount: number | bigint;
assetID: number;
payFlags: TxParams;
}
export interface SSCCallsParam extends SSCOptionalFlags, Sign {
type: TransactionType.CallNoOpSSC | TransactionType.ClearSSC | TransactionType.CloseSSC | TransactionType.DeleteSSC;
fromAccount: AccountSDK;
appId: number;
payFlags: TxParams;
}
export interface AnyMap {
[key: string]: any;
}
export interface Account extends AccountSDK {
name: string;
}
export interface ASADeploymentFlags extends TxParams {
creator: Account;
}
export declare type AccountMap = Map;
export declare type ASADef = z.infer;
export declare type ASADefs = z.infer;
export interface AssetModFields {
manager: string;
reserve: string;
freeze: string;
clawback: string;
}