Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN rm -rf node_modules
ENV VCPKG_FORCE_SYSTEM_BINARIES=1

# Install dependencies
RUN npm install --build-from-source
RUN npm install

# Ensure that the necessary binaries are in the PATH
ENV PATH="/dist/node_modules/.bin:${PATH}"
Expand All @@ -32,4 +32,4 @@ WORKDIR packages/node
EXPOSE 1031

# Define the command to run when the container starts
CMD ["npm", "start"]
CMD ["npm", "start:bcn"]
3,623 changes: 1,136 additions & 2,487 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"esbuild": "^0.24.0"
},
"devDependencies": {
"@types/dotenv": "^8.2.3",
"@types/node": "^20.11.21",
"edit-json-file": "^1.8.0",
"eslint": "^8.57.0",
Expand Down
6 changes: 2 additions & 4 deletions packages/TBC20/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": "rm -rf build && tsc -p tsconfig.release.json",
"build:turbo": "turbo run build",
"build:watch": "tsc -w -p tsconfig.release.json",
"clean": "rimraf coverage build tmp",
"clean": "rm -rf coverage build tmp",
"clean:logs": "rm -f *.log 2> /dev/null",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,scss,md}\"",
"lint": "eslint src test --ext .ts,.tsx",
Expand All @@ -26,12 +26,10 @@
"dependencies": {
"@bitcoin-computer/lib": "^0.23.0-beta.0",
"eslint-plugin-prettier": "^5.1.3",
"ts-node": "^10.9.2",
"tslib": "~2.6.2"
"ts-node": "^10.9.2"
},
"devDependencies": {
"@types/chai": "^5.0.1",
"@types/expect": "^24.3.0",
"@types/mocha": "^10.0.6",
"@types/node": "~20.11.21",
"chai": "^5.1.2",
Expand Down
6 changes: 2 additions & 4 deletions packages/TBC721/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build": "rm -rf build && tsc -p tsconfig.release.json",
"build:turbo": "turbo run build",
"build:watch": "tsc -w -p tsconfig.release.json",
"clean": "rimraf coverage build tmp",
"clean": "rm -rf coverage build tmp",
"clean:logs": "rm -f *.log 2> /dev/null",
"deploy": "npx tsx src/deploy.ts",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,scss,md}\"",
Expand All @@ -30,12 +30,10 @@
"@bitcoin-computer/lib": "^0.23.0-beta.0",
"chai-match-pattern": "^1.3.0",
"eslint-plugin-prettier": "^5.1.3",
"ts-node": "^10.9.2",
"tslib": "~2.6.2"
"ts-node": "^10.9.2"
},
"devDependencies": {
"@types/chai": "^5.0.1",
"@types/expect": "^24.3.0",
"@types/mocha": "^10.0.6",
"@types/node": "~20.11.21",
"chai": "^5.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
"react-dom": "^18.3.1"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"@eslint/js": "^9.18.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.20",
"eslint": "^9.9.0",
"eslint": "^9.18.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.9",
"globals": "^15.9.0",
Expand Down
5 changes: 2 additions & 3 deletions packages/chess-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,18 @@
"url": "^0.11.4"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"@eslint/js": "^9.18.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/dotenv": "^8.2.3",
"@types/node": "^22.9.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.20",
"crypto": "1.0.1",
"ecpair": "^2.1.0",
"eslint": "^9.9.0",
"eslint": "^9.18.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.9",
"globals": "^15.9.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/chess-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
"dotenv": "^16.4.5",
"mocha": "^10.3.0",
"prettier": "~3.2.5",
"ts-node": "^10.9.2",
"tslib": "~2.6.2"
"ts-node": "^10.9.2"
},
"volta": {
"node": "16.13.0"
Expand Down
20 changes: 10 additions & 10 deletions packages/chess-contracts/test/chess-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('ChessContract', () => {
], mod)
expect(typeof secretHashW).not.toEqual('undefined')
expect(chessContract.fen).toEqual('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1')
}, 30000)
})
})

describe('move', () => {
Expand All @@ -84,7 +84,7 @@ describe('ChessContract', () => {
)
expect(typeof chessContract.payment).not.toEqual('undefined')
expect(chessContract.fen).not.toEqual(fenBefore)
}, 30000)
})
})
})

Expand Down Expand Up @@ -126,7 +126,7 @@ describe('ChessContractHelper', () => {
})
chessContractHelperW.mod = await deploy(computerW, chessContractDirectory)
chessContractHelperB.mod = chessContractHelperW.mod
}, 20000)
})

describe('makeTx', () => {
it('Should deploy the smart contract', () => {
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('ChessContractHelper', () => {
])
expect(Object.keys(env)).toEqual([])
await res.move('e2', 'e4')
}, 10000)
})
})

describe('move', () => {
Expand All @@ -182,7 +182,7 @@ describe('ChessContractHelper', () => {
const { newChessContract } = await chessContractHelperW.move(chessContract, 'e2', 'e4')
expect(newChessContract.fen).toEqual('rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1')
expect(newChessContract.sans).toEqual(['e4'])
}, 20000)
})
})

describe.skip('spendWithSecret', () => {
Expand Down Expand Up @@ -224,14 +224,14 @@ describe('ChessContractHelper', () => {
const txId = await cchb.completeTx(tx)
const txId2 = await cchb.spendWithSecret(txId, secretB, 1)
expect(typeof txId2).toEqual('string')
}, 20000)
})

it('Should allow white to spend with the correct secret', async () => {
const tx = await cchw.makeTx()
const txId = await cchb.completeTx(tx)
const txId2 = await cchw.spendWithSecret(txId, secretW, 0)
expect(typeof txId2).toEqual('string')
}, 20000)
})

it('Should throw an error when trying to spend with the wrong secret', async () => {
const tx = await cchw.makeTx()
Expand All @@ -242,7 +242,7 @@ describe('ChessContractHelper', () => {
await expect(cchw.spendWithSecret(txId, secretB, 1)).rejects.toThrow(
'mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)',
)
}, 20000)
})
})

describe('spend', () => {
Expand Down Expand Up @@ -274,7 +274,7 @@ describe('ChessContractHelper', () => {
const res = await chessContractHelperB.move(chessContract5, 'd8', 'h4')
expect(await res.newChessContract.isGameOver()).toEqual(true)
expect(res.isGameOver).toEqual(true)
}, 20000)
})

it('Should work for a game of fools mate', async () => {
const tx = await chessContractHelperW.makeTx()
Expand Down Expand Up @@ -309,6 +309,6 @@ describe('ChessContractHelper', () => {
const res = await chessContractHelperB5.move(chessContract5, 'd8', 'h4')
expect(await res.newChessContract.isGameOver()).toEqual(true)
expect(res.isGameOver).toEqual(true)
}, 20000)
})
})
})
9 changes: 7 additions & 2 deletions packages/chess-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Start a Bitcoin Computer Node in the package `node`. Then copy the `.env.example
cp .env.example .env
```

Setup the environment variables for the chess-app `chess/app/.env` file.

```
cp ../chess-app/.env.example ../chess-app/.env
```
### Deploy Smart Contract

Deploy the smart contract. The script will prompt you to update the `.env` files in this package as well as in the packages `chess-contracts` and `chess-app`.
Expand All @@ -21,7 +26,7 @@ npm run deploy
Start the database.

```
npm run start-postgress
npm run start:postgres
```

Then start the express server.
Expand All @@ -35,7 +40,7 @@ npm run start:dev
Build Docker and start the database and express servers.

```
npm run build-docker
npm run build:docker
npm run up
```

Expand Down
28 changes: 28 additions & 0 deletions packages/chess-server/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
)
16 changes: 7 additions & 9 deletions packages/chess-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@
"private": true,
"type": "module",
"scripts": {
"build-docker": "docker build -t chess-server .",
"build:docker": "docker build -t chess-app-server .",
"build:docker": "docker build -t chess-server .",
"clean": "rm -rf db/db-data",
"create:migration": "migrate create",
"deploy": "node --loader ts-node/esm ./scripts/deploy.ts",
"lint": "tslint -p tsconfig.json --fix",
"lint": "eslint .",
"migrate": "migrate up",
"rollback": "migrate down",
"start": "node --loader ts-node/esm.mjs -r tsconfig-paths/register src/app.ts",
"start:dev": "nodemon --exec npm run start -- --ext ts",
"start:postgres": "docker-compose up postgres",
"test": "POSTGRES_HOST=127.0.0.1 BITCOIN_RPC_HOST=127.0.0.1 BCN_ZMQ_URL=tcp://127.0.0.1:28332 mocha -r ts-node/register --loader=ts-node/esm --timeout=30000000 test/**/*.test.ts test/*.test.ts",
"up": "docker-compose up"
"start:postgres": "docker compose up postgres",
"test": "POSTGRES_HOST=127.0.0.1 BITCOIN_RPC_HOST=127.0.0.1 BCN_ZMQ_URL=tcp://127.0.0.1:28332 mocha -r ts-node/register --loader=ts-node/esm --timeout=30000000 test/*.test.ts",
"up": "docker compose up"
},
"dependencies": {
"@bitcoin-computer/lib": "0.22.0-beta.0",
"@bitcoin-computer/lib": "0.23.0-beta.0",
"@types/cors": "^2.8.17",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
Expand All @@ -32,11 +31,10 @@
"devDependencies": {
"@types/express": "^5.0.0",
"@types/node": "^20.11.20",
"@types/pg-promise": "^5.4.3",
"@types/uuid": "9.0.8",
"migrate": "^2.1.0",
"nodemon": "^3.1.0",
"tslint": "^6.1.3",
"eslint": "^9.18.0",
"typescript": "^5.3.3"
}
}
1 change: 1 addition & 0 deletions packages/chess-server/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import express, { Request, Response } from 'express'
import { db } from '../db/db.js'
import { Computer } from '@bitcoin-computer/lib'
Expand Down
4 changes: 2 additions & 2 deletions packages/explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
"react-dom": "^18.3.1"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"@eslint/js": "^9.18.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.20",
"eslint": "^9.9.0",
"eslint": "^9.18.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.9",
"globals": "^15.9.0",
Expand Down
20 changes: 10 additions & 10 deletions packages/lib/dist/bc-lib.browser.min.mjs

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions packages/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@bitcoin-computer/nakamotojs": "^0.23.0-beta.0",
"@bitcoin-computer/secp256k1": "^0.23.0-beta.0",
"@endo/static-module-record": "^1.0.4",
"axios": "1.6.7",
"axios": "1.7.9",
"bip174": "^2.1.1",
"bip32": "^4.0.0",
"bip39": "^3.1.0",
Expand All @@ -88,8 +88,6 @@
"path": "^0.12.7",
"randombytes": "^2.1.0",
"ses": "1.3.0",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1",
"varuint-bitcoin": "^1.1.2"
},
"devDependencies": {
Expand Down
5 changes: 2 additions & 3 deletions packages/nakamotojs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"build": "npm run clean && tsc -p ./tsconfig.json && npm run formatjs && npm run build:tests",
"build:tests": "npm run clean:jstests && tsc -p ./test/tsconfig.json",
"build:turbo": "turbo run build",
"clean": "rimraf src",
"clean:jstests": "rimraf 'test/**/!(ts-node-register)*.js'",
"clean": "rm -rf src",
"clean:jstests": "rm -rf 'test/**/!(ts-node-register)*.js'",
"coverage": "npm run build && npm run nobuild:coverage",
"coverage:html": "npm run build && npm run nobuild:coverage:html",
"coverage:report": "npm run build && npm run nobuild:coverage:report",
Expand Down Expand Up @@ -85,7 +85,6 @@
"prettier": "^3.2.5",
"proxyquire": "^2.0.1",
"randombytes": "^2.1.0",
"rimraf": "^2.6.3",
"ts-node": "^8.3.0",
"typescript": "^5.5.3"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/nft/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
"react-dom": "^18.3.1"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"@eslint/js": "^9.18.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.20",
"eslint": "^9.9.0",
"eslint": "^9.18.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.9",
"globals": "^15.9.0",
Expand Down
Loading