-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add features for guild migration
- Loading branch information
Showing
14 changed files
with
425 additions
and
389 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
192 changes: 0 additions & 192 deletions
192
.Lib9c.Tests/Action/Guild/Migration/MigratePledgeToGuildTest.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Nekoyume.Action.Guild.Migration | ||
{ | ||
// TODO: [GuildMigration] Remove this class when the migration is done. | ||
public static class GuildMigrationConfig | ||
{ | ||
public static readonly long MigrateDelegationHeight = 55555L; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using Bencodex; | ||
using Bencodex.Types; | ||
using Nekoyume.TypedAddress; | ||
|
||
namespace Nekoyume.Action.Guild.Migration.LegacyModels | ||
{ | ||
// TODO: [GuildMigration] Remove this class when the migration is done. | ||
public class LegacyGuild : IEquatable<LegacyGuild>, IBencodable | ||
{ | ||
private const string StateTypeName = "guild"; | ||
private const long StateVersion = 1; | ||
|
||
public readonly AgentAddress GuildMasterAddress; | ||
|
||
public LegacyGuild(AgentAddress guildMasterAddress) | ||
{ | ||
GuildMasterAddress = guildMasterAddress; | ||
} | ||
|
||
public LegacyGuild(List list) : this(new AgentAddress(list[2])) | ||
{ | ||
if (list[0] is not Text text || text != StateTypeName || list[1] is not Integer integer) | ||
{ | ||
throw new InvalidCastException(); | ||
} | ||
|
||
if (integer > StateVersion) | ||
{ | ||
throw new FailedLoadStateException("Un-deserializable state."); | ||
} | ||
} | ||
|
||
public List Bencoded => List.Empty | ||
.Add(StateTypeName) | ||
.Add(StateVersion) | ||
.Add(GuildMasterAddress.Bencoded); | ||
|
||
IValue IBencodable.Bencoded => Bencoded; | ||
|
||
public bool Equals(LegacyGuild other) | ||
{ | ||
if (ReferenceEquals(null, other)) return false; | ||
if (ReferenceEquals(this, other)) return true; | ||
return GuildMasterAddress.Equals(other.GuildMasterAddress); | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) return false; | ||
if (ReferenceEquals(this, obj)) return true; | ||
if (obj.GetType() != GetType()) return false; | ||
return Equals((LegacyGuild)obj); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return GuildMasterAddress.GetHashCode(); | ||
} | ||
} | ||
} |
Oops, something went wrong.