@deeeed/metamask-harness 0.33.1 → 0.33.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -31,6 +31,8 @@ const EOA_METHODS = [
|
|
|
31
31
|
'eth_signTypedData_v3',
|
|
32
32
|
'eth_signTypedData_v4',
|
|
33
33
|
];
|
|
34
|
+
const MAINNET_CHAIN_ID = '0x1';
|
|
35
|
+
const MAINNET_CLIENT_ID = 'mainnet';
|
|
34
36
|
|
|
35
37
|
function usage() {
|
|
36
38
|
console.error(`Usage:
|
|
@@ -224,46 +226,38 @@ async function buildKeyringEntries(target, wallet) {
|
|
|
224
226
|
}
|
|
225
227
|
|
|
226
228
|
function patchAccountTracker(data, addresses) {
|
|
227
|
-
|
|
229
|
+
const accountsByChainId = data.AccountTracker?.accountsByChainId;
|
|
230
|
+
if (!accountsByChainId) {
|
|
228
231
|
return;
|
|
229
232
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
for (const oldAddress of Object.keys(chain)) {
|
|
235
|
-
delete chain[oldAddress];
|
|
236
|
-
}
|
|
237
|
-
for (const address of addresses) {
|
|
238
|
-
chain[address] = { balance: '0x0' };
|
|
239
|
-
}
|
|
233
|
+
const mainnetAccounts = {};
|
|
234
|
+
for (const address of addresses) {
|
|
235
|
+
mainnetAccounts[address] = { balance: '0x0' };
|
|
240
236
|
}
|
|
237
|
+
data.AccountTracker.accountsByChainId = { [MAINNET_CHAIN_ID]: mainnetAccounts };
|
|
241
238
|
}
|
|
242
239
|
|
|
243
240
|
function patchNetworkState(data) {
|
|
244
|
-
const mainnetChainId = '0x1';
|
|
245
|
-
const mainnetClientId = 'mainnet';
|
|
246
|
-
|
|
247
241
|
if (data.NetworkController) {
|
|
248
|
-
data.NetworkController.selectedNetworkClientId =
|
|
242
|
+
data.NetworkController.selectedNetworkClientId = MAINNET_CLIENT_ID;
|
|
249
243
|
|
|
250
244
|
const configs = data.NetworkController.networkConfigurationsByChainId || {};
|
|
251
245
|
for (const chainId of Object.keys(configs)) {
|
|
252
|
-
if (chainId !==
|
|
246
|
+
if (chainId !== MAINNET_CHAIN_ID) {
|
|
253
247
|
delete configs[chainId];
|
|
254
248
|
}
|
|
255
249
|
}
|
|
256
250
|
|
|
257
251
|
const metadata = data.NetworkController.networksMetadata || {};
|
|
258
252
|
for (const clientId of Object.keys(metadata)) {
|
|
259
|
-
if (clientId !==
|
|
253
|
+
if (clientId !== MAINNET_CLIENT_ID) {
|
|
260
254
|
delete metadata[clientId];
|
|
261
255
|
}
|
|
262
256
|
}
|
|
263
257
|
}
|
|
264
258
|
|
|
265
259
|
if (data.NetworkEnablementController?.enabledNetworkMap?.eip155) {
|
|
266
|
-
data.NetworkEnablementController.enabledNetworkMap.eip155 = { [
|
|
260
|
+
data.NetworkEnablementController.enabledNetworkMap.eip155 = { [MAINNET_CHAIN_ID]: true };
|
|
267
261
|
}
|
|
268
262
|
|
|
269
263
|
if (Array.isArray(data.NetworkOrderController?.orderedNetworkList)) {
|