Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for EUR offramp #94

Merged
merged 4 commits into from
Aug 9, 2024
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
9 changes: 0 additions & 9 deletions signer-service/src/constants/tokenConfig.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
const TOKEN_CONFIG = {
brl: {
tomlFileUrl: 'https://ntokens.com/.well-known/stellar.toml',
assetCode: 'BRL',
assetIssuer: 'GDVKY2GU2DRXWTBEYJJWSFXIGBZV6AZNBVVSUHEPZI54LIS6BA7DVVSP',
vaultAccountId: '6g7fKQQZ9VfbBTQSaKBcATV4psApFra5EDwKLARFZCCVnSWS',
//todo tbc minWithdrawalAmount for this asset
minWithdrawalAmount: '10000000000000',
assetCodeHex: '0x42524c00',
},
eurc: {
tomlFileUrl: 'https://mykobo.co/.well-known/stellar.toml',
assetCode: 'EURC',
Expand Down
Binary file removed src/assets/coins/BRL.png
Binary file not shown.
6 changes: 0 additions & 6 deletions src/components/BenefitsList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,5 @@ export const BenefitsList: FC<BenefitsListProps> = ({ amount, currency }) => (
Should arrive in <span className="font-bold text-blue-700">5 minutes</span>
</p>
</li>
<li className="flex">
<CheckIcon className="w-4 mr-2 text-pink-500" />
<p>
<span className="font-bold text-blue-700">Verify super fast</span> with your Tax ID
</p>
</li>
</ul>
);
2 changes: 1 addition & 1 deletion src/components/Nabla/useSwapForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const useSwapForm = () => {
const storageValues = storageService.getParsed<SwapSettings>(storageKeys.SWAP_SETTINGS);
return {
from: (storageValues?.from ?? 'usdc') as InputTokenType,
to: (storageValues?.to ?? 'brl') as OutputTokenType,
to: (storageValues?.to ?? 'eurc') as OutputTokenType,
taxNumber: '',
bankAccount: '',
};
Expand Down
26 changes: 3 additions & 23 deletions src/constants/tokenConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import BrlIcon from '../assets/coins/BRL.png';
import UsdcIcon from '../assets/coins/USDC.png';
import EurcIcon from '../assets/coins/EURC.png';

Expand All @@ -7,7 +6,7 @@ export interface InputTokenDetails {
erc20AddressSourceChain: `0x${string}`;
axelarEquivalent: {
pendulumErc20WrapperAddress: string;
pendulumCurrencyId: any;
pendulumCurrencyId: { XCM: number };
pendulumAssetSymbol: string;
};
decimals: number;
Expand Down Expand Up @@ -60,27 +59,8 @@ export const INPUT_TOKEN_CONFIG: Record<InputTokenType, InputTokenDetails> = {
},
};

export type OutputTokenType = 'brl' | 'eurc';
export type OutputTokenType = 'eurc';
export const OUTPUT_TOKEN_CONFIG: Record<OutputTokenType, OutputTokenDetails> = {
brl: {
tomlFileUrl: 'https://ntokens.com/.well-known/stellar.toml',
decimals: 12,
stellarAsset: {
code: {
hex: '0x42524c00',
string: 'BRL',
},
issuer: {
hex: '0xeaac68d4d0e37b4c24c2536916e830735f032d0d6b2a1c8fca3bc5a25e083e3a',
stellarEncoding: 'GDVKY2GU2DRXWTBEYJJWSFXIGBZV6AZNBVVSUHEPZI54LIS6BA7DVVSP',
},
},
vaultAccountId: '6g7fKQQZ9VfbBTQSaKBcATV4psApFra5EDwKLARFZCCVnSWS',
minWithdrawalAmountRaw: '200000000000000',
maxWithdrawalAmountRaw: '10000000000000000',
erc20WrapperAddress: '6dZCR7KVmrcxBoUTcM3vUgpQagQAW2wg2izMrT3N4reftwW5',
icon: BrlIcon,
},
eurc: {
tomlFileUrl: 'https://mykobo.co/.well-known/stellar.toml',
decimals: 12,
Expand All @@ -102,7 +82,7 @@ export const OUTPUT_TOKEN_CONFIG: Record<OutputTokenType, OutputTokenDetails> =
},
};

export function getPendulumCurrencyId(outputTokenType: OutputTokenType): any {
export function getPendulumCurrencyId(outputTokenType: OutputTokenType) {
const { stellarAsset } = OUTPUT_TOKEN_CONFIG[outputTokenType];
return {
Stellar: {
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/useGetIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useChainId } from 'wagmi';
import { polygon } from 'wagmi/chains';

import BRL from '../assets/coins/BRL.png';
import EURC from '../assets/coins/EURC.png';
import USDC from '../assets/coins/USDC.png';
import USDC_POLYGON from '../assets/coins/USDC_POLYGON.svg';
Expand All @@ -11,7 +10,6 @@ import { InputTokenType, OutputTokenType } from '../constants/tokenConfig';
type IconMap = Partial<Record<InputTokenType | OutputTokenType, string>>;

const icons: IconMap = {
brl: BRL,
eurc: EURC,
usdce: USDC,
};
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useMainProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export const useMainProcess = () => {
}, [offrampingPhase, wagmiConfig]);

return {
setOfframpingPhase,
handleOnSubmit,
sep24Url,
offrampingPhase,
Expand Down
17 changes: 14 additions & 3 deletions src/pages/progress/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
import { useEffect } from 'preact/hooks';
import { FC, StateUpdater, useEffect } from 'preact/compat';
import { ExclamationCircleIcon } from '@heroicons/react/20/solid';
import { FinalOfframpingPhase, OfframpingPhase } from '../../services/offrampingFlow';
import { Box } from '../../components/Box';
import { BaseLayout } from '../../layouts';

const handleTabClose = (event: Event) => {
event.preventDefault();
};

export const ProgressPage = () => {
interface ProgressPageProps {
setOfframpingPhase: StateUpdater<OfframpingPhase | FinalOfframpingPhase | undefined>;
}

export const ProgressPage: FC<ProgressPageProps> = ({ setOfframpingPhase }) => {
// After 15 minutes of waiting, we want to redirect user to the failure page.
useEffect(() => {
const timer = setTimeout(() => {
setOfframpingPhase('failure');
}, 15 * 60 * 1000);

window.addEventListener('beforeunload', handleTabClose);

return () => {
clearTimeout(timer);
window.removeEventListener('beforeunload', handleTabClose);
};
}, []);
}, [setOfframpingPhase]);

const main = (
<main>
Expand Down
16 changes: 12 additions & 4 deletions src/pages/swap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@ export const SwapPage = () => {
}, []);

// Main process hook
const { handleOnSubmit, finishOfframping, offrampingStarted, sep24Url, sep24Id, offrampingPhase, signingPhase } =
useMainProcess();
const {
handleOnSubmit,
finishOfframping,
offrampingStarted,
sep24Url,
sep24Id,
offrampingPhase,
setOfframpingPhase,
signingPhase,
} = useMainProcess();

const {
tokensModal: [modalType, setModalType],
Expand Down Expand Up @@ -120,7 +128,7 @@ export const SwapPage = () => {
const ReceiveNumericInput = useMemo(
() => (
<AssetNumericInput
additionalText="PIX / Bank Account"
additionalText="IBAN"
tokenType={to}
tokenSymbol={toToken?.stellarAsset.code.string}
onClick={() => setModalType('to')}
Expand Down Expand Up @@ -200,7 +208,7 @@ export const SwapPage = () => {
}

if ((offrampingPhase !== undefined || offrampingStarted) && signingPhase === 'finished') {
return <ProgressPage />;
return <ProgressPage setOfframpingPhase={setOfframpingPhase} />;
}

const main = (
Expand Down
Loading