Skip to content

Commit

Permalink
fix sign / signAll in all adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
jordaaash committed Sep 15, 2022
1 parent 80d1d48 commit f2d50d6
Show file tree
Hide file tree
Showing 41 changed files with 151 additions and 151 deletions.
8 changes: 4 additions & 4 deletions packages/wallets/alpha/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ export class AlphaWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signTransaction(transaction: Transaction): Promise<Transaction> {
async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signTransaction(transaction)) || transaction;
return ((await wallet.signTransaction(transaction)) as T) || transaction;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand All @@ -202,13 +202,13 @@ export class AlphaWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signAllTransactions(transactions: Transaction[]): Promise<Transaction[]> {
async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signAllTransactions(transactions)) || transactions;
return ((await wallet.signAllTransactions(transactions)) as T[]) || transactions;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/wallets/avana/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ export class AvanaWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signTransaction(transaction: Transaction): Promise<Transaction> {
async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signTransaction(transaction)) || transaction;
return ((await wallet.signTransaction(transaction)) as T) || transaction;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand All @@ -204,13 +204,13 @@ export class AvanaWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signAllTransactions(transactions: Transaction[]): Promise<Transaction[]> {
async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signAllTransactions(transactions)) || transactions;
return ((await wallet.signAllTransactions(transactions)) as T[]) || transactions;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/wallets/backpack/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ export class BackpackWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signTransaction(transaction: Transaction): Promise<Transaction> {
async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return await wallet.signTransaction(transaction, this.publicKey);
return (await wallet.signTransaction(transaction, this.publicKey)) as T;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand All @@ -194,13 +194,13 @@ export class BackpackWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signAllTransactions(transactions: Transaction[]): Promise<Transaction[]> {
async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return await wallet.signAllTransactions(transactions, this.publicKey);
return (await wallet.signAllTransactions(transactions, this.publicKey)) as T[];
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/wallets/bitkeep/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ export class BitKeepWalletAdapter extends BaseMessageSignerWalletAdapter {
this.emit('disconnect');
}

async signTransaction(transaction: Transaction): Promise<Transaction> {
async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signTransaction(transaction)) || transaction;
return ((await wallet.signTransaction(transaction)) as T) || transaction;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand All @@ -148,13 +148,13 @@ export class BitKeepWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signAllTransactions(transactions: Transaction[]): Promise<Transaction[]> {
async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signAllTransactions(transactions)) || transactions;
return ((await wallet.signAllTransactions(transactions)) as T[]) || transactions;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/wallets/bitpie/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ export class BitpieWalletAdapter extends BaseSignerWalletAdapter {
this.emit('disconnect');
}

async signTransaction(transaction: Transaction): Promise<Transaction> {
async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signTransaction(transaction)) || transaction;
return ((await wallet.signTransaction(transaction)) as T) || transaction;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand All @@ -133,13 +133,13 @@ export class BitpieWalletAdapter extends BaseSignerWalletAdapter {
}
}

async signAllTransactions(transactions: Transaction[]): Promise<Transaction[]> {
async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signAllTransactions(transactions)) || transactions;
return ((await wallet.signAllTransactions(transactions)) as T[]) || transactions;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/wallets/brave/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ export class BraveWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signTransaction(transaction: Transaction): Promise<Transaction> {
async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signTransaction(transaction)) || transaction;
return ((await wallet.signTransaction(transaction)) as T) || transaction;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand All @@ -202,13 +202,13 @@ export class BraveWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signAllTransactions(transactions: Transaction[]): Promise<Transaction[]> {
async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signAllTransactions(transactions)) || transactions;
return ((await wallet.signAllTransactions(transactions)) as T[]) || transactions;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/wallets/clover/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ export class CloverWalletAdapter extends BaseMessageSignerWalletAdapter {
this.emit('disconnect');
}

async signTransaction(transaction: Transaction): Promise<Transaction> {
async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signTransaction(transaction)) || transaction;
return ((await wallet.signTransaction(transaction)) as T) || transaction;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand All @@ -137,13 +137,13 @@ export class CloverWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signAllTransactions(transactions: Transaction[]): Promise<Transaction[]> {
async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signAllTransactions(transactions)) || transactions;
return ((await wallet.signAllTransactions(transactions)) as T[]) || transactions;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/wallets/coin98/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class Coin98WalletAdapter extends BaseMessageSignerWalletAdapter {
this.emit('disconnect');
}

async signTransaction(transaction: Transaction): Promise<Transaction> {
async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();
Expand All @@ -164,7 +164,7 @@ export class Coin98WalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signAllTransactions(transactions: Transaction[]): Promise<Transaction[]> {
async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();
Expand Down
8 changes: 4 additions & 4 deletions packages/wallets/coinbase/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ export class CoinbaseWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signTransaction(transaction: Transaction): Promise<Transaction> {
async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signTransaction(transaction)) || transaction;
return ((await wallet.signTransaction(transaction)) as T) || transaction;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand All @@ -193,13 +193,13 @@ export class CoinbaseWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signAllTransactions(transactions: Transaction[]): Promise<Transaction[]> {
async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signAllTransactions(transactions)) || transactions;
return ((await wallet.signAllTransactions(transactions)) as T[]) || transactions;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/wallets/coinhub/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ export class CoinhubWalletAdapter extends BaseSignerWalletAdapter {
this.emit('disconnect');
}

async signTransaction(transaction: Transaction): Promise<Transaction> {
async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return wallet.signTransaction(transaction);
return (await wallet.signTransaction(transaction)) as T;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand All @@ -135,13 +135,13 @@ export class CoinhubWalletAdapter extends BaseSignerWalletAdapter {
}
}

async signAllTransactions(transactions: Transaction[]): Promise<Transaction[]> {
async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return wallet.signAllTransactions(transactions);
return (await wallet.signAllTransactions(transactions)) as T[];
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/wallets/exodus/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ export class ExodusWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signTransaction(transaction: Transaction): Promise<Transaction> {
async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return await wallet.signTransaction(transaction);
return (await wallet.signTransaction(transaction)) as T;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand All @@ -204,13 +204,13 @@ export class ExodusWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signAllTransactions(transactions: Transaction[]): Promise<Transaction[]> {
async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return await wallet.signAllTransactions(transactions);
return (await wallet.signAllTransactions(transactions)) as T[];
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/wallets/glow/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ export class GlowWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signTransaction(transaction: Transaction): Promise<Transaction> {
async signTransaction<T extends Transaction>(transaction: T): Promise<T> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signTransaction(transaction, this._network)) || transaction;
return ((await wallet.signTransaction(transaction, this._network)) as T) || transaction;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand All @@ -227,13 +227,13 @@ export class GlowWalletAdapter extends BaseMessageSignerWalletAdapter {
}
}

async signAllTransactions(transactions: Transaction[]): Promise<Transaction[]> {
async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return (await wallet.signAllTransactions(transactions, this._network)) || transactions;
return ((await wallet.signAllTransactions(transactions, this._network)) as T[]) || transactions;
} catch (error: any) {
throw new WalletSignTransactionError(error?.message, error);
}
Expand Down
Loading

0 comments on commit f2d50d6

Please sign in to comment.