question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transaction option is not applied to send translation.

See original GitHub issue

There is a problem that the trasactionOptions cannot be used properly because of merge. In the Web3+ MutatingTransaction class, it is replaced by cleanedOptions. I want to know the reason. 2.6.5 library version. Estimategas for EIP1559 is excellent. However, transaction option is not applied to send translation.

var options = writeTransaction.transactionOptions
        options.nonce = .latest
        options.callOnBlock = .latest
        options.type = .eip1559
        options.maxFeePerGas = .manual(maxFee)
        options.maxPriorityFeePerGas = .manual(maxTip)

If you run sendTransactionPromise with the above options, maxFeePerGas and maxPriorityFeePerGas are ignored. There seems to be some problem when merge.

public func sendPromise(password: String = "web3swift", transactionOptions: TransactionOptions? = nil) -> Promise<TransactionSendingResult>{
    let queue = self.web3.requestDispatcher.queue
    return self.assemblePromise(transactionOptions: transactionOptions).then(on: queue) { transaction throws -> Promise<TransactionSendingResult> in
      let mergedOptions = self.transactionOptions.merge(transactionOptions)
      var cleanedOptions = TransactionOptions ()
      cleanedOptions.to = mergedOptions.to
      return self.web3.eth.sendTransactionPromise(transaction, transactionOptions: cleanedOptions, password: password)
    }
}

image

maxFeePerGas , maxPriorityFeePerGas, type, nonce all nil. Only from, to exists.

/// create a JSCON RPC Request object for the given transaction
/// - Parameters:
///   - method: RPC request method
///   - transaction: the thansaction to encode/send
///   - trasactionOptions: additional options for the transaction
/// - Returns: a JSCONRPCrequest object
static func createRequest(method: JSONRPCmethod, transaction: EthereumTransaction, transactionOptions: TransactionOptions?) -> JSONRPCrequest? {
   let onBlock = transactionOptions?.callOnBlock?.stringValue
   var request = JSONRPCrequest ()

   request.method = method
   let from = transactionOptions?.from
   quard var txParams = transaction.encodeAsDictionary(from: from) else { return nil }
   if method == .estimateGas || transactionOptions?.gasLimit == nil {
        txParams.gas = nil
   }
   var params = [txParams] as [Encodable]
   if method.requiredNumOfParameters == 2&& onBlock != nil {
      params.append( onBlock as Encodable )
   }
   let pars = JSONRPCparams(params: params)
   request.params = pars
   if !request.isValid { return nil }
   return request
}

Maybe there is a problem with this method, too.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
JeneaVranceanucommented, Jul 8, 2022

@Kristenlike1234 Something that I didn’t take into account right away is that TransactionOptions is a struct and since struct in Swift is a value type this action will create absolutely different variable:

var options = writeTransaction.transactionOptions

Modifying options won’t change anything in writeTransaction.transactionOptions.

What you should do instead is change transactionOptions directly:

writeTransaction.transactionOptions.nonce = .latest
writeTransaction.transactionOptions.callOnBlock = .latest
writeTransaction.transactionOptions.type = .eip1559
writeTransaction.transactionOptions.maxFeePerGas = .manual(maxFee)
writeTransaction.transactionOptions.maxPriorityFeePerGas = .manual(maxTip)

If you prefer the way you do it with a new options variable then pass it into send or sendPromise functions like this:

var options = writeTransaction.transactionOptions
options.nonce = .latest
options.callOnBlock = .latest
options.type = .eip1559
options.maxFeePerGas = .manual(maxFee)
options.maxPriorityFeePerGas = .manual(maxTip)

writeTransaction.send(password: ..., transactionOptions: options)
// or
writeTransaction.sendPromise(password: ..., transactionOptions: options)
0reactions
JeneaVranceanucommented, Jul 8, 2022

@Kristenlike1234 Try passing back your options into send or sendPromise and ping me with the result, please. If that won’t help we should look further. For now, I’ll switch to a different task.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with Translation Files - Business Central
How to work with translations, multilanguage, and XLIFF files in Business Central.
Read more >
ISO 20022: In-flow Translation - Swift
This approach aims to facilitate the integration in the receiver's application environment in cases where not all applications can (yet) support the ISO...
Read more >
Fix issues when you send, receive, or transfer money
Use this info to fix common issues in Google Pay when you: Send or receive money. Add or transfer out money. “Transaction cannot...
Read more >
Working with Override Translation Rules - Oracle Help Center
When you create translation rules, you select the translation method and rate account to use for the translation. The translation rule overrides the...
Read more >
A glossary of terms used in payments and settlement systems
The Committee on Payment and Settlement Systems (CPSS) is publishing this comprehensive glossary of payment system terminology as a reference document for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found