Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// setup a response listener (events created by the loader for extension responses)
window.addEventListener('message', ({ data, source }): void => {
// only allow messages from our window, by the loader
if (source !== window || data.origin !== 'content') {
return;
}
if (data.id) {
handleResponse(data);
} else {
console.error('Missing id for response.');
}
});
injectExtension(enable, {
name: 'polkadot-js',
version: process.env.PKG_VERSION as string
});