Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added app/assets/gift-cards/kissofmatcha.agi.cash.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion app/features/accounts/account-repository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type QueryClient, useQueryClient } from '@tanstack/react-query';
import type { DistributedOmit } from 'type-fest';
import { z } from 'zod';
import { normalizeMintUrl } from '~/lib/cashu';
import { ProofSchema } from '~/lib/cashu/types';
import type { Currency } from '~/lib/money';
import {
Expand Down Expand Up @@ -122,7 +123,7 @@ export class AccountRepository {
let details = {};
if (accountInput.type === 'cashu') {
details = CashuAccountDetailsDbDataSchema.parse({
mint_url: accountInput.mintUrl,
mint_url: normalizeMintUrl(accountInput.mintUrl),
is_test_mint: accountInput.isTestMint,
keyset_counters: accountInput.keysetCounters,
} satisfies z.input<typeof CashuAccountDetailsDbDataSchema>);
Expand Down
2 changes: 2 additions & 0 deletions app/features/gift-cards/use-discover-cards.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useMemo } from 'react';
import blockAndBeanCard from '~/assets/gift-cards/blockandbean.agi.cash.webp';
import compassCoffeeCard from '~/assets/gift-cards/compass.agi.cash.webp';
import kissOfMatchaCard from '~/assets/gift-cards/kissofmatcha.agi.cash.webp';
import mapleCard from '~/assets/gift-cards/maple.agi.cash.webp';
import mariposaCard from '~/assets/gift-cards/mariposa.agi.cash.webp';
import pinkOwlCoffeeCard from '~/assets/gift-cards/pinkowl.agi.cash.webp';
Expand All @@ -23,6 +24,7 @@ const GIFT_CARD_IMAGES: Record<string, string> = {
'https://maple.agi.cash': mapleCard,
'https://mariposa.agi.cash': mariposaCard,
'https://compass.agi.cash': compassCoffeeCard,
'https://kissofmatcha.agi.cash': kissOfMatchaCard,
'https://pinkowl.agi.cash': pinkOwlCoffeeCard,
'https://shack.agi.cash': theShackCard,
'https://theepicureantrader.agi.cash': theEpicurianTraderCard,
Expand Down
5 changes: 4 additions & 1 deletion app/features/receive/receive-cashu-token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ export default function ReceiveToken({
className="w-[200px]"
loading={isClaimLoading}
>
{isReceiveAccountKnown ? 'Claim' : 'Add Mint and Claim'}
{!isReceiveAccountKnown &&
receiveAccount.purpose === 'transactional'
? 'Add Mint and Claim'
: 'Claim'}
</Button>
</PageFooter>
)}
Expand Down
3 changes: 2 additions & 1 deletion app/features/user/user-repository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { QueryClient } from '@tanstack/react-query';
import type { DistributedOmit } from 'type-fest';
import type { z } from 'zod';
import { normalizeMintUrl } from '~/lib/cashu';
import type { Currency } from '~/lib/money';
import type { Account, RedactedAccount } from '../accounts/account';
import {
Expand Down Expand Up @@ -187,7 +188,7 @@ export class WriteUserRepository {
details: (() => {
if (account.type === 'cashu') {
return CashuAccountDetailsDbDataSchema.parse({
mint_url: account.mintUrl,
mint_url: normalizeMintUrl(account.mintUrl),
is_test_mint: account.isTestMint,
keyset_counters: {},
} satisfies z.input<typeof CashuAccountDetailsDbDataSchema>);
Expand Down
17 changes: 10 additions & 7 deletions app/lib/cashu/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ export const getCashuWallet = (
});
};

/**
* Normalize a mint URL by trimming whitespace, lowercasing, and stripping
* trailing slashes. Use this whenever a mint URL is stored or compared so
* variants like `https://Mint.io/` and `https://mint.io` match.
*/
export const normalizeMintUrl = (mintUrl: string): string =>
mintUrl.trim().toLowerCase().replace(/\/+$/, '');

/**
* Check if a mint is a test mint by checking if the mint is in the list of
* known test mints.
Expand All @@ -276,9 +284,7 @@ export const getCashuWallet = (
* @returns True if the mint is a known test mint
*/
export const checkIsTestMint = (mintUrl: string): boolean => {
// Normalize URL by removing trailing slash and converting to lowercase
const normalizedUrl = mintUrl.toLowerCase().replace(/\/+$/, '');
return knownTestMints.includes(normalizedUrl);
return knownTestMints.includes(normalizeMintUrl(mintUrl));
};

/**
Expand All @@ -288,8 +294,5 @@ export const checkIsTestMint = (mintUrl: string): boolean => {
* @returns True if the mint URLs are equal
*/
export const areMintUrlsEqual = (a: string, b: string) => {
return (
a.toLowerCase().replace(/\/+$/, '').trim() ===
b.toLowerCase().replace(/\/+$/, '').trim()
);
return normalizeMintUrl(a) === normalizeMintUrl(b);
};
Loading