Skip to content

Commit

Permalink
refactor: type imports (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfrosty authored Feb 24, 2025
1 parent 9e01463 commit 452359c
Show file tree
Hide file tree
Showing 25 changed files with 69 additions and 64 deletions.
6 changes: 6 additions & 0 deletions .changeset/cuddly-taxis-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gill/build-scripts": patch
"gill": patch
---

declare imports as type
2 changes: 1 addition & 1 deletion packages/build-scripts/dev-flag.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readFile } from "fs/promises";
import jscodeshift from "jscodeshift";
import { Options } from "tsup";
import type { Options } from "tsup";

type Loader = NonNullable<
NonNullable<
Expand Down
2 changes: 1 addition & 1 deletion packages/build-scripts/getBaseConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { env } from "node:process";

import browsersListToEsBuild from "browserslist-to-esbuild";
import { Format, Options } from "tsup";
import type { Format, Options } from "tsup";

import { DevFlagPlugin } from "./dev-flag";

Expand Down
2 changes: 1 addition & 1 deletion packages/gill/src/__tests__/base64-transactions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { blockhash } from "@solana/rpc-types";
import { address } from "@solana/addresses";
import { createKeyPairSignerFromPrivateKeyBytes, KeyPairSigner } from "@solana/signers";
import { createKeyPairSignerFromPrivateKeyBytes, type KeyPairSigner } from "@solana/signers";
import { createTransaction, transactionToBase64, transactionToBase64WithSigners } from "../core";

// initialize a sample transaction
Expand Down
6 changes: 3 additions & 3 deletions packages/gill/src/__tests__/create-token-instructions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateKeyPairSigner, KeyPairSigner } from "@solana/signers";
import { Address } from "@solana/addresses";
import { IInstruction } from "@solana/instructions";
import { generateKeyPairSigner, type KeyPairSigner } from "@solana/signers";
import type { Address } from "@solana/addresses";
import type { IInstruction } from "@solana/instructions";
import { getCreateAccountInstruction } from "@solana-program/system";
import { getMinimumBalanceForRentExemption } from "../core";
import { getCreateMetadataAccountV3Instruction } from "../programs/token-metadata";
Expand Down
2 changes: 1 addition & 1 deletion packages/gill/src/__tests__/create-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "node:assert";

import { generateKeyPairSigner, isKeyPairSigner, KeyPairSigner } from "@solana/signers";
import { generateKeyPairSigner, isKeyPairSigner, type KeyPairSigner } from "@solana/signers";
import { blockhash } from "@solana/rpc-types";

import { createTransaction } from "../core";
Expand Down
2 changes: 1 addition & 1 deletion packages/gill/src/__tests__/explorer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from "node:assert";
import { FullySignedTransaction, getSignatureFromTransaction } from "@solana/transactions";
import { type FullySignedTransaction, getSignatureFromTransaction } from "@solana/transactions";

import { getExplorerLink } from "../core";

Expand Down
2 changes: 1 addition & 1 deletion packages/gill/src/core/create-solana-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createSolanaRpc } from "@solana/rpc";
import { createSolanaRpcSubscriptions } from "@solana/rpc-subscriptions";
import { DevnetUrl, MainnetUrl, TestnetUrl } from "@solana/rpc-types";
import type { DevnetUrl, MainnetUrl, TestnetUrl } from "@solana/rpc-types";

import type {
LocalnetUrl,
Expand Down
14 changes: 7 additions & 7 deletions packages/gill/src/core/create-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { Simplify } from "../types";
import type { Simplify } from "../types";
import { pipe } from "@solana/functional";
import {
appendTransactionMessageInstruction,
appendTransactionMessageInstructions,
createTransactionMessage,
ITransactionMessageWithFeePayer,
type ITransactionMessageWithFeePayer,
setTransactionMessageFeePayer,
setTransactionMessageLifetimeUsingBlockhash,
TransactionMessageWithBlockhashLifetime,
TransactionVersion,
type TransactionMessageWithBlockhashLifetime,
type TransactionVersion,
} from "@solana/transaction-messages";
import {
isTransactionSigner,
ITransactionMessageWithFeePayerSigner,
type ITransactionMessageWithFeePayerSigner,
setTransactionMessageFeePayerSigner,
TransactionSigner,
type TransactionSigner,
} from "@solana/signers";
import type { FullTransaction, CreateTransactionInput } from "../types/transactions";
import { Address } from "@solana/addresses";
import type { Address } from "@solana/addresses";
import {
getSetComputeUnitLimitInstruction,
getSetComputeUnitPriceInstruction,
Expand Down
6 changes: 3 additions & 3 deletions packages/gill/src/core/prepare-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
} from "@solana-program/compute-budget";
import {
type CompilableTransactionMessage,
ITransactionMessageWithFeePayer,
TransactionMessage,
TransactionMessageWithBlockhashLifetime,
type ITransactionMessageWithFeePayer,
type TransactionMessage,
type TransactionMessageWithBlockhashLifetime,
appendTransactionMessageInstruction,
assertIsTransactionMessageWithBlockhashLifetime,
setTransactionMessageLifetimeUsingBlockhash,
Expand Down
13 changes: 6 additions & 7 deletions packages/gill/src/core/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { devnet, mainnet, testnet } from "@solana/rpc-types";

import { LocalnetUrl, ModifiedClusterUrl, SolanaClusterMoniker } from "../types/rpc";
import type { MainnetUrl, DevnetUrl, TestnetUrl } from "@solana/rpc-types";
import type { LocalnetUrl, ModifiedClusterUrl, SolanaClusterMoniker } from "../types/rpc";

export function localnet(putativeString: string): LocalnetUrl {
return putativeString as LocalnetUrl;
Expand All @@ -16,14 +15,14 @@ export function getPublicSolanaRpcUrl(
): ModifiedClusterUrl {
switch (cluster) {
case "devnet":
return devnet("https://api.devnet.solana.com");
return "https://api.devnet.solana.com" as DevnetUrl;
case "testnet":
return testnet("https://api.testnet.solana.com");
return "https://api.testnet.solana.com" as TestnetUrl;
case "mainnet-beta":
case "mainnet":
return mainnet("https://api.mainnet-beta.solana.com");
return "https://api.mainnet-beta.solana.com" as MainnetUrl;
case "localnet":
return localnet("http://127.0.0.1:8899");
return "http://127.0.0.1:8899" as LocalnetUrl;
default:
throw new Error("Invalid cluster moniker");
}
Expand Down
16 changes: 8 additions & 8 deletions packages/gill/src/kit/compute-limit-internal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address } from '@solana/addresses';
import type { Address } from '@solana/addresses';
import { getU32Encoder } from '@solana/codecs';
import {
isSolanaError,
Expand All @@ -7,21 +7,21 @@ import {
SolanaError,
} from '@solana/errors';
import {
IInstruction,
IInstructionWithData,
type IInstruction,
type IInstructionWithData,
isInstructionForProgram,
isInstructionWithData,
} from '@solana/instructions';
import { Rpc, SimulateTransactionApi } from '@solana/rpc';
import { Blockhash, Commitment, Slot } from '@solana/rpc-types';
import type { Rpc, SimulateTransactionApi } from '@solana/rpc';
import type { Blockhash, Commitment, Slot } from '@solana/rpc-types';
import {
appendTransactionMessageInstruction,
CompilableTransactionMessage,
type CompilableTransactionMessage,
isDurableNonceTransaction,
isTransactionMessageWithBlockhashLifetime,
ITransactionMessageWithFeePayer,
type ITransactionMessageWithFeePayer,
setTransactionMessageLifetimeUsingBlockhash,
TransactionMessage,
type TransactionMessage,
} from '@solana/transaction-messages';
import { compileTransaction, getBase64EncodedWireTransaction } from '@solana/transactions';

Expand Down
4 changes: 2 additions & 2 deletions packages/gill/src/kit/compute-limit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Rpc, SimulateTransactionApi } from '@solana/rpc';
import {
import type { Rpc, SimulateTransactionApi } from '@solana/rpc';
import type {
CompilableTransactionMessage,
ITransactionMessageWithFeePayer,
TransactionMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type { Address } from '@solana/addresses';
import type { GetMultipleAccountsApi, Rpc } from '@solana/rpc';
import {
type AddressesByLookupTableAddress,
CompilableTransactionMessage,
CompiledTransactionMessage,
type CompilableTransactionMessage,
type CompiledTransactionMessage,
decompileTransactionMessage,
} from '@solana/transaction-messages';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
createRecentSignatureConfirmationPromiseFactory,
waitForDurableNonceTransactionConfirmation,
} from '@solana/transaction-confirmation';
import { FullySignedTransaction, TransactionWithDurableNonceLifetime } from '@solana/transactions';
import type { FullySignedTransaction, TransactionWithDurableNonceLifetime } from '@solana/transactions';

import { sendAndConfirmDurableNonceTransaction_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';

Expand Down
2 changes: 1 addition & 1 deletion packages/gill/src/kit/send-and-confirm-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
createRecentSignatureConfirmationPromiseFactory,
waitForRecentTransactionConfirmation,
} from '@solana/transaction-confirmation';
import { FullySignedTransaction, TransactionWithBlockhashLifetime } from '@solana/transactions';
import type { FullySignedTransaction, TransactionWithBlockhashLifetime } from '@solana/transactions';

import { sendAndConfirmTransactionWithBlockhashLifetime_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';

Expand Down
8 changes: 4 additions & 4 deletions packages/gill/src/kit/send-transaction-internal.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type { Signature } from '@solana/keys';
import type { Rpc, SendTransactionApi } from '@solana/rpc';
import { Commitment, commitmentComparator } from '@solana/rpc-types';
import { type Commitment, commitmentComparator } from '@solana/rpc-types';
import {
waitForDurableNonceTransactionConfirmation,
waitForRecentTransactionConfirmation,
} from '@solana/transaction-confirmation';
import {
FullySignedTransaction,
type FullySignedTransaction,
getBase64EncodedWireTransaction,
getSignatureFromTransaction,
TransactionWithBlockhashLifetime,
TransactionWithDurableNonceLifetime,
type TransactionWithBlockhashLifetime,
type TransactionWithDurableNonceLifetime,
} from '@solana/transactions';
import { debug, getExplorerLink } from '../core';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Rpc, SendTransactionApi } from '@solana/rpc';
import { FullySignedTransaction } from '@solana/transactions';
import type { FullySignedTransaction } from '@solana/transactions';

import { sendTransaction_INTERNAL_ONLY_DO_NOT_EXPORT } from './send-transaction-internal';

Expand Down
6 changes: 3 additions & 3 deletions packages/gill/src/programs/compute-budget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {
ComputeBudgetInstruction,
} from "@solana-program/compute-budget";
import {
IInstruction,
IInstructionWithData,
type IInstruction,
type IInstructionWithData,
isInstructionForProgram,
isInstructionWithData,
} from "@solana/instructions";
import { TransactionMessage } from "@solana/transaction-messages";
import type { TransactionMessage } from "@solana/transaction-messages";

/**
* Check if a given instruction is a `SetComputeUnitLimit` instruction
Expand Down
4 changes: 2 additions & 2 deletions packages/gill/src/programs/token-metadata/addresses.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Address, getAddressEncoder, getProgramDerivedAddress } from "@solana/addresses";
import { type Address, getAddressEncoder, getProgramDerivedAddress } from "@solana/addresses";
import { TOKEN_METADATA_PROGRAM_ADDRESS } from "./generated/instructions";
import { KeyPairSigner } from "@solana/signers";
import { type KeyPairSigner } from "@solana/signers";
import { checkedAddress } from "../../core/utils";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import {
getStructEncoder,
getU8Decoder,
getU8Encoder,
ReadonlyUint8Array,
type ReadonlyUint8Array,
transformEncoder,
type Codec,
type Decoder,
type Encoder,
type Option,
type OptionOrNullable,
} from "@solana/codecs";
import { type Address } from "@solana/addresses";
import type { Address } from "@solana/addresses";
import type {
IInstruction,
IInstructionWithAccounts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/

import {
Codec,
type Codec,
combineCodec,
Decoder,
Encoder,
type Decoder,
type Encoder,
getEnumDecoder,
getEnumEncoder,
} from "@solana/codecs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/

import {
Codec,
type Codec,
combineCodec,
Decoder,
Encoder,
type Decoder,
type Encoder,
getStructDecoder,
getStructEncoder,
getU64Decoder,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TransactionBuilderInput } from "./types";
import type { Address } from "@solana/addresses";
import { type TransactionSigner } from "@solana/signers";
import type { TransactionSigner } from "@solana/signers";
import type {
ITransactionMessageWithFeePayer,
TransactionMessageWithBlockhashLifetime,
Expand Down
10 changes: 5 additions & 5 deletions packages/gill/src/types/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Address } from "@solana/addresses";
import { IInstruction } from "@solana/instructions";
import { ITransactionMessageWithFeePayerSigner, TransactionSigner } from "@solana/signers";
import {
import type { Address } from "@solana/addresses";
import type { IInstruction } from "@solana/instructions";
import type { ITransactionMessageWithFeePayerSigner, TransactionSigner } from "@solana/signers";
import type {
BaseTransactionMessage,
ITransactionMessageWithFeePayer,
TransactionMessageWithBlockhashLifetime,
TransactionVersion,
} from "@solana/transaction-messages";
import { Simplify } from ".";
import type { Simplify } from ".";

export type CreateTransactionInput<
TVersion extends TransactionVersion,
Expand Down

0 comments on commit 452359c

Please sign in to comment.