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

Make utxo chain transitions easier #940

Closed
Thoralf-M opened this issue Mar 17, 2022 · 0 comments
Closed

Make utxo chain transitions easier #940

Thoralf-M opened this issue Mar 17, 2022 · 0 comments
Assignees
Milestone

Comments

@Thoralf-M
Copy link
Member

Description

Currently if we want to update an alias/foundry/nft output we need to check the fields of the previous output and also set them to the new one, maybe with the state transition index updated (not for all, but at least for many fields), instead of every time manually going over every feature block, immutable feature block and other fields, we should have one or multiple functions to make it easier

For example something like this should be made easier, but we also still need the options to modify some fields ourself

        if let Output::Alias(alias_output) = &exiting_alias_output.output {

            let mut new_alias_output_builder = AliasOutputBuilder::new(exiting_alias_output.amount, alias_id)?
            .with_state_index(alias_output.state_index()+1)
            .with_foundry_counter(alias_output.foundry_counter()+1)
            .add_unlock_condition(UnlockCondition::StateControllerAddress(
                StateControllerAddressUnlockCondition::new(controller_address),
            ))
            .add_unlock_condition(UnlockCondition::GovernorAddress(GovernorAddressUnlockCondition::new(
                controller_address,
            )));
            for feature_block in alias_output.feature_blocks().iter(){
                new_alias_output_builder = new_alias_output_builder.add_feature_block(feature_block.clone());
            }
            for immutable_feature_block in alias_output.immutable_feature_blocks().iter(){
                new_alias_output_builder = new_alias_output_builder.add_immutable_feature_block(immutable_feature_block.clone());
            }
        }

Motivation

Cleaner and less code.

Requirements

  1. Add this for alias, foundry and alias outputs

Open questions (optional)

Should the helper functions just return the OutputBuilder with the fields updated? Then we can just overwrite the fields we want to change in a different way
Can this also be useful for basic outputs because of metadata/tag feature blocks?

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

No branches or pull requests

3 participants