-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from hollow-leaf/feat/contractInteract
feat: contract interact
- Loading branch information
Showing
7 changed files
with
172 additions
and
14 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
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,38 @@ | ||
import { get, insert, update } from "./db.js" | ||
|
||
export const latestGame = async () => { | ||
const num = await get("latest_game") | ||
if (!num) { | ||
await insert({ _id: "latest_game", game_id: 0 }) | ||
} | ||
const { game_id } = await get("latest_game") as any | ||
return game_id | ||
} | ||
|
||
const gamePlus = async () => { | ||
const { game_id } = await get("latest_game") as any | ||
await update("latest_game", { | ||
game_id: game_id + 1, | ||
}) | ||
} | ||
|
||
export const gameState = async (game_id: string) => { | ||
const game = await get(game_id) | ||
if (!game) { | ||
await insert({ | ||
_id: game_id, | ||
game_state: "not_start", | ||
draw_count: 0, | ||
max: 0, | ||
prize_list: [], | ||
}) | ||
} | ||
const { game_state, draw_count, max, prize_list } = await get(game_id) as any | ||
return { | ||
game_id, | ||
game_state, | ||
draw_count, | ||
max, | ||
prize_list, | ||
} | ||
} |
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
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