Skip to main content
Version: Next

Namespace: events

Functions​

isAbiEvent​

â–¸ isAbiEvent(object): boolean

Check if an ABI entry is related to events.

Parameters​

NameTypeDescription
objectAbiEntryan Abi entry

Returns​

boolean

true if this Abi Entry is related to an event

Example

// use of a transaction receipt

Defined in​

src/utils/events/index.ts:36


getAbiEvents​

â–¸ getAbiEvents(abi): AbiEvents

Retrieves the events from the given ABI (from Cairo 0 or Cairo 1 contract).

Is able to handle Cairo 1 events nested in Cairo components.

Parameters​

NameTypeDescription
abiAbiThe ABI to extract events from.

Returns​

AbiEvents

  • An object containing the hashes and the definition of the events.

Example

const result = events.getAbiEvents(abi);
// result = {
// '0x22ea134d4126804c60797e633195f8c9aa5fd6d1567e299f4961d0e96f373ee':
// { '0x34e55c1cd55f1338241b50d352f0e91c7e4ffad0e4271d64eb347589ebdfd16': {
// kind: 'struct', type: 'event',
// name: 'ka::ExComponent::ex_logic_component::Mint',
// members: [{
// name: 'spender',
// type: 'core::starknet::contract_address::ContractAddress',
// kind: 'key'},
// { name: 'value', type: 'core::integer::u256', kind: 'data' }]},
// ...

Defined in​

src/utils/events/index.ts:154


parseEvents​

â–¸ parseEvents(providerReceivedEvents, abiEvents, abiStructs, abiEnums): ParsedEvents

Parse raw events and structure them into response object based on a contract structs and defined events

Parameters​

NameTypeDescription
providerReceivedEventsEVENT[]Array of raw events
abiEventsAbiEventsEvents defined in the abi
abiStructsAbiStructsStructs defined in the abi
abiEnumsAbiEnumsEnums defined in the abi

Returns​

ParsedEvents

parsed events corresponding to the abi

Example

const abiEvents = events.getAbiEvents(sierra.abi);
const abiStructs = CallData.getAbiStruct(sierra.abi);
const abiEnums = CallData.getAbiEnum(sierra.abi);
const result = events.parseEvents(myEvents, abiEvents, abiStructs, abiEnums);
// result = [{test::ExCh::ex_ch::Trade: {
maker: 7548613724711489396448209137n,
taker: 6435850562375218974960297344n,
router_maker: 0n,
}}]

Defined in​

src/utils/events/index.ts:196


parseUDCEvent​

â–¸ parseUDCEvent(txReceipt): DeployContractUDCResponse

Parse Transaction Receipt Event from UDC invoke transaction and create DeployContractResponse compatible response with addition of the UDC Event data

Parameters​

NameType
txReceiptInvokeTransactionReceiptResponse

Returns​

DeployContractUDCResponse

parsed UDC event data

Defined in​

src/utils/events/index.ts:258