Bläddra i källkod

refactor: type and name (#35)

Nick Frostbutter 9 månader sedan
förälder
incheckning
a1e342adfc

+ 5 - 0
.changeset/big-mugs-push.md

@@ -0,0 +1,5 @@
+---
+"gill": patch
+---
+
+refactor common type and use `feePayer` vs `payer` for consistency

+ 3 - 3
examples/esrun/src/tokens.ts

@@ -62,8 +62,8 @@ console.log("latestBlockhash:", latestBlockhash);
 const createTokenTx = await buildCreateTokenTransaction({
 const createTokenTx = await buildCreateTokenTransaction({
   mint,
   mint,
   latestBlockhash,
   latestBlockhash,
-  payer: signer,
-  // mintAuthority, // default=same as the `payer`
+  feePayer: signer,
+  // mintAuthority, // default=same as the `feePayer`
   metadata: {
   metadata: {
     isMutable: true, // if the `updateAuthority` can change this metadata in the future
     isMutable: true, // if the `updateAuthority` can change this metadata in the future
     name: "Only Possible On Solana",
     name: "Only Possible On Solana",
@@ -115,7 +115,7 @@ const destination = address("nicktrLHhYzLmoVbuZQzHUTicd2sfP571orwo9jfc8c");
  * - ensure the `mintAuthority` is the correct signer in order to actually mint new tokens
  * - ensure the `mintAuthority` is the correct signer in order to actually mint new tokens
  */
  */
 const mintTokensTx = await buildMintTokensTransaction({
 const mintTokensTx = await buildMintTokensTransaction({
-  payer: signer,
+  feePayer: signer,
   latestBlockhash,
   latestBlockhash,
   mint,
   mint,
   mintAuthority: signer,
   mintAuthority: signer,

+ 12 - 12
packages/gill/src/__tests__/create-token-instructions.ts

@@ -122,7 +122,7 @@ describe("getCreateTokenInstructions", () => {
 
 
   it("should create basic token instructions with default values", () => {
   it("should create basic token instructions with default values", () => {
     const args: GetCreateTokenInstructionsArgs = {
     const args: GetCreateTokenInstructionsArgs = {
-      payer: mockPayer,
+      feePayer: mockPayer,
       mint: mockMint,
       mint: mockMint,
       metadataAddress: mockMetadataAddress,
       metadataAddress: mockMetadataAddress,
       metadata,
       metadata,
@@ -174,7 +174,7 @@ describe("getCreateTokenInstructions", () => {
 
 
   it("should throw error for unsupported token program", () => {
   it("should throw error for unsupported token program", () => {
     const args: GetCreateTokenInstructionsArgs = {
     const args: GetCreateTokenInstructionsArgs = {
-      payer: mockPayer,
+      feePayer: mockPayer,
       mint: mockMint,
       mint: mockMint,
       metadataAddress: mockMetadataAddress,
       metadataAddress: mockMetadataAddress,
       metadata,
       metadata,
@@ -189,7 +189,7 @@ describe("getCreateTokenInstructions", () => {
   describe("should use original token program", () => {
   describe("should use original token program", () => {
     it("should use original token program when specified", () => {
     it("should use original token program when specified", () => {
       const args: GetCreateTokenInstructionsArgs = {
       const args: GetCreateTokenInstructionsArgs = {
-        payer: mockPayer,
+        feePayer: mockPayer,
         mint: mockMint,
         mint: mockMint,
         metadataAddress: mockMetadataAddress,
         metadataAddress: mockMetadataAddress,
         tokenProgram: TOKEN_PROGRAM_ADDRESS,
         tokenProgram: TOKEN_PROGRAM_ADDRESS,
@@ -214,7 +214,7 @@ describe("getCreateTokenInstructions", () => {
 
 
     it("should use custom decimals when provided", () => {
     it("should use custom decimals when provided", () => {
       const args: GetCreateTokenInstructionsArgs = {
       const args: GetCreateTokenInstructionsArgs = {
-        payer: mockPayer,
+        feePayer: mockPayer,
         metadataAddress: mockMetadataAddress,
         metadataAddress: mockMetadataAddress,
         mint: mockMint,
         mint: mockMint,
         decimals: 6,
         decimals: 6,
@@ -233,7 +233,7 @@ describe("getCreateTokenInstructions", () => {
 
 
     it("should use custom mint and freeze authorities when provided", () => {
     it("should use custom mint and freeze authorities when provided", () => {
       const args: GetCreateTokenInstructionsArgs = {
       const args: GetCreateTokenInstructionsArgs = {
-        payer: mockPayer,
+        feePayer: mockPayer,
         mint: mockMint,
         mint: mockMint,
         metadataAddress: mockMetadataAddress,
         metadataAddress: mockMetadataAddress,
         metadata,
         metadata,
@@ -260,7 +260,7 @@ describe("getCreateTokenInstructions", () => {
       };
       };
 
 
       const args: GetCreateTokenInstructionsArgs = {
       const args: GetCreateTokenInstructionsArgs = {
-        payer: mockPayer,
+        feePayer: mockPayer,
         mint: mockMint,
         mint: mockMint,
         metadataAddress: mockMetadataAddress,
         metadataAddress: mockMetadataAddress,
         metadata,
         metadata,
@@ -297,7 +297,7 @@ describe("getCreateTokenInstructions", () => {
       const customUpdateAuthority = { address: "customUpdateAuth" } as KeyPairSigner;
       const customUpdateAuthority = { address: "customUpdateAuth" } as KeyPairSigner;
 
 
       const args: GetCreateTokenInstructionsArgs = {
       const args: GetCreateTokenInstructionsArgs = {
-        payer: mockPayer,
+        feePayer: mockPayer,
         mint: mockMint,
         mint: mockMint,
         metadataAddress: mockMetadataAddress,
         metadataAddress: mockMetadataAddress,
         updateAuthority: customUpdateAuthority,
         updateAuthority: customUpdateAuthority,
@@ -317,7 +317,7 @@ describe("getCreateTokenInstructions", () => {
   describe("should use token22 program", () => {
   describe("should use token22 program", () => {
     it("should use Token-2022 program when specified", () => {
     it("should use Token-2022 program when specified", () => {
       const args: GetCreateTokenInstructionsArgs = {
       const args: GetCreateTokenInstructionsArgs = {
-        payer: mockPayer,
+        feePayer: mockPayer,
         mint: mockMint,
         mint: mockMint,
         metadataAddress: mockMint.address,
         metadataAddress: mockMint.address,
         tokenProgram: TOKEN_2022_PROGRAM_ADDRESS,
         tokenProgram: TOKEN_2022_PROGRAM_ADDRESS,
@@ -342,7 +342,7 @@ describe("getCreateTokenInstructions", () => {
 
 
     it("should use custom decimals when provided", () => {
     it("should use custom decimals when provided", () => {
       const args: GetCreateTokenInstructionsArgs = {
       const args: GetCreateTokenInstructionsArgs = {
-        payer: mockPayer,
+        feePayer: mockPayer,
         mint: mockMint,
         mint: mockMint,
         metadataAddress: mockMint.address,
         metadataAddress: mockMint.address,
         decimals: 6,
         decimals: 6,
@@ -362,7 +362,7 @@ describe("getCreateTokenInstructions", () => {
 
 
     it("should use custom mint and freeze authorities when provided", () => {
     it("should use custom mint and freeze authorities when provided", () => {
       const args: GetCreateTokenInstructionsArgs = {
       const args: GetCreateTokenInstructionsArgs = {
-        payer: mockPayer,
+        feePayer: mockPayer,
         mint: mockMint,
         mint: mockMint,
         metadataAddress: mockMint.address,
         metadataAddress: mockMint.address,
         metadata,
         metadata,
@@ -390,7 +390,7 @@ describe("getCreateTokenInstructions", () => {
       };
       };
 
 
       const args: GetCreateTokenInstructionsArgs = {
       const args: GetCreateTokenInstructionsArgs = {
-        payer: mockPayer,
+        feePayer: mockPayer,
         mint: mockMint,
         mint: mockMint,
         metadataAddress: mockMint.address,
         metadataAddress: mockMint.address,
         metadata,
         metadata,
@@ -435,7 +435,7 @@ describe("getCreateTokenInstructions", () => {
       const customUpdateAuthority = { address: "customUpdateAuth" } as KeyPairSigner;
       const customUpdateAuthority = { address: "customUpdateAuth" } as KeyPairSigner;
 
 
       const args: GetCreateTokenInstructionsArgs = {
       const args: GetCreateTokenInstructionsArgs = {
-        payer: mockPayer,
+        feePayer: mockPayer,
         mint: mockMint,
         mint: mockMint,
         metadataAddress: mockMint.address,
         metadataAddress: mockMint.address,
         updateAuthority: customUpdateAuthority,
         updateAuthority: customUpdateAuthority,

+ 5 - 5
packages/gill/src/__tests__/mint-tokens-instructions.ts

@@ -45,7 +45,7 @@ describe("getMintTokensInstructions", () => {
 
 
   it("should create instructions with default token program", () => {
   it("should create instructions with default token program", () => {
     const args: GetMintTokensInstructionsArgs = {
     const args: GetMintTokensInstructionsArgs = {
-      payer: mockPayer,
+      feePayer: mockPayer,
       mint: mockMint.address,
       mint: mockMint.address,
       mintAuthority: mockMintAuthority,
       mintAuthority: mockMintAuthority,
       destination: mockDestination.address,
       destination: mockDestination.address,
@@ -80,7 +80,7 @@ describe("getMintTokensInstructions", () => {
 
 
   it("should create instructions with Token-2022 program", () => {
   it("should create instructions with Token-2022 program", () => {
     const args: GetMintTokensInstructionsArgs = {
     const args: GetMintTokensInstructionsArgs = {
-      payer: mockPayer,
+      feePayer: mockPayer,
       mint: mockMint.address,
       mint: mockMint.address,
       mintAuthority: mockMintAuthority,
       mintAuthority: mockMintAuthority,
       destination: mockDestination.address,
       destination: mockDestination.address,
@@ -103,7 +103,7 @@ describe("getMintTokensInstructions", () => {
 
 
   it("should accept Address type for mint, mintAuthority, and destination", () => {
   it("should accept Address type for mint, mintAuthority, and destination", () => {
     const args: GetMintTokensInstructionsArgs = {
     const args: GetMintTokensInstructionsArgs = {
-      payer: mockPayer,
+      feePayer: mockPayer,
       mint: "mintAddress" as Address,
       mint: "mintAddress" as Address,
       mintAuthority: "mintAuthorityAddress" as Address,
       mintAuthority: "mintAuthorityAddress" as Address,
       destination: "ownerAddress" as Address,
       destination: "ownerAddress" as Address,
@@ -138,7 +138,7 @@ describe("getMintTokensInstructions", () => {
 
 
   it("should accept number type for amount", () => {
   it("should accept number type for amount", () => {
     const args: GetMintTokensInstructionsArgs = {
     const args: GetMintTokensInstructionsArgs = {
-      payer: mockPayer,
+      feePayer: mockPayer,
       mint: mockMint.address,
       mint: mockMint.address,
       mintAuthority: mockMintAuthority,
       mintAuthority: mockMintAuthority,
       destination: mockDestination.address,
       destination: mockDestination.address,
@@ -164,7 +164,7 @@ describe("getMintTokensInstructions", () => {
 
 
   it("should throw error for unsupported token program", () => {
   it("should throw error for unsupported token program", () => {
     const args: GetMintTokensInstructionsArgs = {
     const args: GetMintTokensInstructionsArgs = {
-      payer: mockPayer,
+      feePayer: mockPayer,
       mint: mockMint.address,
       mint: mockMint.address,
       mintAuthority: mockMintAuthority,
       mintAuthority: mockMintAuthority,
       destination: mockDestination.address,
       destination: mockDestination.address,

+ 7 - 7
packages/gill/src/__typetests__/create-token-transaction.ts

@@ -19,20 +19,20 @@ async () => {
   // Legacy transaction
   // Legacy transaction
   {
   {
     (await buildCreateTokenTransaction({
     (await buildCreateTokenTransaction({
-      payer: signer,
+      feePayer: signer,
       mint,
       mint,
       metadata,
       metadata,
     })) satisfies BaseTransactionMessage<"legacy">;
     })) satisfies BaseTransactionMessage<"legacy">;
 
 
     (await buildCreateTokenTransaction({
     (await buildCreateTokenTransaction({
-      payer: signer,
+      feePayer: signer,
       version: "legacy",
       version: "legacy",
       mint,
       mint,
       metadata,
       metadata,
     })) satisfies BaseTransactionMessage<"legacy">;
     })) satisfies BaseTransactionMessage<"legacy">;
 
 
     const txNotSignable = (await buildCreateTokenTransaction({
     const txNotSignable = (await buildCreateTokenTransaction({
-      payer: signer,
+      feePayer: signer,
       version: "legacy",
       version: "legacy",
       mint,
       mint,
       metadata,
       metadata,
@@ -43,7 +43,7 @@ async () => {
     signTransactionMessageWithSigners(txNotSignable);
     signTransactionMessageWithSigners(txNotSignable);
 
 
     const txSignable = (await buildCreateTokenTransaction({
     const txSignable = (await buildCreateTokenTransaction({
-      payer: signer,
+      feePayer: signer,
       version: "legacy",
       version: "legacy",
       mint,
       mint,
       metadata,
       metadata,
@@ -57,14 +57,14 @@ async () => {
   // Version 0 transaction
   // Version 0 transaction
   {
   {
     (await buildCreateTokenTransaction({
     (await buildCreateTokenTransaction({
-      payer: signer,
+      feePayer: signer,
       version: 0,
       version: 0,
       mint,
       mint,
       metadata,
       metadata,
     })) satisfies BaseTransactionMessage<0>;
     })) satisfies BaseTransactionMessage<0>;
 
 
     const txNotSignable = (await buildCreateTokenTransaction({
     const txNotSignable = (await buildCreateTokenTransaction({
-      payer: signer,
+      feePayer: signer,
       version: 0,
       version: 0,
       mint,
       mint,
       metadata,
       metadata,
@@ -75,7 +75,7 @@ async () => {
     signTransactionMessageWithSigners(txNotSignable);
     signTransactionMessageWithSigners(txNotSignable);
 
 
     const txSignable = (await buildCreateTokenTransaction({
     const txSignable = (await buildCreateTokenTransaction({
-      payer: signer,
+      feePayer: signer,
       version: 0,
       version: 0,
       mint,
       mint,
       metadata,
       metadata,

+ 7 - 7
packages/gill/src/__typetests__/mint-tokens-transaction.ts

@@ -23,7 +23,7 @@ async () => {
   // Legacy transaction
   // Legacy transaction
   {
   {
     (await buildMintTokensTransaction({
     (await buildMintTokensTransaction({
-      payer: signer,
+      feePayer: signer,
       mint,
       mint,
       destination,
       destination,
       amount: 0,
       amount: 0,
@@ -32,7 +32,7 @@ async () => {
     })) satisfies BaseTransactionMessage<"legacy">;
     })) satisfies BaseTransactionMessage<"legacy">;
 
 
     (await buildMintTokensTransaction({
     (await buildMintTokensTransaction({
-      payer: signer,
+      feePayer: signer,
       version: "legacy",
       version: "legacy",
       mint,
       mint,
       destination,
       destination,
@@ -42,7 +42,7 @@ async () => {
     })) satisfies BaseTransactionMessage<"legacy">;
     })) satisfies BaseTransactionMessage<"legacy">;
 
 
     const txNotSignable = (await buildMintTokensTransaction({
     const txNotSignable = (await buildMintTokensTransaction({
-      payer: signer,
+      feePayer: signer,
       version: "legacy",
       version: "legacy",
       mint,
       mint,
       destination,
       destination,
@@ -56,7 +56,7 @@ async () => {
     signTransactionMessageWithSigners(txNotSignable);
     signTransactionMessageWithSigners(txNotSignable);
 
 
     const txSignable = (await buildMintTokensTransaction({
     const txSignable = (await buildMintTokensTransaction({
-      payer: signer,
+      feePayer: signer,
       version: "legacy",
       version: "legacy",
       mint,
       mint,
       destination,
       destination,
@@ -73,7 +73,7 @@ async () => {
   // Version 0 transaction
   // Version 0 transaction
   {
   {
     (await buildMintTokensTransaction({
     (await buildMintTokensTransaction({
-      payer: signer,
+      feePayer: signer,
       version: 0,
       version: 0,
       mint,
       mint,
       destination,
       destination,
@@ -83,7 +83,7 @@ async () => {
     })) satisfies BaseTransactionMessage<0>;
     })) satisfies BaseTransactionMessage<0>;
 
 
     const txNotSignable = (await buildMintTokensTransaction({
     const txNotSignable = (await buildMintTokensTransaction({
-      payer: signer,
+      feePayer: signer,
       version: 0,
       version: 0,
       mint,
       mint,
       destination,
       destination,
@@ -97,7 +97,7 @@ async () => {
     signTransactionMessageWithSigners(txNotSignable);
     signTransactionMessageWithSigners(txNotSignable);
 
 
     const txSignable = (await buildMintTokensTransaction({
     const txSignable = (await buildMintTokensTransaction({
-      payer: signer,
+      feePayer: signer,
       version: 0,
       version: 0,
       mint,
       mint,
       destination,
       destination,

+ 10 - 20
packages/gill/src/programs/token/instructions/create-token.ts

@@ -16,13 +16,10 @@ import {
   getInitializeTokenMetadataInstruction,
   getInitializeTokenMetadataInstruction,
   getInitializeMetadataPointerInstruction,
   getInitializeMetadataPointerInstruction,
 } from "@solana-program/token-2022";
 } from "@solana-program/token-2022";
-import { checkedTokenProgramAddress, type TOKEN_PROGRAM_ADDRESS } from "../addresses";
+import { checkedTokenProgramAddress } from "../addresses";
+import type { TokenInstructionBase } from "./types";
 
 
-export type GetCreateTokenInstructionsArgs = {
-  /** Signer that will pay for the rent storage deposit fee */
-  payer: KeyPairSigner;
-  /** Token mint to be created (aka token address) */
-  mint: KeyPairSigner;
+export type GetCreateTokenInstructionsArgs = TokenInstructionBase<KeyPairSigner> & {
   /**
   /**
    * The number of decimal places this token should have
    * The number of decimal places this token should have
    *
    *
@@ -32,7 +29,7 @@ export type GetCreateTokenInstructionsArgs = {
   /**
   /**
    * Authority address that is allowed to mint new tokens
    * Authority address that is allowed to mint new tokens
    *
    *
-   * When not provided, defaults to: `payer`
+   * When not provided, defaults to: `feePayer`
    **/
    **/
   mintAuthority?: KeyPairSigner;
   mintAuthority?: KeyPairSigner;
   /**
   /**
@@ -45,7 +42,7 @@ export type GetCreateTokenInstructionsArgs = {
   /**
   /**
    * Authority address that is allowed to update the metadata
    * Authority address that is allowed to update the metadata
    *
    *
-   * When not provided, defaults to: `payer`
+   * When not provided, defaults to: `feePayer`
    **/
    **/
   updateAuthority?: KeyPairSigner;
   updateAuthority?: KeyPairSigner;
   /**
   /**
@@ -77,13 +74,6 @@ export type GetCreateTokenInstructionsArgs = {
    * ```
    * ```
    * */
    * */
   metadataAddress: Address;
   metadataAddress: Address;
-  /**
-   * Token program used to create the token's `mint`
-   *
-   * - (default) {@link TOKEN_PROGRAM_ADDRESS} - the original SPL Token Program
-   * - {@link TOKEN_2022_PROGRAM_ADDRESS} - the SPL Token Extensions Program (aka Token22)
-   **/
-  tokenProgram?: Address;
   // extensions // todo
   // extensions // todo
 };
 };
 
 
@@ -94,8 +84,8 @@ export function getCreateTokenInstructions(args: GetCreateTokenInstructionsArgs)
   args.tokenProgram = checkedTokenProgramAddress(args.tokenProgram);
   args.tokenProgram = checkedTokenProgramAddress(args.tokenProgram);
 
 
   if (!args.decimals) args.decimals = 9;
   if (!args.decimals) args.decimals = 9;
-  if (!args.mintAuthority) args.mintAuthority = args.payer;
-  if (!args.updateAuthority) args.updateAuthority = args.payer;
+  if (!args.mintAuthority) args.mintAuthority = args.feePayer;
+  if (!args.updateAuthority) args.updateAuthority = args.feePayer;
   if (args.freezeAuthority) args.freezeAuthority = checkedAddress(args.freezeAuthority);
   if (args.freezeAuthority) args.freezeAuthority = checkedAddress(args.freezeAuthority);
 
 
   if (args.tokenProgram === TOKEN_2022_PROGRAM_ADDRESS) {
   if (args.tokenProgram === TOKEN_2022_PROGRAM_ADDRESS) {
@@ -118,7 +108,7 @@ export function getCreateTokenInstructions(args: GetCreateTokenInstructionsArgs)
 
 
     return [
     return [
       getCreateAccountInstruction({
       getCreateAccountInstruction({
-        payer: args.payer,
+        payer: args.feePayer,
         newAccount: args.mint,
         newAccount: args.mint,
         /**
         /**
          * token22 requires only the pre-mint-initialization extensions (like metadata pointer)
          * token22 requires only the pre-mint-initialization extensions (like metadata pointer)
@@ -162,7 +152,7 @@ export function getCreateTokenInstructions(args: GetCreateTokenInstructionsArgs)
 
 
     return [
     return [
       getCreateAccountInstruction({
       getCreateAccountInstruction({
-        payer: args.payer,
+        payer: args.feePayer,
         newAccount: args.mint,
         newAccount: args.mint,
         lamports: getMinimumBalanceForRentExemption(space),
         lamports: getMinimumBalanceForRentExemption(space),
         space,
         space,
@@ -178,7 +168,7 @@ export function getCreateTokenInstructions(args: GetCreateTokenInstructionsArgs)
         metadata: args.metadataAddress,
         metadata: args.metadataAddress,
         mint: args.mint.address,
         mint: args.mint.address,
         mintAuthority: args.mintAuthority,
         mintAuthority: args.mintAuthority,
-        payer: args.payer,
+        payer: args.feePayer,
         updateAuthority: args.updateAuthority,
         updateAuthority: args.updateAuthority,
         data: {
         data: {
           name: args.metadata.name,
           name: args.metadata.name,

+ 4 - 14
packages/gill/src/programs/token/instructions/mint-tokens.ts

@@ -8,12 +8,9 @@ import {
   getCreateAssociatedTokenIdempotentInstruction,
   getCreateAssociatedTokenIdempotentInstruction,
 } from "@solana-program/token-2022";
 } from "@solana-program/token-2022";
 import { checkedAddress } from "../../../core";
 import { checkedAddress } from "../../../core";
+import type { TokenInstructionBase } from "./types";
 
 
-export type GetMintTokensInstructionsArgs = {
-  /** Signer that will pay for the rent storage deposit fee */
-  payer: KeyPairSigner;
-  /** Token mint to issue the tokens */
-  mint: KeyPairSigner | Address;
+export type GetMintTokensInstructionsArgs = TokenInstructionBase<KeyPairSigner | Address> & {
   /**
   /**
    * The authority address capable of authorizing minting of new tokens.
    * The authority address capable of authorizing minting of new tokens.
    *
    *
@@ -36,13 +33,6 @@ export type GetMintTokensInstructionsArgs = {
   ata: Address;
   ata: Address;
   /** Amount of tokens to mint to the `owner` via their `ata` */
   /** Amount of tokens to mint to the `owner` via their `ata` */
   amount: bigint | number;
   amount: bigint | number;
-  /**
-   * Token program used to create the token's `mint`
-   *
-   * - (default) {@link TOKEN_PROGRAM_ADDRESS} - the original SPL Token Program
-   * - {@link TOKEN_2022_PROGRAM_ADDRESS} - the SPL Token Extensions Program (aka Token22)
-   **/
-  tokenProgram?: Address;
 };
 };
 
 
 /**
 /**
@@ -57,7 +47,7 @@ export type GetMintTokensInstructionsArgs = {
  *
  *
  * const instructions = getMintTokensInstructions({
  * const instructions = getMintTokensInstructions({
  *   mint,
  *   mint,
- *   payer: signer,
+ *   feePayer: signer,
  *   mintAuthority: signer,
  *   mintAuthority: signer,
  *   amount: 1000, // note: be sure to consider the mint's `decimals` value
  *   amount: 1000, // note: be sure to consider the mint's `decimals` value
  *   // if decimals=2 => this will mint 10.00 tokens
  *   // if decimals=2 => this will mint 10.00 tokens
@@ -80,7 +70,7 @@ export function getMintTokensInstructions(args: GetMintTokensInstructionsArgs):
       owner: checkedAddress(args.destination),
       owner: checkedAddress(args.destination),
       mint: args.mint,
       mint: args.mint,
       ata: args.ata,
       ata: args.ata,
-      payer: args.payer,
+      payer: args.feePayer,
       tokenProgram: args.tokenProgram,
       tokenProgram: args.tokenProgram,
     }),
     }),
     getMintToInstruction(
     getMintToInstruction(

+ 18 - 0
packages/gill/src/programs/token/instructions/types.ts

@@ -0,0 +1,18 @@
+import type { Address } from "@solana/addresses";
+import type { KeyPairSigner } from "@solana/signers";
+import type { TOKEN_PROGRAM_ADDRESS } from "../addresses";
+import type { TOKEN_2022_PROGRAM_ADDRESS } from "@solana-program/token-2022";
+
+export type TokenInstructionBase<TMint = KeyPairSigner | Address> = {
+  /** Signer that will pay for the rent storage deposit fee and transaction fees */
+  feePayer: KeyPairSigner;
+  /** Token mint to issue the tokens */
+  mint: TMint;
+  /**
+   * Token program used to create the token's `mint`
+   *
+   * - (default) {@link TOKEN_PROGRAM_ADDRESS} - the original SPL Token Program
+   * - {@link TOKEN_2022_PROGRAM_ADDRESS} - the SPL Token Extensions Program (aka Token22)
+   **/
+  tokenProgram?: Address;
+};

+ 5 - 5
packages/gill/src/programs/token/transactions/create-token.ts

@@ -48,7 +48,7 @@ type GetCreateTokenTransactionInput = Simplify<
  * const mint = await generateKeyPairSigner();
  * const mint = await generateKeyPairSigner();
  *
  *
  * const transaction = await buildCreateTokenTransaction({
  * const transaction = await buildCreateTokenTransaction({
- *   payer: signer,
+ *   feePayer: signer,
  *   latestBlockhash,
  *   latestBlockhash,
  *   mint,
  *   mint,
  *   metadata: {
  *   metadata: {
@@ -111,8 +111,8 @@ export async function buildCreateTokenTransaction<
   }
   }
 
 
   return createTransaction(
   return createTransaction(
-    (({ payer, version, computeUnitLimit, computeUnitPrice, latestBlockhash }: typeof args) => ({
-      feePayer: payer,
+    (({ feePayer, version, computeUnitLimit, computeUnitPrice, latestBlockhash }: typeof args) => ({
+      feePayer,
       version: version || "legacy",
       version: version || "legacy",
       computeUnitLimit,
       computeUnitLimit,
       computeUnitPrice,
       computeUnitPrice,
@@ -124,12 +124,12 @@ export async function buildCreateTokenTransaction<
           freezeAuthority,
           freezeAuthority,
           updateAuthority,
           updateAuthority,
           metadata,
           metadata,
-          payer,
+          feePayer,
           tokenProgram,
           tokenProgram,
           mint,
           mint,
         }: typeof args) => ({
         }: typeof args) => ({
           mint: mint as KeyPairSigner,
           mint: mint as KeyPairSigner,
-          payer,
+          feePayer,
           metadataAddress,
           metadataAddress,
           metadata,
           metadata,
           decimals,
           decimals,

+ 13 - 5
packages/gill/src/programs/token/transactions/mint-tokens.ts

@@ -52,7 +52,7 @@ type GetCreateTokenTransactionInput = Simplify<
  * // or mint can be a keypair from a freshly created token
  * // or mint can be a keypair from a freshly created token
  *
  *
  * const transaction = await buildMintTokensTransaction({
  * const transaction = await buildMintTokensTransaction({
- *   payer: signer,
+ *   feePayer: signer,
  *   latestBlockhash,
  *   latestBlockhash,
  *   mint,
  *   mint,
  *   mintAuthority: signer,
  *   mintAuthority: signer,
@@ -120,16 +120,24 @@ export async function buildMintTokensTransaction<
   }
   }
 
 
   return createTransaction(
   return createTransaction(
-    (({ payer, version, computeUnitLimit, computeUnitPrice, latestBlockhash }: typeof args) => ({
-      feePayer: payer,
+    (({ feePayer, version, computeUnitLimit, computeUnitPrice, latestBlockhash }: typeof args) => ({
+      feePayer,
       version: version || "legacy",
       version: version || "legacy",
       computeUnitLimit,
       computeUnitLimit,
       computeUnitPrice,
       computeUnitPrice,
       latestBlockhash,
       latestBlockhash,
       instructions: getMintTokensInstructions(
       instructions: getMintTokensInstructions(
-        (({ tokenProgram, payer, mint, ata, mintAuthority, amount, destination }: typeof args) => ({
+        (({
           tokenProgram,
           tokenProgram,
-          payer,
+          feePayer,
+          mint,
+          ata,
+          mintAuthority,
+          amount,
+          destination,
+        }: typeof args) => ({
+          tokenProgram,
+          feePayer,
           mint,
           mint,
           mintAuthority,
           mintAuthority,
           ata: ata as Address,
           ata: ata as Address,