Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ECHOT-77] Up library patch version >> 0.1.50: update CommitteeMemberUpdateGlobalParameters operation #2

Merged
merged 2 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions echopy/echobase/feetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ def __init__(self, *args, **kwargs):
]
)
)

class Erc20RegisterToken(EchoObject):
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", Uint64(kwargs["fee"])),
("pool_fee", Uint64(kwargs["pool_fee"])),
]
)
)

ops = {
operations["transfer"]: DefaultFee,
operations["transfer_to_address"]: DefaultFee,
Expand Down Expand Up @@ -142,14 +159,14 @@ def __init__(self, *args, **kwargs):
operations["sidechain_eth_deposit"]: DefaultFee,
operations["sidechain_eth_withdraw"]: DefaultFee,
operations["sidechain_eth_approve_withdraw"]: DefaultFee,
operations["sidechain_issue"]: NoFee,
operations["sidechain_burn"]: NoFee,
operations["sidechain_erc20_register_token"]: DefaultFee,
operations["sidechain_issue"]: DefaultFee,
operations["sidechain_burn"]: DefaultFee,
operations["sidechain_erc20_register_token"]: Erc20RegisterToken,
operations["sidechain_erc20_deposit_token"]: DefaultFee,
operations["sidechain_erc20_withdraw_token"]: DefaultFee,
operations["sidechain_erc20_approve_token_withdraw"]: DefaultFee,
operations["sidechain_erc20_issue"]: NoFee,
operations["sidechain_erc20_burn"]: NoFee,
operations["sidechain_erc20_issue"]: DefaultFee,
operations["sidechain_erc20_burn"]: DefaultFee,
operations["sidechain_btc_create_address"]: DefaultFee,
operations["sidechain_btc_create_intermediate_deposit"]: DefaultFee,
operations["sidechain_btc_intermediate_deposit"]: DefaultFee,
Expand Down
26 changes: 2 additions & 24 deletions echopy/echobase/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,6 @@ class ObjectId(ObjectIdParent):
object_types = object_type


class Memo(EchoObject):
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 "message" in kwargs and kwargs["message"]:
super().__init__(
OrderedDict(
[
("from", PublicKey(kwargs["from"], prefix='ECHO')),
("to", PublicKey(kwargs["to"], prefix='ECHO')),
("nonce", Uint64(int(kwargs["nonce"]))),
("message", Bytes(kwargs["message"])),
]
)
)
else:
super().__init__(None)


class Price(EchoObject):
def __init__(self, *args, **kwargs):
if isArgsThisClass(self, args):
Expand Down Expand Up @@ -469,14 +447,14 @@ def __init__(self, *args, **kwargs):
super().__init__(
OrderedDict(
[
("eth_contract_address", Bytes(kwargs["eth_contract_address"], 20)),
("eth_contract_address", Bytes(kwargs["eth_contract_address"])),
("eth_committee_update_method", EthMethod(kwargs["eth_committee_update_method"])),
("eth_gen_address_method", EthMethod(kwargs["eth_gen_address_method"])),
("eth_withdraw_method", EthMethod(kwargs["eth_withdraw_method"])),
("eth_update_addr_method", EthMethod(kwargs["eth_update_addr_method"])),
("eth_withdraw_token_method", EthMethod(kwargs["eth_withdraw_token_method"])),
("eth_collect_tokens_method", EthMethod(kwargs["eth_collect_tokens_method"])),
("eth_committee_updated_topic", Bytes(kwargs["eth_committee_updated_topic"])),
("eth_committee_updated_topic", Bytes(kwargs["eth_committee_updated_topic"], 32)),
("eth_gen_address_topic", Bytes(kwargs["eth_gen_address_topic"], 32)),
("eth_deposit_topic", Bytes(kwargs["eth_deposit_topic"], 32)),
("eth_withdraw_topic", Bytes(kwargs["eth_withdraw_topic"], 32)),
Expand Down
199 changes: 8 additions & 191 deletions echopy/echobase/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def detail(self, *args, **kwargs):
result = OrderedDict(
[
("from", ObjectId(kwargs["from"], "account")),
("to", Bytes(kwargs["to"])),
("to", Bytes(kwargs["to"], 20)),
("amount", Asset(kwargs["amount"])),
("extensions", Set([])),

Expand Down Expand Up @@ -412,8 +412,8 @@ def detail(self, *args, **kwargs):
[
("committee_member_account", ObjectId(kwargs["committee_member_account"], "account")),
("url", String(kwargs["url"])),
("eth_address", Bytes(kwargs["eth_address"], 20)),
("btc_public_key", Bytes(kwargs["btc_public_key"])),
("eth_address", Bytes(kwargs["eth_address"])),
("btc_public_key", Bytes(kwargs["btc_public_key"], 33)),
("deposit", Asset(kwargs["deposit"])),
("extensions", Set([])),
]
Expand All @@ -426,8 +426,8 @@ def detail(self, *args, **kwargs):
class CommitteeMemberUpdate(EchoObject):
def detail(self, *args, **kwargs):
new_url = get_optional("new_url", kwargs, String)
new_eth_address = get_optional("new_eth_address", kwargs, partial(Bytes, length=20))
new_btc_public_key = get_optional("new_btc_public_key", kwargs, Bytes)
new_eth_address = get_optional("new_eth_address", kwargs, partial(Bytes))
new_btc_public_key = get_optional("new_btc_public_key", kwargs, partial(Bytes, length=33))

result = OrderedDict(
[
Expand Down Expand Up @@ -687,45 +687,12 @@ def detail(self, *args, **kwargs):
return result


class SidechainEthApproveAddress(EchoObject):
def detail(self, *args, **kwargs):
result = OrderedDict(
[
("committee_member_id", ObjectId(kwargs["committee_member_id"], "account")),
("malicious_committeemen", Set(
[ObjectId(i, "account") for i in kwargs["malicious_committeemen"]])),
("account", ObjectId(kwargs["account"], "account")),
("eth_addr", Bytes(kwargs["eth_addr"], 20)),
("extensions", Set([])),
]
)
self.add_fee(result, kwargs)

return result


class SidechainEthDeposit(EchoObject):
def detail(self, *args, **kwargs):
result = OrderedDict(
[
("committee_member_id", ObjectId(kwargs["committee_member_id"], "account")),
("deposit_id", Uint64(kwargs["deposit_id"])),
("account", ObjectId(kwargs["account"], "account")),
("value", Uint64(kwargs["value"])),
("extensions", Set([])),
]
)
self.add_fee(result, kwargs)

return result


class SidechainEthWithdraw(EchoObject):
def detail(self, *args, **kwargs):
result = OrderedDict(
[
("account", ObjectId(kwargs["account"], "account")),
("eth_addr", Bytes(kwargs["eth_addr"], 20)),
("eth_addr", Bytes(kwargs["eth_addr"])),
("value", Uint64(kwargs["value"])),
("extensions", Set([])),
]
Expand All @@ -735,27 +702,13 @@ def detail(self, *args, **kwargs):
return result


class SidechainEthApproveWithdraw(EchoObject):
def detail(self, *args, **kwargs):
result = OrderedDict(
[
("committee_member_id", ObjectId(kwargs["committee_member_id"], "account")),
("withdraw_id", Uint64(kwargs["account"])),
("extensions", Set([])),
]
)
self.add_fee(result, kwargs)

return result


# Sidechain (ERC20)
class SidechainErc20RegisterToken(EchoObject):
def detail(self, *args, **kwargs):
result = OrderedDict(
[
("account", ObjectId(kwargs["account"], "account")),
("eth_addr", Bytes(kwargs["eth_addr"], 20)),
("eth_addr", Bytes(kwargs["eth_addr"])),
("name", String(kwargs["name"])),
("symbol", String(kwargs["symbol"])),
("decimals", Uint8(kwargs["decimals"])),
Expand All @@ -768,32 +721,12 @@ def detail(self, *args, **kwargs):
return result


class SidechainErc20DepositToken(EchoObject):
def detail(self, *args, **kwargs):
result = OrderedDict(
[
("committee_member_id", ObjectId(kwargs["committee_member_id"], "account")),
("malicious_committeemen", Set(
[ObjectId(i, "account") for i in kwargs["malicious_committeemen"]])),
("account", ObjectId(kwargs["account"], "account")),
("eth_addr", Bytes(kwargs["eth_addr"], 20)),
("value", String(kwargs["value"])),
("transaction_hash", Bytes(kwargs["transaction_hash"], 32)),
("extensions", Set([])),

]
)
self.add_fee(result, kwargs)

return result


class SidechainErc20WithdrawToken(EchoObject):
def detail(self, *args, **kwargs):
result = OrderedDict(
[
("account", ObjectId(kwargs["account"], "account")),
("to", Bytes(kwargs["to"], 20)),
("to", Bytes(kwargs["to"])),
("erc20_token", ObjectId(kwargs["erc20_token"], "erc20_token")),
("value", String(kwargs["value"])),
("extensions", Set([])),
Expand All @@ -804,21 +737,6 @@ def detail(self, *args, **kwargs):
return result


class SidechainErc20ApproveTokenWithdraw(EchoObject):
def detail(self, *args, **kwargs):
result = OrderedDict(
[
("committee_member_id", ObjectId(kwargs["committee_member_id"], "account")),
("withdraw_id", Uint64(kwargs["withdraw_id"])),
("extensions", Set([])),

]
)
self.add_fee(result, kwargs)

return result


# Sidechain (Bitcoin)
class SidechainBtcCreateAddress(EchoObject):
def detail(self, *args, **kwargs):
Expand All @@ -833,58 +751,6 @@ def detail(self, *args, **kwargs):
return result


class SidechainBtcCreateIntermediateDeposit(EchoObject):
def detail(self, *args, **kwargs):
result = OrderedDict(
[
("committee_member_id", ObjectId(kwargs["committee_member_id"], "account")),
("account", ObjectId(kwargs["account"], "account")),
("btc_address_id", ObjectId(kwargs["btc_address_id"], "btc_address")),
("tx_info", BtcTransactionDetails(kwargs["tx_info"])),
("extensions", Set([])),
]
)
self.add_fee(result, kwargs)

return result


class SidechainBtcIntermediateDeposit(EchoObject):
def detail(self, *args, **kwargs):
result = OrderedDict(
[
("committee_member_id", ObjectId(kwargs["committee_member_id"], "account")),
("intermediate_address_id", ObjectId(
kwargs["intermediate_address_id"],
"btc_intermediate_deposit"
)),
("signature", String(kwargs["signature"])),
("extensions", Set([])),
]
)
self.add_fee(result, kwargs)

return result


class SidechainBtcDeposit(EchoObject):
def detail(self, *args, **kwargs):
result = OrderedDict(
[
("committee_member_id", ObjectId(kwargs["committee_member_id"], "account")),
("account", ObjectId(kwargs["account"], "account")),
("intermediate_deposit_id", ObjectId(
kwargs["intermediate_deposit_id"],
"btc_intermediate_deposit"
)),
("tx_info", BtcTransactionDetails(kwargs["tx_info"])),
]
)
self.add_fee(result, kwargs)

return result


class SidechainBtcWithdraw(EchoObject):
def detail(self, *args, **kwargs):
result = OrderedDict(
Expand All @@ -900,53 +766,4 @@ def detail(self, *args, **kwargs):
return result


class SidechainBtcAggregate(EchoObject):
def detail(self, *args, **kwargs):
previous_aggregation = get_optional(
"previous_aggregation",
kwargs,
partial(ObjectId, type_verify="btc_aggregating")
)
result = OrderedDict(
[
("committee_member_id", ObjectId(kwargs["committee_member_id"], "account")),
("deposits", Set(
[ObjectId(i, "btc_deposit") for i in kwargs["deposits"]]
)),
("withdrawals", Set(
[ObjectId(i, "btc_withdraw") for i in kwargs["withdrawals"]]
)),
("transaction_id", Bytes(kwargs["transaction_id"], 32)),
("sma_address", P2shP2wsh(kwargs["sma_address"])),
("committee_member_ids_in_script", Set(
[ObjectId(i, "account") for i in kwargs["committee_member_ids_in_script"]]
)),
("aggregation_out_value", Uint64(kwargs["aggregation_out_value"])),
("previous_aggregation", Optional(previous_aggregation)),
("cpfp_depth", Uint8(kwargs["cpfp_depth"])),
("signatures", Map(
[[Uint32(i[0]), String(i[1])] for i in kwargs["signatures"]]
)),
("extensions", Set([])),
]
)
self.add_fee(result, kwargs)

return result


class SidechainBtcApproveAggregate(EchoObject):
def detail(self, *args, **kwargs):
result = OrderedDict(
[
("committee_member_id", ObjectId(kwargs["committee_member_id"], "account")),
("transaction_id", Bytes(kwargs["transaction_id"], 32)),
("extensions", Set([])),
]
)
self.add_fee(result, kwargs)

return result


fill_classmaps()
2 changes: 1 addition & 1 deletion echopy/echobase/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __init__(self, d, length=None):

def __bytes__(self):
d = unhexlify(bytes(self.data, "utf-8"))
return varint(self.length) + d if self.length is not None else d
return varint(len(d)) + d if self.length is None else d

def __str__(self):
return str(self.data)
Expand Down
2 changes: 1 addition & 1 deletion echopy/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def detail(self, *args, **kwargs):
("expiration", PointInTime(kwargs['expiration'])),
("operations", Array([StaticVariant(op_id, op) for op_id, op in kwargs['operations']])),
("extensions", Set([])),
("signatures", Array([Bytes(signature) for signature in kwargs['signatures']])),
("signatures", Array([Bytes(signature, 64) for signature in kwargs['signatures']])),
]
)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from setuptools import setup, find_packages

VERSION = "0.1.49"
VERSION = "0.1.50"
packages = find_packages()
packages.remove('test')

Expand Down