-
Notifications
You must be signed in to change notification settings - Fork 6
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
Changes from 4 commits
d6b46e8
1438790
b091686
c2fa7eb
d8fd4bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { TransactionResponse } from '@ethersproject/providers' | ||
import { Signer, constants, utils } from 'ethers' | ||
import { TransactionRequest } from '@ethersproject/abstract-provider' | ||
import { Signer, constants, utils, BigNumber } from 'ethers' | ||
import { RIFWallet } from '../core' | ||
export class WalletConnectAdapter { | ||
private resolvers: IResolver[] | ||
|
@@ -41,13 +42,19 @@ class SendTransactionResolver implements IResolver { | |
async resolve(params: any[]) { | ||
const payload = params.reduce((prev, curr) => ({ ...prev, ...curr }), {}) | ||
|
||
if (payload.data === '') { | ||
// TODO: assign undefined once the RIFWallet changes are applied | ||
payload.data = constants.HashZero | ||
const formattedPayload: TransactionRequest = { | ||
to: payload.to, | ||
from: payload.from, | ||
nonce: payload.nonce, | ||
data: payload.data || constants.HashZero, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated this to be |
||
value: BigNumber.from(payload.value || 0), | ||
chainId: payload.chainId, | ||
gasLimit: BigNumber.from(payload.gas || 0), // WC's gas to gasLimit | ||
gasPrice: BigNumber.from(payload.gasPrice || 0), | ||
} | ||
|
||
return this.signer | ||
.sendTransaction(payload) | ||
.sendTransaction(formattedPayload) | ||
.then((tx: TransactionResponse) => tx.hash) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.