Skip to content

Commit

Permalink
refactor: add spec6 types
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeR26 committed Jun 6, 2024
1 parent b01893c commit 7702d9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/types/lib/contract/abi.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ENUM_EVENT, EVENT_FIELD, STRUCT_EVENT } from '../../api/rpcspec_0_6/contract';

Check failure on line 1 in src/types/lib/contract/abi.ts

View workflow job for this annotation

GitHub Actions / Run test on rpc-devnet / Run tests

Module '"../../api/rpcspec_0_6/contract"' declares 'ENUM_EVENT' locally, but it is not exported.

Check failure on line 1 in src/types/lib/contract/abi.ts

View workflow job for this annotation

GitHub Actions / Run test on rpc-devnet / Run tests

Module '"../../api/rpcspec_0_6/contract"' declares 'EVENT_FIELD' locally, but it is not exported.

Check failure on line 1 in src/types/lib/contract/abi.ts

View workflow job for this annotation

GitHub Actions / Run test on rpc-devnet / Run tests

Module '"../../api/rpcspec_0_6/contract"' declares 'STRUCT_EVENT' locally, but it is not exported.

/** ABI */
export type Abi = ReadonlyArray<FunctionAbi | AbiEvent | AbiStruct | InterfaceAbi | any>;

Expand Down Expand Up @@ -58,25 +60,22 @@ export type AbiEvents = { [hash: string]: AbiEvent };
// if Cairo 0 then definition of an event
export type AbiEvent = CairoEvent | LegacyEvent;

// CairoEvent is CairoEventDefinition type if we have a leaf (end of the arborescence for an event), otherwise a new branch is created. Only for Cairo 1
// CairoEvent is CairoEventDefinition type if we have a leaf (end of the arborescence for an event), otherwise a new node level is created. Only for Cairo 1
export type CairoEvent = CairoEventDefinition | AbiEvents;

export type CairoEventDefinition = {
export type CairoEventDefinition = STRUCT_EVENT & {
name: string;
members: EventEntry[];
kind: 'struct';
type: 'event';
};

export type CairoEventVariant = {
kind: 'nested' | 'flat';
export type CairoEventVariant = ENUM_EVENT & {
name: string;
type: string;
};

export type LegacyEvent = {
name: string;
type: 'event';
data: EventEntry[];
keys: EventEntry[];
data: EVENT_FIELD[];
keys: EVENT_FIELD[];
};
2 changes: 1 addition & 1 deletion src/utils/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function getCairo1AbiEvents(abi: Abi) {
while (true) {
const eventEnum = abiEventsEnums.find((eventE) => eventE.variants.some(findName));
if (typeof eventEnum === 'undefined') break;
const variant: CairoEventVariant = eventEnum.variants.find(findName);
const variant = eventEnum.variants.find(findName);
nameList.unshift(variant.name);
if (variant.kind === 'flat') flat = true;
name = eventEnum.name;
Expand Down

0 comments on commit 7702d9c

Please sign in to comment.