Skip to content

Commit

Permalink
check for init status
Browse files Browse the repository at this point in the history
  • Loading branch information
KorbinianK committed May 2, 2024
1 parent 6bd8044 commit f8cd7f4
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@ import type { FetchNftArgs } from '../types/common';

class MoralisNFTRepository implements INFTRepository {
private static instance: MoralisNFTRepository;
private static isInitialized = false;

private cursor: string;
private lastFetchedAddress: Address;
private hasFetchedAll: boolean;

private nfts: NFT[] = [];

private constructor() {
Moralis.start({
apiKey: MORALIS_API_KEY,
}).catch(console.error);
if (!MoralisNFTRepository.isInitialized) {
Moralis.start({ apiKey: MORALIS_API_KEY })
.then(() => {
MoralisNFTRepository.isInitialized = true;
})
.catch(console.error);
}

this.cursor = '';
this.lastFetchedAddress = zeroAddress;
Expand All @@ -38,7 +42,6 @@ class MoralisNFTRepository implements INFTRepository {

async findByAddress({ address, chainId, refresh = false }: FetchNftArgs): Promise<NFT[]> {
this.lastFetchedAddress = address;

if (refresh) {
this.reset();
}
Expand Down

0 comments on commit f8cd7f4

Please sign in to comment.