From 0b4c3ab24428be78929d2ac5a88d80b7336fa0af Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Tue, 7 Jan 2025 18:42:49 +0000 Subject: [PATCH] chore!: redistributed the `@fuel-ts/interfaces` package (#3492) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: removed `@fuel-ts/interfaces` package and `AbstractAddress` * chore: finalize changes * chore: fix logger test * chore: changeset * chore: update changeset * chore: fixed changeset * chore: fixed failing tests * Update packages/logger/test/index.test.ts * chore: fix import * chore: fixed import --------- Co-authored-by: Anderson Arboleya Co-authored-by: SΓ©rgio Torres <30977845+Torres-ssf@users.noreply.github.com> --- .changeset/wild-dots-bake.md | 20 + apps/docs/spell-check-custom-words.txt | 1 - .../contracts/managing-deployed-contracts.md | 2 +- apps/docs/src/guide/types/address.md | 10 +- .../src/guide/utilities/address-conversion.md | 4 +- internal/check-imports/package.json | 1 - internal/check-imports/src/imports.ts | 2 - packages/abi-coder/package.json | 3 +- packages/abi-coder/src/FunctionFragment.ts | 2 +- packages/abi-coder/src/Interface.ts | 2 +- .../src/encoding/coders/AbstractCoder.ts | 2 +- packages/abi-coder/src/index.ts | 1 + packages/abi-coder/src/utils/types.ts | 4 + packages/abi-typegen/package.json | 1 - .../src/templates/contract/main.hbs | 4 +- .../contract-with-configurable/main.hbs | 4 +- .../test/fixtures/templates/contract/main.hbs | 4 +- packages/account/package.json | 1 - packages/account/src/account.ts | 23 +- packages/account/src/connectors/fuel.ts | 9 +- packages/account/src/hdwallet/hdwallet.ts | 2 +- packages/account/src/index.ts | 1 + packages/account/src/mnemonic/mnemonic.ts | 2 +- packages/account/src/mnemonic/utils.ts | 2 +- packages/account/src/predicate/predicate.ts | 2 +- .../src/predicate/utils/getPredicateRoot.ts | 2 +- .../account/src/providers/coin-quantity.ts | 2 +- packages/account/src/providers/coin.ts | 5 +- packages/account/src/providers/message.ts | 15 +- packages/account/src/providers/provider.ts | 14 +- packages/account/src/providers/resource.ts | 2 +- .../create-transaction-request.ts | 2 +- .../providers/transaction-request/errors.ts | 4 +- .../providers/transaction-request/helpers.ts | 6 +- .../providers/transaction-request/input.ts | 2 +- .../providers/transaction-request/output.ts | 2 +- .../script-transaction-request.ts | 5 +- .../providers/transaction-request/scripts.ts | 3 +- .../transaction-request/storage-slot.ts | 2 +- .../transaction-request.ts | 11 +- .../providers/transaction-request/types.ts | 8 + .../upgrade-transaction-request.ts | 2 +- .../upload-transaction-request.ts | 2 +- .../providers/transaction-request/witness.ts | 2 +- .../providers/transaction-summary/types.ts | 2 +- packages/account/src/signer/signer.ts | 2 +- .../setup-test-provider-and-wallets.test.ts | 4 +- .../account/src/test-utils/test-message.ts | 11 +- packages/account/src/types.ts | 12 + ...formatTransferToContractScriptData.test.ts | 2 +- .../formatTransferToContractScriptData.ts | 2 +- packages/account/src/wallet-manager/types.ts | 8 +- .../wallet-manager/vaults/mnemonic-vault.ts | 5 +- .../wallet-manager/vaults/privatekey-vault.ts | 5 +- .../src/wallet-manager/wallet-manager.ts | 5 +- .../src/wallet/base-wallet-unlocked.ts | 2 +- .../account/src/wallet/keystore-wallet.ts | 3 +- .../src/wallet/wallet-unlocked.test.ts | 2 +- packages/account/src/wallet/wallet.ts | 5 +- packages/account/src/wallet/wallets.ts | 2 +- .../test/fuel-wallet-connector.test.ts | 7 +- packages/address/package.json | 1 - packages/address/src/address.test.ts | 4 +- packages/address/src/address.ts | 17 +- packages/address/src/index.ts | 3 +- packages/address/src/types.ts | 41 ++ packages/address/src/utils.ts | 32 +- packages/contract/package.json | 3 +- packages/contract/src/contract-factory.ts | 2 +- packages/contract/src/util.ts | 2 +- packages/crypto/package.json | 1 - packages/crypto/src/browser/pbkdf2.ts | 2 +- packages/crypto/src/node/pbkdf2.ts | 2 +- packages/crypto/src/shared/ripemd160.ts | 2 +- packages/crypto/src/types.ts | 2 +- packages/errors/src/error-codes.ts | 1 + .../src/transaction-summary.test.ts | 7 +- packages/fuels/package.json | 1 - packages/fuels/src/index.ts | 1 - packages/hasher/package.json | 1 - packages/hasher/src/hasher.ts | 2 +- packages/interfaces/CHANGELOG.md | 466 ------------------ packages/interfaces/LICENSE | 201 -------- packages/interfaces/README.md | 53 -- packages/interfaces/package.json | 27 - packages/interfaces/src/index.ts | 97 ---- packages/interfaces/tsconfig.dts.json | 9 - packages/interfaces/tsconfig.json | 7 - packages/interfaces/tsdoc.json | 4 - packages/interfaces/tsup.config.ts | 3 - packages/interfaces/typedoc.json | 6 - packages/logger/package.json | 1 - packages/logger/src/index.ts | 3 +- packages/logger/test/index.test.ts | 2 +- packages/program/package.json | 1 - packages/program/src/contract-call-script.ts | 6 +- packages/program/src/contract.ts | 8 +- .../src/functions/base-invocation-scope.ts | 4 +- .../program/src/functions/invocation-scope.ts | 3 +- .../program/src/functions/multicall-scope.ts | 2 +- packages/program/src/response.ts | 9 +- packages/program/src/script-request.ts | 2 +- packages/program/src/types.ts | 23 +- packages/program/src/utils.ts | 3 +- packages/recipes/package.json | 2 +- packages/recipes/scripts/build-recipes.ts | 4 +- packages/recipes/src/types/Src14OwnedProxy.ts | 6 +- packages/script/package.json | 1 - packages/script/src/index.ts | 1 + .../script/src/script-invocation-scope.ts | 3 +- packages/script/src/script.ts | 4 +- packages/script/src/types.ts | 8 + packages/transactions/package.json | 3 +- .../transactions/src/coders/byte-array.ts | 2 +- packages/transactions/src/coders/input.ts | 2 +- packages/transactions/src/receipt.test.ts | 2 +- packages/transactions/src/receipt.ts | 2 +- packages/utils/package.json | 1 - packages/utils/src/utils/arrayify.test.ts | 2 +- packages/utils/src/utils/arrayify.ts | 3 +- packages/utils/src/utils/base58.ts | 2 +- packages/utils/src/utils/bytecode.ts | 2 +- packages/utils/src/utils/concat.ts | 3 +- packages/utils/src/utils/dataSlice.ts | 2 +- packages/utils/src/utils/hexlify.ts | 3 +- packages/utils/src/utils/toUtf8String.ts | 3 +- pnpm-lock.yaml | 56 +-- 127 files changed, 318 insertions(+), 1145 deletions(-) create mode 100644 .changeset/wild-dots-bake.md create mode 100644 packages/abi-coder/src/utils/types.ts create mode 100644 packages/account/src/types.ts create mode 100644 packages/address/src/types.ts delete mode 100644 packages/interfaces/CHANGELOG.md delete mode 100644 packages/interfaces/LICENSE delete mode 100644 packages/interfaces/README.md delete mode 100644 packages/interfaces/package.json delete mode 100644 packages/interfaces/src/index.ts delete mode 100644 packages/interfaces/tsconfig.dts.json delete mode 100644 packages/interfaces/tsconfig.json delete mode 100644 packages/interfaces/tsdoc.json delete mode 100644 packages/interfaces/tsup.config.ts delete mode 100644 packages/interfaces/typedoc.json create mode 100644 packages/script/src/types.ts diff --git a/.changeset/wild-dots-bake.md b/.changeset/wild-dots-bake.md new file mode 100644 index 00000000000..dc4c76004f4 --- /dev/null +++ b/.changeset/wild-dots-bake.md @@ -0,0 +1,20 @@ +--- +"@internal/check-imports": patch +"@fuel-ts/transactions": patch +"@fuel-ts/abi-typegen": patch +"@fuel-ts/abi-coder": patch +"@fuel-ts/contract": patch +"@fuel-ts/account": patch +"@fuel-ts/address": patch +"@fuel-ts/program": patch +"@fuel-ts/recipes": patch +"@fuel-ts/crypto": patch +"@fuel-ts/errors": patch +"@fuel-ts/hasher": patch +"@fuel-ts/logger": patch +"@fuel-ts/script": patch +"fuels": minor +"@fuel-ts/utils": patch +--- + +chore!: redistributed the `@fuel-ts/interfaces` package diff --git a/apps/docs/spell-check-custom-words.txt b/apps/docs/spell-check-custom-words.txt index ea86d3e55f5..8955bf6298c 100644 --- a/apps/docs/spell-check-custom-words.txt +++ b/apps/docs/spell-check-custom-words.txt @@ -2,7 +2,6 @@ ABI ABI's abigen ABIs -AbstractAddress ALU ANDs API's diff --git a/apps/docs/src/guide/contracts/managing-deployed-contracts.md b/apps/docs/src/guide/contracts/managing-deployed-contracts.md index 361a9e37599..e37e56b47b7 100644 --- a/apps/docs/src/guide/contracts/managing-deployed-contracts.md +++ b/apps/docs/src/guide/contracts/managing-deployed-contracts.md @@ -4,7 +4,7 @@ To interact with a deployed contract using the SDK without redeploying it, you o ## Contract ID -The `contractId` property from the [`Contract`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_program.Contract.html) class is of type [`AbstractAddress`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html), an abstract class that is exclusively extended by the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class. +The `contractId` property from the [`Contract`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_program.Contract.html) class is an instance of the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class. The [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class wraps all methods from the [`AbstractAddress`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html) class and adds a single property: `b256Address`. This property is a string encoded in [`B256`](../types/bits256.md) format. diff --git a/apps/docs/src/guide/types/address.md b/apps/docs/src/guide/types/address.md index 73e4a971ea9..d295ec41cd3 100644 --- a/apps/docs/src/guide/types/address.md +++ b/apps/docs/src/guide/types/address.md @@ -2,21 +2,15 @@ In Sway, the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) type serves as a type-safe wrapper around the primitive `b256` type. The SDK takes a different approach and has its own abstraction for the [Address](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) type. -## `AbstractAddress` Class - -The SDK defines the [AbstractAddress](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html) class, which provides a set of utility functions for easy manipulation and conversion between address formats. - -<<< @/../../../packages/interfaces/src/index.ts#address-1{ts:line-numbers} - ## Address Class -Besides conforming to the interface of the [`AbstractAddress`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html), the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class also defines one property; `b256Address`, which is of the [`B256`](./bits256.md) type. +The [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class also provides a set of utility functions for easy manipulation and conversion between address formats along with one property; `b256Address`, which is of the [`B256`](./bits256.md) type. <<< @/../../../packages/address/src/address.ts#address-2{ts:line-numbers} ## Creating an Address -Thanks to the utility functions provided by the [`AbstractAddress`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html) class, there are several ways to create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) instance: +There are several ways to create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) instance: ### From a b256 address diff --git a/apps/docs/src/guide/utilities/address-conversion.md b/apps/docs/src/guide/utilities/address-conversion.md index ba42aeca586..dbb8d82bfd6 100644 --- a/apps/docs/src/guide/utilities/address-conversion.md +++ b/apps/docs/src/guide/utilities/address-conversion.md @@ -25,13 +25,13 @@ This guide demonstrates how to convert between address formats and Sway Standard ## Converting a Contract ID -The Contract `id` property has the [`AbstractAddress`](../types/address.md#abstractaddress-class) type. Therefore, it can be converted using the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class functions such as `toAddress` and `toB256`: +The Contract `id` property is an instance of the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class. Therefore, it can be converted using the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class functions such as `toAddress` and `toB256`: <<< @./snippets/address-conversion/contract.ts#conversion-2{ts:line-numbers} ## Converting a Wallet Address -Similarly, the Wallet `address` property is also of type [`AbstractAddress`](../types/address.md#abstractaddress-class) and can therefore use the same [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class functions for conversion: +Similarly, the Wallet `address` property is also of type [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) and can therefore use the same [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class functions for conversion: <<< @./snippets/address-conversion/wallet.ts#conversion-3{ts:line-numbers} diff --git a/internal/check-imports/package.json b/internal/check-imports/package.json index 7d55c6752fb..e7603253590 100644 --- a/internal/check-imports/package.json +++ b/internal/check-imports/package.json @@ -16,7 +16,6 @@ "@fuel-ts/crypto": "workspace:*", "@fuel-ts/errors": "workspace:*", "@fuel-ts/hasher": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/math": "workspace:*", "@fuel-ts/merkle": "workspace:*", "@fuel-ts/program": "workspace:*", diff --git a/internal/check-imports/src/imports.ts b/internal/check-imports/src/imports.ts index 8e34fec88ae..570ede6e6a6 100644 --- a/internal/check-imports/src/imports.ts +++ b/internal/check-imports/src/imports.ts @@ -8,7 +8,6 @@ import * as errors from '@fuel-ts/errors'; // forc-bin // fuels-gauge import * as hasher from '@fuel-ts/hasher'; -import * as interfaces from '@fuel-ts/interfaces'; import * as math from '@fuel-ts/math'; import * as merkle from '@fuel-ts/merkle'; import * as program from '@fuel-ts/program'; @@ -28,7 +27,6 @@ log([ errors, fuels, hasher, - interfaces, crypto, math, merkle, diff --git a/packages/abi-coder/package.json b/packages/abi-coder/package.json index cd480019997..d3c4a1349d3 100644 --- a/packages/abi-coder/package.json +++ b/packages/abi-coder/package.json @@ -29,8 +29,7 @@ "dependencies": { "@fuel-ts/crypto": "workspace:*", "@fuel-ts/errors": "workspace:*", - "@fuel-ts/hasher": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", + "@fuel-ts/hasher": "workspace:^", "@fuel-ts/math": "workspace:*", "@fuel-ts/utils": "workspace:*", "type-fest": "4.26.1" diff --git a/packages/abi-coder/src/FunctionFragment.ts b/packages/abi-coder/src/FunctionFragment.ts index c44c9d2d4eb..7565564dc35 100644 --- a/packages/abi-coder/src/FunctionFragment.ts +++ b/packages/abi-coder/src/FunctionFragment.ts @@ -1,8 +1,8 @@ import { bufferFromString } from '@fuel-ts/crypto'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { sha256 } from '@fuel-ts/hasher'; -import type { BytesLike } from '@fuel-ts/interfaces'; import { bn } from '@fuel-ts/math'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify } from '@fuel-ts/utils'; import { AbiCoder } from './AbiCoder'; diff --git a/packages/abi-coder/src/Interface.ts b/packages/abi-coder/src/Interface.ts index be85aa6f7d3..d2172d569fd 100644 --- a/packages/abi-coder/src/Interface.ts +++ b/packages/abi-coder/src/Interface.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify } from '@fuel-ts/utils'; import { AbiCoder } from './AbiCoder'; diff --git a/packages/abi-coder/src/encoding/coders/AbstractCoder.ts b/packages/abi-coder/src/encoding/coders/AbstractCoder.ts index 77ae62e77fa..a3ee7ce1128 100644 --- a/packages/abi-coder/src/encoding/coders/AbstractCoder.ts +++ b/packages/abi-coder/src/encoding/coders/AbstractCoder.ts @@ -1,5 +1,5 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; +import type { BytesLike } from '@fuel-ts/utils'; import type { Option } from './OptionCoder'; diff --git a/packages/abi-coder/src/index.ts b/packages/abi-coder/src/index.ts index ffc8e62a1ba..e36a2eb8720 100644 --- a/packages/abi-coder/src/index.ts +++ b/packages/abi-coder/src/index.ts @@ -14,3 +14,4 @@ export { calculateVmTxMemory, ENCODING_V1, } from './utils/constants'; +export type { Bytes, RawSlice, StdString, StrSlice } from './utils/types'; diff --git a/packages/abi-coder/src/utils/types.ts b/packages/abi-coder/src/utils/types.ts new file mode 100644 index 00000000000..30773c24d3a --- /dev/null +++ b/packages/abi-coder/src/utils/types.ts @@ -0,0 +1,4 @@ +export type Bytes = Uint8Array | number[]; +export type RawSlice = Uint8Array | number[]; +export type StdString = string; +export type StrSlice = string; diff --git a/packages/abi-typegen/package.json b/packages/abi-typegen/package.json index 0159020dc0d..bbddaf34e8f 100644 --- a/packages/abi-typegen/package.json +++ b/packages/abi-typegen/package.json @@ -53,7 +53,6 @@ "license": "Apache-2.0", "dependencies": { "@fuel-ts/errors": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/utils": "workspace:*", "@fuel-ts/versions": "workspace:*", "commander": "12.1.0", diff --git a/packages/abi-typegen/src/templates/contract/main.hbs b/packages/abi-typegen/src/templates/contract/main.hbs index d4285148271..eef7efd30a2 100644 --- a/packages/abi-typegen/src/templates/contract/main.hbs +++ b/packages/abi-typegen/src/templates/contract/main.hbs @@ -6,7 +6,7 @@ import type { Provider, Account, StorageSlot, - AbstractAddress, + Address, {{#each imports}} {{this}}, {{/each}} @@ -81,7 +81,7 @@ export class {{capitalizedName}} extends Contract { }; constructor( - id: string | AbstractAddress, + id: string | Address, accountOrProvider: Account | Provider, ) { super(id, abi, accountOrProvider); diff --git a/packages/abi-typegen/test/fixtures/templates/contract-with-configurable/main.hbs b/packages/abi-typegen/test/fixtures/templates/contract-with-configurable/main.hbs index 9c3157b490b..992052611ff 100644 --- a/packages/abi-typegen/test/fixtures/templates/contract-with-configurable/main.hbs +++ b/packages/abi-typegen/test/fixtures/templates/contract-with-configurable/main.hbs @@ -15,7 +15,7 @@ import type { Provider, Account, StorageSlot, - AbstractAddress, + Address, BigNumberish, FunctionFragment, InvokeFunction, @@ -197,7 +197,7 @@ export class MyContract extends Contract { }; constructor( - id: string | AbstractAddress, + id: string | Address, accountOrProvider: Account | Provider, ) { super(id, abi, accountOrProvider); diff --git a/packages/abi-typegen/test/fixtures/templates/contract/main.hbs b/packages/abi-typegen/test/fixtures/templates/contract/main.hbs index 942b70a5042..a0350d966f7 100644 --- a/packages/abi-typegen/test/fixtures/templates/contract/main.hbs +++ b/packages/abi-typegen/test/fixtures/templates/contract/main.hbs @@ -15,7 +15,7 @@ import type { Provider, Account, StorageSlot, - AbstractAddress, + Address, BigNumberish, BN, Bytes, @@ -1248,7 +1248,7 @@ export class MyContract extends Contract { }; constructor( - id: string | AbstractAddress, + id: string | Address, accountOrProvider: Account | Provider, ) { super(id, abi, accountOrProvider); diff --git a/packages/account/package.json b/packages/account/package.json index 446a5ecad12..9e0b972fce6 100644 --- a/packages/account/package.json +++ b/packages/account/package.json @@ -53,7 +53,6 @@ "@fuel-ts/crypto": "workspace:*", "@fuel-ts/errors": "workspace:*", "@fuel-ts/hasher": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/math": "workspace:*", "@fuel-ts/merkle": "workspace:*", "@fuel-ts/transactions": "workspace:*", diff --git a/packages/account/src/account.ts b/packages/account/src/account.ts index 546c5c00c3a..63399b918d5 100644 --- a/packages/account/src/account.ts +++ b/packages/account/src/account.ts @@ -1,12 +1,12 @@ import { UTXO_ID_LEN } from '@fuel-ts/abi-coder'; +import type { WithAddress } from '@fuel-ts/address'; import { Address } from '@fuel-ts/address'; import { randomBytes } from '@fuel-ts/crypto'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { AbstractAccount } from '@fuel-ts/interfaces'; -import type { AbstractAddress, BytesLike } from '@fuel-ts/interfaces'; import type { BigNumberish, BN } from '@fuel-ts/math'; import { bn } from '@fuel-ts/math'; import { InputType } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, hexlify, isDefined } from '@fuel-ts/utils'; import { clone } from 'ramda'; @@ -46,6 +46,7 @@ import { isRequestInputResource, } from './providers/transaction-request/helpers'; import { mergeQuantities } from './providers/utils/merge-quantities'; +import { AbstractAccount } from './types'; import { assembleTransferToContractScript } from './utils/formatTransferToContractScriptData'; export type TxParamsType = Pick< @@ -54,13 +55,13 @@ export type TxParamsType = Pick< >; export type TransferParams = { - destination: string | AbstractAddress; + destination: string | Address; amount: BigNumberish; assetId: BytesLike; }; export type ContractTransferParams = { - contractId: string | AbstractAddress; + contractId: string | Address; amount: BigNumberish; assetId: BytesLike; }; @@ -76,11 +77,11 @@ export type FakeResources = Partial & Required { diff --git a/packages/account/src/connectors/fuel.ts b/packages/account/src/connectors/fuel.ts index 2ebaa84a1fb..6600a5dc6c2 100644 --- a/packages/account/src/connectors/fuel.ts +++ b/packages/account/src/connectors/fuel.ts @@ -1,5 +1,5 @@ +import type { Address } from '@fuel-ts/address'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { AbstractAddress } from '@fuel-ts/interfaces'; import { Account } from '../account'; import { Provider } from '../providers'; @@ -62,10 +62,7 @@ interface FuelSdk { hasWallet(): Promise; // #endregion connector-manager-method-hasWallet // #region connector-manager-method-getWallet - getWallet( - address: string | AbstractAddress, - providerOrNetwork?: Provider | Network - ): Promise; + getWallet(address: string | Address, providerOrNetwork?: Provider | Network): Promise; // #endregion connector-manager-method-getWallet // #region connector-manager-method-unsubscribe unsubscribe(): void; @@ -465,7 +462,7 @@ export class Fuel extends FuelConnector implements FuelSdk { * connectors. */ async getWallet( - address: string | AbstractAddress, + address: string | Address, providerOrNetwork?: Provider | Network ): Promise { const provider = await this._getProvider(providerOrNetwork); diff --git a/packages/account/src/hdwallet/hdwallet.ts b/packages/account/src/hdwallet/hdwallet.ts index 9ccd50dd7a9..c8ad9e7f3af 100644 --- a/packages/account/src/hdwallet/hdwallet.ts +++ b/packages/account/src/hdwallet/hdwallet.ts @@ -1,8 +1,8 @@ import { computeHmac, ripemd160 } from '@fuel-ts/crypto'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { sha256 } from '@fuel-ts/hasher'; -import type { BytesLike } from '@fuel-ts/interfaces'; import { bn, toBytes, toHex } from '@fuel-ts/math'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, hexlify, concat, dataSlice, encodeBase58, decodeBase58 } from '@fuel-ts/utils'; import { Mnemonic } from '../mnemonic'; diff --git a/packages/account/src/index.ts b/packages/account/src/index.ts index 49203ab33c3..35a2f5eebd4 100644 --- a/packages/account/src/index.ts +++ b/packages/account/src/index.ts @@ -1,4 +1,5 @@ export * from './account'; +export * from './types'; export * from './wallet'; export * from './hdwallet'; export * from './mnemonic'; diff --git a/packages/account/src/mnemonic/mnemonic.ts b/packages/account/src/mnemonic/mnemonic.ts index 39d56f8b054..95e25874575 100644 --- a/packages/account/src/mnemonic/mnemonic.ts +++ b/packages/account/src/mnemonic/mnemonic.ts @@ -1,7 +1,7 @@ import { randomBytes, pbkdf2, computeHmac } from '@fuel-ts/crypto'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { sha256 } from '@fuel-ts/hasher'; -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, hexlify, concat, dataSlice, encodeBase58, toUtf8Bytes } from '@fuel-ts/utils'; import { english } from '../wordlists'; diff --git a/packages/account/src/mnemonic/utils.ts b/packages/account/src/mnemonic/utils.ts index 5dfcfb40fc2..5b9e7d888fa 100644 --- a/packages/account/src/mnemonic/utils.ts +++ b/packages/account/src/mnemonic/utils.ts @@ -1,6 +1,6 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { sha256 } from '@fuel-ts/hasher'; -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify } from '@fuel-ts/utils'; /* Mnemonic phrase composed by words from the provided wordlist it can be a text or a array of words */ diff --git a/packages/account/src/predicate/predicate.ts b/packages/account/src/predicate/predicate.ts index 2e9dacdb4c0..2d422f3497b 100644 --- a/packages/account/src/predicate/predicate.ts +++ b/packages/account/src/predicate/predicate.ts @@ -2,7 +2,7 @@ import type { JsonAbi, InputValue } from '@fuel-ts/abi-coder'; import { Interface } from '@fuel-ts/abi-coder'; import { Address } from '@fuel-ts/address'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, hexlify } from '@fuel-ts/utils'; import type { FakeResources } from '../account'; diff --git a/packages/account/src/predicate/utils/getPredicateRoot.ts b/packages/account/src/predicate/utils/getPredicateRoot.ts index fa29a23cc3d..2a6583acc5f 100644 --- a/packages/account/src/predicate/utils/getPredicateRoot.ts +++ b/packages/account/src/predicate/utils/getPredicateRoot.ts @@ -1,7 +1,7 @@ import { hash } from '@fuel-ts/hasher'; -import type { BytesLike } from '@fuel-ts/interfaces'; import { calcRoot } from '@fuel-ts/merkle'; import { chunkAndPadBytes, hexlify, concat, arrayify } from '@fuel-ts/utils'; +import type { BytesLike } from '@fuel-ts/utils'; /** * @hidden diff --git a/packages/account/src/providers/coin-quantity.ts b/packages/account/src/providers/coin-quantity.ts index f9e7bcbd896..a726237869c 100644 --- a/packages/account/src/providers/coin-quantity.ts +++ b/packages/account/src/providers/coin-quantity.ts @@ -1,6 +1,6 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; import type { BigNumberish, BN } from '@fuel-ts/math'; import { bn } from '@fuel-ts/math'; +import type { BytesLike } from '@fuel-ts/utils'; import { hexlify } from '@fuel-ts/utils'; export type CoinQuantityLike = diff --git a/packages/account/src/providers/coin.ts b/packages/account/src/providers/coin.ts index ce7cffb7744..35aa60055e9 100644 --- a/packages/account/src/providers/coin.ts +++ b/packages/account/src/providers/coin.ts @@ -1,5 +1,6 @@ -import type { AbstractAddress, BytesLike } from '@fuel-ts/interfaces'; +import type { Address } from '@fuel-ts/address'; import type { BN } from '@fuel-ts/math'; +import type { BytesLike } from '@fuel-ts/utils'; /** * A Fuel coin @@ -8,7 +9,7 @@ export type Coin = { id: string; assetId: string; amount: BN; - owner: AbstractAddress; + owner: Address; blockCreated: BN; txCreatedIdx: BN; predicate?: BytesLike; diff --git a/packages/account/src/providers/message.ts b/packages/account/src/providers/message.ts index 33c568280ce..d7403ff9d7e 100644 --- a/packages/account/src/providers/message.ts +++ b/packages/account/src/providers/message.ts @@ -1,5 +1,6 @@ -import type { AbstractAddress, BytesLike } from '@fuel-ts/interfaces'; +import type { Address } from '@fuel-ts/address'; import type { BN } from '@fuel-ts/math'; +import type { BytesLike } from '@fuel-ts/utils'; import type { GqlMessageState } from './__generated__/operations'; @@ -9,8 +10,8 @@ import type { GqlMessageState } from './__generated__/operations'; */ export type Message = { messageId: BytesLike; - sender: AbstractAddress; - recipient: AbstractAddress; + sender: Address; + recipient: Address; nonce: BytesLike; amount: BN; data: BytesLike; @@ -22,8 +23,8 @@ export type Message = { export type MessageCoin = { assetId: string; - sender: AbstractAddress; - recipient: AbstractAddress; + sender: Address; + recipient: Address; nonce: BytesLike; amount: BN; daHeight: BN; @@ -60,8 +61,8 @@ export type MessageProof = { blockProof: MerkleProof; messageBlockHeader: BlockHeader; commitBlockHeader: BlockHeader; - sender: AbstractAddress; - recipient: AbstractAddress; + sender: Address; + recipient: Address; nonce: string; amount: BN; data: string; diff --git a/packages/account/src/providers/provider.ts b/packages/account/src/providers/provider.ts index 2a7543da942..1b6b36b1ac7 100644 --- a/packages/account/src/providers/provider.ts +++ b/packages/account/src/providers/provider.ts @@ -1,9 +1,9 @@ import { Address } from '@fuel-ts/address'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { AbstractAddress, BytesLike } from '@fuel-ts/interfaces'; import { BN, bn } from '@fuel-ts/math'; import type { Transaction } from '@fuel-ts/transactions'; import { InputType, InputMessageCoder, TransactionCoder } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, hexlify, DateTime, isDefined } from '@fuel-ts/utils'; import { checkFuelCoreVersionCompatibility, versions } from '@fuel-ts/versions'; import { equalBytes } from '@noble/curves/abstract/utils'; @@ -1400,7 +1400,7 @@ Supported fuel-core version: ${supportedVersion}.` * @returns A promise that resolves to the coins. */ async getCoins( - owner: string | AbstractAddress, + owner: string | Address, assetId?: BytesLike, paginationArgs?: CursorPaginationArgs ): Promise { @@ -1439,7 +1439,7 @@ Supported fuel-core version: ${supportedVersion}.` * @returns A promise that resolves to the resources. */ async getResourcesToSpend( - owner: string | AbstractAddress, + owner: string | Address, quantities: CoinQuantityLike[], excludedIds?: ExcludeResourcesOption ): Promise { @@ -1735,7 +1735,7 @@ Supported fuel-core version: ${supportedVersion}.` */ async getContractBalance( /** The contract ID to get the balance for */ - contractId: string | AbstractAddress, + contractId: string | Address, /** The asset ID of coins to get */ assetId: BytesLike ): Promise { @@ -1755,7 +1755,7 @@ Supported fuel-core version: ${supportedVersion}.` */ async getBalance( /** The address to get coins for */ - owner: string | AbstractAddress, + owner: string | Address, /** The asset ID of coins to get */ assetId: BytesLike ): Promise { @@ -1773,7 +1773,7 @@ Supported fuel-core version: ${supportedVersion}.` * @param paginationArgs - Pagination arguments (optional). * @returns A promise that resolves to the balances. */ - async getBalances(owner: string | AbstractAddress): Promise { + async getBalances(owner: string | Address): Promise { const { balances: { edges }, } = await this.operations.getBalances({ @@ -1801,7 +1801,7 @@ Supported fuel-core version: ${supportedVersion}.` * @returns A promise that resolves to the messages. */ async getMessages( - address: string | AbstractAddress, + address: string | Address, paginationArgs?: CursorPaginationArgs ): Promise { const { diff --git a/packages/account/src/providers/resource.ts b/packages/account/src/providers/resource.ts index 3ffa0e53fdb..b1e88f48eea 100644 --- a/packages/account/src/providers/resource.ts +++ b/packages/account/src/providers/resource.ts @@ -1,4 +1,4 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import type { Coin } from './coin'; import type { MessageCoin } from './message'; diff --git a/packages/account/src/providers/transaction-request/create-transaction-request.ts b/packages/account/src/providers/transaction-request/create-transaction-request.ts index db9336e751c..a61a44c00e3 100644 --- a/packages/account/src/providers/transaction-request/create-transaction-request.ts +++ b/packages/account/src/providers/transaction-request/create-transaction-request.ts @@ -1,8 +1,8 @@ import { ZeroBytes32 } from '@fuel-ts/address/configs'; -import type { BytesLike } from '@fuel-ts/interfaces'; import { bn, type BN } from '@fuel-ts/math'; import type { TransactionCreate } from '@fuel-ts/transactions'; import { TransactionType, OutputType } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, hexlify } from '@fuel-ts/utils'; import { clone } from 'ramda'; diff --git a/packages/account/src/providers/transaction-request/errors.ts b/packages/account/src/providers/transaction-request/errors.ts index 29aceb51a51..c8f48f4940f 100644 --- a/packages/account/src/providers/transaction-request/errors.ts +++ b/packages/account/src/providers/transaction-request/errors.ts @@ -1,5 +1,5 @@ /* eslint-disable max-classes-per-file */ -import type { AbstractAddress } from '@fuel-ts/interfaces'; +import type { Address } from '@fuel-ts/address'; /** * @hidden @@ -26,7 +26,7 @@ export class NoWitnessAtIndexError extends Error { */ export class NoWitnessByOwnerError extends Error { override name = 'NoWitnessByOwnerError'; - constructor(public readonly owner: AbstractAddress) { + constructor(public readonly owner: Address) { super(); this.message = `A witness for the given owner "${owner}" was not found`; } diff --git a/packages/account/src/providers/transaction-request/helpers.ts b/packages/account/src/providers/transaction-request/helpers.ts index b66b670f86d..98424041cfd 100644 --- a/packages/account/src/providers/transaction-request/helpers.ts +++ b/packages/account/src/providers/transaction-request/helpers.ts @@ -1,4 +1,4 @@ -import type { AbstractAddress } from '@fuel-ts/interfaces'; +import type { Address } from '@fuel-ts/address'; import { bn } from '@fuel-ts/math'; import { InputType } from '@fuel-ts/transactions'; @@ -39,7 +39,7 @@ export const getRequestInputResourceOwner = ( export const isRequestInputResourceFromOwner = ( input: CoinTransactionRequestInput | MessageTransactionRequestInput, - owner: AbstractAddress + owner: Address ) => getRequestInputResourceOwner(input) === owner.toB256(); export const getAssetAmountInRequestInputs = ( @@ -77,7 +77,7 @@ export const cacheRequestInputsResources = (inputs: TransactionRequestInput[]) = export const cacheRequestInputsResourcesFromOwner = ( inputs: TransactionRequestInput[], - owner: AbstractAddress + owner: Address ): ExcludeResourcesOption => inputs.reduce( (acc, input) => { diff --git a/packages/account/src/providers/transaction-request/input.ts b/packages/account/src/providers/transaction-request/input.ts index 3a3216058a4..15100c2e5c6 100644 --- a/packages/account/src/providers/transaction-request/input.ts +++ b/packages/account/src/providers/transaction-request/input.ts @@ -1,11 +1,11 @@ import { BYTES_32, UTXO_ID_LEN } from '@fuel-ts/abi-coder'; import { ZeroBytes32 } from '@fuel-ts/address/configs'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { BytesLike } from '@fuel-ts/interfaces'; import type { BigNumberish } from '@fuel-ts/math'; import { bn, toNumber } from '@fuel-ts/math'; import type { Input } from '@fuel-ts/transactions'; import { InputType } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, hexlify } from '@fuel-ts/utils'; export type CoinTransactionRequestInput = { diff --git a/packages/account/src/providers/transaction-request/output.ts b/packages/account/src/providers/transaction-request/output.ts index 50a117dc35d..4d08050006c 100644 --- a/packages/account/src/providers/transaction-request/output.ts +++ b/packages/account/src/providers/transaction-request/output.ts @@ -1,10 +1,10 @@ import { ZeroBytes32 } from '@fuel-ts/address/configs'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { BytesLike } from '@fuel-ts/interfaces'; import type { BigNumberish } from '@fuel-ts/math'; import { bn } from '@fuel-ts/math'; import type { Output } from '@fuel-ts/transactions'; import { OutputType } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { hexlify } from '@fuel-ts/utils'; export type CoinTransactionRequestOutput = { diff --git a/packages/account/src/providers/transaction-request/script-transaction-request.ts b/packages/account/src/providers/transaction-request/script-transaction-request.ts index db3ae35157d..c7251cdcce0 100644 --- a/packages/account/src/providers/transaction-request/script-transaction-request.ts +++ b/packages/account/src/providers/transaction-request/script-transaction-request.ts @@ -1,12 +1,13 @@ import type { InputValue, JsonAbi } from '@fuel-ts/abi-coder'; import { Interface } from '@fuel-ts/abi-coder'; import { addressify } from '@fuel-ts/address'; +import type { ContractIdLike } from '@fuel-ts/address'; import { ZeroBytes32 } from '@fuel-ts/address/configs'; -import type { AbstractScriptRequest, ContractIdLike, BytesLike } from '@fuel-ts/interfaces'; import { bn } from '@fuel-ts/math'; import type { BN, BigNumberish } from '@fuel-ts/math'; import type { TransactionScript } from '@fuel-ts/transactions'; import { InputType, OutputType, TransactionType } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, hexlify } from '@fuel-ts/utils'; import { clone } from 'ramda'; @@ -20,7 +21,7 @@ import type { ContractTransactionRequestOutput, VariableTransactionRequestOutput import { returnZeroScript } from './scripts'; import type { BaseTransactionRequestLike } from './transaction-request'; import { BaseTransactionRequest } from './transaction-request'; -import type { JsonAbisFromAllCalls } from './types'; +import type { AbstractScriptRequest, JsonAbisFromAllCalls } from './types'; /** * @hidden diff --git a/packages/account/src/providers/transaction-request/scripts.ts b/packages/account/src/providers/transaction-request/scripts.ts index 2f7d59a1c3d..79adbf4f2eb 100644 --- a/packages/account/src/providers/transaction-request/scripts.ts +++ b/packages/account/src/providers/transaction-request/scripts.ts @@ -1,6 +1,7 @@ -import type { AbstractScriptRequest } from '@fuel-ts/interfaces'; import { arrayify } from '@fuel-ts/utils'; +import type { AbstractScriptRequest } from './types'; + // We can't import this from `@fuel-ts/script` because it causes // cyclic dependency errors so we duplicate it here. /** @hidden */ diff --git a/packages/account/src/providers/transaction-request/storage-slot.ts b/packages/account/src/providers/transaction-request/storage-slot.ts index 1cacb8b84c9..500aa425044 100644 --- a/packages/account/src/providers/transaction-request/storage-slot.ts +++ b/packages/account/src/providers/transaction-request/storage-slot.ts @@ -1,5 +1,5 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; import type { StorageSlot } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, hexlify } from '@fuel-ts/utils'; export type TransactionRequestStorageSlot = diff --git a/packages/account/src/providers/transaction-request/transaction-request.ts b/packages/account/src/providers/transaction-request/transaction-request.ts index 9acc50532af..d38eaed6a94 100644 --- a/packages/account/src/providers/transaction-request/transaction-request.ts +++ b/packages/account/src/providers/transaction-request/transaction-request.ts @@ -1,9 +1,9 @@ import { UTXO_ID_LEN } from '@fuel-ts/abi-coder'; import { Address, addressify } from '@fuel-ts/address'; +import type { AddressLike } from '@fuel-ts/address'; import { ZeroBytes32 } from '@fuel-ts/address/configs'; import { randomBytes } from '@fuel-ts/crypto'; import { FuelError } from '@fuel-ts/errors'; -import type { AddressLike, AbstractAddress, BytesLike } from '@fuel-ts/interfaces'; import type { BN, BigNumberish } from '@fuel-ts/math'; import { bn } from '@fuel-ts/math'; import type { @@ -21,6 +21,7 @@ import { OutputType, TransactionType, } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { concat, hexlify, isDefined } from '@fuel-ts/utils'; import type { Account } from '../../account'; @@ -263,7 +264,7 @@ export abstract class BaseTransactionRequest implements BaseTransactionRequestLi * @param address - The address to get the coin input witness index for. * @param signature - The signature to update the witness with. */ - updateWitnessByOwner(address: string | AbstractAddress, signature: BytesLike) { + updateWitnessByOwner(address: string | Address, signature: BytesLike) { const ownerAddress = Address.fromAddressOrString(address); const witnessIndex = this.getCoinInputWitnessIndexByOwner(ownerAddress); if (typeof witnessIndex === 'number') { @@ -593,11 +594,7 @@ export abstract class BaseTransactionRequest implements BaseTransactionRequestLi * @deprecated - This method is deprecated and will be removed in future versions. * Please use `Account.generateFakeResources` along with `this.addResources` instead. */ - fundWithFakeUtxos( - quantities: CoinQuantity[], - baseAssetId: string, - resourcesOwner?: AbstractAddress - ) { + fundWithFakeUtxos(quantities: CoinQuantity[], baseAssetId: string, resourcesOwner?: Address) { const findAssetInput = (assetId: string) => this.inputs.find((input) => { if ('assetId' in input) { diff --git a/packages/account/src/providers/transaction-request/types.ts b/packages/account/src/providers/transaction-request/types.ts index c921cffab13..a1719c0d423 100644 --- a/packages/account/src/providers/transaction-request/types.ts +++ b/packages/account/src/providers/transaction-request/types.ts @@ -39,3 +39,11 @@ export type JsonAbisFromAllCalls = { main: JsonAbi; otherContractsAbis: Record; }; + +/** + * @hidden + */ +export abstract class AbstractScriptRequest { + abstract bytes: Uint8Array; + abstract encodeScriptData: (data: T) => Uint8Array; +} diff --git a/packages/account/src/providers/transaction-request/upgrade-transaction-request.ts b/packages/account/src/providers/transaction-request/upgrade-transaction-request.ts index 170983a219c..19e383b5192 100644 --- a/packages/account/src/providers/transaction-request/upgrade-transaction-request.ts +++ b/packages/account/src/providers/transaction-request/upgrade-transaction-request.ts @@ -1,6 +1,5 @@ import { FuelError } from '@fuel-ts/errors'; import { hash } from '@fuel-ts/hasher'; -import type { BytesLike } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; import { TransactionType, @@ -8,6 +7,7 @@ import { type UpgradePurpose, UpgradePurposeTypeEnum, } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { hexlify } from '@fuel-ts/utils'; import { clone } from 'ramda'; diff --git a/packages/account/src/providers/transaction-request/upload-transaction-request.ts b/packages/account/src/providers/transaction-request/upload-transaction-request.ts index 6e4c038439e..3f0a290700b 100644 --- a/packages/account/src/providers/transaction-request/upload-transaction-request.ts +++ b/packages/account/src/providers/transaction-request/upload-transaction-request.ts @@ -1,7 +1,7 @@ import { ZeroBytes32 } from '@fuel-ts/address/configs'; -import type { BytesLike } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; import { type TransactionUpload, TransactionType } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, hexlify } from '@fuel-ts/utils'; import { clone } from 'ramda'; diff --git a/packages/account/src/providers/transaction-request/witness.ts b/packages/account/src/providers/transaction-request/witness.ts index 3e93f0cc149..0d524c409bb 100644 --- a/packages/account/src/providers/transaction-request/witness.ts +++ b/packages/account/src/providers/transaction-request/witness.ts @@ -1,5 +1,5 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; import type { Witness } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, hexlify } from '@fuel-ts/utils'; export type TransactionRequestWitness = BytesLike; diff --git a/packages/account/src/providers/transaction-summary/types.ts b/packages/account/src/providers/transaction-summary/types.ts index 5263e729b6f..b3372035ba8 100644 --- a/packages/account/src/providers/transaction-summary/types.ts +++ b/packages/account/src/providers/transaction-summary/types.ts @@ -1,5 +1,5 @@ import type { JsonAbi } from '@fuel-ts/abi-coder'; -import type { B256Address } from '@fuel-ts/interfaces'; +import type { B256Address } from '@fuel-ts/address'; import type { BN, BNInput } from '@fuel-ts/math'; import type { Input, Output, Transaction, TransactionType } from '@fuel-ts/transactions'; diff --git a/packages/account/src/signer/signer.ts b/packages/account/src/signer/signer.ts index 2ae42aaa54d..850a0358736 100644 --- a/packages/account/src/signer/signer.ts +++ b/packages/account/src/signer/signer.ts @@ -1,8 +1,8 @@ import { Address } from '@fuel-ts/address'; import { randomBytes } from '@fuel-ts/crypto'; import { hash } from '@fuel-ts/hasher'; -import type { BytesLike } from '@fuel-ts/interfaces'; import { toBytes } from '@fuel-ts/math'; +import type { BytesLike } from '@fuel-ts/utils'; import { hexlify, concat, arrayify } from '@fuel-ts/utils'; import { secp256k1 } from '@noble/curves/secp256k1'; diff --git a/packages/account/src/test-utils/setup-test-provider-and-wallets.test.ts b/packages/account/src/test-utils/setup-test-provider-and-wallets.test.ts index cf2fad98ab8..3911bd7a5c2 100644 --- a/packages/account/src/test-utils/setup-test-provider-and-wallets.test.ts +++ b/packages/account/src/test-utils/setup-test-provider-and-wallets.test.ts @@ -1,7 +1,7 @@ +import type { Address } from '@fuel-ts/address'; import { randomBytes } from '@fuel-ts/crypto'; import { ErrorCode } from '@fuel-ts/errors'; import { expectToThrowFuelError, safeExec } from '@fuel-ts/errors/test-utils'; -import type { AbstractAddress } from '@fuel-ts/interfaces'; import { bn, toNumber } from '@fuel-ts/math'; import { arrayify, defaultSnapshotConfigs, hexlify } from '@fuel-ts/utils'; import { waitUntilUnreachable } from '@fuel-ts/utils/test-utils'; @@ -82,7 +82,7 @@ describe('setupTestProviderAndWallets', () => { const { coins: [sutCoin], - } = await provider.getCoins({ toB256: () => coin.owner } as AbstractAddress, coin.asset_id); + } = await provider.getCoins({ toB256: () => coin.owner } as Address, coin.asset_id); expect(sutCoin.amount.toNumber()).toEqual(coin.amount); expect(sutCoin.owner.toB256()).toEqual(coin.owner); diff --git a/packages/account/src/test-utils/test-message.ts b/packages/account/src/test-utils/test-message.ts index 06bcea554a5..69783765a3e 100644 --- a/packages/account/src/test-utils/test-message.ts +++ b/packages/account/src/test-utils/test-message.ts @@ -1,13 +1,12 @@ import { Address } from '@fuel-ts/address'; import { randomBytes } from '@fuel-ts/crypto'; -import type { AbstractAddress } from '@fuel-ts/interfaces'; import { bn, type BN } from '@fuel-ts/math'; import type { SnapshotConfigs } from '@fuel-ts/utils'; import { hexlify } from '@fuel-ts/utils'; interface TestMessageSpecs { - sender: AbstractAddress; - recipient: AbstractAddress; + sender: Address; + recipient: Address; nonce: string; amount: number; data: string; @@ -17,8 +16,8 @@ interface TestMessageSpecs { export type ChainMessage = SnapshotConfigs['stateConfig']['messages'][0]; export class TestMessage { - public readonly sender: AbstractAddress; - public readonly recipient: AbstractAddress; + public readonly sender: Address; + public readonly recipient: Address; public readonly nonce: string; public readonly amount: number | BN; public readonly data: string; @@ -46,7 +45,7 @@ export class TestMessage { this.da_height = da_height; } - toChainMessage(recipient?: AbstractAddress): ChainMessage { + toChainMessage(recipient?: Address): ChainMessage { // Fuel-core throwns error for message data prefixed with 0x within the stateConfig.json file const data = /^0x/.test(this.data) ? this.data.replace(/^0x/, '') : this.data; return { diff --git a/packages/account/src/types.ts b/packages/account/src/types.ts new file mode 100644 index 00000000000..6cd8a38cc1b --- /dev/null +++ b/packages/account/src/types.ts @@ -0,0 +1,12 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import type { Address } from '@fuel-ts/address'; + +export abstract class AbstractAccount { + abstract address: Address; + abstract provider: unknown; + abstract getResourcesToSpend(quantities: any[], options?: any): any; + abstract sendTransaction(transactionRequest: any, options?: any): any; + abstract simulateTransaction(transactionRequest: any, options?: any): any; + abstract getTransactionCost(transactionRequest: any, options?: any): Promise; + abstract fund(transactionRequest: any, txCost: any): Promise; +} diff --git a/packages/account/src/utils/formatTransferToContractScriptData.test.ts b/packages/account/src/utils/formatTransferToContractScriptData.test.ts index 1cee087afa1..d00fe30eb48 100644 --- a/packages/account/src/utils/formatTransferToContractScriptData.test.ts +++ b/packages/account/src/utils/formatTransferToContractScriptData.test.ts @@ -1,8 +1,8 @@ import { BigNumberCoder } from '@fuel-ts/abi-coder'; import { getRandomB256 } from '@fuel-ts/address'; -import type { BytesLike } from '@fuel-ts/interfaces'; import { bn, type BigNumberish } from '@fuel-ts/math'; import * as arrayifyMod from '@fuel-ts/utils'; +import type { BytesLike } from '@fuel-ts/utils'; import { assembleTransferToContractScript, diff --git a/packages/account/src/utils/formatTransferToContractScriptData.ts b/packages/account/src/utils/formatTransferToContractScriptData.ts index 1c441314e4c..2155a3ad46a 100644 --- a/packages/account/src/utils/formatTransferToContractScriptData.ts +++ b/packages/account/src/utils/formatTransferToContractScriptData.ts @@ -1,8 +1,8 @@ import { ASSET_ID_LEN, BigNumberCoder, CONTRACT_ID_LEN, WORD_SIZE } from '@fuel-ts/abi-coder'; import { Address } from '@fuel-ts/address'; -import type { BytesLike } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; import { arrayify, concat } from '@fuel-ts/utils'; +import type { BytesLike } from '@fuel-ts/utils'; import * as asm from '@fuels/vm-asm'; interface AssembleTransferToContractParams { diff --git a/packages/account/src/wallet-manager/types.ts b/packages/account/src/wallet-manager/types.ts index 26c4c788354..835fac6656d 100644 --- a/packages/account/src/wallet-manager/types.ts +++ b/packages/account/src/wallet-manager/types.ts @@ -1,11 +1,11 @@ /* eslint-disable max-classes-per-file */ +import type { Address } from '@fuel-ts/address'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { AbstractAddress } from '@fuel-ts/interfaces'; import type { WalletUnlocked } from '../wallet'; export type WalletManagerAccount = { - address: AbstractAddress; + address: Address; publicKey: string; vaultId?: number; }; @@ -50,11 +50,11 @@ export abstract class Vault { throw new FuelError(ErrorCode.NOT_IMPLEMENTED, 'Not implemented.'); } - exportAccount(_address: AbstractAddress): string { + exportAccount(_address: Address): string { throw new FuelError(ErrorCode.NOT_IMPLEMENTED, 'Not implemented.'); } - getWallet(_address: AbstractAddress): WalletUnlocked { + getWallet(_address: Address): WalletUnlocked { throw new FuelError(ErrorCode.NOT_IMPLEMENTED, 'Not implemented.'); } } diff --git a/packages/account/src/wallet-manager/vaults/mnemonic-vault.ts b/packages/account/src/wallet-manager/vaults/mnemonic-vault.ts index 08804423695..247090873e8 100644 --- a/packages/account/src/wallet-manager/vaults/mnemonic-vault.ts +++ b/packages/account/src/wallet-manager/vaults/mnemonic-vault.ts @@ -1,6 +1,5 @@ import { Address } from '@fuel-ts/address'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { AbstractAddress } from '@fuel-ts/interfaces'; import { Mnemonic } from '../../mnemonic'; import type { WalletUnlocked } from '../../wallet'; @@ -70,7 +69,7 @@ export class MnemonicVault implements Vault { }; } - exportAccount(address: string | AbstractAddress): string { + exportAccount(address: string | Address): string { let numberOfAccounts = 0; const ownerAddress = Address.fromAddressOrString(address); // Look for the account that has the same address @@ -88,7 +87,7 @@ export class MnemonicVault implements Vault { ); } - getWallet(address: string | AbstractAddress): WalletUnlocked { + getWallet(address: string | Address): WalletUnlocked { const privateKey = this.exportAccount(address); return Wallet.fromPrivateKey(privateKey); } diff --git a/packages/account/src/wallet-manager/vaults/privatekey-vault.ts b/packages/account/src/wallet-manager/vaults/privatekey-vault.ts index 0fa82376ac4..127153c4146 100644 --- a/packages/account/src/wallet-manager/vaults/privatekey-vault.ts +++ b/packages/account/src/wallet-manager/vaults/privatekey-vault.ts @@ -1,6 +1,5 @@ import { Address } from '@fuel-ts/address'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { AbstractAddress } from '@fuel-ts/interfaces'; import type { WalletUnlocked } from '../../wallet'; import { Wallet } from '../../wallet'; @@ -54,7 +53,7 @@ export class PrivateKeyVault implements Vault { return this.getPublicAccount(wallet.privateKey); } - exportAccount(address: string | AbstractAddress): string { + exportAccount(address: string | Address): string { const ownerAddress = Address.fromAddressOrString(address); const privateKey = this.#privateKeys.find((pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress) @@ -70,7 +69,7 @@ export class PrivateKeyVault implements Vault { return privateKey; } - getWallet(address: string | AbstractAddress): WalletUnlocked { + getWallet(address: string | Address): WalletUnlocked { const privateKey = this.exportAccount(address); return Wallet.fromPrivateKey(privateKey); } diff --git a/packages/account/src/wallet-manager/wallet-manager.ts b/packages/account/src/wallet-manager/wallet-manager.ts index 75f78170e99..a2e21c51bf4 100644 --- a/packages/account/src/wallet-manager/wallet-manager.ts +++ b/packages/account/src/wallet-manager/wallet-manager.ts @@ -2,7 +2,6 @@ import { Address } from '@fuel-ts/address'; import type { Keystore } from '@fuel-ts/crypto'; import { encrypt, decrypt } from '@fuel-ts/crypto'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { AbstractAddress } from '@fuel-ts/interfaces'; import { EventEmitter } from 'events'; import type { WalletUnlocked } from '../wallet'; @@ -112,7 +111,7 @@ export class WalletManager extends EventEmitter { /** * Create a Wallet instance for the specific account */ - getWallet(address: string | AbstractAddress): WalletUnlocked { + getWallet(address: string | Address): WalletUnlocked { const ownerAddress = Address.fromAddressOrString(address); const vaultState = this.#vaults.find((vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress)) @@ -125,7 +124,7 @@ export class WalletManager extends EventEmitter { /** * Export specific account privateKey */ - exportPrivateKey(address: string | AbstractAddress) { + exportPrivateKey(address: string | Address) { const ownerAddress = Address.fromAddressOrString(address); assert(!this.#isLocked, ERROR_MESSAGES.wallet_not_unlocked); const vaultState = this.#vaults.find((vs) => diff --git a/packages/account/src/wallet/base-wallet-unlocked.ts b/packages/account/src/wallet/base-wallet-unlocked.ts index 3eb66e13437..6a7bbdedbd1 100644 --- a/packages/account/src/wallet/base-wallet-unlocked.ts +++ b/packages/account/src/wallet/base-wallet-unlocked.ts @@ -1,5 +1,5 @@ import { hashMessage } from '@fuel-ts/hasher'; -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import { hexlify } from '@fuel-ts/utils'; import { Account } from '../account'; diff --git a/packages/account/src/wallet/keystore-wallet.ts b/packages/account/src/wallet/keystore-wallet.ts index fa488f75845..7ceb1ef7fce 100644 --- a/packages/account/src/wallet/keystore-wallet.ts +++ b/packages/account/src/wallet/keystore-wallet.ts @@ -10,7 +10,6 @@ import { randomUUID, } from '@fuel-ts/crypto'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { AbstractAddress } from '@fuel-ts/interfaces'; import { hexlify } from '@fuel-ts/utils'; export type KeystoreWallet = { @@ -58,7 +57,7 @@ export const removeHexPrefix = (hexString: string) => { export async function encryptKeystoreWallet( privateKey: string, - address: string | AbstractAddress, + address: string | Address, password: string ): Promise { // Convert the hexlified private key string to a Buffer. diff --git a/packages/account/src/wallet/wallet-unlocked.test.ts b/packages/account/src/wallet/wallet-unlocked.test.ts index 23975271f92..f8a5b4323c0 100644 --- a/packages/account/src/wallet/wallet-unlocked.test.ts +++ b/packages/account/src/wallet/wallet-unlocked.test.ts @@ -1,6 +1,6 @@ import { randomBytes } from '@fuel-ts/crypto'; import { hashMessage } from '@fuel-ts/hasher'; -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import walletSpec from '../../test/fixtures/wallet-spec'; import { SCRIPT_TX_REQUEST, SIGNED_TX, PRIVATE_KEY } from '../../test/fixtures/wallet-unlocked'; diff --git a/packages/account/src/wallet/wallet.ts b/packages/account/src/wallet/wallet.ts index 80b357cf3c5..1dcbe455eaf 100644 --- a/packages/account/src/wallet/wallet.ts +++ b/packages/account/src/wallet/wallet.ts @@ -1,4 +1,5 @@ -import type { AbstractAddress, BytesLike } from '@fuel-ts/interfaces'; +import type { Address } from '@fuel-ts/address'; +import type { BytesLike } from '@fuel-ts/utils'; import type { Provider } from '../providers'; @@ -15,7 +16,7 @@ export class Wallet { * @param provider - A Provider instance (optional). * @returns A locked wallet instance. */ - static fromAddress(address: string | AbstractAddress, provider?: Provider): WalletLocked { + static fromAddress(address: string | Address, provider?: Provider): WalletLocked { return new WalletLocked(address, provider); } diff --git a/packages/account/src/wallet/wallets.ts b/packages/account/src/wallet/wallets.ts index 24498fc3cea..72e2935d56a 100644 --- a/packages/account/src/wallet/wallets.ts +++ b/packages/account/src/wallet/wallets.ts @@ -3,7 +3,7 @@ // it's not possible to split the two classes in different files // /* eslint-disable max-classes-per-file */ -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import { Account } from '../account'; import { HDWallet } from '../hdwallet'; diff --git a/packages/account/test/fuel-wallet-connector.test.ts b/packages/account/test/fuel-wallet-connector.test.ts index 77e0d17d315..3bc9acf861c 100644 --- a/packages/account/test/fuel-wallet-connector.test.ts +++ b/packages/account/test/fuel-wallet-connector.test.ts @@ -2,9 +2,9 @@ import { Address } from '@fuel-ts/address'; import { ZeroBytes32 } from '@fuel-ts/address/configs'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; -import type { AbstractAddress, BytesLike } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; import { bn } from '@fuel-ts/math'; +import type { BytesLike } from '@fuel-ts/utils'; import { TESTNET_NETWORK_URL } from '@internal/utils'; import { EventEmitter } from 'events'; @@ -594,10 +594,7 @@ describe('Fuel Connector', () => { } // eslint-disable-next-line @typescript-eslint/require-await - override async getBalance( - _owner: AbstractAddress, - _assetId: BytesLike = ZeroBytes32 - ): Promise { + override async getBalance(_owner: Address, _assetId: BytesLike = ZeroBytes32): Promise { return bn(1234); } } diff --git a/packages/address/package.json b/packages/address/package.json index d54451e5dc6..cc0e67919da 100644 --- a/packages/address/package.json +++ b/packages/address/package.json @@ -39,7 +39,6 @@ "dependencies": { "@fuel-ts/crypto": "workspace:*", "@fuel-ts/errors": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/utils": "workspace:*", "@noble/hashes": "1.5.0" } diff --git a/packages/address/src/address.test.ts b/packages/address/src/address.test.ts index a168d1e9104..0d2a2fcb78c 100644 --- a/packages/address/src/address.test.ts +++ b/packages/address/src/address.test.ts @@ -1,8 +1,8 @@ import { FuelError } from '@fuel-ts/errors'; import { expectToThrowFuelError } from '@fuel-ts/errors/test-utils'; -import type { AssetId, B256Address, B256AddressEvm, EvmAddress } from '@fuel-ts/interfaces'; -import Address from './address'; +import { Address } from './address'; +import type { AssetId, B256Address, B256AddressEvm, EvmAddress } from './types'; import * as utils from './utils'; const PUBLIC_KEY = diff --git a/packages/address/src/address.ts b/packages/address/src/address.ts index c6ac5de0744..e8691e1ea38 100644 --- a/packages/address/src/address.ts +++ b/packages/address/src/address.ts @@ -1,9 +1,8 @@ import { FuelError } from '@fuel-ts/errors'; -import { AbstractAddress } from '@fuel-ts/interfaces'; -import type { B256Address, EvmAddress, AssetId, ChecksumAddress } from '@fuel-ts/interfaces'; import { arrayify, hexlify } from '@fuel-ts/utils'; import { sha256 } from '@noble/hashes/sha256'; +import type { B256Address, EvmAddress, AssetId, ChecksumAddress } from './types'; import { getRandomB256, isPublicKey, @@ -18,7 +17,7 @@ import { * `Address` provides a type safe wrapper for converting between different address formats * ands comparing them for equality. */ -export default class Address extends AbstractAddress { +export class Address { // #region address-2 readonly b256Address: B256Address; // #endregion address-2 @@ -27,8 +26,6 @@ export default class Address extends AbstractAddress { * @param address - A B256 address */ constructor(address: B256Address) { - super(); - if (!isB256(address)) { throw new FuelError( FuelError.CODES.INVALID_B256_ADDRESS, @@ -125,7 +122,7 @@ export default class Address extends AbstractAddress { * Wraps the B256 address `checksum` and returns it as a string * @returns The B256 address `checksum` as a string */ - override valueOf(): string { + valueOf(): string { return this.toChecksum(); } @@ -194,19 +191,19 @@ export default class Address extends AbstractAddress { * * @returns a new `Address` instance */ - static fromAddressOrString(address: string | AbstractAddress): AbstractAddress { + static fromAddressOrString(address: string | Address): Address { return typeof address === 'string' ? this.fromString(address) : address; } /** - * Takes a dynamic string or `AbstractAddress` and creates an `Address` + * Takes a dynamic string or `Address` and creates an `Address` * * @param addressId - A string containing B256, or Public Key * @throws Error - Unknown address if the format is not recognised * @returns A new `Address` instance */ - static fromDynamicInput(address: string | AbstractAddress): Address { - // If address is a object than we assume it's a AbstractAddress + static fromDynamicInput(address: string | Address): Address { + // If address is a object than we assume it's a Address // we don't check by instanceof because it's possible to // the host app to have a different reference to this same class type if (typeof address !== 'string' && 'toB256' in address) { diff --git a/packages/address/src/index.ts b/packages/address/src/index.ts index 5be958e4314..a9488c70413 100644 --- a/packages/address/src/index.ts +++ b/packages/address/src/index.ts @@ -1,2 +1,3 @@ +export { Address } from './address'; +export * from './types'; export * from './utils'; -export { default as Address } from './address'; diff --git a/packages/address/src/types.ts b/packages/address/src/types.ts new file mode 100644 index 00000000000..92f5284f9d2 --- /dev/null +++ b/packages/address/src/types.ts @@ -0,0 +1,41 @@ +import type { Address } from './address'; + +// #region bech32-1 +/** + * @deprecated + * Type `Bech32Address` is now deprecated. Use `B256` addresses instead. ([help](https://docs.fuel.network/docs/specs/abi/argument-encoding/#b256)) + */ +export type Bech32Address = `fuel${string}`; +// #endregion bech32-1 +export type B256Address = string; + +export type ChecksumAddress = string; + +export type B256AddressEvm = `0x000000000000000000000000${string}`; + +/** + * @prop bits - A 256 bit hash string with the first 12 bytes cleared + */ +export type EvmAddress = { + bits: B256AddressEvm; +}; + +/** + * @prop bits - A wrapped 256 bit hash string + */ +export type AssetId = { + bits: B256Address; +}; + +export interface WithAddress { + address: Address; +} + +export interface WithContractId { + id: Address; +} + +/** A simple type alias defined using the `type` keyword. */ +export type AddressLike = Address | WithAddress; + +export type ContractIdLike = Address | WithContractId; diff --git a/packages/address/src/utils.ts b/packages/address/src/utils.ts index 9f4b7be00e0..b7f554ac70e 100644 --- a/packages/address/src/utils.ts +++ b/packages/address/src/utils.ts @@ -1,15 +1,10 @@ import { randomBytes } from '@fuel-ts/crypto'; import { FuelError } from '@fuel-ts/errors'; -import { AbstractContract, AbstractAccount } from '@fuel-ts/interfaces'; -import type { - B256Address, - AddressLike, - ContractIdLike, - AbstractAddress, - B256AddressEvm, -} from '@fuel-ts/interfaces'; import { arrayify, concat, hexlify } from '@fuel-ts/utils'; +import type { Address } from './address'; +import type { AddressLike, ContractIdLike, B256Address, B256AddressEvm } from './types'; + /** * Determines if a given string is B256 format * @@ -41,21 +36,34 @@ export function normalizeB256(address: B256Address): B256Address { return address.toLowerCase(); } +/** + * A simple type guard to check if an object is an Address + * + * @hidden + */ +export function isAddress(address: object): address is Address { + return 'b256Address' in address; +} + /** * Takes an indeterminate address type and returns an address * * @hidden */ -export const addressify = (addressLike: AddressLike | ContractIdLike): AbstractAddress => { - if (addressLike instanceof AbstractAccount) { +export const addressify = (addressLike: AddressLike | ContractIdLike): Address => { + if (isAddress(addressLike)) { + return addressLike; + } + + if ('address' in addressLike && isAddress(addressLike.address)) { return addressLike.address; } - if (addressLike instanceof AbstractContract) { + if ('id' in addressLike && isAddress(addressLike.id)) { return addressLike.id; } - return addressLike; + throw new FuelError(FuelError.CODES.INVALID_ADDRESS, 'Invalid address'); }; /** diff --git a/packages/contract/package.json b/packages/contract/package.json index fd2f4db6ee0..e6f1baefdf3 100644 --- a/packages/contract/package.json +++ b/packages/contract/package.json @@ -44,8 +44,7 @@ "@fuel-ts/crypto": "workspace:*", "@fuel-ts/errors": "workspace:*", "@fuel-ts/hasher": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", - "@fuel-ts/math": "workspace:*", + "@fuel-ts/math": "workspace:^", "@fuel-ts/merkle": "workspace:*", "@fuel-ts/program": "workspace:*", "@fuel-ts/transactions": "workspace:*", diff --git a/packages/contract/src/contract-factory.ts b/packages/contract/src/contract-factory.ts index 5cdb063e6bd..0ad2c00e955 100644 --- a/packages/contract/src/contract-factory.ts +++ b/packages/contract/src/contract-factory.ts @@ -17,10 +17,10 @@ import { import { randomBytes } from '@fuel-ts/crypto'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { hash } from '@fuel-ts/hasher'; -import type { BytesLike } from '@fuel-ts/interfaces'; import { bn } from '@fuel-ts/math'; import { Contract } from '@fuel-ts/program'; import type { StorageSlot } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, isDefined } from '@fuel-ts/utils'; import { getLoaderInstructions, getContractChunks } from './loader'; diff --git a/packages/contract/src/util.ts b/packages/contract/src/util.ts index 610f7b73ff1..6c2647e1a00 100644 --- a/packages/contract/src/util.ts +++ b/packages/contract/src/util.ts @@ -1,7 +1,7 @@ import { sha256 } from '@fuel-ts/hasher'; -import type { BytesLike } from '@fuel-ts/interfaces'; import { calcRoot, SparseMerkleTree } from '@fuel-ts/merkle'; import type { StorageSlot } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { chunkAndPadBytes, hexlify, concat, arrayify } from '@fuel-ts/utils'; /** diff --git a/packages/crypto/package.json b/packages/crypto/package.json index 4818995a291..7dc4ac5dbe7 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -29,7 +29,6 @@ "license": "Apache-2.0", "dependencies": { "@fuel-ts/errors": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/math": "workspace:*", "@fuel-ts/utils": "workspace:*", "@noble/hashes": "1.5.0" diff --git a/packages/crypto/src/browser/pbkdf2.ts b/packages/crypto/src/browser/pbkdf2.ts index 36d8c633487..a757d7c8124 100644 --- a/packages/crypto/src/browser/pbkdf2.ts +++ b/packages/crypto/src/browser/pbkdf2.ts @@ -1,4 +1,4 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import { hexlify } from '@fuel-ts/utils'; import { pbkdf2 as pb } from '@noble/hashes/pbkdf2'; import { sha256 } from '@noble/hashes/sha256'; diff --git a/packages/crypto/src/node/pbkdf2.ts b/packages/crypto/src/node/pbkdf2.ts index cca0e4b83a1..d132a7b2e03 100644 --- a/packages/crypto/src/node/pbkdf2.ts +++ b/packages/crypto/src/node/pbkdf2.ts @@ -1,4 +1,4 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, hexlify } from '@fuel-ts/utils'; import { pbkdf2Sync } from 'crypto'; diff --git a/packages/crypto/src/shared/ripemd160.ts b/packages/crypto/src/shared/ripemd160.ts index 116206561e8..d58e10c797a 100644 --- a/packages/crypto/src/shared/ripemd160.ts +++ b/packages/crypto/src/shared/ripemd160.ts @@ -1,4 +1,4 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify } from '@fuel-ts/utils'; import { ripemd160 as noble_ripemd160 } from '@noble/hashes/ripemd160'; diff --git a/packages/crypto/src/types.ts b/packages/crypto/src/types.ts index 842c5198f4b..78949b56af0 100644 --- a/packages/crypto/src/types.ts +++ b/packages/crypto/src/types.ts @@ -1,4 +1,4 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; export interface Keystore { data: string; diff --git a/packages/errors/src/error-codes.ts b/packages/errors/src/error-codes.ts index 6728db60612..5d40d4680c0 100644 --- a/packages/errors/src/error-codes.ts +++ b/packages/errors/src/error-codes.ts @@ -25,6 +25,7 @@ export enum ErrorCode { WORKSPACE_NOT_DETECTED = 'workspace-not-detected', // address + INVALID_ADDRESS = 'invalid-address', INVALID_EVM_ADDRESS = 'invalid-evm-address', INVALID_B256_ADDRESS = 'invalid-b256-address', diff --git a/packages/fuel-gauge/src/transaction-summary.test.ts b/packages/fuel-gauge/src/transaction-summary.test.ts index 06edf5d69eb..f1b64360585 100644 --- a/packages/fuel-gauge/src/transaction-summary.test.ts +++ b/packages/fuel-gauge/src/transaction-summary.test.ts @@ -3,10 +3,10 @@ import type { Operation, TransactionSummary, TransactionResult, - AbstractAddress, OutputChange, } from 'fuels'; import { + Address, BN, getTransactionsSummaries, getTransactionSummary, @@ -16,7 +16,6 @@ import { Wallet, AddressType, OperationName, - Address, ChainName, bn, OutputType, @@ -306,8 +305,8 @@ describe('TransactionSummary', () => { describe('Transfer Operations', () => { const validateTransferOperation = (params: { operations: Operation[]; - sender: AbstractAddress; - recipients: { address: AbstractAddress; quantities: { amount: number; assetId: string }[] }[]; + sender: Address; + recipients: { address: Address; quantities: { amount: number; assetId: string }[] }[]; fromType: AddressType; toType: AddressType; }) => { diff --git a/packages/fuels/package.json b/packages/fuels/package.json index d95bd3c43a5..7c93489405b 100644 --- a/packages/fuels/package.json +++ b/packages/fuels/package.json @@ -70,7 +70,6 @@ "@fuel-ts/crypto": "workspace:*", "@fuel-ts/errors": "workspace:*", "@fuel-ts/hasher": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/math": "workspace:*", "@fuel-ts/merkle": "workspace:*", "@fuel-ts/program": "workspace:*", diff --git a/packages/fuels/src/index.ts b/packages/fuels/src/index.ts index e13cabc50c4..d485f2a6cc4 100644 --- a/packages/fuels/src/index.ts +++ b/packages/fuels/src/index.ts @@ -7,7 +7,6 @@ export * from '@fuel-ts/contract'; export * from '@fuel-ts/crypto'; export * from '@fuel-ts/errors'; export * from '@fuel-ts/hasher'; -export * from '@fuel-ts/interfaces'; export * from '@fuel-ts/math'; export * from '@fuel-ts/math/configs'; export * from '@fuel-ts/program'; diff --git a/packages/hasher/package.json b/packages/hasher/package.json index d929e2ce70c..a438d54b60a 100644 --- a/packages/hasher/package.json +++ b/packages/hasher/package.json @@ -26,7 +26,6 @@ "license": "Apache-2.0", "dependencies": { "@fuel-ts/crypto": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/utils": "workspace:*", "@noble/hashes": "1.5.0" } diff --git a/packages/hasher/src/hasher.ts b/packages/hasher/src/hasher.ts index 16750107919..903112bfc0f 100644 --- a/packages/hasher/src/hasher.ts +++ b/packages/hasher/src/hasher.ts @@ -1,5 +1,5 @@ import { bufferFromString } from '@fuel-ts/crypto'; -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify, hexlify } from '@fuel-ts/utils'; import { sha256 as sha256AsBytes } from '@noble/hashes/sha256'; diff --git a/packages/interfaces/CHANGELOG.md b/packages/interfaces/CHANGELOG.md deleted file mode 100644 index e9860253b08..00000000000 --- a/packages/interfaces/CHANGELOG.md +++ /dev/null @@ -1,466 +0,0 @@ -# Change Log - -## 0.97.2 - -## 0.97.1 - -### Patch Changes - -- 27e8808: chore: deprecate bech32 addresses - -## 0.97.0 - -## 0.96.1 - -## 0.96.0 - -## 0.95.0 - -### Patch Changes - -- f7afa04: feat: add checksum utils for address - -## 0.94.9 - -## 0.94.8 - -## 0.94.7 - -### Patch Changes - -- 80df900: chore: fix exported types - -## 0.94.6 - -## 0.94.5 - -## 0.94.4 - -## 0.94.3 - -## 0.94.2 - -## 0.94.1 - -## 0.94.0 - -## 0.93.0 - -### Minor Changes - -- d4c4e55: chore!: refactored the `getTransactionCost` method - -## 0.92.1 - -## 0.92.0 - -## 0.91.0 - -### Patch Changes - -- a9ece17: build: add support for latest node versions - -## 0.90.0 - -## 0.89.2 - -## 0.89.1 - -## 0.89.0 - -## 0.88.1 - -## 0.88.0 - -## 0.87.0 - -## 0.86.0 - -## 0.85.0 - -## 0.84.0 - -## 0.83.0 - -### Minor Changes - -- 9c3c094: chore!: upgrade `fuel-core` to `0.24.3` - -### Patch Changes - -- 0d75266: chore!: upgrading `forc` to `0.55.0` - -## 0.82.0 - -## 0.81.0 - -## 0.80.0 - -## 0.79.0 - -### Minor Changes - -- 3ebb9bcd: chore!: remove `externalLoggedTypes` from `Interface` class - -## 0.78.0 - -## 0.77.0 - -## 0.76.0 - -## 0.75.0 - -### Patch Changes - -- Use interal utilities for arrayify, hexlify, concat and BytesLike, by [@danielbate](https://github.com/danielbate) (See [#1775](https://github.com/FuelLabs/fuels-ts/pull/1775)) - -## 0.74.0 - -### Minor Changes - -- restructure Account related packages, by [@Torres-ssf](https://github.com/Torres-ssf) (See [#1675](https://github.com/FuelLabs/fuels-ts/pull/1675)) - -## 0.73.0 - -## 0.72.0 - -### Patch Changes - -- Remove ethers dependency from the utils package, by [@arboleya](https://github.com/arboleya) (See [#1495](https://github.com/FuelLabs/fuels-ts/pull/1495)) - -## 0.71.1 - -## 0.71.0 - -### Minor Changes - -- Add `pnpm create fuels` CLI tool, by [@arboleya](https://github.com/arboleya) (See [#1624](https://github.com/FuelLabs/fuels-ts/pull/1624)) - -## 0.70.1 - -## 0.70.0 - -### Minor Changes - -- Add `pnpm create fuels` CLI tool, by [@Dhaiwat10](https://github.com/Dhaiwat10) (See [#1565](https://github.com/FuelLabs/fuels-ts/pull/1565)) - -## 0.69.1 - -## 0.69.0 - -### Minor Changes - -- Improve support of Asset ID, by [@danielbate](https://github.com/danielbate) (See [#1476](https://github.com/FuelLabs/fuels-ts/pull/1476)) - -## 0.68.0 - -### Patch Changes - -- Introduce internal hexlify and arrayify functions, by [@danielbate](https://github.com/danielbate) (See [#1401](https://github.com/FuelLabs/fuels-ts/pull/1401)) - -## 0.67.0 - -### Minor Changes - -- 🐞 Fixing transaction funding, by [@Torres-ssf](https://github.com/Torres-ssf) (See [#1372](https://github.com/FuelLabs/fuels-ts/pull/1372)) - -## 0.66.1 - -### Patch Changes - -- Adjusting package manager configs, by [@arboleya](https://github.com/arboleya) (See [#1415](https://github.com/FuelLabs/fuels-ts/pull/1415)) - -## 0.66.0 - -### Patch Changes - -- Improve typegen support for String, RawSlice and Bytes, by [@danielbate](https://github.com/danielbate) (See [#1412](https://github.com/FuelLabs/fuels-ts/pull/1412)) - -## 0.65.0 - -## 0.64.1 - -## 0.64.0 - -## 0.63.0 - -## 0.62.0 - -## 0.61.0 - -## 0.60.0 - -## 0.59.0 - -## 0.58.0 - -## 0.57.0 - -## 0.56.1 - -## 0.56.0 - -## 0.55.0 - -## 0.54.1 - -## 0.54.0 - -## 0.53.0 - -## 0.52.0 - -## 0.51.0 - -## 0.50.0 - -## 0.49.1 - -## 0.49.0 - -## 0.48.2 - -## 0.48.1 - -## 0.48.0 - -## 0.47.0 - -## 0.46.0 - -### Patch Changes - -- Removing `publishConfigs`, using `.dts` files with declaration maps (`.dts.map`), by [@arboleya](https://github.com/arboleya) (See [#1055](https://github.com/FuelLabs/fuels-ts/pull/1055)) - -## 0.45.0 - -## 0.44.2 - -## 0.44.1 - -## 0.44.0 - -### Minor Changes - -- Revamping all packages configs, enabling local installation, by [@arboleya](https://github.com/arboleya) (See [#984](https://github.com/FuelLabs/fuels-ts/pull/984)) - -## 0.43.1 - -### Patch Changes - -- Support EVM Address type, by [@danielbate](https://github.com/danielbate) (See [#995](https://github.com/FuelLabs/fuels-ts/pull/995)) - -## 0.43.0 - -## 0.42.0 - -## 0.41.0 - -## 0.40.0 - -## 0.39.1 - -## 0.39.0 - -### Minor Changes - -- [#891](https://github.com/FuelLabs/fuels-ts/pull/891) [`63c906b2`](https://github.com/FuelLabs/fuels-ts/commit/63c906b25e9cdb65e52c5d77fb85f118400fc545) Thanks [@LuizAsFight](https://github.com/LuizAsFight)! - refact(abi-coder): encode/decode data inside functionFragment - refact(abi-coder): include function selector and signature info, also if input data is pointer type - -## 0.38.1 - -## 0.38.0 - -### Minor Changes - -- [#811](https://github.com/FuelLabs/fuels-ts/pull/811) [`653c8391`](https://github.com/FuelLabs/fuels-ts/commit/653c8391ece33a8f31598ea137452dd601dc7468) Thanks [@Torres-ssf](https://github.com/Torres-ssf)! - switch docs engine from jekyll to vitepress - -## 0.37.1 - -## 0.37.0 - -## 0.36.0 - -## 0.35.0 - -### Patch Changes - -- [#819](https://github.com/FuelLabs/fuels-ts/pull/819) [`f4e1028a`](https://github.com/FuelLabs/fuels-ts/commit/f4e1028acd5a583d12662dd07ca0d17084a35be2) Thanks [@arboleya](https://github.com/arboleya)! - Adjusting export fields for all packages - -## 0.34.1 - -## 0.34.0 - -## 0.33.0 - -## 0.32.0 - -### Minor Changes - -- [#789](https://github.com/FuelLabs/fuels-ts/pull/789) [`66c200a1`](https://github.com/FuelLabs/fuels-ts/commit/66c200a1b4ecbef0ef8664fc01f7142364b0a1bc) Thanks [@luizstacio](https://github.com/luizstacio)! - Updating usages of BaseWalletLocked after renaming it to Account - -## 0.31.0 - -## 0.30.0 - -## 0.29.1 - -## 0.29.0 - -## 0.28.1 - -## 0.28.0 - -## 0.27.0 - -## 0.26.0 - -## 0.25.1 - -## 0.25.0 - -## 0.24.2 - -### Patch Changes - -- [#646](https://github.com/FuelLabs/fuels-ts/pull/646) [`fa97383`](https://github.com/FuelLabs/fuels-ts/commit/fa97383114c36ee7a204be7e7f3f974382fa1b2c) Thanks [@camsjams](https://github.com/camsjams)! - Adjust doc update timing - -## 0.24.1 - -## 0.24.0 - -## 0.23.0 - -### Patch Changes - -- [#639](https://github.com/FuelLabs/fuels-ts/pull/639) [`c0a62ed`](https://github.com/FuelLabs/fuels-ts/commit/c0a62ed278d6118f1af177dc98dcdb42febd0c81) Thanks [@camsjams](https://github.com/camsjams)! - Update docs - -## 0.22.2 - -### Patch Changes - -- [#612](https://github.com/FuelLabs/fuels-ts/pull/612) [`03b060b`](https://github.com/FuelLabs/fuels-ts/commit/03b060b51e00034a2814a0c5ed2718d5dc86533b) Thanks [@camsjams](https://github.com/camsjams)! - Added docs and improved examples - -## 0.22.1 - -## 0.22.0 - -## 0.21.2 - -## 0.21.1 - -## 0.21.0 - -## 0.20.0 - -## 0.19.0 - -### Minor Changes - -- [#549](https://github.com/FuelLabs/fuels-ts/pull/549) [`db8cc6b`](https://github.com/FuelLabs/fuels-ts/commit/db8cc6b49616199368463ecd69aae6b3ca0b65d0) Thanks [@QuinnLee](https://github.com/QuinnLee)! - add output variables to transactions - -## 0.18.0 - -## 0.17.0 - -### Minor Changes - -- [#517](https://github.com/FuelLabs/fuels-ts/pull/517) [`6403076`](https://github.com/FuelLabs/fuels-ts/commit/6403076bb9fce9055b436596e23713b0e7909d87) Thanks [@QuinnLee](https://github.com/QuinnLee)! - Parse Logs and Log Data - -## 0.16.0 - -## 0.15.0 - -### Minor Changes - -- [#502](https://github.com/FuelLabs/fuels-ts/pull/502) [`5828934`](https://github.com/FuelLabs/fuels-ts/commit/5828934ccd96cec82fc0cece0f207dafaee5b89a) Thanks [@luizstacio](https://github.com/luizstacio)! - Add toJSON for parsing values to bech32 when using JSON.stringify with Address object - -### Patch Changes - -- [#468](https://github.com/FuelLabs/fuels-ts/pull/468) [`7ad3d79`](https://github.com/FuelLabs/fuels-ts/commit/7ad3d79bf7a1db766912a7b3d52e4fa2e550af56) Thanks [@LuizAsFight](https://github.com/LuizAsFight)! - Refactor to use bn.js instead of bigint. - -## 0.14.0 - -## 0.13.0 - -## 0.12.0 - -### Minor Changes - -- [#441](https://github.com/FuelLabs/fuels-ts/pull/441) [`f3dcd27`](https://github.com/FuelLabs/fuels-ts/commit/f3dcd272dc5a237c6a8ce235a542ad804039f13b) Thanks [@camsjams](https://github.com/camsjams)! - Added support for Bech32 Address format - -## 0.11.0 - -### Patch Changes - -- [#437](https://github.com/FuelLabs/fuels-ts/pull/437) [`b2f1c66`](https://github.com/FuelLabs/fuels-ts/commit/b2f1c665b8d75f635edb4b75691abc9ebf6850b5) Thanks [@LuizAsFight](https://github.com/LuizAsFight)! - - Fixed linking packages to inside `node_modules` folder - - Remove old Lerna config - -## 0.10.0 - -## 0.9.0 - -## 0.8.0 - -### Minor Changes - -- [#405](https://github.com/FuelLabs/fuels-ts/pull/405) [`19dee43`](https://github.com/FuelLabs/fuels-ts/commit/19dee437f0ea2fe02a4a7f56b0b55d84279c2dc0) Thanks [@camsjams](https://github.com/camsjams)! - Bumping all packages to next minor version - -### Patch Changes - -- [#374](https://github.com/FuelLabs/fuels-ts/pull/374) [`0dd4870`](https://github.com/FuelLabs/fuels-ts/commit/0dd48702fd187eeebdf9f6e1882c400ee44b956e) Thanks [@camsjams](https://github.com/camsjams)! - Add readme - -* [#397](https://github.com/FuelLabs/fuels-ts/pull/397) [`9ac636b`](https://github.com/FuelLabs/fuels-ts/commit/9ac636b7b1f31d2f68c55af2062b4476217ef563) Thanks [@camsjams](https://github.com/camsjams)! - fix list on fuels - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - ---- - - - -## [0.7.0](https://github.com/FuelLabs/fuels-ts/compare/v0.6.0...0.7.0) - -> 2022-05-19 - -### 🐞 Bug Fixes - -- change build tasks in order to use pnpm link correctly ([#246](https://github.com/FuelLabs/fuels-ts/issues/246)) - -### πŸ“ƒ Code Refactoring - -- add turborepo, pnpm and tsup ([#238](https://github.com/FuelLabs/fuels-ts/issues/238)) - -### πŸš€ Features - -- move from BigNumber to BigInt ([#266](https://github.com/FuelLabs/fuels-ts/issues/266)) - - - -## [v0.6.0](https://github.com/FuelLabs/fuels-ts/compare/v0.5.0...v0.6.0) - -> 2022-04-25 - - - -## [v0.5.0](https://github.com/FuelLabs/fuels-ts/compare/v0.4.0...v0.5.0) - -> 2022-03-30 - - - -## [v0.4.0](https://github.com/FuelLabs/fuels-ts/compare/v0.3.0...v0.4.0) - -> 2022-03-13 - - - -## [v0.3.0](https://github.com/FuelLabs/fuels-ts/compare/v0.1.0...v0.3.0) - -> 2022-03-04 - - - -## v0.1.0 - -> 2022-03-04 diff --git a/packages/interfaces/LICENSE b/packages/interfaces/LICENSE deleted file mode 100644 index 261eeb9e9f8..00000000000 --- a/packages/interfaces/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/packages/interfaces/README.md b/packages/interfaces/README.md deleted file mode 100644 index 03d8e855915..00000000000 --- a/packages/interfaces/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# `@fuel-ts/interfaces` - -**@fuel-ts/interfaces** is a sub-module for interacting with **Fuel**. - -This module contains utilities to manipulate binary data and can be used to help normalize binary data representations from the output of various functions and methods. - -# Table of contents - -- [Documentation](#documentation) -- [Usage](#usage) - - [Installation](#installation) - - [Full SDK Installation](#full-sdk-installation) -- [Contributing](#contributing) -- [Changelog](#changelog) -- [License](#license) - -## Documentation - - - -See [Fuels-ts Documentation](https://docs.fuel.network/docs/fuels-ts/) - -## Usage - -### Installation - -```sh -pnpm add @fuel-ts/interfaces -# or -npm add @fuel-ts/interfaces -``` - -### Full SDK Installation - -Alternatively, we recommend you install the [complete SDK](https://github.com/FuelLabs/fuels-ts) using the umbrella package: - -```sh -pnpm add fuels -# or -npm add fuels -``` - -## Contributing - -In order to contribute to `@fuel-ts/interfaces`, please see the main [fuels-ts](https://github.com/FuelLabs/fuels-ts) monorepo. - -## Changelog - -The `@fuel-ts/interfaces` changelog can be found at [CHANGELOG](./CHANGELOG.md). - -## License - -The primary license for `@fuel-ts/interfaces` is `Apache 2.0`, see [LICENSE](./LICENSE). diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json deleted file mode 100644 index fc9806e2c47..00000000000 --- a/packages/interfaces/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@fuel-ts/interfaces", - "version": "0.97.2", - "description": "", - "author": "Fuel Labs (https://fuel.network/)", - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "engines": { - "node": "^18.20.3 || ^20.0.0 || ^22.0.0" - }, - "exports": { - ".": { - "types": "./dist/index.d.ts", - "require": "./dist/index.js", - "import": "./dist/index.mjs" - } - }, - "files": [ - "dist" - ], - "scripts": { - "build": "tsup", - "postbuild": "tsx ../../scripts/postbuild.ts" - }, - "license": "Apache-2.0" -} diff --git a/packages/interfaces/src/index.ts b/packages/interfaces/src/index.ts deleted file mode 100644 index f5d558f64c5..00000000000 --- a/packages/interfaces/src/index.ts +++ /dev/null @@ -1,97 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable max-classes-per-file */ - -/** - * @privateRemarks - * - * TODO: Consider re-distritubing interfaces near their original packages - */ - -export type B256Address = string; - -export type ChecksumAddress = string; - -export type B256AddressEvm = `0x000000000000000000000000${string}`; - -export type Bytes = Uint8Array | number[]; - -export type RawSlice = Uint8Array | number[]; - -export type BytesLike = Uint8Array | string; - -/** - * @prop bits - A 256 bit hash string with the first 12 bytes cleared - */ -export type EvmAddress = { - bits: B256AddressEvm; -}; - -/** - * @prop bits - A wrapped 256 bit hash string - */ -export type AssetId = { - bits: B256Address; -}; - -export type StdString = string; -export type StrSlice = string; - -/** - * @hidden - */ -export abstract class AbstractScriptRequest { - abstract bytes: Uint8Array; - abstract encodeScriptData: (data: T) => Uint8Array; -} - -// #region address-1 -export abstract class AbstractAddress { - abstract toJSON(): string; - abstract toString(): string; - abstract toAddress(): B256Address; - abstract toB256(): B256Address; - abstract toHexString(): string; - abstract toBytes(): Uint8Array; - abstract equals(other: AbstractAddress): boolean; -} -// #endregion address-1 - -export abstract class AbstractAccount { - abstract address: AbstractAddress; - abstract provider: unknown; - abstract getResourcesToSpend(quantities: any[], options?: any): any; - abstract sendTransaction(transactionRequest: any, options?: any): any; - abstract simulateTransaction(transactionRequest: any, options?: any): any; - abstract getTransactionCost(transactionRequest: any, options?: any): Promise; - abstract fund(transactionRequest: any, txCost: any): Promise; -} -/** - * @hidden - */ -export abstract class AbstractProgram { - abstract account: AbstractAccount | null; - abstract interface: { - readonly jsonAbi: any; - }; - - abstract provider: { - sendTransaction(transactionRequest: any, options?: any): any; - getTransactionCost(transactionRequest: any, options?: any): Promise; - } | null; -} - -export abstract class AbstractContract extends AbstractProgram { - abstract id: AbstractAddress; -} - -/** - * @hidden - */ -export abstract class AbstractScript extends AbstractProgram { - abstract bytes: Uint8Array; -} - -/** A simple type alias defined using the `type` keyword. */ -export type AddressLike = AbstractAddress | AbstractAccount; - -export type ContractIdLike = AbstractAddress | AbstractContract; diff --git a/packages/interfaces/tsconfig.dts.json b/packages/interfaces/tsconfig.dts.json deleted file mode 100644 index ccca2ac1f3e..00000000000 --- a/packages/interfaces/tsconfig.dts.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./dist", - "rootDir": "./src" - }, - "include": ["src"], - "exclude": ["**/*.test.ts"] -} diff --git a/packages/interfaces/tsconfig.json b/packages/interfaces/tsconfig.json deleted file mode 100644 index b0fced27d72..00000000000 --- a/packages/interfaces/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist" - }, - "include": ["src"] -} diff --git a/packages/interfaces/tsdoc.json b/packages/interfaces/tsdoc.json deleted file mode 100644 index 4514b072727..00000000000 --- a/packages/interfaces/tsdoc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", - "extends": ["../../tsdoc.base.json"] -} diff --git a/packages/interfaces/tsup.config.ts b/packages/interfaces/tsup.config.ts deleted file mode 100644 index 4c7f2f0354f..00000000000 --- a/packages/interfaces/tsup.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { index } from '@internal/tsup'; - -export default index; diff --git a/packages/interfaces/typedoc.json b/packages/interfaces/typedoc.json deleted file mode 100644 index a8ec6b825f0..00000000000 --- a/packages/interfaces/typedoc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "https://typedoc.org/schema.json", - "extends": ["../../typedoc.base.json"], - "entryPoints": ["src/index.ts"], - "readme": "none" -} diff --git a/packages/logger/package.json b/packages/logger/package.json index 5a3f3df1cdf..1284e908896 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -32,7 +32,6 @@ "dependencies": { "debug": "4.3.7", "@fuel-ts/address": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/math": "workspace:*" }, "devDependencies": { diff --git a/packages/logger/src/index.ts b/packages/logger/src/index.ts index dea385796b0..1126b960e07 100644 --- a/packages/logger/src/index.ts +++ b/packages/logger/src/index.ts @@ -31,7 +31,6 @@ */ import type { Address } from '@fuel-ts/address'; -import type { AbstractAddress } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; import { bn } from '@fuel-ts/math'; import debug from 'debug'; @@ -104,7 +103,7 @@ debug.formatters.a = (v?: BN): string => { }; // Add a formatter for converting to a b256 string -debug.formatters.b = (v?: AbstractAddress): string => (v == null ? 'undefined' : v.toB256()); +debug.formatters.b = (v?: Address): string => (v == null ? 'undefined' : v.toB256()); // Add a formatter for outputting a BN hex string debug.formatters.h = (v?: BN): string => (v == null ? 'undefined' : v.toHex()); diff --git a/packages/logger/test/index.test.ts b/packages/logger/test/index.test.ts index f3933fce4bf..94826315f4d 100644 --- a/packages/logger/test/index.test.ts +++ b/packages/logger/test/index.test.ts @@ -85,7 +85,7 @@ describe('Logger Tests', () => { expect(formatted).toBe('undefined'); }); - it('should format AbstractAddress to b256 string using formatter b', () => { + it('should format Address to b256 string using formatter b', () => { const mockAddress = { toB256: () => '0xabcdef1234567890', }; diff --git a/packages/program/package.json b/packages/program/package.json index df590f63d6f..038ca0c1c6c 100644 --- a/packages/program/package.json +++ b/packages/program/package.json @@ -30,7 +30,6 @@ "@fuel-ts/account": "workspace:*", "@fuel-ts/address": "workspace:*", "@fuel-ts/errors": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/math": "workspace:*", "@fuel-ts/transactions": "workspace:*", "@fuel-ts/utils": "workspace:*", diff --git a/packages/program/src/contract-call-script.ts b/packages/program/src/contract-call-script.ts index b518d3d6fdf..f43811fc8f7 100644 --- a/packages/program/src/contract-call-script.ts +++ b/packages/program/src/contract-call-script.ts @@ -12,9 +12,9 @@ import type { TransactionResultReturnDataReceipt, TransactionResultReturnReceipt, } from '@fuel-ts/account'; +import type { Address } from '@fuel-ts/address'; import { ZeroBytes32 } from '@fuel-ts/address/configs'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { AbstractAddress } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; import { bn, toNumber } from '@fuel-ts/math'; import { ReceiptType } from '@fuel-ts/transactions'; @@ -107,7 +107,7 @@ const getMainCallReceipt = ( type === ReceiptType.Call && id === SCRIPT_WRAPPER_CONTRACT_ID && to === contractId ); -const scriptResultDecoder = (contractId: AbstractAddress) => (result: ScriptResult) => { +const scriptResultDecoder = (contractId: Address) => (result: ScriptResult) => { if (toNumber(result.code) !== 0) { throw new FuelError(ErrorCode.SCRIPT_REVERTED, `Transaction reverted.`); } @@ -140,7 +140,7 @@ const scriptResultDecoder = (contractId: AbstractAddress) => (result: ScriptResu export const decodeContractCallScriptResult = ( callResult: CallResult, - contractId: AbstractAddress, + contractId: Address, logs: Array = [] ): Uint8Array[] => decodeCallResult(callResult, scriptResultDecoder(contractId), logs); diff --git a/packages/program/src/contract.ts b/packages/program/src/contract.ts index e1caf4e8c21..3193944fc04 100644 --- a/packages/program/src/contract.ts +++ b/packages/program/src/contract.ts @@ -2,11 +2,11 @@ import type { FunctionFragment, JsonAbi } from '@fuel-ts/abi-coder'; import { Interface } from '@fuel-ts/abi-coder'; import type { Account, Provider } from '@fuel-ts/account'; import { Address } from '@fuel-ts/address'; -import type { AbstractAddress, AbstractContract, BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import { FunctionInvocationScope } from './functions/invocation-scope'; import { MultiCallInvocationScope } from './functions/multicall-scope'; -import type { InvokeFunction, InvokeFunctions } from './types'; +import type { AbstractContract, InvokeFunction, InvokeFunctions } from './types'; /** * `Contract` provides a way to interact with the contract program type. @@ -15,7 +15,7 @@ export default class Contract implements AbstractContract { /** * The unique contract identifier. */ - id!: AbstractAddress; + id!: Address; /** * The provider for interacting with the contract. @@ -45,7 +45,7 @@ export default class Contract implements AbstractContract { * @param accountOrProvider - The account or provider for interaction. */ constructor( - id: string | AbstractAddress, + id: string | Address, abi: JsonAbi | Interface, accountOrProvider: Account | Provider ) { diff --git a/packages/program/src/functions/base-invocation-scope.ts b/packages/program/src/functions/base-invocation-scope.ts index a4f75a0598b..38cb769a153 100644 --- a/packages/program/src/functions/base-invocation-scope.ts +++ b/packages/program/src/functions/base-invocation-scope.ts @@ -9,11 +9,11 @@ import type { TransferParams, TransactionResponse, TransactionCost, + AbstractAccount, } from '@fuel-ts/account'; import { ScriptTransactionRequest, Wallet } from '@fuel-ts/account'; import { Address } from '@fuel-ts/address'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { AbstractAccount, AbstractContract, AbstractProgram } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; import { bn } from '@fuel-ts/math'; import { InputType, TransactionType } from '@fuel-ts/transactions'; @@ -29,6 +29,8 @@ import type { TxParams, FunctionResult, DryRunResult, + AbstractContract, + AbstractProgram, } from '../types'; import { assert, getAbisFromAllCalls } from '../utils'; diff --git a/packages/program/src/functions/invocation-scope.ts b/packages/program/src/functions/invocation-scope.ts index 70c69106fde..49556956052 100644 --- a/packages/program/src/functions/invocation-scope.ts +++ b/packages/program/src/functions/invocation-scope.ts @@ -3,9 +3,8 @@ import type { FunctionFragment } from '@fuel-ts/abi-coder'; import type { CoinQuantity } from '@fuel-ts/account'; import { coinQuantityfy } from '@fuel-ts/account'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { AbstractProgram } from '@fuel-ts/interfaces'; -import type { CallConfig, CallParams } from '../types'; +import type { AbstractProgram, CallConfig, CallParams } from '../types'; import { BaseInvocationScope } from './base-invocation-scope'; diff --git a/packages/program/src/functions/multicall-scope.ts b/packages/program/src/functions/multicall-scope.ts index 754f78cb87a..1c00d69b301 100644 --- a/packages/program/src/functions/multicall-scope.ts +++ b/packages/program/src/functions/multicall-scope.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import type { AbstractContract } from '@fuel-ts/interfaces'; +import type { AbstractContract } from '../types'; import { BaseInvocationScope } from './base-invocation-scope'; import type { FunctionInvocationScope } from './invocation-scope'; diff --git a/packages/program/src/response.ts b/packages/program/src/response.ts index 2389ae94180..54159eccb3e 100644 --- a/packages/program/src/response.ts +++ b/packages/program/src/response.ts @@ -5,12 +5,17 @@ import type { CallResult, } from '@fuel-ts/account'; import { getGasUsedFromReceipts } from '@fuel-ts/account'; -import type { AbstractContract, AbstractProgram } from '@fuel-ts/interfaces'; import type { TransactionType } from '@fuel-ts/transactions'; import { decodeContractCallScriptResult } from './contract-call-script'; import { callResultToInvocationResult } from './script-request'; -import type { InvocationScopeLike, FunctionResult, DryRunResult } from './types'; +import type { + AbstractContract, + AbstractProgram, + InvocationScopeLike, + FunctionResult, + DryRunResult, +} from './types'; import { getResultLogs } from './utils'; /** @hidden */ diff --git a/packages/program/src/script-request.ts b/packages/program/src/script-request.ts index a5f456e7963..79d749c033c 100644 --- a/packages/program/src/script-request.ts +++ b/packages/program/src/script-request.ts @@ -17,10 +17,10 @@ import type { } from '@fuel-ts/account'; import { extractTxError } from '@fuel-ts/account'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { BytesLike } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; import type { ReceiptScriptResult } from '@fuel-ts/transactions'; import { ReceiptType } from '@fuel-ts/transactions'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify } from '@fuel-ts/utils'; import type { CallConfig } from './types'; diff --git a/packages/program/src/types.ts b/packages/program/src/types.ts index 258f98c277f..fc373f52f30 100644 --- a/packages/program/src/types.ts +++ b/packages/program/src/types.ts @@ -1,4 +1,5 @@ -import type { FunctionFragment, JsonAbi } from '@fuel-ts/abi-coder'; +/* eslint-disable max-classes-per-file */ +import type { FunctionFragment, JsonAbi, Interface } from '@fuel-ts/abi-coder'; import type { CallResult, CoinQuantity, @@ -6,17 +7,33 @@ import type { TransactionResponse, TransactionResult, TransactionType, + AbstractAccount, + Provider, } from '@fuel-ts/account'; -import type { AbstractProgram, AbstractAddress, BytesLike } from '@fuel-ts/interfaces'; +import type { Address, WithContractId } from '@fuel-ts/address'; import type { BN, BigNumberish } from '@fuel-ts/math'; +import type { BytesLike } from '@fuel-ts/utils'; import type { FunctionInvocationScope } from './functions/invocation-scope'; +/** + * @hidden + */ +export abstract class AbstractProgram { + abstract account: AbstractAccount | null; + abstract interface: Pick; + abstract provider: Pick | null; +} + +export abstract class AbstractContract extends AbstractProgram implements WithContractId { + abstract id: Address; +} + /** * Represents a contract call. */ export type ContractCall = { - contractId: AbstractAddress; + contractId: Address; data: BytesLike; fnSelectorBytes: Uint8Array; amount?: BigNumberish; diff --git a/packages/program/src/utils.ts b/packages/program/src/utils.ts index def6899b9b8..dac9f8e6cb0 100644 --- a/packages/program/src/utils.ts +++ b/packages/program/src/utils.ts @@ -1,9 +1,8 @@ import { getDecodedLogs } from '@fuel-ts/account'; import type { TransactionResultReceipt, JsonAbisFromAllCalls } from '@fuel-ts/account'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { AbstractContract } from '@fuel-ts/interfaces'; -import type { CallConfig, InvocationScopeLike } from './types'; +import type { AbstractContract, CallConfig, InvocationScopeLike } from './types'; /** * @hidden diff --git a/packages/recipes/package.json b/packages/recipes/package.json index bc566fe267c..7de02b277d2 100644 --- a/packages/recipes/package.json +++ b/packages/recipes/package.json @@ -28,10 +28,10 @@ }, "license": "Apache-2.0", "dependencies": { + "@fuel-ts/address": "workspace:*", "@fuel-ts/abi-coder": "workspace:*", "@fuel-ts/abi-typegen": "workspace:*", "@fuel-ts/account": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/program": "workspace:*", "@fuel-ts/transactions": "workspace:*", "@fuel-ts/utils": "workspace:*", diff --git a/packages/recipes/scripts/build-recipes.ts b/packages/recipes/scripts/build-recipes.ts index 0e4003f3f86..9df639cbcfa 100644 --- a/packages/recipes/scripts/build-recipes.ts +++ b/packages/recipes/scripts/build-recipes.ts @@ -13,10 +13,10 @@ const importReplacementMap = { Provider: '@fuel-ts/account', Account: '@fuel-ts/account', StorageSlot: '@fuel-ts/transactions', - AbstractAddress: '@fuel-ts/interfaces', + Address: '@fuel-ts/address', FunctionFragment: '@fuel-ts/abi-coder', InvokeFunction: '@fuel-ts/program', - StrSlice: '@fuel-ts/interfaces', + StrSlice: '@fuel-ts/abi-coder', decompressBytecode: '@fuel-ts/utils', }; diff --git a/packages/recipes/src/types/Src14OwnedProxy.ts b/packages/recipes/src/types/Src14OwnedProxy.ts index aab3c9532ae..494f285063c 100644 --- a/packages/recipes/src/types/Src14OwnedProxy.ts +++ b/packages/recipes/src/types/Src14OwnedProxy.ts @@ -9,10 +9,10 @@ */ import { Contract, type InvokeFunction } from '@fuel-ts/program'; -import { Interface, type FunctionFragment } from '@fuel-ts/abi-coder'; +import { Interface, type FunctionFragment, type StrSlice } from '@fuel-ts/abi-coder'; import { type Provider, type Account } from '@fuel-ts/account'; import { type StorageSlot } from '@fuel-ts/transactions'; -import { type AbstractAddress, type StrSlice } from '@fuel-ts/interfaces'; +import { type Address } from '@fuel-ts/address'; import type { Option, Enum } from './common'; export enum AccessErrorInput { @@ -679,7 +679,7 @@ export class Src14OwnedProxy extends Contract { set_proxy_owner: InvokeFunction<[new_proxy_owner: StateInput], void>; }; - constructor(id: string | AbstractAddress, accountOrProvider: Account | Provider) { + constructor(id: string | Address, accountOrProvider: Account | Provider) { super(id, abi, accountOrProvider); } } diff --git a/packages/script/package.json b/packages/script/package.json index 93b9cbad421..92d4b60d6de 100644 --- a/packages/script/package.json +++ b/packages/script/package.json @@ -31,7 +31,6 @@ "@fuel-ts/account": "workspace:*", "@fuel-ts/address": "workspace:*", "@fuel-ts/errors": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/math": "workspace:*", "@fuel-ts/program": "workspace:*", "@fuel-ts/transactions": "workspace:*", diff --git a/packages/script/src/index.ts b/packages/script/src/index.ts index 0a064b69c46..636f76a54c4 100644 --- a/packages/script/src/index.ts +++ b/packages/script/src/index.ts @@ -1,2 +1,3 @@ export * from './script'; export * from './scripts'; +export * from './types'; diff --git a/packages/script/src/script-invocation-scope.ts b/packages/script/src/script-invocation-scope.ts index d2b880e2881..e9e0c5ebeda 100644 --- a/packages/script/src/script-invocation-scope.ts +++ b/packages/script/src/script-invocation-scope.ts @@ -1,9 +1,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import type { Provider } from '@fuel-ts/account'; import { FuelError } from '@fuel-ts/errors'; -import type { AbstractScript } from '@fuel-ts/interfaces'; import { ScriptRequest, FunctionInvocationScope } from '@fuel-ts/program'; +import type { AbstractScript } from './types'; + export class ScriptInvocationScope< TArgs extends Array = Array, TReturn = any, diff --git a/packages/script/src/script.ts b/packages/script/src/script.ts index 765ce671e51..fd86461b8c9 100644 --- a/packages/script/src/script.ts +++ b/packages/script/src/script.ts @@ -3,13 +3,13 @@ import { Interface } from '@fuel-ts/abi-coder'; import type { InputValue, JsonAbi } from '@fuel-ts/abi-coder'; import { deployScriptOrPredicate, type Account, type Provider } from '@fuel-ts/account'; import { FuelError } from '@fuel-ts/errors'; -import { AbstractScript } from '@fuel-ts/interfaces'; -import type { BytesLike } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; import type { ScriptRequest } from '@fuel-ts/program'; +import type { BytesLike } from '@fuel-ts/utils'; import { arrayify } from '@fuel-ts/utils'; import { ScriptInvocationScope } from './script-invocation-scope'; +import { AbstractScript } from './types'; /** * Represents the result of a script execution. diff --git a/packages/script/src/types.ts b/packages/script/src/types.ts new file mode 100644 index 00000000000..cdb548011f3 --- /dev/null +++ b/packages/script/src/types.ts @@ -0,0 +1,8 @@ +import { AbstractProgram } from '@fuel-ts/program'; + +/** + * @hidden + */ +export abstract class AbstractScript extends AbstractProgram { + abstract bytes: Uint8Array; +} diff --git a/packages/transactions/package.json b/packages/transactions/package.json index 84e9e0bf45a..014f1b97166 100644 --- a/packages/transactions/package.json +++ b/packages/transactions/package.json @@ -40,8 +40,7 @@ "@fuel-ts/abi-coder": "workspace:*", "@fuel-ts/address": "workspace:*", "@fuel-ts/errors": "workspace:*", - "@fuel-ts/hasher": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", + "@fuel-ts/hasher": "workspace:^", "@fuel-ts/math": "workspace:*", "@fuel-ts/utils": "workspace:*" } diff --git a/packages/transactions/src/coders/byte-array.ts b/packages/transactions/src/coders/byte-array.ts index 2b751b5e7d0..b5ba3ec11e2 100644 --- a/packages/transactions/src/coders/byte-array.ts +++ b/packages/transactions/src/coders/byte-array.ts @@ -1,5 +1,5 @@ import { Coder } from '@fuel-ts/abi-coder'; -import type { BytesLike } from '@fuel-ts/interfaces'; +import type { BytesLike } from '@fuel-ts/utils'; import { concat, hexlify, arrayify } from '@fuel-ts/utils'; export class ByteArrayCoder extends Coder { diff --git a/packages/transactions/src/coders/input.ts b/packages/transactions/src/coders/input.ts index a5a227e751e..140ab70589f 100644 --- a/packages/transactions/src/coders/input.ts +++ b/packages/transactions/src/coders/input.ts @@ -2,8 +2,8 @@ import { Coder, B256Coder, NumberCoder, BigNumberCoder } from '@fuel-ts/abi-coder'; import { ErrorCode, FuelError } from '@fuel-ts/errors'; import { sha256 } from '@fuel-ts/hasher'; -import type { BytesLike } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; +import type { BytesLike } from '@fuel-ts/utils'; import { concat, arrayify } from '@fuel-ts/utils'; import { ByteArrayCoder } from './byte-array'; diff --git a/packages/transactions/src/receipt.test.ts b/packages/transactions/src/receipt.test.ts index 03771a8508d..5bae4d01197 100644 --- a/packages/transactions/src/receipt.test.ts +++ b/packages/transactions/src/receipt.test.ts @@ -1,7 +1,7 @@ import { BigNumberCoder } from '@fuel-ts/abi-coder'; +import type { AssetId } from '@fuel-ts/address'; import { getRandomB256 } from '@fuel-ts/address'; import { sha256 } from '@fuel-ts/hasher'; -import type { AssetId } from '@fuel-ts/interfaces'; import { bn } from '@fuel-ts/math'; import { arrayify, concat } from '@fuel-ts/utils'; diff --git a/packages/transactions/src/receipt.ts b/packages/transactions/src/receipt.ts index 2faa336927f..eb204485006 100644 --- a/packages/transactions/src/receipt.ts +++ b/packages/transactions/src/receipt.ts @@ -1,6 +1,6 @@ import { BigNumberCoder } from '@fuel-ts/abi-coder'; +import type { AssetId } from '@fuel-ts/address'; import { sha256 } from '@fuel-ts/hasher'; -import type { AssetId } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; import { arrayify, concat } from '@fuel-ts/utils'; diff --git a/packages/utils/package.json b/packages/utils/package.json index 63a44d2d4dc..1bfdf81420e 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -48,7 +48,6 @@ "license": "Apache-2.0", "dependencies": { "@fuel-ts/errors": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/math": "workspace:*", "@fuel-ts/versions": "workspace:*", "fflate": "0.8.2" diff --git a/packages/utils/src/utils/arrayify.test.ts b/packages/utils/src/utils/arrayify.test.ts index c00d2373e10..b51a4771feb 100644 --- a/packages/utils/src/utils/arrayify.test.ts +++ b/packages/utils/src/utils/arrayify.test.ts @@ -1,7 +1,7 @@ import { FuelError, ErrorCode } from '@fuel-ts/errors'; -import type { BytesLike } from '@fuel-ts/interfaces'; import { arrayify } from './arrayify'; +import type { BytesLike } from './arrayify'; /** * @group node diff --git a/packages/utils/src/utils/arrayify.ts b/packages/utils/src/utils/arrayify.ts index bfc0e8ac1b3..198ccf6fccf 100644 --- a/packages/utils/src/utils/arrayify.ts +++ b/packages/utils/src/utils/arrayify.ts @@ -1,5 +1,6 @@ import { FuelError, ErrorCode } from '@fuel-ts/errors'; -import type { BytesLike } from '@fuel-ts/interfaces'; + +export type BytesLike = Uint8Array | string; /** * Get a typed Uint8Array from a BytesLike object. diff --git a/packages/utils/src/utils/base58.ts b/packages/utils/src/utils/base58.ts index a416f503cfb..dd922bee0df 100644 --- a/packages/utils/src/utils/base58.ts +++ b/packages/utils/src/utils/base58.ts @@ -1,9 +1,9 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { BytesLike } from '@fuel-ts/interfaces'; import type { BN } from '@fuel-ts/math'; import { bn } from '@fuel-ts/math'; import { arrayify } from './arrayify'; +import type { BytesLike } from './arrayify'; const BN_0 = bn(0); const BN_58 = bn(58); diff --git a/packages/utils/src/utils/bytecode.ts b/packages/utils/src/utils/bytecode.ts index ced17ff5daf..1ff4588f006 100644 --- a/packages/utils/src/utils/bytecode.ts +++ b/packages/utils/src/utils/bytecode.ts @@ -1,7 +1,7 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; import { gzipSync, gunzipSync } from 'fflate'; import { arrayify } from './arrayify'; +import type { BytesLike } from './arrayify'; export const compressBytecode = (bytecodeAsBinary?: BytesLike) => { if (!bytecodeAsBinary) { diff --git a/packages/utils/src/utils/concat.ts b/packages/utils/src/utils/concat.ts index 699e6452787..eff80a7cea6 100644 --- a/packages/utils/src/utils/concat.ts +++ b/packages/utils/src/utils/concat.ts @@ -1,6 +1,5 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; - import { arrayify } from './arrayify'; +import type { BytesLike } from './arrayify'; /** * Concatenates multiple Uint8Arrays into a single Uint8Array. diff --git a/packages/utils/src/utils/dataSlice.ts b/packages/utils/src/utils/dataSlice.ts index efd79ea58f4..14645c2137a 100644 --- a/packages/utils/src/utils/dataSlice.ts +++ b/packages/utils/src/utils/dataSlice.ts @@ -1,7 +1,7 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import type { BytesLike } from '@fuel-ts/interfaces'; import { arrayify } from './arrayify'; +import type { BytesLike } from './arrayify'; import { hexlify } from './hexlify'; /** diff --git a/packages/utils/src/utils/hexlify.ts b/packages/utils/src/utils/hexlify.ts index aca2d197683..9d3dac197a4 100644 --- a/packages/utils/src/utils/hexlify.ts +++ b/packages/utils/src/utils/hexlify.ts @@ -1,6 +1,5 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; - import { arrayify } from './arrayify'; +import type { BytesLike } from './arrayify'; const HexCharacters: string = '0123456789abcdef'; diff --git a/packages/utils/src/utils/toUtf8String.ts b/packages/utils/src/utils/toUtf8String.ts index 992f37b667b..0ed74e659a8 100644 --- a/packages/utils/src/utils/toUtf8String.ts +++ b/packages/utils/src/utils/toUtf8String.ts @@ -1,6 +1,5 @@ -import type { BytesLike } from '@fuel-ts/interfaces'; - import { arrayify } from './arrayify'; +import type { BytesLike } from './arrayify'; /** * These errors are logged when decoding a UTF-8 string fails. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b712c8768af..b91f7714c72 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -571,9 +571,6 @@ importers: '@fuel-ts/hasher': specifier: workspace:* version: link:../../packages/hasher - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../../packages/interfaces '@fuel-ts/math': specifier: workspace:* version: link:../../packages/math @@ -630,11 +627,8 @@ importers: specifier: workspace:* version: link:../errors '@fuel-ts/hasher': - specifier: workspace:* + specifier: workspace:^ version: link:../hasher - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/math': specifier: workspace:* version: link:../math @@ -650,9 +644,6 @@ importers: '@fuel-ts/errors': specifier: workspace:* version: link:../errors - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/utils': specifier: workspace:* version: link:../utils @@ -705,9 +696,6 @@ importers: '@fuel-ts/hasher': specifier: workspace:* version: link:../hasher - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/math': specifier: workspace:* version: link:../math @@ -778,9 +766,6 @@ importers: '@fuel-ts/errors': specifier: workspace:* version: link:../errors - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/utils': specifier: workspace:* version: link:../utils @@ -805,11 +790,8 @@ importers: '@fuel-ts/hasher': specifier: workspace:* version: link:../hasher - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/math': - specifier: workspace:* + specifier: workspace:^ version: link:../math '@fuel-ts/merkle': specifier: workspace:* @@ -876,9 +858,6 @@ importers: '@fuel-ts/errors': specifier: workspace:* version: link:../errors - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/math': specifier: workspace:* version: link:../math @@ -946,9 +925,6 @@ importers: '@fuel-ts/hasher': specifier: workspace:* version: link:../hasher - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/math': specifier: workspace:* version: link:../math @@ -1028,9 +1004,6 @@ importers: '@fuel-ts/crypto': specifier: workspace:* version: link:../crypto - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/utils': specifier: workspace:* version: link:../utils @@ -1038,16 +1011,11 @@ importers: specifier: 1.5.0 version: 1.5.0 - packages/interfaces: {} - packages/logger: dependencies: '@fuel-ts/address': specifier: workspace:* version: link:../address - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/math': specifier: workspace:* version: link:../math @@ -1094,9 +1062,6 @@ importers: '@fuel-ts/errors': specifier: workspace:* version: link:../errors - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/math': specifier: workspace:* version: link:../math @@ -1128,12 +1093,12 @@ importers: '@fuel-ts/account': specifier: workspace:* version: link:../account + '@fuel-ts/address': + specifier: workspace:* + version: link:../address '@fuel-ts/contract': specifier: workspace:* version: link:../contract - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/program': specifier: workspace:* version: link:../program @@ -1158,9 +1123,6 @@ importers: '@fuel-ts/errors': specifier: workspace:* version: link:../errors - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/math': specifier: workspace:* version: link:../math @@ -1190,11 +1152,8 @@ importers: specifier: workspace:* version: link:../errors '@fuel-ts/hasher': - specifier: workspace:* + specifier: workspace:^ version: link:../hasher - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/math': specifier: workspace:* version: link:../math @@ -1207,9 +1166,6 @@ importers: '@fuel-ts/errors': specifier: workspace:* version: link:../errors - '@fuel-ts/interfaces': - specifier: workspace:* - version: link:../interfaces '@fuel-ts/math': specifier: workspace:* version: link:../math