Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions modules/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,12 @@ def create_new_bookmark(self, args):
except:
color_print("{red}Bad args. Usage:{endc} nb <bookmark-name> <account-addr>")
return
if self.ton.IsAddr(addr):
type = "account"
if not self.ton.IsAddr(addr):
raise Exception("Incorrect address")
# end if

bookmark = dict()
bookmark["name"] = name
bookmark["type"] = type
bookmark["addr"] = addr
self.ton.AddBookmark(bookmark)
color_print("CreatNewBookmark - {green}OK{endc}")
Expand All @@ -153,24 +152,22 @@ def print_bookmarks_list(self, args):
print("No data")
return
table = list()
table += [["Name", "Type", "Address", "Balance / Exp. date"]]
table += [["Name", "Address", "Balance / Exp. date"]]
for item in data:
name = item.get("name")
type = item.get("type")
addr = item.get("addr")
bookmark_data = item.get("data")
table += [[name, type, addr, bookmark_data]]
table += [[name, addr, bookmark_data]]
print_table(table)
# end define

def delete_bookmark(self, args):
try:
name = args[0]
type = args[1]
except:
color_print("{red}Bad args. Usage:{endc} db <bookmark-name> <bookmark-type>")
color_print("{red}Bad args. Usage:{endc} db <bookmark-name>")
return
self.ton.DeleteBookmark(name, type)
self.ton.DeleteBookmark(name)
color_print("DeleteBookmark - {green}OK{endc}")
# end define

Expand Down
46 changes: 8 additions & 38 deletions mytoncore/mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2730,20 +2730,6 @@ def GetItemFromDict(self, data, search):
return None
#end define

def GetAutoTransferRules(self):
autoTransferRules = self.local.db.get("autoTransferRules")
if autoTransferRules is None:
autoTransferRules = list()
self.local.db["autoTransferRules"] = autoTransferRules
return autoTransferRules
#end define

def AddAutoTransferRule(self, rule):
autoTransferRules = self.GetAutoTransferRules()
autoTransferRules.append(rule)
self.local.save()
#end define

def AddBookmark(self, bookmark):
if "bookmarks" not in self.local.db:
self.local.db["bookmarks"] = list()
Expand All @@ -2760,40 +2746,24 @@ def GetBookmarks(self):
return bookmarks
#end define

def GetBookmarkAddr(self, type, name):
bookmarks = self.local.db.get("bookmarks", list())
for bookmark in bookmarks:
bookmarkType = bookmark.get("type")
bookmarkName = bookmark.get("name")
bookmarkAddr = bookmark.get("addr")
if (bookmarkType == type and bookmarkName == name):
return bookmarkAddr
raise Exception("GetBookmarkAddr error: Bookmark not found")
#end define

def DeleteBookmark(self, name, type):
def DeleteBookmark(self, name):
bookmarks = self.local.db.get("bookmarks")
for bookmark in bookmarks:
bookmarkType = bookmark.get("type")
bookmarkName = bookmark.get("name")
if (type == bookmarkType and name == bookmarkName):
bookmark_name = bookmark.get("name")
if name == bookmark_name:
bookmarks.remove(bookmark)
self.local.save()
return
raise Exception("DeleteBookmark error: Bookmark not found")
#end define

def WriteBookmarkData(self, bookmark):
type = bookmark.get("type")
if type == "account":
addr = bookmark.get("addr")
account = self.GetAccount(addr)
if account.status == "empty":
data = "empty"
else:
data = account.balance
addr = bookmark.get("addr")
account = self.GetAccount(addr)
if account.status == "empty":
data = "empty"
else:
data = "null"
data = account.balance
bookmark["data"] = data
#end define

Expand Down