Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Release 1.5.1 #1459

Merged
merged 7 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
### Additions
- Security enhancement
- web3 library dependencies bump
- Transit to upgraded indexing services
## [v1.5.0] - 2024-03-12
### Additions
- Security enhancement on DApp Browser
Expand Down
8 changes: 4 additions & 4 deletions src/config/StaticAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { TestNetCroeseid5Config, MainNetConfig } from './StaticConfig';
export const STATIC_ASSET_COUNT = 4;

// Update Explorer Url - https://cronoscan.com
export const MAINNET_EVM_EXPLORER_URL = 'https://cronoscan.com';
export const MAINNET_EVM_EXPLORER_URL = 'https://explorer.cronos.org';
// There's no testnet explorer on cronoscan.com. Use cronos.org/explorer instead.
export const TESTNET_EVM_EXPLORER_URL = 'https://cronos.org/explorer/testnet3';
export const TESTNET_EVM_EXPLORER_URL = 'https://explorer.cronos.org/testnet';

export const MAINNET_ETHEREUM_EXPLORER_URL = 'https://etherscan.io';
export const ROPSTEN_ETHEREUM_EXPLORER_URL = 'https://ropsten.etherscan.io';
Expand Down Expand Up @@ -235,8 +235,8 @@ export const ETH_ASSET = (walletConfig: WalletConfig) => {

fee: { gasLimit: '50000', networkFee: '20000000000' },
indexingUrl: isTestnet
? 'https://eth-indexing.crypto.org/ethereum/goerli/api/v1'
: 'https://eth-indexing.crypto.org/ethereum/mainnet/api/v1',
? 'https://eth-indexing.crypto.org/ethereum/goerli/api/v2'
: 'https://eth-indexing.crypto.org/ethereum/mainnet/api/v2',
isLedgerSupportDisabled: false,
isStakingDisabled: false,
nodeUrl: isTestnet
Expand Down
2 changes: 0 additions & 2 deletions src/layouts/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,6 @@ function HomeLayout(props: HomeLayoutProps) {
: MAINNET_ETHEREUM_EXPLORER_URL;

setTimeout(async () => {

console.log('checkCorrectExplorerUrl', cronosTendermintAsset?.config?.explorerUrl, checkDefaultCronosPosExplorerUrl);
if (
!walletSession.activeAsset?.config?.explorer ||
// Check if explorerUrl has been updated with latest default
Expand Down
32 changes: 17 additions & 15 deletions src/service/TransactionHistoryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { croMarketPriceApi } from './rpc/MarketApi';
import { CronosNftIndexingAPI } from './rpc/indexing/nft/cronos/CronosNftIndexingAPI';
import {
checkIfTestnet,
getAllERC20WhiteListedAddress,
getCronosEvmAsset,
isCRC20AssetWhitelisted,
isERC20AssetWhitelisted,
Expand Down Expand Up @@ -334,18 +335,19 @@ export class TransactionHistoryService {
const txList = await ethClient.getTxsByAddress(currentAsset.address);

const loadedTxList = txList
.filter(
tx =>
tx.token_symbol === 'ETH' &&
(tx.type?.toLowerCase() === EthereumTransactionType.TRANSFER ||
tx.type?.toLowerCase() === EthereumTransactionType.UTF8TRANSFER),
)
// .filter(
// tx =>
// tx.method_id === ''
// // tx.token_symbol === 'ETH' &&
// // (tx.type?.toLowerCase() === EthereumTransactionType.TRANSFER ||
// // tx.type?.toLowerCase() === EthereumTransactionType.UTF8TRANSFER),
// )
.map(tx => {
const transferTx: TransferTransactionData = {
amount: tx.amount,
assetSymbol: tx.token_symbol,
amount: tx.value,
assetSymbol: 'ETH',
date: new Date(Number(tx.timestamp) * 1000).toISOString(),
hash: tx.transaction_hash,
hash: tx.hash,
memo: '',
receiverAddress: tx.to,
senderAddress: tx.from,
Expand All @@ -356,7 +358,7 @@ export class TransactionHistoryService {
walletId: walletIdentifier,
assetId: currentAsset.identifier,
assetType: currentAsset.assetType,
txHash: tx.transaction_hash,
txHash: tx.hash,
txType: EthereumTransactionType.TRANSFER,
txData: transferTx,
// TODO: add messageTypeName
Expand Down Expand Up @@ -860,9 +862,9 @@ export class TransactionHistoryService {

const ethClient = new EthClient(ethEvmAsset.config?.nodeUrl, ethEvmAsset.config?.indexingUrl);

// const allWhiteListedTokens = getAllERC20WhiteListedAddress();
const allWhiteListedTokens = getAllERC20WhiteListedAddress();
const tokensListResponse = await ethClient.getBalanceByAddress(address, {
// token: allWhiteListedTokens.slice(0, 20).join(','),
contract_addresses: allWhiteListedTokens.slice(0, 20).join(','),
});
const newlyLoadedTokens = await tokensListResponse
.filter(token => token.balance > 0 && token.token_addr !== 'ETH')
Expand Down Expand Up @@ -941,9 +943,9 @@ export class TransactionHistoryService {
if (asset.name.includes('Cronos')) {
await this.fetchCurrentWalletCRC20Tokens(asset, currentSession);
}
if (asset.name.includes('Ethereum')) {
await this.fetchCurrentWalletERC20Tokens(asset, currentSession);
}
// if (asset.name.includes('Ethereum')) {
// await this.fetchCurrentWalletERC20Tokens(asset, currentSession);
// }
break;
default:
break;
Expand Down
51 changes: 0 additions & 51 deletions src/service/ethereum/EthClient.spec.ts

This file was deleted.

59 changes: 54 additions & 5 deletions src/service/ethereum/EthClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class EthClient extends EVMClient implements IEthChainIndexAPI {
getETHBalanceByAddress = async (address: string): Promise<string> => {
const balanceResponse: AxiosResponse<BalancesByAddressResponse> = await axios({
baseURL: this.indexingBaseUrl,
url: `/address/${address.toLowerCase()}/balance`,
url: `/addresses/${address.toLowerCase()}/native_balance`,
});

if (balanceResponse.status !== 200) {
Expand All @@ -62,7 +62,7 @@ export class EthClient extends EVMClient implements IEthChainIndexAPI {
getBalanceByAddress = async (address: string, options?: balanceQueryBaseParams) => {
const balanceResponse: AxiosResponse<BalancesByAddressResponse> = await axios({
baseURL: this.indexingBaseUrl,
url: `/address/${address.toLowerCase()}/balance`,
url: `/addresses/${address.toLowerCase()}/token_balance`,
params: { ...options },
});

Expand All @@ -79,7 +79,7 @@ export class EthClient extends EVMClient implements IEthChainIndexAPI {

getTxsByAddress = async (address: string, options?: txQueryBaseParams) => {
// Pagination params
let currentPage = options?.page || 0;
let currentPage = options?.page || 1;
const limit = options?.pageSize || 100;

// Result
Expand All @@ -91,7 +91,6 @@ export class EthClient extends EVMClient implements IEthChainIndexAPI {
const txDataList = await this.getTxsByAddressPaginated(address, {
pageSize: limit,
page: currentPage,
sort: 'timestamp:desc',
});

// Append TxData list to the final response array
Expand All @@ -111,7 +110,7 @@ export class EthClient extends EVMClient implements IEthChainIndexAPI {
private getTxsByAddressPaginated = async (address: string, options?: txQueryBaseParams) => {
const txListResponse: AxiosResponse<TransactionsByAddressResponse> = await axios({
baseURL: this.indexingBaseUrl,
url: `/address/${address.toLowerCase()}/normal`,
url: `/addresses/${address.toLowerCase()}/transactions`,
params: { ...options },
});

Expand All @@ -134,4 +133,54 @@ export class EthClient extends EVMClient implements IEthChainIndexAPI {
getInternalTxsByAddress(address: string, options?: any) {
throw new Error('Method not implemented.');
}


getERC20TransfersByAddress = async (address: string, options?: txQueryBaseParams) => {
// Pagination params
let currentPage = options?.page || 1;
const limit = options?.pageSize || 100;

// Result
const finalList: TransactionData[] = [];

// eslint-disable-next-line no-constant-condition
while (true) {
// eslint-disable-next-line
const txDataList = await this.getERC20TransfersByAddressPaginated(address, {
pageSize: limit,
page: currentPage,
sort: 'timestamp:desc',
});

// Append TxData list to the final response array
finalList.push(...txDataList);

// Increment pagination params
currentPage += 1;

if (txDataList.length < 1 || txDataList.length < limit) {
break;
}
}

return finalList;
};

private getERC20TransfersByAddressPaginated = async (address: string, options?: txQueryBaseParams) => {
const txListResponse: AxiosResponse<TransactionsByAddressResponse> = await axios({
baseURL: this.indexingBaseUrl,
url: `/addresses/${address.toLowerCase()}/transfers`,
params: { ...options },
});

if (txListResponse.status !== 200) {
return [];
}

if (!txListResponse.data.data) {
return [];
}

return txListResponse.data.data as TransactionData[];
};
}
Loading
Loading