Skip to content

Commit 2b46495

Browse files
authored
Merge pull request #42 from betfinio/dev
Release to prod/games
2 parents 4a3177b + f6c713d commit 2b46495

29 files changed

+220
-210
lines changed

.env.example

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ PUBLIC_STONES_GRAPH_URL=
1111
PUBLIC_PARTNER_ADDRESS=
1212

1313
PUBLIC_BRANCH=
14-
PUBLIC_DEPLOYED=
14+
PUBLIC_DEPLOYED=
15+
16+
PUBLIC_CONTEXT_URL=

.github/workflows/build_deploy.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
BUN_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4040
- name: Build
4141
env:
42-
PUBLIC_OUTPUT_URL: https://s3.${{secrets.AWS_REGION}}.amazonaws.com/${{secrets.AWS_BUCKET}}
42+
PUBLIC_OUTPUT_URL: https://${{secrets.AWS_BUCKET}}
4343
PUBLIC_BRANCH: ${{ github.ref_name }}
4444
PUBLIC_DEPLOYED: ${{ github.sha }}
4545
run: bun run build --env-mode ${{ secrets.AWS_ENVIRONMENT }}
@@ -48,7 +48,7 @@ jobs:
4848
aws s3 cp ./dist s3://${{secrets.AWS_BUCKET}} --cache-control 'public, max-age=0' --recursive
4949
- name: Invalidate CloudFront
5050
run: |
51-
aws cloudfront create-invalidation --distribution-id ${{env.AWS_DISTRIBUTION_ID}} --paths '/*'
51+
aws cloudfront create-invalidation --distribution-id ${{secrets.AWS_DISTRIBUTION_ID}} --paths '/*'
5252
- name: Release
5353
if: ${{github.ref_name == 'dev'}}
5454
continue-on-error: true

package.json

+33-37
Original file line numberDiff line numberDiff line change
@@ -18,60 +18,56 @@
1818
"secret:prod": "bun run secret.ts -- production prod/io"
1919
},
2020
"dependencies": {
21-
"@betfinio/abi": "^2.2.0",
22-
"@betfinio/components": "^1.3.5",
23-
"@module-federation/enhanced": "^0.8.0",
21+
"@betfinio/abi": "^2.3.3",
22+
"@betfinio/components": "^1.4.8",
2423
"@nivo/core": "^0.87.0",
2524
"@nivo/pie": "^0.87.0",
26-
"@tanstack/react-query": "^5.62.2",
27-
"@tanstack/react-router": "^1.85.4",
28-
"@tanstack/react-table": "^8.20.5",
29-
"@types/canvas-confetti": "^1.6.4",
30-
"@types/react-virtualized": "^9.22.0",
31-
"@wagmi/core": "^2.15.2",
25+
"@tanstack/react-query": "^5.63.0",
26+
"@tanstack/react-router": "^1.95.1",
27+
"@tanstack/react-table": "^8.20.6",
28+
"@wagmi/core": "^2.16.3",
3229
"canvas-confetti": "^1.9.3",
33-
"dotenv-cli": "^7.4.4",
34-
"framer-motion": "^11.12.0",
35-
"graphql": "^16.9.0",
36-
"i18next": "^24.0.5",
37-
"i18next-browser-languagedetector": "^8.0.0",
30+
"framer-motion": "^11.16.2",
31+
"i18next": "^24.2.1",
32+
"i18next-browser-languagedetector": "^8.0.2",
3833
"i18next-icu": "^2.3.0",
39-
"intl-messageformat": "^10.7.7",
34+
"intl-messageformat": "^10.7.11",
4035
"lucide-react": "^0.438.0",
4136
"luxon": "^3.5.0",
4237
"react": "^18.3.1",
4338
"react-dom": "^18.3.1",
44-
"react-i18next": "^15.1.3",
39+
"react-i18next": "^15.4.0",
4540
"react-icons": "^5.4.0",
46-
"react-number-format": "^5.4.2",
41+
"react-number-format": "^5.4.3",
4742
"react-responsive": "^10.0.0",
4843
"react-virtualized": "^9.22.5",
49-
"react-window": "^1.8.10",
50-
"tailwind-merge": "^2.5.5",
51-
"tailwindcss": "^3.4.15",
44+
"tailwind-merge": "^2.6.0",
45+
"tailwindcss": "^3.4.17",
5246
"tailwindcss-animate": "^1.0.7",
53-
"viem": "^2.21.53",
54-
"wagmi": "^2.13.3"
47+
"viem": "^2.22.5",
48+
"wagmi": "^2.14.7"
5549
},
5650
"devDependencies": {
57-
"@aws-sdk/client-secrets-manager": "^3.699.0",
51+
"@types/canvas-confetti": "^1.9.0",
52+
"@types/react-virtualized": "^9.22.0",
53+
"@module-federation/enhanced": "^0.8.8",
54+
"@aws-sdk/client-secrets-manager": "^3.723.0",
5855
"@biomejs/biome": "^1.9.4",
59-
"@commitlint/cli": "^19.6.0",
60-
"lefthook": "^1.8.5",
56+
"dotenv-cli": "^7.4.4",
57+
"@commitlint/cli": "^19.6.1",
58+
"lefthook": "^1.10.1",
6159
"@commitlint/config-conventional": "^19.6.0",
6260
"@graphprotocol/client-cli": "^3.0.7",
63-
"@module-federation/rsbuild-plugin": "^0.8.0",
64-
"@radix-ui/react-tabs": "^1.1.1",
65-
"@rsbuild/core": "^1.1.7",
66-
"@rsbuild/plugin-react": "^1.0.7",
67-
"@rsbuild/plugin-svgr": "^1.0.5",
68-
"@tanstack/router-plugin": "^1.85.3",
69-
"@types/bun": "^1.1.14",
61+
"@module-federation/rsbuild-plugin": "^0.8.8",
62+
"@radix-ui/react-tabs": "^1.1.2",
63+
"@rsbuild/core": "^1.1.13",
64+
"@rsbuild/plugin-react": "^1.1.0",
65+
"@rsbuild/plugin-svgr": "^1.0.6",
66+
"@tanstack/router-plugin": "^1.95.1",
67+
"@types/bun": "^1.1.16",
7068
"@types/luxon": "^3.4.2",
71-
"@types/react": "^18.3.12",
72-
"@types/react-dom": "^18.3.1",
73-
"@types/react-slick": "^0.23.13",
74-
"@types/react-window": "^1.8.8",
75-
"typescript": "^5.7.2"
69+
"@types/react": "^18.3.18",
70+
"@types/react-dom": "^18.3.5",
71+
"typescript": "^5.7.3"
7672
}
7773
}

rsbuild.config.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default defineConfig({
1717
html: {
1818
title: 'Betfin Stones',
1919
favicon: './src/assets/favicon.svg',
20+
template: './src/assets/index.html',
2021
meta: {
2122
viewport: 'width=device-width, initial-scale=1, maximum-scale=1',
2223
},
@@ -30,10 +31,15 @@ export default defineConfig({
3031
pluginModuleFederation({
3132
name: 'betfin_stones',
3233
remotes: {
33-
betfinio_app: `betfinio_app@${process.env.PUBLIC_APP_URL}/mf-manifest.json`,
34+
betfinio_context: `betfinio_context@${process.env.PUBLIC_CONTEXT_URL}/mf-manifest.json`,
3435
},
35-
manifest: false,
36-
dts: false,
36+
exposes: {
37+
'./style': './src/style',
38+
'./i18n': './src/i18n',
39+
'./route': './src/routes/games/stones/index',
40+
},
41+
manifest: true,
42+
dts: true,
3743
shared: {
3844
react: {
3945
singleton: true,

src/assets/index.html

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
8+
</head>
9+
10+
<body>
11+
<div id="<%= mountId %>">
12+
<div style="width: 100vw; height: 100vh" class="flex items-center justify-center">
13+
<div style="width: 80px; height: 80px; border: 10px solid white; border-top: 10px solid transparent"
14+
class="animate-spin w-20 h-20 border-foreground rounded-full border-8 border-t-border"></div>
15+
</div>
16+
</div>
17+
</body>
18+
19+
</html>

src/bootstrap.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { routeTree } from './routeTree.gen';
99
const router = createRouter({ routeTree });
1010

1111
const rootElement = document.getElementById('root');
12-
if (rootElement && !rootElement.innerHTML) {
12+
if (rootElement) {
1313
const root = ReactDOM.createRoot(rootElement);
14-
root.render(<RouterProvider router={router} basepath={'/games'} />);
14+
root.render(<RouterProvider router={router} />);
1515
}

src/components/BetAmount/BetAmount.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import { usePotentialWinWithBonus } from '@/src/lib/gql';
66
import { useActualRound, useBetAmount, useCurrentRound, useRoundBank, useRoundStatus, useSideBank } from '@/src/lib/query';
77
import { usePlaceBet, useSetBetAmount } from '@/src/lib/query/mutations';
88
import { useSelectedStone } from '@/src/lib/query/state';
9-
import { arrayFrom, valueToNumber } from '@betfinio/abi';
9+
import { ZeroAddress, arrayFrom, valueToNumber } from '@betfinio/abi';
1010
import { BetValue } from '@betfinio/components/shared';
1111
import { Button, Slider } from '@betfinio/components/ui';
1212
import { useQueryClient } from '@tanstack/react-query';
1313
import { useNavigate } from '@tanstack/react-router';
14-
import { useAllowanceModal } from 'betfinio_app/allowance';
15-
import { useAllowance, useBalance } from 'betfinio_app/lib/query/token';
14+
import { useAllowanceModal } from 'betfinio_context/lib/context';
15+
import { useAllowance, useBalance } from 'betfinio_context/lib/query';
1616
import { cx } from 'class-variance-authority';
1717
import { motion } from 'framer-motion';
1818
import { LoaderIcon } from 'lucide-react';
@@ -39,7 +39,7 @@ const images: { [key: string]: string } = {
3939

4040
const BetAmount = () => {
4141
const { t } = useTranslation('stones', { keyPrefix: 'controls' });
42-
const { address } = useAccount();
42+
const { address = ZeroAddress } = useAccount();
4343
const [betPercentage, setBetPercentage] = useState(0);
4444
const { data: selected, setSelectedStone } = useSelectedStone();
4545
const { data: round = 0 } = useCurrentRound();
@@ -127,7 +127,7 @@ const BetAmount = () => {
127127
borderColor: 'hsl(var(--ruby-border))',
128128
},
129129
];
130-
}, [sideBank, round]);
130+
}, [sideBank, round, bank]);
131131

132132
return (
133133
<div className="w-full">
@@ -292,7 +292,7 @@ const OldRound: FC<{ round: number }> = ({ round }) => {
292292
const { data: status = 0 } = useRoundStatus(round);
293293

294294
const handleClick = () => {
295-
navigate({ to: '/stones', search: { round: actualRound } });
295+
navigate({ to: '/games/stones', search: { round: actualRound } });
296296
queryClient.invalidateQueries({ queryKey: ['stones', 'currentRound'] });
297297
};
298298
const { t } = useTranslation('stones', { keyPrefix: 'oldRound' });

src/components/BetHistory/BetItem.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { StonesBet } from '@/src/lib/types';
44
import { getStoneImage } from '@/src/lib/utils';
55
import { truncateEthAddress } from '@betfinio/abi';
66
import { BetValue } from '@betfinio/components/shared';
7-
import { useCustomUsername, useUsername } from 'betfinio_app/lib/query/username';
7+
import { useCustomUsername, useUsername } from 'betfinio_context/lib/query';
88
import { cx } from 'class-variance-authority';
99
import { motion } from 'framer-motion';
1010
import type { FC } from 'react';

src/components/BetHistory/BonusItem.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { StonesBetWithBonus } from '@/src/lib/types';
33
import { getStoneImage } from '@/src/lib/utils.ts';
44
import { truncateEthAddress } from '@betfinio/abi';
55
import { BetValue } from '@betfinio/components/shared';
6-
import { useCustomUsername, useUsername } from 'betfinio_app/lib/query/username';
6+
import { useCustomUsername, useUsername } from 'betfinio_context/lib/query';
77
import { cx } from 'class-variance-authority';
88
import { motion } from 'framer-motion';
99
import type { FC } from 'react';

src/components/BetHistory/PlayerItem.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { StonesBet } from '@/src/lib/types';
44
import { truncateEthAddress } from '@betfinio/abi';
55
import { BetValue } from '@betfinio/components/shared';
66
import { Fox } from '@betfinio/ui';
7-
import { useCustomUsername, useUsername } from 'betfinio_app/lib/query/username';
7+
import { useCustomUsername, useUsername } from 'betfinio_context/lib/query';
88
import { cx } from 'class-variance-authority';
99
import { motion } from 'framer-motion';
1010
import type { FC } from 'react';

src/components/Roulette/Header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useCurrentRound, useRoundBank } from '@/src/lib/query';
22
import { BetValue } from '@betfinio/components/shared';
33
import { Separator } from '@betfinio/components/ui';
4-
import { useChatbot } from 'betfinio_app/chatbot';
4+
import { useChatbot } from 'betfinio_context/lib/context';
55
import { CircleHelp, TriangleAlert } from 'lucide-react';
66
import { useCallback } from 'react';
77
import { useTranslation } from 'react-i18next';

src/components/Roulette/Wheel.tsx

+3-26
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ import { StonesABI, ZeroAddress, arrayFrom } from '@betfinio/abi';
1111
import { BetValue } from '@betfinio/components/shared';
1212
import { Bet } from '@betfinio/ui';
1313
import { useQueryClient } from '@tanstack/react-query';
14-
import { cx } from 'class-variance-authority';
1514
import { AnimatePresence, motion, useAnimation } from 'framer-motion';
1615
import { useEffect, useRef, useState } from 'react';
17-
import { useTranslation } from 'react-i18next';
1816
import { useAccount, useWatchContractEvent } from 'wagmi';
1917
import arrowdown from '../../assets/Roulette/arrow-down.svg';
2018
import neonImage from '../../assets/Roulette/neon-glow.png';
@@ -100,11 +98,11 @@ const Wheel = () => {
10098
const { data: status = 0 } = useRoundStatus(currentRound);
10199
const [_, end] = getRoundTimes(currentRound);
102100
useEffect(() => {
103-
if (status > 0 || end < Date.now() / 1000 || actualRound !== currentRound) {
101+
if (status > 0 || end < Date.now() / 1000) {
104102
setShowWinnerMessage(true);
105103
setShowCountdown(false);
106104
setSelectedStone(winner || 1);
107-
} else {
105+
} else if (actualRound === currentRound) {
108106
setShowCountdown(true);
109107
setShowWinnerMessage(false);
110108
}
@@ -145,8 +143,8 @@ const Wheel = () => {
145143
if (bets.find((bet) => bet.side === side && bet.player === address)) {
146144
shootConfetti();
147145
}
148-
await queryClient.invalidateQueries({ queryKey: ['stones', 'round', round] });
149146
setShowWinnerMessage(true);
147+
await queryClient.invalidateQueries({ queryKey: ['stones', 'round', round] });
150148
});
151149
},
152150
});
@@ -220,8 +218,6 @@ const Wheel = () => {
220218
};
221219
}, []);
222220

223-
const { t } = useTranslation('stones', { keyPrefix: 'roulette' });
224-
225221
return (
226222
<div
227223
key={'container'}
@@ -362,25 +358,6 @@ const Wheel = () => {
362358
/>
363359
</motion.div>
364360
{showWinnerMessage && <WinnerInfo round={currentRound} scale={scale} />}
365-
<div
366-
key={'round-over'}
367-
className={cx('flex flex-col')}
368-
style={{
369-
fontSize: `${17 * scale * 2}px`,
370-
lineHeight: `${17 * scale * 2}px`,
371-
}}
372-
>
373-
<span>{t('roundIsOver')}</span>
374-
<span
375-
style={{
376-
fontSize: `${10 * scale * 2}px`,
377-
lineHeight: `${14 * scale * 2}px`,
378-
}}
379-
className={'font-light text-tertiary-foreground'}
380-
>
381-
{t('waitingForSpin')}
382-
</span>
383-
</div>
384361
</AnimatePresence>
385362
</div>
386363
</div>

src/components/TableBet/AllRoundsTable.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const AllRoundsTable = () => {
5959
];
6060

6161
const handleClick = (row: { round: number }) => {
62-
navigate({ to: '/stones', search: { round: row.round } });
62+
navigate({ to: '/games/stones', search: { round: row.round } });
6363
};
6464

6565
return <DataTable columns={columns} data={rounds} onRowClick={handleClick} />;

src/components/TableBet/MyBetsTable.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const MyBetsTable = () => {
6767
];
6868

6969
const handleClick = (row: { round: number }) => {
70-
navigate({ to: '/stones', search: { round: row.round } });
70+
navigate({ to: '/games/stones', search: { round: row.round } });
7171
};
7272

7373
return <DataTable columns={columns} data={rounds} onRowClick={handleClick} />;

src/components/VersionValidation.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import logger from '@/src/config/logger.ts';
22
import { toast } from '@betfinio/components/hooks';
33
import { Button } from '@betfinio/components/ui';
4-
import { useLatestVersion } from 'betfinio_app/github';
4+
import { useLatestVersion } from 'betfinio_context/lib/query';
55
import { type FC, useEffect } from 'react';
6+
67
interface VersionValidationProps {
78
repository: string;
89
branch: string;
@@ -13,7 +14,7 @@ export const VersionValidation: FC<VersionValidationProps> = ({ branch, reposito
1314
useEffect(() => {
1415
logger.warn('Latest version:', version);
1516
logger.warn('Deployed version:', current);
16-
if (!version || !current) return;
17+
if (!version || !current || current === 'undefined') return;
1718
if (version.toLowerCase() !== current.toLowerCase()) {
1819
logger.warn('New version available!');
1920
toast({

src/env.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
/// <reference types="@rsbuild/core/types" />
2+
import type { router } from '@/src/bootstrap';
3+
4+
declare module '@tanstack/react-router' {
5+
interface Register {
6+
router: typeof router;
7+
}
8+
}

0 commit comments

Comments
 (0)