41 lines
994 B
TypeScript
41 lines
994 B
TypeScript
|
|
import { trace } from "loglevel"
|
||
|
|
import { TricksterAccount, TricksterInventory } from "../trickster"
|
||
|
|
import { v4 as uuidv4 } from 'uuid';
|
||
|
|
|
||
|
|
|
||
|
|
export interface LTOApi {
|
||
|
|
GetInventory:(path:string)=>Promise<TricksterInventory>
|
||
|
|
GetAccounts:() =>Promise<Array<TricksterAccount>>
|
||
|
|
GetLoggedin: ()=>Promise<boolean>
|
||
|
|
}
|
||
|
|
|
||
|
|
export const TxnStates = ["PENDING","INFLIGHT","WAITING","ERROR","SUCCESS"] as const
|
||
|
|
export type TxnState = typeof TxnStates[number]
|
||
|
|
|
||
|
|
export interface TxnDetails {
|
||
|
|
item_uid: string | "galders"
|
||
|
|
count:number
|
||
|
|
origin:string
|
||
|
|
target:string
|
||
|
|
}
|
||
|
|
|
||
|
|
export abstract class BankReceipt {
|
||
|
|
action_id: string
|
||
|
|
details:TxnDetails
|
||
|
|
created:Date
|
||
|
|
|
||
|
|
constructor(details:TxnDetails) {
|
||
|
|
this.details = details
|
||
|
|
this.created = new Date()
|
||
|
|
this.action_id = uuidv4();
|
||
|
|
}
|
||
|
|
abstract state():Promise<TxnState>
|
||
|
|
abstract status():string
|
||
|
|
abstract progress():[number, number]
|
||
|
|
abstract error():string
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface BankApi {
|
||
|
|
SendTxn: (txn:TxnDetails) => Promise<BankReceipt>
|
||
|
|
}
|