Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(arkmarket): handle sepolia starknet provider #217

Merged
merged 4 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default function CollectionItemsBuyNow({
tokenId: BigInt(token.token_id),
orderHash: BigInt(tokenMarketData.listing.order_hash),
amount: BigInt(tokenMarketData.listing.start_amount),
quantity: BigInt(1),
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ const AcceptOffer: React.FC<AcceptOfferProps> = ({
const [isOpen, setIsOpen] = useState(false);
const { account } = useAccount();
const { fulfillOfferAsync, status } = useFulfillOffer();
const { fulfillAuctionAsync, status: statusAuction } =
useFulfillAuction();
const { fulfillAuctionAsync, status: statusAuction } = useFulfillAuction();

const { toast } = useToast();
const formattedAmount = formatEther(BigInt(offerPrice));
Expand All @@ -72,7 +71,7 @@ const AcceptOffer: React.FC<AcceptOfferProps> = ({
const onConfirm = async () => {
if (!account) {
toast({
variant: "canceled",
variant: "canceled",
title: "Error",
description: "Please connect your wallet before accepting an offer",
});
Expand All @@ -87,6 +86,7 @@ const AcceptOffer: React.FC<AcceptOfferProps> = ({
account: account,
tokenAddress: collectionAddress,
tokenId: BigInt(tokenId),
quantity: BigInt(1),
});
} else {
await fulfillOfferAsync({
Expand All @@ -95,6 +95,7 @@ const AcceptOffer: React.FC<AcceptOfferProps> = ({
account: account,
tokenAddress: collectionAddress,
tokenId: BigInt(tokenId),
quantity: BigInt(1),
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ export default function TokenActionsAcceptBestOffer({
const onConfirm = async () => {
if (!account) {
toast({
variant: "canceled",
variant: "canceled",
title: "Error",
description: "Please connect your wallet before accepting an offer"
description: "Please connect your wallet before accepting an offer",
});
return;
}
Expand All @@ -106,6 +106,7 @@ export default function TokenActionsAcceptBestOffer({
account: account,
tokenAddress: token.collection_address,
tokenId: BigInt(token.token_id),
quantity: BigInt(1),
});
} else {
await fulfillOfferAsync({
Expand All @@ -114,6 +115,7 @@ export default function TokenActionsAcceptBestOffer({
account: account,
tokenAddress: token.collection_address,
tokenId: BigInt(token.token_id),
quantity: BigInt(1),
});
}
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default function TokenActionsBuyNow({
tokenId: BigInt(token.token_id),
orderHash: BigInt(tokenMarketData.listing.order_hash),
amount: BigInt(tokenMarketData.listing.start_amount),
quantity: BigInt(1),
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { notFound } from "next/navigation";

import Providers from "~/components/providers";
import type { Token, TokenMarketData } from "~/types";
import getToken from "~/lib/getToken";
import getTokenMarketData from "~/lib/getTokenMarketData";
Expand Down
8 changes: 6 additions & 2 deletions apps/arkmarket/src/components/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
"use client";

import type { PropsWithChildren } from "react";
import { ArkQueryClient, ArkQueryClientProvider, ArkProvider } from "@ark-project/react";
import { env } from "~/env";
import {
ArkProvider,
ArkQueryClient,
ArkQueryClientProvider,
} from "@ark-project/react";

import { ThemeProvider } from "@ark-market/ui/theme";

import { StarknetProvider } from "./starknet-provider";
Expand Down
11 changes: 5 additions & 6 deletions apps/arkmarket/src/components/starknet-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

import type { Connector } from "@starknet-react/core";
import type { PropsWithChildren } from "react";
import { mainnet } from "@starknet-react/chains";
import { mainnet, sepolia } from "@starknet-react/chains";
import {
alchemyProvider,
argent,
braavos,
StarknetConfig,
Expand All @@ -15,11 +14,11 @@ import { ArgentMobileConnector } from "starknetkit/argentMobile";
import { WebWalletConnector } from "starknetkit/webwallet";

import { env } from "~/env";
import getProvider from "~/lib/getProvider";

export function StarknetProvider({ children }: PropsWithChildren) {
const provider = alchemyProvider({
apiKey: "ssydbI7745ocbNd_c-xULVsq9xXF947b",
});
const provider = getProvider();
const chain = env.NEXT_PUBLIC_NETWORK === "sepolia" ? sepolia : mainnet;
const { connectors: injectedConnectors } = useInjectedConnectors({
recommended: [argent(), braavos()],
includeRecommended: "onlyIfNoConnectors",
Expand All @@ -39,7 +38,7 @@ export function StarknetProvider({ children }: PropsWithChildren) {

return (
<StarknetConfig
chains={[mainnet]}
chains={[chain]}
provider={provider}
connectors={connectors}
explorer={voyager}
Expand Down
13 changes: 13 additions & 0 deletions apps/arkmarket/src/lib/getProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { alchemyProvider, publicProvider } from "@starknet-react/core";

import { env } from "~/env";

export default function getProvider() {
if (env.NEXT_PUBLIC_NETWORK === "mainnet") {
return alchemyProvider({
apiKey: "ssydbI7745ocbNd_c-xULVsq9xXF947b",
});
} else {
return publicProvider();
}
}
2 changes: 1 addition & 1 deletion packages/ui/src/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";

import { cn } from "@ark-market/ui";

interface InputStatus {
export interface InputStatus {
status?: "default" | "error";
}

Expand Down
Loading