coinex-api 0.0.15__py3-none-any.whl → 0.0.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- coinex/__init__.py +7 -0
- coinex/ccxt/__init__.py +101 -0
- coinex/ccxt/abstract/coinex.py +237 -0
- coinex/ccxt/async_support/__init__.py +80 -0
- coinex/ccxt/async_support/base/__init__.py +1 -0
- coinex/ccxt/async_support/base/exchange.py +2100 -0
- coinex/ccxt/async_support/base/throttler.py +50 -0
- coinex/ccxt/async_support/base/ws/__init__.py +38 -0
- coinex/ccxt/async_support/base/ws/aiohttp_client.py +147 -0
- coinex/ccxt/async_support/base/ws/cache.py +213 -0
- coinex/ccxt/async_support/base/ws/client.py +214 -0
- coinex/ccxt/async_support/base/ws/fast_client.py +97 -0
- coinex/ccxt/async_support/base/ws/functions.py +59 -0
- coinex/ccxt/async_support/base/ws/future.py +69 -0
- coinex/ccxt/async_support/base/ws/order_book.py +78 -0
- coinex/ccxt/async_support/base/ws/order_book_side.py +174 -0
- coinex/ccxt/async_support/coinex.py +5833 -0
- coinex/ccxt/base/__init__.py +27 -0
- coinex/ccxt/base/decimal_to_precision.py +174 -0
- coinex/ccxt/base/errors.py +267 -0
- coinex/ccxt/base/exchange.py +6769 -0
- coinex/ccxt/base/precise.py +297 -0
- coinex/ccxt/base/types.py +577 -0
- coinex/ccxt/coinex.py +5832 -0
- coinex/ccxt/pro/__init__.py +21 -0
- coinex/ccxt/pro/coinex.py +1366 -0
- coinex/ccxt/static_dependencies/README.md +1 -0
- coinex/ccxt/static_dependencies/__init__.py +1 -0
- coinex/ccxt/static_dependencies/ecdsa/__init__.py +14 -0
- coinex/ccxt/static_dependencies/ecdsa/_version.py +520 -0
- coinex/ccxt/static_dependencies/ecdsa/curves.py +56 -0
- coinex/ccxt/static_dependencies/ecdsa/der.py +221 -0
- coinex/ccxt/static_dependencies/ecdsa/ecdsa.py +310 -0
- coinex/ccxt/static_dependencies/ecdsa/ellipticcurve.py +197 -0
- coinex/ccxt/static_dependencies/ecdsa/keys.py +332 -0
- coinex/ccxt/static_dependencies/ecdsa/numbertheory.py +531 -0
- coinex/ccxt/static_dependencies/ecdsa/rfc6979.py +100 -0
- coinex/ccxt/static_dependencies/ecdsa/util.py +266 -0
- coinex/ccxt/static_dependencies/ethereum/__init__.py +7 -0
- coinex/ccxt/static_dependencies/ethereum/abi/__init__.py +16 -0
- coinex/ccxt/static_dependencies/ethereum/abi/abi.py +19 -0
- coinex/ccxt/static_dependencies/ethereum/abi/base.py +152 -0
- coinex/ccxt/static_dependencies/ethereum/abi/codec.py +217 -0
- coinex/ccxt/static_dependencies/ethereum/abi/constants.py +3 -0
- coinex/ccxt/static_dependencies/ethereum/abi/decoding.py +565 -0
- coinex/ccxt/static_dependencies/ethereum/abi/encoding.py +720 -0
- coinex/ccxt/static_dependencies/ethereum/abi/exceptions.py +139 -0
- coinex/ccxt/static_dependencies/ethereum/abi/grammar.py +443 -0
- coinex/ccxt/static_dependencies/ethereum/abi/packed.py +13 -0
- coinex/ccxt/static_dependencies/ethereum/abi/py.typed +0 -0
- coinex/ccxt/static_dependencies/ethereum/abi/registry.py +643 -0
- coinex/ccxt/static_dependencies/ethereum/abi/tools/__init__.py +3 -0
- coinex/ccxt/static_dependencies/ethereum/abi/tools/_strategies.py +230 -0
- coinex/ccxt/static_dependencies/ethereum/abi/utils/__init__.py +0 -0
- coinex/ccxt/static_dependencies/ethereum/abi/utils/numeric.py +83 -0
- coinex/ccxt/static_dependencies/ethereum/abi/utils/padding.py +27 -0
- coinex/ccxt/static_dependencies/ethereum/abi/utils/string.py +19 -0
- coinex/ccxt/static_dependencies/ethereum/account/__init__.py +3 -0
- coinex/ccxt/static_dependencies/ethereum/account/encode_typed_data/__init__.py +4 -0
- coinex/ccxt/static_dependencies/ethereum/account/encode_typed_data/encoding_and_hashing.py +239 -0
- coinex/ccxt/static_dependencies/ethereum/account/encode_typed_data/helpers.py +40 -0
- coinex/ccxt/static_dependencies/ethereum/account/messages.py +263 -0
- coinex/ccxt/static_dependencies/ethereum/account/py.typed +0 -0
- coinex/ccxt/static_dependencies/ethereum/hexbytes/__init__.py +5 -0
- coinex/ccxt/static_dependencies/ethereum/hexbytes/_utils.py +54 -0
- coinex/ccxt/static_dependencies/ethereum/hexbytes/main.py +65 -0
- coinex/ccxt/static_dependencies/ethereum/hexbytes/py.typed +0 -0
- coinex/ccxt/static_dependencies/ethereum/typing/__init__.py +63 -0
- coinex/ccxt/static_dependencies/ethereum/typing/abi.py +6 -0
- coinex/ccxt/static_dependencies/ethereum/typing/bls.py +7 -0
- coinex/ccxt/static_dependencies/ethereum/typing/discovery.py +5 -0
- coinex/ccxt/static_dependencies/ethereum/typing/encoding.py +7 -0
- coinex/ccxt/static_dependencies/ethereum/typing/enums.py +17 -0
- coinex/ccxt/static_dependencies/ethereum/typing/ethpm.py +9 -0
- coinex/ccxt/static_dependencies/ethereum/typing/evm.py +20 -0
- coinex/ccxt/static_dependencies/ethereum/typing/networks.py +1122 -0
- coinex/ccxt/static_dependencies/ethereum/typing/py.typed +0 -0
- coinex/ccxt/static_dependencies/ethereum/utils/__init__.py +115 -0
- coinex/ccxt/static_dependencies/ethereum/utils/abi.py +72 -0
- coinex/ccxt/static_dependencies/ethereum/utils/address.py +171 -0
- coinex/ccxt/static_dependencies/ethereum/utils/applicators.py +151 -0
- coinex/ccxt/static_dependencies/ethereum/utils/conversions.py +190 -0
- coinex/ccxt/static_dependencies/ethereum/utils/currency.py +107 -0
- coinex/ccxt/static_dependencies/ethereum/utils/curried/__init__.py +269 -0
- coinex/ccxt/static_dependencies/ethereum/utils/debug.py +20 -0
- coinex/ccxt/static_dependencies/ethereum/utils/decorators.py +132 -0
- coinex/ccxt/static_dependencies/ethereum/utils/encoding.py +6 -0
- coinex/ccxt/static_dependencies/ethereum/utils/exceptions.py +4 -0
- coinex/ccxt/static_dependencies/ethereum/utils/functional.py +75 -0
- coinex/ccxt/static_dependencies/ethereum/utils/hexadecimal.py +74 -0
- coinex/ccxt/static_dependencies/ethereum/utils/humanize.py +188 -0
- coinex/ccxt/static_dependencies/ethereum/utils/logging.py +159 -0
- coinex/ccxt/static_dependencies/ethereum/utils/module_loading.py +31 -0
- coinex/ccxt/static_dependencies/ethereum/utils/numeric.py +43 -0
- coinex/ccxt/static_dependencies/ethereum/utils/py.typed +0 -0
- coinex/ccxt/static_dependencies/ethereum/utils/toolz.py +76 -0
- coinex/ccxt/static_dependencies/ethereum/utils/types.py +54 -0
- coinex/ccxt/static_dependencies/ethereum/utils/typing/__init__.py +18 -0
- coinex/ccxt/static_dependencies/ethereum/utils/typing/misc.py +14 -0
- coinex/ccxt/static_dependencies/ethereum/utils/units.py +31 -0
- coinex/ccxt/static_dependencies/keccak/__init__.py +3 -0
- coinex/ccxt/static_dependencies/keccak/keccak.py +197 -0
- coinex/ccxt/static_dependencies/lark/__init__.py +38 -0
- coinex/ccxt/static_dependencies/lark/__pyinstaller/__init__.py +6 -0
- coinex/ccxt/static_dependencies/lark/__pyinstaller/hook-lark.py +14 -0
- coinex/ccxt/static_dependencies/lark/ast_utils.py +59 -0
- coinex/ccxt/static_dependencies/lark/common.py +86 -0
- coinex/ccxt/static_dependencies/lark/exceptions.py +292 -0
- coinex/ccxt/static_dependencies/lark/grammar.py +130 -0
- coinex/ccxt/static_dependencies/lark/grammars/__init__.py +0 -0
- coinex/ccxt/static_dependencies/lark/grammars/common.lark +59 -0
- coinex/ccxt/static_dependencies/lark/grammars/lark.lark +62 -0
- coinex/ccxt/static_dependencies/lark/grammars/python.lark +302 -0
- coinex/ccxt/static_dependencies/lark/grammars/unicode.lark +7 -0
- coinex/ccxt/static_dependencies/lark/indenter.py +143 -0
- coinex/ccxt/static_dependencies/lark/lark.py +658 -0
- coinex/ccxt/static_dependencies/lark/lexer.py +678 -0
- coinex/ccxt/static_dependencies/lark/load_grammar.py +1428 -0
- coinex/ccxt/static_dependencies/lark/parse_tree_builder.py +391 -0
- coinex/ccxt/static_dependencies/lark/parser_frontends.py +257 -0
- coinex/ccxt/static_dependencies/lark/parsers/__init__.py +0 -0
- coinex/ccxt/static_dependencies/lark/parsers/cyk.py +340 -0
- coinex/ccxt/static_dependencies/lark/parsers/earley.py +314 -0
- coinex/ccxt/static_dependencies/lark/parsers/earley_common.py +42 -0
- coinex/ccxt/static_dependencies/lark/parsers/earley_forest.py +801 -0
- coinex/ccxt/static_dependencies/lark/parsers/grammar_analysis.py +203 -0
- coinex/ccxt/static_dependencies/lark/parsers/lalr_analysis.py +332 -0
- coinex/ccxt/static_dependencies/lark/parsers/lalr_interactive_parser.py +158 -0
- coinex/ccxt/static_dependencies/lark/parsers/lalr_parser.py +122 -0
- coinex/ccxt/static_dependencies/lark/parsers/lalr_parser_state.py +110 -0
- coinex/ccxt/static_dependencies/lark/parsers/xearley.py +165 -0
- coinex/ccxt/static_dependencies/lark/py.typed +0 -0
- coinex/ccxt/static_dependencies/lark/reconstruct.py +107 -0
- coinex/ccxt/static_dependencies/lark/tools/__init__.py +70 -0
- coinex/ccxt/static_dependencies/lark/tools/nearley.py +202 -0
- coinex/ccxt/static_dependencies/lark/tools/serialize.py +32 -0
- coinex/ccxt/static_dependencies/lark/tools/standalone.py +196 -0
- coinex/ccxt/static_dependencies/lark/tree.py +267 -0
- coinex/ccxt/static_dependencies/lark/tree_matcher.py +186 -0
- coinex/ccxt/static_dependencies/lark/tree_templates.py +180 -0
- coinex/ccxt/static_dependencies/lark/utils.py +343 -0
- coinex/ccxt/static_dependencies/lark/visitors.py +596 -0
- coinex/ccxt/static_dependencies/marshmallow/__init__.py +81 -0
- coinex/ccxt/static_dependencies/marshmallow/base.py +65 -0
- coinex/ccxt/static_dependencies/marshmallow/class_registry.py +94 -0
- coinex/ccxt/static_dependencies/marshmallow/decorators.py +231 -0
- coinex/ccxt/static_dependencies/marshmallow/error_store.py +60 -0
- coinex/ccxt/static_dependencies/marshmallow/exceptions.py +71 -0
- coinex/ccxt/static_dependencies/marshmallow/fields.py +2114 -0
- coinex/ccxt/static_dependencies/marshmallow/orderedset.py +89 -0
- coinex/ccxt/static_dependencies/marshmallow/py.typed +0 -0
- coinex/ccxt/static_dependencies/marshmallow/schema.py +1228 -0
- coinex/ccxt/static_dependencies/marshmallow/types.py +12 -0
- coinex/ccxt/static_dependencies/marshmallow/utils.py +378 -0
- coinex/ccxt/static_dependencies/marshmallow/validate.py +678 -0
- coinex/ccxt/static_dependencies/marshmallow/warnings.py +2 -0
- coinex/ccxt/static_dependencies/marshmallow_dataclass/__init__.py +1047 -0
- coinex/ccxt/static_dependencies/marshmallow_dataclass/collection_field.py +51 -0
- coinex/ccxt/static_dependencies/marshmallow_dataclass/lazy_class_attribute.py +45 -0
- coinex/ccxt/static_dependencies/marshmallow_dataclass/mypy.py +71 -0
- coinex/ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
- coinex/ccxt/static_dependencies/marshmallow_dataclass/typing.py +14 -0
- coinex/ccxt/static_dependencies/marshmallow_dataclass/union_field.py +82 -0
- coinex/ccxt/static_dependencies/marshmallow_oneofschema/__init__.py +1 -0
- coinex/ccxt/static_dependencies/marshmallow_oneofschema/one_of_schema.py +193 -0
- coinex/ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
- coinex/ccxt/static_dependencies/msgpack/__init__.py +55 -0
- coinex/ccxt/static_dependencies/msgpack/_cmsgpack.pyx +11 -0
- coinex/ccxt/static_dependencies/msgpack/_packer.pyx +374 -0
- coinex/ccxt/static_dependencies/msgpack/_unpacker.pyx +547 -0
- coinex/ccxt/static_dependencies/msgpack/buff_converter.h +8 -0
- coinex/ccxt/static_dependencies/msgpack/exceptions.py +48 -0
- coinex/ccxt/static_dependencies/msgpack/ext.py +168 -0
- coinex/ccxt/static_dependencies/msgpack/fallback.py +951 -0
- coinex/ccxt/static_dependencies/msgpack/pack.h +89 -0
- coinex/ccxt/static_dependencies/msgpack/pack_template.h +820 -0
- coinex/ccxt/static_dependencies/msgpack/sysdep.h +194 -0
- coinex/ccxt/static_dependencies/msgpack/unpack.h +391 -0
- coinex/ccxt/static_dependencies/msgpack/unpack_define.h +95 -0
- coinex/ccxt/static_dependencies/msgpack/unpack_template.h +464 -0
- coinex/ccxt/static_dependencies/parsimonious/__init__.py +10 -0
- coinex/ccxt/static_dependencies/parsimonious/exceptions.py +105 -0
- coinex/ccxt/static_dependencies/parsimonious/expressions.py +479 -0
- coinex/ccxt/static_dependencies/parsimonious/grammar.py +487 -0
- coinex/ccxt/static_dependencies/parsimonious/nodes.py +325 -0
- coinex/ccxt/static_dependencies/parsimonious/utils.py +40 -0
- coinex/ccxt/static_dependencies/starknet/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/abi/v0/__init__.py +2 -0
- coinex/ccxt/static_dependencies/starknet/abi/v0/model.py +44 -0
- coinex/ccxt/static_dependencies/starknet/abi/v0/parser.py +216 -0
- coinex/ccxt/static_dependencies/starknet/abi/v0/schemas.py +72 -0
- coinex/ccxt/static_dependencies/starknet/abi/v0/shape.py +63 -0
- coinex/ccxt/static_dependencies/starknet/abi/v1/__init__.py +2 -0
- coinex/ccxt/static_dependencies/starknet/abi/v1/core_structures.json +14 -0
- coinex/ccxt/static_dependencies/starknet/abi/v1/model.py +39 -0
- coinex/ccxt/static_dependencies/starknet/abi/v1/parser.py +220 -0
- coinex/ccxt/static_dependencies/starknet/abi/v1/parser_transformer.py +179 -0
- coinex/ccxt/static_dependencies/starknet/abi/v1/schemas.py +66 -0
- coinex/ccxt/static_dependencies/starknet/abi/v1/shape.py +47 -0
- coinex/ccxt/static_dependencies/starknet/abi/v2/__init__.py +2 -0
- coinex/ccxt/static_dependencies/starknet/abi/v2/model.py +89 -0
- coinex/ccxt/static_dependencies/starknet/abi/v2/parser.py +293 -0
- coinex/ccxt/static_dependencies/starknet/abi/v2/parser_transformer.py +192 -0
- coinex/ccxt/static_dependencies/starknet/abi/v2/schemas.py +132 -0
- coinex/ccxt/static_dependencies/starknet/abi/v2/shape.py +107 -0
- coinex/ccxt/static_dependencies/starknet/cairo/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/cairo/data_types.py +123 -0
- coinex/ccxt/static_dependencies/starknet/cairo/deprecated_parse/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/cairo/deprecated_parse/cairo_types.py +77 -0
- coinex/ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser.py +46 -0
- coinex/ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser_transformer.py +138 -0
- coinex/ccxt/static_dependencies/starknet/cairo/felt.py +64 -0
- coinex/ccxt/static_dependencies/starknet/cairo/type_parser.py +121 -0
- coinex/ccxt/static_dependencies/starknet/cairo/v1/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/cairo/v1/type_parser.py +59 -0
- coinex/ccxt/static_dependencies/starknet/cairo/v2/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/cairo/v2/type_parser.py +77 -0
- coinex/ccxt/static_dependencies/starknet/ccxt_utils.py +7 -0
- coinex/ccxt/static_dependencies/starknet/common.py +15 -0
- coinex/ccxt/static_dependencies/starknet/constants.py +39 -0
- coinex/ccxt/static_dependencies/starknet/hash/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/hash/address.py +79 -0
- coinex/ccxt/static_dependencies/starknet/hash/compiled_class_hash_objects.py +111 -0
- coinex/ccxt/static_dependencies/starknet/hash/selector.py +16 -0
- coinex/ccxt/static_dependencies/starknet/hash/storage.py +12 -0
- coinex/ccxt/static_dependencies/starknet/hash/utils.py +78 -0
- coinex/ccxt/static_dependencies/starknet/models/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/models/typed_data.py +45 -0
- coinex/ccxt/static_dependencies/starknet/serialization/__init__.py +24 -0
- coinex/ccxt/static_dependencies/starknet/serialization/_calldata_reader.py +40 -0
- coinex/ccxt/static_dependencies/starknet/serialization/_context.py +142 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/__init__.py +10 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/_common.py +82 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/array_serializer.py +43 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/bool_serializer.py +37 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/byte_array_serializer.py +66 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/cairo_data_serializer.py +71 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/enum_serializer.py +71 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/felt_serializer.py +50 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/named_tuple_serializer.py +58 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/option_serializer.py +43 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/output_serializer.py +40 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/payload_serializer.py +72 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/struct_serializer.py +36 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/tuple_serializer.py +36 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/uint256_serializer.py +76 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/uint_serializer.py +100 -0
- coinex/ccxt/static_dependencies/starknet/serialization/data_serializers/unit_serializer.py +32 -0
- coinex/ccxt/static_dependencies/starknet/serialization/errors.py +10 -0
- coinex/ccxt/static_dependencies/starknet/serialization/factory.py +229 -0
- coinex/ccxt/static_dependencies/starknet/serialization/function_serialization_adapter.py +110 -0
- coinex/ccxt/static_dependencies/starknet/serialization/tuple_dataclass.py +59 -0
- coinex/ccxt/static_dependencies/starknet/utils/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starknet/utils/constructor_args_translator.py +86 -0
- coinex/ccxt/static_dependencies/starknet/utils/iterable.py +13 -0
- coinex/ccxt/static_dependencies/starknet/utils/schema.py +13 -0
- coinex/ccxt/static_dependencies/starknet/utils/typed_data.py +182 -0
- coinex/ccxt/static_dependencies/starkware/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starkware/crypto/__init__.py +0 -0
- coinex/ccxt/static_dependencies/starkware/crypto/fast_pedersen_hash.py +50 -0
- coinex/ccxt/static_dependencies/starkware/crypto/math_utils.py +78 -0
- coinex/ccxt/static_dependencies/starkware/crypto/signature.py +2344 -0
- coinex/ccxt/static_dependencies/starkware/crypto/utils.py +63 -0
- coinex/ccxt/static_dependencies/sympy/__init__.py +0 -0
- coinex/ccxt/static_dependencies/sympy/core/__init__.py +0 -0
- coinex/ccxt/static_dependencies/sympy/core/intfunc.py +35 -0
- coinex/ccxt/static_dependencies/sympy/external/__init__.py +0 -0
- coinex/ccxt/static_dependencies/sympy/external/gmpy.py +345 -0
- coinex/ccxt/static_dependencies/sympy/external/importtools.py +187 -0
- coinex/ccxt/static_dependencies/sympy/external/ntheory.py +637 -0
- coinex/ccxt/static_dependencies/sympy/external/pythonmpq.py +341 -0
- coinex/ccxt/static_dependencies/toolz/__init__.py +26 -0
- coinex/ccxt/static_dependencies/toolz/_signatures.py +784 -0
- coinex/ccxt/static_dependencies/toolz/_version.py +520 -0
- coinex/ccxt/static_dependencies/toolz/compatibility.py +30 -0
- coinex/ccxt/static_dependencies/toolz/curried/__init__.py +101 -0
- coinex/ccxt/static_dependencies/toolz/curried/exceptions.py +22 -0
- coinex/ccxt/static_dependencies/toolz/curried/operator.py +22 -0
- coinex/ccxt/static_dependencies/toolz/dicttoolz.py +339 -0
- coinex/ccxt/static_dependencies/toolz/functoolz.py +1049 -0
- coinex/ccxt/static_dependencies/toolz/itertoolz.py +1057 -0
- coinex/ccxt/static_dependencies/toolz/recipes.py +46 -0
- coinex/ccxt/static_dependencies/toolz/utils.py +9 -0
- coinex/ccxt/static_dependencies/typing_inspect/__init__.py +0 -0
- coinex/ccxt/static_dependencies/typing_inspect/typing_inspect.py +851 -0
- {coinex_api-0.0.15.dist-info → coinex_api-0.0.16.dist-info}/METADATA +1 -1
- coinex_api-0.0.16.dist-info/RECORD +288 -0
- coinex_api-0.0.15.dist-info/RECORD +0 -3
- {coinex_api-0.0.15.dist-info → coinex_api-0.0.16.dist-info}/WHEEL +0 -0
@@ -0,0 +1,266 @@
|
|
1
|
+
from __future__ import division
|
2
|
+
|
3
|
+
import os
|
4
|
+
import math
|
5
|
+
import binascii
|
6
|
+
from hashlib import sha256
|
7
|
+
from . import der
|
8
|
+
from .curves import orderlen
|
9
|
+
|
10
|
+
# RFC5480:
|
11
|
+
# The "unrestricted" algorithm identifier is:
|
12
|
+
# id-ecPublicKey OBJECT IDENTIFIER ::= {
|
13
|
+
# iso(1) member-body(2) us(840) ansi-X9-62(10045) keyType(2) 1 }
|
14
|
+
|
15
|
+
oid_ecPublicKey = (1, 2, 840, 10045, 2, 1)
|
16
|
+
encoded_oid_ecPublicKey = der.encode_oid(*oid_ecPublicKey)
|
17
|
+
|
18
|
+
|
19
|
+
def randrange(order, entropy=None):
|
20
|
+
"""Return a random integer k such that 1 <= k < order, uniformly
|
21
|
+
distributed across that range. For simplicity, this only behaves well if
|
22
|
+
'order' is fairly close (but below) a power of 256. The try-try-again
|
23
|
+
algorithm we use takes longer and longer time (on average) to complete as
|
24
|
+
'order' falls, rising to a maximum of avg=512 loops for the worst-case
|
25
|
+
(256**k)+1 . All of the standard curves behave well. There is a cutoff at
|
26
|
+
10k loops (which raises RuntimeError) to prevent an infinite loop when
|
27
|
+
something is really broken like the entropy function not working.
|
28
|
+
|
29
|
+
Note that this function is not declared to be forwards-compatible: we may
|
30
|
+
change the behavior in future releases. The entropy= argument (which
|
31
|
+
should get a callable that behaves like os.urandom) can be used to
|
32
|
+
achieve stability within a given release (for repeatable unit tests), but
|
33
|
+
should not be used as a long-term-compatible key generation algorithm.
|
34
|
+
"""
|
35
|
+
# we could handle arbitrary orders (even 256**k+1) better if we created
|
36
|
+
# candidates bit-wise instead of byte-wise, which would reduce the
|
37
|
+
# worst-case behavior to avg=2 loops, but that would be more complex. The
|
38
|
+
# change would be to round the order up to a power of 256, subtract one
|
39
|
+
# (to get 0xffff..), use that to get a byte-long mask for the top byte,
|
40
|
+
# generate the len-1 entropy bytes, generate one extra byte and mask off
|
41
|
+
# the top bits, then combine it with the rest. Requires jumping back and
|
42
|
+
# forth between strings and integers a lot.
|
43
|
+
|
44
|
+
if entropy is None:
|
45
|
+
entropy = os.urandom
|
46
|
+
assert order > 1
|
47
|
+
bytes = orderlen(order)
|
48
|
+
dont_try_forever = 10000 # gives about 2**-60 failures for worst case
|
49
|
+
while dont_try_forever > 0:
|
50
|
+
dont_try_forever -= 1
|
51
|
+
candidate = string_to_number(entropy(bytes)) + 1
|
52
|
+
if 1 <= candidate < order:
|
53
|
+
return candidate
|
54
|
+
continue
|
55
|
+
raise RuntimeError("randrange() tried hard but gave up, either something"
|
56
|
+
" is very wrong or you got realllly unlucky. Order was"
|
57
|
+
" %x" % order)
|
58
|
+
|
59
|
+
|
60
|
+
class PRNG:
|
61
|
+
# this returns a callable which, when invoked with an integer N, will
|
62
|
+
# return N pseudorandom bytes. Note: this is a short-term PRNG, meant
|
63
|
+
# primarily for the needs of randrange_from_seed__trytryagain(), which
|
64
|
+
# only needs to run it a few times per seed. It does not provide
|
65
|
+
# protection against state compromise (forward security).
|
66
|
+
def __init__(self, seed):
|
67
|
+
self.generator = self.block_generator(seed)
|
68
|
+
|
69
|
+
def __call__(self, numbytes):
|
70
|
+
a = [next(self.generator) for i in range(numbytes)]
|
71
|
+
return bytes(a)
|
72
|
+
|
73
|
+
def block_generator(self, seed):
|
74
|
+
counter = 0
|
75
|
+
while True:
|
76
|
+
for byte in sha256(("prng-%d-%s" % (counter, seed)).encode()).digest():
|
77
|
+
yield byte
|
78
|
+
counter += 1
|
79
|
+
|
80
|
+
|
81
|
+
def randrange_from_seed__overshoot_modulo(seed, order):
|
82
|
+
# hash the data, then turn the digest into a number in [1,order).
|
83
|
+
#
|
84
|
+
# We use David-Sarah Hopwood's suggestion: turn it into a number that's
|
85
|
+
# sufficiently larger than the group order, then modulo it down to fit.
|
86
|
+
# This should give adequate (but not perfect) uniformity, and simple
|
87
|
+
# code. There are other choices: try-try-again is the main one.
|
88
|
+
base = PRNG(seed)(2 * orderlen(order))
|
89
|
+
number = (int(binascii.hexlify(base), 16) % (order - 1)) + 1
|
90
|
+
assert 1 <= number < order, (1, number, order)
|
91
|
+
return number
|
92
|
+
|
93
|
+
|
94
|
+
def lsb_of_ones(numbits):
|
95
|
+
return (1 << numbits) - 1
|
96
|
+
|
97
|
+
|
98
|
+
def bits_and_bytes(order):
|
99
|
+
bits = int(math.log(order - 1, 2) + 1)
|
100
|
+
bytes = bits // 8
|
101
|
+
extrabits = bits % 8
|
102
|
+
return bits, bytes, extrabits
|
103
|
+
|
104
|
+
|
105
|
+
# the following randrange_from_seed__METHOD() functions take an
|
106
|
+
# arbitrarily-sized secret seed and turn it into a number that obeys the same
|
107
|
+
# range limits as randrange() above. They are meant for deriving consistent
|
108
|
+
# signing keys from a secret rather than generating them randomly, for
|
109
|
+
# example a protocol in which three signing keys are derived from a master
|
110
|
+
# secret. You should use a uniformly-distributed unguessable seed with about
|
111
|
+
# curve.baselen bytes of entropy. To use one, do this:
|
112
|
+
# seed = os.urandom(curve.baselen) # or other starting point
|
113
|
+
# secexp = ecdsa.util.randrange_from_seed__trytryagain(sed, curve.order)
|
114
|
+
# sk = SigningKey.from_secret_exponent(secexp, curve)
|
115
|
+
|
116
|
+
def randrange_from_seed__truncate_bytes(seed, order, hashmod=sha256):
|
117
|
+
# hash the seed, then turn the digest into a number in [1,order), but
|
118
|
+
# don't worry about trying to uniformly fill the range. This will lose,
|
119
|
+
# on average, four bits of entropy.
|
120
|
+
bits, _bytes, extrabits = bits_and_bytes(order)
|
121
|
+
if extrabits:
|
122
|
+
_bytes += 1
|
123
|
+
base = hashmod(seed).digest()[:_bytes]
|
124
|
+
base = "\x00" * (_bytes - len(base)) + base
|
125
|
+
number = 1 + int(binascii.hexlify(base), 16)
|
126
|
+
assert 1 <= number < order
|
127
|
+
return number
|
128
|
+
|
129
|
+
|
130
|
+
def randrange_from_seed__truncate_bits(seed, order, hashmod=sha256):
|
131
|
+
# like string_to_randrange_truncate_bytes, but only lose an average of
|
132
|
+
# half a bit
|
133
|
+
bits = int(math.log(order - 1, 2) + 1)
|
134
|
+
maxbytes = (bits + 7) // 8
|
135
|
+
base = hashmod(seed).digest()[:maxbytes]
|
136
|
+
base = "\x00" * (maxbytes - len(base)) + base
|
137
|
+
topbits = 8 * maxbytes - bits
|
138
|
+
if topbits:
|
139
|
+
base = int.to_bytes(ord(base[0]) & lsb_of_ones(topbits), 1, 'big') + base[1:]
|
140
|
+
number = 1 + int(binascii.hexlify(base), 16)
|
141
|
+
assert 1 <= number < order
|
142
|
+
return number
|
143
|
+
|
144
|
+
|
145
|
+
def randrange_from_seed__trytryagain(seed, order):
|
146
|
+
# figure out exactly how many bits we need (rounded up to the nearest
|
147
|
+
# bit), so we can reduce the chance of looping to less than 0.5 . This is
|
148
|
+
# specified to feed from a byte-oriented PRNG, and discards the
|
149
|
+
# high-order bits of the first byte as necessary to get the right number
|
150
|
+
# of bits. The average number of loops will range from 1.0 (when
|
151
|
+
# order=2**k-1) to 2.0 (when order=2**k+1).
|
152
|
+
assert order > 1
|
153
|
+
bits, bytes, extrabits = bits_and_bytes(order)
|
154
|
+
generate = PRNG(seed)
|
155
|
+
while True:
|
156
|
+
extrabyte = b''
|
157
|
+
if extrabits:
|
158
|
+
extrabyte = int.to_bytes(ord(generate(1)) & lsb_of_ones(extrabits), 1, 'big')
|
159
|
+
guess = string_to_number(extrabyte + generate(bytes)) + 1
|
160
|
+
if 1 <= guess < order:
|
161
|
+
return guess
|
162
|
+
|
163
|
+
|
164
|
+
def number_to_string(num, order):
|
165
|
+
l = orderlen(order)
|
166
|
+
fmt_str = "%0" + str(2 * l) + "x"
|
167
|
+
string = binascii.unhexlify((fmt_str % num).encode())
|
168
|
+
assert len(string) == l, (len(string), l)
|
169
|
+
return string
|
170
|
+
|
171
|
+
|
172
|
+
def number_to_string_crop(num, order):
|
173
|
+
l = orderlen(order)
|
174
|
+
fmt_str = "%0" + str(2 * l) + "x"
|
175
|
+
string = binascii.unhexlify((fmt_str % num).encode())
|
176
|
+
return string[:l]
|
177
|
+
|
178
|
+
|
179
|
+
def string_to_number(string):
|
180
|
+
return int(binascii.hexlify(string), 16)
|
181
|
+
|
182
|
+
|
183
|
+
def string_to_number_fixedlen(string, order):
|
184
|
+
l = orderlen(order)
|
185
|
+
assert len(string) == l, (len(string), l)
|
186
|
+
return int(binascii.hexlify(string), 16)
|
187
|
+
|
188
|
+
|
189
|
+
# these methods are useful for the sigencode= argument to SK.sign() and the
|
190
|
+
# sigdecode= argument to VK.verify(), and control how the signature is packed
|
191
|
+
# or unpacked.
|
192
|
+
|
193
|
+
def sigencode_strings(r, s, order, v=None):
|
194
|
+
r_str = number_to_string(r, order)
|
195
|
+
s_str = number_to_string(s, order)
|
196
|
+
return r_str, s_str, v
|
197
|
+
|
198
|
+
|
199
|
+
def sigencode_string(r, s, order, v=None):
|
200
|
+
# for any given curve, the size of the signature numbers is
|
201
|
+
# fixed, so just use simple concatenation
|
202
|
+
r_str, s_str, v = sigencode_strings(r, s, order)
|
203
|
+
return r_str + s_str
|
204
|
+
|
205
|
+
|
206
|
+
def sigencode_der(r, s, order, v=None):
|
207
|
+
return der.encode_sequence(der.encode_integer(r), der.encode_integer(s))
|
208
|
+
|
209
|
+
|
210
|
+
# canonical versions of sigencode methods
|
211
|
+
# these enforce low S values, by negating the value (modulo the order) if above order/2
|
212
|
+
# see CECKey::Sign() https://github.com/bitcoin/bitcoin/blob/master/src/key.cpp#L214
|
213
|
+
def sigencode_strings_canonize(r, s, order, v=None):
|
214
|
+
if s > order / 2:
|
215
|
+
s = order - s
|
216
|
+
if v is not None:
|
217
|
+
v ^= 1
|
218
|
+
return sigencode_strings(r, s, order, v)
|
219
|
+
|
220
|
+
|
221
|
+
def sigencode_string_canonize(r, s, order, v=None):
|
222
|
+
if s > order / 2:
|
223
|
+
s = order - s
|
224
|
+
if v is not None:
|
225
|
+
v ^= 1
|
226
|
+
return sigencode_string(r, s, order, v)
|
227
|
+
|
228
|
+
|
229
|
+
def sigencode_der_canonize(r, s, order, v=None):
|
230
|
+
if s > order / 2:
|
231
|
+
s = order - s
|
232
|
+
if v is not None:
|
233
|
+
v ^= 1
|
234
|
+
return sigencode_der(r, s, order, v)
|
235
|
+
|
236
|
+
|
237
|
+
def sigdecode_string(signature, order):
|
238
|
+
l = orderlen(order)
|
239
|
+
assert len(signature) == 2 * l, (len(signature), 2 * l)
|
240
|
+
r = string_to_number_fixedlen(signature[:l], order)
|
241
|
+
s = string_to_number_fixedlen(signature[l:], order)
|
242
|
+
return r, s
|
243
|
+
|
244
|
+
|
245
|
+
def sigdecode_strings(rs_strings, order):
|
246
|
+
(r_str, s_str) = rs_strings
|
247
|
+
l = orderlen(order)
|
248
|
+
assert len(r_str) == l, (len(r_str), l)
|
249
|
+
assert len(s_str) == l, (len(s_str), l)
|
250
|
+
r = string_to_number_fixedlen(r_str, order)
|
251
|
+
s = string_to_number_fixedlen(s_str, order)
|
252
|
+
return r, s
|
253
|
+
|
254
|
+
|
255
|
+
def sigdecode_der(sig_der, order):
|
256
|
+
# return der.encode_sequence(der.encode_integer(r), der.encode_integer(s))
|
257
|
+
rs_strings, empty = der.remove_sequence(sig_der)
|
258
|
+
if empty != b'':
|
259
|
+
raise der.UnexpectedDER("trailing junk after DER sig: %s" %
|
260
|
+
binascii.hexlify(empty))
|
261
|
+
r, rest = der.remove_integer(rs_strings)
|
262
|
+
s, empty = der.remove_integer(rest)
|
263
|
+
if empty != b'':
|
264
|
+
raise der.UnexpectedDER("trailing junk after DER numbers: %s" %
|
265
|
+
binascii.hexlify(empty))
|
266
|
+
return r, s
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
from .abi import (
|
3
|
+
decode,
|
4
|
+
decode_abi,
|
5
|
+
decode_single,
|
6
|
+
encode,
|
7
|
+
encode_abi,
|
8
|
+
encode_single,
|
9
|
+
is_encodable,
|
10
|
+
is_encodable_type,
|
11
|
+
)
|
12
|
+
|
13
|
+
# This code from: https://github.com/ethereum/eth-abi/tree/v3.0.1
|
14
|
+
__version__ = 'ccxt'
|
15
|
+
|
16
|
+
__all__ = ['decode','encode']
|
@@ -0,0 +1,19 @@
|
|
1
|
+
from .codec import (
|
2
|
+
ABICodec,
|
3
|
+
)
|
4
|
+
from .registry import (
|
5
|
+
registry,
|
6
|
+
)
|
7
|
+
|
8
|
+
default_codec = ABICodec(registry)
|
9
|
+
|
10
|
+
encode = default_codec.encode
|
11
|
+
encode_abi = default_codec.encode_abi # deprecated
|
12
|
+
encode_single = default_codec.encode_single # deprecated
|
13
|
+
|
14
|
+
decode = default_codec.decode
|
15
|
+
decode_abi = default_codec.decode_abi # deprecated
|
16
|
+
decode_single = default_codec.decode_single # deprecated
|
17
|
+
|
18
|
+
is_encodable = default_codec.is_encodable
|
19
|
+
is_encodable_type = default_codec.is_encodable_type
|
@@ -0,0 +1,152 @@
|
|
1
|
+
import functools
|
2
|
+
|
3
|
+
from ..typing.abi import (
|
4
|
+
TypeStr,
|
5
|
+
)
|
6
|
+
|
7
|
+
from .grammar import (
|
8
|
+
BasicType,
|
9
|
+
TupleType,
|
10
|
+
normalize,
|
11
|
+
parse,
|
12
|
+
)
|
13
|
+
|
14
|
+
|
15
|
+
def parse_type_str(expected_base=None, with_arrlist=False):
|
16
|
+
"""
|
17
|
+
Used by BaseCoder subclasses as a convenience for implementing the
|
18
|
+
``from_type_str`` method required by ``ABIRegistry``. Useful if normalizing
|
19
|
+
then parsing a type string with an (optional) expected base is required in
|
20
|
+
that method.
|
21
|
+
"""
|
22
|
+
|
23
|
+
def decorator(old_from_type_str):
|
24
|
+
@functools.wraps(old_from_type_str)
|
25
|
+
def new_from_type_str(cls, type_str, registry):
|
26
|
+
normalized_type_str = normalize(type_str)
|
27
|
+
abi_type = parse(normalized_type_str)
|
28
|
+
|
29
|
+
type_str_repr = repr(type_str)
|
30
|
+
if type_str != normalized_type_str:
|
31
|
+
type_str_repr = "{} (normalized to {})".format(
|
32
|
+
type_str_repr,
|
33
|
+
repr(normalized_type_str),
|
34
|
+
)
|
35
|
+
|
36
|
+
if expected_base is not None:
|
37
|
+
if not isinstance(abi_type, BasicType):
|
38
|
+
raise ValueError(
|
39
|
+
"Cannot create {} for non-basic type {}".format(
|
40
|
+
cls.__name__,
|
41
|
+
type_str_repr,
|
42
|
+
)
|
43
|
+
)
|
44
|
+
if abi_type.base != expected_base:
|
45
|
+
raise ValueError(
|
46
|
+
"Cannot create {} for type {}: expected type with "
|
47
|
+
"base '{}'".format(
|
48
|
+
cls.__name__,
|
49
|
+
type_str_repr,
|
50
|
+
expected_base,
|
51
|
+
)
|
52
|
+
)
|
53
|
+
|
54
|
+
if not with_arrlist and abi_type.arrlist is not None:
|
55
|
+
raise ValueError(
|
56
|
+
"Cannot create {} for type {}: expected type with "
|
57
|
+
"no array dimension list".format(
|
58
|
+
cls.__name__,
|
59
|
+
type_str_repr,
|
60
|
+
)
|
61
|
+
)
|
62
|
+
if with_arrlist and abi_type.arrlist is None:
|
63
|
+
raise ValueError(
|
64
|
+
"Cannot create {} for type {}: expected type with "
|
65
|
+
"array dimension list".format(
|
66
|
+
cls.__name__,
|
67
|
+
type_str_repr,
|
68
|
+
)
|
69
|
+
)
|
70
|
+
|
71
|
+
# Perform general validation of default solidity types
|
72
|
+
abi_type.validate()
|
73
|
+
|
74
|
+
return old_from_type_str(cls, abi_type, registry)
|
75
|
+
|
76
|
+
return classmethod(new_from_type_str)
|
77
|
+
|
78
|
+
return decorator
|
79
|
+
|
80
|
+
|
81
|
+
def parse_tuple_type_str(old_from_type_str):
|
82
|
+
"""
|
83
|
+
Used by BaseCoder subclasses as a convenience for implementing the
|
84
|
+
``from_type_str`` method required by ``ABIRegistry``. Useful if normalizing
|
85
|
+
then parsing a tuple type string is required in that method.
|
86
|
+
"""
|
87
|
+
|
88
|
+
@functools.wraps(old_from_type_str)
|
89
|
+
def new_from_type_str(cls, type_str, registry):
|
90
|
+
normalized_type_str = normalize(type_str)
|
91
|
+
abi_type = parse(normalized_type_str)
|
92
|
+
|
93
|
+
type_str_repr = repr(type_str)
|
94
|
+
if type_str != normalized_type_str:
|
95
|
+
type_str_repr = "{} (normalized to {})".format(
|
96
|
+
type_str_repr,
|
97
|
+
repr(normalized_type_str),
|
98
|
+
)
|
99
|
+
|
100
|
+
if not isinstance(abi_type, TupleType):
|
101
|
+
raise ValueError(
|
102
|
+
"Cannot create {} for non-tuple type {}".format(
|
103
|
+
cls.__name__,
|
104
|
+
type_str_repr,
|
105
|
+
)
|
106
|
+
)
|
107
|
+
|
108
|
+
abi_type.validate()
|
109
|
+
|
110
|
+
return old_from_type_str(cls, abi_type, registry)
|
111
|
+
|
112
|
+
return classmethod(new_from_type_str)
|
113
|
+
|
114
|
+
|
115
|
+
class BaseCoder:
|
116
|
+
"""
|
117
|
+
Base class for all encoder and decoder classes.
|
118
|
+
"""
|
119
|
+
|
120
|
+
is_dynamic = False
|
121
|
+
|
122
|
+
def __init__(self, **kwargs):
|
123
|
+
cls = type(self)
|
124
|
+
|
125
|
+
# Ensure no unrecognized kwargs were given
|
126
|
+
for key, value in kwargs.items():
|
127
|
+
if not hasattr(cls, key):
|
128
|
+
raise AttributeError(
|
129
|
+
"Property {key} not found on {cls_name} class. "
|
130
|
+
"`{cls_name}.__init__` only accepts keyword arguments which are "
|
131
|
+
"present on the {cls_name} class.".format(
|
132
|
+
key=key,
|
133
|
+
cls_name=cls.__name__,
|
134
|
+
)
|
135
|
+
)
|
136
|
+
setattr(self, key, value)
|
137
|
+
|
138
|
+
# Validate given combination of kwargs
|
139
|
+
self.validate()
|
140
|
+
|
141
|
+
def validate(self):
|
142
|
+
pass
|
143
|
+
|
144
|
+
@classmethod
|
145
|
+
def from_type_str(
|
146
|
+
cls, type_str: TypeStr, registry
|
147
|
+
) -> "BaseCoder": # pragma: no cover
|
148
|
+
"""
|
149
|
+
Used by :any:`ABIRegistry` to get an appropriate encoder or decoder
|
150
|
+
instance for the given type string and type registry.
|
151
|
+
"""
|
152
|
+
raise NotImplementedError("Must implement `from_type_str`")
|
@@ -0,0 +1,217 @@
|
|
1
|
+
from typing import (
|
2
|
+
Any,
|
3
|
+
Iterable,
|
4
|
+
Tuple,
|
5
|
+
)
|
6
|
+
import warnings
|
7
|
+
|
8
|
+
from ..typing.abi import (
|
9
|
+
Decodable,
|
10
|
+
TypeStr,
|
11
|
+
)
|
12
|
+
from ..utils import (
|
13
|
+
is_bytes,
|
14
|
+
)
|
15
|
+
|
16
|
+
from .decoding import (
|
17
|
+
ContextFramesBytesIO,
|
18
|
+
TupleDecoder,
|
19
|
+
)
|
20
|
+
from .encoding import (
|
21
|
+
TupleEncoder,
|
22
|
+
)
|
23
|
+
from .exceptions import (
|
24
|
+
EncodingError,
|
25
|
+
)
|
26
|
+
from .registry import (
|
27
|
+
ABIRegistry,
|
28
|
+
)
|
29
|
+
|
30
|
+
|
31
|
+
class BaseABICoder:
|
32
|
+
"""
|
33
|
+
Base class for porcelain coding APIs. These are classes which wrap
|
34
|
+
instances of :class:`~.registry.ABIRegistry` to provide last-mile
|
35
|
+
coding functionality.
|
36
|
+
"""
|
37
|
+
|
38
|
+
def __init__(self, registry: ABIRegistry):
|
39
|
+
"""
|
40
|
+
Constructor.
|
41
|
+
|
42
|
+
:param registry: The registry providing the encoders to be used when
|
43
|
+
encoding values.
|
44
|
+
"""
|
45
|
+
self._registry = registry
|
46
|
+
|
47
|
+
|
48
|
+
class ABIEncoder(BaseABICoder):
|
49
|
+
"""
|
50
|
+
Wraps a registry to provide last-mile encoding functionality.
|
51
|
+
"""
|
52
|
+
|
53
|
+
def encode_single(self, typ: TypeStr, arg: Any) -> bytes:
|
54
|
+
"""
|
55
|
+
Encodes the python value ``arg`` as a binary value of the ABI type
|
56
|
+
``typ``.
|
57
|
+
|
58
|
+
:param typ: The string representation of the ABI type that will be used
|
59
|
+
for encoding e.g. ``'uint256'``, ``'bytes[]'``, ``'(int,int)'``,
|
60
|
+
etc.
|
61
|
+
:param arg: The python value to be encoded.
|
62
|
+
|
63
|
+
:returns: The binary representation of the python value ``arg`` as a
|
64
|
+
value of the ABI type ``typ``.
|
65
|
+
"""
|
66
|
+
warnings.warn(
|
67
|
+
"abi.encode_single() and abi.encode_single_packed() are deprecated "
|
68
|
+
"and will be removed in version 4.0.0 in favor of abi.encode() and "
|
69
|
+
"abi.encode_packed(), respectively",
|
70
|
+
category=DeprecationWarning,
|
71
|
+
)
|
72
|
+
|
73
|
+
encoder = self._registry.get_encoder(typ)
|
74
|
+
|
75
|
+
return encoder(arg)
|
76
|
+
|
77
|
+
def encode_abi(self, types: Iterable[TypeStr], args: Iterable[Any]) -> bytes:
|
78
|
+
"""
|
79
|
+
Encodes the python values in ``args`` as a sequence of binary values of
|
80
|
+
the ABI types in ``types`` via the head-tail mechanism.
|
81
|
+
|
82
|
+
:param types: An iterable of string representations of the ABI types
|
83
|
+
that will be used for encoding e.g. ``('uint256', 'bytes[]',
|
84
|
+
'(int,int)')``
|
85
|
+
:param args: An iterable of python values to be encoded.
|
86
|
+
|
87
|
+
:returns: The head-tail encoded binary representation of the python
|
88
|
+
values in ``args`` as values of the ABI types in ``types``.
|
89
|
+
"""
|
90
|
+
warnings.warn(
|
91
|
+
"abi.encode_abi() and abi.encode_abi_packed() are deprecated and will be "
|
92
|
+
"removed in version 4.0.0 in favor of abi.encode() and "
|
93
|
+
"abi.encode_packed(), respectively",
|
94
|
+
category=DeprecationWarning,
|
95
|
+
)
|
96
|
+
return self.encode(types, args)
|
97
|
+
|
98
|
+
def encode(self, types, args):
|
99
|
+
encoders = [self._registry.get_encoder(type_str) for type_str in types]
|
100
|
+
|
101
|
+
encoder = TupleEncoder(encoders=encoders)
|
102
|
+
|
103
|
+
return encoder(args)
|
104
|
+
|
105
|
+
def is_encodable(self, typ: TypeStr, arg: Any) -> bool:
|
106
|
+
"""
|
107
|
+
Determines if the python value ``arg`` is encodable as a value of the
|
108
|
+
ABI type ``typ``.
|
109
|
+
|
110
|
+
:param typ: A string representation for the ABI type against which the
|
111
|
+
python value ``arg`` will be checked e.g. ``'uint256'``,
|
112
|
+
``'bytes[]'``, ``'(int,int)'``, etc.
|
113
|
+
:param arg: The python value whose encodability should be checked.
|
114
|
+
|
115
|
+
:returns: ``True`` if ``arg`` is encodable as a value of the ABI type
|
116
|
+
``typ``. Otherwise, ``False``.
|
117
|
+
"""
|
118
|
+
encoder = self._registry.get_encoder(typ)
|
119
|
+
|
120
|
+
try:
|
121
|
+
encoder.validate_value(arg)
|
122
|
+
except EncodingError:
|
123
|
+
return False
|
124
|
+
except AttributeError:
|
125
|
+
try:
|
126
|
+
encoder(arg)
|
127
|
+
except EncodingError:
|
128
|
+
return False
|
129
|
+
|
130
|
+
return True
|
131
|
+
|
132
|
+
def is_encodable_type(self, typ: TypeStr) -> bool:
|
133
|
+
"""
|
134
|
+
Returns ``True`` if values for the ABI type ``typ`` can be encoded by
|
135
|
+
this codec.
|
136
|
+
|
137
|
+
:param typ: A string representation for the ABI type that will be
|
138
|
+
checked for encodability e.g. ``'uint256'``, ``'bytes[]'``,
|
139
|
+
``'(int,int)'``, etc.
|
140
|
+
|
141
|
+
:returns: ``True`` if values for ``typ`` can be encoded by this codec.
|
142
|
+
Otherwise, ``False``.
|
143
|
+
"""
|
144
|
+
return self._registry.has_encoder(typ)
|
145
|
+
|
146
|
+
|
147
|
+
class ABIDecoder(BaseABICoder):
|
148
|
+
"""
|
149
|
+
Wraps a registry to provide last-mile decoding functionality.
|
150
|
+
"""
|
151
|
+
|
152
|
+
stream_class = ContextFramesBytesIO
|
153
|
+
|
154
|
+
def decode_single(self, typ: TypeStr, data: Decodable) -> Any:
|
155
|
+
"""
|
156
|
+
Decodes the binary value ``data`` of the ABI type ``typ`` into its
|
157
|
+
equivalent python value.
|
158
|
+
|
159
|
+
:param typ: The string representation of the ABI type that will be used for
|
160
|
+
decoding e.g. ``'uint256'``, ``'bytes[]'``, ``'(int,int)'``, etc.
|
161
|
+
:param data: The binary value to be decoded.
|
162
|
+
|
163
|
+
:returns: The equivalent python value of the ABI value represented in
|
164
|
+
``data``.
|
165
|
+
"""
|
166
|
+
warnings.warn(
|
167
|
+
"abi.decode_single() is deprecated and will be removed in version 4.0.0 "
|
168
|
+
"in favor of abi.decode()",
|
169
|
+
category=DeprecationWarning,
|
170
|
+
)
|
171
|
+
|
172
|
+
if not is_bytes(data):
|
173
|
+
raise TypeError(
|
174
|
+
"The `data` value must be of bytes type. Got {0}".format(type(data))
|
175
|
+
)
|
176
|
+
|
177
|
+
decoder = self._registry.get_decoder(typ)
|
178
|
+
stream = self.stream_class(data)
|
179
|
+
|
180
|
+
return decoder(stream)
|
181
|
+
|
182
|
+
def decode_abi(self, types: Iterable[TypeStr], data: Decodable) -> Tuple[Any, ...]:
|
183
|
+
"""
|
184
|
+
Decodes the binary value ``data`` as a sequence of values of the ABI types
|
185
|
+
in ``types`` via the head-tail mechanism into a tuple of equivalent python
|
186
|
+
values.
|
187
|
+
|
188
|
+
:param types: An iterable of string representations of the ABI types that
|
189
|
+
will be used for decoding e.g. ``('uint256', 'bytes[]', '(int,int)')``
|
190
|
+
:param data: The binary value to be decoded.
|
191
|
+
|
192
|
+
:returns: A tuple of equivalent python values for the ABI values
|
193
|
+
represented in ``data``.
|
194
|
+
"""
|
195
|
+
warnings.warn(
|
196
|
+
"abi.decode_abi() is deprecated and will be removed in version 4.0.0 in "
|
197
|
+
"favor of abi.decode()",
|
198
|
+
category=DeprecationWarning,
|
199
|
+
)
|
200
|
+
return self.decode(types, data)
|
201
|
+
|
202
|
+
def decode(self, types, data):
|
203
|
+
if not is_bytes(data):
|
204
|
+
raise TypeError(
|
205
|
+
f"The `data` value must be of bytes type. Got {type(data)}"
|
206
|
+
)
|
207
|
+
|
208
|
+
decoders = [self._registry.get_decoder(type_str) for type_str in types]
|
209
|
+
|
210
|
+
decoder = TupleDecoder(decoders=decoders)
|
211
|
+
stream = self.stream_class(data)
|
212
|
+
|
213
|
+
return decoder(stream)
|
214
|
+
|
215
|
+
|
216
|
+
class ABICodec(ABIEncoder, ABIDecoder):
|
217
|
+
pass
|