Skip to content

Commit

Permalink
New examples from Jimmy Core PR
Browse files Browse the repository at this point in the history
  • Loading branch information
vncoelho committed Jan 3, 2024
1 parent 5b825f4 commit 25240b1
Show file tree
Hide file tree
Showing 22 changed files with 2,029 additions and 5 deletions.
21 changes: 20 additions & 1 deletion assets/eco-scripts/global_var.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,26 @@ var cSharpFiles = [
["./assets/sc_examples/csharp/NNS/NameState.cs"],
["./assets/sc_examples/csharp/NNS/RecordType.cs"],
["./assets/sc_examples/csharp/NNS/RecordState.cs"]
]
],
[
["./assets/sc_examples/csharp/NFT-Core/Loot.Admin.cs"],
["./assets/sc_examples/csharp/NFT-Core/Loot.cs"],
["./assets/sc_examples/csharp/NFT-Core/Token.cs"],
["./assets/sc_examples/csharp/NFT-Core/Token.Item.cs"],
["./assets/sc_examples/csharp/NFT-Core/Tools.cs"]
],
["./assets/sc_examples/csharp/ContractCall-Core.cs"],
["./assets/sc_examples/csharp/Event-Core.cs"],
["./assets/sc_examples/csharp/Exception-Core.cs"],
["./assets/sc_examples/csharp/HelloWorld-Core.cs"],
["./assets/sc_examples/csharp/Inscription-Core.cs"],
["./assets/sc_examples/csharp/Modifier-Core.cs"],
["./assets/sc_examples/csharp/Nep17Token-Core.cs"],
["./assets/sc_examples/csharp/Oracle-Core.cs"],
["./assets/sc_examples/csharp/Runtime-Core.cs"],
["./assets/sc_examples/csharp/Storage-Core.cs"],
["./assets/sc_examples/csharp/Transfer-Core.cs"],
["./assets/sc_examples/csharp/ZKP-Core.cs"],
];

var cPythonFiles = [
Expand Down
33 changes: 33 additions & 0 deletions assets/sc_examples/csharp/ContractCall-Core.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Attributes;
using Neo.SmartContract.Framework.Native;

using System.ComponentModel;
using System.Numerics;
using Neo;
using Neo.SmartContract;
using Neo.SmartContract.Framework.Services;

namespace ContractCall;

[DisplayName("SampleContractCall")]
[ManifestExtra("Author", "core-dev")]
[ManifestExtra("Description", "A sample contract to demonstrate how to call a contract")]
[ManifestExtra("Email", "[email protected]")]
[ManifestExtra("Version", "0.0.1")]
[ContractSourceCode("https://github.com/neo-project/neo/examples/ContractCall")]
[ContractPermission("*", "*")]
public class SampleContractCall : SmartContract
{
[InitialValue("0x13a83e059c2eedd5157b766d3357bc826810905e", ContractParameterType.Hash160)]
private static readonly UInt160 DummyTarget;

public static void onNEP17Payment(UInt160 from, BigInteger amount, BigInteger data)
{
UInt160 tokenHash = Runtime.CallingScriptHash;
if (!data.Equals(123)) return;
UInt160 @this = Runtime.ExecutingScriptHash;
BigInteger balanceOf = (BigInteger)Contract.Call(tokenHash, "balanceOf", CallFlags.All, @this);
Contract.Call(DummyTarget, "dummyMethod", CallFlags.All, @this, tokenHash, balanceOf);
}
}
33 changes: 33 additions & 0 deletions assets/sc_examples/csharp/Event-Core.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Attributes;
using Neo.SmartContract.Framework.Native;
using System;
using System.ComponentModel;
using System.Numerics;

namespace Event;

[DisplayName("SampleEvent")]
[ManifestExtra("Author", "code-dev")]
[ManifestExtra("Description", "A sample contract that demonstrates how to use Events")]
[ManifestExtra("Email", "[email protected]")]
[ManifestExtra("Version", "0.0.1")]
[ContractSourceCode("https://github.com/neo-project/samples")]
[ContractPermission("*", "*")]
public class SampleEvent : SmartContract
{
[DisplayName("new_event_name")]
public static event Action<byte[], string, BigInteger> event_name;

public static event Action<byte[], BigInteger> 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;
}
}
Loading

0 comments on commit 25240b1

Please sign in to comment.