Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync update with neo pull 2119 #402

Merged
merged 41 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
cdc135f
Merge pull request #1 from neo-project/master
Sep 11, 2020
be2a614
Merge pull request #2 from neo-project/master
Oct 15, 2020
30893a3
Merge pull request #3 from neo-project/master
Nov 3, 2020
f293fb5
Merge pull request #4 from neo-project/master
Nov 23, 2020
6b0c49c
Upgrade target framework.
Nov 23, 2020
c36f9b2
Revert "Upgrade target framework."
Nov 25, 2020
0ce51ed
Safe Attribute
shargon Dec 5, 2020
782fa68
Update Contract1.cs (#398)
Nov 26, 2020
d13e363
Revert "publish neon to myget/github packages" (#395)
shargon Nov 28, 2020
85ca995
Remove Contract.Create、Contract.Update、Contract.Destroy; Add Contract…
Dec 7, 2020
1270f96
Merge branch 'master' into neo2119
Dec 7, 2020
b80c12f
Update
Dec 7, 2020
6f9aa5d
Merge branch 'neo2119' of https://github.com/chenzhitong/neo-devpack-…
Dec 7, 2020
25793fe
remove CallNative
Dec 7, 2020
6dc95ee
Update templates/Template.CSharp/Contract1.cs
Dec 8, 2020
ca0a550
Update templates/Template.CSharp/Contract1.cs
Dec 8, 2020
da4e1d8
Update tests/Neo.SmartContract.Framework.UnitTests/TestClasses/Contra…
Dec 8, 2020
e5d1685
public
Dec 9, 2020
d6f559c
Merge branch 'neo2119' of https://github.com/chenzhitong/neo-devpack-…
Dec 9, 2020
5658be1
Merge branch 'master' into safe-attribute
shargon Dec 10, 2020
21bef7c
Merge remote-tracking branch 'neo-project/master' into neo2119
shargon Dec 10, 2020
e2cf49b
Update
shargon Dec 10, 2020
479d5dd
Update call
shargon Dec 10, 2020
0bd6915
Fix more UT
shargon Dec 10, 2020
545143a
Update hashes
shargon Dec 10, 2020
c2f974b
Mock contract create
shargon Dec 10, 2020
f287e4d
Fix more UT
shargon Dec 10, 2020
1e02f34
Fix UT
shargon Dec 10, 2020
0298a2e
More fixes
shargon Dec 10, 2020
2d91cb3
Merge pull request #6 from shargon/safe-attribute
Dec 10, 2020
06c3b30
More fixes
shargon Dec 10, 2020
a7ce9fe
More UT
shargon Dec 10, 2020
3493312
Fix UT's
shargon Dec 10, 2020
a754a23
dotnet-format
shargon Dec 10, 2020
3e09e8d
Fix Last test
shargon Dec 10, 2020
431f482
Merge branch 'master' into neo2119
Dec 11, 2020
9439ccd
Update
Dec 14, 2020
c7d4ca8
Remove private properties
shargon Dec 14, 2020
493f225
Merge branch 'master' into neo2119
Dec 15, 2020
b0770d2
Fixed UT
Dec 15, 2020
aa997f3
disable warning CS0626
erikzhang Dec 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/Neo.SmartContract.Framework/Services/Neo/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ public class Contract
[Syscall("System.Contract.CallEx")]
public static extern object CallEx(UInt160 scriptHash, string method, object[] arguments, CallFlags flag);

[Syscall("System.Contract.Create")]
public static extern Contract Create(byte[] script, string manifest);

[Syscall("System.Contract.Update")]
public static extern void Update(byte[] script, string manifest);
shargon marked this conversation as resolved.
Show resolved Hide resolved

[Syscall("System.Contract.Destroy")]
public static extern void Destroy();

[Syscall("System.Contract.GetCallFlags")]
public static extern byte GetCallFlags();

Expand Down
2 changes: 2 additions & 0 deletions src/Neo.SmartContract.Framework/Services/Neo/GAS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class GAS
{
public static extern UInt160 Hash { [ContractHash] get; }
public static extern string Name { get; }
public static extern int Id { get; }
public static extern uint ActiveBlockIndex { get; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this two methods, which weren't defined for contract.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you remove these fields, the fifth field will become the third one, which will be incorrect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use private

Copy link
Member

@shargon shargon Dec 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested without ActiveBlockIndex and it works well, I think that we should remove it. Please take a look @erikzhang

public static extern string Symbol { get; }
public static extern byte Decimals { get; }
public static extern BigInteger TotalSupply();
Expand Down
16 changes: 16 additions & 0 deletions src/Neo.SmartContract.Framework/Services/Neo/ManagementContract.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Neo.SmartContract.Framework.Services.Neo
{
[Contract("0xdf18cb2476964c241558ed1e2e8881dcd2d50bde")]
class ManagementContract
shargon marked this conversation as resolved.
Show resolved Hide resolved
{
public static extern UInt160 Hash { [ContractHash] get; }
public static extern string Name { get; }
public static extern int Id { get; }
public static extern uint ActiveBlockIndex { get; }
public static extern Contract GetContract(UInt160 hash);
}
}
2 changes: 2 additions & 0 deletions src/Neo.SmartContract.Framework/Services/Neo/Oracle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class Oracle
public static extern UInt160 Hash { [ContractHash] get; }
public const uint MinimumResponseFee = 0_10000000;
public static extern string Name { get; }
public static extern int Id { get; }
public static extern uint ActiveBlockIndex { get; }
public static extern void Request(string url, string filter, string callback, object userData, long gasForResponse);
}
}
2 changes: 2 additions & 0 deletions src/Neo.SmartContract.Framework/Services/Neo/Policy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class Policy
{
public static extern UInt160 Hash { [ContractHash] get; }
public static extern string Name();
public static extern int Id { get; }
public static extern uint ActiveBlockIndex { get; }
public static extern uint GetMaxTransactionsPerBlock();
public static extern uint GetMaxBlockSize();
public static extern long GetMaxBlockSystemFee();
Expand Down
76 changes: 38 additions & 38 deletions templates/Template.CSharp/Contract1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,44 @@
namespace $safeprojectname$
{
[ManifestExtra("Author", "Neo")]
[ManifestExtra("Email", "[email protected]")]
[ManifestExtra("Description", "This is a contract example")]
public class Contract1 : SmartContract
[ManifestExtra("Email", "[email protected]")]
[ManifestExtra("Description", "This is a contract example")]
public class Contract1 : SmartContract
{
//TODO: Replace it with your own address.
static readonly UInt160 Owner = "NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB".ToScriptHash();

private static bool IsOwner() => Runtime.CheckWitness(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();

// TODO: Replace it with your methods.
public static byte[] MyMethod()
{
//TODO: Replace it with your own address.
static readonly UInt160 Owner = "NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB".ToScriptHash();

private static bool IsOwner() => Runtime.CheckWitness(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();

// TODO: Replace it with your methods.
public static byte[] MyMethod()
{
return Storage.Get("Hello");
}

public static void _deploy(bool update)
{
if (update) return;

// It will be executed during deploy
Storage.Put("Hello", "World");
}

public static void Update(byte[] script, string manifest)
{
if (!IsOwner()) throw new Exception("No authorization.");
Contract.Update(script, manifest);
}

public static void Destroy()
{
if (!IsOwner()) throw new Exception("No authorization.");
Contract.Destroy();
}
return Storage.Get("Hello");
}

public static void _deploy(bool update)
{
if (update) return;

// It will be executed during deploy
Storage.Put("Hello", "World");
}

public static void Update(byte[] nefFile, string manifest)
{
if (!IsOwner()) throw new Exception("No authorization.");
Contract.Call(ManagementContract.Hash, "update", new object[] { nefFile, manifest });
}

public static void Destroy()
{
if (!IsOwner()) throw new Exception("No authorization.");
Contract.Call(ManagementContract.Hash, "destroy", new object[] {});
}
}
}
6 changes: 3 additions & 3 deletions templates/Template.NEP5.CSharp/NEP5.Owner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ public static bool Deploy()
return true;
}

public static void Update(byte[] script, string manifest)
public static void Update(byte[] nefFile, string manifest)
{
if (!IsOwner()) throw new Exception("No authorization.");
Contract.Update(script, manifest);
Contract.Call(ManagementContract.Hash, "update", nefFile, manifest);
}

public static void Destroy()
{
if (!IsOwner()) throw new Exception("No authorization.");
Contract.Destroy();
Contract.Call(ManagementContract.Hash, "destroy");
}

private static bool IsOwner() => Runtime.CheckWitness(Owner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@ public static object Call(UInt160 scriptHash, string method, object[] arguments)
return Contract.Call(scriptHash, method, arguments);
}

public static object Create(byte[] script, string manifest)
{
return Contract.Create(script, manifest);
}

public static void Update(byte[] script, string manifest)
{
Contract.Update(script, manifest);
}

public static void Destroy()
{
Contract.Destroy();
}

public static int GetCallFlags()
{
return Contract.GetCallFlags();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ namespace Neo.Compiler.MSIL.TestClasses
{
public class Contract_CreateAndUpdate : SmartContract.Framework.SmartContract
{
public static int OldContract(byte[] script, string manifest)
public static int OldContract(byte[] nefFile, string manifest)
{
Contract.Update(script, manifest);
Contract.Call(ManagementContract.Hash, "update", new object[] { nefFile, manifest });
return 123;
}
}
Expand Down