Skip to content

magicblock-labs/Solana.Unity.Anchor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Release Code License Discord

Solana.Unity.Anchor

Solana.Unity.Anchor is a fork of Solnet.Anchor that generates code compatible with Unity dotnet standard 2.1.

Solana.Unity.Anchor rely on Solana.Unity-Core libraries and can be used with the Solana.Unity-SDK

Features

This repo contains 3 main projects:

  • Solana.Unity.Anchor: IDL parsing and code generation
  • Solana.Unity.Anchor.Tool: dotnet tool executable that interfaces with the project above.
  • Solana.Unity.Anchor.SourceGenerator: Roslyn source generator that depends on the tool above to automatically generate code from IDL in your IDE.

Currently covers all of IDL features with the exception of events and seeds.

Requirements

Solana.Unity.Anchor and Solana.Unity.Anchor.Tool are compiled and run in net6. Could be easily backported to net5. Solana.Unity.Anchor.SourceGenerator is compiled in netstandard2.1 to be able to be used as a Roslyn Source Generator. However, machine needs net6 as it just calls Solnet.Anchor.Tool that requires net6.

Instructions

To compile this project:

dotnet build

To use the generator tool:

  • dotnet tool install Solana.Unity.Anchor.Tool (if you use -g option, you won't need to do this for every project')
  • dotnet anchorgen -i idl/file.json -o src/ProgramCode.cs
    • You can generate from a live program that uploaded its idl using flag -a, or add the default program address if used alongside -i
    • You stdout output is supported using -s flag

To use the source generator roslyn plugin:

  • In your .csproj add <PackageReference Include="Solnet.Anchor.SourceGenerator" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
  • For each project you want to generate sources from an address, add inside PropertyGroup: <AnchorGenerator>address1,address2</AnchorGenerator>
  • For each project you want to generate sources from IDL, add <AdditionalFiles Include="IdlFile.json" Address="GDDMwNyyx8uB6zrqwBFHjLLG3TBYk2F8Az4yrQC5RzMp" AnchorGenerate="true" />

Support

Consider supporting us:

  • Sol Address: oaksGKfwkFZwCniyCF35ZVxHDPexQ3keXNTiLa7RCSp
  • Mango Ref Link

Contribution

We encourage everyone to contribute, submit issues, PRs, discuss. Every kind of help is welcome.

Solana.Unity Maintainers

Solnet Maintainers

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details