Skip to content

Builder pattern for creating boxes  #5

@greenhat

Description

@greenhat

Like the following:

 let math_bounty_candidate = create_candidate(
            bounty_amount_in_nano_ergs,
            &"94hWSMqgxHtRNEWoKrJFGVNQEYX34zfX68FNxWr".to_string(),
            &vec![],
            &vec![],
            current_height,
        )

would become something like

let math_bounty_candidate = CandidateBuilder::new(bounty_amount_in_nano_ergs, &"address".to_string(), current_height)
.build();

and if you add tokens :

let math_bounty_candidate = CandidateBuilder::new(bounty_amount_in_nano_ergs, &"address".to_string(), current_height)
.set_tokens(tokens)
.build();

Or even breaking new into separate methods to "name" parameters:

let math_bounty_candidate = CandidateBuilder::with_value(bounty_amount_in_nano_ergs)
.with_address(&"address".to_string())
.with_height(current_height)
.with_tokens(tokens)
.build();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions