diff --git a/.changeset/rich-dryers-do.md b/.changeset/rich-dryers-do.md deleted file mode 100644 index d288a9c4722..00000000000 --- a/.changeset/rich-dryers-do.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@fuel-ts/wallet": patch ---- - -Awaiting for WASM initialization inside wallet utility diff --git a/.eslintrc.js b/.eslintrc.js index d36569da0ed..e30f62a7dae 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -51,6 +51,7 @@ module.exports = { 'tsdoc/syntax': 'warn', 'require-await': 'off', '@typescript-eslint/require-await': 'error', + '@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/no-unused-vars': [ 'warn', { diff --git a/apps/demo-nextjs/CHANGELOG.md b/apps/demo-nextjs/CHANGELOG.md index 01814c4d0e6..2f13474d28d 100644 --- a/apps/demo-nextjs/CHANGELOG.md +++ b/apps/demo-nextjs/CHANGELOG.md @@ -1,5 +1,7 @@ # demo-nextjs +## 0.1.16 + ## 0.1.15 ## 0.1.14 diff --git a/apps/demo-nextjs/package.json b/apps/demo-nextjs/package.json index 98006b8ae74..62d2e5db99e 100644 --- a/apps/demo-nextjs/package.json +++ b/apps/demo-nextjs/package.json @@ -1,6 +1,6 @@ { "name": "demo-nextjs", - "version": "0.1.15", + "version": "0.1.16", "private": true, "scripts": { "original:dev": "next dev", diff --git a/apps/demo-nodejs-esm/CHANGELOG.md b/apps/demo-nodejs-esm/CHANGELOG.md index d48caed70aa..d944e4c8d41 100644 --- a/apps/demo-nodejs-esm/CHANGELOG.md +++ b/apps/demo-nodejs-esm/CHANGELOG.md @@ -27,3 +27,5 @@ ## null ## null + +## null diff --git a/apps/demo-react-cra/CHANGELOG.md b/apps/demo-react-cra/CHANGELOG.md index 6575d5eeb8b..6dbb32aad25 100644 --- a/apps/demo-react-cra/CHANGELOG.md +++ b/apps/demo-react-cra/CHANGELOG.md @@ -1,5 +1,7 @@ # demo-react-cra +## 0.1.16 + ## 0.1.15 ## 0.1.14 diff --git a/apps/demo-react-cra/package.json b/apps/demo-react-cra/package.json index 79f27fa6b9c..07ca930eb82 100644 --- a/apps/demo-react-cra/package.json +++ b/apps/demo-react-cra/package.json @@ -1,6 +1,6 @@ { "name": "demo-react-cra", - "version": "0.1.15", + "version": "0.1.16", "private": true, "dependencies": { "@fuels/vm-asm": "0.36.1", diff --git a/apps/demo-react-vite/CHANGELOG.md b/apps/demo-react-vite/CHANGELOG.md index 126f471c7e4..2197d3b9263 100644 --- a/apps/demo-react-vite/CHANGELOG.md +++ b/apps/demo-react-vite/CHANGELOG.md @@ -1,5 +1,7 @@ # demo-react-vite +## 0.0.16 + ## 0.0.15 ## 0.0.14 diff --git a/apps/demo-react-vite/package.json b/apps/demo-react-vite/package.json index dec7b8de59a..18038121dfe 100644 --- a/apps/demo-react-vite/package.json +++ b/apps/demo-react-vite/package.json @@ -1,7 +1,7 @@ { "name": "demo-react-vite", "private": true, - "version": "0.0.15", + "version": "0.0.16", "type": "module", "scripts": { "original:dev": "vite", diff --git a/apps/demo-typegen/CHANGELOG.md b/apps/demo-typegen/CHANGELOG.md index 47d45916482..2fbdd4eed18 100644 --- a/apps/demo-typegen/CHANGELOG.md +++ b/apps/demo-typegen/CHANGELOG.md @@ -35,3 +35,5 @@ ## null ## null + +## null diff --git a/apps/docs-snippets/CHANGELOG.md b/apps/docs-snippets/CHANGELOG.md index d5862811e55..5b4f5094b2a 100644 --- a/apps/docs-snippets/CHANGELOG.md +++ b/apps/docs-snippets/CHANGELOG.md @@ -1,5 +1,7 @@ # @fuel-ts/docs-snippets +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/apps/docs-snippets/package.json b/apps/docs-snippets/package.json index 5e6618d6278..4141225d668 100644 --- a/apps/docs-snippets/package.json +++ b/apps/docs-snippets/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/docs-snippets", - "version": "0.56.0", + "version": "0.56.1", "description": "", "private": true, "scripts": { diff --git a/apps/docs/CHANGELOG.md b/apps/docs/CHANGELOG.md index ba0eef30103..f38bfb4435c 100644 --- a/apps/docs/CHANGELOG.md +++ b/apps/docs/CHANGELOG.md @@ -1,5 +1,7 @@ # @fuel-ts/docs +## 0.42.8 + ## 0.42.7 ## 0.42.6 diff --git a/apps/docs/package.json b/apps/docs/package.json index fe2a083faa5..f00e913471c 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "docs", - "version": "0.42.7", + "version": "0.42.8", "description": "", "scripts": { "dev": "nodemon --config nodemon.config.json -x 'pnpm run docs && vitepress dev'", diff --git a/apps/docs/scripts/typedoc-postbuild.ts b/apps/docs/scripts/typedoc-postbuild.ts index 23b094eeeb1..887b4473fdc 100644 --- a/apps/docs/scripts/typedoc-postbuild.ts +++ b/apps/docs/scripts/typedoc-postbuild.ts @@ -174,4 +174,4 @@ const main = async () => { recreateInternalLinks(); }; -main(); +main().catch(process.stderr.write); diff --git a/internal/check-imports/CHANGELOG.md b/internal/check-imports/CHANGELOG.md index 71c99105be1..730422f8734 100644 --- a/internal/check-imports/CHANGELOG.md +++ b/internal/check-imports/CHANGELOG.md @@ -31,3 +31,5 @@ ## null ## null + +## null diff --git a/packages/abi-coder/CHANGELOG.md b/packages/abi-coder/CHANGELOG.md index dab9d7c0393..d0c8bddc9a2 100644 --- a/packages/abi-coder/CHANGELOG.md +++ b/packages/abi-coder/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ### Minor Changes diff --git a/packages/abi-coder/package.json b/packages/abi-coder/package.json index 6ab50800483..678e20962af 100644 --- a/packages/abi-coder/package.json +++ b/packages/abi-coder/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/abi-coder", - "version": "0.56.0", + "version": "0.56.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/abi-typegen/CHANGELOG.md b/packages/abi-typegen/CHANGELOG.md index 798014719ea..a2ceb5e8ae0 100644 --- a/packages/abi-typegen/CHANGELOG.md +++ b/packages/abi-typegen/CHANGELOG.md @@ -1,5 +1,7 @@ # @fuel-ts/abi-typegen +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/abi-typegen/package.json b/packages/abi-typegen/package.json index 5b8463ab352..915fcb47653 100644 --- a/packages/abi-typegen/package.json +++ b/packages/abi-typegen/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/abi-typegen", - "version": "0.56.0", + "version": "0.56.1", "description": "Generates Typescript definitions from Sway ABI Json files", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/address/CHANGELOG.md b/packages/address/CHANGELOG.md index 8e812d01d0d..e167613a361 100644 --- a/packages/address/CHANGELOG.md +++ b/packages/address/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/address/package.json b/packages/address/package.json index f6b754c241c..d7c4a4664da 100644 --- a/packages/address/package.json +++ b/packages/address/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/address", - "version": "0.56.0", + "version": "0.56.1", "description": "Utilities for encoding and decoding addresses", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/address/src/address.test.ts b/packages/address/src/address.test.ts index 0e132165d14..f7d8e06c08f 100644 --- a/packages/address/src/address.test.ts +++ b/packages/address/src/address.test.ts @@ -146,13 +146,13 @@ describe('Address utils', () => { expect(result).toEqual(ADDRESS_B256); }); - test('toB256 (b256 to b256)', () => { + test('toB256 (b256 to b256)', async () => { const address = ADDRESS_B256 as Bech32Address; const expectedError = new FuelError( FuelError.CODES.INVALID_BECH32_ADDRESS, `Invalid Bech32 Address: ${address}` ); - expectToThrowFuelError(() => utils.toB256(address), expectedError); + await expectToThrowFuelError(() => utils.toB256(address), expectedError); }); test('toBech32=>toB256', () => { @@ -169,13 +169,13 @@ describe('Address utils', () => { expect(result).toEqual(ADDRESS_B256_EVM); }); - test('clearFirst12BytesFromB256 (invalid B256)', () => { + test('clearFirst12BytesFromB256 (invalid B256)', async () => { const invalidB256 = '0x123'; const expectedError = new FuelError( FuelError.CODES.PARSE_FAILED, `Cannot generate EVM Address B256 from B256: ${invalidB256}` ); - expectToThrowFuelError(() => utils.clearFirst12BytesFromB256(invalidB256), expectedError); + await expectToThrowFuelError(() => utils.clearFirst12BytesFromB256(invalidB256), expectedError); }); }); @@ -243,12 +243,12 @@ describe('Address class', () => { expect(address.toB256()).toEqual(signMessageTest.b256Address); }); - test('create an Address class fromDynamicInput [bad input]', () => { + test('create an Address class fromDynamicInput [bad input]', async () => { const expectedError = new FuelError( FuelError.CODES.PARSE_FAILED, 'Unknown address format: only Bech32, B256, or Public Key (512) supported' ); - expectToThrowFuelError(() => Address.fromDynamicInput('badinput'), expectedError); + await expectToThrowFuelError(() => Address.fromDynamicInput('badinput'), expectedError); }); test('create an Address class fromDynamicInput [Address]', () => { diff --git a/packages/contract/CHANGELOG.md b/packages/contract/CHANGELOG.md index 4474ab8c6bc..e32100b55af 100644 --- a/packages/contract/CHANGELOG.md +++ b/packages/contract/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/contract/package.json b/packages/contract/package.json index 5c77ca6576b..7a3c7706fb5 100644 --- a/packages/contract/package.json +++ b/packages/contract/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/contract", - "version": "0.56.0", + "version": "0.56.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/crypto/CHANGELOG.md b/packages/crypto/CHANGELOG.md index ffc180d7a4b..c635cab283f 100644 --- a/packages/crypto/CHANGELOG.md +++ b/packages/crypto/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/crypto/package.json b/packages/crypto/package.json index 307eecda2b4..1eaade86a63 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/crypto", - "version": "0.56.0", + "version": "0.56.1", "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 fb7c6eb6686..d4e2b15d1d1 100644 --- a/packages/errors/CHANGELOG.md +++ b/packages/errors/CHANGELOG.md @@ -1,5 +1,11 @@ # @fuel-ts/errors +## 0.56.1 + +### Patch Changes + +- Simplyfing errors package and its test utility, by [@arboleya](https://github.com/arboleya) (See [#1228](https://github.com/FuelLabs/fuels-ts/pull/1228)) + ## 0.56.0 ### Minor Changes diff --git a/packages/errors/README.md b/packages/errors/README.md index ee00c2dac3b..cb3923c5f2b 100644 --- a/packages/errors/README.md +++ b/packages/errors/README.md @@ -10,7 +10,8 @@ This package contains core utilities regarding throwing errors internally inside - [Usage](#usage) - [Installation](#installation) - [Internal usage](#internal-usage) - - [Internal usage](#external-usage) + - [Test utilities](#test-utilities) + - [External usage](#external-usage) - [Contributing](#contributing) - [Changelog](#changelog) - [License](#license) @@ -45,6 +46,32 @@ export function multipleImports() { } ``` +### Test Utilities + +You can use the `expectToThrowFuelError` test utility when asserting errors. + +```ts +// can also be imported from `fuels` when using the umbrella package +import { expectToThrowFuelError } from "@fuel-ts/errors/test-utils"; + +import { myFn } from "..."; + +describe('this and that' () => { + const code = FuelError.CODES.INVALID_URL; + + it("should throw FuelError", async () => { + const expected = new FuelError(code); + await expectToThrowFuelError(() => myFn(), expected); + }); + + it("should throw something else", async () => { + const expected = new FuelError(code); + const fn = () => expectToThrowFuelError(() => myFn(), expected) + await expect(fn).rejects.toThrow('Something else'); + }); +}) +``` + ### External usage ```ts @@ -70,7 +97,7 @@ function translateError(e: unknown) { return i18nDict[currentLocale][code]; } -(function main() { +function main() { try { const p = new Provider("0004:tƨoʜlɒɔol//:qttʜ"); console.log(p); @@ -78,7 +105,7 @@ function translateError(e: unknown) { const prettyError = translateError(e); console.log({ prettyError }); } -})(); +); ``` ## Contributing diff --git a/packages/errors/package.json b/packages/errors/package.json index 286c57d2819..6ba0b938e91 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/errors", - "version": "0.56.0", + "version": "0.56.1", "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/errors/src/fuel-error.test.ts b/packages/errors/src/fuel-error.test.ts index bb945881bd1..cc591f6df66 100644 --- a/packages/errors/src/fuel-error.test.ts +++ b/packages/errors/src/fuel-error.test.ts @@ -22,18 +22,18 @@ describe('Parsing', () => { expect(error.code).toBe(ErrorCode.INVALID_URL); }); - it('fails when parsing an object without a code property', () => { + it('fails when parsing an object without a code property', async () => { const expectedError = new FuelError(FuelError.CODES.PARSE_FAILED, "missing 'code' property"); - expectToThrowFuelError(() => FuelError.parse({}), expectedError); + await expectToThrowFuelError(() => FuelError.parse({}), expectedError); }); - it('fails when parsing an object with an unknown error code', () => { + it('fails when parsing an object with an unknown error code', async () => { const code = 'qweqwe'; const expectedError = new FuelError( ErrorCode.PARSE_FAILED, `Unknown error code: ${code}. Accepted codes: ${Object.values(ErrorCode).join(', ')}.` ); - expectToThrowFuelError(() => FuelError.parse({ code }), expectedError); + await expectToThrowFuelError(() => FuelError.parse({ code }), expectedError); }); }); diff --git a/packages/errors/src/test-utils/expect-to-throw-fuel-error.test.ts b/packages/errors/src/test-utils/expect-to-throw-fuel-error.test.ts index 705b3a24ee3..640d9f3818f 100644 --- a/packages/errors/src/test-utils/expect-to-throw-fuel-error.test.ts +++ b/packages/errors/src/test-utils/expect-to-throw-fuel-error.test.ts @@ -3,86 +3,80 @@ import { FuelError } from '..'; import { expectToThrowFuelError } from './expect-to-throw-fuel-error'; describe('expect-to-throw-fuel-error', () => { - const error = new FuelError(FuelError.CODES.PARSE_FAILED, 'It happens'); - const throwFn = () => { - throw FuelError.parse(error); - }; - const asyncThrowFn = async () => new Promise(throwFn); + const otherError = new Error('Original Error'); + const fuelError = new FuelError(FuelError.CODES.PARSE_FAILED, 'FuelError 1'); + // @ts-expect-error creating invalid error with no `code` + const fuelErrorCodeless: FuelError = { message: 'FuelError 2' }; + // @ts-expect-error Creating invalid error with invalid `code` + const fuelErrorInvalid: FuelError = { code: 'xyz', message: 'FuelError 3' }; - it('compares whole or partial error objects (sync)', () => { - expectToThrowFuelError(throwFn, error); - expectToThrowFuelError(throwFn, { code: error.code }); - }); + const genericThrower = (error: Error) => () => { + throw error; + }; - it('compares whole or partial error objects (async)', async () => { - await expectToThrowFuelError(asyncThrowFn, error); - await expectToThrowFuelError(asyncThrowFn, { code: error.code }); - }); + const genericThrowerAsync = (error: Error) => async () => { + const p = new Promise(genericThrower(error)); + return p; + }; - it('fails when passed fn doesnt throw (sync)', () => { - expect(() => expectToThrowFuelError(() => {}, error)).toThrow("Passed-in lambda didn't throw."); - }); + const throwFuelError = genericThrower(fuelError); + const throwFuelErrorAsync = genericThrowerAsync(fuelError); + const throwFuelErrorInvalid = genericThrower(fuelErrorInvalid); + const throwFuelErrorInvalidAsync = genericThrowerAsync(fuelErrorInvalid); + const throwOtherError = genericThrower(otherError); + const throwOtherErrorAsync = genericThrowerAsync(otherError); - it('fails when passed fn doesnt throw (async)', async () => { - await expect(expectToThrowFuelError(async () => {}, error)).rejects.toThrow( - "Passed-in lambda didn't throw." - ); + it(`fails when passed fn doesn't throw`, async () => { + const fn = () => expectToThrowFuelError(() => {}, fuelError); + const fnAsync = () => expectToThrowFuelError(async () => {}, fuelError); + const m = `Passed-in lambda didn't throw.`; + await expect(fn).rejects.toThrow(m); + await expect(fnAsync).rejects.toThrow(m); }); - it('fails when partial error object doesnt contain code (sync)', () => { - expect(() => - expectToThrowFuelError( - throwFn, - // @ts-expect-error code property is required per type definition - { message: error.message } - ) - ).toThrow(`Expected error code 'undefined' is not a valid FuelError code.`); + it('compares whole or partial error objects', async () => { + const expected = { code: fuelError.code }; + await expectToThrowFuelError(throwFuelError, fuelError); + await expectToThrowFuelError(throwFuelErrorAsync, fuelError); + await expectToThrowFuelError(throwFuelError, expected); + await expectToThrowFuelError(throwFuelErrorAsync, expected); }); - it('fails when partial error object doesnt contain code (async)', async () => { - await expect( - expectToThrowFuelError( - asyncThrowFn, - // @ts-expect-error code property is required per type definition - { message: error.message } - ) - ).rejects.toThrow(`Expected error code 'undefined' is not a valid FuelError code.`); + it(`fails if thrown error doesn't have a code`, async () => { + const fn = () => expectToThrowFuelError(throwOtherError, fuelError); + const fnAsync = () => expectToThrowFuelError(throwOtherErrorAsync, fuelError); + const m = `Thrown error must contain a code.`; + await expect(fn).rejects.toThrow(m); + await expect(fnAsync).rejects.toThrow(m); }); - it('fails with non-fuel errors (sync)', () => { - const expected = { code: FuelError.CODES.PARSE_FAILED }; - const nonFuelThrowFn = () => { - throw new Error('x'); // not a FuelError - }; - - expect(() => expectToThrowFuelError(nonFuelThrowFn, expected)).toThrow( - 'Thrown error code is not a valid FuelError code.' - ); + it(`fails if thrown error code is invalid`, async () => { + const fn = () => expectToThrowFuelError(throwFuelErrorInvalid, fuelError); + const fnAsync = () => expectToThrowFuelError(throwFuelErrorInvalidAsync, fuelError); + const m = `Thrown error code '${fuelErrorInvalid.code}' is not a valid FuelError code.`; + await expect(fn).rejects.toThrow(m); + await expect(fnAsync).rejects.toThrow(m); }); - it('fails with non-fuel errors (async)', async () => { - const expected = { code: FuelError.CODES.PARSE_FAILED }; - const asyncThrower = async () => - new Promise(() => { - throw new Error('x'); // not a FuelError - }); - - await expect(expectToThrowFuelError(asyncThrower, expected)).rejects.toThrow( - 'Thrown error code is not a valid FuelError code.' - ); + it(`fails if expected error doesn't have a code`, async () => { + const fn = () => expectToThrowFuelError(throwFuelError, fuelErrorCodeless); + const fnAsync = () => expectToThrowFuelError(throwFuelErrorAsync, fuelErrorCodeless); + const m = `Expected error must contain a code.`; + await expect(fn).rejects.toThrow(m); + await expect(fnAsync).rejects.toThrow(m); }); - it('expected error must contain a valid FuelError code (sync)', () => { - const expected = { code: 'invalid-error-code' }; - expect(() => expectToThrowFuelError(throwFn, expected as FuelError)).toThrow( - `Expected error code '${expected.code}' is not a valid FuelError code.` - ); + it(`fails if expected error code is invalid`, async () => { + const fn = () => expectToThrowFuelError(throwFuelError, fuelErrorInvalid); + const fnAsync = () => expectToThrowFuelError(throwFuelErrorAsync, fuelErrorInvalid); + const m = `Expected error code '${fuelErrorInvalid.code}' is not a valid FuelError code.`; + await expect(fn).rejects.toThrow(m); + await expect(fnAsync).rejects.toThrow(m); }); - it('expected error must contain a valid FuelError code (async)', async () => { - const expected = { code: 'invalid-error-code' }; - await expect(expectToThrowFuelError(asyncThrowFn, expected as FuelError)).rejects.toThrow( - `Expected error code '${expected.code}' is not a valid FuelError code.` - ); + it(`contain information about original error`, async () => { + const errFn = genericThrower(otherError); + const fn = () => expectToThrowFuelError(errFn, fuelError); + await expect(fn).rejects.toThrow('Thrown error >>> Error: Original Error'); }); }); diff --git a/packages/errors/src/test-utils/expect-to-throw-fuel-error.ts b/packages/errors/src/test-utils/expect-to-throw-fuel-error.ts index c33e2f72abb..21ea0d27b7a 100644 --- a/packages/errors/src/test-utils/expect-to-throw-fuel-error.ts +++ b/packages/errors/src/test-utils/expect-to-throw-fuel-error.ts @@ -1,56 +1,42 @@ -import { isAsyncFunction } from 'util/types'; +import { safeExec } from '@fuel-ts/utils/test-utils'; import type { FuelError } from '../index'; import { ErrorCode } from '../index'; -const errorCodes = Object.values(ErrorCode); +type ExpectedFuelError = Partial & Required>; -function assertExpectations( - thrownError: FuelError, - expectedError: FuelError | (Partial & Required>) -) { - if (!errorCodes.includes(thrownError.code)) { - throw new Error('Thrown error code is not a valid FuelError code.'); +const codes = Object.values(ErrorCode); + +export const expectToThrowFuelError = async ( + lambda: () => unknown, + expectedError: ExpectedFuelError +) => { + if (!expectedError.code) { + throw new Error('Expected error must contain a code.'); } - if (!errorCodes.includes(expectedError.code)) { + if (!codes.includes(expectedError.code)) { throw new Error(`Expected error code '${expectedError.code}' is not a valid FuelError code.`); } - expect(thrownError.name).toEqual('FuelError'); + const { error: thrownError } = await safeExec(lambda); - ( - Object.getOwnPropertyNames(expectedError).filter((x) => x !== 'stack') as Array< - keyof typeof expectedError - > - ).forEach((key) => { - expect(thrownError?.[key]).toStrictEqual(expectedError[key]); - }); -} -export function expectToThrowFuelError< - Fn extends () => unknown, - R extends Promise | void = ReturnType extends Promise ? Promise : void ->(lambda: Fn, expectedError: Parameters[1]): R { - if (isAsyncFunction(lambda)) { - const promise = lambda() as Promise; - // @ts-expect-error TS ain't smart enough to figure out that R is indeed Promise - return promise.then( - () => { - throw new Error("Passed-in lambda didn't throw."); - }, - (e) => { - assertExpectations(e as FuelError, expectedError); - } - ); + if (!thrownError) { + throw new Error(`Passed-in lambda didn't throw.`); } - try { - lambda(); - } catch (e: unknown) { - assertExpectations(e as FuelError, expectedError); - // @ts-expect-error TS isn't happy here even though it is void/undefined... - // eslint-disable-next-line consistent-return - return; + + const thrownErrorStr = `Thrown error >>> ${thrownError.toString()}`; + + if (!thrownError.code) { + throw new Error(`Thrown error must contain a code. ${thrownErrorStr}`); } - throw new Error("Passed-in lambda didn't throw."); -} + if (!codes.includes(thrownError.code)) { + throw new Error( + `Thrown error code '${thrownError.code}' is not a valid FuelError code. ${thrownErrorStr}` + ); + } + + expect(thrownError.name).toEqual('FuelError'); + expect(thrownError).toMatchObject(expectedError); +}; diff --git a/packages/forc/CHANGELOG.md b/packages/forc/CHANGELOG.md index 5c64ee4318a..00ef294ee89 100644 --- a/packages/forc/CHANGELOG.md +++ b/packages/forc/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/forc/package.json b/packages/forc/package.json index c921a4f3592..dd7ed16e20c 100644 --- a/packages/forc/package.json +++ b/packages/forc/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/forc", - "version": "0.56.0", + "version": "0.56.1", "description": "NPM bin wrapper around Fuel `forc`", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/fuel-core/CHANGELOG.md b/packages/fuel-core/CHANGELOG.md index 03b810626f0..823ad32650f 100644 --- a/packages/fuel-core/CHANGELOG.md +++ b/packages/fuel-core/CHANGELOG.md @@ -1,5 +1,7 @@ # @fuel-ts/fuel-core +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/fuel-core/package.json b/packages/fuel-core/package.json index 633c0c3822a..11fa534fd48 100644 --- a/packages/fuel-core/package.json +++ b/packages/fuel-core/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/fuel-core", - "version": "0.56.0", + "version": "0.56.1", "description": "NPM bin wrapper around `fuel-core`", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/fuels/CHANGELOG.md b/packages/fuels/CHANGELOG.md index e21d0072cde..a855868418f 100644 --- a/packages/fuels/CHANGELOG.md +++ b/packages/fuels/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/fuels/package.json b/packages/fuels/package.json index 7f784e358c2..e0782bd8b12 100644 --- a/packages/fuels/package.json +++ b/packages/fuels/package.json @@ -1,6 +1,6 @@ { "name": "fuels", - "version": "0.56.0", + "version": "0.56.1", "description": "Fuel TS SDK", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/hasher/CHANGELOG.md b/packages/hasher/CHANGELOG.md index e2b4d87cf83..55851652be8 100644 --- a/packages/hasher/CHANGELOG.md +++ b/packages/hasher/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/hasher/package.json b/packages/hasher/package.json index b11ea98f17e..5f05e56cd06 100644 --- a/packages/hasher/package.json +++ b/packages/hasher/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/hasher", - "version": "0.56.0", + "version": "0.56.1", "description": "Sha256 hash utility for Fuel", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/hdwallet/CHANGELOG.md b/packages/hdwallet/CHANGELOG.md index 6eb069cdc95..7ddf9ecfeac 100644 --- a/packages/hdwallet/CHANGELOG.md +++ b/packages/hdwallet/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/hdwallet/package.json b/packages/hdwallet/package.json index 848cbb74ba3..88b1a138f69 100644 --- a/packages/hdwallet/package.json +++ b/packages/hdwallet/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/hdwallet", - "version": "0.56.0", + "version": "0.56.1", "description": "The Hierarchal Desterministic (HD) Wallet", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/interfaces/CHANGELOG.md b/packages/interfaces/CHANGELOG.md index ae6c69c71b0..018a745cd97 100644 --- a/packages/interfaces/CHANGELOG.md +++ b/packages/interfaces/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index afd06d7a912..3361813c247 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/interfaces", - "version": "0.56.0", + "version": "0.56.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/math/CHANGELOG.md b/packages/math/CHANGELOG.md index 38fa3ac22db..1c04fbef68b 100644 --- a/packages/math/CHANGELOG.md +++ b/packages/math/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/math/package.json b/packages/math/package.json index a005a8c7658..064c602b7b2 100644 --- a/packages/math/package.json +++ b/packages/math/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/math", - "version": "0.56.0", + "version": "0.56.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/merkle/CHANGELOG.md b/packages/merkle/CHANGELOG.md index deabad84287..e19be442bfa 100644 --- a/packages/merkle/CHANGELOG.md +++ b/packages/merkle/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/merkle/package.json b/packages/merkle/package.json index 09a3b307e11..29359ca3e9a 100644 --- a/packages/merkle/package.json +++ b/packages/merkle/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/merkle", - "version": "0.56.0", + "version": "0.56.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/mnemonic/CHANGELOG.md b/packages/mnemonic/CHANGELOG.md index ef903b2fc0a..dfca1d9d413 100644 --- a/packages/mnemonic/CHANGELOG.md +++ b/packages/mnemonic/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/mnemonic/package.json b/packages/mnemonic/package.json index 9eb78f9496a..8139afb259c 100644 --- a/packages/mnemonic/package.json +++ b/packages/mnemonic/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/mnemonic", - "version": "0.56.0", + "version": "0.56.1", "description": "Mnemonic implementation from BIP39", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/predicate/CHANGELOG.md b/packages/predicate/CHANGELOG.md index eb107356364..d76eb85641e 100644 --- a/packages/predicate/CHANGELOG.md +++ b/packages/predicate/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/predicate/package.json b/packages/predicate/package.json index f0e809b1e8d..a4af7bed052 100644 --- a/packages/predicate/package.json +++ b/packages/predicate/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/predicate", - "version": "0.56.0", + "version": "0.56.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/predicate/test/features/predicate-transactions.test.ts b/packages/predicate/test/features/predicate-transactions.test.ts index e64d22344d0..33956316da2 100644 --- a/packages/predicate/test/features/predicate-transactions.test.ts +++ b/packages/predicate/test/features/predicate-transactions.test.ts @@ -29,12 +29,12 @@ describe('Predicate', () => { txCreatedIdx: bn(0), }); - it('includes predicate as input when sending a transaction', () => { + it('includes predicate as input when sending a transaction', async () => { const sendTransactionMock = jest .spyOn(Account.prototype, 'sendTransaction') .mockImplementation(); - predicate.sendTransaction(request); + await predicate.sendTransaction(request); const inputCoinMock = sendTransactionMock.mock.calls[0][0] .inputs?.[0] as unknown as InputCoin; @@ -42,12 +42,12 @@ describe('Predicate', () => { expect(hexlify(inputCoinMock.predicateData)).toBe(b256); }); - it('includes predicate as input when simulating a transaction', () => { + it('includes predicate as input when simulating a transaction', async () => { const sendTransactionMock = jest .spyOn(Account.prototype, 'simulateTransaction') .mockImplementation(); - predicate.simulateTransaction(request); + await predicate.simulateTransaction(request); const inputCoinMock = sendTransactionMock.mock.calls[0][0] .inputs?.[0] as unknown as InputCoin; diff --git a/packages/program/CHANGELOG.md b/packages/program/CHANGELOG.md index df4a0ab4cdf..28afa172e2d 100644 --- a/packages/program/CHANGELOG.md +++ b/packages/program/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ### Minor Changes diff --git a/packages/program/package.json b/packages/program/package.json index 09146ab32d1..0dec7277daf 100644 --- a/packages/program/package.json +++ b/packages/program/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/program", - "version": "0.56.0", + "version": "0.56.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/providers/CHANGELOG.md b/packages/providers/CHANGELOG.md index 55b6e9278aa..f264008cc55 100644 --- a/packages/providers/CHANGELOG.md +++ b/packages/providers/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/providers/package.json b/packages/providers/package.json index f9d767f88a6..cdbf1ac3019 100644 --- a/packages/providers/package.json +++ b/packages/providers/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/providers", - "version": "0.56.0", + "version": "0.56.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/script/CHANGELOG.md b/packages/script/CHANGELOG.md index 611478c78ee..00b3df965e5 100644 --- a/packages/script/CHANGELOG.md +++ b/packages/script/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/script/package.json b/packages/script/package.json index 33aa8a5c0d8..d9a49adf7fa 100644 --- a/packages/script/package.json +++ b/packages/script/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/script", - "version": "0.56.0", + "version": "0.56.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/signer/CHANGELOG.md b/packages/signer/CHANGELOG.md index e3511a3fcf6..9b56e690460 100644 --- a/packages/signer/CHANGELOG.md +++ b/packages/signer/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/signer/package.json b/packages/signer/package.json index 5368732474b..a06c17717a6 100644 --- a/packages/signer/package.json +++ b/packages/signer/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/signer", - "version": "0.56.0", + "version": "0.56.1", "description": "Secp256k1 signer for the Fuel Network", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/testcases/CHANGELOG.md b/packages/testcases/CHANGELOG.md index f20aca0fabb..7d786b55273 100644 --- a/packages/testcases/CHANGELOG.md +++ b/packages/testcases/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/testcases/package.json b/packages/testcases/package.json index ed46257c1ee..adee704cc4e 100644 --- a/packages/testcases/package.json +++ b/packages/testcases/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/testcases", - "version": "0.56.0", + "version": "0.56.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "files": [ diff --git a/packages/transactions/CHANGELOG.md b/packages/transactions/CHANGELOG.md index 109b783bb5e..0c6928c912d 100644 --- a/packages/transactions/CHANGELOG.md +++ b/packages/transactions/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/transactions/package.json b/packages/transactions/package.json index c479f5dddd8..0a576e7450e 100644 --- a/packages/transactions/package.json +++ b/packages/transactions/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/transactions", - "version": "0.56.0", + "version": "0.56.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index b76671c43d1..6f44dc7eacf 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -1,5 +1,7 @@ # @fuel-ts/utils +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/utils/package.json b/packages/utils/package.json index 7a93cd298e4..3ed7a27ba9e 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/utils", - "version": "0.56.0", + "version": "0.56.1", "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 4ea76d74695..53b7200c734 100644 --- a/packages/versions/CHANGELOG.md +++ b/packages/versions/CHANGELOG.md @@ -1,5 +1,7 @@ # @fuel-ts/versions +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/versions/package.json b/packages/versions/package.json index 0c6898c09b0..baab5d607ca 100644 --- a/packages/versions/package.json +++ b/packages/versions/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/versions", - "version": "0.56.0", + "version": "0.56.1", "description": "Validates supported versions of the Fuel toolchain", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/versions/src/lib/getSupportedVersions.ts b/packages/versions/src/lib/getSupportedVersions.ts index dd285e158d6..2904379e336 100644 --- a/packages/versions/src/lib/getSupportedVersions.ts +++ b/packages/versions/src/lib/getSupportedVersions.ts @@ -2,6 +2,6 @@ export function getSupportedVersions() { return { FORC: '0.44.0', FUEL_CORE: '0.20.4', - FUELS: '0.56.0', + FUELS: '0.56.1', }; } diff --git a/packages/wallet-manager/CHANGELOG.md b/packages/wallet-manager/CHANGELOG.md index 6973ff051ee..f2c2cbcd80e 100644 --- a/packages/wallet-manager/CHANGELOG.md +++ b/packages/wallet-manager/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/wallet-manager/package.json b/packages/wallet-manager/package.json index ce7db68b646..e987092df0b 100644 --- a/packages/wallet-manager/package.json +++ b/packages/wallet-manager/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/wallet-manager", - "version": "0.56.0", + "version": "0.56.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/wallet-manager/src/wallet-manager.ts b/packages/wallet-manager/src/wallet-manager.ts index f10b989dea7..da3915a39c6 100644 --- a/packages/wallet-manager/src/wallet-manager.ts +++ b/packages/wallet-manager/src/wallet-manager.ts @@ -183,14 +183,14 @@ export class WalletManager extends EventEmitter { * Lock wallet. It removes passphrase from class instance, encrypt and hide all address and * secrets. */ - async lock() { + lock() { this.#isLocked = true; // Clean state vaults from state this.#vaults = []; // Clean password from state this.#passphrase = ''; // Emit event that wallet is locked - await this.emit('lock'); + this.emit('lock'); } /** diff --git a/packages/wallet/CHANGELOG.md b/packages/wallet/CHANGELOG.md index 661fe6da1c6..23236734821 100644 --- a/packages/wallet/CHANGELOG.md +++ b/packages/wallet/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 0.56.1 + +### Patch Changes + +- Awaiting for WASM initialization inside wallet utility, by [@arboleya](https://github.com/arboleya) (See [#1243](https://github.com/FuelLabs/fuels-ts/pull/1243)) + ## 0.56.0 ## 0.55.0 diff --git a/packages/wallet/package.json b/packages/wallet/package.json index efd020da887..c695bf7b395 100644 --- a/packages/wallet/package.json +++ b/packages/wallet/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/wallet", - "version": "0.56.0", + "version": "0.56.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/wordlists/CHANGELOG.md b/packages/wordlists/CHANGELOG.md index c67e9532d9c..c9cf125ba28 100644 --- a/packages/wordlists/CHANGELOG.md +++ b/packages/wordlists/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 0.56.1 + ## 0.56.0 ## 0.55.0 diff --git a/packages/wordlists/package.json b/packages/wordlists/package.json index 74dba0440d2..5434660b055 100644 --- a/packages/wordlists/package.json +++ b/packages/wordlists/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/wordlists", - "version": "0.56.0", + "version": "0.56.1", "description": "", "license": "Apache-2.0", "author": "Fuel Labs (https://fuel.network/)", diff --git a/scripts/changeset-next.ts b/scripts/changeset-next.ts index efe77b6b789..91ce3b26a60 100644 --- a/scripts/changeset-next.ts +++ b/scripts/changeset-next.ts @@ -1,4 +1,4 @@ -import { writeFile } from 'node:fs/promises'; +import { writeFileSync } from 'node:fs'; const output = `---\n"fuels": patch\n---\n\nincremental\n`; -writeFile('.changeset/fuel-labs-ci.md', output); +writeFileSync('.changeset/fuel-labs-ci.md', output); diff --git a/scripts/verify-forc-version.ts b/scripts/verify-forc-version.ts index d9b59cca816..1fa67ce4bcb 100644 --- a/scripts/verify-forc-version.ts +++ b/scripts/verify-forc-version.ts @@ -7,4 +7,4 @@ import path from 'path'; if (forcVersion.indexOf('git:') !== -1) { throw new Error('Cannot publish from a git branch. Please use a release directly.'); } -})(); +})().catch(process.stderr.write);