@@ -23,7 +23,7 @@ public enum TransactionType {
23
23
/**
24
24
* A standard transaction available in Ethereum from the beginning
25
25
*/
26
- STANDARD (( byte )- 1 ),
26
+ STANDARD (null ),
27
27
28
28
/**
29
29
* Transaction with Access List introduced by EIP-2930 and available since Berlin Fork of Ethereum Mainnet.
@@ -42,9 +42,9 @@ public enum TransactionType {
42
42
*/
43
43
BLOB ((byte )3 );
44
44
45
- private final byte flag ;
45
+ private final Byte flag ;
46
46
47
- TransactionType (byte flag ) {
47
+ TransactionType (Byte flag ) {
48
48
this .flag = flag ;
49
49
}
50
50
@@ -83,11 +83,27 @@ public static TransactionType fromPrefix(byte prefix) {
83
83
throw new IllegalArgumentException ("Unsupported type: 0x" + Integer .toHexString (u ));
84
84
}
85
85
86
- public byte getFlag () {
86
+ public static TransactionType fromTransaction (Transaction tx ) {
87
+ return tx .getType ();
88
+ }
89
+
90
+ /**
91
+ * A byte to prepend to the transaction when encode in Raw
92
+ *
93
+ * @return the byte for EIP-2718 type, or null for other transactions
94
+ */
95
+ public Byte getFlag () {
87
96
return flag ;
88
97
}
89
98
90
- public boolean isFlagPrefixed () {
91
- return this == STANDARD ;
99
+ /**
100
+ * Check if this type is actually an EIP-2718 type (which also means it's a part of the Raw Transaction, etc.).
101
+ * I.e. the Legacy / Standard transaction is not an EIP-2718 type, but all other types are.
102
+ *
103
+ * @see <a href="https://eips.ethereum.org/EIPS/eip-2718">EIP-2718</a>
104
+ * @return true if this type is an EIP-2718 type
105
+ */
106
+ public boolean is2718 () {
107
+ return this != STANDARD ;
92
108
}
93
109
}
0 commit comments