TxnLab / use-wallet

A framework agnostic wallet integration library for Algorand dApps
https://txnlab.gitbook.io/use-wallet
MIT License
81 stars 28 forks source link

[v3] Pera needs global shim #191

Closed PhearZero closed 2 weeks ago

PhearZero commented 1 month ago

Overview

v3 with pera fails to connect with message

ReferenceError: global is not defined

Resolution

Add shim to index.html but it may be better to update the pera library

<head>
  <script>
        // Suggest that Pera to use globalThis instead of global | window
        globalThis.global = globalThis
  </script>
</head>

Details

drichar commented 1 month ago

Yeah this is a bug report I get often in the use-wallet channel on NFD's Discord. There's an open issue for it on Pera Connect: https://github.com/perawallet/connect/issues/101

The Vite example apps for v3 all include the index.html shim: https://github.com/TxnLab/use-wallet/blob/v3/examples/react-ts/index.html#L12

It would be nice to have this resolved in Pera Connect v2, if possible. I don't think it qualifies as a use-wallet issue per se, other than drawing more attention to it in the documentation.

PhearZero commented 1 month ago

Fixed! Going to issue a PR to pera, could be useful while we migrate to v2. I'll take a dive into v2 if we still have issues there

npm install awesome-algorand/walletconnect-socket-transport --save

Edit: Hopefully it lands: https://github.com/perawallet/connect/pull/164