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

Royalty example #3

Merged
merged 4 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34714.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.SmartContract.SampleRoyaltyNEP11Token", "Example.SmartContract.SampleRoyaltyNEP11Token.csproj", "{E363C475-EB64-48BD-A032-B13F48156BE2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E363C475-EB64-48BD-A032-B13F48156BE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E363C475-EB64-48BD-A032-B13F48156BE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E363C475-EB64-48BD-A032-B13F48156BE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E363C475-EB64-48BD-A032-B13F48156BE2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {21916810-7630-4DA1-881A-1413447D8521}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2015-2024 The Neo Project.
//
// SampleNonDivisibleNEP11.cs file belongs to the neo project and is free
// SampleRoyaltyNEP11Token.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
Expand All @@ -20,14 +20,14 @@
namespace NonDivisibleNEP11
{
/// <inheritdoc />
[DisplayName("SampleNonDivisibleNEP11Token")]
[DisplayName("SampleRoyaltyNEP11Token")]
[ContractAuthor("core-dev", "dev@neo.org")]
[ContractVersion("0.0.1")]
[ContractDescription("A sample NonDivisibleNEP11 token")]
[ContractDescription("A sample of NEP-11 Royalty Feature")]
[ContractSourceCode("https://github.com/neo-project/neo-devpack-dotnet/tree/master/examples/")]
[ContractPermission(Permission.WildCard, Method.WildCard)]
[SupportedStandards(NepStandard.Nep11)]
public class SampleNonDivisibleNEP11Token : Nep11Token<Nep11TokenState>
public class SampleRoyaltyNEP11Token : Nep11Token<Nep11TokenState>
{
#region Owner

Expand Down Expand Up @@ -109,7 +109,7 @@ public static void Mint(UInt160 to)
BigInteger tokenId = CurrentCount();
Nep11TokenState nep11TokenState = new Nep11TokenState()
{
Name = "SampleNep11Token",
Name = "SampleRoyaltyNep11Token",
Owner = to
};
Mint((ByteString)tokenId, nep11TokenState);
Expand All @@ -135,7 +135,7 @@ private static void IncreaseCount()

#region Example.SmartContract.NEP11

public override string Symbol { [Safe] get => "SampleNonDivisibleNEP11Token"; }
public override string Symbol { [Safe] get => "SampleRoyalty"; }

#endregion

Expand All @@ -159,6 +159,14 @@ public static void SetRoyaltyInfo(ByteString tokenId, Map<string, object>[] roya
Storage.Put(PrefixRoyalty + tokenId, StdLib.Serialize(royaltyInfos));
}

/// <summary>
/// This implements Royalty Standard: https://github.com/neo-project/proposals/pull/155/
/// This method returns a map of NeoVM Array stack item with single or multi array, each array includes royaltyRecipient and royaltyAmount
/// </summary>
/// <param name="tokenId">tokenId</param>
/// <param name="royaltyToken">royaltyToken hash for payment</param>
/// <param name="salePrice">royaltyToken amount for payment</param>
/// <returns>royaltyInfo</returns>
[Safe]
public static Map<string, object>[] RoyaltyInfo(ByteString tokenId, UInt160 royaltyToken, BigInteger salePrice)
{
Expand All @@ -183,7 +191,7 @@ public static Map<string, object>[] RoyaltyInfo(ByteString tokenId, UInt160 roya
[Safe]
public static bool Verify() => IsOwner();

public static bool Update(ByteString nefFile, string manifest, object data)
public static bool Update(ByteString nefFile, ByteString manifest, object data)
{
ExecutionEngine.Assert(IsOwner() == false, "No Authorization!");
ContractManagement.Update(nefFile, manifest, data);
Expand Down
12 changes: 6 additions & 6 deletions neo-devpack-dotnet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.SmartContract.ZKP",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.SmartContract.Analyzer.UnitTests", "tests\Neo.SmartContract.Analyzer.UnitTests\Neo.SmartContract.Analyzer.UnitTests.csproj", "{F30E2375-012A-4A38-985B-31CB7DBA4D28}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.SmartContract.NonDivisibleNEP11", "examples\Example.SmartContract.NonDivisibleNEP11\Example.SmartContract.NonDivisibleNEP11.csproj", "{4816CE4A-7C82-499A-93EC-FC222F850951}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.SmartContract.SampleRoyaltyNEP11Token", "examples\Example.SmartContract.SampleRoyaltyNEP11Token\Example.SmartContract.SampleRoyaltyNEP11Token.csproj", "{E826275C-FAF9-4F0F-B755-41EC812D0B09}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -204,10 +204,10 @@ Global
{F30E2375-012A-4A38-985B-31CB7DBA4D28}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F30E2375-012A-4A38-985B-31CB7DBA4D28}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F30E2375-012A-4A38-985B-31CB7DBA4D28}.Release|Any CPU.Build.0 = Release|Any CPU
{4816CE4A-7C82-499A-93EC-FC222F850951}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4816CE4A-7C82-499A-93EC-FC222F850951}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4816CE4A-7C82-499A-93EC-FC222F850951}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4816CE4A-7C82-499A-93EC-FC222F850951}.Release|Any CPU.Build.0 = Release|Any CPU
{E826275C-FAF9-4F0F-B755-41EC812D0B09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E826275C-FAF9-4F0F-B755-41EC812D0B09}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E826275C-FAF9-4F0F-B755-41EC812D0B09}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E826275C-FAF9-4F0F-B755-41EC812D0B09}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -244,7 +244,7 @@ Global
{5319BE3E-A5E9-4AFF-94D6-A669DA214F24} = {C10F9957-077F-42C8-B350-8607D4899B7E}
{141AD5BA-1735-4583-93B6-145CF72721E5} = {C10F9957-077F-42C8-B350-8607D4899B7E}
{F30E2375-012A-4A38-985B-31CB7DBA4D28} = {D5266066-0AFD-44D5-A83E-2F73668A63C8}
{4816CE4A-7C82-499A-93EC-FC222F850951} = {C10F9957-077F-42C8-B350-8607D4899B7E}
{E826275C-FAF9-4F0F-B755-41EC812D0B09} = {C10F9957-077F-42C8-B350-8607D4899B7E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6DA935E1-C674-4364-B087-F1B511B79215}
Expand Down