Skip to content

Commit

Permalink
fix itheum coalition delegations
Browse files Browse the repository at this point in the history
  • Loading branch information
michavie committed Jan 2, 2024
1 parent b5f2294 commit 77144b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/extensions/itheum/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ export const fetchDataNft = async (app: AppContextValue, collectionId: string, n
return nft
}

export const fetchDataNftsOfAccount = async (app: AppContextValue, customCollections: string[] = []) => {
export const fetchDataNftsOfAccount = async (
app: AppContextValue,
address: string,
customCollections: string[] = []
) => {
const defaultCollection = Config.DataNftCollection(app.config.network)
const collections = [defaultCollection, ...customCollections]
const collections = [...new Set([defaultCollection, ...customCollections])]

const res: any[] = await app.networkProvider.doGetGeneric(
`accounts/${app.config.entity.address}/nfts?size=10000&collections=${collections.join(',')}&withSupply=true`
`accounts/${address}/nfts?size=10000&collections=${collections.join(',')}&withSupply=true`
)

const nftMintAbiRes = await fetch(Config.Abis.DataNft)
Expand Down
6 changes: 3 additions & 3 deletions src/extensions/itheum/src/coalition/Delegator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ export function Delegator(props: Props) {
}, [app.config.user])

useEffect(() => {
if (!appInfo) return
fetchDataNftsOfAccount(app, appInfo?.dataCollections).then((data) => {
if (!appInfo || !app.config.user) return
fetchDataNftsOfAccount(app, app.config.user.address, appInfo?.dataCollections).then((data) => {
const allowed = collect(data).filter((x) => appInfo.dataCollections.includes(x.collection))
setUserCollections(allowed.groupBy('collection').all() as any)
})
}, [appInfo])
}, [appInfo, app.config.user])

const toggleDelegate = (nft: DataNftMetadata) => {
setSelectedUndelegate({})
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/itheum/src/wallet/WalletTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function WalletTab(props: Props) {
const [nfts, setNfts] = useState<DataNftMetadata[]>([])

useEffect(() => {
fetchDataNftsOfAccount(app).then((nfts) => setNfts(nfts))
fetchDataNftsOfAccount(app, app.config.entity.address).then((nfts) => setNfts(nfts))
}, [])

return (
Expand Down

0 comments on commit 77144b0

Please sign in to comment.