Skip to content

Commit

Permalink
chore!: upgrading forc to 0.55.0 (#2045)
Browse files Browse the repository at this point in the history
  • Loading branch information
arboleya authored Apr 25, 2024
1 parent 267fc8d commit 0d75266
Show file tree
Hide file tree
Showing 47 changed files with 225 additions and 227 deletions.
9 changes: 9 additions & 0 deletions .changeset/ninety-hotels-impress.md
Original file line number Diff line number Diff line change
@@ -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.55.0`
18 changes: 0 additions & 18 deletions .github/actions/test-setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe(__filename, () => {
});

const asset: AssetId = {
value: BaseAssetId,
bits: BaseAssetId,
};

await contract.functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,23 +177,23 @@ 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 };

// Instantiate the 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);
// TX ID: 0x55667d...
// #endregion transaction-request-7

expect(transactionId).toBe(
'0x35cd6a10e917d5d0223413c1fb9863d27da40e5d602a7f37cfbcefb570172f6c'
'0x8a1a2bb529db20cdd8f35a8b6e00b0440629712fa891fa29232a396982be3d15'
);
});
});
10 changes: 5 additions & 5 deletions apps/docs-snippets/src/guide/types/asset-id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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();
Expand All @@ -62,14 +62,14 @@ describe('AssetId', () => {
// #import { AssetId };

const assetId: AssetId = {
value: Bits256,
bits: Bits256,
};

const { value } = await contract.functions.echo_asset_id().simulate();

expect(value).toEqual(assetId);
// #endregion asset-id-4

expect(value.value).toEqual(Bits256);
expect(value.bits).toEqual(Bits256);
});
});
20 changes: 10 additions & 10 deletions apps/docs-snippets/src/guide/types/contract-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ 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);
});

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);
Expand All @@ -49,28 +49,28 @@ 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();

// #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);
Expand All @@ -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);
Expand Down
16 changes: 7 additions & 9 deletions apps/docs-snippets/src/guide/types/evm-address.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,20 @@ describe('EvMAddress', () => {
// #import { EvmAddress };

const evmAddress: EvmAddress = {
value: Bits256,
bits: Bits256,
};
// #endregion evm-address-1

// #region addresses-3
// #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 () => {
Expand All @@ -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();
Expand All @@ -74,14 +72,14 @@ describe('EvMAddress', () => {
// #import { EvmAddress };

const evmAddress: EvmAddress = {
value: Bits256,
bits: Bits256,
};

const { value } = await contract.functions.echo_address().simulate();

expect(value).toEqual(evmAddress);
// #endregion evm-address-4

expect(value.value).toEqual(Bits256);
expect(value.bits).toEqual(Bits256);
});
});
3 changes: 2 additions & 1 deletion apps/docs-snippets/src/guide/types/vector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ authors = ["Fuel Labs <[email protected]>"]
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" }
Original file line number Diff line number Diff line change
@@ -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<u8>) -> b256;
// fn compute_bytecode_root(bytecode_input: Vec<u8>) -> b256;
fn compute_bytecode_root(bytecode_input: Vec<u8>) -> bool;
}

impl MyContract for Contract {
// #region vector-bytecode-input-sway
fn compute_bytecode_root(bytecode_input: Vec<u8>) -> b256 {
let root = compute_bytecode_root(bytecode_input);
return root;
fn compute_bytecode_root(bytecode_input: Vec<u8>) -> bool {
// let root = compute_bytecode_root(bytecode_input);
// return root;
return true;
}
// #endregion vector-bytecode-input-sway
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};

Expand Down
21 changes: 20 additions & 1 deletion apps/docs/src/guide/types/vectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,26 @@ 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}
<!-- <<< @/../../docs-snippets/test/fixtures/forc-projects/bytecode-input/src/main.sw#vector-bytecode-input-sway{ts:line-numbers} -->

<!-- TODO: Uncomment swap hardcoded snippet -->

```rust
contract;

use bytecode::*;

abi MyContract {
fn compute_bytecode_root(bytecode_input: Vec<u8>) -> b256;
}

impl MyContract for Contract {
fn compute_bytecode_root(bytecode_input: Vec<u8>) -> bool {
let root = compute_bytecode_root(bytecode_input);
return root;
}
}
```

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<u8>` type and pass it the function like so:

Expand Down
Loading

0 comments on commit 0d75266

Please sign in to comment.