From a66d11e368b4799b11f603d47cf4bb5aba9698f1 Mon Sep 17 00:00:00 2001 From: cebgcontract <99630598+cebgcontract@users.noreply.github.com> Date: Wed, 6 Jul 2022 16:38:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AAnative?= =?UTF-8?q?=E7=9A=84=E5=9B=9E=E8=B0=83=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 8cdd820..4d5beb7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,6 @@ import { singleton } from "./decorator/singleton.decorator"; import Web3 from './lib/web3.min.js'; let sth = import('./lib/ethSigUtil.js'); import 'whatwg-fetch' -import { ZError } from "./common/ZError"; import { AllChains } from "./data/allchain"; import { createWalletEvents, WALLET_ACCOUNT_CHANGE, WALLET_CHAIN_CHANGE, WALLET_TOKEN_TYPE_CHANGE } from "./common/WalletEvent"; import { ERC20Standard } from "./standards/ERC20Standard"; @@ -24,7 +23,8 @@ declare global { jc: { wallet: JCWallet; }, - ethSigUtil: any; + ethSigUtil: any, + cc: any } } @@ -54,7 +54,7 @@ export default class JCWallet { constructor() { // 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.erc721Standard = new ERC721Standard(this.web3); 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() 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) { let accountData = this.wallet[this.accountIndex] if (!accountData) { - throw new ZError(10, 'no account found') + throw new Error('no account found') } address = accountData.address }