11import { ClientWithPayer , pipe } from '@solana/kit' ;
22import { addSelfPlanAndSendFunctions , SelfPlanAndSendFunctions } from '@solana/kit/program-client-core' ;
33
4- import { CreateMintInstructionPlanInput , getCreateMintInstructionPlan } from './createMint' ;
4+ import {
5+ CreateMintInstructionPlanConfig ,
6+ CreateMintInstructionPlanInput ,
7+ getCreateMintInstructionPlan ,
8+ } from './createMint' ;
59import {
610 TokenPlugin as GeneratedTokenPlugin ,
711 TokenPluginInstructions as GeneratedTokenPluginInstructions ,
812 TokenPluginRequirements as GeneratedTokenPluginRequirements ,
913 tokenProgram as generatedTokenProgram ,
1014} from './generated' ;
11- import { getMintToATAInstructionPlan , MintToATAInstructionPlanInput } from './mintToATA' ;
12- import { getTransferToATAInstructionPlan , TransferToATAInstructionPlanInput } from './transferToATA' ;
15+ import {
16+ getMintToATAInstructionPlanAsync ,
17+ MintToATAInstructionPlanAsyncInput ,
18+ MintToATAInstructionPlanConfig ,
19+ } from './mintToATA' ;
20+ import {
21+ getTransferToATAInstructionPlanAsync ,
22+ TransferToATAInstructionPlanAsyncInput ,
23+ TransferToATAInstructionPlanConfig ,
24+ } from './transferToATA' ;
25+ import { MakeOptional } from './types' ;
1326
1427export type TokenPluginRequirements = GeneratedTokenPluginRequirements & ClientWithPayer ;
1528
1629export type TokenPlugin = Omit < GeneratedTokenPlugin , 'instructions' > & { instructions : TokenPluginInstructions } ;
1730
1831export type TokenPluginInstructions = GeneratedTokenPluginInstructions & {
32+ /** Create a new token mint. */
1933 createMint : (
2034 input : MakeOptional < CreateMintInstructionPlanInput , 'payer' > ,
35+ config ?: CreateMintInstructionPlanConfig ,
2136 ) => ReturnType < typeof getCreateMintInstructionPlan > & SelfPlanAndSendFunctions ;
37+ /** Mint tokens to an owner's ATA (created if needed). */
2238 mintToATA : (
23- input : MakeOptional < MintToATAInstructionPlanInput , 'payer' > ,
24- ) => ReturnType < typeof getMintToATAInstructionPlan > & SelfPlanAndSendFunctions ;
39+ input : MakeOptional < MintToATAInstructionPlanAsyncInput , 'payer' > ,
40+ config ?: MintToATAInstructionPlanConfig ,
41+ ) => ReturnType < typeof getMintToATAInstructionPlanAsync > & SelfPlanAndSendFunctions ;
42+ /** Transfer tokens to a recipient's ATA (created if needed). */
2543 transferToATA : (
26- input : MakeOptional < TransferToATAInstructionPlanInput , 'payer' > ,
27- ) => ReturnType < typeof getTransferToATAInstructionPlan > & SelfPlanAndSendFunctions ;
44+ input : MakeOptional < TransferToATAInstructionPlanAsyncInput , 'payer' > ,
45+ config ?: TransferToATAInstructionPlanConfig ,
46+ ) => ReturnType < typeof getTransferToATAInstructionPlanAsync > & SelfPlanAndSendFunctions ;
2847} ;
2948
3049export function tokenProgram ( ) {
@@ -35,25 +54,41 @@ export function tokenProgram() {
3554 ...c . token ,
3655 instructions : {
3756 ...c . token . instructions ,
38- createMint : input =>
57+ createMint : ( input , config ) =>
3958 addSelfPlanAndSendFunctions (
4059 client ,
41- getCreateMintInstructionPlan ( { ...input , payer : input . payer ?? client . payer } ) ,
60+ getCreateMintInstructionPlan (
61+ {
62+ ...input ,
63+ payer : input . payer ?? client . payer ,
64+ } ,
65+ config ,
66+ ) ,
4267 ) ,
43- mintToATA : input =>
68+ mintToATA : ( input , config ) =>
4469 addSelfPlanAndSendFunctions (
4570 client ,
46- getMintToATAInstructionPlan ( { ...input , payer : input . payer ?? client . payer } ) ,
71+ getMintToATAInstructionPlanAsync (
72+ {
73+ ...input ,
74+ payer : input . payer ?? client . payer ,
75+ } ,
76+ config ,
77+ ) ,
4778 ) ,
48- transferToATA : input =>
79+ transferToATA : ( input , config ) =>
4980 addSelfPlanAndSendFunctions (
5081 client ,
51- getTransferToATAInstructionPlan ( { ...input , payer : input . payer ?? client . payer } ) ,
82+ getTransferToATAInstructionPlanAsync (
83+ {
84+ ...input ,
85+ payer : input . payer ?? client . payer ,
86+ } ,
87+ config ,
88+ ) ,
5289 ) ,
5390 } ,
5491 } ,
5592 } ) ) ;
5693 } ;
5794}
58-
59- type MakeOptional < T , K extends keyof T > = Omit < T , K > & Partial < Pick < T , K > > ;
0 commit comments