完善tiktok登陆
This commit is contained in:
parent
8cfc528f08
commit
06a91b3e36
@ -13,7 +13,7 @@ export function appleAuth(idToken: string) {
|
|||||||
|
|
||||||
export function tikTokAuth(idToken: string) {
|
export function tikTokAuth(idToken: string) {
|
||||||
const url = `${WALLET_API_HOST}/wallet/login/tiktok`;
|
const url = `${WALLET_API_HOST}/wallet/login/tiktok`;
|
||||||
return POST_JSON(url, { token: idToken });
|
return POST_JSON(url, { code: idToken });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getWalletInfo() {
|
export function getWalletInfo() {
|
||||||
|
26
src/index.ts
26
src/index.ts
@ -210,7 +210,7 @@ export default class JCWallet {
|
|||||||
this.createAccount();
|
this.createAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public restoreFromMnemonic(mnemonic: string, password: string) {
|
private restoreFromMnemonic(mnemonic: string, password: string) {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.wallet.clear();
|
this.wallet.clear();
|
||||||
restoreWalletByMnemonic(mnemonic, this.password);
|
restoreWalletByMnemonic(mnemonic, this.password);
|
||||||
@ -231,7 +231,7 @@ export default class JCWallet {
|
|||||||
this.updateListType("tokens");
|
this.updateListType("tokens");
|
||||||
resolve && resolve(this.currentChain);
|
resolve && resolve(this.currentChain);
|
||||||
} else {
|
} else {
|
||||||
console.log("third parth wallet change chain: " + chainId);
|
console.log("third party wallet change chain: " + chainId);
|
||||||
const chainData = this.chainMap.get(chainId);
|
const chainData = this.chainMap.get(chainId);
|
||||||
this.wConnect
|
this.wConnect
|
||||||
.addOrChangeChain(chainData)
|
.addOrChangeChain(chainData)
|
||||||
@ -281,7 +281,7 @@ export default class JCWallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get currentAccountData() {
|
get currentAccountData() {
|
||||||
let address = this.currentAccount().address;
|
let address = this.currentAccAddr;
|
||||||
const chain = this.currentChain.id;
|
const chain = this.currentChain.id;
|
||||||
let data = this.data.find((o) => o.address === address);
|
let data = this.data.find((o) => o.address === address);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
@ -394,7 +394,7 @@ export default class JCWallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async sendEth(to: string, amount: number | string) {
|
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");
|
const amountToSend = this.web3.utils.toWei(amount + "", "ether");
|
||||||
let gas = await this.web3.eth.estimateGas({
|
let gas = await this.web3.eth.estimateGas({
|
||||||
from,
|
from,
|
||||||
@ -404,9 +404,9 @@ export default class JCWallet {
|
|||||||
this.web3.eth.sendTransaction({ from, to, gas, value: amountToSend });
|
this.web3.eth.sendTransaction({ from, to, gas, value: amountToSend });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getBalance(address?: string) {
|
public async getBalance(account?: string) {
|
||||||
console.log("get balance with address: ", address);
|
console.log("get balance with address: ", account);
|
||||||
let balance = await this.chainCommon.getBalance(address);
|
let balance = await this.chainCommon.getBalance(account);
|
||||||
return balance;
|
return balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,14 +464,14 @@ export default class JCWallet {
|
|||||||
|
|
||||||
public async erc20Balance(address: string, account?: string) {
|
public async erc20Balance(address: string, account?: string) {
|
||||||
if (!account) {
|
if (!account) {
|
||||||
account = this.currentAccount().address;
|
account = this.currentAccAddr;
|
||||||
}
|
}
|
||||||
let result = await this.erc20Standard.getBalanceOf(address, account);
|
let result = await this.erc20Standard.getBalanceOf(address, account);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendErc20(address: string, to: string, amount: string) {
|
public async sendErc20(address: string, to: string, amount: string) {
|
||||||
let from = this.currentAccount().address;
|
let from = this.currentAccAddr;
|
||||||
let result = await this.erc20Standard.transfer({
|
let result = await this.erc20Standard.transfer({
|
||||||
address,
|
address,
|
||||||
from,
|
from,
|
||||||
@ -506,7 +506,7 @@ export default class JCWallet {
|
|||||||
account: string,
|
account: string,
|
||||||
refresh: boolean
|
refresh: boolean
|
||||||
) {
|
) {
|
||||||
account = account || this.currentAccount().address;
|
account = account || this.currentAccAddr;
|
||||||
const chain = this.wallet.currentChain.id;
|
const chain = this.wallet.currentChain.id;
|
||||||
const { categor, type } = getTypeByAddress(chain, address);
|
const { categor, type } = getTypeByAddress(chain, address);
|
||||||
let nfts = [];
|
let nfts = [];
|
||||||
@ -522,7 +522,7 @@ export default class JCWallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async nftList(address: string, account?: string) {
|
public async nftList(address: string, account?: string) {
|
||||||
account = account || this.currentAccount().address;
|
account = account || this.currentAccAddr;
|
||||||
const chain = this.wallet.currentChain.id;
|
const chain = this.wallet.currentChain.id;
|
||||||
const amount = await this.erc721Standard.getBalance(address, account);
|
const amount = await this.erc721Standard.getBalance(address, account);
|
||||||
const { categor, type } = getTypeByAddress(chain, address);
|
const { categor, type } = getTypeByAddress(chain, address);
|
||||||
@ -545,7 +545,7 @@ export default class JCWallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async sendNFT(address: string, to: string, tokenId: string) {
|
public async sendNFT(address: string, to: string, tokenId: string) {
|
||||||
let from = this.currentAccount().address;
|
let from = this.currentAccAddr;
|
||||||
let result = await this.erc721Standard.transfer({
|
let result = await this.erc721Standard.transfer({
|
||||||
address,
|
address,
|
||||||
from,
|
from,
|
||||||
@ -559,7 +559,7 @@ export default class JCWallet {
|
|||||||
|
|
||||||
public async erc1155List(address: string, account?: string) {
|
public async erc1155List(address: string, account?: string) {
|
||||||
if (!account) {
|
if (!account) {
|
||||||
account = this.currentAccount().address;
|
account = this.currentAccAddr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO::
|
//TODO::
|
||||||
|
@ -14,7 +14,7 @@ export class NativeSvr {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._subscribeToResponse(id, (result) => {
|
this._subscribeToResponse(id, (result) => {
|
||||||
if (result.errcode) {
|
if (result.errcode) {
|
||||||
reject(result.errcode);
|
reject(result.errmessage || result.errcode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resolve(result.data);
|
resolve(result.data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user