@@ -110,20 +110,19 @@ public protocol ContractProtocol {
110110 /// new Solidity keywords, types etc. that are not yet supported, etc.
111111 init ( _ abiString: String , at: EthereumAddress ? ) throws
112112
113- /// Creates a smart contract deployment transaction.
113+ /// Prepare transaction data for smart contract deployment transaction.
114114 ///
115115 /// - Parameters:
116116 /// - bytecode: bytecode to deploy.
117117 /// - constructor: constructor of the smart contract bytecode is related to. Used to encode `parameters`.
118118 /// - parameters: parameters for `constructor`.
119119 /// - extraData: any extra data. It can be encoded input arguments for a constuctor but then you should set `constructor` and
120120 /// `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
123122 func deploy( bytecode: Data ,
124123 constructor: ABI . Element . Constructor ? ,
125124 parameters: [ AnyObject ] ? ,
126- extraData: Data ? ) -> CodableTransaction ?
125+ extraData: Data ? ) -> Data ?
127126
128127 /// Creates function call transaction with data set as `method` encoded with given `parameters`.
129128 /// The `method` must be part of the ABI used to init this contract.
@@ -187,7 +186,7 @@ extension ContractProtocol {
187186 func deploy( _ bytecode: Data ,
188187 constructor: ABI . Element . Constructor ? = nil ,
189188 parameters: [ AnyObject ] ? = nil ,
190- extraData: Data ? = nil ) -> CodableTransaction ? {
189+ extraData: Data ? = nil ) -> Data ? {
191190 deploy ( bytecode: bytecode,
192191 constructor: constructor,
193192 parameters: parameters,
@@ -200,7 +199,7 @@ extension ContractProtocol {
200199 /// See ``ContractProtocol/method(_:parameters:extraData:)`` for details.
201200 func method( _ method: String = " fallback " ,
202201 parameters: [ AnyObject ] ? = nil ,
203- extraData: Data ? = nil ) -> CodableTransaction ? {
202+ extraData: Data ? = nil ) -> Data ? {
204203 self . method ( method, parameters: parameters ?? [ ] , extraData: extraData)
205204 }
206205
@@ -219,15 +218,14 @@ extension DefaultContractProtocol {
219218 public func deploy( bytecode: Data ,
220219 constructor: ABI . Element . Constructor ? ,
221220 parameters: [ AnyObject ] ? ,
222- extraData: Data ? ) -> CodableTransaction ? {
221+ extraData: Data ? ) -> Data ? {
223222 var fullData = bytecode
224223
225224 if let constructor = constructor,
226225 let parameters = parameters,
227226 !parameters. isEmpty {
228227 guard constructor. inputs. count == parameters. count,
229- let encodedData = constructor. encodeParameters ( parameters)
230- else {
228+ let encodedData = constructor. encodeParameters ( parameters) else {
231229 NSLog ( " Constructor encoding will fail as the number of input arguments doesn't match the number of given arguments. " )
232230 return nil
233231 }
@@ -239,12 +237,7 @@ extension DefaultContractProtocol {
239237 }
240238
241239 // 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
248241 }
249242
250243 /// Call given contract method with given parameters
0 commit comments