Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
roshansyed committed Aug 14, 2020
2 parents 88ffd83 + 7898f31 commit 3b49686
Show file tree
Hide file tree
Showing 15 changed files with 463 additions and 8 deletions.
11 changes: 11 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
stages:
- test

test:
stage: test
script:
- apt-get update -qy
- apt-get install -y python3-dev python3-pip
- pip3 install -r requirements.txt
- pip3 install -r requirements-test.txt
- python3 -m unittest tests/test_hrp.py
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ This is a communications library which allows interface with the Peerplays block

## Installation

The python-peerplays library has following dependencies
python3-dev
build-essential
libssl-dev
libffi-dev
libxml2-dev
libxslt1-dev
zlib1g-dev

Make sure that the above dependencies are installed, if not install with:

$ sudo apt-get install <dependency name>

Install with `pip3`:

$ pip3 install peerplays
Empty file added __init__.py
Empty file.
148 changes: 148 additions & 0 deletions peerplays/peerplays.py
Original file line number Diff line number Diff line change
Expand Up @@ -1554,3 +1554,151 @@ def bet_cancel(self, bet_to_cancel, account=None, **kwargs):
}
)
return self.finalizeOp(op, account["name"], "active", **kwargs)

# -------------------------------------------------------------------------
# HRP methods
# -------------------------------------------------------------------------
def custom_permission_create(
self,
permission_name,
owner_account=None,
weight_threshold=[],
account_auths=[],
key_auths=[],
address_auths=[],
**kwargs
):

#accounts_authority = [["1.2.30", 2]]

owner_account = Account(owner_account, blockchain_instance=self)

op = {
"fee": {"amount": 0, "asset_id": "1.3.0"},
"owner_account": owner_account["id"],
"permission_name": permission_name,
"auth": {
"account_auths": account_auths,
"key_auths": key_auths,
"address_auths": address_auths,
"weight_threshold": weight_threshold,
},
"prefix": self.prefix,
}
op = operations.Custom_permission_create(**op)
return self.finalizeOp(op, owner_account, "active", **kwargs)

def custom_permission_update(
self,
permission_id,
owner_account=None,
weight_threshold=[],
account_auths=[],
key_auths=[],
address_auths=[],
**kwargs
):

#accounts_authority = [["1.2.30", 2]]

owner_account = Account(owner_account, blockchain_instance=self)

op = {
"fee": {"amount": 0, "asset_id": "1.3.0"},
"owner_account": owner_account["id"],
"permission_id": permission_id,
"new_auth": {
"account_auths": account_auths,
"key_auths": key_auths,
"address_auths": address_auths,
"weight_threshold": weight_threshold,
},
"prefix": self.prefix,
}
op = operations.Custom_permission_update(**op)
return self.finalizeOp(op, owner_account, "active", **kwargs)

def custom_permission_delete(
self,
permission_id,
owner_account=None,
**kwargs
):

owner_account = Account(owner_account, blockchain_instance=self)

op = {
"fee": {"amount": 0, "asset_id": "1.3.0"},
"owner_account": owner_account["id"],
"permission_id": permission_id,
"prefix": self.prefix,
}
op = operations.Custom_permission_delete(**op)
# print('op:', op)
return self.finalizeOp(op, owner_account, "active", **kwargs)

def custom_account_authority_create(
self,
permission_id,
operation_type,
valid_from,
valid_to,
owner_account=None,
**kwargs
):

#accounts_authority = [["1.2.30", 2]]

owner_account = Account(owner_account, blockchain_instance=self)

op = {
"fee": {"amount": 0, "asset_id": "1.3.0"},
"permission_id": permission_id,
"operation_type": operation_type,
"valid_from": valid_from,
"valid_to": valid_to,
"owner_account": owner_account["id"],
"prefix": self.prefix,
}
op = operations.Custom_account_authority_create(**op)
return self.finalizeOp(op, owner_account, "active", **kwargs)

def custom_account_authority_update(
self,
auth_id,
new_valid_from,
new_valid_to,
owner_account=None,
**kwargs
):

owner_account = Account(owner_account, blockchain_instance=self)

op = {
"fee": {"amount": 0, "asset_id": "1.3.0"},
"auth_id": auth_id,
"new_valid_from": new_valid_from,
"new_valid_to": new_valid_to,
"owner_account": owner_account["id"],
"prefix": self.prefix,
}
op = operations.Custom_account_authority_update(**op)
return self.finalizeOp(op, owner_account, "active", **kwargs)

def custom_account_authority_delete(
self,
auth_id,
owner_account=None,
**kwargs
):

owner_account = Account(owner_account, blockchain_instance=self)

op = {
"fee": {"amount": 0, "asset_id": "1.3.0"},
"auth_id": auth_id,
"owner_account": owner_account["id"],
"prefix": self.prefix,
}
op = operations.Custom_account_authority_delete(**op)
return self.finalizeOp(op, owner_account, "active", **kwargs)
5 changes: 4 additions & 1 deletion peerplaysbase/chains.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@
"prefix": "TEST",
},
"FRED": {
"chain_id": "735f88594e5b7521047864f7cca7367ff27e95ce7bd40482b85c978d1337f881",
"chain_id": "ef688290dea16ee55ae83bbe30384c24a8ad06268897dd144fb3a677a88306fe",
"core_symbol": "TEST",
"prefix": "TEST",
},
}

# old fred chain_id in the code
# "chain_id": "735f88594e5b7521047864f7cca7367ff27e95ce7bd40482b85c978d1337f881",
1 change: 1 addition & 0 deletions peerplaysbase/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def __init__(self, *args, **kwargs):
("weight_threshold", Uint32(int(kwargs["weight_threshold"]))),
("account_auths", accountAuths),
("key_auths", keyAuths),
("address_auths", []),
("extensions", Set([])),
]
)
Expand Down
4 changes: 3 additions & 1 deletion peerplaysbase/objecttypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"betting_market_rules",
"betting_market_group",
"betting_market",
"bet"
"bet",
"custom_permission",
"custom_account_authority",
]

object_type = {k: ts.index(k) for k in ts}
11 changes: 11 additions & 0 deletions peerplaysbase/operationids.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@
"event_group_delete",
"affiliate_payout",
"affiliate_referral_payout",
"lottery_asset_create",
"ticket_purchase",
"lottery_reward",
"lottery_end",
"sweeps_vesting_claim",
"custom_permission_create",
"custom_permission_update",
"custom_permission_delete",
"custom_account_authority_create",
"custom_account_authority_update",
"custom_account_authority_delete",
]
operations = {o: ops.index(o) for o in ops}

Expand Down
132 changes: 132 additions & 0 deletions peerplaysbase/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1240,3 +1240,135 @@ def __init__(self, *args, **kwargs):
]
)
)


class Custom_permission_create(GrapheneObject):
def __init__(self, *args, **kwargs):
# Allow for overwrite of prefix
if isArgsThisClass(self, args):
self.data = args[0].data
else:
if len(args) == 1 and len(kwargs) == 0:
kwargs = args[0]
prefix = kwargs.get("prefix", default_prefix)

super().__init__(
OrderedDict(
[
("fee", Asset(kwargs["fee"])),
("owner_account", ObjectId(kwargs["owner_account"], "account")),
("permission_name", String(kwargs["permission_name"])),
("auth", Permission(kwargs["auth"], prefix=prefix)),
]
)
)


class Custom_permission_update(GrapheneObject):
def __init__(self, *args, **kwargs):
# Allow for overwrite of prefix
if isArgsThisClass(self, args):
self.data = args[0].data
else:
if len(args) == 1 and len(kwargs) == 0:
kwargs = args[0]
prefix = kwargs.get("prefix", default_prefix)

super().__init__(
OrderedDict(
[
("fee", Asset(kwargs["fee"])),
("permission_id", ObjectId(kwargs["permission_id"], "custom_permission")),
("new_auth", Optional(Permission(kwargs["new_auth"], prefix=prefix))),
("owner_account", ObjectId(kwargs["owner_account"], "account")),
]
)
)


class Custom_permission_delete(GrapheneObject):
def __init__(self, *args, **kwargs):
# Allow for overwrite of prefix
if isArgsThisClass(self, args):
self.data = args[0].data
else:
if len(args) == 1 and len(kwargs) == 0:
kwargs = args[0]
prefix = kwargs.get("prefix", default_prefix)
super().__init__(
OrderedDict(
[
("fee", Asset(kwargs["fee"])),
("permission_id", ObjectId(kwargs["permission_id"], "custom_permission")),
("owner_account", ObjectId(kwargs["owner_account"], "account")),
]
)
)


class Custom_account_authority_create(GrapheneObject):
def __init__(self, *args, **kwargs):
# Allow for overwrite of prefix
if isArgsThisClass(self, args):
self.data = args[0].data
else:
if len(args) == 1 and len(kwargs) == 0:
kwargs = args[0]
prefix = kwargs.get("prefix", default_prefix)

super().__init__(
OrderedDict(
[
("fee", Asset(kwargs["fee"])),
("permission_id", ObjectId(kwargs["permission_id"], "custom_permission")),
("operation_type", Uint32(kwargs["operation_type"])),
("valid_from", PointInTime(kwargs["valid_from"])),
("valid_to", PointInTime(kwargs["valid_to"])),
("owner_account", ObjectId(kwargs["owner_account"], "account")),
]
)
)


class Custom_account_authority_update(GrapheneObject):
def __init__(self, *args, **kwargs):
# Allow for overwrite of prefix
if isArgsThisClass(self, args):
self.data = args[0].data
else:
if len(args) == 1 and len(kwargs) == 0:
kwargs = args[0]
prefix = kwargs.get("prefix", default_prefix)

super().__init__(
OrderedDict(
[
("fee", Asset(kwargs["fee"])),
("auth_id", ObjectId(kwargs["auth_id"], "custom_account_authority")),
("new_valid_from", Optional(PointInTime(kwargs["new_valid_from"]))),
("new_valid_to", Optional(PointInTime(kwargs["new_valid_to"]))),
("owner_account", ObjectId(kwargs["owner_account"], "account")),
]
)
)


class Custom_account_authority_delete(GrapheneObject):
def __init__(self, *args, **kwargs):
# Allow for overwrite of prefix
if isArgsThisClass(self, args):
self.data = args[0].data
else:
if len(args) == 1 and len(kwargs) == 0:
kwargs = args[0]
prefix = kwargs.get("prefix", default_prefix)

super().__init__(
OrderedDict(
[
("fee", Asset(kwargs["fee"])),
("auth_id", ObjectId(kwargs["auth_id"], "custom_account_authority")),
("owner_account", ObjectId(kwargs["owner_account"], "account")),
]
)
)
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
scrypt==0.8.13
appdirs==1.4.3
graphenelib==1.1.18
appdirs
prettytable
events
scrypt
pyyaml

# for AES, installed through graphenelib already
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ascii = codecs.lookup("ascii")
codecs.register(lambda name, enc=ascii: {True: enc}.get(name == "mbcs"))

VERSION = "0.3.12"
VERSION = "0.4.0"

setup(
name="peerplays",
Expand Down
Loading

0 comments on commit 3b49686

Please sign in to comment.