-
Notifications
You must be signed in to change notification settings - Fork 277
feat(near-contract-standards): NEP-199 - Non-Fungible Token Royalties and Payouts #1077
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
Draft
ruseinov
wants to merge
50
commits into
near:master
Choose a base branch
from
ruseinov:feat/payout
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+625
−9
Draft
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
8a1c2da
payout
ymc182 da97136
d
ymc182 34c576f
included the sim
ymc182 7b58745
sim
ymc182 ca930d7
remove macros, add examples and docs
ruseinov 0406030
add royalties storage prefix
ruseinov bd9c9fe
Merge branch 'master' into feat/payout
ruseinov c8bd137
examples
ruseinov 1e62834
Merge branch 'master' into feat/payout
ruseinov 8e5e777
remove near-sdk-sim
ruseinov 14ac453
Merge branch 'master' into feat/payout
frol 5da6f89
Merge branch 'master' into feat/payout
frol 9470437
Merge branch 'master' into feat/payout
ruseinov 98aeceb
update CHANGELOG.md
ruseinov 3d7a4ad
fix test
ruseinov 562b284
fixes and tests
ruseinov 933c029
more tests
ruseinov 2f2779d
better comment
ruseinov a5c67f7
Merge branch 'master' into feat/payout
ruseinov 6f07b52
return the missing check
ruseinov e4da342
fix ci
ruseinov 743eb06
Merge branch 'master' into feat/payout
ruseinov b3716bf
Merge branch 'master' into feat/payout
ruseinov d76ff5d
fix review comments
ruseinov f3b3594
use TreeMap for rolayties storage
ruseinov 815a9ea
apply review suggestions
ruseinov d809519
Merge branch 'master' into feat/payout
ruseinov c2e990e
fixes
ruseinov c3d8b67
fixes
ruseinov ee59a72
fixes
ruseinov 5ec54b3
fix
ruseinov 71dc47b
Merge branch 'master' into feat/payout
ruseinov b7a0a22
add tests
ruseinov 5c20528
fix lint
ruseinov 2db048b
fix nits
ruseinov 279a7ee
simplify royalties and more tests
ruseinov 369faaa
add comment
ruseinov e080566
Merge branch 'master' into feat/payout
ruseinov 9e01a09
validate apply_percent
ruseinov 423bdc9
fix
ruseinov 30175c3
Merge branch 'master' into feat/payout
ruseinov 5829c77
fix tests
ruseinov b59fc92
Merge branch 'master' into feat/payout
ruseinov 312f4ac
fix payouts
ruseinov f2e709c
fix NearToken
ruseinov f2e3e08
Merge branch 'master' into feat/payout
ruseinov 66ccf2c
fix workflow name
ruseinov 1fa86f7
fix
ruseinov 5a574b4
fix compilation
ruseinov 7745888
Merge branch 'master' into feat/payout
ruseinov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| mod test_approval; | ||
| mod test_core; | ||
| mod test_enumeration; | ||
| mod test_payout; | ||
| mod utils; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
examples/non-fungible-token/tests/workspaces/test_payout.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| use crate::utils::{init, TOKEN_ID}; | ||
| use near_contract_standards::non_fungible_token::Token; | ||
| use near_sdk::json_types::U128; | ||
| use near_sdk::NearToken; | ||
|
|
||
| const ONE_YOCTO: NearToken = NearToken::from_yoctonear(1); | ||
|
|
||
| #[tokio::test] | ||
| async fn simulate_payout() -> anyhow::Result<()> { | ||
| let worker = near_workspaces::sandbox().await?; | ||
| let (nft_contract, alice, _, _) = init(&worker).await?; | ||
|
|
||
| let res = nft_contract | ||
| .call("nft_payout") | ||
| .args_json((TOKEN_ID, U128::from(1), Option::<u32>::None)) | ||
| .max_gas() | ||
| .transact() | ||
| .await?; | ||
| assert!(res.is_success()); | ||
|
|
||
| // A single NFT transfer event should have been logged: | ||
| assert_eq!(res.logs().len(), 0); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn nft_transfer_payout() -> anyhow::Result<()> { | ||
| let worker = near_workspaces::sandbox().await?; | ||
| let (nft_contract, alice, _, _) = init(&worker).await?; | ||
|
|
||
| let token = | ||
| nft_contract.call("nft_token").args_json((TOKEN_ID,)).view().await?.json::<Token>()?; | ||
| assert_eq!(token.owner_id.to_string(), nft_contract.id().to_string()); | ||
|
|
||
| let res = nft_contract | ||
| .call("nft_transfer_payout") | ||
| .args_json(( | ||
| alice.id(), | ||
| TOKEN_ID, | ||
| Option::<u64>::None, | ||
| Some("simple transfer".to_string()), | ||
| U128::from(1), | ||
| Option::<u32>::None, | ||
| )) | ||
| .max_gas() | ||
| .deposit(ONE_YOCTO) | ||
| .transact() | ||
| .await?; | ||
|
|
||
| assert!(res.is_success()); | ||
|
|
||
| // A single NFT transfer event should have been logged: | ||
| assert_eq!(res.logs().len(), 1); | ||
|
|
||
| let token = | ||
| nft_contract.call("nft_token").args_json((TOKEN_ID,)).view().await?.json::<Token>()?; | ||
| assert_eq!(token.owner_id.to_string(), alice.id().to_string()); | ||
|
|
||
| Ok(()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.