Skip to content

Commit

Permalink
Merge branch 'master' into mc/chore/upgrade-fuel-core
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Sep 3, 2024
2 parents c92c6ab + b6b83f4 commit afca3d1
Show file tree
Hide file tree
Showing 128 changed files with 1,734 additions and 1,130 deletions.
6 changes: 0 additions & 6 deletions .changeset/fast-bulldogs-hope.md

This file was deleted.

6 changes: 6 additions & 0 deletions .changeset/gentle-files-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fuel-ts/contract": patch
"@fuel-ts/account": patch
---

chore: deprecate `BaseTransactionRequest.fundWithFakeUtxos`
6 changes: 6 additions & 0 deletions .changeset/gorgeous-laws-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fuel-ts/contract": patch
"@fuel-ts/account": patch
---

feat: validate blob IDs against chain in chunk deploys
4 changes: 4 additions & 0 deletions .changeset/lazy-lemons-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

chore: add e2e tests for transaction summary operations
4 changes: 0 additions & 4 deletions .changeset/lazy-teachers-impress.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/light-lizards-help.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/new-rivers-rescue.md

This file was deleted.

4 changes: 4 additions & 0 deletions .changeset/odd-seahorses-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

chore: adding type checking
6 changes: 6 additions & 0 deletions .changeset/rare-shrimps-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fuel-ts/account": patch
"@fuel-ts/errors": patch
---

feat: map 'not enough coins' error
5 changes: 5 additions & 0 deletions .changeset/strong-oranges-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

build(deps): bump the deps-patch group with 9 updates
5 changes: 0 additions & 5 deletions .changeset/stupid-books-pull.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/swift-tools-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/account": patch
---

feat: support basic auth
5 changes: 0 additions & 5 deletions .changeset/tall-hairs-sit.md

This file was deleted.

4 changes: 0 additions & 4 deletions .changeset/wet-hairs-beg.md

This file was deleted.

6 changes: 6 additions & 0 deletions .changeset/wise-deers-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fuel-ts/crypto": patch
"@fuel-ts/errors": patch
---

chore: removed redundant crypto functionality
8 changes: 4 additions & 4 deletions apps/create-fuels-counter-guide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
"@fuels/react": "^0.26.0",
"fuels": "workspace:*",
"@tanstack/react-query": "^5.52.1",
"@wagmi/connectors": "^5.1.7",
"@wagmi/connectors": "^5.1.8",
"@wagmi/core": "^2.13.4",
"dotenv": "^16.4.5",
"next": "14.2.6",
"next": "14.2.7",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hot-toast": "^2.4.1",
"react-use": "^17.5.1"
},
"devDependencies": {
"@types/node": "^22.2.0",
"@types/react": "^18.3.4",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3",
"autoprefixer": "^10.4.20",
"eslint": "^8.57.0",
"eslint-config-next": "14.2.6",
"eslint-config-next": "14.2.7",
"postcss": "^8",
"tailwindcss": "^3.4.10",
"typescript": "~5.4.5"
Expand Down
14 changes: 8 additions & 6 deletions apps/demo-bun-fuels/src/bun.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* It ensures that built code is fully working.
*/

import { toHex, Wallet } from 'fuels';
import { launchTestNode, safeExec } from 'fuels/test-utils';
import { ErrorCode, FuelError, toHex, Wallet } from 'fuels';
import { expectToThrowFuelError, launchTestNode } from 'fuels/test-utils';

import { Sample, SampleFactory } from './sway-programs-api';

Expand Down Expand Up @@ -78,11 +78,13 @@ describe('ExampleContract', () => {

const contractInstance = new Sample(contract.id, unfundedWallet);

const { error } = await safeExec(() =>
contractInstance.functions.return_input(1337).simulate()
await expectToThrowFuelError(
() => contractInstance.functions.return_input(1337).simulate(),
new FuelError(
ErrorCode.NOT_ENOUGH_FUNDS,
`The account(s) sending the transaction don't have enough funds to cover the transaction.`
)
);

expect((<Error>error).message).toMatch('not enough coins to fit the target');
});

it('should not throw when dry running via contract factory with wallet with no resources', async () => {
Expand Down
14 changes: 8 additions & 6 deletions apps/demo-fuels/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* It ensures that built code is fully working.
*/

import { toHex, Wallet } from 'fuels';
import { launchTestNode, safeExec } from 'fuels/test-utils';
import { ErrorCode, FuelError, toHex, Wallet } from 'fuels';
import { expectToThrowFuelError, launchTestNode } from 'fuels/test-utils';

import { SampleFactory, Sample } from './sway-programs-api';

Expand Down Expand Up @@ -71,11 +71,13 @@ describe('ExampleContract', () => {

const contractInstance = new Sample(contract.id, unfundedWallet);

const { error } = await safeExec(() =>
contractInstance.functions.return_input(1337).simulate()
await expectToThrowFuelError(
() => contractInstance.functions.return_input(1337).simulate(),
new FuelError(
ErrorCode.NOT_ENOUGH_FUNDS,
`The account(s) sending the transaction don't have enough funds to cover the transaction.`
)
);

expect((<Error>error).message).toMatch('not enough coins to fit the target');
});

it('should not throw when dry running via contract factory with wallet with no resources', async () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/demo-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"@fuels/vm-asm": "0.56.0",
"@types/node": "^22.2.0",
"@types/react-dom": "^18.3",
"@types/react": "^18.3.4",
"@types/react": "^18.3.5",
"fuels": "workspace:*",
"next": "14.2.6",
"next": "14.2.7",
"react-dom": "^18.3.1",
"react": "^18.3.1",
"typescript": "~5.4.5"
Expand Down
4 changes: 2 additions & 2 deletions apps/demo-react-cra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"private": true,
"dependencies": {
"@fuels/vm-asm": "0.56.0",
"@testing-library/react": "^16.0.0",
"@testing-library/react": "^16.0.1",
"@types/node": "^22.2.0",
"@types/react": "^18.3.4",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3",
"eslint-config-react-app": "^7.0.1",
"fuels": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion apps/demo-react-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"react": "^18.3.1"
},
"devDependencies": {
"@types/react": "^18.3.4",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.21.0",
Expand Down
14 changes: 9 additions & 5 deletions apps/demo-typegen/src/demo.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// #region Testing-in-ts-ts
import { toHex, Address, Wallet } from 'fuels';
import { launchTestNode, safeExec } from 'fuels/test-utils';
import { toHex, Address, Wallet, FuelError, ErrorCode } from 'fuels';
import { expectToThrowFuelError, launchTestNode } from 'fuels/test-utils';

import storageSlots from '../demo-contract/out/release/demo-contract-storage_slots.json';

Expand Down Expand Up @@ -105,9 +105,13 @@ it('should throw when simulating via contract factory with wallet with no resour
const { contract } = await waitForResult();
const contractInstance = new DemoContract(contract.id, unfundedWallet);

const { error } = await safeExec(() => contractInstance.functions.return_input(1337).simulate());

expect((<Error>error).message).toMatch('not enough coins to fit the target');
await expectToThrowFuelError(
() => contractInstance.functions.return_input(1337).simulate(),
new FuelError(
ErrorCode.NOT_ENOUGH_FUNDS,
`The account(s) sending the transaction don't have enough funds to cover the transaction.`
)
);
});

it('should not throw when dry running via contract factory with wallet with no resources', async () => {
Expand Down
6 changes: 3 additions & 3 deletions apps/demo-wallet-sdk-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
"@fuels/react": "^0.26.0",
"@tanstack/react-query": "^5.52.1",
"fuels": "workspace:*",
"next": "14.2.6",
"next": "14.2.7",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/node": "^22.2.0",
"@types/react": "^18.3.4",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3",
"eslint": "^8.57.0",
"eslint-config-next": "14.2.6",
"eslint-config-next": "14.2.7",
"postcss": "^8",
"postcss-load-config": "^6.0.1",
"tailwindcss": "^3.4.10",
Expand Down
5 changes: 3 additions & 2 deletions apps/docs-snippets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"description": "",
"private": true,
"scripts": {
"pretest": "pnpm build:forc",
"build:forc": "pnpm fuels build"
"pretest": "run-s build:forc type:check",
"build:forc": "pnpm fuels build",
"type:check": "tsc --noEmit"
},
"devDependencies": {
"@fuel-ts/account": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
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((<FuelError>error).message)) {
transactionRequest.gasLimit = bn(1000);
// Re-submission will fail
await wallet.sendTransaction(transactionRequest);
}
}
// #endregion resubmitting-failed-transactions-3
}).rejects.toThrow('Transaction is not inserted. UTXO does not exist: 0x');

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((<FuelError>error).message)) {
const transactionRequest2 = await wallet.createTransfer(
recipient.address,
transferAmount,
baseAssetId
);

await wallet.sendTransaction(transactionRequest2);
}
}
// #endregion resubmitting-failed-transactions-4
})()
).resolves.not.toThrow();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('Send and Spend Funds from Predicates', () => {
);

// #region send-and-spend-funds-from-predicates-6
const errorMsg = 'not enough coins to fit the target';
const errorMsg = `The account(s) sending the transaction don't have enough funds to cover the transaction.`;
// #endregion send-and-spend-funds-from-predicates-6

expect((<Error>error).message).toMatch(errorMsg);
Expand Down
1 change: 1 addition & 0 deletions apps/docs-snippets/src/guide/types/arrays.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('Arrays Types', () => {
contracts: [contract],
} = launched;
try {
// @ts-expect-error Will throw error because the array length is not 2
// #region arrays-3
// will throw error because the array length is not 2
await contract.functions.echo_u64_array([10000000]).simulate();
Expand Down
Loading

0 comments on commit afca3d1

Please sign in to comment.