Skip to content

Commit

Permalink
Refactor writeContract function to use write function
Browse files Browse the repository at this point in the history
  • Loading branch information
sasicodes committed Jan 23, 2024
1 parent 984b483 commit c23aa1e
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions apps/web/src/components/Create/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ const CreateSteps = () => {
}
})

const write = ({ args }: { args: any[] }) => {
return writeContract({
address: LENSHUB_PROXY_ADDRESS,
abi: LENSHUB_PROXY_ABI,
functionName: 'post',
args
})
}

const getSignatureFromTypedData = async (
data: CreateMomokaPostEip712TypedData | CreateOnchainPostEip712TypedData
) => {
Expand Down Expand Up @@ -246,21 +255,11 @@ const CreateSteps = () => {
variables: { request: { id, signature } }
})
if (data?.broadcastOnchain?.__typename === 'RelayError') {
return writeContract({
address: LENSHUB_PROXY_ADDRESS,
abi: LENSHUB_PROXY_ABI,
functionName: 'post',
args: [typedData.value]
})
return write({ args: [typedData.value] })
}
return
}
return writeContract({
address: LENSHUB_PROXY_ADDRESS,
abi: LENSHUB_PROXY_ABI,
functionName: 'post',
args: [typedData.value]
})
return write({ args: [typedData.value] })
} catch {
setUploadedMedia({
buttonText: 'Post Now',
Expand Down Expand Up @@ -291,21 +290,11 @@ const CreateSteps = () => {
variables: { request: { id, signature } }
})
if (data?.broadcastOnMomoka?.__typename === 'RelayError') {
return writeContract({
address: LENSHUB_PROXY_ADDRESS,
abi: LENSHUB_PROXY_ABI,
functionName: 'post',
args: [typedData.value]
})
return write({ args: [typedData.value] })
}
return
}
return writeContract({
address: LENSHUB_PROXY_ADDRESS,
abi: LENSHUB_PROXY_ABI,
functionName: 'post',
args: [typedData.value]
})
return write({ args: [typedData.value] })
} catch {
setUploadedMedia({
buttonText: 'Post Now',
Expand Down

0 comments on commit c23aa1e

Please sign in to comment.