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

chore: Bump Snaps dependencies #30396

Merged
merged 10 commits into from
Feb 19, 2025
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
Expand Up @@ -19,7 +19,6 @@ export const CronjobControllerInit: ControllerInitFunction<
// with the expected type.
// TODO: Look into the type mismatch.
state: persistedState.CronjobController,
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
messenger: controllerMessenger,
});

Expand Down
2 changes: 0 additions & 2 deletions app/scripts/controller-init/snaps/execution-service-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export const ExecutionServiceInit: ControllerInitFunction<
memStateKey: null,
persistedStateKey: null,
controller: new OffscreenExecutionService({
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
messenger: controllerMessenger,
setupSnapProvider,
offscreenPromise,
Expand All @@ -68,7 +67,6 @@ export const ExecutionServiceInit: ControllerInitFunction<
memStateKey: null,
persistedStateKey: null,
controller: new IframeExecutionService({
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
messenger: controllerMessenger,
iframeUrl: new URL(iframeUrl),
setupSnapProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const SnapInsightsControllerInit: ControllerInitFunction<
// compatible with the expected type.
// TODO: Look into the type mismatch.
state: persistedState.SnapInsightsController,
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
messenger: controllerMessenger,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const SnapInterfaceControllerInit: ControllerInitFunction<
// with the expected type.
// TODO: Look into the type mismatch.
state: persistedState.SnapInterfaceController,
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
messenger: controllerMessenger,
});

Expand Down
1 change: 0 additions & 1 deletion app/scripts/controller-init/snaps/snaps-registry-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const SnapsRegistryInit: ControllerInitFunction<
// with the expected type.
// TODO: Look into the type mismatch.
state: persistedState.SnapsRegistry,
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
messenger: controllerMessenger,
refetchOnAllowlistMiss: requireAllowlist,
});
Expand Down
52 changes: 45 additions & 7 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2551,14 +2551,32 @@ export default class MetamaskController extends EventEmitter {
}

/**
* Gets whether the privacy mode is enabled from the PreferencesController.
* Gets a subset of preferences from the PreferencesController to pass to a snap.
*
* @returns {boolean} Whether the privacy mode is enabled.
* @returns {object} A subset of preferences.
*/
getPrivacyMode() {
const { privacyMode } = this.preferencesController.state;
getPreferences() {
const {
preferences,
securityAlertsEnabled,
useCurrencyRateCheck,
useTransactionSimulations,
useTokenDetection,
useMultiAccountBalanceChecker,
openSeaEnabled,
useNftDetection,
} = this.preferencesController.state;

return privacyMode;
return {
privacyMode: preferences.privacyMode,
securityAlertsEnabled,
useCurrencyRateCheck,
useTransactionSimulations,
useTokenDetection,
useMultiAccountBalanceChecker,
openSeaEnabled,
useNftDetection,
};
}

/**
Expand All @@ -2573,8 +2591,28 @@ export default class MetamaskController extends EventEmitter {
getPreferences: () => {
const locale = this.getLocale();
const currency = this.currencyRateController.state.currentCurrency;
const hideBalances = this.getPrivacyMode();
return { locale, currency, hideBalances };
const {
privacyMode,
securityAlertsEnabled,
useCurrencyRateCheck,
useTransactionSimulations,
useTokenDetection,
useMultiAccountBalanceChecker,
openSeaEnabled,
useNftDetection,
} = this.getPreferences();
return {
locale,
currency,
hideBalances: privacyMode,
useSecurityAlerts: securityAlertsEnabled,
useExternalPricingData: useCurrencyRateCheck,
simulateOnChainActions: useTransactionSimulations,
useTokenDetection,
batchCheckBalances: useMultiAccountBalanceChecker,
displayNftMedia: openSeaEnabled,
useNftDetection,
};
},
clearSnapState: this.controllerMessenger.call.bind(
this.controllerMessenger,
Expand Down
8 changes: 4 additions & 4 deletions builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ buildTypes:
- ALLOW_LOCAL_SNAPS: false
- REQUIRE_SNAPS_ALLOWLIST: true
- REJECT_INVALID_SNAPS_PLATFORM_VERSION: true
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/6.14.0/index.html
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/7.0.0/index.html
- ACCOUNT_SNAPS_DIRECTORY_URL: https://snaps.metamask.io/account-management
# Main build uses the default browser manifest
manifestOverrides: false
Expand All @@ -48,7 +48,7 @@ buildTypes:
- ALLOW_LOCAL_SNAPS: false
- REQUIRE_SNAPS_ALLOWLIST: true
- REJECT_INVALID_SNAPS_PLATFORM_VERSION: true
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/6.14.0/index.html
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/7.0.0/index.html
- ACCOUNT_SNAPS_DIRECTORY_URL: https://snaps.metamask.io/account-management
# Modifies how the version is displayed.
# eg. instead of 10.25.0 -> 10.25.0-beta.2
Expand All @@ -72,7 +72,7 @@ buildTypes:
- ALLOW_LOCAL_SNAPS: true
- REQUIRE_SNAPS_ALLOWLIST: false
- REJECT_INVALID_SNAPS_PLATFORM_VERSION: false
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/6.14.0/index.html
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/7.0.0/index.html
- SUPPORT_LINK: https://support.metamask.io/
- SUPPORT_REQUEST_LINK: https://support.metamask.io/
- INFURA_ENV_KEY_REF: INFURA_FLASK_PROJECT_ID
Expand All @@ -96,7 +96,7 @@ buildTypes:
- ALLOW_LOCAL_SNAPS: false
- REQUIRE_SNAPS_ALLOWLIST: true
- REJECT_INVALID_SNAPS_PLATFORM_VERSION: true
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/6.14.0/index.html
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/7.0.0/index.html
- MMI_CONFIGURATION_SERVICE_URL: https://configuration.metamask-institutional.io/v2/configuration/default
- SUPPORT_LINK: https://support.metamask-institutional.io
- SUPPORT_REQUEST_LINK: https://support.metamask-institutional.io
Expand Down
94 changes: 74 additions & 20 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@
"console.info": true
},
"packages": {
"@metamask/approval-controller>@metamask/base-controller": true,
"@metamask/base-controller": true,
"@metamask/rpc-errors": true,
"nanoid": true
}
Expand Down Expand Up @@ -928,7 +928,7 @@
"@metamask/metamask-eth-abis": true,
"@metamask/polling-controller": true,
"@metamask/rpc-errors": true,
"@metamask/snaps-utils": true,
"@metamask/assets-controllers>@metamask/snaps-utils": true,
"@metamask/assets-controllers>@metamask/utils": true,
"@metamask/name-controller>async-mutex": true,
"bn.js": true,
Expand All @@ -954,14 +954,6 @@
"immer": true
}
},
"@metamask/approval-controller>@metamask/base-controller": {
"globals": {
"setTimeout": true
},
"packages": {
"immer": true
}
},
"@metamask/network-controller>@metamask/base-controller": {
"globals": {
"setTimeout": true
Expand Down Expand Up @@ -1010,14 +1002,6 @@
"immer": true
}
},
"@metamask/snaps-controllers>@metamask/base-controller": {
"globals": {
"setTimeout": true
},
"packages": {
"immer": true
}
},
"@metamask/transaction-controller>@metamask/base-controller": {
"globals": {
"setTimeout": true
Expand Down Expand Up @@ -1551,7 +1535,7 @@
"@metamask/base-controller": true,
"@metamask/keyring-api": true,
"@metamask/multichain-transactions-controller>@metamask/keyring-snap-client": true,
"@metamask/snaps-utils": true,
"@metamask/multichain-transactions-controller>@metamask/snaps-utils": true,
"@metamask/multichain-transactions-controller>@metamask/utils": true
}
},
Expand Down Expand Up @@ -1886,7 +1870,7 @@
"setTimeout": true
},
"packages": {
"@metamask/snaps-controllers>@metamask/base-controller": true,
"@metamask/base-controller": true,
"@metamask/json-rpc-engine": true,
"@metamask/json-rpc-middleware-stream": true,
"@metamask/object-multiplex": true,
Expand Down Expand Up @@ -1991,6 +1975,76 @@
"@metamask/snaps-utils>validate-npm-package-name": true
}
},
"@metamask/assets-controllers>@metamask/snaps-utils": {
"globals": {
"File": true,
"FileReader": true,
"TextDecoder": true,
"TextEncoder": true,
"URL": true,
"console.error": true,
"console.log": true,
"console.warn": true,
"crypto": true,
"document.body.appendChild": true,
"document.createElement": true,
"fetch": true
},
"packages": {
"@metamask/snaps-sdk>@metamask/key-tree": true,
"@metamask/permission-controller": true,
"@metamask/rpc-errors": true,
"@metamask/snaps-utils>@metamask/slip44": true,
"@metamask/snaps-sdk": true,
"@metamask/utils>@metamask/superstruct": true,
"@metamask/assets-controllers>@metamask/utils": true,
"@noble/hashes": true,
"@metamask/utils>@scure/base": true,
"chalk": true,
"@metamask/snaps-utils>cron-parser": true,
"@metamask/snaps-utils>fast-json-stable-stringify": true,
"@metamask/snaps-utils>fast-xml-parser": true,
"@metamask/snaps-utils>marked": true,
"@metamask/snaps-utils>rfdc": true,
"semver": true,
"@metamask/snaps-utils>validate-npm-package-name": true
}
},
"@metamask/multichain-transactions-controller>@metamask/snaps-utils": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should update @metamask/snaps-utils in MetaMask/core so we can dedupe this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely

"globals": {
"File": true,
"FileReader": true,
"TextDecoder": true,
"TextEncoder": true,
"URL": true,
"console.error": true,
"console.log": true,
"console.warn": true,
"crypto": true,
"document.body.appendChild": true,
"document.createElement": true,
"fetch": true
},
"packages": {
"@metamask/snaps-sdk>@metamask/key-tree": true,
"@metamask/permission-controller": true,
"@metamask/rpc-errors": true,
"@metamask/snaps-utils>@metamask/slip44": true,
"@metamask/snaps-sdk": true,
"@metamask/utils>@metamask/superstruct": true,
"@metamask/multichain-transactions-controller>@metamask/utils": true,
"@noble/hashes": true,
"@metamask/utils>@scure/base": true,
"chalk": true,
"@metamask/snaps-utils>cron-parser": true,
"@metamask/snaps-utils>fast-json-stable-stringify": true,
"@metamask/snaps-utils>fast-xml-parser": true,
"@metamask/snaps-utils>marked": true,
"@metamask/snaps-utils>rfdc": true,
"semver": true,
"@metamask/snaps-utils>validate-npm-package-name": true
}
},
"@metamask/transaction-controller": {
"globals": {
"clearTimeout": true,
Expand Down
Loading
Loading