-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhedera.d.ts
251 lines (218 loc) · 7.45 KB
/
hedera.d.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
declare const _default: {
Hedera: Hedera,
Duration: Duration,
Query: Query,
CryptoGetAccountBalance: CryptoGetAccountBalance,
CryptoGetAccountRecords: CryptoGetAccountRecords,
CryptoTransfer: CryptoTransfer,
CryptoGetInfo: CryptoGetInfo,
Transaction: Transaction,
TransactionID: TransactionID,
TransactionGetRecord: TransactionGetRecord,
TransactionGetFastRecord: TransactionGetFastRecord,
}
export default _default;
export declare namespace util {
function fromPrivateKeyDer(privateKeyDer: string): string;
function fromPublicKeyDer(publicKeyDer: string): string;
function toHbar(tinyBar: Long | string): string;
function toTinyBar(hBar: Long | string): string;
function getOperatorId(transaction: {}): AccountID;
function getTransactionId(transaction: {}): TransactionID;
function getTransfers(transaction: {}): { accountId: string, amount: string }[];
function getRecordTransfers(record: {}): { accountId: string, amount: string }[];
function deserializeTx(hex: string): Transaction
function serializeAccountID(accountId: AccountID): string;
function serializeTxID(transactionID: TransactionID): string;
}
export declare interface Duration {
seconds: number | Long,
nanos?: string | Long,
}
export declare namespace Duration {
function now(): Duration;
function seconds(s: number): Duration;
}
export declare class Hedera {
nodeUrl: string;
nodeAccountId: AccountID;
operatorId: AccountID;
cryptoService: any;
constructor(
nodeUrl: string | {
nodeUrl: string,
nodeAccountId: string,
operatorId: string,
derPublicKey?: string,
derPrivateKey?: string,
operatorPublicKey?: string,
operatorPrivateKey?: string,
},
nodeAccountId: string,
operatorId: string,
operatorPublicKey: string,
operatorPrivateKey: string,
)
static broadcast(requestName: string, nodeUrl: string, tx: {}): Promise<string | {}>
createAccount(newAccountPublicKey: string, initialBalance: string): Promise<string>
cryptoTransfer(destinations: { accountId: string, amount: string }[], memo: string): Promise<string>
cryptoGetBalance(queryAccountId: string): Promise<{ header: Query.Header, accountID: AccountID, balance: string }>
getAccountRecords(queryAccountId: string): Promise<{ header: Query.Header, accountID: AccountID, records: Query.Record[] }>
getAccountInfo(queryAccountId: string): Promise<{}>
getTransactionReceipts(transactionId: TransactionID): Promise<{ header: Query.Header, receipt: Query.Receipt }>
getFastTransactionRecord(transactionId: TransactionID): Promise<{ header: Query.Header, transactionRecord: Query.Record }>
getTxRecordByTxID(transactionId: TransactionID): Promise<{ header: Query.Header, transactionRecord: Query.Record }>
}
export declare interface AccountID {
shardNum?: number;
realmNum?: number;
accountNum?: number;
}
export declare class AccountID {
constructor(obj: AccountID | string | { shardNum: string | number, realmNum: string | number, accountNum: string | number });
fromString(str: string): AccountID;
toObject(): { accountNum: number };
toString(): string;
getShardID(): { shardNum: number };
getRealmID(): { RealmNum: number };
}
export declare interface TransactionID {
transactionValidStart: Duration
accountID: AccountID,
}
export declare interface TransferTransaction {
transactionID: TransactionID,
nodeAccountID: AccountID,
transactionFee: number,
transactionValidDuration: Duration,
memo: string,
cryptoTransfer: { transferList: TransferList }
}
export declare interface TransferList {
accountAmounts: { accountID: string, amount: string }[]
}
export declare interface Query {
}
export declare namespace Query {
export enum RESPONSE_TYPE {
ANSWER_ONLY = 0, // Response returns answer
ANSWER_STATE_PROOF = 1, // Response returns both answer and state proof
COST_ANSWER = 2, // Response returns the cost of answer
COST_ANSWER_STATE_PROOF = 3,
}
export interface QueryResponse {
header: {
nodeTransactionPrecheckCode: string,
cost: string,
}
}
export interface Receipt {
status: string,
accountID?: string,
fileID?: string,
contractID?: string,
}
export interface Record {
transactionHash: Buffer,
consensusTimestamp: { seconds: number, nanos: string },
transactionID: TransactionID,
memo?: string,
transactionFee: string,
transferList?: TransferList,
}
export interface Header {
nodeTransactionPrecheckCode: string,
cost: string,
}
}
export declare class Query {
constructor(options: { nodeAccountId: AccountID | string, operatorId: AccountID | string });
serialize(): Buffer;
static deserialize(hex: string): {};
signTransaction(privateKey: string): Query;
toObject(): {};
}
export declare interface Transaction {
body: {},
sigMap: {},
}
export declare class Transaction {
constructor(options: { operatorId: AccountID | string, nodeAccountId: AccountID | string});
get signatureHash(): Buffer;
addSignature(signature: string | Buffer, publicKey: string): Transaction;
serialize(): Buffer;
static deserialize(hex: string): Transaction;
static serializeBody(tx: any): Buffer;
toObject(): Transaction;
getTransactionId(): TransactionID;
signTransaction(privateKey: string): Transaction;
}
export declare class CryptoGetAccountBalance extends Query {
constructor(options: {
nodeAccountId: AccountID | string,
operatorId: AccountID | string,
queryAccountId: string | AccountID,
responseType?: Query.RESPONSE_TYPE,
});
}
export declare class CryptoGetAccountRecords extends Query {
constructor(options: {
nodeAccountId: AccountID | string,
operatorId: AccountID | string,
queryAccountId: string | AccountID,
responseType?: Query.RESPONSE_TYPE,
});
}
export declare class CryptoGetInfo extends Query {
constructor(options: {
nodeAccountId: AccountID | string,
operatorId: AccountID | string,
queryAccountId: string | AccountID,
responseType?: Query.RESPONSE_TYPE,
});
}
export declare class TransactionGetReceipt extends Query {
constructor(options: {
nodeAccountId: AccountID | string,
operatorId: AccountID | string,
transactionId: TransactionID,
responseType?: Query.RESPONSE_TYPE,
});
}
export declare class TransactionGetRecord extends Query {
constructor(options: {
nodeAccountId: AccountID | string,
operatorId: AccountID | string,
transactionId: TransactionID,
responseType?: Query.RESPONSE_TYPE,
});
}
export declare class TransactionGetFastRecord extends Query {
constructor(options: {
nodeAccountId: AccountID | string,
operatorId: AccountID | string,
transactionId: TransactionID,
responseType?: Query.RESPONSE_TYPE,
});
}
export declare class CryptoTransfer extends Transaction {
constructor(options: {
nodeAccountId: AccountID | string,
operatorId: AccountID | string,
destinations: {
accountId: AccountID | string,
amount: string | Long,
}[],
transactionValidStart?: Duration,
transactionFee?: string,
transactionValidDuration?: Duration,
memo?: string,
});
}
export declare class TransactionID {
constructor(obj: { accountID: AccountID | string, transactionValidStart: { seconds: string | number | Long } });
toObject(): { accountID: string, transactionValidStart: Duration };
static parseString(transactionIdStr: string): TransactionID
static serialize(transactionId: TransactionID): Promise<string>;
static deserialize(hex: string): Promise<TransactionID>;
}