@pincerpay/solana 0.1.1 → 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 +57 -10
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![license](https://img.shields.io/npm/l/@pincerpay/solana?style=flat-square)](https://github.com/ds1/pincerpay/blob/master/LICENSE)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
7
7
 
8
- Solana infrastructure integrations for PincerPay: Kora gasless transactions and Squads SPN smart accounts.
8
+ Solana infrastructure integrations for [PincerPay](https://pincerpay.com): Kora gasless transactions and Squads SPN smart accounts.
9
9
 
10
10
  ## Install
11
11
 
@@ -15,12 +15,15 @@ npm install @pincerpay/solana
15
15
 
16
16
  ## Kora (Gasless Transactions)
17
17
 
18
- 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.
19
19
 
20
20
  ### Quick Start
21
21
 
22
22
  ```typescript
23
- 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);
24
27
 
25
28
  // Low-level client
26
29
  const kora = createKoraClient({
@@ -36,7 +39,7 @@ const signer = createKoraFacilitatorSvmSigner({
36
39
  rpcUrls: { "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1": "https://api.devnet.solana.com" },
37
40
  });
38
41
 
39
- await signer.init(); // Fetches fee payer address
42
+ await signer.init(); // Fetches fee payer address from Kora node
40
43
  ```
41
44
 
42
45
  ### API Reference
@@ -54,14 +57,16 @@ function createKoraFacilitatorSvmSigner(options: {
54
57
  rpcUrls?: Record<string, string>;
55
58
  }): FacilitatorSvmSigner & { init(): Promise<void> };
56
59
 
57
- function parseKoraConfig(
58
- env: Record<string, string | undefined>
59
- ): 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> }>;
60
65
  ```
61
66
 
62
67
  ## Squads SPN (Smart Accounts)
63
68
 
64
- 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).
65
70
 
66
71
  ### Quick Start
67
72
 
@@ -70,6 +75,7 @@ import {
70
75
  deriveSmartAccountPda,
71
76
  createSpendingLimit,
72
77
  checkSpendingLimit,
78
+ revokeSpendingLimit,
73
79
  SpendingLimitPeriod,
74
80
  } from "@pincerpay/solana/squads";
75
81
 
@@ -93,6 +99,9 @@ const ix = await createSpendingLimit(
93
99
  // Check remaining allowance
94
100
  const limit = await checkSpendingLimit(smartAccountPda, 0, rpcUrl);
95
101
  // { exists: true, remainingAmount: 8_000_000n, period: "Day" }
102
+
103
+ // Revoke a spending limit
104
+ const revokeIx = await revokeSpendingLimit(smartAccountPda, 0, authorityAddress, rentCollectorAddress);
96
105
  ```
97
106
 
98
107
  ### API Reference
@@ -113,7 +122,7 @@ async function deriveSpendingLimitPda(
113
122
  ): Promise<[Address, number]>;
114
123
  ```
115
124
 
116
- #### Spending Limit Management
125
+ #### High-Level Spending Limit Management
117
126
 
118
127
  ```typescript
119
128
  async function createSpendingLimit(
@@ -129,6 +138,31 @@ async function revokeSpendingLimit(
129
138
  ): Promise<Instruction>;
130
139
  ```
131
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
+
132
166
  #### Types
133
167
 
134
168
  ```typescript
@@ -172,11 +206,24 @@ const [smartAccount] = await deriveSmartAccountPda(creator, 0);
172
206
  const limit = await checkSpendingLimit(smartAccount, 0, rpcUrl);
173
207
  ```
174
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
+
175
222
  ## Anti-Patterns
176
223
 
177
224
  ### Don't skip `signer.init()` for Kora
178
225
 
179
- 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.
180
227
 
181
228
  ### Don't use Squads on EVM
182
229
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pincerpay/solana",
3
- "version": "0.1.1",
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",
@@ -60,7 +60,7 @@
60
60
  "@solana/kit": "^5.5.1",
61
61
  "@x402/svm": "^2.3.0",
62
62
  "zod": "^3.24",
63
- "@pincerpay/core": "0.1.1"
63
+ "@pincerpay/core": "0.2.0"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@scure/base": "^1.2.6",