-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
AElf.Runtime.CSharp.ExecutiveTokenPlugin/AElf.Runtime.CSharp.ExecutiveTokenPlugin.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
12 changes: 12 additions & 0 deletions
12
AElf.Runtime.CSharp.ExecutiveTokenPlugin/ExecutiveTokenPluginCSharpRuntimeAElfModule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
{ | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
AElf.Runtime.CSharp.ExecutiveTokenPlugin/FeeChargeExecutivePlugin.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters