Move chainId type to long and add palm

pull/2184/head
James Brown 3 years ago
parent 964349c3dd
commit 56179410e9
  1. 2
      README.md
  2. 2
      app/build.gradle
  3. 3
      app/src/main/java/com/alphawallet/app/C.java
  4. 26
      app/src/main/java/com/alphawallet/app/entity/ContractLocator.java
  5. 10
      app/src/main/java/com/alphawallet/app/entity/CustomViewSettings.java
  6. 6
      app/src/main/java/com/alphawallet/app/entity/EIP681Request.java
  7. 2
      app/src/main/java/com/alphawallet/app/entity/EtherscanTransaction.java
  8. 10
      app/src/main/java/com/alphawallet/app/entity/Event.java
  9. 10
      app/src/main/java/com/alphawallet/app/entity/EventMeta.java
  10. 2
      app/src/main/java/com/alphawallet/app/entity/NetworkInfo.java
  11. 6
      app/src/main/java/com/alphawallet/app/entity/QRResult.java
  12. 14
      app/src/main/java/com/alphawallet/app/entity/Transaction.java
  13. 2
      app/src/main/java/com/alphawallet/app/entity/TransactionDecoder.java
  14. 4
      app/src/main/java/com/alphawallet/app/entity/TransactionMeta.java
  15. 4
      app/src/main/java/com/alphawallet/app/entity/UnknownToken.java
  16. 13
      app/src/main/java/com/alphawallet/app/entity/tokens/TokenCardMeta.java
  17. 8
      app/src/main/java/com/alphawallet/app/entity/tokens/TokenInfo.java
  18. 2
      app/src/main/java/com/alphawallet/app/entity/tokenscript/EventUtils.java
  19. 8
      app/src/main/java/com/alphawallet/app/entity/walletconnect/WCRequest.java
  20. 2
      app/src/main/java/com/alphawallet/app/entity/walletconnect/WalletConnectSessionItem.java
  21. 16
      app/src/main/java/com/alphawallet/app/interact/CreateTransactionInteract.java
  22. 2
      app/src/main/java/com/alphawallet/app/interact/ENSInteract.java
  23. 6
      app/src/main/java/com/alphawallet/app/interact/FetchTokensInteract.java
  24. 4
      app/src/main/java/com/alphawallet/app/interact/FetchTransactionsInteract.java
  25. 4
      app/src/main/java/com/alphawallet/app/interact/FindDefaultNetworkInteract.java
  26. 31
      app/src/main/java/com/alphawallet/app/repository/AWRealmMigration.java
  27. 329
      app/src/main/java/com/alphawallet/app/repository/EthereumNetworkBase.java
  28. 8
      app/src/main/java/com/alphawallet/app/repository/EthereumNetworkRepository.java
  29. 24
      app/src/main/java/com/alphawallet/app/repository/EthereumNetworkRepositoryType.java
  30. 4
      app/src/main/java/com/alphawallet/app/repository/PreferenceRepositoryType.java
  31. 10
      app/src/main/java/com/alphawallet/app/repository/SharedPreferenceRepository.java
  32. 26
      app/src/main/java/com/alphawallet/app/repository/TokenLocalSource.java
  33. 50
      app/src/main/java/com/alphawallet/app/repository/TokenRepository.java
  34. 29
      app/src/main/java/com/alphawallet/app/repository/TokenRepositoryType.java
  35. 57
      app/src/main/java/com/alphawallet/app/repository/TokensRealmSource.java
  36. 8
      app/src/main/java/com/alphawallet/app/repository/TransactionLocalSource.java
  37. 28
      app/src/main/java/com/alphawallet/app/repository/TransactionRepository.java
  38. 20
      app/src/main/java/com/alphawallet/app/repository/TransactionRepositoryType.java
  39. 8
      app/src/main/java/com/alphawallet/app/repository/TransactionsRealmCache.java
  40. 10
      app/src/main/java/com/alphawallet/app/repository/entity/RealmAuxData.java
  41. 6
      app/src/main/java/com/alphawallet/app/repository/entity/RealmGasSpread.java
  42. 6
      app/src/main/java/com/alphawallet/app/repository/entity/RealmToken.java
  43. 4
      app/src/main/java/com/alphawallet/app/repository/entity/RealmTokenScriptData.java
  44. 6
      app/src/main/java/com/alphawallet/app/repository/entity/RealmTransaction.java
  45. 6
      app/src/main/java/com/alphawallet/app/repository/entity/RealmWCSession.java
  46. 2
      app/src/main/java/com/alphawallet/app/router/SendTokenRouter.java
  47. 8
      app/src/main/java/com/alphawallet/app/service/AlphaWalletService.java
  48. 60
      app/src/main/java/com/alphawallet/app/service/AssetDefinitionService.java
  49. 24
      app/src/main/java/com/alphawallet/app/service/GasService.java
  50. 39
      app/src/main/java/com/alphawallet/app/service/KeystoreAccountService.java
  51. 36
      app/src/main/java/com/alphawallet/app/service/OpenSeaService.java
  52. 47
      app/src/main/java/com/alphawallet/app/service/TickerService.java
  53. 77
      app/src/main/java/com/alphawallet/app/service/TokensService.java
  54. 26
      app/src/main/java/com/alphawallet/app/service/TransactionsNetworkClient.java
  55. 12
      app/src/main/java/com/alphawallet/app/service/TransactionsService.java
  56. 10
      app/src/main/java/com/alphawallet/app/ui/AddCustomRPCNetworkActivity.java
  57. 4
      app/src/main/java/com/alphawallet/app/ui/AddTokenActivity.java
  58. 2
      app/src/main/java/com/alphawallet/app/ui/AssetDisplayActivity.java
  59. 15
      app/src/main/java/com/alphawallet/app/ui/DappBrowserFragment.java
  60. 4
      app/src/main/java/com/alphawallet/app/ui/Erc1155Activity.java
  61. 2
      app/src/main/java/com/alphawallet/app/ui/Erc1155AssetDetailActivity.java
  62. 2
      app/src/main/java/com/alphawallet/app/ui/Erc1155AssetListActivity.java
  63. 2
      app/src/main/java/com/alphawallet/app/ui/Erc1155AssetSelectActivity.java
  64. 2
      app/src/main/java/com/alphawallet/app/ui/Erc1155AssetsFragment.java
  65. 2
      app/src/main/java/com/alphawallet/app/ui/Erc1155InfoFragment.java
  66. 6
      app/src/main/java/com/alphawallet/app/ui/Erc20DetailActivity.java
  67. 2
      app/src/main/java/com/alphawallet/app/ui/FunctionActivity.java
  68. 4
      app/src/main/java/com/alphawallet/app/ui/GasSettingsActivity.java
  69. 2
      app/src/main/java/com/alphawallet/app/ui/HomeActivity.java
  70. 2
      app/src/main/java/com/alphawallet/app/ui/ImportTokenActivity.java
  71. 10
      app/src/main/java/com/alphawallet/app/ui/MyAddressActivity.java
  72. 2
      app/src/main/java/com/alphawallet/app/ui/QRScanning/QRScanner.java
  73. 2
      app/src/main/java/com/alphawallet/app/ui/RedeemAssetSelectActivity.java
  74. 2
      app/src/main/java/com/alphawallet/app/ui/RedeemSignatureDisplayActivity.java
  75. 10
      app/src/main/java/com/alphawallet/app/ui/SelectNetworkActivity.java
  76. 4
      app/src/main/java/com/alphawallet/app/ui/SelectNetworkFilterActivity.java
  77. 2
      app/src/main/java/com/alphawallet/app/ui/SellDetailActivity.java
  78. 6
      app/src/main/java/com/alphawallet/app/ui/SendActivity.java
  79. 2
      app/src/main/java/com/alphawallet/app/ui/TokenActivityFragment.java
  80. 2
      app/src/main/java/com/alphawallet/app/ui/TokenDetailActivity.java
  81. 2
      app/src/main/java/com/alphawallet/app/ui/TokenFunctionActivity.java
  82. 2
      app/src/main/java/com/alphawallet/app/ui/TransactionDetailActivity.java
  83. 2
      app/src/main/java/com/alphawallet/app/ui/TransferNFTActivity.java
  84. 4
      app/src/main/java/com/alphawallet/app/ui/TransferTicketDetailActivity.java
  85. 21
      app/src/main/java/com/alphawallet/app/ui/WalletConnectActivity.java
  86. 2
      app/src/main/java/com/alphawallet/app/ui/WalletsActivity.java
  87. 8
      app/src/main/java/com/alphawallet/app/ui/widget/adapter/MultiSelectNetworkAdapter.java
  88. 2
      app/src/main/java/com/alphawallet/app/ui/widget/adapter/SingleSelectNetworkAdapter.java
  89. 4
      app/src/main/java/com/alphawallet/app/ui/widget/adapter/TokenScriptManagementAdapter.java
  90. 2
      app/src/main/java/com/alphawallet/app/ui/widget/adapter/TokensAdapter.java
  91. 4
      app/src/main/java/com/alphawallet/app/ui/widget/entity/IconItem.java
  92. 8
      app/src/main/java/com/alphawallet/app/ui/widget/entity/NetworkItem.java
  93. 8
      app/src/main/java/com/alphawallet/app/ui/widget/entity/TokenTransferData.java
  94. 7
      app/src/main/java/com/alphawallet/app/ui/widget/holder/TokenGridHolder.java
  95. 2
      app/src/main/java/com/alphawallet/app/ui/widget/holder/TokenListHolder.java
  96. 20
      app/src/main/java/com/alphawallet/app/util/AWEnsResolver.java
  97. 4
      app/src/main/java/com/alphawallet/app/util/EnsResolver.java
  98. 2
      app/src/main/java/com/alphawallet/app/util/QRParser.java
  99. 124
      app/src/main/java/com/alphawallet/app/util/Utils.java
  100. 12
      app/src/main/java/com/alphawallet/app/viewmodel/ActivityViewModel.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -91,7 +91,7 @@ class CustomViewSettings
...
```
private static final List<TokenInfo> lockedTokens = Arrays.asList(
// new TokenInfo(String TokenAddress, String TokenName, String TokenSymbol, int TokenDecimals, boolean isEnabled, int ChainId)
// new TokenInfo(String TokenAddress, String TokenName, String TokenSymbol, int TokenDecimals, boolean isEnabled, long ChainId)
new TokenInfo("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "USD Coin", "USDC", 6, true, EthereumNetworkBase.MAINNET_ID)
);

@ -46,7 +46,7 @@ android {
//Put your Infura key here, NB with over 30 - 40 users this API key will rate limit, it's only here for bootstrapping a free build
def DEFAULT_INFURA_API_KEY = "\"da3717f25f824cc1baa32d812386d93f\"";
buildConfigField 'int', 'DB_VERSION', '34'
buildConfigField 'int', 'DB_VERSION', '35'
buildConfigField "String", XInfuraAPI, DEFAULT_INFURA_API_KEY
ndk {

@ -45,6 +45,8 @@ public abstract class C {
public static final String CRONOS_TEST_NETWORK = "Cronos (Test)";
public static final String ARBITRUM_TEST_NETWORK = "Arbitrum (Test)";
public static final String ARBITRUM_ONE_NETWORK = "Arbitrum One";
public static final String PALM_NAME = "PALM";
public static final String PALM_TEST_NAME = "PALM (Test)";
public static final String ETHEREUM_TICKER_NAME = "ethereum";
public static final String CLASSIC_TICKER_NAME = "ethereum-classic";
@ -71,6 +73,7 @@ public abstract class C {
public static final String CRONOS_SYMBOL = "tCRO";
public static final String ARBITRUM_SYMBOL = "AETH";
public static final String ARBITRUM_TEST_SYMBOL = "ARETH";
public static final String PALM_SYMBOL = "PALM";
public static final String BURN_ADDRESS = "0x0000000000000000000000000000000000000000";

@ -18,27 +18,27 @@ import java.util.List;
public class ContractLocator implements Parcelable
{
public final String address;
public final int chainId;
public final long chainId;
private final ContractType type;
public ContractLocator(String n, int chain)
public ContractLocator(String n, long chainId)
{
address = n;
chainId = chain;
type = ContractType.NOT_SET;
this.address = n;
this.chainId = chainId;
this.type = ContractType.NOT_SET;
}
public ContractLocator(String n, int chain, ContractType t)
public ContractLocator(String n, long chainId, ContractType t)
{
address = n;
chainId = chain;
type = t;
this.address = n;
this.chainId = chainId;
this.type = t;
}
protected ContractLocator(Parcel in)
{
this.address = in.readString();
this.chainId = in.readInt();
this.chainId = in.readLong();
this.type = ContractType.values()[in.readInt()];
}
@ -53,7 +53,7 @@ public class ContractLocator implements Parcelable
}
/* replace this with a one-liner use of stream when we up our minSdkVersion to 24 */
public static ContractLocator[] fromAddresses(String[] addresses, int chainID) {
public static ContractLocator[] fromAddresses(String[] addresses, long chainID) {
ContractLocator[] retval = new ContractLocator[addresses.length];
for (int i=0; i<addresses.length; i++) {
retval[i] = new ContractLocator(addresses[i], chainID);
@ -65,7 +65,7 @@ public class ContractLocator implements Parcelable
{
// public Map<Integer, List<String>> addresses = new HashMap<>();
List<ContractLocator> retVal = new ArrayList<>();
for (int chainId : cInfo.addresses.keySet())
for (long chainId : cInfo.addresses.keySet())
{
for (String addr : cInfo.addresses.get(chainId))
{
@ -98,7 +98,7 @@ public class ContractLocator implements Parcelable
public void writeToParcel(Parcel dest, int flags)
{
dest.writeString(address);
dest.writeInt(chainId);
dest.writeLong(chainId);
dest.writeInt(type.ordinal());
}
}

@ -19,7 +19,7 @@ import static com.alphawallet.ethereum.EthereumNetworkBase.MAINNET_ID;
public class CustomViewSettings
{
private static final int primaryChain = MAINNET_ID;
private static final long primaryChain = MAINNET_ID;
private static final String primaryChainName = C.ETHEREUM_NETWORK_NAME;
//You can use the settings in this file to customise the wallet appearance
@ -28,7 +28,7 @@ public class CustomViewSettings
//See also lockedChains. You can also lock the chains that are displayed on.
//If you leave the locked chains empty, the token will appear if the chain is selected
private static final List<TokenInfo> lockedTokens = Arrays.asList(
// new TokenInfo(String TokenAddress, String TokenName, String TokenSymbol, int TokenDecimals, boolean isEnabled, int ChainId)
// new TokenInfo(String TokenAddress, String TokenName, String TokenSymbol, int TokenDecimals, boolean isEnabled, long ChainId)
//new TokenInfo("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "USD Coin", "USDC", 6, true, EthereumNetworkBase.MAINNET_ID),
//new TokenInfo("0x6C8c6b02E7b2BE14d4fA6022Dfd6d75921D90E4E", "Compound BAT", "CBAT", 8, true, EthereumNetworkBase.MAINNET_ID)
);
@ -36,7 +36,7 @@ public class CustomViewSettings
//List of chains that wallet can show
//If blank, enable the user filter select dialog, if there are any entries here, the select network dialog is disabled
//Note: you should always enable the chainId corresponding to the chainIDs in the lockedTokens.
private static final List<Integer> lockedChains = Arrays.asList(
private static final List<Long> lockedChains = Arrays.asList(
//EthereumNetworkBase.MAINNET_ID //EG only show Main, xdai, classic and two testnets. Don't allow user to select any others
//EthereumNetworkBase.XDAI_ID,
//EthereumNetworkBase.RINKEBY_ID, //You can mix testnets and mainnets, but probably shouldn't as it may result in people getting scammed
@ -51,7 +51,7 @@ public class CustomViewSettings
return lockedTokens;
}
public static List<Integer> getLockedChains()
public static List<Long> getLockedChains()
{
return lockedChains;
}
@ -70,7 +70,7 @@ public class CustomViewSettings
return token.type == ContractType.ETHEREUM || token.isEnabled || isLockedToken(token.getChain(), token.getAddress());
}
private static boolean isLockedToken(int chainId, String contractAddress)
private static boolean isLockedToken(long chainId, String contractAddress)
{
for (TokenInfo tInfo : lockedTokens)
{

@ -14,17 +14,17 @@ public class EIP681Request
private final String PROTOCOL = "ethereum:";
private String address;
private BigDecimal weiAmount;
private int chainId;
private long chainId;
private String contractAddress;
public EIP681Request(String displayAddress, int chainId, BigDecimal weiAmount)
public EIP681Request(String displayAddress, long chainId, BigDecimal weiAmount)
{
this.address = displayAddress;
this.chainId = chainId;
this.weiAmount = weiAmount;
}
public EIP681Request(String userAddress, String contractAddress, int chainId, BigDecimal weiAmount)
public EIP681Request(String userAddress, String contractAddress, long chainId, BigDecimal weiAmount)
{
this.address = userAddress;
this.chainId = chainId;

@ -26,7 +26,7 @@ public class EtherscanTransaction
String gasUsed;
int confirmations;
public Transaction createTransaction(String walletAddress, int chainId)
public Transaction createTransaction(String walletAddress, long chainId)
{
Transaction tx = new Transaction(hash, isError, blockNumber, timeStamp, nonce, from, to, value, gas, gasPrice, input,
gasUsed, chainId, contractAddress);

@ -10,7 +10,7 @@ public class Event implements Parcelable
{
private final String eventText;
private final long timeStamp;
private final int chainId;
private final long chainId;
@Override
public int describeContents()
@ -18,7 +18,7 @@ public class Event implements Parcelable
return 0;
}
public Event(String eventTxt, long timeStamp, int chainId)
public Event(String eventTxt, long timeStamp, long chainId)
{
this.eventText = eventTxt;
this.timeStamp = timeStamp;
@ -29,7 +29,7 @@ public class Event implements Parcelable
{
eventText = in.readString();
timeStamp = in.readLong();
chainId = in.readInt();
chainId = in.readLong();
}
@Override
@ -37,7 +37,7 @@ public class Event implements Parcelable
{
dest.writeString(eventText);
dest.writeLong(timeStamp);
dest.writeInt(chainId);
dest.writeLong(chainId);
}
public static final Creator<Transaction> CREATOR = new Creator<Transaction>()
@ -63,5 +63,5 @@ public class Event implements Parcelable
String hash = eventText + "-" + timeStamp;
return String.valueOf(hash.hashCode());
}
public int getChainId() { return chainId; }
public long getChainId() { return chainId; }
}

@ -7,16 +7,16 @@ import java.util.UUID;
*/
public class EventMeta extends ActivityMeta
{
public final int chainId;
public final long chainId;
public final String eventName;
public final String activityCardName;
public EventMeta(String txHash, String eName, String cardName, long timeStamp, int chain)
public EventMeta(String txHash, String eName, String cardName, long timeStamp, long chainId)
{
super(timeStamp, txHash);
chainId = chain;
eventName = eName;
activityCardName = cardName;
this.chainId = chainId;
this.eventName = eName;
this.activityCardName = cardName;
}
public long getUID()

@ -20,7 +20,7 @@ public class NetworkInfo extends com.alphawallet.ethereum.NetworkInfo {
String symbol,
String rpcServerUrl,
String etherscanUrl,
int chainId,
long chainId,
String backupNodeUrl,
String etherscanAPI) {
super(name, symbol, rpcServerUrl, etherscanUrl, chainId);

@ -17,7 +17,7 @@ public class QRResult implements Parcelable
private String protocol;
private String address; //becomes the token address for a transfer
private String functionStr;
public int chainId;
public long chainId;
public BigInteger weiValue;
public String functionDetail;
public BigInteger gasLimit;
@ -64,7 +64,7 @@ public class QRResult implements Parcelable
{
protocol = in.readString();
address = in.readString();
chainId = in.readInt();
chainId = in.readLong();
functionStr = in.readString();
functionDetail = in.readString();
gasLimit = new BigInteger(in.readString(), 16);
@ -102,7 +102,7 @@ public class QRResult implements Parcelable
{
p.writeString(protocol);
p.writeString(address);
p.writeInt(chainId);
p.writeLong(chainId);
p.writeString(functionStr);
p.writeString(functionDetail);
p.writeString(gasLimit.toString(16));

@ -58,7 +58,7 @@ public class Transaction implements Parcelable
public final String gasUsed;
public final String input;
public final String error;
public final int chainId;
public final long chainId;
public boolean isConstructor = false;
public TransactionInput transactionInput = null;
@ -114,7 +114,7 @@ public class Transaction implements Parcelable
String gasPrice,
String input,
String gasUsed,
int chainId,
long chainId,
boolean isConstructor) {
this.hash = hash;
this.error = error;
@ -132,7 +132,7 @@ public class Transaction implements Parcelable
this.isConstructor = isConstructor;
}
public Transaction(Web3Transaction tx, int chainId, String wallet)
public Transaction(Web3Transaction tx, long chainId, String wallet)
{
this.hash = null;
this.error = null;
@ -150,7 +150,7 @@ public class Transaction implements Parcelable
this.isConstructor = tx.isConstructor();
}
public Transaction(org.web3j.protocol.core.methods.response.Transaction ethTx, int chainId, boolean isSuccess, long timeStamp)
public Transaction(org.web3j.protocol.core.methods.response.Transaction ethTx, long chainId, boolean isSuccess, long timeStamp)
{
// Get contract address if constructor
String contractAddress = ethTx.getCreates() != null ? ethTx.getCreates() : "";
@ -189,7 +189,7 @@ public class Transaction implements Parcelable
}
public Transaction(String hash, String isError, String blockNumber, long timeStamp, int nonce, String from, String to,
String value, String gas, String gasPrice, String input, String gasUsed, int chainId, String contractAddress)
String value, String gas, String gasPrice, String input, String gasUsed, long chainId, String contractAddress)
{
if (!TextUtils.isEmpty(contractAddress)) //must be a constructor
{
@ -227,7 +227,7 @@ public class Transaction implements Parcelable
gasPrice = in.readString();
input = in.readString();
gasUsed = in.readString();
chainId = in.readInt();
chainId = in.readLong();
}
public static final Creator<Transaction> CREATOR = new Creator<Transaction>() {
@ -261,7 +261,7 @@ public class Transaction implements Parcelable
dest.writeString(gasPrice);
dest.writeString(input);
dest.writeString(gasUsed);
dest.writeInt(chainId);
dest.writeLong(chainId);
}
public boolean isRelated(String contractAddress, String walletAddress)

@ -97,7 +97,7 @@ public class TransactionDecoder
return thisData;
}
public TransactionInput decodeInput(Web3Transaction web3Tx, int chainId, String walletAddress)
public TransactionInput decodeInput(Web3Transaction web3Tx, long chainId, String walletAddress)
{
TransactionInput thisData = decodeInput(web3Tx.payload);
Transaction tx = new Transaction(web3Tx, chainId, walletAddress);

@ -17,9 +17,9 @@ public class TransactionMeta extends ActivityMeta
{
public final boolean isPending;
public final String contractAddress;
public final int chainId;
public final long chainId;
public TransactionMeta(String hash, long timeStamp, String contractAddress, int chainId, String blockNumber)
public TransactionMeta(String hash, long timeStamp, String contractAddress, long chainId, String blockNumber)
{
super(timeStamp, hash);
this.isPending = blockNumber.equals("0") || blockNumber.equals("-2");

@ -6,12 +6,12 @@ package com.alphawallet.app.entity;
*/
public class UnknownToken
{
public int chainId;
public long chainId;
public String name;
public String address;
public boolean isPopular;
public UnknownToken(int chainId, String address, boolean isPopular)
public UnknownToken(long chainId, String address, boolean isPopular)
{
this.chainId = chainId;
this.address = address;

@ -7,6 +7,7 @@ import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.alphawallet.app.entity.ContractType;
import com.alphawallet.app.repository.EthereumNetworkBase;
import com.alphawallet.app.repository.EthereumNetworkRepository;
import com.alphawallet.app.repository.TokensRealmSource;
import com.alphawallet.app.service.AssetDefinitionService;
@ -30,7 +31,7 @@ public class TokenCardMeta implements Comparable<TokenCardMeta>, Parcelable
*/
public boolean isEnabled = false;
public TokenCardMeta(int chainId, String tokenAddress, String balance, long timeStamp, AssetDefinitionService svs, String name, String symbol, ContractType type)
public TokenCardMeta(long chainId, String tokenAddress, String balance, long timeStamp, AssetDefinitionService svs, String name, String symbol, ContractType type)
{
this.tokenId = TokensRealmSource.databaseKey(chainId, tokenAddress);
this.lastUpdate = timeStamp;
@ -39,7 +40,7 @@ public class TokenCardMeta implements Comparable<TokenCardMeta>, Parcelable
this.balance = balance;
}
public TokenCardMeta(int chainId, String tokenAddress, String balance, long timeStamp, long lastTxUpdate, ContractType type)
public TokenCardMeta(long chainId, String tokenAddress, String balance, long timeStamp, long lastTxUpdate, ContractType type)
{
this.tokenId = TokensRealmSource.databaseKey(chainId, tokenAddress);
this.lastUpdate = timeStamp;
@ -103,13 +104,13 @@ public class TokenCardMeta implements Comparable<TokenCardMeta>, Parcelable
return !balance.equals("0");
}
public int getChain()
public long getChain()
{
int chainPos = tokenId.lastIndexOf('-') + 1;
if (chainPos < tokenId.length())
{
String chainStr = tokenId.substring(chainPos);
return Integer.parseInt(chainStr);
return Long.parseLong(chainStr);
}
else
{
@ -117,7 +118,7 @@ public class TokenCardMeta implements Comparable<TokenCardMeta>, Parcelable
}
}
public static int calculateTokenNameWeight(int chainId, String tokenAddress, AssetDefinitionService svs, String tokenName, String symbol, boolean isEth)
public static int calculateTokenNameWeight(long chainId, String tokenAddress, AssetDefinitionService svs, String tokenName, String symbol, boolean isEth)
{
int weight = 1000; //ensure base eth types are always displayed first
String name = svs != null ? svs.getTokenName(chainId, tokenAddress, 1) : null;
@ -136,7 +137,7 @@ public class TokenCardMeta implements Comparable<TokenCardMeta>, Parcelable
}
else if (isEth)
{
return chainId + 1;
return 1 + EthereumNetworkBase.getChainOrdinal(chainId);
}
if (TextUtils.isEmpty(name)) return Integer.MAX_VALUE;

@ -11,10 +11,10 @@ public class TokenInfo implements Parcelable {
public final String name;
public final String symbol;
public final int decimals;
public final int chainId;
public final long chainId;
public boolean isEnabled;
public TokenInfo(String address, String name, String symbol, int decimals, boolean isEnabled, int chainId) {
public TokenInfo(String address, String name, String symbol, int decimals, boolean isEnabled, long chainId) {
if (address.contains("-"))
{
address = address.split("-")[0];
@ -40,7 +40,7 @@ public class TokenInfo implements Parcelable {
symbol = in.readString();
decimals = in.readInt();
isEnabled = in.readInt() == 1;
chainId = in.readInt();
chainId = in.readLong();
}
public static final Creator<TokenInfo> CREATOR = new Creator<TokenInfo>() {
@ -67,6 +67,6 @@ public class TokenInfo implements Parcelable {
dest.writeString(symbol);
dest.writeInt(decimals);
dest.writeInt(isEnabled ? 1 : 0);
dest.writeInt(chainId);
dest.writeLong(chainId);
}
}

@ -166,7 +166,7 @@ public abstract class EventUtils
public static EthFilter generateLogFilter(EventDefinition ev, Token originToken, List<BigInteger> tokenIds, AttributeInterface attrIf) throws Exception
{
int chainId = ev.contract.addresses.keySet().iterator().next();
long chainId = ev.contract.addresses.keySet().iterator().next();
String eventContractAddr = ev.contract.addresses.get(chainId).get(0);
final Event resolverEvent = generateEventFunction(ev);

@ -17,7 +17,7 @@ public class WCRequest
public final WCEthereumSignMessage sign;
public final WCPeerMeta peer;
public final SignType type;
public final int chainId;
public final long chainId;
public final Throwable throwable;
public WCRequest(String sessionId, long id, WCEthereumSignMessage msg)
@ -32,7 +32,7 @@ public class WCRequest
throwable = null;
}
public WCRequest(String sessionId, long id, WCEthereumTransaction tx, boolean signOnly, int chainId)
public WCRequest(String sessionId, long id, WCEthereumTransaction tx, boolean signOnly, long chainId)
{
this.sessionId = sessionId;
this.id = id;
@ -44,7 +44,7 @@ public class WCRequest
throwable = null;
}
public WCRequest(String sessionId, long id, WCPeerMeta pm, int chainId)
public WCRequest(String sessionId, long id, WCPeerMeta pm, long chainId)
{
this.sessionId = sessionId;
this.id = id;
@ -56,7 +56,7 @@ public class WCRequest
throwable = null;
}
public WCRequest(String sessionId, Throwable t, int chainId)
public WCRequest(String sessionId, Throwable t, long chainId)
{
this.sessionId = sessionId;
this.id = 0;

@ -12,7 +12,7 @@ public class WalletConnectSessionItem
public final String icon;
public final String sessionId;
public final String localSessionId;
public final int chainId;
public final long chainId;
public WalletConnectSessionItem(RealmWCSession s)
{

@ -28,25 +28,25 @@ public class CreateTransactionInteract
this.transactionRepository = transactionRepository;
}
public Single<SignaturePair> sign(Wallet wallet, MessagePair messagePair, int chainId)
public Single<SignaturePair> sign(Wallet wallet, MessagePair messagePair, long chainId)
{
return transactionRepository.getSignature(wallet, messagePair, chainId)
.map(sig -> new SignaturePair(messagePair.selection, sig.signature, messagePair.message));
}
public Single<SignatureFromKey> sign(Wallet wallet, Signable message, int chainId)
public Single<SignatureFromKey> sign(Wallet wallet, Signable message, long chainId)
{
return transactionRepository.getSignature(wallet, message, chainId);
}
public Single<String> create(Wallet from, String to, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, byte[] data, int chainId)
public Single<String> create(Wallet from, String to, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, byte[] data, long chainId)
{
return transactionRepository.createTransaction(from, to, subunitAmount, gasPrice, gasLimit, data, chainId)
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread());
}
public Single<TransactionData> createWithSig(Wallet from, Web3Transaction web3Tx, int chainId)
public Single<TransactionData> createWithSig(Wallet from, Web3Transaction web3Tx, long chainId)
{
return transactionRepository.createTransactionWithSig(from, web3Tx.recipient.toString(), web3Tx.value,
web3Tx.gasPrice, web3Tx.gasLimit, web3Tx.nonce,
@ -55,21 +55,21 @@ public class CreateTransactionInteract
.observeOn(AndroidSchedulers.mainThread());
}
public Single<TransactionData> createWithSig(Wallet from, String to, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, byte[] data, int chainId)
public Single<TransactionData> createWithSig(Wallet from, String to, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, byte[] data, long chainId)
{
return transactionRepository.createTransactionWithSig(from, to, subunitAmount, gasPrice, gasLimit, -1, data, chainId)
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread());
}
public Single<TransactionData> createWithSig(Wallet from, BigInteger gasPrice, BigInteger gasLimit, String data, int chainId)
public Single<TransactionData> createWithSig(Wallet from, BigInteger gasPrice, BigInteger gasLimit, String data, long chainId)
{
return transactionRepository.createTransactionWithSig(from, gasPrice, gasLimit, data, chainId)
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread());
}
public Single<String> resend(Wallet from, BigInteger nonce, String to, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, byte[] data, int chainId)
public Single<String> resend(Wallet from, BigInteger nonce, String to, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, byte[] data, long chainId)
{
return transactionRepository.resendTransaction(from, to, subunitAmount, nonce, gasPrice, gasLimit, data, chainId)
.subscribeOn(Schedulers.computation())
@ -81,7 +81,7 @@ public class CreateTransactionInteract
transactionRepository.removeOverridenTransaction(wallet, oldTxHash);
}
public Single<TransactionData> signTransaction(Wallet wallet, Web3Transaction w3tx, int chainId)
public Single<TransactionData> signTransaction(Wallet wallet, Web3Transaction w3tx, long chainId)
{
return transactionRepository.getSignatureForTransaction(wallet, w3tx, chainId);
}

@ -20,7 +20,7 @@ public class ENSInteract
this.tokenRepository = tokenRepository;
}
public Single<String> checkENSAddress(int chainId, String name)
public Single<String> checkENSAddress(long chainId, String name)
{
if (!ENSHandler.canBeENSName(name)) return Single.fromCallable(() -> "0");
return tokenRepository.resolveENS(chainId, name)

@ -26,7 +26,7 @@ public class FetchTokensInteract {
this.tokenRepository = tokenRepository;
}
public Observable<ContractLocator> getContractResponse(String address, int chainId, String method)
public Observable<ContractLocator> getContractResponse(String address, long chainId, String method)
{
return tokenRepository.getTokenResponse(address, chainId, method).toObservable();
}
@ -46,7 +46,7 @@ public class FetchTokensInteract {
.observeOn(AndroidSchedulers.mainThread());
}
public Single<TokenTicker> getEthereumTicker(int chainId)
public Single<TokenTicker> getEthereumTicker(long chainId)
{
return tokenRepository.getEthTicker(chainId);
}
@ -58,7 +58,7 @@ public class FetchTokensInteract {
return tokenRepository.fetchIsRedeemed(token, tokenId);
}
public Single<TokenCardMeta[]> fetchTokenMetas(Wallet wallet, List<Integer> networkFilters, AssetDefinitionService svs)
public Single<TokenCardMeta[]> fetchTokenMetas(Wallet wallet, List<Long> networkFilters, AssetDefinitionService svs)
{
return tokenRepository.fetchTokenMetas(wallet, networkFilters, svs);
}

@ -28,14 +28,14 @@ public class FetchTransactionsInteract {
this.tokenRepository = tokenRepositoryType;
}
public Single<ActivityMeta[]> fetchTransactionMetas(Wallet wallet, List<Integer> networkFilters, long fetchTime, int fetchLimit) {
public Single<ActivityMeta[]> fetchTransactionMetas(Wallet wallet, List<Long> networkFilters, long fetchTime, int fetchLimit) {
return transactionRepository
.fetchCachedTransactionMetas(wallet, networkFilters, fetchTime, fetchLimit)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Single<ActivityMeta[]> fetchEventMetas(Wallet wallet, List<Integer> networkFilters)
public Single<ActivityMeta[]> fetchEventMetas(Wallet wallet, List<Long> networkFilters)
{
return transactionRepository.fetchEventMetas(wallet, networkFilters);
}

@ -11,12 +11,12 @@ public class FindDefaultNetworkInteract {
this.ethereumNetworkRepository = ethereumNetworkRepository;
}
public String getNetworkName(int chainId)
public String getNetworkName(long chainId)
{
return ethereumNetworkRepository.getNetworkByChain(chainId).getShortName();
}
public NetworkInfo getNetworkInfo(int chainId)
public NetworkInfo getNetworkInfo(long chainId)
{
return ethereumNetworkRepository.getNetworkByChain(chainId);
}

@ -1,5 +1,7 @@
package com.alphawallet.app.repository;
import com.alphawallet.app.repository.entity.RealmGasSpread;
import io.realm.DynamicRealm;
import io.realm.FieldAttribute;
import io.realm.RealmMigration;
@ -338,6 +340,35 @@ public class AWRealmMigration implements RealmMigration
}
oldVersion++;
}
if (oldVersion == 34)
{
RealmObjectSchema realmToken = schema.get("RealmToken");
if (realmToken.hasField("chainId")) realmToken.removeField("chainId");
realmToken.addField("chainId", long.class);
RealmObjectSchema realmData = schema.get("RealmAuxData");
realmData.removeField("chainId");
realmData.addField("chainId", long.class);
realmData = schema.get("RealmGasSpread");
realmData.removeField("chainId");
realmData.addField("chainId", long.class, FieldAttribute.PRIMARY_KEY);
realmData = schema.get("RealmToken");
realmData.removeField("chainId");
realmData.addField("chainId", long.class);
realmData = schema.get("RealmTransaction");
realmData.removeField("chainId");
realmData.addField("chainId", long.class);
realmData = schema.get("RealmWCSession");
realmData.removeField("chainId");
realmData.addField("chainId", long.class);
oldVersion++;
}
}
@Override

@ -4,6 +4,7 @@ package com.alphawallet.app.repository;
* between projects including non-Android projects */
import android.text.TextUtils;
import android.view.View;
import com.alphawallet.app.C;
import com.alphawallet.app.R;
@ -62,12 +63,16 @@ import static com.alphawallet.ethereum.EthereumNetworkBase.MATIC_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.MATIC_TEST_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.OPTIMISTIC_MAIN_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.OPTIMISTIC_TEST_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.PALM_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.PALM_TEST_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.POA_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.RINKEBY_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.ROPSTEN_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.SOKOL_ID;
import static com.alphawallet.ethereum.EthereumNetworkBase.XDAI_ID;
import androidx.core.content.ContextCompat;
public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryType
{
public static final String COVALENT = "[COVALENT]";
@ -93,6 +98,8 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
public static native String getInfuraKey();
public static native String getSecondaryInfuraKey();
private static final List<Long> chains = new ArrayList<>();
//Fallback nodes: these nodes are used if there's no Amberdata key, and also as a fallback in case the primary node times out while attempting a call
public static final String MAINNET_RPC_URL = "https://mainnet.infura.io/v3/" + getInfuraKey();
public static final String RINKEBY_RPC_URL = "https://rinkeby.infura.io/v3/" + getInfuraKey();
@ -135,16 +142,17 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
public static final String ARBITRUM_FALLBACK_MAINNET_RPC = "https://arbitrum-mainnet.infura.io/v3/" + getSecondaryInfuraKey();
public static final String ARBITRUM_TESTNET_RPC = "https://arbitrum-rinkeby.infura.io/v3/" + getInfuraKey();
public static final String ARBITRUM_FALLBACK_TESTNET_RPC = "https://arbitrum-rinkeby.infura.io/v3/" + getSecondaryInfuraKey();
public static final String PALM_RPC_URL = "https://palm-mainnet.infura.io/v3/" + getInfuraKey();
public static final String PALM_TEST_RPC_URL = "https://palm-testnet.infura.io/v3/" + getInfuraKey();
public static final String PALM_RPC_FALLBACK_URL = "https://palm-mainnet.infura.io/v3/" + getSecondaryInfuraKey();
public static final String PALM_TEST_RPC_FALLBACK_URL = "https://palm-testnet.infura.io/v3/" + getSecondaryInfuraKey();
//This optional list creates a defined order in which tokens are displayed
static final int[] orderList = {
MAINNET_ID, CLASSIC_ID, XDAI_ID, POA_ID, ARTIS_SIGMA1_ID, KOVAN_ID, ROPSTEN_ID, SOKOL_ID,
RINKEBY_ID, GOERLI_ID, ARTIS_TAU1_ID, BINANCE_TEST_ID, BINANCE_MAIN_ID, HECO_ID, HECO_TEST_ID,
AVALANCHE_ID, FUJI_TEST_ID, FANTOM_ID, FANTOM_TEST_ID, MATIC_ID, MATIC_TEST_ID, OPTIMISTIC_MAIN_ID,
OPTIMISTIC_TEST_ID, CRONOS_TEST_ID
};
//All chains that have fiat/real value (not testnet) must be put here
static final List<Long> hasValue = Arrays.asList(
MAINNET_ID, POA_ID, CLASSIC_ID, XDAI_ID, ARTIS_SIGMA1_ID, BINANCE_MAIN_ID, HECO_ID, AVALANCHE_ID,
FANTOM_ID, MATIC_ID, OPTIMISTIC_MAIN_ID, ARBITRUM_MAIN_ID, PALM_ID);
static final Map<Integer, NetworkInfo> networkMap = new HashMap<Integer, NetworkInfo>() {
static final Map<Long, NetworkInfo> networkMap = new HashMap<Long, NetworkInfo>() {
{
put(MAINNET_ID, new NetworkInfo(C.ETHEREUM_NETWORK_NAME, C.ETH_SYMBOL,
MAINNET_RPC_URL,
@ -246,22 +254,101 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
"https://arbiscan.io/tx/", ARBITRUM_MAIN_ID, ARBITRUM_FALLBACK_MAINNET_RPC,
"https://api.arbiscan.io/api?"));
put(ARBITRUM_TEST_ID, new NetworkInfo(C.ARBITRUM_TEST_NETWORK, C.ARBITRUM_TEST_SYMBOL,
ARBITRUM_TEST_RPC_URL,
ARBITRUM_TESTNET_RPC,
"https://rinkeby-explorer.arbitrum.io/tx/", ARBITRUM_TEST_ID, ARBITRUM_FALLBACK_TESTNET_RPC,
"")); //no transaction API
put(PALM_ID, new NetworkInfo(C.PALM_NAME, C.PALM_SYMBOL,
PALM_RPC_URL,
"https://explorer.palm.io/tx/", PALM_ID, PALM_RPC_FALLBACK_URL,
"https://explorer.palm.io/api?"));
put(PALM_TEST_ID, new NetworkInfo(C.PALM_TEST_NAME, C.PALM_SYMBOL,
PALM_TEST_RPC_URL,
"https://explorer.palm-uat.xyz/tx/", PALM_TEST_ID, PALM_TEST_RPC_FALLBACK_URL,
"https://explorer.palm-uat.xyz/api?"));
}
};
static final Map<Long, Integer> chainLogos = new HashMap<Long, Integer>() {
{
put(MAINNET_ID, R.drawable.ic_token_eth);
put(KOVAN_ID, R.drawable.kovan_logo);
put(ROPSTEN_ID, R.drawable.ropsten_logo);
put(RINKEBY_ID, R.drawable.rinkeby_logo);
put(CLASSIC_ID, R.drawable.classic_logo);
put(POA_ID, R.drawable.ic_poa_logo);
put(SOKOL_ID, R.drawable.ic_poa_sokol);
put(XDAI_ID, R.drawable.xdai_logo);
put(GOERLI_ID, R.drawable.goerli_logo);
put(ARTIS_SIGMA1_ID, R.drawable.ic_artis_sigma_logo);
put(ARTIS_TAU1_ID, R.drawable.ic_artis_tau_logo);
put(BINANCE_MAIN_ID, R.drawable.ic_binance_logo);
put(BINANCE_TEST_ID, R.drawable.ic_binance_test_logo);
put(HECO_ID, R.drawable.ic_heco_logo);
put(HECO_TEST_ID, R.drawable.ic_heco_logo);
put(FANTOM_ID, R.drawable.ic_fantom);
put(FANTOM_TEST_ID, R.drawable.ic_icons_fantom_test);
put(AVALANCHE_ID, R.drawable.ic_icons_tokens_avalanche);
put(FUJI_TEST_ID, R.drawable.ic_icons_tokens_avalanche_testnet);
put(MATIC_ID, R.drawable.ic_icons_polygon);
put(MATIC_TEST_ID, R.drawable.ic_icons_matic);
put(OPTIMISTIC_MAIN_ID, R.drawable.ic_optimism_logo);
put(OPTIMISTIC_TEST_ID, R.drawable.ic_optimism_testnet_logo);
put(CRONOS_TEST_ID, R.drawable.ic_cronos);
put(ARBITRUM_MAIN_ID, R.drawable.ic_icons_arbitrum);
put(ARBITRUM_TEST_ID, R.drawable.ic_icons_arbitrum_test);
put(PALM_ID, R.drawable.palm_logo);
put(PALM_TEST_ID, R.drawable.palm_logo_test);
}
};
static final Map<Long, Integer> chainColours = new HashMap<Long, Integer>() {
{
put(MAINNET_ID, R.color.mainnet);
put(KOVAN_ID, R.color.kovan);
put(ROPSTEN_ID, R.color.ropsten);
put(RINKEBY_ID, R.color.rinkeby);
put(CLASSIC_ID, R.color.classic);
put(POA_ID, R.color.poa);
put(SOKOL_ID, R.color.sokol);
put(XDAI_ID, R.color.xdai);
put(GOERLI_ID, R.color.goerli);
put(ARTIS_SIGMA1_ID, R.color.artis_sigma1);
put(ARTIS_TAU1_ID, R.color.artis_tau1);
put(BINANCE_MAIN_ID, R.color.binance_main);
put(BINANCE_TEST_ID, R.color.binance_test);
put(HECO_ID, R.color.heco_main);
put(HECO_TEST_ID, R.color.heco_test);
put(FANTOM_ID, R.color.fantom_main);
put(FANTOM_TEST_ID, R.color.fantom_test);
put(AVALANCHE_ID, R.color.avalanche_main);
put(FUJI_TEST_ID, R.color.avalanche_test);
put(MATIC_ID, R.color.polygon_main);
put(MATIC_TEST_ID, R.color.polygon_test);
put(OPTIMISTIC_MAIN_ID, R.color.optimistic_main);
put(OPTIMISTIC_TEST_ID, R.color.optimistic_test);
put(CRONOS_TEST_ID, R.color.cronos_test);
put(ARBITRUM_MAIN_ID, R.color.arbitrum_main);
put(ARBITRUM_TEST_ID, R.color.arbitrum_test);
put(PALM_ID, R.color.palm_main);
put(PALM_TEST_ID, R.color.palm_test);
}
};
public static void setChainColour(View view, long chainId)
{
view.getBackground().setTint(ContextCompat.getColor(view.getContext(), getChainColour(chainId)));
}
//Does the chain have a gas oracle?
//Add it to this list here if so. Note that so far, all gas oracles follow the same format:
// <etherscanAPI from the above list> + GAS_API
//If the gas oracle you're adding doesn't follow this spec then you'll have to change the getGasOracle method
private static final List<Integer> hasGasOracleAPI = Arrays.asList(MAINNET_ID, HECO_ID, BINANCE_MAIN_ID, MATIC_ID);
private static final List<Long> hasGasOracleAPI = Arrays.asList(MAINNET_ID, HECO_ID, BINANCE_MAIN_ID, MATIC_ID);
//These chains don't allow custom gas
private static final List<Integer> hasLockedGas = Arrays.asList(OPTIMISTIC_MAIN_ID, OPTIMISTIC_TEST_ID);
private static final List<Long> hasLockedGas = Arrays.asList(OPTIMISTIC_MAIN_ID, OPTIMISTIC_TEST_ID);
public static String getGasOracle(int chainId)
public static String getGasOracle(long chainId)
{
if (hasGasOracleAPI.contains(chainId) && networkMap.containsKey(chainId))
{
@ -273,13 +360,25 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
}
}
public static int getChainOrdinal(long chainId)
{
if (chains.contains(chainId))
{
return chains.indexOf(chainId);
}
else
{
return 500 + (int)chainId%500; //fixed ID above 500
}
}
@Override
public boolean hasLockedGas(int chainId)
public boolean hasLockedGas(long chainId)
{
return hasLockedGas.contains(chainId);
}
static final Map<Integer, String> addressOverride = new HashMap<Integer, String>() {
static final Map<Long, String> addressOverride = new HashMap<Long, String>() {
{
put(OPTIMISTIC_MAIN_ID, "0x4200000000000000000000000000000000000006");
put(OPTIMISTIC_TEST_ID, "0x4200000000000000000000000000000000000006");
@ -294,8 +393,8 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
static class CustomNetworks {
private ArrayList<NetworkInfo> list = new ArrayList<>();
transient private Map<Integer, NetworkInfo> map = new HashMap<>();
private Map<Integer, Boolean> mapToTestNet = new HashMap<>();
transient private Map<Long, NetworkInfo> map = new HashMap<>();
private Map<Long, Boolean> mapToTestNet = new HashMap<>();
transient private PreferenceRepositoryType preferences;
public CustomNetworks(PreferenceRepositoryType preferences) {
@ -316,7 +415,7 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
}
}
public void addCustomNetwork(NetworkInfo info, boolean isTestnet, Integer oldChainId)
public void addCustomNetwork(NetworkInfo info, boolean isTestnet, Long oldChainId)
{
if (oldChainId != null) {
for (NetworkInfo in : list) {
@ -345,6 +444,8 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
this.additionalNetworks = additionalNetworks;
this.useTestNets = useTestNets;
chains.clear();
chains.addAll(networkMap.keySet());
this.customNetworks = new CustomNetworks(this.preferences);
}
@ -358,41 +459,46 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
private void addNetworks(List<NetworkInfo> result, boolean withValue)
{
for (int networkId : orderList)
if (withValue)
{
if (EthereumNetworkRepository.hasRealValue(networkId) == withValue) result.add(networkMap.get(networkId));
for (long networkId : hasValue)
{
result.add(networkMap.get(networkId));
}
}
//Add in case no order was specified
for (NetworkInfo info : networkMap.values())
else
{
if (EthereumNetworkRepository.hasRealValue(info.chainId) == withValue && !result.contains(info))
//Add in case no order was specified
for (NetworkInfo info : networkMap.values())
{
result.add(info);
if (!hasValue.contains(info.chainId) && !result.contains(info))
{
result.add(info);
}
}
}
}
public static String getChainOverrideAddress(int id) {
return addressOverride.containsKey(id) ? addressOverride.get(id) : "";
public static String getChainOverrideAddress(long chainId) {
return addressOverride.containsKey(chainId) ? addressOverride.get(chainId) : "";
}
@Override
public String getNameById(int id)
public String getNameById(long chainId)
{
NetworkInfo info = customNetworks.map.get(id);
NetworkInfo info = customNetworks.map.get(chainId);
if (info != null) {
return info.name;
}
if (networkMap.containsKey(id)) return networkMap.get(id).name;
else return "Unknown: " + id;
if (networkMap.containsKey(chainId)) return networkMap.get(chainId).name;
else return "Unknown: " + chainId;
}
@Override
public NetworkInfo getActiveBrowserNetwork()
{
int activeNetwork = preferences.getActiveBrowserNetwork();
long activeNetwork = preferences.getActiveBrowserNetwork();
NetworkInfo info = customNetworks.map.get(activeNetwork);
if (info != null) {
return info;
@ -402,7 +508,7 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
}
@Override
public NetworkInfo getNetworkByChain(int chainId)
public NetworkInfo getNetworkByChain(long chainId)
{
NetworkInfo info = customNetworks.map.get(chainId);
if (info != null) {
@ -432,19 +538,19 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
}
@Override
public List<Integer> getFilterNetworkList()
public List<Long> getFilterNetworkList()
{
return getSelectedFilters(preferences.isActiveMainnet());
}
@Override
public List<Integer> getSelectedFilters(boolean isMainNet)
public List<Long> getSelectedFilters(boolean isMainNet)
{
String filterList = preferences.getNetworkFilterList();
List<Integer> storedIds = Utils.intListToArray(filterList);
List<Integer> selectedIds = new ArrayList<>();
List<Long> storedIds = Utils.longListToArray(filterList);
List<Long> selectedIds = new ArrayList<>();
for (Integer networkId : storedIds)
for (Long networkId : storedIds)
{
if (hasRealValue(networkId) == isMainNet) { selectedIds.add(networkId); }
}
@ -460,15 +566,15 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
}
@Override
public Integer getDefaultNetwork(boolean isMainNet)
public Long getDefaultNetwork(boolean isMainNet)
{
return isMainNet ? MAINNET_ID : RINKEBY_ID;
}
@Override
public void setFilterNetworkList(Integer[] networkList)
public void setFilterNetworkList(Long[] networkList)
{
String store = Utils.intArrayToString(networkList);
String store = Utils.longArrayToString(networkList);
preferences.setNetworkFilterList(store.toString());
}
@ -522,32 +628,19 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
onNetworkChangedListeners.add(onNetworkChanged);
}
public static boolean hasRealValue(int chainId)
public static boolean hasRealValue(long chainId)
{
switch (chainId)
if (customNetworks.mapToTestNet.containsKey(chainId))
{
case MAINNET_ID:
case POA_ID:
case CLASSIC_ID:
case XDAI_ID:
case ARTIS_SIGMA1_ID:
case BINANCE_MAIN_ID:
case HECO_ID:
case AVALANCHE_ID:
case FANTOM_ID:
case MATIC_ID:
case OPTIMISTIC_MAIN_ID:
case ARBITRUM_MAIN_ID:
return true;
default:
if (customNetworks.mapToTestNet.containsKey(chainId)) {
return customNetworks.mapToTestNet.get(chainId) == false;
}
return false;
return !customNetworks.mapToTestNet.get(chainId);
}
else
{
return hasValue.contains(chainId);
}
}
public static String getSecondaryNodeURL(int networkId)
public static String getSecondaryNodeURL(long networkId)
{
NetworkInfo info = networkMap.get(networkId);
if (info == null) {
@ -561,66 +654,30 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
}
//TODO: Fold this into file and add to database
public static int getChainLogo(int networkId) {
switch (networkId)
public static int getChainLogo(long networkId) {
if (chainLogos.containsKey(networkId))
{
return chainLogos.get(networkId);
}
else
{
case MAINNET_ID:
return R.drawable.ic_token_eth;
case KOVAN_ID:
return R.drawable.kovan_logo;
case ROPSTEN_ID:
return R.drawable.ropsten_logo;
case RINKEBY_ID:
return R.drawable.rinkeby_logo;
case POA_ID:
return R.drawable.ic_poa_logo;
case SOKOL_ID:
return R.drawable.ic_poa_sokol;
case CLASSIC_ID:
return R.drawable.classic_logo;
case XDAI_ID:
return R.drawable.xdai_logo;
case GOERLI_ID:
return R.drawable.goerli_logo;
case ARTIS_SIGMA1_ID:
return R.drawable.ic_artis_sigma_logo;
case ARTIS_TAU1_ID:
return R.drawable.ic_artis_tau_logo;
case BINANCE_MAIN_ID:
return R.drawable.ic_binance_logo;
case BINANCE_TEST_ID:
return R.drawable.ic_binance_test_logo;
case HECO_ID:
case HECO_TEST_ID:
return R.drawable.ic_heco_logo;
case FANTOM_ID:
return R.drawable.ic_fantom;
case FANTOM_TEST_ID:
return R.drawable.ic_icons_fantom_test;
case AVALANCHE_ID:
return R.drawable.ic_icons_tokens_avalanche;
case FUJI_TEST_ID:
return R.drawable.ic_icons_tokens_avalanche_testnet;
case MATIC_ID:
return R.drawable.ic_icons_polygon;
case MATIC_TEST_ID:
return R.drawable.ic_icons_matic;
case OPTIMISTIC_MAIN_ID:
return R.drawable.ic_optimism_logo;
case OPTIMISTIC_TEST_ID:
return R.drawable.ic_optimism_testnet_logo;
case CRONOS_TEST_ID:
return R.drawable.ic_cronos;
case ARBITRUM_MAIN_ID:
return R.drawable.ic_icons_arbitrum;
case ARBITRUM_TEST_ID:
return R.drawable.ic_icons_arbitrum_test;
default:
return R.drawable.ic_ethereum_logo;
}
}
public static String getNodeURLByNetworkId(int networkId)
return R.drawable.rinkeby_logo;
}
}
public static int getChainColour(long chainId)
{
if (chainColours.containsKey(chainId))
{
return chainColours.get(chainId);
}
else
{
return R.color.text_black;
}
}
public static String getNodeURLByNetworkId(long networkId)
{
NetworkInfo info = networkMap.get(networkId);
if (info == null) {
@ -635,7 +692,7 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
* @param networkId
* @return
*/
public static String getDefaultNodeURL(int networkId) {
public static String getDefaultNodeURL(long networkId) {
NetworkInfo info = networkMap.get(networkId);
if (info == null) {
info = customNetworks.map.get(networkId);
@ -644,7 +701,7 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
else return "";
}
public static String getEtherscanURLbyNetworkAndHash(int networkId, String txHash)
public static String getEtherscanURLbyNetworkAndHash(long networkId, String txHash)
{
NetworkInfo info = networkMap.get(networkId);
if (info == null) {
@ -661,7 +718,7 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
}
}
public static int getNetworkIdFromName(String name)
public static long getNetworkIdFromName(String name)
{
if (!TextUtils.isEmpty(name)) {
for (NetworkInfo NETWORK : customNetworks.map.values()) {
@ -678,12 +735,12 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
return 0;
}
public static boolean hasGasOverride(int chainId)
public static boolean hasGasOverride(long chainId)
{
return false;
}
public static BigInteger gasOverrideValue(int chainId)
public static BigInteger gasOverrideValue(long chainId)
{
return BigInteger.valueOf(1);
}
@ -693,12 +750,12 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
return null;
}
public static void addRequiredCredentials(int chainId, HttpService publicNodeService)
public static void addRequiredCredentials(long chainId, HttpService publicNodeService)
{
}
public static List<Integer> addDefaultNetworks()
public static List<Long> addDefaultNetworks()
{
return new ArrayList<>(Collections.singletonList(MAINNET_ID));
}
@ -709,7 +766,7 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
}
@Override
public boolean isChainContract(int chainId, String address)
public boolean isChainContract(long chainId, String address)
{
return (addressOverride.containsKey(chainId) && address.equalsIgnoreCase(addressOverride.get(chainId)));
}
@ -719,18 +776,18 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
return false;
}
public static int getPriorityOverride(Token token)
public static long getPriorityOverride(Token token)
{
if (token.isEthereum()) return token.tokenInfo.chainId + 1;
else return 0;
}
public static int decimalOverride(String address, int chainId)
public static int decimalOverride(String address, long chainId)
{
return 0;
}
public static String defaultDapp(int chainId)
public static String defaultDapp(long chainId)
{
String dapp = (chainId == MATIC_ID || chainId == MATIC_TEST_ID) ? POLYGON_HOMEPAGE : DEFAULT_HOMEPAGE;
return dapp;
@ -801,12 +858,12 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
return preferences.isActiveMainnet();
}
public void addCustomRPCNetwork(String networkName, String rpcUrl, int chainId, String symbol, String blockExplorerUrl, String explorerApiUrl, boolean isTestnet, Integer oldChainId) {
public void addCustomRPCNetwork(String networkName, String rpcUrl, long chainId, String symbol, String blockExplorerUrl, String explorerApiUrl, boolean isTestnet, Long oldChainId) {
NetworkInfo info = new NetworkInfo(networkName, symbol, rpcUrl, blockExplorerUrl, chainId, null, explorerApiUrl);
customNetworks.addCustomNetwork(info, isTestnet, oldChainId);
}
public NetworkInfoExt getNetworkInfoExt(int chainId) {
public NetworkInfoExt getNetworkInfoExt(long chainId) {
boolean isCustom = customNetworks.map.containsKey(chainId);
NetworkInfo info = getNetworkByChain(chainId);
@ -815,13 +872,13 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
return new NetworkInfoExt(info, isTestNetwork, isCustom);
}
public static NetworkInfo getNetworkInfo(int chainId) {
public static NetworkInfo getNetworkInfo(long chainId) {
NetworkInfo info = networkMap.get(chainId);
if (info == null) info = customNetworks.map.get(chainId);
return info;
}
public static String getShortChainName(int chainId)
public static String getShortChainName(long chainId)
{
NetworkInfo info = networkMap.get(chainId);
if (info == null) info = customNetworks.map.get(chainId);
@ -842,7 +899,7 @@ public abstract class EthereumNetworkBase implements EthereumNetworkRepositoryTy
}
}
public static String getChainSymbol(int chainId)
public static String getChainSymbol(long chainId)
{
NetworkInfo info = networkMap.get(chainId);
if (info == null) info = customNetworks.map.get(chainId);

@ -30,11 +30,11 @@ public class EthereumNetworkRepository extends EthereumNetworkBase
context = ctx;
}
public static String getNodeURLByNetworkId(int networkId) {
public static String getNodeURLByNetworkId(long networkId) {
return EthereumNetworkBase.getNodeURLByNetworkId(networkId);
}
public boolean getIsPopularToken(int chain, String address)
public boolean getIsPopularToken(long chainId, String address)
{
return popularTokens.containsKey(address.toLowerCase());
}
@ -44,7 +44,7 @@ public class EthereumNetworkRepository extends EthereumNetworkBase
* ContractResult import android (therefore preventing their use
* in non-Android projects) or introducing a new trivial
* interface/class */
public List<ContractLocator> getAllKnownContracts(List<Integer> networkFilters)
public List<ContractLocator> getAllKnownContracts(List<Long> networkFilters)
{
if (popularTokens.size() == 0)
{
@ -55,7 +55,7 @@ public class EthereumNetworkRepository extends EthereumNetworkBase
}
//Note: There is an issue with this method - if a contract is the same address on XDAI and MAINNET_ID it needs to be refactored
private void buildPopularTokenMap(List<Integer> networkFilters)
private void buildPopularTokenMap(List<Long> networkFilters)
{
KnownContract knownContract = readContracts();
if (knownContract == null) return;

@ -33,7 +33,7 @@ public interface EthereumNetworkRepositoryType {
void setActiveBrowserNetwork(NetworkInfo networkInfo);
NetworkInfo getNetworkByChain(int chainId);
NetworkInfo getNetworkByChain(long chainId);
Single<BigInteger> getLastTransactionNonce(Web3j web3j, String walletAddress);
@ -42,15 +42,15 @@ public interface EthereumNetworkRepositoryType {
void addOnChangeDefaultNetwork(OnNetworkChangeListener onNetworkChanged);
String getNameById(int id);
String getNameById(long chainId);
List<Integer> getFilterNetworkList();
List<Integer> getSelectedFilters(boolean isMainNet);
Integer getDefaultNetwork(boolean isMainNet);
List<Long> getFilterNetworkList();
List<Long> getSelectedFilters(boolean isMainNet);
Long getDefaultNetwork(boolean isMainNet);
void setFilterNetworkList(Integer[] networkList);
void setFilterNetworkList(Long[] networkList);
List<ContractLocator> getAllKnownContracts(List<Integer> networkFilters);
List<ContractLocator> getAllKnownContracts(List<Long> networkFilters);
Single<Token[]> getBlankOverrideTokens(Wallet wallet);
@ -60,16 +60,16 @@ public interface EthereumNetworkRepositoryType {
KnownContract readContracts();
boolean getIsPopularToken(int chainId, String address);
boolean getIsPopularToken(long chainId, String address);
String getCurrentWalletAddress();
boolean hasSetNetworkFilters();
boolean isMainNetSelected();
void addCustomRPCNetwork(String networkName, String rpcUrl, int chainId, String symbol, String blockExplorerUrl, String explorerApiUrl, boolean isTestnet, Integer oldChainId);
NetworkInfoExt getNetworkInfoExt(int chainId);
void addCustomRPCNetwork(String networkName, String rpcUrl, long chainId, String symbol, String blockExplorerUrl, String explorerApiUrl, boolean isTestnet, Long oldChainId);
NetworkInfoExt getNetworkInfoExt(long chainId);
boolean isChainContract(int chainId, String address);
boolean hasLockedGas(int chainId);
boolean isChainContract(long chainId, String address);
boolean hasLockedGas(long chainId);
}

@ -7,9 +7,9 @@ public interface PreferenceRepositoryType {
void setCurrentWalletAddress(String address);
int getActiveBrowserNetwork();
long getActiveBrowserNetwork();
void setActiveBrowserNetwork(int networkId);
void setActiveBrowserNetwork(long networkId);
String getNetworkFilterList();

@ -60,11 +60,11 @@ public class SharedPreferenceRepository implements PreferenceRepositoryType {
}
@Override
public int getActiveBrowserNetwork() {
int selectedNetwork;
public long getActiveBrowserNetwork() {
long selectedNetwork;
try
{
selectedNetwork = pref.getInt(DEFAULT_NETWORK_NAME_KEY, 0);
selectedNetwork = pref.getLong(DEFAULT_NETWORK_NAME_KEY, 0);
}
catch (ClassCastException e) //previously we used string
{
@ -76,8 +76,8 @@ public class SharedPreferenceRepository implements PreferenceRepositoryType {
}
@Override
public void setActiveBrowserNetwork(int networkId) {
pref.edit().putInt(DEFAULT_NETWORK_NAME_KEY, networkId).apply();
public void setActiveBrowserNetwork(long networkId) {
pref.edit().putLong(DEFAULT_NETWORK_NAME_KEY, networkId).apply();
}
@Override

@ -1,13 +1,11 @@
package com.alphawallet.app.repository;
import com.alphawallet.app.entity.ContractType;
import com.alphawallet.app.entity.NetworkInfo;
import com.alphawallet.app.entity.Wallet;
import com.alphawallet.app.entity.nftassets.NFTAsset;
import com.alphawallet.app.entity.tokens.Token;
import com.alphawallet.app.entity.tokens.TokenCardMeta;
import com.alphawallet.app.entity.tokens.TokenTicker;
import com.alphawallet.app.repository.entity.RealmAuxData;
import com.alphawallet.app.service.AssetDefinitionService;
import com.alphawallet.token.entity.ContractAddress;
@ -19,39 +17,37 @@ import java.util.Map;
import io.reactivex.Single;
import io.realm.Realm;
import static com.alphawallet.app.repository.TokensRealmSource.IMAGES_DB;
public interface TokenLocalSource {
Single<Token> saveToken(Wallet wallet, Token token);
Single<Token[]> saveTokens(Wallet wallet, Token[] items);
boolean updateTokenBalance(Wallet wallet, Token token, BigDecimal balance, List<BigInteger> balanceArray);
Token fetchToken(int chainId, Wallet wallet, String address);
Token fetchToken(long chainId, Wallet wallet, String address);
void setEnable(Wallet wallet, Token token, boolean isEnabled);
void createBaseNetworkTokens(String walletAddress);
String getTokenImageUrl(int networkId, String address);
String getTokenImageUrl(long chainId, String address);
Single<Token[]> saveERC20Tokens(Wallet wallet, Token[] tokens);
void deleteRealmToken(int chainId, Wallet wallet, String address);
void deleteRealmToken(long chainId, Wallet wallet, String address);
Token updateTokenType(Token token, Wallet wallet, ContractType type);
void storeTokenUrl(int networkId, String address, String imageUrl);
void storeTokenUrl(long chainId, String address, String imageUrl);
Token[] initNFTAssets(Wallet wallet, Token[] tokens);
Single<TokenCardMeta[]> fetchTokenMetas(Wallet wallet, List<Integer> networkFilters,
Single<TokenCardMeta[]> fetchTokenMetas(Wallet wallet, List<Long> networkFilters,
AssetDefinitionService svs);
Single<TokenCardMeta[]> fetchAllTokenMetas(Wallet wallet, List<Integer> networkFilters,
Single<TokenCardMeta[]> fetchAllTokenMetas(Wallet wallet, List<Long> networkFilters,
String seachTerm);
TokenCardMeta[] fetchTokenMetasForUpdate(Wallet wallet, List<Integer> networkFilters);
TokenCardMeta[] fetchTokenMetasForUpdate(Wallet wallet, List<Long> networkFilters);
Single<Token[]> fetchAllTokensWithNameIssue(String walletAddress, List<Integer> networkFilters);
Single<ContractAddress[]> fetchAllTokensWithBlankName(String walletAddress, List<Integer> networkFilters);
Single<Token[]> fetchAllTokensWithNameIssue(String walletAddress, List<Long> networkFilters);
Single<ContractAddress[]> fetchAllTokensWithBlankName(String walletAddress, List<Long> networkFilters);
Single<Integer> fixFullNames(Wallet wallet, AssetDefinitionService svs);
void updateEthTickers(Map<Integer, TokenTicker> ethTickers);
void updateERC20Tickers(int chainId, Map<String, TokenTicker> erc20Tickers);
void updateEthTickers(Map<Long, TokenTicker> ethTickers);
void updateERC20Tickers(long chainId, Map<String, TokenTicker> erc20Tickers);
void removeOutdatedTickers();
Realm getRealmInstance(Wallet wallet);

@ -98,7 +98,7 @@ public class TokenRepository implements TokenRepositoryType {
private static final int NODE_COMMS_ERROR = -1;
private static final int CONTRACT_BALANCE_NULL = -2;
private final Map<Integer, Web3j> web3jNodeServers;
private final Map<Long, Web3j> web3jNodeServers;
private AWEnsResolver ensResolver;
public TokenRepository(
@ -124,7 +124,7 @@ public class TokenRepository implements TokenRepositoryType {
web3jNodeServers.put(networkInfo.chainId, Web3j.build(publicNodeService));
}
private Web3j getService(int chainId)
private Web3j getService(long chainId)
{
if (!web3jNodeServers.containsKey(chainId))
{
@ -194,14 +194,14 @@ public class TokenRepository implements TokenRepositoryType {
}
@Override
public TokenCardMeta[] fetchTokenMetasForUpdate(Wallet wallet, List<Integer> networkFilters)
public TokenCardMeta[] fetchTokenMetasForUpdate(Wallet wallet, List<Long> networkFilters)
{
if (networkFilters == null) networkFilters = Collections.emptyList(); //if filter null, return all networks
return localSource.fetchTokenMetasForUpdate(wallet, networkFilters);
}
@Override
public Single<TokenCardMeta[]> fetchTokenMetas(Wallet wallet, List<Integer> networkFilters,
public Single<TokenCardMeta[]> fetchTokenMetas(Wallet wallet, List<Long> networkFilters,
AssetDefinitionService svs)
{
if (networkFilters == null) networkFilters = Collections.emptyList(); //if filter null, return all networks
@ -210,21 +210,21 @@ public class TokenRepository implements TokenRepositoryType {
}
@Override
public Single<TokenCardMeta[]> fetchAllTokenMetas(Wallet wallet, List<Integer> networkFilters, String searchTerm) {
public Single<TokenCardMeta[]> fetchAllTokenMetas(Wallet wallet, List<Long> networkFilters, String searchTerm) {
if (networkFilters == null) networkFilters = Collections.emptyList(); //if filter null, return all networks
return localSource
.fetchAllTokenMetas(wallet, networkFilters, searchTerm);
}
@Override
public Single<Token[]> fetchTokensThatMayNeedUpdating(String walletAddress, List<Integer> networkFilters) {
public Single<Token[]> fetchTokensThatMayNeedUpdating(String walletAddress, List<Long> networkFilters) {
if (networkFilters == null) networkFilters = Collections.emptyList(); //if filter null, return all networks
return localSource
.fetchAllTokensWithNameIssue(walletAddress, networkFilters);
}
@Override
public Single<ContractAddress[]> fetchAllTokensWithBlankName(String walletAddress, List<Integer> networkFilters) {
public Single<ContractAddress[]> fetchAllTokensWithBlankName(String walletAddress, List<Long> networkFilters) {
if (networkFilters == null) networkFilters = Collections.emptyList(); //if filter null, return all networks
return localSource
.fetchAllTokensWithBlankName(walletAddress, networkFilters);
@ -243,7 +243,7 @@ public class TokenRepository implements TokenRepositoryType {
}
@Override
public Single<BigInteger> fetchLatestBlockNumber(int chainId)
public Single<BigInteger> fetchLatestBlockNumber(long chainId)
{
return Single.fromCallable(() -> {
try
@ -260,7 +260,7 @@ public class TokenRepository implements TokenRepositoryType {
}
@Override
public Token fetchToken(int chainId, String walletAddress, String address)
public Token fetchToken(long chainId, String walletAddress, String address)
{
Wallet wallet = new Wallet(walletAddress);
return localSource.fetchToken(chainId, wallet, address);
@ -297,7 +297,7 @@ public class TokenRepository implements TokenRepositoryType {
}
@Override
public Single<BigDecimal> fetchChainBalance(String walletAddress, int chainId)
public Single<BigDecimal> fetchChainBalance(String walletAddress, long chainId)
{
Token baseToken = fetchToken(chainId, walletAddress, walletAddress);
return updateTokenBalance(walletAddress, baseToken);
@ -365,7 +365,7 @@ public class TokenRepository implements TokenRepositoryType {
}
@Override
public Single<String> resolveENS(int chainId, String ensName)
public Single<String> resolveENS(long chainId, String ensName)
{
if (ensResolver == null) ensResolver = new AWEnsResolver(TokenRepository.getWeb3jService(MAINNET_ID), context);
return ensResolver.resolveENSAddress(ensName);
@ -384,13 +384,13 @@ public class TokenRepository implements TokenRepositoryType {
}
@Override
public Single<TokenInfo> update(String contractAddr, int chainId)
public Single<TokenInfo> update(String contractAddr, long chainId)
{
return setupTokensFromLocal(contractAddr, chainId);
}
@Override
public String getTokenImageUrl(int networkId, String address)
public String getTokenImageUrl(long networkId, String address)
{
return localSource.getTokenImageUrl(networkId, address);
}
@ -468,7 +468,7 @@ public class TokenRepository implements TokenRepositoryType {
});
}
private BigDecimal checkUint256Balance(@NonNull Wallet wallet, int chainId, String tokenAddress)
private BigDecimal checkUint256Balance(@NonNull Wallet wallet, long chainId, String tokenAddress)
{
BigDecimal balance = BigDecimal.valueOf(-1);
@ -557,12 +557,12 @@ public class TokenRepository implements TokenRepositoryType {
}
@Override
public Single<TokenTicker> getEthTicker(int chainId)
public Single<TokenTicker> getEthTicker(long chainId)
{
return Single.fromCallable(() -> tickerService.getEthTicker(chainId));
}
private BigDecimal getEthBalance(Wallet wallet, int chainId)
private BigDecimal getEthBalance(Wallet wallet, long chainId)
{
//in case chain has an override
if (EthereumNetworkRepository.getChainOverrideAddress(chainId).length() > 0)
@ -586,7 +586,7 @@ public class TokenRepository implements TokenRepositoryType {
}
}
private List<BigInteger> getBalanceArray875(Wallet wallet, int chainId, String tokenAddress) {
private List<BigInteger> getBalanceArray875(Wallet wallet, long chainId, String tokenAddress) {
List<BigInteger> result = new ArrayList<>();
result.add(BigInteger.valueOf(NODE_COMMS_ERROR));
try
@ -638,7 +638,7 @@ public class TokenRepository implements TokenRepositoryType {
return result;
}
private List<BigInteger> getBalanceArray721Ticket(Wallet wallet, int chainId, String tokenAddress) {
private List<BigInteger> getBalanceArray721Ticket(Wallet wallet, long chainId, String tokenAddress) {
List<BigInteger> result = new ArrayList<>();
result.add(BigInteger.valueOf(NODE_COMMS_ERROR));
try
@ -991,7 +991,7 @@ public class TokenRepository implements TokenRepositoryType {
* @return
*/
private String callCustomNetSmartContractFunction(
Function function, String contractAddress, Wallet wallet, int chainId) {
Function function, String contractAddress, Wallet wallet, long chainId) {
String encodedFunction = FunctionEncoder.encode(function);
try
@ -1073,7 +1073,7 @@ public class TokenRepository implements TokenRepositoryType {
}
@Override
public Single<ContractLocator> getTokenResponse(String address, int chainId, String method)
public Single<ContractLocator> getTokenResponse(String address, long chainId, String method)
{
return Single.fromCallable(() -> {
ContractLocator contractLocator = new ContractLocator(INVALID_CONTRACT, chainId);
@ -1098,7 +1098,7 @@ public class TokenRepository implements TokenRepositoryType {
});
}
private Single<TokenInfo> setupTokensFromLocal(String address, int chainId) //pass exception up the chain
private Single<TokenInfo> setupTokensFromLocal(String address, long chainId) //pass exception up the chain
{
return Single.fromCallable(() -> {
NetworkInfo network = ethereumNetworkRepository.getNetworkByChain(chainId);
@ -1268,12 +1268,12 @@ public class TokenRepository implements TokenRepositoryType {
}
@Override
public void addImageUrl(int networkId, String address, String imageUrl)
public void addImageUrl(long networkId, String address, String imageUrl)
{
localSource.storeTokenUrl(networkId, address, imageUrl);
}
public static Web3j getWeb3jService(int chainId)
public static Web3j getWeb3jService(long chainId)
{
OkHttpClient okClient = new OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)
@ -1286,7 +1286,7 @@ public class TokenRepository implements TokenRepositoryType {
return Web3j.build(publicNodeService);
}
public static String callSmartContractFunction(int chainId,
public static String callSmartContractFunction(long chainId,
Function function, String contractAddress, String walletAddr)
{
String encodedFunction = FunctionEncoder.encode(function);
@ -1312,7 +1312,7 @@ public class TokenRepository implements TokenRepositoryType {
return null;
}
public static List callSmartContractFunctionArray(int chainId,
public static List callSmartContractFunctionArray(long chainId,
Function function, String contractAddress, String walletAddr)
{
try

@ -16,7 +16,6 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
import io.reactivex.Completable;
import io.reactivex.Observable;
import io.reactivex.Single;
import io.realm.Realm;
@ -25,21 +24,21 @@ public interface TokenRepositoryType {
Observable<Token> fetchActiveTokenBalance(String walletAddress, Token token);
Single<BigDecimal> updateTokenBalance(String walletAddress, Token token);
Single<ContractLocator> getTokenResponse(String address, int chainId, String method);
Single<ContractLocator> getTokenResponse(String address, long chainId, String method);
Single<Token[]> checkInterface(Token[] tokens, Wallet wallet);
void setEnable(Wallet wallet, Token token, boolean isEnabled);
void setVisibilityChanged(Wallet wallet, Token token);
Single<TokenInfo> update(String address, int chainId);
Single<TokenInfo> update(String address, long chainId);
Observable<TransferFromEventResponse> burnListenerObservable(String contractAddress);
Single<TokenTicker> getEthTicker(int chainId);
Single<TokenTicker> getEthTicker(long chainId);
TokenTicker getTokenTicker(Token token);
Single<BigInteger> fetchLatestBlockNumber(int chainId);
Token fetchToken(int chainId, String walletAddress, String address);
Single<BigInteger> fetchLatestBlockNumber(long chainId);
Token fetchToken(long chainId, String walletAddress, String address);
void createBaseNetworkTokens(String walletAddress);
String getTokenImageUrl(int networkId, String address);
String getTokenImageUrl(long chainId, String address);
Single<Token[]> storeTokens(Wallet wallet, Token[] tokens);
Single<String> resolveENS(int chainId, String address);
Single<String> resolveENS(long chainId, String address);
void updateAssets(String wallet, Token erc721Token, List<BigInteger> additions, List<BigInteger> removals);
void storeAsset(String currentAddress, Token token, BigInteger tokenId, NFTAsset asset);
Token[] initNFTAssets(Wallet wallet, Token[] token);
@ -49,23 +48,23 @@ public interface TokenRepositoryType {
Single<Boolean> fetchIsRedeemed(Token token, BigInteger tokenId);
void addImageUrl(int networkId, String address, String imageUrl);
void addImageUrl(long chainId, String address, String imageUrl);
Single<TokenCardMeta[]> fetchTokenMetas(Wallet wallet, List<Integer> networkFilters,
Single<TokenCardMeta[]> fetchTokenMetas(Wallet wallet, List<Long> networkFilters,
AssetDefinitionService svs);
Single<TokenCardMeta[]> fetchAllTokenMetas(Wallet wallet, List<Integer> networkFilters,
Single<TokenCardMeta[]> fetchAllTokenMetas(Wallet wallet, List<Long> networkFilters,
String searchTerm);
Single<Token[]> fetchTokensThatMayNeedUpdating(String walletAddress, List<Integer> networkFilters);
Single<ContractAddress[]> fetchAllTokensWithBlankName(String walletAddress, List<Integer> networkFilters);
Single<Token[]> fetchTokensThatMayNeedUpdating(String walletAddress, List<Long> networkFilters);
Single<ContractAddress[]> fetchAllTokensWithBlankName(String walletAddress, List<Long> networkFilters);
TokenCardMeta[] fetchTokenMetasForUpdate(Wallet wallet, List<Integer> networkFilters);
TokenCardMeta[] fetchTokenMetasForUpdate(Wallet wallet, List<Long> networkFilters);
Realm getRealmInstance(Wallet wallet);
Realm getTickerRealmInstance();
Single<BigDecimal> fetchChainBalance(String walletAddress, int chainId);
Single<BigDecimal> fetchChainBalance(String walletAddress, long chainId);
Single<Integer> fixFullNames(Wallet wallet, AssetDefinitionService svs);
boolean isEnabled(Token newToken);

@ -109,7 +109,7 @@ public class TokensRealmSource implements TokenLocalSource {
}
@Override
public void deleteRealmToken(int chainId, Wallet wallet, String address)
public void deleteRealmToken(long chainId, Wallet wallet, String address)
{
try (Realm realm = realmManager.getRealmInstance(wallet))
{
@ -181,7 +181,7 @@ public class TokensRealmSource implements TokenLocalSource {
}
@Override
public String getTokenImageUrl(int networkId, String address)
public String getTokenImageUrl(long networkId, String address)
{
String url = "";
String instanceKey = address.toLowerCase() + "-" + networkId;
@ -233,13 +233,12 @@ public class TokensRealmSource implements TokenLocalSource {
}
@Override
public Token fetchToken(int chainId, Wallet wallet, String address)
public Token fetchToken(long chainId, Wallet wallet, String address)
{
try (Realm realm = realmManager.getRealmInstance(wallet))
{
RealmToken realmItem = realm.where(RealmToken.class)
.equalTo("address", databaseKey(chainId, address))
.equalTo("chainId", chainId)
.findFirst();
Token t = convertSingle(realmItem, realm, null, wallet);
@ -264,7 +263,6 @@ public class TokensRealmSource implements TokenLocalSource {
{
RealmToken realmItem = r.where(RealmToken.class)
.equalTo("address", databaseKey(info.chainId, walletAddress))
.equalTo("chainId", info.chainId)
.findFirst();
if (realmItem == null)
@ -297,7 +295,6 @@ public class TokensRealmSource implements TokenLocalSource {
realm.executeTransactionAsync(r -> {
RealmToken realmToken = r.where(RealmToken.class)
.equalTo("address", databaseKey(token))
.equalTo("chainId", token.tokenInfo.chainId)
.findFirst();
if (realmToken != null)
@ -316,7 +313,6 @@ public class TokensRealmSource implements TokenLocalSource {
{
RealmToken realmToken = realm.where(RealmToken.class)
.equalTo("address", databaseKey(token))
.equalTo("chainId", token.tokenInfo.chainId)
.findFirst();
if (realmToken != null)
@ -360,7 +356,6 @@ public class TokensRealmSource implements TokenLocalSource {
{
RealmToken realmToken = realm.where(RealmToken.class)
.equalTo("address", databaseKey(token))
.equalTo("chainId", token.tokenInfo.chainId)
.findFirst();
if (realmToken == null)
@ -373,7 +368,6 @@ public class TokensRealmSource implements TokenLocalSource {
{
RealmToken realmToken = realm.where(RealmToken.class)
.equalTo("address", databaseKey(token))
.equalTo("chainId", token.tokenInfo.chainId)
.findFirst();
if (realmToken != null)
@ -427,7 +421,6 @@ public class TokensRealmSource implements TokenLocalSource {
{
RealmToken realmToken = realm.where(RealmToken.class)
.equalTo("address", databaseKey(token))
.equalTo("chainId", token.tokenInfo.chainId)
.findFirst();
if (realmToken != null)
@ -447,7 +440,6 @@ public class TokensRealmSource implements TokenLocalSource {
realm.executeTransactionAsync(r -> {
RealmToken realmToken = r.where(RealmToken.class)
.equalTo("address", databaseKey(token))
.equalTo("chainId", token.tokenInfo.chainId)
.findFirst();
if (realmToken != null)
@ -462,7 +454,7 @@ public class TokensRealmSource implements TokenLocalSource {
}
}
public static String databaseKey(int chainId, String address)
public static String databaseKey(long chainId, String address)
{
return address.toLowerCase() + "-" + chainId;
}
@ -482,7 +474,7 @@ public class TokensRealmSource implements TokenLocalSource {
return txHash + "-" + activityName + EVENT_CARDS + "-" + extendedId;
}
public static String eventBlockKey(int chainId, String eventAddress, String namedType, String filter)
public static String eventBlockKey(long chainId, String eventAddress, String namedType, String filter)
{
return eventAddress.toLowerCase() + "-" + chainId + "-" + namedType + "-" + filter + "-eventBlock";
}
@ -496,7 +488,6 @@ public class TokensRealmSource implements TokenLocalSource {
{
RealmToken realmToken = realm.where(RealmToken.class)
.equalTo("address", key)
.equalTo("chainId", token.tokenInfo.chainId)
.findFirst();
if (realmToken != null)
@ -551,7 +542,6 @@ public class TokensRealmSource implements TokenLocalSource {
if (!token.isEthereum()) return true;
RealmToken realmToken = realm.where(RealmToken.class)
.equalTo("address", databaseKey(token.tokenInfo.chainId, "eth"))
.equalTo("chainId", token.tokenInfo.chainId)
.findFirst();
return realmToken != null;
@ -561,7 +551,6 @@ public class TokensRealmSource implements TokenLocalSource {
{
RealmToken realmToken = realm.where(RealmToken.class)
.equalTo("address", databaseKey(token.tokenInfo.chainId, "eth"))
.equalTo("chainId", token.tokenInfo.chainId)
.findFirst();
if (realmToken == null)
@ -579,7 +568,7 @@ public class TokensRealmSource implements TokenLocalSource {
}
@Override
public void storeTokenUrl(int networkId, String address, String imageUrl)
public void storeTokenUrl(long networkId, String address, String imageUrl)
{
try (Realm realm = realmManager.getRealmInstance(IMAGES_DB))
{
@ -606,7 +595,6 @@ public class TokensRealmSource implements TokenLocalSource {
String databaseKey = databaseKey(token);
RealmToken realmToken = realm.where(RealmToken.class)
.equalTo("address", databaseKey)
.equalTo("chainId", token.tokenInfo.chainId)
.findFirst();
boolean wasNew = false;
@ -809,10 +797,10 @@ public class TokensRealmSource implements TokenLocalSource {
return assets;
}
public TokenCardMeta[] fetchTokenMetasForUpdate(Wallet wallet, List<Integer> networkFilters)
public TokenCardMeta[] fetchTokenMetasForUpdate(Wallet wallet, List<Long> networkFilters)
{
List<TokenCardMeta> tokenMetas = new ArrayList<>();
List<Integer> rootChainTokenCards = new ArrayList<>(networkFilters);
List<Long> rootChainTokenCards = new ArrayList<>(networkFilters);
try (Realm realm = realmManager.getRealmInstance(wallet))
{
RealmResults<RealmToken> realmItems = realm.where(RealmToken.class)
@ -833,7 +821,7 @@ public class TokensRealmSource implements TokenLocalSource {
{
if (rootChainTokenCards.contains(t.getChainId()))
{
rootChainTokenCards.remove((Integer) t.getChainId());
rootChainTokenCards.remove((Long) t.getChainId());
}
else
{
@ -857,7 +845,7 @@ public class TokensRealmSource implements TokenLocalSource {
finally
{
//create metas for any card not previously saved
for (Integer chainId : rootChainTokenCards)
for (Long chainId : rootChainTokenCards)
{
TokenCardMeta meta = new TokenCardMeta(chainId, wallet.address.toLowerCase(), "0", 0, null, "", "", ContractType.ETHEREUM);
meta.lastTxUpdate = 0;
@ -876,9 +864,9 @@ public class TokensRealmSource implements TokenLocalSource {
* @param svs
* @return
*/
public Single<TokenCardMeta[]> fetchTokenMetas(Wallet wallet, List<Integer> networkFilters, AssetDefinitionService svs)
public Single<TokenCardMeta[]> fetchTokenMetas(Wallet wallet, List<Long> networkFilters, AssetDefinitionService svs)
{
List<Integer> rootChainTokenCards = new ArrayList<>(networkFilters);
List<Long> rootChainTokenCards = new ArrayList<>(networkFilters);
return Single.fromCallable(() -> {
List<TokenCardMeta> tokenMetas = new ArrayList<>();
//ensure root tokens for filters are in there
@ -901,7 +889,7 @@ public class TokensRealmSource implements TokenLocalSource {
{
if (rootChainTokenCards.contains(t.getChainId()))
{
rootChainTokenCards.remove((Integer)t.getChainId());
rootChainTokenCards.remove((Long)t.getChainId());
}
else
{
@ -926,17 +914,16 @@ public class TokensRealmSource implements TokenLocalSource {
}).flatMap(loadedMetas -> populateBaseCards(wallet, rootChainTokenCards, loadedMetas));
}
private Single<TokenCardMeta[]> populateBaseCards(Wallet wallet, List<Integer> rootChainTokenCards, List<TokenCardMeta> loadedMetas)
private Single<TokenCardMeta[]> populateBaseCards(Wallet wallet, List<Long> rootChainTokenCards, List<TokenCardMeta> loadedMetas)
{
return Single.fromCallable(() -> {
try (Realm realm = realmManager.getRealmInstance(wallet))
{
realm.executeTransaction(r -> {
for (int requiredNetwork : rootChainTokenCards)
for (long requiredNetwork : rootChainTokenCards)
{
RealmToken realmItem = r.where(RealmToken.class)
.equalTo("address", databaseKey(requiredNetwork, wallet.address))
.equalTo("chainId", requiredNetwork)
.findFirst();
if (realmItem == null)
@ -1023,7 +1010,7 @@ public class TokensRealmSource implements TokenLocalSource {
* @return
*/
@Override
public Single<TokenCardMeta[]> fetchAllTokenMetas(Wallet wallet, List<Integer> networkFilters, String searchTerm) {
public Single<TokenCardMeta[]> fetchAllTokenMetas(Wallet wallet, List<Long> networkFilters, String searchTerm) {
List<TokenCardMeta> tokenMetas = new ArrayList<>();
return Single.fromCallable(() -> {
try (Realm realm = realmManager.getRealmInstance(wallet))
@ -1049,7 +1036,7 @@ public class TokensRealmSource implements TokenLocalSource {
}
@Override
public Single<Token[]> fetchAllTokensWithNameIssue(String walletAddress, List<Integer> networkFilters) {
public Single<Token[]> fetchAllTokensWithNameIssue(String walletAddress, List<Long> networkFilters) {
List<Token> tokens = new ArrayList<>();
return Single.fromCallable(() -> {
try (Realm realm = realmManager.getRealmInstance(walletAddress))
@ -1074,7 +1061,7 @@ public class TokensRealmSource implements TokenLocalSource {
}
@Override
public Single<ContractAddress[]> fetchAllTokensWithBlankName(String walletAddress, List<Integer> networkFilters) {
public Single<ContractAddress[]> fetchAllTokensWithBlankName(String walletAddress, List<Long> networkFilters) {
List<ContractAddress> tokens = new ArrayList<>();
return Single.fromCallable(() -> {
try (Realm realm = realmManager.getRealmInstance(walletAddress))
@ -1099,12 +1086,12 @@ public class TokensRealmSource implements TokenLocalSource {
}
@Override
public void updateEthTickers(Map<Integer, TokenTicker> ethTickers)
public void updateEthTickers(Map<Long, TokenTicker> ethTickers)
{
try (Realm realm = realmManager.getRealmInstance(TICKER_DB))
{
realm.executeTransactionAsync(r -> {
for (int chainId : ethTickers.keySet())
for (long chainId : ethTickers.keySet())
{
writeTickerToRealm(r, ethTickers.get(chainId), chainId, "eth");
}
@ -1117,7 +1104,7 @@ public class TokensRealmSource implements TokenLocalSource {
}
@Override
public void updateERC20Tickers(int chainId, final Map<String, TokenTicker> erc20Tickers)
public void updateERC20Tickers(long chainId, final Map<String, TokenTicker> erc20Tickers)
{
try (Realm realm = realmManager.getRealmInstance(TICKER_DB))
{
@ -1181,7 +1168,7 @@ public class TokensRealmSource implements TokenLocalSource {
}
}
private void writeTickerToRealm(Realm realm, final TokenTicker ticker, int chainId, String tokenAddress)
private void writeTickerToRealm(Realm realm, final TokenTicker ticker, long chainId, String tokenAddress)
{
if (ticker == null) return;
String databaseKey = databaseKey(chainId, tokenAddress.toLowerCase());

@ -20,16 +20,16 @@ public interface TransactionLocalSource {
Realm getRealmInstance(Wallet wallet);
Single<ActivityMeta[]> fetchActivityMetas(Wallet wallet, List<Integer> networkFilters, long fetchTime, int fetchLimit);
Single<ActivityMeta[]> fetchActivityMetas(Wallet wallet, int chainId, String tokenAddress, int historyCount);
Single<ActivityMeta[]> fetchEventMetas(Wallet wallet, List<Integer> networkFilters);
Single<ActivityMeta[]> fetchActivityMetas(Wallet wallet, List<Long> networkFilters, long fetchTime, int fetchLimit);
Single<ActivityMeta[]> fetchActivityMetas(Wallet wallet, long chainId, String tokenAddress, int historyCount);
Single<ActivityMeta[]> fetchEventMetas(Wallet wallet, List<Long> networkFilters);
void markTransactionBlock(String walletAddress, String hash, long blockValue);
Transaction[] fetchPendingTransactions(String currentAddress);
RealmAuxData fetchEvent(String walletAddress, String eventKey);
Transaction storeRawTx(Wallet wallet, int chainId, EthTransaction object, long timeStamp, boolean isSuccessful);
Transaction storeRawTx(Wallet wallet, long chainId, EthTransaction object, long timeStamp, boolean isSuccessful);
long fetchTxCompletionTime(Wallet wallet, String hash);

@ -70,7 +70,7 @@ public class TransactionRepository implements TransactionRepositoryType {
}
@Override
public Single<String> resendTransaction(Wallet from, String to, BigInteger subunitAmount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte[] data, int chainId)
public Single<String> resendTransaction(Wallet from, String to, BigInteger subunitAmount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte[] data, long chainId)
{
final Web3j web3j = getWeb3jService(chainId);
final BigInteger useGasPrice = gasPriceForNode(chainId, gasPrice);
@ -95,7 +95,7 @@ public class TransactionRepository implements TransactionRepositoryType {
}
@Override
public Single<String> createTransaction(Wallet from, String toAddress, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, byte[] data, int chainId)
public Single<String> createTransaction(Wallet from, String toAddress, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, byte[] data, long chainId)
{
final Web3j web3j = getWeb3jService(chainId);
final BigInteger useGasPrice = gasPriceForNode(chainId, gasPrice);
@ -128,7 +128,7 @@ public class TransactionRepository implements TransactionRepositoryType {
}
@Override
public Single<TransactionData> createTransactionWithSig(Wallet from, String toAddress, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, long nonce, byte[] data, int chainId) {
public Single<TransactionData> createTransactionWithSig(Wallet from, String toAddress, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, long nonce, byte[] data, long chainId) {
final Web3j web3j = getWeb3jService(chainId);
final BigInteger useGasPrice = gasPriceForNode(chainId, gasPrice);
@ -169,7 +169,7 @@ public class TransactionRepository implements TransactionRepositoryType {
* @return
*/
@Override
public Single<TransactionData> getSignatureForTransaction(Wallet wallet, Web3Transaction w3tx, int chainId) {
public Single<TransactionData> getSignatureForTransaction(Wallet wallet, Web3Transaction w3tx, long chainId) {
TransactionData txData = new TransactionData();
return getRawTransaction(txData.nonce, w3tx.gasPrice, w3tx.gasLimit, w3tx.value, w3tx.payload)
@ -183,7 +183,7 @@ public class TransactionRepository implements TransactionRepositoryType {
// Called for constructors from web3 Dapp transaction
@Override
public Single<TransactionData> createTransactionWithSig(Wallet from, BigInteger gasPrice, BigInteger gasLimit, String data, int chainId) {
public Single<TransactionData> createTransactionWithSig(Wallet from, BigInteger gasPrice, BigInteger gasLimit, String data, long chainId) {
final Web3j web3j = getWeb3jService(chainId);
final BigInteger useGasPrice = gasPriceForNode(chainId, gasPrice);
@ -210,13 +210,13 @@ public class TransactionRepository implements TransactionRepositoryType {
.subscribeOn(Schedulers.io());
}
private BigInteger gasPriceForNode(int chainId, BigInteger gasPrice)
private BigInteger gasPriceForNode(long chainId, BigInteger gasPrice)
{
if (EthereumNetworkRepository.hasGasOverride(chainId)) return EthereumNetworkRepository.gasOverrideValue(chainId);
else return gasPrice;
}
private Single<TransactionData> storeUnconfirmedTransaction(Wallet from, TransactionData txData, String toAddress, BigInteger value, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, int chainId, String data, String contractAddr)
private Single<TransactionData> storeUnconfirmedTransaction(Wallet from, TransactionData txData, String toAddress, BigInteger value, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, long chainId, String data, String contractAddr)
{
return Single.fromCallable(() -> {
Transaction newTx = new Transaction(txData.txHash, "0", "0", System.currentTimeMillis()/1000, nonce.intValue(), from.address, toAddress, value.toString(10), "0", gasPrice.toString(10), data,
@ -229,7 +229,7 @@ public class TransactionRepository implements TransactionRepositoryType {
});
}
private Single<String> storeUnconfirmedTransaction(Wallet from, String txHash, String toAddress, BigInteger value, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, int chainId, String data)
private Single<String> storeUnconfirmedTransaction(Wallet from, String txHash, String toAddress, BigInteger value, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, long chainId, String data)
{
return Single.fromCallable(() -> {
@ -254,7 +254,7 @@ public class TransactionRepository implements TransactionRepositoryType {
data));
}
private Single<byte[]> signEncodeRawTransaction(RawTransaction rtx, Wallet wallet, int chainId)
private Single<byte[]> signEncodeRawTransaction(RawTransaction rtx, Wallet wallet, long chainId)
{
return Single.fromCallable(() -> TransactionEncoder.encode(rtx))
.flatMap(encoded -> accountKeystoreService.signTransaction(wallet, encoded, chainId))
@ -277,12 +277,12 @@ public class TransactionRepository implements TransactionRepositoryType {
}
@Override
public Single<SignatureFromKey> getSignature(Wallet wallet, Signable message, int chainId) {
public Single<SignatureFromKey> getSignature(Wallet wallet, Signable message, long chainId) {
return accountKeystoreService.signMessage(wallet, message, chainId);
}
@Override
public Single<byte[]> getSignatureFast(Wallet wallet, String password, byte[] message, int chainId) {
public Single<byte[]> getSignatureFast(Wallet wallet, String password, byte[] message, long chainId) {
return accountKeystoreService.signTransactionFast(wallet, password, message, chainId);
}
@ -305,19 +305,19 @@ public class TransactionRepository implements TransactionRepositoryType {
}
@Override
public Single<ActivityMeta[]> fetchCachedTransactionMetas(Wallet wallet, List<Integer> networkFilters, long fetchTime, int fetchLimit)
public Single<ActivityMeta[]> fetchCachedTransactionMetas(Wallet wallet, List<Long> networkFilters, long fetchTime, int fetchLimit)
{
return inDiskCache.fetchActivityMetas(wallet, networkFilters, fetchTime, fetchLimit);
}
@Override
public Single<ActivityMeta[]> fetchCachedTransactionMetas(Wallet wallet, int chainId, String tokenAddress, int historyCount)
public Single<ActivityMeta[]> fetchCachedTransactionMetas(Wallet wallet, long chainId, String tokenAddress, int historyCount)
{
return inDiskCache.fetchActivityMetas(wallet, chainId, tokenAddress, historyCount);
}
@Override
public Single<ActivityMeta[]> fetchEventMetas(Wallet wallet, List<Integer> networkFilters)
public Single<ActivityMeta[]> fetchEventMetas(Wallet wallet, List<Long> networkFilters)
{
return inDiskCache.fetchEventMetas(wallet, networkFilters);
}

@ -18,23 +18,23 @@ import io.reactivex.Single;
import io.realm.Realm;
public interface TransactionRepositoryType {
Single<String> createTransaction(Wallet from, String toAddress, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, byte[] data, int chainId);
Single<TransactionData> createTransactionWithSig(Wallet from, String toAddress, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, long nonce, byte[] data, int chainId);
Single<TransactionData> createTransactionWithSig(Wallet from, BigInteger gasPrice, BigInteger gasLimit, String data, int chainId);
Single<TransactionData> getSignatureForTransaction(Wallet wallet, Web3Transaction w3tx, int chainId);
Single<SignatureFromKey> getSignature(Wallet wallet, Signable message, int chainId);
Single<byte[]> getSignatureFast(Wallet wallet, String password, byte[] message, int chainId);
Single<String> createTransaction(Wallet from, String toAddress, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, byte[] data, long chainId);
Single<TransactionData> createTransactionWithSig(Wallet from, String toAddress, BigInteger subunitAmount, BigInteger gasPrice, BigInteger gasLimit, long nonce, byte[] data, long chainId);
Single<TransactionData> createTransactionWithSig(Wallet from, BigInteger gasPrice, BigInteger gasLimit, String data, long chainId);
Single<TransactionData> getSignatureForTransaction(Wallet wallet, Web3Transaction w3tx, long chainId);
Single<SignatureFromKey> getSignature(Wallet wallet, Signable message, long chainId);
Single<byte[]> getSignatureFast(Wallet wallet, String password, byte[] message, long chainId);
Transaction fetchCachedTransaction(String walletAddr, String hash);
long fetchTxCompletionTime(String walletAddr, String hash);
Single<String> resendTransaction(Wallet from, String to, BigInteger subunitAmount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte[] data, int chainId);
Single<String> resendTransaction(Wallet from, String to, BigInteger subunitAmount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, byte[] data, long chainId);
void removeOverridenTransaction(Wallet wallet, String oldTxHash);
Single<ActivityMeta[]> fetchCachedTransactionMetas(Wallet wallet, List<Integer> networkFilters, long fetchTime, int fetchLimit);
Single<ActivityMeta[]> fetchCachedTransactionMetas(Wallet wallet, int chainId, String tokenAddress, int historyCount);
Single<ActivityMeta[]> fetchEventMetas(Wallet wallet, List<Integer> networkFilters);
Single<ActivityMeta[]> fetchCachedTransactionMetas(Wallet wallet, List<Long> networkFilters, long fetchTime, int fetchLimit);
Single<ActivityMeta[]> fetchCachedTransactionMetas(Wallet wallet, long chainId, String tokenAddress, int historyCount);
Single<ActivityMeta[]> fetchEventMetas(Wallet wallet, List<Long> networkFilters);
Realm getRealmInstance(Wallet wallet);

@ -110,7 +110,7 @@ public class TransactionsRealmCache implements TransactionLocalSource {
}
@Override
public Single<ActivityMeta[]> fetchActivityMetas(Wallet wallet, int chainId, String tokenAddress, int historyCount)
public Single<ActivityMeta[]> fetchActivityMetas(Wallet wallet, long chainId, String tokenAddress, int historyCount)
{
return Single.fromCallable(() -> {
List<ActivityMeta> metas = new ArrayList<>();
@ -143,7 +143,7 @@ public class TransactionsRealmCache implements TransactionLocalSource {
}
@Override
public Single<ActivityMeta[]> fetchEventMetas(Wallet wallet, List<Integer> networkFilters)
public Single<ActivityMeta[]> fetchEventMetas(Wallet wallet, List<Long> networkFilters)
{
return Single.fromCallable(() -> {
List<ActivityMeta> metas = new ArrayList<>();
@ -170,7 +170,7 @@ public class TransactionsRealmCache implements TransactionLocalSource {
}
@Override
public Single<ActivityMeta[]> fetchActivityMetas(Wallet wallet, List<Integer> networkFilters, long fetchTime, int fetchLimit)
public Single<ActivityMeta[]> fetchActivityMetas(Wallet wallet, List<Long> networkFilters, long fetchTime, int fetchLimit)
{
return Single.fromCallable(() -> {
List<ActivityMeta> metas = new ArrayList<>();
@ -278,7 +278,7 @@ public class TransactionsRealmCache implements TransactionLocalSource {
}
@Override
public Transaction storeRawTx(Wallet wallet, int chainId, EthTransaction rawTx, long timeStamp, boolean isSuccessful)
public Transaction storeRawTx(Wallet wallet, long chainId, EthTransaction rawTx, long timeStamp, boolean isSuccessful)
{
if (rawTx.getResult() == null) return null;
org.web3j.protocol.core.methods.response.Transaction ethTx = rawTx.getTransaction().get();

@ -34,7 +34,7 @@ public class RealmAuxData extends RealmObject
{
@PrimaryKey
private String instanceKey; //should be token address, token Id, chainId
private int chainId;
private long chainId;
private String tokenAddress;
private String tokenId;
private String functionId;
@ -47,7 +47,7 @@ public class RealmAuxData extends RealmObject
return instanceKey;
}
public int getChainId()
public long getChainId()
{
return chainId;
}
@ -66,7 +66,7 @@ public class RealmAuxData extends RealmObject
else return "";
}
public int getExtendId()
public long getExtendId()
{
String[] split = instanceKey.split("-");
if (split.length > 3)
@ -74,14 +74,14 @@ public class RealmAuxData extends RealmObject
String extendId = split[3];
if (extendId != null && extendId.length() > 0 && Character.isDigit(extendId.charAt(0)))
{
return Integer.parseInt(extendId);
return Long.parseLong(extendId);
}
}
return 0;
}
public void setChainId(int chainId)
public void setChainId(long chainId)
{
this.chainId = chainId;
}

@ -2,8 +2,6 @@ package com.alphawallet.app.repository.entity;
import com.alphawallet.app.entity.GasPriceSpread;
import java.math.BigInteger;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
@ -13,7 +11,7 @@ import io.realm.annotations.PrimaryKey;
public class RealmGasSpread extends RealmObject
{
@PrimaryKey
private int chainId;
private long chainId;
private String rapid;
private String fast;
@ -22,7 +20,7 @@ public class RealmGasSpread extends RealmObject
private String baseFee;
private long timeStamp;
public int getChainId()
public long getChainId()
{
return chainId;
}

@ -28,7 +28,7 @@ public class RealmToken extends RealmObject {
private int interfaceSpec;
private String auxData;
private long lastBlockRead;
private int chainId;
private long chainId;
private long earliestTxBlock;
private boolean visibilityChanged;
private String erc1155BlockRead;
@ -150,8 +150,8 @@ public class RealmToken extends RealmObject {
}
public long getLastBlock() { return lastBlockRead; }
public int getChainId() { return chainId; }
public void setChainId(int chainId) { this.chainId = chainId; }
public long getChainId() { return chainId; }
public void setChainId(long chainId) { this.chainId = chainId; }
public long getLastTxTime()
{

@ -26,10 +26,10 @@ public class RealmTokenScriptData extends RealmObject
private String viewList; //CSV list of event views //TODO: replace with RealmMap when available
private boolean hasEvents; //TokenScript has events
public int getChainId()
public long getChainId()
{
String chainId = instanceKey.split("-")[1];
if (Character.isDigit(chainId.charAt(0))) return Integer.parseInt(chainId);
if (Character.isDigit(chainId.charAt(0))) return Long.parseLong(chainId);
else return MAINNET_ID;
}

@ -17,7 +17,7 @@ public class RealmTransaction extends RealmObject {
private String gasUsed;
private String input;
private String error;
private int chainId;
private long chainId;
private long expectedCompletion;
private String contractAddress; // this is so we can efficiently lookup transactions relating to contracts,
// if we discovered them using the Etherscan 'Transfers' API.
@ -121,12 +121,12 @@ public class RealmTransaction extends RealmObject {
this.error = error;
}
public int getChainId()
public long getChainId()
{
return chainId;
}
public void setChainId(int chainId)
public void setChainId(long chainId)
{
this.chainId = chainId;
}

@ -24,7 +24,7 @@ public class RealmWCSession extends RealmObject
private String walletAccount; // Which wallet we connected this session with (note, you can add/remove available session wallets using the update API call,
// maybe add this as an advanced option).
private int chainId;
private long chainId;
public WCSession getSession()
{
@ -101,12 +101,12 @@ public class RealmWCSession extends RealmObject
return sessionId;
}
public int getChainId()
public long getChainId()
{
return chainId;
}
public void setChainId(int chainId)
public void setChainId(long chainId)
{
this.chainId = chainId;
}

@ -11,7 +11,7 @@ import com.alphawallet.app.entity.tokens.Token;
import com.alphawallet.app.ui.SendActivity;
public class SendTokenRouter {
public void open(Activity context, String address, String symbol, int decimals, Wallet wallet, Token token, int chainId) {
public void open(Activity context, String address, String symbol, int decimals, Wallet wallet, Token token, long chainId) {
Intent intent = new Intent(context, SendActivity.class);
intent.putExtra(C.EXTRA_CONTRACT_ADDRESS, address);
intent.putExtra(C.EXTRA_ADDRESS, token.getAddress());

@ -65,7 +65,7 @@ public class AlphaWalletService
}
}
public Observable<Integer> handleFeemasterImport(String url, Wallet wallet, int chainId, MagicLinkData order)
public Observable<Integer> handleFeemasterImport(String url, Wallet wallet, long chainId, MagicLinkData order)
{
switch (order.contractType)
{
@ -132,7 +132,7 @@ public class AlphaWalletService
return dsigDescriptor;
}
private Observable<Integer> sendFeemasterCurrencyTransaction(String url, int networkId, String address, MagicLinkData order)
private Observable<Integer> sendFeemasterCurrencyTransaction(String url, long networkId, String address, MagicLinkData order)
{
return Observable.fromCallable(() -> {
Integer result = 500; //fail by default
@ -199,7 +199,7 @@ public class AlphaWalletService
private Single<Integer> sendFeemasterTransaction(
String url,
int networkId,
long networkId,
String toAddress,
long expiry,
String indices,
@ -293,7 +293,7 @@ public class AlphaWalletService
return sb.toString();
}
public Single<Boolean> checkFeemasterService(String url, int chainId, String address)
public Single<Boolean> checkFeemasterService(String url, long chainId, String address)
{
return Single.fromCallable(() -> {
Boolean result = false;

@ -415,7 +415,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
return td;
}
private String getTSDataKey(int chainId, String address)
private String getTSDataKey(long chainId, String address)
{
return address + "-" + chainId;
}
@ -555,7 +555,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
}
@Override
public long getLastTokenUpdate(int chainId, String address)
public long getLastTokenUpdate(long chainId, String address)
{
long txUpdateTime = 0;
Token token = tokensService.getToken(chainId, address);
@ -572,7 +572,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
{
String addr = null;
TokenDefinition td = null;
int chainId = origin.addresses.keySet().iterator().next();
long chainId = origin.addresses.keySet().iterator().next();
if (origin.addresses.get(chainId).size() > 0) addr = origin.addresses.get(chainId).get(0);
if (addr != null) td = getAssetDefinition(chainId, addr);
if (td != null)
@ -686,7 +686,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
== PackageManager.PERMISSION_GRANTED;
}
private TokenDefinition getDefinition(int chainId, String address)
private TokenDefinition getDefinition(long chainId, String address)
{
if (address.equalsIgnoreCase(tokensService.getCurrentAddress())) address = "ethereum";
TokenDefinition result = null;
@ -732,7 +732,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
return result;
}
public TokenScriptFile getTokenScriptFile(int chainId, String address)
public TokenScriptFile getTokenScriptFile(long chainId, String address)
{
//pull from database
if (address.equalsIgnoreCase(tokensService.getCurrentAddress())) address = "ethereum";
@ -757,7 +757,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
* @param address
* @return
*/
public TokenDefinition getAssetDefinition(int chainId, String address)
public TokenDefinition getAssetDefinition(long chainId, String address)
{
TokenDefinition assetDef = null;
if (address == null) return null;
@ -777,7 +777,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
return assetDef; // if nothing found use default
}
public Single<TokenDefinition> getAssetDefinitionASync(int chainId, final String address)
public Single<TokenDefinition> getAssetDefinitionASync(long chainId, final String address)
{
if (address == null) return Single.fromCallable(TokenDefinition::new);
String contractName = address;
@ -813,7 +813,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
}
}
public String getTokenName(int chainId, String address, int count)
public String getTokenName(long chainId, String address, int count)
{
String tokenName = null;
if (address.equalsIgnoreCase(tokensService.getCurrentAddress())) address = "ethereum";
@ -832,7 +832,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
return tokenName;
}
public Token getTokenFromService(int chainId, String address)
public Token getTokenFromService(long chainId, String address)
{
return tokensService.getToken(chainId, address);
}
@ -846,7 +846,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
*/
public String getIssuerName(Token token)
{
int chainId = token.tokenInfo.chainId;
long chainId = token.tokenInfo.chainId;
String address = token.tokenInfo.address;
String issuer = token.getNetworkName();
@ -1091,7 +1091,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
if (holdingContracts != null)
{
//some Android versions don't have stream()
for (int network : holdingContracts.addresses.keySet())
for (long network : holdingContracts.addresses.keySet())
{
for (String address : holdingContracts.addresses.get(network))
{
@ -1129,7 +1129,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
return td;
}
private void updateRealmForBundledScript(int chainId, String address, String asset, TokenDefinition td)
private void updateRealmForBundledScript(long chainId, String address, String asset, TokenDefinition td)
{
realmManager.getRealmInstance(ASSET_DEFINITION_DB).executeTransactionAsync(r -> {
String entryKey = getTSDataKey(chainId, address);
@ -1284,7 +1284,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
private EthFilter getEventFilter(EventDefinition ev) throws Exception
{
int chainId = ev.getEventChainId();
long chainId = ev.getEventChainId();
String address = ev.getEventContractAddress();
Token originToken = tokensService.getToken(chainId, address);
@ -1297,7 +1297,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
private String processLogs(EventDefinition ev, List<EthLog.LogResult> logs, String walletAddress)
{
if (logs.size() == 0) return ""; //early return
int chainId = ev.contract.addresses.keySet().iterator().next();
long chainId = ev.contract.addresses.keySet().iterator().next();
Web3j web3j = getWeb3jService(chainId);
String firstTxHash = "";
@ -1352,7 +1352,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
ev.readBlock = readBlock.add(BigInteger.ONE);
try (Realm realm = realmManager.getRealmInstance(walletAddress))
{
int chainId = ev.getEventChainId();
long chainId = ev.getEventChainId();
String eventAddress = ev.getEventContractAddress();
String eventName = ev.activityName != null ? ev.activityName : ev.attributeName;
String databaseKey = TokensRealmSource.eventBlockKey(chainId, eventAddress, ev.type.name, ev.filter);
@ -1617,7 +1617,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
return file;
}
public boolean hasDefinition(int chainId, String address)
public boolean hasDefinition(long chainId, String address)
{
boolean hasDefinition = false;
if (address.equalsIgnoreCase(tokensService.getCurrentAddress())) address = "ethereum";
@ -1639,7 +1639,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
assetChecked.clear();
}
public boolean hasTokenView(int chainId, String address, String type)
public boolean hasTokenView(long chainId, String address, String type)
{
if (address.equalsIgnoreCase(tokensService.getCurrentAddress())) address = "ethereum";
try (Realm realm = realmManager.getRealmInstance(ASSET_DEFINITION_DB))
@ -1652,7 +1652,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
}
}
public String getTokenView(int chainId, String contractAddr, String type)
public String getTokenView(long chainId, String contractAddr, String type)
{
String viewHTML = "";
TokenDefinition td = getAssetDefinition(chainId, contractAddr);
@ -1664,7 +1664,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
return viewHTML;
}
public String getTokenViewStyle(int chainId, String contractAddr, String type)
public String getTokenViewStyle(long chainId, String contractAddr, String type)
{
String styleData = "";
TokenDefinition td = getAssetDefinition(chainId, contractAddr);
@ -1676,7 +1676,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
return styleData;
}
public List<Attribute> getTokenViewLocalAttributes(int chainId, String contractAddr)
public List<Attribute> getTokenViewLocalAttributes(long chainId, String contractAddr)
{
TokenDefinition td = getAssetDefinition(chainId, contractAddr);
List<Attribute> results = new ArrayList<>();
@ -1689,7 +1689,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
return results;
}
public Map<String, TSAction> getTokenFunctionMap(int chainId, String contractAddr)
public Map<String, TSAction> getTokenFunctionMap(long chainId, String contractAddr)
{
TokenDefinition td = getAssetDefinition(chainId, contractAddr);
if (td != null)
@ -1942,7 +1942,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
return observer;
}
public Single<XMLDsigDescriptor> getSignatureData(int chainId, String contractAddress)
public Single<XMLDsigDescriptor> getSignatureData(long chainId, String contractAddress)
{
return Single.fromCallable(() -> {
XMLDsigDescriptor sigDescriptor = new XMLDsigDescriptor();
@ -2152,7 +2152,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
String[] contractDetails = eventData.getInstanceKey().split("-");
if (contractDetails.length != 5) return;
String eventAddress = contractDetails[0];
int chainId = Integer.parseInt(contractDetails[1]);
long chainId = Long.parseLong(contractDetails[1]);
String eventId = eventData.getFunctionId();
String eventKey = EventDefinition.getEventKey(chainId, eventAddress, eventId, null);
@ -2242,7 +2242,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
* Get all the magic values - eg native crypto balances for all chains
* @return
*/
public String getMagicValuesForInjection(int chainId) throws Exception
public String getMagicValuesForInjection(long chainId) throws Exception
{
String walletBalance = "walletBalance";
String prefix = "web3.eth";
@ -2447,7 +2447,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
});
}
public Single<TokenDefinition> checkServerForScript(int chainId, String address)
public Single<TokenDefinition> checkServerForScript(long chainId, String address)
{
TokenScriptFile tf = getTokenScriptFile(chainId, address);
if (tf != null && !isInSecureZone(tf)) return Single.fromCallable(TokenDefinition::new); //early return for debug script check
@ -2460,7 +2460,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
.observeOn(AndroidSchedulers.mainThread());
}
public void storeTokenViewHeight(int chainId, String address, int listViewHeight)
public void storeTokenViewHeight(long chainId, String address, int listViewHeight)
{
try (Realm realm = realmManager.getRealmInstance(tokensService.getCurrentAddress()))
{
@ -2486,7 +2486,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
}
}
public String getTokenImageUrl(int networkId, String address)
public String getTokenImageUrl(long networkId, String address)
{
String url = "";
String instanceKey = address.toLowerCase() + "-" + networkId;
@ -2522,7 +2522,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
return tURL;
}
public void storeImageUrl(int chainId, String imageUrl)
public void storeImageUrl(long chainId, String imageUrl)
{
String tokenAddress = Utils.getTokenAddrFromAWUrl(imageUrl);
if (!TextUtils.isEmpty(tokenAddress))
@ -2531,7 +2531,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
}
}
public Single<Integer> fetchViewHeight(int chainId, String address)
public Single<Integer> fetchViewHeight(long chainId, String address)
{
return Single.fromCallable(() -> {
try (Realm realm = realmManager.getRealmInstance(tokensService.getCurrentAddress()))
@ -2567,7 +2567,7 @@ public class AssetDefinitionService implements ParseResult, AttributeInterface
});
}
private String tokenSizeDBKey(int chainId, String address)
private String tokenSizeDBKey(long chainId, String address)
{
return "szkey-" + chainId + "-" + address.toLowerCase();
}

@ -53,7 +53,7 @@ public class GasService implements ContractGasProvider
private final EthereumNetworkRepositoryType networkRepository;
private final OkHttpClient httpClient;
private final RealmManager realmManager;
private int currentChainId;
private long currentChainId;
private Web3j web3j;
private BigInteger currentGasPrice;
private final String ETHERSCAN_API_KEY;
@ -76,7 +76,7 @@ public class GasService implements ContractGasProvider
this.httpClient = httpClient;
this.realmManager = realm;
gasFetchDisposable = null;
currentChainId = MAINNET_ID;
this.currentChainId = MAINNET_ID;
web3j = null;
ETHERSCAN_API_KEY = "&apikey=" + getEtherscanKey();
@ -84,7 +84,7 @@ public class GasService implements ContractGasProvider
keyFail = false;
}
public void startGasPriceCycle(int chainId)
public void startGasPriceCycle(long chainId)
{
updateChainId(chainId);
if (gasFetchDisposable == null || gasFetchDisposable.isDisposed())
@ -102,7 +102,7 @@ public class GasService implements ContractGasProvider
}
}
public void updateChainId(int chainId)
public void updateChainId(long chainId)
{
if (networkRepository.getNetworkByChain(chainId) == null)
{
@ -191,21 +191,21 @@ public class GasService implements ContractGasProvider
}
else
{
final int nodeId = currentChainId;
final long nodeId = currentChainId;
return Single.fromCallable(() -> web3j
.ethGasPrice().send())
.map(price -> updateGasPrice(price, nodeId));
}
}
private Boolean updateGasPrice(EthGasPrice ethGasPrice, int chainId)
private Boolean updateGasPrice(EthGasPrice ethGasPrice, long chainId)
{
currentGasPrice = fixGasPrice(ethGasPrice.getGasPrice(), chainId);
updateRealm(new GasPriceSpread(currentGasPrice, networkRepository.hasLockedGas(chainId)), chainId);
return true;
}
private BigInteger fixGasPrice(BigInteger gasPrice, int chainId)
private BigInteger fixGasPrice(BigInteger gasPrice, long chainId)
{
if (gasPrice.compareTo(BigInteger.ZERO) > 0)
{
@ -214,11 +214,11 @@ public class GasService implements ContractGasProvider
else
{
//gas price from node is zero
switch (chainId)
switch ((int)chainId)
{
default:
return gasPrice;
case ARTIS_TAU1_ID:
case (int)ARTIS_TAU1_ID:
//this node incorrectly returns gas price zero, use 1 Gwei
return new BigInteger(C.DEFAULT_XDAI_GAS_PRICE);
}
@ -227,7 +227,7 @@ public class GasService implements ContractGasProvider
private Single<Boolean> updateEtherscanGasPrices(String gasOracleAPI)
{
final int chainId = currentChainId;
final long chainId = currentChainId;
return Single.fromCallable(() -> {
boolean update = false;
Request request = new Request.Builder()
@ -269,7 +269,7 @@ public class GasService implements ContractGasProvider
* @param gasPriceSpread
* @param chainId
*/
private void updateRealm(final GasPriceSpread gasPriceSpread, final int chainId)
private void updateRealm(final GasPriceSpread gasPriceSpread, final long chainId)
{
realmManager.getRealmInstance(TICKER_DB).executeTransaction(r -> {
RealmGasSpread rgs = r.where(RealmGasSpread.class)
@ -282,7 +282,7 @@ public class GasService implements ContractGasProvider
});
}
public Single<EthEstimateGas> calculateGasEstimate(byte[] transactionBytes, int chainId, String toAddress, BigInteger amount, Wallet wallet)
public Single<EthEstimateGas> calculateGasEstimate(byte[] transactionBytes, long chainId, String toAddress, BigInteger amount, Wallet wallet)
{
String txData = "";
if (transactionBytes != null && transactionBytes.length > 0)

@ -293,45 +293,6 @@ public class KeystoreAccountService implements AccountKeystoreService
return RlpEncoder.encode(rlpList);
}
/*private static byte[] encode(RawTransaction rawTransaction, Sign.SignatureData signatureData) {
List<RlpType> values = asRlpValues(rawTransaction, signatureData);
RlpList rlpList = new RlpList(values);
return RlpEncoder.encode(rlpList);
}
static List<RlpType> asRlpValues(
RawTransaction rawTransaction, Sign.SignatureData signatureData) {
List<RlpType> result = new ArrayList<>();
result.add(RlpString.create(rawTransaction.getNonce()));
result.add(RlpString.create(rawTransaction.getGasPrice()));
result.add(RlpString.create(rawTransaction.getGasLimit()));
// an empty to address (contract creation) should not be encoded as a numeric 0 value
String to = rawTransaction.getTo();
if (to != null && to.length() > 0) {
// addresses that start with zeros should be encoded with the zeros included, not
// as numeric values
result.add(RlpString.create(Numeric.hexStringToByteArray(to)));
} else {
result.add(RlpString.create(""));
}
result.add(RlpString.create(rawTransaction.getValue()));
// value field will already be hex encoded, so we need to convert into binary first
byte[] data = Numeric.hexStringToByteArray(rawTransaction.getData());
result.add(RlpString.create(data));
if (signatureData != null) {
result.add(RlpString.create(signatureData.getV()));
result.add(RlpString.create(Bytes.trimLeadingZeroes(signatureData.getR())));
result.add(RlpString.create(Bytes.trimLeadingZeroes(signatureData.getS())));
}
return result;
}*/
@Override
public Single<byte[]> signTransactionFast(Wallet signer, String signerPassword, byte[] message, long chainId) {
return Single.fromCallable(() -> {

@ -10,6 +10,7 @@ import com.alphawallet.app.entity.opensea.AssetContract;
import com.alphawallet.app.entity.tokens.Token;
import com.alphawallet.app.entity.tokens.TokenFactory;
import com.alphawallet.app.entity.tokens.TokenInfo;
import com.alphawallet.ethereum.EthereumNetworkBase;
import com.google.gson.Gson;
import org.json.JSONArray;
@ -40,7 +41,7 @@ public class OpenSeaService
private static OkHttpClient httpClient;
private static final int PAGE_SIZE = 50;
private final Map<String, String> imageUrls = new HashMap<>();
private final List<Integer> storedImagesForChain = new ArrayList<>();
private final List<Long> storedImagesForChain = new ArrayList<>();
private static final TokenFactory tf = new TokenFactory();
private int pageOffset;
@ -59,7 +60,7 @@ public class OpenSeaService
return pageOffset;
}
public Single<Token[]> getTokens(String address, int networkId, String networkName, TokensService tokensService)
public Single<Token[]> getTokens(String address, long networkId, String networkName, TokensService tokensService)
{
return Single.fromCallable(() -> {
int receivedTokens;
@ -104,7 +105,7 @@ public class OpenSeaService
}
private void processOpenseaTokens(Map<String, Token> foundTokens, JSONArray assets, String address,
int networkId, String networkName, TokensService tokensService) throws Exception
long networkId, String networkName, TokensService tokensService) throws Exception
{
final Map<String, Map<BigInteger, NFTAsset>> assetList = new HashMap<>();
@ -132,7 +133,7 @@ public class OpenSeaService
}
}
private void handleERC721(Map<String, Map<BigInteger, NFTAsset>> assetList, JSONObject assetJSON, int networkId,
private void handleERC721(Map<String, Map<BigInteger, NFTAsset>> assetList, JSONObject assetJSON, long networkId,
Map<String, Token> foundTokens, TokensService svs, String networkName, String address) throws Exception
{
NFTAsset asset = new NFTAsset(assetJSON.toString());
@ -171,7 +172,7 @@ public class OpenSeaService
token.addAssetToTokenBalanceAssets(tokenId, asset);
}
private void handleERC1155(Map<String, Map<BigInteger, NFTAsset>> assetList, JSONObject assetJSON, int networkId,
private void handleERC1155(Map<String, Map<BigInteger, NFTAsset>> assetList, JSONObject assetJSON, long networkId,
Map<String, Token> foundTokens, TokensService svs, String networkName, String address) throws Exception
{
NFTAsset asset = new NFTAsset(assetJSON.toString());
@ -211,7 +212,7 @@ public class OpenSeaService
token.addAssetToTokenBalanceAssets(tokenId, asset);
}
private void addAssetImageToHashMap(Map<String, String> imageUrls, AssetContract assetContract, int networkId)
private void addAssetImageToHashMap(Map<String, String> imageUrls, AssetContract assetContract, long networkId)
{
if (storedImagesForChain.contains(networkId)) return; //already recorded the image
@ -227,21 +228,18 @@ public class OpenSeaService
return jsonData != null && jsonData.length() >= 10 && jsonData.contains("assets"); //validate return from API
}
private String fetchTokensFromOpensea(String address, int networkId, int offset)
{
String jsonResult = "{\"noresult\":[]}";
String apiBase;
switch (networkId)
public static final Map<Long, String> apiMap = new HashMap<Long, String>(){
{
case 1:
apiBase = "https://api.opensea.io";
break;
case 4:
apiBase = "https://rinkeby-api.opensea.io";
break;
default:
return jsonResult;
put(EthereumNetworkBase.MAINNET_ID, "https://api.opensea.io");
put(EthereumNetworkBase.RINKEBY_ID, "https://rinkeby-api.opensea.io");
}
};
private String fetchTokensFromOpensea(String address, long networkId, int offset)
{
String jsonResult = "{\"noresult\":[]}";
String apiBase = apiMap.get(networkId);
if (apiBase == null) return jsonResult;
StringBuilder sb = new StringBuilder();
sb.append(apiBase);

@ -88,12 +88,12 @@ public class TickerService
private final OkHttpClient httpClient;
private final PreferenceRepositoryType sharedPrefs;
private final TokenLocalSource localSource;
private final Map<Integer, TokenTicker> ethTickers = new ConcurrentHashMap<>();
private final Map<Long, TokenTicker> ethTickers = new ConcurrentHashMap<>();
private Disposable tickerUpdateTimer;
private double currentConversionRate = 0.0;
private static String currentCurrencySymbolTxt;
private static String currentCurrencySymbol;
private static final Map<Integer, Boolean> canUpdate = new ConcurrentHashMap<>();
private static final Map<Long, Boolean> canUpdate = new ConcurrentHashMap<>();
private static final ConcurrentLinkedQueue<TokenCardMeta> dexGuruQuery = new ConcurrentLinkedQueue<>();
@Nullable
@ -228,7 +228,7 @@ public class TickerService
});
}
public Single<Integer> getERC20Tickers(int chainId, List<TokenCardMeta> erc20Tokens)
public Single<Integer> getERC20Tickers(long chainId, List<TokenCardMeta> erc20Tokens)
{
final String apiChainName = coinGeckoChainIdToAPIName.get(chainId);
final String dexGuruName = dexGuruChainIdToAPISymbol.get(chainId);
@ -343,17 +343,12 @@ public class TickerService
}
}
private void checkPeggedTickers(int chainId, TokenTicker ticker)
private void checkPeggedTickers(long chainId, TokenTicker ticker)
{
switch (chainId)
if (chainId == MAINNET_ID)
{
case MAINNET_ID:
//add pegged chains
ethTickers.put(ARBITRUM_MAIN_ID, ticker);
ethTickers.put(OPTIMISTIC_MAIN_ID, ticker);
break;
default:
break;
ethTickers.put(ARBITRUM_MAIN_ID, ticker);
ethTickers.put(OPTIMISTIC_MAIN_ID, ticker);
}
}
@ -378,8 +373,8 @@ public class TickerService
TokenTicker tTicker = new TokenTicker(String.valueOf(price * currentConversionRate),
changeValue.setScale(3, RoundingMode.DOWN).toString(), currentCurrencySymbolTxt, "", tickerTime);
ethTickers.put(chainId.intValue(), tTicker);
checkPeggedTickers(chainId.intValue(), tTicker);
ethTickers.put(chainId.longValue(), tTicker);
checkPeggedTickers(chainId.longValue(), tTicker);
}
catch (Exception e)
{
@ -395,7 +390,7 @@ public class TickerService
localSource.removeOutdatedTickers();
}
public TokenTicker getEthTicker(int chainId)
public TokenTicker getEthTicker(long chainId)
{
return ethTickers.get(chainId);
}
@ -526,7 +521,7 @@ public class TickerService
Collections.singletonList(new TypeReference<DynamicArray<Uint256>>() {}));
}
public void addCustomTicker(int chainId, TokenTicker ticker)
public void addCustomTicker(long chainId, TokenTicker ticker)
{
if (ticker != null)
{
@ -534,7 +529,7 @@ public class TickerService
}
}
public void addCustomTicker(int chainId, String address, TokenTicker ticker)
public void addCustomTicker(long chainId, String address, TokenTicker ticker)
{
if (ticker != null && address != null)
{
@ -610,7 +605,7 @@ public class TickerService
dexGuruQuery.clear();
}
private static final Map<Integer, String> coinGeckoChainIdToAPIName = new HashMap<Integer, String>(){{
private static final Map<Long, String> coinGeckoChainIdToAPIName = new HashMap<Long, String>(){{
put(MAINNET_ID, "ethereum");
put(XDAI_ID, "xdai");
put(BINANCE_MAIN_ID, "binance-smart-chain");
@ -620,14 +615,14 @@ public class TickerService
put(AVALANCHE_ID, "avalanche");
put(HECO_ID, "huobi-token");
put(ARBITRUM_MAIN_ID, "arbitrum-one");
put(66, "okex-chain");
put(1666600000, "harmony-shard-0");
put(321, "kucoin-community-chain");
put(88, "tomochain");
put(42220, "celo");
put(66L, "okex-chain");
put(1666600000L, "harmony-shard-0");
put(321L, "kucoin-community-chain");
put(88L, "tomochain");
put(42220L, "celo");
}};
private static final Map<Integer, String> dexGuruChainIdToAPISymbol = new HashMap<Integer, String>(){{
private static final Map<Long, String> dexGuruChainIdToAPISymbol = new HashMap<Long, String>(){{
put(MAINNET_ID, "eth");
put(BINANCE_MAIN_ID, "bsc");
put(MATIC_ID, "polygon");
@ -636,10 +631,10 @@ public class TickerService
private static class ChainPair
{
final int chainId;
final long chainId;
final String chainSymbol;
public ChainPair(int chainId, String chainSymbol)
public ChainPair(long chainId, String chainSymbol)
{
this.chainId = chainId;
this.chainSymbol = chainSymbol;

@ -3,6 +3,7 @@ package com.alphawallet.app.service;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.Log;
import android.util.LongSparseArray;
import android.util.SparseArray;
import androidx.annotation.Nullable;
@ -63,8 +64,8 @@ public class TokensService
public static final long PENDING_TIME_LIMIT = 3*DateUtils.MINUTE_IN_MILLIS; //cut off pending chain after 3 minutes
private static final Map<String, Float> tokenValueMap = new ConcurrentHashMap<>(); //this is used to compute the USD value of the tokens on an address
private static final Map<Integer, Long> pendingChainMap = new ConcurrentHashMap<>();
private static final Map<String, SparseArray<ContractType>> interfaceSpecMap = new ConcurrentHashMap<>();
private static final Map<Long, Long> pendingChainMap = new ConcurrentHashMap<>();
private static final Map<String, LongSparseArray<ContractType>> interfaceSpecMap = new ConcurrentHashMap<>();
private final ConcurrentLinkedDeque<Token> tokenStoreList = new ConcurrentLinkedDeque<>(); //used to hold tokens that will be stored
private final Map<String, Long> pendingTokenMap = new ConcurrentHashMap<>(); //used to determine which token to update next
private String currentAddress = null;
@ -73,16 +74,16 @@ public class TokensService
private final TickerService tickerService;
private final OpenSeaService openseaService;
private final AnalyticsServiceType<AnalyticsProperties> analyticsService;
private final List<Integer> networkFilter;
private final List<Long> networkFilter;
private ContractLocator focusToken;
private final ConcurrentLinkedDeque<ContractAddress> unknownTokens;
private final ConcurrentLinkedQueue<Integer> baseTokenCheck;
private final ConcurrentLinkedQueue<Long> baseTokenCheck;
private static long openSeaCheck;
private int openSeaCheckId;
private long openSeaCheckId;
private boolean appHasFocus = true;
private boolean mainNetActive = true;
private static boolean walletStartup = false;
private int transferCheckChain;
private long transferCheckChain;
private final TokenFactory tokenFactory = new TokenFactory();
@Nullable
@ -165,7 +166,7 @@ public class TokensService
}
}
public Token getToken(int chainId, String addr)
public Token getToken(long chainId, String addr)
{
if (TextUtils.isEmpty(currentAddress) || TextUtils.isEmpty(addr)) return null;
else return tokenRepository.fetchToken(chainId, currentAddress, addr.toLowerCase());
@ -207,7 +208,7 @@ public class TokensService
{
List<Token> tokens = new ArrayList<>();
if (addr == null) return tokens;
for (int chainId : networkFilter)
for (long chainId : networkFilter)
{
tokens.add(getToken(chainId, addr));
}
@ -280,14 +281,14 @@ public class TokensService
* @param chainId
* @return
*/
public Single<Token[]> createBaseToken(int chainId)
public Single<Token[]> createBaseToken(long chainId)
{
Token[] tok = new Token[1];
tok[0] = tokenRepository.fetchToken(chainId, currentAddress, currentAddress);
if (!networkFilter.contains(chainId)) //add chain to filter list
{
networkFilter.add(chainId);
ethereumNetworkRepository.setFilterNetworkList(networkFilter.toArray(new Integer[0]));
ethereumNetworkRepository.setFilterNetworkList(networkFilter.toArray(new Long[0]));
}
return tokenRepository.storeTokens(new Wallet(currentAddress), tok);
@ -314,20 +315,20 @@ public class TokensService
public String getCurrentAddress() { return currentAddress; }
public static void setInterfaceSpec(int chainId, String address, ContractType functionSpec)
public static void setInterfaceSpec(long chainId, String address, ContractType functionSpec)
{
SparseArray<ContractType> types = interfaceSpecMap.get(address);
LongSparseArray<ContractType> types = interfaceSpecMap.get(address);
if (types == null)
{
types = new SparseArray<>();
types = new LongSparseArray<>();
interfaceSpecMap.put(address, types);
}
types.put(chainId, functionSpec);
}
public static ContractType checkInterfaceSpec(int chainId, String address)
public static ContractType checkInterfaceSpec(long chainId, String address)
{
SparseArray<ContractType> types = interfaceSpecMap.get(address);
LongSparseArray<ContractType> types = interfaceSpecMap.get(address);
ContractType type = types != null ? types.get(chainId) : null;
if (type != null)
{
@ -448,31 +449,31 @@ public class TokensService
.isDisposed();
}
public List<Integer> getNetworkFilters()
public List<Long> getNetworkFilters()
{
return networkFilter;
}
public String getNetworkName(int chainId)
public String getNetworkName(long chainId)
{
NetworkInfo info = ethereumNetworkRepository.getNetworkByChain(chainId);
if (info != null) return info.getShortName();
else return "";
}
public String getNetworkSymbol(int chainId)
public String getNetworkSymbol(long chainId)
{
NetworkInfo info = ethereumNetworkRepository.getNetworkByChain(chainId);
if (info == null) { info = ethereumNetworkRepository.getNetworkByChain(MAINNET_ID); }
return info.symbol;
}
public void addTokenImageUrl(int networkId, String address, String imageUrl)
public void addTokenImageUrl(long networkId, String address, String imageUrl)
{
tokenRepository.addImageUrl(networkId, address, imageUrl);
}
public Single<TokenInfo> update(String address, int chainId) {
public Single<TokenInfo> update(String address, long chainId) {
return tokenRepository.update(address, chainId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
@ -529,7 +530,7 @@ public class TokensService
checkPendingChains();
}
public Single<BigDecimal> getChainBalance(String walletAddress, int chainId)
public Single<BigDecimal> getChainBalance(String walletAddress, long chainId)
{
return tokenRepository.fetchChainBalance(walletAddress, chainId);
}
@ -567,14 +568,14 @@ public class TokensService
//activate this filter
networkFilter.add(t.tokenInfo.chainId);
//now update the default filters
ethereumNetworkRepository.setFilterNetworkList(networkFilter.toArray(new Integer[0]));
ethereumNetworkRepository.setFilterNetworkList(networkFilter.toArray(new Long[0]));
}
}
private void checkPendingChains()
{
long currentTime = System.currentTimeMillis();
for (Integer chainId : pendingChainMap.keySet())
for (Long chainId : pendingChainMap.keySet())
{
if (currentTime > pendingChainMap.get(chainId))
{
@ -618,7 +619,7 @@ public class TokensService
this::chuckError);
}
public boolean openSeaUpdateInProgress(int chainId)
public boolean openSeaUpdateInProgress(long chainId)
{
return openSeaQueryDisposable != null && !openSeaQueryDisposable.isDisposed() && openSeaCheckId == chainId;
}
@ -647,7 +648,7 @@ public class TokensService
openSeaCheck = System.currentTimeMillis() + DateUtils.MINUTE_IN_MILLIS; //default update in 1 minute
}
private void checkERC20(int chainId)
private void checkERC20(long chainId)
{
if (erc20CheckDisposable == null || erc20CheckDisposable.isDisposed())
{
@ -660,7 +661,7 @@ public class TokensService
}
}
private List<TokenCardMeta> getAllERC20(int chainId)
private List<TokenCardMeta> getAllERC20(long chainId)
{
TokenCardMeta[] tokenList = tokenRepository.fetchTokenMetasForUpdate(new Wallet(currentAddress), Collections.singletonList(chainId));
List<TokenCardMeta> allERC20 = new ArrayList<>();
@ -711,12 +712,12 @@ public class TokensService
* Called when we create a transaction
* @param chainId
*/
public void markChainPending(int chainId)
public void markChainPending(long chainId)
{
pendingChainMap.put(chainId, System.currentTimeMillis() + PENDING_TIME_LIMIT);
}
public void addTokenValue(int chainId, String tokenAddress, float value)
public void addTokenValue(long chainId, String tokenAddress, float value)
{
if (EthereumNetworkRepository.hasRealValue(chainId))
{
@ -822,7 +823,7 @@ public class TokensService
private TokenCardMeta pendingBaseCheck()
{
Integer chainId = baseTokenCheck.poll();
Long chainId = baseTokenCheck.poll();
if (chainId != null)
{
if (BuildConfig.DEBUG) Log.d(TAG, "Base Token Check: " + ethereumNetworkRepository.getNetworkByChain(chainId).name);
@ -869,7 +870,7 @@ public class TokensService
}
}
for (Integer lockedChain : CustomViewSettings.getLockedChains())
for (Long lockedChain : CustomViewSettings.getLockedChains())
{
if (!networkFilter.contains(lockedChain)) networkFilter.add(lockedChain);
}
@ -877,7 +878,7 @@ public class TokensService
if (networkFilter.size() == 0) networkFilter.add(ethereumNetworkRepository.getDefaultNetwork(mainNetActive));
//set network filter prefs
ethereumNetworkRepository.setFilterNetworkList(networkFilter.toArray(new Integer[0]));
ethereumNetworkRepository.setFilterNetworkList(networkFilter.toArray(new Long[0]));
}
/**
@ -885,7 +886,7 @@ public class TokensService
* @param pendingTxChains
* @return
*/
public Token getRequiresTransactionUpdate(List<Integer> pendingTxChains)
public Token getRequiresTransactionUpdate(List<Long> pendingTxChains)
{
//pull all tokens from this wallet out of DB
TokenCardMeta[] tokenList = tokenRepository.fetchTokenMetasForUpdate(new Wallet(currentAddress), networkFilter);
@ -976,7 +977,7 @@ public class TokensService
* @param pending
* @return
*/
private long getTokenTimeInterval(Token t, Collection<Integer> pending)
private long getTokenTimeInterval(Token t, Collection<Long> pending)
{
long nextTimeCheck;
@ -1042,7 +1043,7 @@ public class TokensService
analyticsService.track(C.AN_USE_GAS, analyticsProperties);
}
public Token getTokenOrBase(int chainId, String address)
public Token getTokenOrBase(long chainId, String address)
{
Token token = getToken(chainId, address);
if (token == null)
@ -1063,17 +1064,17 @@ public class TokensService
tokenRepository.storeAsset(currentAddress, token, tokenId, asset);
}
public boolean isChainToken(int chainId, String tokenAddress)
public boolean isChainToken(long chainId, String tokenAddress)
{
return ethereumNetworkRepository.isChainContract(chainId, tokenAddress);
}
public boolean hasChainToken(int chainId)
public boolean hasChainToken(long chainId)
{
return EthereumNetworkRepository.getChainOverrideAddress(chainId).length() > 0;
}
public Token getServiceToken(int chainId)
public Token getServiceToken(long chainId)
{
if (hasChainToken(chainId))
{
@ -1098,7 +1099,7 @@ public class TokensService
return tURL;
}
public void checkingChain(int chainId)
public void checkingChain(long chainId)
{
transferCheckChain = chainId;
}

@ -269,7 +269,7 @@ public class TransactionsNetworkClient implements TransactionsNetworkClientType
}
}
private void getRelatedTransactionList(List<Transaction> txList, EtherscanTransaction[] myTxs, String walletAddress, int chainId)
private void getRelatedTransactionList(List<Transaction> txList, EtherscanTransaction[] myTxs, String walletAddress, long chainId)
{
txList.clear();
for (EtherscanTransaction etx : myTxs)
@ -706,7 +706,7 @@ public class TransactionsNetworkClient implements TransactionsNetworkClientType
return getEtherscanTransactionsFromCovalent(result, walletAddress, networkInfo);
}
private long getTokenBlockRead(Realm instance, int chainId, boolean isNFT)
private long getTokenBlockRead(Realm instance, long chainId, boolean isNFT)
{
RealmAuxData rd = instance.where(RealmAuxData.class)
.equalTo("instanceKey", BLOCK_ENTRY + chainId)
@ -722,7 +722,7 @@ public class TransactionsNetworkClient implements TransactionsNetworkClientType
}
}
private void writeTokenBlockRead(Realm instance, int chainId, long lastBlockChecked, boolean isNFT)
private void writeTokenBlockRead(Realm instance, long chainId, long lastBlockChecked, boolean isNFT)
{
instance.executeTransaction(r -> {
RealmAuxData rd = r.where(RealmAuxData.class)
@ -745,7 +745,7 @@ public class TransactionsNetworkClient implements TransactionsNetworkClientType
});
}
private long getOldestBlockRead(Realm instance, int chainId, long lastTxTime)
private long getOldestBlockRead(Realm instance, long chainId, long lastTxTime)
{
long txBlockRead = 0;
try
@ -770,14 +770,13 @@ public class TransactionsNetworkClient implements TransactionsNetworkClientType
return txBlockRead;
}
private long getFirstTransactionBlock(Realm instance, int chainId, String walletAddress)
private long getFirstTransactionBlock(Realm instance, long chainId, String walletAddress)
{
long txBlockRead = 0;
try
{
RealmToken realmToken = instance.where(RealmToken.class)
.equalTo("address", databaseKey(chainId, walletAddress))
.equalTo("chainId", chainId)
.findFirst();
if (realmToken != null)
@ -793,7 +792,7 @@ public class TransactionsNetworkClient implements TransactionsNetworkClientType
return txBlockRead;
}
private List<TransactionMeta> fetchOlderThan(String walletAddress, long fetchTime, int chainId)
private List<TransactionMeta> fetchOlderThan(String walletAddress, long fetchTime, long chainId)
{
List<TransactionMeta> metas = new ArrayList<>();
try (Realm instance = realmManager.getRealmInstance(walletAddress.toLowerCase()))
@ -819,14 +818,13 @@ public class TransactionsNetworkClient implements TransactionsNetworkClientType
return metas;
}
private void storeLatestBlockRead(String walletAddress, int chainId, String tokenAddress, String lastBlockRead)
private void storeLatestBlockRead(String walletAddress, long chainId, String tokenAddress, String lastBlockRead)
{
try (Realm instance = realmManager.getRealmInstance(walletAddress))
{
instance.executeTransactionAsync(r -> {
RealmToken realmToken = r.where(RealmToken.class)
.equalTo("address", databaseKey(chainId, tokenAddress))
.equalTo("chainId", chainId)
.findFirst();
if (realmToken != null)
@ -842,14 +840,13 @@ public class TransactionsNetworkClient implements TransactionsNetworkClientType
}
}
private void storeEarliestBlockRead(Realm instance, int chainId, String walletAddress, long earliestBlock)
private void storeEarliestBlockRead(Realm instance, long chainId, String walletAddress, long earliestBlock)
{
try
{
instance.executeTransactionAsync(r -> {
RealmToken realmToken = r.where(RealmToken.class)
.equalTo("address", databaseKey(chainId, walletAddress))
.equalTo("chainId", chainId)
.findFirst();
if (realmToken != null)
@ -864,7 +861,7 @@ public class TransactionsNetworkClient implements TransactionsNetworkClientType
}
}
public void deleteAllChainTransactions(Realm instance, int chainId, String walletAddress)
public void deleteAllChainTransactions(Realm instance, long chainId, String walletAddress)
{
try
{
@ -887,11 +884,10 @@ public class TransactionsNetworkClient implements TransactionsNetworkClientType
}
}
private void resetBlockRead(Realm r, int chainId, String walletAddress)
private void resetBlockRead(Realm r, long chainId, String walletAddress)
{
RealmToken realmToken = r.where(RealmToken.class)
.equalTo("address", databaseKey(chainId, walletAddress))
.equalTo("chainId", chainId)
.findFirst();
if (realmToken != null)
@ -993,7 +989,7 @@ public class TransactionsNetworkClient implements TransactionsNetworkClientType
* @param chainId networkId
* @param txFetches map of transactions that need writing. Note we use a map to de-duplicate
*/
private void fetchRequiredTransactions(Realm instance, int chainId, Map<String, Transaction> txFetches)
private void fetchRequiredTransactions(Realm instance, long chainId, Map<String, Transaction> txFetches)
{
//TODO: this should go into the TX service, or be loaded at view time.
instance.executeTransactionAsync(r -> {

@ -125,7 +125,7 @@ public class TransactionsService
*/
private void checkTransactions()
{
List<Integer> filters = tokensService.getNetworkFilters();
List<Long> filters = tokensService.getNetworkFilters();
if (tokensService.getCurrentAddress() == null || filters.size() == 0 ||
(eventFetch != null && !eventFetch.isDisposed())) { return; } //skip check if the service isn't set up or if a current check is in progress
if (currentChainIndex >= filters.size()) currentChainIndex = 0;
@ -141,7 +141,7 @@ public class TransactionsService
}
}
private boolean readTokenMoves(int chainId, boolean isNFT)
private boolean readTokenMoves(long chainId, boolean isNFT)
{
if (BuildConfig.DEBUG) Log.d(TAG,"Check transfers: " + chainId + " : NFT=" + isNFT);
//check if this route has combined NFT
@ -189,15 +189,15 @@ public class TransactionsService
}
}
public Single<TransactionMeta[]> fetchAndStoreTransactions(int chainId, long lastTxTime)
public Single<TransactionMeta[]> fetchAndStoreTransactions(long chainId, long lastTxTime)
{
NetworkInfo network = ethereumNetworkRepository.getNetworkByChain(chainId);
return transactionsClient.fetchMoreTransactions(tokensService.getCurrentAddress(), network, lastTxTime);
}
private List<Integer> getPendingChains()
private List<Long> getPendingChains()
{
List<Integer> pendingChains = new ArrayList<>();
List<Long> pendingChains = new ArrayList<>();
Transaction[] pendingTransactions = fetchPendingTransactions();
for (Transaction tx : pendingTransactions)
{
@ -391,7 +391,7 @@ public class TransactionsService
return transaction;
}
private Transaction storeRawTx(EthBlock ethBlock, int chainId, EthGetTransactionReceipt receipt, EthTransaction txDetails, String currentWallet)
private Transaction storeRawTx(EthBlock ethBlock, long chainId, EthGetTransactionReceipt receipt, EthTransaction txDetails, String currentWallet)
{
if (ethBlock != null && ethBlock.getBlock() != null && receipt != null && receipt.getResult() != null)
{

@ -83,7 +83,7 @@ public class AddCustomRPCNetworkActivity extends BaseActivity implements Standar
initViewModel();
int chainId = getIntent().getIntExtra(CHAIN_ID, -1);
long chainId = getIntent().getLongExtra(CHAIN_ID, -1);
if (chainId >= 0) {
// get network info and fill ui
@ -144,7 +144,7 @@ public class AddCustomRPCNetworkActivity extends BaseActivity implements Standar
return false;
} else {
try {
Integer.parseInt(chainIdInputView.getText().toString());
Long.parseLong(chainIdInputView.getText().toString());
} catch (NumberFormatException ex) {
chainIdInputView.setError(getString(R.string.error_must_numeric));
return false;
@ -190,15 +190,15 @@ public class AddCustomRPCNetworkActivity extends BaseActivity implements Standar
public void handleClick(String action, int actionId)
{
if (validateInputs()) {
int oldChainId = getIntent().getIntExtra(CHAIN_ID, -1);
long oldChainId = getIntent().getLongExtra(CHAIN_ID, -1);
// add network
viewModel.addNetwork(nameInputView.getText().toString(),
rpcUrlInputView.getText().toString(),
Integer.parseInt(chainIdInputView.getText().toString()),
Long.parseLong(chainIdInputView.getText().toString()),
symbolInputView.getText().toString(),
blockExplorerUrlInputView.getText().toString(),
blockExplorerApiUrl.getText().toString(), testNetSwitch.isChecked(), oldChainId != -1 ? oldChainId : null);
blockExplorerApiUrl.getText().toString(), testNetSwitch.isChecked(), oldChainId != -1L ? oldChainId : null);
finish();
} else {
handler.postDelayed(this::resetValidateErrors, 2000);

@ -435,7 +435,7 @@ public class AddTokenActivity extends BaseActivity implements AddressReadyCallba
aDialog.show();
}
private void setupNetwork(int chainId)
private void setupNetwork(long chainId)
{
networkInfo = viewModel.getNetworkInfo(chainId);
if (networkInfo != null)
@ -446,7 +446,7 @@ public class AddTokenActivity extends BaseActivity implements AddressReadyCallba
ActivityResultLauncher<Intent> getNetwork = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
result -> {
int networkId = result.getData().getIntExtra(C.EXTRA_CHAIN_ID, 1);
long networkId = result.getData().getLongExtra(C.EXTRA_CHAIN_ID, 1);
setupNetwork(networkId);
});

@ -117,7 +117,7 @@ public class AssetDisplayActivity extends BaseActivity implements StandardFuncti
.get(TokenFunctionViewModel.class);
String address = getIntent().getStringExtra(C.EXTRA_ADDRESS);
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getToken(chainId, address);
setContentView(R.layout.activity_asset_display);

@ -232,7 +232,7 @@ public class DappBrowserFragment extends BaseFragment implements OnSignTransacti
// Some multi-chain Dapps have a watchdog thread that checks the chain
// This thread stays in operation until a new page load is complete.
private String loadUrlAfterReload;
private static volatile int forceChainChange = 0;
private static volatile long forceChainChange = 0;
private DAppFunction dAppFunction;
@ -772,8 +772,7 @@ public class DappBrowserFragment extends BaseFragment implements OnSignTransacti
if (realmUpdate != null) realmUpdate.removeAllChangeListeners();
realmUpdate = viewModel.getRealmInstance(wallet).where(RealmToken.class)
.equalTo("address", TokensRealmSource.databaseKey(activeNetwork.chainId, "eth"))
.equalTo("chainId", activeNetwork.chainId).findAllAsync();
.equalTo("address", TokensRealmSource.databaseKey(activeNetwork.chainId, "eth")).findAllAsync();
realmUpdate.addChangeListener(realmTokens -> {
//update balance
if (realmTokens.size() == 0) return;
@ -797,7 +796,7 @@ public class DappBrowserFragment extends BaseFragment implements OnSignTransacti
}
}
public void switchNetworkAndLoadUrl(int chainId, String url)
public void switchNetworkAndLoadUrl(long chainId, String url)
{
forceChainChange = chainId; //avoid prompt to change chain for 1inch
loadUrlAfterReload = url; //after reload with new chain inject, page is clean to load the correct site
@ -834,7 +833,7 @@ public class DappBrowserFragment extends BaseFragment implements OnSignTransacti
ActivityResultLauncher<Intent> getNewNetwork = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
result -> {
int networkId = result.getData().getIntExtra(C.EXTRA_CHAIN_ID, 1);
long networkId = result.getData().getLongExtra(C.EXTRA_CHAIN_ID, 1);
loadNewNetwork(networkId);
});
@ -1027,12 +1026,12 @@ public class DappBrowserFragment extends BaseFragment implements OnSignTransacti
ActivityResultLauncher<Intent> getNetwork = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
result -> {
int networkId = result.getData().getIntExtra(C.EXTRA_CHAIN_ID, 1);
long networkId = result.getData().getLongExtra(C.EXTRA_CHAIN_ID, 1);
forceChainChange = networkId;
loadNewNetwork(networkId);
});
private void loadNewNetwork(int newNetworkId)
private void loadNewNetwork(long newNetworkId)
{
if (activeNetwork == null || activeNetwork.chainId != newNetworkId)
{
@ -1114,7 +1113,7 @@ public class DappBrowserFragment extends BaseFragment implements OnSignTransacti
public void OnWalletAddEthereumChainObject(WalletAddEthereumChainObject chainObj)
{
// read chain value
int chainId = chainObj.getChainId();
long chainId = chainObj.getChainId();
final NetworkInfo info = viewModel.getNetworkInfo(chainId);
if (forceChainChange != 0)

@ -83,7 +83,7 @@ public class Erc1155Activity extends BaseActivity implements StandardFunctionInt
private void getIntentData()
{
wallet = getIntent().getParcelableExtra(WALLET);
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getTokensService().getToken(chainId, getIntent().getStringExtra(C.EXTRA_ADDRESS));
}
@ -94,7 +94,7 @@ public class Erc1155Activity extends BaseActivity implements StandardFunctionInt
TokenActivityFragment tokenActivityFragment = new TokenActivityFragment();
Bundle bundle = new Bundle();
bundle.putInt(C.EXTRA_CHAIN_ID, token.tokenInfo.chainId);
bundle.putLong(C.EXTRA_CHAIN_ID, token.tokenInfo.chainId);
bundle.putString(C.EXTRA_ADDRESS, token.getAddress());
bundle.putParcelable(WALLET, wallet);
infoFragment.setArguments(bundle);

@ -101,7 +101,7 @@ public class Erc1155AssetDetailActivity extends BaseActivity implements Standard
private void getIntentData()
{
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getTokensService().getToken(chainId, getIntent().getStringExtra(C.EXTRA_ADDRESS));
wallet = getIntent().getParcelableExtra(C.Key.WALLET);
tokenId = new BigInteger(getIntent().getStringExtra(C.EXTRA_TOKEN_ID));

@ -75,7 +75,7 @@ public class Erc1155AssetListActivity extends BaseActivity implements StandardFu
private void getIntentData()
{
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getTokensService().getToken(chainId, getIntent().getStringExtra(C.EXTRA_ADDRESS));
wallet = getIntent().getParcelableExtra(C.Key.WALLET);
asset = getIntent().getParcelableExtra(C.EXTRA_NFTASSET_LIST);

@ -81,7 +81,7 @@ public class Erc1155AssetSelectActivity extends BaseActivity implements Standard
private void getIntentData()
{
String address = getIntent().getStringExtra(C.EXTRA_ADDRESS);
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getTokensService().getToken(chainId, address);
wallet = getIntent().getParcelableExtra(C.Key.WALLET);
String tokenIdStr = getIntent().getStringExtra(C.EXTRA_TOKEN_ID);

@ -65,7 +65,7 @@ public class Erc1155AssetsFragment extends BaseFragment implements OnAssetClickL
viewModel = new ViewModelProvider(this, viewModelFactory)
.get(Erc1155AssetsViewModel.class);
int chainId = getArguments().getInt(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getArguments().getLong(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getTokensService().getToken(chainId, getArguments().getString(C.EXTRA_ADDRESS));
wallet = getArguments().getParcelable(C.Key.WALLET);

@ -55,7 +55,7 @@ public class Erc1155InfoFragment extends BaseFragment {
viewModel = new ViewModelProvider(this, viewModelFactory)
.get(Erc1155InfoViewModel.class);
int chainId = getArguments().getInt(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getArguments().getLong(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getTokensService().getToken(chainId, getArguments().getString(C.EXTRA_ADDRESS));
tokenInfoLayout = view.findViewById(R.id.layout_token_info);

@ -88,7 +88,7 @@ public class Erc20DetailActivity extends BaseActivity implements StandardFunctio
{
symbol = savedInstanceState.getString(C.EXTRA_ACTION_NAME);
wallet = savedInstanceState.getParcelable(WALLET);
int chainId = savedInstanceState.getInt(C.EXTRA_CHAIN_ID, MAINNET_ID);
long chainId = savedInstanceState.getLong(C.EXTRA_CHAIN_ID, MAINNET_ID);
token = viewModel.getTokensService().getToken(chainId, savedInstanceState.getString(C.EXTRA_ADDRESS));
}
else
@ -173,7 +173,7 @@ public class Erc20DetailActivity extends BaseActivity implements StandardFunctio
symbol = getIntent().getStringExtra(C.EXTRA_SYMBOL);
symbol = symbol == null ? ETH_SYMBOL : symbol;
wallet = getIntent().getParcelableExtra(WALLET);
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, MAINNET_ID);
token = viewModel.getTokensService().getTokenOrBase(chainId, getIntent().getStringExtra(C.EXTRA_ADDRESS));
tokenMeta = new TokenCardMeta(token);
viewModel.checkForNewScript(token);
@ -185,7 +185,7 @@ public class Erc20DetailActivity extends BaseActivity implements StandardFunctio
super.onSaveInstanceState(outState);
outState.putString(C.EXTRA_SYMBOL, symbol);
outState.putParcelable(WALLET, wallet);
outState.putInt(C.EXTRA_CHAIN_ID, token.tokenInfo.chainId);
outState.putLong(C.EXTRA_CHAIN_ID, token.tokenInfo.chainId);
outState.putString(C.EXTRA_ADDRESS, token.getAddress());
}

@ -111,7 +111,7 @@ public class FunctionActivity extends BaseActivity implements FunctionCallback,
if (tokenIdStr == null || tokenIdStr.length() == 0) tokenIdStr = "0";
String address = getIntent().getStringExtra(C.EXTRA_ADDRESS);
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getToken(chainId, address);
if (token == null)

@ -77,7 +77,7 @@ public class GasSettingsActivity extends BaseActivity implements GasSettingsCall
private final List<GasSpeed> gasSpeeds = new ArrayList<>();
private int currentGasSpeedIndex = -1;
private int chainId;
private long chainId;
private BigDecimal presetGasLimit;
private BigDecimal customGasLimit;
private BigDecimal availableBalance;
@ -119,7 +119,7 @@ public class GasSettingsActivity extends BaseActivity implements GasSettingsCall
}
currentGasSpeedIndex = getIntent().getIntExtra(C.EXTRA_SINGLE_ITEM, -1);
chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, MAINNET_ID);
chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, MAINNET_ID);
customGasLimit = new BigDecimal(getIntent().getStringExtra(C.EXTRA_CUSTOM_GAS_LIMIT));
presetGasLimit = new BigDecimal(getIntent().getStringExtra(C.EXTRA_GAS_LIMIT_PRESET));
availableBalance = new BigDecimal(getIntent().getStringExtra(C.EXTRA_TOKEN_BALANCE));

@ -1134,7 +1134,7 @@ public class HomeActivity extends BaseNavigationActivity implements View.OnClick
if (data != null && resultCode == Activity.RESULT_OK && data.hasExtra(C.DAPP_URL_LOAD))
{
String url = data.getStringExtra(C.DAPP_URL_LOAD);
int chainId = data.getIntExtra(C.EXTRA_CHAIN_ID, MAINNET_ID);
long chainId = data.getLongExtra(C.EXTRA_CHAIN_ID, MAINNET_ID);
((DappBrowserFragment)dappBrowserFragment).switchNetworkAndLoadUrl(chainId, url);
showPage(DAPP_BROWSER);
}

@ -80,7 +80,7 @@ public class ImportTokenActivity extends BaseActivity implements View.OnClickLis
private TextView importTxt;
private LinearLayout costLayout;
private int chainId = 0;
private long chainId = 0;
private boolean usingFeeMaster = false;
private String paymasterUrlPrefix = "https://paymaster.stormbird.sg/api/";
private final String TAG = "ITA";

@ -71,7 +71,7 @@ public class MyAddressActivity extends BaseActivity implements AmountReadyCallba
private LinearLayout selectAddress;
private NetworkInfo networkInfo;
private AddressMode currentMode = AddressMode.MODE_ADDRESS;
private int overrideNetwork;
private long overrideNetwork;
private int screenWidth;
private CopyTextView copyAddress;
private CopyTextView copyWalletName;
@ -321,7 +321,7 @@ public class MyAddressActivity extends BaseActivity implements AmountReadyCallba
result -> {
if (result.getResultCode() == RESULT_OK)
{
int networkId = result.getData().getIntExtra(C.EXTRA_CHAIN_ID, -1);
long networkId = result.getData().getLongExtra(C.EXTRA_CHAIN_ID, -1);
NetworkInfo info = viewModel.getNetworkByChain(networkId);
if (info != null)
{
@ -364,10 +364,10 @@ public class MyAddressActivity extends BaseActivity implements AmountReadyCallba
{
if (viewModel == null) initViewModel();
wallet = getIntent().getParcelableExtra(C.Key.WALLET);
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getTokenService().getToken(chainId, getIntent().getStringExtra(C.EXTRA_ADDRESS));
int fallBackChainId = token != null ? token.tokenInfo.chainId : MAINNET_ID;
overrideNetwork = getIntent().getIntExtra(OVERRIDE_DEFAULT, fallBackChainId);
long fallBackChainId = token != null ? token.tokenInfo.chainId : MAINNET_ID;
overrideNetwork = getIntent().getLongExtra(OVERRIDE_DEFAULT, fallBackChainId);
if (wallet == null)
{

@ -68,7 +68,7 @@ public class QRScanner extends BaseActivity
private BeepManager beepManager;
private String lastText;
private Disposable disposable;
private int chainIdOverride;
private long chainIdOverride;
private TextView flashButton;
private TextView myAddressButton;
private TextView browseButton;

@ -71,7 +71,7 @@ public class RedeemAssetSelectActivity extends BaseActivity implements OnTokenCl
viewModel = new ViewModelProvider(this, viewModelFactory)
.get(RedeemAssetSelectViewModel.class);
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getTokensService().getToken(chainId, getIntent().getStringExtra(C.EXTRA_ADDRESS));
ticketRange = getIntent().getParcelableExtra(TICKET_RANGE);
setContentView(R.layout.activity_redeem_asset);

@ -86,7 +86,7 @@ public class RedeemSignatureDisplayActivity extends BaseActivity implements View
viewModel = new ViewModelProvider(this, redeemSignatureDisplayModelFactory)
.get(RedeemSignatureDisplayModel.class);
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getTokensService().getToken(chainId, getIntent().getStringExtra(C.EXTRA_ADDRESS));
wallet = getIntent().getParcelableExtra(WALLET);
ticketRange = getIntent().getParcelableExtra(TICKET_RANGE);

@ -57,7 +57,7 @@ public class SelectNetworkActivity extends SelectNetworkBaseActivity implements
if (intent != null)
{
localSelectionMode = intent.getBooleanExtra(C.EXTRA_LOCAL_NETWORK_SELECT_FLAG, false);
int selectedChainId = intent.getIntExtra(C.EXTRA_CHAIN_ID, -1);
long selectedChainId = intent.getIntExtra(C.EXTRA_CHAIN_ID, -1);
// Previous active network was deselected, get the first item in filtered networks
if (selectedChainId == -1)
@ -77,7 +77,7 @@ public class SelectNetworkActivity extends SelectNetworkBaseActivity implements
hideSwitches();
List<NetworkInfo> filteredNetworks = new ArrayList<>();
for (Integer chainId : viewModel.getFilterNetworkList())
for (Long chainId : viewModel.getFilterNetworkList())
{
filteredNetworks.add(viewModel.getNetworkByChain(chainId));
}
@ -93,7 +93,7 @@ public class SelectNetworkActivity extends SelectNetworkBaseActivity implements
}
}
void setupList(Integer selectedNetwork, List<NetworkInfo> availableNetworks)
void setupList(Long selectedNetwork, List<NetworkInfo> availableNetworks)
{
boolean isMainNetActive = viewModel.mainNetActive();
@ -133,7 +133,7 @@ public class SelectNetworkActivity extends SelectNetworkBaseActivity implements
setupFilters(selectedNetwork, availableNetworks);
}
private void setupFilters(Integer selectedNetwork, List<NetworkInfo> availableNetworks)
private void setupFilters(Long selectedNetwork, List<NetworkInfo> availableNetworks)
{
ArrayList<NetworkItem> mainNetList = new ArrayList<>();
ArrayList<NetworkItem> testNetList = new ArrayList<>();
@ -201,7 +201,7 @@ public class SelectNetworkActivity extends SelectNetworkBaseActivity implements
@Override
protected void handleSetNetworks()
{
int selectedNetwork = mainnetSwitch.isChecked() ? mainNetAdapter.getSelectedItem() : testNetAdapter.getSelectedItem();
long selectedNetwork = mainnetSwitch.isChecked() ? mainNetAdapter.getSelectedItem() : testNetAdapter.getSelectedItem();
Intent intent = new Intent();
intent.putExtra(C.EXTRA_CHAIN_ID, selectedNetwork);
setResult(RESULT_OK, intent);

@ -96,7 +96,7 @@ public class SelectNetworkFilterActivity extends SelectNetworkBaseActivity imple
MultiSelectNetworkAdapter.EditNetworkListener editNetworkListener = new MultiSelectNetworkAdapter.EditNetworkListener() {
@Override
public void onEditNetwork(int chainId) {
public void onEditNetwork(long chainId) {
Intent intent = new Intent(SelectNetworkFilterActivity.this, AddCustomRPCNetworkActivity.class);
intent.putExtra(CHAIN_ID, chainId);
startActivity(intent);
@ -113,7 +113,7 @@ public class SelectNetworkFilterActivity extends SelectNetworkBaseActivity imple
@Override
protected void handleSetNetworks()
{
List<Integer> filterList = new ArrayList<>(Arrays.asList(mainNetAdapter.getSelectedItems()));
List<Long> filterList = new ArrayList<>(Arrays.asList(mainNetAdapter.getSelectedItems()));
filterList.addAll(Arrays.asList(testNetAdapter.getSelectedItems()));
boolean hasClicked = mainNetAdapter.hasSelectedItems() || testNetAdapter.hasSelectedItems();

@ -126,7 +126,7 @@ public class SellDetailActivity extends BaseActivity implements OnTokenClickList
toolbar();
setTitle(getString(R.string.empty));
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getTokensService().getToken(chainId, getIntent().getStringExtra(C.EXTRA_ADDRESS));
wallet = getIntent().getParcelableExtra(WALLET);
ticketIds = getIntent().getStringExtra(EXTRA_TOKENID_LIST);

@ -110,7 +110,7 @@ public class SendActivity extends BaseActivity implements AmountReadyCallback, S
.get(SendViewModel.class);
String contractAddress = getIntent().getStringExtra(C.EXTRA_CONTRACT_ADDRESS);
int currentChain = getIntent().getIntExtra(C.EXTRA_NETWORKID, MAINNET_ID);
long currentChain = getIntent().getLongExtra(C.EXTRA_NETWORKID, MAINNET_ID);
wallet = getIntent().getParcelableExtra(WALLET);
token = viewModel.getToken(currentChain, getIntent().getStringExtra(C.EXTRA_ADDRESS));
QRResult result = getIntent().getParcelableExtra(C.EXTRA_AMOUNT);
@ -147,7 +147,7 @@ public class SendActivity extends BaseActivity implements AmountReadyCallback, S
}
}
private boolean checkTokenValidity(int currentChain, String contractAddress)
private boolean checkTokenValidity(long currentChain, String contractAddress)
{
if (token == null || token.tokenInfo == null)
{
@ -424,7 +424,7 @@ public class SendActivity extends BaseActivity implements AmountReadyCallback, S
}
}
private void showChainChangeDialog(int chainId)
private void showChainChangeDialog(long chainId)
{
if (dialog != null && dialog.isShowing()) dialog.dismiss();
dialog = new AWalletAlertDialog(this);

@ -56,7 +56,7 @@ public class TokenActivityFragment extends BaseFragment {
viewModel = new ViewModelProvider(this, viewModelFactory)
.get(TokenActivityViewModel.class);
int chainId = getArguments().getInt(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getArguments().getLong(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getTokensService().getToken(chainId, getArguments().getString(C.EXTRA_ADDRESS));
wallet = getArguments().getParcelable(C.Key.WALLET);

@ -95,7 +95,7 @@ public class TokenDetailActivity extends BaseActivity implements StandardFunctio
if (getIntent() != null && getIntent().getExtras() != null) {
asset = getIntent().getExtras().getParcelable(C.EXTRA_NFTASSET);
String address = getIntent().getStringExtra(C.EXTRA_ADDRESS);
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
token = viewModel.getToken(chainId, address);
tokenId = new BigInteger(getIntent().getExtras().getString(C.EXTRA_TOKEN_ID));
initViews();

@ -113,7 +113,7 @@ public class TokenFunctionActivity extends BaseActivity implements StandardFunct
SystemView systemView = findViewById(R.id.system_view);
systemView.hide();
functionBar = findViewById(R.id.layoutButtons);
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, EthereumNetworkBase.MAINNET_ID);
initViews(viewModel.getTokenService().getToken(chainId, getIntent().getStringExtra(C.EXTRA_ADDRESS)));
toolbar();
setTitle(getString(R.string.token_function));

@ -81,7 +81,7 @@ public class TransactionDetailActivity extends BaseActivity implements StandardF
viewModel.transactionError().observe(this, this::txError);
String txHash = getIntent().getStringExtra(C.EXTRA_TXHASH);
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, MAINNET_ID);
wallet = getIntent().getParcelableExtra(WALLET);
viewModel.fetchTransaction(wallet, txHash, chainId);
}

@ -104,7 +104,7 @@ public class TransferNFTActivity extends BaseActivity implements OnTokenClickLis
viewModel = new ViewModelProvider(this, viewModelFactory)
.get(TransferTicketDetailViewModel.class);
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, com.alphawallet.ethereum.EthereumNetworkBase.MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, com.alphawallet.ethereum.EthereumNetworkBase.MAINNET_ID);
token = viewModel.getTokenService().getToken(chainId, getIntent().getStringExtra(C.EXTRA_ADDRESS));
String tokenIds = getIntent().getStringExtra(C.EXTRA_TOKENID_LIST);

@ -157,7 +157,7 @@ public class TransferTicketDetailActivity extends BaseActivity
viewModel = new ViewModelProvider(this, viewModelFactory)
.get(TransferTicketDetailViewModel.class);
int chainId = getIntent().getIntExtra(C.EXTRA_CHAIN_ID, MAINNET_ID);
long chainId = getIntent().getLongExtra(C.EXTRA_CHAIN_ID, MAINNET_ID);
token = viewModel.getTokenService().getToken(chainId, getIntent().getStringExtra(C.EXTRA_ADDRESS));
ticketIds = getIntent().getStringExtra(EXTRA_TOKENID_LIST);
@ -824,7 +824,7 @@ public class TransferTicketDetailActivity extends BaseActivity
final String txSendAddress = sendAddress;
sendAddress = null;
final byte[] transactionBytes = viewModel.getERC721TransferBytes(txSendAddress,token.getAddress(),ticketIds,token.tokenInfo.chainId);
final byte[] transactionBytes = viewModel.getERC721TransferBytes(txSendAddress,token.getAddress(),ticketIds, token.tokenInfo.chainId);
if (token.isEthereum())
{
checkConfirm(BigInteger.valueOf(GAS_LIMIT_MIN), transactionBytes, txSendAddress, txSendAddress);

@ -1,6 +1,7 @@
package com.alphawallet.app.ui;
import static com.alphawallet.app.C.DEFAULT_GAS_LIMIT_FOR_NONFUNGIBLE_TOKENS;
import static com.alphawallet.ethereum.EthereumNetworkBase.MAINNET_ID;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
@ -121,7 +122,7 @@ public class WalletConnectActivity extends BaseActivity implements ActionSheetCa
private SignAuthenticationCallback signCallback;
private long lastId;
private int chainIdOverride;
private long chainIdOverride;
private boolean startup = false;
private boolean switchConnection = false;
@ -408,7 +409,7 @@ public class WalletConnectActivity extends BaseActivity implements ActionSheetCa
if (rq != null)
{
requestId = rq.id;
int useChainId = viewModel.getChainId(getSessionId());
long useChainId = viewModel.getChainId(getSessionId());
switch (rq.type)
{
case MESSAGE:
@ -628,19 +629,19 @@ public class WalletConnectActivity extends BaseActivity implements ActionSheetCa
ActivityResultLauncher<Intent> getNetwork = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
result -> {
chainIdOverride = result.getData().getIntExtra(C.EXTRA_CHAIN_ID, 1);
chainIdOverride = result.getData().getLongExtra(C.EXTRA_CHAIN_ID, MAINNET_ID);
Toast.makeText(this, getText(R.string.hint_network_name) + " " + EthereumNetworkBase.getShortChainName(chainIdOverride), Toast.LENGTH_LONG).show();
onSessionRequest(0L, remotePeerMeta, chainIdOverride);
});
private void onSessionRequest(Long id, WCPeerMeta peer, int chainId)
private void onSessionRequest(Long id, WCPeerMeta peer, long chainId)
{
if (peer == null) { finish(); }
String[] accounts = {viewModel.getWallet().address};
String displayIcon = (peer.getIcons().size() > 0) ? peer.getIcons().get(0) : DEFAULT_IDON;
chainIdOverride = chainIdOverride > 0 ? chainIdOverride : (chainId > 0 ? chainId : com.alphawallet.ethereum.EthereumNetworkBase.MAINNET_ID);
chainIdOverride = chainIdOverride > 0 ? chainIdOverride : (chainId > 0 ? chainId : MAINNET_ID);
Glide.with(this)
.load(displayIcon)
@ -686,12 +687,12 @@ public class WalletConnectActivity extends BaseActivity implements ActionSheetCa
dialog.show();
}
private Spannable buildMessage(String url, int networkId)
private Spannable buildMessage(String url, long networkId)
{
StyledStringBuilder sb = new StyledStringBuilder();
sb.append(url);
sb.startStyleGroup().append("\n\n").append(EthereumNetworkBase.getShortChainName(networkId));
sb.setColor(ContextCompat.getColor(this, Utils.getChainColour(networkId)));
sb.setColor(ContextCompat.getColor(this, EthereumNetworkBase.getChainColour(networkId)));
sb.applyStyles();
return sb;
}
@ -720,7 +721,7 @@ public class WalletConnectActivity extends BaseActivity implements ActionSheetCa
doSignMessage(signable);
}
private void onEthSignTransaction(Long id, WCEthereumTransaction transaction, int chainId)
private void onEthSignTransaction(Long id, WCEthereumTransaction transaction, long chainId)
{
lastId = id;
final Web3Transaction w3Tx = new Web3Transaction(transaction, id);
@ -821,7 +822,7 @@ public class WalletConnectActivity extends BaseActivity implements ActionSheetCa
confirmationDialog.show();
}
private void onEthSendTransaction(Long id, WCEthereumTransaction transaction, int chainId)
private void onEthSendTransaction(Long id, WCEthereumTransaction transaction, long chainId)
{
lastId = id;
final Web3Transaction w3Tx = new Web3Transaction(transaction, id);
@ -829,7 +830,7 @@ public class WalletConnectActivity extends BaseActivity implements ActionSheetCa
if (confirmationDialog != null) confirmationDialog.show();
}
private ActionSheetDialog generateTransactionRequest(Web3Transaction w3Tx, int chainId)
private ActionSheetDialog generateTransactionRequest(Web3Transaction w3Tx, long chainId)
{
ActionSheetDialog confDialog = null;
try

@ -67,7 +67,7 @@ public class WalletsActivity extends BaseActivity implements
private boolean requiresHomeRefresh;
private String dialogError;
private final int balanceChain = EthereumNetworkRepository.getOverrideToken().chainId;
private final long balanceChain = EthereumNetworkRepository.getOverrideToken().chainId;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {

@ -22,7 +22,7 @@ public class MultiSelectNetworkAdapter extends RecyclerView.Adapter<MultiSelectN
private boolean hasClicked = false;
public interface EditNetworkListener {
void onEditNetwork(int chainId);
void onEditNetwork(long chainId);
}
private EditNetworkListener editListener;
@ -34,15 +34,15 @@ public class MultiSelectNetworkAdapter extends RecyclerView.Adapter<MultiSelectN
editListener = editNetworkListener;
}
public Integer[] getSelectedItems()
public Long[] getSelectedItems()
{
List<Integer> enabledIds = new ArrayList<>();
List<Long> enabledIds = new ArrayList<>();
for (NetworkItem data : networkList)
{
if (data.isSelected()) enabledIds.add(data.getChainId());
}
return enabledIds.toArray(new Integer[0]);
return enabledIds.toArray(new Long[0]);
}
public boolean hasSelectedItems()

@ -35,7 +35,7 @@ public class SingleSelectNetworkAdapter extends RecyclerView.Adapter<SingleSelec
}
}
public Integer getSelectedItem()
public Long getSelectedItem()
{
for (NetworkItem data : networkList)
{

@ -65,7 +65,7 @@ public class TokenScriptManagementAdapter extends RecyclerView.Adapter<TokenScri
if(!tokenLocator.isError())
{
ContractInfo originContract = tokenLocator.getContracts();
int chainId;
long chainId;
String address;
//sweep to see if there's a mainnet holding contract
@ -150,7 +150,7 @@ public class TokenScriptManagementAdapter extends RecyclerView.Adapter<TokenScri
message.append(context.getString(R.string.origin_token_title));
if (tokenLocator != null)
{
for (int chainId : tokenLocator.addresses.keySet())
for (long chainId : tokenLocator.addresses.keySet())
{
String chainName = MagicLinkInfo.getNetworkNameById(chainId);
for (String address : tokenLocator.addresses.get(chainId))

@ -290,7 +290,7 @@ public class TokensAdapter extends RecyclerView.Adapter<BinderViewHolder> {
}
}
public void removeToken(int chainId, String tokenAddress) {
public void removeToken(long chainId, String tokenAddress) {
String id = TokensRealmSource.databaseKey(chainId, tokenAddress);
for (int i = 0; i < items.size(); i++) {
Object si = items.get(i);

@ -9,11 +9,11 @@ public class IconItem {
private final String url;
private final UseIcon useText;
private final String correctedAddress;
private final int chainId;
private final long chainId;
private final static Map<String, Boolean> iconLoadType = new ConcurrentHashMap<>();
public IconItem(String url, String correctedAddress, int chainId) {
public IconItem(String url, String correctedAddress, long chainId) {
this.url = url;
this.useText = getLoadType(correctedAddress);
this.correctedAddress = correctedAddress;

@ -2,10 +2,10 @@ package com.alphawallet.app.ui.widget.entity;
public class NetworkItem {
private String name;
private int chainId;
private long chainId;
private boolean isSelected;
public NetworkItem(String name, int chainId, boolean isSelected) {
public NetworkItem(String name, long chainId, boolean isSelected) {
this.name = name;
this.chainId = chainId;
this.isSelected = isSelected;
@ -15,9 +15,9 @@ public class NetworkItem {
return name;
}
public int getChainId() { return chainId; }
public long getChainId() { return chainId; }
public void setName(String name, int chainId) {
public void setName(String name, long chainId) {
this.name = name;
this.chainId = chainId;
}

@ -23,12 +23,12 @@ import static com.alphawallet.app.entity.tokenscript.TokenscriptFunction.ZERO_AD
*/
public class TokenTransferData extends ActivityMeta implements Parcelable
{
public final int chainId;
public final long chainId;
public final String tokenAddress;
public final String eventName;
public final String transferDetail;
public TokenTransferData(String hash, int chainId, String tokenAddress, String eventName, String transferDetail, long transferTime)
public TokenTransferData(String hash, long chainId, String tokenAddress, String eventName, String transferDetail, long transferTime)
{
super(transferTime, hash, true);
this.chainId = chainId;
@ -75,7 +75,7 @@ public class TokenTransferData extends ActivityMeta implements Parcelable
protected TokenTransferData(Parcel in)
{
super(in.readLong(), in.readString(), true);
chainId = in.readInt();
chainId = in.readLong();
tokenAddress = in.readString();
eventName = in.readString();
transferDetail = in.readString();
@ -104,7 +104,7 @@ public class TokenTransferData extends ActivityMeta implements Parcelable
{
dest.writeLong(timeStamp);
dest.writeString(hash);
dest.writeInt(chainId);
dest.writeLong(chainId);
dest.writeString(tokenAddress);
dest.writeString(eventName);
dest.writeString(transferDetail);

@ -92,13 +92,6 @@ public class TokenGridHolder extends BinderViewHolder<TokenCardMeta> {
}
}
/*private void setupIcon(@NotNull Token token) {
imageIcon.setVisibility(View.GONE);
textIcon.setVisibility(View.VISIBLE);
textIcon.setBackgroundTintList(ContextCompat.getColorStateList(getContext(), Utils.getChainColour(token.tokenInfo.chainId)));
textIcon.setText(Utils.getIconisedText(token.tokenInfo.name));
}*/
public void setOnTokenClickListener(OnTokenClickListener onTokenClickListener) {
this.onTokenClickListener = onTokenClickListener;
}

@ -26,7 +26,7 @@ public class TokenListHolder extends BinderViewHolder<TokenCardMeta> implements
final SwitchMaterial switchEnabled;
final View overlay;
final TokenIcon tokenIcon;
int chainId;
long chainId;
//need to cache this locally, unless we cache every string we need in the constructor
private final AssetDefinitionService assetDefinition;

@ -9,6 +9,7 @@ import androidx.preference.PreferenceManager;
import com.alphawallet.app.BuildConfig;
import com.alphawallet.app.C;
import com.alphawallet.app.entity.UnableToResolveENS;
import com.alphawallet.app.service.OpenSeaService;
import com.alphawallet.app.util.das.DASBody;
import com.alphawallet.app.util.das.DASRecord;
import com.alphawallet.token.tools.Numeric;
@ -140,7 +141,7 @@ public class AWEnsResolver extends EnsResolver
{
if (matcher.find())
{
int chainId = Integer.parseInt(Objects.requireNonNull(matcher.group(2)));
long chainId = Long.parseLong(Objects.requireNonNull(matcher.group(2)));
String tokenAddress = Numeric.prependHexPrefix(matcher.group(6));
String tokenId = matcher.group(8);
@ -165,21 +166,10 @@ public class AWEnsResolver extends EnsResolver
return "";
}
private JSONObject fetchOpenseaAsset(int chainId, String tokenAddress, String tokenId)
private JSONObject fetchOpenseaAsset(long chainId, String tokenAddress, String tokenId)
{
String apiBase;
switch (chainId)
{
case 1:
apiBase = "https://api.opensea.io";
break;
case 4:
apiBase = "https://rinkeby-api.opensea.io";
break;
default:
return null;
}
String apiBase = OpenSeaService.apiMap.get(chainId);
if (apiBase == null) return null;
Request request = new Request.Builder()
.url(apiBase + "/api/v1/asset/" + tokenAddress + "/" + tokenId)

@ -295,7 +295,7 @@ public class EnsResolver {
}
private String callSmartContractFunction(
Function function, String contractAddress, int chainId) throws Exception
Function function, String contractAddress, long chainId) throws Exception
{
try
{
@ -314,7 +314,7 @@ public class EnsResolver {
}
}
private <T> T getContractData(int chainId, String address, Function function) throws Exception
private <T> T getContractData(long chainId, String address, Function function) throws Exception
{
String responseValue = callSmartContractFunction(function, address, chainId);

@ -157,7 +157,7 @@ public class QRParser {
{
try
{
int chainId = MagicLinkInfo.identifyChainId(data);
long chainId = MagicLinkInfo.identifyChainId(data);
if (chainId > 0) //see if it's a valid link
{

@ -197,72 +197,6 @@ public class Utils {
}
}
public static int getChainColour(int chainId)
{
switch (chainId)
{
case MAINNET_ID:
return R.color.mainnet;
case CLASSIC_ID:
return R.color.classic;
case POA_ID:
return R.color.poa;
case KOVAN_ID:
return R.color.kovan;
case ROPSTEN_ID:
return R.color.ropsten;
case SOKOL_ID:
return R.color.sokol;
case RINKEBY_ID:
return R.color.rinkeby;
case GOERLI_ID:
return R.color.goerli;
case XDAI_ID:
return R.color.xdai;
case ARTIS_SIGMA1_ID:
return R.color.artis_sigma1;
case ARTIS_TAU1_ID:
return R.color.artis_tau1;
case BINANCE_MAIN_ID:
return R.color.binance_main;
case BINANCE_TEST_ID:
return R.color.binance_test;
case HECO_ID:
return R.color.heco_main;
case HECO_TEST_ID:
return R.color.heco_test;
case FANTOM_ID:
return R.color.fantom_main;
case FANTOM_TEST_ID:
return R.color.fantom_test;
case AVALANCHE_ID:
return R.color.avalanche_main;
case FUJI_TEST_ID:
return R.color.avalanche_test;
case MATIC_ID:
return R.color.polygon_main;
case MATIC_TEST_ID:
return R.color.polygon_test;
case OPTIMISTIC_MAIN_ID:
return R.color.optimistic_main;
case OPTIMISTIC_TEST_ID:
return R.color.optimistic_test;
case CRONOS_TEST_ID:
return R.color.cronos_test;
case ARBITRUM_MAIN_ID:
return R.color.arbitrum_main;
case ARBITRUM_TEST_ID:
return R.color.arbitrum_test;
default:
return R.color.mine;
}
}
public static void setChainColour(View view, int chainId)
{
view.getBackground().setTint(ContextCompat.getColor(view.getContext(), getChainColour(chainId)));
}
/**
* This is here rather than in the Signable class because Signable is cross platform not Android specific
*
@ -411,11 +345,11 @@ public class Utils {
return address != null && address.length() > 0 && WalletUtils.isValidAddress(address);
}
public static String intArrayToString(Integer[] values)
public static String longArrayToString(Long[] values)
{
StringBuilder store = new StringBuilder();
boolean firstValue = true;
for (int network : values)
for (long network : values)
{
if (!firstValue) store.append(",");
store.append(network);
@ -425,17 +359,17 @@ public class Utils {
return store.toString();
}
public static List<Integer> intListToArray(String list)
public static List<Long> longListToArray(String list)
{
List<Integer> idList = new ArrayList<>();
List<Long> idList = new ArrayList<>();
//convert to array
String[] split = list.split(",");
for (String s : split)
{
Integer value;
Long value;
try
{
value = Integer.valueOf(s);
value = Long.valueOf(s);
idList.add(value);
}
catch (NumberFormatException e)
@ -847,40 +781,26 @@ public class Utils {
return "";
}
private static final Map<Long, String> twChainNames = new HashMap<Long, String>() {
{
put(CLASSIC_ID, "classic");
put(XDAI_ID, "xdai");
put(POA_ID, "poa");
put(BINANCE_MAIN_ID, "smartchain");
put(AVALANCHE_ID, "avalanche");
put(OPTIMISTIC_MAIN_ID, "optimism");
put(MATIC_ID, "polygon");
put(MAINNET_ID, "ethereum");
}
};
@NotNull
public static String getTWTokenImageUrl(int chainId, String address)
public static String getTWTokenImageUrl(long chainId, String address)
{
String tURL = TRUST_ICON_REPO;
String repoChain;
switch (chainId)
{
case CLASSIC_ID:
repoChain = "classic";
break;
case XDAI_ID:
repoChain = "xdai";
break;
case POA_ID:
repoChain = "poa";
break;
case BINANCE_MAIN_ID:
repoChain = "smartchain";
break;
case AVALANCHE_ID:
repoChain = "avalanche";
break;
case OPTIMISTIC_MAIN_ID:
repoChain = "optimism";
break;
case MATIC_ID:
repoChain = "polygon";
break;
default:
repoChain = "ethereum";
break;
}
String repoChain = twChainNames.get(chainId);
if (repoChain == null) repoChain = "ethereum";
tURL = tURL.replace(ICON_REPO_ADDRESS_TOKEN, address).replace(CHAIN_REPO_ADDRESS_TOKEN, repoChain);
return tURL;
}

@ -88,22 +88,12 @@ public class ActivityViewModel extends BaseViewModel
public void fetchMoreTransactions(long startTime)
{
List<Integer> currentChains = tokensService.getNetworkFilters();
List<Long> currentChains = tokensService.getNetworkFilters();
disposable = Observable.fromIterable(currentChains)
.flatMap(chainId -> transactionsService.fetchAndStoreTransactions(chainId, startTime).toObservable())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(activityItems::postValue, this::onError);
// disposable = transactionsService.fetchAndStoreTransactions(1, startTime)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(activityItems::postValue, this::onError);
// fetchTransactionsInteract.fetchTransactionMetas(wallet.getValue(), tokensService.getNetworkFilters(), startTime, TRANSACTION_FETCH_LIMIT)
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(activityItems::postValue, this::onError);
}
public void onDestroy()

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save