Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
Add userState query
Browse files Browse the repository at this point in the history
  • Loading branch information
Atralupus committed Feb 12, 2024
1 parent ac2f0ba commit dc7c264
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions backend/app/Savor22b/GraphTypes/Query/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@ public Query(BlockChain blockChain, Swarm? swarm = null)
_blockChain = blockChain;
_swarm = swarm;

Field<UserStateType>(
"userState",
description: "The specified address's user state",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<StringGraphType>>
{
Name = "address",
Description = "The account holder's 40-hex address",
}
),
resolve: context =>
{
var accountAddress = new Address(context.GetArgument<string>("address"));
var rootStateEncoded = blockChain.GetState(accountAddress);
RootState rootState = rootStateEncoded is Bencodex.Types.Dictionary bdict
? new RootState(bdict)
: new RootState();
return rootState;
}
);

Field<StringGraphType>(
"asset",
description: "The specified address's balance in MNT.",
Expand Down

0 comments on commit dc7c264

Please sign in to comment.