Skip to content

Commit

Permalink
feat: add support for multiple winners
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushtom committed Jan 10, 2024
1 parent 02c424b commit dfa2d90
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/quest-boost/[boostId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function Page({ params }: BoostQuestPageProps) {

const handleButtonClick = useCallback(() => {
if (!boost) return;
if (hexToDecimal(boost?.winner ?? "") !== hexToDecimal(address))
if (boost?.winner?.includes(hexToDecimal(address)))
updateBoostClaimStatus(boost?.id, true);

router.push(`/quest-boost/claim/${boost?.id}`);
Expand Down
6 changes: 2 additions & 4 deletions app/quest-boost/claim/[boostId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ export default function Page({ params }: BoostQuestPageProps) {

const isUserWinner = useMemo(() => {
return (
boost &&
boost?.winner &&
hexToDecimal(boost?.winner) === hexToDecimal(address)
boost && boost?.winner && boost?.winner?.includes(hexToDecimal(address))
);
}, [boost, address]);

Expand Down Expand Up @@ -171,7 +169,7 @@ export default function Page({ params }: BoostQuestPageProps) {
<Button
disabled={
boost?.claimed ||
hexToDecimal(boost?.winner ?? "") !== hexToDecimal(address)
boost?.winner?.includes(hexToDecimal(address))
}
onClick={handleClaimClick}
>
Expand Down
3 changes: 2 additions & 1 deletion types/frontTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ type Boost = {
expiry: number;
quests: number[];
claimed: boolean;
winner: string | null;
winner: string[] | null;
img_url: string;
id: number;
name: string;
num_of_winners: number;
};

type Reward = {
Expand Down
2 changes: 1 addition & 1 deletion utils/callData.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CallData, uint256 } from "starknet";

export function boostClaimCall(boost: Boost, sign: Signature) {
const amount = uint256.bnToUint256(boost.amount);
const amount = uint256.bnToUint256(boost.amount / boost.num_of_winners);
const claimCallData = CallData.compile({
amount: amount,
token: boost.token,
Expand Down

0 comments on commit dfa2d90

Please sign in to comment.