Skip to content

Commit

Permalink
Fix type, nits
Browse files Browse the repository at this point in the history
  • Loading branch information
ryangoree committed Oct 5, 2024
1 parent b1166d2 commit 1651cfa
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/drift/src/adapter/MockAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type {
TransactionReceipt,
} from "src/adapter/types/Transaction";
import type { Address, Bytes, TransactionHash } from "src/types";
import { MockStore } from "src/utils/MockStore";
import { MockStore } from "src/utils/testing/MockStore";
import type { OptionalKeys } from "src/utils/types";

// TODO: Allow configuration of error throwing/default return value behavior
Expand Down
6 changes: 3 additions & 3 deletions packages/drift/src/adapter/types/Abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
import type {
EmptyObject,
MergeKeys,
Prettify,
Pretty,
ReplaceKeys,
} from "src/utils/types";

Expand Down Expand Up @@ -119,7 +119,7 @@ type NamedParametersToObject<
TParameterKind extends AbiParameterKind = AbiParameterKind,
> = NamedAbiParameter[] extends TParameters
? Record<number | string, any>
: Prettify<
: Pretty<
{
// For every parameter name, excluding empty names, add a key to the
// object for the parameter name
Expand All @@ -130,7 +130,7 @@ type NamedParametersToObject<
Extract<TParameters[number], { name: TName }>,
TParameterKind
> extends infer TPrimitive
? TPrimitive extends unknown
? unknown extends TPrimitive
? any
: TPrimitive
: never;
Expand Down
2 changes: 1 addition & 1 deletion packages/drift/src/client/Contract/MockContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from "src/client/Contract/Contract";
import { ZERO_ADDRESS } from "src/constants";
import type { Address, Bytes, TransactionHash } from "src/types";
import { MockStore } from "src/utils/MockStore";
import { MockStore } from "src/utils/testing/MockStore";
import type { OptionalKeys } from "src/utils/types";

// TODO: DRY up the mock clients and integrate them better so that modifying a
Expand Down
2 changes: 1 addition & 1 deletion packages/drift/src/client/Drift/MockDrift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
type WriteParams,
} from "src/client/Drift/Drift";
import type { Address, Bytes, TransactionHash } from "src/types";
import { MockStore } from "src/utils/MockStore";
import { MockStore } from "src/utils/testing/MockStore";
import type { OptionalKeys } from "src/utils/types";

export class MockDrift extends Drift<MockAdapter> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class MockStore<T> {
export class NotImplementedError extends DriftError {
constructor({ method, mockKey }: { method: string; mockKey: string }) {
super(
`No mock found with key "${mockKey}". Called ${method} on a Mock without a return value. The value must be stubbed first:
`No mock found with key "${mockKey}". Called \`.${method}\` on a Mock without a return value. The value must be stubbed first:
mock.on${method.replace(/^./, (c) => c.toUpperCase())}(...args).resolves(value)`,
);
this.name = "NotImplementedError";
Expand Down
4 changes: 2 additions & 2 deletions packages/drift/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export type AnyFunction = (...args: any) => any;
* Combines members of an intersection into a readable type.
* @see https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg
*/
export type Prettify<T> = { [K in keyof T]: T[K] } & {};
export type Pretty<T> = { [K in keyof T]: T[K] } & {};

/**
* Replace properties in `T` with properties in `U`.
*/
export type ReplaceKeys<T, U> = Prettify<Omit<T, keyof U> & U>;
export type ReplaceKeys<T, U> = Pretty<Omit<T, keyof U> & U>;

/**
* Make all properties in `T` whose keys are in the union `K` required and
Expand Down

0 comments on commit 1651cfa

Please sign in to comment.