-
Notifications
You must be signed in to change notification settings - Fork 157
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
Add infinite event streaming pagination example #1380
base: main
Are you sure you want to change the base?
Conversation
Preview is available here: |
Events are ephemeral, the data retention window is a maximum of 7 days. See the [ingestion guide](../../../build/guides/events/ingest.mdx) to learn how to work with this constraint. | ||
|
||
::: | ||
`ContractEvents` are emitted in Stellar Core's `TransactionMeta`. You can see in the [TransactionMetaV3] XDR below that there is a list of `OperationEvents` called `events`. Each `OperationEvent` corresponds to an operation in a transaction, and itself contains a list of `ContractEvents`. Note that `events` will only be populated if the transaction succeeds. | ||
|
||
[transactionmetav3]: #transactionmetav3 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below this there is a line which says:
An event also contains a data object of any value or type including types defined by contracts using
#[contracttype]
I don't think it's clear that #[contracttype]
is referring to a rust macro. Is there a page we can link to which describes how #[contracttype]
is used in soroban smart contracts?
const s = new Server("https://soroban-testnet.stellar.org"); | ||
|
||
function main() { | ||
const r = await s.getLatestLedger(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what r
stands for. maybe rename the variable to latestLedger
?
|
||
const xlmFilter = { | ||
type: "contract", | ||
contractIds: ["CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there any helper functions in the typescript sdk to compute the SAC address for a given stellar asset? I think that could be more instructive than hard coding the xlm contract on testnet
filters: [xlmFilter], | ||
}); | ||
|
||
await new Promise(r => setTimeout(r, 5000)); // pause until the next ledger-ish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the wait occur before we request the next page? Also, what if it takes longer than 5 seconds for the next ledger to appear, is there a way we can handle that case?
The main purpose is to highlight
humanizeEvents
but it's a little hard to shoe-horn in without a fuller example.Closes part of #471.
Direct link to page in preview.