You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The main idea here is to export a wrapper that can accept either Expiration or a Duration, and turns it into an Expiration.
The main benefit is that it removes all custom logic that a contract need to handle both cases if a contract wants to accept either one of the options.
Approve{spender:String,token_id:String,expires:Deadline,// or Option<Deadline>,},
In contract, we can easily turn deadline into expiration:
let expiration = expires.into_expiration(&env.block)
Or using an optional Deadline
let expiration = expires.unwrap_or_default().into_expiration(&env.block)
Now the user can specify either a specific block/time or some random duration
NOTE:
The #[serde(untagged)] here is to provide a nicer UI, should work nicely given untagged should be supported now and Expiration and Duration enums doesn't have an overlapping values.
The text was updated successfully, but these errors were encountered:
interested to hear thoughts about this wrapper to live in cw-utils.
The main idea here is to export a wrapper that can accept either Expiration or a Duration, and turns it into an Expiration.
The main benefit is that it removes all custom logic that a contract need to handle both cases if a contract wants to accept either one of the options.
Example:
Looking at cw721
ExecuteMsg::Approve
:can be turned into:
In contract, we can easily turn deadline into expiration:
Or using an optional Deadline
Now the user can specify either a specific block/time or some random duration
NOTE:
The
#[serde(untagged)]
here is to provide a nicer UI, should work nicely given untagged should be supported now and Expiration and Duration enums doesn't have an overlapping values.The text was updated successfully, but these errors were encountered: