Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyfungible-v2 time constraint #28

Open
bart-kuma opened this issue Sep 28, 2022 · 3 comments
Open

Polyfungible-v2 time constraint #28

bart-kuma opened this issue Sep 28, 2022 · 3 comments

Comments

@bart-kuma
Copy link

bart-kuma commented Sep 28, 2022

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,

  1. The seller will pick a date
  2. Now we have to convert the date to seconds seconds = selected-time - current-time
  3. Then to number of blocks blocks = (seconds / average block-time)
  4. 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,

  1. We have to convert the timeout block-height back to seconds seconds = (current-block-height - timeout) / average block-time.
  2. Add the seconds to the current epoch and then show it to the users.

This method has cons like,

  1. The calculated timeout while displaying for the users will not be the same as the seller selected while listing.
  2. The average block time may be inconsistent. Therefore the timeout can happen before the seller's expected time.
  3. Displaying the block height directly to the user is not a good practice and affects the UX of the marketplace.
  4. 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:

  1. Need to change the condition based on block-time in ledger contract
  2. 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.

@kitty-kad
Copy link

kitty-kad commented Oct 4, 2022

I like this proposal. I know other blockchains tend to use block height often, but here it seems good to use block-time.

Especially since block time and time based operations are natively supported in Pact,

@Luzzotica
Copy link
Contributor

I, too, am a fan.
I haven't interacted too much with frontend development for Marmalade tokens, but I suspect those two things caused you more than a little bit of a headache.
How can we push this forward?

@bart-kuma
Copy link
Author

I, too, am a fan. I haven't interacted too much with frontend development for Marmalade tokens, but I suspect those two things caused you more than a little bit of a headache. How can we push this forward?

Hey, yeah, it caused much trouble during development.
I have already mentioned the files that need to be changed.
And I have implemented the same changes in my dev environment, which is ready to launch. I have some demo videos in our discord.
The only issue will be pushing it to the chain, as interfaces are not upgradeable. It has to be a new interface, something like poly-fungible-v3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants