Skip to content

Commit

Permalink
chore(wallet): Migrate Report Tx Sent P3A question into core (#22360)
Browse files Browse the repository at this point in the history
* Move P3A transaction sent reporting into core
  • Loading branch information
StephenHeaps authored Mar 7, 2024
1 parent df60dd4 commit 01f9f5f
Show file tree
Hide file tree
Showing 17 changed files with 517 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@

import com.google.android.material.tabs.TabLayout;

import org.chromium.base.CommandLine;
import org.chromium.base.Log;
import org.chromium.brave_wallet.mojom.AccountInfo;
import org.chromium.brave_wallet.mojom.AssetRatioService;
import org.chromium.brave_wallet.mojom.BlockchainRegistry;
import org.chromium.brave_wallet.mojom.BlockchainToken;
import org.chromium.brave_wallet.mojom.BraveWalletConstants;
import org.chromium.brave_wallet.mojom.BraveWalletP3a;
import org.chromium.brave_wallet.mojom.BraveWalletService;
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;
Expand All @@ -64,7 +60,6 @@
import org.chromium.chrome.browser.crypto_wallet.util.TokenUtils;
import org.chromium.chrome.browser.crypto_wallet.util.TransactionUtils;
import org.chromium.chrome.browser.crypto_wallet.util.Utils;
import org.chromium.chrome.browser.crypto_wallet.util.WalletConstants;
import org.chromium.chrome.browser.util.LiveDataUtil;
import org.chromium.chrome.browser.util.TabUtils;

Expand Down Expand Up @@ -181,15 +176,6 @@ private KeyringService getKeyringService() {
return null;
}

private BraveWalletP3a getBraveWalletP3A() {
Activity activity = getActivity();
if (activity instanceof BraveWalletBaseActivity) {
return ((BraveWalletBaseActivity) activity).getBraveWalletP3A();
}

return null;
}

@Override
public void show(FragmentManager manager, String tag) {
try {
Expand Down Expand Up @@ -514,7 +500,6 @@ private void approveTransaction() {
"approveTransaction", providerError, errorMessage);
return;
}
reportTransactionForP3A();
mApproved = true;
if (mTransactionConfirmationListener != null) {
mTransactionConfirmationListener.onApproveTransaction();
Expand All @@ -523,22 +508,6 @@ private void approveTransaction() {
});
}

private void reportTransactionForP3A() {
if (!WalletConstants.SEND_TRANSACTION_TYPES.contains(mTxInfo.txType)
&& !(mCoinType == CoinType.FIL && mTxInfo.txType == TransactionType.OTHER)) {
return;
}
BraveWalletP3a braveWalletP3A = getBraveWalletP3A();
assert braveWalletP3A != null;

boolean countTestNetworks = CommandLine.getInstance().hasSwitch(
BraveWalletConstants.P3A_COUNT_TEST_NETWORKS_SWITCH);
if (countTestNetworks
|| !WalletConstants.KNOWN_TEST_CHAIN_IDS.contains(mTxNetwork.chainId)) {
braveWalletP3A.reportTransactionSent(mCoinType, true);
}
}

private boolean canUpdateUi() {
return isAdded() && getActivity() != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,4 @@ public final class WalletConstants {

public static final List<String> KNOWN_TEST_CHAIN_IDS =
new ArrayList<>(KNOWN_TEST_CHAINS_MAP.keySet());

public static final List<Integer> SEND_TRANSACTION_TYPES = Arrays.asList(
TransactionType.ETH_SEND, TransactionType.ERC20_TRANSFER,
TransactionType.SOLANA_SYSTEM_TRANSFER, TransactionType.SOLANA_SPL_TOKEN_TRANSFER,
TransactionType.SOLANA_SPL_TOKEN_TRANSFER_WITH_ASSOCIATED_TOKEN_ACCOUNT_CREATION);
}
Loading

0 comments on commit 01f9f5f

Please sign in to comment.