Skip to content

Commit

Permalink
feat: map ckErc20 transaction for display (dfinity#1214)
Browse files Browse the repository at this point in the history
* feat: map ckErc20 transaction for display

* feat: map ckErc20 transaction for display
  • Loading branch information
peterpeterparker authored Apr 23, 2024
1 parent 35b43b6 commit 9305c01
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/frontend/src/icp/utils/cketh-transactions.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
uint8ArrayToHexString
} from '@dfinity/utils';

export const mapCkETHTransaction = ({
export const mapCkEthereumTransaction = ({
transaction,
identity,
ledgerCanisterId
Expand Down
12 changes: 8 additions & 4 deletions src/frontend/src/icp/utils/ic-transactions.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import type {
IcTransactionUi
} from '$icp/types/ic';
import { extendCkBTCTransaction, mapCkBTCTransaction } from '$icp/utils/ckbtc-transactions.utils';
import { mapCkETHTransaction } from '$icp/utils/cketh-transactions.utils';
import { isTokenCkBtcLedger, isTokenCkEthLedger } from '$icp/utils/ic-send.utils';
import { mapCkEthereumTransaction } from '$icp/utils/cketh-transactions.utils';
import {
isTokenCkBtcLedger,
isTokenCkErc20Ledger,
isTokenCkEthLedger
} from '$icp/utils/ic-send.utils';
import { mapIcpTransaction } from '$icp/utils/icp-transactions.utils';
import { mapIcrcTransaction } from '$icp/utils/icrc-transactions.utils';
import type { OptionIdentity } from '$lib/types/identity';
Expand Down Expand Up @@ -40,8 +44,8 @@ export const mapIcTransaction = ({
});
}

if (isTokenCkEthLedger(token)) {
return mapCkETHTransaction({
if (isTokenCkEthLedger(token) || isTokenCkErc20Ledger(token)) {
return mapCkEthereumTransaction({
transaction: transaction as IcrcTransaction,
ledgerCanisterId: (token as IcCkToken).ledgerCanisterId,
...rest
Expand Down
12 changes: 8 additions & 4 deletions src/frontend/src/icp/workers/icrc-wallet.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import type { SchedulerJobData, SchedulerJobParams } from '$icp/schedulers/sched
import { WalletScheduler } from '$icp/schedulers/wallet.scheduler';
import type { IcTransactionUi } from '$icp/types/ic';
import { mapCkBTCTransaction } from '$icp/utils/ckbtc-transactions.utils';
import { mapCkETHTransaction } from '$icp/utils/cketh-transactions.utils';
import { isTokenCkBtcLedger, isTokenCkEthLedger } from '$icp/utils/ic-send.utils';
import { mapCkEthereumTransaction } from '$icp/utils/cketh-transactions.utils';
import {
isTokenCkBtcLedger,
isTokenCkErc20Ledger,
isTokenCkEthLedger
} from '$icp/utils/ic-send.utils';
import { mapIcrcTransaction, mapTransactionIcrcToSelf } from '$icp/utils/icrc-transactions.utils';
import type { PostMessage, PostMessageDataRequestIcrc } from '$lib/types/post-message';
import {
Expand Down Expand Up @@ -44,8 +48,8 @@ const mapTransaction = ({
return mapCkBTCTransaction({ transaction, identity, ...ledgerId });
}

if (nonNullish(ledgerId) && isTokenCkEthLedger(ledgerId)) {
return mapCkETHTransaction({ transaction, identity, ...ledgerId });
if (nonNullish(ledgerId) && (isTokenCkEthLedger(ledgerId) || isTokenCkErc20Ledger(ledgerId))) {
return mapCkEthereumTransaction({ transaction, identity, ...ledgerId });
}

return mapIcrcTransaction({ transaction, identity });
Expand Down

0 comments on commit 9305c01

Please sign in to comment.