Skip to content

Commit

Permalink
Porting getting-started snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
arboleya committed Jul 2, 2024
1 parent 28c0b1c commit 48bbcba
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 54 deletions.
52 changes: 0 additions & 52 deletions apps/docs-snippets/src/guide/introduction/getting-started.test.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { main } from './connecting-to-testnet.wrapped';

/**
* @group node
* @group browser
*/
test('it works', async () => {
const { balances } = await main();
expect(balances).toBeTruthy();
expect(balances).toBeInstanceOf(Array);
});
14 changes: 14 additions & 0 deletions apps/docs-snippets2/src/introduction/connecting-to-localnode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// #region main
import { Provider, Wallet, LOCAL_NETWORK_URL } from 'fuels';

const ADDRESS = '0x767caf5b08eba21c561078a4d5be09bbd7f16b9eca22699a61f1edd9e456126f';

// Create a provider using the `LOCAL_NETWORK_URL` constant
const provider = await Provider.create(LOCAL_NETWORK_URL);

// Then use it when creating a wallet
const wallet = Wallet.fromAddress(ADDRESS, provider);
const balances = await wallet.getBalances();

console.log({ balances });
// #endregion main
11 changes: 11 additions & 0 deletions apps/docs-snippets2/src/introduction/connecting-to-testnet.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { main } from './connecting-to-testnet.wrapped';

/**
* @group node
* @group browser
*/
test('it works', async () => {
const { balances } = await main();
expect(balances).toBeTruthy();
expect(balances).toBeInstanceOf(Array);
});
14 changes: 14 additions & 0 deletions apps/docs-snippets2/src/introduction/connecting-to-testnet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// #region main
import { Provider, Wallet, TESTNET_NETWORK_URL } from 'fuels';

const ADDRESS = '0x767caf5b08eba21c561078a4d5be09bbd7f16b9eca22699a61f1edd9e456126f';

// Create a provider using the `TESTNET_NETWORK_URL` constant
const provider = await Provider.create(TESTNET_NETWORK_URL);

// Then use it when creating a wallet
const wallet = Wallet.fromAddress(ADDRESS, provider);
const balances = await wallet.getBalances();

console.log({ balances });
// #endregion main
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Firstly, you will need a local node running on your machine. We recommend one of

In the following example, we create a provider to connect to the local node and sign a message.

<<< @/../../docs-snippets/src/guide/introduction/getting-started.test.ts#connecting-to-the-local-node{ts:line-numbers}
<<< @/../../docs-snippets2/src/introduction/connecting-to-localnode.ts#main{ts:line-numbers}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ In the example below, we connect a [Provider](../provider/index.md) to the lates

> **Note:** New wallets on the Testnet will not have any assets! You can use the [Faucet](https://faucet-testnet.fuel.network/) to fund your wallet.
<<< @/../../docs-snippets/src/guide/introduction/getting-started.test.ts#connecting-to-the-testnet{ts:line-numbers}
<<< @/../../docs-snippets2/src/introduction/connecting-to-testnet.ts#main{ts:line-numbers}

0 comments on commit 48bbcba

Please sign in to comment.