FuelLabs / fuels-ts

Fuel Network Typescript SDK
https://docs.fuel.network/docs/fuels-ts/
Apache License 2.0
44.22k stars 1.34k forks source link

chore!: refactored the `getTransactionCost` method #2643

Closed petertonysmith94 closed 2 months ago

petertonysmith94 commented 3 months ago

Release notes

In this release, we:

Summary

Breaking Changes

Refactored functionality for Provider.getTransactionCost to Account.getTransactionCost and changed estimation parameter from quantitiesToContract to quantities.

// before
const provider = Provider.create(...);
const account = Wallet.generate({ ... }) || new Predicate(...);
const quantities: Array<CoinQuantityLike> = [
  { amount: 1000, assetId: provider.getBaseAssetId() }
];

const cost = provider.getTransactionCost(txRequest, {
  resourceOwner: account,
  quantitiesToContract: quantities,
})
// after
const provider = Provider.create(...);
const account = Wallet.generate({ ... }) || new Predicate(...);
const quantities: Array<CoinQuantityLike> = [
  { amount: 1000, assetId: provider.getBaseAssetId() }
];

const cost = account.getTransactionCost(txRequest, { quantities });

Checklist

Torres-ssf commented 2 months ago

@petertonysmith94 We still have some tests failing here.

Please let me know if you are having a hard time addressing them.

github-actions[bot] commented 2 months ago

Coverage Report:

Lines Branches Functions Statements
79.4%(+0.04%) 71.53%(-0.12%) 77.32%(+0.02%) 79.53%(+0.04%)
Changed Files: | Ok | File (✨=New File) | Lines | Branches | Functions | Statements | | -- | --------------------------------------------------------------------------------- | ------------------ | ------------------ | ------------------ | ------------------ | | 🔴 | packages/account/src/account.ts | 82.31%
(+1.16%) | 65.07%
(+1.14%) | 82.35%
(+0.54%) | 82%
(+1.15%) | | 🔴 | packages/account/src/providers/provider.ts | 68.02%
(-0.82%) | 62.63%
(-1.19%) | 73.49%
(-0.31%) | 67.98%
(-0.81%) | | 🔴 | packages/account/src/test-utils/launchNode.ts | 98.27%
(+0.01%) | 85.24%
(+0.5%) | 100%
(+0%) | 98.36%
(+0.02%) | | 🔴 | packages/contract/src/contract-factory.ts | 58.33%
(-0.29%) | 46.42%
(+0.27%) | 54.54%
(+0%) | 58.33%
(-0.29%) | | 🔴 | packages/contract/src/util.ts | 93.75%
(+0.42%) | 0%
(+0%) | 66.66%
(+0%) | 88.88%
(+0.65%) | | 🔴 | packages/create-fuels/src/cli.ts | 85.5%
(+0.21%) | 37.5%
(-2.5%) | 100%
(+0%) | 85.5%
(+0.21%) |