Sol ana I DL t o A PI generator.
It supports Anchor/Shank IDls and will output a SPM package generated. It includes Accounts, Errors, Instructions and Types. It uses a a default borsch serializer called
beet also included in the package.
Its a carbon copy from Solita with lots of language specific considerations. IDL processing and architecture has been maintained.
Run solita cli against the idl.json generated by shank or solita
solita render <idlPath> <outputDir>
solita render Tests/SolitaTests/Resources/action_house.json .output
This will generate a swift package that contains a swift package of a library target. By default the target is called
Generated. The package will contain the necessary dependencies to run the library that can be embedded into any project. Inside you will also get all the
Sources of this generated code for this idl.
To change the package name please provide the package name option
solita render Tests/SolitaTests/Resources/action_house.json .output -p ActionHouse
Sources you will also get a
.swiftlint that have the following disabled_rules.
disabled_rules: - identifier_name - force_cast
Currently there is no way to change the name scheme for the identifiers. Casting is also necessary since the parsing requires it.
Please verify your
Program.swift and check if is pointing to the default onchain program. If the publicKey is provided by the IDL it will be shown here. If is not, please provided it or it will throw an exception during runtime.
import Foundation import Solana /** * Program address * * @category constants * @category generated */ let PROGRAM_ADDRESS = "<publickey>" /** * Program public key * * @category constants * @category generated */ public let PROGRAM_ID = PublicKey(string: PROGRAM_ADDRESS)
|AccountsHaveImplicitDiscriminator||-a||--accountsHaveImplicitDiscriminator||True or False|
Run the following command on shell to compile
swift build -c release
the output binary file will be here
If you receive the following error:
error: 'solita-swift': Invalid manifest .../solita-swift/Package.swift:2:8: error: no such module 'PackageDescription'
Running the following command should resolve the issue:
sudo xcode-select --reset
|Last commit: 2 weeks ago|