Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add explicit .js extension #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2023
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
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const compat = new FlatCompat({
module.exports = [
...compat.extends(
'airbnb-typescript',
'plugin:require-extensions/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:import/typescript',
Expand Down
3,332 changes: 3,301 additions & 31 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-require-extensions": "^0.1.3",
"husky": "^8.0.3",
"jest": "^29.4.1",
"json5": "^2.2.3",
Expand All @@ -53,7 +54,5 @@
},
"workspaces": [
"./packages/*/*"
],
"dependencies": {
}
]
}
2 changes: 1 addition & 1 deletion packages/batcher/runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import type { ErrorCode, ErrorMessageFxn, GameInputValidatorCore } from '@paima/batcher-utils';

import { initializePool } from './pg/pgPool.js';
import type { BatcherRuntimeInitializer } from './types';
import type { BatcherRuntimeInitializer } from './types.js';

const MINIMUM_INTER_CATCH_PERIOD = 1000;
let batchedTransactionPosterReference: BatchedTransactionPoster | null = null;
Expand Down
2 changes: 1 addition & 1 deletion packages/batcher/utils/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GameInputValidatorCoreType } from './types';
import { GameInputValidatorCoreType } from './types.js';
import { config } from 'dotenv';
import { ENV as ENGINE_ENV } from '@paima/utils';

Expand Down
2 changes: 1 addition & 1 deletion packages/engine/paima-funnel/src/cde/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
ChainDataExtensionDatum,
ChainDataExtensionErc20,
} from '@paima/runtime';
import type { Transfer } from '@paima/utils/src/contract-types/ERC20Contract';
import type { Transfer } from '@paima/utils/src/contract-types/ERC20Contract.js';
import { DEFAULT_FUNNEL_TIMEOUT } from '@paima/utils';

export default async function getCdeData(
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/paima-funnel/src/cde/erc20Deposit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChainDataExtensionDatumType, timeout } from '@paima/utils';
import type { ChainDataExtensionDatum, ChainDataExtensionErc20Deposit } from '@paima/runtime';
import type { Transfer } from '@paima/utils/src/contract-types/ERC20Contract';
import type { Transfer } from '@paima/utils/src/contract-types/ERC20Contract.js';
import { DEFAULT_FUNNEL_TIMEOUT } from '@paima/utils';

export default async function getCdeData(
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/paima-funnel/src/cde/erc6551Registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
ChainDataExtensionDatum,
ChainDataExtensionErc6551Registry,
} from '@paima/runtime';
import type { AccountCreated } from '@paima/utils/src/contract-types/ERC6551RegistryContract';
import type { AccountCreated } from '@paima/utils/src/contract-types/ERC6551RegistryContract.js';

export default async function getCdeData(
extension: ChainDataExtensionErc6551Registry,
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/paima-funnel/src/cde/erc721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
ChainDataExtensionDatum,
ChainDataExtensionErc721,
} from '@paima/runtime';
import type { Transfer } from '@paima/utils/src/contract-types/ERC721Contract';
import type { Transfer } from '@paima/utils/src/contract-types/ERC721Contract.js';

export default async function getCdeData(
extension: ChainDataExtensionErc721,
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/paima-funnel/src/cde/paimaErc721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
ChainDataExtensionDatum,
ChainDataExtensionPaimaErc721,
} from '@paima/runtime';
import type { Minted, Transfer } from '@paima/utils/src/contract-types/PaimaERC721Contract';
import type { Minted, Transfer } from '@paima/utils/src/contract-types/PaimaERC721Contract.js';

export default async function getCdeData(
extension: ChainDataExtensionPaimaErc721,
Expand Down
12 changes: 6 additions & 6 deletions packages/engine/paima-funnel/src/cde/reading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import type Web3 from 'web3';
import { ChainDataExtensionType } from '@paima/utils';
import type { ChainDataExtensionDatum, ChainDataExtension } from '@paima/runtime';

import getCdeErc20Data from './erc20';
import getCdeErc721Data from './erc721';
import getCdePaimaErc721Data from './paimaErc721';
import getCdeErc20DepositData from './erc20Deposit';
import getCdeGenericData from './generic';
import getCdeErc6551RegistryData from './erc6551Registry';
import getCdeErc20Data from './erc20.js';
import getCdeErc721Data from './erc721.js';
import getCdePaimaErc721Data from './paimaErc721.js';
import getCdeErc20DepositData from './erc20Deposit.js';
import getCdeGenericData from './generic.js';
import getCdeErc6551RegistryData from './erc6551Registry.js';
import assertNever from 'assert-never';

export async function getUngroupedCdeData(
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/paima-funnel/src/funnels/BaseFunnel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ChainData, ChainDataExtension, ChainFunnel, PresyncChainData } from '@paima/runtime';
import type { PaimaL2Contract, Web3 } from '@paima/utils';
import type { FunnelCacheManager } from './FunnelCache';
import type { FunnelCacheManager } from './FunnelCache.js';
import type { PoolClient } from 'pg';

export type FunnelSharedData = {
Expand Down
12 changes: 6 additions & 6 deletions packages/engine/paima-funnel/src/funnels/block/funnel.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ENV, doLog, timeout } from '@paima/utils';
import type { ChainData, ChainFunnel, PresyncChainData } from '@paima/runtime';
import { getBaseChainDataMulti, getBaseChainDataSingle } from '../../reading';
import { getUngroupedCdeData } from '../../cde/reading';
import { composeChainData, groupCdeData } from '../../utils';
import { BaseFunnel } from '../BaseFunnel';
import type { FunnelSharedData } from '../BaseFunnel';
import { RpcCacheEntry, RpcRequestState } from '../FunnelCache';
import { getBaseChainDataMulti, getBaseChainDataSingle } from '../../reading.js';
import { getUngroupedCdeData } from '../../cde/reading.js';
import { composeChainData, groupCdeData } from '../../utils.js';
import { BaseFunnel } from '../BaseFunnel.js';
import type { FunnelSharedData } from '../BaseFunnel.js';
import { RpcCacheEntry, RpcRequestState } from '../FunnelCache.js';
import type { PoolClient } from 'pg';

const GET_BLOCK_NUMBER_TIMEOUT = 5000;
Expand Down
8 changes: 4 additions & 4 deletions packages/engine/paima-funnel/src/funnels/emulated/funnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
import type { IGetBlockHeightsResult } from '@paima/db';
import { hashTogether } from '@paima/utils-backend';

import { calculateBoundaryTimestamp, emulateCde, timestampToBlockNumber } from './utils';
import { BaseFunnel } from '../BaseFunnel';
import type { FunnelSharedData } from '../BaseFunnel';
import { calculateBoundaryTimestamp, emulateCde, timestampToBlockNumber } from './utils.js';
import { BaseFunnel } from '../BaseFunnel.js';
import type { FunnelSharedData } from '../BaseFunnel.js';

import { QueuedBlockCacheEntry, RpcCacheEntry, RpcRequestState } from '../FunnelCache';
import { QueuedBlockCacheEntry, RpcCacheEntry, RpcRequestState } from '../FunnelCache.js';

/**
* For hash calculation of empty blocks to work,
Expand Down
4 changes: 2 additions & 2 deletions packages/engine/paima-funnel/src/funnels/emulated/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { PoolClient } from 'pg';

import type { ChainDataExtensionDatum, ChainFunnel } from '@paima/runtime';
import { EmulatedBlocksFunnel } from './funnel';
import { EmulatedBlocksFunnel } from './funnel.js';
import { DEFAULT_FUNNEL_TIMEOUT, doLog, logError, timeout } from '@paima/utils';
import type { FunnelSharedData } from '../BaseFunnel';
import type { FunnelSharedData } from '../BaseFunnel.js';

export async function wrapToEmulatedBlocksFunnel(
chainFunnel: ChainFunnel,
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/paima-funnel/src/paima-l2-processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import web3UtilsPkg from 'web3-utils';

import { AddressType, doLog, getReadNamespaces } from '@paima/utils';
import type { SubmittedData } from '@paima/runtime';
import type { PaimaGameInteraction } from '@paima/utils/src/contract-types/PaimaL2Contract';
import type { PaimaGameInteraction } from '@paima/utils/src/contract-types/PaimaL2Contract.js';
import { CryptoManager } from '@paima/crypto';
import {
INNER_BATCH_DIVIDER,
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/paima-funnel/src/reading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { BlockTransactionString } from 'web3-eth';
import { timeout, cutAfterFirstRejected, DEFAULT_FUNNEL_TIMEOUT, doLog, delay } from '@paima/utils';
import type { PaimaL2Contract } from '@paima/utils';
import { TimeoutError, type ChainData } from '@paima/runtime';
import type { PaimaGameInteraction } from '@paima/utils/src/contract-types/PaimaL2Contract';
import type { PaimaGameInteraction } from '@paima/utils/src/contract-types/PaimaL2Contract.js';

import { extractSubmittedData } from './paima-l2-processing.js';

Expand Down
8 changes: 4 additions & 4 deletions packages/engine/paima-runtime/src/cde-config/loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import type {
ChainDataExtensionGeneric,
TChainDataExtensionErc721Config,
TChainDataExtensionGenericConfig,
} from '../types';
} from '../types.js';
import {
CdeBaseConfig,
CdeEntryTypeName,
Expand All @@ -33,9 +33,9 @@ import {
ChainDataExtensionErc6551RegistryConfig,
ChainDataExtensionErc721Config,
ChainDataExtensionGenericConfig,
} from '../types';
import type { CdeConfig } from '../types';
import { loadAbi } from './utils';
} from '../types.js';
import type { CdeConfig } from '../types.js';
import { loadAbi } from './utils.js';
import assertNever from 'assert-never';
import fnv from 'fnv-plus';
import stableStringify from 'json-stable-stringify';
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/paima-runtime/src/cde-config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from 'fs/promises';

import { doLog } from '@paima/utils';

import type { ChainDataExtension } from '../types';
import type { ChainDataExtension } from '../types.js';

export function getEarliestStartBlockheight(config: ChainDataExtension[]): number {
const startBlockheights = config.map(cde => cde.startBlockHeight).filter(sbh => !!sbh);
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/paima-runtime/src/cde-config/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { PoolClient, Pool } from 'pg';
import { doLog } from '@paima/utils';
import { tx, getChainDataExtensions, registerChainDataExtension } from '@paima/db';

import type { ChainDataExtension } from '../types';
import type { ChainDataExtension } from '../types.js';

/**
* Check that the configuration used when syncing the game node still matches their current value
Expand Down
18 changes: 9 additions & 9 deletions packages/engine/paima-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import {
emulatedSelectLatestPrior,
getGameInput,
} from '@paima/db';
import { validatePersistentCdeConfig } from './cde-config/validation';
import type { GameStateMachine, IFunnelFactory, PaimaRuntimeInitializer } from './types';
import { validatePersistentCdeConfig } from './cde-config/validation.js';
import type { GameStateMachine, IFunnelFactory, PaimaRuntimeInitializer } from './types.js';

import { run, setRunFlag, clearRunFlag } from './run-flag';
import { run, setRunFlag, clearRunFlag } from './run-flag.js';
import { server, startServer } from './server.js';
import { initSnapshots } from './snapshots.js';
import { startRuntime } from './runtime-loops';
import { startRuntime } from './runtime-loops.js';

export * from './cde-config/loading';
export * from './cde-config/validation';
export * from './cde-config/utils';
export * from './types';
export { TimeoutError } from './utils';
export * from './cde-config/loading.js';
export * from './cde-config/validation.js';
export * from './cde-config/utils.js';
export * from './types.js';
export { TimeoutError } from './utils.js';

process.on('SIGINT', () => {
if (!run) process.exit(0);
Expand Down
10 changes: 5 additions & 5 deletions packages/engine/paima-runtime/src/runtime-loops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ import process from 'process';

import { doLog, logError, delay } from '@paima/utils';
import { tx, DataMigrations } from '@paima/db';
import { getEarliestStartBlockheight } from './cde-config/utils';
import { getEarliestStartBlockheight } from './cde-config/utils.js';
import type {
ChainData,
ChainDataExtension,
ChainFunnel,
GameStateMachine,
IFunnelFactory,
} from './types';
} from './types.js';

import { run } from './run-flag';
import { run } from './run-flag.js';
import { snapshotIfTime } from './snapshots.js';
import {
TimeoutError,
acquireLatestBlockHeight,
exitIfStopped,
loopIfStopBlockReached,
} from './utils';
import { cleanNoncesIfTime } from './nonce-gc';
} from './utils.js';
import { cleanNoncesIfTime } from './nonce-gc.js';
import type { PoolClient } from 'pg';

// The core logic of paima runtime which polls the funnel and processes the resulting chain data using the game's state machine.
Expand Down
4 changes: 2 additions & 2 deletions packages/engine/paima-runtime/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { doLog, logError, delay } from '@paima/utils';
import type { GameStateMachine } from './types';
import type { GameStateMachine } from './types.js';

import { run } from './run-flag';
import { run } from './run-flag.js';
import type { PoolClient } from 'pg';

export async function loopIfStopBlockReached(
Expand Down
12 changes: 6 additions & 6 deletions packages/engine/paima-sm/src/cde-processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import type { PoolClient } from 'pg';
import { ChainDataExtensionDatumType } from '@paima/utils';
import type { ChainDataExtensionDatum } from '@paima/runtime';

import processErc20TransferDatum from './cde-erc20-transfer';
import processErc721TransferDatum from './cde-erc721-transfer';
import processErc721MintDatum from './cde-erc721-mint';
import processErc20DepositDatum from './cde-erc20-deposit';
import processErc6551RegistryDatum from './cde-erc6551-registry';
import processGenericDatum from './cde-generic';
import processErc20TransferDatum from './cde-erc20-transfer.js';
import processErc721TransferDatum from './cde-erc721-transfer.js';
import processErc721MintDatum from './cde-erc721-mint.js';
import processErc20DepositDatum from './cde-erc20-deposit.js';
import processErc6551RegistryDatum from './cde-erc6551-registry.js';
import processGenericDatum from './cde-generic.js';
import type { SQLUpdate } from '@paima/db';
import { getSpecificCdeBlockheight } from '@paima/db';
import assertNever from 'assert-never';
Expand Down
4 changes: 2 additions & 2 deletions packages/engine/paima-standalone/src/sm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { GameStateMachine } from '@paima/runtime';
import PaimaSM from '@paima/sm';
import { importGameStateTransitionRouter } from './utils/import';
import { poolConfig } from './utils';
import { importGameStateTransitionRouter } from './utils/import.js';
import { poolConfig } from './utils/index.js';
import { ENV } from '@paima/utils';

export const gameSM = (): GameStateMachine => {
Expand Down
4 changes: 2 additions & 2 deletions packages/engine/paima-standalone/src/utils/file.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { doLog } from '@paima/utils';
import fs from 'fs';
import path from 'path';
import { API_FILENAME, ROUTER_FILENAME } from './import';
import type { Template } from './types';
import { API_FILENAME, ROUTER_FILENAME } from './import.js';
import type { Template } from './types.js';

export const PACKAGED_TEMPLATES_PATH = `${__dirname}/templates`;
const PACKAGED_BATCHER_PATH = `${__dirname}/batcher`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// eslint-disable-next-line require-extensions/require-extensions -- https://github.com/solana-labs/eslint-plugin-require-extensions/issues/11
import * as buildScript from './middleware-esbuildconfig.template.cjs';
export default buildScript;
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// eslint-disable-next-line require-extensions/require-extensions -- https://github.com/solana-labs/eslint-plugin-require-extensions/issues/11
import * as buildScript from './standalone-esbuildconfig.template.cjs';
export default buildScript;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from '@jest/globals';
import { PaimaParser, PaimaParserError } from '../src/PaimaParser';
import { PaimaParser, PaimaParserError } from '../src/PaimaParser.js';

const myGrammar = `
arrayCommand = a|array?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from '@jest/globals';
import { PaimaParser, PaimaParserError } from '../src/PaimaParser';
import { PaimaParser, PaimaParserError } from '../src/PaimaParser.js';

const myGrammar = `
join = @j|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from '@jest/globals';
import { PaimaParser, PaimaParserError } from '../src/PaimaParser';
import { PaimaParser, PaimaParserError } from '../src/PaimaParser.js';

const myGrammar = `
join = j|base64
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from '@jest/globals';
import { PaimaParser } from '../src/PaimaParser';
import { PaimaParser } from '../src/PaimaParser.js';

const myGrammar = `
createdLobby = c|numOfRounds|roundLength|playTimePerPlayer|isHidden?|isPractice?|playerOneIsWhite?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from '@jest/globals';
import { PaimaParser, PaimaParserError } from '../src/PaimaParser';
import { PaimaParser, PaimaParserError } from '../src/PaimaParser.js';

const myGrammar = `
join = j|x|number?|number_?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from '@jest/globals';
import { PaimaParser, PaimaParserError } from '../src/PaimaParser';
import { PaimaParser, PaimaParserError } from '../src/PaimaParser.js';

const myGrammar = `
join = j|
Expand Down
2 changes: 1 addition & 1 deletion packages/paima-sdk/paima-concise/test/paima-parser.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from '@jest/globals';
import { PaimaParser, PaimaParserError } from '../src/PaimaParser';
import { PaimaParser, PaimaParserError } from '../src/PaimaParser.js';

const myGrammar = `
createLobby = c|numOfRounds|roundLength|isHidden?|isPractice?
Expand Down
2 changes: 1 addition & 1 deletion packages/paima-sdk/paima-crypto/src/algorand.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SignedTransaction, Transaction, SuggestedParams } from 'algosdk';
import { doLog, hexStringToUint8Array } from '@paima/utils';
import web3UtilsPkg from 'web3-utils';
import type { IVerify } from './IVerify';
import type { IVerify } from './IVerify.js';

export class AlgorandCrypto implements IVerify {
verifyAddress = async (address: string): Promise<boolean> => {
Expand Down
2 changes: 1 addition & 1 deletion packages/paima-sdk/paima-crypto/src/cardano.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { doLog } from '@paima/utils';
import type { IVerify } from './IVerify';
import type { IVerify } from './IVerify.js';

export class CardanoCrypto implements IVerify {
verifyAddress = async (address: string): Promise<boolean> => {
Expand Down
Loading