From 5ad7472349ed7cce5b1bb2d7df78651258483da6 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 28 Mar 2024 11:02:04 -0300 Subject: [PATCH 01/92] Upgrading `forc` to `0.51.1` --- .changeset/tidy-olives-dance.md | 7 +++++++ .../abi-typegen/src/templates/contract/bytecode.test.ts | 2 +- .../test/fixtures/templates/contract/bytecode.hbs | 2 +- packages/forc/VERSION | 2 +- packages/fuel-gauge/src/script-with-vectors.test.ts | 4 ++-- .../test/fixtures/forc-projects/token_abi/src/main.sw | 6 +++--- packages/versions/src/lib/getBuiltinVersions.ts | 2 +- 7 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 .changeset/tidy-olives-dance.md diff --git a/.changeset/tidy-olives-dance.md b/.changeset/tidy-olives-dance.md new file mode 100644 index 00000000000..6e830b55472 --- /dev/null +++ b/.changeset/tidy-olives-dance.md @@ -0,0 +1,7 @@ +--- +"@fuel-ts/abi-typegen": patch +"@fuel-ts/forc": patch +"@fuel-ts/versions": patch +--- + +chore: upgrading `forc` to `0.51.1` diff --git a/packages/abi-typegen/src/templates/contract/bytecode.test.ts b/packages/abi-typegen/src/templates/contract/bytecode.test.ts index e110dfb93a7..e6fbcfc2bd5 100644 --- a/packages/abi-typegen/src/templates/contract/bytecode.test.ts +++ b/packages/abi-typegen/src/templates/contract/bytecode.test.ts @@ -25,6 +25,6 @@ describe('templates/contract/bytecode', () => { // validating restore(); - expect(rendered.trim()).toEqual(bytecodeTemplate); + expect(rendered.trim()).toEqual(bytecodeTemplate.trim()); }); }); diff --git a/packages/abi-typegen/test/fixtures/templates/contract/bytecode.hbs b/packages/abi-typegen/test/fixtures/templates/contract/bytecode.hbs index 0693e86bdf1..33096db6af7 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 '0x740000034700000000000000000000445dfcc00110fff3005d4060495d47f001134904407648000272f0007b36f000001aec5000910000005c43f000244000004700000001000000000000000000000055b7ae10' \ No newline at end of file +export default '0x740000034700000000000000000000445dfcc00110fff3005d4060495d47f001134904407648000272f0007b36f000001aec50005c43f00024400000470000000000000001000000000000000000000055b7ae10' diff --git a/packages/forc/VERSION b/packages/forc/VERSION index 72c9da1faf2..1e0c609c978 100644 --- a/packages/forc/VERSION +++ b/packages/forc/VERSION @@ -1 +1 @@ -0.49.3 +0.51.1 diff --git a/packages/fuel-gauge/src/script-with-vectors.test.ts b/packages/fuel-gauge/src/script-with-vectors.test.ts index deb398b26aa..a3d0cd39872 100644 --- a/packages/fuel-gauge/src/script-with-vectors.test.ts +++ b/packages/fuel-gauge/src/script-with-vectors.test.ts @@ -41,13 +41,13 @@ describe('Script With Vectors', () => { expect(formattedLog).toEqual([ 7, 'vector.buf.ptr', - 11256, + 11232, 'vector.capacity()', 4, 'vector.len()', 4, 'addr_of vector', - 11232, + 11208, ]); }); diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/token_abi/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/token_abi/src/main.sw index 941eb292856..9a025e2a77c 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/token_abi/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/token_abi/src/main.sw @@ -3,9 +3,9 @@ library; use std::{address::Address, asset::*, contract_id::ContractId}; pub struct TransferParams { - recipient: Recipient, - asset_id: AssetId, - amount: u64, + pub recipient: Recipient, + pub asset_id: AssetId, + pub amount: u64, } abi Token { diff --git a/packages/versions/src/lib/getBuiltinVersions.ts b/packages/versions/src/lib/getBuiltinVersions.ts index a39135fddab..c4a0d80f68f 100644 --- a/packages/versions/src/lib/getBuiltinVersions.ts +++ b/packages/versions/src/lib/getBuiltinVersions.ts @@ -1,6 +1,6 @@ export function getBuiltinVersions() { return { - FORC: '0.49.3', + FORC: '0.51.1', FUEL_CORE: '0.22.1', FUELS: '0.79.0', }; From d6228560aefd9584c72dec1d48cd979f48fedd31 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 4 Apr 2024 21:16:57 -0300 Subject: [PATCH 02/92] Upgrading `forc` to `0.52.1` --- packages/forc/VERSION | 2 +- packages/versions/src/lib/getBuiltinVersions.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/forc/VERSION b/packages/forc/VERSION index 1e0c609c978..27d68a6aacb 100644 --- a/packages/forc/VERSION +++ b/packages/forc/VERSION @@ -1 +1 @@ -0.51.1 +0.52.1 diff --git a/packages/versions/src/lib/getBuiltinVersions.ts b/packages/versions/src/lib/getBuiltinVersions.ts index c4a0d80f68f..ecb8788b6e8 100644 --- a/packages/versions/src/lib/getBuiltinVersions.ts +++ b/packages/versions/src/lib/getBuiltinVersions.ts @@ -1,6 +1,6 @@ export function getBuiltinVersions() { return { - FORC: '0.51.1', + FORC: '0.52.1', FUEL_CORE: '0.22.1', FUELS: '0.79.0', }; From cca95fe0dd5eb5b572276c217680676d3983d81f Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 4 Apr 2024 21:17:51 -0300 Subject: [PATCH 03/92] Updating `prt()` accessor for `Vec`s --- .../test/fixtures/forc-projects/script-with-vector/src/main.sw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw index 70a1830993c..5cc01908e72 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw @@ -12,7 +12,7 @@ fn main(vector: Vec) { assert(vector.capacity() == 4); assert(vector.is_empty() == false); log(__to_str_array("vector.buf.ptr")); - log(vector.buf.ptr); + log(vector.ptr()); log(__to_str_array("vector.capacity()")); log(vector.capacity()); log(__to_str_array("vector.len()")); From 93e2d91c0df01680b031b6995e59003433aa7cae Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Fri, 5 Apr 2024 11:08:19 -0300 Subject: [PATCH 04/92] Applying new format for `AssetId` --- .../guide/contracts/contract-balance.test.ts | 2 +- .../guide/contracts/variable-outputs.test.ts | 4 ++-- .../cookbook/deposit-and-withdraw.test.ts | 4 ++-- .../scripts/script-custom-transaction.test.ts | 4 ++-- .../src/guide/types/asset-id.test.ts | 10 ++++----- .../src/guide/types/contract-types.test.ts | 20 ++++++++--------- .../src/guide/types/evm-address.test.ts | 16 ++++++-------- .../forc-projects/echo-asset-id/src/main.sw | 4 +--- .../predicate-signing/src/main.sw | 2 +- .../forc-projects/script-signing/src/main.sw | 2 +- .../forc-projects/token-depositor/src/main.sw | 2 +- .../fixtures/templates/contract/bytecode.hbs | 2 +- .../test/fixtures/templates/contract/dts.hbs | 2 +- packages/address/src/address.test.ts | 6 ++--- packages/address/src/address.ts | 4 ++-- .../fuel-gauge/src/advanced-logging.test.ts | 8 +++---- packages/fuel-gauge/src/auth-testing.test.ts | 4 ++-- .../fuel-gauge/src/coverage-contract.test.ts | 2 +- .../src/multi-token-contract.test.ts | 16 +++++++------- packages/fuel-gauge/src/revert-error.test.ts | 6 ++--- .../src/token-test-contract.test.ts | 20 ++++++++--------- .../src/transaction-summary.test.ts | 22 +++++++++---------- .../call-test-contract/src/main.sw | 2 +- .../predicate-triple-sig/src/main.sw | 2 +- .../forc-projects/revert-error/src/main.sw | 11 +++------- packages/interfaces/src/index.ts | 8 +++---- 26 files changed, 88 insertions(+), 97 deletions(-) diff --git a/apps/docs-snippets/src/guide/contracts/contract-balance.test.ts b/apps/docs-snippets/src/guide/contracts/contract-balance.test.ts index 7ceae4643df..dc46ab89979 100644 --- a/apps/docs-snippets/src/guide/contracts/contract-balance.test.ts +++ b/apps/docs-snippets/src/guide/contracts/contract-balance.test.ts @@ -28,7 +28,7 @@ describe(__filename, () => { }); const asset: AssetId = { - value: BaseAssetId, + bits: BaseAssetId, }; await contract.functions diff --git a/apps/docs-snippets/src/guide/contracts/variable-outputs.test.ts b/apps/docs-snippets/src/guide/contracts/variable-outputs.test.ts index 720704db1ba..a614ee41c5c 100644 --- a/apps/docs-snippets/src/guide/contracts/variable-outputs.test.ts +++ b/apps/docs-snippets/src/guide/contracts/variable-outputs.test.ts @@ -18,8 +18,8 @@ describe(__filename, () => { await contract.functions.mint_coins(subId, 100).call(); - const address = { value: Wallet.generate().address.toB256() }; - const assetId = { value: getMintedAssetId(contract.id.toB256(), subId) }; + const address = { bits: Wallet.generate().address.toB256() }; + const assetId = { bits: getMintedAssetId(contract.id.toB256(), subId) }; // #region variable-outputs-2 const { transactionResult } = await contract.functions diff --git a/apps/docs-snippets/src/guide/cookbook/deposit-and-withdraw.test.ts b/apps/docs-snippets/src/guide/cookbook/deposit-and-withdraw.test.ts index aff3abc05f6..41e45a9e31e 100644 --- a/apps/docs-snippets/src/guide/cookbook/deposit-and-withdraw.test.ts +++ b/apps/docs-snippets/src/guide/cookbook/deposit-and-withdraw.test.ts @@ -39,7 +39,7 @@ describe(__filename, () => { const assetId = getMintedAssetId(contractId, subId); await liquidityPoolContract.functions - .deposit({ value: liquidityOwner.address.toB256() }) + .deposit({ bits: liquidityOwner.address.toB256() }) .callParams({ forward: [depositAmount, BaseAssetId] }) .txParams({ variableOutputs: 1 }) .call(); @@ -51,7 +51,7 @@ describe(__filename, () => { // #region deposit-and-withdraw-cookbook-3 await liquidityPoolContract.functions - .withdraw({ value: liquidityOwner.address.toB256() }) + .withdraw({ bits: liquidityOwner.address.toB256() }) .callParams({ forward: [depositAmount, BaseAssetId] }) .txParams({ variableOutputs: 1 }) .call(); diff --git a/apps/docs-snippets/src/guide/scripts/script-custom-transaction.test.ts b/apps/docs-snippets/src/guide/scripts/script-custom-transaction.test.ts index e780db80673..da0512c5032 100644 --- a/apps/docs-snippets/src/guide/scripts/script-custom-transaction.test.ts +++ b/apps/docs-snippets/src/guide/scripts/script-custom-transaction.test.ts @@ -61,9 +61,9 @@ describe(__filename, () => { // 2. Instantiate the script main arguments const scriptArguments = [ contract.id.toB256(), - { value: ASSET_A }, + { bits: ASSET_A }, new BN(1000), - { value: ASSET_B }, + { bits: ASSET_B }, new BN(500), ]; diff --git a/apps/docs-snippets/src/guide/types/asset-id.test.ts b/apps/docs-snippets/src/guide/types/asset-id.test.ts index b4585762c23..ed1d2add6ff 100644 --- a/apps/docs-snippets/src/guide/types/asset-id.test.ts +++ b/apps/docs-snippets/src/guide/types/asset-id.test.ts @@ -20,11 +20,11 @@ describe('AssetId', () => { // #import { AssetId }; const assetId: AssetId = { - value: Bits256, + bits: Bits256, }; // #endregion asset-id-1 - expect(assetId.value).toBe(Bits256); + expect(assetId.bits).toBe(Bits256); }); it('should create an AssetId from a B256Address', async () => { @@ -48,7 +48,7 @@ describe('AssetId', () => { // #import { AssetId }; const assetId: AssetId = { - value: Bits256, + bits: Bits256, }; const { value } = await contract.functions.echo_asset_id_comparison(assetId).simulate(); @@ -62,7 +62,7 @@ describe('AssetId', () => { // #import { AssetId }; const assetId: AssetId = { - value: Bits256, + bits: Bits256, }; const { value } = await contract.functions.echo_asset_id().simulate(); @@ -70,6 +70,6 @@ describe('AssetId', () => { expect(value).toEqual(assetId); // #endregion asset-id-4 - expect(value.value).toEqual(Bits256); + expect(value.bits).toEqual(Bits256); }); }); diff --git a/apps/docs-snippets/src/guide/types/contract-types.test.ts b/apps/docs-snippets/src/guide/types/contract-types.test.ts index 1e814a0a13f..fc315964fd9 100644 --- a/apps/docs-snippets/src/guide/types/contract-types.test.ts +++ b/apps/docs-snippets/src/guide/types/contract-types.test.ts @@ -18,14 +18,14 @@ describe(__filename, () => { // #region address-input // #import { Address }; const address = Address.fromRandom(); - const addressInput = { value: address.toB256() }; + const addressInput = { bits: address.toB256() }; // #endregion address-input const callResponse = await contract.functions.address(addressInput).simulate(); // #region address-output // #import { Address }; const addressOutput = callResponse.value; - const addressFromOutput: Address = Address.fromB256(addressOutput.value); + const addressFromOutput: Address = Address.fromB256(addressOutput.bits); // #endregion address-output expect(addressFromOutput).toEqual(address); }); @@ -33,13 +33,13 @@ describe(__filename, () => { it('should successfully call a function with a ContractId type input and output parameters', async () => { // #region contract-id-input const contractId = '0x7296ff960b5eb86b5f79aa587d7ebe1bae147c7cac046a16d062fbd7f3a753ec'; - const contractIdInput = { value: contractId.toString() }; + const contractIdInput = { bits: contractId.toString() }; // #endregion contract-id-input const callResponse = await contract.functions.contract_id(contractIdInput).simulate(); // #region contract-id-output const contractIdOutput = callResponse.value; - const contractIdFromOutput: string = contractIdOutput.value; + const contractIdFromOutput: string = contractIdOutput.bits; // #endregion contract-id-output expect(contractIdFromOutput).toEqual(contractId); @@ -49,7 +49,7 @@ describe(__filename, () => { // #region identity-address-input // #import { Address }; const address = Address.fromRandom(); - const addressInput = { value: address.toB256() }; + const addressInput = { bits: address.toB256() }; const addressIdentityInput = { Address: addressInput }; // #endregion identity-address-input const callResponse1 = await contract.functions.identity(addressIdentityInput).simulate(); @@ -57,20 +57,20 @@ describe(__filename, () => { // #region identity-address-output // #import { Address }; const identityFromOutput1 = callResponse1.value; - const addressStringFromOutput = identityFromOutput1.Address.value; + const addressStringFromOutput = identityFromOutput1.Address.bits; const addressFromOutput: Address = Address.fromB256(addressStringFromOutput); // #endregion identity-address-output // #region identity-contract-input const contractId = '0x7296ff960b5eb86b5f79aa587d7ebe1bae147c7cac046a16d062fbd7f3a753ec'; - const contractIdInput = { value: contractId.toString() }; + const contractIdInput = { bits: contractId.toString() }; const contractIdentityInput = { ContractId: contractIdInput }; // #endregion identity-contract-input const callResponse2 = await contract.functions.identity(contractIdentityInput).simulate(); // #region identity-contract-output const identityFromOutput2 = callResponse2.value; - const contractIdFromOutput: string = identityFromOutput2.ContractId.value; + const contractIdFromOutput: string = identityFromOutput2.ContractId.bits; // #endregion identity-contract-output expect(addressFromOutput).toEqual(address); @@ -80,13 +80,13 @@ describe(__filename, () => { it('should successfully call a function with an AssetId type input and output parameters', async () => { // #region asset-id-input const assetId = '0x0cfabde7bbe58d253cf3103d8f55d26987b3dc4691205b9299ac6826c613a2e2'; - const assetIdInput = { value: assetId }; + const assetIdInput = { bits: assetId }; // #endregion asset-id-input const callResponse = await contract.functions.asset_id(assetIdInput).simulate(); // #region asset-id-output const assetIdOutput = callResponse.value; - const assetIdFromOutput: string = assetIdOutput.value; + const assetIdFromOutput: string = assetIdOutput.bits; // #endregion asset-id-output expect(assetIdFromOutput).toEqual(assetId); diff --git a/apps/docs-snippets/src/guide/types/evm-address.test.ts b/apps/docs-snippets/src/guide/types/evm-address.test.ts index f094daeb5e0..d7c7193d146 100644 --- a/apps/docs-snippets/src/guide/types/evm-address.test.ts +++ b/apps/docs-snippets/src/guide/types/evm-address.test.ts @@ -21,7 +21,7 @@ describe('EvMAddress', () => { // #import { EvmAddress }; const evmAddress: EvmAddress = { - value: Bits256, + bits: Bits256, }; // #endregion evm-address-1 @@ -29,14 +29,12 @@ describe('EvMAddress', () => { // #import { EvmAddress }; const address: EvmAddress = { - value: '0x000000000000000000000000210cf886ce41952316441ae4cac35f00f0e882a6', + bits: '0x000000000000000000000000210cf886ce41952316441ae4cac35f00f0e882a6', }; // #endregion addresses-3 - expect(evmAddress.value).toBe(Bits256); - expect(address.value).toBe( - '0x000000000000000000000000210cf886ce41952316441ae4cac35f00f0e882a6' - ); + expect(evmAddress.bits).toBe(Bits256); + expect(address.bits).toBe('0x000000000000000000000000210cf886ce41952316441ae4cac35f00f0e882a6'); }); it('should create an Evm Address from a B256Address', async () => { @@ -60,7 +58,7 @@ describe('EvMAddress', () => { // #import { EvmAddress }; const evmAddress: EvmAddress = { - value: Bits256, + bits: Bits256, }; const { value } = await contract.functions.echo_address_comparison(evmAddress).simulate(); @@ -74,7 +72,7 @@ describe('EvMAddress', () => { // #import { EvmAddress }; const evmAddress: EvmAddress = { - value: Bits256, + bits: Bits256, }; const { value } = await contract.functions.echo_address().simulate(); @@ -82,6 +80,6 @@ describe('EvMAddress', () => { expect(value).toEqual(evmAddress); // #endregion evm-address-4 - expect(value.value).toEqual(Bits256); + expect(value.bits).toEqual(Bits256); }); }); diff --git a/apps/docs-snippets/test/fixtures/forc-projects/echo-asset-id/src/main.sw b/apps/docs-snippets/test/fixtures/forc-projects/echo-asset-id/src/main.sw index 2af36a25332..f7dd31b148d 100644 --- a/apps/docs-snippets/test/fixtures/forc-projects/echo-asset-id/src/main.sw +++ b/apps/docs-snippets/test/fixtures/forc-projects/echo-asset-id/src/main.sw @@ -6,9 +6,7 @@ abi EvmTest { fn echo_asset_id_comparison(asset_id: AssetId) -> bool; } -const ASSET_ID: AssetId = AssetId { - value: 0x9ae5b658754e096e4d681c548daf46354495a437cc61492599e33fc64dcdc30c, -}; +const ASSET_ID: AssetId = AssetId::from(0x9ae5b658754e096e4d681c548daf46354495a437cc61492599e33fc64dcdc30c); impl EvmTest for Contract { fn echo_asset_id() -> AssetId { diff --git a/apps/docs-snippets/test/fixtures/forc-projects/predicate-signing/src/main.sw b/apps/docs-snippets/test/fixtures/forc-projects/predicate-signing/src/main.sw index 15a3ea9a1e2..39c8001dea0 100644 --- a/apps/docs-snippets/test/fixtures/forc-projects/predicate-signing/src/main.sw +++ b/apps/docs-snippets/test/fixtures/forc-projects/predicate-signing/src/main.sw @@ -5,7 +5,7 @@ use std::{b512::B512, ecr::ec_recover_address, tx::{tx_id, tx_witness_data}}; fn main(signer: b256) -> bool { let witness_data: B512 = tx_witness_data(1); - let address: b256 = ec_recover_address(witness_data, tx_id()).unwrap().value; + let address: b256 = ec_recover_address(witness_data, tx_id()).unwrap().bits(); return address == signer; } // #endregion multiple-signers-3 diff --git a/apps/docs-snippets/test/fixtures/forc-projects/script-signing/src/main.sw b/apps/docs-snippets/test/fixtures/forc-projects/script-signing/src/main.sw index 5b1f5a7021a..15b7e9f8284 100644 --- a/apps/docs-snippets/test/fixtures/forc-projects/script-signing/src/main.sw +++ b/apps/docs-snippets/test/fixtures/forc-projects/script-signing/src/main.sw @@ -5,7 +5,7 @@ use std::{b512::B512, ecr::ec_recover_address, tx::{tx_id, tx_witness_data}}; fn main(signer: b256) -> bool { let witness_data: B512 = tx_witness_data(1); - let address: b256 = ec_recover_address(witness_data, tx_id()).unwrap().value; + let address: b256 = ec_recover_address(witness_data, tx_id()).unwrap().bits(); return address == signer; } // #endregion multiple-signers-1 diff --git a/apps/docs-snippets/test/fixtures/forc-projects/token-depositor/src/main.sw b/apps/docs-snippets/test/fixtures/forc-projects/token-depositor/src/main.sw index a7ee2183f9d..75caff02db3 100644 --- a/apps/docs-snippets/test/fixtures/forc-projects/token-depositor/src/main.sw +++ b/apps/docs-snippets/test/fixtures/forc-projects/token-depositor/src/main.sw @@ -16,7 +16,7 @@ impl TokenDepositor for Contract { let sender = msg_sender().unwrap(); let address: b256 = match sender { - Identity::Address(sender_param) => sender_param.value, + Identity::Address(sender_param) => sender_param.bits(), _ => revert(0), }; diff --git a/packages/abi-typegen/test/fixtures/templates/contract/bytecode.hbs b/packages/abi-typegen/test/fixtures/templates/contract/bytecode.hbs index 33096db6af7..a6c9c6d78ed 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 '0x740000034700000000000000000000445dfcc00110fff3005d4060495d47f001134904407648000272f0007b36f000001aec50005c43f00024400000470000000000000001000000000000000000000055b7ae10' +export default '0x1af030007400000200000000000000445dffc00110ffff005d4060495d47f001134904407648000272f0007b36f000001aec50005c43f00024400000470000000000000001000000000000000000000055b7ae10' diff --git a/packages/abi-typegen/test/fixtures/templates/contract/dts.hbs b/packages/abi-typegen/test/fixtures/templates/contract/dts.hbs index 6774eb07bb6..5d0234cd4c6 100644 --- a/packages/abi-typegen/test/fixtures/templates/contract/dts.hbs +++ b/packages/abi-typegen/test/fixtures/templates/contract/dts.hbs @@ -29,7 +29,7 @@ import type { Option, Enum, Vec } from "./common"; export enum MyEnumInput { Checked = 'Checked', Pending = 'Pending' }; export enum MyEnumOutput { Checked = 'Checked', Pending = 'Pending' }; -export type AssetIdInput = { value: string }; +export type AssetIdInput = { bits: string }; export type AssetIdOutput = AssetIdInput; export type MyStructInput = { x: BigNumberish, y: BigNumberish, state: MyEnumInput }; export type MyStructOutput = { x: number, y: number, state: MyEnumOutput }; diff --git a/packages/address/src/address.test.ts b/packages/address/src/address.test.ts index 964e1e7dc76..80a0ddf32c0 100644 --- a/packages/address/src/address.test.ts +++ b/packages/address/src/address.test.ts @@ -346,7 +346,7 @@ describe('Address class', () => { const evmAddress: EvmAddress = address.toEvmAddress(); expect(evmAddress).toBeDefined(); - expect(evmAddress.value).toBe(ADDRESS_B256_EVM_PADDED); + expect(evmAddress.bits).toBe(ADDRESS_B256_EVM_PADDED); }); test('create an AssetId from B256', () => { @@ -354,14 +354,14 @@ describe('Address class', () => { const assetId: AssetId = address.toAssetId(); expect(assetId).toBeDefined(); - expect(assetId.value).toBe(ADDRESS_B256); + expect(assetId.bits).toBe(ADDRESS_B256); }); test('create an Address from an Evm Address', () => { const address = Address.fromEvmAddress(ADDRESS_EVM); const evmAddressWrapped: EvmAddress = { - value: ADDRESS_B256_EVM_PADDED, + bits: ADDRESS_B256_EVM_PADDED, }; expect(address.toEvmAddress()).toMatchObject(evmAddressWrapped); diff --git a/packages/address/src/address.ts b/packages/address/src/address.ts index 6a4f3a7bc35..8eb4c88ac00 100644 --- a/packages/address/src/address.ts +++ b/packages/address/src/address.ts @@ -105,7 +105,7 @@ export default class Address extends AbstractAddress { const b256Address = toB256(this.bech32Address); return { - value: clearFirst12BytesFromB256(b256Address), + bits: clearFirst12BytesFromB256(b256Address), } as EvmAddress; } @@ -116,7 +116,7 @@ export default class Address extends AbstractAddress { */ toAssetId(): AssetId { return { - value: this.toB256(), + bits: this.toB256(), } as AssetId; } diff --git a/packages/fuel-gauge/src/advanced-logging.test.ts b/packages/fuel-gauge/src/advanced-logging.test.ts index e701c7cc061..2c42c232354 100644 --- a/packages/fuel-gauge/src/advanced-logging.test.ts +++ b/packages/fuel-gauge/src/advanced-logging.test.ts @@ -42,7 +42,7 @@ describe('Advanced Logging', () => { { Playing: 1 }, 'Contract Id', { - value: '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', + bits: '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', }, 'Game Ref', { @@ -52,7 +52,7 @@ describe('Advanced Logging', () => { game_id: '0x18af8', state: { Playing: 1 }, contract_Id: { - value: '0xfffffffffffffffffffffffffffffffff00fffffffffffffffffffffffffffff', + bits: '0xfffffffffffffffffffffffffffffffff00fffffffffffffffffffffffffffff', }, difficulty: { Medium: true }, }, @@ -66,7 +66,7 @@ describe('Advanced Logging', () => { game_id: '0x20157', state: { Playing: 1 }, contract_Id: { - value: '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', + bits: '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', }, difficulty: { Hard: true }, }, @@ -100,7 +100,7 @@ describe('Advanced Logging', () => { game_id: bn(0x18af8), state: { Playing: 1 }, contract_Id: { - value: '0xfffffffffffffffffffffffffffffffff00fffffffffffffffffffffffffffff', + bits: '0xfffffffffffffffffffffffffffffffff00fffffffffffffffffffffffffffff', }, difficulty: { Medium: true }, }, diff --git a/packages/fuel-gauge/src/auth-testing.test.ts b/packages/fuel-gauge/src/auth-testing.test.ts index df377527dae..3f45d6f3d8b 100644 --- a/packages/fuel-gauge/src/auth-testing.test.ts +++ b/packages/fuel-gauge/src/auth-testing.test.ts @@ -33,7 +33,7 @@ describe('Auth Testing', () => { it('can check_msg_sender [with correct id]', async () => { const { value } = await contractInstance.functions - .check_msg_sender({ value: wallet.address.toB256() }) + .check_msg_sender({ bits: wallet.address.toB256() }) .call(); expect(value).toBeTruthy(); @@ -41,7 +41,7 @@ describe('Auth Testing', () => { it('can check_msg_sender [with incorrect id]', async () => { await expect( - contractInstance.functions.check_msg_sender({ value: getRandomB256() }).call() + contractInstance.functions.check_msg_sender({ bits: getRandomB256() }).call() ).rejects.toThrow( 'The transaction reverted because an "assert" statement failed to evaluate to true.' ); diff --git a/packages/fuel-gauge/src/coverage-contract.test.ts b/packages/fuel-gauge/src/coverage-contract.test.ts index 82e701ff7ab..084d6f70cd5 100644 --- a/packages/fuel-gauge/src/coverage-contract.test.ts +++ b/packages/fuel-gauge/src/coverage-contract.test.ts @@ -119,7 +119,7 @@ describe('Coverage Contract', () => { .call() ).value ).toStrictEqual({ - value: '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', + bits: '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', }); expect( ( diff --git a/packages/fuel-gauge/src/multi-token-contract.test.ts b/packages/fuel-gauge/src/multi-token-contract.test.ts index f28fabb97a4..ce941c4a99e 100644 --- a/packages/fuel-gauge/src/multi-token-contract.test.ts +++ b/packages/fuel-gauge/src/multi-token-contract.test.ts @@ -35,7 +35,7 @@ describe('MultiTokenContract', () => { // New wallet to transfer coins and check balance const userWallet = Wallet.generate({ provider }); const multiTokenContract = await setup(); - const contractId = { value: multiTokenContract.id.toB256() }; + const contractId = { bits: multiTokenContract.id.toB256() }; const helperDict: { [key: string]: { assetId: string; amount: number } } = { [subIds[0]]: { @@ -67,9 +67,9 @@ describe('MultiTokenContract', () => { }); // define helper to get contract balance - const getBalance = async (address: { value: string }, assetId: string) => { + const getBalance = async (address: { bits: string }, assetId: string) => { const { value } = await multiTokenContract.functions - .get_balance(address, { value: assetId }) + .get_balance(address, { bits: assetId }) .simulate(); return value; @@ -89,8 +89,8 @@ describe('MultiTokenContract', () => { .multiCall( subIds.map((subId) => multiTokenContract.functions.transfer_to_address( - { value: userWallet.address.toB256() }, - { value: helperDict[subId].assetId }, + { bits: userWallet.address.toB256() }, + { bits: helperDict[subId].assetId }, helperDict[subId].amount ) ) @@ -111,7 +111,7 @@ describe('MultiTokenContract', () => { it('can burn coins', async () => { const multiTokenContract = await setup(); - const contractId = { value: multiTokenContract.id.toB256() }; + const contractId = { bits: multiTokenContract.id.toB256() }; const helperDict: { [key: string]: { @@ -152,9 +152,9 @@ describe('MultiTokenContract', () => { }); // define helper to get contract balance - const getBalance = async (address: { value: string }, assetId: string) => { + const getBalance = async (address: { bits: string }, assetId: string) => { const { value } = await multiTokenContract.functions - .get_balance(address, { value: assetId }) + .get_balance(address, { bits: assetId }) .simulate(); return value; diff --git a/packages/fuel-gauge/src/revert-error.test.ts b/packages/fuel-gauge/src/revert-error.test.ts index 4f4711a6e4c..af351aea0ad 100644 --- a/packages/fuel-gauge/src/revert-error.test.ts +++ b/packages/fuel-gauge/src/revert-error.test.ts @@ -184,9 +184,9 @@ describe('Revert Error Testing', () => { const tokenContract = await factory.deployContract(); const addresses = [ - { value: getRandomB256() }, - { value: getRandomB256() }, - { value: getRandomB256() }, + { bits: getRandomB256() }, + { bits: getRandomB256() }, + { bits: getRandomB256() }, ]; const request = await tokenContract diff --git a/packages/fuel-gauge/src/token-test-contract.test.ts b/packages/fuel-gauge/src/token-test-contract.test.ts index 0e8a2d856b5..e1e871f4dfe 100644 --- a/packages/fuel-gauge/src/token-test-contract.test.ts +++ b/packages/fuel-gauge/src/token-test-contract.test.ts @@ -36,15 +36,15 @@ describe('TokenTestContract', () => { // New wallet to transfer coins and check balance const userWallet = Wallet.generate({ provider }); const token = await setup(); - const tokenContractId = { value: token.id.toB256() }; - const addressId = { value: userWallet.address.toB256() }; + const tokenContractId = { bits: token.id.toB256() }; + const addressId = { bits: userWallet.address.toB256() }; // Mint some coins const { transactionResult } = await token.functions.mint_coins(100).call(); const { mintedAssets } = transactionResult; - const assetId: AssetId = { value: mintedAssets?.[0].assetId }; + const assetId: AssetId = { bits: mintedAssets?.[0].assetId }; const getBalance = async () => { const { value } = await token.functions.get_balance(tokenContractId, assetId).simulate(); @@ -60,7 +60,7 @@ describe('TokenTestContract', () => { // Check new wallet received the coins from the token contract const balances = await userWallet.getBalances(); - const tokenBalance = balances.find((b) => b.assetId === assetId.value); + const tokenBalance = balances.find((b) => b.assetId === assetId.bits); expect(tokenBalance?.amount.toHex()).toEqual(toHex(50)); }); @@ -70,7 +70,7 @@ describe('TokenTestContract', () => { ); const addresses = [wallet1, wallet2, wallet3].map((wallet) => ({ - value: wallet.address.toB256(), + bits: wallet.address.toB256(), })); const token = await setup(); @@ -128,15 +128,15 @@ describe('TokenTestContract', () => { const userWallet = Wallet.generate({ provider }); const token = await setup(); const addressId = { - value: userWallet.address.toB256(), + bits: userWallet.address.toB256(), }; // mint 100 coins const { transactionResult } = await token.functions.mint_coins(100).call(); const { mintedAssets } = transactionResult; - const assetId: AssetId = { value: mintedAssets?.[0].assetId || '' }; + const assetId: AssetId = { bits: mintedAssets?.[0].assetId || '' }; - const getBalance = async () => token.getBalance(assetId.value); + const getBalance = async () => token.getBalance(assetId.bits); // at the start, the contract should have 100 coins expect((await getBalance()).toHex()).toEqual(bn(100).toHex()); @@ -152,9 +152,9 @@ describe('TokenTestContract', () => { const userWallet = Wallet.generate({ provider }); const token = await setup(); const addressParameter = { - value: userWallet.address, + bits: userWallet.address, }; - const assetId: AssetId = { value: BaseAssetId }; + const assetId: AssetId = { bits: BaseAssetId }; await expectToThrowFuelError( () => token.functions.transfer_to_address(addressParameter, assetId, 50).call(), diff --git a/packages/fuel-gauge/src/transaction-summary.test.ts b/packages/fuel-gauge/src/transaction-summary.test.ts index ab147f94a7d..d39215ce104 100644 --- a/packages/fuel-gauge/src/transaction-summary.test.ts +++ b/packages/fuel-gauge/src/transaction-summary.test.ts @@ -266,7 +266,7 @@ describe('TransactionSummary', () => { const { transactionResult: { operations }, } = await contract.functions - .transfer_to_address({ value: recipient.address.toB256() }, { value: assetId }, amount) + .transfer_to_address({ bits: recipient.address.toB256() }, { bits: assetId }, amount) .call(); validateTransferOperation({ @@ -317,14 +317,14 @@ describe('TransactionSummary', () => { .multi_address_transfer([ // 3 Transfers for recipient contract 1 ...transferData1.quantities.map(({ amount, assetId }) => ({ - recipient: { value: transferData1.address.toB256() }, - asset_id: { value: assetId }, + recipient: { bits: transferData1.address.toB256() }, + asset_id: { bits: assetId }, amount, })), // 2 Transfers for recipient contract 2 ...transferData2.quantities.map(({ amount, assetId }) => ({ - recipient: { value: transferData2.address.toB256() }, - asset_id: { value: assetId }, + recipient: { bits: transferData2.address.toB256() }, + asset_id: { bits: assetId }, amount, })), ]) @@ -357,8 +357,8 @@ describe('TransactionSummary', () => { transactionResult: { operations }, } = await contractSender.functions .transfer_to_contract( - { value: contractRecipient.id.toB256() }, - { value: mintedAssets[0].assetId }, + { bits: contractRecipient.id.toB256() }, + { bits: mintedAssets[0].assetId }, amount ) .call(); @@ -414,14 +414,14 @@ describe('TransactionSummary', () => { .multi_contract_transfer([ // 2 Transfers for recipient contract 1 ...transferData1.quantities.map(({ amount, assetId }) => ({ - recipient: { value: transferData1.address.toB256() }, - asset_id: { value: assetId }, + recipient: { bits: transferData1.address.toB256() }, + asset_id: { bits: assetId }, amount, })), // 3 Transfers for recipient contract 2 ...transferData2.quantities.map(({ amount, assetId }) => ({ - recipient: { value: transferData2.address.toB256() }, - asset_id: { value: assetId }, + recipient: { bits: transferData2.address.toB256() }, + asset_id: { bits: assetId }, amount, })), ]) diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/call-test-contract/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/call-test-contract/src/main.sw index 75757f20dac..a019c76ea27 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/call-test-contract/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/call-test-contract/src/main.sw @@ -128,7 +128,7 @@ impl TestContract for Contract { #[payable] fn return_context_asset() -> b256 { - msg_asset_id().value + msg_asset_id().bits() } #[payable] diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/predicate-triple-sig/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/predicate-triple-sig/src/main.sw index f6be6feb70e..5a7ea115a2e 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/predicate-triple-sig/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/predicate-triple-sig/src/main.sw @@ -6,7 +6,7 @@ fn extract_pulic_key_and_match(signature: B512, expected_public_key: b256) -> u6 let message_hash = 0x6aed34e6bddff5e1d872b5d7d5698a7b73abd6f3b33402732edc73ab9ffb9c70; if let Result::Ok(pub_key_sig) = ec_recover_address(signature, message_hash) { - if pub_key_sig.value == expected_public_key { + if pub_key_sig.bits() == expected_public_key { return 1; } } diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/revert-error/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/revert-error/src/main.sw index c381bfe219b..07b7ef0aae9 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/revert-error/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/revert-error/src/main.sw @@ -23,14 +23,9 @@ abi RevertError { fn revert_with_0(); } -const BASE_TOKEN_A: AssetId = AssetId { - value: 0x0000000000000000000000000000000000000000000000000000000000000001, -}; - -const BASE_TOKEN_B: AssetId = AssetId { - value: 0x0000000000000000000000000000000000000000000000000000000000000001, -}; - +const BASE_TOKEN_A: AssetId = AssetId::from(0x0000000000000000000000000000000000000000000000000000000000000001); +const BASE_TOKEN_B: AssetId = AssetId::from(0x0000000000000000000000000000000000000000000000000000000000000001); + pub struct ValidInputsEvent { token_id: u64, price: u64, diff --git a/packages/interfaces/src/index.ts b/packages/interfaces/src/index.ts index 718b3975110..254544cb2ea 100644 --- a/packages/interfaces/src/index.ts +++ b/packages/interfaces/src/index.ts @@ -21,17 +21,17 @@ export type RawSlice = Uint8Array | number[]; export type BytesLike = Uint8Array | string; /** - * @prop value - A 256 bit hash string with the first 12 bytes cleared + * @prop bits - A 256 bit hash string with the first 12 bytes cleared */ export type EvmAddress = { - value: B256AddressEvm; + bits: B256AddressEvm; }; /** - * @prop value - A wrapped 256 bit hash string + * @prop bits - A wrapped 256 bit hash string */ export type AssetId = { - value: B256Address; + bits: B256Address; }; export type StdString = string; From ac1684f3c0ad2ddbdd0d31c8b55058cc02d482e9 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Fri, 5 Apr 2024 11:09:37 -0300 Subject: [PATCH 05/92] Removing obsolete `forc` exceptions --- packages/forc/VERSION_EXPERIMENTAL | 1 - packages/fuel-gauge/package.json | 2 +- .../scripts/build-forc-experimental.ts | 28 ------------------- 3 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 packages/forc/VERSION_EXPERIMENTAL delete mode 100755 packages/fuel-gauge/scripts/build-forc-experimental.ts diff --git a/packages/forc/VERSION_EXPERIMENTAL b/packages/forc/VERSION_EXPERIMENTAL deleted file mode 100644 index d06c2d46465..00000000000 --- a/packages/forc/VERSION_EXPERIMENTAL +++ /dev/null @@ -1 +0,0 @@ -0.52.1 \ No newline at end of file diff --git a/packages/fuel-gauge/package.json b/packages/fuel-gauge/package.json index 12ddc1e4c67..e24dca096bf 100644 --- a/packages/fuel-gauge/package.json +++ b/packages/fuel-gauge/package.json @@ -7,7 +7,7 @@ "scripts": { "pretest": "run-s build:forc build:forc-experimental build:process-predicates", "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release", - "build:forc-experimental": "tsx ./scripts/build-forc-experimental.ts", + "build:forc-experimental": "pnpm fuels-forc build -p test/fixtures/forc-projects-experimental --release --experimental-new-encoding", "build:process-predicates": "tsx ./scripts/process-predicates.ts" }, "license": "Apache-2.0", diff --git a/packages/fuel-gauge/scripts/build-forc-experimental.ts b/packages/fuel-gauge/scripts/build-forc-experimental.ts deleted file mode 100755 index bf6fb562f39..00000000000 --- a/packages/fuel-gauge/scripts/build-forc-experimental.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { execSync } from 'child_process'; -import { readFileSync } from 'fs'; -import path 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 installedForcVersion = execSync(`${FORC} --version | sed "s/forc//"`, { - env: process.env, -}) - .toString() - .trim(); - -if (installedForcVersion !== EXPECTED_FORC_VERSION) { - // eslint-disable-next-line no-console - console.log( - `Please install the correct version of forc. Installed version: ${installedForcVersion}, expected version: ${EXPECTED_FORC_VERSION}` - ); - process.exit(1); -} - -execSync( - `${FORC} build -p test/fixtures/forc-projects-experimental --experimental-new-encoding --release`, - { stdio: 'inherit' } -); From eeffb2e5343898c00c792b9132f23313cc5ef187 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Fri, 5 Apr 2024 11:24:14 -0300 Subject: [PATCH 06/92] Adding [empty] changeset --- .changeset/five-cats-chew.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .changeset/five-cats-chew.md diff --git a/.changeset/five-cats-chew.md b/.changeset/five-cats-chew.md new file mode 100644 index 00000000000..d96b032e589 --- /dev/null +++ b/.changeset/five-cats-chew.md @@ -0,0 +1,9 @@ +--- +"@fuel-ts/abi-typegen": patch +"@fuel-ts/interfaces": patch +"@fuel-ts/versions": patch +"@fuel-ts/address": patch +"@fuel-ts/forc": patch +--- + +Upgrading `forc` to `0.52.1` From 2e60a573b6c54a4cb76ac273da78ac23504b5f60 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Fri, 5 Apr 2024 11:28:52 -0300 Subject: [PATCH 07/92] Removing obsolete CI steps --- .github/actions/test-setup/action.yaml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/actions/test-setup/action.yaml b/.github/actions/test-setup/action.yaml index a97a4c2e055..6bc095d3ddd 100644 --- a/.github/actions/test-setup/action.yaml +++ b/.github/actions/test-setup/action.yaml @@ -30,21 +30,3 @@ runs: - name: Build run: pnpm build shell: bash - - - name: Install rust toolchain - uses: dtolnay/rust-toolchain@stable - # selecting a toolchain either by action or manual `rustup` calls should happen - # before the cache plugin, as it uses the current rustc version as its cache key - - uses: Swatinem/rust-cache@v2 - with: - prefix-key: "v1-rust" - - - name: Install forc for experimental builds - shell: bash - run: | - curl https://install.fuel.network > install-fuelup.sh - chmod +x install-fuelup.sh - ./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) \ No newline at end of file From 42713ef930b94f67a84cb60bc973ab441d01aa0a Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Fri, 5 Apr 2024 11:31:52 -0300 Subject: [PATCH 08/92] Temporarily disabling workflow step --- .github/workflows/test.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f24e629810d..e0c2f64d994 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -43,8 +43,9 @@ jobs: - name: Verify package.json integrity run: pnpm lint:package-jsons - - name: Forc Format Check - run: pnpm forc:check + # TODO: @arboleya rollback after fixing lint issues + # - name: Forc Format Check + # run: pnpm forc:check # linting of some tests depends on pretest being run so that it generates the necessary files - name: Pretest From de5abaf61cd641d150e9ea101b6308bacba9ff86 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Fri, 5 Apr 2024 11:32:36 -0300 Subject: [PATCH 09/92] Deleting obsolete changeset --- .changeset/tidy-olives-dance.md | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .changeset/tidy-olives-dance.md diff --git a/.changeset/tidy-olives-dance.md b/.changeset/tidy-olives-dance.md deleted file mode 100644 index 6e830b55472..00000000000 --- a/.changeset/tidy-olives-dance.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@fuel-ts/abi-typegen": patch -"@fuel-ts/forc": patch -"@fuel-ts/versions": patch ---- - -chore: upgrading `forc` to `0.51.1` From abf4cd41e37aac3cdbe77d272fd0e87177df3e4b Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Fri, 5 Apr 2024 11:38:33 -0300 Subject: [PATCH 10/92] Adjusting changeset --- .changeset/five-cats-chew.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/five-cats-chew.md b/.changeset/five-cats-chew.md index d96b032e589..ac2967ffe99 100644 --- a/.changeset/five-cats-chew.md +++ b/.changeset/five-cats-chew.md @@ -6,4 +6,4 @@ "@fuel-ts/forc": patch --- -Upgrading `forc` to `0.52.1` +chore: upgrading `forc` to `0.52.1` From e0bd6a68a6efaa3de9d940899696ecf4e95b66d6 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Fri, 5 Apr 2024 11:43:13 -0300 Subject: [PATCH 11/92] Marking PR as a breaking change --- .changeset/five-cats-chew.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/five-cats-chew.md b/.changeset/five-cats-chew.md index ac2967ffe99..542b2eb7690 100644 --- a/.changeset/five-cats-chew.md +++ b/.changeset/five-cats-chew.md @@ -6,4 +6,4 @@ "@fuel-ts/forc": patch --- -chore: upgrading `forc` to `0.52.1` +chore!: upgrading `forc` to `0.52.1` From 65d7fff52cadcf985be660c14c63421eb4d1c8de Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Sun, 7 Apr 2024 08:03:39 -0300 Subject: [PATCH 12/92] Lintfix --- .../test/fixtures/forc-projects/revert-error/src/main.sw | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/revert-error/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/revert-error/src/main.sw index 07b7ef0aae9..c37e906dcce 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/revert-error/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/revert-error/src/main.sw @@ -23,9 +23,9 @@ abi RevertError { fn revert_with_0(); } -const BASE_TOKEN_A: AssetId = AssetId::from(0x0000000000000000000000000000000000000000000000000000000000000001); -const BASE_TOKEN_B: AssetId = AssetId::from(0x0000000000000000000000000000000000000000000000000000000000000001); - +const BASE_TOKEN_A: AssetId = AssetId::from(0x0000000000000000000000000000000000000000000000000000000000000001); +const BASE_TOKEN_B: AssetId = AssetId::from(0x0000000000000000000000000000000000000000000000000000000000000001); + pub struct ValidInputsEvent { token_id: u64, price: u64, From 8c3d18bd79bedd1d4fa8d35dcd1544388750a707 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Sun, 7 Apr 2024 08:05:23 -0300 Subject: [PATCH 13/92] Re-enabling workflow step --- .github/workflows/test.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e0c2f64d994..f24e629810d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -43,9 +43,8 @@ jobs: - name: Verify package.json integrity run: pnpm lint:package-jsons - # TODO: @arboleya rollback after fixing lint issues - # - name: Forc Format Check - # run: pnpm forc:check + - name: Forc Format Check + run: pnpm forc:check # linting of some tests depends on pretest being run so that it generates the necessary files - name: Pretest From cb78ab3bbef17d84913b14102f5944caba8f27e1 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Sun, 7 Apr 2024 08:11:30 -0300 Subject: [PATCH 14/92] Increasing verbosity for debugging purposes --- turbo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/turbo.json b/turbo.json index 84c492502b6..991e47cef2f 100644 --- a/turbo.json +++ b/turbo.json @@ -18,7 +18,7 @@ "outputMode": "new-only" }, "pretest": { - "outputMode": "errors-only", + "outputMode": "new-only", "inputs": [ "**/test/fixtures/forc-projects/Forc.toml", "**/test/fixtures/forc-projects/**/src/*.sw", From 56215b398f80efd678f43ac6fd375bd9cc14f163 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Sun, 7 Apr 2024 08:39:54 -0300 Subject: [PATCH 15/92] Debugging forc build --- .github/workflows/test.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f24e629810d..b2f32d44524 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -46,6 +46,9 @@ jobs: - name: Forc Format Check run: pnpm forc:check + - name: Debugging `forc build` + run: cd packages/fuel-gauge && pnpm pretest + # linting of some tests depends on pretest being run so that it generates the necessary files - name: Pretest run: pnpm pretest From 3c3dd80b4106bf9d99d59a8f7fd096403b632af9 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Sun, 7 Apr 2024 09:00:56 -0300 Subject: [PATCH 16/92] More debugging --- .github/workflows/test.yaml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b2f32d44524..0c75e693797 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -46,9 +46,27 @@ jobs: - name: Forc Format Check run: pnpm forc:check - - name: Debugging `forc build` + - name: Debugging `forc build` @ docs-snippets + run: cd packages/docs-snippets && pnpm pretest + + - name: Debugging `forc build` @ demo-typegen + run: cd packages/demo-typegen && pnpm pretest + + - name: Debugging `forc build` @ abi-coder + run: cd packages/abi-coder && pnpm pretest + + - name: Debugging `forc build` @ fuel-gauge run: cd packages/fuel-gauge && pnpm pretest + - name: Debugging `forc build` @ script + run: cd packages/script && pnpm pretest + + - name: Debugging `forc build` @ abi-typegen + run: cd packages/abi-typegen && pnpm pretest + + - name: Debugging `forc build` @ utils + run: cd packages/utils && pnpm pretest + # linting of some tests depends on pretest being run so that it generates the necessary files - name: Pretest run: pnpm pretest From 40826dfd5fca950898b4aab84aa1897fe2075aab Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Sun, 7 Apr 2024 09:11:25 -0300 Subject: [PATCH 17/92] Fixing directory path --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0c75e693797..26229f04803 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -47,7 +47,7 @@ jobs: run: pnpm forc:check - name: Debugging `forc build` @ docs-snippets - run: cd packages/docs-snippets && pnpm pretest + run: cd apps/docs-snippets && pnpm pretest - name: Debugging `forc build` @ demo-typegen run: cd packages/demo-typegen && pnpm pretest From 9ba63006bb3df3c2184e8dd3bded47ef597a720a Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Sun, 7 Apr 2024 09:15:55 -0300 Subject: [PATCH 18/92] More paths adjustments --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 26229f04803..43d01c2d19b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -50,7 +50,7 @@ jobs: run: cd apps/docs-snippets && pnpm pretest - name: Debugging `forc build` @ demo-typegen - run: cd packages/demo-typegen && pnpm pretest + run: cd apps/demo-typegen && pnpm pretest - name: Debugging `forc build` @ abi-coder run: cd packages/abi-coder && pnpm pretest From 5be60b4fafc3717f46d039c1a7a17a8e74ab20fe Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Mon, 8 Apr 2024 07:19:08 -0300 Subject: [PATCH 19/92] Polishing test assertions --- .../fuel-gauge/src/script-with-vectors.test.ts | 18 ++++++++++++------ .../script-with-vector/src/main.sw | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/fuel-gauge/src/script-with-vectors.test.ts b/packages/fuel-gauge/src/script-with-vectors.test.ts index a3d0cd39872..80e35dbb431 100644 --- a/packages/fuel-gauge/src/script-with-vectors.test.ts +++ b/packages/fuel-gauge/src/script-with-vectors.test.ts @@ -38,16 +38,22 @@ describe('Script With Vectors', () => { const formattedLog = logs.map((l) => (typeof l === 'string' ? l : l.toNumber())); + const vecFirst = someVec[0]; + const vecPointer = 7; + const vecCapacity = 4; + const vecLen = 4; + const vecAddr = 11208; + expect(formattedLog).toEqual([ - 7, - 'vector.buf.ptr', - 11232, + vecFirst, + 'vector.ptr()', + vecPointer, 'vector.capacity()', - 4, + vecCapacity, 'vector.len()', - 4, + vecLen, 'addr_of vector', - 11208, + vecAddr, ]); }); diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw index 5cc01908e72..a77cc04efdb 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw @@ -11,7 +11,7 @@ fn main(vector: Vec) { assert(length == 4); assert(vector.capacity() == 4); assert(vector.is_empty() == false); - log(__to_str_array("vector.buf.ptr")); + log(__to_str_array("vector.ptr()")); log(vector.ptr()); log(__to_str_array("vector.capacity()")); log(vector.capacity()); From 5097ac7adf15a736615b6df07ca2172140af151f Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Wed, 10 Apr 2024 06:15:16 -0300 Subject: [PATCH 20/92] Enabling PR auto-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 47c511eb3fe19e7cd1b39f0948649cd47f4c3e0a Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 11 Apr 2024 11:54:28 -0300 Subject: [PATCH 21/92] Temporarily commenting failing tests --- .../src/guide/types/vector.test.ts | 3 ++- .../forc-projects/bytecode-input/Forc.toml | 7 +++++-- .../forc-projects/bytecode-input/src/main.sw | 15 ++++++++----- .../fuel-gauge/src/bytecode-sway-lib.test.ts | 3 ++- .../forc-projects/bytecode-sway-lib/Forc.toml | 7 +++++-- .../bytecode-sway-lib/src/main.sw | 21 ++++++++++++------- 6 files changed, 37 insertions(+), 19 deletions(-) diff --git a/apps/docs-snippets/src/guide/types/vector.test.ts b/apps/docs-snippets/src/guide/types/vector.test.ts index 80895c61749..febc7b1c04d 100644 --- a/apps/docs-snippets/src/guide/types/vector.test.ts +++ b/apps/docs-snippets/src/guide/types/vector.test.ts @@ -55,7 +55,8 @@ describe(__filename, () => { expect(value.isActive).toEqual(employees[1].isActive); }); - it('should successfully execute a contract call with a bytecode input', async () => { + // TODO: Unskip test after sway-libs become compatible with latest forc (0.52+) + it.skip('should successfully execute a contract call with a bytecode input', async () => { const bytecodeContract = await createAndDeployContractFromProject( DocSnippetProjectsEnum.BYTECODE_INPUT ); diff --git a/apps/docs-snippets/test/fixtures/forc-projects/bytecode-input/Forc.toml b/apps/docs-snippets/test/fixtures/forc-projects/bytecode-input/Forc.toml index 2bf7264eaca..416c9537410 100644 --- a/apps/docs-snippets/test/fixtures/forc-projects/bytecode-input/Forc.toml +++ b/apps/docs-snippets/test/fixtures/forc-projects/bytecode-input/Forc.toml @@ -3,5 +3,8 @@ authors = ["Fuel Labs "] license = "Apache-2.0" name = "bytecode-input" -[dependencies] -bytecode = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.19.0" } +# TODO: Uncomment bytecode-related stuff +# This requires sway-libs to be compatible with latest forc (0.52+) + +# [dependencies] +# bytecode = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.19.0" } diff --git a/apps/docs-snippets/test/fixtures/forc-projects/bytecode-input/src/main.sw b/apps/docs-snippets/test/fixtures/forc-projects/bytecode-input/src/main.sw index b4fa47e738e..601d0cc5089 100644 --- a/apps/docs-snippets/test/fixtures/forc-projects/bytecode-input/src/main.sw +++ b/apps/docs-snippets/test/fixtures/forc-projects/bytecode-input/src/main.sw @@ -1,16 +1,21 @@ contract; -use bytecode::*; +// TODO: Uncomment bytecode-related stuff +// This requires sway-libs to be compatible with latest forc (0.52+) +// use bytecode::*; + abi MyContract { - fn compute_bytecode_root(bytecode_input: Vec) -> b256; + // fn compute_bytecode_root(bytecode_input: Vec) -> b256; + fn compute_bytecode_root(bytecode_input: Vec) -> bool; } impl MyContract for Contract { // #region vector-bytecode-input-sway - fn compute_bytecode_root(bytecode_input: Vec) -> b256 { - let root = compute_bytecode_root(bytecode_input); - return root; + fn compute_bytecode_root(bytecode_input: Vec) -> bool { + // let root = compute_bytecode_root(bytecode_input); + // return root; + return true; } // #endregion vector-bytecode-input-sway } diff --git a/packages/fuel-gauge/src/bytecode-sway-lib.test.ts b/packages/fuel-gauge/src/bytecode-sway-lib.test.ts index 5092af08524..67bada38089 100644 --- a/packages/fuel-gauge/src/bytecode-sway-lib.test.ts +++ b/packages/fuel-gauge/src/bytecode-sway-lib.test.ts @@ -9,7 +9,8 @@ import { getSetupContract } from './utils'; /** * @group node */ -test('compute_bytecode_root', async () => { +// TODO: Unskip test after sway-libs become compatible with latest forc (0.52+) +test.skip('compute_bytecode_root', async () => { const { binHexlified: bytecodeFromFile } = getFuelGaugeForcProject( FuelGaugeProjectsEnum.CALL_TEST_CONTRACT ); diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/bytecode-sway-lib/Forc.toml b/packages/fuel-gauge/test/fixtures/forc-projects/bytecode-sway-lib/Forc.toml index 8704b5962b1..3f1ac99ca7f 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/bytecode-sway-lib/Forc.toml +++ b/packages/fuel-gauge/test/fixtures/forc-projects/bytecode-sway-lib/Forc.toml @@ -3,5 +3,8 @@ authors = ["Fuel Labs "] license = "Apache-2.0" name = "bytecode-sway-lib" -[dependencies] -bytecode = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.19.0" } +# TODO: Uncomment bytecode-related stuff +# This requires sway-libs to be compatible with latest forc (0.52+) + +# [dependencies] +# bytecode = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.19.0" } diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/bytecode-sway-lib/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/bytecode-sway-lib/src/main.sw index 3fb485a3429..c9ff9034fa6 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/bytecode-sway-lib/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/bytecode-sway-lib/src/main.sw @@ -1,28 +1,33 @@ contract; -use bytecode::*; +// TODO: Uncomment bytecode-related stuff +// This requires sway-libs to be compatible with latest forc (0.52+) +// use bytecode::*; + abi MyContract { fn compute_bytecode_root(bytecode_input: Vec); fn verify_contract_bytecode(contract_id: ContractId, bytecode: Vec) -> bool; - fn compute_predicate_address(bytecode: Vec) -> Address; + // fn compute_predicate_address(bytecode: Vec) -> Address; + fn compute_predicate_address(bytecode: Vec) -> bool; } impl MyContract for Contract { fn compute_bytecode_root(bytecode_input: Vec) { - let mut bytecode = bytecode_input; - let root = compute_bytecode_root(bytecode); - log(root); + // let mut bytecode = bytecode_input; + // let root = compute_bytecode_root(bytecode); + // log(root); } fn verify_contract_bytecode(contract_id: ContractId, bytecode: Vec) -> bool { - verify_contract_bytecode(contract_id, bytecode); + // verify_contract_bytecode(contract_id, bytecode); return true; } - fn compute_predicate_address(bytecode: Vec) -> Address { - return compute_predicate_address(bytecode); + fn compute_predicate_address(bytecode: Vec) -> bool { + // return compute_predicate_address(bytecode); + return true; } } From 001229dad27a1514f32f4c2a8ddcad4bd61db190 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 11 Apr 2024 12:17:51 -0300 Subject: [PATCH 22/92] Upgrading `forc` to `0.53.0` --- packages/forc/VERSION | 2 +- packages/versions/src/lib/getBuiltinVersions.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/forc/VERSION b/packages/forc/VERSION index 27d68a6aacb..7f422a161ae 100644 --- a/packages/forc/VERSION +++ b/packages/forc/VERSION @@ -1 +1 @@ -0.52.1 +0.53.0 diff --git a/packages/versions/src/lib/getBuiltinVersions.ts b/packages/versions/src/lib/getBuiltinVersions.ts index ecb8788b6e8..8efd05d0927 100644 --- a/packages/versions/src/lib/getBuiltinVersions.ts +++ b/packages/versions/src/lib/getBuiltinVersions.ts @@ -1,6 +1,6 @@ export function getBuiltinVersions() { return { - FORC: '0.52.1', + FORC: '0.53.0', FUEL_CORE: '0.22.1', FUELS: '0.79.0', }; From e26dc07b487d935bc2b184023733099991b404e2 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 11 Apr 2024 14:23:49 -0300 Subject: [PATCH 23/92] Adjusting changeset --- .changeset/five-cats-chew.md | 9 --------- .changeset/gentle-cherries-reply.md | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) delete mode 100644 .changeset/five-cats-chew.md create mode 100644 .changeset/gentle-cherries-reply.md diff --git a/.changeset/five-cats-chew.md b/.changeset/five-cats-chew.md deleted file mode 100644 index 542b2eb7690..00000000000 --- a/.changeset/five-cats-chew.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -"@fuel-ts/abi-typegen": patch -"@fuel-ts/interfaces": patch -"@fuel-ts/versions": patch -"@fuel-ts/address": patch -"@fuel-ts/forc": patch ---- - -chore!: upgrading `forc` to `0.52.1` diff --git a/.changeset/gentle-cherries-reply.md b/.changeset/gentle-cherries-reply.md new file mode 100644 index 00000000000..fa3416434f8 --- /dev/null +++ b/.changeset/gentle-cherries-reply.md @@ -0,0 +1,15 @@ +--- +"create-fuels": minor +"@fuel-ts/abi-typegen": minor +"@fuel-ts/interfaces": minor +"@fuel-ts/abi-coder": minor +"@fuel-ts/versions": minor +"@fuel-ts/account": minor +"@fuel-ts/address": minor +"@fuel-ts/program": minor +"@fuel-ts/errors": minor +"@fuel-ts/forc": minor +"@fuel-ts/math": minor +--- + +Upgrading `forc` to `0.53.0` From c0d13cd4b47ed5b0540ed73bc3213acab99be26c Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 11 Apr 2024 14:33:28 -0300 Subject: [PATCH 24/92] Rolling back debugging workflow steps --- .github/workflows/test.yaml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 43d01c2d19b..f24e629810d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -46,27 +46,6 @@ jobs: - name: Forc Format Check run: pnpm forc:check - - name: Debugging `forc build` @ docs-snippets - run: cd apps/docs-snippets && pnpm pretest - - - name: Debugging `forc build` @ demo-typegen - run: cd apps/demo-typegen && pnpm pretest - - - name: Debugging `forc build` @ abi-coder - run: cd packages/abi-coder && pnpm pretest - - - name: Debugging `forc build` @ fuel-gauge - run: cd packages/fuel-gauge && pnpm pretest - - - name: Debugging `forc build` @ script - run: cd packages/script && pnpm pretest - - - name: Debugging `forc build` @ abi-typegen - run: cd packages/abi-typegen && pnpm pretest - - - name: Debugging `forc build` @ utils - run: cd packages/utils && pnpm pretest - # linting of some tests depends on pretest being run so that it generates the necessary files - name: Pretest run: pnpm pretest From 73d6a2af7b96933620cd472c626e6d16c7382a70 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 11 Apr 2024 14:45:46 -0300 Subject: [PATCH 25/92] Fixing broken tests (applying breaking changes) --- packages/fuel-gauge/src/bytecode-sway-lib.test.ts | 4 ++-- packages/fuel-gauge/src/fee.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/fuel-gauge/src/bytecode-sway-lib.test.ts b/packages/fuel-gauge/src/bytecode-sway-lib.test.ts index 67bada38089..22980a0034c 100644 --- a/packages/fuel-gauge/src/bytecode-sway-lib.test.ts +++ b/packages/fuel-gauge/src/bytecode-sway-lib.test.ts @@ -39,7 +39,7 @@ test('verify_contract_bytecode', async () => { const { value } = await contract.functions .verify_contract_bytecode( { - value: contract.id.toB256(), + bits: contract.id.toB256(), }, arrayify(bytecodeFromFile) ) @@ -66,5 +66,5 @@ test('compute_predicate_address', async () => { .compute_predicate_address(arrayify(defaultPredicateBytecode)) .call(); - expect(value.value).toEqual(address.toB256()); + expect(value.bits).toEqual(address.toB256()); }); diff --git a/packages/fuel-gauge/src/fee.test.ts b/packages/fuel-gauge/src/fee.test.ts index c8cc08b8dfa..b0753702ded 100644 --- a/packages/fuel-gauge/src/fee.test.ts +++ b/packages/fuel-gauge/src/fee.test.ts @@ -265,7 +265,7 @@ describe('Fee', () => { const subId = '0x4a778acfad1abc155a009dc976d2cf0db6197d3d360194d74b1fb92b96986b00'; - const genAddresses = () => Array.from({ length: 3 }, () => ({ value: getRandomB256() })); + const genAddresses = () => Array.from({ length: 3 }, () => ({ bits: getRandomB256() })); const calls = Array.from({ length: 15 }).map(() => contract.functions.mint_to_addresses(genAddresses(), subId, 100) From 7080ea5ee7a255510dfa01ef71011699aaf15399 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 11 Apr 2024 14:53:57 -0300 Subject: [PATCH 26/92] Adjusting changeset --- .changeset/gentle-cherries-reply.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/gentle-cherries-reply.md b/.changeset/gentle-cherries-reply.md index fa3416434f8..48a8cf4b735 100644 --- a/.changeset/gentle-cherries-reply.md +++ b/.changeset/gentle-cherries-reply.md @@ -12,4 +12,4 @@ "@fuel-ts/math": minor --- -Upgrading `forc` to `0.53.0` +chore!: upgrading `forc` to `0.53.0` From ac13cef6d1bba7123e3b13b6c57f13d3dfcec262 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 11 Apr 2024 15:07:37 -0300 Subject: [PATCH 27/92] Grouping all skipped tests into a single `describe` block --- .../fuel-gauge/src/bytecode-sway-lib.test.ts | 88 ++++++++++--------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/packages/fuel-gauge/src/bytecode-sway-lib.test.ts b/packages/fuel-gauge/src/bytecode-sway-lib.test.ts index 22980a0034c..4bcf2d9b74e 100644 --- a/packages/fuel-gauge/src/bytecode-sway-lib.test.ts +++ b/packages/fuel-gauge/src/bytecode-sway-lib.test.ts @@ -10,61 +10,63 @@ import { getSetupContract } from './utils'; * @group node */ // TODO: Unskip test after sway-libs become compatible with latest forc (0.52+) -test.skip('compute_bytecode_root', async () => { - const { binHexlified: bytecodeFromFile } = getFuelGaugeForcProject( - FuelGaugeProjectsEnum.CALL_TEST_CONTRACT - ); +describe('bytecode computations', () => { + test('compute_bytecode_root', async () => { + const { binHexlified: bytecodeFromFile } = getFuelGaugeForcProject( + FuelGaugeProjectsEnum.CALL_TEST_CONTRACT + ); - const setupContract = getSetupContract(FuelGaugeProjectsEnum.BYTECODE_SWAY_LIB); - const contract = await setupContract(); + const setupContract = getSetupContract(FuelGaugeProjectsEnum.BYTECODE_SWAY_LIB); + const contract = await setupContract(); - const { logs } = await contract.functions - .compute_bytecode_root(arrayify(bytecodeFromFile)) - .call(); + const { logs } = await contract.functions + .compute_bytecode_root(arrayify(bytecodeFromFile)) + .call(); - const bytecodeRoot: string = logs[0]; + const bytecodeRoot: string = logs[0]; - expect(bytecodeRoot).toBeDefined(); - expect(bytecodeRoot.length).toBe(66); -}); + expect(bytecodeRoot).toBeDefined(); + expect(bytecodeRoot.length).toBe(66); + }); -test('verify_contract_bytecode', async () => { - const { binHexlified: bytecodeFromFile } = getFuelGaugeForcProject( - FuelGaugeProjectsEnum.BYTECODE_SWAY_LIB - ); + test('verify_contract_bytecode', async () => { + const { binHexlified: bytecodeFromFile } = getFuelGaugeForcProject( + FuelGaugeProjectsEnum.BYTECODE_SWAY_LIB + ); - const setupContract = getSetupContract(FuelGaugeProjectsEnum.BYTECODE_SWAY_LIB); - const contract = await setupContract(); + const setupContract = getSetupContract(FuelGaugeProjectsEnum.BYTECODE_SWAY_LIB); + const contract = await setupContract(); - const { value } = await contract.functions - .verify_contract_bytecode( - { - bits: contract.id.toB256(), - }, - arrayify(bytecodeFromFile) - ) - .call(); + const { value } = await contract.functions + .verify_contract_bytecode( + { + bits: contract.id.toB256(), + }, + arrayify(bytecodeFromFile) + ) + .call(); - expect(value).toBeTruthy(); -}); + expect(value).toBeTruthy(); + }); -test('compute_predicate_address', async () => { - const provider = await Provider.create(FUEL_NETWORK_URL); + test('compute_predicate_address', async () => { + const provider = await Provider.create(FUEL_NETWORK_URL); - const predicate = new Predicate({ - bytecode: defaultPredicateBytecode, - abi: defaultPredicateAbi, - provider, - }); + const predicate = new Predicate({ + bytecode: defaultPredicateBytecode, + abi: defaultPredicateAbi, + provider, + }); - const address = predicate.address; + const address = predicate.address; - const setupContract = getSetupContract(FuelGaugeProjectsEnum.BYTECODE_SWAY_LIB); - const contract = await setupContract(); + const setupContract = getSetupContract(FuelGaugeProjectsEnum.BYTECODE_SWAY_LIB); + const contract = await setupContract(); - const { value } = await contract.functions - .compute_predicate_address(arrayify(defaultPredicateBytecode)) - .call(); + const { value } = await contract.functions + .compute_predicate_address(arrayify(defaultPredicateBytecode)) + .call(); - expect(value.bits).toEqual(address.toB256()); + expect(value.bits).toEqual(address.toB256()); + }); }); From d53c837cf349c1c77e9c6170037cde1ae624aae9 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 11 Apr 2024 15:16:15 -0300 Subject: [PATCH 28/92] Fixing test; updating vector pointer assertion --- packages/fuel-gauge/src/script-with-vectors.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fuel-gauge/src/script-with-vectors.test.ts b/packages/fuel-gauge/src/script-with-vectors.test.ts index 80e35dbb431..426f5ceb44c 100644 --- a/packages/fuel-gauge/src/script-with-vectors.test.ts +++ b/packages/fuel-gauge/src/script-with-vectors.test.ts @@ -39,7 +39,7 @@ describe('Script With Vectors', () => { const formattedLog = logs.map((l) => (typeof l === 'string' ? l : l.toNumber())); const vecFirst = someVec[0]; - const vecPointer = 7; + const vecPointer = 11232; const vecCapacity = 4; const vecLen = 4; const vecAddr = 11208; From 82a656cb355d78d1a36f086b77c632a70fab3d46 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 11 Apr 2024 15:38:46 -0300 Subject: [PATCH 29/92] Skipping grouped tests --- packages/fuel-gauge/src/bytecode-sway-lib.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fuel-gauge/src/bytecode-sway-lib.test.ts b/packages/fuel-gauge/src/bytecode-sway-lib.test.ts index 4bcf2d9b74e..7129afccf49 100644 --- a/packages/fuel-gauge/src/bytecode-sway-lib.test.ts +++ b/packages/fuel-gauge/src/bytecode-sway-lib.test.ts @@ -10,7 +10,7 @@ import { getSetupContract } from './utils'; * @group node */ // TODO: Unskip test after sway-libs become compatible with latest forc (0.52+) -describe('bytecode computations', () => { +describe.skip('bytecode computations', () => { test('compute_bytecode_root', async () => { const { binHexlified: bytecodeFromFile } = getFuelGaugeForcProject( FuelGaugeProjectsEnum.CALL_TEST_CONTRACT From 2d66ae6d10470b124394be4ca99e3a85b2058b5a Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 11 Apr 2024 16:39:13 -0300 Subject: [PATCH 30/92] Disabling PR auto-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 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 f67d8686b43bea3024b5c107b287a2d3bfcfd784 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 12 Apr 2024 14:51:02 +0100 Subject: [PATCH 31/92] chore: use experimental build for all workspaces --- apps/demo-typegen/package.json | 6 +++--- apps/docs-snippets/package.json | 2 +- packages/abi-coder/package.json | 2 +- packages/abi-typegen/package.json | 2 +- packages/fuel-gauge/package.json | 2 +- packages/script/package.json | 2 +- packages/utils/package.json | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/demo-typegen/package.json b/apps/demo-typegen/package.json index bfa810e6b9a..6a2b7c7a516 100644 --- a/apps/demo-typegen/package.json +++ b/apps/demo-typegen/package.json @@ -6,9 +6,9 @@ "scripts": { "pretest": "run-s build:forc build:types", "build:forc": "run-p forc:*", - "forc:contract": "pnpm fuels-forc build -p contract --release", - "forc:script": "pnpm fuels-forc build -p script --release", - "forc:predicate": "pnpm fuels-forc build -p predicate --release", + "forc:contract": "pnpm fuels-forc build -p contract --release --experimental-new-encoding", + "forc:script": "pnpm fuels-forc build -p script --release --experimental-new-encoding", + "forc:predicate": "pnpm fuels-forc build -p predicate --release --experimental-new-encoding", "build:types": "run-p types:*", "types:contract": "pnpm fuels typegen -i contract/out/release/demo-contract-abi.json -o src/contract-types", "types:script": "pnpm fuels typegen -i script/out/release/script-abi.json -o src/script-types --script", diff --git a/apps/docs-snippets/package.json b/apps/docs-snippets/package.json index f28744bd6dd..cd2c97971fb 100644 --- a/apps/docs-snippets/package.json +++ b/apps/docs-snippets/package.json @@ -5,7 +5,7 @@ "private": true, "scripts": { "pretest": "pnpm build:forc", - "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release" + "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release --experimental-new-encoding" }, "devDependencies": { "@fuel-ts/account": "workspace:*", diff --git a/packages/abi-coder/package.json b/packages/abi-coder/package.json index bdbb20596a6..f5a1869446d 100644 --- a/packages/abi-coder/package.json +++ b/packages/abi-coder/package.json @@ -21,7 +21,7 @@ ], "scripts": { "pretest": "pnpm build:forc", - "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release", + "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release --experimental-new-encoding", "build": "tsup", "postbuild": "tsx ../../scripts/postbuild.ts" }, diff --git a/packages/abi-typegen/package.json b/packages/abi-typegen/package.json index 7ebb5c4450e..dcb60413417 100644 --- a/packages/abi-typegen/package.json +++ b/packages/abi-typegen/package.json @@ -45,7 +45,7 @@ "scripts": { "pretest": "pnpm build:forc", "build": "tsup", - "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release", + "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release --experimental-new-encoding", "postbuild": "tsx ../../scripts/postbuild.ts" }, "license": "Apache-2.0", diff --git a/packages/fuel-gauge/package.json b/packages/fuel-gauge/package.json index e24dca096bf..131fb7f0edb 100644 --- a/packages/fuel-gauge/package.json +++ b/packages/fuel-gauge/package.json @@ -6,7 +6,7 @@ "author": "Fuel Labs (https://fuel.network/)", "scripts": { "pretest": "run-s build:forc build:forc-experimental build:process-predicates", - "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release", + "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release --experimental-new-encoding", "build:forc-experimental": "pnpm fuels-forc build -p test/fixtures/forc-projects-experimental --release --experimental-new-encoding", "build:process-predicates": "tsx ./scripts/process-predicates.ts" }, diff --git a/packages/script/package.json b/packages/script/package.json index 0a4fa4a46ba..2fcd20cb28d 100644 --- a/packages/script/package.json +++ b/packages/script/package.json @@ -22,7 +22,7 @@ "scripts": { "pretest": "pnpm build:forc", "build": "tsup", - "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release", + "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release --experimental-new-encoding", "postbuild": "tsx ../../scripts/postbuild.ts" }, "license": "Apache-2.0", diff --git a/packages/utils/package.json b/packages/utils/package.json index ae9987f1963..ffa8d2f24fb 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -42,7 +42,7 @@ "scripts": { "pretest": "pnpm build:forc", "build": "tsup", - "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release", + "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release --experimental-new-encoding", "postbuild": "tsx ../../scripts/postbuild.ts" }, "license": "Apache-2.0", From d8f4141ad191d8399747622389345c9cf2df6519 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 12 Apr 2024 14:51:19 +0100 Subject: [PATCH 32/92] chore: use correct casing for exhaustive example --- .../fixtures/forc-projects/exhaustive-examples/src/main.sw | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/abi-coder/test/fixtures/forc-projects/exhaustive-examples/src/main.sw b/packages/abi-coder/test/fixtures/forc-projects/exhaustive-examples/src/main.sw index 84c5c1ba917..a7a0418b3d8 100644 --- a/packages/abi-coder/test/fixtures/forc-projects/exhaustive-examples/src/main.sw +++ b/packages/abi-coder/test/fixtures/forc-projects/exhaustive-examples/src/main.sw @@ -133,7 +133,7 @@ abi MyContract { fn struct_simple(x: SimpleStruct) -> SimpleStruct; fn struct_generic_simple(x: StructB) -> StructB; fn struct_with_tuple(x: StructB<(bool, u64)>) -> StructB<(bool, u64)>; - fn struct_with_implicitGenerics( + fn struct_with_implicit_generics( arg: StructWithImplicitGenerics, ) -> StructWithImplicitGenerics; fn bytes(arg: Bytes) -> Bytes; @@ -256,7 +256,7 @@ impl MyContract for Contract { fn vector_u8_then_arg(x: Vec, y: b256) -> (Vec, b256) { (x, y) } - fn struct_with_implicitGenerics( + fn struct_with_implicit_generics( arg: StructWithImplicitGenerics, ) -> StructWithImplicitGenerics { arg From b31ee6f99516bce59a2112b5df9a2ec879188a0f Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 12 Apr 2024 14:52:21 +0100 Subject: [PATCH 33/92] fix: use new vec capacity --- .../test/fixtures/forc-projects/coverage-contract/src/main.sw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/coverage-contract/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/coverage-contract/src/main.sw index 6cd82721b33..7728d88e5be 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/coverage-contract/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/coverage-contract/src/main.sw @@ -229,7 +229,7 @@ impl CoverageContract for Contract { 0 => false, length => { assert(length == 5); - assert(vector.capacity() == 5); + assert(vector.capacity() == 8); assert(vector.is_empty() == false); log(__to_str_array("vector.items")); log(vector.get(0)); From 29897ee30248c9214680752e86955b106ee2c20e Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 12 Apr 2024 14:52:36 +0100 Subject: [PATCH 34/92] chore: use raw ptr patch branch --- packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml b/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml index 22119f792bf..caeab7eb2dc 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml +++ b/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml @@ -55,3 +55,6 @@ members = [ "vector-types-script", "vectors", ] + +[patch.'https://github.com/fuellabs/sway'] +std = { git = "https://github.com/fuellabs/sway", branch = "db/pointer-abiencode-impl" } \ No newline at end of file From b0a937730f6bbd8260b03714efb445940b5c5bc0 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 12 Apr 2024 15:26:58 +0100 Subject: [PATCH 35/92] feat: fix for vec capacity and remove pointer encoding --- packages/fuel-gauge/src/script-with-vectors.test.ts | 6 ------ packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml | 2 +- .../fixtures/forc-projects/coverage-contract/src/main.sw | 2 +- .../fixtures/forc-projects/script-with-vector/src/main.sw | 4 ---- 4 files changed, 2 insertions(+), 12 deletions(-) diff --git a/packages/fuel-gauge/src/script-with-vectors.test.ts b/packages/fuel-gauge/src/script-with-vectors.test.ts index 426f5ceb44c..b4688683b7a 100644 --- a/packages/fuel-gauge/src/script-with-vectors.test.ts +++ b/packages/fuel-gauge/src/script-with-vectors.test.ts @@ -39,21 +39,15 @@ describe('Script With Vectors', () => { const formattedLog = logs.map((l) => (typeof l === 'string' ? l : l.toNumber())); const vecFirst = someVec[0]; - const vecPointer = 11232; const vecCapacity = 4; const vecLen = 4; - const vecAddr = 11208; expect(formattedLog).toEqual([ vecFirst, - 'vector.ptr()', - vecPointer, 'vector.capacity()', vecCapacity, 'vector.len()', vecLen, - 'addr_of vector', - vecAddr, ]); }); diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml b/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml index caeab7eb2dc..dbc20188b7a 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml +++ b/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml @@ -57,4 +57,4 @@ members = [ ] [patch.'https://github.com/fuellabs/sway'] -std = { git = "https://github.com/fuellabs/sway", branch = "db/pointer-abiencode-impl" } \ No newline at end of file +std = { git = "https://github.com/fuellabs/sway", branch = "xunilrj/abi-decode-vec-with-capacity" } \ No newline at end of file diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/coverage-contract/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/coverage-contract/src/main.sw index 7728d88e5be..6cd82721b33 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/coverage-contract/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/coverage-contract/src/main.sw @@ -229,7 +229,7 @@ impl CoverageContract for Contract { 0 => false, length => { assert(length == 5); - assert(vector.capacity() == 8); + assert(vector.capacity() == 5); assert(vector.is_empty() == false); log(__to_str_array("vector.items")); log(vector.get(0)); diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw index a77cc04efdb..864d3bc8088 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw @@ -11,14 +11,10 @@ fn main(vector: Vec) { assert(length == 4); assert(vector.capacity() == 4); assert(vector.is_empty() == false); - log(__to_str_array("vector.ptr()")); - log(vector.ptr()); log(__to_str_array("vector.capacity()")); log(vector.capacity()); log(__to_str_array("vector.len()")); log(vector.len()); - log(__to_str_array("addr_of vector")); - log(__addr_of(vector)); true }, }; From f55e5e9aafb8854862ab781d48837fbf9d05ed8c Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 12 Apr 2024 18:49:17 +0100 Subject: [PATCH 36/92] feat: correctly set script return type for coding --- .../guide/cookbook/signing-transactions.test.ts | 2 +- packages/fuel-gauge/src/bytes.test.ts | 2 +- .../src/script-with-configurable.test.ts | 14 +++++--------- .../fuel-gauge/src/script-with-vectors.test.ts | 4 ++-- packages/fuel-gauge/src/std-lib-string.test.ts | 4 ++-- packages/fuel-gauge/src/vector-types.test.ts | 2 +- .../forc-projects/script-bytes/src/main.sw | 4 +++- .../script-std-lib-string/src/main.sw | 4 +++- .../forc-projects/script-with-vector/src/main.sw | 4 +++- 9 files changed, 21 insertions(+), 19 deletions(-) diff --git a/apps/docs-snippets/src/guide/cookbook/signing-transactions.test.ts b/apps/docs-snippets/src/guide/cookbook/signing-transactions.test.ts index b47e30d8a48..188a65e4bb8 100644 --- a/apps/docs-snippets/src/guide/cookbook/signing-transactions.test.ts +++ b/apps/docs-snippets/src/guide/cookbook/signing-transactions.test.ts @@ -57,7 +57,7 @@ describe('Signing transactions', () => { .call(); // #endregion multiple-signers-2 - expect(value.toNumber()).toEqual(1); + expect(value).toBe(true); expect((await receiver.getBalance()).toNumber()).toEqual(amountToReceiver); }); diff --git a/packages/fuel-gauge/src/bytes.test.ts b/packages/fuel-gauge/src/bytes.test.ts index ce9e75c37e5..eb0d3165ea2 100644 --- a/packages/fuel-gauge/src/bytes.test.ts +++ b/packages/fuel-gauge/src/bytes.test.ts @@ -138,6 +138,6 @@ describe('Bytes Tests', () => { }; const { value } = await scriptInstance.functions.main(1, INPUT).call(); - expect(value.toNumber()).toStrictEqual(0); + expect(value).toBe(true); }); }); diff --git a/packages/fuel-gauge/src/script-with-configurable.test.ts b/packages/fuel-gauge/src/script-with-configurable.test.ts index ab20e3cafb9..b54574b787a 100644 --- a/packages/fuel-gauge/src/script-with-configurable.test.ts +++ b/packages/fuel-gauge/src/script-with-configurable.test.ts @@ -1,6 +1,6 @@ import { generateTestWallet } from '@fuel-ts/account/test-utils'; import type { CoinQuantityLike, WalletUnlocked } from 'fuels'; -import { BN, Script, BaseAssetId, Provider, FUEL_NETWORK_URL } from 'fuels'; +import { Script, BaseAssetId, Provider, FUEL_NETWORK_URL } from 'fuels'; import { FuelGaugeProjectsEnum, getFuelGaugeForcProject } from '../test/fixtures'; @@ -37,8 +37,7 @@ describe('Script With Configurable', () => { const { value } = await script.functions.main(defaultValues.FEE).call(); - // expected to be true - expect(new BN(value as number).toNumber()).toEqual(1); + expect(value).toBe(true); }); it('should returns false when input value differs from default configurable constant', async () => { @@ -52,8 +51,7 @@ describe('Script With Configurable', () => { const { value } = await script.functions.main(configurableConstants.FEE).call(); - // expected to be false - expect(new BN(value as number).toNumber()).toEqual(0); + expect(value).toBe(false); }); it('should returns true when input value matches manually set configurable constant', async () => { @@ -65,8 +63,7 @@ describe('Script With Configurable', () => { const { value } = await script.functions.main(configurableConstants.FEE).call(); - // expected to be true - expect(new BN(value as number).toNumber()).toEqual(1); + expect(value).toBe(true); }); it('should returns false when input value differs from manually set configurable constant', async () => { @@ -82,7 +79,6 @@ describe('Script With Configurable', () => { const { value } = await script.functions.main(input.FEE).call(); - // expected to be false - expect(new BN(value as number).toNumber()).toEqual(0); + expect(value).toBe(false); }); }); diff --git a/packages/fuel-gauge/src/script-with-vectors.test.ts b/packages/fuel-gauge/src/script-with-vectors.test.ts index b4688683b7a..214d20f87d6 100644 --- a/packages/fuel-gauge/src/script-with-vectors.test.ts +++ b/packages/fuel-gauge/src/script-with-vectors.test.ts @@ -88,7 +88,7 @@ describe('Script With Vectors', () => { const scriptInstance = getScript<[any], void>('script-with-vector-mixed', wallet); const { value } = await scriptInstance.functions.main(importantDates).call(); - expect((value as unknown as BN).toString()).toBe('1'); + expect(value).toBe(true); }); it('can call script and use main argument [struct in vec in struct in vec in struct in vec]', async () => { @@ -155,6 +155,6 @@ describe('Script With Vectors', () => { const scriptInstance = getScript<[any[]], void>('script-with-vector-advanced', wallet); const { value } = await scriptInstance.functions.main(vectorOfStructs).call(); - expect((value as unknown as BN).toString()).toBe('1'); + expect(value).toBe(true); }); }); diff --git a/packages/fuel-gauge/src/std-lib-string.test.ts b/packages/fuel-gauge/src/std-lib-string.test.ts index f953e57e86f..3d7a83e717c 100644 --- a/packages/fuel-gauge/src/std-lib-string.test.ts +++ b/packages/fuel-gauge/src/std-lib-string.test.ts @@ -89,8 +89,8 @@ describe('std-lib-string Tests', () => { const scriptInstance = getScript('script-std-lib-string', wallet); const INPUT = 'Hello World'; - const { value } = await scriptInstance.functions.main(INPUT).call(); + const { value } = await scriptInstance.functions.main(INPUT).call(); - expect(value.toNumber()).toStrictEqual(0); + expect(value).toBe(true); }); }); diff --git a/packages/fuel-gauge/src/vector-types.test.ts b/packages/fuel-gauge/src/vector-types.test.ts index 43b06f1512c..4376fee72c1 100644 --- a/packages/fuel-gauge/src/vector-types.test.ts +++ b/packages/fuel-gauge/src/vector-types.test.ts @@ -140,7 +140,7 @@ describe('Vector Types Validation', () => { ) .call(); - expect(value.toString()).toBe('1'); + expect(value).toBe(true); }); it('can use supported vector types [predicate-vector-types]', async () => { diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/script-bytes/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/script-bytes/src/main.sw index f41dc63c7ac..dc3f40abf76 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/script-bytes/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/script-bytes/src/main.sw @@ -23,7 +23,7 @@ fn expected_bytes() -> Bytes { bytes } -fn main(_arg: u64, wrapper: Wrapper>) { +fn main(_arg: u64, wrapper: Wrapper>) -> bool { if let SomeEnum::Second(enum_bytes) = wrapper.inner_enum { require( enum_bytes == expected_bytes(), @@ -51,4 +51,6 @@ fn main(_arg: u64, wrapper: Wrapper>) { .unwrap() == expected_bytes(), "wrapper.inner[1] didn't match expectation", ); + + true } diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/script-std-lib-string/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/script-std-lib-string/src/main.sw index 14ed91e311e..7457956c857 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/script-std-lib-string/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/script-std-lib-string/src/main.sw @@ -19,6 +19,8 @@ fn validate_string(arg: String) { } } -fn main(arg: String) { +fn main(arg: String) -> bool { validate_string(arg); + + true } diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw index 864d3bc8088..db3b2544d35 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw +++ b/packages/fuel-gauge/test/fixtures/forc-projects/script-with-vector/src/main.sw @@ -2,7 +2,7 @@ script; use std::logging::log; -fn main(vector: Vec) { +fn main(vector: Vec) -> bool { log(vector.get(0).unwrap()); let _is_valid = match vector.len() { @@ -20,4 +20,6 @@ fn main(vector: Vec) { }; require(vector.get(0).unwrap() == 7, "value is not as expected"); + + _is_valid } From 7b5c9cf4bd37e1b5aec65317a50bef87c0be1448 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 12 Apr 2024 18:50:02 +0100 Subject: [PATCH 37/92] chore: remove experimental from ABI coder --- packages/abi-coder/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/abi-coder/package.json b/packages/abi-coder/package.json index f5a1869446d..bdbb20596a6 100644 --- a/packages/abi-coder/package.json +++ b/packages/abi-coder/package.json @@ -21,7 +21,7 @@ ], "scripts": { "pretest": "pnpm build:forc", - "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release --experimental-new-encoding", + "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release", "build": "tsup", "postbuild": "tsx ../../scripts/postbuild.ts" }, From 26fccf15b037416d813af334ed5b60d7abc2eb84 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 12 Apr 2024 18:50:41 +0100 Subject: [PATCH 38/92] feat: add multicall test to experimental contract --- .../src/experimental-contract.test.ts | 17 +++++++++++++++++ .../contract-echo/src/main.sw | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/packages/fuel-gauge/src/experimental-contract.test.ts b/packages/fuel-gauge/src/experimental-contract.test.ts index e2078715611..ad4cfa96dcb 100644 --- a/packages/fuel-gauge/src/experimental-contract.test.ts +++ b/packages/fuel-gauge/src/experimental-contract.test.ts @@ -108,4 +108,21 @@ describe('Experimental Contract', () => { 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/test/fixtures/forc-projects-experimental/contract-echo/src/main.sw b/packages/fuel-gauge/test/fixtures/forc-projects-experimental/contract-echo/src/main.sw index 9defecdf883..61b48badd61 100644 --- 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 @@ -73,6 +73,8 @@ 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 { @@ -96,4 +98,12 @@ impl MyContract for Contract { CONF } + + fn first_call(param: u8) -> u8 { + param + } + + fn second_call(param: u16) -> u16 { + param + } } From 9213c9ce9d249f016df7ba7369c9b1d83ea7e6d6 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Mon, 15 Apr 2024 11:50:27 +0100 Subject: [PATCH 39/92] chore: forc format --- packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml b/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml index dbc20188b7a..54091c11575 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml +++ b/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml @@ -57,4 +57,4 @@ members = [ ] [patch.'https://github.com/fuellabs/sway'] -std = { git = "https://github.com/fuellabs/sway", branch = "xunilrj/abi-decode-vec-with-capacity" } \ No newline at end of file +std = { git = "https://github.com/fuellabs/sway", branch = "xunilrj/abi-decode-vec-with-capacity" } From db8a1f5dc7c472aa3469aee3958350c13a6bec24 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 16 Apr 2024 09:45:50 +0100 Subject: [PATCH 40/92] fix: multicall issue in contract call script --- packages/program/src/contract-call-script.ts | 49 +++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/packages/program/src/contract-call-script.ts b/packages/program/src/contract-call-script.ts index f35df0311fc..94a433d0dbe 100644 --- a/packages/program/src/contract-call-script.ts +++ b/packages/program/src/contract-call-script.ts @@ -21,6 +21,7 @@ import { bn, toNumber } from '@fuel-ts/math'; import { ReceiptType } from '@fuel-ts/transactions'; import { concat, arrayify } from '@fuel-ts/utils'; import * as asm from '@fuels/vm-asm'; +import { a } from 'vitest/dist/suite-MFRDkZcV'; import { InstructionSet } from './instruction-set'; import type { EncodedScriptCall, ScriptResult } from './script-request'; @@ -277,40 +278,42 @@ export const getScriptDataV1: ContractCallScriptFn = ( segmentOffset: number ): { scriptData: Uint8Array[]; callParamOffsets: CallOpcodeParamsOffset } => { const scriptData: Uint8Array[] = []; - const callSegmentOffset = segmentOffset + WORD_SIZE; - let gasForwardedSize: number = 0; + + 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() || BaseAssetId)); - // 3. Gas to be forwarded + // 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)); - gasForwardedSize = WORD_SIZE; + gasForwardedOffset = encodedArgsOffset + encodedArgs.byteLength; } const callParamOffsets: CallOpcodeParamsOffset = { - amountOffset: callSegmentOffset, - assetIdOffset: callSegmentOffset + WORD_SIZE, - gasForwardedOffset: callSegmentOffset + WORD_SIZE + ASSET_ID_LEN, - callDataOffset: callSegmentOffset + WORD_SIZE + ASSET_ID_LEN + gasForwardedSize, + amountOffset, + assetIdOffset, + gasForwardedOffset, + callDataOffset, }; - const encodedSelectorOffset = - callParamOffsets.callDataOffset + CONTRACT_ID_LEN + WORD_SIZE + WORD_SIZE; - const customInputOffset = encodedSelectorOffset + call.fnSelectorBytes.length; - const bytes = arrayify(call.data); - - // 4. Contract ID - scriptData.push(call.contractId.toBytes()); - // 5. Function selector offset - scriptData.push(new BigNumberCoder('u64').encode(encodedSelectorOffset)); - // 6. CallData offset - scriptData.push(new BigNumberCoder('u64').encode(customInputOffset)); - // 7. Function selector - scriptData.push(call.fnSelectorBytes); - // 8. Encoded arguments - scriptData.push(bytes); return { scriptData, From 6abc8856b9ce71ce43595d8b9866da4cf503040c Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 16 Apr 2024 09:46:21 +0100 Subject: [PATCH 41/92] docs: remove redundant revert error docs --- .../errors/debugging-revert-errors.test.ts | 37 ------------------ apps/docs/.vitepress/config.ts | 4 -- .../guide/errors/debugging-revert-errors.md | 39 ------------------- 3 files changed, 80 deletions(-) delete mode 100644 apps/docs-snippets/src/guide/errors/debugging-revert-errors.test.ts delete mode 100644 apps/docs/src/guide/errors/debugging-revert-errors.md diff --git a/apps/docs-snippets/src/guide/errors/debugging-revert-errors.test.ts b/apps/docs-snippets/src/guide/errors/debugging-revert-errors.test.ts deleted file mode 100644 index 4b281b208c6..00000000000 --- a/apps/docs-snippets/src/guide/errors/debugging-revert-errors.test.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { DocSnippetProjectsEnum } from '../../../test/fixtures/forc-projects'; -import { createAndDeployContractFromProject } from '../../utils'; - -/** - * @group node - */ -describe(__filename, () => { - it('logs out custom require messages for error enums when tx reverts', async () => { - const contract = await createAndDeployContractFromProject(DocSnippetProjectsEnum.REVERT_ERRORS); - - // #region revert-errors-4 - expect(() => contract.functions.test_function_with_custom_error().call()).rejects.toThrow( - 'The transaction reverted because a "require" statement has thrown "InvalidInput".' - ); - // #endregion revert-errors-4 - }); - - it('logs out custom require messages for require statements using str array when tx reverts', async () => { - const contract = await createAndDeployContractFromProject(DocSnippetProjectsEnum.REVERT_ERRORS); - - // #region revert-errors-7 - expect(() => contract.functions.test_function_with_str_array_message().call()).rejects.toThrow( - 'The transaction reverted because a "require" statement has thrown "This is also a revert error".' - ); - // #endregion revert-errors-7 - }); - - it('logs out a generic error message for require statements with a simple string message', async () => { - const contract = await createAndDeployContractFromProject(DocSnippetProjectsEnum.REVERT_ERRORS); - - // #region revert-errors-5 - expect(() => contract.functions.test_function().call()).rejects.toThrow( - 'String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`' - ); - // #endregion revert-errors-5 - }); -}); diff --git a/apps/docs/.vitepress/config.ts b/apps/docs/.vitepress/config.ts index 15015a88cad..0a5fa0cc949 100644 --- a/apps/docs/.vitepress/config.ts +++ b/apps/docs/.vitepress/config.ts @@ -70,10 +70,6 @@ export default defineConfig({ text: 'Error Codes', link: '/guide/errors/error-codes', }, - { - text: 'Debugging Revert Errors', - link: '/guide/errors/debugging-revert-errors', - }, ], }, { diff --git a/apps/docs/src/guide/errors/debugging-revert-errors.md b/apps/docs/src/guide/errors/debugging-revert-errors.md deleted file mode 100644 index f5c1de1b441..00000000000 --- a/apps/docs/src/guide/errors/debugging-revert-errors.md +++ /dev/null @@ -1,39 +0,0 @@ -# Debugging Revert Errors - -Unfortunately, the SDK does not support debugging revert errors with string messages - at least temporarily. This is because the SDK does not support decoding of Sway `str` slices in the `v0` Sway encoding scheme. This problem will be fixed soon once the `v1` Sway encoding scheme is adopted. - -But for now, if your Sway contract has a revert error with a string message like this: - -<<< @/../../docs-snippets/test/fixtures/forc-projects/revert-errors/src/main.sw#revert-errors-1{rust:line-numbers} - -The SDK will throw an error that says: - -<<< @/../../docs-snippets/src/guide/errors/debugging-revert-errors.test.ts#revert-errors-5{ts:line-numbers} - -It will not log out the message associated with the revert error. This can make debugging functions with multiple require statements difficult. - -## Temporary Workarounds - -### Using `__to_str_array` - -You can work around this by using the `__to_str_array` helper function to convert the `str` slice to a string array: - -<<< @/../../docs-snippets/test/fixtures/forc-projects/revert-errors/src/main.sw#revert-errors-6{rust:line-numbers} - -The SDK will log out the message associated with the revert error like so: - -<<< @/../../docs-snippets/src/guide/errors/debugging-revert-errors.test.ts#revert-errors-7{ts:line-numbers} - -### Using custom error enums - -You can also work around this by using custom enums to represent the error messages. For example, you can create an enum like this: - -<<< @/../../docs-snippets/test/fixtures/forc-projects/revert-errors/src/main.sw#revert-errors-2{rust:line-numbers} - -Then, you can use the enum in your contract like this: - -<<< @/../../docs-snippets/test/fixtures/forc-projects/revert-errors/src/main.sw#revert-errors-3{rust:line-numbers} - -The SDK will log out the message associated with the revert error like so: - -<<< @/../../docs-snippets/src/guide/errors/debugging-revert-errors.test.ts#revert-errors-4{ts:line-numbers} From 035102f5f3b3ff204209199928d9087aa14b72c2 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 16 Apr 2024 09:49:18 +0100 Subject: [PATCH 42/92] feat: update typegen templates --- .../test/fixtures/templates/contract/bytecode.hbs | 2 +- .../abi-typegen/test/fixtures/templates/contract/factory.hbs | 1 + .../templates/predicate-with-configurable/factory.hbs | 5 +++-- .../test/fixtures/templates/predicate/factory.hbs | 1 + .../fixtures/templates/script-with-configurable/factory.hbs | 3 ++- .../abi-typegen/test/fixtures/templates/script/factory.hbs | 1 + 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/abi-typegen/test/fixtures/templates/contract/bytecode.hbs b/packages/abi-typegen/test/fixtures/templates/contract/bytecode.hbs index a6c9c6d78ed..b805cb58b6b 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 '0x1af030007400000200000000000000445dffc00110ffff005d4060495d47f001134904407648000272f0007b36f000001aec50005c43f00024400000470000000000000001000000000000000000000055b7ae10' +export default '0x1af030007400000200000000000002285dffc00110ffff00740000001aec5000910001601a4060005d4900491b401000104524005d43f002104004005d4510001b40140010412400504bb0205fed00045fed10055043b130724c0010284124c05043b130504bb070724c0010284904c05d412000504bb0105fed00025fed10035043b11072440010284124405043b1105d47f009104513005fed10005d47f0035fed10015047b050724800102847b480504bb080724c0010284904c05d492001504fb09072500010284d15005d4d3001134924c0134920001a4c00007648000d504bb0a0724c0010284904c05d492000504fb0b072500010284d15005d453000504fb0c072500010284d05005d413001294d2450764c0001740000411a4060005d41004a5d47f005104404401b48100010490480504fb0305fed20065d4bf0055fed2007504bb1407250001028493500504bb140504fb0d072500010284d25001b441440104104405047b0405fed00085d43f0055fed00095043b15072480010284114805047b150504bb0e072400010284914005d43f006264000001a407000104400405d4bf00615492440764800025d4bf00613492440764800025d43f007364000001b441000104504401a4810005e45200010440040504bb0605fed000c5fed100d5043b12072440010284124405043b1205047b0f072480010284504805d4110005047b120504bb100724c0010284914c05d45200112451040254110005d43f008364000006d61696e000000000000000000000248000000000000000800000000000000040000000000000250000000000000000a000000000000040000000000075bcd15000000000000007b0000000000000228' diff --git a/packages/abi-typegen/test/fixtures/templates/contract/factory.hbs b/packages/abi-typegen/test/fixtures/templates/contract/factory.hbs index a9888c5c65a..952e91c5f42 100644 --- a/packages/abi-typegen/test/fixtures/templates/contract/factory.hbs +++ b/packages/abi-typegen/test/fixtures/templates/contract/factory.hbs @@ -14,6 +14,7 @@ import type { Provider, Account, AbstractAddress, BytesLike, DeployContractOptio import type { MyContractAbi, MyContractAbiInterface } from "../MyContractAbi"; const _abi = { + "encoding": "1", "types": [ { "typeId": 0, 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 17dec7ee97a..45410e3e6cb 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 @@ -24,6 +24,7 @@ export type MyPredicateAbiConfigurables = { export type MyPredicateAbiInputs = [fee: BigNumberish, address: string]; const _abi = { + "encoding": "1", "types": [ { "typeId": 0, @@ -77,7 +78,7 @@ const _abi = { "type": 2, "typeArguments": null }, - "offset": 128 + "offset": 224 }, { "name": "ADDRESS", @@ -86,7 +87,7 @@ const _abi = { "type": 0, "typeArguments": null }, - "offset": 136 + "offset": 232 } ] } diff --git a/packages/abi-typegen/test/fixtures/templates/predicate/factory.hbs b/packages/abi-typegen/test/fixtures/templates/predicate/factory.hbs index c8d64a2851d..7d3e2c7f49a 100644 --- a/packages/abi-typegen/test/fixtures/templates/predicate/factory.hbs +++ b/packages/abi-typegen/test/fixtures/templates/predicate/factory.hbs @@ -26,6 +26,7 @@ export type MyPredicateAbiConfigurables = { export type MyPredicateAbiInputs = [received: ValidationInput]; const _abi = { + "encoding": "1", "types": [ { "typeId": 0, 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 7bf20ddf9f7..98ddb2a4d4c 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 @@ -26,6 +26,7 @@ export type MyScriptAbiConfigurables = { }; const _abi = { + "encoding": "1", "types": [ { "typeId": 0, @@ -85,7 +86,7 @@ const _abi = { "type": 0, "typeArguments": null }, - "offset": 44 + "offset": 156 } ] } diff --git a/packages/abi-typegen/test/fixtures/templates/script/factory.hbs b/packages/abi-typegen/test/fixtures/templates/script/factory.hbs index 0fb0d7c0e1b..9c15f1fe962 100644 --- a/packages/abi-typegen/test/fixtures/templates/script/factory.hbs +++ b/packages/abi-typegen/test/fixtures/templates/script/factory.hbs @@ -22,6 +22,7 @@ type MyScriptAbiInputs = [score: ScoreInput]; type MyScriptAbiOutput = boolean; const _abi = { + "encoding": "1", "types": [ { "typeId": 0, From 69fd3b2f25aa8d92145e9345918478207e49f9a9 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 16 Apr 2024 09:52:47 +0100 Subject: [PATCH 43/92] test: update tx id for new encoding --- .../src/guide/transactions/transaction-request.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 091f1fab851..6d99dab41b2 100644 --- a/apps/docs-snippets/src/guide/transactions/transaction-request.test.ts +++ b/apps/docs-snippets/src/guide/transactions/transaction-request.test.ts @@ -193,7 +193,7 @@ describe('Transaction Request', () => { // #endregion transaction-request-7 expect(transactionId).toBe( - '0x35cd6a10e917d5d0223413c1fb9863d27da40e5d602a7f37cfbcefb570172f6c' + '0x9af26316ce821f76da2c013af899fe2be5cbc1edfa08e5c7d6b39e3c74d024fd' ); }); }); From 68946e8bfd1261ef3e8e356233220ad7770c880b Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 16 Apr 2024 11:20:38 +0100 Subject: [PATCH 44/92] feat: enable vector tests --- packages/errors/src/fuel-error.ts | 2 +- packages/fuel-gauge/src/vectors.test.ts | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/errors/src/fuel-error.ts b/packages/errors/src/fuel-error.ts index 1d8dec81f2b..6e7db136e40 100644 --- a/packages/errors/src/fuel-error.ts +++ b/packages/errors/src/fuel-error.ts @@ -36,7 +36,7 @@ export class FuelError extends Error { super(message); this.code = code; this.name = 'FuelError'; - this.metadata = metadata; + this.metadata = {}; } toObject() { diff --git a/packages/fuel-gauge/src/vectors.test.ts b/packages/fuel-gauge/src/vectors.test.ts index 64bbed42a8f..e0d13814f0c 100644 --- a/packages/fuel-gauge/src/vectors.test.ts +++ b/packages/fuel-gauge/src/vectors.test.ts @@ -255,12 +255,12 @@ describe('Vector Tests', () => { it('should test Option vector input/output', async () => { const INPUT = [undefined, 1, undefined, 2, undefined, 3]; - const { value } = await contractInstance.functions.echo_option_u8(INPUT).call(); + const { value } = await contractInstance.functions.echo_option_u8(INPUT).call(); expect(value).toStrictEqual(INPUT); }); - it.skip('should test Vec inside struct input/output', async () => { + it('should test Vec inside struct input/output', async () => { const INPUT = { num: 2, vec: [1, 5, 98], @@ -271,7 +271,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test Vec inside enum input/output', async () => { + it('should test Vec inside enum input/output', async () => { const INPUT = { vec: [1, 5, 98], }; @@ -289,11 +289,12 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test struct and Vec input/output', async () => { - const INPUT = [ + it('should test struct and Vec input/output', async () => { + type Struct = { foo: number; bar: BN; baz: string }; + const INPUT: [Struct, number[]] = [ { foo: 1, - bar: 10000000, + bar: bn(10000000), baz: 'abc123456', }, [1, 4], @@ -303,10 +304,13 @@ describe('Vector Tests', () => { .echo_struct_and_vector_tuple(INPUT[0], INPUT[1]) .call(); - expect(value).toStrictEqual(INPUT); + expect(value[0].foo).toStrictEqual(INPUT[0].foo); + expect(value[0].bar.toNumber()).toStrictEqual(INPUT[0].bar.toNumber()); + expect(value[0].baz).toStrictEqual(INPUT[0].baz); + expect(value[1]).toStrictEqual(INPUT[1]); }); - it.skip('should test Vec and b256 tuple input/output', async () => { + it('should test Vec and b256 tuple input/output', async () => { const INPUT = [[1, 8, 3, 2, 55, 215], hexlify(randomBytes(32))]; const { value } = await contractInstance.functions.echo_vector_and_b256_tuple(...INPUT).call(); @@ -314,7 +318,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test two vectors tuple input/output', async () => { + it('should test two vectors tuple input/output', async () => { const INPUT = [ [219, 229], [1, 254, 55], @@ -325,7 +329,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test u32 and three different vectors tuple input/output', async () => { + it('should test u32 and three different vectors tuple input/output', async () => { const INPUT = [91000, [true, true, false], [95000, 153333], [20000, 65500]]; const { value } = await contractInstance.functions.echo_u32_then_three_vectors(...INPUT).call(); From 654c1e3b1c561d75e189f44fdbc69b9fae3969ae Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 16 Apr 2024 13:37:37 +0100 Subject: [PATCH 45/92] test: adjust call params gas limits --- .../docs-snippets/src/guide/contracts/call-parameters.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/docs-snippets/src/guide/contracts/call-parameters.test.ts b/apps/docs-snippets/src/guide/contracts/call-parameters.test.ts index 8ce6c7e7623..d2987cdb3e6 100644 --- a/apps/docs-snippets/src/guide/contracts/call-parameters.test.ts +++ b/apps/docs-snippets/src/guide/contracts/call-parameters.test.ts @@ -51,8 +51,8 @@ describe(__filename, () => { // #region call-params-3 const { minGasPrice } = provider.getGasConfig(); const amountToForward = 10; - const contractCallGasLimit = 100; - const transactionGasLimit = 3_000_000; + const contractCallGasLimit = 1000; + const transactionGasLimit = 100_000; const result = await contract.functions .return_context_amount() From b9c16211e14f3a33363c8d73512664d5a509dc85 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 16 Apr 2024 14:21:34 +0100 Subject: [PATCH 46/92] chore: use call in std string lib tests --- apps/docs-snippets/src/guide/types/std-string.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/docs-snippets/src/guide/types/std-string.test.ts b/apps/docs-snippets/src/guide/types/std-string.test.ts index 51fea1d3505..889673e684f 100644 --- a/apps/docs-snippets/src/guide/types/std-string.test.ts +++ b/apps/docs-snippets/src/guide/types/std-string.test.ts @@ -19,7 +19,7 @@ describe('StdString', () => { const stdString: StdString = 'Hello World'; - const { value } = await contract.functions.string_comparison(stdString).simulate(); + const { value } = await contract.functions.string_comparison(stdString).call(); expect(value).toBeTruthy(); // #endregion std-string-1 @@ -31,7 +31,7 @@ describe('StdString', () => { const stdString: StdString = 'Hello Fuel'; - const { value } = await contract.functions.echo_string(stdString).simulate(); + const { value } = await contract.functions.echo_string(stdString).call(); expect(value).toEqual(stdString); // #endregion std-string-2 From 9eadc6a8b6289fea754878126cb154ef6e466c12 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Tue, 16 Apr 2024 12:00:19 -0300 Subject: [PATCH 47/92] Re-generating changeset --- .changeset/gentle-cherries-reply.md | 15 --------------- .changeset/ninety-hotels-impress.md | 9 +++++++++ 2 files changed, 9 insertions(+), 15 deletions(-) delete mode 100644 .changeset/gentle-cherries-reply.md create mode 100644 .changeset/ninety-hotels-impress.md diff --git a/.changeset/gentle-cherries-reply.md b/.changeset/gentle-cherries-reply.md deleted file mode 100644 index 48a8cf4b735..00000000000 --- a/.changeset/gentle-cherries-reply.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -"create-fuels": minor -"@fuel-ts/abi-typegen": minor -"@fuel-ts/interfaces": minor -"@fuel-ts/abi-coder": minor -"@fuel-ts/versions": minor -"@fuel-ts/account": minor -"@fuel-ts/address": minor -"@fuel-ts/program": minor -"@fuel-ts/errors": minor -"@fuel-ts/forc": minor -"@fuel-ts/math": minor ---- - -chore!: upgrading `forc` to `0.53.0` diff --git a/.changeset/ninety-hotels-impress.md b/.changeset/ninety-hotels-impress.md new file mode 100644 index 00000000000..d23f1129a8d --- /dev/null +++ b/.changeset/ninety-hotels-impress.md @@ -0,0 +1,9 @@ +--- +"@fuel-ts/abi-typegen": patch +"@fuel-ts/interfaces": patch +"@fuel-ts/versions": patch +"@fuel-ts/address": patch +"@fuel-ts/forc": patch +--- + +chore!: upgrading `forc` to `0.53.0` From 2bce803b0e2dc54ee6581e5d331ac0f0fc7c3cbd Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Wed, 17 Apr 2024 16:27:52 +0100 Subject: [PATCH 48/92] chore: linting --- packages/errors/src/fuel-error.ts | 2 +- packages/fuel-gauge/src/script-with-configurable.test.ts | 2 +- packages/fuel-gauge/src/script-with-vectors.test.ts | 2 +- packages/program/src/contract-call-script.ts | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/errors/src/fuel-error.ts b/packages/errors/src/fuel-error.ts index 6e7db136e40..1d8dec81f2b 100644 --- a/packages/errors/src/fuel-error.ts +++ b/packages/errors/src/fuel-error.ts @@ -36,7 +36,7 @@ export class FuelError extends Error { super(message); this.code = code; this.name = 'FuelError'; - this.metadata = {}; + this.metadata = metadata; } toObject() { diff --git a/packages/fuel-gauge/src/script-with-configurable.test.ts b/packages/fuel-gauge/src/script-with-configurable.test.ts index b54574b787a..ddc820f432f 100644 --- a/packages/fuel-gauge/src/script-with-configurable.test.ts +++ b/packages/fuel-gauge/src/script-with-configurable.test.ts @@ -1,6 +1,6 @@ import { generateTestWallet } from '@fuel-ts/account/test-utils'; import type { CoinQuantityLike, WalletUnlocked } from 'fuels'; -import { Script, BaseAssetId, Provider, FUEL_NETWORK_URL } from 'fuels'; +import { Script, BaseAssetId, Provider, FUEL_NETWORK_URL } from 'fuels'; import { FuelGaugeProjectsEnum, getFuelGaugeForcProject } from '../test/fixtures'; diff --git a/packages/fuel-gauge/src/script-with-vectors.test.ts b/packages/fuel-gauge/src/script-with-vectors.test.ts index 214d20f87d6..fc8a87c057d 100644 --- a/packages/fuel-gauge/src/script-with-vectors.test.ts +++ b/packages/fuel-gauge/src/script-with-vectors.test.ts @@ -1,5 +1,5 @@ import { generateTestWallet } from '@fuel-ts/account/test-utils'; -import type { BigNumberish, BN } from 'fuels'; +import type { BigNumberish } from 'fuels'; import { BaseAssetId, FUEL_NETWORK_URL, Provider } from 'fuels'; import { getScript } from './utils'; diff --git a/packages/program/src/contract-call-script.ts b/packages/program/src/contract-call-script.ts index 94a433d0dbe..76120a1a2af 100644 --- a/packages/program/src/contract-call-script.ts +++ b/packages/program/src/contract-call-script.ts @@ -21,7 +21,6 @@ import { bn, toNumber } from '@fuel-ts/math'; import { ReceiptType } from '@fuel-ts/transactions'; import { concat, arrayify } from '@fuel-ts/utils'; import * as asm from '@fuels/vm-asm'; -import { a } from 'vitest/dist/suite-MFRDkZcV'; import { InstructionSet } from './instruction-set'; import type { EncodedScriptCall, ScriptResult } from './script-request'; From 5bda0c4c2a9af4c4cf037faecd01d7a76918c5ce Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Wed, 17 Apr 2024 16:34:47 +0100 Subject: [PATCH 49/92] feat: use correct number type in script demo test --- apps/demo-typegen/src/demo.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/demo-typegen/src/demo.test.ts b/apps/demo-typegen/src/demo.test.ts index 320c65bc6aa..aca9b1eaf16 100644 --- a/apps/demo-typegen/src/demo.test.ts +++ b/apps/demo-typegen/src/demo.test.ts @@ -127,8 +127,7 @@ test('Example script', async () => { const script = ScriptAbi__factory.createInstance(wallet); const { value } = await script.functions.main().call(); // #endregion typegen-demo-script - // @ts-expect-error TODO: investitage - typegen is expecting value to be a number but the value being returned is the string '0xa' - expect(value.toNumber()).toBe(10); + expect(value).toBe(10); }); test('Example predicate', async () => { From bb691e3b1c214ee964212a090721c71a217f2b0a Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 18 Apr 2024 15:27:39 +0100 Subject: [PATCH 50/92] docs: pinned version of fuels for `beta-5` docs --- apps/docs/src/creating-a-fuel-dapp.md | 4 ++-- apps/docs/src/getting-started.md | 6 ++++-- apps/docs/src/guide/fuels/binaries.md | 12 +++++------ apps/docs/src/guide/fuels/commands.md | 20 +++++++++---------- apps/docs/src/guide/fuels/index.md | 6 +++--- apps/docs/src/guide/npm-create-fuels/index.md | 4 ++-- .../src/guide/npm-create-fuels/options.md | 4 ++-- .../src/guide/typegen/generating-types.md | 2 +- apps/docs/src/index.md | 4 ++-- 9 files changed, 32 insertions(+), 30 deletions(-) diff --git a/apps/docs/src/creating-a-fuel-dapp.md b/apps/docs/src/creating-a-fuel-dapp.md index 32e1de5c749..5babcc15f87 100644 --- a/apps/docs/src/creating-a-fuel-dapp.md +++ b/apps/docs/src/creating-a-fuel-dapp.md @@ -11,11 +11,11 @@ The first step is to run the command: ::: code-group ```sh [npm] -npm create fuels +npm create fuels@0.81.0 ``` ```sh [pnpm] -pnpm create fuels +pnpm create fuels@0.81.0 ``` ::: diff --git a/apps/docs/src/getting-started.md b/apps/docs/src/getting-started.md index 851f68e8caf..4e32b6f5d2e 100644 --- a/apps/docs/src/getting-started.md +++ b/apps/docs/src/getting-started.md @@ -14,15 +14,17 @@ To begin, you need to add the `fuels` dependency to your project. You can do thi ::: code-group ```sh [npm] -npm install fuels --save +npm install fuels@0.81.0 --save ``` ```sh [pnpm] -pnpm add fuels +pnpm add fuels@0.81.0 ``` ::: +> **Note**: We use the `0.81.0` to ensure compatibility with out latest testnet + ### Note If you are using bun, you'll need to add a `trustedDependencies` field to your `package.json`: diff --git a/apps/docs/src/guide/fuels/binaries.md b/apps/docs/src/guide/fuels/binaries.md index b7fa0f07d26..9766978f04b 100644 --- a/apps/docs/src/guide/fuels/binaries.md +++ b/apps/docs/src/guide/fuels/binaries.md @@ -14,15 +14,15 @@ Here's how to configure this explicitly: You can also call the `built-in` binaries directly: ```console -npx fuels help forc -npx fuels forc --version -npx fuels forc test -h +npx fuels@0.81.0 help forc +npx fuels@0.81.0 forc --version +npx fuels@0.81.0 forc test -h ``` ```console -npx fuels help core -npx fuels core --version -npx fuels core run -h +npx fuels@0.81.0 help core +npx fuels@0.81.0 core --version +npx fuels@0.81.0 core run -h ``` Check the docs for `forc` and `fuel-core`: diff --git a/apps/docs/src/guide/fuels/commands.md b/apps/docs/src/guide/fuels/commands.md index 8a2bc50a288..80f2affa90b 100644 --- a/apps/docs/src/guide/fuels/commands.md +++ b/apps/docs/src/guide/fuels/commands.md @@ -5,7 +5,7 @@ The `fuels` CLI consists of a couple commands. ## `fuels init` ```console -npx fuels help init +npx fuels@0.81.0 help init ``` ```console @@ -20,13 +20,13 @@ Options: Creating a sample `fuel.config.ts` file: ```console -npx fuels init --contracts ./my-contracts/* --output ./src/sway-contracts-api +npx fuels@0.81.0 init --contracts ./my-contracts/* --output ./src/sway-contracts-api ``` Using [Forc workspaces](https://docs.fuel.network/docs/forc/workspaces/)? Try this instead: ```console -npx fuels init --workspace ./sway-programs --output ./src/sway-programs-api +npx fuels@0.81.0 init --workspace ./sway-programs --output ./src/sway-programs-api ``` This will give you a minimal configuration: @@ -51,7 +51,7 @@ In a nutshell: ## `fuels build` ```console -npx fuels help build +npx fuels@0.81.0 help build ``` ```console @@ -64,14 +64,14 @@ Options: Examples: ```console -npx fuels build +npx fuels@0.81.0 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) ```console -npx fuels build --deploy +npx fuels@0.81.0 build --deploy ``` Using the `--deploy` flag will additionally: @@ -84,7 +84,7 @@ Using the `--deploy` flag will additionally: ## `fuels deploy` ```console -npx fuels deploy +npx fuels@0.81.0 deploy ``` 1. Deploy all Sway contracts under `workspace` @@ -109,7 +109,7 @@ For a complete example, see: ## `fuels dev` ```console -npx fuels dev +npx fuels@0.81.0 dev ``` The `fuels dev` command do three things: @@ -125,7 +125,7 @@ The `fuels dev` command do three things: Manually generates type definitions and factory classes from ABI JSON files. ```console -npx fuels help typegen +npx fuels@0.81.0 help typegen ``` ```console @@ -147,7 +147,7 @@ For more info, check: 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. ```console -npx fuels versions +npx fuels@0.81.0 versions ``` ``` diff --git a/apps/docs/src/guide/fuels/index.md b/apps/docs/src/guide/fuels/index.md index 96e09c32b4d..04e00687dff 100644 --- a/apps/docs/src/guide/fuels/index.md +++ b/apps/docs/src/guide/fuels/index.md @@ -33,11 +33,11 @@ Add it to your `my-fuel-dapp` project: ::: code-group ```console [npm] -npm install fuels --save +npm install fuels@0.81.0 --save ``` ```console [pnpm] -pnpm add fuels +pnpm add fuels@0.81.0 ``` ::: @@ -45,7 +45,7 @@ pnpm add fuels ## Double-checking ```console -npx fuels -v +npx fuels@0.81.0 -v ``` ## Next Step diff --git a/apps/docs/src/guide/npm-create-fuels/index.md b/apps/docs/src/guide/npm-create-fuels/index.md index 1e2e63918a1..13ee0f6f841 100644 --- a/apps/docs/src/guide/npm-create-fuels/index.md +++ b/apps/docs/src/guide/npm-create-fuels/index.md @@ -9,11 +9,11 @@ Run the following command in your terminal to get started: ::: code-group ```sh [npm] -npm create fuels +npm create fuels@0.81.0 ``` ```sh [pnpm] -pnpm create fuels +pnpm create fuels@0.81.0 ``` ::: diff --git a/apps/docs/src/guide/npm-create-fuels/options.md b/apps/docs/src/guide/npm-create-fuels/options.md index 4f508d432b6..0dedadd89db 100644 --- a/apps/docs/src/guide/npm-create-fuels/options.md +++ b/apps/docs/src/guide/npm-create-fuels/options.md @@ -5,11 +5,11 @@ The `npm create fuels` command has several command-line options that you can use ::: code-group ```sh [pnpm] -pnpm create fuels [project-name] [options] +pnpm create fuels@0.81.0 [project-name] [options] ``` ```sh [npm] -npm create fuels [project-name] [options] +npm create fuels@0.81.0 [project-name] [options] ``` ::: diff --git a/apps/docs/src/guide/typegen/generating-types.md b/apps/docs/src/guide/typegen/generating-types.md index bd507c2cc91..9d9b9656fef 100644 --- a/apps/docs/src/guide/typegen/generating-types.md +++ b/apps/docs/src/guide/typegen/generating-types.md @@ -5,7 +5,7 @@ First we install `fuels` to our project: ```console -pnpm add fuels +pnpm add fuels@0.81.0 ``` ## Help diff --git a/apps/docs/src/index.md b/apps/docs/src/index.md index 2b1fbced0eb..5192fdfaa5a 100644 --- a/apps/docs/src/index.md +++ b/apps/docs/src/index.md @@ -37,11 +37,11 @@ Learn more about the Fuel Ecosystem. ::: code-group ```sh [pnpm] -pnpm add fuels +pnpm add fuels@0.81.0 ``` ```sh [npm] -npm install fuels --save +npm install fuels@0.81.0 --save ``` ::: From d19a3de98c6f72a42666f8d24fadb4ecb8b99b91 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 18 Apr 2024 15:32:08 +0100 Subject: [PATCH 51/92] chore: added changeset --- .changeset/sixty-actors-rescue.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changeset/sixty-actors-rescue.md diff --git a/.changeset/sixty-actors-rescue.md b/.changeset/sixty-actors-rescue.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/sixty-actors-rescue.md @@ -0,0 +1,2 @@ +--- +--- From 0ff874317c239d8e4055a5aec711e4992c9f3d06 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 18 Apr 2024 15:34:21 +0100 Subject: [PATCH 52/92] chore: added fuelsVersion to create-fuels --- packages/create-fuels/scripts/rewriteTemplatePackageJson.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts b/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts index 9acff7a1975..608e3730517 100644 --- a/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts +++ b/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts @@ -2,12 +2,13 @@ import { versions } from '@fuel-ts/versions'; import { readFileSync, writeFileSync } from 'fs'; import { join } from 'path'; +const fuelsVersion = versions.FUELS 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}"`); +contents = contents.replace(/"fuels": "workspace:\*"/, `"fuels": "${fuelsVersion}"`); contents = contents.replace(/"build": "pnpm run prebuild && next build"/, `"build": "next build"`); writeFileSync(filepath, contents); From 7b58accc328586bcd588e59f8d5372e8d9325e17 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 18 Apr 2024 15:34:59 +0100 Subject: [PATCH 53/92] chore: pinned back the create-fuels version to 0.81.0 --- packages/create-fuels/scripts/rewriteTemplatePackageJson.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts b/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts index 608e3730517..e826b80dffa 100644 --- a/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts +++ b/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts @@ -2,7 +2,7 @@ import { versions } from '@fuel-ts/versions'; import { readFileSync, writeFileSync } from 'fs'; import { join } from 'path'; -const fuelsVersion = versions.FUELS +const fuelsVersion = "0.81.0"; const filepath = join(__dirname, '../templates/nextjs/package.json'); let contents = readFileSync(filepath, 'utf-8'); From 4a4f3e6d467adc736c7dfb3eec30bcbefed6e4a8 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 18 Apr 2024 15:40:11 +0100 Subject: [PATCH 54/92] fix spelling --- apps/docs/src/guide/fuels/commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/src/guide/fuels/commands.md b/apps/docs/src/guide/fuels/commands.md index 80f2affa90b..07d1f144895 100644 --- a/apps/docs/src/guide/fuels/commands.md +++ b/apps/docs/src/guide/fuels/commands.md @@ -118,7 +118,7 @@ The `fuels dev` command do three things: 1. Runs `build` and `deploy` once at the start 1. Watches your Forc workspace and repeats 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._ +> _In `dev` mode, every time 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._ ## `fuels typegen` From 35f52c8ddba7223ae952024231460fea0be4a628 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 18 Apr 2024 17:05:20 +0100 Subject: [PATCH 55/92] chore: lint --- packages/create-fuels/scripts/rewriteTemplatePackageJson.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts b/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts index e826b80dffa..0da3f3bd930 100644 --- a/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts +++ b/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts @@ -1,4 +1,3 @@ -import { versions } from '@fuel-ts/versions'; import { readFileSync, writeFileSync } from 'fs'; import { join } from 'path'; From 99b93b1b27d9fbf1562c1dc1b910373dd7501968 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 18 Apr 2024 17:12:16 +0100 Subject: [PATCH 56/92] chore: lint :'( --- packages/create-fuels/scripts/rewriteTemplatePackageJson.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts b/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts index 0da3f3bd930..4bfa0b405b9 100644 --- a/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts +++ b/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts @@ -1,7 +1,7 @@ import { readFileSync, writeFileSync } from 'fs'; import { join } from 'path'; -const fuelsVersion = "0.81.0"; +const fuelsVersion = '0.81.0'; const filepath = join(__dirname, '../templates/nextjs/package.json'); let contents = readFileSync(filepath, 'utf-8'); From 20a48754b442966d12856876c4726d83aa09555f Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Apr 2024 10:30:38 +0100 Subject: [PATCH 57/92] test: skip failing tests to do with gas, arithemtic overflow and abi coder compilation --- .../src/guide/types/std-string.test.ts | 2 +- packages/abi-coder/test/Interface.test.ts | 2 +- packages/fuel-gauge/src/bytes.test.ts | 4 ++-- .../fuel-gauge/src/coverage-contract.test.ts | 2 +- packages/fuel-gauge/src/std-lib-string.test.ts | 2 +- packages/fuel-gauge/src/vectors.test.ts | 18 +++++++++--------- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/docs-snippets/src/guide/types/std-string.test.ts b/apps/docs-snippets/src/guide/types/std-string.test.ts index 889673e684f..b585b2a077c 100644 --- a/apps/docs-snippets/src/guide/types/std-string.test.ts +++ b/apps/docs-snippets/src/guide/types/std-string.test.ts @@ -25,7 +25,7 @@ describe('StdString', () => { // #endregion std-string-1 }); - it('should retrieve a std string from a contract', async () => { + it.skip('should retrieve a std string from a contract', async () => { // #region std-string-2 // #import { StdString }; diff --git a/packages/abi-coder/test/Interface.test.ts b/packages/abi-coder/test/Interface.test.ts index 7dd7bfbdf1d..3f5cdb95c9b 100644 --- a/packages/abi-coder/test/Interface.test.ts +++ b/packages/abi-coder/test/Interface.test.ts @@ -53,7 +53,7 @@ const exhaustiveExamplesInterface = new Interface(exhaustiveExamplesAbi); /** * @group node */ -describe('Abi interface', () => { +describe.skip('Abi interface', () => { it('can retrieve a function fragment', () => { const fn = exhaustiveExamplesInterface.functions.entry_one; diff --git a/packages/fuel-gauge/src/bytes.test.ts b/packages/fuel-gauge/src/bytes.test.ts index eb0d3165ea2..d1edd67cb5d 100644 --- a/packages/fuel-gauge/src/bytes.test.ts +++ b/packages/fuel-gauge/src/bytes.test.ts @@ -40,7 +40,7 @@ describe('Bytes Tests', () => { ({ minGasPrice: gasPrice } = provider.getGasConfig()); }); - it('should test bytes output', async () => { + it.skip('should test bytes output', async () => { const INPUT = 10; const { value } = await contractInstance.functions.return_bytes(INPUT).call(); @@ -48,7 +48,7 @@ describe('Bytes Tests', () => { expect(value).toStrictEqual(new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])); }); - it('should test bytes output [100 items]', async () => { + it.skip('should test bytes output [100 items]', async () => { const INPUT = 100; const { value } = await contractInstance.functions.return_bytes(INPUT).call(); diff --git a/packages/fuel-gauge/src/coverage-contract.test.ts b/packages/fuel-gauge/src/coverage-contract.test.ts index 084d6f70cd5..9972c42a094 100644 --- a/packages/fuel-gauge/src/coverage-contract.test.ts +++ b/packages/fuel-gauge/src/coverage-contract.test.ts @@ -590,7 +590,7 @@ describe('Coverage Contract', () => { expect(1).toEqual(1); }); - it('should test b256 multiple params vector input/output', async () => { + it.skip('should test b256 multiple params vector input/output', async () => { const INPUT_A = [hexlify(randomBytes(32)), hexlify(randomBytes(32)), hexlify(randomBytes(32))]; const INPUT_B = [hexlify(randomBytes(32)), hexlify(randomBytes(32)), hexlify(randomBytes(32))]; const INPUT_C = hexlify(randomBytes(32)); diff --git a/packages/fuel-gauge/src/std-lib-string.test.ts b/packages/fuel-gauge/src/std-lib-string.test.ts index 3d7a83e717c..2364e265808 100644 --- a/packages/fuel-gauge/src/std-lib-string.test.ts +++ b/packages/fuel-gauge/src/std-lib-string.test.ts @@ -31,7 +31,7 @@ describe('std-lib-string Tests', () => { const { binHexlified: predicateStdString, abiContents: predicateStdStringAbi } = getFuelGaugeForcProject(FuelGaugeProjectsEnum.PREDICATE_STD_LIB_STRING); - it('should test std-lib-string return', async () => { + it.skip('should test std-lib-string return', async () => { const { value } = await contractInstance.functions.return_dynamic_string().call(); expect(value).toBe('Hello World'); }); diff --git a/packages/fuel-gauge/src/vectors.test.ts b/packages/fuel-gauge/src/vectors.test.ts index e0d13814f0c..e46ad56ee14 100644 --- a/packages/fuel-gauge/src/vectors.test.ts +++ b/packages/fuel-gauge/src/vectors.test.ts @@ -27,7 +27,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it('should test u16 vector input/output', async () => { + it.skip('should test u16 vector input/output', async () => { const INPUT = [8, 6, 7, 5, 3, 0, 9]; const { value } = await contractInstance.functions.echo_u16(INPUT).call(); @@ -35,7 +35,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it('should test u32 vector input/output', async () => { + it.skip('should test u32 vector input/output', async () => { const INPUT = [8, 6, 7, 5, 3, 0, 9]; const { value } = await contractInstance.functions.echo_u32(INPUT).call(); @@ -59,7 +59,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it('should test b256 vector input/output', async () => { + it.skip('should test b256 vector input/output', async () => { const INPUT = [hexlify(randomBytes(32)), hexlify(randomBytes(32)), hexlify(randomBytes(32))]; const { value } = await contractInstance.functions.echo_b256(INPUT).call(); @@ -67,7 +67,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it('should test b512 vector input/output', async () => { + it.skip('should test b512 vector input/output', async () => { const INPUT = [hexlify(randomBytes(64)), hexlify(randomBytes(64)), hexlify(randomBytes(64))]; const { value } = await contractInstance.functions.echo_b512(INPUT).call(); @@ -83,7 +83,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it('should test str[9] vector input/output', async () => { + it.skip('should test str[9] vector input/output', async () => { const INPUT = ['123456789', 'abcdefghi', 'catdogcat', 'onetwoone']; const { value } = await contractInstance.functions.echo_str_9(INPUT).call(); @@ -138,7 +138,7 @@ describe('Vector Tests', () => { expect(value.map((nums: BN[]) => toNumbers(nums))).toStrictEqual(INPUT); }); - it('should test [bool; 2] vector input/output', async () => { + it.skip('should test [bool; 2] vector input/output', async () => { const INPUT = [ [true, true], [true, false], @@ -170,7 +170,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it('should test B256Struct vector input/output', async () => { + it.skip('should test B256Struct vector input/output', async () => { const INPUT = [ { i: hexlify(randomBytes(32)), @@ -188,7 +188,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it('should test ComplexStruct vector input/output', async () => { + it.skip('should test ComplexStruct vector input/output', async () => { type ComplexStruct = { foo: number; bar: BN; baz: string }; const INPUT = [ { @@ -234,7 +234,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it('should test BigEnum vector input/output', async () => { + it.skip('should test BigEnum vector input/output', async () => { const INPUT = [ { AddressA: hexlify(randomBytes(32)), From 7508d6d5117a5d1e42a060be98eb4fa2f7e62497 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Fri, 19 Apr 2024 10:31:08 +0100 Subject: [PATCH 58/92] Fix spelling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Nedim Salkić --- apps/docs/src/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/src/getting-started.md b/apps/docs/src/getting-started.md index 4e32b6f5d2e..d20f39bcf7e 100644 --- a/apps/docs/src/getting-started.md +++ b/apps/docs/src/getting-started.md @@ -23,7 +23,7 @@ pnpm add fuels@0.81.0 ::: -> **Note**: We use the `0.81.0` to ensure compatibility with out latest testnet +**Note**: We use `0.81.0` to ensure compatibility with our latest testnet ### Note From 31f710e548f9e550db88cb570a0e5eb558a5fcad Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Apr 2024 10:50:49 +0100 Subject: [PATCH 59/92] chore: upgrade reentrant test to `forc@0.53.0` (#2121) * chore: upgrade forc version in reentrant test * chore: changeset --- .changeset/friendly-peaches-change.md | 2 ++ packages/fuel-gauge/src/reentrant-contract-calls.test.ts | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 .changeset/friendly-peaches-change.md diff --git a/.changeset/friendly-peaches-change.md b/.changeset/friendly-peaches-change.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/friendly-peaches-change.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/fuel-gauge/src/reentrant-contract-calls.test.ts b/packages/fuel-gauge/src/reentrant-contract-calls.test.ts index 62d9ca27534..39419280911 100644 --- a/packages/fuel-gauge/src/reentrant-contract-calls.test.ts +++ b/packages/fuel-gauge/src/reentrant-contract-calls.test.ts @@ -32,7 +32,7 @@ describe('Reentrant Contract Calls', () => { value, transactionResult: { receipts }, } = await fooContract.functions - .foo({ value: fooContract.id.toB256() }, { value: barContract.id.toB256() }) + .foo({ bits: fooContract.id.toB256() }, { bits: barContract.id.toB256() }) .addContracts([barContract]) .call(); @@ -69,8 +69,8 @@ describe('Reentrant Contract Calls', () => { ).deployContract({ storageSlots: storageTest.storageSlots }); const reentrantCall = fooContract.functions.foo( - { value: fooContract.id.toB256() }, - { value: barContract.id.toB256() } + { bits: fooContract.id.toB256() }, + { bits: barContract.id.toB256() } ); const result = await fooContract From 9a948041221fdaa24abef4e31f7417901ff2970f Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Apr 2024 11:17:08 +0100 Subject: [PATCH 60/92] chore: update reentrant call test to check for return data reciept --- packages/fuel-gauge/src/reentrant-contract-calls.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fuel-gauge/src/reentrant-contract-calls.test.ts b/packages/fuel-gauge/src/reentrant-contract-calls.test.ts index 39419280911..39d19510988 100644 --- a/packages/fuel-gauge/src/reentrant-contract-calls.test.ts +++ b/packages/fuel-gauge/src/reentrant-contract-calls.test.ts @@ -54,7 +54,7 @@ describe('Reentrant Contract Calls', () => { * number 42 (from `Foo.foo`) instead of 1337 (from `Foo.baz`). */ const returnReceipts = receipts.filter( - (r) => r.type === ReceiptType.Return && r.id === fooContract.id.toB256() + (r) => r.type === ReceiptType.ReturnData && r.id === fooContract.id.toB256() ); expect(value.toNumber()).toBe(42); From 11fb6172fa81109a346947695fabeb4c08b69e71 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Apr 2024 16:16:55 +0100 Subject: [PATCH 61/92] feat: correctly set heap registers and return data for v1 heaps --- packages/program/src/contract-call-script.ts | 8 +++++++- packages/program/src/functions/invocation-results.ts | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/program/src/contract-call-script.ts b/packages/program/src/contract-call-script.ts index 76120a1a2af..3e45b9c0de2 100644 --- a/packages/program/src/contract-call-script.ts +++ b/packages/program/src/contract-call-script.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ +import type { EncodingVersion } from '@fuel-ts/abi-coder'; import { WORD_SIZE, B256Coder, @@ -6,6 +7,7 @@ import { BigNumberCoder, CONTRACT_ID_LEN, ENCODING_V1, + ENCODING_V0, } from '@fuel-ts/abi-coder'; import type { CallResult, @@ -42,6 +44,7 @@ type CallOpcodeParamsOffset = { type CallOutputInfo = { isHeap: boolean; encodedLength: number; + encoding: EncodingVersion; }; type ContractCallScriptFn = ( @@ -90,7 +93,7 @@ const getSingleCallInstructions = ( inst.push(asm.call(0x10, 0x11, 0x12, asm.RegId.cgas().to_u8())); } - if (outputInfo.isHeap) { + if (outputInfo.encoding === ENCODING_V0 && outputInfo.isHeap) { inst.extend([ // The RET register contains the pointer address of the `CALL` return (a stack // address). @@ -198,6 +201,7 @@ const getCallInstructionsLength = (contractCalls: ContractCall[]): number => const output: CallOutputInfo = { isHeap: call.isOutputDataHeap, encodedLength: call.outputEncodedLength, + encoding: call.encoding ?? ENCODING_V0, }; return sum + getSingleCallInstructions(offset, output).byteLength(); }, @@ -210,6 +214,7 @@ const getFunctionOutputInfos = (functionScopes: InvocationScopeLike[]): CallOutp return { isHeap: func.outputMetadata.isHeapType, encodedLength: func.outputMetadata.encodedLength, + encoding: func.encoding, }; }); @@ -379,6 +384,7 @@ export const getContractCallScript = ( outputInfos.push({ isHeap: call.isOutputDataHeap, encodedLength: call.outputEncodedLength, + encoding: call.encoding ?? ENCODING_V0, }); scriptData.push(concat(callScriptData)); paramOffsets.push(callParamOffsets); diff --git a/packages/program/src/functions/invocation-results.ts b/packages/program/src/functions/invocation-results.ts index 01fc2e13e17..64b94e765bb 100644 --- a/packages/program/src/functions/invocation-results.ts +++ b/packages/program/src/functions/invocation-results.ts @@ -1,5 +1,6 @@ /* 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, @@ -97,10 +98,14 @@ 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, - callConfig?.func.outputMetadata.isHeapType || false, + outputAsIterableHeap, logs ); const returnValues = encodedResults.map((encodedResult, i) => { From 6eaa17ec7330165305fc4fae3ee2a0712599fc19 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Apr 2024 16:17:05 +0100 Subject: [PATCH 62/92] Revert "test: skip failing tests to do with gas, arithemtic overflow and abi coder compilation" This reverts commit 20a48754b442966d12856876c4726d83aa09555f. --- .../src/guide/types/std-string.test.ts | 2 +- packages/abi-coder/test/Interface.test.ts | 2 +- packages/fuel-gauge/src/bytes.test.ts | 4 ++-- .../fuel-gauge/src/coverage-contract.test.ts | 2 +- packages/fuel-gauge/src/std-lib-string.test.ts | 2 +- packages/fuel-gauge/src/vectors.test.ts | 18 +++++++++--------- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/docs-snippets/src/guide/types/std-string.test.ts b/apps/docs-snippets/src/guide/types/std-string.test.ts index b585b2a077c..889673e684f 100644 --- a/apps/docs-snippets/src/guide/types/std-string.test.ts +++ b/apps/docs-snippets/src/guide/types/std-string.test.ts @@ -25,7 +25,7 @@ describe('StdString', () => { // #endregion std-string-1 }); - it.skip('should retrieve a std string from a contract', async () => { + it('should retrieve a std string from a contract', async () => { // #region std-string-2 // #import { StdString }; diff --git a/packages/abi-coder/test/Interface.test.ts b/packages/abi-coder/test/Interface.test.ts index 3f5cdb95c9b..7dd7bfbdf1d 100644 --- a/packages/abi-coder/test/Interface.test.ts +++ b/packages/abi-coder/test/Interface.test.ts @@ -53,7 +53,7 @@ const exhaustiveExamplesInterface = new Interface(exhaustiveExamplesAbi); /** * @group node */ -describe.skip('Abi interface', () => { +describe('Abi interface', () => { it('can retrieve a function fragment', () => { const fn = exhaustiveExamplesInterface.functions.entry_one; diff --git a/packages/fuel-gauge/src/bytes.test.ts b/packages/fuel-gauge/src/bytes.test.ts index d1edd67cb5d..eb0d3165ea2 100644 --- a/packages/fuel-gauge/src/bytes.test.ts +++ b/packages/fuel-gauge/src/bytes.test.ts @@ -40,7 +40,7 @@ describe('Bytes Tests', () => { ({ minGasPrice: gasPrice } = provider.getGasConfig()); }); - it.skip('should test bytes output', async () => { + it('should test bytes output', async () => { const INPUT = 10; const { value } = await contractInstance.functions.return_bytes(INPUT).call(); @@ -48,7 +48,7 @@ describe('Bytes Tests', () => { expect(value).toStrictEqual(new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])); }); - it.skip('should test bytes output [100 items]', async () => { + it('should test bytes output [100 items]', async () => { const INPUT = 100; const { value } = await contractInstance.functions.return_bytes(INPUT).call(); diff --git a/packages/fuel-gauge/src/coverage-contract.test.ts b/packages/fuel-gauge/src/coverage-contract.test.ts index 9972c42a094..084d6f70cd5 100644 --- a/packages/fuel-gauge/src/coverage-contract.test.ts +++ b/packages/fuel-gauge/src/coverage-contract.test.ts @@ -590,7 +590,7 @@ describe('Coverage Contract', () => { expect(1).toEqual(1); }); - it.skip('should test b256 multiple params vector input/output', async () => { + it('should test b256 multiple params vector input/output', async () => { const INPUT_A = [hexlify(randomBytes(32)), hexlify(randomBytes(32)), hexlify(randomBytes(32))]; const INPUT_B = [hexlify(randomBytes(32)), hexlify(randomBytes(32)), hexlify(randomBytes(32))]; const INPUT_C = hexlify(randomBytes(32)); diff --git a/packages/fuel-gauge/src/std-lib-string.test.ts b/packages/fuel-gauge/src/std-lib-string.test.ts index 2364e265808..3d7a83e717c 100644 --- a/packages/fuel-gauge/src/std-lib-string.test.ts +++ b/packages/fuel-gauge/src/std-lib-string.test.ts @@ -31,7 +31,7 @@ describe('std-lib-string Tests', () => { const { binHexlified: predicateStdString, abiContents: predicateStdStringAbi } = getFuelGaugeForcProject(FuelGaugeProjectsEnum.PREDICATE_STD_LIB_STRING); - it.skip('should test std-lib-string return', async () => { + it('should test std-lib-string return', async () => { const { value } = await contractInstance.functions.return_dynamic_string().call(); expect(value).toBe('Hello World'); }); diff --git a/packages/fuel-gauge/src/vectors.test.ts b/packages/fuel-gauge/src/vectors.test.ts index e46ad56ee14..e0d13814f0c 100644 --- a/packages/fuel-gauge/src/vectors.test.ts +++ b/packages/fuel-gauge/src/vectors.test.ts @@ -27,7 +27,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test u16 vector input/output', async () => { + it('should test u16 vector input/output', async () => { const INPUT = [8, 6, 7, 5, 3, 0, 9]; const { value } = await contractInstance.functions.echo_u16(INPUT).call(); @@ -35,7 +35,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test u32 vector input/output', async () => { + it('should test u32 vector input/output', async () => { const INPUT = [8, 6, 7, 5, 3, 0, 9]; const { value } = await contractInstance.functions.echo_u32(INPUT).call(); @@ -59,7 +59,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test b256 vector input/output', async () => { + it('should test b256 vector input/output', async () => { const INPUT = [hexlify(randomBytes(32)), hexlify(randomBytes(32)), hexlify(randomBytes(32))]; const { value } = await contractInstance.functions.echo_b256(INPUT).call(); @@ -67,7 +67,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test b512 vector input/output', async () => { + it('should test b512 vector input/output', async () => { const INPUT = [hexlify(randomBytes(64)), hexlify(randomBytes(64)), hexlify(randomBytes(64))]; const { value } = await contractInstance.functions.echo_b512(INPUT).call(); @@ -83,7 +83,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test str[9] vector input/output', async () => { + it('should test str[9] vector input/output', async () => { const INPUT = ['123456789', 'abcdefghi', 'catdogcat', 'onetwoone']; const { value } = await contractInstance.functions.echo_str_9(INPUT).call(); @@ -138,7 +138,7 @@ describe('Vector Tests', () => { expect(value.map((nums: BN[]) => toNumbers(nums))).toStrictEqual(INPUT); }); - it.skip('should test [bool; 2] vector input/output', async () => { + it('should test [bool; 2] vector input/output', async () => { const INPUT = [ [true, true], [true, false], @@ -170,7 +170,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test B256Struct vector input/output', async () => { + it('should test B256Struct vector input/output', async () => { const INPUT = [ { i: hexlify(randomBytes(32)), @@ -188,7 +188,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test ComplexStruct vector input/output', async () => { + it('should test ComplexStruct vector input/output', async () => { type ComplexStruct = { foo: number; bar: BN; baz: string }; const INPUT = [ { @@ -234,7 +234,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test BigEnum vector input/output', async () => { + it('should test BigEnum vector input/output', async () => { const INPUT = [ { AddressA: hexlify(randomBytes(32)), From b9d876aa03f61e9c958038e3fd2a2e5bf6113621 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Apr 2024 16:20:27 +0100 Subject: [PATCH 63/92] chore: skip interface test --- packages/abi-coder/test/Interface.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/abi-coder/test/Interface.test.ts b/packages/abi-coder/test/Interface.test.ts index 7dd7bfbdf1d..3f5cdb95c9b 100644 --- a/packages/abi-coder/test/Interface.test.ts +++ b/packages/abi-coder/test/Interface.test.ts @@ -53,7 +53,7 @@ const exhaustiveExamplesInterface = new Interface(exhaustiveExamplesAbi); /** * @group node */ -describe('Abi interface', () => { +describe.skip('Abi interface', () => { it('can retrieve a function fragment', () => { const fn = exhaustiveExamplesInterface.functions.entry_one; From e507916429c0ef64e17585ebeea4f465fe9aad6d Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Mon, 22 Apr 2024 07:24:57 -0300 Subject: [PATCH 64/92] Upgrading `forc` to `0.55.0` --- packages/forc/VERSION | 2 +- packages/versions/src/lib/getBuiltinVersions.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/forc/VERSION b/packages/forc/VERSION index 7f422a161ae..316ba4bd9e6 100644 --- a/packages/forc/VERSION +++ b/packages/forc/VERSION @@ -1 +1 @@ -0.53.0 +0.55.0 diff --git a/packages/versions/src/lib/getBuiltinVersions.ts b/packages/versions/src/lib/getBuiltinVersions.ts index 3bdd9704781..08961958887 100644 --- a/packages/versions/src/lib/getBuiltinVersions.ts +++ b/packages/versions/src/lib/getBuiltinVersions.ts @@ -1,6 +1,6 @@ export function getBuiltinVersions() { return { - FORC: '0.53.0', + FORC: '0.55.0', FUEL_CORE: '0.22.1', FUELS: '0.81.0', }; From b457a67c172254a514e7c9bfbcedddd587cc9098 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Mon, 22 Apr 2024 08:16:22 -0300 Subject: [PATCH 65/92] Fixing broken tests --- .../src/guide/transactions/transaction-request.test.ts | 4 ++-- packages/fuel-gauge/src/script-with-vectors.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 091f1fab851..6b194c8277e 100644 --- a/apps/docs-snippets/src/guide/transactions/transaction-request.test.ts +++ b/apps/docs-snippets/src/guide/transactions/transaction-request.test.ts @@ -185,7 +185,7 @@ describe('Transaction Request', () => { const transactionRequest = new ScriptTransactionRequest({ script: scriptBytecode }); // Get the chain ID - const chainId = await provider.getChainId(); + const chainId = provider.getChainId(); // Get the transaction ID using the Chain ID const transactionId = transactionRequest.getTransactionId(chainId); @@ -193,7 +193,7 @@ describe('Transaction Request', () => { // #endregion transaction-request-7 expect(transactionId).toBe( - '0x35cd6a10e917d5d0223413c1fb9863d27da40e5d602a7f37cfbcefb570172f6c' + '0x8a1a2bb529db20cdd8f35a8b6e00b0440629712fa891fa29232a396982be3d15' ); }); }); diff --git a/packages/fuel-gauge/src/script-with-vectors.test.ts b/packages/fuel-gauge/src/script-with-vectors.test.ts index 426f5ceb44c..e1066293b36 100644 --- a/packages/fuel-gauge/src/script-with-vectors.test.ts +++ b/packages/fuel-gauge/src/script-with-vectors.test.ts @@ -39,10 +39,10 @@ describe('Script With Vectors', () => { const formattedLog = logs.map((l) => (typeof l === 'string' ? l : l.toNumber())); const vecFirst = someVec[0]; - const vecPointer = 11232; + const vecPointer = 11616; const vecCapacity = 4; const vecLen = 4; - const vecAddr = 11208; + const vecAddr = 11592; expect(formattedLog).toEqual([ vecFirst, From 058601e8ece4ee99b5bfe3d2899a49facf5a4bc1 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Mon, 22 Apr 2024 17:26:12 +0100 Subject: [PATCH 66/92] feat: enable option vecs and vecs in multicall --- .../src/encoding/coders/v1/VecCoder.ts | 25 +++++---- packages/fuel-gauge/src/contract.test.ts | 51 ++++--------------- .../fuel-gauge/src/coverage-contract.test.ts | 4 +- packages/fuel-gauge/src/vectors.test.ts | 2 +- .../program/src/functions/multicall-scope.ts | 5 +- 5 files changed, 33 insertions(+), 54 deletions(-) diff --git a/packages/abi-coder/src/encoding/coders/v1/VecCoder.ts b/packages/abi-coder/src/encoding/coders/v1/VecCoder.ts index d214ae17457..64eeac3ab3c 100644 --- a/packages/abi-coder/src/encoding/coders/v1/VecCoder.ts +++ b/packages/abi-coder/src/encoding/coders/v1/VecCoder.ts @@ -2,12 +2,14 @@ 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 { MAX_BYTES, OPTION_CODER_TYPE, WORD_SIZE } from '../../../utils/constants'; import { chunkByLength } from '../../../utils/utilities'; import type { TypesOfCoder } from '../AbstractCoder'; import { Coder } from '../AbstractCoder'; import { BigNumberCoder } from '../v0/BigNumberCoder'; +import { OptionCoder } from './OptionCoder'; + type InputValueOf = Array['Input']>; type DecodedValueOf = Array['Decoded']>; @@ -16,10 +18,12 @@ export class VecCoder extends Coder< DecodedValueOf > { coder: TCoder; + #isOptionVec: boolean; constructor(coder: TCoder) { super('struct', `struct Vec`, coder.encodedLength + WORD_SIZE); this.coder = coder; + this.#isOptionVec = this.coder instanceof OptionCoder; } encode(value: InputValueOf): Uint8Array { @@ -34,7 +38,7 @@ export class VecCoder extends Coder< } decode(data: Uint8Array, offset: number): [DecodedValueOf, number] { - if (data.length < this.encodedLength || data.length > MAX_BYTES) { + if (!this.#isOptionVec && (data.length < this.encodedLength || data.length > MAX_BYTES)) { throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid vec data size.`); } @@ -44,15 +48,18 @@ export class VecCoder extends Coder< const dataLength = length * this.coder.encodedLength; const dataBytes = data.slice(offsetAndLength, offsetAndLength + dataLength); - if (dataBytes.length !== dataLength) { + if (!this.#isOptionVec && dataBytes.length !== dataLength) { throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid vec byte data size.`); } - return [ - chunkByLength(dataBytes, this.coder.encodedLength).map( - (chunk) => this.coder.decode(chunk, 0)[0] - ), - offsetAndLength + dataLength, - ]; + let newOffset = offsetAndLength; + const chunks = []; + for (let i = 0; i < length; i++) { + const [decoded, optionOffset] = this.coder.decode(data, newOffset); + chunks.push(decoded); + newOffset = optionOffset; + } + + return [chunks, newOffset]; } } diff --git a/packages/fuel-gauge/src/contract.test.ts b/packages/fuel-gauge/src/contract.test.ts index 738a20f6d1e..33f3df09a04 100644 --- a/packages/fuel-gauge/src/contract.test.ts +++ b/packages/fuel-gauge/src/contract.test.ts @@ -26,6 +26,7 @@ import { BaseAssetId, FUEL_NETWORK_URL, Predicate, + hexlify, } from 'fuels'; import { FuelGaugeProjectsEnum, getFuelGaugeForcProject } from '../test/fixtures'; @@ -825,7 +826,7 @@ describe('Contract', () => { expect(resultB.b.toHex()).toEqual(bn(struct.b).add(1).toHex()); }); - it('should ensure multicall does not allow multiple calls that return heap types', async () => { + it('should ensure multicall allows multiple heap types', async () => { const wallet = Wallet.generate({ provider, }); @@ -841,47 +842,15 @@ describe('Contract', () => { const vector = [5, 4, 3, 2, 1]; - const calls = [ - contract.functions.return_context_amount(), - contract.functions.return_vector(vector), // returns heap type Vec - contract.functions.return_bytes(), // returns heap type Bytes - ]; - - await expectToThrowFuelError( - () => contract.multiCall(calls).call(), - new FuelError( - ErrorCode.INVALID_MULTICALL, - 'A multicall can have only one call that returns a heap type.' - ) - ); - }); - - it('should ensure multicall only allows calls that return a heap type on last position', async () => { - const wallet = Wallet.generate({ - provider, - }); - await seedTestWallet(wallet, [ - { - amount: bn(500_000), - assetId: BaseAssetId, - }, - ]); - const factory = new ContractFactory(contractBytecode, abi, wallet); - - const contract = await factory.deployContract({ gasPrice }); - - const calls = [ - contract.functions.return_bytes(), // returns heap type Bytes - contract.functions.return_context_amount(), - ]; + const { value } = await contract + .multiCall([ + contract.functions.return_context_amount(), + contract.functions.return_vector(vector), // returns heap type Vec + contract.functions.return_bytes(), + ]) + .call(); - await expectToThrowFuelError( - () => contract.multiCall(calls).call(), - new FuelError( - ErrorCode.INVALID_MULTICALL, - 'In a multicall, the contract call returning a heap type must be the last call.' - ) - ); + expect(JSON.stringify(value)).toBe(JSON.stringify([bn(0), vector, new Uint8Array()])); }); it('Read only call', async () => { diff --git a/packages/fuel-gauge/src/coverage-contract.test.ts b/packages/fuel-gauge/src/coverage-contract.test.ts index 084d6f70cd5..ec8eaca8396 100644 --- a/packages/fuel-gauge/src/coverage-contract.test.ts +++ b/packages/fuel-gauge/src/coverage-contract.test.ts @@ -603,7 +603,7 @@ describe('Coverage Contract', () => { expect(value).toStrictEqual(INPUT_B); }); - it.skip('should handle multiple calls [with vectors]', async () => { + it('should handle multiple calls [with vectors]', async () => { const INPUT_A = [hexlify(randomBytes(32)), hexlify(randomBytes(32)), hexlify(randomBytes(32))]; const INPUT_B = [hexlify(randomBytes(32))]; const INPUT_C = hexlify(randomBytes(32)); @@ -621,7 +621,7 @@ describe('Coverage Contract', () => { expect(results).toStrictEqual([INPUT_B, 13, 23, SmallEnum.Empty, INPUT_A]); }); - it.skip('should handle multiple calls [with vectors + stack data first]', async () => { + it('should handle multiple calls [with vectors + stack data first]', async () => { const INPUT_A = [hexlify(randomBytes(32)), hexlify(randomBytes(32)), hexlify(randomBytes(32))]; const INPUT_B = [hexlify(randomBytes(32))]; const INPUT_C = hexlify(randomBytes(32)); diff --git a/packages/fuel-gauge/src/vectors.test.ts b/packages/fuel-gauge/src/vectors.test.ts index e0d13814f0c..dfcea14d05c 100644 --- a/packages/fuel-gauge/src/vectors.test.ts +++ b/packages/fuel-gauge/src/vectors.test.ts @@ -281,7 +281,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test Vec inside vector input/output', async () => { + it('should test Vec inside vector input/output', async () => { const INPUT = [[1, 5, 98], [2, 44], [34]]; const { value } = await contractInstance.functions.echo_vector_inside_vector(INPUT).call(); diff --git a/packages/program/src/functions/multicall-scope.ts b/packages/program/src/functions/multicall-scope.ts index 0b127fb392a..6672439cf94 100644 --- a/packages/program/src/functions/multicall-scope.ts +++ b/packages/program/src/functions/multicall-scope.ts @@ -1,4 +1,5 @@ /* 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'; @@ -20,7 +21,9 @@ export class MultiCallInvocationScope extends BaseInvocationScope constructor(contract: AbstractContract, funcScopes: Array) { super(contract, true); this.addCalls(funcScopes); - this.validateHeapTypeReturnCalls(); + if (this.program.interface.jsonAbi.encoding !== ENCODING_V1) { + this.validateHeapTypeReturnCalls(); + } } /** From c14797958f168efe7a2ceb12c3fea32f72a2815e Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Mon, 22 Apr 2024 17:26:29 +0100 Subject: [PATCH 67/92] test: enable last multicall heap test --- packages/fuel-gauge/src/vectors.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fuel-gauge/src/vectors.test.ts b/packages/fuel-gauge/src/vectors.test.ts index dfcea14d05c..d386b3327d3 100644 --- a/packages/fuel-gauge/src/vectors.test.ts +++ b/packages/fuel-gauge/src/vectors.test.ts @@ -337,7 +337,7 @@ describe('Vector Tests', () => { expect(value).toStrictEqual(INPUT); }); - it.skip('should test multiCall vectors', async () => { + it('should test multiCall vectors', async () => { const { value: results } = await contractInstance .multiCall([ contractInstance.functions.echo_u8([1]), From 3304171fe3890c68b29201f3855ced07eea0f484 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Mon, 22 Apr 2024 17:37:09 +0100 Subject: [PATCH 68/92] chore: linting --- packages/abi-coder/src/encoding/coders/v1/VecCoder.ts | 3 +-- packages/fuel-gauge/src/contract.test.ts | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/abi-coder/src/encoding/coders/v1/VecCoder.ts b/packages/abi-coder/src/encoding/coders/v1/VecCoder.ts index 64eeac3ab3c..cefd6e166f0 100644 --- a/packages/abi-coder/src/encoding/coders/v1/VecCoder.ts +++ b/packages/abi-coder/src/encoding/coders/v1/VecCoder.ts @@ -2,8 +2,7 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { bn } from '@fuel-ts/math'; import { concatBytes } from '@fuel-ts/utils'; -import { MAX_BYTES, OPTION_CODER_TYPE, WORD_SIZE } from '../../../utils/constants'; -import { chunkByLength } from '../../../utils/utilities'; +import { MAX_BYTES, WORD_SIZE } from '../../../utils/constants'; import type { TypesOfCoder } from '../AbstractCoder'; import { Coder } from '../AbstractCoder'; import { BigNumberCoder } from '../v0/BigNumberCoder'; diff --git a/packages/fuel-gauge/src/contract.test.ts b/packages/fuel-gauge/src/contract.test.ts index 33f3df09a04..ce7211610d7 100644 --- a/packages/fuel-gauge/src/contract.test.ts +++ b/packages/fuel-gauge/src/contract.test.ts @@ -26,7 +26,6 @@ import { BaseAssetId, FUEL_NETWORK_URL, Predicate, - hexlify, } from 'fuels'; import { FuelGaugeProjectsEnum, getFuelGaugeForcProject } from '../test/fixtures'; From 6438abb388a1e530e8bfe1e0e898f05f1e8d7169 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Mon, 22 Apr 2024 18:54:27 -0300 Subject: [PATCH 69/92] Adjusting changeset --- .changeset/ninety-hotels-impress.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/ninety-hotels-impress.md b/.changeset/ninety-hotels-impress.md index d23f1129a8d..323a0761556 100644 --- a/.changeset/ninety-hotels-impress.md +++ b/.changeset/ninety-hotels-impress.md @@ -6,4 +6,4 @@ "@fuel-ts/forc": patch --- -chore!: upgrading `forc` to `0.53.0` +chore!: upgrading `forc` to `0.55.0` From 9e14db5cd9fee1e93745e7a7a6975d8545215146 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Mon, 22 Apr 2024 19:30:49 -0300 Subject: [PATCH 70/92] Lintfix --- .../src/guide/transactions/transaction-request.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6b194c8277e..bf5926cafb1 100644 --- a/apps/docs-snippets/src/guide/transactions/transaction-request.test.ts +++ b/apps/docs-snippets/src/guide/transactions/transaction-request.test.ts @@ -177,7 +177,7 @@ describe('Transaction Request', () => { expect(transactionRequest.witnesses.length).toEqual(2); }); - it('gets the transaction ID', async () => { + it('gets the transaction ID', () => { // #region transaction-request-7 // #import { ScriptTransactionRequest }; From 90c0aeb65e75887a9993b5df9fdf1ab6c78eabaa Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 23 Apr 2024 09:44:57 +0100 Subject: [PATCH 71/92] chore: change std string doc test to use simulate --- apps/docs-snippets/src/guide/types/std-string.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/docs-snippets/src/guide/types/std-string.test.ts b/apps/docs-snippets/src/guide/types/std-string.test.ts index 889673e684f..51fea1d3505 100644 --- a/apps/docs-snippets/src/guide/types/std-string.test.ts +++ b/apps/docs-snippets/src/guide/types/std-string.test.ts @@ -19,7 +19,7 @@ describe('StdString', () => { const stdString: StdString = 'Hello World'; - const { value } = await contract.functions.string_comparison(stdString).call(); + const { value } = await contract.functions.string_comparison(stdString).simulate(); expect(value).toBeTruthy(); // #endregion std-string-1 @@ -31,7 +31,7 @@ describe('StdString', () => { const stdString: StdString = 'Hello Fuel'; - const { value } = await contract.functions.echo_string(stdString).call(); + const { value } = await contract.functions.echo_string(stdString).simulate(); expect(value).toEqual(stdString); // #endregion std-string-2 From 31c7f5d7e399ec79d328823c085b79015ad92a71 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 23 Apr 2024 10:01:31 +0100 Subject: [PATCH 72/92] chore: use correct return type in e2e test --- packages/fuel-gauge/src/e2e-script.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fuel-gauge/src/e2e-script.test.ts b/packages/fuel-gauge/src/e2e-script.test.ts index 740d6c4a349..edfcc66ccb6 100644 --- a/packages/fuel-gauge/src/e2e-script.test.ts +++ b/packages/fuel-gauge/src/e2e-script.test.ts @@ -119,6 +119,6 @@ describe('Live Script Test', () => { `); } - expect(output.toString()).toBe('1'); + expect(output).toBe(true); }); }); From 91b8bb82915be6b352b7b90f743d0db865f4eeb3 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Tue, 23 Apr 2024 09:00:57 -0300 Subject: [PATCH 73/92] Removing useless changeset --- .changeset/friendly-peaches-change.md | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .changeset/friendly-peaches-change.md diff --git a/.changeset/friendly-peaches-change.md b/.changeset/friendly-peaches-change.md deleted file mode 100644 index a845151cc84..00000000000 --- a/.changeset/friendly-peaches-change.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- From 442534e3be270513448062a6a4f4a0f6f8ca67ba Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 23 Apr 2024 13:02:07 +0100 Subject: [PATCH 74/92] chore: remove sway patch branch --- packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml b/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml index 125d5e457dc..0fa66ccbd96 100644 --- a/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml +++ b/packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml @@ -58,6 +58,3 @@ members = [ "vector-types-script", "vectors", ] - -[patch.'https://github.com/fuellabs/sway'] -std = { git = "https://github.com/fuellabs/sway", branch = "xunilrj/abi-decode-vec-with-capacity" } From bdbd7e60d37518e81b720688670c3334b3357ab8 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 23 Apr 2024 16:26:52 +0100 Subject: [PATCH 75/92] chore: use experimental encoding for abi coder --- packages/abi-coder/package.json | 2 +- packages/abi-coder/test/Interface.test.ts | 287 ++++++------------ .../exhaustive-examples/src/main.sw | 36 +-- packages/abi-coder/test/utils/constants.ts | 17 +- 4 files changed, 130 insertions(+), 212 deletions(-) diff --git a/packages/abi-coder/package.json b/packages/abi-coder/package.json index 96779ba6566..b17e6b0139b 100644 --- a/packages/abi-coder/package.json +++ b/packages/abi-coder/package.json @@ -21,7 +21,7 @@ ], "scripts": { "pretest": "pnpm build:forc", - "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release", + "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects --release --experimental-new-encoding", "build": "tsup", "postbuild": "tsx ../../scripts/postbuild.ts" }, diff --git a/packages/abi-coder/test/Interface.test.ts b/packages/abi-coder/test/Interface.test.ts index 3f5cdb95c9b..55fc386f022 100644 --- a/packages/abi-coder/test/Interface.test.ts +++ b/packages/abi-coder/test/Interface.test.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { BN } from '@fuel-ts/math'; +import type { BN } from '@fuel-ts/math'; import { concat } from '@fuel-ts/utils'; -import { NumberCoder, WORD_SIZE, Interface } from '../src'; +import { Interface } from '../src'; /** @knipignore */ import type { JsonAbiConfigurable } from '../src/json-abi'; @@ -16,44 +16,31 @@ import { B512_ENCODED, B512_ZERO_DECODED, B512_ZERO_ENCODED, + BOOL_FALSE_ENCODED, BOOL_TRUE_ENCODED, - EMPTY_8_BYTE_ARRAY, + ENUM_FIRST_INDEX, + ENUM_SECOND_INDEX, + ENUM_THIRD_INDEX, U16_MAX, U16_MAX_ENCODED, + U16_MIN_ENCODED, U32_MAX, U32_MAX_ENCODED, + U32_MIN_ENCODED, U64_MAX, U64_MAX_ENCODED, + U64_MIN_ENCODED, U8_MAX, U8_MAX_ENCODED, + U8_MIN_ENCODED, } from './utils/constants'; -function encodeVectorFully( - encodedData: Uint8Array[] | Uint8Array, - offset: number, - dataLength?: number -) { - const data = encodedData instanceof Uint8Array ? encodedData : concat(encodedData); - // eslint-disable-next-line no-param-reassign - dataLength ??= data.length / 8; - const o = new NumberCoder('u32').encode(offset); - const length = new NumberCoder('u8').encode(dataLength); - const capacity = length; - - return { - offset, - length: dataLength, - vec: concat([o, length, capacity]), - data, - }; -} - const exhaustiveExamplesInterface = new Interface(exhaustiveExamplesAbi); /** * @group node */ -describe.skip('Abi interface', () => { +describe('Abi interface', () => { it('can retrieve a function fragment', () => { const fn = exhaustiveExamplesInterface.functions.entry_one; @@ -98,9 +85,9 @@ describe.skip('Abi interface', () => { 'simple_vector(s(s(rawptr,u64),u64))', '0x00000000dd1b1a41', - 'struct_with_implicitGenerics', - 'struct_with_implicitGenerics(s(a[b256;3],(b256,u8)))', - '0x00000000a282b8c9', + 'struct_with_implicit_generics', + 'struct_with_implicit_generics(s(a[b256;3],(b256,u8)))', + '0x0000000032ef2da0', ])('%p', (nameOrSignatureOrSelector: string) => { const fn = exhaustiveExamplesInterface.getFunction(nameOrSignatureOrSelector); @@ -165,19 +152,19 @@ describe.skip('Abi interface', () => { fn: exhaustiveExamplesInterface.functions.u_8, title: '[u8]', value: 0, - encodedValue: EMPTY_8_BYTE_ARRAY, + encodedValue: U8_MIN_ENCODED, }, { fn: exhaustiveExamplesInterface.functions.u_8, title: '[u8]', value: U8_MAX, - encodedValue: Uint8Array.from(U8_MAX_ENCODED).reverse(), + encodedValue: Uint8Array.from(U8_MAX_ENCODED), }, { fn: exhaustiveExamplesInterface.functions.u_16, title: '[u16]', value: 0, - encodedValue: EMPTY_8_BYTE_ARRAY, + encodedValue: Uint8Array.from(U16_MIN_ENCODED), }, { fn: exhaustiveExamplesInterface.functions.u_16, @@ -189,7 +176,7 @@ describe.skip('Abi interface', () => { fn: exhaustiveExamplesInterface.functions.u_32, title: '[u32]', value: 0, - encodedValue: EMPTY_8_BYTE_ARRAY, + encodedValue: U32_MIN_ENCODED, }, { fn: exhaustiveExamplesInterface.functions.u_32, @@ -201,7 +188,7 @@ describe.skip('Abi interface', () => { fn: exhaustiveExamplesInterface.functions.u_64, title: '[u64]', value: 0, - encodedValue: EMPTY_8_BYTE_ARRAY, + encodedValue: U64_MIN_ENCODED, decodedTransformer: (decoded: unknown | undefined) => (decoded as BN).toNumber() as number, }, @@ -209,21 +196,21 @@ describe.skip('Abi interface', () => { fn: exhaustiveExamplesInterface.functions.u_64, title: '[u64]', value: U8_MAX, - encodedValue: Uint8Array.from(U8_MAX_ENCODED).reverse(), + encodedValue: Uint8Array.from([0, 0, 0, 0, 0, 0, 0, U8_MAX]), decodedTransformer: (decoded: unknown | undefined) => (decoded as BN).toNumber(), }, { fn: exhaustiveExamplesInterface.functions.u_64, title: '[u64]', value: U16_MAX, - encodedValue: U16_MAX_ENCODED, + encodedValue: Uint8Array.from([0, 0, 0, 0, 0, 0, U8_MAX, U8_MAX]), decodedTransformer: (decoded: unknown | undefined) => (decoded as BN).toNumber(), }, { fn: exhaustiveExamplesInterface.functions.u_64, title: '[u64]', value: U32_MAX, - encodedValue: U32_MAX_ENCODED, + encodedValue: Uint8Array.from([0, 0, 0, 0, U8_MAX, U8_MAX, U8_MAX, U8_MAX]), decodedTransformer: (decoded: unknown | undefined) => (decoded as BN).toNumber(), }, { @@ -236,13 +223,13 @@ describe.skip('Abi interface', () => { fn: exhaustiveExamplesInterface.functions.boolean, title: '[bool]', value: false, - encodedValue: EMPTY_8_BYTE_ARRAY, + encodedValue: BOOL_FALSE_ENCODED, }, { fn: exhaustiveExamplesInterface.functions.boolean, title: '[bool]', value: true, - encodedValue: Uint8Array.from(BOOL_TRUE_ENCODED).reverse(), + encodedValue: BOOL_TRUE_ENCODED, }, { fn: exhaustiveExamplesInterface.functions.b_256, @@ -272,7 +259,7 @@ describe.skip('Abi interface', () => { fn: exhaustiveExamplesInterface.functions.two_args, title: 'two arguments', value: [B256_DECODED, false], - encodedValue: [B256_ENCODED, EMPTY_8_BYTE_ARRAY], + encodedValue: [B256_ENCODED, BOOL_FALSE_ENCODED], }, { fn: exhaustiveExamplesInterface.functions.struct_simple, @@ -299,7 +286,7 @@ describe.skip('Abi interface', () => { encodedValue: [BOOL_TRUE_ENCODED, U64_MAX_ENCODED], }, { - fn: exhaustiveExamplesInterface.functions.struct_with_implicitGenerics, + fn: exhaustiveExamplesInterface.functions.struct_with_implicit_generics, title: '[struct] with implicit generics', value: { arr: [B256_DECODED, B256_DECODED, B256_DECODED], tuple: [B256_DECODED, U8_MAX] }, encodedValue: [B256_ENCODED, B256_ENCODED, B256_ENCODED, B256_ENCODED, U8_MAX_ENCODED], @@ -308,10 +295,7 @@ describe.skip('Abi interface', () => { fn: exhaustiveExamplesInterface.functions.bytes, title: '[struct Bytes]', value: [[1, 2, 3]], - encodedValue: 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, 1, 2, 3, 0, 0, - 0, 0, 0, - ]), + encodedValue: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 3, 1, 2, 3]), decodedTransformer: (decoded: unknown | undefined) => { const data = (decoded as BN[]).slice(0, 3); return Array.from(data); @@ -321,7 +305,7 @@ describe.skip('Abi interface', () => { fn: exhaustiveExamplesInterface.functions.raw_slice, title: '[raw_slice]', value: [[1, 2, 3]], - encodedValue: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 3, 1, 2, 3]), + encodedValue: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 3, 1, 2, 3]), decodedTransformer: (decoded: unknown | undefined) => (decoded as number[]).slice(-3), }, { @@ -329,75 +313,56 @@ describe.skip('Abi interface', () => { title: '[struct String]', value: 'H3llo W0rld', encodedValue: 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, 72, 51, 108, - 108, 111, 32, 87, 48, 114, 108, 100, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 11, 72, 51, 108, 108, 111, 32, 87, 48, 114, 108, 100, ]), }, { fn: exhaustiveExamplesInterface.functions.tuple_as_param, title: '[tuple] as param', value: [[U8_MAX, { propA1: { propB1: U64_MAX }, propA2: 'aaa' }]], - encodedValue: [ - U8_MAX_ENCODED, - U64_MAX_ENCODED, - EMPTY_8_BYTE_ARRAY.slice().fill(97, 0, 3), - ], + encodedValue: [U8_MAX_ENCODED, U64_MAX_ENCODED, Uint8Array.from([97, 97, 97])], }, { fn: exhaustiveExamplesInterface.functions.option_u8, title: '[option] u8', value: undefined, - encodedValue: [EMPTY_8_BYTE_ARRAY, EMPTY_8_BYTE_ARRAY], + encodedValue: ENUM_FIRST_INDEX, }, { fn: exhaustiveExamplesInterface.functions.option_u8, title: '[option] u8', value: U8_MAX, - encodedValue: [ - Uint8Array.from(EMPTY_8_BYTE_ARRAY).fill(1, 7), - Uint8Array.from(U8_MAX_ENCODED).reverse(), - ], - }, - { - fn: exhaustiveExamplesInterface.functions.enum_simple, - title: '[enum] simple', - value: 'Green', - encodedValue: EMPTY_8_BYTE_ARRAY.slice().fill(1, 7), + encodedValue: [ENUM_SECOND_INDEX, U8_MAX_ENCODED], }, { fn: exhaustiveExamplesInterface.functions.enum_simple, title: '[enum] simple', value: 'Green', - encodedValue: EMPTY_8_BYTE_ARRAY.slice().fill(1, 7), + encodedValue: ENUM_SECOND_INDEX, }, { fn: exhaustiveExamplesInterface.functions.enum_with_builtin_type, title: '[enum] with builtin type', value: { a: true }, - encodedValue: [EMPTY_8_BYTE_ARRAY, EMPTY_8_BYTE_ARRAY.slice().fill(1, 7)], + encodedValue: [ENUM_FIRST_INDEX, BOOL_TRUE_ENCODED], }, { fn: exhaustiveExamplesInterface.functions.enum_with_builtin_type, title: '[enum] with builtin type', value: { b: U64_MAX }, - encodedValue: [EMPTY_8_BYTE_ARRAY.slice().fill(1, 7), U64_MAX_ENCODED], + encodedValue: [ENUM_SECOND_INDEX, U64_MAX_ENCODED], }, { fn: exhaustiveExamplesInterface.functions.enum_with_structs, title: '[enum] with structs', value: { c: { propA1: U64_MAX, propA2: { a: true, b: U32_MAX } } }, - encodedValue: [ - EMPTY_8_BYTE_ARRAY.slice().fill(2, 7), - U64_MAX_ENCODED, - BOOL_TRUE_ENCODED, - U32_MAX_ENCODED, - ], + encodedValue: [ENUM_THIRD_INDEX, U64_MAX_ENCODED, BOOL_TRUE_ENCODED, U32_MAX_ENCODED], }, { fn: exhaustiveExamplesInterface.functions.array_simple, title: '[array] simple', value: [[1, 2, 3, U8_MAX]], - encodedValue: Uint8Array.from([1, 2, 3, U8_MAX, 0, 0, 0, 0]), + encodedValue: Uint8Array.from([1, 2, 3, U8_MAX]), }, { fn: exhaustiveExamplesInterface.functions.array_struct, @@ -411,11 +376,11 @@ describe.skip('Abi interface', () => { ], encodedValue: [ BOOL_TRUE_ENCODED, - EMPTY_8_BYTE_ARRAY.slice().fill(1, 7), - EMPTY_8_BYTE_ARRAY, + Uint8Array.from([0, 0, 0, 1]), + BOOL_FALSE_ENCODED, U32_MAX_ENCODED, BOOL_TRUE_ENCODED, - EMPTY_8_BYTE_ARRAY.slice().fill(2, 7), + Uint8Array.from([0, 0, 0, 2]), ], }, { @@ -427,17 +392,17 @@ describe.skip('Abi interface', () => { { bim: B256_DECODED, bam: { propB1: U8_MAX }, - bom: { propA1: U8_MAX, propA2: B256_DECODED }, + bom: { propA1: B256_DECODED, propA2: U8_MAX }, }, { bim: B256_DECODED, bam: { propB1: 0 }, - bom: { propA1: U8_MAX, propA2: B256_DECODED }, + bom: { propA1: B256_DECODED, propA2: U8_MAX }, }, { bim: B256_DECODED, bam: { propB1: U8_MAX }, - bom: { propA1: U8_MAX, propA2: B256_DECODED }, + bom: { propA1: B256_DECODED, propA2: U8_MAX }, }, ], }, @@ -445,67 +410,56 @@ describe.skip('Abi interface', () => { encodedValue: [ B256_ENCODED, U8_MAX_ENCODED, - U8_MAX_ENCODED, - B256_ENCODED, B256_ENCODED, - EMPTY_8_BYTE_ARRAY, U8_MAX_ENCODED, B256_ENCODED, + U8_MIN_ENCODED, B256_ENCODED, U8_MAX_ENCODED, + B256_ENCODED, U8_MAX_ENCODED, B256_ENCODED, + U8_MAX_ENCODED, ], }, { fn: exhaustiveExamplesInterface.functions.vector_boolean, title: '[vector] boolean', value: [[true, false, true, true]], - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - encodedValue: () => { - const data = Uint8Array.from([1, 0, 1, 1]); - const vector = encodeVectorFully(data, 3 * WORD_SIZE, data.length); - return [vector.vec, vector.data] as Uint8Array[]; - }, + encodedValue: [ + Uint8Array.from([0, 0, 0, 0, 0, 0, 0, 4]), + BOOL_TRUE_ENCODED, + BOOL_FALSE_ENCODED, + BOOL_TRUE_ENCODED, + BOOL_TRUE_ENCODED, + ], }, { fn: exhaustiveExamplesInterface.functions.vector_u8, title: '[vector] u8', value: [[U8_MAX, 0, U8_MAX, U8_MAX]], - encodedValue: () => { - const data = Uint8Array.from([U8_MAX, 0, U8_MAX, U8_MAX]); - const vector = encodeVectorFully(data, 3 * WORD_SIZE, data.length); - return [vector.vec, vector.data] as Uint8Array[]; - }, + encodedValue: Uint8Array.from([0, 0, 0, 0, 0, 0, 0, 4, U8_MAX, 0, U8_MAX, U8_MAX]), }, { skipDecoding: true, fn: exhaustiveExamplesInterface.functions.arg_then_vector_u8, title: '[vector] some arg then u8 vector', value: [{ a: true, b: U32_MAX }, [U8_MAX, 0, U8_MAX, U8_MAX]], - encodedValue: () => { - const data = Uint8Array.from([U8_MAX, 0, U8_MAX, U8_MAX]); - - const vector = encodeVectorFully(data, 2 * WORD_SIZE + 3 * WORD_SIZE, data.length); - return [BOOL_TRUE_ENCODED, U32_MAX_ENCODED, vector.vec, vector.data]; - }, + encodedValue: [ + BOOL_TRUE_ENCODED, + U32_MAX_ENCODED, + Uint8Array.from([0, 0, 0, 0, 0, 0, 0, 4, U8_MAX, 0, U8_MAX, U8_MAX]), + ], }, { skipDecoding: true, fn: exhaustiveExamplesInterface.functions.vector_u8_then_arg, title: '[vector] Vector u8 and then b256', value: [[U8_MAX, 0, U8_MAX, U8_MAX], B256_DECODED], - encodedValue: () => { - const data = Uint8Array.from([U8_MAX, 0, U8_MAX, U8_MAX]); - - const fullyEncodedVector = encodeVectorFully( - data, - 3 * WORD_SIZE + B256_ENCODED.length, - data.length - ); - return [fullyEncodedVector.vec, B256_ENCODED, fullyEncodedVector.data] as Uint8Array[]; - }, + encodedValue: [ + Uint8Array.from([0, 0, 0, 0, 0, 0, 0, 4, U8_MAX, 0, U8_MAX, U8_MAX]), + B256_ENCODED, + ], }, { skipDecoding: true, @@ -515,51 +469,30 @@ describe.skip('Abi interface', () => { [U8_MAX, U8_MAX], [U8_MAX, 0, U8_MAX, U8_MAX], ], - encodedValue: () => { - const vec1Data = Uint8Array.from([U8_MAX, U8_MAX]); - const vec2Data = Uint8Array.from([U8_MAX, 0, U8_MAX, U8_MAX]); - const vec1 = encodeVectorFully(vec1Data, 2 * 3 * WORD_SIZE, vec1Data.length); - const vec2 = encodeVectorFully(vec2Data, vec1.offset + vec1.length, vec2Data.length); - return [vec1.vec, vec2.vec, vec1.data, vec2.data]; - }, + encodedValue: [ + Uint8Array.from([0, 0, 0, 0, 0, 0, 0, 2, U8_MAX, U8_MAX]), + Uint8Array.from([0, 0, 0, 0, 0, 0, 0, 4, U8_MAX, 0, U8_MAX, U8_MAX]), + ], }, { skipDecoding: true, fn: exhaustiveExamplesInterface.functions.u32_then_three_vectors_u64, title: '[vector] arg u32 and then three vectors u64', value: [33, [450, 202, 340], [12, 13, 14], [11, 9]], - encodedValue: () => { - const EXPECTED: Uint8Array[] = [ - new Uint8Array([0, 0, 0, 0, 0, 0, 0, 33]), - new Uint8Array([ - 0, 0, 0, 0, 0, 0, 1, 194, 0, 0, 0, 0, 0, 0, 0, 202, 0, 0, 0, 0, 0, 0, 1, 84, - ]), - new Uint8Array([ - 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 14, - ]), - new Uint8Array([0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 9]), - ]; - const vec1 = encodeVectorFully(EXPECTED[1], WORD_SIZE + 3 * WORD_SIZE * 3); - const vec2 = encodeVectorFully(EXPECTED[2], vec1.offset + vec1.length * WORD_SIZE); - - const vec3 = encodeVectorFully(EXPECTED[3], vec2.offset + vec2.length * WORD_SIZE); - - return [ - EXPECTED[0], - vec1.vec, - vec2.vec, - vec3.vec, - vec1.data, - vec2.data, - vec3.data, - ] as Uint8Array[]; - }, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - decodedTransformer: (value: unknown | undefined) => - (value as any[]).map((x) => - Array.isArray(x) ? x.map((y) => (y instanceof BN ? y.toNumber() : y)) : x - ), + encodedValue: [ + Uint8Array.from([0, 0, 0, 33]), + Uint8Array.from([ + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 194, 0, 0, 0, 0, 0, 0, 0, 202, 0, 0, 0, + 0, 0, 0, 1, 84, + ]), + Uint8Array.from([ + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, + 0, 0, 0, 14, + ]), + Uint8Array.from([ + 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 9, + ]), + ], }, { skipDecoding: true, @@ -571,43 +504,29 @@ describe.skip('Abi interface', () => { [6, 7, 8], ], ], - encodedValue: (input?: any, offset: number = 0) => { + encodedValue: (input?: any, _offset: number = 0) => { // eslint-disable-next-line no-param-reassign input = input[0]; - - const pointer = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, offset + 24]); - const capacity = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input.length]); const length = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input.length]); - - const pointerVec1 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, offset + 72]); - const capacityVec1 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[0].length]); const lengthVec1 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[0].length]); - const data1Vec1 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[0][0]]); - const data2Vec1 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[0][1]]); - const data3Vec1 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[0][2]]); - const pointerVec2 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, offset + 96]); - const capacityVec2 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[1].length]); + const data1Vec1 = Uint8Array.from([0, 0, 0, input[0][0]]); + const data2Vec1 = Uint8Array.from([0, 0, 0, input[0][1]]); + const data3Vec1 = Uint8Array.from([0, 0, 0, input[0][2]]); const lengthVec2 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[1].length]); - const data1Vec2 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[1][0]]); - const data2Vec2 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[1][1]]); - const data3Vec2 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[1][2]]); + const data1Vec2 = Uint8Array.from([0, 0, 0, input[1][0]]); + const data2Vec2 = Uint8Array.from([0, 0, 0, input[1][1]]); + const data3Vec2 = Uint8Array.from([0, 0, 0, input[1][2]]); const expectedBytes = concat([ // top level vector - pointer, - capacity, length, // top level vector, index 0 vector - pointerVec1, - capacityVec1, lengthVec1, - // top level vector, index 1 vector - pointerVec2, - capacityVec2, - lengthVec2, // index 0 vector's data data1Vec1, data2Vec1, data3Vec1, + // top level vector, index 1 vector + lengthVec2, // index 1 vector's data data1Vec2, data2Vec2, @@ -621,17 +540,13 @@ describe.skip('Abi interface', () => { fn: exhaustiveExamplesInterface.functions.vector_inside_array, title: '[vector] vector inside array', value: [[[5, 6]]], - encodedValue: (input?: any, offset: number = 0) => { + encodedValue: (input?: any, _offset: number = 0) => { // eslint-disable-next-line no-param-reassign input = input[0]; - - const pointer = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, 24 + offset]); - const capacity = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[0].length]); const length = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[0].length]); - - const data1 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[0][0]]); - const data2 = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input[0][1]]); - const expectedBytes = concat([pointer, capacity, length, data1, data2]); + const data1 = Uint8Array.from([0, 0, 0, input[0][0]]); + const data2 = Uint8Array.from([0, 0, 0, input[0][1]]); + const expectedBytes = concat([length, data1, data2]); return expectedBytes; }, @@ -649,14 +564,10 @@ describe.skip('Abi interface', () => { encodedValue: (input?: any, _offset: number = 0) => { // eslint-disable-next-line no-param-reassign input = input[0]; - const enumCaseOne = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, 1]); - const pointer = EMPTY_8_BYTE_ARRAY.slice().fill(enumCaseOne.length + 3 * WORD_SIZE, 7); - - const capacity = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input.vec.length]); const length = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input.vec.length]); const vectorData = Uint8Array.from(input.vec); - const expectedBytes = concat([enumCaseOne, pointer, capacity, length, vectorData]); + const expectedBytes = concat([ENUM_SECOND_INDEX, length, vectorData]); return expectedBytes; }, offset: 0, @@ -671,16 +582,14 @@ describe.skip('Abi interface', () => { vec: [3, 9, 6, 4], }, ], - encodedValue: (input?: any, offset: number = 0) => { + encodedValue: (input?: any, _offset: number = 0) => { // eslint-disable-next-line no-param-reassign input = input[0]; - const u8 = EMPTY_8_BYTE_ARRAY.slice().fill(7, 0, 1); - const pointer = EMPTY_8_BYTE_ARRAY.slice().fill(offset + u8.length + 3 * WORD_SIZE, 7); - const capacity = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input.vec.length]); + const u8 = Uint8Array.from([7]); const length = Uint8Array.from([0, 0, 0, 0, 0, 0, 0, input.vec.length]); const vectorData = Uint8Array.from(input.vec); - const expectedBytes = concat([u8, pointer, capacity, length, vectorData]); + const expectedBytes = concat([u8, length, vectorData]); return expectedBytes; }, diff --git a/packages/abi-coder/test/fixtures/forc-projects/exhaustive-examples/src/main.sw b/packages/abi-coder/test/fixtures/forc-projects/exhaustive-examples/src/main.sw index a7a0418b3d8..abed2d93caf 100644 --- a/packages/abi-coder/test/fixtures/forc-projects/exhaustive-examples/src/main.sw +++ b/packages/abi-coder/test/fixtures/forc-projects/exhaustive-examples/src/main.sw @@ -3,8 +3,8 @@ use std::b512::B512; use std::bytes::Bytes; use std::string::String; -enum EnumWithGeneric { - VariantOne: T, +enum EnumWithGeneric { + VariantOne: A, VariantTwo: u64, } @@ -20,13 +20,13 @@ configurable { ENUM: EnumWithGeneric = EnumWithGeneric::VariantOne(true), } -struct StructA { - propA1: T, - propA2: U, +struct StructA { + propA1: B, + propA2: C, } -struct StructB { - propB1: T, +struct StructB { + propB1: D, } struct StructC { @@ -57,17 +57,17 @@ enum EnumWithStructs { c: StructA, } -struct StructWithImplicitGenerics { - arr: [T; 3], - tuple: (T, U), +struct StructWithImplicitGenerics { + arr: [E; 3], + tuple: (E, F), } enum MyGenericEnum { Foo: u64, Bar: bool, } -struct MyGenericStruct { - bim: T, +struct MyGenericStruct { + bim: G, bam: MyGenericEnum, } @@ -109,14 +109,14 @@ struct StructWithVector { vec: Vec, } -struct MyStructWithGeneric { - bim: T, - bam: StructB, - bom: StructA, +struct MyStructWithGeneric { + bim: I, + bam: StructB, + bom: StructA, } -struct ArrWithGenericStruct { - a: [MyStructWithGeneric; 3], +struct ArrWithGenericStruct { + a: [MyStructWithGeneric; 3], } abi MyContract { diff --git a/packages/abi-coder/test/utils/constants.ts b/packages/abi-coder/test/utils/constants.ts index c46e989e4cb..986af402c33 100644 --- a/packages/abi-coder/test/utils/constants.ts +++ b/packages/abi-coder/test/utils/constants.ts @@ -1,17 +1,25 @@ import { bn } from '@fuel-ts/math'; export const U8_MAX = 2 ** 8 - 1; -export const U8_MAX_ENCODED = new Uint8Array([255, 0, 0, 0, 0, 0, 0, 0]); +export const U8_MAX_ENCODED = new Uint8Array([255]); +export const U8_MIN_ENCODED = new Uint8Array([0]); export const U16_MAX = 2 ** 16 - 1; -export const U16_MAX_ENCODED = new Uint8Array([0, 0, 0, 0, 0, 0, 255, 255]); +export const U16_MAX_ENCODED = new Uint8Array([255, 255]); +export const U16_MIN_ENCODED = new Uint8Array([0, 0]); export const U32_MAX = 2 ** 32 - 1; -export const U32_MAX_ENCODED = new Uint8Array([0, 0, 0, 0, 255, 255, 255, 255]); +export const U32_MAX_ENCODED = new Uint8Array([255, 255, 255, 255]); +export const U32_MIN_ENCODED = new Uint8Array([0, 0, 0, 0]); export const U64_MAX = bn(2).pow(64).sub(1); export const U64_MAX_ENCODED = new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255]); +export const U64_MIN_ENCODED = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]); export const U256_MAX = bn(2).pow(256).sub(1); export const U256_MAX_ENCODED = new Uint8Array(32).fill(255); +export const U256_MIN_ENCODED = new Uint8Array(32).fill(0); export const EMPTY_8_BYTE_ARRAY = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]); +export const ENUM_FIRST_INDEX = EMPTY_8_BYTE_ARRAY; +export const ENUM_SECOND_INDEX = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1]); +export const ENUM_THIRD_INDEX = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 2]); export const STRING_MIN_DECODED = ''; export const STRING_MIN_ENCODED = new Uint8Array(); @@ -34,7 +42,8 @@ export const BYTE_MIN_ENCODED = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]); export const BYTE_MAX_DECODED = U8_MAX; export const BYTE_MAX_ENCODED = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 255]); -export const BOOL_TRUE_ENCODED = new Uint8Array([1, 0, 0, 0, 0, 0, 0, 0]); +export const BOOL_TRUE_ENCODED = new Uint8Array([1]); +export const BOOL_FALSE_ENCODED = new Uint8Array([0]); export const B512_DECODED = '0x8e9dda6f7793745ac5aacf9e907cae30b2a01fdf0d23b7750a85c6a44fca0c29f0906f9d1f1e92e6a1fb3c3dcef3cc3b3cdbaae27e47b9d9a4c6a4fce4cf16b2'; From b6cc48bc7ffc69b79f3f5d9f2822e31c8e73dd78 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 17:32:48 +0100 Subject: [PATCH 76/92] Added fuelsInstallVersion --- apps/docs/src/getting-started.md | 12 +++--- .../src/guide/creating-a-fuel-dapp/index.md | 13 ++++-- .../src/guide/creating-a-fuel-dapp/options.md | 13 ++++-- apps/docs/src/guide/fuels-cli/binaries.md | 21 ++++++---- apps/docs/src/guide/fuels-cli/commands.md | 41 +++++++++++-------- .../src/guide/fuels-cli/generating-types.md | 9 +++- apps/docs/src/guide/fuels-cli/index.md | 17 +++++--- apps/docs/src/index.md | 10 ++--- apps/docs/src/versions.data.ts | 1 + 9 files changed, 84 insertions(+), 53 deletions(-) diff --git a/apps/docs/src/getting-started.md b/apps/docs/src/getting-started.md index 0b18f36c2e4..256c6713f4d 100644 --- a/apps/docs/src/getting-started.md +++ b/apps/docs/src/getting-started.md @@ -1,6 +1,6 @@ # Getting Started @@ -17,17 +17,17 @@ To begin, you need to add the `fuels` dependency to your project. You can do thi ::: code-group -```sh [npm] -npm install fuels@0.81.0 --save +```sh-vue [npm] +npm install fuels{{fuelsInstallVersion}} --save ``` -```sh [pnpm] -pnpm add fuels@0.81.0 +```sh-vue [pnpm] +pnpm add fuels{{fuelsInstallVersion}} ``` ::: -**Note**: We use `0.81.0` to ensure compatibility with our latest testnet +**Note**: We use `{{fuelsInstallVersion}}` to ensure compatibility with our latest testnet. ### Note diff --git a/apps/docs/src/guide/creating-a-fuel-dapp/index.md b/apps/docs/src/guide/creating-a-fuel-dapp/index.md index 78403b4e314..6194469e201 100644 --- a/apps/docs/src/guide/creating-a-fuel-dapp/index.md +++ b/apps/docs/src/guide/creating-a-fuel-dapp/index.md @@ -1,3 +1,8 @@ + + # Creating a Fuel dApp `npm create fuels` is a command line tool that helps you scaffold a new full-stack Fuel dApp. In this guide, we will create a new counter dApp using `npm create fuels` and add decrement functionality to it. The final result will look like this: @@ -10,12 +15,12 @@ The first step is to run the command: ::: code-group -```sh [npm] -npm create fuels@0.81.0 +```sh-vue [npm] +npm create fuels{{fuelsInstallVersion}} ``` -```sh [pnpm] -pnpm create fuels@0.81.0 +```sh-vue [pnpm] +pnpm create fuels{{fuelsInstallVersion}} ``` ::: diff --git a/apps/docs/src/guide/creating-a-fuel-dapp/options.md b/apps/docs/src/guide/creating-a-fuel-dapp/options.md index 0dedadd89db..7fe988d6595 100644 --- a/apps/docs/src/guide/creating-a-fuel-dapp/options.md +++ b/apps/docs/src/guide/creating-a-fuel-dapp/options.md @@ -1,15 +1,20 @@ + + # Options The `npm create fuels` command has several command-line options that you can use to customize your project. ::: code-group -```sh [pnpm] -pnpm create fuels@0.81.0 [project-name] [options] +```sh-vue [pnpm] +pnpm create fuels{{fuelsInstallVersion}} [project-name] [options] ``` -```sh [npm] -npm create fuels@0.81.0 [project-name] [options] +```sh-vue [npm] +npm create fuels{{fuelsInstallVersion}} [project-name] [options] ``` ::: diff --git a/apps/docs/src/guide/fuels-cli/binaries.md b/apps/docs/src/guide/fuels-cli/binaries.md index 9766978f04b..7034375b8a6 100644 --- a/apps/docs/src/guide/fuels-cli/binaries.md +++ b/apps/docs/src/guide/fuels-cli/binaries.md @@ -1,3 +1,8 @@ + + # 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/). @@ -13,16 +18,16 @@ Here's how to configure this explicitly: You can also call the `built-in` binaries directly: -```console -npx fuels@0.81.0 help forc -npx fuels@0.81.0 forc --version -npx fuels@0.81.0 forc test -h +```console-vue +npx fuels{{fuelsInstallVersion}} help forc +npx fuels{{fuelsInstallVersion}} forc --version +npx fuels{{fuelsInstallVersion}} forc test -h ``` -```console -npx fuels@0.81.0 help core -npx fuels@0.81.0 core --version -npx fuels@0.81.0 core run -h +```console-vue +npx fuels{{fuelsInstallVersion}} help core +npx fuels{{fuelsInstallVersion}} core --version +npx fuels{{fuelsInstallVersion}} core run -h ``` Check the docs for `forc` and `fuel-core`: diff --git a/apps/docs/src/guide/fuels-cli/commands.md b/apps/docs/src/guide/fuels-cli/commands.md index 0be6497d7be..d293e24123a 100644 --- a/apps/docs/src/guide/fuels-cli/commands.md +++ b/apps/docs/src/guide/fuels-cli/commands.md @@ -1,11 +1,16 @@ + + # Commands The `fuels` CLI consists of a couple commands. ## `fuels init` -```console -npx fuels@0.81.0 help init +```console-vue +npx fuels{{fuelsInstallVersion}} help init ``` ```console @@ -20,13 +25,13 @@ Options: Creating a sample `fuel.config.ts` file: ```console -npx fuels@0.81.0 init --contracts ./my-contracts/* --output ./src/sway-contracts-api +npx fuels{{fuelsInstallVersion}} init --contracts ./my-contracts/* --output ./src/sway-contracts-api ``` Using [Forc workspaces](https://docs.fuel.network/docs/forc/workspaces/)? Try this instead: -```console -npx fuels@0.81.0 init --workspace ./sway-programs --output ./src/sway-programs-api +```console-vue +npx fuels{{fuelsInstallVersion}} init --workspace ./sway-programs --output ./src/sway-programs-api ``` This will give you a minimal configuration: @@ -51,7 +56,7 @@ In a nutshell: ## `fuels build` ```console -npx fuels@0.81.0 help build +npx fuels{{fuelsInstallVersion}} help build ``` ```console @@ -63,15 +68,15 @@ Options: Examples: -```console -npx fuels@0.81.0 build +```console-vue +npx fuels{{fuelsInstallVersion}} 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) -```console -npx fuels@0.81.0 build --deploy +```console-vue +npx fuels{{fuelsInstallVersion}} build --deploy ``` Using the `--deploy` flag will additionally: @@ -83,8 +88,8 @@ Using the `--deploy` flag will additionally: ## `fuels deploy` -```console -npx fuels@0.81.0 deploy +```console-vue +npx fuels{{fuelsInstallVersion}} deploy ``` 1. Deploy all Sway contracts under `workspace` @@ -108,8 +113,8 @@ For a complete example, see: ## `fuels dev` -```console -npx fuels@0.81.0 dev +```console-vue +npx fuels{{fuelsInstallVersion}} dev ``` The `fuels dev` command do three things: @@ -124,8 +129,8 @@ The `fuels dev` command do three things: Manually generates type definitions and factory classes from ABI JSON files. -```console -npx fuels@0.81.0 help typegen +```console-vue +npx fuels{{fuelsInstallVersion}} help typegen ``` ```console @@ -146,8 +151,8 @@ For more info, check: 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. -```console -npx fuels@0.81.0 versions +```console-vue +npx fuels{{fuelsInstallVersion}} versions ``` ``` diff --git a/apps/docs/src/guide/fuels-cli/generating-types.md b/apps/docs/src/guide/fuels-cli/generating-types.md index 9d9b9656fef..9aa3ddda882 100644 --- a/apps/docs/src/guide/fuels-cli/generating-types.md +++ b/apps/docs/src/guide/fuels-cli/generating-types.md @@ -1,11 +1,16 @@ + + # Generating Types from ABI ## Installation First we install `fuels` to our project: -```console -pnpm add fuels@0.81.0 +```console-vue +pnpm add fuels{{fuelsInstallVersion}} ``` ## Help diff --git a/apps/docs/src/guide/fuels-cli/index.md b/apps/docs/src/guide/fuels-cli/index.md index 8241c260cf0..ad101b2327b 100644 --- a/apps/docs/src/guide/fuels-cli/index.md +++ b/apps/docs/src/guide/fuels-cli/index.md @@ -1,3 +1,8 @@ + + # Fuels CLI The quickest way to build full stack Fuel dApps. @@ -32,20 +37,20 @@ Add it to your `my-fuel-dapp` project: ::: code-group -```console [npm] -npm install fuels@0.81.0 --save +```console-vue [npm] +npm install fuels{{fuelsInstallVersion}} --save ``` -```console [pnpm] -pnpm add fuels@0.81.0 +```console-vue [pnpm] +pnpm add fuels{{fuelsInstallVersion}} ``` ::: ## Double-checking -```console -npx fuels@0.81.0 -v +```console-vue +npx fuels{{fuelsInstallVersion}} -v ``` ## Next Step diff --git a/apps/docs/src/index.md b/apps/docs/src/index.md index 2cd470823cb..d1f7191ebdd 100644 --- a/apps/docs/src/index.md +++ b/apps/docs/src/index.md @@ -1,6 +1,6 @@ @@ -32,12 +32,12 @@ Learn more about the Fuel Ecosystem. ::: code-group -```sh [pnpm] -pnpm add fuels@0.81.0 +```sh-vue [pnpm] +pnpm add fuels{{fuelsInstallVersion}} ``` -```sh [npm] -npm install fuels@0.81.0 --save +```sh-vue [npm] +npm install fuels{{fuelsInstallVersion}} --save ``` ::: diff --git a/apps/docs/src/versions.data.ts b/apps/docs/src/versions.data.ts index acc53e24bca..4277826de69 100644 --- a/apps/docs/src/versions.data.ts +++ b/apps/docs/src/versions.data.ts @@ -8,6 +8,7 @@ export default { forc: FORC, fuels: FUELS, fuelCore: FUEL_CORE, + fuelsInstallVersion: '@0.81.0', }; }, }; From 9810efa5c07b791b88dc2d46484ce15852aed82b Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 17:36:37 +0100 Subject: [PATCH 77/92] Finalised fuels install version --- apps/docs/src/getting-started.md | 6 +++--- .../src/guide/creating-a-fuel-dapp/index.md | 4 ++-- .../src/guide/creating-a-fuel-dapp/options.md | 4 ++-- apps/docs/src/guide/fuels-cli/binaries.md | 12 +++++------ apps/docs/src/guide/fuels-cli/commands.md | 20 +++++++++---------- .../src/guide/fuels-cli/generating-types.md | 2 +- apps/docs/src/guide/fuels-cli/index.md | 6 +++--- apps/docs/src/index.md | 4 ++-- apps/docs/src/versions.data.ts | 2 +- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/apps/docs/src/getting-started.md b/apps/docs/src/getting-started.md index 256c6713f4d..91563514b81 100644 --- a/apps/docs/src/getting-started.md +++ b/apps/docs/src/getting-started.md @@ -18,16 +18,16 @@ To begin, you need to add the `fuels` dependency to your project. You can do thi ::: code-group ```sh-vue [npm] -npm install fuels{{fuelsInstallVersion}} --save +npm install fuels@{{fuelsInstallVersion}} --save ``` ```sh-vue [pnpm] -pnpm add fuels{{fuelsInstallVersion}} +pnpm add fuels@{{fuelsInstallVersion}} ``` ::: -**Note**: We use `{{fuelsInstallVersion}}` to ensure compatibility with our latest testnet. +**Note**: We use `@{{fuelsInstallVersion}}` to ensure compatibility with our latest testnet. ### Note diff --git a/apps/docs/src/guide/creating-a-fuel-dapp/index.md b/apps/docs/src/guide/creating-a-fuel-dapp/index.md index 6194469e201..87765e05a81 100644 --- a/apps/docs/src/guide/creating-a-fuel-dapp/index.md +++ b/apps/docs/src/guide/creating-a-fuel-dapp/index.md @@ -16,11 +16,11 @@ The first step is to run the command: ::: code-group ```sh-vue [npm] -npm create fuels{{fuelsInstallVersion}} +npm create fuels@{{fuelsInstallVersion}} ``` ```sh-vue [pnpm] -pnpm create fuels{{fuelsInstallVersion}} +pnpm create fuels@{{fuelsInstallVersion}} ``` ::: diff --git a/apps/docs/src/guide/creating-a-fuel-dapp/options.md b/apps/docs/src/guide/creating-a-fuel-dapp/options.md index 7fe988d6595..51e4a575f9e 100644 --- a/apps/docs/src/guide/creating-a-fuel-dapp/options.md +++ b/apps/docs/src/guide/creating-a-fuel-dapp/options.md @@ -10,11 +10,11 @@ The `npm create fuels` command has several command-line options that you can use ::: code-group ```sh-vue [pnpm] -pnpm create fuels{{fuelsInstallVersion}} [project-name] [options] +pnpm create fuels@{{fuelsInstallVersion}} [project-name] [options] ``` ```sh-vue [npm] -npm create fuels{{fuelsInstallVersion}} [project-name] [options] +npm create fuels@{{fuelsInstallVersion}} [project-name] [options] ``` ::: diff --git a/apps/docs/src/guide/fuels-cli/binaries.md b/apps/docs/src/guide/fuels-cli/binaries.md index 7034375b8a6..42d1d8c3b98 100644 --- a/apps/docs/src/guide/fuels-cli/binaries.md +++ b/apps/docs/src/guide/fuels-cli/binaries.md @@ -19,15 +19,15 @@ Here's how to configure this explicitly: You can also call the `built-in` binaries directly: ```console-vue -npx fuels{{fuelsInstallVersion}} help forc -npx fuels{{fuelsInstallVersion}} forc --version -npx fuels{{fuelsInstallVersion}} forc test -h +npx fuels@{{fuelsInstallVersion}} help forc +npx fuels@{{fuelsInstallVersion}} forc --version +npx fuels@{{fuelsInstallVersion}} forc test -h ``` ```console-vue -npx fuels{{fuelsInstallVersion}} help core -npx fuels{{fuelsInstallVersion}} core --version -npx fuels{{fuelsInstallVersion}} core run -h +npx fuels@{{fuelsInstallVersion}} help core +npx fuels@{{fuelsInstallVersion}} core --version +npx fuels@{{fuelsInstallVersion}} core run -h ``` Check the docs for `forc` and `fuel-core`: diff --git a/apps/docs/src/guide/fuels-cli/commands.md b/apps/docs/src/guide/fuels-cli/commands.md index d293e24123a..724f35eefbe 100644 --- a/apps/docs/src/guide/fuels-cli/commands.md +++ b/apps/docs/src/guide/fuels-cli/commands.md @@ -10,7 +10,7 @@ The `fuels` CLI consists of a couple commands. ## `fuels init` ```console-vue -npx fuels{{fuelsInstallVersion}} help init +npx fuels@{{fuelsInstallVersion}} help init ``` ```console @@ -25,13 +25,13 @@ Options: Creating a sample `fuel.config.ts` file: ```console -npx fuels{{fuelsInstallVersion}} init --contracts ./my-contracts/* --output ./src/sway-contracts-api +npx fuels@{{fuelsInstallVersion}} init --contracts ./my-contracts/* --output ./src/sway-contracts-api ``` Using [Forc workspaces](https://docs.fuel.network/docs/forc/workspaces/)? Try this instead: ```console-vue -npx fuels{{fuelsInstallVersion}} init --workspace ./sway-programs --output ./src/sway-programs-api +npx fuels@{{fuelsInstallVersion}} init --workspace ./sway-programs --output ./src/sway-programs-api ``` This will give you a minimal configuration: @@ -56,7 +56,7 @@ In a nutshell: ## `fuels build` ```console -npx fuels{{fuelsInstallVersion}} help build +npx fuels@{{fuelsInstallVersion}} help build ``` ```console @@ -69,14 +69,14 @@ Options: Examples: ```console-vue -npx fuels{{fuelsInstallVersion}} build +npx fuels@{{fuelsInstallVersion}} 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) ```console-vue -npx fuels{{fuelsInstallVersion}} build --deploy +npx fuels@{{fuelsInstallVersion}} build --deploy ``` Using the `--deploy` flag will additionally: @@ -89,7 +89,7 @@ Using the `--deploy` flag will additionally: ## `fuels deploy` ```console-vue -npx fuels{{fuelsInstallVersion}} deploy +npx fuels@{{fuelsInstallVersion}} deploy ``` 1. Deploy all Sway contracts under `workspace` @@ -114,7 +114,7 @@ For a complete example, see: ## `fuels dev` ```console-vue -npx fuels{{fuelsInstallVersion}} dev +npx fuels@{{fuelsInstallVersion}} dev ``` The `fuels dev` command do three things: @@ -130,7 +130,7 @@ The `fuels dev` command do three things: Manually generates type definitions and factory classes from ABI JSON files. ```console-vue -npx fuels{{fuelsInstallVersion}} help typegen +npx fuels@{{fuelsInstallVersion}} help typegen ``` ```console @@ -152,7 +152,7 @@ For more info, check: 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. ```console-vue -npx fuels{{fuelsInstallVersion}} versions +npx fuels@{{fuelsInstallVersion}} versions ``` ``` diff --git a/apps/docs/src/guide/fuels-cli/generating-types.md b/apps/docs/src/guide/fuels-cli/generating-types.md index 9aa3ddda882..2622c138615 100644 --- a/apps/docs/src/guide/fuels-cli/generating-types.md +++ b/apps/docs/src/guide/fuels-cli/generating-types.md @@ -10,7 +10,7 @@ First we install `fuels` to our project: ```console-vue -pnpm add fuels{{fuelsInstallVersion}} +pnpm add fuels@{{fuelsInstallVersion}} ``` ## Help diff --git a/apps/docs/src/guide/fuels-cli/index.md b/apps/docs/src/guide/fuels-cli/index.md index ad101b2327b..f3324093288 100644 --- a/apps/docs/src/guide/fuels-cli/index.md +++ b/apps/docs/src/guide/fuels-cli/index.md @@ -38,11 +38,11 @@ Add it to your `my-fuel-dapp` project: ::: code-group ```console-vue [npm] -npm install fuels{{fuelsInstallVersion}} --save +npm install fuels@{{fuelsInstallVersion}} --save ``` ```console-vue [pnpm] -pnpm add fuels{{fuelsInstallVersion}} +pnpm add fuels@{{fuelsInstallVersion}} ``` ::: @@ -50,7 +50,7 @@ pnpm add fuels{{fuelsInstallVersion}} ## Double-checking ```console-vue -npx fuels{{fuelsInstallVersion}} -v +npx fuels@{{fuelsInstallVersion}} -v ``` ## Next Step diff --git a/apps/docs/src/index.md b/apps/docs/src/index.md index d1f7191ebdd..0863a93ce8c 100644 --- a/apps/docs/src/index.md +++ b/apps/docs/src/index.md @@ -33,11 +33,11 @@ Learn more about the Fuel Ecosystem. ::: code-group ```sh-vue [pnpm] -pnpm add fuels{{fuelsInstallVersion}} +pnpm add fuels@{{fuelsInstallVersion}} ``` ```sh-vue [npm] -npm install fuels{{fuelsInstallVersion}} --save +npm install fuels@{{fuelsInstallVersion}} --save ``` ::: diff --git a/apps/docs/src/versions.data.ts b/apps/docs/src/versions.data.ts index 4277826de69..cdf37d9b2e8 100644 --- a/apps/docs/src/versions.data.ts +++ b/apps/docs/src/versions.data.ts @@ -8,7 +8,7 @@ export default { forc: FORC, fuels: FUELS, fuelCore: FUEL_CORE, - fuelsInstallVersion: '@0.81.0', + fuelsInstallVersion: '0.81.0', }; }, }; From 80eeb7416410fc05eb3d373c6366ae8115b87a3f Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 17:37:07 +0100 Subject: [PATCH 78/92] Reverted changes to fuels template version --- packages/create-fuels/scripts/rewriteTemplatePackageJson.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts b/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts index 9f400839361..907be434c6f 100644 --- a/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts +++ b/packages/create-fuels/scripts/rewriteTemplatePackageJson.ts @@ -1,12 +1,12 @@ +import { versions } from '@fuel-ts/versions'; import { readFileSync, writeFileSync } from 'fs'; import { join } from 'path'; -const fuelsVersion = '0.81.0'; 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": "${fuelsVersion}"`); +contents = contents.replace(/"fuels": "workspace:\*"/, `"fuels": "${versions.FUELS}"`); writeFileSync(filepath, contents); From ba5526191a50ebbfd87ef20433da2c64b1ceabeb Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 17:38:14 +0100 Subject: [PATCH 79/92] Removed @ prefix from note about version --- apps/docs/src/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/src/getting-started.md b/apps/docs/src/getting-started.md index 91563514b81..467ae08f4b5 100644 --- a/apps/docs/src/getting-started.md +++ b/apps/docs/src/getting-started.md @@ -27,7 +27,7 @@ pnpm add fuels@{{fuelsInstallVersion}} ::: -**Note**: We use `@{{fuelsInstallVersion}}` to ensure compatibility with our latest testnet. +**Note**: We use `{{fuelsInstallVersion}}` to ensure compatibility with our latest testnet. ### Note From f09161057ea0ebce6f22cab7920fd8e4a74ac107 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 18:16:27 +0100 Subject: [PATCH 80/92] Added verbose note Co-authored-by: Anderson Arboleya --- apps/docs/src/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/src/getting-started.md b/apps/docs/src/getting-started.md index 467ae08f4b5..1879d545fe2 100644 --- a/apps/docs/src/getting-started.md +++ b/apps/docs/src/getting-started.md @@ -27,7 +27,7 @@ pnpm add fuels@{{fuelsInstallVersion}} ::: -**Note**: We use `{{fuelsInstallVersion}}` to ensure compatibility with our latest testnet. +**Note**: Use version `{{fuelsInstallVersion}}` to ensure compatibility with `beta-5` network—check the [docs](https://docs.fuel.network/guides/installation/#using-the-latest-toolchain). ### Note From 3c6286e886e824bb45e3f79b3e4d4ea290c64d6d Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 18:19:02 +0100 Subject: [PATCH 81/92] Altered version to accept patches Co-authored-by: Anderson Arboleya --- apps/docs/src/versions.data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/src/versions.data.ts b/apps/docs/src/versions.data.ts index cdf37d9b2e8..b71d4848bc1 100644 --- a/apps/docs/src/versions.data.ts +++ b/apps/docs/src/versions.data.ts @@ -8,7 +8,7 @@ export default { forc: FORC, fuels: FUELS, fuelCore: FUEL_CORE, - fuelsInstallVersion: '0.81.0', + fuelsInstallVersion: '~0.81.0', }; }, }; From a2152e44e17a217cbb642b5c3fe790e55e2b6844 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 23 Apr 2024 18:24:30 +0100 Subject: [PATCH 82/92] Updated install version 0.82.0 --- apps/docs/src/versions.data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/src/versions.data.ts b/apps/docs/src/versions.data.ts index b71d4848bc1..69e5a1ba888 100644 --- a/apps/docs/src/versions.data.ts +++ b/apps/docs/src/versions.data.ts @@ -8,7 +8,7 @@ export default { forc: FORC, fuels: FUELS, fuelCore: FUEL_CORE, - fuelsInstallVersion: '~0.81.0', + fuelsInstallVersion: '~0.82.0', }; }, }; From 1d5fc2ba6e7faa597881ddfcfaa7974b5c644d1f Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Wed, 24 Apr 2024 11:07:29 +0100 Subject: [PATCH 83/92] test: used named constant for tx id tx request test --- .../src/guide/transactions/transaction-request.test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 27abdad1afc..76a288eff90 100644 --- a/apps/docs-snippets/src/guide/transactions/transaction-request.test.ts +++ b/apps/docs-snippets/src/guide/transactions/transaction-request.test.ts @@ -189,11 +189,12 @@ describe('Transaction Request', () => { // Get the transaction ID using the Chain ID const transactionId = transactionRequest.getTransactionId(chainId); - // TX ID: 0x55667d... + // TX ID: 0x420f6... // #endregion transaction-request-7 - expect(transactionId).toBe( - '0x420f6093f32975eec3bd505e1a124be5e7352146841017b6142b34923e563f4b' - ); + const expectedTransactionId = + '0x420f6093f32975eec3bd505e1a124be5e7352146841017b6142b34923e563f4b'; + + expect(transactionId).toBe(expectedTransactionId); }); }); From c52b728028aa412f83ba92ec2e60ea8938caca51 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Wed, 24 Apr 2024 11:30:45 +0100 Subject: [PATCH 84/92] chore: changeset --- .changeset/calm-mails-wash.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .changeset/calm-mails-wash.md diff --git a/.changeset/calm-mails-wash.md b/.changeset/calm-mails-wash.md new file mode 100644 index 00000000000..e8c87fa4801 --- /dev/null +++ b/.changeset/calm-mails-wash.md @@ -0,0 +1,9 @@ +--- +"@fuel-ts/abi-typegen": minor +"@fuel-ts/abi-coder": minor +"@fuel-ts/program": minor +"@fuel-ts/script": minor +"@fuel-ts/utils": minor +--- + +feat!: enabling v1 encoding for everything From d529874a1ef479bd1916ca4533d82651295349ab Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Wed, 24 Apr 2024 17:16:18 -0300 Subject: [PATCH 85/92] Rolling back verbosity increase --- turbo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/turbo.json b/turbo.json index 991e47cef2f..a6c52157e42 100644 --- a/turbo.json +++ b/turbo.json @@ -18,7 +18,7 @@ "outputMode": "new-only" }, "pretest": { - "outputMode": "new-only", + "outputMode": "error-only", "inputs": [ "**/test/fixtures/forc-projects/Forc.toml", "**/test/fixtures/forc-projects/**/src/*.sw", From c13e1489ac9ccc2fda0de86168bebdba637cd731 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Wed, 24 Apr 2024 17:17:33 -0300 Subject: [PATCH 86/92] Tyop --- turbo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/turbo.json b/turbo.json index a6c52157e42..84c492502b6 100644 --- a/turbo.json +++ b/turbo.json @@ -18,7 +18,7 @@ "outputMode": "new-only" }, "pretest": { - "outputMode": "error-only", + "outputMode": "errors-only", "inputs": [ "**/test/fixtures/forc-projects/Forc.toml", "**/test/fixtures/forc-projects/**/src/*.sw", From a5b140727539c1958539641511d48eb8a64ef3bd Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 25 Apr 2024 14:33:16 +0100 Subject: [PATCH 87/92] Removed `fuelsInstallVersion` --- apps/docs/src/getting-started.md | 8 +++---- .../src/guide/creating-a-fuel-dapp/index.md | 6 ++--- .../src/guide/creating-a-fuel-dapp/options.md | 6 ++--- apps/docs/src/guide/fuels-cli/binaries.md | 14 ++++++------ apps/docs/src/guide/fuels-cli/commands.md | 22 +++++++++---------- .../src/guide/fuels-cli/generating-types.md | 4 ++-- apps/docs/src/guide/fuels-cli/index.md | 8 +++---- apps/docs/src/index.md | 6 ++--- apps/docs/src/versions.data.ts | 1 - 9 files changed, 37 insertions(+), 38 deletions(-) diff --git a/apps/docs/src/getting-started.md b/apps/docs/src/getting-started.md index 1879d545fe2..3ef7dbd7450 100644 --- a/apps/docs/src/getting-started.md +++ b/apps/docs/src/getting-started.md @@ -1,6 +1,6 @@ # Getting Started @@ -18,16 +18,16 @@ To begin, you need to add the `fuels` dependency to your project. You can do thi ::: code-group ```sh-vue [npm] -npm install fuels@{{fuelsInstallVersion}} --save +npm install fuels@{{fuels}} --save ``` ```sh-vue [pnpm] -pnpm add fuels@{{fuelsInstallVersion}} +pnpm add fuels@{{fuels}} ``` ::: -**Note**: Use version `{{fuelsInstallVersion}}` to ensure compatibility with `beta-5` network—check the [docs](https://docs.fuel.network/guides/installation/#using-the-latest-toolchain). +**Note**: Use version `{{fuels}}` to ensure compatibility with `beta-5` network—check the [docs](https://docs.fuel.network/guides/installation/#using-the-latest-toolchain). ### Note diff --git a/apps/docs/src/guide/creating-a-fuel-dapp/index.md b/apps/docs/src/guide/creating-a-fuel-dapp/index.md index 87765e05a81..564683bf4ca 100644 --- a/apps/docs/src/guide/creating-a-fuel-dapp/index.md +++ b/apps/docs/src/guide/creating-a-fuel-dapp/index.md @@ -1,6 +1,6 @@ # Creating a Fuel dApp @@ -16,11 +16,11 @@ The first step is to run the command: ::: code-group ```sh-vue [npm] -npm create fuels@{{fuelsInstallVersion}} +npm create fuels@{{fuels}} ``` ```sh-vue [pnpm] -pnpm create fuels@{{fuelsInstallVersion}} +pnpm create fuels@{{fuels}} ``` ::: diff --git a/apps/docs/src/guide/creating-a-fuel-dapp/options.md b/apps/docs/src/guide/creating-a-fuel-dapp/options.md index 51e4a575f9e..4de2e8917d9 100644 --- a/apps/docs/src/guide/creating-a-fuel-dapp/options.md +++ b/apps/docs/src/guide/creating-a-fuel-dapp/options.md @@ -1,6 +1,6 @@ # Options @@ -10,11 +10,11 @@ The `npm create fuels` command has several command-line options that you can use ::: code-group ```sh-vue [pnpm] -pnpm create fuels@{{fuelsInstallVersion}} [project-name] [options] +pnpm create fuels@{{fuels}} [project-name] [options] ``` ```sh-vue [npm] -npm create fuels@{{fuelsInstallVersion}} [project-name] [options] +npm create fuels@{{fuels}} [project-name] [options] ``` ::: diff --git a/apps/docs/src/guide/fuels-cli/binaries.md b/apps/docs/src/guide/fuels-cli/binaries.md index 42d1d8c3b98..e70d1d798e5 100644 --- a/apps/docs/src/guide/fuels-cli/binaries.md +++ b/apps/docs/src/guide/fuels-cli/binaries.md @@ -1,6 +1,6 @@ # Built-In Binaries @@ -19,15 +19,15 @@ Here's how to configure this explicitly: You can also call the `built-in` binaries directly: ```console-vue -npx fuels@{{fuelsInstallVersion}} help forc -npx fuels@{{fuelsInstallVersion}} forc --version -npx fuels@{{fuelsInstallVersion}} forc test -h +npx fuels@{{fuels}} help forc +npx fuels@{{fuels}} forc --version +npx fuels@{{fuels}} forc test -h ``` ```console-vue -npx fuels@{{fuelsInstallVersion}} help core -npx fuels@{{fuelsInstallVersion}} core --version -npx fuels@{{fuelsInstallVersion}} core run -h +npx fuels@{{fuels}} help core +npx fuels@{{fuels}} core --version +npx fuels@{{fuels}} core run -h ``` Check the docs for `forc` and `fuel-core`: diff --git a/apps/docs/src/guide/fuels-cli/commands.md b/apps/docs/src/guide/fuels-cli/commands.md index 724f35eefbe..64f62e94daa 100644 --- a/apps/docs/src/guide/fuels-cli/commands.md +++ b/apps/docs/src/guide/fuels-cli/commands.md @@ -1,6 +1,6 @@ # Commands @@ -10,7 +10,7 @@ The `fuels` CLI consists of a couple commands. ## `fuels init` ```console-vue -npx fuels@{{fuelsInstallVersion}} help init +npx fuels@{{fuels}} help init ``` ```console @@ -25,13 +25,13 @@ Options: Creating a sample `fuel.config.ts` file: ```console -npx fuels@{{fuelsInstallVersion}} init --contracts ./my-contracts/* --output ./src/sway-contracts-api +npx fuels@{{fuels}} init --contracts ./my-contracts/* --output ./src/sway-contracts-api ``` Using [Forc workspaces](https://docs.fuel.network/docs/forc/workspaces/)? Try this instead: ```console-vue -npx fuels@{{fuelsInstallVersion}} init --workspace ./sway-programs --output ./src/sway-programs-api +npx fuels@{{fuels}} init --workspace ./sway-programs --output ./src/sway-programs-api ``` This will give you a minimal configuration: @@ -56,7 +56,7 @@ In a nutshell: ## `fuels build` ```console -npx fuels@{{fuelsInstallVersion}} help build +npx fuels@{{fuels}} help build ``` ```console @@ -69,14 +69,14 @@ Options: Examples: ```console-vue -npx fuels@{{fuelsInstallVersion}} build +npx fuels@{{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) ```console-vue -npx fuels@{{fuelsInstallVersion}} build --deploy +npx fuels@{{fuels}} build --deploy ``` Using the `--deploy` flag will additionally: @@ -89,7 +89,7 @@ Using the `--deploy` flag will additionally: ## `fuels deploy` ```console-vue -npx fuels@{{fuelsInstallVersion}} deploy +npx fuels@{{fuels}} deploy ``` 1. Deploy all Sway contracts under `workspace` @@ -114,7 +114,7 @@ For a complete example, see: ## `fuels dev` ```console-vue -npx fuels@{{fuelsInstallVersion}} dev +npx fuels@{{fuels}} dev ``` The `fuels dev` command do three things: @@ -130,7 +130,7 @@ The `fuels dev` command do three things: Manually generates type definitions and factory classes from ABI JSON files. ```console-vue -npx fuels@{{fuelsInstallVersion}} help typegen +npx fuels@{{fuels}} help typegen ``` ```console @@ -152,7 +152,7 @@ For more info, check: 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. ```console-vue -npx fuels@{{fuelsInstallVersion}} versions +npx fuels@{{fuels}} versions ``` ``` diff --git a/apps/docs/src/guide/fuels-cli/generating-types.md b/apps/docs/src/guide/fuels-cli/generating-types.md index 2622c138615..aa3dbd78f3b 100644 --- a/apps/docs/src/guide/fuels-cli/generating-types.md +++ b/apps/docs/src/guide/fuels-cli/generating-types.md @@ -1,6 +1,6 @@ # Generating Types from ABI @@ -10,7 +10,7 @@ First we install `fuels` to our project: ```console-vue -pnpm add fuels@{{fuelsInstallVersion}} +pnpm add fuels@{{fuels}} ``` ## Help diff --git a/apps/docs/src/guide/fuels-cli/index.md b/apps/docs/src/guide/fuels-cli/index.md index f3324093288..835261e3736 100644 --- a/apps/docs/src/guide/fuels-cli/index.md +++ b/apps/docs/src/guide/fuels-cli/index.md @@ -1,6 +1,6 @@ # Fuels CLI @@ -38,11 +38,11 @@ Add it to your `my-fuel-dapp` project: ::: code-group ```console-vue [npm] -npm install fuels@{{fuelsInstallVersion}} --save +npm install fuels@{{fuels}} --save ``` ```console-vue [pnpm] -pnpm add fuels@{{fuelsInstallVersion}} +pnpm add fuels@{{fuels}} ``` ::: @@ -50,7 +50,7 @@ pnpm add fuels@{{fuelsInstallVersion}} ## Double-checking ```console-vue -npx fuels@{{fuelsInstallVersion}} -v +npx fuels@{{fuels}} -v ``` ## Next Step diff --git a/apps/docs/src/index.md b/apps/docs/src/index.md index 0863a93ce8c..76c91c85161 100644 --- a/apps/docs/src/index.md +++ b/apps/docs/src/index.md @@ -1,6 +1,6 @@ @@ -33,11 +33,11 @@ Learn more about the Fuel Ecosystem. ::: code-group ```sh-vue [pnpm] -pnpm add fuels@{{fuelsInstallVersion}} +pnpm add fuels@{{fuels}} ``` ```sh-vue [npm] -npm install fuels@{{fuelsInstallVersion}} --save +npm install fuels@{{fuels}} --save ``` ::: diff --git a/apps/docs/src/versions.data.ts b/apps/docs/src/versions.data.ts index 69e5a1ba888..acc53e24bca 100644 --- a/apps/docs/src/versions.data.ts +++ b/apps/docs/src/versions.data.ts @@ -8,7 +8,6 @@ export default { forc: FORC, fuels: FUELS, fuelCore: FUEL_CORE, - fuelsInstallVersion: '~0.82.0', }; }, }; From 6896e59c27961142976c88c90b17615a97191a91 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 25 Apr 2024 14:37:54 +0100 Subject: [PATCH 88/92] Update apps/docs/src/guide/fuels-cli/commands.md --- apps/docs/src/guide/fuels-cli/commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/src/guide/fuels-cli/commands.md b/apps/docs/src/guide/fuels-cli/commands.md index 64f62e94daa..8fed05041a9 100644 --- a/apps/docs/src/guide/fuels-cli/commands.md +++ b/apps/docs/src/guide/fuels-cli/commands.md @@ -24,7 +24,7 @@ Options: Creating a sample `fuel.config.ts` file: -```console +```console-vue npx fuels@{{fuels}} init --contracts ./my-contracts/* --output ./src/sway-contracts-api ``` From c57b6c976c619fdc1cd4b9e372de1e9102656170 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Thu, 25 Apr 2024 14:38:04 +0100 Subject: [PATCH 89/92] Update apps/docs/src/guide/fuels-cli/commands.md --- apps/docs/src/guide/fuels-cli/commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/src/guide/fuels-cli/commands.md b/apps/docs/src/guide/fuels-cli/commands.md index 8fed05041a9..20aa0f683c7 100644 --- a/apps/docs/src/guide/fuels-cli/commands.md +++ b/apps/docs/src/guide/fuels-cli/commands.md @@ -55,7 +55,7 @@ In a nutshell: ## `fuels build` -```console +```console-vue npx fuels@{{fuels}} help build ``` From bdebab4dc8e13182201b9cc30355883360d44229 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 25 Apr 2024 16:17:28 +0100 Subject: [PATCH 90/92] chore: fix changeset --- .changeset/calm-mails-wash.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/.changeset/calm-mails-wash.md b/.changeset/calm-mails-wash.md index e8c87fa4801..529fc6f735c 100644 --- a/.changeset/calm-mails-wash.md +++ b/.changeset/calm-mails-wash.md @@ -1,9 +1,6 @@ --- -"@fuel-ts/abi-typegen": minor "@fuel-ts/abi-coder": minor "@fuel-ts/program": minor -"@fuel-ts/script": minor -"@fuel-ts/utils": minor --- feat!: enabling v1 encoding for everything From be3accd9594a4b2be5d061fbfdf0b8451d802cb2 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 25 Apr 2024 13:44:13 -0300 Subject: [PATCH 91/92] Using hardcoded snippet temporarily --- apps/docs/src/guide/types/vectors.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/docs/src/guide/types/vectors.md b/apps/docs/src/guide/types/vectors.md index f0a9925593a..16f4af4dd6a 100644 --- a/apps/docs/src/guide/types/vectors.md +++ b/apps/docs/src/guide/types/vectors.md @@ -26,7 +26,28 @@ Some Sway functions require you to pass in bytecode to the function. The type of Take the `compute_bytecode_root` function from the [`bytecode` Sway library](https://github.com/FuelLabs/sway-libs/tree/master/libs/src/bytecode.sw), for example. -<<< @/../../docs-snippets/test/fixtures/forc-projects/bytecode-input/src/main.sw#vector-bytecode-input-sway{ts:line-numbers} + + + + +```rust +contract; + +use bytecode::*; + +abi MyContract { + fn compute_bytecode_root(bytecode_input: Vec) -> b256; +} + +impl MyContract for Contract { + // #region vector-bytecode-input-sway + fn compute_bytecode_root(bytecode_input: Vec) -> bool { + let root = compute_bytecode_root(bytecode_input); + return root; + } + // #endregion vector-bytecode-input-sway +} +``` 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: From b6b0a872956bed4e4181e0f270ef35774f3cdaa4 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 25 Apr 2024 13:45:53 -0300 Subject: [PATCH 92/92] Removing region notations from hardcoded snippet --- apps/docs/src/guide/types/vectors.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/docs/src/guide/types/vectors.md b/apps/docs/src/guide/types/vectors.md index 16f4af4dd6a..19f771b943b 100644 --- a/apps/docs/src/guide/types/vectors.md +++ b/apps/docs/src/guide/types/vectors.md @@ -40,12 +40,10 @@ abi MyContract { } impl MyContract for Contract { - // #region vector-bytecode-input-sway fn compute_bytecode_root(bytecode_input: Vec) -> bool { let root = compute_bytecode_root(bytecode_input); return root; } - // #endregion vector-bytecode-input-sway } ```