Skip to content

Commit

Permalink
Replace ToAddress() with Address
Browse files Browse the repository at this point in the history
  • Loading branch information
greymistcube committed Nov 29, 2023
1 parent 3adedad commit 7c86dc0
Show file tree
Hide file tree
Showing 31 changed files with 130 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public IReadOnlyList<ICommittedActionEvaluation> Evaluate(IPreEvaluationBlock bl
default,
0,
0,
false,
default,
0,
false),
Expand All @@ -97,7 +96,6 @@ public IReadOnlyList<ICommittedActionEvaluation> Evaluate(IPreEvaluationBlock bl
default,
0,
0,
false,
default,
0,
false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions NineChronicles.Headless.Executable/Commands/GenesisCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ out List<GoldDistribution> initialDepositList
{
new()
{
Address = initialMinter.ToAddress(),
Address = initialMinter.Address,
AmountPerBlock = DefaultCurrencyValue,
StartBlock = 0,
EndBlock = 0,
Expand Down Expand Up @@ -88,7 +88,7 @@ out List<GoldDistribution> initialDepositList
$"Give initial {DefaultCurrencyValue} currency to InitialMinter");
initialDepositList.Add(new GoldDistribution
{
Address = initialMinter.ToAddress(),
Address = initialMinter.Address,
AmountPerBlock = DefaultCurrencyValue,
StartBlock = 0,
EndBlock = 0
Expand All @@ -101,7 +101,7 @@ out List<GoldDistribution> 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
}

Expand Down Expand Up @@ -130,7 +130,7 @@ out List<ActionBase> 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
{
Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion NineChronicles.Headless.Executable/Commands/KeyCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions NineChronicles.Headless.Tests/Common/Fixtures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MonsterCollectionStatus>(), new ReplaySubject<MonsterCollectionState>(), new ReplaySubject<string>());
Expand Down
Loading

0 comments on commit 7c86dc0

Please sign in to comment.