Skip to content

Commit

Permalink
Merge branch 'develop' into getWeiHexFromDecimalValue-error
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing authored Oct 13, 2023
2 parents d5c8a65 + 8235fa2 commit 4cf4d2b
Show file tree
Hide file tree
Showing 37 changed files with 394 additions and 167 deletions.
8 changes: 8 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.

4 changes: 4 additions & 0 deletions app/scripts/lib/setupSentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ export const SENTRY_UI_STATE = {
pendingTokens: false,
welcomeScreenSeen: true,
useSafeChainsListValidation: true,
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
addSnapAccountEnabled: false,
snapsAddSnapAccountModalDismissed: false,
///: END:ONLY_INCLUDE_IN
},
unconnectedAccount: true,
};
Expand Down
2 changes: 2 additions & 0 deletions builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ buildTypes:
features:
- build-main
- snaps
- keyring-snaps
# Additional env variables that are specific to this build
env:
- INFURA_PROD_PROJECT_ID
Expand All @@ -27,6 +28,7 @@ buildTypes:
- REQUIRE_SNAPS_ALLOWLIST: true
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.consensys.io/3.0.0/index.html
- KEYRING_SNAPS_REGISTRY_URL: https://metamask.github.io/keyring-snaps-registry/prod/registry.json
- KEYRING_SNAPS_AVAILABILITY_DATE: 02 Nov 2023 15:00:00 GMT
# Main build uses the default browser manifest
manifestOverrides: false

Expand Down
69 changes: 69 additions & 0 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,50 @@
"koa>content-disposition>safe-buffer": true
}
},
"@metamask/eth-snap-keyring": {
"globals": {
"console.error": true
},
"packages": {
"@ethereumjs/tx": true,
"@metamask/eth-snap-keyring>@metamask/eth-sig-util": true,
"@metamask/eth-snap-keyring>@metamask/utils": true,
"@metamask/eth-snap-keyring>uuid": true,
"@metamask/keyring-api": true,
"superstruct": true,
"webpack>events": true
}
},
"@metamask/eth-snap-keyring>@metamask/eth-sig-util": {
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@ethereumjs/tx>ethereum-cryptography": true,
"@metamask/assets-controllers>@metamask/abi-utils": true,
"@metamask/eth-snap-keyring>@metamask/utils": true,
"browserify>buffer": true,
"eth-sig-util>ethereumjs-util>ethjs-util": true,
"eth-sig-util>tweetnacl": true,
"eth-sig-util>tweetnacl-util": true
}
},
"@metamask/eth-snap-keyring>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/key-tree>@noble/hashes": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true,
"superstruct": true
}
},
"@metamask/eth-snap-keyring>uuid": {
"globals": {
"crypto": true
}
},
"@metamask/eth-token-tracker": {
"globals": {
"console.warn": true
Expand Down Expand Up @@ -1595,6 +1639,31 @@
"TextEncoder": true
}
},
"@metamask/keyring-api": {
"packages": {
"@metamask/keyring-api>@metamask/utils": true,
"@metamask/keyring-api>uuid": true,
"superstruct": true
}
},
"@metamask/keyring-api>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/key-tree>@noble/hashes": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true,
"superstruct": true
}
},
"@metamask/keyring-api>uuid": {
"globals": {
"crypto": true
}
},
"@metamask/keyring-controller": {
"packages": {
"@metamask/base-controller": true,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@
"@metamask/eth-json-rpc-middleware": "^11.0.0",
"@metamask/eth-keyring-controller": "^13.0.1",
"@metamask/eth-ledger-bridge-keyring": "^0.15.0",
"@metamask/eth-snap-keyring": "1.0.0-rc.2",
"@metamask/eth-snap-keyring": "^1.0.0",
"@metamask/eth-token-tracker": "^4.0.0",
"@metamask/eth-trezor-keyring": "^1.1.0",
"@metamask/etherscan-link": "^2.2.0",
"@metamask/ethjs-query": "^0.5.0",
"@metamask/gas-fee-controller": "^6.0.1",
"@metamask/jazzicon": "^2.0.0",
"@metamask/key-tree": "^9.0.0",
"@metamask/keyring-api": "^1.0.0-rc.1",
"@metamask/keyring-api": "^1.0.0",
"@metamask/keyring-controller": "^8.0.1",
"@metamask/logging-controller": "^1.0.1",
"@metamask/logo": "^3.1.2",
Expand Down
7 changes: 3 additions & 4 deletions shared/constants/snaps/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export const EndowmentPermissions = Object.freeze({
'endowment:lifecycle-hooks': 'endowment:lifecycle-hooks',
'endowment:name-lookup': 'endowment:name-lookup',
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
'endowment:keyring': 'endowment:keyring',
///: END:ONLY_INCLUDE_IN
} as const);

// Methods / permissions in external packages that we are temporarily excluding.
Expand All @@ -17,17 +20,13 @@ export const ExcludedSnapPermissions = Object.freeze({
///: BEGIN:ONLY_INCLUDE_IN(build-main)
snap_getLocale:
'This permission is still in development and therefore not available.',
snap_manageAccounts:
'This permission is still in development and therefore not available.',
///: END:ONLY_INCLUDE_IN
eth_accounts:
'eth_accounts is disabled. For more information please see https://github.com/MetaMask/snaps/issues/990.',
});

export const ExcludedSnapEndowments = Object.freeze({
///: BEGIN:ONLY_INCLUDE_IN(build-main)
'endowment:keyring':
'This endowment is still in development therefore not available.',
'endowment:lifecycle-hooks':
'This endowment is experimental and therefore not available.',
'endowment:name-lookup':
Expand Down
23 changes: 23 additions & 0 deletions shared/modules/snap-accounts.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { showSnapAccountExperimentalToggle } from './snap-accounts';

describe('showSnapAccountExperimentalToggle', () => {
beforeEach(() => {
process.env = Object.assign(process.env, {
KEYRING_SNAPS_AVAILABILITY_DATE: '02 Nov 2023 15:00:00 GMT',
});
});

afterEach(() => {
delete process.env.KEYRING_SNAPS_AVAILABILITY_DATE;
});

it('returns false if the current date is before November 2, 2023', () => {
jest.useFakeTimers().setSystemTime(new Date(Date.UTC(2023, 9, 31, 5)));
expect(showSnapAccountExperimentalToggle()).toBe(false);
});

it('returns true if the current date is after November 2, 2023', () => {
jest.useFakeTimers().setSystemTime(new Date(Date.UTC(2023, 10, 3, 5)));
expect(showSnapAccountExperimentalToggle()).toBe(true);
});
});
21 changes: 21 additions & 0 deletions shared/modules/snap-accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
///: BEGIN:ONLY_INCLUDE_IN(build-main)
/**
* Compares the current date to a specific date in UTC.
* This method is meant to be used in a specific case related to the
* Snap Accounts API. It should not be used in other cases.
* Note: Months are 0-indexed in JS, so 10 represents November
*
* @returns true if the current date is after the specified date, false otherwise.
*/
export function showSnapAccountExperimentalToggle(): boolean {
const keyringSnapsAvailabilityDate =
process.env.KEYRING_SNAPS_AVAILABILITY_DATE;
if (!keyringSnapsAvailabilityDate) {
return false;
}

return (
new Date().getTime() > new Date(keyringSnapsAvailabilityDate).getTime()
);
}
///: END:ONLY_INCLUDE_IN
55 changes: 0 additions & 55 deletions test/e2e/accounts/settings-add-snap-account-toggle.spec.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/e2e/accounts/utils.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const TEST_SNAPS_SIMPLE_KEYRING_WEBSITE_URL =
'https://metamask.github.io/snap-simple-keyring/0.4.0/';
'https://metamask.github.io/snap-simple-keyring/1.0.1/';
8 changes: 7 additions & 1 deletion test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,13 @@ async function validateContractDetails(driver) {
await driver.clickElement({ text: 'Got it', tag: 'button' });

// Approve signing typed data
await driver.clickElement('[data-testid="signature-request-scroll-button"]');
try {
await driver.clickElement(
'[data-testid="signature-request-scroll-button"]',
);
} catch (error) {
// Ignore error if scroll button is not present
}
await driver.delay(regularDelayMs);
}

Expand Down
4 changes: 0 additions & 4 deletions test/e2e/run-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ async function main() {
// These tests should only be run on Flask for now.
if (buildType !== 'flask') {
const filteredTests = [
'settings-add-snap-account-toggle.spec.js',
'test-create-snap-account.spec.js',
'test-remove-accounts-snap.spec.js',
'test-snap-accounts.spec.js',
'test-snap-lifecycle.spec.js',
'test-snap-get-locale.spec.js',
'ppom-blockaid-alert.spec.js',
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/add-custom-network.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ describe('Custom network', function () {
});
// verify network switched
const networkDisplayed = await driver.findElement({
tag: 'p',
tag: 'span',
text: 'Arbitrum One',
});
assert.equal(
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/custom-rpc-history.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('Stores custom RPC history', function () {
'.networks-tab__add-network-form-footer .btn-primary',
);

await driver.findElement({ text: networkName, tag: 'p' });
await driver.findElement({ text: networkName, tag: 'span' });
},
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"use4ByteResolution": true,
"useCurrencyRateCheck": true,
"openSeaEnabled": false,
"addSnapAccountEnabled": "boolean",
"advancedGasFee": {},
"featureFlags": {},
"incomingTransactionsPreferences": {},
Expand All @@ -151,6 +152,7 @@
"snapRegistryList": "object",
"transactionSecurityCheckEnabled": false,
"theme": "light",
"snapsAddSnapAccountModalDismissed": "boolean",
"isLineaMainnetReleased": true,
"selectedAddress": "string"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"useNftDetection": false,
"useCurrencyRateCheck": true,
"openSeaEnabled": false,
"addSnapAccountEnabled": "boolean",
"advancedGasFee": {},
"incomingTransactionsPreferences": {},
"lostIdentities": "object",
Expand All @@ -101,6 +102,7 @@
"snapRegistryList": "object",
"transactionSecurityCheckEnabled": false,
"theme": "light",
"snapsAddSnapAccountModalDismissed": "boolean",
"isLineaMainnetReleased": true,
"selectedAddress": "string",
"metaMetricsId": "fake-metrics-id",
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/switch-custom-network.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('Switch ethereum chain', function () {
await driver.switchToWindow(extension);

const currentNetworkName = await driver.findElement({
tag: 'p',
tag: 'span',
text: 'Localhost 8546',
});

Expand Down
5 changes: 3 additions & 2 deletions ui/components/app/asset-list/asset-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { Display } from '../../../helpers/constants/design-system';

import { ReceiveModal } from '../../multichain/receive-modal';
import { useAccountTotalFiatBalance } from '../../../hooks/useAccountTotalFiatBalance';
import { ASSET_LIST_CONVERSION_BUTTON_VARIANT_TYPES } from '../../multichain/asset-list-conversion-button/asset-list-conversion-button';

const AssetList = ({ onClickAsset }) => {
const [showDetectedTokens, setShowDetectedTokens] = useState(false);
Expand Down Expand Up @@ -115,7 +116,7 @@ const AssetList = ({ onClickAsset }) => {
>
{shouldShowBuy ? (
<AssetListConversionButton
variant="buy"
variant={ASSET_LIST_CONVERSION_BUTTON_VARIANT_TYPES.BUY}
onClick={() => {
openBuyCryptoInPdapp();
trackEvent({
Expand All @@ -133,7 +134,7 @@ const AssetList = ({ onClickAsset }) => {
) : null}
{shouldShowReceive ? (
<AssetListConversionButton
variant="receive"
variant={ASSET_LIST_CONVERSION_BUTTON_VARIANT_TYPES.RECEIVE}
onClick={() => setShowReceiveModal(true)}
/>
) : null}
Expand Down
Loading

0 comments on commit 4cf4d2b

Please sign in to comment.