-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨
save_exchange_record
should be Optional (#1195)
* ✨ `save_exchange_record` should be Optional * ✨ Deduplicate `save_exchange_record` Defines a helper class `SaveExchangeRecordField`, with `auto_remove` property, and is extended where needed * 🐛 Fix class inheritance
- Loading branch information
Showing
8 changed files
with
46 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
save_exchange_record_field = Field( | ||
default=None, | ||
description=( | ||
"Controls exchange record retention after exchange is complete. None uses " | ||
"wallet default (typically to delete), true forces save, false forces delete." | ||
), | ||
) | ||
|
||
|
||
class SaveExchangeRecordField(BaseModel): | ||
save_exchange_record: Optional[bool] = save_exchange_record_field | ||
|
||
@property | ||
def auto_remove(self) -> Optional[bool]: | ||
"""Returns the inverse of save_exchange_record if set, otherwise None.""" | ||
if self.save_exchange_record is None: | ||
return None | ||
return not self.save_exchange_record |