Skip to content

Commit

Permalink
feat: Add action queries
Browse files Browse the repository at this point in the history
  • Loading branch information
s2quake committed Jan 13, 2025
1 parent 0917178 commit 2866fd3
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions NineChronicles.Headless/GraphTypes/ActionQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
using Nekoyume.Action.ValidatorDelegation;
using Nekoyume.Action.Guild.Migration;
using Lib9c;
using Nekoyume.Action.Guild;
using Nekoyume.TypedAddress;

namespace NineChronicles.Headless.GraphTypes
{
Expand Down Expand Up @@ -574,6 +576,96 @@ public ActionQuery(StandaloneContext standaloneContext)
context,
new MigrateDelegationHeight(context.GetArgument<long>("amount"))));

Field<ByteStringType>(
name: "makeGuild",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "validatorAddress",
Description = "The validator address to create a guild."
}),
resolve: context =>
{
var validatorAddress = context.GetArgument<Address>("validatorAddress");
return Encode(context, new MakeGuild(validatorAddress));
});

Field<ByteStringType>(
name: "removeGuild",
resolve: context => Encode(context, new RemoveGuild()));

Field<ByteStringType>(
name: "joinGuild",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "guildAddress",
Description = "The guild address to join."
}),
resolve: context =>
{
var address = context.GetArgument<Address>("guildAddress");
var guildAddress = new GuildAddress(address);
return Encode(context, new JoinGuild(guildAddress));
});

Field<ByteStringType>(
name: "quitGuild",
resolve: context => Encode(context, new QuitGuild()));

Field<ByteStringType>(
name: "moveGuild",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "guildAddress",
Description = "The guild address to move."
}),
resolve: context =>
{
var address = context.GetArgument<Address>("guildAddress");
var guildAddress = new GuildAddress(address);
return Encode(context, new MoveGuild(guildAddress));
});

Field<ByteStringType>(
name: "banGuildMember",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "agentAddress",
Description = "The agent address to ban."
}),
resolve: context =>
{
var address = context.GetArgument<Address>("agentAddress");
var agentAddress = new AgentAddress(address);
return Encode(context, new BanGuildMember(agentAddress));
});

Field<ByteStringType>(
name: "unbanGuildMember",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<AddressType>>
{
Name = "agentAddress",
Description = "The agent address to unban."
}),
resolve: context =>
{
var address = context.GetArgument<Address>("agentAddress");
var agentAddress = new AgentAddress(address);
return Encode(context, new UnbanGuildMember(agentAddress));
});

Field<ByteStringType>(
name: "claimReward",
resolve: context => Encode(context, new ClaimReward()));

Field<ByteStringType>(
name: "claimGuildReward",
resolve: context => Encode(context, new ClaimGuildReward()));

RegisterHackAndSlash();
RegisterHackAndSlashSweep();
RegisterDailyReward();
Expand Down

0 comments on commit 2866fd3

Please sign in to comment.