Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: FuelLabs/fuels-ts
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0ecec63e904802506c8571f0a1246107c3ecac52
Choose a base ref
..
head repository: FuelLabs/fuels-ts
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c1ae3473dbb2171c0508d8279f677746e756f4b6
Choose a head ref
11 changes: 6 additions & 5 deletions internal/check-imports/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,21 +6,22 @@

- Updated dependencies [981b992]
- Updated dependencies [11fcd7b]
- Updated dependencies [a7eb9b6]
- fuels@0.97.3
- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/abi-typegen@0.97.3
- @fuel-ts/account@0.97.3
- @fuel-ts/address@0.97.3
- @fuel-ts/contract@0.97.3
- @fuel-ts/program@0.97.3
- @fuel-ts/script@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/abi-typegen@0.97.3
- @fuel-ts/address@0.97.3
- @fuel-ts/crypto@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/hasher@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/merkle@0.97.3
- @fuel-ts/program@0.97.3
- @fuel-ts/script@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/utils@0.97.3
- @fuel-ts/versions@0.97.3

13 changes: 7 additions & 6 deletions packages/abi-coder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,12 +4,13 @@

### Patch Changes

- @fuel-ts/crypto@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/hasher@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/utils@0.97.3
- a7eb9b6: fix: validation and handling of unsafe integers
- @fuel-ts/crypto@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/hasher@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/utils@0.97.3

## 0.97.2

57 changes: 57 additions & 0 deletions packages/abi-coder/src/encoding/coders/BigNumberCoder.test.ts
Original file line number Diff line number Diff line change
@@ -23,6 +23,52 @@ describe('BigNumberCoder', () => {
expect(actual).toStrictEqual(expected);
});

it('should encode a u64 [max safe integer]', () => {
const coder = new BigNumberCoder('u64');
const value: number = Number.MAX_SAFE_INTEGER;
const expected = new Uint8Array([0, 31, 255, 255, 255, 255, 255, 255]);

const data = coder.encode(value);

expect(data).toEqual(expected);
});

it('should throw an error when encoding [number more than max safe integer]', async () => {
const coder = new BigNumberCoder('u64');
const value: number = Number.MAX_SAFE_INTEGER + 1;

await expectToThrowFuelError(
() => coder.encode(value),
new FuelError(
ErrorCode.ENCODE_ERROR,
'Invalid u64 type - number value is too large. Number can only safely handle up to 53 bits.'
)
);
});

it('should encode a u64 [very big number - as string]', () => {
const coder = new BigNumberCoder('u64');
const value: string = '76472027892439376';
const expected = new Uint8Array([1, 15, 174, 231, 121, 200, 89, 80]);

const data = coder.encode(value);

expect(data).toEqual(expected);
});

it('should throw an error when encoding [number more than max safe integer]', async () => {
const coder = new BigNumberCoder('u64');
const value: number = 76472027892439376;

await expectToThrowFuelError(
() => coder.encode(value),
new FuelError(
ErrorCode.ENCODE_ERROR,
'Invalid u64 type - number value is too large. Number can only safely handle up to 53 bits.'
)
);
});

it('should decode a u64 number', () => {
const coder = new BigNumberCoder('u64');
const expectedValue = 0;
@@ -34,6 +80,17 @@ describe('BigNumberCoder', () => {
expect(actualLength).toBe(expectedLength);
});

it('should decode a u64 [very big number]', () => {
const coder = new BigNumberCoder('u64');
const data = new Uint8Array([1, 15, 174, 231, 121, 200, 89, 80]);
const expectedValue = bn('76472027892439376');

const [actualValue, actualLength] = coder.decode(data, 0);

expect(actualValue).toEqualBn(expectedValue);
expect(actualLength).toEqual(8);
});

it('should encode u8 max number', () => {
const coder = new BigNumberCoder('u64');
const expected = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 255]);
10 changes: 10 additions & 0 deletions packages/abi-coder/src/encoding/coders/BigNumberCoder.ts
Original file line number Diff line number Diff line change
@@ -20,6 +20,16 @@ export class BigNumberCoder extends Coder<BNInput, BN> {
encode(value: BNInput): Uint8Array {
let bytes;

// We throw an error if the value is a number and it's more than the max safe integer
// This is because we can experience some odd behavior with integers more than the max safe integer
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER#description
if (typeof value === 'number' && value > Number.MAX_SAFE_INTEGER) {
throw new FuelError(
ErrorCode.ENCODE_ERROR,
`Invalid ${this.type} type - number value is too large. Number can only safely handle up to 53 bits.`
);
}

try {
bytes = toBytes(value, this.encodedLength);
} catch (error) {
23 changes: 12 additions & 11 deletions packages/account/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,17 +4,18 @@

### Patch Changes

- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/address@0.97.3
- @fuel-ts/crypto@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/hasher@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/merkle@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/utils@0.97.3
- @fuel-ts/versions@0.97.3
- Updated dependencies [a7eb9b6]
- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/address@0.97.3
- @fuel-ts/crypto@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/hasher@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/merkle@0.97.3
- @fuel-ts/utils@0.97.3
- @fuel-ts/versions@0.97.3

## 0.97.2

25 changes: 13 additions & 12 deletions packages/contract/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,18 +4,19 @@

### Patch Changes

- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/account@0.97.3
- @fuel-ts/crypto@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/hasher@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/merkle@0.97.3
- @fuel-ts/program@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/utils@0.97.3
- @fuel-ts/versions@0.97.3
- Updated dependencies [a7eb9b6]
- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/account@0.97.3
- @fuel-ts/program@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/crypto@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/hasher@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/merkle@0.97.3
- @fuel-ts/utils@0.97.3
- @fuel-ts/versions@0.97.3

## 0.97.2

13 changes: 7 additions & 6 deletions packages/fuels/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,21 +6,22 @@

- 981b992: docs: improving getting started docs for `mainnet`
- 11fcd7b: fix: paths and globals in `fuels init`
- Updated dependencies [a7eb9b6]
- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/abi-typegen@0.97.3
- @fuel-ts/account@0.97.3
- @fuel-ts/address@0.97.3
- @fuel-ts/contract@0.97.3
- @fuel-ts/program@0.97.3
- @fuel-ts/recipes@0.97.3
- @fuel-ts/script@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/abi-typegen@0.97.3
- @fuel-ts/address@0.97.3
- @fuel-ts/crypto@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/hasher@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/merkle@0.97.3
- @fuel-ts/program@0.97.3
- @fuel-ts/recipes@0.97.3
- @fuel-ts/script@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/utils@0.97.3
- @fuel-ts/versions@0.97.3

17 changes: 9 additions & 8 deletions packages/program/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,14 +4,15 @@

### Patch Changes

- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/account@0.97.3
- @fuel-ts/address@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/utils@0.97.3
- Updated dependencies [a7eb9b6]
- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/account@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/address@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/utils@0.97.3

## 0.97.2

17 changes: 9 additions & 8 deletions packages/recipes/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,14 +4,15 @@

### Patch Changes

- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/abi-typegen@0.97.3
- @fuel-ts/account@0.97.3
- @fuel-ts/contract@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/program@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/utils@0.97.3
- Updated dependencies [a7eb9b6]
- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/account@0.97.3
- @fuel-ts/contract@0.97.3
- @fuel-ts/program@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/abi-typegen@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/utils@0.97.3

## 0.97.2

19 changes: 10 additions & 9 deletions packages/script/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,15 +4,16 @@

### Patch Changes

- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/account@0.97.3
- @fuel-ts/address@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/program@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/utils@0.97.3
- Updated dependencies [a7eb9b6]
- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/account@0.97.3
- @fuel-ts/program@0.97.3
- @fuel-ts/transactions@0.97.3
- @fuel-ts/address@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/utils@0.97.3

## 0.97.2

15 changes: 8 additions & 7 deletions packages/transactions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,13 +4,14 @@

### Patch Changes

- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/address@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/hasher@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/utils@0.97.3
- Updated dependencies [a7eb9b6]
- @fuel-ts/abi-coder@0.97.3
- @fuel-ts/address@0.97.3
- @fuel-ts/errors@0.97.3
- @fuel-ts/hasher@0.97.3
- @fuel-ts/interfaces@0.97.3
- @fuel-ts/math@0.97.3
- @fuel-ts/utils@0.97.3

## 0.97.2