DuniterPy issueshttps://git.duniter.org/clients/python/duniterpy/-/issues2021-11-12T22:23:31+01:00https://git.duniter.org/clients/python/duniterpy/-/issues/187Implement __eq__() methods on Revocation, Identity, Membership, and Certifica...2021-11-12T22:23:31+01:00MoulImplement __eq__() methods on Revocation, Identity, Membership, and Certification classes- [x] Implement `__eq__` in `Document`
- [x] Call `super().__eq__()` in `Transaction`’s `__eq__()` method
- Implement `__eq__()` and `__hash__()` methods in:
- [x] `Identity`:
- [x] `Revocation`
- [x] `Certification`
- [x] `Membershi...- [x] Implement `__eq__` in `Document`
- [x] Call `super().__eq__()` in `Transaction`’s `__eq__()` method
- Implement `__eq__()` and `__hash__()` methods in:
- [x] `Identity`:
- [x] `Revocation`
- [x] `Certification`
- [x] `Membership`
Useful to write tests.
`__eq__()` is already implemented on `Transation`, `Block`, and `BlockUID` classes.1.1.0MoulMoulhttps://git.duniter.org/clients/python/duniterpy/-/issues/172Document.version field should be optional with default=[last_document_version]2021-06-29T14:31:52+02:00Vincent TexierDocument.version field should be optional with default=[last_document_version]**Break backward compatibility.**
`Document` class set the protocol version as the first mandatory constructor field.
It is not easy for a new user to find the last version of the protocol.
To ease the creation of a document, this fie...**Break backward compatibility.**
`Document` class set the protocol version as the first mandatory constructor field.
It is not easy for a new user to find the last version of the protocol.
To ease the creation of a document, this field should be set by default to the last protocol version.
So we need to set the field in last position, with the last protocol version of Duniter (12 at the time of writing) as default value.
Before:
```python
def __init__(self, version: int, currency: str) -> None:
...
```
After:
```python
def __init__(self, currency: str, version: int = 12) -> None:
...
```1.0.0Vincent TexierVincent Texierhttps://git.duniter.org/clients/python/duniterpy/-/issues/163Revocation.from_signed_raw() do not stores timestamps into a BlockUID object2021-05-22T12:50:59+02:00MoulRevocation.from_signed_raw() do not stores timestamps into a BlockUID object> From https://git.duniter.org/clients/python/silkaj/-/merge_requests/170#note_26657 & https://git.duniter.org/clients/python/silkaj/-/merge_requests/170#note_26658
`from_signed_raw()` methods from `Membership`, `Identity`, and `Certifi...> From https://git.duniter.org/clients/python/silkaj/-/merge_requests/170#note_26657 & https://git.duniter.org/clients/python/silkaj/-/merge_requests/170#note_26658
`from_signed_raw()` methods from `Membership`, `Identity`, and `Certification` classes store timestamps into a `BlockUID` object. This is not the case of `Revocation.from_signed_raw()`. Let's make it consistent and more convenient to use.1.0.0MoulMoulhttps://git.duniter.org/clients/python/duniterpy/-/issues/157Create identity attribute on the Revocation and Certification classes2021-04-25T14:46:34+02:00matograineCreate identity attribute on the Revocation and Certification classes> Coming from the [implementation of the `revoke` command implementation on Silkaj](https://git.duniter.org/clients/python/silkaj/-/merge_requests/170#note_26655).
The `Revocation` has `extract_self_cert()` method that needs a signed ra...> Coming from the [implementation of the `revoke` command implementation on Silkaj](https://git.duniter.org/clients/python/silkaj/-/merge_requests/170#note_26655).
The `Revocation` has `extract_self_cert()` method that needs a signed raw document.
However, a `Revocation` object could have an `identity` attribute. Same for `Certification`.
Or a dedicated method, like `Revocation.extract_identity()`.
### Todo
- [ ] `Revocation.identity()`
- [ ] `Certification.identity()`Backloghttps://git.duniter.org/clients/python/duniterpy/-/issues/95Remove `signatures` argument from all `__init__()`’s documents subclasses2021-06-29T19:00:14+02:00Vincent TexierRemove `signatures` argument from all `__init__()`’s documents subclassesWhen we instantiate a `Document` instance, or a `Document` subclass instance, we do not have the signatures of the document as it is not created yet.
**So we can remove the `signatures` argument in the `__init__()` of `Document` and all...When we instantiate a `Document` instance, or a `Document` subclass instance, we do not have the signatures of the document as it is not created yet.
**So we can remove the `signatures` argument in the `__init__()` of `Document` and all his subclass.**
It will be a big backward compatibility break. But the code will be more logic and simple.
### Deprecation first
Deprecation need to be done in a previous release (say %"0.60.0" for example).
It will be Deprecated gracefully with warnings, thanks to python deprecation system.
http://www.jaggedverge.com/2016/09/deprecation-warnings-in-python/
To ease the migration, perhaps start by set the argument as Optional with deprecationWarning.
Then remove it in a future version...
### Previous thoughts
All documents classes inherit of the `Document` class.
The `Document` class has a required `signatures` parameter which type is `List[str]`.
But most of the subclass does not have any signature when creating an instance.
So, when `None` is passed, the subclass handle it differently.
See `Identity` subclass handling (and the fact that you must provide a `None` parameter):
```python
def __init__(
self,
version: int,
currency: str,
pubkey: str,
uid: str,
ts: BlockUID,
signature: Optional[str],
) -> None:
...
if signature:
super().__init__(version, currency, [signature])
else:
super().__init__(version, currency, [])
```
See `Membership` subclass, consider it to be the best way to do it:
```python
def __init__(
self,
version: int,
currency: str,
issuer: str,
membership_ts: BlockUID,
membership_type: str,
uid: str,
identity_ts: BlockUID,
signature: Optional[str] = None,
) -> None:
...
super().__init__(version, currency, [signature] if signature else [])
```
Here, the `signature` parameter is not required, and we prepare a `signatures` parameter for the parent `Document` class.
We should do it for all subclass of `Document`, being careful as some are multi-signature.1.0.0Vincent TexierVincent Texierhttps://git.duniter.org/clients/python/duniterpy/-/issues/17Identity document changed2019-07-31T17:05:34+02:00Cédric MoreauIdentity document changedOriginal changes:
- https://github.com/ucoin-io/ucoin/issues/266 (blocktime reference instead of arbitrary time)
- https://github.com/ucoin-io/ucoin/issues/262 (SHA1 -> SHA256)
- https://github.com/ucoin-io/ucoin/issues/327 (Version: 2)
...Original changes:
- https://github.com/ucoin-io/ucoin/issues/266 (blocktime reference instead of arbitrary time)
- https://github.com/ucoin-io/ucoin/issues/262 (SHA1 -> SHA256)
- https://github.com/ucoin-io/ucoin/issues/327 (Version: 2)
---
There is now an Identity document, previously known as "self-certification". It has a new structure like the following example taken from protocol:
```
Version: 2
Type: Identity
Currency: beta_brousouf
Issuer: HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
UniqueID: lolcat
Timestamp: 32-DB30D958EE5CB75186972286ED3F4686B8A1C2CD
J3G9oM5AKYZNLAB5Wx499w61NuUoS57JVccTShUbGpCMjCqj9yXXqNq7dyZpDWA6BxipsiaMZhujMeBfCznzyci
```
The main changes are:
- A full document with fields, notably headers Version, Type and Issuer
- Field Version now equals `2`
- Timestamp is now a blocktime reference (or BLOCK_UID), so an identity cannot be created with an arbitrary future time
UCPv0.2