Skip to content

Commit 867cbf8

Browse files
committed
chore: synced with main
2 parents 7f962bc + 8358b54 commit 867cbf8

File tree

38 files changed

+520
-206
lines changed

38 files changed

+520
-206
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
diff --git a/dist/TokenBalancesController.cjs b/dist/TokenBalancesController.cjs
2+
index 4918812dde60b8d0e24a7bded27d88f233968858..4e8018bce92b9e5d47fc40784409e16db22be615 100644
3+
--- a/dist/TokenBalancesController.cjs
4+
+++ b/dist/TokenBalancesController.cjs
5+
@@ -535,14 +535,16 @@ class TokenBalancesController extends (0, polling_controller_1.StaticIntervalPol
6+
}
7+
// Update with actual fetched balances only if the value has changed
8+
aggregated.forEach(({ success, value, account, token, chainId }) => {
9+
- var _a, _b, _c;
10+
+ var _a, _b;
11+
if (success && value !== undefined) {
12+
+ // Ensure all accounts we add/update are in lower-case
13+
+ const lowerCaseAccount = account.toLowerCase();
14+
const newBalance = (0, controller_utils_1.toHex)(value);
15+
const tokenAddress = checksum(token);
16+
- const currentBalance = d.tokenBalances[account]?.[chainId]?.[tokenAddress];
17+
+ const currentBalance = d.tokenBalances[lowerCaseAccount]?.[chainId]?.[tokenAddress];
18+
// Only update if the balance has actually changed
19+
if (currentBalance !== newBalance) {
20+
- ((_c = ((_a = d.tokenBalances)[_b = account] ?? (_a[_b] = {})))[chainId] ?? (_c[chainId] = {}))[tokenAddress] = newBalance;
21+
+ ((_b = ((_a = d.tokenBalances)[lowerCaseAccount] ?? (_a[lowerCaseAccount] = {})))[chainId] ?? (_b[chainId] = {}))[tokenAddress] = newBalance;
22+
}
23+
}
24+
});
25+
diff --git a/dist/TokenBalancesController.mjs b/dist/TokenBalancesController.mjs
26+
index f64d13f8de56631345a44e6ebb025e62e03f51bc..99aa7f27c574c94b26daa56091ac50d15281dd30 100644
27+
--- a/dist/TokenBalancesController.mjs
28+
+++ b/dist/TokenBalancesController.mjs
29+
@@ -531,14 +531,16 @@ export class TokenBalancesController extends StaticIntervalPollingController() {
30+
}
31+
// Update with actual fetched balances only if the value has changed
32+
aggregated.forEach(({ success, value, account, token, chainId }) => {
33+
- var _a, _b, _c;
34+
+ var _a, _b;
35+
if (success && value !== undefined) {
36+
+ // Ensure all accounts we add/update are in lower-case
37+
+ const lowerCaseAccount = account.toLowerCase();
38+
const newBalance = toHex(value);
39+
const tokenAddress = checksum(token);
40+
- const currentBalance = d.tokenBalances[account]?.[chainId]?.[tokenAddress];
41+
+ const currentBalance = d.tokenBalances[lowerCaseAccount]?.[chainId]?.[tokenAddress];
42+
// Only update if the balance has actually changed
43+
if (currentBalance !== newBalance) {
44+
- ((_c = ((_a = d.tokenBalances)[_b = account] ?? (_a[_b] = {})))[chainId] ?? (_c[chainId] = {}))[tokenAddress] = newBalance;
45+
+ ((_b = ((_a = d.tokenBalances)[lowerCaseAccount] ?? (_a[lowerCaseAccount] = {})))[chainId] ?? (_b[chainId] = {}))[tokenAddress] = newBalance;
46+
}
47+
}
48+
});
14.6 KB
Binary file not shown.
-994 KB
Binary file not shown.
-3.64 KB
Binary file not shown.

app/images/shield-entry-modal.png

-13.6 KB
Binary file not shown.
-601 Bytes
Binary file not shown.
-58.8 KB
Binary file not shown.

app/manifest/v3/_base.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
"notifications",
8585
"scripting",
8686
"storage",
87-
"tabs",
8887
"unlimitedStorage",
8988
"webRequest",
9089
"offscreen",

development/webpack/test/config.test.ts

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import fs from 'node:fs';
2-
import { describe, it, after, mock } from 'node:test';
2+
import { describe, it, afterEach, mock } from 'node:test';
33
import assert from 'node:assert';
44
import { resolve } from 'node:path';
55
import { version } from '../../../package.json';
@@ -13,21 +13,29 @@ describe('./utils/config.ts', () => {
1313
// behaving
1414
describe('variables', () => {
1515
const originalReadFileSync = fs.readFileSync;
16-
function mockRc(env: Record<string, string> = {}) {
16+
function mockRc(
17+
env: Record<string, string> = {},
18+
prodEnv: Record<string, string> = {},
19+
) {
1720
mock.method(fs, 'readFileSync', (path: string, options: object) => {
21+
// mock the rc files as users might have customized it which may break our tests
1822
if (path === resolve(__dirname, '../../../.metamaskrc')) {
19-
// mock `.metamaskrc`, as users might have customized it which may
20-
// break our tests
2123
return `
22-
${Object.entries(env)
23-
.map(([key, value]) => `${key}=${value}`)
24-
.join('\n')}
25-
`;
24+
${Object.entries(env)
25+
.map(([key, value]) => `${key}=${value}`)
26+
.join('\n')}
27+
`;
28+
} else if (path === resolve(__dirname, '../../../.metamaskprodrc')) {
29+
return `
30+
${Object.entries(prodEnv)
31+
.map(([key, value]) => `${key}=${value}`)
32+
.join('\n')}
33+
`;
2634
}
2735
return originalReadFileSync(path, options);
2836
});
2937
}
30-
after(() => mock.restoreAll());
38+
afterEach(() => mock.restoreAll());
3139

3240
it('should return valid build variables for the default build', () => {
3341
const buildTypes = loadBuildTypesConfig();
@@ -49,17 +57,31 @@ ${Object.entries(env)
4957
);
5058
});
5159

52-
it('should prefer .metamaskrc variables over others', () => {
60+
it('should prefer .metamaskprodrc over .metamaskrc', () => {
5361
const buildTypes = loadBuildTypesConfig();
5462
const { args } = parseArgv([], buildTypes);
5563
const defaultVars = config.getVariables(args, buildTypes);
5664

5765
// verify the default value of the main build is false
5866
assert.strictEqual(defaultVars.variables.get('ALLOW_LOCAL_SNAPS'), false);
5967

60-
mockRc({
61-
ALLOW_LOCAL_SNAPS: 'true',
62-
});
68+
mockRc({ ALLOW_LOCAL_SNAPS: 'false' }, { ALLOW_LOCAL_SNAPS: 'true' });
69+
70+
const overrides = config.getVariables(args, buildTypes);
71+
72+
// verify the value of the main build is set to the value in .metamaskprodrc
73+
assert.strictEqual(overrides.variables.get('ALLOW_LOCAL_SNAPS'), true);
74+
});
75+
76+
it('should prefer .metamaskrc variables over builds.yml', () => {
77+
const buildTypes = loadBuildTypesConfig();
78+
const { args } = parseArgv([], buildTypes);
79+
const defaultVars = config.getVariables(args, buildTypes);
80+
81+
// verify the default value of the main build is false
82+
assert.strictEqual(defaultVars.variables.get('ALLOW_LOCAL_SNAPS'), false);
83+
84+
mockRc({ ALLOW_LOCAL_SNAPS: 'true' });
6385

6486
const overrides = config.getVariables(args, buildTypes);
6587

@@ -68,10 +90,8 @@ ${Object.entries(env)
6890
});
6991

7092
it('should return valid build variables for a non-default build', () => {
71-
mockRc({
72-
// required by the `beta` build type
73-
SEGMENT_BETA_WRITE_KEY: '.',
74-
});
93+
// required by the `beta` build type
94+
mockRc({ SEGMENT_BETA_WRITE_KEY: '.' });
7595
const buildTypes = loadBuildTypesConfig();
7696
const { args } = parseArgv(
7797
['--type', 'beta', '--test', '--env', 'production'],

development/webpack/utils/config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,16 @@ export function getVariables(
155155
}
156156

157157
/**
158-
* Loads configuration variables from process.env, .metamaskrc, and build.yml.
158+
* Loads configuration variables from process.env, .metamaskprodrc, .metamaskrc, and build.yml.
159159
*
160160
* The order of precedence is:
161161
* 1. process.env
162-
* 2. .metamaskrc
163-
* 3. build.yml
162+
* 2. .metamaskprodrc
163+
* 3. .metamaskrc
164+
* 4. builds.yml
164165
*
165166
* i.e., if a variable is defined in `process.env`, it will take precedence over
166-
* the same variable defined in `.metamaskrc` or `build.yml`.
167+
* the same variable defined in `.metamaskprodrc`, `.metamaskrc` or `build.yml`.
167168
*
168169
* @param activeBuild
169170
* @param build
@@ -175,6 +176,7 @@ function loadConfigVars(
175176
{ env }: BuildTypesConfig,
176177
) {
177178
const definitions = loadEnv();
179+
addRc(definitions, join(__dirname, '../../../.metamaskprodrc'));
178180
addRc(definitions, join(__dirname, '../../../.metamaskrc'));
179181
addVars(activeBuild.env);
180182
addVars(env);

0 commit comments

Comments
 (0)