Skip to content

Commit

Permalink
Merge pull request #2953 from eugene-doobu/feature/optimization-get-a…
Browse files Browse the repository at this point in the history
…vatar-state

Feature/optimization get avatar state
  • Loading branch information
eugene-doobu authored Nov 1, 2024
2 parents 448d741 + efe0efc commit b8b8a4d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Lib9c/Action/AdventureBoss/SweepAdventureBoss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public override IWorld Execute(IActionContext context)
);
}

var avatarState = states.GetAvatarState(AvatarAddress);
var avatarState = states.GetAvatarState(AvatarAddress, true, false, false);
if (avatarState is null || !avatarState.agentAddress.Equals(context.Signer))
{
throw new FailedLoadStateException($"{addressesHex}Aborted as the avatar state of the signer was failed to load.");
Expand Down
2 changes: 1 addition & 1 deletion Lib9c/Action/AdventureBoss/UnlockFloor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public override IWorld Execute(IActionContext context)

// Check balance and unlock
var price = costSheet[floorId];
var avatarState = states.GetAvatarState(AvatarAddress);
var avatarState = states.GetAvatarState(AvatarAddress, true, false, false);
if (avatarState is null || !avatarState.agentAddress.Equals(context.Signer))
{
var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress);
Expand Down
2 changes: 1 addition & 1 deletion Lib9c/Action/AdventureBoss/Wanted.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public override IWorld Execute(IActionContext context)

var requiredStakingAmount = stakeRegularRewardSheet[requiredStakingLevel].RequiredGold;

var avatarState = states.GetAvatarState(AvatarAddress);
var avatarState = states.GetAvatarState(AvatarAddress, false, false, false);
if (avatarState is null || !avatarState.agentAddress.Equals(context.Signer))
{
var addressesHex = GetSignerAndOtherAddressesHex(context, AvatarAddress);
Expand Down
3 changes: 2 additions & 1 deletion Lib9c/Action/CreateAvatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ private AgentState GetAgentState(IWorld states, Address signer, Address avatarAd
{
var existingAgentState = states.GetAgentState(signer);
var agentState = existingAgentState ?? new AgentState(signer);
var avatarState = states.GetAvatarState(avatarAddress);
// check has avatar in avatarAddress, see InvalidAddressException in this method
var avatarState = states.GetAvatarState(avatarAddress, false, false, false);
if (avatarState is not null)
{
throw new InvalidAddressException(
Expand Down

0 comments on commit b8b8a4d

Please sign in to comment.