Skip to content

Commit

Permalink
Merge pull request #2471 from planetarium/20240510-bump-lib9c
Browse files Browse the repository at this point in the history
Delete agent, avatar legacy account backward compatible code
  • Loading branch information
ipdae authored May 10, 2024
2 parents a2c3811 + e2cdc1c commit e575125
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Lib9c
Submodule Lib9c updated 79 files
+1 −1 .Lib9c.DevExtensions.Tests/Action/Craft/UnlocakCraftActionTest.cs
+1 −1 .Lib9c.DevExtensions.Tests/Action/Craft/UnlockRecipeTest.cs
+6 −6 .Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs
+1 −1 .Lib9c.DevExtensions.Tests/Action/Stage/ClearStageTest.cs
+3 −16 .Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs
+0 −5 .Lib9c.Tests/Action/ActionEvaluationTest.cs
+0 −930 .Lib9c.Tests/Action/Buy7Test.cs
+4 −4 .Lib9c.Tests/Action/ClaimItemsTest.cs
+166 −199 .Lib9c.Tests/Action/ClaimStakeRewardTest.cs
+15 −27 .Lib9c.Tests/Action/CombinationEquipmentTest.cs
+3 −3 .Lib9c.Tests/Action/Garages/BulkUnloadFromGaragesTest.cs
+0 −1 .Lib9c.Tests/Action/Garages/DeliverToOthersGaragesTest.cs
+0 −1 .Lib9c.Tests/Action/Garages/LoadIntoMyGaragesTest.cs
+0 −1 .Lib9c.Tests/Action/Garages/UnloadFromMyGaragesTest.cs
+0 −190 .Lib9c.Tests/Action/MigrateAgentAvatarTest.cs
+0 −61 .Lib9c.Tests/Action/MigrationAvatarStateTest.cs
+3 −3 .Lib9c.Tests/Action/MintAssetsTest.cs
+0 −86 .Lib9c.Tests/Action/PetEnhancement0Test.cs
+1 −1 .Lib9c.Tests/Action/ReRegisterProductTest.cs
+4 −14 .Lib9c.Tests/Action/RedeemCodeTest.cs
+4 −10 .Lib9c.Tests/Action/Scenario/ItemCraftTest.cs
+1 −2 .Lib9c.Tests/Action/Scenario/Pet/AdditionalOptionRateByFixedValueTest.cs
+1 −2 .Lib9c.Tests/Action/Scenario/Pet/CommonTest.cs
+0 −1 .Lib9c.Tests/Action/Scenario/Pet/DiscountMaterialCostCrystalTest.cs
+1 −4 .Lib9c.Tests/Action/Scenario/Pet/IncreaseBlockPerHourglassTest.cs
+1 −2 .Lib9c.Tests/Action/Scenario/Pet/ReduceRequiredBlockTest.cs
+1 −1 .Lib9c.Tests/Action/Scenario/StakeAndClaimScenarioTest.cs
+0 −707 .Lib9c.Tests/Action/SellCancellationTest.cs
+0 −456 .Lib9c.Tests/Action/SellTest.cs
+0 −1 .Lib9c.Tests/Action/StakeTest.cs
+13 −25 .Lib9c.Tests/Action/UnlockEquipmentRecipeTest.cs
+0 −406 .Lib9c.Tests/Action/UpdateSellTest.cs
+4 −18 .Lib9c.Tests/Util/InitializeUtil.cs
+2 −6 .Lib9c.Tests/Util/QuestUtil.cs
+73 −0 .Lib9c.Tools/SubCommand/Action.cs
+0 −28 .Lib9c.Tools/SubCommand/Tx.cs
+2 −1 .gitallowed
+20 −0 .github/workflows/main.yml
+24 −0 .github/workflows/publish.yml
+5 −0 @planetarium/.editorconfig
+2 −0 @planetarium/.gitignore
+90 −0 @planetarium/lib9c/CONTRIBUTING.md
+661 −0 @planetarium/lib9c/LICENSE
+5 −0 @planetarium/lib9c/README.md
+29 −0 @planetarium/lib9c/biome.json
+12 −0 @planetarium/lib9c/cli/main.ts
+15 −0 @planetarium/lib9c/jsr.json
+34 −0 @planetarium/lib9c/package.json
+51 −0 @planetarium/lib9c/src/actions/claim_items.ts
+25 −0 @planetarium/lib9c/src/actions/claim_stake_reward.ts
+76 −0 @planetarium/lib9c/src/actions/common.ts
+63 −0 @planetarium/lib9c/src/actions/deliver_to_others_garages.ts
+66 −0 @planetarium/lib9c/src/actions/load_into_my_garages.ts
+24 −0 @planetarium/lib9c/src/actions/stake.ts
+56 −0 @planetarium/lib9c/src/actions/transfer_asset.ts
+55 −0 @planetarium/lib9c/src/actions/transfer_assets.ts
+24 −0 @planetarium/lib9c/src/index.ts
+65 −0 @planetarium/lib9c/src/models/currencies.ts
+36 −0 @planetarium/lib9c/src/models/hashdigest.ts
+11 −0 @planetarium/lib9c/src/models/networks.ts
+50 −0 @planetarium/lib9c/tests/actions/claim_items.test.ts
+23 −0 @planetarium/lib9c/tests/actions/claim_stake_reward.test.ts
+60 −0 @planetarium/lib9c/tests/actions/common.ts
+80 −0 @planetarium/lib9c/tests/actions/deliver_to_others_garages.test.ts
+15 −0 @planetarium/lib9c/tests/actions/fixtures.ts
+76 −0 @planetarium/lib9c/tests/actions/load_into_my_garages.test.ts
+11 −0 @planetarium/lib9c/tests/actions/stake.test.ts
+25 −0 @planetarium/lib9c/tests/actions/transfer_asset.test.ts
+47 −0 @planetarium/lib9c/tests/actions/transfer_assets.test.ts
+114 −0 @planetarium/lib9c/tsconfig.json
+7 −0 @planetarium/lib9c/tsup.config.ts
+7 −0 @planetarium/lib9c/vite.config.ts
+2,236 −0 @planetarium/pnpm-lock.yaml
+2 −0 @planetarium/pnpm-workspace.yaml
+0 −124 Lib9c/Action/MigrationAvatarState.cs
+1 −1 Lib9c/Action/UnlockEquipmentRecipe.cs
+1 −1 Lib9c/Action/UnlockWorld.cs
+3 −7 Lib9c/Module/AgentModule.cs
+8 −170 Lib9c/Module/AvatarModule.cs
28 changes: 0 additions & 28 deletions NineChronicles.Headless.Executable/Commands/TxCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,34 +190,6 @@ public void MigrationActivatedAccountsState()
_console.Out.WriteLine(ByteUtil.Hex(raw));
}

[Command(Description = "Create MigrationAvatarState action and dump it.")]
public void MigrationAvatarState(
[Argument("directory-path", Description = "path of the directory contained hex-encoded avatar states.")]
string directoryPath,
[Argument("output-path", Description = "path of the output file dumped action.")]
string outputPath
)
{
var files = Directory.GetFiles(directoryPath, "*", SearchOption.AllDirectories);
var avatarStates = files.Select(a =>
{
var raw = File.ReadAllText(a);
return (Dictionary)_codec.Decode(ByteUtil.ParseHex(raw));
}).ToList();
var action = new MigrationAvatarState()
{
avatarStates = avatarStates
};

var encoded = new List(
(Text)nameof(Nekoyume.Action.MigrationAvatarState),
action.PlainValue
);

byte[] raw = _codec.Encode(encoded);
File.WriteAllText(outputPath, ByteUtil.Hex(raw));
}

[Command(Description = "Create AddRedeemCode action and dump it.")]
public void AddRedeemCode(
[Argument("TABLE-PATH", Description = "A table file path for RedeemCodeListSheet")]
Expand Down
32 changes: 30 additions & 2 deletions NineChronicles.Headless/BlockChainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public async UnaryResult<Dictionary<byte[], byte[]>> GetAvatarStatesByBlockHash(
var addresses = addressBytesList.Select(a => new Address(a)).ToList();
var taskList = addresses.Select(address => Task.Run(() =>
{
var value = worldState.GetFullAvatarStateRaw(address);
var value = GetFullAvatarStateRaw(worldState, address);
result.TryAdd(address.ToByteArray(), _codec.Encode(value ?? Null.Value));
}));

Expand All @@ -217,7 +217,7 @@ public async UnaryResult<Dictionary<byte[], byte[]>> GetAvatarStatesByStateRootH
var result = new ConcurrentDictionary<byte[], byte[]>();
var taskList = addresses.Select(address => Task.Run(() =>
{
var value = worldState.GetFullAvatarStateRaw(address);
var value = GetFullAvatarStateRaw(worldState, address);
result.TryAdd(address.ToByteArray(), _codec.Encode(value ?? Null.Value));
}));

Expand Down Expand Up @@ -447,5 +447,33 @@ public UnaryResult<bool> RemoveClient(byte[] addressBytes)
_publisher.RemoveClient(address).Wait();
return new UnaryResult<bool>(true);
}

// Returning value is a list of [ Avatar, Inventory, QuestList, WorldInformation ]
private static IValue GetFullAvatarStateRaw(IWorldState worldState, Address address)
{
var serializedAvatarRaw = worldState.GetAccountState(Addresses.Avatar).GetState(address);
if (serializedAvatarRaw is not List)
{
Log.Warning(
"Avatar state ({AvatarAddress}) should be " +
"List but: {Raw}",
address.ToHex(),
serializedAvatarRaw);
return null;
}

var serializedInventoryRaw =
worldState.GetAccountState(Addresses.Inventory).GetState(address);
var serializedQuestListRaw =
worldState.GetAccountState(Addresses.QuestList).GetState(address);
var serializedWorldInformationRaw =
worldState.GetAccountState(Addresses.WorldInformation).GetState(address);

return new List(
serializedAvatarRaw,
serializedInventoryRaw!,
serializedQuestListRaw!,
serializedWorldInformationRaw!);
}
}
}

0 comments on commit e575125

Please sign in to comment.