diff --git a/NineChronicles.Headless/GraphTypes/ActionMutation.cs b/NineChronicles.Headless/GraphTypes/ActionMutation.cs index 9fecf836f..6fb5820f6 100644 --- a/NineChronicles.Headless/GraphTypes/ActionMutation.cs +++ b/NineChronicles.Headless/GraphTypes/ActionMutation.cs @@ -702,6 +702,43 @@ public ActionMutation(NineChroniclesNodeService service) } } ); + Field>("delegateValidator", + description: "Unjail validator", + arguments: new QueryArguments( + new QueryArgument> + { + Name = "amount", + Description = "Amount of guild gold to stake." + } + ), + resolve: context => + { + try + { + BlockChain? blockChain = service.BlockChain; + if (blockChain is null) + { + throw new InvalidOperationException($"{nameof(blockChain)} is null."); + } + + BigInteger amount = context.GetArgument("amount"); + var fav = new FungibleAssetValue(ValidatorDelegatee.ValidatorDelegationCurrency, amount, 0); + var actions = new[] { new DelegateValidator(fav) }; + Transaction tx = blockChain.MakeTransaction( + service.MinerPrivateKey, + actions, + Currencies.Mead * 1, + 1L); + return tx.Id; + } + catch (Exception e) + { + var msg = $"Unexpected exception occurred during {typeof(ActionMutation)}: {e}"; + context.Errors.Add(new ExecutionError(msg, e)); + throw; + } + } + ); } } }