From b37080ee26d2efcaa410bec81357794a15e72e2b Mon Sep 17 00:00:00 2001 From: Shargon Date: Fri, 18 May 2018 13:31:21 +0200 Subject: [PATCH 01/15] Update ICO_Template.cs (#21) --- ICO_Template/ICO_Template.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ICO_Template/ICO_Template.cs b/ICO_Template/ICO_Template.cs index 01f5914..6a28cc8 100755 --- a/ICO_Template/ICO_Template.cs +++ b/ICO_Template/ICO_Template.cs @@ -145,9 +145,11 @@ public static bool Transfer(byte[] from, byte[] to, BigInteger value) { if (value <= 0) return false; if (!Runtime.CheckWitness(from)) return false; - if (from == to) return true; + if (to.Length != 20) return false; + BigInteger from_value = Storage.Get(Storage.CurrentContext, from).AsBigInteger(); if (from_value < value) return false; + if (from == to) return true; if (from_value == value) Storage.Delete(Storage.CurrentContext, from); else From 3cf1506d3315624a3dc1ebcd8a1f7acdc07f29bc Mon Sep 17 00:00:00 2001 From: Igor Machado Coelho Date: Tue, 19 Jun 2018 07:21:30 -0300 Subject: [PATCH 02/15] Simple example for Map and StorageMap (#23) --- MapExample/MapExample.cs | 33 +++++++++++++ MapExample/MapExample.csproj | 66 ++++++++++++++++++++++++++ MapExample/Neo.ConvertTask.dll | Bin 0 -> 6144 bytes MapExample/Properties/AssemblyInfo.cs | 35 ++++++++++++++ MapExample/build.tasks | 4 ++ MapExample/packages.config | 4 ++ examples.sln | 6 +++ 7 files changed, 148 insertions(+) create mode 100644 MapExample/MapExample.cs create mode 100644 MapExample/MapExample.csproj create mode 100644 MapExample/Neo.ConvertTask.dll create mode 100644 MapExample/Properties/AssemblyInfo.cs create mode 100644 MapExample/build.tasks create mode 100644 MapExample/packages.config diff --git a/MapExample/MapExample.cs b/MapExample/MapExample.cs new file mode 100644 index 0000000..9e14c4f --- /dev/null +++ b/MapExample/MapExample.cs @@ -0,0 +1,33 @@ +using Neo.SmartContract.Framework.Services.Neo; +using Neo.SmartContract.Framework; + +namespace Neo.SmartContract +{ + public class MapExample : Framework.SmartContract + { + public static void Main() + { + // Simple Map + Map m = new Map(); + m["hello"] = 10; + m["world"] = 15; + Runtime.Notify(m["hello"]); // will print '10' + Runtime.Notify(m["world"]); // will print '15' + + // StorageMap (create prefix for Storage) + StorageMap user_sm = Storage.CurrentContext.CreateMap("user"); // 'user' prefix + user_sm.Put("xyz", 20); + user_sm.Put("wrd", 30); + StorageMap tx_sm = Storage.CurrentContext.CreateMap("tx"); // 'tx' prefix + tx_sm.Put("xyz", 40); + tx_sm.Put("wrd", 50); + + Runtime.Notify(user_sm.Get("xyz").AsBigInteger()); // will print '20' + Runtime.Notify(user_sm.Get("wrd").AsBigInteger()); // will print '30' + Runtime.Notify(tx_sm.Get("xyz").AsBigInteger()); // will print '40' + Runtime.Notify(tx_sm.Get("wrd").AsBigInteger()); // will print '50' + Runtime.Notify(Storage.Get(Storage.CurrentContext, "user\x00xyz").AsBigInteger()); // will print '20' + Runtime.Notify(Storage.Get(Storage.CurrentContext, "tx\u0000xyz").AsBigInteger()); // will print '40' + } + } +} diff --git a/MapExample/MapExample.csproj b/MapExample/MapExample.csproj new file mode 100644 index 0000000..3f5ce53 --- /dev/null +++ b/MapExample/MapExample.csproj @@ -0,0 +1,66 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {00974722-3492-4514-9712-9A7D091A1D24} + Library + Properties + Neo.SmartContract + MapExample + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + none + true + bin\Release\ + + + prompt + 4 + + + + ..\packages\Neo.SmartContract.Framework.2.7.3\lib\net40\Neo.SmartContract.Framework.dll + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MapExample/Neo.ConvertTask.dll b/MapExample/Neo.ConvertTask.dll new file mode 100644 index 0000000000000000000000000000000000000000..2de7c659fbdd1841938844ff83b0eb5a2cb7f5af GIT binary patch literal 6144 zcmeHLZ)_aJ6@R;TKHr_=OU`!AAXKnQm1b2t*)sq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PZOoI0Oztg;80~>K_5S!fFGrVPQ6N^e-68lO zV=!LzRqniuL2WN&PwpsHeg1E;Uy8+m+Dm_B1$Zr2R=?j@jww-}+Qa4JSMKD>ee73b p2C*u+{t~j%M)VDw2pO-X3|Ki1%UazG|3Aau;9>k(`~Qo;e*n&&6wLqt literal 0 HcmV?d00001 diff --git a/MapExample/Properties/AssemblyInfo.cs b/MapExample/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0aa7580 --- /dev/null +++ b/MapExample/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MapExample")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("MapExample")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("00974722-3492-4514-9712-9a7d091a1d24")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// 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("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MapExample/build.tasks b/MapExample/build.tasks new file mode 100644 index 0000000..87cd344 --- /dev/null +++ b/MapExample/build.tasks @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/MapExample/packages.config b/MapExample/packages.config new file mode 100644 index 0000000..813669f --- /dev/null +++ b/MapExample/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/examples.sln b/examples.sln index be71164..414f355 100644 --- a/examples.sln +++ b/examples.sln @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructExample", "StructExam EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICO_Template", "ICO_Template\ICO_Template.csproj", "{5DE79897-0F79-48F7-95C1-92B4A73170C6}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapExample", "MapExample\MapExample.csproj", "{00974722-3492-4514-9712-9A7D091A1D24}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,6 +47,10 @@ Global {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Debug|Any CPU.Build.0 = Debug|Any CPU {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Release|Any CPU.ActiveCfg = Release|Any CPU {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Release|Any CPU.Build.0 = Release|Any CPU + {00974722-3492-4514-9712-9A7D091A1D24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00974722-3492-4514-9712-9A7D091A1D24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00974722-3492-4514-9712-9A7D091A1D24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00974722-3492-4514-9712-9A7D091A1D24}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 8864d18b5f80f178b1e98f2c4163fe0320024330 Mon Sep 17 00:00:00 2001 From: Igor Machado Coelho Date: Mon, 25 Jun 2018 03:23:08 -0300 Subject: [PATCH 03/15] Created example for Events (#24) --- EventExample/EventExample.cs | 24 +++++++++ EventExample/EventExample.csproj | 66 ++++++++++++++++++++++++ EventExample/Neo.ConvertTask.dll | Bin 0 -> 6144 bytes EventExample/Properties/AssemblyInfo.cs | 35 +++++++++++++ EventExample/build.tasks | 4 ++ EventExample/packages.config | 4 ++ examples.sln | 6 +++ 7 files changed, 139 insertions(+) create mode 100644 EventExample/EventExample.cs create mode 100644 EventExample/EventExample.csproj create mode 100644 EventExample/Neo.ConvertTask.dll create mode 100644 EventExample/Properties/AssemblyInfo.cs create mode 100644 EventExample/build.tasks create mode 100644 EventExample/packages.config diff --git a/EventExample/EventExample.cs b/EventExample/EventExample.cs new file mode 100644 index 0000000..60244d9 --- /dev/null +++ b/EventExample/EventExample.cs @@ -0,0 +1,24 @@ +using System; // Action +using System.ComponentModel; // DisplayName +using System.Numerics; // BigInteger + +namespace Neo.SmartContract +{ + public class EventExample : Framework.SmartContract + { + [DisplayName("new_event_name")] + public static event Action event_name; + + public static event Action event2; + + public static bool Main() + { + byte[] ba = new byte[] { 0x01, 0x02, 0x03 }; + event_name(ba, "oi", 10); // will Runtime.Notify: 'new_event_name', '\x01\x02\x03', 'oi', 10 + + event2(ba, 50); // will Runtime.Notify: 'event2', '\x01\x02\x03', '\x32' + + return false; + } + } +} diff --git a/EventExample/EventExample.csproj b/EventExample/EventExample.csproj new file mode 100644 index 0000000..7d14d60 --- /dev/null +++ b/EventExample/EventExample.csproj @@ -0,0 +1,66 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A} + Library + Properties + Neo.SmartContract + EventExample + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + none + true + bin\Release\ + + + prompt + 4 + + + + ..\packages\Neo.SmartContract.Framework.2.7.3\lib\net40\Neo.SmartContract.Framework.dll + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EventExample/Neo.ConvertTask.dll b/EventExample/Neo.ConvertTask.dll new file mode 100644 index 0000000000000000000000000000000000000000..2de7c659fbdd1841938844ff83b0eb5a2cb7f5af GIT binary patch literal 6144 zcmeHLZ)_aJ6@R;TKHr_=OU`!AAXKnQm1b2t*)sqbtjv=H|0#^)t_ zJICx^unR3lEeKS?AE{M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68lO zV=!LzRqniuL2WN&PwpsHeg1E;Uy8+m+Dm_B1$Zr2R=?j@jww-}+Qa4JSMKD>ee73b p2C*u+{t~j%M)VDw2pO-X3|Ki1%UazG|3Aau;9>k(`~Qo;e*n&&6wLqt literal 0 HcmV?d00001 diff --git a/EventExample/Properties/AssemblyInfo.cs b/EventExample/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5f8f845 --- /dev/null +++ b/EventExample/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("EventExample")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EventExample")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("63cecea1-2506-4fde-bfe2-ea89f75fbf7a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// 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("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/EventExample/build.tasks b/EventExample/build.tasks new file mode 100644 index 0000000..87cd344 --- /dev/null +++ b/EventExample/build.tasks @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/EventExample/packages.config b/EventExample/packages.config new file mode 100644 index 0000000..813669f --- /dev/null +++ b/EventExample/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/examples.sln b/examples.sln index 414f355..cad4162 100644 --- a/examples.sln +++ b/examples.sln @@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICO_Template", "ICO_Templat EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapExample", "MapExample\MapExample.csproj", "{00974722-3492-4514-9712-9A7D091A1D24}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventExample", "EventExample\EventExample.csproj", "{63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -51,6 +53,10 @@ Global {00974722-3492-4514-9712-9A7D091A1D24}.Debug|Any CPU.Build.0 = Debug|Any CPU {00974722-3492-4514-9712-9A7D091A1D24}.Release|Any CPU.ActiveCfg = Release|Any CPU {00974722-3492-4514-9712-9A7D091A1D24}.Release|Any CPU.Build.0 = Release|Any CPU + {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 5dee924da8bf6090a197c004bf1aecd6f1d27aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Tue, 20 Nov 2018 14:59:50 +0800 Subject: [PATCH 04/15] Add NEP-5 project, comply with the NEP-5 specification. (#26) --- NEP5/NEP5.cs | 113 +++++++++++++++++++++++++++ NEP5/NEP5.csproj | 67 ++++++++++++++++ NEP5/Neo.ConvertTask.dll | Bin 0 -> 6144 bytes NEP5/Neo.SmartContract.Framework.dll | Bin 0 -> 18432 bytes NEP5/Properties/AssemblyInfo.cs | 36 +++++++++ NEP5/build.tasks | 4 + NEP5/packages.config | 4 + examples.sln | 6 ++ 8 files changed, 230 insertions(+) create mode 100644 NEP5/NEP5.cs create mode 100644 NEP5/NEP5.csproj create mode 100644 NEP5/Neo.ConvertTask.dll create mode 100644 NEP5/Neo.SmartContract.Framework.dll create mode 100644 NEP5/Properties/AssemblyInfo.cs create mode 100644 NEP5/build.tasks create mode 100644 NEP5/packages.config diff --git a/NEP5/NEP5.cs b/NEP5/NEP5.cs new file mode 100644 index 0000000..eba1694 --- /dev/null +++ b/NEP5/NEP5.cs @@ -0,0 +1,113 @@ +using Neo.SmartContract.Framework; +using Neo.SmartContract.Framework.Services.Neo; +using Neo.SmartContract.Framework.Services.System; +using System; +using System.ComponentModel; +using System.Numerics; + +namespace NEP5 +{ + public class NEP5 : SmartContract + { + [DisplayName("transfer")] + public static event Action Transferred; + + private static readonly byte[] Owner = "Ae2d6qj91YL3LVUMkza7WQsaTYjzjHm4z1".ToScriptHash(); //Owner Address + + public static object Main(string method, object[] args) + { + if (Runtime.Trigger == TriggerType.Verification) + { + return Runtime.CheckWitness(Owner); + } + else if (Runtime.Trigger == TriggerType.Application) + { + var callscript = ExecutionEngine.CallingScriptHash; + + if (method == "balanceOf") return BalanceOf((byte[])args[0]); + + if (method == "decimals") return Decimals(); + + if (method == "name") return Name(); + + if (method == "symbol") return Symbol(); + + if (method == "supportedStandards") return SupportedStandards(); + + if (method == "totalSupply") return TotalSupply(); + + if (method == "transfer") return Transfer((byte[])args[0], (byte[])args[1], (BigInteger)args[2], callscript); + } + return false; + } + + [DisplayName("balanceOf")] + public static BigInteger BalanceOf(byte[] account) + { + if (account.Length != 20) + throw new InvalidOperationException("The parameter account SHOULD be 20-byte addresses."); + StorageMap asset = Storage.CurrentContext.CreateMap(nameof(asset)); + return asset.Get(account).AsBigInteger(); + } + [DisplayName("decimals")] + public static byte Decimals() => 8; + + private static bool IsPayable(byte[] to) + { + var c = Blockchain.GetContract(to); + return c == null || c.IsPayable; + } + + [DisplayName("name")] + public static string Name() => "MyToken"; //name of the token + + [DisplayName("symbol")] + public static string Symbol() => "MYT"; //symbol of the token + + [DisplayName("supportedStandards")] + public static string[] SupportedStandards() => new string[] { "NEP-5", "NEP-7", "NEP-10" }; + + [DisplayName("totalSupply")] + public static BigInteger TotalSupply() + { + StorageMap contract = Storage.CurrentContext.CreateMap(nameof(contract)); + return contract.Get("totalSupply").AsBigInteger(); + } +#if DEBUG + [DisplayName("transfer")] //Only for ABI file + public static bool Transfer(byte[] from, byte[] to, BigInteger amount) => true; +#endif + //Methods of actual execution + private static bool Transfer(byte[] from, byte[] to, BigInteger amount, byte[] callscript) + { + //Check parameters + if (from.Length != 20 || to.Length != 20) + throw new InvalidOperationException("The parameters from and to SHOULD be 20-byte addresses."); + if (amount <= 0) + throw new InvalidOperationException("The parameter amount MUST be greater than 0."); + if (!IsPayable(to)) + return false; + if (!Runtime.CheckWitness(from) && from.AsBigInteger() != callscript.AsBigInteger()) + return false; + StorageMap asset = Storage.CurrentContext.CreateMap(nameof(asset)); + var fromAmount = asset.Get(from).AsBigInteger(); + if (fromAmount < amount) + return false; + if (from == to) + return true; + + //Reduce payer balances + if (fromAmount == amount) + asset.Delete(from); + else + asset.Put(from, fromAmount - amount); + + //Increase the payee balance + var toAmount = asset.Get(to).AsBigInteger(); + asset.Put(to, toAmount + amount); + + Transferred(from, to, amount); + return true; + } + } +} diff --git a/NEP5/NEP5.csproj b/NEP5/NEP5.csproj new file mode 100644 index 0000000..e2e7f65 --- /dev/null +++ b/NEP5/NEP5.csproj @@ -0,0 +1,67 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {2712642F-46ED-47B6-95D9-FB2567BFA2F5} + Library + Properties + NEP5 + NEP5 + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + none + true + bin\Release\ + + + prompt + 4 + + + + False + .\Neo.SmartContract.Framework.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/NEP5/Neo.ConvertTask.dll b/NEP5/Neo.ConvertTask.dll new file mode 100644 index 0000000000000000000000000000000000000000..2de7c659fbdd1841938844ff83b0eb5a2cb7f5af GIT binary patch literal 6144 zcmeHLZ)_aJ6@R;TKHr_=OU`!AAXKnQm1b2t*)sqbtjv=H|0#^)t_ zJICx^unR3lEeKS?AE{MURQdZ4nk1rLLd!*qn#{8!-T6%D1ZD=&5E9-I)}w z$fKux8vr2}+JdXD4Z!=PU^a)M^7T##rL6?6x;8*`xUQ?nAIZ3)N#As8pba}PX%msA zxc@tB(eK63;GXSz;LD1DiPr8W`X2m2KdyHILmWF1jfOhoxHY+0PIRXLzsy@D8R~4q zjjxwakweu}NpB9*)+}ODl3~nrOp;lJ? zw&p}@Fwxr3{}0R_=G&y+c0g+=9&A6+8jJ@w9(n_!$bnZSas(%uIP{XF6C5cV-Fk4~ zaoH1}lO}h9(`D$LyKs+e;^0LSXR#KIcY=(En)|=1l&@Q*+)=N*yQ(~;lm~0dH#~}1 zR?Y5;2xP54V{2n1-q?OZS!fMMHpLq^o#cC9W5ZcQLfe_x+WGX(_N}|0=6k_xjU-y5 z@yKIVd(WD9r2VOuXy-Lx@AADC8CYF{cqH*uJeo)(;^FE-x~jfil)i|`nh!TTBK!U- zmig8ci8s}JTNCMsH+5XeH*7~N-t7C<4Bui`@~s)Z#iVa*mixAMTSS;O$GQUTtqs*3 zNpK{4bQkuay4BaBd!XUt%a_BvTdu2N&lbJ22h<)qoVoR|Ry_ssOr7aVb|-tgdwUL` zgL7g79}W=h_zKbcxEl?iGoG-VqANApBBXS7OlD{Sv@AV4j!dS9aeo4RnN>Ru+dL}WPnWns zyA)VU9WWE30qqz#KUDa2g&n%&{7uoM=xIe?qx}W^s6wGVu1BdQuqPOz_voWQjBX6P ztGCct@Dk{^=v_TTw+BQee+Mb9aG5E!K=lub7v zr3R&7tq5y!4cH_!xfdFu*c7-Ua8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#zRGSQ5E-96VEsDI3KS;45F+z7*i&S*Mo*vNSY&ji}7(bZ=E z%>F`8Z>|ftud8o=F4txD_U`ZMnYpfS#@ydG(`Vv^^N2Y7wD zIdld+0eKeIT)a0Ede;f{bL5W?`N1onye$S?Cy;K|Uo6It~p^ccGVujzRn2RS!Hg zkR1$`nOYgcJO)+ZWdR%k+N;_bh3{GPZOoI0Oztg;80~>K_5S!fFGrVPQ6N^e-68lO zV=!LzRqniuL2WN&PwpsHeg1E;Uy8+m+Dm_B1$Zr2R=?j@jww-}+Qa4JSMKD>ee73b p2C*u+{t~j%M)VDw2pO-X3|Ki1%UazG|3Aau;9>k(`~Qo;e*n&&6wLqt literal 0 HcmV?d00001 diff --git a/NEP5/Neo.SmartContract.Framework.dll b/NEP5/Neo.SmartContract.Framework.dll new file mode 100644 index 0000000000000000000000000000000000000000..66491b776aff65d6347e3f39a6fb4b866e6d902c GIT binary patch literal 18432 zcmeHvd3YSvmG8OLUA;?|h_8psU?-Awp-mzcgrg# z0)w0oAWq^4$UsJ68{h*T%p(ceMaIL<49pOQFnmM|WRmbD!81e10t53qr>d)4l7R{D zy+7W3DY<@iwtMcq=Pq^YR<)bAA0-D7IdOjQ0nsD4@=+uB(J%yc@q+IZ)5G3p7e1nz zo?RH}k7a_Xbh0lU9SHVB6NzLt*lh&UgNa})5v*$s2M3b9MpaRfZ?WaNt)8e!IcVCJ z!_Vh(8>iEPezk(=LP$KO^xO_ygE+fz5|s$8ndN2ymtT%iAmn^FsOB0r<$w9B#j*&; z&n_iuWul8{o$Z7L)-gmB0QtmrqDW5m-?;|uqKmZ$d_zIHs;sdu3%=%j0CZAUtK8t^ z2%=O~=}fu@oRqB#gbQa4&Vr)`lB%>3Pr{JPN<%o=*9M#gM-9>X0#?X599JA%HjQ+; z91YX7hDeF@Plr>rg9)@o<@6OAtweJ8Db*^b6Zy~{Gu~G|*D_aT2G|3R8)6F}nDxH$ zyCIv&GR<*FQWH&Ip%cdk)%dXV$yrFUpkj&(k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/AssemblyInfo.cs new file mode 100644 index 0000000..71eab29 --- /dev/null +++ b/NEP5/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("NEP5")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("NEP5")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("2712642f-46ed-47b6-95d9-fb2567bfa2f5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// 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("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/NEP5/build.tasks b/NEP5/build.tasks new file mode 100644 index 0000000..87cd344 --- /dev/null +++ b/NEP5/build.tasks @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/NEP5/packages.config b/NEP5/packages.config new file mode 100644 index 0000000..813669f --- /dev/null +++ b/NEP5/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/examples.sln b/examples.sln index cad4162..a85f8e2 100644 --- a/examples.sln +++ b/examples.sln @@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapExample", "MapExample\Ma EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventExample", "EventExample\EventExample.csproj", "{63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEP5", "NEP5\NEP5.csproj", "{2712642F-46ED-47B6-95D9-FB2567BFA2F5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -57,6 +59,10 @@ Global {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Debug|Any CPU.Build.0 = Debug|Any CPU {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Release|Any CPU.ActiveCfg = Release|Any CPU {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Release|Any CPU.Build.0 = Release|Any CPU + {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 0ab03a0ed5e1e331b756d9ad51b01657385470c7 Mon Sep 17 00:00:00 2001 From: erikzhang Date: Thu, 4 Apr 2019 14:08:33 +0800 Subject: [PATCH 05/15] Merge csharp and java examples --- .../AgencyTransaction}/AgencyTransaction.cs | 0 .../AgencyTransaction.csproj | 0 .../AgencyTransaction/AgencyTransaction.sln | 25 +++ .../AgencyTransaction}/AgencyTransaction.txt | 0 .../AgencyTransaction}/Neo.ConvertTask.dll | Bin .../Properties/AssemblyInfo.cs | 0 .../AgencyTransaction}/build.tasks | 0 .../AgencyTransaction}/packages.config | 0 {Domain => csharp/Domain}/Domain.cs | 0 {Domain => csharp/Domain}/Domain.csproj | 0 csharp/Domain/Domain.sln | 25 +++ {Domain => csharp/Domain}/Neo.ConvertTask.dll | Bin .../Domain}/Properties/AssemblyInfo.cs | 0 {Domain => csharp/Domain}/build.tasks | 0 {Domain => csharp/Domain}/packages.config | 0 .../EventExample}/EventExample.cs | 0 .../EventExample}/EventExample.csproj | 0 csharp/EventExample/EventExample.sln | 25 +++ .../EventExample}/Neo.ConvertTask.dll | Bin .../EventExample}/Properties/AssemblyInfo.cs | 0 .../EventExample}/build.tasks | 0 .../EventExample}/packages.config | 0 .../HelloWorld}/HelloWorld.cs | 0 .../HelloWorld}/HelloWorld.csproj | 0 csharp/HelloWorld/HelloWorld.sln | 25 +++ .../HelloWorld}/Neo.ConvertTask.dll | Bin .../HelloWorld}/Properties/AssemblyInfo.cs | 0 {HelloWorld => csharp/HelloWorld}/build.tasks | 0 .../HelloWorld}/packages.config | 0 .../ICO_Template}/ICO_Template.cs | 0 .../ICO_Template}/ICO_Template.csproj | 0 csharp/ICO_Template/ICO_Template.sln | 25 +++ .../ICO_Template}/Neo.ConvertTask.dll | Bin .../ICO_Template}/Properties/AssemblyInfo.cs | 0 .../ICO_Template}/build.tasks | 0 .../ICO_Template}/packages.config | 0 {Lock => csharp/Lock}/Lock.cs | 0 {Lock => csharp/Lock}/Lock.csproj | 0 csharp/Lock/Lock.sln | 25 +++ {Lock => csharp/Lock}/Neo.ConvertTask.dll | Bin .../Lock}/Properties/AssemblyInfo.cs | 0 {Lock => csharp/Lock}/build.tasks | 0 {Lock => csharp/Lock}/packages.config | 0 .../MapExample}/MapExample.cs | 0 .../MapExample}/MapExample.csproj | 0 csharp/MapExample/MapExample.sln | 25 +++ .../MapExample}/Neo.ConvertTask.dll | Bin .../MapExample}/Properties/AssemblyInfo.cs | 0 {MapExample => csharp/MapExample}/build.tasks | 0 .../MapExample}/packages.config | 0 {NEP5 => csharp/NEP5}/NEP5.cs | 0 {NEP5 => csharp/NEP5}/NEP5.csproj | 0 csharp/NEP5/NEP5.sln | 25 +++ {NEP5 => csharp/NEP5}/Neo.ConvertTask.dll | Bin .../NEP5}/Neo.SmartContract.Framework.dll | Bin .../NEP5}/Properties/AssemblyInfo.cs | 0 {NEP5 => csharp/NEP5}/build.tasks | 0 {NEP5 => csharp/NEP5}/packages.config | 0 .../StructExample}/Neo.ConvertTask.dll | Bin .../StructExample}/Point.cs | 0 .../StructExample}/Properties/AssemblyInfo.cs | 0 .../StructExample}/StructExample.cs | 0 .../StructExample}/StructExample.csproj | 0 csharp/StructExample/StructExample.sln | 25 +++ .../StructExample}/build.tasks | 0 .../StructExample}/packages.config | 0 examples.sln | 73 ------- java/README.md | 35 +++ java/ico-template/README.md | 9 + java/ico-template/pom.xml | 37 ++++ java/ico-template/scripts/promote.sh | 17 ++ .../main/java/org/ico/main/ICOTemplate.java | 203 ++++++++++++++++++ .../main/java/org/ico/token/NEP5Template.java | 109 ++++++++++ .../java/org/ico/token/TemplateToken.java | 85 ++++++++ 74 files changed, 720 insertions(+), 73 deletions(-) rename {AgencyTransaction => csharp/AgencyTransaction}/AgencyTransaction.cs (100%) rename {AgencyTransaction => csharp/AgencyTransaction}/AgencyTransaction.csproj (100%) create mode 100644 csharp/AgencyTransaction/AgencyTransaction.sln rename {AgencyTransaction => csharp/AgencyTransaction}/AgencyTransaction.txt (100%) rename {AgencyTransaction => csharp/AgencyTransaction}/Neo.ConvertTask.dll (100%) rename {AgencyTransaction => csharp/AgencyTransaction}/Properties/AssemblyInfo.cs (100%) rename {AgencyTransaction => csharp/AgencyTransaction}/build.tasks (100%) rename {AgencyTransaction => csharp/AgencyTransaction}/packages.config (100%) rename {Domain => csharp/Domain}/Domain.cs (100%) rename {Domain => csharp/Domain}/Domain.csproj (100%) create mode 100644 csharp/Domain/Domain.sln rename {Domain => csharp/Domain}/Neo.ConvertTask.dll (100%) rename {Domain => csharp/Domain}/Properties/AssemblyInfo.cs (100%) rename {Domain => csharp/Domain}/build.tasks (100%) rename {Domain => csharp/Domain}/packages.config (100%) rename {EventExample => csharp/EventExample}/EventExample.cs (100%) rename {EventExample => csharp/EventExample}/EventExample.csproj (100%) create mode 100644 csharp/EventExample/EventExample.sln rename {EventExample => csharp/EventExample}/Neo.ConvertTask.dll (100%) rename {EventExample => csharp/EventExample}/Properties/AssemblyInfo.cs (100%) rename {EventExample => csharp/EventExample}/build.tasks (100%) rename {EventExample => csharp/EventExample}/packages.config (100%) rename {HelloWorld => csharp/HelloWorld}/HelloWorld.cs (100%) rename {HelloWorld => csharp/HelloWorld}/HelloWorld.csproj (100%) create mode 100644 csharp/HelloWorld/HelloWorld.sln rename {HelloWorld => csharp/HelloWorld}/Neo.ConvertTask.dll (100%) rename {HelloWorld => csharp/HelloWorld}/Properties/AssemblyInfo.cs (100%) rename {HelloWorld => csharp/HelloWorld}/build.tasks (100%) rename {HelloWorld => csharp/HelloWorld}/packages.config (100%) rename {ICO_Template => csharp/ICO_Template}/ICO_Template.cs (100%) mode change 100755 => 100644 rename {ICO_Template => csharp/ICO_Template}/ICO_Template.csproj (100%) create mode 100644 csharp/ICO_Template/ICO_Template.sln rename {ICO_Template => csharp/ICO_Template}/Neo.ConvertTask.dll (100%) rename {ICO_Template => csharp/ICO_Template}/Properties/AssemblyInfo.cs (100%) rename {ICO_Template => csharp/ICO_Template}/build.tasks (100%) rename {ICO_Template => csharp/ICO_Template}/packages.config (100%) rename {Lock => csharp/Lock}/Lock.cs (100%) rename {Lock => csharp/Lock}/Lock.csproj (100%) create mode 100644 csharp/Lock/Lock.sln rename {Lock => csharp/Lock}/Neo.ConvertTask.dll (100%) rename {Lock => csharp/Lock}/Properties/AssemblyInfo.cs (100%) rename {Lock => csharp/Lock}/build.tasks (100%) rename {Lock => csharp/Lock}/packages.config (100%) rename {MapExample => csharp/MapExample}/MapExample.cs (100%) rename {MapExample => csharp/MapExample}/MapExample.csproj (100%) create mode 100644 csharp/MapExample/MapExample.sln rename {MapExample => csharp/MapExample}/Neo.ConvertTask.dll (100%) rename {MapExample => csharp/MapExample}/Properties/AssemblyInfo.cs (100%) rename {MapExample => csharp/MapExample}/build.tasks (100%) rename {MapExample => csharp/MapExample}/packages.config (100%) rename {NEP5 => csharp/NEP5}/NEP5.cs (100%) rename {NEP5 => csharp/NEP5}/NEP5.csproj (100%) create mode 100644 csharp/NEP5/NEP5.sln rename {NEP5 => csharp/NEP5}/Neo.ConvertTask.dll (100%) rename {NEP5 => csharp/NEP5}/Neo.SmartContract.Framework.dll (100%) rename {NEP5 => csharp/NEP5}/Properties/AssemblyInfo.cs (100%) rename {NEP5 => csharp/NEP5}/build.tasks (100%) rename {NEP5 => csharp/NEP5}/packages.config (100%) rename {StructExample => csharp/StructExample}/Neo.ConvertTask.dll (100%) rename {StructExample => csharp/StructExample}/Point.cs (100%) rename {StructExample => csharp/StructExample}/Properties/AssemblyInfo.cs (100%) rename {StructExample => csharp/StructExample}/StructExample.cs (100%) rename {StructExample => csharp/StructExample}/StructExample.csproj (100%) create mode 100644 csharp/StructExample/StructExample.sln rename {StructExample => csharp/StructExample}/build.tasks (100%) rename {StructExample => csharp/StructExample}/packages.config (100%) delete mode 100644 examples.sln create mode 100644 java/README.md create mode 100644 java/ico-template/README.md create mode 100644 java/ico-template/pom.xml create mode 100644 java/ico-template/scripts/promote.sh create mode 100644 java/ico-template/src/main/java/org/ico/main/ICOTemplate.java create mode 100644 java/ico-template/src/main/java/org/ico/token/NEP5Template.java create mode 100644 java/ico-template/src/main/java/org/ico/token/TemplateToken.java diff --git a/AgencyTransaction/AgencyTransaction.cs b/csharp/AgencyTransaction/AgencyTransaction.cs similarity index 100% rename from AgencyTransaction/AgencyTransaction.cs rename to csharp/AgencyTransaction/AgencyTransaction.cs diff --git a/AgencyTransaction/AgencyTransaction.csproj b/csharp/AgencyTransaction/AgencyTransaction.csproj similarity index 100% rename from AgencyTransaction/AgencyTransaction.csproj rename to csharp/AgencyTransaction/AgencyTransaction.csproj diff --git a/csharp/AgencyTransaction/AgencyTransaction.sln b/csharp/AgencyTransaction/AgencyTransaction.sln new file mode 100644 index 0000000..2268fa4 --- /dev/null +++ b/csharp/AgencyTransaction/AgencyTransaction.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28729.10 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgencyTransaction", "AgencyTransaction.csproj", "{2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9168C6FE-829A-46CD-8616-90A1E74A0958} + EndGlobalSection +EndGlobal diff --git a/AgencyTransaction/AgencyTransaction.txt b/csharp/AgencyTransaction/AgencyTransaction.txt similarity index 100% rename from AgencyTransaction/AgencyTransaction.txt rename to csharp/AgencyTransaction/AgencyTransaction.txt diff --git a/AgencyTransaction/Neo.ConvertTask.dll b/csharp/AgencyTransaction/Neo.ConvertTask.dll similarity index 100% rename from AgencyTransaction/Neo.ConvertTask.dll rename to csharp/AgencyTransaction/Neo.ConvertTask.dll diff --git a/AgencyTransaction/Properties/AssemblyInfo.cs b/csharp/AgencyTransaction/Properties/AssemblyInfo.cs similarity index 100% rename from AgencyTransaction/Properties/AssemblyInfo.cs rename to csharp/AgencyTransaction/Properties/AssemblyInfo.cs diff --git a/AgencyTransaction/build.tasks b/csharp/AgencyTransaction/build.tasks similarity index 100% rename from AgencyTransaction/build.tasks rename to csharp/AgencyTransaction/build.tasks diff --git a/AgencyTransaction/packages.config b/csharp/AgencyTransaction/packages.config similarity index 100% rename from AgencyTransaction/packages.config rename to csharp/AgencyTransaction/packages.config diff --git a/Domain/Domain.cs b/csharp/Domain/Domain.cs similarity index 100% rename from Domain/Domain.cs rename to csharp/Domain/Domain.cs diff --git a/Domain/Domain.csproj b/csharp/Domain/Domain.csproj similarity index 100% rename from Domain/Domain.csproj rename to csharp/Domain/Domain.csproj diff --git a/csharp/Domain/Domain.sln b/csharp/Domain/Domain.sln new file mode 100644 index 0000000..f2b4db2 --- /dev/null +++ b/csharp/Domain/Domain.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28729.10 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain.csproj", "{F6ED9982-E374-4A37-8332-CE4368A9B802}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F6ED9982-E374-4A37-8332-CE4368A9B802}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6ED9982-E374-4A37-8332-CE4368A9B802}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6ED9982-E374-4A37-8332-CE4368A9B802}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6ED9982-E374-4A37-8332-CE4368A9B802}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2DD73DE1-53B0-4C63-8003-B43C66247D61} + EndGlobalSection +EndGlobal diff --git a/Domain/Neo.ConvertTask.dll b/csharp/Domain/Neo.ConvertTask.dll similarity index 100% rename from Domain/Neo.ConvertTask.dll rename to csharp/Domain/Neo.ConvertTask.dll diff --git a/Domain/Properties/AssemblyInfo.cs b/csharp/Domain/Properties/AssemblyInfo.cs similarity index 100% rename from Domain/Properties/AssemblyInfo.cs rename to csharp/Domain/Properties/AssemblyInfo.cs diff --git a/Domain/build.tasks b/csharp/Domain/build.tasks similarity index 100% rename from Domain/build.tasks rename to csharp/Domain/build.tasks diff --git a/Domain/packages.config b/csharp/Domain/packages.config similarity index 100% rename from Domain/packages.config rename to csharp/Domain/packages.config diff --git a/EventExample/EventExample.cs b/csharp/EventExample/EventExample.cs similarity index 100% rename from EventExample/EventExample.cs rename to csharp/EventExample/EventExample.cs diff --git a/EventExample/EventExample.csproj b/csharp/EventExample/EventExample.csproj similarity index 100% rename from EventExample/EventExample.csproj rename to csharp/EventExample/EventExample.csproj diff --git a/csharp/EventExample/EventExample.sln b/csharp/EventExample/EventExample.sln new file mode 100644 index 0000000..476d7f9 --- /dev/null +++ b/csharp/EventExample/EventExample.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28729.10 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventExample", "EventExample.csproj", "{63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {32719646-9E08-40F9-82AB-FFA9F0FC7D35} + EndGlobalSection +EndGlobal diff --git a/EventExample/Neo.ConvertTask.dll b/csharp/EventExample/Neo.ConvertTask.dll similarity index 100% rename from EventExample/Neo.ConvertTask.dll rename to csharp/EventExample/Neo.ConvertTask.dll diff --git a/EventExample/Properties/AssemblyInfo.cs b/csharp/EventExample/Properties/AssemblyInfo.cs similarity index 100% rename from EventExample/Properties/AssemblyInfo.cs rename to csharp/EventExample/Properties/AssemblyInfo.cs diff --git a/EventExample/build.tasks b/csharp/EventExample/build.tasks similarity index 100% rename from EventExample/build.tasks rename to csharp/EventExample/build.tasks diff --git a/EventExample/packages.config b/csharp/EventExample/packages.config similarity index 100% rename from EventExample/packages.config rename to csharp/EventExample/packages.config diff --git a/HelloWorld/HelloWorld.cs b/csharp/HelloWorld/HelloWorld.cs similarity index 100% rename from HelloWorld/HelloWorld.cs rename to csharp/HelloWorld/HelloWorld.cs diff --git a/HelloWorld/HelloWorld.csproj b/csharp/HelloWorld/HelloWorld.csproj similarity index 100% rename from HelloWorld/HelloWorld.csproj rename to csharp/HelloWorld/HelloWorld.csproj diff --git a/csharp/HelloWorld/HelloWorld.sln b/csharp/HelloWorld/HelloWorld.sln new file mode 100644 index 0000000..ce21955 --- /dev/null +++ b/csharp/HelloWorld/HelloWorld.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28729.10 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "HelloWorld.csproj", "{BB4BA99D-2AA8-436B-892D-F82375E565B5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BB4BA99D-2AA8-436B-892D-F82375E565B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB4BA99D-2AA8-436B-892D-F82375E565B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB4BA99D-2AA8-436B-892D-F82375E565B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB4BA99D-2AA8-436B-892D-F82375E565B5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {35935530-3F00-4F14-A2FA-E7FD45A19E09} + EndGlobalSection +EndGlobal diff --git a/HelloWorld/Neo.ConvertTask.dll b/csharp/HelloWorld/Neo.ConvertTask.dll similarity index 100% rename from HelloWorld/Neo.ConvertTask.dll rename to csharp/HelloWorld/Neo.ConvertTask.dll diff --git a/HelloWorld/Properties/AssemblyInfo.cs b/csharp/HelloWorld/Properties/AssemblyInfo.cs similarity index 100% rename from HelloWorld/Properties/AssemblyInfo.cs rename to csharp/HelloWorld/Properties/AssemblyInfo.cs diff --git a/HelloWorld/build.tasks b/csharp/HelloWorld/build.tasks similarity index 100% rename from HelloWorld/build.tasks rename to csharp/HelloWorld/build.tasks diff --git a/HelloWorld/packages.config b/csharp/HelloWorld/packages.config similarity index 100% rename from HelloWorld/packages.config rename to csharp/HelloWorld/packages.config diff --git a/ICO_Template/ICO_Template.cs b/csharp/ICO_Template/ICO_Template.cs old mode 100755 new mode 100644 similarity index 100% rename from ICO_Template/ICO_Template.cs rename to csharp/ICO_Template/ICO_Template.cs diff --git a/ICO_Template/ICO_Template.csproj b/csharp/ICO_Template/ICO_Template.csproj similarity index 100% rename from ICO_Template/ICO_Template.csproj rename to csharp/ICO_Template/ICO_Template.csproj diff --git a/csharp/ICO_Template/ICO_Template.sln b/csharp/ICO_Template/ICO_Template.sln new file mode 100644 index 0000000..35ade26 --- /dev/null +++ b/csharp/ICO_Template/ICO_Template.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28729.10 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICO_Template", "ICO_Template.csproj", "{5DE79897-0F79-48F7-95C1-92B4A73170C6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C1D1ACFD-58FD-436A-B32E-3ED81C5477FA} + EndGlobalSection +EndGlobal diff --git a/ICO_Template/Neo.ConvertTask.dll b/csharp/ICO_Template/Neo.ConvertTask.dll similarity index 100% rename from ICO_Template/Neo.ConvertTask.dll rename to csharp/ICO_Template/Neo.ConvertTask.dll diff --git a/ICO_Template/Properties/AssemblyInfo.cs b/csharp/ICO_Template/Properties/AssemblyInfo.cs similarity index 100% rename from ICO_Template/Properties/AssemblyInfo.cs rename to csharp/ICO_Template/Properties/AssemblyInfo.cs diff --git a/ICO_Template/build.tasks b/csharp/ICO_Template/build.tasks similarity index 100% rename from ICO_Template/build.tasks rename to csharp/ICO_Template/build.tasks diff --git a/ICO_Template/packages.config b/csharp/ICO_Template/packages.config similarity index 100% rename from ICO_Template/packages.config rename to csharp/ICO_Template/packages.config diff --git a/Lock/Lock.cs b/csharp/Lock/Lock.cs similarity index 100% rename from Lock/Lock.cs rename to csharp/Lock/Lock.cs diff --git a/Lock/Lock.csproj b/csharp/Lock/Lock.csproj similarity index 100% rename from Lock/Lock.csproj rename to csharp/Lock/Lock.csproj diff --git a/csharp/Lock/Lock.sln b/csharp/Lock/Lock.sln new file mode 100644 index 0000000..26b6592 --- /dev/null +++ b/csharp/Lock/Lock.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28729.10 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lock", "Lock.csproj", "{02F32860-7875-4D48-BB8C-FCD121845C6F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {02F32860-7875-4D48-BB8C-FCD121845C6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {02F32860-7875-4D48-BB8C-FCD121845C6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02F32860-7875-4D48-BB8C-FCD121845C6F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {02F32860-7875-4D48-BB8C-FCD121845C6F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {064793BF-C4BF-46A1-84EF-CCA728059867} + EndGlobalSection +EndGlobal diff --git a/Lock/Neo.ConvertTask.dll b/csharp/Lock/Neo.ConvertTask.dll similarity index 100% rename from Lock/Neo.ConvertTask.dll rename to csharp/Lock/Neo.ConvertTask.dll diff --git a/Lock/Properties/AssemblyInfo.cs b/csharp/Lock/Properties/AssemblyInfo.cs similarity index 100% rename from Lock/Properties/AssemblyInfo.cs rename to csharp/Lock/Properties/AssemblyInfo.cs diff --git a/Lock/build.tasks b/csharp/Lock/build.tasks similarity index 100% rename from Lock/build.tasks rename to csharp/Lock/build.tasks diff --git a/Lock/packages.config b/csharp/Lock/packages.config similarity index 100% rename from Lock/packages.config rename to csharp/Lock/packages.config diff --git a/MapExample/MapExample.cs b/csharp/MapExample/MapExample.cs similarity index 100% rename from MapExample/MapExample.cs rename to csharp/MapExample/MapExample.cs diff --git a/MapExample/MapExample.csproj b/csharp/MapExample/MapExample.csproj similarity index 100% rename from MapExample/MapExample.csproj rename to csharp/MapExample/MapExample.csproj diff --git a/csharp/MapExample/MapExample.sln b/csharp/MapExample/MapExample.sln new file mode 100644 index 0000000..0a53c54 --- /dev/null +++ b/csharp/MapExample/MapExample.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28729.10 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapExample", "MapExample.csproj", "{00974722-3492-4514-9712-9A7D091A1D24}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {00974722-3492-4514-9712-9A7D091A1D24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00974722-3492-4514-9712-9A7D091A1D24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00974722-3492-4514-9712-9A7D091A1D24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00974722-3492-4514-9712-9A7D091A1D24}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C9CF4C92-244F-4A1F-A770-6AE3BB5B66C3} + EndGlobalSection +EndGlobal diff --git a/MapExample/Neo.ConvertTask.dll b/csharp/MapExample/Neo.ConvertTask.dll similarity index 100% rename from MapExample/Neo.ConvertTask.dll rename to csharp/MapExample/Neo.ConvertTask.dll diff --git a/MapExample/Properties/AssemblyInfo.cs b/csharp/MapExample/Properties/AssemblyInfo.cs similarity index 100% rename from MapExample/Properties/AssemblyInfo.cs rename to csharp/MapExample/Properties/AssemblyInfo.cs diff --git a/MapExample/build.tasks b/csharp/MapExample/build.tasks similarity index 100% rename from MapExample/build.tasks rename to csharp/MapExample/build.tasks diff --git a/MapExample/packages.config b/csharp/MapExample/packages.config similarity index 100% rename from MapExample/packages.config rename to csharp/MapExample/packages.config diff --git a/NEP5/NEP5.cs b/csharp/NEP5/NEP5.cs similarity index 100% rename from NEP5/NEP5.cs rename to csharp/NEP5/NEP5.cs diff --git a/NEP5/NEP5.csproj b/csharp/NEP5/NEP5.csproj similarity index 100% rename from NEP5/NEP5.csproj rename to csharp/NEP5/NEP5.csproj diff --git a/csharp/NEP5/NEP5.sln b/csharp/NEP5/NEP5.sln new file mode 100644 index 0000000..0a5be4f --- /dev/null +++ b/csharp/NEP5/NEP5.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28729.10 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEP5", "NEP5.csproj", "{2712642F-46ED-47B6-95D9-FB2567BFA2F5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7D56C83B-01F9-41F0-A703-8DAAF03DC1A8} + EndGlobalSection +EndGlobal diff --git a/NEP5/Neo.ConvertTask.dll b/csharp/NEP5/Neo.ConvertTask.dll similarity index 100% rename from NEP5/Neo.ConvertTask.dll rename to csharp/NEP5/Neo.ConvertTask.dll diff --git a/NEP5/Neo.SmartContract.Framework.dll b/csharp/NEP5/Neo.SmartContract.Framework.dll similarity index 100% rename from NEP5/Neo.SmartContract.Framework.dll rename to csharp/NEP5/Neo.SmartContract.Framework.dll diff --git a/NEP5/Properties/AssemblyInfo.cs b/csharp/NEP5/Properties/AssemblyInfo.cs similarity index 100% rename from NEP5/Properties/AssemblyInfo.cs rename to csharp/NEP5/Properties/AssemblyInfo.cs diff --git a/NEP5/build.tasks b/csharp/NEP5/build.tasks similarity index 100% rename from NEP5/build.tasks rename to csharp/NEP5/build.tasks diff --git a/NEP5/packages.config b/csharp/NEP5/packages.config similarity index 100% rename from NEP5/packages.config rename to csharp/NEP5/packages.config diff --git a/StructExample/Neo.ConvertTask.dll b/csharp/StructExample/Neo.ConvertTask.dll similarity index 100% rename from StructExample/Neo.ConvertTask.dll rename to csharp/StructExample/Neo.ConvertTask.dll diff --git a/StructExample/Point.cs b/csharp/StructExample/Point.cs similarity index 100% rename from StructExample/Point.cs rename to csharp/StructExample/Point.cs diff --git a/StructExample/Properties/AssemblyInfo.cs b/csharp/StructExample/Properties/AssemblyInfo.cs similarity index 100% rename from StructExample/Properties/AssemblyInfo.cs rename to csharp/StructExample/Properties/AssemblyInfo.cs diff --git a/StructExample/StructExample.cs b/csharp/StructExample/StructExample.cs similarity index 100% rename from StructExample/StructExample.cs rename to csharp/StructExample/StructExample.cs diff --git a/StructExample/StructExample.csproj b/csharp/StructExample/StructExample.csproj similarity index 100% rename from StructExample/StructExample.csproj rename to csharp/StructExample/StructExample.csproj diff --git a/csharp/StructExample/StructExample.sln b/csharp/StructExample/StructExample.sln new file mode 100644 index 0000000..54a6bc7 --- /dev/null +++ b/csharp/StructExample/StructExample.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28729.10 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructExample", "StructExample.csproj", "{6777CA72-89CB-4FDD-84C3-BC82A440CD58}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6777CA72-89CB-4FDD-84C3-BC82A440CD58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6777CA72-89CB-4FDD-84C3-BC82A440CD58}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6777CA72-89CB-4FDD-84C3-BC82A440CD58}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6777CA72-89CB-4FDD-84C3-BC82A440CD58}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F63A97ED-905B-4FA8-9C55-03CD146B8D9A} + EndGlobalSection +EndGlobal diff --git a/StructExample/build.tasks b/csharp/StructExample/build.tasks similarity index 100% rename from StructExample/build.tasks rename to csharp/StructExample/build.tasks diff --git a/StructExample/packages.config b/csharp/StructExample/packages.config similarity index 100% rename from StructExample/packages.config rename to csharp/StructExample/packages.config diff --git a/examples.sln b/examples.sln deleted file mode 100644 index a85f8e2..0000000 --- a/examples.sln +++ /dev/null @@ -1,73 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26730.8 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgencyTransaction", "AgencyTransaction\AgencyTransaction.csproj", "{2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lock", "Lock\Lock.csproj", "{02F32860-7875-4D48-BB8C-FCD121845C6F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "HelloWorld\HelloWorld.csproj", "{BB4BA99D-2AA8-436B-892D-F82375E565B5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain\Domain.csproj", "{F6ED9982-E374-4A37-8332-CE4368A9B802}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructExample", "StructExample\StructExample.csproj", "{6777CA72-89CB-4FDD-84C3-BC82A440CD58}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICO_Template", "ICO_Template\ICO_Template.csproj", "{5DE79897-0F79-48F7-95C1-92B4A73170C6}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapExample", "MapExample\MapExample.csproj", "{00974722-3492-4514-9712-9A7D091A1D24}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventExample", "EventExample\EventExample.csproj", "{63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEP5", "NEP5\NEP5.csproj", "{2712642F-46ED-47B6-95D9-FB2567BFA2F5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}.Release|Any CPU.Build.0 = Release|Any CPU - {02F32860-7875-4D48-BB8C-FCD121845C6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {02F32860-7875-4D48-BB8C-FCD121845C6F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {02F32860-7875-4D48-BB8C-FCD121845C6F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {02F32860-7875-4D48-BB8C-FCD121845C6F}.Release|Any CPU.Build.0 = Release|Any CPU - {BB4BA99D-2AA8-436B-892D-F82375E565B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB4BA99D-2AA8-436B-892D-F82375E565B5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB4BA99D-2AA8-436B-892D-F82375E565B5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB4BA99D-2AA8-436B-892D-F82375E565B5}.Release|Any CPU.Build.0 = Release|Any CPU - {F6ED9982-E374-4A37-8332-CE4368A9B802}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F6ED9982-E374-4A37-8332-CE4368A9B802}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F6ED9982-E374-4A37-8332-CE4368A9B802}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F6ED9982-E374-4A37-8332-CE4368A9B802}.Release|Any CPU.Build.0 = Release|Any CPU - {6777CA72-89CB-4FDD-84C3-BC82A440CD58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6777CA72-89CB-4FDD-84C3-BC82A440CD58}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6777CA72-89CB-4FDD-84C3-BC82A440CD58}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6777CA72-89CB-4FDD-84C3-BC82A440CD58}.Release|Any CPU.Build.0 = Release|Any CPU - {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Release|Any CPU.Build.0 = Release|Any CPU - {00974722-3492-4514-9712-9A7D091A1D24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {00974722-3492-4514-9712-9A7D091A1D24}.Debug|Any CPU.Build.0 = Debug|Any CPU - {00974722-3492-4514-9712-9A7D091A1D24}.Release|Any CPU.ActiveCfg = Release|Any CPU - {00974722-3492-4514-9712-9A7D091A1D24}.Release|Any CPU.Build.0 = Release|Any CPU - {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {63CECEA1-2506-4FDE-BFE2-EA89F75FBF7A}.Release|Any CPU.Build.0 = Release|Any CPU - {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {169EC3B8-6AF3-4326-A39C-07FB940E4DEB} - EndGlobalSection -EndGlobal diff --git a/java/README.md b/java/README.md new file mode 100644 index 0000000..f7fcaee --- /dev/null +++ b/java/README.md @@ -0,0 +1,35 @@ +# Java Examples for NEO + +This repository contains resources and quick starts to help Java developers get started on the NEO blockchain. + +## Setup +You will need to setup a few things before getting started with these examples. + +**Required** + * [neo-devpack-java](https://github.com/neo-project/neo-devpack-java) – Java Native Interfaces (JNI) for Neo's methods + * [neo-compiler](https://github.com/neo-project/neo-compiler) – Converter from Java bytecode to Neo bytecode + + + **Advised** + * [neo-privatenet](https://hub.docker.com/r/cityofzion/neo-privatenet/) – Docker image for local testing  + * [neo-python](https://github.com/CityOfZion/neo-python) – CLI for NEO + + +For instructions on the setup process, see the [NEO docs](http://docs.neo.org) + +## Development Notes + +The Java source code that is written is converted to an avm file (Neo's Virtual Machine bytecode) by the neoj neo-compiler. There are a few limitations with this compiler in its current state that are important to mention. + +1. Method calls while instantiating a field variable will result in runtime errors. Example: +Do not do the following +```java +public static final byte[] OWNER = + Helper.asByteArray"AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y"; +``` + +2. Package names cannot start with **org.neo** as they will be ignored by the neoj neo-compiler. +```csharp + var bskip = cc.classfile.Name.IndexOf("org.neo.") == 0 || cc.classfile.Name.IndexOf("src.org.neo.") == 0; +``` +See [neo-compiler's JAVAModule](https://github.com/neo-project/neo-compiler/blob/92533c40058cdda9be67e94a0e13712f16017b8c/neoj/JVM/JAVAModule.cs#L55) diff --git a/java/ico-template/README.md b/java/ico-template/README.md new file mode 100644 index 0000000..e523d9a --- /dev/null +++ b/java/ico-template/README.md @@ -0,0 +1,9 @@ +# ICO Template +To run this ICO Template, you must first setup [neo-devpack-java](https://github.com/neo-project/neo-devpack-java) and install the artifact to your local maven .m2 folder as well as your system's dotnet folder. + + +## Additional Resources +### Promotion process +**Mac OS** + +There is a bash script file called *promote.sh* that simplifies compiling the template but makes some assumptions on the location of the neo-compiler and neo-python projects. diff --git a/java/ico-template/pom.xml b/java/ico-template/pom.xml new file mode 100644 index 0000000..c5ec847 --- /dev/null +++ b/java/ico-template/pom.xml @@ -0,0 +1,37 @@ + + 4.0.0 + org.neo.ico + ico-template + 1.0.0 + + + UTF-8 + 1.8 + 3.6.1 + + + + + org.neo.smartcontract.framework + neo-devpack-java + 2.3.0 + + + + + src/main/java + + + maven-compiler-plugin + ${maven.compiler.plugin.version} + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + + + diff --git a/java/ico-template/scripts/promote.sh b/java/ico-template/scripts/promote.sh new file mode 100644 index 0000000..3e9e990 --- /dev/null +++ b/java/ico-template/scripts/promote.sh @@ -0,0 +1,17 @@ +#bin/bash + +artifactId=ico-template +version=1.0.0 +jarFile=$artifactId-$version.jar +neocompilerLocation=../../neo-compiler +neoj=$neocompilerLocation/neoj +neopythonLocation=~/Documents/neo-python/ + +cd ../ +mvn clean install +cp target/$jarFile $neoj/$jarFile + +cd $neoj +dotnet run $jarFile + +cp $artifactId-$version.avm $neopythonLocation diff --git a/java/ico-template/src/main/java/org/ico/main/ICOTemplate.java b/java/ico-template/src/main/java/org/ico/main/ICOTemplate.java new file mode 100644 index 0000000..ba0b22e --- /dev/null +++ b/java/ico-template/src/main/java/org/ico/main/ICOTemplate.java @@ -0,0 +1,203 @@ +package org.ico.main; + +import org.neo.smartcontract.framework.services.neo.TriggerType; +import org.neo.smartcontract.framework.services.system.ExecutionEngine; + +import java.math.BigInteger; + +import org.ico.token.NEP5Template; +import org.ico.token.TemplateToken; +import org.neo.smartcontract.framework.Helper; +import org.neo.smartcontract.framework.SmartContract; +import org.neo.smartcontract.framework.services.neo.Runtime; +import org.neo.smartcontract.framework.services.neo.Storage; +import org.neo.smartcontract.framework.services.neo.Transaction; +import org.neo.smartcontract.framework.services.neo.TransactionOutput; + +public class ICOTemplate extends SmartContract { + + /** + * The EPOC start time for the ICO. The associated time unit is seconds + */ + private final static long ICO_START_TIME = 1521003600; + + /** + * The EPOC end time for the ICO. The associated time unit is seconds + */ + private final static long ICO_END_TIME = 1523682000; + + /** + * The Entry point for the ICO Smart Contract. The neoj neo-compiler looks + * for a method named: Main with an uppercase M. + */ + public static Object Main(String operation, Object[] args) { + TriggerType trigger = Runtime.trigger(); + + if (trigger == TriggerType.Verification) { + boolean isOwner = Runtime.checkWitness(TemplateToken.getOwner()); + + if (isOwner) { + return true; + } + return false; + + } else if (trigger == TriggerType.Application) { + + if (operation.equals("deploy")) { + return deploy(); + } else if (operation.equals("mintTokens")) { + return mintTokens(); + } else if (operation.equals(NEP5Template.TOTAL_SUPPLY)) { + return NEP5Template.totalSupply(); + } else if (operation.equals(NEP5Template.NAME)) { + return NEP5Template.name(); + } else if (operation.equals(NEP5Template.SYMBOL)) { + return NEP5Template.symbol(); + } else if (operation.equals(NEP5Template.DECIMALS)) { + return NEP5Template.decimalsString(); + } else if (operation.equals(NEP5Template.BALANCE_OF)) { + if (args.length < 1) { + Runtime.log("No account argument-No action"); + return false; + } + + byte[] account = Helper.asByteArray((String) args[0]); + return NEP5Template.balanceOf(account); + } else if (operation.equals(NEP5Template.TRANSFER)) { + if (args.length != 3) { + Runtime.log("Insufficient number of arguments-No action"); + return false; + } + + byte[] from = Helper.asByteArray((String) args[0]); + byte[] to = Helper.asByteArray((String) args[1]); + BigInteger amount = BigInteger.valueOf(Long.valueOf((String) args[2])); + + return NEP5Template.transfer(from, to, amount); + } + } + + return false; + } + + public static Object deploy() { + if (getTotalSupply().length != 0) { + Runtime.log("Insufficient token supply-No action"); + return false; + } + + Storage.put(Storage.currentContext(), TemplateToken.getOwner(), TemplateToken.getPreIcoCap()); + Storage.put(Storage.currentContext(), NEP5Template.TOTAL_SUPPLY, TemplateToken.getPreIcoCap()); + + return true; + } + + public static Object mintTokens() { + byte[] sender = getSender(); + + if (sender.length == 0) { + Runtime.log("Asset is not neo-No action"); + return false; + } + + // The current exchange rate between ICO tokens and Neo during the token + // swap period + BigInteger swapRate = currentSwapRate(); + if (swapRate.equals(BigInteger.ZERO)) { + Runtime.log("Crowd funding failure-No action"); + return false; + } + + BigInteger contributionAmount = getContributionAmount(); + BigInteger tokenTransferAmount = currentSwapToken(sender, contributionAmount, swapRate); + if (tokenTransferAmount.equals(BigInteger.ZERO)) { + Runtime.log("Zero token transfer amount-No action"); + return false; + } + + byte[] senderBalanceByteArray = Storage.get(Storage.currentContext(), sender); + BigInteger senderBalance = new BigInteger(senderBalanceByteArray); + BigInteger postTransferAmount = senderBalance.add(tokenTransferAmount); + Storage.put(Storage.currentContext(), sender, postTransferAmount); + + BigInteger tokenAndSupply = tokenTransferAmount.add(NEP5Template.totalSupply()); + Storage.put(Storage.currentContext(), NEP5Template.TOTAL_SUPPLY, tokenAndSupply); + + return true; + } + + private static BigInteger currentSwapRate() { + long icoDuration = ICO_END_TIME - ICO_START_TIME; + + long now = Runtime.time(); + long time = now - ICO_START_TIME; + + if (time < 0) { + return BigInteger.ZERO; + } else if (time < icoDuration) { + return TemplateToken.getBasicRate(); + } + + return BigInteger.ZERO; + } + + private static BigInteger getContributionAmount() { + Transaction tx = (Transaction) ExecutionEngine.scriptContainer(); + TransactionOutput[] outputs = tx.outputs(); + BigInteger contributionAmount = BigInteger.ZERO; + + for (TransactionOutput transaction : outputs) { + if (transaction.scriptHash() == getReceiver() && transaction.assetId() == neoAssetId()) { + BigInteger transactionAmount = BigInteger.valueOf(transaction.value()); + contributionAmount = contributionAmount.add(transactionAmount); + } + } + + return contributionAmount; + } + + private static BigInteger currentSwapToken(byte[] sender, BigInteger contributedAmount, BigInteger swapRate) { + BigInteger tokenAmount = contributedAmount.divide(TemplateToken.getDecimals()).multiply(swapRate); + BigInteger tokenBalance = TemplateToken.getTotalAmount().subtract(NEP5Template.totalSupply()); + + if (tokenBalance.compareTo(BigInteger.ZERO) <= 0) { + return BigInteger.ZERO; + } else if (tokenBalance.compareTo(tokenAmount) < 0) { + tokenAmount = tokenBalance; + } + + return tokenAmount; + } + + /** + * @return smart contract script hash + */ + private static byte[] getReceiver() { + return ExecutionEngine.executingScriptHash(); + } + + private static byte[] getSender() { + Transaction tx = (Transaction) ExecutionEngine.scriptContainer(); + TransactionOutput[] reference = tx.references(); + + for (TransactionOutput output : reference) { + if (output.assetId() == neoAssetId()) { + return output.scriptHash(); + } + } + return Helper.asByteArray(""); + } + + private static byte[] getTotalSupply() { + return Storage.get(Storage.currentContext(), NEP5Template.TOTAL_SUPPLY); + } + + private static byte[] neoAssetId() { + byte[] assetId = new byte[] { (byte) 155, (byte) 124, (byte) 255, (byte) 218, (byte) 166, (byte) 116, + (byte) 190, (byte) 174, (byte) 15, (byte) 147, (byte) 14, (byte) 190, (byte) 96, (byte) 133, (byte) 175, + (byte) 144, (byte) 147, (byte) 229, (byte) 254, (byte) 86, (byte) 179, (byte) 74, (byte) 92, (byte) 34, + (byte) 12, (byte) 205, (byte) 207, (byte) 110, (byte) 252, (byte) 51, (byte) 111, (byte) 197 }; + return assetId; + } + +} diff --git a/java/ico-template/src/main/java/org/ico/token/NEP5Template.java b/java/ico-template/src/main/java/org/ico/token/NEP5Template.java new file mode 100644 index 0000000..4a728ca --- /dev/null +++ b/java/ico-template/src/main/java/org/ico/token/NEP5Template.java @@ -0,0 +1,109 @@ +package org.ico.token; + +import java.math.BigInteger; + +import org.neo.smartcontract.framework.services.neo.Runtime; +import org.neo.smartcontract.framework.services.neo.Storage; + +/** + * NEP-5 outlines a token standard for the NEO blockchain that will provide + * systems with a generalized interaction mechanism for tokenized Smart + * Contracts. + */ +public class NEP5Template { + public final static String TOTAL_SUPPLY = "totalSupply"; + public final static String NAME = "name"; + public final static String SYMBOL = "symbol"; + public final static String DECIMALS = "decimals"; + public final static String BALANCE_OF = "balanceOf"; + public final static String TRANSFER = "transfer"; + + /** + * @return the total token supply deployed in the system + */ + public static BigInteger totalSupply() { + byte[] totalSupply = Storage.get(Storage.currentContext(), "totalSupply"); + return new BigInteger(totalSupply); + } + + /** + * @return the token name + */ + public static String name() { + return TemplateToken.getName(); + } + + /** + * @return the token symbol + */ + public static String symbol() { + return TemplateToken.getSymbol(); + } + + /** + * @return the number of decimals used by the token + */ + public static byte decimals() { + return TemplateToken.decimals(); + } + + /** + * @return the number of decimals used by the token as a String + */ + public static String decimalsString() { + return String.valueOf(TemplateToken.decimals()); + } + + /** + * @return the token balance of the account + */ + public static BigInteger balanceOf(byte[] account) { + return new BigInteger(Storage.get(Storage.currentContext(), account)); + } + + /** + * Will transfer an amount of tokens from the from account to the to account + */ + public static Boolean transfer(byte[] from, byte[] to, BigInteger amount) { + if (amount.compareTo(BigInteger.ZERO) <= 0) { + Runtime.log("No transfer amount-No action"); + return false; + } + + if (to.length != 20) return false; + + if (!Runtime.checkWitness(from)) { + Runtime.log("Not transfering from self-No action"); + return false; + } + + byte[] senderSupplyByteArray = Storage.get(Storage.currentContext(), from); + BigInteger senderSupply = new BigInteger(senderSupplyByteArray); + + if (senderSupply.compareTo(amount) < 0) { + Runtime.log("Insufficient funds for sender-No action"); + return false; + } + + if (from == to) { + Runtime.log("Transfering to self-No action"); + return true; + } + + if (senderSupply == amount) { + Storage.delete(Storage.currentContext(), from); + } else { + BigInteger remainingSupply = senderSupply.subtract(amount); + Storage.put(Storage.currentContext(), from, remainingSupply); + } + + byte[] receiverSupplyByteArray = Storage.get(Storage.currentContext(), to); + BigInteger receiverSupply = new BigInteger(receiverSupplyByteArray); + + BigInteger postTransferAmount = receiverSupply.add(amount); + Storage.put(Storage.currentContext(), to, postTransferAmount); + + return true; + } + +} diff --git a/java/ico-template/src/main/java/org/ico/token/TemplateToken.java b/java/ico-template/src/main/java/org/ico/token/TemplateToken.java new file mode 100644 index 0000000..76ef1b1 --- /dev/null +++ b/java/ico-template/src/main/java/org/ico/token/TemplateToken.java @@ -0,0 +1,85 @@ +package org.ico.token; + +import java.math.BigInteger; + +import org.neo.smartcontract.framework.Helper; + +public class TemplateToken { + + /** + * The full name of the token + */ + private final static String NAME = "Test Token"; + + /** + * The symbol that will be used to identify the token + */ + private final static String SYMBOL = "TST"; + + /** + * The unique id to the owner of the token + */ + private final static String OWNER = "AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y"; + + /** + * The factor is the value of a single token after the factor is applied + */ + private final static long FACTOR = 1000000000; + + private final static long NEO_DECIMALS = 1000000000; + + private final static long TOTAL_AMOUNT = 100000000 * FACTOR; + + private final static long PRE_ICO_CAP = 30000000 * FACTOR; + + private final static long BASIC_RATE = 1000 * FACTOR; + + public static String getName() { + return NAME; + } + + public static String getSymbol() { + return SYMBOL; + } + + public static byte[] getOwner() { + return Helper.asByteArray(OWNER); + } + + /** + * + * Because NEO is traded in whole numbers we set a decimal value so that + * smaller amounts of the token can be traded. 1 token = 1*10^8 = 100000000 + */ + public static byte decimals() { + return 8; + } + + /** + * The neo decimals is the value of a single token after the factor is + * applied + */ + public static BigInteger getDecimals() { + return BigInteger.valueOf(NEO_DECIMALS); + } + + /** + * The total number of token that exist + */ + public static BigInteger getTotalAmount() { + return BigInteger.valueOf(TOTAL_AMOUNT); + } + + public static BigInteger getPreIcoCap() { + return BigInteger.valueOf(PRE_ICO_CAP); + } + + /** + * The current exchange rate between the ICO tokens and neo during the token + * swap period + */ + public static BigInteger getBasicRate() { + return BigInteger.valueOf(BASIC_RATE); + } + +} From 3c36854f72b59e7688e15b767ddfbcdc0dcce56d Mon Sep 17 00:00:00 2001 From: wanglongfei <34025001+wanglongfei88@users.noreply.github.com> Date: Wed, 6 Nov 2019 04:42:49 +0800 Subject: [PATCH 06/15] update smart contract framework (#28) --- csharp/AgencyTransaction/AgencyTransaction.csproj | 4 ++-- csharp/AgencyTransaction/packages.config | 2 +- csharp/Domain/Domain.csproj | 4 ++-- csharp/Domain/packages.config | 2 +- csharp/EventExample/EventExample.csproj | 5 ++--- csharp/EventExample/packages.config | 2 +- csharp/HelloWorld/HelloWorld.csproj | 4 ++-- csharp/HelloWorld/packages.config | 2 +- csharp/ICO_Template/ICO_Template.csproj | 4 ++-- csharp/ICO_Template/packages.config | 2 +- csharp/Lock/Lock.csproj | 4 ++-- csharp/Lock/packages.config | 2 +- csharp/MapExample/MapExample.csproj | 5 ++--- csharp/MapExample/packages.config | 2 +- csharp/NEP5/NEP5.csproj | 5 ++--- csharp/NEP5/packages.config | 2 +- csharp/StructExample/StructExample.csproj | 4 ++-- csharp/StructExample/packages.config | 2 +- 18 files changed, 27 insertions(+), 30 deletions(-) diff --git a/csharp/AgencyTransaction/AgencyTransaction.csproj b/csharp/AgencyTransaction/AgencyTransaction.csproj index 61774e5..b61f204 100644 --- a/csharp/AgencyTransaction/AgencyTransaction.csproj +++ b/csharp/AgencyTransaction/AgencyTransaction.csproj @@ -32,8 +32,8 @@ 4 - - ..\packages\Neo.SmartContract.Framework.2.3.0\lib\net40\Neo.SmartContract.Framework.dll + + ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll diff --git a/csharp/AgencyTransaction/packages.config b/csharp/AgencyTransaction/packages.config index a526b80..59ff8b7 100644 --- a/csharp/AgencyTransaction/packages.config +++ b/csharp/AgencyTransaction/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/csharp/Domain/Domain.csproj b/csharp/Domain/Domain.csproj index 780a541..0f653a2 100644 --- a/csharp/Domain/Domain.csproj +++ b/csharp/Domain/Domain.csproj @@ -32,8 +32,8 @@ 4 - - ..\packages\Neo.SmartContract.Framework.2.3.0\lib\net40\Neo.SmartContract.Framework.dll + + ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll diff --git a/csharp/Domain/packages.config b/csharp/Domain/packages.config index a526b80..59ff8b7 100644 --- a/csharp/Domain/packages.config +++ b/csharp/Domain/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/csharp/EventExample/EventExample.csproj b/csharp/EventExample/EventExample.csproj index 7d14d60..633d137 100644 --- a/csharp/EventExample/EventExample.csproj +++ b/csharp/EventExample/EventExample.csproj @@ -32,9 +32,8 @@ 4 - - ..\packages\Neo.SmartContract.Framework.2.7.3\lib\net40\Neo.SmartContract.Framework.dll - True + + ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll diff --git a/csharp/EventExample/packages.config b/csharp/EventExample/packages.config index 813669f..59ff8b7 100644 --- a/csharp/EventExample/packages.config +++ b/csharp/EventExample/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/csharp/HelloWorld/HelloWorld.csproj b/csharp/HelloWorld/HelloWorld.csproj index 2f3083d..5f251a0 100644 --- a/csharp/HelloWorld/HelloWorld.csproj +++ b/csharp/HelloWorld/HelloWorld.csproj @@ -32,8 +32,8 @@ 4 - - ..\packages\Neo.SmartContract.Framework.2.3.0\lib\net40\Neo.SmartContract.Framework.dll + + ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll diff --git a/csharp/HelloWorld/packages.config b/csharp/HelloWorld/packages.config index a526b80..59ff8b7 100644 --- a/csharp/HelloWorld/packages.config +++ b/csharp/HelloWorld/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/csharp/ICO_Template/ICO_Template.csproj b/csharp/ICO_Template/ICO_Template.csproj index a44201e..6ce2830 100644 --- a/csharp/ICO_Template/ICO_Template.csproj +++ b/csharp/ICO_Template/ICO_Template.csproj @@ -32,8 +32,8 @@ 4 - - ..\packages\Neo.SmartContract.Framework.2.5.2\lib\net40\Neo.SmartContract.Framework.dll + + ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll diff --git a/csharp/ICO_Template/packages.config b/csharp/ICO_Template/packages.config index fc3debd..59ff8b7 100644 --- a/csharp/ICO_Template/packages.config +++ b/csharp/ICO_Template/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/csharp/Lock/Lock.csproj b/csharp/Lock/Lock.csproj index 26e8fd0..0af4775 100644 --- a/csharp/Lock/Lock.csproj +++ b/csharp/Lock/Lock.csproj @@ -32,8 +32,8 @@ 4 - - ..\packages\Neo.SmartContract.Framework.2.3.0\lib\net40\Neo.SmartContract.Framework.dll + + ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll diff --git a/csharp/Lock/packages.config b/csharp/Lock/packages.config index a526b80..59ff8b7 100644 --- a/csharp/Lock/packages.config +++ b/csharp/Lock/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/csharp/MapExample/MapExample.csproj b/csharp/MapExample/MapExample.csproj index 3f5ce53..1c53544 100644 --- a/csharp/MapExample/MapExample.csproj +++ b/csharp/MapExample/MapExample.csproj @@ -32,9 +32,8 @@ 4 - - ..\packages\Neo.SmartContract.Framework.2.7.3\lib\net40\Neo.SmartContract.Framework.dll - True + + ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll diff --git a/csharp/MapExample/packages.config b/csharp/MapExample/packages.config index 813669f..59ff8b7 100644 --- a/csharp/MapExample/packages.config +++ b/csharp/MapExample/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/csharp/NEP5/NEP5.csproj b/csharp/NEP5/NEP5.csproj index e2e7f65..fb62b3a 100644 --- a/csharp/NEP5/NEP5.csproj +++ b/csharp/NEP5/NEP5.csproj @@ -32,9 +32,8 @@ 4 - - False - .\Neo.SmartContract.Framework.dll + + ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll diff --git a/csharp/NEP5/packages.config b/csharp/NEP5/packages.config index 813669f..59ff8b7 100644 --- a/csharp/NEP5/packages.config +++ b/csharp/NEP5/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/csharp/StructExample/StructExample.csproj b/csharp/StructExample/StructExample.csproj index c26b656..79fd9bf 100644 --- a/csharp/StructExample/StructExample.csproj +++ b/csharp/StructExample/StructExample.csproj @@ -32,8 +32,8 @@ 4 - - ..\packages\Neo.SmartContract.Framework.2.3.0\lib\net40\Neo.SmartContract.Framework.dll + + ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll diff --git a/csharp/StructExample/packages.config b/csharp/StructExample/packages.config index 2e5aba7..59ff8b7 100644 --- a/csharp/StructExample/packages.config +++ b/csharp/StructExample/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file From a24fb73fdcf56a6711b2bb8e980cf0aa023411d6 Mon Sep 17 00:00:00 2001 From: erikzhang Date: Mon, 9 Dec 2019 10:09:09 +0800 Subject: [PATCH 07/15] Remove `AgencyTransaction` --- csharp/AgencyTransaction/AgencyTransaction.cs | 59 ---- .../AgencyTransaction.csproj | 66 ----- .../AgencyTransaction/AgencyTransaction.sln | 25 -- .../AgencyTransaction/AgencyTransaction.txt | 252 ------------------ csharp/AgencyTransaction/Neo.ConvertTask.dll | Bin 6144 -> 0 bytes .../Properties/AssemblyInfo.cs | 36 --- csharp/AgencyTransaction/build.tasks | 4 - csharp/AgencyTransaction/packages.config | 4 - 8 files changed, 446 deletions(-) delete mode 100644 csharp/AgencyTransaction/AgencyTransaction.cs delete mode 100644 csharp/AgencyTransaction/AgencyTransaction.csproj delete mode 100644 csharp/AgencyTransaction/AgencyTransaction.sln delete mode 100644 csharp/AgencyTransaction/AgencyTransaction.txt delete mode 100644 csharp/AgencyTransaction/Neo.ConvertTask.dll delete mode 100644 csharp/AgencyTransaction/Properties/AssemblyInfo.cs delete mode 100644 csharp/AgencyTransaction/build.tasks delete mode 100644 csharp/AgencyTransaction/packages.config diff --git a/csharp/AgencyTransaction/AgencyTransaction.cs b/csharp/AgencyTransaction/AgencyTransaction.cs deleted file mode 100644 index dfa3c44..0000000 --- a/csharp/AgencyTransaction/AgencyTransaction.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Neo.SmartContract.Framework.Services.Neo; -using Neo.SmartContract.Framework.Services.System; -using System.Numerics; - -namespace Neo.SmartContract -{ - public class AgencyTransaction : Framework.SmartContract - { - public static bool Main(byte[] agent, byte[] assetId, byte[] valueId, byte[] client, bool way, BigInteger price, byte[] signature) - { - if (VerifySignature(signature, client)) return true; - if (!VerifySignature(signature, agent)) return false; - byte[] inputId, outputId; - if (way) - { - inputId = assetId; - outputId = valueId; - } - else - { - inputId = valueId; - outputId = assetId; - } - BigInteger inputSum = 0, outputSum = 0; - TransactionOutput[] references = ((Transaction)ExecutionEngine.ScriptContainer).GetReferences(); - foreach (TransactionOutput reference in references) - { - if (reference.ScriptHash.Equals(ExecutionEngine.EntryScriptHash)) - { - if (!reference.AssetId.Equals(inputId)) - return false; - else - inputSum += reference.Value; - } - } - TransactionOutput[] outputs = ((Transaction)ExecutionEngine.ScriptContainer).GetOutputs(); - foreach (TransactionOutput output in outputs) - { - if (output.ScriptHash.Equals(ExecutionEngine.EntryScriptHash)) - { - if (output.AssetId.Equals(inputId)) - inputSum -= output.Value; - else if (output.AssetId.Equals(outputId)) - outputSum += output.Value; - } - } - if (inputSum <= 0) return true; - if (way) - { - if (outputSum * 100000000 < inputSum * price) return false; - } - else - { - if (inputSum * 100000000 > outputSum * price) return false; - } - return true; - } - } -} diff --git a/csharp/AgencyTransaction/AgencyTransaction.csproj b/csharp/AgencyTransaction/AgencyTransaction.csproj deleted file mode 100644 index b61f204..0000000 --- a/csharp/AgencyTransaction/AgencyTransaction.csproj +++ /dev/null @@ -1,66 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {2B3D92C9-CBCD-4AF7-9135-20CD97143ACF} - Library - Properties - Neo.SmartContract - AgencyTransaction - v4.6.2 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - none - true - bin\Release\ - - - prompt - 4 - - - - ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/csharp/AgencyTransaction/AgencyTransaction.sln b/csharp/AgencyTransaction/AgencyTransaction.sln deleted file mode 100644 index 2268fa4..0000000 --- a/csharp/AgencyTransaction/AgencyTransaction.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28729.10 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgencyTransaction", "AgencyTransaction.csproj", "{2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2B3D92C9-CBCD-4AF7-9135-20CD97143ACF}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {9168C6FE-829A-46CD-8616-90A1E74A0958} - EndGlobalSection -EndGlobal diff --git a/csharp/AgencyTransaction/AgencyTransaction.txt b/csharp/AgencyTransaction/AgencyTransaction.txt deleted file mode 100644 index e998637..0000000 --- a/csharp/AgencyTransaction/AgencyTransaction.txt +++ /dev/null @@ -1,252 +0,0 @@ -//public static bool Main(byte[] agent, byte[] assetId, byte[] valueId, byte[] client, bool way, BigInteger price, byte[] signature) - -//if (VerifySignature(signature, client)) return true; -PUSH 6 -PICK -PUSH 4 -ROLL -CHECKSIG -JMPIFNOT S01 -PUSH true -TOALTSTACK -JMP CLEAR - -//if (!VerifySignature(signature, agent)) return false; -S01: -PUSH 5 -ROLL -SWAP -CHECKSIG -JMPIF S02 -PUSH false -TOALTSTACK -JMP CLEAR - -//set inputId and outputId -S02: -PUSH 2 -PICK -JMPIF S03 -SWAP - -//BigInteger inputSum = 0, outputSum = 0; -S03: -PUSH 0 -PUSH 0 - -//TransactionOutput[] references = ((Transaction)ExecutionEngine.ScriptContainer).GetReferences(); -SYSCALL System.ExecutionEngine.GetScriptContainer -SYSCALL Neo.Transaction.GetReferences - -//foreach (TransactionOutput reference in references) -//{ - -//initialize loop -DUP -ARRAYSIZE -PUSH 0 - -//exit test -LOOP1: -OVER -OVER -NUMEQUAL -JMPIF S04 - -//set reference -PUSH 2 -PICK -OVER -PICKITEM - -//if (reference.ScriptHash.Equals(ExecutionEngine.EntryScriptHash)) -//{ -DUP -SYSCALL Neo.Output.GetScriptHash -SYSCALL System.ExecutionEngine.GetEntryScriptHash -EQUAL -JMPIFNOT LOOP1S1 - -//if (!reference.AssetId.Equals(inputId)) -DUP -SYSCALL Neo.Output.GetAssetId -PUSH 7 -PICK -EQUAL -JMPIF LOOP1S2 - -//return false; -PUSH false -TOALTSTACK -JMP CLEAR - -//else -LOOP1S2: - -//inputSum += reference.Value; -DUP -SYSCALL Neo.Output.GetValue -PUSH 5 -PICK -ADD -PUSH 5 -XSWAP -DROP -//} - -LOOP1S1: -DROP -INC -JMP LOOP1 -S04: -DROP -DROP -DROP -//} - -//TransactionOutput[] outputs = ((Transaction)ExecutionEngine.ScriptContainer).GetOutputs(); -SYSCALL System.ExecutionEngine.GetScriptContainer -SYSCALL Neo.Transaction.GetOutputs - -//foreach (TransactionOutput output in outputs) -//{ - -//initialize loop -DUP -ARRAYSIZE -PUSH 0 - -//exit test -LOOP2: -OVER -OVER -NUMEQUAL -JMPIF S05 - -//set output -PUSH 2 -PICK -OVER -PICKITEM - -//if (output.ScriptHash.Equals(ExecutionEngine.EntryScriptHash)) -//{ -DUP -SYSCALL Neo.Output.GetScriptHash -SYSCALL System.ExecutionEngine.GetEntryScriptHash -EQUAL -JMPIFNOT LOOP2S1 - -//if (output.AssetId.Equals(inputId)) -DUP -SYSCALL Neo.Output.GetAssetId -PUSH 7 -PICK -EQUAL -JMPIFNOT LOOP2S2 - -//inputSum -= output.Value; -PUSH 4 -PICK -OVER -SYSCALL Neo.Output.GetValue -SUB -PUSH 5 -XSWAP -DROP -JMP LOOP2S1 - -//else if (output.AssetId.Equals(outputId)) -LOOP2S2: -DUP -SYSCALL Neo.Output.GetAssetId -PUSH 8 -PICK -EQUAL -JMPIFNOT LOOP2S1 - -//outputSum += output.Value; -PUSH 5 -PICK -OVER -SYSCALL Neo.Output.GetValue -ADD -PUSH 6 -XSWAP -DROP -//} - -LOOP2S1: -DROP -INC -JMP LOOP2 -S05: -DROP -DROP -DROP -//} - -//if (inputSum <= 0) return true; -DUP -PUSH 0 -LTE -JMPIFNOT S06 -PUSH true -TOALTSTACK -JMP CLEAR - -//if (way) -//{ -S06: -PUSH 4 -ROLL -JMPIFNOT S07 - -//if (outputSum * 100000000 < inputSum * price) return false; -PUSH 4 -ROLL -MUL -SWAP -PUSH 100000000 -MUL -GT -JMPIFNOT S08 -PUSH false -TOALTSTACK -JMP CLEAR -//} - -//else -//{ -S07: - -//if (inputSum * 100000000 > outputSum * price) return false; -PUSH 100000000 -MUL -SWAP -PUSH 4 -ROLL -MUL -GT -JMPIFNOT S08 -PUSH false -TOALTSTACK -JMP CLEAR -//} - -//return true; -S08: -DROP -DROP -PUSH true -RET - -//clear stack and return -CLEAR: -DEPTH -JMPIFNOT EXIT -DROP -JMP CLEAR -EXIT: -FROMALTSTACK -RET diff --git a/csharp/AgencyTransaction/Neo.ConvertTask.dll b/csharp/AgencyTransaction/Neo.ConvertTask.dll deleted file mode 100644 index 118fa5b9274aa6176a34e09cc30ca833ff1ff69d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6144 zcmeHLeQX@X6@R;TKHr_=OU`!AA)lLsq>h6RJ2u9F5bW6Ja1h(6?`$Wu5cclI=OueP z$LwCP3oS+n1S+3Wr3zHk7NLruR!t<-(jY3eNTorAQmG%RR3yqjRa+tY2dzYrNPjbX zXP<2v(Z9=__P1}|d-LYan>TNFZ|v45DL_O)T$e5py^OnTg9IO8#Oihj(Yn>V&(b%D!gYFK^lz%`Cp|Xrq5pOa0GaZw>Nk3-8ANv^g)8#t zDc=S`$c47xs%wMrJ}H>Zp{RVl143ylfvc_!5*?}QD)Rd>u4vLXof>G(~tBTL2wf0qeqi8*c4ECMY*{>;Qus%Ur0HRllt{ z(Hcy&HVph7vxoUkskaNz8j1(oPqYT(!Oe%?hA49Ib%`9oi6#!eBIyK23P*Pw8hk?b z#22K=J>Ya1ddFVeBU?Fm(Zpj|i^e-Z#zV~m4=Ckp)+leOSKe1uo>t03HRbCbMJ%gk z_eKP=)}OJpF%oZVKcOtNh9g_!jayIhPT1J=7$TwVN$lu&c2E0`eb4g!V75jQtmHGPe-$fy zYl_61YQC+DY>78*xtwp_c^{uSWM^!zY(6g?YDJS3~D^y`u+ICmqS$d_=3B0(qv+^d-BKz1_V%2hqVf zv4IZTNS-X7uWKI%Le!^A+@xI$ ztfwt76QV)w7&tE~{JO#|y5#&t(WK}ZMPH@;3H+!+p*^8TsU^@E4ABSlaUe$52j16P zXgqik^gHyv9-`ZVDd@kW51>rt0vAC)r2iiJ&jkiB?~imT{h^}g6+Q@z(v!-j8<0|i zQm|HpHMs_C5}Mo#4N+_g+#a~0+Pj4=&~Zab9||wfPr*G=?LADdp;u77U(oIP^N7!S z9A0Q{dJQx9(VEpG^co@+2ZrbhV3hU&Hz2|i4=Nl|m{#~jg(nr7z>Q=n`Ywg{14Hz* z!tc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mIq%?^K>IYh(j1uW zFZA^0x_}3|`ucOZF0;3{zpH2Vn!Z`Hzi+nB#0%$9jW#F8Q`x05aaFY*-5?*0SVOFB zNi<@)W!qGbqz!V6u_Q72g34#2?^M4#L6ZU0LM-$-ltQcwPOaAJ_?8_RD}p!>j`#v9)$ zpsWBHO5>lFarD!`QU6~TdNugLC$%pa|F0fh{pE8bM$0DO)%+u%x(Y^s8myWmV8_CD z7M`c5LbIqvvR$c0Wg#`ebs;xVmn>DOlmeX#eh8x)eDa`WL96&Fmflu6-BkPaQ4TcG zW{lKOr8uf#33EHJqCWZ{+f^qktN9nOT2txybIW*bfL6`(5m<03uly*l@N-;M*QA=s zp)=?S$g{BK;=P&ROSsO?w354Z>pXx;-Ce!&Dse!e6szl|Th zU#TB&bGKP5!s=&(vXaU-*+8KlIS@dnplZQ<1Es7X*!kc=3{GFGhORy*qtJ>}me2_7i zsQM~*UdEud7qTaJl&U`ex7aVoVo>d+zp?_nmMg2@@5{%Os88+T%JHjra`iqAs4+uW mm0W)bS!pBs22O;G*K!7|9*1SEZHE7!;ji#8{=EJFMc_X@(G - - - \ No newline at end of file diff --git a/csharp/AgencyTransaction/packages.config b/csharp/AgencyTransaction/packages.config deleted file mode 100644 index 59ff8b7..0000000 --- a/csharp/AgencyTransaction/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From 39335527bde67d2be645af34812edb4b41ccf262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Sat, 6 Feb 2021 01:12:10 +0800 Subject: [PATCH 08/15] Add Oracle project. (#34) --- csharp/Oracle/Oracle.csproj | 19 +++++++++++++++++++ csharp/Oracle/Oracle.sln | 25 +++++++++++++++++++++++++ csharp/Oracle/OracleDemo.cs | 35 +++++++++++++++++++++++++++++++++++ csharp/Oracle/example.json | 1 + 4 files changed, 80 insertions(+) create mode 100644 csharp/Oracle/Oracle.csproj create mode 100644 csharp/Oracle/Oracle.sln create mode 100644 csharp/Oracle/OracleDemo.cs create mode 100644 csharp/Oracle/example.json diff --git a/csharp/Oracle/Oracle.csproj b/csharp/Oracle/Oracle.csproj new file mode 100644 index 0000000..8173a76 --- /dev/null +++ b/csharp/Oracle/Oracle.csproj @@ -0,0 +1,19 @@ + + + + net5.0 + Neo.SmartContract.Examples + OracleDemo + + + + + + + + + + + + + diff --git a/csharp/Oracle/Oracle.sln b/csharp/Oracle/Oracle.sln new file mode 100644 index 0000000..be40356 --- /dev/null +++ b/csharp/Oracle/Oracle.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Oracle", "Oracle.csproj", "{34577FF7-416F-4AB8-8F00-46B70C18A49E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {34577FF7-416F-4AB8-8F00-46B70C18A49E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {34577FF7-416F-4AB8-8F00-46B70C18A49E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {34577FF7-416F-4AB8-8F00-46B70C18A49E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {34577FF7-416F-4AB8-8F00-46B70C18A49E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {88267B26-EB48-445A-94B5-C37954E5FB04} + EndGlobalSection +EndGlobal diff --git a/csharp/Oracle/OracleDemo.cs b/csharp/Oracle/OracleDemo.cs new file mode 100644 index 0000000..441a057 --- /dev/null +++ b/csharp/Oracle/OracleDemo.cs @@ -0,0 +1,35 @@ +using Neo.SmartContract.Framework; +using Neo.SmartContract.Framework.Services.Neo; +using System; + +namespace Neo.SmartContract.Examples +{ + [ManifestExtra("Author", "Neo")] + [ManifestExtra("Email", "dev@neo.org")] + [ManifestExtra("Description", "This is an oracle example")] + public class OracleDemo : Framework.SmartContract + { + public static void DoRequest() + { + string url = "https://github.com/neo-project/examples/tree/master/csharp/Oracle/example.json"; // the content is { "value": "hello world" } + string filter = "$.value"; // JSONPath format https://github.com/atifaziz/JSONPath + string callback = "callback"; // callback method + object userdata = "userdata"; // arbitrary type + long gasForResponse = Oracle.MinimumResponseFee; + + Oracle.Request(url, filter, callback, userdata, gasForResponse); + } + + public static void Callback(string url, string userdata, OracleResponseCode code, string result) + { + if (code != OracleResponseCode.Success) throw new Exception("Oracle response failure with code " + (byte)code); + + object ret = Json.Deserialize(result); // [ "hello world" ] + object[] arr = (object[])ret; + string value = (string)arr[0]; + + Runtime.Log("userdata: " + userdata); + Runtime.Log("response value: " + value); + } + } +} diff --git a/csharp/Oracle/example.json b/csharp/Oracle/example.json new file mode 100644 index 0000000..36c524f --- /dev/null +++ b/csharp/Oracle/example.json @@ -0,0 +1 @@ +{ "value": "hello world" } \ No newline at end of file From 6f63197932674a6e29cdb7598a8cabee88e56784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Sun, 7 Feb 2021 16:31:21 +0800 Subject: [PATCH 09/15] Update OracleDemo.cs (#35) --- csharp/Oracle/OracleDemo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csharp/Oracle/OracleDemo.cs b/csharp/Oracle/OracleDemo.cs index 441a057..e8f1e68 100644 --- a/csharp/Oracle/OracleDemo.cs +++ b/csharp/Oracle/OracleDemo.cs @@ -11,7 +11,7 @@ public class OracleDemo : Framework.SmartContract { public static void DoRequest() { - string url = "https://github.com/neo-project/examples/tree/master/csharp/Oracle/example.json"; // the content is { "value": "hello world" } + string url = "https://raw.githubusercontent.com/neo-project/examples/master/csharp/Oracle/example.json"; // the content is { "value": "hello world" } string filter = "$.value"; // JSONPath format https://github.com/atifaziz/JSONPath string callback = "callback"; // callback method object userdata = "userdata"; // arbitrary type From 0f4874f01e141f802638583f72041bbde7a951e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Wed, 17 Mar 2021 20:45:58 +0800 Subject: [PATCH 10/15] NEP17 example (#33) * Add NEP17, Remove NEP5 and ICO_Template * Update * net5.0 * Revert NEP17.csproj * Revert Neo.SmartContract.Framework.dll * Update all examples to 3.0.0-preview5 * Revert "Update all examples to 3.0.0-preview5" This reverts commit 227f30ed3794ff4b4dbb55959dbb77dd43f6a2e3. * sync to neo * onNEP17Payment * update * sync to neo * Fixed deploy error: Invalid type for SIZE: Any * preview5 * Remove redundant judgments and fixed bug. * Change namespace * Rename * ContractPermission * Update NEP17.Methods.cs * update permission * Revert "update permission" This reverts commit 8642dffa2f40ec3a9602b73bb10dae2b4fa93ac2. * fix GetPaymentStatus Co-authored-by: Erik Zhang Co-authored-by: superboyiii <573504781@qq.com> --- csharp/ICO_Template/ICO_Template.cs | 247 ------------------ csharp/ICO_Template/ICO_Template.csproj | 65 ----- csharp/ICO_Template/ICO_Template.sln | 25 -- csharp/ICO_Template/Neo.ConvertTask.dll | Bin 6656 -> 0 bytes .../ICO_Template/Properties/AssemblyInfo.cs | 36 --- csharp/ICO_Template/build.tasks | 4 - csharp/ICO_Template/packages.config | 4 - csharp/NEP17/AssetStorage.cs | 37 +++ csharp/NEP17/NEP17.Crowdsale.cs | 49 ++++ csharp/NEP17/NEP17.Methods.cs | 32 +++ csharp/NEP17/NEP17.Owner.cs | 46 ++++ csharp/NEP17/NEP17.cs | 37 +++ csharp/NEP17/NEP17.csproj | 18 ++ csharp/{NEP5/NEP5.sln => NEP17/NEP17.sln} | 14 +- csharp/NEP17/TotalSupplyStorage.cs | 24 ++ csharp/NEP5/NEP5.cs | 113 -------- csharp/NEP5/NEP5.csproj | 66 ----- csharp/NEP5/Neo.ConvertTask.dll | Bin 6144 -> 0 bytes csharp/NEP5/Neo.SmartContract.Framework.dll | Bin 18432 -> 0 bytes csharp/NEP5/Properties/AssemblyInfo.cs | 36 --- csharp/NEP5/build.tasks | 4 - csharp/NEP5/packages.config | 4 - 22 files changed, 250 insertions(+), 611 deletions(-) delete mode 100644 csharp/ICO_Template/ICO_Template.cs delete mode 100644 csharp/ICO_Template/ICO_Template.csproj delete mode 100644 csharp/ICO_Template/ICO_Template.sln delete mode 100644 csharp/ICO_Template/Neo.ConvertTask.dll delete mode 100644 csharp/ICO_Template/Properties/AssemblyInfo.cs delete mode 100644 csharp/ICO_Template/build.tasks delete mode 100644 csharp/ICO_Template/packages.config create mode 100644 csharp/NEP17/AssetStorage.cs create mode 100644 csharp/NEP17/NEP17.Crowdsale.cs create mode 100644 csharp/NEP17/NEP17.Methods.cs create mode 100644 csharp/NEP17/NEP17.Owner.cs create mode 100644 csharp/NEP17/NEP17.cs create mode 100644 csharp/NEP17/NEP17.csproj rename csharp/{NEP5/NEP5.sln => NEP17/NEP17.sln} (57%) create mode 100644 csharp/NEP17/TotalSupplyStorage.cs delete mode 100644 csharp/NEP5/NEP5.cs delete mode 100644 csharp/NEP5/NEP5.csproj delete mode 100644 csharp/NEP5/Neo.ConvertTask.dll delete mode 100644 csharp/NEP5/Neo.SmartContract.Framework.dll delete mode 100644 csharp/NEP5/Properties/AssemblyInfo.cs delete mode 100644 csharp/NEP5/build.tasks delete mode 100644 csharp/NEP5/packages.config diff --git a/csharp/ICO_Template/ICO_Template.cs b/csharp/ICO_Template/ICO_Template.cs deleted file mode 100644 index 6a28cc8..0000000 --- a/csharp/ICO_Template/ICO_Template.cs +++ /dev/null @@ -1,247 +0,0 @@ -using Neo.SmartContract.Framework; -using Neo.SmartContract.Framework.Services.Neo; -using Neo.SmartContract.Framework.Services.System; -using System; -using System.ComponentModel; -using System.Numerics; - -namespace Neo.SmartContract -{ - public class ICO_Template : Framework.SmartContract - { - //Token Settings - public static string Name() => "name of the token"; - public static string Symbol() => "SymbolOfTheToken"; - public static readonly byte[] Owner = "ATrzHaicmhRj15C3Vv6e6gLfLqhSD2PtTr".ToScriptHash(); - public static byte Decimals() => 8; - private const ulong factor = 100000000; //decided by Decimals() - private const ulong neo_decimals = 100000000; - - //ICO Settings - private static readonly byte[] neo_asset_id = { 155, 124, 255, 218, 166, 116, 190, 174, 15, 147, 14, 190, 96, 133, 175, 144, 147, 229, 254, 86, 179, 74, 92, 34, 12, 205, 207, 110, 252, 51, 111, 197 }; - private const ulong total_amount = 100000000 * factor; // total token amount - private const ulong pre_ico_cap = 30000000 * factor; // pre ico token amount - private const ulong basic_rate = 1000 * factor; - private const int ico_start_time = 1506787200; - private const int ico_end_time = 1538323200; - - [DisplayName("transfer")] - public static event Action Transferred; - - [DisplayName("refund")] - public static event Action Refund; - - public static Object Main(string operation, params object[] args) - { - if (Runtime.Trigger == TriggerType.Verification) - { - if (Owner.Length == 20) - { - // if param Owner is script hash - return Runtime.CheckWitness(Owner); - } - else if (Owner.Length == 33) - { - // if param Owner is public key - byte[] signature = operation.AsByteArray(); - return VerifySignature(signature, Owner); - } - } - else if (Runtime.Trigger == TriggerType.Application) - { - if (operation == "deploy") return Deploy(); - if (operation == "mintTokens") return MintTokens(); - if (operation == "totalSupply") return TotalSupply(); - if (operation == "name") return Name(); - if (operation == "symbol") return Symbol(); - if (operation == "transfer") - { - if (args.Length != 3) return false; - byte[] from = (byte[])args[0]; - byte[] to = (byte[])args[1]; - BigInteger value = (BigInteger)args[2]; - return Transfer(from, to, value); - } - if (operation == "balanceOf") - { - if (args.Length != 1) return 0; - byte[] account = (byte[])args[0]; - return BalanceOf(account); - } - if (operation == "decimals") return Decimals(); - } - //you can choice refund or not refund - byte[] sender = GetSender(); - ulong contribute_value = GetContributeValue(); - if (contribute_value > 0 && sender.Length != 0) - { - Refund(sender, contribute_value); - } - return false; - } - - // initialization parameters, only once - // 初始化参数 - public static bool Deploy() - { - byte[] total_supply = Storage.Get(Storage.CurrentContext, "totalSupply"); - if (total_supply.Length != 0) return false; - Storage.Put(Storage.CurrentContext, Owner, pre_ico_cap); - Storage.Put(Storage.CurrentContext, "totalSupply", pre_ico_cap); - Transferred(null, Owner, pre_ico_cap); - return true; - } - - // The function MintTokens is only usable by the chosen wallet - // contract to mint a number of tokens proportional to the - // amount of neo sent to the wallet contract. The function - // can only be called during the tokenswap period - // 将众筹的neo转化为等价的ico代币 - public static bool MintTokens() - { - byte[] sender = GetSender(); - // contribute asset is not neo - if (sender.Length == 0) - { - return false; - } - ulong contribute_value = GetContributeValue(); - // the current exchange rate between ico tokens and neo during the token swap period - // 获取众筹期间ico token和neo间的转化率 - ulong swap_rate = CurrentSwapRate(); - // crowdfunding failure - // 众筹失败 - if (swap_rate == 0) - { - Refund(sender, contribute_value); - return false; - } - // you can get current swap token amount - ulong token = CurrentSwapToken(sender, contribute_value, swap_rate); - if (token == 0) - { - return false; - } - // crowdfunding success - // 众筹成功 - BigInteger balance = Storage.Get(Storage.CurrentContext, sender).AsBigInteger(); - Storage.Put(Storage.CurrentContext, sender, token + balance); - BigInteger totalSupply = Storage.Get(Storage.CurrentContext, "totalSupply").AsBigInteger(); - Storage.Put(Storage.CurrentContext, "totalSupply", token + totalSupply); - Transferred(null, sender, token); - return true; - } - - // get the total token supply - // 获取已发行token总量 - public static BigInteger TotalSupply() - { - return Storage.Get(Storage.CurrentContext, "totalSupply").AsBigInteger(); - } - - // function that is always called when someone wants to transfer tokens. - // 流转token调用 - public static bool Transfer(byte[] from, byte[] to, BigInteger value) - { - if (value <= 0) return false; - if (!Runtime.CheckWitness(from)) return false; - if (to.Length != 20) return false; - - BigInteger from_value = Storage.Get(Storage.CurrentContext, from).AsBigInteger(); - if (from_value < value) return false; - if (from == to) return true; - if (from_value == value) - Storage.Delete(Storage.CurrentContext, from); - else - Storage.Put(Storage.CurrentContext, from, from_value - value); - BigInteger to_value = Storage.Get(Storage.CurrentContext, to).AsBigInteger(); - Storage.Put(Storage.CurrentContext, to, to_value + value); - Transferred(from, to, value); - return true; - } - - // get the account balance of another account with address - // 根据地址获取token的余额 - public static BigInteger BalanceOf(byte[] address) - { - return Storage.Get(Storage.CurrentContext, address).AsBigInteger(); - } - - // The function CurrentSwapRate() returns the current exchange rate - // between ico tokens and neo during the token swap period - private static ulong CurrentSwapRate() - { - const int ico_duration = ico_end_time - ico_start_time; - uint now = Runtime.Time; - int time = (int)now - ico_start_time; - if (time < 0) - { - return 0; - } - else if (time < ico_duration) - { - return basic_rate; - } - else - { - return 0; - } - } - - //whether over contribute capacity, you can get the token amount - private static ulong CurrentSwapToken(byte[] sender, ulong value, ulong swap_rate) - { - ulong token = value / neo_decimals * swap_rate; - BigInteger total_supply = Storage.Get(Storage.CurrentContext, "totalSupply").AsBigInteger(); - BigInteger balance_token = total_amount - total_supply; - if (balance_token <= 0) - { - Refund(sender, value); - return 0; - } - else if (balance_token < token) - { - Refund(sender, (token - balance_token) / swap_rate * neo_decimals); - token = (ulong)balance_token; - } - return token; - } - - // check whether asset is neo and get sender script hash - private static byte[] GetSender() - { - Transaction tx = (Transaction)ExecutionEngine.ScriptContainer; - TransactionOutput[] reference = tx.GetReferences(); - // you can choice refund or not refund - foreach (TransactionOutput output in reference) - { - if (output.AssetId == neo_asset_id) return output.ScriptHash; - } - return new byte[]{}; - } - - // get smart contract script hash - private static byte[] GetReceiver() - { - return ExecutionEngine.ExecutingScriptHash; - } - - // get all you contribute neo amount - private static ulong GetContributeValue() - { - Transaction tx = (Transaction)ExecutionEngine.ScriptContainer; - TransactionOutput[] outputs = tx.GetOutputs(); - ulong value = 0; - // get the total amount of Neo - // 获取转入智能合约地址的Neo总量 - foreach (TransactionOutput output in outputs) - { - if (output.ScriptHash == GetReceiver() && output.AssetId == neo_asset_id) - { - value += (ulong)output.Value; - } - } - return value; - } - } -} diff --git a/csharp/ICO_Template/ICO_Template.csproj b/csharp/ICO_Template/ICO_Template.csproj deleted file mode 100644 index 6ce2830..0000000 --- a/csharp/ICO_Template/ICO_Template.csproj +++ /dev/null @@ -1,65 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {5DE79897-0F79-48F7-95C1-92B4A73170C6} - Library - Properties - Neo.SmartContract - ICO_Template - v4.6.1 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - none - true - bin\Release\ - - - prompt - 4 - - - - ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/csharp/ICO_Template/ICO_Template.sln b/csharp/ICO_Template/ICO_Template.sln deleted file mode 100644 index 35ade26..0000000 --- a/csharp/ICO_Template/ICO_Template.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28729.10 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICO_Template", "ICO_Template.csproj", "{5DE79897-0F79-48F7-95C1-92B4A73170C6}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5DE79897-0F79-48F7-95C1-92B4A73170C6}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {C1D1ACFD-58FD-436A-B32E-3ED81C5477FA} - EndGlobalSection -EndGlobal diff --git a/csharp/ICO_Template/Neo.ConvertTask.dll b/csharp/ICO_Template/Neo.ConvertTask.dll deleted file mode 100644 index 9a32e15881a163a35847d422e89d65d444d80578..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6656 zcmeHLeQX@X6@R<;k@GpZc<-EZVkhzD6DP3`$2K7e0i5{k;3l?%?;MBXHtgMv&r9xh zj@>=SE~RxpK!8dcq^Ka&AZVd2RH}l61g)S7sI8zCQa>o7rIkP`w3S*xEBJ$=CjHIq zoqcxFNd2!;nY(@a=6%h3Z)V=??$9Ssk&lS{xGr2EdKP!ldL_I(m;*b~`ojo4UH8g{ zXO+XRY)DU;j$X2P-ZqMQ*03z@>KUfnWlJ|LJvoxni#*2?D^`RzS4ogiaNd?w;rMxVhZ2v~X?1%x2m_iw&bNTxx(^y*ExhL~1PH2qg&1Nm~~4?|u!MP`s*Eak;jOx8#hypt z2`qZU#UikcP2f2dTdDcAl}*Q_!B_)?w3Tab;yYk7rfJ&h`*irWCEnV0W=m7+wlln4 zFrx8TOpAWiY&x&T8nwpu2x-x#hoZ5z4sf?t!n0EtV*zN<_(NJO9*=7cm4FlTe!nf< zv&X7ViKMU6R_!_C`Rzp;i!buK34S+K{a&s4TePN@ir;IrHJA3gIUZ}#nmxbQYHNkx z&G5VBvVJ$i?-t?r>ZN|~=oHgr)Ox*6Th|_-rdV)(j^iA)1W6GyTU}+?g;+mIY`wOA z?-&1d;X)lpy~E@OW34+#YsGeI>k@?R2U4Fnpj39J*z40hiOxiKXZOxMA~OLh06v1f zw&`=I1*jEA0>D$QZCZIpNKDj`l-V?vqL+Y+(zxm1*kBU(*U^6u3ue=S0?!CxG%RFg zeAPD_elDul?ZekA(Xr9F*`z32&0n09-|;#BY=E z3xGkoAF!F8lK2nk9rYl+K#$QOdQ?&#r3Vnj3v^ae_68b2|FXIY@SI=3ze#vSU=_Vg zTj>ZW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i@6g^@;SjXw@%32zm$_GURx~bG(n+ z$wFbsFfH$yhcQ{?1^2=h*buKlA2;ktkqCTcnOmF;?~N1bzKAa5#J8hky;!>oPo}_o zKs|~l=;MH*LZ)aCU)qMz9|RomzPi!#{&&xNZ%$$t2+X@*FMHl|vqz~Aa7#+Lqhyc` zJ0{*|@w9;|J&9T^+GhE*od(wc)dAl?-8N+K&t9_5*8fFN?T=lk+GCF+rLxLAMbOfH?r s-BM>iq7v~Ju__D5zK(q+^0lx6mg*s_iyIcS_>SbqS@&`K|I5I?0Ttzdd;kCd diff --git a/csharp/ICO_Template/Properties/AssemblyInfo.cs b/csharp/ICO_Template/Properties/AssemblyInfo.cs deleted file mode 100644 index 223afc9..0000000 --- a/csharp/ICO_Template/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ICO_Template")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ICO_Template")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5de79897-0f79-48f7-95c1-92b4a73170c6")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// 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("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/csharp/ICO_Template/build.tasks b/csharp/ICO_Template/build.tasks deleted file mode 100644 index 87cd344..0000000 --- a/csharp/ICO_Template/build.tasks +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/csharp/ICO_Template/packages.config b/csharp/ICO_Template/packages.config deleted file mode 100644 index 59ff8b7..0000000 --- a/csharp/ICO_Template/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/csharp/NEP17/AssetStorage.cs b/csharp/NEP17/AssetStorage.cs new file mode 100644 index 0000000..4f0b1bb --- /dev/null +++ b/csharp/NEP17/AssetStorage.cs @@ -0,0 +1,37 @@ +using Neo.SmartContract.Framework.Services.Neo; +using System.Numerics; + +namespace Neo.SmartContract.Examples +{ + public static class AssetStorage + { + public static readonly string mapName = "asset"; + + public static void Increase(UInt160 key, BigInteger value) => Put(key, Get(key) + value); + + public static void Enable() => Storage.CurrentContext.CreateMap(mapName).Put("enable", 1); + + public static void Disable() => Storage.CurrentContext.CreateMap(mapName).Put("enable", 0); + + public static void Reduce(UInt160 key, BigInteger value) + { + var oldValue = Get(key); + if (oldValue == value) + Remove(key); + else + Put(key, oldValue - value); + } + + public static void Put(UInt160 key, BigInteger value) => Storage.CurrentContext.CreateMap(mapName).Put(key, value); + + public static BigInteger Get(UInt160 key) + { + var value = Storage.CurrentContext.CreateMap(mapName).Get(key); + return value is null ? 0 : (BigInteger)value; + } + + public static bool GetPaymentStatus() => ((BigInteger) Storage.CurrentContext.CreateMap(mapName).Get("enable")).Equals(1); + + public static void Remove(UInt160 key) => Storage.CurrentContext.CreateMap(mapName).Delete(key); + } +} diff --git a/csharp/NEP17/NEP17.Crowdsale.cs b/csharp/NEP17/NEP17.Crowdsale.cs new file mode 100644 index 0000000..fe390ff --- /dev/null +++ b/csharp/NEP17/NEP17.Crowdsale.cs @@ -0,0 +1,49 @@ +using Neo.SmartContract.Framework.Services.Neo; +using Neo.SmartContract.Framework.Services.System; +using System; +using System.Numerics; + +namespace Neo.SmartContract.Examples +{ + partial class NEP17Demo + { + public static void OnNEP17Payment(UInt160 from, BigInteger amount, object data) + { + if (AssetStorage.GetPaymentStatus()) + { + if (ExecutionEngine.CallingScriptHash == NEO.Hash) + { + Mint(amount * TokensPerNEO); + } + else if (ExecutionEngine.CallingScriptHash == GAS.Hash) + { + if (from != null) Mint(amount * TokensPerGAS); + } + else + { + throw new Exception("Wrong calling script hash"); + } + } + else + { + throw new Exception("Payment is disable on this contract!"); + } + } + + private static void Mint(BigInteger amount) + { + var totalSupply = TotalSupplyStorage.Get(); + + var avaliable_supply = MaxSupply - totalSupply; + + if (amount <= 0) throw new Exception("Amount must be greater than zero."); + if (amount > avaliable_supply) throw new Exception("Insufficient supply for mint tokens."); + + Transaction tx = (Transaction)ExecutionEngine.ScriptContainer; + AssetStorage.Increase(tx.Sender, amount); + TotalSupplyStorage.Increase(amount); + + OnTransfer(null, tx.Sender, amount); + } + } +} diff --git a/csharp/NEP17/NEP17.Methods.cs b/csharp/NEP17/NEP17.Methods.cs new file mode 100644 index 0000000..ddf5fc7 --- /dev/null +++ b/csharp/NEP17/NEP17.Methods.cs @@ -0,0 +1,32 @@ +using Neo.SmartContract.Framework.Services.Neo; +using Neo.SmartContract.Framework.Services.System; +using System; +using System.Numerics; + +namespace Neo.SmartContract.Examples +{ + partial class NEP17Demo + { + public static BigInteger TotalSupply() => TotalSupplyStorage.Get(); + + public static BigInteger BalanceOf(UInt160 account) => AssetStorage.Get(account); + + public static bool Transfer(UInt160 from, UInt160 to, BigInteger amount, object data) + { + if (amount <= 0) throw new Exception("The parameter amount MUST be greater than 0."); + if (!Runtime.CheckWitness(from) && !from.Equals(ExecutionEngine.CallingScriptHash)) throw new Exception("No authorization."); + if (AssetStorage.Get(from) < amount) throw new Exception("Insufficient balance."); + if (from == to) return true; + + AssetStorage.Reduce(from, amount); + AssetStorage.Increase(to, amount); + + OnTransfer(from, to, amount); + + // Validate payable + if (ContractManagement.GetContract(to) != null) + Contract.Call(to, "onNEP17Payment", CallFlags.All, new object[] { from, amount, data }); + return true; + } + } +} diff --git a/csharp/NEP17/NEP17.Owner.cs b/csharp/NEP17/NEP17.Owner.cs new file mode 100644 index 0000000..3cf2a01 --- /dev/null +++ b/csharp/NEP17/NEP17.Owner.cs @@ -0,0 +1,46 @@ +using Neo.SmartContract.Framework; +using Neo.SmartContract.Framework.Services.Neo; +using System; + +namespace Neo.SmartContract.Examples +{ + partial class NEP17Demo + { + public static void _deploy(object data, bool update) + { + if (update) return; + if (TotalSupplyStorage.Get() > 0) throw new Exception("Contract has been deployed."); + + TotalSupplyStorage.Increase(InitialSupply); + AssetStorage.Increase(Owner, InitialSupply); + + OnTransfer(null, Owner, InitialSupply); + } + + public static void Update(ByteString nefFile, string manifest, object data) + { + if (!IsOwner()) throw new Exception("No authorization."); + ContractManagement.Update(nefFile, manifest, data); + } + + public static void Destroy() + { + if (!IsOwner()) throw new Exception("No authorization."); + ContractManagement.Destroy(); + } + + public static void EnablePayment() + { + if (!IsOwner()) throw new Exception("No authorization."); + AssetStorage.Enable(); + } + + public static void DisablePayment() + { + if (!IsOwner()) throw new Exception("No authorization."); + AssetStorage.Disable(); + } + + private static bool IsOwner() => Runtime.CheckWitness(Owner); + } +} diff --git a/csharp/NEP17/NEP17.cs b/csharp/NEP17/NEP17.cs new file mode 100644 index 0000000..d5e02c9 --- /dev/null +++ b/csharp/NEP17/NEP17.cs @@ -0,0 +1,37 @@ +using Neo.SmartContract.Framework; +using System; +using System.ComponentModel; +using System.Numerics; + +namespace Neo.SmartContract.Examples +{ + [ManifestExtra("Author", "Neo")] + [ManifestExtra("Email", "dev@neo.org")] + [ManifestExtra("Description", "This is a NEP17 example")] + [SupportedStandards("NEP-17")] + [ContractPermission("*", "onNEP17Payment")] + public partial class NEP17Demo : Framework.SmartContract + { + #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 + + #region Notifications + [DisplayName("Transfer")] + public static event Action 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(); + + public static string Symbol() => "TokenSymbol"; + + public static ulong Decimals() => 8; + } +} diff --git a/csharp/NEP17/NEP17.csproj b/csharp/NEP17/NEP17.csproj new file mode 100644 index 0000000..f2703bf --- /dev/null +++ b/csharp/NEP17/NEP17.csproj @@ -0,0 +1,18 @@ + + + + net5.0 + Neo.SmartContract.Examples + + + + + + + + + + + + + diff --git a/csharp/NEP5/NEP5.sln b/csharp/NEP17/NEP17.sln similarity index 57% rename from csharp/NEP5/NEP5.sln rename to csharp/NEP17/NEP17.sln index 0a5be4f..fb2a98e 100644 --- a/csharp/NEP5/NEP5.sln +++ b/csharp/NEP17/NEP17.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 -VisualStudioVersion = 16.0.28729.10 +VisualStudioVersion = 16.0.30804.86 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEP5", "NEP5.csproj", "{2712642F-46ED-47B6-95D9-FB2567BFA2F5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NEP17", "NEP17.csproj", "{8FBE87C6-6A8A-4650-A668-4B7C4A20D5D0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,15 +11,15 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2712642F-46ED-47B6-95D9-FB2567BFA2F5}.Release|Any CPU.Build.0 = Release|Any CPU + {8FBE87C6-6A8A-4650-A668-4B7C4A20D5D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8FBE87C6-6A8A-4650-A668-4B7C4A20D5D0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8FBE87C6-6A8A-4650-A668-4B7C4A20D5D0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8FBE87C6-6A8A-4650-A668-4B7C4A20D5D0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7D56C83B-01F9-41F0-A703-8DAAF03DC1A8} + SolutionGuid = {E0C52AFF-CFA9-4816-A825-F5A03BD2F2B2} EndGlobalSection EndGlobal diff --git a/csharp/NEP17/TotalSupplyStorage.cs b/csharp/NEP17/TotalSupplyStorage.cs new file mode 100644 index 0000000..f31264f --- /dev/null +++ b/csharp/NEP17/TotalSupplyStorage.cs @@ -0,0 +1,24 @@ +using Neo.SmartContract.Framework.Services.Neo; +using System.Numerics; + +namespace Neo.SmartContract.Examples +{ + public static class TotalSupplyStorage + { + public static readonly string mapName = "contract"; + + public static readonly string key = "totalSupply"; + + public static void Increase(BigInteger value) => Put(Get() + value); + + public static void Reduce(BigInteger value) => Put(Get() - value); + + public static void Put(BigInteger value) => Storage.CurrentContext.CreateMap(mapName).Put(key, value); + + public static BigInteger Get() + { + var value = Storage.CurrentContext.CreateMap(mapName).Get(key); + return value is null ? 0 : (BigInteger)value; + } + } +} diff --git a/csharp/NEP5/NEP5.cs b/csharp/NEP5/NEP5.cs deleted file mode 100644 index eba1694..0000000 --- a/csharp/NEP5/NEP5.cs +++ /dev/null @@ -1,113 +0,0 @@ -using Neo.SmartContract.Framework; -using Neo.SmartContract.Framework.Services.Neo; -using Neo.SmartContract.Framework.Services.System; -using System; -using System.ComponentModel; -using System.Numerics; - -namespace NEP5 -{ - public class NEP5 : SmartContract - { - [DisplayName("transfer")] - public static event Action Transferred; - - private static readonly byte[] Owner = "Ae2d6qj91YL3LVUMkza7WQsaTYjzjHm4z1".ToScriptHash(); //Owner Address - - public static object Main(string method, object[] args) - { - if (Runtime.Trigger == TriggerType.Verification) - { - return Runtime.CheckWitness(Owner); - } - else if (Runtime.Trigger == TriggerType.Application) - { - var callscript = ExecutionEngine.CallingScriptHash; - - if (method == "balanceOf") return BalanceOf((byte[])args[0]); - - if (method == "decimals") return Decimals(); - - if (method == "name") return Name(); - - if (method == "symbol") return Symbol(); - - if (method == "supportedStandards") return SupportedStandards(); - - if (method == "totalSupply") return TotalSupply(); - - if (method == "transfer") return Transfer((byte[])args[0], (byte[])args[1], (BigInteger)args[2], callscript); - } - return false; - } - - [DisplayName("balanceOf")] - public static BigInteger BalanceOf(byte[] account) - { - if (account.Length != 20) - throw new InvalidOperationException("The parameter account SHOULD be 20-byte addresses."); - StorageMap asset = Storage.CurrentContext.CreateMap(nameof(asset)); - return asset.Get(account).AsBigInteger(); - } - [DisplayName("decimals")] - public static byte Decimals() => 8; - - private static bool IsPayable(byte[] to) - { - var c = Blockchain.GetContract(to); - return c == null || c.IsPayable; - } - - [DisplayName("name")] - public static string Name() => "MyToken"; //name of the token - - [DisplayName("symbol")] - public static string Symbol() => "MYT"; //symbol of the token - - [DisplayName("supportedStandards")] - public static string[] SupportedStandards() => new string[] { "NEP-5", "NEP-7", "NEP-10" }; - - [DisplayName("totalSupply")] - public static BigInteger TotalSupply() - { - StorageMap contract = Storage.CurrentContext.CreateMap(nameof(contract)); - return contract.Get("totalSupply").AsBigInteger(); - } -#if DEBUG - [DisplayName("transfer")] //Only for ABI file - public static bool Transfer(byte[] from, byte[] to, BigInteger amount) => true; -#endif - //Methods of actual execution - private static bool Transfer(byte[] from, byte[] to, BigInteger amount, byte[] callscript) - { - //Check parameters - if (from.Length != 20 || to.Length != 20) - throw new InvalidOperationException("The parameters from and to SHOULD be 20-byte addresses."); - if (amount <= 0) - throw new InvalidOperationException("The parameter amount MUST be greater than 0."); - if (!IsPayable(to)) - return false; - if (!Runtime.CheckWitness(from) && from.AsBigInteger() != callscript.AsBigInteger()) - return false; - StorageMap asset = Storage.CurrentContext.CreateMap(nameof(asset)); - var fromAmount = asset.Get(from).AsBigInteger(); - if (fromAmount < amount) - return false; - if (from == to) - return true; - - //Reduce payer balances - if (fromAmount == amount) - asset.Delete(from); - else - asset.Put(from, fromAmount - amount); - - //Increase the payee balance - var toAmount = asset.Get(to).AsBigInteger(); - asset.Put(to, toAmount + amount); - - Transferred(from, to, amount); - return true; - } - } -} diff --git a/csharp/NEP5/NEP5.csproj b/csharp/NEP5/NEP5.csproj deleted file mode 100644 index fb62b3a..0000000 --- a/csharp/NEP5/NEP5.csproj +++ /dev/null @@ -1,66 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {2712642F-46ED-47B6-95D9-FB2567BFA2F5} - Library - Properties - NEP5 - NEP5 - v4.5 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - none - true - bin\Release\ - - - prompt - 4 - - - - ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/csharp/NEP5/Neo.ConvertTask.dll b/csharp/NEP5/Neo.ConvertTask.dll deleted file mode 100644 index 2de7c659fbdd1841938844ff83b0eb5a2cb7f5af..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6144 zcmeHLZ)_aJ6@R;TKHr_=OU`!AAXKnQm1b2t*)sqbtjv=H|0#^)t_ zJICx^unR3lEeKS?AE{MURQdZ4nk1rLLd!*qn#{8!-T6%D1ZD=&5E9-I)}w z$fKux8vr2}+JdXD4Z!=PU^a)M^7T##rL6?6x;8*`xUQ?nAIZ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X3|Ki1%UazG|3Aau;9>k(`~Qo;e*n&&6wLqt diff --git a/csharp/NEP5/Neo.SmartContract.Framework.dll b/csharp/NEP5/Neo.SmartContract.Framework.dll deleted file mode 100644 index 66491b776aff65d6347e3f39a6fb4b866e6d902c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18432 zcmeHvd3YSvmG8OLUA;?|h_8psU?-Awp-mzcgrg# z0)w0oAWq^4$UsJ68{h*T%p(ceMaIL<49pOQFnmM|WRmbD!81e10t53qr>d)4l7R{D zy+7W3DY<@iwtMcq=Pq^YR<)bAA0-D7IdOjQ0nsD4@=+uB(J%yc@q+IZ)5G3p7e1nz zo?RH}k7a_Xbh0lU9SHVB6NzLt*lh&UgNa})5v*$s2M3b9MpaRfZ?WaNt)8e!IcVCJ z!_Vh(8>iEPezk(=LP$KO^xO_ygE+fz5|s$8ndN2ymtT%iAmn^FsOB0r<$w9B#j*&; z&n_iuWul8{o$Z7L)-gmB0QtmrqDW5m-?;|uqKmZ$d_zIHs;sdu3%=%j0CZAUtK8t^ z2%=O~=}fu@oRqB#gbQa4&Vr)`lB%>3Pr{JPN<%o=*9M#gM-9>X0#?X599JA%HjQ+; z91YX7hDeF@Plr>rg9)@o<@6OAtweJ8Db*^b6Zy~{Gu~G|*D_aT2G|3R8)6F}nDxH$ zyCIv&GR<*FQWH&Ip%cdk)%dXV$yrFUpkj&(k(Xb3{i(=Z+|3Fs4QdrAiOb{gly5Ij z&PKu@yRIk)b&F^A)_}(}xFPnwv&g&r`O4F*LRX?fX|B-vTrE&W5kQfdtPlZ`&VgIv zq^QEgq$02_3W?3!ww$k-*d{m@4uTN8d|29XmQ%Vk_UXaMl0Y`J$0s{-xxu zlrpdWxU^IAwjFS6mVaE?x#qb#J1bIBX({)goc6N+gS6;12)30kkByIPrzv&L7o6+- zNz&&E|4GxE6+p*4EH$xv=qDpE8HGQ!URg5@&s%#|SFNa8wPIEEIbhJ6;=t$T5-qxd z==@WN78ijIXVbAn9|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%rcuva`x*t;M@Ns&jJQQL*#4o;tXG-0sqMa??P8j%+VEAwS;OS>}Y+ zKBFCroLshh?UpSVg89CbyVFflniFYm4w|I2A1E=&eCf4(%Jr*aaa}S;NWHCu! z@Pv&IK4<~A`y`VI&&GCK?V@oF&249UxJ=N=?mO9iiXVsbLCFm~sRfIz-kuwHX7O2J z-;Z+loV?2Fak){KSD15+IVQ0}8RrEGc@;Tj2TC{^eP`*9Nj0}=U~j`Y?^2u>m^wyY z!A!?_2F@Qq_k#i*M0i^~@n{d%g%53A`Nqv1m()GD_KbDkyyUJwu#ehvJ2qvo2i4Kj zZzK+M)FpdlhbYrg&F>aE5=L@4egnQsp-Tne_cG@%-eMGw#6`H1JFwM!4kNc9I~lC|1A0cC<6RTILzt9Oa8)xAAsa{ zk3)r0b3~cH9pBo8FB|eNz(Mn`0yg6fdM6NXUO_eD-Fgf7M&JhXSNHh!;#=>tA3Vmw z-eF%avNCew%9_HX4vd1=D83ThfVcN?ywm63Cho*<3Hewo@7^QOMj_2WAH|n|F=+9# zVL2Xjp3l$NC{q?zG06K);;CG0R^aOd^KUi2Aixt7zBSLAZR!}Urb&wRZn&fwK zYvtPt|EGksYY1(bLA?ghyW@yr5F=}13+L0A?TZln`S_m_fj0C13_1V&|0xyvb3Oi) G2>cftx}0qQ diff --git a/csharp/NEP5/Properties/AssemblyInfo.cs b/csharp/NEP5/Properties/AssemblyInfo.cs deleted file mode 100644 index 71eab29..0000000 --- a/csharp/NEP5/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("NEP5")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NEP5")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("2712642f-46ed-47b6-95d9-fb2567bfa2f5")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// 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("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/csharp/NEP5/build.tasks b/csharp/NEP5/build.tasks deleted file mode 100644 index 87cd344..0000000 --- a/csharp/NEP5/build.tasks +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/csharp/NEP5/packages.config b/csharp/NEP5/packages.config deleted file mode 100644 index 59ff8b7..0000000 --- a/csharp/NEP5/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From a06893509670a1ea598941be7d8a3f335282d30b Mon Sep 17 00:00:00 2001 From: cloud8little <34291844+cloud8little@users.noreply.github.com> Date: Sat, 20 Mar 2021 21:03:54 +0800 Subject: [PATCH 11/15] update Json Deserialize (#38) * update Json Deserialize * Update Oracle.csproj --- csharp/Oracle/Oracle.csproj | 2 +- csharp/Oracle/OracleDemo.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/csharp/Oracle/Oracle.csproj b/csharp/Oracle/Oracle.csproj index 8173a76..4585a10 100644 --- a/csharp/Oracle/Oracle.csproj +++ b/csharp/Oracle/Oracle.csproj @@ -7,7 +7,7 @@ - + diff --git a/csharp/Oracle/OracleDemo.cs b/csharp/Oracle/OracleDemo.cs index e8f1e68..69dd1c4 100644 --- a/csharp/Oracle/OracleDemo.cs +++ b/csharp/Oracle/OracleDemo.cs @@ -24,7 +24,7 @@ public static void Callback(string url, string userdata, OracleResponseCode code { if (code != OracleResponseCode.Success) throw new Exception("Oracle response failure with code " + (byte)code); - object ret = Json.Deserialize(result); // [ "hello world" ] + object ret = StdLib.JsonDeserialize(result); // [ "hello world" ] object[] arr = (object[])ret; string value = (string)arr[0]; From f7dc93b4f4f2a0c1173569216d9e366d4db6927f Mon Sep 17 00:00:00 2001 From: Erik Zhang Date: Wed, 31 Mar 2021 20:15:32 +0800 Subject: [PATCH 12/15] Remove the obsolete examples (#41) --- csharp/Domain/Domain.cs | 57 ----- csharp/Domain/Domain.csproj | 65 ------ csharp/Domain/Domain.sln | 25 --- csharp/Domain/Neo.ConvertTask.dll | Bin 6144 -> 0 bytes csharp/Domain/Properties/AssemblyInfo.cs | 36 ---- csharp/Domain/build.tasks | 4 - csharp/Domain/packages.config | 4 - csharp/Lock/Lock.cs | 14 -- csharp/Lock/Lock.csproj | 65 ------ csharp/Lock/Lock.sln | 25 --- csharp/Lock/Neo.ConvertTask.dll | Bin 6144 -> 0 bytes csharp/Lock/Properties/AssemblyInfo.cs | 36 ---- csharp/Lock/build.tasks | 4 - csharp/Lock/packages.config | 4 - java/README.md | 35 --- java/ico-template/README.md | 9 - java/ico-template/pom.xml | 37 ---- java/ico-template/scripts/promote.sh | 17 -- .../main/java/org/ico/main/ICOTemplate.java | 203 ------------------ .../main/java/org/ico/token/NEP5Template.java | 109 ---------- .../java/org/ico/token/TemplateToken.java | 85 -------- 21 files changed, 834 deletions(-) delete mode 100644 csharp/Domain/Domain.cs delete mode 100644 csharp/Domain/Domain.csproj delete mode 100644 csharp/Domain/Domain.sln delete mode 100644 csharp/Domain/Neo.ConvertTask.dll delete mode 100644 csharp/Domain/Properties/AssemblyInfo.cs delete mode 100644 csharp/Domain/build.tasks delete mode 100644 csharp/Domain/packages.config delete mode 100644 csharp/Lock/Lock.cs delete mode 100644 csharp/Lock/Lock.csproj delete mode 100644 csharp/Lock/Lock.sln delete mode 100644 csharp/Lock/Neo.ConvertTask.dll delete mode 100644 csharp/Lock/Properties/AssemblyInfo.cs delete mode 100644 csharp/Lock/build.tasks delete mode 100644 csharp/Lock/packages.config delete mode 100644 java/README.md delete mode 100644 java/ico-template/README.md delete mode 100644 java/ico-template/pom.xml delete mode 100644 java/ico-template/scripts/promote.sh delete mode 100644 java/ico-template/src/main/java/org/ico/main/ICOTemplate.java delete mode 100644 java/ico-template/src/main/java/org/ico/token/NEP5Template.java delete mode 100644 java/ico-template/src/main/java/org/ico/token/TemplateToken.java diff --git a/csharp/Domain/Domain.cs b/csharp/Domain/Domain.cs deleted file mode 100644 index e4ee374..0000000 --- a/csharp/Domain/Domain.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Neo.SmartContract.Framework.Services.Neo; - -namespace Neo.SmartContract -{ - public class Domain : Framework.SmartContract - { - public static object Main(string operation, params object[] args) - { - switch (operation) - { - case "query": - return Query((string)args[0]); - case "register": - return Register((string)args[0], (byte[])args[1]); - case "transfer": - return Transfer((string)args[0], (byte[])args[1]); - case "delete": - return Delete((string)args[0]); - default: - return false; - } - } - - private static byte[] Query(string domain) - { - return Storage.Get(Storage.CurrentContext, domain); - } - - private static bool Register(string domain, byte[] owner) - { - if (!Runtime.CheckWitness(owner)) return false; - byte[] value = Storage.Get(Storage.CurrentContext, domain); - if (value != null) return false; - Storage.Put(Storage.CurrentContext, domain, owner); - return true; - } - - private static bool Transfer(string domain, byte[] to) - { - if (!Runtime.CheckWitness(to)) return false; - byte[] from = Storage.Get(Storage.CurrentContext, domain); - if (from == null) return false; - if (!Runtime.CheckWitness(from)) return false; - Storage.Put(Storage.CurrentContext, domain, to); - return true; - } - - private static bool Delete(string domain) - { - byte[] owner = Storage.Get(Storage.CurrentContext, domain); - if (owner == null) return false; - if (!Runtime.CheckWitness(owner)) return false; - Storage.Delete(Storage.CurrentContext, domain); - return true; - } - } -} diff --git a/csharp/Domain/Domain.csproj b/csharp/Domain/Domain.csproj deleted file mode 100644 index 0f653a2..0000000 --- a/csharp/Domain/Domain.csproj +++ /dev/null @@ -1,65 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {F6ED9982-E374-4A37-8332-CE4368A9B802} - Library - Properties - Neo.SmartContract - Domain - v4.6.2 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - none - true - bin\Release\ - - - prompt - 4 - - - - ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/csharp/Domain/Domain.sln b/csharp/Domain/Domain.sln deleted file mode 100644 index f2b4db2..0000000 --- a/csharp/Domain/Domain.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28729.10 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain.csproj", "{F6ED9982-E374-4A37-8332-CE4368A9B802}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F6ED9982-E374-4A37-8332-CE4368A9B802}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F6ED9982-E374-4A37-8332-CE4368A9B802}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F6ED9982-E374-4A37-8332-CE4368A9B802}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F6ED9982-E374-4A37-8332-CE4368A9B802}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {2DD73DE1-53B0-4C63-8003-B43C66247D61} - EndGlobalSection -EndGlobal diff --git a/csharp/Domain/Neo.ConvertTask.dll b/csharp/Domain/Neo.ConvertTask.dll dele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ZF0;3{zpH2Vn!Z`Hzi+nB#0%$9jW#F8Q`x05aaFY*-5?*0SVOFB zNi<@)W!qGbqz!V6u_Q72g34#2?^M4#L6ZU0LM-$-ltQcwPOaAJ_?8_RD}p!>j`#v9)$ zpsWBHO5>lFarD!`QU6~TdNugLC$%pa|F0fh{pE8bM$0DO)%+u%x(Y^s8myWmV8_CD z7M`c5LbIqvvR$c0Wg#`ebs;xVmn>DOlmeX#eh8x)eDa`WL96&Fmflu6-BkPaQ4TcG zW{lKOr8uf#33EHJqCWZ{+f^qktN9nOT2txybIW*bfL6`(5m<03uly*l@N-;M*QA=s zp)=?S$g{BK;=P&ROSsO?w354Z>pXx;-Ce!&Dse!e6szl|Th zU#TB&bGKP5!s=&(vXaU-*+8KlIS@dnplZQ<1Es7X*!kc=3{GFGhORy*qtJ>}me2_7i zsQM~*UdEud7qTaJl&U`ex7aVoVo>d+zp?_nmMg2@@5{%Os88+T%JHjra`iqAs4+uW mm0W)bS!pBs22O;G*K!7|9*1SEZHE7!;ji#8{=EJFMc_X@(G - - - \ No newline at end of file diff --git a/csharp/Domain/packages.config b/csharp/Domain/packages.config deleted file mode 100644 index 59ff8b7..0000000 --- a/csharp/Domain/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/csharp/Lock/Lock.cs b/csharp/Lock/Lock.cs deleted file mode 100644 index 5e6e94e..0000000 --- a/csharp/Lock/Lock.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Neo.SmartContract.Framework.Services.Neo; - -namespace Neo.SmartContract -{ - public class Lock : Framework.SmartContract - { - public static bool Main(uint timestamp, byte[] pubkey, byte[] signature) - { - Header header = Blockchain.GetHeader(Blockchain.GetHeight()); - if (timestamp > header.Timestamp) return false; - return VerifySignature(signature, pubkey); - } - } -} diff --git a/csharp/Lock/Lock.csproj b/csharp/Lock/Lock.csproj deleted file mode 100644 index 0af4775..0000000 --- a/csharp/Lock/Lock.csproj +++ /dev/null @@ -1,65 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {02F32860-7875-4D48-BB8C-FCD121845C6F} - Library - Properties - Neo.SmartContract - Lock - v4.6.2 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - none - true - bin\Release\ - - - prompt - 4 - - - - ..\packages\Neo.SmartContract.Framework.2.9.3.1\lib\net40\Neo.SmartContract.Framework.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/csharp/Lock/Lock.sln b/csharp/Lock/Lock.sln deleted file mode 100644 index 26b6592..0000000 --- a/csharp/Lock/Lock.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28729.10 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lock", "Lock.csproj", "{02F32860-7875-4D48-BB8C-FCD121845C6F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {02F32860-7875-4D48-BB8C-FCD121845C6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {02F32860-7875-4D48-BB8C-FCD121845C6F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {02F32860-7875-4D48-BB8C-FCD121845C6F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {02F32860-7875-4D48-BB8C-FCD121845C6F}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {064793BF-C4BF-46A1-84EF-CCA728059867} - EndGlobalSection -EndGlobal diff --git a/csharp/Lock/Neo.ConvertTask.dll b/csharp/Lock/Neo.ConvertTask.dll deleted file mode 100644 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H2Vn!Z`Hzi+nB#0%$9jW#F8Q`x05aaFY*-5?*0SVOFB zNi<@)W!qGbqz!V6u_Q72g34#2?^M4#L6ZU0LM-$-ltQcwPOaAJ_?8_RD}p!>j`#v9)$ zpsWBHO5>lFarD!`QU6~TdNugLC$%pa|F0fh{pE8bM$0DO)%+u%x(Y^s8myWmV8_CD z7M`c5LbIqvvR$c0Wg#`ebs;xVmn>DOlmeX#eh8x)eDa`WL96&Fmflu6-BkPaQ4TcG zW{lKOr8uf#33EHJqCWZ{+f^qktN9nOT2txybIW*bfL6`(5m<03uly*l@N-;M*QA=s zp)=?S$g{BK;=P&ROSsO?w354Z>pXx;-Ce!&Dse!e6szl|Th zU#TB&bGKP5!s=&(vXaU-*+8KlIS@dnplZQ<1Es7X*!kc=3{GFGhORy*qtJ>}me2_7i zsQM~*UdEud7qTaJl&U`ex7aVoVo>d+zp?_nmMg2@@5{%Os88+T%JHjra`iqAs4+uW mm0W)bS!pBs22O;G*K!7|9*1SEZHE7!;ji#8{=EJFMc_X@(G - - - \ No newline at end of file diff --git a/csharp/Lock/packages.config b/csharp/Lock/packages.config deleted file mode 100644 index 59ff8b7..0000000 --- a/csharp/Lock/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/java/README.md b/java/README.md deleted file mode 100644 index f7fcaee..0000000 --- a/java/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# Java Examples for NEO - -This repository contains resources and quick starts to help Java developers get started on the NEO blockchain. - -## Setup -You will need to setup a few things before getting started with these examples. - -**Required** - * [neo-devpack-java](https://github.com/neo-project/neo-devpack-java) – Java Native Interfaces (JNI) for Neo's methods - * [neo-compiler](https://github.com/neo-project/neo-compiler) – Converter from Java bytecode to Neo bytecode - - - **Advised** - * [neo-privatenet](https://hub.docker.com/r/cityofzion/neo-privatenet/) – Docker image for local testing  - * [neo-python](https://github.com/CityOfZion/neo-python) – CLI for NEO - - -For instructions on the setup process, see the [NEO docs](http://docs.neo.org) - -## Development Notes - -The Java source code that is written is converted to an avm file (Neo's Virtual Machine bytecode) by the neoj neo-compiler. There are a few limitations with this compiler in its current state that are important to mention. - -1. Method calls while instantiating a field variable will result in runtime errors. Example: -Do not do the following -```java -public static final byte[] OWNER = - Helper.asByteArray"AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y"; -``` - -2. Package names cannot start with **org.neo** as they will be ignored by the neoj neo-compiler. -```csharp - var bskip = cc.classfile.Name.IndexOf("org.neo.") == 0 || cc.classfile.Name.IndexOf("src.org.neo.") == 0; -``` -See [neo-compiler's JAVAModule](https://github.com/neo-project/neo-compiler/blob/92533c40058cdda9be67e94a0e13712f16017b8c/neoj/JVM/JAVAModule.cs#L55) diff --git a/java/ico-template/README.md b/java/ico-template/README.md deleted file mode 100644 index e523d9a..0000000 --- a/java/ico-template/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# ICO Template -To run this ICO Template, you must first setup [neo-devpack-java](https://github.com/neo-project/neo-devpack-java) and install the artifact to your local maven .m2 folder as well as your system's dotnet folder. - - -## Additional Resources -### Promotion process -**Mac OS** - -There is a bash script file called *promote.sh* that simplifies compiling the template but makes some assumptions on the location of the neo-compiler and neo-python projects. diff --git a/java/ico-template/pom.xml b/java/ico-template/pom.xml deleted file mode 100644 index c5ec847..0000000 --- a/java/ico-template/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - 4.0.0 - org.neo.ico - ico-template - 1.0.0 - - - UTF-8 - 1.8 - 3.6.1 - - - - - org.neo.smartcontract.framework - neo-devpack-java - 2.3.0 - - - - - src/main/java - - - maven-compiler-plugin - ${maven.compiler.plugin.version} - - ${java.version} - ${java.version} - ${project.build.sourceEncoding} - - - - - - diff --git a/java/ico-template/scripts/promote.sh b/java/ico-template/scripts/promote.sh deleted file mode 100644 index 3e9e990..0000000 --- a/java/ico-template/scripts/promote.sh +++ /dev/null @@ -1,17 +0,0 @@ -#bin/bash - -artifactId=ico-template -version=1.0.0 -jarFile=$artifactId-$version.jar -neocompilerLocation=../../neo-compiler -neoj=$neocompilerLocation/neoj -neopythonLocation=~/Documents/neo-python/ - -cd ../ -mvn clean install -cp target/$jarFile $neoj/$jarFile - -cd $neoj -dotnet run $jarFile - -cp $artifactId-$version.avm $neopythonLocation diff --git a/java/ico-template/src/main/java/org/ico/main/ICOTemplate.java b/java/ico-template/src/main/java/org/ico/main/ICOTemplate.java deleted file mode 100644 index ba0b22e..0000000 --- a/java/ico-template/src/main/java/org/ico/main/ICOTemplate.java +++ /dev/null @@ -1,203 +0,0 @@ -package org.ico.main; - -import org.neo.smartcontract.framework.services.neo.TriggerType; -import org.neo.smartcontract.framework.services.system.ExecutionEngine; - -import java.math.BigInteger; - -import org.ico.token.NEP5Template; -import org.ico.token.TemplateToken; -import org.neo.smartcontract.framework.Helper; -import org.neo.smartcontract.framework.SmartContract; -import org.neo.smartcontract.framework.services.neo.Runtime; -import org.neo.smartcontract.framework.services.neo.Storage; -import org.neo.smartcontract.framework.services.neo.Transaction; -import org.neo.smartcontract.framework.services.neo.TransactionOutput; - -public class ICOTemplate extends SmartContract { - - /** - * The EPOC start time for the ICO. The associated time unit is seconds - */ - private final static long ICO_START_TIME = 1521003600; - - /** - * The EPOC end time for the ICO. The associated time unit is seconds - */ - private final static long ICO_END_TIME = 1523682000; - - /** - * The Entry point for the ICO Smart Contract. The neoj neo-compiler looks - * for a method named: Main with an uppercase M. - */ - public static Object Main(String operation, Object[] args) { - TriggerType trigger = Runtime.trigger(); - - if (trigger == TriggerType.Verification) { - boolean isOwner = Runtime.checkWitness(TemplateToken.getOwner()); - - if (isOwner) { - return true; - } - return false; - - } else if (trigger == TriggerType.Application) { - - if (operation.equals("deploy")) { - return deploy(); - } else if (operation.equals("mintTokens")) { - return mintTokens(); - } else if (operation.equals(NEP5Template.TOTAL_SUPPLY)) { - return NEP5Template.totalSupply(); - } else if (operation.equals(NEP5Template.NAME)) { - return NEP5Template.name(); - } else if (operation.equals(NEP5Template.SYMBOL)) { - return NEP5Template.symbol(); - } else if (operation.equals(NEP5Template.DECIMALS)) { - return NEP5Template.decimalsString(); - } else if (operation.equals(NEP5Template.BALANCE_OF)) { - if (args.length < 1) { - Runtime.log("No account argument-No action"); - return false; - } - - byte[] account = Helper.asByteArray((String) args[0]); - return NEP5Template.balanceOf(account); - } else if (operation.equals(NEP5Template.TRANSFER)) { - if (args.length != 3) { - Runtime.log("Insufficient number of arguments-No action"); - return false; - } - - byte[] from = Helper.asByteArray((String) args[0]); - byte[] to = Helper.asByteArray((String) args[1]); - BigInteger amount = BigInteger.valueOf(Long.valueOf((String) args[2])); - - return NEP5Template.transfer(from, to, amount); - } - } - - return false; - } - - public static Object deploy() { - if (getTotalSupply().length != 0) { - Runtime.log("Insufficient token supply-No action"); - return false; - } - - Storage.put(Storage.currentContext(), TemplateToken.getOwner(), TemplateToken.getPreIcoCap()); - Storage.put(Storage.currentContext(), NEP5Template.TOTAL_SUPPLY, TemplateToken.getPreIcoCap()); - - return true; - } - - public static Object mintTokens() { - byte[] sender = getSender(); - - if (sender.length == 0) { - Runtime.log("Asset is not neo-No action"); - return false; - } - - // The current exchange rate between ICO tokens and Neo during the token - // swap period - BigInteger swapRate = currentSwapRate(); - if (swapRate.equals(BigInteger.ZERO)) { - Runtime.log("Crowd funding failure-No action"); - return false; - } - - BigInteger contributionAmount = getContributionAmount(); - BigInteger tokenTransferAmount = currentSwapToken(sender, contributionAmount, swapRate); - if (tokenTransferAmount.equals(BigInteger.ZERO)) { - Runtime.log("Zero token transfer amount-No action"); - return false; - } - - byte[] senderBalanceByteArray = Storage.get(Storage.currentContext(), sender); - BigInteger senderBalance = new BigInteger(senderBalanceByteArray); - BigInteger postTransferAmount = senderBalance.add(tokenTransferAmount); - Storage.put(Storage.currentContext(), sender, postTransferAmount); - - BigInteger tokenAndSupply = tokenTransferAmount.add(NEP5Template.totalSupply()); - Storage.put(Storage.currentContext(), NEP5Template.TOTAL_SUPPLY, tokenAndSupply); - - return true; - } - - private static BigInteger currentSwapRate() { - long icoDuration = ICO_END_TIME - ICO_START_TIME; - - long now = Runtime.time(); - long time = now - ICO_START_TIME; - - if (time < 0) { - return BigInteger.ZERO; - } else if (time < icoDuration) { - return TemplateToken.getBasicRate(); - } - - return BigInteger.ZERO; - } - - private static BigInteger getContributionAmount() { - Transaction tx = (Transaction) ExecutionEngine.scriptContainer(); - TransactionOutput[] outputs = tx.outputs(); - BigInteger contributionAmount = BigInteger.ZERO; - - for (TransactionOutput transaction : outputs) { - if (transaction.scriptHash() == getReceiver() && transaction.assetId() == neoAssetId()) { - BigInteger transactionAmount = BigInteger.valueOf(transaction.value()); - contributionAmount = contributionAmount.add(transactionAmount); - } - } - - return contributionAmount; - } - - private static BigInteger currentSwapToken(byte[] sender, BigInteger contributedAmount, BigInteger swapRate) { - BigInteger tokenAmount = contributedAmount.divide(TemplateToken.getDecimals()).multiply(swapRate); - BigInteger tokenBalance = TemplateToken.getTotalAmount().subtract(NEP5Template.totalSupply()); - - if (tokenBalance.compareTo(BigInteger.ZERO) <= 0) { - return BigInteger.ZERO; - } else if (tokenBalance.compareTo(tokenAmount) < 0) { - tokenAmount = tokenBalance; - } - - return tokenAmount; - } - - /** - * @return smart contract script hash - */ - private static byte[] getReceiver() { - return ExecutionEngine.executingScriptHash(); - } - - private static byte[] getSender() { - Transaction tx = (Transaction) ExecutionEngine.scriptContainer(); - TransactionOutput[] reference = tx.references(); - - for (TransactionOutput output : reference) { - if (output.assetId() == neoAssetId()) { - return output.scriptHash(); - } - } - return Helper.asByteArray(""); - } - - private static byte[] getTotalSupply() { - return Storage.get(Storage.currentContext(), NEP5Template.TOTAL_SUPPLY); - } - - private static byte[] neoAssetId() { - byte[] assetId = new byte[] { (byte) 155, (byte) 124, (byte) 255, (byte) 218, (byte) 166, (byte) 116, - (byte) 190, (byte) 174, (byte) 15, (byte) 147, (byte) 14, (byte) 190, (byte) 96, (byte) 133, (byte) 175, - (byte) 144, (byte) 147, (byte) 229, (byte) 254, (byte) 86, (byte) 179, (byte) 74, (byte) 92, (byte) 34, - (byte) 12, (byte) 205, (byte) 207, (byte) 110, (byte) 252, (byte) 51, (byte) 111, (byte) 197 }; - return assetId; - } - -} diff --git a/java/ico-template/src/main/java/org/ico/token/NEP5Template.java b/java/ico-template/src/main/java/org/ico/token/NEP5Template.java deleted file mode 100644 index 4a728ca..0000000 --- a/java/ico-template/src/main/java/org/ico/token/NEP5Template.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.ico.token; - -import java.math.BigInteger; - -import org.neo.smartcontract.framework.services.neo.Runtime; -import org.neo.smartcontract.framework.services.neo.Storage; - -/** - * NEP-5 outlines a token standard for the NEO blockchain that will provide - * systems with a generalized interaction mechanism for tokenized Smart - * Contracts. - */ -public class NEP5Template { - public final static String TOTAL_SUPPLY = "totalSupply"; - public final static String NAME = "name"; - public final static String SYMBOL = "symbol"; - public final static String DECIMALS = "decimals"; - public final static String BALANCE_OF = "balanceOf"; - public final static String TRANSFER = "transfer"; - - /** - * @return the total token supply deployed in the system - */ - public static BigInteger totalSupply() { - byte[] totalSupply = Storage.get(Storage.currentContext(), "totalSupply"); - return new BigInteger(totalSupply); - } - - /** - * @return the token name - */ - public static String name() { - return TemplateToken.getName(); - } - - /** - * @return the token symbol - */ - public static String symbol() { - return TemplateToken.getSymbol(); - } - - /** - * @return the number of decimals used by the token - */ - public static byte decimals() { - return TemplateToken.decimals(); - } - - /** - * @return the number of decimals used by the token as a String - */ - public static String decimalsString() { - return String.valueOf(TemplateToken.decimals()); - } - - /** - * @return the token balance of the account - */ - public static BigInteger balanceOf(byte[] account) { - return new BigInteger(Storage.get(Storage.currentContext(), account)); - } - - /** - * Will transfer an amount of tokens from the from account to the to account - */ - public static Boolean transfer(byte[] from, byte[] to, BigInteger amount) { - if (amount.compareTo(BigInteger.ZERO) <= 0) { - Runtime.log("No transfer amount-No action"); - return false; - } - - if (to.length != 20) return false; - - if (!Runtime.checkWitness(from)) { - Runtime.log("Not transfering from self-No action"); - return false; - } - - byte[] senderSupplyByteArray = Storage.get(Storage.currentContext(), from); - BigInteger senderSupply = new BigInteger(senderSupplyByteArray); - - if (senderSupply.compareTo(amount) < 0) { - Runtime.log("Insufficient funds for sender-No action"); - return false; - } - - if (from == to) { - Runtime.log("Transfering to self-No action"); - return true; - } - - if (senderSupply == amount) { - Storage.delete(Storage.currentContext(), from); - } else { - BigInteger remainingSupply = senderSupply.subtract(amount); - Storage.put(Storage.currentContext(), from, remainingSupply); - } - - byte[] receiverSupplyByteArray = Storage.get(Storage.currentContext(), to); - BigInteger receiverSupply = new BigInteger(receiverSupplyByteArray); - - BigInteger postTransferAmount = receiverSupply.add(amount); - Storage.put(Storage.currentContext(), to, postTransferAmount); - - return true; - } - -} diff --git a/java/ico-template/src/main/java/org/ico/token/TemplateToken.java b/java/ico-template/src/main/java/org/ico/token/TemplateToken.java deleted file mode 100644 index 76ef1b1..0000000 --- a/java/ico-template/src/main/java/org/ico/token/TemplateToken.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.ico.token; - -import java.math.BigInteger; - -import org.neo.smartcontract.framework.Helper; - -public class TemplateToken { - - /** - * The full name of the token - */ - private final static String NAME = "Test Token"; - - /** - * The symbol that will be used to identify the token - */ - private final static String SYMBOL = "TST"; - - /** - * The unique id to the owner of the token - */ - private final static String OWNER = "AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y"; - - /** - * The factor is the value of a single token after the factor is applied - */ - private final static long FACTOR = 1000000000; - - private final static long NEO_DECIMALS = 1000000000; - - private final static long TOTAL_AMOUNT = 100000000 * FACTOR; - - private final static long PRE_ICO_CAP = 30000000 * FACTOR; - - private final static long BASIC_RATE = 1000 * FACTOR; - - public static String getName() { - return NAME; - } - - public static String getSymbol() { - return SYMBOL; - } - - public static byte[] getOwner() { - return Helper.asByteArray(OWNER); - } - - /** - * - * Because NEO is traded in whole numbers we set a decimal value so that - * smaller amounts of the token can be traded. 1 token = 1*10^8 = 100000000 - */ - public static byte decimals() { - return 8; - } - - /** - * The neo decimals is the value of a single token after the factor is - * applied - */ - public static BigInteger getDecimals() { - return BigInteger.valueOf(NEO_DECIMALS); - } - - /** - * The total number of token that exist - */ - public static BigInteger getTotalAmount() { - return BigInteger.valueOf(TOTAL_AMOUNT); - } - - public static BigInteger getPreIcoCap() { - return BigInteger.valueOf(PRE_ICO_CAP); - } - - /** - * The current exchange rate between the ICO tokens and neo during the token - * swap period - */ - public static BigInteger getBasicRate() { - return BigInteger.valueOf(BASIC_RATE); - } - -} From 76f9c228413fc0619372bb1795c39f465300fa2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Thu, 8 Apr 2021 14:52:50 +0800 Subject: [PATCH 13/15] Update OracleDemo.cs (#42) --- csharp/Oracle/OracleDemo.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/csharp/Oracle/OracleDemo.cs b/csharp/Oracle/OracleDemo.cs index 69dd1c4..996aeb0 100644 --- a/csharp/Oracle/OracleDemo.cs +++ b/csharp/Oracle/OracleDemo.cs @@ -22,6 +22,7 @@ public static void DoRequest() public static void Callback(string url, string userdata, OracleResponseCode code, string result) { + if (ExecutionEngine.CallingScriptHash != Oracle.Hash) throw new Exception("Unauthorized!"); if (code != OracleResponseCode.Success) throw new Exception("Oracle response failure with code " + (byte)code); object ret = StdLib.JsonDeserialize(result); // [ "hello world" ] From 0b2ff45429214eedadd95697e349269b6be48bc1 Mon Sep 17 00:00:00 2001 From: Owen Zhang <38493437+superboyiii@users.noreply.github.com> Date: Wed, 30 Jun 2021 01:37:41 +0800 Subject: [PATCH 14/15] sync to Neo.SmartContract.Framework v3.0.0-rc3 (#44) * sync to Neo.SmartContract.Framework v3.0.0-CI00300 * fix * Add safe label and IsPayable() * add NuGet.Config * For RC2 * update csproj * improve * format * fix * fix * set data to null * Change Prefix_Contract to byte --- csharp/NEP17/AssetStorage.cs | 37 ----------------- csharp/NEP17/NEP17.Crowdsale.cs | 49 ----------------------- csharp/NEP17/NEP17.Methods.cs | 32 --------------- csharp/NEP17/NEP17.Owner.cs | 46 --------------------- csharp/NEP17/NEP17.cs | 64 +++++++++++++++++++++--------- csharp/NEP17/NEP17.csproj | 6 +-- csharp/NEP17/TotalSupplyStorage.cs | 24 ----------- 7 files changed, 48 insertions(+), 210 deletions(-) delete mode 100644 csharp/NEP17/AssetStorage.cs delete mode 100644 csharp/NEP17/NEP17.Crowdsale.cs delete mode 100644 csharp/NEP17/NEP17.Methods.cs delete mode 100644 csharp/NEP17/NEP17.Owner.cs delete mode 100644 csharp/NEP17/TotalSupplyStorage.cs diff --git a/csharp/NEP17/AssetStorage.cs b/csharp/NEP17/AssetStorage.cs deleted file mode 100644 index 4f0b1bb..0000000 --- a/csharp/NEP17/AssetStorage.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Neo.SmartContract.Framework.Services.Neo; -using System.Numerics; - -namespace Neo.SmartContract.Examples -{ - public static class AssetStorage - { - public static readonly string mapName = "asset"; - - public static void Increase(UInt160 key, BigInteger value) => Put(key, Get(key) + value); - - public static void Enable() => Storage.CurrentContext.CreateMap(mapName).Put("enable", 1); - - public static void Disable() => Storage.CurrentContext.CreateMap(mapName).Put("enable", 0); - - public static void Reduce(UInt160 key, BigInteger value) - { - var oldValue = Get(key); - if (oldValue == value) - Remove(key); - else - Put(key, oldValue - value); - } - - public static void Put(UInt160 key, BigInteger value) => Storage.CurrentContext.CreateMap(mapName).Put(key, value); - - public static BigInteger Get(UInt160 key) - { - var value = Storage.CurrentContext.CreateMap(mapName).Get(key); - return value is null ? 0 : (BigInteger)value; - } - - public static bool GetPaymentStatus() => ((BigInteger) Storage.CurrentContext.CreateMap(mapName).Get("enable")).Equals(1); - - public static void Remove(UInt160 key) => Storage.CurrentContext.CreateMap(mapName).Delete(key); - } -} diff --git a/csharp/NEP17/NEP17.Crowdsale.cs b/csharp/NEP17/NEP17.Crowdsale.cs deleted file mode 100644 index fe390ff..0000000 --- a/csharp/NEP17/NEP17.Crowdsale.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Neo.SmartContract.Framework.Services.Neo; -using Neo.SmartContract.Framework.Services.System; -using System; -using System.Numerics; - -namespace Neo.SmartContract.Examples -{ - partial class NEP17Demo - { - public static void OnNEP17Payment(UInt160 from, BigInteger amount, object data) - { - if (AssetStorage.GetPaymentStatus()) - { - if (ExecutionEngine.CallingScriptHash == NEO.Hash) - { - Mint(amount * TokensPerNEO); - } - else if (ExecutionEngine.CallingScriptHash == GAS.Hash) - { - if (from != null) Mint(amount * TokensPerGAS); - } - else - { - throw new Exception("Wrong calling script hash"); - } - } - else - { - throw new Exception("Payment is disable on this contract!"); - } - } - - private static void Mint(BigInteger amount) - { - var totalSupply = TotalSupplyStorage.Get(); - - var avaliable_supply = MaxSupply - totalSupply; - - if (amount <= 0) throw new Exception("Amount must be greater than zero."); - if (amount > avaliable_supply) throw new Exception("Insufficient supply for mint tokens."); - - Transaction tx = (Transaction)ExecutionEngine.ScriptContainer; - AssetStorage.Increase(tx.Sender, amount); - TotalSupplyStorage.Increase(amount); - - OnTransfer(null, tx.Sender, amount); - } - } -} diff --git a/csharp/NEP17/NEP17.Methods.cs b/csharp/NEP17/NEP17.Methods.cs deleted file mode 100644 index ddf5fc7..0000000 --- a/csharp/NEP17/NEP17.Methods.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Neo.SmartContract.Framework.Services.Neo; -using Neo.SmartContract.Framework.Services.System; -using System; -using System.Numerics; - -namespace Neo.SmartContract.Examples -{ - partial class NEP17Demo - { - public static BigInteger TotalSupply() => TotalSupplyStorage.Get(); - - public static BigInteger BalanceOf(UInt160 account) => AssetStorage.Get(account); - - public static bool Transfer(UInt160 from, UInt160 to, BigInteger amount, object data) - { - if (amount <= 0) throw new Exception("The parameter amount MUST be greater than 0."); - if (!Runtime.CheckWitness(from) && !from.Equals(ExecutionEngine.CallingScriptHash)) throw new Exception("No authorization."); - if (AssetStorage.Get(from) < amount) throw new Exception("Insufficient balance."); - if (from == to) return true; - - AssetStorage.Reduce(from, amount); - AssetStorage.Increase(to, amount); - - OnTransfer(from, to, amount); - - // Validate payable - if (ContractManagement.GetContract(to) != null) - Contract.Call(to, "onNEP17Payment", CallFlags.All, new object[] { from, amount, data }); - return true; - } - } -} diff --git a/csharp/NEP17/NEP17.Owner.cs b/csharp/NEP17/NEP17.Owner.cs deleted file mode 100644 index 3cf2a01..0000000 --- a/csharp/NEP17/NEP17.Owner.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Neo.SmartContract.Framework; -using Neo.SmartContract.Framework.Services.Neo; -using System; - -namespace Neo.SmartContract.Examples -{ - partial class NEP17Demo - { - public static void _deploy(object data, bool update) - { - if (update) return; - if (TotalSupplyStorage.Get() > 0) throw new Exception("Contract has been deployed."); - - TotalSupplyStorage.Increase(InitialSupply); - AssetStorage.Increase(Owner, InitialSupply); - - OnTransfer(null, Owner, InitialSupply); - } - - public static void Update(ByteString nefFile, string manifest, object data) - { - if (!IsOwner()) throw new Exception("No authorization."); - ContractManagement.Update(nefFile, manifest, data); - } - - public static void Destroy() - { - if (!IsOwner()) throw new Exception("No authorization."); - ContractManagement.Destroy(); - } - - public static void EnablePayment() - { - if (!IsOwner()) throw new Exception("No authorization."); - AssetStorage.Enable(); - } - - public static void DisablePayment() - { - if (!IsOwner()) throw new Exception("No authorization."); - AssetStorage.Disable(); - } - - private static bool IsOwner() => Runtime.CheckWitness(Owner); - } -} diff --git a/csharp/NEP17/NEP17.cs b/csharp/NEP17/NEP17.cs index d5e02c9..9a99286 100644 --- a/csharp/NEP17/NEP17.cs +++ b/csharp/NEP17/NEP17.cs @@ -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 @@ -10,28 +11,53 @@ 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; + // Prefix_TotalSupply = 0x00; Prefix_Balance = 0x01; + private const byte Prefix_Contract = 0x02; + public static readonly StorageMap ContractMap = new StorageMap(Storage.CurrentContext, Prefix_Contract); + private static readonly byte[] ownerKey = "owner".ToByteArray(); + 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 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)ContractMap.Get(ownerKey); + } - public static string Symbol() => "TokenSymbol"; + public static new void Mint(UInt160 account, BigInteger amount) + { + if (!IsOwner()) throw new InvalidOperationException("No Authorization!"); + Nep17Token.Mint(account, amount); + } - public static ulong Decimals() => 8; + 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) + { + if (!IsOwner()) throw new InvalidOperationException("No Authorization!"); + ContractManagement.Update(nefFile, manifest, null); + return true; + } + + public static bool Destroy() + { + if (!IsOwner()) throw new InvalidOperationException("No Authorization!"); + ContractManagement.Destroy(); + return true; + } } } diff --git a/csharp/NEP17/NEP17.csproj b/csharp/NEP17/NEP17.csproj index f2703bf..b04b86d 100644 --- a/csharp/NEP17/NEP17.csproj +++ b/csharp/NEP17/NEP17.csproj @@ -1,4 +1,4 @@ - + net5.0 @@ -6,13 +6,13 @@ - + - + diff --git a/csharp/NEP17/TotalSupplyStorage.cs b/csharp/NEP17/TotalSupplyStorage.cs deleted file mode 100644 index f31264f..0000000 --- a/csharp/NEP17/TotalSupplyStorage.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Neo.SmartContract.Framework.Services.Neo; -using System.Numerics; - -namespace Neo.SmartContract.Examples -{ - public static class TotalSupplyStorage - { - public static readonly string mapName = "contract"; - - public static readonly string key = "totalSupply"; - - public static void Increase(BigInteger value) => Put(Get() + value); - - public static void Reduce(BigInteger value) => Put(Get() - value); - - public static void Put(BigInteger value) => Storage.CurrentContext.CreateMap(mapName).Put(key, value); - - public static BigInteger Get() - { - var value = Storage.CurrentContext.CreateMap(mapName).Get(key); - return value is null ? 0 : (BigInteger)value; - } - } -} From fa6d793dab966adfbde7f90cf2ff7bdfe236bc4a Mon Sep 17 00:00:00 2001 From: Owen Zhang <38493437+superboyiii@users.noreply.github.com> Date: Tue, 20 Sep 2022 16:54:00 +0800 Subject: [PATCH 15/15] update to 3.4.0 (#51) --- csharp/NEP17/NEP17.cs | 6 +++++- csharp/NEP17/NEP17.csproj | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/csharp/NEP17/NEP17.cs b/csharp/NEP17/NEP17.cs index 9a99286..966a921 100644 --- a/csharp/NEP17/NEP17.cs +++ b/csharp/NEP17/NEP17.cs @@ -1,4 +1,5 @@ using Neo.SmartContract.Framework; +using Neo.SmartContract.Framework.Attributes; using Neo.SmartContract.Framework.Native; using Neo.SmartContract.Framework.Services; using System; @@ -20,13 +21,16 @@ public partial class NEP17Demo : Nep17Token public static readonly StorageMap ContractMap = new StorageMap(Storage.CurrentContext, Prefix_Contract); private static readonly byte[] ownerKey = "owner".ToByteArray(); private static bool IsOwner() => Runtime.CheckWitness(GetOwner()); - public override byte Decimals() => 8; + public override byte Decimals() => Factor(); public override string Symbol() => "NEP17"; + public static byte Factor() => 8; + public static void _deploy(object data, bool update) { if (update) return; ContractMap.Put(ownerKey, owner); + Nep17Token.Mint(owner, 100000000 * BigInteger.Pow(10, Factor())); } public static UInt160 GetOwner() diff --git a/csharp/NEP17/NEP17.csproj b/csharp/NEP17/NEP17.csproj index b04b86d..f562ec4 100644 --- a/csharp/NEP17/NEP17.csproj +++ b/csharp/NEP17/NEP17.csproj @@ -1,12 +1,12 @@  - net5.0 + net6.0 Neo.SmartContract.Examples - +