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

Add userState query #125

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading