Skip to content

Commit 44b5a23

Browse files
Fix Wanchain (#615)
* fix Wanchain app sign error * remove redundant path --------- Co-authored-by: zhwir <[email protected]>
1 parent 6389499 commit 44b5a23

File tree

4 files changed

+4
-61
lines changed

4 files changed

+4
-61
lines changed

src/ethUstream.c

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,6 @@ static void processAccessList(txContext_t *context) {
103103
}
104104
}
105105

106-
static void processType(txContext_t *context) {
107-
if (context->currentFieldIsList) {
108-
PRINTF("Invalid type for RLP_TYPE\n");
109-
THROW(EXCEPTION);
110-
}
111-
if (context->currentFieldLength > MAX_INT256) {
112-
PRINTF("Invalid length for RLP_TYPE\n");
113-
THROW(EXCEPTION);
114-
}
115-
if (context->currentFieldPos < context->currentFieldLength) {
116-
uint32_t copySize =
117-
MIN(context->commandLength, context->currentFieldLength - context->currentFieldPos);
118-
copyTxData(context, NULL, copySize);
119-
}
120-
if (context->currentFieldPos == context->currentFieldLength) {
121-
context->currentField++;
122-
context->processingField = false;
123-
}
124-
}
125-
126106
static void processChainID(txContext_t *context) {
127107
if (context->currentFieldIsList) {
128108
PRINTF("Invalid type for RLP_CHAINID\n");
@@ -321,14 +301,6 @@ static bool processEIP1559Tx(txContext_t *context) {
321301
switch (context->currentField) {
322302
case EIP1559_RLP_CONTENT: {
323303
processContent(context);
324-
if ((context->processingFlags & TX_FLAG_TYPE) == 0) {
325-
context->currentField++;
326-
}
327-
break;
328-
}
329-
// This gets hit only by Wanchain
330-
case EIP1559_RLP_TYPE: {
331-
processType(context);
332304
break;
333305
}
334306
case EIP1559_RLP_CHAINID: {
@@ -377,13 +349,6 @@ static bool processEIP2930Tx(txContext_t *context) {
377349
switch (context->currentField) {
378350
case EIP2930_RLP_CONTENT:
379351
processContent(context);
380-
if ((context->processingFlags & TX_FLAG_TYPE) == 0) {
381-
context->currentField++;
382-
}
383-
break;
384-
// This gets hit only by Wanchain
385-
case EIP2930_RLP_TYPE:
386-
processType(context);
387352
break;
388353
case EIP2930_RLP_CHAINID:
389354
processChainID(context);
@@ -420,13 +385,6 @@ static bool processLegacyTx(txContext_t *context) {
420385
switch (context->currentField) {
421386
case LEGACY_RLP_CONTENT:
422387
processContent(context);
423-
if ((context->processingFlags & TX_FLAG_TYPE) == 0) {
424-
context->currentField++;
425-
}
426-
break;
427-
// This gets hit only by Wanchain
428-
case LEGACY_RLP_TYPE:
429-
processType(context);
430388
break;
431389
case LEGACY_RLP_NONCE:
432390
processNonce(context);
@@ -592,16 +550,12 @@ static parserStatus_e processTxInternal(txContext_t *context) {
592550
PRINTF("end of here\n");
593551
}
594552

595-
parserStatus_e processTx(txContext_t *context,
596-
const uint8_t *buffer,
597-
uint32_t length,
598-
uint32_t processingFlags) {
553+
parserStatus_e processTx(txContext_t *context, const uint8_t *buffer, uint32_t length) {
599554
parserStatus_e result;
600555
BEGIN_TRY {
601556
TRY {
602557
context->workBuffer = buffer;
603558
context->commandLength = length;
604-
context->processingFlags = processingFlags;
605559
result = processTxInternal(context);
606560
PRINTF("result: %d\n", result);
607561
}

src/ethUstream.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ typedef enum customStatus_e {
3636

3737
typedef customStatus_e (*ustreamProcess_t)(struct txContext_t *context);
3838

39-
#define TX_FLAG_TYPE 0x01
40-
4139
// First variant of every Tx enum.
4240
#define RLP_NONE 0
4341

@@ -49,7 +47,6 @@ typedef customStatus_e (*ustreamProcess_t)(struct txContext_t *context);
4947
typedef enum rlpLegacyTxField_e {
5048
LEGACY_RLP_NONE = RLP_NONE,
5149
LEGACY_RLP_CONTENT,
52-
LEGACY_RLP_TYPE, // For wanchain
5350
LEGACY_RLP_NONCE,
5451
LEGACY_RLP_GASPRICE,
5552
LEGACY_RLP_STARTGAS,
@@ -65,7 +62,6 @@ typedef enum rlpLegacyTxField_e {
6562
typedef enum rlpEIP2930TxField_e {
6663
EIP2930_RLP_NONE = RLP_NONE,
6764
EIP2930_RLP_CONTENT,
68-
EIP2930_RLP_TYPE, // For wanchain
6965
EIP2930_RLP_CHAINID,
7066
EIP2930_RLP_NONCE,
7167
EIP2930_RLP_GASPRICE,
@@ -80,7 +76,6 @@ typedef enum rlpEIP2930TxField_e {
8076
typedef enum rlpEIP1559TxField_e {
8177
EIP1559_RLP_NONE = RLP_NONE,
8278
EIP1559_RLP_CONTENT,
83-
EIP1559_RLP_TYPE, // For wanchain
8479
EIP1559_RLP_CHAINID,
8580
EIP1559_RLP_NONCE,
8681
EIP1559_RLP_MAX_PRIORITY_FEE_PER_GAS,
@@ -125,7 +120,6 @@ typedef struct txContext_t {
125120
uint32_t rlpBufferPos;
126121
const uint8_t *workBuffer;
127122
uint32_t commandLength;
128-
uint32_t processingFlags;
129123
ustreamProcess_t customProcessor;
130124
txContent_t *content;
131125
void *extra;
@@ -137,10 +131,7 @@ void initTx(txContext_t *context,
137131
txContent_t *content,
138132
ustreamProcess_t customProcessor,
139133
void *extra);
140-
parserStatus_e processTx(txContext_t *context,
141-
const uint8_t *buffer,
142-
uint32_t length,
143-
uint32_t processingFlags);
134+
parserStatus_e processTx(txContext_t *context, const uint8_t *buffer, uint32_t length);
144135
parserStatus_e continueTx(txContext_t *context);
145136
void copyTxData(txContext_t *context, uint8_t *out, uint32_t length);
146137
uint8_t readTxByte(txContext_t *context);

src/network.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ static const network_info_t NETWORK_MAPPING[] = {
5151
{.chain_id = 336, .name = "Shiden", .ticker = "SDN"},
5252
{.chain_id = 369, .name = "PulseChain", .ticker = "PLS"},
5353
{.chain_id = 592, .name = "Astar", .ticker = "ASTR"},
54+
{.chain_id = 888, .name = "Wanchain", .ticker = "WAN"},
5455
{.chain_id = 1030, .name = "Conflux", .ticker = "CFX"},
5556
{.chain_id = 1088, .name = "Metis Andromeda", .ticker = "METIS"},
5657
{.chain_id = 1101, .name = "Polygon zkEVM", .ticker = "ETH"},

src_features/signTx/cmd_signTx.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ void handleSign(uint8_t p1,
6969
PRINTF("Parser not initialized\n");
7070
THROW(0x6985);
7171
}
72-
txResult = processTx(&txContext,
73-
workBuffer,
74-
dataLength,
75-
(chainConfig->chainId == 888 ? TX_FLAG_TYPE : 0)); // Wanchain exception
72+
txResult = processTx(&txContext, workBuffer, dataLength);
7673
switch (txResult) {
7774
case USTREAM_SUSPENDED:
7875
break;

0 commit comments

Comments
 (0)