Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signature for email modal #4474

Merged
merged 18 commits into from
Aug 7, 2023
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react'

// import { useApi } from '@/api/hooks/useApi'
import { useMyAccounts } from '@/accounts/hooks/useMyAccounts'
import { FailureModal } from '@/common/components/FailureModal'
import { ResultText } from '@/common/components/Modal'
import { WaitModal } from '@/common/components/WaitModal'
Expand All @@ -13,18 +13,26 @@ import { EmailSubscriptionMachine } from './machine'
import { EmailSubscriptionForm } from './types'

export const EmailSubscriptionModal = () => {
// const { api } = useApi()
const {
hideModal,
modalData: { member },
} = useModal<EmailSubscriptionModalCall>()

const { wallet } = useMyAccounts()
const [state, send] = useMachine(EmailSubscriptionMachine)

const signEmail = async () => {
const timestamp = Date.now()
const signature = await wallet?.signer.signPayload({
address: member.controllerAccount,
data: `${member.id}:${timestamp}`,
})
return signature
}

useEffect(() => {
if (state.matches('signature')) {
// const timestamp = new Date()
// api?.sign(member.controllerAccount, `${member.id}:${timestamp}`)
signEmail()
}
}, [state])

Expand Down