Skip to content

Commit

Permalink
Added a ton of code, might be unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
luloxi committed Jul 3, 2023
1 parent 8760993 commit a9a8bf1
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 332 deletions.
104 changes: 104 additions & 0 deletions migration/DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
### Write Functions

**function createChallenge(address \_team2, address \_locationProvider) public payable**

Desafia a otro address `_team2` especificando un segundo address para el proveedor de locación `_locationProvider`. Asimismo, es payable y tiene un monto mínimo para ser llamada la función, que si se supera, queda todo el monto excedente a ese mínimo como monto apostado.

**function acceptChallenge(uint256 \_challengeId) public payable**

Acepta el desafío indicando el `_challengeId` del desafio a aceptar, y es payable, requiriendo pagar al menos el mismo monto que ha pagado el equipo desafiante al enviar el desafío.

**function updateLocationProvider(uint256 \_challengeId, address \_newLocationProvider) public**

Permite cambiar el address `_newLocationProvider` del desafío especificado `_challengeId`

**function deleteChallenge(uint256 \_challengeId) public**

Permite eliminar o rechazar el desafío, y reembolsar a el/los equipos que hayan pagado para participar.

**function startChallenge(uint256 \_challengeId) public**

Función sólo llamable por el proveedor de locación, permite dar por empezado el desafío, quedando así imposibilitado de serr eliminado/rechazado, y habilitandolo para ser completado al finalizar el encuentro.

**function completeChallenge(uint256 \_challengeId,uint8 \_team1Result,uint8 \_team2Result**

Función que da por concluido el desafío `_challengeId`, específicando el puntaje de cada equipo `_team1Result` y `_team2Result`. Habilita para ser retirado el monto ganado al equipo ganador, así como el monto abonado al proveedor de locación, y mintea un NFT para cada equipo participante con el resultado del partido.

**function claimPrize() external**

Permite reclamar todos los tokens que corresponden al wallet por haber empatado o ganado desafíos.

**function claimLocationProviderWinnings() public**

Permite reclamar todos los tokens que corresponden al wallet por haber arbitrado desafíos.

### Read Functions

**function viewMatchChallenge(uint256 \_id) public view returns (address[3] memory)**
Retorna [team1, team2, locationProvider];

**function viewMatchStatus(uint256 \_id) public view returns (MatchStatus)**
Retorna 0, 1, 2, 3
(pendiente de aceptar, aceptado, iniciado, terminado)

**function viewUnclaimedPrize() public view returns (uint256)**
Muestra el monto de premios sin reclamar por un equipo

**function viewLocationProviderWithdrawableAmount()public view returns (uint256)**
Muestra el monto de premios sin reclamar por un proveedor de locación

**function viewMatchFee() public view returns (uint256)**
Muestra el fee que se compone de lo que se abonará al proveedor de locación y al dueño del contrato Sportsbook.

**function getAllMatches() public view returns (MatchChallenge[])**
Retorna todos los partidos que fueron creados en el contrato.

## Functions

### createChallenge(address \_team2, address \_locationProvider)

_Create a new match challenge_

- Push a MatchChallenge structured item to matchChallenges array.
- Specify an amount to be betted on the outcome of the match
- Specify the location provider

### acceptChallenge(uint256 \_challengeId)

_Accept an existing challenge_

- Push the MatchAccepted structured item to the acceptedChallenges array.
- Add payment for betting on outcome of the match

### deleteChallenge(uint256 \_challengeId)

_Function that deletes existing challenge_

- Set challenge on matchChallenges as finished
- Return ETH paid

### updateChallengedTeam(uint256 \_challengeId, address \_newTeam2)

_Update an existing challenge's team 2_

- Give team1 (proposer) the ability to challenge a different team on the same proposal.

### updateLocationProvider(uint256 \_challengeId, address \_newLocationProvider)

_Update an existing challenge's location provider_

- Give both teams the ability to update the location provider.
- If a location update is submitted, it must be accepted by the other team

### functions to view existing challenges... (to be listed)

### struct MatchChallenge

_Data structure for a match_

- **Team(s)** involved in a match.
- **Location provider**
- If match already been **accepted** by both teams
- If match already **started** according to location provider
- If match already **finished** according to location provider
(after setting **finished** to true, trigger payments for location provider and winner),
172 changes: 0 additions & 172 deletions migration/EXPAND-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,6 @@ Permite la creacion de desafios deportivos de un equipo a otro, especificando un

Al momento de finalización de cada encuentro, se paga el monto apostado al ganador, y un pequeño fee al proveedor de locacion y al dueño del contrato Sportsbook por el servicio. Tambien se mintea un NFT para cada equipo como conmemoración del resultado del encuentro.

## Para usar

Para usar el cliente, se recomienda usar la version LTS de node 16.13.0 o superior

```
cd client
npm install
npm run dev
```

## Network

#### Tesnet: Mumbai

Por favor, antes de testear el proyecto, fondear su wallet con MATIC MUMBAI.

#### Faucet:

https://mumbaifaucet.com/

https://faucet.polygon.technology/

## Frontend

Primero se llega a una landing que explica brevemente la dapp, permite hacer login con wallet, y luego se ingresa a la app.
Expand Down Expand Up @@ -76,16 +54,6 @@ La interfaz para proveedores de locacion tiene las siguientes funcionalidades.

(for big sports betting there's already [other options](https://stake.com/) )

## Changelog

- 11/12/2022: Added some concept images made with Canva
- 09/12/2022: Added some Wagmi read indicators,improvements to interface and smart contract
- 08/12/2022: Integrated Wagmi hooks to make buttons interact with the blockchain
- 07/12/2022: Made a simple layout for buttons with ChakraUI
- 06/12/2022: Installed NextJS with TypeScript, RainbowKit, Wagmi and ChakraUI for frontend
- 05/12/2022: Tested smart contract with Hardhat and did some corrections. Expanded README.md
- 04/12/2022: Created README.md and first smart contract (SportsbookBase). Tested on scaffold-eth for a quick frontend

## Pending

### Now
Expand Down Expand Up @@ -140,146 +108,6 @@ La interfaz para proveedores de locacion tiene las siguientes funcionalidades.
- Explore the option of a platform token ($SPOR)
- Automatically generate a wallet key pair for each user that doesn't register with a wallet, with a section to view the private key like [Gala Games](https://app.gala.games/) or [PunkWallet](https://punkwallet.io/).

# Smart Contracts

1. To run tests, enter `/hardhat` folder with command `cd hardhat`
2. Then, run `yarn` to install dependencies
3. Finally, run `yarn hardhat test` to run the tests

## Smart contract

Deploy: https://mumbai.polygonscan.com/address/0x4f1b7e7f61ad6a6efa788e974bbb9e31519ec05c

### Write Functions

**function createChallenge(address \_team2, address \_locationProvider) public payable**

Desafia a otro address `_team2` especificando un segundo address para el proveedor de locación `_locationProvider`. Asimismo, es payable y tiene un monto mínimo para ser llamada la función, que si se supera, queda todo el monto excedente a ese mínimo como monto apostado.

**function acceptChallenge(uint256 \_challengeId) public payable**

Acepta el desafío indicando el `_challengeId` del desafio a aceptar, y es payable, requiriendo pagar al menos el mismo monto que ha pagado el equipo desafiante al enviar el desafío.

**function updateLocationProvider(uint256 \_challengeId, address \_newLocationProvider) public**

Permite cambiar el address `_newLocationProvider` del desafío especificado `_challengeId`

**function deleteChallenge(uint256 \_challengeId) public**

Permite eliminar o rechazar el desafío, y reembolsar a el/los equipos que hayan pagado para participar.

**function startChallenge(uint256 \_challengeId) public**

Función sólo llamable por el proveedor de locación, permite dar por empezado el desafío, quedando así imposibilitado de serr eliminado/rechazado, y habilitandolo para ser completado al finalizar el encuentro.

**function completeChallenge(uint256 \_challengeId,uint8 \_team1Result,uint8 \_team2Result**

Función que da por concluido el desafío `_challengeId`, específicando el puntaje de cada equipo `_team1Result` y `_team2Result`. Habilita para ser retirado el monto ganado al equipo ganador, así como el monto abonado al proveedor de locación, y mintea un NFT para cada equipo participante con el resultado del partido.

**function claimPrize() external**

Permite reclamar todos los tokens que corresponden al wallet por haber empatado o ganado desafíos.

**function claimLocationProviderWinnings() public**

Permite reclamar todos los tokens que corresponden al wallet por haber arbitrado desafíos.

### Read Functions

**function viewMatchChallenge(uint256 \_id) public view returns (address[3] memory)**
Retorna [team1, team2, locationProvider];

**function viewMatchStatus(uint256 \_id) public view returns (MatchStatus)**
Retorna 0, 1, 2, 3
(pendiente de aceptar, aceptado, iniciado, terminado)

**function viewUnclaimedPrize() public view returns (uint256)**
Muestra el monto de premios sin reclamar por un equipo

**function viewLocationProviderWithdrawableAmount()public view returns (uint256)**
Muestra el monto de premios sin reclamar por un proveedor de locación

**function viewMatchFee() public view returns (uint256)**
Muestra el fee que se compone de lo que se abonará al proveedor de locación y al dueño del contrato Sportsbook.

**function getAllMatches() public view returns (MatchChallenge[])**
Retorna todos los partidos que fueron creados en el contrato.

## Functions

### createChallenge(address \_team2, address \_locationProvider)

_Create a new match challenge_

- Push a MatchChallenge structured item to matchChallenges array.
- Specify an amount to be betted on the outcome of the match
- Specify the location provider

### acceptChallenge(uint256 \_challengeId)

_Accept an existing challenge_

- Push the MatchAccepted structured item to the acceptedChallenges array.
- Add payment for betting on outcome of the match

### deleteChallenge(uint256 \_challengeId)

_Function that deletes existing challenge_

- Set challenge on matchChallenges as finished
- Return ETH paid

### updateChallengedTeam(uint256 \_challengeId, address \_newTeam2)

_Update an existing challenge's team 2_

- Give team1 (proposer) the ability to challenge a different team on the same proposal.

### updateLocationProvider(uint256 \_challengeId, address \_newLocationProvider)

_Update an existing challenge's location provider_

- Give both teams the ability to update the location provider.
- If a location update is submitted, it must be accepted by the other team

### functions to view existing challenges... (to be listed)

### struct MatchChallenge

_Data structure for a match_

- **Team(s)** involved in a match.
- **Location provider**
- If match already been **accepted** by both teams
- If match already **started** according to location provider
- If match already **finished** according to location provider
(after setting **finished** to true, trigger payments for location provider and winner),

## Frontend

### Functionalities to add:

**Displaying existing challenges for connected wallet:**

- **address and name** of who made the challenge
- **challenge cost**
- **bet amount** (if any)
- **accept** button
- **cancel** button

**Displaying unstarted challenges by location provider**

- a button to **start**
- a button to **complete**
- a button to **decline**

**Profiles**

- A display for NFTs
- Challenges made, received, and played
- Contact information
- Preferred locations & geographic area for matchmaking.

## Cosas que nos faltaron:

- La interface del Referee, que se encarga de actualizar los estados del partido desde su inicio hasta su finalización.
Expand Down
Loading

0 comments on commit a9a8bf1

Please sign in to comment.