Basic Implementation

LiquidAccount Consumer Example Contract used in unit tests

in zeus_boxes/contracts/eos/vaccountsconsumer/vaccountsconsumer.cpp The consumer contract is a great starting point for playing around with the LiquidAccount syntax.
1
/* DELAY REMOVAL OF USER DATA INTO VRAM */
2
/* ALLOWS FOR QUICKER ACCESS TO USER DATA WITHOUT THE NEED TO WARM DATA UP */
3
#define VACCOUNTS_DELAYED_CLEANUP 120
4
​
5
/* ADD NECESSARY LIQUIDACCOUNT / VRAM INCLUDES */
6
#include "../dappservices/vaccounts.hpp"
7
#include "../dappservices/ipfs.hpp"
8
#include "../dappservices/multi_index.hpp"
9
​
10
/* ADD LIQUIDACCOUNT / VRAM RELATED ACTIONS */
11
#define DAPPSERVICES_ACTIONS() \
12
XSIGNAL_DAPPSERVICE_ACTION \
13
IPFS_DAPPSERVICE_ACTIONS \
14
VACCOUNTS_DAPPSERVICE_ACTIONS
15
​
16
#define DAPPSERVICE_ACTIONS_COMMANDS() \
17
IPFS_SVC_COMMANDS()VACCOUNTS_SVC_COMMANDS()
18
19
#define CONTRACT_NAME() vaccountsconsumer
20
​
21
​
22
CONTRACT_START()
23
24
/* THE FOLLOWING STRUCT DEFINES THE PARAMS THAT MUST BE PASSED */
25
struct dummy_action_hello {
26
name vaccount;
27
uint64_t b;
28
uint64_t c;
29
30
EOSLIB_SERIALIZE( dummy_action_hello, (vaccount)(b)(c) )
31
};
32
33
/* DATA IS PASSED AS PAYLOADS INSTEAD OF INDIVIDUAL PARAMS */
34
[[eosio::action]] void hello(dummy_action_hello payload) {
35
/* require_vaccount is the equivalent of require_auth for EOS */
36
require_vaccount(payload.vaccount);
37
38
print("hello from ");
39
print(payload.vaccount);
40
print(" ");
41
print(payload.b + payload.c);
42
print("\n");
43
}
44
45
[[eosio::action]] void hello2(dummy_action_hello payload) {
46
print("hello2(default action) from ");
47
print(payload.vaccount);
48
print(" ");
49
print(payload.b + payload.c);
50
print("\n");
51
}
52
53
[[eosio::action]] void init(dummy_action_hello payload) {
54
}
55
56
/* EACH ACTION MUST HAVE A STRUCT THAT DEFINES THE PAYLOAD SYNTAX TO BE PASSED */
57
VACCOUNTS_APPLY(((dummy_action_hello)(hello))((dummy_action_hello)(hello2)))
58
59
CONTRACT_END((init)(hello)(hello2)(regaccount)(xdcommit)(xvinit)(xvauth))
Copied!
Last modified 9mo ago
Copy link