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
);
}
}
};
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:
To Reproduce
Expected behavior
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 unsignedTransaction
that is from thealgosdk
.Therefore,
signTxns
should probably follow: