-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
80 changed files
with
1,672 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
from dataclasses import dataclass | ||
|
||
from app.engine.projects.rewards.threshold import ( | ||
ProjectThreshold, | ||
ProjectThresholdPayload, | ||
) | ||
|
||
|
||
@dataclass | ||
class DefaultProjectThreshold(ProjectThreshold): | ||
PROJECTS_COUNT_MULTIPLIER: int | ||
|
||
def calculate_threshold(self, payload: ProjectThresholdPayload) -> int: | ||
return ( | ||
int(payload.total_allocated / (payload.projects_count * 2)) | ||
int( | ||
payload.total_allocated | ||
/ (payload.projects_count * self.PROJECTS_COUNT_MULTIPLIER) | ||
) | ||
if payload.projects_count | ||
else 0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
backend/app/infrastructure/external_api/safe/message_details.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import requests | ||
|
||
import app as app_module | ||
from app.constants import SAFE_API_MAINNET, SAFE_API_SEPOLIA | ||
from app.exceptions import ExternalApiException | ||
|
||
|
||
def get_message_details(message_hash: str, is_mainnet: bool) -> dict: | ||
api_url = _get_api_url(message_hash, is_mainnet) | ||
|
||
try: | ||
response = requests.request("GET", api_url) | ||
response.raise_for_status() | ||
json_response = response.json() | ||
except requests.exceptions.RequestException as e: | ||
app_module.ExceptionHandler.print_stacktrace(e) | ||
raise ExternalApiException(api_url, e, 500) | ||
|
||
return json_response | ||
|
||
|
||
def _get_api_url( | ||
message_hash: str, | ||
is_mainnet: bool, | ||
) -> str: | ||
base_url = SAFE_API_MAINNET if is_mainnet else SAFE_API_SEPOLIA | ||
return f"{base_url}/messages/{message_hash}" |
24 changes: 24 additions & 0 deletions
24
backend/app/infrastructure/external_api/safe/user_details.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import requests | ||
|
||
import app as app_module | ||
from app.constants import SAFE_API_MAINNET, SAFE_API_SEPOLIA | ||
from app.exceptions import ExternalApiException | ||
|
||
|
||
def get_user_details(user_address: str, is_mainnet: bool) -> dict: | ||
api_url = _get_api_url(user_address, is_mainnet) | ||
|
||
try: | ||
response = requests.request("GET", api_url) | ||
response.raise_for_status() | ||
json_response = response.json() | ||
except requests.exceptions.RequestException as e: | ||
app_module.ExceptionHandler.print_stacktrace(e) | ||
raise ExternalApiException(api_url, e, 500) | ||
|
||
return json_response | ||
|
||
|
||
def _get_api_url(user_address: str, is_mainnet: bool) -> str: | ||
base_url = SAFE_API_MAINNET if is_mainnet else SAFE_API_SEPOLIA | ||
return f"{base_url}/safes/{user_address}" |
Oops, something went wrong.