Skip to content

Commit

Permalink
feat: update REG and RWA type to support new filter
Browse files Browse the repository at this point in the history
  • Loading branch information
NandyBa committed Dec 17, 2024
1 parent 2b0db53 commit 9732cad
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { useTranslation } from 'react-i18next'
import { Select } from '@mantine/core'

import {
RWARealtoken,
OtherRealtoken,
UserRealtoken,
} from 'src/store/features/wallets/walletsSelector'
import { APIRealTokenProductType } from 'src/types/APIRealToken'

import { useInputStyles } from '../../inputs/useInputStyles'
import { AssetProductType } from '../types'
Expand Down Expand Up @@ -57,19 +58,18 @@ export const AssetsViewProductTypeFilter: FC<
AssetsViewProductTypeFilter.displayName = 'AssetsViewProductTypeFilter'

export function useAssetsViewProductTypeFilter(filter: AssetsViewFilterType) {
function assetProductTypeFilterFunction(asset: UserRealtoken | RWARealtoken) {
const Asset = asset as UserRealtoken
function assetProductTypeFilterFunction(
asset: UserRealtoken | OtherRealtoken,
) {
switch (filter.productType) {
case AssetProductType.ALL:
return true
case AssetProductType.REAL_EASTATE_RENTAL:
return (
String(Asset.productType) === AssetProductType.REAL_EASTATE_RENTAL
)
return asset.productType === APIRealTokenProductType.RealEstateRental
case AssetProductType.LOAN_INCOME:
return String(Asset.productType) === AssetProductType.LOAN_INCOME
return asset.productType === APIRealTokenProductType.LoanIncome
case AssetProductType.EQUITY_TOKEN:
return String(Asset.productType) === AssetProductType.EQUITY_TOKEN
return asset.productType === APIRealTokenProductType.EquityToken
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useREG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
selectUserIncludesEth,
} from 'src/store/features/settings/settingsSelector'
import { REGRealtoken } from 'src/store/features/wallets/walletsSelector'
import { APIRealTokenProductType } from 'src/types/APIRealToken'
import { Currency } from 'src/types/Currencies'
import { ERC20ABI } from 'src/utils/blockchain/abi/ERC20ABI'
import {
Expand Down Expand Up @@ -147,6 +148,7 @@ const getREG = async (
id: `${REG_asset_ID}`,
fullName: 'RealToken Ecosystem Governance',
shortName: 'REG',
productType: APIRealTokenProductType.EquityToken,
amount,
tokenPrice,
totalTokens,
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useREGVotingPower.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Contract } from 'ethers'
import { initializeProviders } from 'src/repositories/RpcProvider'
import { selectUserAddressList } from 'src/store/features/settings/settingsSelector'
import { REGVotingPowertoken } from 'src/store/features/wallets/walletsSelector'
import { APIRealTokenProductType } from 'src/types/APIRealToken'
import { ERC20ABI } from 'src/utils/blockchain/abi/ERC20ABI'
import {
DEFAULT_REGVotingPower_PRICE,
Expand Down Expand Up @@ -44,6 +45,7 @@ const getRegVotingPower = async (
id: `${REGVotingPower_asset_ID}`,
fullName: 'REG Voting Power Registry',
shortName: 'REG VOTING POWER',
productType: APIRealTokenProductType.EquityToken,
amount,
tokenPrice,
totalTokens,
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useRWA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
selectUserAddressList, // selectUserIncludesEth,
} from 'src/store/features/settings/settingsSelector'
import { RWARealtoken } from 'src/store/features/wallets/walletsSelector'
import { APIRealTokenProductType } from 'src/types/APIRealToken'
import { Currency } from 'src/types/Currencies'
import { ERC20ABI } from 'src/utils/blockchain/abi/ERC20ABI'
import {
Expand Down Expand Up @@ -98,6 +99,7 @@ const getRWA = async (
shortName: 'RWA',
amount,
tokenPrice,
productType: APIRealTokenProductType.EquityToken,
totalTokens,
imageLink: [
'https://realt.co/wp-content/uploads/2024/02/Equity_FinalDesign-2000px-800x542.png',
Expand Down
7 changes: 6 additions & 1 deletion src/store/features/wallets/walletsSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ import _max from 'lodash/max'
import _sumBy from 'lodash/sumBy'
import moment from 'moment'

import { AssetProductType } from 'src/components/assetsView'
import { WalletBalances, WalletType } from 'src/repositories'
import { UserRealTokenTransfer } from 'src/repositories/transfers/transfers.type'
import { RootState } from 'src/store/store'
import { APIRealTokenDate } from 'src/types/APIRealToken'
import {
APIRealTokenDate,
APIRealTokenProductType,
} from 'src/types/APIRealToken'
import { RealToken, RealTokenCanal } from 'src/types/RealToken'
import {
RentCalculation,
Expand Down Expand Up @@ -42,6 +46,7 @@ export interface OtherRealtoken {
id: string
fullName: string
shortName: string
productType: APIRealTokenProductType
amount: number
value: number
tokenPrice: number
Expand Down
81 changes: 79 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,11 @@
"@noble/hashes" "~1.3.0"
"@scure/base" "~1.1.0"

"@sindresorhus/merge-streams@^2.1.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/merge-streams/-/merge-streams-2.3.0.tgz#719df7fb41766bc143369eaa0dd56d8dc87c9958"
integrity sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==

"@solana/buffer-layout@^4.0.1":
version "4.0.1"
resolved "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz"
Expand Down Expand Up @@ -2780,6 +2785,26 @@ defu@^6.1.2, defu@^6.1.3:
resolved "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz"
integrity sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==

del-cli@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/del-cli/-/del-cli-6.0.0.tgz#7822d0ffd5b73449a506a586d839711485bfb119"
integrity sha512-9nitGV2W6KLFyya4qYt4+9AKQFL+c0Ehj5K7V7IwlxTc6RMCfQUGY9E9pLG6e8TQjtwXpuiWIGGZb3mfVxyZkw==
dependencies:
del "^8.0.0"
meow "^13.2.0"

del@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/del/-/del-8.0.0.tgz#f333a5673cfeb72e46084031714a7c30515e80aa"
integrity sha512-R6ep6JJ+eOBZsBr9esiNN1gxFbZE4Q2cULkUSFumGYecAiS6qodDvcPx/sFuWHMNul7DWmrtoEOpYSm7o6tbSA==
dependencies:
globby "^14.0.2"
is-glob "^4.0.3"
is-path-cwd "^3.0.0"
is-path-inside "^4.0.0"
p-map "^7.0.2"
slash "^5.1.0"

delay@^5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz"
Expand Down Expand Up @@ -3401,9 +3426,9 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
resolved "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==

fast-glob@^3.2.11, fast-glob@^3.2.9:
fast-glob@^3.2.11, fast-glob@^3.2.9, fast-glob@^3.3.2:
version "3.3.2"
resolved "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129"
integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==
dependencies:
"@nodelib/fs.stat" "^2.0.2"
Expand Down Expand Up @@ -3652,6 +3677,18 @@ globby@^11.1.0:
merge2 "^1.4.1"
slash "^3.0.0"

globby@^14.0.2:
version "14.0.2"
resolved "https://registry.yarnpkg.com/globby/-/globby-14.0.2.tgz#06554a54ccfe9264e5a9ff8eded46aa1e306482f"
integrity sha512-s3Fq41ZVh7vbbe2PN3nrW7yC7U7MFVc5c98/iTl9c2GawNMKx/J648KQRW6WKkuU8GIbbh2IXfIRQjOZnXcTnw==
dependencies:
"@sindresorhus/merge-streams" "^2.1.0"
fast-glob "^3.3.2"
ignore "^5.2.4"
path-type "^5.0.0"
slash "^5.1.0"
unicorn-magic "^0.1.0"

gopd@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz"
Expand Down Expand Up @@ -3824,6 +3861,11 @@ ignore@^5.2.0:
resolved "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz"
integrity sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==

ignore@^5.2.4:
version "5.3.2"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.2.tgz#3cd40e729f3643fd87cb04e50bf0eb722bc596f5"
integrity sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==

immer@^10.0.3:
version "10.0.3"
resolved "https://registry.npmjs.org/immer/-/immer-10.0.3.tgz"
Expand Down Expand Up @@ -4031,11 +4073,21 @@ is-number@^7.0.0:
resolved "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz"
integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==

is-path-cwd@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-3.0.0.tgz#889b41e55c8588b1eb2a96a61d05740a674521c7"
integrity sha512-kyiNFFLU0Ampr6SDZitD/DwUo4Zs1nSdnygUBqsu3LooL00Qvb5j+UnvApUn/TTj1J3OuE6BTdQ5rudKmU2ZaA==

is-path-inside@^3.0.3:
version "3.0.3"
resolved "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz"
integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==

is-path-inside@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-4.0.0.tgz#805aeb62c47c1b12fc3fd13bfb3ed1e7430071db"
integrity sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==

is-regex@^1.1.4:
version "1.1.4"
resolved "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz"
Expand Down Expand Up @@ -4460,6 +4512,11 @@ match-sorter@^6.0.2:
"@babel/runtime" "^7.23.8"
remove-accents "0.5.0"

meow@^13.2.0:
version "13.2.0"
resolved "https://registry.yarnpkg.com/meow/-/meow-13.2.0.tgz#6b7d63f913f984063b3cc261b6e8800c4cd3474f"
integrity sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==

merge-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz"
Expand Down Expand Up @@ -4828,6 +4885,11 @@ p-locate@^5.0.0:
dependencies:
p-limit "^3.0.2"

p-map@^7.0.2:
version "7.0.3"
resolved "https://registry.yarnpkg.com/p-map/-/p-map-7.0.3.tgz#7ac210a2d36f81ec28b736134810f7ba4418cdb6"
integrity sha512-VkndIv2fIB99swvQoA65bm+fsmt6UNdGeIB0oxBs+WhAhdh08QA04JXpI7rbB9r08/nkbysKoya9rtDERYOYMA==

p-try@^2.0.0:
version "2.2.0"
resolved "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz"
Expand Down Expand Up @@ -4875,6 +4937,11 @@ path-type@^4.0.0:
resolved "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz"
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==

path-type@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/path-type/-/path-type-5.0.0.tgz#14b01ed7aea7ddf9c7c3f46181d4d04f9c785bb8"
integrity sha512-5HviZNaZcfqP95rwpv+1HDgUamezbqdSYTyzjTvwtJSnIH+3vnbmWsItli8OFEndS984VT55M3jduxZbX351gg==

pathe@^1.1.0, pathe@^1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/pathe/-/pathe-1.1.1.tgz"
Expand Down Expand Up @@ -5503,6 +5570,11 @@ slash@^3.0.0:
resolved "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz"
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==

slash@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-5.1.0.tgz#be3adddcdf09ac38eebe8dcdc7b1a57a75b095ce"
integrity sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==

sonic-boom@^2.2.1:
version "2.8.0"
resolved "https://registry.npmjs.org/sonic-boom/-/sonic-boom-2.8.0.tgz"
Expand Down Expand Up @@ -5899,6 +5971,11 @@ unfetch@^4.2.0:
resolved "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz"
integrity sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA==

unicorn-magic@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/unicorn-magic/-/unicorn-magic-0.1.0.tgz#1bb9a51c823aaf9d73a8bfcd3d1a23dde94b0ce4"
integrity sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==

[email protected]:
version "2.2.0"
resolved "https://registry.npmjs.org/unload/-/unload-2.2.0.tgz"
Expand Down

0 comments on commit 9732cad

Please sign in to comment.