Closed livthomas closed 5 days ago
It would be nice if
Program.addEventListener
method also took an optionalcommitment
parameter so we could use a single Solana connection across the whole app.
Sounds great! Feel free to create a PR for this, or let me know if you'd like me to add it.
I have implemented it in https://github.com/coral-xyz/anchor/pull/3052
Right now, if you call Program.addEventListener, you only get subscribed to Anchor events at the default commitment level set in the
Connection
instance. And if you want to receive events at multiple commitment levels, you need to create a separate connection for each.It looks like Connection.onLogs method provides a third optional
commitment
parameter so it is actually possible to subscribe to the same event at multiple commitment levels using a single connection.It would be nice if
Program.addEventListener
method also took an optionalcommitment
parameter so we could use a single Solana connection across the whole app. Right now, we are basically forced to create multiple connection instances just because Anchor doesn't support this.