Skip to content

Commit 7a37be8

Browse files
authored
Merge pull request bitshares#224 from bitfag/tip-asset-fixes
Pass blockchain_instance in Asset methods
2 parents d22cfc5 + 5ad6701 commit 7a37be8

File tree

1 file changed

+48
-16
lines changed

1 file changed

+48
-16
lines changed

bitshares/asset.py

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def max_market_fee(self):
5555
from .amount import Amount
5656

5757
return Amount(
58-
{"amount": self["options"]["max_market_fee"], "asset_id": self["id"]}
58+
{"amount": self["options"]["max_market_fee"], "asset_id": self["id"]},
59+
blockchain_instance=self.blockchain,
5960
)
6061

6162
@property
@@ -222,10 +223,12 @@ def release(
222223
{
223224
"flags": flags_int,
224225
"whitelist_authorities": [
225-
Account(a)["id"] for a in whitelist_authorities
226+
Account(a, blockchain_instance=self.blockchain)["id"]
227+
for a in whitelist_authorities
226228
],
227229
"blacklist_authorities": [
228-
Account(a)["id"] for a in blacklist_authorities
230+
Account(a, blockchain_instance=self.blockchain)["id"]
231+
for a in blacklist_authorities
229232
],
230233
"whitelist_markets": [Asset(a)["id"] for a in whitelist_markets],
231234
"blacklist_markets": [Asset(a)["id"] for a in blacklist_markets],
@@ -330,11 +333,17 @@ def add_authorities(self, type, authorities=[]):
330333
options = self["options"]
331334
if type == "whitelist":
332335
options["whitelist_authorities"].extend(
333-
[Account(a)["id"] for a in authorities]
336+
[
337+
Account(a, blockchain_instance=self.blockchain)["id"]
338+
for a in authorities
339+
]
334340
)
335341
if type == "blacklist":
336342
options["blacklist_authorities"].extend(
337-
[Account(a)["id"] for a in authorities]
343+
[
344+
Account(a, blockchain_instance=self.blockchain)["id"]
345+
for a in authorities
346+
]
338347
)
339348
op = operations.Asset_update(
340349
**{
@@ -360,10 +369,14 @@ def remove_authorities(self, type, authorities=[]):
360369
options = self["options"]
361370
if type == "whitelist":
362371
for a in authorities:
363-
options["whitelist_authorities"].remove(Account(a)["id"])
372+
options["whitelist_authorities"].remove(
373+
Account(a, blockchain_instance=self.blockchain)["id"]
374+
)
364375
if type == "blacklist":
365376
for a in authorities:
366-
options["blacklist_authorities"].remove(Account(a)["id"])
377+
options["blacklist_authorities"].remove(
378+
Account(a, blockchain_instance=self.blockchain)["id"]
379+
)
367380
op = operations.Asset_update(
368381
**{
369382
"fee": {"amount": 0, "asset_id": "1.3.0"},
@@ -396,9 +409,19 @@ def add_markets(self, type, authorities=[], force_enable=True):
396409
), "whitelist feature not enabled"
397410

398411
if type == "whitelist":
399-
options["whitelist_markets"].extend([Asset(a)["id"] for a in authorities])
412+
options["whitelist_markets"].extend(
413+
[
414+
Asset(a, blockchain_instance=self.blockchain)["id"]
415+
for a in authorities
416+
]
417+
)
400418
if type == "blacklist":
401-
options["blacklist_markets"].extend([Asset(a)["id"] for a in authorities])
419+
options["blacklist_markets"].extend(
420+
[
421+
Asset(a, blockchain_instance=self.blockchain)["id"]
422+
for a in authorities
423+
]
424+
)
402425
op = operations.Asset_update(
403426
**{
404427
"fee": {"amount": 0, "asset_id": "1.3.0"},
@@ -422,10 +445,14 @@ def remove_markets(self, type, authorities=[]):
422445
options = self["options"]
423446
if type == "whitelist":
424447
for a in authorities:
425-
options["whitelist_markets"].remove(Asset(a)["id"])
448+
options["whitelist_markets"].remove(
449+
Asset(a, blockchain_instance=self.blockchain)["id"]
450+
)
426451
if type == "blacklist":
427452
for a in authorities:
428-
options["blacklist_markets"].remove(Asset(a)["id"])
453+
options["blacklist_markets"].remove(
454+
Asset(a, blockchain_instance=self.blockchain)["id"]
455+
)
429456
op = operations.Asset_update(
430457
**{
431458
"fee": {"amount": 0, "asset_id": "1.3.0"},
@@ -481,7 +508,10 @@ def update_feed_producers(self, producers):
481508
"fee": {"amount": 0, "asset_id": "1.3.0"},
482509
"issuer": self["issuer"],
483510
"asset_to_update": self["id"],
484-
"new_feed_producers": [Account(a)["id"] for a in producers],
511+
"new_feed_producers": [
512+
Account(a, blockchain_instance=self.blockchain)["id"]
513+
for a in producers
514+
],
485515
"extensions": [],
486516
}
487517
)
@@ -495,7 +525,7 @@ def change_issuer(self, new_issuer, **kwargs):
495525
"""
496526
from .account import Account
497527

498-
new_issuer = Account(new_issuer)
528+
new_issuer = Account(new_issuer, blockchain_instance=self.blockchain)
499529
op = operations.Asset_update_issuer(
500530
**{
501531
"fee": {"amount": 0, "asset_id": "1.3.0"},
@@ -517,9 +547,11 @@ def issue(self, amount, to, memo=None, **kwargs):
517547
from .memo import Memo
518548
from .account import Account
519549

520-
to = Account(to)
550+
to = Account(to, blockchain_instance=self.blockchain)
521551
account = Account(self["issuer"])
522-
memoObj = Memo(from_account=account, to_account=to, blockchain_instance=self)
552+
memoObj = Memo(
553+
from_account=account, to_account=to, blockchain_instance=self.blockchain
554+
)
523555

524556
# append operation
525557
op = operations.Asset_issue(
@@ -538,4 +570,4 @@ def issue(self, amount, to, memo=None, **kwargs):
538570
"extensions": [],
539571
}
540572
)
541-
return self.exbet.finalizeOp(op, self["issuer"], "active", **kwargs)
573+
return self.blockchain.finalizeOp(op, self["issuer"], "active", **kwargs)

0 commit comments

Comments
 (0)