Skip to content
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: token detection and import (#23798) #23871

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/dist/TokenDetectionController.js b/dist/TokenDetectionController.js
index 9aa09140d47424217eac118aebca9031e5d2a236..8100c432e7e01dbefcb5f53db3c58e51f120a51d 100644
--- a/dist/TokenDetectionController.js
+++ b/dist/TokenDetectionController.js
@@ -230,8 +230,7 @@ _TokenDetectionController_intervalId = new WeakMap(), _TokenDetectionController_
const isDetectionChangedFromPreferences = __classPrivateFieldGet(this, _TokenDetectionController_isDetectionEnabledFromPreferences, "f") !== useTokenDetection;
__classPrivateFieldSet(this, _TokenDetectionController_selectedAddress, newSelectedAddress, "f");
__classPrivateFieldSet(this, _TokenDetectionController_isDetectionEnabledFromPreferences, useTokenDetection, "f");
- if (useTokenDetection &&
- (isSelectedAddressChanged || isDetectionChangedFromPreferences)) {
+ if (isSelectedAddressChanged || isDetectionChangedFromPreferences) {
yield __classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_restartTokenDetection).call(this, {
selectedAddress: __classPrivateFieldGet(this, _TokenDetectionController_selectedAddress, "f"),
});
@@ -239,8 +238,7 @@ _TokenDetectionController_intervalId = new WeakMap(), _TokenDetectionController_
}));
this.messagingSystem.subscribe('AccountsController:selectedAccountChange', ({ address: newSelectedAddress }) => __awaiter(this, void 0, void 0, function* () {
const isSelectedAddressChanged = __classPrivateFieldGet(this, _TokenDetectionController_selectedAddress, "f") !== newSelectedAddress;
- if (isSelectedAddressChanged &&
- __classPrivateFieldGet(this, _TokenDetectionController_isDetectionEnabledFromPreferences, "f")) {
+ if (isSelectedAddressChanged) {
__classPrivateFieldSet(this, _TokenDetectionController_selectedAddress, newSelectedAddress, "f");
yield __classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_restartTokenDetection).call(this, {
selectedAddress: __classPrivateFieldGet(this, _TokenDetectionController_selectedAddress, "f"),
18 changes: 9 additions & 9 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ export default class MetamaskController extends EventEmitter {

const preferencesMessenger = this.controllerMessenger.getRestricted({
name: 'PreferencesController',
allowedActions: ['PreferencesController:getState'],
allowedEvents: ['PreferencesController:stateChange'],
allowedActions: [],
allowedEvents: [],
});

this.preferencesController = new PreferencesController({
Expand Down Expand Up @@ -2209,6 +2209,7 @@ export default class MetamaskController extends EventEmitter {
triggerNetworkrequests() {
this.accountTracker.start();
this.txController.startIncomingTransactionPolling();
this.tokenDetectionController.enable();
if (this.preferencesController.store.getState().useCurrencyRateCheck) {
this.currencyRateController.startPollingByNetworkClientId(
this.networkController.state.selectedNetworkClientId,
Expand All @@ -2222,6 +2223,7 @@ export default class MetamaskController extends EventEmitter {
stopNetworkRequests() {
this.accountTracker.stop();
this.txController.stopIncomingTransactionPolling();
this.tokenDetectionController.disable();
if (this.preferencesController.store.getState().useCurrencyRateCheck) {
this.currencyRateController.stopAllPolling();
}
Expand Down Expand Up @@ -2500,8 +2502,9 @@ export default class MetamaskController extends EventEmitter {

// TODO: Remove once the preferences controller has been replaced with the core monorepo implementation
this.controllerMessenger.publish(
`${this.preferencesController.name}:stateChange`,
[state, []],
'PreferencesController:stateChange',
state,
[],
);
});

Expand Down Expand Up @@ -3733,6 +3736,8 @@ export default class MetamaskController extends EventEmitter {

this.txController.clearUnapprovedTransactions();

this.tokenDetectionController.enable();

// create new vault
const vault = await this.keyringController.createNewVaultAndRestore(
password,
Expand Down Expand Up @@ -5652,11 +5657,6 @@ export default class MetamaskController extends EventEmitter {
*/
set isClientOpen(open) {
this._isClientOpen = open;
if (open) {
this.tokenDetectionController.enable();
} else {
this.tokenDetectionController.disable();
}
}
/* eslint-enable accessor-pairs */

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
"@metamask/address-book-controller": "^3.1.7",
"@metamask/announcement-controller": "^5.0.1",
"@metamask/approval-controller": "^6.0.0",
"@metamask/assets-controllers": "^26.0.0",
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@npm%3A26.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch",
"@metamask/base-controller": "^4.1.0",
"@metamask/browser-passworder": "^4.3.0",
"@metamask/contract-metadata": "^2.3.1",
Expand Down
46 changes: 44 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3998,7 +3998,7 @@ __metadata:
languageName: node
linkType: hard

"@metamask/assets-controllers@npm:^26.0.0":
"@metamask/assets-controllers@npm:26.0.0":
version: 26.0.0
resolution: "@metamask/assets-controllers@npm:26.0.0"
dependencies:
Expand Down Expand Up @@ -4040,6 +4040,48 @@ __metadata:
languageName: node
linkType: hard

"@metamask/assets-controllers@patch:@metamask/assets-controllers@npm%3A26.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch":
version: 26.0.0
resolution: "@metamask/assets-controllers@patch:@metamask/assets-controllers@npm%3A26.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch::version=26.0.0&hash=cf1d54"
dependencies:
"@ethereumjs/util": "npm:^8.1.0"
"@ethersproject/address": "npm:^5.7.0"
"@ethersproject/bignumber": "npm:^5.7.0"
"@ethersproject/contracts": "npm:^5.7.0"
"@ethersproject/providers": "npm:^5.7.0"
"@metamask/abi-utils": "npm:^2.0.2"
"@metamask/accounts-controller": "npm:^11.0.0"
"@metamask/approval-controller": "npm:^5.1.3"
"@metamask/base-controller": "npm:^4.1.1"
"@metamask/contract-metadata": "npm:^2.4.0"
"@metamask/controller-utils": "npm:^8.0.4"
"@metamask/eth-query": "npm:^4.0.0"
"@metamask/keyring-controller": "npm:^13.0.0"
"@metamask/metamask-eth-abis": "npm:3.0.0"
"@metamask/network-controller": "npm:^17.2.1"
"@metamask/polling-controller": "npm:^5.0.1"
"@metamask/preferences-controller": "npm:^8.0.0"
"@metamask/rpc-errors": "npm:^6.2.1"
"@metamask/utils": "npm:^8.3.0"
"@types/bn.js": "npm:^5.1.5"
"@types/uuid": "npm:^8.3.0"
async-mutex: "npm:^0.2.6"
bn.js: "npm:^5.2.1"
cockatiel: "npm:^3.1.2"
lodash: "npm:^4.17.21"
multiformats: "npm:^9.5.2"
single-call-balance-checker-abi: "npm:^1.0.0"
uuid: "npm:^8.3.2"
peerDependencies:
"@metamask/accounts-controller": ^11.0.0
"@metamask/approval-controller": ^5.1.2
"@metamask/keyring-controller": ^13.0.0
"@metamask/network-controller": ^17.2.0
"@metamask/preferences-controller": ^8.0.0
checksum: 44e0ce87c9a2e4e161771c212460947629502ad6e72542e87a29a3de6e9c6665190396a2ae7d8206e57ad091cb80ad6634dfbfd254632a5ee6833c496f1ad0ad
languageName: node
linkType: hard

"@metamask/auto-changelog@npm:^2.1.0":
version: 2.6.1
resolution: "@metamask/auto-changelog@npm:2.6.1"
Expand Down Expand Up @@ -24683,7 +24725,7 @@ __metadata:
"@metamask/address-book-controller": "npm:^3.1.7"
"@metamask/announcement-controller": "npm:^5.0.1"
"@metamask/approval-controller": "npm:^6.0.0"
"@metamask/assets-controllers": "npm:^26.0.0"
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@npm%3A26.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch"
"@metamask/auto-changelog": "npm:^2.1.0"
"@metamask/base-controller": "npm:^4.1.0"
"@metamask/browser-passworder": "npm:^4.3.0"
Expand Down
Loading