增加一个native的回调方法
This commit is contained in:
parent
a8fbfca0ce
commit
a66d11e368
12
src/index.ts
12
src/index.ts
@ -3,7 +3,6 @@ import { singleton } from "./decorator/singleton.decorator";
|
|||||||
import Web3 from './lib/web3.min.js';
|
import Web3 from './lib/web3.min.js';
|
||||||
let sth = import('./lib/ethSigUtil.js');
|
let sth = import('./lib/ethSigUtil.js');
|
||||||
import 'whatwg-fetch'
|
import 'whatwg-fetch'
|
||||||
import { ZError } from "./common/ZError";
|
|
||||||
import { AllChains } from "./data/allchain";
|
import { AllChains } from "./data/allchain";
|
||||||
import { createWalletEvents, WALLET_ACCOUNT_CHANGE, WALLET_CHAIN_CHANGE, WALLET_TOKEN_TYPE_CHANGE } from "./common/WalletEvent";
|
import { createWalletEvents, WALLET_ACCOUNT_CHANGE, WALLET_CHAIN_CHANGE, WALLET_TOKEN_TYPE_CHANGE } from "./common/WalletEvent";
|
||||||
import { ERC20Standard } from "./standards/ERC20Standard";
|
import { ERC20Standard } from "./standards/ERC20Standard";
|
||||||
@ -24,7 +23,8 @@ declare global {
|
|||||||
jc: {
|
jc: {
|
||||||
wallet: JCWallet;
|
wallet: JCWallet;
|
||||||
},
|
},
|
||||||
ethSigUtil: any;
|
ethSigUtil: any,
|
||||||
|
cc: any
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ export default class JCWallet {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
// this.web3 = new Web3('https://rpc-mainnet.kcc.network')
|
// this.web3 = new Web3('https://rpc-mainnet.kcc.network')
|
||||||
this.web3 = new Web3('https://rpc-testnet.kcc.network')
|
this.web3 = new Web3('https://rpc-testnet.kcc.network', {timeout: 30000})
|
||||||
this.erc20Standard = new ERC20Standard(this.web3);
|
this.erc20Standard = new ERC20Standard(this.web3);
|
||||||
this.erc721Standard = new ERC721Standard(this.web3);
|
this.erc721Standard = new ERC721Standard(this.web3);
|
||||||
this.wallet = this.web3.eth.accounts.wallet.load(this.password, WALLET_STORAGE_KEY_NAME)
|
this.wallet = this.web3.eth.accounts.wallet.load(this.password, WALLET_STORAGE_KEY_NAME)
|
||||||
@ -65,6 +65,10 @@ export default class JCWallet {
|
|||||||
}
|
}
|
||||||
this.data = this.dataManage.loadData()
|
this.data = this.dataManage.loadData()
|
||||||
window.jc = { wallet: this };
|
window.jc = { wallet: this };
|
||||||
|
window.cc = window.cc || {};
|
||||||
|
window.cc.walletCallback = (dataStr: string) => {
|
||||||
|
console.log('[Native CB]::' + dataStr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -198,7 +202,7 @@ export default class JCWallet {
|
|||||||
if (!address) {
|
if (!address) {
|
||||||
let accountData = this.wallet[this.accountIndex]
|
let accountData = this.wallet[this.accountIndex]
|
||||||
if (!accountData) {
|
if (!accountData) {
|
||||||
throw new ZError(10, 'no account found')
|
throw new Error('no account found')
|
||||||
}
|
}
|
||||||
address = accountData.address
|
address = accountData.address
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user