diff --git a/Data/js/main.js b/Data/js/main.js index cd34c6b..f637caf 100644 --- a/Data/js/main.js +++ b/Data/js/main.js @@ -11,9 +11,8 @@ function promiseCb(funId, promiseFun, dataParser) { }); } /** - * oauth login for before init internal wallet - * @param {*} funId - * @param {*} channel 0: google, 1: apple, 2: tiktok, 3: facebook, 4: twitter 5: tg, 6: email + * oauth login before init internal wallet + * @param {*} channel 0: google, 1: apple, 2: tiktok, 3: facebook, 4: twitter 5: tg */ function walletLogin(funId, channel) { channel = parseInt(channel); @@ -24,9 +23,8 @@ function walletLogin(funId, channel) { } /** * init internal wallet with password - * @param {*} funId - * @param {*} chain - * @param {*} pass + * @param {number | string} chain chain id + * @param {string} pass */ function initInternalWallet(funId, chain, pass) { chain = parseInt(chain); @@ -48,7 +46,8 @@ function initInternalWallet(funId, chain, pass) { } /** * verify if password is correct - * @param {*} pass + * compare with local password hash + * @param {string} pass password for wallet */ function verifyPassword(funId, pass) { try { @@ -60,8 +59,7 @@ function verifyPassword(funId, pass) { } /** * init third party wallet - * @param {*} funId - * @param {*} chain + * @param {number | string} chain chain id */ function initThirdPartyWallet(funId, chain) { chain = parseInt(chain); @@ -477,29 +475,54 @@ function tokenHistory(funId, start, limit, address, tokenId) { } // ======= end of transaction history ======= +/** + * get email info of current user + */ function emailInfo(funId) { promiseCb(funId, jc.wallet.emailVerifySvr.checkEmailVerified()); } - +/** + * send code with email + * @param {*} email + * @param {*} type + */ function sendEmailCode(funId, email, type) { - promiseCb(funId, jc.wallet.emailVerifySvr.sendEmailCode(email, type)); + const wallet = + !window.jc || !jc.wallet ? new jcwallet.default({ type: 0 }) : jc.wallet; + promiseCb(funId, wallet.emailVerifySvr.sendEmailCode(email, type)); } - +/** + * verify email with code, and update email + * @param {*} email + * @param {*} code + */ function verifyEmail(funId, email, code) { promiseCb(funId, jc.wallet.emailVerifySvr.updateEmailVerify(email, code)); } +/** + * check if email had already been registed + * @param {*} email + */ function checkEmailExists(funId, email) { - promiseCb(funId, jc.wallet.emailVerifySvr.isEmailRegister(email)); + const wallet = + !window.jc || !jc.wallet ? new jcwallet.default({ type: 0 }) : jc.wallet; + promiseCb(funId, wallet.emailVerifySvr.isEmailRegister(email)); } - +/** + * regist with email + * @param {*} email + * @param {*} password + * @param {*} code + */ function emailRegist(funId, email, password, code) { - promiseCb( - funId, - jc.wallet.emailVerifySvr.registByEmail(email, password, code) - ); + const wallet = + !window.jc || !jc.wallet ? new jcwallet.default({ type: 0 }) : jc.wallet; + promiseCb(funId, wallet.emailVerifySvr.registByEmail(email, password, code)); } function emailLogin(funId, email, password) { - promiseCb(funId, jc.wallet.emailLogin(email, password)); + const wallet = + !window.jc || !jc.wallet ? new jcwallet.default({ type: 0 }) : jc.wallet; + promiseCb(funId, wallet.emailLogin(email, password)); }