multiversx_sc_wasm_adapter/api/
endpoint_arg_api_node.rs1use crate::api::VmApiImpl;
2use multiversx_sc::api::{EndpointArgumentApi, EndpointArgumentApiImpl};
3
4unsafe extern "C" {
5 fn getNumArguments() -> i32;
6 fn getArgumentLength(id: i32) -> i32;
7
8 fn mBufferGetArgument(argId: i32, mBufferHandle: i32) -> i32;
10
11 fn bigIntGetUnsignedArgument(arg_index: i32, dest: i32);
13 fn bigIntGetSignedArgument(arg_index: i32, dest: i32);
14
15 fn smallIntGetUnsignedArgument(id: i32) -> i64;
17 fn smallIntGetSignedArgument(id: i32) -> i64;
18
19 fn managedGetCallbackClosure(callbackClosureHandle: i32);
21}
22
23impl EndpointArgumentApi for VmApiImpl {
24 type EndpointArgumentApiImpl = VmApiImpl;
25
26 #[inline]
27 fn argument_api_impl() -> Self::EndpointArgumentApiImpl {
28 VmApiImpl {}
29 }
30}
31
32impl EndpointArgumentApiImpl for VmApiImpl {
35 #[inline]
36 fn get_num_arguments(&self) -> i32 {
37 unsafe { getNumArguments() }
38 }
39
40 #[inline]
41 fn get_argument_len(&self, arg_index: i32) -> usize {
42 unsafe { getArgumentLength(arg_index) as usize }
43 }
44
45 #[inline]
46 fn load_argument_managed_buffer(&self, arg_index: i32, dest: Self::ManagedBufferHandle) {
47 unsafe {
48 mBufferGetArgument(arg_index, dest);
49 }
50 }
51
52 #[inline]
53 fn load_argument_big_int_unsigned(&self, arg_index: i32, dest: Self::ManagedBufferHandle) {
54 unsafe {
55 bigIntGetUnsignedArgument(arg_index, dest);
56 }
57 }
58
59 #[inline]
60 fn load_argument_big_int_signed(&self, arg_index: i32, dest: Self::ManagedBufferHandle) {
61 unsafe {
62 bigIntGetSignedArgument(arg_index, dest);
63 }
64 }
65
66 #[inline]
67 fn get_argument_u64(&self, arg_index: i32) -> u64 {
68 unsafe { smallIntGetUnsignedArgument(arg_index) as u64 }
69 }
70
71 #[inline]
72 fn get_argument_i64(&self, arg_index: i32) -> i64 {
73 unsafe { smallIntGetSignedArgument(arg_index) }
74 }
75
76 #[inline]
77 fn load_callback_closure_buffer(&self, dest: Self::ManagedBufferHandle) {
78 unsafe {
79 managedGetCallbackClosure(dest);
80 }
81 }
82}