gnosis.eth.django package
Subpackages
Submodules
gnosis.eth.django.filters module
- class gnosis.eth.django.filters.EthereumAddressFieldForm(*, max_length=None, min_length=None, strip=True, empty_value='', **kwargs)
Bases:
CharField
- default_error_messages
- prepare_value(value)
- to_python(value)
Return a string.
- class gnosis.eth.django.filters.EthereumAddressFilter(field_name=None, lookup_expr=None, *, label=None, method=None, distinct=False, exclude=False, **kwargs)
Bases:
Filter
- field_class
alias of
EthereumAddressFieldForm
- class gnosis.eth.django.filters.Keccak256FieldForm(*, max_length=None, min_length=None, strip=True, empty_value='', **kwargs)
Bases:
CharField
- default_error_messages
- prepare_value(value)
- to_python(value)
Return a string.
- class gnosis.eth.django.filters.Keccak256Filter(field_name=None, lookup_expr=None, *, label=None, method=None, distinct=False, exclude=False, **kwargs)
Bases:
Filter
- field_class
alias of
Keccak256FieldForm
gnosis.eth.django.models module
- class gnosis.eth.django.models.EthereumAddressField(*args, **kwargs)
Bases:
CharField
- deconstruct()
Return enough information to recreate the field as a 4-tuple:
The name of the field on the model, if contribute_to_class() has been run.
The import path of the field, including the class:e.g. django.db.models.IntegerField This should be the most portable version, so less specific may be better.
A list of positional arguments.
A dict of keyword arguments.
Note that the positional or keyword arguments must contain values of the following types (including inner values of collection types):
None, bool, str, int, float, complex, set, frozenset, list, tuple, dict
UUID
datetime.datetime (naive), datetime.date
top-level classes, top-level functions - will be referenced by their full import path
Storage instances - these have their own deconstruct() method
This is because the values here must be serialized into a text format (possibly new Python code, possibly JSON) and these are the only types with encoding handlers defined.
There’s no need to return the exact way the field was instantiated this time, just ensure that the resulting field is the same - prefer keyword arguments over positional ones, and omit parameters with their default values.
- default_error_messages
- default_validators = [<function validate_checksumed_address>]
- description = 'DEPRECATED. Use `EthereumAddressV2Field`. Ethereum address (EIP55)'
- from_db_value(value, expression, connection)
- get_prep_value(value)
Perform preliminary non-db specific value checks and conversions.
- to_python(value)
Convert the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can’t be converted. Return the converted value. Subclasses should override this.
- class gnosis.eth.django.models.EthereumAddressV2Field(verbose_name=None, name=None, primary_key=False, max_length=None, unique=False, blank=False, null=False, db_index=False, rel=None, default=<class 'django.db.models.fields.NOT_PROVIDED'>, editable=True, serialize=True, unique_for_date=None, unique_for_month=None, unique_for_year=None, choices=None, help_text='', db_column=None, db_tablespace=None, auto_created=False, validators=(), error_messages=None)
Bases:
Field
- default_error_messages
- default_validators = [<function validate_checksumed_address>]
- description = 'Ethereum address (EIP55)'
- formfield(**kwargs)
Return a django.forms.Field instance for this field.
- from_db_value(value: memoryview, expression, connection) Optional[ChecksumAddress]
- get_internal_type()
- get_prep_value(value: ChecksumAddress) Optional[bytes]
Perform preliminary non-db specific value checks and conversions.
- to_python(value) Optional[ChecksumAddress]
Convert the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can’t be converted. Return the converted value. Subclasses should override this.
- class gnosis.eth.django.models.HexField(*args, db_collation=None, **kwargs)
Bases:
CharField
Field to store hex values (without 0x). Returns hex with 0x prefix.
On Database side a CharField is used.
- clean(value, model_instance)
Convert the value’s type and run validation. Validation errors from to_python() and validate() are propagated. Return the correct value if no error is raised.
- description = 'Stores a hex value into an CharField'
- formfield(**kwargs)
Return a django.forms.Field instance for this field.
- from_db_value(value, expression, connection)
- get_prep_value(value)
Perform preliminary non-db specific value checks and conversions.
- to_python(value)
Convert the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can’t be converted. Return the converted value. Subclasses should override this.
- class gnosis.eth.django.models.Keccak256Field(*args, **kwargs)
Bases:
BinaryField
- default_error_messages
- description = 'Keccak256 hash stored as binary'
- formfield(**kwargs)
Return a django.forms.Field instance for this field.
- from_db_value(value: memoryview, expression, connection) Optional[bytes]
- get_prep_value(value: Union[bytes, str]) Optional[bytes]
Perform preliminary non-db specific value checks and conversions.
- to_python(value) Optional[str]
Convert the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can’t be converted. Return the converted value. Subclasses should override this.
- class gnosis.eth.django.models.Sha3HashField(*args, **kwargs)
Bases:
HexField
- deconstruct()
Return enough information to recreate the field as a 4-tuple:
The name of the field on the model, if contribute_to_class() has been run.
The import path of the field, including the class:e.g. django.db.models.IntegerField This should be the most portable version, so less specific may be better.
A list of positional arguments.
A dict of keyword arguments.
Note that the positional or keyword arguments must contain values of the following types (including inner values of collection types):
None, bool, str, int, float, complex, set, frozenset, list, tuple, dict
UUID
datetime.datetime (naive), datetime.date
top-level classes, top-level functions - will be referenced by their full import path
Storage instances - these have their own deconstruct() method
This is because the values here must be serialized into a text format (possibly new Python code, possibly JSON) and these are the only types with encoding handlers defined.
There’s no need to return the exact way the field was instantiated this time, just ensure that the resulting field is the same - prefer keyword arguments over positional ones, and omit parameters with their default values.
- description = 'DEPRECATED. Use `Keccak256Field`'
- class gnosis.eth.django.models.Uint256Field(*args, **kwargs)
Bases:
DecimalField
- deconstruct()
Return enough information to recreate the field as a 4-tuple:
The name of the field on the model, if contribute_to_class() has been run.
The import path of the field, including the class:e.g. django.db.models.IntegerField This should be the most portable version, so less specific may be better.
A list of positional arguments.
A dict of keyword arguments.
Note that the positional or keyword arguments must contain values of the following types (including inner values of collection types):
None, bool, str, int, float, complex, set, frozenset, list, tuple, dict
UUID
datetime.datetime (naive), datetime.date
top-level classes, top-level functions - will be referenced by their full import path
Storage instances - these have their own deconstruct() method
This is because the values here must be serialized into a text format (possibly new Python code, possibly JSON) and these are the only types with encoding handlers defined.
There’s no need to return the exact way the field was instantiated this time, just ensure that the resulting field is the same - prefer keyword arguments over positional ones, and omit parameters with their default values.
- description
Field to store ethereum uint256 values. Uses Decimal db type without decimals to store in the database, but retrieve as int instead of Decimal (https://docs.python.org/3/library/decimal.html)
- from_db_value(value, expression, connection)
gnosis.eth.django.serializers module
- class gnosis.eth.django.serializers.EthereumAddressField(*args, **kwargs)
Bases:
Field
Ethereum address checksumed https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md
- to_internal_value(data)
Transform the incoming primitive data into a native value.
- to_representation(obj)
Transform the outgoing native value into primitive data.
- class gnosis.eth.django.serializers.HexadecimalField(*args, **kwargs)
Bases:
Field
Serializes hexadecimal values starting by 0x. Empty values should be None or just 0x.
- default_error_messages
- to_internal_value(data)
Transform the incoming primitive data into a native value.
- to_representation(obj)
Transform the outgoing native value into primitive data.
- class gnosis.eth.django.serializers.Sha3HashField(*args, **kwargs)
Bases:
HexadecimalField
- class gnosis.eth.django.serializers.SignatureSerializer(*args, **kwargs)
Bases:
Serializer
gnosis.eth.django.validators module
- gnosis.eth.django.validators.validate_checksumed_address(address)