fix: 🚨 Add error in TS for missing awaits (#81)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Documentation**
- Added detailed IDE configuration recommendations for Rust, Solidity,
and TypeScript in the README to enhance developer experience.

- **Chores**
- Updated Biome configuration files and package dependencies to the
latest schema and version.
- Refined code formatting, linting, and import organization settings for
consistency across the project.

- **Refactor**
- Reordered import statements in multiple files for improved
readability.
- Simplified function signatures and ensured proper async handling in
utility scripts.

- **Bug Fixes**
- Ensured proper completion of asynchronous operations in shell utility
functions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Gonza Montiel <gonzamontiel@users.noreply.github.com>
This commit is contained in:
Facundo Farall 2025-05-19 19:28:43 -03:00 committed by GitHub
parent fea69ead32
commit 4c7a64fc39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 141 additions and 60 deletions

View file

@ -50,6 +50,75 @@ To run a docker image locally (`moonsonglabs/datahaven:local`), from the `/test`
bun build:docker:operator
```
## Working with IDEs
### VS Code (and its forks)
IDE configurations are ignored from this repo's version control, to allow for personalisation. However, there are a few key configurations that we suggest for a better experience. Here are the key suggested configurations to add to your `.vscode/settings.json` file:
#### Rust
```json
{
"rust-analyzer.linkedProjects": ["./operator/Cargo.toml"],
"rust-analyzer.cargo.allTargets": true,
"rust-analyzer.procMacro.enable": false,
"rust-analyzer.server.extraEnv": {
"CARGO_TARGET_DIR": "target/.rust-analyzer",
"SKIP_WASM_BUILD": 1
},
"rust-analyzer.diagnostics.disabled": ["unresolved-macro-call"],
"rust-analyzer.cargo.buildScripts.enable": false
}
```
These settings optimise Rust Analyzer for the DataHaven codebase:
- Marks the `operator/` folder as a linked project for analysis. The root of this repo is a workspace, and this is the rust project that should be analysed by `rust-analyzer`.
- Disables proc macros and build scripts to improve performance. Otherwise, Substrate's proc macros will make iterative checks from `rust-analyzer` unbearably slow.
- Sets a dedicated target directory for Rust Analyzer to avoid conflicts with other build targets like `release` builds.
- Disables WASM builds during analysis for faster feedback.
#### Solidity
For [Juan Blanco's Solidity Extension](https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity), add the following to your `.vscode/settings.json` file:
```json
{
"solidity.formatter": "forge",
"solidity.compileUsingRemoteVersion": "v0.8.28+commit.7893614a",
"[solidity]": {
"editor.defaultFormatter": "JuanBlanco.solidity"
}
}
```
These settings configure Solidity support:
- Uses Forge as the formatter for consistency with the project's tooling.
- Sets a specific Solidity version for compilation. This one should match the version used in [foundry.toml](./contracts/foundry.toml).
- Sets the Solidity extension as the default formatter.
#### Typescript
This repo uses [Biome](https://github.com/biomejs/biome) for TypeScript linting and formatting. Bare in mind, that as of writing, it needs to be the pre-release version of the extension, that supports setting an inner folder as the project root. To make the extension work nicely with this repo, add the following to your `.vscode/settings.json` file:
```json
{
"biome.projects": [{ "path": "test/" }],
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.codeActionsOnSave": {
"source.organizeImports.biome": "always"
}
}
}
```
- Sets up Biome for JavaScript/TypeScript formatting in the test directory.
- Sets Biome as the default formatter for TypeScript.
- Sets Biome to always organise imports on save.
## CI
Using the [act](https://github.com/nektos/act) binary, you can run GitHub Actions locally.

View file

@ -1,22 +1,27 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.0-beta.5/schema.json",
"files": {
"include": ["*.js", "*.ts", "*.json", "*.yml", "*.md"],
"ignore": [
"./node_modules/*",
"./target/*",
"**/tmp/*",
"*.spec.json",
"**/.papi/descriptors/**/*",
"**/contract-bindings/**/*"
"includes": [
"**/*.js",
"**/*.ts",
"**/*.json",
"**/*.yml",
"**/*.md",
"!node_modules/*",
"!target/*",
"!**/tmp/*",
"!**/*.spec.json",
"!**/.papi/descriptors/**/*",
"!**/contract-bindings/**/*"
]
},
"organizeImports": {
"enabled": true
},
"assist": { "actions": { "source": { "organizeImports": "on" } } },
"formatter": {
"enabled": true,
"attributePosition": "multiline"
"attributePosition": "multiline",
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100
},
"json": {
"formatter": {
@ -27,9 +32,6 @@
"formatter": {
"trailingCommas": "none",
"semicolons": "always",
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100,
"quoteStyle": "double"
}
},
@ -47,6 +49,21 @@
},
"performance": {
"noAccumulatingSpread": "off"
},
"nursery": {
"noFloatingPromises": "error"
},
"style": {
"noParameterAssign": "error",
"useAsConstAssertion": "error",
"useDefaultParameterLast": "error",
"useEnumInitializers": "error",
"useSelfClosingElements": "error",
"useSingleVarDeclarator": "error",
"noUnusedTemplateLiteral": "error",
"useNumberNamespace": "error",
"noInferrableTypes": "error",
"noUselessElse": "error"
}
}
}

View file

@ -1,4 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.0-beta.5/schema.json",
"extends": ["../biome.json"]
}

View file

@ -4,7 +4,7 @@
"": {
"name": "@datahaven/e2e-test",
"dependencies": {
"@biomejs/biome": "^1.9.4",
"@biomejs/biome": "^2.0.0-beta.5",
"@commander-js/extra-typings": "^13.1.0",
"@dotenvx/dotenvx": "^1.41.0",
"@inquirer/prompts": "^7.5.0",
@ -59,23 +59,23 @@
"@balena/dockerignore": ["@balena/dockerignore@1.0.2", "", {}, "sha512-wMue2Sy4GAVTk6Ic4tJVcnfdau+gx2EnG7S+uAEe+TWJFqE4YoWN4/H8MSLj4eYJKxGg26lZwboEniNiNwZQ6Q=="],
"@biomejs/biome": ["@biomejs/biome@1.9.4", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "1.9.4", "@biomejs/cli-darwin-x64": "1.9.4", "@biomejs/cli-linux-arm64": "1.9.4", "@biomejs/cli-linux-arm64-musl": "1.9.4", "@biomejs/cli-linux-x64": "1.9.4", "@biomejs/cli-linux-x64-musl": "1.9.4", "@biomejs/cli-win32-arm64": "1.9.4", "@biomejs/cli-win32-x64": "1.9.4" }, "bin": { "biome": "bin/biome" } }, "sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog=="],
"@biomejs/biome": ["@biomejs/biome@2.0.0-beta.5", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.0.0-beta.5", "@biomejs/cli-darwin-x64": "2.0.0-beta.5", "@biomejs/cli-linux-arm64": "2.0.0-beta.5", "@biomejs/cli-linux-arm64-musl": "2.0.0-beta.5", "@biomejs/cli-linux-x64": "2.0.0-beta.5", "@biomejs/cli-linux-x64-musl": "2.0.0-beta.5", "@biomejs/cli-win32-arm64": "2.0.0-beta.5", "@biomejs/cli-win32-x64": "2.0.0-beta.5" }, "bin": { "biome": "bin/biome" } }, "sha512-1ldO4AepieVvg4aLi1ubZkA7NsefQT2UTNssbJbDiQTGem8kCHx/PZCwLxIR6UzFpGIjh0xsDzivyVvhnmqmuA=="],
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@1.9.4", "", { "os": "darwin", "cpu": "arm64" }, "sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw=="],
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.0.0-beta.5", "", { "os": "darwin", "cpu": "arm64" }, "sha512-pnJiaoDpwGo+ctGkMu4POcO8jgOgCErBdYbhutr+K9rxxJS+TlHLr0LR91GCEWbGV2O1oyZRFQcW21rYFoak4w=="],
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@1.9.4", "", { "os": "darwin", "cpu": "x64" }, "sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg=="],
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.0.0-beta.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-WwEZpqcmsNoFpZkUFNQcbZo52WK4hLGQ0vZk3PQ8JlZ55gJsHiyhtv6aem6fVlyVCvZgpsC0sYPLE3VvFVKNAQ=="],
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@1.9.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g=="],
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.0.0-beta.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-lAF1de+Ki0vnq14NwDXouKkAR/iviyMNrUngSHjTGFC4z8XGVEfIw0ZMSm7fAdJZ5fAWodt9HiYmEAVs5EtHQg=="],
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@1.9.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA=="],
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.0.0-beta.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-4vxNkYx1uEt211W8hLdXddc7icRHQgYENb72g6uTd/tLVPSBvIwqUAxAOkU+9Ai1E/8R4sWy7HIxREgpuFgbNA=="],
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@1.9.4", "", { "os": "linux", "cpu": "x64" }, "sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg=="],
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.0.0-beta.5", "", { "os": "linux", "cpu": "x64" }, "sha512-I0Pt1VHeL1mN8G7ZwV2u9AfzBd5ZKfbvHUI4x2wETUZbwcQlAu/nEzEa2LUe5HqSmnctTR36ig7RkkM9qbmIrA=="],
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@1.9.4", "", { "os": "linux", "cpu": "x64" }, "sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg=="],
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.0.0-beta.5", "", { "os": "linux", "cpu": "x64" }, "sha512-nUeKGO517GtRCxziVD9les1HiCs2s2/WIVITMN9+9RRuLOko8r+T77E8ZXEmlfLOfOIOeE6z62WITqei3oNccA=="],
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@1.9.4", "", { "os": "win32", "cpu": "arm64" }, "sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg=="],
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.0.0-beta.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-YXW6hgbrgBcWQ1SLO69ypWlluPchgQV5C1lTG4xOcBUWdCsfYuQirM64S6Dov7SFPqsMIoFC6LlQRW+n8qAyiA=="],
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@1.9.4", "", { "os": "win32", "cpu": "x64" }, "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA=="],
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.0.0-beta.5", "", { "os": "win32", "cpu": "x64" }, "sha512-N7Yby52BJmvEdst1iMbclE5hxxefboaXKRJLm1tLfBYr4FeuoCe6j8HdiQSwhCRdIUGFFqBLaDXh//LLF6EReA=="],
"@coinbase/wallet-sdk": ["@coinbase/wallet-sdk@4.3.0", "", { "dependencies": { "@noble/hashes": "^1.4.0", "clsx": "^1.2.1", "eventemitter3": "^5.0.1", "preact": "^10.24.2" } }, "sha512-T3+SNmiCw4HzDm4we9wCHCxlP0pqCiwKe4sOwPH3YAK2KSKjxPRydKu6UQJrdONFVLG7ujXvbd/6ZqmvJb8rkw=="],

View file

@ -3,7 +3,7 @@ import path from "node:path";
import { secp256k1 } from "@noble/curves/secp256k1";
import { datahaven } from "@polkadot-api/descriptors";
import { $ } from "bun";
import { type PolkadotClient, createClient } from "polkadot-api";
import { createClient, type PolkadotClient } from "polkadot-api";
import { withPolkadotSdkCompat } from "polkadot-api/polkadot-sdk-compat";
import { getWsProvider } from "polkadot-api/ws-provider/web";
import { cargoCrossbuild } from "scripts/cargo-crossbuild";

View file

@ -52,7 +52,7 @@ const launchFunction = async (options: LaunchOptions, launchedNetwork: LaunchedN
await launchKurtosis(launchedNetwork, options);
logger.trace("Deploy contracts using the extracted function");
let blockscoutBackendUrl: string | undefined = undefined;
let blockscoutBackendUrl: string | undefined;
if (options.blockscout === true) {
const blockscoutPublicPort = await getPortFromKurtosis("blockscout", "http");

View file

@ -1,6 +1,6 @@
import fs from "node:fs";
import invariant from "tiny-invariant";
import { type RelayerType, logger } from "utils";
import { logger, type RelayerType } from "utils";
type PipeOptions = number | "inherit" | "pipe" | "ignore";
type BunProcess = Bun.Subprocess<PipeOptions, PipeOptions, PipeOptions>;

View file

@ -1,14 +1,12 @@
import path from "node:path";
import { datahaven } from "@polkadot-api/descriptors";
import { $ } from "bun";
import { type PolkadotClient, createClient } from "polkadot-api";
import { createClient, type PolkadotClient } from "polkadot-api";
import { withPolkadotSdkCompat } from "polkadot-api/polkadot-sdk-compat";
import { getWsProvider } from "polkadot-api/ws-provider/web";
import invariant from "tiny-invariant";
import {
ANVIL_FUNDED_ACCOUNTS,
type RelayerType,
SUBSTRATE_FUNDED_ACCOUNTS,
confirmWithTimeout,
getEvmEcdsaSigner,
getPortFromKurtosis,
@ -18,7 +16,9 @@ import {
parseRelayConfig,
printDivider,
printHeader,
type RelayerType,
runShellCommandWithLogger,
SUBSTRATE_FUNDED_ACCOUNTS,
waitForContainerToStart
} from "utils";
import type { BeaconCheckpoint, FinalityCheckpointsResponse } from "utils/types";

View file

@ -36,7 +36,7 @@
"typescript": "^5.8.3"
},
"dependencies": {
"@biomejs/biome": "^1.9.4",
"@biomejs/biome": "^2.0.0-beta.5",
"@commander-js/extra-typings": "^13.1.0",
"@dotenvx/dotenvx": "^1.41.0",
"@inquirer/prompts": "^7.5.0",

View file

@ -10,9 +10,7 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const RUNTIME_FEATURES = ["fast-runtime"];
export const cargoCrossbuild = async (options: {
datahavenBuildExtraArgs?: string;
}) => {
export const cargoCrossbuild = async (options: { datahavenBuildExtraArgs?: string }) => {
logger.info("🔀 Cross-building DataHaven node for Linux AMD64");
const ARCH = (await $`uname -m`.text()).trim();
@ -30,7 +28,7 @@ export const cargoCrossbuild = async (options: {
throw new Error("Zig is not installed");
}
installCargoZigbuild();
await installCargoZigbuild();
const target = "x86_64-unknown-linux-gnu";
await addRustupTarget(target);

View file

@ -1,13 +1,11 @@
import { generateRandomAccount, getEvmEcdsaSigner, logger, printDivider, printHeader } from "utils";
import { http, createWalletClient, defineChain, parseEther, publicActions } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { datahaven } from "@polkadot-api/descriptors";
import { Binary } from "@polkadot-api/substrate-bindings";
import { createClient } from "polkadot-api";
import { withPolkadotSdkCompat } from "polkadot-api/polkadot-sdk-compat";
import { getWsProvider } from "polkadot-api/ws-provider/web";
import { generateRandomAccount, getEvmEcdsaSigner, logger, printDivider, printHeader } from "utils";
import { createWalletClient, defineChain, http, parseEther, publicActions } from "viem";
import { privateKeyToAccount } from "viem/accounts";
export const sendEthTxn = async (privateKey: string, networkRpcUrl: string) => {
printHeader("Sending Test ETH Transaction");

View file

@ -1,10 +1,10 @@
import { beforeAll, describe, expect, it } from "bun:test";
import {
ANVIL_FUNDED_ACCOUNTS,
type ViemClientInterface,
createDefaultClient,
generateRandomAccount,
logger
logger,
type ViemClientInterface
} from "utils";
import { parseEther } from "viem";

View file

@ -3,11 +3,11 @@ import { beefyClientAbi } from "contract-bindings";
import {
type AnvilDeployments,
type ContractInstance,
type ViemClientInterface,
createDefaultClient,
getContractInstance,
logger,
parseDeploymentsFile
parseDeploymentsFile,
type ViemClientInterface
} from "utils";
import { isAddress } from "viem";

View file

@ -1,12 +1,12 @@
import { beforeAll, describe, expect, it } from "bun:test";
import type { PolkadotSigner } from "polkadot-api";
import {
type DataHavenApi,
SUBSTRATE_FUNDED_ACCOUNTS,
createPapiConnectors,
type DataHavenApi,
generateRandomAccount,
getPapiSigner,
logger
logger,
SUBSTRATE_FUNDED_ACCOUNTS
} from "utils";
import { isAddress, parseEther } from "viem";

View file

@ -1,10 +1,9 @@
import * as generated from "contract-bindings";
import invariant from "tiny-invariant";
import { type Abi, erc20Abi, getContract, isAddress } from "viem";
import { z } from "zod";
import { logger } from "./logger";
import { type ViemClientInterface, createDefaultClient } from "./viem";
import invariant from "tiny-invariant";
import { createDefaultClient, type ViemClientInterface } from "./viem";
const ethAddressRegex = /^0x[a-fA-F0-9]{40}$/;
const ethAddress = z.string().regex(ethAddressRegex, "Invalid Ethereum address");

View file

@ -1,7 +1,7 @@
import { type Duplex, PassThrough, Transform } from "node:stream";
import Docker from "dockerode";
import invariant from "tiny-invariant";
import { type ServiceInfo, StandardServiceMappings, logger } from "utils";
import { logger, type ServiceInfo, StandardServiceMappings } from "utils";
const docker = new Docker({});

View file

@ -1,9 +1,9 @@
import {
type Status,
type Theme,
createPrompt,
isEnterKey,
makeTheme,
type Status,
type Theme,
useEffect,
useKeypress,
usePrefix,

View file

@ -1,9 +1,9 @@
import { secp256k1 } from "@noble/curves/secp256k1";
import { keccak_256 } from "@noble/hashes/sha3";
import { datahaven } from "@polkadot-api/descriptors";
import { type PolkadotClient, type TypedApi, createClient } from "polkadot-api";
import { createClient, type PolkadotClient, type TypedApi } from "polkadot-api";
import { withPolkadotSdkCompat } from "polkadot-api/polkadot-sdk-compat";
import { type PolkadotSigner, getPolkadotSigner } from "polkadot-api/signer";
import { getPolkadotSigner, type PolkadotSigner } from "polkadot-api/signer";
import { getWsProvider } from "polkadot-api/ws-provider/web";
import { SUBSTRATE_FUNDED_ACCOUNTS } from "./constants";
import type { Prettify } from "./types";

View file

@ -58,7 +58,7 @@ export const runShellCommandWithLogger = async (
}
};
Promise.all([
await Promise.all([
readStream(stdoutReader, "stdout", logLevel),
readStream(stderrReader, "stderr", "error")
]);

View file

@ -1,5 +1,5 @@
import { ANVIL_FUNDED_ACCOUNTS, CHAIN_ID, getRPCUrl, getWSUrl } from "utils";
import { http, createWalletClient, defineChain, publicActions } from "viem";
import { createWalletClient, defineChain, http, publicActions } from "viem";
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
import type { Prettify } from "./types";