-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclient.contract.ts
106 lines (87 loc) · 2.74 KB
/
client.contract.ts
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { BigNumber } from "@ardenthq/sdk-helpers";
import { DateTime } from "@ardenthq/sdk-intl";
import { ConfirmedTransactionDataCollection, WalletDataCollection } from "./collections.js";
import { ConfirmedTransactionData } from "./confirmed-transaction.dto.contract.js";
import { KeyValuePair, SignedTransactionData, WalletData } from "./contracts.js";
import { TransactionType } from "./networks.js";
export type ClientPaginatorCursor = string | number | undefined;
export interface MetaPagination {
prev: ClientPaginatorCursor;
self: ClientPaginatorCursor;
next: ClientPaginatorCursor;
last: ClientPaginatorCursor;
}
export interface BroadcastResponse {
accepted: string[];
rejected: string[];
errors: Record<string, string>;
}
export interface WalletIdentifier {
type: "address" | "publicKey" | "extendedPublicKey" | "username";
value: string;
method?: "bip39" | "bip44" | "bip49" | "bip84";
networkId?: string;
}
export interface ClientService {
transaction(id: string): Promise<ConfirmedTransactionData>;
transactions(query: ClientTransactionsInput): Promise<ConfirmedTransactionDataCollection>;
wallet(id: WalletIdentifier): Promise<WalletData>;
wallets(query: ClientWalletsInput): Promise<WalletDataCollection>;
delegate(id: string): Promise<WalletData>;
delegates(query?: ClientWalletsInput): Promise<WalletDataCollection>;
votes(id: string): Promise<VoteReport>;
// TODO: return struct like VoteReport
voters(id: string, query?: KeyValuePair): Promise<WalletDataCollection>;
unlockableBalances(id: string): Promise<UnlockTokenResponse>;
broadcast(transactions: SignedTransactionData[]): Promise<BroadcastResponse>;
}
export interface ClientPagination {
cursor?: string | number;
limit?: number;
orderBy?: string;
}
export interface RangeCriteria {
from?: number;
to?: number;
}
export interface ClientTransactionsInput extends ClientPagination {
// Addresses
identifiers?: WalletIdentifier[];
senderId?: string;
recipientId?: string;
// Public Keys
senderPublicKey?: string;
recipientPublicKey?: string;
// Meta
asset?: Record<string, any>;
memo?: string;
timestamp?: RangeCriteria;
// Transaction Types
type?: TransactionType;
types?: TransactionType[];
}
export interface ClientWalletsInput extends ClientPagination {
identifiers?: WalletIdentifier[];
}
// TODO: move
export interface VoteReport {
used: number;
available: number;
votes: { id: string; amount: number }[];
}
export interface TransactionDetailInput {
walletId?: string;
}
// Only supported by Lisk at the moment
export interface UnlockableBalance {
address: string;
amount: BigNumber;
height: string;
timestamp: DateTime;
isReady: boolean;
}
export interface UnlockTokenResponse {
objects: UnlockableBalance[];
current: BigNumber;
pending: BigNumber;
}