Skip to content

Commit

Permalink
Merge pull request #3124 from planetarium/fix/moving-guild
Browse files Browse the repository at this point in the history
Fix as issure where agent cannot move to other guild
  • Loading branch information
OnedgeLee authored Jan 8, 2025
2 parents 227549a + 014abf9 commit f4f1a92
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .Lib9c.Tests/Action/Guild/MoveGuildTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void Execute()
var guildAddress2 = AddressUtil.CreateGuildAddress();
world = EnsureToCreateValidator(world, validatorKey1.PublicKey);
world = EnsureToCreateValidator(world, validatorKey2.PublicKey);
world = EnsureToPrepareGuildGold(world, guildMasterAddress1, GG * 100);
world = EnsureToMakeGuild(world, guildAddress1, guildMasterAddress1, validatorKey1.Address);
world = EnsureToMakeGuild(world, guildAddress2, guildMasterAddress2, validatorKey2.Address);
world = EnsureToPrepareGuildGold(world, agentAddress, GG * 100);
Expand All @@ -62,8 +63,8 @@ public void Execute()
var guildParticipant = guildRepository.GetGuildParticipant(agentAddress);

Assert.Equal(guildAddress2, guildParticipant.GuildAddress);
Assert.Equal(0, guildDelegatee1.TotalShares);
Assert.Equal(0, validatorDelegatee1.TotalShares);
Assert.Equal(100 * SharePerGG, guildDelegatee1.TotalShares);
Assert.Equal(100 * SharePerGG, validatorDelegatee1.TotalShares);
Assert.Equal(100 * SharePerGG, guildDelegatee2.TotalShares);
Assert.Equal(100 * SharePerGG, validatorDelegatee2.TotalShares);
}
Expand Down
4 changes: 2 additions & 2 deletions Lib9c/Module/Guild/GuildParticipantModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ public static GuildRepository MoveGuild(
var guildParticipant1 = repository.GetGuildParticipant(guildParticipantAddress);
var srcGuild = repository.GetGuild(guildParticipant1.GuildAddress);
var dstGuild = repository.GetGuild(dstGuildAddress);
var srcGuildDelegatee = repository.GetDelegatee(srcGuild.ValidatorAddress);
var validatorRepository = new ValidatorRepository(repository.World, repository.ActionContext);
var srcValidatorDelegatee = validatorRepository.GetDelegatee(srcGuild.ValidatorAddress);
var dstValidatorDelegatee = validatorRepository.GetDelegatee(dstGuild.ValidatorAddress);
if (dstValidatorDelegatee.Tombstoned)
{
throw new InvalidOperationException("The validator of the guild to move to has been tombstoned.");
}

var guildParticipant2 = new GuildParticipant(guildParticipantAddress, dstGuildAddress, repository);
var bond = validatorRepository.GetBond(srcValidatorDelegatee, srcGuild.Address);
var bond = repository.GetBond(srcGuildDelegatee, guildParticipantAddress);
var share = bond.Share;
repository.RemoveGuildParticipant(guildParticipantAddress);
repository.DecreaseGuildMemberCount(guildParticipant1.GuildAddress);
Expand Down

0 comments on commit f4f1a92

Please sign in to comment.