Skip to content

Commit

Permalink
feat: Add delegateValidator action mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
s2quake committed Nov 26, 2024
1 parent 23cb1ac commit 1789953
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions NineChronicles.Headless/GraphTypes/ActionMutation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,43 @@ public ActionMutation(NineChroniclesNodeService service)
}
}
);
Field<NonNullGraphType<TxIdType>>("delegateValidator",
description: "Unjail validator",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<BigIntGraphType>>
{
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<BigInteger>("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;
}
}
);
}
}
}

0 comments on commit 1789953

Please sign in to comment.