tari-project / tari-dan

BSD 3-Clause "New" or "Revised" License
7 stars 16 forks source link

Feat: allow templates/instruction to allocate an address on workspace for resource and components #1103

Open stringhandler opened 2 months ago

stringhandler commented 2 months ago
Transaction::builder()
.allocate_address(SubstateType::Component, "my_addr")
.allocate_address(SubstateType::Resource, "my_resx")
.call_method(foo_component, "whitelist_component", args![Workspace("my_addr")])
.call_method(foo_component, "whitelist_resource", args![Workspace("my_resx")])
.call_function(my_component_template, "create_with_addresses", args![Workspace("my_addr"),Workspace("my_resx")])
.put_last_instruction_output_on_workspace("c")
.call_method(foo_component, "register", args![Workspace("c")])
// Uses IdProvider to allocate an address 
let my_addr = allocate_address!(Component);
let my_resx = allocate_address!(Resource);

let foo = var!["my-foo"];
foo.whitelist_component(my_addr);
foo.whitelist_resource(my_resx);

let c = MyComponent::create_with_addresses(my_addr, my_resx);
foo.register(c);