fix some bug of init wallet
This commit is contained in:
parent
f63ccb25ec
commit
0f366b87c7
2
src/JCWallet.d.ts
vendored
2
src/JCWallet.d.ts
vendored
@ -39,7 +39,7 @@ declare namespace jsb {
|
||||
key_master: string,
|
||||
salt: string,
|
||||
pass: string
|
||||
): { address: string };
|
||||
): string;
|
||||
}
|
||||
|
||||
declare let window: Window;
|
||||
|
@ -18,6 +18,6 @@ export class WalletEnv {
|
||||
if (datas.length < 2) {
|
||||
return {};
|
||||
}
|
||||
return window.atob(datas[1]);
|
||||
return JSON.parse(window.atob(datas[1]));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
12
src/index.ts
12
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;
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user