Skip to content

Commit

Permalink
feat: upgrade fuels-ts to 0.83 (#72)
Browse files Browse the repository at this point in the history
Fixes #71 
- Upgrade fuels-ts to 0.83
- Fix error on sequential builds in `test-utils` leading to failure to
overwrite type declarations
<img width="1523" alt="Screenshot 2024-04-30 at 10 25 52"
src="https://github.com/FuelLabs/fuels-npm-packs/assets/3487334/4d5bbb77-e6d8-413c-bf94-b9def8177fe6">

---------

Co-authored-by: LuizAsFight <felipebolsonigomes@gmail.com>
  • Loading branch information
arthurgeron and LuizAsFight authored May 7, 2024
1 parent 9e789fc commit 753b7e9
Show file tree
Hide file tree
Showing 12 changed files with 4,803 additions and 6,811 deletions.
6 changes: 6 additions & 0 deletions .changeset/forty-lamps-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@fuels/playwright-utils': minor
'@fuels/react': minor
---

Upgrade to testnet (fuel-core 0.26.0 + fuels-ts 0.84.0)
6 changes: 6 additions & 0 deletions .changeset/ten-chicken-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@fuels/playwright-utils': minor
'@fuels/react': minor
---

Upgraded fuels-ts to new minor 0.83.0
49 changes: 49 additions & 0 deletions .github/workflows/pr-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release to @pr-<number> tag on npm
on:
pull_request:
workflow_dispatch:

jobs:
release-pr:
name: 'Release PR to npm'
runs-on: buildjet-4vcpu-ubuntu-2204
# comment out if:false to enable release PR to npm
if: false
permissions: write-all
steps:
- uses: actions/checkout@v3
with:
# need this to get full git-history/clone in order to build changelogs and check changesets
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}

- uses: FuelLabs/github-actions/setups/node@master
with:
pnpm-version: 8.x.x
- uses: FuelLabs/github-actions/setups/npm@master
with:
npm-token: ${{ secrets.NPM_TOKEN }}

- name: Build
run: pnpm build

- name: Release to @pr-${{ github.event.pull_request.number }} tag on npm
id: release
run: |
pnpm changeset:next
git add .changeset/fuel-labs-ci.md
pnpm changeset version --snapshot pr-${{ env.PR_NUMBER }}
changetsets=$(pnpm changeset publish --tag pr-${{ env.PR_NUMBER }})
published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-pr-${{ env.PR_NUMBER }}-\d+' | head -1)
echo "published_version=$published_version" >> $GITHUB_OUTPUT
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}

- uses: mshick/add-pr-comment@v2
with:
message: |
This PR is published in NPM with version **${{ steps.release.outputs.published_version }}**
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 8 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
fetch-depth: 0

- uses: FuelLabs/github-actions/setups/node@master
with:
pnpm-version: 8.x.x
- run: pnpm changeset:check

audit:
Expand All @@ -54,6 +56,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: FuelLabs/github-actions/setups/node@master
with:
pnpm-version: 8.x.x
- run: pnpm audit --prod

lint-build:
Expand All @@ -62,6 +66,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: FuelLabs/github-actions/setups/node@master
with:
pnpm-version: 8.x.x
- run: |
pnpm lint
pnpm build
Expand All @@ -72,6 +78,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: FuelLabs/github-actions/setups/node@master
with:
pnpm-version: 8.x.x
- name: Checking PR Number
uses: jwalton/gh-find-current-pr@v1
id: findPr
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"build:watch": "pnpm -r --parallel build --watch",
"changeset": "changeset",
"changeset:check": "changeset status --since=origin/main",
"changeset:next": "tsx ./scripts/changeset-next",
"changeset:release": "changeset publish --no-git-tag",
"changeset:version": "changeset version",
"deps:update": "updates -gu && pnpm -r exec updates -gu",
Expand Down Expand Up @@ -55,6 +56,7 @@
"prettier": "^3.0.3",
"ts-node": "^10.9.1",
"tsup": "^7.2.0",
"tsx": "^4.7.3",
"turbo": "^1.10.13",
"typescript": "5.4.2",
"updates": "^14.5.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"peerDependencies": {
"@tanstack/react-query": ">=5.0.0",
"fuels": ">=0.74.0",
"fuels": ">=0.84.0",
"react": "^18.2.0"
},
"dependencies": {
Expand All @@ -38,7 +38,7 @@
"@fuels/tsup-config": "workspace:*",
"@tanstack/react-query": "5.28.4",
"compare-versions": "^6.1.0",
"fuels": "0.74.0",
"fuels": "0.84.0",
"styled-components": "^6.1.1",
"tsup": "^7.2.0"
}
Expand Down
10 changes: 5 additions & 5 deletions packages/react/src/hooks/useBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export const useBalance = ({
queryKey: QUERY_KEYS.balance(address, assetId),
queryFn: async () => {
try {
// TODO: replace with ETH_ASSET_ID from asset-list package after this task gets done
// https://linear.app/fuel-network/issue/FRO-144/make-asset-list-package-public-and-publish-in-npm
const currentFuelBalance = await provider?.getBalance(
if (!provider) throw new Error('Provider is needed');

const baseAssetId = assetId || provider.getBaseAssetId();
const currentFuelBalance = await provider.getBalance(
Address.fromString(address || ''),
assetId ||
'0x0000000000000000000000000000000000000000000000000000000000000000',
baseAssetId,
);
return currentFuelBalance || null;
} catch (error: unknown) {
Expand Down
4 changes: 2 additions & 2 deletions packages/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
"adm-zip": "^0.5.10"
},
"devDependencies": {
"fuels": "0.74.0",
"fuels": "0.84.0",
"@fuels/ts-config": "workspace:*",
"@fuels/tsup-config": "workspace:*",
"@playwright/test": "^1.39.0",
"@types/adm-zip": "^0.5.3",
"tsup": "^7.2.0"
},
"peerDependencies": {
"fuels": ">=0.74.0",
"fuels": ">=0.84.0",
"@playwright/test": "^1.39.0"
}
}
17 changes: 7 additions & 10 deletions packages/test-utils/src/test-utils/seedWallet.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import type { BN } from 'fuels';
import { Address, BaseAssetId, Wallet, Provider, bn } from 'fuels';

type SeedWalletOptions = {
gasPrice?: number;
};
import type { BN, TxParamsType } from 'fuels';
import { Address, Wallet, Provider, bn } from 'fuels';

export async function seedWallet(
address: string,
amount: BN,
fuelProviderUrl: string,
genesisSecret: string,
options: SeedWalletOptions = {},
options: TxParamsType = {},
) {
const fuelProvider = await Provider.create(fuelProviderUrl);
const { minGasPrice } = await fuelProvider.getGasConfig();
const baseAssetId = fuelProvider.getBaseAssetId();
const genesisWallet = Wallet.fromPrivateKey(genesisSecret!, fuelProvider);
const parameters: TxParamsType = { gasLimit: bn(100_000), ...options };
const response = await genesisWallet.transfer(
Address.fromString(address),
amount,
BaseAssetId,
{ gasPrice: minGasPrice, gasLimit: bn(100_000), ...options },
baseAssetId,
parameters,
);
await response.wait();
}
2 changes: 1 addition & 1 deletion packages/test-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"rootDir": "."
},
"include": ["**/*.ts", "**/*.tsx", "tsup.config.js"],
"exclude": ["**/*.test.ts"]
"exclude": ["**/*.test.ts", "dist"]
}
Loading

0 comments on commit 753b7e9

Please sign in to comment.