Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve getOperations logic and validations #1411

Closed
Torres-ssf opened this issue Nov 7, 2023 · 1 comment
Closed

Improve getOperations logic and validations #1411

Torres-ssf opened this issue Nov 7, 2023 · 1 comment
Assignees
Labels
bug Issue is a bug

Comments

@Torres-ssf
Copy link
Contributor

Torres-ssf commented Nov 7, 2023

The getOperations function and all associated helper functions currently require refactoring and improvements in their logic.

  1. For instance, there is a (potential) recurring issue where the operation variable is reassigned during each iteration of the loop, as can be seen in the following snippet:

let operations: Operation[] = [];
coinOutputs.forEach((output) => {
const input = getInputFromAssetId(inputs, output.assetId);
if (input) {
const inputAddress = getInputAccountAddress(input);
operations = addOperation(operations, {

It is crucial to ascertain whether this logic properly handles cases like a single transaction that involves the transfer of multiple assets among various addresses.

We can also improve the logic here and stop reassigning the operations variable if only one operation is expected.

  1. Additionally, it is necessary to validate whether transactions of the Create type can in fact generate a Transfer Asset operation:

if (isTypeCreate(transactionType)) {
return [
...getContractCreatedOperations({ inputs, outputs }),
...getTransferOperations({ inputs, outputs }),
];
}

Proper validation will ensure the reliability and maintainability of this code.

@arboleya
Copy link
Member

arboleya commented Jan 29, 2024

Completed via #1619.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is a bug
Projects
None yet
Development

No branches or pull requests

2 participants