Skip to content

Commit

Permalink
Merge pull request #1 from superboyiii/rc2
Browse files Browse the repository at this point in the history
For RC2
  • Loading branch information
superboyiii authored May 14, 2021
2 parents 116e223 + 05a0cd4 commit 10b1d17
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 229 deletions.
39 changes: 0 additions & 39 deletions csharp/NEP17/AssetStorage.cs

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

74 changes: 44 additions & 30 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,36 +11,49 @@ 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
[InitialValue("NhGobEnuWX5rVdpnuZZAZExPoRs5J6D2Sb", ContractParameterType.Hash160)]
private static readonly UInt160 Owner = default;

static readonly ulong MaxSupply = 10_000_000_000_000_000;
static readonly ulong InitialSupply = 2_000_000_000_000_000;
static readonly ulong TokensPerNEO = 1_000_000_000;
static readonly ulong TokensPerGAS = 1;
#endregion

#region Notifications
[DisplayName("Transfer")]
public static event Action<UInt160, UInt160, BigInteger> OnTransfer;
#endregion

// 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();

[Safe]
public static string Symbol() => "NTT";

[Safe]
public static ulong Decimals() => 8;

[Safe]
public static UInt160 GetOwner() => Owner;

private static readonly UInt160 owner = default;
private static readonly byte[] ownerKey = "owner".ToByteArray();
private static bool IsOwner() => Runtime.CheckWitness(GetOwner());
public override byte Decimals() => 8;
public override string Symbol() => "NEP17";

public static void _deploy(object data, bool update)
{
if (update) return;
Storage.Put(Storage.CurrentContext, ownerKey, owner);
}

public static UInt160 GetOwner()
{
return (UInt160)Storage.Get(Storage.CurrentContext, ownerKey);
}
public static new void Mint(UInt160 account, BigInteger amount)
{
if (!IsOwner()) throw new InvalidOperationException("No Authorization!");
Nep17Token.Mint(account, amount);
}

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

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;
}
}
}
26 changes: 0 additions & 26 deletions csharp/NEP17/TotalSupplyStorage.cs

This file was deleted.

0 comments on commit 10b1d17

Please sign in to comment.