-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix/use etherjs specific imports #15461
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
f485c62
to
ec73c85
Compare
8986e80
to
89a1ff0
Compare
@@ -377,7 +377,7 @@ describe('SwapsController', function () { | |||
assert.strictEqual(gasEstimate, bufferedGasLimit); | |||
assert.strictEqual( | |||
gasEstimateWithRefund, | |||
`0x${new BigNumber(maxGas, 10) | |||
`0x${new BigNumberjs(maxGas, 10) |
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.
Could we just use the ethers
version of BigNumber here too? And get rid of bignumber.js
here?
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.
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.
One small question, otherwise LGTM
5a9f2df
to
921da2c
Compare
Builds ready [0367001]
Page Load Metrics (1947 ± 57 ms)
highlights:storybook
|
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.
hmmm... why does this make the bundle size bigger? We should investigate that
seconding @danjm 's message above, in the before and after all the numbers you posted look good (reduction in bundle size) but the image of the zip files show an increase in total size. We should at least understand that portion and where the size is coming from. |
I was trying this approach to measuring size increase as well - looking at the zip file size - but I'm not sure if its a valid way to measure...? @brad-decker @Gudahtt what do you think? |
2092919
to
b17d8a9
Compare
Builds ready [492f884]
Page Load Metrics (2139 ± 92 ms)
highlights:storybook
|
@danjm I investigated why we have bundle sizes bigger after using specific ethers packages. It looks like every specific ethers package will install node modules that he needs, so it will cause multiple installations of the same package. Like in the picture below. When we install umbrella ethers, the size of that node module is 8,5 MB. |
looking into this. |
So at least part of the problem is that any places in our dependency tree that |
Actually not sure if we can do this since |
Looks like upgrading our version of |
Looks like the interfaces haven't changed for the functions/objects we use |
0e0b22c
to
f34f903
Compare
Builds ready [98092de]
Page Load Metrics (1333 ± 105 ms)
Bundle size diffs [🚀 Bundle size reduced!]
highlights:storybook
|
98092de
to
cb30ace
Compare
Builds ready [cb30ace]
Page Load Metrics (1225 ± 81 ms)
Bundle size diffs [🚀 Bundle size reduced!]
highlights:storybook
|
The only outstanding instance of |
cb30ace
to
d3bdcf3
Compare
Builds ready [d3bdcf3]
Page Load Metrics (1404 ± 137 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
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.
LGTM!
@@ -114,6 +115,7 @@ export default class DetectTokensController { | |||
: tokenList; | |||
|
|||
const tokensToDetect = []; | |||
this.ethersProvider = new Web3Provider(this._network._provider); |
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.
Oh, I don't know if this file needs a provider any more?
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.
looks like you're right! Will remove
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.
done here
@@ -73,7 +73,7 @@ export default class PreferencesController { | |||
}; | |||
|
|||
this.network = opts.network; | |||
this.ethersProvider = new ethers.providers.Web3Provider(opts.provider); | |||
this.ethersProvider = new Web3Provider(opts.provider); |
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.
similar comment as above, what is this provider used for?
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.
done here
Builds ready [eb4d944]
Page Load Metrics (1338 ± 96 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
Is replacing bignumber imports an important part of this? It doesnt seem like all were changed |
Explanation
We don't need to import both whole ethers npm package.
This PR replaces all imports of ethers npm umbrella package with a specific ethers package.
More Information
Fixes #15232
Screenshots/Screencaps
Before
Current bundle size on develop
"background": {
"name": "background",
"size": 76085955
"ui": {
"name": "ui",
"size": 94503010,
Google Chrome build size after removing web3 npm package.
"background": {
"name": "background",
"size": 10236142,
"ui": {
"name": "ui",
"size": 12504705,
After
Google Chrome build size after removing ethers umbrella npm package.
"background": {
"name": "background",
"size": 13145874,
"ui": {
"name": "ui",
"size": 16133810,
Manual Testing Steps
Check if the extension works correctly. There are a lot of places where we changed ethers package.
Pre-Merge Checklist
+ If there are functional changes: