@@ -116,14 +116,17 @@ type decoded struct {
116116type RollupClient interface {
117117 GetEnqueue (index uint64 ) (* types.Transaction , error )
118118 GetLatestEnqueue () (* types.Transaction , error )
119- GetTransaction (uint64 ) (* types.Transaction , error )
120- GetLatestTransaction () (* types.Transaction , error )
119+ GetLatestEnqueueIndex () (* uint64 , error )
120+ GetTransaction (uint64 , Backend ) (* types.Transaction , error )
121+ GetLatestTransaction (Backend ) (* types.Transaction , error )
122+ GetLatestTransactionIndex (Backend ) (* uint64 , error )
121123 GetEthContext (uint64 ) (* EthContext , error )
122124 GetLatestEthContext () (* EthContext , error )
123125 GetLastConfirmedEnqueue () (* types.Transaction , error )
124126 GetLatestTransactionBatch () (* Batch , []* types.Transaction , error )
127+ GetLatestTransactionBatchIndex () (* uint64 , error )
125128 GetTransactionBatch (uint64 ) (* Batch , []* types.Transaction , error )
126- SyncStatus () (* SyncStatus , error )
129+ SyncStatus (Backend ) (* SyncStatus , error )
127130 GetL1GasPrice () (* big.Int , error )
128131}
129132
@@ -270,6 +273,43 @@ func (c *Client) GetLatestEnqueue() (*types.Transaction, error) {
270273 return tx , nil
271274}
272275
276+ // GetLatestEnqueueIndex returns the latest `enqueue()` index
277+ func (c * Client ) GetLatestEnqueueIndex () (* uint64 , error ) {
278+ tx , err := c .GetLatestEnqueue ()
279+ if err != nil {
280+ return nil , err
281+ }
282+ index := tx .GetMeta ().QueueIndex
283+ if index == nil {
284+ return nil , errors .New ("Latest queue index is nil" )
285+ }
286+ return index , nil
287+ }
288+
289+ // GetLatestTransactionIndex returns the latest CTC index that has been batch
290+ // submitted or not, depending on the backend
291+ func (c * Client ) GetLatestTransactionIndex (backend Backend ) (* uint64 , error ) {
292+ tx , err := c .GetLatestTransaction (backend )
293+ if err != nil {
294+ return nil , err
295+ }
296+ index := tx .GetMeta ().Index
297+ if index == nil {
298+ return nil , errors .New ("Latest index is nil" )
299+ }
300+ return index , nil
301+ }
302+
303+ // GetLatestTransactionBatchIndex returns the latest transaction batch index
304+ func (c * Client ) GetLatestTransactionBatchIndex () (* uint64 , error ) {
305+ batch , _ , err := c .GetLatestTransactionBatch ()
306+ if err != nil {
307+ return nil , err
308+ }
309+ index := batch .Index
310+ return & index , nil
311+ }
312+
273313// batchedTransactionToTransaction converts a transaction into a
274314// types.Transaction that can be consumed by the SyncService
275315func batchedTransactionToTransaction (res * transaction , signer * types.EIP155Signer ) (* types.Transaction , error ) {
@@ -364,12 +404,15 @@ func batchedTransactionToTransaction(res *transaction, signer *types.EIP155Signe
364404}
365405
366406// GetTransaction will get a transaction by Canonical Transaction Chain index
367- func (c * Client ) GetTransaction (index uint64 ) (* types.Transaction , error ) {
407+ func (c * Client ) GetTransaction (index uint64 , backend Backend ) (* types.Transaction , error ) {
368408 str := strconv .FormatUint (index , 10 )
369409 response , err := c .client .R ().
370410 SetPathParams (map [string ]string {
371411 "index" : str ,
372412 }).
413+ SetQueryParams (map [string ]string {
414+ "backend" : backend .String (),
415+ }).
373416 SetResult (& TransactionResponse {}).
374417 Get ("/transaction/index/{index}" )
375418
@@ -385,9 +428,12 @@ func (c *Client) GetTransaction(index uint64) (*types.Transaction, error) {
385428
386429// GetLatestTransaction will get the latest transaction, meaning the transaction
387430// with the greatest Canonical Transaction Chain index
388- func (c * Client ) GetLatestTransaction () (* types.Transaction , error ) {
431+ func (c * Client ) GetLatestTransaction (backend Backend ) (* types.Transaction , error ) {
389432 response , err := c .client .R ().
390433 SetResult (& TransactionResponse {}).
434+ SetQueryParams (map [string ]string {
435+ "backend" : backend .String (),
436+ }).
391437 Get ("/transaction/latest" )
392438
393439 if err != nil {
@@ -477,9 +523,12 @@ func (c *Client) GetLastConfirmedEnqueue() (*types.Transaction, error) {
477523}
478524
479525// SyncStatus will query the remote server to determine if it is still syncing
480- func (c * Client ) SyncStatus () (* SyncStatus , error ) {
526+ func (c * Client ) SyncStatus (backend Backend ) (* SyncStatus , error ) {
481527 response , err := c .client .R ().
482528 SetResult (& SyncStatus {}).
529+ SetQueryParams (map [string ]string {
530+ "backend" : backend .String (),
531+ }).
483532 Get ("/eth/syncing" )
484533
485534 if err != nil {
@@ -533,8 +582,8 @@ func (c *Client) GetTransactionBatch(index uint64) (*Batch, []*types.Transaction
533582// parseTransactionBatchResponse will turn a TransactionBatchResponse into a
534583// Batch and its corresponding types.Transactions
535584func parseTransactionBatchResponse (txBatch * TransactionBatchResponse , signer * types.EIP155Signer ) (* Batch , []* types.Transaction , error ) {
536- if txBatch == nil {
537- return nil , nil , nil
585+ if txBatch == nil || txBatch . Batch == nil {
586+ return nil , nil , errElementNotFound
538587 }
539588 batch := txBatch .Batch
540589 txs := make ([]* types.Transaction , len (txBatch .Transactions ))
0 commit comments