Skip to content

Commit

Permalink
use correct chain
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkas committed Oct 21, 2024
1 parent 7dcd856 commit 5475a65
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/web/pages/api/proofs/discountCode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { logger } from 'apps/web/src/utils/logger';
import { withTimeout } from 'apps/web/pages/api/decorators';
import { Address, Hash, stringToHex } from 'viem';
import { USERNAME_DISCOUNT_CODE_VALIDATORS } from 'apps/web/src/addresses/usernames';
import { baseSepolia } from 'viem/chains';
import { getDiscountCode } from 'apps/web/src/utils/proofs/discount_code_storage';

export type DiscountCodeResponse = {
Expand All @@ -26,6 +25,8 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
return res.status(validationErr.status).json({ error: validationErr.error });
}

const chainId = parseInt(chain as string);

if (!code || typeof code !== 'string') {
return res.status(500).json({ error: 'Discount code invalid' });
}
Expand Down Expand Up @@ -58,14 +59,13 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
const signature = await signDiscountMessageWithTrustedSigner(
address as Address,
couponCodeUuid,
// TODO: Set variable chain
USERNAME_DISCOUNT_CODE_VALIDATORS[baseSepolia.id],
USERNAME_DISCOUNT_CODE_VALIDATORS[chainId],
expirationTimeUnix,
);

// 4. Return the discount data
const result: DiscountCodeResponse = {
discountValidatorAddress: USERNAME_DISCOUNT_CODE_VALIDATORS[baseSepolia.id],
discountValidatorAddress: USERNAME_DISCOUNT_CODE_VALIDATORS[chainId],
address: address as Address,
signedMessage: signature,
};
Expand Down

0 comments on commit 5475a65

Please sign in to comment.