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

sync to Neo.SmartContract.Framework v3.0.0-rc3 #44

Merged
merged 14 commits into from
Jun 29, 2021
37 changes: 0 additions & 37 deletions csharp/NEP17/AssetStorage.cs

This file was deleted.

49 changes: 0 additions & 49 deletions csharp/NEP17/NEP17.Crowdsale.cs

This file was deleted.

32 changes: 0 additions & 32 deletions csharp/NEP17/NEP17.Methods.cs

This file was deleted.

46 changes: 0 additions & 46 deletions csharp/NEP17/NEP17.Owner.cs

This file was deleted.

62 changes: 43 additions & 19 deletions csharp/NEP17/NEP17.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Native;
using Neo.SmartContract.Framework.Services;
using System;
using System.ComponentModel;
using System.Numerics;

namespace Neo.SmartContract.Examples
Expand All @@ -10,28 +11,51 @@ namespace Neo.SmartContract.Examples
[ManifestExtra("Description", "This is a NEP17 example")]
[SupportedStandards("NEP-17")]
[ContractPermission("*", "onNEP17Payment")]
public partial class NEP17Demo : Framework.SmartContract
public partial class NEP17Demo : Nep17Token
{
#region Token Settings
static readonly ulong MaxSupply = 10_000_000_000_000_000;
static readonly ulong InitialSupply = 2_000_000_000_000_000;
static readonly UInt160 Owner = "NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB".ToScriptHash();
static readonly ulong TokensPerNEO = 1_000_000_000;
static readonly ulong TokensPerGAS = 1;
#endregion
[InitialValue("NhGobEnuWX5rVdpnuZZAZExPoRs5J6D2Sb", ContractParameterType.Hash160)]
private static readonly UInt160 owner = default;
private static readonly byte[] ContractPrefix = new byte[] { 0x01, 0x01 };
superboyiii marked this conversation as resolved.
Show resolved Hide resolved
public static readonly StorageMap ContractMap = new StorageMap(Storage.CurrentContext, ContractPrefix);
private static readonly byte[] ownerKey = "owner".ToByteArray();
erikzhang marked this conversation as resolved.
Show resolved Hide resolved
private static bool IsOwner() => Runtime.CheckWitness(GetOwner());
public override byte Decimals() => 8;
public override string Symbol() => "NEP17";

#region Notifications
[DisplayName("Transfer")]
public static event Action<UInt160, UInt160, BigInteger> OnTransfer;
#endregion
public static void _deploy(object data, bool update)
{
if (update) return;
ContractMap.Put(ownerKey, owner);
}

// When this contract address is included in the transaction signature,
// this method will be triggered as a VerificationTrigger to verify that the signature is correct.
// For example, this method needs to be called when withdrawing token from the contract.
public static bool Verify() => IsOwner();
public static UInt160 GetOwner()
{
return (UInt160)Storage.Get(Storage.CurrentContext, ownerKey);
}
public static new void Mint(UInt160 account, BigInteger amount)
superboyiii marked this conversation as resolved.
Show resolved Hide resolved
{
if (!IsOwner()) throw new InvalidOperationException("No Authorization!");
Nep17Token.Mint(account, amount);
}

public static string Symbol() => "TokenSymbol";
public static new void Burn(UInt160 account, BigInteger amount)
{
if (!IsOwner()) throw new InvalidOperationException("No Authorization!");
Nep17Token.Burn(account, amount);
}

public static ulong Decimals() => 8;
public static bool Update(ByteString nefFile, string manifest, object data = null)
{
if (!IsOwner()) throw new InvalidOperationException("No Authorization!");
ContractManagement.Update(nefFile, manifest, data);
return true;
}

public static bool Destroy()
{
if (!IsOwner()) throw new InvalidOperationException("No Authorization!");
ContractManagement.Destroy();
return true;
}
}
}
6 changes: 3 additions & 3 deletions csharp/NEP17/NEP17.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Neo.SmartContract.Examples</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo.SmartContract.Framework" Version="3.0.0-preview5" />
<PackageReference Include="Neo.SmartContract.Framework" Version="3.0.0-rc3" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Message Text="Start NeoContract converter, Source File: $(TargetPath)" Importance="high">
</Message>
<Exec Command="neon -f &quot;$(TargetPath)&quot; -o" />
<Exec Command="nccs &quot;$(ProjectPath)&quot;" />
</Target>

</Project>
24 changes: 0 additions & 24 deletions csharp/NEP17/TotalSupplyStorage.cs

This file was deleted.