-
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
Changes from 4 commits
558d7c2
77d0b0d
3bee27c
d3bdcf3
cbe7652
eb4d944
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,6 +1,6 @@ | ||
import { ObservableStore } from '@metamask/obs-store'; | ||
import { normalize as normalizeAddress } from 'eth-sig-util'; | ||
import { ethers } from 'ethers'; | ||
import { Web3Provider } from '@ethersproject/providers'; | ||
import { IPFS_DEFAULT_GATEWAY_URL } from '../../../shared/constants/network'; | ||
import { isPrefixedFormattedHexString } from '../../../shared/modules/network.utils'; | ||
import { LedgerTransportTypes } from '../../../shared/constants/hardware-wallets'; | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. done here |
||
this.store = new ObservableStore(initState); | ||
this.store.setMaxListeners(12); | ||
this.openPopup = opts.openPopup; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { strict as assert } from 'assert'; | ||
import sinon from 'sinon'; | ||
|
||
import { ethers } from 'ethers'; | ||
import { BigNumber } from '@ethersproject/bignumber'; | ||
import { mapValues } from 'lodash'; | ||
import BigNumber from 'bignumber.js'; | ||
import BigNumberjs from 'bignumber.js'; | ||
import { CHAIN_IDS, NETWORK_IDS } from '../../../shared/constants/network'; | ||
import { ETH_SWAPS_TOKEN_OBJECT } from '../../../shared/constants/swaps'; | ||
import { createTestProviderTools } from '../../../test/stub/provider'; | ||
|
@@ -373,7 +373,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 commentThe reason will be displayed to describe this comment to others. Learn more. Could we just use the 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. |
||
.minus(estimatedRefund, 10) | ||
.toString(16)}`, | ||
); | ||
|
@@ -667,7 +667,7 @@ describe('SwapsController', function () { | |
// Make it so approval is not required | ||
sandbox | ||
.stub(swapsController, '_getERC20Allowance') | ||
.resolves(ethers.BigNumber.from(1)); | ||
.resolves(BigNumber.from(1)); | ||
|
||
const [newQuotes] = await swapsController.fetchAndSetQuotes( | ||
MOCK_FETCH_PARAMS, | ||
|
@@ -711,7 +711,7 @@ describe('SwapsController', function () { | |
// Make it so approval is not required | ||
const allowanceStub = sandbox | ||
.stub(swapsController, '_getERC20Allowance') | ||
.resolves(ethers.BigNumber.from(1)); | ||
.resolves(BigNumber.from(1)); | ||
|
||
await swapsController.fetchAndSetQuotes( | ||
MOCK_FETCH_PARAMS, | ||
|
@@ -734,7 +734,7 @@ describe('SwapsController', function () { | |
// Ensure approval is required | ||
sandbox | ||
.stub(swapsController, '_getERC20Allowance') | ||
.resolves(ethers.BigNumber.from(0)); | ||
.resolves(BigNumber.from(0)); | ||
|
||
const timedoutGasReturnResult = { gasLimit: 1000000 }; | ||
const timedoutGasReturnStub = sandbox | ||
|
@@ -759,7 +759,7 @@ describe('SwapsController', function () { | |
// Make it so approval is not required | ||
sandbox | ||
.stub(swapsController, '_getERC20Allowance') | ||
.resolves(ethers.BigNumber.from(1)); | ||
.resolves(BigNumber.from(1)); | ||
|
||
const [newQuotes, topAggId] = await swapsController.fetchAndSetQuotes( | ||
MOCK_FETCH_PARAMS, | ||
|
@@ -777,7 +777,7 @@ describe('SwapsController', function () { | |
const bestQuote = { | ||
...getMockQuotes()[TEST_AGG_ID_1], | ||
aggregator: bestAggId, | ||
destinationAmount: ethers.BigNumber.from( | ||
destinationAmount: BigNumber.from( | ||
getMockQuotes()[TEST_AGG_ID_1].destinationAmount, | ||
) | ||
.add((100e18).toString()) | ||
|
@@ -789,7 +789,7 @@ describe('SwapsController', function () { | |
// Make it so approval is not required | ||
sandbox | ||
.stub(swapsController, '_getERC20Allowance') | ||
.resolves(ethers.BigNumber.from(1)); | ||
.resolves(BigNumber.from(1)); | ||
|
||
const [newQuotes, topAggId] = await swapsController.fetchAndSetQuotes( | ||
MOCK_FETCH_PARAMS, | ||
|
@@ -806,7 +806,7 @@ describe('SwapsController', function () { | |
// Make it so approval is not required | ||
sandbox | ||
.stub(swapsController, '_getERC20Allowance') | ||
.resolves(ethers.BigNumber.from(1)); | ||
.resolves(BigNumber.from(1)); | ||
|
||
swapsController.getTokenRatesState = () => ({ | ||
contractExchangeRates: {}, | ||
|
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