Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Incorrect assign to transaction payload field #7

Closed
ezykov opened this issue May 25, 2018 · 3 comments
Closed

Incorrect assign to transaction payload field #7

ezykov opened this issue May 25, 2018 · 3 comments

Comments

@ezykov
Copy link

ezykov commented May 25, 2018

Hi, I have an issue when I try to send transaction with a "payload" field. For Example, when I send transaction with some data to TrustWallet:

var transaction = Transaction(gasPrice: BigInt(21), gasLimit: 21000, to: address)
transaction.amount = amount
transaction.payload = Data(hexString: "0x8f834227000000000000000000000000000000005224") //some data

trustSDK.signTransaction(transaction) { [weak self] signedTransaction in
    let alert = UIAlertController(title: "Signed Transaction", message: signedTransaction.hexString, 
        preferredStyle: .alert)
    alert.addAction(.init(title: "OK", style: .default, handler: nil))
    self?.present(alert, animated: true, completion: nil)
}

it doesn't display at screen:
image

I think it happened because transaction data is base64 encoded string and TrustWalletSDK can't parse it correctly. If change this code (in source TrustWalletSDK - > TrustWalletSDK.swift -> handleSignTransaction function):

 transaction.payload = components.queryParameterValue(for: "data").flatMap({ Data(hexString: $0) })

for something like this:

let data = components.queryParameterValue(for: "data").flatMap({ String($0) })!
let dataEncoded = Data(base64Encoded: data)!
transaction.payload = dataEncoded

now it's work correct:
image

@vikmeup
Copy link
Contributor

vikmeup commented May 25, 2018

@ezykov thanks for finding this issue! I will fix this on our side.

Since data is always in hex, we don't need to convert into base64 I think

@vikmeup
Copy link
Contributor

vikmeup commented May 25, 2018

@ezykov should be fixed on master! Thanks

Can you telegram me: @vikmeup? curious to see what you are working on

@vikmeup vikmeup closed this as completed May 25, 2018
@ezykov
Copy link
Author

ezykov commented May 26, 2018

Glad to be helpful. Thanks for fix issue. Yes, sure, I’ll contact you soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants