From cf46f26fd84bc695ee56e16534f31b59eb12e4fe Mon Sep 17 00:00:00 2001 From: Raymond Jacobson Date: Mon, 17 Jul 2023 18:43:01 -0700 Subject: [PATCH] [C-2858] Fix phantom signing (#3761) --- .../web/src/store/token-dashboard/signMessage.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/audius-client/packages/web/src/store/token-dashboard/signMessage.ts b/apps/audius-client/packages/web/src/store/token-dashboard/signMessage.ts index 04f29b48132..4c393b942a9 100644 --- a/apps/audius-client/packages/web/src/store/token-dashboard/signMessage.ts +++ b/apps/audius-client/packages/web/src/store/token-dashboard/signMessage.ts @@ -2,7 +2,8 @@ import { accountSelectors, Chain, tokenDashboardPageActions, - tokenDashboardPageSelectors + tokenDashboardPageSelectors, + PhantomProvider } from '@audius/common' import { call, put, select } from 'typed-redux-saga' @@ -11,6 +12,10 @@ const { getUserId } = accountSelectors const { getConfirmingWallet } = tokenDashboardPageSelectors const { updateWalletError } = tokenDashboardPageActions +const solSign = async (provider: PhantomProvider, msg: Uint8Array) => { + return provider.signMessage(msg, 'utf8') +} + export function* signMessage(connection: WalletConnection) { const accountUserId = yield* select(getUserId) const message = `AudiusUserID:${accountUserId}` @@ -24,9 +29,9 @@ export function* signMessage(connection: WalletConnection) { case Chain.Sol: { const encodedMessage = new TextEncoder().encode(message) const signedResponse = yield* call( - connection.provider.signMessage, - encodedMessage, - 'utf8' + solSign, + connection.provider, + encodedMessage ) const publicKey = signedResponse.publicKey.toString() const signature = signedResponse.signature.toString('hex')