Use flatMap in findSuitableResources
This commit is contained in:
@@ -510,7 +510,7 @@ export class Invitation extends EventEmitter<InvitationEventMap> {
|
|||||||
const templates = await this.engine.listImportedTemplates();
|
const templates = await this.engine.listImportedTemplates();
|
||||||
|
|
||||||
// For each template, we need to create a 2d array of all the outputs
|
// For each template, we need to create a 2d array of all the outputs
|
||||||
const outputs = templates.map(template => {
|
const outputs = templates.flatMap(template => {
|
||||||
return Object.keys(template.outputs).map(output => {
|
return Object.keys(template.outputs).map(output => {
|
||||||
const templateIdentifier = generateTemplateIdentifier(template);
|
const templateIdentifier = generateTemplateIdentifier(template);
|
||||||
|
|
||||||
@@ -522,7 +522,7 @@ export class Invitation extends EventEmitter<InvitationEventMap> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// then, for each output, we need to get the spendable resources
|
// then, for each output, we need to get the spendable resources
|
||||||
const spendableResources = await Promise.all(outputs.flat().map(output => {
|
const spendableResources = await Promise.all(outputs.map(output => {
|
||||||
return this.engine.getSpendableResources(this.data, {
|
return this.engine.getSpendableResources(this.data, {
|
||||||
templateIdentifier: output.templateIdentifier,
|
templateIdentifier: output.templateIdentifier,
|
||||||
outputIdentifier: output.outputIdentifier,
|
outputIdentifier: output.outputIdentifier,
|
||||||
|
|||||||
Reference in New Issue
Block a user