fixes
This commit is contained in:
parent
db9c2829fd
commit
e5b151f5be
10 changed files with 70 additions and 13 deletions
|
@ -5,6 +5,7 @@ import chipImg from '../../../../assets/icons/chip.png'
|
||||||
import {useStores} from "../../../hooks/useStores.tsx";
|
import {useStores} from "../../../hooks/useStores.tsx";
|
||||||
import {observer} from "mobx-react-lite";
|
import {observer} from "mobx-react-lite";
|
||||||
import {CheckBalanceButton} from "../../../web3/balance/CheckBalanceButton.tsx";
|
import {CheckBalanceButton} from "../../../web3/balance/CheckBalanceButton.tsx";
|
||||||
|
import {FaucetButton} from "../../web3/FaucetButton.tsx";
|
||||||
|
|
||||||
export const AppNav = observer(() => {
|
export const AppNav = observer(() => {
|
||||||
const { userStore } = useStores()
|
const { userStore } = useStores()
|
||||||
|
@ -23,15 +24,12 @@ export const AppNav = observer(() => {
|
||||||
<div className="rounded-[100px] bg-[#2D313D] flex flex-row items-center justify-between shadow-inset">
|
<div className="rounded-[100px] bg-[#2D313D] flex flex-row items-center justify-between shadow-inset">
|
||||||
<div className="flex flex-row gap-[3px] items-center px-[15px] py-[11px]">
|
<div className="flex flex-row gap-[3px] items-center px-[15px] py-[11px]">
|
||||||
<CoinIcon />
|
<CoinIcon />
|
||||||
{/* placeholder for balance */}
|
{userStore.balance ? <span> {
|
||||||
{userStore.balance ? <span>{userStore.balance}</span> : <CheckBalanceButton/>}
|
parseFloat(userStore.balance) > 5 ? userStore.balance : <FaucetButton/>
|
||||||
|
}</span> : <CheckBalanceButton/>}
|
||||||
</div>
|
</div>
|
||||||
<ConnectStateButton/>
|
<ConnectStateButton/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row items-center">
|
|
||||||
<span>Robin F.</span>
|
|
||||||
<ProfileIcon />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
19
frontend/casino/src/app/components/web3/FaucetButton.tsx
Normal file
19
frontend/casino/src/app/components/web3/FaucetButton.tsx
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import {useCheckBalance} from "./useCheckBalance.ts";
|
||||||
|
import {observer} from "mobx-react-lite";
|
||||||
|
import {useEffect} from "react";
|
||||||
|
import {useStores} from "../../hooks/useStores.tsx";
|
||||||
|
import {useFaucet} from "../../web3/functions/Faucet/useFaucet.ts";
|
||||||
|
|
||||||
|
export const FaucetButton = observer(() => {
|
||||||
|
const { faucet, result } = useFaucet()
|
||||||
|
const { userStore } = useStores()
|
||||||
|
useEffect(() => {
|
||||||
|
if (result) userStore.setBalance(result.balance)
|
||||||
|
}, [result])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button onClick={faucet}>
|
||||||
|
Get coins
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
});
|
|
@ -6,7 +6,7 @@ export const RPSPlayButton = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
onClick={() => { playRPS('rock') }}
|
onClick={() => { playRPS('1') }}
|
||||||
className="bg-rose-700 rounded-[100px] shadow text-white text-2xl font-bold py-5 px-10 hover:bg-rose-600 inline-block max-w-[200px]">
|
className="bg-rose-700 rounded-[100px] shadow text-white text-2xl font-bold py-5 px-10 hover:bg-rose-600 inline-block max-w-[200px]">
|
||||||
Играть
|
Играть
|
||||||
</button >
|
</button >
|
||||||
|
|
|
@ -1,14 +1,21 @@
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
import {useSlotMachine} from "../../web3/functions/SlotMachine/useSlotMachine.ts";
|
||||||
|
|
||||||
interface SlotPlayButtonProps {
|
interface SlotPlayButtonProps {
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SlotPlayButton: React.FC<SlotPlayButtonProps> = ({ onClick }) => {
|
const SlotPlayButton: React.FC<SlotPlayButtonProps> = ({ onClick }) => {
|
||||||
|
|
||||||
|
const { playSlot } = useSlotMachine()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="bg-rose-700 rounded-[100px] shadow text-white text-2xl font-bold py-5 px-10 hover:bg-rose-600 max-w-[200px]"
|
className="bg-rose-700 rounded-[100px] shadow text-white text-2xl font-bold py-5 px-10 hover:bg-rose-600 max-w-[200px]"
|
||||||
onClick={onClick}
|
onClick={() => {
|
||||||
|
onClick()
|
||||||
|
playSlot()
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Крутить
|
Крутить
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {useEffect, useState} from "react";
|
import { useEffect, useState } from "react";
|
||||||
import ContainerLayout from "../../utils/ContainerLayout.tsx";
|
import ContainerLayout from "../../utils/ContainerLayout.tsx";
|
||||||
import Reel from "../../components/App/Slot/Reel.tsx";
|
import Reel from "../../components/App/Slot/Reel.tsx";
|
||||||
import SlotPlayButton from "../../components/web3/SlotPlayButton.tsx";
|
import SlotPlayButton from "../../components/web3/SlotPlayButton.tsx";
|
||||||
|
|
|
@ -14,7 +14,7 @@ export const usePlayCraps = () => {
|
||||||
scriptHash: config.craps.contractAddress,
|
scriptHash: config.craps.contractAddress,
|
||||||
operation: 'playCraps',
|
operation: 'playCraps',
|
||||||
args: [
|
args: [
|
||||||
{ type: 'Integer', value: '40' },
|
{ type: 'Integer', value: '4' },
|
||||||
{ type: 'Integer', value: value.toString() },
|
{ type: 'Integer', value: value.toString() },
|
||||||
{ type: 'Integer', value: secondValue.toString() },
|
{ type: 'Integer', value: secondValue.toString() },
|
||||||
]
|
]
|
||||||
|
|
30
frontend/casino/src/app/web3/functions/Faucet/useFaucet.ts
Normal file
30
frontend/casino/src/app/web3/functions/Faucet/useFaucet.ts
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import {useWalletConnect} from "@cityofzion/wallet-connect-sdk-react";
|
||||||
|
import {useCallback} from "react";
|
||||||
|
import {useGetResult} from "../utils/useGetResult.ts";
|
||||||
|
import {config} from "../config/config.ts";
|
||||||
|
|
||||||
|
export const useFaucet = () => {
|
||||||
|
const wcSdk = useWalletConnect()
|
||||||
|
const { getResult, ...statuses } = useGetResult()
|
||||||
|
|
||||||
|
const faucet = useCallback(async () => {
|
||||||
|
console.log(config.zaFaucet.contractAddress)
|
||||||
|
const resp = await wcSdk.invokeFunction({
|
||||||
|
invocations: [{
|
||||||
|
scriptHash: config.zaFaucet.contractAddress,
|
||||||
|
operation: 'getZaCoin',
|
||||||
|
args: []
|
||||||
|
}],
|
||||||
|
signers: [{
|
||||||
|
scopes: 'Global',
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
console.log(resp)
|
||||||
|
await getResult(resp, 'rouletteNumber')
|
||||||
|
}, [wcSdk, getResult])
|
||||||
|
|
||||||
|
return {
|
||||||
|
faucet,
|
||||||
|
...statuses
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,8 +14,8 @@ export const usePlayRPS = () => {
|
||||||
scriptHash: config.rps.contractAddress,
|
scriptHash: config.rps.contractAddress,
|
||||||
operation: 'playRPS',
|
operation: 'playRPS',
|
||||||
args: [
|
args: [
|
||||||
{ type: 'String', value: value },
|
{ type: 'Integer', value: value },
|
||||||
{ type: 'Integer', value: '40' },
|
{ type: 'Integer', value: '4' },
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
signers: [{
|
signers: [{
|
||||||
|
|
|
@ -14,7 +14,7 @@ export const useSlotMachine = () => {
|
||||||
scriptHash: config.slotMachine.contractAddress,
|
scriptHash: config.slotMachine.contractAddress,
|
||||||
operation: 'rollSlot',
|
operation: 'rollSlot',
|
||||||
args: [
|
args: [
|
||||||
{ type: 'Integer', value: '40' },
|
{ type: 'Integer', value: '4' },
|
||||||
]
|
]
|
||||||
}],
|
}],
|
||||||
signers: [{
|
signers: [{
|
||||||
|
|
|
@ -13,5 +13,8 @@ export const config = {
|
||||||
},
|
},
|
||||||
rps: {
|
rps: {
|
||||||
contractAddress: 'ae71ad7c8174530cddecf483e8094539f84fcd7f'
|
contractAddress: 'ae71ad7c8174530cddecf483e8094539f84fcd7f'
|
||||||
|
},
|
||||||
|
zaFaucet: {
|
||||||
|
contractAddress: '66621b53f51303d29a224cb6e5deeec30ad2631b'
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue