diff --git a/services/sinner/api/resolver_test.go b/services/sinner/api/resolver_test.go index f46752ca74..95a6f2f59a 100644 --- a/services/sinner/api/resolver_test.go +++ b/services/sinner/api/resolver_test.go @@ -27,10 +27,15 @@ func (t *APISuite) TestGetOrigin() { err := t.db.StoreOriginSent(t.GetTestContext(), originSent) Nil(t.T(), err) - result, err := t.sinnerAPI.GetOriginInfo(t.GetTestContext(), txHash, int(chainID)) + result, err := t.sinnerAPI.GetOriginInfo(t.GetTestContext(), messageHash) Nil(t.T(), err) NotNil(t.T(), result) Equal(t.T(), txHash, *result.Response.OriginTxHash) + + results, err := t.sinnerAPI.GetOriginInfos(t.GetTestContext(), txHash, int(chainID)) + Nil(t.T(), err) + NotNil(t.T(), results) + Equal(t.T(), txHash, *results.Response[0].OriginTxHash) } func (t *APISuite) TestGetExecuted() { @@ -51,10 +56,15 @@ func (t *APISuite) TestGetExecuted() { err := t.db.StoreExecuted(t.GetTestContext(), executed) Nil(t.T(), err) - result, err := t.sinnerAPI.GetDestinationInfo(t.GetTestContext(), txHash, int(chainID)) + result, err := t.sinnerAPI.GetDestinationInfo(t.GetTestContext(), messageHash) Nil(t.T(), err) NotNil(t.T(), result) Equal(t.T(), txHash, *result.Response.TxHash) + + results, err := t.sinnerAPI.GetDestinationInfos(t.GetTestContext(), txHash, int(chainID)) + Nil(t.T(), err) + NotNil(t.T(), results) + Equal(t.T(), txHash, *results.Response[0].TxHash) } func (t *APISuite) TestMessageStatus() { diff --git a/services/sinner/contracts/origin/parser.go b/services/sinner/contracts/origin/parser.go index f65683bead..7c9f080065 100644 --- a/services/sinner/contracts/origin/parser.go +++ b/services/sinner/contracts/origin/parser.go @@ -117,7 +117,7 @@ func (p *ParserImpl) ParseSent(log ethTypes.Log) (*model.OriginSent, error) { TxHash: iFace.Raw.TxHash.String(), TxIndex: iFace.Raw.TxIndex, DestinationChainID: iFace.Destination, - Message: common.Bytes2Hex(iFace.Message[:]), + Message: common.Bytes2Hex(iFace.Message), Nonce: iFace.Nonce, MessageHash: common.Bytes2Hex(iFace.MessageHash[:]), } diff --git a/services/sinner/db/event.go b/services/sinner/db/event.go index a27157420d..813ed8414d 100644 --- a/services/sinner/db/event.go +++ b/services/sinner/db/event.go @@ -31,14 +31,18 @@ type EventDBWriter interface { // //nolint:interfacebloat type EventDBReader interface { - // RetrieveOriginSent gets the OriginSent record. - RetrieveOriginSent(ctx context.Context, chainID uint32, txHash string) (model.OriginSent, error) + // RetrieveOriginSent gets the Origin Sent event with a message hash. + RetrieveOriginSent(ctx context.Context, messageHash string) (model.OriginSent, error) + // RetrieveOriginSents gets the Origin Sent events tied to a tx hash. + RetrieveOriginSents(ctx context.Context, chainID uint32, txHash string) ([]model.OriginSent, error) + // RetrieveExecuted gets the Executed event with a message hash. + RetrieveExecuted(ctx context.Context, messageHash string) (model.Executed, error) + // RetrieveExecuteds gets the Executed events tied to a tx hash. + RetrieveExecuteds(ctx context.Context, chainID uint32, txHash string) ([]model.Executed, error) // RetrieveMessageStatus gets status of a message. RetrieveMessageStatus(ctx context.Context, messageHash string) (graphqlModel.MessageStatus, error) // RetrieveLastStoredBlock gets the last block stored in sinner. RetrieveLastStoredBlock(ctx context.Context, chainID uint32, address common.Address) (uint64, error) - // RetrieveExecuted gets the Executed record. - RetrieveExecuted(ctx context.Context, chainID uint32, txHash string) (model.Executed, error) } // EventDB stores events. diff --git a/services/sinner/db/mocks/event_db.go b/services/sinner/db/mocks/event_db.go index 5f9c59dc65..3f9484f0e4 100644 --- a/services/sinner/db/mocks/event_db.go +++ b/services/sinner/db/mocks/event_db.go @@ -23,17 +23,40 @@ type EventDB struct { mock.Mock } -// RetrieveExecuted provides a mock function with given fields: ctx, chainID, txHash -func (_m *EventDB) RetrieveExecuted(ctx context.Context, chainID uint32, txHash string) (model.Executed, error) { - ret := _m.Called(ctx, chainID, txHash) +// RetrieveExecuted provides a mock function with given fields: ctx, messageHash +func (_m *EventDB) RetrieveExecuted(ctx context.Context, messageHash string) (model.Executed, error) { + ret := _m.Called(ctx, messageHash) var r0 model.Executed - if rf, ok := ret.Get(0).(func(context.Context, uint32, string) model.Executed); ok { - r0 = rf(ctx, chainID, txHash) + if rf, ok := ret.Get(0).(func(context.Context, string) model.Executed); ok { + r0 = rf(ctx, messageHash) } else { r0 = ret.Get(0).(model.Executed) } + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, messageHash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RetrieveExecuteds provides a mock function with given fields: ctx, chainID, txHash +func (_m *EventDB) RetrieveExecuteds(ctx context.Context, chainID uint32, txHash string) ([]model.Executed, error) { + ret := _m.Called(ctx, chainID, txHash) + + var r0 []model.Executed + if rf, ok := ret.Get(0).(func(context.Context, uint32, string) []model.Executed); ok { + r0 = rf(ctx, chainID, txHash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.Executed) + } + } + var r1 error if rf, ok := ret.Get(1).(func(context.Context, uint32, string) error); ok { r1 = rf(ctx, chainID, txHash) @@ -86,17 +109,40 @@ func (_m *EventDB) RetrieveMessageStatus(ctx context.Context, messageHash string return r0, r1 } -// RetrieveOriginSent provides a mock function with given fields: ctx, chainID, txHash -func (_m *EventDB) RetrieveOriginSent(ctx context.Context, chainID uint32, txHash string) (model.OriginSent, error) { - ret := _m.Called(ctx, chainID, txHash) +// RetrieveOriginSent provides a mock function with given fields: ctx, messageHash +func (_m *EventDB) RetrieveOriginSent(ctx context.Context, messageHash string) (model.OriginSent, error) { + ret := _m.Called(ctx, messageHash) var r0 model.OriginSent - if rf, ok := ret.Get(0).(func(context.Context, uint32, string) model.OriginSent); ok { - r0 = rf(ctx, chainID, txHash) + if rf, ok := ret.Get(0).(func(context.Context, string) model.OriginSent); ok { + r0 = rf(ctx, messageHash) } else { r0 = ret.Get(0).(model.OriginSent) } + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, messageHash) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RetrieveOriginSents provides a mock function with given fields: ctx, chainID, txHash +func (_m *EventDB) RetrieveOriginSents(ctx context.Context, chainID uint32, txHash string) ([]model.OriginSent, error) { + ret := _m.Called(ctx, chainID, txHash) + + var r0 []model.OriginSent + if rf, ok := ret.Get(0).(func(context.Context, uint32, string) []model.OriginSent); ok { + r0 = rf(ctx, chainID, txHash) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.OriginSent) + } + } + var r1 error if rf, ok := ret.Get(1).(func(context.Context, uint32, string) error); ok { r1 = rf(ctx, chainID, txHash) diff --git a/services/sinner/db/model/model.go b/services/sinner/db/model/model.go index 9af4daab86..fa7882f923 100644 --- a/services/sinner/db/model/model.go +++ b/services/sinner/db/model/model.go @@ -64,7 +64,7 @@ type OriginSent struct { // BlockNumber is the block number in which the tx occurred. BlockNumber uint64 `gorm:"column:block_number"` // TxHash is the hash of the tx. - TxHash string `gorm:"column:tx_hash;primaryKey;index:idx_tx_hash_origin,priority:1,sort:desc"` + TxHash string `gorm:"column:tx_hash;index:idx_tx_hash_origin,priority:1,sort:desc"` // TxIndex is the index of the tx in a block. TxIndex uint `gorm:"column:tx_index"` // Sender is the address of the sender of the tx. @@ -76,7 +76,7 @@ type OriginSent struct { // MessageID is the keccaked message. MessageID string `gorm:"column:message_id"` // MessageHash is the message hash. - MessageHash string `gorm:"column:message_hash"` + MessageHash string `gorm:"column:message_hash;primaryKey"` // ChainID is the chain id. ChainID uint32 `gorm:"column:chain_id;primaryKey;index:idx_tx_hash_origin,priority:2,sort:desc"` // Destination is the destination chain id. @@ -114,11 +114,11 @@ type Executed struct { // BlockNumber is the block number in which the tx occurred. BlockNumber uint64 `gorm:"column:block_number"` // TxHash is the hash of the tx. - TxHash string `gorm:"column:tx_hash;primaryKey;index:idx_tx_hash_executed,priority:1,sort:desc"` + TxHash string `gorm:"column:tx_hash;index:idx_tx_hash_executed,priority:1,sort:desc"` // TxIndex is the index of the tx in a block. TxIndex uint `gorm:"column:tx_index"` // MessageHash is the message hash. - MessageHash string `gorm:"column:message_hash"` + MessageHash string `gorm:"column:message_hash;primaryKey"` // ChainID is the chain id. ChainID uint32 `gorm:"column:chain_id;primaryKey;index:idx_tx_hash_executed,priority:2,sort:desc"` // RemoteDomain is the destination. diff --git a/services/sinner/db/read_test.go b/services/sinner/db/read_test.go index f1f61fa2a9..cc4c2b1551 100644 --- a/services/sinner/db/read_test.go +++ b/services/sinner/db/read_test.go @@ -89,11 +89,17 @@ func (t *DBSuite) TestRetrieveOriginSent() { Nil(t.T(), err) // Test: Retrieve and validate the OriginSent record - retrievedRecord, err := testDB.RetrieveOriginSent(t.GetTestContext(), chainID, txHash) + retrievedRecord, err := testDB.RetrieveOriginSent(t.GetTestContext(), messageHash) Nil(t.T(), err) Equal(t.T(), txHash, retrievedRecord.TxHash) Equal(t.T(), chainID, retrievedRecord.ChainID) Equal(t.T(), messageHash, retrievedRecord.MessageHash) + + retrievedRecords, err := testDB.RetrieveOriginSents(t.GetTestContext(), chainID, txHash) + Nil(t.T(), err) + Equal(t.T(), txHash, retrievedRecords[0].TxHash) + Equal(t.T(), chainID, retrievedRecords[0].ChainID) + Equal(t.T(), messageHash, retrievedRecords[0].MessageHash) }) } @@ -118,10 +124,16 @@ func (t *DBSuite) TestRetrieveExecuted() { Nil(t.T(), err) // Test: Retrieve and validate the Executed record - retrievedRecord, err := testDB.RetrieveExecuted(t.GetTestContext(), chainID, txHash) + retrievedRecord, err := testDB.RetrieveExecuted(t.GetTestContext(), messageHash) Nil(t.T(), err) Equal(t.T(), txHash, retrievedRecord.TxHash) Equal(t.T(), chainID, retrievedRecord.ChainID) Equal(t.T(), messageHash, retrievedRecord.MessageHash) + + retrievedRecords, err := testDB.RetrieveExecuteds(t.GetTestContext(), chainID, txHash) + Nil(t.T(), err) + Equal(t.T(), txHash, retrievedRecords[0].TxHash) + Equal(t.T(), chainID, retrievedRecords[0].ChainID) + Equal(t.T(), messageHash, retrievedRecords[0].MessageHash) }) } diff --git a/services/sinner/db/sql/base/read.go b/services/sinner/db/sql/base/read.go index 92085d158d..6e974c9d8d 100644 --- a/services/sinner/db/sql/base/read.go +++ b/services/sinner/db/sql/base/read.go @@ -12,7 +12,7 @@ import ( func (s Store) RetrieveMessageStatus(ctx context.Context, messageHash string) (graphqlModel.MessageStatus, error) { var record model.MessageStatus - err := s.DB().WithContext(ctx). + err := s.DB().WithContext(ctx).Model(&model.MessageStatus{}). Where("message_hash = ?", messageHash). First(&record).Error @@ -41,7 +41,7 @@ func (s Store) RetrieveMessageStatus(ctx context.Context, messageHash string) (g // RetrieveLastStoredBlock gets the last stored block. func (s Store) RetrieveLastStoredBlock(ctx context.Context, chainID uint32, address common.Address) (uint64, error) { var lastIndexed model.LastIndexed - err := s.DB().WithContext(ctx). + err := s.DB().WithContext(ctx).Model(&model.LastIndexed{}). Where("contract_address = ? AND chain_id = ?", address.String(), chainID). Order("block_number DESC").First(&lastIndexed).Error @@ -56,28 +56,54 @@ func (s Store) RetrieveLastStoredBlock(ctx context.Context, chainID uint32, addr return lastIndexed.BlockNumber, nil } -// RetrieveOriginSent gets the OriginSent record. -func (s Store) RetrieveOriginSent(ctx context.Context, chainID uint32, txHash string) (model.OriginSent, error) { +// RetrieveOriginSent gets the Origin Sent event. +func (s Store) RetrieveOriginSent(ctx context.Context, messageHash string) (model.OriginSent, error) { var originSentRecord model.OriginSent - err := s.DB().WithContext(ctx). - Where("chain_id = ? AND tx_hash = ?", chainID, txHash). + err := s.DB().WithContext(ctx).Model(&model.OriginSent{}). + Where("message_hash = ?", messageHash). First(&originSentRecord).Error if err != nil { - return model.OriginSent{}, fmt.Errorf("could not retrieve OriginSent record: %w", err) + return model.OriginSent{}, fmt.Errorf("could not retrieve Origin Sent event: %w", err) } return originSentRecord, nil } -// RetrieveExecuted gets the Executed record. -func (s Store) RetrieveExecuted(ctx context.Context, chainID uint32, txHash string) (model.Executed, error) { - var executedRecord model.Executed - err := s.DB().WithContext(ctx). +// RetrieveOriginSents gets the Origin Sent events. +func (s Store) RetrieveOriginSents(ctx context.Context, chainID uint32, txHash string) ([]model.OriginSent, error) { + var originSentRecord []model.OriginSent + err := s.DB().WithContext(ctx).Model(&model.OriginSent{}). Where("chain_id = ? AND tx_hash = ?", chainID, txHash). + Scan(&originSentRecord).Error + + if err != nil { + return []model.OriginSent{}, fmt.Errorf("could not retrieve Origin Sent event: %w", err) + } + return originSentRecord, nil +} + +// RetrieveExecuted gets a Executed event. +func (s Store) RetrieveExecuted(ctx context.Context, messageHash string) (model.Executed, error) { + var executedRecord model.Executed + err := s.DB().WithContext(ctx).Model(&model.Executed{}). + Where("message_hash = ?", messageHash). First(&executedRecord).Error if err != nil { - return model.Executed{}, fmt.Errorf("could not retrieve Executed record: %w", err) + return model.Executed{}, fmt.Errorf("could not retrieve Executed event: %w", err) + } + return executedRecord, nil +} + +// RetrieveExecuteds gets Executed events. +func (s Store) RetrieveExecuteds(ctx context.Context, chainID uint32, txHash string) ([]model.Executed, error) { + var executedRecord []model.Executed + err := s.DB().WithContext(ctx).Model(&model.Executed{}). + Where("chain_id = ? AND tx_hash = ?", chainID, txHash). + Scan(&executedRecord).Error + + if err != nil { + return []model.Executed{}, fmt.Errorf("could not retrieve Executed event: %w", err) } return executedRecord, nil } diff --git a/services/sinner/graphql/client/client.go b/services/sinner/graphql/client/client.go index 3259864197..608065e253 100644 --- a/services/sinner/graphql/client/client.go +++ b/services/sinner/graphql/client/client.go @@ -19,9 +19,11 @@ func NewClient(cli *http.Client, baseURL string, options ...client.HTTPRequestOp } type Query struct { - GetMessageStatus *model.MessageStatus "json:\"getMessageStatus\" graphql:\"getMessageStatus\"" - GetOriginInfo []*model.OriginInfo "json:\"getOriginInfo\" graphql:\"getOriginInfo\"" - GetDestinationInfo []*model.DestinationInfo "json:\"getDestinationInfo\" graphql:\"getDestinationInfo\"" + GetMessageStatus *model.MessageStatus "json:\"getMessageStatus\" graphql:\"getMessageStatus\"" + GetOriginInfo *model.OriginInfo "json:\"getOriginInfo\" graphql:\"getOriginInfo\"" + GetDestinationInfo *model.DestinationInfo "json:\"getDestinationInfo\" graphql:\"getDestinationInfo\"" + GetOriginInfos []*model.OriginInfo "json:\"getOriginInfos\" graphql:\"getOriginInfos\"" + GetDestinationInfos []*model.DestinationInfo "json:\"getDestinationInfos\" graphql:\"getDestinationInfos\"" } type GetMessageStatus struct { Response *struct { @@ -32,6 +34,29 @@ type GetMessageStatus struct { } "json:\"response\" graphql:\"response\"" } type GetOriginInfo struct { + Response *struct { + MessageHash *string "json:\"messageHash\" graphql:\"messageHash\"" + ContractAddress *string "json:\"contractAddress\" graphql:\"contractAddress\"" + BlockNumber *int "json:\"blockNumber\" graphql:\"blockNumber\"" + OriginTxHash *string "json:\"originTxHash\" graphql:\"originTxHash\"" + Sender *string "json:\"sender\" graphql:\"sender\"" + Recipient *string "json:\"recipient\" graphql:\"recipient\"" + OriginChainID *int "json:\"originChainID\" graphql:\"originChainID\"" + DestinationChainID *int "json:\"destinationChainID\" graphql:\"destinationChainID\"" + Nonce *int "json:\"nonce\" graphql:\"nonce\"" + Message *string "json:\"message\" graphql:\"message\"" + OptimisticSeconds *int "json:\"optimisticSeconds\" graphql:\"optimisticSeconds\"" + MessageFlag *int "json:\"messageFlag\" graphql:\"messageFlag\"" + SummitTip *string "json:\"summitTip\" graphql:\"summitTip\"" + AttestationTip *string "json:\"attestationTip\" graphql:\"attestationTip\"" + ExecutionTip *string "json:\"executionTip\" graphql:\"executionTip\"" + DeliveryTip *string "json:\"deliveryTip\" graphql:\"deliveryTip\"" + Version *int "json:\"version\" graphql:\"version\"" + GasLimit *int "json:\"gasLimit\" graphql:\"gasLimit\"" + GasDrop *string "json:\"gasDrop\" graphql:\"gasDrop\"" + } "json:\"response\" graphql:\"response\"" +} +type GetOriginInfos struct { Response []*struct { MessageHash *string "json:\"messageHash\" graphql:\"messageHash\"" ContractAddress *string "json:\"contractAddress\" graphql:\"contractAddress\"" @@ -39,12 +64,12 @@ type GetOriginInfo struct { OriginTxHash *string "json:\"originTxHash\" graphql:\"originTxHash\"" Sender *string "json:\"sender\" graphql:\"sender\"" Recipient *string "json:\"recipient\" graphql:\"recipient\"" - OriginChainID *string "json:\"originChainID\" graphql:\"originChainID\"" - DestinationChainID *string "json:\"destinationChainID\" graphql:\"destinationChainID\"" + OriginChainID *int "json:\"originChainID\" graphql:\"originChainID\"" + DestinationChainID *int "json:\"destinationChainID\" graphql:\"destinationChainID\"" Nonce *int "json:\"nonce\" graphql:\"nonce\"" Message *string "json:\"message\" graphql:\"message\"" - OptimisticSeconds *string "json:\"optimisticSeconds\" graphql:\"optimisticSeconds\"" - MessageFlag *string "json:\"messageFlag\" graphql:\"messageFlag\"" + OptimisticSeconds *int "json:\"optimisticSeconds\" graphql:\"optimisticSeconds\"" + MessageFlag *int "json:\"messageFlag\" graphql:\"messageFlag\"" SummitTip *string "json:\"summitTip\" graphql:\"summitTip\"" AttestationTip *string "json:\"attestationTip\" graphql:\"attestationTip\"" ExecutionTip *string "json:\"executionTip\" graphql:\"executionTip\"" @@ -55,6 +80,18 @@ type GetOriginInfo struct { } "json:\"response\" graphql:\"response\"" } type GetDestinationInfo struct { + Response *struct { + ContractAddress *string "json:\"contractAddress\" graphql:\"contractAddress\"" + BlockNumber *int "json:\"blockNumber\" graphql:\"blockNumber\"" + TxHash *string "json:\"txHash\" graphql:\"txHash\"" + TxIndex *int "json:\"txIndex\" graphql:\"txIndex\"" + MessageHash *string "json:\"messageHash\" graphql:\"messageHash\"" + ChainID *int "json:\"chainID\" graphql:\"chainID\"" + RemoteDomain *int "json:\"remoteDomain\" graphql:\"remoteDomain\"" + Success *bool "json:\"success\" graphql:\"success\"" + } "json:\"response\" graphql:\"response\"" +} +type GetDestinationInfos struct { Response []*struct { ContractAddress *string "json:\"contractAddress\" graphql:\"contractAddress\"" BlockNumber *int "json:\"blockNumber\" graphql:\"blockNumber\"" @@ -90,8 +127,8 @@ func (c *Client) GetMessageStatus(ctx context.Context, messageHash string, httpR return &res, nil } -const GetOriginInfoDocument = `query GetOriginInfo ($txHash: String!, $chainID: Int!) { - response: getOriginInfo(txHash: $txHash, chainID: $chainID) { +const GetOriginInfoDocument = `query GetOriginInfo ($messageHash: String!) { + response: getOriginInfo(messageHash: $messageHash) { messageHash contractAddress blockNumber @@ -115,10 +152,9 @@ const GetOriginInfoDocument = `query GetOriginInfo ($txHash: String!, $chainID: } ` -func (c *Client) GetOriginInfo(ctx context.Context, txHash string, chainID int, httpRequestOptions ...client.HTTPRequestOption) (*GetOriginInfo, error) { +func (c *Client) GetOriginInfo(ctx context.Context, messageHash string, httpRequestOptions ...client.HTTPRequestOption) (*GetOriginInfo, error) { vars := map[string]interface{}{ - "txHash": txHash, - "chainID": chainID, + "messageHash": messageHash, } var res GetOriginInfo @@ -129,8 +165,47 @@ func (c *Client) GetOriginInfo(ctx context.Context, txHash string, chainID int, return &res, nil } -const GetDestinationInfoDocument = `query GetDestinationInfo ($txHash: String!, $chainID: Int!) { - response: getDestinationInfo(txHash: $txHash, chainID: $chainID) { +const GetOriginInfosDocument = `query GetOriginInfos ($txHash: String!, $chainID: Int!) { + response: getOriginInfos(txHash: $txHash, chainID: $chainID) { + messageHash + contractAddress + blockNumber + originTxHash + sender + recipient + originChainID + destinationChainID + nonce + message + optimisticSeconds + messageFlag + summitTip + attestationTip + executionTip + deliveryTip + version + gasLimit + gasDrop + } +} +` + +func (c *Client) GetOriginInfos(ctx context.Context, txHash string, chainID int, httpRequestOptions ...client.HTTPRequestOption) (*GetOriginInfos, error) { + vars := map[string]interface{}{ + "txHash": txHash, + "chainID": chainID, + } + + var res GetOriginInfos + if err := c.Client.Post(ctx, "GetOriginInfos", GetOriginInfosDocument, &res, vars, httpRequestOptions...); err != nil { + return nil, err + } + + return &res, nil +} + +const GetDestinationInfoDocument = `query GetDestinationInfo ($messageHash: String!) { + response: getDestinationInfo(messageHash: $messageHash) { contractAddress blockNumber txHash @@ -143,10 +218,9 @@ const GetDestinationInfoDocument = `query GetDestinationInfo ($txHash: String!, } ` -func (c *Client) GetDestinationInfo(ctx context.Context, txHash string, chainID int, httpRequestOptions ...client.HTTPRequestOption) (*GetDestinationInfo, error) { +func (c *Client) GetDestinationInfo(ctx context.Context, messageHash string, httpRequestOptions ...client.HTTPRequestOption) (*GetDestinationInfo, error) { vars := map[string]interface{}{ - "txHash": txHash, - "chainID": chainID, + "messageHash": messageHash, } var res GetDestinationInfo @@ -156,3 +230,31 @@ func (c *Client) GetDestinationInfo(ctx context.Context, txHash string, chainID return &res, nil } + +const GetDestinationInfosDocument = `query GetDestinationInfos ($txHash: String!, $chainID: Int!) { + response: getDestinationInfos(txHash: $txHash, chainID: $chainID) { + contractAddress + blockNumber + txHash + txIndex + messageHash + chainID + remoteDomain + success + } +} +` + +func (c *Client) GetDestinationInfos(ctx context.Context, txHash string, chainID int, httpRequestOptions ...client.HTTPRequestOption) (*GetDestinationInfos, error) { + vars := map[string]interface{}{ + "txHash": txHash, + "chainID": chainID, + } + + var res GetDestinationInfos + if err := c.Client.Post(ctx, "GetDestinationInfos", GetDestinationInfosDocument, &res, vars, httpRequestOptions...); err != nil { + return nil, err + } + + return &res, nil +} diff --git a/services/sinner/graphql/client/queries/queries.graphql b/services/sinner/graphql/client/queries/queries.graphql index c07cbf5f5c..fc5801f1fc 100644 --- a/services/sinner/graphql/client/queries/queries.graphql +++ b/services/sinner/graphql/client/queries/queries.graphql @@ -11,8 +11,33 @@ query GetMessageStatus($messageHash: String!) { } -query GetOriginInfo($txHash: String!, $chainID: Int!) { +query GetOriginInfo($messageHash: String!) { response: getOriginInfo( + messageHash: $messageHash + ) { + messageHash + contractAddress + blockNumber + originTxHash + sender + recipient + originChainID + destinationChainID + nonce + message + optimisticSeconds + messageFlag + summitTip + attestationTip + executionTip + deliveryTip + version + gasLimit + gasDrop + } +} +query GetOriginInfos($txHash: String!, $chainID: Int!) { + response: getOriginInfos( txHash: $txHash, chainID: $chainID ) { @@ -38,8 +63,22 @@ query GetOriginInfo($txHash: String!, $chainID: Int!) { } } -query GetDestinationInfo($txHash: String!, $chainID: Int!) { +query GetDestinationInfo($messageHash: String!) { response: getDestinationInfo( + messageHash: $messageHash) { + contractAddress + blockNumber + txHash + txIndex + messageHash + chainID + remoteDomain + success + } +} + +query GetDestinationInfos($txHash: String!, $chainID: Int!) { + response: getDestinationInfos( txHash: $txHash, chainID: $chainID ) { contractAddress diff --git a/services/sinner/graphql/server/graph/helper.go b/services/sinner/graphql/server/graph/helper.go index 4625117545..7c48ab150f 100644 --- a/services/sinner/graphql/server/graph/helper.go +++ b/services/sinner/graphql/server/graph/helper.go @@ -1,5 +1,10 @@ package graph +import ( + "github.com/synapsecns/sanguine/services/sinner/db/model" + graphqlmodel "github.com/synapsecns/sanguine/services/sinner/graphql/server/graph/model" +) + // Helper function to convert int to *int. func intPtr(val int) *int { return &val @@ -9,3 +14,40 @@ func intPtr(val int) *int { func strPtr(val string) *string { return &val } + +func dbToGraphqlModelOrigin(event model.OriginSent) *graphqlmodel.OriginInfo { + return &graphqlmodel.OriginInfo{ + MessageHash: &event.MessageHash, + ContractAddress: &event.ContractAddress, + BlockNumber: intPtr(int(event.BlockNumber)), + OriginTxHash: &event.TxHash, + Sender: &event.Sender, + Recipient: &event.Recipient, + OriginChainID: intPtr(int(event.ChainID)), + DestinationChainID: intPtr(int(event.DestinationChainID)), + Nonce: intPtr(int(event.Nonce)), + Message: strPtr(event.Message), + OptimisticSeconds: intPtr(int(event.OptimisticSeconds)), + MessageFlag: intPtr(int(event.MessageFlag)), + SummitTip: &event.SummitTip, + AttestationTip: &event.AttestationTip, + ExecutionTip: &event.ExecutionTip, + DeliveryTip: &event.DeliveryTip, + Version: intPtr(int(event.Version)), + GasLimit: intPtr(int(event.GasLimit)), + GasDrop: &event.GasDrop, + } +} + +func dbToGraphqlModelDestination(event model.Executed) *graphqlmodel.DestinationInfo { + return &graphqlmodel.DestinationInfo{ + ContractAddress: &event.ContractAddress, + BlockNumber: intPtr(int(event.BlockNumber)), + TxHash: &event.TxHash, + TxIndex: intPtr(int(event.TxIndex)), + MessageHash: &event.MessageHash, + ChainID: intPtr(int(event.ChainID)), + RemoteDomain: intPtr(int(event.RemoteDomain)), + Success: &event.Success, + } +} diff --git a/services/sinner/graphql/server/graph/model/models_gen.go b/services/sinner/graphql/server/graph/model/models_gen.go index 9e76b9e50a..b3e6d38f13 100644 --- a/services/sinner/graphql/server/graph/model/models_gen.go +++ b/services/sinner/graphql/server/graph/model/models_gen.go @@ -10,15 +10,16 @@ import ( // DestinationInfo provides granular information on an execution event. type DestinationInfo struct { - ContractAddress *string `json:"contractAddress,omitempty"` - BlockNumber *int `json:"blockNumber,omitempty"` - TxHash *string `json:"txHash,omitempty"` - TxIndex *int `json:"txIndex,omitempty"` - MessageHash *string `json:"messageHash,omitempty"` - ChainID *int `json:"chainID,omitempty"` - RemoteDomain *int `json:"remoteDomain,omitempty"` - Success *bool `json:"success,omitempty"` - OriginInfo *OriginInfo `json:"originInfo,omitempty"` + ContractAddress *string `json:"contractAddress,omitempty"` + BlockNumber *int `json:"blockNumber,omitempty"` + TxHash *string `json:"txHash,omitempty"` + TxIndex *int `json:"txIndex,omitempty"` + MessageHash *string `json:"messageHash,omitempty"` + ChainID *int `json:"chainID,omitempty"` + RemoteDomain *int `json:"remoteDomain,omitempty"` + Success *bool `json:"success,omitempty"` + MessageStatus *MessageStatus `json:"messageStatus,omitempty"` + OriginInfo *OriginInfo `json:"originInfo,omitempty"` } // MessageStatus gives the status of a message. @@ -37,12 +38,12 @@ type OriginInfo struct { OriginTxHash *string `json:"originTxHash,omitempty"` Sender *string `json:"sender,omitempty"` Recipient *string `json:"recipient,omitempty"` - OriginChainID *string `json:"originChainID,omitempty"` - DestinationChainID *string `json:"destinationChainID,omitempty"` + OriginChainID *int `json:"originChainID,omitempty"` + DestinationChainID *int `json:"destinationChainID,omitempty"` Nonce *int `json:"nonce,omitempty"` Message *string `json:"message,omitempty"` - OptimisticSeconds *string `json:"optimisticSeconds,omitempty"` - MessageFlag *string `json:"messageFlag,omitempty"` + OptimisticSeconds *int `json:"optimisticSeconds,omitempty"` + MessageFlag *int `json:"messageFlag,omitempty"` SummitTip *string `json:"summitTip,omitempty"` AttestationTip *string `json:"attestationTip,omitempty"` ExecutionTip *string `json:"executionTip,omitempty"` @@ -50,6 +51,7 @@ type OriginInfo struct { Version *int `json:"version,omitempty"` GasLimit *int `json:"gasLimit,omitempty"` GasDrop *string `json:"gasDrop,omitempty"` + MessageStatus *MessageStatus `json:"messageStatus,omitempty"` DestinationInfo *DestinationInfo `json:"destinationInfo,omitempty"` } diff --git a/services/sinner/graphql/server/graph/queries.resolvers.go b/services/sinner/graphql/server/graph/queries.resolvers.go index aa21a3a196..1cff2bd28e 100644 --- a/services/sinner/graphql/server/graph/queries.resolvers.go +++ b/services/sinner/graphql/server/graph/queries.resolvers.go @@ -23,54 +23,51 @@ func (r *queryResolver) GetMessageStatus(ctx context.Context, messageHash string } // GetOriginInfo is the resolver for the getOriginInfo field. -func (r *queryResolver) GetOriginInfo(ctx context.Context, txHash string, chainID int) ([]*model.OriginInfo, error) { - //originSent, err := r.DB.RetrieveOriginSent(ctx, uint32(chainID), txHash) - //if err != nil { - // return nil, fmt.Errorf("error retrieving origin sent data: %w", err) - //} - // - //return &model.OriginInfo{ - // MessageHash: &originSent.MessageHash, - // ContractAddress: &originSent.ContractAddress, - // BlockNumber: intPtr(int(originSent.BlockNumber)), - // OriginTxHash: &originSent.TxHash, - // Sender: &originSent.Sender, - // Recipient: &originSent.Recipient, - // OriginChainID: strPtr(fmt.Sprintf("%d", originSent.ChainID)), - // DestinationChainID: strPtr(fmt.Sprintf("%d", originSent.DestinationChainID)), - // Nonce: intPtr(int(originSent.Nonce)), - // Message: strPtr(string(originSent.Message)), - // OptimisticSeconds: strPtr(fmt.Sprintf("%d", originSent.OptimisticSeconds)), - // MessageFlag: strPtr(fmt.Sprintf("%d", originSent.MessageFlag)), - // SummitTip: &originSent.SummitTip, - // AttestationTip: &originSent.AttestationTip, - // ExecutionTip: &originSent.ExecutionTip, - // DeliveryTip: &originSent.DeliveryTip, - // Version: intPtr(int(originSent.Version)), - // GasLimit: intPtr(int(originSent.GasLimit)), - // GasDrop: &originSent.GasDrop, - //}, nil - return []*model.OriginInfo{}, nil +func (r *queryResolver) GetOriginInfo(ctx context.Context, messageHash string) (*model.OriginInfo, error) { + originSent, err := r.DB.RetrieveOriginSent(ctx, messageHash) + if err != nil { + return nil, fmt.Errorf("error retrieving origin sent data: %w", err) + } + + return dbToGraphqlModelOrigin(originSent), nil } // GetDestinationInfo is the resolver for the getDestinationInfo field. -func (r *queryResolver) GetDestinationInfo(ctx context.Context, txHash string, chainID int) ([]*model.DestinationInfo, error) { +func (r *queryResolver) GetDestinationInfo(ctx context.Context, messageHash string) (*model.DestinationInfo, error) { // Call the database function to retrieve the executed data - //executed, err := r.DB.RetrieveExecuted(ctx, uint32(chainID), txHash) - //if err != nil { - // return nil, fmt.Errorf("error retrieving destination info: %w", err) - //} - //return &model.DestinationInfo{ - // ContractAddress: &executed.ContractAddress, - // BlockNumber: intPtr(int(executed.BlockNumber)), - // TxHash: &executed.TxHash, - // TxIndex: intPtr(int(executed.TxIndex)), - // MessageHash: &executed.MessageHash, - // ChainID: intPtr(int(executed.ChainID)), - // RemoteDomain: intPtr(int(executed.RemoteDomain)), - // Success: &executed.Success, - //}, nil - return []*model.DestinationInfo{}, nil + executed, err := r.DB.RetrieveExecuted(ctx, messageHash) + if err != nil { + return nil, fmt.Errorf("error retrieving destination info: %w", err) + } + return dbToGraphqlModelDestination(executed), nil +} + +// GetOriginInfos is the resolver for the getOriginInfos field. +func (r *queryResolver) GetOriginInfos(ctx context.Context, txHash string, chainID int) ([]*model.OriginInfo, error) { + originSents, err := r.DB.RetrieveOriginSents(ctx, uint32(chainID), txHash) + if err != nil { + return nil, fmt.Errorf("error retrieving origin sent data: %w", err) + } + var output []*model.OriginInfo + for _, origin := range originSents { + output = append(output, dbToGraphqlModelOrigin(origin)) + } + return output, nil +} + +// GetDestinationInfos is the resolver for the getDestinationInfos field. +func (r *queryResolver) GetDestinationInfos(ctx context.Context, txHash string, chainID int) ([]*model.DestinationInfo, error) { + // Call the database function to retrieve the executed data + executeds, err := r.DB.RetrieveExecuteds(ctx, uint32(chainID), txHash) + if err != nil { + return nil, fmt.Errorf("error retrieving destination info: %w", err) + } + var output []*model.DestinationInfo + for _, executed := range executeds { + output = append(output, dbToGraphqlModelDestination(executed)) + } + + return output, nil } // Query returns resolvers.QueryResolver implementation. diff --git a/services/sinner/graphql/server/graph/resolver/server.go b/services/sinner/graphql/server/graph/resolver/server.go index 8975e9d844..4f6e00248e 100644 --- a/services/sinner/graphql/server/graph/resolver/server.go +++ b/services/sinner/graphql/server/graph/resolver/server.go @@ -50,6 +50,7 @@ type ComplexityRoot struct { ChainID func(childComplexity int) int ContractAddress func(childComplexity int) int MessageHash func(childComplexity int) int + MessageStatus func(childComplexity int) int OriginInfo func(childComplexity int) int RemoteDomain func(childComplexity int) int Success func(childComplexity int) int @@ -77,6 +78,7 @@ type ComplexityRoot struct { Message func(childComplexity int) int MessageFlag func(childComplexity int) int MessageHash func(childComplexity int) int + MessageStatus func(childComplexity int) int Nonce func(childComplexity int) int OptimisticSeconds func(childComplexity int) int OriginChainID func(childComplexity int) int @@ -88,22 +90,28 @@ type ComplexityRoot struct { } Query struct { - GetDestinationInfo func(childComplexity int, txHash string, chainID int) int - GetMessageStatus func(childComplexity int, messageHash string) int - GetOriginInfo func(childComplexity int, txHash string, chainID int) int + GetDestinationInfo func(childComplexity int, messageHash string) int + GetDestinationInfos func(childComplexity int, txHash string, chainID int) int + GetMessageStatus func(childComplexity int, messageHash string) int + GetOriginInfo func(childComplexity int, messageHash string) int + GetOriginInfos func(childComplexity int, txHash string, chainID int) int } } type DestinationInfoResolver interface { + MessageStatus(ctx context.Context, obj *model.DestinationInfo) (*model.MessageStatus, error) OriginInfo(ctx context.Context, obj *model.DestinationInfo) (*model.OriginInfo, error) } type OriginInfoResolver interface { + MessageStatus(ctx context.Context, obj *model.OriginInfo) (*model.MessageStatus, error) DestinationInfo(ctx context.Context, obj *model.OriginInfo) (*model.DestinationInfo, error) } type QueryResolver interface { GetMessageStatus(ctx context.Context, messageHash string) (*model.MessageStatus, error) - GetOriginInfo(ctx context.Context, txHash string, chainID int) ([]*model.OriginInfo, error) - GetDestinationInfo(ctx context.Context, txHash string, chainID int) ([]*model.DestinationInfo, error) + GetOriginInfo(ctx context.Context, messageHash string) (*model.OriginInfo, error) + GetDestinationInfo(ctx context.Context, messageHash string) (*model.DestinationInfo, error) + GetOriginInfos(ctx context.Context, txHash string, chainID int) ([]*model.OriginInfo, error) + GetDestinationInfos(ctx context.Context, txHash string, chainID int) ([]*model.DestinationInfo, error) } type executableSchema struct { @@ -149,6 +157,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.DestinationInfo.MessageHash(childComplexity), true + case "DestinationInfo.messageStatus": + if e.complexity.DestinationInfo.MessageStatus == nil { + break + } + + return e.complexity.DestinationInfo.MessageStatus(childComplexity), true + case "DestinationInfo.originInfo": if e.complexity.DestinationInfo.OriginInfo == nil { break @@ -296,6 +311,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.OriginInfo.MessageHash(childComplexity), true + case "OriginInfo.messageStatus": + if e.complexity.OriginInfo.MessageStatus == nil { + break + } + + return e.complexity.OriginInfo.MessageStatus(childComplexity), true + case "OriginInfo.nonce": if e.complexity.OriginInfo.Nonce == nil { break @@ -362,7 +384,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.GetDestinationInfo(childComplexity, args["txHash"].(string), args["chainID"].(int)), true + return e.complexity.Query.GetDestinationInfo(childComplexity, args["messageHash"].(string)), true + + case "Query.getDestinationInfos": + if e.complexity.Query.GetDestinationInfos == nil { + break + } + + args, err := ec.field_Query_getDestinationInfos_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetDestinationInfos(childComplexity, args["txHash"].(string), args["chainID"].(int)), true case "Query.getMessageStatus": if e.complexity.Query.GetMessageStatus == nil { @@ -386,7 +420,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.GetOriginInfo(childComplexity, args["txHash"].(string), args["chainID"].(int)), true + return e.complexity.Query.GetOriginInfo(childComplexity, args["messageHash"].(string)), true + + case "Query.getOriginInfos": + if e.complexity.Query.GetOriginInfos == nil { + break + } + + args, err := ec.field_Query_getOriginInfos_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.GetOriginInfos(childComplexity, args["txHash"].(string), args["chainID"].(int)), true } return 0, false @@ -493,15 +539,22 @@ directive @goField(forceResolver: Boolean, name: String) on INPUT_FIELD_DEFINITI ): MessageStatus getOriginInfo( + messageHash: String! + ): OriginInfo + + getDestinationInfo( + messageHash: String! + ): DestinationInfo + + getOriginInfos( txHash: String! chainID: Int! ): [OriginInfo] - getDestinationInfo( + getDestinationInfos( txHash: String! chainID: Int! ): [DestinationInfo] - } @@ -516,6 +569,7 @@ type MessageStatus { messageHash: String } + """ OriginInfo provides granular information on an origin sent event. """ @@ -526,12 +580,12 @@ type OriginInfo { originTxHash: String sender: String recipient: String - originChainID: String - destinationChainID: String + originChainID: Int + destinationChainID: Int nonce: Int message: String - optimisticSeconds: String - messageFlag: String + optimisticSeconds: Int + messageFlag: Int summitTip: String attestationTip: String executionTip: String @@ -539,6 +593,7 @@ type OriginInfo { version: Int gasLimit:Int gasDrop: String + messageStatus: MessageStatus @goField(forceResolver: true) destinationInfo: DestinationInfo @goField(forceResolver: true) } @@ -554,6 +609,7 @@ type DestinationInfo { chainID: Int remoteDomain: Int success: Boolean + messageStatus: MessageStatus @goField(forceResolver: true) originInfo: OriginInfo @goField(forceResolver: true) } @@ -586,6 +642,21 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs } func (ec *executionContext) field_Query_getDestinationInfo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["messageHash"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("messageHash")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["messageHash"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getDestinationInfos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string @@ -625,6 +696,21 @@ func (ec *executionContext) field_Query_getMessageStatus_args(ctx context.Contex } func (ec *executionContext) field_Query_getOriginInfo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["messageHash"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("messageHash")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["messageHash"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_getOriginInfos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string @@ -1014,6 +1100,57 @@ func (ec *executionContext) fieldContext_DestinationInfo_success(ctx context.Con return fc, nil } +func (ec *executionContext) _DestinationInfo_messageStatus(ctx context.Context, field graphql.CollectedField, obj *model.DestinationInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_DestinationInfo_messageStatus(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.DestinationInfo().MessageStatus(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.MessageStatus) + fc.Result = res + return ec.marshalOMessageStatus2ᚖgithub.comᚋsynapsecnsᚋsanguineᚋservicesᚋsinnerᚋgraphqlᚋserverᚋgraphᚋmodelᚐMessageStatus(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_DestinationInfo_messageStatus(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "DestinationInfo", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "lastSeen": + return ec.fieldContext_MessageStatus_lastSeen(ctx, field) + case "originTxHash": + return ec.fieldContext_MessageStatus_originTxHash(ctx, field) + case "destinationTxHash": + return ec.fieldContext_MessageStatus_destinationTxHash(ctx, field) + case "messageHash": + return ec.fieldContext_MessageStatus_messageHash(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MessageStatus", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _DestinationInfo_originInfo(ctx context.Context, field graphql.CollectedField, obj *model.DestinationInfo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_DestinationInfo_originInfo(ctx, field) if err != nil { @@ -1088,6 +1225,8 @@ func (ec *executionContext) fieldContext_DestinationInfo_originInfo(ctx context. return ec.fieldContext_OriginInfo_gasLimit(ctx, field) case "gasDrop": return ec.fieldContext_OriginInfo_gasDrop(ctx, field) + case "messageStatus": + return ec.fieldContext_OriginInfo_messageStatus(ctx, field) case "destinationInfo": return ec.fieldContext_OriginInfo_destinationInfo(ctx, field) } @@ -1530,9 +1669,9 @@ func (ec *executionContext) _OriginInfo_originChainID(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*int) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOInt2ᚖint(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_OriginInfo_originChainID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -1542,7 +1681,7 @@ func (ec *executionContext) fieldContext_OriginInfo_originChainID(ctx context.Co IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil @@ -1571,9 +1710,9 @@ func (ec *executionContext) _OriginInfo_destinationChainID(ctx context.Context, if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*int) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOInt2ᚖint(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_OriginInfo_destinationChainID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -1583,7 +1722,7 @@ func (ec *executionContext) fieldContext_OriginInfo_destinationChainID(ctx conte IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil @@ -1694,9 +1833,9 @@ func (ec *executionContext) _OriginInfo_optimisticSeconds(ctx context.Context, f if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*int) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOInt2ᚖint(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_OriginInfo_optimisticSeconds(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -1706,7 +1845,7 @@ func (ec *executionContext) fieldContext_OriginInfo_optimisticSeconds(ctx contex IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil @@ -1735,9 +1874,9 @@ func (ec *executionContext) _OriginInfo_messageFlag(ctx context.Context, field g if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*int) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOInt2ᚖint(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_OriginInfo_messageFlag(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -1747,7 +1886,7 @@ func (ec *executionContext) fieldContext_OriginInfo_messageFlag(ctx context.Cont IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil @@ -2040,6 +2179,57 @@ func (ec *executionContext) fieldContext_OriginInfo_gasDrop(ctx context.Context, return fc, nil } +func (ec *executionContext) _OriginInfo_messageStatus(ctx context.Context, field graphql.CollectedField, obj *model.OriginInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OriginInfo_messageStatus(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.OriginInfo().MessageStatus(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.MessageStatus) + fc.Result = res + return ec.marshalOMessageStatus2ᚖgithub.comᚋsynapsecnsᚋsanguineᚋservicesᚋsinnerᚋgraphqlᚋserverᚋgraphᚋmodelᚐMessageStatus(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_OriginInfo_messageStatus(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OriginInfo", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "lastSeen": + return ec.fieldContext_MessageStatus_lastSeen(ctx, field) + case "originTxHash": + return ec.fieldContext_MessageStatus_originTxHash(ctx, field) + case "destinationTxHash": + return ec.fieldContext_MessageStatus_destinationTxHash(ctx, field) + case "messageHash": + return ec.fieldContext_MessageStatus_messageHash(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type MessageStatus", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _OriginInfo_destinationInfo(ctx context.Context, field graphql.CollectedField, obj *model.OriginInfo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_OriginInfo_destinationInfo(ctx, field) if err != nil { @@ -2092,6 +2282,8 @@ func (ec *executionContext) fieldContext_OriginInfo_destinationInfo(ctx context. return ec.fieldContext_DestinationInfo_remoteDomain(ctx, field) case "success": return ec.fieldContext_DestinationInfo_success(ctx, field) + case "messageStatus": + return ec.fieldContext_DestinationInfo_messageStatus(ctx, field) case "originInfo": return ec.fieldContext_DestinationInfo_originInfo(ctx, field) } @@ -2177,7 +2369,7 @@ func (ec *executionContext) _Query_getOriginInfo(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetOriginInfo(rctx, fc.Args["txHash"].(string), fc.Args["chainID"].(int)) + return ec.resolvers.Query().GetOriginInfo(rctx, fc.Args["messageHash"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -2186,9 +2378,9 @@ func (ec *executionContext) _Query_getOriginInfo(ctx context.Context, field grap if resTmp == nil { return graphql.Null } - res := resTmp.([]*model.OriginInfo) + res := resTmp.(*model.OriginInfo) fc.Result = res - return ec.marshalOOriginInfo2ᚕᚖgithub.comᚋsynapsecnsᚋsanguineᚋservicesᚋsinnerᚋgraphqlᚋserverᚋgraphᚋmodelᚐOriginInfo(ctx, field.Selections, res) + return ec.marshalOOriginInfo2ᚖgithub.comᚋsynapsecnsᚋsanguineᚋservicesᚋsinnerᚋgraphqlᚋserverᚋgraphᚋmodelᚐOriginInfo(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_getOriginInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2237,6 +2429,8 @@ func (ec *executionContext) fieldContext_Query_getOriginInfo(ctx context.Context return ec.fieldContext_OriginInfo_gasLimit(ctx, field) case "gasDrop": return ec.fieldContext_OriginInfo_gasDrop(ctx, field) + case "messageStatus": + return ec.fieldContext_OriginInfo_messageStatus(ctx, field) case "destinationInfo": return ec.fieldContext_OriginInfo_destinationInfo(ctx, field) } @@ -2271,7 +2465,7 @@ func (ec *executionContext) _Query_getDestinationInfo(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().GetDestinationInfo(rctx, fc.Args["txHash"].(string), fc.Args["chainID"].(int)) + return ec.resolvers.Query().GetDestinationInfo(rctx, fc.Args["messageHash"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -2280,9 +2474,9 @@ func (ec *executionContext) _Query_getDestinationInfo(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.([]*model.DestinationInfo) + res := resTmp.(*model.DestinationInfo) fc.Result = res - return ec.marshalODestinationInfo2ᚕᚖgithub.comᚋsynapsecnsᚋsanguineᚋservicesᚋsinnerᚋgraphqlᚋserverᚋgraphᚋmodelᚐDestinationInfo(ctx, field.Selections, res) + return ec.marshalODestinationInfo2ᚖgithub.comᚋsynapsecnsᚋsanguineᚋservicesᚋsinnerᚋgraphqlᚋserverᚋgraphᚋmodelᚐDestinationInfo(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_getDestinationInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -2309,6 +2503,8 @@ func (ec *executionContext) fieldContext_Query_getDestinationInfo(ctx context.Co return ec.fieldContext_DestinationInfo_remoteDomain(ctx, field) case "success": return ec.fieldContext_DestinationInfo_success(ctx, field) + case "messageStatus": + return ec.fieldContext_DestinationInfo_messageStatus(ctx, field) case "originInfo": return ec.fieldContext_DestinationInfo_originInfo(ctx, field) } @@ -2329,6 +2525,176 @@ func (ec *executionContext) fieldContext_Query_getDestinationInfo(ctx context.Co return fc, nil } +func (ec *executionContext) _Query_getOriginInfos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getOriginInfos(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetOriginInfos(rctx, fc.Args["txHash"].(string), fc.Args["chainID"].(int)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*model.OriginInfo) + fc.Result = res + return ec.marshalOOriginInfo2ᚕᚖgithub.comᚋsynapsecnsᚋsanguineᚋservicesᚋsinnerᚋgraphqlᚋserverᚋgraphᚋmodelᚐOriginInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getOriginInfos(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "messageHash": + return ec.fieldContext_OriginInfo_messageHash(ctx, field) + case "contractAddress": + return ec.fieldContext_OriginInfo_contractAddress(ctx, field) + case "blockNumber": + return ec.fieldContext_OriginInfo_blockNumber(ctx, field) + case "originTxHash": + return ec.fieldContext_OriginInfo_originTxHash(ctx, field) + case "sender": + return ec.fieldContext_OriginInfo_sender(ctx, field) + case "recipient": + return ec.fieldContext_OriginInfo_recipient(ctx, field) + case "originChainID": + return ec.fieldContext_OriginInfo_originChainID(ctx, field) + case "destinationChainID": + return ec.fieldContext_OriginInfo_destinationChainID(ctx, field) + case "nonce": + return ec.fieldContext_OriginInfo_nonce(ctx, field) + case "message": + return ec.fieldContext_OriginInfo_message(ctx, field) + case "optimisticSeconds": + return ec.fieldContext_OriginInfo_optimisticSeconds(ctx, field) + case "messageFlag": + return ec.fieldContext_OriginInfo_messageFlag(ctx, field) + case "summitTip": + return ec.fieldContext_OriginInfo_summitTip(ctx, field) + case "attestationTip": + return ec.fieldContext_OriginInfo_attestationTip(ctx, field) + case "executionTip": + return ec.fieldContext_OriginInfo_executionTip(ctx, field) + case "deliveryTip": + return ec.fieldContext_OriginInfo_deliveryTip(ctx, field) + case "version": + return ec.fieldContext_OriginInfo_version(ctx, field) + case "gasLimit": + return ec.fieldContext_OriginInfo_gasLimit(ctx, field) + case "gasDrop": + return ec.fieldContext_OriginInfo_gasDrop(ctx, field) + case "messageStatus": + return ec.fieldContext_OriginInfo_messageStatus(ctx, field) + case "destinationInfo": + return ec.fieldContext_OriginInfo_destinationInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type OriginInfo", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getOriginInfos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_getDestinationInfos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_getDestinationInfos(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().GetDestinationInfos(rctx, fc.Args["txHash"].(string), fc.Args["chainID"].(int)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*model.DestinationInfo) + fc.Result = res + return ec.marshalODestinationInfo2ᚕᚖgithub.comᚋsynapsecnsᚋsanguineᚋservicesᚋsinnerᚋgraphqlᚋserverᚋgraphᚋmodelᚐDestinationInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_getDestinationInfos(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "contractAddress": + return ec.fieldContext_DestinationInfo_contractAddress(ctx, field) + case "blockNumber": + return ec.fieldContext_DestinationInfo_blockNumber(ctx, field) + case "txHash": + return ec.fieldContext_DestinationInfo_txHash(ctx, field) + case "txIndex": + return ec.fieldContext_DestinationInfo_txIndex(ctx, field) + case "messageHash": + return ec.fieldContext_DestinationInfo_messageHash(ctx, field) + case "chainID": + return ec.fieldContext_DestinationInfo_chainID(ctx, field) + case "remoteDomain": + return ec.fieldContext_DestinationInfo_remoteDomain(ctx, field) + case "success": + return ec.fieldContext_DestinationInfo_success(ctx, field) + case "messageStatus": + return ec.fieldContext_DestinationInfo_messageStatus(ctx, field) + case "originInfo": + return ec.fieldContext_DestinationInfo_originInfo(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type DestinationInfo", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_getDestinationInfos_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { @@ -4266,6 +4632,39 @@ func (ec *executionContext) _DestinationInfo(ctx context.Context, sel ast.Select out.Values[i] = ec._DestinationInfo_remoteDomain(ctx, field, obj) case "success": out.Values[i] = ec._DestinationInfo_success(ctx, field, obj) + case "messageStatus": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._DestinationInfo_messageStatus(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "originInfo": field := field @@ -4413,6 +4812,39 @@ func (ec *executionContext) _OriginInfo(ctx context.Context, sel ast.SelectionSe out.Values[i] = ec._OriginInfo_gasLimit(ctx, field, obj) case "gasDrop": out.Values[i] = ec._OriginInfo_gasDrop(ctx, field, obj) + case "messageStatus": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._OriginInfo_messageStatus(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "destinationInfo": field := field @@ -4544,6 +4976,44 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "getOriginInfos": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_getOriginInfos(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "getDestinationInfos": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_getDestinationInfos(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { diff --git a/services/sinner/graphql/server/graph/schema/queries.graphql b/services/sinner/graphql/server/graph/schema/queries.graphql index 1b3eea0056..61b3ce4435 100644 --- a/services/sinner/graphql/server/graph/schema/queries.graphql +++ b/services/sinner/graphql/server/graph/schema/queries.graphql @@ -4,15 +4,22 @@ type Query { ): MessageStatus getOriginInfo( + messageHash: String! + ): OriginInfo + + getDestinationInfo( + messageHash: String! + ): DestinationInfo + + getOriginInfos( txHash: String! chainID: Int! ): [OriginInfo] - getDestinationInfo( + getDestinationInfos( txHash: String! chainID: Int! ): [DestinationInfo] - } diff --git a/services/sinner/graphql/server/graph/schema/types.graphql b/services/sinner/graphql/server/graph/schema/types.graphql index 596dd1decc..d472b0b38d 100644 --- a/services/sinner/graphql/server/graph/schema/types.graphql +++ b/services/sinner/graphql/server/graph/schema/types.graphql @@ -8,6 +8,7 @@ type MessageStatus { messageHash: String } + """ OriginInfo provides granular information on an origin sent event. """ @@ -18,12 +19,12 @@ type OriginInfo { originTxHash: String sender: String recipient: String - originChainID: String - destinationChainID: String + originChainID: Int + destinationChainID: Int nonce: Int message: String - optimisticSeconds: String - messageFlag: String + optimisticSeconds: Int + messageFlag: Int summitTip: String attestationTip: String executionTip: String @@ -31,6 +32,7 @@ type OriginInfo { version: Int gasLimit:Int gasDrop: String + messageStatus: MessageStatus @goField(forceResolver: true) destinationInfo: DestinationInfo @goField(forceResolver: true) } @@ -46,6 +48,7 @@ type DestinationInfo { chainID: Int remoteDomain: Int success: Boolean + messageStatus: MessageStatus @goField(forceResolver: true) originInfo: OriginInfo @goField(forceResolver: true) } diff --git a/services/sinner/graphql/server/graph/types.resolvers.go b/services/sinner/graphql/server/graph/types.resolvers.go index 5b3301a395..c110678b86 100644 --- a/services/sinner/graphql/server/graph/types.resolvers.go +++ b/services/sinner/graphql/server/graph/types.resolvers.go @@ -12,14 +12,42 @@ import ( resolvers "github.com/synapsecns/sanguine/services/sinner/graphql/server/graph/resolver" ) +// MessageStatus is the resolver for the messageStatus field. +func (r *destinationInfoResolver) MessageStatus(ctx context.Context, obj *model.DestinationInfo) (*model.MessageStatus, error) { + messageStatus, err := r.DB.RetrieveMessageStatus(ctx, *obj.MessageHash) + if err != nil { + return nil, fmt.Errorf("error retrieving message status: %w", err) + } + + return &messageStatus, nil +} + // OriginInfo is the resolver for the originInfo field. func (r *destinationInfoResolver) OriginInfo(ctx context.Context, obj *model.DestinationInfo) (*model.OriginInfo, error) { + originSent, err := r.DB.RetrieveOriginSent(ctx, *obj.MessageHash) + if err != nil { + return nil, fmt.Errorf("error retrieving origin sent data: %w", err) + } + return dbToGraphqlModelOrigin(originSent), nil +} + +// MessageStatus is the resolver for the messageStatus field. +func (r *originInfoResolver) MessageStatus(ctx context.Context, obj *model.OriginInfo) (*model.MessageStatus, error) { + messageStatus, err := r.DB.RetrieveMessageStatus(ctx, *obj.MessageHash) + if err != nil { + return nil, fmt.Errorf("error retrieving message status: %w", err) + } + return &messageStatus, nil } // DestinationInfo is the resolver for the destinationInfo field. func (r *originInfoResolver) DestinationInfo(ctx context.Context, obj *model.OriginInfo) (*model.DestinationInfo, error) { - panic(fmt.Errorf("not implemented: DestinationInfo - destinationInfo")) + executed, err := r.DB.RetrieveExecuted(ctx, *obj.MessageHash) + if err != nil { + return nil, fmt.Errorf("error retrieving destination info: %w", err) + } + return dbToGraphqlModelDestination(executed), nil } // DestinationInfo returns resolvers.DestinationInfoResolver implementation. diff --git a/services/sinner/service/indexer.go b/services/sinner/service/indexer.go index 227d9334aa..39fa10212a 100644 --- a/services/sinner/service/indexer.go +++ b/services/sinner/service/indexer.go @@ -124,7 +124,6 @@ func (c ChainIndexer) Index(ctx context.Context) error { // If the end block is not specified in the config (livefill) the last block stored will be used. if endHeight == 0 { - // Get last stored block from sinner. storedStartHeight, err := c.eventDB.RetrieveLastStoredBlock(contractCtx, c.config.ChainID, common.HexToAddress(contract.Address)) if err != nil {