import { CancelMfaPayload, InitMfaEnrollmentWithTotpResponse, InitMfaEnrollmentWithSmsPayload, InitMfaEnrollmentWithTotpPayload, InitMfaPayload, SubmitMfaEnrollmentWithSmsPayload, SubmitMfaEnrollmentWithTotpPayload, SubmitMfaPayload, CheckMfaEnrollmentPayload, CheckMfaEnrollmentResponse, UnenrollWithSmsPayload, UnenrollWithTotpPayload, } from "@opensea/wallet-messages" import { getState } from "../intialize" import { MfaMethod } from "./base" export const initMfaChallenge = async (mfaMethod: MfaMethod) => { const { vessel } = await getState() return await vessel.send( { type: "action", action: "InitMfa", mfaMethod, }, { timeout: undefined, }, ) } export const submitMfaChallenge = async ( mfaMethod: MfaMethod, mfaCode: string, ) => { const { vessel } = await getState() return await vessel.send( { type: "action", action: "SubmitMfa", mfaCode, mfaMethod, }, { timeout: undefined, }, ) } export const cancelMfaChallenge = async () => { const { vessel } = await getState() return await vessel.send( { type: "action", action: "CancelMfa", }, { timeout: undefined, }, ) } export const initMfaEnrollmentWithSms = async (phoneNumber: string) => { const { vessel } = await getState() return await vessel.send( { type: "action", action: "InitMfaEnrollmentWithSms", phoneNumber, }, { timeout: undefined, }, ) } export const submitMfaEnrollmentWithSms = async ( phoneNumber: string, mfaCode: string, ) => { const { vessel } = await getState() return await vessel.send( { type: "action", action: "SubmitMfaEnrollmentWithSms", phoneNumber, mfaCode, }, { timeout: undefined, }, ) } export const unenrollWithSms = async () => { const { vessel } = await getState() return await vessel.send({ type: "action", action: "UnenrollWithSms", }) } export const initMfaEnrollmentWithTotp = async () => { const { vessel } = await getState() return await vessel.send< InitMfaEnrollmentWithTotpResponse, InitMfaEnrollmentWithTotpPayload >( { type: "action", action: "InitMfaEnrollmentWithTotp", }, { timeout: undefined, }, ) } export const submitMfaEnrollmentWithTotp = async (mfaCode: string) => { const { vessel } = await getState() return await vessel.send( { type: "action", action: "SubmitMfaEnrollmentWithTotp", mfaCode, }, { timeout: undefined, }, ) } export const unenrollWithTotp = async () => { const { vessel } = await getState() return await vessel.send({ type: "action", action: "UnenrollWithTotp", }) } export const checkMfaEnrollment = async () => { const { vessel } = await getState() return await vessel.send< CheckMfaEnrollmentResponse, CheckMfaEnrollmentPayload >({ type: "action", action: "CheckMfaEnrollment", }) }