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

Update tokens controller (#18459)

* update tokens controller
This commit is contained in:
Bernardo Garces Chapero 2023-04-21 09:05:27 +01:00 committed by GitHub
parent 7f00c2f313
commit 8632acbba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 64 additions and 150 deletions

View File

@ -22,7 +22,6 @@ import {
MESSAGE_TYPE,
///: END:ONLY_INCLUDE_IN
} from '../../shared/constants/app';
import { SECOND } from '../../shared/constants/time';
import {
REJECT_NOTIFICATION_CLOSE,
REJECT_NOTIFICATION_CLOSE_SIG,
@ -442,7 +441,6 @@ export function setupController(
infuraProjectId: process.env.INFURA_PROJECT_ID,
// User confirmation callbacks:
showUserConfirmation: triggerUi,
openPopup,
// initial state
initState,
// initial locale code
@ -839,22 +837,6 @@ async function triggerUi() {
}
}
/**
* Opens the browser popup for user confirmation of watchAsset
* then it waits until user interact with the UI
*/
async function openPopup() {
await triggerUi();
await new Promise((resolve) => {
const interval = setInterval(() => {
if (!notificationIsOpen) {
clearInterval(interval);
resolve();
}
}, SECOND);
});
}
// It adds the "App Installed" event into a queue of events, which will be tracked only after a user opts into metrics.
const addAppInstalledEvent = () => {
if (controller) {

View File

@ -339,6 +339,14 @@ export default class MetamaskController extends EventEmitter {
}),
config: { provider: this.provider },
state: initState.TokensController,
messenger: this.controllerMessenger.getRestricted({
name: 'TokensController',
allowedActions: [
`${this.approvalController.name}:addRequest`,
`${this.approvalController.name}:acceptRequest`,
`${this.approvalController.name}:rejectRequest`,
],
}),
});
this.assetsContractController = new AssetsContractController(
@ -699,10 +707,6 @@ export default class MetamaskController extends EventEmitter {
initState: initState.CachedBalancesController,
});
this.tokensController.hub.on('pendingSuggestedAsset', async () => {
await opts.openPopup();
});
let additionalKeyrings = [keyringBuilderFactory(QRHardwareKeyring)];
if (this.canUseHardwareWallets()) {

View File

@ -80,7 +80,6 @@
"app/scripts/lib/createStreamSink.js",
"app/scripts/lib/createTabIdMiddleware.js",
"app/scripts/lib/decrypt-message-manager.js",
"app/scripts/lib/encryption-public-key-manager.js",
"app/scripts/lib/ens-ipfs/contracts/registry.js",
"app/scripts/lib/ens-ipfs/contracts/resolver.js",
"app/scripts/lib/ens-ipfs/resolver.js",

View File

@ -687,6 +687,7 @@
"URL": true,
"clearInterval": true,
"clearTimeout": true,
"console.error": true,
"console.info": true,
"console.log": true,
"setInterval": true,
@ -696,13 +697,13 @@
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/assets-controllers>@metamask/abi-utils": true,
"@metamask/assets-controllers>@metamask/utils": true,
"@metamask/assets-controllers>abort-controller": true,
"@metamask/assets-controllers>multiformats": true,
"@metamask/base-controller": true,
"@metamask/contract-metadata": true,
"@metamask/controller-utils": true,
"@metamask/metamask-eth-abis": true,
"@metamask/utils": true,
"browserify>events": true,
"eth-json-rpc-filters>async-mutex": true,
"eth-query": true,
@ -730,18 +731,6 @@
"semver": true
}
},
"@metamask/assets-controllers>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>superstruct": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/assets-controllers>abort-controller": {
"globals": {
"AbortController": true
@ -766,8 +755,8 @@
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>@metamask/utils": true,
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/utils": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
@ -775,18 +764,6 @@
"ethjs>ethjs-unit": true
}
},
"@metamask/controller-utils>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>superstruct": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/controller-utils>@spruceid/siwe-parser": {
"globals": {
"console.error": true,

View File

@ -687,6 +687,7 @@
"URL": true,
"clearInterval": true,
"clearTimeout": true,
"console.error": true,
"console.info": true,
"console.log": true,
"setInterval": true,
@ -696,13 +697,13 @@
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/assets-controllers>@metamask/abi-utils": true,
"@metamask/assets-controllers>@metamask/utils": true,
"@metamask/assets-controllers>abort-controller": true,
"@metamask/assets-controllers>multiformats": true,
"@metamask/base-controller": true,
"@metamask/contract-metadata": true,
"@metamask/controller-utils": true,
"@metamask/metamask-eth-abis": true,
"@metamask/utils": true,
"browserify>events": true,
"eth-json-rpc-filters>async-mutex": true,
"eth-query": true,
@ -730,18 +731,6 @@
"semver": true
}
},
"@metamask/assets-controllers>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>superstruct": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/assets-controllers>abort-controller": {
"globals": {
"AbortController": true
@ -766,8 +755,8 @@
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>@metamask/utils": true,
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/utils": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
@ -775,18 +764,6 @@
"ethjs>ethjs-unit": true
}
},
"@metamask/controller-utils>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>superstruct": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/controller-utils>@spruceid/siwe-parser": {
"globals": {
"console.error": true,

View File

@ -687,6 +687,7 @@
"URL": true,
"clearInterval": true,
"clearTimeout": true,
"console.error": true,
"console.info": true,
"console.log": true,
"setInterval": true,
@ -696,13 +697,13 @@
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/assets-controllers>@metamask/abi-utils": true,
"@metamask/assets-controllers>@metamask/utils": true,
"@metamask/assets-controllers>abort-controller": true,
"@metamask/assets-controllers>multiformats": true,
"@metamask/base-controller": true,
"@metamask/contract-metadata": true,
"@metamask/controller-utils": true,
"@metamask/metamask-eth-abis": true,
"@metamask/utils": true,
"browserify>events": true,
"eth-json-rpc-filters>async-mutex": true,
"eth-query": true,
@ -730,18 +731,6 @@
"semver": true
}
},
"@metamask/assets-controllers>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>superstruct": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/assets-controllers>abort-controller": {
"globals": {
"AbortController": true
@ -766,8 +755,8 @@
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>@metamask/utils": true,
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/utils": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
@ -775,18 +764,6 @@
"ethjs>ethjs-unit": true
}
},
"@metamask/controller-utils>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>superstruct": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/controller-utils>@spruceid/siwe-parser": {
"globals": {
"console.error": true,

View File

@ -687,6 +687,7 @@
"URL": true,
"clearInterval": true,
"clearTimeout": true,
"console.error": true,
"console.info": true,
"console.log": true,
"setInterval": true,
@ -696,13 +697,13 @@
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/assets-controllers>@metamask/abi-utils": true,
"@metamask/assets-controllers>@metamask/utils": true,
"@metamask/assets-controllers>abort-controller": true,
"@metamask/assets-controllers>multiformats": true,
"@metamask/base-controller": true,
"@metamask/contract-metadata": true,
"@metamask/controller-utils": true,
"@metamask/metamask-eth-abis": true,
"@metamask/utils": true,
"browserify>events": true,
"eth-json-rpc-filters>async-mutex": true,
"eth-query": true,
@ -730,18 +731,6 @@
"semver": true
}
},
"@metamask/assets-controllers>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>superstruct": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/assets-controllers>abort-controller": {
"globals": {
"AbortController": true
@ -766,8 +755,8 @@
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>@metamask/utils": true,
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/utils": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
@ -775,18 +764,6 @@
"ethjs>ethjs-unit": true
}
},
"@metamask/controller-utils>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>superstruct": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/controller-utils>@spruceid/siwe-parser": {
"globals": {
"console.error": true,

View File

@ -226,10 +226,10 @@
"@metamask/address-book-controller": "^2.0.0",
"@metamask/announcement-controller": "^3.0.0",
"@metamask/approval-controller": "^2.1.0",
"@metamask/assets-controllers": "^5.0.0",
"@metamask/assets-controllers": "^6.0.0",
"@metamask/base-controller": "^2.0.0",
"@metamask/contract-metadata": "^2.3.1",
"@metamask/controller-utils": "^3.1.0",
"@metamask/controller-utils": "^3.2.0",
"@metamask/design-tokens": "^1.9.0",
"@metamask/desktop": "^0.3.0",
"@metamask/eth-json-rpc-infura": "^8.0.0",

View File

@ -3615,35 +3615,37 @@ __metadata:
languageName: node
linkType: hard
"@metamask/assets-controllers@npm:^5.0.0":
version: 5.0.1
resolution: "@metamask/assets-controllers@npm:5.0.1"
"@metamask/assets-controllers@npm:^6.0.0":
version: 6.0.0
resolution: "@metamask/assets-controllers@npm:6.0.0"
dependencies:
"@ethersproject/bignumber": ^5.7.0
"@ethersproject/contracts": ^5.7.0
"@ethersproject/providers": ^5.7.0
"@metamask/abi-utils": ^1.1.0
"@metamask/approval-controller": ^2.1.0
"@metamask/base-controller": ^2.0.0
"@metamask/contract-metadata": ^2.3.1
"@metamask/controller-utils": ^3.1.0
"@metamask/controller-utils": ^3.2.0
"@metamask/metamask-eth-abis": 3.0.0
"@metamask/network-controller": ^6.0.0
"@metamask/network-controller": ^7.0.0
"@metamask/preferences-controller": ^3.0.0
"@metamask/utils": ^3.3.1
"@metamask/utils": ^5.0.1
"@types/uuid": ^8.3.0
abort-controller: ^3.0.0
async-mutex: ^0.2.6
babel-runtime: ^6.26.0
eth-query: ^2.1.2
eth-rpc-errors: ^4.0.0
eth-rpc-errors: ^4.0.2
ethereumjs-util: ^7.0.10
immer: ^9.0.6
multiformats: ^9.5.2
single-call-balance-checker-abi: ^1.0.0
uuid: ^8.3.2
peerDependencies:
"@metamask/network-controller": ^6.0.0
checksum: aa2ab83752c121fe410f191660c4b57be9cc74cbe462e8c35b86077160c8d6640ccf19d0fa423c8123803e00ba6d7c9112d68b9e058c0fbac1df6210ad3be2b7
"@metamask/approval-controller": ^2.1.0
"@metamask/network-controller": ^7.0.0
checksum: 79c56421567b48b24deab2410645ae60022954ad590e6d91c3770fbeaf24ea3e92608935ae15696349a51bfc5d4337b22cc21f48b0d09bbf4e2f1a0c4aa96904
languageName: node
linkType: hard
@ -3723,18 +3725,18 @@ __metadata:
languageName: node
linkType: hard
"@metamask/controller-utils@npm:^3.0.0, @metamask/controller-utils@npm:^3.1.0":
version: 3.1.0
resolution: "@metamask/controller-utils@npm:3.1.0"
"@metamask/controller-utils@npm:^3.0.0, @metamask/controller-utils@npm:^3.1.0, @metamask/controller-utils@npm:^3.2.0":
version: 3.2.0
resolution: "@metamask/controller-utils@npm:3.2.0"
dependencies:
"@metamask/utils": ^3.3.1
"@metamask/utils": ^5.0.1
"@spruceid/siwe-parser": 1.1.3
eth-ens-namehash: ^2.0.8
eth-rpc-errors: ^4.0.0
eth-rpc-errors: ^4.0.2
ethereumjs-util: ^7.0.10
ethjs-unit: ^0.1.6
fast-deep-equal: ^3.1.3
checksum: 811fc4b9da98ca406a0e002c87933687e745d20f802305bb2af0affcdad454189c705caae9389444da1f5f88f2d10269b3ae8354aa1f600a11ddb9315cfa5718
checksum: 06b27f9273719ca6eb556c032b77e9066c8d38ad4ff081896a68046e1e4764482f244bf849d51fc622f425e54c9063cc697abdb0cb2f2aaab9a0d8807f2310f3
languageName: node
linkType: hard
@ -4079,6 +4081,25 @@ __metadata:
languageName: node
linkType: hard
"@metamask/network-controller@npm:^7.0.0":
version: 7.0.0
resolution: "@metamask/network-controller@npm:7.0.0"
dependencies:
"@metamask/base-controller": ^2.0.0
"@metamask/controller-utils": ^3.1.0
"@metamask/swappable-obj-proxy": ^2.1.0
"@metamask/utils": ^3.3.1
async-mutex: ^0.2.6
babel-runtime: ^6.26.0
eth-json-rpc-infura: ^5.1.0
eth-query: ^2.1.2
immer: ^9.0.6
uuid: ^8.3.2
web3-provider-engine: ^16.0.3
checksum: 62eeb223f164db1cb5914070b9ec799ee980c0723e9e154afaab3a3032d5ac133c7d1e1cbc506fd9083254f1888a7f7e99137278a107c9b9d854cb9c629b1713
languageName: node
linkType: hard
"@metamask/notification-controller@npm:^2.0.0":
version: 2.0.0
resolution: "@metamask/notification-controller@npm:2.0.0"
@ -4452,16 +4473,16 @@ __metadata:
languageName: node
linkType: hard
"@metamask/utils@npm:^5.0.0":
version: 5.0.0
resolution: "@metamask/utils@npm:5.0.0"
"@metamask/utils@npm:^5.0.0, @metamask/utils@npm:^5.0.1":
version: 5.0.1
resolution: "@metamask/utils@npm:5.0.1"
dependencies:
"@ethereumjs/tx": ^4.1.1
"@types/debug": ^4.1.7
debug: ^4.3.4
semver: ^7.3.8
superstruct: ^1.0.3
checksum: 34e39fc0bf28db5fe92676753de3291b05a517f8c81dbe332a4b6002739a58450a89fb2bddd85922a4f420affb1674604e6ad4627cdf052459e5371361ef7dd2
checksum: 29745bd3d2db06bf66263bdec04e93a8f417c46c69d8054149c0046ed54b5f13d26d94a998fff1a31b5a8e7a2200935bfc8392a5fa3c4261e3cecd3ccdd9ddc0
languageName: node
linkType: hard
@ -24148,11 +24169,11 @@ __metadata:
"@metamask/address-book-controller": ^2.0.0
"@metamask/announcement-controller": ^3.0.0
"@metamask/approval-controller": ^2.1.0
"@metamask/assets-controllers": ^5.0.0
"@metamask/assets-controllers": ^6.0.0
"@metamask/auto-changelog": ^2.1.0
"@metamask/base-controller": ^2.0.0
"@metamask/contract-metadata": ^2.3.1
"@metamask/controller-utils": ^3.1.0
"@metamask/controller-utils": ^3.2.0
"@metamask/design-tokens": ^1.9.0
"@metamask/desktop": ^0.3.0
"@metamask/eslint-config": ^9.0.0