Skip to content

Commit

Permalink
refactor(wallet): Streamline lockdown process using consoleTaming par…
Browse files Browse the repository at this point in the history
…am (#3890)

* refactor(wallet): Streamline lockdown process using consoleTaming param

* chore(wallet): Add public/lockdown.umd.js to gitignore
  • Loading branch information
samsiegart authored Sep 24, 2021
1 parent 4e1fc9f commit 05e4370
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
1 change: 1 addition & 0 deletions packages/dapp-svelte-wallet/react-ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# production
/build
/public/lockdown.umd.js

# misc
.DS_Store
Expand Down
22 changes: 16 additions & 6 deletions packages/dapp-svelte-wallet/react-ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
<meta charset="utf-8" />
<script src="lockdown.umd.js"></script>
<script>
if ('%NODE_ENV%' === 'production') {
const { pow: mathPow } = Math;
Math.pow = (base, exp) => (typeof base === 'bigint' && typeof exp ==='bigint') ? base ** exp : mathPow(base, exp);
lockdown({ __allowUnsafeMonkeyPatching__: 'unsafe', errorTaming: 'unsafe', overrideTaming: 'severe' });
console.log('lockdown done.');
}
// Allow the React dev environment to extend the console for debugging
// features.
const consoleTaming = '%NODE_ENV%' === 'production' ? 'safe' : 'unsafe';

const { pow: mathPow } = Math;
Math.pow = (base, exp) =>
(typeof base === 'bigint' && typeof exp ==='bigint')
? base ** exp : mathPow(base, exp);

lockdown({
__allowUnsafeMonkeyPatching__: 'unsafe',
errorTaming: 'unsafe',
overrideTaming: 'severe',
consoleTaming: consoleTaming });

console.log('lockdown done.');
</script>
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
Expand Down
3 changes: 2 additions & 1 deletion packages/dapp-svelte-wallet/react-ui/src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import './install-ses-lockdown.js';
import React from 'react';
import ReactDOM from 'react-dom';

import './index.css';
import App from './App.js';

Error.stackTraceLimit = Infinity;

ReactDOM.render(<App />, document.getElementById('root'));
19 changes: 0 additions & 19 deletions packages/dapp-svelte-wallet/react-ui/src/install-ses-lockdown.js

This file was deleted.

0 comments on commit 05e4370

Please sign in to comment.