Skip to content

Commit

Permalink
Add query
Browse files Browse the repository at this point in the history
  • Loading branch information
Atralupus committed Apr 14, 2024
1 parent b721854 commit 3614142
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
4 changes: 2 additions & 2 deletions backend/app/Savor22b.Tests/Action/BuyTradeGoodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void Execute_Success()
FungibleAssetValue.Parse(Currencies.KeyCurrency, "10")
);

var action = new BuyTradeGood(
var action = new BuyTradeGoodAction(
productId
);

Expand All @@ -50,7 +50,7 @@ public void Execute_Fail_InsufficientBalance()
{
var (stateDelta, productId) = CreatePresetStateDelta();

var action = new BuyTradeGood(
var action = new BuyTradeGoodAction(
productId
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ namespace Savor22b.Action;
using Savor22b.States.Trade;
using Savor22b.Action.Exceptions;

[ActionType(nameof(BuyTradeGood))]
public class BuyTradeGood : SVRAction
[ActionType(nameof(BuyTradeGoodAction))]
public class BuyTradeGoodAction : SVRAction
{
public BuyTradeGood() { }
public BuyTradeGoodAction() { }

public BuyTradeGood(Guid productId)
public BuyTradeGoodAction(Guid productId)
{
ProductId = productId;
}
Expand Down
32 changes: 32 additions & 0 deletions backend/app/Savor22b/GraphTypes/Query/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,38 @@ swarm is null
}
);

Field<NonNullGraphType<StringGraphType>>(
"createAction_BuyTradeGoodAction",
description: "무역상점 구매",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<StringGraphType>>
{
Name = "publicKey",
Description = "The base64-encoded public key for Transaction.",
},
new QueryArgument<NonNullGraphType<GuidGraphType>>
{
Name = "productId",
Description = "상품 고유 Id",
}
),
resolve: context =>
{
var publicKey = new PublicKey(
ByteUtil.ParseHex(context.GetArgument<string>("publicKey"))
);
var action = new BuyTradeGoodAction(context.GetArgument<Guid>("productId"));
return new GetUnsignedTransactionHex(
action,
publicKey,
_blockChain,
_swarm
).UnsignedTransactionHex;
}
);

Field<NonNullGraphType<StringGraphType>>(
"createAction_RegisterTradeGoodAction",
description: "Register Trade Good to Trade Store",
Expand Down

0 comments on commit 3614142

Please sign in to comment.