Skip to content

Commit

Permalink
Merge pull request #2689 from planetarium/revert-2680-update-max-gas-…
Browse files Browse the repository at this point in the history
…price

Revert "Update default max gas price"
  • Loading branch information
ipdae authored Jan 22, 2025
2 parents 8573385 + e389c53 commit 63d26b4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 86 deletions.
6 changes: 3 additions & 3 deletions NineChronicles.Headless.Tests/GraphTypes/SignScenarioTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public async Task SignTransaction_CreatePledge()
Assert.Equal(sender, action.AgentAddresses.Single().Item1);
Assert.Equal(MeadConfig.PatronAddress, action.PatronAddress);
Assert.Equal(1, signedTx.GasLimit);
Assert.Equal(FungibleAssetValue.FromRawValue(Currencies.Mead, 10000000000000), signedTx.MaxGasPrice);
Assert.Equal(1 * Currencies.Mead, signedTx.MaxGasPrice);
await StageTransaction(signedTx, hex);
}

Expand Down Expand Up @@ -206,7 +206,7 @@ private async Task<object> GetAction(string actionName, string queryArgs)

// Create unsigned Transaction.
var unsignedQuery = gas ? $@"query {{
unsignedTransaction(publicKey: ""{hexedPublicKey}"", plainValue: ""{plainValue}"", nonce: {nonce}, maxGasPrice: {{ quantity: ""0.00001"", decimalPlaces: 18, ticker: ""Mead"" }})
unsignedTransaction(publicKey: ""{hexedPublicKey}"", plainValue: ""{plainValue}"", nonce: {nonce}, maxGasPrice: {{ quantity: 1, decimalPlaces: 18, ticker: ""Mead"" }})
}}" : $@"query {{
unsignedTransaction(publicKey: ""{hexedPublicKey}"", plainValue: ""{plainValue}"", nonce: {nonce})
}}";
Expand Down Expand Up @@ -249,7 +249,7 @@ private async Task<object> GetAction(string actionName, string queryArgs)
Assert.Single(unsignedTx.Actions);
Assert.Single(signedTx.Actions!);
Assert.Equal(expectedGasLimit, signedTx.GasLimit);
Assert.Equal(FungibleAssetValue.FromRawValue(Currencies.Mead, 10000000000000), signedTx.MaxGasPrice);
Assert.Equal(1 * Currencies.Mead, signedTx.MaxGasPrice);
return (signedTx, hex);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
using Lib9c;
using Libplanet.Common;
using Libplanet.Crypto;
using Libplanet.Types.Assets;
using Libplanet.Types.Tx;
using Nekoyume.Action;
using Nekoyume.Action.Loader;
using Xunit;
using BigInteger = System.Numerics.BigInteger;

namespace NineChronicles.Headless.Tests.GraphTypes
{
Expand Down Expand Up @@ -38,7 +36,7 @@ public async Task ActionTxQuery_CreateTransaction()
Assert.Equal(publicKey.Address, tx.Signer);
Assert.Equal(0, tx.Nonce);
Assert.Equal(1, tx.GasLimit);
Assert.Equal(FungibleAssetValue.FromRawValue(Currencies.Mead, 10000000000000), tx.MaxGasPrice);
Assert.Equal(1 * Currencies.Mead, tx.MaxGasPrice);
var rawAction = Assert.Single(tx.Actions);
var action = new NCActionLoader().LoadAction(0, rawAction);
Assert.IsType<Stake>(action);
Expand Down Expand Up @@ -67,17 +65,15 @@ public async Task ActionTxQuery_CreateTransaction_With_Timestamp(string timestam
Assert.Equal(DateTimeOffset.Parse(timestamp), tx.Timestamp);
}

[Theory]
[InlineData("1")]
[InlineData("0.00001")]
public async Task ActionTxQuery_With_Gas(string quantity)
[Fact]
public async Task ActionTxQuery_With_Gas()
{
var publicKey = new PrivateKey().PublicKey;
var address = new PrivateKey().Address;
long nonce = 0;
var result = await ExecuteQueryAsync($@"
query {{
actionTxQuery(publicKey: ""{publicKey.ToString()}"", nonce: {nonce}, maxGasPrice: {{ quantity: ""{quantity}"", decimalPlaces: 18, ticker: ""Mead"" }}) {{
actionTxQuery(publicKey: ""{publicKey.ToString()}"", nonce: {nonce}, maxGasPrice: {{ quantity: 1, decimalPlaces: 18, ticker: ""Mead"" }}) {{
requestPledge(agentAddress: ""{address}"")
}}
}}");
Expand All @@ -91,7 +87,7 @@ public async Task ActionTxQuery_With_Gas(string quantity)
Assert.Equal(0, tx.Nonce);
Assert.IsType<DateTimeOffset>(tx.Timestamp);
Assert.Equal(1, tx.GasLimit);
Assert.Equal(FungibleAssetValue.Parse(Currencies.Mead, quantity), tx.MaxGasPrice);
Assert.Equal(1 * Currencies.Mead, tx.MaxGasPrice);
var rawAction = Assert.Single(tx.Actions);
var action = Assert.IsType<RequestPledge>(new NCActionLoader().LoadAction(0, rawAction));
Assert.Equal(address, action.AgentAddress);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class FungibleAssetValueInputType : InputObjectGraphType<FungibleAssetVal
{
public FungibleAssetValueInputType()
{
DeprecationReason = "incorrect handling of decimal points or improper conversion logic. please use A";
Field<NonNullGraphType<BigIntGraphType>>("quantity");
Field<NonNullGraphType<StringGraphType>>("ticker");
Field<NonNullGraphType<ByteGraphType>>("decimalPlaces");
Expand Down
4 changes: 2 additions & 2 deletions NineChronicles.Headless/GraphTypes/StandaloneQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,10 @@ public StandaloneQuery(StandaloneContext standaloneContext, IKeyStore keyStore,
Name = "timestamp",
Description = "The time this transaction is created.",
},
new QueryArgument<FixedFungibleAssetValueInputType>
new QueryArgument<FungibleAssetValueInputType>
{
Name = "maxGasPrice",
DefaultValue = FungibleAssetValue.Parse(Currencies.Mead, "0.00001"),
DefaultValue = 1 * Currencies.Mead
}
),
resolve: context =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public TransactionHeadlessQuery(StandaloneContext standaloneContext)
genesisHash: blockChain.Genesis.Hash,
actions: new TxActionList(new[] { action.PlainValue }),
gasLimit: action is ITransferAsset or ITransferAssets ? RequestPledge.DefaultRefillMead : 1L,
maxGasPrice: FungibleAssetValue.Parse(Currencies.Mead, "0.00001")
maxGasPrice: 1 * Currencies.Mead
),
new TxSigningMetadata(publicKey: publicKey, nonce: nonce)
);
Expand Down Expand Up @@ -253,10 +253,10 @@ public TransactionHeadlessQuery(StandaloneContext standaloneContext)
Name = "nonce",
Description = "The nonce for Transaction.",
},
new QueryArgument<FixedFungibleAssetValueInputType>
new QueryArgument<FungibleAssetValueInputType>
{
Name = "maxGasPrice",
DefaultValue = FungibleAssetValue.Parse(Currencies.Mead, "0.00001"),
DefaultValue = 1 * Currencies.Mead
}
),
resolve: context =>
Expand Down

0 comments on commit 63d26b4

Please sign in to comment.