From ab3520003557f372c8d7a128eae099ae8384aeff Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Thu, 22 Jun 2023 13:00:05 +0200 Subject: [PATCH 01/20] fix: allow to use custom prefix for signing key --- bitsharesbase/operations.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bitsharesbase/operations.py b/bitsharesbase/operations.py index 3f25fd8..5317ef1 100644 --- a/bitsharesbase/operations.py +++ b/bitsharesbase/operations.py @@ -682,8 +682,11 @@ def __init__(self, *args, **kwargs): else: new_url = Optional(None) + prefix = kwargs.get("prefix", default_prefix) if "new_signing_key" in kwargs and kwargs["new_signing_key"]: - new_signing_key = Optional(PublicKey(kwargs["new_signing_key"])) + new_signing_key = Optional( + PublicKey(kwargs["new_signing_key"], prefix=prefix) + ) else: new_signing_key = Optional(None) From 43f5e931438da16633d6db7bd796be11e1468ec0 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Wed, 11 Oct 2023 10:58:53 +0200 Subject: [PATCH 02/20] fix: allow to overwrite prefix when changing witness data --- bitsharesbase/operations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitsharesbase/operations.py b/bitsharesbase/operations.py index 5317ef1..b437748 100644 --- a/bitsharesbase/operations.py +++ b/bitsharesbase/operations.py @@ -675,6 +675,7 @@ def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: + prefix = kwargs.get("prefix", default_prefix) if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] if "new_url" in kwargs and kwargs["new_url"]: @@ -682,7 +683,6 @@ def __init__(self, *args, **kwargs): else: new_url = Optional(None) - prefix = kwargs.get("prefix", default_prefix) if "new_signing_key" in kwargs and kwargs["new_signing_key"]: new_signing_key = Optional( PublicKey(kwargs["new_signing_key"], prefix=prefix) From 5f32630275e34c3629aa5e91eb960dc3042b7ccc Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Mon, 20 Nov 2023 15:10:25 +0100 Subject: [PATCH 03/20] ci: remove py 3.6 and 3.7 from pipeline --- .github/workflows/tox.yml | 2 +- tox.ini | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index ca577d8..5edfca8 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -8,7 +8,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.6, 3.7, 3.8] + python-version: [3.8, 3.9] steps: - name: Install secp256k1 diff --git a/tox.ini b/tox.ini index 7f15471..a3520d6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,10 @@ [tox] -envlist = py{36,37,38}-{linux,windows},lint,docs +envlist = py{38,39}-{linux,windows},lint,docs skip_missing_interpreters = true [gh-actions] python = - 3.6: py36 - 3.7: py37 + 3.9: py39 3.8: py38, lint, docs [testenv] From d4163131809cf7d8288186751d354373de8bc867 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Mon, 20 Nov 2023 15:18:23 +0100 Subject: [PATCH 04/20] fix: unittest with proper prefix --- tests/test_transactions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_transactions.py b/tests/test_transactions.py index db95b2e..bdaf72b 100644 --- a/tests/test_transactions.py +++ b/tests/test_transactions.py @@ -521,7 +521,7 @@ def test_witness_update(self): self.op = operations.Witness_update( **{ "fee": {"amount": 0, "asset_id": "1.3.0"}, - "prefix": "TEST", + "prefix": "BTS", "witness": "1.6.63", "witness_account": "1.2.212", "new_url": "https://example.com", From f395f89fc4be5653f749c2bcfe1ab2545afcde16 Mon Sep 17 00:00:00 2001 From: pi314x <51694688+pi314x@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:01:16 +0100 Subject: [PATCH 05/20] Update operations.py --- bitsharesbase/operations.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/bitsharesbase/operations.py b/bitsharesbase/operations.py index b437748..040bdc9 100644 --- a/bitsharesbase/operations.py +++ b/bitsharesbase/operations.py @@ -1224,6 +1224,27 @@ def __init__(self, *args, **kwargs): ] ) ) - + +class Limit_order_update(GrapheneObject): + def __init__(self, *args, **kwargs): + if isArgsThisClass(self, args): + self.data = args[0].data + else: + if len(args) == 1 and len(kwargs) == 0: + kwargs = args[0] + super().__init__( + OrderedDict( + [ + ("fee", Asset(kwargs["fee"])), + ("seller", ObjectId(kwargs["seller"], "account")), + ("order", ObjectId(kwargs["order"], "limit_order")), + ("new_price", Optional(Price(kwargs["new_price"]))), + ("delta_amount_to_sell", Optional(Asset(kwargs["delta_amount_to_sell"]))), + ("new_expiration", Optional(None)), + ("on_fill", Optional(None)), + ("extensions", Optional(None)), + ] + ) + ) fill_classmaps() From 44af638fd247a24a2b150d003233829535decf61 Mon Sep 17 00:00:00 2001 From: pi314x <51694688+pi314x@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:02:04 +0100 Subject: [PATCH 06/20] Update operationids.py --- bitsharesbase/operationids.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bitsharesbase/operationids.py b/bitsharesbase/operationids.py index 208ad16..18299b3 100644 --- a/bitsharesbase/operationids.py +++ b/bitsharesbase/operationids.py @@ -65,6 +65,20 @@ "liquidity_pool_deposit", "liquidity_pool_withdraw", "liquidity_pool_exchange", + "samet_fund_create", + "samet_fund_delete", + "samet_fund_update", + "samet_fund_borrow", + "samet_fund_repay", + "credit_offer_create", + "credit_offer_delete", + "credit_offer_update", + "credit_offer_accept", + "credit_deal_repay", + "credit_deal_expired", + "liquidity_pool_update", + "credit_deal_update", + "limit_order_update", ] operations = {o: ops.index(o) for o in ops} From 0c4da409609b55c7ae07c2629c54b80fd2b148c4 Mon Sep 17 00:00:00 2001 From: pi314x <51694688+pi314x@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:08:20 +0100 Subject: [PATCH 07/20] Update operations.py --- bitsharesbase/operations.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bitsharesbase/operations.py b/bitsharesbase/operations.py index 040bdc9..e87dc75 100644 --- a/bitsharesbase/operations.py +++ b/bitsharesbase/operations.py @@ -1232,14 +1232,25 @@ def __init__(self, *args, **kwargs): else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] + + if kwargs.get("new_price"): + new_price = Optional(Price(kwargs["new_price"])) + else: + new_price = Optional(None) + + if kwargs.get("delta_amount_to_sell"): + delta_amount_to_sell = Optional(Asset(kwargs["delta_amount_to_sell"])) + else: + delta_amount_to_sell = Optional(None) + super().__init__( OrderedDict( [ ("fee", Asset(kwargs["fee"])), ("seller", ObjectId(kwargs["seller"], "account")), ("order", ObjectId(kwargs["order"], "limit_order")), - ("new_price", Optional(Price(kwargs["new_price"]))), - ("delta_amount_to_sell", Optional(Asset(kwargs["delta_amount_to_sell"]))), + ("new_price", new_price), + ("delta_amount_to_sell", delta_amount_to_sell), ("new_expiration", Optional(None)), ("on_fill", Optional(None)), ("extensions", Optional(None)), From d9b9d4bc959a5c1bd2835fc3543729cb54dae3ff Mon Sep 17 00:00:00 2001 From: pi314x <51694688+pi314x@users.noreply.github.com> Date: Fri, 17 Nov 2023 14:59:49 +0100 Subject: [PATCH 08/20] Update operations.py added credit_deal_update and liquidity_pool_update --- bitsharesbase/operations.py | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/bitsharesbase/operations.py b/bitsharesbase/operations.py index e87dc75..c217abe 100644 --- a/bitsharesbase/operations.py +++ b/bitsharesbase/operations.py @@ -1224,6 +1224,56 @@ def __init__(self, *args, **kwargs): ] ) ) + +class Liquidity_pool_update(GrapheneObject): + def __init__(self, *args, **kwargs): + if isArgsThisClass(self, args): + self.data = args[0].data + else: + if len(args) == 1 and len(kwargs) == 0: + kwargs = args[0] + + if kwargs.get("taker_fee_percent"): + taker_fee_percent = Optional(Uint16(kwargs["taker_fee_percent"])) + else: + taker_fee_percent = Optional(None) + + if kwargs.get("withdrawal_fee_percent"): + withdrawal_fee_percent = Optional(Uint16(kwargs["withdrawal_fee_percent"])) + else: + withdrawal_fee_percent = Optional(None) + + super().__init__( + OrderedDict( + [ + ("fee", Asset(kwargs["fee"])), + ("account", ObjectId(kwargs["account"], "account")), + ("pool", ObjectId(kwargs["pool"], "liquidity_pool")), + ("taker_fee_percent", taker_fee_percent), + ("withdrawal_fee_percent", withdrawal_fee_percent), + ("extensions", Set([])), + ] + ) + ) + +class Credit_deal_update(GrapheneObject): + def __init__(self, *args, **kwargs): + if isArgsThisClass(self, args): + self.data = args[0].data + else: + if len(args) == 1 and len(kwargs) == 0: + kwargs = args[0] + super().__init__( + OrderedDict( + [ + ("fee", Asset(kwargs["fee"])), + ("account", ObjectId(kwargs["account"], "account")), + ("deal_id", ObjectId(kwargs["deal_id"], "credit_deal")), + ("auto_repay", Uint8(kwargs["auto_repay"])), + ("extensions", Set([])), + ] + ) + ) class Limit_order_update(GrapheneObject): def __init__(self, *args, **kwargs): From c529e687cdc0422b878a03d1fe63289e1d5bfac4 Mon Sep 17 00:00:00 2001 From: pi314x <51694688+pi314x@users.noreply.github.com> Date: Sat, 18 Nov 2023 08:32:32 +0100 Subject: [PATCH 09/20] Update operations.py --- bitsharesbase/operations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitsharesbase/operations.py b/bitsharesbase/operations.py index c217abe..f20a102 100644 --- a/bitsharesbase/operations.py +++ b/bitsharesbase/operations.py @@ -1303,7 +1303,7 @@ def __init__(self, *args, **kwargs): ("delta_amount_to_sell", delta_amount_to_sell), ("new_expiration", Optional(None)), ("on_fill", Optional(None)), - ("extensions", Optional(None)), + ("extensions", Set([])), ] ) ) From fb832307851a967758468ff0cca4a988471c9aa8 Mon Sep 17 00:00:00 2001 From: pi314x <51694688+pi314x@users.noreply.github.com> Date: Sat, 18 Nov 2023 08:40:47 +0100 Subject: [PATCH 10/20] Update objecttypes.py added samet_fund, credit_offer, credit_deal --- bitsharesbase/objecttypes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bitsharesbase/objecttypes.py b/bitsharesbase/objecttypes.py index eadeedd..a271b49 100644 --- a/bitsharesbase/objecttypes.py +++ b/bitsharesbase/objecttypes.py @@ -21,4 +21,7 @@ object_type["custom_authority"] = 17 object_type["ticket"] = 18 object_type["liquidity_pool"] = 19 -object_type["OBJECT_TYPE_COUNT"] = 19 +object_type["samet_fund"] = 20 +object_type["credit_offer"] = 21 +object_type["credit_deal"] = 22 +object_type["OBJECT_TYPE_COUNT"] = 22 From 3377d852030530a731d59ff16c846183adb9838a Mon Sep 17 00:00:00 2001 From: pi314x <51694688+pi314x@users.noreply.github.com> Date: Sat, 18 Nov 2023 09:04:16 +0100 Subject: [PATCH 11/20] Update operations.py --- bitsharesbase/operations.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bitsharesbase/operations.py b/bitsharesbase/operations.py index f20a102..c6453a5 100644 --- a/bitsharesbase/operations.py +++ b/bitsharesbase/operations.py @@ -45,6 +45,7 @@ Worker_initializer, isArgsThisClass, AssertPredicate, + LimitOrderAutoAction, ) from .operationids import operations @@ -1283,15 +1284,20 @@ def __init__(self, *args, **kwargs): if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] + if kwargs.get("delta_amount_to_sell"): + delta_amount_to_sell = Optional(Asset(kwargs["delta_amount_to_sell"])) + else: + delta_amount_to_sell = Optional(None) + if kwargs.get("new_price"): new_price = Optional(Price(kwargs["new_price"])) else: - new_price = Optional(None) + new_price = Optional(None) - if kwargs.get("delta_amount_to_sell"): - delta_amount_to_sell = Optional(Asset(kwargs["delta_amount_to_sell"])) + if kwargs.get("on_fill"): + on_fill = Optional(Array([LimitOrderAutoAction(o) for o in kwargs["on_fill"]])), else: - delta_amount_to_sell = Optional(None) + on_fill = Optional(None) super().__init__( OrderedDict( @@ -1302,7 +1308,7 @@ def __init__(self, *args, **kwargs): ("new_price", new_price), ("delta_amount_to_sell", delta_amount_to_sell), ("new_expiration", Optional(None)), - ("on_fill", Optional(None)), + ("on_fill", on_fill), ("extensions", Set([])), ] ) From eac2ad499d8ec5d4405cecc1fb5cc73aa5ad528a Mon Sep 17 00:00:00 2001 From: pi314x <51694688+pi314x@users.noreply.github.com> Date: Sat, 18 Nov 2023 09:05:26 +0100 Subject: [PATCH 12/20] Update objects.py --- bitsharesbase/objects.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/bitsharesbase/objects.py b/bitsharesbase/objects.py index 9d1c161..fed83ec 100644 --- a/bitsharesbase/objects.py +++ b/bitsharesbase/objects.py @@ -456,3 +456,29 @@ def __init__(self, *args, **kwargs): else: raise ValueError("Unknown {}".format(self.__class__.name)) super().__init__(data, id) + + +class LimitOrderAutoAction(Static_variant): + def __init__(self, o): + class Create_take_profit_order_action(GrapheneObject): + def __init__(self, *args, **kwargs): + kwargs.update(args[0]) + super().__init__( + OrderedDict( + [ + ("fee_asset_id", ObjectId(kwargs["fee_asset_id"], "asset")), + ("spread_percent", Uint16(kwargs["spread_percent"])), + ("size_percent", Uint16(kwargs["size_percent"])), + ("expiration_seconds", Uint32(kwargs["expiration_seconds"])), + ("repeat", Bool(kwargs["repeat"])), + ("extensions", Set([])), + ] + ) + ) + + id = o[0] + if id == 0: + data = Create_take_profit_order_action(o[1]) + else: + raise ValueError("Unknown {}".format(self.__class__.name)) + super().__init__(data, id) From 8e45870e0bcabd0dd116802a226167306d0e57e7 Mon Sep 17 00:00:00 2001 From: pi314x <51694688+pi314x@users.noreply.github.com> Date: Sat, 18 Nov 2023 09:43:07 +0100 Subject: [PATCH 13/20] Update objects.py --- bitsharesbase/objects.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitsharesbase/objects.py b/bitsharesbase/objects.py index fed83ec..50508da 100644 --- a/bitsharesbase/objects.py +++ b/bitsharesbase/objects.py @@ -454,7 +454,7 @@ def __init__(self, *args, **kwargs): elif id == 2: data = Block_id_predicate(o[1]) else: - raise ValueError("Unknown {}".format(self.__class__.name)) + raise ValueError("Unknown {}".format(self.__class__.__name__)) super().__init__(data, id) @@ -480,5 +480,5 @@ def __init__(self, *args, **kwargs): if id == 0: data = Create_take_profit_order_action(o[1]) else: - raise ValueError("Unknown {}".format(self.__class__.name)) + raise ValueError("Unknown {}".format(self.__class__.__name__)) super().__init__(data, id) From 21cccc5335c33c74e14a398ab939b6a13ea38b81 Mon Sep 17 00:00:00 2001 From: pi314x <51694688+pi314x@users.noreply.github.com> Date: Sat, 18 Nov 2023 18:06:10 +0100 Subject: [PATCH 14/20] Update operations.py --- bitsharesbase/operations.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bitsharesbase/operations.py b/bitsharesbase/operations.py index c6453a5..a022c2a 100644 --- a/bitsharesbase/operations.py +++ b/bitsharesbase/operations.py @@ -1284,15 +1284,20 @@ def __init__(self, *args, **kwargs): if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] + if kwargs.get("new_price"): + new_price = Optional(Price(kwargs["new_price"])) + else: + new_price = Optional(None) + if kwargs.get("delta_amount_to_sell"): delta_amount_to_sell = Optional(Asset(kwargs["delta_amount_to_sell"])) else: delta_amount_to_sell = Optional(None) - if kwargs.get("new_price"): - new_price = Optional(Price(kwargs["new_price"])) + if kwargs.get("new_expiration"): + new_expiration = Optional(PointInTime(kwargs["new_expiration"])) else: - new_price = Optional(None) + new_expiration = Optional(None) if kwargs.get("on_fill"): on_fill = Optional(Array([LimitOrderAutoAction(o) for o in kwargs["on_fill"]])), @@ -1307,7 +1312,7 @@ def __init__(self, *args, **kwargs): ("order", ObjectId(kwargs["order"], "limit_order")), ("new_price", new_price), ("delta_amount_to_sell", delta_amount_to_sell), - ("new_expiration", Optional(None)), + ("new_expiration", new_expiration), ("on_fill", on_fill), ("extensions", Set([])), ] From 424f22295e91969a599b6ec5c2f36bbf2792068c Mon Sep 17 00:00:00 2001 From: pi314x <51694688+pi314x@users.noreply.github.com> Date: Sun, 19 Nov 2023 08:34:33 +0100 Subject: [PATCH 15/20] Update operations.py --- bitsharesbase/operations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitsharesbase/operations.py b/bitsharesbase/operations.py index a022c2a..fb45bc6 100644 --- a/bitsharesbase/operations.py +++ b/bitsharesbase/operations.py @@ -1300,7 +1300,7 @@ def __init__(self, *args, **kwargs): new_expiration = Optional(None) if kwargs.get("on_fill"): - on_fill = Optional(Array([LimitOrderAutoAction(o) for o in kwargs["on_fill"]])), + on_fill = Optional(Array([LimitOrderAutoAction(o) for o in kwargs["on_fill"]])) else: on_fill = Optional(None) From db98c224bf44650e3b4bf86add900b3427ccb759 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Mon, 20 Nov 2023 15:05:22 +0100 Subject: [PATCH 16/20] fix(tests): add tests for limit_order_update and others, add extension to limit_order_create --- bitsharesbase/objects.py | 17 +++++- bitsharesbase/operations.py | 20 ++++-- tests/test_transactions.py | 117 ++++++++++++++++++++++++++++++++++-- 3 files changed, 143 insertions(+), 11 deletions(-) diff --git a/bitsharesbase/objects.py b/bitsharesbase/objects.py index 50508da..e0d54b8 100644 --- a/bitsharesbase/objects.py +++ b/bitsharesbase/objects.py @@ -469,7 +469,10 @@ def __init__(self, *args, **kwargs): ("fee_asset_id", ObjectId(kwargs["fee_asset_id"], "asset")), ("spread_percent", Uint16(kwargs["spread_percent"])), ("size_percent", Uint16(kwargs["size_percent"])), - ("expiration_seconds", Uint32(kwargs["expiration_seconds"])), + ( + "expiration_seconds", + Uint32(kwargs["expiration_seconds"]), + ), ("repeat", Bool(kwargs["repeat"])), ("extensions", Set([])), ] @@ -482,3 +485,15 @@ def __init__(self, *args, **kwargs): else: raise ValueError("Unknown {}".format(self.__class__.__name__)) super().__init__(data, id) + + +class LimitOrderCreateExtensions(Extension): + def NestedLimitOrderAutoAction(value): + if value: + return Array([LimitOrderAutoAction(o) for o in value]) + else: + return None + + sorted_options = [ + ("on_fill", NestedLimitOrderAutoAction), + ] diff --git a/bitsharesbase/operations.py b/bitsharesbase/operations.py index fb45bc6..0c9e149 100644 --- a/bitsharesbase/operations.py +++ b/bitsharesbase/operations.py @@ -46,6 +46,7 @@ isArgsThisClass, AssertPredicate, LimitOrderAutoAction, + LimitOrderCreateExtensions, ) from .operationids import operations @@ -387,7 +388,10 @@ def __init__(self, *args, **kwargs): ("min_to_receive", Asset(kwargs["min_to_receive"])), ("expiration", PointInTime(kwargs["expiration"])), ("fill_or_kill", Bool(kwargs["fill_or_kill"])), - ("extensions", Set([])), + ( + "extensions", + LimitOrderCreateExtensions(kwargs["extensions"]), + ), ] ) ) @@ -1226,6 +1230,7 @@ def __init__(self, *args, **kwargs): ) ) + class Liquidity_pool_update(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): @@ -1240,7 +1245,9 @@ def __init__(self, *args, **kwargs): taker_fee_percent = Optional(None) if kwargs.get("withdrawal_fee_percent"): - withdrawal_fee_percent = Optional(Uint16(kwargs["withdrawal_fee_percent"])) + withdrawal_fee_percent = Optional( + Uint16(kwargs["withdrawal_fee_percent"]) + ) else: withdrawal_fee_percent = Optional(None) @@ -1257,6 +1264,7 @@ def __init__(self, *args, **kwargs): ) ) + class Credit_deal_update(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): @@ -1275,7 +1283,8 @@ def __init__(self, *args, **kwargs): ] ) ) - + + class Limit_order_update(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): @@ -1300,7 +1309,9 @@ def __init__(self, *args, **kwargs): new_expiration = Optional(None) if kwargs.get("on_fill"): - on_fill = Optional(Array([LimitOrderAutoAction(o) for o in kwargs["on_fill"]])) + on_fill = Optional( + Array([LimitOrderAutoAction(o) for o in kwargs["on_fill"]]) + ) else: on_fill = Optional(None) @@ -1319,4 +1330,5 @@ def __init__(self, *args, **kwargs): ) ) + fill_classmaps() diff --git a/tests/test_transactions.py b/tests/test_transactions.py index bdaf72b..830ce5c 100644 --- a/tests/test_transactions.py +++ b/tests/test_transactions.py @@ -83,15 +83,29 @@ def test_limit_order_create(self): "min_to_receive": {"amount": 10000, "asset_id": "1.3.105"}, "expiration": "2016-05-18T09:22:05", "fill_or_kill": False, - "extensions": [], + "extensions": { + "on_fill": [ + [ + 0, + { + "fee_asset_id": "1.3.0", + "spread_percent": 100, + "size_percent": 1000, + "expiration_seconds": 3600, + "repeat": True, + "extensions": [], + }, + ] + ] + }, } ) self.cm = ( - "f68585abf4dce7c8045701016400000000000000001da08601000" - "0000000001027000000000000693d343c57000000011f75cbfd49" - "ae8d9b04af76cc0a7de8b6e30b71167db7fe8e2197ef9d858df18" - "77043493bc24ffdaaffe592357831c978fd8a296b913979f106de" - "be940d60d77b50" + "f68585abf4dce7c8045701016400000000000000001da0860100000" + "00000001027000000000000693d343c570001000100006400e80310" + "0e0000010000011f5ddffd232fd713e106aec3068646f5a74ae145e" + "08e1e13f7464885a507e808e365594f5e7c14049d9432bcf1ca2330" + "a65d1b7ab88aa08b355970ca6f23e06aa0" ) self.doit() @@ -1045,6 +1059,97 @@ def test_assert_b(self): ) self.doit(0) + def test_limit_order_update(self): + self.op = operations.Limit_order_update( + **{ + "fee": {"amount": 0, "asset_id": "1.3.0"}, + "seller": "1.2.4", + "order": "1.7.12535", + "extensions": [], + } + ) + self.cm = ( + "f68585abf4dce7c80457014d00000000000000000004f76100" + "0000000000011f06d0b4467a5916ffb3d8ef4261c0719b1fb0" + "964aa5d3fbecbfbcbc9fe1117bc20e8a2c3f87e7817b83446c" + "45deb2a0d3d5b8b0d3b22fc8076ffc8eeb1a95e928" + ) + self.doit(0) + + self.op = operations.Limit_order_update( + **{ + "fee": {"amount": 0, "asset_id": "1.3.0"}, + "seller": "1.2.4", + "order": "1.7.12535", + "new_price": { + "base": {"amount": 1123456, "asset_id": "1.3.0"}, + "quote": {"amount": 78901122, "asset_id": "1.3.0"}, + }, + "delta_amount_to_sell": {"amount": 12562, "asset_id": "1.3.0"}, + "new_expiration": "2023-12-18T09:22:05", + "on_fill": [ + [ + 0, + { + "fee_asset_id": "1.3.0", + "spread_percent": 100, + "size_percent": 1000, + "expiration_seconds": 3600, + "repeat": True, + "extensions": [], + }, + ] + ], + "extensions": [], + } + ) + self.cm = ( + "f68585abf4dce7c80457014d00000000000000000004f76101" + "80241100000000000082efb304000000000001123100000000" + "000000013d0f8065010100006400e803100e00000100000001" + "2051a24fb550e4a8ec890ad404ea0e3cf6ea449d6ba397d280" + "64f7129153dd013e27846eb6567a88d8eea7557f32ddc02cdc" + "a614c5a30130c83141c4050ffc50e2" + ) + self.doit() + + def test_liquidity_pool_update(self): + self.op = operations.Liquidity_pool_update( + **{ + "fee": {"amount": 0, "asset_id": "1.3.0"}, + "account": "1.2.4", + "pool": "1.19.13356", + "taker_fee_percent": 124, + "withdrawal_fee_percent": 125, + "extensions": [], + } + ) + self.cm = ( + "f68585abf4dce7c80457014b00000000000000000004ac6801" + "7c00017d00000001202e3f140515ce936020348f845a4c034b" + "164441049dfe0a59a6c0fe27cbef740c10fa0d315e14e77e62" + "d8dae4f45d95fef358ff79f5304a420d6fc13abfd9374b" + ) + self.doit(0) + + def test_credit_deal_update(self): + self.op = operations.Credit_deal_update( + **{ + "fee": {"amount": 0, "asset_id": "1.3.0"}, + "account": "1.2.4", + "deal_id": "1.22.2356", + "auto_repay": 24, + "extensions": [], + } + ) + self.cm = ( + "f68585abf4dce7c80457014c00000000000000000004b41218" + "0000012026b59b7796cb9ca40d92b1d339558a94aa9f70d2f6" + "d8a7b8b0155c943b89bd602a1ecc9df3143664f801f401a728" + "78cce9f064dbcfc1af65826ce68a2177a38d" + ) + self.doit() + def compareConstructedTX(self): self.maxDiff = None self.op = operations.Call_order_update( From 41addc7429ebeb55d181ec00d1a5365bc5c28d0b Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Mon, 20 Nov 2023 15:27:14 +0100 Subject: [PATCH 17/20] fix: tailing whitespace breaks lint --- bitsharesbase/operationids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitsharesbase/operationids.py b/bitsharesbase/operationids.py index 18299b3..0d72e80 100644 --- a/bitsharesbase/operationids.py +++ b/bitsharesbase/operationids.py @@ -75,7 +75,7 @@ "credit_offer_update", "credit_offer_accept", "credit_deal_repay", - "credit_deal_expired", + "credit_deal_expired", "liquidity_pool_update", "credit_deal_update", "limit_order_update", From 87ace0f962f5aec4d4f182becb2bf91a9b1cc866 Mon Sep 17 00:00:00 2001 From: Fabian Schuh Date: Thu, 7 Dec 2023 11:36:58 +0100 Subject: [PATCH 18/20] 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( From b7576b3b24e20c4ccb4d589c6f2fbbd65b83e045 Mon Sep 17 00:00:00 2001 From: Abit Date: Wed, 19 Feb 2025 16:43:27 +0100 Subject: [PATCH 19/20] Update links in FAQ --- docs/faq.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index abbee9d..db416ab 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -27,10 +27,10 @@ Note: this way has limitation: public nodes doesn't store full account history, only limited number of entries * By querying `elasticsearch plugin - `_. + `_. In short, elasticsearch plugin export account history data into elasticsearch instance, from which it's can be obtained directly or via elasticsearch - wrapper. See ``_ to get info on how + wrapper. See ``_ to get info on how to query the wrapper. A real-world example of elasticsearch wrapper usage for obtaining filled orders history is `bitshares-tradehistory-analyzer `_ From b195184009ec30e748d8f200de2b21401d737a6e Mon Sep 17 00:00:00 2001 From: squiddible <63127872+squidKid-deluxe@users.noreply.github.com> Date: Wed, 18 Jun 2025 16:47:55 -0400 Subject: [PATCH 20/20] Fix: Avoid .get for checking falsy objects --- bitsharesbase/operations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitsharesbase/operations.py b/bitsharesbase/operations.py index 0c9e149..1ef7735 100644 --- a/bitsharesbase/operations.py +++ b/bitsharesbase/operations.py @@ -1239,12 +1239,12 @@ def __init__(self, *args, **kwargs): if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] - if kwargs.get("taker_fee_percent"): + if "taker_fee_percent" in kwargs: taker_fee_percent = Optional(Uint16(kwargs["taker_fee_percent"])) else: taker_fee_percent = Optional(None) - if kwargs.get("withdrawal_fee_percent"): + if "withdrawal_fee_percent" in kwargs: withdrawal_fee_percent = Optional( Uint16(kwargs["withdrawal_fee_percent"]) )