Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aepp-wallet connection is not working if aepp running over file:// protocol #1872

Closed
davidyuk opened this issue Jul 29, 2023 · 1 comment · Fixed by #1900
Closed

Aepp-wallet connection is not working if aepp running over file:// protocol #1872

davidyuk opened this issue Jul 29, 2023 · 1 comment · Fixed by #1900
Labels
bug Something isn't working

Comments

@davidyuk
Copy link
Member

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>SDK test in browser</title>
</head>
<body>
  Open developer console
  <script src="https://unpkg.com/@aeternity/aepp-sdk@13.2.0/dist/aepp-sdk.browser-script.js"></script>
  <script type="text/javascript">
    const { AeSdkAepp, Node, CompilerHttp, walletDetector, BrowserWindowMessageConnection } = Aeternity;
    const aeSdk = new AeSdkAepp({
      name: 'Simple æpp',
      nodes: [
        { name: 'testnet', instance: new Node('https://testnet.aeternity.io') },
        { name: 'mainnet', instance: new Node('https://mainnet.aeternity.io') },
      ],
      onCompiler: new CompilerHttp('https://v7.compiler.aepps.com'),
      async onNetworkChange({ networkId }) {
        console.log('Network', networkId);
        const [{ name }] = (await this.getNodesInPool())
          .filter((node) => node.nodeNetworkId === networkId);
        this.selectNode(name);
      },
    });
    async function detectWallets() {
      const connection = new BrowserWindowMessageConnection();
      return new Promise((resolve, reject) => {
        const stopDetection = walletDetector(connection, async ({ newWallet }) => {
          if (confirm(`Do you want to connect to wallet ${newWallet.info.name} with id ${newWallet.info.id}`)) {
            stopDetection();
            resolve(newWallet.getConnection());
          }
        });
      });
    }
    (async () => {
      console.log('Looking for a wallet');
      const connection = await detectWallets();
      const walletInfo = await aeSdk.connectToWallet(connection);
      console.log('Connected to', walletInfo);
      const { address: { current } } = await aeSdk.subscribeAddress('subscribe', 'connected');
      console.log('Address', current);
    })();
  </script>
</body>
</html>
  • save the above to index.html
  • drag it into Chrome
  • ensure that it stuck after printing "Looking for a wallet", with Superhero Wallet installed
@davidyuk davidyuk added the bug Something isn't working label Jul 29, 2023
@davidyuk
Copy link
Member Author

Not possible with wallet-iframe because of error

Not allowed to load local resource: file:///.../aepp-sdk-js/test/environment/browser-aepp.html

trying to open file:/// in <iframe />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@davidyuk and others