update js lib

This commit is contained in:
zhl 2023-05-26 15:03:18 +08:00
parent 8c6aa18bce
commit 6a6b3acc8e
2 changed files with 29 additions and 15 deletions

File diff suppressed because one or more lines are too long

View File

@ -32,11 +32,11 @@ function walletLogin(funId, channel) {
* @param {number | string} chain chain id
* @param {string} pass
*/
function initInternalWallet(funId, chain, pass) {
function initInternalWallet(funId, chain, pass, env) {
chain = parseInt(chain);
const wallet =
!window.jc || !jc.wallet ? new jcwallet.default({ type: 0 }) : jc.wallet;
promiseCb(funId, wallet.initInternalWallet(chain, pass), () => {
promiseCb(funId, wallet.initInternalWallet(chain, pass, env), () => {
return jc.wallet.nativeAccount;
});
}
@ -52,11 +52,11 @@ function verifyPassword(funId, pass) {
* init third party wallet
* @param {number | string} chain chain id
*/
function initThirdPartyWallet(funId, chain) {
function initThirdPartyWallet(funId, chain, env) {
chain = parseInt(chain);
const wallet =
!window.jc || !jc.wallet ? new jcwallet.default({ type: 1 }) : jc.wallet;
promiseCb(funId, wallet.initThirdPartyWallet(chain), () => {
promiseCb(funId, wallet.initThirdPartyWallet(chain, env), () => {
return jc.wallet.currentAccount();
});
}
@ -488,6 +488,11 @@ function emailRegist(funId, email, password, code) {
promiseCb(funId, wallet.emailVerifySvr.registByEmail(email, password, code));
}
/**
* login with email
* @param {*} email
* @param {*} password
*/
function emailLogin(funId, email, password) {
const wallet =
!window.jc || !jc.wallet ? new jcwallet.default({ type: 0 }) : jc.wallet;
@ -505,3 +510,12 @@ function tokenList(funId) {
return JSON.stringify({ errcode: 1, errmsg: err.message || err });
}
}
/**
* calc token price of USD
* token must already be in DEX
* @param {*} tokenName
* @param {*} amount
*/
function tokenPrice(funId, tokenName, amount) {
promiseCb(funId, jc.wallet.calcTokenPrice(tokenName, amount));
}