@pincerpay/solana 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +62 -10
  2. package/package.json +12 -3
package/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # @pincerpay/solana
2
2
 
3
- Solana infrastructure integrations for PincerPay: Kora gasless transactions and Squads SPN smart accounts.
3
+ [![npm](https://img.shields.io/npm/v/@pincerpay/solana?style=flat-square)](https://www.npmjs.com/package/@pincerpay/solana)
4
+ [![downloads](https://img.shields.io/npm/dm/@pincerpay/solana?style=flat-square)](https://www.npmjs.com/package/@pincerpay/solana)
5
+ [![license](https://img.shields.io/npm/l/@pincerpay/solana?style=flat-square)](https://github.com/ds1/pincerpay/blob/master/LICENSE)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
7
+
8
+ Solana infrastructure integrations for [PincerPay](https://pincerpay.com): Kora gasless transactions and Squads SPN smart accounts.
4
9
 
5
10
  ## Install
6
11
 
@@ -10,12 +15,15 @@ npm install @pincerpay/solana
10
15
 
11
16
  ## Kora (Gasless Transactions)
12
17
 
13
- Agents pay transaction fees in USDC instead of SOL via Kora signer nodes.
18
+ Agents pay transaction fees in USDC instead of SOL via [Kora](https://launch.solana.com/docs/kora/json-rpc-api) signer nodes.
14
19
 
15
20
  ### Quick Start
16
21
 
17
22
  ```typescript
18
- import { createKoraClient, createKoraFacilitatorSvmSigner } from "@pincerpay/solana/kora";
23
+ import { createKoraClient, createKoraFacilitatorSvmSigner, parseKoraConfig } from "@pincerpay/solana/kora";
24
+
25
+ // Parse config from environment variables (KORA_RPC_URL, KORA_API_KEY)
26
+ const config = parseKoraConfig(process.env);
19
27
 
20
28
  // Low-level client
21
29
  const kora = createKoraClient({
@@ -31,7 +39,7 @@ const signer = createKoraFacilitatorSvmSigner({
31
39
  rpcUrls: { "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1": "https://api.devnet.solana.com" },
32
40
  });
33
41
 
34
- await signer.init(); // Fetches fee payer address
42
+ await signer.init(); // Fetches fee payer address from Kora node
35
43
  ```
36
44
 
37
45
  ### API Reference
@@ -49,14 +57,16 @@ function createKoraFacilitatorSvmSigner(options: {
49
57
  rpcUrls?: Record<string, string>;
50
58
  }): FacilitatorSvmSigner & { init(): Promise<void> };
51
59
 
52
- function parseKoraConfig(
53
- env: Record<string, string | undefined>
54
- ): KoraConfig | null;
60
+ // Parse KORA_RPC_URL and KORA_API_KEY from env — returns null if no URL
61
+ function parseKoraConfig(env: Record<string, string | undefined>): KoraConfig | null;
62
+
63
+ // Zod schema for KoraConfig validation
64
+ const koraConfigSchema: z.ZodObject<{ rpcUrl: z.ZodString; apiKey: z.ZodOptional<z.ZodString> }>;
55
65
  ```
56
66
 
57
67
  ## Squads SPN (Smart Accounts)
58
68
 
59
- Decentralized policy co-signer for agent sub-accounts with on-chain spending limits.
69
+ Decentralized policy co-signer for agent sub-accounts with on-chain spending limits via the [Squads Protocol](https://squads.so).
60
70
 
61
71
  ### Quick Start
62
72
 
@@ -65,6 +75,7 @@ import {
65
75
  deriveSmartAccountPda,
66
76
  createSpendingLimit,
67
77
  checkSpendingLimit,
78
+ revokeSpendingLimit,
68
79
  SpendingLimitPeriod,
69
80
  } from "@pincerpay/solana/squads";
70
81
 
@@ -88,6 +99,9 @@ const ix = await createSpendingLimit(
88
99
  // Check remaining allowance
89
100
  const limit = await checkSpendingLimit(smartAccountPda, 0, rpcUrl);
90
101
  // { exists: true, remainingAmount: 8_000_000n, period: "Day" }
102
+
103
+ // Revoke a spending limit
104
+ const revokeIx = await revokeSpendingLimit(smartAccountPda, 0, authorityAddress, rentCollectorAddress);
91
105
  ```
92
106
 
93
107
  ### API Reference
@@ -108,7 +122,7 @@ async function deriveSpendingLimitPda(
108
122
  ): Promise<[Address, number]>;
109
123
  ```
110
124
 
111
- #### Spending Limit Management
125
+ #### High-Level Spending Limit Management
112
126
 
113
127
  ```typescript
114
128
  async function createSpendingLimit(
@@ -124,6 +138,31 @@ async function revokeSpendingLimit(
124
138
  ): Promise<Instruction>;
125
139
  ```
126
140
 
141
+ #### Low-Level Instruction Builders
142
+
143
+ For fine-grained control over transaction construction:
144
+
145
+ ```typescript
146
+ // Create a new Squads Smart Account
147
+ function createSmartAccountInstruction(config: SmartAccountConfig): Promise<Instruction>;
148
+
149
+ // Add a spending limit to an existing Smart Account
150
+ function addSpendingLimitInstruction(
151
+ config: SpendingLimitConfig, spendingLimitIndex: number, authority: Address
152
+ ): Promise<Instruction>;
153
+
154
+ // Use (decrement) a spending limit
155
+ function useSpendingLimitInstruction(...): Promise<Instruction>;
156
+
157
+ // Remove a spending limit and reclaim rent
158
+ function removeSpendingLimitInstruction(params: {
159
+ smartAccountPda: Address;
160
+ spendingLimitIndex: number;
161
+ authority: Address;
162
+ rentCollector: Address;
163
+ }): Promise<Instruction>;
164
+ ```
165
+
127
166
  #### Types
128
167
 
129
168
  ```typescript
@@ -167,11 +206,24 @@ const [smartAccount] = await deriveSmartAccountPda(creator, 0);
167
206
  const limit = await checkSpendingLimit(smartAccount, 0, rpcUrl);
168
207
  ```
169
208
 
209
+ ### Parse Kora config from environment
210
+
211
+ ```typescript
212
+ import { parseKoraConfig } from "@pincerpay/solana/kora";
213
+
214
+ const config = parseKoraConfig(process.env);
215
+ if (config) {
216
+ console.log("Kora enabled:", config.rpcUrl);
217
+ } else {
218
+ console.log("Kora not configured, using local keypair for gas");
219
+ }
220
+ ```
221
+
170
222
  ## Anti-Patterns
171
223
 
172
224
  ### Don't skip `signer.init()` for Kora
173
225
 
174
- The Kora signer must call `init()` before use it fetches the fee payer address from the Kora node.
226
+ The Kora signer must call `init()` before use -- it fetches the fee payer address from the Kora node.
175
227
 
176
228
  ### Don't use Squads on EVM
177
229
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pincerpay/solana",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "Solana integration for PincerPay. Kora gasless transactions and Squads smart account support.",
6
6
  "license": "MIT",
@@ -24,7 +24,16 @@
24
24
  "gasless",
25
25
  "usdc",
26
26
  "smart-accounts",
27
- "session-keys"
27
+ "session-keys",
28
+ "typescript",
29
+ "web3",
30
+ "crypto",
31
+ "on-chain",
32
+ "http-402",
33
+ "spl-token",
34
+ "transfer-checked",
35
+ "devnet",
36
+ "mainnet"
28
37
  ],
29
38
  "files": [
30
39
  "dist",
@@ -51,7 +60,7 @@
51
60
  "@solana/kit": "^5.5.1",
52
61
  "@x402/svm": "^2.3.0",
53
62
  "zod": "^3.24",
54
- "@pincerpay/core": "0.1.0"
63
+ "@pincerpay/core": "0.2.0"
55
64
  },
56
65
  "devDependencies": {
57
66
  "@scure/base": "^1.2.6",