Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-teeth-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@codama/renderers-js': patch
---

Include JSDoc comments for generated accounts
4 changes: 4 additions & 0 deletions src/fragments/accountType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ export function getAccountTypeFragment(
if (customAccountData.has(accountNode.name)) return;

return getTypeWithCodecFragment({
codecDocs: [`Gets the codec for {@link ${nameApi.dataType(accountNode.name)}} account data.`],
decoderDocs: [`Gets the decoder for {@link ${nameApi.dataType(accountNode.name)}} account data.`],
encoderDocs: [`Gets the encoder for {@link ${nameApi.dataArgsType(accountNode.name)}} account data.`],
manifest: typeManifest,
name: accountNode.name,
nameApi,
node: resolveNestedTypeNode(accountNode.data),
size: scope.size,
typeDocs: accountNode.docs,
});
}
3 changes: 3 additions & 0 deletions test/e2e/anchor/src/generated/accounts/guardV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export type GuardV1Args = {
additionalFieldsRule: Array<MetadataAdditionalFieldRuleArgs>;
};

/** Gets the encoder for {@link GuardV1Args} account data. */
export function getGuardV1Encoder(): Encoder<GuardV1Args> {
return transformEncoder(
getStructEncoder([
Expand All @@ -109,6 +110,7 @@ export function getGuardV1Encoder(): Encoder<GuardV1Args> {
);
}

/** Gets the decoder for {@link GuardV1} account data. */
export function getGuardV1Decoder(): Decoder<GuardV1> {
return getStructDecoder([
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
Expand All @@ -123,6 +125,7 @@ export function getGuardV1Decoder(): Decoder<GuardV1> {
]);
}

/** Gets the codec for {@link GuardV1} account data. */
export function getGuardV1Codec(): Codec<GuardV1Args, GuardV1> {
return combineCodec(getGuardV1Encoder(), getGuardV1Decoder());
}
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/system/src/generated/accounts/nonce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export type NonceArgs = {
lamportsPerSignature: Lamports;
};

/** Gets the encoder for {@link NonceArgs} account data. */
export function getNonceEncoder(): FixedSizeEncoder<NonceArgs> {
return getStructEncoder([
['version', getNonceVersionEncoder()],
Expand All @@ -70,6 +71,7 @@ export function getNonceEncoder(): FixedSizeEncoder<NonceArgs> {
]);
}

/** Gets the decoder for {@link Nonce} account data. */
export function getNonceDecoder(): FixedSizeDecoder<Nonce> {
return getStructDecoder([
['version', getNonceVersionDecoder()],
Expand All @@ -80,6 +82,7 @@ export function getNonceDecoder(): FixedSizeDecoder<Nonce> {
]);
}

/** Gets the codec for {@link Nonce} account data. */
export function getNonceCodec(): FixedSizeCodec<NonceArgs, Nonce> {
return combineCodec(getNonceEncoder(), getNonceDecoder());
}
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/token/idl.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
}
],
"name": "mint",
"docs": [],
"docs": ["Uniquely represents a token on the network and stores global metadata about the token."],
"size": 82
},
{
Expand Down Expand Up @@ -199,7 +199,7 @@
}
],
"name": "token",
"docs": [],
"docs": ["Stores information about an individual's ownership of a specific token (mint). Each token account is associated with a single mint and tracks details like the token balance and owner."],
"size": 165
},
{
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/token/src/generated/accounts/mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
type OptionOrNullable,
} from '@solana/kit';

/** Uniquely represents a token on the network and stores global metadata about the token. */
export type Mint = {
/**
* Optional authority used to mint new tokens. The mint authority may only
Expand Down Expand Up @@ -75,6 +76,7 @@ export type MintArgs = {
freezeAuthority: OptionOrNullable<Address>;
};

/** Gets the encoder for {@link MintArgs} account data. */
export function getMintEncoder(): FixedSizeEncoder<MintArgs> {
return getStructEncoder([
[
Expand All @@ -97,6 +99,7 @@ export function getMintEncoder(): FixedSizeEncoder<MintArgs> {
]);
}

/** Gets the decoder for {@link Mint} account data. */
export function getMintDecoder(): FixedSizeDecoder<Mint> {
return getStructDecoder([
[
Expand All @@ -119,6 +122,7 @@ export function getMintDecoder(): FixedSizeDecoder<Mint> {
]);
}

/** Gets the codec for {@link Mint} account data. */
export function getMintCodec(): FixedSizeCodec<MintArgs, Mint> {
return combineCodec(getMintEncoder(), getMintDecoder());
}
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/token/src/generated/accounts/multisig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type Multisig = {

export type MultisigArgs = Multisig;

/** Gets the encoder for {@link MultisigArgs} account data. */
export function getMultisigEncoder(): FixedSizeEncoder<MultisigArgs> {
return getStructEncoder([
['m', getU8Encoder()],
Expand All @@ -57,6 +58,7 @@ export function getMultisigEncoder(): FixedSizeEncoder<MultisigArgs> {
]);
}

/** Gets the decoder for {@link Multisig} account data. */
export function getMultisigDecoder(): FixedSizeDecoder<Multisig> {
return getStructDecoder([
['m', getU8Decoder()],
Expand All @@ -66,6 +68,7 @@ export function getMultisigDecoder(): FixedSizeDecoder<Multisig> {
]);
}

/** Gets the codec for {@link Multisig} account data. */
export function getMultisigCodec(): FixedSizeCodec<MultisigArgs, Multisig> {
return combineCodec(getMultisigEncoder(), getMultisigDecoder());
}
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/token/src/generated/accounts/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
type AccountStateArgs,
} from '../types';

/** Stores information about an individual's ownership of a specific token (mint). Each token account is associated with a single mint and tracks details like the token balance and owner. */
export type Token = {
/** The mint associated with this account. */
mint: Address;
Expand Down Expand Up @@ -97,6 +98,7 @@ export type TokenArgs = {
closeAuthority: OptionOrNullable<Address>;
};

/** Gets the encoder for {@link TokenArgs} account data. */
export function getTokenEncoder(): FixedSizeEncoder<TokenArgs> {
return getStructEncoder([
['mint', getAddressEncoder()],
Expand Down Expand Up @@ -128,6 +130,7 @@ export function getTokenEncoder(): FixedSizeEncoder<TokenArgs> {
]);
}

/** Gets the decoder for {@link Token} account data. */
export function getTokenDecoder(): FixedSizeDecoder<Token> {
return getStructDecoder([
['mint', getAddressDecoder()],
Expand Down Expand Up @@ -159,6 +162,7 @@ export function getTokenDecoder(): FixedSizeDecoder<Token> {
]);
}

/** Gets the codec for {@link Token} account data. */
export function getTokenCodec(): FixedSizeCodec<TokenArgs, Token> {
return combineCodec(getTokenEncoder(), getTokenDecoder());
}
Expand Down