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

Add infinite event streaming pagination example #1380

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Shaptic
Copy link
Contributor

@Shaptic Shaptic commented Mar 7, 2025

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.

@Shaptic Shaptic requested review from ElliotFriend and a team March 7, 2025 21:27
@stellar-jenkins
Copy link

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

Copy link
Contributor

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();
Copy link
Contributor

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"],
Copy link
Contributor

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
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants