Skip to content

Commit

Permalink
feat: fix method name
Browse files Browse the repository at this point in the history
  • Loading branch information
BATMAH69 committed Jan 23, 2024
1 parent f9f9887 commit 134e435
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/internal/test_ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_fetch_cid_status_from_ipfs():
status = fetch_cid_status_from_ipfs("bafkreigvk6oenx6mp4mca4at4znujzgljywcfghuvrcxxkhye5b7ghutbm")
assert status == 200
status = fetch_cid_status_from_ipfs("bafkreigdsodbw6dlajnk7xyudw52cutzioovt7r7mrdf3t3cx7xfzz3eou")
assert status == 404
assert status == 404 or status == 504 # depends on service


def test_upload_vote_ipfs_description():
Expand Down
9 changes: 6 additions & 3 deletions utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_deployer_account() -> Union[LocalAccount, Account]:
return accounts.load(os.environ["DEPLOYER"]) if (is_live or "DEPLOYER" in os.environ) else accounts[4]


def get_web3_storage_token(silent = False) -> str:
def get_web3_storage_token(silent=False) -> str:
is_live = get_is_live()
if is_live and not silent and "WEB3_STORAGE_TOKEN" not in os.environ:
raise EnvironmentError(
Expand All @@ -72,7 +72,8 @@ def get_web3_storage_token(silent = False) -> str:

return os.environ["WEB3_STORAGE_TOKEN"] if (is_live or "WEB3_STORAGE_TOKEN" in os.environ) else ""

def get_pinata_cloud_token(silent = False) -> str:

def get_pinata_cloud_token(silent=False) -> str:
is_live = get_is_live()
if is_live and not silent and "PINATA_CLOUD_TOKEN" not in os.environ:
raise EnvironmentError(
Expand All @@ -83,7 +84,8 @@ def get_pinata_cloud_token(silent = False) -> str:

return os.environ["PINATA_CLOUD_TOKEN"] if (is_live or "PINATA_CLOUD_TOKEN" in os.environ) else ""

def get_infura_io_keys(silent = False) -> Tuple[str, str]:

def get_infura_io_keys(silent=False) -> Tuple[str, str]:
is_live = get_is_live()
if is_live and not silent and (
"WEB3_INFURA_IPFS_PROJECT_ID" not in os.environ or "WEB3_INFURA_IPFS_PROJECT_SECRET" not in os.environ
Expand All @@ -102,6 +104,7 @@ def get_infura_io_keys(silent = False) -> Tuple[str, str]:
)
return project_id, project_secret


def prompt_bool() -> Optional[bool]:
choice = input().lower()
if choice in {"yes", "y"}:
Expand Down
6 changes: 3 additions & 3 deletions utils/ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _upload_str_to_pinata_cloud(text: str) -> str:
text_bytes = text.encode("utf-8")
text_file = io.BytesIO(text_bytes)
files = {"file": text_file}
pinata_cloud_token = get_pinata_cloud_keys()
pinata_cloud_token = get_pinata_cloud_token()

endpoint = "https://api.pinata.cloud"

Expand Down Expand Up @@ -101,9 +101,9 @@ def _upload_str_to_web3_storage(text: str) -> str:


def _upload_str_to_ipfs(text: str) -> str:
if get_pinata_cloud_keys(silent = True):
if get_pinata_cloud_token(silent=True):
return _upload_str_to_web3_storage(text)
if get_infura_io_keys(silent =True):
if get_infura_io_keys(silent=True):
return _upload_str_to_infura_io(text)
return _upload_str_to_web3_storage(text)

Expand Down

0 comments on commit 134e435

Please sign in to comment.