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
use crate::{
abi::{EndpointAbi, EndpointMutabilityAbi, InputAbi, OutputAbis, TypeAbi},
api::{
const_handles, use_raw_handle, CallValueApiImpl, ManagedBufferApi, StorageWriteApiImpl,
VMApi, EXTERNAL_VIEW_TARGET_ADRESS_KEY,
},
io::load_endpoint_args,
types::ManagedType,
};
pub fn external_view_contract_constructor<A>()
where
A: VMApi,
{
A::call_value_api_impl().check_not_payable();
let (target_contract_address, ()) = load_endpoint_args::<
A,
(crate::types::ManagedAddress<A>, ()),
>(("target_contract_address", ()));
let key_handle: A::ManagedBufferHandle = use_raw_handle(const_handles::MBUF_TEMPORARY_1);
A::managed_type_impl().mb_overwrite(key_handle.clone(), EXTERNAL_VIEW_TARGET_ADRESS_KEY);
A::storage_write_api_impl()
.storage_store_managed_buffer_raw(key_handle, target_contract_address.get_handle());
}
pub fn external_view_contract_constructor_abi() -> EndpointAbi {
EndpointAbi {
docs: &[
"The external view init prepares a contract that looks in another contract's storage.",
"It takes a single argument, the other contract's address",
"You won't find this constructors' definition in the contract, it gets injected automatically by the framework. See `elrond_wasm::external_view_contract`.",
],
name: "init",
rust_method_name: "",
only_owner: false,
only_admin: false,
labels: &[],
mutability: EndpointMutabilityAbi::Mutable,
payable_in_tokens: &[],
inputs: [InputAbi{
arg_name: "target_contract_address",
type_name: crate::types::heap::Address::type_name(),
multi_arg: false,
}].to_vec(),
outputs: OutputAbis::new(),
}
}