Skip to content

Commit

Permalink
fix: Fix build errors in lib9c
Browse files Browse the repository at this point in the history
  • Loading branch information
s2quake committed Dec 26, 2024
1 parent 7aa9b9d commit b8bf7f6
Show file tree
Hide file tree
Showing 25 changed files with 102 additions and 127 deletions.
4 changes: 2 additions & 2 deletions Lib9c/Action/Guild/ClaimGuildReward.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public override IWorld Execute(IActionContext context)
}

var repository = new ValidatorRepository(guildRepository);
var validatorDelegatee = repository.GetValidatorDelegatee(guild.ValidatorAddress);
var validatorDelegator = repository.GetValidatorDelegator(guild.Address);
var validatorDelegatee = repository.GetDelegatee(guild.ValidatorAddress);
var validatorDelegator = repository.GetDelegator(guild.Address);
validatorDelegator.ClaimReward(validatorDelegatee, context.BlockIndex);

return repository.World;
Expand Down
4 changes: 2 additions & 2 deletions Lib9c/Action/Guild/ClaimReward.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public override IWorld Execute(IActionContext context)

var guildParticipant = repository.GetGuildParticipant(context.Signer);
var guild = repository.GetGuild(guildParticipant.GuildAddress);
var guildDelegatee = repository.GetGuildDelegatee(guild.ValidatorAddress);
var guildDelegator = repository.GetGuildDelegator(context.Signer);
var guildDelegatee = repository.GetDelegatee(guild.ValidatorAddress);
var guildDelegator = repository.GetDelegator(context.Signer);
guildDelegator.ClaimReward(guildDelegatee, context.BlockIndex);

return repository.World;
Expand Down
4 changes: 2 additions & 2 deletions Lib9c/Action/InitializeStates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ public override IWorld Execute(IActionContext context)
var validatorRepository = new ValidatorRepository(states, ctx);
var validatorDelegatee = validatorRepository.CreateValidatorDelegatee(
validator.PublicKey, ValidatorDelegatee.DefaultCommissionPercentage);
var validatorDelegator = validatorRepository.GetValidatorDelegator(validator.OperatorAddress);
var validatorDelegator = validatorRepository.GetDelegator(validator.OperatorAddress);
validatorDelegatee.Bond(validatorDelegator, delegationFAV, context.BlockIndex);

var guildRepository = new GuildRepository(validatorRepository);
var guildDelegatee = guildRepository.CreateGuildDelegatee(validator.OperatorAddress);
var guildDelegator = guildRepository.GetGuildDelegator(validator.OperatorAddress);
var guildDelegator = guildRepository.GetDelegator(validator.OperatorAddress);
guildDelegator.Delegate(guildDelegatee, delegationFAV, context.BlockIndex);
states = guildRepository.World;
}
Expand Down
8 changes: 4 additions & 4 deletions Lib9c/Action/Stake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ private static IWorld ContractNewStake(
if (guildRepository.TryGetGuildParticipant(agentAddress, out var guildParticipant))
{
var guild = guildRepository.GetGuild(guildParticipant.GuildAddress);
var guildDelegatee = guildRepository.GetGuildDelegatee(guild.ValidatorAddress);
var guildDelegatee = guildRepository.GetDelegatee(guild.ValidatorAddress);
var share = guildDelegatee.ShareFromFAV(gg);

var guildDelegator = guildRepository.GetGuildDelegator(agentAddress);
var guildDelegator = guildRepository.GetDelegator(agentAddress);
guildDelegatee.Unbond(guildDelegator, share, height);

var validatorRepository = new ValidatorRepository(guildRepository);
var validatorDelegatee = validatorRepository.GetValidatorDelegatee(guild.ValidatorAddress);
var validatorDelegator = validatorRepository.GetValidatorDelegator(guild.Address);
var validatorDelegatee = validatorRepository.GetDelegatee(guild.ValidatorAddress);
var validatorDelegator = validatorRepository.GetDelegator(guild.Address);
validatorDelegatee.Unbond(validatorDelegator, share, height);

state = validatorRepository.World;
Expand Down
8 changes: 4 additions & 4 deletions Lib9c/Action/ValidatorDelegation/ClaimValidatorRewardSelf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public override IWorld Execute(IActionContext context)

var world = context.PreviousState;
var repository = new ValidatorRepository(world, context);
var validatorDelegatee = repository.GetValidatorDelegatee(context.Signer);
var validatorDelegator = repository.GetValidatorDelegator(context.Signer);
var validatorDelegatee = repository.GetDelegatee(context.Signer);
var validatorDelegator = repository.GetDelegator(context.Signer);
validatorDelegator.ClaimReward(validatorDelegatee, context.BlockIndex);

var guildRepository = new GuildRepository(repository);
var guildDelegatee = guildRepository.GetGuildDelegatee(context.Signer);
var guildDelegator = guildRepository.GetGuildDelegator(context.Signer);
var guildDelegatee = guildRepository.GetDelegatee(context.Signer);
var guildDelegator = guildRepository.GetDelegator(context.Signer);
guildDelegator.ClaimReward(guildDelegatee, context.BlockIndex);

return guildRepository.World;
Expand Down
8 changes: 4 additions & 4 deletions Lib9c/Action/ValidatorDelegation/DelegateValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public override IWorld Execute(IActionContext context)
}

var guildRepository = new GuildRepository(context.PreviousState, context);
var guildDelegatee = guildRepository.GetGuildDelegatee(context.Signer);
var guildDelegator = guildRepository.GetGuildDelegator(context.Signer);
var guildDelegatee = guildRepository.GetDelegatee(context.Signer);
var guildDelegator = guildRepository.GetDelegator(context.Signer);
guildDelegator.Delegate(guildDelegatee, FAV, context.BlockIndex);

var validatorRepository = new ValidatorRepository(guildRepository);
var validatorDelegatee = validatorRepository.GetValidatorDelegatee(context.Signer);
var validatorDelegator = validatorRepository.GetValidatorDelegator(context.Signer);
var validatorDelegatee = validatorRepository.GetDelegatee(context.Signer);
var validatorDelegator = validatorRepository.GetDelegator(context.Signer);
validatorDelegatee.Bond(validatorDelegator, FAV, context.BlockIndex);

return validatorRepository.World;
Expand Down
4 changes: 2 additions & 2 deletions Lib9c/Action/ValidatorDelegation/PromoteValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ public IWorld ExecutePublic(IActionContext context)

var repository = new ValidatorRepository(world, context);
var validatorDelegatee = repository.CreateValidatorDelegatee(PublicKey, CommissionPercentage);
var validatorDelegator = repository.GetValidatorDelegator(context.Signer);
var validatorDelegator = repository.GetDelegator(context.Signer);
validatorDelegatee.Bond(validatorDelegator, FAV, context.BlockIndex);

var guildRepository = new GuildRepository(repository);
var guildDelegatee = guildRepository.CreateGuildDelegatee(context.Signer);
var guildDelegator = guildRepository.GetGuildDelegator(context.Signer);
var guildDelegator = guildRepository.GetDelegator(context.Signer);
guildDelegator.Delegate(guildDelegatee, FAV, context.BlockIndex);

return guildRepository.World;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private static bool IsValidator(IWorld world, IActionContext context, Address ad
var repository = new ValidatorRepository(world, context);
try
{
repository.GetValidatorDelegatee(address);
repository.GetDelegatee(address);
return true;
}
catch (FailedLoadStateException)
Expand Down
8 changes: 4 additions & 4 deletions Lib9c/Action/ValidatorDelegation/SlashValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override IWorld Execute(IActionContext context)

foreach (var abstain in abstainsToSlash)
{
var validatorDelegatee = repository.GetValidatorDelegatee(abstain.Address);
var validatorDelegatee = repository.GetDelegatee(abstain.Address);
if (validatorDelegatee.Jailed)
{
continue;
Expand All @@ -61,7 +61,7 @@ public override IWorld Execute(IActionContext context)
validatorDelegatee.Jail(context.BlockIndex + AbstainJailTime);

var guildRepository = new GuildRepository(repository.World, repository.ActionContext);
var guildDelegatee = guildRepository.GetGuildDelegatee(abstain.Address);
var guildDelegatee = guildRepository.GetDelegatee(abstain.Address);
guildDelegatee.Slash(LivenessSlashFactor, context.BlockIndex, context.BlockIndex);
repository.UpdateWorld(guildRepository.World);
}
Expand All @@ -76,12 +76,12 @@ public override IWorld Execute(IActionContext context)
throw new Exception("Evidence height is greater than block index.");
}

var validatorDelegatee = repository.GetValidatorDelegatee(e.TargetAddress);
var validatorDelegatee = repository.GetDelegatee(e.TargetAddress);
validatorDelegatee.Slash(DuplicateVoteSlashFactor, e.Height, context.BlockIndex);
validatorDelegatee.Tombstone();

var guildRepository = new GuildRepository(repository.World, repository.ActionContext);
var guildDelegatee = guildRepository.GetGuildDelegatee(e.TargetAddress);
var guildDelegatee = guildRepository.GetDelegatee(e.TargetAddress);
guildDelegatee.Slash(DuplicateVoteSlashFactor, e.Height, context.BlockIndex);
repository.UpdateWorld(guildRepository.World);
break;
Expand Down
8 changes: 4 additions & 4 deletions Lib9c/Action/ValidatorDelegation/UndelegateValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public override IWorld Execute(IActionContext context)
}

var guildRepository = new GuildRepository(context.PreviousState, context);
var guildDelegatee = guildRepository.GetGuildDelegatee(context.Signer);
var guildDelegator = guildRepository.GetGuildDelegator(context.Signer);
var guildDelegatee = guildRepository.GetDelegatee(context.Signer);
var guildDelegator = guildRepository.GetDelegator(context.Signer);
guildDelegator.Undelegate(guildDelegatee, Share, context.BlockIndex);

var validatorRepository = new ValidatorRepository(guildRepository);
var validatorDelegatee = validatorRepository.GetValidatorDelegatee(context.Signer);
var validatorDelegator = validatorRepository.GetValidatorDelegator(context.Signer);
var validatorDelegatee = validatorRepository.GetDelegatee(context.Signer);
var validatorDelegator = validatorRepository.GetDelegator(context.Signer);
validatorDelegatee.Unbond(validatorDelegator, Share, context.BlockIndex);

return validatorRepository.World;
Expand Down
2 changes: 1 addition & 1 deletion Lib9c/Action/ValidatorDelegation/UnjailValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override IWorld Execute(IActionContext context)

var world = context.PreviousState;
var repository = new ValidatorRepository(world, context);
var delegatee = repository.GetValidatorDelegatee(context.Signer);
var delegatee = repository.GetDelegatee(context.Signer);
delegatee.Unjail(context.BlockIndex);

return repository.World;
Expand Down
16 changes: 8 additions & 8 deletions Lib9c/Action/ValidatorDelegation/UpdateValidators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ public override IWorld Execute(IActionContext context)
foreach (var deactivated in prevValidators.Select(v => v.OperatorAddress)
.Except(validators.Select(v => v.OperatorAddress)))
{
var validatorDelegatee = repository.GetValidatorDelegatee(deactivated);
var validatorDelegatee = repository.GetDelegatee(deactivated);
validatorDelegatee.Deactivate();
repository.SetValidatorDelegatee(validatorDelegatee);
repository.SetDelegatee(validatorDelegatee);
var guildRepository = new GuildRepository(repository.World, repository.ActionContext);
var guildDelegatee = guildRepository.GetGuildDelegatee(deactivated);
var guildDelegatee = guildRepository.GetDelegatee(deactivated);
guildDelegatee.Deactivate();
guildRepository.SetGuildDelgatee(guildDelegatee);
guildRepository.SetDelegatee(guildDelegatee);
repository.UpdateWorld(guildRepository.World);
}

foreach (var activated in validators.Select(v => v.OperatorAddress)
.Except(prevValidators.Select(v => v.OperatorAddress)))
{
var validatorDelegatee = repository.GetValidatorDelegatee(activated);
var validatorDelegatee = repository.GetDelegatee(activated);
validatorDelegatee.Activate();
repository.SetValidatorDelegatee(validatorDelegatee);
repository.SetDelegatee(validatorDelegatee);
var guildRepository = new GuildRepository(repository.World, repository.ActionContext);
var guildDelegatee = guildRepository.GetGuildDelegatee(activated);
var guildDelegatee = guildRepository.GetDelegatee(activated);
guildDelegatee.Activate();
guildRepository.SetGuildDelgatee(guildDelegatee);
guildRepository.SetDelegatee(guildDelegatee);
repository.UpdateWorld(guildRepository.World);
}

Expand Down
8 changes: 4 additions & 4 deletions Lib9c/Model/Guild/Guild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public Guild(

public void ClaimReward(Address validatorAddress, long height)
{
var guildDelegatee = Repository.GetGuildDelegatee(validatorAddress);
var guildDelegator = Repository.GetGuildDelegator(Address);
var guildDelegatee = Repository.GetDelegatee(validatorAddress);
var guildDelegator = Repository.GetDelegator(Address);
guildDelegator.ClaimReward(guildDelegatee, height);

var validatorRepository = new ValidatorRepository(Repository);
var validatorDelegatee = validatorRepository.GetValidatorDelegatee(validatorAddress);
var validatorDelegator = validatorRepository.GetValidatorDelegator(Address);
var validatorDelegatee = validatorRepository.GetDelegatee(validatorAddress);
var validatorDelegator = validatorRepository.GetDelegator(Address);
validatorDelegator.ClaimReward(validatorDelegatee, height);

Repository.UpdateWorld(validatorRepository.World);
Expand Down
2 changes: 1 addition & 1 deletion Lib9c/Model/Guild/GuildDelegatee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Nekoyume.Model.Guild
{
public class GuildDelegatee
: Delegatee<GuildDelegator, GuildDelegatee>, IEquatable<GuildDelegatee>
: Delegatee<GuildRepository, GuildDelegatee, GuildDelegator>, IEquatable<GuildDelegatee>
{
public GuildDelegatee(
Address address,
Expand Down
2 changes: 1 addition & 1 deletion Lib9c/Model/Guild/GuildDelegator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Nekoyume.Model.Guild
{
public class GuildDelegator
: Delegator<GuildDelegatee, GuildDelegator>, IEquatable<GuildDelegator>
: Delegator<GuildRepository, GuildDelegatee, GuildDelegator>, IEquatable<GuildDelegator>
{
public GuildDelegator(
Address address,
Expand Down
38 changes: 19 additions & 19 deletions Lib9c/Model/Guild/GuildParticipant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public GuildParticipant(
public AgentAddress Address { get; }

public Address DelegationPoolAddress
=> Repository.GetGuildDelegator(Address).DelegationPoolAddress;
=> Repository.GetDelegator(Address).DelegationPoolAddress;

public Address RewardAddress
=> Repository.GetGuildDelegator(Address).RewardAddress;
=> Repository.GetDelegator(Address).RewardAddress;

public GuildRepository Repository { get; }

Expand All @@ -85,13 +85,13 @@ public void Delegate(Guild guild, FungibleAssetValue fav, long height)
nameof(fav), fav, "Fungible asset value must be positive.");
}

var guildDelegatee = Repository.GetGuildDelegatee(guild.ValidatorAddress);
var guildDelegator = Repository.GetGuildDelegator(Address);
var guildDelegatee = Repository.GetDelegatee(guild.ValidatorAddress);
var guildDelegator = Repository.GetDelegator(Address);
guildDelegator.Delegate(guildDelegatee, fav, height);

var validatorRepository = new ValidatorRepository(Repository);
var validatorDelegatee = validatorRepository.GetValidatorDelegatee(guild.ValidatorAddress);
var validatorDelegator = validatorRepository.GetValidatorDelegator(guild.Address);
var validatorDelegatee = validatorRepository.GetDelegatee(guild.ValidatorAddress);
var validatorDelegator = validatorRepository.GetDelegator(guild.Address);
validatorDelegatee.Bond(validatorDelegator, fav, height);

Repository.UpdateWorld(validatorRepository.World);
Expand All @@ -111,13 +111,13 @@ public void Undelegate(Guild guild, BigInteger share, long height)
nameof(height), height, "Height must be positive.");
}

var guildDelegatee = Repository.GetGuildDelegatee(guild.ValidatorAddress);
var guildDelegator = Repository.GetGuildDelegator(Address);
var guildDelegatee = Repository.GetDelegatee(guild.ValidatorAddress);
var guildDelegator = Repository.GetDelegator(Address);
guildDelegator.Undelegate(guildDelegatee, share, height);

var validatorRepository = new ValidatorRepository(Repository);
var validatorDelegatee = validatorRepository.GetValidatorDelegatee(guild.ValidatorAddress);
var validatorDelegator = validatorRepository.GetValidatorDelegator(guild.Address);
var validatorDelegatee = validatorRepository.GetDelegatee(guild.ValidatorAddress);
var validatorDelegator = validatorRepository.GetDelegator(guild.Address);
validatorDelegatee.Unbond(validatorDelegator, share, height);

Repository.UpdateWorld(validatorRepository.World);
Expand All @@ -138,26 +138,26 @@ public void Redelegate(
nameof(height), height, "Height must be positive.");
}

var srcGuildDelegatee = Repository.GetGuildDelegatee(srcGuild.ValidatorAddress);
var dstGuildDelegator = Repository.GetGuildDelegatee(dstGuild.ValidatorAddress);
var guildDelegator = Repository.GetGuildDelegator(Address);
var srcGuildDelegatee = Repository.GetDelegatee(srcGuild.ValidatorAddress);
var dstGuildDelegator = Repository.GetDelegatee(dstGuild.ValidatorAddress);
var guildDelegator = Repository.GetDelegator(Address);
guildDelegator.Redelegate(srcGuildDelegatee, dstGuildDelegator, share, height);

var validatorRepository = new ValidatorRepository(Repository);
var srcValidatorDelegatee = validatorRepository.GetValidatorDelegatee(srcGuild.ValidatorAddress);
var srcValidatorDelegator = validatorRepository.GetValidatorDelegator(srcGuild.Address);
var srcValidatorDelegatee = validatorRepository.GetDelegatee(srcGuild.ValidatorAddress);
var srcValidatorDelegator = validatorRepository.GetDelegator(srcGuild.Address);
var fav = srcValidatorDelegatee.Unbond(srcValidatorDelegator, share, height);
var dstValidatorDelegatee = validatorRepository.GetValidatorDelegatee(dstGuild.ValidatorAddress);
var dstValidatorDelegator = validatorRepository.GetValidatorDelegator(dstGuild.Address);
var dstValidatorDelegatee = validatorRepository.GetDelegatee(dstGuild.ValidatorAddress);
var dstValidatorDelegator = validatorRepository.GetDelegator(dstGuild.Address);
dstValidatorDelegatee.Bond(dstValidatorDelegator, fav, height);

Repository.UpdateWorld(validatorRepository.World);
}

public void ClaimReward(Guild guild, long height)
{
var guildDelegatee = Repository.GetGuildDelegatee(guild.ValidatorAddress);
var guildDelegator = Repository.GetGuildDelegator(Address);
var guildDelegatee = Repository.GetDelegatee(guild.ValidatorAddress);
var guildDelegator = Repository.GetDelegator(Address);
guildDelegator.ClaimReward(guildDelegatee, height);
}

Expand Down
Loading

0 comments on commit b8bf7f6

Please sign in to comment.