Extract data needed by plugin from ethUstream.h
This commit is contained in:
@@ -15,14 +15,15 @@
|
||||
* limitations under the License.
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef _ETHUSTREAM_H_
|
||||
#define _ETHUSTREAM_H_
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "os.h"
|
||||
#include "cx.h"
|
||||
#include "utils.h"
|
||||
#include "tx_content.h"
|
||||
|
||||
struct txContext_t;
|
||||
|
||||
@@ -35,10 +36,7 @@ typedef enum customStatus_e {
|
||||
|
||||
typedef customStatus_e (*ustreamProcess_t)(struct txContext_t *context);
|
||||
|
||||
#define TX_FLAG_TYPE 0x01
|
||||
#define ADDRESS_LENGTH 20
|
||||
#define INT128_LENGTH 16
|
||||
#define INT256_LENGTH 32
|
||||
#define TX_FLAG_TYPE 0x01
|
||||
|
||||
// First variant of every Tx enum.
|
||||
#define RLP_NONE 0
|
||||
@@ -114,24 +112,6 @@ typedef enum parserStatus_e {
|
||||
USTREAM_CONTINUE // Used internally to signify we can keep on parsing
|
||||
} parserStatus_e;
|
||||
|
||||
typedef struct txInt256_t {
|
||||
uint8_t value[INT256_LENGTH];
|
||||
uint8_t length;
|
||||
} txInt256_t;
|
||||
|
||||
typedef struct txContent_t {
|
||||
txInt256_t gasprice; // Used as MaxFeePerGas when dealing with EIP1559 transactions.
|
||||
txInt256_t startgas; // Also known as `gasLimit`.
|
||||
txInt256_t value;
|
||||
txInt256_t nonce;
|
||||
txInt256_t chainID;
|
||||
uint8_t destination[ADDRESS_LENGTH];
|
||||
uint8_t destinationLength;
|
||||
uint8_t v[8];
|
||||
uint8_t vLength;
|
||||
bool dataPresent;
|
||||
} txContent_t;
|
||||
|
||||
typedef struct txContext_t {
|
||||
uint8_t currentField;
|
||||
cx_sha3_t *sha3;
|
||||
@@ -164,5 +144,3 @@ parserStatus_e processTx(txContext_t *context,
|
||||
parserStatus_e continueTx(txContext_t *context);
|
||||
void copyTxData(txContext_t *context, uint8_t *out, uint32_t length);
|
||||
uint8_t readTxByte(txContext_t *context);
|
||||
|
||||
#endif // _ETHUSTREAM_H_
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "os.h"
|
||||
#include "cx.h"
|
||||
#include "ethUstream.h"
|
||||
#include "tokens.h"
|
||||
#include "shared_context.h"
|
||||
|
||||
|
||||
43
src/tx_content.h
Normal file
43
src/tx_content.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*******************************************************************************
|
||||
* Ledger Ethereum App
|
||||
* (c) 2016-2019 Ledger
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "os.h"
|
||||
#include "cx.h"
|
||||
#include "utils.h"
|
||||
|
||||
typedef struct txInt256_t {
|
||||
uint8_t value[INT256_LENGTH];
|
||||
uint8_t length;
|
||||
} txInt256_t;
|
||||
|
||||
typedef struct txContent_t {
|
||||
txInt256_t gasprice; // Used as MaxFeePerGas when dealing with EIP1559 transactions.
|
||||
txInt256_t startgas; // Also known as `gasLimit`.
|
||||
txInt256_t value;
|
||||
txInt256_t nonce;
|
||||
txInt256_t chainID;
|
||||
uint8_t destination[ADDRESS_LENGTH];
|
||||
uint8_t destinationLength;
|
||||
uint8_t v[8];
|
||||
uint8_t vLength;
|
||||
bool dataPresent;
|
||||
} txContent_t;
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ethUstream.h"
|
||||
#include "ethUtils.h"
|
||||
#include "uint128.h"
|
||||
#include "uint256.h"
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
|
||||
#include "uint256.h"
|
||||
|
||||
#define ADDRESS_LENGTH 20
|
||||
#define INT128_LENGTH 16
|
||||
#define INT256_LENGTH 32
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
void array_hexstr(char* strbuf, const void* bin, unsigned int len);
|
||||
|
||||
@@ -156,7 +156,7 @@ if __name__ == "__main__":
|
||||
headers_to_merge = [
|
||||
"src/tokens.h",
|
||||
"src/utils.h",
|
||||
"src/ethUstream.h",
|
||||
"src/tx_content.h",
|
||||
"src/ethUtils.h",
|
||||
"src/shared_context.h",
|
||||
"src/eth_plugin_internal.h",
|
||||
|
||||
Reference in New Issue
Block a user