Skip to content

Commit

Permalink
feat: remove 'audio hack' for Pera
Browse files Browse the repository at this point in the history
Playing an audio file in the background is a workaround for iOS devices breaking the websocket connection when they enter background mode. This solution is now part of Pera Connect's own library, and no longer needed.
  • Loading branch information
gabrielkuettel committed Dec 7, 2022
1 parent 5647acb commit 8dc3a2d
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions src/clients/pera/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,8 @@ class PeraWalletClient extends BaseWallet {
}

async connect(onDisconnect: () => void): Promise<Wallet> {
this.keepWCAliveStart();

const accounts = await this.#client.connect();

this.keepWCAliveStop();

this.#client.connector?.on("disconnect", onDisconnect);

if (accounts.length === 0) {
Expand Down Expand Up @@ -149,15 +145,9 @@ class PeraWalletClient extends BaseWallet {
return acc;
}, []);

// Play an audio file to keep Wallet Connect's web socket open on iOS
// when the user goes into background mode.
this.keepWCAliveStart();

// Sign them with the client.
const result = await this.#client.signTransaction([txnsToSign]);

this.keepWCAliveStop();

// Join the newly signed transactions with the original group of transactions.
const signedTxns = decodedTxns.reduce<Uint8Array[]>((acc, txn, i) => {
if (!("txn" in txn)) {
Expand Down Expand Up @@ -201,14 +191,10 @@ class PeraWalletClient extends BaseWallet {
async signEncodedTransactions(transactions: TransactionsArray) {
const transactionsToSign = this.formatTransactionsArray(transactions);

this.keepWCAliveStart();

const result = (await this.#client.signTransaction([
transactionsToSign,
])) as Uint8Array[];

this.keepWCAliveStop();

const signedTransactions: Uint8Array[] = [];
let resultIndex = 0;

Expand Down

0 comments on commit 8dc3a2d

Please sign in to comment.