Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs to include how to deal with events #202

Open
alilloig opened this issue Jan 13, 2023 · 0 comments · May be fixed by #203
Open

Update docs to include how to deal with events #202

alilloig opened this issue Jan 13, 2023 · 0 comments · May be fixed by #203
Assignees
Labels
documentation Improvements or additions to documentation SC-Eng

Comments

@alilloig
Copy link
Member

alilloig commented Jan 13, 2023

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"
    }
]
@alilloig alilloig added documentation Improvements or additions to documentation SC-Eng labels Jan 13, 2023
@alilloig alilloig self-assigned this Jan 13, 2023
@alilloig alilloig linked a pull request Jan 20, 2023 that will close this issue
6 tasks
@alilloig alilloig linked a pull request Jan 20, 2023 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation SC-Eng
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant