Skip to content

Commit 2324680

Browse files
committed
[TIDY] API for function -> transaction
1 parent 9250e53 commit 2324680

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

web3swift/src/Contract/Statically Typed/ABIFunction.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,22 @@ public protocol ABIFunction {
2121
public protocol ABIResponse: ABITupleDecodable {}
2222

2323
extension ABIFunction {
24-
public func transaction(gasPrice: BigUInt? = nil, gasLimit: BigUInt? = nil) throws -> EthereumTransaction {
24+
public func transaction(
25+
value: BigUInt? = nil,
26+
gasPrice: BigUInt? = nil,
27+
gasLimit: BigUInt? = nil
28+
) throws -> EthereumTransaction {
2529
let encoder = ABIFunctionEncoder(Self.name)
2630
try self.encode(to: encoder)
2731
let data = try encoder.encoded()
28-
29-
return EthereumTransaction(from: from, to: contract, data: data, gasPrice: self.gasPrice ?? gasPrice ?? BigUInt(0), gasLimit: self.gasLimit ?? gasLimit ?? BigUInt(0))
32+
33+
return EthereumTransaction(
34+
from: from,
35+
to: contract,
36+
value: value ?? 0,
37+
data: data,
38+
gasPrice: self.gasPrice ?? gasPrice ?? 0,
39+
gasLimit: self.gasLimit ?? gasLimit ?? 0
40+
)
3041
}
3142
}

0 commit comments

Comments
 (0)