Skip to content

Commit ca9d5c9

Browse files
Remove data needed by plugins from shared_context file
1 parent 3d9da0d commit ca9d5c9

File tree

9 files changed

+55
-21
lines changed

9 files changed

+55
-21
lines changed

src/caller_api.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*******************************************************************************
2+
* Ledger Ethereum App
3+
* (c) 2016-2019 Ledger
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
********************************************************************************/
17+
18+
#pragma once
19+
20+
#ifdef HAVE_NBGL
21+
#include "ux.h"
22+
#endif
23+
24+
typedef enum { CALLER_TYPE_CLONE, CALLER_TYPE_PLUGIN } e_caller_type;
25+
26+
typedef struct caller_app_t {
27+
const char *name;
28+
#ifdef HAVE_NBGL
29+
const nbgl_icon_details_t *icon;
30+
#endif
31+
char type; // does not have to be set by the caller app
32+
} caller_app_t;
33+
34+
extern caller_app_t *caller_app;

src/eth_plugin_interface.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "os.h"
77
#include "cx.h"
88
#include "tokens.h"
9-
#include "shared_context.h"
109

1110
/*************************************************************************************************
1211
* Comments provided in this file are quick reminders on the usage of the plugin interface *

src/extra_info.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include "tokens.h"
4+
#include "nft.h"
5+
6+
typedef union extraInfo_t {
7+
tokenDefinition_t token;
8+
nftInfo_t nft;
9+
} extraInfo_t;

src/shared_context.h

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33

44
#include <stdbool.h>
55
#include <stdint.h>
6+
7+
#include "os.h"
8+
#include "cx.h"
69
#include "ethUstream.h"
710
#include "tokens.h"
11+
#include "extra_info.h"
12+
#include "tx_content.h"
813
#include "chainConfig.h"
914
#include "nft.h"
1015
#ifdef HAVE_NBGL
@@ -13,8 +18,6 @@
1318

1419
#define MAX_BIP32_PATH 10
1520

16-
#define WEI_TO_ETHER 18
17-
1821
#define SELECTOR_LENGTH 4
1922

2023
#define PLUGIN_ID_LENGTH 30
@@ -95,11 +98,6 @@ typedef struct publicKeyContext_t {
9598
bool getChaincode;
9699
} publicKeyContext_t;
97100

98-
typedef union extraInfo_t {
99-
tokenDefinition_t token;
100-
nftInfo_t nft;
101-
} extraInfo_t;
102-
103101
typedef struct transactionContext_t {
104102
bip32_path_t bip32;
105103
uint8_t hash[INT256_LENGTH];
@@ -226,16 +224,6 @@ typedef enum {
226224

227225
extern pluginType_t pluginType;
228226

229-
typedef enum { CALLER_TYPE_CLONE, CALLER_TYPE_PLUGIN } e_caller_type;
230-
231-
typedef struct caller_app_t {
232-
const char *name;
233-
#ifdef HAVE_NBGL
234-
const nbgl_icon_details_t *icon;
235-
#endif
236-
char type; // does not have to be set by the caller app
237-
} caller_app_t;
238-
239227
extern uint8_t appState;
240228
#ifdef HAVE_STARKWARE
241229
extern bool quantumSet;
@@ -244,8 +232,6 @@ extern bool quantumSet;
244232
extern uint32_t eth2WithdrawalIndex;
245233
#endif
246234

247-
extern caller_app_t *caller_app;
248-
249235
void reset_app_context(void);
250236
const uint8_t *parseBip32(const uint8_t *dataBuffer, uint8_t *dataLength, bip32_path_t *bip32);
251237

src/swap_lib_calls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "chainConfig.h"
1111
#include "shared_context.h"
1212
#include "stdint.h"
13+
#include "caller_api.h"
1314

1415
#define RUN_APPLICATION 1
1516

src/utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "cx.h"
2525
#include "uint256.h"
2626

27+
#define WEI_TO_ETHER 18
28+
2729
#define ADDRESS_LENGTH 20
2830
#define INT128_LENGTH 16
2931
#define INT256_LENGTH 32

src_nbgl/ui_approve_tx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "ui_signing.h"
77
#include "plugins.h"
88
#include "domain_name.h"
9+
#include "caller_api.h"
910
#include "network_icons.h"
1011
#include "network.h"
1112

src_nbgl/ui_idle.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "ui_nbgl.h"
44
#include "nbgl_use_case.h"
55
#include "glyphs.h"
6+
#include "caller_api.h"
67
#include "network.h"
78

89
char g_stax_shared_buffer[SHARED_BUFFER_SIZE] = {0};

tools/build_sdk.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,10 @@ def merge_c_files(sources, nodes_to_extract):
157157
"src/tokens.h",
158158
"src/utils.h",
159159
"src/tx_content.h",
160-
"src/shared_context.h",
161160
"src/eth_plugin_internal.h",
162161
"src/nft.h",
162+
"src/extra_info.h",
163+
"src/caller_api.h",
163164
]
164165
nodes_to_extract = {
165166
"#define": ["MAX_TICKER_LEN",

0 commit comments

Comments
 (0)