Skip to content

Commit 56a604b

Browse files
committed
Add EventsByHandle to the client interface
1 parent 2f4a7b5 commit 56a604b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

client.go

+26
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,22 @@ type AptosRpcClient interface {
217217
// client.AccountTransactions(AccountOne, 1, 100) // Returns 100 transactions for 0x1
218218
AccountTransactions(address AccountAddress, start *uint64, limit *uint64) (data []*api.CommittedTransaction, err error)
219219

220+
// EventsByHandle retrieves events by event handle and field name for a given account.
221+
//
222+
// Arguments:
223+
// - account - The account address to get events for
224+
// - eventHandle - The event handle struct tag
225+
// - fieldName - The field in the event handle struct
226+
// - start - The starting sequence number. nil for most recent events
227+
// - limit - The number of events to return, 100 by default
228+
EventsByHandle(
229+
account AccountAddress,
230+
eventHandle string,
231+
fieldName string,
232+
start *uint64,
233+
limit *uint64,
234+
) ([]*api.Event, error)
235+
220236
// SubmitTransaction Submits an already signed transaction to the blockchain
221237
//
222238
// sender := NewEd25519Account()
@@ -649,6 +665,16 @@ func (client *Client) AccountTransactions(address AccountAddress, start *uint64,
649665
return client.nodeClient.AccountTransactions(address, start, limit)
650666
}
651667

668+
// EventsByHandle Get events by handle and field name for an account.
669+
// Start is a sequence number. Nil for most recent events.
670+
// Limit is a number of events to return, 100 by default.
671+
//
672+
// client.EventsByHandle(AccountOne, "0x2", "transfer", 0, 2) // Returns 2 events
673+
// client.EventsByHandle(AccountOne, "0x2", "transfer", 1, 100) // Returns 100 events
674+
func (client *Client) EventsByHandle(account AccountAddress, eventHandle string, fieldName string, start *uint64, limit *uint64) ([]*api.Event, error) {
675+
return client.nodeClient.EventsByHandle(account, eventHandle, fieldName, start, limit)
676+
}
677+
652678
// SubmitTransaction Submits an already signed transaction to the blockchain
653679
//
654680
// sender := NewEd25519Account()

0 commit comments

Comments
 (0)