Skip to content

Commit

Permalink
refactor: move @reactive-dot/types to @reactive-dot/core/types.js
Browse files Browse the repository at this point in the history
  • Loading branch information
tien committed Jun 13, 2024
1 parent 87902a6 commit f5948af
Show file tree
Hide file tree
Showing 25 changed files with 229 additions and 305 deletions.
2 changes: 1 addition & 1 deletion apps/docs/docs/getting-started/connect-wallets.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Wallets & accounts connection can by managed via [`useWallets`](/api/react/funct
## Add wallet connector to the config

```ts title="config.ts"
import type { Config } from "@reactive-dot/core/types.js";
import { InjectedConnector } from "@reactive-dot/core/wallets.js";
import type { Config } from "@reactive-dot/types";

const config: Config = {
// ...
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/docs/getting-started/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The records of `ChainId` -> `Descriptor` here will be used to provided you with
```ts title="redot.d.ts"
import type { dot } from "@polkadot-api/descriptors";

declare module "@reactive-dot/types" {
declare module "@reactive-dot/core/types.js" {
export interface Chains {
polkadot: typeof dot;
}
Expand All @@ -66,8 +66,8 @@ declare module "@reactive-dot/types" {

```ts title="config.ts"
import { dot } from "@polkadot-api/descriptors";
import type { Config } from "@reactive-dot/core/types.js";
import { InjectedConnector } from "@reactive-dot/core/wallets.js";
import type { Config } from "@reactive-dot/types";
import { chainSpec } from "polkadot-api/chains/polkadot";
import { getSmProvider } from "polkadot-api/sm-provider";
import { startFromWorker } from "polkadot-api/smoldot/from-worker";
Expand Down
2 changes: 1 addition & 1 deletion apps/example/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { kusama, polkadot, westend } from "@polkadot-api/descriptors";
import type { Config } from "@reactive-dot/core/types.js";
import { InjectedConnector } from "@reactive-dot/core/wallets.js";
import type { Config } from "@reactive-dot/types";
import { getSmProvider } from "polkadot-api/sm-provider";
import { startFromWorker } from "polkadot-api/smoldot/from-worker";

Expand Down
2 changes: 1 addition & 1 deletion apps/example/src/redot.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { polkadot, kusama, westend } from "@polkadot-api/descriptors";

declare module "@reactive-dot/types" {
declare module "@reactive-dot/core/types.js" {
export interface Chains {
polkadot: typeof polkadot;
kusama: typeof kusama;
Expand Down
7 changes: 4 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
"./wallets.js": {
"default": "./build/wallets/index.js",
"types": "./src/wallets/index.ts"
},
"./types.js": {
"default": "./build/types/index.js",
"types": "./src/types/index.ts"
}
},
"scripts": {
"dev": "tsc --build --watch",
"build": "rm -rf build && tsc --build",
"lint": "eslint src"
},
"dependencies": {
"@reactive-dot/types": "workspace:^"
},
"devDependencies": {
"@reactive-dot/eslint-config": "workspace:^",
"@tsconfig/recommended": "^1.0.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/QueryBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { ReDotDescriptor } from "@reactive-dot/types";
import { ReDotDescriptor } from "./types/index.js";
import type { ChainDefinition, TypedApi } from "polkadot-api";
import type { Observable } from "rxjs";

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {
InferInstructionResponse,
QueryInstruction,
} from "./QueryBuilder.js";
import type { ReDotDescriptor } from "@reactive-dot/types";
import { ReDotDescriptor } from "./types/index.js";
import type { ChainDefinition, TypedApi } from "polkadot-api";

export const preflight = <TInstruction extends QueryInstruction>(
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/core/src/wallets/connectors/connector.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Connector as IConnector } from "../../types/index.js";
import type Wallet from "../wallet.js";
import type { Connector as IConnector } from "@reactive-dot/types";
import type { Observable } from "rxjs";

export default abstract class Connector implements IConnector {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/wallets/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Wallet as IWallet } from "@reactive-dot/types";
import type { Wallet as IWallet } from "../types/index.js";
import type { InjectedPolkadotAccount } from "polkadot-api/pjs-signer";
import type { Observable } from "rxjs";

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/context.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { chainConfigsAtom } from "./stores/config.js";
import { connectorsAtom, directWalletsAtom } from "./stores/wallets.js";
import type { ChainId, Config } from "@reactive-dot/core/types.js";
import { Connector, Wallet } from "@reactive-dot/core/wallets.js";
import type { ChainId, Config } from "@reactive-dot/types";
import { ScopeProvider } from "jotai-scope";
import { useHydrateAtoms } from "jotai/utils";
import { PolkadotSigner } from "polkadot-api";
Expand Down
3 changes: 1 addition & 2 deletions packages/react/src/development.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "@reactive-dot/types";
import { ChainDefinition } from "polkadot-api";

declare module "@reactive-dot/types" {
declare module "@reactive-dot/core/types.js" {
export interface Chains {
[id: string]: ChainDefinition;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ChainId } from "@reactive-dot/types";
import type { ChainId } from "@reactive-dot/core/types.js";

// eslint-disable-next-line @typescript-eslint/ban-types
export type ChainHookOptions<T = {}> = T & {
Expand Down
6 changes: 5 additions & 1 deletion packages/react/src/hooks/useMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { ChainIdContext, SignerContext } from "../context.js";
import { typedApiAtomFamily } from "../stores/client.js";
import type { ChainHookOptions } from "./types.js";
import { IDLE, MutationError, PENDING } from "@reactive-dot/core";
import type { ChainId, Chains, ReDotDescriptor } from "@reactive-dot/types";
import type {
ChainId,
Chains,
ReDotDescriptor,
} from "@reactive-dot/core/types.js";
import { useAtomCallback } from "jotai/utils";
import type {
PolkadotSigner,
Expand Down
6 changes: 5 additions & 1 deletion packages/react/src/hooks/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import {
QueryInstruction,
type InferQueryPayload,
} from "@reactive-dot/core";
import type { ChainId, Chains, ReDotDescriptor } from "@reactive-dot/types";
import type {
ChainId,
Chains,
ReDotDescriptor,
} from "@reactive-dot/core/types.js";
import { atom, useAtomValue } from "jotai";
import { useAtomCallback } from "jotai/utils";
import { useCallback, useContext, useMemo } from "react";
Expand Down
6 changes: 5 additions & 1 deletion packages/react/src/hooks/useTypedApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { ChainIdContext } from "../context.js";
import { typedApiAtomFamily } from "../stores/client.js";
import type { ChainHookOptions } from "./types.js";
import { ReDotError } from "@reactive-dot/core";
import type { Chains, ChainId, ReDotDescriptor } from "@reactive-dot/types";
import type {
Chains,
ChainId,
ReDotDescriptor,
} from "@reactive-dot/core/types.js";
import { useAtomValue } from "jotai";
import { TypedApi } from "polkadot-api";
import { useContext } from "react";
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/stores/block.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { clientAtomFamily } from "./client.js";
import { ChainId } from "@reactive-dot/types";
import { ChainId } from "@reactive-dot/core/types.js";
import { atomFamily, atomWithObservable } from "jotai/utils";
import { from } from "rxjs";
import { switchMap, map } from "rxjs/operators";
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/stores/client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { chainConfigsAtom } from "./config.js";
import type { JsonRpcProvider } from "@polkadot-api/json-rpc-provider";
import { ReDotError } from "@reactive-dot/core";
import type { ChainId } from "@reactive-dot/types";
import type { ChainId } from "@reactive-dot/core/types.js";
import { atom } from "jotai";
import { atomFamily } from "jotai/utils";
import { createClient } from "polkadot-api";
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/stores/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ChainConfig, ChainId } from "@reactive-dot/types";
import type { ChainConfig, ChainId } from "@reactive-dot/core/types.js";
import { atom } from "jotai";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/stores/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
type MultiInstruction,
type Query,
} from "@reactive-dot/core";
import type { ChainId } from "@reactive-dot/types";
import type { ChainId } from "@reactive-dot/core/types.js";
import { type Atom, type WritableAtom, atom } from "jotai";
import { atomFamily, atomWithObservable, atomWithRefresh } from "jotai/utils";
import { from, switchMap, type Observable } from "rxjs";
Expand Down
1 change: 0 additions & 1 deletion packages/types/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions packages/types/eslint.config.js

This file was deleted.

27 changes: 0 additions & 27 deletions packages/types/package.json

This file was deleted.

14 changes: 0 additions & 14 deletions packages/types/tsconfig.json

This file was deleted.

Loading

0 comments on commit f5948af

Please sign in to comment.