Skip to content

Commit

Permalink
Merge pull request #50 from PaimaStudios/update-chess-autosign
Browse files Browse the repository at this point in the history
Update the chess template to support auto-sign
  • Loading branch information
SebastienGllmt authored Dec 8, 2023
2 parents 913d9ba + 56866b6 commit eb13b74
Show file tree
Hide file tree
Showing 28 changed files with 139,791 additions and 106,858 deletions.
2 changes: 1 addition & 1 deletion chess/api/src/controllers/lobbyState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getLobbyById, getRoundData, requirePool } from '@chess/db';
import type { Timer } from '@chess/utils';
import { updateTimer, type LobbyStateQuery } from '@chess/utils';
import { getLobbyRounds } from '@chess/db/src/select.queries';
import { getLatestProcessedBlockHeight } from '@paima/sdk/db';
import { getLatestProcessedBlockHeight } from '@paima/node-sdk/db';

interface Response {
lobby: LobbyStateQuery | null;
Expand Down
2 changes: 1 addition & 1 deletion chess/api/src/controllers/roundExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { requirePool, getLobbyById, getRoundData, getRoundMoves } from '@chess/d
import { isLeft } from 'fp-ts/Either';
import { psqlNum } from '../validation.js';
import type { RoundExecutorData } from '@chess/utils';
import { getBlockHeights } from '@paima/sdk/db';
import { getBlockHeights } from '@paima/node-sdk/db';

type Response = RoundExecutorData | Error;

Expand Down
6 changes: 3 additions & 3 deletions chess/change-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const getBlockHeight = (url, command) =>
// Update .env START_BLOCKHEIGHT with latest value from RPC command: "eth_getBlockByNumber"
const updateEnvFile = async file => {
const dataEnv = await fs.promises.readFile(__dirname + '/' + file, 'utf8');
const url = dataEnv.match(/CHAIN_URI="(.+)"/)[1];
const url = dataEnv.match(/\nCHAIN_URI="(.+)"/)[1];
if (!url) throw new Error('CHAIN_URI not found');
const START_BLOCKHEIGHT = await getBlockHeight(url, {
jsonrpc: '2.0',
Expand All @@ -34,8 +34,8 @@ const updateEnvFile = async file => {
id: 1,
});
const ndataEnv = dataEnv.replace(
/START_BLOCKHEIGHT="\d+"/,
`START_BLOCKHEIGHT="${START_BLOCKHEIGHT}"`
/\nSTART_BLOCKHEIGHT="\d+"/,
`\nSTART_BLOCKHEIGHT="${START_BLOCKHEIGHT}"`
);
await fs.promises.writeFile(file, ndataEnv, 'utf8');
console.log(`ENV file changed: START_BLOCKHEIGHT="${START_BLOCKHEIGHT}"`);
Expand Down
2 changes: 1 addition & 1 deletion chess/db/src/pgPool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type pg from 'pg';
import { getConnection } from '@paima/sdk/db';
import { getConnection } from '@paima/node-sdk/db';

/**
* Pool of Postgres connections to avoid overhead of connecting on every request.
Expand Down
Loading

0 comments on commit eb13b74

Please sign in to comment.