@wuwei-labs/srsly 2.0.0-beta.21 → 2.0.0-beta.22
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 +66 -65
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/utils/config.js +164 -96
- package/dist/cjs/utils/config.js.map +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/utils/config.js +164 -96
- package/dist/esm/utils/config.js.map +1 -1
- package/dist/types/utils/config.d.ts +24 -4
- package/dist/types/utils/config.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,8 +46,8 @@ setConfig({
|
|
|
46
46
|
// 2. Create signer from keypair
|
|
47
47
|
const signer = await createKeyPairSignerFromBytes(keypairBytes);
|
|
48
48
|
|
|
49
|
-
// 3. Pack
|
|
50
|
-
const
|
|
49
|
+
// 3. Pack and send in one chain (NEW: No double await needed!)
|
|
50
|
+
const signature = await createContract({
|
|
51
51
|
owner: signer,
|
|
52
52
|
fleet: fleetAddress,
|
|
53
53
|
ownerProfile: profileAddress,
|
|
@@ -55,23 +55,24 @@ const packedTx = await createContract({
|
|
|
55
55
|
durationMin: 86400, // 1 day
|
|
56
56
|
durationMax: 604800, // 1 week
|
|
57
57
|
paymentsFreq: 'daily'
|
|
58
|
-
}).pack(signer.address);
|
|
59
|
-
|
|
60
|
-
const signature = await packedTx.send(signer); // Send with signer
|
|
58
|
+
}).pack(signer.address).send(signer); // Now chainable!
|
|
61
59
|
|
|
62
60
|
console.log('Transaction signature:', signature);
|
|
63
61
|
|
|
64
|
-
//
|
|
65
|
-
const
|
|
62
|
+
// Or still use two steps if preferred
|
|
63
|
+
const packedTx = await createContract(params).pack(signer.address);
|
|
64
|
+
const signature2 = await packedTx.send(signer);
|
|
65
|
+
|
|
66
|
+
// With custom transaction options (also chainable!)
|
|
67
|
+
const signature3 = await createContract(params)
|
|
66
68
|
.set({
|
|
67
69
|
transactionOptions: {
|
|
68
70
|
commitment: 'finalized',
|
|
69
71
|
skipPreflight: true
|
|
70
72
|
}
|
|
71
73
|
})
|
|
72
|
-
.pack(signer.address)
|
|
73
|
-
|
|
74
|
-
const signature = await customPackedTx.send(signer);
|
|
74
|
+
.pack(signer.address)
|
|
75
|
+
.send(signer);
|
|
75
76
|
```
|
|
76
77
|
|
|
77
78
|
### Option 2: Pack for Wallet Adapters (Browser)
|
|
@@ -219,56 +220,74 @@ const closeIx = await closeRental({
|
|
|
219
220
|
});
|
|
220
221
|
```
|
|
221
222
|
|
|
222
|
-
##
|
|
223
|
+
## Configuration
|
|
223
224
|
|
|
224
|
-
The SDK
|
|
225
|
+
The SDK provides flexible configuration options for different networks and custom setups:
|
|
225
226
|
|
|
226
227
|
### Global Configuration
|
|
227
228
|
|
|
228
229
|
```typescript
|
|
229
230
|
import { setConfig, getConfig, clearConfig } from '@wuwei-labs/srsly';
|
|
230
231
|
|
|
231
|
-
//
|
|
232
|
-
setConfig({
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
rpcUrl: 'https://
|
|
232
|
+
// Complete configuration example with all possible options
|
|
233
|
+
setConfig({
|
|
234
|
+
// Program Set - Choose predefined network configuration
|
|
235
|
+
programs: 'atlasnet', // 'mainnet' | 'atlasnet' | 'holosim'
|
|
236
|
+
|
|
237
|
+
// RPC Configuration - Required for creating transactions
|
|
238
|
+
rpcUrl: 'https://your-rpc-provider.com/api-key', // Your RPC endpoint
|
|
239
|
+
|
|
240
|
+
// Program Address Overrides - Customize specific program addresses
|
|
241
|
+
srslyProgramAddress: 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT', // SRSLY program
|
|
242
|
+
profileFactionProgramAddress: 'PprofUW1pURCnMW2si88GWPXEEK3Bvh9Tksy8WtnoYJ', // Profile Faction program
|
|
243
|
+
gameId: 'GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k', // SAGE game ID
|
|
244
|
+
atlasMint: 'ATLA5nAaVRfH6BNwD4SAyWp96EdQaAh6bBmGeTx956sx', // ATLAS token mint
|
|
245
|
+
|
|
246
|
+
// Transaction Options - Control transaction behavior
|
|
247
|
+
transactionOptions: {
|
|
248
|
+
commitment: 'confirmed', // 'processed' | 'confirmed' | 'finalized'
|
|
249
|
+
skipPreflight: false // Skip transaction simulation before sending
|
|
250
|
+
}
|
|
238
251
|
});
|
|
239
252
|
|
|
240
|
-
//
|
|
241
|
-
setConfig({
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
});
|
|
253
|
+
// Simple network configurations
|
|
254
|
+
setConfig({ programs: 'mainnet' }); // Uses mainnet programs + default RPC
|
|
255
|
+
setConfig({ programs: 'atlasnet', rpcUrl: 'https://your-rpc.com' }); // Atlasnet + custom RPC
|
|
256
|
+
setConfig({ programs: 'holosim', rpcUrl: 'https://your-rpc.com' }); // Holosim + custom RPC
|
|
245
257
|
|
|
246
|
-
//
|
|
247
|
-
setConfig({
|
|
248
|
-
programs: 'mainnet',
|
|
249
|
-
srslyProgramAddress: 'custom-srsly-program...',
|
|
250
|
-
gameId: 'custom-game-id...',
|
|
251
|
-
atlasMint: 'custom-atlas-mint...'
|
|
252
|
-
// mainnet includes default RPC URL
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
// Check current config
|
|
258
|
+
// Check current configuration
|
|
256
259
|
console.log(getConfig());
|
|
257
260
|
|
|
258
261
|
// Reset to defaults
|
|
259
262
|
clearConfig();
|
|
260
263
|
```
|
|
261
264
|
|
|
265
|
+
### Configuration Options Reference
|
|
266
|
+
|
|
267
|
+
| Option | Type | Description | Default |
|
|
268
|
+
|--------|------|-------------|---------|
|
|
269
|
+
| `programs` | `'mainnet' \| 'atlasnet' \| 'holosim'` | Predefined program address set | `'atlasnet'` |
|
|
270
|
+
| `rpcUrl` | `string` | Solana RPC endpoint URL (required for pack/send) | `undefined` |
|
|
271
|
+
| `srslyProgramAddress` | `string` | SRSLY program address override | From program set |
|
|
272
|
+
| `profileFactionProgramAddress` | `string` | Profile Faction program override | From program set |
|
|
273
|
+
| `gameId` | `string` | SAGE game ID override | From program set |
|
|
274
|
+
| `atlasMint` | `string` | ATLAS token mint override | From program set |
|
|
275
|
+
| `transactionOptions.commitment` | `'processed' \| 'confirmed' \| 'finalized'` | Transaction confirmation level | `'confirmed'` |
|
|
276
|
+
| `transactionOptions.skipPreflight` | `boolean` | Skip transaction simulation | `false` |
|
|
277
|
+
|
|
262
278
|
### Per-Instruction Configuration
|
|
263
279
|
|
|
264
280
|
```typescript
|
|
265
281
|
// Override global config for specific instructions
|
|
266
|
-
const ix = await createContract(params).set({
|
|
282
|
+
const ix = await createContract(params).set({
|
|
283
|
+
programs: 'mainnet',
|
|
284
|
+
transactionOptions: { commitment: 'finalized' }
|
|
285
|
+
});
|
|
267
286
|
|
|
268
287
|
// Chain multiple configurations
|
|
269
288
|
const ix2 = await acceptRental(params)
|
|
270
|
-
.set({ programs: 'holosim' })
|
|
271
|
-
.set({ gameId: 'custom-game-id...' });
|
|
289
|
+
.set({ programs: 'holosim', rpcUrl: 'https://custom-rpc.com' })
|
|
290
|
+
.set({ gameId: 'custom-game-id...', atlasMint: 'custom-mint...' });
|
|
272
291
|
```
|
|
273
292
|
|
|
274
293
|
## Payment System
|
|
@@ -287,40 +306,22 @@ const duration = 86400; // 1 day in seconds
|
|
|
287
306
|
const totalAmount = rate * duration * ATLAS_TO_STARDUST; // in stardust
|
|
288
307
|
```
|
|
289
308
|
|
|
290
|
-
##
|
|
309
|
+
## Program Sets Reference
|
|
291
310
|
|
|
292
|
-
|
|
293
|
-
// Program address sets
|
|
294
|
-
const networks = {
|
|
295
|
-
mainnet: {
|
|
296
|
-
sageProgram: 'SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE',
|
|
297
|
-
gameId: 'GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr',
|
|
298
|
-
atlasMint: 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx',
|
|
299
|
-
rpcUrl: 'https://api.mainnet-beta.solana.com' // Default RPC for mainnet
|
|
300
|
-
},
|
|
301
|
-
atlasnet: {
|
|
302
|
-
sageProgram: 'SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF',
|
|
303
|
-
gameId: 'GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k',
|
|
304
|
-
atlasMint: 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx'
|
|
305
|
-
// No default RPC - must provide rpcUrl required permissions
|
|
306
|
-
},
|
|
307
|
-
holosim: {
|
|
308
|
-
sageProgram: 'SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF',
|
|
309
|
-
gameId: 'GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k',
|
|
310
|
-
atlasMint: 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx'
|
|
311
|
-
// No default RPC - must provide rpcUrl required permissions
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
```
|
|
311
|
+
The SDK includes predefined program address sets for different networks:
|
|
315
312
|
|
|
316
|
-
|
|
313
|
+
| Network | SAGE Program | Game ID | ATLAS Mint | Default RPC |
|
|
314
|
+
|---------|--------------|---------|------------|-------------|
|
|
315
|
+
| `mainnet` | `SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE` | `GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr` | `ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx` | ✅ Included |
|
|
316
|
+
| `atlasnet` | `SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF` | `GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k` | `ATLA5nAaVRfH6BNwD4SAyWp96EdQaAh6bBmGeTx956sx` | ❌ Provide your own |
|
|
317
|
+
| `holosim` | `SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF` | `GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k` | `ATLA5nAaVRfH6BNwD4SAyWp96EdQaAh6bBmGeTx956sx` | ❌ Provide your own |
|
|
318
|
+
|
|
319
|
+
**Note**: Atlasnet and holosim networks require you to provide your own RPC URL since they need API keys. You'll get a helpful error message if you forget:
|
|
317
320
|
|
|
318
321
|
```typescript
|
|
319
|
-
// This will throw a clear error for atlasnet/holosim
|
|
320
322
|
setConfig({ programs: 'atlasnet' }); // Missing rpcUrl!
|
|
321
|
-
|
|
322
323
|
await createContract(params).pack(address);
|
|
323
|
-
// Error: RPC URL is required for atlasnet network. Please provide your RPC endpoint
|
|
324
|
+
// Error: RPC URL is required for atlasnet network. Please provide your RPC endpoint...
|
|
324
325
|
```
|
|
325
326
|
|
|
326
327
|
## Types and Constants
|
package/dist/cjs/package.json
CHANGED
package/dist/cjs/utils/config.js
CHANGED
|
@@ -158,6 +158,72 @@ async function getCachedNetworkModule(modulePath) {
|
|
|
158
158
|
}
|
|
159
159
|
return getModule(modulePath);
|
|
160
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Ensures the input is a proper Uint8Array compatible with web3.js
|
|
163
|
+
* Handles various TypedArray formats that @solana/kit might return
|
|
164
|
+
*/
|
|
165
|
+
function ensureUint8Array(input) {
|
|
166
|
+
// If it's already a standard Uint8Array, return as-is
|
|
167
|
+
if (input instanceof Uint8Array && input.constructor === Uint8Array) {
|
|
168
|
+
return input;
|
|
169
|
+
}
|
|
170
|
+
// Handle various ArrayBufferView types (including ReadonlyUint8Array)
|
|
171
|
+
if (ArrayBuffer.isView(input)) {
|
|
172
|
+
return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
173
|
+
}
|
|
174
|
+
// Handle objects with buffer property (some Node.js environments)
|
|
175
|
+
if (input && input.buffer && typeof input.byteLength === 'number') {
|
|
176
|
+
return new Uint8Array(input.buffer, input.byteOffset || 0, input.byteLength);
|
|
177
|
+
}
|
|
178
|
+
// Handle array-like objects and iterables
|
|
179
|
+
if (input && typeof input.length === 'number') {
|
|
180
|
+
return new Uint8Array(input);
|
|
181
|
+
}
|
|
182
|
+
// Handle objects that might be iterable but don't have length
|
|
183
|
+
if (input && typeof input[Symbol.iterator] === 'function') {
|
|
184
|
+
return new Uint8Array(Array.from(input));
|
|
185
|
+
}
|
|
186
|
+
// Fallback: try to create from the input directly
|
|
187
|
+
return new Uint8Array(input);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Create a chainable packed transaction that allows .pack().send() without double await
|
|
191
|
+
*
|
|
192
|
+
* @param packedTxPromise Promise that resolves to a PackedTransaction
|
|
193
|
+
* @returns ChainablePackedTransaction that can be chained with .send()
|
|
194
|
+
*/
|
|
195
|
+
function createChainablePackedTransaction(packedTxPromise) {
|
|
196
|
+
let cachedPackedTx = null;
|
|
197
|
+
const chainable = {
|
|
198
|
+
get messageBytes() {
|
|
199
|
+
if (cachedPackedTx)
|
|
200
|
+
return cachedPackedTx.messageBytes;
|
|
201
|
+
throw new Error('PackedTransaction not yet resolved. Use await on .pack() first, or use .send() directly for chaining.');
|
|
202
|
+
},
|
|
203
|
+
get signatures() {
|
|
204
|
+
if (cachedPackedTx)
|
|
205
|
+
return cachedPackedTx.signatures;
|
|
206
|
+
throw new Error('PackedTransaction not yet resolved. Use await on .pack() first, or use .send() directly for chaining.');
|
|
207
|
+
},
|
|
208
|
+
send: async (signer) => {
|
|
209
|
+
// If not cached, wait for the packed transaction
|
|
210
|
+
if (!cachedPackedTx) {
|
|
211
|
+
cachedPackedTx = await packedTxPromise;
|
|
212
|
+
}
|
|
213
|
+
return cachedPackedTx.send(signer);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
// Make the chainable object thenable so it can be awaited to get the PackedTransaction
|
|
217
|
+
const thenable = Object.assign(chainable, {
|
|
218
|
+
then(onfulfilled, onrejected) {
|
|
219
|
+
return packedTxPromise.then((packedTx) => {
|
|
220
|
+
cachedPackedTx = packedTx;
|
|
221
|
+
return onfulfilled ? onfulfilled(packedTx) : packedTx;
|
|
222
|
+
}, onrejected);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
return thenable;
|
|
226
|
+
}
|
|
161
227
|
/**
|
|
162
228
|
* Create a chainable config selector with existing configuration state.
|
|
163
229
|
* This enables config chaining by merging new options with existing ones.
|
|
@@ -177,56 +243,57 @@ function createChainableConfigSelector(executeFn, existingConfig) {
|
|
|
177
243
|
const selector = {
|
|
178
244
|
set: (additionalOptions) => createChainableConfigSelector(executeFn, { ...existingConfig, ...additionalOptions }),
|
|
179
245
|
build: () => executeFn(existingConfig),
|
|
180
|
-
pack:
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
190
|
-
}
|
|
191
|
-
// Create RPC connection to get latest blockhash
|
|
192
|
-
const rpc = (0, kit_1.createSolanaRpc)(resolvedAddresses.rpcUrl);
|
|
193
|
-
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
194
|
-
// Build unsigned transaction message
|
|
195
|
-
const transactionMessage = (0, kit_1.pipe)((0, kit_1.createTransactionMessage)({ version: 0 }), (msg) => (0, kit_1.setTransactionMessageFeePayer)(feePayer, msg), (msg) => (0, kit_1.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, msg), (msg) => (0, kit_1.appendTransactionMessageInstructions)([instruction], msg));
|
|
196
|
-
// Compile to unsigned transaction
|
|
197
|
-
const unsignedTransaction = (0, kit_1.compileTransaction)(transactionMessage);
|
|
198
|
-
// Ensure messageBytes is a proper Uint8Array for web3.js compatibility
|
|
199
|
-
const messageBytes = unsignedTransaction.messageBytes instanceof Uint8Array
|
|
200
|
-
? unsignedTransaction.messageBytes
|
|
201
|
-
: new Uint8Array(unsignedTransaction.messageBytes);
|
|
202
|
-
// Return PackedTransaction with send() method
|
|
203
|
-
return {
|
|
204
|
-
messageBytes,
|
|
205
|
-
signatures: unsignedTransaction.signatures,
|
|
206
|
-
send: async (signer) => {
|
|
207
|
-
// Create RPC connections for sending
|
|
208
|
-
const sendRpc = (0, kit_1.createSolanaRpc)(resolvedAddresses.rpcUrl);
|
|
209
|
-
const rpcSubscriptions = (0, kit_1.createSolanaRpcSubscriptions)(resolvedAddresses.rpcUrl.replace('https:', 'wss:').replace('http:', 'ws:'));
|
|
210
|
-
// Build transaction message with signer
|
|
211
|
-
const signerTransactionMessage = (0, kit_1.pipe)((0, kit_1.createTransactionMessage)({ version: 0 }), (msg) => (0, kit_1.setTransactionMessageFeePayerSigner)(signer, msg), (msg) => (0, kit_1.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, msg), (msg) => (0, kit_1.appendTransactionMessageInstructions)([instruction], msg));
|
|
212
|
-
// Sign transaction
|
|
213
|
-
const signedTransaction = await (0, kit_1.signTransactionMessageWithSigners)(signerTransactionMessage);
|
|
214
|
-
// Send and confirm transaction
|
|
215
|
-
const sendAndConfirmTransaction = (0, kit_1.sendAndConfirmTransactionFactory)({ rpc: sendRpc, rpcSubscriptions: rpcSubscriptions });
|
|
216
|
-
try {
|
|
217
|
-
await sendAndConfirmTransaction(signedTransaction, {
|
|
218
|
-
commitment: effectiveConfig.transactionOptions?.commitment || 'confirmed',
|
|
219
|
-
skipPreflight: effectiveConfig.transactionOptions?.skipPreflight || false
|
|
220
|
-
});
|
|
221
|
-
// Extract and return the signature
|
|
222
|
-
const signature = (0, kit_1.getSignatureFromTransaction)(signedTransaction);
|
|
223
|
-
return signature;
|
|
224
|
-
}
|
|
225
|
-
catch (error) {
|
|
226
|
-
throw new Error(`Transaction failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
246
|
+
pack: (feePayer) => {
|
|
247
|
+
const packedTxPromise = (async () => {
|
|
248
|
+
const instruction = await executeFn(existingConfig);
|
|
249
|
+
const effectiveConfig = getEffectiveConfig(existingConfig);
|
|
250
|
+
const resolvedAddresses = resolveProgramAddresses(effectiveConfig);
|
|
251
|
+
if (!resolvedAddresses.rpcUrl) {
|
|
252
|
+
const networkType = effectiveConfig.programs || 'unknown';
|
|
253
|
+
if (networkType === 'atlasnet' || networkType === 'holosim') {
|
|
254
|
+
throw new Error(`RPC URL is required for ${networkType} network. Please provide your RPC endpoint via setConfig({ rpcUrl: "your-rpc-url-with-api-key" }) or .set({ rpcUrl: "your-rpc-url-with-api-key" })`);
|
|
227
255
|
}
|
|
256
|
+
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
228
257
|
}
|
|
229
|
-
|
|
258
|
+
// Create RPC connection to get latest blockhash
|
|
259
|
+
const rpc = (0, kit_1.createSolanaRpc)(resolvedAddresses.rpcUrl);
|
|
260
|
+
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
261
|
+
// Build unsigned transaction message
|
|
262
|
+
const transactionMessage = (0, kit_1.pipe)((0, kit_1.createTransactionMessage)({ version: 0 }), (msg) => (0, kit_1.setTransactionMessageFeePayer)(feePayer, msg), (msg) => (0, kit_1.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, msg), (msg) => (0, kit_1.appendTransactionMessageInstructions)([instruction], msg));
|
|
263
|
+
// Compile to unsigned transaction
|
|
264
|
+
const unsignedTransaction = (0, kit_1.compileTransaction)(transactionMessage);
|
|
265
|
+
// Ensure messageBytes is a proper Uint8Array for web3.js compatibility
|
|
266
|
+
const messageBytes = ensureUint8Array(unsignedTransaction.messageBytes);
|
|
267
|
+
// Return PackedTransaction with send() method
|
|
268
|
+
return {
|
|
269
|
+
messageBytes,
|
|
270
|
+
signatures: unsignedTransaction.signatures,
|
|
271
|
+
send: async (signer) => {
|
|
272
|
+
// Create RPC connections for sending
|
|
273
|
+
const sendRpc = (0, kit_1.createSolanaRpc)(resolvedAddresses.rpcUrl);
|
|
274
|
+
const rpcSubscriptions = (0, kit_1.createSolanaRpcSubscriptions)(resolvedAddresses.rpcUrl.replace('https:', 'wss:').replace('http:', 'ws:'));
|
|
275
|
+
// Build transaction message with signer
|
|
276
|
+
const signerTransactionMessage = (0, kit_1.pipe)((0, kit_1.createTransactionMessage)({ version: 0 }), (msg) => (0, kit_1.setTransactionMessageFeePayerSigner)(signer, msg), (msg) => (0, kit_1.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, msg), (msg) => (0, kit_1.appendTransactionMessageInstructions)([instruction], msg));
|
|
277
|
+
// Sign transaction
|
|
278
|
+
const signedTransaction = await (0, kit_1.signTransactionMessageWithSigners)(signerTransactionMessage);
|
|
279
|
+
// Send and confirm transaction
|
|
280
|
+
const sendAndConfirmTransaction = (0, kit_1.sendAndConfirmTransactionFactory)({ rpc: sendRpc, rpcSubscriptions: rpcSubscriptions });
|
|
281
|
+
try {
|
|
282
|
+
await sendAndConfirmTransaction(signedTransaction, {
|
|
283
|
+
commitment: effectiveConfig.transactionOptions?.commitment || 'confirmed',
|
|
284
|
+
skipPreflight: effectiveConfig.transactionOptions?.skipPreflight || false
|
|
285
|
+
});
|
|
286
|
+
// Extract and return the signature
|
|
287
|
+
const signature = (0, kit_1.getSignatureFromTransaction)(signedTransaction);
|
|
288
|
+
return signature;
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
throw new Error(`Transaction failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
})();
|
|
296
|
+
return createChainablePackedTransaction(packedTxPromise);
|
|
230
297
|
},
|
|
231
298
|
// Implement PromiseLike to allow direct awaiting
|
|
232
299
|
then(onfulfilled, onrejected) {
|
|
@@ -258,56 +325,57 @@ function createConfigSelector(executeFn) {
|
|
|
258
325
|
const selector = {
|
|
259
326
|
set: (options) => createChainableConfigSelector(executeFn, getEffectiveConfig(options)),
|
|
260
327
|
build: () => executeFn(getEffectiveConfig()),
|
|
261
|
-
pack:
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
271
|
-
}
|
|
272
|
-
// Create RPC connection to get latest blockhash
|
|
273
|
-
const rpc = (0, kit_1.createSolanaRpc)(resolvedAddresses.rpcUrl);
|
|
274
|
-
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
275
|
-
// Build unsigned transaction message
|
|
276
|
-
const transactionMessage = (0, kit_1.pipe)((0, kit_1.createTransactionMessage)({ version: 0 }), (msg) => (0, kit_1.setTransactionMessageFeePayer)(feePayer, msg), (msg) => (0, kit_1.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, msg), (msg) => (0, kit_1.appendTransactionMessageInstructions)([instruction], msg));
|
|
277
|
-
// Compile to unsigned transaction
|
|
278
|
-
const unsignedTransaction = (0, kit_1.compileTransaction)(transactionMessage);
|
|
279
|
-
// Ensure messageBytes is a proper Uint8Array for web3.js compatibility
|
|
280
|
-
const messageBytes = unsignedTransaction.messageBytes instanceof Uint8Array
|
|
281
|
-
? unsignedTransaction.messageBytes
|
|
282
|
-
: new Uint8Array(unsignedTransaction.messageBytes);
|
|
283
|
-
// Return PackedTransaction with send() method
|
|
284
|
-
return {
|
|
285
|
-
messageBytes,
|
|
286
|
-
signatures: unsignedTransaction.signatures,
|
|
287
|
-
send: async (signer) => {
|
|
288
|
-
// Create RPC connections for sending
|
|
289
|
-
const sendRpc = (0, kit_1.createSolanaRpc)(resolvedAddresses.rpcUrl);
|
|
290
|
-
const rpcSubscriptions = (0, kit_1.createSolanaRpcSubscriptions)(resolvedAddresses.rpcUrl.replace('https:', 'wss:').replace('http:', 'ws:'));
|
|
291
|
-
// Build transaction message with signer
|
|
292
|
-
const signerTransactionMessage = (0, kit_1.pipe)((0, kit_1.createTransactionMessage)({ version: 0 }), (msg) => (0, kit_1.setTransactionMessageFeePayerSigner)(signer, msg), (msg) => (0, kit_1.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, msg), (msg) => (0, kit_1.appendTransactionMessageInstructions)([instruction], msg));
|
|
293
|
-
// Sign transaction
|
|
294
|
-
const signedTransaction = await (0, kit_1.signTransactionMessageWithSigners)(signerTransactionMessage);
|
|
295
|
-
// Send and confirm transaction
|
|
296
|
-
const sendAndConfirmTransaction = (0, kit_1.sendAndConfirmTransactionFactory)({ rpc: sendRpc, rpcSubscriptions: rpcSubscriptions });
|
|
297
|
-
try {
|
|
298
|
-
await sendAndConfirmTransaction(signedTransaction, {
|
|
299
|
-
commitment: effectiveConfig.transactionOptions?.commitment || 'confirmed',
|
|
300
|
-
skipPreflight: effectiveConfig.transactionOptions?.skipPreflight || false
|
|
301
|
-
});
|
|
302
|
-
// Extract and return the signature
|
|
303
|
-
const signature = (0, kit_1.getSignatureFromTransaction)(signedTransaction);
|
|
304
|
-
return signature;
|
|
305
|
-
}
|
|
306
|
-
catch (error) {
|
|
307
|
-
throw new Error(`Transaction failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
328
|
+
pack: (feePayer) => {
|
|
329
|
+
const packedTxPromise = (async () => {
|
|
330
|
+
const instruction = await executeFn(getEffectiveConfig());
|
|
331
|
+
const effectiveConfig = getEffectiveConfig();
|
|
332
|
+
const resolvedAddresses = resolveProgramAddresses(effectiveConfig);
|
|
333
|
+
if (!resolvedAddresses.rpcUrl) {
|
|
334
|
+
const networkType = effectiveConfig.programs || 'unknown';
|
|
335
|
+
if (networkType === 'atlasnet' || networkType === 'holosim') {
|
|
336
|
+
throw new Error(`RPC URL is required for ${networkType} network. Please provide your RPC endpoint via setConfig({ rpcUrl: "your-rpc-url-with-api-key" }) or .set({ rpcUrl: "your-rpc-url-with-api-key" })`);
|
|
308
337
|
}
|
|
338
|
+
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
309
339
|
}
|
|
310
|
-
|
|
340
|
+
// Create RPC connection to get latest blockhash
|
|
341
|
+
const rpc = (0, kit_1.createSolanaRpc)(resolvedAddresses.rpcUrl);
|
|
342
|
+
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
343
|
+
// Build unsigned transaction message
|
|
344
|
+
const transactionMessage = (0, kit_1.pipe)((0, kit_1.createTransactionMessage)({ version: 0 }), (msg) => (0, kit_1.setTransactionMessageFeePayer)(feePayer, msg), (msg) => (0, kit_1.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, msg), (msg) => (0, kit_1.appendTransactionMessageInstructions)([instruction], msg));
|
|
345
|
+
// Compile to unsigned transaction
|
|
346
|
+
const unsignedTransaction = (0, kit_1.compileTransaction)(transactionMessage);
|
|
347
|
+
// Ensure messageBytes is a proper Uint8Array for web3.js compatibility
|
|
348
|
+
const messageBytes = ensureUint8Array(unsignedTransaction.messageBytes);
|
|
349
|
+
// Return PackedTransaction with send() method
|
|
350
|
+
return {
|
|
351
|
+
messageBytes,
|
|
352
|
+
signatures: unsignedTransaction.signatures,
|
|
353
|
+
send: async (signer) => {
|
|
354
|
+
// Create RPC connections for sending
|
|
355
|
+
const sendRpc = (0, kit_1.createSolanaRpc)(resolvedAddresses.rpcUrl);
|
|
356
|
+
const rpcSubscriptions = (0, kit_1.createSolanaRpcSubscriptions)(resolvedAddresses.rpcUrl.replace('https:', 'wss:').replace('http:', 'ws:'));
|
|
357
|
+
// Build transaction message with signer
|
|
358
|
+
const signerTransactionMessage = (0, kit_1.pipe)((0, kit_1.createTransactionMessage)({ version: 0 }), (msg) => (0, kit_1.setTransactionMessageFeePayerSigner)(signer, msg), (msg) => (0, kit_1.setTransactionMessageLifetimeUsingBlockhash)(latestBlockhash, msg), (msg) => (0, kit_1.appendTransactionMessageInstructions)([instruction], msg));
|
|
359
|
+
// Sign transaction
|
|
360
|
+
const signedTransaction = await (0, kit_1.signTransactionMessageWithSigners)(signerTransactionMessage);
|
|
361
|
+
// Send and confirm transaction
|
|
362
|
+
const sendAndConfirmTransaction = (0, kit_1.sendAndConfirmTransactionFactory)({ rpc: sendRpc, rpcSubscriptions: rpcSubscriptions });
|
|
363
|
+
try {
|
|
364
|
+
await sendAndConfirmTransaction(signedTransaction, {
|
|
365
|
+
commitment: effectiveConfig.transactionOptions?.commitment || 'confirmed',
|
|
366
|
+
skipPreflight: effectiveConfig.transactionOptions?.skipPreflight || false
|
|
367
|
+
});
|
|
368
|
+
// Extract and return the signature
|
|
369
|
+
const signature = (0, kit_1.getSignatureFromTransaction)(signedTransaction);
|
|
370
|
+
return signature;
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
throw new Error(`Transaction failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
})();
|
|
378
|
+
return createChainablePackedTransaction(packedTxPromise);
|
|
311
379
|
},
|
|
312
380
|
// Implement PromiseLike to allow direct awaiting
|
|
313
381
|
then(onfulfilled, onrejected) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EH,0DAkBC;AAwBD,8BAEC;AAMD,8BAEC;AAKD,kCAEC;AAiBD,8BAEC;AAMD,wDAKC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EH,0DAkBC;AAwBD,8BAEC;AAMD,8BAEC;AAKD,kCAEC;AAiBD,8BAEC;AAMD,wDAKC;AA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AiD;QACjD,IAAI,CACF,WAAqE,EACrE,UAAuE;YAEvE,OAAO,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACvE,CAAC;KACF,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/esm/package.json
CHANGED
package/dist/esm/utils/config.js
CHANGED
|
@@ -116,6 +116,72 @@ export async function getCachedNetworkModule(modulePath) {
|
|
|
116
116
|
}
|
|
117
117
|
return getModule(modulePath);
|
|
118
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Ensures the input is a proper Uint8Array compatible with web3.js
|
|
121
|
+
* Handles various TypedArray formats that @solana/kit might return
|
|
122
|
+
*/
|
|
123
|
+
function ensureUint8Array(input) {
|
|
124
|
+
// If it's already a standard Uint8Array, return as-is
|
|
125
|
+
if (input instanceof Uint8Array && input.constructor === Uint8Array) {
|
|
126
|
+
return input;
|
|
127
|
+
}
|
|
128
|
+
// Handle various ArrayBufferView types (including ReadonlyUint8Array)
|
|
129
|
+
if (ArrayBuffer.isView(input)) {
|
|
130
|
+
return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
131
|
+
}
|
|
132
|
+
// Handle objects with buffer property (some Node.js environments)
|
|
133
|
+
if (input && input.buffer && typeof input.byteLength === 'number') {
|
|
134
|
+
return new Uint8Array(input.buffer, input.byteOffset || 0, input.byteLength);
|
|
135
|
+
}
|
|
136
|
+
// Handle array-like objects and iterables
|
|
137
|
+
if (input && typeof input.length === 'number') {
|
|
138
|
+
return new Uint8Array(input);
|
|
139
|
+
}
|
|
140
|
+
// Handle objects that might be iterable but don't have length
|
|
141
|
+
if (input && typeof input[Symbol.iterator] === 'function') {
|
|
142
|
+
return new Uint8Array(Array.from(input));
|
|
143
|
+
}
|
|
144
|
+
// Fallback: try to create from the input directly
|
|
145
|
+
return new Uint8Array(input);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Create a chainable packed transaction that allows .pack().send() without double await
|
|
149
|
+
*
|
|
150
|
+
* @param packedTxPromise Promise that resolves to a PackedTransaction
|
|
151
|
+
* @returns ChainablePackedTransaction that can be chained with .send()
|
|
152
|
+
*/
|
|
153
|
+
function createChainablePackedTransaction(packedTxPromise) {
|
|
154
|
+
let cachedPackedTx = null;
|
|
155
|
+
const chainable = {
|
|
156
|
+
get messageBytes() {
|
|
157
|
+
if (cachedPackedTx)
|
|
158
|
+
return cachedPackedTx.messageBytes;
|
|
159
|
+
throw new Error('PackedTransaction not yet resolved. Use await on .pack() first, or use .send() directly for chaining.');
|
|
160
|
+
},
|
|
161
|
+
get signatures() {
|
|
162
|
+
if (cachedPackedTx)
|
|
163
|
+
return cachedPackedTx.signatures;
|
|
164
|
+
throw new Error('PackedTransaction not yet resolved. Use await on .pack() first, or use .send() directly for chaining.');
|
|
165
|
+
},
|
|
166
|
+
send: async (signer) => {
|
|
167
|
+
// If not cached, wait for the packed transaction
|
|
168
|
+
if (!cachedPackedTx) {
|
|
169
|
+
cachedPackedTx = await packedTxPromise;
|
|
170
|
+
}
|
|
171
|
+
return cachedPackedTx.send(signer);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
// Make the chainable object thenable so it can be awaited to get the PackedTransaction
|
|
175
|
+
const thenable = Object.assign(chainable, {
|
|
176
|
+
then(onfulfilled, onrejected) {
|
|
177
|
+
return packedTxPromise.then((packedTx) => {
|
|
178
|
+
cachedPackedTx = packedTx;
|
|
179
|
+
return onfulfilled ? onfulfilled(packedTx) : packedTx;
|
|
180
|
+
}, onrejected);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return thenable;
|
|
184
|
+
}
|
|
119
185
|
/**
|
|
120
186
|
* Create a chainable config selector with existing configuration state.
|
|
121
187
|
* This enables config chaining by merging new options with existing ones.
|
|
@@ -135,56 +201,57 @@ function createChainableConfigSelector(executeFn, existingConfig) {
|
|
|
135
201
|
const selector = {
|
|
136
202
|
set: (additionalOptions) => createChainableConfigSelector(executeFn, { ...existingConfig, ...additionalOptions }),
|
|
137
203
|
build: () => executeFn(existingConfig),
|
|
138
|
-
pack:
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
148
|
-
}
|
|
149
|
-
// Create RPC connection to get latest blockhash
|
|
150
|
-
const rpc = createSolanaRpc(resolvedAddresses.rpcUrl);
|
|
151
|
-
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
152
|
-
// Build unsigned transaction message
|
|
153
|
-
const transactionMessage = pipe(createTransactionMessage({ version: 0 }), (msg) => setTransactionMessageFeePayer(feePayer, msg), (msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg), (msg) => appendTransactionMessageInstructions([instruction], msg));
|
|
154
|
-
// Compile to unsigned transaction
|
|
155
|
-
const unsignedTransaction = compileTransaction(transactionMessage);
|
|
156
|
-
// Ensure messageBytes is a proper Uint8Array for web3.js compatibility
|
|
157
|
-
const messageBytes = unsignedTransaction.messageBytes instanceof Uint8Array
|
|
158
|
-
? unsignedTransaction.messageBytes
|
|
159
|
-
: new Uint8Array(unsignedTransaction.messageBytes);
|
|
160
|
-
// Return PackedTransaction with send() method
|
|
161
|
-
return {
|
|
162
|
-
messageBytes,
|
|
163
|
-
signatures: unsignedTransaction.signatures,
|
|
164
|
-
send: async (signer) => {
|
|
165
|
-
// Create RPC connections for sending
|
|
166
|
-
const sendRpc = createSolanaRpc(resolvedAddresses.rpcUrl);
|
|
167
|
-
const rpcSubscriptions = createSolanaRpcSubscriptions(resolvedAddresses.rpcUrl.replace('https:', 'wss:').replace('http:', 'ws:'));
|
|
168
|
-
// Build transaction message with signer
|
|
169
|
-
const signerTransactionMessage = pipe(createTransactionMessage({ version: 0 }), (msg) => setTransactionMessageFeePayerSigner(signer, msg), (msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg), (msg) => appendTransactionMessageInstructions([instruction], msg));
|
|
170
|
-
// Sign transaction
|
|
171
|
-
const signedTransaction = await signTransactionMessageWithSigners(signerTransactionMessage);
|
|
172
|
-
// Send and confirm transaction
|
|
173
|
-
const sendAndConfirmTransaction = sendAndConfirmTransactionFactory({ rpc: sendRpc, rpcSubscriptions: rpcSubscriptions });
|
|
174
|
-
try {
|
|
175
|
-
await sendAndConfirmTransaction(signedTransaction, {
|
|
176
|
-
commitment: effectiveConfig.transactionOptions?.commitment || 'confirmed',
|
|
177
|
-
skipPreflight: effectiveConfig.transactionOptions?.skipPreflight || false
|
|
178
|
-
});
|
|
179
|
-
// Extract and return the signature
|
|
180
|
-
const signature = getSignatureFromTransaction(signedTransaction);
|
|
181
|
-
return signature;
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
throw new Error(`Transaction failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
204
|
+
pack: (feePayer) => {
|
|
205
|
+
const packedTxPromise = (async () => {
|
|
206
|
+
const instruction = await executeFn(existingConfig);
|
|
207
|
+
const effectiveConfig = getEffectiveConfig(existingConfig);
|
|
208
|
+
const resolvedAddresses = resolveProgramAddresses(effectiveConfig);
|
|
209
|
+
if (!resolvedAddresses.rpcUrl) {
|
|
210
|
+
const networkType = effectiveConfig.programs || 'unknown';
|
|
211
|
+
if (networkType === 'atlasnet' || networkType === 'holosim') {
|
|
212
|
+
throw new Error(`RPC URL is required for ${networkType} network. Please provide your RPC endpoint via setConfig({ rpcUrl: "your-rpc-url-with-api-key" }) or .set({ rpcUrl: "your-rpc-url-with-api-key" })`);
|
|
185
213
|
}
|
|
214
|
+
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
186
215
|
}
|
|
187
|
-
|
|
216
|
+
// Create RPC connection to get latest blockhash
|
|
217
|
+
const rpc = createSolanaRpc(resolvedAddresses.rpcUrl);
|
|
218
|
+
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
219
|
+
// Build unsigned transaction message
|
|
220
|
+
const transactionMessage = pipe(createTransactionMessage({ version: 0 }), (msg) => setTransactionMessageFeePayer(feePayer, msg), (msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg), (msg) => appendTransactionMessageInstructions([instruction], msg));
|
|
221
|
+
// Compile to unsigned transaction
|
|
222
|
+
const unsignedTransaction = compileTransaction(transactionMessage);
|
|
223
|
+
// Ensure messageBytes is a proper Uint8Array for web3.js compatibility
|
|
224
|
+
const messageBytes = ensureUint8Array(unsignedTransaction.messageBytes);
|
|
225
|
+
// Return PackedTransaction with send() method
|
|
226
|
+
return {
|
|
227
|
+
messageBytes,
|
|
228
|
+
signatures: unsignedTransaction.signatures,
|
|
229
|
+
send: async (signer) => {
|
|
230
|
+
// Create RPC connections for sending
|
|
231
|
+
const sendRpc = createSolanaRpc(resolvedAddresses.rpcUrl);
|
|
232
|
+
const rpcSubscriptions = createSolanaRpcSubscriptions(resolvedAddresses.rpcUrl.replace('https:', 'wss:').replace('http:', 'ws:'));
|
|
233
|
+
// Build transaction message with signer
|
|
234
|
+
const signerTransactionMessage = pipe(createTransactionMessage({ version: 0 }), (msg) => setTransactionMessageFeePayerSigner(signer, msg), (msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg), (msg) => appendTransactionMessageInstructions([instruction], msg));
|
|
235
|
+
// Sign transaction
|
|
236
|
+
const signedTransaction = await signTransactionMessageWithSigners(signerTransactionMessage);
|
|
237
|
+
// Send and confirm transaction
|
|
238
|
+
const sendAndConfirmTransaction = sendAndConfirmTransactionFactory({ rpc: sendRpc, rpcSubscriptions: rpcSubscriptions });
|
|
239
|
+
try {
|
|
240
|
+
await sendAndConfirmTransaction(signedTransaction, {
|
|
241
|
+
commitment: effectiveConfig.transactionOptions?.commitment || 'confirmed',
|
|
242
|
+
skipPreflight: effectiveConfig.transactionOptions?.skipPreflight || false
|
|
243
|
+
});
|
|
244
|
+
// Extract and return the signature
|
|
245
|
+
const signature = getSignatureFromTransaction(signedTransaction);
|
|
246
|
+
return signature;
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
throw new Error(`Transaction failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
})();
|
|
254
|
+
return createChainablePackedTransaction(packedTxPromise);
|
|
188
255
|
},
|
|
189
256
|
// Implement PromiseLike to allow direct awaiting
|
|
190
257
|
then(onfulfilled, onrejected) {
|
|
@@ -216,56 +283,57 @@ export function createConfigSelector(executeFn) {
|
|
|
216
283
|
const selector = {
|
|
217
284
|
set: (options) => createChainableConfigSelector(executeFn, getEffectiveConfig(options)),
|
|
218
285
|
build: () => executeFn(getEffectiveConfig()),
|
|
219
|
-
pack:
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
229
|
-
}
|
|
230
|
-
// Create RPC connection to get latest blockhash
|
|
231
|
-
const rpc = createSolanaRpc(resolvedAddresses.rpcUrl);
|
|
232
|
-
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
233
|
-
// Build unsigned transaction message
|
|
234
|
-
const transactionMessage = pipe(createTransactionMessage({ version: 0 }), (msg) => setTransactionMessageFeePayer(feePayer, msg), (msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg), (msg) => appendTransactionMessageInstructions([instruction], msg));
|
|
235
|
-
// Compile to unsigned transaction
|
|
236
|
-
const unsignedTransaction = compileTransaction(transactionMessage);
|
|
237
|
-
// Ensure messageBytes is a proper Uint8Array for web3.js compatibility
|
|
238
|
-
const messageBytes = unsignedTransaction.messageBytes instanceof Uint8Array
|
|
239
|
-
? unsignedTransaction.messageBytes
|
|
240
|
-
: new Uint8Array(unsignedTransaction.messageBytes);
|
|
241
|
-
// Return PackedTransaction with send() method
|
|
242
|
-
return {
|
|
243
|
-
messageBytes,
|
|
244
|
-
signatures: unsignedTransaction.signatures,
|
|
245
|
-
send: async (signer) => {
|
|
246
|
-
// Create RPC connections for sending
|
|
247
|
-
const sendRpc = createSolanaRpc(resolvedAddresses.rpcUrl);
|
|
248
|
-
const rpcSubscriptions = createSolanaRpcSubscriptions(resolvedAddresses.rpcUrl.replace('https:', 'wss:').replace('http:', 'ws:'));
|
|
249
|
-
// Build transaction message with signer
|
|
250
|
-
const signerTransactionMessage = pipe(createTransactionMessage({ version: 0 }), (msg) => setTransactionMessageFeePayerSigner(signer, msg), (msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg), (msg) => appendTransactionMessageInstructions([instruction], msg));
|
|
251
|
-
// Sign transaction
|
|
252
|
-
const signedTransaction = await signTransactionMessageWithSigners(signerTransactionMessage);
|
|
253
|
-
// Send and confirm transaction
|
|
254
|
-
const sendAndConfirmTransaction = sendAndConfirmTransactionFactory({ rpc: sendRpc, rpcSubscriptions: rpcSubscriptions });
|
|
255
|
-
try {
|
|
256
|
-
await sendAndConfirmTransaction(signedTransaction, {
|
|
257
|
-
commitment: effectiveConfig.transactionOptions?.commitment || 'confirmed',
|
|
258
|
-
skipPreflight: effectiveConfig.transactionOptions?.skipPreflight || false
|
|
259
|
-
});
|
|
260
|
-
// Extract and return the signature
|
|
261
|
-
const signature = getSignatureFromTransaction(signedTransaction);
|
|
262
|
-
return signature;
|
|
263
|
-
}
|
|
264
|
-
catch (error) {
|
|
265
|
-
throw new Error(`Transaction failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
286
|
+
pack: (feePayer) => {
|
|
287
|
+
const packedTxPromise = (async () => {
|
|
288
|
+
const instruction = await executeFn(getEffectiveConfig());
|
|
289
|
+
const effectiveConfig = getEffectiveConfig();
|
|
290
|
+
const resolvedAddresses = resolveProgramAddresses(effectiveConfig);
|
|
291
|
+
if (!resolvedAddresses.rpcUrl) {
|
|
292
|
+
const networkType = effectiveConfig.programs || 'unknown';
|
|
293
|
+
if (networkType === 'atlasnet' || networkType === 'holosim') {
|
|
294
|
+
throw new Error(`RPC URL is required for ${networkType} network. Please provide your RPC endpoint via setConfig({ rpcUrl: "your-rpc-url-with-api-key" }) or .set({ rpcUrl: "your-rpc-url-with-api-key" })`);
|
|
266
295
|
}
|
|
296
|
+
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
267
297
|
}
|
|
268
|
-
|
|
298
|
+
// Create RPC connection to get latest blockhash
|
|
299
|
+
const rpc = createSolanaRpc(resolvedAddresses.rpcUrl);
|
|
300
|
+
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
301
|
+
// Build unsigned transaction message
|
|
302
|
+
const transactionMessage = pipe(createTransactionMessage({ version: 0 }), (msg) => setTransactionMessageFeePayer(feePayer, msg), (msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg), (msg) => appendTransactionMessageInstructions([instruction], msg));
|
|
303
|
+
// Compile to unsigned transaction
|
|
304
|
+
const unsignedTransaction = compileTransaction(transactionMessage);
|
|
305
|
+
// Ensure messageBytes is a proper Uint8Array for web3.js compatibility
|
|
306
|
+
const messageBytes = ensureUint8Array(unsignedTransaction.messageBytes);
|
|
307
|
+
// Return PackedTransaction with send() method
|
|
308
|
+
return {
|
|
309
|
+
messageBytes,
|
|
310
|
+
signatures: unsignedTransaction.signatures,
|
|
311
|
+
send: async (signer) => {
|
|
312
|
+
// Create RPC connections for sending
|
|
313
|
+
const sendRpc = createSolanaRpc(resolvedAddresses.rpcUrl);
|
|
314
|
+
const rpcSubscriptions = createSolanaRpcSubscriptions(resolvedAddresses.rpcUrl.replace('https:', 'wss:').replace('http:', 'ws:'));
|
|
315
|
+
// Build transaction message with signer
|
|
316
|
+
const signerTransactionMessage = pipe(createTransactionMessage({ version: 0 }), (msg) => setTransactionMessageFeePayerSigner(signer, msg), (msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg), (msg) => appendTransactionMessageInstructions([instruction], msg));
|
|
317
|
+
// Sign transaction
|
|
318
|
+
const signedTransaction = await signTransactionMessageWithSigners(signerTransactionMessage);
|
|
319
|
+
// Send and confirm transaction
|
|
320
|
+
const sendAndConfirmTransaction = sendAndConfirmTransactionFactory({ rpc: sendRpc, rpcSubscriptions: rpcSubscriptions });
|
|
321
|
+
try {
|
|
322
|
+
await sendAndConfirmTransaction(signedTransaction, {
|
|
323
|
+
commitment: effectiveConfig.transactionOptions?.commitment || 'confirmed',
|
|
324
|
+
skipPreflight: effectiveConfig.transactionOptions?.skipPreflight || false
|
|
325
|
+
});
|
|
326
|
+
// Extract and return the signature
|
|
327
|
+
const signature = getSignatureFromTransaction(signedTransaction);
|
|
328
|
+
return signature;
|
|
329
|
+
}
|
|
330
|
+
catch (error) {
|
|
331
|
+
throw new Error(`Transaction failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
})();
|
|
336
|
+
return createChainablePackedTransaction(packedTxPromise);
|
|
269
337
|
},
|
|
270
338
|
// Implement PromiseLike to allow direct awaiting
|
|
271
339
|
then(onfulfilled, onrejected) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,0CAA0C;AAC1C,OAAO,KAAK,YAAY,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAIL,eAAe,EACf,4BAA4B,EAC5B,wBAAwB,EACxB,6BAA6B,EAC7B,mCAAmC,EACnC,2CAA2C,EAC3C,oCA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AiD;QACjD,IAAI,CACF,WAAqE,EACrE,UAAuE;YAEvE,OAAO,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACvE,CAAC;KACF,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -95,7 +95,27 @@ export interface PackedTransaction {
|
|
|
95
95
|
* // Create signer from keypair bytes
|
|
96
96
|
* const signer = await createKeyPairSignerFromBytes(keypairBytes);
|
|
97
97
|
*
|
|
98
|
-
* // Pack transaction, then send
|
|
98
|
+
* // Pack transaction, then send (now chainable!)
|
|
99
|
+
* const signature = await createContract(params)
|
|
100
|
+
* .pack(signer.address)
|
|
101
|
+
* .send(signer);
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
send(signer: TransactionSigner): Promise<string>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Chainable PackedTransaction that allows fluent .pack().send() without double await
|
|
108
|
+
*/
|
|
109
|
+
export interface ChainablePackedTransaction extends PackedTransaction {
|
|
110
|
+
/**
|
|
111
|
+
* Chainable send method that can be called directly on pack() result
|
|
112
|
+
*
|
|
113
|
+
* @param signer The transaction signer that will sign and pay for the transaction
|
|
114
|
+
* @returns Promise resolving to the transaction signature
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* // Now works without double await!
|
|
99
119
|
* const signature = await createContract(params)
|
|
100
120
|
* .pack(signer.address)
|
|
101
121
|
* .send(signer);
|
|
@@ -120,11 +140,11 @@ export interface ConfigSelector<T> extends PromiseLike<T> {
|
|
|
120
140
|
* Pack the instruction into an unsigned transaction ready for signing and sending
|
|
121
141
|
*
|
|
122
142
|
* @param feePayer The address that will pay for the transaction fees
|
|
123
|
-
* @returns
|
|
143
|
+
* @returns ChainablePackedTransaction with send() method (no double await needed!)
|
|
124
144
|
*
|
|
125
145
|
* @example
|
|
126
146
|
* ```typescript
|
|
127
|
-
* // Option 1: Pack and send (server-side/CLI)
|
|
147
|
+
* // Option 1: Pack and send (server-side/CLI) - Now chainable!
|
|
128
148
|
* import { createKeyPairSignerFromBytes } from '@solana/kit';
|
|
129
149
|
* const signer = await createKeyPairSignerFromBytes(keypairBytes);
|
|
130
150
|
* const signature = await createContract(params)
|
|
@@ -142,7 +162,7 @@ export interface ConfigSelector<T> extends PromiseLike<T> {
|
|
|
142
162
|
* const txBytes = packedTx.messageBytes;
|
|
143
163
|
* ```
|
|
144
164
|
*/
|
|
145
|
-
pack(feePayer: Address | string):
|
|
165
|
+
pack(feePayer: Address | string): ChainablePackedTransaction;
|
|
146
166
|
}
|
|
147
167
|
/**
|
|
148
168
|
* Create the initial fluent config selector for a function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,iBAAiB,EAcvB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAwB5D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE;QACnB,UAAU,CAAC,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;QACrD,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB,CAAC;CACH;AAQD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,aAAa;;;;;;;EAkB5D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;A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