Skip to content

Commit

Permalink
Merge branch 'feature/inline-cross-chain-transfer' into feature/2.7.0…
Browse files Browse the repository at this point in the history
…-union

# Conflicts:
#	src/CAServer.ContractEventHandler.Core/Worker/TransferAutoReceiveWorker.cs
  • Loading branch information
felix-zhaolei committed Dec 17, 2024
2 parents 9317771 + e89c519 commit 3aa359a
Show file tree
Hide file tree
Showing 5 changed files with 386 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public static class CommonConstant
public const string GetUserExtraInfoUri = "api/app/userExtraInfo";

public const string CrossChainTransferMethodName = "CrossChainTransfer";
public const string InlineCrossChainTransferMethodName = ".CrossChainTransfer";

public const string TwitterTokenUrl = "https://api.twitter.com/2/oauth2/token";
public const string TwitterUserInfoUrl = "https://api.twitter.com/2/users/me";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: inline_transaction.proto
// </auto-generated>
#pragma warning disable 0414, 1591
#region Designer generated code

using System.Collections.Generic;
using aelf = global::AElf.CSharp.Core;

namespace AElf.Types {

#region Events
public partial class InlineTransactionCreated : aelf::IEvent<InlineTransactionCreated>
{
public global::System.Collections.Generic.IEnumerable<InlineTransactionCreated> GetIndexed()
{
return new List<InlineTransactionCreated>
{
new InlineTransactionCreated
{
Transaction = Transaction
},
};
}

public InlineTransactionCreated GetNonIndexed()
{
return new InlineTransactionCreated
{
};
}
}

#endregion
}
#endregion

244 changes: 244 additions & 0 deletions src/CAServer.Application.Contracts/Contracts/InlineTransaction.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: inline_transaction.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code

using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace AElf.Types {

/// <summary>Holder for reflection information generated from inline_transaction.proto</summary>
public static partial class InlineTransactionReflection {

#region Descriptor
/// <summary>File descriptor for inline_transaction.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;

static InlineTransactionReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"ChhpbmxpbmVfdHJhbnNhY3Rpb24ucHJvdG8aD2FlbGYvY29yZS5wcm90bxoS",
"YWVsZi9vcHRpb25zLnByb3RvIk8KGElubGluZVRyYW5zYWN0aW9uQ3JlYXRl",
"ZBItCgt0cmFuc2FjdGlvbhgBIAEoCzIRLmFlbGYuVHJhbnNhY3Rpb25CBYiP",
"9QEBOgSguxgBMhMKEUlubGluZVRyYW5zYWN0aW9uQg2qAgpBRWxmLlR5cGVz",
"YgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::AElf.Types.CoreReflection.Descriptor, global::AElf.OptionsReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::AElf.Types.InlineTransactionCreated), global::AElf.Types.InlineTransactionCreated.Parser, new[]{ "Transaction" }, null, null, null, null)
}));
}
#endregion

}
#region Messages
public sealed partial class InlineTransactionCreated : pb::IMessage<InlineTransactionCreated>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage
#endif
{
private static readonly pb::MessageParser<InlineTransactionCreated> _parser = new pb::MessageParser<InlineTransactionCreated>(() => new InlineTransactionCreated());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pb::MessageParser<InlineTransactionCreated> Parser { get { return _parser; } }

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::AElf.Types.InlineTransactionReflection.Descriptor.MessageTypes[0]; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public InlineTransactionCreated() {
OnConstruction();
}

partial void OnConstruction();

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public InlineTransactionCreated(InlineTransactionCreated other) : this() {
transaction_ = other.transaction_ != null ? other.transaction_.Clone() : null;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public InlineTransactionCreated Clone() {
return new InlineTransactionCreated(this);
}

/// <summary>Field number for the "transaction" field.</summary>
public const int TransactionFieldNumber = 1;
private global::AElf.Types.Transaction transaction_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public global::AElf.Types.Transaction Transaction {
get { return transaction_; }
set {
transaction_ = value;
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override bool Equals(object other) {
return Equals(other as InlineTransactionCreated);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool Equals(InlineTransactionCreated other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (!object.Equals(Transaction, other.Transaction)) return false;
return Equals(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override int GetHashCode() {
int hash = 1;
if (transaction_ != null) hash ^= Transaction.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void WriteTo(pb::CodedOutputStream output) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (transaction_ != null) {
output.WriteRawTag(10);
output.WriteMessage(Transaction);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
#endif
}

#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (transaction_ != null) {
output.WriteRawTag(10);
output.WriteMessage(Transaction);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
}
}
#endif

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public int CalculateSize() {
int size = 0;
if (transaction_ != null) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(Transaction);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void MergeFrom(InlineTransactionCreated other) {
if (other == null) {
return;
}
if (other.transaction_ != null) {
if (transaction_ == null) {
Transaction = new global::AElf.Types.Transaction();
}
Transaction.MergeFrom(other.Transaction);
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void MergeFrom(pb::CodedInputStream input) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
input.ReadRawMessage(this);
#else
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
if (transaction_ == null) {
Transaction = new global::AElf.Types.Transaction();
}
input.ReadMessage(Transaction);
break;
}
}
}
#endif
}

#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 10: {
if (transaction_ == null) {
Transaction = new global::AElf.Types.Transaction();
}
input.ReadMessage(Transaction);
break;
}
}
}
}
#endif

}

#endregion

}

#endregion Designer generated code
12 changes: 7 additions & 5 deletions src/CAServer.Application/IGraphQLProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Task<CaHolderTransactionInfos> GetToReceiveTransactionsAsync(string chainId, lon
long endHeight);

Task<IndexerTransaction> GetReceiveTransactionAsync(string chainId, string transferTxId, long endHeight);

Task<List<QueryEventDto>> GetGuardianTransactionInfosAsync(string chainId,
long startBlockHeight, long endBlockHeight);

Expand All @@ -60,7 +60,7 @@ public GraphQLProvider(ILogger<GraphQLProvider> logger, IClusterClient clusterCl
_graphQLOptions = graphQLOptions.Value;
_graphQLClient = new GraphQLHttpClient(_graphQLOptions.Configuration, new NewtonsoftJsonSerializer());
}

public async Task<long> GetIndexBlockHeightAsync(string chainId)
{
try
Expand Down Expand Up @@ -229,7 +229,8 @@ public async Task<CaHolderTransactionInfos> GetToReceiveTransactionsAsync(string
chainId = chainId,
startBlockHeight = startHeight,
endBlockHeight = endHeight,
methodNames = new List<string> { "CrossChainTransfer" },
methodNames = new List<string>
{ CommonConstant.CrossChainTransferMethodName, CommonConstant.InlineCrossChainTransferMethodName },
skipCount = 0,
maxResultCount = 10000
}
Expand Down Expand Up @@ -270,7 +271,8 @@ public async Task<IndexerTransaction> GetReceiveTransactionAsync(string chainId,
return txs.Data.CaHolderTransactionInfo.Data.FirstOrDefault();
}

public async Task<List<QueryEventDto>> GetGuardianTransactionInfosAsync(string chainId, long startBlockHeight, long endBlockHeight)
public async Task<List<QueryEventDto>> GetGuardianTransactionInfosAsync(string chainId, long startBlockHeight,
long endBlockHeight)
{
try
{
Expand Down Expand Up @@ -319,7 +321,7 @@ public async Task<List<QueryEventDto>> GetGuardianTransactionInfosAsync(string c
return new List<QueryEventDto>();
}
}

public async Task<CaHolderQueryDto> GetCaHolderInfoAsync(string caHash, int skipCount = 0, int maxResultCount = 1)
{
var response = await _graphQLClient.SendQueryAsync<CaHolderQueryDto>(new GraphQLRequest
Expand Down
Loading

0 comments on commit 3aa359a

Please sign in to comment.