From d1980fc448d178b88ab57fb5abf151215f67cb59 Mon Sep 17 00:00:00 2001 From: Erik Zhang Date: Mon, 8 Jan 2018 15:58:15 +0800 Subject: [PATCH] upgrade to v2.5.4 1. Remove old APIs: `Neo.Account.SetVotes` and `Neo.Validator.Register` 2. Add `StorageMap` --- Installer/Properties/AssemblyInfo.cs | 2 +- Installer/source.extension.vsixmanifest | 2 +- Neo.ConvertTask/Properties/AssemblyInfo.cs | 2 +- .../Neo.SmartContract.Framework.csproj | 2 +- .../Services/Neo/Account.cs | 2 - .../Services/Neo/Helper.cs | 76 ++++++++++++++++++ .../Services/Neo/StorageMap.cs | 8 ++ .../Services/Neo/Validator.cs | 8 -- Template.CSharp/Neo.ConvertTask.dll | Bin 6144 -> 6144 bytes Template.CSharp/ProjectTemplate.csproj | 4 +- Template.CSharp/Properties/AssemblyInfo.cs | 2 +- Template.CSharp/packages_t.config | 2 +- Template.VB/My Project/AssemblyInfo.vb | 2 +- Template.VB/Neo.ConvertTask.dll | Bin 6144 -> 6144 bytes Template.VB/ProjectTemplate.vbproj | 4 +- Template.VB/packages_t.config | 2 +- 16 files changed, 96 insertions(+), 22 deletions(-) create mode 100644 Neo.SmartContract.Framework/Services/Neo/Helper.cs create mode 100644 Neo.SmartContract.Framework/Services/Neo/StorageMap.cs delete mode 100644 Neo.SmartContract.Framework/Services/Neo/Validator.cs diff --git a/Installer/Properties/AssemblyInfo.cs b/Installer/Properties/AssemblyInfo.cs index a6afac36f..227383e95 100644 --- a/Installer/Properties/AssemblyInfo.cs +++ b/Installer/Properties/AssemblyInfo.cs @@ -28,5 +28,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.5.2")] +[assembly: AssemblyVersion("2.5.4")] //[assembly: AssemblyFileVersion("1.6.1")] diff --git a/Installer/source.extension.vsixmanifest b/Installer/source.extension.vsixmanifest index 1b9221ea5..09444f928 100644 --- a/Installer/source.extension.vsixmanifest +++ b/Installer/source.extension.vsixmanifest @@ -1,7 +1,7 @@ - + NeoContractPlugin Allow users to create smart contract in Visual Studio. https://github.com/neo-project/neo-devpack-dotnet diff --git a/Neo.ConvertTask/Properties/AssemblyInfo.cs b/Neo.ConvertTask/Properties/AssemblyInfo.cs index 454984b74..fa72d606b 100644 --- a/Neo.ConvertTask/Properties/AssemblyInfo.cs +++ b/Neo.ConvertTask/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.5.2")] +[assembly: AssemblyVersion("2.5.4")] //[assembly: AssemblyFileVersion("1.6.1")] diff --git a/Neo.SmartContract.Framework/Neo.SmartContract.Framework.csproj b/Neo.SmartContract.Framework/Neo.SmartContract.Framework.csproj index 26187a1f6..56f76b14d 100644 --- a/Neo.SmartContract.Framework/Neo.SmartContract.Framework.csproj +++ b/Neo.SmartContract.Framework/Neo.SmartContract.Framework.csproj @@ -3,7 +3,7 @@ 2016-2017 The Neo Project Neo.SmartContract.Framework - 2.5.2 + 2.5.4 The Neo Project netstandard1.6;net40 Neo.SmartContract.Framework diff --git a/Neo.SmartContract.Framework/Services/Neo/Account.cs b/Neo.SmartContract.Framework/Services/Neo/Account.cs index 5b03c0a6c..834263911 100644 --- a/Neo.SmartContract.Framework/Services/Neo/Account.cs +++ b/Neo.SmartContract.Framework/Services/Neo/Account.cs @@ -12,8 +12,6 @@ public class Account { [Syscall("Neo.Account.GetVotes")] get; - [Syscall("Neo.Account.SetVotes")] - set; } [Syscall("Neo.Account.GetBalance")] diff --git a/Neo.SmartContract.Framework/Services/Neo/Helper.cs b/Neo.SmartContract.Framework/Services/Neo/Helper.cs new file mode 100644 index 000000000..58ba27444 --- /dev/null +++ b/Neo.SmartContract.Framework/Services/Neo/Helper.cs @@ -0,0 +1,76 @@ +using System.Numerics; + +namespace Neo.SmartContract.Framework.Services.Neo +{ + public static class Helper + { + public static StorageMap CreateMap(this StorageContext context, string prefix) + { + return new StorageMap + { + Context = context, + Prefix = prefix + }; + } + + public static void Delete(this StorageMap map, byte[] key) + { + byte[] k = map.Prefix.AsByteArray().Concat(new byte[] { 0 }).Concat(key); + Storage.Delete(map.Context, k); + } + + public static void Delete(this StorageMap map, string key) + { + byte[] k = map.Prefix.AsByteArray().Concat(new byte[] { 0 }).Concat(key.AsByteArray()); + Storage.Delete(map.Context, k); + } + + public static byte[] Get(this StorageMap map, byte[] key) + { + byte[] k = map.Prefix.AsByteArray().Concat(new byte[] { 0 }).Concat(key); + return Storage.Get(map.Context, k); + } + + public static byte[] Get(this StorageMap map, string key) + { + byte[] k = map.Prefix.AsByteArray().Concat(new byte[] { 0 }).Concat(key.AsByteArray()); + return Storage.Get(map.Context, k); + } + + public static void Put(this StorageMap map, byte[] key, byte[] value) + { + byte[] k = map.Prefix.AsByteArray().Concat(new byte[] { 0 }).Concat(key); + Storage.Put(map.Context, k, value); + } + + public static void Put(this StorageMap map, byte[] key, BigInteger value) + { + byte[] k = map.Prefix.AsByteArray().Concat(new byte[] { 0 }).Concat(key); + Storage.Put(map.Context, k, value); + } + + public static void Put(this StorageMap map, byte[] key, string value) + { + byte[] k = map.Prefix.AsByteArray().Concat(new byte[] { 0 }).Concat(key); + Storage.Put(map.Context, k, value); + } + + public static void Put(this StorageMap map, string key, byte[] value) + { + byte[] k = map.Prefix.AsByteArray().Concat(new byte[] { 0 }).Concat(key.AsByteArray()); + Storage.Put(map.Context, k, value); + } + + public static void Put(this StorageMap map, string key, BigInteger value) + { + byte[] k = map.Prefix.AsByteArray().Concat(new byte[] { 0 }).Concat(key.AsByteArray()); + Storage.Put(map.Context, k, value); + } + + public static void Put(this StorageMap map, string key, string value) + { + byte[] k = map.Prefix.AsByteArray().Concat(new byte[] { 0 }).Concat(key.AsByteArray()); + Storage.Put(map.Context, k, value); + } + } +} diff --git a/Neo.SmartContract.Framework/Services/Neo/StorageMap.cs b/Neo.SmartContract.Framework/Services/Neo/StorageMap.cs new file mode 100644 index 000000000..7e2375cbb --- /dev/null +++ b/Neo.SmartContract.Framework/Services/Neo/StorageMap.cs @@ -0,0 +1,8 @@ +namespace Neo.SmartContract.Framework.Services.Neo +{ + public class StorageMap + { + internal StorageContext Context; + internal string Prefix; + } +} diff --git a/Neo.SmartContract.Framework/Services/Neo/Validator.cs b/Neo.SmartContract.Framework/Services/Neo/Validator.cs deleted file mode 100644 index e55029768..000000000 --- a/Neo.SmartContract.Framework/Services/Neo/Validator.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Neo.SmartContract.Framework.Services.Neo -{ - public class Validator - { - [Syscall("Neo.Validator.Register")] - public static extern Validator Register(byte[] pubkey); - } -} diff --git a/Template.CSharp/Neo.ConvertTask.dll b/Template.CSharp/Neo.ConvertTask.dll index 3ff6590eb799ba09fd0b9676d2a5b21a385702bd..36cc5a81f3707bcd17d3e6d48e29440af8816273 100644 GIT binary patch delta 85 zcmV-b0IL6hFn}#v2mu1Ks|f7{5HljBwWg%=+2nE(DnzN`5<^u@= r00jU700002vzHQ00Rb|z4 - - ..\packages\Neo.SmartContract.Framework.2.5.2\lib\net40\Neo.SmartContract.Framework.dll + + ..\packages\Neo.SmartContract.Framework.2.5.4\lib\net40\Neo.SmartContract.Framework.dll True diff --git a/Template.CSharp/Properties/AssemblyInfo.cs b/Template.CSharp/Properties/AssemblyInfo.cs index 8637d1c69..5e917b7c9 100644 --- a/Template.CSharp/Properties/AssemblyInfo.cs +++ b/Template.CSharp/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.5.2")] +[assembly: AssemblyVersion("2.5.4")] //[assembly: AssemblyFileVersion("1.6.1")] diff --git a/Template.CSharp/packages_t.config b/Template.CSharp/packages_t.config index ede17ba97..82f862666 100644 --- a/Template.CSharp/packages_t.config +++ b/Template.CSharp/packages_t.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Template.VB/My Project/AssemblyInfo.vb b/Template.VB/My Project/AssemblyInfo.vb index 04055b424..f54602209 100644 --- a/Template.VB/My Project/AssemblyInfo.vb +++ b/Template.VB/My Project/AssemblyInfo.vb @@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - + ' diff --git a/Template.VB/Neo.ConvertTask.dll b/Template.VB/Neo.ConvertTask.dll index 3ff6590eb799ba09fd0b9676d2a5b21a385702bd..36cc5a81f3707bcd17d3e6d48e29440af8816273 100644 GIT binary patch delta 85 zcmV-b0IL6hFn}#v2mu1Ks|f7{5HljBwWg%=+2nE(DnzN`5<^u@= r00jU700002vzHQ00Rb|z - - ..\packages\Neo.SmartContract.Framework.2.5.2\lib\net40\Neo.SmartContract.Framework.dll + + ..\packages\Neo.SmartContract.Framework.2.5.4\lib\net40\Neo.SmartContract.Framework.dll True diff --git a/Template.VB/packages_t.config b/Template.VB/packages_t.config index ede17ba97..82f862666 100644 --- a/Template.VB/packages_t.config +++ b/Template.VB/packages_t.config @@ -1,4 +1,4 @@  - + \ No newline at end of file