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

Pera wallet connect not working #1548

Open
kieranroneill opened this issue Jan 30, 2023 · 2 comments
Open

Pera wallet connect not working #1548

kieranroneill opened this issue Jan 30, 2023 · 2 comments

Comments

@kieranroneill
Copy link

Describe the error

In the latest update, it seems Pera wallet connect no longer seems to work. Whenever a transaction is sent to be signed to Pera an error is thrown:

"TypeError: e.map is not a function"

To Reproduce

import { ALGO_MakePeraConnect as MakePeraConnect } from '@reach-sh/stdlib'; // 0.1.13-rc.0
import { PeraWalletConnect } from "@perawallet/connect"; // 1.1.0

stdlib.setWalletFallback(
  stdlib.walletFallback({
    providerEnv: 'TestNet', 
    WalletConnect: MakePeraConnect(PeraWalletConnect) 
  })
);

await stdlib.getDefaultAccount();

Expected behavior

  • Pera wallet connect's modal pops up.

Extra information

Looking at the code where the transactions are sent to Pera wallet here, the unsigned transactions are sent in base64 but @perawallet/connect is expecting an unsigned Transaction that is from the algosdk.

Therefore, signTxns should probably follow:

import { decodeUnsignedTransaction } from 'algosdk';

export default function ALGO_MakePeraConnect( PeraWalletConnect:any ) {
  return class PeraConnect {
    // ...
    async signTxns(txns:string[]): Promise<string[]> {
      let rawSignedTxns: Uint8Array[];

      await this.ensureSession();

      rawSignedTxns = await this.pc.signTransaction([
        txns.map((value) => {
          const decodedUnsignedTxn: Transaction = decodeUnsignedTransaction(Buffer.from(value, 'base64')); // decode the transaction

          return {
            txn: decodedUnsignedTxn,
          };
        }),
      ]);

      return rawSignedTxns.map((value) =>
        Buffer.from(value).toString('base64') // encode the signed transactions back to base64 to be returned
      );
    }
  }
};
@BMscis
Copy link

BMscis commented Jun 29, 2023

Does this work for reach ?

@temptemp3
Copy link
Contributor

Does this work for reach ?

Sure it does ; )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants