Skip to content

Commit 4e4ae26

Browse files
committed
did modify gasEstimate according policy
1 parent 5484e81 commit 4e4ae26

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Sources/web3swift/Promises/Promise+Web3+Eth+EstimateGas.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,22 @@ extension web3.Eth {
2424
}
2525
throw Web3Error.nodeError(desc: "Invalid value from Ethereum node")
2626
}
27-
return value
27+
28+
if let policy = transactionOptions?.gasLimit {
29+
switch policy {
30+
case .automatic:
31+
return value
32+
case .limited(let limitValue):
33+
return limitValue < value ? limitValue: value
34+
case .manual(let exactValue):
35+
return exactValue
36+
case .withMargin:
37+
// MARK: - update value according margin
38+
return value
39+
}
40+
} else {
41+
return value
42+
}
2843
}
2944
} catch {
3045
let returnPromise = Promise<BigUInt>.pending()

0 commit comments

Comments
 (0)