Skip to content

Commit

Permalink
refactor: reexport vs web3
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfrosty committed Jan 29, 2025
1 parent 5e0a77b commit acf3df9
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 137 deletions.
5 changes: 5 additions & 0 deletions .changeset/pink-weeks-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gill": patch
---

added tests for createTransaction
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ helper library for building Solana apps in Node, web, and React Native.
Install `gill` with your package manager of choice:

```shell
npm install gill @solana/web3.js@2
npm install gill
```

```shell
pnpm add gill @solana/web3.js@2
pnpm add gill
```

```shell
yarn add gill @solana/web3.js@2
yarn add gill
```

## Quick start
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"@eslint/js": "^9.15.0",
"@eslint/json": "^0.7.0",
"@solana/eslint-config-solana": "^4.0.0",
"@solana/web3.js": "^2.0.0",
"@swc/jest": "^0.2.37",
"@types/jest": "^29.5.14",
"@types/jscodeshift": "^0.12.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/gill/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ helper library for building Solana apps in Node, web, and React Native.
Install `gill` with your package manager of choice:

```shell
npm install gill @solana/web3.js@2
npm install gill
```

```shell
pnpm add gill @solana/web3.js@2
pnpm add gill
```

```shell
yarn add gill @solana/web3.js@2
yarn add gill
```

## Quick start
Expand Down
19 changes: 18 additions & 1 deletion packages/gill/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,27 @@
"maintained node versions"
],
"peerDependencies": {
"@solana/web3.js": "^2.0.0",
"typescript": ">=5"
},
"engines": {
"node": ">=20.18.0"
},
"dependencies": {
"@solana/accounts": "^2.0.0",
"@solana/addresses": "^2.0.0",
"@solana/codecs": "^2.0.0",
"@solana/errors": "^2.0.0",
"@solana/functional": "^2.0.0",
"@solana/instructions": "^2.0.0",
"@solana/keys": "^2.0.0",
"@solana/programs": "^2.0.0",
"@solana/rpc": "^2.0.0",
"@solana/rpc-parsed-types": "^2.0.0",
"@solana/rpc-spec-types": "^2.0.0",
"@solana/rpc-subscriptions": "^2.0.0",
"@solana/rpc-types": "^2.0.0",
"@solana/signers": "^2.0.0",
"@solana/transaction-messages": "^2.0.0",
"@solana/transactions": "^2.0.0"
}
}
4 changes: 3 additions & 1 deletion packages/gill/src/__tests__/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import assert from "node:assert";

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

import { createTransaction } from "../core/transactions";
import { blockhash, generateKeyPairSigner, isKeyPairSigner, KeyPairSigner } from "@solana/web3.js";

describe("createTransaction", () => {
let signer: KeyPairSigner;
Expand Down
7 changes: 3 additions & 4 deletions packages/gill/src/core/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createSolanaRpc, createSolanaRpcSubscriptions } from "@solana/web3.js";
import { createSolanaRpc } from "@solana/rpc";
import { createSolanaRpcSubscriptions } from "@solana/rpc-subscriptions";
import {
CreateSolanaClientArgs,
CreateSolanaClientResult,
Expand Down Expand Up @@ -38,9 +39,7 @@ export function createSolanaClient({
urlOrMoniker = new URL(urlOrMoniker);
} catch (err) {
try {
urlOrMoniker = new URL(
getPublicSolanaRpcUrl(urlOrMoniker as SolanaClusterMoniker),
);
urlOrMoniker = new URL(getPublicSolanaRpcUrl(urlOrMoniker as SolanaClusterMoniker));
} catch (err) {
throw new Error("Invalid URL or cluster moniker");
}
Expand Down
9 changes: 4 additions & 5 deletions packages/gill/src/core/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { pipe } from "@solana/functional";
import {
pipe,
isTransactionSigner,
appendTransactionMessageInstructions,
createTransactionMessage,
setTransactionMessageFeePayer,
setTransactionMessageFeePayerSigner,
appendTransactionMessageInstructions,
setTransactionMessageLifetimeUsingBlockhash,
} from "@solana/web3.js";
} from "@solana/transaction-messages";
import { isTransactionSigner, setTransactionMessageFeePayerSigner } from "@solana/signers";
import type { CreateTransactionInput } from "../types/transactions";

/**
Expand Down
32 changes: 32 additions & 0 deletions packages/gill/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
export * from "@solana/accounts";
export * from "@solana/addresses";
export * from "@solana/codecs";
export * from "@solana/errors";
export * from "@solana/functional";
export * from "@solana/instructions";
export * from "@solana/keys";
export * from "@solana/programs";
export * from "@solana/rpc";
export * from "@solana/rpc-parsed-types";
export * from "@solana/rpc-subscriptions";
export * from "@solana/rpc-types";
export * from "@solana/signers";
export * from "@solana/transaction-messages";
export * from "@solana/transactions";

export type {
RpcRequest,
RpcRequestTransformer,
RpcResponse,
RpcResponseData,
RpcResponseTransformer,
} from "@solana/rpc-spec-types";
export { createRpcMessage } from "@solana/rpc-spec-types";

// export * from './airdrop';
// export * from './compute-limit';
// export * from './decompile-transaction-message-fetching-lookup-tables';
// export * from './send-and-confirm-durable-nonce-transaction';
// export * from './send-and-confirm-transaction';
// export * from './send-transaction-without-confirming';

export * from "./types";
export * from "./core";
12 changes: 3 additions & 9 deletions packages/gill/src/node/load-keypair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ import { resolve } from "node:path";
import { readFileSync } from "node:fs";
import { homedir } from "node:os";

import {
createKeyPairFromBytes,
createSignerFromKeyPair,
KeyPairSigner,
} from "@solana/web3.js";

import { DEFAULT_CLI_KEYPAIR_PATH } from "./const";
import { createSignerFromKeyPair, KeyPairSigner } from "@solana/signers";
import { createKeyPairFromBytes } from "@solana/keys";

/**
* Load a `KeyPairSigner` from a filesystem wallet json file
Expand All @@ -32,7 +28,5 @@ export async function loadKeypairFromFile(
const resolvedPath = resolve(
filePath.startsWith("~") ? filePath.replace("~", homedir()) : filePath,
);
return createKeyPairFromBytes(
Uint8Array.from(JSON.parse(readFileSync(resolvedPath, "utf8"))),
);
return createKeyPairFromBytes(Uint8Array.from(JSON.parse(readFileSync(resolvedPath, "utf8"))));
}
22 changes: 5 additions & 17 deletions packages/gill/src/types/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
import type {
createSolanaRpc,
createSolanaRpcSubscriptions,
DevnetUrl,
MainnetUrl,
TestnetUrl,
} from "@solana/web3.js";
import type { createSolanaRpc } from "@solana/rpc";
import type { createSolanaRpcSubscriptions } from "@solana/rpc-subscriptions";
import type { DevnetUrl, MainnetUrl, TestnetUrl } from "@solana/rpc-types";

/** Solana cluster moniker */
export type SolanaClusterMoniker =
| "mainnet-beta"
| "devnet"
| "testnet"
| "localnet";
export type SolanaClusterMoniker = "mainnet-beta" | "devnet" | "testnet" | "localnet";

type GenericUrl = string & {};

export type ModifiedClusterUrl =
| DevnetUrl
| MainnetUrl
| TestnetUrl
| GenericUrl;
export type ModifiedClusterUrl = DevnetUrl | MainnetUrl | TestnetUrl | GenericUrl;

export type SolanaUrlOrMoniker = SolanaClusterMoniker | ModifiedClusterUrl;

Expand Down
12 changes: 5 additions & 7 deletions packages/gill/src/types/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type {
Address,
Blockhash,
IInstruction,
TransactionSigner,
TransactionVersion,
} from "@solana/web3.js";
import { Address } from "@solana/addresses";
import { IInstruction } from "@solana/instructions";
import { Blockhash } from "@solana/rpc-types";
import { TransactionSigner } from "@solana/signers";
import { TransactionVersion } from "@solana/transaction-messages";

export type CreateTransactionInput = {
/**
Expand Down
1 change: 0 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
},
"peerDependencies": {
"gill": "workspace:*",
"@solana/web3.js": "^2.0.0",
"@tanstack/react-query": "^5.61.4",
"@types/react-test-renderer": "^18",
"@types/react": "^18",
Expand Down
1 change: 0 additions & 1 deletion packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"devDependencies": {},
"peerDependencies": {
"gill": "workspace:*",
"@solana/web3.js": "^2.0.0",
"typescript": ">=5"
},
"engines": {
Expand Down
1 change: 0 additions & 1 deletion packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"devDependencies": {},
"peerDependencies": {
"gill": "workspace:*",
"@solana/web3.js": "^2.0.0",
"typescript": ">=5"
},
"engines": {
Expand Down
Loading

0 comments on commit acf3df9

Please sign in to comment.