-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathcall_tree_deploy.rs
More file actions
71 lines (60 loc) · 2.52 KB
/
call_tree_deploy.rs
File metadata and controls
71 lines (60 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use crate::{
call_tree::CallState, comp_interact_controller::ComposabilityInteract, forwarder_queue_proxy,
vault_proxy,
};
use multiversx_sc_snippets::imports::*;
impl ComposabilityInteract {
pub async fn deploy_call_tree_contracts(
&mut self,
call_state: &CallState,
) -> (Vec<Bech32Address>, Vec<Bech32Address>) {
let vault_deploy_addresses = self.typed_sc_deploy_vault(call_state).await;
let forwarder_deploy_addresses = self.typed_sc_deploy_forwarder_queue(call_state).await;
let mut vault_iter = call_state.vaults.iter();
for address in vault_deploy_addresses.iter() {
let rc_vault = vault_iter.next().unwrap();
let mut vault = rc_vault.borrow_mut();
println!("New vault {0} deployed address: {1}", vault.name, address);
vault.address = Some(address.to_address());
}
let mut fwd_iter = call_state.forwarders.iter();
for address in forwarder_deploy_addresses.iter() {
let rc_fwd = fwd_iter.next().unwrap();
let mut fwd = rc_fwd.borrow_mut();
println!("New forwarder {0} deployed address: {1}", fwd.name, address);
fwd.address = Some(address.to_address());
}
(vault_deploy_addresses, forwarder_deploy_addresses)
}
pub async fn typed_sc_deploy_vault(&mut self, call_state: &CallState) -> Vec<Bech32Address> {
let mut buffer = self.interactor.homogenous_call_buffer();
for _ in call_state.vaults.iter() {
buffer.push_tx(|tx| {
tx.from(&self.wallet_address)
.typed(vault_proxy::VaultProxy)
.init(OptionalValue::<BoxedBytes>::None)
.code(&self.vault_code)
.gas(NumExpr("70,000,000"))
.returns(ReturnsNewBech32Address)
});
}
buffer.run().await
}
pub async fn typed_sc_deploy_forwarder_queue(
&mut self,
call_state: &CallState,
) -> Vec<Bech32Address> {
let mut buffer = self.interactor.homogenous_call_buffer();
for _ in call_state.forwarders.iter() {
buffer.push_tx(|tx| {
tx.from(&self.wallet_address)
.typed(forwarder_queue_proxy::ForwarderQueueProxy)
.init()
.code(&self.forw_queue_code)
.gas(NumExpr("70,000,000"))
.returns(ReturnsNewBech32Address)
});
}
buffer.run().await
}
}