Browse Source

Improve Kinobi IDL

Loris Leiva 1 year ago
parent
commit
c59dc48cbf

+ 12 - 0
clients/js/src/generated/instructions/createAssociatedToken.ts

@@ -65,11 +65,17 @@ export type CreateAssociatedTokenInput<
   TAccountSystemProgram extends string = string,
   TAccountTokenProgram extends string = string,
 > = {
+  /** Funding account (must be a system account). */
   payer: TransactionSigner<TAccountPayer>;
+  /** Associated token account address to be created. */
   ata: Address<TAccountAta>;
+  /** Wallet address for the new associated token account. */
   owner: Address<TAccountOwner>;
+  /** The token mint for the new associated token account. */
   mint: Address<TAccountMint>;
+  /** System program. */
   systemProgram?: Address<TAccountSystemProgram>;
+  /** SPL Token program. */
   tokenProgram?: Address<TAccountTokenProgram>;
 };
 
@@ -155,11 +161,17 @@ export type ParsedCreateAssociatedTokenInstruction<
 > = {
   programAddress: Address<TProgram>;
   accounts: {
+    /** Funding account (must be a system account). */
     payer: TAccountMetas[0];
+    /** Associated token account address to be created. */
     ata: TAccountMetas[1];
+    /** Wallet address for the new associated token account. */
     owner: TAccountMetas[2];
+    /** The token mint for the new associated token account. */
     mint: TAccountMetas[3];
+    /** System program. */
     systemProgram: TAccountMetas[4];
+    /** SPL Token program. */
     tokenProgram: TAccountMetas[5];
   };
 };

+ 21 - 9
clients/js/src/generated/instructions/createIdempotentAssociatedToken.ts → clients/js/src/generated/instructions/createAssociatedTokenIdempotent.ts

@@ -20,7 +20,7 @@ import {
 import { ASSOCIATED_TOKEN_PROGRAM_ADDRESS } from '../programs';
 import { ResolvedAccount, getAccountMetaFactory } from '../shared';
 
-export type CreateIdempotentAssociatedTokenInstruction<
+export type CreateAssociatedTokenIdempotentInstruction<
   TProgram extends string = typeof ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
   TAccountPayer extends string | IAccountMeta<string> = string,
   TAccountAta extends string | IAccountMeta<string> = string,
@@ -57,7 +57,7 @@ export type CreateIdempotentAssociatedTokenInstruction<
     ]
   >;
 
-export type CreateIdempotentAssociatedTokenInput<
+export type CreateAssociatedTokenIdempotentInput<
   TAccountPayer extends string = string,
   TAccountAta extends string = string,
   TAccountOwner extends string = string,
@@ -65,15 +65,21 @@ export type CreateIdempotentAssociatedTokenInput<
   TAccountSystemProgram extends string = string,
   TAccountTokenProgram extends string = string,
 > = {
+  /** Funding account (must be a system account). */
   payer: TransactionSigner<TAccountPayer>;
+  /** Associated token account address to be created. */
   ata: Address<TAccountAta>;
+  /** Wallet address for the new associated token account. */
   owner: Address<TAccountOwner>;
+  /** The token mint for the new associated token account. */
   mint: Address<TAccountMint>;
+  /** System program. */
   systemProgram?: Address<TAccountSystemProgram>;
+  /** SPL Token program. */
   tokenProgram?: Address<TAccountTokenProgram>;
 };
 
-export function getCreateIdempotentAssociatedTokenInstruction<
+export function getCreateAssociatedTokenIdempotentInstruction<
   TAccountPayer extends string,
   TAccountAta extends string,
   TAccountOwner extends string,
@@ -81,7 +87,7 @@ export function getCreateIdempotentAssociatedTokenInstruction<
   TAccountSystemProgram extends string,
   TAccountTokenProgram extends string,
 >(
-  input: CreateIdempotentAssociatedTokenInput<
+  input: CreateAssociatedTokenIdempotentInput<
     TAccountPayer,
     TAccountAta,
     TAccountOwner,
@@ -89,7 +95,7 @@ export function getCreateIdempotentAssociatedTokenInstruction<
     TAccountSystemProgram,
     TAccountTokenProgram
   >
-): CreateIdempotentAssociatedTokenInstruction<
+): CreateAssociatedTokenIdempotentInstruction<
   typeof ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
   TAccountPayer,
   TAccountAta,
@@ -136,7 +142,7 @@ export function getCreateIdempotentAssociatedTokenInstruction<
       getAccountMeta(accounts.tokenProgram),
     ],
     programAddress,
-  } as CreateIdempotentAssociatedTokenInstruction<
+  } as CreateAssociatedTokenIdempotentInstruction<
     typeof ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
     TAccountPayer,
     TAccountAta,
@@ -149,27 +155,33 @@ export function getCreateIdempotentAssociatedTokenInstruction<
   return instruction;
 }
 
-export type ParsedCreateIdempotentAssociatedTokenInstruction<
+export type ParsedCreateAssociatedTokenIdempotentInstruction<
   TProgram extends string = typeof ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
   TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[],
 > = {
   programAddress: Address<TProgram>;
   accounts: {
+    /** Funding account (must be a system account). */
     payer: TAccountMetas[0];
+    /** Associated token account address to be created. */
     ata: TAccountMetas[1];
+    /** Wallet address for the new associated token account. */
     owner: TAccountMetas[2];
+    /** The token mint for the new associated token account. */
     mint: TAccountMetas[3];
+    /** System program. */
     systemProgram: TAccountMetas[4];
+    /** SPL Token program. */
     tokenProgram: TAccountMetas[5];
   };
 };
 
-export function parseCreateIdempotentAssociatedTokenInstruction<
+export function parseCreateAssociatedTokenIdempotentInstruction<
   TProgram extends string,
   TAccountMetas extends readonly IAccountMeta[],
 >(
   instruction: IInstruction<TProgram> & IInstructionWithAccounts<TAccountMetas>
-): ParsedCreateIdempotentAssociatedTokenInstruction<TProgram, TAccountMetas> {
+): ParsedCreateAssociatedTokenIdempotentInstruction<TProgram, TAccountMetas> {
   if (instruction.accounts.length < 6) {
     // TODO: Coded error.
     throw new Error('Not enough accounts');

+ 1 - 1
clients/js/src/generated/instructions/index.ts

@@ -13,7 +13,7 @@ export * from './burn';
 export * from './burnChecked';
 export * from './closeAccount';
 export * from './createAssociatedToken';
-export * from './createIdempotentAssociatedToken';
+export * from './createAssociatedTokenIdempotent';
 export * from './freezeAccount';
 export * from './getAccountDataSize';
 export * from './initializeAccount';

+ 14 - 0
clients/js/src/generated/instructions/recoverNestedAssociatedToken.ts

@@ -76,12 +76,19 @@ export type RecoverNestedAssociatedTokenInput<
   TAccountWalletAddress extends string = string,
   TAccountTokenProgram extends string = string,
 > = {
+  /** Nested associated token account, must be owned by `ownerAssociatedAccountAddress`. */
   nestedAssociatedAccountAddress: Address<TAccountNestedAssociatedAccountAddress>;
+  /** Token mint for the nested associated token account. */
   nestedTokenMintAddress: Address<TAccountNestedTokenMintAddress>;
+  /** Wallet's associated token account. */
   destinationAssociatedAccountAddress: Address<TAccountDestinationAssociatedAccountAddress>;
+  /** Owner associated token account address, must be owned by `walletAddress`. */
   ownerAssociatedAccountAddress: Address<TAccountOwnerAssociatedAccountAddress>;
+  /** Token mint for the owner associated token account. */
   ownerTokenMintAddress: Address<TAccountOwnerTokenMintAddress>;
+  /** Wallet address for the owner associated token account. */
   walletAddress: TransactionSigner<TAccountWalletAddress>;
+  /** SPL Token program. */
   tokenProgram?: Address<TAccountTokenProgram>;
 };
 
@@ -184,12 +191,19 @@ export type ParsedRecoverNestedAssociatedTokenInstruction<
 > = {
   programAddress: Address<TProgram>;
   accounts: {
+    /** Nested associated token account, must be owned by `ownerAssociatedAccountAddress`. */
     nestedAssociatedAccountAddress: TAccountMetas[0];
+    /** Token mint for the nested associated token account. */
     nestedTokenMintAddress: TAccountMetas[1];
+    /** Wallet's associated token account. */
     destinationAssociatedAccountAddress: TAccountMetas[2];
+    /** Owner associated token account address, must be owned by `walletAddress`. */
     ownerAssociatedAccountAddress: TAccountMetas[3];
+    /** Token mint for the owner associated token account. */
     ownerTokenMintAddress: TAccountMetas[4];
+    /** Wallet address for the owner associated token account. */
     walletAddress: TAccountMetas[5];
+    /** SPL Token program. */
     tokenProgram: TAccountMetas[6];
   };
 };

+ 4 - 4
clients/js/src/generated/programs/associatedToken.ts

@@ -8,8 +8,8 @@
 
 import { Address } from '@solana/web3.js';
 import {
+  ParsedCreateAssociatedTokenIdempotentInstruction,
   ParsedCreateAssociatedTokenInstruction,
-  ParsedCreateIdempotentAssociatedTokenInstruction,
   ParsedRecoverNestedAssociatedTokenInstruction,
 } from '../instructions';
 
@@ -18,7 +18,7 @@ export const ASSOCIATED_TOKEN_PROGRAM_ADDRESS =
 
 export enum AssociatedTokenInstruction {
   CreateAssociatedToken,
-  CreateIdempotentAssociatedToken,
+  CreateAssociatedTokenIdempotent,
   RecoverNestedAssociatedToken,
 }
 
@@ -29,8 +29,8 @@ export type ParsedAssociatedTokenInstruction<
       instructionType: AssociatedTokenInstruction.CreateAssociatedToken;
     } & ParsedCreateAssociatedTokenInstruction<TProgram>)
   | ({
-      instructionType: AssociatedTokenInstruction.CreateIdempotentAssociatedToken;
-    } & ParsedCreateIdempotentAssociatedTokenInstruction<TProgram>)
+      instructionType: AssociatedTokenInstruction.CreateAssociatedTokenIdempotent;
+    } & ParsedCreateAssociatedTokenIdempotentInstruction<TProgram>)
   | ({
       instructionType: AssociatedTokenInstruction.RecoverNestedAssociatedToken;
     } & ParsedRecoverNestedAssociatedTokenInstruction<TProgram>);

+ 50 - 33
program/idl.json

@@ -2262,7 +2262,7 @@
               "isWritable": true,
               "isSigner": true,
               "isOptional": false,
-              "docs": [],
+              "docs": ["Funding account (must be a system account)."],
               "defaultValue": { "kind": "payerValueNode" }
             },
             {
@@ -2271,7 +2271,7 @@
               "isWritable": true,
               "isSigner": false,
               "isOptional": false,
-              "docs": []
+              "docs": ["Associated token account address to be created."]
             },
             {
               "kind": "instructionAccountNode",
@@ -2279,7 +2279,7 @@
               "isWritable": false,
               "isSigner": false,
               "isOptional": false,
-              "docs": []
+              "docs": ["Wallet address for the new associated token account."]
             },
             {
               "kind": "instructionAccountNode",
@@ -2287,7 +2287,7 @@
               "isWritable": false,
               "isSigner": false,
               "isOptional": false,
-              "docs": []
+              "docs": ["The token mint for the new associated token account."]
             },
             {
               "kind": "instructionAccountNode",
@@ -2295,11 +2295,10 @@
               "isWritable": false,
               "isSigner": false,
               "isOptional": false,
-              "docs": [],
+              "docs": ["System program."],
               "defaultValue": {
                 "kind": "publicKeyValueNode",
-                "publicKey": "11111111111111111111111111111111",
-                "identifier": "splSystem"
+                "publicKey": "11111111111111111111111111111111"
               }
             },
             {
@@ -2308,17 +2307,19 @@
               "isWritable": false,
               "isSigner": false,
               "isOptional": false,
-              "docs": [],
+              "docs": ["SPL Token program."],
               "defaultValue": {
                 "kind": "publicKeyValueNode",
-                "publicKey": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
-                "identifier": "splToken"
+                "publicKey": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
               }
             }
           ],
           "arguments": [],
           "name": "createAssociatedToken",
-          "docs": [],
+          "docs": [
+            "Creates an associated token account for the given wallet address and",
+            "token mint Returns an error if the account exists."
+          ],
           "optionalAccountStrategy": "programId"
         },
         {
@@ -2330,7 +2331,7 @@
               "isWritable": true,
               "isSigner": true,
               "isOptional": false,
-              "docs": [],
+              "docs": ["Funding account (must be a system account)."],
               "defaultValue": { "kind": "payerValueNode" }
             },
             {
@@ -2339,7 +2340,7 @@
               "isWritable": true,
               "isSigner": false,
               "isOptional": false,
-              "docs": []
+              "docs": ["Associated token account address to be created."]
             },
             {
               "kind": "instructionAccountNode",
@@ -2347,7 +2348,7 @@
               "isWritable": false,
               "isSigner": false,
               "isOptional": false,
-              "docs": []
+              "docs": ["Wallet address for the new associated token account."]
             },
             {
               "kind": "instructionAccountNode",
@@ -2355,7 +2356,7 @@
               "isWritable": false,
               "isSigner": false,
               "isOptional": false,
-              "docs": []
+              "docs": ["The token mint for the new associated token account."]
             },
             {
               "kind": "instructionAccountNode",
@@ -2363,11 +2364,10 @@
               "isWritable": false,
               "isSigner": false,
               "isOptional": false,
-              "docs": [],
+              "docs": ["System program."],
               "defaultValue": {
                 "kind": "publicKeyValueNode",
-                "publicKey": "11111111111111111111111111111111",
-                "identifier": "splSystem"
+                "publicKey": "11111111111111111111111111111111"
               }
             },
             {
@@ -2376,17 +2376,20 @@
               "isWritable": false,
               "isSigner": false,
               "isOptional": false,
-              "docs": [],
+              "docs": ["SPL Token program."],
               "defaultValue": {
                 "kind": "publicKeyValueNode",
-                "publicKey": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
-                "identifier": "splToken"
+                "publicKey": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
               }
             }
           ],
           "arguments": [],
-          "name": "createIdempotentAssociatedToken",
-          "docs": [],
+          "name": "createAssociatedTokenIdempotent",
+          "docs": [
+            "Creates an associated token account for the given wallet address and",
+            "token mint, if it doesn't already exist. Returns an error if the",
+            "account exists, but with a different owner."
+          ],
           "optionalAccountStrategy": "programId"
         },
         {
@@ -2398,7 +2401,9 @@
               "isWritable": true,
               "isSigner": false,
               "isOptional": false,
-              "docs": []
+              "docs": [
+                "Nested associated token account, must be owned by `ownerAssociatedAccountAddress`."
+              ]
             },
             {
               "kind": "instructionAccountNode",
@@ -2406,7 +2411,7 @@
               "isWritable": false,
               "isSigner": false,
               "isOptional": false,
-              "docs": []
+              "docs": ["Token mint for the nested associated token account."]
             },
             {
               "kind": "instructionAccountNode",
@@ -2414,7 +2419,7 @@
               "isWritable": true,
               "isSigner": false,
               "isOptional": false,
-              "docs": []
+              "docs": ["Wallet's associated token account."]
             },
             {
               "kind": "instructionAccountNode",
@@ -2422,7 +2427,9 @@
               "isWritable": false,
               "isSigner": false,
               "isOptional": false,
-              "docs": []
+              "docs": [
+                "Owner associated token account address, must be owned by `walletAddress`."
+              ]
             },
             {
               "kind": "instructionAccountNode",
@@ -2430,7 +2437,7 @@
               "isWritable": false,
               "isSigner": false,
               "isOptional": false,
-              "docs": []
+              "docs": ["Token mint for the owner associated token account."]
             },
             {
               "kind": "instructionAccountNode",
@@ -2438,7 +2445,7 @@
               "isWritable": true,
               "isSigner": true,
               "isOptional": false,
-              "docs": []
+              "docs": ["Wallet address for the owner associated token account."]
             },
             {
               "kind": "instructionAccountNode",
@@ -2446,17 +2453,27 @@
               "isWritable": false,
               "isSigner": false,
               "isOptional": false,
-              "docs": [],
+              "docs": ["SPL Token program."],
               "defaultValue": {
                 "kind": "publicKeyValueNode",
-                "publicKey": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
-                "identifier": "splToken"
+                "publicKey": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
               }
             }
           ],
           "arguments": [],
           "name": "recoverNestedAssociatedToken",
-          "docs": [],
+          "docs": [
+            "Transfers from and closes a nested associated token account: an",
+            "associated token account owned by an associated token account.",
+            "",
+            "The tokens are moved from the nested associated token account to the",
+            "wallet's associated token account, and the nested account lamports are",
+            "moved to the wallet.",
+            "",
+            "Note: Nested token accounts are an anti-pattern, and almost always",
+            "created unintentionally, so this instruction should only be used to",
+            "recover from errors."
+          ],
           "optionalAccountStrategy": "programId"
         }
       ],