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

Include in docs how to check events #203

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions docs/send-transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,46 @@ const main = async () => {

main()
```
## Transaction result

As showed before, the result of sending a transaction can be captured on a variable or constant, allowing you to access its result and any errors that may occur. This can be specially interesting for testing the behavior of any events that were emitted during the execution of the transaction.

### Checking events

The `events` object array can be found inside the result object, following the previous example:

```
const [result, error, logs] = await shallPass(
sendTransaction("log-message", [], args)
)
console.log({result})
```
The console output will be:
```
{
blockId: '',
status: 4,
statusString: 'SEALED',
statusCode: 0,
errorMessage: '',
events: [ [Object] ]
}
```

And if we dig a little further on the events object:
```
console.log({result.events})
```
We will get the array containing the emitted events, that will look something like this:
```
[
{
type: 'eventType',
transactionId: 'txId',
transactionIndex: 1,
eventIndex: 0,
data: {}
}
]
```
Most times you will want to access the `data` object inside each emitted event to test that the info emitted matches what is expected.