@@ -11,57 +11,13 @@ import Core
11
11
extension web3 . Eth {
12
12
13
13
// FIXME: Rewrite this to CodableTransaction
14
- public func send( _ transaction: CodableTransaction , transactionOptions: CodableTransaction ? = nil , password: String = " web3swift " ) async throws -> TransactionSendingResult {
15
- // print(transaction)
16
- var assembledTransaction : CodableTransaction = transaction
17
-
18
- var mergedOptions = self . web3. transactionOptions. merge ( transactionOptions)
19
-
20
- var forAssemblyPipeline : ( CodableTransaction , CodableTransaction ) = ( assembledTransaction, mergedOptions)
21
-
22
- // usually not calling
23
- // Can't find where this hooks are implemented.
24
- for hook in self . web3. preSubmissionHooks {
25
- let hookResult = hook. function ( forAssemblyPipeline)
26
- if hookResult. 2 {
27
- forAssemblyPipeline = ( hookResult. 0 , hookResult. 1 )
28
- }
29
-
30
- let shouldContinue = hookResult. 2
31
- if !shouldContinue {
32
- throw Web3Error . processingError ( desc: " Transaction is canceled by middleware " )
33
- }
34
- }
35
-
36
- assembledTransaction = forAssemblyPipeline. 0
37
- mergedOptions = forAssemblyPipeline. 1
38
-
39
-
40
- if let attachedKeystoreManager = self . web3. provider. attachedKeystoreManager {
41
- guard let from = mergedOptions. from else {
42
- throw Web3Error . inputError ( desc: " No 'from' field provided " )
43
- }
44
- do {
45
- try Web3Signer . signTX ( transaction: & assembledTransaction, keystore: attachedKeystoreManager, account: from, password: password)
46
- } catch {
47
- throw Web3Error . inputError ( desc: " Failed to locally sign a transaction " )
48
- }
49
- return try await self . web3. eth. send ( raw: assembledTransaction)
50
- }
51
- // MARK: Writing Data flow
52
- // From CodableTransaction.data to TransactionParameters.data
53
- assembledTransaction. applyOptions ( mergedOptions)
54
- // guard let transactionParameters = transaction.encodeAsDictionary(from: transactionOptions?.from) else { throw Web3Error.dataError }
55
-
14
+ public func send( _ transaction: CodableTransaction ) async throws -> TransactionSendingResult {
56
15
// MARK: Sending Data flow
57
16
// FIXME: This gives empty object, fix me, there were TransactionParameters applied.
58
- let request : APIRequest = . sendTransaction( assembledTransaction )
17
+ let request : APIRequest = . sendTransaction( transaction )
59
18
let response : APIResponse < Hash > = try await APIRequest . sendRequest ( with: self . provider, for: request)
60
19
61
- let result = TransactionSendingResult ( transaction: assembledTransaction, hash: response. result)
62
- for hook in self . web3. postSubmissionHooks {
63
- hook. function ( result)
64
- }
20
+ let result = TransactionSendingResult ( transaction: transaction, hash: response. result)
65
21
return result
66
22
}
67
23
}
0 commit comments