@@ -77,16 +77,6 @@ typedef enum eth_ui_type_e {
77
77
ETH_UI_TYPE_GENERIC = 0x02 ,
78
78
} eth_ui_type_t ;
79
79
80
- // Scratch objects and utilities available to the plugin READ-WRITE
81
- typedef struct ethPluginSharedRW_s {
82
- cx_sha3_t * sha3 ;
83
- } ethPluginSharedRW_t ;
84
-
85
- // Transaction data available to the plugin READ-ONLY
86
- typedef struct ethPluginSharedRO_s {
87
- txContent_t * txContent ;
88
- } ethPluginSharedRO_t ;
89
-
90
80
// --8<-- [start:plugin_context]
91
81
// Plugin-only memory allocated by the Ethereum application and used by the
92
82
// plugin. 1k memory is available.
@@ -126,27 +116,13 @@ adapt for your use case.
126
116
127
117
// --8<-- [start:handle_init_contract_parameters]
128
118
typedef struct ethPluginInitContract_s {
119
+ // ===== READ ONLY ===== //
129
120
// INPUT. Used to check that `ETH_PLUGIN_INTERFACE_VERSION_LATEST` is
130
121
// correct.
131
122
eth_plugin_interface_version_t interfaceVersion ;
132
123
133
- // OUTPUT. Used by the plugin to inform the Ethereum application of the
134
- // result of this handle The following return codes are expected, any other
135
- // will abort the signing process:
136
- // - ETH_PLUGIN_RESULT_OK
137
- // - ETH_PLUGIN_RESULT_FALLBACK : if the signing logic should fallback to
138
- // the generic one
139
- eth_plugin_result_t result ;
140
-
141
- // DEPRECATED, will be removed soon. Do not use.
142
- ethPluginSharedRW_t * pluginSharedRW ;
143
-
144
124
// INPUT. Transaction data available to the plugin. READ-ONLY.
145
- ethPluginSharedRO_t * pluginSharedRO ;
146
-
147
- // RW INPUT. Contains the semi-persistent RAM space that can be used by the
148
- // plugin in each handle call.
149
- uint8_t * pluginContext ;
125
+ const txContent_t * txContent ;
150
126
151
127
// INPUT. Size of context allocated by the Ethereum application, must be
152
128
// equal to PLUGIN_CONTEXT_SIZE.
@@ -160,6 +136,20 @@ typedef struct ethPluginInitContract_s {
160
136
size_t dataSize ;
161
137
bip32_path_t * bip32 ;
162
138
139
+ // ===== READ WRITE ===== //
140
+ // RW INPUT. Contains the semi-persistent RAM space that can be used by the
141
+ // plugin in each handle call.
142
+ uint8_t * pluginContext ;
143
+
144
+ // ===== WRITE ONLY ===== //
145
+ // OUTPUT. Used by the plugin to inform the Ethereum application of the
146
+ // result of this handle The following return codes are expected, any other
147
+ // will abort the signing process:
148
+ // - ETH_PLUGIN_RESULT_OK
149
+ // - ETH_PLUGIN_RESULT_FALLBACK : if the signing logic should fallback to
150
+ // the generic one
151
+ eth_plugin_result_t result ;
152
+
163
153
} ethPluginInitContract_t ;
164
154
// --8<-- [end:handle_init_contract_parameters]
165
155
@@ -183,15 +173,9 @@ Adapt and expand it for your use case.
183
173
184
174
// --8<-- [start:handle_provide_parameter_parameters]
185
175
typedef struct ethPluginProvideParameter_s {
186
- // DEPRECATED, will be removed soon. Do not use.
187
- ethPluginSharedRW_t * pluginSharedRW ;
188
-
176
+ // ===== READ ONLY ===== //
189
177
// INPUT. Transaction data available to the plugin. READ-ONLY.
190
- ethPluginSharedRO_t * pluginSharedRO ;
191
-
192
- // RW INPUT. Contains the semi-persistent RAM space that can be used by the
193
- // plugin in each handle call.
194
- uint8_t * pluginContext ;
178
+ const txContent_t * txContent ;
195
179
196
180
// INPUT. Pointer to the 32 bytes parameter being parsed in the smart
197
181
// contract data.
@@ -201,6 +185,12 @@ typedef struct ethPluginProvideParameter_s {
201
185
// (starts at 4, following the selector).
202
186
uint32_t parameterOffset ;
203
187
188
+ // ===== READ WRITE ===== //
189
+ // RW INPUT. Contains the semi-persistent RAM space that can be used by the
190
+ // plugin in each handle call.
191
+ uint8_t * pluginContext ; // PLUGIN_CONTEXT_SIZE
192
+
193
+ // ===== WRITE ONLY ===== //
204
194
// OUTPUT. Used by the plugin to inform the Ethereum application of the
205
195
// result of this handle The following return codes are expected, any other
206
196
// will abort the signing process:
@@ -237,44 +227,46 @@ boilerplate plugin. Adapt and expand it for your use case.
237
227
238
228
// --8<-- [start:handle_finalize_parameters]
239
229
typedef struct ethPluginFinalize_s {
240
- // DEPRECATED, will be removed soon. Do not use.
241
- ethPluginSharedRW_t * pluginSharedRW ;
242
-
230
+ // ===== READ ONLY ===== //
243
231
// INPUT. Transaction data available to the plugin. READ-ONLY.
244
- ethPluginSharedRO_t * pluginSharedRO ;
232
+ const txContent_t * txContent ;
245
233
234
+ // ===== READ WRITE ===== //
246
235
// RW INPUT. Contains the semi-persistent RAM space that can be used by the
247
236
// plugin in each handle call.
248
- uint8_t * pluginContext ;
237
+ uint8_t * pluginContext ; // PLUGIN_CONTEXT_SIZE
249
238
239
+ // ===== WRITE ONLY ===== //
250
240
// OUTPUT. The plugin can set this value to a 20 bytes array in
251
241
// pluginContext containing the address of an ERC20 token. In this case
252
242
// Ethereum will call the plugin with handle_provide_token() with the
253
243
// requested ERC20 token information. The Ethereum application must be made
254
244
// aware of ERC20 token information first using 'PROVIDE ERC 20 TOKEN
255
245
// INFORMATION' APDU. Leave the value at NULL if not needed
256
- uint8_t * tokenLookup1 ;
246
+ const uint8_t * tokenLookup1 ;
257
247
// OUTPUT. Same as tokenLookup1.
258
- uint8_t * tokenLookup2 ;
259
-
260
- // OUTPUT. The plugin needs to set this pointer to a 256 bits number in
261
- // pluginContext to display as the amount in UI_AMOUNT_ADDRESS case. IGNORED
262
- // if uiType is UI_AMOUNT_ADDRESS.
263
- const uint8_t * amount ;
264
- // OUTPUT. The plugin needs to set this pointer to a 20 bytes address in
265
- // pluginContext to display as the address in UI_AMOUNT_ADDRESS case.
266
- // IGNORED if uiType is UI_AMOUNT_ADDRESS.
267
- const uint8_t * address ;
248
+ const uint8_t * tokenLookup2 ;
249
+ // Reminder: const applies to the pointed memory area, which means the plugin
250
+ // can set the value and ethereum will modify the pointed value.
268
251
269
252
// OUTPUT. The plugin needs to set this value to either
270
253
// ETH_UI_TYPE_AMOUNT_ADDRESS for an amount/address UI or
271
254
// ETH_UI_TYPE_GENERIC for a generic UI.
272
255
eth_ui_type_t uiType ;
273
-
274
- // OUTPUT. The plugin needs to set this value to the number of screens
275
- // needed to display the smart contract in ETH_UI_TYPE_GENERIC case. IGNORED
276
- // if uiType is UI_AMOUNT_ADDRESS.
277
- uint8_t numScreens ;
256
+ union {
257
+ // OUTPUT. The plugin needs to set this pointer to a 256 bits number in
258
+ // pluginContext to display as the amount in UI_AMOUNT_ADDRESS case.
259
+ // IGNORED if uiType is UI_TYPE_GENERIC.
260
+ const uint8_t * amount ;
261
+ // OUTPUT. The plugin needs to set this value to the number of screens
262
+ // needed to display the smart contract in ETH_UI_TYPE_GENERIC case.
263
+ // IGNORED if uiType is UI_AMOUNT_ADDRESS.
264
+ uint8_t numScreens ;
265
+ };
266
+ // OUTPUT. The plugin needs to set this pointer to a 20 bytes address in
267
+ // pluginContext to display as the address in UI_AMOUNT_ADDRESS case.
268
+ // Set to the user's address if uiType is UI_TYPE_GENERIC
269
+ const uint8_t * address ; // set a pointer to the destination address (in pluginContext) if uiType is UI_AMOUNT_ADDRESS.
278
270
279
271
// OUTPUT. Used by the plugin to inform the Ethereum application of the
280
272
// result of this handle The following return codes are expected, any other
@@ -311,25 +303,26 @@ Adapt and expand it for your use case.
311
303
312
304
// --8<-- [start:handle_provide_token_parameters]
313
305
typedef struct ethPluginProvideInfo_s {
314
- // DEPRECATED, will be removed soon. Do not use.
315
- ethPluginSharedRW_t * pluginSharedRW ;
316
-
306
+ // ===== READ ONLY ===== //
317
307
// INPUT. Transaction data available to the plugin. READ-ONLY.
318
- ethPluginSharedRO_t * pluginSharedRO ;
319
-
320
- // RW INPUT. Contains the semi-persistent RAM space that can be used by the
321
- // plugin in each handle call.
322
- uint8_t * pluginContext ;
308
+ const txContent_t * txContent ;
323
309
324
310
// INPUT. ERC20 token information as requested by tokenLookup1 in
325
311
// handle_finalize. NULL if not found.
326
312
union extraInfo_t * item1 ;
327
313
// INPUT. Same as item1 but for tokenLookup2.
328
314
union extraInfo_t * item2 ;
329
315
316
+ // ===== READ WRITE ===== //
317
+ // RW INPUT. Contains the semi-persistent RAM space that can be used by the
318
+ // plugin in each handle call.
319
+ uint8_t * pluginContext ; // PLUGIN_CONTEXT_SIZE
320
+
321
+ // ===== WRITE ONLY ===== //
330
322
// OUTPUT. Set by the plugin if it needs to display additional screens based
331
323
// on the information received from the token definitions.
332
- uint8_t additionalScreens ;
324
+ uint8_t additionalScreens ; // Used by the plugin if it needs to display additional screens
325
+ // based on the information received from the token definitions.
333
326
334
327
// OUTPUT. Used by the plugin to inform the Ethereum application of the
335
328
// result of this handle The following return codes are expected, any other
@@ -359,25 +352,24 @@ your use case.
359
352
360
353
// --8<-- [start:handle_query_contract_id_parameters]
361
354
typedef struct ethQueryContractID_s {
362
- // DEPRECATED, will be removed soon. Do not use.
363
- ethPluginSharedRW_t * pluginSharedRW ;
364
-
355
+ // ===== READ ONLY ===== //
365
356
// INPUT. Transaction data available to the plugin. READ-ONLY.
366
- ethPluginSharedRO_t * pluginSharedRO ;
357
+ const txContent_t * txContent ;
358
+ // INPUT. Maximum possible name string length
359
+ size_t nameLength ;
360
+ // INPUT. Maximum possible version string length
361
+ size_t versionLength ;
367
362
363
+ // ===== READ WRITE ===== //
368
364
// RW INPUT. Contains the semi-persistent RAM space that can be used by the
369
365
// plugin in each handle call.
370
- uint8_t * pluginContext ;
366
+ uint8_t * pluginContext ; // PLUGIN_CONTEXT_SIZE
371
367
368
+ // ===== WRITE ONLY ===== //
372
369
// OUTPUT. Pointer to the name of the plugin
373
370
char * name ;
374
- // INPUT. Maximum possible name string length
375
- size_t nameLength ;
376
-
377
371
// OUTPUT. Pointer to the version of the plugin
378
372
char * version ;
379
- // INPUT. Maximum possible version string length
380
- size_t versionLength ;
381
373
382
374
// OUTPUT. Used by the plugin to inform the Ethereum application of the
383
375
// result of this handle The following return codes are expected, any other
@@ -405,11 +397,9 @@ your use case.
405
397
406
398
// --8<-- [start:handle_query_contract_ui_parameters]
407
399
typedef struct ethQueryContractUI_s {
408
- // DEPRECATED, will be removed soon. Do not use.
409
- ethPluginSharedRW_t * pluginSharedRW ;
410
-
400
+ // ===== READ ONLY ===== //
411
401
// INPUT. Transaction data available to the plugin. READ-ONLY.
412
- ethPluginSharedRO_t * pluginSharedRO ;
402
+ const txContent_t * txContent ;
413
403
414
404
// INPUT. ERC20 token information as requested by tokenLookup1 in
415
405
// handle_finalize. NULL if not found.
@@ -420,24 +410,25 @@ typedef struct ethQueryContractUI_s {
420
410
// INPUT. String that holds the network ticker
421
411
char network_ticker [MAX_TICKER_LEN ];
422
412
423
- // RW INPUT. Contains the semi-persistent RAM space that can be used by the
424
- // plugin in each handle call.
425
- uint8_t * pluginContext ;
426
-
427
413
// INPUT. Current screen to display.
428
414
uint8_t screenIndex ;
415
+ // INPUT. Maximum possible title length
416
+ size_t titleLength ;
417
+ // INPUT. Maximum possible msg length
418
+ size_t msgLength ;
429
419
420
+ // ===== READ WRITE ===== //
421
+ // RW INPUT. Contains the semi-persistent RAM space that can be used by the
422
+ // plugin in each handle call.
423
+ uint8_t * pluginContext ; // PLUGIN_CONTEXT_SIZE
424
+
425
+ // ===== WRITE ONLY ===== //
430
426
// OUTPUT. Pointer to the first line of the screen, to be filled by the
431
427
// plugin
432
428
char * title ;
433
- // INPUT. Maximum possible title length
434
- size_t titleLength ;
435
-
436
- // OUTPUT. Pointer to the second line of the screen, to be filled by the
429
+ // OUTPUT. Pointer to the second line of he screen, to be filled by the
437
430
// plugin
438
431
char * msg ;
439
- // INPUT. Maximum possible msg length
440
- size_t msgLength ;
441
432
442
433
// OUTPUT. Used by the plugin to inform the Ethereum application of the
443
434
// result of this handle The following return codes are expected, any other
0 commit comments