# Path: python3-src/graphenebase/chains.py

# 
# Path: python3-src/graphenebase/objecttypes.py

# 
# Path: python3-src/graphenebase/account.py
# class PublicKey(Address):
#     """ This class deals with Public Keys and inherits ``Address``.
# 
#         :param str pk: Base58 encoded public key
#         :param str prefix: Network prefix (defaults to ``GPH``)
# 
#         Example:::
# 
#            PublicKey("GPH6UtYWWs3rkZGV8JA86qrgkG6tyFksgECefKE1MiH4HkLD8PFGL")
# 
#         .. note:: By default, graphene-based networks deal with **compressed**
#                   public keys. If an **uncompressed** key is required, the
#                   method ``unCompressed`` can be used::
# 
#                       PublicKey("xxxxx").unCompressed()
# 
#     """
#     def __init__(self, pk, prefix="GPH"):
#         self.prefix = prefix
#         self._pk = Base58(pk, prefix=prefix)
#         self.address = Address(pubkey=pk, prefix=prefix)
#         self.pubkey = self._pk
# 
#     def _derive_y_from_x(self, x, is_even):
#         """ Derive y point from x point """
#         curve = ecdsa.SECP256k1.curve
#         # The curve equation over F_p is:
#         #   y^2 = x^3 + ax + b
#         a, b, p = curve.a(), curve.b(), curve.p()
#         alpha = (pow(x, 3, p) + a * x + b) % p
#         beta = ecdsa.numbertheory.square_root_mod_prime(alpha, p)
#         if (beta % 2) == is_even:
#             beta = p - beta
#         return beta
# 
#     def compressed(self):
#         """ Derive compressed public key """
#         order = ecdsa.SECP256k1.generator.order()
#         p = ecdsa.VerifyingKey.from_string(bytes(self), curve=ecdsa.SECP256k1).pubkey.point
#         x_str = ecdsa.util.number_to_string(p.x(), order)
#         # y_str = ecdsa.util.number_to_string(p.y(), order)
#         compressed = hexlify(bytes(chr(2 + (p.y() & 1)), 'ascii') + x_str).decode('ascii')
#         return(compressed)
# 
#     def unCompressed(self):
#         """ Derive uncompressed key """
#         public_key = repr(self._pk)
#         prefix = public_key[0:2]
#         if prefix == "04":
#             return public_key
#         assert prefix == "02" or prefix == "03"
#         x = int(public_key[2:], 16)
#         y = self._derive_y_from_x(x, (prefix == "02"))
#         key = '04' + '%064x' % x + '%064x' % y
#         return key
# 
#     def point(self):
#         """ Return the point for the public key """
#         string = unhexlify(self.unCompressed())
#         return ecdsa.VerifyingKey.from_string(string[1:], curve=ecdsa.SECP256k1).pubkey.point
# 
#     def __repr__(self):
#         """ Gives the hex representation of the Graphene public key. """
#         return repr(self._pk)
# 
#     def __str__(self):
#         """ Returns the readable Graphene public key. This call is equivalent to
#             ``format(PublicKey, "GPH")``
#         """
#         return format(self._pk, self.prefix)
# 
#     def __format__(self, _format):
#         """ Formats the instance of:doc:`Base58 <base58>` according to ``_format`` """
#         return format(self._pk, _format)
# 
#     def __bytes__(self):
#         """ Returns the raw public key (has length 33)"""
#         return bytes(self._pk)
# 
# Path: python3-src/graphenebase/chains.py

# 
# Path: python3-src/graphenebase/operationids.py



from collections import OrderedDict
from graphenebase.types import (
    Uint8, Int16, Uint16, Uint32, Uint64,
    Varint32, Int64, String, Bytes, Void,
    Array, PointInTime, Signature, Bool,
    Set, Fixed_array, Optional, Static_variant,
    Map, Id, VoteId, ObjectId,
    JsonObj
)
from .chains import known_chains
from .objecttypes import object_type
from .account import PublicKey
from .chains import default_prefix
from .operationids import operations
import json


class Operation():
    def __init__(self, op):
        if isinstance(op, list) and len(op) == 2:
            if isinstance(op[0], int):
                self.opId = op[0]
                name = self.getOperationNameForId(self.opId)
            else:

# Path: python3-src/graphenebase/chains.py

# 
# Path: python3-src/graphenebase/objecttypes.py

# 
# Path: python3-src/graphenebase/account.py
# class PublicKey(Address):
#     """ This class deals with Public Keys and inherits ``Address``.
# 
#         :param str pk: Base58 encoded public key
#         :param str prefix: Network prefix (defaults to ``GPH``)
# 
#         Example:::
# 
#            PublicKey("GPH6UtYWWs3rkZGV8JA86qrgkG6tyFksgECefKE1MiH4HkLD8PFGL")
# 
#         .. note:: By default, graphene-based networks deal with **compressed**
#                   public keys. If an **uncompressed** key is required, the
#                   method ``unCompressed`` can be used::
# 
#                       PublicKey("xxxxx").unCompressed()
# 
#     """
#     def __init__(self, pk, prefix="GPH"):
#         self.prefix = prefix
#         self._pk = Base58(pk, prefix=prefix)
#         self.address = Address(pubkey=pk, prefix=prefix)
#         self.pubkey = self._pk
# 
#     def _derive_y_from_x(self, x, is_even):
#         """ Derive y point from x point """
#         curve = ecdsa.SECP256k1.curve
#         # The curve equation over F_p is:
#         #   y^2 = x^3 + ax + b
#         a, b, p = curve.a(), curve.b(), curve.p()
#         alpha = (pow(x, 3, p) + a * x + b) % p
#         beta = ecdsa.numbertheory.square_root_mod_prime(alpha, p)
#         if (beta % 2) == is_even:
#             beta = p - beta
#         return beta
# 
#     def compressed(self):
#         """ Derive compressed public key """
#         order = ecdsa.SECP256k1.generator.order()
#         p = ecdsa.VerifyingKey.from_string(bytes(self), curve=ecdsa.SECP256k1).pubkey.point
#         x_str = ecdsa.util.number_to_string(p.x(), order)
#         # y_str = ecdsa.util.number_to_string(p.y(), order)
#         compressed = hexlify(bytes(chr(2 + (p.y() & 1)), 'ascii') + x_str).decode('ascii')
#         return(compressed)
# 
#     def unCompressed(self):
#         """ Derive uncompressed key """
#         public_key = repr(self._pk)
#         prefix = public_key[0:2]
#         if prefix == "04":
#             return public_key
#         assert prefix == "02" or prefix == "03"
#         x = int(public_key[2:], 16)
#         y = self._derive_y_from_x(x, (prefix == "02"))
#         key = '04' + '%064x' % x + '%064x' % y
#         return key
# 
#     def point(self):
#         """ Return the point for the public key """
#         string = unhexlify(self.unCompressed())
#         return ecdsa.VerifyingKey.from_string(string[1:], curve=ecdsa.SECP256k1).pubkey.point
# 
#     def __repr__(self):
#         """ Gives the hex representation of the Graphene public key. """
#         return repr(self._pk)
# 
#     def __str__(self):
#         """ Returns the readable Graphene public key. This call is equivalent to
#             ``format(PublicKey, "GPH")``
#         """
#         return format(self._pk, self.prefix)
# 
#     def __format__(self, _format):
#         """ Formats the instance of:doc:`Base58 <base58>` according to ``_format`` """
#         return format(self._pk, _format)
# 
#     def __bytes__(self):
#         """ Returns the raw public key (has length 33)"""
#         return bytes(self._pk)
# 
# Path: python3-src/graphenebase/chains.py

# 
# Path: python3-src/graphenebase/operationids.py



# Path: python3-src/graphenebase/objects.py
from collections import OrderedDict
from graphenebase.types import (
    Uint8, Int16, Uint16, Uint32, Uint64,
    Varint32, Int64, String, Bytes, Void,
    Array, PointInTime, Signature, Bool,
    Set, Fixed_array, Optional, Static_variant,
    Map, Id, VoteId, ObjectId,
    JsonObj
)
from .chains import known_chains
from .objecttypes import object_type
from .account import PublicKey
from .chains import default_prefix
from .operationids import operations
import json



class Operation():
    def __init__(self, op):
        if isinstance(op, list) and len(op) == 2:
            if isinstance(op[0], int):
                self.opId = op[0]
                name = self.getOperationNameForId(self.opId)
            else:

                self.opId = self.operations().get(op[0], None)