Skip to content

Commit

Permalink
Shim Object.keys
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing committed Nov 14, 2024
1 parent 108ab54 commit c37ef5a
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 159 deletions.
3 changes: 3 additions & 0 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,9 @@
}
},
"@metamask/signature-controller": {
"globals": {
"fetch": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
Expand Down
3 changes: 3 additions & 0 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,9 @@
}
},
"@metamask/signature-controller": {
"globals": {
"fetch": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
Expand Down
3 changes: 3 additions & 0 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,9 @@
}
},
"@metamask/signature-controller": {
"globals": {
"fetch": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
Expand Down
3 changes: 3 additions & 0 deletions lavamoat/browserify/mmi/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2695,6 +2695,9 @@
}
},
"@metamask/signature-controller": {
"globals": {
"fetch": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
Expand Down
170 changes: 19 additions & 151 deletions lavamoat/build-system/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,12 @@
"console.warn": true
},
"packages": {
"@babel/core>@babel/generator>@babel/types": true,
"@babel/core>@babel/generator>jsesc": true,
"@babel/core>@babel/types": true,
"terser-webpack-plugin>@jridgewell/trace-mapping": true,
"terser>@jridgewell/source-map>@jridgewell/gen-mapping": true
}
},
"@babel/core>@babel/generator>@babel/types": {
"globals": {
"console.warn": true,
"process.env": true
},
"packages": {
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
}
},
"@babel/core>@babel/generator>jsesc": {
"globals": {
"Buffer": true
Expand Down Expand Up @@ -182,65 +172,25 @@
"assert": true
},
"packages": {
"@babel/core>@babel/helper-module-transforms>@babel/helper-module-imports>@babel/types": true
}
},
"@babel/core>@babel/helper-module-transforms>@babel/helper-module-imports>@babel/types": {
"globals": {
"console.warn": true,
"process.env": true
},
"packages": {
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
"@babel/core>@babel/types": true
}
},
"@babel/core>@babel/helper-module-transforms>@babel/helper-simple-access": {
"packages": {
"@babel/core>@babel/helper-module-transforms>@babel/helper-simple-access>@babel/types": true
}
},
"@babel/core>@babel/helper-module-transforms>@babel/helper-simple-access>@babel/types": {
"globals": {
"console.warn": true,
"process.env": true
},
"packages": {
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
"@babel/core>@babel/types": true
}
},
"@babel/core>@babel/helpers": {
"packages": {
"@babel/core>@babel/helpers>@babel/types": true,
"@babel/core>@babel/template": true
}
},
"@babel/core>@babel/helpers>@babel/types": {
"globals": {
"console.warn": true,
"process.env": true
},
"packages": {
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
"@babel/core>@babel/template": true,
"@babel/core>@babel/types": true
}
},
"@babel/core>@babel/template": {
"packages": {
"@babel/code-frame": true,
"@babel/core>@babel/parser": true,
"@babel/core>@babel/template>@babel/types": true
}
},
"@babel/core>@babel/template>@babel/types": {
"globals": {
"console.warn": true,
"process.env": true
},
"packages": {
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
"@babel/core>@babel/types": true
}
},
"@babel/core>@babel/types": {
Expand Down Expand Up @@ -481,20 +431,10 @@
"@babel/preset-env>@babel/plugin-transform-async-to-generator>@babel/helper-remap-async-to-generator>@babel/helper-wrap-function": {
"packages": {
"@babel/core>@babel/template": true,
"@babel/preset-env>@babel/plugin-transform-async-to-generator>@babel/helper-remap-async-to-generator>@babel/helper-wrap-function>@babel/types": true,
"@babel/core>@babel/types": true,
"depcheck>@babel/traverse": true
}
},
"@babel/preset-env>@babel/plugin-transform-async-to-generator>@babel/helper-remap-async-to-generator>@babel/helper-wrap-function>@babel/types": {
"globals": {
"console.warn": true,
"process.env": true
},
"packages": {
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
}
},
"@babel/preset-env>@babel/plugin-transform-block-scoped-functions": {
"packages": {
"@babel/core": true,
Expand Down Expand Up @@ -532,17 +472,7 @@
},
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-annotate-as-pure": {
"packages": {
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-annotate-as-pure>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-annotate-as-pure>@babel/types": {
"globals": {
"console.warn": true,
"process.env": true
},
"packages": {
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
"@babel/core>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers": {
Expand All @@ -555,32 +485,12 @@
},
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-member-expression-to-functions": {
"packages": {
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-member-expression-to-functions>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-member-expression-to-functions>@babel/types": {
"globals": {
"console.warn": true,
"process.env": true
},
"packages": {
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
"@babel/core>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-optimise-call-expression": {
"packages": {
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-optimise-call-expression>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-optimise-call-expression>@babel/types": {
"globals": {
"console.warn": true,
"process.env": true
},
"packages": {
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
"@babel/core>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-computed-properties": {
Expand Down Expand Up @@ -675,17 +585,7 @@
},
"@babel/preset-env>@babel/plugin-transform-exponentiation-operator>@babel/helper-builder-binary-assignment-operator-visitor": {
"packages": {
"@babel/preset-env>@babel/plugin-transform-exponentiation-operator>@babel/helper-builder-binary-assignment-operator-visitor>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-exponentiation-operator>@babel/helper-builder-binary-assignment-operator-visitor>@babel/types": {
"globals": {
"console.warn": true,
"process.env": true
},
"packages": {
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
"@babel/core>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-export-namespace-from": {
Expand All @@ -703,17 +603,7 @@
},
"@babel/preset-env>@babel/plugin-transform-for-of>@babel/helper-skip-transparent-expression-wrappers": {
"packages": {
"@babel/preset-env>@babel/plugin-transform-for-of>@babel/helper-skip-transparent-expression-wrappers>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-for-of>@babel/helper-skip-transparent-expression-wrappers>@babel/types": {
"globals": {
"console.warn": true,
"process.env": true
},
"packages": {
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
"@babel/core>@babel/types": true
}
},
"@babel/preset-env>@babel/plugin-transform-function-name": {
Expand Down Expand Up @@ -1261,17 +1151,6 @@
"@metamask/object-multiplex>once>wrappy": true
}
},
"@metamask/snaps-utils>@babel/types": {
"globals": {
"console.warn": true,
"process.env.BABEL_TYPES_8_BREAKING": true
},
"packages": {
"@metamask/snaps-utils>@babel/types>@babel/helper-string-parser": true,
"@metamask/snaps-utils>@babel/types>@babel/helper-validator-identifier": true,
"@metamask/snaps-utils>@babel/types>to-fast-properties": true
}
},
"@metamask/utils>@scure/base": {
"globals": {
"TextDecoder": true,
Expand Down Expand Up @@ -2392,22 +2271,12 @@
"@babel/core>@babel/generator": true,
"@babel/core>@babel/parser": true,
"@babel/core>@babel/template": true,
"@babel/core>@babel/types": true,
"babel/preset-env>b@babel/types": true,
"depcheck>@babel/traverse>@babel/types": true,
"depcheck>@babel/traverse>globals": true,
"nock>debug": true
}
},
"depcheck>@babel/traverse>@babel/types": {
"globals": {
"console.warn": true,
"process.env": true
},
"packages": {
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
}
},
"depcheck>cosmiconfig>parse-json": {
"packages": {
"@babel/code-frame": true,
Expand Down Expand Up @@ -6371,12 +6240,11 @@
"lavamoat-viz>lavamoat-core>lavamoat-tofu>@babel/traverse>@babel/types": {
"globals": {
"console.warn": true,
"process.env.BABEL_TYPES_8_BREAKING": true
"process.env": true
},
"packages": {
"@metamask/snaps-utils>@babel/types>to-fast-properties": true,
"lavamoat-viz>lavamoat-core>lavamoat-tofu>@babel/traverse>@babel/types>@babel/helper-string-parser": true,
"lavamoat-viz>lavamoat-core>lavamoat-tofu>@babel/traverse>@babel/types>@babel/helper-validator-identifier": true
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"lavamoat>@babel/highlight>@babel/helper-validator-identifier": true
}
},
"lavamoat>@lavamoat/aa": {
Expand Down Expand Up @@ -6454,17 +6322,17 @@
"lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-function-name": {
"packages": {
"@babel/core>@babel/template": true,
"@metamask/snaps-utils>@babel/types": true
"@babel/core>@babel/types": true
}
},
"lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-hoist-variables": {
"packages": {
"@metamask/snaps-utils>@babel/types": true
"@babel/core>@babel/types": true
}
},
"lavamoat>lavamoat-tofu>@babel/traverse>@babel/helper-split-export-declaration": {
"packages": {
"@metamask/snaps-utils>@babel/types": true
"@babel/core>@babel/types": true
}
},
"lodash": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,19 @@ const AssetListControlBar = ({ showTokensLinks }: AssetListControlBarProps) => {
useState(false);

const allOpts: Record<string, boolean> = {};
Object.keys(allNetworks).forEach((chainId) => {
Object.keys(allNetworks || {}).forEach((chainId) => {
allOpts[chainId] = true;
});

const allNetworksFilterShown =
Object.keys(tokenNetworkFilter).length !== Object.keys(allOpts).length;
Object.keys(tokenNetworkFilter || {}).length !==
Object.keys(allOpts || {}).length;

// TODO: This useEffect should be a migration
// We need to set the default filter for all users to be all included networks, rather than defaulting to empty object
// This effect is to unblock and derisk in the short-term
useEffect(() => {
if (Object.keys(tokenNetworkFilter).length === 0) {
if (Object.keys(tokenNetworkFilter || {}).length === 0) {
dispatch(setTokenNetworkFilter(allOpts));
}
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ const NetworkFilter = ({ handleClose }: SortControlProps) => {

useEffect(() => {
const testnetChains: string[] = TEST_CHAINS;
const mainnetChainIds = Object.keys(allNetworks).filter(
const mainnetChainIds = Object.keys(allNetworks || {}).filter(
(chain) => !testnetChains.includes(chain),
);
setChainsToShow(mainnetChainIds);
}, []);

const allOpts: Record<string, boolean> = {};
Object.keys(allNetworks).forEach((chain) => {
Object.keys(allNetworks || {}).forEach((chain) => {
allOpts[chain] = true;
});

return (
<>
<SelectableListItem
isSelected={
Object.keys(tokenNetworkFilter).length ===
Object.keys(allNetworks).length
Object.keys(tokenNetworkFilter || {}).length ===
Object.keys(allNetworks || {}).length
}
onClick={() => handleFilter(allOpts)}
>
Expand Down Expand Up @@ -123,7 +123,7 @@ const NetworkFilter = ({ handleClose }: SortControlProps) => {
<SelectableListItem
isSelected={
tokenNetworkFilter[chainId] &&
Object.keys(tokenNetworkFilter).length === 1
Object.keys(tokenNetworkFilter || {}).length === 1
}
onClick={() => handleFilter({ [chainId]: true })}
>
Expand Down

0 comments on commit c37ef5a

Please sign in to comment.