-
Notifications
You must be signed in to change notification settings - Fork 49
chore: shutter env variables #2017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,8 +1,10 @@ | ||||||||||||
import env from "./utils/env"; | ||||||||||||
import { encryptData, decrypt as shutterDecrypt } from "@shutter-network/shutter-sdk"; | ||||||||||||
import { Hex, stringToHex, hexToString } from "viem"; | ||||||||||||
import crypto from "crypto"; | ||||||||||||
import "isomorphic-fetch"; | ||||||||||||
|
||||||||||||
const SHUTTER_API = env.optionalNoDefault("SHUTTER_API"); | ||||||||||||
// Time in seconds to wait before the message can be decrypted | ||||||||||||
export const DECRYPTION_DELAY = 5; | ||||||||||||
|
||||||||||||
|
@@ -38,7 +40,7 @@ async function fetchShutterData(decryptionTimestamp: number): Promise<ShutterApi | |||||||||||
const identityPrefix = generateRandomBytes32(); | ||||||||||||
console.log(`Generated identity prefix: ${identityPrefix}`); | ||||||||||||
|
||||||||||||
const response = await fetch("https://shutter-api.shutter.network/api/register_identity", { | ||||||||||||
const response = await fetch(`${SHUTTER_API}/register_identity`, { | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify the environment variable is properly set. Since Ensure the environment variable is properly configured across all deployment environments: 🏁 Script executed: #!/bin/bash
# Description: Check if SHUTTER_API is defined in environment configuration files
# Look for SHUTTER_API definitions in env files
fd -e env -e example | xargs grep -l "SHUTTER_API" || echo "No SHUTTER_API found in env files"
# Check if there are any default values or fallbacks defined
rg "SHUTTER_API.*=" -A 2 -B 2 Length of output: 1202 🏁 Script executed: #!/bin/bash
set -e
# Search for definition of optionalNoDefault to understand its behavior
rg "optionalNoDefault" -n -C 3 Length of output: 3790 Use a required environment variable for SHUTTER_API The • In contracts/scripts/shutter.ts (at the top, around line 7) - const SHUTTER_API = env.optionalNoDefault("SHUTTER_API");
+ const SHUTTER_API = env.require("SHUTTER_API"); • This change will throw a clear error at startup if SHUTTER_API is not defined, preventing invalid fetch URLs. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||
method: "POST", | ||||||||||||
headers: { | ||||||||||||
accept: "application/json", | ||||||||||||
|
@@ -88,7 +90,7 @@ async function fetchShutterData(decryptionTimestamp: number): Promise<ShutterApi | |||||||||||
async function fetchDecryptionKey(identity: string): Promise<ShutterDecryptionKeyData> { | ||||||||||||
console.log(`Fetching decryption key for identity: ${identity}`); | ||||||||||||
|
||||||||||||
const response = await fetch(`https://shutter-api.shutter.network/api/get_decryption_key?identity=${identity}`, { | ||||||||||||
const response = await fetch(`${SHUTTER_API}/get_decryption_key?identity=${identity}`, { | ||||||||||||
method: "GET", | ||||||||||||
headers: { | ||||||||||||
accept: "application/json", | ||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,4 +8,5 @@ export REACT_APP_ARBITRATOR_TYPE=neo | |||||
export REACT_APP_ATLAS_URI=http://localhost:3000 | ||||||
export WALLETCONNECT_PROJECT_ID= | ||||||
export ALCHEMY_API_KEY= | ||||||
export NODE_OPTIONS='--max-old-space-size=7680' | ||||||
export NODE_OPTIONS='--max-old-space-size=7680' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify if staging URL is appropriate for mainnet environment. The mainnet (production) environment is configured to use the staging Shutter API URL. This may cause reliability issues if the staging environment has different uptime guarantees or gets reset. Please confirm if this is intentional or if a production Shutter API URL should be used instead: 🌐 Web query:
💡 Result: Based on the search results, the Shutter API has different endpoints for staging and production environments. Shutter API EndpointsThe production and staging URLs for Shutter API are environment-specific. According to the information available, the Shutter API can be accessed through the following endpoint for the Chiado environment:
This appears to be one of the available endpoints where you can query the API[2]. However, the complete production URL structure isn't fully specified in the provided information. Staging vs. Production EnvironmentsThere is indeed a difference between staging and production environments for APIs, including the Shutter API. These differences typically include:
One common approach is to use different application plans for each environment with distinct rate limits and method availability. This helps developers test their applications in a controlled environment before moving to production[6][10]. While the specific differences between Shutter API's staging and production endpoints aren't explicitly detailed in the search results, it follows standard API management practices of providing separate environments for development/testing and production use. Citations:
Use Production Shutter API Endpoint in Mainnet Environment The • File: - export REACT_APP_SHUTTER_API="https://shutter-api.chiado.staging.shutter.network/api"
+ export REACT_APP_SHUTTER_API="https://shutter-api.chiado/api" Please confirm the exact production URL (e.g. include or omit 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||
export REACT_APP_SHUTTER_API="https://shutter-api.chiado.staging.shutter.network/api" |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add validation for the required environment variable.
The
SHUTTER_API
environment variable is declared as optional with no default value, which means it could beundefined
. This will cause runtime errors when constructing API URLs in the fetch functions.Add proper validation to ensure the environment variable is set:
Or if you want to keep it optional, add validation:
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually handle it like this in the feat/shutter-dispute-kit branch. I will change it when merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaybuidl Thanks for the confirmation! That sounds like a good approach to handle the environment variable validation in the feature branch and apply it during the merge. I appreciate you keeping track of these improvements across branches.