Namespace: events
Functions​
isAbiEvent​
â–¸ isAbiEvent(object
): boolean
Check if an ABI entry is related to events.
Parameters​
Name | Type | Description |
---|---|---|
object | AbiEntry | an Abi entry |
Returns​
boolean
true if this Abi Entry is related to an event
Example
// use of a transaction receipt
Defined in​
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​
Name | Type | Description |
---|---|---|
abi | Abi | The ABI to extract events from. |
Returns​
- 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​
isObject​
â–¸ isObject(item
): boolean
Checks if a given value is an object (Object or Array)
Parameters​
Name | Type | Description |
---|---|---|
item | any | the tested item |
Returns​
boolean
Example
const result = events.isObject({event: "pending"});
// result = true
Defined in​
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​
Name | Type | Description |
---|---|---|
providerReceivedEvents | EVENT [] | Array of raw events |
abiEvents | AbiEvents | Events defined in the abi |
abiStructs | AbiStructs | Structs defined in the abi |
abiEnums | AbiEnums | Enums defined in the abi |
Returns​
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​
parseUDCEvent​
â–¸ parseUDCEvent(txReceipt
): Object
Parse Transaction Receipt Event from UDC invoke transaction and create DeployContractResponse compatible response with addition of the UDC Event data
Parameters​
Name | Type |
---|---|
txReceipt | InvokeTransactionReceiptResponse |
Returns​
Object
DeployContractResponse | UDC Event Response data
Name | Type |
---|---|
transaction_hash | string |
contract_address | string |
address | string |
deployer | string |
unique | string |
classHash | string |
calldata_len | string |
calldata | string [] |
salt | string |