Skip to content

Commit

Permalink
Fix bug in pay plan w/ wallet intro. in 2.0.6. Fix bug in app.theme f…
Browse files Browse the repository at this point in the history
…ail dialog
  • Loading branch information
freQniK committed Dec 20, 2024
1 parent c83906e commit 04a7428
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
20 changes: 11 additions & 9 deletions src/cli/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,25 +321,27 @@ def send_2plan_wallet(self, KEYNAME, plan_id, DENOM, amount_required, tax: bool=
balance = self.get_balance(sdk._account.address)
print(balance)

amount_required = float(amount_required) # Just in case was passed as str
token_ibc = {v: k for k, v in IBCTokens.IBCUNITTOKEN.items()}
ubalance = balance.get(token_ibc[DENOM][1:], 0) * IBCTokens.SATOSHI
# Get balance automatically return udvpn ad dvpn
if ubalance < amount_required:
message = f"Balance is too low, required: {amount_required}{DENOM}"
return (False, {'hash' : None, 'success' : False, 'message' : message})
amount_required = int(amount_required) # Just in case was passed as str

# F***ck we have always a unit issue ...
if DENOM == "dvpn":
print(f"Denom is a dvpn, convert as udvpn, amount_required: {amount_required}dvpn")
DENOM = "udvpn"
amount_required = int(round(amount_required * IBCTokens.SATOSHI, 4))
print(f"amount_required: {amount_required}udvpn")
ubalance = balance.get("dvpn", 0) * IBCTokens.SATOSHI
else:
# I need to convert osmo, atom etc to ibc denom
# token_ibc (k: v) is a dict like: {'uscrt': 'ibc/31FEE1A2A9F9C01113F90BD0BBCCE8FD6BBB8585FAF109A2101827DD1D5B95B8', 'uatom': 'ibc/A8C2D23A1E6
token_ibc = {k: v for k, v in IBCTokens.IBCUNITTOKEN.items()}
DENOM = token_ibc.get(DENOM, DENOM)
ubalance = balance.get(token_ibc[DENOM][1:], 0) * IBCTokens.SATOSHI

print(ubalance)
print(f"amount_required: {amount_required}{DENOM}")

# Get balance automatically return udvpn ad dvpn
if ubalance < amount_required:
message = f"Balance is too low, required: {amount_required}{DENOM}"
return (False, {'hash' : None, 'success' : False, 'message' : message})

gas = random.randint(ConfParams.GAS-50000, 314159)

Expand Down
20 changes: 18 additions & 2 deletions src/typedef/konstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ class IBCTokens():
#mu_coins = ["tsent", "udvpn", "uscrt", "uosmo", "uatom", "udec"]
class TextStrings():
dash = "-"
VERSION = "v2.0.4"
BUILD = "1733738460383"
VERSION = "v2.0.7"
BUILD = "1734702982077"
RootTag = "SENTINEL"
PassedHealthCheck = "Passed Sentinel Health Check"
FailedHealthCheck = "Failed Sentinel Health Check"
Expand Down Expand Up @@ -722,6 +722,22 @@ class NodeKeys():






















Expand Down
4 changes: 2 additions & 2 deletions src/ui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ def pay_meile_plan_with_wallet(self, deposit, mu_coin, usd, on_success: callable
KEYNAME = CONFIG['wallet'].get('keyname', '')

hwf = HandleWalletFunctions()
result, output = hwf.send_2plan_wallet(KEYNAME, self.plan_id, mu_coin, deposit)
result, output = hwf.send_2plan_wallet(KEYNAME, self.plan_id, mu_coin, int(round(float(deposit),4)*IBCTokens.SATOSHI))
print("result", result)
print("output", output)

Expand All @@ -1061,7 +1061,7 @@ def pay_meile_plan_with_wallet(self, deposit, mu_coin, usd, on_success: callable
MDFlatButton(
text="OK",
theme_text_color="Custom",
text_color=self.theme_cls.primary_color,
text_color=MeileColors.MEILE,
on_release=self.closeDialog
),])
if isinstance(output, dict) is True:
Expand Down

0 comments on commit 04a7428

Please sign in to comment.