- {connectors?.map((connector, index) => {
+ {connectors?.map((connector) => {
if (connector?.available()) {
return (
diff --git a/apps/nextjs/src/app/_components/wallet/WalletSheet.tsx b/apps/nextjs/src/app/_components/wallet/WalletSheet.tsx
index dbe35fbf..8fe7fe03 100644
--- a/apps/nextjs/src/app/_components/wallet/WalletSheet.tsx
+++ b/apps/nextjs/src/app/_components/wallet/WalletSheet.tsx
@@ -7,7 +7,6 @@ import Bridge from "@/icons/bridge.svg";
import {
useDisconnect,
useAccount as useL2Account,
- useConnect as useL2Connect,
useNetwork,
} from "@starknet-react/core";
@@ -16,7 +15,6 @@ import {
Button,
Dialog,
DialogContent,
- DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
@@ -79,10 +77,16 @@ export const WalletSheet = () => {
} else {
setIsWrongNetwork(false);
}
- }, [chain?.id, l2Address, isL2Connected]);
+ }, [
+ chain.id,
+ l2Address,
+ isL2Connected,
+ chainId,
+ NETWORK_ID.sepolia,
+ NETWORK_ID.mainnet,
+ ]);
const { isAccountOpen, toggleAccount } = useUIContext();
- const [open, setOpen] = useState(false);
const tabs = [
{
@@ -109,7 +113,7 @@ export const WalletSheet = () => {
{
variant={"outline"}
href={url}
>
- {shortenHex(text || "", 8)}
+ {shortenHex(text ?? "", 8)}
))}
diff --git a/apps/nextjs/src/app/api/staking/cumulative-payment-tree.ts b/apps/nextjs/src/app/api/staking/cumulative-payment-tree.ts
index 41176714..992f894d 100644
--- a/apps/nextjs/src/app/api/staking/cumulative-payment-tree.ts
+++ b/apps/nextjs/src/app/api/staking/cumulative-payment-tree.ts
@@ -1,3 +1,6 @@
+/* eslint-disable @typescript-eslint/no-unsafe-member-access */
+/* eslint-disable @typescript-eslint/no-unsafe-return */
+/* eslint-disable @typescript-eslint/no-explicit-any */
import { bufferToHex, zeros } from "ethereumjs-util";
import _ from "lodash";
import Web3Utils from "web3-utils";
@@ -23,17 +26,18 @@ import MerkleTree from "./merkle-tree";
*/
export default class CumulativePaymentTree extends MerkleTree {
- constructor(paymentList) {
- let filteredPaymentList = paymentList.filter(
+ paymentNodes: { payee: string; amount: number }[];
+ constructor(paymentList: any[]) {
+ const filteredPaymentList = paymentList.filter(
(payment) => payment.payee && payment.amount,
);
- let groupedPayees = _.groupBy(
+ const groupedPayees = _.groupBy(
filteredPaymentList,
(payment) => payment.payee,
);
- let reducedPaymentList = Object.keys(groupedPayees).map((payee) => {
- let payments = groupedPayees[payee];
- let amount = _.reduce(
+ const reducedPaymentList = Object.keys(groupedPayees).map((payee) => {
+ const payments = groupedPayees[payee];
+ const amount = _.reduce(
payments,
(sum, payment) => sum + payment.amount,
0,
@@ -44,8 +48,8 @@ export default class CumulativePaymentTree extends MerkleTree {
this.paymentNodes = reducedPaymentList;
}
- amountForPayee(payee) {
- let payment = _.find(this.paymentNodes, { payee });
+ amountForPayee(payee: string) {
+ const payment = _.find(this.paymentNodes, { payee });
if (!payment) {
return 0;
}
@@ -53,8 +57,8 @@ export default class CumulativePaymentTree extends MerkleTree {
return Web3Utils.toHex(payment.amount);
}
- hexProofForPayee(payee, paymentCycle) {
- let leaf = _.find(this.paymentNodes, { payee });
+ hexProofForPayee(payee: string, paymentCycle: number) {
+ const leaf = _.find(this.paymentNodes, { payee });
if (!leaf) {
return bufferToHex(zeros(32));
}
diff --git a/apps/nextjs/src/app/api/staking/merkle-tree.ts b/apps/nextjs/src/app/api/staking/merkle-tree.ts
index 5bb4caa0..90d206a7 100644
--- a/apps/nextjs/src/app/api/staking/merkle-tree.ts
+++ b/apps/nextjs/src/app/api/staking/merkle-tree.ts
@@ -1,3 +1,11 @@
+/* eslint-disable @typescript-eslint/no-unsafe-argument */
+/* eslint-disable @typescript-eslint/no-unsafe-call */
+/* eslint-disable @typescript-eslint/no-unsafe-member-access */
+/* eslint-disable @typescript-eslint/no-unsafe-return */
+/* eslint-disable @typescript-eslint/unbound-method */
+/* eslint-disable @typescript-eslint/no-unsafe-assignment */
+/* eslint-disable @typescript-eslint/no-explicit-any */
+import type { ToBufferInputTypes } from "ethereumjs-util";
import {
bufferToHex,
keccak256,
@@ -7,7 +15,9 @@ import {
import Web3Utils from "web3-utils";
export default class MerkleTree {
- constructor(elements) {
+ elements: Buffer[];
+ layers: any[];
+ constructor(elements: any[]) {
// Filter empty strings and hash elements
this.elements = elements.filter((el) => el).map((el) => this.sha3(el));
@@ -20,7 +30,7 @@ export default class MerkleTree {
this.layers = this.getLayers(this.elements);
}
- getLayers(elements) {
+ getLayers(elements: string | any[]) {
if (elements.length === 0) {
return [[""]];
}
@@ -35,18 +45,21 @@ export default class MerkleTree {
return layers;
}
- getNextLayer(elements) {
- return elements.reduce((layer, el, idx, arr) => {
- if (idx % 2 === 0) {
- // Hash the current element with its pair element
- layer.push(this.combinedHash(el, arr[idx + 1]));
- }
-
- return layer;
- }, []);
+ getNextLayer(elements?: any) {
+ return elements?.reduce(
+ (layer: any[], el: any, idx: number, arr: Record) => {
+ if (idx % 2 === 0) {
+ // Hash the current element with its pair element
+ layer.push(this.combinedHash(el, arr[idx + 1]));
+ }
+
+ return layer;
+ },
+ [],
+ );
}
- combinedHash(first, second) {
+ combinedHash(first: any, second: any) {
if (!first) {
return second;
}
@@ -64,7 +77,7 @@ export default class MerkleTree {
return bufferToHex(this.getRoot());
}
- getProof(el, prefix) {
+ getProof(el: any, prefix: any[]) {
let idx = this.bufIndexOf(el, this.elements);
if (idx === -1) {
@@ -88,20 +101,25 @@ export default class MerkleTree {
prefix = [prefix];
}
- prefix = prefix.map((item) => setLengthLeft(toBuffer(item), 32));
+ prefix = prefix.map((item: ToBufferInputTypes) =>
+ setLengthLeft(toBuffer(item), 32),
+ );
proof = prefix.concat(proof);
}
return proof;
}
- getHexProof(el, prefix) {
+ getHexProof(
+ el: { payee: string; amount: number },
+ prefix: (string | number)[],
+ ) {
const proof = this.getProof(el, prefix);
return this.bufArrToHex(proof);
}
- getPairElement(idx, layer) {
+ getPairElement(idx: number, layer: string | any[]) {
const pairIdx = idx % 2 === 0 ? idx + 1 : idx - 1;
if (pairIdx < layer.length) {
@@ -111,7 +129,7 @@ export default class MerkleTree {
}
}
- bufIndexOf(el, arr) {
+ bufIndexOf(el: any, arr: any) {
let hash;
// Convert element to 32 byte hash if it is not one already
@@ -130,31 +148,36 @@ export default class MerkleTree {
return -1;
}
- bufDedup(elements) {
- return elements.filter((el, idx) => {
+ bufDedup(elements: any[]) {
+ return elements.filter((el: any, idx: number) => {
return this.bufIndexOf(el, elements) === idx;
});
}
- bufArrToHex(arr) {
- if (arr.some((el) => !Buffer.isBuffer(el))) {
+ bufArrToHex(arr: any[]) {
+ if (arr.some((el: any) => !Buffer.isBuffer(el))) {
throw new Error("Array is not an array of buffers");
}
- return "0x" + arr.map((el) => el.toString("hex")).join("");
+ return (
+ "0x" +
+ arr
+ .map((el: { toString: (arg0: string) => any }) => el.toString("hex"))
+ .join("")
+ );
}
- sortAndConcat(...args) {
+ sortAndConcat(...args: any[]) {
return Buffer.concat([...args].sort(Buffer.compare));
}
- sha3(node) {
+ sha3(node: { payee: any; amount: any }) {
return Buffer.from(
Web3Utils.hexToBytes(
Web3Utils.soliditySha3(
- { t: "address", v: node["payee"] },
- { t: "uint256", v: node["amount"] },
- ),
+ { t: "address", v: node.payee },
+ { t: "uint256", v: node.amount },
+ )!,
),
);
}
diff --git a/apps/nextjs/src/app/bridge/Account.tsx b/apps/nextjs/src/app/bridge/Account.tsx
index 95764f33..d4abf854 100644
--- a/apps/nextjs/src/app/bridge/Account.tsx
+++ b/apps/nextjs/src/app/bridge/Account.tsx
@@ -4,24 +4,12 @@ import React from "react";
import { TransferLog } from "@/app/bridge/TransferLog";
import { useTransferLog } from "@/app/providers/TransferLogProvider";
import { useCompleteTransferToL1 } from "@/hooks/useTransferToL1";
-import { api } from "@/trpc/react";
-import { padAddress } from "@/utils/utils";
-import { useAccount as useL2Account } from "@starknet-react/core";
//import { evaluate } from "@starkware-industries/commons-js-utils";
import PropTypes from "prop-types";
-import { useAccount } from "wagmi";
export const Account = ({ isL1 }: { isL1: boolean }) => {
- const { address } = useAccount();
- const { address: l2address } = useL2Account();
const { transfers /*, fetchNextPage, isLoading*/ } = useTransferLog(isL1);
const completeTransferToL1 = useCompleteTransferToL1();
- /*const [bridge] = api.bridge.all.useSuspenseQuery({
- l1Account: padAddress(address ?? ""),
- l2Account: padAddress(l2address ?? ""),
- });
- console.log(bridge);*/
- console.log(transfers);
const onCompleteTransferClick = (transfer: any) => {
completeTransferToL1(transfer);
diff --git a/apps/nextjs/src/app/bridge/TransferLog.tsx b/apps/nextjs/src/app/bridge/TransferLog.tsx
index 9130cf30..82540483 100644
--- a/apps/nextjs/src/app/bridge/TransferLog.tsx
+++ b/apps/nextjs/src/app/bridge/TransferLog.tsx
@@ -1,7 +1,6 @@
-"use client";
-
-import React, { useEffect, useState } from "react";
import type { DepositEvent, WithdrawalEvent } from "@/.graphclient";
+import type { ChainTypeL2 } from "@starkware-industries/commons-js-enums";
+import React, { useEffect, useState } from "react";
import {
NETWORK_NAME,
STARKSCAN_ETH_TX_URL,
@@ -10,7 +9,6 @@ import {
import { ChainType, tokens } from "@/constants/tokens";
import LordsIcon from "@/icons/lords.svg";
import { useNetwork } from "@starknet-react/core";
-import type { ChainTypeL2 } from "@starkware-industries/commons-js-enums";
import {
isOnChain,
isRejected,
@@ -45,7 +43,6 @@ export const TransferLog = ({
onCompleteTransferClick: () => void;
}) => {
const [sign, setSign] = useState("");
- const { chain } = useNetwork();
const [l2hash, setL2hash] = useState("");
const { depositEvents, withdrawalEvents, createdTimestamp } = transfer;
@@ -54,11 +51,9 @@ export const TransferLog = ({
id,
//l2Recipient,
amount,
- createdTxHash,
finishedTxHash: l1hash,
- finishedAtDate,
- }: DepositEvent | WithdrawalEvent = depositEvents?.[0] ||
- withdrawalEvents?.[0] ||
+ }: DepositEvent | WithdrawalEvent = depositEvents?.[0] ??
+ withdrawalEvents?.[0] ??
transfer;
const getl2hash = async () => {
@@ -98,7 +93,7 @@ export const TransferLog = ({
>
{!isOnChain(typedStatus)
? TransactionStatusFriendlyMessage[
- typedStatus || TransactionStatus.NOT_RECEIVED
+ typedStatus ?? TransactionStatus.NOT_RECEIVED
]
: ""}
@@ -158,7 +153,7 @@ export const TransferLog = ({
)}
- {transfer.amount ? amount : formatEther(amount || 0)}
+ {transfer.amount ? amount : formatEther(amount ?? 0)}
diff --git a/apps/nextjs/src/app/collection/CollectionsList.tsx b/apps/nextjs/src/app/collection/CollectionsList.tsx
index 66fce722..619791d9 100644
--- a/apps/nextjs/src/app/collection/CollectionsList.tsx
+++ b/apps/nextjs/src/app/collection/CollectionsList.tsx
@@ -1,6 +1,8 @@
import type { Collection, L2Collection } from "@/types";
import { CollectionCard } from "@/app/_components/CollectionCard";
-import { getTokenContractAddresses } from "@/utils/utils";
+import { SUPPORTED_L1_CHAIN_ID } from "@/constants/env";
+
+import { Collections, getCollectionAddresses } from "@realms-world/constants";
import { getCollections } from "../../lib/reservoir/getCollections";
@@ -11,12 +13,15 @@ export const metadata = {
};
export default async function CollectionsList() {
- const l1Collections = await getCollections([
- { contract: getTokenContractAddresses("realms").L1! },
- ]);
+ const { collections } = (await getCollections([
+ {
+ contract: getCollectionAddresses(Collections.REALMS)[
+ SUPPORTED_L1_CHAIN_ID
+ ]!,
+ },
+ ])) as { collections: Collection[] };
// TODO refine collection display logic (with l2 collections included)
- const collections: Collection[] = l1Collections?.collections;
const l2Collections: L2Collection[] = [
{
name: "Beasts",
@@ -25,8 +30,8 @@ export default async function CollectionsList() {
},
{
name: "Golden Token",
- link: "goldenToken",
- image: "/collections/goldenToken.svg",
+ link: "goldentoken",
+ image: "/collections/goldentoken.svg",
},
];
diff --git a/apps/nextjs/src/app/collection/[id]/(list)/AttributesDropdown.tsx b/apps/nextjs/src/app/collection/[id]/(list)/AttributesDropdown.tsx
index b8233c1d..50627f38 100644
--- a/apps/nextjs/src/app/collection/[id]/(list)/AttributesDropdown.tsx
+++ b/apps/nextjs/src/app/collection/[id]/(list)/AttributesDropdown.tsx
@@ -24,12 +24,7 @@ export const AttributesDropdown = ({
attributes?: any;
attributesPromise?: Promise
;
}) => {
- const {
- handleAttributeClick,
- isAttributeInQuery,
- isKeyInQuery,
- getQueriesFromUrl,
- } = useQuery();
+ const { handleAttributeClick, isAttributeInQuery, isKeyInQuery } = useQuery();
const { data: attributesFetched } = api.erc721Attributes.all.useQuery(
{
contractAddress: address,
diff --git a/apps/nextjs/src/app/collection/[id]/(list)/CardAction.tsx b/apps/nextjs/src/app/collection/[id]/(list)/CardAction.tsx
index 3af7d694..77a56b87 100644
--- a/apps/nextjs/src/app/collection/[id]/(list)/CardAction.tsx
+++ b/apps/nextjs/src/app/collection/[id]/(list)/CardAction.tsx
@@ -1,4 +1,3 @@
-import LordsIcon from "@/icons/lords.svg";
import { useAccount } from "@starknet-react/core";
import type { RouterOutputs } from "@realms-world/api";
@@ -11,10 +10,8 @@ import { ListingEditModal } from "../../marketplace/listEdit/ListingEditModal";
export const CardAction = ({
token,
- layout = "grid",
}: {
token: RouterOutputs["erc721Tokens"]["all"]["items"][number];
- layout?: "grid" | "list";
}) => {
const { address } = useAccount();
return (
@@ -29,7 +26,7 @@ export const CardAction = ({
}
// tokenId={tokenId}
token={token}
- collectionId={token.contract_address}
+ collectionId={token.contract_address!}
orderId={0}
/>
) : (
@@ -49,7 +46,7 @@ export const CardAction = ({
List Item
diff --git a/apps/nextjs/src/app/collection/[id]/(list)/CollectionSummary.tsx b/apps/nextjs/src/app/collection/[id]/(list)/CollectionSummary.tsx
index a3e59ddb..11fba143 100644
--- a/apps/nextjs/src/app/collection/[id]/(list)/CollectionSummary.tsx
+++ b/apps/nextjs/src/app/collection/[id]/(list)/CollectionSummary.tsx
@@ -1,30 +1,34 @@
-import type { erc721Tokens } from "@/constants";
import type { Collection } from "@reservoir0x/reservoir-kit-ui";
import Image from "next/image";
import Link from "next/link";
+import { SUPPORTED_L1_CHAIN_ID, SUPPORTED_L2_CHAIN_ID } from "@/constants/env";
import Discord from "@/icons/discord.svg";
import { getCollections } from "@/lib/reservoir/getCollections";
import { getGamesByContract } from "@/utils/getters";
-import { getTokenContractAddresses } from "@/utils/utils";
-import { ExternalLink, Globe, Twitter } from "lucide-react";
+import { ExternalLink, Globe, X } from "lucide-react";
import { formatEther } from "viem";
-import { games } from "@realms-world/constants";
+import type { Collections } from "@realms-world/constants";
+import { games, getCollectionAddresses } from "@realms-world/constants";
import L2CollectionSummary from "./L2CollectionSummary";
export default async function CollectionSummary({
collectionId,
}: {
- collectionId: keyof typeof erc721Tokens;
+ collectionId: string;
}) {
- const tokenAddresses = getTokenContractAddresses(collectionId);
+ const tokenAddresses = getCollectionAddresses(collectionId);
+ if (!tokenAddresses) {
+ return Collection Not Found
;
+ }
- if (tokenAddresses.L2) {
- return ;
- } else if (tokenAddresses.L1) {
+ if (tokenAddresses[SUPPORTED_L2_CHAIN_ID]) {
+ return ;
+ } else if (tokenAddresses[SUPPORTED_L1_CHAIN_ID]) {
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { collections }: { collections: Collection[] } = await getCollections(
- [{ contract: tokenAddresses.L1 }],
+ [{ contract: tokenAddresses[SUPPORTED_L1_CHAIN_ID]! }],
);
const collection = collections?.[0];
@@ -43,7 +47,7 @@ export default async function CollectionSummary({
value: collection.discordUrl,
},
{
- icon: ,
+ icon: ,
value: "https://twitter.com/" + collection.twitterUsername,
},
{ icon: , value: collection.externalUrl },
diff --git a/apps/nextjs/src/app/collection/[id]/(list)/L1TokenCard.tsx b/apps/nextjs/src/app/collection/[id]/(list)/L1TokenCard.tsx
index fb4ed7f0..bcf4a332 100644
--- a/apps/nextjs/src/app/collection/[id]/(list)/L1TokenCard.tsx
+++ b/apps/nextjs/src/app/collection/[id]/(list)/L1TokenCard.tsx
@@ -1,12 +1,13 @@
import type { TokenMarketData } from "@/types";
import Image from "next/image";
import Link from "next/link";
-import { findTokenName } from "@/utils/utils";
// import { BuyModal } from "@reservoir0x/reservoir-kit-ui";
import { formatEther } from "viem";
import { Button } from "@realms-world/ui";
+import { BuyButton } from "../../reservoir/BuyModal";
+
//import { BuyButton } from "./BuyModal";
interface TokenCardProps {
@@ -119,10 +120,11 @@ export const L1TokenCard = (props: TokenCardProps) => {
>
view
+ {/* TODO add back with reservoir
+ />*/}