Skip to content

Commit

Permalink
Add signMessage method to Fractal adapter (#661)
Browse files Browse the repository at this point in the history
* Bumps fractal wallet adapter implementation dependency

* Updates fractal impl dep

* Adds `signMessage` support for Fracatal wallet adapter

* Updates lock file

* update lockfile

* add changeset

Co-authored-by: Kan Adachi <kadachi1023@gmail.com>
  • Loading branch information
jordaaash and obber authored Nov 17, 2022
1 parent fef266d commit ac78da7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-parents-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@solana/wallet-adapter-fractal': patch
---

Add signMessage method to Fractal adapter
4 changes: 2 additions & 2 deletions packages/wallets/fractal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
"@solana/web3.js": "^1.58.0"
},
"dependencies": {
"@fractalwagmi/solana-wallet-adapter": "^0.0.8",
"@fractalwagmi/solana-wallet-adapter": "0.0.9",
"@solana/wallet-adapter-base": "workspace:^"
},
"devDependencies": {
"@solana/web3.js": "^1.58.0",
"shx": "^0.3.4"
}
}
}
21 changes: 19 additions & 2 deletions packages/wallets/fractal/src/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FractalWalletAdapterImpl as FractalWallet } from '@fractalwagmi/solana-wallet-adapter';
import type { WalletName } from '@solana/wallet-adapter-base';
import {
BaseSignerWalletAdapter,
BaseMessageSignerWalletAdapter,
WalletConfigError,
WalletConnectionError,
WalletDisconnectionError,
Expand All @@ -11,6 +11,7 @@ import {
WalletPublicKeyError,
WalletReadyState,
WalletSignTransactionError,
WalletSignMessageError,
} from '@solana/wallet-adapter-base';
import type { Transaction } from '@solana/web3.js';
import { PublicKey } from '@solana/web3.js';
Expand All @@ -19,7 +20,7 @@ export interface FractalWalletAdapterConfig {}

export const FractalWalletName = 'Fractal' as WalletName<'Fractal'>;

export class FractalWalletAdapter extends BaseSignerWalletAdapter {
export class FractalWalletAdapter extends BaseMessageSignerWalletAdapter {
name = FractalWalletName;
url = 'https://developers.fractal.is/wallet-adapters/solana';
icon =
Expand Down Expand Up @@ -150,4 +151,20 @@ export class FractalWalletAdapter extends BaseSignerWalletAdapter {
throw error;
}
}

async signMessage(message: Uint8Array): Promise<Uint8Array> {
try {
const wallet = this._wallet;
if (!wallet) throw new WalletNotConnectedError();

try {
return wallet.signMessage(message);
} catch (error: any) {
throw new WalletSignMessageError(error?.message, error);
}
} catch (error: any) {
this.emit('error', error);
throw error;
}
}
}
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ac78da7

Please sign in to comment.