Skip to content

Commit

Permalink
- Fixed deprecated API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Svirsky committed Jan 31, 2024
1 parent 7125296 commit 0c63fd6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### vNext

- Fixed fractional Matic balance transfer issue
- Updated Freeport URLs
- Fixed deprecated API usage

### v1.29.0

Expand Down
2 changes: 1 addition & 1 deletion src/api/freeport-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class FreeportApiService {

public static async getMinterCollections(minter: string): Promise<FreeportCollectionInterface[]> {
try {
const { data } = await api.get<FreeportCollectionInterface[]>(`/wallet/${minter}/collections`);
const { data } = await api.get<FreeportCollectionInterface[]>(`/api/wallet/${minter}/collections`);
return Array.isArray(data) ? data.filter((item: unknown) => freeportCollectionValidator(item)) : [];
} catch (err: any) {
reportError(err);
Expand Down
9 changes: 3 additions & 6 deletions src/api/interfaces/freeport-nft.interface.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
export interface FreeportNftInterface {
nftId: string;
minter: string;
collectionAddress: string | null;
supply: number;
quantity: number;
priceInUsdCents: number;
priceInCereUnits: number;
collection: {
address: string;
};
}
11 changes: 5 additions & 6 deletions src/api/validators/freeport-nft.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import * as yup from 'yup';

let schema = yup.object().shape({
nftId: yup.string().required(),
minter: yup.string().required(),
collectionAddress: yup.string().nullable(true),
supply: yup.number().required(),
quantity: yup.number().required(),
priceInUsdCents: yup.number().required(),
priceInCereUnits: yup.number().required(),
collection: yup
.object({
address: yup.string().required(),
})
.required(),
});

export const freeportNftValidator = (data: unknown): data is FreeportNftInterface => {
Expand Down
10 changes: 5 additions & 5 deletions src/stores/CollectiblesStore/CollectionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class CollectiblesStore {

const freeportNfts = await FreeportApiService.getWalletNftList(wallet);
const nftIds: string[] = freeportNfts.map((nft) => nft.nftId);
const minters: string[] = freeportNfts.map((nft) => nft.minter);
const minters: string[] = freeportNfts.map((nft) => '').filter(Boolean);
const cids = await Promise.all(nftIds.map(FreeportApiService.getNftCids));
const assets = await Promise.all(cids.map((cid, i) => DdcApiService.getAssetInfo(minters[i], cid[0])));
const collections = await Promise.all(Array.from(new Set(minters)).map(FreeportApiService.getMinterCollections));
Expand All @@ -66,15 +66,15 @@ export class CollectiblesStore {

const result = freeportNfts.map((nft, i) => ({
nftId: nft.nftId,
minter: nft.minter,
minter: '', // TODO: Add to the API
title: assets[i]?.contentMetadata?.title || nft.nftId,
description: assets[i]?.contentMetadata?.description,
previewUrl:
cids[i]?.length > 0 ? `${REACT_APP_DDC_API}/assets/v2/${minters[i]}/${cids[i][0]}/preview` : undefined,
network: 'CERE',
collectionAddress: nft.collectionAddress ? nft.collectionAddress : undefined,
collectionName: nft.collectionAddress ? collectionKeyMap[nft.collectionAddress] : undefined,
quantity: nft.quantity,
collectionAddress: nft.collection ? nft.collection.address : undefined,
collectionName: nft.collection ? collectionKeyMap[nft.collection.address] : undefined,
quantity: 0, // TODO: Add to the API
}));

runInAction(() => {
Expand Down

0 comments on commit 0c63fd6

Please sign in to comment.