Skip to content

Commit ce7bc0d

Browse files
Remove ethPluginSharedRW_t and rename ethPluginSharedRO_t
1 parent 93cd7f1 commit ce7bc0d

File tree

3 files changed

+53
-53
lines changed

3 files changed

+53
-53
lines changed

src/common_utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,15 @@ void getEthAddressFromRawKey(const uint8_t raw_pubkey[static 65],
235235
}
236236

237237
void getEthAddressStringFromRawKey(const uint8_t raw_pubkey[static 65],
238-
char out[static (ADDRESS_LENGTH * 2) + 1],
238+
char out[static(ADDRESS_LENGTH * 2) + 1],
239239
uint64_t chainId) {
240240
uint8_t hashAddress[CX_KECCAK_256_SIZE];
241241
CX_ASSERT(cx_keccak_256_hash(raw_pubkey + 1, 64, hashAddress));
242242
getEthAddressStringFromBinary(hashAddress + 12, out, chainId);
243243
}
244244

245245
bool getEthAddressStringFromBinary(uint8_t *address,
246-
char out[static (ADDRESS_LENGTH * 2) + 1],
246+
char out[static(ADDRESS_LENGTH * 2) + 1],
247247
uint64_t chainId) {
248248
// save some precious stack space
249249
union locals_union {

src/common_utils.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ static const char HEXDIGITS[] = "0123456789abcdef";
4040
* @deprecated
4141
* See format_hex in SDK
4242
*/
43-
DEPRECATED static inline void array_hexstr(char *strbuf, const void *bin, unsigned int len)
44-
{
43+
DEPRECATED static inline void array_hexstr(char *strbuf, const void *bin, unsigned int len) {
4544
// Consider the output buffer is sufficiently large!
4645
format_hex(bin, len, strbuf, (2 * len + 1));
4746
}
@@ -71,11 +70,11 @@ void getEthAddressFromRawKey(const uint8_t raw_pubkey[static 65],
7170
uint8_t out[static ADDRESS_LENGTH]);
7271

7372
void getEthAddressStringFromRawKey(const uint8_t raw_pubkey[static 65],
74-
char out[static (ADDRESS_LENGTH * 2) + 1],
73+
char out[static(ADDRESS_LENGTH * 2) + 1],
7574
uint64_t chainId);
7675

7776
bool getEthAddressStringFromBinary(uint8_t *address,
78-
char out[static (ADDRESS_LENGTH * 2) + 1],
77+
char out[static(ADDRESS_LENGTH * 2) + 1],
7978
uint64_t chainId);
8079

8180
bool getEthDisplayableAddress(uint8_t *in, char *out, size_t out_len, uint64_t chainId);

src/eth_plugin_interface.h

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,6 @@ typedef enum eth_ui_type_e {
7575
} eth_ui_type_t;
7676

7777

78-
// Scratch objects and utilities available to the plugin READ-WRITE
79-
typedef struct ethPluginSharedRW_s {
80-
cx_sha3_t *sha3;
81-
} ethPluginSharedRW_t;
82-
83-
84-
// Transaction data available to the plugin READ-ONLY
85-
typedef struct ethPluginSharedRO_s {
86-
txContent_t *txContent;
87-
} ethPluginSharedRO_t;
88-
89-
9078
// Plugin-only memory allocated by the Ethereum application and used by the plugin.
9179
#define PLUGIN_CONTEXT_SIZE (5 * INT256_LENGTH)
9280
// It is recommended to cast the raw uin8_t array to a structure meaningful for your plugin
@@ -106,30 +94,35 @@ typedef struct ethPluginSharedRO_s {
10694
// Init Contract
10795

10896
typedef struct ethPluginInitContract_s {
97+
// READ ONLY //
10998
eth_plugin_interface_version_t interfaceVersion;
110-
eth_plugin_result_t result;
111-
112-
// in
113-
ethPluginSharedRW_t *pluginSharedRW;
114-
ethPluginSharedRO_t *pluginSharedRO;
115-
uint8_t *pluginContext;
99+
const txContent_t *txContent;
116100
size_t pluginContextLength;
117101
const uint8_t *selector; // 4 bytes selector
118102
size_t dataSize;
119103

104+
// READ WRITE //
105+
uint8_t *pluginContext;
106+
107+
// WRITE ONLY //
108+
eth_plugin_result_t result;
109+
120110
} ethPluginInitContract_t;
121111
// void handle_init_contract(ethPluginInitContract_t *parameters);
122112

123113

124114
// Provide parameter
125115

126116
typedef struct ethPluginProvideParameter_s {
127-
ethPluginSharedRW_t *pluginSharedRW;
128-
ethPluginSharedRO_t *pluginSharedRO;
129-
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
117+
// READ ONLY //
118+
const txContent_t *txContent;
130119
const uint8_t *parameter; // 32 bytes parameter
131120
uint32_t parameterOffset;
132121

122+
// READ WRITE //
123+
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
124+
125+
// WRITE ONLY //
133126
eth_plugin_result_t result;
134127

135128
} ethPluginProvideParameter_t;
@@ -139,19 +132,22 @@ typedef struct ethPluginProvideParameter_s {
139132
// Finalize
140133

141134
typedef struct ethPluginFinalize_s {
142-
ethPluginSharedRW_t *pluginSharedRW;
143-
ethPluginSharedRO_t *pluginSharedRO;
144-
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
135+
// READ ONLY //
136+
const txContent_t *txContent;
145137

146-
uint8_t *tokenLookup1; // set by the plugin if a token should be looked up
147-
uint8_t *tokenLookup2;
148-
149-
const uint8_t *amount; // set an uint256 pointer if uiType is UI_AMOUNT_ADDRESS
150-
const uint8_t *address; // set to the destination address if uiType is UI_AMOUNT_ADDRESS. Set
151-
// to the user's address if uiType is UI_TYPE_GENERIC
138+
// READ WRITE //
139+
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
152140

141+
// WRITE ONLY //
142+
const uint8_t *tokenLookup1; // set by the plugin if a token should be looked up
143+
const uint8_t *tokenLookup2;
153144
eth_ui_type_t uiType;
154-
uint8_t numScreens; // ignored if uiType is UI_AMOUNT_ADDRESS
145+
union {
146+
const uint8_t *amount; // set a pointer to the amount (in pluginContext) if uiType is UI_AMOUNT_ADDRESS
147+
uint8_t numScreens; // set the number of screens to query if uiType is UI_TYPE_GENERIC
148+
};
149+
const uint8_t *address; // set a pointer to the destination address (in pluginContext) if uiType is UI_AMOUNT_ADDRESS. Set
150+
// to the user's address if uiType is UI_TYPE_GENERIC
155151
eth_plugin_result_t result;
156152

157153
} ethPluginFinalize_t;
@@ -161,16 +157,17 @@ typedef struct ethPluginFinalize_s {
161157
// Provide token
162158

163159
typedef struct ethPluginProvideInfo_s {
164-
ethPluginSharedRW_t *pluginSharedRW;
165-
ethPluginSharedRO_t *pluginSharedRO;
166-
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
167-
160+
// READ ONLY //
161+
const txContent_t *txContent;
168162
union extraInfo_t *item1; // set by the ETH application, to be saved by the plugin
169163
union extraInfo_t *item2;
170164

165+
// READ WRITE //
166+
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
167+
168+
// WRITE ONLY //
171169
uint8_t additionalScreens; // Used by the plugin if it needs to display additional screens
172170
// based on the information received from the token definitions.
173-
174171
eth_plugin_result_t result;
175172

176173
} ethPluginProvideInfo_t;
@@ -182,15 +179,17 @@ typedef struct ethPluginProvideInfo_s {
182179
// This is always called on the non aliased contract
183180

184181
typedef struct ethQueryContractID_s {
185-
ethPluginSharedRW_t *pluginSharedRW;
186-
ethPluginSharedRO_t *pluginSharedRO;
182+
// READ ONLY //
183+
const txContent_t *txContent;
184+
size_t nameLength;
185+
size_t versionLength;
186+
187+
// READ WRITE //
187188
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
188189

190+
// WRITE ONLY //
189191
char *name;
190-
size_t nameLength;
191192
char *version;
192-
size_t versionLength;
193-
194193
eth_plugin_result_t result;
195194

196195
} ethQueryContractID_t;
@@ -200,19 +199,21 @@ typedef struct ethQueryContractID_s {
200199
// Query Contract UI
201200

202201
typedef struct ethQueryContractUI_s {
203-
ethPluginSharedRW_t *pluginSharedRW;
204-
ethPluginSharedRO_t *pluginSharedRO;
202+
// READ ONLY //
203+
const txContent_t *txContent;
205204
union extraInfo_t *item1;
206205
union extraInfo_t *item2;
207206
char network_ticker[MAX_TICKER_LEN];
208-
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
209207
uint8_t screenIndex;
210-
211-
char *title;
212208
size_t titleLength;
213-
char *msg;
214209
size_t msgLength;
215210

211+
// READ WRITE //
212+
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
213+
214+
// WRITE ONLY //
215+
char *title;
216+
char *msg;
216217
eth_plugin_result_t result;
217218

218219
} ethQueryContractUI_t;

0 commit comments

Comments
 (0)