diff --git a/src/index.ts b/src/index.ts index 908df40..d8b1967 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,7 +28,9 @@ import { loadInternalWallet, restoreWalletByMnemonic, } from "./manage/WalletManage"; +import { EmailVerifySvr } from "./services/EmailVerifySvr"; import { NativeSvr } from "./services/NativeSvr"; +import { PaySvr } from "./services/PaySvr"; import { TranHistorySvr } from "./services/TranHistorySvr"; import { ChainCommon } from "./standards/ChainCommon"; import { ERC1155Standard } from "./standards/ERC1155Standard"; @@ -70,6 +72,8 @@ export default class JCWallet { public jcStandard: JCStandard; public nativeSvr: NativeSvr; public historySvr: TranHistorySvr; + public emailVerifySvr: EmailVerifySvr; + public paySvr: PaySvr; public wConnect: ZWalletConnect; public mainHandlers = createWalletEvents(); public data: IAccount[] = []; @@ -84,6 +88,8 @@ export default class JCWallet { constructor({ type, chain }: { type: number; chain: number }) { this.nativeSvr = new NativeSvr(); this.historySvr = new TranHistorySvr(); + this.emailVerifySvr = new EmailVerifySvr(); + this.paySvr = new PaySvr(); this.walletType = type; chain = chain || 80001; let data = AllChains.find((o) => o.id === chain); diff --git a/src/services/EmailVerifySvr.ts b/src/services/EmailVerifySvr.ts new file mode 100644 index 0000000..e6c28d9 --- /dev/null +++ b/src/services/EmailVerifySvr.ts @@ -0,0 +1,30 @@ +import { updateEmailVerify } from "../api/PayApi"; +import { isEmailVerified } from "../api/WalletApi"; +import { singleton } from "../decorator/singleton.decorator"; + +@singleton +export class EmailVerifySvr { + /** + * Checks if the user's email is verified + * @returns an object containing the verification status and the user's email + */ + public async checkEmailVerified() { + let res = await isEmailVerified(); + let verified = 0; + let email = ""; + if (!res.errcode) { + verified = res.data.verified; + email = res.data?.email; + } + return { verified, email }; + } + /** + * Begins the process of verifying the user's email + * @param email - the email to be verified + * @returns a Promise that resolves to the result of the updateEmailVerify API call + */ + + public async beginVerifyEmail(email: string) { + return updateEmailVerify({ email }); + } +} diff --git a/src/services/PaySvr.ts b/src/services/PaySvr.ts new file mode 100644 index 0000000..9ccb2ca --- /dev/null +++ b/src/services/PaySvr.ts @@ -0,0 +1,15 @@ +import { alchemyPrePay } from "../api/PayApi"; +import { singleton } from "../decorator/singleton.decorator"; +import { IPayData } from "../types/data.types"; + +@singleton +export class PaySvr { + /** + * Calls the alchemyPrePay function with the given data. + * @param data - The data to be passed to the alchemyPrePay function. + * @returns The result of the alchemyPrePay function. + */ + public async alchemyPrePay(data: IPayData) { + return alchemyPrePay(data); + } +} diff --git a/src/types/data.types.ts b/src/types/data.types.ts index b142a84..cbec1f8 100644 --- a/src/types/data.types.ts +++ b/src/types/data.types.ts @@ -7,3 +7,9 @@ export interface IChainData { explorerurl: string; decimals?: number; } + +export interface IPayData { + address: string; + chain: string; + currency: string; +}