From efbed28cb7c4a19ca9295de822088f692d1f22f6 Mon Sep 17 00:00:00 2001 From: roman_harazha Date: Fri, 8 Mar 2024 19:46:39 +0200 Subject: [PATCH] add no_send option --- config.yaml | 1 + internal/config/network.go | 2 ++ internal/service/api/handlers/verify_proof.go | 10 ++++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/config.yaml b/config.yaml index 0c91f9d..1c121bc 100644 --- a/config.yaml +++ b/config.yaml @@ -3,6 +3,7 @@ network: verifier_address: "" vault_address: "http://127.0.0.1:8200" vault_mount_path: "secret_data" + no_send: false log: level: debug diff --git a/internal/config/network.go b/internal/config/network.go index 64a37ee..a445011 100644 --- a/internal/config/network.go +++ b/internal/config/network.go @@ -37,6 +37,7 @@ type NetworkConfig struct { VotingRegistry common.Address `fig:"voting_registry,required"` Address string `fig:"vault_address,required"` MountPath string `fig:"vault_mount_path,required"` + NoSend bool `fig:"no_send"` ChainID *big.Int `fig:"chain_id"` Token string `dig:"VAULT_TOKEN,clear"` @@ -79,6 +80,7 @@ func (e *ethereum) NetworkConfig() *NetworkConfig { "voting_registry": result.VotingRegistry, "vault_address": result.Address, "vault_mount_path": result.MountPath, + "no_send": result.NoSend, }).Now(); err != nil { panic(err) } diff --git a/internal/service/api/handlers/verify_proof.go b/internal/service/api/handlers/verify_proof.go index 207458b..168a670 100644 --- a/internal/service/api/handlers/verify_proof.go +++ b/internal/service/api/handlers/verify_proof.go @@ -116,10 +116,12 @@ func VerifyProof(w http.ResponseWriter, r *http.Request) { return } - if err := EthClient(r).SendTransaction(r.Context(), tx); err != nil { - Log(r).WithError(err).Error("failed to send transaction") - ape.RenderErr(w, problems.InternalError()) - return + if !NetworkConfig(r).NoSend { + if err := EthClient(r).SendTransaction(r.Context(), tx); err != nil { + Log(r).WithError(err).Error("failed to send transaction") + ape.RenderErr(w, problems.InternalError()) + return + } } NetworkConfig(r).IncrementNonce()