From 3adedad841edfc51d1f0542dbc446c8b410fc0cb Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Fri, 24 Nov 2023 17:54:11 +0900 Subject: [PATCH 1/2] Bump lib9c to d6d629e8 --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index d7c3bfdc9..d6d629e80 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit d7c3bfdc93a240ec31da8c70f46716e9e8504470 +Subproject commit d6d629e8089d41432d525c5a58a12e5cf832ba17 From 7c86dc0355357ccad3a3523e70f9479ce16d81f9 Mon Sep 17 00:00:00 2001 From: Say Cheong Date: Fri, 24 Nov 2023 19:05:52 +0900 Subject: [PATCH 2/2] Replace ToAddress() with Address --- .../ForkableActionEvaluatorTest.cs | 2 - .../Commands/AccountCommandTest.cs | 2 +- .../Commands/ActionCommandTest.cs | 12 +-- .../Commands/TxCommandTest.cs | 6 +- .../Commands/GenesisCommand.cs | 10 +-- .../Commands/Key/ConversionCommand.cs | 2 +- .../Commands/KeyCommand.cs | 2 +- .../Common/Fixtures.cs | 4 +- .../Controllers/GraphQLControllerTest.cs | 2 +- .../GraphTypes/ActionQueryTest.cs | 78 +++++++++---------- .../GraphTypes/AddressQueryTest.cs | 4 +- .../GraphTypes/CraftQueryTest.cs | 4 +- .../GraphTypes/GraphQLTestBase.cs | 4 +- .../GraphTypes/SignScenarioTest.cs | 18 ++--- .../GraphTypes/StandaloneMutationTest.cs | 28 +++---- .../StandaloneQueryTest.ActionTxQuery.cs | 6 +- .../GraphTypes/StandaloneQueryTest.cs | 34 ++++---- .../GraphTypes/StandaloneSubscriptionTest.cs | 2 +- .../GraphTypes/StateQueryTest.cs | 2 +- .../States/Models/MeadPledgeTypeTest.cs | 2 +- .../TransactionHeadlessQueryTest.cs | 6 +- .../GraphTypes/TransferNCGHistoryTypeTest.cs | 4 +- .../GraphTypes/WorldBossScenarioTest.cs | 4 +- .../Controllers/GraphQLController.cs | 4 +- .../GraphTypes/ActionMutation.cs | 2 +- .../GraphTypes/ActionTxQuery.cs | 2 +- .../GraphTypes/ActivationStatusQuery.cs | 2 +- .../GraphTypes/PublicKeyType.cs | 2 +- .../GraphTypes/StandaloneMutation.cs | 4 +- .../GraphTypes/StandaloneQuery.cs | 4 +- .../GraphTypes/TransactionHeadlessQuery.cs | 4 +- 31 files changed, 130 insertions(+), 132 deletions(-) diff --git a/Libplanet.Extensions.ForkableActionEvaluator.Tests/ForkableActionEvaluatorTest.cs b/Libplanet.Extensions.ForkableActionEvaluator.Tests/ForkableActionEvaluatorTest.cs index 3e40b03c0..6549e728c 100644 --- a/Libplanet.Extensions.ForkableActionEvaluator.Tests/ForkableActionEvaluatorTest.cs +++ b/Libplanet.Extensions.ForkableActionEvaluator.Tests/ForkableActionEvaluatorTest.cs @@ -73,7 +73,6 @@ public IReadOnlyList Evaluate(IPreEvaluationBlock bl default, 0, 0, - false, default, 0, false), @@ -97,7 +96,6 @@ public IReadOnlyList Evaluate(IPreEvaluationBlock bl default, 0, 0, - false, default, 0, false), diff --git a/NineChronicles.Headless.Executable.Tests/Commands/AccountCommandTest.cs b/NineChronicles.Headless.Executable.Tests/Commands/AccountCommandTest.cs index a190c5cdc..e21a38c07 100644 --- a/NineChronicles.Headless.Executable.Tests/Commands/AccountCommandTest.cs +++ b/NineChronicles.Headless.Executable.Tests/Commands/AccountCommandTest.cs @@ -40,7 +40,7 @@ public void Balance(StoreType storeType) { IStore store = storeType.CreateStore(_storePath); var statesPath = Path.Combine(_storePath, "states"); - Address targetAddress = new PrivateKey().ToAddress(); + Address targetAddress = new PrivateKey().Address; int targetCurrency = 10000; // 100 NCG Block genesisBlock = GenesisHelper.MineGenesisBlock(targetAddress, targetCurrency); var stateKeyValueStore = new RocksDBKeyValueStore(statesPath); diff --git a/NineChronicles.Headless.Executable.Tests/Commands/ActionCommandTest.cs b/NineChronicles.Headless.Executable.Tests/Commands/ActionCommandTest.cs index a0745ed60..6853ee931 100644 --- a/NineChronicles.Headless.Executable.Tests/Commands/ActionCommandTest.cs +++ b/NineChronicles.Headless.Executable.Tests/Commands/ActionCommandTest.cs @@ -116,8 +116,8 @@ public void TransferAsset( var recipientPrivateKey = new PrivateKey(); var filePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); var resultCode = _command.TransferAsset( - senderPrivateKey.ToAddress().ToHex(), - recipientPrivateKey.ToAddress().ToHex(), + senderPrivateKey.Address.ToHex(), + recipientPrivateKey.Address.ToHex(), Convert.ToString(amount), filePath, memo); @@ -134,8 +134,8 @@ public void TransferAsset( action.LoadPlainValue(plainValue); Assert.Equal(memo, action.Memo); Assert.Equal(amount, action.Amount.MajorUnit); - Assert.Equal(senderPrivateKey.ToAddress(), action.Sender); - Assert.Equal(recipientPrivateKey.ToAddress(), action.Recipient); + Assert.Equal(senderPrivateKey.Address, action.Sender); + Assert.Equal(recipientPrivateKey.Address, action.Recipient); } else { @@ -205,7 +205,7 @@ public void ClaimStakeReward(string addressString, int expectedCode) public void ClaimStakeRewardWithBlockIndex(long blockIndex, Type expectedActionType) { var filePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); - var addr = new PrivateKey().ToAddress(); + var addr = new PrivateKey().Address; var resultCode = _command.ClaimStakeReward( addr.ToHex(), filePath, @@ -236,7 +236,7 @@ public void ClaimStakeRewardWithActionVersion( for (var i = actionVersionMin; i < actionVersionMax + 1; i++) { var filePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); - var addr = new PrivateKey().ToAddress(); + var addr = new PrivateKey().Address; var resultCode = _command.ClaimStakeReward( addr.ToHex(), filePath, diff --git a/NineChronicles.Headless.Executable.Tests/Commands/TxCommandTest.cs b/NineChronicles.Headless.Executable.Tests/Commands/TxCommandTest.cs index 0daabf136..732d040fc 100644 --- a/NineChronicles.Headless.Executable.Tests/Commands/TxCommandTest.cs +++ b/NineChronicles.Headless.Executable.Tests/Commands/TxCommandTest.cs @@ -73,8 +73,8 @@ public void Sign_TransferAsset(int amount, bool gas) var filePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); var actionCommand = new ActionCommand(_console); actionCommand.TransferAsset( - _privateKey.ToAddress().ToHex(), - new PrivateKey().ToAddress().ToHex(), + _privateKey.Address.ToHex(), + new PrivateKey().Address.ToHex(), Convert.ToString(amount), filePath); Assert_Tx(1, filePath, gas); @@ -143,7 +143,7 @@ private void Assert_Tx(long txNonce, string filePath, bool gas) var tx = Transaction.Deserialize(rawTx); Assert.Equal(txNonce, tx.Nonce); Assert.Equal(_blockHash, tx.GenesisHash); - Assert.Equal(_privateKey.ToAddress(), tx.Signer); + Assert.Equal(_privateKey.Address, tx.Signer); Assert.Equal(timeStamp, tx.Timestamp); ActionBase action = (ActionBase)new NCActionLoader().LoadAction(1L, tx.Actions.Single()); long expectedGasLimit = 1L; diff --git a/NineChronicles.Headless.Executable/Commands/GenesisCommand.cs b/NineChronicles.Headless.Executable/Commands/GenesisCommand.cs index 2ff33584c..b4653d034 100644 --- a/NineChronicles.Headless.Executable/Commands/GenesisCommand.cs +++ b/NineChronicles.Headless.Executable/Commands/GenesisCommand.cs @@ -57,7 +57,7 @@ out List initialDepositList { new() { - Address = initialMinter.ToAddress(), + Address = initialMinter.Address, AmountPerBlock = DefaultCurrencyValue, StartBlock = 0, EndBlock = 0, @@ -88,7 +88,7 @@ out List initialDepositList $"Give initial {DefaultCurrencyValue} currency to InitialMinter"); initialDepositList.Add(new GoldDistribution { - Address = initialMinter.ToAddress(), + Address = initialMinter.Address, AmountPerBlock = DefaultCurrencyValue, StartBlock = 0, EndBlock = 0 @@ -101,7 +101,7 @@ out List initialDepositList #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 - currency = Currency.Legacy("NCG", 2, minters: config.Value.AllowMint ? null : ImmutableHashSet.Create(initialMinter.ToAddress())); + currency = Currency.Legacy("NCG", 2, minters: config.Value.AllowMint ? null : ImmutableHashSet.Create(initialMinter.Address)); #pragma warning restore CS0618 } @@ -130,7 +130,7 @@ out List meadActions if (string.IsNullOrEmpty(config.Value.Address)) { _console.Out.WriteLine("Admin address not provided. Give admin privilege to initialMinter"); - adminAddress = initialMinter.ToAddress(); + adminAddress = initialMinter.Address; } else { @@ -303,7 +303,7 @@ public void Mine( File.WriteAllText("initial_deposit.csv", "Address,PrivateKey,AmountPerBlock,StartBlock,EndBlock\n"); File.AppendAllText("initial_deposit.csv", - $"{initialMinter.ToAddress()},{ByteUtil.Hex(initialMinter.ByteArray)},{DefaultCurrencyValue},0,0"); + $"{initialMinter.Address},{ByteUtil.Hex(initialMinter.ByteArray)},{DefaultCurrencyValue},0,0"); } else { diff --git a/NineChronicles.Headless.Executable/Commands/Key/ConversionCommand.cs b/NineChronicles.Headless.Executable/Commands/Key/ConversionCommand.cs index 2d3b5bea5..f322b9652 100644 --- a/NineChronicles.Headless.Executable/Commands/Key/ConversionCommand.cs +++ b/NineChronicles.Headless.Executable/Commands/Key/ConversionCommand.cs @@ -30,7 +30,7 @@ public void PrivateKey( var privateKey = new PrivateKey(ByteUtil.ParseHex(privateKeyHex)); if (address) { - _console.Out.WriteLine(privateKey.ToAddress().ToHex()); + _console.Out.WriteLine(privateKey.Address.ToHex()); } if (publicKey) diff --git a/NineChronicles.Headless.Executable/Commands/KeyCommand.cs b/NineChronicles.Headless.Executable/Commands/KeyCommand.cs index 2c7672866..943f217c8 100644 --- a/NineChronicles.Headless.Executable/Commands/KeyCommand.cs +++ b/NineChronicles.Headless.Executable/Commands/KeyCommand.cs @@ -162,7 +162,7 @@ public void Generate( { var key = new PrivateKey(); string priv = ByteUtil.Hex(key.ByteArray); - string addr = key.ToAddress().ToString(); + string addr = key.Address.ToString(); string pub = ByteUtil.Hex(key.PublicKey.Format(compress: true)); if (!noAddress && publicKey) diff --git a/NineChronicles.Headless.Tests/Common/Fixtures.cs b/NineChronicles.Headless.Tests/Common/Fixtures.cs index 59cdc950b..7d165541c 100644 --- a/NineChronicles.Headless.Tests/Common/Fixtures.cs +++ b/NineChronicles.Headless.Tests/Common/Fixtures.cs @@ -16,9 +16,9 @@ public static class Fixtures public static readonly PrivateKey UserPrivateKey = new PrivateKey(ByteUtil.ParseHex("b934cb79757b1dec9f89caa01c4b791a6de6937dbecdc102fbdca217156cc2f5")); - public static readonly Address MinerAddress = new PrivateKey().PublicKey.ToAddress(); + public static readonly Address MinerAddress = new PrivateKey().PublicKey.Address; - public static readonly Address UserAddress = UserPrivateKey.PublicKey.ToAddress(); + public static readonly Address UserAddress = UserPrivateKey.PublicKey.Address; public static readonly Address AvatarAddress = new Address("983c3Fbfe8243a0e36D55C6C1aE26A7c8Bb6CBd4"); diff --git a/NineChronicles.Headless.Tests/Controllers/GraphQLControllerTest.cs b/NineChronicles.Headless.Tests/Controllers/GraphQLControllerTest.cs index c94c32b38..f9daa0754 100644 --- a/NineChronicles.Headless.Tests/Controllers/GraphQLControllerTest.cs +++ b/NineChronicles.Headless.Tests/Controllers/GraphQLControllerTest.cs @@ -132,7 +132,7 @@ public void SetPrivateKeyThrowsBadRequest() [InlineData(false)] public void RemoveSubscribe(bool exist) { - var address = new PrivateKey().ToAddress(); + var address = new PrivateKey().Address; if (exist) { _standaloneContext.AgentAddresses[address] = (new ReplaySubject(), new ReplaySubject(), new ReplaySubject()); diff --git a/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs b/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs index 9628f9631..99db860d0 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/ActionQueryTest.cs @@ -52,11 +52,11 @@ public ActionQueryTest() .Add("address", RedeemCodeState.Address.Serialize()) .Add("map", Bencodex.Types.Dictionary.Empty) ), - adminAddressState: new AdminState(new PrivateKey().ToAddress(), 1500000), + adminAddressState: new AdminState(new PrivateKey().Address, 1500000), activatedAccountsState: new ActivatedAccountsState(), #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 - goldCurrencyState: new GoldCurrencyState(Currency.Legacy("NCG", 2, minerPrivateKey.ToAddress())), + goldCurrencyState: new GoldCurrencyState(Currency.Legacy("NCG", 2, minerPrivateKey.Address)), #pragma warning restore CS0618 goldDistributions: Array.Empty(), tableSheets: new Dictionary(), @@ -94,7 +94,7 @@ public async Task Stake(BigInteger amount) [Fact] public async Task ClaimStakeReward() { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; string query = $@" {{ claimStakeReward(avatarAddress: ""{avatarAddress.ToString()}"") @@ -111,7 +111,7 @@ public async Task ClaimStakeReward() [Fact] public async Task MigrateMonsterCollection() { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; string query = $@" {{ migrateMonsterCollection(avatarAddress: ""{avatarAddress.ToString()}"") @@ -150,7 +150,7 @@ private class StakeFixture : IEnumerable [InlineData(null, false)] public async Task Grinding(string chargeApValue, bool chargeAp) { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var equipmentId = Guid.NewGuid(); string queryArgs = $"avatarAddress: \"{avatarAddress.ToString()}\", equipmentIds: [{string.Format($"\"{equipmentId}\"")}]"; @@ -180,7 +180,7 @@ public async Task Grinding(string chargeApValue, bool chargeAp) [Fact] public async Task UnlockEquipmentRecipe() { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; string query = $@" {{ unlockEquipmentRecipe(avatarAddress: ""{avatarAddress.ToString()}"", recipeIds: [2, 3]) @@ -207,7 +207,7 @@ public async Task UnlockEquipmentRecipe() [Fact] public async Task UnlockWorld() { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; string query = $@" {{ unlockWorld(avatarAddress: ""{avatarAddress.ToString()}"", worldIds: [2, 3]) @@ -238,8 +238,8 @@ public async Task UnlockWorld() [InlineData("CRYSTAL", false)] public async Task TransferAssetWithCurrencyEnum(string currencyType, bool memo) { - var recipient = new PrivateKey().ToAddress(); - var sender = new PrivateKey().ToAddress(); + var recipient = new PrivateKey().Address; + var sender = new PrivateKey().Address; var args = $"recipient: \"{recipient}\", sender: \"{sender}\", amount: \"17.5\", currency: {currencyType}"; if (memo) { @@ -280,8 +280,8 @@ public async Task TransferAsset(string valueType, bool memo) var rawState = _standaloneContext.BlockChain!.GetState(Addresses.GoldCurrency); var goldCurrencyState = new GoldCurrencyState((Dictionary)rawState); - var recipient = new PrivateKey().ToAddress(); - var sender = new PrivateKey().ToAddress(); + var recipient = new PrivateKey().Address; + var sender = new PrivateKey().Address; var valueTypeWithMinter = valueType.Replace("[]", valueType.Contains("NCG") ? $"[\"{goldCurrencyState.Currency.Minters.First()}\"]" : "[]"); var args = $"recipient: \"{recipient}\", sender: \"{sender}\", rawCurrency: {valueTypeWithMinter}, amount: \"17.5\""; @@ -382,7 +382,7 @@ public async Task PatchTableSheet_Invalid_TableName() [InlineData(false, false, false, false, true)] public async Task Raid(bool equipment, bool costume, bool food, bool payNcg, bool rune) { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var args = $"avatarAddress: \"{avatarAddress}\""; var guid = Guid.NewGuid(); if (equipment) @@ -466,7 +466,7 @@ public async Task Raid(bool equipment, bool costume, bool food, bool payNcg, boo [Fact] public async Task ClaimRaidReward() { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var query = $"{{ claimRaidReward(avatarAddress: \"{avatarAddress}\") }}"; var queryResult = await ExecuteQueryAsync(query, standaloneContext: _standaloneContext); var data = (Dictionary)((ExecutionNode)queryResult.Data!).ToValue()!; @@ -481,7 +481,7 @@ public async Task ClaimRaidReward() [Fact] public async Task ClaimWorldBossKillReward() { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var query = $"{{ claimWorldBossKillReward(avatarAddress: \"{avatarAddress}\") }}"; var queryResult = await ExecuteQueryAsync(query, standaloneContext: _standaloneContext); var data = (Dictionary)((ExecutionNode)queryResult.Data!).ToValue()!; @@ -498,7 +498,7 @@ public async Task ClaimWorldBossKillReward() [InlineData(false, 1)] public async Task PrepareRewardAssets(bool mintersExist, int expectedCount) { - var rewardPoolAddress = new PrivateKey().ToAddress(); + var rewardPoolAddress = new PrivateKey().Address; var assets = "{quantity: 100, decimalPlaces: 0, ticker: \"CRYSTAL\"}"; if (mintersExist) { @@ -536,7 +536,7 @@ public async Task PrepareRewardAssets(bool mintersExist, int expectedCount) [InlineData(false)] public async Task TransferAssets(bool exc) { - var sender = new PrivateKey().ToAddress(); + var sender = new PrivateKey().Address; var recipients = $"{{ recipient: \"{sender}\", amount: {{ quantity: 100, decimalPlaces: 18, ticker: \"CRYSTAL\" }} }}, {{ recipient: \"{sender}\", amount: {{ quantity: 100, decimalPlaces: 0, ticker: \"RUNE_FENRIR1\" }} }}"; if (exc) @@ -678,7 +678,7 @@ public async Task CreateAvatar( [InlineData(1001, -1, false)] public async Task RuneEnhancement(int runeId, int? tryCount, bool isSuccessCase) { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var args = $"avatarAddress: \"{avatarAddress}\", runeId: {runeId}"; if (tryCount is not null) { @@ -712,7 +712,7 @@ public async Task RuneEnhancement(int runeId, int? tryCount, bool isSuccessCase) [InlineData(true, true, true, true, true)] public async Task HackAndSlash(bool useCostume, bool useEquipment, bool useFood, bool useRune, bool useBuff) { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var worldId = 1; var stageId = 1; var costume = Guid.NewGuid(); @@ -794,7 +794,7 @@ public async Task HackAndSlash(bool useCostume, bool useEquipment, bool useFood, [InlineData(true, true, true, true)] public async Task HackAndSlashSweep(bool useCostume, bool useEquipment, bool useRune, bool useApStone) { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var worldId = 1; var stageId = 1; var costume = Guid.NewGuid(); @@ -863,7 +863,7 @@ public async Task HackAndSlashSweep(bool useCostume, bool useEquipment, bool use [Fact] public async Task DailyReward() { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var query = $"{{dailyReward(avatarAddress: \"{avatarAddress}\")}}"; var queryResult = await ExecuteQueryAsync(query, standaloneContext: _standaloneContext); Assert.Null(queryResult.Errors); @@ -881,7 +881,7 @@ public async Task DailyReward() [InlineData(false)] public async Task CombinationEquipment(bool useSubRecipe) { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var slotIndex = 0; var recipeId = 1; var subRecipeId = 10; @@ -924,7 +924,7 @@ public async Task CombinationEquipment(bool useSubRecipe) [Fact] public async Task ItemEnhancement() { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var slotIndex = 0; var itemId = Guid.NewGuid(); var materialIds = new List { Guid.NewGuid() }; @@ -954,7 +954,7 @@ public async Task ItemEnhancement() [Fact] public async Task RapidCombination() { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var slotIndex = 0; var query = $"{{rapidCombination(avatarAddress: \"{avatarAddress}\", slotIndex: {slotIndex})}}"; @@ -973,7 +973,7 @@ public async Task RapidCombination() [Fact] public async Task CombinationConsumable() { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var slotIndex = 0; var recipeId = 1; @@ -997,7 +997,7 @@ public async Task CombinationConsumable() [InlineData(100, 100)] public async Task RequestPledge(int? mead, int expected) { - var agentAddress = new PrivateKey().ToAddress(); + var agentAddress = new PrivateKey().Address; var query = mead.HasValue ? $"{{requestPledge(agentAddress: \"{agentAddress}\", mead: {mead})}}" @@ -1017,7 +1017,7 @@ public async Task RequestPledge(int? mead, int expected) [Fact] public async Task ApprovePledge() { - var patronAddress = new PrivateKey().ToAddress(); + var patronAddress = new PrivateKey().Address; var query = $"{{approvePledge(patronAddress: \"{patronAddress}\")}}"; var queryResult = await ExecuteQueryAsync(query, standaloneContext: _standaloneContext); @@ -1034,7 +1034,7 @@ public async Task ApprovePledge() [Fact] public async Task EndPledge() { - var agentAddress = new PrivateKey().ToAddress(); + var agentAddress = new PrivateKey().Address; var query = $"{{endPledge(agentAddress: \"{agentAddress}\")}}"; var queryResult = await ExecuteQueryAsync(query, standaloneContext: _standaloneContext); @@ -1053,7 +1053,7 @@ public async Task EndPledge() [InlineData(1, 1)] public async Task CreatePledge(int? mead, int expected) { - var agentAddress = new PrivateKey().ToAddress(); + var agentAddress = new PrivateKey().Address; var query = mead.HasValue ? $"{{createPledge(patronAddress: \"{MeadConfig.PatronAddress}\", agentAddresses: [\"{agentAddress}\"], mead: {mead})}}" @@ -1153,15 +1153,15 @@ private static IEnumerable GetMemberDataOfLoadIntoMyGarages() new[] { ( - address: new PrivateKey().ToAddress(), + address: new PrivateKey().Address, fungibleAssetValue: new FungibleAssetValue(Currencies.Garage, 1, 0) ), ( - address: new PrivateKey().ToAddress(), + address: new PrivateKey().Address, fungibleAssetValue: new FungibleAssetValue(Currencies.Garage, 1, 0) ), }, - new PrivateKey().ToAddress(), + new PrivateKey().Address, new[] { (fungibleId: new HashDigest(), count: 1), @@ -1238,14 +1238,14 @@ private static IEnumerable GetMemberDataOfDeliverToOthersGarages() { yield return new object[] { - new PrivateKey().ToAddress(), + new PrivateKey().Address, null, null, null, }; yield return new object[] { - new PrivateKey().ToAddress(), + new PrivateKey().Address, new[] { new FungibleAssetValue(Currencies.Garage, 1, 0), @@ -1328,22 +1328,22 @@ private static IEnumerable GetMemberDataOfUnloadFromMyGarages() { yield return new object[] { - new PrivateKey().ToAddress(), + new PrivateKey().Address, null, null, null, }; yield return new object[] { - new PrivateKey().ToAddress(), + new PrivateKey().Address, new[] { ( - address: new PrivateKey().ToAddress(), + address: new PrivateKey().Address, fungibleAssetValue: new FungibleAssetValue(Currencies.Garage, 1, 0) ), ( - address: new PrivateKey().ToAddress(), + address: new PrivateKey().Address, fungibleAssetValue: new FungibleAssetValue(Currencies.Garage, 1, 0) ), }, @@ -1360,7 +1360,7 @@ private static IEnumerable GetMemberDataOfUnloadFromMyGarages() public async Task AuraSummon() { var random = new Random(); - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var groupId = random.Next(10001, 10002 + 1); // FIXME: Change 10 to AuraSummon.SummonLimit var summonCount = random.Next(1, 10 + 1); @@ -1403,7 +1403,7 @@ public async Task ClaimItems(int claimDataCount, bool hasMemo) var expectedMemo = "This is test memo"; for (var i = 0; i < claimDataCount; i++) { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var currencyCount = random.Next(1, tickerList.Count + 1); var tickerCandidates = tickerList.OrderBy(i => random.Next()).Take(currencyCount); queryBuilder.Append($@"{{ diff --git a/NineChronicles.Headless.Tests/GraphTypes/AddressQueryTest.cs b/NineChronicles.Headless.Tests/GraphTypes/AddressQueryTest.cs index 4104ffe7e..fad1668b6 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/AddressQueryTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/AddressQueryTest.cs @@ -30,12 +30,12 @@ public AddressQueryTest() .Add("address", RedeemCodeState.Address.Serialize()) .Add("map", Bencodex.Types.Dictionary.Empty) ), - adminAddressState: new AdminState(new PrivateKey().ToAddress(), 1500000), + adminAddressState: new AdminState(new PrivateKey().Address, 1500000), activatedAccountsState: new ActivatedAccountsState(), #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 goldCurrencyState: - new GoldCurrencyState(Currency.Legacy("NCG", 2, minerPrivateKey.ToAddress())), + new GoldCurrencyState(Currency.Legacy("NCG", 2, minerPrivateKey.Address)), #pragma warning restore CS0618 goldDistributions: Array.Empty(), tableSheets: new Dictionary(), diff --git a/NineChronicles.Headless.Tests/GraphTypes/CraftQueryTest.cs b/NineChronicles.Headless.Tests/GraphTypes/CraftQueryTest.cs index 7f2271b3e..437987564 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/CraftQueryTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/CraftQueryTest.cs @@ -27,7 +27,7 @@ public CraftQueryTest() [Fact] public async Task EventConsumableItemCrafts() { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var eventScheduleId = 1; var eventConsumableItemRecipeId = 10; var slotIndex = 0; @@ -61,7 +61,7 @@ public async Task EventConsumableItemCrafts() [Fact] public async Task EventMaterialItemCrafts() { - var avatarAddress = new PrivateKey().ToAddress(); + var avatarAddress = new PrivateKey().Address; var eventScheduleId = 1; var eventMaterialItemRecipeId = 10; var MaterialsToUse = new Dictionary diff --git a/NineChronicles.Headless.Tests/GraphTypes/GraphQLTestBase.cs b/NineChronicles.Headless.Tests/GraphTypes/GraphQLTestBase.cs index 44fdb1b5f..d7393fbf7 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/GraphQLTestBase.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/GraphQLTestBase.cs @@ -138,7 +138,7 @@ public GraphQLTestBase(ITestOutputHelper output) protected PrivateKey AdminPrivateKey { get; } = new PrivateKey(); - protected Address AdminAddress => AdminPrivateKey.ToAddress(); + protected Address AdminAddress => AdminPrivateKey.Address; protected PrivateKey ProposerPrivateKey { get; } = new PrivateKey(); @@ -147,7 +147,7 @@ protected List GenesisValidators get => new List { ProposerPrivateKey - }.OrderBy(key => key.ToAddress()).ToList(); + }.OrderBy(key => key.Address).ToList(); } protected StandaloneSchema Schema { get; } diff --git a/NineChronicles.Headless.Tests/GraphTypes/SignScenarioTest.cs b/NineChronicles.Headless.Tests/GraphTypes/SignScenarioTest.cs index f982957b1..08ee85c08 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/SignScenarioTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/SignScenarioTest.cs @@ -40,8 +40,8 @@ public async Task SignTransaction_TransferAsset(bool gas) { var privateKey = new PrivateKey(); var privateKey2 = new PrivateKey(); - var recipient = privateKey.ToAddress(); - var sender = privateKey2.ToAddress(); + var recipient = privateKey.Address; + var sender = privateKey2.Address; // Create Action. var args = $"recipient: \"{recipient}\", sender: \"{sender}\", amount: \"17.5\", currency: CRYSTAL"; @@ -61,7 +61,7 @@ public async Task SignTransaction_TransferAsset(bool gas) public async Task SignTransaction_Raid(bool gas) { var privateKey = new PrivateKey(); - var avatarAddress = privateKey.ToAddress(); + var avatarAddress = privateKey.Address; var guid = Guid.NewGuid(); string ids = $"[\"{guid}\"]"; @@ -87,7 +87,7 @@ public async Task SignTransaction_Raid(bool gas) public async Task SignTransaction_ClaimRaidReward(bool gas) { var privateKey = new PrivateKey(); - var avatarAddress = privateKey.ToAddress(); + var avatarAddress = privateKey.Address; // Create Action. var args = $"avatarAddress: \"{avatarAddress}\""; object plainValue = await GetAction("claimRaidReward", args); @@ -104,7 +104,7 @@ public async Task SignTransaction_ClaimRaidReward(bool gas) public async Task SignTransaction_ClaimWorldBossKillReward(bool gas) { var privateKey = new PrivateKey(); - var avatarAddress = privateKey.ToAddress(); + var avatarAddress = privateKey.Address; // Create Action. var args = $"avatarAddress: \"{avatarAddress}\""; object plainValue = await GetAction("claimWorldBossKillReward", args); @@ -121,7 +121,7 @@ public async Task SignTransaction_ClaimWorldBossKillReward(bool gas) public async Task SignTransaction_PrepareRewardAssets(bool gas) { var privateKey = new PrivateKey(); - var rewardPoolAddress = privateKey.ToAddress(); + var rewardPoolAddress = privateKey.Address; // Create Action. var args = $"rewardPoolAddress: \"{rewardPoolAddress}\", assets:[{{ quantity: 100, decimalPlaces: 0, ticker: \"CRYSTAL\" }}]"; object plainValue = await GetAction("prepareRewardAssets", args); @@ -142,7 +142,7 @@ public async Task SignTransaction_PrepareRewardAssets(bool gas) public async Task SignTransaction_TransferAssets(bool gas) { var privateKey = new PrivateKey(); - var sender = privateKey.ToAddress(); + var sender = privateKey.Address; // Create Action. var args = $"sender: \"{sender}\", recipients: [{{ recipient: \"{sender}\", amount: {{ quantity: 100, decimalPlaces: 18, ticker: \"CRYSTAL\" }} }}, {{ recipient: \"{sender}\", amount: {{ quantity: 100, decimalPlaces: 0, ticker: \"RUNE_FENRIR1\" }} }}]"; object plainValue = await GetAction("transferAssets", args); @@ -158,7 +158,7 @@ public async Task SignTransaction_TransferAssets(bool gas) public async Task SignTransaction_CreatePledge() { var privateKey = new PrivateKey(); - var sender = privateKey.ToAddress(); + var sender = privateKey.Address; // Create Action. var args = $"patronAddress: \"{MeadConfig.PatronAddress}\", agentAddresses: [\"{sender}\"]"; object plainValue = await GetAction("createPledge", args); @@ -184,7 +184,7 @@ private async Task GetAction(string actionName, string queryArgs) { // Get Nonce. var nonceQuery = $@"query {{ - nextTxNonce(address: ""{privateKey.ToAddress()}"") + nextTxNonce(address: ""{privateKey.Address}"") }}"; var nonceQueryResult = await ExecuteQueryAsync(nonceQuery, standaloneContext: StandaloneContextFx); diff --git a/NineChronicles.Headless.Tests/GraphTypes/StandaloneMutationTest.cs b/NineChronicles.Headless.Tests/GraphTypes/StandaloneMutationTest.cs index 14e1e7f49..76db158cc 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/StandaloneMutationTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/StandaloneMutationTest.cs @@ -97,7 +97,7 @@ public async Task RevokePrivateKey() var protectedPrivateKey = ProtectedPrivateKey.Protect(privateKey, passphrase); KeyStore.Add(protectedPrivateKey); - var address = privateKey.ToAddress(); + var address = privateKey.Address; var result = await ExecuteQueryAsync( $"mutation {{ keyStore {{ revokePrivateKey(address: \"{address.ToHex()}\") {{ address }} }} }}"); @@ -140,7 +140,7 @@ public async Task ActivateAccount() data["activationStatus"])["activateAccount"]; Assert.True(result); - Address userAddress = StandaloneContextFx.NineChroniclesNodeService!.MinerPrivateKey!.ToAddress(); + Address userAddress = StandaloneContextFx.NineChroniclesNodeService!.MinerPrivateKey!.Address; IValue? state = BlockChain.GetState( userAddress.Derive(ActivationKey.DeriveKey) ); @@ -159,7 +159,7 @@ public async Task Transfer(string? memo, bool error) (Dictionary)BlockChain.GetState(GoldCurrencyState.Address) ).Currency; - Address senderAddress = service.MinerPrivateKey!.ToAddress(); + Address senderAddress = service.MinerPrivateKey!.Address; var store = service.Store; Block block = BlockChain.ProposeBlock( service.MinerPrivateKey, @@ -177,7 +177,7 @@ public async Task Transfer(string? memo, bool error) ); var recipientKey = new PrivateKey(); - Address recipient = recipientKey.ToAddress(); + Address recipient = recipientKey.Address; long txNonce = BlockChain.GetNextTxNonce(senderAddress); var args = $"recipient: \"{recipient}\", txNonce: {txNonce}, amount: \"17.5\""; @@ -246,7 +246,7 @@ public async Task TransferGold() (Dictionary)BlockChain.GetState(GoldCurrencyState.Address) ).Currency; - Address senderAddress = service.MinerPrivateKey!.ToAddress(); + Address senderAddress = service.MinerPrivateKey!.Address; var store = service.Store; Block block = BlockChain.ProposeBlock( @@ -265,7 +265,7 @@ public async Task TransferGold() ); var recipientKey = new PrivateKey(); - Address recipient = recipientKey.ToAddress(); + Address recipient = recipientKey.Address; var query = $"mutation {{ transferGold(recipient: \"{recipient}\", amount: \"17.5\") }}"; ExecutionResult result = await ExecuteQueryAsync(query); var data = (Dictionary)((ExecutionNode)result.Data!).ToValue()!; @@ -736,7 +736,7 @@ public async Task MonsterCollect() Block block = BlockChain.ProposeBlock(playerPrivateKey); BlockChain.Append(block, GenerateBlockCommit(block.Index, block.Hash, GenesisValidators)); - Assert.NotNull(BlockChain.GetState(playerPrivateKey.ToAddress())); + Assert.NotNull(BlockChain.GetState(playerPrivateKey.Address)); var result = await ExecuteQueryAsync(query); var data = (Dictionary)((ExecutionNode)result.Data!).ToValue()!; Assert.Null(result.Errors); @@ -761,7 +761,7 @@ public async Task MonsterCollect() public async Task ClaimMonsterCollectionReward() { var playerPrivateKey = StandaloneContextFx.NineChroniclesNodeService!.MinerPrivateKey!; - var avatarAddress = playerPrivateKey.ToAddress(); + var avatarAddress = playerPrivateKey.Address; string query = $@"mutation {{ action {{ claimMonsterCollectionReward(avatarAddress: ""{avatarAddress}"") @@ -781,7 +781,7 @@ public async Task ClaimMonsterCollectionReward() Block block = BlockChain.ProposeBlock(playerPrivateKey); BlockChain.Append(block, GenerateBlockCommit(block.Index, block.Hash, GenesisValidators)); - Assert.NotNull(BlockChain.GetState(playerPrivateKey.ToAddress())); + Assert.NotNull(BlockChain.GetState(playerPrivateKey.Address)); var result = await ExecuteQueryAsync(query); var data = (Dictionary)((ExecutionNode)result.Data!).ToValue()!; @@ -824,9 +824,9 @@ public async Task ClaimMonsterCollectionReward() // name = "avatar", // }; // BlockChain.MakeTransaction(playerPrivateKey, new[] { createAvatar }); - // await BlockChain.MineBlock(playerPrivateKey.ToAddress()); + // await BlockChain.MineBlock(playerPrivateKey.Address); // - // Assert.NotNull(BlockChain.GetState(playerPrivateKey.ToAddress())); + // Assert.NotNull(BlockChain.GetState(playerPrivateKey.Address)); // // var result = await ExecuteQueryAsync(query); // Assert.Null(result.Errors); @@ -951,7 +951,7 @@ public async Task Tx_ActivateAccount() var console = new StringIOConsole(); var txCommand = new TxCommand(console); var timeStamp = DateTimeOffset.UtcNow; - txCommand.Sign(ByteUtil.Hex(privateKey.ByteArray), BlockChain.GetNextTxNonce(privateKey.ToAddress()), ByteUtil.Hex(BlockChain.Genesis.Hash.ByteArray), timeStamp.ToString(), new[] { filePath }); + txCommand.Sign(ByteUtil.Hex(privateKey.ByteArray), BlockChain.GetNextTxNonce(privateKey.Address), ByteUtil.Hex(BlockChain.Genesis.Hash.ByteArray), timeStamp.ToString(), new[] { filePath }); var output = console.Out.ToString(); output = output.Trim(); var queryResult = await ExecuteQueryAsync( @@ -965,7 +965,7 @@ public async Task Tx_ActivateAccount() var result = (bool)data["stageTx"]; Assert.True(result); - IValue? state = BlockChain.GetState(privateKey.ToAddress().Derive(ActivationKey.DeriveKey)); + IValue? state = BlockChain.GetState(privateKey.Address.Derive(ActivationKey.DeriveKey)); Assert.True((Bencodex.Types.Boolean)state); } @@ -989,7 +989,7 @@ public async Task StageTransaction() var pk = new PrivateKey(); ActionBase action = new ApprovePledge { - PatronAddress = new PrivateKey().ToAddress() + PatronAddress = new PrivateKey().Address }; var tx = Transaction.Create(0, pk, BlockChain.Genesis.Hash, new[] { action.PlainValue }); var payload = ByteUtil.Hex(tx.Serialize()); diff --git a/NineChronicles.Headless.Tests/GraphTypes/StandaloneQueryTest.ActionTxQuery.cs b/NineChronicles.Headless.Tests/GraphTypes/StandaloneQueryTest.ActionTxQuery.cs index d8441fc3e..51d9a84e4 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/StandaloneQueryTest.ActionTxQuery.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/StandaloneQueryTest.ActionTxQuery.cs @@ -32,7 +32,7 @@ public async Task ActionTxQuery_CreateTransaction() var stake = Assert.IsType(actionTxQueryData["stake"]); var tx = TxMarshaler.DeserializeUnsignedTx(ByteUtil.ParseHex(stake)); Assert.Equal(publicKey, tx.PublicKey); - Assert.Equal(publicKey.ToAddress(), tx.Signer); + Assert.Equal(publicKey.Address, tx.Signer); Assert.Equal(0, tx.Nonce); Assert.Equal(1, tx.GasLimit); Assert.Equal(1 * Currencies.Mead, tx.MaxGasPrice); @@ -67,7 +67,7 @@ public async Task ActionTxQuery_CreateTransaction_With_Timestamp(string timestam public async Task ActionTxQuery_With_Gas() { var publicKey = new PrivateKey().PublicKey; - var address = new PrivateKey().ToAddress(); + var address = new PrivateKey().Address; long nonce = 0; var result = await ExecuteQueryAsync($@" query {{ @@ -81,7 +81,7 @@ public async Task ActionTxQuery_With_Gas() var stake = Assert.IsType(actionTxQueryData["requestPledge"]); var tx = TxMarshaler.DeserializeUnsignedTx(ByteUtil.ParseHex(stake)); Assert.Equal(publicKey, tx.PublicKey); - Assert.Equal(publicKey.ToAddress(), tx.Signer); + Assert.Equal(publicKey.Address, tx.Signer); Assert.Equal(0, tx.Nonce); Assert.IsType(tx.Timestamp); Assert.Equal(1, tx.GasLimit); diff --git a/NineChronicles.Headless.Tests/GraphTypes/StandaloneQueryTest.cs b/NineChronicles.Headless.Tests/GraphTypes/StandaloneQueryTest.cs index a7847392f..3a2a5bb82 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/StandaloneQueryTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/StandaloneQueryTest.cs @@ -100,7 +100,7 @@ public async Task DecryptedPrivateKey() var privateKey = protectedPrivateKey.Unprotect(passphrase); KeyStore.Add(protectedPrivateKey); - var result = await ExecuteQueryAsync($"query {{ keyStore {{ decryptedPrivateKey(address: \"{privateKey.ToAddress()}\", passphrase: \"{passphrase}\") }} }}"); + var result = await ExecuteQueryAsync($"query {{ keyStore {{ decryptedPrivateKey(address: \"{privateKey.Address}\", passphrase: \"{passphrase}\") }} }}"); var data = (Dictionary)((ExecutionNode)result.Data!).ToValue()!; var keyStoreResult = (Dictionary)data["keyStore"]; @@ -209,7 +209,7 @@ public async Task NodeStatusStagedTxIds() new ActionBase[] { } ); - var address = privateKey.ToAddress(); + var address = privateKey.Address; var query = $@"query {{ nodeStatus {{ stagedTxIds(address: ""{address}"") @@ -239,7 +239,7 @@ public async Task NodeStatusGetTopMostBlocks() { ProposerPrivateKey, userPrivateKey, - }.OrderBy(x => x.ToAddress()).ToList(); + }.OrderBy(x => x.Address).ToList(); var service = MakeNineChroniclesNodeService(userPrivateKey); StandaloneContextFx.NineChroniclesNodeService = service; StandaloneContextFx.BlockChain = service.Swarm?.BlockChain; @@ -423,7 +423,7 @@ public async Task ConvertPrivateKey(bool compress) Assert.Equal(privateKeyHex, privateKeyResult["hex"]); var publicKeyResult = (Dictionary)privateKeyResult["publicKey"]; Assert.Equal(ByteUtil.Hex(privateKey.PublicKey.Format(compress)), publicKeyResult["hex"]); - Assert.Equal(privateKey.ToAddress().ToString(), publicKeyResult["address"]); + Assert.Equal(privateKey.Address.ToString(), publicKeyResult["address"]); } [Theory] @@ -432,7 +432,7 @@ public async Task ConvertPrivateKey(bool compress) public async Task ActivationStatus(bool existsActivatedAccounts) { var adminPrivateKey = new PrivateKey(); - var adminAddress = adminPrivateKey.ToAddress(); + var adminAddress = adminPrivateKey.Address; var activatedAccounts = ImmutableHashSet
.Empty; if (existsActivatedAccounts) @@ -557,11 +557,11 @@ public async Task ActivationStatus(bool existsActivatedAccounts) public async Task GoldBalance() { var userPrivateKey = new PrivateKey(); - var userAddress = userPrivateKey.ToAddress(); + var userAddress = userPrivateKey.Address; var validators = new List { ProposerPrivateKey, userPrivateKey - }.OrderBy(x => x.ToAddress()).ToList(); + }.OrderBy(x => x.Address).ToList(); var service = MakeNineChroniclesNodeService(userPrivateKey); StandaloneContextFx.NineChroniclesNodeService = service; StandaloneContextFx.BlockChain = service.Swarm?.BlockChain; @@ -600,7 +600,7 @@ public async Task GoldBalance() public async Task TransferNCGHistories(string? memo) { PrivateKey senderKey = ProposerPrivateKey, recipientKey = new PrivateKey(); - Address sender = senderKey.ToAddress(), recipient = recipientKey.ToAddress(); + Address sender = senderKey.Address, recipient = recipientKey.Address; Block block = BlockChain.ProposeBlock( ProposerPrivateKey, @@ -661,7 +661,7 @@ ITransferAsset GetFirstCustomActionAsTransferAsset(Transaction tx) public async Task MinerAddress() { var userPrivateKey = new PrivateKey(); - var userAddress = userPrivateKey.ToAddress(); + var userAddress = userPrivateKey.Address; var service = MakeNineChroniclesNodeService(userPrivateKey); StandaloneContextFx.NineChroniclesNodeService = service; StandaloneContextFx.BlockChain = service.Swarm!.BlockChain; @@ -685,7 +685,7 @@ public async Task MinerAddress() public async Task MonsterCollectionStatus_AgentState_Null(bool miner) { var userPrivateKey = new PrivateKey(); - var userAddress = userPrivateKey.ToAddress(); + var userAddress = userPrivateKey.Address; var service = MakeNineChroniclesNodeService(userPrivateKey); StandaloneContextFx.NineChroniclesNodeService = service; StandaloneContextFx.BlockChain = service.Swarm!.BlockChain; @@ -723,11 +723,11 @@ public async Task MonsterCollectionStatus_AgentState_Null(bool miner) public async Task MonsterCollectionStatus_MonsterCollectionState_Null(bool miner) { var userPrivateKey = new PrivateKey(); - var userAddress = userPrivateKey.ToAddress(); + var userAddress = userPrivateKey.Address; var validators = new List { ProposerPrivateKey, userPrivateKey - }.OrderBy(x => x.ToAddress()).ToList(); + }.OrderBy(x => x.Address).ToList(); var service = MakeNineChroniclesNodeService(userPrivateKey); StandaloneContextFx.NineChroniclesNodeService = service; StandaloneContextFx.BlockChain = service.Swarm!.BlockChain; @@ -778,11 +778,11 @@ public async Task MonsterCollectionStatus_MonsterCollectionState_Null(bool miner public async Task Avatar() { var userPrivateKey = new PrivateKey(); - var userAddress = userPrivateKey.ToAddress(); + var userAddress = userPrivateKey.Address; var validators = new List { ProposerPrivateKey, userPrivateKey - }.OrderBy(x => x.ToAddress()).ToList(); + }.OrderBy(x => x.Address).ToList(); var service = MakeNineChroniclesNodeService(userPrivateKey); StandaloneContextFx.NineChroniclesNodeService = service; StandaloneContextFx.BlockChain = service.Swarm!.BlockChain; @@ -828,7 +828,7 @@ public async Task Avatar() public async Task ActivationKeyNonce(bool trim) { var adminPrivateKey = new PrivateKey(); - var adminAddress = adminPrivateKey.ToAddress(); + var adminAddress = adminPrivateKey.Address; var activatedAccounts = ImmutableHashSet
.Empty; var nonce = new byte[] { 0x00, 0x01, 0x02, 0x03 }; var privateKey = new PrivateKey(); @@ -919,7 +919,7 @@ public async Task ActivationKeyNonce(bool trim) public async Task ActivationKeyNonce_Throw_ExecutionError(string code, string msg) { var adminPrivateKey = new PrivateKey(); - var adminAddress = adminPrivateKey.ToAddress(); + var adminAddress = adminPrivateKey.Address; var activatedAccounts = ImmutableHashSet
.Empty; var pendingActivationStates = new List(); @@ -1000,7 +1000,7 @@ public async Task ActivationKeyNonce_Throw_ExecutionError(string code, string ms public async Task Balance() { var adminPrivateKey = new PrivateKey(); - var adminAddress = adminPrivateKey.ToAddress(); + var adminAddress = adminPrivateKey.Address; var activatedAccounts = ImmutableHashSet
.Empty; var pendingActivationStates = new List(); diff --git a/NineChronicles.Headless.Tests/GraphTypes/StandaloneSubscriptionTest.cs b/NineChronicles.Headless.Tests/GraphTypes/StandaloneSubscriptionTest.cs index c441f7d8b..03b40deb9 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/StandaloneSubscriptionTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/StandaloneSubscriptionTest.cs @@ -156,7 +156,7 @@ public async Task SubscribePreloadProgress() var validators = new List { ProposerPrivateKey, apvPrivateKey - }.OrderBy(x => x.ToAddress()).ToList(); + }.OrderBy(x => x.Address).ToList(); // 에러로 인하여 NineChroniclesNodeService 를 사용할 수 없습니다. https://git.io/JfS0M // 따라서 LibplanetNodeService로 비슷한 환경을 맞춥니다. diff --git a/NineChronicles.Headless.Tests/GraphTypes/StateQueryTest.cs b/NineChronicles.Headless.Tests/GraphTypes/StateQueryTest.cs index 038763d82..8d7df65d9 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/StateQueryTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/StateQueryTest.cs @@ -224,7 +224,7 @@ public async Task Garage( private static IEnumerable GetMemberDataOfGarages() { - var agentAddr = new PrivateKey().ToAddress(); + var agentAddr = new PrivateKey().Address; yield return new object[] { agentAddr, diff --git a/NineChronicles.Headless.Tests/GraphTypes/States/Models/MeadPledgeTypeTest.cs b/NineChronicles.Headless.Tests/GraphTypes/States/Models/MeadPledgeTypeTest.cs index 2e55add9b..54b6a4b72 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/States/Models/MeadPledgeTypeTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/States/Models/MeadPledgeTypeTest.cs @@ -29,7 +29,7 @@ public async Task Query(bool exist, bool approved, int mead) Address? address = null; if (exist) { - address = new PrivateKey().ToAddress(); + address = new PrivateKey().Address; } (Address?, bool, int) contract = (address, approved, mead); var queryResult = await ExecuteQueryAsync(query, source: contract); diff --git a/NineChronicles.Headless.Tests/GraphTypes/TransactionHeadlessQueryTest.cs b/NineChronicles.Headless.Tests/GraphTypes/TransactionHeadlessQueryTest.cs index 8e9153f4b..339c043c4 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/TransactionHeadlessQueryTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/TransactionHeadlessQueryTest.cs @@ -77,7 +77,7 @@ public TransactionHeadlessQueryTest() public async Task NextTxNonce() { var userPrivateKey = new PrivateKey(); - var userAddress = userPrivateKey.ToAddress(); + var userAddress = userPrivateKey.Address; string query = $"{{ nextTxNonce(address: \"{userAddress}\") }}"; var queryResult = await ExecuteAsync(query); var data = (Dictionary)((ExecutionNode)queryResult.Data!).ToValue()!; @@ -163,7 +163,7 @@ public async Task CreateUnsignedTx(long? nonce) { var privateKey = new PrivateKey(); PublicKey publicKey = privateKey.PublicKey; - Address signer = publicKey.ToAddress(); + Address signer = publicKey.Address; long expectedNonce = nonce ?? _blockChain.GetNextTxNonce(signer); ActionBase action = new CreateAvatar2 { @@ -216,7 +216,7 @@ public async Task AttachSignature() { var privateKey = new PrivateKey(); PublicKey publicKey = privateKey.PublicKey; - Address signer = publicKey.ToAddress(); + Address signer = publicKey.Address; long nonce = _blockChain.GetNextTxNonce(signer); IUnsignedTx unsignedTx = new UnsignedTx( new TxInvoice(genesisHash: _blockChain.Genesis.Hash), diff --git a/NineChronicles.Headless.Tests/GraphTypes/TransferNCGHistoryTypeTest.cs b/NineChronicles.Headless.Tests/GraphTypes/TransferNCGHistoryTypeTest.cs index 0e8506398..7958316d9 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/TransferNCGHistoryTypeTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/TransferNCGHistoryTypeTest.cs @@ -21,8 +21,8 @@ public class TransferNCGHistoryTypeTest public async Task Query(string? memo) { Random random = new Random(); - Address sender = new PrivateKey().ToAddress(), - recipient = new PrivateKey().ToAddress(); + Address sender = new PrivateKey().Address, + recipient = new PrivateKey().Address; #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 Currency currency = Currency.Legacy("NCG", 2, null); diff --git a/NineChronicles.Headless.Tests/GraphTypes/WorldBossScenarioTest.cs b/NineChronicles.Headless.Tests/GraphTypes/WorldBossScenarioTest.cs index d791b86da..c1982fb9c 100644 --- a/NineChronicles.Headless.Tests/GraphTypes/WorldBossScenarioTest.cs +++ b/NineChronicles.Headless.Tests/GraphTypes/WorldBossScenarioTest.cs @@ -72,12 +72,12 @@ public WorldBossScenarioTest() .Add("address", RedeemCodeState.Address.Serialize()) .Add("map", Bencodex.Types.Dictionary.Empty) ), - adminAddressState: new AdminState(new PrivateKey().ToAddress(), 1500000), + adminAddressState: new AdminState(new PrivateKey().Address, 1500000), activatedAccountsState: new ActivatedAccountsState(), #pragma warning disable CS0618 // Use of obsolete method Currency.Legacy(): https://github.com/planetarium/lib9c/discussions/1319 goldCurrencyState: - new GoldCurrencyState(Currency.Legacy("NCG", 2, minerPrivateKey.ToAddress())), + new GoldCurrencyState(Currency.Legacy("NCG", 2, minerPrivateKey.Address)), #pragma warning restore CS0618 goldDistributions: Array.Empty(), tableSheets: new Dictionary(), diff --git a/NineChronicles.Headless/Controllers/GraphQLController.cs b/NineChronicles.Headless/Controllers/GraphQLController.cs index 88dacd21f..70a1591b5 100644 --- a/NineChronicles.Headless/Controllers/GraphQLController.cs +++ b/NineChronicles.Headless/Controllers/GraphQLController.cs @@ -71,7 +71,7 @@ public IActionResult SetPrivateKey([FromBody] SetPrivateKeyRequest request) var privateKey = new PrivateKey(destArray); StandaloneContext.NineChroniclesNodeService.MinerPrivateKey = privateKey; var msg = - $"Private key set ({StandaloneContext.NineChroniclesNodeService.MinerPrivateKey.PublicKey.ToAddress()})."; + $"Private key set ({StandaloneContext.NineChroniclesNodeService.MinerPrivateKey.PublicKey.Address})."; Log.Information("SetPrivateKey: {Msg}", msg); return Ok(msg); } @@ -234,7 +234,7 @@ private void NotifyAction(ActionEvaluation eval) Log.Information("PrivateKey is not set. please call SetPrivateKey() first."); return; } - Address address = StandaloneContext.NineChroniclesNodeService.MinerPrivateKey.PublicKey.ToAddress(); + Address address = StandaloneContext.NineChroniclesNodeService.MinerPrivateKey.PublicKey.Address; var input = StandaloneContext.NineChroniclesNodeService.BlockChain.GetAccountState(eval.PreviousState); var output = StandaloneContext.NineChroniclesNodeService.BlockChain.GetAccountState(eval.OutputState); var diff = AccountDiff.Create(input, output); diff --git a/NineChronicles.Headless/GraphTypes/ActionMutation.cs b/NineChronicles.Headless/GraphTypes/ActionMutation.cs index 7c8fa684a..03da59e92 100644 --- a/NineChronicles.Headless/GraphTypes/ActionMutation.cs +++ b/NineChronicles.Headless/GraphTypes/ActionMutation.cs @@ -508,7 +508,7 @@ public ActionMutation(NineChroniclesNodeService service) } Address avatarAddress = context.GetArgument
("avatarAddress"); - Address agentAddress = service.MinerPrivateKey.ToAddress(); + Address agentAddress = service.MinerPrivateKey.Address; AgentState agentState = new AgentState((Dictionary)service.BlockChain.GetState(agentAddress)); var action = new ClaimMonsterCollectionReward diff --git a/NineChronicles.Headless/GraphTypes/ActionTxQuery.cs b/NineChronicles.Headless/GraphTypes/ActionTxQuery.cs index f71ac845e..27bd9b506 100644 --- a/NineChronicles.Headless/GraphTypes/ActionTxQuery.cs +++ b/NineChronicles.Headless/GraphTypes/ActionTxQuery.cs @@ -25,7 +25,7 @@ internal override byte[] Encode(IResolveFieldContext context, ActionBase action) $"{nameof(Headless.StandaloneContext)}.{nameof(Headless.StandaloneContext.BlockChain)} was not set yet!"); } - Address signer = publicKey.ToAddress(); + Address signer = publicKey.Address; long nonce = context.Parent!.GetArgument("nonce") ?? blockChain.GetNextTxNonce(signer); DateTimeOffset? timestamp = context.Parent!.GetArgument("timestamp"); long? gasLimit = action is ITransferAsset or ITransferAssets ? RequestPledge.DefaultRefillMead : 1L; diff --git a/NineChronicles.Headless/GraphTypes/ActivationStatusQuery.cs b/NineChronicles.Headless/GraphTypes/ActivationStatusQuery.cs index cd6dea9f8..b0717d119 100644 --- a/NineChronicles.Headless/GraphTypes/ActivationStatusQuery.cs +++ b/NineChronicles.Headless/GraphTypes/ActivationStatusQuery.cs @@ -41,7 +41,7 @@ public ActivationStatusQuery(StandaloneContext standaloneContext) throw new InvalidOperationException($"{nameof(service.Swarm.BlockChain)} is null."); } - Address userAddress = privateKey.ToAddress(); + Address userAddress = privateKey.Address; Address activatedAddress = userAddress.Derive(ActivationKey.DeriveKey); if (blockChain.GetState(activatedAddress) is Bencodex.Types.Boolean) diff --git a/NineChronicles.Headless/GraphTypes/PublicKeyType.cs b/NineChronicles.Headless/GraphTypes/PublicKeyType.cs index 120a8d07f..e9d6aa8d8 100644 --- a/NineChronicles.Headless/GraphTypes/PublicKeyType.cs +++ b/NineChronicles.Headless/GraphTypes/PublicKeyType.cs @@ -28,7 +28,7 @@ public PublicKeyType() Field>( name: "address", description: "An address derived from the public-key.", - resolve: context => context.Source.ToAddress()); + resolve: context => context.Source.Address); } } } diff --git a/NineChronicles.Headless/GraphTypes/StandaloneMutation.cs b/NineChronicles.Headless/GraphTypes/StandaloneMutation.cs index 06223a2a4..b356498c8 100644 --- a/NineChronicles.Headless/GraphTypes/StandaloneMutation.cs +++ b/NineChronicles.Headless/GraphTypes/StandaloneMutation.cs @@ -205,7 +205,7 @@ IConfiguration configuration new ActionBase[] { new TransferAsset( - privateKey.ToAddress(), + privateKey.Address, recipient, amount, memo @@ -261,7 +261,7 @@ IConfiguration configuration new ActionBase[] { new TransferAsset( - privateKey.ToAddress(), + privateKey.Address, recipient, amount ), diff --git a/NineChronicles.Headless/GraphTypes/StandaloneQuery.cs b/NineChronicles.Headless/GraphTypes/StandaloneQuery.cs index 841a504db..413d20e12 100644 --- a/NineChronicles.Headless/GraphTypes/StandaloneQuery.cs +++ b/NineChronicles.Headless/GraphTypes/StandaloneQuery.cs @@ -263,7 +263,7 @@ public StandaloneQuery(StandaloneContext standaloneContext, IConfiguration confi $"{nameof(StandaloneContext)}.{nameof(StandaloneContext.NineChroniclesNodeService)}.{nameof(StandaloneContext.NineChroniclesNodeService.MinerPrivateKey)} is null."); } - return standaloneContext.NineChroniclesNodeService.MinerPrivateKey.ToAddress(); + return standaloneContext.NineChroniclesNodeService.MinerPrivateKey.Address; }); Field( @@ -295,7 +295,7 @@ public StandaloneQuery(StandaloneContext standaloneContext, IConfiguration confi $"{nameof(StandaloneContext)}.{nameof(StandaloneContext.NineChroniclesNodeService)}.{nameof(StandaloneContext.NineChroniclesNodeService.MinerPrivateKey)} is null."); } - agentAddress = standaloneContext.NineChroniclesNodeService!.MinerPrivateKey!.ToAddress(); + agentAddress = standaloneContext.NineChroniclesNodeService!.MinerPrivateKey!.Address; } else { diff --git a/NineChronicles.Headless/GraphTypes/TransactionHeadlessQuery.cs b/NineChronicles.Headless/GraphTypes/TransactionHeadlessQuery.cs index e8ea6a5b5..979e21b97 100644 --- a/NineChronicles.Headless/GraphTypes/TransactionHeadlessQuery.cs +++ b/NineChronicles.Headless/GraphTypes/TransactionHeadlessQuery.cs @@ -140,7 +140,7 @@ public TransactionHeadlessQuery(StandaloneContext standaloneContext) var action = NCActionUtils.ToAction(plainValue); var publicKey = new PublicKey(Convert.FromBase64String(context.GetArgument("publicKey"))); - Address signer = publicKey.ToAddress(); + Address signer = publicKey.Address; long nonce = context.GetArgument("nonce") ?? blockChain.GetNextTxNonce(signer); UnsignedTx unsignedTransaction = new UnsignedTx( @@ -251,7 +251,7 @@ public TransactionHeadlessQuery(StandaloneContext standaloneContext) var action = NCActionUtils.ToAction(plainValue); var publicKey = new PublicKey(ByteUtil.ParseHex(context.GetArgument("publicKey"))); - Address signer = publicKey.ToAddress(); + Address signer = publicKey.Address; long nonce = context.GetArgument("nonce") ?? blockChain.GetNextTxNonce(signer); long? gasLimit = action is ITransferAsset or ITransferAssets ? RequestPledge.DefaultRefillMead : 1L; FungibleAssetValue? maxGasPrice = context.GetArgument("maxGasPrice");