@wuwei-labs/srsly 2.0.0-beta.20 → 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 +82 -58
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/utils/config.js +164 -80
- package/dist/cjs/utils/config.js.map +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/utils/config.js +164 -80
- package/dist/esm/utils/config.js.map +1 -1
- package/dist/types/utils/config.d.ts +26 -6
- package/dist/types/utils/config.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ setConfig({
|
|
|
46
46
|
// 2. Create signer from keypair
|
|
47
47
|
const signer = await createKeyPairSignerFromBytes(keypairBytes);
|
|
48
48
|
|
|
49
|
-
// 3. Pack
|
|
49
|
+
// 3. Pack and send in one chain (NEW: No double await needed!)
|
|
50
50
|
const signature = await createContract({
|
|
51
51
|
owner: signer,
|
|
52
52
|
fleet: fleetAddress,
|
|
@@ -55,14 +55,16 @@ const signature = await createContract({
|
|
|
55
55
|
durationMin: 86400, // 1 day
|
|
56
56
|
durationMax: 604800, // 1 week
|
|
57
57
|
paymentsFreq: 'daily'
|
|
58
|
-
})
|
|
59
|
-
.pack(signer.address) // Pack with fee payer
|
|
60
|
-
.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',
|
|
@@ -98,10 +100,15 @@ const packedTx = await createContract({
|
|
|
98
100
|
// 3. Sign and send with wallet adapter
|
|
99
101
|
import { useWallet } from '@solana/wallet-adapter-react';
|
|
100
102
|
import { VersionedTransaction } from '@solana/web3.js';
|
|
103
|
+
|
|
101
104
|
const wallet = useWallet();
|
|
105
|
+
|
|
106
|
+
// The messageBytes are now properly formatted for web3.js compatibility
|
|
102
107
|
const versionedTx = VersionedTransaction.deserialize(packedTx.messageBytes);
|
|
103
108
|
const signedTx = await wallet.signTransaction(versionedTx);
|
|
104
|
-
|
|
109
|
+
|
|
110
|
+
// Send the signed transaction
|
|
111
|
+
const signature = await connection.sendRawTransaction(signedTx.serialize());
|
|
105
112
|
|
|
106
113
|
// Note: packedTx also has a .send() method, but it requires a TransactionSigner
|
|
107
114
|
// which wallet adapters don't provide directly
|
|
@@ -129,6 +136,15 @@ const instruction = await createContract({
|
|
|
129
136
|
|
|
130
137
|
## Core Features
|
|
131
138
|
|
|
139
|
+
### Dual Compatibility
|
|
140
|
+
|
|
141
|
+
The SDK provides two optimized paths for different environments:
|
|
142
|
+
|
|
143
|
+
- **🌐 Browser/Wallet Adapter Path**: Uses `.pack()` to create `messageBytes` compatible with `web3.js` `VersionedTransaction.deserialize()`
|
|
144
|
+
- **🖥️ Server/CLI Path**: Uses `.pack().send()` with `@solana/kit` for direct transaction submission
|
|
145
|
+
|
|
146
|
+
Both paths are independent and fully optimized for their respective use cases.
|
|
147
|
+
|
|
132
148
|
### Flexible Address Input
|
|
133
149
|
|
|
134
150
|
The SDK accepts both string and Address types for all address parameters, automatically converting them to the proper format:
|
|
@@ -204,56 +220,74 @@ const closeIx = await closeRental({
|
|
|
204
220
|
});
|
|
205
221
|
```
|
|
206
222
|
|
|
207
|
-
##
|
|
223
|
+
## Configuration
|
|
208
224
|
|
|
209
|
-
The SDK
|
|
225
|
+
The SDK provides flexible configuration options for different networks and custom setups:
|
|
210
226
|
|
|
211
227
|
### Global Configuration
|
|
212
228
|
|
|
213
229
|
```typescript
|
|
214
230
|
import { setConfig, getConfig, clearConfig } from '@wuwei-labs/srsly';
|
|
215
231
|
|
|
216
|
-
//
|
|
217
|
-
setConfig({
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
rpcUrl: 'https://
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
+
}
|
|
229
251
|
});
|
|
230
252
|
|
|
231
|
-
//
|
|
232
|
-
setConfig({
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
gameId: 'custom-game-id...',
|
|
236
|
-
atlasMint: 'custom-atlas-mint...'
|
|
237
|
-
// mainnet includes default RPC URL
|
|
238
|
-
});
|
|
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
|
|
239
257
|
|
|
240
|
-
// Check current
|
|
258
|
+
// Check current configuration
|
|
241
259
|
console.log(getConfig());
|
|
242
260
|
|
|
243
261
|
// Reset to defaults
|
|
244
262
|
clearConfig();
|
|
245
263
|
```
|
|
246
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
|
+
|
|
247
278
|
### Per-Instruction Configuration
|
|
248
279
|
|
|
249
280
|
```typescript
|
|
250
281
|
// Override global config for specific instructions
|
|
251
|
-
const ix = await createContract(params).set({
|
|
282
|
+
const ix = await createContract(params).set({
|
|
283
|
+
programs: 'mainnet',
|
|
284
|
+
transactionOptions: { commitment: 'finalized' }
|
|
285
|
+
});
|
|
252
286
|
|
|
253
287
|
// Chain multiple configurations
|
|
254
288
|
const ix2 = await acceptRental(params)
|
|
255
|
-
.set({ programs: 'holosim' })
|
|
256
|
-
.set({ gameId: 'custom-game-id...' });
|
|
289
|
+
.set({ programs: 'holosim', rpcUrl: 'https://custom-rpc.com' })
|
|
290
|
+
.set({ gameId: 'custom-game-id...', atlasMint: 'custom-mint...' });
|
|
257
291
|
```
|
|
258
292
|
|
|
259
293
|
## Payment System
|
|
@@ -272,34 +306,24 @@ const duration = 86400; // 1 day in seconds
|
|
|
272
306
|
const totalAmount = rate * duration * ATLAS_TO_STARDUST; // in stardust
|
|
273
307
|
```
|
|
274
308
|
|
|
275
|
-
##
|
|
309
|
+
## Program Sets Reference
|
|
310
|
+
|
|
311
|
+
The SDK includes predefined program address sets for different networks:
|
|
312
|
+
|
|
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:
|
|
276
320
|
|
|
277
321
|
```typescript
|
|
278
|
-
//
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
sageProgram: 'SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE',
|
|
282
|
-
gameId: 'GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr',
|
|
283
|
-
atlasMint: 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx',
|
|
284
|
-
rpcUrl: 'https://api.mainnet-beta.solana.com' // Default RPC for mainnet
|
|
285
|
-
},
|
|
286
|
-
atlasnet: {
|
|
287
|
-
sageProgram: 'SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF',
|
|
288
|
-
gameId: 'GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k',
|
|
289
|
-
atlasMint: 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx'
|
|
290
|
-
// No default RPC - must provide rpcUrl required permissions
|
|
291
|
-
},
|
|
292
|
-
holosim: {
|
|
293
|
-
sageProgram: 'SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF',
|
|
294
|
-
gameId: 'GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k',
|
|
295
|
-
atlasMint: 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx'
|
|
296
|
-
// No default RPC - must provide rpcUrl required permissions
|
|
297
|
-
}
|
|
298
|
-
};
|
|
322
|
+
setConfig({ programs: 'atlasnet' }); // Missing rpcUrl!
|
|
323
|
+
await createContract(params).pack(address);
|
|
324
|
+
// Error: RPC URL is required for atlasnet network. Please provide your RPC endpoint...
|
|
299
325
|
```
|
|
300
326
|
|
|
301
|
-
**Note**: Atlasnet and holosim networks require you to explicitly provide an `rpcUrl` in your configuration since they don't have default RPC endpoints.
|
|
302
|
-
|
|
303
327
|
## Types and Constants
|
|
304
328
|
|
|
305
329
|
```typescript
|
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,48 +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
|
-
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
190
|
-
// Build unsigned transaction message
|
|
191
|
-
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));
|
|
192
|
-
// Compile to unsigned transaction
|
|
193
|
-
const unsignedTransaction = (0, kit_1.compileTransaction)(transactionMessage);
|
|
194
|
-
// Return PackedTransaction with send() method
|
|
195
|
-
return {
|
|
196
|
-
messageBytes: unsignedTransaction.messageBytes,
|
|
197
|
-
signatures: unsignedTransaction.signatures,
|
|
198
|
-
send: async (signer) => {
|
|
199
|
-
// Create RPC connections for sending
|
|
200
|
-
const sendRpc = (0, kit_1.createSolanaRpc)(resolvedAddresses.rpcUrl);
|
|
201
|
-
const rpcSubscriptions = (0, kit_1.createSolanaRpcSubscriptions)(resolvedAddresses.rpcUrl.replace('https:', 'wss:').replace('http:', 'ws:'));
|
|
202
|
-
// Build transaction message with signer
|
|
203
|
-
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));
|
|
204
|
-
// Sign transaction
|
|
205
|
-
const signedTransaction = await (0, kit_1.signTransactionMessageWithSigners)(signerTransactionMessage);
|
|
206
|
-
// Send and confirm transaction
|
|
207
|
-
const sendAndConfirmTransaction = (0, kit_1.sendAndConfirmTransactionFactory)({ rpc: sendRpc, rpcSubscriptions: rpcSubscriptions });
|
|
208
|
-
try {
|
|
209
|
-
await sendAndConfirmTransaction(signedTransaction, {
|
|
210
|
-
commitment: effectiveConfig.transactionOptions?.commitment || 'confirmed',
|
|
211
|
-
skipPreflight: effectiveConfig.transactionOptions?.skipPreflight || false
|
|
212
|
-
});
|
|
213
|
-
// Extract and return the signature
|
|
214
|
-
const signature = (0, kit_1.getSignatureFromTransaction)(signedTransaction);
|
|
215
|
-
return signature;
|
|
216
|
-
}
|
|
217
|
-
catch (error) {
|
|
218
|
-
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" })`);
|
|
219
255
|
}
|
|
256
|
+
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
220
257
|
}
|
|
221
|
-
|
|
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);
|
|
222
297
|
},
|
|
223
298
|
// Implement PromiseLike to allow direct awaiting
|
|
224
299
|
then(onfulfilled, onrejected) {
|
|
@@ -250,48 +325,57 @@ function createConfigSelector(executeFn) {
|
|
|
250
325
|
const selector = {
|
|
251
326
|
set: (options) => createChainableConfigSelector(executeFn, getEffectiveConfig(options)),
|
|
252
327
|
build: () => executeFn(getEffectiveConfig()),
|
|
253
|
-
pack:
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
263
|
-
// Build unsigned transaction message
|
|
264
|
-
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));
|
|
265
|
-
// Compile to unsigned transaction
|
|
266
|
-
const unsignedTransaction = (0, kit_1.compileTransaction)(transactionMessage);
|
|
267
|
-
// Return PackedTransaction with send() method
|
|
268
|
-
return {
|
|
269
|
-
messageBytes: unsignedTransaction.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)}`);
|
|
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" })`);
|
|
292
337
|
}
|
|
338
|
+
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
293
339
|
}
|
|
294
|
-
|
|
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);
|
|
295
379
|
},
|
|
296
380
|
// Implement PromiseLike to allow direct awaiting
|
|
297
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;AAmTD,oDA0FC;AA9iBD,0CAA0C;AAC1C,qEAAuD;AACvD,6DAA+C;AAC/C,qCAgBqB;AA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E,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,48 +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
|
-
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
148
|
-
// Build unsigned transaction message
|
|
149
|
-
const transactionMessage = pipe(createTransactionMessage({ version: 0 }), (msg) => setTransactionMessageFeePayer(feePayer, msg), (msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg), (msg) => appendTransactionMessageInstructions([instruction], msg));
|
|
150
|
-
// Compile to unsigned transaction
|
|
151
|
-
const unsignedTransaction = compileTransaction(transactionMessage);
|
|
152
|
-
// Return PackedTransaction with send() method
|
|
153
|
-
return {
|
|
154
|
-
messageBytes: unsignedTransaction.messageBytes,
|
|
155
|
-
signatures: unsignedTransaction.signatures,
|
|
156
|
-
send: async (signer) => {
|
|
157
|
-
// Create RPC connections for sending
|
|
158
|
-
const sendRpc = createSolanaRpc(resolvedAddresses.rpcUrl);
|
|
159
|
-
const rpcSubscriptions = createSolanaRpcSubscriptions(resolvedAddresses.rpcUrl.replace('https:', 'wss:').replace('http:', 'ws:'));
|
|
160
|
-
// Build transaction message with signer
|
|
161
|
-
const signerTransactionMessage = pipe(createTransactionMessage({ version: 0 }), (msg) => setTransactionMessageFeePayerSigner(signer, msg), (msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg), (msg) => appendTransactionMessageInstructions([instruction], msg));
|
|
162
|
-
// Sign transaction
|
|
163
|
-
const signedTransaction = await signTransactionMessageWithSigners(signerTransactionMessage);
|
|
164
|
-
// Send and confirm transaction
|
|
165
|
-
const sendAndConfirmTransaction = sendAndConfirmTransactionFactory({ rpc: sendRpc, rpcSubscriptions: rpcSubscriptions });
|
|
166
|
-
try {
|
|
167
|
-
await sendAndConfirmTransaction(signedTransaction, {
|
|
168
|
-
commitment: effectiveConfig.transactionOptions?.commitment || 'confirmed',
|
|
169
|
-
skipPreflight: effectiveConfig.transactionOptions?.skipPreflight || false
|
|
170
|
-
});
|
|
171
|
-
// Extract and return the signature
|
|
172
|
-
const signature = getSignatureFromTransaction(signedTransaction);
|
|
173
|
-
return signature;
|
|
174
|
-
}
|
|
175
|
-
catch (error) {
|
|
176
|
-
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" })`);
|
|
177
213
|
}
|
|
214
|
+
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
178
215
|
}
|
|
179
|
-
|
|
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);
|
|
180
255
|
},
|
|
181
256
|
// Implement PromiseLike to allow direct awaiting
|
|
182
257
|
then(onfulfilled, onrejected) {
|
|
@@ -208,48 +283,57 @@ export function createConfigSelector(executeFn) {
|
|
|
208
283
|
const selector = {
|
|
209
284
|
set: (options) => createChainableConfigSelector(executeFn, getEffectiveConfig(options)),
|
|
210
285
|
build: () => executeFn(getEffectiveConfig()),
|
|
211
|
-
pack:
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
221
|
-
// Build unsigned transaction message
|
|
222
|
-
const transactionMessage = pipe(createTransactionMessage({ version: 0 }), (msg) => setTransactionMessageFeePayer(feePayer, msg), (msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg), (msg) => appendTransactionMessageInstructions([instruction], msg));
|
|
223
|
-
// Compile to unsigned transaction
|
|
224
|
-
const unsignedTransaction = compileTransaction(transactionMessage);
|
|
225
|
-
// Return PackedTransaction with send() method
|
|
226
|
-
return {
|
|
227
|
-
messageBytes: unsignedTransaction.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)}`);
|
|
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" })`);
|
|
250
295
|
}
|
|
296
|
+
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
251
297
|
}
|
|
252
|
-
|
|
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);
|
|
253
337
|
},
|
|
254
338
|
// Implement PromiseLike to allow direct awaiting
|
|
255
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,oCAAoC,EACpC,kBAAkB,EAClB,iCAAiC,EACjC,gCAAgC,EAChC,2BAA2B,EAC3B,IAAI,GACL,MAAM,aAAa,CAAC;AAIrB,MAAM,YAAY,GAAG;IACnB,OAAO,EAAE;QACP,oBAAoB,EAAE,6CAA6C;QACnE,+BAA+B,EAAE,6CAA6C;QAC9E,YAAY,EAAE,8CAA8C;QAC5D,UAAU,EAAE,8CAA8C;QAC1D,OAAO,EAAE,qCAAqC;KAC/C;IACD,QAAQ,EAAE;QACR,oBAAoB,EAAE,6CAA6C;QACnE,+BAA+B,EAAE,6CAA6C;QAC9E,YAAY,EAAE,8CAA8C;QAC5D,UAAU,EAAE,8CAA8C;KAC3D;IACD,OAAO,EAAE;QACP,oBAAoB,EAAE,6CAA6C;QACnE,+BAA+B,EAAE,6CAA6C;QAC9E,YAAY,EAAE,8CAA8C;QAC5D,UAAU,EAAE,8CAA8C;KAC3D;CACO,CAAC;AAkBX,6CAA6C;AAC7C,MAAM,mBAAmB,GAAe,UAAU,CAAC;AAEnD,6BAA6B;AAC7B,IAAI,YAAY,GAAkB,EAAE,CAAC;AAErC;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAqB;IAC3D,qCAAqC;IACrC,MA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,aAAa,IAAI,KAAK;6BAC1E,CAAC,CAAC;4BAEH,mCAAmC;4BACnC,MAAM,SAAS,GAAG,2BAA2B,CAAC,iBAAiB,CAAC,CAAC;4BACjE,OAAO,SAAS,CAAC;wBACnB,CAAC;wBAAC,OAAO,KAAK,EAAE,CAAC;4BACf,MAAM,IAAI,KAAK,CAAC,uBAAuB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;wBACnG,CAAC;oBACH,CAAC;iBACF,CAAC;YACJ,CAAC,CAAC,EAAE,CAAC;YAEL,OAAO,gCAAgC,CAAC,eAAe,CAAC,CAAC;QAC3D,CAAC;QACD,iDAAiD;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"}
|
|
@@ -78,8 +78,8 @@ export declare function getCachedNetworkModule<T = any>(modulePath: string): Pro
|
|
|
78
78
|
* Interface for a packed transaction that can be sent or used with wallet adapters
|
|
79
79
|
*/
|
|
80
80
|
export interface PackedTransaction {
|
|
81
|
-
/** Raw transaction message bytes
|
|
82
|
-
messageBytes:
|
|
81
|
+
/** Raw transaction message bytes compatible with web3.js VersionedTransaction.deserialize() */
|
|
82
|
+
messageBytes: Uint8Array;
|
|
83
83
|
/** Transaction signature map (empty for unsigned transactions) */
|
|
84
84
|
signatures: any;
|
|
85
85
|
/**
|
|
@@ -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;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAErD;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,aAAa,CAEzC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAYD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,cAAc,GAAG,UAAU,GAAG,GAAG,CAEtE;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAKpF;
|
|
1
|
+
{"version":3,"file":"config.d.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