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,7 @@
import { ApiPromise, WsProvider } from '@polkadot/api'
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 +14,31 @@ import { EmailSubscriptionMachine } from './machine'
import { EmailSubscriptionForm } from './types'

export const EmailSubscriptionModal = () => {
// const { api } = useApi()
const provider = new WsProvider(process.env.REACT_APP_TESTNET_NODE_SOCKET)
const api = new ApiPromise({ provider })
const {
hideModal,
modalData: { member },
} = useModal<EmailSubscriptionModalCall>()

const { wallet } = useMyAccounts()

const [state, send] = useMachine(EmailSubscriptionMachine)

const signEmail = async () => {
if (state.context.email) {
await api.setSigner(wallet?.signer)
await api.sign(member.controllerAccount, {
data: state.context.email,
})
}
}

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

Expand Down