1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

Update @metamask/gas-fee-controller to v6 (#19366)

* Update `@metamask/gas-fee-controller` to v6

The `@metamask/address-book-controller` package has been updated to v3.
This version was part of the [core monorepo v53](MetaMask/core#1385)
release. The remaining packages released as part of v53 will be updated
in later PRs.

This release included a number of breaking changes, but most of them
do not affect the extension:

* Bump to Node 16
  * The extension already uses Node.js v16
* The `getChainId` constructor parameter now expects a `Hex` return
type rather than a decimal string
  * The extension was already passing in a `getChainId` parameter that
returned `Hex`
* The gas fee controller messenger now requires the
`NetworkController:stateChange` event instead of the
`NetworkController:providerConfigChange` event
  * This does not apply if `onNetworkStateChange` and `getChainId` are
provided to the constructor, which is the case here.
* Update `@metamask/network-controller` dependency and peer dependency
  * This dependency is only used for types, and none of the type
changes affect how the extension interacts with this controller.

The one change that did have an impact is that the constructor
parameter `onNetworkStateChange` now expects event handlers to be
passed the full network state.

Relates to #19271

* Ensure chainid always matches mainnet in test builds

This is a bit strange, but this is how the tests were setup previously.

* Fix accidental state mutation

* Remove hardcoded mainnet chain ID from test builds
This commit is contained in:
Mark Stacey 2023-06-13 12:13:13 -02:30 committed by GitHub
parent be7900e9e9
commit abd2a5559e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 55 additions and 142 deletions

View File

@ -513,10 +513,12 @@ export default class MetamaskController extends EventEmitter {
this.networkController.getProviderAndBlockTracker().provider,
// NOTE: This option is inaccurately named; it should be called
// onNetworkDidChange
onNetworkStateChange: networkControllerMessenger.subscribe.bind(
networkControllerMessenger,
onNetworkStateChange: (eventHandler) => {
networkControllerMessenger.subscribe(
'NetworkController:networkDidChange',
),
() => eventHandler(this.networkController.store.getState()),
);
},
getCurrentNetworkEIP1559Compatibility:
this.networkController.getEIP1559Compatibility.bind(
this.networkController,
@ -530,11 +532,8 @@ export default class MetamaskController extends EventEmitter {
this.networkController.store.getState().providerConfig;
return process.env.IN_TEST || chainId === CHAIN_IDS.MAINNET;
},
getChainId: () => {
return process.env.IN_TEST
? CHAIN_IDS.MAINNET
: this.networkController.store.getState().providerConfig.chainId;
},
getChainId: () =>
this.networkController.store.getState().providerConfig.chainId,
});
this.qrHardwareKeyring = new QRHardwareKeyring();

View File

@ -1467,36 +1467,14 @@
"setInterval": true
},
"packages": {
"@metamask/gas-fee-controller>@metamask/base-controller": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"eth-query": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true,
"uuid": true
}
},
"@metamask/gas-fee-controller>@metamask/base-controller": {
"packages": {
"immer": true
}
},
"@metamask/gas-fee-controller>@metamask/controller-utils": {
"globals": {
"URL": true,
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/utils": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true
}
},
"@metamask/jazzicon": {
"globals": {
"document.createElement": true,

View File

@ -1538,36 +1538,14 @@
"setInterval": true
},
"packages": {
"@metamask/gas-fee-controller>@metamask/base-controller": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"eth-query": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true,
"uuid": true
}
},
"@metamask/gas-fee-controller>@metamask/base-controller": {
"packages": {
"immer": true
}
},
"@metamask/gas-fee-controller>@metamask/controller-utils": {
"globals": {
"URL": true,
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/utils": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true
}
},
"@metamask/jazzicon": {
"globals": {
"document.createElement": true,

View File

@ -1538,36 +1538,14 @@
"setInterval": true
},
"packages": {
"@metamask/gas-fee-controller>@metamask/base-controller": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"eth-query": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true,
"uuid": true
}
},
"@metamask/gas-fee-controller>@metamask/base-controller": {
"packages": {
"immer": true
}
},
"@metamask/gas-fee-controller>@metamask/controller-utils": {
"globals": {
"URL": true,
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/utils": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true
}
},
"@metamask/jazzicon": {
"globals": {
"document.createElement": true,

View File

@ -1467,36 +1467,14 @@
"setInterval": true
},
"packages": {
"@metamask/gas-fee-controller>@metamask/base-controller": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"eth-query": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true,
"uuid": true
}
},
"@metamask/gas-fee-controller>@metamask/base-controller": {
"packages": {
"immer": true
}
},
"@metamask/gas-fee-controller>@metamask/controller-utils": {
"globals": {
"URL": true,
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/utils": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true
}
},
"@metamask/jazzicon": {
"globals": {
"document.createElement": true,

View File

@ -1688,36 +1688,14 @@
"setInterval": true
},
"packages": {
"@metamask/gas-fee-controller>@metamask/base-controller": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"eth-query": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true,
"uuid": true
}
},
"@metamask/gas-fee-controller>@metamask/base-controller": {
"packages": {
"immer": true
}
},
"@metamask/gas-fee-controller>@metamask/controller-utils": {
"globals": {
"URL": true,
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/utils": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true
}
},
"@metamask/jazzicon": {
"globals": {
"document.createElement": true,

View File

@ -243,7 +243,7 @@
"@metamask/eth-token-tracker": "^4.0.0",
"@metamask/eth-trezor-keyring": "^1.0.0",
"@metamask/etherscan-link": "^2.2.0",
"@metamask/gas-fee-controller": "^5.0.0",
"@metamask/gas-fee-controller": "^6.0.0",
"@metamask/jazzicon": "^2.0.0",
"@metamask/key-tree": "^7.0.0",
"@metamask/logo": "^3.1.1",

View File

@ -99,7 +99,7 @@ async function setupMocking(server, testSpecificMock) {
});
await server
.forGet('https://gas-api.metaswap.codefi.network/networks/1/gasPrices')
.forGet('https://gas-api.metaswap.codefi.network/networks/1337/gasPrices')
.thenCallback(() => {
return {
statusCode: 200,
@ -130,7 +130,7 @@ async function setupMocking(server, testSpecificMock) {
await server
.forGet(
'https://gas-api.metaswap.codefi.network/networks/1/suggestedGasFees',
'https://gas-api.metaswap.codefi.network/networks/1337/suggestedGasFees',
)
.thenCallback(() => {
return {

View File

@ -10,7 +10,7 @@ describe('Gas API fallback', function () {
async function mockGasApiDown(mockServer) {
await mockServer
.forGet(
'https://gas-api.metaswap.codefi.network/networks/1/suggestedGasFees',
'https://gas-api.metaswap.codefi.network/networks/1337/suggestedGasFees',
)
.always()
.thenCallback(() => {

View File

@ -4256,13 +4256,14 @@ __metadata:
languageName: node
linkType: hard
"@metamask/gas-fee-controller@npm:^5.0.0":
version: 5.0.0
resolution: "@metamask/gas-fee-controller@npm:5.0.0"
"@metamask/gas-fee-controller@npm:^6.0.0":
version: 6.0.0
resolution: "@metamask/gas-fee-controller@npm:6.0.0"
dependencies:
"@metamask/base-controller": ^2.0.0
"@metamask/controller-utils": ^3.4.0
"@metamask/network-controller": ^8.0.0
"@metamask/base-controller": ^3.0.0
"@metamask/controller-utils": ^4.0.0
"@metamask/network-controller": ^9.0.0
"@metamask/utils": ^5.0.2
"@types/uuid": ^8.3.0
babel-runtime: ^6.26.0
eth-query: ^2.1.2
@ -4271,8 +4272,8 @@ __metadata:
immer: ^9.0.6
uuid: ^8.3.2
peerDependencies:
"@metamask/network-controller": ^8.0.0
checksum: 6c6a21ab2ca42ad2fc361373e192624deef9f02686e9e124fc3af53f37438dc02264aa2f73c82a3f1e4153b5a8ea518fa11fb212066218c0f4afdc16a95868db
"@metamask/network-controller": ^9.0.0
checksum: e7f15b0d3043e228f85cfa462c800d7332845b8d13211b1688c68a3b4b09b921aaa9b3304688dd0b7e4d9abd59f96dab0f50259a90f35c4b50321e2805c65bfb
languageName: node
linkType: hard
@ -4391,6 +4392,29 @@ __metadata:
languageName: node
linkType: hard
"@metamask/network-controller@npm:^9.0.0":
version: 9.0.0
resolution: "@metamask/network-controller@npm:9.0.0"
dependencies:
"@metamask/base-controller": ^3.0.0
"@metamask/controller-utils": ^4.0.0
"@metamask/eth-json-rpc-infura": ^8.0.0
"@metamask/eth-json-rpc-middleware": ^11.0.0
"@metamask/eth-json-rpc-provider": ^1.0.0
"@metamask/swappable-obj-proxy": ^2.1.0
"@metamask/utils": ^5.0.2
async-mutex: ^0.2.6
babel-runtime: ^6.26.0
eth-block-tracker: ^7.0.1
eth-query: ^2.1.2
eth-rpc-errors: ^4.0.2
immer: ^9.0.6
json-rpc-engine: ^6.1.0
uuid: ^8.3.2
checksum: 7548fe82990ff62d36a6c42a49442422fe3634933b6fc85b86a3bbb2788a755c73f3fa70a70ae48ddf09a70e3e33d375723980aec76e89cdf21b76b96a069b07
languageName: node
linkType: hard
"@metamask/notification-controller@npm:^3.0.0":
version: 3.0.0
resolution: "@metamask/notification-controller@npm:3.0.0"
@ -24053,7 +24077,7 @@ __metadata:
"@metamask/eth-trezor-keyring": ^1.0.0
"@metamask/etherscan-link": ^2.2.0
"@metamask/forwarder": ^1.1.0
"@metamask/gas-fee-controller": ^5.0.0
"@metamask/gas-fee-controller": ^6.0.0
"@metamask/jazzicon": ^2.0.0
"@metamask/key-tree": ^7.0.0
"@metamask/logo": ^3.1.1