Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
swapEmitter.emit('progress', message);
if (message.method) {
swapEmitter.emit(message.method, message);
}
if (message.method === 'tradestatus' && message.status === 'finished') {
swapEmitter.emit('completed', message);
}
});
// We should wait for 10 minutes before removing the listener
// to handle edge cases where swaps can breifly have an incorrect
// status due to communication issues:
// https://github.com/jl777/SuperNET/issues/756
const TEN_MINUTES = 1000 * 60 * 10;
pAny([
swapEmitter.once('failed'),
swapEmitter.once('completed'),
]).then(async () => {
await delay(TEN_MINUTES);
removeListener();
});
return swapEmitter;
}
}
pProps(options.extensions, (extnames: Array) => {
let findFileWithExtname = (extname: string) => {
let filePath = replaceExt(this.resourcePath, `.${extname}`)
// @ts-ignore
return fs.exists(filePath).then(isExist => ({ isExist, filePath }))
}
return pAny(extnames.map(findFileWithExtname), {
filter: ({ isExist }) => isExist,
}).then(
({ filePath }) => {
this.addDependency(filePath)
return fs.readFile(filePath, 'utf8')
},
() => {}
)
})
.then((parts: Record) => done(null, template(parts)))
.catch(function (err) {
if (err instanceof pAny.AggregateError) {
for (const e of err) {
throw e;
}
} else {
throw err;
}
});