surfman-sdk 0.1.0 → 0.1.2

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 +244 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,244 @@
1
+ # surfman-sdk
2
+
3
+ TypeScript SDK for SurfPool RPC API interaction - A powerful toolkit for Solana local development and testing.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/surfman-sdk.svg)](https://www.npmjs.com/package/surfman-sdk)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ > 📖 **[SurfPool Documentation](https://docs.surfpool.run/)** - Learn more about SurfPool's local development environment
9
+
10
+ ## Features
11
+
12
+ - 🔧 **Cheatcodes**: Time travel, account manipulation, network control
13
+ - 🌐 **Network APIs**: Block queries, transactions, fees, cluster info
14
+ - 📦 **Account APIs**: Account info, token balances, batch queries
15
+ - 📊 **Scan & Analytics**: Program accounts, largest holders, supply metrics
16
+ - 💪 **Type-safe**: Full TypeScript support with comprehensive type definitions
17
+ - ⚡ **Easy to use**: Simple, intuitive API design
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ npm install surfman-sdk
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ```typescript
28
+ import { Surfman } from 'surfman-sdk';
29
+
30
+ // Initialize client
31
+ const client = new Surfman('http://localhost:8899');
32
+
33
+ // Cheatcodes - Time travel by epoch
34
+ await client.cheatcodes.timeTravel({
35
+ absoluteEpoch: 100
36
+ });
37
+
38
+ // Time travel to specific timestamp
39
+ await client.cheatcodes.timeTravel({
40
+ absoluteTimestamp: Math.floor(Date.now() / 1000) + 86400 // +1 day
41
+ });
42
+
43
+ // Set or remove program authority
44
+ await client.cheatcodes.setProgramAuthority(
45
+ 'program-id',
46
+ 'new-authority-pubkey' // or null to remove authority
47
+ );
48
+
49
+ // Network - Get latest blockhash
50
+ const blockhash = await client.network.getLatestBlockhash();
51
+
52
+ // Network - Send transaction
53
+ const signature = await client.network.sendTransaction(txData);
54
+
55
+ // Accounts - Get account info
56
+ const account = await client.accounts.getAccountInfo(pubkey);
57
+
58
+ // Scan - Get program accounts
59
+ const accounts = await client.scan.getProgramAccounts(programId, {
60
+ filters: [{ dataSize: 165 }]
61
+ });
62
+
63
+ // Scan - Get largest accounts
64
+ const largest = await client.scan.getLargestAccounts();
65
+ ```
66
+
67
+ ## API Modules
68
+
69
+ ### Cheatcodes (9 APIs)
70
+
71
+ Time travel and network manipulation for testing:
72
+
73
+ ```typescript
74
+ // Time control
75
+ await client.cheatcodes.timeTravel({ relativeSlots: 100 });
76
+ await client.cheatcodes.pauseClock();
77
+ await client.cheatcodes.resumeClock();
78
+
79
+ // Account manipulation
80
+ await client.cheatcodes.setAccount(pubkey, options);
81
+ await client.cheatcodes.setTokenAccount(account, options);
82
+ await client.cheatcodes.resetAccount(pubkey);
83
+
84
+ // Network management
85
+ await client.cheatcodes.resetNetwork();
86
+ await client.cheatcodes.setProgramAuthority(programId, newAuthority);
87
+ const sigs = await client.cheatcodes.getLocalSignatures();
88
+ ```
89
+
90
+ ### Network (18 APIs)
91
+
92
+ Comprehensive network and transaction APIs:
93
+
94
+ ```typescript
95
+ // Block queries
96
+ const blockhash = await client.network.getLatestBlockhash();
97
+ const block = await client.network.getBlock(slot);
98
+ const blocks = await client.network.getBlocks(startSlot, endSlot);
99
+
100
+ // Transactions
101
+ const tx = await client.network.getTransaction(signature);
102
+ const sig = await client.network.sendTransaction(txData);
103
+ const result = await client.network.simulateTransaction(tx);
104
+
105
+ // Network info
106
+ const nodes = await client.network.getClusterNodes();
107
+ const fees = await client.network.getRecentPrioritizationFees();
108
+ const isValid = await client.network.isBlockhashValid(blockhash);
109
+ ```
110
+
111
+ ### Accounts (5 APIs)
112
+
113
+ Account and token data queries:
114
+
115
+ ```typescript
116
+ // Account queries
117
+ const account = await client.accounts.getAccountInfo(pubkey);
118
+ const accounts = await client.accounts.getMultipleAccounts([pubkey1, pubkey2]);
119
+
120
+ // Token queries
121
+ const balance = await client.accounts.getTokenAccountBalance(tokenAccount);
122
+ const supply = await client.accounts.getTokenSupply(mint);
123
+ const commitment = await client.accounts.getBlockCommitment(slot);
124
+ ```
125
+
126
+ ### Scan & Analytics (6 APIs)
127
+
128
+ Batch queries and network statistics:
129
+
130
+ ```typescript
131
+ // Program accounts
132
+ const accounts = await client.scan.getProgramAccounts(programId, {
133
+ filters: [{ dataSize: 165 }],
134
+ encoding: 'base64'
135
+ });
136
+
137
+ // Supply and distribution
138
+ const supply = await client.scan.getSupply();
139
+ const largest = await client.scan.getLargestAccounts();
140
+ const holders = await client.scan.getTokenLargestAccounts(mint);
141
+
142
+ // Token accounts
143
+ const owned = await client.scan.getTokenAccountsByOwner(owner, { mint });
144
+ const delegated = await client.scan.getTokenAccountsByDelegate(delegate, { mint });
145
+ ```
146
+
147
+ ## Configuration
148
+
149
+ ```typescript
150
+ // String URL
151
+ const client = new Surfman('http://localhost:8899');
152
+
153
+ // Or with config object
154
+ const client = new Surfman({
155
+ url: 'http://localhost:8899',
156
+ timeout: 30000,
157
+ // ... other RPC config options
158
+ });
159
+ ```
160
+
161
+ ## Use Cases
162
+
163
+ ### Testing Smart Contracts
164
+
165
+ ```typescript
166
+ // Set up test environment - move forward 1 week
167
+ const oneWeekInSlots = 7 * 24 * 60 * 60 * 2; // ~7 days
168
+ await client.cheatcodes.timeTravel({ relativeSlots: oneWeekInSlots });
169
+
170
+ // Fund test account
171
+ await client.cheatcodes.setAccount(testAccount, {
172
+ lamports: 10_000_000_000
173
+ });
174
+
175
+ // Change program authority for testing
176
+ await client.cheatcodes.setProgramAuthority(
177
+ programId,
178
+ testAuthority
179
+ );
180
+
181
+ // Run your tests
182
+ // ...
183
+
184
+ // Clean up
185
+ await client.cheatcodes.resetNetwork();
186
+ ```
187
+
188
+ ### Token Analytics
189
+
190
+ ```typescript
191
+ // Get token distribution
192
+ const supply = await client.scan.getSupply();
193
+ const largestHolders = await client.scan.getTokenLargestAccounts(mint);
194
+
195
+ // Analyze holder concentration
196
+ const top10Percentage = largestHolders
197
+ .slice(0, 10)
198
+ .reduce((sum, holder) => sum + holder.uiAmount, 0) / supply.circulating;
199
+ ```
200
+
201
+ ### Program Account Scanning
202
+
203
+ ```typescript
204
+ // Find all token accounts for a specific mint
205
+ const accounts = await client.scan.getProgramAccounts(TOKEN_PROGRAM_ID, {
206
+ filters: [
207
+ { dataSize: 165 },
208
+ { memcmp: { offset: 0, bytes: mintAddress } }
209
+ ]
210
+ });
211
+ ```
212
+
213
+ ## TypeScript Support
214
+
215
+ Full TypeScript definitions included:
216
+
217
+ ```typescript
218
+ import {
219
+ Surfman,
220
+ AccountInfo,
221
+ BlockInfo,
222
+ TransactionResponse
223
+ } from 'surfman-sdk';
224
+ ```
225
+
226
+ ## CLI Companion
227
+
228
+ For command-line usage, install the companion CLI tool:
229
+
230
+ ```bash
231
+ npm install -g surfman
232
+ surfman --help
233
+ ```
234
+
235
+ ## Documentation
236
+
237
+ - [SurfPool Documentation](https://docs.surfpool.run/) - Official SurfPool docs
238
+ - [GitHub Repository](https://github.com/ennea8/surfman)
239
+ - [CLI Tool](https://www.npmjs.com/package/surfman)
240
+ - [Report Issues](https://github.com/ennea8/surfman/issues)
241
+
242
+ ## License
243
+
244
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "surfman-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "TypeScript SDK for SurfPool RPC API interaction",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -13,7 +13,8 @@
13
13
  }
14
14
  },
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "README.md"
17
18
  ],
18
19
  "keywords": [
19
20
  "surfpool",