diff --git a/Lib9c b/Lib9c index 9fb67c2f0..75ef95354 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 9fb67c2f0f4c96f71068eae86e72972852eb8867 +Subproject commit 75ef95354a4a290687be22d1b463aa2752840c94 diff --git a/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs b/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs index b964d7416..8e720b2ce 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs @@ -1311,5 +1311,34 @@ private static IEnumerable GetMemberDataOfUnloadFromMyGarages() "memo", }; } + + [Fact] + public async Task AuraSummon() + { + var random = new Random(); + var avatarAddress = new PrivateKey().ToAddress(); + var groupId = random.Next(10001, 10002 + 1); + // FIXME: Change 10 to AuraSummon.SummonLimit + var summonCount = random.Next(1, 10 + 1); + + var query = $@"{{ + auraSummon( + avatarAddress: ""{avatarAddress}"", + groupId: {groupId}, + summonCount: {summonCount} + ) + }}"; + + var queryResult = await ExecuteQueryAsync(query, standaloneContext: _standaloneContext); + var data = (Dictionary)((ExecutionNode)queryResult.Data!).ToValue()!; + var plainValue = _codec.Decode(ByteUtil.ParseHex((string)data["auraSummon"])); + Assert.IsType(plainValue); + var actionBase = DeserializeNCAction(plainValue); + var action = Assert.IsType(actionBase); + + Assert.Equal(avatarAddress, action.AvatarAddress); + Assert.Equal(groupId, action.GroupId); + Assert.Equal(summonCount, action.SummonCount); + } } } diff --git a/NineChronicles.Headless/GraphTypes/ActionQuery.cs b/NineChronicles.Headless/GraphTypes/ActionQuery.cs index 207be91b5..a3e583954 100644 --- a/NineChronicles.Headless/GraphTypes/ActionQuery.cs +++ b/NineChronicles.Headless/GraphTypes/ActionQuery.cs @@ -542,6 +542,7 @@ public ActionQuery(StandaloneContext standaloneContext) RegisterCombinationConsumable(); RegisterMead(); RegisterGarages(); + RegisterSummon(); Field>( name: "craftQuery", diff --git a/NineChronicles.Headless/GraphTypes/ActionQueryFields/Summon.cs b/NineChronicles.Headless/GraphTypes/ActionQueryFields/Summon.cs new file mode 100644 index 000000000..6391f7eaf --- /dev/null +++ b/NineChronicles.Headless/GraphTypes/ActionQueryFields/Summon.cs @@ -0,0 +1,43 @@ +using GraphQL; +using GraphQL.Types; +using Libplanet.Crypto; +using Libplanet.Explorer.GraphTypes; +using Nekoyume.Action; + +namespace NineChronicles.Headless.GraphTypes; + +public partial class ActionQuery +{ + private void RegisterSummon() + { + Field>( + "auraSummon", + arguments: new QueryArguments( + new QueryArgument> + { + Name = "avatarAddress", + Description = "Avatar address to get summoned items" + }, + new QueryArgument> + { + Name = "groupId", + Description = "Summon group id" + }, + new QueryArgument> + { + Name = "summonCount", + Description = "Count to summon. Must between 1 and 10." + } + ), + resolve: context => + { + var avatarAddr = context.GetArgument
("avatarAddress"); + var groupId = context.GetArgument("groupId"); + var summonCount = context.GetArgument("summonCount"); + + ActionBase action = new AuraSummon(avatarAddr, groupId, summonCount); + return Encode(context, action); + } + ); + } +}