Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make packages usable locally #984

Merged
merged 62 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
fc80492
Adding new workspace for tooling stuff
arboleya May 5, 2023
d439486
Re-configuring `tsup.config.ts` and `package.json` for all packages
arboleya May 5, 2023
e7b042f
Fixing broken mock
arboleya May 5, 2023
5e91d01
Adding simple TODO
arboleya May 5, 2023
fabc541
Updating lock file
arboleya May 5, 2023
955c40c
Adding changeset
arboleya May 5, 2023
a2dbdc2
Renaming workspace
arboleya May 5, 2023
82f1e11
Using Typescript for internal package
arboleya May 5, 2023
8457e2a
Building package ahead of time for early availability
arboleya May 5, 2023
f55ff50
Merging with master
arboleya May 5, 2023
0705762
Docs
arboleya May 5, 2023
3f81569
Enabling pr release
arboleya May 5, 2023
02762ef
Adjusting dependencies split
arboleya May 5, 2023
3091491
Updating lock file
arboleya May 5, 2023
9bb81d1
Re-stitching internal dependencies
arboleya May 5, 2023
4277a96
Adjusting tsup configs for `forc-bin`
arboleya May 5, 2023
3ce4181
Merge remote-tracking branch 'origin/master' into aa/feat/make-packag…
arboleya May 5, 2023
ae476a3
Lintfix
arboleya May 5, 2023
9ab72b3
Configuring `nodemon` for optimal file-watch performance
arboleya May 5, 2023
9efdd8a
Sorting
arboleya May 5, 2023
6e4a5f4
Docs
arboleya May 5, 2023
932cf2a
DRY tsup config for `fuels`
arboleya May 5, 2023
8f98342
Merge branch 'master' into aa/feat/make-packages-usable-locally
arboleya May 8, 2023
e8f2ce4
Moving commands from external script to `package.json`
arboleya May 8, 2023
abdc0aa
Re-configuring newly added `utils` package
arboleya May 8, 2023
a6423c6
Referencing bin directly (symlink is broken at first execution)
arboleya May 8, 2023
5fe8d3c
Fixing workflow, ensuring only the first regex match is used (head -1)
arboleya May 8, 2023
d7a87a2
Merge branch 'master' into aa/feat/make-packages-usable-locally
arboleya May 9, 2023
5b565aa
Improving docs
arboleya May 10, 2023
bdefdd4
Merge branch 'master' into aa/feat/make-packages-usable-locally
arboleya May 10, 2023
59651da
Turning off PR auto-release
arboleya May 10, 2023
9fbd944
Update CONTRIBUTING.md
arboleya May 11, 2023
5568562
Resetting docker env before (and after) running tests
arboleya May 11, 2023
14082fa
Better organizing scripts
arboleya May 11, 2023
b31c50f
Merge branch 'master' into aa/feat/make-packages-usable-locally
arboleya May 11, 2023
4272721
Marking package as a core module (installed on the monorepo root)
arboleya May 11, 2023
80ca770
Fixing binary path
arboleya May 11, 2023
2733db3
Publishing a new PR version
arboleya May 11, 2023
d3d5600
Merging with master
arboleya May 11, 2023
8d823a6
Fixing residual merge problems (using `tsx`).
arboleya May 11, 2023
4dd64db
Merge branch 'master' into aa/feat/make-packages-usable-locally
arboleya May 11, 2023
fa6bf6d
Merge branch 'aa/feat/make-packages-usable-locally' of github.com:Fue…
arboleya May 11, 2023
75da28a
Disabling PR auto-publish
arboleya May 11, 2023
755beb0
Merge branch 'master' into aa/feat/make-packages-usable-locally
arboleya May 12, 2023
0fa46e9
Merge branch 'master' into aa/feat/make-packages-usable-locally
arboleya May 15, 2023
04a4b31
Merging with master
arboleya May 18, 2023
1ba46c0
Merging with master
arboleya May 19, 2023
ea65535
Enabling PR auto-publish
arboleya May 19, 2023
ac84689
Disabling PR auto-publish
arboleya May 19, 2023
d940a9c
Merge branch 'master' into aa/feat/make-packages-usable-locally
arboleya May 22, 2023
e4f9ce3
Merge branch 'master' into aa/feat/make-packages-usable-locally
arboleya May 23, 2023
7ef1364
Merge branch 'master' into aa/feat/make-packages-usable-locally
arboleya May 25, 2023
6623a50
Merging with master
arboleya May 26, 2023
5c2948d
Fixing broken link
arboleya May 26, 2023
058a328
Merging with master
arboleya May 26, 2023
110e7fa
Re-adding lost `nodemon` dep after merge conflicts
arboleya May 26, 2023
47bd051
Docs
arboleya May 26, 2023
8a8a672
Enabling PR auto-publish
arboleya May 26, 2023
fa8cf36
Disabling PR auto-publish
arboleya May 26, 2023
1b89cb2
Merge branch 'master' into aa/feat/make-packages-usable-locally
arboleya May 29, 2023
9e427f9
Merge branch 'master' into aa/feat/make-packages-usable-locally
arboleya May 29, 2023
74b6b08
Merge branch 'master' into aa/feat/make-packages-usable-locally
arboleya May 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .changeset/slimy-drinks-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
"@fuel-ts/abi-coder": minor
"@fuel-ts/abi-typegen": minor
"@fuel-ts/address": minor
"@fuel-ts/contract": minor
"forc-bin": minor
"fuels": minor
"@fuel-ts/hasher": minor
"@fuel-ts/hdwallet": minor
"@fuel-ts/interfaces": minor
"@fuel-ts/keystore": minor
"@fuel-ts/math": minor
"@fuel-ts/merkle": minor
"@fuel-ts/merkle-shared": minor
"@fuel-ts/merklesum": minor
"@fuel-ts/mnemonic": minor
"@fuel-ts/predicate": minor
"@fuel-ts/program": minor
"@fuel-ts/providers": minor
"@fuel-ts/script": minor
"@fuel-ts/signer": minor
"@fuel-ts/sparsemerkle": minor
"@fuel-ts/transactions": minor
"@fuel-ts/versions": minor
"@fuel-ts/wallet": minor
"@fuel-ts/wallet-manager": minor
"@fuel-ts/wordlists": minor
---

Revamping all packages configs, enabling local installation
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
],
settings: {
'import/core-modules': ['@internal/tsup'],
jsdoc: {
mode: 'typescript',
},
Expand Down
161 changes: 100 additions & 61 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
## 💚 Contributing To Fuel TypeScript SDK
# Contributing To Fuel TypeScript SDK

Thanks for your interest in contributing to the Fuel TypeScript SDK! This document outlines the process for installing dependencies, setting up for development, and conventions for contributing.
Thanks for your interest in contributing to the Fuel TypeScript SDK!

## Finding Something to Work On
This document outlines the process for installing dependencies, setting up for development and conventions for contributing.

# Finding Something to Work On

There are many ways in which you may contribute to the project, some of which involve coding knowledge and some which do not. A few examples include:

Expand All @@ -14,7 +16,7 @@ Check out our [Help Wanted](https://github.com/FuelLabs/fuels-ts/issues?q=is%3Ao

If you are planning something big, for example, changes related to multiple components or changes to current behaviors, make sure to [open an issue](https://github.com/FuelLabs/fuels-ts/issues/new) to discuss with us before starting on the implementation.

### Setup
# Setting up

```sh
git clone git@github.com:FuelLabs/fuels-ts.git
Expand All @@ -23,9 +25,76 @@ pnpm install
pnpm build
```

## Testing
# Developing

For building everything in watch-mode, run:

```sh
# build all projects in watch-mode
pnpm dev
```

File watching is done by `nodemon` for increased performance.

Check `nodemon.config.json` for all settings.

> **Note**: You can `pnpm dev` a single package:
>
> ```sh
> cd packages/abi-coder
> pnpm dev
> ```

# Using local sym-linked packages

First, we need to link our `fuels` package globally in our local `global pnpm store`:

```sh
cd fuels-ts/packages/fuels
pnpm link --global
```

Let's check it out:

```sh
pnpm list --global
```

Cool, now on the root directory of `my-local-project`:

```sh
cd my-local-project
pnpm link --global fuels
```

That's it — `my-local-project` is now using our local version of `fuels`.

The same can be done with all other packages:

```sh
cd fuels-ts/packages/wallet
pnpm link --global

# ...

pnpm list --global # validating

# ...

cd my-local-project
pnpm link --global @fuel-ts/wallet
```

> **Warning** When using local symlinked `fuels-ts` in `your-local-project`, remember to `pnpm build` the SDK whenever you change a source file to reflect the changes on `your-local-project`. To automate this, you can use `pnpm dev`, which will keep watching and compiling everything automatically while developing.

See also:

- [Developing](#Developing)

# Testing

In order to run tests locally, you need `fuel-core` running as a docker container.

To do that run this command in your terminal:

```sh
Expand All @@ -37,10 +106,15 @@ And then run the tests in another terminal tab:
```sh
# run all tests
pnpm test
# run tests and get coverage
pnpm test -- --coverage

# run tests while passing other flags to sub-program
pnpm test -- --coverage --my-other-flag

# run tests for a specific package
pnpm --filter @fuel-ts/contract run test
pnpm test packages/my-desired-package

# run tests for a specific file
pnpm test packages/my-desired-package/src/my.test.ts
```

Or if you want to run docker and all tests serially you can do:
Expand All @@ -51,10 +125,10 @@ pnpm ci:test

This will run `services:run`, `test` and then `services:clean`

> The tests may break if you are running your tests locally using`services:run` in a separate terminal.
> The tests may break if you are running your tests locally using `services:run` in a separate terminal.
> To fix this run `services:clean` to clean docker containers and volumes.

## Commit Convention
# Commit Convention

Before you create a Pull Request, please check whether your commits comply with
the commit conventions used in this repository.
Expand All @@ -79,7 +153,7 @@ the following categories:
- `chore`: all changes to the repository that do not fit into any of the above
categories

## Steps to PR
# Steps to PR

1. Fork the fuels-ts repository and clone your fork

Expand All @@ -100,74 +174,39 @@ the following categories:
> `pnpm changeset add --empty` to generate an empty changeset file to document
> your changes.

## Git Hooks
# Git Hooks

The SDK utilizes a pre-push git hook to validate your contribution before review. This is a script that will run automatically before changes are pushed to the remote repository. Within the SDK, the pre-push script will run code linting.

> This can be overridden using the `--no-verify` flag when pushing.

## Build and watch all packages

If you want to work locally using realtime builds, open in one terminal tab build in watch mode
on all packages from the root directory:

```sh
pnpm build:watch
```

This command will run `tsup --watch` on all packages using Turborepo

## Using linked packages

This will link all packages inside our monorepo in your `global pnpm store`, enabling you to use `fuels-ts` packages via links in
your local projects.

### On `fuels-ts` root directory

```sh
pnpm -r exec pnpm link --global --dir ./
```

You can use [build watch](#build-and-watch-all-packages).

### On `your project` root directory

```sh
pnpm link --global fuels
```
# Updating Forc version

Or for specfic packages just use `pnpm link @fuel-ts/<pkg-name>`, ex;
The following script will upgrade Forc to the latest version on GitHub, remove all lockfiles so the latest stdlib can be used, and rebuild all projects:

```sh
pnpm link --global @fuel-ts/wallet
pnpm forc:update
```

### Troubleshooting

If you're linking for the first time, you might need:
After this you should run tests and fix any incompatibilities.

```sh
pnpm setup
```
# Updating Fuel Core version

If it still have problems, you might need to setup again (As `pnpm` releases new version, the global folder structure may change)
Manually edit the `.docker/fuel-core/Dockerfile` file, add the right version, and then:

```sh
pnpm setup
pnpm services:clean # causes rebuilding of the Docker image
pnpm test:ci
arboleya marked this conversation as resolved.
Show resolved Hide resolved
```

## Updating Forc version
If all tests pass, that's it.
arboleya marked this conversation as resolved.
Show resolved Hide resolved

The following script will upgrade Forc to the latest version on GitHub, remove all lockfiles so the latest stdlib can be used, and rebuild all projects:
Otherwise, you have work to do.

```sh
pnpm forc:update
```

After this you should run tests and fix any incompatibilities.

## FAQ
# FAQ

### Why is the prefix `fuels` and not `fuel`?

In order to make the SDK for Fuel feel familiar with those coming from the [ethers.js](https://github.com/ethers-io/ethers.js) ecosystem, this project opted for an `s` at the end. The `fuels-*` family of SDKs is inspired by The Ethers Project.
In order to make the SDK for Fuel feel familiar with those coming from the [ethers.js](https://github.com/ethers-io/ethers.js) ecosystem, this project opted for an `s` at the end.

The `fuels-*` family of SDKs is inspired by The Ethers Project.
75 changes: 31 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,30 @@
[![docs](https://img.shields.io/badge/docs-fuels.ts-brightgreen.svg?style=flat)](https://fuellabs.github.io/fuels-ts/)
[![discord](https://img.shields.io/badge/chat%20on-discord-orange?&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xfpK4Pe)

## Table of contents
# Resources

The [documentation](https://fuellabs.github.io/fuels-ts) site is your main stop for resources.

- [Quickstart](https://fuellabs.github.io/fuel-docs/master/quickstart/developer-quickstart.html)
- [Documentation](https://fuellabs.github.io/fuels-ts)
- [Install](#install)
- [Import](#import)
- [Interacting with Contracts](https://fuellabs.github.io/fuels-ts/guide/contracts/managing-deployed-contracts.html)
- [Generate Types from ABI](https://fuellabs.github.io/fuels-ts/guide/abi-typegen/generating-types-from-abi.html)
- [Using Generated Types](https://fuellabs.github.io/fuels-ts/guide/abi-typegen/using-generated-types.html)
- [Deploying Contracts](https://fuellabs.github.io/fuels-ts/guide/contracts/deploying-contracts)
- [CLI](#cli)
- [Wallets](https://fuellabs.github.io/fuels-ts/guide/wallets/)
- [Contracts](https://fuellabs.github.io/fuels-ts/guide/contracts/)
- [Scripts](https://fuellabs.github.io/fuels-ts/guide/scripts/)
- [Predicates](https://fuellabs.github.io/fuels-ts/guide/predicates/)
- [ABI Typegen](https://fuellabs.github.io/fuels-ts/guide/abi-typegen/)
- [Contributing](https://github.com/FuelLabs/fuels-ts/blob/master/CONTRIBUTING.md)
- [License](#license)

## Quickstart

We recommend starting with the [Quickstart](https://fuellabs.github.io/fuel-docs/master/quickstart/developer-quickstart.html) to speed-up and build your first DApp using Fuel.

- [Other example projects](https://github.com/FuelLabs/sway-applications)

## Documentation

You can find in-depth [usage and examples in our Guide](https://fuellabs.github.io/fuels-ts/guide), or deep-dive into the internals with our detailed [SDK Documentation](https://fuellabs.github.io/fuels-ts).

## The Fuel Ecosystem

Learn more about the Fuel Ecosystem.

- [🌴 Sway](https://fuellabs.github.io/sway/) the new language. Empowering everyone to build reliable and efficient smart contracts.
- [🧰 Forc](https://fuellabs.github.io/sway/v0.30.1/forc/index.html) 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.
- [🦀 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/)
- [The Fuel Ecosystem](#the-fuel-ecosystem)

## Install

#### YARN

```sh
yarn add fuels
```

#### NPM
# Install

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

## Import
# Import

Simple example usages.

```ts
import { Wallet } from "fuels";
Expand All @@ -71,13 +45,13 @@ console.log(Wallet.generate());
console.log(new Wallet("0x0000...0000"));
```

## CLI
# CLI

Fuels include some utility commands via built-in CLI tool.

```console
$ yarn add fuels
$ yarn exec fuels -h
$ npm add fuels
$ npx fuels --help
Usage: fuels [options] [command]

Options:
Expand All @@ -90,6 +64,19 @@ Commands:
help [command] display help for command
```

## License
# The Fuel Ecosystem

Learn more about the Fuel Ecosystem.

- [🌴 Sway](https://fuellabs.github.io/sway/) — The new language, empowering everyone to build reliable and efficient smart contracts
- [🧰 Forc](https://fuellabs.github.io/sway/v0.30.1/forc/index.html) — 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

The primary license for this repo is `Apache 2.0`, see [`LICENSE`](https://github.com/FuelLabs/fuels-ts/blob/master/LICENSE).
Loading
Loading