diff --git a/SharedBuildProperties.props b/SharedBuildProperties.props index ead11c2..b298616 100644 --- a/SharedBuildProperties.props +++ b/SharedBuildProperties.props @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> Solana.Unity.Anchor - 0.2.13 + 0.2.14 Copyright 2023 © Magicblock Magicblock Magicblock diff --git a/Solana.Unity.Anchor.Test/Resources/Hero.json b/Solana.Unity.Anchor.Test/Resources/Hero.json new file mode 100644 index 0000000..281ef72 --- /dev/null +++ b/Solana.Unity.Anchor.Test/Resources/Hero.json @@ -0,0 +1,331 @@ +{ + "address": "GBzY8ujNDb1FNkJUXUUjKV5uZPqzi6AoKsPjsqFEHCeh", + "metadata": { + "name": "hero", + "version": "0.1.10", + "spec": "0.1.0", + "description": "Created with Bolt" + }, + "instructions": [ + { + "name": "delegate", + "discriminator": [ + 90, + 147, + 75, + 178, + 85, + 88, + 4, + 137 + ], + "accounts": [ + { + "name": "payer", + "signer": true + }, + { + "name": "entity" + }, + { + "name": "account", + "writable": true + }, + { + "name": "owner_program" + }, + { + "name": "buffer", + "writable": true + }, + { + "name": "delegation_record", + "writable": true + }, + { + "name": "delegate_account_seeds", + "writable": true + }, + { + "name": "delegation_program" + }, + { + "name": "system_program" + } + ], + "args": [ + { + "name": "valid_until", + "type": "i64" + }, + { + "name": "commit_frequency_ms", + "type": "u32" + } + ] + }, + { + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "data", + "writable": true + }, + { + "name": "entity" + }, + { + "name": "authority" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "process_undelegation", + "discriminator": [ + 196, + 28, + 41, + 206, + 48, + 37, + 51, + 167 + ], + "accounts": [ + { + "name": "delegated_account", + "writable": true + }, + { + "name": "buffer" + }, + { + "name": "payer", + "writable": true + }, + { + "name": "system_program" + } + ], + "args": [ + { + "name": "account_seeds", + "type": { + "vec": "bytes" + } + } + ] + }, + { + "name": "undelegate", + "discriminator": [ + 131, + 148, + 180, + 198, + 91, + 104, + 42, + 238 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "delegated_account", + "writable": true + }, + { + "name": "magic_context", + "writable": true, + "address": "MagicContext1111111111111111111111111111111" + }, + { + "name": "magic_program", + "address": "Magic11111111111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "update", + "discriminator": [ + 219, + 200, + 88, + 176, + 158, + 63, + 253, + 127 + ], + "accounts": [ + { + "name": "bolt_component", + "writable": true + }, + { + "name": "authority" + }, + { + "name": "instruction_sysvar_account", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "data", + "type": "bytes" + } + ] + } + ], + "accounts": [ + { + "name": "Entity", + "discriminator": [ + 46, + 157, + 161, + 161, + 254, + 46, + 79, + 24 + ] + }, + { + "name": "Hero", + "discriminator": [ + 12, + 63, + 39, + 30, + 183, + 229, + 154, + 172 + ] + } + ], + "types": [ + { + "name": "BoltMetadata", + "docs": [ + "Metadata for the component." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "type": "pubkey" + } + ] + } + }, + { + "name": "Entity", + "type": { + "kind": "struct", + "fields": [ + { + "name": "id", + "type": "u64" + } + ] + } + }, + { + "name": "Hero", + "type": { + "kind": "struct", + "fields": [ + { + "name": "x", + "type": "i32" + }, + { + "name": "y", + "type": "i32" + }, + { + "name": "last_activity", + "type": "i64" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "backpack", + "type": { + "defined": { + "name": "ResourceBalance" + } + } + }, + { + "name": "bolt_metadata", + "type": { + "defined": { + "name": "BoltMetadata" + } + } + } + ] + } + }, + { + "name": "ResourceBalance", + "type": { + "kind": "struct", + "fields": [ + { + "name": "food", + "type": "u16" + }, + { + "name": "water", + "type": "u16" + }, + { + "name": "wood", + "type": "u16" + }, + { + "name": "stone", + "type": "u16" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/Solana.Unity.Anchor.Test/Solana.Unity.Anchor.Test.csproj b/Solana.Unity.Anchor.Test/Solana.Unity.Anchor.Test.csproj index d4c81ff..e839950 100644 --- a/Solana.Unity.Anchor.Test/Solana.Unity.Anchor.Test.csproj +++ b/Solana.Unity.Anchor.Test/Solana.Unity.Anchor.Test.csproj @@ -42,6 +42,9 @@ PreserveNewest + + PreserveNewest + diff --git a/Solana.Unity.Anchor.Test/UnitTest1.cs b/Solana.Unity.Anchor.Test/UnitTest1.cs index 1aad400..3b6a506 100644 --- a/Solana.Unity.Anchor.Test/UnitTest1.cs +++ b/Solana.Unity.Anchor.Test/UnitTest1.cs @@ -95,6 +95,21 @@ public void TestBoltWorldNewProgramParsing() var code = c.GenerateCode(res); Assert.IsNotNull(code); } + + [TestMethod] + public void TestHerosParsing() + { + var res = IdlParser.ParseFile("Resources/Hero.json"); + Assert.IsNotNull(res); + + ClientGenerator c = new(); + + c.GenerateSyntaxTree(res); + Assert.IsNotNull(c); + + var code = c.GenerateCode(res); + Assert.IsNotNull(code); + } } }