From 06a91b3e366a40cd0c4f9241cee3cb7a131361fe Mon Sep 17 00:00:00 2001 From: cebgcontract <99630598+cebgcontract@users.noreply.github.com> Date: Thu, 15 Dec 2022 12:05:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84tiktok=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/WalletApi.ts | 2 +- src/index.ts | 26 +++++++++++++------------- src/services/NativeSvr.ts | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/api/WalletApi.ts b/src/api/WalletApi.ts index e877d0d..c784d1e 100644 --- a/src/api/WalletApi.ts +++ b/src/api/WalletApi.ts @@ -13,7 +13,7 @@ export function appleAuth(idToken: string) { export function tikTokAuth(idToken: string) { const url = `${WALLET_API_HOST}/wallet/login/tiktok`; - return POST_JSON(url, { token: idToken }); + return POST_JSON(url, { code: idToken }); } export function getWalletInfo() { diff --git a/src/index.ts b/src/index.ts index 21359a2..685c303 100644 --- a/src/index.ts +++ b/src/index.ts @@ -210,7 +210,7 @@ export default class JCWallet { this.createAccount(); } - public restoreFromMnemonic(mnemonic: string, password: string) { + private restoreFromMnemonic(mnemonic: string, password: string) { this.password = password; this.wallet.clear(); restoreWalletByMnemonic(mnemonic, this.password); @@ -231,7 +231,7 @@ export default class JCWallet { this.updateListType("tokens"); resolve && resolve(this.currentChain); } else { - console.log("third parth wallet change chain: " + chainId); + console.log("third party wallet change chain: " + chainId); const chainData = this.chainMap.get(chainId); this.wConnect .addOrChangeChain(chainData) @@ -281,7 +281,7 @@ export default class JCWallet { } get currentAccountData() { - let address = this.currentAccount().address; + let address = this.currentAccAddr; const chain = this.currentChain.id; let data = this.data.find((o) => o.address === address); if (!data) { @@ -394,7 +394,7 @@ export default class JCWallet { } public async sendEth(to: string, amount: number | string) { - let from = this.currentAccount().address; + let from = this.currentAccAddr; const amountToSend = this.web3.utils.toWei(amount + "", "ether"); let gas = await this.web3.eth.estimateGas({ from, @@ -404,9 +404,9 @@ export default class JCWallet { this.web3.eth.sendTransaction({ from, to, gas, value: amountToSend }); } - public async getBalance(address?: string) { - console.log("get balance with address: ", address); - let balance = await this.chainCommon.getBalance(address); + public async getBalance(account?: string) { + console.log("get balance with address: ", account); + let balance = await this.chainCommon.getBalance(account); return balance; } @@ -464,14 +464,14 @@ export default class JCWallet { public async erc20Balance(address: string, account?: string) { if (!account) { - account = this.currentAccount().address; + account = this.currentAccAddr; } let result = await this.erc20Standard.getBalanceOf(address, account); return result; } public async sendErc20(address: string, to: string, amount: string) { - let from = this.currentAccount().address; + let from = this.currentAccAddr; let result = await this.erc20Standard.transfer({ address, from, @@ -506,7 +506,7 @@ export default class JCWallet { account: string, refresh: boolean ) { - account = account || this.currentAccount().address; + account = account || this.currentAccAddr; const chain = this.wallet.currentChain.id; const { categor, type } = getTypeByAddress(chain, address); let nfts = []; @@ -522,7 +522,7 @@ export default class JCWallet { } public async nftList(address: string, account?: string) { - account = account || this.currentAccount().address; + account = account || this.currentAccAddr; const chain = this.wallet.currentChain.id; const amount = await this.erc721Standard.getBalance(address, account); const { categor, type } = getTypeByAddress(chain, address); @@ -545,7 +545,7 @@ export default class JCWallet { } public async sendNFT(address: string, to: string, tokenId: string) { - let from = this.currentAccount().address; + let from = this.currentAccAddr; let result = await this.erc721Standard.transfer({ address, from, @@ -559,7 +559,7 @@ export default class JCWallet { public async erc1155List(address: string, account?: string) { if (!account) { - account = this.currentAccount().address; + account = this.currentAccAddr; } } //TODO:: diff --git a/src/services/NativeSvr.ts b/src/services/NativeSvr.ts index f0e5d20..e87a7c7 100644 --- a/src/services/NativeSvr.ts +++ b/src/services/NativeSvr.ts @@ -14,7 +14,7 @@ export class NativeSvr { return new Promise((resolve, reject) => { this._subscribeToResponse(id, (result) => { if (result.errcode) { - reject(result.errcode); + reject(result.errmessage || result.errcode); return; } resolve(result.data);