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