(client)
| 294 | * @module TransactionsApi |
| 295 | */ |
| 296 | const transactionsAPI = (client) => { |
| 297 | /** |
| 298 | * Processing callback for building a transaction. The instance of |
| 299 | * {@link TransactionBuilder} modified in the function is used to build a transaction |
| 300 | * in Chain Core. |
| 301 | * |
| 302 | * @callback builderCallback |
| 303 | * @param {TransactionBuilder} builder |
| 304 | */ |
| 305 | |
| 306 | return { |
| 307 | /** |
| 308 | * Get one page of transactions matching the specified query. |
| 309 | * |
| 310 | * @param {Object} params={} - Filter and pagination information. |
| 311 | * @param {String} params.filter - Filter string, see {@link https://chain.com/docs/core/build-applications/queries}. |
| 312 | * @param {Array<String|Number>} params.filterParams - Parameter values for filter string (if needed). |
| 313 | * @param {Number} params.startTime - A Unix timestamp in milliseconds. When specified, only transactions with a block time greater than the start time will be returned. |
| 314 | * @param {Number} params.endTime - A Unix timestamp in milliseconds. When specified, only transactions with a block time less than the start time will be returned. |
| 315 | * @param {Number} params.timeout - A time in milliseconds after which a server timeout should occur. Defaults to 1000 (1 second). |
| 316 | * @param {Number} params.pageSize - Number of items to return in result set. |
| 317 | * @param {pageCallback} [callback] - Optional callback. Use instead of Promise return value as desired. |
| 318 | * @returns {Promise<Page<Transaction>>} Requested page of results. |
| 319 | */ |
| 320 | query: (params, cb) => shared.query(client, 'transactions', '/list-transactions', params, {cb}), |
| 321 | |
| 322 | /** |
| 323 | * Request all transactions matching the specified query, calling the |
| 324 | * supplied processor callback with each item individually. |
| 325 | * |
| 326 | * @param {Object} params={} - Filter and pagination information. |
| 327 | * @param {String} params.filter - Filter string, see {@link https://chain.com/docs/core/build-applications/queries}. |
| 328 | * @param {Array<String|Number>} params.filterParams - Parameter values for filter string (if needed). |
| 329 | * @param {Number} params.startTime - A Unix timestamp in milliseconds. When specified, only transactions with a block time greater than the start time will be returned. |
| 330 | * @param {Number} params.endTime - A Unix timestamp in milliseconds. When specified, only transactions with a block time less than the start time will be returned. |
| 331 | * @param {Number} params.timeout - A time in milliseconds after which a server timeout should occur. Defaults to 1000 (1 second). |
| 332 | * @param {Number} params.pageSize - Number of items to return in result set. |
| 333 | * @param {QueryProcessor<Transaction>} processor - Processing callback. |
| 334 | * @param {objectCallback} [callback] - Optional callback. Use instead of Promise return value as desired. |
| 335 | * @returns {Promise} A promise resolved upon processing of all items, or |
| 336 | * rejected on error. |
| 337 | */ |
| 338 | queryAll: (params, processor, cb) => shared.queryAll(client, 'transactions', params, processor, cb), |
| 339 | |
| 340 | /** |
| 341 | * Build an unsigned transaction from a set of actions. |
| 342 | * |
| 343 | * @param {module:TransactionsApi~builderCallback} builderBlock - Function that adds desired actions |
| 344 | * to a given builder object. |
| 345 | * @param {objectCallback} [callback] - Optional callback. Use instead of Promise return value as desired. |
| 346 | * @returns {Promise<Object>} Unsigned transaction template, or error. |
| 347 | */ |
| 348 | build: (builderBlock, cb) => { |
| 349 | const builder = new TransactionBuilder() |
| 350 | builderBlock(builder) |
| 351 | |
| 352 | return shared.tryCallback( |
| 353 | client.request('/build-transaction', [builder]).then(resp => checkForError(resp[0])), |
no test coverage detected