blob: cec3fdec14c2a8432baa84effa4d6be5b0b719ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import { fns } from "./bindings.ts";
import { TransactionInfo, TransactionInfoPtr } from "./transaction_info.ts";
import { CString } from "./utils.ts";
export type TransactionHistoryPtr = Deno.PointerObject<"transactionHistory">;
export class TransactionHistory {
#ptr: TransactionHistoryPtr;
#count!: number;
constructor(ptr: TransactionHistoryPtr) {
this.#ptr = ptr;
}
static async new(ptr: TransactionHistoryPtr) {
const instance = new TransactionHistory(ptr);
instance.#count = await fns.TransactionHistory_count(ptr);
return instance;
}
get count(): number {
return this.#count;
}
async transaction(index: number): Promise<TransactionInfo> {
return TransactionInfo.new(
await fns.TransactionHistory_transaction(this.#ptr, index) as TransactionInfoPtr,
);
}
async refresh(): Promise<void> {
await fns.TransactionHistory_refresh(this.#ptr);
}
async setTxNote(transactionId: string, note: string): Promise<void> {
await fns.TransactionHistory_setTxNote(
this.#ptr,
CString(transactionId),
CString(note),
);
}
}
|