-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(store): add HelloStore event to TS event definitions (#1724)
- Loading branch information
Showing
3 changed files
with
43 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { parseAbiItem, AbiEvent } from "abitype"; | ||
import IStoreAbi from "../out/IStore.sol/IStore.abi.json"; | ||
import { helloStoreEvent } from "./storeEvents"; | ||
|
||
function normalizeAbiEvent(event: AbiEvent) { | ||
return { | ||
type: event.type, | ||
name: event.name, | ||
inputs: event.inputs.map((input) => ({ | ||
type: input.type, | ||
name: input.name, | ||
...(input.indexed ? { indexed: true } : null), | ||
})), | ||
} as const; | ||
} | ||
|
||
describe("Store events", () => { | ||
it("should match the HelloStore event ABI", () => { | ||
const forgeAbiItem = IStoreAbi.find((item) => item.type === "event" && item.name === "HelloStore") as AbiEvent; | ||
expect(normalizeAbiEvent(parseAbiItem(helloStoreEvent))).toMatchObject(normalizeAbiEvent(forgeAbiItem)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
export const helloStoreEvent = "event HelloStore(bytes32 indexed storeVersion)"; | ||
|
||
export const storeSetRecordEvent = | ||
"event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)"; | ||
|
||
export const storeSpliceStaticDataEvent = | ||
"event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)"; | ||
|
||
export const storeSpliceDynamicDataEvent = | ||
"event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)"; | ||
|
||
export const storeDeleteRecordEvent = "event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)"; | ||
|
||
// Store protocol events | ||
export const storeEvents = [ | ||
"event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)", | ||
"event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)", | ||
"event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)", | ||
"event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)", | ||
storeSetRecordEvent, | ||
storeSpliceStaticDataEvent, | ||
storeSpliceDynamicDataEvent, | ||
storeDeleteRecordEvent, | ||
] as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters