import { Base64String, PartialNillable } from '../utils/types'; import { ActionSchema, Attribute, Column, Extension, Index, Table, Procedure, ForeignProcedure, DataInfo, ProcedureReturn, NamedType } from './database'; import { PayloadType } from './enums'; import { AccountId } from './network'; /** * `AllPayloads` is the union of all payload types. */ export type AllPayloads = UnencodedActionPayload | TransferPayload | RawStatementPayload; export type UnencodedActionPayload = { dbid: string; action: string; arguments: T extends PayloadType.EXECUTE_ACTION ? EncodedValue[][] : EncodedValue[] | undefined; }; export interface EncodedValue { type: DataInfo; data: Uint8Array[]; } export interface EncodedParameterValue { type: DataInfo; data: Base64String[]; } export interface RawStatementPayload { statement: string; parameters: NamedValue[]; } interface NamedValue { name: string; value: EncodedValue; } /** * `TransferPayload` is the payload for transferring funds. * The generic allows the Builder to be typed to the correct payload type. * The `to` field is typed to either a Uint8Array or a base64 string depending on the encoding status. * The `amount` field is typed to a string because it is a decimal value. */ export interface TransferPayload { to: AccountId; amount: string; } /** DEPRECATED */ /** * `CompiledKuneiform` is the compiled version of the Kuneiform schema. This is the schema that is used to deploy a database. * The schema follows the Database Interface {@link Database}, with each field being optional. */ export interface CompiledKuneiform { owner: Uint8Array | string | null; name: string; tables: PartialNillable[] | null; actions: PartialNillable[] | null; extensions: PartialNillable[] | null; procedures: PartialNillable[] | null; foreign_calls: PartialNillable[] | null; } export type CompiledTable = Omit & { columns: ReadonlyArray; indexes: ReadonlyArray; }; type CompiledColumn = Omit & { attributes: ReadonlyArray; type: CompiledDataType; }; export type CompiledDataType = Omit & { name: string; metadata?: Array | Array | null; }; type CompiledAttribute = Omit & { type: string; }; type CompiledIndex = Omit & { type: string; }; export type CompiledProcedure = Omit & { parameters: ReadonlyArray; return_types: CompiledProcedureReturn | Array; }; type CompiledProcedureReturn = Omit & { fields: ReadonlyArray; }; type CompiledNamedType = Omit & { type: CompiledDataType; }; export type CompiledForeignProcedure = Omit & { parameters: ReadonlyArray; return_types: CompiledProcedureReturn | Array; }; export {};