增加内外钱包的切换功能
This commit is contained in:
parent
6b3b788ed5
commit
430e210bf6
14
src/index.ts
14
src/index.ts
@ -90,9 +90,6 @@ export default class JCWallet {
|
|||||||
this._currentChain = data;
|
this._currentChain = data;
|
||||||
this.rpcUrl = data.rpc;
|
this.rpcUrl = data.rpc;
|
||||||
console.log(`rpc url: ${this.rpcUrl}`);
|
console.log(`rpc url: ${this.rpcUrl}`);
|
||||||
if (this.walletType === WalletType.INTERNAL) {
|
|
||||||
this.prepareInternalWallet();
|
|
||||||
}
|
|
||||||
this.init({ chains: [chain], password: this.password });
|
this.init({ chains: [chain], password: this.password });
|
||||||
window.jc = { wallet: this };
|
window.jc = { wallet: this };
|
||||||
}
|
}
|
||||||
@ -101,16 +98,8 @@ export default class JCWallet {
|
|||||||
return this.walletType === WalletType.INTERNAL;
|
return this.walletType === WalletType.INTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private prepareInternalWallet() {
|
|
||||||
let token = loadToken();
|
|
||||||
if (!token) {
|
|
||||||
// check if token expired
|
|
||||||
} else {
|
|
||||||
// to goole login
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async initInternalWallet(channel: number) {
|
public async initInternalWallet(channel: number) {
|
||||||
|
this.walletType = WalletType.INTERNAL;
|
||||||
let address: string = await loadInternalWallet(channel);
|
let address: string = await loadInternalWallet(channel);
|
||||||
this.nativeAccount = address;
|
this.nativeAccount = address;
|
||||||
console.log("native wallet address: " + address);
|
console.log("native wallet address: " + address);
|
||||||
@ -150,6 +139,7 @@ export default class JCWallet {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
public async initThirdPartyWallet() {
|
public async initThirdPartyWallet() {
|
||||||
|
this.walletType = WalletType.THIRD_PATH;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
for (const d of AllChains) {
|
for (const d of AllChains) {
|
||||||
const id = d.id;
|
const id = d.id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user