Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
Browse files Browse the repository at this point in the history
…/feat/replace-lodash-with-ramda
  • Loading branch information
danielbate committed Sep 13, 2023
2 parents c9cfc52 + e49d63c commit 6016ea7
Show file tree
Hide file tree
Showing 80 changed files with 249 additions and 168 deletions.
5 changes: 0 additions & 5 deletions .changeset/rich-dryers-do.md

This file was deleted.

1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
{
Expand Down
2 changes: 2 additions & 0 deletions apps/demo-nextjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# demo-nextjs

## 0.1.16

## 0.1.15

## 0.1.14
Expand Down
2 changes: 1 addition & 1 deletion apps/demo-nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "demo-nextjs",
"version": "0.1.15",
"version": "0.1.16",
"private": true,
"scripts": {
"original:dev": "next dev",
Expand Down
2 changes: 2 additions & 0 deletions apps/demo-nodejs-esm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@
## null

## null

## null
2 changes: 2 additions & 0 deletions apps/demo-react-cra/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# demo-react-cra

## 0.1.16

## 0.1.15

## 0.1.14
Expand Down
2 changes: 1 addition & 1 deletion apps/demo-react-cra/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions apps/demo-react-vite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# demo-react-vite

## 0.0.16

## 0.0.15

## 0.0.14
Expand Down
2 changes: 1 addition & 1 deletion apps/demo-react-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "demo-react-vite",
"private": true,
"version": "0.0.15",
"version": "0.0.16",
"type": "module",
"scripts": {
"original:dev": "vite",
Expand Down
2 changes: 2 additions & 0 deletions apps/demo-typegen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@
## null

## null

## null
2 changes: 2 additions & 0 deletions apps/docs-snippets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @fuel-ts/docs-snippets

## 0.56.1

## 0.56.0

## 0.55.0
Expand Down
2 changes: 1 addition & 1 deletion apps/docs-snippets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fuel-ts/docs-snippets",
"version": "0.56.0",
"version": "0.56.1",
"description": "",
"private": true,
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions apps/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @fuel-ts/docs

## 0.42.8

## 0.42.7

## 0.42.6
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
@@ -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'",
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/scripts/typedoc-postbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,4 @@ const main = async () => {
recreateInternalLinks();
};

main();
main().catch(process.stderr.write);
2 changes: 2 additions & 0 deletions internal/check-imports/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@
## null

## null

## null
2 changes: 2 additions & 0 deletions packages/abi-coder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 0.56.1

## 0.56.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/abi-coder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fuel-ts/abi-coder",
"version": "0.56.0",
"version": "0.56.1",
"description": "",
"author": "Fuel Labs <contact@fuel.sh> (https://fuel.network/)",
"main": "dist/index.js",
Expand Down
2 changes: 2 additions & 0 deletions packages/abi-typegen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @fuel-ts/abi-typegen

## 0.56.1

## 0.56.0

## 0.55.0
Expand Down
2 changes: 1 addition & 1 deletion packages/abi-typegen/package.json
Original file line number Diff line number Diff line change
@@ -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 <contact@fuel.sh> (https://fuel.network/)",
"bin": {
Expand Down
2 changes: 2 additions & 0 deletions packages/address/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 0.56.1

## 0.56.0

## 0.55.0
Expand Down
2 changes: 1 addition & 1 deletion packages/address/package.json
Original file line number Diff line number Diff line change
@@ -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 <contact@fuel.sh> (https://fuel.network/)",
"main": "dist/index.js",
Expand Down
12 changes: 6 additions & 6 deletions packages/address/src/address.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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);
});
});

Expand Down Expand Up @@ -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]', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/contract/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 0.56.1

## 0.56.0

## 0.55.0
Expand Down
2 changes: 1 addition & 1 deletion packages/contract/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fuel-ts/contract",
"version": "0.56.0",
"version": "0.56.1",
"description": "",
"author": "Fuel Labs <contact@fuel.sh> (https://fuel.network/)",
"main": "dist/index.js",
Expand Down
2 changes: 2 additions & 0 deletions packages/crypto/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 0.56.1

## 0.56.0

## 0.55.0
Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/package.json
Original file line number Diff line number Diff line change
@@ -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 <contact@fuel.sh> (https://fuel.network/)",
"main": "dist/index.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/errors/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
33 changes: 30 additions & 3 deletions packages/errors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -70,15 +97,15 @@ 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);
} catch (e) {
const prettyError = translateError(e);
console.log({ prettyError });
}
})();
);
```
## Contributing
Expand Down
2 changes: 1 addition & 1 deletion packages/errors/package.json
Original file line number Diff line number Diff line change
@@ -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 <contact@fuel.sh> (https://fuel.network/)",
"main": "dist/index.js",
Expand Down
8 changes: 4 additions & 4 deletions packages/errors/src/fuel-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down
Loading

0 comments on commit 6016ea7

Please sign in to comment.