Skip to content

Commit

Permalink
Add domains resolution for sending
Browse files Browse the repository at this point in the history
  • Loading branch information
bitlogik committed Feb 28, 2023
1 parent de6196a commit a84f58c
Show file tree
Hide file tree
Showing 15 changed files with 352 additions and 70 deletions.
10 changes: 6 additions & 4 deletions gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,10 @@ def load_coins_list(self, coins_list):
self.gui_panel.Layout()
self.gui_frame.Layout()

def confirm_tx(self, to_addr, amount):
conf_txt = f"Confirm this transaction ?\n{amount} {self.wallet.coin} to {to_addr}"
def confirm_tx(self, to_addr, amount, domain):
if domain:
to_addr += f" ({domain})"
conf_txt = "Confirm this transaction ?\n" f"{amount} {self.wallet.coin} to {to_addr}"
confirm_tx_modal = wx.MessageDialog(
self.gui_frame,
conf_txt,
Expand All @@ -575,7 +577,7 @@ def confirm_tx(self, to_addr, amount):
)
return confirm_tx_modal.ShowModal()

def callback_send(self, status, address, amount_str, sel_fee=1):
def callback_send(self, status, address, amount_str, sel_fee=1, domain=""):
self.gui_panel.Enable()
if status != "OK":
self.send_dialog.Destroy()
Expand Down Expand Up @@ -605,7 +607,7 @@ def callback_send(self, status, address, amount_str, sel_fee=1):
self.warn_modal("Unvalid amount input", parent=self.send_dialog)
return
self.send_dialog.Disable()
conf = self.confirm_tx(address, amount_str)
conf = self.confirm_tx(address, amount_str, domain)
if conf == wx.ID_YES:
self.gui_panel.Enable()
self.send_dialog.Destroy()
Expand Down
25 changes: 19 additions & 6 deletions gui/galleryapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
import webbrowser
import wx

from wallets.ETHwallet import testaddr
from wallets.ETHwallet import testaddr, ETH_wallet
from wallets.NFTwallet import get_image_file
from wallets.name_service import resolve
from gui.utils import icon_file, file_path
from gui.gallerygui import GalleryFrame, GalleryPanel

Expand Down Expand Up @@ -211,23 +212,35 @@ def open_url(self, url):
def send_nft(self, nft):
# Ask the receiving address
dest_modal = wx.TextEntryDialog(
self.frame, "Input the destination address :", f"Send the {self.symb} #{nft['id']}"
self.frame,
"Input the destination address or domain",
f"Send the {self.symb} #{nft['id']}",
)
ret_mod = dest_modal.ShowModal()
if ret_mod != wx.ID_OK:
dest_modal.Destroy()
return
dest_addr = dest_modal.GetValue()
dest_str = dest_modal.GetValue()
dest_modal.Destroy()
# Resolve domain
resolved = resolve(dest_str, ETH_wallet.coin)
if resolved:
dest_addr = resolved
else:
dest_addr = dest_str
# Check address
if not testaddr(dest_addr):
self.show_message("Bad address format provided.")
dest_addr = testaddr(dest_addr)
if not dest_addr:
self.show_message("Wrong address or domain provided.")
return

# Confirm
disp_dest = dest_addr
if "." in dest_str:
disp_dest += f" ({dest_str})"
conf_modal = wx.MessageDialog(
self.frame,
f"Confirm sending {self.symb} NFT #{nft['id']} to {dest_addr} ?",
f"Confirm sending {self.symb} NFT #{nft['id']}\n" f"to {disp_dest} ?",
style=wx.OK | wx.CENTRE | wx.CANCEL,
)
ret_conf = conf_modal.ShowModal()
Expand Down
54 changes: 27 additions & 27 deletions gui/gui2.fbp
Original file line number Diff line number Diff line change
Expand Up @@ -3747,10 +3747,10 @@
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxLEFT</property>
<property name="border">8</property>
<property name="flag">wxBOTTOM|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<object class="wxBitmapButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
Expand All @@ -3761,24 +3761,30 @@
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">0,0,0</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Destination Address</property>
<property name="label">Paste</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
Expand All @@ -3787,24 +3793,29 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText7</property>
<property name="name">paste_btn</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<property name="window_style">wxBORDER_NONE</property>
</object>
</object>
<object class="sizeritem" expanded="1">
Expand All @@ -3818,10 +3829,10 @@
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">8</property>
<property name="flag">wxBOTTOM</property>
<property name="border">5</property>
<property name="flag">wxTOP|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxBitmapButton" expanded="1">
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
Expand All @@ -3832,30 +3843,24 @@
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="fg">0,0,0</property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Paste</property>
<property name="margins"></property>
<property name="label">Destination Address or Domain</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
Expand All @@ -3864,29 +3869,24 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">paste_btn</property>
<property name="name">m_staticText7</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxBORDER_NONE</property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
</object>
Expand Down
14 changes: 7 additions & 7 deletions gui/maingui.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,18 +578,18 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.

bSizer201 = wx.BoxSizer( wx.HORIZONTAL )

self.m_staticText7 = wx.StaticText( self, wx.ID_ANY, u"Destination Address", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText7.Wrap( -1 )
self.paste_btn = wx.BitmapButton( self, wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW|0|wx.BORDER_NONE )
bSizer201.Add( self.paste_btn, 0, wx.BOTTOM|wx.LEFT, 8 )

self.m_staticText7.SetForegroundColour( wx.Colour( 0, 0, 0 ) )

bSizer201.Add( self.m_staticText7, 0, wx.TOP|wx.LEFT, 5 )
bSizer201.Add( ( 0, 0), 0, wx.LEFT, 20 )

self.m_staticText7 = wx.StaticText( self, wx.ID_ANY, u"Destination Address or Domain", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText7.Wrap( -1 )

bSizer201.Add( ( 0, 0), 0, wx.LEFT, 20 )
self.m_staticText7.SetForegroundColour( wx.Colour( 0, 0, 0 ) )

self.paste_btn = wx.BitmapButton( self, wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW|0|wx.BORDER_NONE )
bSizer201.Add( self.paste_btn, 0, wx.BOTTOM, 8 )
bSizer201.Add( self.m_staticText7, 0, wx.TOP|wx.LEFT, 5 )


bSizer23.Add( bSizer201, 0, 0, 5 )
Expand Down
13 changes: 11 additions & 2 deletions gui/send_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self, parent, coin, check, callback):
self.panel.text_amount.Bind(wx.EVT_TEXT_ENTER, self.click_ok)
self.panel.paste_btn.Bind(wx.EVT_BUTTON, self.paste_addr)
self.panel.bmp_chk.SetBitmap(self.BAD_BMP)
self.dest_addr = ""
if platform.startswith("darwin"):
self.panel.fiat_label.SetFont(wx.Font(wx.FontInfo(14)))
self.panel.fiat_value.SetFont(wx.Font(wx.FontInfo(14)))
Expand Down Expand Up @@ -81,8 +82,11 @@ def paste_addr(self, evt):
self.panel.text_dest.SetValue(text_data.GetText())

def check_addr(self, evt):
if self.check_addr_method(evt.GetString()):
self.dest_addr = ""
dest = self.check_addr_method(evt.GetString())
if dest:
self.panel.bmp_chk.SetBitmap(self.GOOD_BMP)
self.dest_addr = dest
else:
self.panel.bmp_chk.SetBitmap(self.BAD_BMP)

Expand Down Expand Up @@ -114,5 +118,10 @@ def click_cancel(self, event):
def click_ok(self, event):
amount = self.panel.text_amount.GetValue()
dest = self.panel.text_dest.GetValue()
if "." in dest:
domain = dest
dest = self.dest_addr
else:
domain = ""
fee_level = self.panel.fee_slider.GetValue()
self.cb("OK", dest, amount, fee_level)
self.cb("OK", dest, amount, fee_level, domain)
Loading

0 comments on commit a84f58c

Please sign in to comment.