Skip to content

Commit

Permalink
Merge pull request #885 from ooochoche/testnet
Browse files Browse the repository at this point in the history
fix: boost token
  • Loading branch information
Marchand-Nicolas authored Oct 17, 2024
2 parents 420026d + 525586e commit ca3ee66
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
24 changes: 14 additions & 10 deletions app/admin/quests/dashboard/[questId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export default function Page({ params }: QuestIdProps) {
contract_calls: task.calls,
},
};
} else if(task.task_type === "custom_api"){
} else if (task.task_type === "custom_api") {
return {
type: "CustomApi",
data: {
Expand All @@ -239,11 +239,10 @@ export default function Page({ params }: QuestIdProps) {
api_href: task.href,
api_url: task.api_url,
api_cta: task.cta,
api_regex: task.regex
}
}
api_regex: task.regex,
},
};
}

});

const res = await Promise.all(taskPromises);
Expand All @@ -270,6 +269,9 @@ export default function Page({ params }: QuestIdProps) {
await AdminService.updateBoost({
...boostInput,
hidden: !showBoost,
amount: Number(boostInput.amount),
num_of_winners: Number(boostInput.num_of_winners),
token_decimals: Number(boostInput.token_decimals),
});

return;
Expand Down Expand Up @@ -546,8 +548,7 @@ export default function Page({ params }: QuestIdProps) {
cta: step.data.contract_cta,
calls: JSON.parse(step.data.contract_calls),
});
}
else if(step.type === "CustomApi"){
} else if (step.type === "CustomApi") {
await AdminService.createCustomApi({
quest_id: questId.current,
name: step.data.api_name,
Expand All @@ -556,7 +557,7 @@ export default function Page({ params }: QuestIdProps) {
regex: step.data.api_regex,
href: step.data.api_href,
cta: step.data.api_cta,
})
});
}
} catch (error) {
showNotification(`Error adding ${step.type} task: ${error}`, "error");
Expand Down Expand Up @@ -666,7 +667,10 @@ export default function Page({ params }: QuestIdProps) {
calls: JSON.parse(step.data.contract_calls),
});
} catch (error) {
showNotification(`Error updating ${step.type} task: ${error}`, "error");
showNotification(
`Error updating ${step.type} task: ${error}`,
"error"
);
}
} else if (step.type === "CustomApi") {
await AdminService.updateCustomApi({
Expand Down Expand Up @@ -817,7 +821,7 @@ export default function Page({ params }: QuestIdProps) {
<AdminQuestDetails
quest={questData}
// eslint-disable-next-line @typescript-eslint/no-empty-function
setShowDomainPopup={() => { }}
setShowDomainPopup={() => {}}
hasRootDomain={false}
rewardButtonTitle={questData.disabled ? "Enable" : "Disable"}
onRewardButtonClick={async () => {
Expand Down
17 changes: 9 additions & 8 deletions components/admin/formSteps/RewardDetailsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,19 @@ const RewardDetailsForm: FunctionComponent<RewardDetailsFormProps> = ({

const handleBoostTokenChange = useCallback(
(event: SelectChangeEvent) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const tokenAddress = event.target.value;
const tokenName =
Object.keys(TOKEN_ADDRESS_MAP[network]).find(
(key) => TOKEN_ADDRESS_MAP[network][key] === tokenAddress
) || "";
setBoostInput((prev: any) => ({
...prev,
token: event.target.value,
// token decimals is a value which has different tokens which we support and use their decimals here
token: tokenAddress,
token_decimals:
TOKEN_DECIMAL_MAP[
event.target.value as keyof typeof TOKEN_DECIMAL_MAP
],
TOKEN_DECIMAL_MAP[tokenName as keyof typeof TOKEN_DECIMAL_MAP],
}));
},
[setBoostInput]
[setBoostInput, network]
);

return (
Expand Down Expand Up @@ -142,7 +143,7 @@ const RewardDetailsForm: FunctionComponent<RewardDetailsFormProps> = ({
handleChange={handleBoostTokenChange}
options={Object.keys(TOKEN_ADDRESS_MAP[network]).map((eachItem) => {
return {
value: eachItem,
value: TOKEN_ADDRESS_MAP[network][eachItem],
label: eachItem,
};
})}
Expand Down
2 changes: 1 addition & 1 deletion constants/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const TOP_50_TAB_STRING = "Top 50";
export const rankOrder = [1, 2, 3];
export const rankOrderMobile = [1, 2, 3];

export const TOKEN_ADDRESS_MAP = {
export const TOKEN_ADDRESS_MAP: Record<string, Record<string, string>> = {
MAINNET: {
USDC: "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
ETH: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
Expand Down

0 comments on commit ca3ee66

Please sign in to comment.