-
Notifications
You must be signed in to change notification settings - Fork 25
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
Format send result to work with ethers #8
Conversation
b851368
to
a0c0ab2
Compare
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.
Just the two things, otherwise I'm happy!
RemoteMetaMaskProvider.js
Outdated
|
||
// Format "gasPrice" | ||
if (result && typeof result.gasPrice === 'string') { | ||
result.gasPrice = Number(result.gasPrice); |
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 think I'd rather see parseInt(x, 10)
here as it is more explicit
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.
👍
RemoteMetaMaskProvider.js
Outdated
|
||
// Because requests are handled across a WebSocket, their callbacks need to | ||
// be associated with an ID which is returned with the response. | ||
const requestId = RemoteMetaMaskProvider.generateRequestId(); |
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.
We like to use this.constructor.xxx
instead.
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.
👍
RemoteMetaMaskProvider.js
Outdated
if (result && result.logIndex) { | ||
const array = []; | ||
array.push(result); | ||
return array; |
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.
Isn't that the same as return [result]
?
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.
👍
2eb40e7
to
ee60f08
Compare
@chmanie It's working with the latest commit! Could you please review once more? |
Description
Adds
formatResult
static function toRemoteMetamaskProvider
, which ensures thegasPrice
andvalue
of the result object are properly formatted to work withethers
. IfgasPrice
orvalue
is a string, the string is converted to a number usingparseInt
.Ideally, we would convert the string to a standard big number type but
ethers
does not support any big number types other than its own proprietary type usingethers.utils.bigNumberify
.Also adds a condition to
formatResult
that returns the result in an array if the result object has alogIndex
property. This provides the correct formatting foreht_filter
to work withethers
.Other Changes
Added comments and updated formatting.
Related Issues
JoinColony/colonyStarter#14