From d8725d5164c85f8d692237c3a6bc488828711158 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 18 Jul 2024 16:42:43 +0100 Subject: [PATCH 01/18] feat: invalid -> unsupported txs --- apps/docs/src/guide/errors/index.md | 4 ++-- .../transaction-request/transaction-request.test.ts | 6 +++--- .../account/src/providers/transaction-request/utils.ts | 5 ++++- .../src/providers/transaction-summary/operations.test.ts | 2 +- .../src/providers/transaction-summary/operations.ts | 4 ++-- packages/errors/src/error-codes.ts | 2 +- packages/fuel-gauge/src/transaction.test.ts | 2 ++ packages/transactions/src/coders/transaction.ts | 8 ++++---- packages/transactions/src/coders/upgrade-purpose.ts | 8 ++++---- 9 files changed, 23 insertions(+), 18 deletions(-) diff --git a/apps/docs/src/guide/errors/index.md b/apps/docs/src/guide/errors/index.md index 27b94c4c1ef..2feb5012a90 100644 --- a/apps/docs/src/guide/errors/index.md +++ b/apps/docs/src/guide/errors/index.md @@ -174,9 +174,9 @@ When the transaction status received from the node is unexpected. Check the status received is within `TransactionStatus`. -### `INVALID_TRANSACTION_TYPE` +### `UNSUPPORTED_TRANSACTION_TYPE` -When the transaction type from the Fuel Node is _not_ valid. +When the transaction type from the Fuel Node is _not_ supported. The type is within [`TransactionType`](../../api/Account/TransactionType.md). diff --git a/packages/account/src/providers/transaction-request/transaction-request.test.ts b/packages/account/src/providers/transaction-request/transaction-request.test.ts index d25feee64e3..dded844f561 100644 --- a/packages/account/src/providers/transaction-request/transaction-request.test.ts +++ b/packages/account/src/providers/transaction-request/transaction-request.test.ts @@ -185,11 +185,11 @@ describe('transactionRequestify', () => { expect(txRequest.witnesses).toEqual(txRequestLike.witnesses); }); - it('should throw error if invalid transaction type', () => { + it('should throw error if unsupported transaction type', () => { const txRequestLike = { - type: 5, + type: 1234, }; - expect(() => transactionRequestify(txRequestLike)).toThrow('Invalid transaction type: 5'); + expect(() => transactionRequestify(txRequestLike)).toThrow('Unsupported transaction type: 1234'); }); }); diff --git a/packages/account/src/providers/transaction-request/utils.ts b/packages/account/src/providers/transaction-request/utils.ts index d89de4772cb..3aeac32e56a 100644 --- a/packages/account/src/providers/transaction-request/utils.ts +++ b/packages/account/src/providers/transaction-request/utils.ts @@ -21,7 +21,10 @@ export const transactionRequestify = (obj: TransactionRequestLike): TransactionR return CreateTransactionRequest.from(obj); } default: { - throw new FuelError(ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`); + throw new FuelError( + ErrorCode.UNSUPPORTED_TRANSACTION_TYPE, + `Unsupported transaction type: ${type}.` + ); } } }; diff --git a/packages/account/src/providers/transaction-summary/operations.test.ts b/packages/account/src/providers/transaction-summary/operations.test.ts index 2cda7a660bb..cf20482aca0 100644 --- a/packages/account/src/providers/transaction-summary/operations.test.ts +++ b/packages/account/src/providers/transaction-summary/operations.test.ts @@ -936,7 +936,7 @@ describe('operations', () => { expect(getTransactionTypeName(TransactionType.Script)).toBe(TransactionTypeName.Script); expect(() => getTransactionTypeName('' as unknown as TransactionType)).toThrowError( - 'Invalid transaction type: ' + 'Unsupported transaction type: ' ); }); }); diff --git a/packages/account/src/providers/transaction-summary/operations.ts b/packages/account/src/providers/transaction-summary/operations.ts index 55b4edd64b1..17e4f677302 100644 --- a/packages/account/src/providers/transaction-summary/operations.ts +++ b/packages/account/src/providers/transaction-summary/operations.ts @@ -57,8 +57,8 @@ export function getTransactionTypeName(transactionType: TransactionType): Transa return TransactionTypeName.Script; default: throw new FuelError( - ErrorCode.INVALID_TRANSACTION_TYPE, - `Invalid transaction type: ${transactionType}.` + ErrorCode.UNSUPPORTED_TRANSACTION_TYPE, + `Unsupported transaction type: ${transactionType}.` ); } } diff --git a/packages/errors/src/error-codes.ts b/packages/errors/src/error-codes.ts index 3a7927f71e1..d5550550b90 100644 --- a/packages/errors/src/error-codes.ts +++ b/packages/errors/src/error-codes.ts @@ -67,7 +67,7 @@ export enum ErrorCode { INVALID_TRANSACTION_INPUT = 'invalid-transaction-input', INVALID_TRANSACTION_OUTPUT = 'invalid-transaction-output', INVALID_TRANSACTION_STATUS = 'invalid-transaction-status', - INVALID_TRANSACTION_TYPE = 'invalid-transaction-type', + UNSUPPORTED_TRANSACTION_TYPE = 'unsupported-transaction-type', TRANSACTION_ERROR = 'transaction-error', INVALID_POLICY_TYPE = 'invalid-policy-type', DUPLICATED_POLICY = 'duplicated-policy', diff --git a/packages/fuel-gauge/src/transaction.test.ts b/packages/fuel-gauge/src/transaction.test.ts index e23b872a244..70e9a0fefc8 100644 --- a/packages/fuel-gauge/src/transaction.test.ts +++ b/packages/fuel-gauge/src/transaction.test.ts @@ -21,4 +21,6 @@ describe('Transaction', () => { cleanup(); }); + + }); diff --git a/packages/transactions/src/coders/transaction.ts b/packages/transactions/src/coders/transaction.ts index 1aab7442bb4..efca5d0e472 100644 --- a/packages/transactions/src/coders/transaction.ts +++ b/packages/transactions/src/coders/transaction.ts @@ -628,8 +628,8 @@ export class TransactionCoder extends Coder { } default: { throw new FuelError( - ErrorCode.INVALID_TRANSACTION_TYPE, - `Invalid transaction type: ${type}` + ErrorCode.UNSUPPORTED_TRANSACTION_TYPE, + `Unsupported transaction type: ${type}` ); } } @@ -667,8 +667,8 @@ export class TransactionCoder extends Coder { } default: { throw new FuelError( - ErrorCode.INVALID_TRANSACTION_TYPE, - `Invalid transaction type: ${type}` + ErrorCode.UNSUPPORTED_TRANSACTION_TYPE, + `Unsupported transaction type: ${type}` ); } } diff --git a/packages/transactions/src/coders/upgrade-purpose.ts b/packages/transactions/src/coders/upgrade-purpose.ts index 1b51e340abf..33db4b8d5ad 100644 --- a/packages/transactions/src/coders/upgrade-purpose.ts +++ b/packages/transactions/src/coders/upgrade-purpose.ts @@ -59,8 +59,8 @@ export class UpgradePurposeCoder extends Coder { default: { throw new FuelError( - ErrorCode.INVALID_TRANSACTION_TYPE, - `Invalid transaction type: ${type}` + ErrorCode.UNSUPPORTED_TRANSACTION_TYPE, + `Unsupported transaction type: ${type}` ); } } @@ -94,8 +94,8 @@ export class UpgradePurposeCoder extends Coder { default: { throw new FuelError( - ErrorCode.INVALID_TRANSACTION_TYPE, - `Invalid transaction type: ${type}` + ErrorCode.UNSUPPORTED_TRANSACTION_TYPE, + `Unsupported transaction type: ${type}` ); } } From 6d54746f2fb19f4a3f29433b51993981e45d5a89 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 18 Jul 2024 17:47:19 +0100 Subject: [PATCH 02/18] feat: validate contract size before deploy --- packages/contract/src/contract-factory.ts | 10 +++++++++- packages/contract/src/util.ts | 3 +++ packages/errors/src/error-codes.ts | 1 + packages/fuel-gauge/src/contract-factory.test.ts | 14 ++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/contract/src/contract-factory.ts b/packages/contract/src/contract-factory.ts index 362d0abf025..58e9186202c 100644 --- a/packages/contract/src/contract-factory.ts +++ b/packages/contract/src/contract-factory.ts @@ -15,7 +15,7 @@ import { Contract } from '@fuel-ts/program'; import type { StorageSlot } from '@fuel-ts/transactions'; import { arrayify, isDefined } from '@fuel-ts/utils'; -import { getContractId, getContractStorageRoot, hexlifyWithPrefix } from './util'; +import { MAX_CONTACT_SIZE, getContractId, getContractStorageRoot, hexlifyWithPrefix } from './util'; /** * Options for deploying a contract. @@ -149,7 +149,15 @@ export default class ContractFactory { async deployContract( deployContractOptions: DeployContractOptions = {} ): Promise> { + if (this.bytecode.length > MAX_CONTACT_SIZE) { + throw new FuelError( + ErrorCode.CONTRACT_SIZE_EXCEEDS_LIMIT, + 'Contract bytecode is too large. Max contract size is 100KB' + ); + } + const { contractId, transactionRequest } = await this.prepareDeploy(deployContractOptions); + const account = this.getAccount(); const transactionResponse = await account.sendTransaction(transactionRequest, { diff --git a/packages/contract/src/util.ts b/packages/contract/src/util.ts index 610f7b73ff1..90a5834adf1 100644 --- a/packages/contract/src/util.ts +++ b/packages/contract/src/util.ts @@ -4,6 +4,9 @@ import { calcRoot, SparseMerkleTree } from '@fuel-ts/merkle'; import type { StorageSlot } from '@fuel-ts/transactions'; import { chunkAndPadBytes, hexlify, concat, arrayify } from '@fuel-ts/utils'; +// Max contract size in bytes is 100KB +export const MAX_CONTACT_SIZE = 102400; + /** * @hidden * diff --git a/packages/errors/src/error-codes.ts b/packages/errors/src/error-codes.ts index d5550550b90..4fc0c2f59d7 100644 --- a/packages/errors/src/error-codes.ts +++ b/packages/errors/src/error-codes.ts @@ -72,6 +72,7 @@ export enum ErrorCode { INVALID_POLICY_TYPE = 'invalid-policy-type', DUPLICATED_POLICY = 'duplicated-policy', TRANSACTION_SQUEEZED_OUT = 'transaction-squeezed-out', + CONTRACT_SIZE_EXCEEDS_LIMIT = 'contract-size-exceeds-limit', // receipt INVALID_RECEIPT_TYPE = 'invalid-receipt-type', diff --git a/packages/fuel-gauge/src/contract-factory.test.ts b/packages/fuel-gauge/src/contract-factory.test.ts index 3dff8a68369..664b01b1360 100644 --- a/packages/fuel-gauge/src/contract-factory.test.ts +++ b/packages/fuel-gauge/src/contract-factory.test.ts @@ -230,4 +230,18 @@ describe('Contract Factory', () => { ) ); }); + + it('should not deploy contracts greater than 100KB', async () => { + const factory = await createContractFactory(); + const largeByteCode = `0x${'00'.repeat(102400)}`; + factory.bytecode = largeByteCode; + + await expectToThrowFuelError( + async () => factory.deployContract(), + new FuelError( + ErrorCode.CONTRACT_SIZE_EXCEEDS_LIMIT, + 'Contract bytecode is too large. Max contract size is 100KB' + ) + ); + }); }); From dbc2bd23814d74f5a3fcdfeaf4c9c928a742b837 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 18 Jul 2024 17:50:24 +0100 Subject: [PATCH 03/18] chore: changeset --- .changeset/tall-planes-nail.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changeset/tall-planes-nail.md diff --git a/.changeset/tall-planes-nail.md b/.changeset/tall-planes-nail.md new file mode 100644 index 00000000000..1459231c620 --- /dev/null +++ b/.changeset/tall-planes-nail.md @@ -0,0 +1,8 @@ +--- +"@fuel-ts/transactions": patch +"@fuel-ts/contract": patch +"@fuel-ts/account": patch +"@fuel-ts/errors": patch +--- + +feat: deploy contract validation From a5405bcb2c171556cd45aa5e5827c245f3ecc078 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 18 Jul 2024 18:00:53 +0100 Subject: [PATCH 04/18] docs: add doc re contract deployment size validation --- apps/docs/src/guide/contracts/deploying-contracts.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/docs/src/guide/contracts/deploying-contracts.md b/apps/docs/src/guide/contracts/deploying-contracts.md index 1defa7265da..e894055677c 100644 --- a/apps/docs/src/guide/contracts/deploying-contracts.md +++ b/apps/docs/src/guide/contracts/deploying-contracts.md @@ -9,6 +9,8 @@ This guide walks you through deploying a contract using the SDK, covering loading contract artifacts, initializing a contract factory, and deploying the contract. +> **Note:** The maximum contract deployment size supported by the SDK is 100 KB. The SDK will `throw` for contracts larger than this size. + ## 1. Obtaining Contract Artifacts After writing a contract in Sway and compiling it with `forc build` (read more on how to work with Sway), you will obtain two important artifacts: the compiled binary file and the JSON ABI file. These files are required for deploying a contract using the SDK. From 55db3e4def4dda37dc98e4916ec508b8f4b79d60 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Thu, 18 Jul 2024 18:03:09 +0100 Subject: [PATCH 05/18] chore: lint --- packages/fuel-gauge/src/transaction.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/fuel-gauge/src/transaction.test.ts b/packages/fuel-gauge/src/transaction.test.ts index 70e9a0fefc8..e23b872a244 100644 --- a/packages/fuel-gauge/src/transaction.test.ts +++ b/packages/fuel-gauge/src/transaction.test.ts @@ -21,6 +21,4 @@ describe('Transaction', () => { cleanup(); }); - - }); From a057fa0549a576063f8e88adc10e406ca5f34a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nedim=20Salki=C4=87?= Date: Fri, 19 Jul 2024 09:46:01 +0200 Subject: [PATCH 06/18] FIxed typo --- packages/contract/src/contract-factory.ts | 4 ++-- packages/contract/src/util.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/contract/src/contract-factory.ts b/packages/contract/src/contract-factory.ts index 58e9186202c..bd48624edce 100644 --- a/packages/contract/src/contract-factory.ts +++ b/packages/contract/src/contract-factory.ts @@ -15,7 +15,7 @@ import { Contract } from '@fuel-ts/program'; import type { StorageSlot } from '@fuel-ts/transactions'; import { arrayify, isDefined } from '@fuel-ts/utils'; -import { MAX_CONTACT_SIZE, getContractId, getContractStorageRoot, hexlifyWithPrefix } from './util'; +import { MAX_CONTRACT_SIZE, getContractId, getContractStorageRoot, hexlifyWithPrefix } from './util'; /** * Options for deploying a contract. @@ -149,7 +149,7 @@ export default class ContractFactory { async deployContract( deployContractOptions: DeployContractOptions = {} ): Promise> { - if (this.bytecode.length > MAX_CONTACT_SIZE) { + if (this.bytecode.length > MAX_CONTRACT_SIZE) { throw new FuelError( ErrorCode.CONTRACT_SIZE_EXCEEDS_LIMIT, 'Contract bytecode is too large. Max contract size is 100KB' diff --git a/packages/contract/src/util.ts b/packages/contract/src/util.ts index 90a5834adf1..e540d55235f 100644 --- a/packages/contract/src/util.ts +++ b/packages/contract/src/util.ts @@ -5,7 +5,7 @@ import type { StorageSlot } from '@fuel-ts/transactions'; import { chunkAndPadBytes, hexlify, concat, arrayify } from '@fuel-ts/utils'; // Max contract size in bytes is 100KB -export const MAX_CONTACT_SIZE = 102400; +export const MAX_CONTRACT_SIZE = 102400; /** * @hidden From 672cdd840b712545943797c16dd24fe9676c3e8e Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Jul 2024 09:33:25 +0100 Subject: [PATCH 07/18] chore: changeset --- .changeset/tall-planes-nail.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/tall-planes-nail.md b/.changeset/tall-planes-nail.md index 1459231c620..44c1437016b 100644 --- a/.changeset/tall-planes-nail.md +++ b/.changeset/tall-planes-nail.md @@ -2,7 +2,7 @@ "@fuel-ts/transactions": patch "@fuel-ts/contract": patch "@fuel-ts/account": patch -"@fuel-ts/errors": patch +"@fuel-ts/errors": minor --- feat: deploy contract validation From aa6226dfdd3b4a99d9e43c36519ef99e23968af0 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Jul 2024 09:34:30 +0100 Subject: [PATCH 08/18] chore: changeset --- .changeset/tall-planes-nail.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/tall-planes-nail.md b/.changeset/tall-planes-nail.md index 44c1437016b..480955269e7 100644 --- a/.changeset/tall-planes-nail.md +++ b/.changeset/tall-planes-nail.md @@ -5,4 +5,4 @@ "@fuel-ts/errors": minor --- -feat: deploy contract validation +feat!: deploy contract validation From 12cabd6ee72f84c5fd9a3659c96acc349640f9bb Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Jul 2024 09:58:13 +0100 Subject: [PATCH 09/18] chore: changeset --- .changeset/tall-planes-nail.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/tall-planes-nail.md b/.changeset/tall-planes-nail.md index 480955269e7..1419e9c50db 100644 --- a/.changeset/tall-planes-nail.md +++ b/.changeset/tall-planes-nail.md @@ -1,7 +1,7 @@ --- -"@fuel-ts/transactions": patch +"@fuel-ts/transactions": minor "@fuel-ts/contract": patch -"@fuel-ts/account": patch +"@fuel-ts/account": minor "@fuel-ts/errors": minor --- From a48c39951a03a5752aa66b0348f56f05caea3cbf Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Jul 2024 10:16:43 +0100 Subject: [PATCH 10/18] chore: linting --- .../transaction-request/transaction-request.test.ts | 4 +++- packages/contract/src/contract-factory.ts | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/account/src/providers/transaction-request/transaction-request.test.ts b/packages/account/src/providers/transaction-request/transaction-request.test.ts index dded844f561..738c46cb9e8 100644 --- a/packages/account/src/providers/transaction-request/transaction-request.test.ts +++ b/packages/account/src/providers/transaction-request/transaction-request.test.ts @@ -190,6 +190,8 @@ describe('transactionRequestify', () => { type: 1234, }; - expect(() => transactionRequestify(txRequestLike)).toThrow('Unsupported transaction type: 1234'); + expect(() => transactionRequestify(txRequestLike)).toThrow( + 'Unsupported transaction type: 1234' + ); }); }); diff --git a/packages/contract/src/contract-factory.ts b/packages/contract/src/contract-factory.ts index bd48624edce..f24f03d1d7d 100644 --- a/packages/contract/src/contract-factory.ts +++ b/packages/contract/src/contract-factory.ts @@ -15,7 +15,12 @@ import { Contract } from '@fuel-ts/program'; import type { StorageSlot } from '@fuel-ts/transactions'; import { arrayify, isDefined } from '@fuel-ts/utils'; -import { MAX_CONTRACT_SIZE, getContractId, getContractStorageRoot, hexlifyWithPrefix } from './util'; +import { + MAX_CONTRACT_SIZE, + getContractId, + getContractStorageRoot, + hexlifyWithPrefix, +} from './util'; /** * Options for deploying a contract. From c2af41fe7144065fae654232f82d72c5ea14e2dc Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Jul 2024 10:19:52 +0100 Subject: [PATCH 11/18] chore: docs --- apps/docs/src/guide/errors/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/docs/src/guide/errors/index.md b/apps/docs/src/guide/errors/index.md index 2feb5012a90..b84657a5d52 100644 --- a/apps/docs/src/guide/errors/index.md +++ b/apps/docs/src/guide/errors/index.md @@ -30,6 +30,12 @@ When converting a big number into an incompatible format. Ensure that the value you've supplied to the big number is compatible with the value you are converting to. +### `CONTRACT_SIZE_EXCEEDS_LIMIT` + +When the contract size exceeds the maximum contract size limit. + +Ensure that the contract size is less than the maximum contract size limit, of 100 KB. This can be validated by checking the bytecode length of the contract. + ### `DUPLICATED_POLICY` When there are more than policies with the same type, for a transaction. From 11b41c25020a3165b8f7286d473625a93f4b3412 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Jul 2024 10:22:50 +0100 Subject: [PATCH 12/18] chore: cross link doc --- apps/docs/src/guide/contracts/deploying-contracts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/src/guide/contracts/deploying-contracts.md b/apps/docs/src/guide/contracts/deploying-contracts.md index e894055677c..7dc1731311d 100644 --- a/apps/docs/src/guide/contracts/deploying-contracts.md +++ b/apps/docs/src/guide/contracts/deploying-contracts.md @@ -9,7 +9,7 @@ This guide walks you through deploying a contract using the SDK, covering loading contract artifacts, initializing a contract factory, and deploying the contract. -> **Note:** The maximum contract deployment size supported by the SDK is 100 KB. The SDK will `throw` for contracts larger than this size. +> **Note:** The maximum contract deployment size supported by the SDK is 100 KB. The SDK will `throw` an [error](../errors/index.md#contract_size_exceeds_limit) for contracts larger than this size. ## 1. Obtaining Contract Artifacts From 57c4c5679fac4bfe4c583ee23e6c41c914cc2968 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Jul 2024 13:32:37 +0100 Subject: [PATCH 13/18] feat: fix link --- apps/docs/src/guide/contracts/deploying-contracts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/src/guide/contracts/deploying-contracts.md b/apps/docs/src/guide/contracts/deploying-contracts.md index 7dc1731311d..fac61c5dbe2 100644 --- a/apps/docs/src/guide/contracts/deploying-contracts.md +++ b/apps/docs/src/guide/contracts/deploying-contracts.md @@ -9,7 +9,7 @@ This guide walks you through deploying a contract using the SDK, covering loading contract artifacts, initializing a contract factory, and deploying the contract. -> **Note:** The maximum contract deployment size supported by the SDK is 100 KB. The SDK will `throw` an [error](../errors/index.md#contract_size_exceeds_limit) for contracts larger than this size. +> **Note:** The maximum contract deployment size supported by the SDK is 100 KB. The SDK will `throw` an [error](../errors/index.md#contract-size-exceeds-limit) for contracts larger than this size. ## 1. Obtaining Contract Artifacts From b9992eb9edd8f26d1f8022a45933a9d816ed383b Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Jul 2024 13:44:43 +0100 Subject: [PATCH 14/18] docs: add contract deploy note to fuels cli deploy docs --- apps/docs/src/guide/fuels-cli/commands.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/docs/src/guide/fuels-cli/commands.md b/apps/docs/src/guide/fuels-cli/commands.md index 0afb25e397d..a911115b39c 100644 --- a/apps/docs/src/guide/fuels-cli/commands.md +++ b/apps/docs/src/guide/fuels-cli/commands.md @@ -109,6 +109,9 @@ The `fuels deploy` command does two things: } ``` +> [!NOTE] Note +> The maximum contract deployment size supported by the SDK is 100 KB. The SDK will `throw` an [error](../errors/index.md#contract-size-exceeds-limit) for contracts larger than this size. + Use it when instantiating your contracts: <<< @../../../demo-fuels/src/index.test.ts#using-generated-files{ts:line-numbers} From 693a3e7a968b0242a1241bcfd04c53c6c619e033 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Jul 2024 14:14:21 +0100 Subject: [PATCH 15/18] docs: move notes together --- apps/docs/src/guide/fuels-cli/commands.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/docs/src/guide/fuels-cli/commands.md b/apps/docs/src/guide/fuels-cli/commands.md index a911115b39c..4021011098b 100644 --- a/apps/docs/src/guide/fuels-cli/commands.md +++ b/apps/docs/src/guide/fuels-cli/commands.md @@ -95,6 +95,8 @@ npx fuels@{{fuels}} deploy > [!NOTE] Note > We recommend using the `fuels deploy` command only when you are deploying contracts to a local node. > If you are deploying contracts to a live network like the Testnet, we recommend using the [`forc deploy`](https://docs.fuel.network/docs/intro/quickstart-contract/#deploy-to-testnet) command instead. +> +> Additionally, the maximum contract deployment size supported by the SDK is 100 KB. The SDK will `throw` an [error](../errors/index.md#contract-size-exceeds-limit) for contracts larger than this size. The `fuels deploy` command does two things: @@ -109,9 +111,6 @@ The `fuels deploy` command does two things: } ``` -> [!NOTE] Note -> The maximum contract deployment size supported by the SDK is 100 KB. The SDK will `throw` an [error](../errors/index.md#contract-size-exceeds-limit) for contracts larger than this size. - Use it when instantiating your contracts: <<< @../../../demo-fuels/src/index.test.ts#using-generated-files{ts:line-numbers} From 8a203adce0cf37eb3e9ca5c462d4141b77a0a988 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Jul 2024 15:43:01 +0100 Subject: [PATCH 16/18] docs: remove andchor links --- apps/docs/src/guide/contracts/deploying-contracts.md | 2 +- apps/docs/src/guide/fuels-cli/commands.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/docs/src/guide/contracts/deploying-contracts.md b/apps/docs/src/guide/contracts/deploying-contracts.md index fac61c5dbe2..9e00beac37a 100644 --- a/apps/docs/src/guide/contracts/deploying-contracts.md +++ b/apps/docs/src/guide/contracts/deploying-contracts.md @@ -9,7 +9,7 @@ This guide walks you through deploying a contract using the SDK, covering loading contract artifacts, initializing a contract factory, and deploying the contract. -> **Note:** The maximum contract deployment size supported by the SDK is 100 KB. The SDK will `throw` an [error](../errors/index.md#contract-size-exceeds-limit) for contracts larger than this size. +> **Note:** The maximum contract deployment size supported by the SDK is 100 KB. The SDK will `throw` an [error](../errors/index.md) for contracts larger than this size. ## 1. Obtaining Contract Artifacts diff --git a/apps/docs/src/guide/fuels-cli/commands.md b/apps/docs/src/guide/fuels-cli/commands.md index 4021011098b..5bdcaa9683e 100644 --- a/apps/docs/src/guide/fuels-cli/commands.md +++ b/apps/docs/src/guide/fuels-cli/commands.md @@ -96,7 +96,7 @@ npx fuels@{{fuels}} deploy > We recommend using the `fuels deploy` command only when you are deploying contracts to a local node. > If you are deploying contracts to a live network like the Testnet, we recommend using the [`forc deploy`](https://docs.fuel.network/docs/intro/quickstart-contract/#deploy-to-testnet) command instead. > -> Additionally, the maximum contract deployment size supported by the SDK is 100 KB. The SDK will `throw` an [error](../errors/index.md#contract-size-exceeds-limit) for contracts larger than this size. +> Additionally, the maximum contract deployment size supported by the SDK is 100 KB. The SDK will `throw` an [error](../errors/index.md) for contracts larger than this size. The `fuels deploy` command does two things: From 2ac1c7d2afe2b65b4f03fe7cfca56468a3d49c19 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Jul 2024 17:02:33 +0100 Subject: [PATCH 17/18] chore: fix test --- packages/fuel-gauge/src/contract-factory.test.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/fuel-gauge/src/contract-factory.test.ts b/packages/fuel-gauge/src/contract-factory.test.ts index dd698b10644..879f49c9dc5 100644 --- a/packages/fuel-gauge/src/contract-factory.test.ts +++ b/packages/fuel-gauge/src/contract-factory.test.ts @@ -236,7 +236,8 @@ describe('Contract Factory', () => { it('should throws if calls createTransactionRequest is called when provider is not set', async () => { const factory = new ContractFactory( StorageTestContractAbiHex, - StorageTestContractAbi__factory.abi + StorageTestContractAbi__factory.abi, + process ); await expectToThrowFuelError( @@ -249,9 +250,13 @@ describe('Contract Factory', () => { }); it('should not deploy contracts greater than 100KB', async () => { - const factory = await createContractFactory(); - const largeByteCode = `0x${'00'.repeat(102400)}`; - factory.bytecode = largeByteCode; + using launched = await launchTestNode(); + const { + wallets: [wallet], + } = launched; + + const largeByteCode = `0x${'00'.repeat(112400)}`; + const factory = new ContractFactory(largeByteCode, StorageTestContractAbi__factory.abi, wallet); await expectToThrowFuelError( async () => factory.deployContract(), From 6815383f33d56563eba17ce0871847c334a6f4ae Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Fri, 19 Jul 2024 17:04:11 +0100 Subject: [PATCH 18/18] chore: fix test --- packages/fuel-gauge/src/contract-factory.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/fuel-gauge/src/contract-factory.test.ts b/packages/fuel-gauge/src/contract-factory.test.ts index 879f49c9dc5..03e918c17ee 100644 --- a/packages/fuel-gauge/src/contract-factory.test.ts +++ b/packages/fuel-gauge/src/contract-factory.test.ts @@ -236,8 +236,7 @@ describe('Contract Factory', () => { it('should throws if calls createTransactionRequest is called when provider is not set', async () => { const factory = new ContractFactory( StorageTestContractAbiHex, - StorageTestContractAbi__factory.abi, - process + StorageTestContractAbi__factory.abi ); await expectToThrowFuelError(