AlphaWallet / alpha-wallet-ios

An advanced Ethereum/EVM mobile wallet
https://www.alphawallet.com
MIT License
595 stars 367 forks source link

eth_sendRawTransaction #5569

Closed wangaojie001 closed 1 year ago

wangaojie001 commented 1 year ago

``

 let (r, s, v) = signer.values(transaction: transaction, signature: signature)
                let values: [Any] = [
                    transaction.nonce,
                    transaction.gasPrice,
                    transaction.gasLimit,
                    transaction.to?.data ?? Data(),
                    transaction.value,
                    transaction.data,
                    v, r, s,
                ]

This is the original sign parameter

I want to add a new parameter "maxPriorityFeePerGas" like this

                let signature = try EthereumSigner().sign(hash: hash, withPrivateKey: key)
                let (r, s, v) = signer.values(transaction: transaction, signature: signature)
                let values: [Any] = [
                    transaction.nonce,
                    transaction.gasPrice,
                    transaction.gasLimit,
                    transaction.to?.data ?? Data(),
                    transaction.value,
                    transaction.data,
                    transaction.maxPriorityFeePerGas,
                    v, r, s,
                ]

This will result in an error like the one below

responseError(JSONRPCKit.JSONRPCError.responseError(code: -32602, message: "transaction could not be decoded: unexpected EIP-155 V value", data: nil)) from: convertToUserFriendlyError(error:server:baseUrl:)

How can I add a new parameter "maxPriorityFeePerGas" to eth_sendRawTransaction?

wangaojie001 commented 1 year ago
            let newConfiguration = TransactionConfiguration(
                    gasPrice: configuration.gasPrice,
                    gasLimit: configuration.gasLimit,
                    maxPriorityFeePerGas:EtherNumberFormatter.full.number(from: String("30"), units: UnitConfiguration.gasPriceUnit) ?? BigInt(),
                    data: configuration.data,
                    nonce: configuration.nonce,
                    hasUserAdjustedGasPrice: true,
                    hasUserAdjustedGasLimit: true
            )

I write for the value of the parameter maxPriorityFeePerGas

EtherNumberFormatter.full.number (from: String (" 30 "), units: UnitConfiguration.gasPriceUnit) ?? BigInt()

hboon commented 1 year ago

Is this to support EIP1559? If so, best to wait for #5172

wangaojie001 commented 1 year ago

Simulator Screen Shot - iPhone 14 Pro - 2022-10-13 at 14 59 43

TransactionConfirmationViewController

    @objc func confirmButtonTapped(_ sender: UIButton) {
        guard viewModel.canBeConfirmed else { return }
        delegate?.controller(self, continueButtonTapped: sender)
    }

then to. TransactionConfirmationCoordinator

    func controller(_ controller: TransactionConfirmationViewController, continueButtonTapped sender: UIButton) {
        sender.isEnabled = false
        canBeDismissed = false
        rootViewController.set(state: .pending)

        firstly { () -> Promise<ConfirmResult> in
            return sendTransaction()
        }.done { result in
            self.handleSendTransactionSuccessfully(result: result)
            self.logCompleteActionSheetForTransactionConfirmationSuccessfully()
        }.catch { error in
            self.logActionSheetForTransactionConfirmationFailed()
            //TODO remove delay which is currently needed because the starting animation may not have completed and internal state (whether animation is running) is in correct
            DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) {
                self.rootViewController.set(state: .done(withError: true)) {
                    self.handleSendTransactionError(error)
                }
            }
        }.finally {
            sender.isEnabled = true
            self.canBeDismissed = true
        }
    }

Method is
sendTransaction()

wangaojie001 commented 1 year ago

截屏2022-10-12 09 26 17 返回错误

wangaojie001 commented 1 year ago

截屏2022-10-13 14 29 59

wangaojie001 commented 1 year ago

Is this to support EIP1559? If so, best to wait for #5172

Does this project support Moralis API to send transaction?

hboon commented 1 year ago

Is this to support EIP1559? If so, best to wait for #5172

Does this project support Moralis API to send transaction?

No, do you have a link to a doc so I can have a quick look? What's the advantage in doing it?