Skip to content

Commit a0c7265

Browse files
Merge pull request #594 from JeneaVranceanu/chore/extensions-with-initializers
Chore: public structs with initializers
2 parents ce1c62f + a9461c9 commit a0c7265

File tree

5 files changed

+63
-8
lines changed

5 files changed

+63
-8
lines changed

Sources/web3swift/Contract/ContractProtocol.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ public struct EventFilter {
5858
}
5959
}
6060

61-
public init() { }
62-
63-
public init(fromBlock: Block?, toBlock: Block?,
61+
public init(fromBlock: Block? = nil,
62+
toBlock: Block? = nil,
6463
addresses: [EthereumAddress]? = nil,
6564
parameterFilters: [[EventFilterable]?]? = nil) {
6665
self.fromBlock = fromBlock

Sources/web3swift/KeystoreManager/IBAN.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ public struct ICAP {
1111
public var asset: String
1212
public var institution: String
1313
public var client: String
14+
15+
public init(asset: String, institution: String, client: String) {
16+
self.asset = asset
17+
self.institution = institution
18+
self.client = client
19+
}
1420
}
1521

1622
public struct IBAN {

Sources/web3swift/Tokens/ERC1376/Web3+ERC1376.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ public enum IERC1376DelegateMode: UInt {
1818
}
1919

2020
public struct DirectDebitInfo {
21-
let amount: BigUInt
22-
let startTime: BigUInt
23-
let interval: BigUInt
21+
public let amount: BigUInt
22+
public let startTime: BigUInt
23+
public let interval: BigUInt
2424
}
2525

2626
public struct DirectDebit {
27-
let info: DirectDebitInfo
28-
let epoch: BigUInt
27+
public let info: DirectDebitInfo
28+
public let epoch: BigUInt
2929
}
3030

3131
extension DirectDebit: Hashable {

Sources/web3swift/Transaction/EthereumParameters.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,30 @@ public struct EthereumParameters {
4949

5050
/// access list for contract execution (EIP-2930 and EIP-1559 only)
5151
public var accessList: [AccessListEntry]?
52+
53+
public init(type: TransactionType? = nil,
54+
to: EthereumAddress? = nil,
55+
nonce: BigUInt? = nil,
56+
chainID: BigUInt? = nil,
57+
value: BigUInt? = nil,
58+
data: Data? = nil,
59+
gasLimit: BigUInt? = nil,
60+
gasPrice: BigUInt? = nil,
61+
maxFeePerGas: BigUInt? = nil,
62+
maxPriorityFeePerGas: BigUInt? = nil,
63+
accessList: [AccessListEntry]? = nil) {
64+
self.type = type
65+
self.to = to
66+
self.nonce = nonce
67+
self.chainID = chainID
68+
self.value = value
69+
self.data = data
70+
self.gasLimit = gasLimit
71+
self.gasPrice = gasPrice
72+
self.maxFeePerGas = maxFeePerGas
73+
self.maxPriorityFeePerGas = maxPriorityFeePerGas
74+
self.accessList = accessList
75+
}
5276
}
5377

5478
public extension EthereumParameters {

Sources/web3swift/Web3/Web3+Options.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,32 @@ public struct TransactionOptions {
8888

8989
public var accessList: [AccessListEntry]?
9090

91+
public init(type: TransactionType? = nil,
92+
to: EthereumAddress? = nil,
93+
from: EthereumAddress? = nil,
94+
chainID: BigUInt? = nil,
95+
gasLimit: TransactionOptions.GasLimitPolicy? = nil,
96+
gasPrice: TransactionOptions.GasPricePolicy? = nil,
97+
maxFeePerGas: TransactionOptions.FeePerGasPolicy? = nil,
98+
maxPriorityFeePerGas: TransactionOptions.FeePerGasPolicy? = nil,
99+
value: BigUInt? = nil,
100+
nonce: TransactionOptions.NoncePolicy? = nil,
101+
callOnBlock: TransactionOptions.CallingBlockPolicy? = nil,
102+
accessList: [AccessListEntry]? = nil) {
103+
self.type = type
104+
self.to = to
105+
self.from = from
106+
self.chainID = chainID
107+
self.gasLimit = gasLimit
108+
self.gasPrice = gasPrice
109+
self.maxFeePerGas = maxFeePerGas
110+
self.maxPriorityFeePerGas = maxPriorityFeePerGas
111+
self.value = value
112+
self.nonce = nonce
113+
self.callOnBlock = callOnBlock
114+
self.accessList = accessList
115+
}
116+
91117
public static var defaultOptions: TransactionOptions {
92118
var opts = TransactionOptions()
93119
opts.type = .legacy

0 commit comments

Comments
 (0)