ApeWorX / ape

The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
https://apeworx.io
Apache License 2.0
884 stars 132 forks source link

TimestampConverter converts `timedelta` objects as `datetime.now(UTC) + timedelta` #2300

Open fubuloubu opened 1 month ago

fubuloubu commented 1 month ago

Not sure if I like that this is the case, or at least I ran into an issue where I expected that putting a timedelta object in the deployment params of a contract that expected a timedelta arg ended up making a quite large timedelta unexpectedly

https://github.com/ApeWorX/ape/blob/13ea95253a75d9576d5f89f6378254abda200e9e/src/ape/managers/converters.py#L229

Should this converter instead convert timedelta as td.total_seconds(), and then suggest in the docs to do datetime + timedelta for those scenarios where you want it to produce a specific timestamp and not a delta? e.g.

tx = contract.method(..., chain.pending_timestamp + timedelta(hours=1), ...)
linear[bot] commented 1 month ago

APE-1831 TimestampConverter converts `timedelta` objects as `datetime.now(UTC) + timedelta`