import { Expression } from '@incentum/jsonata'; import { Coin } from './coin'; import { HashKeyString, PublicKeyString, SHA256HashKeyFactory, OutputJson, CoinJson, OutputHashableJson, SignatureHashableJson, TemplateJson, ContractJson, ActionJson } from '@incentum/praxis-interfaces'; export declare const keyFactory: SHA256HashKeyFactory; export declare function chainFrom(hash: HashKeyString): string; export declare function hashJson(json: any): string; export declare function hashString(value: string): string; export declare function uniqueKey(): HashKeyString; export declare type Omit = Pick>; interface Jsonable { toJson(): T; } export declare abstract class Hashable implements Jsonable { abstract toJson(): T; toHashableJson(): any; toHash(): string; } export declare class Output extends Hashable implements OutputJson { contract: Contract; key: HashKeyString; ledger: PublicKeyString; data: any; tags: string[]; msgs: string[]; title: string; subtitle: string; description: string; coins: CoinJson[]; actionHash: HashKeyString; actionKey: HashKeyString; constructor(json: OutputJson); toJson(): OutputJson; } export declare function createOutputJson(key?: HashKeyString, ledger?: string, data?: any, coins?: CoinJson[], tags?: string[], msgs?: string[], title?: string, subtitle?: string, description?: string): OutputJson; export interface InputJson { key: HashKeyString; outputKey: HashKeyString; outputHash: HashKeyString; output: OutputHashableJson; actionHash: HashKeyString; actionKey: HashKeyString; other: any; } export declare type InputHashableJson = Omit; export declare function toInputHashableJson(json: InputHashableJson): InputHashableJson; export declare type InputSignableJson = Omit; export declare function toInputSignableJson(json: InputHashableJson): InputSignableJson; export declare function inputFromOutput(output: OutputJson, other?: any): InputJson; export declare function toInputJson(json: InputJson): Pick; export declare class Input extends Hashable implements InputJson { contract: Contract; output: Output; key: HashKeyString; readonly outputKey: string; readonly outputHash: string; readonly actionHash: string; readonly actionKey: string; other: any; constructor(contract: Contract, output: Output, other?: any); toJson(): InputJson; } export interface StateJson { state: any; coins: CoinJson[]; } export interface ReducerJson { type: string; code: string; language: string; } export interface ReducerInputJson { action: ActionJson; state: StateJson; } export interface ContractStartJson { other: any; action: ActionJson; initialState: any; } export interface MintJson { amount: string; symbol: string; other: any; tags: string[]; outputData: any; ledger: HashKeyString; decimals: number; title: string; subtitle: string; description: string; } export declare function mintToOutputJson(json: MintJson, mint: HashKeyString): OutputJson; export declare function mintToCoinJson(json: MintJson, mint: HashKeyString): CoinJson; export interface ReducerOutputJson { outputs: OutputJson[]; state: any; mint: MintJson[]; } export declare function toReducerOutputJson(json: any, oldstate: any): ReducerOutputJson; export declare type ReducerFunc = (x: any) => Promise; export declare abstract class Reducer implements ReducerJson { type: string; code: string; language: string; constructor(type: string, code: string, language: string); abstract reduce(input: ReducerInputJson, extensions?: any, func?: ReducerFunc): Promise; } export declare function toReducerJson(json: ReducerJson): ReducerJson; export declare class ReducerJsonata extends Reducer { expr: Expression; constructor(json: ReducerJson); toJson(): ReducerJson; reduce(input: ReducerInputJson, extensions?: any, func?: ReducerFunc): Promise; extend(input: ReducerInputJson, extensions?: any): any; } export declare class ReducerJavascript extends Reducer { constructor(json: ReducerJson); toJson(): ReducerJson; reduce(input: ReducerInputJson, extensions?: any, func?: ReducerFunc): Promise; extend(input: ReducerInputJson, extensions?: any): any; } interface Map { [key: string]: T; } export declare class ReducerFactory { static create(reducer: ReducerJson): Reducer; } export declare class Template extends Hashable implements TemplateJson { name: string; tags: string[]; other: string; ledger: string; versionMajor: number; versionMinor: number; versionPatch: number; description: string; reducers: ReducerJson[]; reducerMap: Map; constructor(json: TemplateJson); toJson(): TemplateJson; } export interface DispatchResultJson { outputs: OutputJson[]; state: StateJson; mint: MintJson[]; } export declare function toDispatchResultJson(json: ReducerOutputJson, coins: CoinJson[]): DispatchResultJson; export declare function hashContractKey(ledger: string, key: string): HashKeyString; export declare class Contract extends Hashable implements ContractJson { ledger: HashKeyString; template: Template; other: any; title: string; subtitle: string; description: string; key: HashKeyString; constructor(ledger: HashKeyString, template: Template, other: any, key: HashKeyString); readonly hash: string; readonly templateHash: string; dispatch(action: ActionJson, state: StateJson, extensions?: any, func?: ReducerFunc): Promise; mergeInputCoins(coins: Coin[], inputs: InputHashableJson[]): void; toJson(): ContractJson; findSignature(key: string, sigs: SignatureHashableJson[]): SignatureHashableJson; findInput(key: string, inputs: InputHashableJson[]): InputHashableJson; findCoin(coin: CoinJson, coins: Coin[]): Coin; calculateCoins(output: ReducerOutputJson, coins: Coin[]): CoinJson[]; } export {}; //# sourceMappingURL=contract.d.ts.map