Skip to content

Commit

Permalink
refactor: use named export when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
tien committed Jul 23, 2024
1 parent ea12e2a commit 9e9f502
Show file tree
Hide file tree
Showing 32 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion apps/docs/src/components/homepage-features/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function Feature({ title, emoji, description }: FeatureItem) {
);
}

export default function HomepageFeatures() {
export function HomepageFeatures() {
return (
<section className={clsx(styles.features, "margin-vert--lg")}>
<div className="container">
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/src/components/homepage-sponsors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function Sponsor({ title, image, href }: SponsorItem) {
);
}

export default function HomepageSponsors() {
export function HomepageSponsors() {
return (
<section className="margin-vert--lg">
<header className="text--center">
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import HomepageSponsors from "../components/homepage-sponsors";
import { HomepageSponsors } from "../components/homepage-sponsors";
import styles from "./index.module.css";
import Link from "@docusaurus/Link";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import HomepageFeatures from "@site/src/components/homepage-features";
import { HomepageFeatures } from "@site/src/components/homepage-features";
import Heading from "@theme/Heading";
import Layout from "@theme/Layout";
import clsx from "clsx";
Expand Down
4 changes: 2 additions & 2 deletions apps/example/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import config from "./config";
import { config } from "./config";
import { IDLE, MutationError, PENDING } from "@reactive-dot/core";
import type { Wallet } from "@reactive-dot/core/wallets.js";
import {
Expand Down Expand Up @@ -374,7 +374,7 @@ function Example(props: ExampleProps) {
);
}

export default function App() {
export function App() {
return (
<ReDotProvider config={config}>
<Suspense fallback="Loading wallet connection...">
Expand Down
4 changes: 1 addition & 3 deletions apps/example/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const smoldotPromise = startFromWorker(
}),
);

const config = {
export const config = {
chains: {
polkadot: {
descriptor: polkadot,
Expand Down Expand Up @@ -60,5 +60,3 @@ const config = {
}),
],
} as const satisfies Config;

export default config;
2 changes: 1 addition & 1 deletion apps/example/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import App from "./app.js";
import { App } from "./app.js";
import "./index.css";
import React from "react";
import ReactDOM from "react-dom/client";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/actions/connect-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type Wallet from "../wallets/wallet.js";
import type { Wallet } from "../wallets/wallet.js";

export async function connectWallet(wallet: Wallet | Wallet[]) {
const walletsToConnect = Array.isArray(wallet) ? wallet : [wallet];
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/actions/disconnect-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type Wallet from "../wallets/wallet.js";
import type { Wallet } from "../wallets/wallet.js";

export async function disconnectWallet(wallet: Wallet | Wallet[]) {
const walletsToDisconnect = Array.isArray(wallet) ? wallet : [wallet];
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/actions/get-accounts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MaybeAsync } from "../types.js";
import { toObservable } from "../utils.js";
import type Wallet from "../wallets/wallet.js";
import type { Wallet } from "../wallets/wallet.js";
import type { ChainSpecData } from "@polkadot-api/substrate-client";
import { combineLatest } from "rxjs";
import { map, switchMap } from "rxjs/operators";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/actions/get-connected-wallets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MaybeAsync } from "../types.js";
import { toObservable } from "../utils.js";
import type Wallet from "../wallets/wallet.js";
import type { Wallet } from "../wallets/wallet.js";
import { combineLatest } from "rxjs";
import { map, switchMap } from "rxjs/operators";

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export {
default as Query,
Query,
type InferQueryPayload,
type InferQueryResponse,
type MultiInstruction,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/query-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export type InferQueryPayload<T extends Query> =
? InferInstructionsPayload<Instructions, Descriptor>
: never;

export default class Query<
export class Query<
const TInstructions extends QueryInstruction[] = QueryInstruction[],
TDescriptor extends ChainDefinition = CommonDescriptor,
> implements Query<TInstructions>
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/wallets/aggregator/aggregator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type Wallet from "../wallet.js";
import type { Wallet } from "../wallet.js";
import type { Observable } from "rxjs";

export default abstract class WalletAggregator {
export abstract class WalletAggregator {
abstract scan(): Wallet[] | Promise<Wallet[]>;

abstract readonly wallets$: Observable<Wallet[]>;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/wallets/aggregator/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as WalletAggregator } from "./aggregator.js";
export { default as InjectedWalletAggregator } from "./injected.js";
export { WalletAggregator } from "./aggregator.js";
export { InjectedWalletAggregator } from "./injected.js";
6 changes: 3 additions & 3 deletions packages/core/src/wallets/aggregator/injected.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import InjectedWallet from "../injected.js";
import { InjectedWallet } from "../injected.js";
import type { WalletOptions } from "../wallet.js";
import WalletAggregator from "./aggregator.js";
import { WalletAggregator } from "./aggregator.js";
import { getInjectedExtensions } from "polkadot-api/pjs-signer";
import { BehaviorSubject } from "rxjs";
import { map } from "rxjs/operators";

export default class InjectedWalletAggregator extends WalletAggregator {
export class InjectedWalletAggregator extends WalletAggregator {
#walletOptions: WalletOptions | undefined;

constructor(options?: WalletOptions) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/wallets/deep-link.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Wallet from "./wallet.js";
import { Wallet } from "./wallet.js";

type ConnectionHandshake = {
uri: string;
settled: Promise<void>;
};

export default abstract class DeepLinkWallet extends Wallet {
export abstract class DeepLinkWallet extends Wallet {
abstract initiateConnectionHandshake():
| ConnectionHandshake
| Promise<ConnectionHandshake>;
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/wallets/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from "./aggregator/index.js";
export { default as DeepLinkWallet } from "./deep-link.js";
export { DeepLinkWallet } from "./deep-link.js";
export { initializeWallets } from "./initialize-wallets.js";
export { default as InjectedWallet } from "./injected.js";
export { default as WalletConnect } from "./wallet-connect/index.js";
export { default as Wallet } from "./wallet.js";
export { InjectedWallet } from "./injected.js";
export { WalletConnect } from "./wallet-connect/index.js";
export { Wallet } from "./wallet.js";
2 changes: 1 addition & 1 deletion packages/core/src/wallets/initialize-wallets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { WalletAggregator } from "./aggregator/index.js";
import type Wallet from "./wallet.js";
import type { Wallet } from "./wallet.js";

export async function initializeWallets(
walletsOrAggregators: Array<Wallet | WalletAggregator>,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/wallets/injected.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReDotError } from "../errors.js";
import Wallet, { type WalletOptions } from "./wallet.js";
import { Wallet, type WalletOptions } from "./wallet.js";
import {
connectInjectedExtension,
type InjectedExtension,
Expand All @@ -8,7 +8,7 @@ import {
import { BehaviorSubject, Observable } from "rxjs";
import { map, switchMap } from "rxjs/operators";

export default class InjectedWallet extends Wallet {
export class InjectedWallet extends Wallet {
readonly #extension$ = new BehaviorSubject<InjectedExtension | undefined>(
undefined,
);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/wallets/wallet-connect/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReDotError } from "../../errors.js";
import DeepLinkWallet from "../deep-link.js";
import { DeepLinkWallet } from "../deep-link.js";
import { getPolkadotSignerFromPjs } from "./from-pjs-account.js";
import type {
WalletConnectModal,
Expand All @@ -14,7 +14,7 @@ import type { InjectedPolkadotAccount } from "polkadot-api/pjs-signer";
import { BehaviorSubject, lastValueFrom } from "rxjs";
import { map } from "rxjs/operators";

export default class WalletConnect extends DeepLinkWallet {
export class WalletConnect extends DeepLinkWallet {
readonly #providerOptions: UniversalProviderOpts;

#provider: IUniversalProvider | undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/wallets/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type WalletOptions = {
storage?: PrefixedStorage | undefined;
};

export default abstract class Wallet {
export abstract class Wallet {
abstract readonly id: string;

abstract readonly name: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/use-accounts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { accountsAtom } from "../stores/accounts.js";
import type { ChainHookOptions } from "./types.js";
import useChainId from "./use-chain-id.js";
import { useChainId } from "./use-chain-id.js";
import { useAtomValue } from "jotai";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/use-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
finalizedBlockAtomFamily,
} from "../stores/block.js";
import type { ChainHookOptions } from "./types.js";
import useChainId from "./use-chain-id.js";
import { useChainId } from "./use-chain-id.js";
import { useAtomValue } from "jotai";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/use-chain-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ChainHookOptions } from "./types.js";
import { ReDotError } from "@reactive-dot/core";
import { useContext } from "react";

export default function useChainId(options?: ChainHookOptions) {
export function useChainId(options?: ChainHookOptions) {
const contextChainId = useContext(ChainIdContext);
const chainId = options?.chainId ?? contextChainId;

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/use-chain-spec-data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { chainSpecDataAtomFamily } from "../stores/client.js";
import type { ChainHookOptions } from "./types.js";
import useChainId from "./use-chain-id.js";
import { useChainId } from "./use-chain-id.js";
import { useAtomValue } from "jotai";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/use-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { clientAtomFamily } from "../stores/client.js";
import type { ChainHookOptions } from "./types.js";
import useChainId from "./use-chain-id.js";
import { useChainId } from "./use-chain-id.js";
import { useAtomValue } from "jotai";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/use-mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { typedApiAtomFamily } from "../stores/client.js";
import type { ChainHookOptions } from "./types.js";
import { useAsyncState } from "./use-async-state.js";
import useChainId from "./use-chain-id.js";
import { useChainId } from "./use-chain-id.js";
import type { ChainId, Chains } from "@reactive-dot/core";
import { MutationError, PENDING } from "@reactive-dot/core";
import { useAtomCallback } from "jotai/utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/use-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import type { Falsy, FalsyGuard, FlatHead } from "../types.js";
import { flatHead, stringify } from "../utils/vanilla.js";
import type { ChainHookOptions } from "./types.js";
import useChainId from "./use-chain-id.js";
import { useChainId } from "./use-chain-id.js";
import {
IDLE,
Query,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/use-typed-api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { typedApiAtomFamily } from "../stores/client.js";
import type { ChainHookOptions } from "./types.js";
import useChainId from "./use-chain-id.js";
import { useChainId } from "./use-chain-id.js";
import type { ChainId, Chains } from "@reactive-dot/core";
import { useAtomValue } from "jotai";
import type { TypedApi } from "polkadot-api";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import DenominatedNumber from "./DenominatedNumber.js";
import { DenominatedNumber } from "./denominated-number.js";
import { describe, expect, it } from "vitest";

describe("DenominatedNumber", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default class DenominatedNumber extends Number {
export class DenominatedNumber extends Number {
// Large values lead to massive memory usage. Limit to something sensible.
static #maxDecimal = 100;

Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as DenominatedNumber } from "./DenominatedNumber.js";
export { DenominatedNumber } from "./denominated-number.js";

0 comments on commit 9e9f502

Please sign in to comment.