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

docs: migrate other half of the wallet snippets #3365

Merged
merged 26 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
161516f
docs: convert old wallet snippets
maschad Oct 29, 2024
7dd6566
docs: split snippets
maschad Oct 29, 2024
a5d5354
docs: update snippets
maschad Oct 29, 2024
0c93303
Merge branch 'master' into mc/docs/update-snippets-wallet
maschad Oct 29, 2024
11d0bde
docs: ensure test is node only
maschad Oct 29, 2024
b96dbc1
docs: add node group at the bottom
maschad Oct 29, 2024
672a4f8
remove old import
maschad Oct 30, 2024
a67635a
remove old import
maschad Oct 30, 2024
781d4f3
remove space
maschad Oct 30, 2024
5ff9c3e
adjust imports in snippet
maschad Oct 30, 2024
c3cfbd9
remove old import
maschad Oct 30, 2024
4087812
Merge branch 'master' into mc/docs/update-snippets-wallet
maschad Oct 30, 2024
44de64e
docs: remove old import
maschad Oct 30, 2024
787cb6b
docs: update snippet test suffix
maschad Oct 30, 2024
b887173
Merge branch 'master' into mc/docs/update-snippets-wallet
maschad Nov 6, 2024
715481c
docs: move snippets into wallet guide
maschad Nov 6, 2024
8c92aff
docs: update snippets comment
maschad Nov 8, 2024
07cefcf
Merge branch 'master' into mc/docs/update-snippets-wallet
maschad Nov 8, 2024
5e402a2
Merge branch 'master' into mc/docs/update-snippets-wallet
maschad Nov 11, 2024
1a71489
docs: remove unnecessary full examples
maschad Nov 11, 2024
b139ab5
linting fixes
maschad Nov 11, 2024
6d5cc59
docs: add try/catch to snippet
maschad Nov 11, 2024
c28b6b2
docs: add defaultConnectors + remove unused snippet
maschad Nov 11, 2024
f2c8ed7
dep: patch temp issue with knip
maschad Nov 11, 2024
6a918c9
docs: update to use mocked deps
maschad Nov 12, 2024
23b81fb
Merge branch 'master' into mc/docs/update-snippets-wallet
petertonysmith94 Nov 12, 2024
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
Prev Previous commit
Next Next commit
docs: move snippets into wallet guide
  • Loading branch information
maschad committed Nov 6, 2024
commit 715481c662f882deeb2b649986bb27331d9379ae
51 changes: 2 additions & 49 deletions apps/docs-snippets2/src/wallets/connectors.ts
maschad marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// #region full

/* eslint-disable max-classes-per-file */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Fuel, LocalStorage, MemoryStorage, FuelConnector } from 'fuels';
import type { TargetObject, Network, Asset, FuelABI } from 'fuels';
import { MemoryStorage, FuelConnector } from 'fuels';
import type { Network, Asset, FuelABI } from 'fuels';

// prettier-ignore
// #region fuel-connector-extends
Expand Down Expand Up @@ -134,48 +132,3 @@ class WalletConnector extends FuelConnector {
// #endregion fuel-connector-events-abis
}
}

const sdk = new Fuel();

/*
Awaits for initialization to mitigate potential race conditions
derived from the async nature of instantiating a connector.
*/
await sdk.init();

const defaultConnectors = (_opts: {
devMode: boolean;
}): Array<FuelConnector> => [new WalletConnector()];

const sdkDevMode = await new Fuel({
connectors: defaultConnectors({
devMode: true,
}),
}).init();

const sdkWithMemoryStorage = await new Fuel({
storage: new MemoryStorage(),
}).init();

const window = {
localStorage: {
setItem: vi.fn(),
getItem: vi.fn(),
removeItem: vi.fn(),
clear: vi.fn(),
} as unknown as Storage,
};

const sdkWithLocalStorage = await new Fuel({
storage: new LocalStorage(window.localStorage),
}).init();

const emptyWindow = {} as unknown as TargetObject;

const targetObject: TargetObject = emptyWindow || document;

const sdkWithTargetObject = await new Fuel({
targetObject,
}).init();

// #endregion full
54 changes: 54 additions & 0 deletions apps/docs-snippets2/src/wallets/full-connectors.ts
maschad marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// #region full
/* eslint-disable @typescript-eslint/no-unused-vars */
maschad marked this conversation as resolved.
Show resolved Hide resolved

import { FuelConnector, Fuel, MemoryStorage, LocalStorage } from 'fuels';
import type { TargetObject } from 'fuels';

class WalletConnector extends FuelConnector {
name = 'My Wallet Connector';
}

const sdk = new Fuel();

/*
Awaits for initialization to mitigate potential race conditions
derived from the async nature of instantiating a connector.
*/
await sdk.init();

const defaultConnectors = (_opts: {
devMode: boolean;
}): Array<FuelConnector> => [new WalletConnector()];

const sdkDevMode = await new Fuel({
connectors: defaultConnectors({
devMode: true,
}),
}).init();

const sdkWithMemoryStorage = await new Fuel({
storage: new MemoryStorage(),
}).init();

const window = {
localStorage: {
setItem: vi.fn(),
getItem: vi.fn(),
removeItem: vi.fn(),
clear: vi.fn(),
} as unknown as Storage,
};

const sdkWithLocalStorage = await new Fuel({
storage: new LocalStorage(window.localStorage),
}).init();

const emptyWindow = {} as unknown as TargetObject;

const targetObject: TargetObject = emptyWindow || document;

const sdkWithTargetObject = await new Fuel({
targetObject,
}).init();

// #endregion full
2 changes: 1 addition & 1 deletion apps/docs/src/guide/wallets/connectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,4 +442,4 @@ For a deeper understanding of `Fuel Connectors` and how to start using them in y

For a full example of how to use connectors, see the snippet below:

<<< @/../../docs-snippets2/src/wallets/connectors.ts#full{ts:line-numbers}
<<< @/../../docs-snippets2/src/wallets/full-connectors.ts#full{ts:line-numbers}
Loading