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

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation SC-Eng
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant