Skip to content

Commit 2e204b4

Browse files
Remove ethPluginSharedRW_t and rename ethPluginSharedRO_t
1 parent 8e2907f commit 2e204b4

File tree

1 file changed

+79
-88
lines changed

1 file changed

+79
-88
lines changed

src/eth_plugin_interface.h

Lines changed: 79 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,6 @@ typedef enum eth_ui_type_e {
7777
ETH_UI_TYPE_GENERIC = 0x02,
7878
} eth_ui_type_t;
7979

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-
9080
// --8<-- [start:plugin_context]
9181
// Plugin-only memory allocated by the Ethereum application and used by the
9282
// plugin. 1k memory is available.
@@ -126,27 +116,13 @@ adapt for your use case.
126116

127117
// --8<-- [start:handle_init_contract_parameters]
128118
typedef struct ethPluginInitContract_s {
119+
// ===== READ ONLY ===== //
129120
// INPUT. Used to check that `ETH_PLUGIN_INTERFACE_VERSION_LATEST` is
130121
// correct.
131122
eth_plugin_interface_version_t interfaceVersion;
132123

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-
144124
// 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;
150126

151127
// INPUT. Size of context allocated by the Ethereum application, must be
152128
// equal to PLUGIN_CONTEXT_SIZE.
@@ -160,6 +136,20 @@ typedef struct ethPluginInitContract_s {
160136
size_t dataSize;
161137
bip32_path_t *bip32;
162138

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+
163153
} ethPluginInitContract_t;
164154
// --8<-- [end:handle_init_contract_parameters]
165155

@@ -183,15 +173,9 @@ Adapt and expand it for your use case.
183173

184174
// --8<-- [start:handle_provide_parameter_parameters]
185175
typedef struct ethPluginProvideParameter_s {
186-
// DEPRECATED, will be removed soon. Do not use.
187-
ethPluginSharedRW_t *pluginSharedRW;
188-
176+
// ===== READ ONLY ===== //
189177
// 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;
195179

196180
// INPUT. Pointer to the 32 bytes parameter being parsed in the smart
197181
// contract data.
@@ -201,6 +185,12 @@ typedef struct ethPluginProvideParameter_s {
201185
// (starts at 4, following the selector).
202186
uint32_t parameterOffset;
203187

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 ===== //
204194
// OUTPUT. Used by the plugin to inform the Ethereum application of the
205195
// result of this handle The following return codes are expected, any other
206196
// will abort the signing process:
@@ -237,44 +227,46 @@ boilerplate plugin. Adapt and expand it for your use case.
237227

238228
// --8<-- [start:handle_finalize_parameters]
239229
typedef struct ethPluginFinalize_s {
240-
// DEPRECATED, will be removed soon. Do not use.
241-
ethPluginSharedRW_t *pluginSharedRW;
242-
230+
// ===== READ ONLY ===== //
243231
// INPUT. Transaction data available to the plugin. READ-ONLY.
244-
ethPluginSharedRO_t *pluginSharedRO;
232+
const txContent_t *txContent;
245233

234+
// ===== READ WRITE ===== //
246235
// RW INPUT. Contains the semi-persistent RAM space that can be used by the
247236
// plugin in each handle call.
248-
uint8_t *pluginContext;
237+
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
249238

239+
// ===== WRITE ONLY ===== //
250240
// OUTPUT. The plugin can set this value to a 20 bytes array in
251241
// pluginContext containing the address of an ERC20 token. In this case
252242
// Ethereum will call the plugin with handle_provide_token() with the
253243
// requested ERC20 token information. The Ethereum application must be made
254244
// aware of ERC20 token information first using 'PROVIDE ERC 20 TOKEN
255245
// INFORMATION' APDU. Leave the value at NULL if not needed
256-
uint8_t *tokenLookup1;
246+
const uint8_t *tokenLookup1;
257247
// 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.
268251

269252
// OUTPUT. The plugin needs to set this value to either
270253
// ETH_UI_TYPE_AMOUNT_ADDRESS for an amount/address UI or
271254
// ETH_UI_TYPE_GENERIC for a generic UI.
272255
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.
278270

279271
// OUTPUT. Used by the plugin to inform the Ethereum application of the
280272
// result of this handle The following return codes are expected, any other
@@ -311,25 +303,26 @@ Adapt and expand it for your use case.
311303

312304
// --8<-- [start:handle_provide_token_parameters]
313305
typedef struct ethPluginProvideInfo_s {
314-
// DEPRECATED, will be removed soon. Do not use.
315-
ethPluginSharedRW_t *pluginSharedRW;
316-
306+
// ===== READ ONLY ===== //
317307
// 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;
323309

324310
// INPUT. ERC20 token information as requested by tokenLookup1 in
325311
// handle_finalize. NULL if not found.
326312
union extraInfo_t *item1;
327313
// INPUT. Same as item1 but for tokenLookup2.
328314
union extraInfo_t *item2;
329315

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 ===== //
330322
// OUTPUT. Set by the plugin if it needs to display additional screens based
331323
// 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.
333326

334327
// OUTPUT. Used by the plugin to inform the Ethereum application of the
335328
// result of this handle The following return codes are expected, any other
@@ -359,25 +352,24 @@ your use case.
359352

360353
// --8<-- [start:handle_query_contract_id_parameters]
361354
typedef struct ethQueryContractID_s {
362-
// DEPRECATED, will be removed soon. Do not use.
363-
ethPluginSharedRW_t *pluginSharedRW;
364-
355+
// ===== READ ONLY ===== //
365356
// 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;
367362

363+
// ===== READ WRITE ===== //
368364
// RW INPUT. Contains the semi-persistent RAM space that can be used by the
369365
// plugin in each handle call.
370-
uint8_t *pluginContext;
366+
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
371367

368+
// ===== WRITE ONLY ===== //
372369
// OUTPUT. Pointer to the name of the plugin
373370
char *name;
374-
// INPUT. Maximum possible name string length
375-
size_t nameLength;
376-
377371
// OUTPUT. Pointer to the version of the plugin
378372
char *version;
379-
// INPUT. Maximum possible version string length
380-
size_t versionLength;
381373

382374
// OUTPUT. Used by the plugin to inform the Ethereum application of the
383375
// result of this handle The following return codes are expected, any other
@@ -405,11 +397,9 @@ your use case.
405397

406398
// --8<-- [start:handle_query_contract_ui_parameters]
407399
typedef struct ethQueryContractUI_s {
408-
// DEPRECATED, will be removed soon. Do not use.
409-
ethPluginSharedRW_t *pluginSharedRW;
410-
400+
// ===== READ ONLY ===== //
411401
// INPUT. Transaction data available to the plugin. READ-ONLY.
412-
ethPluginSharedRO_t *pluginSharedRO;
402+
const txContent_t *txContent;
413403

414404
// INPUT. ERC20 token information as requested by tokenLookup1 in
415405
// handle_finalize. NULL if not found.
@@ -420,24 +410,25 @@ typedef struct ethQueryContractUI_s {
420410
// INPUT. String that holds the network ticker
421411
char network_ticker[MAX_TICKER_LEN];
422412

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-
427413
// INPUT. Current screen to display.
428414
uint8_t screenIndex;
415+
// INPUT. Maximum possible title length
416+
size_t titleLength;
417+
// INPUT. Maximum possible msg length
418+
size_t msgLength;
429419

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 ===== //
430426
// OUTPUT. Pointer to the first line of the screen, to be filled by the
431427
// plugin
432428
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
437430
// plugin
438431
char *msg;
439-
// INPUT. Maximum possible msg length
440-
size_t msgLength;
441432

442433
// OUTPUT. Used by the plugin to inform the Ethereum application of the
443434
// result of this handle The following return codes are expected, any other

0 commit comments

Comments
 (0)