diff --git a/AElf.All.sln b/AElf.All.sln
index 34ad27a9ac..4a896ad02b 100644
--- a/AElf.All.sln
+++ b/AElf.All.sln
@@ -385,6 +385,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.FeatureDisable.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Kernel.FeatureDisable.Core", "src\AElf.Kernel.FeatureDisable.Core\AElf.Kernel.FeatureDisable.Core.csproj", "{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Sdk.CSharp.Internal", "src\AElf.Sdk.CSharp.Internal\AElf.Sdk.CSharp.Internal.csproj", "{21BC1437-BD34-4EBA-8F91-6A606782D06A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AElf.Sdk.CSharp.Spec", "src\AElf.Sdk.CSharp.Spec\AElf.Sdk.CSharp.Spec.csproj", "{D749B50E-34BF-43F1-AAAE-1306C490B7FE}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -1107,6 +1111,14 @@ Global
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {21BC1437-BD34-4EBA-8F91-6A606782D06A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {21BC1437-BD34-4EBA-8F91-6A606782D06A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {21BC1437-BD34-4EBA-8F91-6A606782D06A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {21BC1437-BD34-4EBA-8F91-6A606782D06A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D749B50E-34BF-43F1-AAAE-1306C490B7FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D749B50E-34BF-43F1-AAAE-1306C490B7FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D749B50E-34BF-43F1-AAAE-1306C490B7FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D749B50E-34BF-43F1-AAAE-1306C490B7FE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1301,5 +1313,7 @@ Global
{A4ACE6D2-4CF8-4B52-93C9-BB8BEC0C098E} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC}
{8C0D86A4-D1A7-4B61-AC44-755F5AC75D67} = {4E54480A-D155-43ED-9736-1A5BE7957211}
{659A7C7A-44C9-424E-B4F6-D1D3656F7AD4} = {90B310B4-C2DB-419E-B5EE-97FA096B62CC}
+ {21BC1437-BD34-4EBA-8F91-6A606782D06A} = {798BAA50-825B-4DD9-83E2-77A9EE6EBE09}
+ {D749B50E-34BF-43F1-AAAE-1306C490B7FE} = {798BAA50-825B-4DD9-83E2-77A9EE6EBE09}
EndGlobalSection
EndGlobal
diff --git a/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj b/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj
new file mode 100644
index 0000000000..73e020c00f
--- /dev/null
+++ b/src/AElf.Sdk.CSharp.Internal/AElf.Sdk.CSharp.Internal.csproj
@@ -0,0 +1,22 @@
+
+
+
+
+ net8.0
+ AElf.Sdk.CSharp.Internal
+ true
+ latest
+ Types for the C# smart contract SDK.
+
+
+
+
+ all
+
+
+
+
+
+
+
+
diff --git a/src/AElf.Sdk.CSharp.Internal/AssemblyInfo.cs b/src/AElf.Sdk.CSharp.Internal/AssemblyInfo.cs
new file mode 100644
index 0000000000..660010686b
--- /dev/null
+++ b/src/AElf.Sdk.CSharp.Internal/AssemblyInfo.cs
@@ -0,0 +1,3 @@
+using System.Runtime.CompilerServices;
+
+[assembly: InternalsVisibleTo("AElf.Sdk.CSharp")]
\ No newline at end of file
diff --git a/src/AElf.Sdk.CSharp/BuiltIns.cs b/src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs
similarity index 62%
rename from src/AElf.Sdk.CSharp/BuiltIns.cs
rename to src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs
index 944e86dd92..e9a419f455 100644
--- a/src/AElf.Sdk.CSharp/BuiltIns.cs
+++ b/src/AElf.Sdk.CSharp.Internal/InternalBuiltIns.cs
@@ -1,10 +1,11 @@
using System;
+using AElf.Sdk.CSharp.Spec;
-namespace AElf.Sdk.CSharp;
+namespace AElf.Sdk.CSharp.Internal;
-public static class BuiltIns
+internal class InternalBuiltIns : IBuiltIns
{
- public static bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey)
+ public bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey)
{
try
{
diff --git a/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj b/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj
new file mode 100644
index 0000000000..eb2460e910
--- /dev/null
+++ b/src/AElf.Sdk.CSharp.Spec/AElf.Sdk.CSharp.Spec.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
diff --git a/src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs b/src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs
new file mode 100644
index 0000000000..13a4dce49e
--- /dev/null
+++ b/src/AElf.Sdk.CSharp.Spec/IBuiltIns.cs
@@ -0,0 +1,6 @@
+namespace AElf.Sdk.CSharp.Spec;
+
+public interface IBuiltIns
+{
+ bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey);
+}
\ No newline at end of file
diff --git a/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj b/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj
index b38a4ba3e2..c629c1e057 100644
--- a/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj
+++ b/src/AElf.Sdk.CSharp/AElf.Sdk.CSharp.csproj
@@ -1,5 +1,5 @@
-
+
net8.0
@@ -10,15 +10,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
all
-
+
diff --git a/src/AElf.Sdk.CSharp/CSharpSmartContractAbstract.cs b/src/AElf.Sdk.CSharp/CSharpSmartContractAbstract.cs
index 31d642fdf0..d7d05bac0f 100644
--- a/src/AElf.Sdk.CSharp/CSharpSmartContractAbstract.cs
+++ b/src/AElf.Sdk.CSharp/CSharpSmartContractAbstract.cs
@@ -1,4 +1,5 @@
using AElf.Kernel.SmartContract;
+using AElf.Sdk.CSharp.Spec;
using AElf.Types;
namespace AElf.Sdk.CSharp;
@@ -11,6 +12,8 @@ public abstract class CSharpSmartContractAbstract : CSharpSmartContract
///
public CSharpSmartContractContext Context { get; set; }
+ public IBuiltIns BuiltIns { get; internal set; }
+
internal abstract TransactionExecutingStateSet GetChanges();
internal abstract void Cleanup();
diff --git a/src/AElf.Sdk.CSharp/CSharpSmartContractContext.cs b/src/AElf.Sdk.CSharp/CSharpSmartContractContext.cs
index 5e3ed6c94a..d78b9d6f4e 100644
--- a/src/AElf.Sdk.CSharp/CSharpSmartContractContext.cs
+++ b/src/AElf.Sdk.CSharp/CSharpSmartContractContext.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using AElf.Kernel.SmartContract;
+using AElf.Sdk.CSharp.Internal;
+using AElf.Sdk.CSharp.Spec;
using AElf.Types;
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
@@ -12,11 +14,14 @@ namespace AElf.Sdk.CSharp;
/// base class for smart contracts (Context property). It provides access to properties and methods useful for
/// implementing the logic in smart contracts.
///
-public class CSharpSmartContractContext : ISmartContractBridgeContext
+public class CSharpSmartContractContext : ISmartContractBridgeContext, IBuiltIns
{
+ private IBuiltIns BuiltInsImplementation { get; }
+
public CSharpSmartContractContext(ISmartContractBridgeContext smartContractBridgeContextImplementation)
{
SmartContractBridgeContextImplementation = smartContractBridgeContextImplementation;
+ BuiltInsImplementation = new InternalBuiltIns();
}
public ISmartContractBridgeContext SmartContractBridgeContextImplementation { get; }
@@ -85,7 +90,7 @@ public void FireLogEvent(LogEvent logEvent)
/// The height of the block that contains the transaction before charging.
///
public Transaction Transaction => SmartContractBridgeContextImplementation.Transaction;
-
+
///
/// The time included in the current blocks header.
///
@@ -148,7 +153,7 @@ public void DeployContract(Address address, SmartContractRegistration registrati
{
SmartContractBridgeContextImplementation.DeployContract(address, registration, name);
}
-
+
///
/// Update a smart contract (only the genesis contract can call it).
///
@@ -159,17 +164,21 @@ public void UpdateContract(Address address, SmartContractRegistration registrati
{
SmartContractBridgeContextImplementation.UpdateContract(address, registration, name);
}
-
+
public ContractInfoDto DeploySmartContract(Address address, SmartContractRegistration registration, Hash name)
{
- return SmartContractBridgeContextImplementation.DeploySmartContract(address,registration,name);
+ return SmartContractBridgeContextImplementation.DeploySmartContract(address, registration, name);
}
- public ContractInfoDto UpdateSmartContract(Address address, SmartContractRegistration registration, Hash name,string previousContractVersion)
+
+ public ContractInfoDto UpdateSmartContract(Address address, SmartContractRegistration registration, Hash name,
+ string previousContractVersion)
{
- return SmartContractBridgeContextImplementation.UpdateSmartContract(address,registration,name,previousContractVersion);
+ return SmartContractBridgeContextImplementation.UpdateSmartContract(address, registration, name,
+ previousContractVersion);
}
- public ContractVersionCheckDto CheckContractVersion(string previousContractVersion, SmartContractRegistration registration)
+ public ContractVersionCheckDto CheckContractVersion(string previousContractVersion,
+ SmartContractRegistration registration)
{
return SmartContractBridgeContextImplementation.CheckContractVersion(previousContractVersion, registration);
}
@@ -221,13 +230,14 @@ public void SendVirtualInline(Hash fromVirtualAddress, Address toAddress, string
SmartContractBridgeContextImplementation.SendVirtualInline(fromVirtualAddress, toAddress, methodName,
args);
}
-
- public void SendVirtualInline(Hash fromVirtualAddress, Address toAddress, string methodName, ByteString args,bool logTransaction)
+
+ public void SendVirtualInline(Hash fromVirtualAddress, Address toAddress, string methodName, ByteString args,
+ bool logTransaction)
{
SmartContractBridgeContextImplementation.SendVirtualInline(fromVirtualAddress, toAddress, methodName,
- args,logTransaction);
+ args, logTransaction);
}
-
+
///
/// Sends a virtual inline transaction to another contract. This method is only available to system smart contract.
@@ -245,7 +255,7 @@ public void SendVirtualInlineBySystemContract(Hash fromVirtualAddress, Address t
SmartContractBridgeContextImplementation.SendVirtualInlineBySystemContract(fromVirtualAddress, toAddress,
methodName, args);
}
-
+
public void SendVirtualInlineBySystemContract(Hash fromVirtualAddress, Address toAddress, string methodName,
ByteString args, bool logTransaction)
{
@@ -386,9 +396,14 @@ public Address ConvertVirtualAddressToContractAddressWithContractHashName(Hash v
return SmartContractBridgeContextImplementation.ConvertVirtualAddressToContractAddressWithContractHashName(
virtualAddress);
}
-
+
public bool ECVrfVerify(byte[] pubKey, byte[] alpha, byte[] pi, out byte[] beta)
{
return SmartContractBridgeContextImplementation.ECVrfVerify(pubKey, alpha, pi, out beta);
}
+
+ public bool Ed25519Verify(byte[] signature, byte[] message, byte[] publicKey)
+ {
+ return BuiltInsImplementation.Ed25519Verify(signature, message, publicKey);
+ }
}
\ No newline at end of file