Skip to content

Commit

Permalink
Merge pull request #299 from EmmanuelAR/feat/298
Browse files Browse the repository at this point in the history
Fix is owner validation
  • Loading branch information
EmmanuelAR authored Dec 18, 2024
2 parents aab8a21 + 44dcbd8 commit 819a559
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions frontend/gostarkme-web/components/modules/Fund/Fund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ const Fund = () => {
let evidenceLink = await fundContract.get_evidence_link();
let contactHandle = await fundContract.get_contact_handle();
// Fetch owner
const owner = (await fundContract.get_owner()).toString();
setIsOwner(owner.toLowerCase() === wallet?.account?.address.toLowerCase());
const ownerDecimal = (await fundContract.get_owner()).toString();
const ownerHex = "0x"+BigInt(ownerDecimal).toString(16);
setIsOwner(ownerHex.toLowerCase() === wallet?.account?.address.toLowerCase());
// USER VOTED?
let voted = await fundContract.get_voter(wallet != undefined ? wallet?.account.address : "0x0000000000");

Expand Down Expand Up @@ -113,15 +114,13 @@ const Fund = () => {
)}
{Number(fund.state) === 2 && (
<>
{!isOwner && (
<FundDonate
currentBalance={fund.currentBalance}
goal={fund.goal}
addr={fund.addr}
name={fund.name}
icon={starknetlogo}
/>
)}
</>
)}
{Number(fund.state) === 3 && isOwner && (
Expand Down
4 changes: 2 additions & 2 deletions frontend/gostarkme-web/components/modules/Fund/FundDonate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ const FundDonate = ({ currentBalance, goal, addr, name, icon }: FundDonateProps)
const chainId = useAtomValue(activeChainId);
const networkEnvironment = process.env.NEXT_PUBLIC_CHAIN_ID;
const progress = calculatePorcentage(localBalance, goal);

const donationMessage = `🙌 Supporting ${name} on Go Stark Me! Donate now: https://web3wagers.github.io/gostarkme/ 💪 @undefined_org_ @Starknet`;
const [donationMessage, setDonationMessage] = useState('');

const handleAmountChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const value = e.target.value === "" ? "" : Number(e.target.value);
Expand Down Expand Up @@ -97,6 +96,7 @@ const FundDonate = ({ currentBalance, goal, addr, name, icon }: FundDonateProps)
if (typeof amount === 'number') {
setLocalBalance(prev => Number(prev) + amount);
}
setDonationMessage(`🙌 Supporting ${name} on Go Stark Me with ${amount} $STRK! Donate now: https://web3wagers.github.io/gostarkme/ 💪 @undefined_org_ @Starknet`);
setAmount("");
setLatestTx(tx.transaction_hash);
setShowSuccessPopup(true);
Expand Down

0 comments on commit 819a559

Please sign in to comment.