Skip to content

Commit

Permalink
remove filter from event names
Browse files Browse the repository at this point in the history
  • Loading branch information
kyscott18 committed Jan 2, 2025
1 parent ad4a41a commit 81019f5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 48 deletions.
38 changes: 1 addition & 37 deletions packages/core/src/types/virtual.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const account = onchainTable("account", (p) => ({

const schema = { account };

test("FormatEventNames without filter", () => {
test("FormatEventNames", () => {
type a = Virtual.FormatEventNames<
// ^?
{
Expand All @@ -114,42 +114,6 @@ test("FormatEventNames without filter", () => {
assertType<eventNames>({} as any as a);
});

test("FormatEvent names with filter", () => {
type a = Virtual.FormatEventNames<
// ^?
{
contract: { abi: abi; network: ""; filter: { event: "Event1()" } };
},
{},
{}
>;

type eventNames = "contract:setup" | "contract:Event1()";

assertType<a>({} as any as eventNames);
assertType<eventNames>({} as any as a);
});

test("FormatEvent names with filter array", () => {
type a = Virtual.FormatEventNames<
// ^?
{
contract: {
abi: abi;
network: "";
filter: { event: readonly ["Event1()"] };
};
},
{},
{}
>;

type eventNames = "contract:setup" | "contract:Event1()";

assertType<a>({} as any as eventNames);
assertType<eventNames>({} as any as a);
});

test("FormatEventNames with semi-weak abi", () => {
type a = Virtual.FormatEventNames<
// ^?
Expand Down
12 changes: 1 addition & 11 deletions packages/core/src/types/virtual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,7 @@ export namespace Virtual {
contract extends Config["contracts"][string],
///
safeEventNames = SafeEventNames<contract["abi"]>,
> = string extends safeEventNames
? never
: contract extends {
filter: { event: infer event extends string | readonly string[] };
}
? event extends safeEventNames
? event
: event[number] extends safeEventNames
? event[number]
: safeEventNames
: safeEventNames;
> = string extends safeEventNames ? never : safeEventNames;

type _FormatFunctionNames<
contract extends Config["contracts"][string],
Expand Down

0 comments on commit 81019f5

Please sign in to comment.