Skip to content

Commit

Permalink
feat(refactor): Use withProvider from @w3ux/factories (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
rossbulat authored Nov 2, 2024
2 parents 0dc822c + b714652 commit 91425e6
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 72 deletions.
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@polkadot/util-crypto": "^13.2.2",
"@tanstack/react-query": "^5.53.3",
"@w3ux/extension-assets": "^0.4.0",
"@w3ux/factories": "^1.0.0-beta.0",
"@w3ux/hooks": "^1.1.1",
"@w3ux/react-connect-kit": "^1.8.0",
"@w3ux/react-odometer": "^1.1.0",
Expand Down
98 changes: 48 additions & 50 deletions packages/app/src/Providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

import { App } from 'App';
import { DappName } from 'consts';
import type { AnyJson } from '@w3ux/types';
import { TabsProvider } from 'contexts/Tabs';
import type { Provider } from 'hooks/withProviders';
import { withProviders } from 'hooks/withProviders';
import { withProviders } from '@w3ux/factories';
import { MenuProvider } from 'contexts/Menu';
import { TagsProvider } from 'contexts/Tags';
import { ChainFilterProvider } from 'contexts/ChainFilter';
Expand Down Expand Up @@ -41,61 +39,61 @@ import { InputMetaProvider } from 'contexts/InputMeta';
import { DisconnectTabProvider } from 'contexts/DisconnectTab';
import { WalletConnectProvider } from 'contexts/WalletConnect';

export const Providers = () => {
export const Providers = () =>
// !! --------------------------------
// !! Provider order matters.
// !! --------------------------------
const providers: Provider<AnyJson>[] = [
// Workspace and tab providers.
SettingsProvider,
TabsProvider,
ActiveTabProvider,
TagsProvider,
GlobalChainSpaceProvider,
withProviders(
[
// Workspace and tab providers.
SettingsProvider,
TabsProvider,
ActiveTabProvider,
TagsProvider,
GlobalChainSpaceProvider,

// UI providers.
MenuProvider,
TooltipProvider,
OneShotTooltipProvider,
ConnectProvider,
ChainUiProvider,
OverlayProvider,
PromptProvider,
InputMetaProvider,
// UI providers.
MenuProvider,
TooltipProvider,
OneShotTooltipProvider,
ConnectProvider,
ChainUiProvider,
OverlayProvider,
PromptProvider,
InputMetaProvider,

// Transaction providers.
TxMetaProvider,
// Transaction providers.
TxMetaProvider,

// Chain space environment and api indexer.
ApiIndexerProvider,
ChainSpaceEnvProvider,
// Chain space environment and api indexer.
ApiIndexerProvider,
ChainSpaceEnvProvider,

// Account import related providers.
ExtensionsProvider,
[ExtensionAccountsProvider, { dappName: DappName, network: 'polkadot' }], // TODO: Replace hard-coded `network`.
WalletConnectProvider,
WCAccountsProvider,
VaultAccountsProvider,
LedgerHardwareProvider,
LedgerAccountsProvider,
ImportedAccountsProvider,
// Account import related providers.
ExtensionsProvider,
[ExtensionAccountsProvider, { dappName: DappName, network: 'polkadot' }], // TODO: Replace hard-coded `network`.
WalletConnectProvider,
WCAccountsProvider,
VaultAccountsProvider,
LedgerHardwareProvider,
LedgerAccountsProvider,
ImportedAccountsProvider,

// Account formatting and balances provider.
AccountsProvider,
// Account formatting and balances provider.
AccountsProvider,

// Task: `chainExplorer` related providers.
ChainFilterProvider,
ChainStateProvider,
ChainExplorerProvider,
// Task: `chainExplorer` related providers.
ChainFilterProvider,
ChainStateProvider,
ChainExplorerProvider,

// Task: `parachainSetup` related providers.
ReserveParaIdProvider,
RegisterParathreadProvider,
ParaSetupProvider,
// Task: `parachainSetup` related providers.
ReserveParaIdProvider,
RegisterParathreadProvider,
ParaSetupProvider,

// Tab disconnect and destroy provider.
DisconnectTabProvider,
];

return withProviders(providers, App);
};
// Tab disconnect and destroy provider.
DisconnectTabProvider,
],
App
);
22 changes: 0 additions & 22 deletions packages/app/src/hooks/withProviders/index.tsx

This file was deleted.

10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,7 @@ __metadata:
"@polkadot/util-crypto": "npm:^13.2.2"
"@tanstack/react-query": "npm:^5.53.3"
"@w3ux/extension-assets": "npm:^0.4.0"
"@w3ux/factories": "npm:^1.0.0-beta.0"
"@w3ux/hooks": "npm:^1.1.1"
"@w3ux/react-connect-kit": "npm:^1.8.0"
"@w3ux/react-odometer": "npm:^1.1.0"
Expand Down Expand Up @@ -4159,6 +4160,15 @@ __metadata:
languageName: node
linkType: hard

"@w3ux/factories@npm:^1.0.0-beta.0":
version: 1.0.0-beta.0
resolution: "@w3ux/factories@npm:1.0.0-beta.0"
peerDependencies:
react: ^18
checksum: 10c0/1c2a8adb966300fe7e36410e4b91381221a70f2470dfa3c1b5612ddc2e84c4579b6928ac7d4c9cad34291b7d8e1cbc97cbba66ae46fd04627042df50e9646b66
languageName: node
linkType: hard

"@w3ux/hooks@npm:^1.1.0":
version: 1.1.0
resolution: "@w3ux/hooks@npm:1.1.0"
Expand Down

0 comments on commit 91425e6

Please sign in to comment.