diff --git a/clients/js/src/generated/accounts/config.ts b/clients/js/src/generated/accounts/config.ts index 0774984..d68aa0a 100644 --- a/clients/js/src/generated/accounts/config.ts +++ b/clients/js/src/generated/accounts/config.ts @@ -1,9 +1,9 @@ /** - * This code was AUTOGENERATED using the kinobi library. + * This code was AUTOGENERATED using the codama library. * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun kinobi to update it. + * to add features, then rerun codama to update it. * - * @see https://github.com/kinobi-so/kinobi + * @see https://github.com/codama-idl/codama */ import { @@ -34,7 +34,7 @@ import { getConfigKeysEncoder, type ConfigKeys, type ConfigKeysArgs, -} from '../../hooked'; +} from '../types'; export type Config = { /** diff --git a/clients/js/src/generated/accounts/index.ts b/clients/js/src/generated/accounts/index.ts index 79c505f..6a79796 100644 --- a/clients/js/src/generated/accounts/index.ts +++ b/clients/js/src/generated/accounts/index.ts @@ -1,9 +1,9 @@ /** - * This code was AUTOGENERATED using the kinobi library. + * This code was AUTOGENERATED using the codama library. * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun kinobi to update it. + * to add features, then rerun codama to update it. * - * @see https://github.com/kinobi-so/kinobi + * @see https://github.com/codama-idl/codama */ export * from './config'; diff --git a/clients/js/src/generated/index.ts b/clients/js/src/generated/index.ts index dbd55ae..5fd6de6 100644 --- a/clients/js/src/generated/index.ts +++ b/clients/js/src/generated/index.ts @@ -1,11 +1,12 @@ /** - * This code was AUTOGENERATED using the kinobi library. + * This code was AUTOGENERATED using the codama library. * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun kinobi to update it. + * to add features, then rerun codama to update it. * - * @see https://github.com/kinobi-so/kinobi + * @see https://github.com/codama-idl/codama */ export * from './accounts'; export * from './instructions'; export * from './programs'; +export * from './types'; diff --git a/clients/js/src/generated/instructions/index.ts b/clients/js/src/generated/instructions/index.ts index 9efe8e2..aad28e0 100644 --- a/clients/js/src/generated/instructions/index.ts +++ b/clients/js/src/generated/instructions/index.ts @@ -1,9 +1,9 @@ /** - * This code was AUTOGENERATED using the kinobi library. + * This code was AUTOGENERATED using the codama library. * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun kinobi to update it. + * to add features, then rerun codama to update it. * - * @see https://github.com/kinobi-so/kinobi + * @see https://github.com/codama-idl/codama */ export * from './store'; diff --git a/clients/js/src/generated/instructions/store.ts b/clients/js/src/generated/instructions/store.ts index 2f4753f..a26ba8f 100644 --- a/clients/js/src/generated/instructions/store.ts +++ b/clients/js/src/generated/instructions/store.ts @@ -1,9 +1,9 @@ /** - * This code was AUTOGENERATED using the kinobi library. + * This code was AUTOGENERATED using the codama library. * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun kinobi to update it. + * to add features, then rerun codama to update it. * - * @see https://github.com/kinobi-so/kinobi + * @see https://github.com/codama-idl/codama */ import { @@ -27,14 +27,14 @@ import { type WritableAccount, type WritableSignerAccount, } from '@solana/web3.js'; +import { SOLANA_CONFIG_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { getConfigKeysDecoder, getConfigKeysEncoder, type ConfigKeys, type ConfigKeysArgs, -} from '../../hooked'; -import { SOLANA_CONFIG_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +} from '../types'; export type StoreInstruction< TProgram extends string = typeof SOLANA_CONFIG_PROGRAM_ADDRESS, @@ -111,17 +111,22 @@ export type StoreInput = { signers?: Array; }; -export function getStoreInstruction( - input: StoreInput +export function getStoreInstruction< + TAccountConfigAccount extends string, + TProgramAddress extends Address = typeof SOLANA_CONFIG_PROGRAM_ADDRESS, +>( + input: StoreInput, + config?: { programAddress?: TProgramAddress } ): StoreInstruction< - typeof SOLANA_CONFIG_PROGRAM_ADDRESS, + TProgramAddress, (typeof input)['configAccount'] extends TransactionSigner ? WritableSignerAccount & IAccountSignerMeta : TAccountConfigAccount > { // Program address. - const programAddress = SOLANA_CONFIG_PROGRAM_ADDRESS; + const programAddress = + config?.programAddress ?? SOLANA_CONFIG_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { @@ -152,7 +157,7 @@ export function getStoreInstruction( args as StoreInstructionDataArgs ), } as StoreInstruction< - typeof SOLANA_CONFIG_PROGRAM_ADDRESS, + TProgramAddress, (typeof input)['configAccount'] extends TransactionSigner ? WritableSignerAccount & IAccountSignerMeta diff --git a/clients/js/src/generated/programs/index.ts b/clients/js/src/generated/programs/index.ts index 717293e..73aae5f 100644 --- a/clients/js/src/generated/programs/index.ts +++ b/clients/js/src/generated/programs/index.ts @@ -1,9 +1,9 @@ /** - * This code was AUTOGENERATED using the kinobi library. + * This code was AUTOGENERATED using the codama library. * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun kinobi to update it. + * to add features, then rerun codama to update it. * - * @see https://github.com/kinobi-so/kinobi + * @see https://github.com/codama-idl/codama */ export * from './solanaConfig'; diff --git a/clients/js/src/generated/programs/solanaConfig.ts b/clients/js/src/generated/programs/solanaConfig.ts index 9a9f7ec..286e51e 100644 --- a/clients/js/src/generated/programs/solanaConfig.ts +++ b/clients/js/src/generated/programs/solanaConfig.ts @@ -1,9 +1,9 @@ /** - * This code was AUTOGENERATED using the kinobi library. + * This code was AUTOGENERATED using the codama library. * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun kinobi to update it. + * to add features, then rerun codama to update it. * - * @see https://github.com/kinobi-so/kinobi + * @see https://github.com/codama-idl/codama */ import { type Address } from '@solana/web3.js'; diff --git a/clients/js/src/generated/shared/index.ts b/clients/js/src/generated/shared/index.ts index 278bf59..01a7d93 100644 --- a/clients/js/src/generated/shared/index.ts +++ b/clients/js/src/generated/shared/index.ts @@ -1,9 +1,9 @@ /** - * This code was AUTOGENERATED using the kinobi library. + * This code was AUTOGENERATED using the codama library. * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun kinobi to update it. + * to add features, then rerun codama to update it. * - * @see https://github.com/kinobi-so/kinobi + * @see https://github.com/codama-idl/codama */ import { diff --git a/clients/js/src/generated/types/configKeys.ts b/clients/js/src/generated/types/configKeys.ts new file mode 100644 index 0000000..2e0c1fd --- /dev/null +++ b/clients/js/src/generated/types/configKeys.ts @@ -0,0 +1,53 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBooleanDecoder, + getBooleanEncoder, + getShortU16Decoder, + getShortU16Encoder, + getTupleDecoder, + getTupleEncoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/web3.js'; + +/** + * A collection of keys to be stored in Config account data. + * Each key tuple comprises a unique `Pubkey` identifier, + * and `bool` whether that key is a signer of the data. + */ + +export type ConfigKeys = Array; + +export type ConfigKeysArgs = ConfigKeys; + +export function getConfigKeysEncoder(): Encoder { + return getArrayEncoder( + getTupleEncoder([getAddressEncoder(), getBooleanEncoder()]), + { size: getShortU16Encoder() } + ); +} + +export function getConfigKeysDecoder(): Decoder { + return getArrayDecoder( + getTupleDecoder([getAddressDecoder(), getBooleanDecoder()]), + { size: getShortU16Decoder() } + ); +} + +export function getConfigKeysCodec(): Codec { + return combineCodec(getConfigKeysEncoder(), getConfigKeysDecoder()); +} diff --git a/clients/js/src/generated/types/index.ts b/clients/js/src/generated/types/index.ts new file mode 100644 index 0000000..bf9f6b6 --- /dev/null +++ b/clients/js/src/generated/types/index.ts @@ -0,0 +1,9 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +export * from './configKeys'; diff --git a/clients/js/src/hooked/index.ts b/clients/js/src/hooked/index.ts deleted file mode 100644 index 6c2d1bc..0000000 --- a/clients/js/src/hooked/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './shortVec'; diff --git a/clients/js/src/hooked/shortVec.ts b/clients/js/src/hooked/shortVec.ts deleted file mode 100644 index c56b6fa..0000000 --- a/clients/js/src/hooked/shortVec.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { - getShortU16Decoder, - getShortU16Encoder, - combineCodec, - Decoder, - Encoder, - getAddressEncoder, - getArrayDecoder, - getArrayEncoder, - getBooleanEncoder, - getTupleEncoder, - VariableSizeDecoder, - VariableSizeEncoder, - Address, - getAddressDecoder, - getBooleanDecoder, - getTupleDecoder, -} from '@solana/web3.js'; - -/** - * ShortVec generic type. - */ -export type ShortVec = T[]; -export type ShortVecArgs = ShortVec; - -export const getShortVecEncoder = ( - elementEncoder: Encoder -): VariableSizeEncoder> => - getArrayEncoder(elementEncoder, { size: getShortU16Encoder() }); - -export const getShortVecDecoder = ( - elementDecoder: Decoder -): VariableSizeDecoder> => - getArrayDecoder(elementDecoder, { size: getShortU16Decoder() }); - -export const getShortVecCodec = ( - elementEncoder: Encoder, - elementDecoder: Decoder -) => - combineCodec( - getShortVecEncoder(elementEncoder), - getShortVecDecoder(elementDecoder) - ); - -/** - * ConfigKeys type - uses short vec. - */ -export type ConfigKeys = ShortVec<[Address, boolean]>; -export type ConfigKeysArgs = ConfigKeys; - -export const getConfigKeysEncoder = (): VariableSizeEncoder< - ShortVec<[Address, boolean]> -> => - getShortVecEncoder( - getTupleEncoder([getAddressEncoder(), getBooleanEncoder()]) - ); - -export const getConfigKeysDecoder = (): VariableSizeDecoder< - ShortVec<[Address, boolean]> -> => - getShortVecDecoder( - getTupleDecoder([getAddressDecoder(), getBooleanDecoder()]) - ) as VariableSizeDecoder>; - -export const getConfigKeysCodec = combineCodec( - getConfigKeysEncoder(), - getConfigKeysDecoder() -); diff --git a/clients/js/src/index.ts b/clients/js/src/index.ts index 44a1d0d..69e4e4e 100644 --- a/clients/js/src/index.ts +++ b/clients/js/src/index.ts @@ -1,2 +1 @@ export * from './generated'; -export * from './hooked'; diff --git a/clients/js/test/test.ts b/clients/js/test/test.ts index a076156..26e4276 100644 --- a/clients/js/test/test.ts +++ b/clients/js/test/test.ts @@ -1,5 +1,5 @@ import test from 'ava'; -test('placeholder', async (t) => { +test('placeholder', (t) => { t.true(true); }); diff --git a/clients/rust/src/generated/accounts/config.rs b/clients/rust/src/generated/accounts/config.rs index 2b666c5..017fc38 100644 --- a/clients/rust/src/generated/accounts/config.rs +++ b/clients/rust/src/generated/accounts/config.rs @@ -1,8 +1,8 @@ -//! This code was AUTOGENERATED using the kinobi library. +//! This code was AUTOGENERATED using the codama library. //! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun kinobi to update it. +//! to add features, then rerun codama to update it. //! -//! +//! use { crate::hooked::ConfigKeys, diff --git a/clients/rust/src/generated/accounts/mod.rs b/clients/rust/src/generated/accounts/mod.rs index 4374a93..05c9b56 100644 --- a/clients/rust/src/generated/accounts/mod.rs +++ b/clients/rust/src/generated/accounts/mod.rs @@ -1,8 +1,8 @@ -//! This code was AUTOGENERATED using the kinobi library. +//! This code was AUTOGENERATED using the codama library. //! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun kinobi to update it. +//! to add features, then rerun codama to update it. //! -//! +//! pub(crate) mod r#config; diff --git a/clients/rust/src/generated/errors/mod.rs b/clients/rust/src/generated/errors/mod.rs index 05ea2cd..d698264 100644 --- a/clients/rust/src/generated/errors/mod.rs +++ b/clients/rust/src/generated/errors/mod.rs @@ -1,5 +1,5 @@ -//! This code was AUTOGENERATED using the kinobi library. +//! This code was AUTOGENERATED using the codama library. //! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun kinobi to update it. +//! to add features, then rerun codama to update it. //! -//! +//! diff --git a/clients/rust/src/generated/instructions/mod.rs b/clients/rust/src/generated/instructions/mod.rs index 3bbe0bc..f4e5185 100644 --- a/clients/rust/src/generated/instructions/mod.rs +++ b/clients/rust/src/generated/instructions/mod.rs @@ -1,8 +1,8 @@ -//! This code was AUTOGENERATED using the kinobi library. +//! This code was AUTOGENERATED using the codama library. //! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun kinobi to update it. +//! to add features, then rerun codama to update it. //! -//! +//! pub(crate) mod r#store; diff --git a/clients/rust/src/generated/instructions/store.rs b/clients/rust/src/generated/instructions/store.rs index 311d949..51e6234 100644 --- a/clients/rust/src/generated/instructions/store.rs +++ b/clients/rust/src/generated/instructions/store.rs @@ -1,8 +1,8 @@ -//! This code was AUTOGENERATED using the kinobi library. +//! This code was AUTOGENERATED using the codama library. //! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun kinobi to update it. +//! to add features, then rerun codama to update it. //! -//! +//! use { crate::hooked::ConfigKeys, @@ -110,7 +110,7 @@ impl StoreBuilder { self.data = Some(data); self } - /// Add an aditional account to the instruction. + /// Add an additional account to the instruction. #[inline(always)] pub fn add_remaining_account( &mut self, diff --git a/clients/rust/src/generated/mod.rs b/clients/rust/src/generated/mod.rs index 9933f3d..7820567 100644 --- a/clients/rust/src/generated/mod.rs +++ b/clients/rust/src/generated/mod.rs @@ -1,8 +1,8 @@ -//! This code was AUTOGENERATED using the kinobi library. +//! This code was AUTOGENERATED using the codama library. //! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun kinobi to update it. +//! to add features, then rerun codama to update it. //! -//! +//! pub mod accounts; pub mod errors; diff --git a/clients/rust/src/generated/programs.rs b/clients/rust/src/generated/programs.rs index 6b8d2fb..a342009 100644 --- a/clients/rust/src/generated/programs.rs +++ b/clients/rust/src/generated/programs.rs @@ -1,8 +1,8 @@ -//! This code was AUTOGENERATED using the kinobi library. +//! This code was AUTOGENERATED using the codama library. //! Please DO NOT EDIT THIS FILE, instead use visitors -//! to add features, then rerun kinobi to update it. +//! to add features, then rerun codama to update it. //! -//! +//! use solana_program::{pubkey, pubkey::Pubkey}; diff --git a/package.json b/package.json index 20f819e..af6f9dd 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,9 @@ }, "devDependencies": { "@iarna/toml": "^2.2.5", - "@kinobi-so/renderers-js": "^0.21.2", - "@kinobi-so/renderers-rust": "^0.21.1", - "kinobi": "^0.21.0", + "@codama/renderers-js": "^1.0.0", + "@codama/renderers-rust": "^1.0.1", + "codama": "^1.0.0", "typescript": "^5.5.2", "zx": "^7.2.3" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f7ea90c..99dc203 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,18 +8,18 @@ importers: .: devDependencies: + '@codama/renderers-js': + specifier: ^1.0.0 + version: 1.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) + '@codama/renderers-rust': + specifier: ^1.0.1 + version: 1.0.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) '@iarna/toml': specifier: ^2.2.5 version: 2.2.5 - '@kinobi-so/renderers-js': - specifier: ^0.21.2 - version: 0.21.2(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) - '@kinobi-so/renderers-rust': - specifier: ^0.21.1 - version: 0.21.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) - kinobi: - specifier: ^0.21.0 - version: 0.21.0 + codama: + specifier: ^1.0.0 + version: 1.0.0 typescript: specifier: ^5.5.2 version: 5.5.4 @@ -29,43 +29,43 @@ importers: packages: - '@iarna/toml@2.2.5': - resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} - - '@kinobi-so/errors@0.21.0': - resolution: {integrity: sha512-7dPK35L/Y01qzekhVHdKAu+lENmHhuwX39rIx3qNJpNPHKi1VCcorLuOJlfT2F9MPPUjv5pZliL5qQ5IsvtNMw==} + '@codama/errors@1.0.0': + resolution: {integrity: sha512-XSdkNbCNJukhKO5TFJ5cFP7TfddxZwqHV7N/XyMbZ0meVPN1ymT94/d/9b8R+bvKuflj/SXImv527tGZWz6pGA==} hasBin: true - '@kinobi-so/node-types@0.21.0': - resolution: {integrity: sha512-UmzjocmsLa1pZ/ExVklGRsWQZNoIvifKBuTEAcpdxlDhg6hmrMWoXwWvRrLI5o7v1WKvTucv7KuM+5GU9UhFDw==} + '@codama/node-types@1.0.0': + resolution: {integrity: sha512-UAc+0jprwHFOqtAPqqA//PkrnlUzuqs+N5E36bHhLV0m5qWMlqrfmPg/ffBwMYFJsLFWsRsisALrqPy7ARkUow==} + + '@codama/nodes-from-anchor@1.0.0': + resolution: {integrity: sha512-urqFOV5K1oKBptgIFFLCPWrUsEeZsonml12ieP26ozX12aglGlN0tsxNsCvxJulRIjUxuONbH6xzv7uKt0xSYQ==} - '@kinobi-so/nodes-from-anchor@0.20.9': - resolution: {integrity: sha512-xNlwvJek6Hbfi45Unocwq/lT3rFXhmpZcAZmQJMgdIH8E4iAya9ZQ89j4neRQ+C1KVrK9qFJh0SaJvt9xnJQXA==} + '@codama/nodes@1.0.0': + resolution: {integrity: sha512-btcnjDaOpEFvVq3uVzlQK4G2OxxyK3P9HkXw423GZaqYQzeSr1pDdTKjyVyg+QO578CGqIMySVlJ2UAdHVMytw==} - '@kinobi-so/nodes@0.21.0': - resolution: {integrity: sha512-Z8STFjB3/f9LzK494l6qydkBMsFtnm96YreJjlAg9/DeKNtphimslSvFTF/9qHiGMfOQpOVhQqbWFXpt+PCZiQ==} + '@codama/renderers-core@1.0.0': + resolution: {integrity: sha512-WYvOylIzcR0WOc7GlUvGi5ym8IwmslwyV8zfj7FR646bMqaROirFJc+naGEbZ1lMykOyxcackTKL0eDB7954Qw==} - '@kinobi-so/renderers-core@0.20.7': - resolution: {integrity: sha512-KJhU8+UMowO9dDkLhEodAkbRkgSxdfBWeY+DIgOCgXcakt0T140K7OREuaAo9fp12Owf+10SAEGx9AzTNySoHA==} + '@codama/renderers-js@1.0.0': + resolution: {integrity: sha512-wi9eqrtLbTM49ELqKqxIgbTaf7xKMWT+HIqj6GN373G0OJnSKwUJPIXAGLO+RCls5DGjDuOE5svuThU0zBkfzA==} - '@kinobi-so/renderers-js@0.21.2': - resolution: {integrity: sha512-G576GAQ10ugmA63EZRlEbv892th37q9ow+AMzZD1vtypRCEJ7znakzySSDG3aeqaZujk2igKXFQTD+FHuY/xPg==} + '@codama/renderers-rust@1.0.1': + resolution: {integrity: sha512-O4M7XHAovUskq5rYvTIqQ/JBLJXiUpPaeb2r5TBH+3BSwcdV/zZLrecsPYdj47JeFgI8FECqNzXLdEI7wm3QtA==} - '@kinobi-so/renderers-rust@0.21.1': - resolution: {integrity: sha512-G2MmTdaAT2JbjZxIZobweVd9HmusxzaEFZeTL3Xc5Ke5aFth4z4JijkdftcdNS1K6N34/4/qg/IXbC43l/XSkw==} + '@codama/validators@1.0.0': + resolution: {integrity: sha512-jSfU5IrcGTvcqsJSBSzD3Ochig+hKKg2NKsT/vUfQ4jAw2cQrVUP5f4dMXyX779JYfHLHCwZnBYvgEdgi9gBZQ==} - '@kinobi-so/validators@0.21.0': - resolution: {integrity: sha512-mpBqgqlto/Wdj6rlf1mqWkyw00rPJw98bkNItXq+ofCEtBsjaMq9lsevCE+IPmfJJYEPFGHGJW4Gb6m/cLmOqw==} + '@codama/visitors-core@1.0.0': + resolution: {integrity: sha512-tDIfURVPf7ZokCFLOpKL6Au0ORiza1sPT4zmRSEjCC7iZp0Vb5K5FrdtUL13Wb+6jNM191e5GUFOmULRoavWug==} - '@kinobi-so/visitors-core@0.21.0': - resolution: {integrity: sha512-m6C/cAy7q7ZAWhByQGo2YnBsbt0qS3Un0lyT4mmPGQt0QFXUDExFipjTvY/NnzZ5lQJ2grvnL04pqLx8V7eiuw==} + '@codama/visitors@1.0.0': + resolution: {integrity: sha512-JncE6wRJLxt0imlj+loGH6dLPEMK7ozlv9YjWgCQgUYUI7is66OFwhWP5SFO0iEFlVjtOzZLXVQwoe9LSDz8Gg==} - '@kinobi-so/visitors@0.21.0': - resolution: {integrity: sha512-gigysLJCfVtNCFkdDMeHGB+1SOvoiQOPUVKxewzOq1wDYVioFmmf4aXfB1GCEslLlMvl63cTJrwvh8bDIZoaSA==} + '@iarna/toml@2.2.5': + resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} - '@noble/hashes@1.4.0': - resolution: {integrity: sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==} - engines: {node: '>= 16'} + '@noble/hashes@1.5.0': + resolution: {integrity: sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==} + engines: {node: ^14.21.3 || >=16} '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} @@ -79,24 +79,24 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} - '@solana/codecs-core@2.0.0-preview.4': - resolution: {integrity: sha512-A0VVuDDA5kNKZUinOqHxJQK32aKTucaVbvn31YenGzHX1gPqq+SOnFwgaEY6pq4XEopSmaK16w938ZQS8IvCnw==} + '@solana/codecs-core@2.0.0-rc.1': + resolution: {integrity: sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ==} peerDependencies: typescript: '>=5' - '@solana/codecs-numbers@2.0.0-preview.4': - resolution: {integrity: sha512-Q061rLtMadsO7uxpguT+Z7G4UHnjQ6moVIxAQxR58nLxDPCC7MB1Pk106/Z7NDhDLHTcd18uO6DZ7ajHZEn2XQ==} + '@solana/codecs-numbers@2.0.0-rc.1': + resolution: {integrity: sha512-J5i5mOkvukXn8E3Z7sGIPxsThRCgSdgTWJDQeZvucQ9PT6Y3HiVXJ0pcWiOWAoQ3RX8e/f4I3IC+wE6pZiJzDQ==} peerDependencies: typescript: '>=5' - '@solana/codecs-strings@2.0.0-preview.4': - resolution: {integrity: sha512-YDbsQePRWm+xnrfS64losSGRg8Wb76cjK1K6qfR8LPmdwIC3787x9uW5/E4icl/k+9nwgbIRXZ65lpF+ucZUnw==} + '@solana/codecs-strings@2.0.0-rc.1': + resolution: {integrity: sha512-9/wPhw8TbGRTt6mHC4Zz1RqOnuPTqq1Nb4EyuvpZ39GW6O2t2Q7Q0XxiB3+BdoEjwA2XgPw6e2iRfvYgqty44g==} peerDependencies: fastestsmallesttextencoderdecoder: ^1.0.22 typescript: '>=5' - '@solana/errors@2.0.0-preview.4': - resolution: {integrity: sha512-kadtlbRv2LCWr8A9V22On15Us7Nn8BvqNaOB4hXsTB3O0fU40D1ru2l+cReqLcRPij4znqlRzW9Xi0m6J5DIhA==} + '@solana/errors@2.0.0-rc.1': + resolution: {integrity: sha512-ejNvQ2oJ7+bcFAYWj225lyRkHnixuAeb7RQCixm+5mH4n1IA4Qya/9Bmfy5RAAHQzxK43clu3kZmL5eF9VGtYQ==} hasBin: true peerDependencies: typescript: '>=5' @@ -137,6 +137,9 @@ packages: resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + codama@1.0.0: + resolution: {integrity: sha512-ttJ9n2THpqTD8fP8reec+Y2j4ZTBuonDJk8SiKuS6enZBXd67JF3b+GFKM2S5a0xtxN5Evof5aBlY3JyC+jujQ==} + commander@12.1.0: resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==} engines: {node: '>=18'} @@ -272,9 +275,6 @@ packages: jsonify@0.0.1: resolution: {integrity: sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==} - kinobi@0.21.0: - resolution: {integrity: sha512-T71VNh4yS8uSvtNp1FEWhJGygW5/8O82SAlFRlPYsWiwqWH9X3eZwwUthBVH7dfazqs8GLia0rAMEmUP99iwLw==} - map-stream@0.1.0: resolution: {integrity: sha512-CkYQrPYZfWnu/DAmVCpTSX/xHpKZ80eKh2lAkyA6AJTef6bW+6JpbQZN5rofum7da+SyN1bi5ctTm+lTfcCW3g==} @@ -400,42 +400,40 @@ packages: snapshots: - '@iarna/toml@2.2.5': {} - - '@kinobi-so/errors@0.21.0': + '@codama/errors@1.0.0': dependencies: - '@kinobi-so/node-types': 0.21.0 + '@codama/node-types': 1.0.0 chalk: 5.3.0 commander: 12.1.0 - '@kinobi-so/node-types@0.21.0': {} + '@codama/node-types@1.0.0': {} - '@kinobi-so/nodes-from-anchor@0.20.9': + '@codama/nodes-from-anchor@1.0.0': dependencies: - '@kinobi-so/errors': 0.21.0 - '@kinobi-so/nodes': 0.21.0 - '@kinobi-so/visitors': 0.21.0 - '@noble/hashes': 1.4.0 + '@codama/errors': 1.0.0 + '@codama/nodes': 1.0.0 + '@codama/visitors': 1.0.0 + '@noble/hashes': 1.5.0 - '@kinobi-so/nodes@0.21.0': + '@codama/nodes@1.0.0': dependencies: - '@kinobi-so/errors': 0.21.0 - '@kinobi-so/node-types': 0.21.0 + '@codama/errors': 1.0.0 + '@codama/node-types': 1.0.0 - '@kinobi-so/renderers-core@0.20.7': + '@codama/renderers-core@1.0.0': dependencies: - '@kinobi-so/errors': 0.21.0 - '@kinobi-so/nodes': 0.21.0 - '@kinobi-so/visitors-core': 0.21.0 + '@codama/errors': 1.0.0 + '@codama/nodes': 1.0.0 + '@codama/visitors-core': 1.0.0 - '@kinobi-so/renderers-js@0.21.2(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)': + '@codama/renderers-js@1.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)': dependencies: - '@kinobi-so/errors': 0.21.0 - '@kinobi-so/nodes': 0.21.0 - '@kinobi-so/nodes-from-anchor': 0.20.9 - '@kinobi-so/renderers-core': 0.20.7 - '@kinobi-so/visitors-core': 0.21.0 - '@solana/codecs-strings': 2.0.0-preview.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) + '@codama/errors': 1.0.0 + '@codama/nodes': 1.0.0 + '@codama/nodes-from-anchor': 1.0.0 + '@codama/renderers-core': 1.0.0 + '@codama/visitors-core': 1.0.0 + '@solana/codecs-strings': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) nunjucks: 3.2.4 prettier: 3.3.3 transitivePeerDependencies: @@ -443,38 +441,40 @@ snapshots: - fastestsmallesttextencoderdecoder - typescript - '@kinobi-so/renderers-rust@0.21.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)': + '@codama/renderers-rust@1.0.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)': dependencies: - '@kinobi-so/errors': 0.21.0 - '@kinobi-so/nodes': 0.21.0 - '@kinobi-so/renderers-core': 0.20.7 - '@kinobi-so/visitors-core': 0.21.0 - '@solana/codecs-strings': 2.0.0-preview.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) + '@codama/errors': 1.0.0 + '@codama/nodes': 1.0.0 + '@codama/renderers-core': 1.0.0 + '@codama/visitors-core': 1.0.0 + '@solana/codecs-strings': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4) nunjucks: 3.2.4 transitivePeerDependencies: - chokidar - fastestsmallesttextencoderdecoder - typescript - '@kinobi-so/validators@0.21.0': + '@codama/validators@1.0.0': dependencies: - '@kinobi-so/errors': 0.21.0 - '@kinobi-so/nodes': 0.21.0 - '@kinobi-so/visitors-core': 0.21.0 + '@codama/errors': 1.0.0 + '@codama/nodes': 1.0.0 + '@codama/visitors-core': 1.0.0 - '@kinobi-so/visitors-core@0.21.0': + '@codama/visitors-core@1.0.0': dependencies: - '@kinobi-so/errors': 0.21.0 - '@kinobi-so/nodes': 0.21.0 + '@codama/errors': 1.0.0 + '@codama/nodes': 1.0.0 json-stable-stringify: 1.1.1 - '@kinobi-so/visitors@0.21.0': + '@codama/visitors@1.0.0': dependencies: - '@kinobi-so/errors': 0.21.0 - '@kinobi-so/nodes': 0.21.0 - '@kinobi-so/visitors-core': 0.21.0 + '@codama/errors': 1.0.0 + '@codama/nodes': 1.0.0 + '@codama/visitors-core': 1.0.0 + + '@iarna/toml@2.2.5': {} - '@noble/hashes@1.4.0': {} + '@noble/hashes@1.5.0': {} '@nodelib/fs.scandir@2.1.5': dependencies: @@ -488,26 +488,26 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.17.1 - '@solana/codecs-core@2.0.0-preview.4(typescript@5.5.4)': + '@solana/codecs-core@2.0.0-rc.1(typescript@5.5.4)': dependencies: - '@solana/errors': 2.0.0-preview.4(typescript@5.5.4) + '@solana/errors': 2.0.0-rc.1(typescript@5.5.4) typescript: 5.5.4 - '@solana/codecs-numbers@2.0.0-preview.4(typescript@5.5.4)': + '@solana/codecs-numbers@2.0.0-rc.1(typescript@5.5.4)': dependencies: - '@solana/codecs-core': 2.0.0-preview.4(typescript@5.5.4) - '@solana/errors': 2.0.0-preview.4(typescript@5.5.4) + '@solana/codecs-core': 2.0.0-rc.1(typescript@5.5.4) + '@solana/errors': 2.0.0-rc.1(typescript@5.5.4) typescript: 5.5.4 - '@solana/codecs-strings@2.0.0-preview.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)': + '@solana/codecs-strings@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.5.4)': dependencies: - '@solana/codecs-core': 2.0.0-preview.4(typescript@5.5.4) - '@solana/codecs-numbers': 2.0.0-preview.4(typescript@5.5.4) - '@solana/errors': 2.0.0-preview.4(typescript@5.5.4) + '@solana/codecs-core': 2.0.0-rc.1(typescript@5.5.4) + '@solana/codecs-numbers': 2.0.0-rc.1(typescript@5.5.4) + '@solana/errors': 2.0.0-rc.1(typescript@5.5.4) fastestsmallesttextencoderdecoder: 1.0.22 typescript: 5.5.4 - '@solana/errors@2.0.0-preview.4(typescript@5.5.4)': + '@solana/errors@2.0.0-rc.1(typescript@5.5.4)': dependencies: chalk: 5.3.0 commander: 12.1.0 @@ -550,6 +550,13 @@ snapshots: chalk@5.3.0: {} + codama@1.0.0: + dependencies: + '@codama/errors': 1.0.0 + '@codama/nodes': 1.0.0 + '@codama/validators': 1.0.0 + '@codama/visitors': 1.0.0 + commander@12.1.0: {} commander@5.1.0: {} @@ -690,13 +697,6 @@ snapshots: jsonify@0.0.1: {} - kinobi@0.21.0: - dependencies: - '@kinobi-so/errors': 0.21.0 - '@kinobi-so/nodes': 0.21.0 - '@kinobi-so/validators': 0.21.0 - '@kinobi-so/visitors': 0.21.0 - map-stream@0.1.0: {} merge2@1.4.1: {} diff --git a/program/idl.json b/program/idl.json index 28d29a2..a31c741 100644 --- a/program/idl.json +++ b/program/idl.json @@ -13,31 +13,8 @@ "kind": "structFieldTypeNode", "name": "keys", "type": { - "kind": "arrayTypeNode", - "item": { - "kind": "tupleTypeNode", - "items": [ - { - "kind": "publicKeyTypeNode" - }, - { - "kind": "booleanTypeNode", - "size": { - "kind": "numberTypeNode", - "format": "u8", - "endian": "le" - } - } - ] - }, - "count": { - "kind": "prefixedCountNode", - "prefix": { - "kind": "numberTypeNode", - "format": "shortU16", - "endian": "le" - } - } + "kind": "definedTypeLinkNode", + "name": "configKeys" }, "docs": [ "List of pubkeys stored in the config account,", @@ -80,31 +57,8 @@ "kind": "instructionArgumentNode", "name": "keys", "type": { - "kind": "arrayTypeNode", - "item": { - "kind": "tupleTypeNode", - "items": [ - { - "kind": "publicKeyTypeNode" - }, - { - "kind": "booleanTypeNode", - "size": { - "kind": "numberTypeNode", - "format": "u8", - "endian": "le" - } - } - ] - }, - "count": { - "kind": "prefixedCountNode", - "prefix": { - "kind": "numberTypeNode", - "format": "shortU16", - "endian": "le" - } - } + "kind": "definedTypeLinkNode", + "name": "configKeys" }, "docs": [ "List of pubkeys to store in the config account,", @@ -141,15 +95,52 @@ "optionalAccountStrategy": "omitted" } ], - "definedTypes": [], + "definedTypes": [ + { + "kind": "definedTypeNode", + "name": "configKeys", + "type": { + "kind": "arrayTypeNode", + "item": { + "kind": "tupleTypeNode", + "items": [ + { + "kind": "publicKeyTypeNode" + }, + { + "kind": "booleanTypeNode", + "size": { + "kind": "numberTypeNode", + "format": "u8", + "endian": "le" + } + } + ] + }, + "count": { + "kind": "prefixedCountNode", + "prefix": { + "kind": "numberTypeNode", + "format": "shortU16", + "endian": "le" + } + } + }, + "docs": [ + "A collection of keys to be stored in Config account data.", + "Each key tuple comprises a unique `Pubkey` identifier,", + "and `bool` whether that key is a signer of the data." + ] + } + ], "errors": [], - "name": "solanaConfigProgram", + "name": "solanaConfig", "prefix": "", "publicKey": "Config1111111111111111111111111111111111111", "version": "0.0.1", "origin": "shank" }, "additionalPrograms": [], - "standard": "kinobi", - "version": "0.19.0" + "standard": "codama", + "version": "1.0.0" } diff --git a/scripts/generate-clients.mjs b/scripts/generate-clients.mjs index a317a9a..42b0bca 100644 --- a/scripts/generate-clients.mjs +++ b/scripts/generate-clients.mjs @@ -1,58 +1,40 @@ #!/usr/bin/env zx import 'zx/globals'; -import * as k from "kinobi"; -import { renderVisitor as renderJavaScriptVisitor } from '@kinobi-so/renderers-js'; -import { renderVisitor as renderRustVisitor } from '@kinobi-so/renderers-rust'; +import { createFromRoot, deleteNodesVisitor } from 'codama'; +import { renderVisitor as renderJavaScriptVisitor } from '@codama/renderers-js'; +import { renderVisitor as renderRustVisitor } from '@codama/renderers-rust'; import { getToolchainArgument, workingDirectory } from './utils.mjs'; -// Instanciate Kinobi. -const kinobi = k.createFromRoot( +// Instanciate Codama. +const codama = createFromRoot( require(path.join(workingDirectory, 'program', 'idl.json')) ); -// Update programs. -kinobi.update( - k.updateProgramsVisitor({ - "solanaConfigProgram": { name: "solanaConfig" }, - }) -); - -// Add missing types from the IDL. -kinobi.update( - k.bottomUpTransformerVisitor([ - { - select: (node) => { - const names = ["keys"]; - return ( - names.includes(node.name) && - (k.isNode(node, "instructionArgumentNode") || k.isNode(node, "structFieldTypeNode")) && - k.isNode(node.type, "arrayTypeNode") - ); - }, - transform: (node) => { - return { - ...node, - type: k.definedTypeLinkNode("configKeys", "hooked"), - }; - }, - }, - ]) -); - // Render JavaScript. const jsClient = path.join(__dirname, '..', 'clients', 'js'); -kinobi.accept( +codama.accept( renderJavaScriptVisitor(path.join(jsClient, 'src', 'generated'), { prettier: require(path.join(jsClient, '.prettierrc.json')), }) ); +// FIXME: Currently, the Rust renderer fails to generate a `ShortVec` because +// it requires extra traits such as `BorshSerialize` that are not implemented +// on the `ShortVec` type. To work around this issue, we remove the `configKeys` +// type from Rust code generation and use a hooked type for it instead. +codama.update(deleteNodesVisitor(['[definedTypeNode]configKeys'])); + // Render Rust. const rustClient = path.join(__dirname, '..', 'clients', 'rust'); -kinobi.accept( +codama.accept( renderRustVisitor(path.join(rustClient, 'src', 'generated'), { formatCode: true, crateFolder: rustClient, toolchain: getToolchainArgument('format'), + + // FIXME: The second part of the workaround for the `ShortVec` issue mentioned above. + linkOverrides: { + definedTypes: { configKeys: 'hooked' }, + }, }) -); \ No newline at end of file +);