Sha256: 9a80e23ded06f6b78b7fa64a44bb8c050ec56cc77202bd815cd4f76bfaa04a00
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
import { head, indexBy, prop, toArray, wait } from '../utils'; import { fetchStatus } from '../../api-node/transactions'; import { TRANSACTION_STATUSES } from '../../constants'; export default function (base, tx, options) { const isOnce = !Array.isArray(tx); const start = Date.now(); const confirmed = []; const confirmations = options && options.confirmations || 0; const maxWaitTime = options && options.maxWaitTime || 0; const requestInterval = options && options.requestInterval || 250; const waitTx = (list) => { return fetchStatus(base, list.map(prop('id'))) .then(status => { const hash = indexBy(prop('id'), status.statuses); const hasError = list.some(tx => hash[tx.id].status === TRANSACTION_STATUSES.NOT_FOUND); if (hasError) { throw new Error('One transaction is not in blockchain!'); } const toRequest = list.filter(tx => { if (hash[tx.id].confirmations >= confirmations) { confirmed.push(tx); return false; } else { return true; } }); if (!toRequest.length) { return void 0; } if (maxWaitTime && Date.now() - start > maxWaitTime) { return Promise.reject('Timeout error!'); } return wait(requestInterval).then(() => waitTx(toRequest)); }); }; return waitTx(toArray(tx)).then(() => isOnce ? head(confirmed) : confirmed); } //# sourceMappingURL=wait.js.map
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
waves_lib-0.1.0 | js/node_modules/@waves/node-api-js/es/tools/transactions/wait.js |