There is no fundings to display.
diff --git a/frontend/gostarkme-web/components/dashboard/fundCard.tsx b/frontend/gostarkme-web/components/dashboard/fundCard.tsx
index 28b13a0..4b6cee2 100644
--- a/frontend/gostarkme-web/components/dashboard/fundCard.tsx
+++ b/frontend/gostarkme-web/components/dashboard/fundCard.tsx
@@ -22,7 +22,7 @@ const FundCards = ({ fund, index }: FundCardProps) => {
const setClickedFund = useSetAtom(clickedFundState);
function handleNav() {
- setClickedFund(Number(fund.fund_id));
+ setClickedFund({id: Number(fund.fund_id), name: fund.title});
}
return (
diff --git a/frontend/gostarkme-web/components/modules/Fund/Fund.tsx b/frontend/gostarkme-web/components/modules/Fund/Fund.tsx
index a963103..2407295 100644
--- a/frontend/gostarkme-web/components/modules/Fund/Fund.tsx
+++ b/frontend/gostarkme-web/components/modules/Fund/Fund.tsx
@@ -27,7 +27,7 @@ const Fund = () => {
const clickedFund = useAtomValue(clickedFundState);
async function getDetails() {
- let addr = await fundManagerContract.getFund(clickedFund);
+ let addr = await fundManagerContract.getFund(clickedFund?.id);
addr = "0x" + addr.toString(16);
const fundContract = new Contract(fundAbi, addr, wallet?.account);
@@ -51,16 +51,8 @@ const Fund = () => {
let evidenceLink = await fundContract.get_evidence_link();
- if (evidenceLink.indexOf('https') <= 0) {
- evidenceLink = "https://" + evidenceLink;
- }
-
let contactHandle = await fundContract.get_contact_handle();
- if (contactHandle.indexOf('https') <= 0) {
- contactHandle = "https://" + contactHandle;
- }
-
setFund({
name: name,
desc: desc,
@@ -97,10 +89,10 @@ const Fund = () => {
{fund.desc}
Evidence
-
{fund.evidenceLink}
+
{fund.evidenceLink}
Contact handle
-
{fund.contactHandle}
+
{fund.contactHandle}
{Number(fund.state) === 0 &&
Fund is currently innactive.
}
{Number(fund.state) === 1 &&
}
{Number(fund.state) === 2 &&
}
diff --git a/frontend/gostarkme-web/components/modules/Fund/FundDonate.tsx b/frontend/gostarkme-web/components/modules/Fund/FundDonate.tsx
index 6a6f063..165c651 100644
--- a/frontend/gostarkme-web/components/modules/Fund/FundDonate.tsx
+++ b/frontend/gostarkme-web/components/modules/Fund/FundDonate.tsx
@@ -3,14 +3,15 @@
import { calculatePorcentage } from "@/app/utils";
import ProgressBar from "@/components/ui/ProgressBar";
import { provider } from "@/constants";
-import { fundAbi } from "@/contracts/abis/fund";
import { strkAbi } from "@/contracts/abis/strk";
import { addrSTRK } from "@/contracts/addresses";
import { walletStarknetkitLatestAtom } from "@/state/connectedWallet";
-import { useAtomValue } from "jotai";
+import { useAtomValue, useSetAtom } from "jotai";
import Image, { StaticImageData } from "next/image";
import { useState } from "react";
import { Contract, InvokeFunctionResponse } from "starknet";
+import { useRouter } from "next/navigation";
+import { latestTxAtom } from "@/state/latestTx";
interface FundDonateProps {
currentBalance: number;
@@ -22,8 +23,10 @@ interface FundDonateProps {
const FundDonate = ({ currentBalance, goal, addr, icon }: FundDonateProps) => {
const [amount, setAmount] = useState
("");
const [error, setError] = useState("");
+ const setLatestTx = useSetAtom(latestTxAtom);
const wallet = useAtomValue(walletStarknetkitLatestAtom);
const progress = calculatePorcentage(currentBalance, goal);
+ const router = useRouter();
const handleAmountChange = (e: React.ChangeEvent) => {
const value = e.target.value === "" ? "" : Number(e.target.value);
@@ -46,7 +49,8 @@ const FundDonate = ({ currentBalance, goal, addr, icon }: FundDonateProps) => {
});
wallet?.account?.execute(transferCall)
.then(async (resp: InvokeFunctionResponse) => {
- console.log("DONE!");
+ setLatestTx({ txHash: resp.transaction_hash, type: "donation" });
+ router.push("/app/confirmation");
})
.catch((e: any) => { console.log("error increase balance =", e) });
}
diff --git a/frontend/gostarkme-web/components/modules/Fund/FundVote.tsx b/frontend/gostarkme-web/components/modules/Fund/FundVote.tsx
index f70f8c5..eb6db6c 100644
--- a/frontend/gostarkme-web/components/modules/Fund/FundVote.tsx
+++ b/frontend/gostarkme-web/components/modules/Fund/FundVote.tsx
@@ -3,8 +3,10 @@ import { Button } from "@/components/ui/Button";
import ProgressBar from "@/components/ui/ProgressBar";
import { fundAbi } from "@/contracts/abis/fund";
import { walletStarknetkitLatestAtom } from "@/state/connectedWallet";
-import { useAtomValue } from "jotai";
+import { latestTxAtom } from "@/state/latestTx";
+import { useAtomValue, useSetAtom } from "jotai";
import { Contract, InvokeFunctionResponse } from "starknet";
+import { useRouter } from "next/navigation";
interface FundVoteProps {
upVotes: number,
@@ -20,15 +22,19 @@ export const FundVote = ({ upVotes, upVotesNeeded, addr, setLoading, getDetails
const progress = calculatePorcentage(upVotes, upVotesNeeded);
- function vote() {
+ const setLatestTx = useSetAtom(latestTxAtom);
+
+ const router = useRouter();
+
+ async function vote() {
setLoading(true);
const fundContract = new Contract(fundAbi, addr, wallet?.account);
- const myCall = fundContract.populate("receiveVote", []);
- wallet?.account?.execute(myCall)
+ fundContract.receiveVote()
.then(async (resp: InvokeFunctionResponse) => {
- getDetails();
+ setLatestTx({ txHash: resp.transaction_hash, type: "vote" });
+ router.push("/app/confirmation");
})
- .catch((e: any) => { console.log("error increase balance =", e) });
+ .catch((e: any) => { getDetails() });
}
return (
diff --git a/frontend/gostarkme-web/components/modules/confirmation/Confirmation.tsx b/frontend/gostarkme-web/components/modules/confirmation/Confirmation.tsx
new file mode 100644
index 0000000..edb75c4
--- /dev/null
+++ b/frontend/gostarkme-web/components/modules/confirmation/Confirmation.tsx
@@ -0,0 +1,58 @@
+'use client';
+import React, { useEffect } from "react";
+import CreationConfirmation from "./CreationConfirmation";
+import VoteConfirmation from "./VoteConfirmation";
+import DonationConfirmation from "./DonationConfirmation";
+import { useAtom, useAtomValue } from "jotai";
+import { latestTxAtom } from "@/state/latestTx";
+import Navbar from "@/components/ui/Navbar";
+import { navItems } from "@/constants";
+import { clickedFundState } from "@/state/nFunds";
+import { walletStarknetkitLatestAtom } from "@/state/connectedWallet";
+
+const Confirmation = () => {
+ const tx = useAtomValue(latestTxAtom);
+ const actualFund = useAtomValue(clickedFundState);
+ const voteMessage = ` ๐ณ๏ธ Just cast my vote for an amazing cause called ${actualFund?.name} on Go Stark Me! This fund needs more votes to start raising fundsโevery vote counts! Letโs support projects that make a difference at https://web3wagers.github.io/gostarkme/ @web3_wagers ๐๐ซ #GoStarkMe #Starknet #CommunityPower`;
+ const donationMessage = `๐ Proud to support ${actualFund?.name} on Go Stark Me! Donations make a difference. ๐ช Go ahead and donate at https://web3wagers.github.io/gostarkme/ @web3_wagers #Starknet #GoStarkMe #Web3Wagers`;
+ const newFundMessage = `๐ Just launched a new fund on Go Stark Me called ${actualFund?.name}! Iโm raising support for an important cause, and every contribution makes a difference. Join me in making an impact at https://web3wagers.github.io/gostarkme/! ๐ช๐ Check it out on @web3_wagers #GoStarkMe #Starknet #BlockchainForGood`;
+
+ return (
+ <>
+
+ {tx === undefined &&
+
+ The place you are trying to reach is not enabled yet.
+
+ }
+
+ {tx !== undefined &&
+
+
Success 🚀
+ {tx?.type === "newfund" &&
+
+ }
+
+ {tx?.type === "vote" &&
+
+ }
+
+ {tx?.type === "donation" &&
+
+ }
+
+ }
+ >
+ )
+};
+
+export default Confirmation;
diff --git a/frontend/gostarkme-web/components/modules/confirmation/CreationConfirmation.tsx b/frontend/gostarkme-web/components/modules/confirmation/CreationConfirmation.tsx
new file mode 100644
index 0000000..fca5460
--- /dev/null
+++ b/frontend/gostarkme-web/components/modules/confirmation/CreationConfirmation.tsx
@@ -0,0 +1,22 @@
+import ShareXButton from "@/components/ui/ShareOnX";
+import React from "react";
+
+interface CreationConfirmationProps {
+ txHash: String;
+ message: String;
+}
+
+const CreationConfirmation: React.FC = ({
+ txHash,
+ message,
+}) => (
+ <>
+
+
Your funding was created, take a look at the transaction here.
+
Share your contribution via X to tell everyone how cool you are
+
+
+ >
+);
+
+export default CreationConfirmation;
diff --git a/frontend/gostarkme-web/components/modules/confirmation/DonationConfirmation.tsx b/frontend/gostarkme-web/components/modules/confirmation/DonationConfirmation.tsx
new file mode 100644
index 0000000..6641179
--- /dev/null
+++ b/frontend/gostarkme-web/components/modules/confirmation/DonationConfirmation.tsx
@@ -0,0 +1,22 @@
+import ShareXButton from "@/components/ui/ShareOnX";
+import React from "react";
+
+interface DonationConfirmationProps {
+ txHash: String;
+ message: String;
+}
+
+const DonationConfirmation: React.FC = ({
+ txHash,
+ message,
+}) => (
+ <>
+
+
Your donation was sent to the funding, take a look at the transaction here.
+
Share your contribution via X to tell everyone how cool you are
+
+
+ >
+);
+
+export default DonationConfirmation;
diff --git a/frontend/gostarkme-web/components/modules/confirmation/VoteConfirmation.tsx b/frontend/gostarkme-web/components/modules/confirmation/VoteConfirmation.tsx
new file mode 100644
index 0000000..2dfc05d
--- /dev/null
+++ b/frontend/gostarkme-web/components/modules/confirmation/VoteConfirmation.tsx
@@ -0,0 +1,22 @@
+import ShareXButton from "@/components/ui/ShareOnX";
+import React from "react";
+
+interface VoteConfirmationProps {
+ txHash: String;
+ message: String;
+}
+
+const VoteConfirmation: React.FC = ({
+ txHash,
+ message,
+}) => (
+ <>
+
+
Your vote was submitted, take a look at the transaction here.
+
Share your contribution via X to tell everyone how cool you are
+
+
+ >
+);
+
+export default VoteConfirmation;
diff --git a/frontend/gostarkme-web/components/modules/newfunding/Stages.tsx b/frontend/gostarkme-web/components/modules/newfunding/Stages.tsx
index 605523b..1ea0929 100644
--- a/frontend/gostarkme-web/components/modules/newfunding/Stages.tsx
+++ b/frontend/gostarkme-web/components/modules/newfunding/Stages.tsx
@@ -5,23 +5,29 @@ import DescriptionStep from "./DescriptionStep";
import { Contract, wallet, InvokeFunctionResponse, shortString } from "starknet";
import { fundManager } from "@/contracts/abis/fundManager";
import { FUND_MANAGER_ADDR } from "@/constants";
-import { useAtomValue } from "jotai";
+import { useAtom, useAtomValue, useSetAtom } from "jotai";
import { walletStarknetkitLatestAtom } from "@/state/connectedWallet";
-
+import { latestTxAtom } from "@/state/latestTx";
+import { useRouter } from "next/navigation";
+import { clickedFundState } from "@/state/nFunds";
const Stages = () => {
const [currentStep, setCurrentStep] = useState(0);
const [fundingName, setFundingName] = useState("");
const [goal, setGoal] = useState("");
const [fundingDescription, setFundingDescription] = useState("");
- const [errors, setErrors] = useState({ fundingName: "", goal: "",evidenceLink: "",contactHandle: "" });
+ const [errors, setErrors] = useState({ fundingName: "", goal: "", evidenceLink: "", contactHandle: "" });
const [evidenceLink, setEvidenceLink] = useState("");
const [contactHandle, setContactHandle] = useState("");
+ const setLatesTx = useSetAtom(latestTxAtom);
+ const setActualFund = useSetAtom(clickedFundState);
+
const wallet = useAtomValue(walletStarknetkitLatestAtom);
+ const router = useRouter();
const handleNextStep = () => {
// Reset errors
- setErrors({ fundingName: "", goal: "", evidenceLink: "", contactHandle: ""});
+ setErrors({ fundingName: "", goal: "", evidenceLink: "", contactHandle: "" });
// Validate fields
let hasErrors = false;
@@ -58,14 +64,15 @@ const Stages = () => {
newFund();
};
- function newFund() {
+ async function newFund() {
const fundManagerContract = new Contract(fundManager, FUND_MANAGER_ADDR, wallet?.account);
- const myCall = fundManagerContract.newFund(fundingName,goal,evidenceLink,contactHandle,fundingDescription);
- wallet?.account?.execute(myCall)
+ fundManagerContract.newFund(fundingName, goal, evidenceLink, contactHandle, fundingDescription)
.then(async (resp: InvokeFunctionResponse) => {
- console.log("increaseBalance txH =", resp.transaction_hash);
+ setLatesTx({ txHash: resp.transaction_hash, type: "newfund" });
+ setActualFund({id: 0, name: fundingName});
+ router.push("/app/confirmation");
})
- .catch((e: any) => { console.log("error increase balance =", e) });
+ .catch((e: any) => { console.log(e) });
}
return (
@@ -96,9 +103,8 @@ const Stages = () => {
{[0, 1].map((_, index) => (
setCurrentStep(index)}
/>
))}
diff --git a/frontend/gostarkme-web/components/ui/ShareOnX.tsx b/frontend/gostarkme-web/components/ui/ShareOnX.tsx
new file mode 100644
index 0000000..a3da1ae
--- /dev/null
+++ b/frontend/gostarkme-web/components/ui/ShareOnX.tsx
@@ -0,0 +1,28 @@
+import React from 'react';
+
+
+interface ShareXButtonProps {
+ message: String;
+}
+
+const ShareXButton : React.FC = ({message}) => {
+ const tweetText = encodeURIComponent(message.toString());
+ const tweetUrl = `https://twitter.com/intent/tweet?text=${tweetText}`;
+ return (
+
+ );
+};
+
+export default ShareXButton;
\ No newline at end of file
diff --git a/frontend/gostarkme-web/package.json b/frontend/gostarkme-web/package.json
index ef6f5cc..2b81d3f 100644
--- a/frontend/gostarkme-web/package.json
+++ b/frontend/gostarkme-web/package.json
@@ -18,6 +18,7 @@
"next": "14.2.10",
"react": "^18",
"react-dom": "^18",
+ "react-router-dom": "^6.28.0",
"starknet": "^6.7.0",
"starknetkit": "^1.1.5",
"usehooks-ts": "^3.1.0"
diff --git a/frontend/gostarkme-web/state/latestTx.ts b/frontend/gostarkme-web/state/latestTx.ts
new file mode 100644
index 0000000..6d40407
--- /dev/null
+++ b/frontend/gostarkme-web/state/latestTx.ts
@@ -0,0 +1,8 @@
+import { atomWithReset } from "jotai/utils"
+
+interface tx {
+ txHash: String;
+ type: String
+}
+
+export const latestTxAtom = atomWithReset(undefined)
\ No newline at end of file
diff --git a/frontend/gostarkme-web/state/nFunds.ts b/frontend/gostarkme-web/state/nFunds.ts
index c6d7458..97a12c1 100644
--- a/frontend/gostarkme-web/state/nFunds.ts
+++ b/frontend/gostarkme-web/state/nFunds.ts
@@ -1,5 +1,10 @@
import { atomWithReset } from "jotai/utils"
+interface fundInfo {
+ id: Number;
+ name: String
+}
+
export const clickedFundState = atomWithReset<
- Number | null | undefined
+ fundInfo | null | undefined
>(undefined)
\ No newline at end of file