Skip to content

Commit

Permalink
updated lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobHomanics committed May 18, 2024
1 parent 21b1964 commit dc9fae5
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 45 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
os: [ubuntu-latest]
node: [lts/*]


steps:
- name: Checkout
uses: actions/checkout@master
Expand All @@ -25,19 +26,27 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: yarn
cache : yarn


- name: Install dependencies
run: yarn install --immutable

- name: Run hardhat node, deploy contracts (& generate contracts typescript output)
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run foundry node, deploy contracts (& generate contracts typescript output)
env:
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
run: yarn chain & yarn deploy
id: build

- name: Run tests
run: yarn test -vvv


- name: Run nextjs lint
run: yarn next:lint --max-warnings=0

- name: Check typings on nextjs
run: yarn next:check-types

- name: Run hardhat lint
run: yarn hardhat:lint --max-warnings=0
4 changes: 2 additions & 2 deletions packages/nextjs/app/collections/[network]/[address]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function CollectionPage({ params }: { params: { network: string;
const { collection, isLoading, isError } = useTokens(
params["network"],
params["address"],
userAccount.address!,
userAccount.address,
tokenIds,
"nftstorage",
//chosenOption2,
Expand All @@ -49,7 +49,7 @@ export default function CollectionPage({ params }: { params: { network: string;
collection={collection}
isLoading={isLoading}
isError={isError}
renderOrder={["Image", "Token Id", "Name", "Description", "Attributes"]}
renderOrder={["balanceOf", "Image", "Token Id", "Name", "Description", "Attributes"]}
/>
</div>
);
Expand Down
8 changes: 8 additions & 0 deletions packages/nextjs/components/scaffold-nft/nft/Nft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ export const Nft = ({
);
}

console.log(token);

if (renderOrder[i] === "balanceOf") {
selectedElement = (
<Text value={token?.balanceOf?.toString()} size={size} valueClassName={bigAndBoldTextStyleMap[size]} />
);
}

if (renderOrder[i] === "Name") {
selectedElement = (
<Text value={token?.metadata?.name} size={size} valueClassName={bigAndBoldTextStyleMap[size]} />
Expand Down
82 changes: 44 additions & 38 deletions packages/nextjs/hooks/scaffold-nft/useTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const replacement = {
export const useTokens = (
chainName: string,
address: string,
userAddress: string,
userAddress: string | undefined,
tokenIds: bigint[],
replacementType: string,
// loadType = "url",
Expand All @@ -44,27 +44,27 @@ export const useTokens = (
setIsLoading(true);
setIsError(false);

let collectionName;
try {
collectionName = await publicClient?.readContract({
address,
abi: erc1155Abi,
functionName: "name",
});
} catch (e) {
console.log(e);
}

let collectionSymbol;
try {
collectionSymbol = await publicClient?.readContract({
address,
abi: erc1155Abi,
functionName: "symbol",
});
} catch (e) {
console.log(e);
}
// let collectionName;
// try {
// collectionName = await publicClient?.readContract({
// address,
// abi: erc1155Abi,
// functionName: "name",
// });
// } catch (e) {
// console.log(e);
// }

// let collectionSymbol;
// try {
// collectionSymbol = await publicClient?.readContract({
// address,
// abi: erc1155Abi,
// functionName: "symbol",
// });
// } catch (e) {
// console.log(e);
// }
try {
// const collectionName = await publicClient?.readContract({
// address,
Expand All @@ -80,17 +80,6 @@ export const useTokens = (

//const balanceOf =

try {
await publicClient?.readContract({
address,
abi: erc1155Abi,
functionName: "balanceOf",
args: [userAddress],
});
} catch (e) {
console.log(e);
}

const arr = [];

for (let i = 0; i < tokenIds.length; i++) {
Expand Down Expand Up @@ -133,21 +122,38 @@ export const useTokens = (
alt: metadataJson.name + " Image",
};

let balanceOf;
try {
balanceOf = await publicClient?.readContract({
address,
abi: erc1155Abi,
functionName: "balanceOf",
args: [userAddress, tokenIds[i]],
});
} catch (e) {
console.log("NYEUH22222");
console.log(userAddress);

console.log(e);
console.log("NYEUH");
}

const token = {} as any;
token.address = address;
token.metadata = metadataJson;
token.id = tokenIds[i];
token.balanceOf = balanceOf;
token.uri = tokenURIFormatted;
token.collectionName = collectionName;
token.collectionSymbol = collectionSymbol;
// token.collectionName = collectionName;
// token.collectionSymbol = collectionSymbol;
arr.push(token);
}

const collection = {} as ScaffoldCollection;
collection.tokens = arr;
collection.address = address;
collection.symbol = collectionSymbol as string | undefined;
collection.name = collectionName as string | undefined;
// collection.symbol = collectionSymbol as string | undefined;
// collection.name = collectionName as string | undefined;

setCollection(collection);
} catch (e) {
Expand All @@ -158,7 +164,7 @@ export const useTokens = (
setIsLoading(false);
}
get();
}, [publicClient?.account, tokenIds]);
}, [publicClient?.account, tokenIds, userAddress]);

return { collection, isLoading, isError };
};
1 change: 1 addition & 0 deletions packages/nextjs/types/scaffold-nft/ScaffoldToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export type ScaffoldToken = {
collectionSymbol?: string;
id?: bigint;
uri?: string;
balanceOf?: bigint;
metadata?: {
name?: string;
description?: string;
Expand Down
1 change: 1 addition & 0 deletions packages/nextjs/types/scaffold-nft/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type Style = "rounded" | "straight";
export type Size = "base";

export type RenderableTypes =
| "balanceOf"
| "Image"
| "Token Id"
| "Name"
Expand Down

0 comments on commit dc9fae5

Please sign in to comment.