From 1ea2e27d02bfa5d65a6705db990b1deb9d2f90c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:53:31 +0700 Subject: [PATCH 1/6] docs: migrate `guide/cookbook` snippets (#3367) --- .changeset/seven-poets-matter.md | 4 + ...custom-transactions-contract-calls.test.ts | 77 ------- .../cookbook/deposit-and-withdraw.test.ts | 66 ------ .../cookbook/generate-fake-resources.test.ts | 47 ----- .../resubmitting-failed-transactions.test.ts | 105 ---------- .../cookbook/signing-transactions.test.ts | 115 ---------- .../cookbook/transferring-assets.test.ts | 196 ------------------ .../test/fixtures/forc-projects/Forc.toml | 4 - .../src/cookbook/custom-contract-calls.ts | 61 ++++++ .../cookbook/deposit-and-withdraw/deposit.ts | 38 ++++ .../cookbook/deposit-and-withdraw/withdraw.ts | 34 +++ .../src/cookbook/fake-resources.ts | 43 ++++ .../right-resubmission.ts | 37 ++++ .../submitting.ts | 25 +++ .../wrong-resubmission.ts | 36 ++++ .../signing-transactions/predicate.ts | 73 +++++++ .../cookbook/signing-transactions/script.ts | 34 +++ .../wallet-transferring/between-accounts.ts | 25 +++ .../wallet-transferring/create-transfer-2.ts | 36 ++++ .../wallet-transferring/create-transfer.ts | 29 +++ .../transferring-to-contracts.ts | 25 +++ .../transferring-to-multiple-contracts.ts | 40 ++++ apps/docs-snippets2/sway/Forc.toml | 4 + .../sway}/liquidity-pool/Forc.toml | 0 .../sway}/liquidity-pool/src/main.sw | 0 .../sway}/predicate-signing/Forc.toml | 0 .../sway}/predicate-signing/src/main.sw | 0 .../sway}/return-script/Forc.toml | 0 .../sway}/return-script/src/main.sw | 0 .../sway}/script-signing/Forc.toml | 0 .../sway}/script-signing/src/main.sw | 0 ...custom-transactions-from-contract-calls.md | 2 +- .../guide/cookbook/deposit-and-withdraw.md | 6 +- .../guide/cookbook/generate-fake-resources.md | 4 +- .../resubmitting-failed-transactions.md | 14 +- .../transactions-with-multiple-signers.md | 8 +- .../src/guide/wallets/wallet-transferring.md | 10 +- 37 files changed, 566 insertions(+), 632 deletions(-) create mode 100644 .changeset/seven-poets-matter.md delete mode 100644 apps/docs-snippets/src/guide/cookbook/custom-transactions-contract-calls.test.ts delete mode 100644 apps/docs-snippets/src/guide/cookbook/deposit-and-withdraw.test.ts delete mode 100644 apps/docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts delete mode 100644 apps/docs-snippets/src/guide/cookbook/resubmitting-failed-transactions.test.ts delete mode 100644 apps/docs-snippets/src/guide/cookbook/signing-transactions.test.ts delete mode 100644 apps/docs-snippets/src/guide/cookbook/transferring-assets.test.ts create mode 100644 apps/docs-snippets2/src/cookbook/custom-contract-calls.ts create mode 100644 apps/docs-snippets2/src/cookbook/deposit-and-withdraw/deposit.ts create mode 100644 apps/docs-snippets2/src/cookbook/deposit-and-withdraw/withdraw.ts create mode 100644 apps/docs-snippets2/src/cookbook/fake-resources.ts create mode 100644 apps/docs-snippets2/src/cookbook/resubmitting-failed-transactions/right-resubmission.ts create mode 100644 apps/docs-snippets2/src/cookbook/resubmitting-failed-transactions/submitting.ts create mode 100644 apps/docs-snippets2/src/cookbook/resubmitting-failed-transactions/wrong-resubmission.ts create mode 100644 apps/docs-snippets2/src/cookbook/signing-transactions/predicate.ts create mode 100644 apps/docs-snippets2/src/cookbook/signing-transactions/script.ts create mode 100644 apps/docs-snippets2/src/cookbook/wallet-transferring/between-accounts.ts create mode 100644 apps/docs-snippets2/src/cookbook/wallet-transferring/create-transfer-2.ts create mode 100644 apps/docs-snippets2/src/cookbook/wallet-transferring/create-transfer.ts create mode 100644 apps/docs-snippets2/src/cookbook/wallet-transferring/transferring-to-contracts.ts create mode 100644 apps/docs-snippets2/src/cookbook/wallet-transferring/transferring-to-multiple-contracts.ts rename apps/{docs-snippets/test/fixtures/forc-projects => docs-snippets2/sway}/liquidity-pool/Forc.toml (100%) rename apps/{docs-snippets/test/fixtures/forc-projects => docs-snippets2/sway}/liquidity-pool/src/main.sw (100%) rename apps/{docs-snippets/test/fixtures/forc-projects => docs-snippets2/sway}/predicate-signing/Forc.toml (100%) rename apps/{docs-snippets/test/fixtures/forc-projects => docs-snippets2/sway}/predicate-signing/src/main.sw (100%) rename apps/{docs-snippets/test/fixtures/forc-projects => docs-snippets2/sway}/return-script/Forc.toml (100%) rename apps/{docs-snippets/test/fixtures/forc-projects => docs-snippets2/sway}/return-script/src/main.sw (100%) rename apps/{docs-snippets/test/fixtures/forc-projects => docs-snippets2/sway}/script-signing/Forc.toml (100%) rename apps/{docs-snippets/test/fixtures/forc-projects => docs-snippets2/sway}/script-signing/src/main.sw (100%) diff --git a/.changeset/seven-poets-matter.md b/.changeset/seven-poets-matter.md new file mode 100644 index 00000000000..b51b4827260 --- /dev/null +++ b/.changeset/seven-poets-matter.md @@ -0,0 +1,4 @@ +--- +--- + +docs: migrate `guide/cookbook` snippets diff --git a/apps/docs-snippets/src/guide/cookbook/custom-transactions-contract-calls.test.ts b/apps/docs-snippets/src/guide/cookbook/custom-transactions-contract-calls.test.ts deleted file mode 100644 index 352a95fce64..00000000000 --- a/apps/docs-snippets/src/guide/cookbook/custom-transactions-contract-calls.test.ts +++ /dev/null @@ -1,77 +0,0 @@ -import type { BN } from 'fuels'; -import { Contract, bn, buildFunctionResult, Wallet } from 'fuels'; -import { launchTestNode } from 'fuels/test-utils'; - -import { CounterFactory } from '../../../test/typegen'; - -/** - * @group node - * @group browser - */ -describe('Custom Transactions from Contract Calls', () => { - it('creates a custom transaction from a contract call', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: CounterFactory, - }, - ], - }); - const { - contracts: [contract], - provider, - wallets: [senderWallet], - } = launched; - - const receiverWallet = Wallet.generate({ provider }); - - const initialBalance = await receiverWallet.getBalance(provider.getBaseAssetId()); - expect(initialBalance.toNumber()).toBe(0); - - // #region custom-transactions-contract-calls - // #import { bn, Contract, buildFunctionResult }; - - const amountToRecipient = bn(10_000); // 0x2710 - // Connect to the contract - const contractInstance = new Contract(contract.id, contract.interface, senderWallet); - // Create an invocation scope for the contract function you'd like to call in the transaction - const scope = contractInstance.functions.increment_counter(amountToRecipient).addTransfer({ - amount: amountToRecipient, - destination: receiverWallet.address, - assetId: provider.getBaseAssetId(), - }); - - // Build a transaction request from the invocation scope - const transactionRequest = await scope.getTransactionRequest(); - // Add coin output for the recipient - transactionRequest.addCoinOutput( - receiverWallet.address, - amountToRecipient, - provider.getBaseAssetId() - ); - - const txCost = await senderWallet.getTransactionCost(transactionRequest); - - transactionRequest.gasLimit = txCost.gasUsed; - transactionRequest.maxFee = txCost.maxFee; - - await senderWallet.fund(transactionRequest, txCost); - - // Submit the transaction - const response = await senderWallet.sendTransaction(transactionRequest); - await response.waitForResult(); - // Get result of contract call - const { value } = await buildFunctionResult({ - funcScope: scope, - isMultiCall: false, - program: contract, - transactionResponse: response, - }); - // - // #endregion custom-transactions-contract-calls - - const receiverBalance = await receiverWallet.getBalance(provider.getBaseAssetId()); - expect(receiverBalance.toNumber()).toBeGreaterThan(initialBalance.toNumber()); - expect((value as BN).toNumber()).toBe(amountToRecipient.toNumber()); - }); -}); diff --git a/apps/docs-snippets/src/guide/cookbook/deposit-and-withdraw.test.ts b/apps/docs-snippets/src/guide/cookbook/deposit-and-withdraw.test.ts deleted file mode 100644 index dddc75a9cd6..00000000000 --- a/apps/docs-snippets/src/guide/cookbook/deposit-and-withdraw.test.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { Wallet, ZeroBytes32, getMintedAssetId } from 'fuels'; -import { launchTestNode } from 'fuels/test-utils'; - -import { LiquidityPoolFactory } from '../../../test/typegen'; - -/** - * @group node - * @group browser - */ -describe('Deposit and Withdraw with Liquidity Pool', () => { - it('deposit and withdraw cookbook guide', async () => { - using launched = await launchTestNode(); - - const { - provider, - wallets: [wallet], - } = launched; - - const liquidityPoolContractFactory = new LiquidityPoolFactory(wallet); - - const { waitForResult } = await liquidityPoolContractFactory.deploy({ - configurableConstants: { - TOKEN: { bits: provider.getBaseAssetId() }, - }, - }); - - const { contract: liquidityPoolContract } = await waitForResult(); - - // #region deposit-and-withdraw-cookbook-2 - const depositAmount = 100_000; - const liquidityOwner = Wallet.generate({ provider }); - - // the subId used to mint the new asset is a zero b256 on the contract - const subId = ZeroBytes32; - const contractId = liquidityPoolContract.id.toB256(); - - const assetId = getMintedAssetId(contractId, subId); - - const call1 = await liquidityPoolContract.functions - .deposit({ bits: liquidityOwner.address.toB256() }) - .callParams({ forward: [depositAmount, provider.getBaseAssetId()] }) - .txParams({ variableOutputs: 1 }) - .call(); - - await call1.waitForResult(); - - const liquidityAmount = await liquidityOwner.getBalance(assetId); - - expect(liquidityAmount.toNumber()).toBe(depositAmount * 2); - // #endregion deposit-and-withdraw-cookbook-2 - - // #region deposit-and-withdraw-cookbook-3 - const call2 = await liquidityPoolContract.functions - .withdraw({ bits: liquidityOwner.address.toB256() }) - .callParams({ forward: [depositAmount, provider.getBaseAssetId()] }) - .txParams({ variableOutputs: 1 }) - .call(); - - await call2.waitForResult(); - - const baseAssetAfterWithdraw = await liquidityOwner.getBalance(provider.getBaseAssetId()); - - expect(baseAssetAfterWithdraw.toNumber()).toBe(depositAmount / 2); - // #endregion deposit-and-withdraw-cookbook-3 - }); -}); diff --git a/apps/docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts b/apps/docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts deleted file mode 100644 index e1c5994ff42..00000000000 --- a/apps/docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts +++ /dev/null @@ -1,47 +0,0 @@ -import type { TransactionResultReturnDataReceipt } from 'fuels'; -import { ReceiptType, ScriptTransactionRequest, bn } from 'fuels'; -import { launchTestNode } from 'fuels/test-utils'; - -import { ReturnScript } from '../../../test/typegen'; - -/** - * @group node - * @group browser - */ -describe('Generate fake resources', () => { - it('should generate fake resources just fine', async () => { - const { - provider, - wallets: [wallet], - } = await launchTestNode(); - const baseAssetId = provider.getBaseAssetId(); - - // #region generate-fake-resources-2 - const transactionRequest = new ScriptTransactionRequest({ - gasLimit: bn(62_000), - maxFee: bn(60_000), - script: ReturnScript.bytecode, - }); - - const resources = wallet.generateFakeResources([ - { - amount: bn(100_000), - assetId: baseAssetId, - }, - ]); - - transactionRequest.addResources(resources); - - const dryrunResult = await provider.dryRun(transactionRequest); - - const returnReceipt = dryrunResult.receipts.find( - (receipt) => receipt.type === ReceiptType.ReturnData - ) as TransactionResultReturnDataReceipt; - - const { data: returnedValue } = returnReceipt; - // #endregion generate-fake-resources-2 - - expect(bn(returnedValue).toNumber()).toBe(1337); - expect(dryrunResult.dryRunStatus?.type).toBe('DryRunSuccessStatus'); - }); -}); diff --git a/apps/docs-snippets/src/guide/cookbook/resubmitting-failed-transactions.test.ts b/apps/docs-snippets/src/guide/cookbook/resubmitting-failed-transactions.test.ts deleted file mode 100644 index c2674eb50dc..00000000000 --- a/apps/docs-snippets/src/guide/cookbook/resubmitting-failed-transactions.test.ts +++ /dev/null @@ -1,105 +0,0 @@ -import { bn, type FuelError } from 'fuels'; -import { launchTestNode } from 'fuels/test-utils'; - -/** - * @group node - * @group browser - */ -describe('Resubmitting Failed Transactions', () => { - it('should submit transaction just fine', async () => { - const { - provider, - wallets: [wallet, recipient], - } = await launchTestNode({ - walletsConfig: { - count: 2, - }, - }); - const baseAssetId = provider.getBaseAssetId(); - - const transferAmount = 1000; - - // #region resubmitting-failed-transactions-1 - const transactionRequest = await wallet.createTransfer( - recipient.address, - transferAmount, - baseAssetId - ); - - const response = await wallet.sendTransaction(transactionRequest); - // #endregion resubmitting-failed-transactions-1 - - // #region resubmitting-failed-transactions-2 - const result = await response.waitForResult(); - // #endregion resubmitting-failed-transactions-2 - - expect(result.isStatusSuccess).toBeTruthy(); - }); - - it('should try to re-submit the transaction', async () => { - const { - provider, - wallets: [wallet, recipient], - } = await launchTestNode({ - walletsConfig: { - count: 2, - }, - }); - const baseAssetId = provider.getBaseAssetId(); - const transferAmount = 1000; - - await expect(async () => { - // #region resubmitting-failed-transactions-3 - const transactionRequest = await wallet.createTransfer( - recipient.address, - transferAmount, - baseAssetId - ); - - // Set the gasLimit to 0 to force revert with OutOfGas error - transactionRequest.gasLimit = bn(0); - - // Transaction will be successfully submitted - const response = await wallet.sendTransaction(transactionRequest); - try { - await response.waitForResult(); - } catch (error) { - if (/OutOfGas/.test((error).message)) { - transactionRequest.gasLimit = bn(1000); - // Re-submission will fail - await wallet.sendTransaction(transactionRequest); - } - } - // #endregion resubmitting-failed-transactions-3 - }).rejects.toThrowError(/Transaction input validation failed: UTXO \(id: .*\) does not exist/); - - await expect( - (async () => { - const transactionRequest = await wallet.createTransfer( - recipient.address, - transferAmount, - baseAssetId - ); - - transactionRequest.gasLimit = bn(0); - - const response = await wallet.sendTransaction(transactionRequest); - // #region resubmitting-failed-transactions-4 - try { - await response.waitForResult(); - } catch (error) { - if (/OutOfGas/.test((error).message)) { - const transactionRequest2 = await wallet.createTransfer( - recipient.address, - transferAmount, - baseAssetId - ); - - await wallet.sendTransaction(transactionRequest2); - } - } - // #endregion resubmitting-failed-transactions-4 - })() - ).resolves.not.toThrow(); - }); -}); diff --git a/apps/docs-snippets/src/guide/cookbook/signing-transactions.test.ts b/apps/docs-snippets/src/guide/cookbook/signing-transactions.test.ts deleted file mode 100644 index 3091eb3f16d..00000000000 --- a/apps/docs-snippets/src/guide/cookbook/signing-transactions.test.ts +++ /dev/null @@ -1,115 +0,0 @@ -import type { BN } from 'fuels'; -import { Predicate, Script, ScriptTransactionRequest, Wallet } from 'fuels'; -import { launchTestNode } from 'fuels/test-utils'; - -import { ScriptSigning } from '../../../test/typegen'; -import { PredicateSigning } from '../../../test/typegen/predicates'; - -/** - * @group node - * @group browser - */ -describe('Signing transactions', () => { - it('creates a transfer with external signer [script]', async () => { - using launched = await launchTestNode(); - const { - provider, - wallets: [sender], - } = launched; - const amountToReceiver = 100; - - const signer = Wallet.generate({ - provider, - }); - - const receiver = Wallet.generate({ - provider, - }); - // #region multiple-signers-2 - // #import { Script }; - - const script = new Script(ScriptSigning.bytecode, ScriptSigning.abi, sender); - const { waitForResult } = await script.functions - .main(signer.address.toB256()) - .addTransfer({ - destination: receiver.address, - amount: amountToReceiver, - assetId: provider.getBaseAssetId(), - }) - .addSigners(signer) - .call(); - - const { value } = await waitForResult(); - // #endregion multiple-signers-2 - - expect(value).toBe(true); - expect((await receiver.getBalance()).toNumber()).toEqual(amountToReceiver); - }); - - it('creates a transfer with external signer [predicate]', async () => { - using launched = await launchTestNode(); - const { - provider, - wallets: [sender], - } = launched; - const amountToReceiver = 100; - - const signer = Wallet.generate({ - provider, - }); - - const receiver = Wallet.generate({ - provider, - }); - - // #region multiple-signers-4 - // #import { Predicate, ScriptTransactionRequest }; - - // Create and fund the predicate - const predicate = new Predicate<[string]>({ - bytecode: PredicateSigning.bytecode, - abi: PredicateSigning.abi, - provider, - data: [signer.address.toB256()], - }); - const tx1 = await sender.transfer(predicate.address, 200_000, provider.getBaseAssetId()); - await tx1.waitForResult(); - - // Create the transaction request - const request = new ScriptTransactionRequest(); - request.addCoinOutput(receiver.address, amountToReceiver, provider.getBaseAssetId()); - - // Get the predicate resources and add them and predicate data to the request - const resources = await predicate.getResourcesToSpend([ - { - assetId: provider.getBaseAssetId(), - amount: amountToReceiver, - }, - ]); - - request.addResources(resources); - request.addWitness('0x'); - - // Add witnesses including the signer - // Estimate the predicate inputs - const txCost = await predicate.getTransactionCost(request, { - signatureCallback: (tx) => tx.addAccountWitnesses(signer), - }); - - request.updatePredicateGasUsed(txCost.estimatedPredicates); - - request.gasLimit = txCost.gasUsed; - request.maxFee = txCost.maxFee; - - await predicate.fund(request, txCost); - - await request.addAccountWitnesses(signer); - - // Send the transaction - const res = await provider.sendTransaction(request); - await res.waitForResult(); - - // #endregion multiple-signers-4 - expect((await receiver.getBalance()).toNumber()).toEqual(amountToReceiver); - }); -}); diff --git a/apps/docs-snippets/src/guide/cookbook/transferring-assets.test.ts b/apps/docs-snippets/src/guide/cookbook/transferring-assets.test.ts deleted file mode 100644 index a173df234cc..00000000000 --- a/apps/docs-snippets/src/guide/cookbook/transferring-assets.test.ts +++ /dev/null @@ -1,196 +0,0 @@ -import type { ContractTransferParams, ReceiptTransfer } from 'fuels'; -import { BN, ReceiptType, Wallet } from 'fuels'; -import { launchTestNode, TestAssetId } from 'fuels/test-utils'; - -import { CounterFactory, TokenFactory } from '../../../test/typegen'; - -/** - * @group node - * @group browser - */ -describe('Transferring Assets', () => { - it('should successfully transfer asset to another account', async () => { - using launched = await launchTestNode(); - const { - wallets: [sender], - } = launched; - // #region transferring-assets-1 - // #import { Wallet, BN }; - - // #context const sender = Wallet.fromPrivateKey('...'); - const destination = Wallet.generate({ - provider: sender.provider, - }); - const amountToTransfer = 500; - - const baseAssetId = sender.provider.getBaseAssetId(); - - const response = await sender.transfer(destination.address, amountToTransfer, baseAssetId); - - await response.wait(); - - // Retrieve balances - const receiverBalance = await destination.getBalance(baseAssetId); - - // Validate new balance - expect(new BN(receiverBalance).toNumber()).toEqual(amountToTransfer); - // #endregion transferring-assets-1 - }); - - it('should successfully prepare transfer to another account', async () => { - using launched = await launchTestNode(); - const { - provider, - wallets: [sender], - } = launched; - const destination = Wallet.generate({ - provider: sender.provider, - }); - - const assetId = provider.getBaseAssetId(); - const amountToTransfer = 200; - - // #region transferring-assets-2 - const transactionRequest = await sender.createTransfer( - destination.address, - amountToTransfer, - assetId - ); - - const chainId = provider.getChainId(); - - const transactionId = transactionRequest.getTransactionId(chainId); - - const response = await sender.sendTransaction(transactionRequest); - - const { id } = await response.wait(); - - // The transaction id should is the same as the one returned by the transaction request - expect(id).toEqual(transactionId); - // #endregion transferring-assets-2 - }); - - it('should validate that modifying the transaction request will result in another TX ID', async () => { - using launched = await launchTestNode({ - nodeOptions: { - args: ['--poa-instant', 'false', '--poa-interval-period', '10ms'], - }, - }); - const { - provider, - wallets: [sender], - } = launched; - const destination = Wallet.generate({ - provider: sender.provider, - }); - - const amountToTransfer = 200; - const assetId = provider.getBaseAssetId(); - - // #region transferring-assets-3 - const transactionRequest = await sender.createTransfer( - destination.address, - amountToTransfer, - assetId - ); - - const chainId = provider.getChainId(); - - const transactionId = transactionRequest.getTransactionId(chainId); - - transactionRequest.maturity = 1; - - const { maxFee } = await provider.estimateTxGasAndFee({ transactionRequest }); - - transactionRequest.maxFee = maxFee; - - const response = await sender.sendTransaction(transactionRequest); - - const { id } = await response.wait(); - - expect(id).not.toEqual(transactionId); - // #endregion transferring-assets-3 - }); - - it('should successfully transfer to contract', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: CounterFactory, - }, - ], - }); - const { - provider, - wallets: [sender], - contracts: [deployedContract], - } = launched; - // #region transferring-assets-4 - // #import { Wallet, BN }; - - // #context const sender = Wallet.fromPrivateKey('...'); - - const amountToTransfer = 400; - const assetId = provider.getBaseAssetId(); - const contractId = deployedContract.id; - - const contractBalance = await deployedContract.getBalance(assetId); - - const tx = await sender.transferToContract(contractId, amountToTransfer, assetId); - await tx.waitForResult(); - - expect(new BN(contractBalance).toNumber()).toBe(0); - expect(new BN(await deployedContract.getBalance(assetId)).toNumber()).toBe(amountToTransfer); - // #endregion transferring-assets-4 - }); - - it('should successfully batch transfer to contracts', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: CounterFactory, - }, - { - factory: TokenFactory, - }, - ], - }); - const { - provider, - wallets: [sender], - contracts: [contract1, contract2], - } = launched; - - // #region transferring-assets-5 - const baseAssetId = provider.getBaseAssetId(); - const assetA = TestAssetId.A.value; - - const contractTransferParams: ContractTransferParams[] = [ - { - contractId: contract1.id, - amount: 999, - assetId: baseAssetId, - }, - { - contractId: contract1.id, - amount: 550, - assetId: assetA, - }, - { - contractId: contract2.id, - amount: 200, - assetId: assetA, - }, - ]; - - const submit = await sender.batchTransferToContracts(contractTransferParams); - const txResult = await submit.waitForResult(); - // #endregion transferring-assets-5 - - const transferReceipts = txResult.receipts.filter( - (receipt) => receipt.type === ReceiptType.Transfer - ) as ReceiptTransfer[]; - - expect(transferReceipts.length).toBe(contractTransferParams.length); - }); -}); diff --git a/apps/docs-snippets/test/fixtures/forc-projects/Forc.toml b/apps/docs-snippets/test/fixtures/forc-projects/Forc.toml index ded6b45dc75..2b4602f5d98 100644 --- a/apps/docs-snippets/test/fixtures/forc-projects/Forc.toml +++ b/apps/docs-snippets/test/fixtures/forc-projects/Forc.toml @@ -2,7 +2,6 @@ members = [ "counter", "echo-enum", - "liquidity-pool", "log-values", "sum-script", "echo-values", @@ -16,7 +15,6 @@ members = [ "simple-token-abi", "echo-configurables", "transfer-to-address", - "return-script", "return-true-predicate", "echo-employee-data-vector", "whitelisted-address-predicate", @@ -29,8 +27,6 @@ members = [ "echo-std-string", "revert-errors", "revert-errors-script", - "predicate-signing", - "script-signing", "input-output-types", "bytecode-input", "configurable-pin", diff --git a/apps/docs-snippets2/src/cookbook/custom-contract-calls.ts b/apps/docs-snippets2/src/cookbook/custom-contract-calls.ts new file mode 100644 index 00000000000..c80cdb81770 --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/custom-contract-calls.ts @@ -0,0 +1,61 @@ +// #region custom-transactions-contract-calls +import { bn, buildFunctionResult, Contract, Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../env'; +import { CounterFactory } from '../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const wallet = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); +const deploy = await CounterFactory.deploy(wallet); +const { contract } = await deploy.waitForResult(); + +const receiverWallet = Wallet.generate({ provider }); + +const amountToRecipient = bn(10_000); // 0x2710 +// Connect to the contract +const contractInstance = new Contract(contract.id, contract.interface, wallet); +// Create an invocation scope for the contract function you'd like to call in the transaction +const scope = contractInstance.functions + .increment_count(amountToRecipient) + .addTransfer({ + amount: amountToRecipient, + destination: receiverWallet.address, + assetId: provider.getBaseAssetId(), + }); + +// Build a transaction request from the invocation scope +const transactionRequest = await scope.getTransactionRequest(); +// Add coin output for the recipient +transactionRequest.addCoinOutput( + receiverWallet.address, + amountToRecipient, + provider.getBaseAssetId() +); + +const txCost = await wallet.getTransactionCost(transactionRequest); + +transactionRequest.gasLimit = txCost.gasUsed; +transactionRequest.maxFee = txCost.maxFee; + +await wallet.fund(transactionRequest, txCost); + +// Submit the transaction +const response = await wallet.sendTransaction(transactionRequest); +await response.waitForResult(); +// Get result of contract call +const { value } = await buildFunctionResult({ + funcScope: scope, + isMultiCall: false, + program: contract, + transactionResponse: response, +}); + +console.log('value', value); +// +// #endregion custom-transactions-contract-calls + +const receiverBalance = await receiverWallet.getBalance( + provider.getBaseAssetId() +); + +console.log('balance', receiverBalance.toNumber()); diff --git a/apps/docs-snippets2/src/cookbook/deposit-and-withdraw/deposit.ts b/apps/docs-snippets2/src/cookbook/deposit-and-withdraw/deposit.ts new file mode 100644 index 00000000000..a3a54026f62 --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/deposit-and-withdraw/deposit.ts @@ -0,0 +1,38 @@ +// #region deposit-and-withdraw-cookbook-2 +import { getMintedAssetId, Provider, Wallet, ZeroBytes32 } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { LiquidityPoolFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const wallet = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deploy = await LiquidityPoolFactory.deploy(wallet, { + configurableConstants: { + TOKEN: { bits: provider.getBaseAssetId() }, + }, +}); + +const { contract } = await deploy.waitForResult(); + +const depositAmount = 100_000; +const liquidityOwner = Wallet.generate({ provider }); + +// the subId used to mint the new asset is a zero b256 on the contract +const subId = ZeroBytes32; +const contractId = contract.id.toB256(); + +const assetId = getMintedAssetId(contractId, subId); + +const { waitForResult } = await contract.functions + .deposit({ bits: liquidityOwner.address.toB256() }) + .callParams({ forward: [depositAmount, provider.getBaseAssetId()] }) + .txParams({ variableOutputs: 1 }) + .call(); + +await waitForResult(); + +const liquidityAmount = await liquidityOwner.getBalance(assetId); +// #endregion deposit-and-withdraw-cookbook-2 + +console.log('value', liquidityAmount.toNumber()); diff --git a/apps/docs-snippets2/src/cookbook/deposit-and-withdraw/withdraw.ts b/apps/docs-snippets2/src/cookbook/deposit-and-withdraw/withdraw.ts new file mode 100644 index 00000000000..c9f71c7d94e --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/deposit-and-withdraw/withdraw.ts @@ -0,0 +1,34 @@ +// #region deposit-and-withdraw-cookbook-3 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { LiquidityPoolFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const wallet = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deploy = await LiquidityPoolFactory.deploy(wallet, { + configurableConstants: { + TOKEN: { bits: provider.getBaseAssetId() }, + }, +}); + +const { contract } = await deploy.waitForResult(); + +const depositAmount = 100_000; +const liquidityOwner = Wallet.generate({ provider }); + +const { waitForResult } = await contract.functions + .withdraw({ bits: liquidityOwner.address.toB256() }) + .callParams({ forward: [depositAmount, provider.getBaseAssetId()] }) + .txParams({ variableOutputs: 1 }) + .call(); + +await waitForResult(); + +const baseAssetAfterWithdraw = await liquidityOwner.getBalance( + provider.getBaseAssetId() +); +// #endregion deposit-and-withdraw-cookbook-3 + +console.log('balance', baseAssetAfterWithdraw.toNumber()); diff --git a/apps/docs-snippets2/src/cookbook/fake-resources.ts b/apps/docs-snippets2/src/cookbook/fake-resources.ts new file mode 100644 index 00000000000..172e04634be --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/fake-resources.ts @@ -0,0 +1,43 @@ +// #region generate-fake-resources-2 +import type { TransactionResultReturnDataReceipt } from 'fuels'; +import { + bn, + Provider, + ReceiptType, + ScriptTransactionRequest, + Wallet, +} from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../env'; +import { ReturnScript } from '../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const wallet = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const baseAssetId = provider.getBaseAssetId(); + +const transactionRequest = new ScriptTransactionRequest({ + gasLimit: bn(62_000), + maxFee: bn(60_000), + script: ReturnScript.bytecode, +}); + +const resources = wallet.generateFakeResources([ + { + amount: bn(100_000), + assetId: baseAssetId, + }, +]); + +transactionRequest.addResources(resources); + +const dryrunResult = await provider.dryRun(transactionRequest); + +const returnReceipt = dryrunResult.receipts.find( + (receipt) => receipt.type === ReceiptType.ReturnData +) as TransactionResultReturnDataReceipt; + +const { data: returnedValue } = returnReceipt; +// #endregion generate-fake-resources-2 + +console.log('returned', bn(returnedValue).toNumber() === 1337); diff --git a/apps/docs-snippets2/src/cookbook/resubmitting-failed-transactions/right-resubmission.ts b/apps/docs-snippets2/src/cookbook/resubmitting-failed-transactions/right-resubmission.ts new file mode 100644 index 00000000000..d98be9e932b --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/resubmitting-failed-transactions/right-resubmission.ts @@ -0,0 +1,37 @@ +import type { FuelError } from 'fuels'; +import { bn, Provider, Wallet } from 'fuels'; +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from 'src/env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const wallet = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const baseAssetId = provider.getBaseAssetId(); +const transferAmount = 1000; + +const transactionRequest = await wallet.createTransfer( + wallet.address, + transferAmount, + baseAssetId +); + +// Set the gasLimit to 0 to force revert with OutOfGas error +transactionRequest.gasLimit = bn(0); + +// Transaction will be successfully submitted +const response = await wallet.sendTransaction(transactionRequest); + +// #region resubmitting-failed-transactions-4 +try { + await response.waitForResult(); +} catch (error) { + if (/OutOfGas/.test((error).message)) { + const transactionRequest2 = await wallet.createTransfer( + wallet.address, + transferAmount, + baseAssetId + ); + + await wallet.sendTransaction(transactionRequest2); + } +} +// #endregion resubmitting-failed-transactions-4 diff --git a/apps/docs-snippets2/src/cookbook/resubmitting-failed-transactions/submitting.ts b/apps/docs-snippets2/src/cookbook/resubmitting-failed-transactions/submitting.ts new file mode 100644 index 00000000000..542b0ec353e --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/resubmitting-failed-transactions/submitting.ts @@ -0,0 +1,25 @@ +// #region resubmitting-failed-transactions-1 +import { Provider, Wallet } from 'fuels'; +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from 'src/env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const wallet = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const baseAssetId = provider.getBaseAssetId(); + +const transferAmount = 1000; + +const transactionRequest = await wallet.createTransfer( + wallet.address, + transferAmount, + baseAssetId +); + +const response = await wallet.sendTransaction(transactionRequest); +// #endregion resubmitting-failed-transactions-1 + +// #region resubmitting-failed-transactions-2 +const result = await response.waitForResult(); +// #endregion resubmitting-failed-transactions-2 + +console.log('success', result.isStatusSuccess); diff --git a/apps/docs-snippets2/src/cookbook/resubmitting-failed-transactions/wrong-resubmission.ts b/apps/docs-snippets2/src/cookbook/resubmitting-failed-transactions/wrong-resubmission.ts new file mode 100644 index 00000000000..5cca84731f0 --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/resubmitting-failed-transactions/wrong-resubmission.ts @@ -0,0 +1,36 @@ +import type { FuelError } from 'fuels'; +import { bn, Provider, Wallet } from 'fuels'; +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from 'src/env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const wallet = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const baseAssetId = provider.getBaseAssetId(); +const transferAmount = 1000; + +// #region resubmitting-failed-transactions-3 +const transactionRequest = await wallet.createTransfer( + wallet.address, + transferAmount, + baseAssetId +); + +// Set the gasLimit to 0 to force revert with OutOfGas error +transactionRequest.gasLimit = bn(0); + +// Transaction will be successfully submitted +const response = await wallet.sendTransaction(transactionRequest); +// let error: FuelError | undefined; +try { + await response.waitForResult(); +} catch (error) { + if (/OutOfGas/.test((error).message)) { + transactionRequest.gasLimit = bn(1000); + + // Re-submission will fail + await wallet.sendTransaction(transactionRequest).catch((error2) => { + console.log('error2', error2); + }); + } +} +// #endregion resubmitting-failed-transactions-3 diff --git a/apps/docs-snippets2/src/cookbook/signing-transactions/predicate.ts b/apps/docs-snippets2/src/cookbook/signing-transactions/predicate.ts new file mode 100644 index 00000000000..ca5e9e67416 --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/signing-transactions/predicate.ts @@ -0,0 +1,73 @@ +// #region multiple-signers-4 +import { Predicate, Provider, ScriptTransactionRequest, Wallet } from 'fuels'; + +import { + LOCAL_NETWORK_URL, + WALLET_PVT_KEY, + WALLET_PVT_KEY_2, + WALLET_PVT_KEY_3, +} from '../../env'; +import { PredicateSigning } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); + +const sender = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); +const signer = Wallet.fromPrivateKey(WALLET_PVT_KEY_2, provider); +const receiver = Wallet.fromPrivateKey(WALLET_PVT_KEY_3, provider); + +const amountToReceiver = 100; + +// Create and fund the predicate +const predicate = new Predicate<[string]>({ + bytecode: PredicateSigning.bytecode, + abi: PredicateSigning.abi, + provider, + data: [signer.address.toB256()], +}); +const tx = await sender.transfer( + predicate.address, + 200_000, + provider.getBaseAssetId() +); +await tx.waitForResult(); + +// Create the transaction request +const request = new ScriptTransactionRequest(); +request.addCoinOutput( + receiver.address, + amountToReceiver, + provider.getBaseAssetId() +); + +// Get the predicate resources and add them and predicate data to the request +const resources = await predicate.getResourcesToSpend([ + { + assetId: provider.getBaseAssetId(), + amount: amountToReceiver, + }, +]); + +request.addResources(resources); +request.addWitness('0x'); + +// Add witnesses including the signer +// Estimate the predicate inputs +const txCost = await predicate.getTransactionCost(request, { + signatureCallback: (txRequest) => txRequest.addAccountWitnesses(signer), +}); + +request.updatePredicateGasUsed(txCost.estimatedPredicates); + +request.gasLimit = txCost.gasUsed; +request.maxFee = txCost.maxFee; + +await predicate.fund(request, txCost); + +await request.addAccountWitnesses(signer); + +// Send the transaction +const res = await provider.sendTransaction(request); +await res.waitForResult(); + +// #endregion multiple-signers-4 +console.log('balance', (await receiver.getBalance()).toNumber()); diff --git a/apps/docs-snippets2/src/cookbook/signing-transactions/script.ts b/apps/docs-snippets2/src/cookbook/signing-transactions/script.ts new file mode 100644 index 00000000000..b909737109b --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/signing-transactions/script.ts @@ -0,0 +1,34 @@ +// #region multiple-signers-2 +import type { BN } from 'fuels'; +import { Script, Provider, Wallet } from 'fuels'; + +import { + LOCAL_NETWORK_URL, + WALLET_PVT_KEY, + WALLET_PVT_KEY_2, + WALLET_PVT_KEY_3, +} from '../../env'; +import { ScriptSigning } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const sender = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); +const signer = Wallet.fromPrivateKey(WALLET_PVT_KEY_2, provider); +const receiver = Wallet.fromPrivateKey(WALLET_PVT_KEY_3, provider); + +const amountToReceiver = 100; + +const script = new Script(ScriptSigning.bytecode, ScriptSigning.abi, sender); +const { waitForResult } = await script.functions + .main(signer.address.toB256()) + .addTransfer({ + destination: receiver.address, + amount: amountToReceiver, + assetId: provider.getBaseAssetId(), + }) + .addSigners(signer) + .call(); + +const { value } = await waitForResult(); +// #endregion multiple-signers-2 + +console.log('value', value); diff --git a/apps/docs-snippets2/src/cookbook/wallet-transferring/between-accounts.ts b/apps/docs-snippets2/src/cookbook/wallet-transferring/between-accounts.ts new file mode 100644 index 00000000000..5a9ad39e307 --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/wallet-transferring/between-accounts.ts @@ -0,0 +1,25 @@ +// #region transferring-assets-1 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY, WALLET_PVT_KEY_2 } from '../../env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const sender = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); +const destination = Wallet.fromPrivateKey(WALLET_PVT_KEY_2, provider); + +const amountToTransfer = 500; +const baseAssetId = sender.provider.getBaseAssetId(); + +const response = await sender.transfer( + destination.address, + amountToTransfer, + baseAssetId +); + +await response.waitForResult(); + +// Retrieve balances +const balance = await destination.getBalance(baseAssetId); +// #endregion transferring-assets-1 + +console.log('new balance', balance.toNumber() >= amountToTransfer); diff --git a/apps/docs-snippets2/src/cookbook/wallet-transferring/create-transfer-2.ts b/apps/docs-snippets2/src/cookbook/wallet-transferring/create-transfer-2.ts new file mode 100644 index 00000000000..99fa0376486 --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/wallet-transferring/create-transfer-2.ts @@ -0,0 +1,36 @@ +// #region transferring-assets-3 +import { bn, Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY, WALLET_PVT_KEY_2 } from '../../env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const sender = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); +const destination = Wallet.fromPrivateKey(WALLET_PVT_KEY_2, provider); + +const amountToTransfer = 200; +const assetId = provider.getBaseAssetId(); + +const transactionRequest = await sender.createTransfer( + destination.address, + amountToTransfer, + assetId +); + +const chainId = provider.getChainId(); + +const transactionId = transactionRequest.getTransactionId(chainId); + +/** + * Modifying any property of the transaction request, except for the number + * of witnesses within the ".witnesses" array, will generate a new transaction + * hash, resulting in a different transaction ID. + */ +transactionRequest.gasLimit = bn(1000); + +const response = await sender.sendTransaction(transactionRequest); + +// The transaction id here is NOT the same one returned above. +const { id } = await response.wait(); +// #endregion transferring-assets-3 + +console.log('transactionId', id !== transactionId); diff --git a/apps/docs-snippets2/src/cookbook/wallet-transferring/create-transfer.ts b/apps/docs-snippets2/src/cookbook/wallet-transferring/create-transfer.ts new file mode 100644 index 00000000000..bb38bafee2d --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/wallet-transferring/create-transfer.ts @@ -0,0 +1,29 @@ +// #region transferring-assets-2 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY, WALLET_PVT_KEY_2 } from '../../env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const sender = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); +const destination = Wallet.fromPrivateKey(WALLET_PVT_KEY_2, provider); + +const amountToTransfer = 200; +const assetId = provider.getBaseAssetId(); + +const transactionRequest = await sender.createTransfer( + destination.address, + amountToTransfer, + assetId +); + +const chainId = provider.getChainId(); + +const transactionId = transactionRequest.getTransactionId(chainId); + +const response = await sender.sendTransaction(transactionRequest); + +// The transaction id is the same one returned by the code above. +const { id } = await response.wait(); +// #endregion transferring-assets-2 + +console.log('transactionId', id === transactionId); diff --git a/apps/docs-snippets2/src/cookbook/wallet-transferring/transferring-to-contracts.ts b/apps/docs-snippets2/src/cookbook/wallet-transferring/transferring-to-contracts.ts new file mode 100644 index 00000000000..10b6f410b9e --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/wallet-transferring/transferring-to-contracts.ts @@ -0,0 +1,25 @@ +// #region transferring-assets-4 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { CounterFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const sender = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); +const deploy = await CounterFactory.deploy(sender); +const { contract } = await deploy.waitForResult(); + +const amountToTransfer = 400; +const assetId = provider.getBaseAssetId(); +const contractId = contract.id; + +const tx = await sender.transferToContract( + contractId, + amountToTransfer, + assetId +); + +await tx.waitForResult(); +// #endregion transferring-assets-4 + +console.log('balance', (await contract.getBalance(assetId)).toNumber() !== 0); diff --git a/apps/docs-snippets2/src/cookbook/wallet-transferring/transferring-to-multiple-contracts.ts b/apps/docs-snippets2/src/cookbook/wallet-transferring/transferring-to-multiple-contracts.ts new file mode 100644 index 00000000000..a45dab04d9f --- /dev/null +++ b/apps/docs-snippets2/src/cookbook/wallet-transferring/transferring-to-multiple-contracts.ts @@ -0,0 +1,40 @@ +// #region transferring-assets-5 +import type { ContractTransferParams } from 'fuels'; +import { Provider, Wallet } from 'fuels'; +import { TestAssetId } from 'fuels/test-utils'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { CounterFactory, EchoValuesFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const sender = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); +const baseAssetId = provider.getBaseAssetId(); +const assetA = TestAssetId.A.value; + +const deploy1 = await CounterFactory.deploy(sender); +const deploy2 = await EchoValuesFactory.deploy(sender); + +const { contract: contract1 } = await deploy1.waitForResult(); +const { contract: contract2 } = await deploy2.waitForResult(); + +const contractTransferParams: ContractTransferParams[] = [ + { + contractId: contract1.id, + amount: 999, + assetId: baseAssetId, + }, + { + contractId: contract1.id, + amount: 550, + assetId: assetA, + }, + { + contractId: contract2.id, + amount: 200, + assetId: assetA, + }, +]; + +const transfer = await sender.batchTransferToContracts(contractTransferParams); +await transfer.waitForResult(); +// #endregion transferring-assets-5 diff --git a/apps/docs-snippets2/sway/Forc.toml b/apps/docs-snippets2/sway/Forc.toml index 512284fe60b..c0d77ce6ba3 100644 --- a/apps/docs-snippets2/sway/Forc.toml +++ b/apps/docs-snippets2/sway/Forc.toml @@ -17,6 +17,10 @@ members = [ "echo-std-string", "employee-data", "input-output-types", + "liquidity-pool", + "predicate-signing", + "return-script", + "script-signing", "predicate-main-args-struct", "predicate-multi-args", "return-true-predicate", diff --git a/apps/docs-snippets/test/fixtures/forc-projects/liquidity-pool/Forc.toml b/apps/docs-snippets2/sway/liquidity-pool/Forc.toml similarity index 100% rename from apps/docs-snippets/test/fixtures/forc-projects/liquidity-pool/Forc.toml rename to apps/docs-snippets2/sway/liquidity-pool/Forc.toml diff --git a/apps/docs-snippets/test/fixtures/forc-projects/liquidity-pool/src/main.sw b/apps/docs-snippets2/sway/liquidity-pool/src/main.sw similarity index 100% rename from apps/docs-snippets/test/fixtures/forc-projects/liquidity-pool/src/main.sw rename to apps/docs-snippets2/sway/liquidity-pool/src/main.sw diff --git a/apps/docs-snippets/test/fixtures/forc-projects/predicate-signing/Forc.toml b/apps/docs-snippets2/sway/predicate-signing/Forc.toml similarity index 100% rename from apps/docs-snippets/test/fixtures/forc-projects/predicate-signing/Forc.toml rename to apps/docs-snippets2/sway/predicate-signing/Forc.toml diff --git a/apps/docs-snippets/test/fixtures/forc-projects/predicate-signing/src/main.sw b/apps/docs-snippets2/sway/predicate-signing/src/main.sw similarity index 100% rename from apps/docs-snippets/test/fixtures/forc-projects/predicate-signing/src/main.sw rename to apps/docs-snippets2/sway/predicate-signing/src/main.sw diff --git a/apps/docs-snippets/test/fixtures/forc-projects/return-script/Forc.toml b/apps/docs-snippets2/sway/return-script/Forc.toml similarity index 100% rename from apps/docs-snippets/test/fixtures/forc-projects/return-script/Forc.toml rename to apps/docs-snippets2/sway/return-script/Forc.toml diff --git a/apps/docs-snippets/test/fixtures/forc-projects/return-script/src/main.sw b/apps/docs-snippets2/sway/return-script/src/main.sw similarity index 100% rename from apps/docs-snippets/test/fixtures/forc-projects/return-script/src/main.sw rename to apps/docs-snippets2/sway/return-script/src/main.sw diff --git a/apps/docs-snippets/test/fixtures/forc-projects/script-signing/Forc.toml b/apps/docs-snippets2/sway/script-signing/Forc.toml similarity index 100% rename from apps/docs-snippets/test/fixtures/forc-projects/script-signing/Forc.toml rename to apps/docs-snippets2/sway/script-signing/Forc.toml diff --git a/apps/docs-snippets/test/fixtures/forc-projects/script-signing/src/main.sw b/apps/docs-snippets2/sway/script-signing/src/main.sw similarity index 100% rename from apps/docs-snippets/test/fixtures/forc-projects/script-signing/src/main.sw rename to apps/docs-snippets2/sway/script-signing/src/main.sw diff --git a/apps/docs/src/guide/cookbook/custom-transactions-from-contract-calls.md b/apps/docs/src/guide/cookbook/custom-transactions-from-contract-calls.md index 346e7106f19..ad7a3f9c610 100644 --- a/apps/docs/src/guide/cookbook/custom-transactions-from-contract-calls.md +++ b/apps/docs/src/guide/cookbook/custom-transactions-from-contract-calls.md @@ -4,4 +4,4 @@ In the previous example we demonstrated how you can instantiate a [`ScriptTransa This cookbook demonstrates how we can utilize a contract call to build out a custom transaction, allowing us to update on-chain state and transfer assets to a recipient address. -<<< @/../../docs-snippets/src/guide/cookbook/custom-transactions-contract-calls.test.ts#custom-transactions-contract-calls{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/custom-contract-calls.ts#custom-transactions-contract-calls{ts:line-numbers} diff --git a/apps/docs/src/guide/cookbook/deposit-and-withdraw.md b/apps/docs/src/guide/cookbook/deposit-and-withdraw.md index 0ae4806e3c9..d3765bc44ec 100644 --- a/apps/docs/src/guide/cookbook/deposit-and-withdraw.md +++ b/apps/docs/src/guide/cookbook/deposit-and-withdraw.md @@ -2,14 +2,14 @@ Consider the following contract: -<<< @/../../docs-snippets/test/fixtures/forc-projects/liquidity-pool/src/main.sw#deposit-and-withdraw-cookbook-1{rust:line-numbers} +<<< @/../../docs-snippets2/sway/liquidity-pool/src/main.sw#deposit-and-withdraw-cookbook-1{rust:line-numbers} As the name implies, this contract represents a simplified version of a liquidity pool. The `deposit()` method allows you to supply an arbitrary amount of `BASE_TOKEN`. In response, it mints twice the amount of the liquidity asset to the caller's address. Similarly, the `withdraw()` method transfers half the amount of the `BASE_TOKEN` back to the caller's address. Now, let's deposit some tokens into the liquidity pool contract. Since this requires forwarding assets to the contract, we need to pass the appropriate values to `callParams` when creating a contract call. -<<< @/../../docs-snippets/src/guide/cookbook/deposit-and-withdraw.test.ts#deposit-and-withdraw-cookbook-2{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/deposit-and-withdraw/deposit.ts#deposit-and-withdraw-cookbook-2{ts:line-numbers} As a final demonstration, let's use all our liquidity asset balance to withdraw from the pool and confirm we retrieved the initial amount. For this, we get our liquidity asset balance and supply it to the `withdraw()` function via `callParams`. -<<< @/../../docs-snippets/src/guide/cookbook/deposit-and-withdraw.test.ts#deposit-and-withdraw-cookbook-3{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/deposit-and-withdraw/withdraw.ts#deposit-and-withdraw-cookbook-3{ts:line-numbers} diff --git a/apps/docs/src/guide/cookbook/generate-fake-resources.md b/apps/docs/src/guide/cookbook/generate-fake-resources.md index 37f472ce565..ae1a896609d 100644 --- a/apps/docs/src/guide/cookbook/generate-fake-resources.md +++ b/apps/docs/src/guide/cookbook/generate-fake-resources.md @@ -4,10 +4,10 @@ When working with an unfunded account, you can generate fake resources to perfor Below is an example script that returns the value `1337`. You can use fake resources to execute a dry-run of this script and obtain the returned value. -<<< @/../../docs-snippets/test/fixtures/forc-projects/return-script/src/main.sw#generate-fake-resources-1{rust:line-numbers} +<<< @/../../docs-snippets2/sway/return-script/src/main.sw#generate-fake-resources-1{rust:line-numbers} To execute a dry-run, use the `Provider.dryRun` method. Ensure you set the `utxo_validation` flag to true, as this script uses fake UTXOs: -<<< @/../../docs-snippets/src/guide/cookbook/generate-fake-resources.test.ts#generate-fake-resources-2{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/fake-resources.ts#generate-fake-resources-2{ts:line-numbers} By setting `utxo_validation` to `true`, you can successfully execute the dry-run and retrieve the returned value from the script without requiring actual funds. diff --git a/apps/docs/src/guide/cookbook/resubmitting-failed-transactions.md b/apps/docs/src/guide/cookbook/resubmitting-failed-transactions.md index c1f105892cd..491546b0f53 100644 --- a/apps/docs/src/guide/cookbook/resubmitting-failed-transactions.md +++ b/apps/docs/src/guide/cookbook/resubmitting-failed-transactions.md @@ -2,22 +2,22 @@ In certain scenarios, you might need to implement a solution to resubmit failed transactions to the Fuel Network. While this approach can be effective, there are important considerations to remember. - ## Submission and Processing When submitting a transaction, you will first get a response. -<<< @/../../docs-snippets/src/guide/cookbook/resubmitting-failed-transactions.test.ts#resubmitting-failed-transactions-1{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/resubmitting-failed-transactions/submitting.ts#resubmitting-failed-transactions-1{ts:line-numbers} If the `sendTransaction` method resolves without an error, we know that the transaction was successfully submitted and accepted by the network. However, this does not guarantee that the transaction has been processed; it only indicates that the transaction has been accepted and placed in a queue for processing. To determine whether the transaction has been processed, you must call `waitForResult`, which will either resolve (with the processed transaction) or reject with an error. -<<< @/../../docs-snippets/src/guide/cookbook/resubmitting-failed-transactions.test.ts#resubmitting-failed-transactions-2{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/resubmitting-failed-transactions/submitting.ts#resubmitting-failed-transactions-2{ts:line-numbers} In other words: - - If `sendTransaction` is rejected with an error, the transaction was not accepted by the network and is not processed. - - If `waitForResult` is rejected with an error, the transaction was accepted but reverted during processing. + +- If `sendTransaction` is rejected with an error, the transaction was not accepted by the network and is not processed. +- If `waitForResult` is rejected with an error, the transaction was accepted but reverted during processing. ## Resources Spent When a Transaction Is Processed @@ -25,7 +25,7 @@ If a transaction is reverted during processing, the Fuel VM will still consume t Attempting to resubmit the same transaction request that failed during processing will likely result in an error, as the initially spent resources no longer exist. -<<< @/../../docs-snippets/src/guide/cookbook/resubmitting-failed-transactions.test.ts#resubmitting-failed-transactions-3{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/resubmitting-failed-transactions/wrong-resubmission.ts#resubmitting-failed-transactions-3{ts:line-numbers} The attempt from the above snippet will result in the error: @@ -35,4 +35,4 @@ FuelError: Transaction is not inserted. UTXO does not exist: {{utxoId}} To safely retry a transaction that failed during processing, you should reassemble the request from scratch and resubmit it. -<<< @/../../docs-snippets/src/guide/cookbook/resubmitting-failed-transactions.test.ts#resubmitting-failed-transactions-4{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/resubmitting-failed-transactions/right-resubmission.ts#resubmitting-failed-transactions-4{ts:line-numbers} diff --git a/apps/docs/src/guide/cookbook/transactions-with-multiple-signers.md b/apps/docs/src/guide/cookbook/transactions-with-multiple-signers.md index a7d5000323f..ef870ffa837 100644 --- a/apps/docs/src/guide/cookbook/transactions-with-multiple-signers.md +++ b/apps/docs/src/guide/cookbook/transactions-with-multiple-signers.md @@ -4,18 +4,18 @@ When a transaction contains a spendable input such as a coin, it must also conta Consider a script that requires two signatures to be spent: -<<< @/../../docs-snippets/test/fixtures/forc-projects/script-signing/src/main.sw#multiple-signers-1{rust:line-numbers} +<<< @/../../docs-snippets2/sway/script-signing/src/main.sw#multiple-signers-1{rust:line-numbers} In the snippet above, we use the built-in Sway function `tx_witness_data()` to retrieve the witness signatures and `tx_id()` for the transaction hash. Then, we retrieve the signing address to validate the script. We would interact with this script in the SDK by creating a transaction request from an invocation scope. The same can be done for a contract. Consider the following script: -<<< @/../../docs-snippets/src/guide/cookbook/signing-transactions.test.ts#multiple-signers-2{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/signing-transactions/script.ts#multiple-signers-2{ts:line-numbers} The same approach can be used for a predicate by instantiating it and adding it to a transaction request. Consider the following predicate: -<<< @/../../docs-snippets/test/fixtures/forc-projects/predicate-signing/src/main.sw#multiple-signers-3{rust:line-numbers} +<<< @/../../docs-snippets2/sway/predicate-signing/src/main.sw#multiple-signers-3{rust:line-numbers} We can interact with this predicate in the SDK with the following implementation: -<<< @/../../docs-snippets/src/guide/cookbook/signing-transactions.test.ts#multiple-signers-4{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/signing-transactions/predicate.ts#multiple-signers-4{ts:line-numbers} diff --git a/apps/docs/src/guide/wallets/wallet-transferring.md b/apps/docs/src/guide/wallets/wallet-transferring.md index 96c6c68b54b..f41e352d2b9 100644 --- a/apps/docs/src/guide/wallets/wallet-transferring.md +++ b/apps/docs/src/guide/wallets/wallet-transferring.md @@ -16,7 +16,7 @@ Upon execution, this function returns a promise that resolves to a transaction r Here is an example of how to use the `transfer` function: -<<< @/../../docs-snippets/src/guide/cookbook/transferring-assets.test.ts#transferring-assets-1{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/wallet-transferring/between-accounts.ts#transferring-assets-1{ts:line-numbers} In the previous example, we used the `transfer` method which creates a `ScriptTransactionRequest`, populates its data with the provided transfer information and submits the transaction. @@ -24,11 +24,11 @@ However, there may be times when you need the Transaction ID before actually sub This method also creates a `ScriptTransactionRequest` and populates it with the provided data but returns the request object prior to submission. -<<< @/../../docs-snippets/src/guide/cookbook/transferring-assets.test.ts#transferring-assets-2{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/wallet-transferring/create-transfer.ts#transferring-assets-2{ts:line-numbers} > **Note**: Any changes made to a transaction request will alter the transaction ID. Therefore, you should only get the transaction ID after all modifications have been made. -<<< @/../../docs-snippets/src/guide/cookbook/transferring-assets.test.ts#transferring-assets-3{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/wallet-transferring/create-transfer-2.ts#transferring-assets-3{ts:line-numbers} ## Transferring Assets To Multiple Wallets @@ -46,7 +46,7 @@ If you have the [Contract](../contracts/) instance of the deployed contract, you Here's an example demonstrating how to use `transferToContract`: -<<< @/../../docs-snippets/src/guide/cookbook/transferring-assets.test.ts#transferring-assets-4{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/wallet-transferring/transferring-to-contracts.ts#transferring-assets-4{ts:line-numbers} _Note: Use `transferToContract` exclusively for transfers to a contract. For transfers to an account address, use `transfer` instead._ @@ -54,7 +54,7 @@ _Note: Use `transferToContract` exclusively for transfers to a contract. For tra Similar to the `Account.batchTransfer` method, you can transfer multiple assets to multiple contracts using the `Account.batchTransferToContracts` method. Here's how it works: -<<< @/../../docs-snippets/src/guide/cookbook/transferring-assets.test.ts#transferring-assets-5{ts:line-numbers} +<<< @/../../docs-snippets2/src/cookbook/wallet-transferring/transferring-to-multiple-contracts.ts#transferring-assets-5{ts:line-numbers} Always remember to call the `waitForResult()` function on the transaction response. That ensures the transaction has been mined successfully before proceeding. From 8c77765aad82427a3569ca6d8f3f84c9b9767fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:20:36 +0700 Subject: [PATCH 2/6] chore!: optimize `getTransactions` query (#3336) --- .changeset/nervous-impalas-serve.md | 5 +++ .../account/src/providers/operations.graphql | 14 +++---- .../account/src/providers/provider.test.ts | 42 +++++++++++++++++++ 3 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 .changeset/nervous-impalas-serve.md diff --git a/.changeset/nervous-impalas-serve.md b/.changeset/nervous-impalas-serve.md new file mode 100644 index 00000000000..8d3d8437801 --- /dev/null +++ b/.changeset/nervous-impalas-serve.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/account": minor +--- + +chore!: optimize `getTransactions` query diff --git a/packages/account/src/providers/operations.graphql b/packages/account/src/providers/operations.graphql index 67efe338593..a4cbed37adb 100644 --- a/packages/account/src/providers/operations.graphql +++ b/packages/account/src/providers/operations.graphql @@ -130,6 +130,11 @@ fragment transactionFragment on Transaction { } } +fragment transactionRawPayloadFragment on Transaction { + id + rawPayload +} + fragment inputEstimatePredicatesFragment on Input { ... on InputCoin { predicateGasUsed @@ -487,7 +492,7 @@ query getTransactions( transactions(after: $after, before: $before, first: $first, last: $last) { edges { node { - ...transactionFragment + rawPayload } } pageInfo { @@ -553,7 +558,7 @@ query getBlockWithTransactions($blockId: BlockId, $blockHeight: U32) { block(id: $blockId, height: $blockHeight) { ...blockFragment transactions { - ...transactionRawPayload + ...transactionRawPayloadFragment } } } @@ -571,11 +576,6 @@ query getBlocks($after: String, $before: String, $first: Int, $last: Int) { } } -fragment transactionRawPayload on Transaction { - id - rawPayload -} - query getCoin($coinId: UtxoId!) { coin(utxoId: $coinId) { ...coinFragment diff --git a/packages/account/src/providers/provider.test.ts b/packages/account/src/providers/provider.test.ts index f0042b90ad0..f8791c58505 100644 --- a/packages/account/src/providers/provider.test.ts +++ b/packages/account/src/providers/provider.test.ts @@ -1878,6 +1878,48 @@ Supported fuel-core version: ${mock.supportedVersion}.` }); }); + it('ensures getTransactions does not fetch unused data', async () => { + using launched = await setupTestProviderAndWallets(); + const { provider } = launched; + + await provider.produceBlocks(1); + + const { transactions } = await provider.operations.getTransactions({ + first: 1, + }); + + expect(transactions.edges.length).toBe(1); + + const expectedData = { + rawPayload: expect.any(String), + }; + + expect(transactions.edges[0].node).toStrictEqual(expectedData); + }); + + it('ensures getBlockWithTransactions does not fetch unused transaction data', async () => { + using launched = await setupTestProviderAndWallets(); + const { provider } = launched; + + await provider.produceBlocks(1); + + const blockNumber = await provider.getBlockNumber(); + + const { block } = await provider.operations.getBlockWithTransactions({ + blockHeight: blockNumber.toString(), + }); + + expect(block).toBeDefined(); + expect(block?.transactions.length).toBe(1); + + const expectedData = { + id: expect.any(String), + rawPayload: expect.any(String), + }; + + expect(block?.transactions?.[0]).toStrictEqual(expectedData); + }); + describe('paginated methods', () => { test('can properly use getCoins', async () => { const totalCoins = RESOURCES_PAGE_SIZE_LIMIT + 1; From 63a34f6269e38f04b769d7daf7cc4063dfcfb1fd Mon Sep 17 00:00:00 2001 From: Chad Nehemiah Date: Tue, 12 Nov 2024 04:31:40 -0500 Subject: [PATCH 3/6] docs: migrate other half of the wallet snippets (#3365) * docs: convert old wallet snippets * docs: split snippets * docs: update snippets * docs: ensure test is node only * docs: add node group at the bottom * remove old import Co-authored-by: Peter Smith * remove old import Co-authored-by: Peter Smith * remove space Co-authored-by: Peter Smith * adjust imports in snippet Co-authored-by: Peter Smith * remove old import Co-authored-by: Peter Smith * docs: remove old import * docs: update snippet test suffix * docs: move snippets into wallet guide * docs: update snippets comment Co-authored-by: Daniel Bate * docs: remove unnecessary full examples * linting fixes * docs: add try/catch to snippet * docs: add defaultConnectors + remove unused snippet * dep: patch temp issue with knip * docs: update to use mocked deps --------- Co-authored-by: Peter Smith Co-authored-by: Daniel Bate --- .knip.json | 1 + .../src/guide/wallets/access.test.ts | 78 ----- .../checking-balances-and-coins.test.ts | 39 --- .../guide/wallets/checking-balances.test.ts | 45 --- ...ypting-and-decrypting-json-wallets.test.ts | 61 ---- apps/docs-snippets2/src/wallets/access.ts | 45 +++ .../src/wallets/checking-balances-two.ts | 11 + .../src/wallets/checking-balances.ts | 15 + .../src/wallets/connectors.ts} | 102 +----- ...rypting-and-decrypting-json-wallets-two.ts | 31 ++ .../encrypting-and-decrypting-wallets.ts | 22 ++ .../src/wallets/fuel-instantiation-one.ts | 13 + .../src/wallets/fuel-instantiation-options.ts | 19 ++ .../src/wallets/fuel-options-storage-local.ts | 17 + .../wallets/fuel-options-storage-memory.ts | 8 + .../src/wallets/fuel-options-target-object.ts | 13 + .../src/wallets/locked-to-unlocked.ts | 17 + .../src/wallets/unlocked-to-locked.ts | 12 + .../src/wallets/wallet-optional-provider.ts | 20 ++ .../guide/testing/setting-up-test-wallets.md | 2 +- .../src/guide/wallets/checking-balances.md | 4 +- apps/docs/src/guide/wallets/connectors.md | 40 +-- .../wallets/encrypting-and-decrypting.md | 5 +- .../guide/wallets/locking-and-unlocking.md | 14 +- apps/docs/src/guide/wallets/private-keys.md | 2 +- pnpm-lock.yaml | 316 +++++++++--------- 26 files changed, 451 insertions(+), 501 deletions(-) delete mode 100644 apps/docs-snippets/src/guide/wallets/access.test.ts delete mode 100644 apps/docs-snippets/src/guide/wallets/checking-balances-and-coins.test.ts delete mode 100644 apps/docs-snippets/src/guide/wallets/checking-balances.test.ts delete mode 100644 apps/docs-snippets/src/guide/wallets/encrypting-and-decrypting-json-wallets.test.ts create mode 100644 apps/docs-snippets2/src/wallets/access.ts create mode 100644 apps/docs-snippets2/src/wallets/checking-balances-two.ts create mode 100644 apps/docs-snippets2/src/wallets/checking-balances.ts rename apps/{docs-snippets/src/guide/wallets/connectors.test.ts => docs-snippets2/src/wallets/connectors.ts} (57%) create mode 100644 apps/docs-snippets2/src/wallets/encrypting-and-decrypting-json-wallets-two.ts create mode 100644 apps/docs-snippets2/src/wallets/encrypting-and-decrypting-wallets.ts create mode 100644 apps/docs-snippets2/src/wallets/fuel-instantiation-one.ts create mode 100644 apps/docs-snippets2/src/wallets/fuel-instantiation-options.ts create mode 100644 apps/docs-snippets2/src/wallets/fuel-options-storage-local.ts create mode 100644 apps/docs-snippets2/src/wallets/fuel-options-storage-memory.ts create mode 100644 apps/docs-snippets2/src/wallets/fuel-options-target-object.ts create mode 100644 apps/docs-snippets2/src/wallets/locked-to-unlocked.ts create mode 100644 apps/docs-snippets2/src/wallets/unlocked-to-locked.ts create mode 100644 apps/docs-snippets2/src/wallets/wallet-optional-provider.ts diff --git a/.knip.json b/.knip.json index 6e629a38f71..31d3c192d79 100644 --- a/.knip.json +++ b/.knip.json @@ -15,6 +15,7 @@ "bun", "@/sway-api/*", "@fuel-ts/*", + "@fuels/connectors", "@internal/fuel-core", "@internal/forc", "@types/jest", diff --git a/apps/docs-snippets/src/guide/wallets/access.test.ts b/apps/docs-snippets/src/guide/wallets/access.test.ts deleted file mode 100644 index 4cb269c5b72..00000000000 --- a/apps/docs-snippets/src/guide/wallets/access.test.ts +++ /dev/null @@ -1,78 +0,0 @@ -import type { WalletLocked, WalletUnlocked } from 'fuels'; -import { Wallet } from 'fuels'; -import { launchTestNode } from 'fuels/test-utils'; - -/** - * @group node - * @group browser - */ -describe('Wallet Access', () => { - it('wallets', async () => { - using launched = await launchTestNode(); - const { provider } = launched; - - // #region wallets - // #import { Wallet, WalletLocked, WalletUnlocked }; - - // We can use the `generate` to create a new unlocked wallet. - const myWallet: WalletUnlocked = Wallet.generate({ provider }); - - // or use an Address to create a wallet - const someWallet: WalletLocked = Wallet.fromAddress(myWallet.address, provider); - // #endregion wallets - - expect(myWallet.address).toBeTruthy(); - expect(someWallet.address).toBeTruthy(); - }); - - it('wallet-locked-to-unlocked', async () => { - using launched = await launchTestNode(); - const { provider } = launched; - - const myWallet: WalletUnlocked = Wallet.generate({ provider }); - const PRIVATE_KEY = myWallet.privateKey; - - // #region wallet-locked-to-unlocked - // #import { Wallet, WalletLocked, WalletUnlocked }; - - // Lock an existing wallet - const lockedWallet: WalletLocked = Wallet.fromAddress(myWallet.address, provider); - - // Unlock an existing wallet - const unlockedWallet: WalletUnlocked = lockedWallet.unlock(PRIVATE_KEY); - // #endregion wallet-locked-to-unlocked - - expect(myWallet.address).toBeTruthy(); - expect(unlockedWallet.address).toEqual(myWallet.address); - }); - - it('wallet-unlocked-to-locked', async () => { - using launched = await launchTestNode(); - const { provider } = launched; - - const unlockedWallet: WalletUnlocked = Wallet.generate({ provider }); - - // #region wallet-unlocked-to-locked - const newlyLockedWallet = unlockedWallet.lock(); - // #endregion wallet-unlocked-to-locked - - expect(unlockedWallet).toBeTruthy(); - expect(newlyLockedWallet.address).toEqual(unlockedWallet.address); - }); - - it('it can be created without a provider', async () => { - // #region wallet-optional-provider - // #context import { Wallet, WalletUnlocked } from 'fuels'; - - // You can create a wallet, without a provider - let unlockedWallet: WalletUnlocked = Wallet.generate(); - unlockedWallet = Wallet.fromPrivateKey(unlockedWallet.privateKey); - - // All non-provider dependent methods are available - unlockedWallet.lock(); - - // All provider dependent methods will throw - await expect(() => unlockedWallet.getCoins()).rejects.toThrow(/Provider not set/); - // #endregion wallet-optional-provider - }); -}); diff --git a/apps/docs-snippets/src/guide/wallets/checking-balances-and-coins.test.ts b/apps/docs-snippets/src/guide/wallets/checking-balances-and-coins.test.ts deleted file mode 100644 index 1fb2b8cb8f8..00000000000 --- a/apps/docs-snippets/src/guide/wallets/checking-balances-and-coins.test.ts +++ /dev/null @@ -1,39 +0,0 @@ -import type { BigNumberish, WalletUnlocked } from 'fuels'; -import { Wallet } from 'fuels'; -import { launchTestNode } from 'fuels/test-utils'; - -/** - * @group node - * @group browser - */ -describe('Checking balances and coins', () => { - it('wallet-check-balance', async () => { - using launched = await launchTestNode(); - const { provider } = launched; - - const myWallet: WalletUnlocked = Wallet.generate({ provider }); - - // #region wallet-check-balance - // #import { BigNumberish }; - - const balance: BigNumberish = await myWallet.getBalance(provider.getBaseAssetId()); - // #endregion wallet-check-balance - - expect(balance.toNumber()).toEqual(0); - }); - - it('wallet-check-balances', async () => { - using launched = await launchTestNode(); - const { provider } = launched; - - const myWallet: WalletUnlocked = Wallet.generate({ provider }); - - // #region wallet-check-balances - // #context import { CoinQuantity } from 'fuels'; - - const { balances } = await myWallet.getBalances(); - // #endregion wallet-check-balances - - expect(balances).toEqual([]); - }); -}); diff --git a/apps/docs-snippets/src/guide/wallets/checking-balances.test.ts b/apps/docs-snippets/src/guide/wallets/checking-balances.test.ts deleted file mode 100644 index b9cf92ea312..00000000000 --- a/apps/docs-snippets/src/guide/wallets/checking-balances.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import type { BN } from 'fuels'; -import { Wallet } from 'fuels'; -import { launchTestNode } from 'fuels/test-utils'; - -/** - * @group node - * @group browser - */ -describe('Checking balances', () => { - it('should fetch specific balance just fine', async () => { - using launched = await launchTestNode(); - const { - provider, - wallets: [testWallet], - } = launched; - - const privateKey = testWallet.privateKey; - - // #region checking-balances-1 - const myWallet = Wallet.fromPrivateKey(privateKey, provider); - - // The returned amount is a BigNumber - const balance: BN = await myWallet.getBalance(provider.getBaseAssetId()); - // #endregion checking-balances-1 - - expect(balance).toBeDefined(); - }); - - it('should fetch all balances just fine', async () => { - using launched = await launchTestNode(); - const { - provider, - wallets: [testWallet], - } = launched; - - const privateKey = testWallet.privateKey; - // #region checking-balances-2 - const myWallet = Wallet.fromPrivateKey(privateKey, provider); - - const { balances } = await myWallet.getBalances(); - // #endregion checking-balances-2 - - expect(balances).toBeDefined(); - }); -}); diff --git a/apps/docs-snippets/src/guide/wallets/encrypting-and-decrypting-json-wallets.test.ts b/apps/docs-snippets/src/guide/wallets/encrypting-and-decrypting-json-wallets.test.ts deleted file mode 100644 index 6664b1b16e5..00000000000 --- a/apps/docs-snippets/src/guide/wallets/encrypting-and-decrypting-json-wallets.test.ts +++ /dev/null @@ -1,61 +0,0 @@ -import fs from 'fs'; -import { Wallet } from 'fuels'; -import { launchTestNode } from 'fuels/test-utils'; - -/** - * @group node - */ -describe('Encrypting and decrypting JSON wallets', () => { - it('should successfully encrypt wallet', async () => { - using launched = await launchTestNode(); - const { provider } = launched; - - // #region encrypting-and-decrypting-json-wallets-1 - // #import { Wallet, fs }; - - const wallet = Wallet.generate({ provider }); - - // Encrypt the wallet - const password = 'my-password'; - const jsonWallet = await wallet.encrypt(password); - - // Save the encrypted wallet to a file - // #context fs.writeFileSync('secure-path/my-wallet.json', jsonWallet); - // #endregion encrypting-and-decrypting-json-wallets-1 - - expect(jsonWallet).toBeDefined(); - }); - - it('should successfully decrypt a wallet', async () => { - using launched = await launchTestNode(); - const { provider } = launched; - - const jsonWallet = await Wallet.generate({ - provider, - }).encrypt('my-password'); - // #region encrypting-and-decrypting-json-wallets-2 - // #import { Wallet, fs }; - - // Load the encrypted wallet from a file - // #context const jsonWallet = fs.readFileSync('secure-path/my-wallet.json', 'utf-8'); - - // Decrypt the wallet - const password = 'my-password'; - const decryptedWallet = await Wallet.fromEncryptedJson(jsonWallet, password, provider); - - // Use the decrypted wallet - const myBalance = await decryptedWallet.getBalance(); - // #endregion encrypting-and-decrypting-json-wallets-2 - - expect(myBalance).toBeDefined(); - }, 10000); - - it('should validate that fs was imported on this file', () => { - /** - * This test exists only to validate that the fs import is present on this file. - * This is required because the fs import is being used in code snippets declared - * on within this file therefore its import will be extracted from this same file. - */ - expect(fs).toBeDefined(); - }); -}); diff --git a/apps/docs-snippets2/src/wallets/access.ts b/apps/docs-snippets2/src/wallets/access.ts new file mode 100644 index 00000000000..5c6340fee18 --- /dev/null +++ b/apps/docs-snippets2/src/wallets/access.ts @@ -0,0 +1,45 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +// #region full +// #region wallets +import type { WalletLocked, WalletUnlocked } from 'fuels'; +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL } from '../env'; + +// We can use the `generate` to create a new unlocked wallet. +const provider = await Provider.create(LOCAL_NETWORK_URL); +const myWallet: WalletUnlocked = Wallet.generate({ provider }); + +// or use an Address to create a wallet +const someWallet: WalletLocked = Wallet.fromAddress(myWallet.address, provider); +// #endregion wallets + +const wallet: WalletUnlocked = Wallet.generate({ provider }); +const PRIVATE_KEY = wallet.privateKey; + +// Lock an existing wallet +const lockedWallet: WalletLocked = Wallet.fromAddress( + myWallet.address, + provider +); + +// Unlock an existing wallet +const someUnlockedWallet: WalletUnlocked = lockedWallet.unlock(PRIVATE_KEY); + +const unlockedWallet: WalletUnlocked = Wallet.generate({ provider }); +const newlyLockedWallet = unlockedWallet.lock(); + +// You can create a wallet, without a provider +let unlockedWalletWithoutProvider: WalletUnlocked = Wallet.generate(); +unlockedWalletWithoutProvider = Wallet.fromPrivateKey( + unlockedWalletWithoutProvider.privateKey +); + +// All non-provider dependent methods are available +unlockedWalletWithoutProvider.lock(); + +// All provider dependent methods will throw +await expect(() => unlockedWalletWithoutProvider.getCoins()).rejects.toThrow( + /Provider not set/ +); +// #endregion full diff --git a/apps/docs-snippets2/src/wallets/checking-balances-two.ts b/apps/docs-snippets2/src/wallets/checking-balances-two.ts new file mode 100644 index 00000000000..1ef62c05c5c --- /dev/null +++ b/apps/docs-snippets2/src/wallets/checking-balances-two.ts @@ -0,0 +1,11 @@ +// #region checking-balances-2 +import { Provider, Wallet } from 'fuels'; + +import { WALLET_PVT_KEY_2, LOCAL_NETWORK_URL } from '../env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const myOtherWallet = Wallet.fromPrivateKey(WALLET_PVT_KEY_2, provider); + +const { balances } = await myOtherWallet.getBalances(); +// #endregion checking-balances-2 +console.log('balances:', balances); diff --git a/apps/docs-snippets2/src/wallets/checking-balances.ts b/apps/docs-snippets2/src/wallets/checking-balances.ts new file mode 100644 index 00000000000..88bab34d0b1 --- /dev/null +++ b/apps/docs-snippets2/src/wallets/checking-balances.ts @@ -0,0 +1,15 @@ +// #region checking-balances-1 +import type { BN } from 'fuels'; +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); + +const myWallet = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +// The returned amount is a BigNumber +const balance: BN = await myWallet.getBalance(provider.getBaseAssetId()); + +// #endregion checking-balances-1 +console.log('balance', balance); diff --git a/apps/docs-snippets/src/guide/wallets/connectors.test.ts b/apps/docs-snippets2/src/wallets/connectors.ts similarity index 57% rename from apps/docs-snippets/src/guide/wallets/connectors.test.ts rename to apps/docs-snippets2/src/wallets/connectors.ts index ff7dce6832e..117be5d3318 100644 --- a/apps/docs-snippets/src/guide/wallets/connectors.test.ts +++ b/apps/docs-snippets2/src/wallets/connectors.ts @@ -1,6 +1,7 @@ /* eslint-disable max-classes-per-file */ -import { Fuel, LocalStorage, MemoryStorage, FuelConnector } from 'fuels'; -import type { TargetObject, Network, Asset, FuelABI } from 'fuels'; +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { MemoryStorage, FuelConnector } from 'fuels'; +import type { Network, Asset, FuelABI } from 'fuels'; // prettier-ignore // #region fuel-connector-extends @@ -76,8 +77,6 @@ class WalletConnector extends FuelConnector { // #endregion fuel-connector-events-currentAccount // #region fuel-connector-events-networks - // #import { Network }; - const network: Network = { chainId: 1, url: 'https://example.com/rpc', @@ -87,8 +86,6 @@ class WalletConnector extends FuelConnector { // #endregion fuel-connector-events-networks // #region fuel-connector-events-currentNetwork - // #import { Network }; - const currentNetwork: Network = { chainId: 1, url: 'https://example.com/rpc', @@ -98,8 +95,6 @@ class WalletConnector extends FuelConnector { // #endregion fuel-connector-events-currentNetwork // #region fuel-connector-events-assets - // #import { Asset }; - const assets: Array = [ { name: 'Ethereum', @@ -137,94 +132,3 @@ class WalletConnector extends FuelConnector { // #endregion fuel-connector-events-abis } } - -/** - * @group node - */ -describe('connectors', () => { - describe('instantiation', () => { - test('should be able to instantiate a Fuel SDK', async () => { - // #region fuel-instantiation-1 - // #import { Fuel }; - - const sdk = new Fuel(); - - /* - Awaits for initialization to mitigate potential race conditions - derived from the async nature of instantiating a connector. - */ - await sdk.init(); - // #endregion fuel-instantiation-1 - - expect(sdk).toBeDefined(); - }); - - test('should be able to instantiate with connectors', async () => { - const defaultConnectors = (_opts: { devMode: boolean }): Array => [ - new WalletConnector(), - ]; - - // #region fuel-options-connectors - // #import { Fuel }; - // #context import { defaultConnectors } from '@fuels/connectors'; - - const sdk = await new Fuel({ - connectors: defaultConnectors({ - devMode: true, - }), - }).init(); - // #endregion fuel-options-connectors - - expect(sdk).toBeDefined(); - }); - - test('should be able to instantiate with memory storage', async () => { - // #region fuel-options-storage-memory - // #import { Fuel, MemoryStorage }; - - const sdk = await new Fuel({ - storage: new MemoryStorage(), - }).init(); - // #endregion fuel-options-storage-memory - - expect(sdk).toBeDefined(); - }); - - test('should be able to instantiate with local storage', async () => { - const window = { - localStorage: { - setItem: vi.fn(), - getItem: vi.fn(), - removeItem: vi.fn(), - clear: vi.fn(), - } as unknown as Storage, - }; - - // #region fuel-options-storage-local - // #import { Fuel, LocalStorage }; - - const sdk = await new Fuel({ - storage: new LocalStorage(window.localStorage), - }).init(); - // #endregion fuel-options-storage-local - - expect(sdk).toBeDefined(); - }); - - test('should be able to instantiate with targetObject', async () => { - const window = {} as unknown as TargetObject; - - // #region fuel-options-target-object - // #import { Fuel, TargetObject }; - - const targetObject: TargetObject = window || document; - - const sdk = await new Fuel({ - targetObject, - }).init(); - // #endregion fuel-options-target-object - - expect(sdk).toBeDefined(); - }); - }); -}); diff --git a/apps/docs-snippets2/src/wallets/encrypting-and-decrypting-json-wallets-two.ts b/apps/docs-snippets2/src/wallets/encrypting-and-decrypting-json-wallets-two.ts new file mode 100644 index 00000000000..65348b9b1ca --- /dev/null +++ b/apps/docs-snippets2/src/wallets/encrypting-and-decrypting-json-wallets-two.ts @@ -0,0 +1,31 @@ +// #region encrypting-and-decrypting-json-wallets-2 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL } from '../env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); + +const newJsonWallet = await Wallet.generate({ + provider, +}).encrypt('my-password'); + +// Load the encrypted wallet from a file +// const jsonWallet = fs.readFileSync('secure-path/my-wallet.json', 'utf-8'); + +// Decrypt the wallet +const newPassword = 'my-password'; +const decryptedWallet = await Wallet.fromEncryptedJson( + newJsonWallet, + newPassword, + provider +); + +// Use the decrypted wallet +const myBalance = await decryptedWallet.getBalance(); +// #endregion encrypting-and-decrypting-json-wallets-2 + +/** + * @group node + */ + +console.log('myBalance', myBalance); diff --git a/apps/docs-snippets2/src/wallets/encrypting-and-decrypting-wallets.ts b/apps/docs-snippets2/src/wallets/encrypting-and-decrypting-wallets.ts new file mode 100644 index 00000000000..a23a47a91ef --- /dev/null +++ b/apps/docs-snippets2/src/wallets/encrypting-and-decrypting-wallets.ts @@ -0,0 +1,22 @@ +// #region encrypting-and-decrypting-json-wallets-1 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL } from '../env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); + +const wallet = Wallet.generate({ provider }); + +// Encrypt the wallet +const password = 'my-password'; +const jsonWallet = await wallet.encrypt(password); + +// Save the encrypted wallet to a file +// e.g. const jsonWallet = fs.writeFileSync('secure-path/my-wallet.json', jsonWallet); +// #endregion encrypting-and-decrypting-json-wallets-1 + +console.log('jsonWallet', jsonWallet); + +/** + * @group node + */ diff --git a/apps/docs-snippets2/src/wallets/fuel-instantiation-one.ts b/apps/docs-snippets2/src/wallets/fuel-instantiation-one.ts new file mode 100644 index 00000000000..dc262a96cfe --- /dev/null +++ b/apps/docs-snippets2/src/wallets/fuel-instantiation-one.ts @@ -0,0 +1,13 @@ +import { Fuel } from 'fuels'; + +// #region fuel-instantiation-1 + +const sdk = new Fuel(); + +/* + Awaits for initialization to mitigate potential race conditions + derived from the async nature of instantiating a connector. +*/ +await sdk.init(); +// #endregion fuel-instantiation-1 +console.log('sdk', sdk); diff --git a/apps/docs-snippets2/src/wallets/fuel-instantiation-options.ts b/apps/docs-snippets2/src/wallets/fuel-instantiation-options.ts new file mode 100644 index 00000000000..bb596c73a5a --- /dev/null +++ b/apps/docs-snippets2/src/wallets/fuel-instantiation-options.ts @@ -0,0 +1,19 @@ +// #region fuel-options-connectors +import { Fuel, FuelConnector } from 'fuels'; + +class WalletConnector extends FuelConnector { + name: string = 'My Wallet Connector'; +} + +const defaultConnectors = (_opts: { + devMode: boolean; +}): Array => [new WalletConnector()]; + +const sdkDevMode = await new Fuel({ + connectors: defaultConnectors({ + devMode: true, + }), +}).init(); + +// #endregion fuel-options-connectors +console.log('sdkDevMode', sdkDevMode); diff --git a/apps/docs-snippets2/src/wallets/fuel-options-storage-local.ts b/apps/docs-snippets2/src/wallets/fuel-options-storage-local.ts new file mode 100644 index 00000000000..a5500d011bb --- /dev/null +++ b/apps/docs-snippets2/src/wallets/fuel-options-storage-local.ts @@ -0,0 +1,17 @@ +// #region fuel-options-storage-local +import { Fuel, LocalStorage } from 'fuels'; + +const window = { + localStorage: { + setItem: vi.fn(), + getItem: vi.fn(), + removeItem: vi.fn(), + clear: vi.fn(), + } as unknown as Storage, +}; + +const sdkWithLocalStorage = await new Fuel({ + storage: new LocalStorage(window.localStorage), +}).init(); +// #endregion fuel-options-storage-local +console.log('sdkWithLocalStorage', sdkWithLocalStorage); diff --git a/apps/docs-snippets2/src/wallets/fuel-options-storage-memory.ts b/apps/docs-snippets2/src/wallets/fuel-options-storage-memory.ts new file mode 100644 index 00000000000..2353241abdf --- /dev/null +++ b/apps/docs-snippets2/src/wallets/fuel-options-storage-memory.ts @@ -0,0 +1,8 @@ +// #region fuel-options-storage-memory +import { Fuel, MemoryStorage } from 'fuels'; + +const sdkWithMemoryStorage = await new Fuel({ + storage: new MemoryStorage(), +}).init(); +// #endregion fuel-options-storage-memory +console.log('sdkWithMemoryStorage', sdkWithMemoryStorage); diff --git a/apps/docs-snippets2/src/wallets/fuel-options-target-object.ts b/apps/docs-snippets2/src/wallets/fuel-options-target-object.ts new file mode 100644 index 00000000000..f4398f48087 --- /dev/null +++ b/apps/docs-snippets2/src/wallets/fuel-options-target-object.ts @@ -0,0 +1,13 @@ +// #region fuel-options-target-object +import { Fuel } from 'fuels'; +import type { TargetObject } from 'fuels'; + +const emptyWindow = {} as unknown as TargetObject; + +const targetObject: TargetObject = emptyWindow || document; + +const sdkWithTargetObject = await new Fuel({ + targetObject, +}).init(); +// #endregion fuel-options-target-object +console.log('sdkWithTargetObject', sdkWithTargetObject); diff --git a/apps/docs-snippets2/src/wallets/locked-to-unlocked.ts b/apps/docs-snippets2/src/wallets/locked-to-unlocked.ts new file mode 100644 index 00000000000..5367244e0cc --- /dev/null +++ b/apps/docs-snippets2/src/wallets/locked-to-unlocked.ts @@ -0,0 +1,17 @@ +// #region wallet-locked-to-unlocked +import type { WalletLocked, WalletUnlocked } from 'fuels'; +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL } from '../env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const wallet: WalletUnlocked = Wallet.generate({ provider }); +const PRIVATE_KEY = wallet.privateKey; + +// Lock an existing wallet +const lockedWallet: WalletLocked = Wallet.fromAddress(wallet.address, provider); + +// Unlock an existing wallet +const someUnlockedWallet: WalletUnlocked = lockedWallet.unlock(PRIVATE_KEY); +// #endregion wallet-locked-to-unlocked +console.log('unlocked wallet address', someUnlockedWallet.address); diff --git a/apps/docs-snippets2/src/wallets/unlocked-to-locked.ts b/apps/docs-snippets2/src/wallets/unlocked-to-locked.ts new file mode 100644 index 00000000000..419ab12d20c --- /dev/null +++ b/apps/docs-snippets2/src/wallets/unlocked-to-locked.ts @@ -0,0 +1,12 @@ +// #region wallet-unlocked-to-locked +import type { WalletUnlocked } from 'fuels'; +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL } from '../env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); + +const unlockedWallet: WalletUnlocked = Wallet.generate({ provider }); +const newlyLockedWallet = unlockedWallet.lock(); +// #endregion wallet-unlocked-to-locked +console.log('newly locked wallet address', newlyLockedWallet.address); diff --git a/apps/docs-snippets2/src/wallets/wallet-optional-provider.ts b/apps/docs-snippets2/src/wallets/wallet-optional-provider.ts new file mode 100644 index 00000000000..fb0928852d3 --- /dev/null +++ b/apps/docs-snippets2/src/wallets/wallet-optional-provider.ts @@ -0,0 +1,20 @@ +// #region wallet-optional-provider +import type { WalletUnlocked } from 'fuels'; +import { Wallet } from 'fuels'; + +// You can create a wallet, without a provider +let unlockedWalletWithoutProvider: WalletUnlocked = Wallet.generate(); +unlockedWalletWithoutProvider = Wallet.fromPrivateKey( + unlockedWalletWithoutProvider.privateKey +); + +// All non-provider dependent methods are available +unlockedWalletWithoutProvider.lock(); + +// All provider dependent methods will throw +try { + await unlockedWalletWithoutProvider.getCoins(); +} catch (e) { + console.log('error', e); +} +// #endregion wallet-optional-provider diff --git a/apps/docs/src/guide/testing/setting-up-test-wallets.md b/apps/docs/src/guide/testing/setting-up-test-wallets.md index 2c44b47ac63..a4c131be4ac 100644 --- a/apps/docs/src/guide/testing/setting-up-test-wallets.md +++ b/apps/docs/src/guide/testing/setting-up-test-wallets.md @@ -4,7 +4,7 @@ You'll often want to create one or more test wallets when testing your contracts ## Create a single wallet -<<< @/../../docs-snippets/src/guide/wallets/access.test.ts#wallets{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/access.ts#wallets{ts:line-numbers} ## Setting up multiple test wallets diff --git a/apps/docs/src/guide/wallets/checking-balances.md b/apps/docs/src/guide/wallets/checking-balances.md index ff112bb7446..fa26d640ed9 100644 --- a/apps/docs/src/guide/wallets/checking-balances.md +++ b/apps/docs/src/guide/wallets/checking-balances.md @@ -2,8 +2,8 @@ To check the balance of a specific asset, you can use [`getBalance`](../../api/Account/Account.md#getbalance) method. This function aggregates the amounts of all unspent coins of the given asset in your wallet. -<<< @/../../docs-snippets/src/guide/wallets/checking-balances.test.ts#checking-balances-1{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/checking-balances.ts#checking-balances-1{ts:line-numbers} To retrieve the balances of all assets in your wallet, use the [`getBalances`](../../api/Account/Account.md#getbalances) method, it returns an array of [`CoinQuantity`](../../api/Account/index.md#coinquantity). This is useful for getting a comprehensive view of your holdings. -<<< @/../../docs-snippets/src/guide/wallets/checking-balances.test.ts#checking-balances-2{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/checking-balances-two.ts#checking-balances-2{ts:line-numbers} diff --git a/apps/docs/src/guide/wallets/connectors.md b/apps/docs/src/guide/wallets/connectors.md index 136f2264c20..552f1d67a4b 100644 --- a/apps/docs/src/guide/wallets/connectors.md +++ b/apps/docs/src/guide/wallets/connectors.md @@ -8,7 +8,7 @@ Fuel Wallet Connectors offer a standardized interface to integrate multiple wall To build your own wallet integration, you can create a custom connector that extends the abstract [`FuelConnector`](../../api/Account/FuelConnector.md) class. This interface provides a set of methods and events that allow you to interact with the wallet and handle various operations such as connecting, disconnecting, signing messages, and sending transactions. -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-extends{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-extends{ts:line-numbers} ### Properties @@ -18,7 +18,7 @@ The `FuelConnector` abstract class provides several properties that should be im The `name` property is simply a `string` on the connector that serves as an identifier and will be displayed to the end-user when selecting a connector. -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-name{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-name{ts:line-numbers} ### `external` The `external` property is simply a `boolean` that indicates when a connector is external or not. @@ -42,17 +42,17 @@ The `install` object requires three properties: - `description` (_required_) - a `string` that will contain a description of the installation process. -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-metadata-install{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-metadata-install{ts:line-numbers} ##### `image` The `metadata.image` property (_optional_) provides an image that will be displayed to the end-user when selecting a connector. The image will be a URL to the image to be displayed (this can be an inline data URI, encoded in base64). -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-metadata-image{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-metadata-image{ts:line-numbers} You can even define a `light` and `dark` theme for the image by providing an object with the `light` and `dark` keys (these will take a similar URI as above). -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-metadata-image-theme{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-metadata-image-theme{ts:line-numbers} ### Events @@ -62,55 +62,55 @@ The `FuelConnector` class provides a number of events that enable developers to The `accounts` event is emitted every time a connector's accounts change. The event data is an array of `string` addresses available on the network. -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-events-accounts{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-events-accounts{ts:line-numbers} #### `connectors` The `connectors` event is emitted when the connectors are initialized. The event data is an array of [`FuelConnector`](../../api/Account/FuelConnector.md) objects available on the network. -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-events-connectors{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-events-connectors{ts:line-numbers} #### `currentConnector` The `currentConnector` event is emitted every time the current connector changes. The event data is a [`FuelConnector`](../../api/Account/FuelConnector.md) object that is currently connected. -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-events-currentConnector{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-events-currentConnector{ts:line-numbers} #### `currentAccount` The `currentAccount` event is emitted every time the current account changes. The event data is a string containing the current account address. -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-events-currentAccount{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-events-currentAccount{ts:line-numbers} #### `connection` The `connection` event is emitted every time the connection status changes. The event data is a `boolean` value that is `true` if the connection is established and `false` otherwise. -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-events-connection{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-events-connection{ts:line-numbers} #### `networks` The `networks` event is emitted every time the network changes. The event data will be a [`Network`](../../api/Account/index.md#network) object containing the current network information. -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-events-networks{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-events-networks{ts:line-numbers} #### `currentNetwork` The `currentNetwork` event is emitted every time the current network changes. The event data will be a [`Network`](../../api/Account/index.md#network) object containing the current network information. -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-events-currentNetwork{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-events-currentNetwork{ts:line-numbers} #### `assets` The `assets` event is emitted every time the assets change. The event data will be an array of [`Asset`](../../api/Account/index.md#asset) objects available on the network. -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-events-assets{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-events-assets{ts:line-numbers} #### `abis` The `abis` event is emitted every time an ABI is added to a connector. The event data will be an array of [`FuelABI`](../../api/Account/index.md#fuelabi) object. -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-connector-events-assets{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/connectors.ts#fuel-connector-events-assets{ts:line-numbers} ### Methods @@ -323,7 +323,7 @@ The TS SDK exports the `Fuel` class, which serves as the connectors manager. Thi It can be instantiated as follows: -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-instantiation-1{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/fuel-instantiation-one.ts#fuel-instantiation-1{ts:line-numbers} > [!NOTE] Note > We recommend initializing the Fuel class with the `init` method to avoid any potential race conditions that may arise from the async nature of instantiating a connector. @@ -340,25 +340,25 @@ Several options can be passed to the `Fuel` connector manager: The `connectors` option provides a list of connectors with which the `Fuel` connector manager can interact. The manager interacts with the connectors, which in turn handle communication with the respective wallet. You can find a list of all the connectors in our [`FuelLabs/fuel-connectors`](https://github.com/FuelLabs/fuel-connectors). -Below, we initialize the manager using the `defaultConnectors` method which provides an array of all the default connectors available in the `fuel-connectors` package. Supplying the `devMode` flag as `true` will enable the development wallet for the connectors (to install visit our [wallet documentation](https://docs.fuel.network/docs/wallet/install/)). +Below, we initialize the manager using the `defaultConnectors` method which provides an array of all the default connectors available in the `fuel-connectors` package. It's being mocked here for the purposes of this example, but you can provide your own custom connectors. Supplying the `devMode` flag as `true` will enable the development wallet for the connectors (to install visit our [wallet documentation](https://docs.fuel.network/docs/wallet/install/)). -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-options-connectors{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/fuel-instantiation-options.ts#fuel-options-connectors{ts:line-numbers} #### `storage` The `storage` is used internally to store the current connector state. It can be overridden by passing an instance that extends the `StorageAbstract` class. -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-options-storage-memory{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/fuel-options-storage-memory.ts#fuel-options-storage-memory{ts:line-numbers} The default behavior will use `LocalStorage` if the `window` is available: -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-options-storage-local{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/fuel-options-storage-local.ts#fuel-options-storage-local{ts:line-numbers} #### `targetObject` The `targetObject` provides a target with which the `Fuel` manager can interact. Used for registering events and can be overridden as follows: -<<< @/../../docs-snippets/src/guide/wallets/connectors.test.ts#fuel-options-target-object{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/fuel-options-target-object.ts#fuel-options-target-object{ts:line-numbers} ### Methods diff --git a/apps/docs/src/guide/wallets/encrypting-and-decrypting.md b/apps/docs/src/guide/wallets/encrypting-and-decrypting.md index 7d793490d9a..3a6992ad955 100644 --- a/apps/docs/src/guide/wallets/encrypting-and-decrypting.md +++ b/apps/docs/src/guide/wallets/encrypting-and-decrypting.md @@ -8,7 +8,7 @@ We will be calling `encrypt` from the [`WalletUnlocked`](../../api/Account/Walle Here is an example of how you can accomplish this: -<<< @/../../docs-snippets/src/guide/wallets/encrypting-and-decrypting-json-wallets.test.ts#encrypting-and-decrypting-json-wallets-1{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/encrypting-and-decrypting-wallets.ts#encrypting-and-decrypting-json-wallets-1{ts:line-numbers} Please note that `encrypt` must be called within an instance of [`WalletUnlocked`](../../api/Account/WalletUnlocked.md). This instance can only be achieved through passing a private key or mnemonic phrase to a locked wallet. @@ -18,10 +18,11 @@ To decrypt the JSON wallet and retrieve your private key, you can call `fromEncr Here is an example: -<<< @/../../docs-snippets/src/guide/wallets/encrypting-and-decrypting-json-wallets.test.ts#encrypting-and-decrypting-json-wallets-2{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/encrypting-and-decrypting-json-wallets-two.ts#encrypting-and-decrypting-json-wallets-2{ts:line-numbers} In this example, `decryptedWallet` is an instance of [`WalletUnlocked`](../../api/Account/WalletUnlocked.md) class, now available for use. ## Important Remember to securely store your encrypted JSON wallet and password. If you lose them, there will be no way to recover your wallet. For security reasons, avoid sharing your private key, encrypted JSON wallet or password with anyone. + diff --git a/apps/docs/src/guide/wallets/locking-and-unlocking.md b/apps/docs/src/guide/wallets/locking-and-unlocking.md index 9be9a63e31b..80a0296f0d0 100644 --- a/apps/docs/src/guide/wallets/locking-and-unlocking.md +++ b/apps/docs/src/guide/wallets/locking-and-unlocking.md @@ -24,23 +24,23 @@ provides greater access via its private key. ## Basic Example -<<< @/../../docs-snippets/src/guide/wallets/access.test.ts#wallets{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/access.ts#wallets{ts:line-numbers} ## Optional Provider You can choose not to pass through a provider argument on `Wallet` construction: -<<< @/../../docs-snippets/src/guide/wallets/access.test.ts#wallet-optional-provider{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/wallet-optional-provider.ts#wallet-optional-provider{ts:line-numbers} ## Transitioning States A [`WalletLocked`](../../api/Account/WalletLocked.md) instance can be unlocked by providing the private key: -<<< @/../../docs-snippets/src/guide/wallets/access.test.ts#wallet-locked-to-unlocked{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/locked-to-unlocked.ts#wallet-locked-to-unlocked{ts:line-numbers} A [`WalletUnlocked`](../../api/Account/WalletUnlocked.md) instance can be locked using the `lock` method: -<<< @/../../docs-snippets/src/guide/wallets/access.test.ts#wallet-unlocked-to-locked{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/unlocked-to-locked.ts#wallet-unlocked-to-locked{ts:line-numbers} Most wallet constructors that create or generate a new wallet are provided on the [`WalletUnlocked`](../../api/Account/WalletUnlocked.md) type. Consider locking the wallet with the `lock` method after the new private @@ -54,3 +54,9 @@ about the kind of access that we require. API developers should aim to minimise their usage of [`WalletUnlocked`](../../api/Account/WalletUnlocked.md) in order to ensure private keys are stored in memory no longer than necessary to reduce the surface area for attacks and vulnerabilities in downstream libraries and applications. + +## Full Example + +For a full example of how to lock and unlock a wallet, see the snippet below: + +<<< @/../../docs-snippets2/src/wallets/access.ts#full{ts:line-numbers} diff --git a/apps/docs/src/guide/wallets/private-keys.md b/apps/docs/src/guide/wallets/private-keys.md index c553b2559bf..c3fa8b8506e 100644 --- a/apps/docs/src/guide/wallets/private-keys.md +++ b/apps/docs/src/guide/wallets/private-keys.md @@ -2,7 +2,7 @@ A new wallet with a randomly generated private key can be created by supplying `Wallet.generate`. -<<< @/../../docs-snippets/src/guide/wallets/access.test.ts#wallets{ts:line-numbers} +<<< @/../../docs-snippets2/src/wallets/access.ts#wallets{ts:line-numbers} Alternatively, you can create a wallet from a Private Key: diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f320ee8a0b4..cd16940106f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -163,7 +163,7 @@ importers: version: 0.1.1 tsup: specifier: ^6.7.0 - version: 6.7.0(@swc/core@1.7.14)(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(typescript@5.6.3) + version: 6.7.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(typescript@5.6.3) tsx: specifier: ^4.19.1 version: 4.19.1 @@ -266,7 +266,7 @@ importers: version: 8.4.47 tailwindcss: specifier: ^3.4.14 - version: 3.4.14(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3)) + version: 3.4.14(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3)) typescript: specifier: ~5.6.3 version: 5.6.3 @@ -363,7 +363,7 @@ importers: version: 18.3.0 eslint-config-react-app: specifier: ^7.0.1 - version: 7.0.1(@babel/plugin-syntax-flow@7.25.7(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.25.7(@babel/core@7.22.5))(eslint@9.9.1(jiti@2.3.3))(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10))(typescript@5.6.3) + version: 7.0.1(@babel/plugin-syntax-flow@7.25.7(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.25.7(@babel/core@7.22.5))(eslint@9.9.1(jiti@2.3.3))(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10))(typescript@5.6.3) fuels: specifier: workspace:* version: link:../../packages/fuels @@ -375,7 +375,7 @@ importers: version: 18.3.1(react@18.3.1) react-scripts: specifier: 5.0.1 - version: 5.0.1(@babel/plugin-syntax-flow@7.25.7(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.25.7(@babel/core@7.22.5))(@swc/core@1.7.14)(@types/babel__core@7.20.5)(bufferutil@4.0.8)(esbuild@0.17.19)(eslint@9.9.1(jiti@2.3.3))(react@18.3.1)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(type-fest@3.1.0)(typescript@5.6.3)(utf-8-validate@5.0.10) + version: 5.0.1(@babel/plugin-syntax-flow@7.25.7(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.25.7(@babel/core@7.22.5))(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/babel__core@7.20.5)(bufferutil@4.0.8)(esbuild@0.17.19)(eslint@9.9.1(jiti@2.3.3))(react@18.3.1)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(type-fest@3.1.0)(typescript@5.6.3)(utf-8-validate@5.0.10) typescript: specifier: ~5.6.3 version: 5.6.3 @@ -496,7 +496,7 @@ importers: version: 6.0.1(jiti@2.3.3)(postcss@8.4.47)(tsx@4.19.1)(yaml@2.6.0) tailwindcss: specifier: ^3.4.14 - version: 3.4.14(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3)) + version: 3.4.14(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3)) typescript: specifier: ~5.6.3 version: 5.6.3 @@ -566,7 +566,7 @@ importers: version: link:../../packages/fuels vitest: specifier: ~2.0.5 - version: 2.0.5(@types/node@22.7.7)(@vitest/browser@2.0.5)(jsdom@16.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.4))(terser@5.36.0) + version: 2.0.5(@types/node@22.7.7)(@vitest/browser@2.0.5)(jsdom@16.7.0(bufferutil@4.0.8)(utf-8-validate@5.0.10))(terser@5.36.0) apps/docs-snippets2: dependencies: @@ -1319,7 +1319,7 @@ importers: version: 8.4.47 tailwindcss: specifier: ^3.4.14 - version: 3.4.14(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3)) + version: 3.4.14(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3)) typescript: specifier: ~5.6.3 version: 5.6.3 @@ -1401,7 +1401,7 @@ importers: version: 8.4.47 tailwindcss: specifier: ^3.4.14 - version: 3.4.14(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.7.7)(typescript@5.6.3)) + version: 3.4.14(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.7.7)(typescript@5.6.3)) typescript: specifier: ~5.6.3 version: 5.6.3 @@ -20432,7 +20432,7 @@ snapshots: jest-util: 28.1.3 slash: 3.0.0 - '@jest/core@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10)': + '@jest/core@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10)': dependencies: '@jest/console': 27.5.1 '@jest/reporters': 27.5.1 @@ -20446,7 +20446,7 @@ snapshots: exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 27.5.1 - jest-config: 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) + jest-config: 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) jest-haste-map: 27.5.1 jest-message-util: 27.5.1 jest-regex-util: 27.5.1 @@ -21299,7 +21299,7 @@ snapshots: dependencies: playwright: 1.47.2 - '@pmmmwh/react-refresh-webpack-plugin@0.5.10(react-refresh@0.11.0)(type-fest@3.1.0)(webpack-dev-server@4.15.1(bufferutil@4.0.8)(utf-8-validate@5.0.10)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)))(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19))': + '@pmmmwh/react-refresh-webpack-plugin@0.5.10(react-refresh@0.11.0)(type-fest@3.1.0)(webpack-dev-server@4.15.1(bufferutil@4.0.8)(utf-8-validate@5.0.10)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)))(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19))': dependencies: ansi-html-community: 0.0.8 common-path-prefix: 3.0.0 @@ -21311,10 +21311,10 @@ snapshots: react-refresh: 0.11.0 schema-utils: 3.3.0 source-map: 0.7.4 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) optionalDependencies: type-fest: 3.1.0 - webpack-dev-server: 4.15.1(bufferutil@4.0.8)(utf-8-validate@5.0.10)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + webpack-dev-server: 4.15.1(bufferutil@4.0.8)(utf-8-validate@5.0.10)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) '@polka/url@1.0.0-next.24': {} @@ -22396,7 +22396,7 @@ snapshots: '@swc/core-win32-x64-msvc@1.7.14': optional: true - '@swc/core@1.7.14': + '@swc/core@1.7.14(@swc/helpers@0.5.12)': dependencies: '@swc/counter': 0.1.3 '@swc/types': 0.1.12 @@ -22411,6 +22411,7 @@ snapshots: '@swc/core-win32-arm64-msvc': 1.7.14 '@swc/core-win32-ia32-msvc': 1.7.14 '@swc/core-win32-x64-msvc': 1.7.14 + '@swc/helpers': 0.5.12 optional: true '@swc/counter@0.1.3': {} @@ -23380,7 +23381,7 @@ snapshots: vite: 5.4.9(@types/node@22.7.7)(terser@5.36.0) vue: 3.5.12(typescript@5.6.3) - '@vitest/browser@2.0.5(bufferutil@4.0.8)(playwright@1.47.2)(typescript@5.6.3)(utf-8-validate@5.0.10)(vitest@2.0.5)(webdriverio@9.0.9(bufferutil@4.0.8)(utf-8-validate@6.0.4))': + '@vitest/browser@2.0.5(bufferutil@4.0.8)(playwright@1.47.2)(typescript@5.6.3)(utf-8-validate@5.0.10)(vitest@2.0.5)(webdriverio@9.0.9(bufferutil@4.0.8)(utf-8-validate@5.0.10))': dependencies: '@testing-library/dom': 10.4.0 '@testing-library/user-event': 14.5.2(@testing-library/dom@10.4.0) @@ -23392,7 +23393,7 @@ snapshots: ws: 8.18.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) optionalDependencies: playwright: 1.47.2 - webdriverio: 9.0.9(bufferutil@4.0.8)(utf-8-validate@6.0.4) + webdriverio: 9.0.9(bufferutil@4.0.8)(utf-8-validate@5.0.10) transitivePeerDependencies: - bufferutil - typescript @@ -23407,7 +23408,7 @@ snapshots: magic-string: 0.30.11 msw: 2.4.7(typescript@5.6.3) sirv: 2.0.4 - vitest: 2.0.5(@types/node@22.7.7)(@vitest/browser@2.0.5)(jsdom@16.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.4))(terser@5.36.0) + vitest: 2.0.5(@types/node@22.5.5)(@vitest/browser@2.0.5)(jsdom@16.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.4))(terser@5.36.0) ws: 8.18.0(bufferutil@4.0.8)(utf-8-validate@6.0.4) optionalDependencies: playwright: 1.47.2 @@ -25366,14 +25367,14 @@ snapshots: transitivePeerDependencies: - supports-color - babel-loader@8.3.0(@babel/core@7.22.5)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + babel-loader@8.3.0(@babel/core@7.22.5)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: '@babel/core': 7.22.5 find-cache-dir: 3.3.2 loader-utils: 2.0.4 make-dir: 3.1.0 schema-utils: 2.7.1 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) babel-plugin-istanbul@6.1.1: dependencies: @@ -26717,7 +26718,7 @@ snapshots: dependencies: hyphenate-style-name: 1.0.4 - css-loader@6.8.1(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + css-loader@6.8.1(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: icss-utils: 5.1.0(postcss@8.4.47) postcss: 8.4.47 @@ -26727,9 +26728,9 @@ snapshots: postcss-modules-values: 4.0.0(postcss@8.4.47) postcss-value-parser: 4.2.0 semver: 7.3.8 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) - css-minimizer-webpack-plugin@3.4.1(esbuild@0.17.19)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + css-minimizer-webpack-plugin@3.4.1(esbuild@0.17.19)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: cssnano: 5.1.15(postcss@8.4.47) jest-worker: 27.5.1 @@ -26737,7 +26738,7 @@ snapshots: schema-utils: 4.2.0 serialize-javascript: 6.0.1 source-map: 0.6.1 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) optionalDependencies: esbuild: 0.17.19 @@ -27825,7 +27826,7 @@ snapshots: dependencies: eslint: 8.57.0 - eslint-config-react-app@7.0.1(@babel/plugin-syntax-flow@7.25.7(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.25.7(@babel/core@7.22.5))(eslint@9.9.1(jiti@2.3.3))(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10))(typescript@5.6.3): + eslint-config-react-app@7.0.1(@babel/plugin-syntax-flow@7.25.7(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.25.7(@babel/core@7.22.5))(eslint@9.9.1(jiti@2.3.3))(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10))(typescript@5.6.3): dependencies: '@babel/core': 7.22.5 '@babel/eslint-parser': 7.22.5(@babel/core@7.22.5)(eslint@9.9.1(jiti@2.3.3)) @@ -27837,7 +27838,7 @@ snapshots: eslint: 9.9.1(jiti@2.3.3) eslint-plugin-flowtype: 8.0.3(@babel/plugin-syntax-flow@7.25.7(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.25.7(@babel/core@7.22.5))(eslint@9.9.1(jiti@2.3.3)) eslint-plugin-import: 2.29.1(@typescript-eslint/parser@5.59.0(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3))(eslint@9.9.1(jiti@2.3.3)) - eslint-plugin-jest: 25.7.0(@typescript-eslint/eslint-plugin@5.59.0(@typescript-eslint/parser@5.59.0(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3))(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3))(eslint@9.9.1(jiti@2.3.3))(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10))(typescript@5.6.3) + eslint-plugin-jest: 25.7.0(@typescript-eslint/eslint-plugin@5.59.0(@typescript-eslint/parser@5.59.0(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3))(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3))(eslint@9.9.1(jiti@2.3.3))(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10))(typescript@5.6.3) eslint-plugin-jsx-a11y: 6.9.0(eslint@9.9.1(jiti@2.3.3)) eslint-plugin-react: 7.35.0(eslint@9.9.1(jiti@2.3.3)) eslint-plugin-react-hooks: 4.6.2(eslint@9.9.1(jiti@2.3.3)) @@ -28004,13 +28005,13 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-plugin-jest@25.7.0(@typescript-eslint/eslint-plugin@5.59.0(@typescript-eslint/parser@5.59.0(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3))(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3))(eslint@9.9.1(jiti@2.3.3))(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10))(typescript@5.6.3): + eslint-plugin-jest@25.7.0(@typescript-eslint/eslint-plugin@5.59.0(@typescript-eslint/parser@5.59.0(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3))(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3))(eslint@9.9.1(jiti@2.3.3))(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10))(typescript@5.6.3): dependencies: '@typescript-eslint/experimental-utils': 5.60.1(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3) eslint: 9.9.1(jiti@2.3.3) optionalDependencies: '@typescript-eslint/eslint-plugin': 5.59.0(@typescript-eslint/parser@5.59.0(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3))(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3) - jest: 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) + jest: 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) transitivePeerDependencies: - supports-color - typescript @@ -28192,7 +28193,7 @@ snapshots: eslint-visitor-keys@4.1.0: {} - eslint-webpack-plugin@3.2.0(eslint@9.9.1(jiti@2.3.3))(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + eslint-webpack-plugin@3.2.0(eslint@9.9.1(jiti@2.3.3))(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: '@types/eslint': 8.40.2 eslint: 9.9.1(jiti@2.3.3) @@ -28200,7 +28201,7 @@ snapshots: micromatch: 4.0.8 normalize-path: 3.0.0 schema-utils: 4.2.0 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) eslint@8.57.0: dependencies: @@ -28659,11 +28660,11 @@ snapshots: dependencies: flat-cache: 4.0.1 - file-loader@6.2.0(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + file-loader@6.2.0(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: loader-utils: 2.0.4 schema-utils: 3.3.0 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) file-uri-to-path@1.0.0: {} @@ -28799,7 +28800,7 @@ snapshots: forever-agent@0.6.1: {} - fork-ts-checker-webpack-plugin@6.5.3(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + fork-ts-checker-webpack-plugin@6.5.3(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: '@babel/code-frame': 7.25.7 '@types/json-schema': 7.0.12 @@ -28815,7 +28816,7 @@ snapshots: semver: 7.6.3 tapable: 1.1.3 typescript: 5.6.3 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) optionalDependencies: eslint: 9.9.1(jiti@2.3.3) @@ -29379,14 +29380,14 @@ snapshots: relateurl: 0.2.7 terser: 5.18.2 - html-webpack-plugin@5.5.3(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + html-webpack-plugin@5.5.3(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: '@types/html-minifier-terser': 6.1.0 html-minifier-terser: 6.1.0 lodash: 4.17.21 pretty-error: 4.0.0 tapable: 2.2.1 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) htmlescape@1.1.1: {} @@ -30123,16 +30124,16 @@ snapshots: transitivePeerDependencies: - supports-color - jest-cli@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10): + jest-cli@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10): dependencies: - '@jest/core': 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) + '@jest/core': 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 import-local: 3.1.0 - jest-config: 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) + jest-config: 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) jest-util: 27.5.1 jest-validate: 27.5.1 prompts: 2.4.2 @@ -30144,7 +30145,7 @@ snapshots: - ts-node - utf-8-validate - jest-config@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10): + jest-config@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10): dependencies: '@babel/core': 7.25.8 '@jest/test-sequencer': 27.5.1 @@ -30171,7 +30172,7 @@ snapshots: slash: 3.0.0 strip-json-comments: 3.1.1 optionalDependencies: - ts-node: 10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3) + ts-node: 10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3) transitivePeerDependencies: - bufferutil - canvas @@ -30508,11 +30509,11 @@ snapshots: leven: 3.1.0 pretty-format: 29.7.0 - jest-watch-typeahead@1.1.0(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10)): + jest-watch-typeahead@1.1.0(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10)): dependencies: ansi-escapes: 4.3.2 chalk: 4.1.2 - jest: 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) + jest: 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) jest-regex-util: 28.0.2 jest-watcher: 28.1.3 slash: 4.0.0 @@ -30565,11 +30566,11 @@ snapshots: merge-stream: 2.0.0 supports-color: 8.1.1 - jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10): + jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10): dependencies: - '@jest/core': 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) + '@jest/core': 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) import-local: 3.1.0 - jest-cli: 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) + jest-cli: 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) transitivePeerDependencies: - bufferutil - canvas @@ -31630,10 +31631,10 @@ snapshots: mimic-response@1.0.1: {} - mini-css-extract-plugin@2.7.6(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + mini-css-extract-plugin@2.7.6(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: schema-utils: 4.2.0 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) minify-stream@2.1.0: dependencies: @@ -32891,29 +32892,29 @@ snapshots: postcss: 8.4.47 postcss-value-parser: 4.2.0 - postcss-load-config@3.1.4(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3)): + postcss-load-config@3.1.4(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3)): dependencies: lilconfig: 2.1.0 yaml: 1.10.2 optionalDependencies: postcss: 8.4.47 - ts-node: 10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3) + ts-node: 10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3) - postcss-load-config@4.0.1(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3)): + postcss-load-config@4.0.1(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3)): dependencies: lilconfig: 2.1.0 yaml: 2.6.0 optionalDependencies: postcss: 8.4.47 - ts-node: 10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3) + ts-node: 10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3) - postcss-load-config@4.0.1(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.7.7)(typescript@5.6.3)): + postcss-load-config@4.0.1(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.7.7)(typescript@5.6.3)): dependencies: lilconfig: 2.1.0 yaml: 2.6.0 optionalDependencies: postcss: 8.4.47 - ts-node: 10.9.1(@swc/core@1.7.14)(@types/node@22.7.7)(typescript@5.6.3) + ts-node: 10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.7.7)(typescript@5.6.3) postcss-load-config@6.0.1(jiti@2.3.3)(postcss@8.4.47)(tsx@4.19.1)(yaml@2.6.0): dependencies: @@ -32924,13 +32925,13 @@ snapshots: tsx: 4.19.1 yaml: 2.6.0 - postcss-loader@6.2.1(postcss@8.4.47)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + postcss-loader@6.2.1(postcss@8.4.47)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: cosmiconfig: 7.1.0 klona: 2.0.6 postcss: 8.4.47 semver: 7.3.8 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) postcss-logical@5.0.4(postcss@8.4.47): dependencies: @@ -33493,7 +33494,7 @@ snapshots: regenerator-runtime: 0.13.11 whatwg-fetch: 3.6.2 - react-dev-utils@12.0.1(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + react-dev-utils@12.0.1(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: '@babel/code-frame': 7.22.5 address: 1.2.2 @@ -33504,7 +33505,7 @@ snapshots: escape-string-regexp: 4.0.0 filesize: 8.0.7 find-up: 5.0.0 - fork-ts-checker-webpack-plugin: 6.5.3(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + fork-ts-checker-webpack-plugin: 6.5.3(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) global-modules: 2.0.0 globby: 11.1.0 gzip-size: 6.0.0 @@ -33519,7 +33520,7 @@ snapshots: shell-quote: 1.8.1 strip-ansi: 6.0.1 text-table: 0.2.0 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) optionalDependencies: typescript: 5.6.3 transitivePeerDependencies: @@ -33686,56 +33687,56 @@ snapshots: optionalDependencies: '@types/react': 18.3.1 - react-scripts@5.0.1(@babel/plugin-syntax-flow@7.25.7(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.25.7(@babel/core@7.22.5))(@swc/core@1.7.14)(@types/babel__core@7.20.5)(bufferutil@4.0.8)(esbuild@0.17.19)(eslint@9.9.1(jiti@2.3.3))(react@18.3.1)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(type-fest@3.1.0)(typescript@5.6.3)(utf-8-validate@5.0.10): + react-scripts@5.0.1(@babel/plugin-syntax-flow@7.25.7(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.25.7(@babel/core@7.22.5))(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/babel__core@7.20.5)(bufferutil@4.0.8)(esbuild@0.17.19)(eslint@9.9.1(jiti@2.3.3))(react@18.3.1)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(type-fest@3.1.0)(typescript@5.6.3)(utf-8-validate@5.0.10): dependencies: '@babel/core': 7.22.5 - '@pmmmwh/react-refresh-webpack-plugin': 0.5.10(react-refresh@0.11.0)(type-fest@3.1.0)(webpack-dev-server@4.15.1(bufferutil@4.0.8)(utf-8-validate@5.0.10)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)))(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + '@pmmmwh/react-refresh-webpack-plugin': 0.5.10(react-refresh@0.11.0)(type-fest@3.1.0)(webpack-dev-server@4.15.1(bufferutil@4.0.8)(utf-8-validate@5.0.10)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)))(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) '@svgr/webpack': 5.5.0 babel-jest: 27.5.1(@babel/core@7.22.5) - babel-loader: 8.3.0(@babel/core@7.22.5)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + babel-loader: 8.3.0(@babel/core@7.22.5)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) babel-plugin-named-asset-import: 0.3.8(@babel/core@7.22.5) babel-preset-react-app: 10.0.1 bfj: 7.0.2 browserslist: 4.21.9 camelcase: 6.3.0 case-sensitive-paths-webpack-plugin: 2.4.0 - css-loader: 6.8.1(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) - css-minimizer-webpack-plugin: 3.4.1(esbuild@0.17.19)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + css-loader: 6.8.1(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) + css-minimizer-webpack-plugin: 3.4.1(esbuild@0.17.19)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) dotenv: 10.0.0 dotenv-expand: 5.1.0 eslint: 9.9.1(jiti@2.3.3) - eslint-config-react-app: 7.0.1(@babel/plugin-syntax-flow@7.25.7(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.25.7(@babel/core@7.22.5))(eslint@9.9.1(jiti@2.3.3))(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10))(typescript@5.6.3) - eslint-webpack-plugin: 3.2.0(eslint@9.9.1(jiti@2.3.3))(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) - file-loader: 6.2.0(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + eslint-config-react-app: 7.0.1(@babel/plugin-syntax-flow@7.25.7(@babel/core@7.22.5))(@babel/plugin-transform-react-jsx@7.25.7(@babel/core@7.22.5))(eslint@9.9.1(jiti@2.3.3))(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10))(typescript@5.6.3) + eslint-webpack-plugin: 3.2.0(eslint@9.9.1(jiti@2.3.3))(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) + file-loader: 6.2.0(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) fs-extra: 10.1.0 - html-webpack-plugin: 5.5.3(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + html-webpack-plugin: 5.5.3(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) identity-obj-proxy: 3.0.0 - jest: 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) + jest: 27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10) jest-resolve: 27.5.1 - jest-watch-typeahead: 1.1.0(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10)) - mini-css-extract-plugin: 2.7.6(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + jest-watch-typeahead: 1.1.0(jest@27.5.1(bufferutil@4.0.8)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(utf-8-validate@5.0.10)) + mini-css-extract-plugin: 2.7.6(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) postcss: 8.4.47 postcss-flexbugs-fixes: 5.0.2(postcss@8.4.47) - postcss-loader: 6.2.1(postcss@8.4.47)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + postcss-loader: 6.2.1(postcss@8.4.47)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) postcss-normalize: 10.0.1(browserslist@4.21.9)(postcss@8.4.47) postcss-preset-env: 7.8.3(postcss@8.4.47) prompts: 2.4.2 react: 18.3.1 react-app-polyfill: 3.0.0 - react-dev-utils: 12.0.1(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + react-dev-utils: 12.0.1(eslint@9.9.1(jiti@2.3.3))(typescript@5.6.3)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) react-refresh: 0.11.0 resolve: 1.22.2 resolve-url-loader: 4.0.0 - sass-loader: 12.6.0(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + sass-loader: 12.6.0(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) semver: 7.3.8 - source-map-loader: 3.0.2(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) - style-loader: 3.3.3(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) - tailwindcss: 3.4.14(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3)) - terser-webpack-plugin: 5.3.9(@swc/core@1.7.14)(esbuild@0.17.19)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) - webpack-dev-server: 4.15.1(bufferutil@4.0.8)(utf-8-validate@5.0.10)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) - webpack-manifest-plugin: 4.1.1(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) - workbox-webpack-plugin: 6.6.0(@types/babel__core@7.20.5)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + source-map-loader: 3.0.2(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) + style-loader: 3.3.3(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) + tailwindcss: 3.4.14(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3)) + terser-webpack-plugin: 5.3.9(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) + webpack-dev-server: 4.15.1(bufferutil@4.0.8)(utf-8-validate@5.0.10)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) + webpack-manifest-plugin: 4.1.1(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) + workbox-webpack-plugin: 6.6.0(@types/babel__core@7.20.5)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) optionalDependencies: fsevents: 2.3.3 typescript: 5.6.3 @@ -34284,11 +34285,11 @@ snapshots: sanitize.css@13.0.0: {} - sass-loader@12.6.0(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + sass-loader@12.6.0(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: klona: 2.0.6 neo-async: 2.6.2 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) sax@1.2.4: {} @@ -34667,12 +34668,12 @@ snapshots: source-map-js@1.2.1: {} - source-map-loader@3.0.2(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + source-map-loader@3.0.2(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: abab: 2.0.6 iconv-lite: 0.6.3 source-map-js: 1.2.1 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) source-map-support@0.5.21: dependencies: @@ -35063,9 +35064,9 @@ snapshots: dependencies: boundary: 2.0.0 - style-loader@3.3.3(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + style-loader@3.3.3(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) styled-jsx@5.1.1(@babel/core@7.25.8)(react@18.3.1): dependencies: @@ -35208,7 +35209,7 @@ snapshots: tachyons@4.12.0: {} - tailwindcss@3.4.14(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3)): + tailwindcss@3.4.14(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3)): dependencies: '@alloc/quick-lru': 5.2.0 arg: 5.0.2 @@ -35227,7 +35228,7 @@ snapshots: postcss: 8.4.47 postcss-import: 15.1.0(postcss@8.4.47) postcss-js: 4.0.1(postcss@8.4.47) - postcss-load-config: 4.0.1(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3)) + postcss-load-config: 4.0.1(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3)) postcss-nested: 6.0.1(postcss@8.4.47) postcss-selector-parser: 6.0.13 resolve: 1.22.8 @@ -35235,7 +35236,7 @@ snapshots: transitivePeerDependencies: - ts-node - tailwindcss@3.4.14(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.7.7)(typescript@5.6.3)): + tailwindcss@3.4.14(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.7.7)(typescript@5.6.3)): dependencies: '@alloc/quick-lru': 5.2.0 arg: 5.0.2 @@ -35254,7 +35255,7 @@ snapshots: postcss: 8.4.47 postcss-import: 15.1.0(postcss@8.4.47) postcss-js: 4.0.1(postcss@8.4.47) - postcss-load-config: 4.0.1(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.7.7)(typescript@5.6.3)) + postcss-load-config: 4.0.1(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.7.7)(typescript@5.6.3)) postcss-nested: 6.0.1(postcss@8.4.47) postcss-selector-parser: 6.0.13 resolve: 1.22.8 @@ -35300,16 +35301,16 @@ snapshots: ansi-escapes: 4.3.2 supports-hyperlinks: 2.3.0 - terser-webpack-plugin@5.3.9(@swc/core@1.7.14)(esbuild@0.17.19)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + terser-webpack-plugin@5.3.9(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 schema-utils: 3.3.0 serialize-javascript: 6.0.1 terser: 5.34.1 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) optionalDependencies: - '@swc/core': 1.7.14 + '@swc/core': 1.7.14(@swc/helpers@0.5.12) esbuild: 0.17.19 terser@4.8.1: @@ -35586,7 +35587,7 @@ snapshots: ts-log@2.2.5: {} - ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3): + ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.11 @@ -35604,10 +35605,10 @@ snapshots: v8-compile-cache-lib: 3.0.1 yn: 3.1.1 optionalDependencies: - '@swc/core': 1.7.14 + '@swc/core': 1.7.14(@swc/helpers@0.5.12) optional: true - ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.7.7)(typescript@5.6.3): + ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.7.7)(typescript@5.6.3): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.11 @@ -35625,7 +35626,7 @@ snapshots: v8-compile-cache-lib: 3.0.1 yn: 3.1.1 optionalDependencies: - '@swc/core': 1.7.14 + '@swc/core': 1.7.14(@swc/helpers@0.5.12) optional: true ts-toolbelt@9.6.0: {} @@ -35649,7 +35650,7 @@ snapshots: tslib@2.8.0: {} - tsup@6.7.0(@swc/core@1.7.14)(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3))(typescript@5.6.3): + tsup@6.7.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3))(typescript@5.6.3): dependencies: bundle-require: 4.0.1(esbuild@0.17.19) cac: 6.7.14 @@ -35659,14 +35660,14 @@ snapshots: execa: 5.1.1 globby: 11.1.0 joycon: 3.1.1 - postcss-load-config: 3.1.4(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14)(@types/node@22.5.5)(typescript@5.6.3)) + postcss-load-config: 3.1.4(postcss@8.4.47)(ts-node@10.9.1(@swc/core@1.7.14(@swc/helpers@0.5.12))(@types/node@22.5.5)(typescript@5.6.3)) resolve-from: 5.0.0 rollup: 3.25.3 source-map: 0.8.0-beta.0 sucrase: 3.32.0 tree-kill: 1.2.2 optionalDependencies: - '@swc/core': 1.7.14 + '@swc/core': 1.7.14(@swc/helpers@0.5.12) postcss: 8.4.47 typescript: 5.6.3 transitivePeerDependencies: @@ -36374,7 +36375,7 @@ snapshots: why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 22.5.5 - '@vitest/browser': 2.0.5(bufferutil@4.0.8)(playwright@1.47.2)(typescript@5.6.3)(utf-8-validate@5.0.10)(vitest@2.0.5)(webdriverio@9.0.9(bufferutil@4.0.8)(utf-8-validate@6.0.4)) + '@vitest/browser': 2.0.5(bufferutil@4.0.8)(playwright@1.47.2)(typescript@5.6.3)(utf-8-validate@5.0.10)(vitest@2.0.5)(webdriverio@9.0.9(bufferutil@4.0.8)(utf-8-validate@5.0.10)) jsdom: 16.7.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) transitivePeerDependencies: - less @@ -36444,7 +36445,7 @@ snapshots: why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 22.7.7 - '@vitest/browser': 2.0.5(bufferutil@4.0.8)(playwright@1.47.2)(typescript@5.6.3)(utf-8-validate@5.0.10)(vitest@2.0.5)(webdriverio@9.0.9(bufferutil@4.0.8)(utf-8-validate@6.0.4)) + '@vitest/browser': 2.0.5(bufferutil@4.0.8)(playwright@1.47.2)(typescript@5.6.3)(utf-8-validate@5.0.10)(vitest@2.0.5)(webdriverio@9.0.9(bufferutil@4.0.8)(utf-8-validate@5.0.10)) jsdom: 16.7.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) transitivePeerDependencies: - less @@ -36456,41 +36457,6 @@ snapshots: - supports-color - terser - vitest@2.0.5(@types/node@22.7.7)(@vitest/browser@2.0.5)(jsdom@16.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.4))(terser@5.36.0): - dependencies: - '@ampproject/remapping': 2.3.0 - '@vitest/expect': 2.0.5 - '@vitest/pretty-format': 2.1.1 - '@vitest/runner': 2.0.5 - '@vitest/snapshot': 2.0.5 - '@vitest/spy': 2.0.5 - '@vitest/utils': 2.0.5 - chai: 5.1.1 - debug: 4.3.7(supports-color@5.5.0) - execa: 8.0.1 - magic-string: 0.30.11 - pathe: 1.1.2 - std-env: 3.7.0 - tinybench: 2.9.0 - tinypool: 1.0.1 - tinyrainbow: 1.2.0 - vite: 5.4.9(@types/node@22.7.7)(terser@5.36.0) - vite-node: 2.0.5(@types/node@22.7.7)(terser@5.36.0) - why-is-node-running: 2.3.0 - optionalDependencies: - '@types/node': 22.7.7 - '@vitest/browser': 2.0.5(bufferutil@4.0.8)(playwright@1.47.2)(typescript@5.6.3)(utf-8-validate@6.0.4)(vitest@2.0.5)(webdriverio@9.0.9(bufferutil@4.0.8)(utf-8-validate@6.0.4)) - jsdom: 16.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.4) - transitivePeerDependencies: - - less - - lightningcss - - sass - - sass-embedded - - stylus - - sugarss - - supports-color - - terser - vlq@1.0.1: {} vm-browserify@1.1.2: {} @@ -36551,6 +36517,23 @@ snapshots: '@noble/curves': 1.6.0 '@noble/hashes': 1.5.0 + webdriver@9.0.8(bufferutil@4.0.8)(utf-8-validate@5.0.10): + dependencies: + '@types/node': 20.14.15 + '@types/ws': 8.5.12 + '@wdio/config': 9.0.8 + '@wdio/logger': 9.0.8 + '@wdio/protocols': 9.0.8 + '@wdio/types': 9.0.8 + '@wdio/utils': 9.0.8 + deepmerge-ts: 7.1.0 + ws: 8.18.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + optional: true + webdriver@9.0.8(bufferutil@4.0.8)(utf-8-validate@6.0.4): dependencies: '@types/node': 20.14.15 @@ -36567,6 +36550,41 @@ snapshots: - supports-color - utf-8-validate + webdriverio@9.0.9(bufferutil@4.0.8)(utf-8-validate@5.0.10): + dependencies: + '@types/node': 20.14.15 + '@types/sinonjs__fake-timers': 8.1.5 + '@wdio/config': 9.0.8 + '@wdio/logger': 9.0.8 + '@wdio/protocols': 9.0.8 + '@wdio/repl': 9.0.8 + '@wdio/types': 9.0.8 + '@wdio/utils': 9.0.8 + archiver: 7.0.1 + aria-query: 5.3.0 + cheerio: 1.0.0 + css-shorthand-properties: 1.1.1 + css-value: 0.0.1 + grapheme-splitter: 1.0.4 + htmlfy: 0.2.1 + import-meta-resolve: 4.1.0 + is-plain-obj: 4.1.0 + jszip: 3.10.1 + lodash.clonedeep: 4.5.0 + lodash.zip: 4.2.0 + minimatch: 9.0.5 + query-selector-shadow-dom: 1.0.1 + resq: 1.11.0 + rgb2hex: 0.2.5 + serialize-error: 11.0.3 + urlpattern-polyfill: 10.0.0 + webdriver: 9.0.8(bufferutil@4.0.8)(utf-8-validate@5.0.10) + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + optional: true + webdriverio@9.0.9(bufferutil@4.0.8)(utf-8-validate@6.0.4): dependencies: '@types/node': 20.14.15 @@ -36613,16 +36631,16 @@ snapshots: webidl-conversions@6.1.0: {} - webpack-dev-middleware@5.3.3(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + webpack-dev-middleware@5.3.3(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: colorette: 2.0.20 memfs: 3.5.3 mime-types: 2.1.35 range-parser: 1.2.1 schema-utils: 4.2.0 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) - webpack-dev-server@4.15.1(bufferutil@4.0.8)(utf-8-validate@5.0.10)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + webpack-dev-server@4.15.1(bufferutil@4.0.8)(utf-8-validate@5.0.10)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: '@types/bonjour': 3.5.10 '@types/connect-history-api-fallback': 1.5.0 @@ -36652,20 +36670,20 @@ snapshots: serve-index: 1.9.1 sockjs: 0.3.24 spdy: 4.0.2 - webpack-dev-middleware: 5.3.3(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + webpack-dev-middleware: 5.3.3(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) ws: 8.18.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) optionalDependencies: - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) transitivePeerDependencies: - bufferutil - debug - supports-color - utf-8-validate - webpack-manifest-plugin@4.1.1(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + webpack-manifest-plugin@4.1.1(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: tapable: 2.2.1 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) webpack-sources: 2.3.1 webpack-sources@1.4.3: @@ -36682,7 +36700,7 @@ snapshots: webpack-virtual-modules@0.6.2: {} - webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19): + webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19): dependencies: '@types/eslint-scope': 3.7.4 '@types/estree': 1.0.5 @@ -36705,7 +36723,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.9(@swc/core@1.7.14)(esbuild@0.17.19)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)) + terser-webpack-plugin: 5.3.9(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)) watchpack: 2.4.0 webpack-sources: 3.2.3 transitivePeerDependencies: @@ -36931,12 +36949,12 @@ snapshots: workbox-sw@6.6.0: {} - workbox-webpack-plugin@6.6.0(@types/babel__core@7.20.5)(webpack@5.88.0(@swc/core@1.7.14)(esbuild@0.17.19)): + workbox-webpack-plugin@6.6.0(@types/babel__core@7.20.5)(webpack@5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19)): dependencies: fast-json-stable-stringify: 2.1.0 pretty-bytes: 5.6.0 upath: 1.2.0 - webpack: 5.88.0(@swc/core@1.7.14)(esbuild@0.17.19) + webpack: 5.88.0(@swc/core@1.7.14(@swc/helpers@0.5.12))(esbuild@0.17.19) webpack-sources: 1.4.3 workbox-build: 6.6.0(@types/babel__core@7.20.5) transitivePeerDependencies: From f607ba2c7639de4a62bdd445a6953b0b60b2a4bc Mon Sep 17 00:00:00 2001 From: Chad Nehemiah Date: Tue, 12 Nov 2024 21:46:18 -0500 Subject: [PATCH 4/6] fix!: remove unnecessary nonce from message gql queries (#3298) --- .changeset/chatty-camels-wave.md | 5 +++++ packages/account/src/providers/operations.graphql | 9 ++++++--- packages/account/src/providers/provider.ts | 4 ++-- packages/account/test/fixtures/messageProof.ts | 3 +-- 4 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 .changeset/chatty-camels-wave.md diff --git a/.changeset/chatty-camels-wave.md b/.changeset/chatty-camels-wave.md new file mode 100644 index 00000000000..cf8cb8f06f7 --- /dev/null +++ b/.changeset/chatty-camels-wave.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/account": minor +--- + +fix!: remove unnecessary nonce from message gql queries \ No newline at end of file diff --git a/packages/account/src/providers/operations.graphql b/packages/account/src/providers/operations.graphql index a4cbed37adb..a92ef5ff8a0 100644 --- a/packages/account/src/providers/operations.graphql +++ b/packages/account/src/providers/operations.graphql @@ -265,10 +265,14 @@ fragment messageFragment on Message { sender recipient data - nonce daHeight } +fragment getMessageFragment on Message { + ...messageFragment + nonce +} + fragment messageProofFragment on MessageProof { messageProof { proofSet @@ -312,7 +316,6 @@ fragment messageProofFragment on MessageProof { } sender recipient - nonce amount data } @@ -698,7 +701,7 @@ query getMessages( } edges { node { - ...messageFragment + ...getMessageFragment } } } diff --git a/packages/account/src/providers/provider.ts b/packages/account/src/providers/provider.ts index c143a3bbee5..9fbc5bfcc48 100644 --- a/packages/account/src/providers/provider.ts +++ b/packages/account/src/providers/provider.ts @@ -2068,13 +2068,13 @@ Supported fuel-core version: ${supportedVersion}.` messageId: InputMessageCoder.getMessageId({ sender: rawMessage.sender, recipient: rawMessage.recipient, - nonce: rawMessage.nonce, + nonce, amount: bn(rawMessage.amount), data: rawMessage.data, }), sender: Address.fromAddressOrString(rawMessage.sender), recipient: Address.fromAddressOrString(rawMessage.recipient), - nonce: rawMessage.nonce, + nonce, amount: bn(rawMessage.amount), data: InputMessageCoder.decodeData(rawMessage.data), daHeight: bn(rawMessage.daHeight), diff --git a/packages/account/test/fixtures/messageProof.ts b/packages/account/test/fixtures/messageProof.ts index 4d08d5ca574..6221d9c47f0 100644 --- a/packages/account/test/fixtures/messageProof.ts +++ b/packages/account/test/fixtures/messageProof.ts @@ -56,7 +56,6 @@ export const MESSAGE_PROOF_RAW_RESPONSE: GqlGetMessageProofQuery['messageProof'] }, sender: '0x79c54219a5c910979e5e4c2728df163fa654a1fe03843e6af59daa2c3fcd42ea', recipient: '0x00000000000000000000000047ba61eec8e5e65247d717ff236f504cf3b0a263', - nonce: '0x3e87e0f44613cabecd1aad381ad41a433afb12ec5c54c172de3db25b1b4d1b53', amount: '10', data: '0x', }; @@ -110,7 +109,7 @@ export const MESSAGE_PROOF: MessageProof = { }, sender: Address.fromAddressOrString(MESSAGE_PROOF_RAW_RESPONSE.sender), recipient: Address.fromAddressOrString(MESSAGE_PROOF_RAW_RESPONSE.recipient), - nonce: MESSAGE_PROOF_RAW_RESPONSE.nonce, + nonce: '0xb33895e6fdf23b5a62c92a1d45c71a11579027f9e5c4dda73c26cf140bcd6895', amount: bn(MESSAGE_PROOF_RAW_RESPONSE.amount), data: MESSAGE_PROOF_RAW_RESPONSE.data, }; From 174876c65bdc1e09b7a0091709e560636d1d218a Mon Sep 17 00:00:00 2001 From: Chad Nehemiah Date: Tue, 12 Nov 2024 22:12:08 -0500 Subject: [PATCH 5/6] chore!: optimize coin gql queries (#3301) --- .changeset/young-steaks-brake.md | 5 +++++ packages/account/src/providers/operations.graphql | 2 +- packages/account/src/providers/provider.ts | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/young-steaks-brake.md diff --git a/.changeset/young-steaks-brake.md b/.changeset/young-steaks-brake.md new file mode 100644 index 00000000000..34c0c351b5e --- /dev/null +++ b/.changeset/young-steaks-brake.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/account": minor +--- + +chore!: optimize coin gql queries diff --git a/packages/account/src/providers/operations.graphql b/packages/account/src/providers/operations.graphql index a92ef5ff8a0..3dd5c17dece 100644 --- a/packages/account/src/providers/operations.graphql +++ b/packages/account/src/providers/operations.graphql @@ -243,7 +243,6 @@ fragment blockFragment on Block { fragment coinFragment on Coin { type: __typename utxoId - owner amount assetId blockCreated @@ -582,6 +581,7 @@ query getBlocks($after: String, $before: String, $first: Int, $last: Int) { query getCoin($coinId: UtxoId!) { coin(utxoId: $coinId) { ...coinFragment + owner } } diff --git a/packages/account/src/providers/provider.ts b/packages/account/src/providers/provider.ts index 9fbc5bfcc48..6eabf92c7e1 100644 --- a/packages/account/src/providers/provider.ts +++ b/packages/account/src/providers/provider.ts @@ -1418,7 +1418,7 @@ Supported fuel-core version: ${supportedVersion}.` id: node.utxoId, assetId: node.assetId, amount: bn(node.amount), - owner: Address.fromAddressOrString(node.owner), + owner: ownerAddress, blockCreated: bn(node.blockCreated), txCreatedIdx: bn(node.txCreatedIdx), })); @@ -1486,7 +1486,7 @@ Supported fuel-core version: ${supportedVersion}.` id: coin.utxoId, amount: bn(coin.amount), assetId: coin.assetId, - owner: Address.fromAddressOrString(coin.owner), + owner: ownerAddress, blockCreated: bn(coin.blockCreated), txCreatedIdx: bn(coin.txCreatedIdx), } as Coin; From 74112cc825e0f915db8498ce5dd19dbcaf105200 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Wed, 13 Nov 2024 05:05:09 +0000 Subject: [PATCH 6/6] docs: migrate other half of contract snippets (#3377) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: migrated contract methods * docs: migrated contract `minted-token-asset-id` * docs: migrated contract `multi-call` * docs: fixed utilities * docs: migrated `storageSlots` * docs: migrated `add-transfer` * docs: migrated `understanding-the-fuelvm-binary-file` * docs: migrated `using-different-wallets` * docs: migrated `variable-outputs` * docs: removed `add-transfer.test.ts` * docs: lintfix * chore: removed duplicate Sway project --------- Co-authored-by: Nedim Salkić --- .../src/guide/contracts/add-transfer.test.ts | 83 ----------- .../interacting-with-contracts.test.ts | 129 ---------------- .../contracts/is-function-readonly.test.ts | 35 ----- .../contracts/minted-token-asset-id.test.ts | 59 -------- .../src/guide/contracts/multicalls.test.ts | 141 ------------------ .../guide/contracts/variable-outputs.test.ts | 45 ------ .../forc-projects/echo-values/src/main.sw | 2 - .../fixtures/forc-projects/token/src/main.sw | 3 +- .../src/contracts/methods/call.ts | 19 +++ .../src/contracts/methods/dry-run.ts | 17 +++ .../src/contracts/methods/get.ts | 18 +++ .../src/contracts/methods/is-read-only.ts | 26 ++++ .../src/contracts/methods/simulate.ts | 17 +++ .../different-contracts-chain-methods.ts | 31 ++++ .../different-contracts-readonly.ts | 31 ++++ .../multi-call/different-contracts.ts | 31 ++++ .../src/contracts/multi-call/same-contract.ts | 29 ++++ .../override-storage-slots-inline.ts | 43 ++++++ .../storage-slots/override-storage-slots.ts | 25 ++++ .../add-transfer-multiple-recipients.ts | 47 ++++++ .../add-transfer-single-recipient.ts | 31 ++++ .../contracts/utilities/create-asset-id.ts | 19 +++ .../utilities/minted-token-asset-id.ts | 32 ++++ .../utilities/using-different-wallet.ts | 21 +++ .../contracts/utilities/variable-outputs.ts | 35 +++++ apps/docs-snippets2/sway/Forc.toml | 18 ++- .../sway/storage-test-contract/Forc.toml | 6 + .../sway/storage-test-contract/src/main.sw | 95 ++++++++++++ apps/docs-snippets2/sway/token/Forc.toml | 7 + apps/docs-snippets2/sway/token/src/main.sw | 31 ++++ apps/docs/src/guide/contracts/methods.md | 10 +- .../guide/contracts/minted-token-asset-id.md | 6 +- .../guide/contracts/multi-contract-calls.md | 8 +- .../docs/src/guide/contracts/storage-slots.md | 4 +- .../guide/contracts/transferring-assets.md | 4 +- .../understanding-the-fuelvm-binary-file.md | 2 +- .../contracts/using-different-wallets.md | 2 +- .../src/guide/contracts/variable-outputs.md | 4 +- .../src/storage-test-contract.test.ts | 7 +- 39 files changed, 643 insertions(+), 530 deletions(-) delete mode 100644 apps/docs-snippets/src/guide/contracts/add-transfer.test.ts delete mode 100644 apps/docs-snippets/src/guide/contracts/interacting-with-contracts.test.ts delete mode 100644 apps/docs-snippets/src/guide/contracts/is-function-readonly.test.ts delete mode 100644 apps/docs-snippets/src/guide/contracts/minted-token-asset-id.test.ts delete mode 100644 apps/docs-snippets/src/guide/contracts/multicalls.test.ts delete mode 100644 apps/docs-snippets/src/guide/contracts/variable-outputs.test.ts create mode 100644 apps/docs-snippets2/src/contracts/methods/call.ts create mode 100644 apps/docs-snippets2/src/contracts/methods/dry-run.ts create mode 100644 apps/docs-snippets2/src/contracts/methods/get.ts create mode 100644 apps/docs-snippets2/src/contracts/methods/is-read-only.ts create mode 100644 apps/docs-snippets2/src/contracts/methods/simulate.ts create mode 100644 apps/docs-snippets2/src/contracts/multi-call/different-contracts-chain-methods.ts create mode 100644 apps/docs-snippets2/src/contracts/multi-call/different-contracts-readonly.ts create mode 100644 apps/docs-snippets2/src/contracts/multi-call/different-contracts.ts create mode 100644 apps/docs-snippets2/src/contracts/multi-call/same-contract.ts create mode 100644 apps/docs-snippets2/src/contracts/storage-slots/override-storage-slots-inline.ts create mode 100644 apps/docs-snippets2/src/contracts/storage-slots/override-storage-slots.ts create mode 100644 apps/docs-snippets2/src/contracts/utilities/add-transfer-multiple-recipients.ts create mode 100644 apps/docs-snippets2/src/contracts/utilities/add-transfer-single-recipient.ts create mode 100644 apps/docs-snippets2/src/contracts/utilities/create-asset-id.ts create mode 100644 apps/docs-snippets2/src/contracts/utilities/minted-token-asset-id.ts create mode 100644 apps/docs-snippets2/src/contracts/utilities/using-different-wallet.ts create mode 100644 apps/docs-snippets2/src/contracts/utilities/variable-outputs.ts create mode 100644 apps/docs-snippets2/sway/storage-test-contract/Forc.toml create mode 100644 apps/docs-snippets2/sway/storage-test-contract/src/main.sw create mode 100644 apps/docs-snippets2/sway/token/Forc.toml create mode 100644 apps/docs-snippets2/sway/token/src/main.sw diff --git a/apps/docs-snippets/src/guide/contracts/add-transfer.test.ts b/apps/docs-snippets/src/guide/contracts/add-transfer.test.ts deleted file mode 100644 index 78d2cb5de16..00000000000 --- a/apps/docs-snippets/src/guide/contracts/add-transfer.test.ts +++ /dev/null @@ -1,83 +0,0 @@ -import type { TransferParams } from 'fuels'; -import { Wallet } from 'fuels'; -import { ASSET_A, ASSET_B, launchTestNode } from 'fuels/test-utils'; - -import { EchoValuesFactory } from '../../../test/typegen'; - -/** - * @group node - * @group browser - */ -describe('Add Transfer', () => { - it('should successfully execute addTransfer for one recipient', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: EchoValuesFactory, - }, - ], - }); - const { - provider, - contracts: [contract], - } = launched; - // #region add-transfer-1 - const recipient = Wallet.generate({ provider }); - - const { waitForResult } = await contract.functions - .echo_u64(100) - .addTransfer({ - destination: recipient.address, - amount: 100, - assetId: provider.getBaseAssetId(), - }) - .call(); - - await waitForResult(); - // #endregion add-transfer-1 - - const recipientBalance = await recipient.getBalance(provider.getBaseAssetId()); - - expect(recipientBalance.toNumber()).toBe(100); - }); - - it('should successfully execute multiple addTransfer for multiple recipients', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: EchoValuesFactory, - }, - ], - }); - const { - provider, - contracts: [contract], - } = launched; - // #region add-transfer-2 - const recipient1 = Wallet.generate({ provider }); - const recipient2 = Wallet.generate({ provider }); - - const transferParams: TransferParams[] = [ - { destination: recipient1.address, amount: 100, assetId: provider.getBaseAssetId() }, - { destination: recipient1.address, amount: 400, assetId: ASSET_A }, - { destination: recipient2.address, amount: 300, assetId: ASSET_B }, - ]; - - const { waitForResult } = await contract.functions - .echo_u64(100) - .addBatchTransfer(transferParams) - .call(); - - await waitForResult(); - // #endregion add-transfer-2 - - const recipient1BalanceBaseAsset = await recipient1.getBalance(provider.getBaseAssetId()); - const recipient1BalanceAssetA = await recipient1.getBalance(ASSET_A); - - const recipient2BalanceAssetB = await recipient2.getBalance(ASSET_B); - - expect(recipient1BalanceBaseAsset.toNumber()).toBe(100); - expect(recipient1BalanceAssetA.toNumber()).toBe(400); - expect(recipient2BalanceAssetB.toNumber()).toBe(300); - }); -}); diff --git a/apps/docs-snippets/src/guide/contracts/interacting-with-contracts.test.ts b/apps/docs-snippets/src/guide/contracts/interacting-with-contracts.test.ts deleted file mode 100644 index 8aef10c18c4..00000000000 --- a/apps/docs-snippets/src/guide/contracts/interacting-with-contracts.test.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { Contract } from 'fuels'; -import { launchTestNode } from 'fuels/test-utils'; - -import { CounterFactory } from '../../../test/typegen'; - -/** - * @group node - * @group browser - */ -describe('Interacting with Contracts', () => { - it('should successfully use "get" to read from the blockchain', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: CounterFactory, - }, - ], - }); - - const { - contracts: [counterContract], - provider, - } = launched; - - const { waitForResult } = await counterContract.functions.increment_counter(1).call(); - await waitForResult(); - - const { id: contractId, interface: abi } = counterContract; - - // #region interacting-with-contracts-1 - const contract = new Contract(contractId, abi, provider); - - const { value } = await contract.functions.get_count().get(); - // #endregion interacting-with-contracts-1 - expect(value.toNumber()).toBeGreaterThanOrEqual(1); - }); - - it('should successfully use "dryRun" to validate a TX without a wallet', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: CounterFactory, - }, - ], - }); - - const { - contracts: [counterContract], - provider, - } = launched; - - const { id: contractId, interface: abi } = counterContract; - - // #region interacting-with-contracts-2 - const contract = new Contract(contractId, abi, provider); - - const { value } = await contract.functions.increment_counter(1).dryRun(); - // #endregion interacting-with-contracts-2 - expect(value.toNumber()).toBeGreaterThanOrEqual(1); - }); - - it('should successfully use "simulate" to validate if wallet can pay for transaction', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: CounterFactory, - }, - ], - }); - - const { - contracts: [counterContract], - wallets: [fundedWallet], - } = launched; - - const { id: contractId, interface: abi } = counterContract; - - // #region interacting-with-contracts-3 - const contract = new Contract(contractId, abi, fundedWallet); - - const { value } = await contract.functions.increment_counter(10).simulate(); - // #endregion interacting-with-contracts-3 - expect(value.toNumber()).toBeGreaterThanOrEqual(10); - }); - - it('should successfully execute a contract call without a wallet [call]', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: CounterFactory, - }, - ], - }); - - const { - contracts: [contract], - } = launched; - - // #region interacting-with-contracts-4 - const { transactionId, waitForResult } = await contract.functions.increment_counter(10).call(); - - const { value } = await waitForResult(); - // #endregion interacting-with-contracts-4 - - expect(transactionId).toBeDefined(); - expect(value.toNumber()).toBeGreaterThanOrEqual(10); - }); - - it('should successfully execute a contract call without a wallet [call]', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: CounterFactory, - }, - ], - }); - - const { - contracts: [contract], - } = launched; - - // #region interacting-with-contracts-5 - const { waitForResult } = await contract.functions.increment_counter(10).call(); - const { value } = await waitForResult(); - // #endregion interacting-with-contracts-5 - - expect(value.toNumber()).toBeGreaterThanOrEqual(10); - }); -}); diff --git a/apps/docs-snippets/src/guide/contracts/is-function-readonly.test.ts b/apps/docs-snippets/src/guide/contracts/is-function-readonly.test.ts deleted file mode 100644 index d4f2925933a..00000000000 --- a/apps/docs-snippets/src/guide/contracts/is-function-readonly.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { launchTestNode } from 'fuels/test-utils'; - -import { CounterFactory } from '../../../test/typegen'; - -/** - * @group node - * @group browser - */ -test('isReadOnly returns true for read-only functions', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: CounterFactory, - }, - ], - }); - - const { - contracts: [contract], - } = launched; - - // #region is-function-readonly-1 - - const isReadOnly = contract.functions.get_count.isReadOnly(); - - if (isReadOnly) { - await contract.functions.get_count().get(); - } else { - const { waitForResult } = await contract.functions.get_count().call(); - await waitForResult(); - } - // #endregion is-function-readonly-1 - - expect(isReadOnly).toBe(true); -}); diff --git a/apps/docs-snippets/src/guide/contracts/minted-token-asset-id.test.ts b/apps/docs-snippets/src/guide/contracts/minted-token-asset-id.test.ts deleted file mode 100644 index 670566742bc..00000000000 --- a/apps/docs-snippets/src/guide/contracts/minted-token-asset-id.test.ts +++ /dev/null @@ -1,59 +0,0 @@ -import type { AssetId } from 'fuels'; -import { bn, getMintedAssetId, createAssetId } from 'fuels'; -import { launchTestNode } from 'fuels/test-utils'; - -import { EchoAssetIdFactory, TokenFactory } from '../../../test/typegen'; - -/** - * @group node - * @group browser - */ -describe('Minted Token Asset Id', () => { - it('should successfully execute contract call with forwarded amount', async () => { - using launched = await launchTestNode({ - contractsConfigs: [{ factory: TokenFactory }], - }); - - const { - contracts: [contract], - } = launched; - - // #region minted-token-asset-id-2 - // #import { bn, getMintedAssetId }; - - // Any valid bits256 string can be used as a sub ID - const subID = '0xc7fd1d987ada439fc085cfa3c49416cf2b504ac50151e3c2335d60595cb90745'; - const mintAmount = bn(1000); - - const { waitForResult } = await contract.functions.mint_coins(subID, mintAmount).call(); - const txResult = await waitForResult(); - - const mintedAssetId = getMintedAssetId(contract.id.toB256(), subID); - // #endregion minted-token-asset-id-2 - - expect(mintedAssetId).toBeDefined(); - expect(txResult.transactionResult.isStatusSuccess).toBeTruthy(); - }); - - it('should create valid asset ID', async () => { - using launched = await launchTestNode({ - contractsConfigs: [{ factory: EchoAssetIdFactory }], - }); - - const { - contracts: [contract], - } = launched; - - // #region create-asset-id-1 - // #import { createAssetId, AssetId }; - - const subID = '0xc7fd1d987ada439fc085cfa3c49416cf2b504ac50151e3c2335d60595cb90745'; - - const assetId: AssetId = createAssetId(contract.id.toB256(), subID); - // #endregion create-asset-id-1 - const { value } = await contract.functions.echo_asset_id_input(assetId).simulate(); - - expect(assetId).toBeDefined(); - expect(value).toEqual(assetId); - }); -}); diff --git a/apps/docs-snippets/src/guide/contracts/multicalls.test.ts b/apps/docs-snippets/src/guide/contracts/multicalls.test.ts deleted file mode 100644 index 728cec3b09a..00000000000 --- a/apps/docs-snippets/src/guide/contracts/multicalls.test.ts +++ /dev/null @@ -1,141 +0,0 @@ -import { bn, BN } from 'fuels'; -import { launchTestNode } from 'fuels/test-utils'; - -import { CounterFactory, EchoValuesFactory, ReturnContextFactory } from '../../../test/typegen'; - -/** - * @group node - * @group browser - */ -describe('Multicalls', () => { - it('should successfully submit multiple calls from the same contract function', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: CounterFactory, - }, - ], - }); - - const { - contracts: [counterContract], - } = launched; - - // #region multicall-1 - const { waitForResult } = await counterContract - .multiCall([ - counterContract.functions.get_count(), - counterContract.functions.increment_counter(2), - counterContract.functions.increment_counter(4), - ]) - .call(); - - const { value: results } = await waitForResult(); - - expect(results[0].toNumber()).toBe(0); - expect(results[1].toNumber()).toBe(2); - expect(results[2].toNumber()).toBe(6); - // #endregion multicall-1 - }); - - it('should successfully submit multiple calls from different contracts functions', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: EchoValuesFactory, - }, - { - factory: CounterFactory, - }, - ], - }); - - const { - contracts: [echoContract, counterContract], - } = launched; - - // #region multicall-2 - const { waitForResult } = await echoContract - .multiCall([ - echoContract.functions.echo_u8(17), - counterContract.functions.get_count(), - counterContract.functions.increment_counter(5), - ]) - .call(); - - const { value: results } = await waitForResult(); - - expect(results[0]).toEqual(17); - expect(results[1].toNumber()).toBe(0); - expect(results[2].toNumber()).toBe(5); - // #endregion multicall-2 - }); - - it('should successfully submit multiple calls from different contracts functions', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: ReturnContextFactory, - }, - { - factory: EchoValuesFactory, - }, - ], - }); - - const { - contracts: [contextContract, echoContract], - provider, - } = launched; - - // #region multicall-3 - const { waitForResult } = await contextContract - .multiCall([ - echoContract.functions.echo_u8(10), - contextContract.functions.return_context_amount().callParams({ - forward: [100, provider.getBaseAssetId()], - }), - ]) - .call(); - - const { value: results } = await waitForResult(); - - const echoedValue = results[0]; - const fowardedValue = new BN(results[1]).toNumber(); - - expect(echoedValue).toEqual(10); - expect(fowardedValue).toEqual(100); - // #endregion multicall-3 - }); - - it('should successfully submit multiple read-only calls', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: CounterFactory, - }, - { - factory: EchoValuesFactory, - }, - ], - }); - - const { - contracts: [counterContract, echoValuesContract], - } = launched; - - // #region multicall-4 - const { value: results } = await counterContract - .multiCall([ - counterContract.functions.get_count(), - echoValuesContract.functions.echo_u8(10), - echoValuesContract.functions.echo_str('Fuel'), - ]) - .get(); - - expect(results[0].toNumber()).toBe(bn(0).toNumber()); - expect(results[1]).toBe(10); - expect(results[2]).toBe('Fuel'); - // #endregion multicall-4 - }); -}); diff --git a/apps/docs-snippets/src/guide/contracts/variable-outputs.test.ts b/apps/docs-snippets/src/guide/contracts/variable-outputs.test.ts deleted file mode 100644 index 2d7de39e0bd..00000000000 --- a/apps/docs-snippets/src/guide/contracts/variable-outputs.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { getMintedAssetId, getRandomB256, Wallet } from 'fuels'; -import { launchTestNode } from 'fuels/test-utils'; - -import { TokenFactory } from '../../../test/typegen'; - -/** - * @group node - * @group browser - */ -describe('Variable Outputs', () => { - it('should successfully execute contract call with variable outputs', async () => { - using launched = await launchTestNode({ - contractsConfigs: [ - { - factory: TokenFactory, - }, - ], - }); - - const { - contracts: [contract], - } = launched; - - const subId = getRandomB256(); - - const call1 = await contract.functions.mint_coins(subId, 100).call(); - await call1.waitForResult(); - - const address = { bits: Wallet.generate().address.toB256() }; - const assetId = { bits: getMintedAssetId(contract.id.toB256(), subId) }; - - // #region variable-outputs-2 - const { waitForResult } = await contract.functions - .transfer_to_address(address, assetId, 100) - .txParams({ - variableOutputs: 1, - }) - .call(); - - const { transactionResult } = await waitForResult(); - // #endregion variable-outputs-2 - - expect(transactionResult.isStatusSuccess).toBeTruthy(); - }); -}); diff --git a/apps/docs-snippets/test/fixtures/forc-projects/echo-values/src/main.sw b/apps/docs-snippets/test/fixtures/forc-projects/echo-values/src/main.sw index 87bb47a673d..03a7ca5247b 100644 --- a/apps/docs-snippets/test/fixtures/forc-projects/echo-values/src/main.sw +++ b/apps/docs-snippets/test/fixtures/forc-projects/echo-values/src/main.sw @@ -1,4 +1,3 @@ -// #region understanding-fuel-binary-file contract; use std::b512::B512; @@ -45,4 +44,3 @@ impl EchoValues for Contract { value } } -// #endregion understanding-fuel-binary-file diff --git a/apps/docs-snippets/test/fixtures/forc-projects/token/src/main.sw b/apps/docs-snippets/test/fixtures/forc-projects/token/src/main.sw index 65084202343..fe27fa75290 100644 --- a/apps/docs-snippets/test/fixtures/forc-projects/token/src/main.sw +++ b/apps/docs-snippets/test/fixtures/forc-projects/token/src/main.sw @@ -11,7 +11,6 @@ abi Token { } impl Token for Contract { - // #region variable-outputs-1 fn transfer_to_address(recipient: Address, asset_id: AssetId, amount: u64) { transfer(Identity::Address(recipient), asset_id, amount); } @@ -19,7 +18,7 @@ impl Token for Contract { fn transfer_to_contract(target: ContractId, asset_id: AssetId, amount: u64) { transfer(Identity::ContractId(target), asset_id, amount); } - // #endregion variable-outputs-1 + fn mint_coins(sub_id: b256, mint_amount: u64) { mint(sub_id, mint_amount); } diff --git a/apps/docs-snippets2/src/contracts/methods/call.ts b/apps/docs-snippets2/src/contracts/methods/call.ts new file mode 100644 index 00000000000..f589ec945a3 --- /dev/null +++ b/apps/docs-snippets2/src/contracts/methods/call.ts @@ -0,0 +1,19 @@ +// #region interacting-with-contracts-4 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { CounterFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deployContract = await CounterFactory.deploy(deployer); +const { contract } = await deployContract.waitForResult(); + +// Perform the transaction +const { waitForResult } = await contract.functions.increment_count(10).call(); + +const { value } = await waitForResult(); +// #endregion interacting-with-contracts-4 + +console.log('Value should equal 10', value.toNumber() === 10); diff --git a/apps/docs-snippets2/src/contracts/methods/dry-run.ts b/apps/docs-snippets2/src/contracts/methods/dry-run.ts new file mode 100644 index 00000000000..9d0e9c1c8d0 --- /dev/null +++ b/apps/docs-snippets2/src/contracts/methods/dry-run.ts @@ -0,0 +1,17 @@ +// #region interacting-with-contracts-2 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { CounterFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deployContract = await CounterFactory.deploy(deployer); +const { contract } = await deployContract.waitForResult(); + +// Perform a dry-run of the transaction +const { value } = await contract.functions.increment_count(1).dryRun(); +// #endregion interacting-with-contracts-2 + +console.log('Value should equal 1', value.toNumber() === 1); diff --git a/apps/docs-snippets2/src/contracts/methods/get.ts b/apps/docs-snippets2/src/contracts/methods/get.ts new file mode 100644 index 00000000000..21683065fd9 --- /dev/null +++ b/apps/docs-snippets2/src/contracts/methods/get.ts @@ -0,0 +1,18 @@ +// #region interacting-with-contracts-1 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { CounterFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deployContract = await CounterFactory.deploy(deployer); +const { contract } = await deployContract.waitForResult(); + +// Read from the blockchain +const { value } = await contract.functions.get_count().get(); +// 0 +// #endregion interacting-with-contracts-1 + +console.log('Value should equal 0', value.toNumber() === 0); diff --git a/apps/docs-snippets2/src/contracts/methods/is-read-only.ts b/apps/docs-snippets2/src/contracts/methods/is-read-only.ts new file mode 100644 index 00000000000..edab7d83c8d --- /dev/null +++ b/apps/docs-snippets2/src/contracts/methods/is-read-only.ts @@ -0,0 +1,26 @@ +// #region is-function-readonly-1 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { CounterFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deployContract = await CounterFactory.deploy(deployer); +const { contract } = await deployContract.waitForResult(); + +const isReadOnly = contract.functions.get_count.isReadOnly(); + +if (isReadOnly) { + await contract.functions.get_count().get(); +} else { + const { waitForResult } = await contract.functions.get_count().call(); + await waitForResult(); +} +// #endregion is-function-readonly-1 + +console.log( + 'isReadOnly should be true for get_count method', + isReadOnly === true +); diff --git a/apps/docs-snippets2/src/contracts/methods/simulate.ts b/apps/docs-snippets2/src/contracts/methods/simulate.ts new file mode 100644 index 00000000000..a702c1f84c0 --- /dev/null +++ b/apps/docs-snippets2/src/contracts/methods/simulate.ts @@ -0,0 +1,17 @@ +// #region interacting-with-contracts-3 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { CounterFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deployContract = await CounterFactory.deploy(deployer); +const { contract } = await deployContract.waitForResult(); + +// Simulate the transaction +const { value } = await contract.functions.increment_count(10).simulate(); +// #endregion interacting-with-contracts-3 + +console.log('Value should equal 10', value.toNumber() === 10); diff --git a/apps/docs-snippets2/src/contracts/multi-call/different-contracts-chain-methods.ts b/apps/docs-snippets2/src/contracts/multi-call/different-contracts-chain-methods.ts new file mode 100644 index 00000000000..2a2ee1da752 --- /dev/null +++ b/apps/docs-snippets2/src/contracts/multi-call/different-contracts-chain-methods.ts @@ -0,0 +1,31 @@ +// #region multicall-3 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { EchoValuesFactory, ReturnContextFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const echoContractTx = await EchoValuesFactory.deploy(deployer); +const { contract: echoContract } = await echoContractTx.waitForResult(); +const returnContextTx = await ReturnContextFactory.deploy(deployer); +const { contract: returnContextContract } = + await returnContextTx.waitForResult(); + +const { waitForResult } = await echoContract + .multiCall([ + echoContract.functions.echo_u8(10), + returnContextContract.functions.return_context_amount().callParams({ + forward: [100, provider.getBaseAssetId()], + }), + ]) + .call(); + +const { value: results } = await waitForResult(); +// results[0] == 10 +// results[1] == BN <100> +// #endregion multicall-3 + +console.log('result[0]', results[0] === 10); +console.log('result[1]', results[1].toNumber() === 100); diff --git a/apps/docs-snippets2/src/contracts/multi-call/different-contracts-readonly.ts b/apps/docs-snippets2/src/contracts/multi-call/different-contracts-readonly.ts new file mode 100644 index 00000000000..e8e3930543f --- /dev/null +++ b/apps/docs-snippets2/src/contracts/multi-call/different-contracts-readonly.ts @@ -0,0 +1,31 @@ +// #region multicall-4 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { CounterFactory, EchoValuesFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const counterContractTx = await CounterFactory.deploy(deployer); +const { contract: counterContract } = await counterContractTx.waitForResult(); +const echoContractTx = await EchoValuesFactory.deploy(deployer); +const { contract: echoContract } = await echoContractTx.waitForResult(); + +const { waitForResult } = await echoContract + .multiCall([ + counterContract.functions.get_count(), + echoContract.functions.echo_u8(10), + echoContract.functions.echo_str('Fuel'), + ]) + .call(); + +const { value: results } = await waitForResult(); +// results[0] == BN <0> +// results[1] == 10 +// results[2] == 'Fuel' +// #endregion multicall-4 + +console.log('result[0]', results[0].toNumber() === 0); +console.log('result[1]', results[1] === 10); +console.log('result[2]', results[2] === 'Fuel'); diff --git a/apps/docs-snippets2/src/contracts/multi-call/different-contracts.ts b/apps/docs-snippets2/src/contracts/multi-call/different-contracts.ts new file mode 100644 index 00000000000..e8eb3d7b98d --- /dev/null +++ b/apps/docs-snippets2/src/contracts/multi-call/different-contracts.ts @@ -0,0 +1,31 @@ +// #region multicall-2 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { CounterFactory, EchoValuesFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const counterContractTx = await CounterFactory.deploy(deployer); +const { contract: counterContract } = await counterContractTx.waitForResult(); +const echoContractTx = await EchoValuesFactory.deploy(deployer); +const { contract: echoContract } = await echoContractTx.waitForResult(); + +const { waitForResult } = await echoContract + .multiCall([ + echoContract.functions.echo_u8(17), + counterContract.functions.get_count(), + counterContract.functions.increment_count(5), + ]) + .call(); + +const { value: results } = await waitForResult(); +// results[0] == 17 +// results[1] == BN <0> +// results[2] == BN <5> +// #endregion multicall-2 + +console.log('result[0]', results[0] === 17); +console.log('result[1]', results[1].toNumber() === 0); +console.log('result[2]', results[2].toNumber() === 5); diff --git a/apps/docs-snippets2/src/contracts/multi-call/same-contract.ts b/apps/docs-snippets2/src/contracts/multi-call/same-contract.ts new file mode 100644 index 00000000000..0e316acfb27 --- /dev/null +++ b/apps/docs-snippets2/src/contracts/multi-call/same-contract.ts @@ -0,0 +1,29 @@ +// #region multicall-1 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { CounterFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const counterContractTx = await CounterFactory.deploy(deployer); +const { contract: counterContract } = await counterContractTx.waitForResult(); + +const { waitForResult } = await counterContract + .multiCall([ + counterContract.functions.get_count(), + counterContract.functions.increment_count(2), + counterContract.functions.increment_count(4), + ]) + .call(); + +const { value: results } = await waitForResult(); +// results[0] == 0 +// results[1] == 2 +// results[2] == 6 +// #endregion multicall-1 + +console.log('result[0]', results[0].toNumber() === 0); +console.log('result[1]', results[1].toNumber() === 2); +console.log('result[2]', results[2].toNumber() === 6); diff --git a/apps/docs-snippets2/src/contracts/storage-slots/override-storage-slots-inline.ts b/apps/docs-snippets2/src/contracts/storage-slots/override-storage-slots-inline.ts new file mode 100644 index 00000000000..a7f3939ceba --- /dev/null +++ b/apps/docs-snippets2/src/contracts/storage-slots/override-storage-slots-inline.ts @@ -0,0 +1,43 @@ +// #region contract-deployment-storage-slots-inline +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { StorageTestContractFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deploymentTx = await StorageTestContractFactory.deploy(deployer, { + storageSlots: [ + { + key: '02dac99c283f16bc91b74f6942db7f012699a2ad51272b15207b9cc14a70dbae', + value: '0000000000000001000000000000000000000000000000000000000000000000', + }, + { + key: '6294951dcb0a9111a517be5cf4785670ff4e166fb5ab9c33b17e6881b48e964f', + value: '0000000000000001000000000000003200000000000000000000000000000000', + }, + { + key: 'b48b753af346966d0d169c0b2e3234611f65d5cfdb57c7b6e7cd6ca93707bee0', + value: '000000000000001e000000000000000000000000000000000000000000000000', + }, + { + key: 'de9090cb50e71c2588c773487d1da7066d0c719849a7e58dc8b6397a25c567c0', + value: '0000000000000014000000000000000000000000000000000000000000000000', + }, + { + key: 'f383b0ce51358be57daa3b725fe44acdb2d880604e367199080b4379c41bb6ed', + value: '000000000000000a000000000000000000000000000000000000000000000000', + }, + ], +}); + +await deploymentTx.waitForResult(); +// #endregion contract-deployment-storage-slots-inline + +const { contract, transactionResult } = await deploymentTx.waitForResult(); +console.log('Contract should be defined', contract); +console.log( + 'Deployment transaction should be successful', + transactionResult.isStatusSuccess +); diff --git a/apps/docs-snippets2/src/contracts/storage-slots/override-storage-slots.ts b/apps/docs-snippets2/src/contracts/storage-slots/override-storage-slots.ts new file mode 100644 index 00000000000..486979bbf45 --- /dev/null +++ b/apps/docs-snippets2/src/contracts/storage-slots/override-storage-slots.ts @@ -0,0 +1,25 @@ +// #region contract-deployment-storage-slots +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { + StorageTestContract, + StorageTestContractFactory, +} from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deploymentTx = await StorageTestContractFactory.deploy(deployer, { + storageSlots: StorageTestContract.storageSlots, +}); + +await deploymentTx.waitForResult(); +// #endregion contract-deployment-storage-slots + +const { contract, transactionResult } = await deploymentTx.waitForResult(); +console.log('Contract should be defined', contract); +console.log( + 'Deployment transaction should be successful', + transactionResult.isStatusSuccess +); diff --git a/apps/docs-snippets2/src/contracts/utilities/add-transfer-multiple-recipients.ts b/apps/docs-snippets2/src/contracts/utilities/add-transfer-multiple-recipients.ts new file mode 100644 index 00000000000..94e17866dc0 --- /dev/null +++ b/apps/docs-snippets2/src/contracts/utilities/add-transfer-multiple-recipients.ts @@ -0,0 +1,47 @@ +// #region add-transfer-2 +import type { TransferParams } from 'fuels'; +import { Provider, Wallet } from 'fuels'; +import { ASSET_A, ASSET_B } from 'fuels/test-utils'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { EchoValuesFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deployContract = await EchoValuesFactory.deploy(deployer); +const { contract } = await deployContract.waitForResult(); + +const recipient1 = Wallet.generate({ provider }); +const recipient2 = Wallet.generate({ provider }); + +const transferParams: TransferParams[] = [ + { + destination: recipient1.address, + amount: 100, + assetId: provider.getBaseAssetId(), + }, + { destination: recipient1.address, amount: 400, assetId: ASSET_A }, + { destination: recipient2.address, amount: 300, assetId: ASSET_B }, +]; + +const { waitForResult } = await contract.functions + .echo_u64(100) + .addBatchTransfer(transferParams) + .call(); + +await waitForResult(); +// #endregion add-transfer-2 + +const recipientBalanceBaseAsset = await recipient1.getBalance( + provider.getBaseAssetId() +); +const recipientBalanceAssetA = await recipient1.getBalance(ASSET_A); +const recipientBalanceAssetB = await recipient2.getBalance(ASSET_B); + +console.log( + 'Recipient 1 balance (base asset)', + recipientBalanceBaseAsset.toNumber() +); +console.log('Recipient 1 balance (asset A)', recipientBalanceAssetA.toNumber()); +console.log('Recipient 2 balance (asset B)', recipientBalanceAssetB.toNumber()); diff --git a/apps/docs-snippets2/src/contracts/utilities/add-transfer-single-recipient.ts b/apps/docs-snippets2/src/contracts/utilities/add-transfer-single-recipient.ts new file mode 100644 index 00000000000..4cec79601b7 --- /dev/null +++ b/apps/docs-snippets2/src/contracts/utilities/add-transfer-single-recipient.ts @@ -0,0 +1,31 @@ +// #region add-transfer-1 +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { EchoValuesFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deployContract = await EchoValuesFactory.deploy(deployer); +const { contract } = await deployContract.waitForResult(); + +const recipient = Wallet.generate({ provider }); + +const { waitForResult } = await contract.functions + .echo_u64(100) + .addTransfer({ + destination: recipient.address, + amount: 100, + assetId: provider.getBaseAssetId(), + }) + .call(); + +await waitForResult(); +// #endregion add-transfer-1 + +const recipientBalance = await recipient.getBalance(provider.getBaseAssetId()); +console.log( + 'Recipient balance should equal 100', + recipientBalance.toNumber() === 100 +); diff --git a/apps/docs-snippets2/src/contracts/utilities/create-asset-id.ts b/apps/docs-snippets2/src/contracts/utilities/create-asset-id.ts new file mode 100644 index 00000000000..7f1a3276ac3 --- /dev/null +++ b/apps/docs-snippets2/src/contracts/utilities/create-asset-id.ts @@ -0,0 +1,19 @@ +// #region create-asset-id-1 +import type { AssetId, B256Address } from 'fuels'; +import { createAssetId } from 'fuels'; + +const contractId: B256Address = + '0x67eb6a384151a30e162c26d2f3e81ca2023dfa1041000210caed42ead32d63c0'; +const subID: B256Address = + '0xc7fd1d987ada439fc085cfa3c49416cf2b504ac50151e3c2335d60595cb90745'; + +const assetId: AssetId = createAssetId(contractId, subID); +// { +// bits: '0x16c1cb95e999d0c74806f97643af158e821a0063a0c8ea61183bad2497b57478' +// } +// #endregion create-asset-id-1 + +const expectedAssetId = + '0x16c1cb95e999d0c74806f97643af158e821a0063a0c8ea61183bad2497b57478'; + +console.log('Asset ID should be equal', assetId.bits === expectedAssetId); diff --git a/apps/docs-snippets2/src/contracts/utilities/minted-token-asset-id.ts b/apps/docs-snippets2/src/contracts/utilities/minted-token-asset-id.ts new file mode 100644 index 00000000000..fcced21cef1 --- /dev/null +++ b/apps/docs-snippets2/src/contracts/utilities/minted-token-asset-id.ts @@ -0,0 +1,32 @@ +// #region minted-token-asset-id-2 +import { bn, getMintedAssetId, Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { TokenFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deployContract = await TokenFactory.deploy(deployer); +const { contract } = await deployContract.waitForResult(); + +// Any valid bits256 string can be used as a sub ID +const subID = + '0xc7fd1d987ada439fc085cfa3c49416cf2b504ac50151e3c2335d60595cb90745'; +const mintAmount = bn(1000); + +const { waitForResult } = await contract.functions + .mint_coins(subID, mintAmount) + .call(); +await waitForResult(); + +// Get the minted +const mintedAssetId = getMintedAssetId(contract.id.toB256(), subID); +// #endregion minted-token-asset-id-2 + +console.log('Minted asset ID should be defined', mintedAssetId); +const { transactionResult } = await waitForResult(); +console.log( + 'Transaction should be successful', + transactionResult.isStatusSuccess +); diff --git a/apps/docs-snippets2/src/contracts/utilities/using-different-wallet.ts b/apps/docs-snippets2/src/contracts/utilities/using-different-wallet.ts new file mode 100644 index 00000000000..603885541e7 --- /dev/null +++ b/apps/docs-snippets2/src/contracts/utilities/using-different-wallet.ts @@ -0,0 +1,21 @@ +// #region using-different-wallet +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { ReturnContextFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deployContract = await ReturnContextFactory.deploy(deployer); +const { contract } = await deployContract.waitForResult(); + +// Update the wallet +const newWallet = Wallet.generate({ provider }); +contract.account = newWallet; +// #endregion using-different-wallet + +console.log( + 'Contract account should equal the new wallet address', + contract.account.address.toB256() === newWallet.address.toB256() +); diff --git a/apps/docs-snippets2/src/contracts/utilities/variable-outputs.ts b/apps/docs-snippets2/src/contracts/utilities/variable-outputs.ts new file mode 100644 index 00000000000..9a31af550cb --- /dev/null +++ b/apps/docs-snippets2/src/contracts/utilities/variable-outputs.ts @@ -0,0 +1,35 @@ +// #region variable-outputs-2 +import { Provider, Wallet, getMintedAssetId, getRandomB256 } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../env'; +import { TokenFactory } from '../../typegend'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +const deployContract = await TokenFactory.deploy(deployer); +const { contract } = await deployContract.waitForResult(); + +const subId = getRandomB256(); + +const call1 = await contract.functions.mint_coins(subId, 100).call(); +await call1.waitForResult(); + +const address = { bits: Wallet.generate().address.toB256() }; +const assetId = { bits: getMintedAssetId(contract.id.toB256(), subId) }; + +const { waitForResult } = await contract.functions + .transfer_to_address(address, assetId, 100) + .txParams({ + variableOutputs: 1, + }) + .call(); + +await waitForResult(); +// #endregion variable-outputs-2 + +const { transactionResult } = await waitForResult(); +console.log( + 'Transaction should be successful', + transactionResult.isStatusSuccess +); diff --git a/apps/docs-snippets2/sway/Forc.toml b/apps/docs-snippets2/sway/Forc.toml index c0d77ce6ba3..a8a0b44e2ca 100644 --- a/apps/docs-snippets2/sway/Forc.toml +++ b/apps/docs-snippets2/sway/Forc.toml @@ -3,10 +3,6 @@ members = [ "bytecode-input", "configurable-pin", "counter", - "log-values", - "my-contract", - "echo-values", - "script-transfer-to-contract", "echo-asset-id", "echo-bytes", "echo-configurables", @@ -15,22 +11,28 @@ members = [ "echo-evm-address", "echo-raw-slice", "echo-std-string", + "echo-values", "employee-data", "input-output-types", "liquidity-pool", - "predicate-signing", - "return-script", - "script-signing", + "log-values", + "my-contract", "predicate-main-args-struct", "predicate-multi-args", + "predicate-signing", + "return-context", + "return-script", "return-true-predicate", + "script-signing", "script-sum", + "script-transfer-to-contract", "simple-predicate", "simple-token", "simple-token-abi", + "storage-test-contract", "sum-option-u8", + "token", "token-depositor", - "return-context", "transfer-to-address", "whitelisted-address-predicate", ] diff --git a/apps/docs-snippets2/sway/storage-test-contract/Forc.toml b/apps/docs-snippets2/sway/storage-test-contract/Forc.toml new file mode 100644 index 00000000000..c13ea4684e9 --- /dev/null +++ b/apps/docs-snippets2/sway/storage-test-contract/Forc.toml @@ -0,0 +1,6 @@ +[project] +authors = ["Fuel Labs "] +license = "Apache-2.0" +name = "storage-test-contract" + +[dependencies] diff --git a/apps/docs-snippets2/sway/storage-test-contract/src/main.sw b/apps/docs-snippets2/sway/storage-test-contract/src/main.sw new file mode 100644 index 00000000000..7613b90c52e --- /dev/null +++ b/apps/docs-snippets2/sway/storage-test-contract/src/main.sw @@ -0,0 +1,95 @@ +contract; + +use std::storage::storage_api::{read, write}; + +struct StructValidation { + v1: bool, + v2: u64, +} + +storage { + var1: u64 = 0, + var2: u32 = 20, + var3: u16 = 30, + var4: bool = true, + var5: StructValidation = StructValidation { + v1: true, + v2: 50, + }, +} + +abi StorageTestContract { + #[storage(write)] + fn initialize_counter(value: u64) -> u64; + #[storage(read, write)] + fn increment_counter(amount: u64) -> u64; + #[storage(read)] + fn counter() -> u64; + #[storage(read)] + fn return_b256() -> b256; + #[storage(read)] + fn return_var1() -> u64; + #[storage(read)] + fn return_var2() -> u32; + #[storage(read)] + fn return_var3() -> u16; + #[storage(read)] + fn return_var4() -> bool; + #[storage(read)] + fn return_var5() -> StructValidation; + fn return_true() -> bool; +} + +const COUNTER_KEY: b256 = 0x0000000000000000000000000000000000000000000000000000000000000000; +const VALUE_B256: b256 = 0x0000000000000000000000000000000000000000000000000000000000000001; + +impl StorageTestContract for Contract { + #[storage(write)] + fn initialize_counter(value: u64) -> u64 { + write(COUNTER_KEY, 0, value); + value + } + #[storage(read, write)] + fn increment_counter(amount: u64) -> u64 { + let value: Option = read::(COUNTER_KEY, 0); + let value = value.unwrap_or(0) + amount; + write(COUNTER_KEY, 0, value); + value + } + #[storage(read)] + fn counter() -> u64 { + let value: Option = read::(COUNTER_KEY, 0); + let value = value.unwrap_or(0); + value + } + // Return values from storage + // This is used to test storage initialization, on contract deployment + #[storage(read)] + fn return_b256() -> b256 { + let value: Option = read::(VALUE_B256, 0); + value.unwrap_or(VALUE_B256) + } + #[storage(read)] + fn return_var1() -> u64 { + storage.var1.read() + } + #[storage(read)] + fn return_var2() -> u32 { + storage.var2.read() + } + #[storage(read)] + fn return_var3() -> u16 { + storage.var3.read() + } + #[storage(read)] + fn return_var4() -> bool { + storage.var4.read() + } + #[storage(read)] + fn return_var5() -> StructValidation { + storage.var5.read() + } + fn return_true() -> bool { + true + } +} diff --git a/apps/docs-snippets2/sway/token/Forc.toml b/apps/docs-snippets2/sway/token/Forc.toml new file mode 100644 index 00000000000..5be8d04f8cf --- /dev/null +++ b/apps/docs-snippets2/sway/token/Forc.toml @@ -0,0 +1,7 @@ +[project] +authors = ["Fuel Labs "] +entry = "main.sw" +license = "Apache-2.0" +name = "token" + +[dependencies] diff --git a/apps/docs-snippets2/sway/token/src/main.sw b/apps/docs-snippets2/sway/token/src/main.sw new file mode 100644 index 00000000000..65084202343 --- /dev/null +++ b/apps/docs-snippets2/sway/token/src/main.sw @@ -0,0 +1,31 @@ +// #region minted-token-asset-id-1 +contract; + +use std::asset::{burn, mint, transfer}; + +abi Token { + fn transfer_to_address(target: Address, asset_id: AssetId, coins: u64); + fn transfer_to_contract(recipient: ContractId, asset_id: AssetId, coins: u64); + fn mint_coins(sub_id: b256, mint_amount: u64); + fn burn_coins(sub_id: b256, burn_amount: u64); +} + +impl Token for Contract { + // #region variable-outputs-1 + fn transfer_to_address(recipient: Address, asset_id: AssetId, amount: u64) { + transfer(Identity::Address(recipient), asset_id, amount); + } + + fn transfer_to_contract(target: ContractId, asset_id: AssetId, amount: u64) { + transfer(Identity::ContractId(target), asset_id, amount); + } + // #endregion variable-outputs-1 + fn mint_coins(sub_id: b256, mint_amount: u64) { + mint(sub_id, mint_amount); + } + + fn burn_coins(sub_id: b256, burn_amount: u64) { + burn(sub_id, burn_amount); + } +} +// #endregion minted-token-asset-id-1 diff --git a/apps/docs/src/guide/contracts/methods.md b/apps/docs/src/guide/contracts/methods.md index ccd5f04baa8..a5a4c2b27a8 100644 --- a/apps/docs/src/guide/contracts/methods.md +++ b/apps/docs/src/guide/contracts/methods.md @@ -6,13 +6,13 @@ There are 4 ways to interact with contracts: `get`, `dryRun`, `simulate`, `call` The `get` method should be used to read data from the blockchain without using resources. It can be used with an unfunded wallet or even without a wallet at all: -<<< @/../../docs-snippets/src/guide/contracts/interacting-with-contracts.test.ts#interacting-with-contracts-1{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/methods/get.ts#interacting-with-contracts-1{ts:line-numbers} ## `dryRun` The `dryRun` method should be used to dry-run a contract call. It does not spend resources and can be used with an unfunded wallet or even without a wallet at all: -<<< @/../../docs-snippets/src/guide/contracts/interacting-with-contracts.test.ts#interacting-with-contracts-2{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/methods/dry-run.ts#interacting-with-contracts-2{ts:line-numbers} ## `simulate` @@ -20,7 +20,7 @@ The `simulate` method should be used to dry-run a contract call, ensuring that t A funded wallet it's required: -<<< @/../../docs-snippets/src/guide/contracts/interacting-with-contracts.test.ts#interacting-with-contracts-3{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/methods/simulate.ts#interacting-with-contracts-3{ts:line-numbers} ## `call` @@ -28,13 +28,13 @@ The `call` method submits a real contract call transaction to the node, resolvin Real resources are consumed, and any operations executed by the contract function will be processed on the blockchain. -<<< @/../../docs-snippets/src/guide/contracts/interacting-with-contracts.test.ts#interacting-with-contracts-4{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/methods/call.ts#interacting-with-contracts-4{ts:line-numbers} ## `isReadOnly` (utility) If you want to figure out whether a function is read-only, you can use the `isReadOnly` method: -<<< @/../../docs-snippets/src/guide/contracts/is-function-readonly.test.ts#is-function-readonly-1{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/methods/is-read-only.ts#is-function-readonly-1{ts:line-numbers} If the function is read-only, you can use the `get` method to retrieve onchain data without spending gas. diff --git a/apps/docs/src/guide/contracts/minted-token-asset-id.md b/apps/docs/src/guide/contracts/minted-token-asset-id.md index 091e7a26eaa..abd77637a9c 100644 --- a/apps/docs/src/guide/contracts/minted-token-asset-id.md +++ b/apps/docs/src/guide/contracts/minted-token-asset-id.md @@ -11,11 +11,11 @@ The process involves applying a SHA-256 hash algorithm to the combination of the Consider the following simplified token contract: -<<< @/../../docs-snippets/test/fixtures/forc-projects/token/src/main.sw#minted-token-asset-id-1{rs:line-numbers} +<<< @/../../docs-snippets2/sway/token/src/main.sw#minted-token-asset-id-1{rs:line-numbers} Imagine that this contract is already deployed and we are about to mint some coins: -<<< @/../../docs-snippets/src/guide/contracts/minted-token-asset-id.test.ts#minted-token-asset-id-2{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/utilities/minted-token-asset-id.ts#minted-token-asset-id-2{ts:line-numbers} ## Obtaining the Asset ID @@ -25,4 +25,4 @@ Since the asset ID depends on the contract ID, which is always dynamic (unlike t The SDK provides a helper named `createAssetId` which takes the contract ID and sub ID as parameters. This helper internally calls `getMintedAssetId` and returns the Sway native parameter [AssetId](https://docs.fuel.network/docs/fuels-ts/interfaces/#assetid), ready to be used in a Sway program invocation: -<<< @/../../docs-snippets/src/guide/contracts/minted-token-asset-id.test.ts#create-asset-id-1{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/utilities/create-asset-id.ts#create-asset-id-1{ts:line-numbers} diff --git a/apps/docs/src/guide/contracts/multi-contract-calls.md b/apps/docs/src/guide/contracts/multi-contract-calls.md index b1ab73165d4..f9c6b7e4c6c 100644 --- a/apps/docs/src/guide/contracts/multi-contract-calls.md +++ b/apps/docs/src/guide/contracts/multi-contract-calls.md @@ -16,17 +16,17 @@ Use the `multiCall` method to call multiple functions on the same contract in a -<<< @/../../docs-snippets/src/guide/contracts/multicalls.test.ts#multicall-1{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/multi-call/same-contract.ts#multicall-1{ts:line-numbers} ## Different Contracts Multi Calls The `multiCall` method also allows you to execute multiple contract calls to distinct contracts within a single transaction: -<<< @/../../docs-snippets/src/guide/contracts/multicalls.test.ts#multicall-2{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/multi-call/different-contracts.ts#multicall-2{ts:line-numbers} You can also chain supported contract call methods, like `callParams`, for each contract call: -<<< @/../../docs-snippets/src/guide/contracts/multicalls.test.ts#multicall-3{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/multi-call/different-contracts-chain-methods.ts#multicall-3{ts:line-numbers} When using `multiCall`, the contract calls are queued and executed only after invoking one of the following methods: `.get`, `.simulate`, or `.call`. @@ -34,4 +34,4 @@ When using `multiCall`, the contract calls are queued and executed only after in When you need to read data from multiple contracts, the `multiCall` method can perform multiple [read-only](./methods.md#get) calls in a single transaction. This minimizes the number of requests sent to the network and consolidates data retrieval, making your dApp interactions more efficient. -<<< @/../../docs-snippets/src/guide/contracts/multicalls.test.ts#multicall-4{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/multi-call/different-contracts-readonly.ts#multicall-4{ts:line-numbers} diff --git a/apps/docs/src/guide/contracts/storage-slots.md b/apps/docs/src/guide/contracts/storage-slots.md index 3064d8f8436..c1475e31c1d 100644 --- a/apps/docs/src/guide/contracts/storage-slots.md +++ b/apps/docs/src/guide/contracts/storage-slots.md @@ -2,7 +2,7 @@ When deploying a contract, you can specify the custom storage slots that you want to use. -<<< @/../../../packages/fuel-gauge/src/storage-test-contract.test.ts#contract-deployment-storage-slots{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/storage-slots/override-storage-slots.ts#contract-deployment-storage-slots{ts:line-numbers} ## Using plain JavaScript @@ -10,7 +10,7 @@ In the above example, we directly imported the storage slots from a JSON file ge Instead of importing from a file, you can also specify the custom storage slots directly in your code: -<<< @/../../../packages/fuel-gauge/src/storage-test-contract.test.ts#contract-deployment-storage-slots-inline{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/storage-slots/override-storage-slots-inline.ts#contract-deployment-storage-slots-inline{ts:line-numbers} ## Auto-load of Storage Slots diff --git a/apps/docs/src/guide/contracts/transferring-assets.md b/apps/docs/src/guide/contracts/transferring-assets.md index eeae1dd343b..6550a83f193 100644 --- a/apps/docs/src/guide/contracts/transferring-assets.md +++ b/apps/docs/src/guide/contracts/transferring-assets.md @@ -4,7 +4,7 @@ Consider a scenario where you're interacting with a smart contract and need to t The `addTransfer` method allows you to append an asset transfer to your contract call transaction. You can use it is shown in the following example: -<<< @/../../docs-snippets/src/guide/contracts/add-transfer.test.ts#add-transfer-1{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/utilities/add-transfer-single-recipient.ts#add-transfer-1{ts:line-numbers} In the previous example, we first use a contract call to the `echo_u64` function. Following this, `addTransfer` is added to chain call to include a transfer of `100` units of the `BaseAssetId` in the transaction. @@ -12,4 +12,4 @@ In the previous example, we first use a contract call to the `echo_u64` function You can add a batch of transfers into a single transaction by using `addBatchTransfer`: -<<< @/../../docs-snippets/src/guide/contracts/add-transfer.test.ts#add-transfer-2{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/utilities/add-transfer-multiple-recipients.ts#add-transfer-2{ts:line-numbers} diff --git a/apps/docs/src/guide/contracts/understanding-the-fuelvm-binary-file.md b/apps/docs/src/guide/contracts/understanding-the-fuelvm-binary-file.md index 3ddda4c13ad..a30b335a877 100644 --- a/apps/docs/src/guide/contracts/understanding-the-fuelvm-binary-file.md +++ b/apps/docs/src/guide/contracts/understanding-the-fuelvm-binary-file.md @@ -4,7 +4,7 @@ When you compile your Sway code using the `forc build` command, it generates a b For example, consider the following smart contract: -<<< @/../../docs-snippets/test/fixtures/forc-projects/echo-values/src/main.sw#understanding-fuel-binary-file{ts:line-numbers} +<<< @/../../docs-snippets2/sway/echo-values/src/main.sw#understanding-fuel-binary-file{ts:line-numbers} After running `forc build`, a binary file will be generated with the following content: diff --git a/apps/docs/src/guide/contracts/using-different-wallets.md b/apps/docs/src/guide/contracts/using-different-wallets.md index 94d8185849f..5c6bfe4b249 100644 --- a/apps/docs/src/guide/contracts/using-different-wallets.md +++ b/apps/docs/src/guide/contracts/using-different-wallets.md @@ -6,7 +6,7 @@ This guide demonstrates how to make contract calls using different wallets and p To change the wallet associated with a contract instance, assign a new wallet to the instance's `account` property. This allows you to make contract calls with different wallets in a concise manner: -<<< @/../../docs-snippets/src/guide/contracts/calls-with-different-wallets.test.ts#calls-with-different-wallets-1{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/utilities/using-different-wallet.ts#using-different-wallet{ts:line-numbers} ## Changing Providers diff --git a/apps/docs/src/guide/contracts/variable-outputs.md b/apps/docs/src/guide/contracts/variable-outputs.md index cfcc8520aca..912e67f9b08 100644 --- a/apps/docs/src/guide/contracts/variable-outputs.md +++ b/apps/docs/src/guide/contracts/variable-outputs.md @@ -8,7 +8,7 @@ For instance, if a contract function calls a Sway transfer function 3 times, it ## Example: Sway functions that requires `Output Variable` -<<< @/../../docs-snippets/test/fixtures/forc-projects/token/src/main.sw#variable-outputs-1{ts:line-numbers} +<<< @/../../docs-snippets2/sway/token/src/main.sw#variable-outputs-1{ts:line-numbers} ## Adding Variable Outputs to the contract call @@ -16,7 +16,7 @@ When your contract invokes any of these functions, or if it calls a function tha This can be done as shown in the following example: -<<< @/../../docs-snippets/src/guide/contracts/variable-outputs.test.ts#variable-outputs-2{ts:line-numbers} +<<< @/../../docs-snippets2/src/contracts/utilities/variable-outputs.ts#variable-outputs-2{ts:line-numbers} In the TypeScript SDK, the Output Variables are automatically added to the transaction's list of outputs. diff --git a/packages/fuel-gauge/src/storage-test-contract.test.ts b/packages/fuel-gauge/src/storage-test-contract.test.ts index f428fcdfa82..f34b4ef0c45 100644 --- a/packages/fuel-gauge/src/storage-test-contract.test.ts +++ b/packages/fuel-gauge/src/storage-test-contract.test.ts @@ -17,9 +17,6 @@ describe('StorageTestContract', () => { const { storageSlots } = StorageTestContract; - // #region contract-deployment-storage-slots - // #context import storageSlots from '../your-sway-project/out/debug/your-sway-project-storage_slots.json'; - const factory = new ContractFactory( StorageTestContractFactory.bytecode, StorageTestContract.abi, @@ -30,7 +27,6 @@ describe('StorageTestContract', () => { }); const { contract } = await deploy.waitForResult(); - // #endregion contract-deployment-storage-slots // Call contract const call1 = await contract.functions.initialize_counter(1300).call(); @@ -61,7 +57,6 @@ describe('StorageTestContract', () => { StorageTestContract.abi, wallet ); - // #region contract-deployment-storage-slots-inline const { waitForResult } = await factory.deploy({ storageSlots: [ { @@ -87,7 +82,7 @@ describe('StorageTestContract', () => { ], }); const { contract } = await waitForResult(); - // #endregion contract-deployment-storage-slots-inline + const call1 = await contract.functions.initialize_counter(1300).call(); const { value: initializeResult } = await call1.waitForResult(); expect(initializeResult.toHex()).toEqual(toHex(1300));