diff --git a/.github/workflows/build-programs.yml b/.github/workflows/build-programs.yml index ec52468..71b96d7 100644 --- a/.github/workflows/build-programs.yml +++ b/.github/workflows/build-programs.yml @@ -72,4 +72,5 @@ jobs: name: program-builds # First wildcard ensures exported paths are consistently under the programs folder. path: ./program*/.bin/*.so + include-hidden-files: true if-no-files-found: error diff --git a/configs/kinobi-asset.cjs b/configs/kinobi-asset.cjs index fe69083..cd038a2 100644 --- a/configs/kinobi-asset.cjs +++ b/configs/kinobi-asset.cjs @@ -2,6 +2,7 @@ const anchorIdl = require("@kinobi-so/nodes-from-anchor"); const jsRenderer = require("@kinobi-so/renderers-js-umi"); const rustRenderer = require("@kinobi-so/renderers-rust"); const k = require("kinobi"); +const { writeFileSync } = require("fs"); // Paths. const path = require("path"); @@ -627,3 +628,5 @@ kinobi.accept( } ) ); + +writeFileSync(path.join(idlDir, "asset-program.kinobi.json"), kinobi.getJson()); diff --git a/idls/asset-program.kinobi.json b/idls/asset-program.kinobi.json new file mode 100644 index 0000000..ac32586 --- /dev/null +++ b/idls/asset-program.kinobi.json @@ -0,0 +1 @@ +{"kind":"rootNode","standard":"kinobi","version":"0.20.4","program":{"kind":"programNode","name":"asset","publicKey":"AssetGtQBTSgm5s91d1RAQod5JmaZiJDxqsgtqrZud73","version":"0.6.1","origin":"shank","docs":[],"accounts":[{"kind":"accountNode","name":"internalAsset","docs":[],"data":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"discriminator","docs":[],"type":{"kind":"definedTypeLinkNode","name":"discriminator"}},{"kind":"structFieldTypeNode","name":"state","docs":[],"type":{"kind":"definedTypeLinkNode","name":"state"}},{"kind":"structFieldTypeNode","name":"standard","docs":[],"type":{"kind":"definedTypeLinkNode","name":"standard"}},{"kind":"structFieldTypeNode","name":"mutable","docs":[],"type":{"kind":"booleanTypeNode","size":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"structFieldTypeNode","name":"owner","docs":[],"type":{"kind":"publicKeyTypeNode"}},{"kind":"structFieldTypeNode","name":"group","docs":[],"type":{"kind":"definedTypeLinkNode","name":"nullablePublicKey","importFrom":"hooked"}},{"kind":"structFieldTypeNode","name":"authority","docs":[],"type":{"kind":"publicKeyTypeNode"}},{"kind":"structFieldTypeNode","name":"delegate","docs":[],"type":{"kind":"definedTypeLinkNode","name":"delegate"}},{"kind":"structFieldTypeNode","name":"name","docs":[],"type":{"kind":"fixedSizeTypeNode","type":{"kind":"stringTypeNode","encoding":"utf8"},"size":35}}]}}],"instructions":[{"kind":"instructionNode","name":"close","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"buffer","isWritable":true,"isSigner":true,"isOptional":false,"docs":["The uninitialized buffer account"]},{"kind":"instructionAccountNode","name":"recipient","isWritable":true,"isSigner":false,"isOptional":false,"docs":["The account receiving refunded rent"]}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":0}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"burn","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"signer","isWritable":true,"isSigner":true,"isOptional":false,"docs":["The owner or burn delegate of the asset"]},{"kind":"instructionAccountNode","name":"recipient","isWritable":true,"isSigner":false,"isOptional":true,"docs":["The account receiving refunded rent"]},{"kind":"instructionAccountNode","name":"group","isWritable":true,"isSigner":false,"isOptional":true,"docs":["Asset account of the group"]}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":1}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"create","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":true,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"authority","isWritable":false,"isSigner":"either","isOptional":false,"docs":["The authority of the asset"],"defaultValue":{"kind":"identityValueNode"}},{"kind":"instructionAccountNode","name":"owner","isWritable":false,"isSigner":false,"isOptional":false,"docs":["The owner of the asset"],"defaultValue":{"kind":"identityValueNode"}},{"kind":"instructionAccountNode","name":"group","isWritable":true,"isSigner":false,"isOptional":true,"docs":["Asset account of the group"]},{"kind":"instructionAccountNode","name":"groupAuthority","isWritable":false,"isSigner":true,"isOptional":true,"docs":["Group authority for creating an asset into a group"]},{"kind":"instructionAccountNode","name":"payer","isWritable":true,"isSigner":true,"isOptional":true,"docs":["The account paying for the storage fees"]},{"kind":"instructionAccountNode","name":"systemProgram","isWritable":false,"isSigner":false,"isOptional":true,"docs":["The system program"],"defaultValue":{"kind":"conditionalValueNode","condition":{"kind":"accountValueNode","name":"payer"},"ifTrue":{"kind":"publicKeyValueNode","publicKey":"11111111111111111111111111111111","identifier":"systemProgram"}}}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":2}},{"kind":"instructionArgumentNode","name":"name","docs":[],"type":{"kind":"sizePrefixTypeNode","type":{"kind":"stringTypeNode","encoding":"utf8"},"prefix":{"kind":"numberTypeNode","format":"u32","endian":"le"}}},{"kind":"instructionArgumentNode","name":"standard","docs":[],"type":{"kind":"definedTypeLinkNode","name":"standard"},"defaultValue":{"kind":"enumValueNode","variant":"nonFungible","enum":{"kind":"definedTypeLinkNode","name":"standard"}}},{"kind":"instructionArgumentNode","name":"mutable","docs":[],"type":{"kind":"booleanTypeNode","size":{"kind":"numberTypeNode","format":"u8","endian":"le"}},"defaultValue":{"kind":"booleanValueNode","boolean":true}},{"kind":"instructionArgumentNode","name":"extensions","docs":[],"type":{"kind":"optionTypeNode","fixed":false,"item":{"kind":"arrayTypeNode","item":{"kind":"definedTypeLinkNode","name":"extensionInput"},"count":{"kind":"prefixedCountNode","prefix":{"kind":"numberTypeNode","format":"u32","endian":"le"}}},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}},"defaultValue":{"kind":"noneValueNode"}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"approve","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"owner","isWritable":false,"isSigner":true,"isOptional":false,"docs":["The owner of the asset"],"defaultValue":{"kind":"identityValueNode"}},{"kind":"instructionAccountNode","name":"delegate","isWritable":false,"isSigner":false,"isOptional":false,"docs":["The delegate account"]}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":3}},{"kind":"instructionArgumentNode","name":"delegateInput","docs":[],"type":{"kind":"definedTypeLinkNode","name":"delegateInput"}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"allocate","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":true,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"payer","isWritable":true,"isSigner":true,"isOptional":true,"docs":["The account paying for the storage fees"]},{"kind":"instructionAccountNode","name":"systemProgram","isWritable":false,"isSigner":false,"isOptional":true,"docs":["The system program"],"defaultValue":{"kind":"conditionalValueNode","condition":{"kind":"accountValueNode","name":"payer"},"ifTrue":{"kind":"publicKeyValueNode","publicKey":"11111111111111111111111111111111","identifier":"systemProgram"}}}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":4}},{"kind":"instructionArgumentNode","name":"extension","docs":[],"type":{"kind":"definedTypeLinkNode","name":"extensionInput"}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"lock","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"signer","isWritable":false,"isSigner":true,"isOptional":false,"docs":["Delegate or owner account"],"defaultValue":{"kind":"identityValueNode"}}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":5}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"revoke","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"signer","isWritable":false,"isSigner":true,"isOptional":false,"docs":["Owner of the asset or current delegate"],"defaultValue":{"kind":"identityValueNode"}}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":6}},{"kind":"instructionArgumentNode","name":"delegateInput","docs":[],"type":{"kind":"definedTypeLinkNode","name":"delegateInput"}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"transfer","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"signer","isWritable":false,"isSigner":true,"isOptional":false,"docs":["Current owner of the asset or transfer delegate"],"defaultValue":{"kind":"identityValueNode"}},{"kind":"instructionAccountNode","name":"recipient","isWritable":false,"isSigner":false,"isOptional":false,"docs":["The recipient of the asset"]},{"kind":"instructionAccountNode","name":"group","isWritable":false,"isSigner":false,"isOptional":true,"docs":["The asset defining the group, if applicable"]}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":7}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"unlock","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"signer","isWritable":false,"isSigner":true,"isOptional":false,"docs":["Delegate or owner account"],"defaultValue":{"kind":"identityValueNode"}}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":8}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"unverify","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"creator","isWritable":false,"isSigner":true,"isOptional":false,"docs":["Creator account to unverify"]}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":9}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"update","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"authority","isWritable":false,"isSigner":true,"isOptional":false,"docs":["The authority of the asset"],"defaultValue":{"kind":"identityValueNode"}},{"kind":"instructionAccountNode","name":"buffer","isWritable":true,"isSigner":false,"isOptional":true,"docs":["Extension buffer (uninitialized asset) account"]},{"kind":"instructionAccountNode","name":"group","isWritable":false,"isSigner":false,"isOptional":true,"docs":["The asset defining the group, if applicable"]},{"kind":"instructionAccountNode","name":"payer","isWritable":true,"isSigner":true,"isOptional":true,"docs":["The account paying for the storage fees"]},{"kind":"instructionAccountNode","name":"systemProgram","isWritable":false,"isSigner":false,"isOptional":true,"docs":["The system program"],"defaultValue":{"kind":"conditionalValueNode","condition":{"kind":"accountValueNode","name":"payer"},"ifTrue":{"kind":"publicKeyValueNode","publicKey":"11111111111111111111111111111111","identifier":"systemProgram"}}}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":10}},{"kind":"instructionArgumentNode","name":"name","defaultValueStrategy":"optional","docs":[],"type":{"kind":"optionTypeNode","fixed":false,"item":{"kind":"sizePrefixTypeNode","type":{"kind":"stringTypeNode","encoding":"utf8"},"prefix":{"kind":"numberTypeNode","format":"u32","endian":"le"}},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}},"defaultValue":{"kind":"noneValueNode"}},{"kind":"instructionArgumentNode","name":"mutable","defaultValueStrategy":"optional","docs":[],"type":{"kind":"optionTypeNode","fixed":false,"item":{"kind":"booleanTypeNode","size":{"kind":"numberTypeNode","format":"u8","endian":"le"}},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}},"defaultValue":{"kind":"noneValueNode"}},{"kind":"instructionArgumentNode","name":"extension","defaultValueStrategy":"optional","docs":[],"type":{"kind":"optionTypeNode","fixed":false,"item":{"kind":"definedTypeLinkNode","name":"extensionInput"},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}},"defaultValue":{"kind":"noneValueNode"}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"verify","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"creator","isWritable":false,"isSigner":true,"isOptional":false,"docs":["Creator account to verify"]}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":11}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"write","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":true,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"payer","isWritable":true,"isSigner":true,"isOptional":false,"docs":["The account paying for the storage fees"],"defaultValue":{"kind":"payerValueNode"}},{"kind":"instructionAccountNode","name":"systemProgram","isWritable":false,"isSigner":false,"isOptional":false,"docs":["The system program"],"defaultValue":{"kind":"publicKeyValueNode","publicKey":"11111111111111111111111111111111","identifier":"systemProgram"}}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":12}},{"kind":"instructionArgumentNode","name":"overwrite","docs":[],"type":{"kind":"booleanTypeNode","size":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"instructionArgumentNode","name":"bytes","docs":[],"type":{"kind":"sizePrefixTypeNode","type":{"kind":"bytesTypeNode"},"prefix":{"kind":"numberTypeNode","format":"u32","endian":"le"}}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"group","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"group","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account of the group"]},{"kind":"instructionAccountNode","name":"authority","isWritable":false,"isSigner":true,"isOptional":false,"docs":["The authority of the assets"],"defaultValue":{"kind":"identityValueNode"}}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":13}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"ungroup","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"group","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account of the group"]},{"kind":"instructionAccountNode","name":"authority","isWritable":false,"isSigner":true,"isOptional":false,"docs":["The authority of the assets"],"defaultValue":{"kind":"identityValueNode"}}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":14}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"handover","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"authority","isWritable":false,"isSigner":true,"isOptional":false,"docs":["The authority of the asset"],"defaultValue":{"kind":"identityValueNode"}},{"kind":"instructionAccountNode","name":"newAuthority","isWritable":false,"isSigner":true,"isOptional":false,"docs":["The new authority of the asset"]}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":15}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"remove","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"authority","isWritable":false,"isSigner":true,"isOptional":false,"docs":["The authority of the asset"],"defaultValue":{"kind":"identityValueNode"}},{"kind":"instructionAccountNode","name":"group","isWritable":false,"isSigner":false,"isOptional":true,"docs":["The asset defining the group, if applicable"]},{"kind":"instructionAccountNode","name":"recipient","isWritable":true,"isSigner":false,"isOptional":false,"docs":["The account receiving refunded rent"],"defaultValue":{"kind":"identityValueNode"}}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":16}},{"kind":"instructionArgumentNode","name":"extensionType","docs":[],"type":{"kind":"definedTypeLinkNode","name":"extensionType"}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]},{"kind":"instructionNode","name":"resize","docs":[],"optionalAccountStrategy":"programId","accounts":[{"kind":"instructionAccountNode","name":"asset","isWritable":true,"isSigner":false,"isOptional":false,"docs":["Asset account"]},{"kind":"instructionAccountNode","name":"authority","isWritable":false,"isSigner":true,"isOptional":false,"docs":["The authority of the asset"],"defaultValue":{"kind":"identityValueNode"}},{"kind":"instructionAccountNode","name":"payer","isWritable":true,"isSigner":"either","isOptional":false,"docs":["The account paying for the storage fees"],"defaultValue":{"kind":"payerValueNode"}},{"kind":"instructionAccountNode","name":"systemProgram","isWritable":false,"isSigner":false,"isOptional":true,"docs":["The system program"],"defaultValue":{"kind":"conditionalValueNode","condition":{"kind":"accountValueNode","name":"payer"},"ifTrue":{"kind":"publicKeyValueNode","publicKey":"11111111111111111111111111111111","identifier":"systemProgram"}}}],"arguments":[{"kind":"instructionArgumentNode","name":"discriminator","defaultValueStrategy":"omitted","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"},"defaultValue":{"kind":"numberValueNode","number":17}},{"kind":"instructionArgumentNode","name":"strategy","docs":[],"type":{"kind":"definedTypeLinkNode","name":"strategy"}}],"discriminators":[{"kind":"fieldDiscriminatorNode","name":"discriminator","offset":0}]}],"definedTypes":[{"kind":"definedTypeNode","name":"extensionInput","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"extensionType","docs":[],"type":{"kind":"definedTypeLinkNode","name":"extensionType"}},{"kind":"structFieldTypeNode","name":"length","docs":[],"type":{"kind":"numberTypeNode","format":"u32","endian":"le"}},{"kind":"structFieldTypeNode","name":"data","docs":[],"type":{"kind":"optionTypeNode","fixed":false,"item":{"kind":"sizePrefixTypeNode","type":{"kind":"bytesTypeNode"},"prefix":{"kind":"numberTypeNode","format":"u32","endian":"le"}},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}}}]}},{"kind":"definedTypeNode","name":"delegateInput","docs":[],"type":{"kind":"enumTypeNode","variants":[{"kind":"enumEmptyVariantTypeNode","name":"all"},{"kind":"enumStructVariantTypeNode","name":"some","struct":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"roles","docs":[],"type":{"kind":"arrayTypeNode","item":{"kind":"definedTypeLinkNode","name":"delegateRole"},"count":{"kind":"prefixedCountNode","prefix":{"kind":"numberTypeNode","format":"u32","endian":"le"}}}}]}}],"size":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"definedTypeNode","name":"strategy","docs":[],"type":{"kind":"enumTypeNode","variants":[{"kind":"enumEmptyVariantTypeNode","name":"trim"},{"kind":"enumStructVariantTypeNode","name":"extend","struct":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"value","docs":[],"type":{"kind":"numberTypeNode","format":"u16","endian":"le"}}]}}],"size":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"definedTypeNode","name":"discriminator","docs":[],"type":{"kind":"enumTypeNode","variants":[{"kind":"enumEmptyVariantTypeNode","name":"uninitialized"},{"kind":"enumEmptyVariantTypeNode","name":"asset"}],"size":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"definedTypeNode","name":"standard","docs":[],"type":{"kind":"enumTypeNode","variants":[{"kind":"enumEmptyVariantTypeNode","name":"nonFungible"},{"kind":"enumEmptyVariantTypeNode","name":"managed"},{"kind":"enumEmptyVariantTypeNode","name":"soulbound"},{"kind":"enumEmptyVariantTypeNode","name":"proxied"}],"size":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"definedTypeNode","name":"state","docs":[],"type":{"kind":"enumTypeNode","variants":[{"kind":"enumEmptyVariantTypeNode","name":"unlocked"},{"kind":"enumEmptyVariantTypeNode","name":"locked"}],"size":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"definedTypeNode","name":"delegateRole","docs":[],"type":{"kind":"enumTypeNode","variants":[{"kind":"enumEmptyVariantTypeNode","name":"none"},{"kind":"enumEmptyVariantTypeNode","name":"transfer"},{"kind":"enumEmptyVariantTypeNode","name":"lock"},{"kind":"enumEmptyVariantTypeNode","name":"burn"}],"size":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"definedTypeNode","name":"extensionType","docs":[],"type":{"kind":"enumTypeNode","variants":[{"kind":"enumEmptyVariantTypeNode","name":"none"},{"kind":"enumEmptyVariantTypeNode","name":"attributes"},{"kind":"enumEmptyVariantTypeNode","name":"blob"},{"kind":"enumEmptyVariantTypeNode","name":"creators"},{"kind":"enumEmptyVariantTypeNode","name":"links"},{"kind":"enumEmptyVariantTypeNode","name":"metadata"},{"kind":"enumEmptyVariantTypeNode","name":"grouping"},{"kind":"enumEmptyVariantTypeNode","name":"royalties"},{"kind":"enumEmptyVariantTypeNode","name":"manager"},{"kind":"enumEmptyVariantTypeNode","name":"proxy"},{"kind":"enumEmptyVariantTypeNode","name":"properties"},{"kind":"enumEmptyVariantTypeNode","name":"bucket"}],"size":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"definedTypeNode","name":"delegate","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"address","docs":[],"type":{"kind":"definedTypeLinkNode","name":"nullablePublicKey","importFrom":"hooked"}},{"kind":"structFieldTypeNode","name":"roles","docs":[],"type":{"kind":"definedTypeLinkNode","name":"delegateRoles","importFrom":"hooked"}}]}},{"kind":"definedTypeNode","name":"extensionHeader","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"kind","docs":[],"type":{"kind":"numberTypeNode","format":"u32","endian":"le"}},{"kind":"structFieldTypeNode","name":"length","docs":[],"type":{"kind":"numberTypeNode","format":"u32","endian":"le"}},{"kind":"structFieldTypeNode","name":"boundary","docs":[],"type":{"kind":"numberTypeNode","format":"u32","endian":"le"}},{"kind":"structFieldTypeNode","name":"padding","docs":[],"type":{"kind":"numberTypeNode","format":"u32","endian":"le"}}]}},{"kind":"definedTypeNode","name":"attributes","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"values","docs":[],"type":{"kind":"arrayTypeNode","item":{"kind":"definedTypeLinkNode","name":"trait"},"count":{"kind":"remainderCountNode"}}}]}},{"kind":"definedTypeNode","name":"trait","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"name","docs":[],"type":{"kind":"sizePrefixTypeNode","type":{"kind":"stringTypeNode","encoding":"utf8"},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"structFieldTypeNode","name":"value","docs":[],"type":{"kind":"sizePrefixTypeNode","type":{"kind":"stringTypeNode","encoding":"utf8"},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}}}]}},{"kind":"definedTypeNode","name":"blob","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"contentType","docs":[],"type":{"kind":"sizePrefixTypeNode","type":{"kind":"stringTypeNode","encoding":"utf8"},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"structFieldTypeNode","name":"data","docs":[],"type":{"kind":"arrayTypeNode","item":{"kind":"numberTypeNode","format":"u8","endian":"le"},"count":{"kind":"remainderCountNode"}}}]}},{"kind":"definedTypeNode","name":"links","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"values","docs":[],"type":{"kind":"arrayTypeNode","item":{"kind":"definedTypeLinkNode","name":"link"},"count":{"kind":"remainderCountNode"}}}]}},{"kind":"definedTypeNode","name":"link","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"name","docs":[],"type":{"kind":"sizePrefixTypeNode","type":{"kind":"stringTypeNode","encoding":"utf8"},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"structFieldTypeNode","name":"uri","docs":[],"type":{"kind":"sizePrefixTypeNode","type":{"kind":"stringTypeNode","encoding":"utf8"},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}}}]}},{"kind":"definedTypeNode","name":"creators","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"values","docs":[],"type":{"kind":"arrayTypeNode","item":{"kind":"definedTypeLinkNode","name":"creator"},"count":{"kind":"remainderCountNode"}}}]}},{"kind":"definedTypeNode","name":"creator","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"address","docs":[],"type":{"kind":"publicKeyTypeNode"}},{"kind":"structFieldTypeNode","name":"verified","docs":[],"type":{"kind":"booleanTypeNode","size":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"structFieldTypeNode","name":"share","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"}}]}},{"kind":"definedTypeNode","name":"metadata","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"symbol","docs":[],"type":{"kind":"sizePrefixTypeNode","type":{"kind":"stringTypeNode","encoding":"utf8"},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"structFieldTypeNode","name":"description","docs":[],"type":{"kind":"sizePrefixTypeNode","type":{"kind":"stringTypeNode","encoding":"utf8"},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"structFieldTypeNode","name":"uri","docs":[],"type":{"kind":"sizePrefixTypeNode","type":{"kind":"stringTypeNode","encoding":"utf8"},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}}},{"kind":"structFieldTypeNode","name":"imageUri","docs":[],"type":{"kind":"sizePrefixTypeNode","type":{"kind":"stringTypeNode","encoding":"utf8"},"prefix":{"kind":"numberTypeNode","format":"u8","endian":"le"}}}]}},{"kind":"definedTypeNode","name":"grouping","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"size","docs":[],"type":{"kind":"numberTypeNode","format":"u64","endian":"le"}},{"kind":"structFieldTypeNode","name":"maxSize","docs":[],"type":{"kind":"numberTypeNode","format":"u64","endian":"le"}},{"kind":"structFieldTypeNode","name":"delegate","docs":[],"type":{"kind":"definedTypeLinkNode","name":"nullablePublicKey","importFrom":"hooked"}}]}},{"kind":"definedTypeNode","name":"manager","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"delegate","docs":[],"type":{"kind":"definedTypeLinkNode","name":"delegate"}}]}},{"kind":"definedTypeNode","name":"proxy","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"program","docs":[],"type":{"kind":"publicKeyTypeNode"}},{"kind":"structFieldTypeNode","name":"seeds","docs":[],"type":{"kind":"arrayTypeNode","item":{"kind":"numberTypeNode","format":"u8","endian":"le"},"count":{"kind":"fixedCountNode","value":32}}},{"kind":"structFieldTypeNode","name":"bump","docs":[],"type":{"kind":"numberTypeNode","format":"u8","endian":"le"}},{"kind":"structFieldTypeNode","name":"authority","docs":[],"type":{"kind":"definedTypeLinkNode","name":"nullablePublicKey","importFrom":"hooked"}}]}},{"kind":"definedTypeNode","name":"bucket","docs":[],"type":{"kind":"structTypeNode","fields":[{"kind":"structFieldTypeNode","name":"data","docs":[],"type":{"kind":"arrayTypeNode","item":{"kind":"numberTypeNode","format":"u8","endian":"le"},"count":{"kind":"remainderCountNode"}}}]}},{"kind":"definedTypeNode","name":"type","docs":[],"type":{"kind":"enumTypeNode","variants":[{"kind":"enumEmptyVariantTypeNode","name":"text"},{"kind":"enumEmptyVariantTypeNode","name":"number"},{"kind":"enumEmptyVariantTypeNode","name":"boolean"}],"size":{"kind":"numberTypeNode","format":"u8","endian":"le"}}}],"pdas":[],"errors":[{"kind":"errorNode","name":"alreadyInitialized","code":0,"message":"Asset already initialized","docs":["AlreadyInitialized: Asset already initialized"]},{"kind":"errorNode","name":"invalidAccountLength","code":1,"message":"Invalid account length","docs":["InvalidAccountLength: Invalid account length"]},{"kind":"errorNode","name":"incompleteExtensionData","code":2,"message":"Incomplete extension data","docs":["IncompleteExtensionData: Incomplete extension data"]},{"kind":"errorNode","name":"uninitialized","code":3,"message":"Uninitialized account","docs":["Uninitialized: Uninitialized account"]},{"kind":"errorNode","name":"extensionNotFound","code":4,"message":"Extension not found","docs":["ExtensionNotFound: Extension not found"]},{"kind":"errorNode","name":"invalidAlignment","code":5,"message":"Invalid alignment","docs":["InvalidAlignment: Invalid alignment"]},{"kind":"errorNode","name":"invalidBurnAuthority","code":6,"message":"Invalid owner or burn delegate","docs":["InvalidBurnAuthority: Invalid owner or burn delegate"]},{"kind":"errorNode","name":"invalidTransferAuthority","code":7,"message":"Invalid owner or transfer delegate","docs":["InvalidTransferAuthority: Invalid owner or transfer delegate"]},{"kind":"errorNode","name":"delegateNotFound","code":8,"message":"Delegate not found","docs":["DelegateNotFound: Delegate not found"]},{"kind":"errorNode","name":"delegateRoleNotActive","code":9,"message":"Delegate role not active","docs":["DelegateRoleNotActive: Delegate role not active"]},{"kind":"errorNode","name":"invalidDelegate","code":10,"message":"Invalid delegate","docs":["InvalidDelegate: Invalid delegate"]},{"kind":"errorNode","name":"invalidAssetOwner","code":11,"message":"Invalid asset owner","docs":["InvalidAssetOwner: Invalid asset owner"]},{"kind":"errorNode","name":"lockedAsset","code":12,"message":"Asset is locked","docs":["LockedAsset: Asset is locked"]},{"kind":"errorNode","name":"invalidAuthority","code":13,"message":"Invalid authority","docs":["InvalidAuthority: Invalid authority"]},{"kind":"errorNode","name":"immutableAsset","code":14,"message":"Immutable asset","docs":["ImmutableAsset: Immutable asset"]},{"kind":"errorNode","name":"cannotTransferSoulbound","code":15,"message":"Soulbound assets are non-transferable","docs":["CannotTransferSoulbound: Soulbound assets are non-transferable"]},{"kind":"errorNode","name":"extensionDataInvalid","code":16,"message":"Extension data invalid","docs":["ExtensionDataInvalid: Extension data invalid"]},{"kind":"errorNode","name":"invalidGroup","code":17,"message":"Invalid group","docs":["InvalidGroup: Invalid group"]},{"kind":"errorNode","name":"assertionFailure","code":18,"message":"Assertion Failure","docs":["AssertionFailure: Assertion Failure"]},{"kind":"errorNode","name":"groupNotEmpty","code":19,"message":"Group is not empty","docs":["GroupNotEmpty: Group is not empty"]},{"kind":"errorNode","name":"alreadyInGroup","code":20,"message":"Asset is already in a group","docs":["AlreadyInGroup: Asset is already in a group"]},{"kind":"errorNode","name":"extensionLengthInvalid","code":21,"message":"Extension length invalid","docs":["ExtensionLengthInvalid: Extension length invalid"]}]},"additionalPrograms":[]} \ No newline at end of file diff --git a/include-idl-cli/src/main.rs b/include-idl-cli/src/main.rs index faffc48..c49a34e 100644 --- a/include-idl-cli/src/main.rs +++ b/include-idl-cli/src/main.rs @@ -1,9 +1,9 @@ use std::path::PathBuf; -use goblin::error::Result; -use include_idl::parse_idl_from_program_binary; +// use goblin::error::Result; +use include_idl::parse::{parse_idl_from_program_binary, IdlType}; -use clap::{Parser, Subcommand}; +use clap::{Error, Parser, Subcommand}; #[derive(Parser)] #[command(version, about, long_about = None)] @@ -17,19 +17,25 @@ enum Commands { Parse { /// Read IDL from a solana program binary path: PathBuf, + idl_type: IdlType, }, } -pub fn main() -> Result<()> { +// This example uses ArgEnum, so this might not be necessary. + +pub fn main() -> Result<(), Error> { let cli = Cli::parse(); match &cli.command { - Some(Commands::Parse { path }) => { + Some(Commands::Parse { path, idl_type }) => { let buffer = std::fs::read(path).expect("Could not read file."); - let idl = parse_idl_from_program_binary(&buffer)?; - println!(" Program IDL"); - println!("============================"); - println!("{}", idl); + if let Ok(idl) = parse_idl_from_program_binary(&buffer, idl_type.clone()) { + println!(" Program IDL"); + println!("============================"); + println!("{}", idl); + } else { + println!("Could not find {:?} IDL in program binary", idl_type); + } } None => {} } diff --git a/include-idl/src/lib.rs b/include-idl/src/lib.rs index 56244af..aa4d1ee 100644 --- a/include-idl/src/lib.rs +++ b/include-idl/src/lib.rs @@ -1,10 +1,9 @@ #[cfg(feature = "parse")] -mod parse; -#[cfg(feature = "parse")] -pub use parse::parse_idl_from_program_binary; +pub mod parse; #[cfg(feature = "shrink")] mod shrink; + #[cfg(feature = "shrink")] pub use shrink::compress_idl; @@ -20,3 +19,16 @@ macro_rules! include_idl { pub static IDL_BYTES: &[u8] = include_bytes!($s); }; } + +#[macro_export] +macro_rules! include_kinobi_idl { + ($s:expr) => { + #[cfg_attr( + any(target_arch = "sbf", target_arch = "bpf"), + link_section = ".kinobi.idl" + )] + #[allow(dead_code)] + #[no_mangle] + pub static KINOBI_IDL_BYTES: &[u8] = include_bytes!($s); + }; +} diff --git a/include-idl/src/parse.rs b/include-idl/src/parse.rs index 5e6a881..579c375 100644 --- a/include-idl/src/parse.rs +++ b/include-idl/src/parse.rs @@ -1,17 +1,55 @@ #[cfg(feature = "parse")] use { - flate2::bufread::ZlibDecoder, goblin::elf::Elf, goblin::error::Result, serde_json::Value, - std::io::Read, + flate2::bufread::ZlibDecoder, goblin::elf::Elf, serde_json::Value, std::fmt, std::io::Read, + std::str::FromStr, }; -#[cfg(feature = "parse")] -pub fn parse_idl_from_program_binary(buffer: &[u8]) -> Result { +#[derive(Clone, Debug)] +pub enum IdlType { + Anchor, + Kinobi, +} + +impl fmt::Display for IdlType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + IdlType::Anchor => write!(f, "Anchor"), + IdlType::Kinobi => write!(f, "Kinobi"), + } + } +} + +impl FromStr for IdlType { + type Err = &'static str; + + fn from_str(s: &str) -> Result { + match s.to_lowercase().as_str() { + "anchor" => Ok(IdlType::Anchor), + "kinobi" => Ok(IdlType::Kinobi), + _ => Err("Invalid IDL type"), + } + } +} + +fn get_section_name(idl_type: IdlType) -> String { + match idl_type { + IdlType::Anchor => ".solana.idl".to_string(), + IdlType::Kinobi => ".kinobi.idl".to_string(), + } +} + +pub fn parse_idl_from_program_binary( + buffer: &[u8], + idl_type: IdlType, +) -> goblin::error::Result { let elf = Elf::parse(buffer)?; + let section_name = get_section_name(idl_type); + // Iterate over section headers and print information for sh in &elf.section_headers { let name = elf.shdr_strtab.get_at(sh.sh_name).unwrap_or(""); - if name == ".solana.idl" { + if name == section_name { // Get offset of .solana.idl section data let offset = sh.sh_offset as usize; diff --git a/programs/asset/program/build.rs b/programs/asset/program/build.rs index 140a759..d03d193 100644 --- a/programs/asset/program/build.rs +++ b/programs/asset/program/build.rs @@ -11,12 +11,17 @@ fn main() { .output() .expect("Failed to run shank"); + let _output = Command::new("pnpm") + .arg("generate:clients") + .output() + .expect("Failed to create the kinobi IDLs"); + // Get the IDL path - let idl_path = PathBuf::from("../../../idls").join("asset_program.json"); + let idl_path = PathBuf::from("../../../idls").join("asset-program.kinobi.json"); // Concat output path of compressed IDL let out_dir = env::var("OUT_DIR").unwrap(); - let dest_path = PathBuf::from(out_dir).join("idl.json.zip"); + let dest_path = PathBuf::from(out_dir).join("kinobi.idl.zip"); compress_idl(&idl_path, &dest_path); } diff --git a/programs/asset/program/src/lib.rs b/programs/asset/program/src/lib.rs index d364254..1fcdbaa 100644 --- a/programs/asset/program/src/lib.rs +++ b/programs/asset/program/src/lib.rs @@ -15,13 +15,13 @@ pub mod utils; pub use solana_program; #[cfg(not(feature = "no-entrypoint"))] -use include_idl::include_idl; +use include_idl::include_kinobi_idl; #[cfg(not(feature = "no-entrypoint"))] use solana_security_txt::security_txt; #[cfg(not(feature = "no-entrypoint"))] -include_idl!(concat!(env!("OUT_DIR"), "/idl.json.zip")); +include_kinobi_idl!(concat!(env!("OUT_DIR"), "/kinobi.idl.zip")); #[cfg(not(feature = "no-entrypoint"))] security_txt! {