Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions .changeset/young-ends-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@reactive-dot/wallet-polkadot-vault": patch
"@reactive-dot/wallet-readonly": patch
"@reactive-dot/wallet-ledger": patch
"@reactive-dot/wallet-mimir": patch
"@reactive-dot/react": patch
"@reactive-dot/core": patch
"@reactive-dot/vue": patch
---

Prefer `interface` over `type` alias for object types and use `extends` instead of intersection types (`&`), yielding better TypeScript type-checking performance and more consistent error messages.
14 changes: 7 additions & 7 deletions examples/react/.papi/descriptors/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
{
"name": "@polkadot-api/descriptors",
"version": "0.1.0-autogenerated.12798067100670306101",
"name": "@polkadot-api/descriptors",
"files": [
"dist"
],
"type": "module",
"sideEffects": false,
"main": "./dist/index.js",
"module": "./dist/index.js",
"browser": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
Expand All @@ -19,7 +14,12 @@
},
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"module": "./dist/index.js",
"browser": "./dist/index.js",
"types": "./dist/index.d.ts",
"sideEffects": false,
"peerDependencies": {
"polkadot-api": ">=2.0.1"
"polkadot-api": ">=2.0.0"
}
}
4 changes: 2 additions & 2 deletions examples/react/src/account-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { WalletAccount } from "@reactive-dot/core/wallets.js";
import { useConnectedWallets, useAccounts } from "@reactive-dot/react";
import { type ReactNode, useState } from "react";

type AccountSelectProps = {
interface AccountSelectProps {
children: (account: WalletAccount) => ReactNode;
};
}

export function AccountSelect({ children }: AccountSelectProps) {
const connectedWallets = useConnectedWallets();
Expand Down
4 changes: 3 additions & 1 deletion examples/react/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export function App() {
);
}

type ExampleProps = { chainName: string };
interface ExampleProps {
chainName: string;
}

function Example({ chainName }: ExampleProps) {
const resetQueryError = useQueryErrorResetter();
Expand Down
4 changes: 2 additions & 2 deletions examples/react/src/ink-contract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export function InkContracts() {
);
}

type ContractProps = {
interface ContractProps {
address: string;
};
}

function Psp22TokenInfo({ address }: ContractProps) {
const [timestamp, [tokenName, tokenDecimals, tokenSymbol, totalSupply]] = useLazyLoadQuery(
Expand Down
8 changes: 4 additions & 4 deletions examples/react/src/query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ function SpendableBalances() {
);
}

type SpendableBalanceProps = {
interface SpendableBalanceProps {
account: PolkadotAccount;
};
}

function SpendableBalance({ account }: SpendableBalanceProps) {
return (
Expand Down Expand Up @@ -180,10 +180,10 @@ function PendingPoolRewards() {
);
}

type PendingRewardsProps = {
interface PendingRewardsProps {
account: PolkadotAccount;
rewards: bigint;
};
}

function PendingRewards({ account, rewards }: PendingRewardsProps) {
return (
Expand Down
4 changes: 2 additions & 2 deletions examples/react/src/wallet-connection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export function WalletConnection() {
);
}

type WalletItemProps = {
interface WalletItemProps {
wallet: Wallet;
};
}

function WalletItem({ wallet }: WalletItemProps) {
const connectedWallets = useConnectedWallets();
Expand Down
14 changes: 7 additions & 7 deletions examples/vue/.papi/descriptors/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
{
"name": "@polkadot-api/descriptors",
"version": "0.1.0-autogenerated.12798067100670306101",
"name": "@polkadot-api/descriptors",
"files": [
"dist"
],
"type": "module",
"sideEffects": false,
"main": "./dist/index.js",
"module": "./dist/index.js",
"browser": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
Expand All @@ -19,7 +14,12 @@
},
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"module": "./dist/index.js",
"browser": "./dist/index.js",
"types": "./dist/index.d.ts",
"sideEffects": false,
"peerDependencies": {
"polkadot-api": ">=2.0.1"
"polkadot-api": ">=2.0.0"
}
}
4 changes: 2 additions & 2 deletions packages/core/src/actions/get-block-extrinsics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ type Extra = Partial<{
[key: string]: unknown;
}>;

type Call = {
interface Call {
module: string;
func: string;
args: unknown;
};
}

type Extrinsic = { version: number; call: Call } & (
| { signed: false }
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/actions/get-block.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import type { PolkadotClient } from "polkadot-api";
import { of } from "rxjs";
import { expect, it } from "vitest";

type DummyBlock = { id: string };
interface DummyBlock {
id: string;
}

it("should return the best block when options.tag is 'best'", () =>
new Promise<void>((resolve) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/actions/get-block.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { PolkadotClient } from "polkadot-api";
import { map } from "rxjs";

export type GetBlockOptions = {
export interface GetBlockOptions {
tag?: "best" | "finalized";
};
}

export function getBlock<TOptions extends GetBlockOptions>(
client: PolkadotClient,
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import type { Wallet, WalletProvider } from "./wallets/index.js";
import type { JsonRpcProvider } from "polkadot-api";
import type { ChainDefinition } from "polkadot-api";

export type ChainConfig = {
export interface ChainConfig {
readonly descriptor: ChainDefinition | UnsafeDescriptor;
readonly provider: Gettable<JsonRpcProvider | LightClientProvider>;
};
}

export type Config<
export interface Config<
TChains extends Readonly<Record<string, ChainConfig>> = Readonly<Record<string, ChainConfig>>,
TTargetChainIds extends Extract<keyof TChains, string>[] = Extract<keyof TChains, string>[],
> = {
> {
readonly chains: TChains;
readonly targetChains?: TTargetChainIds;
readonly wallets?: Array<WalletProvider | Wallet>;
Expand All @@ -31,7 +31,7 @@ export type Config<
* @defaultValue false
*/
readonly ssr?: boolean;
};
}

export function defineConfig<
const TChains extends Readonly<Record<string, ChainConfig>>,
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/contract/ink/query-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import type { ExcludeProperties, Finality, FlatHead, StringKeyOf } from "../../t
import type { UnwrapResult } from "./result.js";
import type { GenericInkDescriptors } from "./types.js";

type StorageReadInstruction = BaseInstruction<"storage"> & {
interface StorageReadInstruction extends BaseInstruction<"storage"> {
path: string;
key: unknown | undefined;
at: Finality | undefined;
};
}

type MultiStorageReadInstruction = MultiInstruction<StorageReadInstruction, "key", "keys">;

Expand All @@ -22,12 +22,12 @@ export type InferStorageReadInstructionPayload<
TDescriptor extends GenericInkDescriptors,
> = TDescriptor["__types"]["storage"][TInstruction["path"]]["value"];

type MessageSendInstruction = BaseInstruction<"message"> & {
interface MessageSendInstruction extends BaseInstruction<"message"> {
name: string;
body: unknown;
origin: Address | undefined;
at: Finality | undefined;
};
}

type MultiMessageSendInstruction = MultiInstruction<MessageSendInstruction, "body", "bodies">;

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/contract/ink/watch-event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const mockContract = {
},
} as unknown as InkContract;

type MockBlockEvents = {
interface MockBlockEvents {
block: unknown;
events: Array<{
payload: {
Expand All @@ -36,7 +36,7 @@ type MockBlockEvents = {
topics: string[];
};
}>;
};
}

const contractEmitted$ = new Subject<MockBlockEvents>();
const mockApi = {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/contract/mutation-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { SolidityTxBody } from "./solidity/types.js";
import type { Abi, ExtractAbiFunctionNames } from "abitype";
import type { Transaction } from "polkadot-api";

export type MutationBuilder = {
export interface MutationBuilder {
<
TDescriptor extends GenericInkDescriptors,
TMessageName extends StringKeyOf<
Expand All @@ -28,4 +28,4 @@ export type MutationBuilder = {
? [body?: SolidityTxBody<TAbi, TFunctionName>]
: [body: SolidityTxBody<TAbi, TFunctionName>]
): MaybePromise<Transaction>;
};
}
4 changes: 2 additions & 2 deletions packages/core/src/contract/solidity/query-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import type {
ExtractAbiFunctionNames,
} from "abitype";

export type FunctionCallInstruction = BaseInstruction<"function"> & {
export interface FunctionCallInstruction extends BaseInstruction<"function"> {
name: string;
args: unknown[];
at: Finality | undefined;
};
}

export type InferFunctionCallInstructionPayload<
TInstruction extends FunctionCallInstruction,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/contract/solidity/watch-event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ const transferEvent = AbiEvent.from(

const bsEvent = AbiEvent.from("event Bs(address indexed clown)");

type MockEvent = {
interface MockEvent {
payload: {
contract: SizedHex<20>;
data: Uint8Array;
topics: SizedHex<32>[];
};
};
}

type MockBlock = Record<string, never>;

Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/contract/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ import type {

export type ContractAddress = Address | SizedHex<20>;

export type ContractEvent<TName extends string = string, TData = unknown> = {
export interface ContractEvent<TName extends string = string, TData = unknown> {
block: BlockInfo;
contract: Address;
name: TName;
data: TData;
};
}

export type Gas = {
export interface Gas {
ref_time: bigint;
proof_size: bigint;
};
}

export type StorageError = Enum<{
DoesntExist: undefined;
Expand Down Expand Up @@ -216,7 +216,7 @@ export type ContractPallets = PalletsTypedef<
{}
>;

export type GenericDefinition<TPallet, TApis> = {
export interface GenericDefinition<TPallet, TApis> {
descriptors: Promise<any> & {
pallets: TPallet;
apis: TApis;
Expand All @@ -225,6 +225,6 @@ export type GenericDefinition<TPallet, TApis> = {
metadataTypes: any;
getMetadata: any;
genesis: any;
};
}

export type ContractCompatApi = TypedApi<GenericDefinition<ContractPallets, ContractApis>>;
4 changes: 2 additions & 2 deletions packages/core/src/maths/spendable-balance.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { BigIntMath } from "@reactive-dot/utils";

type SpendableBalanceParam = {
interface SpendableBalanceParam {
free: bigint;
reserved: bigint;
frozen: bigint;
existentialDeposit: bigint;
includesExistentialDeposit?: boolean;
};
}

export function spendableBalance({
free,
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/mutation-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import type { ChainId } from "./chains.js";
import type { Contract } from "./contract/contract.js";
import type { Transaction } from "polkadot-api";

export type MutationEvent = {
export interface MutationEvent {
id: `${string}-${string}-${string}-${string}-${string}`;
chainId: ChainId;
call?: Transaction["decodedCall"];
};
}

export type ContractMutationEvent = MutationEvent & {
export interface ContractMutationEvent extends MutationEvent {
contractCalls: Array<{
contract: Contract;
address: Address;
message: string;
}>;
};
}
Loading
Loading