diff --git a/src/JCWallet.d.ts b/src/JCWallet.d.ts index 0f87adb..3fc4d7c 100644 --- a/src/JCWallet.d.ts +++ b/src/JCWallet.d.ts @@ -39,7 +39,7 @@ declare namespace jsb { key_master: string, salt: string, pass: string - ): { address: string }; + ): string; } declare let window: Window; diff --git a/src/config/WalletEnv.ts b/src/config/WalletEnv.ts index b6783a2..272a827 100644 --- a/src/config/WalletEnv.ts +++ b/src/config/WalletEnv.ts @@ -18,6 +18,6 @@ export class WalletEnv { if (datas.length < 2) { return {}; } - return window.atob(datas[1]); + return JSON.parse(window.atob(datas[1])); } } diff --git a/src/config/constants.ts b/src/config/constants.ts index ee23421..673ab51 100644 --- a/src/config/constants.ts +++ b/src/config/constants.ts @@ -1,7 +1,7 @@ export const WALLET_STORAGE_KEY_NAME = "jc_wallet_data"; // export const WALLET_API_HOST = "https://wallet.cebggame.com"; -export const WALLET_API_HOST = "http://192.168.100.184:3007"; +export const WALLET_API_HOST = "http://192.168.100.183:3007"; export const MAX_TRY_COUNT = 6; diff --git a/src/index.ts b/src/index.ts index 51f568d..47fc1cb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -217,18 +217,6 @@ export default class JCWallet { // } } - public newWallet(password: string) { - this.password = password; - this.createAccount(); - } - - private restoreFromMnemonic(mnemonic: string, password: string) { - this.password = password; - this.wallet.clear(); - restoreWalletByMnemonic(mnemonic, this.password); - return this.createAccount(); - } - get currentChain() { return this._currentChain; } diff --git a/src/manage/WalletManage.ts b/src/manage/WalletManage.ts index 783eec5..fd4a6a5 100644 --- a/src/manage/WalletManage.ts +++ b/src/manage/WalletManage.ts @@ -99,21 +99,21 @@ export async function loginByEmail(email: string, password: string) { export async function loadInternalWallet(pass: string) { let walletEnv = new WalletEnv(); + console.log(JSON.stringify(walletEnv)); if (!walletEnv.key) { await syncWalletEnv(); } - if (!walletEnv.address) { - walletEnv.address; - } let { id, openid } = walletEnv.tokenData; - let { address } = jsb.prepareWallet( + console.log("data from token: " + JSON.stringify(walletEnv.tokenData)); + let address = jsb.prepareWallet( id, openid, walletEnv.key, walletEnv.salt, pass ); + console.log("prepare wallet result: " + address); if (walletEnv.address && walletEnv.address !== address) { throw new ZError(10, "address not match, perhaps wrong password"); }