quantum-coin-js-sdk 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -26
- package/example/example-misc.js +57 -0
- package/example/example-send.js +70 -0
- package/example/example.js +1 -1
- package/example/package-lock.json +31 -23
- package/example/package.json +1 -1
- package/index.d.ts +718 -0
- package/index.js +76 -15
- package/package.json +3 -2
- package/wasm_exec.d.ts +0 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,718 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The initialize function has to be called before attempting to invoke any other function. This function should be called only once.
|
|
3
|
+
*
|
|
4
|
+
* @async
|
|
5
|
+
* @function initialize
|
|
6
|
+
* @param {Config} clientConfig - A configuration represented by the Config class
|
|
7
|
+
* @return {Promise<boolean>} Returns a promise of type boolean; true if the initialization succeeded, else false.
|
|
8
|
+
*/
|
|
9
|
+
export function initialize(clientConfig: Config): Promise<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* The serializeWallet function serializes a Wallet object to a JSON string. You should encrypt the string before saving it to disk or a database.
|
|
12
|
+
*
|
|
13
|
+
* @function serializeWallet
|
|
14
|
+
* @param {Wallet} wallet - A Wallet object representing the wallet to serialize.
|
|
15
|
+
* @return {string} Returns the Wallet in JSON string format. If the wallet is invalid, null is returned.
|
|
16
|
+
*/
|
|
17
|
+
export function serializeWallet(wallet: Wallet): string;
|
|
18
|
+
/**
|
|
19
|
+
* The deserializeWallet function creates a Wallet object from a JSON string.
|
|
20
|
+
*
|
|
21
|
+
* @function deserializeWallet
|
|
22
|
+
* @param {string} walletJson - A Wallet object representing the wallet to deserialize.
|
|
23
|
+
* @return {Wallet} Returns the Wallet corresponding to the walletJson. If the wallet is invalid, null is returned.
|
|
24
|
+
*/
|
|
25
|
+
export function deserializeWallet(walletJson: string): Wallet;
|
|
26
|
+
/**
|
|
27
|
+
* The serializeEncryptedWallet function encrypts and serializes a Wallet object to a JSON string readable by the Desktop/Mobile/Web/CLI wallet applications. You can save this string to a file and open the file in one of these wallet applications. You may also open this string using the deserializeEncryptedWallet function. If you loose the passphrase, you will be unable to open the wallet. This function can take upto a minute or so to execute.
|
|
28
|
+
*
|
|
29
|
+
* @function serializeEncryptedWallet
|
|
30
|
+
* @param {Wallet} wallet - A Wallet object representing the wallet to serialize.
|
|
31
|
+
* @param {string} passphrase - A passphrase used to encrypt the wallet. It should atleast be 12 characters long.
|
|
32
|
+
* @return {string} Returns the Wallet in JSON string format. If the wallet is invalid, null is returned.
|
|
33
|
+
*/
|
|
34
|
+
export function serializeEncryptedWallet(wallet: Wallet, passphrase: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* The deserializeEncryptedWallet function opens a wallet backed-up using an application such as the Desktop/Mobile/CLI/Web wallet. This function can take upto a minute or so to execute. You should open wallets only from trusted sources.
|
|
37
|
+
*
|
|
38
|
+
* @function deserializeEncryptedWallet
|
|
39
|
+
* @param {string} walletJsonString - The json string from a wallet file.
|
|
40
|
+
* @param {string} passphrase - The passphrase used to encrypt the wallet.
|
|
41
|
+
* @return {Wallet} Returns a Wallet object. Returns null if opening the wallet fails.
|
|
42
|
+
*/
|
|
43
|
+
export function deserializeEncryptedWallet(walletJsonString: string, passphrase: string): Wallet;
|
|
44
|
+
/**
|
|
45
|
+
* The verifyWallet function verifies whether a Wallet is valid or not. To mitigate spoofing and other attachs, it is highly recommended to verify a wallet, especially if it is from an untrusted source.
|
|
46
|
+
*
|
|
47
|
+
* @function verifyWallet
|
|
48
|
+
* @param {Wallet} wallet - A Wallet object representing the wallet to verify.
|
|
49
|
+
* @return {boolean} Returns true if the Wallet verification succeeded, else returns false.
|
|
50
|
+
*/
|
|
51
|
+
export function verifyWallet(wallet: Wallet): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The newWallet function creates a new Wallet.
|
|
54
|
+
*
|
|
55
|
+
* @function newWallet
|
|
56
|
+
* @return {Wallet} Returns a Wallet object.
|
|
57
|
+
*/
|
|
58
|
+
export function newWallet(): Wallet;
|
|
59
|
+
/**
|
|
60
|
+
* The sendCoins function posts a send-coin transaction to the blockchain.
|
|
61
|
+
* Since the gas fee for sending coins is fixed at 1000 coins, there is no option to set the gas fee explicitly.
|
|
62
|
+
* It may take many seconds after submitting a transaction before the transaction is returned by the getTransactionDetails function.
|
|
63
|
+
* Transactions are usually committed in less than 30 seconds.
|
|
64
|
+
*
|
|
65
|
+
* @async
|
|
66
|
+
* @function sendCoins
|
|
67
|
+
* @param {Wallet} wallet - A Wallet object from which the transaction has to be sent. The address corresponding to the Wallet should have enough coins to cover gas fees as well. A minimum of 1000 coins (1000000000000000000000 wei) are required for gas fees.
|
|
68
|
+
* @param {string} toAddress - The address to which the coins should be sent.
|
|
69
|
+
* @param {string} coins - The string representing the number of coins (in ether) to send. To convert between ethers and wei, see https://docs.ethers.org/v4/api-utils.html#ether-strings-and-wei
|
|
70
|
+
* @param {number} nonce - The nonce of the account retrieved by invoking the getAccountDetails function. You have to carefully manage state of the nonce to avoid sending the coins multiple times, such as when retrying sendCoins after a network error.
|
|
71
|
+
* @return {Promise<SendResult>} Returns a promise of type SendResult.
|
|
72
|
+
*/
|
|
73
|
+
export function sendCoins(wallet: Wallet, toAddress: string, coins: string, nonce: number): Promise<SendResult>;
|
|
74
|
+
/**
|
|
75
|
+
* The getAccountDetails function returns details of an account corresponding to the address.
|
|
76
|
+
*
|
|
77
|
+
* @async
|
|
78
|
+
* @function getAccountDetails
|
|
79
|
+
* @param {string} address - The address of the account of which the details have to be retrieved.
|
|
80
|
+
* @return {Promise<AccountDetailsResult>} Returns a promise of type AccountDetailsResult.
|
|
81
|
+
*/
|
|
82
|
+
export function getAccountDetails(address: string): Promise<AccountDetailsResult>;
|
|
83
|
+
/**
|
|
84
|
+
* The getTransactionDetails function returns details of a transaction posted to the blockchain.
|
|
85
|
+
* Transactions may take a while to get registered in the blockchain. After a transaction is submitted, it may take a while before it is available for reading.
|
|
86
|
+
* Some transactions that have lower balance than the minimum required for gas fees may be discarded.
|
|
87
|
+
* In these cases, the transactions may not be returned when invoking the getTransactionDetails function.
|
|
88
|
+
* You should consider the transaction as succeeded only if the status field of the transactionReceipt object is 0x1 (success).
|
|
89
|
+
* The transactionReceipt field can be null unless the transaction is registered with the blockchain.
|
|
90
|
+
* @async
|
|
91
|
+
* @function getTransactionDetails
|
|
92
|
+
* @param {string} txnHash - The hash of the transaction to retrieve.
|
|
93
|
+
* @return {Promise<TransactionDetailsResult>} Returns a promise of type type TransactionDetailsResult.
|
|
94
|
+
*/
|
|
95
|
+
export function getTransactionDetails(txnHash: string): Promise<TransactionDetailsResult>;
|
|
96
|
+
/**
|
|
97
|
+
* The isAddressValid function validates whether an address is valid or not. An address is of length 66 characters including 0x.
|
|
98
|
+
*
|
|
99
|
+
* @function isAddressValid
|
|
100
|
+
* @param {string} address - A string representing the address to validate.
|
|
101
|
+
* @return {boolean} Returns true if the address validation succeeded, else returns false.
|
|
102
|
+
*/
|
|
103
|
+
export function isAddressValid(address: string): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* The getLatestBlockDetails function returns details of the latest block of the blockchain.
|
|
106
|
+
*
|
|
107
|
+
* @async
|
|
108
|
+
* @function getLatestBlockDetails
|
|
109
|
+
* @return {Promise<LatestBlockDetailsResult>} Returns a promise of an object of type BlockDetailsResult.
|
|
110
|
+
*/
|
|
111
|
+
export function getLatestBlockDetails(): Promise<LatestBlockDetailsResult>;
|
|
112
|
+
/**
|
|
113
|
+
* The signSendCoinTransaction function returns a signed transaction.
|
|
114
|
+
* Since the gas fee for sending coins is fixed at 1000 coins, there is no option to set the gas fee explicitly.
|
|
115
|
+
* This function is useful for offline (cold storage) wallets, where you can sign a transaction offline and then use the postTransaction function to post it on a connected device.
|
|
116
|
+
* Another usecase for this function is when you want to first store a signed transaction to a database, then queue it and finally submit the transaction by calling the postTransaction function.
|
|
117
|
+
*
|
|
118
|
+
* @function signSendCoinTransaction
|
|
119
|
+
* @param {Wallet} wallet - A Wallet object from which the transaction has to be sent. The address corresponding to the Wallet should have enough coins to cover gas fees as well. A minimum of 1000 coins (1000000000000000000000 wei) are required for gas fees.
|
|
120
|
+
* @param {string} toAddress - The address to which the coins should be sent.
|
|
121
|
+
* @param {string} coins - The string representing the number of coins (in ether) to send. To convert between ethers and wei, see https://docs.ethers.org/v4/api-utils.html#ether-strings-and-wei
|
|
122
|
+
* @param {number} nonce - The nonce of the account retrieved by invoking the getAccountDetails function. You have to carefully manage state of the nonce to avoid sending the coins multiple times, such as when retrying sendCoins after a network error.
|
|
123
|
+
* @return {SignResult} Returns a promise of type SignResult.
|
|
124
|
+
*/
|
|
125
|
+
export function signSendCoinTransaction(wallet: Wallet, toAddress: string, coins: string, nonce: number): SignResult;
|
|
126
|
+
/**
|
|
127
|
+
* The listAccountTransactions function returns a list of transactions for a specific account.
|
|
128
|
+
* Transactions may take a while to get registered in the blockchain. After a transaction is submitted, it may take a while before it is available for listing.
|
|
129
|
+
* Some transactions that have lower balance than the minimum required for gas fees may be discarded.
|
|
130
|
+
* In these cases, the transactions may not be returned when invoking the listAccountTransactions function.
|
|
131
|
+
* You should consider the transaction as succeeded only if the status field AccountDetailsCompact object is 0x1 (success).
|
|
132
|
+
* Both transactions from and transactions to the address will be returned in the list.
|
|
133
|
+
* Use the getTransactionDetails function, passing the hash of the transaction to get detailed information about the transaction.
|
|
134
|
+
* @async
|
|
135
|
+
* @function listAccountTransactions
|
|
136
|
+
* @param {string} address - The address for which the transactions have to be listed.
|
|
137
|
+
* @param {number} pageNumber - The page number for which the transactions has to be listed for the account. Pass 0 to list the latest page. Pass 1 to list the oldest page. A maximum of 20 transactions are returned in each page. The response of this API includes a field that shows the pageCount (total number of pages available). You can pass any number between 1 to pageCount to get the corresponding page.
|
|
138
|
+
* @return {Promise<ListAccountTransactionsResponse>} Returns a promise of type type ListAccountTransactionsResponse.
|
|
139
|
+
*/
|
|
140
|
+
export function listAccountTransactions(address: string, pageNumber: number): Promise<ListAccountTransactionsResponse>;
|
|
141
|
+
/**
|
|
142
|
+
* The postTransaction function posts a signed transaction to the blockchain.
|
|
143
|
+
* This method can be used in conjunction with the signSendCoinTransaction method to submit a transaction that was signed using a cold wallet (offline or disconnected or air-gapped wallet).
|
|
144
|
+
*
|
|
145
|
+
* @async
|
|
146
|
+
* @function postTransaction
|
|
147
|
+
* @param {string} txnData - A signed transaction string returned by the signSendCoinTransaction function.
|
|
148
|
+
* @return {Promise<SendResult>} Returns a promise of type SendResult. txnHash will be null in SendResult.
|
|
149
|
+
*/
|
|
150
|
+
export function postTransaction(txnData: string): Promise<SendResult>;
|
|
151
|
+
/**
|
|
152
|
+
* @class
|
|
153
|
+
* @constructor
|
|
154
|
+
* @public
|
|
155
|
+
* @classdesc This is the configuration class required to initialize and interact with Quantum Coin blockchain
|
|
156
|
+
*/
|
|
157
|
+
export class Config {
|
|
158
|
+
/**
|
|
159
|
+
* Creates a config class
|
|
160
|
+
* @param {string} readUrl - The Read API URL pointing to a read relay. See https://github.com/quantumcoinproject/quantum-coin-go/tree/dogep/relay. The following URLs are community maintained. Please use your own relay service. Mainnet: https://sdk.readrelay.quantumcoinapi.com
|
|
161
|
+
* @param {string} writeUrl - The Write API URL pointing to a write relay. See https://github.com/quantumcoinproject/quantum-coin-go/tree/dogep/relay. The following URLs are community maintained. Please use your own relay service. Mainnet: https://sdk.writerelay.quantumcoinapi.com
|
|
162
|
+
* @param {number} chainId - The chain id of the blockchain. Mainnet chainId is 123123. Testnet T4 chainId is 310324.
|
|
163
|
+
* @param {string} readApiKey - Optional parameter if authorization is enabled for the relay service. API Key for authorization. Defaults to null which indicates no authorization.
|
|
164
|
+
* @param {string} writeApiKey - Optional parameter if authorization is enabled for the relay service. API Key for authorization. Defaults to null which indicates no authorization.
|
|
165
|
+
*/
|
|
166
|
+
constructor(readUrl: string, writeUrl: string, chainId: number, readApiKey: string, writeApiKey: string);
|
|
167
|
+
/**
|
|
168
|
+
* The Read API URL pointing to a read relay. See https://github.com/quantumcoinproject/quantum-coin-go/tree/dogep/relay
|
|
169
|
+
* @type {string}
|
|
170
|
+
* @public
|
|
171
|
+
*/
|
|
172
|
+
public readUrl: string;
|
|
173
|
+
/**
|
|
174
|
+
* The Read API URL pointing to a read relay. See https://github.com/quantumcoinproject/quantum-coin-go/tree/dogep/relay
|
|
175
|
+
* @type {string}
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
178
|
+
public writeUrl: string;
|
|
179
|
+
/**
|
|
180
|
+
* The chain id of the blockchain. Mainnet chainId is 123123. Testnet T4 chainId is 310324.
|
|
181
|
+
* @type {number}
|
|
182
|
+
* @public
|
|
183
|
+
*/
|
|
184
|
+
public chainId: number;
|
|
185
|
+
/**
|
|
186
|
+
* API Key for authorization if authorization is enabled for the relay service. Defaults to null which indicates no authorization.
|
|
187
|
+
* @type {string}
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
public readApiKey: string;
|
|
191
|
+
/**
|
|
192
|
+
* API Key for authorization if authorization is enabled for the relay service. Defaults to null which indicates no authorization.
|
|
193
|
+
* @type {string}
|
|
194
|
+
* @public
|
|
195
|
+
*/
|
|
196
|
+
public writeApiKey: string;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* @class
|
|
200
|
+
* @constructor
|
|
201
|
+
* @public
|
|
202
|
+
* @classdesc This class represents a Wallet. Use the verifyWallet function to verify if a wallet is valid. Verifying the wallet is highly recommended, especially if it comes from an untrusted source. For more details on the underlying cryptography of the Wallet, see https://github.com/QuantumCoinProject/hybrid-pqc
|
|
203
|
+
*/
|
|
204
|
+
export class Wallet {
|
|
205
|
+
/**
|
|
206
|
+
* Creates a Wallet class. The constructor does not verify the wallet. To verify a wallet, call the verifyWallet function explicitly.
|
|
207
|
+
* @param {string} address - Address of the wallet
|
|
208
|
+
* @param {number[]} privateKey - Private Key byte array of the wallet
|
|
209
|
+
* @param {number[]} publicKey - The chain id of the blockchain. Mainnet chainId is 123123. Testnet T4 chainId is 310324.
|
|
210
|
+
*/
|
|
211
|
+
constructor(address: string, privateKey: number[], publicKey: number[]);
|
|
212
|
+
/**
|
|
213
|
+
* Address of the wallet. Is 66 bytes in length including 0x (if the wallet is valid).
|
|
214
|
+
* @type {string}
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
public address: string;
|
|
218
|
+
/**
|
|
219
|
+
* Private Key byte array of the wallet. Is 4064 bytes in length (if the wallet is valid).
|
|
220
|
+
* @type {number[]}
|
|
221
|
+
* @public
|
|
222
|
+
*/
|
|
223
|
+
public privateKey: number[];
|
|
224
|
+
/**
|
|
225
|
+
* Public Key byte array of the wallet. Is 1408 bytes in length (if the wallet is valid).
|
|
226
|
+
* @type {number[]}
|
|
227
|
+
* @public
|
|
228
|
+
*/
|
|
229
|
+
public publicKey: number[];
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* @class
|
|
233
|
+
* @constructor
|
|
234
|
+
* @public
|
|
235
|
+
* @classdesc This class represents a Block.
|
|
236
|
+
*/
|
|
237
|
+
export class BlockDetails {
|
|
238
|
+
constructor(blockNumber: any);
|
|
239
|
+
/**
|
|
240
|
+
* Block Number of the block
|
|
241
|
+
* @type {number}
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
public blockNumber: number;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* @class
|
|
248
|
+
* @constructor
|
|
249
|
+
* @public
|
|
250
|
+
* @classdesc This class represents a result from invoking the getLatestBlock function.
|
|
251
|
+
*/
|
|
252
|
+
export class LatestBlockDetailsResult {
|
|
253
|
+
constructor(resultCode: any, blockDetails: any, response: any, requestId: any, err: any);
|
|
254
|
+
/**
|
|
255
|
+
* Represents the result of the operation. A value of 0 represents that the operation succeeded. Any other value indicates the operation failed. See the result code section for more details.
|
|
256
|
+
* @type {number}
|
|
257
|
+
* @public
|
|
258
|
+
*/
|
|
259
|
+
public resultCode: number;
|
|
260
|
+
/**
|
|
261
|
+
* An object of type BlockDetails representing the block. This value is null if the value of resultCode is not 0.
|
|
262
|
+
* @type {BlockDetails}
|
|
263
|
+
* @public
|
|
264
|
+
*/
|
|
265
|
+
public blockDetails: BlockDetails;
|
|
266
|
+
/**
|
|
267
|
+
* An object of representing the raw Response returned by the service. For details, see https://developer.mozilla.org/en-US/docs/Web/API/Response. This value can be null if the value of resultCode is not 0.
|
|
268
|
+
* @type {Object}
|
|
269
|
+
* @public
|
|
270
|
+
*/
|
|
271
|
+
public response: any;
|
|
272
|
+
/**
|
|
273
|
+
* An unique id to represent the request. This can be null if request failed before it could be sent.
|
|
274
|
+
* @type {string}
|
|
275
|
+
* @public
|
|
276
|
+
*/
|
|
277
|
+
public requestId: string;
|
|
278
|
+
/**
|
|
279
|
+
* An error object if the operation resulted in an error and there was no response. This property is defined only if the resultCode is -10000.
|
|
280
|
+
* @type {Error}
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
283
|
+
public err: Error;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* @class
|
|
287
|
+
* @constructor
|
|
288
|
+
* @public
|
|
289
|
+
* @classdesc This class represents an Account.
|
|
290
|
+
*/
|
|
291
|
+
export class AccountDetails {
|
|
292
|
+
constructor(address: any, balance: any, nonce: any, blockNumber: any);
|
|
293
|
+
/**
|
|
294
|
+
* Address of the wallet. Is 66 bytes in length including 0x.
|
|
295
|
+
* @type {string}
|
|
296
|
+
* @public
|
|
297
|
+
*/
|
|
298
|
+
public address: string;
|
|
299
|
+
/**
|
|
300
|
+
* Balance of the account in wei. To convert this to ethers, see https://docs.ethers.org/v4/api-utils.html#ether-strings-and-wei
|
|
301
|
+
* @type {string}
|
|
302
|
+
* @public
|
|
303
|
+
*/
|
|
304
|
+
public balance: string;
|
|
305
|
+
/**
|
|
306
|
+
* A monotonically increasing number representing the nonce of the account. After each transaction from the account that gets registered in the blockchain, the nonce increases by 1.
|
|
307
|
+
* @type {number}
|
|
308
|
+
* @public
|
|
309
|
+
*/
|
|
310
|
+
public nonce: number;
|
|
311
|
+
/**
|
|
312
|
+
* The block number as of which the Account details was retrieved.
|
|
313
|
+
* @type {number}
|
|
314
|
+
* @public
|
|
315
|
+
*/
|
|
316
|
+
public blockNumber: number;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* @class
|
|
320
|
+
* @constructor
|
|
321
|
+
* @public
|
|
322
|
+
* @classdesc This class represents a result from invoking the getAccountDetails function.
|
|
323
|
+
*/
|
|
324
|
+
export class AccountDetailsResult {
|
|
325
|
+
constructor(resultCode: any, accountDetails: any, response: any, requestId: any, err: any);
|
|
326
|
+
/**
|
|
327
|
+
* Represents the result of the operation. A value of 0 represents that the operation succeeded. Any other value indicates the operation failed. See the result code section for more details.
|
|
328
|
+
* @type {number}
|
|
329
|
+
* @public
|
|
330
|
+
*/
|
|
331
|
+
public resultCode: number;
|
|
332
|
+
/**
|
|
333
|
+
* An object of type AccountDetails representing the block. This value is null if the value of resultCode is not 0.
|
|
334
|
+
* @type {AccountDetails}
|
|
335
|
+
* @public
|
|
336
|
+
*/
|
|
337
|
+
public accountDetails: AccountDetails;
|
|
338
|
+
/**
|
|
339
|
+
* An object of representing the raw Response returned by the service. For details, see https://developer.mozilla.org/en-US/docs/Web/API/Response. This value can be null if the value of resultCode is not 0.
|
|
340
|
+
* @type {Object}
|
|
341
|
+
* @public
|
|
342
|
+
*/
|
|
343
|
+
public response: any;
|
|
344
|
+
/**
|
|
345
|
+
* An unique id to represent the request. This can be null if request failed before it could be sent.
|
|
346
|
+
* @type {string}
|
|
347
|
+
* @public
|
|
348
|
+
*/
|
|
349
|
+
public requestId: string;
|
|
350
|
+
/**
|
|
351
|
+
* An error object if the operation resulted in an error and there was no response. This property is defined only if the resultCode is -10000.
|
|
352
|
+
* @type {Error}
|
|
353
|
+
* @public
|
|
354
|
+
*/
|
|
355
|
+
public err: Error;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* @class
|
|
359
|
+
* @constructor
|
|
360
|
+
* @public
|
|
361
|
+
* @classdesc This class represents a result from invoking the sendCoins function.
|
|
362
|
+
*/
|
|
363
|
+
export class SendResult {
|
|
364
|
+
constructor(resultCode: any, txnHash: any, response: any, requestId: any, err: any);
|
|
365
|
+
/**
|
|
366
|
+
* Represents the result of the operation. A value of 0 represents that the operation succeeded. Any other value indicates the operation failed. See the result code section for more details.
|
|
367
|
+
* @type {number}
|
|
368
|
+
* @public
|
|
369
|
+
*/
|
|
370
|
+
public resultCode: number;
|
|
371
|
+
/**
|
|
372
|
+
* Hash of the Transaction, to uniquely identify it. Is 66 bytes in length including 0x. This value is null if the value of resultCode is not 0.
|
|
373
|
+
* @type {string}
|
|
374
|
+
* @public
|
|
375
|
+
*/
|
|
376
|
+
public txnHash: string;
|
|
377
|
+
/**
|
|
378
|
+
* An object of representing the raw Response returned by the service. For details, see https://developer.mozilla.org/en-US/docs/Web/API/Response. This value can be null if the value of resultCode is not 0.
|
|
379
|
+
* @type {Object}
|
|
380
|
+
* @public
|
|
381
|
+
*/
|
|
382
|
+
public response: any;
|
|
383
|
+
/**
|
|
384
|
+
* An unique id to represent the request. This can be null if request failed before it could be sent.
|
|
385
|
+
* @type {string}
|
|
386
|
+
* @public
|
|
387
|
+
*/
|
|
388
|
+
public requestId: string;
|
|
389
|
+
/**
|
|
390
|
+
* An error object if the operation resulted in an error and there was no response. This property is defined only if the resultCode is -10000.
|
|
391
|
+
* @type {Error}
|
|
392
|
+
* @public
|
|
393
|
+
*/
|
|
394
|
+
public err: Error;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* @class
|
|
398
|
+
* @constructor
|
|
399
|
+
* @public
|
|
400
|
+
* @classdesc This class represents a Receipt of a transaction that is registered in the blockchain. The transactionReceipt field can be null unless the transaction is registered with the blockchain.
|
|
401
|
+
* While the transaction is pending, this field will be null. You should consider the transaction as succeeded only if the status field's value is 0x1 (success).
|
|
402
|
+
*/
|
|
403
|
+
export class TransactionReceipt {
|
|
404
|
+
/**
|
|
405
|
+
* A hexadecimal string representing the total amount of gas used when this transaction was executed in the block.
|
|
406
|
+
* @type {string}
|
|
407
|
+
* @public
|
|
408
|
+
*/
|
|
409
|
+
public cumulativeGasUsed: string;
|
|
410
|
+
/**
|
|
411
|
+
* A hexadecimal string representing the sum of the base fee and tip paid per unit of gas.
|
|
412
|
+
* @type {string}
|
|
413
|
+
* @public
|
|
414
|
+
*/
|
|
415
|
+
public effectiveGasPrice: string;
|
|
416
|
+
/**
|
|
417
|
+
* A hexadecimal string representing the amount of gas used by this specific transaction alone.
|
|
418
|
+
* @type {string}
|
|
419
|
+
* @public
|
|
420
|
+
*/
|
|
421
|
+
public gasUsed: string;
|
|
422
|
+
/**
|
|
423
|
+
* A hexadecimal string representing either 0x1 (success) or 0x0 (failure). Failed transactions can also incur gas fee. You should consider the transaction as succeeded only if the status value is 0x1 (success).
|
|
424
|
+
* @type {string}
|
|
425
|
+
* @public
|
|
426
|
+
*/
|
|
427
|
+
public status: string;
|
|
428
|
+
/**
|
|
429
|
+
* Hash of the Transaction, to uniquely identify it. Is 66 bytes in length including 0x.
|
|
430
|
+
* @type {string}
|
|
431
|
+
* @public
|
|
432
|
+
*/
|
|
433
|
+
public hash: string;
|
|
434
|
+
/**
|
|
435
|
+
* A hexadecimal string representing the transaction type. 0x0 is DefaultFeeTxType.
|
|
436
|
+
* @type {string}
|
|
437
|
+
* @public
|
|
438
|
+
*/
|
|
439
|
+
public type: string;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* @class
|
|
443
|
+
* @constructor
|
|
444
|
+
* @public
|
|
445
|
+
* @classdesc This class represents details of a transaction. You should consider the transaction as succeeded only if the status field of the receipt object is 0x1 (success).
|
|
446
|
+
*/
|
|
447
|
+
export class TransactionDetails {
|
|
448
|
+
/**
|
|
449
|
+
* A hexadecimal string representing the hash of the block that registered the transaction. This field can be null if the transaction was not registered in the blockchain.
|
|
450
|
+
* @type {string}
|
|
451
|
+
* @public
|
|
452
|
+
*/
|
|
453
|
+
public blockHash: string;
|
|
454
|
+
/**
|
|
455
|
+
* The number of the block that registered the transaction. This field can be null if the transaction was not registered in the blockchain.
|
|
456
|
+
* @type {number}
|
|
457
|
+
* @public
|
|
458
|
+
*/
|
|
459
|
+
public blockNumber: number;
|
|
460
|
+
/**
|
|
461
|
+
* A 66 character hexadecimal string representing the address the transaction is sent from.
|
|
462
|
+
* @type {string}
|
|
463
|
+
* @public
|
|
464
|
+
*/
|
|
465
|
+
public from: string;
|
|
466
|
+
/**
|
|
467
|
+
* A hexadecimal string representing the gas provided for the transaction execution.
|
|
468
|
+
* @type {string}
|
|
469
|
+
* @public
|
|
470
|
+
*/
|
|
471
|
+
public gas: string;
|
|
472
|
+
/**
|
|
473
|
+
* A hexadecimal string representing the gasPrice used for each paid gas, in Wei.
|
|
474
|
+
* @type {string}
|
|
475
|
+
* @public
|
|
476
|
+
*/
|
|
477
|
+
public gasPrice: string;
|
|
478
|
+
/**
|
|
479
|
+
* A 66 character hexadecimal string representing the hash of the transaction.
|
|
480
|
+
* @type {string}
|
|
481
|
+
* @public
|
|
482
|
+
*/
|
|
483
|
+
public hash: string;
|
|
484
|
+
/**
|
|
485
|
+
* A hexadecimal string representing the compiled code of a contract OR the hash of the invoked method signature and encoded parameters.
|
|
486
|
+
* @type {string}
|
|
487
|
+
* @public
|
|
488
|
+
*/
|
|
489
|
+
public input: string;
|
|
490
|
+
/**
|
|
491
|
+
* A monotonically increasing number representing the nonce of the account. After each transaction from the account that gets registered in the blockchain, the nonce increases by 1.
|
|
492
|
+
* @type {number}
|
|
493
|
+
* @public
|
|
494
|
+
*/
|
|
495
|
+
public nonce: number;
|
|
496
|
+
/**
|
|
497
|
+
* A 66 character hexadecimal string representing address the transaction is directed to.
|
|
498
|
+
* @type {string}
|
|
499
|
+
* @public
|
|
500
|
+
*/
|
|
501
|
+
public to: string;
|
|
502
|
+
/**
|
|
503
|
+
* A hexadecimal string representing the value sent with this transaction. The value can be 0 for smart contract transactions, since it only represents the number of coins sent.
|
|
504
|
+
* @type {string}
|
|
505
|
+
* @public
|
|
506
|
+
*/
|
|
507
|
+
public value: string;
|
|
508
|
+
/**
|
|
509
|
+
* The receipt of the transaction. This field will be null while the transaction is pending (not yet registered in the blockchain).
|
|
510
|
+
* @type {TransactionReceipt}
|
|
511
|
+
* @public
|
|
512
|
+
*/
|
|
513
|
+
public receipt: TransactionReceipt;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* @class
|
|
517
|
+
* @constructor
|
|
518
|
+
* @public
|
|
519
|
+
* @classdesc This class represents a result from invoking the getTransactionDetails function. If transactions get discarded by the blockchain, for reasons such as due to lower than minimum gas fees or invalid nonce, the resultCode will always contain a non-zero value (failure).
|
|
520
|
+
*/
|
|
521
|
+
export class TransactionDetailsResult {
|
|
522
|
+
constructor(resultCode: any, transactionDetails: any, response: any, requestId: any, err: any);
|
|
523
|
+
/**
|
|
524
|
+
* Represents the result of the operation. A value of 0 represents that the operation succeeded. Any other value indicates the operation failed. See the result code section for more details.
|
|
525
|
+
* @type {number}
|
|
526
|
+
* @public
|
|
527
|
+
*/
|
|
528
|
+
public resultCode: number;
|
|
529
|
+
/**
|
|
530
|
+
* An object of type TransactionDetails representing the transaction. This value is null if the value of resultCode is not 0.
|
|
531
|
+
* @type {TransactionDetails}
|
|
532
|
+
* @public
|
|
533
|
+
*/
|
|
534
|
+
public transactionDetails: TransactionDetails;
|
|
535
|
+
/**
|
|
536
|
+
* An object of representing the raw Response returned by the service. For details, see https://developer.mozilla.org/en-US/docs/Web/API/Response. This value can be null if the value of resultCode is not 0.
|
|
537
|
+
* @type {Object}
|
|
538
|
+
* @public
|
|
539
|
+
*/
|
|
540
|
+
public response: any;
|
|
541
|
+
/**
|
|
542
|
+
* An unique id to represent the request. This can be null if request failed before it could be sent.
|
|
543
|
+
* @type {string}
|
|
544
|
+
* @public
|
|
545
|
+
*/
|
|
546
|
+
public requestId: string;
|
|
547
|
+
/**
|
|
548
|
+
* An error object if the operation resulted in an error and there was no response. This property is defined only if the resultCode is -10000.
|
|
549
|
+
* @type {Error}
|
|
550
|
+
* @public
|
|
551
|
+
*/
|
|
552
|
+
public err: Error;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* @class
|
|
556
|
+
* @constructor
|
|
557
|
+
* @public
|
|
558
|
+
* @classdesc This class represents a result from invoking the listAccountTransactionDetails function.
|
|
559
|
+
*/
|
|
560
|
+
export class AccountTransactionsResult {
|
|
561
|
+
constructor(resultCode: any, listAccountTransactionsResponse: any, response: any, requestId: any, err: any);
|
|
562
|
+
/**
|
|
563
|
+
* Represents the result of the operation. A value of 0 represents that the operation succeeded. Any other value indicates the operation failed. See the result code section for more details.
|
|
564
|
+
* @type {number}
|
|
565
|
+
* @public
|
|
566
|
+
*/
|
|
567
|
+
public resultCode: number;
|
|
568
|
+
/**
|
|
569
|
+
* An object of type ListAccountTransactionsResponse representing the list of transactions along with metadata. This value is null if the value of resultCode is not 0.
|
|
570
|
+
* @type {ListAccountTransactionsResponse}
|
|
571
|
+
* @public
|
|
572
|
+
*/
|
|
573
|
+
public listAccountTransactionsResponse: ListAccountTransactionsResponse;
|
|
574
|
+
/**
|
|
575
|
+
* An object of representing the raw Response returned by the service. For details, see https://developer.mozilla.org/en-US/docs/Web/API/Response. This value can be null if the value of resultCode is not 0.
|
|
576
|
+
* @type {Object}
|
|
577
|
+
* @public
|
|
578
|
+
*/
|
|
579
|
+
public response: any;
|
|
580
|
+
/**
|
|
581
|
+
* An unique id to represent the request. This can be null if request failed before it could be sent.
|
|
582
|
+
* @type {string}
|
|
583
|
+
* @public
|
|
584
|
+
*/
|
|
585
|
+
public requestId: string;
|
|
586
|
+
/**
|
|
587
|
+
* An error object if the operation resulted in an error and there was no response. This property is defined only if the resultCode is -10000.
|
|
588
|
+
* @type {Error}
|
|
589
|
+
* @public
|
|
590
|
+
*/
|
|
591
|
+
public err: Error;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* @class
|
|
595
|
+
* @constructor
|
|
596
|
+
* @public
|
|
597
|
+
* @classdesc This class represents a list of account transactions returned by the listAccountTransactionDetails function.
|
|
598
|
+
*/
|
|
599
|
+
export class ListAccountTransactionsResponse {
|
|
600
|
+
/**
|
|
601
|
+
* The number of pages available for listing.
|
|
602
|
+
* @type {number}
|
|
603
|
+
* @public
|
|
604
|
+
*/
|
|
605
|
+
public pageCount: number;
|
|
606
|
+
/**
|
|
607
|
+
* An array of type AccountTransactionCompact, containing the list of transactions. Can be null if no items are available.
|
|
608
|
+
* @type {(AccountTransactionCompact|Array)}
|
|
609
|
+
* @public
|
|
610
|
+
*/
|
|
611
|
+
public items: (AccountTransactionCompact | any[]);
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* @class
|
|
615
|
+
* @constructor
|
|
616
|
+
* @public
|
|
617
|
+
* @classdesc This class represents a transaction of an account. You should consider the transaction as succeeded only if the status field is 0x1 (success).
|
|
618
|
+
*/
|
|
619
|
+
export class AccountTransactionCompact {
|
|
620
|
+
/**
|
|
621
|
+
* The number of the block that registered the transaction. This field can be null if the transaction was not registered in the blockchain.
|
|
622
|
+
* @type {number}
|
|
623
|
+
* @public
|
|
624
|
+
*/
|
|
625
|
+
public blockNumber: number;
|
|
626
|
+
/**
|
|
627
|
+
* A 66 character hexadecimal string representing the address the transaction is sent from.
|
|
628
|
+
* @type {string}
|
|
629
|
+
* @public
|
|
630
|
+
*/
|
|
631
|
+
public from: string;
|
|
632
|
+
/**
|
|
633
|
+
* A 66 character hexadecimal string representing the hash of the transaction.
|
|
634
|
+
* @type {string}
|
|
635
|
+
* @public
|
|
636
|
+
*/
|
|
637
|
+
public hash: string;
|
|
638
|
+
/**
|
|
639
|
+
* A 66 character hexadecimal string representing address the transaction is directed to.
|
|
640
|
+
* @type {string}
|
|
641
|
+
* @public
|
|
642
|
+
*/
|
|
643
|
+
public to: string;
|
|
644
|
+
/**
|
|
645
|
+
* A hexadecimal string representing the value sent with this transaction. The value can be 0 for smart contract transactions, since it only represents the number of coins sent.
|
|
646
|
+
* @type {string}
|
|
647
|
+
* @public
|
|
648
|
+
*/
|
|
649
|
+
public value: string;
|
|
650
|
+
/**
|
|
651
|
+
* A hexadecimal string representing either 0x1 (success) or 0x0 (failure). Failed transactions can also incur gas fee. You should consider the transaction as succeeded only if the status value is 0x1 (success).
|
|
652
|
+
* @type {string}
|
|
653
|
+
* @public
|
|
654
|
+
*/
|
|
655
|
+
public status: string;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* The newWalletSeed function creates a new Wallet seed word list. The return array can then be passed to the openWalletFromSeedWords function to create a new wallet.
|
|
659
|
+
*
|
|
660
|
+
* @function newWalletSeed
|
|
661
|
+
* @return {array} Returns an array of seed words (48 words in total). Returns null if the operation failed.
|
|
662
|
+
*/
|
|
663
|
+
export function newWalletSeed(): any[];
|
|
664
|
+
/**
|
|
665
|
+
* The openWalletFromSeedWords function creates a wallet from a seed word list. The seed word list is available for wallets created from Desktop/Web/Mobile wallets.
|
|
666
|
+
*
|
|
667
|
+
* @function openWalletFromSeedWords
|
|
668
|
+
* @param {array} seedWordList - An array of seed words. There should be 48 words in total.
|
|
669
|
+
* @return {Wallet} Returns a Wallet object. Returns null if the operation failed.
|
|
670
|
+
*/
|
|
671
|
+
export function openWalletFromSeedWords(seedWordList: any[]): Wallet;
|
|
672
|
+
/**
|
|
673
|
+
* The publicKeyFromSignature extracts the public key from a signature.
|
|
674
|
+
*
|
|
675
|
+
* @function publicKeyFromSignature
|
|
676
|
+
* @param {number[]} digest - An array of bytes containing the digestHash. Should be of length 32.
|
|
677
|
+
* @param {number[]} signature - An array of bytes containing the signature.
|
|
678
|
+
* @return {number[]} - Returns a byte array containing the public key. Returns null if the operation failed.
|
|
679
|
+
*/
|
|
680
|
+
export function publicKeyFromSignature(digest: number[], signature: number[]): number[];
|
|
681
|
+
/**
|
|
682
|
+
* The publicKeyFromPrivateKey extracts the public key from a private key.
|
|
683
|
+
*
|
|
684
|
+
* @function publicKeyFromPrivateKey
|
|
685
|
+
* @param {number[]} privateKey - An array of bytes containing the privateKey.
|
|
686
|
+
* @return {number[]} - Returns a byte array containing the public key. Returns null if the operation failed.
|
|
687
|
+
*/
|
|
688
|
+
export function publicKeyFromPrivateKey(privateKey: number[]): number[];
|
|
689
|
+
/**
|
|
690
|
+
* @class
|
|
691
|
+
* @constructor
|
|
692
|
+
* @public
|
|
693
|
+
* @classdesc This class represents a result from invoking the signSendCoinTransaction function.
|
|
694
|
+
*/
|
|
695
|
+
declare class SignResult {
|
|
696
|
+
constructor(resultCode: any, txnHash: any, txnData: any);
|
|
697
|
+
/**
|
|
698
|
+
* Represents the result of the operation. A value of 0 represents that the operation succeeded. Any other value indicates the operation failed. See the result code section for more details.
|
|
699
|
+
* @type {number}
|
|
700
|
+
* @public
|
|
701
|
+
*/
|
|
702
|
+
public resultCode: number;
|
|
703
|
+
/**
|
|
704
|
+
* Hash of the Transaction, to uniquely identify it. Is 66 bytes in length including 0x. This value is null if the value of resultCode is not 0.
|
|
705
|
+
* @type {string}
|
|
706
|
+
* @public
|
|
707
|
+
*/
|
|
708
|
+
public txnHash: string;
|
|
709
|
+
/**
|
|
710
|
+
* A payload representing the signed transaction.
|
|
711
|
+
* To actually send a transaction, this payload can then be taken to to a different device that is connected to the blockchain relay and then sent using the postTransaction function.
|
|
712
|
+
* This value is null if the value of resultCode is not 0.
|
|
713
|
+
* @type {string}
|
|
714
|
+
* @public
|
|
715
|
+
*/
|
|
716
|
+
public txnData: string;
|
|
717
|
+
}
|
|
718
|
+
export {};
|