Skip to content

Commit

Permalink
Global prettier reformat. (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraviolet10 authored Mar 4, 2024
2 parents 639f9ff + 78e953c commit b0d586c
Show file tree
Hide file tree
Showing 92 changed files with 6,783 additions and 7,023 deletions.
12 changes: 6 additions & 6 deletions packages/webapp/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"semi": false,
"trailingComma": "es5",
"singleQuote": false,
"tabWidth": 4,
"useTabs": false,
"printWidth": 120
"semi": false,
"trailingComma": "es5",
"singleQuote": false,
"tabWidth": 4,
"useTabs": false,
"printWidth": 120
}
2 changes: 1 addition & 1 deletion packages/webapp/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"javascript.validate.enable": false,
"typescript.validate.enable": false
}
}
2 changes: 1 addition & 1 deletion packages/webapp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ lint:
# Runs code quality checks.
check:
pnpm eslint .
pnpm prettier --check "**/*.{js,jsx,ts,tsx,json,css}"
pnpm prettier --check "src/**/*.{js,jsx,ts,tsx,json,css}"
.PHONY: check

# Runs prettier formatting across webapp files with specified file extensions.
Expand Down
115 changes: 58 additions & 57 deletions packages/webapp/package.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,60 @@
{
"name": "@xfable/webapp",
"version": "0.1.0",
"private": true,
"browser": {
"fs": false,
"path": false,
"os": false
},
"dependencies": {
"@dnd-kit/core": "^6.0.8",
"@dnd-kit/sortable": "^7.0.2",
"@dnd-kit/utilities": "^3.2.1",
"@emotion/react": "^11.11.1",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-slot": "^1.0.2",
"circomlibjs": "^0.1.7",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"connectkit": "^1.5.3",
"eslint-config-prettier": "^9.1.0",
"jotai": "^2.4.3",
"jotai-devtools": "^0.7.0",
"lodash": "^4.17.21",
"lucide-react": "^0.309.0",
"next": "^13.5.6",
"next-themes": "^0.2.1",
"next-transpile-modules": "^10.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "^4.11.0",
"snarkjs": "^0.7.1",
"sonner": "^1.4.0",
"tailwind-merge": "^2.2.0",
"tailwindcss-animate": "^1.0.7",
"viem": "^1.16.6",
"wagmi": "^1.4.5"
},
"devDependencies": {
"@swc-jotai/debug-label": "^0.1.0",
"@swc-jotai/react-refresh": "^0.1.0",
"@types/eslint": "^8.44.6",
"@types/lodash": "^4.14.200",
"@types/node": "^20.8.7",
"@types/react": "^18.2.31",
"@types/react-dom": "^18.2.14",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"@wagmi/cli": "^1.5.2",
"@welldone-software/why-did-you-render": "^7.0.1",
"autoprefixer": "^10.4.16",
"eslint": "^8.52.0",
"eslint-config-next": "^13.5.6",
"postcss": "^8.4.31",
"tailwindcss": "^3.3.3",
"typescript": "^5.2.2"
}
"name": "@xfable/webapp",
"version": "0.1.0",
"private": true,
"browser": {
"fs": false,
"path": false,
"os": false
},
"dependencies": {
"@dnd-kit/core": "^6.0.8",
"@dnd-kit/sortable": "^7.0.2",
"@dnd-kit/utilities": "^3.2.1",
"@emotion/react": "^11.11.1",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-slot": "^1.0.2",
"circomlibjs": "^0.1.7",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"connectkit": "^1.5.3",
"eslint-config-prettier": "^9.1.0",
"jotai": "^2.4.3",
"jotai-devtools": "^0.7.0",
"lodash": "^4.17.21",
"lucide-react": "^0.309.0",
"next": "^13.5.6",
"next-themes": "^0.2.1",
"next-transpile-modules": "^10.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "^4.11.0",
"snarkjs": "^0.7.1",
"sonner": "^1.4.0",
"tailwind-merge": "^2.2.0",
"tailwindcss-animate": "^1.0.7",
"viem": "^1.16.6",
"wagmi": "^1.4.5"
},
"devDependencies": {
"@swc-jotai/debug-label": "^0.1.0",
"@swc-jotai/react-refresh": "^0.1.0",
"@types/eslint": "^8.44.6",
"@types/lodash": "^4.14.200",
"@types/node": "^20.8.7",
"@types/react": "^18.2.31",
"@types/react-dom": "^18.2.14",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"@wagmi/cli": "^1.5.2",
"@welldone-software/why-did-you-render": "^7.0.1",
"autoprefixer": "^10.4.16",
"eslint": "^8.52.0",
"eslint-config-next": "^13.5.6",
"postcss": "^8.4.31",
"prettier": "2.8.8",
"tailwindcss": "^3.3.3",
"typescript": "^5.2.2"
}
}
56 changes: 27 additions & 29 deletions packages/webapp/src/actions/attack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { getOpponentIndex } from "src/store/read"
// =================================================================================================

export type AttackArgs = {
gameID: bigint
playerAddress: Address
setLoading: (label: string | null) => void
/**
* A list of attacking creatures indexes.
*/
selectedCreaturesIndexes: number[]
gameID: bigint
playerAddress: Address
setLoading: (label: string | null) => void
/**
* A list of attacking creatures indexes.
*/
selectedCreaturesIndexes: number[]
}

// -------------------------------------------------------------------------------------------------
Expand All @@ -27,32 +27,30 @@ export type AttackArgs = {
* Returns `true` iff the player successfully declared the attack.
*/
export async function attack(args: AttackArgs): Promise<boolean> {
try {
return await attackImpl(args)
} catch (err) {
args.setLoading(null)
return defaultErrorHandling("attack", err)
}
try {
return await attackImpl(args)
} catch (err) {
args.setLoading(null)
return defaultErrorHandling("attack", err)
}
}

// -------------------------------------------------------------------------------------------------

async function attackImpl(args: AttackArgs): Promise<boolean> {

checkFresh(await freshWrap(
contractWriteThrowing({
contract: deployment.Game,
abi: gameABI,
functionName: "attack",
args: [
args.gameID,
getOpponentIndex()!,
args.selectedCreaturesIndexes
],
setLoading: args.setLoading
})))

return true
checkFresh(
await freshWrap(
contractWriteThrowing({
contract: deployment.Game,
abi: gameABI,
functionName: "attack",
args: [args.gameID, getOpponentIndex()!, args.selectedCreaturesIndexes],
setLoading: args.setLoading,
})
)
)

return true
}

// =================================================================================================
// =================================================================================================
50 changes: 25 additions & 25 deletions packages/webapp/src/actions/concede.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { gameABI } from "src/generated"
// =================================================================================================

export type ConcedeArgs = {
gameID: bigint
playerAddress: Address
setLoading: (label: string | null) => void
onSuccess: () => void
gameID: bigint
playerAddress: Address
setLoading: (label: string | null) => void
onSuccess: () => void
}

// -------------------------------------------------------------------------------------------------
Expand All @@ -22,31 +22,31 @@ export type ConcedeArgs = {
* Returns `true` iff the player successfully conceded the defenders.
*/
export async function concede(args: ConcedeArgs): Promise<boolean> {
try {
return await concedeImpl(args)
} catch (err) {
args.setLoading(null)
return defaultErrorHandling("concede", err)
}
try {
return await concedeImpl(args)
} catch (err) {
args.setLoading(null)
return defaultErrorHandling("concede", err)
}
}

// -------------------------------------------------------------------------------------------------

async function concedeImpl(args: ConcedeArgs): Promise<boolean> {

checkFresh(await freshWrap(
contractWriteThrowing({
contract: deployment.Game,
abi: gameABI,
functionName: "concedeGame",
args: [
args.gameID,
],
setLoading: args.setLoading
})))

args.onSuccess()
return true
checkFresh(
await freshWrap(
contractWriteThrowing({
contract: deployment.Game,
abi: gameABI,
functionName: "concedeGame",
args: [args.gameID],
setLoading: args.setLoading,
})
)
)

args.onSuccess()
return true
}

// =================================================================================================
// =================================================================================================
59 changes: 29 additions & 30 deletions packages/webapp/src/actions/defend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { gameABI } from "src/generated"
// =================================================================================================

export type DefendArgs = {
gameID: bigint
playerAddress: Address
setLoading: (label: string | null) => void
/**
* A list of defending creatures indexes. This array must be the same length as the list of
* attacking creatures, and maybe contain 0 to signal that an attacking creature should not be
* blocked.
*/
defendingCreaturesIndexes: number[]
gameID: bigint
playerAddress: Address
setLoading: (label: string | null) => void
/**
* A list of defending creatures indexes. This array must be the same length as the list of
* attacking creatures, and maybe contain 0 to signal that an attacking creature should not be
* blocked.
*/
defendingCreaturesIndexes: number[]
}

// -------------------------------------------------------------------------------------------------
Expand All @@ -27,31 +27,30 @@ export type DefendArgs = {
* Returns `true` iff the player successfully declared the defenders.
*/
export async function defend(args: DefendArgs): Promise<boolean> {
try {
return await defendImpl(args)
} catch (err) {
args.setLoading(null)
return defaultErrorHandling("defend", err)
}
try {
return await defendImpl(args)
} catch (err) {
args.setLoading(null)
return defaultErrorHandling("defend", err)
}
}

// -------------------------------------------------------------------------------------------------

async function defendImpl(args: DefendArgs): Promise<boolean> {

checkFresh(await freshWrap(
contractWriteThrowing({
contract: deployment.Game,
abi: gameABI,
functionName: "defend",
args: [
args.gameID,
args.defendingCreaturesIndexes
],
setLoading: args.setLoading
})))

return true
checkFresh(
await freshWrap(
contractWriteThrowing({
contract: deployment.Game,
abi: gameABI,
functionName: "defend",
args: [args.gameID, args.defendingCreaturesIndexes],
setLoading: args.setLoading,
})
)
)

return true
}

// =================================================================================================
// =================================================================================================
Loading

0 comments on commit b0d586c

Please sign in to comment.