From 6b9ec9dd8c31ae69f7cd92ea3ab4ff6724fa396b Mon Sep 17 00:00:00 2001 From: defi-moses Date: Wed, 30 Oct 2024 23:16:25 +0000 Subject: [PATCH] Adding to all bridge watcher queries --- services/explorer/graphql/client/client.go | 20 +++--- .../graphql/client/queries/queries.graphql | 2 + .../graphql/server/graph/model/models_gen.go | 11 ++-- .../graphql/server/graph/queryutils.go | 24 ++++--- .../graphql/server/graph/resolver/server.go | 66 +++++++++++++++++-- .../graphql/server/graph/schema/types.graphql | 1 + 6 files changed, 96 insertions(+), 28 deletions(-) diff --git a/services/explorer/graphql/client/client.go b/services/explorer/graphql/client/client.go index da7aa9d9e3..2c8628e41c 100644 --- a/services/explorer/graphql/client/client.go +++ b/services/explorer/graphql/client/client.go @@ -246,10 +246,11 @@ type GetOriginBridgeTx struct { Time *int "json:\"time\" graphql:\"time\"" FormattedTime *string "json:\"formattedTime\" graphql:\"formattedTime\"" } "json:\"bridgeTx\" graphql:\"bridgeTx\"" - Pending *bool "json:\"pending\" graphql:\"pending\"" - Type *model.BridgeTxType "json:\"type\" graphql:\"type\"" - Kappa *string "json:\"kappa\" graphql:\"kappa\"" - KappaStatus *model.KappaStatus "json:\"kappaStatus\" graphql:\"kappaStatus\"" + Pending *bool "json:\"pending\" graphql:\"pending\"" + Type *model.BridgeTxType "json:\"type\" graphql:\"type\"" + Kappa *string "json:\"kappa\" graphql:\"kappa\"" + KappaStatus *model.KappaStatus "json:\"kappaStatus\" graphql:\"kappaStatus\"" + BridgeModule *string "json:\"bridgeModule\" graphql:\"bridgeModule\"" } "json:\"response\" graphql:\"response\"" } type GetDestinationBridgeTx struct { @@ -268,10 +269,11 @@ type GetDestinationBridgeTx struct { Time *int "json:\"time\" graphql:\"time\"" FormattedTime *string "json:\"formattedTime\" graphql:\"formattedTime\"" } "json:\"bridgeTx\" graphql:\"bridgeTx\"" - Pending *bool "json:\"pending\" graphql:\"pending\"" - Type *model.BridgeTxType "json:\"type\" graphql:\"type\"" - Kappa *string "json:\"kappa\" graphql:\"kappa\"" - KappaStatus *model.KappaStatus "json:\"kappaStatus\" graphql:\"kappaStatus\"" + Pending *bool "json:\"pending\" graphql:\"pending\"" + Type *model.BridgeTxType "json:\"type\" graphql:\"type\"" + Kappa *string "json:\"kappa\" graphql:\"kappa\"" + KappaStatus *model.KappaStatus "json:\"kappaStatus\" graphql:\"kappaStatus\"" + BridgeModule *string "json:\"bridgeModule\" graphql:\"bridgeModule\"" } "json:\"response\" graphql:\"response\"" } @@ -700,6 +702,7 @@ const GetOriginBridgeTxDocument = `query GetOriginBridgeTx ($chainID: Int!, $txn type kappa kappaStatus + bridgeModule } } ` @@ -739,6 +742,7 @@ const GetDestinationBridgeTxDocument = `query GetDestinationBridgeTx ($chainID: type kappa kappaStatus + bridgeModule } } ` diff --git a/services/explorer/graphql/client/queries/queries.graphql b/services/explorer/graphql/client/queries/queries.graphql index 219deb965c..5c5ed67e93 100644 --- a/services/explorer/graphql/client/queries/queries.graphql +++ b/services/explorer/graphql/client/queries/queries.graphql @@ -304,6 +304,7 @@ query GetOriginBridgeTx($chainID: Int!, $txnHash: String!, $bridgeType: BridgeTy type kappa kappaStatus + bridgeModule } } query GetDestinationBridgeTx($chainID: Int!, $kappa: String!, $address: String!, $timestamp: Int!, $bridgeType: BridgeType!, $historical: Boolean) { @@ -333,5 +334,6 @@ query GetDestinationBridgeTx($chainID: Int!, $kappa: String!, $address: String!, type kappa kappaStatus + bridgeModule } } diff --git a/services/explorer/graphql/server/graph/model/models_gen.go b/services/explorer/graphql/server/graph/model/models_gen.go index 207975e3d8..801708bf02 100644 --- a/services/explorer/graphql/server/graph/model/models_gen.go +++ b/services/explorer/graphql/server/graph/model/models_gen.go @@ -62,11 +62,12 @@ type BridgeTransaction struct { // BridgeWatcherTx represents a single sided bridge transaction specifically for the bridge watcher. type BridgeWatcherTx struct { - BridgeTx *PartialInfo `json:"bridgeTx,omitempty"` - Pending *bool `json:"pending,omitempty"` - Type *BridgeTxType `json:"type,omitempty"` - Kappa *string `json:"kappa,omitempty"` - KappaStatus *KappaStatus `json:"kappaStatus,omitempty"` + BridgeTx *PartialInfo `json:"bridgeTx,omitempty"` + Pending *bool `json:"pending,omitempty"` + Type *BridgeTxType `json:"type,omitempty"` + Kappa *string `json:"kappa,omitempty"` + KappaStatus *KappaStatus `json:"kappaStatus,omitempty"` + BridgeModule *string `json:"bridgeModule,omitempty"` } type ContractQuery struct { diff --git a/services/explorer/graphql/server/graph/queryutils.go b/services/explorer/graphql/server/graph/queryutils.go index ca54e666d2..00ab52dbe3 100644 --- a/services/explorer/graphql/server/graph/queryutils.go +++ b/services/explorer/graphql/server/graph/queryutils.go @@ -1777,12 +1777,14 @@ func bwBridgeMVToBWTxOrigin(bridgeEvent *sql.HybridBridgeEvent, txType model.Bri Time: ×tamp, FormattedTime: &timeStampFormatted, } + bridgeModule := getBridgeModule(int(bridgeEvent.FEventType)) result := &model.BridgeWatcherTx{ - BridgeTx: &bridgeTx, - Pending: &isPending, - Type: &txType, - Kappa: &kappa, - KappaStatus: &kappaStatus, + BridgeTx: &bridgeTx, + Pending: &isPending, + Type: &txType, + Kappa: &kappa, + KappaStatus: &kappaStatus, + BridgeModule: &bridgeModule, } return result, nil } @@ -1825,12 +1827,14 @@ func bwBridgeMVToBWTxDestination(bridgeEvent *sql.HybridBridgeEvent, txType mode Time: ×tamp, FormattedTime: &timeStampFormatted, } + bridgeModule := getBridgeModule(int(bridgeEvent.TEventType)) result := &model.BridgeWatcherTx{ - BridgeTx: &bridgeTx, - Pending: &isPending, - Type: &txType, - Kappa: &kappa, - KappaStatus: &kappaStatus, + BridgeTx: &bridgeTx, + Pending: &isPending, + Type: &txType, + Kappa: &kappa, + KappaStatus: &kappaStatus, + BridgeModule: &bridgeModule, } return result, nil } diff --git a/services/explorer/graphql/server/graph/resolver/server.go b/services/explorer/graphql/server/graph/resolver/server.go index 6d49ace349..9558cc8be2 100644 --- a/services/explorer/graphql/server/graph/resolver/server.go +++ b/services/explorer/graphql/server/graph/resolver/server.go @@ -88,11 +88,12 @@ type ComplexityRoot struct { } BridgeWatcherTx struct { - BridgeTx func(childComplexity int) int - Kappa func(childComplexity int) int - KappaStatus func(childComplexity int) int - Pending func(childComplexity int) int - Type func(childComplexity int) int + BridgeModule func(childComplexity int) int + BridgeTx func(childComplexity int) int + Kappa func(childComplexity int) int + KappaStatus func(childComplexity int) int + Pending func(childComplexity int) int + Type func(childComplexity int) int } DateResult struct { @@ -452,6 +453,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.BridgeTransaction.ToInfo(childComplexity), true + case "BridgeWatcherTx.bridgeModule": + if e.complexity.BridgeWatcherTx.BridgeModule == nil { + break + } + + return e.complexity.BridgeWatcherTx.BridgeModule(childComplexity), true + case "BridgeWatcherTx.bridgeTx": if e.complexity.BridgeWatcherTx.BridgeTx == nil { break @@ -1544,6 +1552,7 @@ type BridgeWatcherTx { type: BridgeTxType kappa: String kappaStatus: KappaStatus + bridgeModule: String } """ DateResult is a given statistic for a given date. @@ -3866,6 +3875,47 @@ func (ec *executionContext) fieldContext_BridgeWatcherTx_kappaStatus(ctx context return fc, nil } +func (ec *executionContext) _BridgeWatcherTx_bridgeModule(ctx context.Context, field graphql.CollectedField, obj *model.BridgeWatcherTx) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BridgeWatcherTx_bridgeModule(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 obj.BridgeModule, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2áš–string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_BridgeWatcherTx_bridgeModule(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BridgeWatcherTx", + Field: field, + 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 fc, nil +} + func (ec *executionContext) _DateResult_date(ctx context.Context, field graphql.CollectedField, obj *model.DateResult) (ret graphql.Marshaler) { fc, err := ec.fieldContext_DateResult_date(ctx, field) if err != nil { @@ -7558,6 +7608,8 @@ func (ec *executionContext) fieldContext_Query_getOriginBridgeTx(ctx context.Con return ec.fieldContext_BridgeWatcherTx_kappa(ctx, field) case "kappaStatus": return ec.fieldContext_BridgeWatcherTx_kappaStatus(ctx, field) + case "bridgeModule": + return ec.fieldContext_BridgeWatcherTx_bridgeModule(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type BridgeWatcherTx", field.Name) }, @@ -7622,6 +7674,8 @@ func (ec *executionContext) fieldContext_Query_getDestinationBridgeTx(ctx contex return ec.fieldContext_BridgeWatcherTx_kappa(ctx, field) case "kappaStatus": return ec.fieldContext_BridgeWatcherTx_kappaStatus(ctx, field) + case "bridgeModule": + return ec.fieldContext_BridgeWatcherTx_bridgeModule(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type BridgeWatcherTx", field.Name) }, @@ -10422,6 +10476,8 @@ func (ec *executionContext) _BridgeWatcherTx(ctx context.Context, sel ast.Select out.Values[i] = ec._BridgeWatcherTx_kappa(ctx, field, obj) case "kappaStatus": out.Values[i] = ec._BridgeWatcherTx_kappaStatus(ctx, field, obj) + case "bridgeModule": + out.Values[i] = ec._BridgeWatcherTx_bridgeModule(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } diff --git a/services/explorer/graphql/server/graph/schema/types.graphql b/services/explorer/graphql/server/graph/schema/types.graphql index fa475d8295..9759feb118 100644 --- a/services/explorer/graphql/server/graph/schema/types.graphql +++ b/services/explorer/graphql/server/graph/schema/types.graphql @@ -44,6 +44,7 @@ type BridgeWatcherTx { type: BridgeTxType kappa: String kappaStatus: KappaStatus + bridgeModule: String } """ DateResult is a given statistic for a given date.