@kimafinance/kima-transaction-widget 1.2.42 → 1.2.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useEffect, useMemo, useRef, useCallback } from 'react';
2
2
  import * as toolkitRaw from '@reduxjs/toolkit';
3
- import { clusterApiUrl, TransactionInstruction, SystemProgram, SYSVAR_RENT_PUBKEY, PublicKey, Transaction } from '@solana/web3.js';
3
+ import { clusterApiUrl, PublicKey, TransactionInstruction, Transaction } from '@solana/web3.js';
4
4
  import { useSelector, useDispatch, Provider } from 'react-redux';
5
5
  import * as SolanaAdapter from '@solana/wallet-adapter-react';
6
6
  import { useWallet, useConnection } from '@solana/wallet-adapter-react';
@@ -18,7 +18,7 @@ import { WalletReadyState } from '@solana/wallet-adapter-base';
18
18
  import { getAddress, AddressPurpose, BitcoinNetworkType, signTransaction, sendBtcTransaction } from 'sats-connect';
19
19
  import { Contract } from '@ethersproject/contracts';
20
20
  import { formatUnits, parseUnits } from '@ethersproject/units';
21
- import { TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, AccountLayout } from '@solana/spl-token';
21
+ import { TOKEN_PROGRAM_ID, AccountLayout, ASSOCIATED_TOKEN_PROGRAM_ID } from '@solana/spl-token';
22
22
  import { TronWeb } from 'tronweb';
23
23
  import { ethers, utils as utils$3 } from 'ethers';
24
24
  import BufferLayout from 'buffer-layout';
@@ -2077,43 +2077,6 @@ var ERC20ABI = {
2077
2077
  abi: abi
2078
2078
  };
2079
2079
 
2080
- function createAssociatedTokenAccountInstruction(payer, associatedToken, owner, mint, programId = TOKEN_PROGRAM_ID, associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID) {
2081
- const keys = [{
2082
- pubkey: payer,
2083
- isSigner: true,
2084
- isWritable: true
2085
- }, {
2086
- pubkey: associatedToken,
2087
- isSigner: false,
2088
- isWritable: true
2089
- }, {
2090
- pubkey: owner,
2091
- isSigner: false,
2092
- isWritable: false
2093
- }, {
2094
- pubkey: mint,
2095
- isSigner: false,
2096
- isWritable: false
2097
- }, {
2098
- pubkey: SystemProgram.programId,
2099
- isSigner: false,
2100
- isWritable: false
2101
- }, {
2102
- pubkey: programId,
2103
- isSigner: false,
2104
- isWritable: false
2105
- }, {
2106
- pubkey: SYSVAR_RENT_PUBKEY,
2107
- isSigner: false,
2108
- isWritable: false
2109
- }];
2110
- return new TransactionInstruction({
2111
- keys,
2112
- programId: associatedTokenProgramId,
2113
- data: Buffer.alloc(0)
2114
- });
2115
- }
2116
-
2117
2080
  var AccountState;
2118
2081
  (function (AccountState) {
2119
2082
  AccountState[AccountState["Uninitialized"] = 0] = "Uninitialized";
@@ -2149,26 +2112,11 @@ async function getAssociatedTokenAddress(mint, owner, allowOwnerOffCurve = false
2149
2112
 
2150
2113
  async function getOrCreateAssociatedTokenAccount(connection, payer, mint, owner, signTransaction, allowOwnerOffCurve = false, commitment, programId = TOKEN_PROGRAM_ID, associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID) {
2151
2114
  const associatedToken = await getAssociatedTokenAddress(mint, owner, allowOwnerOffCurve, programId, associatedTokenProgramId);
2115
+ console.log(payer, signTransaction);
2152
2116
  let account;
2153
2117
  try {
2154
2118
  account = await getAccountInfo(connection, associatedToken, commitment, programId);
2155
- } catch (error) {
2156
- const err = error;
2157
- if (err.message === 'TokenAccountNotFoundError' || err.message === 'TokenInvalidAccountOwnerError') {
2158
- try {
2159
- const transaction = new Transaction().add(createAssociatedTokenAccountInstruction(payer, associatedToken, owner, mint, programId, associatedTokenProgramId));
2160
- const blockHash = await connection.getRecentBlockhash();
2161
- transaction.feePayer = await payer;
2162
- transaction.recentBlockhash = await blockHash.blockhash;
2163
- const signed = await signTransaction(transaction);
2164
- const signature = await connection.sendRawTransaction(signed.serialize());
2165
- await connection.confirmTransaction(signature);
2166
- } catch (error) {}
2167
- account = await getAccountInfo(connection, associatedToken, commitment, programId);
2168
- } else {
2169
- throw error;
2170
- }
2171
- }
2119
+ } catch (error) {}
2172
2120
  if (!account.mint.equals(mint)) throw Error('TokenInvalidMintError');
2173
2121
  if (!account.owner.equals(owner)) throw new Error('TokenInvalidOwnerError');
2174
2122
  return account;
@@ -12041,10 +11989,9 @@ const KimaProvider = ({
12041
11989
  } else toast$1.error(e.message);
12042
11990
  }
12043
11991
  const onChainChanged = chainData => {
12044
- console.log(chainData);
12045
- toast$1.error('Please switch to Tron Nile Testnet!');
12046
- if (chainData.chainId !== '0xcd8690dc') {
12047
- adapters[0].switchChain('0xcd8690dc');
11992
+ toast$1.error('Please switch to Tron Mainnet!');
11993
+ if (chainData.chainId !== '0x2b6653dc') {
11994
+ adapters[0].switchChain('0x2b6653dc');
12048
11995
  }
12049
11996
  };
12050
11997
  createWeb3Modal({