From 87ace0f962f5aec4d4f182becb2bf91a9b1cc866 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Thu, 7 Dec 2023 11:36:58 +0100 Subject: [PATCH] feat: add extra options to asset-options per extension --- bitsharesbase/objects.py | 31 ++++++++++++++++++++++++++++++- tests/test_transactions.py | 17 +++++++++++------ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/bitsharesbase/objects.py b/bitsharesbase/objects.py index e0d54b8..53c216d 100644 --- a/bitsharesbase/objects.py +++ b/bitsharesbase/objects.py @@ -242,7 +242,10 @@ def __init__(self, *args, **kwargs): ), ), ("description", String(kwargs["description"])), - ("extensions", Set([])), + ( + "extensions", + AdditionalAssetOptionsType(kwargs.get("extensions")), + ), ] ) ) @@ -497,3 +500,29 @@ def NestedLimitOrderAutoAction(value): sorted_options = [ ("on_fill", NestedLimitOrderAutoAction), ] + + +class AdditionalAssetOptionsType(Extension): + def RewardPercent(value): + if value: + return Uint16(value) + else: + return None + + def WhitelistMarketFeeSharing(value): + if value: + return Array([ObjectId(o, "account") for o in value]) + else: + return None + + def TakerFeePercent(value): + if value: + return Uint16(value) + else: + return None + + sorted_options = [ + ("reward_percent", RewardPercent), + ("whitelist_market_fee_sharing", WhitelistMarketFeeSharing), + ("taker_fee_percent", TakerFeePercent), + ] diff --git a/tests/test_transactions.py b/tests/test_transactions.py index 830ce5c..a8b5f50 100644 --- a/tests/test_transactions.py +++ b/tests/test_transactions.py @@ -649,7 +649,11 @@ def test_asset_create(self): "whitelist_markets": ["1.3.0"], "blacklist_markets": ["1.3.1"], "description": "Foobar think", - "extensions": [], + "extensions": { + "reward_percent": 145, + "whitelist_market_fee_sharing": ["1.2.215"], + "taker_fee_percent": 675, + }, }, "bitasset_opts": { "feed_lifetime_sec": 86400, @@ -668,12 +672,13 @@ def test_asset_create(self): "f68585abf4dce7c80457010a000000000000000000000554484" "94e47000080c6a47e8d030000000080c6a47e8d03004f000000" "000000000000000000000000000000000000010001010100010" - "10c466f6f626172207468696e6b000180510100078051010064" - "0032000000000000011f1b8ac491bb327921d9346d543e530d8" - "8acb68bade58296a7a27b0a74a28eaca762260dbb905a6415f6" - "225a8028a810de6290badc29d16fea0ffd88bc8c0cbec4" + "10c466f6f626172207468696e6b030091000101d70102a30201" + "805101000780510100640032000000000000012049dd5c7f6fa" + "e9b7e071c59911cf61b12f7983f71eaa576b4b46313e0af27c5" + "6e20b781e8736362447645547c050c1fd5ae39881f6da68dc71" + "e230a64cb60c8db" ) - self.doit() + self.doit(1) def test_asset_update(self): self.op = operations.Asset_update(