Skip to content

v0.98.0

Latest
Compare
Choose a tag to compare
@fuel-service-user fuel-service-user released this 10 Jan 16:53
· 4 commits to master since this release
d633eaf

Summary

In this release, we:

  • Added method fromInstance to the Predicate class
  • Added auto-detection for the user's package manager of choice for create fuels
  • Made Provider constructor public and sync again
  • Added support for --fuel-core-port flag in fuels init command
  • Added the autoCost method to easily estimate and fund transactions
  • Migrated fundWithRequiredCoins -> autoCost for contract and script calls
  • Improved speed in assembling result for settled transactions
  • Added a guard to sendTransaction to ensure that we prevent implicit asset burns
  • Fixed an issue when using multiple paths (or globals) in fuels init
  • Improved validation and handling of unsafe integers in BigNumberCoder
  • Upgraded fuel-core to 0.40.2
  • Removed unused operations from OperationName enum
  • Remove receipts deprecated properties
  • Removed all receipt coders
  • Removed all instances of Bech32 address format in favour of B256
  • Removed the AbstractAddress in favour of the Address class
  • Improved Getting Started docs and repo README, focusing on Mainnet
  • Added documentation on optimizing frontend apps through transaction pre-loading

Breaking


Features

Fixes

Chores

Docs


Migration Notes

Features

#3514 - Making provider initialization sync again

1. Provider Instantiation

  • Going from async to sync
// before
const provider = await Provider.create(NETWORK_URL);
// after
const provider = new Provider(NETWORK_URL);

2. Provider methods

  • The following methods are now async
// before
provider.getNode();
provider.getChain();
provider.getChainId();
provider.getBaseAssetId();
provider.getGasConfig();
provider.validateTransaction();
// after
await provider.getNode();
await provider.getChain();
await provider.getChainId();
await provider.getBaseAssetId();
await provider.getGasConfig();
await provider.validateTransaction();

3. TransferParams and ContractTransferParams

export type TransferParams = {
  destination: string | AbstractAddress;
  amount: BigNumberish;
-  assetId?: BytesLike;
+  assetId: BytesLike;
};

export type ContractTransferParams = {
  contractId: string | AbstractAddress;
  amount: BigNumberish;
-  assetId?: BytesLike;
+  assetId: BytesLike;
};

4. Transaction Response

  • The constructor now requires a chainId
// before
new TransactionResponse('0x..', provider);
// after
new TransactionResponse('0x..', provider, chainId);

#3539 - autoCost for transaction estimation and funding

To be brought inline with autoCost, funding a contract and script call has been migrated from fundWithRequiredCoins to autoCost:

// before
const request: ScriptTransactionRequest = contract.functions.add(1).fundWithRequiredCoins();
// after
const request: ScriptTransactionRequest = contract.functions.add(1).autoCost();

#3559 - Remove redundant gas price call for tx summary

  • calculateTXFeeForSummary and subsequently the CalculateTXFeeForSummaryParams no longer accept a totalFee property. If you have the totalFee, then there is no need to call the calculateTxFeeForSummary() function.
// before
const totalFee = bn(..):
calculateTXFeeForSummary({ ..., totalFee } as CalculateTXFeeForSummaryParams);
// after
calculateTXFeeForSummary({ ... } as CalculateTXFeeForSummaryParams);

#3540 - Prevent implicit asset burn

// before
const transactionRequest = new ScriptTransactionRequest();
transactionRequest.inputs.push({ ... });

// since outputs weren't added, assets would be burned
await sender.sendTransaction(transactionRequest);
// after
const transactionRequest = new ScriptTransactionRequest();
transactionRequest.inputs.push({ ... });

// now, an error will be thrown unless `enableAssetBurn`is true,
// in which case, assets can still be burned
await sender.sendTransaction(transactionRequest, {
  enableAssetBurn: true,
});

Chores

#3553 - Remove unused operations

The following operations have been removed from the OperationName enum, as they were never used to assemble operations:

  • OperationName.mint
  • OperationName.predicatecall
  • OperationName.script
  • OperationName.sent

#3552 - Remove receipts deprecated properties

All receipts deprecated properties were removed:

// before
ReceiptCall.from

ReceiptLog.val0
ReceiptLog.val1
ReceiptLog.val2
ReceiptLog.val3

ReceiptLogData.val0
ReceiptLogData.val1

ReceiptTransfer.from

ReceiptTransferOut.from
// after
ReceiptCall.id

ReceiptLog.ra
ReceiptLog.rb
ReceiptLog.rc
ReceiptLog.rd

ReceiptLogData.ra
ReceiptLogData.rb

ReceiptTransfer.id

ReceiptTransferOut.id

#3551 - Remove receipt coders

All previously deprecated receipt coders have been removed. These classes were barely used aside from a few internal helpers, which were converted to utility functions.

// before
const messageId = ReceiptMessageOutCoder.getMessageId({
  sender,
  recipient,
  nonce,
  amount,
  data,
});

const assetId = ReceiptMintCoder.getAssetId(contractId, subId);

const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
// after
import { getMessageId, getAssetId } from 'fuels'

const messageId = getMessageId({
  sender,
  recipient,
  nonce,
  amount,
  data,
});

const assetId = getAssetId(contractId, subId);

#3548 - Remove deprecated submitAndAwait operation

  • submitAndAwait operation was removed

After being deprecated since #3101, we have removed this operation altogether. Please use the submitAndAwaitStatus method instead which gives the same results as submitAndAwait. If you are interested in the deprecation/removal reasons, please refer to FuelLabs/fuel-core#2108.

// before
const response = await provider.operations.submitAndAwait(txRequest);
// after
const response = await provider.operations.submitAndAwaitStatus(txRequest);

#3493 - Remove Bech32 address

  • We no longer support Bech32 addresses
// before
import { Address, Bech32Address } from "fuels";

const bech32Address: Bech32Address = "fuel1234";
const address = new Address(bech32Address);
// after
import { Address, B256Address } from "fuels";

const b256Address: B256Address = "0x1234";
const address = new Address(b256Address);
  • Removed INVALID_BECH32_ADDRESS error code.

  • Removed associated Bech32 helper functions.

    • normalizeBech32
    • isBech32
    • toB256
    • getBytesFromBech32
    • toBech32
    • clearFirst12BytesFromB256

#3492 - Redistributed the @fuel-ts/interfaces package

  • Removed the AbstractAddress class; use the Address class instead.
// before
import { AbstractAddress } from 'fuels';
// after
import { Address } from 'fuels';
  • Removed the @fuel-ts/interfaces package; use the fuels package instead.
// before
import { BytesLike } from '@fuel-ts/interfaces'
// after
import { BytesLike } from 'fuels'

Docs

#3573 - Optimizing frontend apps

  • ScriptTransactionRequest.autoCost() has been renamed to ScriptTransactionRequest.estimateAndFund(), initially introduced by #3535
// before
await request.autoCost(wallet);
// after
await request.estimateAndFund(wallet);
  • BaseInvocationScope.autoCost() has been renamed back to BaseInvocationScope.fundWithRequiredCoins(), initially introduced by #3535
// before
const request = await contract.functions.increment().autoCost();
// after
const request = await contract.functions.increment().fundWithRequiredCoins();