Skip to content

Commit

Permalink
fix: ui
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao committed Jul 19, 2024
1 parent 8059b1c commit 0b28eaf
Show file tree
Hide file tree
Showing 17 changed files with 2,010 additions and 1,995 deletions.
51 changes: 0 additions & 51 deletions apps/hybrid-pay/api/geoblock.js

This file was deleted.

26 changes: 4 additions & 22 deletions apps/hybrid-pay/api/index.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
import { createProxyMiddleware } from 'http-proxy-middleware';

const CHAIN = process.env.CHAIN || 'mainnet';

const API_URL = {
mainnet: 'https://fusion-api.gobob.xyz',
sepolia: 'https://fusion-api-sepolia.gobob.xyz'
};

const ONRAMP_API_URL = {
mainnet: 'https://onramp-api-mainnet.gobob.xyz',
sepolia: 'https://onramp-api-testnet.gobob.xyz'
};

const BTC_API_URL = {
mainnet: 'https://btc-mainnet.gobob.xyz',
sepolia: 'https://btc-testnet.gobob.xyz'
};

const proxyMiddleware = createProxyMiddleware({
target: API_URL[CHAIN],
target: 'https://app.gobob.xyz/api',
router: {
'/dynamic-api': API_URL[CHAIN],
'/onramp-api': ONRAMP_API_URL[CHAIN],
'/btc-api': BTC_API_URL[CHAIN]
'/api': 'https://app.gobob.xyz/api',
'/dynamic-api': 'https://app.dynamicauth.com/api/v0'
},
changeOrigin: true,
pathRewrite: { '^/dynamic-api': '', '^/onramp-api': '', '^/btc-api': '' },
pathRewrite: { '^/dynamic-api': '', '^/api': '' },
on: {
proxyReq: (proxyReq) => {
proxyReq.setHeader('x-sec-token', 'foobar');
Expand Down
12 changes: 6 additions & 6 deletions apps/hybrid-pay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@dynamic-labs/bitcoin": "^2.2.10",
"@dynamic-labs/ethereum": "^2.2.10",
"@dynamic-labs/ethereum-aa": "^2.2.10",
"@dynamic-labs/sdk-react-core": "^2.2.10",
"@dynamic-labs/wagmi-connector": "^2.2.10",
"@dynamic-labs/bitcoin": "^v3.0.0-alpha.22",
"@dynamic-labs/ethereum": "^v3.0.0-alpha.22",
"@dynamic-labs/ethereum-aa": "^v3.0.0-alpha.22",
"@dynamic-labs/sdk-react-core": "^v3.0.0-alpha.22",
"@dynamic-labs/wagmi-connector": "^v3.0.0-alpha.22",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@gobob/chains": "workspace:^",
Expand All @@ -36,7 +36,7 @@
"@react-stately/list": "^3.9.1",
"@sentry/react": "^8.8.0",
"@sentry/vite-plugin": "^2.18.0",
"@zerodev/sdk": "^5.3.3",
"@zerodev/sdk": "^5.3.4",
"big.js": "^6.2.1",
"date-fns": "^3.2.0",
"graphql-request": "6.1.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/hybrid-pay/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ScrollToTop = () => {

const Wallet = lazy(() => import('./pages/Wallet'));
const Send = lazy(() => import('./pages/Send'));
const Recieve = lazy(() => import('./pages/Recieve'));
const Receive = lazy(() => import('./pages/Receive'));
const Custom404 = lazy(() => import('./pages/404'));

const ProtectedRoute = ({ children }: { children: ReactNode }) => {
Expand Down Expand Up @@ -107,7 +107,7 @@ function App() {
<Route
element={
<ProtectedRoute>
<Recieve />
<Receive />
</ProtectedRoute>
}
path={RoutesPath.RECIEVE}
Expand Down
2 changes: 1 addition & 1 deletion apps/hybrid-pay/src/components/Layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Header = ({ ...props }: HeaderProps): JSX.Element => {
return (
<StyledHeader alignItems='center' elementType='header' justifyContent='space-between' {...props}>
<StyledLogoWrapper alignItems='center' gap='md'>
{pathname === RoutesPath.HOME ? (
{pathname === RoutesPath.HOME || !isAuthenticated ? (
<Logo to={RoutesPath.HOME} />
) : (
<Flex alignItems='center'>
Expand Down
3 changes: 2 additions & 1 deletion apps/hybrid-pay/src/hooks/useKernelClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const useKernelClient = (gasToken?: Currency) => {
return;
}

const paymaster = gasToken ? paymasters?.[CHAIN]?.[gasToken.symbol] : undefined;
const paymaster = gasToken ? paymasters?.[CHAIN as ChainId.BOB]?.[gasToken.symbol] : undefined;

const dynamicAccountProvider = connector.getAccountAbstractionProvider();

Expand Down Expand Up @@ -91,6 +91,7 @@ const useKernelClient = (gasToken?: Currency) => {
};

// can't json-serialize bigints - convert them to strings
// @ts-ignore
BigInt.prototype['toJSON'] = function () {
return this.toString();
};
Expand Down
1 change: 0 additions & 1 deletion apps/hybrid-pay/src/lib/form/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type TransferTokenFormValues = {

type TransferTokenFormValidationParams = {
[TRANSFER_TOKEN_AMOUNT]: MaxAmountValidationParams & MinAmountValidationParams;
[TRANSFER_TOKEN_RECIPIENT]?: 'evm' | 'email';
};

const transferTokenSchema = (params: TransferTokenFormValidationParams) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { useAccount } from 'wagmi';
import { truncateEthAddress } from '@gobob/utils';

import { Main } from '../../components';
import { RoutesPath } from '../../constants';

const Recieve = () => {
const Receive = () => {
const { user } = useDynamicContext();
const { address } = useAccount();

Expand Down Expand Up @@ -35,12 +36,12 @@ const Recieve = () => {
fgColor='#ffffff'
size={256}
style={{ height: 'auto', maxWidth: '100%', width: '100%', background: 'transparent' }}
value={address!}
value={`${window.location.host}${RoutesPath.SEND}?to=${user?.email || address}`}
viewBox={`0 0 256 256`}
/>
</Flex>
</Main>
);
};

export { Recieve };
export { Receive };
1 change: 1 addition & 0 deletions apps/hybrid-pay/src/pages/Receive/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Receive as default } from './Receive';
1 change: 0 additions & 1 deletion apps/hybrid-pay/src/pages/Recieve/index.tsx

This file was deleted.

30 changes: 21 additions & 9 deletions apps/hybrid-pay/src/pages/Send/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ const Send = ({}: SendProps): JSX.Element => {

const { user } = useDynamicContext();

const [ticker, setTicker] = useState(CHAIN === ChainId.BASE_SEPOLIA ? 'USDC' : searchParams.get('token') || 'WBTC');
const defaultTicker = CHAIN === ChainId.BASE_SEPOLIA ? 'USDC' : searchParams.get('token') || 'WBTC';

const [ticker, setTicker] = useState(defaultTicker);
const [amount, setAmount] = useState('');
const [isGroupAmount, setGroupAmount] = useState(false);

const { getPrice } = usePrices({ baseUrl: import.meta.env.VITE_MARKET_DATA_API });
const { getBalance } = useBalances(CHAIN);
const { getBalance, balances, isPending } = useBalances(CHAIN);

const { data: tokens } = useTokens(CHAIN);

Expand Down Expand Up @@ -146,10 +148,6 @@ const Send = ({}: SendProps): JSX.Element => {
error: eoaTransferError
} = useMutation({
mutationKey: ['eoa-transfer', amount, form.values[TRANSFER_TOKEN_RECIPIENT]],
onSuccess: () => {
form.resetForm();
setAmount('');
},
mutationFn: async ({
recipient,
currencyAmount
Expand Down Expand Up @@ -183,6 +181,11 @@ const Send = ({}: SendProps): JSX.Element => {
useEffect(() => {
if (eoaTransferTransactionReceipt?.status === 'success') {
toast.success(`Successfully sent ${amount} ${token?.currency.symbol}`);

form.resetForm();
setAmount('');
setGroupAmount(false);
setTicker(defaultTicker);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [eoaTransferTransactionReceipt]);
Expand All @@ -207,12 +210,13 @@ const Send = ({}: SendProps): JSX.Element => {
}

toast.success(
`Successfully transfered ${variables.currencyAmount.numerator} ${variables.currencyAmount.currency.symbol}`
`Successfully transfered ${variables.currencyAmount.toExact()} ${variables.currencyAmount.currency.symbol}`
);

form.resetForm();
setAmount('');
// eslint-disable-next-line react-hooks/exhaustive-deps
setGroupAmount(false);
setTicker(defaultTicker);
},
mutationFn: async ({
recipient,
Expand Down Expand Up @@ -278,6 +282,13 @@ const Send = ({}: SendProps): JSX.Element => {
}
}, [smartAccountTransferError]);

useEffect(() => {
if (!isPending) {
form.validateField(TRANSFER_TOKEN_AMOUNT);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [balances, isPending]);

const tokenInputItems = useMemo(
() =>
tokens?.map((token) => {
Expand Down Expand Up @@ -332,9 +343,10 @@ const Send = ({}: SendProps): JSX.Element => {
currency={token.currency}
isSelected={isGroupAmount}
onSelectionChange={(currencyAmount) => {
form.setFieldValue(TRANSFER_TOKEN_AMOUNT, currencyAmount.toSignificant(), true);
form.setFieldValue(TRANSFER_TOKEN_AMOUNT, currencyAmount.toSignificant());
form.setFieldTouched(TRANSFER_TOKEN_AMOUNT, true);
setGroupAmount(true);
setTimeout(() => form.validateField(TRANSFER_TOKEN_AMOUNT), 0);
}}
/>
<Button color='primary' disabled={isSubmitDisabled} loading={isTransferLoading} size='xl' type='submit'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import styled from 'styled-components';
import { Card } from '@gobob/ui';

const StyledCard = styled(Card)`
border: 1px solid transparent;
&[aria-selected='true'] {
border: 1px solid ${({ theme }) => theme.color('primary-500')};
box-shadow: 0 0 0 1px ${({ theme }) => theme.color('primary-500')};
Expand Down
18 changes: 8 additions & 10 deletions apps/hybrid-pay/src/pages/Wallet/Wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import { Main } from '../../components';
import { StyledFlex } from './Wallet.style';
import { Hero, TransactionList } from './components';

const Wallet = () => {
return (
<Main maxWidth='5xl' padding='md'>
<StyledFlex direction='column'>
<Hero />
<TransactionList />
</StyledFlex>
</Main>
);
};
const Wallet = () => (
<Main maxWidth='5xl' padding='md'>
<StyledFlex direction='column'>
<Hero />
<TransactionList />
</StyledFlex>
</Main>
);

export { Wallet };
6 changes: 1 addition & 5 deletions apps/hybrid-pay/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
}
},
"rewrites": [
{
"source": "/check_access",
"destination": "/api/geoblock.js"
},
{
"source": "/tunnel",
"destination": "/api/sentry.js"
Expand All @@ -19,7 +15,7 @@
"destination": "/api/marketdata.js"
},
{
"source": "/(dynamic-api|onramp-api|btc-api)/(.*)",
"source": "/(dynamic-api|api)/(.*)",
"destination": "/api"
},
{
Expand Down
10 changes: 0 additions & 10 deletions apps/hybrid-pay/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ export default defineConfig(({ mode }) => {
target: env.VITE_DYNAMIC_API_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/dynamic-api/, '')
},
'/onramp-api': {
target: env.VITE_ONRAMP_API_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/onramp-api/, '')
},
'/btc-api': {
target: env.VITE_BTC_API_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/btc-api/, '')
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/tokens/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export const tokens = {
[ChainId.OPBNB]: [],
[ChainId.POLYGON]: [],
[ChainId.POLYGON_ZKEVM]: [],
[ChainId.MOONBEAM]: []
[ChainId.MOONBEAM]: [],
[ChainId.BASE_SEPOLIA]: []
};
Loading

0 comments on commit 0b28eaf

Please sign in to comment.