Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/covalenthq/goldrush-kit int…
Browse files Browse the repository at this point in the history
…o xyk-token-list
  • Loading branch information
nguyenlejoe committed Jan 12, 2024
2 parents 1e829b0 + 6bd9496 commit 7c04af7
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 62 deletions.
89 changes: 52 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div align="center">
<a href="https://www.covalenthq.com/products/goldrush/" target="_blank">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/covalenthq/goldrush-kit/main/src/static/grk-banner.png">
<img alt="GoldRush Kit Logo" src="https://raw.githubusercontent.com/covalenthq/goldrush-kit/main/src/static/grk-banner.png" width="680"/>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/covalenthq/goldrush-kit/main/src/static/grk-kit-banner.png">
<img alt="GoldRush Kit Logo" src="https://raw.githubusercontent.com/covalenthq/goldrush-kit/main/src/static/grk-kit-banner.png" width="680"/>
</picture>
</a>
</div>
Expand Down Expand Up @@ -87,41 +87,56 @@ Here's a full example to get you started. If you're using `next.js` versions `^1
Be sure to secure your key to prevent unauthorized use in the Covalent platform by restricting usage to specific URLs.

```tsx
// 'use client';
// If using Next.js, put your API key in a .env.local file
<GoldRushProvider
apikey={process.env.NEXT_PUBLIC_API_KEY}
mode="dark"
color="emerald"
>
<TokenBalancesListView
chain_names={[
"eth-mainnet",
"matic-mainnet",
"bsc-mainnet",
"avalanche-mainnet",
"optimism-mainnet",
]}
hide_small_balances
address="0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de"
/>
<TokenTransfersListView
chain_name="eth-mainnet"
address="0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de"
contract_address="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
/>
<AddressActivityListView address="0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de" />
<NFTWalletTokenListView
address="0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de"
chain_names={[
"eth-mainnet",
"matic-mainnet",
"bsc-mainnet",
"avalanche-mainnet",
"optimism-mainnet",
]}
/>
</GoldRushProvider>
'use client'
import "@covalenthq/goldrush-kit/styles.css";
import {
GoldRushProvider,
NFTWalletTokenListView,
TokenBalancesListView,
TokenTransfersListView,
AddressActivityListView,
} from "@covalenthq/goldrush-kit";

export default function GoldRushExample() {
return (
<main className="">
<GoldRushProvider
apikey={process.env.NEXT_PUBLIC_API_KEY}
mode="dark"
color="emerald"
>
<TokenBalancesListView
chain_names={[
"eth-mainnet",
"matic-mainnet",
"bsc-mainnet",
"avalanche-mainnet",
"optimism-mainnet",
]}
hide_small_balances
address="0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de"
/>
<TokenTransfersListView
chain_name="eth-mainnet"
address="0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de"
contract_address="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
/>
<AddressActivityListView address="0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de" />
<NFTWalletTokenListView
address="0xfc43f5f9dd45258b3aff31bdbe6561d97e8b71de"
chain_names={[
"eth-mainnet",
"matic-mainnet",
"bsc-mainnet",
"avalanche-mainnet",
"optimism-mainnet",
]}
/>
</GoldRushProvider>
</main>
)
}

```

## GoldRush Templates
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"_id": "[email protected]",
"name": "@covalenthq/goldrush-kit",
"version": "0.2.7",
"version": "0.3.2",
"types": "dist/index.d.ts",
"exports": {
".": {
Expand Down Expand Up @@ -78,14 +78,14 @@
"vite-plugin-dts": "^1.7.3",
"vite-plugin-lib-inject-css": "^1.3.0",
"vite-tsconfig-paths": "^4.2.1",
"@covalenthq/client-sdk": "^0.7.2"
"@covalenthq/client-sdk": "^0.7.4"
},
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"dependencies": {
"@covalenthq/client-sdk": "^0.6.6",
"@covalenthq/client-sdk": "^0.7.5",
"@headlessui/react": "^1.7.17",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-checkbox": "^1.0.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { GRK_SIZES } from "@/utils/constants/shared.constants";
import {
GRK_SIZES,
allowedCacheChains,
} from "@/utils/constants/shared.constants";
import { type Option, Some, None } from "@/utils/option";
import type {
MarketFloorPriceItem,
Expand Down Expand Up @@ -46,6 +49,8 @@ export const NFTCollectionTokenListView: React.FC<
const handleNftsToken = async () => {
setResult(None);
let response;

const cache = !allowedCacheChains.includes(chain_name);
try {
response =
await covalentClient.NftService.getTokenIdsForContractWithMetadataByPage(
Expand All @@ -54,6 +59,7 @@ export const NFTCollectionTokenListView: React.FC<
{
pageNumber: paginator.pageNumber,
pageSize: paginator.pageSize,
withUncached: cache,
}
);
setError({ error: false, error_message: "" });
Expand Down
12 changes: 9 additions & 3 deletions src/components/Organisms/NFTs/NFTDetailView/NFTDetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { type NFTDetailViewProps } from "@/utils/types/organisms.types";
import { type NftTokenContract } from "@covalenthq/client-sdk";
import { useEffect, useState } from "react";
import { Skeleton } from "@/components/ui/skeleton";
import { GRK_SIZES } from "@/utils/constants/shared.constants";
import {
GRK_SIZES,
allowedCacheChains,
} from "@/utils/constants/shared.constants";

export const NFTDetailView: React.FC<NFTDetailViewProps> = ({
chain_name,
Expand All @@ -20,15 +23,18 @@ export const NFTDetailView: React.FC<NFTDetailViewProps> = ({

useEffect(() => {
let response;
const cache = !allowedCacheChains.includes(chain_name);
(async () => {
try {
response =
await covalentClient.NftService.getNftMetadataForGivenTokenIdForContract(
chain_name,
collection_address,
token_id
token_id,
{
withUncached: cache,
}
);

setResult(new Some(response.data.items[0]));
} catch (error) {
console.error(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { GRK_SIZES } from "@/utils/constants/shared.constants";
import {
GRK_SIZES,
allowedCacheChains,
} from "@/utils/constants/shared.constants";
import { type Option, Some, None } from "@/utils/option";
import type { ChainItem } from "@covalenthq/client-sdk";
import {
Expand Down Expand Up @@ -38,16 +41,6 @@ export const NFTWalletTokenListView: React.FC<NFTWalletTokenListViewProps> = ({
const handleNftsToken = async () => {
setResult(None);
const promises = chain_names.map(async (chain) => {
const allowedCacheChains = [
"bsc-mainnet",
"eth-mainnet",
"bsc-testnet",
"eth-sepolia",
"gnosis-mainnet",
"gnosis-testnet",
"matic-mainnet",
"matic-mumbai",
];
const cache = !allowedCacheChains.includes(chain);
let response;
try {
Expand Down
Binary file removed src/static/grk-banner.png
Binary file not shown.
Binary file added src/static/grk-kit-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/utils/constants/shared.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,14 @@ export enum CURRENCY {
USD,
NATIVE,
}

export const allowedCacheChains = [
"bsc-mainnet",
"eth-mainnet",
"bsc-testnet",
"eth-sepolia",
"gnosis-mainnet",
"gnosis-testnet",
"matic-mainnet",
"matic-mumbai",
];

0 comments on commit 7c04af7

Please sign in to comment.