Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.

Commit 3145ffd

Browse files
committed
Add beneficiaries command to beempy,
* New anyx.io node added to nodelist * GetWitnesses fixed
1 parent 5e1e77b commit 3145ffd

3 files changed

Lines changed: 82 additions & 7 deletions

File tree

beem/cli.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,67 @@ def updatememokey(account, key):
14471447
print(tx)
14481448

14491449

1450+
@cli.command()
1451+
@click.argument('authorperm', nargs=1)
1452+
@click.argument('beneficiaries', nargs=-1)
1453+
def beneficiaries(authorperm, beneficiaries):
1454+
"""Set beneficaries"""
1455+
stm = shared_steem_instance()
1456+
if stm.rpc is not None:
1457+
stm.rpc.rpcconnect()
1458+
c = Comment(authorperm, steem_instance=stm)
1459+
account = c["author"]
1460+
1461+
if not account:
1462+
account = stm.config["default_account"]
1463+
if not unlock_wallet(stm):
1464+
return
1465+
beneficiaries_list = []
1466+
beneficiaries_accounts = []
1467+
beneficiaries_sum = 0
1468+
1469+
options = {"author": c["author"],
1470+
"permlink": c["permlink"],
1471+
"max_accepted_payout": c["max_accepted_payout"],
1472+
"percent_steem_dollars": c["percent_steem_dollars"],
1473+
"allow_votes": c["allow_votes"],
1474+
"allow_curation_rewards": c["allow_curation_rewards"]}
1475+
1476+
for w in beneficiaries[0].split(","):
1477+
account_name = w.strip().split(":")[0]
1478+
if account_name[0] == "@":
1479+
account_name = account_name[1:]
1480+
a = Account(account_name, steem_instance=stm)
1481+
if a["name"] in beneficiaries_accounts:
1482+
continue
1483+
if w.find(":") == -1:
1484+
percentage = -1
1485+
else:
1486+
percentage = w.strip().split(":")[1]
1487+
if "%" in percentage:
1488+
percentage = percentage.strip().split("%")[0].strip()
1489+
percentage = float(percentage)
1490+
beneficiaries_sum += percentage
1491+
beneficiaries_list.append({"account": a["name"], "weight": int(percentage * 100)})
1492+
beneficiaries_accounts.append(a["name"])
1493+
1494+
missing = 0
1495+
for bene in beneficiaries_list:
1496+
if bene["weight"] < 0:
1497+
missing += 1
1498+
index = 0
1499+
for bene in beneficiaries_list:
1500+
if bene["weight"] < 0:
1501+
beneficiaries_list[index]["weight"] = int((int(100 * 100) - int(beneficiaries_sum * 100)) / missing)
1502+
index += 1
1503+
beneficiaries_list_sorted = sorted(beneficiaries_list, key=lambda beneficiaries_list: beneficiaries_list["account"])
1504+
tx = stm.comment_options(options, authorperm, beneficiaries_list_sorted, account=account)
1505+
if stm.unsigned and stm.nobroadcast and stm.steemconnect is not None:
1506+
tx = stm.steemconnect.url_from_tx(tx)
1507+
tx = json.dumps(tx, indent=4)
1508+
print(tx)
1509+
1510+
14501511
@cli.command()
14511512
@click.argument('witness', nargs=1)
14521513
@click.option('--account', '-a', help='Your account')

beem/nodelist.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ def __init__(self):
208208
"owner": "followbtcnews",
209209
"score": 10
210210
},
211+
{
212+
"url": "wss://anyx.io",
213+
"version": "0.20.6",
214+
"type": "appbase",
215+
"owner": "anyx",
216+
"score": 50
217+
},
218+
{
219+
"url": "https://anyx.io",
220+
"version": "0.20.6",
221+
"type": "appbase",
222+
"owner": "anyx",
223+
"score": 50
224+
},
211225
{
212226
"url": "https://rpc.curiesteem.com",
213227
"version": "0.20.2",

beem/witness.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,14 @@ def __init__(self, name_list, batch_limit=100, lazy=False, full=True, steem_inst
293293
return
294294
witnesses = []
295295
name_cnt = 0
296-
297-
while name_cnt < len(name_list):
298-
self.steem.rpc.set_next_node_on_empty_reply(False)
299-
if self.steem.rpc.get_use_appbase():
296+
if self.steem.rpc.get_use_appbase():
297+
while name_cnt < len(name_list):
298+
self.steem.rpc.set_next_node_on_empty_reply(False)
300299
witnesses += self.steem.rpc.find_witnesses({'owners': name_list[name_cnt:batch_limit + name_cnt]}, api="database")["witnesses"]
301-
else:
302-
witnesses += self.steem.rpc.get_witness_by_account(name_list[name_cnt:batch_limit + name_cnt])
303-
name_cnt += batch_limit
300+
name_cnt += batch_limit
301+
else:
302+
for witness in name_list:
303+
witnesses.append(self.steem.rpc.get_witness_by_account(witness))
304304
self.identifier = ""
305305
super(GetWitnesses, self).__init__(
306306
[

0 commit comments

Comments
 (0)