Skip to content

Commit

Permalink
Merge pull request #2261 from moreal/improve-tx-features
Browse files Browse the repository at this point in the history
Provide some features related to transactions
  • Loading branch information
moreal authored Oct 5, 2023
2 parents 8f97dda + 1d7cc12 commit 8a2f685
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions NineChronicles.Headless/GraphTypes/StandaloneSubscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Reactive.Disposables;
using System.Text.RegularExpressions;
using Bencodex.Types;
using Libplanet.Crypto;
using Libplanet.Types.Assets;
Expand Down Expand Up @@ -145,7 +146,7 @@ public StandaloneSubscription(StandaloneContext standaloneContext)
Arguments = new QueryArguments(
new QueryArgument<NonNullGraphType<StringGraphType>>
{
Description = "A type of action in transaction.",
Description = "A regular expression to filter transactions based on action type.",
Name = "actionType",
}
),
Expand Down Expand Up @@ -304,7 +305,7 @@ private IObservable<Tx> SubscribeTx(IResolveFieldContext context)
return false;
}

return typeId == actionType;
return Regex.IsMatch(typeId, actionType);
}))
.Select(transaction => new Tx
{
Expand Down
10 changes: 10 additions & 0 deletions NineChronicles.Headless/GraphTypes/TransactionType.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using GraphQL.Types;
using Libplanet.Explorer.GraphTypes;
using Libplanet.Types.Tx;
Expand Down Expand Up @@ -48,6 +49,15 @@ public TransactionType()
description: "A list of actions in this transaction.",
resolve: context => context.Source.Actions
);

Field<NonNullGraphType<StringGraphType>>(
name: "SerializedPayload",
description: "A serialized tx payload in base64 string.",
resolve: x =>
{
byte[] bytes = x.Source.Serialize();
return Convert.ToBase64String(bytes);
});
}
}
}

0 comments on commit 8a2f685

Please sign in to comment.