diff --git a/Libplanet.Action.Tests/Common/Attack.cs b/Libplanet.Action.Tests/Common/Attack.cs index 679a319e46f..3d989523eea 100644 --- a/Libplanet.Action.Tests/Common/Attack.cs +++ b/Libplanet.Action.Tests/Common/Attack.cs @@ -13,7 +13,7 @@ public class Attack : BaseAction .Add("values", Dictionary.Empty .Add("weapon", Weapon) .Add("target", Target) - .Add("target_address", TargetAddress.ByteArray)); + .Add("target_address", TargetAddress.Bencoded)); public string Weapon { get; set; } diff --git a/Libplanet.Action.Tests/Common/DetectRehearsal.cs b/Libplanet.Action.Tests/Common/DetectRehearsal.cs index cd0b2c86aea..164ebbb5b27 100644 --- a/Libplanet.Action.Tests/Common/DetectRehearsal.cs +++ b/Libplanet.Action.Tests/Common/DetectRehearsal.cs @@ -10,7 +10,7 @@ public class DetectRehearsal : BaseAction public override IValue PlainValue => Dictionary.Empty .Add("type_id", TypeId) .Add("values", Dictionary.Empty - .Add("target_address", TargetAddress.ByteArray)); + .Add("target_address", TargetAddress.Bencoded)); public bool ResultState { get; set; } diff --git a/Libplanet.Action.Tests/Common/DumbAction.cs b/Libplanet.Action.Tests/Common/DumbAction.cs index 9ce03d08027..3ce6c1ca913 100644 --- a/Libplanet.Action.Tests/Common/DumbAction.cs +++ b/Libplanet.Action.Tests/Common/DumbAction.cs @@ -96,7 +96,7 @@ public IValue PlainValue new Dictionary { ["item"] = (Text)Item, - ["target_address"] = new Binary(TargetAddress.ByteArray), + ["target_address"] = TargetAddress.Bencoded, ["record_rehearsal"] = new Bencodex.Types.Boolean(RecordRehearsal), }); } @@ -116,8 +116,8 @@ public IValue PlainValue if (!(Transfer is null)) { plainValue = plainValue - .Add("transfer_from", Transfer.Item1.ByteArray) - .Add("transfer_to", Transfer.Item2.ByteArray) + .Add("transfer_from", Transfer.Item1.Bencoded) + .Add("transfer_to", Transfer.Item2.Bencoded) .Add("transfer_amount", Transfer.Item3); } diff --git a/Libplanet.Action.Tests/Common/SetStatesAtBlock.cs b/Libplanet.Action.Tests/Common/SetStatesAtBlock.cs index 5923bbf3a89..1ebbcfb9a69 100644 --- a/Libplanet.Action.Tests/Common/SetStatesAtBlock.cs +++ b/Libplanet.Action.Tests/Common/SetStatesAtBlock.cs @@ -22,7 +22,7 @@ public SetStatesAtBlock(Address address, IValue value, long blockIndex) } public IValue PlainValue => Bencodex.Types.Dictionary.Empty - .Add("address", _address.ByteArray) + .Add("address", _address.Bencoded) .Add("value", _value) .Add("block_index", _blockIndex); diff --git a/Libplanet.Action.Tests/Loader/IndexedActionLoaderTest.cs b/Libplanet.Action.Tests/Loader/IndexedActionLoaderTest.cs index cace54b1acf..211d0e1383b 100644 --- a/Libplanet.Action.Tests/Loader/IndexedActionLoaderTest.cs +++ b/Libplanet.Action.Tests/Loader/IndexedActionLoaderTest.cs @@ -46,7 +46,7 @@ public void LoadAction() .Add("values", Dictionary.Empty .Add("weapon", "sword") .Add("target", "dummy") - .Add("target_address", new PrivateKey().PublicKey.ToAddress().ByteArray))); + .Add("target_address", new PrivateKey().PublicKey.ToAddress().Bencoded))); var action3 = new RandomAction(new PrivateKey().PublicKey.ToAddress()); var loader = new IndexedActionLoader( diff --git a/Libplanet.Tests/Action/ActionEvaluatorTest.cs b/Libplanet.Tests/Action/ActionEvaluatorTest.cs index ca5f9d2eb08..13a2d3bdf4f 100644 --- a/Libplanet.Tests/Action/ActionEvaluatorTest.cs +++ b/Libplanet.Tests/Action/ActionEvaluatorTest.cs @@ -1323,10 +1323,9 @@ private sealed class EvaluateTestAction : IAction public Address BlockIndexKey { get; set; } public IValue PlainValue => new List( - (Binary)SignerKey.ByteArray, - (Binary)MinerKey.ByteArray, - (Binary)BlockIndexKey.ByteArray - ); + SignerKey.Bencoded, + MinerKey.Bencoded, + BlockIndexKey.Bencoded); public void LoadPlainValue(IValue plainValue) { diff --git a/Libplanet.Tests/Blocks/BlockMarshalerTest.cs b/Libplanet.Tests/Blocks/BlockMarshalerTest.cs index 80792064ba6..4cd5791c9fa 100644 --- a/Libplanet.Tests/Blocks/BlockMarshalerTest.cs +++ b/Libplanet.Tests/Blocks/BlockMarshalerTest.cs @@ -132,7 +132,7 @@ public void MarshalBlockMetadata() Dictionary.Empty .Add(IndexKey, 0L) .Add(TimestampKey, "2021-09-06T04:46:39.123000Z") - .Add(MinerKey, _content.GenesisContentPv0.Miner.ByteArray), + .Add(MinerKey, _content.GenesisContentPv0.Miner.Bencoded), BlockMarshaler.MarshalBlockMetadata(_content.GenesisContentPv0) ); AssertBencodexEqual( @@ -143,7 +143,7 @@ public void MarshalBlockMetadata() PreviousHashKey, _content.Block1ContentPv1.PreviousHash?.ByteArray ?? default) .Add(TimestampKey, "2021-09-06T08:01:09.045000Z") - .Add(MinerKey, _content.Block1ContentPv1.Miner.ByteArray) + .Add(MinerKey, _content.Block1ContentPv1.Miner.Bencoded) .Add(TxHashKey, _content.Block1ContentPv1.TxHash?.ByteArray ?? default), BlockMarshaler.MarshalBlockMetadata(_content.Block1ContentPv1) ); diff --git a/Libplanet.Tests/Tx/TxMarshalerTest.cs b/Libplanet.Tests/Tx/TxMarshalerTest.cs index 6f496719e9f..d4579f23c85 100644 --- a/Libplanet.Tests/Tx/TxMarshalerTest.cs +++ b/Libplanet.Tests/Tx/TxMarshalerTest.cs @@ -314,7 +314,7 @@ public void UnmarshalTransactionWithCustomActions() .Add("values", Dictionary.Empty .Add("weapon", "wand") .Add("target", "orc") - .Add("target_address", new Address(publicKey).ByteArray)), + .Add("target_address", new Address(publicKey).Bencoded)), action0.PlainValue ); diff --git a/Libplanet.Tests/Tx/TxMetadataTest.cs b/Libplanet.Tests/Tx/TxMetadataTest.cs index 234c6e37273..5845d78e5bd 100644 --- a/Libplanet.Tests/Tx/TxMetadataTest.cs +++ b/Libplanet.Tests/Tx/TxMetadataTest.cs @@ -99,7 +99,7 @@ public void Deserialize() { Bencodex.Types.Dictionary dict1 = Dictionary.Empty .Add(new byte[] { 0x6e }, 123L) - .Add(new byte[] { 0x73 }, _key1.ToAddress().ByteArray) + .Add(new byte[] { 0x73 }, _key1.ToAddress().Bencoded) .Add(new byte[] { 0x75 }, new List()) .Add(new byte[] { 0x74 }, "2022-05-23T10:02:00.000000Z") .Add(new byte[] { 0x70 }, _key1.PublicKey.ToImmutableArray(compress: false)); @@ -115,12 +115,12 @@ public void Deserialize() Bencodex.Types.Dictionary dict2 = Dictionary.Empty .Add(new byte[] { 0x6e }, 0L) - .Add(new byte[] { 0x73 }, _key2.ToAddress().ByteArray) + .Add(new byte[] { 0x73 }, _key2.ToAddress().Bencoded) .Add( new byte[] { 0x75 }, Bencodex.Types.List.Empty - .Add(_key1.ToAddress().ToByteArray()) - .Add(_key2.ToAddress().ToByteArray())) + .Add(_key1.ToAddress().Bencoded) + .Add(_key2.ToAddress().Bencoded)) .Add(new byte[] { 0x74 }, "2022-01-12T04:56:07.890000Z") .Add(new byte[] { 0x70 }, _key2.PublicKey.ToImmutableArray(compress: false)) .Add( @@ -155,7 +155,7 @@ public void ToBencodex(DateTimeOffset timestamp) }; Bencodex.Types.Dictionary expected1 = Dictionary.Empty .Add(new byte[] { 0x6e }, 123L) - .Add(new byte[] { 0x73 }, _key1.ToAddress().ByteArray) + .Add(new byte[] { 0x73 }, _key1.ToAddress().Bencoded) .Add(new byte[] { 0x75 }, new List()) .Add(new byte[] { 0x74 }, "2022-05-23T10:02:00.000000Z") .Add(new byte[] { 0x70 }, _key1.PublicKey.ToImmutableArray(compress: false)); @@ -177,12 +177,12 @@ public void ToBencodex(DateTimeOffset timestamp) }; Bencodex.Types.Dictionary expected2 = Dictionary.Empty .Add(new byte[] { 0x6e }, 0L) - .Add(new byte[] { 0x73 }, _key2.ToAddress().ByteArray) + .Add(new byte[] { 0x73 }, _key2.ToAddress().Bencoded) .Add( new byte[] { 0x75 }, Bencodex.Types.List.Empty - .Add(_key1.ToAddress().ToByteArray()) - .Add(_key2.ToAddress().ToByteArray())) + .Add(_key1.ToAddress().Bencoded) + .Add(_key2.ToAddress().Bencoded)) .Add(new byte[] { 0x74 }, "2022-01-12T04:56:07.890000Z") .Add(new byte[] { 0x70 }, _key2.PublicKey.ToImmutableArray(compress: false)) .Add( diff --git a/Libplanet.Types/Assets/Currency.cs b/Libplanet.Types/Assets/Currency.cs index f001267b497..8707437e5e4 100644 --- a/Libplanet.Types/Assets/Currency.cs +++ b/Libplanet.Types/Assets/Currency.cs @@ -688,7 +688,7 @@ public bool Equals(Currency other) => public IValue Serialize() { IValue minters = Minters is IImmutableSet
m - ? new Bencodex.Types.List(m.Select(a => new Binary(a.ByteArray))) + ? new Bencodex.Types.List(m.Select(a => a.Bencoded)) : (IValue)Null.Value; var serialized = Bencodex.Types.Dictionary.Empty .Add("ticker", Ticker) @@ -727,7 +727,7 @@ private static SHA1 GetSHA1() private IValue SerializeForHash() { IValue minters = Minters is ImmutableHashSet
a - ? new List(a.OrderBy(m => m).Select(m => m.ByteArray)) + ? new List(a.OrderBy(m => m).Select(m => m.Bencoded)) : (IValue)Null.Value; var serialized = Dictionary.Empty diff --git a/Libplanet.Types/Blocks/BlockMarshaler.cs b/Libplanet.Types/Blocks/BlockMarshaler.cs index b6c5595b72e..d396ffd4b6e 100644 --- a/Libplanet.Types/Blocks/BlockMarshaler.cs +++ b/Libplanet.Types/Blocks/BlockMarshaler.cs @@ -93,7 +93,7 @@ public static Dictionary MarshalBlockMetadata(IBlockMetadata metadata) dict = metadata.PublicKey is { } pubKey ? dict.Add(PublicKeyKey, pubKey.Format(compress: true)) - : dict.Add(MinerKey, metadata.Miner.ByteArray); + : dict.Add(MinerKey, metadata.Miner.Bencoded); if (metadata.LastCommit is { } commit) { diff --git a/Libplanet.Types/Blocks/BlockMetadata.cs b/Libplanet.Types/Blocks/BlockMetadata.cs index b774ed3639d..76ff5a668b2 100644 --- a/Libplanet.Types/Blocks/BlockMetadata.cs +++ b/Libplanet.Types/Blocks/BlockMetadata.cs @@ -296,7 +296,7 @@ public Bencodex.Types.Dictionary MakeCandidateData(Nonce nonce) // and its ProtocolVersion is >= 2 when it is not null: dict = PublicKey is { } pubKey && ProtocolVersion >= 2 ? dict.Add("public_key", pubKey.Format(compress: true)) // ProtocolVersion >= 2 - : dict.Add("reward_beneficiary", Miner.ByteArray); /////// ProtocolVersion <= 1 + : dict.Add("reward_beneficiary", Miner.Bencoded); /////// ProtocolVersion <= 1 return dict; } diff --git a/Libplanet.Types/Tx/TxMarshaler.cs b/Libplanet.Types/Tx/TxMarshaler.cs index ccae2700e4e..22d400780d8 100644 --- a/Libplanet.Types/Tx/TxMarshaler.cs +++ b/Libplanet.Types/Tx/TxMarshaler.cs @@ -31,7 +31,7 @@ public static class TxMarshaler public static Bencodex.Types.Dictionary MarshalTxInvoice(this ITxInvoice invoice) { Bencodex.Types.List updatedAddresses = new Bencodex.Types.List( - invoice.UpdatedAddresses.Select(addr => new Binary(addr.ByteArray)) + invoice.UpdatedAddresses.Select(addr => addr.Bencoded) ); string timestamp = invoice.Timestamp .ToUniversalTime() @@ -70,7 +70,7 @@ public static Bencodex.Types.Dictionary MarshalTxSigningMetadata( this ITxSigningMetadata metadata ) => Dictionary.Empty .Add(NonceKey, metadata.Nonce) - .Add(SignerKey, metadata.Signer.ByteArray) + .Add(SignerKey, metadata.Signer.Bencoded) .Add(PublicKeyKey, metadata.PublicKey.ToImmutableArray(compress: false)); [Pure] diff --git a/Libplanet.Types/Tx/TxMetadata.cs b/Libplanet.Types/Tx/TxMetadata.cs index cff1456ea40..411f292a416 100644 --- a/Libplanet.Types/Tx/TxMetadata.cs +++ b/Libplanet.Types/Tx/TxMetadata.cs @@ -125,13 +125,13 @@ public TxMetadata(Bencodex.Types.Dictionary dictionary) public Bencodex.Types.Dictionary ToBencodex() { List updatedAddresses = new List( - UpdatedAddresses.Select(addr => new Binary(addr.ByteArray))); + UpdatedAddresses.Select(addr => addr.Bencoded)); string timestamp = Timestamp .ToUniversalTime() .ToString(TimestampFormat, CultureInfo.InvariantCulture); Bencodex.Types.Dictionary dict = Dictionary.Empty .Add(NonceKey, Nonce) - .Add(SignerKey, Signer.ByteArray) + .Add(SignerKey, Signer.Bencoded) .Add(UpdatedAddressesKey, updatedAddresses) .Add(PublicKeyKey, PublicKey.ToImmutableArray(compress: false)) .Add(TimestampKey, timestamp);