fix some bug of init wallet

This commit is contained in:
zhl 2023-05-15 14:04:31 +08:00
parent f63ccb25ec
commit 0f366b87c7
5 changed files with 7 additions and 19 deletions

2
src/JCWallet.d.ts vendored
View File

@ -39,7 +39,7 @@ declare namespace jsb {
key_master: string,
salt: string,
pass: string
): { address: string };
): string;
}
declare let window: Window;

View File

@ -18,6 +18,6 @@ export class WalletEnv {
if (datas.length < 2) {
return {};
}
return window.atob(datas[1]);
return JSON.parse(window.atob(datas[1]));
}
}

View File

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

View File

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

View File

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