Skip to content

Commit

Permalink
set correct token standard
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkNerdi committed Jul 8, 2024
1 parent 3fa8484 commit 47aca9a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 ?? '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface IParsedCoinTransfer extends Omit<IParsedSmartContractData, 'typ

export interface IParsedTokenTransfer extends Omit<IParsedSmartContractData, 'type'> {
type: ParsedSmartContractType.TokenTransfer
standard: TokenStandard.Erc20 | TokenStandard.Irc30
standard: TokenStandard.Erc20 | TokenStandard.Irc30 | TokenStandard.BaseToken
tokenId: string
rawAmount: bigint
}
Expand All @@ -22,7 +22,7 @@ export interface IParsedNftTransfer extends Omit<IParsedSmartContractData, 'type

export interface IParsedTokenApproval extends Omit<IParsedSmartContractData, 'type'> {
type: ParsedSmartContractType.TokenApproval
standard: TokenStandard.Erc20
standard: TokenStandard.Erc20 | TokenStandard.BaseToken
spender: string
tokenId: string
rawAmount: bigint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down

0 comments on commit 47aca9a

Please sign in to comment.