Skip to content

Commit

Permalink
[C-2858] Fix phantom signing (#3761)
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondjacobson committed Jul 18, 2023
1 parent 9238864 commit cf46f26
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
accountSelectors,
Chain,
tokenDashboardPageActions,
tokenDashboardPageSelectors
tokenDashboardPageSelectors,
PhantomProvider
} from '@audius/common'
import { call, put, select } from 'typed-redux-saga'

Expand All @@ -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}`
Expand All @@ -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')
Expand Down

0 comments on commit cf46f26

Please sign in to comment.