From 143ae314152988254d0bddcb9d99b54af9cfdbba Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 08:39:03 +0100 Subject: [PATCH 01/89] Removed documentation reference to the built-in binaries --- README.md | 2 - apps/docs/.vitepress/config.ts | 4 -- apps/docs/src/getting-started.md | 17 +------ apps/docs/src/guide/fuels/binaries.md | 56 ------------------------ apps/docs/src/guide/fuels/commands.md | 28 +++--------- apps/docs/src/guide/fuels/config-file.md | 28 ------------ apps/docs/src/guide/fuels/index.md | 4 ++ apps/docs/src/index.md | 6 +-- 8 files changed, 13 insertions(+), 132 deletions(-) delete mode 100644 apps/docs/src/guide/fuels/binaries.md diff --git a/README.md b/README.md index 6848fe39462..7bfb60b7a84 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,6 @@ Commands: deploy [options] Deploy contracts to the Fuel network typegen [options] Generate Typescript from Sway ABI JSON files versions Check for version incompatibilities - core Wrapper around Fuel Core binary - forc Wrapper around Forc binary help [command] Display help for command ``` diff --git a/apps/docs/.vitepress/config.ts b/apps/docs/.vitepress/config.ts index b5e66728784..33ad2cbf184 100644 --- a/apps/docs/.vitepress/config.ts +++ b/apps/docs/.vitepress/config.ts @@ -468,10 +468,6 @@ export default defineConfig({ text: 'Commands', link: '/guide/fuels/commands', }, - { - text: 'Binaries', - link: '/guide/fuels/binaries', - }, ], }, ], diff --git a/apps/docs/src/getting-started.md b/apps/docs/src/getting-started.md index 793b68a7f64..9cbc68b9bbc 100644 --- a/apps/docs/src/getting-started.md +++ b/apps/docs/src/getting-started.md @@ -27,21 +27,6 @@ pnpm add fuels ::: -### Note - -If you are using bun, you'll need to add a `trustedDependencies` field to your `package.json`: - -```json -{ - // ... - "trustedDependencies": ["@fuel-ts/fuel-core", "@fuel-ts/forc"] -} -``` - -This is to ensure that bun includes the `fuel-core` and `forc` binaries in your project. - -> IMPORTANT: We don't officially support `bun` yet; use it at your own risk. - ## Usage With the Fuels dependency set up, you can now create a React component that will connect to the Fuel provider and retrieve the base asset balance for a given wallet address. Here's an example of how to do this: @@ -130,7 +115,7 @@ In the example below, we connect a [Provider](./guide/provider/index.md) to the Firstly, you will need a local node running on your machine. We recommend one of the following methods: - [Testing utilities](./guide/testing/index.md#wallet-test-utilities) can assist in programmatically launching a short-lived node. -- Running [fuel-core](https://docs.fuel.network/guides/running-a-node/running-a-local-node/) directly, or via the CLI [fuels](./guide/fuels/commands.md#fuels-core). +- Running [fuel-core](https://docs.fuel.network/guides/running-a-node/running-a-local-node/) directly. In the following example, we create a provider to connect to the local node and sign a message. diff --git a/apps/docs/src/guide/fuels/binaries.md b/apps/docs/src/guide/fuels/binaries.md deleted file mode 100644 index b7fa0f07d26..00000000000 --- a/apps/docs/src/guide/fuels/binaries.md +++ /dev/null @@ -1,56 +0,0 @@ -# Built-In Binaries - -`fuels` conveniently ships with `built-in` binaries for [`forc`](https://docs.fuel.network/docs/forc/commands/) and [`fuel-core`](https://docs.fuel.network/guides/running-a-node/running-a-local-node/). - -In case you haven't installed [The Fuel Toolchain](#the-fuel-toolchain) _yet_, these will be used. - -Here's how to configure this explicitly: - -- [`useBuiltinForc`](./config-file.md#usebuiltinforc): `true` -- [`useBuiltinFuelCore`](./config-file.md#usebuiltinfuelcore): `true` - -<<< @../../../demo-fuels/fuels.config.explicit-built-in.ts#config-built-in{ts:line-numbers} - -You can also call the `built-in` binaries directly: - -```console -npx fuels help forc -npx fuels forc --version -npx fuels forc test -h -``` - -```console -npx fuels help core -npx fuels core --version -npx fuels core run -h -``` - -Check the docs for `forc` and `fuel-core`: - -- [Forc Commands](https://docs.fuel.network/docs/forc/commands/) -- [Running a local Node using `fuel-core`](https://docs.fuel.network/guides/running-a-node/running-a-local-node/) - -## The Fuel Toolchain - -The Fuel Toolchain consists of several [components](https://docs.fuel.network/docs/sway/introduction/fuel_toolchain/). - -You can use [`fuel-up`](https://docs.fuel.network/docs/fuelup/installation/) to get it up and running. - -Check if it's working correctly with: - -```console -forc --version -``` - -```console -fuel-core --version -``` - -The `forc` and `fuel-core` binaries will be available in your `system` and `fuels` automatically prioritize them instead of the `built-in` ones. - -Here's how to configure this explicitly: - -- [`useBuiltinForc`](./config-file.md#usebuiltinforc): `false` -- [`useBuiltinFuelCore`](./config-file.md#usebuiltinfuelcore): `false` - -<<< @../../../demo-fuels/fuels.config.explicit-system.ts#config-system{ts:line-numbers} diff --git a/apps/docs/src/guide/fuels/commands.md b/apps/docs/src/guide/fuels/commands.md index 8a2bc50a288..332277ddbed 100644 --- a/apps/docs/src/guide/fuels/commands.md +++ b/apps/docs/src/guide/fuels/commands.md @@ -1,6 +1,6 @@ # Commands -The `fuels` CLI consists of a couple commands. +The `fuels` CLI consists of a couple of commands. ## `fuels init` @@ -67,8 +67,8 @@ Examples: npx fuels build ``` -1. Build all Sway programs under your `workspace` using `forc` [1](#commands-for-wrapped-utiltities) -1. Generate types for them using `fuels-typegen` [2](#typegen) +1. Build all Sway programs under your `workspace` using `forc` [1](https://docs.fuel.network/docs/forc/commands/forc_build/) +1. Generate types for them using `fuels-typegen` [2](#fuels-typegen) ```console npx fuels build --deploy @@ -116,7 +116,7 @@ The `fuels dev` command do three things: 1. Auto-start a short-lived `fuel-core` node ([docs](./config-file.md#autostartfuelcore)) 1. Runs `build` and `deploy` once at the start -1. Watches your Forc workspace and repeats previous step on every change +1. Watches your Forc workspace and repeats the previous step on every change > _In `dev` mode, everytime you update a contract on your Forc `workspace`, we re-generate type definitions and factory classes for it, following your pre-configured [`output`](./config-file.md#output) directory. If it's part of another build system running in dev mode (i.e. `next dev`), you can expect it to re-build / auto-reload as well._ @@ -144,7 +144,7 @@ For more info, check: ## `fuels versions` -Check for version incompatibilities between your [Fuel Toolchain](#the-fuel-toolchain) component versions, matching them against the ones supported by the Typescript SDK version that you have. +Check for version incompatibilities between your [Fuel Toolchain](https://docs.fuel.network/docs/sway/introduction/fuel_toolchain/#the-fuel-toolchain) component versions, matching them against the ones supported by the Typescript SDK version that you have. ```console npx fuels versions @@ -160,21 +160,3 @@ You have all the right versions! ⚡ │ Fuel-Core │ 0.14.0 │ 0.14.0 │ └───────────┴───────────┴─────────────────┘ ``` - -## `fuels forc` - -Simple [wrapper](./binaries.md) around the `forc` binary. - -Check also: - -- [Built-in Binaries](./binaries.md) -- [`forc` documentation](https://docs.fuel.network/docs/forc/commands/) - -## `fuels core` - -Simple [wrapper](./binaries.md) around the `fuel-core` binary. - -Check also: - -- [Built-in Binaries](./binaries.md) -- [`fuel-core` documentation](https://docs.fuel.network/guides/running-a-node/running-a-local-node/) diff --git a/apps/docs/src/guide/fuels/config-file.md b/apps/docs/src/guide/fuels/config-file.md index 99adcd4b380..073e1ece164 100644 --- a/apps/docs/src/guide/fuels/config-file.md +++ b/apps/docs/src/guide/fuels/config-file.md @@ -139,34 +139,6 @@ Parameters: <<< @../../../demo-fuels/fuels.config.full.ts#onFailure{ts:line-numbers} -## `useBuiltinForc` - -Opt-in or out from using [built-in](./binaries.md) `forc` binaries. - -When not supplied, will default to using the `system` binaries. - -If `system` binaries are absent, print a warning and use `built-in` ones instead. - -<<< @../../../demo-fuels/fuels.config.full.ts#useBuiltInForc{ts:line-numbers} - -Check also: - -- [Built-in Binaries](./binaries.md) - -## `useBuiltinFuelCore` - -Opt-in or out from using [built-in](./binaries.md) `fuel-core` binaries. - -When not supplied, will default to using the `system` binaries. - -If `system` binaries are absent, print a warning and use `built-in` ones instead. - -<<< @../../../demo-fuels/fuels.config.full.ts#useBuiltInFuelCore{ts:line-numbers} - -Check also: - -- [Built-in Binaries](./binaries.md) - ## Loading environment variables If you want to load environment variables from a `.env` file, you can use the `dotenv` package. diff --git a/apps/docs/src/guide/fuels/index.md b/apps/docs/src/guide/fuels/index.md index 96e09c32b4d..4e92e4b81e6 100644 --- a/apps/docs/src/guide/fuels/index.md +++ b/apps/docs/src/guide/fuels/index.md @@ -26,6 +26,10 @@ my-fuel-dapp # NextJS app or similar └── package.json ``` +## Prerequisites + +We expect you to install the [Fuel Toolchain](https://docs.fuel.network/docs/sway/introduction/fuel_toolchain/#the-fuel-toolchain) before using this library. Follow [this guide](https://docs.fuel.network/guides/installation/) to get this installed. + ## Installation Add it to your `my-fuel-dapp` project: diff --git a/apps/docs/src/index.md b/apps/docs/src/index.md index 2b1fbced0eb..fb6100df733 100644 --- a/apps/docs/src/index.md +++ b/apps/docs/src/index.md @@ -11,11 +11,11 @@ This doc was generated using Fuels `v{{fuels}}`, Fuel Core `v{{fuelCore}}`, Sway ## Installation Guide -Please visit the Fuel's [installation guide](https://docs.fuel.network/guides/installation) to install The Fuel toolchain binaries and pre requisites. +Please visit the Fuel's [installation guide](https://docs.fuel.network/guides/installation) to install The Fuel toolchain binaries and prerequisites. ## Developer Quickstart Guide -We recommend starting with the [Developer Quickstart](https://docs.fuel.network/docs/intro/quickstart-contract/) for a walk through on building your first DApp on Fuel. +We recommend starting with the [Developer Quickstart](https://docs.fuel.network/docs/intro/quickstart-contract/) for a walk-through on building your first DApp on Fuel. - [Guide](./guide/) - [Sample Application](https://github.com/FuelLabs/beta2-quickstart) @@ -29,7 +29,7 @@ Learn more about the Fuel Ecosystem. - 🧰 Forc the Fuel toolbox. Build, deploy and manage your sway projects. - [⚙️ Fuel Core](https://github.com/FuelLabs/fuel-core) the new FuelVM, a blazingly fast blockchain VM. - [🔗 Fuel Specs](https://github.com/FuelLabs/fuel-specs) the Fuel protocol specifications. -- [🦀 RUST SDK](https://github.com/FuelLabs/fuels-rs) a robust SDK in rust. +- [🦀 RUST SDK](https://github.com/FuelLabs/fuels-rs) a robust SDK in Rust. - [⚡ Fuel Network](https://fuel.network/) the project. ## Install From 9e86b74d10778eb0dc47e5428ea54aacd7cebf9a Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 08:41:57 +0100 Subject: [PATCH 02/89] Update versions on documentation --- apps/docs/src/guide/fuels/commands.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/docs/src/guide/fuels/commands.md b/apps/docs/src/guide/fuels/commands.md index 332277ddbed..ca501064739 100644 --- a/apps/docs/src/guide/fuels/commands.md +++ b/apps/docs/src/guide/fuels/commands.md @@ -155,8 +155,8 @@ You have all the right versions! ⚡ ┌───────────┬───────────┬─────────────────┐ │ │ Supported │ Yours / System │ ├───────────┼───────────┼─────────────────┤ -│ Forc │ 0.30.0 │ 0.30.0 │ +│ Forc │ 0.49.3 │ 0.49.3 │ ├───────────┼───────────┼─────────────────┤ -│ Fuel-Core │ 0.14.0 │ 0.14.0 │ +│ Fuel-Core │ 0.22.1 │ 0.22.1 │ └───────────┴───────────┴─────────────────┘ ``` From 00210a64579c31d6244313e9185253daeaabe15c Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 08:43:22 +0100 Subject: [PATCH 03/89] Changeset --- .changeset/friendly-deers-glow.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .changeset/friendly-deers-glow.md diff --git a/.changeset/friendly-deers-glow.md b/.changeset/friendly-deers-glow.md new file mode 100644 index 00000000000..f6e7215adc0 --- /dev/null +++ b/.changeset/friendly-deers-glow.md @@ -0,0 +1,4 @@ +--- +--- + +docs: Un-documented built-in binaries \ No newline at end of file From 8940ff95e3f16a9d450d3d8aaab4a41a64ded447 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 17:50:00 +0100 Subject: [PATCH 04/89] Removed unused configs --- apps/demo-fuels/fuels.config.explicit-built-in.ts | 10 ---------- apps/demo-fuels/fuels.config.explicit-system.ts | 10 ---------- 2 files changed, 20 deletions(-) delete mode 100644 apps/demo-fuels/fuels.config.explicit-built-in.ts delete mode 100644 apps/demo-fuels/fuels.config.explicit-system.ts diff --git a/apps/demo-fuels/fuels.config.explicit-built-in.ts b/apps/demo-fuels/fuels.config.explicit-built-in.ts deleted file mode 100644 index 8c0cc48b73e..00000000000 --- a/apps/demo-fuels/fuels.config.explicit-built-in.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { createConfig } from 'fuels'; - -// #region config-built-in -export default createConfig({ - workspace: './sway-programs', - output: './src/sway-programs-api', - useBuiltinForc: true, - useBuiltinFuelCore: true, -}); -// #endregion config-built-in diff --git a/apps/demo-fuels/fuels.config.explicit-system.ts b/apps/demo-fuels/fuels.config.explicit-system.ts deleted file mode 100644 index 12294eeadf5..00000000000 --- a/apps/demo-fuels/fuels.config.explicit-system.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { createConfig } from 'fuels'; - -// #region config-system -export default createConfig({ - workspace: './sway-programs', - output: './src/sway-programs-api', - useBuiltinForc: false, - useBuiltinFuelCore: false, -}); -// #endregion config-system From 61e00499d61611b4450f0bac9e90adfa6321b629 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 18:56:33 +0100 Subject: [PATCH 05/89] Removed `forc` and `core` from CLI + configuration --- apps/demo-fuels/fuels.config.full.ts | 12 +--- packages/fuels/src/cli.test.ts | 6 -- packages/fuels/src/cli.ts | 15 ----- .../cli/commands/build/buildSwayProgram.ts | 5 +- .../cli/commands/build/buildSwayPrograms.ts | 3 +- .../src/cli/commands/dev/autoStartFuelCore.ts | 5 +- packages/fuels/src/cli/commands/init/index.ts | 4 +- .../init/shouldUseBuiltinForc.test.ts | 59 ------------------- .../cli/commands/init/shouldUseBuiltinForc.ts | 12 ---- .../init/shouldUseBuiltinFuelCore.test.ts | 49 --------------- .../commands/init/shouldUseBuiltinFuelCore.ts | 12 ---- .../fuels/src/cli/config/loadConfig.test.ts | 26 -------- packages/fuels/src/cli/config/loadConfig.ts | 7 --- .../fuels/src/cli/templates/fuels.config.hbs | 6 -- .../fuels/src/cli/templates/fuels.config.ts | 2 - packages/fuels/src/cli/types.ts | 8 --- packages/fuels/test/features/init.test.ts | 4 -- packages/fuels/test/fixtures/fuels.config.ts | 2 - packages/fuels/test/utils/runCommands.ts | 3 - 19 files changed, 6 insertions(+), 234 deletions(-) delete mode 100644 packages/fuels/src/cli/commands/init/shouldUseBuiltinForc.test.ts delete mode 100644 packages/fuels/src/cli/commands/init/shouldUseBuiltinForc.ts delete mode 100644 packages/fuels/src/cli/commands/init/shouldUseBuiltinFuelCore.test.ts delete mode 100644 packages/fuels/src/cli/commands/init/shouldUseBuiltinFuelCore.ts diff --git a/apps/demo-fuels/fuels.config.full.ts b/apps/demo-fuels/fuels.config.full.ts index 839d1588b2d..87344f433d4 100644 --- a/apps/demo-fuels/fuels.config.full.ts +++ b/apps/demo-fuels/fuels.config.full.ts @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import { createConfig } from 'fuels'; -import type { CommandEvent, ContractDeployOptions, FuelsConfig } from 'fuels/src/cli/types'; +import type { CommandEvent, ContractDeployOptions, FuelsConfig } from 'fuels'; const MY_FIRST_DEPLOYED_CONTRACT_NAME = ''; @@ -96,16 +96,6 @@ export default createConfig({ console.log('fuels:onFailure', { error, config }); }, // #endregion onFailure - - // #region useBuiltInForc - // Default: undefined - useBuiltinForc: false, - // #endregion useBuiltInForc - - // #region useBuiltInFuelCore - // Default: undefined - useBuiltinFuelCore: false, - // #endregion useBuiltInFuelCore }); export const simpleDeployConfig = createConfig({ diff --git a/packages/fuels/src/cli.test.ts b/packages/fuels/src/cli.test.ts index 37bf5bc22dd..02c5a2e6feb 100644 --- a/packages/fuels/src/cli.test.ts +++ b/packages/fuels/src/cli.test.ts @@ -36,15 +36,11 @@ describe('cli.js', () => { const dev = cmd(Commands.dev); const build = cmd(Commands.build); const deploy = cmd(Commands.deploy); - const forc = cmd('forc'); - const core = cmd('core'); expect(init).toBeTruthy(); expect(dev).toBeTruthy(); expect(build).toBeTruthy(); expect(deploy).toBeTruthy(); - expect(forc).toBeTruthy(); - expect(core).toBeTruthy(); // checking default options const path = process.cwd(); @@ -53,8 +49,6 @@ describe('cli.js', () => { expect(dev?.opts()).toEqual({ path }); expect(build?.opts()).toEqual({ path }); expect(deploy?.opts()).toEqual({ path }); - expect(forc?.opts()).toEqual({}); - expect(core?.opts()).toEqual({}); }); it('preAction should configure logging', () => { diff --git a/packages/fuels/src/cli.ts b/packages/fuels/src/cli.ts index 427fbac360f..11fb960577e 100644 --- a/packages/fuels/src/cli.ts +++ b/packages/fuels/src/cli.ts @@ -1,5 +1,4 @@ import { configureCliOptions as configureTypegenCliOptions } from '@fuel-ts/abi-typegen/cli'; -import { findBinPath } from '@fuel-ts/utils/cli-utils'; import { versions } from '@fuel-ts/versions'; import { runVersions } from '@fuel-ts/versions/cli'; import { Command, Option } from 'commander'; @@ -56,8 +55,6 @@ export const configureCli = () => { .addOption(new Option(`-s, --scripts ${arg}`, `${desc} Scripts`).conflicts('workspace')) .addOption(new Option(`-p, --predicates ${arg}`, `${desc} Predicates`).conflicts('workspace')) .requiredOption('-o, --output ', 'Relative dir path for Typescript generation output') - .option('--use-builtin-forc', 'Use buit-in `forc` to build Sway programs') - .option('--use-builtin-fuel-core', 'Use buit-in `fuel-core` when starting a Fuel node') .option('--auto-start-fuel-core', 'Auto-starts a `fuel-core` node during `dev` command') .action(withProgram(command, Commands.init, init)); @@ -95,17 +92,5 @@ export const configureCli = () => { .description('Check for version incompatibilities') .action(runVersions); - /** - * Binary wrappers - */ - - program.command('core', 'Wrapper around Fuel Core binary', { - executableFile: findBinPath('fuels-core', __dirname), - }); - - program.command('forc', 'Wrapper around Forc binary', { - executableFile: findBinPath('fuels-forc', __dirname), - }); - return program; }; diff --git a/packages/fuels/src/cli/commands/build/buildSwayProgram.ts b/packages/fuels/src/cli/commands/build/buildSwayProgram.ts index b3370b1195f..41ac9df9f43 100644 --- a/packages/fuels/src/cli/commands/build/buildSwayProgram.ts +++ b/packages/fuels/src/cli/commands/build/buildSwayProgram.ts @@ -10,11 +10,8 @@ export const buildSwayProgram = async (config: FuelsConfig, path: string) => { debug('Building Sway program', path); return new Promise((resolve, reject) => { - const builtInForcPath = findBinPath('fuels-forc', __dirname); - - const command = config.useBuiltinForc ? builtInForcPath : 'forc'; const args = ['build', '-p', path].concat(config.forcBuildFlags); - const forc = spawn(command, args, { stdio: 'pipe' }); + const forc = spawn('forc', args, { stdio: 'pipe' }); if (loggingConfig.isLoggingEnabled) { forc.stderr?.pipe(process.stderr); diff --git a/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts b/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts index 57cf9957dd5..b700b796296 100644 --- a/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts +++ b/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts @@ -1,11 +1,10 @@ import type { FuelsConfig } from '../../types'; -import { getBinarySource } from '../../utils/getBinarySource'; import { log } from '../../utils/logger'; import { buildSwayProgram } from './buildSwayProgram'; export async function buildSwayPrograms(config: FuelsConfig) { - log(`Building Sway programs using ${getBinarySource(config.useBuiltinFuelCore)} 'forc' binary`); + log(`Building Sway programs using 'forc'`); const paths = config.workspace ? [config.workspace] diff --git a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts index ef7176a79c4..d920e304d94 100644 --- a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts +++ b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts @@ -4,7 +4,6 @@ import type { ChildProcessWithoutNullStreams } from 'child_process'; import { getPortPromise } from 'portfinder'; import type { FuelsConfig } from '../../types'; -import { getBinarySource } from '../../utils/getBinarySource'; import { log, loggingConfig } from '../../utils/logger'; export type FuelCoreNode = { @@ -28,7 +27,7 @@ export const autoStartFuelCore = async (config: FuelsConfig) => { let fuelCore: FuelCoreNode | undefined; if (config.autoStartFuelCore) { - log(`Starting ${getBinarySource(config.useBuiltinFuelCore)} 'fuel-core' node..`); + log(`Starting 'fuel-core' node..`); const bindIp = '0.0.0.0'; const accessIp = '127.0.0.1'; @@ -47,7 +46,7 @@ export const autoStartFuelCore = async (config: FuelsConfig) => { loggingEnabled: loggingConfig.isLoggingEnabled, debugEnabled: loggingConfig.isDebugEnabled, basePath: config.basePath, - useSystemFuelCore: !config.useBuiltinFuelCore, + useSystemFuelCore: true, }); fuelCore = { diff --git a/packages/fuels/src/cli/commands/init/index.ts b/packages/fuels/src/cli/commands/init/index.ts index 934f4c1391a..5cbfecaf057 100644 --- a/packages/fuels/src/cli/commands/init/index.ts +++ b/packages/fuels/src/cli/commands/init/index.ts @@ -9,7 +9,7 @@ import { log } from '../../utils/logger'; export function init(program: Command) { const options = program.opts(); - const { path, autoStartFuelCore, useBuiltinForc, useBuiltinFuelCore } = options; + const { path, autoStartFuelCore } = options; let workspace: string | undefined; let absoluteWorkspace: string | undefined; @@ -53,8 +53,6 @@ export function init(program: Command) { scripts, predicates, output, - useBuiltinForc, - useBuiltinFuelCore, autoStartFuelCore, }); diff --git a/packages/fuels/src/cli/commands/init/shouldUseBuiltinForc.test.ts b/packages/fuels/src/cli/commands/init/shouldUseBuiltinForc.test.ts deleted file mode 100644 index 6324b16246a..00000000000 --- a/packages/fuels/src/cli/commands/init/shouldUseBuiltinForc.test.ts +++ /dev/null @@ -1,59 +0,0 @@ -import * as getSystemFuelCoreMod from '@fuel-ts/versions/cli'; - -import { mockLogger } from '../../../../test/utils/mockLogger'; - -import { shouldUseBuiltinFuelCore } from './shouldUseBuiltinFuelCore'; - -vi.mock('prompts', async () => { - const mod = await vi.importActual('prompts'); - return { - __esModule: true, - ...mod, - }; -}); - -/** - * @group node - */ -describe('shouldUseBuiltinFuelCore', () => { - afterEach(() => { - vi.restoreAllMocks(); - }); - - function mockAll(returns: { getSystemFuelCore: string | null }) { - const getSystemFuelCore = vi - .spyOn(getSystemFuelCoreMod, 'getSystemFuelCore') - .mockReturnValue({ error: null, systemFuelCoreVersion: returns.getSystemFuelCore }); - - const { error } = mockLogger(); - - return { - getSystemFuelCore, - error, - }; - } - - it('should select [built-in] fuel-core', () => { - const { getSystemFuelCore, error } = mockAll({ getSystemFuelCore: null }); - - const useBuiltinFuelCore = shouldUseBuiltinFuelCore(); - - expect(useBuiltinFuelCore).toEqual(true); - expect(getSystemFuelCore).toHaveBeenCalledTimes(1); - - expect(error).toHaveBeenCalledTimes(0); - }); - - it('should select [system] fuel-core', () => { - const { getSystemFuelCore, error } = mockAll({ - getSystemFuelCore: '1.0.0', - }); - - const useBuiltinFuelCore = shouldUseBuiltinFuelCore(); - - expect(useBuiltinFuelCore).toEqual(false); - expect(getSystemFuelCore).toHaveBeenCalledTimes(1); - - expect(error).toHaveBeenCalledTimes(0); - }); -}); diff --git a/packages/fuels/src/cli/commands/init/shouldUseBuiltinForc.ts b/packages/fuels/src/cli/commands/init/shouldUseBuiltinForc.ts deleted file mode 100644 index aa4975cc298..00000000000 --- a/packages/fuels/src/cli/commands/init/shouldUseBuiltinForc.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { getSystemForc } from '@fuel-ts/versions/cli'; - -export const shouldUseBuiltinForc = () => { - // first, tries to use system binary - const { systemForcVersion } = getSystemForc(); - if (systemForcVersion !== null) { - return false; - } - - // if its not found, will default to the built-in binary - return true; -}; diff --git a/packages/fuels/src/cli/commands/init/shouldUseBuiltinFuelCore.test.ts b/packages/fuels/src/cli/commands/init/shouldUseBuiltinFuelCore.test.ts deleted file mode 100644 index 3f02b09f773..00000000000 --- a/packages/fuels/src/cli/commands/init/shouldUseBuiltinFuelCore.test.ts +++ /dev/null @@ -1,49 +0,0 @@ -import * as getSystemForcMod from '@fuel-ts/versions/cli'; - -import { mockLogger } from '../../../../test/utils/mockLogger'; - -import { shouldUseBuiltinForc } from './shouldUseBuiltinForc'; - -/** - * @group node - */ -describe('shouldUseBuiltinForc', () => { - beforeEach(() => { - vi.restoreAllMocks(); - }); - - function mockAll(returns: { getSystemForc: string | null }) { - const getSystemForc = vi - .spyOn(getSystemForcMod, 'getSystemForc') - .mockReturnValue({ error: null, systemForcVersion: returns.getSystemForc }); - - const { error } = mockLogger(); - - return { - getSystemForc, - error, - }; - } - - it('should select [built-in] forc', () => { - const { getSystemForc, error } = mockAll({ getSystemForc: null }); - - const useBuiltinForc = shouldUseBuiltinForc(); - - expect(useBuiltinForc).toEqual(true); - expect(getSystemForc).toHaveBeenCalledTimes(1); - - expect(error).toHaveBeenCalledTimes(0); - }); - - it('should select [system] forc', () => { - const { getSystemForc, error } = mockAll({ getSystemForc: '1.0.0' }); - - const useBuiltinForc = shouldUseBuiltinForc(); - - expect(useBuiltinForc).toEqual(false); - expect(getSystemForc).toHaveBeenCalledTimes(1); - - expect(error).toHaveBeenCalledTimes(0); - }); -}); diff --git a/packages/fuels/src/cli/commands/init/shouldUseBuiltinFuelCore.ts b/packages/fuels/src/cli/commands/init/shouldUseBuiltinFuelCore.ts deleted file mode 100644 index 7cb7f7ef9fc..00000000000 --- a/packages/fuels/src/cli/commands/init/shouldUseBuiltinFuelCore.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { getSystemFuelCore } from '@fuel-ts/versions/cli'; - -export const shouldUseBuiltinFuelCore = () => { - // first, tries use system binary - const { systemFuelCoreVersion } = getSystemFuelCore(); - if (systemFuelCoreVersion !== null) { - return false; - } - - // if its not found, will default to the built-in binary - return true; -}; diff --git a/packages/fuels/src/cli/config/loadConfig.test.ts b/packages/fuels/src/cli/config/loadConfig.test.ts index 6fbc5dc3e7b..bf3ae39cd08 100644 --- a/packages/fuels/src/cli/config/loadConfig.test.ts +++ b/packages/fuels/src/cli/config/loadConfig.test.ts @@ -7,8 +7,6 @@ import { resetConfigAndMocks, resetDiskAndMocks, } from '../../../test/utils/runCommands'; -import * as shouldUseBuiltinForcMod from '../commands/init/shouldUseBuiltinForc'; -import * as shouldUseBuiltinFuelCoreMod from '../commands/init/shouldUseBuiltinFuelCore'; import type { FuelsConfig } from '../types'; import { loadConfig } from './loadConfig'; @@ -123,28 +121,4 @@ describe('loadConfig', () => { expect(error?.message).toMatch(/forc workspace not detected/i); expect(error?.message).toMatch(/try using 'contracts'/i); }); - - test(`should smart-set built-in flags`, async () => { - await runInit({ - root: paths.root, - workspace: paths.workspaceDir, - output: paths.outputDir, - }); - - const shouldUseBuiltinForc = vi - .spyOn(shouldUseBuiltinForcMod, 'shouldUseBuiltinForc') - .mockReturnValue(false); - - const shouldUseBuiltinFuelCore = vi - .spyOn(shouldUseBuiltinFuelCoreMod, 'shouldUseBuiltinFuelCore') - .mockReturnValue(true); - - const config = await loadConfig(paths.root); - - expect(config.useBuiltinForc).toEqual(false); - expect(config.useBuiltinFuelCore).toEqual(true); - - expect(shouldUseBuiltinForc).toHaveBeenCalledTimes(1); - expect(shouldUseBuiltinFuelCore).toHaveBeenCalledTimes(1); - }); }); diff --git a/packages/fuels/src/cli/config/loadConfig.ts b/packages/fuels/src/cli/config/loadConfig.ts index 7e80d34d4e9..2a50e11349d 100644 --- a/packages/fuels/src/cli/config/loadConfig.ts +++ b/packages/fuels/src/cli/config/loadConfig.ts @@ -5,8 +5,6 @@ import type { BuildOptions } from 'esbuild'; import JoyCon from 'joycon'; import { resolve, parse } from 'path'; -import { shouldUseBuiltinForc } from '../commands/init/shouldUseBuiltinForc'; -import { shouldUseBuiltinFuelCore } from '../commands/init/shouldUseBuiltinFuelCore'; import type { FuelsConfig, UserFuelsConfig } from '../types'; import { readForcToml, readSwayType } from './forcUtils'; @@ -41,9 +39,6 @@ export async function loadConfig(cwd: string): Promise { await validateConfig(userConfig); - const useBuiltinForc = userConfig.useBuiltinForc ?? shouldUseBuiltinForc(); - const useBuiltinFuelCore = userConfig.useBuiltinFuelCore ?? shouldUseBuiltinFuelCore(); - const { forcBuildFlags = [] } = userConfig; const releaseFlag = forcBuildFlags.find((f) => f === '--release'); const buildMode = releaseFlag ? 'release' : 'debug'; @@ -60,8 +55,6 @@ export async function loadConfig(cwd: string): Promise { privateKey: defaultConsensusKey, ...userConfig, basePath: cwd, - useBuiltinForc, - useBuiltinFuelCore, configPath, forcBuildFlags, buildMode, diff --git a/packages/fuels/src/cli/templates/fuels.config.hbs b/packages/fuels/src/cli/templates/fuels.config.hbs index 7971ad4f8ef..c2bcc802341 100644 --- a/packages/fuels/src/cli/templates/fuels.config.hbs +++ b/packages/fuels/src/cli/templates/fuels.config.hbs @@ -27,12 +27,6 @@ export default createConfig({ {{/if}} {{/if}} output: '{{output}}', - {{#if (isDefined useBuiltinForc)}} - useBuiltinForc: {{useBuiltinForc}}, - {{/if}} - {{#if (isDefined useBuiltinFuelCore)}} - useBuiltinFuelCore: {{useBuiltinFuelCore}}, - {{/if}} {{#if (isDefined autoStartFuelCore)}} autoStartFuelCore: {{autoStartFuelCore}}, {{/if}} diff --git a/packages/fuels/src/cli/templates/fuels.config.ts b/packages/fuels/src/cli/templates/fuels.config.ts index 1e6951d8584..b208769676c 100644 --- a/packages/fuels/src/cli/templates/fuels.config.ts +++ b/packages/fuels/src/cli/templates/fuels.config.ts @@ -13,8 +13,6 @@ export function renderFuelsConfigTemplate(props: { scripts?: string[]; predicates?: string[]; output: string; - useBuiltinForc?: boolean; - useBuiltinFuelCore?: boolean; autoStartFuelCore?: boolean; }) { const renderTemplate = Handlebars.compile(fuelsConfigTemplate, { diff --git a/packages/fuels/src/cli/types.ts b/packages/fuels/src/cli/types.ts index 428326d42a7..c21cc96c732 100644 --- a/packages/fuels/src/cli/types.ts +++ b/packages/fuels/src/cli/types.ts @@ -70,12 +70,6 @@ export type UserFuelsConfig = { /** Static of dyanmic deploy configs to be used when deploying contracts */ deployConfig?: DeployContractOptions | OptionsFunction; - /** Opt-in or out from using builtin Forc binaries */ - useBuiltinForc?: boolean; - - /** Opt-in or out from using builtin Fuel Core binaries */ - useBuiltinFuelCore?: boolean; - /** If set to false, you will need to spin up a Fuel core node by yourself */ autoStartFuelCore?: boolean; @@ -116,8 +110,6 @@ export type FuelsConfig = UserFuelsConfig & | 'predicates' | 'scripts' | 'deployConfig' - | 'useBuiltinForc' - | 'useBuiltinFuelCore' | 'autoStartFuelCore' | 'providerUrl' | 'forcBuildFlags' diff --git a/packages/fuels/test/features/init.test.ts b/packages/fuels/test/features/init.test.ts index 3f111cd75d5..a105dc16e6d 100644 --- a/packages/fuels/test/features/init.test.ts +++ b/packages/fuels/test/features/init.test.ts @@ -40,8 +40,6 @@ describe('init', () => { const fuelsContents = readFileSync(paths.fuelsConfigPath, 'utf-8'); expect(fuelsContents).toMatch(`workspace: './workspace',`); expect(fuelsContents).toMatch(`output: './output',`); - expect(fuelsContents).not.toMatch(`useBuiltinForc: true,`); - expect(fuelsContents).not.toMatch(`useBuiltinFuelCore: true,`); }); it('should run `init` command using built-in flags', async () => { @@ -56,8 +54,6 @@ describe('init', () => { const fuelsContents = readFileSync(paths.fuelsConfigPath, 'utf-8'); expect(fuelsContents).toMatch(`workspace: './workspace',`); expect(fuelsContents).toMatch(`output: './output',`); - expect(fuelsContents).toMatch(`useBuiltinForc: true,`); - expect(fuelsContents).toMatch(`useBuiltinFuelCore: true,`); }); it('should run `init` command and throw for existent config file', async () => { diff --git a/packages/fuels/test/fixtures/fuels.config.ts b/packages/fuels/test/fixtures/fuels.config.ts index 76ff37e7267..9d32d2b51b8 100644 --- a/packages/fuels/test/fixtures/fuels.config.ts +++ b/packages/fuels/test/fixtures/fuels.config.ts @@ -19,8 +19,6 @@ export const fuelsConfig: FuelsConfig = { deployConfig: { gasPrice: 5, }, - useBuiltinForc: false, - useBuiltinFuelCore: false, autoStartFuelCore: true, fuelCorePort: 4000, providerUrl: FUEL_NETWORK_URL, diff --git a/packages/fuels/test/utils/runCommands.ts b/packages/fuels/test/utils/runCommands.ts index 37b3337bd56..9b564775c52 100644 --- a/packages/fuels/test/utils/runCommands.ts +++ b/packages/fuels/test/utils/runCommands.ts @@ -82,7 +82,6 @@ export type InitParams = BaseParams & { scripts?: string; predicates?: string; output: string; - useBuiltinBinaries?: boolean; autoStartFuelCore?: boolean; build?: boolean; }; @@ -99,7 +98,6 @@ export async function runInit(params: InitParams) { predicates, root, scripts, - useBuiltinBinaries, workspace, } = params; @@ -113,7 +111,6 @@ export async function runInit(params: InitParams) { flag(['--contracts', contracts], contracts), flag(['--scripts', scripts], scripts), flag(['--predicates', predicates], predicates), - flag(['--use-builtin-forc', '--use-builtin-fuel-core'], useBuiltinBinaries), flag(['--auto-start-fuel-core'], autoStartFuelCore), ].flat(); From ec14826f3d81292f33f9aeb2ed2c452c87068904 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 19:02:14 +0100 Subject: [PATCH 06/89] Removed trustedDependencies --- apps/create-fuels-counter-guide/package.json | 6 +----- templates/nextjs/package.json | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/apps/create-fuels-counter-guide/package.json b/apps/create-fuels-counter-guide/package.json index b6ae1ff06c6..f92cf264ea7 100644 --- a/apps/create-fuels-counter-guide/package.json +++ b/apps/create-fuels-counter-guide/package.json @@ -33,9 +33,5 @@ "postcss": "^8", "tailwindcss": "^3.3.0", "typescript": "^5" - }, - "trustedDependencies": [ - "@fuel-ts/fuel-core", - "@fuel-ts/forc" - ] + } } diff --git a/templates/nextjs/package.json b/templates/nextjs/package.json index a17d9fbabf4..233e77addbc 100644 --- a/templates/nextjs/package.json +++ b/templates/nextjs/package.json @@ -32,9 +32,5 @@ "postcss": "^8", "tailwindcss": "^3.3.0", "typescript": "^5" - }, - "trustedDependencies": [ - "@fuel-ts/fuel-core", - "@fuel-ts/forc" - ] + } } From cb337554a23e8eb21542a8bc2116f654a61719ed Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 19:03:10 +0100 Subject: [PATCH 07/89] Moved forc and fuel-core to internal --- {packages => internal}/forc/.gitignore | 0 {packages => internal}/forc/CHANGELOG.md | 0 {packages => internal}/forc/LICENSE | 0 {packages => internal}/forc/README.md | 0 {packages => internal}/forc/VERSION | 0 {packages => internal}/forc/VERSION_EXPERIMENTAL | 0 {packages => internal}/forc/lib/bin.js | 0 {packages => internal}/forc/lib/install.js | 0 {packages => internal}/forc/lib/shared.js | 0 {packages => internal}/forc/lib/update.js | 0 {packages => internal}/forc/package.json | 1 + {packages => internal}/fuel-core/.gitignore | 0 {packages => internal}/fuel-core/CHANGELOG.md | 0 {packages => internal}/fuel-core/LICENSE | 0 {packages => internal}/fuel-core/README.md | 0 {packages => internal}/fuel-core/VERSION | 0 {packages => internal}/fuel-core/lib/bin.js | 0 {packages => internal}/fuel-core/lib/install.js | 0 {packages => internal}/fuel-core/lib/shared.js | 0 {packages => internal}/fuel-core/lib/update.js | 0 {packages => internal}/fuel-core/package.json | 1 + 21 files changed, 2 insertions(+) rename {packages => internal}/forc/.gitignore (100%) rename {packages => internal}/forc/CHANGELOG.md (100%) rename {packages => internal}/forc/LICENSE (100%) rename {packages => internal}/forc/README.md (100%) rename {packages => internal}/forc/VERSION (100%) rename {packages => internal}/forc/VERSION_EXPERIMENTAL (100%) rename {packages => internal}/forc/lib/bin.js (100%) rename {packages => internal}/forc/lib/install.js (100%) rename {packages => internal}/forc/lib/shared.js (100%) rename {packages => internal}/forc/lib/update.js (100%) rename {packages => internal}/forc/package.json (96%) rename {packages => internal}/fuel-core/.gitignore (100%) rename {packages => internal}/fuel-core/CHANGELOG.md (100%) rename {packages => internal}/fuel-core/LICENSE (100%) rename {packages => internal}/fuel-core/README.md (100%) rename {packages => internal}/fuel-core/VERSION (100%) rename {packages => internal}/fuel-core/lib/bin.js (100%) rename {packages => internal}/fuel-core/lib/install.js (100%) rename {packages => internal}/fuel-core/lib/shared.js (100%) rename {packages => internal}/fuel-core/lib/update.js (100%) rename {packages => internal}/fuel-core/package.json (96%) diff --git a/packages/forc/.gitignore b/internal/forc/.gitignore similarity index 100% rename from packages/forc/.gitignore rename to internal/forc/.gitignore diff --git a/packages/forc/CHANGELOG.md b/internal/forc/CHANGELOG.md similarity index 100% rename from packages/forc/CHANGELOG.md rename to internal/forc/CHANGELOG.md diff --git a/packages/forc/LICENSE b/internal/forc/LICENSE similarity index 100% rename from packages/forc/LICENSE rename to internal/forc/LICENSE diff --git a/packages/forc/README.md b/internal/forc/README.md similarity index 100% rename from packages/forc/README.md rename to internal/forc/README.md diff --git a/packages/forc/VERSION b/internal/forc/VERSION similarity index 100% rename from packages/forc/VERSION rename to internal/forc/VERSION diff --git a/packages/forc/VERSION_EXPERIMENTAL b/internal/forc/VERSION_EXPERIMENTAL similarity index 100% rename from packages/forc/VERSION_EXPERIMENTAL rename to internal/forc/VERSION_EXPERIMENTAL diff --git a/packages/forc/lib/bin.js b/internal/forc/lib/bin.js similarity index 100% rename from packages/forc/lib/bin.js rename to internal/forc/lib/bin.js diff --git a/packages/forc/lib/install.js b/internal/forc/lib/install.js similarity index 100% rename from packages/forc/lib/install.js rename to internal/forc/lib/install.js diff --git a/packages/forc/lib/shared.js b/internal/forc/lib/shared.js similarity index 100% rename from packages/forc/lib/shared.js rename to internal/forc/lib/shared.js diff --git a/packages/forc/lib/update.js b/internal/forc/lib/update.js similarity index 100% rename from packages/forc/lib/update.js rename to internal/forc/lib/update.js diff --git a/packages/forc/package.json b/internal/forc/package.json similarity index 96% rename from packages/forc/package.json rename to internal/forc/package.json index dc024e20787..a4fb5f90405 100644 --- a/packages/forc/package.json +++ b/internal/forc/package.json @@ -1,4 +1,5 @@ { + "private": true, "name": "@fuel-ts/forc", "version": "0.81.0", "description": "NPM bin wrapper around Fuel `forc`", diff --git a/packages/fuel-core/.gitignore b/internal/fuel-core/.gitignore similarity index 100% rename from packages/fuel-core/.gitignore rename to internal/fuel-core/.gitignore diff --git a/packages/fuel-core/CHANGELOG.md b/internal/fuel-core/CHANGELOG.md similarity index 100% rename from packages/fuel-core/CHANGELOG.md rename to internal/fuel-core/CHANGELOG.md diff --git a/packages/fuel-core/LICENSE b/internal/fuel-core/LICENSE similarity index 100% rename from packages/fuel-core/LICENSE rename to internal/fuel-core/LICENSE diff --git a/packages/fuel-core/README.md b/internal/fuel-core/README.md similarity index 100% rename from packages/fuel-core/README.md rename to internal/fuel-core/README.md diff --git a/packages/fuel-core/VERSION b/internal/fuel-core/VERSION similarity index 100% rename from packages/fuel-core/VERSION rename to internal/fuel-core/VERSION diff --git a/packages/fuel-core/lib/bin.js b/internal/fuel-core/lib/bin.js similarity index 100% rename from packages/fuel-core/lib/bin.js rename to internal/fuel-core/lib/bin.js diff --git a/packages/fuel-core/lib/install.js b/internal/fuel-core/lib/install.js similarity index 100% rename from packages/fuel-core/lib/install.js rename to internal/fuel-core/lib/install.js diff --git a/packages/fuel-core/lib/shared.js b/internal/fuel-core/lib/shared.js similarity index 100% rename from packages/fuel-core/lib/shared.js rename to internal/fuel-core/lib/shared.js diff --git a/packages/fuel-core/lib/update.js b/internal/fuel-core/lib/update.js similarity index 100% rename from packages/fuel-core/lib/update.js rename to internal/fuel-core/lib/update.js diff --git a/packages/fuel-core/package.json b/internal/fuel-core/package.json similarity index 96% rename from packages/fuel-core/package.json rename to internal/fuel-core/package.json index a7eec9969e5..c9f7817540e 100644 --- a/packages/fuel-core/package.json +++ b/internal/fuel-core/package.json @@ -1,4 +1,5 @@ { + "private": true, "name": "@fuel-ts/fuel-core", "version": "0.81.0", "description": "NPM bin wrapper around `fuel-core`", From e7fd38535890676e1a01394f539cba3ff2339078 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 19:04:18 +0100 Subject: [PATCH 08/89] Removed forc and fuel-core from fuels --- packages/fuels/package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/fuels/package.json b/packages/fuels/package.json index 16c69444e46..d14898182fb 100644 --- a/packages/fuels/package.json +++ b/packages/fuels/package.json @@ -48,8 +48,6 @@ "@fuel-ts/contract": "workspace:*", "@fuel-ts/crypto": "workspace:*", "@fuel-ts/errors": "workspace:*", - "@fuel-ts/forc": "workspace:*", - "@fuel-ts/fuel-core": "workspace:*", "@fuel-ts/hasher": "workspace:*", "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/math": "workspace:*", From b629f57c3eb8c4ebb08504f371ef43c0baf46559 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 19:08:04 +0100 Subject: [PATCH 09/89] Changed to @internal/forc and @internal/fuel-core namespaces --- apps/demo-typegen/package.json | 2 +- internal/forc/README.md | 2 +- internal/forc/package.json | 2 +- internal/fuel-core/CHANGELOG.md | 2 +- internal/fuel-core/package.json | 2 +- package.json | 4 +- packages/abi-typegen/package.json | 2 +- packages/account/src/test-utils/launchNode.ts | 2 +- packages/fuel-gauge/package.json | 2 +- packages/script/package.json | 2 +- pnpm-lock.yaml | 921 +++++++++++------- scripts/forc-update.ts | 2 +- 12 files changed, 601 insertions(+), 344 deletions(-) diff --git a/apps/demo-typegen/package.json b/apps/demo-typegen/package.json index 489629f5a07..0869ed7dc9a 100644 --- a/apps/demo-typegen/package.json +++ b/apps/demo-typegen/package.json @@ -21,7 +21,7 @@ "devDependencies": { "@fuel-ts/account": "workspace:*", "@fuel-ts/errors": "workspace:*", - "@fuel-ts/forc": "workspace:*" + "@internal/forc": "workspace:*" }, "version": null } diff --git a/internal/forc/README.md b/internal/forc/README.md index 96518e3e7fc..494db35ed65 100644 --- a/internal/forc/README.md +++ b/internal/forc/README.md @@ -1,3 +1,3 @@ -# `@fuel-ts/forc` +# `@internal/forc` Binary wrapper for [Forc](https://github.com/FuelLabs/sway) diff --git a/internal/forc/package.json b/internal/forc/package.json index a4fb5f90405..006eab50f15 100644 --- a/internal/forc/package.json +++ b/internal/forc/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "@fuel-ts/forc", + "name": "@internal/forc", "version": "0.81.0", "description": "NPM bin wrapper around Fuel `forc`", "author": "Fuel Labs (https://fuel.network/)", diff --git a/internal/fuel-core/CHANGELOG.md b/internal/fuel-core/CHANGELOG.md index edcdd0bc23b..3d8dd2390b3 100644 --- a/internal/fuel-core/CHANGELOG.md +++ b/internal/fuel-core/CHANGELOG.md @@ -1,4 +1,4 @@ -# @fuel-ts/fuel-core +# @internal/fuel-core ## 0.81.0 diff --git a/internal/fuel-core/package.json b/internal/fuel-core/package.json index c9f7817540e..6fcb087f1ba 100644 --- a/internal/fuel-core/package.json +++ b/internal/fuel-core/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "@fuel-ts/fuel-core", + "name": "@internal/fuel-core", "version": "0.81.0", "description": "NPM bin wrapper around `fuel-core`", "author": "Fuel Labs (https://fuel.network/)", diff --git a/package.json b/package.json index 9c22b7d28e5..da720fa9f22 100644 --- a/package.json +++ b/package.json @@ -63,8 +63,8 @@ "@changesets/get-github-info": "^0.5.2", "@changesets/read": "^0.6.0", "@changesets/types": "^6.0.0", - "@fuel-ts/forc": "workspace:*", - "@fuel-ts/fuel-core": "workspace:*", + "@internal/forc": "workspace:*", + "@internal/fuel-core": "workspace:*", "@fuel-ts/utils": "workspace:*", "@fuel-ts/versions": "workspace:^", "@internal/tsup": "workspace:*", diff --git a/packages/abi-typegen/package.json b/packages/abi-typegen/package.json index bc8a6e18ddc..fade42620b7 100644 --- a/packages/abi-typegen/package.json +++ b/packages/abi-typegen/package.json @@ -62,7 +62,7 @@ "rimraf": "^3.0.2" }, "devDependencies": { - "@fuel-ts/forc": "workspace:*", + "@internal/forc": "workspace:*", "@types/mkdirp": "^1.0.2", "@types/ramda": "^0.29.3", "@types/rimraf": "^3.0.2" diff --git a/packages/account/src/test-utils/launchNode.ts b/packages/account/src/test-utils/launchNode.ts index 2cb1fe4e8cd..a1f70d49873 100644 --- a/packages/account/src/test-utils/launchNode.ts +++ b/packages/account/src/test-utils/launchNode.ts @@ -87,7 +87,7 @@ export const killNode = (params: KillNodeParams) => { * @param ip - the ip to bind to. (optional, defaults to 0.0.0.0) * @param port - the port to bind to. (optional, defaults to 4000 or the next available port) * @param args - additional arguments to pass to fuel-core. - * @param useSystemFuelCore - whether to use the system fuel-core binary or the one provided by the \@fuel-ts/fuel-core package. + * @param useSystemFuelCore - whether to use the system fuel-core binary or the one provided by the \@internal/fuel-core package. * @param loggingEnabled - whether the node should output logs. (optional, defaults to true) * @param debugEnabled - whether the node should log debug messages. (optional, defaults to false) * @param basePath - the base path to use for the temporary folder. (optional, defaults to os.tmpdir()) diff --git a/packages/fuel-gauge/package.json b/packages/fuel-gauge/package.json index 12ddc1e4c67..f1a570e74b3 100644 --- a/packages/fuel-gauge/package.json +++ b/packages/fuel-gauge/package.json @@ -16,7 +16,7 @@ }, "devDependencies": { "@fuel-ts/account": "workspace:*", - "@fuel-ts/forc": "workspace:*", + "@internal/forc": "workspace:*", "@fuel-ts/utils": "workspace:*", "@fuel-ts/errors": "workspace:*" } diff --git a/packages/script/package.json b/packages/script/package.json index ffad25748bb..7fb324bffe7 100644 --- a/packages/script/package.json +++ b/packages/script/package.json @@ -38,6 +38,6 @@ "@fuel-ts/utils": "workspace:*" }, "devDependencies": { - "@fuel-ts/forc": "workspace:*" + "@internal/forc": "workspace:*" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2755fb9ce18..9d479d00b5d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,18 +29,18 @@ importers: '@changesets/types': specifier: ^6.0.0 version: 6.0.0 - '@fuel-ts/forc': - specifier: workspace:* - version: link:packages/forc - '@fuel-ts/fuel-core': - specifier: workspace:* - version: link:packages/fuel-core '@fuel-ts/utils': specifier: workspace:* version: link:packages/utils '@fuel-ts/versions': specifier: workspace:^ version: link:packages/versions + '@internal/forc': + specifier: workspace:* + version: link:internal/forc + '@internal/fuel-core': + specifier: workspace:* + version: link:internal/fuel-core '@internal/tsup': specifier: workspace:* version: link:internal/tsup @@ -58,16 +58,16 @@ importers: version: 0.0.65 '@typescript-eslint/eslint-plugin': specifier: ^6.9.0 - version: 6.9.1(@typescript-eslint/parser@6.9.1)(eslint@8.52.0)(typescript@5.2.2) + version: 6.9.1(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0)(typescript@5.2.2) '@typescript-eslint/parser': specifier: ^6.9.0 version: 6.9.1(eslint@8.52.0)(typescript@5.2.2) '@vitest/browser': specifier: ^1.1.3 - version: 1.2.1(vitest@1.2.1)(webdriverio@8.32.2) + version: 1.2.1(vitest@1.2.1)(webdriverio@8.32.2(typescript@5.2.2)) '@vitest/coverage-istanbul': specifier: ^1.1.3 - version: 1.2.1(vitest@1.2.1) + version: 1.2.1(vitest@1.2.1(@types/node@18.15.3)(@vitest/browser@1.2.1)(jsdom@16.7.0)(terser@5.18.2)) compare-versions: specifier: ^6.1.0 version: 6.1.0 @@ -79,10 +79,10 @@ importers: version: 8.52.0 eslint-config-airbnb-base: specifier: ^15.0.0 - version: 15.0.0(eslint-plugin-import@2.29.0)(eslint@8.52.0) + version: 15.0.0(eslint-plugin-import@2.29.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0))(eslint@8.52.0) eslint-config-airbnb-typescript: specifier: ^17.1.0 - version: 17.1.0(@typescript-eslint/eslint-plugin@6.9.1)(@typescript-eslint/parser@6.9.1)(eslint-plugin-import@2.29.0)(eslint@8.52.0) + version: 17.1.0(@typescript-eslint/eslint-plugin@6.9.1(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0)(typescript@5.2.2))(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint-plugin-import@2.29.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0))(eslint@8.52.0) eslint-config-prettier: specifier: ^9.0.0 version: 9.0.0(eslint@8.52.0) @@ -91,7 +91,7 @@ importers: version: 3.2.0(eslint@8.52.0) eslint-plugin-import: specifier: ^2.29.0 - version: 2.29.0(@typescript-eslint/parser@6.9.1)(eslint@8.52.0) + version: 2.29.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0) eslint-plugin-jsdoc: specifier: ^46.8.2 version: 46.8.2(eslint@8.52.0) @@ -100,7 +100,7 @@ importers: version: 6.7.1(eslint@8.52.0) eslint-plugin-prettier: specifier: ^5.0.1 - version: 5.0.1(eslint-config-prettier@9.0.0)(eslint@8.52.0)(prettier@3.0.3) + version: 5.0.1(@types/eslint@8.40.2)(eslint-config-prettier@9.0.0(eslint@8.52.0))(eslint@8.52.0)(prettier@3.0.3) eslint-plugin-react: specifier: ^7.33.2 version: 7.33.2(eslint@8.52.0) @@ -148,7 +148,7 @@ importers: version: 0.1.1 tsup: specifier: ^6.7.0 - version: 6.7.0(typescript@5.2.2) + version: 6.7.0(postcss@8.4.33)(ts-node@10.9.1(@types/node@18.15.3)(typescript@5.2.2))(typescript@5.2.2) tsx: specifier: ^4.7.0 version: 4.7.0 @@ -160,16 +160,16 @@ importers: version: 5.2.2 vite: specifier: ^5.0.11 - version: 5.0.12(@types/node@18.15.3) + version: 5.0.12(@types/node@18.15.3)(terser@5.18.2) vite-plugin-node-polyfills: specifier: ^0.17.0 - version: 0.17.0(vite@5.0.12) + version: 0.17.0(rollup@4.9.6)(vite@5.0.12(@types/node@18.15.3)(terser@5.18.2)) vite-plugin-plain-text: specifier: ^1.4.2 version: 1.4.2 vitest: specifier: ^1.1.3 - version: 1.2.1(@types/node@18.15.3)(@vitest/browser@1.2.1) + version: 1.2.1(@types/node@18.15.3)(@vitest/browser@1.2.1)(jsdom@16.7.0)(terser@5.18.2) webdriverio: specifier: ^8.32.0 version: 8.32.2(typescript@5.2.2) @@ -181,7 +181,7 @@ importers: version: 0.2.2(fuels@packages+fuels) '@fuels/react': specifier: ^0.18.1 - version: 0.18.1(@tanstack/react-query@5.29.2)(@types/react-dom@18.2.4)(@types/react@18.2.9)(fuels@packages+fuels)(react-dom@18.2.0)(react@18.2.0) + version: 0.18.1(@tanstack/react-query@5.29.2(react@18.2.0))(@types/react-dom@18.2.4)(@types/react@18.2.9)(fuels@packages+fuels)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@tanstack/react-query': specifier: ^5.29.2 version: 5.29.2(react@18.2.0) @@ -193,7 +193,7 @@ importers: version: link:../../packages/fuels next: specifier: 14.0.1 - version: 14.0.1(@babel/core@7.23.3)(react-dom@18.2.0)(react@18.2.0) + version: 14.0.1(@babel/core@7.23.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: specifier: ^18.2 version: 18.2.0 @@ -202,10 +202,10 @@ importers: version: 18.2.0(react@18.2.0) react-hot-toast: specifier: ^2.4.1 - version: 2.4.1(csstype@3.1.3)(react-dom@18.2.0)(react@18.2.0) + version: 2.4.1(csstype@3.1.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react-use: specifier: ^17.5.0 - version: 17.5.0(react-dom@18.2.0)(react@18.2.0) + version: 17.5.0(react-dom@18.2.0(react@18.2.0))(react@18.2.0) devDependencies: '@types/node': specifier: ^20 @@ -230,7 +230,7 @@ importers: version: 8.4.33 tailwindcss: specifier: ^3.3.0 - version: 3.3.2 + version: 3.3.2(ts-node@10.9.1(@types/node@20.11.13)(typescript@5.2.2)) typescript: specifier: ^5 version: 5.2.2 @@ -266,7 +266,7 @@ importers: version: link:../../packages/fuels next: specifier: 13.4.4 - version: 13.4.4(@babel/core@7.23.3)(react-dom@18.2.0)(react@18.2.0) + version: 13.4.4(@babel/core@7.23.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: specifier: 18.2.0 version: 18.2.0 @@ -290,7 +290,7 @@ importers: version: 0.42.1 '@testing-library/react': specifier: ^13.4.0 - version: 13.4.0(react-dom@18.2.0)(react@18.2.0) + version: 13.4.0(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@types/node': specifier: ^16.18.34 version: 16.18.34 @@ -302,7 +302,7 @@ importers: version: 18.2.4 eslint-config-react-app: specifier: ^7.0.1 - version: 7.0.1(@babel/plugin-syntax-flow@7.23.3)(@babel/plugin-transform-react-jsx@7.23.4)(eslint@8.54.0)(jest@27.5.1)(typescript@5.2.2) + version: 7.0.1(@babel/plugin-syntax-flow@7.23.3(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.23.4(@babel/core@7.22.5))(eslint@8.54.0)(jest@27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)))(typescript@5.2.2) fuels: specifier: workspace:* version: link:../../packages/fuels @@ -314,7 +314,7 @@ importers: version: 18.2.0(react@18.2.0) react-scripts: specifier: 5.0.1 - version: 5.0.1(@babel/plugin-syntax-flow@7.23.3)(@babel/plugin-transform-react-jsx@7.23.4)(esbuild@0.17.19)(eslint@8.54.0)(react@18.2.0)(typescript@5.2.2) + version: 5.0.1(@babel/plugin-syntax-flow@7.23.3(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.23.4(@babel/core@7.22.5))(@types/babel__core@7.20.1)(esbuild@0.17.19)(eslint@8.54.0)(react@18.2.0)(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2))(type-fest@3.1.0)(typescript@5.2.2) typescript: specifier: ~5.2.2 version: 5.2.2 @@ -349,13 +349,13 @@ importers: version: 18.2.4 '@typescript-eslint/eslint-plugin': specifier: ^5.59.0 - version: 5.59.0(@typescript-eslint/parser@5.59.0)(eslint@8.38.0)(typescript@5.2.2) + version: 5.59.0(@typescript-eslint/parser@5.59.0(eslint@8.38.0)(typescript@5.2.2))(eslint@8.38.0)(typescript@5.2.2) '@typescript-eslint/parser': specifier: ^5.59.0 version: 5.59.0(eslint@8.38.0)(typescript@5.2.2) '@vitejs/plugin-react': specifier: ^4.0.0 - version: 4.0.0(vite@4.3.9) + version: 4.0.0(vite@4.3.9(@types/node@20.11.13)(terser@5.18.2)) eslint: specifier: ^8.38.0 version: 8.38.0 @@ -370,7 +370,7 @@ importers: version: 5.2.2 vite: specifier: ^4.3.9 - version: 4.3.9(@types/node@18.15.3) + version: 4.3.9(@types/node@20.11.13)(terser@5.18.2) apps/demo-typegen: dependencies: @@ -384,9 +384,9 @@ importers: '@fuel-ts/errors': specifier: workspace:* version: link:../../packages/errors - '@fuel-ts/forc': + '@internal/forc': specifier: workspace:* - version: link:../../packages/forc + version: link:../../internal/forc apps/demo-wallet-sdk-react: dependencies: @@ -395,7 +395,7 @@ importers: version: 0.2.2(fuels@packages+fuels) '@fuels/react': specifier: ^0.18.1 - version: 0.18.1(@tanstack/react-query@5.29.2)(@types/react-dom@18.2.4)(@types/react@18.2.9)(fuels@packages+fuels)(react-dom@18.2.0)(react@18.2.0) + version: 0.18.1(@tanstack/react-query@5.29.2(react@18.2.0))(@types/react-dom@18.2.4)(@types/react@18.2.9)(fuels@packages+fuels)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@tanstack/react-query': specifier: ^5.29.2 version: 5.29.2(react@18.2.0) @@ -404,7 +404,7 @@ importers: version: link:../../packages/fuels next: specifier: 14.1.0 - version: 14.1.0(@babel/core@7.23.3)(react-dom@18.2.0)(react@18.2.0) + version: 14.1.0(@babel/core@7.23.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: specifier: ^18 version: 18.2.0 @@ -429,7 +429,7 @@ importers: version: 8.4.33 tailwindcss: specifier: ^3.3.0 - version: 3.3.2 + version: 3.3.2(ts-node@10.9.1(@types/node@20.11.13)(typescript@5.2.2)) typescript: specifier: ^5 version: 5.2.2 @@ -447,7 +447,7 @@ importers: version: link:../../packages/fuels typedoc-plugin-markdown: specifier: ^3.15.3 - version: 3.15.3(typedoc@0.25.3) + version: 3.15.3(typedoc@0.25.3(typescript@5.2.2)) devDependencies: '@types/markdown-it': specifier: ^12.2.3 @@ -472,13 +472,13 @@ importers: version: 0.25.3(typescript@5.2.2) typedoc-plugin-merge-modules: specifier: ^5.0.1 - version: 5.0.1(typedoc@0.25.3) + version: 5.0.1(typedoc@0.25.3(typescript@5.2.2)) vitepress: specifier: 1.0.0-rc.40 - version: 1.0.0-rc.40(@algolia/client-search@4.22.1)(@types/node@18.15.3)(search-insights@2.11.0)(typescript@5.2.2) + version: 1.0.0-rc.40(@algolia/client-search@4.22.1)(@types/node@20.11.13)(@types/react@18.2.9)(change-case@4.1.2)(postcss@8.4.33)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.11.0)(terser@5.18.2)(typescript@5.2.2) vitepress-plugin-search: specifier: 1.0.4-alpha.19 - version: 1.0.4-alpha.19(flexsearch@0.7.31)(vitepress@1.0.0-rc.40)(vue@3.4.15) + version: 1.0.4-alpha.19(flexsearch@0.7.31)(vitepress@1.0.0-rc.40(@algolia/client-search@4.22.1)(@types/node@20.11.13)(@types/react@18.2.9)(change-case@4.1.2)(postcss@8.4.33)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.11.0)(terser@5.18.2)(typescript@5.2.2))(vue@3.4.15(typescript@5.2.2)) vue: specifier: ^3.4.15 version: 3.4.15(typescript@5.2.2) @@ -502,7 +502,7 @@ importers: version: link:../../packages/fuels vitest: specifier: ^1.1.3 - version: 1.2.1(@types/node@18.15.3)(@vitest/browser@1.2.1) + version: 1.2.1(@types/node@20.11.13)(@vitest/browser@1.2.1)(jsdom@16.7.0)(terser@5.18.2) internal/check-imports: dependencies: @@ -560,6 +560,18 @@ importers: internal/check-tests: {} + internal/forc: + dependencies: + node-fetch: + specifier: ^2.6.7 + version: 2.7.0 + + internal/fuel-core: + dependencies: + node-fetch: + specifier: ^2.7.0 + version: 2.7.0 + internal/tsup: {} packages/abi-coder: @@ -622,9 +634,9 @@ importers: specifier: ^3.0.2 version: 3.0.2 devDependencies: - '@fuel-ts/forc': + '@internal/forc': specifier: workspace:* - version: link:../forc + version: link:../../internal/forc '@types/mkdirp': specifier: ^1.0.2 version: 1.0.2 @@ -706,13 +718,13 @@ importers: devDependencies: '@graphql-codegen/cli': specifier: ^2.13.7 - version: 2.13.7(@babel/core@7.23.3)(@types/node@20.11.13)(graphql@16.6.0)(ts-node@10.9.1)(typescript@5.2.2) + version: 2.13.7(@babel/core@7.22.5)(@types/node@20.11.13)(enquirer@2.3.6)(graphql@16.6.0)(ts-node@10.9.1(@types/node@20.11.13)(typescript@5.2.2))(typescript@5.2.2) '@graphql-codegen/typescript': specifier: ^2.8.0 version: 2.8.0(graphql@16.6.0) '@graphql-codegen/typescript-generic-sdk': specifier: ^3.1.0 - version: 3.1.0(graphql-tag@2.12.6)(graphql@16.6.0) + version: 3.1.0(graphql-tag@2.12.6(graphql@16.6.0))(graphql@16.6.0) '@graphql-codegen/typescript-operations': specifier: ^2.5.5 version: 2.5.5(graphql@16.6.0) @@ -829,18 +841,6 @@ importers: specifier: workspace:* version: link:../versions - packages/forc: - dependencies: - node-fetch: - specifier: ^2.6.7 - version: 2.6.7 - - packages/fuel-core: - dependencies: - node-fetch: - specifier: ^2.7.0 - version: 2.7.0 - packages/fuel-gauge: dependencies: fuels: @@ -853,12 +853,12 @@ importers: '@fuel-ts/errors': specifier: workspace:* version: link:../errors - '@fuel-ts/forc': - specifier: workspace:* - version: link:../forc '@fuel-ts/utils': specifier: workspace:* version: link:../utils + '@internal/forc': + specifier: workspace:* + version: link:../../internal/forc packages/fuels: dependencies: @@ -883,12 +883,6 @@ importers: '@fuel-ts/errors': specifier: workspace:* version: link:../errors - '@fuel-ts/forc': - specifier: workspace:* - version: link:../forc - '@fuel-ts/fuel-core': - specifier: workspace:* - version: link:../fuel-core '@fuel-ts/hasher': specifier: workspace:* version: link:../hasher @@ -964,7 +958,7 @@ importers: version: 3.0.2 vite: specifier: ^4.3.9 - version: 4.3.9(@types/node@18.15.3) + version: 4.3.9(@types/node@20.11.13)(terser@5.18.2) packages/hasher: dependencies: @@ -1064,9 +1058,9 @@ importers: specifier: workspace:* version: link:../utils devDependencies: - '@fuel-ts/forc': + '@internal/forc': specifier: workspace:* - version: link:../forc + version: link:../../internal/forc packages/transactions: dependencies: @@ -1121,7 +1115,7 @@ importers: version: 0.2.2(fuels@packages+fuels) '@fuels/react': specifier: ^0.18.1 - version: 0.18.1(@tanstack/react-query@5.29.2)(@types/react-dom@18.2.4)(@types/react@18.2.9)(fuels@packages+fuels)(react-dom@18.2.0)(react@18.2.0) + version: 0.18.1(@tanstack/react-query@5.29.2(react@18.2.0))(@types/react-dom@18.2.4)(@types/react@18.2.9)(fuels@packages+fuels)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@tanstack/react-query': specifier: ^5.29.2 version: 5.29.2(react@18.2.0) @@ -1133,7 +1127,7 @@ importers: version: link:../../packages/fuels next: specifier: 14.0.1 - version: 14.0.1(@babel/core@7.23.3)(react-dom@18.2.0)(react@18.2.0) + version: 14.0.1(@babel/core@7.23.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: specifier: ^18.2 version: 18.2.0 @@ -1142,10 +1136,10 @@ importers: version: 18.2.0(react@18.2.0) react-hot-toast: specifier: ^2.4.1 - version: 2.4.1(csstype@3.1.3)(react-dom@18.2.0)(react@18.2.0) + version: 2.4.1(csstype@3.1.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react-use: specifier: ^17.5.0 - version: 17.5.0(react-dom@18.2.0)(react@18.2.0) + version: 17.5.0(react-dom@18.2.0(react@18.2.0))(react@18.2.0) devDependencies: '@types/node': specifier: ^20 @@ -1170,7 +1164,7 @@ importers: version: 8.4.24 tailwindcss: specifier: ^3.3.0 - version: 3.3.2 + version: 3.3.2(ts-node@10.9.1(@types/node@20.10.5)(typescript@5.2.2)) typescript: specifier: ^5 version: 5.2.2 @@ -8785,15 +8779,6 @@ packages: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} - node-fetch@2.6.7: - resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==} - engines: {node: 4.x || >=6.0.0} - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true - node-fetch@2.7.0: resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} engines: {node: 4.x || >=6.0.0} @@ -12807,11 +12792,6 @@ snapshots: '@babel/core': 7.22.5 '@babel/helper-plugin-utils': 7.22.5 - '@babel/plugin-syntax-import-assertions@7.22.5(@babel/core@7.23.3)': - dependencies: - '@babel/core': 7.23.3 - '@babel/helper-plugin-utils': 7.22.5 - '@babel/plugin-syntax-import-attributes@7.22.5(@babel/core@7.22.5)': dependencies: '@babel/core': 7.22.5 @@ -13765,9 +13745,9 @@ snapshots: '@docsearch/css@3.5.2': {} - '@docsearch/js@3.5.2(@algolia/client-search@4.22.1)(search-insights@2.11.0)': + '@docsearch/js@3.5.2(@algolia/client-search@4.22.1)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.11.0)': dependencies: - '@docsearch/react': 3.5.2(@algolia/client-search@4.22.1)(search-insights@2.11.0) + '@docsearch/react': 3.5.2(@algolia/client-search@4.22.1)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.11.0) preact: 10.15.1 transitivePeerDependencies: - '@algolia/client-search' @@ -13776,12 +13756,16 @@ snapshots: - react-dom - search-insights - '@docsearch/react@3.5.2(@algolia/client-search@4.22.1)(search-insights@2.11.0)': + '@docsearch/react@3.5.2(@algolia/client-search@4.22.1)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.11.0)': dependencies: '@algolia/autocomplete-core': 1.9.3(@algolia/client-search@4.22.1)(algoliasearch@4.22.1)(search-insights@2.11.0) '@algolia/autocomplete-preset-algolia': 1.9.3(@algolia/client-search@4.22.1)(algoliasearch@4.22.1) '@docsearch/css': 3.5.2 algoliasearch: 4.22.1 + optionalDependencies: + '@types/react': 18.2.9 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) search-insights: 2.11.0 transitivePeerDependencies: - '@algolia/client-search' @@ -14088,9 +14072,9 @@ snapshots: dependencies: fuels: link:packages/fuels - '@fuels/react@0.18.1(@tanstack/react-query@5.29.2)(@types/react-dom@18.2.4)(@types/react@18.2.9)(fuels@packages+fuels)(react-dom@18.2.0)(react@18.2.0)': + '@fuels/react@0.18.1(@tanstack/react-query@5.29.2(react@18.2.0))(@types/react-dom@18.2.4)(@types/react@18.2.9)(fuels@packages+fuels)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: - '@radix-ui/react-dialog': 1.0.5(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-dialog': 1.0.5(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@tanstack/react-query': 5.29.2(react@18.2.0) events: 3.3.0 fuels: link:packages/fuels @@ -14102,7 +14086,7 @@ snapshots: '@fuels/vm-asm@0.42.1': {} - '@graphql-codegen/cli@2.13.7(@babel/core@7.23.3)(@types/node@20.11.13)(graphql@16.6.0)(ts-node@10.9.1)(typescript@5.2.2)': + '@graphql-codegen/cli@2.13.7(@babel/core@7.22.5)(@types/node@20.11.13)(enquirer@2.3.6)(graphql@16.6.0)(ts-node@10.9.1(@types/node@20.11.13)(typescript@5.2.2))(typescript@5.2.2)': dependencies: '@babel/generator': 7.23.4 '@babel/template': 7.22.15 @@ -14110,9 +14094,9 @@ snapshots: '@graphql-codegen/core': 2.6.2(graphql@16.6.0) '@graphql-codegen/plugin-helpers': 2.7.2(graphql@16.6.0) '@graphql-tools/apollo-engine-loader': 7.3.26(graphql@16.6.0) - '@graphql-tools/code-file-loader': 7.3.23(@babel/core@7.23.3)(graphql@16.6.0) - '@graphql-tools/git-loader': 7.3.0(@babel/core@7.23.3)(graphql@16.6.0) - '@graphql-tools/github-loader': 7.3.28(@babel/core@7.23.3)(@types/node@20.11.13)(graphql@16.6.0) + '@graphql-tools/code-file-loader': 7.3.23(@babel/core@7.22.5)(graphql@16.6.0) + '@graphql-tools/git-loader': 7.3.0(@babel/core@7.22.5)(graphql@16.6.0) + '@graphql-tools/github-loader': 7.3.28(@babel/core@7.22.5)(@types/node@20.11.13)(graphql@16.6.0) '@graphql-tools/graphql-file-loader': 7.5.17(graphql@16.6.0) '@graphql-tools/json-file-loader': 7.4.18(graphql@16.6.0) '@graphql-tools/load': 7.8.14(graphql@16.6.0) @@ -14124,7 +14108,7 @@ snapshots: chalk: 4.1.2 chokidar: 3.5.3 cosmiconfig: 7.1.0 - cosmiconfig-typescript-loader: 4.1.1(@types/node@20.11.13)(cosmiconfig@7.1.0)(ts-node@10.9.1)(typescript@5.2.2) + cosmiconfig-typescript-loader: 4.1.1(@types/node@20.11.13)(cosmiconfig@7.1.0)(ts-node@10.9.1(@types/node@20.11.13)(typescript@5.2.2))(typescript@5.2.2) debounce: 1.2.1 detect-indent: 6.1.0 graphql: 16.6.0 @@ -14132,7 +14116,7 @@ snapshots: inquirer: 8.2.5 is-glob: 4.0.3 json-to-pretty-yaml: 1.2.2 - listr2: 4.0.5 + listr2: 4.0.5(enquirer@2.3.6) log-symbols: 4.1.0 mkdirp: 1.0.4 shell-quote: 1.8.1 @@ -14189,7 +14173,7 @@ snapshots: graphql: 16.6.0 tslib: 2.4.1 - '@graphql-codegen/typescript-generic-sdk@3.1.0(graphql-tag@2.12.6)(graphql@16.6.0)': + '@graphql-codegen/typescript-generic-sdk@3.1.0(graphql-tag@2.12.6(graphql@16.6.0))(graphql@16.6.0)': dependencies: '@graphql-codegen/plugin-helpers': 3.1.2(graphql@16.6.0) '@graphql-codegen/visitor-plugin-common': 2.13.1(graphql@16.6.0) @@ -14277,9 +14261,9 @@ snapshots: tslib: 2.6.0 value-or-promise: 1.0.12 - '@graphql-tools/code-file-loader@7.3.23(@babel/core@7.23.3)(graphql@16.6.0)': + '@graphql-tools/code-file-loader@7.3.23(@babel/core@7.22.5)(graphql@16.6.0)': dependencies: - '@graphql-tools/graphql-tag-pluck': 7.5.2(@babel/core@7.23.3)(graphql@16.6.0) + '@graphql-tools/graphql-tag-pluck': 7.5.2(@babel/core@7.22.5)(graphql@16.6.0) '@graphql-tools/utils': 9.2.1(graphql@16.6.0) globby: 11.1.0 graphql: 16.6.0 @@ -14349,9 +14333,9 @@ snapshots: tslib: 2.6.0 value-or-promise: 1.0.12 - '@graphql-tools/git-loader@7.3.0(@babel/core@7.23.3)(graphql@16.6.0)': + '@graphql-tools/git-loader@7.3.0(@babel/core@7.22.5)(graphql@16.6.0)': dependencies: - '@graphql-tools/graphql-tag-pluck': 7.5.2(@babel/core@7.23.3)(graphql@16.6.0) + '@graphql-tools/graphql-tag-pluck': 7.5.2(@babel/core@7.22.5)(graphql@16.6.0) '@graphql-tools/utils': 9.2.1(graphql@16.6.0) graphql: 16.6.0 is-glob: 4.0.3 @@ -14362,11 +14346,11 @@ snapshots: - '@babel/core' - supports-color - '@graphql-tools/github-loader@7.3.28(@babel/core@7.23.3)(@types/node@20.11.13)(graphql@16.6.0)': + '@graphql-tools/github-loader@7.3.28(@babel/core@7.22.5)(@types/node@20.11.13)(graphql@16.6.0)': dependencies: '@ardatan/sync-fetch': 0.0.1 '@graphql-tools/executor-http': 0.1.10(@types/node@20.11.13)(graphql@16.6.0) - '@graphql-tools/graphql-tag-pluck': 7.5.2(@babel/core@7.23.3)(graphql@16.6.0) + '@graphql-tools/graphql-tag-pluck': 7.5.2(@babel/core@7.22.5)(graphql@16.6.0) '@graphql-tools/utils': 9.2.1(graphql@16.6.0) '@whatwg-node/fetch': 0.8.8 graphql: 16.6.0 @@ -14387,10 +14371,10 @@ snapshots: tslib: 2.6.0 unixify: 1.0.0 - '@graphql-tools/graphql-tag-pluck@7.5.2(@babel/core@7.23.3)(graphql@16.6.0)': + '@graphql-tools/graphql-tag-pluck@7.5.2(@babel/core@7.22.5)(graphql@16.6.0)': dependencies: '@babel/parser': 7.23.9 - '@babel/plugin-syntax-import-assertions': 7.22.5(@babel/core@7.23.3) + '@babel/plugin-syntax-import-assertions': 7.22.5(@babel/core@7.22.5) '@babel/traverse': 7.23.4 '@babel/types': 7.23.9 '@graphql-tools/utils': 9.2.1(graphql@16.6.0) @@ -14592,7 +14576,7 @@ snapshots: jest-util: 28.1.3 slash: 3.0.0 - '@jest/core@27.5.1': + '@jest/core@27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2))': dependencies: '@jest/console': 27.5.1 '@jest/reporters': 27.5.1 @@ -14606,7 +14590,7 @@ snapshots: exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 27.5.1 - jest-config: 27.5.1 + jest-config: 27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)) jest-haste-map: 27.5.1 jest-message-util: 27.5.1 jest-regex-util: 27.5.1 @@ -15135,7 +15119,7 @@ snapshots: picocolors: 1.0.0 tslib: 2.6.0 - '@pmmmwh/react-refresh-webpack-plugin@0.5.10(react-refresh@0.11.0)(webpack-dev-server@4.15.1)(webpack@5.88.0)': + '@pmmmwh/react-refresh-webpack-plugin@0.5.10(react-refresh@0.11.0)(type-fest@3.1.0)(webpack-dev-server@4.15.1(webpack@5.88.0(esbuild@0.17.19)))(webpack@5.88.0(esbuild@0.17.19))': dependencies: ansi-html-community: 0.0.8 common-path-prefix: 3.0.0 @@ -15148,7 +15132,9 @@ snapshots: schema-utils: 3.3.0 source-map: 0.7.4 webpack: 5.88.0(esbuild@0.17.19) - webpack-dev-server: 4.15.1(webpack@5.88.0) + optionalDependencies: + type-fest: 3.1.0 + webpack-dev-server: 4.15.1(webpack@5.88.0(esbuild@0.17.19)) '@pnpm/constants@7.1.1': {} @@ -15241,9 +15227,10 @@ snapshots: progress: 2.0.3 proxy-agent: 6.3.0 tar-fs: 3.0.4 - typescript: 5.2.2 unbzip2-stream: 1.4.3 yargs: 17.7.1 + optionalDependencies: + typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -15266,149 +15253,168 @@ snapshots: '@radix-ui/react-compose-refs@1.0.1(@types/react@18.2.9)(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 - '@types/react': 18.2.9 react: 18.2.0 + optionalDependencies: + '@types/react': 18.2.9 '@radix-ui/react-context@1.0.1(@types/react@18.2.9)(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 - '@types/react': 18.2.9 react: 18.2.0 + optionalDependencies: + '@types/react': 18.2.9 - '@radix-ui/react-dialog@1.0.5(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0)': + '@radix-ui/react-dialog@1.0.5(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 '@radix-ui/primitive': 1.0.1 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.9)(react@18.2.0) '@radix-ui/react-context': 1.0.1(@types/react@18.2.9)(react@18.2.0) - '@radix-ui/react-dismissable-layer': 1.0.5(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-dismissable-layer': 1.0.5(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@radix-ui/react-focus-guards': 1.0.1(@types/react@18.2.9)(react@18.2.0) - '@radix-ui/react-focus-scope': 1.0.4(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-focus-scope': 1.0.4(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@radix-ui/react-id': 1.0.1(@types/react@18.2.9)(react@18.2.0) - '@radix-ui/react-portal': 1.0.4(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0) - '@radix-ui/react-presence': 1.0.1(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0) - '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-portal': 1.0.4(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@radix-ui/react-presence': 1.0.1(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@radix-ui/react-slot': 1.0.2(@types/react@18.2.9)(react@18.2.0) '@radix-ui/react-use-controllable-state': 1.0.1(@types/react@18.2.9)(react@18.2.0) - '@types/react': 18.2.9 - '@types/react-dom': 18.2.4 aria-hidden: 1.2.3 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) react-remove-scroll: 2.5.5(@types/react@18.2.9)(react@18.2.0) + optionalDependencies: + '@types/react': 18.2.9 + '@types/react-dom': 18.2.4 - '@radix-ui/react-dismissable-layer@1.0.5(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0)': + '@radix-ui/react-dismissable-layer@1.0.5(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 '@radix-ui/primitive': 1.0.1 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.9)(react@18.2.0) - '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@radix-ui/react-use-callback-ref': 1.0.1(@types/react@18.2.9)(react@18.2.0) '@radix-ui/react-use-escape-keydown': 1.0.3(@types/react@18.2.9)(react@18.2.0) - '@types/react': 18.2.9 - '@types/react-dom': 18.2.4 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + optionalDependencies: + '@types/react': 18.2.9 + '@types/react-dom': 18.2.4 '@radix-ui/react-focus-guards@1.0.1(@types/react@18.2.9)(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 - '@types/react': 18.2.9 react: 18.2.0 + optionalDependencies: + '@types/react': 18.2.9 - '@radix-ui/react-focus-scope@1.0.4(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0)': + '@radix-ui/react-focus-scope@1.0.4(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.9)(react@18.2.0) - '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@radix-ui/react-use-callback-ref': 1.0.1(@types/react@18.2.9)(react@18.2.0) - '@types/react': 18.2.9 - '@types/react-dom': 18.2.4 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + optionalDependencies: + '@types/react': 18.2.9 + '@types/react-dom': 18.2.4 '@radix-ui/react-id@1.0.1(@types/react@18.2.9)(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 '@radix-ui/react-use-layout-effect': 1.0.1(@types/react@18.2.9)(react@18.2.0) - '@types/react': 18.2.9 react: 18.2.0 + optionalDependencies: + '@types/react': 18.2.9 - '@radix-ui/react-portal@1.0.4(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0)': + '@radix-ui/react-portal@1.0.4(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 - '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0) - '@types/react': 18.2.9 - '@types/react-dom': 18.2.4 + '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + optionalDependencies: + '@types/react': 18.2.9 + '@types/react-dom': 18.2.4 - '@radix-ui/react-presence@1.0.1(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0)': + '@radix-ui/react-presence@1.0.1(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.9)(react@18.2.0) '@radix-ui/react-use-layout-effect': 1.0.1(@types/react@18.2.9)(react@18.2.0) - '@types/react': 18.2.9 - '@types/react-dom': 18.2.4 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + optionalDependencies: + '@types/react': 18.2.9 + '@types/react-dom': 18.2.4 - '@radix-ui/react-primitive@1.0.3(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0)(react@18.2.0)': + '@radix-ui/react-primitive@1.0.3(@types/react-dom@18.2.4)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 '@radix-ui/react-slot': 1.0.2(@types/react@18.2.9)(react@18.2.0) - '@types/react': 18.2.9 - '@types/react-dom': 18.2.4 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) + optionalDependencies: + '@types/react': 18.2.9 + '@types/react-dom': 18.2.4 '@radix-ui/react-slot@1.0.2(@types/react@18.2.9)(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.9)(react@18.2.0) - '@types/react': 18.2.9 react: 18.2.0 + optionalDependencies: + '@types/react': 18.2.9 '@radix-ui/react-use-callback-ref@1.0.1(@types/react@18.2.9)(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 - '@types/react': 18.2.9 react: 18.2.0 + optionalDependencies: + '@types/react': 18.2.9 '@radix-ui/react-use-controllable-state@1.0.1(@types/react@18.2.9)(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 '@radix-ui/react-use-callback-ref': 1.0.1(@types/react@18.2.9)(react@18.2.0) - '@types/react': 18.2.9 react: 18.2.0 + optionalDependencies: + '@types/react': 18.2.9 '@radix-ui/react-use-escape-keydown@1.0.3(@types/react@18.2.9)(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 '@radix-ui/react-use-callback-ref': 1.0.1(@types/react@18.2.9)(react@18.2.0) - '@types/react': 18.2.9 react: 18.2.0 + optionalDependencies: + '@types/react': 18.2.9 '@radix-ui/react-use-layout-effect@1.0.1(@types/react@18.2.9)(react@18.2.0)': dependencies: '@babel/runtime': 7.23.4 - '@types/react': 18.2.9 react: 18.2.0 + optionalDependencies: + '@types/react': 18.2.9 '@repeaterjs/repeater@3.0.4': {} - '@rollup/plugin-babel@5.3.1(@babel/core@7.22.5)(rollup@2.79.1)': + '@rollup/plugin-babel@5.3.1(@babel/core@7.22.5)(@types/babel__core@7.20.1)(rollup@2.79.1)': dependencies: '@babel/core': 7.22.5 '@babel/helper-module-imports': 7.22.5 '@rollup/pluginutils': 3.1.0(rollup@2.79.1) rollup: 2.79.1 + optionalDependencies: + '@types/babel__core': 7.20.1 - '@rollup/plugin-inject@5.0.5': + '@rollup/plugin-inject@5.0.5(rollup@4.9.6)': dependencies: - '@rollup/pluginutils': 5.1.0 + '@rollup/pluginutils': 5.1.0(rollup@4.9.6) estree-walker: 2.0.2 magic-string: 0.30.5 + optionalDependencies: + rollup: 4.9.6 '@rollup/plugin-node-resolve@11.2.1(rollup@2.79.1)': dependencies: @@ -15433,11 +15439,13 @@ snapshots: picomatch: 2.3.1 rollup: 2.79.1 - '@rollup/pluginutils@5.1.0': + '@rollup/pluginutils@5.1.0(rollup@4.9.6)': dependencies: '@types/estree': 1.0.5 estree-walker: 2.0.2 picomatch: 2.3.1 + optionalDependencies: + rollup: 4.9.6 '@rollup/rollup-android-arm-eabi@4.9.6': optional: true @@ -15606,7 +15614,7 @@ snapshots: lz-string: 1.5.0 pretty-format: 27.5.1 - '@testing-library/react@13.4.0(react-dom@18.2.0)(react@18.2.0)': + '@testing-library/react@13.4.0(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@babel/runtime': 7.22.5 '@testing-library/dom': 8.20.1 @@ -16041,7 +16049,7 @@ snapshots: '@types/node': 20.11.13 optional: true - '@typescript-eslint/eslint-plugin@5.59.0(@typescript-eslint/parser@5.59.0)(eslint@8.38.0)(typescript@5.2.2)': + '@typescript-eslint/eslint-plugin@5.59.0(@typescript-eslint/parser@5.59.0(eslint@8.38.0)(typescript@5.2.2))(eslint@8.38.0)(typescript@5.2.2)': dependencies: '@eslint-community/regexpp': 4.5.1 '@typescript-eslint/parser': 5.59.0(eslint@8.38.0)(typescript@5.2.2) @@ -16055,11 +16063,12 @@ snapshots: natural-compare-lite: 1.4.0 semver: 7.3.8 tsutils: 3.21.0(typescript@5.2.2) + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - supports-color - '@typescript-eslint/eslint-plugin@5.59.0(@typescript-eslint/parser@5.59.0)(eslint@8.54.0)(typescript@5.2.2)': + '@typescript-eslint/eslint-plugin@5.59.0(@typescript-eslint/parser@5.59.0(eslint@8.54.0)(typescript@5.2.2))(eslint@8.54.0)(typescript@5.2.2)': dependencies: '@eslint-community/regexpp': 4.5.1 '@typescript-eslint/parser': 5.59.0(eslint@8.54.0)(typescript@5.2.2) @@ -16073,11 +16082,12 @@ snapshots: natural-compare-lite: 1.4.0 semver: 7.3.8 tsutils: 3.21.0(typescript@5.2.2) + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - supports-color - '@typescript-eslint/eslint-plugin@6.9.1(@typescript-eslint/parser@6.9.1)(eslint@8.52.0)(typescript@5.2.2)': + '@typescript-eslint/eslint-plugin@6.9.1(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0)(typescript@5.2.2)': dependencies: '@eslint-community/regexpp': 4.5.1 '@typescript-eslint/parser': 6.9.1(eslint@8.52.0)(typescript@5.2.2) @@ -16092,6 +16102,7 @@ snapshots: natural-compare: 1.4.0 semver: 7.5.4 ts-api-utils: 1.0.3(typescript@5.2.2) + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -16111,6 +16122,7 @@ snapshots: '@typescript-eslint/typescript-estree': 5.59.0(typescript@5.2.2) debug: 4.3.4(supports-color@5.5.0) eslint: 8.38.0 + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -16122,6 +16134,7 @@ snapshots: '@typescript-eslint/typescript-estree': 5.59.0(typescript@5.2.2) debug: 4.3.4(supports-color@5.5.0) eslint: 8.54.0 + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -16134,6 +16147,7 @@ snapshots: '@typescript-eslint/visitor-keys': 6.9.1 debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -16146,6 +16160,7 @@ snapshots: '@typescript-eslint/visitor-keys': 6.9.1 debug: 4.3.4(supports-color@5.5.0) eslint: 8.54.0 + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -16172,6 +16187,7 @@ snapshots: debug: 4.3.4(supports-color@5.5.0) eslint: 8.38.0 tsutils: 3.21.0(typescript@5.2.2) + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -16183,6 +16199,7 @@ snapshots: debug: 4.3.4(supports-color@5.5.0) eslint: 8.54.0 tsutils: 3.21.0(typescript@5.2.2) + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -16194,6 +16211,7 @@ snapshots: debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 ts-api-utils: 1.0.3(typescript@5.2.2) + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -16213,6 +16231,7 @@ snapshots: is-glob: 4.0.3 semver: 7.3.8 tsutils: 3.21.0(typescript@5.2.2) + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -16226,6 +16245,7 @@ snapshots: is-glob: 4.0.3 semver: 7.5.4 tsutils: 3.21.0(typescript@5.2.2) + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -16239,6 +16259,7 @@ snapshots: is-glob: 4.0.3 semver: 7.5.4 ts-api-utils: 1.0.3(typescript@5.2.2) + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -16319,30 +16340,31 @@ snapshots: '@ungap/structured-clone@1.2.0': {} - '@vitejs/plugin-react@4.0.0(vite@4.3.9)': + '@vitejs/plugin-react@4.0.0(vite@4.3.9(@types/node@20.11.13)(terser@5.18.2))': dependencies: '@babel/core': 7.22.5 '@babel/plugin-transform-react-jsx-self': 7.22.5(@babel/core@7.22.5) '@babel/plugin-transform-react-jsx-source': 7.22.5(@babel/core@7.22.5) react-refresh: 0.14.0 - vite: 4.3.9(@types/node@18.15.3) + vite: 4.3.9(@types/node@20.11.13)(terser@5.18.2) transitivePeerDependencies: - supports-color - '@vitejs/plugin-vue@5.0.3(vite@5.0.12)(vue@3.4.15)': + '@vitejs/plugin-vue@5.0.3(vite@5.0.12(@types/node@20.11.13)(terser@5.18.2))(vue@3.4.15(typescript@5.2.2))': dependencies: - vite: 5.0.12(@types/node@18.15.3) + vite: 5.0.12(@types/node@20.11.13)(terser@5.18.2) vue: 3.4.15(typescript@5.2.2) - '@vitest/browser@1.2.1(vitest@1.2.1)(webdriverio@8.32.2)': + '@vitest/browser@1.2.1(vitest@1.2.1)(webdriverio@8.32.2(typescript@5.2.2))': dependencies: '@vitest/utils': 1.2.1 magic-string: 0.30.5 sirv: 2.0.4 - vitest: 1.2.1(@types/node@18.15.3)(@vitest/browser@1.2.1) + vitest: 1.2.1(@types/node@20.11.13)(@vitest/browser@1.2.1)(jsdom@16.7.0)(terser@5.18.2) + optionalDependencies: webdriverio: 8.32.2(typescript@5.2.2) - '@vitest/coverage-istanbul@1.2.1(vitest@1.2.1)': + '@vitest/coverage-istanbul@1.2.1(vitest@1.2.1(@types/node@18.15.3)(@vitest/browser@1.2.1)(jsdom@16.7.0)(terser@5.18.2))': dependencies: debug: 4.3.4(supports-color@5.5.0) istanbul-lib-coverage: 3.2.2 @@ -16353,7 +16375,7 @@ snapshots: magicast: 0.3.3 picocolors: 1.0.0 test-exclude: 6.0.0 - vitest: 1.2.1(@types/node@18.15.3)(@vitest/browser@1.2.1) + vitest: 1.2.1(@types/node@18.15.3)(@vitest/browser@1.2.1)(jsdom@16.7.0)(terser@5.18.2) transitivePeerDependencies: - supports-color @@ -16435,7 +16457,7 @@ snapshots: '@vue/shared': 3.4.15 csstype: 3.1.3 - '@vue/server-renderer@3.4.15(vue@3.4.15)': + '@vue/server-renderer@3.4.15(vue@3.4.15(typescript@5.2.2))': dependencies: '@vue/compiler-ssr': 3.4.15 '@vue/shared': 3.4.15 @@ -16443,31 +16465,33 @@ snapshots: '@vue/shared@3.4.15': {} - '@vueuse/core@10.7.2(vue@3.4.15)': + '@vueuse/core@10.7.2(vue@3.4.15(typescript@5.2.2))': dependencies: '@types/web-bluetooth': 0.0.20 '@vueuse/metadata': 10.7.2 - '@vueuse/shared': 10.7.2(vue@3.4.15) - vue-demi: 0.14.6(vue@3.4.15) + '@vueuse/shared': 10.7.2(vue@3.4.15(typescript@5.2.2)) + vue-demi: 0.14.6(vue@3.4.15(typescript@5.2.2)) transitivePeerDependencies: - '@vue/composition-api' - vue - '@vueuse/integrations@10.7.2(focus-trap@7.5.4)(vue@3.4.15)': + '@vueuse/integrations@10.7.2(change-case@4.1.2)(focus-trap@7.5.4)(vue@3.4.15(typescript@5.2.2))': dependencies: - '@vueuse/core': 10.7.2(vue@3.4.15) - '@vueuse/shared': 10.7.2(vue@3.4.15) + '@vueuse/core': 10.7.2(vue@3.4.15(typescript@5.2.2)) + '@vueuse/shared': 10.7.2(vue@3.4.15(typescript@5.2.2)) + vue-demi: 0.14.6(vue@3.4.15(typescript@5.2.2)) + optionalDependencies: + change-case: 4.1.2 focus-trap: 7.5.4 - vue-demi: 0.14.6(vue@3.4.15) transitivePeerDependencies: - '@vue/composition-api' - vue '@vueuse/metadata@10.7.2': {} - '@vueuse/shared@10.7.2(vue@3.4.15)': + '@vueuse/shared@10.7.2(vue@3.4.15(typescript@5.2.2))': dependencies: - vue-demi: 0.14.6(vue@3.4.15) + vue-demi: 0.14.6(vue@3.4.15(typescript@5.2.2)) transitivePeerDependencies: - '@vue/composition-api' - vue @@ -16706,7 +16730,7 @@ snapshots: indent-string: 4.0.0 ajv-formats@2.1.1(ajv@8.12.0): - dependencies: + optionalDependencies: ajv: 8.12.0 ajv-keywords@3.5.2(ajv@6.12.6): @@ -17042,7 +17066,7 @@ snapshots: transitivePeerDependencies: - supports-color - babel-loader@8.3.0(@babel/core@7.22.5)(webpack@5.88.0): + babel-loader@8.3.0(@babel/core@7.22.5)(webpack@5.88.0(esbuild@0.17.19)): dependencies: '@babel/core': 7.22.5 find-cache-dir: 3.3.2 @@ -17795,14 +17819,14 @@ snapshots: dependencies: '@iarna/toml': 2.2.5 - cosmiconfig-typescript-loader@4.1.1(@types/node@20.11.13)(cosmiconfig@7.0.1)(ts-node@10.9.1)(typescript@5.2.2): + cosmiconfig-typescript-loader@4.1.1(@types/node@20.11.13)(cosmiconfig@7.0.1)(ts-node@10.9.1(@types/node@20.11.13)(typescript@5.2.2))(typescript@5.2.2): dependencies: '@types/node': 20.11.13 cosmiconfig: 7.0.1 ts-node: 10.9.1(@types/node@20.11.13)(typescript@5.2.2) typescript: 5.2.2 - cosmiconfig-typescript-loader@4.1.1(@types/node@20.11.13)(cosmiconfig@7.1.0)(ts-node@10.9.1)(typescript@5.2.2): + cosmiconfig-typescript-loader@4.1.1(@types/node@20.11.13)(cosmiconfig@7.1.0)(ts-node@10.9.1(@types/node@20.11.13)(typescript@5.2.2))(typescript@5.2.2): dependencies: '@types/node': 20.11.13 cosmiconfig: 7.1.0 @@ -17930,7 +17954,7 @@ snapshots: dependencies: hyphenate-style-name: 1.0.4 - css-loader@6.8.1(webpack@5.88.0): + css-loader@6.8.1(webpack@5.88.0(esbuild@0.17.19)): dependencies: icss-utils: 5.1.0(postcss@8.4.33) postcss: 8.4.33 @@ -17942,16 +17966,17 @@ snapshots: semver: 7.5.4 webpack: 5.88.0(esbuild@0.17.19) - css-minimizer-webpack-plugin@3.4.1(esbuild@0.17.19)(webpack@5.88.0): + css-minimizer-webpack-plugin@3.4.1(esbuild@0.17.19)(webpack@5.88.0(esbuild@0.17.19)): dependencies: cssnano: 5.1.15(postcss@8.4.33) - esbuild: 0.17.19 jest-worker: 27.5.1 postcss: 8.4.33 schema-utils: 4.2.0 serialize-javascript: 6.0.1 source-map: 0.6.1 webpack: 5.88.0(esbuild@0.17.19) + optionalDependencies: + esbuild: 0.17.19 css-prefers-color-scheme@6.0.3(postcss@8.4.33): dependencies: @@ -18098,6 +18123,7 @@ snapshots: debug@4.3.4(supports-color@5.5.0): dependencies: ms: 2.1.2 + optionalDependencies: supports-color: 5.5.0 decamelize-keys@1.1.1: @@ -18656,22 +18682,22 @@ snapshots: optionalDependencies: source-map: 0.6.1 - eslint-config-airbnb-base@15.0.0(eslint-plugin-import@2.29.0)(eslint@8.52.0): + eslint-config-airbnb-base@15.0.0(eslint-plugin-import@2.29.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0))(eslint@8.52.0): dependencies: confusing-browser-globals: 1.0.11 eslint: 8.52.0 - eslint-plugin-import: 2.29.0(@typescript-eslint/parser@6.9.1)(eslint@8.52.0) + eslint-plugin-import: 2.29.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0) object.assign: 4.1.4 object.entries: 1.1.6 semver: 6.3.0 - eslint-config-airbnb-typescript@17.1.0(@typescript-eslint/eslint-plugin@6.9.1)(@typescript-eslint/parser@6.9.1)(eslint-plugin-import@2.29.0)(eslint@8.52.0): + eslint-config-airbnb-typescript@17.1.0(@typescript-eslint/eslint-plugin@6.9.1(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0)(typescript@5.2.2))(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint-plugin-import@2.29.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0))(eslint@8.52.0): dependencies: - '@typescript-eslint/eslint-plugin': 6.9.1(@typescript-eslint/parser@6.9.1)(eslint@8.52.0)(typescript@5.2.2) + '@typescript-eslint/eslint-plugin': 6.9.1(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0)(typescript@5.2.2) '@typescript-eslint/parser': 6.9.1(eslint@8.52.0)(typescript@5.2.2) eslint: 8.52.0 - eslint-config-airbnb-base: 15.0.0(eslint-plugin-import@2.29.0)(eslint@8.52.0) - eslint-plugin-import: 2.29.0(@typescript-eslint/parser@6.9.1)(eslint@8.52.0) + eslint-config-airbnb-base: 15.0.0(eslint-plugin-import@2.29.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0))(eslint@8.52.0) + eslint-plugin-import: 2.29.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0) eslint-config-next@14.0.1(eslint@8.54.0)(typescript@5.2.2): dependencies: @@ -18680,11 +18706,12 @@ snapshots: '@typescript-eslint/parser': 6.9.1(eslint@8.54.0)(typescript@5.2.2) eslint: 8.54.0 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@6.9.1)(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0)(eslint@8.54.0) - eslint-plugin-import: 2.29.0(@typescript-eslint/parser@6.9.1)(eslint@8.54.0) + eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@6.9.1(eslint@8.54.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0)(eslint@8.54.0) + eslint-plugin-import: 2.29.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.54.0) eslint-plugin-jsx-a11y: 6.7.1(eslint@8.54.0) eslint-plugin-react: 7.33.2(eslint@8.54.0) eslint-plugin-react-hooks: 4.6.0(eslint@8.54.0) + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - eslint-import-resolver-webpack @@ -18694,23 +18721,24 @@ snapshots: dependencies: eslint: 8.52.0 - eslint-config-react-app@7.0.1(@babel/plugin-syntax-flow@7.23.3)(@babel/plugin-transform-react-jsx@7.23.4)(eslint@8.54.0)(jest@27.5.1)(typescript@5.2.2): + eslint-config-react-app@7.0.1(@babel/plugin-syntax-flow@7.23.3(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.23.4(@babel/core@7.22.5))(eslint@8.54.0)(jest@27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)))(typescript@5.2.2): dependencies: '@babel/core': 7.22.5 '@babel/eslint-parser': 7.22.5(@babel/core@7.22.5)(eslint@8.54.0) '@rushstack/eslint-patch': 1.3.2 - '@typescript-eslint/eslint-plugin': 5.59.0(@typescript-eslint/parser@5.59.0)(eslint@8.54.0)(typescript@5.2.2) + '@typescript-eslint/eslint-plugin': 5.59.0(@typescript-eslint/parser@5.59.0(eslint@8.54.0)(typescript@5.2.2))(eslint@8.54.0)(typescript@5.2.2) '@typescript-eslint/parser': 5.59.0(eslint@8.54.0)(typescript@5.2.2) babel-preset-react-app: 10.0.1 confusing-browser-globals: 1.0.11 eslint: 8.54.0 - eslint-plugin-flowtype: 8.0.3(@babel/plugin-syntax-flow@7.23.3)(@babel/plugin-transform-react-jsx@7.23.4)(eslint@8.54.0) - eslint-plugin-import: 2.26.0(@typescript-eslint/parser@5.59.0)(eslint@8.54.0) - eslint-plugin-jest: 25.7.0(@typescript-eslint/eslint-plugin@5.59.0)(eslint@8.54.0)(jest@27.5.1)(typescript@5.2.2) + eslint-plugin-flowtype: 8.0.3(@babel/plugin-syntax-flow@7.23.3(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.23.4(@babel/core@7.22.5))(eslint@8.54.0) + eslint-plugin-import: 2.26.0(@typescript-eslint/parser@5.59.0(eslint@8.54.0)(typescript@5.2.2))(eslint@8.54.0) + eslint-plugin-jest: 25.7.0(@typescript-eslint/eslint-plugin@5.59.0(@typescript-eslint/parser@5.59.0(eslint@8.54.0)(typescript@5.2.2))(eslint@8.54.0)(typescript@5.2.2))(eslint@8.54.0)(jest@27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)))(typescript@5.2.2) eslint-plugin-jsx-a11y: 6.6.1(eslint@8.54.0) eslint-plugin-react: 7.31.10(eslint@8.54.0) eslint-plugin-react-hooks: 4.6.0(eslint@8.54.0) eslint-plugin-testing-library: 5.11.0(eslint@8.54.0)(typescript@5.2.2) + optionalDependencies: typescript: 5.2.2 transitivePeerDependencies: - '@babel/plugin-syntax-flow' @@ -18736,13 +18764,13 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.9.1)(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0)(eslint@8.54.0): + eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.9.1(eslint@8.54.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0)(eslint@8.54.0): dependencies: debug: 4.3.4(supports-color@5.5.0) enhanced-resolve: 5.15.0 eslint: 8.54.0 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.9.1)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.54.0) - eslint-plugin-import: 2.29.0(@typescript-eslint/parser@6.9.1)(eslint@8.54.0) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.9.1(eslint@8.54.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.9.1(eslint@8.54.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0)(eslint@8.54.0))(eslint@8.54.0) + eslint-plugin-import: 2.29.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.54.0) fast-glob: 3.3.1 get-tsconfig: 4.7.2 is-core-module: 2.13.1 @@ -18753,40 +18781,44 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-module-utils@2.8.0(@typescript-eslint/parser@5.59.0)(eslint-import-resolver-node@0.3.7)(eslint@8.54.0): + eslint-module-utils@2.8.0(@typescript-eslint/parser@5.59.0(eslint@8.54.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.7)(eslint@8.54.0): dependencies: - '@typescript-eslint/parser': 5.59.0(eslint@8.54.0)(typescript@5.2.2) debug: 3.2.7 + optionalDependencies: + '@typescript-eslint/parser': 5.59.0(eslint@8.54.0)(typescript@5.2.2) eslint: 8.54.0 eslint-import-resolver-node: 0.3.7 transitivePeerDependencies: - supports-color - eslint-module-utils@2.8.0(@typescript-eslint/parser@6.9.1)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.54.0): + eslint-module-utils@2.8.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint@8.52.0): dependencies: - '@typescript-eslint/parser': 6.9.1(eslint@8.54.0)(typescript@5.2.2) debug: 3.2.7 - eslint: 8.54.0 + optionalDependencies: + '@typescript-eslint/parser': 6.9.1(eslint@8.52.0)(typescript@5.2.2) + eslint: 8.52.0 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@6.9.1)(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0)(eslint@8.54.0) transitivePeerDependencies: - supports-color - eslint-module-utils@2.8.0(@typescript-eslint/parser@6.9.1)(eslint-import-resolver-node@0.3.9)(eslint@8.52.0): + eslint-module-utils@2.8.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint@8.54.0): dependencies: - '@typescript-eslint/parser': 6.9.1(eslint@8.52.0)(typescript@5.2.2) debug: 3.2.7 - eslint: 8.52.0 + optionalDependencies: + '@typescript-eslint/parser': 6.9.1(eslint@8.52.0)(typescript@5.2.2) + eslint: 8.54.0 eslint-import-resolver-node: 0.3.9 transitivePeerDependencies: - supports-color - eslint-module-utils@2.8.0(@typescript-eslint/parser@6.9.1)(eslint-import-resolver-node@0.3.9)(eslint@8.54.0): + eslint-module-utils@2.8.0(@typescript-eslint/parser@6.9.1(eslint@8.54.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.9.1(eslint@8.54.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0)(eslint@8.54.0))(eslint@8.54.0): dependencies: - '@typescript-eslint/parser': 6.9.1(eslint@8.52.0)(typescript@5.2.2) debug: 3.2.7 + optionalDependencies: + '@typescript-eslint/parser': 6.9.1(eslint@8.54.0)(typescript@5.2.2) eslint: 8.54.0 eslint-import-resolver-node: 0.3.9 + eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@6.9.1(eslint@8.54.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0)(eslint@8.54.0) transitivePeerDependencies: - supports-color @@ -18796,7 +18828,7 @@ snapshots: eslint: 8.52.0 ignore: 5.2.4 - eslint-plugin-flowtype@8.0.3(@babel/plugin-syntax-flow@7.23.3)(@babel/plugin-transform-react-jsx@7.23.4)(eslint@8.54.0): + eslint-plugin-flowtype@8.0.3(@babel/plugin-syntax-flow@7.23.3(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.23.4(@babel/core@7.22.5))(eslint@8.54.0): dependencies: '@babel/plugin-syntax-flow': 7.23.3(@babel/core@7.22.5) '@babel/plugin-transform-react-jsx': 7.23.4(@babel/core@7.22.5) @@ -18804,16 +18836,15 @@ snapshots: lodash: 4.17.21 string-natural-compare: 3.0.1 - eslint-plugin-import@2.26.0(@typescript-eslint/parser@5.59.0)(eslint@8.54.0): + eslint-plugin-import@2.26.0(@typescript-eslint/parser@5.59.0(eslint@8.54.0)(typescript@5.2.2))(eslint@8.54.0): dependencies: - '@typescript-eslint/parser': 5.59.0(eslint@8.54.0)(typescript@5.2.2) array-includes: 3.1.6 array.prototype.flat: 1.3.1 debug: 2.6.9 doctrine: 2.1.0 eslint: 8.54.0 eslint-import-resolver-node: 0.3.7 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.59.0)(eslint-import-resolver-node@0.3.7)(eslint@8.54.0) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.59.0(eslint@8.54.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.7)(eslint@8.54.0) has: 1.0.3 is-core-module: 2.12.1 is-glob: 4.0.3 @@ -18821,14 +18852,15 @@ snapshots: object.values: 1.1.6 resolve: 1.22.2 tsconfig-paths: 3.14.2 + optionalDependencies: + '@typescript-eslint/parser': 5.59.0(eslint@8.54.0)(typescript@5.2.2) transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack - supports-color - eslint-plugin-import@2.29.0(@typescript-eslint/parser@6.9.1)(eslint@8.52.0): + eslint-plugin-import@2.29.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.52.0): dependencies: - '@typescript-eslint/parser': 6.9.1(eslint@8.52.0)(typescript@5.2.2) array-includes: 3.1.7 array.prototype.findlastindex: 1.2.3 array.prototype.flat: 1.3.2 @@ -18837,7 +18869,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.52.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.9.1)(eslint-import-resolver-node@0.3.9)(eslint@8.52.0) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint@8.52.0) hasown: 2.0.0 is-core-module: 2.13.1 is-glob: 4.0.3 @@ -18847,14 +18879,15 @@ snapshots: object.values: 1.1.7 semver: 6.3.1 tsconfig-paths: 3.14.2 + optionalDependencies: + '@typescript-eslint/parser': 6.9.1(eslint@8.52.0)(typescript@5.2.2) transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack - supports-color - eslint-plugin-import@2.29.0(@typescript-eslint/parser@6.9.1)(eslint@8.54.0): + eslint-plugin-import@2.29.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint@8.54.0): dependencies: - '@typescript-eslint/parser': 6.9.1(eslint@8.52.0)(typescript@5.2.2) array-includes: 3.1.7 array.prototype.findlastindex: 1.2.3 array.prototype.flat: 1.3.2 @@ -18863,7 +18896,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.54.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.9.1)(eslint-import-resolver-node@0.3.9)(eslint@8.54.0) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.9.1(eslint@8.52.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint@8.54.0) hasown: 2.0.0 is-core-module: 2.13.1 is-glob: 4.0.3 @@ -18873,17 +18906,20 @@ snapshots: object.values: 1.1.7 semver: 6.3.1 tsconfig-paths: 3.14.2 + optionalDependencies: + '@typescript-eslint/parser': 6.9.1(eslint@8.52.0)(typescript@5.2.2) transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack - supports-color - eslint-plugin-jest@25.7.0(@typescript-eslint/eslint-plugin@5.59.0)(eslint@8.54.0)(jest@27.5.1)(typescript@5.2.2): + eslint-plugin-jest@25.7.0(@typescript-eslint/eslint-plugin@5.59.0(@typescript-eslint/parser@5.59.0(eslint@8.54.0)(typescript@5.2.2))(eslint@8.54.0)(typescript@5.2.2))(eslint@8.54.0)(jest@27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)))(typescript@5.2.2): dependencies: - '@typescript-eslint/eslint-plugin': 5.59.0(@typescript-eslint/parser@5.59.0)(eslint@8.54.0)(typescript@5.2.2) '@typescript-eslint/experimental-utils': 5.60.1(eslint@8.54.0)(typescript@5.2.2) eslint: 8.54.0 - jest: 27.5.1 + optionalDependencies: + '@typescript-eslint/eslint-plugin': 5.59.0(@typescript-eslint/parser@5.59.0(eslint@8.54.0)(typescript@5.2.2))(eslint@8.54.0)(typescript@5.2.2) + jest: 27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)) transitivePeerDependencies: - supports-color - typescript @@ -18960,13 +18996,15 @@ snapshots: object.fromentries: 2.0.7 semver: 6.3.1 - eslint-plugin-prettier@5.0.1(eslint-config-prettier@9.0.0)(eslint@8.52.0)(prettier@3.0.3): + eslint-plugin-prettier@5.0.1(@types/eslint@8.40.2)(eslint-config-prettier@9.0.0(eslint@8.52.0))(eslint@8.52.0)(prettier@3.0.3): dependencies: eslint: 8.52.0 - eslint-config-prettier: 9.0.0(eslint@8.52.0) prettier: 3.0.3 prettier-linter-helpers: 1.0.0 synckit: 0.8.5 + optionalDependencies: + '@types/eslint': 8.40.2 + eslint-config-prettier: 9.0.0(eslint@8.52.0) eslint-plugin-react-hooks@4.6.0(eslint@8.38.0): dependencies: @@ -19076,7 +19114,7 @@ snapshots: eslint-visitor-keys@3.4.3: {} - eslint-webpack-plugin@3.2.0(eslint@8.54.0)(webpack@5.88.0): + eslint-webpack-plugin@3.2.0(eslint@8.54.0)(webpack@5.88.0(esbuild@0.17.19)): dependencies: '@types/eslint': 8.40.2 eslint: 8.54.0 @@ -19495,7 +19533,7 @@ snapshots: dependencies: flat-cache: 3.0.4 - file-loader@6.2.0(webpack@5.88.0): + file-loader@6.2.0(webpack@5.88.0(esbuild@0.17.19)): dependencies: loader-utils: 2.0.4 schema-utils: 3.3.0 @@ -19593,7 +19631,7 @@ snapshots: cross-spawn: 7.0.3 signal-exit: 4.1.0 - fork-ts-checker-webpack-plugin@6.5.3(eslint@8.54.0)(typescript@5.2.2)(webpack@5.88.0): + fork-ts-checker-webpack-plugin@6.5.3(eslint@8.54.0)(typescript@5.2.2)(webpack@5.88.0(esbuild@0.17.19)): dependencies: '@babel/code-frame': 7.22.5 '@types/json-schema': 7.0.12 @@ -19601,7 +19639,6 @@ snapshots: chokidar: 3.5.3 cosmiconfig: 6.0.0 deepmerge: 4.3.1 - eslint: 8.54.0 fs-extra: 9.1.0 glob: 7.2.3 memfs: 3.5.3 @@ -19611,6 +19648,8 @@ snapshots: tapable: 1.1.3 typescript: 5.2.2 webpack: 5.88.0(esbuild@0.17.19) + optionalDependencies: + eslint: 8.54.0 form-data-encoder@1.9.0: {} @@ -19904,7 +19943,7 @@ snapshots: '@graphql-tools/utils': 8.13.1(graphql@16.6.0) cosmiconfig: 7.0.1 cosmiconfig-toml-loader: 1.0.0 - cosmiconfig-typescript-loader: 4.1.1(@types/node@20.11.13)(cosmiconfig@7.0.1)(ts-node@10.9.1)(typescript@5.2.2) + cosmiconfig-typescript-loader: 4.1.1(@types/node@20.11.13)(cosmiconfig@7.0.1)(ts-node@10.9.1(@types/node@20.11.13)(typescript@5.2.2))(typescript@5.2.2) graphql: 16.6.0 minimatch: 4.2.1 string-env-interpolation: 1.0.1 @@ -20065,7 +20104,7 @@ snapshots: relateurl: 0.2.7 terser: 5.18.2 - html-webpack-plugin@5.5.3(webpack@5.88.0): + html-webpack-plugin@5.5.3(webpack@5.88.0(esbuild@0.17.19)): dependencies: '@types/html-minifier-terser': 6.1.0 html-minifier-terser: 6.1.0 @@ -20126,12 +20165,13 @@ snapshots: http-proxy-middleware@2.0.6(@types/express@4.17.17): dependencies: - '@types/express': 4.17.17 '@types/http-proxy': 1.17.11 http-proxy: 1.18.1 is-glob: 4.0.3 is-plain-obj: 3.0.0 micromatch: 4.0.5 + optionalDependencies: + '@types/express': 4.17.17 transitivePeerDependencies: - debug @@ -20647,16 +20687,16 @@ snapshots: transitivePeerDependencies: - supports-color - jest-cli@27.5.1: + jest-cli@27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)): dependencies: - '@jest/core': 27.5.1 + '@jest/core': 27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)) '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 import-local: 3.1.0 - jest-config: 27.5.1 + jest-config: 27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)) jest-util: 27.5.1 jest-validate: 27.5.1 prompts: 2.4.2 @@ -20668,7 +20708,7 @@ snapshots: - ts-node - utf-8-validate - jest-config@27.5.1: + jest-config@27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)): dependencies: '@babel/core': 7.23.3 '@jest/test-sequencer': 27.5.1 @@ -20694,6 +20734,8 @@ snapshots: pretty-format: 27.5.1 slash: 3.0.0 strip-json-comments: 3.1.1 + optionalDependencies: + ts-node: 10.9.1(@types/node@16.18.34)(typescript@5.2.2) transitivePeerDependencies: - bufferutil - canvas @@ -20854,7 +20896,7 @@ snapshots: '@types/node': 20.11.13 jest-pnp-resolver@1.2.3(jest-resolve@27.5.1): - dependencies: + optionalDependencies: jest-resolve: 27.5.1 jest-regex-util@27.5.1: {} @@ -21006,11 +21048,11 @@ snapshots: leven: 3.1.0 pretty-format: 27.5.1 - jest-watch-typeahead@1.1.0(jest@27.5.1): + jest-watch-typeahead@1.1.0(jest@27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2))): dependencies: ansi-escapes: 4.3.2 chalk: 4.1.2 - jest: 27.5.1 + jest: 27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)) jest-regex-util: 28.0.2 jest-watcher: 28.1.3 slash: 4.0.0 @@ -21056,11 +21098,11 @@ snapshots: merge-stream: 2.0.0 supports-color: 8.1.1 - jest@27.5.1: + jest@27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)): dependencies: - '@jest/core': 27.5.1 + '@jest/core': 27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)) import-local: 3.1.0 - jest-cli: 27.5.1 + jest-cli: 27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)) transitivePeerDependencies: - bufferutil - canvas @@ -21281,7 +21323,7 @@ snapshots: listenercount@1.0.1: {} - listr2@4.0.5: + listr2@4.0.5(enquirer@2.3.6): dependencies: cli-truncate: 2.1.0 colorette: 2.0.20 @@ -21291,6 +21333,8 @@ snapshots: rxjs: 7.8.1 through: 2.3.8 wrap-ansi: 7.0.0 + optionalDependencies: + enquirer: 2.3.6 load-json-file@1.1.0: dependencies: @@ -21652,7 +21696,7 @@ snapshots: merge2@1.4.1: {} meros@1.3.0(@types/node@20.11.13): - dependencies: + optionalDependencies: '@types/node': 20.11.13 methods@1.1.2: {} @@ -21741,7 +21785,7 @@ snapshots: min-indent@1.0.1: {} - mini-css-extract-plugin@2.7.6(webpack@5.88.0): + mini-css-extract-plugin@2.7.6(webpack@5.88.0(esbuild@0.17.19)): dependencies: schema-utils: 4.2.0 webpack: 5.88.0(esbuild@0.17.19) @@ -21830,7 +21874,7 @@ snapshots: n12@1.8.16: {} - nano-css@5.6.1(react-dom@18.2.0)(react@18.2.0): + nano-css@5.6.1(react-dom@18.2.0(react@18.2.0))(react@18.2.0): dependencies: '@jridgewell/sourcemap-codec': 1.4.15 css-tree: 1.1.3 @@ -21867,7 +21911,7 @@ snapshots: netmask@2.0.2: {} - next@13.4.4(@babel/core@7.23.3)(react-dom@18.2.0)(react@18.2.0): + next@13.4.4(@babel/core@7.23.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0): dependencies: '@next/env': 13.4.4 '@swc/helpers': 0.5.1 @@ -21892,7 +21936,7 @@ snapshots: - '@babel/core' - babel-plugin-macros - next@14.0.1(@babel/core@7.23.3)(react-dom@18.2.0)(react@18.2.0): + next@14.0.1(@babel/core@7.23.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0): dependencies: '@next/env': 14.0.1 '@swc/helpers': 0.5.2 @@ -21917,7 +21961,7 @@ snapshots: - '@babel/core' - babel-plugin-macros - next@14.1.0(@babel/core@7.23.3)(react-dom@18.2.0)(react@18.2.0): + next@14.1.0(@babel/core@7.23.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0): dependencies: '@next/env': 14.1.0 '@swc/helpers': 0.5.2 @@ -21951,10 +21995,6 @@ snapshots: node-domexception@1.0.0: {} - node-fetch@2.6.7: - dependencies: - whatwg-url: 5.0.0 - node-fetch@2.7.0: dependencies: whatwg-url: 5.0.0 @@ -22725,18 +22765,39 @@ snapshots: postcss: 8.4.33 postcss-value-parser: 4.2.0 - postcss-load-config@3.1.4: + postcss-load-config@3.1.4(postcss@8.4.33)(ts-node@10.9.1(@types/node@18.15.3)(typescript@5.2.2)): dependencies: lilconfig: 2.1.0 yaml: 1.10.2 + optionalDependencies: + postcss: 8.4.33 + ts-node: 10.9.1(@types/node@18.15.3)(typescript@5.2.2) - postcss-load-config@4.0.1(postcss@8.4.33): + postcss-load-config@4.0.1(postcss@8.4.33)(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)): dependencies: lilconfig: 2.1.0 + yaml: 2.3.1 + optionalDependencies: postcss: 8.4.33 + ts-node: 10.9.1(@types/node@16.18.34)(typescript@5.2.2) + + postcss-load-config@4.0.1(postcss@8.4.33)(ts-node@10.9.1(@types/node@20.10.5)(typescript@5.2.2)): + dependencies: + lilconfig: 2.1.0 + yaml: 2.3.1 + optionalDependencies: + postcss: 8.4.33 + ts-node: 10.9.1(@types/node@20.10.5)(typescript@5.2.2) + + postcss-load-config@4.0.1(postcss@8.4.33)(ts-node@10.9.1(@types/node@20.11.13)(typescript@5.2.2)): + dependencies: + lilconfig: 2.1.0 yaml: 2.3.1 + optionalDependencies: + postcss: 8.4.33 + ts-node: 10.9.1(@types/node@20.11.13)(typescript@5.2.2) - postcss-loader@6.2.1(postcss@8.4.33)(webpack@5.88.0): + postcss-loader@6.2.1(postcss@8.4.33)(webpack@5.88.0(esbuild@0.17.19)): dependencies: cosmiconfig: 7.1.0 klona: 2.0.6 @@ -23180,8 +23241,9 @@ snapshots: cross-fetch: 4.0.0 debug: 4.3.4(supports-color@5.5.0) devtools-protocol: 0.0.1147663 - typescript: 5.2.2 ws: 8.13.0 + optionalDependencies: + typescript: 5.2.2 transitivePeerDependencies: - bufferutil - encoding @@ -23266,7 +23328,7 @@ snapshots: regenerator-runtime: 0.13.11 whatwg-fetch: 3.6.2 - react-dev-utils@12.0.1(eslint@8.54.0)(typescript@5.2.2)(webpack@5.88.0): + react-dev-utils@12.0.1(eslint@8.54.0)(typescript@5.2.2)(webpack@5.88.0(esbuild@0.17.19)): dependencies: '@babel/code-frame': 7.22.5 address: 1.2.2 @@ -23277,7 +23339,7 @@ snapshots: escape-string-regexp: 4.0.0 filesize: 8.0.7 find-up: 5.0.0 - fork-ts-checker-webpack-plugin: 6.5.3(eslint@8.54.0)(typescript@5.2.2)(webpack@5.88.0) + fork-ts-checker-webpack-plugin: 6.5.3(eslint@8.54.0)(typescript@5.2.2)(webpack@5.88.0(esbuild@0.17.19)) global-modules: 2.0.0 globby: 11.1.0 gzip-size: 6.0.0 @@ -23292,8 +23354,9 @@ snapshots: shell-quote: 1.8.1 strip-ansi: 6.0.1 text-table: 0.2.0 - typescript: 5.2.2 webpack: 5.88.0(esbuild@0.17.19) + optionalDependencies: + typescript: 5.2.2 transitivePeerDependencies: - eslint - supports-color @@ -23307,7 +23370,7 @@ snapshots: react-error-overlay@6.0.11: {} - react-hot-toast@2.4.1(csstype@3.1.3)(react-dom@18.2.0)(react@18.2.0): + react-hot-toast@2.4.1(csstype@3.1.3)(react-dom@18.2.0(react@18.2.0))(react@18.2.0): dependencies: goober: 2.1.14(csstype@3.1.3) react: 18.2.0 @@ -23327,74 +23390,76 @@ snapshots: react-remove-scroll-bar@2.3.5(@types/react@18.2.9)(react@18.2.0): dependencies: - '@types/react': 18.2.9 react: 18.2.0 react-style-singleton: 2.2.1(@types/react@18.2.9)(react@18.2.0) tslib: 2.6.0 + optionalDependencies: + '@types/react': 18.2.9 react-remove-scroll@2.5.5(@types/react@18.2.9)(react@18.2.0): dependencies: - '@types/react': 18.2.9 react: 18.2.0 react-remove-scroll-bar: 2.3.5(@types/react@18.2.9)(react@18.2.0) react-style-singleton: 2.2.1(@types/react@18.2.9)(react@18.2.0) tslib: 2.6.0 use-callback-ref: 1.3.1(@types/react@18.2.9)(react@18.2.0) use-sidecar: 1.1.2(@types/react@18.2.9)(react@18.2.0) + optionalDependencies: + '@types/react': 18.2.9 - react-scripts@5.0.1(@babel/plugin-syntax-flow@7.23.3)(@babel/plugin-transform-react-jsx@7.23.4)(esbuild@0.17.19)(eslint@8.54.0)(react@18.2.0)(typescript@5.2.2): + react-scripts@5.0.1(@babel/plugin-syntax-flow@7.23.3(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.23.4(@babel/core@7.22.5))(@types/babel__core@7.20.1)(esbuild@0.17.19)(eslint@8.54.0)(react@18.2.0)(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2))(type-fest@3.1.0)(typescript@5.2.2): dependencies: '@babel/core': 7.22.5 - '@pmmmwh/react-refresh-webpack-plugin': 0.5.10(react-refresh@0.11.0)(webpack-dev-server@4.15.1)(webpack@5.88.0) + '@pmmmwh/react-refresh-webpack-plugin': 0.5.10(react-refresh@0.11.0)(type-fest@3.1.0)(webpack-dev-server@4.15.1(webpack@5.88.0(esbuild@0.17.19)))(webpack@5.88.0(esbuild@0.17.19)) '@svgr/webpack': 5.5.0 babel-jest: 27.5.1(@babel/core@7.22.5) - babel-loader: 8.3.0(@babel/core@7.22.5)(webpack@5.88.0) + babel-loader: 8.3.0(@babel/core@7.22.5)(webpack@5.88.0(esbuild@0.17.19)) babel-plugin-named-asset-import: 0.3.8(@babel/core@7.22.5) babel-preset-react-app: 10.0.1 bfj: 7.0.2 browserslist: 4.21.9 camelcase: 6.3.0 case-sensitive-paths-webpack-plugin: 2.4.0 - css-loader: 6.8.1(webpack@5.88.0) - css-minimizer-webpack-plugin: 3.4.1(esbuild@0.17.19)(webpack@5.88.0) + css-loader: 6.8.1(webpack@5.88.0(esbuild@0.17.19)) + css-minimizer-webpack-plugin: 3.4.1(esbuild@0.17.19)(webpack@5.88.0(esbuild@0.17.19)) dotenv: 10.0.0 dotenv-expand: 5.1.0 eslint: 8.54.0 - eslint-config-react-app: 7.0.1(@babel/plugin-syntax-flow@7.23.3)(@babel/plugin-transform-react-jsx@7.23.4)(eslint@8.54.0)(jest@27.5.1)(typescript@5.2.2) - eslint-webpack-plugin: 3.2.0(eslint@8.54.0)(webpack@5.88.0) - file-loader: 6.2.0(webpack@5.88.0) + eslint-config-react-app: 7.0.1(@babel/plugin-syntax-flow@7.23.3(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.23.4(@babel/core@7.22.5))(eslint@8.54.0)(jest@27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)))(typescript@5.2.2) + eslint-webpack-plugin: 3.2.0(eslint@8.54.0)(webpack@5.88.0(esbuild@0.17.19)) + file-loader: 6.2.0(webpack@5.88.0(esbuild@0.17.19)) fs-extra: 10.1.0 - html-webpack-plugin: 5.5.3(webpack@5.88.0) + html-webpack-plugin: 5.5.3(webpack@5.88.0(esbuild@0.17.19)) identity-obj-proxy: 3.0.0 - jest: 27.5.1 + jest: 27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)) jest-resolve: 27.5.1 - jest-watch-typeahead: 1.1.0(jest@27.5.1) - mini-css-extract-plugin: 2.7.6(webpack@5.88.0) + jest-watch-typeahead: 1.1.0(jest@27.5.1(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2))) + mini-css-extract-plugin: 2.7.6(webpack@5.88.0(esbuild@0.17.19)) postcss: 8.4.33 postcss-flexbugs-fixes: 5.0.2(postcss@8.4.33) - postcss-loader: 6.2.1(postcss@8.4.33)(webpack@5.88.0) + postcss-loader: 6.2.1(postcss@8.4.33)(webpack@5.88.0(esbuild@0.17.19)) postcss-normalize: 10.0.1(browserslist@4.21.9)(postcss@8.4.33) postcss-preset-env: 7.8.3(postcss@8.4.33) prompts: 2.4.2 react: 18.2.0 react-app-polyfill: 3.0.0 - react-dev-utils: 12.0.1(eslint@8.54.0)(typescript@5.2.2)(webpack@5.88.0) + react-dev-utils: 12.0.1(eslint@8.54.0)(typescript@5.2.2)(webpack@5.88.0(esbuild@0.17.19)) react-refresh: 0.11.0 resolve: 1.22.2 resolve-url-loader: 4.0.0 - sass-loader: 12.6.0(webpack@5.88.0) + sass-loader: 12.6.0(webpack@5.88.0(esbuild@0.17.19)) semver: 7.3.8 - source-map-loader: 3.0.2(webpack@5.88.0) - style-loader: 3.3.3(webpack@5.88.0) - tailwindcss: 3.3.2 - terser-webpack-plugin: 5.3.9(esbuild@0.17.19)(webpack@5.88.0) - typescript: 5.2.2 + source-map-loader: 3.0.2(webpack@5.88.0(esbuild@0.17.19)) + style-loader: 3.3.3(webpack@5.88.0(esbuild@0.17.19)) + tailwindcss: 3.3.2(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)) + terser-webpack-plugin: 5.3.9(esbuild@0.17.19)(webpack@5.88.0(esbuild@0.17.19)) webpack: 5.88.0(esbuild@0.17.19) - webpack-dev-server: 4.15.1(webpack@5.88.0) - webpack-manifest-plugin: 4.1.1(webpack@5.88.0) - workbox-webpack-plugin: 6.6.0(webpack@5.88.0) + webpack-dev-server: 4.15.1(webpack@5.88.0(esbuild@0.17.19)) + webpack-manifest-plugin: 4.1.1(webpack@5.88.0(esbuild@0.17.19)) + workbox-webpack-plugin: 6.6.0(@types/babel__core@7.20.1)(webpack@5.88.0(esbuild@0.17.19)) optionalDependencies: fsevents: 2.3.3 + typescript: 5.2.2 transitivePeerDependencies: - '@babel/plugin-syntax-flow' - '@babel/plugin-transform-react-jsx' @@ -23430,18 +23495,19 @@ snapshots: react-style-singleton@2.2.1(@types/react@18.2.9)(react@18.2.0): dependencies: - '@types/react': 18.2.9 get-nonce: 1.0.1 invariant: 2.2.4 react: 18.2.0 tslib: 2.6.0 + optionalDependencies: + '@types/react': 18.2.9 react-universal-interface@0.6.2(react@18.2.0)(tslib@2.6.0): dependencies: react: 18.2.0 tslib: 2.6.0 - react-use@17.5.0(react-dom@18.2.0)(react@18.2.0): + react-use@17.5.0(react-dom@18.2.0(react@18.2.0))(react@18.2.0): dependencies: '@types/js-cookie': 2.2.7 '@xobotyi/scrollbar-width': 1.9.5 @@ -23449,7 +23515,7 @@ snapshots: fast-deep-equal: 3.1.3 fast-shallow-equal: 1.0.0 js-cookie: 2.2.1 - nano-css: 5.6.1(react-dom@18.2.0)(react@18.2.0) + nano-css: 5.6.1(react-dom@18.2.0(react@18.2.0))(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) react-universal-interface: 0.6.2(react@18.2.0)(tslib@2.6.0) @@ -23835,7 +23901,7 @@ snapshots: sanitize.css@13.0.0: {} - sass-loader@12.6.0(webpack@5.88.0): + sass-loader@12.6.0(webpack@5.88.0(esbuild@0.17.19)): dependencies: klona: 2.0.6 neo-async: 2.6.2 @@ -24103,7 +24169,7 @@ snapshots: source-map-js@1.0.2: {} - source-map-loader@3.0.2(webpack@5.88.0): + source-map-loader@3.0.2(webpack@5.88.0(esbuild@0.17.19)): dependencies: abab: 2.0.6 iconv-lite: 0.6.3 @@ -24383,15 +24449,16 @@ snapshots: dependencies: boundary: 2.0.0 - style-loader@3.3.3(webpack@5.88.0): + style-loader@3.3.3(webpack@5.88.0(esbuild@0.17.19)): dependencies: webpack: 5.88.0(esbuild@0.17.19) styled-jsx@5.1.1(@babel/core@7.23.3)(react@18.2.0): dependencies: - '@babel/core': 7.23.3 client-only: 0.0.1 react: 18.2.0 + optionalDependencies: + '@babel/core': 7.23.3 stylehacks@5.1.1(postcss@8.4.33): dependencies: @@ -24481,7 +24548,35 @@ snapshots: string-width: 4.2.3 strip-ansi: 6.0.1 - tailwindcss@3.3.2: + tailwindcss@3.3.2(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)): + dependencies: + '@alloc/quick-lru': 5.2.0 + arg: 5.0.2 + chokidar: 3.5.3 + didyoumean: 1.2.2 + dlv: 1.1.3 + fast-glob: 3.3.1 + glob-parent: 6.0.2 + is-glob: 4.0.3 + jiti: 1.18.2 + lilconfig: 2.1.0 + micromatch: 4.0.5 + normalize-path: 3.0.0 + object-hash: 3.0.0 + picocolors: 1.0.0 + postcss: 8.4.33 + postcss-import: 15.1.0(postcss@8.4.33) + postcss-js: 4.0.1(postcss@8.4.33) + postcss-load-config: 4.0.1(postcss@8.4.33)(ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2)) + postcss-nested: 6.0.1(postcss@8.4.33) + postcss-selector-parser: 6.0.13 + postcss-value-parser: 4.2.0 + resolve: 1.22.8 + sucrase: 3.32.0 + transitivePeerDependencies: + - ts-node + + tailwindcss@3.3.2(ts-node@10.9.1(@types/node@20.10.5)(typescript@5.2.2)): dependencies: '@alloc/quick-lru': 5.2.0 arg: 5.0.2 @@ -24500,7 +24595,35 @@ snapshots: postcss: 8.4.33 postcss-import: 15.1.0(postcss@8.4.33) postcss-js: 4.0.1(postcss@8.4.33) - postcss-load-config: 4.0.1(postcss@8.4.33) + postcss-load-config: 4.0.1(postcss@8.4.33)(ts-node@10.9.1(@types/node@20.10.5)(typescript@5.2.2)) + postcss-nested: 6.0.1(postcss@8.4.33) + postcss-selector-parser: 6.0.13 + postcss-value-parser: 4.2.0 + resolve: 1.22.8 + sucrase: 3.32.0 + transitivePeerDependencies: + - ts-node + + tailwindcss@3.3.2(ts-node@10.9.1(@types/node@20.11.13)(typescript@5.2.2)): + dependencies: + '@alloc/quick-lru': 5.2.0 + arg: 5.0.2 + chokidar: 3.5.3 + didyoumean: 1.2.2 + dlv: 1.1.3 + fast-glob: 3.3.1 + glob-parent: 6.0.2 + is-glob: 4.0.3 + jiti: 1.18.2 + lilconfig: 2.1.0 + micromatch: 4.0.5 + normalize-path: 3.0.0 + object-hash: 3.0.0 + picocolors: 1.0.0 + postcss: 8.4.33 + postcss-import: 15.1.0(postcss@8.4.33) + postcss-js: 4.0.1(postcss@8.4.33) + postcss-load-config: 4.0.1(postcss@8.4.33)(ts-node@10.9.1(@types/node@20.11.13)(typescript@5.2.2)) postcss-nested: 6.0.1(postcss@8.4.33) postcss-selector-parser: 6.0.13 postcss-value-parser: 4.2.0 @@ -24541,15 +24664,16 @@ snapshots: ansi-escapes: 4.3.2 supports-hyperlinks: 2.3.0 - terser-webpack-plugin@5.3.9(esbuild@0.17.19)(webpack@5.88.0): + terser-webpack-plugin@5.3.9(esbuild@0.17.19)(webpack@5.88.0(esbuild@0.17.19)): dependencies: '@jridgewell/trace-mapping': 0.3.18 - esbuild: 0.17.19 jest-worker: 27.5.1 schema-utils: 3.3.0 serialize-javascript: 6.0.1 terser: 5.18.2 webpack: 5.88.0(esbuild@0.17.19) + optionalDependencies: + esbuild: 0.17.19 terser@5.18.2: dependencies: @@ -24580,8 +24704,9 @@ snapshots: node-fetch: 2.7.0 p-memoize: 3.1.0 p-queue: 6.6.2 - textlint: 13.3.2 textlint-rule-helper: 2.3.0 + optionalDependencies: + textlint: 13.3.2 transitivePeerDependencies: - encoding @@ -24748,6 +24873,63 @@ snapshots: ts-log@2.2.5: {} + ts-node@10.9.1(@types/node@16.18.34)(typescript@5.2.2): + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.9 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.4 + '@types/node': 16.18.34 + acorn: 8.11.3 + acorn-walk: 8.3.2 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 5.2.2 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + optional: true + + ts-node@10.9.1(@types/node@18.15.3)(typescript@5.2.2): + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.9 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.4 + '@types/node': 18.15.3 + acorn: 8.11.3 + acorn-walk: 8.3.2 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 5.2.2 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + optional: true + + ts-node@10.9.1(@types/node@20.10.5)(typescript@5.2.2): + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.9 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.4 + '@types/node': 20.10.5 + acorn: 8.11.3 + acorn-walk: 8.3.2 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 5.2.2 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + optional: true + ts-node@10.9.1(@types/node@20.11.13)(typescript@5.2.2): dependencies: '@cspotcode/source-map-support': 0.8.1 @@ -24783,7 +24965,7 @@ snapshots: tslib@2.6.0: {} - tsup@6.7.0(typescript@5.2.2): + tsup@6.7.0(postcss@8.4.33)(ts-node@10.9.1(@types/node@18.15.3)(typescript@5.2.2))(typescript@5.2.2): dependencies: bundle-require: 4.0.1(esbuild@0.17.19) cac: 6.7.14 @@ -24793,12 +24975,14 @@ snapshots: execa: 5.1.1 globby: 11.1.0 joycon: 3.1.1 - postcss-load-config: 3.1.4 + postcss-load-config: 3.1.4(postcss@8.4.33)(ts-node@10.9.1(@types/node@18.15.3)(typescript@5.2.2)) resolve-from: 5.0.0 rollup: 3.25.3 source-map: 0.8.0-beta.0 sucrase: 3.32.0 tree-kill: 1.2.2 + optionalDependencies: + postcss: 8.4.33 typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -24921,12 +25105,12 @@ snapshots: dependencies: is-typedarray: 1.0.0 - typedoc-plugin-markdown@3.15.3(typedoc@0.25.3): + typedoc-plugin-markdown@3.15.3(typedoc@0.25.3(typescript@5.2.2)): dependencies: handlebars: 4.7.7 typedoc: 0.25.3(typescript@5.2.2) - typedoc-plugin-merge-modules@5.0.1(typedoc@0.25.3): + typedoc-plugin-merge-modules@5.0.1(typedoc@0.25.3(typescript@5.2.2)): dependencies: typedoc: 0.25.3(typescript@5.2.2) @@ -25098,16 +25282,18 @@ snapshots: use-callback-ref@1.3.1(@types/react@18.2.9)(react@18.2.0): dependencies: - '@types/react': 18.2.9 react: 18.2.0 tslib: 2.6.0 + optionalDependencies: + '@types/react': 18.2.9 use-sidecar@1.1.2(@types/react@18.2.9)(react@18.2.0): dependencies: - '@types/react': 18.2.9 detect-node-es: 1.1.0 react: 18.2.0 tslib: 2.6.0 + optionalDependencies: + '@types/react': 18.2.9 userhome@1.0.0: {} @@ -25177,13 +25363,30 @@ snapshots: unist-util-stringify-position: 2.0.3 vfile-message: 2.0.4 - vite-node@1.2.1(@types/node@18.15.3): + vite-node@1.2.1(@types/node@18.15.3)(terser@5.18.2): + dependencies: + cac: 6.7.14 + debug: 4.3.4(supports-color@5.5.0) + pathe: 1.1.2 + picocolors: 1.0.0 + vite: 5.0.12(@types/node@18.15.3)(terser@5.18.2) + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + + vite-node@1.2.1(@types/node@20.11.13)(terser@5.18.2): dependencies: cac: 6.7.14 debug: 4.3.4(supports-color@5.5.0) pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.0.12(@types/node@18.15.3) + vite: 5.0.12(@types/node@20.11.13)(terser@5.18.2) transitivePeerDependencies: - '@types/node' - less @@ -25194,13 +25397,13 @@ snapshots: - supports-color - terser - vite-plugin-node-polyfills@0.17.0(vite@5.0.12): + vite-plugin-node-polyfills@0.17.0(rollup@4.9.6)(vite@5.0.12(@types/node@18.15.3)(terser@5.18.2)): dependencies: - '@rollup/plugin-inject': 5.0.5 + '@rollup/plugin-inject': 5.0.5(rollup@4.9.6) buffer-polyfill: buffer@6.0.3 node-stdlib-browser: 1.2.0 process: 0.11.10 - vite: 5.0.12(@types/node@18.15.3) + vite: 5.0.12(@types/node@18.15.3)(terser@5.18.2) transitivePeerDependencies: - rollup @@ -25210,50 +25413,64 @@ snapshots: fast-glob: 3.3.1 minimatch: 6.2.0 - vite@4.3.9(@types/node@18.15.3): + vite@4.3.9(@types/node@20.11.13)(terser@5.18.2): dependencies: - '@types/node': 18.15.3 esbuild: 0.17.19 postcss: 8.4.33 rollup: 3.25.3 optionalDependencies: + '@types/node': 20.11.13 fsevents: 2.3.3 + terser: 5.18.2 - vite@5.0.12(@types/node@18.15.3): + vite@5.0.12(@types/node@18.15.3)(terser@5.18.2): dependencies: + esbuild: 0.19.3 + postcss: 8.4.33 + rollup: 4.9.6 + optionalDependencies: '@types/node': 18.15.3 + fsevents: 2.3.3 + terser: 5.18.2 + + vite@5.0.12(@types/node@20.11.13)(terser@5.18.2): + dependencies: esbuild: 0.19.3 postcss: 8.4.33 rollup: 4.9.6 optionalDependencies: + '@types/node': 20.11.13 fsevents: 2.3.3 + terser: 5.18.2 - vitepress-plugin-search@1.0.4-alpha.19(flexsearch@0.7.31)(vitepress@1.0.0-rc.40)(vue@3.4.15): + vitepress-plugin-search@1.0.4-alpha.19(flexsearch@0.7.31)(vitepress@1.0.0-rc.40(@algolia/client-search@4.22.1)(@types/node@20.11.13)(@types/react@18.2.9)(change-case@4.1.2)(postcss@8.4.33)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.11.0)(terser@5.18.2)(typescript@5.2.2))(vue@3.4.15(typescript@5.2.2)): dependencies: '@types/flexsearch': 0.7.3 '@types/markdown-it': 12.2.3 flexsearch: 0.7.31 markdown-it: 13.0.1 - vitepress: 1.0.0-rc.40(@algolia/client-search@4.22.1)(@types/node@18.15.3)(search-insights@2.11.0)(typescript@5.2.2) + vitepress: 1.0.0-rc.40(@algolia/client-search@4.22.1)(@types/node@20.11.13)(@types/react@18.2.9)(change-case@4.1.2)(postcss@8.4.33)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.11.0)(terser@5.18.2)(typescript@5.2.2) vue: 3.4.15(typescript@5.2.2) - vitepress@1.0.0-rc.40(@algolia/client-search@4.22.1)(@types/node@18.15.3)(search-insights@2.11.0)(typescript@5.2.2): + vitepress@1.0.0-rc.40(@algolia/client-search@4.22.1)(@types/node@20.11.13)(@types/react@18.2.9)(change-case@4.1.2)(postcss@8.4.33)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.11.0)(terser@5.18.2)(typescript@5.2.2): dependencies: '@docsearch/css': 3.5.2 - '@docsearch/js': 3.5.2(@algolia/client-search@4.22.1)(search-insights@2.11.0) + '@docsearch/js': 3.5.2(@algolia/client-search@4.22.1)(@types/react@18.2.9)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.11.0) '@types/markdown-it': 13.0.7 - '@vitejs/plugin-vue': 5.0.3(vite@5.0.12)(vue@3.4.15) + '@vitejs/plugin-vue': 5.0.3(vite@5.0.12(@types/node@20.11.13)(terser@5.18.2))(vue@3.4.15(typescript@5.2.2)) '@vue/devtools-api': 6.5.1 - '@vueuse/core': 10.7.2(vue@3.4.15) - '@vueuse/integrations': 10.7.2(focus-trap@7.5.4)(vue@3.4.15) + '@vueuse/core': 10.7.2(vue@3.4.15(typescript@5.2.2)) + '@vueuse/integrations': 10.7.2(change-case@4.1.2)(focus-trap@7.5.4)(vue@3.4.15(typescript@5.2.2)) focus-trap: 7.5.4 mark.js: 8.11.1 minisearch: 6.3.0 shikiji: 0.10.2 shikiji-core: 0.10.2 shikiji-transformers: 0.10.2 - vite: 5.0.12(@types/node@18.15.3) + vite: 5.0.12(@types/node@20.11.13)(terser@5.18.2) vue: 3.4.15(typescript@5.2.2) + optionalDependencies: + postcss: 8.4.33 transitivePeerDependencies: - '@algolia/client-search' - '@types/node' @@ -25281,10 +25498,44 @@ snapshots: - typescript - universal-cookie - vitest@1.2.1(@types/node@18.15.3)(@vitest/browser@1.2.1): + vitest@1.2.1(@types/node@18.15.3)(@vitest/browser@1.2.1)(jsdom@16.7.0)(terser@5.18.2): dependencies: + '@vitest/expect': 1.2.1 + '@vitest/runner': 1.2.1 + '@vitest/snapshot': 1.2.1 + '@vitest/spy': 1.2.1 + '@vitest/utils': 1.2.1 + acorn-walk: 8.3.2 + cac: 6.7.14 + chai: 4.4.1 + debug: 4.3.4(supports-color@5.5.0) + execa: 8.0.1 + local-pkg: 0.5.0 + magic-string: 0.30.5 + pathe: 1.1.2 + picocolors: 1.0.0 + std-env: 3.7.0 + strip-literal: 1.3.0 + tinybench: 2.6.0 + tinypool: 0.8.2 + vite: 5.0.12(@types/node@18.15.3)(terser@5.18.2) + vite-node: 1.2.1(@types/node@18.15.3)(terser@5.18.2) + why-is-node-running: 2.2.2 + optionalDependencies: '@types/node': 18.15.3 - '@vitest/browser': 1.2.1(vitest@1.2.1)(webdriverio@8.32.2) + '@vitest/browser': 1.2.1(vitest@1.2.1)(webdriverio@8.32.2(typescript@5.2.2)) + jsdom: 16.7.0 + transitivePeerDependencies: + - less + - lightningcss + - sass + - stylus + - sugarss + - supports-color + - terser + + vitest@1.2.1(@types/node@20.11.13)(@vitest/browser@1.2.1)(jsdom@16.7.0)(terser@5.18.2): + dependencies: '@vitest/expect': 1.2.1 '@vitest/runner': 1.2.1 '@vitest/snapshot': 1.2.1 @@ -25303,9 +25554,13 @@ snapshots: strip-literal: 1.3.0 tinybench: 2.6.0 tinypool: 0.8.2 - vite: 5.0.12(@types/node@18.15.3) - vite-node: 1.2.1(@types/node@18.15.3) + vite: 5.0.12(@types/node@20.11.13)(terser@5.18.2) + vite-node: 1.2.1(@types/node@20.11.13)(terser@5.18.2) why-is-node-running: 2.2.2 + optionalDependencies: + '@types/node': 20.11.13 + '@vitest/browser': 1.2.1(vitest@1.2.1)(webdriverio@8.32.2(typescript@5.2.2)) + jsdom: 16.7.0 transitivePeerDependencies: - less - lightningcss @@ -25323,7 +25578,7 @@ snapshots: vscode-textmate@8.0.0: {} - vue-demi@0.14.6(vue@3.4.15): + vue-demi@0.14.6(vue@3.4.15(typescript@5.2.2)): dependencies: vue: 3.4.15(typescript@5.2.2) @@ -25332,8 +25587,9 @@ snapshots: '@vue/compiler-dom': 3.4.15 '@vue/compiler-sfc': 3.4.15 '@vue/runtime-dom': 3.4.15 - '@vue/server-renderer': 3.4.15(vue@3.4.15) + '@vue/server-renderer': 3.4.15(vue@3.4.15(typescript@5.2.2)) '@vue/shared': 3.4.15 + optionalDependencies: typescript: 5.2.2 w3c-hr-time@1.0.2: @@ -25442,7 +25698,7 @@ snapshots: webidl-conversions@6.1.0: {} - webpack-dev-middleware@5.3.3(webpack@5.88.0): + webpack-dev-middleware@5.3.3(webpack@5.88.0(esbuild@0.17.19)): dependencies: colorette: 2.0.20 memfs: 3.5.3 @@ -25451,7 +25707,7 @@ snapshots: schema-utils: 4.2.0 webpack: 5.88.0(esbuild@0.17.19) - webpack-dev-server@4.15.1(webpack@5.88.0): + webpack-dev-server@4.15.1(webpack@5.88.0(esbuild@0.17.19)): dependencies: '@types/bonjour': 3.5.10 '@types/connect-history-api-fallback': 1.5.0 @@ -25481,16 +25737,17 @@ snapshots: serve-index: 1.9.1 sockjs: 0.3.24 spdy: 4.0.2 - webpack: 5.88.0(esbuild@0.17.19) - webpack-dev-middleware: 5.3.3(webpack@5.88.0) + webpack-dev-middleware: 5.3.3(webpack@5.88.0(esbuild@0.17.19)) ws: 8.13.0 + optionalDependencies: + webpack: 5.88.0(esbuild@0.17.19) transitivePeerDependencies: - bufferutil - debug - supports-color - utf-8-validate - webpack-manifest-plugin@4.1.1(webpack@5.88.0): + webpack-manifest-plugin@4.1.1(webpack@5.88.0(esbuild@0.17.19)): dependencies: tapable: 2.2.1 webpack: 5.88.0(esbuild@0.17.19) @@ -25531,7 +25788,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.9(esbuild@0.17.19)(webpack@5.88.0) + terser-webpack-plugin: 5.3.9(esbuild@0.17.19)(webpack@5.88.0(esbuild@0.17.19)) watchpack: 2.4.0 webpack-sources: 3.2.3 transitivePeerDependencies: @@ -25656,13 +25913,13 @@ snapshots: dependencies: workbox-core: 6.6.0 - workbox-build@6.6.0: + workbox-build@6.6.0(@types/babel__core@7.20.1): dependencies: '@apideck/better-ajv-errors': 0.3.6(ajv@8.12.0) '@babel/core': 7.22.5 '@babel/preset-env': 7.22.5(@babel/core@7.22.5) '@babel/runtime': 7.23.4 - '@rollup/plugin-babel': 5.3.1(@babel/core@7.22.5)(rollup@2.79.1) + '@rollup/plugin-babel': 5.3.1(@babel/core@7.22.5)(@types/babel__core@7.20.1)(rollup@2.79.1) '@rollup/plugin-node-resolve': 11.2.1(rollup@2.79.1) '@rollup/plugin-replace': 2.4.2(rollup@2.79.1) '@surma/rollup-plugin-off-main-thread': 2.2.3 @@ -25755,14 +26012,14 @@ snapshots: workbox-sw@6.6.0: {} - workbox-webpack-plugin@6.6.0(webpack@5.88.0): + workbox-webpack-plugin@6.6.0(@types/babel__core@7.20.1)(webpack@5.88.0(esbuild@0.17.19)): dependencies: fast-json-stable-stringify: 2.1.0 pretty-bytes: 5.6.0 upath: 1.2.0 webpack: 5.88.0(esbuild@0.17.19) webpack-sources: 1.4.3 - workbox-build: 6.6.0 + workbox-build: 6.6.0(@types/babel__core@7.20.1) transitivePeerDependencies: - '@types/babel__core' - supports-color diff --git a/scripts/forc-update.ts b/scripts/forc-update.ts index 7122fd7ad56..e65c593516e 100644 --- a/scripts/forc-update.ts +++ b/scripts/forc-update.ts @@ -4,7 +4,7 @@ import { execSync } from 'child_process'; (() => { // Update - execSync(`pnpm --filter @fuel-ts/forc run update`); + execSync(`pnpm --filter @internal/forc run update`); // Remove lockfiles so latest stdlib can be used execSync(`rm packages/**/Forc.lock`); From 1ebe3aebb15bc04dde085cc2dc47b3af34d49c17 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 19:09:00 +0100 Subject: [PATCH 10/89] Removed unneed import --- packages/fuels/src/cli/commands/build/buildSwayProgram.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/fuels/src/cli/commands/build/buildSwayProgram.ts b/packages/fuels/src/cli/commands/build/buildSwayProgram.ts index 41ac9df9f43..ea95b0cc56f 100644 --- a/packages/fuels/src/cli/commands/build/buildSwayProgram.ts +++ b/packages/fuels/src/cli/commands/build/buildSwayProgram.ts @@ -1,4 +1,3 @@ -import { findBinPath } from '@fuel-ts/utils/cli-utils'; import { spawn } from 'child_process'; import type { FuelsConfig } from '../../types'; From 74efc8b8792ae9404efd48e119be623f7e6c9131 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 19:10:23 +0100 Subject: [PATCH 11/89] Lint --- packages/fuels/test/utils/runCommands.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/fuels/test/utils/runCommands.ts b/packages/fuels/test/utils/runCommands.ts index 9b564775c52..c17e0c8b618 100644 --- a/packages/fuels/test/utils/runCommands.ts +++ b/packages/fuels/test/utils/runCommands.ts @@ -91,15 +91,7 @@ export type BuildParams = BaseParams & { }; export async function runInit(params: InitParams) { - const { - autoStartFuelCore, - contracts, - output, - predicates, - root, - scripts, - workspace, - } = params; + const { autoStartFuelCore, contracts, output, predicates, root, scripts, workspace } = params; const flag = (flags: (string | undefined)[], value?: string | boolean): string[] => value ? (flags as string[]) : []; From d6cd544ec7292742695c713ca8d6262b70eae6cc Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 19:14:50 +0100 Subject: [PATCH 12/89] Fixed filepaths for fuel-core and forc --- .github/actions/test-setup/action.yaml | 2 +- .github/workflows/release.yaml | 4 ++-- CONTRIBUTING.md | 2 +- packages/versions/README.md | 4 ++-- packages/versions/scripts/rewriteVersions.ts | 5 +++-- packages/versions/src/index.ts | 4 ++-- scripts/forc-check.sh | 2 +- scripts/forc-format.sh | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/actions/test-setup/action.yaml b/.github/actions/test-setup/action.yaml index 3a288cb3d1e..cddebb793cc 100644 --- a/.github/actions/test-setup/action.yaml +++ b/.github/actions/test-setup/action.yaml @@ -47,4 +47,4 @@ runs: ./install-fuelup.sh --no-modify-path --skip-toolchain-installation export PATH="${HOME}/.fuelup/bin:${PATH}" fuelup toolchain new forc-experimental - fuelup component add forc@$(cat ./packages/forc/VERSION_EXPERIMENTAL) + fuelup component add forc@$(cat ./internal/forc/VERSION_EXPERIMENTAL) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8395ec65bca..e6b67ecff26 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -35,8 +35,8 @@ jobs: run: | pnpm changeset version echo "RELEASE_VERSION=v$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' packages/fuels/package.json)" >> $GITHUB_ENV - echo "FUEL_CORE_VERSION=$(cat ./packages/fuel-core/VERSION)" >> $GITHUB_ENV - echo "FORC_VERSION=$(cat ./packages/forc/VERSION)" >> $GITHUB_ENV + echo "FUEL_CORE_VERSION=$(cat ./internal/fuel-core/VERSION)" >> $GITHUB_ENV + echo "FORC_VERSION=$(cat ./internal/forc/VERSION)" >> $GITHUB_ENV git reset --hard env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b7cbf014406..5da8c2a9c1d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -222,7 +222,7 @@ After this you should run tests and fix any incompatibilities. # Updating Fuel Core version -Manually edit the `packages/fuel-core/VERSION` file, add the right version, and then: +Manually edit the `internal/fuel-core/VERSION` file, add the right version, and then: ```sh pnpm install # will download new binaries diff --git a/packages/versions/README.md b/packages/versions/README.md index 5797b70f7ff..3ecfaa61fbf 100644 --- a/packages/versions/README.md +++ b/packages/versions/README.md @@ -5,8 +5,8 @@ It automatically assembles all supported versions of the Fuel toolchain, including: - `FUELS` — comes from `/packages/fuels/package.json` -- `FUEL_CORE` — comes from `/packages/fuel-core/VERSION` -- `FORC` — comes from `/packages/forc/VERSION` +- `FUEL_CORE` — comes from `/internal/fuel-core/VERSION` +- `FORC` — comes from `/internal/forc/VERSION` There is a `prebuild` script to ensure that the `src/index.ts` file never goes outdated. diff --git a/packages/versions/scripts/rewriteVersions.ts b/packages/versions/scripts/rewriteVersions.ts index 4c3997668e2..36ba9394f5f 100644 --- a/packages/versions/scripts/rewriteVersions.ts +++ b/packages/versions/scripts/rewriteVersions.ts @@ -3,16 +3,17 @@ import { join } from 'path'; export const readVersionsFromFiles = () => { const rootDir = join(__dirname, '../../..'); + const internalDir = join(rootDir, 'internal'); const packagesDir = join(rootDir, 'packages'); const firstLineReg = /^.+$/m; // forc - const forcPath = join(packagesDir, 'forc', 'VERSION'); + const forcPath = join(internalDir, 'forc', 'VERSION'); const forcVersion = readFileSync(forcPath, 'utf8').match(firstLineReg)?.[0]; // fuel-core - const fuelCorePath = join(packagesDir, 'fuel-core', 'VERSION'); + const fuelCorePath = join(internalDir, 'fuel-core', 'VERSION'); const fuelCoreVersion = readFileSync(fuelCorePath, 'utf8').match(firstLineReg)?.[0]; // fuels diff --git a/packages/versions/src/index.ts b/packages/versions/src/index.ts index 1936481f6e6..4c14514fe13 100644 --- a/packages/versions/src/index.ts +++ b/packages/versions/src/index.ts @@ -2,8 +2,8 @@ 1) Variables ------------ `FUELS` — comes from `/packages/fuels/package.json` - `FUEL_CORE` — comes from `/packages/fuel-core/VERSION` - `FORC` — comes from `/packages/forc/VERSION` + `FUEL_CORE` — comes from `/internal/fuel-core/VERSION` + `FORC` — comes from `/internal/forc/VERSION` 3) Pre Build ------------ diff --git a/scripts/forc-check.sh b/scripts/forc-check.sh index 0f10025e1f4..e8c412b9b8c 100755 --- a/scripts/forc-check.sh +++ b/scripts/forc-check.sh @@ -2,7 +2,7 @@ main_dir=$(pwd) forc_tomls=$(find . -type f -name "Forc.toml") -forc_fmt=$(realpath ./packages/forc/forc-binaries/forc-fmt) +forc_fmt=$(realpath ./internal/forc/forc-binaries/forc-fmt) expected_authors="authors = [\"Fuel Labs \"]" ERRORED=0 diff --git a/scripts/forc-format.sh b/scripts/forc-format.sh index 8c151534ff5..20f95316610 100755 --- a/scripts/forc-format.sh +++ b/scripts/forc-format.sh @@ -2,7 +2,7 @@ main_dir=$(pwd) forc_tomls=$(find . -type f -name "Forc.toml") -forc_fmt=$(realpath ./packages/forc/forc-binaries/forc-fmt) +forc_fmt=$(realpath ./internal/forc/forc-binaries/forc-fmt) expected_authors="authors = [\"Fuel Labs \"]" for forc_toml in $forc_tomls; do From cc5ce233b6e7461bad5749305bc7101282ee6391 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 19:18:35 +0100 Subject: [PATCH 13/89] Fix VERSION_EXPERIMENTAL --- packages/fuel-gauge/scripts/build-forc-experimental.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/fuel-gauge/scripts/build-forc-experimental.ts b/packages/fuel-gauge/scripts/build-forc-experimental.ts index bf6fb562f39..29cb01daf48 100755 --- a/packages/fuel-gauge/scripts/build-forc-experimental.ts +++ b/packages/fuel-gauge/scripts/build-forc-experimental.ts @@ -1,12 +1,14 @@ import { execSync } from 'child_process'; import { readFileSync } from 'fs'; -import path from 'path'; +import path, { join } from 'path'; const FORC = '~/.fuelup/bin/forc'; // node doesn't find it in PATH and fails, thus we need to provide the full path -const EXPECTED_FORC_VERSION = readFileSync( - path.join(process.cwd(), '..', 'forc', 'VERSION_EXPERIMENTAL') -).toString(); +const rootDir = join(__dirname, '../../..'); +const internalDir = join(rootDir, 'internal'); + +const versionFilePath = join(internalDir, 'forc', 'VERSION_EXPERIMENTAL'); +const EXPECTED_FORC_VERSION = readFileSync(versionFilePath).toString(); const installedForcVersion = execSync(`${FORC} --version | sed "s/forc//"`, { env: process.env, From 03a161078da26d92fd3bde4e8d110d6ce4054403 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 19:24:37 +0100 Subject: [PATCH 14/89] Added packages to knip ignore --- .knip.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.knip.json b/.knip.json index 63def7c5b47..dd70c82409e 100644 --- a/.knip.json +++ b/.knip.json @@ -8,6 +8,8 @@ ], "ignoreDependencies": [ "@fuel-ts/*", + "@internal/fuel-core", + "@internal/forc", "@types/jest", "@types/rimraf", "@graphql-codegen*", From 7fb5690e97ebad61b4cb0fa6532bd23b9ddafc75 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 20:42:39 +0100 Subject: [PATCH 15/89] Update .changeset/friendly-deers-glow.md Co-authored-by: Anderson Arboleya --- .changeset/friendly-deers-glow.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/friendly-deers-glow.md b/.changeset/friendly-deers-glow.md index f6e7215adc0..61235d6873e 100644 --- a/.changeset/friendly-deers-glow.md +++ b/.changeset/friendly-deers-glow.md @@ -1,4 +1,4 @@ --- --- -docs: Un-documented built-in binaries \ No newline at end of file +chore!: Remove built-in binaries for `forc` and `fuel-core` \ No newline at end of file From 11e2f7bdb66510e221870c3195038572caaa01c4 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 21:39:49 +0100 Subject: [PATCH 16/89] Implemented `forcPath` and `fuelCorePath` --- apps/demo-fuels/fuels.config.full.ts | 10 ++++++++++ apps/demo-fuels/fuels.config.ts | 2 ++ apps/docs/src/guide/fuels-cli/config-file.md | 16 ++++++++++++++++ .../src/cli/commands/build/buildSwayProgram.ts | 4 +++- packages/fuels/src/cli/config/loadConfig.test.ts | 1 - packages/fuels/src/cli/config/loadConfig.ts | 5 +++++ packages/fuels/src/cli/types.ts | 8 ++++++++ packages/fuels/test/fixtures/fuels.config.ts | 2 ++ templates/nextjs/fuels.config.ts | 2 ++ 9 files changed, 48 insertions(+), 2 deletions(-) diff --git a/apps/demo-fuels/fuels.config.full.ts b/apps/demo-fuels/fuels.config.full.ts index 87344f433d4..c4110f06da6 100644 --- a/apps/demo-fuels/fuels.config.full.ts +++ b/apps/demo-fuels/fuels.config.full.ts @@ -96,6 +96,16 @@ export default createConfig({ console.log('fuels:onFailure', { error, config }); }, // #endregion onFailure + + // #region forcPath + // Default: undefined + forcPath: 'fuels-forc', + // #endregion forcPath + + // #region fuelCorePath + // Default: undefined + fuelCorePath: 'fuel-core', + // #endregion fuelCorePath }); export const simpleDeployConfig = createConfig({ diff --git a/apps/demo-fuels/fuels.config.ts b/apps/demo-fuels/fuels.config.ts index 8b17236adde..07b4dc90db1 100644 --- a/apps/demo-fuels/fuels.config.ts +++ b/apps/demo-fuels/fuels.config.ts @@ -4,6 +4,8 @@ import { createConfig } from 'fuels'; export default createConfig({ workspace: './sway-programs', // forc workspace output: './src/sway-programs-api', + forcPath: 'fuels-forc', + fuelCorePath: 'fuel-core', }); // #endregion config diff --git a/apps/docs/src/guide/fuels-cli/config-file.md b/apps/docs/src/guide/fuels-cli/config-file.md index 073e1ece164..b89bea7c131 100644 --- a/apps/docs/src/guide/fuels-cli/config-file.md +++ b/apps/docs/src/guide/fuels-cli/config-file.md @@ -139,6 +139,22 @@ Parameters: <<< @../../../demo-fuels/fuels.config.full.ts#onFailure{ts:line-numbers} +## `forcPath` + +Path to the `forc` binary. + +When not supplied, will default to using the `system` binaries. + +<<< @../../../demo-fuels/fuels.config.full.ts#forcPath{ts:line-numbers} + +## `fuelCorePath` + +Path to the `fuel-core` binary. + +When not supplied, will default to using the `system` binaries. + +<<< @../../../demo-fuels/fuels.config.full.ts#fuelCorePath{ts:line-numbers} + ## Loading environment variables If you want to load environment variables from a `.env` file, you can use the `dotenv` package. diff --git a/packages/fuels/src/cli/commands/build/buildSwayProgram.ts b/packages/fuels/src/cli/commands/build/buildSwayProgram.ts index ea95b0cc56f..8e49f523295 100644 --- a/packages/fuels/src/cli/commands/build/buildSwayProgram.ts +++ b/packages/fuels/src/cli/commands/build/buildSwayProgram.ts @@ -8,9 +8,11 @@ import { onForcExit, onForcError } from './forcHandlers'; export const buildSwayProgram = async (config: FuelsConfig, path: string) => { debug('Building Sway program', path); + const forcPath = config.forcPath ?? 'forc'; + return new Promise((resolve, reject) => { const args = ['build', '-p', path].concat(config.forcBuildFlags); - const forc = spawn('forc', args, { stdio: 'pipe' }); + const forc = spawn(forcPath, args, { stdio: 'pipe' }); if (loggingConfig.isLoggingEnabled) { forc.stderr?.pipe(process.stderr); diff --git a/packages/fuels/src/cli/config/loadConfig.test.ts b/packages/fuels/src/cli/config/loadConfig.test.ts index bf3ae39cd08..ee4e3ec9f9d 100644 --- a/packages/fuels/src/cli/config/loadConfig.test.ts +++ b/packages/fuels/src/cli/config/loadConfig.test.ts @@ -38,7 +38,6 @@ describe('loadConfig', () => { root: paths.root, workspace: paths.workspaceDir, output: paths.outputDir, - useBuiltinBinaries: true, autoStartFuelCore: true, }); diff --git a/packages/fuels/src/cli/config/loadConfig.ts b/packages/fuels/src/cli/config/loadConfig.ts index 2a50e11349d..4f387ebe75f 100644 --- a/packages/fuels/src/cli/config/loadConfig.ts +++ b/packages/fuels/src/cli/config/loadConfig.ts @@ -43,6 +43,9 @@ export async function loadConfig(cwd: string): Promise { const releaseFlag = forcBuildFlags.find((f) => f === '--release'); const buildMode = releaseFlag ? 'release' : 'debug'; + const forcPath = userConfig.forcPath ?? 'forc'; + const fuelCorePath = userConfig.fuelCorePath ?? 'fuel-core'; + // Start clone-object while initializing optional props const config: FuelsConfig = { contracts: [], @@ -53,6 +56,8 @@ export async function loadConfig(cwd: string): Promise { fuelCorePort: 4000, providerUrl: FUEL_NETWORK_URL, privateKey: defaultConsensusKey, + forcPath, + fuelCorePath, ...userConfig, basePath: cwd, configPath, diff --git a/packages/fuels/src/cli/types.ts b/packages/fuels/src/cli/types.ts index c21cc96c732..3142ae9c773 100644 --- a/packages/fuels/src/cli/types.ts +++ b/packages/fuels/src/cli/types.ts @@ -73,6 +73,12 @@ export type UserFuelsConfig = { /** If set to false, you will need to spin up a Fuel core node by yourself */ autoStartFuelCore?: boolean; + /** If set, will use absolute path to forc binary */ + forcPath?: string; + + /** If set, will use absolute path to forc binary */ + fuelCorePath?: string; + /** * Port to use when starting a `fuel-core` node * Default: first free port, starting from 4000 @@ -111,6 +117,8 @@ export type FuelsConfig = UserFuelsConfig & | 'scripts' | 'deployConfig' | 'autoStartFuelCore' + | 'forcPath' + | 'fuelCorePath' | 'providerUrl' | 'forcBuildFlags' > diff --git a/packages/fuels/test/fixtures/fuels.config.ts b/packages/fuels/test/fixtures/fuels.config.ts index 9d32d2b51b8..d585bf60f3b 100644 --- a/packages/fuels/test/fixtures/fuels.config.ts +++ b/packages/fuels/test/fixtures/fuels.config.ts @@ -19,6 +19,8 @@ export const fuelsConfig: FuelsConfig = { deployConfig: { gasPrice: 5, }, + forcPath: 'forc', + fuelCorePath: 'fuel-core', autoStartFuelCore: true, fuelCorePort: 4000, providerUrl: FUEL_NETWORK_URL, diff --git a/templates/nextjs/fuels.config.ts b/templates/nextjs/fuels.config.ts index 38682bc5c9f..d14d32f6dd1 100644 --- a/templates/nextjs/fuels.config.ts +++ b/templates/nextjs/fuels.config.ts @@ -13,4 +13,6 @@ export default createConfig({ output: './src/sway-api', fuelCorePort, providerUrl: NODE_URL, + forcPath: 'fuels-forc', + fuelCorePath: 'fuels-core', }); From 0d79292083cbd51aa42225cfee89cf8c9a3f7922 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 21:49:28 +0100 Subject: [PATCH 17/89] Fixed forc version path --- scripts/verify-forc-version.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/verify-forc-version.ts b/scripts/verify-forc-version.ts index 1fa67ce4bcb..9d6a0e764b1 100644 --- a/scripts/verify-forc-version.ts +++ b/scripts/verify-forc-version.ts @@ -2,7 +2,7 @@ import fs from 'fs/promises'; import path from 'path'; (async () => { - const pathToForcVersionFile = path.join(__dirname, '..', 'packages', 'forc', 'VERSION'); + const pathToForcVersionFile = path.join(__dirname, '..', 'internal', 'forc', 'VERSION'); const forcVersion = await fs.readFile(pathToForcVersionFile, 'utf-8'); if (forcVersion.indexOf('git:') !== -1) { throw new Error('Cannot publish from a git branch. Please use a release directly.'); From 85493066ed40bdda67bcbc7140d29cbcefcb01d2 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 21:56:17 +0100 Subject: [PATCH 18/89] Removed binaries from docs --- apps/docs/.vitepress/config.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apps/docs/.vitepress/config.ts b/apps/docs/.vitepress/config.ts index 4339e14ec08..779904911cf 100644 --- a/apps/docs/.vitepress/config.ts +++ b/apps/docs/.vitepress/config.ts @@ -75,10 +75,6 @@ export default defineConfig({ text: 'Commands', link: '/guide/fuels-cli/commands', }, - { - text: 'Binaries', - link: '/guide/fuels-cli/binaries', - }, { text: 'ABI Typegen', link: '/guide/fuels-cli/abi-typegen', From e9f19dce1f2aafb51b04c90087383af734b7485a Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 21:56:59 +0100 Subject: [PATCH 19/89] Lint --- packages/fuel-gauge/scripts/build-forc-experimental.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fuel-gauge/scripts/build-forc-experimental.ts b/packages/fuel-gauge/scripts/build-forc-experimental.ts index 29cb01daf48..39b77bfafd1 100755 --- a/packages/fuel-gauge/scripts/build-forc-experimental.ts +++ b/packages/fuel-gauge/scripts/build-forc-experimental.ts @@ -1,6 +1,6 @@ import { execSync } from 'child_process'; import { readFileSync } from 'fs'; -import path, { join } from 'path'; +import { join } from 'path'; const FORC = '~/.fuelup/bin/forc'; // node doesn't find it in PATH and fails, thus we need to provide the full path From e0dd7bd696658a1fa0868f0f8a8784ad1dd89cee Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 24 Apr 2024 09:43:44 +0100 Subject: [PATCH 20/89] Finalising passing though forcPath and fuelCorePath --- apps/demo-fuels/fuels.config.full.ts | 2 +- apps/demo-fuels/fuels.config.ts | 2 +- packages/fuels/src/cli.ts | 2 ++ packages/fuels/src/cli/commands/init/index.ts | 4 +++- .../fuels/src/cli/templates/fuels.config.hbs | 6 ++++++ .../fuels/src/cli/templates/fuels.config.ts | 2 ++ packages/fuels/test/features/build.test.ts | 8 +++++++ packages/fuels/test/features/deploy.test.ts | 1 + packages/fuels/test/fixtures/fuels.config.ts | 4 ++-- packages/fuels/test/utils/runCommands.ts | 21 ++++++++++++++++++- 10 files changed, 46 insertions(+), 6 deletions(-) diff --git a/apps/demo-fuels/fuels.config.full.ts b/apps/demo-fuels/fuels.config.full.ts index c4110f06da6..6ffa340eeca 100644 --- a/apps/demo-fuels/fuels.config.full.ts +++ b/apps/demo-fuels/fuels.config.full.ts @@ -104,7 +104,7 @@ export default createConfig({ // #region fuelCorePath // Default: undefined - fuelCorePath: 'fuel-core', + fuelCorePath: 'fuels-core', // #endregion fuelCorePath }); diff --git a/apps/demo-fuels/fuels.config.ts b/apps/demo-fuels/fuels.config.ts index 07b4dc90db1..42fc18c88e8 100644 --- a/apps/demo-fuels/fuels.config.ts +++ b/apps/demo-fuels/fuels.config.ts @@ -5,7 +5,7 @@ export default createConfig({ workspace: './sway-programs', // forc workspace output: './src/sway-programs-api', forcPath: 'fuels-forc', - fuelCorePath: 'fuel-core', + fuelCorePath: 'fuels-core', }); // #endregion config diff --git a/packages/fuels/src/cli.ts b/packages/fuels/src/cli.ts index 11fb960577e..52bd48f8436 100644 --- a/packages/fuels/src/cli.ts +++ b/packages/fuels/src/cli.ts @@ -55,6 +55,8 @@ export const configureCli = () => { .addOption(new Option(`-s, --scripts ${arg}`, `${desc} Scripts`).conflicts('workspace')) .addOption(new Option(`-p, --predicates ${arg}`, `${desc} Predicates`).conflicts('workspace')) .requiredOption('-o, --output ', 'Relative dir path for Typescript generation output') + .option('--forc-path ', 'Path to the `forc` binary') + .option('--fuel-core-path ', 'Path to the `fuel-core` binary') .option('--auto-start-fuel-core', 'Auto-starts a `fuel-core` node during `dev` command') .action(withProgram(command, Commands.init, init)); diff --git a/packages/fuels/src/cli/commands/init/index.ts b/packages/fuels/src/cli/commands/init/index.ts index 5cbfecaf057..433d6b5fc07 100644 --- a/packages/fuels/src/cli/commands/init/index.ts +++ b/packages/fuels/src/cli/commands/init/index.ts @@ -9,7 +9,7 @@ import { log } from '../../utils/logger'; export function init(program: Command) { const options = program.opts(); - const { path, autoStartFuelCore } = options; + const { path, autoStartFuelCore, forcPath, fuelCorePath } = options; let workspace: string | undefined; let absoluteWorkspace: string | undefined; @@ -53,6 +53,8 @@ export function init(program: Command) { scripts, predicates, output, + forcPath, + fuelCorePath, autoStartFuelCore, }); diff --git a/packages/fuels/src/cli/templates/fuels.config.hbs b/packages/fuels/src/cli/templates/fuels.config.hbs index c2bcc802341..c38d627424b 100644 --- a/packages/fuels/src/cli/templates/fuels.config.hbs +++ b/packages/fuels/src/cli/templates/fuels.config.hbs @@ -27,6 +27,12 @@ export default createConfig({ {{/if}} {{/if}} output: '{{output}}', + {{#if (isDefined forcPath)}} + forcPath: '{{forcPath}}', + {{/if}} + {{#if (isDefined fuelCorePath)}} + fuelCorePath: '{{fuelCorePath}}', + {{/if}} {{#if (isDefined autoStartFuelCore)}} autoStartFuelCore: {{autoStartFuelCore}}, {{/if}} diff --git a/packages/fuels/src/cli/templates/fuels.config.ts b/packages/fuels/src/cli/templates/fuels.config.ts index b208769676c..71930e975a9 100644 --- a/packages/fuels/src/cli/templates/fuels.config.ts +++ b/packages/fuels/src/cli/templates/fuels.config.ts @@ -13,6 +13,8 @@ export function renderFuelsConfigTemplate(props: { scripts?: string[]; predicates?: string[]; output: string; + forcPath?: string; + fuelCorePath?: string; autoStartFuelCore?: boolean; }) { const renderTemplate = Handlebars.compile(fuelsConfigTemplate, { diff --git a/packages/fuels/test/features/build.test.ts b/packages/fuels/test/features/build.test.ts index ebc7c8049b6..ff473a2f7f2 100644 --- a/packages/fuels/test/features/build.test.ts +++ b/packages/fuels/test/features/build.test.ts @@ -41,6 +41,8 @@ describe( root: paths.root, workspace: paths.workspaceDir, output: paths.outputDir, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, }); await runBuild({ root: paths.root }); @@ -76,6 +78,8 @@ describe( root: paths.root, contracts: paths.contractsDir, output: paths.outputDir, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, }); await runBuild({ root: paths.root }); @@ -102,6 +106,8 @@ describe( root: paths.root, workspace: paths.workspaceDir, output: paths.outputDir, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, }); await runBuild({ root: paths.root, deploy: true }); @@ -118,6 +124,8 @@ describe( root: paths.root, workspace: paths.workspaceDir, output: paths.outputDir, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, }); // inject `forcBuildFlags: ['--release']` in config file diff --git a/packages/fuels/test/features/deploy.test.ts b/packages/fuels/test/features/deploy.test.ts index 444c46b0214..88a9977c366 100644 --- a/packages/fuels/test/features/deploy.test.ts +++ b/packages/fuels/test/features/deploy.test.ts @@ -30,6 +30,7 @@ describe( root: paths.root, workspace: paths.workspaceDir, output: paths.outputDir, + forcPath: paths.forcPath, }); await runBuild({ root: paths.root }); diff --git a/packages/fuels/test/fixtures/fuels.config.ts b/packages/fuels/test/fixtures/fuels.config.ts index d585bf60f3b..21dabe512ca 100644 --- a/packages/fuels/test/fixtures/fuels.config.ts +++ b/packages/fuels/test/fixtures/fuels.config.ts @@ -19,8 +19,8 @@ export const fuelsConfig: FuelsConfig = { deployConfig: { gasPrice: 5, }, - forcPath: 'forc', - fuelCorePath: 'fuel-core', + forcPath: 'fuels-forc', + fuelCorePath: 'fuels-core', autoStartFuelCore: true, fuelCorePort: 4000, providerUrl: FUEL_NETWORK_URL, diff --git a/packages/fuels/test/utils/runCommands.ts b/packages/fuels/test/utils/runCommands.ts index c17e0c8b618..57d47e8c829 100644 --- a/packages/fuels/test/utils/runCommands.ts +++ b/packages/fuels/test/utils/runCommands.ts @@ -48,6 +48,9 @@ export function bootstrapProject(testFilepath: string) { const contractsJsonPath = join(outputDir, 'contract-ids.json'); const fooContractFactoryPath = join(outputDir, 'contracts', 'factories', 'FooBarAbi__factory.ts'); + const forcPath = 'fuels-forc'; + const fuelCorePath = 'fuels-core'; + return { root, workspaceDir, @@ -60,6 +63,8 @@ export function bootstrapProject(testFilepath: string) { outputDir, contractsJsonPath, fooContractFactoryPath, + forcPath, + fuelCorePath, }; } @@ -82,6 +87,8 @@ export type InitParams = BaseParams & { scripts?: string; predicates?: string; output: string; + forcPath?: string; + fuelCorePath?: string; autoStartFuelCore?: boolean; build?: boolean; }; @@ -91,7 +98,17 @@ export type BuildParams = BaseParams & { }; export async function runInit(params: InitParams) { - const { autoStartFuelCore, contracts, output, predicates, root, scripts, workspace } = params; + const { + autoStartFuelCore, + contracts, + output, + predicates, + root, + scripts, + forcPath, + fuelCorePath, + workspace, + } = params; const flag = (flags: (string | undefined)[], value?: string | boolean): string[] => value ? (flags as string[]) : []; @@ -103,6 +120,8 @@ export async function runInit(params: InitParams) { flag(['--contracts', contracts], contracts), flag(['--scripts', scripts], scripts), flag(['--predicates', predicates], predicates), + flag(['--forc-path', forcPath], forcPath), + flag(['--fuel-core-path', fuelCorePath], fuelCorePath), flag(['--auto-start-fuel-core'], autoStartFuelCore), ].flat(); From 597b615ae3373a913109dc5a3992e60eebf44cb4 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 24 Apr 2024 10:44:07 +0100 Subject: [PATCH 21/89] Re-added binary source log --- .../fuels/src/cli/commands/build/buildSwayPrograms.ts | 3 ++- packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts | 3 ++- packages/fuels/src/cli/utils/getBinarySource.ts | 8 +++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts b/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts index b700b796296..5f09ef87bd8 100644 --- a/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts +++ b/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts @@ -1,10 +1,11 @@ import type { FuelsConfig } from '../../types'; +import { getBinarySource } from '../../utils/getBinarySource'; import { log } from '../../utils/logger'; import { buildSwayProgram } from './buildSwayProgram'; export async function buildSwayPrograms(config: FuelsConfig) { - log(`Building Sway programs using 'forc'`); + log(`Building Sway programs using ${getBinarySource(config.fuelCorePath)} 'forc' binary`); const paths = config.workspace ? [config.workspace] diff --git a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts index d920e304d94..bd2f735d279 100644 --- a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts +++ b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts @@ -4,6 +4,7 @@ import type { ChildProcessWithoutNullStreams } from 'child_process'; import { getPortPromise } from 'portfinder'; import type { FuelsConfig } from '../../types'; +import { getBinarySource } from '../../utils/getBinarySource'; import { log, loggingConfig } from '../../utils/logger'; export type FuelCoreNode = { @@ -27,7 +28,7 @@ export const autoStartFuelCore = async (config: FuelsConfig) => { let fuelCore: FuelCoreNode | undefined; if (config.autoStartFuelCore) { - log(`Starting 'fuel-core' node..`); + log(`Starting ${getBinarySource(config.fuelCorePath)} 'fuel-core' node..`); const bindIp = '0.0.0.0'; const accessIp = '127.0.0.1'; diff --git a/packages/fuels/src/cli/utils/getBinarySource.ts b/packages/fuels/src/cli/utils/getBinarySource.ts index 6323d447807..18b1e4a78f9 100644 --- a/packages/fuels/src/cli/utils/getBinarySource.ts +++ b/packages/fuels/src/cli/utils/getBinarySource.ts @@ -1,7 +1,5 @@ import chalk from 'chalk'; -export const getBinarySource = (useBuiltIn: boolean) => - ({ - true: chalk.cyan('built-in'), - false: chalk.green('source'), - })[`${useBuiltIn}`]; +export const getBinarySource = (binaryPath?: string) => binaryPath ? + chalk.cyan('user-defined') : + chalk.green('source'); \ No newline at end of file From d0dbd512cbbb1d460ccf61fa695a98c5e70e2146 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 24 Apr 2024 11:01:56 +0100 Subject: [PATCH 22/89] Readd tests for init config --- packages/fuels/test/features/init.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/fuels/test/features/init.test.ts b/packages/fuels/test/features/init.test.ts index a105dc16e6d..39e494390ed 100644 --- a/packages/fuels/test/features/init.test.ts +++ b/packages/fuels/test/features/init.test.ts @@ -40,20 +40,25 @@ describe('init', () => { const fuelsContents = readFileSync(paths.fuelsConfigPath, 'utf-8'); expect(fuelsContents).toMatch(`workspace: './workspace',`); expect(fuelsContents).toMatch(`output: './output',`); + expect(fuelsContents).not.toMatch(`forcPath: 'fuels-forc',`); + expect(fuelsContents).not.toMatch(`fuelCorePath: 'fuels-core',`); }); - it('should run `init` command using built-in flags', async () => { + it('should run `init` command using custom binaries', async () => { await runInit({ root: paths.root, workspace: paths.workspaceDir, output: paths.outputDir, - useBuiltinBinaries: true, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, }); expect(existsSync(paths.fuelsConfigPath)).toBeTruthy(); const fuelsContents = readFileSync(paths.fuelsConfigPath, 'utf-8'); expect(fuelsContents).toMatch(`workspace: './workspace',`); expect(fuelsContents).toMatch(`output: './output',`); + expect(fuelsContents).toMatch(`forcPath: 'fuels-forc',`); + expect(fuelsContents).toMatch(`fuelCorePath: 'fuels-core',`); }); it('should run `init` command and throw for existent config file', async () => { From 65eba4e8305fc4fdb46a3672d295d14c65803e32 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 24 Apr 2024 11:11:09 +0100 Subject: [PATCH 23/89] Adding functionality to pass thought a custom fuelCorePath to launchNode --- .../account/src/test-utils/launchNode.test.ts | 31 +++++++++++++++++++ packages/account/src/test-utils/launchNode.ts | 4 ++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/account/src/test-utils/launchNode.test.ts b/packages/account/src/test-utils/launchNode.test.ts index f49d0913499..d83476895df 100644 --- a/packages/account/src/test-utils/launchNode.test.ts +++ b/packages/account/src/test-utils/launchNode.test.ts @@ -90,6 +90,37 @@ describe('launchNode', () => { cleanup(); }); + test('should start `fuel-core` node with custom binary', async () => { + const { spawn } = mockSpawn(); + + const { cleanup, ip, port } = await launchNode({ + ...defaultLaunchNodeConfig, + fuelCorePath: 'fuels-core', + }); + + expect(ip).toBe('0.0.0.0'); + expect(port).toBe('4000'); + expect(spawn).toBeCalledWith('fuels-core', expect.any(Array), expect.any(Object)); + + cleanup(); + }); + + test('should start `fuel-core` node with system binary (favour over custom)', async () => { + const { spawn } = mockSpawn(); + + const { cleanup, ip, port } = await launchNode({ + ...defaultLaunchNodeConfig, + fuelCorePath: 'custom-fuels-core', + useSystemFuelCore: true, + }); + + expect(ip).toBe('0.0.0.0'); + expect(port).toBe('4000'); + expect(spawn).toBeCalledWith('fuel-core', expect.any(Array), expect.any(Object)); + + cleanup(); + }); + test('should throw on error', async () => { const { innerMocks } = mockSpawn({ shouldError: true }); diff --git a/packages/account/src/test-utils/launchNode.ts b/packages/account/src/test-utils/launchNode.ts index a1f70d49873..f89b176099e 100644 --- a/packages/account/src/test-utils/launchNode.ts +++ b/packages/account/src/test-utils/launchNode.ts @@ -40,6 +40,7 @@ export type LaunchNodeOptions = { ip?: string; port?: string; args?: string[]; + fuelCorePath?: string; useSystemFuelCore?: boolean; loggingEnabled?: boolean; debugEnabled?: boolean; @@ -97,6 +98,7 @@ export const launchNode = async ({ ip, port, args = [], + fuelCorePath = undefined, useSystemFuelCore = false, loggingEnabled = true, debugEnabled = false, @@ -124,7 +126,7 @@ export const launchNode = async ({ // This string is logged by the client when the node has successfully started. We use it to know when to resolve. const graphQLStartSubstring = 'Binding GraphQL provider to'; - const binPath = findBinPath('fuels-core', __dirname); + const binPath = fuelCorePath ?? findBinPath('fuels-core', __dirname); const command = useSystemFuelCore ? 'fuel-core' : binPath; From 01c4ecdb310263caf75f5f69a7eb12788101dae4 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 24 Apr 2024 11:20:11 +0100 Subject: [PATCH 24/89] Added fuelCorePath to autoStartFuelCore --- .../src/cli/commands/dev/autoStartFuelCore.test.ts | 10 ++++++++-- .../fuels/src/cli/commands/dev/autoStartFuelCore.ts | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts index fc8aa161f9e..94ece721b09 100644 --- a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts +++ b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts @@ -55,11 +55,11 @@ describe('autoStartFuelCore', () => { expect(launchNode).toHaveBeenCalledTimes(0); }); - test('should start `fuel-core` node using built-in binary', async () => { + test('should start `fuel-core` node using custom binary', async () => { const { launchNode } = mockLaunchNode(); const copyConfig: FuelsConfig = structuredClone(fuelsConfig); - copyConfig.useBuiltinFuelCore = true; + copyConfig.fuelCorePath = 'fuels-core'; // this will cause it to autofind a free port copyConfig.fuelCorePort = undefined; @@ -74,6 +74,12 @@ describe('autoStartFuelCore', () => { expect(core.port).toBeGreaterThanOrEqual(4000); expect(core.providerUrl).toMatch(/http:\/\/127\.0\.0\.1:([0-9]+)\/graphql/); expect(core.killChildProcess).toBeTruthy(); + expect(launchNode).toBeCalledWith( + expect.objectContaining({ + fuelCorePath: 'fuels-core', + useSystemFuelCore: false, + }) + ) core.killChildProcess(); }); diff --git a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts index bd2f735d279..6221fc024f9 100644 --- a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts +++ b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts @@ -47,7 +47,8 @@ export const autoStartFuelCore = async (config: FuelsConfig) => { loggingEnabled: loggingConfig.isLoggingEnabled, debugEnabled: loggingConfig.isDebugEnabled, basePath: config.basePath, - useSystemFuelCore: true, + fuelCorePath: config.fuelCorePath, + useSystemFuelCore: !config.fuelCorePath, }); fuelCore = { From 4d6568a12a67d6b8d0b3ed3410e374eefe6cf23e Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 24 Apr 2024 11:28:07 +0100 Subject: [PATCH 25/89] Tests around loadConfig --- .../fuels/src/cli/config/loadConfig.test.ts | 28 +++++++++++++++++++ packages/fuels/src/cli/config/loadConfig.ts | 4 +-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/fuels/src/cli/config/loadConfig.test.ts b/packages/fuels/src/cli/config/loadConfig.test.ts index ee4e3ec9f9d..6c84f1913b9 100644 --- a/packages/fuels/src/cli/config/loadConfig.test.ts +++ b/packages/fuels/src/cli/config/loadConfig.test.ts @@ -120,4 +120,32 @@ describe('loadConfig', () => { expect(error?.message).toMatch(/forc workspace not detected/i); expect(error?.message).toMatch(/try using 'contracts'/i); }); + + test('should use system binary paths by default', async () => { + await runInit({ + root: paths.root, + workspace: paths.workspaceDir, + output: paths.outputDir, + }); + + const config = await loadConfig(paths.root); + + expect(config.forcPath).toEqual('forc'); + expect(config.fuelCorePath).toEqual('fuel-core'); + }) + + test(`should load custom binary paths`, async () => { + await runInit({ + root: paths.root, + workspace: paths.workspaceDir, + output: paths.outputDir, + forcPath: 'fuels-forc', + fuelCorePath: 'fuels-core', + }); + + const config = await loadConfig(paths.root); + + expect(config.forcPath).toEqual('fuels-forc'); + expect(config.fuelCorePath).toEqual('fuels-core'); + }) }); diff --git a/packages/fuels/src/cli/config/loadConfig.ts b/packages/fuels/src/cli/config/loadConfig.ts index 4f387ebe75f..08b0b76c9a5 100644 --- a/packages/fuels/src/cli/config/loadConfig.ts +++ b/packages/fuels/src/cli/config/loadConfig.ts @@ -56,10 +56,10 @@ export async function loadConfig(cwd: string): Promise { fuelCorePort: 4000, providerUrl: FUEL_NETWORK_URL, privateKey: defaultConsensusKey, - forcPath, - fuelCorePath, ...userConfig, basePath: cwd, + forcPath, + fuelCorePath, configPath, forcBuildFlags, buildMode, From abc48ea73a89a72e498061a07f218a0f2a96aeff Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 24 Apr 2024 11:40:18 +0100 Subject: [PATCH 26/89] Changeset update --- .changeset/friendly-deers-glow.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.changeset/friendly-deers-glow.md b/.changeset/friendly-deers-glow.md index 61235d6873e..fb23aa9cb20 100644 --- a/.changeset/friendly-deers-glow.md +++ b/.changeset/friendly-deers-glow.md @@ -1,4 +1,7 @@ --- +"@fuel-ts/account": patch +"fuels": minor +"@fuel-ts/versions": patch --- chore!: Remove built-in binaries for `forc` and `fuel-core` \ No newline at end of file From f4faeb0ebe11ef0459a7b1921236dbe9e64edf61 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 24 Apr 2024 11:40:25 +0100 Subject: [PATCH 27/89] Lint --- .../fuels/src/cli/commands/dev/autoStartFuelCore.test.ts | 2 +- packages/fuels/src/cli/config/loadConfig.test.ts | 4 ++-- packages/fuels/src/cli/utils/getBinarySource.ts | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts index 94ece721b09..a8abfb972f5 100644 --- a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts +++ b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts @@ -79,7 +79,7 @@ describe('autoStartFuelCore', () => { fuelCorePath: 'fuels-core', useSystemFuelCore: false, }) - ) + ); core.killChildProcess(); }); diff --git a/packages/fuels/src/cli/config/loadConfig.test.ts b/packages/fuels/src/cli/config/loadConfig.test.ts index 6c84f1913b9..94aec9f8ee9 100644 --- a/packages/fuels/src/cli/config/loadConfig.test.ts +++ b/packages/fuels/src/cli/config/loadConfig.test.ts @@ -132,7 +132,7 @@ describe('loadConfig', () => { expect(config.forcPath).toEqual('forc'); expect(config.fuelCorePath).toEqual('fuel-core'); - }) + }); test(`should load custom binary paths`, async () => { await runInit({ @@ -147,5 +147,5 @@ describe('loadConfig', () => { expect(config.forcPath).toEqual('fuels-forc'); expect(config.fuelCorePath).toEqual('fuels-core'); - }) + }); }); diff --git a/packages/fuels/src/cli/utils/getBinarySource.ts b/packages/fuels/src/cli/utils/getBinarySource.ts index 18b1e4a78f9..ddfd219a26e 100644 --- a/packages/fuels/src/cli/utils/getBinarySource.ts +++ b/packages/fuels/src/cli/utils/getBinarySource.ts @@ -1,5 +1,4 @@ import chalk from 'chalk'; -export const getBinarySource = (binaryPath?: string) => binaryPath ? - chalk.cyan('user-defined') : - chalk.green('source'); \ No newline at end of file +export const getBinarySource = (binaryPath?: string) => + binaryPath ? chalk.cyan('user-defined') : chalk.green('source'); From 51bedd0c1a8d572cd8136cd0fda2ff4e034ff491 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 24 Apr 2024 14:34:13 +0100 Subject: [PATCH 28/89] Removed unneeded forc path conditional --- packages/fuels/src/cli/commands/build/buildSwayProgram.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/fuels/src/cli/commands/build/buildSwayProgram.ts b/packages/fuels/src/cli/commands/build/buildSwayProgram.ts index 8e49f523295..89b29e15f81 100644 --- a/packages/fuels/src/cli/commands/build/buildSwayProgram.ts +++ b/packages/fuels/src/cli/commands/build/buildSwayProgram.ts @@ -8,11 +8,9 @@ import { onForcExit, onForcError } from './forcHandlers'; export const buildSwayProgram = async (config: FuelsConfig, path: string) => { debug('Building Sway program', path); - const forcPath = config.forcPath ?? 'forc'; - return new Promise((resolve, reject) => { const args = ['build', '-p', path].concat(config.forcBuildFlags); - const forc = spawn(forcPath, args, { stdio: 'pipe' }); + const forc = spawn(config.forcPath, args, { stdio: 'pipe' }); if (loggingConfig.isLoggingEnabled) { forc.stderr?.pipe(process.stderr); From 82039500edcb75394ef3d73d20bd5e5321e6a01a Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 24 Apr 2024 15:02:52 +0100 Subject: [PATCH 29/89] Removed `useSystemFuelCore` from `autoStartFuelCore` --- packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts index 6221fc024f9..765b1257731 100644 --- a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts +++ b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts @@ -48,7 +48,6 @@ export const autoStartFuelCore = async (config: FuelsConfig) => { debugEnabled: loggingConfig.isDebugEnabled, basePath: config.basePath, fuelCorePath: config.fuelCorePath, - useSystemFuelCore: !config.fuelCorePath, }); fuelCore = { From ac61598afeda06d02a03071fbf67d606b29d331d Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 24 Apr 2024 15:06:19 +0100 Subject: [PATCH 30/89] Added doc block param for launchNode --- packages/account/src/test-utils/launchNode.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/account/src/test-utils/launchNode.ts b/packages/account/src/test-utils/launchNode.ts index f89b176099e..89a28faba80 100644 --- a/packages/account/src/test-utils/launchNode.ts +++ b/packages/account/src/test-utils/launchNode.ts @@ -88,6 +88,7 @@ export const killNode = (params: KillNodeParams) => { * @param ip - the ip to bind to. (optional, defaults to 0.0.0.0) * @param port - the port to bind to. (optional, defaults to 4000 or the next available port) * @param args - additional arguments to pass to fuel-core. + * @param fuelCorePath - the path to the fuel-core binary. (optional, defaults to the fuel-core binary in the node_modules folder) * @param useSystemFuelCore - whether to use the system fuel-core binary or the one provided by the \@internal/fuel-core package. * @param loggingEnabled - whether the node should output logs. (optional, defaults to true) * @param debugEnabled - whether the node should log debug messages. (optional, defaults to false) From 3c336f8fec2951001b152e11ac36ae9201683984 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 24 Apr 2024 15:08:37 +0100 Subject: [PATCH 31/89] Removed --- packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts index a8abfb972f5..f6434943a97 100644 --- a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts +++ b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts @@ -77,7 +77,6 @@ describe('autoStartFuelCore', () => { expect(launchNode).toBeCalledWith( expect.objectContaining({ fuelCorePath: 'fuels-core', - useSystemFuelCore: false, }) ); From 675d168d95841eeb228c615501b302c8ff949029 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 24 Apr 2024 17:02:47 +0100 Subject: [PATCH 32/89] Removed @fuel-ts/versions from changeset --- .changeset/friendly-deers-glow.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.changeset/friendly-deers-glow.md b/.changeset/friendly-deers-glow.md index fb23aa9cb20..a40ec38f354 100644 --- a/.changeset/friendly-deers-glow.md +++ b/.changeset/friendly-deers-glow.md @@ -1,7 +1,6 @@ --- "@fuel-ts/account": patch "fuels": minor -"@fuel-ts/versions": patch --- chore!: Remove built-in binaries for `forc` and `fuel-core` \ No newline at end of file From 5b04cdd9182ccc36214b82bc0d0188e161c759db Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 25 Apr 2024 16:14:02 +0100 Subject: [PATCH 33/89] Update .changeset/friendly-deers-glow.md Co-authored-by: Anderson Arboleya --- .changeset/friendly-deers-glow.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/friendly-deers-glow.md b/.changeset/friendly-deers-glow.md index a40ec38f354..000ce7e9f35 100644 --- a/.changeset/friendly-deers-glow.md +++ b/.changeset/friendly-deers-glow.md @@ -3,4 +3,4 @@ "fuels": minor --- -chore!: Remove built-in binaries for `forc` and `fuel-core` \ No newline at end of file +chore!: remove built-in binaries for `forc` and `fuel-core` \ No newline at end of file From dab42020adf5b251e501cfea311d344fdaa8ea2c Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 25 Apr 2024 17:41:58 +0100 Subject: [PATCH 34/89] Added rewrite functionality for fuels.config --- packages/create-fuels/package.json | 2 +- .../scripts/rewriteTemplateFiles.ts | 19 +++++++++++++++++++ .../scripts/rewriteTemplatePackageJson.ts | 12 ------------ 3 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 packages/create-fuels/scripts/rewriteTemplateFiles.ts delete mode 100644 packages/create-fuels/scripts/rewriteTemplatePackageJson.ts diff --git a/packages/create-fuels/package.json b/packages/create-fuels/package.json index 31c7c3c42d7..253c3874685 100644 --- a/packages/create-fuels/package.json +++ b/packages/create-fuels/package.json @@ -16,7 +16,7 @@ "license": "Apache-2.0", "scripts": { "build": "tsup", - "prepublishOnly": "cp -r ../../templates . && tsx ./scripts/rewriteTemplatePackageJson.ts" + "prepublishOnly": "cp -r ../../templates . && tsx ./scripts/rewriteTemplateFiles.ts" }, "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/packages/create-fuels/scripts/rewriteTemplateFiles.ts b/packages/create-fuels/scripts/rewriteTemplateFiles.ts new file mode 100644 index 00000000000..573016ed0d9 --- /dev/null +++ b/packages/create-fuels/scripts/rewriteTemplateFiles.ts @@ -0,0 +1,19 @@ +import { versions } from '@fuel-ts/versions'; +import { readFileSync, writeFileSync } from 'fs'; +import { join } from 'path'; + +const templateDir = join(__dirname, '../templates/nextjs'); +const packageJsonFilePath = join(templateDir, 'package.json'); +const fuelsConfigFilePath = join(templateDir, 'fuels.config.ts'); + +// package.json +let contents = readFileSync(packageJsonFilePath, 'utf-8'); +contents = contents.replace(/xprebuild/g, 'prebuild'); +contents = contents.replace(/"fuels": "workspace:\*"/, `"fuels": "${versions.FUELS}"`); +writeFileSync(packageJsonFilePath, contents); + +// fuels.config.ts +contents = readFileSync(fuelsConfigFilePath, 'utf-8'); +contents = contents.replace(/\n\W+forcPath: 'fuels-forc',/g, '') +contents = contents.replace(/\n\W+fuelCorePath: 'fuels-core',/g, '') +writeFileSync(fuelsConfigFilePath, contents); diff --git a/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts b/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts deleted file mode 100644 index 907be434c6f..00000000000 --- a/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { versions } from '@fuel-ts/versions'; -import { readFileSync, writeFileSync } from 'fs'; -import { join } from 'path'; - -const filepath = join(__dirname, '../templates/nextjs/package.json'); - -let contents = readFileSync(filepath, 'utf-8'); - -contents = contents.replace(/xprebuild/g, 'prebuild'); -contents = contents.replace(/"fuels": "workspace:\*"/, `"fuels": "${versions.FUELS}"`); - -writeFileSync(filepath, contents); From f3536b1ba097a3452c27b1eac0d02366be3632f7 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Sat, 27 Apr 2024 09:19:11 +0100 Subject: [PATCH 35/89] Removed binaries doc --- apps/docs/src/guide/fuels-cli/binaries.md | 61 ----------------------- 1 file changed, 61 deletions(-) delete mode 100644 apps/docs/src/guide/fuels-cli/binaries.md diff --git a/apps/docs/src/guide/fuels-cli/binaries.md b/apps/docs/src/guide/fuels-cli/binaries.md deleted file mode 100644 index e70d1d798e5..00000000000 --- a/apps/docs/src/guide/fuels-cli/binaries.md +++ /dev/null @@ -1,61 +0,0 @@ - - -# Built-In Binaries - -`fuels` conveniently ships with `built-in` binaries for [`forc`](https://docs.fuel.network/docs/forc/commands/) and [`fuel-core`](https://docs.fuel.network/guides/running-a-node/running-a-local-node/). - -In case you haven't installed [The Fuel Toolchain](#the-fuel-toolchain) _yet_, these will be used. - -Here's how to configure this explicitly: - -- [`useBuiltinForc`](./config-file.md#usebuiltinforc): `true` -- [`useBuiltinFuelCore`](./config-file.md#usebuiltinfuelcore): `true` - -<<< @../../../demo-fuels/fuels.config.explicit-built-in.ts#config-built-in{ts:line-numbers} - -You can also call the `built-in` binaries directly: - -```console-vue -npx fuels@{{fuels}} help forc -npx fuels@{{fuels}} forc --version -npx fuels@{{fuels}} forc test -h -``` - -```console-vue -npx fuels@{{fuels}} help core -npx fuels@{{fuels}} core --version -npx fuels@{{fuels}} core run -h -``` - -Check the docs for `forc` and `fuel-core`: - -- [Forc Commands](https://docs.fuel.network/docs/forc/commands/) -- [Running a local Node using `fuel-core`](https://docs.fuel.network/guides/running-a-node/running-a-local-node/) - -## The Fuel Toolchain - -The Fuel Toolchain consists of several [components](https://docs.fuel.network/docs/sway/introduction/fuel_toolchain/). - -You can use [`fuel-up`](https://docs.fuel.network/docs/fuelup/installation/) to get it up and running. - -Check if it's working correctly with: - -```console -forc --version -``` - -```console -fuel-core --version -``` - -The `forc` and `fuel-core` binaries will be available in your `system` and `fuels` automatically prioritize them instead of the `built-in` ones. - -Here's how to configure this explicitly: - -- [`useBuiltinForc`](./config-file.md#usebuiltinforc): `false` -- [`useBuiltinFuelCore`](./config-file.md#usebuiltinfuelcore): `false` - -<<< @../../../demo-fuels/fuels.config.explicit-system.ts#config-system{ts:line-numbers} From adfab06eb92463f1a7dce25a1935b3bc47b6dd5b Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Sat, 27 Apr 2024 09:20:12 +0100 Subject: [PATCH 36/89] Lint --- packages/create-fuels/scripts/rewriteTemplateFiles.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/create-fuels/scripts/rewriteTemplateFiles.ts b/packages/create-fuels/scripts/rewriteTemplateFiles.ts index 573016ed0d9..5767c0b5259 100644 --- a/packages/create-fuels/scripts/rewriteTemplateFiles.ts +++ b/packages/create-fuels/scripts/rewriteTemplateFiles.ts @@ -14,6 +14,6 @@ writeFileSync(packageJsonFilePath, contents); // fuels.config.ts contents = readFileSync(fuelsConfigFilePath, 'utf-8'); -contents = contents.replace(/\n\W+forcPath: 'fuels-forc',/g, '') -contents = contents.replace(/\n\W+fuelCorePath: 'fuels-core',/g, '') +contents = contents.replace(/\n\W+forcPath: 'fuels-forc',/g, ''); +contents = contents.replace(/\n\W+fuelCorePath: 'fuels-core',/g, ''); writeFileSync(fuelsConfigFilePath, contents); From 36fd47cb44e89d5125d1c1ec3105128f39be04cd Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 30 Apr 2024 08:35:01 +0100 Subject: [PATCH 37/89] Log out the binary paths for debugging purposes only --- packages/fuels/src/cli/commands/build/buildSwayPrograms.ts | 6 +++--- packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts | 6 +++--- packages/fuels/src/cli/utils/getBinarySource.ts | 4 ---- 3 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 packages/fuels/src/cli/utils/getBinarySource.ts diff --git a/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts b/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts index 5f09ef87bd8..22794c27b3c 100644 --- a/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts +++ b/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts @@ -1,11 +1,11 @@ import type { FuelsConfig } from '../../types'; -import { getBinarySource } from '../../utils/getBinarySource'; -import { log } from '../../utils/logger'; +import { log, debug } from '../../utils/logger'; import { buildSwayProgram } from './buildSwayProgram'; export async function buildSwayPrograms(config: FuelsConfig) { - log(`Building Sway programs using ${getBinarySource(config.fuelCorePath)} 'forc' binary`); + log(`Building Sway programs using 'forc' binary`); + debug(`Using 'forc' binary from: ${config.forcPath}`); const paths = config.workspace ? [config.workspace] diff --git a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts index 8d0624e9af9..a6827e06fb2 100644 --- a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts +++ b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts @@ -4,8 +4,7 @@ import type { ChildProcessWithoutNullStreams } from 'child_process'; import { getPortPromise } from 'portfinder'; import type { FuelsConfig } from '../../types'; -import { getBinarySource } from '../../utils/getBinarySource'; -import { log, loggingConfig } from '../../utils/logger'; +import { debug, log, loggingConfig } from '../../utils/logger'; export type FuelCoreNode = { bindIp: string; @@ -28,7 +27,8 @@ export const autoStartFuelCore = async (config: FuelsConfig) => { let fuelCore: FuelCoreNode | undefined; if (config.autoStartFuelCore) { - log(`Starting ${getBinarySource(config.fuelCorePath)} 'fuel-core' node..`); + log(`Starting 'fuel-core' node..`); + debug(`Using 'fuel-core' binary from: ${config.fuelCorePath}`); const bindIp = '0.0.0.0'; const accessIp = '127.0.0.1'; diff --git a/packages/fuels/src/cli/utils/getBinarySource.ts b/packages/fuels/src/cli/utils/getBinarySource.ts deleted file mode 100644 index ddfd219a26e..00000000000 --- a/packages/fuels/src/cli/utils/getBinarySource.ts +++ /dev/null @@ -1,4 +0,0 @@ -import chalk from 'chalk'; - -export const getBinarySource = (binaryPath?: string) => - binaryPath ? chalk.cyan('user-defined') : chalk.green('source'); From be777c56afd8db3be49317c1486b0bc86657ccaf Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 1 May 2024 07:11:41 +0100 Subject: [PATCH 38/89] Fix changeset version --- .changeset/friendly-deers-glow.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/friendly-deers-glow.md b/.changeset/friendly-deers-glow.md index 000ce7e9f35..4f8a0155fe7 100644 --- a/.changeset/friendly-deers-glow.md +++ b/.changeset/friendly-deers-glow.md @@ -1,6 +1,6 @@ --- "@fuel-ts/account": patch -"fuels": minor +"fuels": patch --- chore!: remove built-in binaries for `forc` and `fuel-core` \ No newline at end of file From 34ec48dc097164e4fc2c02ce4c7a704722317dd6 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 1 May 2024 09:58:20 +0100 Subject: [PATCH 39/89] Reshuffle test case --- .../src/lib/getSystemVersions.test.ts | 157 +++++++++--------- 1 file changed, 78 insertions(+), 79 deletions(-) diff --git a/packages/versions/src/lib/getSystemVersions.test.ts b/packages/versions/src/lib/getSystemVersions.test.ts index 85d09234ccb..8577dc8b849 100644 --- a/packages/versions/src/lib/getSystemVersions.test.ts +++ b/packages/versions/src/lib/getSystemVersions.test.ts @@ -10,95 +10,94 @@ vi.mock('child_process', async () => { }; }); +/* + Test (mocking) utility +*/ +function mockAllDeps(params: { + systemForcVersion: string; + systemFuelCoreVersion: string; + shouldThrow?: boolean; +}) { + const { systemForcVersion, systemFuelCoreVersion, shouldThrow } = params; + + const error = vi.spyOn(console, 'error').mockImplementation(() => []); + + const mockedExecOk = vi.fn(); + mockedExecOk.mockReturnValueOnce(systemForcVersion); // first call (forc) + mockedExecOk.mockReturnValueOnce(systemFuelCoreVersion); // second call (fuel-core) + + const execSyncThrow = vi.fn(() => { + throw new Error(); + }); + + const execSync = vi + .spyOn(childProcessMod, 'execSync') + .mockImplementation(shouldThrow ? execSyncThrow : mockedExecOk); + + return { + error, + execSync, + }; +} + /** * @group node */ -describe('getSystemVersions.js', () => { - /* - Test (mocking) utility - */ - function mockAllDeps(params: { - systemForcVersion: string; - systemFuelCoreVersion: string; - shouldThrow?: boolean; - }) { - const { systemForcVersion, systemFuelCoreVersion, shouldThrow } = params; - - const error = vi.spyOn(console, 'error').mockImplementation(() => []); - - const mockedExecOk = vi.fn(); - mockedExecOk.mockReturnValueOnce(systemForcVersion); // first call (forc) - mockedExecOk.mockReturnValueOnce(systemFuelCoreVersion); // second call (fuel-core) - - const execSyncThrow = vi.fn(() => { - throw new Error(); - }); - - const execSync = vi - .spyOn(childProcessMod, 'execSync') - .mockImplementation(shouldThrow ? execSyncThrow : mockedExecOk); - - return { - error, - execSync, - }; - } - - /* - Tests - */ - test('should get user versions just fine', () => { - // mocking - const systemForcVersion = '1.0.0'; - const systemFuelCoreVersion = '2.0.0'; - const { execSync } = mockAllDeps({ - systemForcVersion, - systemFuelCoreVersion, +describe('getSystemVersions', () => { + describe('default behavior', () => { + test('should get user versions just fine', () => { + // mocking + const systemForcVersion = '1.0.0'; + const systemFuelCoreVersion = '2.0.0'; + const { execSync } = mockAllDeps({ + systemForcVersion, + systemFuelCoreVersion, + }); + + // executing + const versions = getSystemVersions(); + + // validating + expect(execSync).toHaveBeenCalledTimes(2); + expect(versions.systemForcVersion).toEqual(systemForcVersion); + expect(versions.systemFuelCoreVersion).toEqual(systemFuelCoreVersion); }); - // executing - const versions = getSystemVersions(); + test('should return error if Forc or Fuel-Core is not installed', () => { + // mocking + const systemForcVersion = '1.0.0'; + const systemFuelCoreVersion = '2.0.0'; - // validating - expect(execSync).toHaveBeenCalledTimes(2); - expect(versions.systemForcVersion).toEqual(systemForcVersion); - expect(versions.systemFuelCoreVersion).toEqual(systemFuelCoreVersion); - }); + mockAllDeps({ + systemForcVersion, + systemFuelCoreVersion, + shouldThrow: true, + }); - test('should return error if Forc or Fuel-Core is not installed', () => { - // mocking - const systemForcVersion = '1.0.0'; - const systemFuelCoreVersion = '2.0.0'; + // executing + const { error: systemError } = getSystemVersions(); - mockAllDeps({ - systemForcVersion, - systemFuelCoreVersion, - shouldThrow: true, + // validating + expect(systemError).toBeTruthy(); }); - // executing - const { error: systemError } = getSystemVersions(); - - // validating - expect(systemError).toBeTruthy(); - }); - - test('should throw for fuelup exception', () => { - // mocking - const systemForcVersion = 'fuelup exception'; - const systemFuelCoreVersion = 'fuelup exception'; - const { execSync } = mockAllDeps({ - systemForcVersion, - systemFuelCoreVersion, + test('should throw for fuelup exception', () => { + // mocking + const systemForcVersion = 'fuelup exception'; + const systemFuelCoreVersion = 'fuelup exception'; + const { execSync } = mockAllDeps({ + systemForcVersion, + systemFuelCoreVersion, + }); + + // executing + const versions = getSystemVersions(); + + // validating + expect(execSync).toHaveBeenCalledTimes(2); + expect(versions.error?.toString()).toEqual(`Error: ${systemForcVersion}`); + expect(versions.systemForcVersion).toEqual(null); + expect(versions.systemFuelCoreVersion).toEqual(null); }); - - // executing - const versions = getSystemVersions(); - - // validating - expect(execSync).toHaveBeenCalledTimes(2); - expect(versions.error?.toString()).toEqual(`Error: ${systemForcVersion}`); - expect(versions.systemForcVersion).toEqual(null); - expect(versions.systemFuelCoreVersion).toEqual(null); }); }); From 7c77c50e0f0ded2a85ef8c94dc805b5541c9e33e Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 1 May 2024 10:31:46 +0100 Subject: [PATCH 40/89] Added functionality to pass through a custom fuel core or forc path to system versions --- .../src/lib/getSystemVersions.test.ts | 28 +++++++++++++++---- .../versions/src/lib/getSystemVersions.ts | 17 ++++++----- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/packages/versions/src/lib/getSystemVersions.test.ts b/packages/versions/src/lib/getSystemVersions.test.ts index 8577dc8b849..7ce786cf3b5 100644 --- a/packages/versions/src/lib/getSystemVersions.test.ts +++ b/packages/versions/src/lib/getSystemVersions.test.ts @@ -40,11 +40,21 @@ function mockAllDeps(params: { }; } +const defaultBinaryPaths = { forcPath: 'forc', fuelCorePath: 'fuel-core' }; +const scenarioBinaryPaths = [ + { message: 'Using default "forc" and "fuel-core"' }, + { message: 'Using custom "forc" path', forcPath: 'fuels-forc' }, + { message: 'Using custom "fuel-core" path', fuelCorePath: 'fuels-core' }, + { message: 'Using custom "forc" and "fuel-core" path', forcPath: 'fuels-forc', fuelCorePath: 'fuels-core' }, +] + /** * @group node */ describe('getSystemVersions', () => { - describe('default behavior', () => { + describe.each(scenarioBinaryPaths)('$message', ({ message: _, ...params }) => { + const { forcPath: expectedForcCommand, fuelCorePath: expectedFuelCoreCommand } = { ...defaultBinaryPaths, ...params }; + test('should get user versions just fine', () => { // mocking const systemForcVersion = '1.0.0'; @@ -55,10 +65,12 @@ describe('getSystemVersions', () => { }); // executing - const versions = getSystemVersions(); + const versions = getSystemVersions(params); // validating expect(execSync).toHaveBeenCalledTimes(2); + expect(execSync).toBeCalledWith(`${expectedForcCommand} --version`); + expect(execSync).toBeCalledWith(`${expectedFuelCoreCommand} --version`); expect(versions.systemForcVersion).toEqual(systemForcVersion); expect(versions.systemFuelCoreVersion).toEqual(systemFuelCoreVersion); }); @@ -67,17 +79,19 @@ describe('getSystemVersions', () => { // mocking const systemForcVersion = '1.0.0'; const systemFuelCoreVersion = '2.0.0'; - - mockAllDeps({ + const { execSync } = mockAllDeps({ systemForcVersion, systemFuelCoreVersion, shouldThrow: true, }); // executing - const { error: systemError } = getSystemVersions(); + const { error: systemError } = getSystemVersions(params); // validating + expect(execSync).toHaveBeenCalledTimes(2); + expect(execSync).toBeCalledWith(`${expectedForcCommand} --version`); + expect(execSync).toBeCalledWith(`${expectedFuelCoreCommand} --version`); expect(systemError).toBeTruthy(); }); @@ -91,10 +105,12 @@ describe('getSystemVersions', () => { }); // executing - const versions = getSystemVersions(); + const versions = getSystemVersions(params); // validating expect(execSync).toHaveBeenCalledTimes(2); + expect(execSync).toBeCalledWith(`${expectedForcCommand} --version`); + expect(execSync).toBeCalledWith(`${expectedFuelCoreCommand} --version`); expect(versions.error?.toString()).toEqual(`Error: ${systemForcVersion}`); expect(versions.systemForcVersion).toEqual(null); expect(versions.systemFuelCoreVersion).toEqual(null); diff --git a/packages/versions/src/lib/getSystemVersions.ts b/packages/versions/src/lib/getSystemVersions.ts index 86ea4a2b63c..00888d3f2e5 100644 --- a/packages/versions/src/lib/getSystemVersions.ts +++ b/packages/versions/src/lib/getSystemVersions.ts @@ -1,6 +1,8 @@ import { execSync } from 'child_process'; const versionReg = /[0-9]+\.[0-9]+\.[0-9]/; +const defaultForcPath = 'forc'; +const defaultFuelCorePath = 'fuel-core'; export const getSystemVersion = (command: string) => { let version: string | null = null; @@ -23,19 +25,20 @@ export const getSystemVersion = (command: string) => { }; }; -export function getSystemForc() { - const { error, version: v } = getSystemVersion('forc --version'); +export function getSystemForc(forcPath: string = defaultForcPath) { + const { error, version: v } = getSystemVersion(`${forcPath} --version`); return { error, systemForcVersion: v }; } -export function getSystemFuelCore() { - const { error, version: v } = getSystemVersion('fuel-core --version'); +export function getSystemFuelCore(fuelCorePath: string = defaultFuelCorePath) { + const { error, version: v } = getSystemVersion(`${fuelCorePath} --version`); return { error, systemFuelCoreVersion: v }; } -export function getSystemVersions() { - const { error: errorForc, systemForcVersion } = getSystemForc(); - const { error: errorCore, systemFuelCoreVersion } = getSystemFuelCore(); +export function getSystemVersions(params: { forcPath?: string; fuelCorePath?: string } = {}) { + const { forcPath, fuelCorePath } = params; + const { error: errorForc, systemForcVersion } = getSystemForc(forcPath); + const { error: errorCore, systemFuelCoreVersion } = getSystemFuelCore(fuelCorePath); const error = errorForc ?? errorCore; From d3a678687fc3bfa972e9f9064963c63b25255ac2 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 1 May 2024 16:47:45 +0100 Subject: [PATCH 41/89] Throw error when binary path not found --- .../fuels/src/cli/config/loadConfig.test.ts | 22 +++++++++++++++++++ packages/fuels/src/cli/config/loadConfig.ts | 18 +++++++++++++-- .../versions/src/lib/getSystemVersions.ts | 4 ++-- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/packages/fuels/src/cli/config/loadConfig.test.ts b/packages/fuels/src/cli/config/loadConfig.test.ts index 94aec9f8ee9..64e6d73ffb7 100644 --- a/packages/fuels/src/cli/config/loadConfig.test.ts +++ b/packages/fuels/src/cli/config/loadConfig.test.ts @@ -148,4 +148,26 @@ describe('loadConfig', () => { expect(config.forcPath).toEqual('fuels-forc'); expect(config.fuelCorePath).toEqual('fuels-core'); }); + + test('should throw if system binary paths are not found', async () => { + await runInit({ + root: paths.root, + workspace: paths.workspaceDir, + output: paths.outputDir, + forcPath: '/non/existent/forc', + fuelCorePath: '/non/existent/fuel-core', + }); + + + const { error, result } = await safeExec( + () => loadConfig(paths.root) + ); + + const expectedMessage = [ + `Binary for 'forc' not found at path '/non/existent/forc'`, + `Binary for 'fuel-core' not found at path '/non/existent/fuel-core'`, + ].join('\n'); + expect(result).toBeFalsy(); + expect(error?.message).toEqual(expectedMessage) + }) }); diff --git a/packages/fuels/src/cli/config/loadConfig.ts b/packages/fuels/src/cli/config/loadConfig.ts index 08b0b76c9a5..93d106bb9a3 100644 --- a/packages/fuels/src/cli/config/loadConfig.ts +++ b/packages/fuels/src/cli/config/loadConfig.ts @@ -1,5 +1,7 @@ import { FUEL_NETWORK_URL } from '@fuel-ts/account/configs'; +import { FuelError } from '@fuel-ts/errors'; import { defaultConsensusKey } from '@fuel-ts/utils'; +import { getSystemForc, getSystemFuelCore } from '@fuel-ts/versions/cli'; import { bundleRequire } from 'bundle-require'; import type { BuildOptions } from 'esbuild'; import JoyCon from 'joycon'; @@ -43,8 +45,20 @@ export async function loadConfig(cwd: string): Promise { const releaseFlag = forcBuildFlags.find((f) => f === '--release'); const buildMode = releaseFlag ? 'release' : 'debug'; - const forcPath = userConfig.forcPath ?? 'forc'; - const fuelCorePath = userConfig.fuelCorePath ?? 'fuel-core'; + const { error: forcError, forcPath } = getSystemForc(userConfig.forcPath); + const { error: fuelCoreError, fuelCorePath } = getSystemFuelCore(userConfig.fuelCorePath); + + if (forcError || fuelCoreError) { + const errors = [ + forcError ? `Binary for 'forc' not found at path '${forcPath}'` : undefined, + fuelCoreError ? `Binary for 'fuel-core' not found at path '${fuelCorePath}'` : undefined, + ] + + throw new FuelError( + FuelError.CODES.BIN_FILE_NOT_FOUND, + errors.filter(Boolean).join('\n') + ); + } // Start clone-object while initializing optional props const config: FuelsConfig = { diff --git a/packages/versions/src/lib/getSystemVersions.ts b/packages/versions/src/lib/getSystemVersions.ts index 00888d3f2e5..b5fffd02411 100644 --- a/packages/versions/src/lib/getSystemVersions.ts +++ b/packages/versions/src/lib/getSystemVersions.ts @@ -27,12 +27,12 @@ export const getSystemVersion = (command: string) => { export function getSystemForc(forcPath: string = defaultForcPath) { const { error, version: v } = getSystemVersion(`${forcPath} --version`); - return { error, systemForcVersion: v }; + return { error, systemForcVersion: v, forcPath }; } export function getSystemFuelCore(fuelCorePath: string = defaultFuelCorePath) { const { error, version: v } = getSystemVersion(`${fuelCorePath} --version`); - return { error, systemFuelCoreVersion: v }; + return { error, systemFuelCoreVersion: v, fuelCorePath }; } export function getSystemVersions(params: { forcPath?: string; fuelCorePath?: string } = {}) { From 37527edb8bf76457f24ecc9bfc7cbfc05aad19c4 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 1 May 2024 16:48:21 +0100 Subject: [PATCH 42/89] Lint --- packages/fuels/src/cli/config/loadConfig.test.ts | 9 +++------ packages/fuels/src/cli/config/loadConfig.ts | 7 ++----- packages/versions/src/lib/getSystemVersions.test.ts | 13 ++++++++++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/fuels/src/cli/config/loadConfig.test.ts b/packages/fuels/src/cli/config/loadConfig.test.ts index 64e6d73ffb7..28df6b2b34b 100644 --- a/packages/fuels/src/cli/config/loadConfig.test.ts +++ b/packages/fuels/src/cli/config/loadConfig.test.ts @@ -158,16 +158,13 @@ describe('loadConfig', () => { fuelCorePath: '/non/existent/fuel-core', }); - - const { error, result } = await safeExec( - () => loadConfig(paths.root) - ); + const { error, result } = await safeExec(() => loadConfig(paths.root)); const expectedMessage = [ `Binary for 'forc' not found at path '/non/existent/forc'`, `Binary for 'fuel-core' not found at path '/non/existent/fuel-core'`, ].join('\n'); expect(result).toBeFalsy(); - expect(error?.message).toEqual(expectedMessage) - }) + expect(error?.message).toEqual(expectedMessage); + }); }); diff --git a/packages/fuels/src/cli/config/loadConfig.ts b/packages/fuels/src/cli/config/loadConfig.ts index 93d106bb9a3..63bae8812d7 100644 --- a/packages/fuels/src/cli/config/loadConfig.ts +++ b/packages/fuels/src/cli/config/loadConfig.ts @@ -52,12 +52,9 @@ export async function loadConfig(cwd: string): Promise { const errors = [ forcError ? `Binary for 'forc' not found at path '${forcPath}'` : undefined, fuelCoreError ? `Binary for 'fuel-core' not found at path '${fuelCorePath}'` : undefined, - ] + ]; - throw new FuelError( - FuelError.CODES.BIN_FILE_NOT_FOUND, - errors.filter(Boolean).join('\n') - ); + throw new FuelError(FuelError.CODES.BIN_FILE_NOT_FOUND, errors.filter(Boolean).join('\n')); } // Start clone-object while initializing optional props diff --git a/packages/versions/src/lib/getSystemVersions.test.ts b/packages/versions/src/lib/getSystemVersions.test.ts index 7ce786cf3b5..22442ff0058 100644 --- a/packages/versions/src/lib/getSystemVersions.test.ts +++ b/packages/versions/src/lib/getSystemVersions.test.ts @@ -45,15 +45,22 @@ const scenarioBinaryPaths = [ { message: 'Using default "forc" and "fuel-core"' }, { message: 'Using custom "forc" path', forcPath: 'fuels-forc' }, { message: 'Using custom "fuel-core" path', fuelCorePath: 'fuels-core' }, - { message: 'Using custom "forc" and "fuel-core" path', forcPath: 'fuels-forc', fuelCorePath: 'fuels-core' }, -] + { + message: 'Using custom "forc" and "fuel-core" path', + forcPath: 'fuels-forc', + fuelCorePath: 'fuels-core', + }, +]; /** * @group node */ describe('getSystemVersions', () => { describe.each(scenarioBinaryPaths)('$message', ({ message: _, ...params }) => { - const { forcPath: expectedForcCommand, fuelCorePath: expectedFuelCoreCommand } = { ...defaultBinaryPaths, ...params }; + const { forcPath: expectedForcCommand, fuelCorePath: expectedFuelCoreCommand } = { + ...defaultBinaryPaths, + ...params, + }; test('should get user versions just fine', () => { // mocking From 834b242103531559f20fc0dc2db04054bd98b612 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 1 May 2024 16:49:25 +0100 Subject: [PATCH 43/89] Added @fuels-ts/versions to changeset --- .changeset/friendly-deers-glow.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/friendly-deers-glow.md b/.changeset/friendly-deers-glow.md index 4f8a0155fe7..751151cfb68 100644 --- a/.changeset/friendly-deers-glow.md +++ b/.changeset/friendly-deers-glow.md @@ -1,6 +1,7 @@ --- "@fuel-ts/account": patch "fuels": patch +"@fuel-ts/versions": patch --- chore!: remove built-in binaries for `forc` and `fuel-core` \ No newline at end of file From cc7a7a63d8d163e73c0d6308649413210e14fba8 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 1 May 2024 17:09:37 +0100 Subject: [PATCH 44/89] Added forcPath and fuelCorePath for required tests --- .../fuels/src/cli/config/loadConfig.test.ts | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/fuels/src/cli/config/loadConfig.test.ts b/packages/fuels/src/cli/config/loadConfig.test.ts index 28df6b2b34b..b5d46849354 100644 --- a/packages/fuels/src/cli/config/loadConfig.test.ts +++ b/packages/fuels/src/cli/config/loadConfig.test.ts @@ -38,6 +38,8 @@ describe('loadConfig', () => { root: paths.root, workspace: paths.workspaceDir, output: paths.outputDir, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, autoStartFuelCore: true, }); @@ -52,6 +54,8 @@ describe('loadConfig', () => { await runInit({ root: paths.root, output: paths.outputDir, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, contracts: 'workspace/contracts/*', scripts: 'workspace/scripts/*', predicates: 'workspace/predicates/*', @@ -68,6 +72,8 @@ describe('loadConfig', () => { await runInit({ root: paths.root, output: paths.outputDir, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, contracts: 'workspace/contracts/*', }); @@ -82,6 +88,8 @@ describe('loadConfig', () => { await runInit({ root: paths.root, output: paths.outputDir, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, scripts: 'workspace/scripts/*', }); @@ -96,6 +104,8 @@ describe('loadConfig', () => { await runInit({ root: paths.root, output: paths.outputDir, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, predicates: 'workspace/predicates/*', }); @@ -110,6 +120,8 @@ describe('loadConfig', () => { await runInit({ root: paths.root, output: paths.outputDir, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, // passing contract path in workspace config option workspace: 'workspace/contracts/bar', }); @@ -121,19 +133,6 @@ describe('loadConfig', () => { expect(error?.message).toMatch(/try using 'contracts'/i); }); - test('should use system binary paths by default', async () => { - await runInit({ - root: paths.root, - workspace: paths.workspaceDir, - output: paths.outputDir, - }); - - const config = await loadConfig(paths.root); - - expect(config.forcPath).toEqual('forc'); - expect(config.fuelCorePath).toEqual('fuel-core'); - }); - test(`should load custom binary paths`, async () => { await runInit({ root: paths.root, From 458b2fa64838bb13ad056fd6d2e5674b01b15c99 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 1 May 2024 17:29:07 +0100 Subject: [PATCH 45/89] Added forcPath and fuelCorePath for deploy and dev tests --- packages/fuels/test/features/deploy.test.ts | 1 + packages/fuels/test/features/dev.test.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/packages/fuels/test/features/deploy.test.ts b/packages/fuels/test/features/deploy.test.ts index 88a9977c366..f3f75f89f9a 100644 --- a/packages/fuels/test/features/deploy.test.ts +++ b/packages/fuels/test/features/deploy.test.ts @@ -31,6 +31,7 @@ describe( workspace: paths.workspaceDir, output: paths.outputDir, forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, }); await runBuild({ root: paths.root }); diff --git a/packages/fuels/test/features/dev.test.ts b/packages/fuels/test/features/dev.test.ts index bb4daaa47a9..832e7917432 100644 --- a/packages/fuels/test/features/dev.test.ts +++ b/packages/fuels/test/features/dev.test.ts @@ -52,6 +52,8 @@ describe('dev', () => { root: paths.root, workspace: paths.workspaceDir, output: paths.outputDir, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, }); await runDev({ root: paths.root }); From 5452b06adf7f25621e82526729e9218ff0d27d20 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 2 May 2024 10:50:58 +0100 Subject: [PATCH 46/89] Extracted find binary logics to cli-utils --- packages/fuels/src/cli/config/loadConfig.ts | 18 ++--- packages/utils/src/cli-utils.ts | 1 + .../src/cli-utils/tryFindBinaries.test.ts | 77 +++++++++++++++++++ .../utils/src/cli-utils/tryFindBinaries.ts | 33 ++++++++ 4 files changed, 116 insertions(+), 13 deletions(-) create mode 100644 packages/utils/src/cli-utils/tryFindBinaries.test.ts create mode 100644 packages/utils/src/cli-utils/tryFindBinaries.ts diff --git a/packages/fuels/src/cli/config/loadConfig.ts b/packages/fuels/src/cli/config/loadConfig.ts index 63bae8812d7..aea3c99e67e 100644 --- a/packages/fuels/src/cli/config/loadConfig.ts +++ b/packages/fuels/src/cli/config/loadConfig.ts @@ -1,7 +1,6 @@ import { FUEL_NETWORK_URL } from '@fuel-ts/account/configs'; -import { FuelError } from '@fuel-ts/errors'; import { defaultConsensusKey } from '@fuel-ts/utils'; -import { getSystemForc, getSystemFuelCore } from '@fuel-ts/versions/cli'; +import { tryFindBinaries } from '@fuel-ts/utils/cli-utils'; import { bundleRequire } from 'bundle-require'; import type { BuildOptions } from 'esbuild'; import JoyCon from 'joycon'; @@ -45,17 +44,10 @@ export async function loadConfig(cwd: string): Promise { const releaseFlag = forcBuildFlags.find((f) => f === '--release'); const buildMode = releaseFlag ? 'release' : 'debug'; - const { error: forcError, forcPath } = getSystemForc(userConfig.forcPath); - const { error: fuelCoreError, fuelCorePath } = getSystemFuelCore(userConfig.fuelCorePath); - - if (forcError || fuelCoreError) { - const errors = [ - forcError ? `Binary for 'forc' not found at path '${forcPath}'` : undefined, - fuelCoreError ? `Binary for 'fuel-core' not found at path '${fuelCorePath}'` : undefined, - ]; - - throw new FuelError(FuelError.CODES.BIN_FILE_NOT_FOUND, errors.filter(Boolean).join('\n')); - } + const { forcPath, fuelCorePath } = tryFindBinaries({ + forcPath: userConfig.forcPath, + fuelCorePath: userConfig.fuelCorePath, + }); // Start clone-object while initializing optional props const config: FuelsConfig = { diff --git a/packages/utils/src/cli-utils.ts b/packages/utils/src/cli-utils.ts index eaac016729a..a65d7367d6c 100644 --- a/packages/utils/src/cli-utils.ts +++ b/packages/utils/src/cli-utils.ts @@ -1 +1,2 @@ export * from './cli-utils/findBinPath'; +export * from './cli-utils/tryFindBinaries'; diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts new file mode 100644 index 00000000000..91b76d4265b --- /dev/null +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -0,0 +1,77 @@ +import * as versionsCliMod from '@fuel-ts/versions/cli'; + +import { tryFindBinaries } from './tryFindBinaries'; + +const mockAllDeps = ( + params: { + forcError?: Error; + fuelCoreError?: Error; + } = {} +) => { + const { forcError, fuelCoreError } = params; + + const version = '1.0.0'; + + const getSystemForc = vi + .spyOn(versionsCliMod, 'getSystemForc') + .mockImplementation(() => ({ error: forcError ?? null, systemForcVersion: version })); + + const getSystemFuelCore = vi + .spyOn(versionsCliMod, 'getSystemFuelCore') + .mockImplementation(() => ({ error: fuelCoreError ?? null, systemFuelCoreVersion: version })); + + return { + getSystemForc, + getSystemFuelCore, + }; +}; + +describe('tryFindBinaries', () => { + it(`should use default binaries when not paths supplied`, () => { + const { getSystemForc, getSystemFuelCore } = mockAllDeps(); + + const binaries = tryFindBinaries(); + + expect(getSystemForc).toHaveBeenCalledTimes(1); + expect(getSystemForc).toBeCalledWith('forc'); + expect(getSystemFuelCore).toHaveBeenCalledTimes(1); + expect(getSystemFuelCore).toBeCalledWith('fuel-core'); + expect(binaries.forcPath).toEqual('forc'); + expect(binaries.fuelCorePath).toEqual('fuel-core'); + }); + + it(`should use custom binaries when paths supplied`, () => { + const { getSystemForc, getSystemFuelCore } = mockAllDeps(); + + const forcPath = '/some/path/to/forc'; + const fuelCorePath = '/some/path/to/fuel-core'; + + const binaries = tryFindBinaries({ forcPath, fuelCorePath }); + + expect(getSystemForc).toHaveBeenCalledTimes(1); + expect(getSystemForc).toBeCalledWith(forcPath); + expect(getSystemFuelCore).toHaveBeenCalledTimes(1); + expect(getSystemFuelCore).toBeCalledWith(fuelCorePath); + expect(binaries.forcPath).toEqual(forcPath); + expect(binaries.fuelCorePath).toEqual(fuelCorePath); + }); + + it(`should throw when binaries are not found`, () => { + const forcPath = '/non/existent/path/to/forc'; + const fuelCorePath = '/non/existent/path/to/fuel-core'; + const { getSystemForc, getSystemFuelCore } = mockAllDeps({ + forcError: new Error('forc not found'), + fuelCoreError: new Error('fuel-core not found'), + }); + + const expectedErrors = [ + `Binary for 'forc' not found at path '${forcPath}'`, + `Binary for 'fuel-core' not found at path '${fuelCorePath}'`, + ]; + expect(() => tryFindBinaries({ forcPath, fuelCorePath })).toThrowError( + expectedErrors.join('\n') + ); + expect(getSystemForc).toHaveBeenCalledTimes(1); + expect(getSystemFuelCore).toHaveBeenCalledTimes(1); + }); +}); diff --git a/packages/utils/src/cli-utils/tryFindBinaries.ts b/packages/utils/src/cli-utils/tryFindBinaries.ts new file mode 100644 index 00000000000..49854e4c98b --- /dev/null +++ b/packages/utils/src/cli-utils/tryFindBinaries.ts @@ -0,0 +1,33 @@ +import { FuelError } from '@fuel-ts/errors'; +import { getSystemForc, getSystemFuelCore } from '@fuel-ts/versions/cli'; + +const defaultBinaryPaths = { + forcPath: 'forc', + fuelCorePath: 'fuel-core', +} as const; + +/** + * Tries to find the binaries in the system, otherwise throws an error. + * + * @param paths - paths to the binaries (optional) + * @returns - paths and versions of the binaries + */ +export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: string } = {}) => { + const { forcPath, fuelCorePath } = { ...defaultBinaryPaths, ...paths }; + + // Ensure we can get the binary versions + const { error: forcError, systemForcVersion } = getSystemForc(forcPath); + const { error: fuelCoreError, systemFuelCoreVersion } = getSystemFuelCore(fuelCorePath); + if (forcError || fuelCoreError) { + const errors = [ + forcError ? `Binary for 'forc' not found at path '${forcPath}'` : undefined, + fuelCoreError ? `Binary for 'fuel-core' not found at path '${fuelCorePath}'` : undefined, + ]; + throw new FuelError(FuelError.CODES.BIN_FILE_NOT_FOUND, errors.filter(Boolean).join('\n')); + } + + return { + forcPath, + fuelCorePath, + }; +}; From d7ad26e01497a629c9dd59de34fb6b70a747d714 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 2 May 2024 10:58:44 +0100 Subject: [PATCH 47/89] Removed unneeded additions to getSystemVersions --- .../src/lib/getSystemVersions.test.ts | 150 +++++++++--------- .../versions/src/lib/getSystemVersions.ts | 12 +- 2 files changed, 83 insertions(+), 79 deletions(-) diff --git a/packages/versions/src/lib/getSystemVersions.test.ts b/packages/versions/src/lib/getSystemVersions.test.ts index 22442ff0058..2962b38fc82 100644 --- a/packages/versions/src/lib/getSystemVersions.test.ts +++ b/packages/versions/src/lib/getSystemVersions.test.ts @@ -40,87 +40,91 @@ function mockAllDeps(params: { }; } -const defaultBinaryPaths = { forcPath: 'forc', fuelCorePath: 'fuel-core' }; -const scenarioBinaryPaths = [ - { message: 'Using default "forc" and "fuel-core"' }, - { message: 'Using custom "forc" path', forcPath: 'fuels-forc' }, - { message: 'Using custom "fuel-core" path', fuelCorePath: 'fuels-core' }, - { - message: 'Using custom "forc" and "fuel-core" path', - forcPath: 'fuels-forc', - fuelCorePath: 'fuels-core', - }, -]; - /** * @group node */ describe('getSystemVersions', () => { - describe.each(scenarioBinaryPaths)('$message', ({ message: _, ...params }) => { - const { forcPath: expectedForcCommand, fuelCorePath: expectedFuelCoreCommand } = { - ...defaultBinaryPaths, - ...params, - }; - - test('should get user versions just fine', () => { - // mocking - const systemForcVersion = '1.0.0'; - const systemFuelCoreVersion = '2.0.0'; - const { execSync } = mockAllDeps({ - systemForcVersion, - systemFuelCoreVersion, - }); - - // executing - const versions = getSystemVersions(params); - - // validating - expect(execSync).toHaveBeenCalledTimes(2); - expect(execSync).toBeCalledWith(`${expectedForcCommand} --version`); - expect(execSync).toBeCalledWith(`${expectedFuelCoreCommand} --version`); - expect(versions.systemForcVersion).toEqual(systemForcVersion); - expect(versions.systemFuelCoreVersion).toEqual(systemFuelCoreVersion); + test('should get user versions just fine', () => { + // mocking + const systemForcVersion = '1.0.0'; + const systemFuelCoreVersion = '2.0.0'; + const { execSync } = mockAllDeps({ + systemForcVersion, + systemFuelCoreVersion, }); - test('should return error if Forc or Fuel-Core is not installed', () => { - // mocking - const systemForcVersion = '1.0.0'; - const systemFuelCoreVersion = '2.0.0'; - const { execSync } = mockAllDeps({ - systemForcVersion, - systemFuelCoreVersion, - shouldThrow: true, - }); - - // executing - const { error: systemError } = getSystemVersions(params); - - // validating - expect(execSync).toHaveBeenCalledTimes(2); - expect(execSync).toBeCalledWith(`${expectedForcCommand} --version`); - expect(execSync).toBeCalledWith(`${expectedFuelCoreCommand} --version`); - expect(systemError).toBeTruthy(); + // executing + const versions = getSystemVersions(); + + // validating + expect(execSync).toHaveBeenCalledTimes(2); + expect(execSync).toBeCalledWith(`forc --version`); + expect(execSync).toBeCalledWith(`fuel-core --version`); + expect(versions.systemForcVersion).toEqual(systemForcVersion); + expect(versions.systemFuelCoreVersion).toEqual(systemFuelCoreVersion); + }); + + test('should return error if Forc or Fuel-Core is not installed', () => { + // mocking + const systemForcVersion = '1.0.0'; + const systemFuelCoreVersion = '2.0.0'; + const { execSync } = mockAllDeps({ + systemForcVersion, + systemFuelCoreVersion, + shouldThrow: true, }); - test('should throw for fuelup exception', () => { - // mocking - const systemForcVersion = 'fuelup exception'; - const systemFuelCoreVersion = 'fuelup exception'; - const { execSync } = mockAllDeps({ - systemForcVersion, - systemFuelCoreVersion, - }); - - // executing - const versions = getSystemVersions(params); - - // validating - expect(execSync).toHaveBeenCalledTimes(2); - expect(execSync).toBeCalledWith(`${expectedForcCommand} --version`); - expect(execSync).toBeCalledWith(`${expectedFuelCoreCommand} --version`); - expect(versions.error?.toString()).toEqual(`Error: ${systemForcVersion}`); - expect(versions.systemForcVersion).toEqual(null); - expect(versions.systemFuelCoreVersion).toEqual(null); + // executing + const { error: systemError } = getSystemVersions(); + + // validating + expect(execSync).toHaveBeenCalledTimes(2); + expect(execSync).toBeCalledWith(`forc --version`); + expect(execSync).toBeCalledWith(`fuel-core --version`); + expect(systemError).toBeTruthy(); + }); + + test('should throw for fuelup exception', () => { + // mocking + const systemForcVersion = 'fuelup exception'; + const systemFuelCoreVersion = 'fuelup exception'; + const { execSync } = mockAllDeps({ + systemForcVersion, + systemFuelCoreVersion, }); + + // executing + const versions = getSystemVersions(); + + // validating + expect(execSync).toHaveBeenCalledTimes(2); + expect(execSync).toBeCalledWith(`forc --version`); + expect(execSync).toBeCalledWith(`fuel-core --version`); + expect(versions.error?.toString()).toEqual(`Error: ${systemForcVersion}`); + expect(versions.systemForcVersion).toEqual(null); + expect(versions.systemFuelCoreVersion).toEqual(null); + }); + + it('should be able to use custom binary paths', () => { + // mocking + const systemForcVersion = '1.0.0'; + const systemFuelCoreVersion = '2.0.0'; + const { execSync } = mockAllDeps({ + systemForcVersion, + systemFuelCoreVersion, + }); + + // executing + const versions = getSystemVersions({ + forcPath: '/path/to/custom/forc', + fuelCorePath: '/path/to/custom/fuel-core', + }); + + // validating + expect(execSync).toHaveBeenCalledTimes(2); + expect(execSync).toBeCalledWith(`/path/to/custom/forc --version`); + expect(execSync).toBeCalledWith(`/path/to/custom/fuel-core --version`); + expect(versions.systemForcVersion).toEqual(systemForcVersion); + expect(versions.systemFuelCoreVersion).toEqual(systemFuelCoreVersion); }); }); diff --git a/packages/versions/src/lib/getSystemVersions.ts b/packages/versions/src/lib/getSystemVersions.ts index b5fffd02411..227a4480672 100644 --- a/packages/versions/src/lib/getSystemVersions.ts +++ b/packages/versions/src/lib/getSystemVersions.ts @@ -1,8 +1,8 @@ import { execSync } from 'child_process'; const versionReg = /[0-9]+\.[0-9]+\.[0-9]/; -const defaultForcPath = 'forc'; -const defaultFuelCorePath = 'fuel-core'; +const defaultForcCommand = 'forc'; +const defaultFuelCoreCommand = 'fuel-core'; export const getSystemVersion = (command: string) => { let version: string | null = null; @@ -25,14 +25,14 @@ export const getSystemVersion = (command: string) => { }; }; -export function getSystemForc(forcPath: string = defaultForcPath) { +export function getSystemForc(forcPath: string = defaultForcCommand) { const { error, version: v } = getSystemVersion(`${forcPath} --version`); - return { error, systemForcVersion: v, forcPath }; + return { error, systemForcVersion: v }; } -export function getSystemFuelCore(fuelCorePath: string = defaultFuelCorePath) { +export function getSystemFuelCore(fuelCorePath: string = defaultFuelCoreCommand) { const { error, version: v } = getSystemVersion(`${fuelCorePath} --version`); - return { error, systemFuelCoreVersion: v, fuelCorePath }; + return { error, systemFuelCoreVersion: v }; } export function getSystemVersions(params: { forcPath?: string; fuelCorePath?: string } = {}) { From bf16835d859eebb46e9272ee581402e6f6745643 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 2 May 2024 10:59:05 +0100 Subject: [PATCH 48/89] Linting --- packages/utils/src/cli-utils/tryFindBinaries.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/utils/src/cli-utils/tryFindBinaries.ts b/packages/utils/src/cli-utils/tryFindBinaries.ts index 49854e4c98b..6437a86a3cf 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.ts @@ -8,16 +8,16 @@ const defaultBinaryPaths = { /** * Tries to find the binaries in the system, otherwise throws an error. - * + * * @param paths - paths to the binaries (optional) - * @returns - paths and versions of the binaries + * @returns - paths to the resolved binaries */ export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: string } = {}) => { const { forcPath, fuelCorePath } = { ...defaultBinaryPaths, ...paths }; // Ensure we can get the binary versions - const { error: forcError, systemForcVersion } = getSystemForc(forcPath); - const { error: fuelCoreError, systemFuelCoreVersion } = getSystemFuelCore(fuelCorePath); + const { error: forcError } = getSystemForc(forcPath); + const { error: fuelCoreError } = getSystemFuelCore(fuelCorePath); if (forcError || fuelCoreError) { const errors = [ forcError ? `Binary for 'forc' not found at path '${forcPath}'` : undefined, From 0237b69e5ff3b70087251ac6bc7ebb5da258a92e Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 2 May 2024 14:42:53 +0100 Subject: [PATCH 49/89] Removed unneeded dependency --- package.json | 1 - pnpm-lock.yaml | 3 --- 2 files changed, 4 deletions(-) diff --git a/package.json b/package.json index f288a1d6040..79848015ca2 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,6 @@ "@internal/forc": "workspace:*", "@internal/fuel-core": "workspace:*", "@fuel-ts/utils": "workspace:*", - "@fuel-ts/versions": "workspace:^", "@internal/tsup": "workspace:*", "@istanbuljs/nyc-config-typescript": "^1.0.2", "@types/node": "18.15.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e7f41a29973..02a324631df 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,9 +32,6 @@ importers: '@fuel-ts/utils': specifier: workspace:* version: link:packages/utils - '@fuel-ts/versions': - specifier: workspace:^ - version: link:packages/versions '@internal/forc': specifier: workspace:* version: link:internal/forc From 6dcca89fff6864aa24867dd48ee4a3ad31a66171 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 2 May 2024 14:48:15 +0100 Subject: [PATCH 50/89] Added versions to the utils package --- packages/utils/package.json | 3 ++- pnpm-lock.yaml | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/utils/package.json b/packages/utils/package.json index f11a1487a9b..2ed2bf6bbc6 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -48,6 +48,7 @@ "license": "Apache-2.0", "dependencies": { "@fuel-ts/errors": "workspace:*", - "@fuel-ts/interfaces": "workspace:*" + "@fuel-ts/interfaces": "workspace:*", + "@fuel-ts/versions": "workspace:*" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 02a324631df..5396c76993f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1091,6 +1091,9 @@ importers: '@fuel-ts/interfaces': specifier: workspace:* version: link:../interfaces + '@fuel-ts/versions': + specifier: workspace:* + version: link:../versions packages/versions: dependencies: From 06126357da2cecc0e96c286d3dfe784cdab16b97 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 2 May 2024 15:32:38 +0100 Subject: [PATCH 51/89] Added node group to test file --- packages/utils/src/cli-utils/tryFindBinaries.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts index 91b76d4265b..68ff7f0e1d6 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.test.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -26,6 +26,9 @@ const mockAllDeps = ( }; }; +/** + * @group node + */ describe('tryFindBinaries', () => { it(`should use default binaries when not paths supplied`, () => { const { getSystemForc, getSystemFuelCore } = mockAllDeps(); From 8910b1160c6d2b7b3d05a3b285dcaee25c240340 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 6 May 2024 12:15:01 +0100 Subject: [PATCH 52/89] pls release --- .github/workflows/pr-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yaml b/.github/workflows/pr-release.yaml index 9b48fc2352a..34ad25146b1 100644 --- a/.github/workflows/pr-release.yaml +++ b/.github/workflows/pr-release.yaml @@ -8,7 +8,7 @@ jobs: name: "Release PR to npm" runs-on: ubuntu-latest # comment out if:false to enable release PR to npm - if: false + # if: false permissions: write-all steps: - name: Checkout From c0fb94dfaee4c6b6ef0f7cd5b15ebafb0c9452db Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 6 May 2024 19:18:07 +0100 Subject: [PATCH 53/89] Fixing issue with path not being found correctly --- .../utils/src/cli-utils/tryFindBinaries.test.ts | 13 +++++++++++++ packages/utils/src/cli-utils/tryFindBinaries.ts | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts index 68ff7f0e1d6..262dad25a61 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.test.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -59,6 +59,19 @@ describe('tryFindBinaries', () => { expect(binaries.fuelCorePath).toEqual(fuelCorePath); }); + it('should handle undefined paths', () => { + const { getSystemForc, getSystemFuelCore } = mockAllDeps(); + + const binaries = tryFindBinaries({ forcPath: undefined, fuelCorePath: undefined }); + + expect(getSystemForc).toHaveBeenCalledTimes(1); + expect(getSystemForc).toBeCalledWith('forc'); + expect(getSystemFuelCore).toHaveBeenCalledTimes(1); + expect(getSystemFuelCore).toBeCalledWith('fuel-core'); + expect(binaries.forcPath).toEqual('forc'); + expect(binaries.fuelCorePath).toEqual('fuel-core'); + }) + it(`should throw when binaries are not found`, () => { const forcPath = '/non/existent/path/to/forc'; const fuelCorePath = '/non/existent/path/to/fuel-core'; diff --git a/packages/utils/src/cli-utils/tryFindBinaries.ts b/packages/utils/src/cli-utils/tryFindBinaries.ts index 6437a86a3cf..2f1e0cb6b0b 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.ts @@ -13,7 +13,10 @@ const defaultBinaryPaths = { * @returns - paths to the resolved binaries */ export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: string } = {}) => { - const { forcPath, fuelCorePath } = { ...defaultBinaryPaths, ...paths }; + const { forcPath, fuelCorePath } = { + forcPath: paths.forcPath ?? defaultBinaryPaths.forcPath, + fuelCorePath: paths.fuelCorePath ?? defaultBinaryPaths.fuelCorePath, + }; // Ensure we can get the binary versions const { error: forcError } = getSystemForc(forcPath); From a75c7ca605c14ddc3f42f7b0e5ba24bf352d7dc9 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 6 May 2024 19:40:42 +0100 Subject: [PATCH 54/89] Lint --- packages/utils/src/cli-utils/tryFindBinaries.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts index 262dad25a61..2272d3dc638 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.test.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -70,7 +70,7 @@ describe('tryFindBinaries', () => { expect(getSystemFuelCore).toBeCalledWith('fuel-core'); expect(binaries.forcPath).toEqual('forc'); expect(binaries.fuelCorePath).toEqual('fuel-core'); - }) + }); it(`should throw when binaries are not found`, () => { const forcPath = '/non/existent/path/to/forc'; From bd2643c5fc7fec1baa8e1bcca813d6389d41e76b Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 7 May 2024 08:15:32 +0100 Subject: [PATCH 55/89] Suppress stdio for getSystemVersion --- .../versions/src/lib/getSystemVersions.test.ts | 18 ++++++++++-------- packages/versions/src/lib/getSystemVersions.ts | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/versions/src/lib/getSystemVersions.test.ts b/packages/versions/src/lib/getSystemVersions.test.ts index 2962b38fc82..2aec9e19d93 100644 --- a/packages/versions/src/lib/getSystemVersions.test.ts +++ b/packages/versions/src/lib/getSystemVersions.test.ts @@ -44,6 +44,8 @@ function mockAllDeps(params: { * @group node */ describe('getSystemVersions', () => { + const expectedExecSyncOptions = expect.objectContaining({ stdio: 'pipe' }) + test('should get user versions just fine', () => { // mocking const systemForcVersion = '1.0.0'; @@ -58,8 +60,8 @@ describe('getSystemVersions', () => { // validating expect(execSync).toHaveBeenCalledTimes(2); - expect(execSync).toBeCalledWith(`forc --version`); - expect(execSync).toBeCalledWith(`fuel-core --version`); + expect(execSync).toBeCalledWith(`forc --version`, expectedExecSyncOptions); + expect(execSync).toBeCalledWith(`fuel-core --version`, expectedExecSyncOptions); expect(versions.systemForcVersion).toEqual(systemForcVersion); expect(versions.systemFuelCoreVersion).toEqual(systemFuelCoreVersion); }); @@ -79,8 +81,8 @@ describe('getSystemVersions', () => { // validating expect(execSync).toHaveBeenCalledTimes(2); - expect(execSync).toBeCalledWith(`forc --version`); - expect(execSync).toBeCalledWith(`fuel-core --version`); + expect(execSync).toBeCalledWith(`forc --version`, expectedExecSyncOptions); + expect(execSync).toBeCalledWith(`fuel-core --version`, expectedExecSyncOptions); expect(systemError).toBeTruthy(); }); @@ -98,8 +100,8 @@ describe('getSystemVersions', () => { // validating expect(execSync).toHaveBeenCalledTimes(2); - expect(execSync).toBeCalledWith(`forc --version`); - expect(execSync).toBeCalledWith(`fuel-core --version`); + expect(execSync).toBeCalledWith(`forc --version`, expectedExecSyncOptions); + expect(execSync).toBeCalledWith(`fuel-core --version`, expectedExecSyncOptions); expect(versions.error?.toString()).toEqual(`Error: ${systemForcVersion}`); expect(versions.systemForcVersion).toEqual(null); expect(versions.systemFuelCoreVersion).toEqual(null); @@ -122,8 +124,8 @@ describe('getSystemVersions', () => { // validating expect(execSync).toHaveBeenCalledTimes(2); - expect(execSync).toBeCalledWith(`/path/to/custom/forc --version`); - expect(execSync).toBeCalledWith(`/path/to/custom/fuel-core --version`); + expect(execSync).toBeCalledWith(`/path/to/custom/forc --version`, expectedExecSyncOptions); + expect(execSync).toBeCalledWith(`/path/to/custom/fuel-core --version`, expectedExecSyncOptions); expect(versions.systemForcVersion).toEqual(systemForcVersion); expect(versions.systemFuelCoreVersion).toEqual(systemFuelCoreVersion); }); diff --git a/packages/versions/src/lib/getSystemVersions.ts b/packages/versions/src/lib/getSystemVersions.ts index 227a4480672..42060d6b4a2 100644 --- a/packages/versions/src/lib/getSystemVersions.ts +++ b/packages/versions/src/lib/getSystemVersions.ts @@ -9,7 +9,7 @@ export const getSystemVersion = (command: string) => { let error: Error | null = null; try { - const contents = execSync(command).toString(); + const contents = execSync(command, { stdio: 'pipe' }).toString(); if (versionReg.test(contents)) { version = contents.match(versionReg)?.[0] as string; } else { From b46115dc536f67b176652ea60617ff6e4a49f66b Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 7 May 2024 08:57:53 +0100 Subject: [PATCH 56/89] Making error message more explicit --- packages/fuels/src/cli/config/loadConfig.test.ts | 9 ++++----- .../utils/src/cli-utils/tryFindBinaries.test.ts | 16 ++++++++-------- packages/utils/src/cli-utils/tryFindBinaries.ts | 12 +++++++++--- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/packages/fuels/src/cli/config/loadConfig.test.ts b/packages/fuels/src/cli/config/loadConfig.test.ts index b5d46849354..6fe8932d638 100644 --- a/packages/fuels/src/cli/config/loadConfig.test.ts +++ b/packages/fuels/src/cli/config/loadConfig.test.ts @@ -159,11 +159,10 @@ describe('loadConfig', () => { const { error, result } = await safeExec(() => loadConfig(paths.root)); - const expectedMessage = [ - `Binary for 'forc' not found at path '/non/existent/forc'`, - `Binary for 'fuel-core' not found at path '/non/existent/fuel-core'`, - ].join('\n'); expect(result).toBeFalsy(); - expect(error?.message).toEqual(expectedMessage); + expect(error?.message).toMatch(/Unable to find the following binaries on the filesystem/g); + expect(error?.message).toMatch(/\/non\/existent\/forc/g); + expect(error?.message).toMatch(/\/non\/existent\/fuel-core/g); + expect(error?.message).toMatch(/Visit https:\/\/docs.fuel.network\/guides\/installation\//g); }); }); diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts index 2272d3dc638..c089604e0ae 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.test.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -1,6 +1,7 @@ import * as versionsCliMod from '@fuel-ts/versions/cli'; import { tryFindBinaries } from './tryFindBinaries'; +import { safeExec } from '@fuel-ts/errors/test-utils'; const mockAllDeps = ( params: { @@ -72,7 +73,7 @@ describe('tryFindBinaries', () => { expect(binaries.fuelCorePath).toEqual('fuel-core'); }); - it(`should throw when binaries are not found`, () => { + it(`should throw when binaries are not found`, async() => { const forcPath = '/non/existent/path/to/forc'; const fuelCorePath = '/non/existent/path/to/fuel-core'; const { getSystemForc, getSystemFuelCore } = mockAllDeps({ @@ -80,14 +81,13 @@ describe('tryFindBinaries', () => { fuelCoreError: new Error('fuel-core not found'), }); - const expectedErrors = [ - `Binary for 'forc' not found at path '${forcPath}'`, - `Binary for 'fuel-core' not found at path '${fuelCorePath}'`, - ]; - expect(() => tryFindBinaries({ forcPath, fuelCorePath })).toThrowError( - expectedErrors.join('\n') - ); + const { error, result } = await safeExec(() => tryFindBinaries({ forcPath, fuelCorePath })); + expect(getSystemForc).toHaveBeenCalledTimes(1); expect(getSystemFuelCore).toHaveBeenCalledTimes(1); + expect(error?.message).toMatch(/Unable to find the following binaries on the filesystem/g); + expect(error?.message).toMatch(/\/non\/existent\/forc/g); + expect(error?.message).toMatch(/\/non\/existent\/fuel-core/g); + expect(error?.message).toMatch(/Visit https:\/\/docs.fuel.network\/guides\/installation\//g); }); }); diff --git a/packages/utils/src/cli-utils/tryFindBinaries.ts b/packages/utils/src/cli-utils/tryFindBinaries.ts index 2f1e0cb6b0b..c25d219456a 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.ts @@ -23,10 +23,16 @@ export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: strin const { error: fuelCoreError } = getSystemFuelCore(fuelCorePath); if (forcError || fuelCoreError) { const errors = [ - forcError ? `Binary for 'forc' not found at path '${forcPath}'` : undefined, - fuelCoreError ? `Binary for 'fuel-core' not found at path '${fuelCorePath}'` : undefined, + 'Unable to find the following binaries on the filesystem:', + forcError ? ` -> 'forc' at path '${forcPath}'` : undefined, + fuelCoreError ? ` -> 'fuel-core' at path '${fuelCorePath}'` : undefined, + `\nVisit https://docs.fuel.network/guides/installation/ for an installation guide.` ]; - throw new FuelError(FuelError.CODES.BIN_FILE_NOT_FOUND, errors.filter(Boolean).join('\n')); + throw new FuelError( + FuelError.CODES.BIN_FILE_NOT_FOUND, + `${errors.filter(Boolean).join('\n')}`, + { forcPath, fuelCorePath } + ) } return { From 7b854d249545d8416dd398de35400ca36cc8c4ac Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 7 May 2024 08:58:47 +0100 Subject: [PATCH 57/89] Only display the error message when config throws --- packages/fuels/src/cli/commands/withConfig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fuels/src/cli/commands/withConfig.ts b/packages/fuels/src/cli/commands/withConfig.ts index bc1870e1c4e..7dbd9883d74 100644 --- a/packages/fuels/src/cli/commands/withConfig.ts +++ b/packages/fuels/src/cli/commands/withConfig.ts @@ -6,7 +6,7 @@ import type { Commands, FuelsConfig, CommandEvent } from '../types'; import { error, log } from '../utils/logger'; export const withConfigErrorHandler = async (err: Error, config?: FuelsConfig) => { - error(err); + error(err.message); if (config) { await config.onFailure?.(err, config); } From ec0efd512c58f922fe5dcddc23331dd53d5ff79f Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 7 May 2024 09:00:15 +0100 Subject: [PATCH 58/89] Lint --- packages/utils/src/cli-utils/tryFindBinaries.test.ts | 6 +++--- packages/utils/src/cli-utils/tryFindBinaries.ts | 4 ++-- packages/versions/src/lib/getSystemVersions.test.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts index c089604e0ae..6133691eccf 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.test.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -1,7 +1,7 @@ +import { safeExec } from '@fuel-ts/errors/test-utils'; import * as versionsCliMod from '@fuel-ts/versions/cli'; import { tryFindBinaries } from './tryFindBinaries'; -import { safeExec } from '@fuel-ts/errors/test-utils'; const mockAllDeps = ( params: { @@ -73,7 +73,7 @@ describe('tryFindBinaries', () => { expect(binaries.fuelCorePath).toEqual('fuel-core'); }); - it(`should throw when binaries are not found`, async() => { + it(`should throw when binaries are not found`, async () => { const forcPath = '/non/existent/path/to/forc'; const fuelCorePath = '/non/existent/path/to/fuel-core'; const { getSystemForc, getSystemFuelCore } = mockAllDeps({ @@ -81,7 +81,7 @@ describe('tryFindBinaries', () => { fuelCoreError: new Error('fuel-core not found'), }); - const { error, result } = await safeExec(() => tryFindBinaries({ forcPath, fuelCorePath })); + const { error } = await safeExec(() => tryFindBinaries({ forcPath, fuelCorePath })); expect(getSystemForc).toHaveBeenCalledTimes(1); expect(getSystemFuelCore).toHaveBeenCalledTimes(1); diff --git a/packages/utils/src/cli-utils/tryFindBinaries.ts b/packages/utils/src/cli-utils/tryFindBinaries.ts index c25d219456a..f48f014e56c 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.ts @@ -26,13 +26,13 @@ export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: strin 'Unable to find the following binaries on the filesystem:', forcError ? ` -> 'forc' at path '${forcPath}'` : undefined, fuelCoreError ? ` -> 'fuel-core' at path '${fuelCorePath}'` : undefined, - `\nVisit https://docs.fuel.network/guides/installation/ for an installation guide.` + `\nVisit https://docs.fuel.network/guides/installation/ for an installation guide.`, ]; throw new FuelError( FuelError.CODES.BIN_FILE_NOT_FOUND, `${errors.filter(Boolean).join('\n')}`, { forcPath, fuelCorePath } - ) + ); } return { diff --git a/packages/versions/src/lib/getSystemVersions.test.ts b/packages/versions/src/lib/getSystemVersions.test.ts index 2aec9e19d93..a7e522206d9 100644 --- a/packages/versions/src/lib/getSystemVersions.test.ts +++ b/packages/versions/src/lib/getSystemVersions.test.ts @@ -44,7 +44,7 @@ function mockAllDeps(params: { * @group node */ describe('getSystemVersions', () => { - const expectedExecSyncOptions = expect.objectContaining({ stdio: 'pipe' }) + const expectedExecSyncOptions = expect.objectContaining({ stdio: 'pipe' }); test('should get user versions just fine', () => { // mocking From 5dc2014e4e24913ab7dd639ddb804433bfb8dd67 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 7 May 2024 11:56:58 +0100 Subject: [PATCH 59/89] Fixing tests --- packages/fuels/src/cli/config/loadConfig.test.ts | 16 ++++++++++------ .../utils/src/cli-utils/tryFindBinaries.test.ts | 10 ++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/fuels/src/cli/config/loadConfig.test.ts b/packages/fuels/src/cli/config/loadConfig.test.ts index 6fe8932d638..7ea51dbbb8a 100644 --- a/packages/fuels/src/cli/config/loadConfig.test.ts +++ b/packages/fuels/src/cli/config/loadConfig.test.ts @@ -149,20 +149,24 @@ describe('loadConfig', () => { }); test('should throw if system binary paths are not found', async () => { + const forcPath = '/non/existent/forc'; + const fuelCorePath = '/non/existent/fuel-core'; await runInit({ root: paths.root, workspace: paths.workspaceDir, output: paths.outputDir, - forcPath: '/non/existent/forc', - fuelCorePath: '/non/existent/fuel-core', + forcPath, + fuelCorePath, }); const { error, result } = await safeExec(() => loadConfig(paths.root)); expect(result).toBeFalsy(); - expect(error?.message).toMatch(/Unable to find the following binaries on the filesystem/g); - expect(error?.message).toMatch(/\/non\/existent\/forc/g); - expect(error?.message).toMatch(/\/non\/existent\/fuel-core/g); - expect(error?.message).toMatch(/Visit https:\/\/docs.fuel.network\/guides\/installation\//g); + expect(error?.message).toContain(`Unable to find the following binaries on the filesystem`); + expect(error?.message).toContain(`'forc' at path '${forcPath}'`); + expect(error?.message).toContain(`'fuel-core' at path '${fuelCorePath}'`); + expect(error?.message).toContain( + 'Visit https://docs.fuel.network/guides/installation/ for an installation guide.' + ); }); }); diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts index 6133691eccf..9d231d36974 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.test.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -85,9 +85,11 @@ describe('tryFindBinaries', () => { expect(getSystemForc).toHaveBeenCalledTimes(1); expect(getSystemFuelCore).toHaveBeenCalledTimes(1); - expect(error?.message).toMatch(/Unable to find the following binaries on the filesystem/g); - expect(error?.message).toMatch(/\/non\/existent\/forc/g); - expect(error?.message).toMatch(/\/non\/existent\/fuel-core/g); - expect(error?.message).toMatch(/Visit https:\/\/docs.fuel.network\/guides\/installation\//g); + expect(error?.message).toContain(`Unable to find the following binaries on the filesystem`); + expect(error?.message).toContain(`'forc' at path '${forcPath}'`); + expect(error?.message).toContain(`'fuel-core' at path '${fuelCorePath}'`); + expect(error?.message).toContain( + 'Visit https://docs.fuel.network/guides/installation/ for an installation guide.' + ); }); }); From cbc25d8acdb1915566dd009fce67d1e9cd893eb0 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Fri, 10 May 2024 15:34:58 +0100 Subject: [PATCH 60/89] Added binary paths to the versions command --- packages/fuels/src/cli.ts | 7 +- .../src/cli/commands/withBinaryPaths.test.ts | 92 +++++++++++++++++++ .../fuels/src/cli/commands/withBinaryPaths.ts | 33 +++++++ packages/fuels/src/cli/config/loadConfig.ts | 8 +- packages/fuels/src/cli/types.ts | 5 + .../src/cli-utils/tryFindBinaries.test.ts | 44 ++++++--- .../utils/src/cli-utils/tryFindBinaries.ts | 24 ++--- packages/versions/src/cli.test.ts | 2 + packages/versions/src/cli.ts | 21 ++++- .../src/lib/getSystemVersions.test.ts | 4 + .../versions/src/lib/getSystemVersions.ts | 14 ++- 11 files changed, 210 insertions(+), 44 deletions(-) create mode 100644 packages/fuels/src/cli/commands/withBinaryPaths.test.ts create mode 100644 packages/fuels/src/cli/commands/withBinaryPaths.ts diff --git a/packages/fuels/src/cli.ts b/packages/fuels/src/cli.ts index 52bd48f8436..b32842805f4 100644 --- a/packages/fuels/src/cli.ts +++ b/packages/fuels/src/cli.ts @@ -7,6 +7,7 @@ import { build } from './cli/commands/build'; import { deploy } from './cli/commands/deploy'; import { dev } from './cli/commands/dev'; import { init } from './cli/commands/init'; +import { withBinaryPaths } from './cli/commands/withBinaryPaths'; import { withConfig } from './cli/commands/withConfig'; import { withProgram } from './cli/commands/withProgram'; import { Commands } from './cli/types'; @@ -89,10 +90,10 @@ export const configureCli = () => { ); // Versions - program - .command('versions') + (command = program.command('versions')) .description('Check for version incompatibilities') - .action(runVersions); + .addOption(pathOption) + .action(withBinaryPaths(command, Commands.versions, runVersions)); return program; }; diff --git a/packages/fuels/src/cli/commands/withBinaryPaths.test.ts b/packages/fuels/src/cli/commands/withBinaryPaths.test.ts new file mode 100644 index 00000000000..ad1ccf86795 --- /dev/null +++ b/packages/fuels/src/cli/commands/withBinaryPaths.test.ts @@ -0,0 +1,92 @@ +import { program } from 'commander'; + +import { fuelsConfig } from '../../../test/fixtures/fuels.config'; +import { mockLogger } from '../../../test/utils/mockLogger'; +import * as loadConfigMod from '../config/loadConfig'; +import { Commands } from '../types'; + +import { withBinaryPaths } from './withBinaryPaths'; + +const mockAllDeps = ( + params: { configPath?: string; forcPath?: string; fuelCorePath?: string } = {} +) => { + const { forcPath, fuelCorePath, configPath } = params; + + const command = program + .command(Commands.versions) + .option('-p, --path ', 'Path to project root', configPath); + + const runVersions = vi.fn(); + + const loadUserConfig = vi.spyOn(loadConfigMod, 'loadUserConfig').mockResolvedValue({ + configPath: '/path/to/config', + userConfig: { + ...structuredClone(fuelsConfig), + forcPath, + fuelCorePath, + }, + }); + + return { + command, + runVersions, + loadUserConfig, + }; +}; + +describe('withBinaryPaths', () => { + beforeEach(() => { + mockLogger(); + }); + + beforeEach(() => { + vi.restoreAllMocks(); + }); + + it('should load the user config from the path', async () => { + const configPath = '/path/to/config'; + const { command, runVersions, loadUserConfig } = mockAllDeps({ configPath }); + + await withBinaryPaths(command, Commands.versions, runVersions)(); + + expect(loadUserConfig).toHaveBeenCalledWith(configPath); + }); + + it('should fallback to default binary paths (undefined)', async () => { + const expectedPaths = { forcPath: undefined, fuelCorePath: undefined }; + const { command, runVersions } = mockAllDeps(); + + await withBinaryPaths(command, Commands.versions, runVersions)(); + + expect(runVersions).toHaveBeenCalledWith(expectedPaths); + }); + + it('should use resolved user config paths', async () => { + const expectedPaths = { forcPath: 'forc', fuelCorePath: 'fuel-core' }; + const { command, runVersions } = mockAllDeps({ ...expectedPaths }); + + await withBinaryPaths(command, Commands.versions, runVersions)(); + + expect(runVersions).toHaveBeenCalledWith(expectedPaths); + }); + + it(`should debug any errors that occur while loading the user config`, async () => { + const { debug } = mockLogger(); + const { command, runVersions, loadUserConfig } = mockAllDeps(); + loadUserConfig.mockRejectedValue(new Error('Something happened')); + + await withBinaryPaths(command, Commands.versions, runVersions)(); + + expect(debug).toHaveBeenCalledWith('Something happened'); + }); + + it(`should error any errors that occur while running the command`, async () => { + const { error } = mockLogger(); + const { command, runVersions } = mockAllDeps(); + runVersions.mockRejectedValue(new Error('Something happened')); + + await withBinaryPaths(command, Commands.versions, runVersions)(); + + expect(error).toHaveBeenCalledWith(new Error('Something happened')); + }); +}); diff --git a/packages/fuels/src/cli/commands/withBinaryPaths.ts b/packages/fuels/src/cli/commands/withBinaryPaths.ts new file mode 100644 index 00000000000..4df77474ae6 --- /dev/null +++ b/packages/fuels/src/cli/commands/withBinaryPaths.ts @@ -0,0 +1,33 @@ +import type { Command } from 'commander'; + +import { loadUserConfig } from '../config/loadConfig'; +import type { Commands, UserFuelsConfig } from '../types'; +import { debug, error } from '../utils/logger'; + +type BinaryPaths = Pick; + +export function withBinaryPaths( + program: Command, + _command: CType, + fn: (paths: BinaryPaths) => void +) { + return async () => { + const options = program.opts(); + + const paths: BinaryPaths = {}; + + try { + const { userConfig } = await loadUserConfig(options.path); + paths.forcPath = userConfig.forcPath; + paths.fuelCorePath = userConfig.fuelCorePath; + } catch (err) { + debug((err).message); + } + + try { + await fn(paths); + } catch (err) { + error(err); + } + }; +} diff --git a/packages/fuels/src/cli/config/loadConfig.ts b/packages/fuels/src/cli/config/loadConfig.ts index aea3c99e67e..f00ee72f23b 100644 --- a/packages/fuels/src/cli/config/loadConfig.ts +++ b/packages/fuels/src/cli/config/loadConfig.ts @@ -11,7 +11,9 @@ import type { FuelsConfig, UserFuelsConfig } from '../types'; import { readForcToml, readSwayType } from './forcUtils'; import { validateConfig } from './validateConfig'; -export async function loadConfig(cwd: string): Promise { +export async function loadUserConfig( + cwd: string +): Promise<{ userConfig: UserFuelsConfig; configPath: string }> { const configJoycon = new JoyCon(); const configPath = await configJoycon.resolve({ @@ -37,7 +39,11 @@ export async function loadConfig(cwd: string): Promise { }); const userConfig: UserFuelsConfig = result.mod.default; + return { configPath, userConfig }; +} +export async function loadConfig(cwd: string): Promise { + const { configPath, userConfig } = await loadUserConfig(cwd); await validateConfig(userConfig); const { forcBuildFlags = [] } = userConfig; diff --git a/packages/fuels/src/cli/types.ts b/packages/fuels/src/cli/types.ts index 835637a779d..b4c8d007c91 100644 --- a/packages/fuels/src/cli/types.ts +++ b/packages/fuels/src/cli/types.ts @@ -5,6 +5,7 @@ export enum Commands { deploy = 'deploy', dev = 'dev', init = 'init', + versions = 'versions', } export type CommandEvent = @@ -23,6 +24,10 @@ export type CommandEvent = | { type: Commands.init; data: unknown; + } + | { + type: Commands.versions; + data: unknown; }; export type DeployedContract = { diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts index 9d231d36974..75d789321fe 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.test.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -1,25 +1,41 @@ import { safeExec } from '@fuel-ts/errors/test-utils'; import * as versionsCliMod from '@fuel-ts/versions/cli'; +import * as childProcessMod from 'child_process'; import { tryFindBinaries } from './tryFindBinaries'; +vi.mock('child_process', async () => { + const mod = await vi.importActual('child_process'); + return { + __esModule: true, + ...mod, + }; +}); + const mockAllDeps = ( params: { - forcError?: Error; - fuelCoreError?: Error; + forcError?: boolean; + fuelCoreError?: boolean; } = {} ) => { const { forcError, fuelCoreError } = params; const version = '1.0.0'; - const getSystemForc = vi - .spyOn(versionsCliMod, 'getSystemForc') - .mockImplementation(() => ({ error: forcError ?? null, systemForcVersion: version })); + const execSyncError = vi.fn(() => { + throw new Error(); + }); + const execSyncVersion = vi.fn().mockReturnValue(version); + + const getSystemForc = vi.spyOn(versionsCliMod, 'getSystemForc'); + vi.spyOn(childProcessMod, 'execSync').mockImplementationOnce( + forcError ? execSyncError : execSyncVersion + ); - const getSystemFuelCore = vi - .spyOn(versionsCliMod, 'getSystemFuelCore') - .mockImplementation(() => ({ error: fuelCoreError ?? null, systemFuelCoreVersion: version })); + const getSystemFuelCore = vi.spyOn(versionsCliMod, 'getSystemFuelCore'); + vi.spyOn(childProcessMod, 'execSync').mockImplementationOnce( + fuelCoreError ? execSyncError : execSyncVersion + ); return { getSystemForc, @@ -37,9 +53,9 @@ describe('tryFindBinaries', () => { const binaries = tryFindBinaries(); expect(getSystemForc).toHaveBeenCalledTimes(1); - expect(getSystemForc).toBeCalledWith('forc'); + expect(getSystemForc).toBeCalledWith(undefined); expect(getSystemFuelCore).toHaveBeenCalledTimes(1); - expect(getSystemFuelCore).toBeCalledWith('fuel-core'); + expect(getSystemFuelCore).toBeCalledWith(undefined); expect(binaries.forcPath).toEqual('forc'); expect(binaries.fuelCorePath).toEqual('fuel-core'); }); @@ -66,9 +82,9 @@ describe('tryFindBinaries', () => { const binaries = tryFindBinaries({ forcPath: undefined, fuelCorePath: undefined }); expect(getSystemForc).toHaveBeenCalledTimes(1); - expect(getSystemForc).toBeCalledWith('forc'); + expect(getSystemForc).toBeCalledWith(undefined); expect(getSystemFuelCore).toHaveBeenCalledTimes(1); - expect(getSystemFuelCore).toBeCalledWith('fuel-core'); + expect(getSystemFuelCore).toBeCalledWith(undefined); expect(binaries.forcPath).toEqual('forc'); expect(binaries.fuelCorePath).toEqual('fuel-core'); }); @@ -77,8 +93,8 @@ describe('tryFindBinaries', () => { const forcPath = '/non/existent/path/to/forc'; const fuelCorePath = '/non/existent/path/to/fuel-core'; const { getSystemForc, getSystemFuelCore } = mockAllDeps({ - forcError: new Error('forc not found'), - fuelCoreError: new Error('fuel-core not found'), + forcError: true, + fuelCoreError: true, }); const { error } = await safeExec(() => tryFindBinaries({ forcPath, fuelCorePath })); diff --git a/packages/utils/src/cli-utils/tryFindBinaries.ts b/packages/utils/src/cli-utils/tryFindBinaries.ts index f48f014e56c..f51eb984e18 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.ts @@ -1,11 +1,6 @@ import { FuelError } from '@fuel-ts/errors'; import { getSystemForc, getSystemFuelCore } from '@fuel-ts/versions/cli'; -const defaultBinaryPaths = { - forcPath: 'forc', - fuelCorePath: 'fuel-core', -} as const; - /** * Tries to find the binaries in the system, otherwise throws an error. * @@ -13,30 +8,25 @@ const defaultBinaryPaths = { * @returns - paths to the resolved binaries */ export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: string } = {}) => { - const { forcPath, fuelCorePath } = { - forcPath: paths.forcPath ?? defaultBinaryPaths.forcPath, - fuelCorePath: paths.fuelCorePath ?? defaultBinaryPaths.fuelCorePath, - }; - // Ensure we can get the binary versions - const { error: forcError } = getSystemForc(forcPath); - const { error: fuelCoreError } = getSystemFuelCore(fuelCorePath); + const { error: forcError, systemForcPath } = getSystemForc(paths.forcPath); + const { error: fuelCoreError, systemFuelCorePath } = getSystemFuelCore(paths.fuelCorePath); if (forcError || fuelCoreError) { const errors = [ 'Unable to find the following binaries on the filesystem:', - forcError ? ` -> 'forc' at path '${forcPath}'` : undefined, - fuelCoreError ? ` -> 'fuel-core' at path '${fuelCorePath}'` : undefined, + forcError ? ` -> 'forc' at path '${systemForcPath}'` : undefined, + fuelCoreError ? ` -> 'fuel-core' at path '${systemFuelCorePath}'` : undefined, `\nVisit https://docs.fuel.network/guides/installation/ for an installation guide.`, ]; throw new FuelError( FuelError.CODES.BIN_FILE_NOT_FOUND, `${errors.filter(Boolean).join('\n')}`, - { forcPath, fuelCorePath } + { ...paths } ); } return { - forcPath, - fuelCorePath, + forcPath: systemForcPath, + fuelCorePath: systemFuelCorePath, }; }; diff --git a/packages/versions/src/cli.test.ts b/packages/versions/src/cli.test.ts index 7b3e36145d6..64a905f40a1 100644 --- a/packages/versions/src/cli.test.ts +++ b/packages/versions/src/cli.test.ts @@ -58,6 +58,8 @@ describe('cli.js', () => { error: systemVersionsError, systemForcVersion, systemFuelCoreVersion, + systemForcPath: 'forc', + systemFuelCorePath: 'fuel-core', })); vi.spyOn(getBuiltinVersionsMod, 'getBuiltinVersions').mockImplementation(() => ({ diff --git a/packages/versions/src/cli.ts b/packages/versions/src/cli.ts index 09cf858b3f5..fdc80e9ddd4 100644 --- a/packages/versions/src/cli.ts +++ b/packages/versions/src/cli.ts @@ -13,16 +13,22 @@ export * from './lib/getSystemVersions'; export const eitherOr = (val1: string | null, val2: string) => val1 ?? val2; -export function runVersions() { +export function runVersions(params: { forcPath?: string; fuelCorePath?: string } = {}) { const { error, info } = console; const supportedVersions = getBuiltinVersions(); const cliTable = new CliTable({ - head: ['', chalk.bold('Supported'), chalk.bold(`Yours / System`)], + head: ['', chalk.bold('Supported'), chalk.bold(`Yours / System`), chalk.bold('System Path')], }); - const { error: systemError, systemForcVersion, systemFuelCoreVersion } = getSystemVersions(); + const { + error: systemError, + systemForcVersion, + systemFuelCoreVersion, + systemForcPath, + systemFuelCorePath, + } = getSystemVersions(params); const comparisons = compareSystemVersions({ systemForcVersion: eitherOr(systemForcVersion, '0'), @@ -41,8 +47,13 @@ export function runVersions() { isOk: comparisons.systemFuelCoreIsEq, }); - cliTable.push(['Forc', supportedVersions.FORC, userForcColorized]); - cliTable.push(['Fuel-Core', supportedVersions.FUEL_CORE, userFuelCoreColorized]); + cliTable.push(['Forc', supportedVersions.FORC, userForcColorized, systemForcPath]); + cliTable.push([ + 'Fuel-Core', + supportedVersions.FUEL_CORE, + userFuelCoreColorized, + systemFuelCorePath, + ]); const someIsGt = comparisons.systemForcIsGt || comparisons.systemFuelCoreIsGt; const bothAreExact = comparisons.systemForcIsEq && comparisons.systemFuelCoreIsEq; diff --git a/packages/versions/src/lib/getSystemVersions.test.ts b/packages/versions/src/lib/getSystemVersions.test.ts index a7e522206d9..24623993787 100644 --- a/packages/versions/src/lib/getSystemVersions.test.ts +++ b/packages/versions/src/lib/getSystemVersions.test.ts @@ -64,6 +64,8 @@ describe('getSystemVersions', () => { expect(execSync).toBeCalledWith(`fuel-core --version`, expectedExecSyncOptions); expect(versions.systemForcVersion).toEqual(systemForcVersion); expect(versions.systemFuelCoreVersion).toEqual(systemFuelCoreVersion); + expect(versions.systemForcPath).toEqual('forc'); + expect(versions.systemFuelCorePath).toEqual('fuel-core'); }); test('should return error if Forc or Fuel-Core is not installed', () => { @@ -128,5 +130,7 @@ describe('getSystemVersions', () => { expect(execSync).toBeCalledWith(`/path/to/custom/fuel-core --version`, expectedExecSyncOptions); expect(versions.systemForcVersion).toEqual(systemForcVersion); expect(versions.systemFuelCoreVersion).toEqual(systemFuelCoreVersion); + expect(versions.systemForcPath).toEqual('/path/to/custom/forc'); + expect(versions.systemFuelCorePath).toEqual('/path/to/custom/fuel-core'); }); }); diff --git a/packages/versions/src/lib/getSystemVersions.ts b/packages/versions/src/lib/getSystemVersions.ts index 42060d6b4a2..dc62e7c1f12 100644 --- a/packages/versions/src/lib/getSystemVersions.ts +++ b/packages/versions/src/lib/getSystemVersions.ts @@ -27,24 +27,30 @@ export const getSystemVersion = (command: string) => { export function getSystemForc(forcPath: string = defaultForcCommand) { const { error, version: v } = getSystemVersion(`${forcPath} --version`); - return { error, systemForcVersion: v }; + return { error, systemForcVersion: v, systemForcPath: forcPath }; } export function getSystemFuelCore(fuelCorePath: string = defaultFuelCoreCommand) { const { error, version: v } = getSystemVersion(`${fuelCorePath} --version`); - return { error, systemFuelCoreVersion: v }; + return { error, systemFuelCoreVersion: v, systemFuelCorePath: fuelCorePath }; } export function getSystemVersions(params: { forcPath?: string; fuelCorePath?: string } = {}) { const { forcPath, fuelCorePath } = params; - const { error: errorForc, systemForcVersion } = getSystemForc(forcPath); - const { error: errorCore, systemFuelCoreVersion } = getSystemFuelCore(fuelCorePath); + const { error: errorForc, systemForcVersion, systemForcPath } = getSystemForc(forcPath); + const { + error: errorCore, + systemFuelCoreVersion, + systemFuelCorePath, + } = getSystemFuelCore(fuelCorePath); const error = errorForc ?? errorCore; return { error, systemForcVersion, + systemForcPath, systemFuelCoreVersion, + systemFuelCorePath, }; } From 0104ab1c48265b905dd4f7dcef6a9ee9c400b437 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Fri, 10 May 2024 16:53:25 +0100 Subject: [PATCH 61/89] Added version error for incompatible versions --- .../src/cli-utils/tryFindBinaries.test.ts | 40 ++++++++++++++++--- .../utils/src/cli-utils/tryFindBinaries.ts | 35 ++++++++++++++-- packages/versions/src/cli.ts | 1 + .../src/lib/compareSystemVersions.test.ts | 6 +++ .../versions/src/lib/compareSystemVersions.ts | 6 +++ 5 files changed, 79 insertions(+), 9 deletions(-) diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts index 75d789321fe..ca01e9c6217 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.test.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -14,32 +14,44 @@ vi.mock('child_process', async () => { const mockAllDeps = ( params: { + compatibleVersion?: string; forcError?: boolean; + forcVersion?: string; fuelCoreError?: boolean; + fuelCoreVersion?: string; } = {} ) => { - const { forcError, fuelCoreError } = params; + const { forcError, forcVersion, fuelCoreError, fuelCoreVersion } = params; - const version = '1.0.0'; + const compatibleVersion = params.compatibleVersion ?? '1.0.0'; const execSyncError = vi.fn(() => { throw new Error(); }); - const execSyncVersion = vi.fn().mockReturnValue(version); const getSystemForc = vi.spyOn(versionsCliMod, 'getSystemForc'); vi.spyOn(childProcessMod, 'execSync').mockImplementationOnce( - forcError ? execSyncError : execSyncVersion + forcError ? execSyncError : vi.fn().mockReturnValue(forcVersion ?? compatibleVersion) ); const getSystemFuelCore = vi.spyOn(versionsCliMod, 'getSystemFuelCore'); vi.spyOn(childProcessMod, 'execSync').mockImplementationOnce( - fuelCoreError ? execSyncError : execSyncVersion + fuelCoreError ? execSyncError : vi.fn().mockReturnValue(fuelCoreVersion ?? compatibleVersion) ); + const getBuiltinVersions = vi + .spyOn(versionsCliMod, 'getBuiltinVersions') + .mockReturnValue({ + FORC: compatibleVersion, + FUEL_CORE: compatibleVersion, + FUELS: compatibleVersion, + }); + + return { getSystemForc, getSystemFuelCore, + getBuiltinVersions, }; }; @@ -108,4 +120,22 @@ describe('tryFindBinaries', () => { 'Visit https://docs.fuel.network/guides/installation/ for an installation guide.' ); }); + + it(`should throw when binaries are outdated`, async () => { + const compatibleVersion = '1.0.0'; + const currentVersion = '0.0.1'; + const { getSystemForc, getSystemFuelCore } = mockAllDeps({ + compatibleVersion, + forcVersion: currentVersion, + fuelCoreVersion: currentVersion, + }); + + const { error } = await safeExec(() => tryFindBinaries()); + + expect(getSystemForc).toHaveBeenCalledTimes(1); + expect(getSystemFuelCore).toHaveBeenCalledTimes(1); + expect(error?.message).toContain(`The following binaries on the filesystem are outdated`); + expect(error?.message).toContain(`'forc' is currently '${currentVersion}', but requires '${compatibleVersion}'`); + expect(error?.message).toContain(`'fuel-core' is currently '${currentVersion}', but requires '${compatibleVersion}'`); + }); }); diff --git a/packages/utils/src/cli-utils/tryFindBinaries.ts b/packages/utils/src/cli-utils/tryFindBinaries.ts index f51eb984e18..2f38d0b7afd 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.ts @@ -1,16 +1,26 @@ import { FuelError } from '@fuel-ts/errors'; -import { getSystemForc, getSystemFuelCore } from '@fuel-ts/versions/cli'; +import { + compareSystemVersions, + eitherOr, + getSystemForc, + getSystemFuelCore, + getBuiltinVersions, +} from '@fuel-ts/versions/cli'; /** - * Tries to find the binaries in the system, otherwise throws an error. + * Tries to find compatible binaries on the filesystem, otherwise throws an error. * * @param paths - paths to the binaries (optional) * @returns - paths to the resolved binaries */ export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: string } = {}) => { // Ensure we can get the binary versions - const { error: forcError, systemForcPath } = getSystemForc(paths.forcPath); - const { error: fuelCoreError, systemFuelCorePath } = getSystemFuelCore(paths.fuelCorePath); + const { error: forcError, systemForcPath, systemForcVersion } = getSystemForc(paths.forcPath); + const { + error: fuelCoreError, + systemFuelCorePath, + systemFuelCoreVersion, + } = getSystemFuelCore(paths.fuelCorePath); if (forcError || fuelCoreError) { const errors = [ 'Unable to find the following binaries on the filesystem:', @@ -25,6 +35,23 @@ export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: strin ); } + const { systemForcIsLt, systemFuelCoreIsLt } = compareSystemVersions({ + systemForcVersion: eitherOr(systemForcVersion, '0'), + systemFuelCoreVersion: eitherOr(systemFuelCoreVersion, '0'), + }); + + if (systemForcIsLt || systemFuelCoreIsLt) { + const { FORC: compatibleForcVersion, FUEL_CORE: compatibleFuelCoreVersion } = getBuiltinVersions(); + const errors = [ + 'The following binaries on the filesystem are outdated:', + systemForcIsLt ? ` -> '${systemForcPath}' is currently '${systemForcVersion}', but requires '${compatibleForcVersion}'.` : undefined, + systemFuelCoreIsLt ? ` -> '${systemFuelCorePath}' is currently '${systemFuelCoreVersion}', but requires '${compatibleFuelCoreVersion}'.` : undefined, + ]; + throw new FuelError(FuelError.CODES.NOT_SUPPORTED, `${errors.filter(Boolean).join('\n')}`, { + ...paths, + }); + } + return { forcPath: systemForcPath, fuelCorePath: systemFuelCorePath, diff --git a/packages/versions/src/cli.ts b/packages/versions/src/cli.ts index fdc80e9ddd4..f15697b1bb5 100644 --- a/packages/versions/src/cli.ts +++ b/packages/versions/src/cli.ts @@ -10,6 +10,7 @@ import { getSystemVersions } from './lib/getSystemVersions'; export * from './lib/compareSystemVersions'; export * from './lib/fuelUpLink'; export * from './lib/getSystemVersions'; +export * from './lib/getBuiltinVersions'; export const eitherOr = (val1: string | null, val2: string) => val1 ?? val2; diff --git a/packages/versions/src/lib/compareSystemVersions.test.ts b/packages/versions/src/lib/compareSystemVersions.test.ts index e4003a7b5d2..6863d24157b 100644 --- a/packages/versions/src/lib/compareSystemVersions.test.ts +++ b/packages/versions/src/lib/compareSystemVersions.test.ts @@ -29,9 +29,11 @@ describe('compareSystemVersions.js', () => { expect(comparisons.systemForcIsGt).toEqual(true); expect(comparisons.systemForcIsEq).toEqual(false); + expect(comparisons.systemForcIsLt).toEqual(false); expect(comparisons.systemFuelCoreIsGt).toEqual(true); expect(comparisons.systemFuelCoreIsEq).toEqual(false); + expect(comparisons.systemFuelCoreIsLt).toEqual(false); }); test('should compare against: exact versions', () => { @@ -42,9 +44,11 @@ describe('compareSystemVersions.js', () => { expect(comparisons.systemForcIsGt).toEqual(false); expect(comparisons.systemForcIsEq).toEqual(true); + expect(comparisons.systemForcIsLt).toEqual(false); expect(comparisons.systemFuelCoreIsGt).toEqual(false); expect(comparisons.systemFuelCoreIsEq).toEqual(true); + expect(comparisons.systemFuelCoreIsLt).toEqual(false); }); test('should compare against: older versions', () => { @@ -55,8 +59,10 @@ describe('compareSystemVersions.js', () => { expect(comparisons.systemForcIsGt).toEqual(false); expect(comparisons.systemForcIsEq).toEqual(false); + expect(comparisons.systemForcIsLt).toEqual(true); expect(comparisons.systemFuelCoreIsGt).toEqual(false); expect(comparisons.systemFuelCoreIsEq).toEqual(false); + expect(comparisons.systemFuelCoreIsLt).toEqual(true); }); }); diff --git a/packages/versions/src/lib/compareSystemVersions.ts b/packages/versions/src/lib/compareSystemVersions.ts index 12f47794091..690deabdd46 100644 --- a/packages/versions/src/lib/compareSystemVersions.ts +++ b/packages/versions/src/lib/compareSystemVersions.ts @@ -19,10 +19,16 @@ export function compareSystemVersions(params: ICompareVersionsParams) { const systemForcIsEq = eq(systemForcVersion, versions.FORC); const systemFuelCoreIsEq = eq(systemFuelCoreVersion, versions.FUEL_CORE); + // are user's versions LESS than the ones supported by the SDK? + const systemForcIsLt = !systemForcIsGt && !systemForcIsEq; + const systemFuelCoreIsLt = !systemFuelCoreIsGt && !systemFuelCoreIsEq; + return { systemForcIsGt, systemFuelCoreIsGt, systemForcIsEq, systemFuelCoreIsEq, + systemForcIsLt, + systemFuelCoreIsLt, }; } From 5f2600cfca90569cc96afe8acfa196889882aabe Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Fri, 10 May 2024 17:57:47 +0100 Subject: [PATCH 62/89] Lint --- .../src/cli-utils/tryFindBinaries.test.ts | 21 ++++++++++--------- .../utils/src/cli-utils/tryFindBinaries.ts | 11 +++++++--- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts index ca01e9c6217..7ded6368065 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.test.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -39,14 +39,11 @@ const mockAllDeps = ( fuelCoreError ? execSyncError : vi.fn().mockReturnValue(fuelCoreVersion ?? compatibleVersion) ); - const getBuiltinVersions = vi - .spyOn(versionsCliMod, 'getBuiltinVersions') - .mockReturnValue({ - FORC: compatibleVersion, - FUEL_CORE: compatibleVersion, - FUELS: compatibleVersion, - }); - + const getBuiltinVersions = vi.spyOn(versionsCliMod, 'getBuiltinVersions').mockReturnValue({ + FORC: compatibleVersion, + FUEL_CORE: compatibleVersion, + FUELS: compatibleVersion, + }); return { getSystemForc, @@ -135,7 +132,11 @@ describe('tryFindBinaries', () => { expect(getSystemForc).toHaveBeenCalledTimes(1); expect(getSystemFuelCore).toHaveBeenCalledTimes(1); expect(error?.message).toContain(`The following binaries on the filesystem are outdated`); - expect(error?.message).toContain(`'forc' is currently '${currentVersion}', but requires '${compatibleVersion}'`); - expect(error?.message).toContain(`'fuel-core' is currently '${currentVersion}', but requires '${compatibleVersion}'`); + expect(error?.message).toContain( + `'forc' is currently '${currentVersion}', but requires '${compatibleVersion}'` + ); + expect(error?.message).toContain( + `'fuel-core' is currently '${currentVersion}', but requires '${compatibleVersion}'` + ); }); }); diff --git a/packages/utils/src/cli-utils/tryFindBinaries.ts b/packages/utils/src/cli-utils/tryFindBinaries.ts index 2f38d0b7afd..d251b11a607 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.ts @@ -41,11 +41,16 @@ export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: strin }); if (systemForcIsLt || systemFuelCoreIsLt) { - const { FORC: compatibleForcVersion, FUEL_CORE: compatibleFuelCoreVersion } = getBuiltinVersions(); + const { FORC: compatibleForcVersion, FUEL_CORE: compatibleFuelCoreVersion } = + getBuiltinVersions(); const errors = [ 'The following binaries on the filesystem are outdated:', - systemForcIsLt ? ` -> '${systemForcPath}' is currently '${systemForcVersion}', but requires '${compatibleForcVersion}'.` : undefined, - systemFuelCoreIsLt ? ` -> '${systemFuelCorePath}' is currently '${systemFuelCoreVersion}', but requires '${compatibleFuelCoreVersion}'.` : undefined, + systemForcIsLt + ? ` -> '${systemForcPath}' is currently '${systemForcVersion}', but requires '${compatibleForcVersion}'.` + : undefined, + systemFuelCoreIsLt + ? ` -> '${systemFuelCorePath}' is currently '${systemFuelCoreVersion}', but requires '${compatibleFuelCoreVersion}'.` + : undefined, ]; throw new FuelError(FuelError.CODES.NOT_SUPPORTED, `${errors.filter(Boolean).join('\n')}`, { ...paths, From 2d3621f0f96f2d8841ee2c50c7f2263d05a68c95 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Fri, 10 May 2024 20:28:13 +0100 Subject: [PATCH 63/89] Missing test group --- packages/fuels/src/cli/commands/withBinaryPaths.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/fuels/src/cli/commands/withBinaryPaths.test.ts b/packages/fuels/src/cli/commands/withBinaryPaths.test.ts index ad1ccf86795..b2d09bfa6b8 100644 --- a/packages/fuels/src/cli/commands/withBinaryPaths.test.ts +++ b/packages/fuels/src/cli/commands/withBinaryPaths.test.ts @@ -34,6 +34,9 @@ const mockAllDeps = ( }; }; +/** + * @group node + */ describe('withBinaryPaths', () => { beforeEach(() => { mockLogger(); From dd543dd5a1b1558042ca24915dc124a4afacea0b Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 13 May 2024 13:06:37 +0100 Subject: [PATCH 64/89] Updated docs to reflect changes better --- apps/demo-fuels/fuels.config.full.ts | 8 ++++---- apps/demo-fuels/fuels.config.minimal.ts | 13 +++++++++++++ apps/docs/src/guide/fuels-cli/commands.md | 17 +++++++++-------- apps/docs/src/guide/fuels-cli/config-file.md | 4 ++-- 4 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 apps/demo-fuels/fuels.config.minimal.ts diff --git a/apps/demo-fuels/fuels.config.full.ts b/apps/demo-fuels/fuels.config.full.ts index f071969b1b9..ff395283785 100644 --- a/apps/demo-fuels/fuels.config.full.ts +++ b/apps/demo-fuels/fuels.config.full.ts @@ -97,13 +97,13 @@ export default createConfig({ // #endregion onFailure // #region forcPath - // Default: undefined - forcPath: 'fuels-forc', + // Default: 'forc', + forcPath: '/custom/path/to/forc', // #endregion forcPath // #region fuelCorePath - // Default: undefined - fuelCorePath: 'fuels-core', + // Default: 'fuel-core' + fuelCorePath: '/custom/path/to/fuel-core', // #endregion fuelCorePath }); diff --git a/apps/demo-fuels/fuels.config.minimal.ts b/apps/demo-fuels/fuels.config.minimal.ts new file mode 100644 index 00000000000..8b17236adde --- /dev/null +++ b/apps/demo-fuels/fuels.config.minimal.ts @@ -0,0 +1,13 @@ +// #region config +import { createConfig } from 'fuels'; + +export default createConfig({ + workspace: './sway-programs', // forc workspace + output: './src/sway-programs-api', +}); +// #endregion config + +/** + * Check the docs: + * https://fuellabs.github.io/fuels-ts/guide/fuels/config-file + */ diff --git a/apps/docs/src/guide/fuels-cli/commands.md b/apps/docs/src/guide/fuels-cli/commands.md index 076978b9af3..65966017247 100644 --- a/apps/docs/src/guide/fuels-cli/commands.md +++ b/apps/docs/src/guide/fuels-cli/commands.md @@ -36,7 +36,7 @@ npx fuels@{{fuels}} init --workspace ./sway-programs --output ./src/sway-program This will give you a minimal configuration: -<<< @../../../demo-fuels/fuels.config.ts#config{ts:line-numbers} +<<< @../../../demo-fuels/fuels.config.minimal.ts#config{ts:line-numbers} In a nutshell: @@ -162,12 +162,13 @@ npx fuels@{{fuels}} versions ``` ``` +┌───────────┬───────────┬────────────────┬─────────────┐ +│ │ Supported │ Yours / System │ System Path │ +├───────────┼───────────┼────────────────┼─────────────┤ +│ Forc │ 0.56.1 │ 0.56.1 │ forc │ +├───────────┼───────────┼────────────────┼─────────────┤ +│ Fuel-Core │ 0.26.0 │ 0.26.0 │ fuel-core │ +└───────────┴───────────┴────────────────┴─────────────┘ + You have all the right versions! ⚡ -┌───────────┬───────────┬─────────────────┐ -│ │ Supported │ Yours / System │ -├───────────┼───────────┼─────────────────┤ -│ Forc │ 0.49.3 │ 0.49.3 │ -├───────────┼───────────┼─────────────────┤ -│ Fuel-Core │ 0.22.1 │ 0.22.1 │ -└───────────┴───────────┴─────────────────┘ ``` diff --git a/apps/docs/src/guide/fuels-cli/config-file.md b/apps/docs/src/guide/fuels-cli/config-file.md index 9efeefdda27..3b9beec829e 100644 --- a/apps/docs/src/guide/fuels-cli/config-file.md +++ b/apps/docs/src/guide/fuels-cli/config-file.md @@ -147,7 +147,7 @@ Parameters: Path to the `forc` binary. -When not supplied, will default to using the `system` binaries. +When not supplied, will default to using the `system` binaries (`forc`). <<< @../../../demo-fuels/fuels.config.full.ts#forcPath{ts:line-numbers} @@ -155,7 +155,7 @@ When not supplied, will default to using the `system` binaries. Path to the `fuel-core` binary. -When not supplied, will default to using the `system` binaries. +When not supplied, will default to using the `system` binaries (`fuel-core`). <<< @../../../demo-fuels/fuels.config.full.ts#fuelCorePath{ts:line-numbers} From 85d4f2a5c22a25a2251b1c5a15d0c4e3c642d7df Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 13 May 2024 14:12:33 +0100 Subject: [PATCH 65/89] Suppressing the version logs (stderr) from outputting --- .../versions/src/lib/getSystemVersions.test.ts | 18 ++++++++---------- packages/versions/src/lib/getSystemVersions.ts | 5 ++++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/versions/src/lib/getSystemVersions.test.ts b/packages/versions/src/lib/getSystemVersions.test.ts index 24623993787..6771be7729f 100644 --- a/packages/versions/src/lib/getSystemVersions.test.ts +++ b/packages/versions/src/lib/getSystemVersions.test.ts @@ -44,8 +44,6 @@ function mockAllDeps(params: { * @group node */ describe('getSystemVersions', () => { - const expectedExecSyncOptions = expect.objectContaining({ stdio: 'pipe' }); - test('should get user versions just fine', () => { // mocking const systemForcVersion = '1.0.0'; @@ -60,8 +58,8 @@ describe('getSystemVersions', () => { // validating expect(execSync).toHaveBeenCalledTimes(2); - expect(execSync).toBeCalledWith(`forc --version`, expectedExecSyncOptions); - expect(execSync).toBeCalledWith(`fuel-core --version`, expectedExecSyncOptions); + expect(execSync).toBeCalledWith(`forc --version`, expect.any(Object)); + expect(execSync).toBeCalledWith(`fuel-core --version`, expect.any(Object)); expect(versions.systemForcVersion).toEqual(systemForcVersion); expect(versions.systemFuelCoreVersion).toEqual(systemFuelCoreVersion); expect(versions.systemForcPath).toEqual('forc'); @@ -83,8 +81,8 @@ describe('getSystemVersions', () => { // validating expect(execSync).toHaveBeenCalledTimes(2); - expect(execSync).toBeCalledWith(`forc --version`, expectedExecSyncOptions); - expect(execSync).toBeCalledWith(`fuel-core --version`, expectedExecSyncOptions); + expect(execSync).toBeCalledWith(`forc --version`, expect.any(Object)); + expect(execSync).toBeCalledWith(`fuel-core --version`, expect.any(Object)); expect(systemError).toBeTruthy(); }); @@ -102,8 +100,8 @@ describe('getSystemVersions', () => { // validating expect(execSync).toHaveBeenCalledTimes(2); - expect(execSync).toBeCalledWith(`forc --version`, expectedExecSyncOptions); - expect(execSync).toBeCalledWith(`fuel-core --version`, expectedExecSyncOptions); + expect(execSync).toBeCalledWith(`forc --version`, expect.any(Object)); + expect(execSync).toBeCalledWith(`fuel-core --version`, expect.any(Object)); expect(versions.error?.toString()).toEqual(`Error: ${systemForcVersion}`); expect(versions.systemForcVersion).toEqual(null); expect(versions.systemFuelCoreVersion).toEqual(null); @@ -126,8 +124,8 @@ describe('getSystemVersions', () => { // validating expect(execSync).toHaveBeenCalledTimes(2); - expect(execSync).toBeCalledWith(`/path/to/custom/forc --version`, expectedExecSyncOptions); - expect(execSync).toBeCalledWith(`/path/to/custom/fuel-core --version`, expectedExecSyncOptions); + expect(execSync).toBeCalledWith(`/path/to/custom/forc --version`, expect.any(Object)); + expect(execSync).toBeCalledWith(`/path/to/custom/fuel-core --version`, expect.any(Object)); expect(versions.systemForcVersion).toEqual(systemForcVersion); expect(versions.systemFuelCoreVersion).toEqual(systemFuelCoreVersion); expect(versions.systemForcPath).toEqual('/path/to/custom/forc'); diff --git a/packages/versions/src/lib/getSystemVersions.ts b/packages/versions/src/lib/getSystemVersions.ts index dc62e7c1f12..ee9a883b2da 100644 --- a/packages/versions/src/lib/getSystemVersions.ts +++ b/packages/versions/src/lib/getSystemVersions.ts @@ -9,7 +9,10 @@ export const getSystemVersion = (command: string) => { let error: Error | null = null; try { - const contents = execSync(command, { stdio: 'pipe' }).toString(); + const contents = execSync(command, { + stdio: ['pipe', 'pipe', 'ignore'], + encoding: 'utf8', + }).toString(); if (versionReg.test(contents)) { version = contents.match(versionReg)?.[0] as string; } else { From ec7a3c536456665f19b4233d4d515be442a6e8b1 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 13 May 2024 14:12:42 +0100 Subject: [PATCH 66/89] Removed region --- apps/demo-fuels/fuels.config.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/demo-fuels/fuels.config.ts b/apps/demo-fuels/fuels.config.ts index 42fc18c88e8..7bda359dc78 100644 --- a/apps/demo-fuels/fuels.config.ts +++ b/apps/demo-fuels/fuels.config.ts @@ -1,13 +1,11 @@ -// #region config import { createConfig } from 'fuels'; export default createConfig({ workspace: './sway-programs', // forc workspace output: './src/sway-programs-api', - forcPath: 'fuels-forc', + forcPath: 'fues-forc', fuelCorePath: 'fuels-core', }); -// #endregion config /** * Check the docs: From 844a3859d5eaee4707bff15bed62746a96675eb7 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 13 May 2024 14:29:18 +0100 Subject: [PATCH 67/89] Incorrect binary --- apps/demo-fuels/fuels.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/demo-fuels/fuels.config.ts b/apps/demo-fuels/fuels.config.ts index 7bda359dc78..614e16fd23b 100644 --- a/apps/demo-fuels/fuels.config.ts +++ b/apps/demo-fuels/fuels.config.ts @@ -3,7 +3,7 @@ import { createConfig } from 'fuels'; export default createConfig({ workspace: './sway-programs', // forc workspace output: './src/sway-programs-api', - forcPath: 'fues-forc', + forcPath: 'fuels-forc', fuelCorePath: 'fuels-core', }); From 34333f84252e08a3e51302cff175e3c12d47a206 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 14 May 2024 22:12:14 +0100 Subject: [PATCH 68/89] Removed release tag --- .github/workflows/pr-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-release.yaml b/.github/workflows/pr-release.yaml index 34ad25146b1..9b48fc2352a 100644 --- a/.github/workflows/pr-release.yaml +++ b/.github/workflows/pr-release.yaml @@ -8,7 +8,7 @@ jobs: name: "Release PR to npm" runs-on: ubuntu-latest # comment out if:false to enable release PR to npm - # if: false + if: false permissions: write-all steps: - name: Checkout From bc90d1d41a4eab24f112263369fe2b1cc76d4b64 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 15 May 2024 07:56:26 +0100 Subject: [PATCH 69/89] Merge branch 'master' into ps/docs/undocument-binaries --- .changeset/curly-schools-obey.md | 4 - .changeset/green-houses-applaud.md | 4 - .changeset/grumpy-years-stare.md | 8 - .changeset/lemon-berries-arrive.md | 5 - .changeset/loud-fans-hunt.md | 5 - .changeset/ninety-pianos-crash.md | 4 - .changeset/rotten-bananas-explode.md | 2 - .changeset/spotty-rats-dance.md | 2 - .changeset/tame-icons-film.md | 5 - .changeset/tough-cows-hide.md | 7 - ...-rockets-brush.md => tough-peas-retire.md} | 0 .../transactions/transaction-request.test.ts | 2 +- apps/docs/src/guide/types/vectors.md | 6 +- internal/check-imports/CHANGELOG.md | 28 ++ internal/forc/CHANGELOG.md | 6 + internal/forc/VERSION | 2 +- internal/forc/package.json | 2 +- internal/fuel-core/CHANGELOG.md | 2 + internal/fuel-core/package.json | 2 +- package.json | 12 +- packages/abi-coder/CHANGELOG.md | 19 + packages/abi-coder/package.json | 2 +- packages/abi-coder/src/AbiCoder.ts | 2 +- packages/abi-coder/src/FunctionFragment.ts | 58 +-- packages/abi-coder/src/Interface.ts | 11 +- .../src/encoding/coders/AbstractCoder.ts | 2 +- .../coders/{v0 => }/ArrayCoder.test.ts | 27 +- .../encoding/coders/{v0 => }/ArrayCoder.ts | 11 +- .../coders/{v0 => }/B256Coder.test.ts | 0 .../src/encoding/coders/{v0 => }/B256Coder.ts | 5 +- .../coders/{v0 => }/B512Coder.test.ts | 0 .../src/encoding/coders/{v0 => }/B512Coder.ts | 5 +- .../coders/{v0 => }/BigNumberCoder.test.ts | 2 +- .../coders/{v0 => }/BigNumberCoder.ts | 5 +- .../coders/{v1 => }/BooleanCoder.test.ts | 44 +++ .../encoding/coders/{v1 => }/BooleanCoder.ts | 18 +- .../coders/{v1 => }/ByteCoder.test.ts | 0 .../src/encoding/coders/{v1 => }/ByteCoder.ts | 7 +- .../coders/{v1 => }/EnumCoder.test.ts | 4 +- .../src/encoding/coders/{v1 => }/EnumCoder.ts | 9 +- .../coders/{v1 => }/NumberCoder.test.ts | 68 +++- .../encoding/coders/{v1 => }/NumberCoder.ts | 26 +- .../encoding/coders/{v1 => }/OptionCoder.ts | 3 +- .../coders/{v1 => }/RawSliceCoder.test.ts | 0 .../encoding/coders/{v1 => }/RawSliceCoder.ts | 8 +- .../coders/{v1 => }/StdStringCoder.test.ts | 0 .../coders/{v1 => }/StdStringCoder.ts | 7 +- .../coders/{v1 => }/StrSliceCoder.test.ts | 0 .../encoding/coders/{v1 => }/StrSliceCoder.ts | 7 +- .../coders/{v1 => }/StringCoder.test.ts | 0 .../encoding/coders/{v1 => }/StringCoder.ts | 2 +- .../coders/{v1 => }/StructCoder.test.ts | 4 +- .../encoding/coders/{v1 => }/StructCoder.ts | 5 +- .../coders/{v1 => }/TupleCoder.test.ts | 4 +- .../encoding/coders/{v1 => }/TupleCoder.ts | 4 +- .../encoding/coders/{v1 => }/VecCoder.test.ts | 2 +- .../src/encoding/coders/{v1 => }/VecCoder.ts | 10 +- .../abi-coder/src/encoding/coders/index.ts | 16 + .../encoding/coders/v0/BooleanCoder.test.ts | 74 ---- .../src/encoding/coders/v0/BooleanCoder.ts | 65 ---- .../src/encoding/coders/v0/ByteCoder.test.ts | 104 ------ .../src/encoding/coders/v0/ByteCoder.ts | 67 ---- .../src/encoding/coders/v0/EnumCoder.test.ts | 120 ------ .../src/encoding/coders/v0/EnumCoder.ts | 109 ------ .../encoding/coders/v0/NumberCoder.test.ts | 166 --------- .../src/encoding/coders/v0/NumberCoder.ts | 97 ----- .../src/encoding/coders/v0/OptionCoder.ts | 41 --- .../encoding/coders/v0/RawSliceCoder.test.ts | 44 --- .../src/encoding/coders/v0/RawSliceCoder.ts | 52 --- .../encoding/coders/v0/StdStringCoder.test.ts | 121 ------ .../src/encoding/coders/v0/StdStringCoder.ts | 68 ---- .../encoding/coders/v0/StringCoder.test.ts | 106 ------ .../src/encoding/coders/v0/StringCoder.ts | 44 --- .../encoding/coders/v0/StructCoder.test.ts | 158 -------- .../src/encoding/coders/v0/StructCoder.ts | 84 ----- .../src/encoding/coders/v0/TupleCoder.test.ts | 135 ------- .../src/encoding/coders/v0/TupleCoder.ts | 66 ---- .../src/encoding/coders/v0/VecCoder.test.ts | 89 ----- .../src/encoding/coders/v0/VecCoder.ts | 80 ---- .../strategies/getCoderForEncoding.test.ts | 11 +- .../strategies/getCoderForEncoding.ts | 7 +- .../src/encoding/strategies/getCoderV0.ts | 157 -------- .../src/encoding/strategies/getCoderV1.ts | 44 ++- packages/abi-coder/src/index.ts | 17 +- .../abi-coder/src/types/EncodingOptions.ts | 58 +-- packages/abi-coder/src/utils/constants.ts | 3 +- packages/abi-coder/src/utils/json-abi.test.ts | 17 +- packages/abi-coder/src/utils/json-abi.ts | 5 +- .../abi-coder/src/utils/utilities.test.ts | 292 --------------- packages/abi-coder/src/utils/utilities.ts | 133 +------ packages/abi-coder/test/Interface.test.ts | 6 +- packages/abi-typegen/CHANGELOG.md | 12 + packages/abi-typegen/package.json | 2 +- .../fixtures/templates/contract/bytecode.hbs | 2 +- .../predicate-with-configurable/factory.hbs | 4 +- .../script-with-configurable/factory.hbs | 2 +- packages/account/CHANGELOG.md | 27 ++ packages/account/package.json | 2 +- packages/account/src/account.ts | 2 - packages/account/src/predicate/predicate.ts | 32 +- packages/account/src/providers/coin.ts | 1 - packages/account/src/providers/message.ts | 1 - .../providers/transaction-request/input.ts | 4 - .../transaction-request.ts | 16 - .../src/providers/transaction-summary/call.ts | 61 ++-- packages/address/CHANGELOG.md | 11 + packages/address/package.json | 2 +- packages/contract/CHANGELOG.md | 20 + packages/contract/package.json | 2 +- packages/create-fuels/CHANGELOG.md | 2 + packages/create-fuels/package.json | 2 +- packages/crypto/CHANGELOG.md | 12 + packages/crypto/package.json | 2 +- packages/errors/CHANGELOG.md | 8 + packages/errors/package.json | 2 +- packages/fuel-gauge/package.json | 3 +- .../src/experimental-contract.test.ts | 128 ------- .../src/experimental-logging.test.ts | 344 ------------------ .../src/experimental-predicate.test.ts | 99 ----- .../src/experimental-script.test.ts | 122 ------- .../src/predicate-conditional-inputs.test.ts | 2 +- .../predicate/predicate-configurables.test.ts | 2 + packages/fuel-gauge/src/small-bytes.test.ts | 234 ------------ .../forc-projects-experimental/Forc.toml | 8 - .../contract-echo/Forc.toml | 7 - .../contract-echo/src/main.sw | 109 ------ .../logging/Forc.toml | 7 - .../logging/src/main.sw | 267 -------------- .../predicate-echo/Forc.toml | 7 - .../predicate-echo/src/main.sw | 65 ---- .../script-echo/Forc.toml | 7 - .../script-echo/src/main.sw | 62 ---- .../script-print/Forc.toml | 7 - .../script-print/src/main.sw | 112 ------ packages/fuels/CHANGELOG.md | 29 ++ packages/fuels/package.json | 2 +- packages/hasher/CHANGELOG.md | 10 + packages/hasher/package.json | 2 +- packages/interfaces/CHANGELOG.md | 2 + packages/interfaces/package.json | 2 +- packages/math/CHANGELOG.md | 7 + packages/math/package.json | 2 +- packages/merkle/CHANGELOG.md | 7 + packages/merkle/package.json | 2 +- packages/program/CHANGELOG.md | 19 + packages/program/package.json | 2 +- packages/program/src/contract-call-script.ts | 317 ++++------------ .../src/functions/base-invocation-scope.ts | 17 +- .../src/functions/invocation-results.ts | 6 - .../program/src/functions/multicall-scope.ts | 35 -- packages/program/src/types.ts | 3 - packages/script/CHANGELOG.md | 23 ++ packages/script/package.json | 2 +- .../script/src/script-invocation-scope.ts | 10 +- packages/transactions/CHANGELOG.md | 17 + packages/transactions/package.json | 2 +- packages/transactions/src/coders/input.ts | 22 +- packages/transactions/src/coders/output.ts | 8 +- packages/transactions/src/coders/policy.ts | 7 +- packages/transactions/src/coders/receipt.ts | 8 +- .../src/coders/transaction.test.ts | 8 +- .../transactions/src/coders/transaction.ts | 40 +- .../transactions/src/coders/tx-pointer.ts | 4 +- .../src/coders/upgrade-purpose.test.ts | 2 +- .../src/coders/upgrade-purpose.ts | 8 +- packages/transactions/src/coders/utxo-id.ts | 2 +- packages/transactions/src/coders/witness.ts | 4 +- packages/utils/CHANGELOG.md | 11 + packages/utils/package.json | 2 +- packages/versions/CHANGELOG.md | 6 + packages/versions/package.json | 2 +- .../versions/src/lib/getBuiltinVersions.ts | 4 +- vite.node.config.mts | 14 - ...er.config.mts => vitest.browser.config.mts | 6 +- vitest.config.ts | 24 ++ vite.env.ts => vitest.env.ts | 0 vitest.node.config.mts | 14 + ...ase.config.mts => vitest.shared.config.mts | 20 +- vitest.workspace.ts | 3 + 179 files changed, 823 insertions(+), 4882 deletions(-) delete mode 100644 .changeset/curly-schools-obey.md delete mode 100644 .changeset/green-houses-applaud.md delete mode 100644 .changeset/grumpy-years-stare.md delete mode 100644 .changeset/lemon-berries-arrive.md delete mode 100644 .changeset/loud-fans-hunt.md delete mode 100644 .changeset/ninety-pianos-crash.md delete mode 100644 .changeset/rotten-bananas-explode.md delete mode 100644 .changeset/spotty-rats-dance.md delete mode 100644 .changeset/tame-icons-film.md delete mode 100644 .changeset/tough-cows-hide.md rename .changeset/{long-rockets-brush.md => tough-peas-retire.md} (100%) rename packages/abi-coder/src/encoding/coders/{v0 => }/ArrayCoder.test.ts (83%) rename packages/abi-coder/src/encoding/coders/{v0 => }/ArrayCoder.ts (82%) rename packages/abi-coder/src/encoding/coders/{v0 => }/B256Coder.test.ts (100%) rename packages/abi-coder/src/encoding/coders/{v0 => }/B256Coder.ts (92%) rename packages/abi-coder/src/encoding/coders/{v0 => }/B512Coder.test.ts (100%) rename packages/abi-coder/src/encoding/coders/{v0 => }/B512Coder.ts (92%) rename packages/abi-coder/src/encoding/coders/{v0 => }/BigNumberCoder.test.ts (99%) rename packages/abi-coder/src/encoding/coders/{v0 => }/BigNumberCoder.ts (92%) rename packages/abi-coder/src/encoding/coders/{v1 => }/BooleanCoder.test.ts (62%) rename packages/abi-coder/src/encoding/coders/{v1 => }/BooleanCoder.ts (69%) rename packages/abi-coder/src/encoding/coders/{v1 => }/ByteCoder.test.ts (100%) rename packages/abi-coder/src/encoding/coders/{v1 => }/ByteCoder.ts (88%) rename packages/abi-coder/src/encoding/coders/{v1 => }/EnumCoder.test.ts (95%) rename packages/abi-coder/src/encoding/coders/{v1 => }/EnumCoder.ts (94%) rename packages/abi-coder/src/encoding/coders/{v1 => }/NumberCoder.test.ts (70%) rename packages/abi-coder/src/encoding/coders/{v1 => }/NumberCoder.ts (66%) rename packages/abi-coder/src/encoding/coders/{v1 => }/OptionCoder.ts (95%) rename packages/abi-coder/src/encoding/coders/{v1 => }/RawSliceCoder.test.ts (100%) rename packages/abi-coder/src/encoding/coders/{v1 => }/RawSliceCoder.ts (88%) rename packages/abi-coder/src/encoding/coders/{v1 => }/StdStringCoder.test.ts (100%) rename packages/abi-coder/src/encoding/coders/{v1 => }/StdStringCoder.ts (88%) rename packages/abi-coder/src/encoding/coders/{v1 => }/StrSliceCoder.test.ts (100%) rename packages/abi-coder/src/encoding/coders/{v1 => }/StrSliceCoder.ts (88%) rename packages/abi-coder/src/encoding/coders/{v1 => }/StringCoder.test.ts (100%) rename packages/abi-coder/src/encoding/coders/{v1 => }/StringCoder.ts (95%) rename packages/abi-coder/src/encoding/coders/{v1 => }/StructCoder.test.ts (93%) rename packages/abi-coder/src/encoding/coders/{v1 => }/StructCoder.ts (95%) rename packages/abi-coder/src/encoding/coders/{v1 => }/TupleCoder.test.ts (94%) rename packages/abi-coder/src/encoding/coders/{v1 => }/TupleCoder.ts (93%) rename packages/abi-coder/src/encoding/coders/{v1 => }/VecCoder.test.ts (97%) rename packages/abi-coder/src/encoding/coders/{v1 => }/VecCoder.ts (89%) create mode 100644 packages/abi-coder/src/encoding/coders/index.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/BooleanCoder.test.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/BooleanCoder.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/ByteCoder.test.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/ByteCoder.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/EnumCoder.test.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/EnumCoder.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/NumberCoder.test.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/NumberCoder.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/OptionCoder.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/RawSliceCoder.test.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/RawSliceCoder.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/StdStringCoder.test.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/StdStringCoder.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/StringCoder.test.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/StringCoder.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/StructCoder.test.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/StructCoder.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/TupleCoder.test.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/TupleCoder.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/VecCoder.test.ts delete mode 100644 packages/abi-coder/src/encoding/coders/v0/VecCoder.ts delete mode 100644 packages/abi-coder/src/encoding/strategies/getCoderV0.ts delete mode 100644 packages/abi-coder/src/utils/utilities.test.ts delete mode 100644 packages/fuel-gauge/src/experimental-contract.test.ts delete mode 100644 packages/fuel-gauge/src/experimental-logging.test.ts delete mode 100644 packages/fuel-gauge/src/experimental-predicate.test.ts delete mode 100644 packages/fuel-gauge/src/experimental-script.test.ts delete mode 100644 packages/fuel-gauge/src/small-bytes.test.ts delete mode 100644 packages/fuel-gauge/test/fixtures/forc-projects-experimental/Forc.toml delete mode 100644 packages/fuel-gauge/test/fixtures/forc-projects-experimental/contract-echo/Forc.toml delete mode 100644 packages/fuel-gauge/test/fixtures/forc-projects-experimental/contract-echo/src/main.sw delete mode 100644 packages/fuel-gauge/test/fixtures/forc-projects-experimental/logging/Forc.toml delete mode 100644 packages/fuel-gauge/test/fixtures/forc-projects-experimental/logging/src/main.sw delete mode 100644 packages/fuel-gauge/test/fixtures/forc-projects-experimental/predicate-echo/Forc.toml delete mode 100644 packages/fuel-gauge/test/fixtures/forc-projects-experimental/predicate-echo/src/main.sw delete mode 100644 packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-echo/Forc.toml delete mode 100644 packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-echo/src/main.sw delete mode 100644 packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-print/Forc.toml delete mode 100644 packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-print/src/main.sw delete mode 100644 vite.node.config.mts rename vite.browser.config.mts => vitest.browser.config.mts (81%) create mode 100644 vitest.config.ts rename vite.env.ts => vitest.env.ts (100%) create mode 100644 vitest.node.config.mts rename vite.base.config.mts => vitest.shared.config.mts (96%) create mode 100644 vitest.workspace.ts diff --git a/.changeset/curly-schools-obey.md b/.changeset/curly-schools-obey.md deleted file mode 100644 index 7a9db09db7c..00000000000 --- a/.changeset/curly-schools-obey.md +++ /dev/null @@ -1,4 +0,0 @@ ---- ---- - -build: upgrade `turbo` to v1.13.3 \ No newline at end of file diff --git a/.changeset/green-houses-applaud.md b/.changeset/green-houses-applaud.md deleted file mode 100644 index 3c355702ad1..00000000000 --- a/.changeset/green-houses-applaud.md +++ /dev/null @@ -1,4 +0,0 @@ ---- ---- - -build: remove dependabot need to report coverage \ No newline at end of file diff --git a/.changeset/grumpy-years-stare.md b/.changeset/grumpy-years-stare.md deleted file mode 100644 index 95b6e53457e..00000000000 --- a/.changeset/grumpy-years-stare.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@fuel-ts/account": patch -"@fuel-ts/crypto": patch -"@fuel-ts/utils": patch -"@fuel-ts/errors": patch ---- - -fix: internalize `ethers` functionality and remove dependency \ No newline at end of file diff --git a/.changeset/lemon-berries-arrive.md b/.changeset/lemon-berries-arrive.md deleted file mode 100644 index b8233904ea4..00000000000 --- a/.changeset/lemon-berries-arrive.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@fuel-ts/account": minor ---- - -fix!: avoid add witnesses for predicates diff --git a/.changeset/loud-fans-hunt.md b/.changeset/loud-fans-hunt.md deleted file mode 100644 index 8979105eba8..00000000000 --- a/.changeset/loud-fans-hunt.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"fuels": patch ---- - -fix: ignore libraries in `fuels` CLI diff --git a/.changeset/ninety-pianos-crash.md b/.changeset/ninety-pianos-crash.md deleted file mode 100644 index 842a6cc61c3..00000000000 --- a/.changeset/ninety-pianos-crash.md +++ /dev/null @@ -1,4 +0,0 @@ ---- ---- - -docs: split up getting started guide into multiple pages diff --git a/.changeset/rotten-bananas-explode.md b/.changeset/rotten-bananas-explode.md deleted file mode 100644 index a845151cc84..00000000000 --- a/.changeset/rotten-bananas-explode.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/spotty-rats-dance.md b/.changeset/spotty-rats-dance.md deleted file mode 100644 index a845151cc84..00000000000 --- a/.changeset/spotty-rats-dance.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/tame-icons-film.md b/.changeset/tame-icons-film.md deleted file mode 100644 index b4cabf6d067..00000000000 --- a/.changeset/tame-icons-film.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@fuel-ts/abi-coder": patch ---- - -feat: `VecCoder@v1` accepts `UInt8Array` as encode input diff --git a/.changeset/tough-cows-hide.md b/.changeset/tough-cows-hide.md deleted file mode 100644 index 493d53ca9e3..00000000000 --- a/.changeset/tough-cows-hide.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@fuel-ts/abi-coder": patch -"@fuel-ts/account": patch -"@fuel-ts/utils": patch ---- - -chore: remove `ethers` from `abi-coder` diff --git a/.changeset/long-rockets-brush.md b/.changeset/tough-peas-retire.md similarity index 100% rename from .changeset/long-rockets-brush.md rename to .changeset/tough-peas-retire.md diff --git a/apps/docs-snippets/src/guide/transactions/transaction-request.test.ts b/apps/docs-snippets/src/guide/transactions/transaction-request.test.ts index 6c27c7673c5..a0ae1069767 100644 --- a/apps/docs-snippets/src/guide/transactions/transaction-request.test.ts +++ b/apps/docs-snippets/src/guide/transactions/transaction-request.test.ts @@ -224,7 +224,7 @@ describe('Transaction Request', () => { // #endregion transaction-request-7 expect(transactionId).toBe( - '0x20995f5333a9cd4d7acfab212ee723faec022fd0bd17b7778d552f624ea55d8e' + '0xb82d9e3da13a1b56b623238c0d7a7ab4d602f2c7f886bf7a9c05ecfb99267ce3' ); }); }); diff --git a/apps/docs/src/guide/types/vectors.md b/apps/docs/src/guide/types/vectors.md index 9c2f974f0f7..326dcaf3df6 100644 --- a/apps/docs/src/guide/types/vectors.md +++ b/apps/docs/src/guide/types/vectors.md @@ -28,8 +28,4 @@ Some functions require you to pass in bytecode to the function. The type of the To pass bytecode to this function, you can make use of the `arrayify` function to convert the bytecode file contents into a `UInt8Array`, the TS compatible type for Sway's `Vec` type and pass it the function like so: -<<< @/../../docs-snippets/src/guide/types/vector.test.ts#vector-bytecode-input-ts{ts:line-numbers} - -## Returning vectors - -Currently, returning vectors is not supported by Sway. If you try returning a type that is or contains a Vector, you will get a compile-time error. +<<< @/../../docs-snippets/src/guide/types/vector.test.ts#vector-bytecode-input-ts{ts:line-numbers} \ No newline at end of file diff --git a/internal/check-imports/CHANGELOG.md b/internal/check-imports/CHANGELOG.md index 12bf45cca93..7d4d8d93fcd 100644 --- a/internal/check-imports/CHANGELOG.md +++ b/internal/check-imports/CHANGELOG.md @@ -4,6 +4,34 @@ ### Patch Changes +- Updated dependencies [316c757] +- Updated dependencies [ee969d3] +- Updated dependencies [8866c09] +- Updated dependencies [16196b6] +- Updated dependencies [0651a5f] +- Updated dependencies [64e9659] + - @fuel-ts/account@0.86.0 + - @fuel-ts/crypto@0.86.0 + - @fuel-ts/utils@0.86.0 + - @fuel-ts/errors@0.86.0 + - fuels@0.86.0 + - @fuel-ts/abi-coder@0.86.0 + - @fuel-ts/transactions@0.86.0 + - @fuel-ts/versions@0.86.0 + - @fuel-ts/program@0.86.0 + - @fuel-ts/script@0.86.0 + - @fuel-ts/contract@0.86.0 + - @fuel-ts/address@0.86.0 + - @fuel-ts/hasher@0.86.0 + - @fuel-ts/abi-typegen@0.86.0 + - @fuel-ts/math@0.86.0 + - @fuel-ts/merkle@0.86.0 + - @fuel-ts/interfaces@0.86.0 + +## null + +### Patch Changes + - Updated dependencies [9bc893b] - Updated dependencies [d0e9b1a] - Updated dependencies [1115ade] diff --git a/internal/forc/CHANGELOG.md b/internal/forc/CHANGELOG.md index b75c78064e4..d76c5b25a79 100644 --- a/internal/forc/CHANGELOG.md +++ b/internal/forc/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 0.86.0 + +### Patch Changes + +- 64e9659: feat!: upgrade `forc@0.58.0` and remove `V0` encoding + ## 0.85.0 ## 0.84.0 diff --git a/internal/forc/VERSION b/internal/forc/VERSION index 25a153f0a95..a60476bfe1c 100644 --- a/internal/forc/VERSION +++ b/internal/forc/VERSION @@ -1 +1 @@ -0.56.1 +0.58.0 diff --git a/internal/forc/package.json b/internal/forc/package.json index b77a5cfbd72..796bdb639a7 100644 --- a/internal/forc/package.json +++ b/internal/forc/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@internal/forc", - "version": "0.85.0", + "version": "0.86.0", "description": "NPM bin wrapper around Fuel `forc`", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/internal/fuel-core/CHANGELOG.md b/internal/fuel-core/CHANGELOG.md index 16ae9090a98..2de83710a67 100644 --- a/internal/fuel-core/CHANGELOG.md +++ b/internal/fuel-core/CHANGELOG.md @@ -1,5 +1,7 @@ # @internal/fuel-core +## 0.86.0 + ## 0.85.0 ## 0.84.0 diff --git a/internal/fuel-core/package.json b/internal/fuel-core/package.json index 4d21342e0bb..d8e878f8952 100644 --- a/internal/fuel-core/package.json +++ b/internal/fuel-core/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@internal/fuel-core", - "version": "0.85.0", + "version": "0.86.0", "description": "NPM bin wrapper around `fuel-core`", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/package.json b/package.json index c5db53d6887..b4e8cabfa23 100644 --- a/package.json +++ b/package.json @@ -17,15 +17,15 @@ "pretest": "turbo run pretest", "depcheck": "knip --dependencies --tags=-knipignore", "knip:fix": "knip --fix", - "test": "vitest --run --coverage --config vite.node.config.mts $(scripts/tests-find.sh --node)", - "test:filter": "vitest --run --coverage --config vite.node.config.mts", + "test": "vitest --run --coverage --config vitest.node.config.mts $(scripts/tests-find.sh --node)", + "test:filter": "vitest --run --coverage --config vitest.node.config.mts", "test:coverage-merge": "tsx ./scripts/tests-coverage-merge.ts", "test:coverage-diff": "tsx ./scripts/tests-coverage-diff.ts", - "test:watch": "vitest --watch --config vite.node.config.mts $(scripts/tests-find.sh --node)", + "test:watch": "vitest --watch --config vitest.node.config.mts $(scripts/tests-find.sh --node)", "test:validate": "./scripts/tests-validate.sh", - "test:browser": "vitest --run --coverage --config vite.browser.config.mts $(scripts/tests-find.sh --browser)", - "test:browser:filter": "vitest --run --coverage --config vite.browser.config.mts", - "test:e2e": "vitest --run --config vite.node.config.mts $(scripts/tests-find.sh --e2e)", + "test:browser": "vitest --run --coverage --config vitest.browser.config.mts $(scripts/tests-find.sh --browser)", + "test:browser:filter": "vitest --run --coverage --config vitest.browser.config.mts", + "test:e2e": "vitest --run --config vitest.node.config.mts $(scripts/tests-find.sh --e2e)", "lint": "run-s lint:check prettier:check", "lint:check": "eslint . --ext .ts --max-warnings 0", "lint:fix": "pnpm lint:check --fix", diff --git a/packages/abi-coder/CHANGELOG.md b/packages/abi-coder/CHANGELOG.md index b180e24ac3a..82de3ca48b5 100644 --- a/packages/abi-coder/CHANGELOG.md +++ b/packages/abi-coder/CHANGELOG.md @@ -1,5 +1,24 @@ # Change Log +## 0.86.0 + +### Minor Changes + +- 64e9659: feat!: upgrade `forc@0.58.0` and remove `V0` encoding + +### Patch Changes + +- 16196b6: feat: `VecCoder@v1` accepts `UInt8Array` as encode input +- 0651a5f: chore: remove `ethers` from `abi-coder` +- Updated dependencies [316c757] +- Updated dependencies [0651a5f] + - @fuel-ts/crypto@0.86.0 + - @fuel-ts/utils@0.86.0 + - @fuel-ts/errors@0.86.0 + - @fuel-ts/hasher@0.86.0 + - @fuel-ts/math@0.86.0 + - @fuel-ts/interfaces@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/abi-coder/package.json b/packages/abi-coder/package.json index 3a24d1b135c..452e0a3b83b 100644 --- a/packages/abi-coder/package.json +++ b/packages/abi-coder/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/abi-coder", - "version": "0.85.0", + "version": "0.86.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/abi-coder/src/AbiCoder.ts b/packages/abi-coder/src/AbiCoder.ts index 1714fbd75b1..b7fd369f1de 100644 --- a/packages/abi-coder/src/AbiCoder.ts +++ b/packages/abi-coder/src/AbiCoder.ts @@ -9,7 +9,7 @@ export abstract class AbiCoder { abi: JsonAbi, argument: JsonAbiArgument, options: EncodingOptions = { - isSmallBytes: false, + padToWordSize: false, } ): Coder { const resolvedAbiType = new ResolvedAbiType(abi, argument); diff --git a/packages/abi-coder/src/FunctionFragment.ts b/packages/abi-coder/src/FunctionFragment.ts index 99344271600..e8941de523d 100644 --- a/packages/abi-coder/src/FunctionFragment.ts +++ b/packages/abi-coder/src/FunctionFragment.ts @@ -8,11 +8,8 @@ import { arrayify } from '@fuel-ts/utils'; import { AbiCoder } from './AbiCoder'; import { ResolvedAbiType } from './ResolvedAbiType'; import type { DecodedValue, InputValue } from './encoding/coders/AbstractCoder'; -import { ByteCoder } from './encoding/coders/v0/ByteCoder'; -import { TupleCoder } from './encoding/coders/v0/TupleCoder'; -import { VecCoder } from './encoding/coders/v0/VecCoder'; -import { StdStringCoder } from './encoding/coders/v1/StdStringCoder'; -import { TupleCoder as TupleCoderV1 } from './encoding/coders/v1/TupleCoder'; +import { StdStringCoder } from './encoding/coders/StdStringCoder'; +import { TupleCoder } from './encoding/coders/TupleCoder'; import type { JsonAbi, JsonAbiArgument, @@ -20,15 +17,13 @@ import type { JsonAbiFunctionAttribute, } from './types/JsonAbi'; import type { EncodingVersion } from './utils/constants'; -import { ENCODING_V1, OPTION_CODER_TYPE } from './utils/constants'; +import { OPTION_CODER_TYPE } from './utils/constants'; import { findFunctionByName, findNonEmptyInputs, findTypeById, getEncodingVersion, } from './utils/json-abi'; -import type { Uint8ArrayWithDynamicData } from './utils/utilities'; -import { isHeapType, isPointerType, unpackDynamicData } from './utils/utilities'; export class FunctionFragment< TAbi extends JsonAbi = JsonAbi, @@ -41,11 +36,6 @@ export class FunctionFragment< readonly name: string; readonly jsonFn: JsonAbiFunction; readonly attributes: readonly JsonAbiFunctionAttribute[]; - readonly isInputDataPointer: boolean; - readonly outputMetadata: { - isHeapType: boolean; - encodedLength: number; - }; private readonly jsonAbi: JsonAbi; @@ -58,11 +48,6 @@ export class FunctionFragment< this.selector = FunctionFragment.getFunctionSelector(this.signature); this.selectorBytes = new StdStringCoder().encode(name); this.encoding = getEncodingVersion(jsonAbi.encoding); - this.isInputDataPointer = this.#isInputDataPointer(); - this.outputMetadata = { - isHeapType: this.#isOutputDataHeap(), - encodedLength: this.#getOutputEncodedLength(), - }; this.attributes = this.jsonFn.attributes ?? []; } @@ -80,35 +65,7 @@ export class FunctionFragment< return bn(hashedFunctionSignature.slice(0, 10)).toHex(8); } - #isInputDataPointer(): boolean { - const inputTypes = this.jsonFn.inputs.map((i) => findTypeById(this.jsonAbi, i.type)); - - return this.jsonFn.inputs.length > 1 || isPointerType(inputTypes[0]?.type || ''); - } - - #isOutputDataHeap(): boolean { - const outputType = findTypeById(this.jsonAbi, this.jsonFn.output.type); - - return isHeapType(outputType?.type || ''); - } - - #getOutputEncodedLength(): number { - try { - const heapCoder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output); - if (heapCoder instanceof VecCoder) { - return heapCoder.coder.encodedLength; - } - if (heapCoder instanceof ByteCoder) { - return ByteCoder.memorySize; - } - - return heapCoder.encodedLength; - } catch (e) { - return 0; - } - } - - encodeArguments(values: InputValue[], offset = 0): Uint8Array { + encodeArguments(values: InputValue[]): Uint8Array { FunctionFragment.verifyArgsAndInputsAlign(values, this.jsonFn.inputs, this.jsonAbi); const shallowCopyValues = values.slice(); @@ -121,16 +78,11 @@ export class FunctionFragment< const coders = nonEmptyInputs.map((t) => AbiCoder.getCoder(this.jsonAbi, t, { - isRightPadded: nonEmptyInputs.length > 1, encoding: this.encoding, }) ); - if (this.encoding === ENCODING_V1) { - return new TupleCoderV1(coders).encode(shallowCopyValues); - } - const results: Uint8ArrayWithDynamicData = new TupleCoder(coders).encode(shallowCopyValues); - return unpackDynamicData(results, offset, results.byteLength); + return new TupleCoder(coders).encode(shallowCopyValues); } private static verifyArgsAndInputsAlign( diff --git a/packages/abi-coder/src/Interface.ts b/packages/abi-coder/src/Interface.ts index 69725f7aa0e..96fc8157e3d 100644 --- a/packages/abi-coder/src/Interface.ts +++ b/packages/abi-coder/src/Interface.ts @@ -7,7 +7,7 @@ import { AbiCoder } from './AbiCoder'; import { FunctionFragment } from './FunctionFragment'; import type { InputValue } from './encoding/coders/AbstractCoder'; import type { JsonAbi, JsonAbiConfigurable } from './types/JsonAbi'; -import { ENCODING_V0, type EncodingVersion } from './utils/constants'; +import { type EncodingVersion } from './utils/constants'; import { findTypeById, getEncodingVersion } from './utils/json-abi'; export class Interface { @@ -58,13 +58,12 @@ export class Interface { encodeFunctionData( functionFragment: FunctionFragment | string, - values: Array, - offset = 0 + values: Array ): Uint8Array { const fragment = typeof functionFragment === 'string' ? this.getFunction(functionFragment) : functionFragment; - return fragment.encodeArguments(values, offset); + return fragment.encodeArguments(values); } // Decode the result of a function call @@ -99,9 +98,7 @@ export class Interface { } return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, { - isRightPadded: true, - // TODO: Review support for configurables in v1 encoding when it becomes available - encoding: ENCODING_V0, + encoding: this.encoding, }); } diff --git a/packages/abi-coder/src/encoding/coders/AbstractCoder.ts b/packages/abi-coder/src/encoding/coders/AbstractCoder.ts index 105ef4e9602..8088d782224 100644 --- a/packages/abi-coder/src/encoding/coders/AbstractCoder.ts +++ b/packages/abi-coder/src/encoding/coders/AbstractCoder.ts @@ -1,7 +1,7 @@ import type { BytesLike } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; -import type { Option } from './v0/OptionCoder'; +import type { Option } from './OptionCoder'; type Primitive = string | number | boolean; diff --git a/packages/abi-coder/src/encoding/coders/v0/ArrayCoder.test.ts b/packages/abi-coder/src/encoding/coders/ArrayCoder.test.ts similarity index 83% rename from packages/abi-coder/src/encoding/coders/v0/ArrayCoder.test.ts rename to packages/abi-coder/src/encoding/coders/ArrayCoder.test.ts index daadfa6ffa1..c667e3d2b8e 100644 --- a/packages/abi-coder/src/encoding/coders/v0/ArrayCoder.test.ts +++ b/packages/abi-coder/src/encoding/coders/ArrayCoder.test.ts @@ -1,8 +1,7 @@ import { FuelError, ErrorCode } from '@fuel-ts/errors'; import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; -import { U32_MAX, U8_MAX } from '../../../../test/utils/constants'; -import type { EncodingOptions } from '../../../types/EncodingOptions'; +import { U32_MAX, U8_MAX } from '../../../test/utils/constants'; import { ArrayCoder } from './ArrayCoder'; import { BooleanCoder } from './BooleanCoder'; @@ -13,12 +12,8 @@ import { NumberCoder } from './NumberCoder'; * @group node */ describe('ArrayCoder', () => { - const options: EncodingOptions = { - isSmallBytes: true, - }; - it('should encode a number array with zero inputs', () => { - const coder = new ArrayCoder(new NumberCoder('u8', options), 0); + const coder = new ArrayCoder(new NumberCoder('u8'), 0); const expected = new Uint8Array([]); const actual = coder.encode([]); @@ -26,7 +21,7 @@ describe('ArrayCoder', () => { }); it('should decode a number array with zero inputs', () => { - const coder = new ArrayCoder(new NumberCoder('u8', options), 0); + const coder = new ArrayCoder(new NumberCoder('u8'), 0); const expectedValue: number[] = []; const expectedLength = 0; const [actualValue, actualLength] = coder.decode(new Uint8Array([]), 0); @@ -36,7 +31,7 @@ describe('ArrayCoder', () => { }); it('should encode a number array with four inputs', () => { - const coder = new ArrayCoder(new NumberCoder('u8', options), 4); + const coder = new ArrayCoder(new NumberCoder('u8'), 4); const array = [0, 13, 37, U8_MAX]; const expected = new Uint8Array(array); const actual = coder.encode(array); @@ -44,7 +39,7 @@ describe('ArrayCoder', () => { }); it('should decode a number array with four inputs', () => { - const coder = new ArrayCoder(new NumberCoder('u8', options), 4); + const coder = new ArrayCoder(new NumberCoder('u8'), 4); const expectedValue = [0, 13, 37, U8_MAX]; const expectedLength = expectedValue.length; const [actualValue, actualLength] = coder.decode(new Uint8Array(expectedValue), 0); @@ -56,8 +51,8 @@ describe('ArrayCoder', () => { it('should encode an enum array with differently typed inputs', () => { const coder = new ArrayCoder( new EnumCoder('TestEnum', { - a: new NumberCoder('u8', options), - b: new BooleanCoder(options), + a: new NumberCoder('u8'), + b: new BooleanCoder(), }), 4 ); @@ -73,8 +68,8 @@ describe('ArrayCoder', () => { it('should decode an enum array with differently typed inputs', () => { const coder = new ArrayCoder( new EnumCoder('TestEnum', { - a: new NumberCoder('u8', options), - b: new BooleanCoder(options), + a: new NumberCoder('u8'), + b: new BooleanCoder(), }), 4 ); @@ -93,7 +88,7 @@ describe('ArrayCoder', () => { }); it('should throw when value to encode is not array', async () => { - const coder = new ArrayCoder(new NumberCoder('u8', options), 1); + const coder = new ArrayCoder(new NumberCoder('u8'), 1); const nonArrayInput = { ...[1] }; await expectToThrowFuelError( () => coder.encode(nonArrayInput), @@ -102,7 +97,7 @@ describe('ArrayCoder', () => { }); it('should throw when coder length is not match inputted array length', async () => { - const coder = new ArrayCoder(new NumberCoder('u8', options), 1); + const coder = new ArrayCoder(new NumberCoder('u8'), 1); await expectToThrowFuelError( () => coder.encode([1, 2]), new FuelError(ErrorCode.ENCODE_ERROR, 'Types/values length mismatch.') diff --git a/packages/abi-coder/src/encoding/coders/v0/ArrayCoder.ts b/packages/abi-coder/src/encoding/coders/ArrayCoder.ts similarity index 82% rename from packages/abi-coder/src/encoding/coders/v0/ArrayCoder.ts rename to packages/abi-coder/src/encoding/coders/ArrayCoder.ts index fe73ac678f6..4927701f920 100644 --- a/packages/abi-coder/src/encoding/coders/v0/ArrayCoder.ts +++ b/packages/abi-coder/src/encoding/coders/ArrayCoder.ts @@ -1,9 +1,10 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; +import { concat } from '@fuel-ts/utils'; -import { MAX_BYTES } from '../../../utils/constants'; -import { concatWithDynamicData } from '../../../utils/utilities'; -import type { TypesOfCoder } from '../AbstractCoder'; -import { Coder } from '../AbstractCoder'; +import { MAX_BYTES } from '../../utils/constants'; + +import type { TypesOfCoder } from './AbstractCoder'; +import { Coder } from './AbstractCoder'; type InputValueOf = Array['Input']>; type DecodedValueOf = Array['Decoded']>; @@ -30,7 +31,7 @@ export class ArrayCoder extends Coder< throw new FuelError(ErrorCode.ENCODE_ERROR, `Types/values length mismatch.`); } - return concatWithDynamicData(Array.from(value).map((v) => this.coder.encode(v))); + return concat(Array.from(value).map((v) => this.coder.encode(v))); } decode(data: Uint8Array, offset: number): [DecodedValueOf, number] { diff --git a/packages/abi-coder/src/encoding/coders/v0/B256Coder.test.ts b/packages/abi-coder/src/encoding/coders/B256Coder.test.ts similarity index 100% rename from packages/abi-coder/src/encoding/coders/v0/B256Coder.test.ts rename to packages/abi-coder/src/encoding/coders/B256Coder.test.ts diff --git a/packages/abi-coder/src/encoding/coders/v0/B256Coder.ts b/packages/abi-coder/src/encoding/coders/B256Coder.ts similarity index 92% rename from packages/abi-coder/src/encoding/coders/v0/B256Coder.ts rename to packages/abi-coder/src/encoding/coders/B256Coder.ts index b2a6b6c5721..46e12f8a274 100644 --- a/packages/abi-coder/src/encoding/coders/v0/B256Coder.ts +++ b/packages/abi-coder/src/encoding/coders/B256Coder.ts @@ -2,8 +2,9 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { bn, toHex } from '@fuel-ts/math'; import { arrayify } from '@fuel-ts/utils'; -import { WORD_SIZE } from '../../../utils/constants'; -import { Coder } from '../AbstractCoder'; +import { WORD_SIZE } from '../../utils/constants'; + +import { Coder } from './AbstractCoder'; export class B256Coder extends Coder { constructor() { diff --git a/packages/abi-coder/src/encoding/coders/v0/B512Coder.test.ts b/packages/abi-coder/src/encoding/coders/B512Coder.test.ts similarity index 100% rename from packages/abi-coder/src/encoding/coders/v0/B512Coder.test.ts rename to packages/abi-coder/src/encoding/coders/B512Coder.test.ts diff --git a/packages/abi-coder/src/encoding/coders/v0/B512Coder.ts b/packages/abi-coder/src/encoding/coders/B512Coder.ts similarity index 92% rename from packages/abi-coder/src/encoding/coders/v0/B512Coder.ts rename to packages/abi-coder/src/encoding/coders/B512Coder.ts index 8395be2b7ff..65c576d2508 100644 --- a/packages/abi-coder/src/encoding/coders/v0/B512Coder.ts +++ b/packages/abi-coder/src/encoding/coders/B512Coder.ts @@ -2,8 +2,9 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { bn, toHex } from '@fuel-ts/math'; import { arrayify } from '@fuel-ts/utils'; -import { WORD_SIZE } from '../../../utils/constants'; -import { Coder } from '../AbstractCoder'; +import { WORD_SIZE } from '../../utils/constants'; + +import { Coder } from './AbstractCoder'; export class B512Coder extends Coder { constructor() { diff --git a/packages/abi-coder/src/encoding/coders/v0/BigNumberCoder.test.ts b/packages/abi-coder/src/encoding/coders/BigNumberCoder.test.ts similarity index 99% rename from packages/abi-coder/src/encoding/coders/v0/BigNumberCoder.test.ts rename to packages/abi-coder/src/encoding/coders/BigNumberCoder.test.ts index 97e517cb5be..2cd1632c752 100644 --- a/packages/abi-coder/src/encoding/coders/v0/BigNumberCoder.test.ts +++ b/packages/abi-coder/src/encoding/coders/BigNumberCoder.test.ts @@ -2,7 +2,7 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; import { BN, bn } from '@fuel-ts/math'; -import { U16_MAX, U256_MAX, U32_MAX, U64_MAX, U8_MAX } from '../../../../test/utils/constants'; +import { U16_MAX, U256_MAX, U32_MAX, U64_MAX, U8_MAX } from '../../../test/utils/constants'; import { BigNumberCoder } from './BigNumberCoder'; diff --git a/packages/abi-coder/src/encoding/coders/v0/BigNumberCoder.ts b/packages/abi-coder/src/encoding/coders/BigNumberCoder.ts similarity index 92% rename from packages/abi-coder/src/encoding/coders/v0/BigNumberCoder.ts rename to packages/abi-coder/src/encoding/coders/BigNumberCoder.ts index 338ec8b29e5..08e8c58eb5c 100644 --- a/packages/abi-coder/src/encoding/coders/v0/BigNumberCoder.ts +++ b/packages/abi-coder/src/encoding/coders/BigNumberCoder.ts @@ -1,8 +1,9 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { type BNInput, type BN, toBytes, bn } from '@fuel-ts/math'; -import { WORD_SIZE } from '../../../utils/constants'; -import { Coder } from '../AbstractCoder'; +import { WORD_SIZE } from '../../utils/constants'; + +import { Coder } from './AbstractCoder'; type BigNumberCoderType = 'u64' | 'u256'; diff --git a/packages/abi-coder/src/encoding/coders/v1/BooleanCoder.test.ts b/packages/abi-coder/src/encoding/coders/BooleanCoder.test.ts similarity index 62% rename from packages/abi-coder/src/encoding/coders/v1/BooleanCoder.test.ts rename to packages/abi-coder/src/encoding/coders/BooleanCoder.test.ts index b33931bbdc4..ab4dced2e0f 100644 --- a/packages/abi-coder/src/encoding/coders/v1/BooleanCoder.test.ts +++ b/packages/abi-coder/src/encoding/coders/BooleanCoder.test.ts @@ -1,5 +1,8 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; +import { concat } from '@fuel-ts/utils'; + +import { WORD_SIZE } from '../../utils/constants'; import { BooleanCoder } from './BooleanCoder'; @@ -13,6 +16,7 @@ describe('BooleanCoder', () => { const FALSE_ENCODED = new Uint8Array([0]); const coder = new BooleanCoder(); + const paddedCoder = new BooleanCoder({ padToWordSize: true }); it('encodes a true boolean', () => { const expected = TRUE_ENCODED; @@ -46,6 +50,46 @@ describe('BooleanCoder', () => { expect(actualLength).toBe(expectedLength); }); + it('encodes a true boolean [padded]', () => { + const expected = concat([new Uint8Array(7), TRUE_ENCODED]); + const actual = paddedCoder.encode(TRUE_DECODED); + + expect(actual).toStrictEqual(expected); + }); + + it('encodes a false boolean [padded]', () => { + const expected = concat([new Uint8Array(7), FALSE_ENCODED]); + const actual = paddedCoder.encode(FALSE_DECODED); + + expect(actual).toStrictEqual(expected); + }); + + it('decodes a true boolean [padded]', () => { + const expectedValue = TRUE_DECODED; + const expectedLength = WORD_SIZE; + + const [actualValue, actualLength] = paddedCoder.decode( + concat([new Uint8Array(7), TRUE_ENCODED]), + 0 + ); + + expect(actualValue).toStrictEqual(expectedValue); + expect(actualLength).toBe(expectedLength); + }); + + it('decodes a false boolean [padded]', () => { + const expectedValue = FALSE_DECODED; + const expectedLength = WORD_SIZE; + + const [actualValue, actualLength] = paddedCoder.decode( + concat([new Uint8Array(7), FALSE_ENCODED]), + 0 + ); + + expect(actualValue).toStrictEqual(expectedValue); + expect(actualLength).toBe(expectedLength); + }); + it.each([undefined, null, 0, {}, [], '', 'a', Symbol('asd')])( 'should throw an error when encoding an invalid boolean value', (val) => { diff --git a/packages/abi-coder/src/encoding/coders/v1/BooleanCoder.ts b/packages/abi-coder/src/encoding/coders/BooleanCoder.ts similarity index 69% rename from packages/abi-coder/src/encoding/coders/v1/BooleanCoder.ts rename to packages/abi-coder/src/encoding/coders/BooleanCoder.ts index 350b945b98d..6b8bf0348bc 100644 --- a/packages/abi-coder/src/encoding/coders/v1/BooleanCoder.ts +++ b/packages/abi-coder/src/encoding/coders/BooleanCoder.ts @@ -1,11 +1,23 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { bn, toBytes } from '@fuel-ts/math'; -import { Coder } from '../AbstractCoder'; +import type { EncodingOptions } from '../../types/EncodingOptions'; +import { WORD_SIZE } from '../../utils/constants'; + +import { Coder } from './AbstractCoder'; export class BooleanCoder extends Coder { - constructor() { - super('boolean', 'boolean', 1); + options: EncodingOptions; + + constructor( + options: EncodingOptions = { + padToWordSize: false, + } + ) { + const encodedLength = options.padToWordSize ? WORD_SIZE : 1; + super('boolean', 'boolean', encodedLength); + + this.options = options; } encode(value: boolean): Uint8Array { diff --git a/packages/abi-coder/src/encoding/coders/v1/ByteCoder.test.ts b/packages/abi-coder/src/encoding/coders/ByteCoder.test.ts similarity index 100% rename from packages/abi-coder/src/encoding/coders/v1/ByteCoder.test.ts rename to packages/abi-coder/src/encoding/coders/ByteCoder.test.ts diff --git a/packages/abi-coder/src/encoding/coders/v1/ByteCoder.ts b/packages/abi-coder/src/encoding/coders/ByteCoder.ts similarity index 88% rename from packages/abi-coder/src/encoding/coders/v1/ByteCoder.ts rename to packages/abi-coder/src/encoding/coders/ByteCoder.ts index 285ec8dd986..a2504d48d68 100644 --- a/packages/abi-coder/src/encoding/coders/v1/ByteCoder.ts +++ b/packages/abi-coder/src/encoding/coders/ByteCoder.ts @@ -1,9 +1,10 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { bn } from '@fuel-ts/math'; -import { WORD_SIZE } from '../../../utils/constants'; -import { Coder } from '../AbstractCoder'; -import { BigNumberCoder } from '../v0/BigNumberCoder'; +import { WORD_SIZE } from '../../utils/constants'; + +import { Coder } from './AbstractCoder'; +import { BigNumberCoder } from './BigNumberCoder'; export class ByteCoder extends Coder { static memorySize = 1; diff --git a/packages/abi-coder/src/encoding/coders/v1/EnumCoder.test.ts b/packages/abi-coder/src/encoding/coders/EnumCoder.test.ts similarity index 95% rename from packages/abi-coder/src/encoding/coders/v1/EnumCoder.test.ts rename to packages/abi-coder/src/encoding/coders/EnumCoder.test.ts index fbdabfb1f12..47d154de434 100644 --- a/packages/abi-coder/src/encoding/coders/v1/EnumCoder.test.ts +++ b/packages/abi-coder/src/encoding/coders/EnumCoder.test.ts @@ -2,9 +2,9 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; import { bn } from '@fuel-ts/math'; -import { U64_MAX } from '../../../../test/utils/constants'; -import { BigNumberCoder } from '../v0/BigNumberCoder'; +import { U64_MAX } from '../../../test/utils/constants'; +import { BigNumberCoder } from './BigNumberCoder'; import { BooleanCoder } from './BooleanCoder'; import { EnumCoder } from './EnumCoder'; diff --git a/packages/abi-coder/src/encoding/coders/v1/EnumCoder.ts b/packages/abi-coder/src/encoding/coders/EnumCoder.ts similarity index 94% rename from packages/abi-coder/src/encoding/coders/v1/EnumCoder.ts rename to packages/abi-coder/src/encoding/coders/EnumCoder.ts index 680bc1e01e6..159e19d3411 100644 --- a/packages/abi-coder/src/encoding/coders/v1/EnumCoder.ts +++ b/packages/abi-coder/src/encoding/coders/EnumCoder.ts @@ -3,10 +3,11 @@ import { toNumber } from '@fuel-ts/math'; import { concat } from '@fuel-ts/utils'; import type { RequireExactlyOne } from 'type-fest'; -import { WORD_SIZE } from '../../../utils/constants'; -import type { TypesOfCoder } from '../AbstractCoder'; -import { Coder } from '../AbstractCoder'; -import { BigNumberCoder } from '../v0/BigNumberCoder'; +import { WORD_SIZE } from '../../utils/constants'; + +import type { TypesOfCoder } from './AbstractCoder'; +import { Coder } from './AbstractCoder'; +import { BigNumberCoder } from './BigNumberCoder'; export type InputValueOf> = RequireExactlyOne<{ [P in keyof TCoders]: TypesOfCoder['Input']; diff --git a/packages/abi-coder/src/encoding/coders/v1/NumberCoder.test.ts b/packages/abi-coder/src/encoding/coders/NumberCoder.test.ts similarity index 70% rename from packages/abi-coder/src/encoding/coders/v1/NumberCoder.test.ts rename to packages/abi-coder/src/encoding/coders/NumberCoder.test.ts index 90cd807b221..836297e38be 100644 --- a/packages/abi-coder/src/encoding/coders/v1/NumberCoder.test.ts +++ b/packages/abi-coder/src/encoding/coders/NumberCoder.test.ts @@ -1,7 +1,7 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; -import { U8_MAX, U16_MAX, U32_MAX } from '../../../../test/utils/constants'; +import { U8_MAX, U16_MAX, U32_MAX } from '../../../test/utils/constants'; import { NumberCoder } from './NumberCoder'; @@ -166,4 +166,70 @@ describe('NumberCoder', () => { new FuelError(ErrorCode.TYPE_NOT_SUPPORTED, `Invalid number type: ${invalidNumber}`) ); }); + + it('encodes a u8 number [padded]', () => { + const coder = new NumberCoder('u8', { padToWordSize: true }); + const expected = new Uint8Array([0, 0, 0, 0, 0, 0, 0, U8_MAX]); + const actual = coder.encode(U8_MAX); + + expect(actual).toStrictEqual(expected); + }); + + it('decodes a u8 number [padded]', () => { + const coder = new NumberCoder('u8', { padToWordSize: true }); + const expectedValue = U8_MAX; + const expectedLength = 8; + + const [actualValue, actualLength] = coder.decode( + new Uint8Array([0, 0, 0, 0, 0, 0, 0, U8_MAX]), + 0 + ); + + expect(actualValue).toStrictEqual(expectedValue); + expect(actualLength).toBe(expectedLength); + }); + + it('encodes a u16 number [padded]', () => { + const coder = new NumberCoder('u16', { padToWordSize: true }); + const expected = new Uint8Array([0, 0, 0, 0, 0, 0, U8_MAX, U8_MAX]); + const actual = coder.encode(U16_MAX); + + expect(actual).toStrictEqual(expected); + }); + + it('decodes a u16 number [padded]', () => { + const coder = new NumberCoder('u16', { padToWordSize: true }); + const expectedValue = U16_MAX; + const expectedLength = 8; + + const [actualValue, actualLength] = coder.decode( + new Uint8Array([0, 0, 0, 0, 0, 0, U8_MAX, U8_MAX]), + 0 + ); + + expect(actualValue).toStrictEqual(expectedValue); + expect(actualLength).toBe(expectedLength); + }); + + it('encodes a u32 number [padded]', () => { + const coder = new NumberCoder('u32', { padToWordSize: true }); + const expected = new Uint8Array([0, 0, 0, 0, U8_MAX, U8_MAX, U8_MAX, U8_MAX]); + const actual = coder.encode(U32_MAX); + + expect(actual).toStrictEqual(expected); + }); + + it('decodes a u32 number [padded]', () => { + const coder = new NumberCoder('u32', { padToWordSize: true }); + const expectedValue = U32_MAX; + const expectedLength = 8; + + const [actualValue, actualLength] = coder.decode( + new Uint8Array([0, 0, 0, 0, U8_MAX, U8_MAX, U8_MAX, U8_MAX]), + 0 + ); + + expect(actualValue).toStrictEqual(expectedValue); + expect(actualLength).toBe(expectedLength); + }); }); diff --git a/packages/abi-coder/src/encoding/coders/v1/NumberCoder.ts b/packages/abi-coder/src/encoding/coders/NumberCoder.ts similarity index 66% rename from packages/abi-coder/src/encoding/coders/v1/NumberCoder.ts rename to packages/abi-coder/src/encoding/coders/NumberCoder.ts index 43f2e6c19dd..df890204359 100644 --- a/packages/abi-coder/src/encoding/coders/v1/NumberCoder.ts +++ b/packages/abi-coder/src/encoding/coders/NumberCoder.ts @@ -1,7 +1,10 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { toNumber, toBytes } from '@fuel-ts/math'; -import { Coder } from '../AbstractCoder'; +import type { EncodingOptions } from '../../types/EncodingOptions'; +import { WORD_SIZE } from '../../utils/constants'; + +import { Coder } from './AbstractCoder'; type NumberCoderType = 'u8' | 'u16' | 'u32' | 'u64'; @@ -19,14 +22,19 @@ const getLength = (baseType: NumberCoderType): number => { }; export class NumberCoder extends Coder { - length: number; baseType: NumberCoderType; + options: EncodingOptions; - constructor(baseType: NumberCoderType) { - const length = getLength(baseType); + constructor( + baseType: NumberCoderType, + options: EncodingOptions = { + padToWordSize: false, + } + ) { + const length = options.padToWordSize ? WORD_SIZE : getLength(baseType); super('number', baseType, length); this.baseType = baseType; - this.length = length; + this.options = options; } encode(value: number | string): Uint8Array { @@ -38,11 +46,11 @@ export class NumberCoder extends Coder { throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}.`); } - if (bytes.length > this.length) { + if (bytes.length > this.encodedLength) { throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}, too many bytes.`); } - return toBytes(bytes, this.length); + return toBytes(bytes, this.encodedLength); } decode(data: Uint8Array, offset: number): [number, number] { @@ -50,12 +58,12 @@ export class NumberCoder extends Coder { throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number data size.`); } - const bytes = data.slice(offset, offset + this.length); + const bytes = data.slice(offset, offset + this.encodedLength); if (bytes.length !== this.encodedLength) { throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number byte data size.`); } - return [toNumber(bytes), offset + this.length]; + return [toNumber(bytes), offset + this.encodedLength]; } } diff --git a/packages/abi-coder/src/encoding/coders/v1/OptionCoder.ts b/packages/abi-coder/src/encoding/coders/OptionCoder.ts similarity index 95% rename from packages/abi-coder/src/encoding/coders/v1/OptionCoder.ts rename to packages/abi-coder/src/encoding/coders/OptionCoder.ts index 45f16d8035c..e706bdd1dc7 100644 --- a/packages/abi-coder/src/encoding/coders/v1/OptionCoder.ts +++ b/packages/abi-coder/src/encoding/coders/OptionCoder.ts @@ -1,5 +1,4 @@ -import type { Coder } from '../AbstractCoder'; - +import type { Coder } from './AbstractCoder'; import type { InputValueOf, DecodedValueOf } from './EnumCoder'; import { EnumCoder } from './EnumCoder'; diff --git a/packages/abi-coder/src/encoding/coders/v1/RawSliceCoder.test.ts b/packages/abi-coder/src/encoding/coders/RawSliceCoder.test.ts similarity index 100% rename from packages/abi-coder/src/encoding/coders/v1/RawSliceCoder.test.ts rename to packages/abi-coder/src/encoding/coders/RawSliceCoder.test.ts diff --git a/packages/abi-coder/src/encoding/coders/v1/RawSliceCoder.ts b/packages/abi-coder/src/encoding/coders/RawSliceCoder.ts similarity index 88% rename from packages/abi-coder/src/encoding/coders/v1/RawSliceCoder.ts rename to packages/abi-coder/src/encoding/coders/RawSliceCoder.ts index 58105a51e45..7c7882f8208 100644 --- a/packages/abi-coder/src/encoding/coders/v1/RawSliceCoder.ts +++ b/packages/abi-coder/src/encoding/coders/RawSliceCoder.ts @@ -1,11 +1,11 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { bn } from '@fuel-ts/math'; -import { WORD_SIZE } from '../../../utils/constants'; -import { Coder } from '../AbstractCoder'; -import { ArrayCoder } from '../v0/ArrayCoder'; -import { BigNumberCoder } from '../v0/BigNumberCoder'; +import { WORD_SIZE } from '../../utils/constants'; +import { Coder } from './AbstractCoder'; +import { ArrayCoder } from './ArrayCoder'; +import { BigNumberCoder } from './BigNumberCoder'; import { NumberCoder } from './NumberCoder'; export class RawSliceCoder extends Coder { diff --git a/packages/abi-coder/src/encoding/coders/v1/StdStringCoder.test.ts b/packages/abi-coder/src/encoding/coders/StdStringCoder.test.ts similarity index 100% rename from packages/abi-coder/src/encoding/coders/v1/StdStringCoder.test.ts rename to packages/abi-coder/src/encoding/coders/StdStringCoder.test.ts diff --git a/packages/abi-coder/src/encoding/coders/v1/StdStringCoder.ts b/packages/abi-coder/src/encoding/coders/StdStringCoder.ts similarity index 88% rename from packages/abi-coder/src/encoding/coders/v1/StdStringCoder.ts rename to packages/abi-coder/src/encoding/coders/StdStringCoder.ts index aecbe013ce8..f98fc5318b9 100644 --- a/packages/abi-coder/src/encoding/coders/v1/StdStringCoder.ts +++ b/packages/abi-coder/src/encoding/coders/StdStringCoder.ts @@ -2,9 +2,10 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { bn } from '@fuel-ts/math'; import { toUtf8Bytes, toUtf8String } from '@fuel-ts/utils'; -import { WORD_SIZE } from '../../../utils/constants'; -import { Coder } from '../AbstractCoder'; -import { BigNumberCoder } from '../v0/BigNumberCoder'; +import { WORD_SIZE } from '../../utils/constants'; + +import { Coder } from './AbstractCoder'; +import { BigNumberCoder } from './BigNumberCoder'; export class StdStringCoder extends Coder { static memorySize = 1; diff --git a/packages/abi-coder/src/encoding/coders/v1/StrSliceCoder.test.ts b/packages/abi-coder/src/encoding/coders/StrSliceCoder.test.ts similarity index 100% rename from packages/abi-coder/src/encoding/coders/v1/StrSliceCoder.test.ts rename to packages/abi-coder/src/encoding/coders/StrSliceCoder.test.ts diff --git a/packages/abi-coder/src/encoding/coders/v1/StrSliceCoder.ts b/packages/abi-coder/src/encoding/coders/StrSliceCoder.ts similarity index 88% rename from packages/abi-coder/src/encoding/coders/v1/StrSliceCoder.ts rename to packages/abi-coder/src/encoding/coders/StrSliceCoder.ts index ba84b30f88c..cbc00de9b14 100644 --- a/packages/abi-coder/src/encoding/coders/v1/StrSliceCoder.ts +++ b/packages/abi-coder/src/encoding/coders/StrSliceCoder.ts @@ -2,9 +2,10 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { bn } from '@fuel-ts/math'; import { toUtf8Bytes, toUtf8String } from '@fuel-ts/utils'; -import { WORD_SIZE } from '../../../utils/constants'; -import { Coder } from '../AbstractCoder'; -import { BigNumberCoder } from '../v0/BigNumberCoder'; +import { WORD_SIZE } from '../../utils/constants'; + +import { Coder } from './AbstractCoder'; +import { BigNumberCoder } from './BigNumberCoder'; export class StrSliceCoder extends Coder { static memorySize = 1; diff --git a/packages/abi-coder/src/encoding/coders/v1/StringCoder.test.ts b/packages/abi-coder/src/encoding/coders/StringCoder.test.ts similarity index 100% rename from packages/abi-coder/src/encoding/coders/v1/StringCoder.test.ts rename to packages/abi-coder/src/encoding/coders/StringCoder.test.ts diff --git a/packages/abi-coder/src/encoding/coders/v1/StringCoder.ts b/packages/abi-coder/src/encoding/coders/StringCoder.ts similarity index 95% rename from packages/abi-coder/src/encoding/coders/v1/StringCoder.ts rename to packages/abi-coder/src/encoding/coders/StringCoder.ts index 67516ae384e..eca5956ae3b 100644 --- a/packages/abi-coder/src/encoding/coders/v1/StringCoder.ts +++ b/packages/abi-coder/src/encoding/coders/StringCoder.ts @@ -1,7 +1,7 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { toUtf8Bytes, toUtf8String } from '@fuel-ts/utils'; -import { Coder } from '../AbstractCoder'; +import { Coder } from './AbstractCoder'; export class StringCoder extends Coder { constructor(length: TLength) { diff --git a/packages/abi-coder/src/encoding/coders/v1/StructCoder.test.ts b/packages/abi-coder/src/encoding/coders/StructCoder.test.ts similarity index 93% rename from packages/abi-coder/src/encoding/coders/v1/StructCoder.test.ts rename to packages/abi-coder/src/encoding/coders/StructCoder.test.ts index e1b7f446520..f9622725345 100644 --- a/packages/abi-coder/src/encoding/coders/v1/StructCoder.test.ts +++ b/packages/abi-coder/src/encoding/coders/StructCoder.test.ts @@ -2,9 +2,9 @@ import { FuelError, ErrorCode } from '@fuel-ts/errors'; import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; import { bn } from '@fuel-ts/math'; -import { U32_MAX } from '../../../../test/utils/constants'; -import { BigNumberCoder } from '../v0/BigNumberCoder'; +import { U32_MAX } from '../../../test/utils/constants'; +import { BigNumberCoder } from './BigNumberCoder'; import { BooleanCoder } from './BooleanCoder'; import { StructCoder } from './StructCoder'; diff --git a/packages/abi-coder/src/encoding/coders/v1/StructCoder.ts b/packages/abi-coder/src/encoding/coders/StructCoder.ts similarity index 95% rename from packages/abi-coder/src/encoding/coders/v1/StructCoder.ts rename to packages/abi-coder/src/encoding/coders/StructCoder.ts index 55f96895b28..54bea7fa211 100644 --- a/packages/abi-coder/src/encoding/coders/v1/StructCoder.ts +++ b/packages/abi-coder/src/encoding/coders/StructCoder.ts @@ -1,9 +1,8 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { concatBytes } from '@fuel-ts/utils'; -import type { TypesOfCoder } from '../AbstractCoder'; -import { Coder } from '../AbstractCoder'; - +import type { TypesOfCoder } from './AbstractCoder'; +import { Coder } from './AbstractCoder'; import { OptionCoder } from './OptionCoder'; type InputValueOf> = { diff --git a/packages/abi-coder/src/encoding/coders/v1/TupleCoder.test.ts b/packages/abi-coder/src/encoding/coders/TupleCoder.test.ts similarity index 94% rename from packages/abi-coder/src/encoding/coders/v1/TupleCoder.test.ts rename to packages/abi-coder/src/encoding/coders/TupleCoder.test.ts index 8afcbc90e9f..ffe1828d9c7 100644 --- a/packages/abi-coder/src/encoding/coders/v1/TupleCoder.test.ts +++ b/packages/abi-coder/src/encoding/coders/TupleCoder.test.ts @@ -2,9 +2,9 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; import { bn } from '@fuel-ts/math'; -import { U64_MAX } from '../../../../test/utils/constants'; -import { BigNumberCoder } from '../v0/BigNumberCoder'; +import { U64_MAX } from '../../../test/utils/constants'; +import { BigNumberCoder } from './BigNumberCoder'; import { BooleanCoder } from './BooleanCoder'; import { TupleCoder } from './TupleCoder'; diff --git a/packages/abi-coder/src/encoding/coders/v1/TupleCoder.ts b/packages/abi-coder/src/encoding/coders/TupleCoder.ts similarity index 93% rename from packages/abi-coder/src/encoding/coders/v1/TupleCoder.ts rename to packages/abi-coder/src/encoding/coders/TupleCoder.ts index 1b787505a77..39186a0f945 100644 --- a/packages/abi-coder/src/encoding/coders/v1/TupleCoder.ts +++ b/packages/abi-coder/src/encoding/coders/TupleCoder.ts @@ -1,8 +1,8 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { concatBytes } from '@fuel-ts/utils'; -import type { TypesOfCoder } from '../AbstractCoder'; -import { Coder } from '../AbstractCoder'; +import type { TypesOfCoder } from './AbstractCoder'; +import { Coder } from './AbstractCoder'; type InputValueOf = { [P in keyof TCoders]: TypesOfCoder['Input']; diff --git a/packages/abi-coder/src/encoding/coders/v1/VecCoder.test.ts b/packages/abi-coder/src/encoding/coders/VecCoder.test.ts similarity index 97% rename from packages/abi-coder/src/encoding/coders/v1/VecCoder.test.ts rename to packages/abi-coder/src/encoding/coders/VecCoder.test.ts index 15a331549a9..3adb4a7b0ce 100644 --- a/packages/abi-coder/src/encoding/coders/v1/VecCoder.test.ts +++ b/packages/abi-coder/src/encoding/coders/VecCoder.test.ts @@ -2,7 +2,7 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; import { arrayify } from '@fuel-ts/utils'; -import { U32_MAX } from '../../../../test/utils/constants'; +import { U32_MAX } from '../../../test/utils/constants'; import { BooleanCoder } from './BooleanCoder'; import { NumberCoder } from './NumberCoder'; diff --git a/packages/abi-coder/src/encoding/coders/v1/VecCoder.ts b/packages/abi-coder/src/encoding/coders/VecCoder.ts similarity index 89% rename from packages/abi-coder/src/encoding/coders/v1/VecCoder.ts rename to packages/abi-coder/src/encoding/coders/VecCoder.ts index 9582318377f..f09cc313c88 100644 --- a/packages/abi-coder/src/encoding/coders/v1/VecCoder.ts +++ b/packages/abi-coder/src/encoding/coders/VecCoder.ts @@ -2,12 +2,12 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { bn } from '@fuel-ts/math'; import { concatBytes } from '@fuel-ts/utils'; -import { MAX_BYTES, WORD_SIZE } from '../../../utils/constants'; -import { isUint8Array } from '../../../utils/utilities'; -import type { TypesOfCoder } from '../AbstractCoder'; -import { Coder } from '../AbstractCoder'; -import { BigNumberCoder } from '../v0/BigNumberCoder'; +import { MAX_BYTES, WORD_SIZE } from '../../utils/constants'; +import { isUint8Array } from '../../utils/utilities'; +import { Coder } from './AbstractCoder'; +import type { TypesOfCoder } from './AbstractCoder'; +import { BigNumberCoder } from './BigNumberCoder'; import { OptionCoder } from './OptionCoder'; type InputValueOf = Array['Input']> | Uint8Array; diff --git a/packages/abi-coder/src/encoding/coders/index.ts b/packages/abi-coder/src/encoding/coders/index.ts new file mode 100644 index 00000000000..b7a96853de1 --- /dev/null +++ b/packages/abi-coder/src/encoding/coders/index.ts @@ -0,0 +1,16 @@ +export { ArrayCoder } from './ArrayCoder'; +export { B256Coder } from './B256Coder'; +export { B512Coder } from './B512Coder'; +export { BigNumberCoder } from './BigNumberCoder'; +export { BooleanCoder } from './BooleanCoder'; +export { ByteCoder } from './ByteCoder'; +export { EnumCoder } from './EnumCoder'; +export { NumberCoder } from './NumberCoder'; +export { OptionCoder } from './OptionCoder'; +export { RawSliceCoder } from './RawSliceCoder'; +export { StdStringCoder } from './StdStringCoder'; +export { StrSliceCoder } from './StrSliceCoder'; +export { StringCoder } from './StringCoder'; +export { StructCoder } from './StructCoder'; +export { TupleCoder } from './TupleCoder'; +export { VecCoder } from './VecCoder'; diff --git a/packages/abi-coder/src/encoding/coders/v0/BooleanCoder.test.ts b/packages/abi-coder/src/encoding/coders/v0/BooleanCoder.test.ts deleted file mode 100644 index d8bea77fd47..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/BooleanCoder.test.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; - -import { BooleanCoder } from './BooleanCoder'; - -/** - * @group node - */ -describe('BooleanCoder', () => { - const TRUE_DECODED = true; - const TRUE_ENCODED = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1]); - const FALSE_DECODED = false; - const FALSE_ENCODED = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]); - - const coder = new BooleanCoder(); - - it('should encode a true boolean', () => { - const expected = TRUE_ENCODED; - const actual = coder.encode(TRUE_DECODED); - - expect(actual).toStrictEqual(expected); - }); - - it('should encode a false boolean', () => { - const expected = FALSE_ENCODED; - const actual = coder.encode(FALSE_DECODED); - - expect(actual).toStrictEqual(expected); - }); - - it('should decode a true boolean', () => { - const expectedValue = TRUE_DECODED; - const expectedLength = TRUE_ENCODED.length; - const [actualValue, actualLength] = coder.decode(TRUE_ENCODED, 0); - - expect(actualValue).toStrictEqual(expectedValue); - expect(actualLength).toBe(expectedLength); - }); - - it('should decode a false boolean', () => { - const expectedValue = FALSE_DECODED; - const expectedLength = FALSE_ENCODED.length; - const [actualValue, actualLength] = coder.decode(FALSE_ENCODED, 0); - - expect(actualValue).toStrictEqual(expectedValue); - expect(actualLength).toBe(expectedLength); - }); - - it.each([undefined, null, 0, {}, [], '', 'a', Symbol('asd')])( - 'should throw an error when encoding an invalid boolean value', - (val) => { - expect(() => { - // @ts-expect-error val isn't boolean due to nature of test - coder.encode(val); - }).toThrow('Invalid bool'); - } - ); - it('should throw an error when decoding an invalid boolean value', async () => { - const invalidInput = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 2]); - await expectToThrowFuelError( - () => coder.decode(invalidInput, 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid boolean value.') - ); - }); - - it('throws when decoding empty bytes', async () => { - const input = new Uint8Array(0); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid boolean data size.') - ); - }); -}); diff --git a/packages/abi-coder/src/encoding/coders/v0/BooleanCoder.ts b/packages/abi-coder/src/encoding/coders/v0/BooleanCoder.ts deleted file mode 100644 index 07a69f55575..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/BooleanCoder.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { bn, toBytes } from '@fuel-ts/math'; - -import type { EncodingOptions } from '../../../types/EncodingOptions'; -import { Coder } from '../AbstractCoder'; - -export class BooleanCoder extends Coder { - paddingLength: number; - options: EncodingOptions; - - constructor( - options: EncodingOptions = { - isSmallBytes: false, - isRightPadded: false, - } - ) { - const paddingLength = options.isSmallBytes ? 1 : 8; - - super('boolean', 'boolean', paddingLength); - - this.paddingLength = paddingLength; - this.options = options; - } - - encode(value: boolean): Uint8Array { - const isTrueBool = value === true || value === false; - - if (!isTrueBool) { - throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid boolean value.`); - } - - const output: Uint8Array = toBytes(value ? 1 : 0, this.paddingLength); - - if (this.options.isRightPadded) { - return output.reverse(); - } - - return output; - } - - decode(data: Uint8Array, offset: number): [boolean, number] { - if (data.length < this.paddingLength) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid boolean data size.`); - } - - let bytes; - - if (this.options.isRightPadded) { - bytes = data.slice(offset, offset + 1); - } else { - bytes = data.slice(offset, offset + this.paddingLength); - } - - const decodedValue = bn(bytes); - if (decodedValue.isZero()) { - return [false, offset + this.paddingLength]; - } - - if (!decodedValue.eq(bn(1))) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid boolean value.`); - } - - return [true, offset + this.paddingLength]; - } -} diff --git a/packages/abi-coder/src/encoding/coders/v0/ByteCoder.test.ts b/packages/abi-coder/src/encoding/coders/v0/ByteCoder.test.ts deleted file mode 100644 index d54e552c6b1..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/ByteCoder.test.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { FuelError, ErrorCode } from '@fuel-ts/errors'; -import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; - -import type { Uint8ArrayWithDynamicData } from '../../../utils/utilities'; - -import { ByteCoder } from './ByteCoder'; - -/** - * @group node - * @group browser - */ -describe('ByteCoder', () => { - it('should encode a byte', () => { - const coder = new ByteCoder(); - const expected: Uint8ArrayWithDynamicData = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 3, - ]); - expected.dynamicData = { - 0: new Uint8Array([1, 2, 3, 0, 0, 0, 0, 0]), - }; - - const actual = coder.encode([1, 2, 3]); - - expect(actual).toStrictEqual(expected); - }); - - it('should encode a byte [byte array]', () => { - const coder = new ByteCoder(); - const expected: Uint8ArrayWithDynamicData = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 3, - ]); - expected.dynamicData = { - 0: new Uint8Array([1, 2, 3, 0, 0, 0, 0, 0]), - }; - - const actual = coder.encode(Uint8Array.from([1, 2, 3])); - - expect(actual).toStrictEqual(expected); - }); - - it('should encode a byte [full word]', () => { - const coder = new ByteCoder(); - const expected: Uint8ArrayWithDynamicData = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 8, - ]); - expected.dynamicData = { - 0: new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]), - }; - - const actual = coder.encode([1, 2, 3, 4, 5, 6, 7, 8]); - - expect(actual).toStrictEqual(expected); - }); - - it('should decode a byte', () => { - const coder = new ByteCoder(); - const input = new Uint8Array([ - 0, 0, 0, 0, 3, 255, 255, 225, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 10, 0, 1, 2, 3, 4, - 5, 6, 7, 8, 9, - ]); - const expected = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); - - const [actual, newOffset] = coder.decode(input, 0); - - expect(actual).toEqual(expected); - expect(newOffset).toEqual(24); - }); - - it('should decode a byte [with padding]', () => { - const coder = new ByteCoder(); - const input = new Uint8Array([ - 0, 0, 0, 0, 3, 255, 255, 225, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 11, 0, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, - ]); - const expected = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - - const [actual, newOffset] = coder.decode(input, 0); - - expect(actual).toEqual(expected); - expect(newOffset).toEqual(24); - }); - - it('throws when decoding empty bytes', async () => { - const coder = new ByteCoder(); - const input = new Uint8Array(0); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid byte data size.') - ); - }); - - it('throws when decoding empty byte data', async () => { - const coder = new ByteCoder(); - const input = new Uint8Array([ - 0, 0, 0, 0, 3, 255, 255, 225, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 255, - ]); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid bytes byte data size.') - ); - }); -}); diff --git a/packages/abi-coder/src/encoding/coders/v0/ByteCoder.ts b/packages/abi-coder/src/encoding/coders/v0/ByteCoder.ts deleted file mode 100644 index 444d3877a31..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/ByteCoder.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { bn } from '@fuel-ts/math'; -import { concat } from '@fuel-ts/utils'; - -import { WORD_SIZE } from '../../../utils/constants'; -import type { Uint8ArrayWithDynamicData } from '../../../utils/utilities'; -import { BASE_VECTOR_OFFSET, concatWithDynamicData } from '../../../utils/utilities'; -import { Coder } from '../AbstractCoder'; - -import { BigNumberCoder } from './BigNumberCoder'; - -export class ByteCoder extends Coder { - static memorySize = 1; - constructor() { - super('struct', 'struct Bytes', BASE_VECTOR_OFFSET); - } - - encode(value: number[] | Uint8Array): Uint8Array { - const parts: Uint8Array[] = []; - - // pointer (ptr) - const pointer: Uint8ArrayWithDynamicData = new BigNumberCoder('u64').encode(BASE_VECTOR_OFFSET); - - // pointer dynamicData, encode the byte vector now and attach to its pointer - const data = this.#getPaddedData(value); - pointer.dynamicData = { - 0: concatWithDynamicData([data]), - }; - - parts.push(pointer); - - // capacity (cap) - parts.push(new BigNumberCoder('u64').encode(data.byteLength)); - - // length (len) - parts.push(new BigNumberCoder('u64').encode(value.length)); - - return concatWithDynamicData(parts); - } - - #getPaddedData(value: number[] | Uint8Array): Uint8Array { - const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)]; - - const paddingLength = (WORD_SIZE - (value.length % WORD_SIZE)) % WORD_SIZE; - if (paddingLength) { - data.push(new Uint8Array(paddingLength)); - } - - return concat(data); - } - - decode(data: Uint8Array, offset: number): [Uint8Array, number] { - if (data.length < BASE_VECTOR_OFFSET) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid byte data size.`); - } - - const len = data.slice(16, 24); - const encodedLength = bn(new BigNumberCoder('u64').decode(len, 0)[0]).toNumber(); - const byteData = data.slice(BASE_VECTOR_OFFSET, BASE_VECTOR_OFFSET + encodedLength); - - if (byteData.length !== encodedLength) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid bytes byte data size.`); - } - - return [byteData, offset + BASE_VECTOR_OFFSET]; - } -} diff --git a/packages/abi-coder/src/encoding/coders/v0/EnumCoder.test.ts b/packages/abi-coder/src/encoding/coders/v0/EnumCoder.test.ts deleted file mode 100644 index 9e26b7d48bc..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/EnumCoder.test.ts +++ /dev/null @@ -1,120 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; -import { bn } from '@fuel-ts/math'; - -import { U64_MAX } from '../../../../test/utils/constants'; - -import { BigNumberCoder } from './BigNumberCoder'; -import { BooleanCoder } from './BooleanCoder'; -import { EnumCoder } from './EnumCoder'; - -/** - * @group node - * @group browser - */ -describe('EnumCoder', () => { - const coder = new EnumCoder('TestEnum', { a: new BooleanCoder(), b: new BigNumberCoder('u64') }); - - it('should encode an enum containing a boolean', () => { - const expected = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]); - const actual = coder.encode({ a: true }); - - expect(actual).toStrictEqual(expected); - }); - - it('should decode an enum containing a boolean', () => { - const expectedValue = { a: true }; - const expectedLength = 16; - const [actualValue, actualLength] = coder.decode( - new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), - 0 - ); - - expect(actualValue).toStrictEqual(expectedValue); - expect(actualLength).toBe(expectedLength); - }); - - it('should encode an enum containing a u64', () => { - const expected = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 1, 255, 255, 255, 255, 255, 255, 255, 255, - ]); - const actual = coder.encode({ b: bn(U64_MAX) }); - - expect(actual).toStrictEqual(expected); - }); - - it('should decode an enum containing a u64', () => { - const expectedValue = { b: bn(U64_MAX) }; - const expectedLength = 16; - const [actualValue, actualLength] = coder.decode( - new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 255, 255, 255, 255, 255, 255, 255, 255]), - 0 - ); - - expect(actualValue).toStrictEqual(expectedValue); - expect(actualLength).toBe(expectedLength); - }); - - it('should throw an error when encoding if no enum key is provided', async () => { - await expectToThrowFuelError( - () => coder.encode({} as never), - new FuelError(ErrorCode.DECODE_ERROR, 'A field for the case must be provided.') - ); - }); - - it('should throw an error when decoded value accesses an invalid index', async () => { - const input = new Uint8Array(Array.from(Array(8).keys())); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError( - ErrorCode.DECODE_ERROR, - 'Invalid caseIndex "283686952306183". Valid cases: a,b.' - ) - ); - }); - - it('should not throw given correctly typed inputs', () => { - expect(() => coder.encode({ a: true })).not.toThrow(); - expect(() => coder.encode({ b: bn(1234) })).not.toThrow(); - }); - - it('should throw when provided with extra inputs', async () => { - await expectToThrowFuelError( - () => - coder.encode( - // @ts-expect-error - { a: true, b: bn(1234), c: false } - ), - new FuelError(ErrorCode.ENCODE_ERROR, 'Only one field must be provided.') - ); - }); - - it('should throw type error with invalid input for coder', async () => { - await expectToThrowFuelError( - () => - coder.encode( - // @ts-expect-error - { b: true } - ), - new FuelError(ErrorCode.ENCODE_ERROR, 'Invalid u64.') - ); - }); - - it('should throw type error with invalid input key', () => { - expect(() => - coder.encode( - // @ts-expect-error - { nope: 42 } - ) - ).toThrow(); - }); - - it('throws when decoding empty bytes', async () => { - await expectToThrowFuelError( - () => coder.decode(new Uint8Array(), 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid enum data size.') - ); - }); -}); diff --git a/packages/abi-coder/src/encoding/coders/v0/EnumCoder.ts b/packages/abi-coder/src/encoding/coders/v0/EnumCoder.ts deleted file mode 100644 index 17afb3cb597..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/EnumCoder.ts +++ /dev/null @@ -1,109 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { toNumber } from '@fuel-ts/math'; -import { concat } from '@fuel-ts/utils'; -import type { RequireExactlyOne } from 'type-fest'; - -import { concatWithDynamicData } from '../../../utils/utilities'; -import type { TypesOfCoder } from '../AbstractCoder'; -import { Coder } from '../AbstractCoder'; - -import { BigNumberCoder } from './BigNumberCoder'; - -export type InputValueOf> = RequireExactlyOne<{ - [P in keyof TCoders]: TypesOfCoder['Input']; -}>; -export type DecodedValueOf> = RequireExactlyOne<{ - [P in keyof TCoders]: TypesOfCoder['Decoded']; -}>; - -const isFullyNativeEnum = (enumCoders: { [s: string]: unknown } | ArrayLike): boolean => - Object.values(enumCoders).every( - // @ts-expect-error complicated types - ({ type, coders }) => type === '()' && JSON.stringify(coders) === JSON.stringify([]) - ); - -export class EnumCoder> extends Coder< - InputValueOf, - DecodedValueOf -> { - name: string; - coders: TCoders; - #caseIndexCoder: BigNumberCoder; - #encodedValueSize: number; - - constructor(name: string, coders: TCoders) { - const caseIndexCoder = new BigNumberCoder('u64'); - const encodedValueSize = Object.values(coders).reduce( - (max, coder) => Math.max(max, coder.encodedLength), - 0 - ); - super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize); - this.name = name; - this.coders = coders; - this.#caseIndexCoder = caseIndexCoder; - this.#encodedValueSize = encodedValueSize; - } - - #encodeNativeEnum(value: string): Uint8Array { - const valueCoder = this.coders[value]; - const encodedValue = valueCoder.encode([]); - const caseIndex = Object.keys(this.coders).indexOf(value); - - const padding = new Uint8Array(this.#encodedValueSize - valueCoder.encodedLength); - return concat([this.#caseIndexCoder.encode(caseIndex), padding, encodedValue]); - } - - encode(value: InputValueOf): Uint8Array { - if (typeof value === 'string' && this.coders[value]) { - return this.#encodeNativeEnum(value); - } - - const [caseKey, ...empty] = Object.keys(value); - if (!caseKey) { - throw new FuelError(ErrorCode.INVALID_DECODE_VALUE, 'A field for the case must be provided.'); - } - if (empty.length !== 0) { - throw new FuelError(ErrorCode.INVALID_DECODE_VALUE, 'Only one field must be provided.'); - } - const valueCoder = this.coders[caseKey]; - const caseIndex = Object.keys(this.coders).indexOf(caseKey); - const encodedValue = valueCoder.encode(value[caseKey]); - - const padding = new Uint8Array(this.#encodedValueSize - valueCoder.encodedLength); - return concatWithDynamicData([this.#caseIndexCoder.encode(caseIndex), padding, encodedValue]); - } - - #decodeNativeEnum(caseKey: string, newOffset: number): [DecodedValueOf, number] { - return [caseKey as unknown as DecodedValueOf, newOffset]; - } - - decode(data: Uint8Array, offset: number): [DecodedValueOf, number] { - if (data.length < this.#encodedValueSize) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid enum data size.`); - } - - let newOffset = offset; - - let decoded; - [decoded, newOffset] = new BigNumberCoder('u64').decode(data, newOffset); - const caseIndex = toNumber(decoded); - const caseKey = Object.keys(this.coders)[caseIndex]; - if (!caseKey) { - throw new FuelError( - ErrorCode.INVALID_DECODE_VALUE, - `Invalid caseIndex "${caseIndex}". Valid cases: ${Object.keys(this.coders)}.` - ); - } - - const valueCoder = this.coders[caseKey]; - const padding = this.#encodedValueSize - valueCoder.encodedLength; - newOffset += padding; - [decoded, newOffset] = valueCoder.decode(data, newOffset); - - if (isFullyNativeEnum(this.coders)) { - return this.#decodeNativeEnum(caseKey, newOffset); - } - - return [{ [caseKey]: decoded } as DecodedValueOf, newOffset]; - } -} diff --git a/packages/abi-coder/src/encoding/coders/v0/NumberCoder.test.ts b/packages/abi-coder/src/encoding/coders/v0/NumberCoder.test.ts deleted file mode 100644 index 1d53ad877b7..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/NumberCoder.test.ts +++ /dev/null @@ -1,166 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; - -import { U8_MAX, U16_MAX, U32_MAX } from '../../../../test/utils/constants'; - -import { NumberCoder } from './NumberCoder'; - -/** - * @group node - * @group browser - */ -describe('NumberCoder', () => { - it('should encode min u8 number as a u8 coder', () => { - const coder = new NumberCoder('u8'); - const expected = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]); - const actual = coder.encode(0); - - expect(actual).toStrictEqual(expected); - }); - - it('should decode a min u8 number as a u8 coder', () => { - const coder = new NumberCoder('u8'); - const expectedValue = 0; - const expectedLength = 8; - const [actualValue, actualLength] = coder.decode(new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]), 0); - - expect(actualValue).toBe(expectedValue); - expect(actualLength).toBe(expectedLength); - }); - - it('should encode max u8 number as a u8 coder', () => { - const coder = new NumberCoder('u8'); - const expected = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 255]); - const actual = coder.encode(U8_MAX); - - expect(actual).toStrictEqual(expected); - }); - - it('should decode a max u8 number as a u8 coder', () => { - const coder = new NumberCoder('u8'); - const expectedValue = U8_MAX; - const expectedLength = 8; - const [actualValue, actualLength] = coder.decode(new Uint8Array([0, 0, 0, 0, 0, 0, 0, 255]), 0); - - expect(actualValue).toBe(expectedValue); - expect(actualLength).toBe(expectedLength); - }); - - it('should encode min u16 number as a u16 coder', () => { - const coder = new NumberCoder('u16'); - const expected = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]); - const actual = coder.encode(0); - - expect(actual).toStrictEqual(expected); - }); - - it('should decode a min u16 number as a u16 coder', () => { - const coder = new NumberCoder('u16'); - const expectedValue = 0; - const expectedLength = 8; - const [actualValue, actualLength] = coder.decode(new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]), 0); - - expect(actualValue).toBe(expectedValue); - expect(actualLength).toBe(expectedLength); - }); - - it('should encode max u16 number as a u16 coder', () => { - const coder = new NumberCoder('u16'); - const expected = new Uint8Array([0, 0, 0, 0, 0, 0, 255, 255]); - const actual = coder.encode(U16_MAX); - - expect(actual).toStrictEqual(expected); - }); - - it('should decode a max u16 number as a u16 coder', () => { - const coder = new NumberCoder('u16'); - const expectedValue = U16_MAX; - const expectedLength = 8; - const [actualValue, actualLength] = coder.decode( - new Uint8Array([0, 0, 0, 0, 0, 0, 255, 255]), - 0 - ); - - expect(actualValue).toBe(expectedValue); - expect(actualLength).toBe(expectedLength); - }); - - it('should encode min u32 number as a u32 coder', () => { - const coder = new NumberCoder('u32'); - const expected = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]); - const actual = coder.encode(0); - - expect(actual).toStrictEqual(expected); - }); - - it('should decode a min u32 number as a u32 coder', () => { - const coder = new NumberCoder('u32'); - const expectedValue = 0; - const expectedLength = 8; - const [actualValue, actualLength] = coder.decode(new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]), 0); - - expect(actualValue).toBe(expectedValue); - expect(actualLength).toBe(expectedLength); - }); - - it('should encode max u32 number as a u32 coder', () => { - const coder = new NumberCoder('u32'); - const expected = new Uint8Array([0, 0, 0, 0, 255, 255, 255, 255]); - const actual = coder.encode(U32_MAX); - - expect(actual).toStrictEqual(expected); - }); - - it('should decode a max u32 number as a u32 coder', () => { - const coder = new NumberCoder('u32'); - const expectedValue = U32_MAX; - const expectedLength = 8; - const [actualValue, actualLength] = coder.decode( - new Uint8Array([0, 0, 0, 0, 255, 255, 255, 255]), - 0 - ); - - expect(actualValue).toBe(expectedValue); - expect(actualLength).toBe(expectedLength); - }); - - it('should throw if a negative number is encoded', async () => { - const coder = new NumberCoder('u8'); - const invalidInput = -1; - - await expectToThrowFuelError( - () => coder.encode(invalidInput), - new FuelError(ErrorCode.ENCODE_ERROR, 'Invalid u8.') - ); - }); - - it('should throw if coder is too small for number size', async () => { - const coder = new NumberCoder('u8'); - const invalidInput = U32_MAX; - - await expectToThrowFuelError( - () => coder.encode(invalidInput), - new FuelError(ErrorCode.ENCODE_ERROR, `Invalid u8, too many bytes.`) - ); - }); - - it('throws when decoding empty bytes', async () => { - const coder = new NumberCoder('u32'); - const input = new Uint8Array(0); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid number data size.') - ); - }); - - it('throws when decoding empty byte data', async () => { - const coder = new NumberCoder('u32'); - const input = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7]); - - await expectToThrowFuelError( - () => coder.decode(input, 8), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid number byte data size.') - ); - }); -}); diff --git a/packages/abi-coder/src/encoding/coders/v0/NumberCoder.ts b/packages/abi-coder/src/encoding/coders/v0/NumberCoder.ts deleted file mode 100644 index 14f30c51e97..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/NumberCoder.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { toNumber, toBytes } from '@fuel-ts/math'; - -import type { EncodingOptions } from '../../../types/EncodingOptions'; -import { Coder } from '../AbstractCoder'; - -type NumberCoderType = 'u8' | 'u16' | 'u32'; - -export class NumberCoder extends Coder { - // This is to align the bits to the total bytes - // See https://github.com/FuelLabs/fuel-specs/blob/master/specs/protocol/abi.md#unsigned-integers - length: number; - paddingLength: number; - baseType: NumberCoderType; - options: EncodingOptions; - - constructor( - baseType: NumberCoderType, - options: EncodingOptions = { - isSmallBytes: false, - isRightPadded: false, - } - ) { - const paddingLength = options.isSmallBytes && baseType === 'u8' ? 1 : 8; - - super('number', baseType, paddingLength); - this.baseType = baseType; - switch (baseType) { - case 'u8': - this.length = 1; - break; - case 'u16': - this.length = 2; - break; - case 'u32': - default: - this.length = 4; - break; - } - - this.paddingLength = paddingLength; - this.options = options; - } - - encode(value: number | string): Uint8Array { - let bytes; - - try { - bytes = toBytes(value); - } catch (error) { - throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}.`); - } - - if (bytes.length > this.length) { - throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}, too many bytes.`); - } - - const output = toBytes(bytes, this.paddingLength); - - if (this.baseType !== 'u8') { - return output; - } - - return this.options.isRightPadded ? output.reverse() : output; - } - - private decodeU8(data: Uint8Array, offset: number): [number, number] { - let bytes; - if (this.options.isRightPadded) { - bytes = data.slice(offset, offset + 1); - } else { - bytes = data.slice(offset, offset + this.paddingLength); - bytes = bytes.slice(this.paddingLength - this.length, this.paddingLength); - } - - return [toNumber(bytes), offset + this.paddingLength]; - } - - decode(data: Uint8Array, offset: number): [number, number] { - if (data.length < this.paddingLength) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number data size.`); - } - - if (this.baseType === 'u8') { - return this.decodeU8(data, offset); - } - - let bytes = data.slice(offset, offset + this.paddingLength); - bytes = bytes.slice(8 - this.length, 8); - - if (bytes.length !== this.paddingLength - (this.paddingLength - this.length)) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number byte data size.`); - } - - return [toNumber(bytes), offset + 8]; - } -} diff --git a/packages/abi-coder/src/encoding/coders/v0/OptionCoder.ts b/packages/abi-coder/src/encoding/coders/v0/OptionCoder.ts deleted file mode 100644 index f333d2dea02..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/OptionCoder.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; - -import type { Coder } from '../AbstractCoder'; - -import type { InputValueOf, DecodedValueOf } from './EnumCoder'; -import { EnumCoder } from './EnumCoder'; - -type SwayOption = { None: [] } | { Some: T }; -export type Option = T | undefined; - -export class OptionCoder> extends EnumCoder { - encode(value: InputValueOf): Uint8Array { - const result = super.encode(this.toSwayOption(value) as unknown as InputValueOf); - return result; - } - - toSwayOption(input: InputValueOf): SwayOption { - if (input !== undefined) { - return { Some: input }; - } - - return { None: [] }; - } - - decode(data: Uint8Array, offset: number): [DecodedValueOf, number] { - if (data.length < this.encodedLength) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`); - } - - const [decoded, newOffset] = super.decode(data, offset); - return [this.toOption(decoded) as DecodedValueOf, newOffset]; - } - - toOption(output?: DecodedValueOf): Option { - if (output && 'Some' in output) { - return output.Some; - } - - return undefined; - } -} diff --git a/packages/abi-coder/src/encoding/coders/v0/RawSliceCoder.test.ts b/packages/abi-coder/src/encoding/coders/v0/RawSliceCoder.test.ts deleted file mode 100644 index 1631f9da3a1..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/RawSliceCoder.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { FuelError, ErrorCode } from '@fuel-ts/errors'; -import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; - -import type { Uint8ArrayWithDynamicData } from '../../../utils/utilities'; - -import { RawSliceCoder } from './RawSliceCoder'; - -/** - * @group node - * @group browser - */ -describe('RawSliceCoder', () => { - it('should encode a raw-slice', () => { - const coder = new RawSliceCoder(); - const expected: Uint8ArrayWithDynamicData = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 3, - ]); - expected.dynamicData = { - 0: new Uint8Array([1, 2, 3]), - }; - - const actual = coder.encode([1, 2, 3]); - - expect(actual).toStrictEqual(expected); - }); - - it('should throw when value to encode is not array', async () => { - const coder = new RawSliceCoder(); - const nonArrayInput = { ...[1] }; - await expectToThrowFuelError( - () => coder.encode(nonArrayInput), - new FuelError(ErrorCode.ENCODE_ERROR, 'Expected array value.') - ); - }); - - it('should decode a raw-slice', () => { - const coder = new RawSliceCoder(); - const expected = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; - const [actual, newOffset] = coder.decode(new Uint8Array(expected), 0); - - expect(actual).toStrictEqual(expected); - expect(newOffset).toEqual(10); - }); -}); diff --git a/packages/abi-coder/src/encoding/coders/v0/RawSliceCoder.ts b/packages/abi-coder/src/encoding/coders/v0/RawSliceCoder.ts deleted file mode 100644 index b0f5aed0f17..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/RawSliceCoder.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; - -import type { Uint8ArrayWithDynamicData } from '../../../utils/utilities'; -import { BASE_RAW_SLICE_OFFSET, concatWithDynamicData } from '../../../utils/utilities'; -import { Coder } from '../AbstractCoder'; - -import { ArrayCoder } from './ArrayCoder'; -import { BigNumberCoder } from './BigNumberCoder'; -import { NumberCoder } from './NumberCoder'; - -export class RawSliceCoder extends Coder { - constructor() { - super('raw untyped slice', 'raw untyped slice', BASE_RAW_SLICE_OFFSET); - } - - encode(value: number[]): Uint8Array { - if (!Array.isArray(value)) { - throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`); - } - - const parts: Uint8Array[] = []; - const coder = new NumberCoder('u8', { isSmallBytes: true }); - - // pointer (ptr) - const pointer: Uint8ArrayWithDynamicData = new BigNumberCoder('u64').encode( - BASE_RAW_SLICE_OFFSET - ); - - // pointer dynamicData, encode the vector now and attach to its pointer - pointer.dynamicData = { - 0: concatWithDynamicData(value.map((v) => coder.encode(v))), - }; - - parts.push(pointer); - - // length (len) - parts.push(new BigNumberCoder('u64').encode(value.length)); - - return concatWithDynamicData(parts); - } - - decode(data: Uint8Array, offset: number): [number[], number] { - const dataBytes = data.slice(offset); - const internalCoder = new ArrayCoder( - new NumberCoder('u8', { isSmallBytes: true }), - dataBytes.length - ); - const [decodedValue] = internalCoder.decode(dataBytes, 0); - - return [decodedValue, offset + dataBytes.length]; - } -} diff --git a/packages/abi-coder/src/encoding/coders/v0/StdStringCoder.test.ts b/packages/abi-coder/src/encoding/coders/v0/StdStringCoder.test.ts deleted file mode 100644 index 5e976a42d29..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/StdStringCoder.test.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; - -import type { Uint8ArrayWithDynamicData } from '../../../utils/utilities'; - -import { StdStringCoder } from './StdStringCoder'; - -/** - * @group node - * @group browser - */ -describe('StdStringCoder', () => { - it('should encode an empty string', () => { - const coder = new StdStringCoder(); - const expected: Uint8ArrayWithDynamicData = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ]); - expected.dynamicData = { - 0: new Uint8Array([]), - }; - - const actual = coder.encode(''); - expect(actual).toStrictEqual(expected); - }); - - it('should encode [hello world]', () => { - const coder = new StdStringCoder(); - const expected: Uint8ArrayWithDynamicData = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 11, - ]); - expected.dynamicData = { - 0: new Uint8Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 0, 0, 0, 0, 0]), - }; - - const actual = coder.encode('hello world'); - expect(actual).toStrictEqual(expected); - }); - - it('should encode [H3llo W0rld]', () => { - const coder = new StdStringCoder(); - const expected: Uint8ArrayWithDynamicData = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 11, - ]); - expected.dynamicData = { - 0: new Uint8Array([72, 51, 108, 108, 111, 32, 87, 48, 114, 108, 100, 0, 0, 0, 0, 0]), - }; - - const actual = coder.encode('H3llo W0rld'); - expect(actual).toStrictEqual(expected); - }); - - it('should encode [abcdefghijklmnopqrstuvwxyz1234567890]', () => { - const coder = new StdStringCoder(); - const expected: Uint8ArrayWithDynamicData = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 36, - ]); - expected.dynamicData = { - 0: new Uint8Array([ - 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 121, 122, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 0, 0, 0, 0, - ]), - }; - - const actual = coder.encode('abcdefghijklmnopqrstuvwxyz1234567890'); - expect(actual).toStrictEqual(expected); - }); - - it('should decode a string', () => { - const coder = new StdStringCoder(); - const input = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 49, 120, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 72, 101, 108, - 108, 111, 32, 87, 111, 114, 108, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ]); - const expected = 'Hello World'; - - const [actual, newOffset] = coder.decode(input, 0); - - expect(actual).toEqual(expected); - expect(newOffset).toEqual(24); - }); - - it('should decode a string [with offset]', () => { - const coder = new StdStringCoder(); - const input = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 49, 120, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 11, 72, 101, 108, - 108, 111, 32, 87, 111, 114, 108, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ]); - const expected = 'Hello World'; - - const [actual, newOffset] = coder.decode(input, 16); - - expect(actual).toEqual(expected); - expect(newOffset).toEqual(40); - }); - - it('throws when decoding a string with empty bytes', async () => { - const coder = new StdStringCoder(); - const input = new Uint8Array(0); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.ENCODE_ERROR, 'Invalid std string data size.') - ); - }); - - it('throws when decoding a string with empty byte data', async () => { - const coder = new StdStringCoder(); - const input = new Uint8Array([ - 0, 0, 0, 0, 3, 255, 255, 225, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 255, - ]); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid std string byte data size.') - ); - }); -}); diff --git a/packages/abi-coder/src/encoding/coders/v0/StdStringCoder.ts b/packages/abi-coder/src/encoding/coders/v0/StdStringCoder.ts deleted file mode 100644 index ae75bac1093..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/StdStringCoder.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { bn } from '@fuel-ts/math'; -import { concat, toUtf8String, toUtf8Bytes } from '@fuel-ts/utils'; - -import { WORD_SIZE } from '../../../utils/constants'; -import type { Uint8ArrayWithDynamicData } from '../../../utils/utilities'; -import { BASE_VECTOR_OFFSET, concatWithDynamicData } from '../../../utils/utilities'; -import { Coder } from '../AbstractCoder'; - -import { BigNumberCoder } from './BigNumberCoder'; - -export class StdStringCoder extends Coder { - static memorySize = 1; - constructor() { - super('struct', 'struct String', 1); - } - - encode(value: string): Uint8Array { - const parts: Uint8Array[] = []; - - // pointer (ptr) - const pointer: Uint8ArrayWithDynamicData = new BigNumberCoder('u64').encode(BASE_VECTOR_OFFSET); - - // pointer dynamicData, encode the string vector now and attach to its pointer - const data = this.#getPaddedData(value); - pointer.dynamicData = { - 0: concatWithDynamicData([data]), - }; - - parts.push(pointer); - - // capacity (cap) - parts.push(new BigNumberCoder('u64').encode(data.byteLength)); - - // length (len) - parts.push(new BigNumberCoder('u64').encode(value.length)); - - return concatWithDynamicData(parts); - } - - #getPaddedData(value: string): Uint8Array { - const data: Uint8Array[] = [toUtf8Bytes(value)]; - - const paddingLength = (WORD_SIZE - (value.length % WORD_SIZE)) % WORD_SIZE; - if (paddingLength) { - data.push(new Uint8Array(paddingLength)); - } - - return concat(data); - } - - decode(data: Uint8Array, offset: number): [string, number] { - if (data.length < this.encodedLength) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid std string data size.`); - } - - const len = data.slice(16, 24); - const encodedLength = bn(new BigNumberCoder('u64').decode(len, 0)[0]).toNumber(); - const byteData = data.slice(BASE_VECTOR_OFFSET, BASE_VECTOR_OFFSET + encodedLength); - - if (byteData.length !== encodedLength) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid std string byte data size.`); - } - - const value = toUtf8String(byteData); - return [value, offset + BASE_VECTOR_OFFSET]; - } -} diff --git a/packages/abi-coder/src/encoding/coders/v0/StringCoder.test.ts b/packages/abi-coder/src/encoding/coders/v0/StringCoder.test.ts deleted file mode 100644 index 1954ce7f818..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/StringCoder.test.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; - -import { U8_MAX } from '../../../../test/utils/constants'; - -import { StringCoder } from './StringCoder'; - -/** - * @group node - * @group browser - */ -describe('StringCoder', () => { - const STRING_MIN_DECODED = ''; - const STRING_MIN_ENCODED = new Uint8Array(); - const STRING_MAX_DECODED = 'a'.repeat(U8_MAX); - const STRING_MAX_ENCODED = new Uint8Array([...Array.from(Array(U8_MAX + 1).fill(97, 0, U8_MAX))]); - - it('should encode an empty string', () => { - const coder = new StringCoder(0); - const expected = STRING_MIN_ENCODED; - const actual = coder.encode(STRING_MIN_DECODED); - - expect(actual).toStrictEqual(expected); - }); - - it('should encode a max len string', () => { - const coder = new StringCoder(U8_MAX); - const expected = STRING_MAX_ENCODED; - const actual = coder.encode(STRING_MAX_DECODED); - - expect(actual).toStrictEqual(expected); - }); - - it('should decode an empty string', () => { - const coder = new StringCoder(0); - const expectedValue = STRING_MIN_DECODED; - const expectedLength = STRING_MIN_ENCODED.length; - const [actualValue, actualLength] = coder.decode(STRING_MIN_ENCODED, 0); - - expect(actualValue).toStrictEqual(expectedValue); - expect(actualLength).toBe(expectedLength); - }); - - it('should decode a max len string', () => { - const coder = new StringCoder(U8_MAX); - const expectedValue = STRING_MAX_DECODED; - const expectedLength = STRING_MAX_ENCODED.length; - const [actualValue, actualLength] = coder.decode(STRING_MAX_ENCODED, 0); - - expect(actualValue).toStrictEqual(expectedValue); - expect(actualLength).toBe(expectedLength); - }); - - it('should throw when encoding a string that is too big', async () => { - const coder = new StringCoder(0); - const invalidInput = STRING_MAX_DECODED; - - await expectToThrowFuelError( - () => coder.encode(invalidInput), - new FuelError(ErrorCode.ENCODE_ERROR, 'Value length mismatch during encode.') - ); - }); - - it('should throw when encoding a string that is too small', async () => { - const coder = new StringCoder(1); - const invalidInput = STRING_MIN_DECODED; - - expect(() => { - coder.encode(invalidInput); - }).toThrow(); - - await expectToThrowFuelError( - () => coder.encode(invalidInput), - new FuelError(ErrorCode.ENCODE_ERROR, 'Value length mismatch during encode.') - ); - }); - - it('should not completely decode a string that is too big for the coder', () => { - const coder = new StringCoder(1); - const invalidInput = STRING_MAX_ENCODED; - const [actualValue, actualLength] = coder.decode(invalidInput, 0); - - expect(actualValue).not.toBe(STRING_MAX_DECODED); - expect(actualLength).toBe(8); - }); - - it('throws when decoding empty bytes', async () => { - const coder = new StringCoder(1); - const input = new Uint8Array(0); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid string data size.') - ); - }); - - it('throws when decoding empty byte data', async () => { - const coder = new StringCoder(1); - const input = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7]); - - await expectToThrowFuelError( - () => coder.decode(input, 8), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid string byte data size.') - ); - }); -}); diff --git a/packages/abi-coder/src/encoding/coders/v0/StringCoder.ts b/packages/abi-coder/src/encoding/coders/v0/StringCoder.ts deleted file mode 100644 index 6b8bb521f9f..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/StringCoder.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { concat, toUtf8Bytes, toUtf8String } from '@fuel-ts/utils'; - -import { Coder } from '../AbstractCoder'; - -export class StringCoder extends Coder { - length: TLength; - #paddingLength: number; - - constructor(length: TLength) { - let paddingLength = (8 - length) % 8; - paddingLength = paddingLength < 0 ? paddingLength + 8 : paddingLength; - super('string', `str[${length}]`, length + paddingLength); - this.length = length; - this.#paddingLength = paddingLength; - } - - encode(value: string): Uint8Array { - if (this.length !== value.length) { - throw new FuelError(ErrorCode.ENCODE_ERROR, `Value length mismatch during encode.`); - } - - const encoded = toUtf8Bytes(value); - const padding = new Uint8Array(this.#paddingLength); - return concat([encoded, padding]); - } - - decode(data: Uint8Array, offset: number): [string, number] { - if (data.length < this.encodedLength) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string data size.`); - } - - const bytes = data.slice(offset, offset + this.length); - - if (bytes.length !== this.length) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string byte data size.`); - } - - const value = toUtf8String(bytes); - - const padding = this.#paddingLength; - return [value, offset + this.length + padding]; - } -} diff --git a/packages/abi-coder/src/encoding/coders/v0/StructCoder.test.ts b/packages/abi-coder/src/encoding/coders/v0/StructCoder.test.ts deleted file mode 100644 index e34daa08e02..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/StructCoder.test.ts +++ /dev/null @@ -1,158 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import { FuelError, ErrorCode } from '@fuel-ts/errors'; -import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; -import { bn } from '@fuel-ts/math'; - -import { U32_MAX } from '../../../../test/utils/constants'; - -import { BigNumberCoder } from './BigNumberCoder'; -import { BooleanCoder } from './BooleanCoder'; -import { StructCoder } from './StructCoder'; - -/** - * @group node - * @group browser - */ -describe('StructCoder', () => { - const STRUCT_NAME = 'TestStruct'; - const coder = new StructCoder(STRUCT_NAME, { - a: new BooleanCoder(), - b: new BigNumberCoder('u64'), - }); - - it('should encode a struct containing a boolean and number', () => { - const expected = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 255, 255, 255, 255]); - const actual = coder.encode({ a: true, b: U32_MAX }); - - expect(actual).toStrictEqual(expected); - }); - - it('should decode a struct containing a boolean and number', () => { - const expectedValue = { a: true, b: bn(U32_MAX) }; - const expectedLength = 16; - const [actualValue, actualLength] = coder.decode( - new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 255, 255, 255, 255]), - 0 - ); - - expect(JSON.stringify(actualValue)).toStrictEqual(JSON.stringify(expectedValue)); - expect(actualLength).toBe(expectedLength); - }); - - it('should not throw given correctly typed inputs', () => { - expect(() => coder.encode({ a: true, b: bn(1234) })).not.toThrow(); - }); - - it('pads to word size for encoded data with small bytes', () => { - const options = { isSmallBytes: true }; - const unpaddedCoder = new StructCoder(STRUCT_NAME, { - a: new BooleanCoder(options), - b: new BooleanCoder(options), - }); - const expected = new Uint8Array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); - const actual = unpaddedCoder.encode({ a: true, b: false }); - - expect(actual).toStrictEqual(expected); - }); - - it('pads new offset to word size when decoding data with small bytes', () => { - const options = { isSmallBytes: true }; - const unpaddedCoder = new StructCoder(STRUCT_NAME, { - a: new BooleanCoder(options), - b: new BooleanCoder(options), - }); - - const expectedValue = { a: true, b: false }; - const expectedLength = 16; - const [actualValue, actualLength] = unpaddedCoder.decode(new Uint8Array([1, 0]), 0); - - expect(JSON.stringify(actualValue)).toStrictEqual(JSON.stringify(expectedValue)); - expect(actualLength).toBe(expectedLength); - }); - - it('should not throw when provided with extra inputs', () => { - expect(() => - coder.encode( - // @ts-expect-error - { a: true, b: bn(1234), c: false } - ) - ).not.toThrow(); - }); - - it('should throw type error with both missing inputs', () => { - expect(() => - coder.encode( - // @ts-expect-error - {} - ) - ).toThrow(`Invalid struct ${STRUCT_NAME}`); - }); - - it('should throw type error with missing input for second coder', () => { - expect(() => - coder.encode( - // @ts-expect-error - { a: true } - ) - ).toThrow(`Invalid struct ${STRUCT_NAME}`); - }); - - it('should throw type error with missing input for first coder', () => { - expect(() => - coder.encode( - // @ts-expect-error - { b: bn(1234) } - ) - ).toThrow(`Invalid struct ${STRUCT_NAME}`); - }); - - it.skip('should throw type error with invalid input for first coder and missing input for second', () => { - // Skipped because this is failing with a different message because it's now failing on encoding a: 1234, - // which should be boolean, - // whereas previously it wasn't failing because of this but rather because the second 'b' prop is missing. - // This test should be deleted as it's testing the same thing as the - // 'should throw type error with missing input for second coder' test. - expect(() => - coder.encode( - // @ts-expect-error - { a: 1234 } - ) - ).toThrow(`Invalid struct ${STRUCT_NAME}`); - }); - - it('should throw type error with invalid input for second coder and missing input for first', () => { - expect(() => - coder.encode( - // @ts-expect-error - { b: true } - ) - ).toThrow(`Invalid struct ${STRUCT_NAME}`); - }); - - it('should throw type error with invalid input key', () => { - expect(() => - coder.encode( - // @ts-expect-error - { nope: 1234, alsoNope: true } - ) - ).toThrow(`Invalid struct ${STRUCT_NAME}`); - }); - - it('throws when decoding empty bytes', async () => { - const input = new Uint8Array(0); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid struct data size.') - ); - }); - - it('throws when decoding empty bytes', async () => { - const input = new Uint8Array(0); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid struct data size.') - ); - }); -}); diff --git a/packages/abi-coder/src/encoding/coders/v0/StructCoder.ts b/packages/abi-coder/src/encoding/coders/v0/StructCoder.ts deleted file mode 100644 index e4aca0a2b92..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/StructCoder.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; - -import { - concatWithDynamicData, - getWordSizePadding, - isMultipleOfWordSize, - rightPadToWordSize, -} from '../../../utils/utilities'; -import type { TypesOfCoder } from '../AbstractCoder'; -import { Coder } from '../AbstractCoder'; - -import { OptionCoder } from './OptionCoder'; - -type InputValueOf> = { - [P in keyof TCoders]: TypesOfCoder['Input']; -}; -type DecodedValueOf> = { - [P in keyof TCoders]: TypesOfCoder['Decoded']; -}; - -export class StructCoder> extends Coder< - InputValueOf, - DecodedValueOf -> { - name: string; - coders: TCoders; - - constructor(name: string, coders: TCoders) { - const encodedLength = Object.values(coders).reduce( - (acc, coder) => acc + coder.encodedLength, - 0 - ); - super('struct', `struct ${name}`, encodedLength); - this.name = name; - this.coders = coders; - } - - encode(value: InputValueOf) { - const encodedFields = Object.keys(this.coders).map((fieldName) => { - const fieldCoder = this.coders[fieldName]; - const fieldValue = value[fieldName]; - - if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) { - throw new FuelError( - ErrorCode.ENCODE_ERROR, - `Invalid ${this.type}. Field "${fieldName}" not present.` - ); - } - - const encoded = fieldCoder.encode(fieldValue); - - if (!isMultipleOfWordSize(encoded.length)) { - return rightPadToWordSize(encoded); - } - - return encoded; - }); - - return concatWithDynamicData([concatWithDynamicData(encodedFields)]); - } - - decode(data: Uint8Array, offset: number): [DecodedValueOf, number] { - if (data.length < this.encodedLength) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid struct data size.`); - } - - let newOffset = offset; - const decodedValue = Object.keys(this.coders).reduce((obj, fieldName) => { - const fieldCoder = this.coders[fieldName]; - let decoded; - [decoded, newOffset] = fieldCoder.decode(data, newOffset); - - if (!isMultipleOfWordSize(newOffset)) { - newOffset += getWordSizePadding(newOffset); - } - - // eslint-disable-next-line no-param-reassign - obj[fieldName as keyof DecodedValueOf] = decoded; - return obj; - }, {} as DecodedValueOf); - - return [decodedValue, newOffset]; - } -} diff --git a/packages/abi-coder/src/encoding/coders/v0/TupleCoder.test.ts b/packages/abi-coder/src/encoding/coders/v0/TupleCoder.test.ts deleted file mode 100644 index 0f04fbcd78b..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/TupleCoder.test.ts +++ /dev/null @@ -1,135 +0,0 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment */ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; -import { bn } from '@fuel-ts/math'; - -import { U64_MAX } from '../../../../test/utils/constants'; - -import { BigNumberCoder } from './BigNumberCoder'; -import { BooleanCoder } from './BooleanCoder'; -import { TupleCoder } from './TupleCoder'; - -/** - * @group node - * @group browser - */ -describe('Tuple Coder', () => { - const coder = new TupleCoder<[BooleanCoder, BigNumberCoder]>([ - new BooleanCoder(), - new BigNumberCoder('u64'), - ]); - - it('should encode a tuple containing a boolean and u64', () => { - const expected = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 1, 255, 255, 255, 255, 255, 255, 255, 255, - ]); - const actual = coder.encode([true, U64_MAX]); - - expect(actual).toStrictEqual(expected); - }); - - it('should decode a tuple containing a boolean and u64', () => { - const expectedValue = [true, bn(U64_MAX)]; - const expectedLength = 16; - const [actualValue, actualLength] = coder.decode( - new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 255, 255, 255, 255, 255, 255, 255, 255]), - 0 - ); - - expect(JSON.stringify(actualValue)).toStrictEqual(JSON.stringify(expectedValue)); - expect(actualLength).toBe(expectedLength); - }); - - it('pads to word size for encoded data with small bytes', () => { - const options = { isSmallBytes: true }; - const unpaddedCoder = new TupleCoder<[BooleanCoder, BooleanCoder]>([ - new BooleanCoder(options), - new BooleanCoder(options), - ]); - const expected = new Uint8Array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); - const actual = unpaddedCoder.encode([true, false]); - expect(actual).toStrictEqual(expected); - }); - - it('pads new offset to word size when decoding data with small bytes', () => { - const options = { isSmallBytes: true }; - const unpaddedCoder = new TupleCoder<[BooleanCoder, BooleanCoder]>([ - new BooleanCoder(options), - new BooleanCoder(options), - ]); - - const expectedValue = [true, false]; - const expectedLength = 16; - const [actualValue, actualLength] = unpaddedCoder.decode(new Uint8Array([1, 0]), 0); - - expect(JSON.stringify(actualValue)).toStrictEqual(JSON.stringify(expectedValue)); - expect(actualLength).toBe(expectedLength); - }); - - it('should not throw given correctly typed inputs', () => { - expect(() => coder.encode([true, bn(1234)])).not.toThrow(); - }); - - it('should throw when provided with extra inputs', () => { - expect(() => - coder.encode( - // @ts-expect-error - [true, bn(1337), false] - ) - ).toThrow('Types/values length mismatch'); - }); - - it('should throw type error with both missing inputs', () => { - expect(() => - coder.encode( - // @ts-expect-error - [] - ) - ).toThrow('Types/values length mismatch'); - }); - - it('should throw type error with a missing input', () => { - expect(() => - coder.encode( - // @ts-expect-error - [true] - ) - ).toThrow('Types/values length mismatch'); - }); - - it('should throw type error with invalid inputs', () => { - expect(() => - coder.encode( - // @ts-expect-error - [bn(1234), true] - ) - ).toThrow(); - }); - - it('should throw when input is an object', () => { - expect(() => - coder.encode( - // @ts-expect-error - { nope: 42 } - ) - ).toThrow(); - }); - - it('throws when decoding empty bytes', async () => { - const input = new Uint8Array(0); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid tuple data size.') - ); - }); - - it('throws when decoding empty bytes', async () => { - const input = new Uint8Array(0); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid tuple data size.') - ); - }); -}); diff --git a/packages/abi-coder/src/encoding/coders/v0/TupleCoder.ts b/packages/abi-coder/src/encoding/coders/v0/TupleCoder.ts deleted file mode 100644 index e3b7c63bcda..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/TupleCoder.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; - -import { - concatWithDynamicData, - getWordSizePadding, - isMultipleOfWordSize, - rightPadToWordSize, -} from '../../../utils/utilities'; -import type { TypesOfCoder } from '../AbstractCoder'; -import { Coder } from '../AbstractCoder'; - -type InputValueOf = { - [P in keyof TCoders]: TypesOfCoder['Input']; -}; -type DecodedValueOf = { - [P in keyof TCoders]: TypesOfCoder['Decoded']; -}; - -export class TupleCoder extends Coder< - InputValueOf, - DecodedValueOf -> { - coders: TCoders; - - constructor(coders: TCoders) { - const encodedLength = coders.reduce((acc, coder) => acc + coder.encodedLength, 0); - super('tuple', `(${coders.map((coder) => coder.type).join(', ')})`, encodedLength); - this.coders = coders; - } - - encode(value: InputValueOf): Uint8Array { - if (this.coders.length !== value.length) { - throw new FuelError(ErrorCode.ENCODE_ERROR, `Types/values length mismatch.`); - } - - return concatWithDynamicData( - this.coders.map((coder, i) => { - const encoded = coder.encode(value[i]); - if (!isMultipleOfWordSize(encoded.length)) { - return rightPadToWordSize(encoded); - } - return encoded; - }) - ); - } - - decode(data: Uint8Array, offset: number): [DecodedValueOf, number] { - if (data.length < this.encodedLength) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid tuple data size.`); - } - - let newOffset = offset; - const decodedValue = this.coders.map((coder) => { - let decoded; - [decoded, newOffset] = coder.decode(data, newOffset); - - if (!isMultipleOfWordSize(newOffset)) { - newOffset += getWordSizePadding(newOffset); - } - - return decoded; - }); - - return [decodedValue as DecodedValueOf, newOffset]; - } -} diff --git a/packages/abi-coder/src/encoding/coders/v0/VecCoder.test.ts b/packages/abi-coder/src/encoding/coders/v0/VecCoder.test.ts deleted file mode 100644 index 24b35237644..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/VecCoder.test.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; - -import { U32_MAX } from '../../../../test/utils/constants'; -import type { EncodingOptions } from '../../../types/EncodingOptions'; -import type { Uint8ArrayWithDynamicData } from '../../../utils/utilities'; - -import { BooleanCoder } from './BooleanCoder'; -import { NumberCoder } from './NumberCoder'; -import { VecCoder } from './VecCoder'; - -/** - * @group node - */ -describe('VecCoder', () => { - const options: EncodingOptions = { - isSmallBytes: true, - }; - - it('should encode a Vec of Booleans', () => { - const coder = new VecCoder(new BooleanCoder(options)); - const expected: Uint8ArrayWithDynamicData = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, - ]); - expected.dynamicData = { - 0: new Uint8Array([1, 0]), - }; - - const actual = coder.encode([true, false]); - - expect(actual).toEqual(expected); - }); - - it('should throw when encoding non array input', async () => { - const coder = new VecCoder(new BooleanCoder(options)); - await expectToThrowFuelError( - () => coder.encode('Nope' as never), - new FuelError( - ErrorCode.ENCODE_ERROR, - 'Expected array value, or a Uint8Array. You can use arrayify to convert a value to a Uint8Array.' - ) - ); - }); - - it('should decode a u8 Vec', () => { - const coder = new VecCoder(new NumberCoder('u8', options)); - const input = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 41, 16, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 3, 8, 6, 7, - ]); - const expected = [8, 6, 7]; - - const [actual, newOffset] = coder.decode(input, 0); - - expect(actual).toEqual(expected); - expect(newOffset).toEqual(24); - }); - - it('throws when decoding empty vec bytes', async () => { - const coder = new VecCoder(new NumberCoder('u8')); - const input = new Uint8Array(0); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.ENCODE_ERROR, 'Invalid vec data size.') - ); - }); - - it('throws when decoding empty vec byte data', async () => { - const coder = new VecCoder(new NumberCoder('u8')); - const input = new Uint8Array([ - 0, 0, 0, 0, 3, 255, 255, 225, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 255, - ]); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid vec byte data size.') - ); - }); - - it('throws when decoding vec larger than max size', async () => { - const coder = new VecCoder(new NumberCoder('u8')); - const input = new Uint8Array(U32_MAX + 1); - - await expectToThrowFuelError( - () => coder.decode(input, 0), - new FuelError(ErrorCode.DECODE_ERROR, 'Invalid vec data size.') - ); - }); -}); diff --git a/packages/abi-coder/src/encoding/coders/v0/VecCoder.ts b/packages/abi-coder/src/encoding/coders/v0/VecCoder.ts deleted file mode 100644 index 9b715e21980..00000000000 --- a/packages/abi-coder/src/encoding/coders/v0/VecCoder.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { bn } from '@fuel-ts/math'; - -import { MAX_BYTES } from '../../../utils/constants'; -import type { Uint8ArrayWithDynamicData } from '../../../utils/utilities'; -import { - concatWithDynamicData, - BASE_VECTOR_OFFSET, - chunkByLength, - isUint8Array, -} from '../../../utils/utilities'; -import type { TypesOfCoder } from '../AbstractCoder'; -import { Coder } from '../AbstractCoder'; - -import { BigNumberCoder } from './BigNumberCoder'; - -type InputValueOf = Array['Input']>; -type DecodedValueOf = Array['Decoded']>; - -export class VecCoder extends Coder< - InputValueOf, - DecodedValueOf -> { - coder: TCoder; - - constructor(coder: TCoder) { - super('struct', `struct Vec`, coder.encodedLength + BASE_VECTOR_OFFSET); - this.coder = coder; - } - - encode(value: InputValueOf): Uint8Array { - if (!Array.isArray(value) && !isUint8Array(value)) { - throw new FuelError( - ErrorCode.ENCODE_ERROR, - `Expected array value, or a Uint8Array. You can use arrayify to convert a value to a Uint8Array.` - ); - } - - const parts: Uint8Array[] = []; - - // pointer (ptr) - const pointer: Uint8ArrayWithDynamicData = new BigNumberCoder('u64').encode(BASE_VECTOR_OFFSET); - // pointer dynamicData, encode the vector now and attach to its pointer - pointer.dynamicData = { - 0: concatWithDynamicData(Array.from(value).map((v) => this.coder.encode(v))), - }; - - parts.push(pointer); - - // capacity (cap) - parts.push(new BigNumberCoder('u64').encode(value.length)); - - // length (len) - parts.push(new BigNumberCoder('u64').encode(value.length)); - - return concatWithDynamicData(parts); - } - - decode(data: Uint8Array, offset: number): [DecodedValueOf, number] { - if (data.length < BASE_VECTOR_OFFSET || data.length > MAX_BYTES) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid vec data size.`); - } - - const len = data.slice(16, 24); - const encodedLength = bn(new BigNumberCoder('u64').decode(len, 0)[0]).toNumber(); - const vectorRawDataLength = encodedLength * this.coder.encodedLength; - const vectorRawData = data.slice(BASE_VECTOR_OFFSET, BASE_VECTOR_OFFSET + vectorRawDataLength); - - if (vectorRawData.length !== vectorRawDataLength) { - throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid vec byte data size.`); - } - - return [ - chunkByLength(vectorRawData, this.coder.encodedLength).map( - (chunk) => this.coder.decode(chunk, 0)[0] - ), - offset + BASE_VECTOR_OFFSET, - ]; - } -} diff --git a/packages/abi-coder/src/encoding/strategies/getCoderForEncoding.test.ts b/packages/abi-coder/src/encoding/strategies/getCoderForEncoding.test.ts index 657ae674b49..15020c8859a 100644 --- a/packages/abi-coder/src/encoding/strategies/getCoderForEncoding.test.ts +++ b/packages/abi-coder/src/encoding/strategies/getCoderForEncoding.test.ts @@ -1,7 +1,6 @@ -import { ENCODING_V0, ENCODING_V1 } from '../../utils/constants'; +import { ENCODING_V1 } from '../../utils/constants'; import { getCoderForEncoding } from './getCoderForEncoding'; -import { getCoder as getCoderV0 } from './getCoderV0'; import { getCoder as getCoderV1 } from './getCoderV1'; /** @@ -9,18 +8,14 @@ import { getCoder as getCoderV1 } from './getCoderV1'; * @group browser */ describe('getEncodingStrategy', () => { - it('defaults to encoding version 0', () => { - expect(getCoderForEncoding()).toBe(getCoderV0); + it('defaults to encoding version 1', () => { + expect(getCoderForEncoding()).toBe(getCoderV1); }); it('returns getCoderV1 for encoding version 1', () => { expect(getCoderForEncoding(ENCODING_V1)).toBe(getCoderV1); }); - it('returns getCoderV0 for encoding version 0', () => { - expect(getCoderForEncoding(ENCODING_V0)).toBe(getCoderV0); - }); - it('throws for an unsupported encoding version', () => { expect(() => getCoderForEncoding('2')).toThrowError('Encoding version 2 is unsupported.'); }); diff --git a/packages/abi-coder/src/encoding/strategies/getCoderForEncoding.ts b/packages/abi-coder/src/encoding/strategies/getCoderForEncoding.ts index ca4f2b35aa9..33a19562859 100644 --- a/packages/abi-coder/src/encoding/strategies/getCoderForEncoding.ts +++ b/packages/abi-coder/src/encoding/strategies/getCoderForEncoding.ts @@ -2,9 +2,8 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import type { GetCoderFn } from '../../types/GetCoder'; import type { EncodingVersion } from '../../utils/constants'; -import { ENCODING_V0, ENCODING_V1 } from '../../utils/constants'; +import { ENCODING_V1 } from '../../utils/constants'; -import { getCoder as getCoderV0 } from './getCoderV0'; import { getCoder as getCoderV1 } from './getCoderV1'; /** @@ -14,12 +13,10 @@ import { getCoder as getCoderV1 } from './getCoderV1'; * @throws for an unsupported encoding version. * @returns the appropriate encoding strategy. */ -export function getCoderForEncoding(encoding: EncodingVersion = ENCODING_V0): GetCoderFn { +export function getCoderForEncoding(encoding: EncodingVersion = ENCODING_V1): GetCoderFn { switch (encoding) { case ENCODING_V1: return getCoderV1; - case ENCODING_V0: - return getCoderV0; default: throw new FuelError( ErrorCode.UNSUPPORTED_ENCODING_VERSION, diff --git a/packages/abi-coder/src/encoding/strategies/getCoderV0.ts b/packages/abi-coder/src/encoding/strategies/getCoderV0.ts deleted file mode 100644 index c812b1d4cbb..00000000000 --- a/packages/abi-coder/src/encoding/strategies/getCoderV0.ts +++ /dev/null @@ -1,157 +0,0 @@ -import { ErrorCode, FuelError } from '@fuel-ts/errors'; - -import { ResolvedAbiType } from '../../ResolvedAbiType'; -import type { EncodingOptions } from '../../types/EncodingOptions'; -import type { GetCoderFn } from '../../types/GetCoder'; -import { - B256_CODER_TYPE, - B512_CODER_TYPE, - BOOL_CODER_TYPE, - BYTES_CODER_TYPE, - ENCODING_V0, - OPTION_CODER_TYPE, - RAW_PTR_CODER_TYPE, - RAW_SLICE_CODER_TYPE, - STD_STRING_CODER_TYPE, - STR_SLICE_CODER_TYPE, - U16_CODER_TYPE, - U256_CODER_TYPE, - U32_CODER_TYPE, - U64_CODER_TYPE, - U8_CODER_TYPE, - VEC_CODER_TYPE, - arrayRegEx, - enumRegEx, - stringRegEx, - structRegEx, - tupleRegEx, -} from '../../utils/constants'; -import { findVectorBufferArgument } from '../../utils/json-abi'; -import type { Coder } from '../coders/AbstractCoder'; -import { ArrayCoder } from '../coders/v0/ArrayCoder'; -import { B256Coder } from '../coders/v0/B256Coder'; -import { B512Coder } from '../coders/v0/B512Coder'; -import { BigNumberCoder } from '../coders/v0/BigNumberCoder'; -import { BooleanCoder } from '../coders/v0/BooleanCoder'; -import { ByteCoder } from '../coders/v0/ByteCoder'; -import { EnumCoder } from '../coders/v0/EnumCoder'; -import { NumberCoder } from '../coders/v0/NumberCoder'; -import { OptionCoder } from '../coders/v0/OptionCoder'; -import { RawSliceCoder } from '../coders/v0/RawSliceCoder'; -import { StdStringCoder } from '../coders/v0/StdStringCoder'; -import { StringCoder } from '../coders/v0/StringCoder'; -import { StructCoder } from '../coders/v0/StructCoder'; -import { TupleCoder } from '../coders/v0/TupleCoder'; -import { VecCoder } from '../coders/v0/VecCoder'; - -import { getCoders } from './getCoders'; - -/** - * Retrieves coders that adhere to the v0 spec. - * - * @param resolvedAbiType - the resolved type to return a coder for. - * @param options - options to be utilized during the encoding process. - * @returns the coder for a given type. - */ -export const getCoder: GetCoderFn = ( - resolvedAbiType: ResolvedAbiType, - options?: EncodingOptions -): Coder => { - switch (resolvedAbiType.type) { - case U8_CODER_TYPE: - case U16_CODER_TYPE: - case U32_CODER_TYPE: - return new NumberCoder(resolvedAbiType.type, options); - case U64_CODER_TYPE: - case RAW_PTR_CODER_TYPE: - return new BigNumberCoder('u64'); - case U256_CODER_TYPE: - return new BigNumberCoder('u256'); - case RAW_SLICE_CODER_TYPE: - return new RawSliceCoder(); - case BOOL_CODER_TYPE: - return new BooleanCoder(options); - case B256_CODER_TYPE: - return new B256Coder(); - case B512_CODER_TYPE: - return new B512Coder(); - case BYTES_CODER_TYPE: - return new ByteCoder(); - case STD_STRING_CODER_TYPE: - return new StdStringCoder(); - default: - break; - } - - const stringMatch = stringRegEx.exec(resolvedAbiType.type)?.groups; - if (stringMatch) { - const length = parseInt(stringMatch.length, 10); - - return new StringCoder(length); - } - - // ABI types underneath MUST have components by definition - - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const components = resolvedAbiType.components!; - - const arrayMatch = arrayRegEx.exec(resolvedAbiType.type)?.groups; - if (arrayMatch) { - const length = parseInt(arrayMatch.length, 10); - const arg = components[0]; - if (!arg) { - throw new FuelError( - ErrorCode.INVALID_COMPONENT, - `The provided Array type is missing an item of 'component'.` - ); - } - - const arrayElementCoder = getCoder(arg, { isSmallBytes: true }); - return new ArrayCoder(arrayElementCoder as Coder, length); - } - - if (resolvedAbiType.type === VEC_CODER_TYPE) { - const arg = findVectorBufferArgument(components); - const argType = new ResolvedAbiType(resolvedAbiType.abi, arg); - - const itemCoder = getCoder(argType, { isSmallBytes: true, encoding: ENCODING_V0 }); - return new VecCoder(itemCoder as Coder); - } - - const structMatch = structRegEx.exec(resolvedAbiType.type)?.groups; - if (structMatch) { - const coders = getCoders(components, { isRightPadded: true, getCoder }); - return new StructCoder(structMatch.name, coders); - } - - const enumMatch = enumRegEx.exec(resolvedAbiType.type)?.groups; - if (enumMatch) { - const coders = getCoders(components, { getCoder }); - - const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE; - if (isOptionEnum) { - return new OptionCoder(enumMatch.name, coders); - } - return new EnumCoder(enumMatch.name, coders); - } - - const tupleMatch = tupleRegEx.exec(resolvedAbiType.type)?.groups; - if (tupleMatch) { - const coders = components.map((component) => - getCoder(component, { isRightPadded: true, encoding: ENCODING_V0 }) - ); - return new TupleCoder(coders as Coder[]); - } - - if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) { - throw new FuelError( - ErrorCode.INVALID_DATA, - 'String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`' - ); - } - - throw new FuelError( - ErrorCode.CODER_NOT_FOUND, - `Coder not found: ${JSON.stringify(resolvedAbiType)}.` - ); -}; diff --git a/packages/abi-coder/src/encoding/strategies/getCoderV1.ts b/packages/abi-coder/src/encoding/strategies/getCoderV1.ts index bbe5b82d125..2b746061ab0 100644 --- a/packages/abi-coder/src/encoding/strategies/getCoderV1.ts +++ b/packages/abi-coder/src/encoding/strategies/getCoderV1.ts @@ -8,7 +8,7 @@ import { B512_CODER_TYPE, BOOL_CODER_TYPE, BYTES_CODER_TYPE, - ENCODING_V0, + ENCODING_V1, OPTION_CODER_TYPE, RAW_PTR_CODER_TYPE, RAW_SLICE_CODER_TYPE, @@ -28,22 +28,22 @@ import { } from '../../utils/constants'; import { findVectorBufferArgument } from '../../utils/json-abi'; import type { Coder } from '../coders/AbstractCoder'; -import { ArrayCoder } from '../coders/v0/ArrayCoder'; -import { B256Coder } from '../coders/v0/B256Coder'; -import { B512Coder } from '../coders/v0/B512Coder'; -import { BigNumberCoder } from '../coders/v0/BigNumberCoder'; -import { BooleanCoder } from '../coders/v1/BooleanCoder'; -import { ByteCoder } from '../coders/v1/ByteCoder'; -import { EnumCoder } from '../coders/v1/EnumCoder'; -import { NumberCoder } from '../coders/v1/NumberCoder'; -import { OptionCoder } from '../coders/v1/OptionCoder'; -import { RawSliceCoder } from '../coders/v1/RawSliceCoder'; -import { StdStringCoder } from '../coders/v1/StdStringCoder'; -import { StrSliceCoder } from '../coders/v1/StrSliceCoder'; -import { StringCoder } from '../coders/v1/StringCoder'; -import { StructCoder } from '../coders/v1/StructCoder'; -import { TupleCoder } from '../coders/v1/TupleCoder'; -import { VecCoder } from '../coders/v1/VecCoder'; +import { ArrayCoder } from '../coders/ArrayCoder'; +import { B256Coder } from '../coders/B256Coder'; +import { B512Coder } from '../coders/B512Coder'; +import { BigNumberCoder } from '../coders/BigNumberCoder'; +import { BooleanCoder } from '../coders/BooleanCoder'; +import { ByteCoder } from '../coders/ByteCoder'; +import { EnumCoder } from '../coders/EnumCoder'; +import { NumberCoder } from '../coders/NumberCoder'; +import { OptionCoder } from '../coders/OptionCoder'; +import { RawSliceCoder } from '../coders/RawSliceCoder'; +import { StdStringCoder } from '../coders/StdStringCoder'; +import { StrSliceCoder } from '../coders/StrSliceCoder'; +import { StringCoder } from '../coders/StringCoder'; +import { StructCoder } from '../coders/StructCoder'; +import { TupleCoder } from '../coders/TupleCoder'; +import { VecCoder } from '../coders/VecCoder'; import { getCoders } from './getCoders'; @@ -109,7 +109,7 @@ export const getCoder: GetCoderFn = ( ); } - const arrayElementCoder = getCoder(arg, { isSmallBytes: true }); + const arrayElementCoder = getCoder(arg); return new ArrayCoder(arrayElementCoder as Coder, length); } @@ -117,13 +117,13 @@ export const getCoder: GetCoderFn = ( const arg = findVectorBufferArgument(components); const argType = new ResolvedAbiType(resolvedAbiType.abi, arg); - const itemCoder = getCoder(argType, { isSmallBytes: true, encoding: ENCODING_V0 }); + const itemCoder = getCoder(argType, { encoding: ENCODING_V1 }); return new VecCoder(itemCoder as Coder); } const structMatch = structRegEx.exec(resolvedAbiType.type)?.groups; if (structMatch) { - const coders = getCoders(components, { isRightPadded: true, getCoder }); + const coders = getCoders(components, { getCoder }); return new StructCoder(structMatch.name, coders); } @@ -140,9 +140,7 @@ export const getCoder: GetCoderFn = ( const tupleMatch = tupleRegEx.exec(resolvedAbiType.type)?.groups; if (tupleMatch) { - const coders = components.map((component) => - getCoder(component, { isRightPadded: true, encoding: ENCODING_V0 }) - ); + const coders = components.map((component) => getCoder(component, { encoding: ENCODING_V1 })); return new TupleCoder(coders as Coder[]); } diff --git a/packages/abi-coder/src/index.ts b/packages/abi-coder/src/index.ts index 3437f3723c0..93c8078e46f 100644 --- a/packages/abi-coder/src/index.ts +++ b/packages/abi-coder/src/index.ts @@ -1,19 +1,6 @@ export { Coder, InputValue, DecodedValue } from './encoding/coders/AbstractCoder'; -export { ArrayCoder } from './encoding/coders/v0/ArrayCoder'; -export { B256Coder } from './encoding/coders/v0/B256Coder'; -export { B512Coder } from './encoding/coders/v0/B512Coder'; -export { BooleanCoder } from './encoding/coders/v0/BooleanCoder'; -export { ByteCoder } from './encoding/coders/v0/ByteCoder'; -export { EnumCoder } from './encoding/coders/v0/EnumCoder'; -export { OptionCoder } from './encoding/coders/v0/OptionCoder'; -export { NumberCoder } from './encoding/coders/v0/NumberCoder'; -export { RawSliceCoder } from './encoding/coders/v0/RawSliceCoder'; -export { StdStringCoder } from './encoding/coders/v0/StdStringCoder'; -export { StringCoder } from './encoding/coders/v0/StringCoder'; -export { StructCoder } from './encoding/coders/v0/StructCoder'; -export { TupleCoder } from './encoding/coders/v0/TupleCoder'; -export { VecCoder } from './encoding/coders/v0/VecCoder'; export type { FunctionFragment } from './FunctionFragment'; +export * from './encoding/coders'; export { Interface } from './Interface'; export { JsonAbi } from './types/JsonAbi'; export { @@ -26,7 +13,5 @@ export { BYTES_32, calculateVmTxMemory, type EncodingVersion, - ENCODING_V0, ENCODING_V1, } from './utils/constants'; -export { BigNumberCoder } from './encoding/coders/v0/BigNumberCoder'; diff --git a/packages/abi-coder/src/types/EncodingOptions.ts b/packages/abi-coder/src/types/EncodingOptions.ts index 7577288937f..df14a41cecb 100644 --- a/packages/abi-coder/src/types/EncodingOptions.ts +++ b/packages/abi-coder/src/types/EncodingOptions.ts @@ -6,59 +6,21 @@ import type { EncodingVersion } from '../utils/constants'; * Firstly we should consider the encoding version being used. For more info on this * please refer to the fuel specs (https://github.com/FuelLabs/fuel-specs); * - * Encoding Version 0: - * - * This is the currently supported version. It offers the following configurable options - * regarding the encoding of small bytes: - * - * These options relates only to: - * - NumberCoder (u8, u16, u32) - * - BooleanCoder - * - * 1) isSmallBytes (default=false) - * - * Describes how many bytes it will occupy: - * - * false — occupies 8 bytes (default), and should be used when underneath: - * • standalone - * • tuple - * • struct - * • enum - * - * true — occupies 1 byte, and should be used when underneath: - * • array - * • vector - * - * - * - * 2) isRightPadded (default=false) - * - * Used only when `isSmallBytes` is FALSE. - * - * Describes how the padding should happen: - * - * false —— left padded (default), and should be used when underneath: - * • standalone - * • array - * • vector - * • enum - * • only one function argument + * Encoding Version 1: * - * true —— right padded, and should be used when underneath: - * • struct - * • tuple - * • multiple function arguments - * • configurable + * As version 1 aims to make call data as compact as possible, types are only using their required + * property space. In the VM, they are still padded. Therefore the following option is available: * + * 1) padToWordSize (default=false) * - * Encoding Version 1: + * Describes if the encoding should be padded to the word size. * - * It currently is supported only by logs, but has no specific configurable options. - * More information on the improvements made in this version can be found in the - * fuel specs (https://github.com/FuelLabs/fuel-specs/blob/master/src/abi/argument-encoding.md#version-1 + * false —— no padding (default). + * true —— padding to the word size, and should be used when underneath: + * • number(u8, u16, u32) + * • boolean */ export type EncodingOptions = { encoding?: EncodingVersion; - isSmallBytes?: boolean; - isRightPadded?: boolean; + padToWordSize?: boolean; }; diff --git a/packages/abi-coder/src/utils/constants.ts b/packages/abi-coder/src/utils/constants.ts index d8e37a076cc..a533ddf8f51 100644 --- a/packages/abi-coder/src/utils/constants.ts +++ b/packages/abi-coder/src/utils/constants.ts @@ -25,9 +25,8 @@ export const genericRegEx = /^generic (?\w+)$/; /** * Encoding versions */ -export const ENCODING_V0 = '0'; export const ENCODING_V1 = '1'; -export type EncodingVersion = typeof ENCODING_V0 | typeof ENCODING_V1; +export type EncodingVersion = typeof ENCODING_V1; /** * Property space and config constants diff --git a/packages/abi-coder/src/utils/json-abi.test.ts b/packages/abi-coder/src/utils/json-abi.test.ts index 243f77b4667..853530c87bb 100644 --- a/packages/abi-coder/src/utils/json-abi.test.ts +++ b/packages/abi-coder/src/utils/json-abi.test.ts @@ -1,7 +1,7 @@ import type { ResolvedAbiType } from '../ResolvedAbiType'; import type { JsonAbi, JsonAbiArgument } from '../types/JsonAbi'; -import { ENCODING_V0, ENCODING_V1 } from './constants'; +import { ENCODING_V1 } from './constants'; import { findFunctionByName, findNonEmptyInputs, @@ -22,7 +22,7 @@ const MOCK_ABI: JsonAbi = { configurables: [], }; -const DEFAULT_ENCODING_VERSION = '0'; +const DEFAULT_ENCODING_VERSION = ENCODING_V1; /** * @group node @@ -39,16 +39,13 @@ describe('json-abi', () => { expect(actual).toBe(expected); }); - it.each([ENCODING_V0, ENCODING_V1])( - 'should return the encoding version (when defined)', - (version) => { - const expected = version; + it('should return the encoding version (when defined)', () => { + const expected = ENCODING_V1; - const actual = getEncodingVersion(version); + const actual = getEncodingVersion(ENCODING_V1); - expect(actual).toBe(expected); - } - ); + expect(actual).toBe(expected); + }); it('should throw an error if the encoding version is not supported', () => { const encodingVersion = '-1'; diff --git a/packages/abi-coder/src/utils/json-abi.ts b/packages/abi-coder/src/utils/json-abi.ts index 1e6abf579b4..753244174a8 100644 --- a/packages/abi-coder/src/utils/json-abi.ts +++ b/packages/abi-coder/src/utils/json-abi.ts @@ -3,7 +3,7 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import type { ResolvedAbiType } from '../ResolvedAbiType'; import type { JsonAbi, JsonAbiArgument, JsonAbiFunction, JsonAbiType } from '../types/JsonAbi'; -import { ENCODING_V0, ENCODING_V1, type EncodingVersion } from './constants'; +import { ENCODING_V1, type EncodingVersion } from './constants'; /** * Asserts that the encoding version is supported by the ABI coder. @@ -15,9 +15,6 @@ import { ENCODING_V0, ENCODING_V1, type EncodingVersion } from './constants'; export const getEncodingVersion = (encoding?: string): EncodingVersion => { switch (encoding) { case undefined: - case ENCODING_V0: - return ENCODING_V0; - case ENCODING_V1: return ENCODING_V1; diff --git a/packages/abi-coder/src/utils/utilities.test.ts b/packages/abi-coder/src/utils/utilities.test.ts deleted file mode 100644 index d0e04ab5294..00000000000 --- a/packages/abi-coder/src/utils/utilities.test.ts +++ /dev/null @@ -1,292 +0,0 @@ -import { concat } from '@fuel-ts/utils'; - -import type { Uint8ArrayWithDynamicData } from './utilities'; -import { unpackDynamicData, concatWithDynamicData } from './utilities'; - -/** - * @group node - * @group browser - */ -describe('Abi Coder Utilities', () => { - it('can concatWithVectorData [no dynamicData, should match original concat]', () => { - const data1 = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 24]); - const data2 = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]); - const data3 = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]); - const data4 = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 16]); - const EXPECTED = concat([data1, data2, data3, data4]); - - const RESULT = concatWithDynamicData([data1, data2, data3, data4]); - expect(RESULT).toEqual(EXPECTED); - }); - - it('can concatWithVectorData [relocate single dynamicData]', () => { - const pointer: Uint8ArrayWithDynamicData = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 24]); - pointer.dynamicData = { 0: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 36]) }; - const capacity = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]); - const length = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]); - const someData = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 16]); - const EXPECTED: Uint8ArrayWithDynamicData = concat([pointer, capacity, length, someData]); - EXPECTED.dynamicData = { 0: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 36]) }; - - const RESULT = concatWithDynamicData([pointer, capacity, length, someData]); - expect(RESULT).toEqual(EXPECTED); - - // is idempotent - const RESULT_NEW = concatWithDynamicData([RESULT]); - expect(RESULT_NEW).toEqual(EXPECTED); - }); - - it('can concatWithVectorData [two distinct dynamicData]', () => { - const pointer = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 24]); - const capacity = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]); - const length = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]); - const EXPECTED: Uint8ArrayWithDynamicData = concat([ - pointer, - capacity, - length, - pointer, - capacity, - length, - ]); - EXPECTED.dynamicData = { - 0: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 36]), - 3: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 36]), - }; - - const arrayWithVectorData: Uint8ArrayWithDynamicData = concat([pointer, capacity, length]); - arrayWithVectorData.dynamicData = { 0: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 36]) }; - - const RESULT = concatWithDynamicData([arrayWithVectorData, arrayWithVectorData]); - - expect(RESULT).toEqual(EXPECTED); - - // is idempotent - const RESULT_NEW = concatWithDynamicData([RESULT]); - expect(RESULT_NEW).toEqual(EXPECTED); - }); - - it('can concatWithVectorData [three distinct dynamicData]', () => { - const pointer = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 24]); - const capacity = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]); - const length = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]); - const EXPECTED: Uint8ArrayWithDynamicData = concat([ - pointer, - capacity, - length, - pointer, - capacity, - length, - pointer, - capacity, - length, - ]); - EXPECTED.dynamicData = { - 0: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 33]), - 3: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 35]), - 6: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 37]), - }; - - const arrayWithVectorData1: Uint8ArrayWithDynamicData = concat([pointer, capacity, length]); - const arrayWithVectorData2: Uint8ArrayWithDynamicData = concat([pointer, capacity, length]); - const arrayWithVectorData3: Uint8ArrayWithDynamicData = concat([pointer, capacity, length]); - arrayWithVectorData1.dynamicData = { 0: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 33]) }; - arrayWithVectorData2.dynamicData = { 0: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 35]) }; - arrayWithVectorData3.dynamicData = { 0: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 37]) }; - - const RESULT = concatWithDynamicData([ - arrayWithVectorData1, - arrayWithVectorData2, - arrayWithVectorData3, - ]); - - expect(RESULT).toEqual(EXPECTED); - - // is idempotent - const RESULT_NEW = concatWithDynamicData([RESULT]); - expect(RESULT_NEW).toEqual(EXPECTED); - }); - - it('can concatWithVectorData [relocate three dynamicData]', () => { - const pointerA: Uint8ArrayWithDynamicData = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 24]); - pointerA.dynamicData = { 0: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 33]) }; - const pointerB: Uint8ArrayWithDynamicData = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 24]); - pointerB.dynamicData = { 0: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 12]) }; - const pointerC: Uint8ArrayWithDynamicData = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 24]); - pointerC.dynamicData = { 0: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]) }; - const capacity = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]); - const length = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]); - const someData = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 16]); - const EXPECTED: Uint8ArrayWithDynamicData = concat([ - pointerA, - capacity, - length, - pointerB, - capacity, - length, - pointerC, - capacity, - length, - someData, - ]); - EXPECTED.dynamicData = { - 0: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 33]), - 3: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 12]), - 6: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]), - }; - - const RESULT = concatWithDynamicData([ - pointerA, - capacity, - length, - pointerB, - capacity, - length, - pointerC, - capacity, - length, - someData, - ]); - - expect(RESULT).toEqual(EXPECTED); - - // is idempotent - const RESULT_NEW = concatWithDynamicData([RESULT]); - expect(RESULT_NEW).toEqual(EXPECTED); - }); - - it('can concatWithVectorData [with dynamicData in middle, should relocate]', () => { - const otherData = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 9]); - const pointer: Uint8ArrayWithDynamicData = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 24]); - pointer.dynamicData = { 0: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 36]) }; - const capacity = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]); - const length = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 4]); - const data = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 16]); - const EXPECTED: Uint8ArrayWithDynamicData = concat([ - otherData, - pointer, - capacity, - length, - data, - ]); - EXPECTED.dynamicData = { 2: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 36]) }; - - const RESULT = concatWithDynamicData([otherData, pointer, capacity, length, data]); - - expect(RESULT).toEqual(EXPECTED); - - // is idempotent - const RESULT_NEW = concatWithDynamicData([RESULT]); - expect(RESULT_NEW).toEqual(EXPECTED); - }); - - it('can unpackDynamicData [with dynamicData]', () => { - const results: Uint8ArrayWithDynamicData = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, - 24, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, - ]); - const DATA_1 = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 7, 228, 0, 0, 0, 0, 0, 0, - 0, 12, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 7, 227, - ]); - const DATA_2 = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 7, 188, - ]); - results.dynamicData = { - 0: new Uint8Array(DATA_1), - 3: new Uint8Array(DATA_2), - }; - const BASE_OFFSET = 0; - const DATA_OFFSET = 0; - // prettier-ignore - const EXPECTED = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 0, 0, 0, 48, - 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 1, - ...DATA_1, - ...DATA_2, - ]); - - const RESULT = unpackDynamicData(results, BASE_OFFSET, DATA_OFFSET); - - expect(RESULT).toEqual(EXPECTED); - }); - - it('can unpackDynamicData [with dynamicData before regular data]', () => { - const results: Uint8ArrayWithDynamicData = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - 0, 2, - ]); - const DATA_1 = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 7, 228, 0, 0, 0, 0, 0, 0, - 0, 12, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 7, 227, - ]); - const DATA_2 = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 7, 188, - ]); - results.dynamicData = { - 0: new Uint8Array(DATA_1), - 4: new Uint8Array(DATA_2), - }; - const BASE_OFFSET = 0; - const DATA_OFFSET = 0; - // prettier-ignore - const EXPECTED = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 48, - 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 2, - ...DATA_1, - ...DATA_2, - ]); - - const RESULT = unpackDynamicData(results, BASE_OFFSET, DATA_OFFSET); - - expect(RESULT).toEqual(EXPECTED); - }); - - it('can unpackDynamicData [with dynamicData before regular data, with offset]', () => { - const results: Uint8ArrayWithDynamicData = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - 0, 2, - ]); - const DATA_1 = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 7, 228, 0, 0, 0, 0, 0, 0, - 0, 12, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 7, 227, - ]); - const DATA_2 = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 7, 188, - ]); - results.dynamicData = { - 0: new Uint8Array(DATA_1), - 4: new Uint8Array(DATA_2), - }; - const BASE_OFFSET = 12584; - const DATA_OFFSET = 352; - // prettier-ignore - const EXPECTED = new Uint8Array([ - 0, 0, 0, 0, 0, 0, 50, 136, - 0, 0, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 50, 184, - 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 2, - ...DATA_1, - ...DATA_2, - ]); - - const RESULT = unpackDynamicData(results, BASE_OFFSET, DATA_OFFSET); - - expect(RESULT).toEqual(EXPECTED); - }); -}); diff --git a/packages/abi-coder/src/utils/utilities.ts b/packages/abi-coder/src/utils/utilities.ts index 1f096dafefd..00626d19382 100644 --- a/packages/abi-coder/src/utils/utilities.ts +++ b/packages/abi-coder/src/utils/utilities.ts @@ -1,95 +1,4 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; -import { concat, concatBytes, arrayify } from '@fuel-ts/utils'; - -import { BigNumberCoder } from '../encoding/coders/v0/BigNumberCoder'; - -import { BYTES_CODER_TYPE, VEC_CODER_TYPE, STD_STRING_CODER_TYPE, WORD_SIZE } from './constants'; - -export type DynamicData = { - [pointerIndex: number]: Uint8ArrayWithDynamicData; -}; - -export type Uint8ArrayWithDynamicData = Uint8Array & { - dynamicData?: DynamicData; -}; - -const VEC_PROPERTY_SPACE = 3; // ptr + cap + length -export const BASE_VECTOR_OFFSET = VEC_PROPERTY_SPACE * WORD_SIZE; - -const RAW_SLICE_PROPERTY_SPACE = 2; // ptr + length -export const BASE_RAW_SLICE_OFFSET = RAW_SLICE_PROPERTY_SPACE * WORD_SIZE; - -// this is a fork of @ethersproject/bytes:concat -// this collects individual dynamicData data and relocates it to top level -export function concatWithDynamicData(items: ReadonlyArray): Uint8ArrayWithDynamicData { - const topLevelData: DynamicData = {}; - - let totalIndex = 0; - const objects = items.map((item) => { - const dynamicData = (item as Uint8ArrayWithDynamicData).dynamicData; - if (dynamicData) { - Object.entries(dynamicData).forEach(([pointerIndex, vData]) => { - topLevelData[parseInt(pointerIndex, 10) + totalIndex] = vData; - }); - } - - const byteArray = arrayify(item); - totalIndex += byteArray.byteLength / WORD_SIZE; - - return byteArray; - }); - - const length = objects.reduce((accum, item) => accum + item.length, 0); - const result: Uint8ArrayWithDynamicData = new Uint8Array(length); - - objects.reduce((offset, object) => { - result.set(object, offset); - return offset + object.length; - }, 0); - - // store vector data and pointer indices, but only if data exist - if (Object.keys(topLevelData).length) { - result.dynamicData = topLevelData; - } - - return result; -} - -export function unpackDynamicData( - results: Uint8ArrayWithDynamicData, - baseOffset: number, - dataOffset: number -): Uint8Array { - if (!results.dynamicData) { - return concat([results]); - } - - let cumulativeDynamicByteLength = 0; - let updatedResults = results; - Object.entries(results.dynamicData).forEach(([pointerIndex, vData]) => { - // update value of pointer - const pointerOffset = parseInt(pointerIndex, 10) * WORD_SIZE; - const adjustedValue = new BigNumberCoder('u64').encode( - dataOffset + baseOffset + cumulativeDynamicByteLength - ); - updatedResults.set(adjustedValue, pointerOffset); - - // append dynamic data at the end - const dataToAppend = vData.dynamicData - ? // unpack child dynamic data - unpackDynamicData( - vData, - baseOffset, - dataOffset + vData.byteLength + cumulativeDynamicByteLength - ) - : vData; - updatedResults = concat([updatedResults, dataToAppend]); - - cumulativeDynamicByteLength += dataToAppend.byteLength; - }); - - return updatedResults; -} +import { WORD_SIZE } from './constants'; /** * Turns: @@ -124,44 +33,4 @@ export const chunkByLength = (data: Uint8Array, length = WORD_SIZE): Uint8Array[ return chunks; }; -/** - * Checks if a given type is a pointer type - * See: https://github.com/FuelLabs/sway/issues/1368 - */ -export const isPointerType = (type: string) => { - switch (type) { - case 'u8': - case 'u16': - case 'u32': - case 'u64': - case 'bool': { - return false; - } - default: { - return true; - } - } -}; - -export const isHeapType = (type: string) => - type === VEC_CODER_TYPE || type === BYTES_CODER_TYPE || type === STD_STRING_CODER_TYPE; - -/** - * Because some properties can be single-bytes, we need to pad them - * with zeros until they are aligned to a word-sized increment. - * This is the case for `tuple` and `struct` properties. - * Please refer to packages/abi-coder/src/coders/abstract-coder.ts for more details - */ -export const isMultipleOfWordSize = (length: number) => length % WORD_SIZE === 0; - -export const getWordSizePadding = (length: number) => WORD_SIZE - (length % WORD_SIZE); - -export const rightPadToWordSize = (encoded: Uint8Array) => { - if (isMultipleOfWordSize(encoded.length)) { - return encoded; - } - const padding = new Uint8Array(WORD_SIZE - (encoded.length % WORD_SIZE)); - return concatBytes([encoded, padding]); -}; - export const isUint8Array = (value: unknown): value is Uint8Array => value instanceof Uint8Array; diff --git a/packages/abi-coder/test/Interface.test.ts b/packages/abi-coder/test/Interface.test.ts index 55fc386f022..d93c26ca5f9 100644 --- a/packages/abi-coder/test/Interface.test.ts +++ b/packages/abi-coder/test/Interface.test.ts @@ -135,7 +135,7 @@ describe('Abi interface', () => { it('encodes configurables', () => { const encoded = exhaustiveExamplesInterface.encodeConfigurable('U8', 55); - expect(encoded).toEqual(new Uint8Array([55, 0, 0, 0, 0, 0, 0, 0])); + expect(encoded).toEqual(new Uint8Array([55])); }); it('throws when encoding non-existent configurable', () => { @@ -599,8 +599,8 @@ describe('Abi interface', () => { '$title: $value', ({ fn, title: _title, value, encodedValue, decodedTransformer, offset, skipDecoding }) => { const encoded = Array.isArray(value) - ? fn.encodeArguments(value, offset) - : fn.encodeArguments([value], offset); + ? fn.encodeArguments(value) + : fn.encodeArguments([value]); const encodedVal = encodedValue instanceof Function ? encodedValue(value, offset) : encodedValue; diff --git a/packages/abi-typegen/CHANGELOG.md b/packages/abi-typegen/CHANGELOG.md index f1612ff0117..9d3b04c0ac4 100644 --- a/packages/abi-typegen/CHANGELOG.md +++ b/packages/abi-typegen/CHANGELOG.md @@ -1,5 +1,17 @@ # @fuel-ts/abi-typegen +## 0.86.0 + +### Patch Changes + +- Updated dependencies [316c757] +- Updated dependencies [0651a5f] +- Updated dependencies [64e9659] + - @fuel-ts/utils@0.86.0 + - @fuel-ts/errors@0.86.0 + - @fuel-ts/versions@0.86.0 + - @fuel-ts/interfaces@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/abi-typegen/package.json b/packages/abi-typegen/package.json index 4baafb0f443..3fa0ab45fcf 100644 --- a/packages/abi-typegen/package.json +++ b/packages/abi-typegen/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/abi-typegen", - "version": "0.85.0", + "version": "0.86.0", "description": "Generates Typescript definitions from Sway ABI Json files", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/abi-typegen/test/fixtures/templates/contract/bytecode.hbs b/packages/abi-typegen/test/fixtures/templates/contract/bytecode.hbs index e24f89fb667..77bfba6625a 100644 --- a/packages/abi-typegen/test/fixtures/templates/contract/bytecode.hbs +++ b/packages/abi-typegen/test/fixtures/templates/contract/bytecode.hbs @@ -9,4 +9,4 @@ Fuel-Core version: 33.33.33 */ -export default '0x1af030007400000200000000000004405dffc00110ffff00740000001aec5000910001a85d43f009104100c01a4460005d4d10491b441000104934405d47f002104404405d4920001b44144010453440504fb0205fed10045fed20055047b19872500010284535005047b198504fb08072500010284d15005d453000504fb0105fed10025fed20035047b17872480010284534805047b1785fed00005d43f0035fed00015043b058724800102843b480504bb0e8724c0010284914c01ae9200020f8330058fbe00250fbe004740000991a4bd000504fb0f872500010284d05001ae9300020f8330058fbe00250fbe004740000901a4fd000134924c0134920001a4c00007648001c504bb118724c0010284914c01ae9200020f8330058fbe00250fbe004740000931a4bd000504fb12872500010284d05001ae9300020f8330058fbe00250fbe0047400008a1a43d000504fb10872500010284d15001ae9300020f8330058fbe00250fbe004740000711a47d000294d2411764c00017400006b1a4060005d41004a5fed002a5fec002b5043b1505047b0c81ae900001ae5100020f8330058fbe00250fbe004740000815047b0d81ae900001ae5100020f8330058fbe00250fbe0047400007a5d43f005264000001a4070005fed002c5d43f0055fed002d5fec002e504fb1605d43b02c5d47b02d5d4bb02e10492040165114807650000113511480765000065043b0685fec000d5047b13872480018284504807400000d12492440104920401b49148026480000281d04401a4470005043b0305fec10065fed10075fed20085047b13872480018284504805043b0b072480018284114805d43b027134100007640000f5d43b01613410040764000025d43f006364000005043b0b0504100085047b0b0504510085045100872480008284d04805041300872480008284114805d4130005d4530021b441440104104401a4410005e4110005d413002104100405f4d00025043b16050450010504bb048724c0008284904c050412008724c0008284114c05043b18872440010284124405043b1885047b09072480010284504805d4110005047b188504bb0a0724c0010284914c05d45200112451040254110005d43f0073640000095000007960800001aec5000910000101a43a0001a47e0007248001028ed04801a43b0005d4100011af50000920000101af9100098080000970000074af8000095000007960800001aec5000910000101a43a0001a47e0007248001028ed04801a43b0005d4100001af50000920000101af9100098080000970000074af800009500007f960800001aec5000910000301a43a0001a4790001a4be0005d4d00015d53f008104d35005d5100005d5500011b541540105145405fed40005d53f0085fed40011a53b0005057b02072580010285545805f4130015043b020504fb01072500010284d05005d413000724c0010284504c01af51000920000301af92000980800009700007f4af800006d61696e0000000000000000000002480000000000000008000000000000000400000000000002500000000000000400cccccccccccc0002000000000000007b000000000000000a0000000000000418' +export default '0x1af030007400000200000000000003e85dffc00110ffff00740000001aec5000910001f05d43f009104100c01a4460005d4d10491b441000104934405d47f002104404405d4920001b44144010453440504fb0205fed10045fed20055047b1e072500010284535005047b1e0504fb0c872500010284d15005d453000504fb0105fed10025fed20035047b1c072480010284534805047b1c05fed00005d43f0035fed00015043b078724800102843b480504bb148724c0010284914c01ae9200020f8330058fbe00250fbe004740000821a4bd000504fb15872500010284d05001ae9300020f8330058fbe00250fbe004740000791a4fd000134924c0134920001a4c00007648001c504bb178724c0010284914c01ae9200020f8330058fbe00250fbe0047400007c1a4bd000504fb18872500010284d05001ae9300020f8330058fbe00250fbe004740000731a43d000504fb16872500010284d15001ae9300020f8330058fbe00250fbe0047400005a1a47d000294d2411764c0001740000541a4060005d41004a5fed00335fec00345043b1985047b1281ae900001ae5100020f8330058fbe00250fbe0047400006a5047b1381ae900001ae5100020f8330058fbe00250fbe004740000635d43f005264000001a4070005047b0605fed000c5d43f0055fed000d5fec000e5043b08872480018284114805047b0d872480018284504805043b03072480018284114805d47b006504100085d4bb008104d14805c53f0305e4d400010492040504fb0a05fed10145045300872500008284505005fed20165d4930005d4130015d4530025fed20355fed00365fed10375043b1a85047b0f072480018284504805043b04872480018284114805d47b00950410010504bb0b85fed101750452008724c0008284504c05043b1d072440010284124405043b1d05047b10872480010284504805d4110005047b1d0504bb118724c0010284914c05d45200112451040254110005d43f0073640000095000007960800001aec5000910000101a43a0001a47e0007248001028ed04801a43b0005d4100011af50000920000101af9100098080000970000074af8000095000007960800001aec5000910000101a43a0001a47e0007248001028ed04801a43b0005d4100001af50000920000101af9100098080000970000074af800009500007f960800001aec5000910000301a43a0001a4790001a4be0005d4d00015d53f008104d35005d5100005d5500011b541540105145405fed40005d53f0085fed40011a53b0005057b02072580010285545805f4130015043b020504fb01072500010284d05005d413000724c0010284504c01af51000920000301af92000980800009700007f4af80000470000006d61696e00000000000000000000024800000000000000080000000000000004000000000000025000000000000004000100000000000000000000000000007b000000000000000a00000000000003c0' diff --git a/packages/abi-typegen/test/fixtures/templates/predicate-with-configurable/factory.hbs b/packages/abi-typegen/test/fixtures/templates/predicate-with-configurable/factory.hbs index 45410e3e6cb..fc0cb34b886 100644 --- a/packages/abi-typegen/test/fixtures/templates/predicate-with-configurable/factory.hbs +++ b/packages/abi-typegen/test/fixtures/templates/predicate-with-configurable/factory.hbs @@ -78,7 +78,7 @@ const _abi = { "type": 2, "typeArguments": null }, - "offset": 224 + "offset": 560 }, { "name": "ADDRESS", @@ -87,7 +87,7 @@ const _abi = { "type": 0, "typeArguments": null }, - "offset": 232 + "offset": 576 } ] } diff --git a/packages/abi-typegen/test/fixtures/templates/script-with-configurable/factory.hbs b/packages/abi-typegen/test/fixtures/templates/script-with-configurable/factory.hbs index 5056d8c91ca..3fc28762edd 100644 --- a/packages/abi-typegen/test/fixtures/templates/script-with-configurable/factory.hbs +++ b/packages/abi-typegen/test/fixtures/templates/script-with-configurable/factory.hbs @@ -86,7 +86,7 @@ const _abi = { "type": 0, "typeArguments": null }, - "offset": 496 + "offset": 536 } ] } diff --git a/packages/account/CHANGELOG.md b/packages/account/CHANGELOG.md index 5f16003e29d..0f73cd86f5d 100644 --- a/packages/account/CHANGELOG.md +++ b/packages/account/CHANGELOG.md @@ -1,5 +1,32 @@ # Change Log +## 0.86.0 + +### Minor Changes + +- ee969d3: fix!: avoid add witnesses for predicates +- 64e9659: feat!: upgrade `forc@0.58.0` and remove `V0` encoding + +### Patch Changes + +- 316c757: fix: internalize `ethers` functionality and remove dependency +- 0651a5f: chore: remove `ethers` from `abi-coder` +- Updated dependencies [316c757] +- Updated dependencies [16196b6] +- Updated dependencies [0651a5f] +- Updated dependencies [64e9659] + - @fuel-ts/crypto@0.86.0 + - @fuel-ts/utils@0.86.0 + - @fuel-ts/errors@0.86.0 + - @fuel-ts/abi-coder@0.86.0 + - @fuel-ts/transactions@0.86.0 + - @fuel-ts/versions@0.86.0 + - @fuel-ts/address@0.86.0 + - @fuel-ts/hasher@0.86.0 + - @fuel-ts/math@0.86.0 + - @fuel-ts/merkle@0.86.0 + - @fuel-ts/interfaces@0.86.0 + ## 0.85.0 ### Minor Changes diff --git a/packages/account/package.json b/packages/account/package.json index 5a0a1fe3af1..f99207817af 100644 --- a/packages/account/package.json +++ b/packages/account/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/account", - "version": "0.85.0", + "version": "0.86.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/account/src/account.ts b/packages/account/src/account.ts index 9995d8d9a4f..d62faa37dc3 100644 --- a/packages/account/src/account.ts +++ b/packages/account/src/account.ts @@ -301,7 +301,6 @@ export class Account extends AbstractAccount { ); request.addResources(resources); - request.shiftPredicateData(); request.updatePredicateGasUsed(estimatedPredicates); const requestToReestimate = clone(request); @@ -340,7 +339,6 @@ export class Account extends AbstractAccount { fundingAttempts += 1; } - request.shiftPredicateData(); request.updatePredicateGasUsed(estimatedPredicates); const requestToReestimate = clone(request); diff --git a/packages/account/src/predicate/predicate.ts b/packages/account/src/predicate/predicate.ts index 8cf86a98400..c16d07f3f96 100644 --- a/packages/account/src/predicate/predicate.ts +++ b/packages/account/src/predicate/predicate.ts @@ -1,21 +1,13 @@ import type { JsonAbi, InputValue } from '@fuel-ts/abi-coder'; -import { - Interface, - INPUT_COIN_FIXED_SIZE, - WORD_SIZE, - calculateVmTxMemory, - SCRIPT_FIXED_SIZE, -} from '@fuel-ts/abi-coder'; +import { Interface } from '@fuel-ts/abi-coder'; import { Address } from '@fuel-ts/address'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; import type { BytesLike } from '@fuel-ts/interfaces'; -import { ByteArrayCoder } from '@fuel-ts/transactions'; import { arrayify, hexlify } from '@fuel-ts/utils'; import { Account } from '../account'; import { transactionRequestify, - BaseTransactionRequest, isRequestInputResource, isRequestInputResourceFromOwner, } from '../providers'; @@ -90,8 +82,6 @@ export class Predicate extends Account { ) { const request = transactionRequestify(transactionRequestLike) as T; - const { policies } = BaseTransactionRequest.getPolicyMeta(request); - const placeholderIndex = this.getIndexFromPlaceholderWitness(request); if (placeholderIndex !== -1) { @@ -103,7 +93,7 @@ export class Predicate extends Account { // eslint-disable-next-line no-param-reassign input.predicate = hexlify(this.bytes); // eslint-disable-next-line no-param-reassign - input.predicateData = hexlify(this.getPredicateData(policies.length)); + input.predicateData = hexlify(this.getPredicateData()); // eslint-disable-next-line no-param-reassign input.witnessIndex = 0; } @@ -134,26 +124,13 @@ export class Predicate extends Account { return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false }); } - private getPredicateData(policiesLength: number): Uint8Array { + private getPredicateData(): Uint8Array { if (!this.predicateData.length) { return new Uint8Array(); } const mainFn = this.interface?.functions.main; - const paddedCode = new ByteArrayCoder(this.bytes.length).encode(this.bytes); - - const VM_TX_MEMORY = calculateVmTxMemory({ - maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber(), - }); - const OFFSET = - VM_TX_MEMORY + - SCRIPT_FIXED_SIZE + - INPUT_COIN_FIXED_SIZE + - WORD_SIZE + - paddedCode.byteLength + - policiesLength * WORD_SIZE; - - return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array(); + return mainFn?.encodeArguments(this.predicateData) || new Uint8Array(); } /** @@ -215,7 +192,6 @@ export class Predicate extends Account { return resources.map((resource) => ({ ...resource, predicate: hexlify(this.bytes), - padPredicateData: (policiesLength: number) => hexlify(this.getPredicateData(policiesLength)), })); } diff --git a/packages/account/src/providers/coin.ts b/packages/account/src/providers/coin.ts index 1c71db35a7d..ce7cffb7744 100644 --- a/packages/account/src/providers/coin.ts +++ b/packages/account/src/providers/coin.ts @@ -13,5 +13,4 @@ export type Coin = { txCreatedIdx: BN; predicate?: BytesLike; predicateData?: BytesLike; - padPredicateData?: (policiesLenght: number) => BytesLike; }; diff --git a/packages/account/src/providers/message.ts b/packages/account/src/providers/message.ts index dcafe0abc0c..886f68e4e15 100644 --- a/packages/account/src/providers/message.ts +++ b/packages/account/src/providers/message.ts @@ -27,7 +27,6 @@ export type MessageCoin = { daHeight: BN; predicate?: BytesLike; predicateData?: BytesLike; - padPredicateData?: (policiesLenght: number) => BytesLike; }; export type MerkleProof = { diff --git a/packages/account/src/providers/transaction-request/input.ts b/packages/account/src/providers/transaction-request/input.ts index 57ec20c7a05..3a3216058a4 100644 --- a/packages/account/src/providers/transaction-request/input.ts +++ b/packages/account/src/providers/transaction-request/input.ts @@ -37,8 +37,6 @@ export type CoinTransactionRequestInput = { /** Predicate input data (parameters) */ predicateData?: BytesLike; - - padPredicateData?: (policiesLenght: number) => BytesLike; }; export type MessageTransactionRequestInput = { @@ -68,8 +66,6 @@ export type MessageTransactionRequestInput = { /** Predicate input data (parameters) */ predicateData?: BytesLike; - padPredicateData?: (policiesLenght: number) => BytesLike; - /** data of message */ data?: BytesLike; }; diff --git a/packages/account/src/providers/transaction-request/transaction-request.ts b/packages/account/src/providers/transaction-request/transaction-request.ts index 33b4e15da6b..135c6db7642 100644 --- a/packages/account/src/providers/transaction-request/transaction-request.ts +++ b/packages/account/src/providers/transaction-request/transaction-request.ts @@ -688,20 +688,4 @@ export abstract class BaseTransactionRequest implements BaseTransactionRequestLi } }); } - - shiftPredicateData() { - this.inputs.forEach((input) => { - // TODO: improve logic - if ( - 'predicateData' in input && - 'padPredicateData' in input && - typeof input.padPredicateData === 'function' - ) { - // eslint-disable-next-line no-param-reassign - input.predicateData = input.padPredicateData( - BaseTransactionRequest.getPolicyMeta(this).policies.length - ); - } - }); - } } diff --git a/packages/account/src/providers/transaction-summary/call.ts b/packages/account/src/providers/transaction-summary/call.ts index 4cf9cd24d8b..f1aa0f9f220 100644 --- a/packages/account/src/providers/transaction-summary/call.ts +++ b/packages/account/src/providers/transaction-summary/call.ts @@ -1,6 +1,5 @@ -import { Interface, type JsonAbi, calculateVmTxMemory } from '@fuel-ts/abi-coder'; +import { Interface, type JsonAbi } from '@fuel-ts/abi-coder'; import type { BN } from '@fuel-ts/math'; -import { bn } from '@fuel-ts/math'; import type { ReceiptCall } from '@fuel-ts/transactions'; type GetFunctionCallProps = { @@ -10,51 +9,33 @@ type GetFunctionCallProps = { maxInputs: BN; }; -export const getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }: GetFunctionCallProps) => { +export const getFunctionCall = ({ abi, receipt }: GetFunctionCallProps) => { const abiInterface = new Interface(abi); const callFunctionSelector = receipt.param1.toHex(8); const functionFragment = abiInterface.getFunction(callFunctionSelector); const inputs = functionFragment.jsonFn.inputs; - let encodedArgs; - - // if has more than 1 input or input type is bigger than 8 bytes, then it's a pointer to data - if (functionFragment.isInputDataPointer) { - if (rawPayload) { - // calculate offset to get function params from rawPayload. should also consider vm offset - const argsOffset = bn(receipt.param2) - .sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })) - .toNumber(); - - // slice(2) to remove first 0x, then slice again to remove offset and get only args - encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`; - } - } else { - // for small inputs, param2 is directly the value - encodedArgs = receipt.param2.toHex(); - } - + const encodedArgs = receipt.param2.toHex(); let argumentsProvided; - if (encodedArgs) { - // use bytes got from rawPayload to decode function params - const data = functionFragment.decodeArguments(encodedArgs); - if (data) { - // put together decoded data with input names from abi - argumentsProvided = inputs.reduce((prev, input, index) => { - const value = data[index]; - const name = input.name; - - if (name) { - return { - ...prev, - // reparse to remove bn - [name]: JSON.parse(JSON.stringify(value)), - }; - } - return prev; - }, {}); - } + // use bytes got from rawPayload to decode function params + const data = functionFragment.decodeArguments(encodedArgs); + if (data) { + // put together decoded data with input names from abi + argumentsProvided = inputs.reduce((prev, input, index) => { + const value = data[index]; + const name = input.name; + + if (name) { + return { + ...prev, + // reparse to remove bn + [name]: JSON.parse(JSON.stringify(value)), + }; + } + + return prev; + }, {}); } const call = { diff --git a/packages/address/CHANGELOG.md b/packages/address/CHANGELOG.md index 97b0fb0d193..b6da2d1c59c 100644 --- a/packages/address/CHANGELOG.md +++ b/packages/address/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log +## 0.86.0 + +### Patch Changes + +- Updated dependencies [316c757] +- Updated dependencies [0651a5f] + - @fuel-ts/crypto@0.86.0 + - @fuel-ts/utils@0.86.0 + - @fuel-ts/errors@0.86.0 + - @fuel-ts/interfaces@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/address/package.json b/packages/address/package.json index d5997d1a4a0..3626bc39755 100644 --- a/packages/address/package.json +++ b/packages/address/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/address", - "version": "0.85.0", + "version": "0.86.0", "description": "Utilities for encoding and decoding addresses", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/contract/CHANGELOG.md b/packages/contract/CHANGELOG.md index 2fbfbdf49d5..95491d04bbd 100644 --- a/packages/contract/CHANGELOG.md +++ b/packages/contract/CHANGELOG.md @@ -1,5 +1,25 @@ # Change Log +## 0.86.0 + +### Patch Changes + +- Updated dependencies [316c757] +- Updated dependencies [ee969d3] +- Updated dependencies [16196b6] +- Updated dependencies [0651a5f] +- Updated dependencies [64e9659] + - @fuel-ts/account@0.86.0 + - @fuel-ts/crypto@0.86.0 + - @fuel-ts/utils@0.86.0 + - @fuel-ts/errors@0.86.0 + - @fuel-ts/abi-coder@0.86.0 + - @fuel-ts/transactions@0.86.0 + - @fuel-ts/program@0.86.0 + - @fuel-ts/hasher@0.86.0 + - @fuel-ts/merkle@0.86.0 + - @fuel-ts/interfaces@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/contract/package.json b/packages/contract/package.json index 8c88889e4fb..d1701d20af2 100644 --- a/packages/contract/package.json +++ b/packages/contract/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/contract", - "version": "0.85.0", + "version": "0.86.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/create-fuels/CHANGELOG.md b/packages/create-fuels/CHANGELOG.md index 0f5ba7c4407..aa6685c4c54 100644 --- a/packages/create-fuels/CHANGELOG.md +++ b/packages/create-fuels/CHANGELOG.md @@ -1,5 +1,7 @@ # create-fuels +## 0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/create-fuels/package.json b/packages/create-fuels/package.json index 391325aa717..5b507eb722e 100644 --- a/packages/create-fuels/package.json +++ b/packages/create-fuels/package.json @@ -1,6 +1,6 @@ { "name": "create-fuels", - "version": "0.85.0", + "version": "0.86.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/crypto/CHANGELOG.md b/packages/crypto/CHANGELOG.md index 936a7115d26..c2ec312f8ac 100644 --- a/packages/crypto/CHANGELOG.md +++ b/packages/crypto/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log +## 0.86.0 + +### Patch Changes + +- 316c757: fix: internalize `ethers` functionality and remove dependency +- Updated dependencies [316c757] +- Updated dependencies [0651a5f] + - @fuel-ts/utils@0.86.0 + - @fuel-ts/errors@0.86.0 + - @fuel-ts/math@0.86.0 + - @fuel-ts/interfaces@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/crypto/package.json b/packages/crypto/package.json index aeedbe60ebd..f5b403e1d81 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/crypto", - "version": "0.85.0", + "version": "0.86.0", "description": "Utilities for encrypting and decrypting data", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/errors/CHANGELOG.md b/packages/errors/CHANGELOG.md index d33da9f41af..cfe0e2316d6 100644 --- a/packages/errors/CHANGELOG.md +++ b/packages/errors/CHANGELOG.md @@ -1,5 +1,13 @@ # @fuel-ts/errors +## 0.86.0 + +### Patch Changes + +- 316c757: fix: internalize `ethers` functionality and remove dependency +- Updated dependencies [64e9659] + - @fuel-ts/versions@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/errors/package.json b/packages/errors/package.json index 2a99c1d6224..7e39db04b2a 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/errors", - "version": "0.85.0", + "version": "0.86.0", "description": "Error class and error codes that the fuels-ts library throws", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/fuel-gauge/package.json b/packages/fuel-gauge/package.json index b1d3b7f2301..a74e4141624 100644 --- a/packages/fuel-gauge/package.json +++ b/packages/fuel-gauge/package.json @@ -5,9 +5,8 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "scripts": { - "pretest": "run-s build:forc build:forc-experimental build:process-predicates", + "pretest": "run-s build:forc build:process-predicates", "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release", - "build:forc-experimental": "pnpm fuels-forc build -p test/fixtures/forc-projects-experimental --release", "build:process-predicates": "tsx ./scripts/process-predicates.ts" }, "license": "Apache-2.0", diff --git a/packages/fuel-gauge/src/experimental-contract.test.ts b/packages/fuel-gauge/src/experimental-contract.test.ts deleted file mode 100644 index ad4cfa96dcb..00000000000 --- a/packages/fuel-gauge/src/experimental-contract.test.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { readFileSync } from 'fs'; -import type { Contract } from 'fuels'; -import { ContractFactory, bn } from 'fuels'; -import { join } from 'path'; - -import { setup } from './utils'; - -let contractInstance: Contract; -let contractFactory: ContractFactory; - -const U8_MAX = 2 ** 8 - 1; -const U16_MAX = 2 ** 16 - 1; -const U32_MAX = 2 ** 32 - 1; -const U64_MAX = bn(2).pow(64).sub(1); -const U256_MAX = bn(2).pow(256).sub(1); -const B512 = - '0x8e9dda6f7793745ac5aacf9e907cae30b2a01fdf0d23b7750a85c6a44fca0c29f0906f9d1f1e92e6a1fb3c3dcef3cc3b3cdbaae27e47b9d9a4c6a4fce4cf16b2'; - -/** - * @group node - */ -describe('Experimental Contract', () => { - beforeAll(async () => { - const projectName = 'contract-echo'; - const path = join( - __dirname, - `../test/fixtures/forc-projects-experimental/${projectName}/out/release/${projectName}` - ); - const contractBytecode = readFileSync(`${path}.bin`); - const abi = JSON.parse(readFileSync(`${path}-abi.json`, 'utf8')); - - contractInstance = await setup({ contractBytecode, abi }); - contractFactory = new ContractFactory(contractBytecode, abi, contractInstance.account); - }); - - it('echos mixed struct with all types', async () => { - const struct = { - a: U8_MAX, - b: U16_MAX, - c: U32_MAX, - d: U64_MAX, - e: U256_MAX, - f: '0xbebd3baab326f895289ecbd4210cf886ce41952316441ae4cac35f00f0e882a6', - g: B512, - native: 'Pending', - mixed: { Value: true }, - grades: [1, 4, 6, 22], - fuel: 'fuel', - hello: 'Hello World', - opt: 42, - nada: undefined, - bytes: Uint8Array.from([40, 41, 42]), - tuple: [U8_MAX, U16_MAX, U32_MAX, 'fuel'], - vec_u8: [40, 41, 42], - str_slice: 'fuel', - deep: { - a: U8_MAX, - b: U16_MAX, - c: U32_MAX, - d: U64_MAX, - e: U256_MAX, - f: '0xbebd3baab326f895289ecbd4210cf886ce41952316441ae4cac35f00f0e882a6', - g: B512, - native: 'Pending', - mixed: { Value: true }, - grades: [1, 4, 6, 22], - fuel: 'fuel', - hello: 'Hello World', - opt: 42, - nada: undefined, - bytes: Uint8Array.from([40, 41, 42]), - tuple: [U8_MAX, U16_MAX, U32_MAX, 'fuel'], - vec_u8: [40, 41, 42], - even_deeper: { - nested_vec: [1, 2, 3, 4, 5], - nested_str: 'fuel labs', - nested_raw: [88, 89, 90, 100], - }, - }, - }; - - const { value } = await contractInstance.functions.echo_struct(struct).call(); - expect(value).toStrictEqual(struct); - }); - - it('extracts str slice from revert', async () => { - await expect(contractInstance.functions.test_revert().call()).rejects.toThrow( - 'The transaction reverted because a "require" statement has thrown "This is a revert error".' - ); - }); - - it('echos configurable (both encoding versions)', async () => { - const param = [1, 2, 3, 'four']; - const { value } = await contractInstance.functions.echo_configurable(param).call(); - - expect(value).toStrictEqual(param); - - const configurableParam = [5, 6, 7, 'fuel']; - const configurableConstants = { - CONF: configurableParam, - }; - const configurableContractInstance = await contractFactory.deployContract({ - configurableConstants, - }); - const { value: configurableValue } = await configurableContractInstance.functions - .echo_configurable(configurableParam) - .call(); - - expect(configurableValue).toStrictEqual(configurableParam); - }); - - it('multicalls', async () => { - const { value: firstResults } = await contractInstance - .multiCall([contractInstance.functions.first_call(255)]) - .call(); - - expect(firstResults).toStrictEqual([255]); - - const { value: secondResults } = await contractInstance - .multiCall([ - contractInstance.functions.first_call(255), - contractInstance.functions.second_call(555), - ]) - .call(); - - expect(secondResults).toStrictEqual([255, 555]); - }); -}); diff --git a/packages/fuel-gauge/src/experimental-logging.test.ts b/packages/fuel-gauge/src/experimental-logging.test.ts deleted file mode 100644 index b60dae82dc8..00000000000 --- a/packages/fuel-gauge/src/experimental-logging.test.ts +++ /dev/null @@ -1,344 +0,0 @@ -import { readFileSync } from 'fs'; -import type { Contract } from 'fuels'; -import { bn, hexlify, randomBytes } from 'fuels'; -import { join } from 'path'; - -import { setup } from './utils'; - -let contractInstance: Contract; - -const U8_MAX = 2 ** 8 - 1; -const U16_MAX = 2 ** 16 - 1; -const U32_MAX = 2 ** 32 - 1; -const B256 = '0xd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b'; -const B512 = - '0x8e9dda6f7793745ac5aacf9e907cae30b2a01fdf0d23b7750a85c6a44fca0c29f0906f9d1f1e92e6a1fb3c3dcef3cc3b3cdbaae27e47b9d9a4c6a4fce4cf16b2'; - -beforeAll(async () => { - const projectName = 'logging'; - const path = join( - __dirname, - `../test/fixtures/forc-projects-experimental/${projectName}/out/release/${projectName}` - ); - const contractBytecode = readFileSync(`${path}.bin`); - const abi = JSON.parse(readFileSync(`${path}-abi.json`, 'utf8')); - - contractInstance = await setup({ contractBytecode, abi }); -}); - -/** - * @group node - */ -describe('Experimental Logging', () => { - it('logs u8', async () => { - const expected = U8_MAX; - - const { logs } = await contractInstance.functions.log_u8(expected).call(); - - expect(logs).toStrictEqual([expected]); - }); - - it('logs u16', async () => { - const expected = U16_MAX; - - const { logs } = await contractInstance.functions.log_u16(expected).call(); - - expect(logs).toStrictEqual([expected]); - }); - - it('logs u32', async () => { - const expected = U32_MAX; - - const { logs } = await contractInstance.functions.log_u32(expected).call(); - - expect(logs).toStrictEqual([expected]); - }); - - it('logs u8 u16 u32 multiple params', async () => { - const expected = [U8_MAX, U16_MAX, U32_MAX]; - - const { value, logs } = await contractInstance.functions.log_u8_u16_u32(...expected).call(); - - expect(value).toEqual(expected); - expect(logs).toEqual(expected); - }); - - it('logs u64', async () => { - const expected = U32_MAX + 1; - - const { logs } = await contractInstance.functions.log_u64(expected).call(); - - expect(bn(logs[0]).toNumber()).toStrictEqual(expected); - }); - - it('logs u256', async () => { - const expected = U32_MAX + 1; - - const { logs } = await contractInstance.functions.log_u256(expected).call(); - - expect(bn(logs[0]).toNumber()).toStrictEqual(expected); - }); - - it('logs u64 u8 multiple params', async () => { - const expected = [U32_MAX + 1, U8_MAX]; - - const { logs } = await contractInstance.functions.log_u64_u8(...expected).call(); - - expect(bn(logs[0]).toNumber()).toStrictEqual(expected[0]); - expect(logs[1]).toEqual(expected[1]); - }); - - it('logs boolean', async () => { - const expected = true; - - const { logs } = await contractInstance.functions.log_boolean(expected).call(); - - expect(logs).toStrictEqual([expected]); - }); - - it('logs boolean boolean multiple params', async () => { - const expected = [true, false]; - - const { logs } = await contractInstance.functions.log_boolean_boolean(...expected).call(); - - expect(logs).toEqual(expected); - }); - - it('logs number boolean mixed params', async () => { - const expected = [U32_MAX, true]; - - const { logs } = await contractInstance.functions.log_number_boolean(...expected).call(); - - expect(logs).toEqual(expected); - }); - - it('logs b256', async () => { - const expected = B256; - - const { logs } = await contractInstance.functions.log_b256(expected).call(); - - expect(logs).toStrictEqual([expected]); - }); - - it('logs b256 vec', async () => { - const expected = [B256, B256]; - - const { logs } = await contractInstance.functions.log_vec_b256(expected).call(); - - expect(logs).toEqual([expected]); - }); - - it('logs b512', async () => { - const expected = B512; - - const { logs } = await contractInstance.functions.log_b512(expected).call(); - - expect(logs).toStrictEqual([expected]); - }); - - it('logs b512 vec', async () => { - const expected = [B512, B512]; - - const { logs } = await contractInstance.functions.log_vec_b512(expected).call(); - - expect(logs).toEqual([expected]); - }); - - it('logs b256 b512 multiple params', async () => { - const expected = [B256, B512]; - - const { logs } = await contractInstance.functions.log_b256_b512(...expected).call(); - - expect(logs).toEqual(expected); - }); - - it('logs u8 vec', async () => { - const expected = [U8_MAX, 1, U8_MAX, 5]; - - const { logs } = await contractInstance.functions.log_vec_u8(expected).call(); - - expect(logs).toEqual([expected]); - }); - - it('logs b256 vec', async () => { - const expected = [hexlify(randomBytes(32)), hexlify(randomBytes(32))]; - - const { logs } = await contractInstance.functions.log_vec_b256(expected).call(); - - expect(logs).toEqual([expected]); - }); - - it('logs bytes', async () => { - const expected = [40, 41, 42]; - - const { logs } = await contractInstance.functions.log_bytes(expected).call(); - - expect(logs).toEqual([Uint8Array.from(expected)]); - }); - - it('logs StdString', async () => { - const expected = 'fuel'; - - const { logs } = await contractInstance.functions.log_std_string(expected).call(); - - expect(logs).toEqual([expected]); - }); - - it('logs u16 bytes multiple params', async () => { - const expected = [U16_MAX, [40, 41, 42]]; - - const { logs } = await contractInstance.functions.log_u16_bytes(...expected).call(); - - expect(logs).toEqual([U16_MAX, Uint8Array.from([40, 41, 42])]); - }); - - it('logs u8 array', async () => { - const expected = [U8_MAX, 5, U8_MAX]; - - const { logs } = await contractInstance.functions.log_u8_array(expected).call(); - - expect(logs).toEqual([expected]); - }); - - it('logs u16 array', async () => { - const expected = [U16_MAX, 5, U16_MAX]; - - const { logs } = await contractInstance.functions.log_u16_array(expected).call(); - - expect(logs).toEqual([expected]); - }); - - it('log u16 u8 array multiple params', async () => { - const expected = [U16_MAX, [U8_MAX, 5, U8_MAX]]; - - const { logs } = await contractInstance.functions.log_u16_u8_array(...expected).call(); - - expect(logs).toEqual(expected); - }); - - it('logs string', async () => { - const expected = 'fuel'; - - const { logs } = await contractInstance.functions.log_str_4(expected).call(); - - expect(logs).toEqual([expected]); - }); - - it('logs u8 string multiple params', async () => { - const expected = [U8_MAX, 'at']; - - const { logs } = await contractInstance.functions.log_u8_str_2(...expected).call(); - - expect(logs).toEqual(expected); - }); - - it('logs u8 u16 tuple', async () => { - const expected = [U8_MAX, U16_MAX]; - - const { logs } = await contractInstance.functions.log_u8_u16_tuple(expected).call(); - - expect(logs).toEqual([expected]); - }); - - it('logs enum', async () => { - const expectedFoo = { Foo: U32_MAX }; - const expectedBar = { Bar: true }; - - const { logs: logsFoo } = await contractInstance.functions.log_enum(expectedFoo).call(); - - const { logs: logsBar } = await contractInstance.functions.log_enum(expectedBar).call(); - - expect(logsFoo).toEqual([expectedFoo]); - expect(logsBar).toEqual([expectedBar]); - }); - - it('logs native enum', async () => { - const expectedFoo = 'Foo'; - const expectedBar = 'Bar'; - - const { logs: logsFoo } = await contractInstance.functions.log_native_enum(expectedFoo).call(); - - const { logs: logsBar } = await contractInstance.functions.log_native_enum(expectedBar).call(); - - expect(logsFoo).toEqual([expectedFoo]); - expect(logsBar).toEqual([expectedBar]); - }); - - it('logs boolean enum multiple params', async () => { - const expected = [true, { Foo: U32_MAX }]; - - const { logs } = await contractInstance.functions.log_boolean_enum(...expected).call(); - - expect(logs).toEqual(expected); - }); - - it('logs struct', async () => { - const expected = { - a: U8_MAX, - b: U16_MAX, - }; - - const { logs } = await contractInstance.functions.log_struct(expected).call(); - - expect(logs).toEqual([expected]); - }); - - it('logs struct vec', async () => { - const expected = [ - { - a: U8_MAX, - b: U16_MAX, - }, - { - a: 1, - b: 2, - }, - ]; - - const { logs } = await contractInstance.functions.log_struct_vec(expected).call(); - - expect(logs).toEqual([expected]); - }); - - it('logs struct boolean multiple params', async () => { - const expected = [ - { - a: U8_MAX, - b: U16_MAX, - }, - true, - ]; - - const { logs } = await contractInstance.functions.log_struct_boolean(...expected).call(); - - expect(logs).toEqual(expected); - }); - - it('logs u8 option', async () => { - const expectedSome = U8_MAX; - const expectedNone = undefined; - - const { logs: logsSome } = await contractInstance.functions.log_option_u8(expectedSome).call(); - - const { logs: logsNone } = await contractInstance.functions.log_option_u8(expectedNone).call(); - - expect(logsSome).toEqual([expectedSome]); - expect(logsNone).toEqual([expectedNone]); - }); - - it('logs raw slice', async () => { - const expected = [40, 41, 42]; - - const { logs } = await contractInstance.functions.log_raw_slice(expected).call(); - - expect(logs).toEqual([expected]); - }); - - it('logs str slice', async () => { - const expected = 'fuel'; - - const { logs } = await contractInstance.functions.log_str_slice(expected).call(); - - expect(logs).toEqual([expected]); - }); -}); diff --git a/packages/fuel-gauge/src/experimental-predicate.test.ts b/packages/fuel-gauge/src/experimental-predicate.test.ts deleted file mode 100644 index f106476f87d..00000000000 --- a/packages/fuel-gauge/src/experimental-predicate.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { readFileSync } from 'fs'; -import type { JsonAbi, Provider, WalletLocked, WalletUnlocked } from 'fuels'; -import { Predicate, bn } from 'fuels'; -import { join } from 'path'; - -import { fundPredicate, setupWallets } from './predicate/utils/predicate'; - -const U8_MAX = 255; -const U16_MAX = 65535; -const U32_MAX = 4294967295; -const U64_MAX = bn(2).pow(64).sub(1); -const U256_MAX = bn(2).pow(256).sub(1); -const B512 = - '0x8e9dda6f7793745ac5aacf9e907cae30b2a01fdf0d23b7750a85c6a44fca0c29f0906f9d1f1e92e6a1fb3c3dcef3cc3b3cdbaae27e47b9d9a4c6a4fce4cf16b2'; - -/** - * @group node - */ -describe('Experimental Predicate', () => { - let wallet: WalletUnlocked; - let receiver: WalletLocked; - let bytecode: Buffer; - let abi: JsonAbi; - let provider: Provider; - let baseAssetId: string; - - beforeAll(async () => { - [wallet, receiver] = await setupWallets(); - baseAssetId = wallet.provider.getBaseAssetId(); - const name = 'predicate-echo'; - const path = join( - __dirname, - `../test/fixtures/forc-projects-experimental/${name}/out/release/${name}` - ); - bytecode = readFileSync(`${path}.bin`); - abi = JSON.parse(readFileSync(`${path}-abi.json`, 'utf8')); - provider = wallet.provider; - }); - - it('echos struct', async () => { - const struct = { - a: U8_MAX, - b: U16_MAX, - c: U32_MAX, - d: U64_MAX, - e: U256_MAX, - f: '0xbebd3baab326f895289ecbd4210cf886ce41952316441ae4cac35f00f0e882a6', - g: B512, - native: 'Pending', - mixed: { Value: true }, - grades: [1, 4, 6, 22], - fuel: 'fuel', - hello: 'Hello World', - opt: 42, - nada: undefined, - bytes: Uint8Array.from([40, 41, 42]), - tuple: [U8_MAX, U16_MAX, U32_MAX, 'fuel'], - vec_u8: [40, 41, 42], - deep: { - a: U8_MAX, - b: U16_MAX, - c: U32_MAX, - d: U64_MAX, - e: U256_MAX, - f: '0xbebd3baab326f895289ecbd4210cf886ce41952316441ae4cac35f00f0e882a6', - g: B512, - native: 'Pending', - mixed: { Value: true }, - grades: [1, 4, 6, 22], - fuel: 'fuel', - hello: 'Hello World', - opt: 42, - nada: undefined, - bytes: Uint8Array.from([40, 41, 42]), - tuple: [U8_MAX, U16_MAX, U32_MAX, 'fuel'], - vec_u8: [40, 41, 42], - }, - }; - - const predicate = new Predicate<[typeof struct]>({ - bytecode, - provider, - abi, - inputData: [struct], - }); - - const initialBalance = await receiver.getBalance(baseAssetId); - expect(initialBalance).toStrictEqual(bn(0)); - - const amountToReceiver = 100; - - await fundPredicate(wallet, predicate, 100_000); - const tx = await predicate.transfer(receiver.address, amountToReceiver, baseAssetId); - await tx.waitForResult(); - - const finalBalance = await receiver.getBalance(baseAssetId); - expect(finalBalance).toStrictEqual(bn(amountToReceiver)); - }); -}); diff --git a/packages/fuel-gauge/src/experimental-script.test.ts b/packages/fuel-gauge/src/experimental-script.test.ts deleted file mode 100644 index bd0534ed9b6..00000000000 --- a/packages/fuel-gauge/src/experimental-script.test.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { readFileSync } from 'fs'; -import { Script, bn } from 'fuels'; -import { join } from 'path'; - -import { createWallet } from './utils'; - -let echoScript: Script; -let printScript: Script; -const U8_MAX = 255; -const U16_MAX = 65535; -const U32_MAX = 4294967295; -const U64_MAX = bn(2).pow(64).sub(1); -const U256_MAX = bn(2).pow(256).sub(1); -const B512 = - '0x8e9dda6f7793745ac5aacf9e907cae30b2a01fdf0d23b7750a85c6a44fca0c29f0906f9d1f1e92e6a1fb3c3dcef3cc3b3cdbaae27e47b9d9a4c6a4fce4cf16b2'; - -const getScript = async (name: string) => { - const wallet = await createWallet(); - const path = join( - __dirname, - `../test/fixtures/forc-projects-experimental/${name}/out/release/${name}` - ); - const bytes = readFileSync(`${path}.bin`); - const abi = JSON.parse(readFileSync(`${path}-abi.json`, 'utf8')); - return new Script(bytes, abi, wallet); -}; - -beforeAll(async () => { - printScript = await getScript('script-print'); - echoScript = await getScript('script-echo'); -}); - -/** - * @group node - */ -describe('Experimental Script', () => { - it('prints mixed struct with all types', async () => { - const { value } = await printScript.functions.main(B512).call(); - expect(value).toStrictEqual({ - a: U8_MAX, - b: U16_MAX, - c: U32_MAX, - d: U64_MAX, - e: U256_MAX, - f: '0xbebd3baab326f895289ecbd4210cf886ce41952316441ae4cac35f00f0e882a6', - g: B512, - native: 'Pending', - mixed: { Value: true }, - grades: [1, 4, 6, 22], - fuel: 'fuel', - hello: 'Hello World', - opt: 42, - nada: undefined, - bytes: Uint8Array.from([40, 41, 42]), - tuple: [U8_MAX, U16_MAX, U32_MAX, 'fuel'], - vec_u8: [40, 41, 42], - deep: { - a: U8_MAX, - b: U16_MAX, - c: U32_MAX, - d: U64_MAX, - e: U256_MAX, - f: '0xbebd3baab326f895289ecbd4210cf886ce41952316441ae4cac35f00f0e882a6', - g: B512, - native: 'Pending', - mixed: { Value: true }, - grades: [1, 4, 6, 22], - fuel: 'fuel', - hello: 'Hello World', - opt: 42, - nada: undefined, - bytes: Uint8Array.from([40, 41, 42]), - tuple: [U8_MAX, U16_MAX, U32_MAX, 'fuel'], - vec_u8: [40, 41, 42], - }, - }); - }); - - it('echos number struct', async () => { - const struct = { - a: U8_MAX, - b: U16_MAX, - c: U32_MAX, - d: U64_MAX, - e: U256_MAX, - f: '0xbebd3baab326f895289ecbd4210cf886ce41952316441ae4cac35f00f0e882a6', - g: B512, - native: 'Pending', - mixed: { Value: true }, - grades: [1, 4, 6, 22], - fuel: 'fuel', - hello: 'Hello World', - opt: 42, - nada: undefined, - bytes: Uint8Array.from([40, 41, 42]), - tuple: [U8_MAX, U16_MAX, U32_MAX, 'fuel'], - vec_u8: [40, 41, 42], - deep: { - a: U8_MAX, - b: U16_MAX, - c: U32_MAX, - d: U64_MAX, - e: U256_MAX, - f: '0xbebd3baab326f895289ecbd4210cf886ce41952316441ae4cac35f00f0e882a6', - g: B512, - native: 'Pending', - mixed: { Value: true }, - grades: [1, 4, 6, 22], - fuel: 'fuel', - hello: 'Hello World', - opt: 42, - nada: undefined, - bytes: Uint8Array.from([40, 41, 42]), - tuple: [U8_MAX, U16_MAX, U32_MAX, 'fuel'], - vec_u8: [40, 41, 42], - }, - }; - - const { value } = await echoScript.functions.main(struct).call(); - expect(value).toStrictEqual(struct); - }); -}); diff --git a/packages/fuel-gauge/src/predicate-conditional-inputs.test.ts b/packages/fuel-gauge/src/predicate-conditional-inputs.test.ts index 3ed14f869d0..73b4fd108e5 100644 --- a/packages/fuel-gauge/src/predicate-conditional-inputs.test.ts +++ b/packages/fuel-gauge/src/predicate-conditional-inputs.test.ts @@ -46,7 +46,7 @@ describe('PredicateConditionalInputs', () => { await tx1.waitForResult(); // transfer base asset to Alice so she can pay the fees - const tx2 = await adminWallet.transfer(aliceWallet.address, 2_000, baseAssetId); + const tx2 = await adminWallet.transfer(aliceWallet.address, 2105, baseAssetId); await tx2.waitForResult(); diff --git a/packages/fuel-gauge/src/predicate/predicate-configurables.test.ts b/packages/fuel-gauge/src/predicate/predicate-configurables.test.ts index 3970c2702a2..9e0cfbeaa09 100644 --- a/packages/fuel-gauge/src/predicate/predicate-configurables.test.ts +++ b/packages/fuel-gauge/src/predicate/predicate-configurables.test.ts @@ -180,6 +180,8 @@ describe('Predicate', () => { provider: wallet.provider, }); + await fundPredicate(wallet, predicate, amountToPredicate); + await expect( predicate.transfer(destination.address, 300, baseAssetId, { gasLimit: 1000 }) ).rejects.toThrow(/PredicateVerificationFailed/); diff --git a/packages/fuel-gauge/src/small-bytes.test.ts b/packages/fuel-gauge/src/small-bytes.test.ts deleted file mode 100644 index 953156c88c4..00000000000 --- a/packages/fuel-gauge/src/small-bytes.test.ts +++ /dev/null @@ -1,234 +0,0 @@ -import { getForcProject } from '@fuel-ts/utils/test-utils'; -import type { Contract, JsonAbi } from 'fuels'; -import { bn, ContractFactory } from 'fuels'; -import { join } from 'path'; - -import { getSetupContract, createWallet } from './utils'; - -/** - * @group node - */ -describe('small-bytes', () => { - const smallBytesProjectDir = join(__dirname, '../test/fixtures/forc-projects/small-bytes'); - - const setupContract = getSetupContract('small-bytes'); - - let contract: Contract; - - beforeAll(async () => { - contract = await setupContract(); - }); - it('should successfully call contract and echo values', async () => { - const expected = [48, 63]; - const res1 = await contract.functions.echo_u8_array().simulate(); - expect(res1.value).toMatchObject(expected); - }); - - it('should successfully echo u8 array', async () => { - const expected = [48, 63]; - const res1 = await contract.functions.echo_u8_array_with_value(expected).simulate(); - expect(res1.value).toMatchObject(expected); - }); - - it('should echo boolean array', async () => { - const expected = [true, false]; - const res1 = await contract.functions.echo_boolean_array().simulate(); - expect(res1.value).toMatchObject(expected); - }); - - it('should echo boolean array with value', async () => { - const expected = [true, false]; - const res1 = await contract.functions.echo_boolean_array_with_value(expected).simulate(); - expect(res1.value).toMatchObject(expected); - }); - - it('echos a mixed tuple with value', async () => { - const expected = [73, true]; - const res1 = await contract.functions.echo_mixed_tuple_with_value(expected).simulate(); - expect(res1.value).toMatchObject(expected); - }); - - it('echos a mixed tuple', async () => { - const expected = [48, true]; - const res1 = await contract.functions.echo_mixed_tuple().simulate(); - expect(res1.value).toMatchObject(expected); - }); - - it('echos a bigger mixed tuple', async () => { - const expected = [48, true, bn(1337)]; - const res1 = await contract.functions.echo_tuple().simulate(); - expect(JSON.stringify(res1.value)).toEqual(JSON.stringify(expected)); - }); - - it('echos a mixed struct with value', async () => { - const expected = { a: 73, b: true }; - const res1 = await contract.functions.echo_mixed_struct_with_value(expected).simulate(); - expect(res1.value).toMatchObject(expected); - }); - - it('echos a mixed enum with value', async () => { - const expectedA = { a: 73 }; - const expectedB = { b: true }; - - const res1 = await contract.functions.echo_mixed_enum_with_value(expectedA).simulate(); - expect(res1.value).toMatchObject(expectedA); - - const res2 = await contract.functions.echo_mixed_enum_with_value(expectedB).simulate(); - expect(res2.value).toMatchObject(expectedB); - }); - - it('accepts native enum', async () => { - const res1 = await contract.functions.echo_native_enum('B').simulate(); - expect(res1.value).toEqual('C'); - }); - - it('echos a u8 vector with value', async () => { - const expected = [73, 23]; - const res1 = await contract.functions.echo_u8_vector_with_value(expected).simulate(); - expect(res1.value).toMatchObject(expected); - }); - - it('echos a u8 vector', async () => { - const expected = [23, 32, 78]; - const res1 = await contract.functions.echo_u8_vector().simulate(); - expect(res1.value).toMatchObject(expected); // [ 23 ] - }); - - it('echos a u64 vector', async () => { - const expected = [bn(1337), bn(1448), bn(1559)]; - const res1 = await contract.functions.echo_u64_vector().simulate(); - expect(JSON.stringify(res1.value)).toEqual(JSON.stringify(expected)); - }); - - it('echos a mixed struct', async () => { - const expected = { - a: true, - b: bn(1337), - }; - - const res1 = await contract.functions.echo_mixed_struct().simulate(); - expect(JSON.stringify(res1.value)).toEqual(JSON.stringify(expected)); - }); - - it('send and echos a mixed struct', async () => { - const expected = { - a: true, - b: bn(1337), - }; - - const res1 = await contract.functions.echo_received_mixed_struct(expected).simulate(); - expect(JSON.stringify(res1.value)).toEqual(JSON.stringify(expected)); - }); - - it('echos a u8 with configurable constant', async () => { - const expected = 23; - const configurableConstants = { - U8: expected, - }; - - const { binHexlified, abiContents } = getForcProject({ - projectDir: smallBytesProjectDir, - projectName: 'small-bytes', - build: 'release', - }); - - const wallet = await createWallet(); - const factory = new ContractFactory(binHexlified, abiContents, wallet); - const configurableContract = await factory.deployContract({ - configurableConstants, - }); - - const res1 = await configurableContract.functions.echo_configurable_u8().simulate(); - - expect(res1.value).toBe(expected); - }); - - it('echos a boolean with configurable constant', async () => { - const expected = true; - const configurableConstants = { - BOOLEAN: expected, - }; - - const { binHexlified, abiContents } = getForcProject({ - projectDir: smallBytesProjectDir, - projectName: 'small-bytes', - build: 'release', - }); - - const wallet = await createWallet(); - const factory = new ContractFactory(binHexlified, abiContents, wallet); - const configurableContract = await factory.deployContract({ - configurableConstants, - }); - - const res1 = await configurableContract.functions.echo_configurable_boolean().simulate(); - - expect(res1.value).toBe(expected); - }); - - it('echos a u8 literal', async () => { - const expected = 47; - const res1 = await contract.functions.echo_u8_literal().simulate(); - expect(res1.value).toBe(expected); - }); - - it('echos a u16', async () => { - const res1 = await contract.functions.echo_u16(30000).simulate(); - expect(res1.value).toBe(30000 * 2); - }); - - it('echos a u32', async () => { - const res1 = await contract.functions.echo_u32(100000).simulate(); - expect(res1.value).toBe(100000 * 2); - }); - - it('echos a boolean literal', async () => { - const expected = true; - const res1 = await contract.functions.echo_boolean_literal().simulate(); - expect(res1.value).toBe(expected); - }); - - it('echos a u8 value', async () => { - const expected = 47; - const res1 = await contract.functions.echo_u8(expected).simulate(); - expect(res1.value).toBe(expected); - }); - - it('accepts two u8 values', async () => { - const res1 = await contract.functions.echo_two_u8s(15, 255).simulate(); - expect(res1.value).toBe(255); - }); - - it('accepts two boolean values', async () => { - const res1 = await contract.functions.two_booleans(true, true).simulate(); - expect(res1.value).toBe(true); - }); - - it('accepts u8, u64, bool', async () => { - const res1 = await contract.functions.u8_u64_bool(255, 10000, true).simulate(); - expect(res1.value).toBe(55); - }); - - it('accepts struct and u8', async () => { - const res1 = await contract.functions - .struct_and_u8( - { - a: 254, - b: true, - }, - 230 - ) - .simulate(); - - expect(res1.value).toEqual({ - a: 230, - b: true, - }); - }); - - it('echos a boolean value', async () => { - const expected = true; - const res1 = await contract.functions.echo_boolean(expected).simulate(); - expect(res1.value).toBe(expected); - }); -}); diff --git a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/Forc.toml b/packages/fuel-gauge/test/fixtures/forc-projects-experimental/Forc.toml deleted file mode 100644 index dc76225a689..00000000000 --- a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/Forc.toml +++ /dev/null @@ -1,8 +0,0 @@ -[workspace] -members = [ - "predicate-echo", - "script-echo", - "script-print", - "logging", - "contract-echo", -] diff --git a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/contract-echo/Forc.toml b/packages/fuel-gauge/test/fixtures/forc-projects-experimental/contract-echo/Forc.toml deleted file mode 100644 index 57b95ffcfef..00000000000 --- a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/contract-echo/Forc.toml +++ /dev/null @@ -1,7 +0,0 @@ -[project] -authors = ["Fuel Labs "] -entry = "main.sw" -license = "Apache-2.0" -name = "contract-echo" - -[dependencies] diff --git a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/contract-echo/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects-experimental/contract-echo/src/main.sw deleted file mode 100644 index 61b48badd61..00000000000 --- a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/contract-echo/src/main.sw +++ /dev/null @@ -1,109 +0,0 @@ -contract; - -use std::b512::B512; -use std::string::String; -use std::option::Option; -use std::bytes::Bytes; -use std::vec::Vec; - -enum NativeEnum { - Checked: (), - Pending: (), -} - -enum MixedEnum { - Value: bool, - Data: u16, -} - -struct EvenDeeperStruct { - nested_vec: Vec, - nested_str: str, - nested_raw: raw_slice, -} - -struct DeeperStruct { - a: u8, - b: u16, - c: u32, - d: u64, - e: u256, - f: b256, - g: B512, - native: NativeEnum, - mixed: MixedEnum, - grades: [u8; 4], - fuel: str[4], - hello: String, - opt: Option, - nada: Option, - bytes: Bytes, - tuple: (u8, u16, u32, str[4]), - vec_u8: Vec, - even_deeper: EvenDeeperStruct, -} - -struct MixedStruct { - a: u8, - b: u16, - c: u32, - d: u64, - e: u256, - f: b256, - g: B512, - native: NativeEnum, - mixed: MixedEnum, - grades: [u8; 4], - fuel: str[4], - hello: String, - opt: Option, - nada: Option, - bytes: Bytes, - tuple: (u8, u16, u32, str[4]), - vec_u8: Vec, - deep: DeeperStruct, - str_slice: str, -} - -configurable { - CONF: (u8, u16, u32, str[4]) = (1, 2, 3, __to_str_array("four")), -} - -abi MyContract { - fn echo_struct(param: MixedStruct) -> MixedStruct; - fn test_revert() -> bool; - fn echo_configurable(param: (u8, u16, u32, str[4])) -> (u8, u16, u32, str[4]); - fn first_call(param: u8) -> u8; - fn second_call(param: u16) -> u16; -} - -impl MyContract for Contract { - fn echo_struct(param: MixedStruct) -> MixedStruct { - param - } - - fn test_revert() -> bool { - require(false, "This is a revert error"); - true - } - - fn echo_configurable(param: (u8, u16, u32, str[4])) -> (u8, u16, u32, str[4]) { - assert_eq(param.0, CONF.0); - assert_eq(param.1, CONF.1); - assert_eq(param.2, CONF.2); - - let param_str: str = from_str_array(param.3); - let conf_str: str = from_str_array(CONF.3); - assert_eq(param_str, conf_str); - - CONF - } - - fn first_call(param: u8) -> u8 { - param - } - - fn second_call(param: u16) -> u16 { - param - } -} diff --git a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/logging/Forc.toml b/packages/fuel-gauge/test/fixtures/forc-projects-experimental/logging/Forc.toml deleted file mode 100644 index 36fbc29bc39..00000000000 --- a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/logging/Forc.toml +++ /dev/null @@ -1,7 +0,0 @@ -[project] -authors = ["Fuel Labs "] -entry = "main.sw" -license = "Apache-2.0" -name = "logging" - -[dependencies] diff --git a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/logging/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects-experimental/logging/src/main.sw deleted file mode 100644 index 0a2aa368788..00000000000 --- a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/logging/src/main.sw +++ /dev/null @@ -1,267 +0,0 @@ -contract; - -use std::logging::log; -use std::b512::B512; -use std::vec::Vec; -use std::bytes::Bytes; -use std::string::String; -use std::option::Option; - -enum MyNativeEnum { - Foo: (), - Bar: (), -} - -enum MyEnum { - Foo: u32, - Bar: bool, -} - -struct MyStruct { - a: u8, - b: u16, -} - -abi LoggingContract { - fn log_u8(a: u8) -> u8; - fn log_u16(a: u16) -> u16; - fn log_u32(a: u32) -> u32; - fn log_u8_u16_u32(a: u8, b: u16, c: u32) -> (u8, u16, u32); - fn log_u64(a: u64) -> u64; - fn log_u256(a: u256) -> u256; - fn log_u64_u8(a: u64, b: u8) -> (u64, u8); - fn log_boolean(a: bool) -> bool; - fn log_boolean_boolean(a: bool, b: bool) -> (bool, bool); - fn log_number_boolean(a: u32, b: bool) -> (u32, bool); - fn log_b256(a: b256) -> b256; - fn log_b512(a: B512) -> B512; - fn log_b256_b512(a: b256, b: B512) -> (b256, B512); - fn log_vec_u8(a: Vec) -> Vec; - fn log_vec_b256(a: Vec); - fn log_vec_b512(a: Vec); - fn log_u16_vec_u8(a: u16, b: Vec) -> (u16, Vec); - fn log_bytes(a: Bytes) -> Bytes; - fn log_u16_bytes(a: u16, b: Bytes) -> (u16, Bytes); - fn log_std_string(a: String) -> String; - fn log_u16_std_string(a: u16, b: String) -> (u16, String); - fn log_raw_slice(a: raw_slice) -> raw_slice; - fn log_u8_array(a: [u8; 3]) -> [u8; 3]; - fn log_u16_array(a: [u16; 3]) -> [u16; 3]; - fn log_u16_u8_array(a: u16, b: [u8; 3]) -> (u16, [u8; 3]); - fn log_str_4(a: str[4]) -> str[4]; - fn log_u8_str_2(a: u8, b: str[2]) -> (u8, str[2]); - fn log_u8_u16_tuple(a: (u8, u16)) -> (u8, u16); - fn log_boolean_u8_vec_tuple(a: (bool, Vec)) -> (bool, Vec); - fn log_enum(a: MyEnum) -> MyEnum; - fn log_native_enum(a: MyNativeEnum) -> MyNativeEnum; - fn log_boolean_enum(a: bool, b: MyEnum) -> (bool, MyEnum); - fn log_struct(a: MyStruct) -> MyStruct; - fn log_struct_vec(a: Vec) -> Vec; - fn log_struct_boolean(a: MyStruct, b: bool) -> (MyStruct, bool); - fn log_option_u8(a: Option) -> Option; - fn log_option_vec_u16(a: Option>) -> Option>; - fn log_str_slice(a: str) -> str; -} - -impl LoggingContract for Contract { - fn log_u8(a: u8) -> u8 { - log(a); - a - } - - fn log_u16(a: u16) -> u16 { - log(a); - a - } - - fn log_u32(a: u32) -> u32 { - log(a); - a - } - - fn log_u8_u16_u32(a: u8, b: u16, c: u32) -> (u8, u16, u32) { - log(a); - log(b); - log(c); - (a, b, c) - } - - fn log_u64(a: u64) -> u64 { - log(a); - a - } - - fn log_u256(a: u256) -> u256 { - log(a); - a - } - - fn log_u64_u8(a: u64, b: u8) -> (u64, u8) { - log(a); - log(b); - (a, b) - } - - fn log_boolean(a: bool) -> bool { - log(a); - a - } - - fn log_boolean_boolean(a: bool, b: bool) -> (bool, bool) { - log(a); - log(b); - (a, b) - } - - fn log_number_boolean(a: u32, b: bool) -> (u32, bool) { - log(a); - log(b); - (a, b) - } - - fn log_b256(a: b256) -> b256 { - log(a); - a - } - - fn log_b512(a: B512) -> B512 { - log(a); - a - } - - fn log_b256_b512(a: b256, b: B512) -> (b256, B512) { - log(a); - log(b); - (a, b) - } - - fn log_vec_u8(a: Vec) -> Vec { - log(a); - a - } - - fn log_vec_b256(a: Vec) { - log(a); - } - - fn log_vec_b512(a: Vec) { - log(a); - } - - fn log_bytes(a: Bytes) -> Bytes { - log(a); - a - } - - fn log_std_string(a: String) -> String { - log(a); - a - } - - fn log_u16_vec_u8(a: u16, b: Vec) -> (u16, Vec) { - log(a); - log(b); - (a, b) - } - - fn log_u16_bytes(a: u16, b: Bytes) -> (u16, Bytes) { - log(a); - log(b); - (a, b) - } - - fn log_u16_std_string(a: u16, b: String) -> (u16, String) { - log(a); - log(b); - (a, b) - } - - fn log_raw_slice(a: raw_slice) -> raw_slice { - log(a); - a - } - - fn log_u8_array(a: [u8; 3]) -> [u8; 3] { - log(a); - a - } - - fn log_u16_array(a: [u16; 3]) -> [u16; 3] { - log(a); - a - } - - fn log_u16_u8_array(a: u16, b: [u8; 3]) -> (u16, [u8; 3]) { - log(a); - log(b); - (a, b) - } - - fn log_str_4(a: str[4]) -> str[4] { - log(a); - a - } - - fn log_u8_str_2(a: u8, b: str[2]) -> (u8, str[2]) { - log(a); - log(b); - (a, b) - } - - fn log_u8_u16_tuple(a: (u8, u16)) -> (u8, u16) { - log(a); - a - } - - fn log_boolean_u8_vec_tuple(a: (bool, Vec)) -> (bool, Vec) { - log(a); - a - } - - fn log_enum(a: MyEnum) -> MyEnum { - log(a); - a - } - - fn log_native_enum(a: MyNativeEnum) -> MyNativeEnum { - log(a); - a - } - - fn log_boolean_enum(a: bool, b: MyEnum) -> (bool, MyEnum) { - log(a); - log(b); - (a, b) - } - - fn log_struct(a: MyStruct) -> MyStruct { - log(a); - a - } - - fn log_struct_vec(a: Vec) -> Vec { - log(a); - a - } - - fn log_struct_boolean(a: MyStruct, b: bool) -> (MyStruct, bool) { - log(a); - log(b); - (a, b) - } - - fn log_option_u8(a: Option) -> Option { - log(a); - a - } - - fn log_option_vec_u16(a: Option>) -> Option> { - log(a); - a - } - - fn log_str_slice(a: str) -> str { - log(a); - a - } -} diff --git a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/predicate-echo/Forc.toml b/packages/fuel-gauge/test/fixtures/forc-projects-experimental/predicate-echo/Forc.toml deleted file mode 100644 index a17df04822d..00000000000 --- a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/predicate-echo/Forc.toml +++ /dev/null @@ -1,7 +0,0 @@ -[project] -authors = ["Fuel Labs "] -entry = "main.sw" -license = "Apache-2.0" -name = "predicate-echo" - -[dependencies] diff --git a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/predicate-echo/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects-experimental/predicate-echo/src/main.sw deleted file mode 100644 index 2e13f3d402f..00000000000 --- a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/predicate-echo/src/main.sw +++ /dev/null @@ -1,65 +0,0 @@ -predicate; - -use std::b512::B512; -use std::string::String; -use std::option::Option; -use std::bytes::Bytes; -use std::vec::Vec; - -enum NativeEnum { - Checked: (), - Pending: (), -} - -enum MixedEnum { - Value: bool, - Data: u16, -} - -struct DeeperStruct { - a: u8, - b: u16, - c: u32, - d: u64, - e: u256, - f: b256, - g: B512, - native: NativeEnum, - mixed: MixedEnum, - grades: [u8; 4], - fuel: str[4], - hello: String, - opt: Option, - nada: Option, - bytes: Bytes, - tuple: (u8, u16, u32, str[4]), - vec_u8: Vec, -} - -struct MixedStruct { - a: u8, - b: u16, - c: u32, - d: u64, - e: u256, - f: b256, - g: B512, - native: NativeEnum, - mixed: MixedEnum, - grades: [u8; 4], - fuel: str[4], - hello: String, - opt: Option, - nada: Option, - bytes: Bytes, - tuple: (u8, u16, u32, str[4]), - vec_u8: Vec, - deep: DeeperStruct, -} - -fn main(param: MixedStruct) -> bool { - if (param.deep.d == 18446744073709551615) { - return true; - } - return false; -} diff --git a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-echo/Forc.toml b/packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-echo/Forc.toml deleted file mode 100644 index 34b6fef5427..00000000000 --- a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-echo/Forc.toml +++ /dev/null @@ -1,7 +0,0 @@ -[project] -authors = ["Fuel Labs "] -entry = "main.sw" -license = "Apache-2.0" -name = "script-echo" - -[dependencies] diff --git a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-echo/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-echo/src/main.sw deleted file mode 100644 index 7a274d55355..00000000000 --- a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-echo/src/main.sw +++ /dev/null @@ -1,62 +0,0 @@ -script; - -use std::b512::B512; -use std::string::String; -use std::option::Option; -use std::bytes::Bytes; -use std::vec::Vec; - -enum NativeEnum { - Checked: (), - Pending: (), -} - -enum MixedEnum { - Value: bool, - Data: u16, -} - -struct DeeperStruct { - a: u8, - b: u16, - c: u32, - d: u64, - e: u256, - f: b256, - g: B512, - native: NativeEnum, - mixed: MixedEnum, - grades: [u8; 4], - fuel: str[4], - hello: String, - opt: Option, - nada: Option, - bytes: Bytes, - tuple: (u8, u16, u32, str[4]), - vec_u8: Vec, -} - -struct MixedStruct { - a: u8, - b: u16, - c: u32, - d: u64, - e: u256, - f: b256, - g: B512, - native: NativeEnum, - mixed: MixedEnum, - grades: [u8; 4], - fuel: str[4], - hello: String, - opt: Option, - nada: Option, - bytes: Bytes, - tuple: (u8, u16, u32, str[4]), - vec_u8: Vec, - deep: DeeperStruct, -} - -fn main(param: MixedStruct) -> MixedStruct { - param -} diff --git a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-print/Forc.toml b/packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-print/Forc.toml deleted file mode 100644 index 647a1bd0549..00000000000 --- a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-print/Forc.toml +++ /dev/null @@ -1,7 +0,0 @@ -[project] -authors = ["Fuel Labs "] -entry = "main.sw" -license = "Apache-2.0" -name = "script-print" - -[dependencies] diff --git a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-print/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-print/src/main.sw deleted file mode 100644 index 9b97833f77f..00000000000 --- a/packages/fuel-gauge/test/fixtures/forc-projects-experimental/script-print/src/main.sw +++ /dev/null @@ -1,112 +0,0 @@ -script; - -use std::b512::B512; -use std::string::String; -use std::option::Option; -use std::bytes::Bytes; -use std::vec::Vec; - -enum NativeEnum { - Checked: (), - Pending: (), -} - -enum MixedEnum { - Value: bool, - Data: u16, -} - -struct DeeperStruct { - a: u8, - b: u16, - c: u32, - d: u64, - e: u256, - f: b256, - g: B512, - native: NativeEnum, - mixed: MixedEnum, - grades: [u8; 4], - fuel: str[4], - hello: String, - opt: Option, - nada: Option, - bytes: Bytes, - tuple: (u8, u16, u32, str[4]), - vec_u8: Vec, -} - -struct MixedStruct { - a: u8, - b: u16, - c: u32, - d: u64, - e: u256, - f: b256, - g: B512, - native: NativeEnum, - mixed: MixedEnum, - grades: [u8; 4], - fuel: str[4], - hello: String, - opt: Option, - nada: Option, - bytes: Bytes, - tuple: (u8, u16, u32, str[4]), - vec_u8: Vec, - deep: DeeperStruct, -} - -fn main(param_one: B512) -> MixedStruct { - let mut my_bytes = Bytes::new(); - - my_bytes.push(40u8); - my_bytes.push(41u8); - my_bytes.push(42u8); - - let mut my_vec_u8 = Vec::new(); - my_vec_u8.push(40u8); - my_vec_u8.push(41u8); - my_vec_u8.push(42u8); - - let my_struct = MixedStruct { - a: 255, - b: 65535, - c: 4294967295, - d: 18446744073709551615, - e: 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFu256, - f: 0xbebd3baab326f895289ecbd4210cf886ce41952316441ae4cac35f00f0e882a6, - g: param_one, - native: NativeEnum::Pending, - mixed: MixedEnum::Value(true), - grades: [1, 4, 6, 22], - fuel: __to_str_array("fuel"), - hello: String::from_ascii_str("Hello World"), - opt: Option::Some(42), - nada: Option::None, - bytes: my_bytes, - tuple: (255, 65535, 4294967295, __to_str_array("fuel")), - vec_u8: my_vec_u8, - deep: DeeperStruct { - a: 255, - b: 65535, - c: 4294967295, - d: 18446744073709551615, - e: 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFu256, - f: 0xbebd3baab326f895289ecbd4210cf886ce41952316441ae4cac35f00f0e882a6, - g: param_one, - native: NativeEnum::Pending, - mixed: MixedEnum::Value(true), - grades: [1, 4, 6, 22], - fuel: __to_str_array("fuel"), - hello: String::from_ascii_str("Hello World"), - opt: Option::Some(42), - nada: Option::None, - bytes: my_bytes, - tuple: (255, 65535, 4294967295, __to_str_array("fuel")), - vec_u8: my_vec_u8, - }, - }; - - my_struct -} diff --git a/packages/fuels/CHANGELOG.md b/packages/fuels/CHANGELOG.md index 53c3a090d2f..93c34c69648 100644 --- a/packages/fuels/CHANGELOG.md +++ b/packages/fuels/CHANGELOG.md @@ -1,5 +1,34 @@ # Change Log +## 0.86.0 + +### Patch Changes + +- 8866c09: fix: ignore libraries in `fuels` CLI +- Updated dependencies [316c757] +- Updated dependencies [ee969d3] +- Updated dependencies [16196b6] +- Updated dependencies [0651a5f] +- Updated dependencies [64e9659] + - @fuel-ts/account@0.86.0 + - @fuel-ts/crypto@0.86.0 + - @fuel-ts/utils@0.86.0 + - @fuel-ts/errors@0.86.0 + - @fuel-ts/abi-coder@0.86.0 + - @fuel-ts/transactions@0.86.0 + - @fuel-ts/versions@0.86.0 + - @fuel-ts/program@0.86.0 + - @fuel-ts/script@0.86.0 + - @fuel-ts/forc@0.86.0 + - @fuel-ts/contract@0.86.0 + - @fuel-ts/address@0.86.0 + - @fuel-ts/hasher@0.86.0 + - @fuel-ts/abi-typegen@0.86.0 + - @fuel-ts/math@0.86.0 + - @fuel-ts/merkle@0.86.0 + - @fuel-ts/fuel-core@0.86.0 + - @fuel-ts/interfaces@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/fuels/package.json b/packages/fuels/package.json index 53ac54f298c..74d8e1c96c8 100644 --- a/packages/fuels/package.json +++ b/packages/fuels/package.json @@ -1,6 +1,6 @@ { "name": "fuels", - "version": "0.85.0", + "version": "0.86.0", "description": "Fuel TS SDK", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/hasher/CHANGELOG.md b/packages/hasher/CHANGELOG.md index 6a28ab6da4d..1d5ccf9753f 100644 --- a/packages/hasher/CHANGELOG.md +++ b/packages/hasher/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## 0.86.0 + +### Patch Changes + +- Updated dependencies [316c757] +- Updated dependencies [0651a5f] + - @fuel-ts/crypto@0.86.0 + - @fuel-ts/utils@0.86.0 + - @fuel-ts/interfaces@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/hasher/package.json b/packages/hasher/package.json index 2ef71198de6..d092066ca6e 100644 --- a/packages/hasher/package.json +++ b/packages/hasher/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/hasher", - "version": "0.85.0", + "version": "0.86.0", "description": "Sha256 hash utility for Fuel", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/interfaces/CHANGELOG.md b/packages/interfaces/CHANGELOG.md index 1819372a3b8..c5547f95591 100644 --- a/packages/interfaces/CHANGELOG.md +++ b/packages/interfaces/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.86.0 + ## 0.85.0 ## 0.84.0 diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index bb6ca7f8660..2c10703059a 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/interfaces", - "version": "0.85.0", + "version": "0.86.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/math/CHANGELOG.md b/packages/math/CHANGELOG.md index d51f48a66b1..11b48d61a30 100644 --- a/packages/math/CHANGELOG.md +++ b/packages/math/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## 0.86.0 + +### Patch Changes + +- Updated dependencies [316c757] + - @fuel-ts/errors@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/math/package.json b/packages/math/package.json index 2fa70a4204d..a53bff06817 100644 --- a/packages/math/package.json +++ b/packages/math/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/math", - "version": "0.85.0", + "version": "0.86.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/merkle/CHANGELOG.md b/packages/merkle/CHANGELOG.md index 9da51e73a39..807a6ea50d8 100644 --- a/packages/merkle/CHANGELOG.md +++ b/packages/merkle/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## 0.86.0 + +### Patch Changes + +- @fuel-ts/hasher@0.86.0 +- @fuel-ts/math@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/merkle/package.json b/packages/merkle/package.json index 5b60776f54e..61122fc1f8f 100644 --- a/packages/merkle/package.json +++ b/packages/merkle/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/merkle", - "version": "0.85.0", + "version": "0.86.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/program/CHANGELOG.md b/packages/program/CHANGELOG.md index a9c73aaafb9..490106f1739 100644 --- a/packages/program/CHANGELOG.md +++ b/packages/program/CHANGELOG.md @@ -1,5 +1,24 @@ # Change Log +## 0.86.0 + +### Patch Changes + +- 64e9659: feat!: upgrade `forc@0.58.0` and remove `V0` encoding +- Updated dependencies [316c757] +- Updated dependencies [ee969d3] +- Updated dependencies [16196b6] +- Updated dependencies [0651a5f] +- Updated dependencies [64e9659] + - @fuel-ts/account@0.86.0 + - @fuel-ts/utils@0.86.0 + - @fuel-ts/errors@0.86.0 + - @fuel-ts/abi-coder@0.86.0 + - @fuel-ts/transactions@0.86.0 + - @fuel-ts/address@0.86.0 + - @fuel-ts/math@0.86.0 + - @fuel-ts/interfaces@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/program/package.json b/packages/program/package.json index 46b2879b9d5..578e8ed7256 100644 --- a/packages/program/package.json +++ b/packages/program/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/program", - "version": "0.85.0", + "version": "0.86.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/program/src/contract-call-script.ts b/packages/program/src/contract-call-script.ts index 7551d28188c..1d892d65c77 100644 --- a/packages/program/src/contract-call-script.ts +++ b/packages/program/src/contract-call-script.ts @@ -1,13 +1,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import type { EncodingVersion } from '@fuel-ts/abi-coder'; import { WORD_SIZE, B256Coder, ASSET_ID_LEN, BigNumberCoder, CONTRACT_ID_LEN, - ENCODING_V1, - ENCODING_V0, } from '@fuel-ts/abi-coder'; import type { CallResult, @@ -26,12 +23,7 @@ import * as asm from '@fuels/vm-asm'; import { InstructionSet } from './instruction-set'; import type { EncodedScriptCall, ScriptResult } from './script-request'; -import { - decodeCallResult, - ScriptRequest, - POINTER_DATA_OFFSET, - calculateScriptDataBaseOffset, -} from './script-request'; +import { decodeCallResult, ScriptRequest, calculateScriptDataBaseOffset } from './script-request'; import type { ContractCall, InvocationScopeLike } from './types'; type CallOpcodeParamsOffset = { @@ -41,17 +33,6 @@ type CallOpcodeParamsOffset = { assetIdOffset: number; }; -type CallOutputInfo = { - isHeap: boolean; - encodedLength: number; - encoding: EncodingVersion; -}; - -type ContractCallScriptFn = ( - call: ContractCall, - segmentOffset: number -) => { scriptData: Uint8Array[]; callParamOffsets: CallOpcodeParamsOffset }; - const DEFAULT_OPCODE_PARAMS: CallOpcodeParamsOffset = { assetIdOffset: 0, amountOffset: 0, @@ -72,10 +53,12 @@ const SCRIPT_WRAPPER_CONTRACT_ID = ZeroBytes32; // 0x13 Gas forwarded // // These are arbitrary non-reserved registers, no special meaning -const getSingleCallInstructions = ( - { callDataOffset, gasForwardedOffset, amountOffset, assetIdOffset }: CallOpcodeParamsOffset, - outputInfo: CallOutputInfo -): InstructionSet => { +const getSingleCallInstructions = ({ + callDataOffset, + gasForwardedOffset, + amountOffset, + assetIdOffset, +}: CallOpcodeParamsOffset): InstructionSet => { const inst = new InstructionSet( asm.movi(0x10, callDataOffset), asm.movi(0x11, amountOffset), @@ -93,36 +76,17 @@ const getSingleCallInstructions = ( inst.push(asm.call(0x10, 0x11, 0x12, asm.RegId.cgas().to_u8())); } - if (outputInfo.encoding === ENCODING_V0 && outputInfo.isHeap) { - inst.extend([ - // The RET register contains the pointer address of the `CALL` return (a stack - // address). - // The RETL register contains the length of the `CALL` return (=24 because the Vec/Bytes - // struct takes 3 WORDs). We don't actually need it unless the Vec/Bytes struct encoding - // changes in the compiler. - // Load the word located at the address contained in RET, it's a word that - // translates to a heap address. 0x15 is a free register. - asm.lw(0x15, asm.RegId.ret().to_u8(), 0), - // We know a Vec/Bytes struct has its third WORD contain the length of the underlying - // vector, so use a 2 offset to store the length in 0x16, which is a free register. - asm.lw(0x16, asm.RegId.ret().to_u8(), 2), - // The in-memory size of the type is (in-memory size of the inner type) * length - asm.muli(0x16, 0x16, outputInfo.encodedLength), - asm.retd(0x15, 0x16), - ]); - } - return inst; }; // Given a list of contract calls, create the actual opcodes used to call the contract -function getInstructions(offsets: CallOpcodeParamsOffset[], outputs: CallOutputInfo[]): Uint8Array { +function getInstructions(offsets: CallOpcodeParamsOffset[]): Uint8Array { if (!offsets.length) { return new Uint8Array(); } const multiCallInstructions = new InstructionSet(); for (let i = 0; i < offsets.length; i += 1) { - multiCallInstructions.extend(getSingleCallInstructions(offsets[i], outputs[i]).entries()); + multiCallInstructions.extend(getSingleCallInstructions(offsets[i]).entries()); } multiCallInstructions.push(asm.ret(0x01)); @@ -143,53 +107,42 @@ const getMainCallReceipt = ( type === ReceiptType.Call && from === SCRIPT_WRAPPER_CONTRACT_ID && to === contractId ); -const scriptResultDecoder = - (contractId: AbstractAddress, isOutputDataHeap: boolean) => (result: ScriptResult) => { - if (toNumber(result.code) !== 0) { - throw new FuelError(ErrorCode.SCRIPT_REVERTED, `Transaction reverted.`); - } +const scriptResultDecoder = (contractId: AbstractAddress) => (result: ScriptResult) => { + if (toNumber(result.code) !== 0) { + throw new FuelError(ErrorCode.SCRIPT_REVERTED, `Transaction reverted.`); + } - const mainCallResult = getMainCallReceipt( - result.receipts as TransactionResultCallReceipt[], - contractId.toB256() - ); - const mainCallInstructionStart = bn(mainCallResult?.is); - - const receipts = result.receipts as ReturnReceipt[]; - return receipts - .filter(({ type }) => isReturnType(type)) - .flatMap((receipt: ReturnReceipt, index, filtered) => { - if (!mainCallInstructionStart.eq(bn(receipt.is))) { - return []; - } - if (receipt.type === ReceiptType.Return) { - return [ - new BigNumberCoder('u64').encode((receipt as TransactionResultReturnReceipt).val), - ]; - } - if (receipt.type === ReceiptType.ReturnData) { - const encodedScriptReturn = arrayify(receipt.data); - if (isOutputDataHeap && isReturnType(filtered[index + 1]?.type)) { - const nextReturnData: TransactionResultReturnDataReceipt = filtered[ - index + 1 - ] as TransactionResultReturnDataReceipt; - return concat([encodedScriptReturn, arrayify(nextReturnData.data)]); - } - - return [encodedScriptReturn]; - } + const mainCallResult = getMainCallReceipt( + result.receipts as TransactionResultCallReceipt[], + contractId.toB256() + ); + const mainCallInstructionStart = bn(mainCallResult?.is); + + const receipts = result.receipts as ReturnReceipt[]; + return receipts + .filter(({ type }) => isReturnType(type)) + .flatMap((receipt: ReturnReceipt) => { + if (!mainCallInstructionStart.eq(bn(receipt.is))) { + return []; + } + if (receipt.type === ReceiptType.Return) { + return [new BigNumberCoder('u64').encode((receipt as TransactionResultReturnReceipt).val)]; + } + if (receipt.type === ReceiptType.ReturnData) { + const encodedScriptReturn = arrayify(receipt.data); - return [new Uint8Array()]; - }); - }; + return [encodedScriptReturn]; + } + + return [new Uint8Array()]; + }); +}; export const decodeContractCallScriptResult = ( callResult: CallResult, contractId: AbstractAddress, - isOutputDataHeap: boolean, logs: Array = [] -): Uint8Array[] => - decodeCallResult(callResult, scriptResultDecoder(contractId, isOutputDataHeap), logs); +): Uint8Array[] => decodeCallResult(callResult, scriptResultDecoder(contractId), logs); const getCallInstructionsLength = (contractCalls: ContractCall[]): number => contractCalls.reduce( @@ -198,156 +151,19 @@ const getCallInstructionsLength = (contractCalls: ContractCall[]): number => if (call.gas) { offset.gasForwardedOffset = 1; } - const output: CallOutputInfo = { - isHeap: call.isOutputDataHeap, - encodedLength: call.outputEncodedLength, - encoding: call.encoding ?? ENCODING_V0, - }; - return sum + getSingleCallInstructions(offset, output).byteLength(); + + return sum + getSingleCallInstructions(offset).byteLength(); }, asm.Instruction.size() // placeholder for single RET instruction which is added later ); -const getFunctionOutputInfos = (functionScopes: InvocationScopeLike[]): CallOutputInfo[] => - functionScopes.map((funcScope) => { - const { func } = funcScope.getCallConfig(); - return { - isHeap: func.outputMetadata.isHeapType, - encodedLength: func.outputMetadata.encodedLength, - encoding: func.encoding, - }; - }); - -/** - * Obtains script data for a contract call according to the V0 specification. - * - * @param call - the contract call to obtain for script data for. - * @param segmentOffset - the segment to generate pointers and offset data from. - * @returns the populated script data and call parameter offsets. - */ -export const getScriptDataV0: ContractCallScriptFn = ( - call: ContractCall, - segmentOffset: number -): { scriptData: Uint8Array[]; callParamOffsets: CallOpcodeParamsOffset } => { - const scriptData: Uint8Array[] = []; - let gasForwardedSize: number = 0; - - const callParamOffsets: CallOpcodeParamsOffset = { - amountOffset: segmentOffset, - assetIdOffset: segmentOffset + WORD_SIZE, - gasForwardedOffset: call.gas ? segmentOffset + WORD_SIZE + ASSET_ID_LEN : 0, - callDataOffset: segmentOffset + WORD_SIZE + ASSET_ID_LEN + gasForwardedSize, - }; - - // 1. Amount - scriptData.push(new BigNumberCoder('u64').encode(call.amount || 0)); - // 2. Asset ID - scriptData.push(new B256Coder().encode(call.assetId?.toString() || ZeroBytes32)); - // 3. Contract ID - scriptData.push(call.contractId.toBytes()); - // 4. Function selector - scriptData.push(new BigNumberCoder('u64').encode(call.fnSelector)); - // 5. Gas to be forwarded - if (call.gas) { - scriptData.push(new BigNumberCoder('u64').encode(call.gas)); - - gasForwardedSize = WORD_SIZE; - } - - // 6. Calldata offset - if (call.isInputDataPointer) { - const pointerInputOffset = segmentOffset + POINTER_DATA_OFFSET + gasForwardedSize; - scriptData.push(new BigNumberCoder('u64').encode(pointerInputOffset)); - } - - // 7. Encoded arguments (optional) (variable length) - const args = arrayify(call.data); - scriptData.push(args); - - return { - scriptData, - callParamOffsets, - }; -}; - -/** - * Obtains script data for a contract call according to the V1 specification. - * - * @param call - the contract call to obtain for script data for. - * @param segmentOffset - the segment to generate pointers and offset data from. - * @returns the populated script data and call parameter offsets. - */ -export const getScriptDataV1: ContractCallScriptFn = ( - call: ContractCall, - segmentOffset: number -): { scriptData: Uint8Array[]; callParamOffsets: CallOpcodeParamsOffset } => { - const scriptData: Uint8Array[] = []; - - const amountOffset = segmentOffset; - const assetIdOffset = amountOffset + WORD_SIZE; - const callDataOffset = assetIdOffset + ASSET_ID_LEN; - const encodedSelectorOffset = callDataOffset + CONTRACT_ID_LEN + WORD_SIZE + WORD_SIZE; - const encodedArgsOffset = encodedSelectorOffset + call.fnSelectorBytes.byteLength; - const encodedArgs = arrayify(call.data); - let gasForwardedOffset = 0; - - // 1. Amount - scriptData.push(new BigNumberCoder('u64').encode(call.amount || 0)); - // 2. Asset ID - scriptData.push(new B256Coder().encode(call.assetId?.toString() || ZeroBytes32)); - // 3. Contract ID - scriptData.push(call.contractId.toBytes()); - // 4. Function selector offset - scriptData.push(new BigNumberCoder('u64').encode(encodedSelectorOffset)); - // 5. Encoded argument offset - scriptData.push(new BigNumberCoder('u64').encode(encodedArgsOffset)); - // 6. Encoded function selector - scriptData.push(call.fnSelectorBytes); - // 7. Encoded arguments - scriptData.push(encodedArgs); - - // 8. Gas to be forwarded - if (call.gas) { - scriptData.push(new BigNumberCoder('u64').encode(call.gas)); - gasForwardedOffset = encodedArgsOffset + encodedArgs.byteLength; - } - - const callParamOffsets: CallOpcodeParamsOffset = { - amountOffset, - assetIdOffset, - gasForwardedOffset, - callDataOffset, - }; - - return { - scriptData, - callParamOffsets, - }; -}; - -/** - * Retrieves a script data function for a specific encoding version. - * - * @param encoding - the encoding version used for the contract call. - * @returns an appropriate script data function. - */ -export const getScriptDataForEncoding = (encoding?: string): ContractCallScriptFn => { - if (encoding === ENCODING_V1) { - return getScriptDataV1; - } - return getScriptDataV0; -}; - export const getContractCallScript = ( functionScopes: InvocationScopeLike[], maxInputs: BN ): ScriptRequest => new ScriptRequest( // Script to call the contract, start with stub size matching length of calls - getInstructions( - new Array(functionScopes.length).fill(DEFAULT_OPCODE_PARAMS), - getFunctionOutputInfos(functionScopes) - ), + getInstructions(new Array(functionScopes.length).fill(DEFAULT_OPCODE_PARAMS)), (contractCalls): EncodedScriptCall => { const TOTAL_CALLS = contractCalls.length; @@ -369,30 +185,55 @@ export const getContractCallScript = ( // The data for each call is ordered into segments const paramOffsets: CallOpcodeParamsOffset[] = []; // the data about the contract output - const outputInfos: CallOutputInfo[] = []; let segmentOffset = dataOffset; const scriptData: Uint8Array[] = []; for (let i = 0; i < TOTAL_CALLS; i += 1) { const call = contractCalls[i]; - const { scriptData: callScriptData, callParamOffsets } = getScriptDataForEncoding( - call.encoding - )(call, segmentOffset); - - // store output and param offsets for asm instructions later - outputInfos.push({ - isHeap: call.isOutputDataHeap, - encodedLength: call.outputEncodedLength, - encoding: call.encoding ?? ENCODING_V0, - }); - scriptData.push(concat(callScriptData)); + const amountOffset = segmentOffset; + const assetIdOffset = amountOffset + WORD_SIZE; + const callDataOffset = assetIdOffset + ASSET_ID_LEN; + const encodedSelectorOffset = callDataOffset + CONTRACT_ID_LEN + WORD_SIZE + WORD_SIZE; + const encodedArgsOffset = encodedSelectorOffset + call.fnSelectorBytes.byteLength; + const encodedArgs = arrayify(call.data); + let gasForwardedOffset = 0; + + // 1. Amount + scriptData.push(new BigNumberCoder('u64').encode(call.amount || 0)); + // 2. Asset ID + scriptData.push(new B256Coder().encode(call.assetId?.toString() || ZeroBytes32)); + // 3. Contract ID + scriptData.push(call.contractId.toBytes()); + // 4. Function selector offset + scriptData.push(new BigNumberCoder('u64').encode(encodedSelectorOffset)); + // 5. Encoded argument offset + scriptData.push(new BigNumberCoder('u64').encode(encodedArgsOffset)); + // 6. Encoded function selector + scriptData.push(call.fnSelectorBytes); + // 7. Encoded arguments + scriptData.push(encodedArgs); + + // 8. Gas to be forwarded + if (call.gas) { + scriptData.push(new BigNumberCoder('u64').encode(call.gas)); + gasForwardedOffset = encodedArgsOffset + encodedArgs.byteLength; + } + + const callParamOffsets: CallOpcodeParamsOffset = { + amountOffset, + assetIdOffset, + gasForwardedOffset, + callDataOffset, + }; + + // store param offsets for asm instructions later paramOffsets.push(callParamOffsets); segmentOffset = dataOffset + concat(scriptData).byteLength; } // get asm instructions - const script = getInstructions(paramOffsets, outputInfos); + const script = getInstructions(paramOffsets); const finalScriptData = concat(scriptData); return { data: finalScriptData, script }; }, diff --git a/packages/program/src/functions/base-invocation-scope.ts b/packages/program/src/functions/base-invocation-scope.ts index 8b94e63077e..43affcdbed3 100644 --- a/packages/program/src/functions/base-invocation-scope.ts +++ b/packages/program/src/functions/base-invocation-scope.ts @@ -19,7 +19,6 @@ import * as asm from '@fuels/vm-asm'; import { clone } from 'ramda'; import { getContractCallScript } from '../contract-call-script'; -import { POINTER_DATA_OFFSET } from '../script-request'; import type { ContractCall, InvocationScopeLike, TxParams } from '../types'; import { assert, getAbisFromAllCalls } from '../utils'; @@ -31,12 +30,9 @@ import { InvocationCallResult, FunctionInvocationResult } from './invocation-res * @param funcScope - The invocation scope containing the necessary information for the contract call. * @returns The contract call object. */ -function createContractCall(funcScope: InvocationScopeLike, offset: number): ContractCall { +function createContractCall(funcScope: InvocationScopeLike): ContractCall { const { program, args, forward, func, callParameters, externalAbis } = funcScope.getCallConfig(); - const DATA_POINTER_OFFSET = funcScope.getCallConfig().func.isInputDataPointer - ? POINTER_DATA_OFFSET - : 0; - const data = func.encodeArguments(args as Array, offset + DATA_POINTER_OFFSET); + const data = func.encodeArguments(args as Array); return { contractId: (program as AbstractContract).id, @@ -44,9 +40,6 @@ function createContractCall(funcScope: InvocationScopeLike, offset: number): Con fnSelectorBytes: func.selectorBytes, encoding: func.encoding, data, - isInputDataPointer: func.isInputDataPointer, - isOutputDataHeap: func.outputMetadata.isHeapType, - outputEncodedLength: func.outputMetadata.encodedLength, assetId: forward?.assetId, amount: forward?.amount, gas: callParameters?.gasLimit, @@ -97,11 +90,7 @@ export class BaseInvocationScope { 'Provider chain info cache is empty. Please make sure to initialize the `Provider` properly by running `await Provider.create()``' ); } - const maxInputs = consensusParams.consensusParameters.txParameters.maxInputs; - const script = getContractCallScript(this.functionInvocationScopes, maxInputs); - return this.functionInvocationScopes.map((funcScope) => - createContractCall(funcScope, script.getScriptDataOffset(maxInputs.toNumber())) - ); + return this.functionInvocationScopes.map((funcScope) => createContractCall(funcScope)); } /** diff --git a/packages/program/src/functions/invocation-results.ts b/packages/program/src/functions/invocation-results.ts index 64b94e765bb..86927ec2151 100644 --- a/packages/program/src/functions/invocation-results.ts +++ b/packages/program/src/functions/invocation-results.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable max-classes-per-file */ -import { ENCODING_V0 } from '@fuel-ts/abi-coder'; import type { CallResult, JsonAbisFromAllCalls, @@ -98,14 +97,9 @@ export class InvocationResult { return callResultToInvocationResult(callResult, callConfig, logs); } - const outputAsIterableHeap = - (callConfig?.func.encoding === ENCODING_V0 && callConfig?.func.outputMetadata.isHeapType) || - false; - const encodedResults = decodeContractCallScriptResult( callResult, (callConfig?.program as AbstractContract).id, - outputAsIterableHeap, logs ); const returnValues = encodedResults.map((encodedResult, i) => { diff --git a/packages/program/src/functions/multicall-scope.ts b/packages/program/src/functions/multicall-scope.ts index 6672439cf94..0c7c9eae898 100644 --- a/packages/program/src/functions/multicall-scope.ts +++ b/packages/program/src/functions/multicall-scope.ts @@ -1,6 +1,4 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { ENCODING_V1 } from '@fuel-ts/abi-coder'; -import { ErrorCode, FuelError } from '@fuel-ts/errors'; import type { AbstractContract } from '@fuel-ts/interfaces'; import { BaseInvocationScope } from './base-invocation-scope'; @@ -21,9 +19,6 @@ export class MultiCallInvocationScope extends BaseInvocationScope constructor(contract: AbstractContract, funcScopes: Array) { super(contract, true); this.addCalls(funcScopes); - if (this.program.interface.jsonAbi.encoding !== ENCODING_V1) { - this.validateHeapTypeReturnCalls(); - } } /** @@ -45,34 +40,4 @@ export class MultiCallInvocationScope extends BaseInvocationScope addCalls(funcScopes: Array) { return super.addCalls(funcScopes); } - - private validateHeapTypeReturnCalls() { - let heapOutputIndex = -1; - let numberOfHeaps = 0; - - this.calls.forEach((call, callIndex) => { - const { isOutputDataHeap } = call; - - if (isOutputDataHeap) { - heapOutputIndex = callIndex; - - if (++numberOfHeaps > 1) { - throw new FuelError( - ErrorCode.INVALID_MULTICALL, - 'A multicall can have only one call that returns a heap type.' - ); - } - } - }); - - const hasHeapTypeReturn = heapOutputIndex !== -1; - const isOnLastCall = heapOutputIndex === this.calls.length - 1; - - if (hasHeapTypeReturn && !isOnLastCall) { - throw new FuelError( - ErrorCode.INVALID_MULTICALL, - 'In a multicall, the contract call returning a heap type must be the last call.' - ); - } - } } diff --git a/packages/program/src/types.ts b/packages/program/src/types.ts index 17d6a32338d..7a7eff538c4 100644 --- a/packages/program/src/types.ts +++ b/packages/program/src/types.ts @@ -14,9 +14,6 @@ export type ContractCall = { fnSelector: string; fnSelectorBytes: Uint8Array; encoding?: EncodingVersion; - isInputDataPointer: boolean; - isOutputDataHeap: boolean; - outputEncodedLength: number; amount?: BigNumberish; assetId?: BytesLike; gas?: BigNumberish; diff --git a/packages/script/CHANGELOG.md b/packages/script/CHANGELOG.md index b103c8c502c..c3bae509574 100644 --- a/packages/script/CHANGELOG.md +++ b/packages/script/CHANGELOG.md @@ -1,5 +1,28 @@ # Change Log +## 0.86.0 + +### Minor Changes + +- 64e9659: feat!: upgrade `forc@0.58.0` and remove `V0` encoding + +### Patch Changes + +- Updated dependencies [316c757] +- Updated dependencies [ee969d3] +- Updated dependencies [16196b6] +- Updated dependencies [0651a5f] +- Updated dependencies [64e9659] + - @fuel-ts/account@0.86.0 + - @fuel-ts/utils@0.86.0 + - @fuel-ts/errors@0.86.0 + - @fuel-ts/abi-coder@0.86.0 + - @fuel-ts/transactions@0.86.0 + - @fuel-ts/program@0.86.0 + - @fuel-ts/address@0.86.0 + - @fuel-ts/math@0.86.0 + - @fuel-ts/interfaces@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/script/package.json b/packages/script/package.json index 17725203929..162fc2c60cc 100644 --- a/packages/script/package.json +++ b/packages/script/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/script", - "version": "0.85.0", + "version": "0.86.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/script/src/script-invocation-scope.ts b/packages/script/src/script-invocation-scope.ts index c0edc844520..4d51a16a33c 100644 --- a/packages/script/src/script-invocation-scope.ts +++ b/packages/script/src/script-invocation-scope.ts @@ -3,7 +3,6 @@ import type { Provider } from '@fuel-ts/account'; import { FuelError } from '@fuel-ts/errors'; import type { AbstractScript } from '@fuel-ts/interfaces'; import { ScriptRequest, FunctionInvocationScope } from '@fuel-ts/program'; -import { ByteArrayCoder } from '@fuel-ts/transactions'; export class ScriptInvocationScope< TArgs extends Array = Array, @@ -31,16 +30,9 @@ export class ScriptInvocationScope< ); } - const maxInputs = chainInfoCache.consensusParameters.txParameters.maxInputs.toNumber(); - - const byteLength = new ByteArrayCoder(programBytes.length).encodedLength; this.scriptRequest = new ScriptRequest( programBytes, - (args: TArgs) => - this.func.encodeArguments( - args, - ScriptRequest.getScriptDataOffsetWithScriptBytes(byteLength, maxInputs) - ), + (args: TArgs) => this.func.encodeArguments(args), () => [] as unknown as TReturn ); } diff --git a/packages/transactions/CHANGELOG.md b/packages/transactions/CHANGELOG.md index d52fdae122a..f8338592c7e 100644 --- a/packages/transactions/CHANGELOG.md +++ b/packages/transactions/CHANGELOG.md @@ -1,5 +1,22 @@ # Change Log +## 0.86.0 + +### Patch Changes + +- 64e9659: feat!: upgrade `forc@0.58.0` and remove `V0` encoding +- Updated dependencies [316c757] +- Updated dependencies [16196b6] +- Updated dependencies [0651a5f] +- Updated dependencies [64e9659] + - @fuel-ts/utils@0.86.0 + - @fuel-ts/errors@0.86.0 + - @fuel-ts/abi-coder@0.86.0 + - @fuel-ts/address@0.86.0 + - @fuel-ts/hasher@0.86.0 + - @fuel-ts/math@0.86.0 + - @fuel-ts/interfaces@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/transactions/package.json b/packages/transactions/package.json index 11a97821ba5..c0f7d5a6ad0 100644 --- a/packages/transactions/package.json +++ b/packages/transactions/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/transactions", - "version": "0.85.0", + "version": "0.86.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/transactions/src/coders/input.ts b/packages/transactions/src/coders/input.ts index 366ea315901..a5a227e751e 100644 --- a/packages/transactions/src/coders/input.ts +++ b/packages/transactions/src/coders/input.ts @@ -65,12 +65,12 @@ export class InputCoinCoder extends Coder { const parts: Uint8Array[] = []; parts.push(new B256Coder().encode(value.txID)); - parts.push(new NumberCoder('u16').encode(value.outputIndex)); + parts.push(new NumberCoder('u16', { padToWordSize: true }).encode(value.outputIndex)); parts.push(new B256Coder().encode(value.owner)); parts.push(new BigNumberCoder('u64').encode(value.amount)); parts.push(new B256Coder().encode(value.assetId)); parts.push(new TxPointerCoder().encode(value.txPointer)); - parts.push(new NumberCoder('u16').encode(value.witnessIndex)); + parts.push(new NumberCoder('u16', { padToWordSize: true }).encode(value.witnessIndex)); parts.push(new BigNumberCoder('u64').encode(value.predicateGasUsed)); parts.push(new BigNumberCoder('u64').encode(value.predicateLength)); parts.push(new BigNumberCoder('u64').encode(value.predicateDataLength)); @@ -88,7 +88,7 @@ export class InputCoinCoder extends Coder { [decoded, o] = new B256Coder().decode(data, o); const txID = decoded; - [decoded, o] = new NumberCoder('u16').decode(data, o); + [decoded, o] = new NumberCoder('u16', { padToWordSize: true }).decode(data, o); const outputIndex = decoded; [decoded, o] = new B256Coder().decode(data, o); const owner = decoded; @@ -98,7 +98,7 @@ export class InputCoinCoder extends Coder { const assetId = decoded; [decoded, o] = new TxPointerCoder().decode(data, o); const txPointer = decoded; - [decoded, o] = new NumberCoder('u16').decode(data, o); + [decoded, o] = new NumberCoder('u16', { padToWordSize: true }).decode(data, o); const witnessIndex = Number(decoded); [decoded, o] = new BigNumberCoder('u64').decode(data, o); const predicateGasUsed = decoded; @@ -163,7 +163,7 @@ export class InputContractCoder extends Coder { const parts: Uint8Array[] = []; parts.push(new B256Coder().encode(value.txID)); - parts.push(new NumberCoder('u16').encode(value.outputIndex)); + parts.push(new NumberCoder('u16', { padToWordSize: true }).encode(value.outputIndex)); parts.push(new B256Coder().encode(value.balanceRoot)); parts.push(new B256Coder().encode(value.stateRoot)); parts.push(new TxPointerCoder().encode(value.txPointer)); @@ -178,7 +178,7 @@ export class InputContractCoder extends Coder { [decoded, o] = new B256Coder().decode(data, o); const txID = decoded; - [decoded, o] = new NumberCoder('u16').decode(data, o); + [decoded, o] = new NumberCoder('u16', { padToWordSize: true }).decode(data, o); const outputIndex = decoded; [decoded, o] = new B256Coder().decode(data, o); const balanceRoot = decoded; @@ -277,7 +277,7 @@ export class InputMessageCoder extends Coder { parts.push(new ByteArrayCoder(32).encode(value.recipient)); parts.push(new BigNumberCoder('u64').encode(value.amount)); parts.push(new ByteArrayCoder(32).encode(value.nonce)); - parts.push(new NumberCoder('u16').encode(value.witnessIndex)); + parts.push(new NumberCoder('u16', { padToWordSize: true }).encode(value.witnessIndex)); parts.push(new BigNumberCoder('u64').encode(value.predicateGasUsed)); parts.push(new BigNumberCoder('u64').encode(data.length)); parts.push(new BigNumberCoder('u64').encode(value.predicateLength)); @@ -311,11 +311,11 @@ export class InputMessageCoder extends Coder { const amount = decoded; [decoded, o] = new B256Coder().decode(data, o); const nonce = decoded; - [decoded, o] = new NumberCoder('u16').decode(data, o); + [decoded, o] = new NumberCoder('u16', { padToWordSize: true }).decode(data, o); const witnessIndex = Number(decoded); [decoded, o] = new BigNumberCoder('u64').decode(data, o); const predicateGasUsed = decoded; - [decoded, o] = new NumberCoder('u32').decode(data, o); + [decoded, o] = new NumberCoder('u32', { padToWordSize: true }).decode(data, o); const dataLength = decoded; [decoded, o] = new BigNumberCoder('u64').decode(data, o); const predicateLength = decoded; @@ -359,7 +359,7 @@ export class InputCoder extends Coder { encode(value: Input): Uint8Array { const parts: Uint8Array[] = []; - parts.push(new NumberCoder('u8').encode(value.type)); + parts.push(new NumberCoder('u8', { padToWordSize: true }).encode(value.type)); const { type } = value; @@ -391,7 +391,7 @@ export class InputCoder extends Coder { let decoded; let o = offset; - [decoded, o] = new NumberCoder('u8').decode(data, o); + [decoded, o] = new NumberCoder('u8', { padToWordSize: true }).decode(data, o); const type = decoded as InputType; switch (type) { case InputType.Coin: { diff --git a/packages/transactions/src/coders/output.ts b/packages/transactions/src/coders/output.ts index fb086db0541..8110df38f84 100644 --- a/packages/transactions/src/coders/output.ts +++ b/packages/transactions/src/coders/output.ts @@ -78,7 +78,7 @@ export class OutputContractCoder extends Coder { encode(value: OutputContract): Uint8Array { const parts: Uint8Array[] = []; - parts.push(new NumberCoder('u8').encode(value.inputIndex)); + parts.push(new NumberCoder('u8', { padToWordSize: true }).encode(value.inputIndex)); parts.push(new B256Coder().encode(value.balanceRoot)); parts.push(new B256Coder().encode(value.stateRoot)); @@ -89,7 +89,7 @@ export class OutputContractCoder extends Coder { let decoded; let o = offset; - [decoded, o] = new NumberCoder('u8').decode(data, o); + [decoded, o] = new NumberCoder('u8', { padToWordSize: true }).decode(data, o); const inputIndex = decoded; [decoded, o] = new B256Coder().decode(data, o); const balanceRoot = decoded; @@ -264,7 +264,7 @@ export class OutputCoder extends Coder { encode(value: Output): Uint8Array { const parts: Uint8Array[] = []; - parts.push(new NumberCoder('u8').encode(value.type)); + parts.push(new NumberCoder('u8', { padToWordSize: true }).encode(value.type)); const { type } = value; @@ -304,7 +304,7 @@ export class OutputCoder extends Coder { let decoded; let o = offset; - [decoded, o] = new NumberCoder('u8').decode(data, o); + [decoded, o] = new NumberCoder('u8', { padToWordSize: true }).decode(data, o); const type = decoded as OutputType; switch (type) { case OutputType.Coin: { diff --git a/packages/transactions/src/coders/policy.ts b/packages/transactions/src/coders/policy.ts index b7e4ae9a20e..aeb7c03fb8e 100644 --- a/packages/transactions/src/coders/policy.ts +++ b/packages/transactions/src/coders/policy.ts @@ -70,7 +70,7 @@ export class PoliciesCoder extends Coder { break; case PolicyType.Maturity: - parts.push(new NumberCoder('u32').encode(data)); + parts.push(new NumberCoder('u32', { padToWordSize: true }).encode(data)); break; default: { @@ -99,7 +99,10 @@ export class PoliciesCoder extends Coder { } if (policyTypes & PolicyType.Maturity) { - const [maturity, nextOffset] = new NumberCoder('u32').decode(data, o); + const [maturity, nextOffset] = new NumberCoder('u32', { padToWordSize: true }).decode( + data, + o + ); o = nextOffset; policies.push({ type: PolicyType.Maturity, data: maturity }); } diff --git a/packages/transactions/src/coders/receipt.ts b/packages/transactions/src/coders/receipt.ts index e883c85a616..19c4b1970f8 100644 --- a/packages/transactions/src/coders/receipt.ts +++ b/packages/transactions/src/coders/receipt.ts @@ -709,7 +709,7 @@ export class ReceiptMessageOutCoder extends Coder { encode(value: Receipt): Uint8Array { const parts: Uint8Array[] = []; - parts.push(new NumberCoder('u8').encode(value.type)); + parts.push(new NumberCoder('u8', { padToWordSize: true }).encode(value.type)); const { type } = value; @@ -986,7 +986,7 @@ export class ReceiptCoder extends Coder { let decoded; let o = offset; - [decoded, o] = new NumberCoder('u8').decode(data, o); + [decoded, o] = new NumberCoder('u8', { padToWordSize: true }).decode(data, o); const type = decoded as ReceiptType; switch (type) { case ReceiptType.Call: { diff --git a/packages/transactions/src/coders/transaction.test.ts b/packages/transactions/src/coders/transaction.test.ts index c4ca284623e..9f5d654b5bb 100644 --- a/packages/transactions/src/coders/transaction.test.ts +++ b/packages/transactions/src/coders/transaction.test.ts @@ -319,7 +319,7 @@ describe('TransactionCoder', () => { const encoded = hexlify(new TransactionCoder().encode(transaction)); expect(encoded).toEqual( - '0x000000000000000300000000000000000000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b000000000000000500000000000000000000000000000000000000000000000000000000000003e800000000000003e8' + '0x000000000000000300000000000000000000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000500000000000000000000000003e800000000000003e8' ); const [decoded, offset] = new TransactionCoder().decode(arrayify(encoded), 0); @@ -389,7 +389,7 @@ describe('TransactionCoder', () => { const encoded = hexlify(new TransactionCoder().encode(transaction)); expect(encoded).toEqual( - '0x00000000000000030000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b000000000000000700000000000000010000000000000001000000000000000300000000000003e800000000000003e800000000000003e80000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b00000000000000000000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b000000000000000101000000000000000000000000000002010100000000000000000000000000030101010000000000' + '0x00000000000000030000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000700010001000300000000000003e800000000000003e800000000000003e80000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b00000000000000000000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b000000000000000101000000000000000000000000000002010100000000000000000000000000030101010000000000' ); const [decoded, offset] = new TransactionCoder().decode(arrayify(encoded), 0); @@ -426,7 +426,7 @@ describe('TransactionCoder', () => { const encoded = hexlify(new TransactionCoder().encode(transaction)); expect(encoded).toEqual( - '0x0000000000000004d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b00000000000003840000000000000384000000000000038400000000000000030000000000000007000000000000000000000000000000000000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b00000000000003e800000000000003e800000000000003e8' + '0x0000000000000004d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b038403840384000300000007000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b00000000000003e800000000000003e800000000000003e8' ); const [decoded, offset] = new TransactionCoder().decode(arrayify(encoded), 0); @@ -521,7 +521,7 @@ describe('TransactionCoder', () => { const encoded = hexlify(new TransactionCoder().encode(transaction)); expect(encoded).toEqual( - '0x0000000000000004d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000384000000000000038400000000000003840000000000000005000000000000000f000000000000000200000000000000020000000000000003d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b00000000000003e800000000000003e800000000000003e800000000000000200000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b00000000000000000000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000002d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b000000000000000101000000000000000000000000000002010100000000000000000000000000030101010000000000' + '0x0000000000000004d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b03840384038400050000000f000200020003d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b00000000000003e800000000000003e800000000000003e800000000000000200000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b00000000000000000000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000002d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b000000000000000101000000000000000000000000000002010100000000000000000000000000030101010000000000' ); const [decoded, offset] = new TransactionCoder().decode(arrayify(encoded), 0); diff --git a/packages/transactions/src/coders/transaction.ts b/packages/transactions/src/coders/transaction.ts index 740f778a2e8..64f055603f2 100644 --- a/packages/transactions/src/coders/transaction.ts +++ b/packages/transactions/src/coders/transaction.ts @@ -86,10 +86,10 @@ export class TransactionScriptCoder extends Coder { encode(value: Transaction): Uint8Array { const parts: Uint8Array[] = []; - parts.push(new NumberCoder('u8').encode(value.type)); + parts.push(new NumberCoder('u8', { padToWordSize: true }).encode(value.type)); const { type } = value; @@ -641,7 +641,7 @@ export class TransactionCoder extends Coder { let decoded; let o = offset; - [decoded, o] = new NumberCoder('u8').decode(data, o); + [decoded, o] = new NumberCoder('u8', { padToWordSize: true }).decode(data, o); const type = decoded as TransactionType; switch (type) { diff --git a/packages/transactions/src/coders/tx-pointer.ts b/packages/transactions/src/coders/tx-pointer.ts index 5e9f1dbffea..a4cd880f5cc 100644 --- a/packages/transactions/src/coders/tx-pointer.ts +++ b/packages/transactions/src/coders/tx-pointer.ts @@ -14,8 +14,8 @@ export class TxPointerCoder extends StructCoder<{ }> { constructor() { super('TxPointer', { - blockHeight: new NumberCoder('u32'), - txIndex: new NumberCoder('u16'), + blockHeight: new NumberCoder('u32', { padToWordSize: true }), + txIndex: new NumberCoder('u16', { padToWordSize: true }), }); } } diff --git a/packages/transactions/src/coders/upgrade-purpose.test.ts b/packages/transactions/src/coders/upgrade-purpose.test.ts index 4bff302e37d..9c40186179a 100644 --- a/packages/transactions/src/coders/upgrade-purpose.test.ts +++ b/packages/transactions/src/coders/upgrade-purpose.test.ts @@ -23,7 +23,7 @@ describe('UpgradePurposeCoder', () => { }; const typeBytes = [0, 0, 0, 0, 0, 0, 0, UpgradePurposeTypeEnum.ConsensusParameters]; - const witnessIndexBytes = new NumberCoder('u8').encode(witnessIndex); + const witnessIndexBytes = new NumberCoder('u8', { padToWordSize: true }).encode(witnessIndex); const checksumBytes = new B256Coder().encode(checksum); const expectedEncoded = Uint8Array.from([...typeBytes, ...witnessIndexBytes, ...checksumBytes]); diff --git a/packages/transactions/src/coders/upgrade-purpose.ts b/packages/transactions/src/coders/upgrade-purpose.ts index 1544033e26f..1b51e340abf 100644 --- a/packages/transactions/src/coders/upgrade-purpose.ts +++ b/packages/transactions/src/coders/upgrade-purpose.ts @@ -39,13 +39,13 @@ export class UpgradePurposeCoder extends Coder { const parts: Uint8Array[] = []; const { type } = upgradePurposeType; - parts.push(new NumberCoder('u8').encode(type)); + parts.push(new NumberCoder('u8', { padToWordSize: true }).encode(type)); switch (type) { case UpgradePurposeTypeEnum.ConsensusParameters: { const data = upgradePurposeType.data as ConsensusParameters; - parts.push(new NumberCoder('u16').encode(data.witnessIndex)); + parts.push(new NumberCoder('u16', { padToWordSize: true }).encode(data.witnessIndex)); parts.push(new B256Coder().encode(data.checksum)); break; } @@ -72,12 +72,12 @@ export class UpgradePurposeCoder extends Coder { let o = offset; let decoded; - [decoded, o] = new NumberCoder('u8').decode(data, o); + [decoded, o] = new NumberCoder('u8', { padToWordSize: true }).decode(data, o); const type = decoded as UpgradePurposeTypeEnum; switch (type) { case UpgradePurposeTypeEnum.ConsensusParameters: { - [decoded, o] = new NumberCoder('u16').decode(data, o); + [decoded, o] = new NumberCoder('u16', { padToWordSize: true }).decode(data, o); const witnessIndex = decoded; [decoded, o] = new B256Coder().decode(data, o); const checksum = decoded; diff --git a/packages/transactions/src/coders/utxo-id.ts b/packages/transactions/src/coders/utxo-id.ts index 08af089e195..c6b0688e937 100644 --- a/packages/transactions/src/coders/utxo-id.ts +++ b/packages/transactions/src/coders/utxo-id.ts @@ -14,7 +14,7 @@ export class UtxoIdCoder extends StructCoder<{ constructor() { super('UtxoId', { transactionId: new B256Coder(), - outputIndex: new NumberCoder('u8'), + outputIndex: new NumberCoder('u8', { padToWordSize: true }), }); } } diff --git a/packages/transactions/src/coders/witness.ts b/packages/transactions/src/coders/witness.ts index d56e28eafcc..5121e60fc3a 100644 --- a/packages/transactions/src/coders/witness.ts +++ b/packages/transactions/src/coders/witness.ts @@ -23,7 +23,7 @@ export class WitnessCoder extends Coder { encode(value: Witness): Uint8Array { const parts: Uint8Array[] = []; - parts.push(new NumberCoder('u32').encode(value.dataLength)); + parts.push(new NumberCoder('u32', { padToWordSize: true }).encode(value.dataLength)); parts.push(new ByteArrayCoder(value.dataLength).encode(value.data)); return concat(parts); @@ -33,7 +33,7 @@ export class WitnessCoder extends Coder { let decoded; let o = offset; - [decoded, o] = new NumberCoder('u32').decode(data, o); + [decoded, o] = new NumberCoder('u32', { padToWordSize: true }).decode(data, o); const dataLength = decoded; [decoded, o] = new ByteArrayCoder(dataLength).decode(data, o); const witnessData = decoded; diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 67296717149..edeb233463b 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -1,5 +1,16 @@ # @fuel-ts/utils +## 0.86.0 + +### Patch Changes + +- 316c757: fix: internalize `ethers` functionality and remove dependency +- 0651a5f: chore: remove `ethers` from `abi-coder` +- Updated dependencies [316c757] + - @fuel-ts/errors@0.86.0 + - @fuel-ts/math@0.86.0 + - @fuel-ts/interfaces@0.86.0 + ## 0.85.0 ### Patch Changes diff --git a/packages/utils/package.json b/packages/utils/package.json index 4f007694559..34e496d2e30 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/utils", - "version": "0.85.0", + "version": "0.86.0", "description": "Utilities (and test utilities) collection", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/versions/CHANGELOG.md b/packages/versions/CHANGELOG.md index 81eab80d785..fe0ef5957e3 100644 --- a/packages/versions/CHANGELOG.md +++ b/packages/versions/CHANGELOG.md @@ -1,5 +1,11 @@ # @fuel-ts/versions +## 0.86.0 + +### Patch Changes + +- 64e9659: feat!: upgrade `forc@0.58.0` and remove `V0` encoding + ## 0.85.0 ## 0.84.0 diff --git a/packages/versions/package.json b/packages/versions/package.json index 19cbcd31a86..7961306b101 100644 --- a/packages/versions/package.json +++ b/packages/versions/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/versions", - "version": "0.85.0", + "version": "0.86.0", "description": "Validates supported versions of the Fuel toolchain", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/versions/src/lib/getBuiltinVersions.ts b/packages/versions/src/lib/getBuiltinVersions.ts index e95ad517956..d302297717d 100644 --- a/packages/versions/src/lib/getBuiltinVersions.ts +++ b/packages/versions/src/lib/getBuiltinVersions.ts @@ -1,7 +1,7 @@ export function getBuiltinVersions() { return { - FORC: '0.56.1', + FORC: '0.58.0', FUEL_CORE: '0.26.0', - FUELS: '0.85.0', + FUELS: '0.86.0', }; } diff --git a/vite.node.config.mts b/vite.node.config.mts deleted file mode 100644 index 57e002b56df..00000000000 --- a/vite.node.config.mts +++ /dev/null @@ -1,14 +0,0 @@ -import type { UserConfig } from "vitest/config"; -import { mergeConfig } from "vitest/config"; - -import baseConfig from "./vite.base.config.mts"; - -const config: UserConfig = { - test: { - coverage: { - reportsDirectory: "coverage/environments/node", - }, - }, -}; - -export default mergeConfig(baseConfig, config); diff --git a/vite.browser.config.mts b/vitest.browser.config.mts similarity index 81% rename from vite.browser.config.mts rename to vitest.browser.config.mts index fd260dd6aa1..8c7b3b0132f 100644 --- a/vite.browser.config.mts +++ b/vitest.browser.config.mts @@ -1,8 +1,8 @@ import { nodePolyfills } from "vite-plugin-node-polyfills"; -import { mergeConfig } from "vitest/config"; import type { UserConfig } from "vitest/config"; +import { mergeConfig, defineProject } from "vitest/config"; -import baseConfig from "./vite.base.config.mts"; +import sharedConfig from "./vitest.shared.config.mts"; const config: UserConfig = { plugins: [ @@ -42,4 +42,4 @@ const config: UserConfig = { }, }; -export default mergeConfig(baseConfig, config); +export default mergeConfig(sharedConfig, defineProject(config)); diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 00000000000..224c9b5a35d --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,24 @@ +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + coverage: { + enabled: true, + provider: 'istanbul', + reporter: ['json', 'text', 'html'], + include: ['packages', 'internal', 'apps'], + exclude: [ + '**/*.js', + '**/node_modules/**', + '**/dist/**', + '**/test/**', + '**/*.test.ts', + '**/*.d.ts', + '**/bin.ts', + 'packages/fuel-gauge/**', + 'apps/demo-*', + 'apps/docs', + ], + }, + }, +}); diff --git a/vite.env.ts b/vitest.env.ts similarity index 100% rename from vite.env.ts rename to vitest.env.ts diff --git a/vitest.node.config.mts b/vitest.node.config.mts new file mode 100644 index 00000000000..d3b8430251a --- /dev/null +++ b/vitest.node.config.mts @@ -0,0 +1,14 @@ +import type { UserConfig } from "vitest/config"; +import { mergeConfig, defineProject } from "vitest/config"; + +import sharedConfig from "./vitest.shared.config.mts"; + +const config: UserConfig = { + test: { + coverage: { + reportsDirectory: "coverage/environments/node", + }, + }, +}; + +export default mergeConfig(sharedConfig, defineProject(config)); diff --git a/vite.base.config.mts b/vitest.shared.config.mts similarity index 96% rename from vite.base.config.mts rename to vitest.shared.config.mts index ab159041524..08ba4406074 100644 --- a/vite.base.config.mts +++ b/vitest.shared.config.mts @@ -11,16 +11,6 @@ export default defineConfig({ }), ], test: { - exclude: [ - "**/node_modules/**", - "**/dist/**", - "/apps/demo-nextjs", - "/apps/demo-react-cra", - "/apps/demo-react-vite", - ], - globals: true, - setupFiles: ["./vite.env.ts"], - env: loadEnv(mode, process.cwd(), ""), coverage: { enabled: true, provider: "istanbul", @@ -39,6 +29,16 @@ export default defineConfig({ "apps/docs", ], }, + exclude: [ + "**/node_modules/**", + "**/dist/**", + "/apps/demo-nextjs", + "/apps/demo-react-cra", + "/apps/demo-react-vite", + ], + globals: true, + setupFiles: ["./vitest.env.ts"], + env: loadEnv(mode, process.cwd(), ""), poolOptions: { threads: { minThreads: 1, diff --git a/vitest.workspace.ts b/vitest.workspace.ts new file mode 100644 index 00000000000..d5607cb861f --- /dev/null +++ b/vitest.workspace.ts @@ -0,0 +1,3 @@ +import { defineWorkspace } from 'vitest/config'; + +export default defineWorkspace(['./vitest.node.config.mts', './vitest.browser.config.mts']); From f5f3bffe78e4ffb658f24729cd2b7c411e043b3a Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 15 May 2024 08:17:18 +0100 Subject: [PATCH 70/89] Fixing test --- packages/fuels/src/cli/config/loadConfig.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/fuels/src/cli/config/loadConfig.test.ts b/packages/fuels/src/cli/config/loadConfig.test.ts index e68195fbe31..c696215dc89 100644 --- a/packages/fuels/src/cli/config/loadConfig.test.ts +++ b/packages/fuels/src/cli/config/loadConfig.test.ts @@ -65,6 +65,8 @@ describe('loadConfig', () => { root: paths.root, workspace: paths.workspaceDir, output: paths.outputDir, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, }); const config = await loadConfig(paths.root); From 054d877732732d519c5821c4b3a406299b6510bc Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 15 May 2024 10:18:06 +0100 Subject: [PATCH 71/89] Auto-populate latest binary versions to docs --- apps/docs/src/guide/fuels-cli/commands.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/docs/src/guide/fuels-cli/commands.md b/apps/docs/src/guide/fuels-cli/commands.md index 65966017247..71dd906709e 100644 --- a/apps/docs/src/guide/fuels-cli/commands.md +++ b/apps/docs/src/guide/fuels-cli/commands.md @@ -1,6 +1,6 @@ # Commands @@ -161,13 +161,13 @@ Check for version incompatibilities between your [Fuel Toolchain](https://docs.f npx fuels@{{fuels}} versions ``` -``` +```console-vue ┌───────────┬───────────┬────────────────┬─────────────┐ │ │ Supported │ Yours / System │ System Path │ ├───────────┼───────────┼────────────────┼─────────────┤ -│ Forc │ 0.56.1 │ 0.56.1 │ forc │ +│ Forc │ {{forc}} │ {{forc}} │ forc │ ├───────────┼───────────┼────────────────┼─────────────┤ -│ Fuel-Core │ 0.26.0 │ 0.26.0 │ fuel-core │ +│ Fuel-Core │ {{fuelCore}} │ {{fuelCore}} │ fuel-core │ └───────────┴───────────┴────────────────┴─────────────┘ You have all the right versions! ⚡ From 4d33bf6432b1cb16160dc04468f0b550051a5d4f Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 15 May 2024 10:21:59 +0100 Subject: [PATCH 72/89] Added default install path for forc and fuel-core to examples --- apps/demo-fuels/fuels.config.full.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/demo-fuels/fuels.config.full.ts b/apps/demo-fuels/fuels.config.full.ts index ff395283785..9dadb0fcef8 100644 --- a/apps/demo-fuels/fuels.config.full.ts +++ b/apps/demo-fuels/fuels.config.full.ts @@ -98,12 +98,12 @@ export default createConfig({ // #region forcPath // Default: 'forc', - forcPath: '/custom/path/to/forc', + forcPath: '~/.fuelup/bin/forc', // #endregion forcPath // #region fuelCorePath // Default: 'fuel-core' - fuelCorePath: '/custom/path/to/fuel-core', + fuelCorePath: '~/.fuelup/bin/fuel-core', // #endregion fuelCorePath }); From a1d8827b6c6ad408e19cf6556c23b9e317850701 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 15 May 2024 10:34:51 +0100 Subject: [PATCH 73/89] Rewrite Prerequisites --- apps/docs/src/guide/fuels-cli/index.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/docs/src/guide/fuels-cli/index.md b/apps/docs/src/guide/fuels-cli/index.md index 89f44469c25..de545bec5a6 100644 --- a/apps/docs/src/guide/fuels-cli/index.md +++ b/apps/docs/src/guide/fuels-cli/index.md @@ -33,7 +33,12 @@ my-fuel-dapp # NextJS app or similar ## Prerequisites -We expect you to install the [Fuel Toolchain](https://docs.fuel.network/docs/sway/introduction/fuel_toolchain/#the-fuel-toolchain) before using this library. Follow [this guide](https://docs.fuel.network/guides/installation/) to get this installed. +The [Fuel Toolchain](https://docs.fuel.network/docs/sway/introduction/fuel_toolchain/#the-fuel-toolchain) and its components (namely `forc` and `fuel-core`) are pre-requisite for several operations with the Fuels CLI. For example: + +- Building out contracts using [`fuels build`](./commands.md#fuels-build) requires `forc`. +- Deploying contracts locally using [`fuels deploy`](./commands.md#fuels-deploy) requires `fuel-core`. + +Follow the [installation guide](https://docs.fuel.network/guides/installation/) if you don't have them installed already. ## Installation From d41c11ddeeb0694f2f2c835b79486b2ef1ac80f4 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 15 May 2024 14:32:46 +0100 Subject: [PATCH 74/89] Lint --- pnpm-lock.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 971d43f640c..05c8783c175 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,7 +8,6 @@ overrides: cross-fetch: 4.0.0 importers: - .: devDependencies: '@actions/core': @@ -1180,7 +1179,6 @@ importers: version: 5.2.2 packages: - '@aashutoshrathi/word-wrap@1.2.6': resolution: {integrity: sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==} engines: {node: '>=0.10.0'} @@ -12261,7 +12259,6 @@ packages: resolution: {integrity: sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==} snapshots: - '@aashutoshrathi/word-wrap@1.2.6': {} '@actions/core@1.10.1': From 5b8b9dc879e8cf5ee5059eba32fa93d2c949bda9 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 15 May 2024 14:42:21 +0100 Subject: [PATCH 75/89] Anchor doesn't exist --- .../src/guide/getting-started/connecting-to-a-local-node.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/src/guide/getting-started/connecting-to-a-local-node.md b/apps/docs/src/guide/getting-started/connecting-to-a-local-node.md index f6b2d99f696..705592612b2 100644 --- a/apps/docs/src/guide/getting-started/connecting-to-a-local-node.md +++ b/apps/docs/src/guide/getting-started/connecting-to-a-local-node.md @@ -3,7 +3,7 @@ Firstly, you will need a local node running on your machine. We recommend one of the following methods: - [Testing utilities](../testing/index.md#wallet-test-utilities) can assist in programmatically launching a short-lived node. -- Running [fuel-core](https://docs.fuel.network/guides/running-a-node/running-a-local-node/) directly, or via the CLI [fuels](../fuels-cli/commands.md#fuels-core). +- Running [fuel-core](https://docs.fuel.network/guides/running-a-node/running-a-local-node/) locally. In the following example, we create a provider to connect to the local node and sign a message. From 4392ba3ce9752dcf034ec4635e0214a39085eed4 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 16 May 2024 14:26:27 +0100 Subject: [PATCH 76/89] Nitty McNittyson: Whitespace Co-authored-by: Anderson Arboleya --- packages/utils/src/cli-utils/tryFindBinaries.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/utils/src/cli-utils/tryFindBinaries.ts b/packages/utils/src/cli-utils/tryFindBinaries.ts index d251b11a607..bed1ff0a8de 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.ts @@ -28,6 +28,7 @@ export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: strin fuelCoreError ? ` -> 'fuel-core' at path '${systemFuelCorePath}'` : undefined, `\nVisit https://docs.fuel.network/guides/installation/ for an installation guide.`, ]; + throw new FuelError( FuelError.CODES.BIN_FILE_NOT_FOUND, `${errors.filter(Boolean).join('\n')}`, From 9bc2e17a6ec9090633bcca09d8aa9cfd4271a4f5 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 16 May 2024 14:26:36 +0100 Subject: [PATCH 77/89] Nitty McNittyson: Whitespace Co-authored-by: Anderson Arboleya --- packages/utils/src/cli-utils/tryFindBinaries.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/utils/src/cli-utils/tryFindBinaries.ts b/packages/utils/src/cli-utils/tryFindBinaries.ts index bed1ff0a8de..1d58d845983 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.ts @@ -21,6 +21,7 @@ export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: strin systemFuelCorePath, systemFuelCoreVersion, } = getSystemFuelCore(paths.fuelCorePath); + if (forcError || fuelCoreError) { const errors = [ 'Unable to find the following binaries on the filesystem:', From 0c14e3fd46af8eaeebe10f9eed35748c8d419b13 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 16 May 2024 14:26:43 +0100 Subject: [PATCH 78/89] Nitty McNittyson: Whitespace Co-authored-by: Anderson Arboleya --- packages/utils/src/cli-utils/tryFindBinaries.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/utils/src/cli-utils/tryFindBinaries.ts b/packages/utils/src/cli-utils/tryFindBinaries.ts index 1d58d845983..008b07b2dc5 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.ts @@ -16,6 +16,7 @@ import { export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: string } = {}) => { // Ensure we can get the binary versions const { error: forcError, systemForcPath, systemForcVersion } = getSystemForc(paths.forcPath); + const { error: fuelCoreError, systemFuelCorePath, From 7e5f5403687bdc02999aa1f3566965aa5a61e843 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 16 May 2024 14:31:54 +0100 Subject: [PATCH 79/89] Updated logs with binary path --- packages/fuels/src/cli/commands/build/buildSwayPrograms.ts | 5 ++--- packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts b/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts index 22794c27b3c..936d4d99fd8 100644 --- a/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts +++ b/packages/fuels/src/cli/commands/build/buildSwayPrograms.ts @@ -1,11 +1,10 @@ import type { FuelsConfig } from '../../types'; -import { log, debug } from '../../utils/logger'; +import { log } from '../../utils/logger'; import { buildSwayProgram } from './buildSwayProgram'; export async function buildSwayPrograms(config: FuelsConfig) { - log(`Building Sway programs using 'forc' binary`); - debug(`Using 'forc' binary from: ${config.forcPath}`); + log(`Building Sway programs using: '${config.forcPath}'`); const paths = config.workspace ? [config.workspace] diff --git a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts index 14d91c29a8e..a06ddbc09e3 100644 --- a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts +++ b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts @@ -27,8 +27,7 @@ export const autoStartFuelCore = async (config: FuelsConfig) => { let fuelCore: FuelCoreNode | undefined; if (config.autoStartFuelCore) { - log(`Starting 'fuel-core' node..`); - debug(`Using 'fuel-core' binary from: ${config.fuelCorePath}`); + log(`Starting node using: '${config.fuelCorePath}'`); const bindIp = '0.0.0.0'; const accessIp = '127.0.0.1'; From 9d2464301861ef3bf50e48e829480b7183b1cbd8 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 16 May 2024 16:01:37 +0100 Subject: [PATCH 80/89] Fixing ci:test --- apps/docs-snippets/fuels.config.ts | 2 ++ packages/fuel-gauge/fuels.config.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/apps/docs-snippets/fuels.config.ts b/apps/docs-snippets/fuels.config.ts index fcc0abef737..016d6327b74 100644 --- a/apps/docs-snippets/fuels.config.ts +++ b/apps/docs-snippets/fuels.config.ts @@ -4,4 +4,6 @@ export default createConfig({ workspace: './test/fixtures/forc-projects', output: './test/typegen', forcBuildFlags: ['--release'], + forcPath: 'fuels-forc', + fuelCorePath: 'fuels-core', }); diff --git a/packages/fuel-gauge/fuels.config.ts b/packages/fuel-gauge/fuels.config.ts index fcc0abef737..016d6327b74 100644 --- a/packages/fuel-gauge/fuels.config.ts +++ b/packages/fuel-gauge/fuels.config.ts @@ -4,4 +4,6 @@ export default createConfig({ workspace: './test/fixtures/forc-projects', output: './test/typegen', forcBuildFlags: ['--release'], + forcPath: 'fuels-forc', + fuelCorePath: 'fuels-core', }); From a25091f6dd76adfae881ffcfd42933a6fde12e1f Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 16 May 2024 16:08:20 +0100 Subject: [PATCH 81/89] Refactored to warn the user over throwing --- .../src/cli-utils/tryFindBinaries.test.ts | 22 ++++++++++--------- .../utils/src/cli-utils/tryFindBinaries.ts | 11 +++++----- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts index 7ded6368065..132fe654ac2 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.test.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -45,7 +45,10 @@ const mockAllDeps = ( FUELS: compatibleVersion, }); + const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}); + return { + warn, getSystemForc, getSystemFuelCore, getBuiltinVersions, @@ -118,25 +121,24 @@ describe('tryFindBinaries', () => { ); }); - it(`should throw when binaries are outdated`, async () => { + it(`should warn the user when binaries are outdated`, async () => { const compatibleVersion = '1.0.0'; const currentVersion = '0.0.1'; - const { getSystemForc, getSystemFuelCore } = mockAllDeps({ + const expectedMessage = [ + `The following binaries on the filesystem are outdated:`, + ` -> 'forc' is currently '${currentVersion}', but requires '${compatibleVersion}'.`, + ` -> 'fuel-core' is currently '${currentVersion}', but requires '${compatibleVersion}'.`, + ].join('\n'); + const { warn, getSystemForc, getSystemFuelCore } = mockAllDeps({ compatibleVersion, forcVersion: currentVersion, fuelCoreVersion: currentVersion, }); - const { error } = await safeExec(() => tryFindBinaries()); + tryFindBinaries(); expect(getSystemForc).toHaveBeenCalledTimes(1); expect(getSystemFuelCore).toHaveBeenCalledTimes(1); - expect(error?.message).toContain(`The following binaries on the filesystem are outdated`); - expect(error?.message).toContain( - `'forc' is currently '${currentVersion}', but requires '${compatibleVersion}'` - ); - expect(error?.message).toContain( - `'fuel-core' is currently '${currentVersion}', but requires '${compatibleVersion}'` - ); + expect(warn).toBeCalledWith(expectedMessage) }); }); diff --git a/packages/utils/src/cli-utils/tryFindBinaries.ts b/packages/utils/src/cli-utils/tryFindBinaries.ts index 008b07b2dc5..1663e0fe08b 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.ts @@ -16,13 +16,13 @@ import { export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: string } = {}) => { // Ensure we can get the binary versions const { error: forcError, systemForcPath, systemForcVersion } = getSystemForc(paths.forcPath); - + const { error: fuelCoreError, systemFuelCorePath, systemFuelCoreVersion, } = getSystemFuelCore(paths.fuelCorePath); - + if (forcError || fuelCoreError) { const errors = [ 'Unable to find the following binaries on the filesystem:', @@ -46,6 +46,7 @@ export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: strin if (systemForcIsLt || systemFuelCoreIsLt) { const { FORC: compatibleForcVersion, FUEL_CORE: compatibleFuelCoreVersion } = getBuiltinVersions(); + const errors = [ 'The following binaries on the filesystem are outdated:', systemForcIsLt @@ -55,9 +56,9 @@ export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: strin ? ` -> '${systemFuelCorePath}' is currently '${systemFuelCoreVersion}', but requires '${compatibleFuelCoreVersion}'.` : undefined, ]; - throw new FuelError(FuelError.CODES.NOT_SUPPORTED, `${errors.filter(Boolean).join('\n')}`, { - ...paths, - }); + + // eslint-disable-next-line no-console + console.warn(`${errors.filter(Boolean).join('\n')}`); } return { From 3a51c670d20f56c32e02da001ebfe5acefe82082 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 16 May 2024 16:11:13 +0100 Subject: [PATCH 82/89] Verbose warning message --- packages/utils/src/cli-utils/tryFindBinaries.test.ts | 4 ++-- packages/utils/src/cli-utils/tryFindBinaries.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts index 132fe654ac2..7196f1e01c4 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.test.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -126,8 +126,8 @@ describe('tryFindBinaries', () => { const currentVersion = '0.0.1'; const expectedMessage = [ `The following binaries on the filesystem are outdated:`, - ` -> 'forc' is currently '${currentVersion}', but requires '${compatibleVersion}'.`, - ` -> 'fuel-core' is currently '${currentVersion}', but requires '${compatibleVersion}'.`, + ` -> 'forc' is currently 'v${currentVersion}', but the current 'fuels' version requires 'v${compatibleVersion}'.`, + ` -> 'fuel-core' is currently 'v${currentVersion}', but the current 'fuels' version requires 'v${compatibleVersion}'.`, ].join('\n'); const { warn, getSystemForc, getSystemFuelCore } = mockAllDeps({ compatibleVersion, diff --git a/packages/utils/src/cli-utils/tryFindBinaries.ts b/packages/utils/src/cli-utils/tryFindBinaries.ts index 1663e0fe08b..c7901371919 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.ts @@ -50,10 +50,10 @@ export const tryFindBinaries = (paths: { forcPath?: string; fuelCorePath?: strin const errors = [ 'The following binaries on the filesystem are outdated:', systemForcIsLt - ? ` -> '${systemForcPath}' is currently '${systemForcVersion}', but requires '${compatibleForcVersion}'.` + ? ` -> '${systemForcPath}' is currently 'v${systemForcVersion}', but the current 'fuels' version requires 'v${compatibleForcVersion}'.` : undefined, systemFuelCoreIsLt - ? ` -> '${systemFuelCorePath}' is currently '${systemFuelCoreVersion}', but requires '${compatibleFuelCoreVersion}'.` + ? ` -> '${systemFuelCorePath}' is currently 'v${systemFuelCoreVersion}', but the current 'fuels' version requires 'v${compatibleFuelCoreVersion}'.` : undefined, ]; From c6a06ea38d36805739f6396fcfc208eca172b63f Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 16 May 2024 16:20:14 +0100 Subject: [PATCH 83/89] Removed old parameter --- .../fuels/src/cli/commands/dev/autoStartFuelCore.test.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts index 43fb9b1faa3..40dafed638e 100644 --- a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts +++ b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts @@ -91,10 +91,8 @@ describe('autoStartFuelCore', () => { test('should start `fuel-core` node using system binary', async () => { const { launchNode } = mockLaunchNode(); - const core = (await autoStartFuelCore({ - ...structuredClone(fuelsConfig), - useBuiltinFuelCore: false, - })) as FuelCoreNode; + const config = structuredClone(fuelsConfig); + const core = (await autoStartFuelCore(config)) as FuelCoreNode; expect(launchNode).toHaveBeenCalledTimes(1); From c52036e385ac2a03879d0f5f009bb28c72fd3cf4 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 16 May 2024 16:27:07 +0100 Subject: [PATCH 84/89] Removed `useSystemFuelCore` from `launchNode` --- .../account/src/test-utils/launchNode.test.ts | 23 +++---------------- packages/account/src/test-utils/launchNode.ts | 11 +++------ vitest.env.ts | 2 ++ 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/packages/account/src/test-utils/launchNode.test.ts b/packages/account/src/test-utils/launchNode.test.ts index d83476895df..cf88c28d7d4 100644 --- a/packages/account/src/test-utils/launchNode.test.ts +++ b/packages/account/src/test-utils/launchNode.test.ts @@ -63,26 +63,10 @@ const defaultLaunchNodeConfig: Partial = { * @group node */ describe('launchNode', () => { - test('should start `fuel-core` node using built-in binary', async () => { - mockSpawn(); - - const { cleanup, ip, port } = await launchNode({ - ...defaultLaunchNodeConfig, - useSystemFuelCore: false, - }); - - expect(ip).toBe('0.0.0.0'); - expect(port).toBe('4000'); - cleanup(); - }); - test('should start `fuel-core` node using system binary', async () => { mockSpawn(); - const { cleanup, ip, port } = await launchNode({ - ...defaultLaunchNodeConfig, - useSystemFuelCore: true, - }); + const { cleanup, ip, port } = await launchNode(defaultLaunchNodeConfig); expect(ip).toBe('0.0.0.0'); expect(port).toBe('4000'); @@ -105,18 +89,17 @@ describe('launchNode', () => { cleanup(); }); - test('should start `fuel-core` node with system binary (favour over custom)', async () => { + test('should start `fuel-core` node with custom binaries', async () => { const { spawn } = mockSpawn(); const { cleanup, ip, port } = await launchNode({ ...defaultLaunchNodeConfig, fuelCorePath: 'custom-fuels-core', - useSystemFuelCore: true, }); expect(ip).toBe('0.0.0.0'); expect(port).toBe('4000'); - expect(spawn).toBeCalledWith('fuel-core', expect.any(Array), expect.any(Object)); + expect(spawn).toBeCalledWith('custom-fuels-core', expect.any(Array), expect.any(Object)); cleanup(); }); diff --git a/packages/account/src/test-utils/launchNode.ts b/packages/account/src/test-utils/launchNode.ts index d6370232928..9c568e4174a 100644 --- a/packages/account/src/test-utils/launchNode.ts +++ b/packages/account/src/test-utils/launchNode.ts @@ -41,7 +41,6 @@ export type LaunchNodeOptions = { port?: string; args?: string[]; fuelCorePath?: string; - useSystemFuelCore?: boolean; loggingEnabled?: boolean; debugEnabled?: boolean; basePath?: string; @@ -88,8 +87,7 @@ export const killNode = (params: KillNodeParams) => { * @param ip - the ip to bind to. (optional, defaults to 0.0.0.0) * @param port - the port to bind to. (optional, defaults to 4000 or the next available port) * @param args - additional arguments to pass to fuel-core. - * @param fuelCorePath - the path to the fuel-core binary. (optional, defaults to the fuel-core binary in the node_modules folder) - * @param useSystemFuelCore - whether to use the system fuel-core binary or the one provided by the \@internal/fuel-core package. + * @param fuelCorePath - the path to the fuel-core binary. (optional, defaults to 'fuel-core') * @param loggingEnabled - whether the node should output logs. (optional, defaults to true) * @param debugEnabled - whether the node should log debug messages. (optional, defaults to false) * @param basePath - the base path to use for the temporary folder. (optional, defaults to os.tmpdir()) @@ -99,8 +97,7 @@ export const launchNode = async ({ ip, port, args = [], - fuelCorePath = undefined, - useSystemFuelCore = false, + fuelCorePath = process.env.FUEL_CORE_PATH ?? undefined, loggingEnabled = true, debugEnabled = false, basePath, @@ -127,9 +124,7 @@ export const launchNode = async ({ // This string is logged by the client when the node has successfully started. We use it to know when to resolve. const graphQLStartSubstring = 'Binding GraphQL provider to'; - const binPath = fuelCorePath ?? findBinPath('fuels-core', __dirname); - - const command = useSystemFuelCore ? 'fuel-core' : binPath; + const command = fuelCorePath ?? 'fuel-core'; const ipToUse = ip || '0.0.0.0'; diff --git a/vitest.env.ts b/vitest.env.ts index 689c8aa5304..5d994aa1248 100644 --- a/vitest.env.ts +++ b/vitest.env.ts @@ -32,5 +32,7 @@ const getPrivateKeyForCurrentWorker = () => { return privateKey; }; +process.env.FUEL_CORE_PATH = 'fuels-core'; + process.env.GENESIS_SECRET = process.env.FUEL_NETWORK_GENESIS_KEY || getPrivateKeyForCurrentWorker(); From a12e73472accc69fc41776ba01f1e7d5e7d84212 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 16 May 2024 16:31:10 +0100 Subject: [PATCH 85/89] Fix url in config --- apps/demo-fuels/fuels.config.minimal.ts | 2 +- apps/demo-fuels/fuels.config.ts | 2 +- packages/fuels/src/cli/templates/fuels.config.hbs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/demo-fuels/fuels.config.minimal.ts b/apps/demo-fuels/fuels.config.minimal.ts index 8b17236adde..7d8d6a04635 100644 --- a/apps/demo-fuels/fuels.config.minimal.ts +++ b/apps/demo-fuels/fuels.config.minimal.ts @@ -9,5 +9,5 @@ export default createConfig({ /** * Check the docs: - * https://fuellabs.github.io/fuels-ts/guide/fuels/config-file + * https://docs.fuel.network/docs/fuels-ts/fuels-cli/config-file/ */ diff --git a/apps/demo-fuels/fuels.config.ts b/apps/demo-fuels/fuels.config.ts index 614e16fd23b..81f8a998759 100644 --- a/apps/demo-fuels/fuels.config.ts +++ b/apps/demo-fuels/fuels.config.ts @@ -9,5 +9,5 @@ export default createConfig({ /** * Check the docs: - * https://fuellabs.github.io/fuels-ts/guide/fuels/config-file + * https://docs.fuel.network/docs/fuels-ts/fuels-cli/config-file/ */ diff --git a/packages/fuels/src/cli/templates/fuels.config.hbs b/packages/fuels/src/cli/templates/fuels.config.hbs index c38d627424b..dc351121c38 100644 --- a/packages/fuels/src/cli/templates/fuels.config.hbs +++ b/packages/fuels/src/cli/templates/fuels.config.hbs @@ -40,5 +40,5 @@ export default createConfig({ /** * Check the docs: - * https://fuellabs.github.io/fuels-ts/tooling/cli/fuels/config-file + * https://docs.fuel.network/docs/fuels-ts/fuels-cli/config-file/ */ From 157ebb96afc78254601d5d7baa8e242edda16996 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 16 May 2024 16:31:20 +0100 Subject: [PATCH 86/89] Lint --- packages/account/src/test-utils/launchNode.ts | 1 - packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts | 2 +- packages/utils/src/cli-utils/tryFindBinaries.test.ts | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/account/src/test-utils/launchNode.ts b/packages/account/src/test-utils/launchNode.ts index 9c568e4174a..9684067171c 100644 --- a/packages/account/src/test-utils/launchNode.ts +++ b/packages/account/src/test-utils/launchNode.ts @@ -1,7 +1,6 @@ import { UTXO_ID_LEN } from '@fuel-ts/abi-coder'; import { randomBytes } from '@fuel-ts/crypto'; import { defaultSnapshotConfigs, defaultConsensusKey, hexlify } from '@fuel-ts/utils'; -import { findBinPath } from '@fuel-ts/utils/cli-utils'; import type { ChildProcessWithoutNullStreams } from 'child_process'; import { spawn } from 'child_process'; import { randomUUID } from 'crypto'; diff --git a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts index a06ddbc09e3..dd538e200a1 100644 --- a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts +++ b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.ts @@ -4,7 +4,7 @@ import type { ChildProcessWithoutNullStreams } from 'child_process'; import { getPortPromise } from 'portfinder'; import type { FuelsConfig } from '../../types'; -import { debug, log, loggingConfig } from '../../utils/logger'; +import { log, loggingConfig } from '../../utils/logger'; export type FuelCoreNode = { bindIp: string; diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts index 7196f1e01c4..de630130b25 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.test.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -121,7 +121,7 @@ describe('tryFindBinaries', () => { ); }); - it(`should warn the user when binaries are outdated`, async () => { + it(`should warn the user when binaries are outdated`, () => { const compatibleVersion = '1.0.0'; const currentVersion = '0.0.1'; const expectedMessage = [ From 90c2e8586a43487176476f4b150da94596ac8b5c Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 16 May 2024 16:35:31 +0100 Subject: [PATCH 87/89] Removed redundant `findBinPath` method --- .../commands/build/buildSwayProgram.test.ts | 4 -- packages/utils/src/cli-utils.ts | 1 - .../utils/src/cli-utils/findBinPath.test.ts | 63 ------------------- packages/utils/src/cli-utils/findBinPath.ts | 17 ----- 4 files changed, 85 deletions(-) delete mode 100644 packages/utils/src/cli-utils/findBinPath.test.ts delete mode 100644 packages/utils/src/cli-utils/findBinPath.ts diff --git a/packages/fuels/src/cli/commands/build/buildSwayProgram.test.ts b/packages/fuels/src/cli/commands/build/buildSwayProgram.test.ts index 24cf1be223b..94e32731fe1 100644 --- a/packages/fuels/src/cli/commands/build/buildSwayProgram.test.ts +++ b/packages/fuels/src/cli/commands/build/buildSwayProgram.test.ts @@ -1,4 +1,3 @@ -import * as findBinPathMod from '@fuel-ts/utils/cli-utils'; import * as childProcessMod from 'child_process'; import { fuelsConfig } from '../../../../test/fixtures/fuels.config'; @@ -24,8 +23,6 @@ describe('buildSwayPrograms', () => { }); function mockAll(params: { shouldError: boolean } = { shouldError: false }) { - const findBinPath = vi.spyOn(findBinPathMod, 'findBinPath').mockReturnValue(''); - const spawnMocks = { // eslint-disable-next-line @typescript-eslint/no-explicit-any on: vi.fn((eventName: string, fn: (..._: any) => void) => { @@ -48,7 +45,6 @@ describe('buildSwayPrograms', () => { return { spawn, spawnMocks, - findBinPath, }; } diff --git a/packages/utils/src/cli-utils.ts b/packages/utils/src/cli-utils.ts index a65d7367d6c..01bf43b5e2a 100644 --- a/packages/utils/src/cli-utils.ts +++ b/packages/utils/src/cli-utils.ts @@ -1,2 +1 @@ -export * from './cli-utils/findBinPath'; export * from './cli-utils/tryFindBinaries'; diff --git a/packages/utils/src/cli-utils/findBinPath.test.ts b/packages/utils/src/cli-utils/findBinPath.test.ts deleted file mode 100644 index 48c1247299a..00000000000 --- a/packages/utils/src/cli-utils/findBinPath.test.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { safeExec } from '@fuel-ts/errors/test-utils'; -import { mkdirSync, rmSync, writeFileSync } from 'fs'; -import { join } from 'path'; - -import { findBinPath } from './findBinPath'; - -/** - * @group node - */ -describe('findBinPath', () => { - const bootstrap = (dir: string) => { - const cmdName = 'my-cmd'; - const mods = join(dir, 'node_modules'); - const bin = join(mods, '.bin'); - const cmdPath = join(bin, cmdName); - - const resetDisk = (params?: { cmdOnly: boolean }) => { - if (params?.cmdOnly) { - rmSync(cmdPath); - } else { - rmSync(mods, { recursive: true }); - } - }; - - mkdirSync(bin, { recursive: true }); - writeFileSync(cmdPath, ''); - - return { resetDisk, mods, cmdName, cmdPath }; - }; - - it('should find bin path in current dir', () => { - const base = __dirname; // current dir - const { cmdName, cmdPath, resetDisk } = bootstrap(base); - const binPath = findBinPath(cmdName, base); - - resetDisk(); - expect(binPath).toEqual(cmdPath); - }); - - it('should find bin path one dir up', () => { - const base = join(__dirname, '..'); // one dir up - const { cmdName, cmdPath, resetDisk } = bootstrap(base); - const binPath = findBinPath(cmdName, base); - - resetDisk(); - expect(binPath).toEqual(cmdPath); - }); - - it('should find bin path two dir up', () => { - const base = join(__dirname, '..', '..'); // two dirs up - const { cmdName, cmdPath, resetDisk } = bootstrap(base); - const binPath = findBinPath(cmdName, base); - - resetDisk({ cmdOnly: true }); - expect(binPath).toEqual(cmdPath); - }); - - it('should throw for bin path not found', async () => { - const cmdName = 'non-existent'; - const { error } = await safeExec(() => findBinPath(cmdName, __dirname)); - expect(error?.message).toEqual(`Command not found: ${cmdName}`); - }); -}); diff --git a/packages/utils/src/cli-utils/findBinPath.ts b/packages/utils/src/cli-utils/findBinPath.ts deleted file mode 100644 index 7f255e01bd1..00000000000 --- a/packages/utils/src/cli-utils/findBinPath.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { existsSync } from 'fs'; -import { join } from 'path'; - -export const findBinPath = (binCommandName: string, startingDir: string): string => { - const cmdPath = join(startingDir, 'node_modules', '.bin', binCommandName); - const parentDir = join(startingDir, '..'); - - if (existsSync(cmdPath)) { - return cmdPath; - } - - if (parentDir === startingDir) { - throw new Error(`Command not found: ${binCommandName}`); - } - - return findBinPath(binCommandName, parentDir); -}; From 16b995ebc84c4e51f1ce113431c4dab1b29f64e2 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 16 May 2024 16:40:10 +0100 Subject: [PATCH 88/89] Lint --- packages/utils/src/cli-utils/tryFindBinaries.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/src/cli-utils/tryFindBinaries.test.ts b/packages/utils/src/cli-utils/tryFindBinaries.test.ts index de630130b25..9dfb07b36fd 100644 --- a/packages/utils/src/cli-utils/tryFindBinaries.test.ts +++ b/packages/utils/src/cli-utils/tryFindBinaries.test.ts @@ -139,6 +139,6 @@ describe('tryFindBinaries', () => { expect(getSystemForc).toHaveBeenCalledTimes(1); expect(getSystemFuelCore).toHaveBeenCalledTimes(1); - expect(warn).toBeCalledWith(expectedMessage) + expect(warn).toBeCalledWith(expectedMessage); }); }); From 328f8094d139bf4abf3405af929c87a7e0dc1593 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 20 May 2024 16:17:04 +0100 Subject: [PATCH 89/89] chore: changeset update --- .changeset/friendly-deers-glow.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.changeset/friendly-deers-glow.md b/.changeset/friendly-deers-glow.md index 751151cfb68..da9fcc9d217 100644 --- a/.changeset/friendly-deers-glow.md +++ b/.changeset/friendly-deers-glow.md @@ -1,6 +1,8 @@ --- "@fuel-ts/account": patch -"fuels": patch +"create-fuels": patch +"fuels": minor +"@fuel-ts/utils": minor "@fuel-ts/versions": patch ---