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] managing braavos chain id #13

Merged
merged 1 commit into from
Dec 21, 2024
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
39 changes: 0 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,6 @@
- Rename the `frontend/gostarkme-web/.env.example` file to: `frontend/gostarkme-web/.env`.



- Comment the content of the file `frontend/gostarkme-web/next.config.mjs`. Adding only one element to the ```nextConfig``` object like this:

```
/** @type {import('next').NextConfig} */
const nextConfig = {
/**
* Enable static exports for the App Router.
*
* @see https://nextjs.org/docs/app/building-your-application/deploying/static-exports
*/
// output: "export",

/**
* Set base path. This is the slug of your GitHub repository.
*
* @see https://nextjs.org/docs/app/api-reference/next-config-js/basePath
*/
// basePath: "/gostarkme",

// assetPrefix: 'https://web3wagers.github.io/gostarkme',

/**
* Disable server-based image optimization. Next.js does not support
* dynamic features with static exports.
*
* @see https://nextjs.org/docs/app/api-reference/components/image#unoptimized
*/
// images: {
// unoptimized: true,
// },

reactStrictMode: false,
};

export default nextConfig;
```


## Local Deployment

### Installing Dependencies
Expand Down
11 changes: 5 additions & 6 deletions components/modules/Fund/FundDonate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { calculatePorcentage } from "@/app/utils";
import ProgressBar from "@/components/ui/ProgressBar";
import ShareXButton from "@/components/ui/ShareOnX";
import { provider } from "@/constants";
import { BRAAVOS_CHAIN_ID, CHAIN_ID, provider } from "@/constants";
import { addrSTRK } from "@/contracts/addresses";
import { activeChainId } from "@/state/activeChain";
import {
Expand Down Expand Up @@ -33,7 +33,6 @@ const FundDonate = ({ currentBalance, goal, addr, name, icon }: FundDonateProps)
const [isDonating, setIsDonating] = useState(false);
const wallet = useAtomValue(walletStarknetkitLatestAtom);
const chainId = useAtomValue(activeChainId);
const networkEnvironment = process.env.NEXT_PUBLIC_CHAIN_ID;
const progress = calculatePorcentage(localBalance, goal);
const [donationMessage, setDonationMessage] = useState('');

Expand Down Expand Up @@ -145,18 +144,18 @@ const FundDonate = ({ currentBalance, goal, addr, name, icon }: FundDonateProps)
)}
<div className="text-center">
<button
disabled={chainId !== networkEnvironment || !wallet || isDonating}
disabled={chainId !== CHAIN_ID && chainId !== BRAAVOS_CHAIN_ID || !wallet || isDonating}
onClick={handleDonateClick}
className={`self-center bg-darkblue text-white py-2 px-6 md:py-3 md:px-10 rounded-md
text-xs md:text-sm shadow-xl hover:bg-starkorange active:bg-darkblue ease-in-out
duration-500 active:duration-0 shadow-gray-400 ${chainId !== networkEnvironment || isDonating ? "opacity-50 cursor-not-allowed" : ""}`}
duration-500 active:duration-0 shadow-gray-400 ${chainId !== CHAIN_ID && chainId !== BRAAVOS_CHAIN_ID || isDonating ? "opacity-50 cursor-not-allowed" : ""}`}
>
{isDonating === true ? "Donating..." : "Donate"}
</button>
{wallet && chainId !== networkEnvironment && (
{wallet && chainId !== CHAIN_ID && chainId !== BRAAVOS_CHAIN_ID && (
<p className="text-sm text-gray-500 mt-2">
Your wallet is currently connected to the wrong network. Please
switch to {networkEnvironment} to continue.
switch to {CHAIN_ID} to continue.
</p>
)}
{!wallet && (
Expand Down
12 changes: 5 additions & 7 deletions components/modules/Fund/FundVote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { latestTxAtom } from "@/state/latestTx";
import { useAtom, useAtomValue } from "jotai";
import { useState } from "react";
import ShareXButton from "@/components/ui/ShareOnX";
import { provider } from "@/constants";
import { BRAAVOS_CHAIN_ID, CHAIN_ID, provider } from "@/constants";
import { CallData } from "starknet";
import { activeChainId } from "@/state/activeChain";

Expand All @@ -24,8 +24,6 @@ interface FundVoteProps {
export const FundVote = ({ name, upVotes, upVotesNeeded, addr, voted, setLoading }: FundVoteProps) => {
const wallet = useAtomValue(walletStarknetkitLatestAtom);
const chainId = useAtomValue(activeChainId);
const networkEnvironment = process.env.NEXT_PUBLIC_CHAIN_ID;

const [progress, setProgress] = useState(calculatePorcentage(upVotes, upVotesNeeded));
const [currentUpvotes, setCurrentUpvotes] = useState(upVotes);
const voteMessage = `🗳️ Voted for ${name} on Go Stark Me! Support now: https://gostarkme.com 🙌💫 @undefined_org_ @Starknet`;
Expand Down Expand Up @@ -108,15 +106,15 @@ export const FundVote = ({ name, upVotes, upVotesNeeded, addr, voted, setLoading
<div className="text-center">
<button
onClick={handleVoteClick}
disabled={isVoting || chainId !== networkEnvironment}
disabled={isVoting || chainId !== CHAIN_ID && chainId != BRAAVOS_CHAIN_ID}
className={`bg-darkblue text-white py-2 px-4 md:py-3 md:px-6 rounded-md text-xs md:text-sm shadow-md hover:bg-starkorange
active:bg-darkblue ease-in-out duration-500 ${chainId !== networkEnvironment ? "opacity-50 cursor-not-allowed" : ""}`}
active:bg-darkblue ease-in-out duration-500 ${chainId !== CHAIN_ID && chainId != BRAAVOS_CHAIN_ID ? "opacity-50 cursor-not-allowed" : ""}`}
>
Vote
</button>
{chainId !== networkEnvironment && (
{chainId !== CHAIN_ID && chainId != BRAAVOS_CHAIN_ID && (
<p className="text-xs md:text-sm text-gray-500 mt-2">
Your wallet is connected to the wrong network. Please switch to {networkEnvironment}.
Your wallet is connected to the wrong network. Please switch to {CHAIN_ID}.
</p>
)}
</div>
Expand Down
5 changes: 4 additions & 1 deletion constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ export const navItems = [
// { label: 'My funds', href: '/app/myfunds' }
];

export const upVotesNeeded = 50;
export const upVotesNeeded = 50;

export const BRAAVOS_CHAIN_ID = CHAIN_ID == constants.NetworkName.SN_MAIN ?
"0x534e5f4d41494e" : "0x534e5f5345504f4c4941";
Loading