Skip to content

Commit

Permalink
Merge pull request #53 from lum-network/improvement/lum-876
Browse files Browse the repository at this point in the history
[LUM-876] Fix temporary code
  • Loading branch information
ThibaultJRD authored Feb 1, 2024
2 parents 66d0973 + 9d8d3f9 commit 2a288f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 28 deletions.
10 changes: 10 additions & 0 deletions src/pages/MySavings/components/DepositTable/DepositTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ const DepositTable = ({ deposits, pools, prices, onLeavePool, onDepositRetry, on
break;

case DepositState.DEPOSIT_STATE_IBC_TRANSFER:
// If the deposit is older than 1 hour, we consider it as failed
if (deposit.updatedAt && dayjs().diff(dayjs(deposit.updatedAt), 'hours') > 1) {
statusClassName = 'failure';
cta = <Button onClick={() => onDepositRetry(deposit as DepositModel)}>{I18n.t('common.retry')}</Button>;
} else {
statusClassName = 'pending';
cta = I18n.t('mySavings.transferWaitingCta');
}
break;

case DepositState.DEPOSIT_STATE_ICA_DELEGATE:
statusClassName = 'pending';
cta = I18n.t('mySavings.transferWaitingCta');
Expand Down
31 changes: 3 additions & 28 deletions src/utils/lumClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { formatTxs } from './txs';
import { getDenomFromIbc } from './denoms';
import { ApiConstants } from 'constant';
import { LumApi } from 'api';
import { Deposit, DepositState } from '@lum-network/sdk-javascript/build/codec/lum/network/millions/deposit';
import { DepositState } from '@lum-network/sdk-javascript/build/codec/lum/network/millions/deposit';
import { QueryDepositsResponse, QueryWithdrawalsResponse } from '@lum-network/sdk-javascript/build/codec/lum/network/millions/query';
import { Withdrawal, WithdrawalState } from '@lum-network/sdk-javascript/build/codec/lum/network/millions/withdrawal';

Expand Down Expand Up @@ -115,23 +115,8 @@ class LumClient {

while (true) {
const resDeposits: QueryDepositsResponse = await this.client.queryClient.millions.accountDeposits(address, pageDeposits);
const fixedDeposits: Deposit[] = [];

//FIXME: remove this when the chain is fixed
for (const deposit of resDeposits.deposits) {
if (deposit.state !== DepositState.DEPOSIT_STATE_SUCCESS) {
const fixedDeposit = await this.client?.queryClient.millions.poolDeposit(Long.fromNumber(2), deposit.depositId);

if (fixedDeposit) {
fixedDeposits.push(fixedDeposit);
continue;
}
}

fixedDeposits.push(deposit);
}

deposits.push(...fixedDeposits);
deposits.push(...resDeposits.deposits);

// If we have pagination key, we just patch it, and it will process in the next loop
if (resDeposits.pagination && resDeposits.pagination.nextKey && resDeposits.pagination.nextKey.length) {
Expand All @@ -148,18 +133,8 @@ class LumClient {

while (true) {
const resWithdrawals: QueryWithdrawalsResponse = await this.client.queryClient.millions.accountWithdrawals(address, pageWithdrawals);
const fixedWithdrawals: Withdrawal[] = [];

//FIXME: remove this when the chain is fixed
for (const withdrawal of resWithdrawals.withdrawals) {
const fixedWithdrawal = await this.client?.queryClient.millions.poolWithdrawal(Long.fromNumber(2), withdrawal.withdrawalId);

if (fixedWithdrawal) {
fixedWithdrawals.push(fixedWithdrawal);
}
}

withdrawals.push(...fixedWithdrawals);
withdrawals.push(...resWithdrawals.withdrawals);

// If we have pagination key, we just patch it, and it will process in the next loop
if (resWithdrawals.pagination && resWithdrawals.pagination.nextKey && resWithdrawals.pagination.nextKey.length) {
Expand Down

0 comments on commit 2a288f0

Please sign in to comment.