-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5bdaece
Showing
207 changed files
with
40,265 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Contracts | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: {} | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
test: | ||
name: "Contracts: Unit Tests" | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./contracts | ||
env: | ||
REPORT_GAS: true | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Run tests | ||
run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"solidity.compileUsingRemoteVersion": "v0.8.7+commit.e28d00a7" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Rugby Prediction Game | ||
|
||
> **Note** | ||
> | ||
> _This demo represents an educational example to use a Chainlink system, product, or service and is provided to demonstrate how to interact with Chainlink’s systems, products, and services to integrate them into your own. This template is provided “AS IS” and “AS AVAILABLE” without warranties of any kind, it has not been audited, and it may be missing key checks or error handling to make the usage of the system, product or service more clear. Do not use the code in this example in a production environment without completing your own audits and application of best practices. Neither Chainlink Labs, the Chainlink Foundation, nor Chainlink node operators are responsible for unintended outputs that are generated due to errors in code._ | ||
This project has been developed for educational purposes only and is not meant to be used for gambling. | ||
|
||
This project demostrates how to build a smart contract based application using real time sports data via [Chainlink Functions](https://docs.chain.link/chainlink-functions). | ||
|
||
Additionally, the project showcases how to send automatic payouts using [Chainlink Automation](https://chain.link/automation) and how to transfer tokens cross-chain using [Chainlink CCIP](https://chain.link/cross-chain). | ||
|
||
## Requirements | ||
|
||
- Node.js version [18](https://nodejs.org/en/download/) or higher | ||
|
||
## Getting Started | ||
|
||
Clone the repo: | ||
|
||
```bash | ||
git clone https://github.com/hackbg/chainlink-prediction-game | ||
``` | ||
|
||
It contains two separate projects: | ||
|
||
- [`contracts`](./contracts/) - the smart contracts | ||
- [`app`](./app/) - the frontend | ||
|
||
Navigate to each directory and follow the instructions in their respective README files, starting with the contracts. | ||
|
||
## Solution Overview | ||
|
||
<img src="./solution-diagram.png" alt="Solution" width="100%"/> | ||
|
||
## Resources | ||
|
||
- [Chainlink Functions Docs](https://docs.chain.link/chainlink-functions) | ||
- [Chainlink Automation Docs](https://docs.chain.link/chainlink-automation/introduction) | ||
- [Chainlink CCIP Docs](https://docs.chain.link/ccip) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
NEXT_PUBLIC_ALCHEMY_API_KEY= | ||
NEXT_PUBLIC_WALLET_CONNECT_ID= | ||
NEXT_PUBLIC_CONTRACT_ADDRESS= | ||
NEXT_PUBLIC_GTM_ID= | ||
API_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": [ | ||
"next/core-web-vitals", | ||
"prettier", | ||
"plugin:tailwindcss/recommended" | ||
], | ||
"plugins": ["tailwindcss"], | ||
"settings": { | ||
"tailwindcss": { | ||
"callees": ["cn"], | ||
"config": "./tailwind.config.js" | ||
} | ||
}, | ||
"rules": { "tailwindcss/no-custom-classname": "off" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
|
||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
|
||
/coverage | ||
|
||
# next.js | ||
|
||
/.next/ | ||
/out/ | ||
|
||
# production | ||
|
||
/build | ||
|
||
# misc | ||
|
||
.DS_Store | ||
\*.pem | ||
|
||
# debug | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
|
||
.env | ||
.env\*.local | ||
|
||
# vercel | ||
|
||
.vercel | ||
|
||
# typescript | ||
|
||
\*.tsbuildinfo | ||
next-env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
strict-peer-dependencies = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
.next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"arrowParens": "always", | ||
"endOfLine": "lf", | ||
"printWidth": 80, | ||
"semi": false, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Sports Prediction Game: Frontend | ||
|
||
This directory is a Next.js project bootstrapped with [`create-next-app`](https://nextjs.org/docs/pages/api-reference/create-next-app). | ||
|
||
It contains the frontend for the sports prediction game and additional backend for data aggregation and server side rendering. | ||
|
||
## Quick Start | ||
|
||
Install all dependencies: | ||
|
||
```bash | ||
npm install | ||
``` | ||
|
||
Set environment variables by copying `.env.example` to `.env` and filling in the values: | ||
|
||
- _NEXT_PUBLIC_ALCHEMY_API_KEY_ for the network you want to use. You can get one from [Alchemy](https://www.alchemy.com/). | ||
- _NEXT_PUBLIC_WALLET_CONNECT_ID_ for the wallet connector. You can get one from [WalletConnect](https://walletconnect.org/). | ||
- _NEXT_PUBLIC_CONTRACT_ADDRESS_ for the deployed game contract address. | ||
- _API_KEY_ for the sports data API. Obtain one [here](https://dashboard.api-football.com/register). | ||
|
||
Run `npm run dev` in your terminal, and then open [localhost:3000](http://localhost:3000) in your browser. | ||
|
||
## Tech Stack | ||
|
||
- [Next.js](https://nextjs.org/) | ||
- [TypeScript](https://www.typescriptlang.org/) | ||
- [Tailwind CSS](https://tailwindcss.com/) | ||
- [RainbowKit](https://www.rainbowkit.com/) | ||
- [wagmi](https://wagmi.sh/) & [viem](https://viem.sh/) | ||
- [shadcn/ui](https://ui.shadcn.com/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** @type {import('next').NextConfig} */ | ||
module.exports = { | ||
reactStrictMode: true, | ||
images: { | ||
remotePatterns: [ | ||
{ | ||
protocol: 'https', | ||
hostname: 'media-?.api-sports.io', | ||
}, | ||
], | ||
}, | ||
webpack: (config) => { | ||
// Grab the existing rule that handles SVG imports | ||
const fileLoaderRule = config.module.rules.find((rule) => | ||
rule.test?.test?.('.svg'), | ||
) | ||
|
||
config.module.rules.push( | ||
// Reapply the existing rule, but only for svg imports ending in ?url | ||
{ | ||
...fileLoaderRule, | ||
test: /\.svg$/i, | ||
resourceQuery: /url/, // *.svg?url | ||
}, | ||
// Convert all other *.svg imports to React components | ||
{ | ||
test: /\.svg$/i, | ||
issuer: /\.[jt]sx?$/, | ||
resourceQuery: { not: /url/ }, // exclude if *.svg?url | ||
use: ['@svgr/webpack'], | ||
}, | ||
) | ||
|
||
// Modify the file loader rule to ignore *.svg, since we have it handled now. | ||
fileLoaderRule.exclude = /\.svg$/i | ||
config.resolve.fallback = { fs: false, net: false, tls: false } | ||
return config | ||
}, | ||
} |
Oops, something went wrong.