@@ -13,13 +13,13 @@ import
1313
1414func encodeTransactionLegacy (s: TransactionArgs , pk: PrivateKey ): seq [byte ] =
1515 var tr = Transaction (txType: TxLegacy )
16- tr.gasLimit = s.gas.get.GasInt
17- tr.gasPrice = s.gasPrice.get.GasInt
16+ tr.gasLimit = s.gas.get ( 0 . Quantity ) .GasInt
17+ tr.gasPrice = s.gasPrice.get ( 0 . Quantity ) .GasInt
1818 tr.to = s.to
1919
2020 if s.value.isSome:
21- tr.value = s.value.get
22- tr.nonce = uint64 (s.nonce.get)
21+ tr.value = s.value.value
22+ tr.nonce = uint64 (s.nonce.get ( 0 . Quantity ) )
2323 tr.payload = s.payload
2424 tr.signature =
2525 if s.chainId.isSome ():
@@ -31,67 +31,84 @@ func encodeTransactionLegacy(s: TransactionArgs, pk: PrivateKey): seq[byte] =
3131
3232func encodeTransactionEip2930 (s: TransactionArgs , pk: PrivateKey ): seq [byte ] =
3333 var tr = Transaction (txType: TxEip2930 )
34- tr.gasLimit = s.gas.get.GasInt
35- tr.gasPrice = s.gasPrice.get.GasInt
34+ tr.gasLimit = s.gas.get ( 0 . Quantity ) .GasInt
35+ tr.gasPrice = s.gasPrice.get ( 0 . Quantity ) .GasInt
3636 tr.to = s.to
3737 if s.value.isSome:
38- tr.value = s.value.get
39- tr.nonce = uint64 (s.nonce.get)
38+ tr.value = s.value.value
39+ tr.nonce = uint64 (s.nonce.get ( 0 . Quantity ) )
4040 tr.payload = s.payload
4141 tr.chainId = s.chainId.get
4242 tr.signature = tr.sign (pk, true )
43- tr.accessList = s.accessList.get
43+ tr.accessList = s.accessList.value
4444 rlp.encode (tr)
4545
4646func encodeTransactionEip1559 (s: TransactionArgs , pk: PrivateKey ): seq [byte ] =
4747 var tr = Transaction (txType: TxEip1559 )
48- tr.gasLimit = s.gas.get.GasInt
49- tr.maxPriorityFeePerGas = s.maxPriorityFeePerGas.get.GasInt
50- tr.maxFeePerGas = s.maxFeePerGas.get.GasInt
48+ tr.gasLimit = s.gas.get ( 0 . Quantity ) .GasInt
49+ tr.maxPriorityFeePerGas = s.maxPriorityFeePerGas.get ( 0 . Quantity ) .GasInt
50+ tr.maxFeePerGas = s.maxFeePerGas.get ( 0 . Quantity ) .GasInt
5151 tr.to = s.to
5252 if s.value.isSome:
53- tr.value = s.value.get
54- tr.nonce = uint64 (s.nonce.get)
53+ tr.value = s.value.value
54+ tr.nonce = uint64 (s.nonce.get ( 0 . Quantity ) )
5555 tr.payload = s.payload
56- tr.chainId = s.chainId.get
56+ tr.chainId = s.chainId.get ( 0 .u256)
5757 tr.signature = tr.sign (pk, true )
5858 if s.accessList.isSome:
59- tr.accessList = s.accessList.get
59+ tr.accessList = s.accessList.value
6060 rlp.encode (tr)
6161
6262func encodeTransactionEip4844 (s: TransactionArgs , pk: PrivateKey ): seq [byte ] =
6363 var tr = Transaction (txType: TxEip4844 )
64- tr.gasLimit = s.gas.get.GasInt
65- tr.maxPriorityFeePerGas = s.maxPriorityFeePerGas.get.GasInt
66- tr.maxFeePerGas = s.maxFeePerGas.get.GasInt
64+ tr.gasLimit = s.gas.get ( 0 . Quantity ) .GasInt
65+ tr.maxPriorityFeePerGas = s.maxPriorityFeePerGas.get ( 0 . Quantity ) .GasInt
66+ tr.maxFeePerGas = s.maxFeePerGas.get ( 0 . Quantity ) .GasInt
6767 tr.to = s.to
6868 if s.value.isSome:
69- tr.value = s.value.get
70- tr.nonce = uint64 (s.nonce.get)
69+ tr.value = s.value.value
70+ tr.nonce = uint64 (s.nonce.get ( 0 . Quantity ) )
7171 tr.payload = s.payload
72- tr.chainId = s.chainId.get
72+ tr.chainId = s.chainId.get ( 0 .u256)
7373 tr.signature = tr.sign (pk, true )
7474 if s.accessList.isSome:
75- tr.accessList = s.accessList.get
76- tr.maxFeePerBlobGas = s.maxFeePerBlobGas.get
77- tr.versionedHashes = s.blobVersionedHashes.get
75+ tr.accessList = s.accessList.value
76+ tr.maxFeePerBlobGas = s.maxFeePerBlobGas.get ( 0 .u256)
77+ tr.versionedHashes = s.blobVersionedHashes.value
7878 rlp.encode (tr)
7979
8080func encodeTransactionEip7702 (s: TransactionArgs , pk: PrivateKey ): seq [byte ] =
8181 var tr = Transaction (txType: TxEip7702 )
82- tr.gasLimit = s.gas.get.GasInt
83- tr.maxPriorityFeePerGas = s.maxPriorityFeePerGas.get.GasInt
84- tr.maxFeePerGas = s.maxFeePerGas.get.GasInt
82+ tr.gasLimit = s.gas.get ( 0 . Quantity ) .GasInt
83+ tr.maxPriorityFeePerGas = s.maxPriorityFeePerGas.get ( 0 . Quantity ) .GasInt
84+ tr.maxFeePerGas = s.maxFeePerGas.get ( 0 . Quantity ) .GasInt
8585 tr.to = s.to
8686 if s.value.isSome:
87- tr.value = s.value.get
88- tr.nonce = uint64 (s.nonce.get)
87+ tr.value = s.value.value
88+ tr.nonce = uint64 (s.nonce.get ( 0 . Quantity ) )
8989 tr.payload = s.payload
90- tr.chainId = s.chainId.get
90+ tr.chainId = s.chainId.get (0 .u256)
91+ tr.signature = tr.sign (pk, true )
92+ if s.accessList.isSome:
93+ tr.accessList = s.accessList.value
94+ tr.authorizationList = s.authorizationList.value
95+ rlp.encode (tr)
96+
97+ func encodeTransactionEip7873 (s: TransactionArgs , pk: PrivateKey ): seq [byte ] =
98+ var tr = Transaction (txType: TxEip7873 )
99+ tr.gasLimit = s.gas.get (0 .Quantity ).GasInt
100+ tr.maxPriorityFeePerGas = s.maxPriorityFeePerGas.get (0 .Quantity ).GasInt
101+ tr.maxFeePerGas = s.maxFeePerGas.get (0 .Quantity ).GasInt
102+ tr.to = s.to
103+ if s.value.isSome:
104+ tr.value = s.value.value
105+ tr.nonce = uint64 (s.nonce.get (0 .Quantity ))
106+ tr.payload = s.payload
107+ tr.chainId = s.chainId.get (0 .u256)
91108 tr.signature = tr.sign (pk, true )
92109 if s.accessList.isSome:
93- tr.accessList = s.accessList.get
94- tr.authorizationList = s.authorizationList.get
110+ tr.accessList = s.accessList.value
111+ tr.initCodes = s.initCodes.value
95112 rlp.encode (tr)
96113
97114func encodeTransaction * (s: TransactionArgs , pk: PrivateKey , txType: TxType ): seq [byte ] =
@@ -106,8 +123,12 @@ func encodeTransaction*(s: TransactionArgs, pk: PrivateKey, txType: TxType): seq
106123 encodeTransactionEip4844 (s, pk)
107124 of TxEip7702 :
108125 encodeTransactionEip7702 (s, pk)
126+ of TxEip7873 :
127+ encodeTransactionEip7873 (s, pk)
109128
110129func txType (s: TransactionArgs ): TxType =
130+ if s.initCodes.isSome:
131+ return TxEip7873
111132 if s.authorizationList.isSome:
112133 return TxEip7702
113134 if s.blobVersionedHashes.isSome:
0 commit comments