Skip to content

Commit

Permalink
Merge branch 'develop' into ad/fix/remove-snaps-methods-from-queueing
Browse files Browse the repository at this point in the history
  • Loading branch information
adonesky1 committed May 6, 2024
2 parents 426b5b4 + ba1e55b commit c3d6658
Show file tree
Hide file tree
Showing 50 changed files with 685 additions and 183 deletions.
54 changes: 10 additions & 44 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,54 +407,20 @@ jobs:
command: |
#!/bin/bash
# GitHub Personal Access Token for API Authentication
GITHUB_TOKEN="${GITHUB_TOKEN}"
BRANCH="${CIRCLE_BRANCH}"
# Fetch the PRs associated with the current branch and check the response
PR_RESPONSE=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" \
"https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?state=open&head=${CIRCLE_PROJECT_USERNAME}:${BRANCH}")
echo "https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?state=open&head=${CIRCLE_PROJECT_USERNAME}:${BRANCH}"
# Check if the response contains valid JSON
if ! echo "$PR_RESPONSE" | jq empty; then
echo "Failed to parse JSON response."
echo "$PR_RESPONSE"
exit 1
fi
# Check if we received an array of PRs
if ! echo "$PR_RESPONSE" | jq -e '. | type == "array"'; then
echo "$PR_RESPONSE"
echo "Expected an array of PRs, got something else."
exit 1
fi
GH_LABEL=team-mmi
# Check if the array of PRs is empty
PR_COUNT=$(echo "$PR_RESPONSE" | jq '. | length')
echo $CIRCLE_PULL_REQUESTS | sed 's/,/\n/g'
# If no PRs are found, exit gracefully
if [ "$PR_COUNT" -eq 0 ]; then
echo "No open PRs found. Exiting."
echo "false" > ./RUN_MMI_OPTIONAL
exit 0
fi
# Extract label names from the PR_RESPONSE
LABEL_NAMES=$(echo "$PR_RESPONSE" | jq -r '.[0].labels[].name')
# See if any associated PRs have matching label
HAS_MATCHING_PR=$(echo $CIRCLE_PULL_REQUESTS \
| sed -e 's#,#\n#g' -e 's#/github.com/#/api.github.com/repos/#g' -e 's#/pull/#/pulls/#g' \
| xargs -n1 curl -s \
| jq -s "map((.labels|map(select(.name==\"${GH_LABEL}\"))))|flatten|length > 0")
echo "Labels found: $LABEL_NAMES"
echo "${GH_LABEL} tag presence: ${HAS_MATCHING_PR}"
# Check if "team-mmi" label is present
if echo "$LABEL_NAMES" | grep -qw "team-mmi"; then
echo "team-mmi tag found."
# assign the RUN_MMI_OPTIONAL variable to true
echo "true" > ./RUN_MMI_OPTIONAL
else
echo "team-mmi tag not found."
# assign the RUN_MMI_OPTIONAL variable to false
echo "false" > ./RUN_MMI_OPTIONAL
fi
# assign the RUN_MMI_OPTIONAL variable
echo "${HAS_MATCHING_PR}" > ./RUN_MMI_OPTIONAL
- persist_to_workspace:
root: .
paths:
Expand Down
33 changes: 33 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions app/scripts/controllers/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ export default class PreferencesController {
useExternalNameSources: true,
useTransactionSimulations: true,
enableMV3TimestampSave: true,
// Turning OFF basic functionality toggle means turning OFF this useExternalServices flag.
// Whenever useExternalServices is false, certain features will be disabled.
// The flag is true by Default, meaning the toggle is ON by default.
useExternalServices: true,
...opts.initState,
};

Expand Down Expand Up @@ -212,6 +216,16 @@ export default class PreferencesController {
this.store.updateState({ useSafeChainsListValidation: val });
}

toggleExternalServices(useExternalServices) {
this.store.updateState({ useExternalServices });
this.setUseTokenDetection(useExternalServices);
this.setUseCurrencyRateCheck(useExternalServices);
this.setUsePhishDetect(useExternalServices);
this.setUseAddressBarEnsResolution(useExternalServices);
this.setOpenSeaEnabled(useExternalServices);
this.setUseNftDetection(useExternalServices);
}

/**
* Setter for the `useTokenDetection` property
*
Expand Down
1 change: 1 addition & 0 deletions app/scripts/lib/setupSentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export const SENTRY_BACKGROUND_STATE = {
useNativeCurrencyAsPrimaryCurrency: true,
petnamesEnabled: true,
},
useExternalServices: false,
selectedAddress: false,
snapRegistryList: false,
theme: true,
Expand Down
12 changes: 12 additions & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3068,6 +3068,7 @@ export default class MetamaskController extends EventEmitter {
throw new Error(`No account found for address: ${address}`);
}
},
toggleExternalServices: this.toggleExternalServices.bind(this),
addToken: tokensController.addToken.bind(tokensController),
updateTokenType: tokensController.updateTokenType.bind(tokensController),
setFeatureFlag: preferencesController.setFeatureFlag.bind(
Expand Down Expand Up @@ -5641,6 +5642,17 @@ export default class MetamaskController extends EventEmitter {
};
}

toggleExternalServices(useExternal) {
this.preferencesController.toggleExternalServices(useExternal);
if (useExternal) {
this.tokenDetectionController.enable();
this.gasFeeController.enableNonRPCGasFeeApis();
} else {
this.tokenDetectionController.disable();
this.gasFeeController.disableNonRPCGasFeeApis();
}
}

//=============================================================================
// CONFIG
//=============================================================================
Expand Down
18 changes: 4 additions & 14 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -728,26 +728,16 @@
},
"@metamask/address-book-controller": {
"packages": {
"@metamask/address-book-controller>@metamask/controller-utils": true,
"@metamask/base-controller": true
"@metamask/address-book-controller>@metamask/base-controller": true,
"@metamask/controller-utils": true
}
},
"@metamask/address-book-controller>@metamask/controller-utils": {
"@metamask/address-book-controller>@metamask/base-controller": {
"globals": {
"URL": true,
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/ethjs>@metamask/ethjs-unit": true,
"@metamask/utils": true,
"bn.js": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true
"immer": true
}
},
"@metamask/announcement-controller": {
Expand Down
18 changes: 4 additions & 14 deletions lavamoat/browserify/desktop/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -728,26 +728,16 @@
},
"@metamask/address-book-controller": {
"packages": {
"@metamask/address-book-controller>@metamask/controller-utils": true,
"@metamask/base-controller": true
"@metamask/address-book-controller>@metamask/base-controller": true,
"@metamask/controller-utils": true
}
},
"@metamask/address-book-controller>@metamask/controller-utils": {
"@metamask/address-book-controller>@metamask/base-controller": {
"globals": {
"URL": true,
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/ethjs>@metamask/ethjs-unit": true,
"@metamask/utils": true,
"bn.js": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true
"immer": true
}
},
"@metamask/announcement-controller": {
Expand Down
18 changes: 4 additions & 14 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -728,26 +728,16 @@
},
"@metamask/address-book-controller": {
"packages": {
"@metamask/address-book-controller>@metamask/controller-utils": true,
"@metamask/base-controller": true
"@metamask/address-book-controller>@metamask/base-controller": true,
"@metamask/controller-utils": true
}
},
"@metamask/address-book-controller>@metamask/controller-utils": {
"@metamask/address-book-controller>@metamask/base-controller": {
"globals": {
"URL": true,
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/ethjs>@metamask/ethjs-unit": true,
"@metamask/utils": true,
"bn.js": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true
"immer": true
}
},
"@metamask/announcement-controller": {
Expand Down
18 changes: 4 additions & 14 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -728,26 +728,16 @@
},
"@metamask/address-book-controller": {
"packages": {
"@metamask/address-book-controller>@metamask/controller-utils": true,
"@metamask/base-controller": true
"@metamask/address-book-controller>@metamask/base-controller": true,
"@metamask/controller-utils": true
}
},
"@metamask/address-book-controller>@metamask/controller-utils": {
"@metamask/address-book-controller>@metamask/base-controller": {
"globals": {
"URL": true,
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/ethjs>@metamask/ethjs-unit": true,
"@metamask/utils": true,
"bn.js": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true
"immer": true
}
},
"@metamask/announcement-controller": {
Expand Down
18 changes: 4 additions & 14 deletions lavamoat/browserify/mmi/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -867,26 +867,16 @@
},
"@metamask/address-book-controller": {
"packages": {
"@metamask/address-book-controller>@metamask/controller-utils": true,
"@metamask/base-controller": true
"@metamask/address-book-controller>@metamask/base-controller": true,
"@metamask/controller-utils": true
}
},
"@metamask/address-book-controller>@metamask/controller-utils": {
"@metamask/address-book-controller>@metamask/base-controller": {
"globals": {
"URL": true,
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask/controller-utils>@spruceid/siwe-parser": true,
"@metamask/ethjs>@metamask/ethjs-unit": true,
"@metamask/utils": true,
"bn.js": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true
"immer": true
}
},
"@metamask/announcement-controller": {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
"@metamask-institutional/transaction-update": "^0.2.0",
"@metamask/abi-utils": "^2.0.2",
"@metamask/accounts-controller": "^11.0.0",
"@metamask/address-book-controller": "^3.1.7",
"@metamask/address-book-controller": "^4.0.1",
"@metamask/announcement-controller": "^6.1.0",
"@metamask/approval-controller": "^6.0.0",
"@metamask/assets-controllers": "patch:@metamask/assets-controllers@patch%3A@metamask/assets-controllers@patch%253A@metamask/assets-controllers@npm%25253A26.0.0%2523~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch%253A%253Aversion=26.0.0&hash=cf1d54%23~/.yarn/patches/@metamask-assets-controllers-patch-0f46262fea.patch%3A%3Aversion=26.0.0&hash=5c145e#~/.yarn/patches/@metamask-assets-controllers-patch-7616cc1669.patch",
Expand Down Expand Up @@ -572,7 +572,6 @@
"nock": "^13.2.9",
"node-fetch": "^2.6.1",
"nyc": "^15.1.0",
"polyfill-crypto.getrandomvalues": "^1.0.0",
"postcss": "^8.4.32",
"postcss-rtlcss": "^4.0.9",
"prettier": "^2.7.1",
Expand Down
4 changes: 2 additions & 2 deletions shared/modules/selectors/smart-transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
type SmartTransactionsMetaMaskState = {
metamask: {
preferences: {
smartTransactionsOptInStatus: boolean | null;
smartTransactionsOptInStatus?: boolean | null;
};
internalAccounts: {
selectedAccount: string;
Expand Down Expand Up @@ -62,7 +62,7 @@ type SmartTransactionsMetaMaskState = {
export const getSmartTransactionsOptInStatus = (
state: SmartTransactionsMetaMaskState,
): boolean | null => {
return state.metamask.preferences?.smartTransactionsOptInStatus;
return state.metamask.preferences?.smartTransactionsOptInStatus ?? null;
};

export const getCurrentChainSupportsSmartTransactions = (
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/fixture-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ function defaultFixture(inputChainId = CHAIN_IDS.LOCALHOST) {
PreferencesController: {
advancedGasFee: null,
currentLocale: 'en',
useExternalServices: true,
dismissSeedBackUpReminder: true,
featureFlags: {},
forgottenPassword: false,
Expand Down Expand Up @@ -307,6 +308,7 @@ function onboardingFixture() {
useNativeCurrencyAsPrimaryCurrency: true,
petnamesEnabled: true,
},
useExternalServices: true,
theme: 'light',
useBlockie: false,
useNftDetection: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"useNativeCurrencyAsPrimaryCurrency": true,
"petnamesEnabled": true
},
"useExternalServices": "boolean",
"ipfsGateway": "string",
"isIpfsGatewayEnabled": "boolean",
"useAddressBarEnsResolution": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"usePhishDetect": true,
"dismissSeedBackUpReminder": true,
"disabledRpcMethodPreferences": { "eth_sign": false },
"useExternalServices": "boolean",
"useMultiAccountBalanceChecker": true,
"hasDismissedOpenSeaToBlockaidBanner": false,
"useSafeChainsListValidation": true,
Expand Down

0 comments on commit c3d6658

Please sign in to comment.