Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Update docs to include how to deal with events #202

@alilloig

Description

@alilloig

Issue To Be Solved

Checking the data emitted by an event is possible using the js testing framework but is not showcased on the docs

Suggest A Solution

Include a subsection on the Send Transactions section telling how to it and including a little example.

Message from Amit explaining how it works

when executing a transaction, the result from its promise contains an events array which should give you it.
some old code of mine which should mostly work still, except might be result[0].events instead of result.events:

result = await shallPass(await sendTransaction({
      code: cadenceCode,
      signers: [ accountA ],
      args: [ null, 2, 1, 1, 1, (tomorrow.getTime() / 1000).toString() ],
      addressMap: addressMap
    }))

    expect(result.events.length).toBe(2)
    expect(result.events[0].type.indexOf('ZayTrader.TradeCollectionInitialized') > 0).toBe(true)
    expect(result.events[1].type.indexOf('ZayTrader.TradeOfferAvailable') > 0).toBe(true)

This is how result[0].events looks like with a single event

[
    {
        "data": {"sequence": "0", "versionTable": {"15": {"isBackwardsCompatible": true, "major": "0", "minor": "1", "patch": "2", "preRelease": "alpha.1"}}}, 
        "eventIndex": 0, 
        "transactionId": "a0f210b5f0710dac3a02071b3a5492501bb02aabdb88e132a3b41f3e576cb6c3", 
        "transactionIndex": 1, "type": "A.01cf0e2f2f715450.NodeVersionBeacon.NodeVersionTableUpdated"
    }
]

Metadata

Metadata

Assignees

Labels

SC-EngdocumentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions