From 47aca9a31980f7fdc0f20dba1514553b76bcb8dc Mon Sep 17 00:00:00 2001 From: Mark Nardi Date: Mon, 8 Jul 2024 15:38:34 +0200 Subject: [PATCH] set correct token standard --- .../activity/components/AssetPillsForActivity.svelte | 11 ++++++++--- .../types/evm/evm-token-approval-activity.type.ts | 7 ++++++- .../getSmartContractDataFromBlockscoutTransaction.ts | 7 ++++++- .../interfaces/parsed-contract-data.interface.ts | 4 ++-- .../parseSmartContractDataFromTransactionData.ts | 6 ++++-- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/packages/desktop/views/dashboard/wallet/tab-section/activity/components/AssetPillsForActivity.svelte b/packages/desktop/views/dashboard/wallet/tab-section/activity/components/AssetPillsForActivity.svelte index 702f90167c..80982c8d26 100644 --- a/packages/desktop/views/dashboard/wallet/tab-section/activity/components/AssetPillsForActivity.svelte +++ b/packages/desktop/views/dashboard/wallet/tab-section/activity/components/AssetPillsForActivity.svelte @@ -3,7 +3,7 @@ import { Pill } from '@bloomwalletio/ui' import { Activity, StardustActivityType, isEvmTokenActivity } from '@core/activity' import { getTokenFromActivity } from '@core/activity/utils/getTokenFromActivity' - import { BASE_TOKEN_ID } from '@core/token' + import { BASE_TOKEN_ID, TokenStandard } from '@core/token' import { getNftByIdForAccount } from '@core/nfts/stores' import { selectedAccountIndex } from '@core/account/stores' import { NetworkNamespace } from '@core/network/enums' @@ -53,8 +53,13 @@ standardPill = '' } else if (isEvmTokenActivity(activity)) { const standard = activity.tokenTransfer.standard - standardPill = standard - typePill = standard === NftStandard.Erc721 || standard === NftStandard.Irc27 ? 'nft' : 'token' + standardPill = standard === TokenStandard.BaseToken ? '' : standard + typePill = + standard === NftStandard.Erc721 || standard === NftStandard.Irc27 + ? 'nft' + : standard === TokenStandard.BaseToken + ? 'baseCoin' + : 'token' } else if (activity.type === EvmActivityType.ContractCall) { typePill = '' standardPill = convertCamelCaseToPhrase(activity.method ?? '') diff --git a/packages/shared/src/lib/core/activity/types/evm/evm-token-approval-activity.type.ts b/packages/shared/src/lib/core/activity/types/evm/evm-token-approval-activity.type.ts index 8a13180089..a2925821b2 100644 --- a/packages/shared/src/lib/core/activity/types/evm/evm-token-approval-activity.type.ts +++ b/packages/shared/src/lib/core/activity/types/evm/evm-token-approval-activity.type.ts @@ -7,7 +7,12 @@ import { IParsedInput } from '@core/layer-2/interfaces' export type EvmTokenApprovalActivity = BaseEvmActivity & { type: EvmActivityType.TokenApproval tokenTransfer: { - standard: TokenStandard.Erc20 | TokenStandard.Irc30 | NftStandard.Irc27 | NftStandard.Erc721 + standard: + | TokenStandard.BaseToken + | TokenStandard.Erc20 + | TokenStandard.Irc30 + | NftStandard.Irc27 + | NftStandard.Erc721 tokenId: string rawAmount: bigint } diff --git a/packages/shared/src/lib/core/activity/utils/evm/getSmartContractDataFromBlockscoutTransaction.ts b/packages/shared/src/lib/core/activity/utils/evm/getSmartContractDataFromBlockscoutTransaction.ts index 71fdbe2bdc..65009264a4 100644 --- a/packages/shared/src/lib/core/activity/utils/evm/getSmartContractDataFromBlockscoutTransaction.ts +++ b/packages/shared/src/lib/core/activity/utils/evm/getSmartContractDataFromBlockscoutTransaction.ts @@ -25,7 +25,12 @@ export function getSmartContractDataFromBlockscoutTransaction( | undefined let tokenTransfer: | { - standard: TokenStandard.Erc20 | TokenStandard.Irc30 | NftStandard.Irc27 | NftStandard.Erc721 + standard: + | TokenStandard.BaseToken + | TokenStandard.Erc20 + | TokenStandard.Irc30 + | NftStandard.Irc27 + | NftStandard.Erc721 tokenId: string rawAmount: bigint } diff --git a/packages/shared/src/lib/core/layer-2/interfaces/parsed-contract-data.interface.ts b/packages/shared/src/lib/core/layer-2/interfaces/parsed-contract-data.interface.ts index e62a8d4802..8f2e2e526b 100644 --- a/packages/shared/src/lib/core/layer-2/interfaces/parsed-contract-data.interface.ts +++ b/packages/shared/src/lib/core/layer-2/interfaces/parsed-contract-data.interface.ts @@ -9,7 +9,7 @@ export interface IParsedCoinTransfer extends Omit { type: ParsedSmartContractType.TokenTransfer - standard: TokenStandard.Erc20 | TokenStandard.Irc30 + standard: TokenStandard.Erc20 | TokenStandard.Irc30 | TokenStandard.BaseToken tokenId: string rawAmount: bigint } @@ -22,7 +22,7 @@ export interface IParsedNftTransfer extends Omit { type: ParsedSmartContractType.TokenApproval - standard: TokenStandard.Erc20 + standard: TokenStandard.Erc20 | TokenStandard.BaseToken spender: string tokenId: string rawAmount: bigint diff --git a/packages/shared/src/lib/core/layer-2/utils/parseSmartContractDataFromTransactionData.ts b/packages/shared/src/lib/core/layer-2/utils/parseSmartContractDataFromTransactionData.ts index d5efb3a2d5..0e038a3650 100644 --- a/packages/shared/src/lib/core/layer-2/utils/parseSmartContractDataFromTransactionData.ts +++ b/packages/shared/src/lib/core/layer-2/utils/parseSmartContractDataFromTransactionData.ts @@ -176,11 +176,13 @@ function parseSmartContractDataWithErc20Abi( inputs: Object.values(decodedData.inputs), } + const standard = recipientAddress === ISC_BASE_COIN_ADDRESS ? TokenStandard.BaseToken : TokenStandard.Erc20 + switch (decodedData.name) { case 'transfer': { return { type: ParsedSmartContractType.TokenTransfer, - standard: TokenStandard.Erc20, + standard, tokenId: recipientAddress, rawAmount: BigInt(decodedData.inputs._value.value), rawData, @@ -192,7 +194,7 @@ function parseSmartContractDataWithErc20Abi( case 'approve': { return { type: ParsedSmartContractType.TokenApproval, - standard: TokenStandard.Erc20, + standard, tokenId: recipientAddress, spender: decodedData.inputs._spender.value, rawAmount: BigInt(decodedData.inputs._value.value),