@@ -110,20 +110,19 @@ public protocol ContractProtocol {
110
110
/// new Solidity keywords, types etc. that are not yet supported, etc.
111
111
init ( _ abiString: String , at: EthereumAddress ? ) throws
112
112
113
- /// Creates a smart contract deployment transaction.
113
+ /// Prepare transaction data for smart contract deployment transaction.
114
114
///
115
115
/// - Parameters:
116
116
/// - bytecode: bytecode to deploy.
117
117
/// - constructor: constructor of the smart contract bytecode is related to. Used to encode `parameters`.
118
118
/// - parameters: parameters for `constructor`.
119
119
/// - extraData: any extra data. It can be encoded input arguments for a constuctor but then you should set `constructor` and
120
120
/// `parameters` to be `nil`.
121
- /// - Returns: transaction if given `parameters` were successfully encoded in a `constructor`. If any or both are `nil`
122
- /// then no encoding will take place and a transaction with `bytecode + extraData` will be returned.
121
+ /// - Returns: Encoded data for a given parameters, which is should be assigned to ``CodableTransaction.data`` property
123
122
func deploy( bytecode: Data ,
124
123
constructor: ABI . Element . Constructor ? ,
125
124
parameters: [ AnyObject ] ? ,
126
- extraData: Data ? ) -> CodableTransaction ?
125
+ extraData: Data ? ) -> Data ?
127
126
128
127
/// Creates function call transaction with data set as `method` encoded with given `parameters`.
129
128
/// The `method` must be part of the ABI used to init this contract.
@@ -187,7 +186,7 @@ extension ContractProtocol {
187
186
func deploy( _ bytecode: Data ,
188
187
constructor: ABI . Element . Constructor ? = nil ,
189
188
parameters: [ AnyObject ] ? = nil ,
190
- extraData: Data ? = nil ) -> CodableTransaction ? {
189
+ extraData: Data ? = nil ) -> Data ? {
191
190
deploy ( bytecode: bytecode,
192
191
constructor: constructor,
193
192
parameters: parameters,
@@ -200,7 +199,7 @@ extension ContractProtocol {
200
199
/// See ``ContractProtocol/method(_:parameters:extraData:)`` for details.
201
200
func method( _ method: String = " fallback " ,
202
201
parameters: [ AnyObject ] ? = nil ,
203
- extraData: Data ? = nil ) -> CodableTransaction ? {
202
+ extraData: Data ? = nil ) -> Data ? {
204
203
self . method ( method, parameters: parameters ?? [ ] , extraData: extraData)
205
204
}
206
205
@@ -219,15 +218,14 @@ extension DefaultContractProtocol {
219
218
public func deploy( bytecode: Data ,
220
219
constructor: ABI . Element . Constructor ? ,
221
220
parameters: [ AnyObject ] ? ,
222
- extraData: Data ? ) -> CodableTransaction ? {
221
+ extraData: Data ? ) -> Data ? {
223
222
var fullData = bytecode
224
223
225
224
if let constructor = constructor,
226
225
let parameters = parameters,
227
226
!parameters. isEmpty {
228
227
guard constructor. inputs. count == parameters. count,
229
- let encodedData = constructor. encodeParameters ( parameters)
230
- else {
228
+ let encodedData = constructor. encodeParameters ( parameters) else {
231
229
NSLog ( " Constructor encoding will fail as the number of input arguments doesn't match the number of given arguments. " )
232
230
return nil
233
231
}
@@ -239,12 +237,7 @@ extension DefaultContractProtocol {
239
237
}
240
238
241
239
// MARK: Writing Data flow
242
- return CodableTransaction ( to: . contractDeploymentAddress( ) ,
243
- value: BigUInt ( 0 ) ,
244
- data: fullData
245
- // FIXME: Return parameters
246
- // parameters: CodableTransaction()
247
- )
240
+ return fullData
248
241
}
249
242
250
243
/// Call given contract method with given parameters
0 commit comments