Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert values coming in from WalletConnect #70

Merged
merged 5 commits into from
Dec 5, 2021
Merged

Conversation

jessgusclark
Copy link
Member

@jessgusclark jessgusclark commented Nov 29, 2021

Convert values coming from WalletConnect to integers which is what is expected. Also, delete the gas property as this was also causing ethers to fail.

This uses BigNumber's from method to handle the conversion to BigNumber then back to number. We could extract out the from portion if it would make it faster.

Update:

  • Take WC object and conform it to a TransactionRequest including renaming gas to gasLimit.
  • Leave numbers as BigNumber and allow UI to change them toString().
  • does not estimate gas - The UI currently looks to see if the gasLimit and gasPrice is set and if not, it estimates them, since both numbers here are being passed as 0 if they don't exist, it would estimate it. Choose the higher gasLimit and gasPrice in the modal #72 will estimate regardless and will take the higher value, therefor, I will leave this 'bug' here.

notes

src/lib/walletAdapters/WalletConnectAdapter.ts Outdated Show resolved Hide resolved
src/lib/walletAdapters/WalletConnectAdapter.ts Outdated Show resolved Hide resolved
src/lib/walletAdapters/WalletConnectAdapter.ts Outdated Show resolved Hide resolved
src/lib/walletAdapters/WalletConnectAdapter.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@chescalante chescalante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@ilanolkies ilanolkies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

to: payload.to,
from: payload.from,
nonce: payload.nonce,
data: payload.data || constants.HashZero,
Copy link
Contributor

@ilanolkies ilanolkies Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need 0x here as no data. HashZero produces 32 bytes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this to be 0x but I also made the default for gasPrice and gasLimit undefined. I think this adapter should not set them to zero in case it is reused in a different app. In #72, if the gasLimit/gasPrice are undefined, then it will use the estimates.

@@ -23,6 +23,8 @@ describe('Wallet Connect Adapter', () => {
from,
to,
value: '0x3e8',
gas: '25000',
Copy link
Contributor

@ilanolkies ilanolkies Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add two tests? One for the payload with values and another for the defaults that trigger estimations

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new test and refactored the existing test to use spyon to get the parameters being sent to sendTransaction.

- Spyon the sendTransaction method to get the parameters that are being sent to the provider
- Change default values to undefined not zero.
@ilanolkies ilanolkies merged commit 37bef06 into main Dec 5, 2021
@jessgusclark jessgusclark deleted the convert-hex-from-wc branch December 6, 2021 11:35
@ilanolkies ilanolkies added the lib Libraries and dependencies label Jan 14, 2022
@ilanolkies ilanolkies added this to the v1.0.0 milestone Jan 14, 2022
@ilanolkies ilanolkies added tx Transactions wc Wallet Connect and removed lib Libraries and dependencies labels Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tx Transactions wc Wallet Connect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants