Skip to content

Instantly share code, notes, and snippets.

@lukaw3d
Last active October 22, 2022 00:47
Show Gist options
  • Select an option

  • Save lukaw3d/4575bc197ba0f238ad3ee151b032d75d to your computer and use it in GitHub Desktop.

Select an option

Save lukaw3d/4575bc197ba0f238ad3ee151b032d75d to your computer and use it in GitHub Desktop.
bookmarklet: generate random wallet. Use on e.g. https://wallet.oasisprotocol.org
javascript:
/* use on https://wallet.oasisprotocol.org */
reactContainerField = Object.keys(document.querySelector('#root')).find(field => field.startsWith('__reactContainer'));
store = document.querySelector('#root')[reactContainerField].memoizedState.element.props.store;
function requireUnscrambled(moduleName) {
const parcelRequire = Object.entries(window).find(a => a[0].startsWith('parcelRequire'))[1];
const scrambledName = Object.values(parcelRequire.modules)
.flatMap(a => Object.entries(a[1]))
.find(a => a[0] === moduleName)[1];
return parcelRequire(scrambledName);
}
store.dispatch({ type: 'network/selectNetwork', payload: 'testnet' });
store.dispatch({
type: 'wallet/openWalletFromPrivateKey',
payload: {
privateKey: requireUnscrambled('app/lib/helpers').uint2hex(
requireUnscrambled('app/lib/key').OasisKey.fromPrivateKey(crypto.getRandomValues(new Uint8Array(32)))
),
choosePassword: undefined,
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment