Skip to content

Commit

Permalink
Merge pull request #230 from planetarium/release/0.10.0
Browse files Browse the repository at this point in the history
Backmerge 0.10.0 to development
  • Loading branch information
U-lis authored Feb 5, 2024
2 parents 3a834ea + 07c3abb commit 6b803fe
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
9 changes: 5 additions & 4 deletions common/lib9c/models/fungible_asset_value.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from decimal import Decimal
from typing import Dict, List, Optional, Any

import bencodex
Expand All @@ -8,7 +9,7 @@


class FungibleAssetValue:
def __init__(self, currency: Currency, amount: float):
def __init__(self, currency: Currency, amount: Decimal):
self.currency = currency
self.amount = amount

Expand All @@ -19,16 +20,16 @@ def __eq__(self, other: FungibleAssetValue):
def from_raw_data(
cls,
ticker: str, decimal_places: int, minters: Optional[List[str]] = None, total_supply_trackable: bool = False,
amount: float = 0
amount: Decimal = Decimal("0")
):
return cls(
Currency(ticker, decimal_places, minters, total_supply_trackable),
amount=amount
)

@property
def plain_value(self) -> List[Dict[str, Any] | float]:
return [self.currency.plain_value, self.amount * max(1, 10 ** self.currency.decimal_places)]
def plain_value(self) -> List[Dict[str, Any] | int]:
return [self.currency.plain_value, int(self.amount * max(1, 10 ** self.currency.decimal_places))]

@property
def serialized_plain_value(self) -> bytes:
Expand Down
28 changes: 24 additions & 4 deletions worker/worker/status_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from common.utils.aws import fetch_secrets
from common.utils.receipt import PlanetID

STAGE = os.environ.get("STAGE")
DB_URI = os.environ.get("DB_URI")
db_password = fetch_secrets(os.environ.get("REGION_NAME"), os.environ.get("SECRET_ARN"))["password"]
DB_URI = DB_URI.replace("[DB_PASSWORD]", db_password)
Expand All @@ -28,6 +29,17 @@
"48e50ecd6d1aa2689fd349c1f0611e6cc1e9c4c74ec4de9d4637ec7b78617308": "Golden Meat (800202)",
}

VIEW_ORDER = (
"CRYSTAL",
FUNGIBLE_DICT["3991e04dd808dc0bc24b21f5adb7bf1997312f8700daf1334bf34936e8a0813a"], # Hourglass
FUNGIBLE_DICT["00dfffe23964af9b284d121dae476571b7836b8d9e2e5f510d92a840fecc64fe"], # AP Potion
"RUNE_GOLDENLEAF",
FUNGIBLE_DICT["f8faf92c9c0d0e8e06694361ea87bfc8b29a8ae8de93044b98470a57636ed0e0"], # Golden Dust
FUNGIBLE_DICT["48e50ecd6d1aa2689fd349c1f0611e6cc1e9c4c74ec4de9d4637ec7b78617308"], # Golden Meat
FUNGIBLE_DICT["1a755098a2bc0659a063107df62e2ff9b3cdaba34d96b79519f504b996f53820"], # Silver Dust
"SOULSTONE_1001", "SOULSTONE_1002", "SOULSTONE_1003", "SOULSTONE_1004",
)

engine = create_engine(DB_URI)


Expand Down Expand Up @@ -148,13 +160,21 @@ def check_garage():
fav_data = data["garageBalances"]
item_data = data["fungibleItemGarages"]

msg = []
result_dict = {}

for fav in fav_data:
msg.append(create_block(f"{fav['currency']['ticker']} : {int(fav['quantity'].split('.')[0]):,}"))
result_dict[fav["currency"]["ticker"]] = fav["quantity"].split(".")[0]
for item in item_data:
msg.append(create_block(f"{FUNGIBLE_DICT[item['fungibleItemId']]} : {item['count']:,}"))
result_dict[FUNGIBLE_DICT[item["fungibleItemId"]]] = item["count"]

msg = []
for key in VIEW_ORDER:
result = result_dict.pop(key)
msg.append(create_block(f"{key} : {int(result):,}"))
for key, result in result_dict.items():
msg.append(create_block(f"{key} : {int(result):,}"))

send_message(IAP_GARAGE_WEBHOOK_URL, "[NineChronicles.IAP] Daily Garage Report", msg)
send_message(IAP_GARAGE_WEBHOOK_URL, f"[NineChronicles.IAP] Daily Garage Report - {STAGE}", msg)


def handle(event, context):
Expand Down

0 comments on commit 6b803fe

Please sign in to comment.