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
4 changes: 4 additions & 0 deletions src/__tests__/evm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jest.mock('@dfx.swiss/react', () => ({
GNOSIS: 'Gnosis',
BINANCE_SMART_CHAIN: 'BinanceSmartChain',
HAQQ: 'Haqq',
CITREA: 'Citrea',
CITREA_TESTNET: 'CitreaTestnet',
BITCOIN: 'Bitcoin',
LIGHTNING: 'Lightning',
SOLANA: 'Solana',
Expand Down Expand Up @@ -83,6 +85,8 @@ describe('Evm', () => {
Blockchain.GNOSIS,
Blockchain.BINANCE_SMART_CHAIN,
Blockchain.HAQQ,
Blockchain.CITREA,
Blockchain.CITREA_TESTNET,
];

evmChains.forEach(chain => {
Expand Down
194 changes: 194 additions & 0 deletions src/config/feature-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ export const FeatureTree: Page[] = [
page: 'buy-gnosis',
},
},
{
id: 'citrea',
img: 'citrea',
next: {
page: 'buy-citrea',
},
},
],
},
{
Expand Down Expand Up @@ -744,6 +751,96 @@ export const FeatureTree: Page[] = [
},
],
},
{
id: 'buy-citrea',
dfxStyle: true,
tiles: [
{
id: 'cbtc',
img: 'cbtc',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'buy',
query: { blockchain: Blockchain.CITREA, assetOut: 'cBTC' },
},
},
},
{
id: 'jusd',
img: 'jusd',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'buy',
query: { blockchain: Blockchain.CITREA, assetOut: 'JUSD' },
},
},
},
{
id: 'ctusd',
img: 'ctusd',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'buy',
query: { blockchain: Blockchain.CITREA, assetOut: 'ctUSD' },
},
},
},
{
id: 'wbtce',
img: 'wbtc',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'buy',
query: { blockchain: Blockchain.CITREA, assetOut: 'WBTC.e' },
},
},
},
{
id: 'usdte',
img: 'usdt',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'buy',
query: { blockchain: Blockchain.CITREA, assetOut: 'USDT.e' },
},
},
},
{
id: 'usdce',
img: 'usdc',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'buy',
query: { blockchain: Blockchain.CITREA, assetOut: 'USDC.e' },
},
},
},
{
id: 'juice',
img: 'juice',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'buy',
query: { blockchain: Blockchain.CITREA, assetOut: 'JUICE' },
},
},
},
],
},
{
id: 'sell',
dfxStyle: true,
Expand Down Expand Up @@ -860,6 +957,13 @@ export const FeatureTree: Page[] = [
page: 'sell-gnosis',
},
},
{
id: 'citrea',
img: 'citrea',
next: {
page: 'sell-citrea',
},
},
],
},
{
Expand Down Expand Up @@ -1410,6 +1514,96 @@ export const FeatureTree: Page[] = [
},
],
},
{
id: 'sell-citrea',
dfxStyle: true,
tiles: [
{
id: 'cbtc',
img: 'cbtc',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'sell',
query: { blockchain: Blockchain.CITREA, assetIn: 'cBTC' },
},
},
},
{
id: 'jusd',
img: 'jusd',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'sell',
query: { blockchain: Blockchain.CITREA, assetIn: 'JUSD' },
},
},
},
{
id: 'ctusd',
img: 'ctusd',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'sell',
query: { blockchain: Blockchain.CITREA, assetIn: 'ctUSD' },
},
},
},
{
id: 'wbtce',
img: 'wbtc',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'sell',
query: { blockchain: Blockchain.CITREA, assetIn: 'WBTC.e' },
},
},
},
{
id: 'usdte',
img: 'usdt',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'sell',
query: { blockchain: Blockchain.CITREA, assetIn: 'USDT.e' },
},
},
},
{
id: 'usdce',
img: 'usdc',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'sell',
query: { blockchain: Blockchain.CITREA, assetIn: 'USDC.e' },
},
},
},
{
id: 'juice',
img: 'juice',
next: {
page: 'wallets',
tiles: ['hw-wallet', 'metamask', 'walletconnect', 'cli'],
options: {
service: 'sell',
query: { blockchain: Blockchain.CITREA, assetIn: 'JUICE' },
},
},
},
],
},

// --- LOGIN --- //
{
Expand Down
26 changes: 14 additions & 12 deletions src/screens/account.screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ function formatAddress(address: UserProfile['address']): string {
.join(', ');
}

// Supported EVM blockchains for balance PDF (must match API's SUPPORTED_BLOCKCHAINS)
const SUPPORTED_PDF_BLOCKCHAINS: Blockchain[] = [
Blockchain.ETHEREUM,
Blockchain.BINANCE_SMART_CHAIN,
Blockchain.POLYGON,
Blockchain.ARBITRUM,
Blockchain.OPTIMISM,
Blockchain.BASE,
Blockchain.GNOSIS,
];

enum FiatCurrency {
CHF = 'CHF',
EUR = 'EUR',
Expand Down Expand Up @@ -107,6 +96,7 @@ export default function AccountScreen(): JSX.Element {
const [pdfError, setPdfError] = useState<string>();
const [showRecommendationModal, setShowRecommendationModal] = useState(false);
const [isDataLoading, setIsDataLoading] = useState(true);
const [pdfBlockchains, setPdfBlockchains] = useState<Blockchain[]>([]);

const isKycLevel50 = user && user.kyc.level >= 50;

Expand All @@ -131,7 +121,7 @@ export default function AccountScreen(): JSX.Element {
const selectedPdfCurrency = useWatch({ control: pdfControl, name: 'currency' });
const selectedPdfDate = useWatch({ control: pdfControl, name: 'date' });

const supportedBlockchains = selectedAddress?.blockchains.filter((b) => SUPPORTED_PDF_BLOCKCHAINS.includes(b)) ?? [];
const supportedBlockchains = selectedAddress?.blockchains.filter((b) => pdfBlockchains.includes(b)) ?? [];
const canDownloadPdf = supportedBlockchains.length > 0;

useEffect(() => {
Expand All @@ -147,6 +137,10 @@ export default function AccountScreen(): JSX.Element {
if (isLoggedIn) loadTransactions();
}, [isLoggedIn]);

useEffect(() => {
loadPdfBlockchains();
}, []);

useEffect(() => {
if (selectedAddress?.address && user?.activeAddress?.address !== selectedAddress?.address && !isUserLoading) {
changeAddress(selectedAddress.address)
Expand All @@ -157,6 +151,14 @@ export default function AccountScreen(): JSX.Element {
}
}, [selectedAddress, user?.activeAddress, !isUserLoading]);

async function loadPdfBlockchains(): Promise<void> {
return call<Blockchain[]>({ url: 'balance/pdf/blockchains', method: 'GET' })
.then(setPdfBlockchains)
.catch(() => {
// ignore errors
});
}

async function loadInitialData(): Promise<void> {
setIsDataLoading(true);

Expand Down
1 change: 1 addition & 0 deletions src/screens/blockchain-tx.screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const availableBlockchains = [
Blockchain.ARBITRUM,
Blockchain.OPTIMISM,
Blockchain.BASE,
Blockchain.CITREA,
];

const availableSigners = ['0x9229e0179a436CD0b77F731992307AC765Bc4b17'];
Expand Down
2 changes: 2 additions & 0 deletions src/util/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export class Evm {
Blockchain.GNOSIS,
Blockchain.BINANCE_SMART_CHAIN,
Blockchain.HAQQ,
Blockchain.CITREA,
Blockchain.CITREA_TESTNET,
].includes(blockchain);
}
}
Loading