Fix transaction balance and network (#18477)

* use correct network for balance and gas

* use correct network for transaction approval, sign, and add token

* add null check and clean up

* update formatting

* update formatting
This commit is contained in:
Pavneet Singh
2023-05-16 19:19:20 +05:30
committed by GitHub
parent 90315fcfae
commit feb4fcf0e2
8 changed files with 168 additions and 143 deletions
@@ -51,6 +51,7 @@ import org.chromium.chrome.browser.util.LiveDataUtil;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -178,15 +179,15 @@ public class AccountDetailActivity
return;
}
AccountInfo[] accounts = keyringInfo.accountInfos;
AccountInfo[] allAccountInfos = keyringInfo.accountInfos;
LiveDataUtil.observeOnce(
mWalletModel.getCryptoModel().getNetworkModel().mCryptoNetworks,
allNetworks -> {
Utils.getTxExtraInfo(new WeakReference<>(this), TokenUtils.TokenType.ALL,
allNetworks, selectedNetwork, accounts, null, false,
allNetworks, selectedNetwork, allAccountInfos, null, false,
(assetPrices, fullTokenList, nativeAssetsBalances,
blockchainTokensBalances) -> {
for (AccountInfo accountInfo : accounts) {
for (AccountInfo accountInfo : allAccountInfos) {
if (accountInfo.address.equals(mAddress)
&& accountInfo.name.equals(mName)) {
AccountInfo[] accountInfos = new AccountInfo[1];
@@ -196,11 +197,13 @@ public class AccountDetailActivity
Utils.getCoinIcon(mCoinType), mName,
mAddress, null, null, mIsImported);
Utils.setUpTransactionList(this, accountInfos,
thisAccountItemModel, assetPrices,
allNetworks, thisAccountItemModel, assetPrices,
fullTokenList, nativeAssetsBalances,
blockchainTokensBalances,
findViewById(R.id.rv_transactions), this,
mWalletTxCoinAdapter);
blockchainTokensBalances, selectedNetwork,
walletListItemModelList -> {
showTransactionList(
walletListItemModelList);
});
break;
}
}
@@ -209,6 +212,17 @@ public class AccountDetailActivity
});
}
private void showTransactionList(List<WalletListItemModel> walletListItemModelList) {
mWalletTxCoinAdapter.setWalletCoinAdapterType(
WalletCoinAdapter.AdapterType.VISIBLE_ASSETS_LIST);
mWalletTxCoinAdapter.setWalletListItemModelList(walletListItemModelList);
mWalletTxCoinAdapter.setOnWalletListItemClick(AccountDetailActivity.this);
mWalletTxCoinAdapter.setWalletListItemType(Utils.TRANSACTION_ITEM);
RecyclerView rvTransactions = findViewById(R.id.rv_transactions);
rvTransactions.setAdapter(mWalletTxCoinAdapter);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
@@ -36,8 +36,6 @@ import org.chromium.brave_wallet.mojom.AccountInfo;
import org.chromium.brave_wallet.mojom.AssetPriceTimeframe;
import org.chromium.brave_wallet.mojom.BlockchainToken;
import org.chromium.brave_wallet.mojom.CoinType;
import org.chromium.brave_wallet.mojom.JsonRpcService;
import org.chromium.brave_wallet.mojom.KeyringService;
import org.chromium.brave_wallet.mojom.NetworkInfo;
import org.chromium.brave_wallet.mojom.TransactionInfo;
import org.chromium.chrome.R;
@@ -62,6 +60,7 @@ import org.chromium.chrome.browser.util.TabUtils;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -85,7 +84,7 @@ public class AssetDetailActivity
private BlockchainToken mAsset;
private ExecutorService mExecutor;
private Handler mHandler;
private AccountInfo[] accountInfos;
private AccountInfo[] mAccountInfos;
private WalletCoinAdapter mWalletTxCoinAdapter;
private Button mBtnBuy;
private Button mBtnSwap;
@@ -320,29 +319,32 @@ public class AssetDetailActivity
mWalletModel.getKeyringModel().getKeyringPerId(
AssetUtils.getKeyringForCoinType(mCoinType), keyringInfo -> {
if (keyringInfo == null) return;
accountInfos = keyringInfo.accountInfos;
mAccountInfos = keyringInfo.accountInfos;
WalletListItemModel thisAssetItemModel = new WalletListItemModel(
R.drawable.ic_eth, mAsset.name, mAsset.symbol, mAsset.tokenId, "", "");
LiveDataUtil.observeOnce(
mWalletModel.getNetworkModel().mCryptoNetworks, allNetworks -> {
Utils.getTxExtraInfo(new WeakReference<>(this),
TokenUtils.TokenType.ALL, allNetworks, mAssetNetwork,
accountInfos, new BlockchainToken[] {mAsset}, false,
mAccountInfos, new BlockchainToken[] {mAsset}, false,
(assetPrices, fullTokenList, nativeAssetsBalances,
blockchainTokensBalances) -> {
thisAssetItemModel.setBlockchainToken(mAsset);
Utils.setUpTransactionList(this, accountInfos,
thisAssetItemModel, assetPrices, fullTokenList,
nativeAssetsBalances, blockchainTokensBalances,
findViewById(R.id.rv_transactions), this,
mWalletTxCoinAdapter);
Utils.setUpTransactionList(this, mAccountInfos,
allNetworks, thisAssetItemModel, assetPrices,
fullTokenList, nativeAssetsBalances,
blockchainTokensBalances, mAssetNetwork,
walletListItemModelList -> {
showTransactionList(
walletListItemModelList);
});
double assetPrice = Utils.getOrDefault(assetPrices,
mAsset.symbol.toLowerCase(Locale.ENGLISH),
0.0d);
List<WalletListItemModel> walletListItemModelList =
createAccountList(accountInfos, assetPrice,
createAccountList(mAccountInfos, assetPrice,
nativeAssetsBalances,
blockchainTokensBalances);
@@ -353,6 +355,17 @@ public class AssetDetailActivity
});
}
private void showTransactionList(List<WalletListItemModel> walletListItemModelList) {
mWalletTxCoinAdapter.setWalletCoinAdapterType(
WalletCoinAdapter.AdapterType.VISIBLE_ASSETS_LIST);
mWalletTxCoinAdapter.setWalletListItemModelList(walletListItemModelList);
mWalletTxCoinAdapter.setOnWalletListItemClick(AssetDetailActivity.this);
mWalletTxCoinAdapter.setWalletListItemType(Utils.TRANSACTION_ITEM);
RecyclerView rvTransactions = findViewById(R.id.rv_transactions);
rvTransactions.setAdapter(mWalletTxCoinAdapter);
}
private Double getAccountBalance(HashMap<String, Double> nativeAssetsBalances,
HashMap<String, HashMap<String, Double>> blockchainTokensBalances,
String accountAddressLower) {
@@ -407,7 +420,7 @@ public class AssetDetailActivity
@Override
public void onTransactionClick(TransactionInfo txInfo) {
Utils.openTransaction(txInfo, mJsonRpcService, this, accountInfos, mCoinType);
Utils.openTransaction(txInfo, mJsonRpcService, this, mAccountInfos, mCoinType);
}
@Override
@@ -59,6 +59,7 @@ import org.chromium.chrome.browser.crypto_wallet.listeners.TransactionConfirmati
import org.chromium.chrome.browser.crypto_wallet.observers.ApprovedTxObserver;
import org.chromium.chrome.browser.crypto_wallet.util.AndroidUtils;
import org.chromium.chrome.browser.crypto_wallet.util.AssetUtils;
import org.chromium.chrome.browser.crypto_wallet.util.JavaUtils;
import org.chromium.chrome.browser.crypto_wallet.util.ParsedTransaction;
import org.chromium.chrome.browser.crypto_wallet.util.SolanaTransactionsGasHelper;
import org.chromium.chrome.browser.crypto_wallet.util.TokenUtils;
@@ -270,71 +271,46 @@ public class ApproveTxBottomSheetDialogFragment extends BottomSheetDialogFragmen
associatedSplTokenInfo.setText(associatedSPLTokenAccountInfo);
}
mCoinType = TransactionUtils.getCoinFromTxDataUnion(mTxInfo.txDataUnion);
jsonRpcService.getNetwork(mCoinType, null, selectedNetwork -> {
networkName.setText(selectedNetwork.chainName);
keyringService.getKeyringInfo(
AssetUtils.getKeyringForCoinType(mCoinType), keyringInfo -> {
final AccountInfo[] accounts = keyringInfo.accountInfos;
// First fill in data that does not require remote queries
TokenUtils.getAllTokensFiltered(getBraveWalletService(),
getBlockchainRegistry(), selectedNetwork, selectedNetwork.coin,
TokenUtils.TokenType.ALL, tokenList -> {
SolanaTransactionsGasHelper solanaTransactionsGasHelper =
new SolanaTransactionsGasHelper(
(BraveWalletBaseActivity) getActivity(),
new TransactionInfo[] {mTxInfo});
solanaTransactionsGasHelper.maybeGetSolanaGasEstimations(() -> {
HashMap<String, Long> perTxFee =
solanaTransactionsGasHelper.getPerTxFee();
if (perTxFee.get(mTxInfo.id) != null) {
mSolanaEstimatedTxFee = perTxFee.get(mTxInfo.id);
}
if (!canUpdateUi()) return;
ParsedTransaction parsedTx = fillAssetDependentControls(
view, selectedNetwork, accounts,
new HashMap<String, Double>(), tokenList,
new HashMap<String, Double>(),
new HashMap<String, HashMap<String, Double>>(),
mSolanaEstimatedTxFee);
if (JavaUtils.anyNull(mWalletModel)) return;
var selectedNetwork = mWalletModel.getNetworkModel().getNetwork(mTxInfo.chainId);
networkName.setText(selectedNetwork.chainName);
keyringService.getKeyringInfo(AssetUtils.getKeyringForCoinType(mCoinType), keyringInfo -> {
final AccountInfo[] accounts = keyringInfo.accountInfos;
// First fill in data that does not require remote queries
TokenUtils.getAllTokensFiltered(getBraveWalletService(), getBlockchainRegistry(),
selectedNetwork, selectedNetwork.coin, TokenUtils.TokenType.ALL, tokenList -> {
SolanaTransactionsGasHelper solanaTransactionsGasHelper =
new SolanaTransactionsGasHelper(
(BraveWalletBaseActivity) getActivity(),
new TransactionInfo[] {mTxInfo});
solanaTransactionsGasHelper.maybeGetSolanaGasEstimations(() -> {
HashMap<String, Long> perTxFee =
solanaTransactionsGasHelper.getPerTxFee();
if (perTxFee.get(mTxInfo.id) != null) {
mSolanaEstimatedTxFee = perTxFee.get(mTxInfo.id);
}
if (!canUpdateUi()) return;
ParsedTransaction parsedTx = fillAssetDependentControls(view,
selectedNetwork, accounts, new HashMap<String, Double>(),
tokenList, new HashMap<String, Double>(),
new HashMap<String, HashMap<String, Double>>(),
mSolanaEstimatedTxFee);
// Get tokens involved in this transaction
List<BlockchainToken> tokens = new ArrayList<>();
tokens.add(Utils.makeNetworkAsset(
selectedNetwork)); // Always add native asset
if (parsedTx.getIsSwap()) {
tokens.add(parsedTx.getSellToken());
tokens.add(parsedTx.getBuyToken());
} else if (parsedTx.getToken() != null)
tokens.add(parsedTx.getToken());
BlockchainToken[] filterByTokens =
tokens.toArray(new BlockchainToken[0]);
// Get tokens involved in this transaction
List<BlockchainToken> tokens = new ArrayList<>();
tokens.add(Utils.makeNetworkAsset(
selectedNetwork)); // Always add native asset
if (parsedTx.getIsSwap()) {
tokens.add(parsedTx.getSellToken());
tokens.add(parsedTx.getBuyToken());
} else if (parsedTx.getToken() != null)
tokens.add(parsedTx.getToken());
BlockchainToken[] filterByTokens =
tokens.toArray(new BlockchainToken[0]);
if (mWalletModel == null) return;
LiveDataUtil.observeOnce(mWalletModel.getCryptoModel()
.getNetworkModel()
.mCryptoNetworks,
allNetworks -> {
Utils.getTxExtraInfo(
new WeakReference<>(
(BraveWalletBaseActivity)
getActivity()),
TokenUtils.TokenType.ALL, allNetworks,
selectedNetwork, accounts,
filterByTokens, false,
(assetPrices, fullTokenList,
nativeAssetsBalances,
blockchainTokensBalances) -> {
if (!canUpdateUi()) return;
fillAssetDependentControls(view,
selectedNetwork, accounts,
assetPrices, fullTokenList,
nativeAssetsBalances,
blockchainTokensBalances,
mSolanaEstimatedTxFee);
});
});
});
});
fetchTxBalanceAndUpdateUi(
view, selectedNetwork, accounts, filterByTokens);
});
});
});
ImageView icon = (ImageView) view.findViewById(R.id.account_picture);
@@ -391,6 +367,25 @@ public class ApproveTxBottomSheetDialogFragment extends BottomSheetDialogFragmen
}
}
private void fetchTxBalanceAndUpdateUi(View view, NetworkInfo selectedNetwork,
AccountInfo[] accounts, BlockchainToken[] filterByTokens) {
if (mWalletModel == null) return;
LiveDataUtil.observeOnce(
mWalletModel.getCryptoModel().getNetworkModel().mCryptoNetworks, allNetworks -> {
Utils.getTxExtraInfo(
new WeakReference<>((BraveWalletBaseActivity) getActivity()),
TokenUtils.TokenType.ALL, allNetworks, selectedNetwork, accounts,
filterByTokens, false,
(assetPrices, fullTokenList, nativeAssetsBalances,
blockchainTokensBalances) -> {
if (!canUpdateUi()) return;
fillAssetDependentControls(view, selectedNetwork, accounts,
assetPrices, fullTokenList, nativeAssetsBalances,
blockchainTokensBalances, mSolanaEstimatedTxFee);
});
});
}
private void refreshListContentUi() {
mRejectAllTx.setText(getString(
R.string.brave_wallet_queue_reject_all, String.valueOf(mTransactionInfos.size())));
@@ -18,13 +18,17 @@ import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import org.chromium.base.Log;
import org.chromium.brave_wallet.mojom.AddSuggestTokenRequest;
import org.chromium.brave_wallet.mojom.CoinType;
import org.chromium.brave_wallet.mojom.NetworkInfo;
import org.chromium.brave_wallet.mojom.OriginInfo;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.app.BraveActivity;
import org.chromium.chrome.browser.app.domain.WalletModel;
import org.chromium.chrome.browser.crypto_wallet.BlockchainRegistryFactory;
import org.chromium.chrome.browser.crypto_wallet.activities.BraveWalletBaseActivity;
import org.chromium.chrome.browser.crypto_wallet.util.JavaUtils;
import org.chromium.chrome.browser.crypto_wallet.util.Utils;
import org.chromium.url.GURL;
@@ -32,6 +36,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class AddTokenFragment extends BaseDAppsFragment {
private static final String TAG = "AddTokenFragment";
private AddSuggestTokenRequest mCurrentAddSuggestTokenRequest;
private Button mBtCancel;
private Button mBtAdd;
@@ -42,6 +47,7 @@ public class AddTokenFragment extends BaseDAppsFragment {
private ImageView mTokenImage;
private ExecutorService mExecutor;
private Handler mHandler;
private WalletModel mWalletModel;
@Override
public View onCreateView(
@@ -57,6 +63,12 @@ public class AddTokenFragment extends BaseDAppsFragment {
mTokenImage = view.findViewById(R.id.fragment_add_token_iv_token);
mTokenName = view.findViewById(R.id.fragment_add_token_tv_token);
mTokenAddress = view.findViewById(R.id.fragment_add_token_tv_address);
try {
BraveActivity activity = BraveActivity.getBraveActivity();
mWalletModel = activity.getWalletModel();
} catch (BraveActivity.BraveActivityNotFoundException e) {
Log.e(TAG, "onCreate ", e);
}
initComponents(true);
return view;
@@ -98,7 +110,7 @@ public class AddTokenFragment extends BaseDAppsFragment {
}
fillOriginInfo(mCurrentAddSuggestTokenRequest.origin);
initToken();
updateNetwork(mCurrentAddSuggestTokenRequest.token.coin);
updateNetwork(mCurrentAddSuggestTokenRequest.token.chainId);
});
}
@@ -109,9 +121,10 @@ public class AddTokenFragment extends BaseDAppsFragment {
}
}
private void updateNetwork(@CoinType.EnumType int coin) {
getJsonRpcService().getNetwork(coin, null,
selectedNetwork -> { mNetworkName.setText(selectedNetwork.chainName); });
private void updateNetwork(String chainId) {
if (JavaUtils.anyNull(mWalletModel, chainId)) return;
var selectedNetwork = mWalletModel.getNetworkModel().getNetwork(chainId);
mNetworkName.setText(selectedNetwork.chainName);
}
private void initToken() {
@@ -30,7 +30,9 @@ import org.chromium.brave_wallet.mojom.NetworkInfo;
import org.chromium.brave_wallet.mojom.SignMessageRequest;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.app.BraveActivity;
import org.chromium.chrome.browser.app.domain.WalletModel;
import org.chromium.chrome.browser.crypto_wallet.adapters.SignMessagePagerAdapter;
import org.chromium.chrome.browser.crypto_wallet.util.JavaUtils;
import org.chromium.chrome.browser.crypto_wallet.util.Utils;
import org.chromium.url.GURL;
@@ -54,6 +56,7 @@ public class SignMessageFragment extends BaseDAppsBottomSheetDialogFragment {
private TextView mWebSite;
private ExecutorService mExecutor;
private Handler mHandler;
private WalletModel mWalletModel;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -62,6 +65,12 @@ public class SignMessageFragment extends BaseDAppsBottomSheetDialogFragment {
mHandler = new Handler(Looper.getMainLooper());
mTabTitles = new ArrayList<>();
mTabTitles.add(getString(R.string.details));
try {
BraveActivity activity = BraveActivity.getBraveActivity();
mWalletModel = activity.getWalletModel();
} catch (BraveActivity.BraveActivityNotFoundException e) {
Log.e(TAG, "onCreate ", e);
}
}
@Override
@@ -121,7 +130,7 @@ public class SignMessageFragment extends BaseDAppsBottomSheetDialogFragment {
mCurrentSignMessageRequest.originInfo.eTldPlusOne));
}
updateAccount(mCurrentSignMessageRequest.address);
updateNetwork(mCurrentSignMessageRequest.coin);
updateNetwork(mCurrentSignMessageRequest.chainId);
});
}
@@ -140,8 +149,9 @@ public class SignMessageFragment extends BaseDAppsBottomSheetDialogFragment {
}
}
private void updateNetwork(@CoinType.EnumType int coin) {
getJsonRpcService().getNetwork(coin, null,
selectedNetwork -> { mNetworkName.setText(selectedNetwork.chainName); });
private void updateNetwork(String chainId) {
if (JavaUtils.anyNull(mWalletModel, chainId)) return;
var selectedNetwork = mWalletModel.getNetworkModel().getNetwork(chainId);
mNetworkName.setText(selectedNetwork.chainName);
}
}
@@ -1130,40 +1130,26 @@ public class Utils {
}
public static void setUpTransactionList(BraveWalletBaseActivity activity,
AccountInfo[] accounts, WalletListItemModel walletListItemModel,
HashMap<String, Double> assetPrices, BlockchainToken[] fullTokenList,
HashMap<String, Double> nativeAssetsBalances,
AccountInfo[] accounts, List<NetworkInfo> allNetworks,
WalletListItemModel walletListItemModel, HashMap<String, Double> assetPrices,
BlockchainToken[] fullTokenList, HashMap<String, Double> nativeAssetsBalances,
HashMap<String, HashMap<String, Double>> blockchainTokensBalances,
RecyclerView rvTransactions, OnWalletListItemClick callback,
WalletCoinAdapter walletTxCoinAdapter) {
JsonRpcService jsonRpcService = activity.getJsonRpcService();
NetworkInfo selectedNetwork, Callbacks.Callback1<List<WalletListItemModel>> callback) {
TxService txService = activity.getTxService();
assert jsonRpcService != null;
assert txService != null;
int coinType = CoinType.ETH;
if (walletListItemModel.isAccount()) {
AccountInfo account = findAccount(accounts, walletListItemModel.getSubTitle());
coinType = account != null ? account.coin : CoinType.ETH;
} else {
coinType = walletListItemModel.getBlockchainToken().coin;
}
jsonRpcService.getNetwork(coinType, null, selectedNetwork -> {
PendingTxHelper pendingTxHelper = new PendingTxHelper(txService, accounts, true);
PendingTxHelper pendingTxHelper = new PendingTxHelper(txService, accounts, true);
pendingTxHelper.fetchTransactions(() -> {
HashMap<String, TransactionInfo[]> pendingTxInfos =
pendingTxHelper.getTransactions();
pendingTxHelper.destroy();
SolanaTransactionsGasHelper solanaTransactionsGasHelper =
new SolanaTransactionsGasHelper(
activity, getTransactionArray(pendingTxInfos));
solanaTransactionsGasHelper.maybeGetSolanaGasEstimations(() -> {
workWithTransactions(activity, selectedNetwork, pendingTxInfos, accounts,
walletListItemModel, assetPrices, fullTokenList, nativeAssetsBalances,
blockchainTokensBalances, rvTransactions, callback, walletTxCoinAdapter,
solanaTransactionsGasHelper.getPerTxFee());
});
pendingTxHelper.fetchTransactions(() -> {
HashMap<String, TransactionInfo[]> pendingTxInfos = pendingTxHelper.getTransactions();
pendingTxHelper.destroy();
SolanaTransactionsGasHelper solanaTransactionsGasHelper =
new SolanaTransactionsGasHelper(activity, getTransactionArray(pendingTxInfos));
solanaTransactionsGasHelper.maybeGetSolanaGasEstimations(() -> {
workWithTransactions(activity, selectedNetwork, allNetworks, pendingTxInfos,
accounts, walletListItemModel, assetPrices, fullTokenList,
nativeAssetsBalances, blockchainTokensBalances,
solanaTransactionsGasHelper.getPerTxFee(), callback);
});
});
}
@@ -1187,19 +1173,15 @@ public class Utils {
}
private static void workWithTransactions(BraveWalletBaseActivity activity,
NetworkInfo selectedNetwork, HashMap<String, TransactionInfo[]> pendingTxInfos,
AccountInfo[] accounts, WalletListItemModel walletListItemModel,
HashMap<String, Double> assetPrices, BlockchainToken[] fullTokenList,
HashMap<String, Double> nativeAssetsBalances,
NetworkInfo selectedNetwork, List<NetworkInfo> allNetworks,
HashMap<String, TransactionInfo[]> pendingTxInfos, AccountInfo[] accounts,
WalletListItemModel walletListItemModel, HashMap<String, Double> assetPrices,
BlockchainToken[] fullTokenList, HashMap<String, Double> nativeAssetsBalances,
HashMap<String, HashMap<String, Double>> blockchainTokensBalances,
RecyclerView rvTransactions, OnWalletListItemClick callback,
WalletCoinAdapter walletTxCoinAdapter, HashMap<String, Long> perTxSolanaFee) {
walletTxCoinAdapter.setWalletCoinAdapterType(
WalletCoinAdapter.AdapterType.VISIBLE_ASSETS_LIST);
HashMap<String, Long> perTxSolanaFee,
Callbacks.Callback1<List<WalletListItemModel>> callback) {
List<WalletListItemModel> walletListItemModelList = new ArrayList<>();
BlockchainToken filterByToken =
walletListItemModel.isAccount() ? null : walletListItemModel.getBlockchainToken();
for (String accountName : pendingTxInfos.keySet()) {
TransactionInfo[] txInfos = pendingTxInfos.get(accountName);
for (TransactionInfo txInfo : txInfos) {
@@ -1207,11 +1189,13 @@ public class Utils {
if (perTxSolanaFee.get(txInfo.id) != null) {
solanaEstimatedTxFee = perTxSolanaFee.get(txInfo.id);
}
ParsedTransaction parsedTx = ParsedTransaction.parseTransaction(txInfo,
selectedNetwork, accounts, assetPrices, solanaEstimatedTxFee, fullTokenList,
var txNetwork = JavaUtils.safeVal(
NetworkUtils.findNetwork(allNetworks, txInfo.chainId), selectedNetwork);
ParsedTransaction parsedTx = ParsedTransaction.parseTransaction(txInfo, txNetwork,
accounts, assetPrices, solanaEstimatedTxFee, fullTokenList,
nativeAssetsBalances, blockchainTokensBalances);
WalletListItemModel itemModel =
makeWalletItem((Context) activity, txInfo, selectedNetwork, parsedTx);
makeWalletItem((Context) activity, txInfo, txNetwork, parsedTx);
// Filter by token. Account is already filtered in the accounts array.
if (!walletListItemModel.isAccount()
&& !walletListItemModel.getBlockchainToken().symbol.equals(
@@ -1220,11 +1204,7 @@ public class Utils {
walletListItemModelList.add(itemModel);
}
}
walletTxCoinAdapter.setWalletListItemModelList(walletListItemModelList);
walletTxCoinAdapter.setOnWalletListItemClick(callback);
walletTxCoinAdapter.setWalletListItemType(Utils.TRANSACTION_ITEM);
rvTransactions.setAdapter(walletTxCoinAdapter);
rvTransactions.setLayoutManager(new LinearLayoutManager((Context) activity));
callback.call(walletListItemModelList);
}
private static WalletListItemModel makeWalletItem(Context context, TransactionInfo txInfo,
@@ -123,9 +123,9 @@
android:id="@+id/rv_transactions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="24dp"/>
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="24dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
</LinearLayout>
@@ -320,9 +320,9 @@
android:id="@+id/rv_transactions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="24dp"/>
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="24dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
<TextView
android:layout_width="match_parent"