(action)
| 574 | } |
| 575 | |
| 576 | constructCallAndResultFormat(action) { |
| 577 | if (typeof action === 'object' && 'raw' in action) { |
| 578 | const { to: toVariable, value: valueVariable, data: dataVariable } = action.raw; |
| 579 | |
| 580 | const to = this.variables[toVariable]; |
| 581 | const value = this.variables[valueVariable]; |
| 582 | const data = this.variables[dataVariable]; |
| 583 | |
| 584 | this.calls.push({ |
| 585 | to, |
| 586 | value, |
| 587 | data, |
| 588 | }); |
| 589 | } else { |
| 590 | const appliedArgs = []; |
| 591 | |
| 592 | // parse calls and results |
| 593 | const splitActionCalls = action.split(" => ")[0]; |
| 594 | const splitActionResults = (action.split(" => ")[1] || "") |
| 595 | .split(" ") |
| 596 | .filter(x => x); |
| 597 | |
| 598 | let givenArgumentsString = splitActionCalls.split(" ").slice(2).join(" "); |
| 599 | |
| 600 | let givenArguments = []; |
| 601 | |
| 602 | while (givenArgumentsString) { |
| 603 | if (givenArgumentsString.startsWith("(")) { |
| 604 | givenArguments.push( |
| 605 | givenArgumentsString.slice( |
| 606 | 1, |
| 607 | givenArgumentsString.indexOf(")") |
| 608 | ).split(" ") |
| 609 | ); |
| 610 | |
| 611 | givenArgumentsString = givenArgumentsString |
| 612 | .slice(givenArgumentsString.indexOf(")") + 1) |
| 613 | .trim(); |
| 614 | } else if (givenArgumentsString.indexOf(" ") !== -1) { |
| 615 | givenArguments.push( |
| 616 | givenArgumentsString.slice( |
| 617 | 0, |
| 618 | givenArgumentsString.indexOf(" ") |
| 619 | ) |
| 620 | ); |
| 621 | givenArgumentsString = givenArgumentsString |
| 622 | .slice(givenArgumentsString.indexOf(" ") + 1); |
| 623 | } else { |
| 624 | givenArguments.push(givenArgumentsString); |
| 625 | break; |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | let args = givenArguments |
| 630 | .filter(x => x) |
| 631 | .map(x => typeof x === "string" ? x.trim(" ") : x); |
| 632 | |
| 633 | let [contractName, functionName] = splitActionCalls.split( |
no test coverage detected