Repository navigation
Expand file tree
/
Copy pathdemo_candid_type_int8.cpp
More file actions
52 lines (41 loc) · 1.73 KB
/
Copy pathdemo_candid_type_int8.cpp
File metadata and controls
52 lines (41 loc) · 1.73 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
/* file: https://github.com/icppWorld/icpp-demos/tree/main/canisters/api_reference/src/demo_candid_type_int8.cpp
$ icp canister call demo demo_candid_type_int8 '(101 : int8)' --environment local
(101 : int8)
-> check the console of the local network. The canister will print:
[Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Method demo_candid_type_int8 received value '101'
$ icp canister call demo demo_candid_type_int8s '(101 : int8, -102 : int8)' --environment local
(101 : int8, -102 : int8)
-> check the console of the local network. The canister will print:
[Canister bkyz2-fmaaa-aaaaa-qaaaq-cai] Method demo_candid_type_int8s received values '101' & '-102'
*/
#include "demo_candid_type_int8.h"
#include <iostream>
#include <string>
#include "ic_api.h"
void demo_candid_type_int8() {
IC_API ic_api(CanisterQuery{std::string(__func__)}, false);
CandidTypePrincipal caller = ic_api.get_caller();
int8_t in{0};
ic_api.from_wire(CandidTypeInt8{&in});
std::cout << "Method " + std::string(__func__) + " received value '" +
std::to_string(in) + "'"
<< std::endl;
ic_api.to_wire(CandidTypeInt8{in});
}
void demo_candid_type_int8s() {
IC_API ic_api(CanisterQuery{std::string(__func__)}, false);
CandidTypePrincipal caller = ic_api.get_caller();
int8_t in1{0};
int8_t in2{0};
CandidArgs args_in;
args_in.append(CandidTypeInt8(&in1));
args_in.append(CandidTypeInt8(&in2));
ic_api.from_wire(args_in);
std::cout << "Method " + std::string(__func__) + " received values '" +
std::to_string(in1) + "' & '" + std::to_string(in2) + "'"
<< std::endl;
CandidArgs args_out;
args_out.append(CandidTypeInt8(in1));
args_out.append(CandidTypeInt8(in2));
ic_api.to_wire(args_out);
}