Skip to content

Commit

Permalink
fix: added api FastNear
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenary committed Oct 10, 2024
1 parent d2f55ef commit 96525db
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const networks: Record<NetworkId, Network> = {
apiNearBlocks: 'https://api.nearblocks.io',
ftContract: 'tkn.primitives.near',
nftContract: 'nft.primitives.near',
fastNearApi: 'https://api.fastnear.com',
},
testnet: {
networkId: 'testnet',
Expand All @@ -50,6 +51,7 @@ export const networks: Record<NetworkId, Network> = {
apiNearBlocks: 'https://api-testnet.nearblocks.io',
ftContract: 'tkn.primitives.testnet',
nftContract: 'nft.primitives.testnet',
fastNearApi: 'https://test.api.fastnear.com',
},

// localnet: {
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useNFT.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback, useContext, useEffect, useState } from 'react';

import { NearContext } from '@/components/wallet-selector/WalletSelector';
import { network } from '@/config';
import type { Metadata, NFT } from '@/utils/types';

export interface Fastnear {
Expand All @@ -22,7 +23,7 @@ export interface NFTConsult {
}

export const accounts_nft = async (accountId: string): Promise<Fastnear> => {
const response = await fetch(`https://api.fastnear.com/v1/account/${accountId}/nft`);
const response = await fetch(`${network.fastNearApi}/v1/account/${accountId}/nft`);
return await response.json();
};

Expand Down
7 changes: 6 additions & 1 deletion src/hooks/useNearBlocksTxns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ const useNearBlocksTxns = (contract: string, method: string) => {
throw new Error('Network response was not ok');
}
const data = await response.json();
console.log(
'pepe grillo',
data.txns.filter((txn: Txns) => txn.outcomes.status),
);

setTransactions(data.txns.filter((txn: Txns) => txn.outcomes.status));
setLoading(false);
} catch (err) {
Expand All @@ -96,7 +101,7 @@ const useNearBlocksTxns = (contract: string, method: string) => {
if (!wallet || !signedAccountId) return;
fetchTransactions();
}, [contract, method, wallet, signedAccountId, fetchTransactions]);

console.log('pepe grillo trans', transactions);
return { transactions, loading, error, reloadTokens: fetchTransactions };
};

Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useCallback, useContext, useEffect, useState } from 'react';

import NearIconSvg from '@/components/sidebar-navigation/icons/near-icon.svg';
import { NearContext } from '@/components/wallet-selector/WalletSelector';
import { network } from '@/config';
import whiteList from '@/utils/white-list.json';

export interface FastNearFT {
Expand All @@ -16,7 +17,7 @@ export interface TokenFastNear {
}

export const accounts_ft = async (accountId: string): Promise<FastNearFT> => {
const response = await fetch(`https://api.fastnear.com/v1/account/${accountId}/ft`);
const response = await fetch(`${network.fastNearApi}/v1/account/${accountId}/ft`);
return (await response.json()) as FastNearFT;
};

Expand Down
1 change: 1 addition & 0 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type ProductionNetwork = {
apiNearBlocks: string;
ftContract: string;
nftContract: string;
fastNearApi: string;
};

export interface TosData {
Expand Down

0 comments on commit 96525db

Please sign in to comment.