Skip to content

Commit e164bf6

Browse files
committed
Back out the workaround implemented tor gasPrice on EIP-1159 transactions
1 parent 878c2a9 commit e164bf6

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

Sources/web3swift/Transaction/EIP1559Envelope.swift

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ public struct EIP1559Envelope: EIP2718Envelope {
4141
public var maxFeePerGas: BigUInt
4242
public var accessList: [AccessListEntry] // from EIP-2930
4343

44-
/// EIP-1159 trnsactions do not have a gasPrice parameter
45-
/// However, it appears that some nodes report a gasPrice, even for EIP-1159 transactions
46-
/// thus for a temporary workaround we capture and store gasPrice if initialized from a JSON transaction
47-
/// decided form a node. This is currently needed for Oracle to work
48-
private var gasPrice: BigUInt = 0
49-
5044
// for CustomStringConvertible
5145
public var description: String {
5246
var toReturn = ""
@@ -76,9 +70,6 @@ public struct EIP1559Envelope: EIP2718Envelope {
7670
value: value,
7771
data: data,
7872
gasLimit: gasLimit,
79-
// MARK: workaround for gasPrice coming from nodes for EIP-1159 - this allows Oracle to work for now
80-
gasPrice: gasPrice,
81-
8273
maxFeePerGas: maxFeePerGas,
8374
maxPriorityFeePerGas: maxPriorityFeePerGas,
8475
accessList: accessList
@@ -94,8 +85,6 @@ public struct EIP1559Envelope: EIP2718Envelope {
9485
maxFeePerGas = val.maxFeePerGas ?? maxFeePerGas
9586
maxPriorityFeePerGas = val.maxPriorityFeePerGas ?? maxPriorityFeePerGas
9687
accessList = val.accessList ?? accessList
97-
// MARK: workaround for gasPrice coming from nodes for EIP-1159 - this allows Oracle to work for now
98-
gasPrice = val.gasPrice ?? gasPrice
9988
}
10089
}
10190

@@ -117,8 +106,6 @@ extension EIP1559Envelope {
117106
case v
118107
case r
119108
case s
120-
// MARK: workaround for gasPrice coming from nodes for EIP-1159 - this allows Oracle to work for now
121-
case gasPrice
122109
}
123110

124111
public init?(from decoder: Decoder) throws {
@@ -147,9 +134,6 @@ extension EIP1559Envelope {
147134
self.to = ethAddr
148135
}
149136

150-
// MARK: workaround for gasPrice coming from nodes for EIP-1159 - this allows Oracle to work for now
151-
self.gasPrice = try container.decodeHexIfPresent(BigUInt.self, forKey: .gasPrice) ?? 5000000000
152-
153137
self.value = try container.decodeHexIfPresent(BigUInt.self, forKey: .value) ?? 0
154138
self.maxPriorityFeePerGas = try container.decodeHexIfPresent(BigUInt.self, forKey: .maxPriorityFeePerGas) ?? 0
155139
self.maxFeePerGas = try container.decodeHexIfPresent(BigUInt.self, forKey: .maxFeePerGas) ?? 0
@@ -212,7 +196,7 @@ extension EIP1559Envelope {
212196

213197
// swiftlint:disable force_unwrapping
214198
switch rlpItem[RlpKey.destination.rawValue]!.content {
215-
// swiftlint:enable force_unwrapping
199+
// swiftlint:enable force_unwrapping
216200
case .noItem:
217201
self.to = EthereumAddress.contractDeploymentAddress()
218202
case .data(let addressData):

Sources/web3swift/Transaction/EthereumTransaction.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,7 @@ extension EthereumTransaction {
336336
guard let env = self.envelope as? EIP2930Envelope else { preconditionFailure("Unable to downcast to EIP2930Envelope") }
337337
return env.parameters.gasPrice ?? 0
338338
case .eip1559:
339-
// MARK: workaround for gasPrice coming from nodes for EIP-1159 - this allows Oracle to work for now
340-
guard let env = self.envelope as? EIP1559Envelope else { preconditionFailure("Unable to downcast to EIP1559Envelope") }
341-
return env.parameters.gasPrice ?? 0
342-
// preconditionFailure("EIP1559Envelope has no member gasPrice")
339+
preconditionFailure("EIP1559Envelope has no member gasPrice")
343340
}
344341
}
345342
set(value) {

0 commit comments

Comments
 (0)