Skip to content

Commit

Permalink
wip: utils / contract porting
Browse files Browse the repository at this point in the history
  • Loading branch information
xBalbinus committed Oct 2, 2024
1 parent 2d893c5 commit d5e6b9f
Show file tree
Hide file tree
Showing 16 changed files with 1,008 additions and 166 deletions.
7 changes: 7 additions & 0 deletions packages/nextjs/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as chains from "viem/chains";

export const targetNetworks = [chains.hardhat];
export const pollingInterval = 30000;
export const alchemyApiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY || "oKxs-03sij-U_N0iOlrSsZFr29-IqbuF";
export const walletConnectProjectId = process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID || "3a8170812b534d0ff9d794f19a901d64";
export const onlyLocalBurnerWallet = true;
9 changes: 9 additions & 0 deletions packages/nextjs/contracts/deployedContracts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* This file is autogenerated by FIL-Frame.
* You should not edit it manually or your changes might be overwritten.
*/
import { GenericContractsDeclaration } from "@utils/contract";

const deployedContracts = {} as const;

export default deployedContracts satisfies GenericContractsDeclaration;
16 changes: 16 additions & 0 deletions packages/nextjs/contracts/externalContracts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { GenericContractsDeclaration } from "@utils/contract";

/**
* @example
* const externalContracts = {
* 1: {
* DAI: {
* address: "0x...",
* abi: [...],
* },
* },
* } as const;
*/
const externalContracts = {} as const;

export default externalContracts satisfies GenericContractsDeclaration;
3 changes: 2 additions & 1 deletion packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"next": "^14.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sass": "1.77.8"
"sass": "1.77.8",
"viem": "2.21.7"
},
"devDependencies": {
"@types/node": "^22.1.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/nextjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"paths": {
"@root/*": ["./*"],
"@system/*": ["./system/*"],
"@demos/*": ["./demos/*"],
"@common/*": ["./common/*"],
"@contracts/*": ["./contracts/*"],
"@data/*": ["./data/*"],
"@components/*": ["./components/*"],
"@pages/*": ["./pages/*"],
"@modules/*": ["./modules/*"]
"@modules/*": ["./modules/*"],
"@utils/*": ["./utils/*"]
},
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
Expand Down
17 changes: 17 additions & 0 deletions packages/nextjs/utils/block.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Block, Transaction, TransactionReceipt } from "viem";

export type TransactionWithFunction = Transaction & {
functionName?: string;
functionArgs?: any[];
functionArgNames?: string[];
functionArgTypes?: string[];
};

type TransactionReceipts = {
[key: string]: TransactionReceipt;
};

export type TransactionsTableProps = {
blocks: Block[];
transactionReceipts: TransactionReceipts;
};
7 changes: 7 additions & 0 deletions packages/nextjs/utils/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// To be used in JSON.stringify when a field might be bigint
// https://wagmi.sh/react/faq#bigint-serialization
export const replacer = (_key: string, value: unknown) => (typeof value === "bigint" ? value.toString() : value);

export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";

export const isZeroAddress = (address: string) => address === ZERO_ADDRESS;
Loading

0 comments on commit d5e6b9f

Please sign in to comment.