Skip to content

Commit

Permalink
fix naming issue
Browse files Browse the repository at this point in the history
  • Loading branch information
shan57blocks committed Nov 13, 2024
1 parent 7c18123 commit ed61933
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { CHAIN_TYPE } from '@huma-finance/shared'
import axios, { HttpStatusCode } from 'axios'
import { useCallback, useState } from 'react'
import { useAuthErrorHandingEvm } from './useAuthErrorHandingEvm'
import { useAuthErrorHandingSolana } from './useAuthErrorHandingSolana'
import { useAuthErrorHandlingEvm } from './useAuthErrorHandlingEvm'
import { useAuthErrorHandlingSolana } from './useAuthErrorHandlingSolana'

export type ErrorType = 'NotSignedIn' | 'UserRejected' | 'Other'

Expand Down Expand Up @@ -50,7 +50,7 @@ export const useAuthErrorHandling = (
}
}, [])

useAuthErrorHandingEvm(
useAuthErrorHandlingEvm(
chainType,
isDev,
error,
Expand All @@ -60,7 +60,7 @@ export const useAuthErrorHandling = (
setIsVerificationRequired,
handleVerificationCompletion,
)
useAuthErrorHandingSolana(
useAuthErrorHandlingSolana(
chainType,
isDev,
error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const verifyOwnershipEvm = async (
onVerificationComplete()
}

export const useAuthErrorHandingEvm = (
export const useAuthErrorHandlingEvm = (
chainType: CHAIN_TYPE,
isDev: boolean,
error: any,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,22 @@ const createSiwsMessage = (
return message.prepareMessage()
}

const buildAuthTx = async (message: string): Promise<Transaction> => {
const buildAuthTx = async (
account: PublicKey,
message: string,
): Promise<Transaction> => {
const tx = new Transaction()

tx.add(
new TransactionInstruction({
programId: MEMO_PROGRAM_ID,
keys: [],
keys: [
{
pubkey: account,
isSigner: true,
isWritable: true,
},
],
data: Buffer.from(message, 'utf8'),
}),
)
Expand All @@ -68,6 +77,7 @@ const verifyOwnershipSolana = async (
try {
const { nonce, expiresAt } = await AuthService.createSession(chainId, isDev)
const message = createSiwsMessage(address, chainId, nonce, expiresAt)
const account = new PublicKey(address)

if (signMessage) {
const encodedMessage = new TextEncoder().encode(message)
Expand All @@ -80,8 +90,8 @@ const verifyOwnershipSolana = async (
isDev,
)
} else {
const tx = await buildAuthTx(message)
tx.feePayer = new PublicKey(address)
const tx = await buildAuthTx(account, message)
tx.feePayer = account
tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash
const signedTx = await signTransaction(tx)
const serializedTx = signedTx.serialize().toString('base64')
Expand All @@ -94,7 +104,7 @@ const verifyOwnershipSolana = async (
}
}

export const useAuthErrorHandingSolana = (
export const useAuthErrorHandlingSolana = (
chainType: CHAIN_TYPE,
isDev: boolean,
error: any,
Expand Down

0 comments on commit ed61933

Please sign in to comment.