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