Current Problem
It's a bit hard to handle the UI/UX for NFT sales in poly-fungible-v2 based contracts because it uses block-height as the time constraint for time dependant functions instead of block-time.
While listing an NFT for sale, the seller has to provide how long a token should be listed (timeout). block-height is used to check the timeout. To calculate the block height for the timeout,
- The seller will pick a date
- Now we have to convert the date to seconds
seconds = selected-time - current-time
- Then to number of blocks
blocks = (seconds / average block-time)
- We have to add the blocks to current-block-height
timeout = current-block-height + blocks and send it to the contract.
Now while displaying the timeout after the token listing has completed, we will have to convert the block-height back to user-understandable time format. To do this,
- We have to convert the timeout block-height back to seconds
seconds = (current-block-height - timeout) / average block-time.
- Add the seconds to the current epoch and then show it to the users.
This method has cons like,
- The calculated timeout while displaying for the users will not be the same as the seller selected while listing.
- The average block time may be inconsistent. Therefore the timeout can happen before the seller's expected time.
- Displaying the block height directly to the user is not a good practice and affects the UX of the marketplace.
- The calculated time may not be the same for users in different time zones.
Proposal
To use block-time as the constraint to validate time dependant functions because it will be a lot easier for marketplaces to display time, and it serves the same purpose as the block-height in validating the expiry of the token listing.
Files to be changed:
- Need to change the condition based on
block-time in ledger contract
- Need to change the type of
timeout from integer to time in poly-fungible-v2 interface
I will be happy to collaborate for implementing these changes.
References
I'm sharing some discussions in the eth community regarding block-time vs block-height.
Current Problem
It's a bit hard to handle the UI/UX for NFT sales in
poly-fungible-v2based contracts because it usesblock-heightas the time constraint for time dependant functions instead ofblock-time.While listing an NFT for sale, the seller has to provide how long a token should be listed
(timeout).block-heightis used to check the timeout. To calculate theblock heightfor the timeout,seconds = selected-time - current-timeblocks = (seconds / average block-time)timeout = current-block-height + blocksand send it to the contract.Now while displaying the
timeoutafter the token listing has completed, we will have to convert theblock-heightback to user-understandable time format. To do this,seconds = (current-block-height - timeout) / average block-time.This method has cons like,
Proposal
To use
block-timeas the constraint to validate time dependant functions because it will be a lot easier for marketplaces to display time, and it serves the same purpose as theblock-heightin validating the expiry of the token listing.Files to be changed:
block-timeinledgercontracttimeoutfromintegertotimeinpoly-fungible-v2interfaceI will be happy to collaborate for implementing these changes.
References
I'm sharing some discussions in the eth community regarding block-time vs block-height.