Skip to content

Commit 53ef818

Browse files
committed
add register paymaster parser
1 parent c4623f8 commit 53ef818

3 files changed

Lines changed: 299 additions & 37 deletions

File tree

app/src/parser_txdef.h

Lines changed: 103 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ extern "C" {
2828
#define GAS_DIMENSIONS 2
2929
#define TOKEN_ID_SIZE 32
3030
#define ADDRESS_SIZE 28
31+
#define MAX_AUTHORIZED_UPDATERS 10
32+
#define DEFAULT_SAFE_VEC_LEN 20
3133

3234
typedef enum {
3335
RUNTIME_BANK,
@@ -45,12 +47,28 @@ typedef enum {
4547
} runtime_type_t;
4648

4749
typedef enum {
48-
CALL_MESSAGE_CREATE_TOKEN,
49-
CALL_MESSAGE_TRANSFER,
50-
CALL_MESSAGE_BURN,
51-
CALL_MESSAGE_MINT,
52-
CALL_MESSAGE_FREEZE,
53-
} call_message_type_t;
50+
BANK_CALL_MESSAGE_CREATE_TOKEN,
51+
BANK_CALL_MESSAGE_TRANSFER,
52+
BANK_CALL_MESSAGE_BURN,
53+
BANK_CALL_MESSAGE_MINT,
54+
BANK_CALL_MESSAGE_FREEZE,
55+
} bank_call_message_type_t;
56+
57+
typedef enum {
58+
PAYMASTER_CALL_REGISTER_PAYMASTER,
59+
PAYMASTER_CALL_SET_PAYER_FOR_SEQUENCER,
60+
PAYMASTER_CALL_UPDATE_POLICY,
61+
} paymaster_call_message_type_t;
62+
63+
typedef enum {
64+
PAYEE_POLICY_ALLOW,
65+
PAYEE_POLICY_DENY,
66+
} payee_policy_type_t;
67+
68+
typedef enum {
69+
AUTHORIZED_SEQUENCERS_ALL,
70+
AUTHORIZED_SEQUENCERS_SOME,
71+
} authorized_sequencers_type_t;
5472

5573
typedef struct {
5674
uint64_t hi;
@@ -70,6 +88,14 @@ typedef struct {
7088
bytes_t address;
7189
} address_t;
7290

91+
typedef struct {
92+
uint64_t gas[GAS_DIMENSIONS];
93+
} gas_t;
94+
95+
typedef struct {
96+
amount_t gas[GAS_DIMENSIONS];
97+
} gas_u128_t;
98+
7399
// CallMessage structs
74100
typedef struct {
75101
address_t to;
@@ -90,27 +116,90 @@ typedef struct {
90116
} freeze_t;
91117

92118
typedef struct {
93-
call_message_type_t type;
119+
bank_call_message_type_t type;
94120
union {
95121
transfer_t transfer;
96122
burn_t burn;
97123
mint_t mint;
98124
freeze_t freeze;
99125
};
100-
} call_message_t;
126+
} bank_call_message_t;
101127

102-
// Runtime structs
103128
typedef struct {
104-
runtime_type_t type;
129+
bool has_max_fee;
130+
amount_t max_fee;
131+
bool has_gas_limit;
132+
gas_t gas_limit;
133+
bool has_max_gas_price;
134+
gas_u128_t max_gas_price;
135+
bool has_transaction_limit;
136+
uint64_t transaction_limit;
137+
} payee_policy_allow_t;
138+
139+
typedef struct {
140+
payee_policy_type_t type;
105141
union {
106-
call_message_t call_message;
142+
payee_policy_allow_t allow;
107143
};
108-
} runtime_t;
144+
} payee_policy_t;
109145

110146
typedef struct {
111-
uint64_t gas[GAS_DIMENSIONS];
112-
} gas_t;
147+
uint32_t length;
148+
struct {
149+
address_t address;
150+
payee_policy_t policy;
151+
} pairs[DEFAULT_SAFE_VEC_LEN];
152+
} payee_policy_list_t;
153+
154+
typedef struct {
155+
uint32_t length;
156+
address_t address[DEFAULT_SAFE_VEC_LEN];
157+
} address_list_t;
158+
159+
typedef struct {
160+
authorized_sequencers_type_t type;
161+
union {
162+
address_list_t updaters;
163+
};
164+
} authorized_sequencers_t;
165+
166+
typedef struct {
167+
payee_policy_t default_payee_policy;
168+
payee_policy_list_t payees;
169+
address_list_t authorized_updaters;
170+
authorized_sequencers_t authorized_sequencers;
171+
} paymaster_policy_initializer_t;
172+
173+
typedef struct {
174+
paymaster_policy_initializer_t policy;
175+
} paymaster_call_register_paymaster_t;
113176

177+
typedef struct {
178+
address_t payer;
179+
} paymaster_call_set_payer_for_sequencer_t;
180+
181+
typedef struct {
182+
address_t payer;
183+
//policy_update_t update;
184+
} paymaster_call_update_policy_t;
185+
186+
typedef struct {
187+
paymaster_call_message_type_t type;
188+
union {
189+
paymaster_call_register_paymaster_t register_paymaster;
190+
paymaster_call_set_payer_for_sequencer_t set_payer_for_sequencer;
191+
paymaster_call_update_policy_t update_policy;
192+
};
193+
} paymaster_call_message_t;
194+
195+
// Runtime structs
196+
typedef struct {
197+
runtime_type_t type;
198+
union {
199+
bank_call_message_t bank;
200+
paymaster_call_message_t paymaster;
201+
};
202+
} runtime_t;
114203
typedef struct {
115204
uint64_t max_priority_fee_bips;
116205
amount_t max_fee;

0 commit comments

Comments
 (0)