From 1e3a014d7052f989b5e68fb8f832d91372b0bc4c Mon Sep 17 00:00:00 2001 From: kompotkot Date: Mon, 18 Dec 2023 19:08:21 +0000 Subject: [PATCH 1/2] No metatx param mostly for test purpose --- server.go | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/server.go b/server.go index f2353ad..35cabbd 100644 --- a/server.go +++ b/server.go @@ -55,6 +55,16 @@ type SignDropperRequest struct { Sensible bool `json:"sensible"` Requests []*DropperClaimMessage `json:"requests"` + NoMetatx bool `json:"no_metatx"` +} + +type SignDropperResponse struct { + ChainId int `json:"chain_id"` + Dropper string `json:"dropper"` + TtlDays int `json:"ttl_days"` + Sensible bool `json:"sensible"` + Requests []*DropperClaimMessage `json:"requests"` + MetatxRegistered bool `json:"metatx_registered"` } @@ -285,7 +295,7 @@ func (server *Server) signDropperRoute(w http.ResponseWriter, r *http.Request, s authorizationToken := authorizationContext.AuthorizationToken queries := r.URL.Query() - isMetatxDrop := queries.Has("is_metatx_drop") + noMetatx := queries.Has("no_metatx") body, readErr := io.ReadAll(r.Body) if readErr != nil { @@ -320,7 +330,7 @@ func (server *Server) signDropperRoute(w http.ResponseWriter, r *http.Request, s message.Signature = hex.EncodeToString(signedMessage) message.Signer = server.AvailableSigners[signer].key.Address.Hex() - if isMetatxDrop { + if !noMetatx { callRequests[i] = CallRequestSpecification{ Caller: message.Claimant, Method: "claim", @@ -336,16 +346,24 @@ func (server *Server) signDropperRoute(w http.ResponseWriter, r *http.Request, s } } - if isMetatxDrop { + resp := SignDropperResponse{ + ChainId: req.ChainId, + Dropper: req.Dropper, + TtlDays: req.TtlDays, + Sensible: req.Sensible, + Requests: req.Requests, + } + + if !noMetatx { createReqErr := server.MoonstreamEngineAPIClient.CreateCallRequests(authorizationToken, "", req.Dropper, req.TtlDays, callRequests, 100, 1) if createReqErr == nil { log.Printf("New %d call_requests registered at metatx for %s", len(callRequests), req.Dropper) - req.MetatxRegistered = true + resp.MetatxRegistered = true } } w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(req) + json.NewEncoder(w).Encode(resp) } // Serve handles server run From 4b4c3252e380a6b27b3d91b4ba6cfe21b421bcf5 Mon Sep 17 00:00:00 2001 From: kompotkot Date: Tue, 19 Dec 2023 14:36:02 +0000 Subject: [PATCH 2/2] no_metatx as body --- server.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/server.go b/server.go index 35cabbd..456d0f7 100644 --- a/server.go +++ b/server.go @@ -294,9 +294,6 @@ func (server *Server) signDropperRoute(w http.ResponseWriter, r *http.Request, s authorizationContext := r.Context().Value("authorizationContext").(AuthorizationContext) authorizationToken := authorizationContext.AuthorizationToken - queries := r.URL.Query() - noMetatx := queries.Has("no_metatx") - body, readErr := io.ReadAll(r.Body) if readErr != nil { http.Error(w, "Unable to read body", http.StatusBadRequest) @@ -330,7 +327,7 @@ func (server *Server) signDropperRoute(w http.ResponseWriter, r *http.Request, s message.Signature = hex.EncodeToString(signedMessage) message.Signer = server.AvailableSigners[signer].key.Address.Hex() - if !noMetatx { + if !req.NoMetatx { callRequests[i] = CallRequestSpecification{ Caller: message.Claimant, Method: "claim", @@ -354,7 +351,7 @@ func (server *Server) signDropperRoute(w http.ResponseWriter, r *http.Request, s Requests: req.Requests, } - if !noMetatx { + if !req.NoMetatx { createReqErr := server.MoonstreamEngineAPIClient.CreateCallRequests(authorizationToken, "", req.Dropper, req.TtlDays, callRequests, 100, 1) if createReqErr == nil { log.Printf("New %d call_requests registered at metatx for %s", len(callRequests), req.Dropper)