-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: added asset docs * chore: changeset * chore: lint * docs: added further docs
- Loading branch information
1 parent
48db506
commit 8930417
Showing
5 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
--- | ||
|
||
docs: added assets guide |
39 changes: 39 additions & 0 deletions
39
apps/docs-snippets/src/guide/utilities/using-assets.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* eslint-disable @typescript-eslint/no-non-null-assertion */ | ||
import type { Asset, AssetFuel } from 'fuels'; | ||
import { assets, CHAIN_IDS, getAssetFuel, Wallet } from 'fuels'; | ||
import { launchTestNode } from 'fuels/test-utils'; | ||
|
||
/** | ||
* @group node | ||
* @group browser | ||
*/ | ||
describe('using-assets', () => { | ||
it('should be able to use `getAssetFuel`', async () => { | ||
using launched = await launchTestNode(); | ||
const { | ||
provider, | ||
wallets: [sender], | ||
} = launched; | ||
|
||
// #region using-assets-1 | ||
// #import { Wallet, Asset, AssetFuel, assets, getAssetFuel }; | ||
|
||
const recipient = Wallet.generate({ provider }); | ||
|
||
// Find the asset with symbol 'ETH' | ||
const assetEth: Asset = assets.find((asset) => asset.symbol === 'ETH')!; | ||
|
||
// Get all the metadata for ETH on Fuel Test Network | ||
const chainId: number = CHAIN_IDS.fuel.testnet; | ||
const assetEthOnFuel: AssetFuel = getAssetFuel(assetEth, chainId)!; | ||
|
||
// Send a transaction (using the asset on Fuel Test Network) | ||
const transaction = await sender.transfer(recipient.address, 100, assetEthOnFuel.assetId); | ||
const result = await transaction.waitForResult(); | ||
// #endregion using-assets-1 | ||
|
||
expect(result.isStatusSuccess).toBe(true); | ||
expect(assetEthOnFuel).toBeDefined(); | ||
expect(assetEthOnFuel).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -333,4 +333,8 @@ incentivise | |
URI | ||
walletsConfig | ||
reuploaded | ||
Vite | ||
Vite | ||
USDT | ||
USD | ||
USDC | ||
WETH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Assets | ||
|
||
We export an array of [`Asset`](https://docs.fuel.network/docs/fuels-ts/account/#asset) objects, that can be useful when creating your dApp. The `Asset` object has useful metadata about the different assets that are available on blockchain networks (Fuel and Ethereum). | ||
|
||
Included assets such as: | ||
|
||
- Ethereum (ETH) | ||
- Tether (USDT) | ||
- USD Coin (USDC) | ||
- Wrapped ETH (WETH) | ||
|
||
The helper functions `getAssetFuel` and `getAssetEth` can be used to get an asset's details relative to each network. These return a combination of the asset, and network information (the return types are [`AssetFuel`](../../api/Account/index.md#assetfuel) and [`AssetEth`](../../api/Account/index.md#asseteth) respectively). | ||
|
||
<<< @/../../docs-snippets/src/guide/utilities/using-assets.test.ts#using-assets-1{ts:line-numbers} |