Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Removed boolean parameters from SetAvatarState() #2398

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .Lib9c.DevExtensions.Tests/Action/FaucetRuneTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public FaucetRuneTest(ITestOutputHelper outputHelper)

_initialState = _initialState
.SetAgentState(agentAddress, agentState)
.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, avatarState);
}

[Theory]
Expand Down
9 changes: 4 additions & 5 deletions .Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public void TryGetAvatarStateInvalidCastException()
[Fact]
public void TryGetAvatarStateInvalidAddress()
{
var states = new World(new MockWorldState()).SetAvatarState(
default, _avatarState, true, true, true, true);
var states = new World(new MockWorldState()).SetAvatarState(default, _avatarState);

Assert.False(states.TryGetAvatarState(Addresses.GameConfig, _avatarAddress, out _));
}
Expand All @@ -97,7 +96,7 @@ public void GetAvatarStateV2()
{
IWorld states = new World(new MockWorldState());
states = states
.SetAvatarState(_avatarAddress, _avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, _avatarState);

var v2 = states.GetAvatarState(_avatarAddress);
Assert.NotNull(v2.inventory);
Expand All @@ -121,7 +120,7 @@ public void GetAvatarStateV2_Throw_FailedLoadStateException(string account)

IWorld states = new World(new MockWorldState());
states = states
.SetAvatarState(_avatarAddress, _avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, _avatarState);
states = states.SetAccount(
accountAddress,
states.GetAccount(accountAddress).SetNull(_avatarAddress));
Expand All @@ -143,7 +142,7 @@ public void TryGetAvatarState(bool backward)
else
{
states = states
.SetAvatarState(_avatarAddress, _avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, _avatarState);
}

Assert.True(states.TryGetAvatarState(_agentAddress, _avatarAddress, out _));
Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.Tests/Action/ArenahelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ArenaHelperTest(ITestOutputHelper outputHelper)
_state = _state
.SetLegacyState(Addresses.GoldCurrency, goldCurrencyState.Serialize())
.SetAgentState(_agent1Address, agent1State)
.SetAvatarState(_avatar1Address, _avatar1, true, true, true, true)
.SetAvatarState(_avatar1Address, _avatar1)
.SetLegacyState(Addresses.GameConfig, new GameConfigState(sheets[nameof(GameConfigSheet)]).Serialize());

Log.Logger = new LoggerConfiguration()
Expand Down
8 changes: 4 additions & 4 deletions .Lib9c.Tests/Action/BattleArenaTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ public BattleArenaTest(ITestOutputHelper outputHelper)
_initialStates = _initialStates
.SetLegacyState(Addresses.GoldCurrency, goldCurrencyState.Serialize())
.SetAgentState(_agent1Address, agent1State)
.SetAvatarState(_avatar1Address, avatar1State, true, true, true, true)
.SetAvatarState(_avatar1Address, avatar1State)
.SetAgentState(_agent2Address, agent2State)
.SetAvatarState(_avatar2Address, avatar2State, true, true, true, true)
.SetAvatarState(_avatar2Address, avatar2State)
.SetAgentState(_agent3Address, agent3State)
.SetAvatarState(_avatar3Address, avatar3State, true, true, true, true)
.SetAvatarState(_avatar3Address, avatar3State)
.SetAgentState(_agent4Address, agent4State)
.SetAvatarState(_avatar4Address, avatar4State, true, true, true, true)
.SetAvatarState(_avatar4Address, avatar4State)
.SetLegacyState(
Addresses.GameConfig,
new GameConfigState(_sheets[nameof(GameConfigSheet)]).Serialize());
Expand Down
8 changes: 4 additions & 4 deletions .Lib9c.Tests/Action/Buy7Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ out _
purchaseInfos.Add(purchaseInfo);

_initialState = _initialState
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState, true, true, true, true)
.SetAvatarState(sellerAvatarState.address, sellerAvatarState, true, true, true, true)
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState)
.SetAvatarState(sellerAvatarState.address, sellerAvatarState)
.SetLegacyState(shardedShopAddress, shopState.Serialize())
.SetLegacyState(Addresses.Shop, legacyShopState.Serialize());
}
Expand Down Expand Up @@ -462,7 +462,7 @@ public void Execute_Throw_NotEnoughClearedStageLevel()
0
),
};
_initialState = _initialState.SetAvatarState(_buyerAvatarAddress, avatarState, true, true, true, true);
_initialState = _initialState.SetAvatarState(_buyerAvatarAddress, avatarState);

PurchaseInfo0 purchaseInfo0 = new PurchaseInfo0(
default,
Expand Down Expand Up @@ -904,7 +904,7 @@ public void Execute_ErrorCode_InvalidPrice(int shopPrice, int price)

_initialState = _initialState
.SetAgentState(agentAddress, agentState)
.SetAvatarState(avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(avatarAddress, avatarState);
return (avatarState, agentState);
}

Expand Down
10 changes: 5 additions & 5 deletions .Lib9c.Tests/Action/BuyMultipleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public BuyMultipleTest(ITestOutputHelper outputHelper)
.SetLegacyState(GoldCurrencyState.Address, _goldCurrencyState.Serialize())
.SetLegacyState(Addresses.Shop, shopState.Serialize())
.SetAgentState(_buyerAgentAddress, buyerAgentState)
.SetAvatarState(_buyerAvatarAddress, _buyerAvatarState, true, true, true, true)
.SetAvatarState(_buyerAvatarAddress, _buyerAvatarState)
.MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100);
}

Expand Down Expand Up @@ -294,7 +294,7 @@ public void Execute(params ShopItemData[] productDatas)
Assert.Equal(3, shopState.Products.Count);

_initialState = _initialState
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState, true, true, true, true)
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState)
.SetLegacyState(Addresses.Shop, shopState.Serialize());

var priceData = new PriceData(goldCurrency);
Expand All @@ -305,7 +305,7 @@ public void Execute(params ShopItemData[] productDatas)
priceData.TaxedPriceSum[agentState.address] = new FungibleAssetValue(goldCurrency, 0, 0);

_initialState = _initialState
.SetAvatarState(avatarState.address, avatarState, true, true, true, true);
.SetAvatarState(avatarState.address, avatarState);
}

IWorld previousStates = _initialState;
Expand Down Expand Up @@ -444,7 +444,7 @@ public void ExecuteThrowNotEnoughClearedStageLevelException()
0
),
};
_initialState = _initialState.SetAvatarState(_buyerAvatarAddress, avatarState, true, true, true, true);
_initialState = _initialState.SetAvatarState(_buyerAvatarAddress, avatarState);

var action = new BuyMultiple
{
Expand Down Expand Up @@ -631,7 +631,7 @@ public void ExecuteThrowShopItemExpiredError()

_initialState = _initialState
.SetAgentState(agentAddress, agentState)
.SetAvatarState(avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(avatarAddress, avatarState);
return (avatarState, agentState);
}

Expand Down
6 changes: 3 additions & 3 deletions .Lib9c.Tests/Action/BuyProduct2Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ public BuyProduct2Test(ITestOutputHelper outputHelper)
_initialState = _initialState
.SetLegacyState(GoldCurrencyState.Address, _goldCurrencyState.Serialize())
.SetAgentState(SellerAgentAddress, sellerAgentState)
.SetAvatarState(SellerAvatarAddress, sellerAvatarState, true, true, true, true)
.SetAvatarState(SellerAvatarAddress, sellerAvatarState)
.SetAgentState(_sellerAgentAddress2, agentState2)
.SetAvatarState(_sellerAvatarAddress2, sellerAvatarState2, true, true, true, true)
.SetAvatarState(_sellerAvatarAddress2, sellerAvatarState2)
.SetAgentState(BuyerAgentAddress, buyerAgentState)
.SetAvatarState(BuyerAvatarAddress, _buyerAvatarState, true, true, true, true)
.SetAvatarState(BuyerAvatarAddress, _buyerAvatarState)
.MintAsset(context, BuyerAgentAddress, _goldCurrencyState.Currency * 1);
}

Expand Down
23 changes: 10 additions & 13 deletions .Lib9c.Tests/Action/BuyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public BuyTest(ITestOutputHelper outputHelper)
_initialState = _initialState
.SetLegacyState(GoldCurrencyState.Address, _goldCurrencyState.Serialize())
.SetAgentState(_sellerAgentAddress, sellerAgentState)
.SetAvatarState(_sellerAvatarAddress, sellerAvatarState, true, true, true, true)
.SetAvatarState(_sellerAvatarAddress, sellerAvatarState)
.SetAgentState(_buyerAgentAddress, buyerAgentState)
.SetAvatarState(_buyerAvatarAddress, _buyerAvatarState, true, true, true, true)
.SetAvatarState(_buyerAvatarAddress, _buyerAvatarState)
.SetLegacyState(Addresses.Shop, new ShopState().Serialize())
.MintAsset(context, _buyerAgentAddress, _goldCurrencyState.Currency * 100);
}
Expand Down Expand Up @@ -332,8 +332,8 @@ public void Execute(params OrderData[] orderDataList)

_initialState = _initialState
.SetLegacyState(Order.DeriveAddress(orderId), order.Serialize())
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState, true, true, true, true)
.SetAvatarState(sellerAvatarState.address, sellerAvatarState, true, true, true, true)
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState)
.SetAvatarState(sellerAvatarState.address, sellerAvatarState)
.SetLegacyState(shardedShopAddress, shopState.Serialize())
.SetLegacyState(orderDigestListState.Address, orderDigestListState.Serialize());
}
Expand Down Expand Up @@ -476,8 +476,7 @@ public void Execute_Throw_Exception(bool equalAvatarAddress, bool clearStage, Ty
0
),
};
_initialState = _initialState.SetAvatarState(
_buyerAvatarAddress, avatarState, true, true, true, true);
_initialState = _initialState.SetAvatarState(_buyerAvatarAddress, avatarState);
}

var avatarAddress = equalAvatarAddress ? _buyerAvatarAddress : default;
Expand Down Expand Up @@ -575,8 +574,7 @@ public void Execute_ErrorCode(ErrorCodeMember errorCodeMember)

var digest = order.Digest(sellerAvatarState, _tableSheets.CostumeStatSheet);
shopState.Add(digest, 0);
_initialState = _initialState.SetAvatarState(
sellerAvatarAddress, sellerAvatarState, true, true, true, true);
_initialState = _initialState.SetAvatarState(sellerAvatarAddress, sellerAvatarState);
}

_initialState = _initialState.SetLegacyState(Order.DeriveAddress(_orderId), order.Serialize());
Expand Down Expand Up @@ -717,8 +715,7 @@ public void Execute_ReconfigureFungibleItem(params OrderData[] orderDataList)
itemSubType,
orderData.ItemCount
);
_initialState.SetAvatarState(
orderData.SellerAvatarAddress, sellerAvatarState, false, true, false, false);
_initialState.SetAvatarState(orderData.SellerAvatarAddress, sellerAvatarState);

var sellItem = order.Sell3(sellerAvatarState);
var orderDigest = order.Digest(sellerAvatarState, _tableSheets.CostumeStatSheet);
Expand Down Expand Up @@ -757,8 +754,8 @@ public void Execute_ReconfigureFungibleItem(params OrderData[] orderDataList)

_initialState = _initialState
.SetLegacyState(Order.DeriveAddress(orderId), order.Serialize())
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState, true, true, true, true)
.SetAvatarState(sellerAvatarState.address, sellerAvatarState, true, true, true, true)
.SetAvatarState(_buyerAvatarAddress, buyerAvatarState)
.SetAvatarState(sellerAvatarState.address, sellerAvatarState)
.SetLegacyState(shardedShopAddress, shopState.Serialize())
.SetLegacyState(orderDigestListState.Address, orderDigestListState.Serialize());
}
Expand Down Expand Up @@ -985,7 +982,7 @@ public void Execute_With_Testbed()

_initialState = _initialState
.SetAgentState(agentAddress, agentState)
.SetAvatarState(avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(avatarAddress, avatarState);
return (avatarState, agentState);
}

Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.Tests/Action/CancelProductRegistration0Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public CancelProductRegistration0Test(ITestOutputHelper outputHelper)
.SetLegacyState(GoldCurrencyState.Address, _goldCurrencyState.Serialize())
.SetAgentState(_agentAddress, agentState)
.SetLegacyState(Addresses.Shop, new ShopState().Serialize())
.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, avatarState);
}

[Theory]
Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.Tests/Action/ChargeActionPoint0Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void Execute()
var state = new World(new MockWorldState())
.SetLegacyState(Addresses.GameConfig, gameConfigState.Serialize())
.SetAgentState(agentAddress, agent)
.SetAvatarState(avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(avatarAddress, avatarState);

foreach (var (key, value) in _sheets)
{
Expand Down
6 changes: 3 additions & 3 deletions .Lib9c.Tests/Action/ChargeActionPoint2Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ChargeActionPoint2Test()
_initialState = new World(new MockWorldState())
.SetLegacyState(Addresses.GameConfig, gameConfigState.Serialize())
.SetAgentState(_agentAddress, agent)
.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, avatarState);

foreach (var (key, value) in _sheets)
{
Expand Down Expand Up @@ -75,7 +75,7 @@ public void Execute(bool useTradable)

Assert.Equal(0, avatarState.actionPoint);

var state = _initialState.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
var state = _initialState.SetAvatarState(_avatarAddress, avatarState);

foreach (var (key, value) in _sheets)
{
Expand Down Expand Up @@ -134,7 +134,7 @@ public void Execute_Throw_NotEnoughMaterialException(bool useTradable)

Assert.Equal(0, avatarState.actionPoint);

var state = _initialState.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
var state = _initialState.SetAvatarState(_avatarAddress, avatarState);

var action = new ChargeActionPoint2()
{
Expand Down
8 changes: 4 additions & 4 deletions .Lib9c.Tests/Action/ChargeActionPointTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ChargeActionPointTest()
_initialState = new World(new MockWorldState())
.SetLegacyState(Addresses.GameConfig, gameConfigState.Serialize())
.SetAgentState(_agentAddress, agent)
.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, avatarState);

foreach (var (key, value) in _sheets)
{
Expand Down Expand Up @@ -78,7 +78,7 @@ public void Execute(bool useTradable)
Assert.Equal(0, avatarState.actionPoint);

IWorld state;
state = _initialState.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
state = _initialState.SetAvatarState(_avatarAddress, avatarState);

foreach (var (key, value) in _sheets)
{
Expand Down Expand Up @@ -131,13 +131,13 @@ public void Execute_Throw_Exception(bool useAvatarAddress, bool useTradable, boo
if (enough)
{
avatarState.inventory.AddItem(apStone);
state = state.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
state = state.SetAvatarState(_avatarAddress, avatarState);
}

if (charge)
{
avatarState.actionPoint = state.GetGameConfigState().ActionPointMax;
state = state.SetAvatarState(_avatarAddress, avatarState, true, true, true, true);
state = state.SetAvatarState(_avatarAddress, avatarState);
}

var action = new ChargeActionPoint()
Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.Tests/Action/ClaimItemsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ private IWorld GenerateAvatar(IWorld state, out Address avatarAddress, out Addre

state = state
.SetAgentState(agentAddress, agentState)
.SetAvatarState(avatarAddress, avatarState, true, true, true, true);
.SetAvatarState(avatarAddress, avatarState);

return state;
}
Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.Tests/Action/ClaimWorldBossKillRewardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void Execute(long blockIndex, Type exc)
.SetLegacyState(Addresses.GetSheetAddress<RuneSheet>(), tableSheets.RuneSheet.Serialize())
.SetLegacyState(Addresses.GetSheetAddress<WorldBossCharacterSheet>(), tableSheets.WorldBossCharacterSheet.Serialize())
.SetLegacyState(Addresses.GameConfig, gameConfigState.Serialize())
.SetAvatarState(avatarAddress, avatarState, true, true, true, true)
.SetAvatarState(avatarAddress, avatarState)
.SetLegacyState(worldBossKillRewardRecordAddress, worldBossKillRewardRecord.Serialize())
.SetLegacyState(worldBossAddress, worldBossState.Serialize())
.SetLegacyState(raiderStateAddress, raiderState.Serialize());
Expand Down
4 changes: 2 additions & 2 deletions .Lib9c.Tests/Action/CombinationEquipment16Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ bool previousCostStateExist
}
else
{
state = state.SetAvatarState(_avatarAddress, _avatarState, true, true, true, true);
state = state.SetAvatarState(_avatarAddress, _avatarState);
}

if (!slotUnlock)
Expand Down Expand Up @@ -390,7 +390,7 @@ public void ExecuteWithCheckingHammerPointState(
}

state = state
.SetAvatarState(_avatarAddress, _avatarState, true, true, true, true);
.SetAvatarState(_avatarAddress, _avatarState);
var hammerPointAddress =
Addresses.GetHammerPointStateAddress(_avatarAddress, recipeId);
if (doSuperCraft)
Expand Down
6 changes: 3 additions & 3 deletions .Lib9c.Tests/Action/Coupons/RedeemCouponTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public void Execute()
default);

state = state
.SetAvatarState(agent1Avatar0Address, agent1Avatar0State, true, true, true, true)
.SetAvatarState(agent1Avatar1Address, agent1Avatar1State, true, true, true, true)
.SetAvatarState(agent2Avatar0Address, agent2Avatar0State, true, true, true, true);
.SetAvatarState(agent1Avatar0Address, agent1Avatar0State)
.SetAvatarState(agent1Avatar1Address, agent1Avatar1State)
.SetAvatarState(agent2Avatar0Address, agent2Avatar0State);

// can't redeem a coupon with an arbitrary guid
Assert.Equal(
Expand Down
Loading
Loading