Skip to content

Commit

Permalink
fix git ignore files
Browse files Browse the repository at this point in the history
  • Loading branch information
loning committed Mar 12, 2019
1 parent 490629f commit 35bd4de
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 5 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,10 @@ __pycache__/

.vs/
slnx.sqlite
/AElf.Kernel/MerkleTree.cs
/AElf.Kernel/MerkleNode.cs

# Generated Protobuf classes
*.g.cs
*plugin
grpc_csharp_plugin
*Grpc.cs

launchSettings.json
Expand Down
2 changes: 1 addition & 1 deletion AElf.Kernel.SmartContract/Infrastructure/IExecutive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface IExecutive
IExecutive SetStateProviderFactory(IStateProviderFactory stateProviderFactory);
void SetDataCache(IStateCache cache); //temporary solution to let data provider access actor's state cache
Task Apply();
ulong GetFee(string methodName);
//ulong GetFee(string methodName);
string GetJsonStringOfParameters(string methodName, byte[] paramsBytes);
object GetReturnValue(string methodName, byte[] bytes);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\AElf.Kernel.SmartContract\AElf.Kernel.SmartContract.csproj" />
<ProjectReference Include="..\AElf.Kernel.Token\AElf.Kernel.Token.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using AElf.Common;
using AElf.Kernel.SmartContract;
using AElf.Modularity;
using Volo.Abp.Modularity;

namespace AElf.Runtime.CSharp.ExecutiveTokenPlugin
{
[DependsOn(typeof(SmartContractAElfModule))]
public class ExecutiveTokenPluginCSharpRuntimeAElfModule : AElfModule<ExecutiveTokenPluginCSharpRuntimeAElfModule>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using AElf.Kernel;
using AElf.Kernel.SmartContract;
using AElf.Kernel.SmartContract.Infrastructure;
using AElf.Kernel.Token;
using AElf.Kernel.Types.SmartContract;
using AElf.Types.CSharp;
using Google.Protobuf;
using Volo.Abp.DependencyInjection;

namespace AElf.Runtime.CSharp.ExecutiveTokenPlugin
{
public class FeeChargeExecutivePlugin : IExecutivePlugin, ITransientDependency
{
public void AfterApply(ISmartContract smartContract, IHostSmartContractBridgeContext context,
Func<string, object[], object> executeReadOnlyHandler)
{
if (!(smartContract is IFeeChargedContract) || context.TransactionContext.CallDepth > 0)
{
return;
}

var fee = (ulong) executeReadOnlyHandler(nameof(IFeeChargedContract.GetMethodFee),

new object[] {context.TransactionContext.Transaction.MethodName});

context.TransactionContext.Trace.InlineTransactions.Add(new Transaction()
{
From = context.TransactionContext.Transaction.From,
To = context.GetContractAddressByName(
TokenSmartContractAddressNameProvider.Name),
MethodName = nameof(ITokenContract.ChargeTransactionFees),
Params = ByteString.CopyFrom(
ParamsPacker.Pack(fee))
});
}
}
}
3 changes: 2 additions & 1 deletion AElf.Runtime.CSharp/Executive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,14 @@ public async Task ExecuteMainTransaction()
CurrentTransactionContext.Trace.Elapsed = (e - s).Ticks;
}

/*
public ulong GetFee(string methodName)
{
var handler = _cache.GetHandler(nameof(IFeeChargedContract.GetMethodFee));
var retVal = handler.Execute(ParamsPacker.Pack(methodName));
handler.BytesToReturnType(retVal);
return (ulong) handler.BytesToReturnType(retVal);
}
}*/

private object ExecuteReadOnlyHandler(string methodName, params object[] objects)
{
Expand Down

0 comments on commit 35bd4de

Please sign in to comment.