增加账号email认证相关接口,增加开始购买的接口

This commit is contained in:
zhl 2023-03-23 15:41:49 +08:00
parent 1824e4230e
commit 1a1ca431e3
4 changed files with 57 additions and 0 deletions

View File

@ -28,7 +28,9 @@ import {
loadInternalWallet, loadInternalWallet,
restoreWalletByMnemonic, restoreWalletByMnemonic,
} from "./manage/WalletManage"; } from "./manage/WalletManage";
import { EmailVerifySvr } from "./services/EmailVerifySvr";
import { NativeSvr } from "./services/NativeSvr"; import { NativeSvr } from "./services/NativeSvr";
import { PaySvr } from "./services/PaySvr";
import { TranHistorySvr } from "./services/TranHistorySvr"; import { TranHistorySvr } from "./services/TranHistorySvr";
import { ChainCommon } from "./standards/ChainCommon"; import { ChainCommon } from "./standards/ChainCommon";
import { ERC1155Standard } from "./standards/ERC1155Standard"; import { ERC1155Standard } from "./standards/ERC1155Standard";
@ -70,6 +72,8 @@ export default class JCWallet {
public jcStandard: JCStandard; public jcStandard: JCStandard;
public nativeSvr: NativeSvr; public nativeSvr: NativeSvr;
public historySvr: TranHistorySvr; public historySvr: TranHistorySvr;
public emailVerifySvr: EmailVerifySvr;
public paySvr: PaySvr;
public wConnect: ZWalletConnect; public wConnect: ZWalletConnect;
public mainHandlers = createWalletEvents(); public mainHandlers = createWalletEvents();
public data: IAccount[] = []; public data: IAccount[] = [];
@ -84,6 +88,8 @@ export default class JCWallet {
constructor({ type, chain }: { type: number; chain: number }) { constructor({ type, chain }: { type: number; chain: number }) {
this.nativeSvr = new NativeSvr(); this.nativeSvr = new NativeSvr();
this.historySvr = new TranHistorySvr(); this.historySvr = new TranHistorySvr();
this.emailVerifySvr = new EmailVerifySvr();
this.paySvr = new PaySvr();
this.walletType = type; this.walletType = type;
chain = chain || 80001; chain = chain || 80001;
let data = AllChains.find((o) => o.id === chain); let data = AllChains.find((o) => o.id === chain);

View File

@ -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 });
}
}

15
src/services/PaySvr.ts Normal file
View File

@ -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);
}
}

View File

@ -7,3 +7,9 @@ export interface IChainData {
explorerurl: string; explorerurl: string;
decimals?: number; decimals?: number;
} }
export interface IPayData {
address: string;
chain: string;
currency: string;
}