Skip to content

Commit

Permalink
[operation] allow to create a new committee member with pybitshares
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Feb 20, 2018
1 parent 7dba22e commit 8a556c0
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 11 deletions.
28 changes: 27 additions & 1 deletion bitshares/bitshares.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ def create_worker(
account=None,
**kwargs
):
""" Reserve/Burn an amount of this shares
""" Create a worker
This removes the shares from the supply
Expand Down Expand Up @@ -1403,3 +1403,29 @@ def fund_fee_pool(self, symbol, amount, account=None, **kwargs):
"extensions": []
})
return self.finalizeOp(op, account, "active", **kwargs)

def create_committee_member(
self,
url="",
account=None,
**kwargs
):
""" Create a committee member
:param str url: URL to read more about the worker
:param str account: (optional) the account to allow access
to (defaults to ``default_account``)
"""
if not account:
if "default_account" in config:
account = config["default_account"]
if not account:
raise ValueError("You need to provide an account")
account = Account(account, bitshares_instance=self)

op = operations.Committee_member_create(**{
"fee": {"amount": 0, "asset_id": "1.3.0"},
"committee_member_account": account["id"],
"url": url
})
return self.finalizeOp(op, account, "active", **kwargs)
14 changes: 14 additions & 0 deletions bitsharesbase/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,3 +548,17 @@ def __init__(self, *args, **kwargs):
('periods_until_expiration', Uint32(kwargs["periods_until_expiration"])),
('period_start_time', PointInTime(kwargs["period_start_time"])),
]))


class Committee_member_create(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"])),
('committee_member_account', ObjectId(kwargs["committee_member_account"], "account")),
('url', String(kwargs["url"])),
]))
28 changes: 18 additions & 10 deletions tests/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,22 +641,30 @@ def test_withdraw_permission_create(self):
"b3324dddbac1b7617de3f0")
self.doit()

def compareConstructedTX(self):
self.maxDiff = None
self.op = operations.Withdraw_permission_create(**{
def test_committee_create(self):
self.op = operations.Committee_member_create(**{
"fee": {
"amount": 0,
"asset_id": "1.3.0"
},
"withdraw_from_account": "1.2.0",
"authorized_account": "1.2.0",
"withdrawal_limit": {
"amount": 35634,
"committee_member_account": "1.2.0",
"url": "foobar"
})
self.cm = ("f68585abf4dce7c80457011d0000000000000000000006666f"
"6f62617200011f26ced69cf1c79c7cd5be14092b15c9bd07f2"
"a1ea988ac3dff2e8e706d72461b21bef9a8eda4c51b5d484f7"
"8d31567ef7066d105bcd75c215f8d919673ea57c32")
self.doit()

def compareConstructedTX(self):
self.maxDiff = None
self.op = operations.Committee_member_create(**{
"fee": {
"amount": 0,
"asset_id": "1.3.0"
},
"withdrawal_period_sec": 53454,
"periods_until_expiration": 65435354,
"period_start_time": "1970-01-01T00:00:00"
"committee_member_account": "1.2.0",
"url": "foobar"
})
ops = [Operation(self.op)]
tx = Signed_Transaction(
Expand Down

0 comments on commit 8a556c0

Please sign in to comment.