Skip to content

Commit

Permalink
Merge branch 'master' of github.com:FuelLabs/fuels-ts into db/chore/d…
Browse files Browse the repository at this point in the history
…ep-pinning-audit
  • Loading branch information
petertonysmith94 committed Jan 2, 2025
2 parents ec5e1ad + 4ccc628 commit 34a1fef
Show file tree
Hide file tree
Showing 73 changed files with 687 additions and 930 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-lies-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fuels": patch
---

docs: improving getting started docs for `mainnet`
5 changes: 5 additions & 0 deletions .changeset/clever-bikes-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

chore: bumped `@fuels/*` deps to `0.36.1`
5 changes: 5 additions & 0 deletions .changeset/orange-moles-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/abi-coder": patch
---

fix: validation and handling of unsafe integers
8 changes: 8 additions & 0 deletions .changeset/small-plums-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@fuel-ts/address": minor
"@fuel-ts/errors": patch
"@fuel-ts/recipes": patch
"@fuel-ts/logger": minor
---

chore!: remove Bech32 address
7 changes: 1 addition & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,7 @@ During the CI process an automated end-to-end (e2e) test is executed. This test
The e2e test can be found at:
`packages/fuel-gauge/src/e2e-script.test.ts`

The Bech32 address of this wallet is `fuel1x33ajpj0jy5p2wcqqu45e32r75zrwfeh6hwqfv5un670rv4p0mns58enjg`. This address can be funded via the [faucet](https://faucet-testnet.fuel.network/).

> [!NOTE] Note
> `Bech32` addresses like `fuel1..` are now deprecated. Use `B256` addresses instead. ([help](https://docs.fuel.network/docs/specs/abi/argument-encoding/#b256))
The B256 address of this wallet is `0x3463d9064f9128153b00072b4cc543f504372737d5dc04b29c9ebcf1b2a17ee7`. This address can be funded via the [faucet](https://faucet-testnet.fuel.network/).

If you want to run an e2e test locally, you can provide your own wallet address and private key. For obvious security reasons, the private key should not be shared.

Expand All @@ -270,8 +267,6 @@ This will enable you to run the e2e test locally against the live network:
pnpm test:filter e2e-script
```

<!-- TODO: add/fix block explorer URL after testnet support- Checking Wallet Balance: https://fuellabs.github.io/block-explorer-v2/beta-5/?#/address/fuel1x33ajpj0jy5p2wcqqu45e32r75zrwfeh6hwqfv5un670rv4p0mns58enjg -->

# Commit Convention

Before you create a Pull Request, please check whether your commits comply with
Expand Down
139 changes: 77 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,107 @@
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/FuelLabs/fuels-ts/master/apps/docs/src/public/fuels-ts-logo-dark.png">
<img alt="Fuels-ts SDK logo" width="400px" src="https://raw.githubusercontent.com/FuelLabs/fuels-ts/master/apps/docs/src/public/fuels-ts-logo-light.png">
</picture>
# fuels-ts

**fuels-ts** is a library for interacting with **Fuel v2**.
Typescript SDK for Fuel.

[![test](https://github.com/FuelLabs/fuels-ts/actions/workflows/test.yaml/badge.svg)](https://github.com/FuelLabs/fuels-ts/actions/workflows/test.yaml)
[![npm](https://img.shields.io/npm/v/fuels)](https://www.npmjs.com/package/fuels)
[![docs](https://img.shields.io/badge/docs-fuels.ts-brightgreen.svg?style=flat)](https://docs.fuel.network/docs/fuels-ts/)
[![npm](https://img.shields.io/npm/v/fuels)](https://www.npmjs.com/package/fuels)
[![discord](https://img.shields.io/badge/chat%20on-discord-orange?&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xfpK4Pe)

# Resources

The [documentation](https://docs.fuel.network/docs/fuels-ts/) site is your main stop for resources.
# Install ([docs](https://docs.fuel.network/docs/fuels-ts/getting-started/installation))

- [Quickstart](https://docs.fuel.network/docs/intro/quickstart-contract/)
- [Documentation](https://docs.fuel.network/docs/fuels-ts/)
- [Wallets](https://docs.fuel.network/docs/fuels-ts/wallets/)
- [Contracts](https://docs.fuel.network/docs/fuels-ts/contracts/)
- [Scripts](https://docs.fuel.network/docs/fuels-ts/scripts/)
- [Predicates](https://docs.fuel.network/docs/fuels-ts/predicates/)
- [ABI Typegen](https://docs.fuel.network/docs/fuels-ts/fuels-cli/abi-typegen/)
- [Contributing](https://github.com/FuelLabs/fuels-ts/blob/master/CONTRIBUTING.md)
- [The Fuel Forum](https://forum.fuel.network/)
- [The Fuel Ecosystem](#the-fuel-ecosystem)

# Install

```sh
```console
npm install fuels --save
```

> If you are a Windows user, you will need to be running Windows Subsystem for Linux (WSL) to install and use the Fuel toolchain, including the TypeScript SDK. We don't support Windows natively at this time.
# Connect ([docs](https://docs.fuel.network/docs/fuels-ts/getting-started/connecting-to-the-network/))

# Import

Simple example usages.
| Network | URL |
| --------- | --------------------------------------------------------------------------------------------------------------- |
| Mainnet | `https://mainnet.fuel.network/v1/graphql` |
| Testnet | `https://testnet.fuel.network/v1/graphql` |
| Localhost | [Running a local Fuel node](https://docs.fuel.network/docs/fuels-ts/getting-started/running-a-local-fuel-node/) |

```ts
import { Wallet } from "fuels";
import { Provider } from 'fuels';

// Random Wallet
console.log(Wallet.generate());
const NETWORK_URL = 'https://mainnet.fuel.network/v1/graphql';

// Using privateKey Wallet
console.log(new Wallet("0x0000...0000"));
```
const provider = await Provider.create(NETWORK_URL);

# CLI
const chainId = provider.getChainId();
const gasConfig = provider.getGasConfig();
const baseAssetId = provider.getBaseAssetId();

Fuels include some utility commands via built-in CLI tool.
console.log({ chainId, gasConfig, baseAssetId });
```

Check the [docs](https://docs.fuel.network/docs/fuels-ts/) for more info.
# Create a new dApp ([docs](https://docs.fuel.network/docs/fuels-ts/creating-a-fuel-dapp/))

```console
$ npm add fuels
$ npx fuels --help
Usage: fuels [options] [command]
$ npm create fuels

◇ What is the name of your project? #
│ my-fuel-project

⚡️ Success! Created a fullstack Fuel dapp at: my-fuel-project.
```

Options:
-D, --debug Enables verbose logging (default: false)
-S, --silent Omit output messages (default: false)
-v, --version Output the version number
-h, --help Display help
# Enjoy the `fuels` CLI ([docs](https://docs.fuel.network/docs/fuels-ts/fuels-cli/))

```console
$ npm install fuels --save
$ npm fuels --help

Commands:
init [options] Create a sample `fuel.config.ts` file
node [options] Start a Fuel node
dev [options] Start a Fuel node and run build + deploy on every file change
build [options] Build Sway programs and generate Typescript for them
deploy [options] Deploy contracts to the Fuel network
typegen [options] Generate Typescript from Sway ABI JSON files
versions Check for version incompatibilities
help [command] Display help for command
init [options] Create a sample `fuel.config.ts` file
build [options] Build Sway programs and generate Typescript for them
deploy [options] Deploy contracts to the Fuel network
dev [options] Start a Fuel node with hot-reload capabilities
node [options] Start a Fuel node using project configs
typegen [options] Generate Typescript from Sway ABI JSON files
versions [options] Check for version incompatibilities
help [command] Display help for command
```

# The Fuel Ecosystem
In-depth docs:
- [`fuels init`](https://docs.fuel.network/docs/fuels-ts/fuels-cli/commands#fuels-init) — Creates a new `fuels.config.ts` file
- [`fuels build`](https://docs.fuel.network/docs/fuels-ts/fuels-cli/commands#fuels-build) — Build `forc` workspace and generate Typescript types for everything
- [`fuels deploy`](https://docs.fuel.network/docs/fuels-ts/fuels-cli/commands#fuels-deploy) — Deploy workspace contracts and save their IDs to JSON file
- [`fuels dev`](https://docs.fuel.network/docs/fuels-ts/fuels-cli/commands#fuels-dev) — Start a Fuel node with hot-reload capabilities


# Official Docs

- Install The Fuel Toolchain — https://docs.fuel.network/guides/installation/
---
- Typescript SDK — https://docs.fuel.network/docs/fuels-ts
- Fuel Wallet SDK — https://docs.fuel.network/docs/wallet
- Rust SDK — https://docs.fuel.network/docs/fuels-rs
- GraphQL Playground — https://docs.fuel.network/docs/graphql
---
- Forc — https://docs.fuel.network/docs/forc
- Sway — https://docs.fuel.network/docs/sway
- Fuel Core — https://github.com/FuelLabs/fuel-core
- Fuel VM — https://docs.fuel.network/docs/specs/fuel-vm
- Fuel Specs — https://docs.fuel.network/docs/specs

# Apps & Ecosystem

- Fuel Bridge — https://app.fuel.network/bridge
- Block Explorer — https://app.fuel.network
- Ecosystem Apps — https://app.fuel.network/ecosystem

# Get in Touch

- `Forum`https://forum.fuel.network
- `Discord`https://discord.gg/xfpK4Pe


# Contribute

Learn more about the Fuel Ecosystem.
- [./CONTRIBUTING.md](https://github.com/FuelLabs/fuels-ts/blob/master/CONTRIBUTING.md)

- [🌴 Sway](https://docs.fuel.network/docs/sway/) — The new language, empowering everyone to build reliable and efficient smart contracts
- [🧰 Forc](https://docs.fuel.network/docs/forc/) — The Fuel toolbox: _Build, deploy and manage your sway projects_
- [⚙️ Fuel Core](https://github.com/FuelLabs/fuel-core) — The new FuelVM, a blazingly fast blockchain VM
- [🔗 Fuel Specs](https://github.com/FuelLabs/fuel-specs) — The Fuel protocol specifications
- [💼 Fuels Wallet](https://github.com/FuelLabs/fuels-wallet) — The Official Fuels Wallet
- [🦀 Rust SDK](https://github.com/FuelLabs/fuels-rs) — A robust SDK in rust
- [⚡ Fuel Network](https://fuel.network/) — The project
- [📚 The Fuel Forum](https://forum.fuel.network/) — Ask questions, get updates, and contribute to a modular future

# License

Expand Down
4 changes: 2 additions & 2 deletions apps/create-fuels-counter-guide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"postbuild": "run-s fuels:build original:build"
},
"dependencies": {
"@fuels/connectors": "0.27.1",
"@fuels/react": "0.27.1",
"@fuels/connectors": "0.36.1",
"@fuels/react": "0.36.1",
"@tanstack/react-query": "5.55.4",
"clsx": "2.1.1",
"@wagmi/connectors": "5.1.14",
Expand Down
3 changes: 2 additions & 1 deletion apps/create-fuels-counter-guide/src/lib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const isTestnet = environment === environments.TESTNET;
export const localProviderUrl = `http://127.0.0.1:${process.env.VITE_FUEL_NODE_PORT || 4000}/v1/graphql`;
export const testnetProviderUrl = 'https://testnet.fuel.network/v1/graphql';
export const providerUrl = isLocal ? localProviderUrl : testnetProviderUrl;
export const chainId = 0; // Local and testnet are both on chain 0
export const playgroundUrl = providerUrl.replace('v1/graphql', 'v1/playground');

// #region deploying-dapp-to-testnet-frontend-contract-id
Expand All @@ -28,7 +29,7 @@ export const renderTransactionId = (transactionId: string) => {

return (
<a
href={`https://app.fuel.network/tx/${transactionId}/simple`}
href={`https://app-testnet.fuel.network/tx/${transactionId}/simple`}
target="_blank"
rel="noreferrer"
className="underline"
Expand Down
10 changes: 6 additions & 4 deletions apps/create-fuels-counter-guide/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { FuelProvider } from "@fuels/react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { ToastContainer } from "react-toastify";
import { Provider } from "fuels";
import { Network, Provider } from "fuels";

import App from "./App.tsx";
import { providerUrl } from "./lib.tsx";
import { chainId, providerUrl } from "./lib.tsx";

import "react-toastify/dist/ReactToastify.css";
import "./index.css";
Expand All @@ -16,13 +16,15 @@ const queryClient = new QueryClient();

const connectors = defaultConnectors({
devMode: true,
burnerWalletConfig: { fuelProvider: Provider.create(providerUrl) },
fuelProvider: Provider.create(providerUrl),
});

const networks: Network[] = [{ url: providerUrl, chainId }];

createRoot(document.getElementById("root")!).render(
<StrictMode>
<QueryClientProvider client={queryClient}>
<FuelProvider theme="dark" fuelConfig={{ connectors }}>
<FuelProvider theme="dark" fuelConfig={{ connectors }} networks={networks}>
<App />
<ToastContainer theme="dark" />
</FuelProvider>
Expand Down
4 changes: 2 additions & 2 deletions apps/demo-wallet-sdk-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"lint": "next lint"
},
"dependencies": {
"@fuels/connectors": "0.27.1",
"@fuels/react": "0.27.1",
"@fuels/connectors": "0.36.1",
"@fuels/react": "0.36.1",
"@tanstack/react-query": "5.55.4",
"fuels": "workspace:*",
"next": "14.2.15",
Expand Down
24 changes: 12 additions & 12 deletions apps/docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,24 @@ export default defineConfig({
link: '/guide/getting-started/installation',
},
{
text: 'Usage',
link: '/guide/getting-started/usage',
text: 'Connecting to the Network',
link: '/guide/getting-started/connecting-to-the-network',
},
{
text: 'Connecting to Testnet',
link: '/guide/getting-started/connecting-to-testnet',
text: 'Running a local Fuel node',
link: '/guide/getting-started/running-a-local-fuel-node',
},
{
text: 'Connecting to a Local Node',
link: '/guide/getting-started/connecting-to-a-local-node',
text: 'React Example',
link: '/guide/getting-started/react-example',
},
{
text: 'Further Resources',
link: '/guide/getting-started/further-resources',
text: 'CDN Usage',
link: '/guide/getting-started/cdn-usage',
},
{
text: 'Next Steps',
link: '/guide/getting-started/next-steps',
},
],
},
Expand Down Expand Up @@ -483,10 +487,6 @@ export default defineConfig({
text: 'Asset Id',
link: '/guide/types/asset-id',
},
{
text: 'Bech32',
link: '/guide/types/bech32',
},
{
text: 'Bits256',
link: '/guide/types/bits256',
Expand Down
1 change: 0 additions & 1 deletion apps/docs/spell-check-custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ backends
backoff
backtrace
backtraces
Bech
BigNumber
Bitfield
bitmask
Expand Down
7 changes: 2 additions & 5 deletions apps/docs/src/guide/contracts/managing-deployed-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ To interact with a deployed contract using the SDK without redeploying it, you o

The `contractId` property from the [`Contract`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_program.Contract.html) class is of type [`AbstractAddress`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html), an abstract class that is exclusively extended by the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class.

The [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class wraps all methods from the [`AbstractAddress`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html) class and adds a single property: `bech32Address`. This property is a string encoded in [`Bech32`](../types/bech32.md) format, recognizable by the human-readable prefix `fuel` followed by the separator `1`.

> [!NOTE] Note
> `Bech32` addresses like `fuel1..` are now deprecated; please switch to B256 format, for more details see [here](https://docs.fuel.network/docs/specs/abi/argument-encoding/#b256).
The [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class wraps all methods from the [`AbstractAddress`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html) class and adds a single property: `b256Address`. This property is a string encoded in [`B256`](../types/bits256.md) format.

When you log the `contractId` property of an instantiated Contract using `console.log`, the output appears as follows:

```console
Address {
bech32Address: 'fuel1e5tdjlzufcvwut5dvs5yglweepmrevpnvuvt2djj6pyl3mygkwaq8m7f20'
b256Address: '0xcd16d97c5c4e18ee2e8d6428447dd9c8763cb0336718b53652d049f8ec88b3ba'
}
```

Expand Down
6 changes: 5 additions & 1 deletion apps/docs/src/guide/fuels-cli/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ The `fuels dev` command does three things:
npx fuels@{{fuels}} node
```

The `fuels node` command starts a short-lived `fuel-core` node ([docs](./config-file.md#autostartfuelcore)).
Starts a short-lived `fuel-core` node and requires a `fuels.config.ts` config file.

Generate one with [`fuels init`](#fuels-init):

<<< @/../../demo-fuels/fuels.config.minimal.ts#config{ts:line-numbers}

## `fuels typegen`

Expand Down
Loading

0 comments on commit 34a1fef

Please sign in to comment.