Skip to content

Commit

Permalink
Merge pull request #2491 from planetarium/hotfix/duplicate-collection
Browse files Browse the repository at this point in the history
Validate collection id already activated
  • Loading branch information
ipdae authored Mar 26, 2024
2 parents 0a369cb + b283b6f commit 2f676d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .Lib9c.Tests/Action/ActivateCollectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ public void Execute()

var nextAvatarState = nextState.GetAvatarState(_avatarAddress);
Assert.Empty(nextAvatarState.inventory.Items);

Assert.Throws<AlreadyActivatedException>(() => activateCollection.Execute(new ActionContext
{
PreviousState = nextState,
Signer = _agentAddress,
}));
}
}
}
4 changes: 4 additions & 0 deletions Lib9c/Action/ActivateCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public override IWorld Execute(IActionContext context)
var itemSheet = sheets.GetItemSheet();
foreach (var (collectionId, collectionMaterials) in CollectionData)
{
if (collectionState.Ids.Contains(collectionId))
{
throw new AlreadyActivatedException($"{collectionId} already activated.");
}
var row = collectionSheet[collectionId];
foreach (var requiredMaterial in row.Materials)
{
Expand Down

0 comments on commit 2f676d7

Please sign in to comment.