Skip to main content

Switching accounts on the same departure chain

In the first version of the widget, there was an issue with switching accounts without changing the blockchain of departure. A user switched the account in the browser extension, but the bridge kept displaying the assets of the initial account. It was caused by the inability of the Metamask wallet to interact with the <iframe> tag properly.

We have fixed the bug by adding the missing code. Now the <iframe> gets properly notified of the changes in Metamask.

Step 1 - viewing the assets

9

Fig.1 - NFT Cards displaying assets of the first account

Step 2 - switching accounts in Metamask

  1. Open Metamask and select a different account.
  2. Click the Connect link for the selected account.

10

Fig.2 - Switching accounts in Metamask

Step 3 - viewing the assets of the second account

11

Fig.3 - NFT Cards displaying assets of the second account

New structure

The new structure of the widget allows for establishing communication between the browser extension and the iframe:

<!-- 1. The wrapping tag of the widget -->
<div>
<!-- 2. The iframe with the widget settings -->
<iframe>
...
</iframe>
<!-- 3. The JavaScript code connecting Metamask & the iframe -->
<script src='https://widget-staging.xp.network/wscript.js'>
</script>
</div>

To conform with the security best practices, it is a good idea to protect the script link above with the unique nonce or add the JavaScript code of the widget to the rest of the trusted JS source code.