Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't rely on explicit export of TransactionCtorFields type #205

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 2 additions & 8 deletions src/actions/utility/createExternalPriceAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import {
VaultProgram,
UpdateExternalPriceAccount,
} from '@metaplex-foundation/mpl-token-vault';
import {
Keypair,
PublicKey,
SystemProgram,
TransactionCtorFields,
TransactionSignature,
} from '@solana/web3.js';
import { Keypair, PublicKey, SystemProgram, TransactionSignature } from '@solana/web3.js';
import { NATIVE_MINT } from '@solana/spl-token';
import { Transaction } from '@metaplex-foundation/mpl-core';

Expand All @@ -37,7 +31,7 @@ export const createExternalPriceAccount = async ({
wallet,
}: CreateExternalPriceAccountParams): Promise<CreateExternalPriceAccountResponse> => {
const txBatch = new TransactionsBatch({ transactions: [] });
const txOptions: TransactionCtorFields = { feePayer: wallet.publicKey };
const txOptions: ConstructorParameters<typeof Transaction>[0] = { feePayer: wallet.publicKey };

const epaRentExempt = await connection.getMinimumBalanceForRentExemption(
Vault.MAX_EXTERNAL_ACCOUNT_SIZE,
Expand Down
6 changes: 4 additions & 2 deletions src/transactions/CreateAssociatedTokenAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
PublicKey,
SystemProgram,
SYSVAR_RENT_PUBKEY,
TransactionCtorFields,
TransactionInstruction,
} from '@solana/web3.js';
import { Buffer } from 'buffer';
Expand All @@ -16,7 +15,10 @@ type CreateAssociatedTokenAccountParams = {
};

export class CreateAssociatedTokenAccount extends Transaction {
constructor(options: TransactionCtorFields, params: CreateAssociatedTokenAccountParams) {
constructor(
options: ConstructorParameters<typeof Transaction>[0],
params: CreateAssociatedTokenAccountParams,
) {
const { feePayer } = options;
const { associatedTokenAddress, walletAddress, splTokenMintAddress } = params;
super(options);
Expand Down
4 changes: 2 additions & 2 deletions src/transactions/CreateMint.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Transaction } from '@metaplex-foundation/mpl-core';
import { MintLayout, Token, TOKEN_PROGRAM_ID } from '@solana/spl-token';
import { PublicKey, SystemProgram, TransactionCtorFields } from '@solana/web3.js';
import { PublicKey, SystemProgram } from '@solana/web3.js';

type CreateMintParams = {
newAccountPubkey: PublicKey;
Expand All @@ -11,7 +11,7 @@ type CreateMintParams = {
};

export class CreateMint extends Transaction {
constructor(options: TransactionCtorFields, params: CreateMintParams) {
constructor(options: ConstructorParameters<typeof Transaction>[0], params: CreateMintParams) {
const { feePayer } = options;
const { newAccountPubkey, lamports, decimals, owner, freezeAuthority } = params;

Expand Down
7 changes: 5 additions & 2 deletions src/transactions/CreateTokenAccount.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Transaction } from '@metaplex-foundation/mpl-core';
import { AccountLayout, Token, TOKEN_PROGRAM_ID } from '@solana/spl-token';
import { PublicKey, SystemProgram, TransactionCtorFields } from '@solana/web3.js';
import { PublicKey, SystemProgram } from '@solana/web3.js';

type CreateTokenAccountParams = {
newAccountPubkey: PublicKey;
Expand All @@ -10,7 +10,10 @@ type CreateTokenAccountParams = {
};

export class CreateTokenAccount extends Transaction {
constructor(options: TransactionCtorFields, params: CreateTokenAccountParams) {
constructor(
options: ConstructorParameters<typeof Transaction>[0],
params: CreateTokenAccountParams,
) {
const { feePayer } = options;
const { newAccountPubkey, lamports, mint, owner } = params;

Expand Down
4 changes: 2 additions & 2 deletions src/transactions/MintTo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Token, TOKEN_PROGRAM_ID } from '@solana/spl-token';
import { PublicKey, TransactionCtorFields } from '@solana/web3.js';
import { PublicKey } from '@solana/web3.js';
import BN from 'bn.js';
import { Transaction } from '@metaplex-foundation/mpl-core';

Expand All @@ -11,7 +11,7 @@ type MintToParams = {
};

export class MintTo extends Transaction {
constructor(options: TransactionCtorFields, params: MintToParams) {
constructor(options: ConstructorParameters<typeof Transaction>[0], params: MintToParams) {
const { feePayer } = options;
const { mint, dest, authority, amount } = params;

Expand Down
9 changes: 2 additions & 7 deletions src/transactions/PayForFiles.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { Transaction } from '@metaplex-foundation/mpl-core';
import {
PublicKey,
SystemProgram,
TransactionCtorFields,
TransactionInstruction,
} from '@solana/web3.js';
import { PublicKey, SystemProgram, TransactionInstruction } from '@solana/web3.js';
import { config } from '@metaplex-foundation/mpl-core';
import { Buffer } from 'buffer';

Expand All @@ -15,7 +10,7 @@ type PayForFilesParams = {
};

export class PayForFiles extends Transaction {
constructor(options: TransactionCtorFields, params: PayForFilesParams) {
constructor(options: ConstructorParameters<typeof Transaction>[0], params: PayForFilesParams) {
const { feePayer } = options;
const { lamports, fileHashes, arweaveWallet } = params;

Expand Down
4 changes: 2 additions & 2 deletions test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import { Keypair, PublicKey, TransactionCtorFields } from '@solana/web3.js';
import { Keypair, PublicKey, Transaction } from '@solana/web3.js';
import { tmpdir } from 'os';
import { readFileSync } from 'fs';

Expand Down Expand Up @@ -88,7 +88,7 @@ export const VAULT_EXTENRNAL_PRICE_ACCOUNT = new PublicKey(
'58S2MNcuS79ncBc5xi1T8jdS98jcXJbXqM5UvGvgmwcr',
);

export const mockTransaction: TransactionCtorFields = {
export const mockTransaction: ConstructorParameters<typeof Transaction>[0] = {
feePayer: new PublicKey('7J6QvJGCB22vDvYB33ikrWCXRBRsFY74ntAArSK4KJUn'),
recentBlockhash: RECENT_ISH_BLOCKHASH,
};
Expand Down