-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
102 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "eth_data.h" | ||
#include <string.h> | ||
|
||
#define ETH_ERC20_TRANSFER_SIGNATURE_LEN 16 | ||
#define ETH_ERC20_TRANSFER_LEN 68 | ||
|
||
const uint8_t ETH_ERC20_TRANSFER_SIGNATURE[] = { | ||
0xa9, 0x05, 0x9c, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
}; | ||
|
||
eth_data_type_t eth_data_recognize(const txContent_t* tx) { | ||
if (tx->dataLength == 0) { | ||
return ETH_DATA_ABSENT; | ||
} else if (tx->value.length == 0 && (tx->dataLength == ETH_ERC20_TRANSFER_LEN) && !memcmp(tx->data, ETH_ERC20_TRANSFER_SIGNATURE, ETH_ERC20_TRANSFER_SIGNATURE_LEN)) { | ||
return ETH_DATA_ERC20_TRANSFER; | ||
} else { | ||
return ETH_DATA_UNKNOWN; | ||
} | ||
} | ||
|
||
eip712_data_type_t eip712_recognize(const eip712_ctx_t* msg) { | ||
return EIP712_UNKNOWN; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef __ETH_DATA__ | ||
#define __ETH_DATA__ | ||
|
||
#include <stddef.h> | ||
#include "ethUstream.h" | ||
#include "eip712.h" | ||
|
||
typedef enum { | ||
ETH_DATA_ABSENT, | ||
ETH_DATA_UNKNOWN, | ||
ETH_DATA_ERC20_TRANSFER | ||
} eth_data_type_t; | ||
|
||
typedef enum { | ||
EIP712_UNKNOWN, | ||
EIP712_PERMIT, | ||
} eip712_data_type_t; | ||
|
||
#define ETH_ERC20_ADDR_OFF 16 | ||
#define ETH_ERC20_VALUE_OFF 36 | ||
|
||
eth_data_type_t eth_data_recognize(const txContent_t* tx); | ||
eip712_data_type_t eip712_recognize(const eip712_ctx_t* msg); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters