Skip to content

Commit

Permalink
feat: add Realms x braavos quest (#480)
Browse files Browse the repository at this point in the history
* feat: add Realms x braavos quest & add Lords in boost tokens

* fix: tests

* fix: update timeout
  • Loading branch information
irisdv authored Jan 25, 2024
1 parent e070a0b commit f38cdcf
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/quest-boost/claim/[boostId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ export default function Page({ params }: BoostQuestPageProps) {
height={97}
alt="usdc icon"
/>
) : boost && getTokenName(boost?.token) === "LORDS" ? (
<CDNImage
src={"/icons/lord.webp"}
priority
width={97}
height={97}
alt="lords icon"
/>
) : (
<CDNImage
src={"/icons/eth.svg"}
Expand Down
4 changes: 4 additions & 0 deletions components/quest-boost/TokenSymbol.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const TokenSymbol: FunctionComponent<TokenSymbolProps> = ({
setTokenImageLink("/icons/eth.svg");
imageDimensions = { width: 15, height: 20 };
break;
case TOKEN_ADDRESS_MAP[network].LORDS:
setTokenImageLink("/icons/lord.webp");
imageDimensions = { width: 20, height: 20 };
break;
default:
setTokenImageLink("/icons/usdc.svg");
break;
Expand Down
2 changes: 1 addition & 1 deletion components/quests/questDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ const QuestDetails: FunctionComponent<QuestDetailsProps> = ({
verifyRedirect={task.verify_redirect}
verifyEndpoint={
task.verify_endpoint_type &&
task.verify_endpoint_type === "default"
task.verify_endpoint_type.startsWith("default")
? `${task.verify_endpoint}?addr=${hexToDecimal(address)}`
: task.verify_endpoint_type === "quiz"
? task.verify_endpoint
Expand Down
8 changes: 7 additions & 1 deletion components/quests/task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,20 @@ const Task: FunctionComponent<Task> = ({
}

if (verifyRedirect) {
// if the verify_endpoint_type contains a timeout indication we use it,
// otherwise we use the default timeout of 15 seconds
const timeout =
verifyEndpointType.split("_").length === 2
? parseInt(verifyEndpointType.split("_")[1]) ?? 15000
: 15000;
await new Promise((resolve) =>
setTimeout(() => {
setIsVerified(true);
checkUserRewards();
refreshRewards();
setIsLoading(false);
resolve(null);
}, 15000)
}, timeout)
);
} else {
setIsVerified(true);
Expand Down
Binary file added public/braavos/realms.webp
Binary file not shown.
Binary file added public/icons/lord.webp
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/utils/tokenService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ describe("getTokenName function", () => {
expect(tokenName).toBe("ETH");
});

it("should return 'LORDS' for LORDS token address on the current network", () => {
// Assuming TOKEN_ADDRESS_MAP is defined and has the necessary structure
const tokenName = getTokenName(TOKEN_ADDRESS_MAP["MAINNET"].LORDS);
expect(tokenName).toBe("LORDS");
});

it("should return 'USDC' for unknown token addresses on the current network", () => {
// Assuming TOKEN_ADDRESS_MAP is defined and has the necessary structure
const tokenName = getTokenName("unknownTokenAddress");
Expand Down
2 changes: 2 additions & 0 deletions utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ export const TOKEN_ADDRESS_MAP = {
MAINNET: {
USDC: "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
ETH: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
LORDS: "0x0124aeb495b947201f5fac96fd1138e326ad86195b98df6dec9009158a533b49",
},
TESTNET: {
USDC: "0x005a643907b9a4bc6a55e9069c4fd5fd1f5c79a22470690f75556c4736e34426",
ETH: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
LORDS: "0x05e367ac160e5f90c5775089b582dfc987dd148a5a2f977c49def2a6644f724b",
},
};
2 changes: 2 additions & 0 deletions utils/tokenService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const getTokenName = (token: string) => {
return "USDC";
case TOKEN_ADDRESS_MAP[network].ETH:
return "ETH";
case TOKEN_ADDRESS_MAP[network].LORDS:
return "LORDS";
default:
return "USDC";
}
Expand Down

1 comment on commit f38cdcf

@vercel
Copy link

@vercel vercel bot commented on f38cdcf Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.