Skip to content

Commit 0b4c3ab

Browse files
petertonysmith94arboleyaTorres-ssf
authored
chore!: redistributed the @fuel-ts/interfaces package (#3492)
* 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 <[email protected]> Co-authored-by: Sérgio Torres <[email protected]>
1 parent e83b237 commit 0b4c3ab

File tree

127 files changed

+318
-1145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+318
-1145
lines changed

.changeset/wild-dots-bake.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
"@internal/check-imports": patch
3+
"@fuel-ts/transactions": patch
4+
"@fuel-ts/abi-typegen": patch
5+
"@fuel-ts/abi-coder": patch
6+
"@fuel-ts/contract": patch
7+
"@fuel-ts/account": patch
8+
"@fuel-ts/address": patch
9+
"@fuel-ts/program": patch
10+
"@fuel-ts/recipes": patch
11+
"@fuel-ts/crypto": patch
12+
"@fuel-ts/errors": patch
13+
"@fuel-ts/hasher": patch
14+
"@fuel-ts/logger": patch
15+
"@fuel-ts/script": patch
16+
"fuels": minor
17+
"@fuel-ts/utils": patch
18+
---
19+
20+
chore!: redistributed the `@fuel-ts/interfaces` package

apps/docs/spell-check-custom-words.txt

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ ABI
22
ABI's
33
abigen
44
ABIs
5-
AbstractAddress
65
ALU
76
ANDs
87
API's

apps/docs/src/guide/contracts/managing-deployed-contracts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ To interact with a deployed contract using the SDK without redeploying it, you o
44

55
## Contract ID
66

7-
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.
7+
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.
88

99
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.
1010

apps/docs/src/guide/types/address.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,15 @@
22

33
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.
44

5-
## `AbstractAddress` Class
6-
7-
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.
8-
9-
<<< @/../../../packages/interfaces/src/index.ts#address-1{ts:line-numbers}
10-
115
## Address Class
126

13-
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.
7+
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.
148

159
<<< @/../../../packages/address/src/address.ts#address-2{ts:line-numbers}
1610

1711
## Creating an Address
1812

19-
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:
13+
There are several ways to create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) instance:
2014

2115
### From a b256 address
2216

apps/docs/src/guide/utilities/address-conversion.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ This guide demonstrates how to convert between address formats and Sway Standard
2525

2626
## Converting a Contract ID
2727

28-
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`:
28+
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`:
2929

3030
<<< @./snippets/address-conversion/contract.ts#conversion-2{ts:line-numbers}
3131

3232
## Converting a Wallet Address
3333

34-
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:
34+
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:
3535

3636
<<< @./snippets/address-conversion/wallet.ts#conversion-3{ts:line-numbers}
3737

internal/check-imports/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"@fuel-ts/crypto": "workspace:*",
1717
"@fuel-ts/errors": "workspace:*",
1818
"@fuel-ts/hasher": "workspace:*",
19-
"@fuel-ts/interfaces": "workspace:*",
2019
"@fuel-ts/math": "workspace:*",
2120
"@fuel-ts/merkle": "workspace:*",
2221
"@fuel-ts/program": "workspace:*",

internal/check-imports/src/imports.ts

-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import * as errors from '@fuel-ts/errors';
88
// forc-bin
99
// fuels-gauge
1010
import * as hasher from '@fuel-ts/hasher';
11-
import * as interfaces from '@fuel-ts/interfaces';
1211
import * as math from '@fuel-ts/math';
1312
import * as merkle from '@fuel-ts/merkle';
1413
import * as program from '@fuel-ts/program';
@@ -28,7 +27,6 @@ log([
2827
errors,
2928
fuels,
3029
hasher,
31-
interfaces,
3230
crypto,
3331
math,
3432
merkle,

packages/abi-coder/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
"dependencies": {
3030
"@fuel-ts/crypto": "workspace:*",
3131
"@fuel-ts/errors": "workspace:*",
32-
"@fuel-ts/hasher": "workspace:*",
33-
"@fuel-ts/interfaces": "workspace:*",
32+
"@fuel-ts/hasher": "workspace:^",
3433
"@fuel-ts/math": "workspace:*",
3534
"@fuel-ts/utils": "workspace:*",
3635
"type-fest": "4.26.1"

packages/abi-coder/src/FunctionFragment.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { bufferFromString } from '@fuel-ts/crypto';
22
import { ErrorCode, FuelError } from '@fuel-ts/errors';
33
import { sha256 } from '@fuel-ts/hasher';
4-
import type { BytesLike } from '@fuel-ts/interfaces';
54
import { bn } from '@fuel-ts/math';
5+
import type { BytesLike } from '@fuel-ts/utils';
66
import { arrayify } from '@fuel-ts/utils';
77

88
import { AbiCoder } from './AbiCoder';

packages/abi-coder/src/Interface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import { ErrorCode, FuelError } from '@fuel-ts/errors';
3-
import type { BytesLike } from '@fuel-ts/interfaces';
3+
import type { BytesLike } from '@fuel-ts/utils';
44
import { arrayify } from '@fuel-ts/utils';
55

66
import { AbiCoder } from './AbiCoder';

packages/abi-coder/src/encoding/coders/AbstractCoder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { BytesLike } from '@fuel-ts/interfaces';
21
import type { BN } from '@fuel-ts/math';
2+
import type { BytesLike } from '@fuel-ts/utils';
33

44
import type { Option } from './OptionCoder';
55

packages/abi-coder/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ export {
1414
calculateVmTxMemory,
1515
ENCODING_V1,
1616
} from './utils/constants';
17+
export type { Bytes, RawSlice, StdString, StrSlice } from './utils/types';

packages/abi-coder/src/utils/types.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export type Bytes = Uint8Array | number[];
2+
export type RawSlice = Uint8Array | number[];
3+
export type StdString = string;
4+
export type StrSlice = string;

packages/abi-typegen/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"license": "Apache-2.0",
5454
"dependencies": {
5555
"@fuel-ts/errors": "workspace:*",
56-
"@fuel-ts/interfaces": "workspace:*",
5756
"@fuel-ts/utils": "workspace:*",
5857
"@fuel-ts/versions": "workspace:*",
5958
"commander": "12.1.0",

packages/abi-typegen/src/templates/contract/main.hbs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
Provider,
77
Account,
88
StorageSlot,
9-
AbstractAddress,
9+
Address,
1010
{{#each imports}}
1111
{{this}},
1212
{{/each}}
@@ -81,7 +81,7 @@ export class {{capitalizedName}} extends Contract {
8181
};
8282

8383
constructor(
84-
id: string | AbstractAddress,
84+
id: string | Address,
8585
accountOrProvider: Account | Provider,
8686
) {
8787
super(id, abi, accountOrProvider);

packages/abi-typegen/test/fixtures/templates/contract-with-configurable/main.hbs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type {
1515
Provider,
1616
Account,
1717
StorageSlot,
18-
AbstractAddress,
18+
Address,
1919
BigNumberish,
2020
FunctionFragment,
2121
InvokeFunction,
@@ -197,7 +197,7 @@ export class MyContract extends Contract {
197197
};
198198

199199
constructor(
200-
id: string | AbstractAddress,
200+
id: string | Address,
201201
accountOrProvider: Account | Provider,
202202
) {
203203
super(id, abi, accountOrProvider);

packages/abi-typegen/test/fixtures/templates/contract/main.hbs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type {
1515
Provider,
1616
Account,
1717
StorageSlot,
18-
AbstractAddress,
18+
Address,
1919
BigNumberish,
2020
BN,
2121
Bytes,
@@ -1248,7 +1248,7 @@ export class MyContract extends Contract {
12481248
};
12491249

12501250
constructor(
1251-
id: string | AbstractAddress,
1251+
id: string | Address,
12521252
accountOrProvider: Account | Provider,
12531253
) {
12541254
super(id, abi, accountOrProvider);

packages/account/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"@fuel-ts/crypto": "workspace:*",
5454
"@fuel-ts/errors": "workspace:*",
5555
"@fuel-ts/hasher": "workspace:*",
56-
"@fuel-ts/interfaces": "workspace:*",
5756
"@fuel-ts/math": "workspace:*",
5857
"@fuel-ts/merkle": "workspace:*",
5958
"@fuel-ts/transactions": "workspace:*",

packages/account/src/account.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { UTXO_ID_LEN } from '@fuel-ts/abi-coder';
2+
import type { WithAddress } from '@fuel-ts/address';
23
import { Address } from '@fuel-ts/address';
34
import { randomBytes } from '@fuel-ts/crypto';
45
import { ErrorCode, FuelError } from '@fuel-ts/errors';
5-
import { AbstractAccount } from '@fuel-ts/interfaces';
6-
import type { AbstractAddress, BytesLike } from '@fuel-ts/interfaces';
76
import type { BigNumberish, BN } from '@fuel-ts/math';
87
import { bn } from '@fuel-ts/math';
98
import { InputType } from '@fuel-ts/transactions';
9+
import type { BytesLike } from '@fuel-ts/utils';
1010
import { arrayify, hexlify, isDefined } from '@fuel-ts/utils';
1111
import { clone } from 'ramda';
1212

@@ -46,6 +46,7 @@ import {
4646
isRequestInputResource,
4747
} from './providers/transaction-request/helpers';
4848
import { mergeQuantities } from './providers/utils/merge-quantities';
49+
import { AbstractAccount } from './types';
4950
import { assembleTransferToContractScript } from './utils/formatTransferToContractScriptData';
5051

5152
export type TxParamsType = Pick<
@@ -54,13 +55,13 @@ export type TxParamsType = Pick<
5455
>;
5556

5657
export type TransferParams = {
57-
destination: string | AbstractAddress;
58+
destination: string | Address;
5859
amount: BigNumberish;
5960
assetId: BytesLike;
6061
};
6162

6263
export type ContractTransferParams = {
63-
contractId: string | AbstractAddress;
64+
contractId: string | Address;
6465
amount: BigNumberish;
6566
assetId: BytesLike;
6667
};
@@ -76,11 +77,11 @@ export type FakeResources = Partial<Coin> & Required<Pick<Coin, 'amount' | 'asse
7677
/**
7778
* `Account` provides an abstraction for interacting with accounts or wallets on the network.
7879
*/
79-
export class Account extends AbstractAccount {
80+
export class Account extends AbstractAccount implements WithAddress {
8081
/**
8182
* The address associated with the account.
8283
*/
83-
readonly address: AbstractAddress;
84+
readonly address: Address;
8485

8586
/**
8687
* The provider used to interact with the network.
@@ -99,7 +100,7 @@ export class Account extends AbstractAccount {
99100
* @param provider - A Provider instance (optional).
100101
* @param connector - A FuelConnector instance (optional).
101102
*/
102-
constructor(address: string | AbstractAddress, provider?: Provider, connector?: FuelConnector) {
103+
constructor(address: string | Address, provider?: Provider, connector?: FuelConnector) {
103104
super();
104105
this._provider = provider;
105106
this._connector = connector;
@@ -341,7 +342,7 @@ export class Account extends AbstractAccount {
341342
* @returns A promise that resolves to the prepared transaction request.
342343
*/
343344
async createTransfer(
344-
destination: string | AbstractAddress,
345+
destination: string | Address,
345346
amount: BigNumberish,
346347
assetId?: BytesLike,
347348
txParams: TxParamsType = {}
@@ -369,7 +370,7 @@ export class Account extends AbstractAccount {
369370
* @returns A promise that resolves to the transaction response.
370371
*/
371372
async transfer(
372-
destination: string | AbstractAddress,
373+
destination: string | Address,
373374
amount: BigNumberish,
374375
assetId?: BytesLike,
375376
txParams: TxParamsType = {}
@@ -437,7 +438,7 @@ export class Account extends AbstractAccount {
437438
* @returns A promise that resolves to the transaction response.
438439
*/
439440
async transferToContract(
440-
contractId: string | AbstractAddress,
441+
contractId: string | Address,
441442
amount: BigNumberish,
442443
assetId: BytesLike,
443444
txParams: TxParamsType = {}
@@ -499,7 +500,7 @@ export class Account extends AbstractAccount {
499500
* @returns A promise that resolves to the transaction response.
500501
*/
501502
async withdrawToBaseLayer(
502-
recipient: string | AbstractAddress,
503+
recipient: string | Address,
503504
amount: BigNumberish,
504505
txParams: TxParamsType = {}
505506
): Promise<TransactionResponse> {

packages/account/src/connectors/fuel.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import type { Address } from '@fuel-ts/address';
12
import { ErrorCode, FuelError } from '@fuel-ts/errors';
2-
import type { AbstractAddress } from '@fuel-ts/interfaces';
33

44
import { Account } from '../account';
55
import { Provider } from '../providers';
@@ -62,10 +62,7 @@ interface FuelSdk {
6262
hasWallet(): Promise<boolean>;
6363
// #endregion connector-manager-method-hasWallet
6464
// #region connector-manager-method-getWallet
65-
getWallet(
66-
address: string | AbstractAddress,
67-
providerOrNetwork?: Provider | Network
68-
): Promise<Account>;
65+
getWallet(address: string | Address, providerOrNetwork?: Provider | Network): Promise<Account>;
6966
// #endregion connector-manager-method-getWallet
7067
// #region connector-manager-method-unsubscribe
7168
unsubscribe(): void;
@@ -465,7 +462,7 @@ export class Fuel extends FuelConnector implements FuelSdk {
465462
* connectors.
466463
*/
467464
async getWallet(
468-
address: string | AbstractAddress,
465+
address: string | Address,
469466
providerOrNetwork?: Provider | Network
470467
): Promise<Account> {
471468
const provider = await this._getProvider(providerOrNetwork);

packages/account/src/hdwallet/hdwallet.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { computeHmac, ripemd160 } from '@fuel-ts/crypto';
22
import { ErrorCode, FuelError } from '@fuel-ts/errors';
33
import { sha256 } from '@fuel-ts/hasher';
4-
import type { BytesLike } from '@fuel-ts/interfaces';
54
import { bn, toBytes, toHex } from '@fuel-ts/math';
5+
import type { BytesLike } from '@fuel-ts/utils';
66
import { arrayify, hexlify, concat, dataSlice, encodeBase58, decodeBase58 } from '@fuel-ts/utils';
77

88
import { Mnemonic } from '../mnemonic';

packages/account/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './account';
2+
export * from './types';
23
export * from './wallet';
34
export * from './hdwallet';
45
export * from './mnemonic';

packages/account/src/mnemonic/mnemonic.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { randomBytes, pbkdf2, computeHmac } from '@fuel-ts/crypto';
22
import { ErrorCode, FuelError } from '@fuel-ts/errors';
33
import { sha256 } from '@fuel-ts/hasher';
4-
import type { BytesLike } from '@fuel-ts/interfaces';
4+
import type { BytesLike } from '@fuel-ts/utils';
55
import { arrayify, hexlify, concat, dataSlice, encodeBase58, toUtf8Bytes } from '@fuel-ts/utils';
66

77
import { english } from '../wordlists';

packages/account/src/mnemonic/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ErrorCode, FuelError } from '@fuel-ts/errors';
22
import { sha256 } from '@fuel-ts/hasher';
3-
import type { BytesLike } from '@fuel-ts/interfaces';
3+
import type { BytesLike } from '@fuel-ts/utils';
44
import { arrayify } from '@fuel-ts/utils';
55

66
/* Mnemonic phrase composed by words from the provided wordlist it can be a text or a array of words */

packages/account/src/predicate/predicate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { JsonAbi, InputValue } from '@fuel-ts/abi-coder';
22
import { Interface } from '@fuel-ts/abi-coder';
33
import { Address } from '@fuel-ts/address';
44
import { ErrorCode, FuelError } from '@fuel-ts/errors';
5-
import type { BytesLike } from '@fuel-ts/interfaces';
5+
import type { BytesLike } from '@fuel-ts/utils';
66
import { arrayify, hexlify } from '@fuel-ts/utils';
77

88
import type { FakeResources } from '../account';

packages/account/src/predicate/utils/getPredicateRoot.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { hash } from '@fuel-ts/hasher';
2-
import type { BytesLike } from '@fuel-ts/interfaces';
32
import { calcRoot } from '@fuel-ts/merkle';
43
import { chunkAndPadBytes, hexlify, concat, arrayify } from '@fuel-ts/utils';
4+
import type { BytesLike } from '@fuel-ts/utils';
55

66
/**
77
* @hidden

0 commit comments

Comments
 (0)