Skip to content

Commit

Permalink
fix: pydantic 2 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Dec 11, 2023
1 parent 95749d0 commit e7b0340
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ape_safe/client/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ def get_confirmations(self, safe_tx_hash: SafeTxID) -> Iterator[SafeTxConfirmati

def post_transaction(self, safe_tx: SafeTx, signaures: Dict[AddressType, MessageSignature]):
safe_tx_data = UnexecutedTxData.from_safe_tx(safe_tx, self.safe_details.threshold)

# NOTE: Using `construct` to avoid HexBytes pydantic v1 backimports issue.
safe_tx_data.confirmations.extend(
SafeTxConfirmation(
SafeTxConfirmation.construct(
owner=signer,
submissionDate=datetime.now(timezone.utc),
signature=sig.encode_rsv(),
Expand Down
4 changes: 3 additions & 1 deletion ape_safe/client/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ class UnexecutedTxData(BaseModel):

@classmethod
def from_safe_tx(cls, safe_tx: SafeTx, confirmations_required: int) -> "UnexecutedTxData":
return cls(
# NOTE: Using construct because of a HexBytes issue with pydantic v1 back imports.
# TODO: Switch to model_construct during v2 upgrade.
return cls.construct(
safe=safe_tx._verifyingContract_,
submissionDate=datetime.now(timezone.utc),
modified=datetime.now(timezone.utc),
Expand Down

0 comments on commit e7b0340

Please sign in to comment.