Skip to content

Commit

Permalink
Merge branch 'master' into db/chore/manual-proxy-contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
Torres-ssf authored Oct 22, 2024
2 parents e1c676a + b306b7b commit 4c5f549
Show file tree
Hide file tree
Showing 52 changed files with 3,708 additions and 3,339 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-experts-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

fix: moved `create-fuels` deps for `fuels-ts`
9 changes: 9 additions & 0 deletions .changeset/famous-hornets-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@fuel-ts/contract": patch
"@fuel-ts/account": patch
"@fuel-ts/program": patch
"fuels": patch
"create-fuels": patch
---

build(deps): bump the deps-minor group with 20 updates
4 changes: 4 additions & 0 deletions .changeset/happy-kiwis-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

ci(deps): bump thollander/actions-comment-pull-request from 2 to 3
5 changes: 5 additions & 0 deletions .changeset/honest-jobs-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

build(deps): bump typescript-eslint from 8.5.0 to 8.8.0
4 changes: 4 additions & 0 deletions .changeset/loud-hotels-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

build(deps): bump memfs from 4.11.1 to 4.14.0
8 changes: 8 additions & 0 deletions .changeset/lucky-avocados-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@internal/fuel-core": patch
"@fuel-ts/versions": patch
"@fuel-ts/account": patch
"@fuel-ts/errors": patch
---

chore: upgrading `fuel-core` to `0.40.0`
5 changes: 5 additions & 0 deletions .changeset/popular-seals-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/account": patch
---

feat: implement batch transfer to contracts
5 changes: 5 additions & 0 deletions .changeset/proud-donuts-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

chore: exclude `node_modules` in template tests
4 changes: 4 additions & 0 deletions .changeset/rare-drinks-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

chore: increase benchmark iterations
3 changes: 3 additions & 0 deletions .changeset/selfish-weeks-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
---
ci: add optimized graphql query e2e tests
2 changes: 2 additions & 0 deletions .changeset/thick-geckos-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
10 changes: 5 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ jobs:
run: pnpm test:coverage-diff

- name: Report Coverage
uses: thollander/actions-comment-pull-request@v2
uses: thollander/actions-comment-pull-request@v3
if: ${{ steps.findPr.outputs.number }}
with:
filePath: coverage/report/coverage-diff.txt
pr_number: ${{ (steps.findPr.outputs.number) }}
comment_tag: diff
file-path: coverage/report/coverage-diff.txt
pr-number: ${{ (steps.findPr.outputs.number) }}
comment-tag: diff
mode: recreate
create_if_not_exists: true
create-if-not-exists: true
18 changes: 9 additions & 9 deletions apps/create-fuels-counter-guide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@
"@tanstack/react-query": "^5.55.4",
"clsx": "2.1.1",
"@wagmi/connectors": "^5.1.14",
"@wagmi/core": "^2.13.8",
"@wagmi/core": "^2.13.9",
"dotenv": "^16.4.5",
"fuels": "workspace:*",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-toastify": "^10.0.5"
"react-toastify": "^10.0.6"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-react": "^4.3.3",
"@eslint/js": "^9.10.0",
"@types/node": "^22.5.5",
"@playwright/test": "^1.47.2",
"@types/react": "^18.3.10",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3",
"autoprefixer": "^10.4.20",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.12",
"eslint-plugin-react-refresh": "^0.4.13",
"globals": "^15.9.0",
"postcss": "^8.4.47",
"tailwindcss": "^3.4.12",
"typescript": "~5.6.2",
"typescript-eslint": "^8.5.0",
"vite": "^5.4.8",
"tailwindcss": "^3.4.14",
"typescript": "~5.6.3",
"typescript-eslint": "^8.8.0",
"vite": "^5.4.9",
"vitest": "~2.0.5"
}
}
2 changes: 1 addition & 1 deletion apps/demo-bun-fuels/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"fuels": "workspace:*"
},
"devDependencies": {
"bun": "^1.1.29"
"bun": "^1.1.31"
}
}
8 changes: 4 additions & 4 deletions apps/demo-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"pretest": "pnpm original:build"
},
"dependencies": {
"@fuels/vm-asm": "0.58.0",
"@fuels/vm-asm": "0.58.2",
"@types/node": "^22.5.5",
"@types/react-dom": "^18.3",
"@types/react": "^18.3.10",
"@types/react": "^18.3.11",
"fuels": "workspace:*",
"next": "14.2.13",
"next": "14.2.15",
"react-dom": "^18.3.1",
"react": "^18.3.1",
"typescript": "~5.6.2"
"typescript": "~5.6.3"
}
}
6 changes: 3 additions & 3 deletions apps/demo-react-cra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
"version": "0.1.29",
"private": true,
"dependencies": {
"@fuels/vm-asm": "0.58.0",
"@fuels/vm-asm": "0.58.2",
"@testing-library/react": "^16.0.1",
"@types/node": "^22.5.5",
"@types/react": "^18.3.10",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3",
"eslint-config-react-app": "^7.0.1",
"fuels": "workspace:*",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-scripts": "5.0.1",
"typescript": "~5.6.2",
"typescript": "~5.6.3",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
12 changes: 6 additions & 6 deletions apps/demo-react-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
"pretest": "pnpm original:build"
},
"dependencies": {
"@fuels/vm-asm": "0.58.0",
"@fuels/vm-asm": "0.58.2",
"fuels": "workspace:*",
"react-dom": "^18.3.1",
"react": "^18.3.1"
},
"devDependencies": {
"@types/react": "^18.3.10",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-react": "^4.3.3",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.12",
"typescript": "~5.6.2",
"vite": "^5.4.8"
"eslint-plugin-react-refresh": "^0.4.13",
"typescript": "~5.6.3",
"vite": "^5.4.9"
}
}
10 changes: 5 additions & 5 deletions apps/demo-wallet-sdk-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
"@fuels/react": "^0.27.1",
"@tanstack/react-query": "^5.55.4",
"fuels": "workspace:*",
"next": "14.2.13",
"next": "14.2.15",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/node": "^22.5.5",
"@types/react": "^18.3.10",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3",
"eslint": "^8.57.0",
"eslint-config-next": "14.2.13",
"eslint-config-next": "14.2.15",
"postcss": "^8.4.47",
"postcss-load-config": "^6.0.1",
"tailwindcss": "^3.4.12",
"typescript": "~5.6.2"
"tailwindcss": "^3.4.14",
"typescript": "~5.6.3"
}
}
2 changes: 1 addition & 1 deletion apps/docs-snippets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@fuel-ts/account": "workspace:*",
"@fuel-ts/errors": "workspace:*",
"@fuel-ts/utils": "workspace:*",
"ethers": "^6.13.2",
"ethers": "^6.13.4",
"fuels": "workspace:*",
"vitest": "~2.0.5"
},
Expand Down
68 changes: 58 additions & 10 deletions apps/docs-snippets/src/guide/cookbook/transferring-assets.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Address, BN, Wallet } from 'fuels';
import { launchTestNode } from 'fuels/test-utils';
import type { ContractTransferParams, ReceiptTransfer } from 'fuels';
import { BN, ReceiptType, Wallet } from 'fuels';
import { launchTestNode, TestAssetId } from 'fuels/test-utils';

import { CounterFactory } from '../../../test/typegen';
import { CounterFactory, TokenFactory } from '../../../test/typegen';

/**
* @group node
Expand Down Expand Up @@ -111,7 +112,7 @@ describe('Transferring Assets', () => {
// #endregion transferring-assets-3
});

it('should successfully prepare transfer transaction request', async () => {
it('should successfully transfer to contract', async () => {
using launched = await launchTestNode({
contractsConfigs: [
{
Expand All @@ -124,25 +125,72 @@ describe('Transferring Assets', () => {
wallets: [sender],
contracts: [deployedContract],
} = launched;
const contractId = Address.fromAddressOrString(deployedContract.id);
// #region transferring-assets-4
// #import { Wallet, BN };

// #context const senderWallet = Wallet.fromPrivateKey('...');
// #context const sender = Wallet.fromPrivateKey('...');

const amountToTransfer = 400;
const assetId = provider.getBaseAssetId();
// #context const contractId = Address.fromAddressOrString('0x123...');
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);

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);
});
});
57 changes: 57 additions & 0 deletions apps/docs-snippets2/src/cookbook/combining-utxos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// #region combining-utxos
import { Provider, Wallet } from 'fuels';

import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../env';

const provider = await Provider.create(LOCAL_NETWORK_URL);
const fundingWallet = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider);

const wallet = Wallet.generate({ provider });

// First, lets fund a wallet with 10_000 of the base asset. But as we are doing this across 10 transactions,
// we will end up with 10 UTXOs.
for (let i = 0; i < 10; i++) {
const initTx = await fundingWallet.transfer(
wallet.address,
1000,
provider.getBaseAssetId()
);
await initTx.waitForResult();
}

// We can fetch the coins to see how many UTXOs we have, and confirm it is 10.
const { coins: initialCoins } = await wallet.getCoins(
provider.getBaseAssetId()
);
console.log('Initial Coins Length', initialCoins.length);
// 10

// But we can also confirm the total balance of the base asset for this account is 10_000.
const initialBalance = await wallet.getBalance(provider.getBaseAssetId());
console.log('Initial Balance', initialBalance.toNumber());
// 10_000

// Now we can combine the UTXOs into a single UTXO by performing a single transfer for the
// majority of the balance. Of course, we will still need some funds for the transaction fees.
const combineTx = await wallet.transfer(
wallet.address,
9500,
provider.getBaseAssetId()
);
await combineTx.wait();

// Now we can perform the same validations and see we have less UTXOs.
// We have 2 in this instance, as we have performed the transfer in the base asset:
// a UTXO for our transfer, and another for what is left after paying the fees.
const { coins: combinedCoins } = await wallet.getCoins(
provider.getBaseAssetId()
);
console.log('Combined Coins Length', combinedCoins.length);
// 2

// And we can also confirm the final balance of the base asset for this account is 9_998,
// so the cost of combining is also minimal.
const combinedBalance = await wallet.getBalance(provider.getBaseAssetId());
console.log('Combined Balance', combinedBalance.toNumber());
// 9_998
// #endregion combining-utxos
Loading

0 comments on commit 4c5f549

Please sign in to comment.