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

OmniFlix NFT (x/onft) staked voting module #838

Merged
merged 14 commits into from
Jul 8, 2024
Merged

Conversation

NoahSaso
Copy link
Member

@NoahSaso NoahSaso commented Jun 7, 2024

This PR upgrades cw-multi-test to v0.20.1 so that we can add custom Stargate query and message handlers to mock Omniflix's x/onft module.

dao-voting-onft-staked

This is a basic implementation of an NFT staking contract that supports
OmniFlix's NFT standard:
x/onft.

Staked tokens can be unbonded with a configurable unbonding period. Staked balances can be queried at any arbitrary height by external contracts. This contract implements the interface needed to be a DAO DAO voting module.

Stake process

Unlike the base cw721 smart contract, the x/onft SDK module doesn't support
executing a smart contract on NFT transfer, so the stake process is broken up
into three steps:

  1. The sender calls PrepareStake to inform this staking contract of the NFTs
    that are about to be staked. This will succeed only if the sender currently
    owns the NFT(s).
  2. The sender then transfers the NFT(s) to the staking contract.
  3. The sender calls ConfirmStake on this staking contract which confirms the
    NFTs were transferred to it and registers the stake.

In case this process is interrupted, or executed incorrectly (e.g. the sender
accidentally transfers an NFT to the staking contract without first preparing
it), there is also a CancelStake action to help recover NFTs. If called by:

  • the original stake preparer, the preparation will be canceled, and the NFT(s)
    will be sent back if the staking contract owns them.
  • the current NFT(s) owner, the preparation will be canceled, if any.
  • the DAO, the preparation will be canceled (if any exists), and the NFT(s) will
    be sent to the specified recipient (if the staking contract owns them). if no
    recipient is specified but the NFT was prepared, it will be sent back to the
    preparer.

The recipient field only applies when the sender is the DAO. In the other cases,
the NFT(s) will always be sent back to the sender. Note: if the NFTs were sent
to the staking contract, but no stake was prepared, only the DAO will be able to
correct this and send them somewhere.

The PrepareStake step overrides any previous PrepareStake calls as long as
the new sender owns the NFT(s) and the first stake was never confirmed (which
should be impossible if someone else now owns the NFT(s)). Thus there is no
combination of messages or steps where someone can stake nor prevent stake when
it would otherwise be valid. A stake is only ever confirmed if it was prepared
and transferred by the same address confirming, and the DAO can always recover
an NFT that accidentally skipped the preparation step.

Copy link

codecov bot commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 99.50025% with 10 lines in your changes missing coverage. Please review.

Project coverage is 96.53%. Comparing base (87485be) to head (b61a51e).
Report is 3 commits behind head on development.

Files Patch % Lines
...oting-onft-staked/src/testing/omniflix_stargate.rs 96.00% 5 Missing ⚠️
...s/voting/dao-voting-onft-staked/src/testing/app.rs 80.00% 3 Missing ⚠️
contracts/voting/dao-voting-onft-staked/src/msg.rs 80.00% 1 Missing ⚠️
...voting/dao-voting-onft-staked/src/testing/tests.rs 99.88% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           development     #838      +/-   ##
===============================================
+ Coverage        96.26%   96.53%   +0.27%     
===============================================
  Files              209      229      +20     
  Lines            53514    60562    +7048     
===============================================
+ Hits             51513    58466    +6953     
- Misses            2001     2096      +95     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@NoahSaso NoahSaso marked this pull request as ready for review June 17, 2024 22:15
@NoahSaso NoahSaso merged commit 5918cbe into development Jul 8, 2024
9 checks passed
@NoahSaso NoahSaso deleted the noah/omniflix branch July 8, 2024 22:33
ismellike added a commit to Arena-DAO/dao-contracts that referenced this pull request Jul 19, 2024
commit 0c09c62
Author: Gabriel Lopez <[email protected]>
Date:   Thu Jul 18 20:56:03 2024 -0500

    Revert integration_tests.yml

commit c46937a
Author: Gabriel Lopez <[email protected]>
Date:   Wed Jul 17 13:18:11 2024 -0500

    Update basic.yml to cache only cargo deps

    Nightly toolchain is required for integration_tests

commit 7773cb0
Author: Gabriel Lopez <[email protected]>
Date:   Wed Jul 17 12:45:09 2024 -0500

    Set integration_tests toolchain to latest stable

commit 74aea83
Author: Gabriel Lopez <[email protected]>
Date:   Thu Jul 11 02:21:52 2024 -0500

    Cargo schema + fix orch wasm build and tests

commit e8081ac
Author: Gabriel Lopez <[email protected]>
Date:   Thu Jul 11 00:40:32 2024 -0500

    Fix cargo stuff

commit d5a1850
Merge: 87925b2 5918cbe
Author: Gabriel Lopez <[email protected]>
Date:   Wed Jul 10 23:48:52 2024 -0500

    Merge branch 'development' into feature/cw-orch-interface

commit 87925b2
Author: Gabriel Lopez <[email protected]>
Date:   Wed Jul 10 23:47:50 2024 -0500

    Add cache to basic.yml

commit 2951f8c
Author: Gabriel Lopez <[email protected]>
Date:   Wed Jul 10 23:47:40 2024 -0500

    Fix lints

    Also updates just lint to match basic.yml

commit 5918cbe
Author: noah <[email protected]>
Date:   Mon Jul 8 18:33:22 2024 -0400

    OmniFlix NFT (x/onft) staked voting module (DA0-DA0#838)

commit ac249f4
Author: noah <[email protected]>
Date:   Sat Jul 6 23:11:22 2024 -0400

    Improve pre-propose proposal creation permission granularity (and bump versions to v2.5.0) (DA0-DA0#843)

commit 8be18d1
Author: bekauz <[email protected]>
Date:   Mon Jun 17 18:05:24 2024 +0200

    staking rewards distribution followup (DA0-DA0#835)

    Co-authored-by: Noah Saso <[email protected]>
    Co-authored-by: Jake Hartnell <[email protected]>

commit bb8224e
Author: noah <[email protected]>
Date:   Thu Jun 6 00:32:12 2024 -0400

    moved .cargo/config to .cargo/config.toml (DA0-DA0#837)

commit 87485be
Author: bekauz <[email protected]>
Date:   Wed May 22 18:39:06 2024 +0200

    bump cw-std to 1.5.4 (DA0-DA0#824)

commit 8c945ac
Author: Kayanski <[email protected]>
Date:   Fri May 17 09:09:32 2024 +0000

    Added other derives

commit f720001
Author: Kayanski <[email protected]>
Date:   Fri May 17 09:06:45 2024 +0000

    Added derive fns

commit 003f87d
Author: Kayanski <[email protected]>
Date:   Fri May 17 08:54:07 2024 +0000

    Fix tests

commit 88ec5ed
Author: Kayanski <[email protected]>
Date:   Fri May 17 08:52:54 2024 +0000

    Added Queryfns on voting

commit 3440d34
Author: Kayanski <[email protected]>
Date:   Fri May 17 08:06:38 2024 +0000

    Finalize test changes

commit 9492e37
Author: Kayanski <[email protected]>
Date:   Fri May 17 07:40:35 2024 +0000

    More tests

commit 5883c87
Author: Kayanski <[email protected]>
Date:   Thu May 16 17:24:41 2024 +0000

    Added tests with cw-orch

commit b01de1c
Author: Kayanski <[email protected]>
Date:   Thu May 16 14:41:02 2024 +0000

    First test modifications

commit 3ab7017
Author: noah <[email protected]>
Date:   Mon Apr 1 20:04:11 2024 +0200

    Update versions to 2.4.2 (DA0-DA0#817)

commit caea80a
Author: noah <[email protected]>
Date:   Mon Apr 1 19:32:50 2024 +0200

    support kujira's /kujira.denom... tokenfactory fork (DA0-DA0#816)
ismellike added a commit to Arena-DAO/dao-contracts that referenced this pull request Jul 19, 2024
commit aff2c4e
Author: Gabe <[email protected]>
Date:   Fri Jul 19 12:08:16 2024 -0500

    Revert basic.yml

    i think caching is causing issues with the cargo.lock

commit 6db4637
Author: Gabe <[email protected]>
Date:   Fri Jul 19 12:06:17 2024 -0500

    Lint + not(target_arch = "wasm32") in lib.rs

commit 18241d0
Merge: 761a780 87847fd
Author: Gabe <[email protected]>
Date:   Fri Jul 19 10:58:25 2024 -0500

    Merge branch 'pr/1' into feature/cw-orch-interface

commit 761a780
Author: Gabe <[email protected]>
Date:   Fri Jul 19 02:40:02 2024 -0500

    Update to cw-orch .24.1

commit 0c09c62
Author: Gabriel Lopez <[email protected]>
Date:   Thu Jul 18 20:56:03 2024 -0500

    Revert integration_tests.yml

commit c46937a
Author: Gabriel Lopez <[email protected]>
Date:   Wed Jul 17 13:18:11 2024 -0500

    Update basic.yml to cache only cargo deps

    Nightly toolchain is required for integration_tests

commit 7773cb0
Author: Gabriel Lopez <[email protected]>
Date:   Wed Jul 17 12:45:09 2024 -0500

    Set integration_tests toolchain to latest stable

commit 87847fd
Author: hard-nett <[email protected]>
Date:   Sat Jul 13 18:53:38 2024 +0000

    add cw-orch to external contract

commit 74aea83
Author: Gabriel Lopez <[email protected]>
Date:   Thu Jul 11 02:21:52 2024 -0500

    Cargo schema + fix orch wasm build and tests

commit e8081ac
Author: Gabriel Lopez <[email protected]>
Date:   Thu Jul 11 00:40:32 2024 -0500

    Fix cargo stuff

commit d5a1850
Merge: 87925b2 5918cbe
Author: Gabriel Lopez <[email protected]>
Date:   Wed Jul 10 23:48:52 2024 -0500

    Merge branch 'development' into feature/cw-orch-interface

commit 87925b2
Author: Gabriel Lopez <[email protected]>
Date:   Wed Jul 10 23:47:50 2024 -0500

    Add cache to basic.yml

commit 2951f8c
Author: Gabriel Lopez <[email protected]>
Date:   Wed Jul 10 23:47:40 2024 -0500

    Fix lints

    Also updates just lint to match basic.yml

commit 5918cbe
Author: noah <[email protected]>
Date:   Mon Jul 8 18:33:22 2024 -0400

    OmniFlix NFT (x/onft) staked voting module (DA0-DA0#838)

commit ac249f4
Author: noah <[email protected]>
Date:   Sat Jul 6 23:11:22 2024 -0400

    Improve pre-propose proposal creation permission granularity (and bump versions to v2.5.0) (DA0-DA0#843)

commit 8be18d1
Author: bekauz <[email protected]>
Date:   Mon Jun 17 18:05:24 2024 +0200

    staking rewards distribution followup (DA0-DA0#835)

    Co-authored-by: Noah Saso <[email protected]>
    Co-authored-by: Jake Hartnell <[email protected]>

commit bb8224e
Author: noah <[email protected]>
Date:   Thu Jun 6 00:32:12 2024 -0400

    moved .cargo/config to .cargo/config.toml (DA0-DA0#837)

commit 87485be
Author: bekauz <[email protected]>
Date:   Wed May 22 18:39:06 2024 +0200

    bump cw-std to 1.5.4 (DA0-DA0#824)

commit 8c945ac
Author: Kayanski <[email protected]>
Date:   Fri May 17 09:09:32 2024 +0000

    Added other derives

commit f720001
Author: Kayanski <[email protected]>
Date:   Fri May 17 09:06:45 2024 +0000

    Added derive fns

commit 003f87d
Author: Kayanski <[email protected]>
Date:   Fri May 17 08:54:07 2024 +0000

    Fix tests

commit 88ec5ed
Author: Kayanski <[email protected]>
Date:   Fri May 17 08:52:54 2024 +0000

    Added Queryfns on voting

commit 3440d34
Author: Kayanski <[email protected]>
Date:   Fri May 17 08:06:38 2024 +0000

    Finalize test changes

commit 9492e37
Author: Kayanski <[email protected]>
Date:   Fri May 17 07:40:35 2024 +0000

    More tests

commit 5883c87
Author: Kayanski <[email protected]>
Date:   Thu May 16 17:24:41 2024 +0000

    Added tests with cw-orch

commit b01de1c
Author: Kayanski <[email protected]>
Date:   Thu May 16 14:41:02 2024 +0000

    First test modifications

commit 3ab7017
Author: noah <[email protected]>
Date:   Mon Apr 1 20:04:11 2024 +0200

    Update versions to 2.4.2 (DA0-DA0#817)

commit caea80a
Author: noah <[email protected]>
Date:   Mon Apr 1 19:32:50 2024 +0200

    support kujira's /kujira.denom... tokenfactory fork (DA0-DA0#816)
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

Successfully merging this pull request may close these issues.

2 participants