@wuwei-labs/srsly 2.0.0-beta.29 → 2.0.0-beta.31
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 +101 -263
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/utils/instruction-converter.js +24 -7
- package/dist/cjs/utils/instruction-converter.js.map +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/utils/instruction-converter.js +24 -7
- package/dist/esm/utils/instruction-converter.js.map +1 -1
- package/dist/types/utils/instruction-converter.d.ts +51 -10
- package/dist/types/utils/instruction-converter.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,56 +4,43 @@
|
|
|
4
4
|
[](https://www.typescriptlang.org/)
|
|
5
5
|
[](https://solana.com/)
|
|
6
6
|
|
|
7
|
-
A
|
|
7
|
+
A TypeScript SDK for building Solana instructions to interact with the SRSLY (Space Rental from SLY) program - a decentralized rental system for Star Atlas fleets.
|
|
8
8
|
|
|
9
9
|
## What This SDK Does
|
|
10
10
|
|
|
11
11
|
The SRSLY SDK is a focused instruction builder that helps you create Solana instructions for fleet rentals. It provides:
|
|
12
12
|
|
|
13
|
-
- ✅ **
|
|
14
|
-
- ✅ **Instruction Building** - Creates properly formatted Solana instructions
|
|
13
|
+
- ✅ **Instruction Building** - Creates properly formatted Solana instructions using @solana/kit
|
|
15
14
|
- ✅ **Account derivation and validation** - Automatically derives required accounts
|
|
16
15
|
- ✅ **Instruction data encoding** - Handles all the complex encoding for you
|
|
17
16
|
- ✅ **Type-safe parameter handling** - Full TypeScript support with validation
|
|
18
|
-
- ✅ **Format conversion utilities** - Easy conversion between library formats
|
|
19
17
|
- ✅ **Duration helper functions** - `days()`, `weeks()`, `months()` for time calculations
|
|
20
|
-
- ✅ **
|
|
18
|
+
- ✅ **Default Star Atlas Programs** - Support for mainnet, atlasnet, and holosim
|
|
21
19
|
|
|
22
|
-
**Current Status**: Instruction
|
|
20
|
+
**Current Status**: Instruction-only SDK using @solana/kit. Users handle transaction assembly and sending.
|
|
23
21
|
|
|
24
22
|
## Installation
|
|
25
23
|
|
|
26
24
|
```bash
|
|
27
|
-
# Install the SDK
|
|
25
|
+
# Install the SDK (includes @solana/kit as a dependency)
|
|
28
26
|
npm install @wuwei-labs/srsly
|
|
29
|
-
|
|
30
|
-
# Install your preferred Solana library
|
|
31
|
-
# Option A: Modern @solana/kit (recommended)
|
|
32
|
-
npm install @solana/kit
|
|
33
|
-
|
|
34
|
-
# Option B: Legacy @solana/web3.js (wallet adapter compatibility)
|
|
35
|
-
npm install @solana/web3.js
|
|
36
|
-
|
|
37
|
-
# Option C: Both libraries (for maximum flexibility)
|
|
38
|
-
npm install @solana/kit @solana/web3.js
|
|
39
27
|
```
|
|
40
28
|
|
|
41
|
-
The SDK
|
|
29
|
+
The SDK uses @solana/kit internally and provides seamless conversion to @solana/web3.js format for browser wallet compatibility.
|
|
42
30
|
|
|
43
31
|
## Quick Start
|
|
44
32
|
|
|
45
|
-
###
|
|
33
|
+
### Using with @solana/kit (Default)
|
|
46
34
|
|
|
47
35
|
```typescript
|
|
48
|
-
import { createContract, setConfig, days
|
|
49
|
-
import { createKeyPairSignerFromBytes, createTransactionMessage, pipe } from '@solana/kit';
|
|
36
|
+
import { createContract, setConfig, days } from '@wuwei-labs/srsly';
|
|
50
37
|
|
|
51
38
|
// 1. Configure SDK for your network
|
|
52
39
|
setConfig({
|
|
53
40
|
programs: 'atlasnet' // or 'mainnet', 'holosim'
|
|
54
41
|
});
|
|
55
42
|
|
|
56
|
-
// 2. Create an instruction
|
|
43
|
+
// 2. Create an instruction (returns @solana/kit format by default)
|
|
57
44
|
const instruction = await createContract({
|
|
58
45
|
owner: signer, // Can be a signer object or string address
|
|
59
46
|
fleet: "FleetAddress123...", // String address
|
|
@@ -63,93 +50,83 @@ const instruction = await createContract({
|
|
|
63
50
|
paymentsFreq: 'daily' // Payment frequency
|
|
64
51
|
});
|
|
65
52
|
|
|
66
|
-
// 3.
|
|
67
|
-
|
|
68
|
-
createTransactionMessage({ version: 0 }),
|
|
69
|
-
// ... add instruction to transaction and send with @solana/kit
|
|
70
|
-
);
|
|
53
|
+
// 3. Add instruction to your transaction and send
|
|
54
|
+
// (Use your preferred transaction building and sending method)
|
|
71
55
|
```
|
|
72
56
|
|
|
73
|
-
###
|
|
57
|
+
### Using with @solana/web3.js (wallet-adapter)
|
|
74
58
|
|
|
75
59
|
```typescript
|
|
76
|
-
import { createContract, setConfig, days
|
|
60
|
+
import { createContract, setConfig, days } from '@wuwei-labs/srsly';
|
|
77
61
|
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
78
62
|
|
|
79
|
-
// 1. Configure SDK
|
|
63
|
+
// 1. Configure SDK for your network
|
|
80
64
|
setConfig({ programs: 'atlasnet' });
|
|
81
65
|
|
|
82
|
-
// 2. Create
|
|
83
|
-
const
|
|
66
|
+
// 2. Create and convert to web3.js format
|
|
67
|
+
const web3jsInstruction = await createContract({
|
|
84
68
|
owner: wallet.publicKey.toString(), // String address
|
|
85
|
-
fleet: "FleetAddress123...",
|
|
86
|
-
ownerProfile: "ProfileAddr...",
|
|
69
|
+
fleet: "FleetAddress123...", // String address
|
|
70
|
+
ownerProfile: "ProfileAddr...", // String address
|
|
87
71
|
rate: 1000000,
|
|
88
72
|
durationMax: days(7),
|
|
89
73
|
paymentsFreq: 'daily'
|
|
90
|
-
});
|
|
74
|
+
}).web3js(PublicKey); // Convert to web3.js format with PublicKey instances
|
|
91
75
|
|
|
92
|
-
// 3.
|
|
93
|
-
const web3jsInstruction = convertKitToWeb3js(kitInstruction);
|
|
76
|
+
// 3. Add to transaction and send
|
|
94
77
|
const transaction = new Transaction().add(web3jsInstruction);
|
|
95
|
-
|
|
96
|
-
// Sign and send with your preferred method
|
|
97
78
|
const signature = await wallet.sendTransaction(transaction, connection);
|
|
98
79
|
```
|
|
99
80
|
|
|
100
81
|
## Core Features
|
|
101
82
|
|
|
102
|
-
###
|
|
83
|
+
### Instruction Building & Format Conversion
|
|
84
|
+
|
|
85
|
+
The SDK creates @solana/kit compatible instructions with seamless web3.js conversion:
|
|
103
86
|
|
|
104
|
-
|
|
87
|
+
- **📦 Instruction-Only**: Focus on instruction building, users handle transaction assembly/sending
|
|
88
|
+
- **🔄 Format Conversion**: Built-in `.web3js(PublicKey)` method for wallet compatibility
|
|
89
|
+
- **🎯 String Addresses**: Simple string-based addressing for all inputs
|
|
90
|
+
- **⚡ Lightweight**: Uses @solana/kit internally with optional web3.js conversion
|
|
105
91
|
|
|
106
|
-
|
|
107
|
-
- **📦 Instruction-Only**: Focus on instruction building, users handle transaction packing/sending
|
|
108
|
-
- **🎯 String Addresses**: Simple string-based addressing eliminates type complexity
|
|
109
|
-
- **⚡ Lightweight**: No bundled Solana libraries, users choose their own
|
|
92
|
+
### Web3.js Format Conversion
|
|
110
93
|
|
|
111
|
-
|
|
94
|
+
The SDK accepts string addresses as input and provides seamless conversion to @solana/web3.js format for browser wallet compatibility:
|
|
112
95
|
|
|
113
96
|
```typescript
|
|
114
|
-
import { createContract
|
|
97
|
+
import { createContract } from '@wuwei-labs/srsly';
|
|
98
|
+
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
115
99
|
|
|
116
|
-
//
|
|
117
|
-
const
|
|
100
|
+
// Web3.js format with PublicKey instances
|
|
101
|
+
const web3jsInstruction = await createContract({
|
|
102
|
+
owner: "OwnerAddress123...", // String address input
|
|
103
|
+
fleet: "FleetAddress123...", // String address input
|
|
104
|
+
ownerProfile: "ProfileAddr...", // String address input
|
|
105
|
+
rate: 1000000,
|
|
106
|
+
durationMax: days(7),
|
|
107
|
+
paymentsFreq: 'daily'
|
|
108
|
+
}).web3js(PublicKey);
|
|
118
109
|
|
|
119
|
-
//
|
|
120
|
-
const
|
|
110
|
+
// Chain configuration with conversion
|
|
111
|
+
const configuredInstruction = await createContract({
|
|
112
|
+
owner: "OwnerAddress123...",
|
|
113
|
+
fleet: "FleetAddress123...",
|
|
114
|
+
ownerProfile: "ProfileAddr...",
|
|
115
|
+
rate: 1000000,
|
|
116
|
+
durationMax: days(7),
|
|
117
|
+
paymentsFreq: 'daily'
|
|
118
|
+
}).set({ programs: 'mainnet' })
|
|
119
|
+
.web3js(PublicKey);
|
|
121
120
|
|
|
122
|
-
//
|
|
121
|
+
// Use in transactions
|
|
123
122
|
const transaction = new Transaction().add(web3jsInstruction);
|
|
124
123
|
```
|
|
125
124
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
setConfig({
|
|
130
|
-
programs: 'atlasnet',
|
|
131
|
-
rpcUrl: 'https://api.atlasnet.com',
|
|
132
|
-
solanaLibrary: 'kit' // 'auto' | 'kit' | 'web3js'
|
|
133
|
-
});
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Flexible Address Input
|
|
125
|
+
**Key points:**
|
|
137
126
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
import { createContract, address } from '@wuwei-labs/srsly';
|
|
142
|
-
|
|
143
|
-
// Mixed usage allowed
|
|
144
|
-
const createIx = await createContract({
|
|
145
|
-
owner: wallet,
|
|
146
|
-
fleet: "123abc...", // string
|
|
147
|
-
ownerProfile: address("456def..."), // Address<string>
|
|
148
|
-
rate: 5000000,
|
|
149
|
-
durationMax: 2592000,
|
|
150
|
-
paymentsFreq: 'daily' // Minimum duration automatically set to 1 day
|
|
151
|
-
});
|
|
152
|
-
```
|
|
127
|
+
- SDK inputs are always **string addresses**
|
|
128
|
+
- `.web3js(PublicKey)` converts output to web3.js format with PublicKey instances
|
|
129
|
+
- Use when working with browser wallets (Phantom, Solflare, etc.)
|
|
153
130
|
|
|
154
131
|
### Duration Helper Functions
|
|
155
132
|
|
|
@@ -172,7 +149,7 @@ const contract = await createContract({
|
|
|
172
149
|
ownerProfile: profileAddress,
|
|
173
150
|
rate: 1000000,
|
|
174
151
|
durationMax: weeks(2), // 2 weeks maximum
|
|
175
|
-
paymentsFreq: 'daily'
|
|
152
|
+
paymentsFreq: 'daily'
|
|
176
153
|
});
|
|
177
154
|
|
|
178
155
|
// Alternative: use the duration object
|
|
@@ -182,7 +159,7 @@ const anotherContract = await createContract({
|
|
|
182
159
|
ownerProfile: profileAddress,
|
|
183
160
|
rate: 500000,
|
|
184
161
|
durationMax: duration.months(3), // 3 months maximum
|
|
185
|
-
paymentsFreq: 'weekly'
|
|
162
|
+
paymentsFreq: 'weekly'
|
|
186
163
|
});
|
|
187
164
|
|
|
188
165
|
// You can still use raw seconds if preferred
|
|
@@ -208,7 +185,7 @@ const createIx = await createContract({
|
|
|
208
185
|
ownerProfile: profileAddress,
|
|
209
186
|
rate: 5000000,
|
|
210
187
|
durationMax: months(1), // 30 days using helper function
|
|
211
|
-
paymentsFreq: 'daily'
|
|
188
|
+
paymentsFreq: 'daily'
|
|
212
189
|
});
|
|
213
190
|
|
|
214
191
|
// Close contract instruction
|
|
@@ -222,15 +199,16 @@ const closeIx = await closeContract({
|
|
|
222
199
|
### Rental Operations
|
|
223
200
|
|
|
224
201
|
```typescript
|
|
225
|
-
import { acceptRental, cancelRental, closeRental } from '@wuwei-labs/srsly';
|
|
202
|
+
import { acceptRental, cancelRental, closeRental, resetRental } from '@wuwei-labs/srsly';
|
|
203
|
+
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
226
204
|
|
|
227
|
-
// Accept rental offer instruction
|
|
205
|
+
// Accept rental offer instruction (all addresses are strings)
|
|
228
206
|
const acceptIx = await acceptRental({
|
|
229
|
-
borrower: borrowerWallet,
|
|
230
|
-
borrowerProfile: borrowerProfileAddress,
|
|
207
|
+
borrower: borrowerWallet, // signer object or string address
|
|
208
|
+
borrowerProfile: borrowerProfileAddress, // string address
|
|
231
209
|
borrowerFaction: 'mud', // or 1, 2, 3
|
|
232
|
-
fleet: fleetAddress,
|
|
233
|
-
contract: contractAddress,
|
|
210
|
+
fleet: fleetAddress, // string address
|
|
211
|
+
contract: contractAddress, // string address
|
|
234
212
|
rate: 100, // ATLAS per payment period (based on contract's payment frequency)
|
|
235
213
|
duration: 86400 // Duration in seconds (must be between contract's min/max)
|
|
236
214
|
});
|
|
@@ -249,49 +227,44 @@ const closeIx = await closeRental({
|
|
|
249
227
|
rentalState: rentalStateAddress,
|
|
250
228
|
ownerTokenAccount: ownerTokenAccountAddress
|
|
251
229
|
});
|
|
230
|
+
|
|
231
|
+
// Reset rental instruction
|
|
232
|
+
const resetIx = await resetRental({
|
|
233
|
+
borrower: borrowerWallet,
|
|
234
|
+
contract: contractAddress,
|
|
235
|
+
rentalState: rentalStateAddress
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// Convert any instruction to web3.js format for wallet compatibility
|
|
239
|
+
const web3jsAcceptIx = await acceptRental(params).web3js(PublicKey);
|
|
240
|
+
const web3jsCancelIx = await cancelRental(params).web3js(PublicKey);
|
|
241
|
+
|
|
242
|
+
// Use in web3.js transactions
|
|
243
|
+
const transaction = new Transaction()
|
|
244
|
+
.add(web3jsAcceptIx)
|
|
245
|
+
.add(web3jsCancelIx);
|
|
252
246
|
```
|
|
253
247
|
|
|
254
248
|
## Configuration
|
|
255
249
|
|
|
256
|
-
The SDK provides
|
|
257
|
-
|
|
258
|
-
### Global Configuration
|
|
250
|
+
The SDK provides simple configuration for different networks:
|
|
259
251
|
|
|
260
252
|
```typescript
|
|
261
253
|
import { setConfig, getConfig, clearConfig } from '@wuwei-labs/srsly';
|
|
262
254
|
|
|
263
|
-
//
|
|
255
|
+
// Set network configuration
|
|
264
256
|
setConfig({
|
|
265
|
-
// Program Set - Choose predefined network configuration
|
|
266
257
|
programs: 'atlasnet', // 'mainnet' | 'atlasnet' | 'holosim'
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
// Solana Library Preference - Control which library to use for pack methods
|
|
272
|
-
solanaLibrary: 'auto', // 'auto' | 'kit' | 'web3js' (auto prefers @solana/kit)
|
|
273
|
-
|
|
274
|
-
// Program Address Overrides - Customize specific program addresses
|
|
275
|
-
srslyProgramAddress: 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT', // SRSLY program
|
|
276
|
-
profileFactionProgramAddress: 'PprofUW1pURCnMW2si88GWPXEEK3Bvh9Tksy8WtnoYJ', // Profile Faction program
|
|
277
|
-
gameId: 'GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k', // SAGE game ID
|
|
278
|
-
atlasMint: 'ATLA5nAaVRfH6BNwD4SAyWp96EdQaAh6bBmGeTx956sx', // ATLAS token mint
|
|
279
|
-
|
|
280
|
-
// Transaction Options - Control transaction behavior
|
|
281
|
-
transactionOptions: {
|
|
282
|
-
commitment: 'confirmed', // 'processed' | 'confirmed' | 'finalized'
|
|
283
|
-
skipPreflight: false // Skip transaction simulation before sending
|
|
284
|
-
}
|
|
258
|
+
srslyProgramAddress: 'custom-program-address...', // Optional override
|
|
259
|
+
profileFactionProgramAddress: 'custom-profile-program...', // Optional override
|
|
260
|
+
gameId: 'custom-game-id...', // Optional override
|
|
261
|
+
atlasMint: 'custom-atlas-mint...' // Optional override
|
|
285
262
|
});
|
|
286
263
|
|
|
287
264
|
// Simple network configurations
|
|
288
|
-
setConfig({ programs: 'mainnet' });
|
|
289
|
-
setConfig({ programs: 'atlasnet'
|
|
290
|
-
setConfig({ programs: 'holosim'
|
|
291
|
-
|
|
292
|
-
// Library preference configurations
|
|
293
|
-
setConfig({ programs: 'atlasnet', rpcUrl: 'https://your-rpc.com', solanaLibrary: 'kit' }); // Force @solana/kit
|
|
294
|
-
setConfig({ programs: 'atlasnet', rpcUrl: 'https://your-rpc.com', solanaLibrary: 'web3js' }); // Force @solana/web3.js
|
|
265
|
+
setConfig({ programs: 'mainnet' });
|
|
266
|
+
setConfig({ programs: 'atlasnet' });
|
|
267
|
+
setConfig({ programs: 'holosim' });
|
|
295
268
|
|
|
296
269
|
// Check current configuration
|
|
297
270
|
console.log(getConfig());
|
|
@@ -300,35 +273,15 @@ console.log(getConfig());
|
|
|
300
273
|
clearConfig();
|
|
301
274
|
```
|
|
302
275
|
|
|
303
|
-
### Configuration Options
|
|
276
|
+
### Configuration Options
|
|
304
277
|
|
|
305
278
|
| Option | Type | Description | Default |
|
|
306
279
|
|--------|------|-------------|---------|
|
|
307
280
|
| `programs` | `'mainnet' \| 'atlasnet' \| 'holosim'` | Predefined program address set | `'atlasnet'` |
|
|
308
|
-
| `rpcUrl` | `string` | Solana RPC endpoint URL (required for pack/send) | `undefined` |
|
|
309
|
-
| `solanaLibrary` | `'auto' \| 'kit' \| 'web3js'` | Preferred Solana library for pack methods | `'auto'` |
|
|
310
281
|
| `srslyProgramAddress` | `string` | SRSLY program address override | From program set |
|
|
311
282
|
| `profileFactionProgramAddress` | `string` | Profile Faction program override | From program set |
|
|
312
283
|
| `gameId` | `string` | SAGE game ID override | From program set |
|
|
313
284
|
| `atlasMint` | `string` | ATLAS token mint override | From program set |
|
|
314
|
-
| `transactionOptions.commitment` | `'processed' \| 'confirmed' \| 'finalized'` | Transaction confirmation level | `'confirmed'` |
|
|
315
|
-
| `transactionOptions.skipPreflight` | `boolean` | Skip transaction simulation | `false` |
|
|
316
|
-
|
|
317
|
-
### Per-Instruction Configuration
|
|
318
|
-
|
|
319
|
-
```typescript
|
|
320
|
-
// Override global config for specific instructions
|
|
321
|
-
const ix = await createContract(params).set({
|
|
322
|
-
programs: 'mainnet',
|
|
323
|
-
solanaLibrary: 'kit',
|
|
324
|
-
transactionOptions: { commitment: 'finalized' }
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
// Chain multiple configurations
|
|
328
|
-
const ix2 = await acceptRental(params)
|
|
329
|
-
.set({ programs: 'holosim', rpcUrl: 'https://custom-rpc.com', solanaLibrary: 'web3js' })
|
|
330
|
-
.set({ gameId: 'custom-game-id...', atlasMint: 'custom-mint...' });
|
|
331
|
-
```
|
|
332
285
|
|
|
333
286
|
## Duration and Payment Frequency
|
|
334
287
|
|
|
@@ -401,19 +354,11 @@ const totalAmount = rate * paymentPeriods * ATLAS_TO_STARDUST; // Total in stard
|
|
|
401
354
|
|
|
402
355
|
The SDK includes predefined program address sets for different networks:
|
|
403
356
|
|
|
404
|
-
| Network | SAGE Program | Game ID | ATLAS Mint |
|
|
405
|
-
|
|
406
|
-
| `mainnet` | `SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE` | `GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr` | `ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx` |
|
|
407
|
-
| `atlasnet` | `SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF` | `GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k` | `ATLA5nAaVRfH6BNwD4SAyWp96EdQaAh6bBmGeTx956sx` |
|
|
408
|
-
| `holosim` | `SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF` | `GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k` | `ATLA5nAaVRfH6BNwD4SAyWp96EdQaAh6bBmGeTx956sx` |
|
|
409
|
-
|
|
410
|
-
**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:
|
|
411
|
-
|
|
412
|
-
```typescript
|
|
413
|
-
setConfig({ programs: 'atlasnet' }); // Missing rpcUrl!
|
|
414
|
-
await createContract(params).pack(address);
|
|
415
|
-
// Error: RPC URL is required for atlasnet network. Please provide your RPC endpoint...
|
|
416
|
-
```
|
|
357
|
+
| Network | SAGE Program | Game ID | ATLAS Mint |
|
|
358
|
+
|---------|--------------|---------|------------|
|
|
359
|
+
| `mainnet` | `SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE` | `GAMEzqJehF8yAnKiTARUuhZMvLvkZVAsCVri5vSfemLr` | `ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx` |
|
|
360
|
+
| `atlasnet` | `SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF` | `GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k` | `ATLA5nAaVRfH6BNwD4SAyWp96EdQaAh6bBmGeTx956sx` |
|
|
361
|
+
| `holosim` | `SAgeTraQfBMdvGVDJYoEvjnbq5szW7RJPi6obDTDQUF` | `GAMEC7U7cqmFFaRow33j1LwuV8u4YhAS1mJ5Dqjnar2k` | `ATLA5nAaVRfH6BNwD4SAyWp96EdQaAh6bBmGeTx956sx` |
|
|
417
362
|
|
|
418
363
|
## Types and Constants
|
|
419
364
|
|
|
@@ -428,7 +373,6 @@ import type {
|
|
|
428
373
|
import {
|
|
429
374
|
ATLAS_TO_STARDUST,
|
|
430
375
|
FACTION_MAPPING,
|
|
431
|
-
toAddress,
|
|
432
376
|
days,
|
|
433
377
|
weeks,
|
|
434
378
|
months,
|
|
@@ -443,10 +387,6 @@ console.log(FACTION_MAPPING[1]); // 'mud'
|
|
|
443
387
|
console.log(FACTION_MAPPING[2]); // 'oni'
|
|
444
388
|
console.log(FACTION_MAPPING[3]); // 'ustur'
|
|
445
389
|
|
|
446
|
-
// Address conversion utility
|
|
447
|
-
const addressObj = toAddress("123abc..."); // converts string to Address<string>
|
|
448
|
-
console.log(addressObj); // Address<string>
|
|
449
|
-
|
|
450
390
|
// Duration helper functions
|
|
451
391
|
console.log(days(7)); // 604800 (7 days in seconds)
|
|
452
392
|
console.log(weeks(2)); // 1209600 (2 weeks in seconds)
|
|
@@ -457,9 +397,8 @@ console.log(duration.hours(12)); // 43200 (12 hours in seconds)
|
|
|
457
397
|
## IDL and Program Information
|
|
458
398
|
|
|
459
399
|
```typescript
|
|
460
|
-
// Access program
|
|
461
|
-
import
|
|
462
|
-
import atlasnetIdl from '@wuwei-labs/srsly/idl/atlasnet';
|
|
400
|
+
// Access program IDL
|
|
401
|
+
import idl from '@wuwei-labs/srsly/idl';
|
|
463
402
|
```
|
|
464
403
|
|
|
465
404
|
## Error Handling
|
|
@@ -486,110 +425,9 @@ The SDK provides optimized builds for different environments:
|
|
|
486
425
|
- **CommonJS**: `./dist/cjs/` (Node.js, webpack)
|
|
487
426
|
- **ESM**: `./dist/esm/` (Modern ES modules)
|
|
488
427
|
- **Types**: `./dist/types/` (TypeScript definitions)
|
|
489
|
-
- **
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
### Webpack Build Errors with Peer Dependencies
|
|
494
|
-
|
|
495
|
-
If you encounter `Can't resolve '@solana/kit'` or `Can't resolve '@solana/web3.js'` errors during webpack builds, this is because webpack tries to resolve all imports at build time, even for optional peer dependencies you haven't installed.
|
|
496
|
-
|
|
497
|
-
#### Solution 1: Use Library-Specific Entry Points (Recommended)
|
|
498
|
-
|
|
499
|
-
Use library-specific imports to avoid webpack trying to resolve libraries you don't have installed:
|
|
500
|
-
|
|
501
|
-
```javascript
|
|
502
|
-
// ✅ Best: Only bundles @solana/kit dependencies
|
|
503
|
-
import { createContract, setConfig } from '@wuwei-labs/srsly/kit';
|
|
504
|
-
|
|
505
|
-
// ✅ Best: Only bundles @solana/web3.js dependencies
|
|
506
|
-
import { createContract, setConfig } from '@wuwei-labs/srsly/web3js';
|
|
507
|
-
|
|
508
|
-
// ❌ Avoid if you only have one library: May try to resolve both
|
|
509
|
-
import { createContract, setConfig } from '@wuwei-labs/srsly';
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
**Benefits:**
|
|
513
|
-
- ✅ Webpack only bundles the dependencies you actually need
|
|
514
|
-
- ✅ No resolution errors for missing peer dependencies
|
|
515
|
-
- ✅ Smaller bundle sizes due to better tree-shaking
|
|
516
|
-
|
|
517
|
-
#### Solution 2: Use ES Modules
|
|
518
|
-
|
|
519
|
-
Use ES module imports instead of CommonJS `require()` to enable proper tree-shaking:
|
|
520
|
-
|
|
521
|
-
```javascript
|
|
522
|
-
// ✅ Good: ESM imports (allows tree-shaking)
|
|
523
|
-
import { createContract, setConfig } from '@wuwei-labs/srsly';
|
|
524
|
-
|
|
525
|
-
// ❌ Avoid: CommonJS requires (bundles everything)
|
|
526
|
-
const { createContract, setConfig } = require('@wuwei-labs/srsly');
|
|
527
|
-
```
|
|
528
|
-
|
|
529
|
-
#### Solution 3: Install the Missing Library
|
|
530
|
-
|
|
531
|
-
If you must use CommonJS or get resolution errors:
|
|
532
|
-
|
|
533
|
-
```bash
|
|
534
|
-
# Install the library webpack is complaining about
|
|
535
|
-
npm install @solana/kit
|
|
536
|
-
|
|
537
|
-
# Or if you only want web3.js:
|
|
538
|
-
npm install @solana/web3.js
|
|
539
|
-
```
|
|
540
|
-
|
|
541
|
-
#### Solution 4: Webpack Configuration
|
|
542
|
-
|
|
543
|
-
Configure webpack to ignore optional peer dependencies you don't need (may still be needed in some webpack configurations):
|
|
544
|
-
|
|
545
|
-
```javascript
|
|
546
|
-
// webpack.config.js
|
|
547
|
-
module.exports = {
|
|
548
|
-
// ... other config
|
|
549
|
-
externals: {
|
|
550
|
-
// Only ignore the library you're NOT using
|
|
551
|
-
'@solana/kit': 'commonjs @solana/kit', // If you only use web3.js
|
|
552
|
-
'@solana/web3.js': 'commonjs @solana/web3.js' // If you only use @solana/kit
|
|
553
|
-
},
|
|
554
|
-
// Alternative: use IgnorePlugin for dynamic imports
|
|
555
|
-
plugins: [
|
|
556
|
-
new webpack.IgnorePlugin({
|
|
557
|
-
resourceRegExp: /@solana\/kit$/, // Ignore @solana/kit if you only use web3.js
|
|
558
|
-
// OR
|
|
559
|
-
resourceRegExp: /@solana\/web3\.js$/ // Ignore web3.js if you only use @solana/kit
|
|
560
|
-
})
|
|
561
|
-
]
|
|
562
|
-
};
|
|
563
|
-
```
|
|
564
|
-
|
|
565
|
-
#### Solution 5: Use Specific Pack Methods
|
|
566
|
-
|
|
567
|
-
Use only the pack method for your installed library:
|
|
568
|
-
|
|
569
|
-
```typescript
|
|
570
|
-
// If you only have @solana/web3.js installed:
|
|
571
|
-
const packedTx = await createContract(params).packWeb3js(feePayer);
|
|
572
|
-
|
|
573
|
-
// If you only have @solana/kit installed:
|
|
574
|
-
const packedTx = await createContract(params).packKit(feePayer);
|
|
575
|
-
|
|
576
|
-
// Avoid .pack() auto-detection if you want to minimize bundle analysis issues
|
|
577
|
-
```
|
|
578
|
-
|
|
579
|
-
### Library Not Found at Runtime
|
|
580
|
-
|
|
581
|
-
If you get runtime errors about missing libraries, ensure you've installed the peer dependency:
|
|
582
|
-
|
|
583
|
-
```bash
|
|
584
|
-
# For modern Solana development (recommended):
|
|
585
|
-
npm install @solana/kit
|
|
586
|
-
|
|
587
|
-
# For wallet adapter compatibility:
|
|
588
|
-
npm install @solana/web3.js
|
|
589
|
-
|
|
590
|
-
# For maximum compatibility:
|
|
591
|
-
npm install @solana/kit @solana/web3.js
|
|
592
|
-
```
|
|
428
|
+
- **Codama**: `./dist/*/codama/` (Generated Solana program interfaces)
|
|
429
|
+
- **IDL**: `./target/idl/srsly.json` (Anchor IDL)
|
|
430
|
+
- **Types**: `./target/types/srsly.ts` (Generated types)
|
|
593
431
|
|
|
594
432
|
## Links
|
|
595
433
|
|
package/dist/cjs/package.json
CHANGED
|
@@ -11,9 +11,21 @@ exports.createFluentConfigSelector = createFluentConfigSelector;
|
|
|
11
11
|
* @returns Fluent instruction with conversion methods
|
|
12
12
|
*/
|
|
13
13
|
function createFluentInstruction(kitInstruction) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
function web3js(PublicKeyConstructor) {
|
|
15
|
+
if (PublicKeyConstructor) {
|
|
16
|
+
// Return instruction with PublicKey instances
|
|
17
|
+
return {
|
|
18
|
+
keys: kitInstruction.accounts.map(account => ({
|
|
19
|
+
pubkey: new PublicKeyConstructor(account.address),
|
|
20
|
+
isWritable: (account.role & 1) === 1, // Check if writable bit is set
|
|
21
|
+
isSigner: (account.role & 2) === 2, // Check if signer bit is set
|
|
22
|
+
})),
|
|
23
|
+
programId: new PublicKeyConstructor(kitInstruction.programAddress),
|
|
24
|
+
data: kitInstruction.data
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// Return instruction with string addresses
|
|
17
29
|
return {
|
|
18
30
|
keys: kitInstruction.accounts.map(account => ({
|
|
19
31
|
pubkey: account.address,
|
|
@@ -24,6 +36,10 @@ function createFluentInstruction(kitInstruction) {
|
|
|
24
36
|
data: kitInstruction.data
|
|
25
37
|
};
|
|
26
38
|
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
...kitInstruction,
|
|
42
|
+
web3js
|
|
27
43
|
};
|
|
28
44
|
}
|
|
29
45
|
/**
|
|
@@ -32,6 +48,10 @@ function createFluentInstruction(kitInstruction) {
|
|
|
32
48
|
* @returns FluentConfigSelector with additional format conversion methods
|
|
33
49
|
*/
|
|
34
50
|
function createFluentConfigSelector(baseSelector) {
|
|
51
|
+
async function web3js(PublicKeyConstructor) {
|
|
52
|
+
const fluentInstruction = await baseSelector.build();
|
|
53
|
+
return fluentInstruction.web3js(PublicKeyConstructor);
|
|
54
|
+
}
|
|
35
55
|
return {
|
|
36
56
|
// Override set to return FluentConfigSelector
|
|
37
57
|
set(options) {
|
|
@@ -40,10 +60,7 @@ function createFluentConfigSelector(baseSelector) {
|
|
|
40
60
|
},
|
|
41
61
|
build: baseSelector.build,
|
|
42
62
|
then: baseSelector.then,
|
|
43
|
-
|
|
44
|
-
const fluentInstruction = await baseSelector.build();
|
|
45
|
-
return fluentInstruction.web3js();
|
|
46
|
-
}
|
|
63
|
+
web3js
|
|
47
64
|
};
|
|
48
65
|
}
|
|
49
66
|
//# sourceMappingURL=instruction-converter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruction-converter.js","sourceRoot":"","sources":["../../../src/utils/instruction-converter.ts"],"names":[],"mappings":";AAAA;;GAEG;;
|
|
1
|
+
{"version":3,"file":"instruction-converter.js","sourceRoot":"","sources":["../../../src/utils/instruction-converter.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAkHH,0DA+BC;AAOD,gEAkBC;AA7DD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,MAAM,iBAAiB,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,CAAC;QACrD,OAAO,iBAAiB,CAAC,MAAM,CAAC,oBAA2B,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO;QACL,8CAA8C;QAC9C,GAAG,CAAC,OAAY;YACd,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAClD,OAAO,0BAA0B,CAAC,eAAe,CAAC,CAAC;QACrD,CAAC;QACD,KAAK,EAAE,YAAY,CAAC,KAAK;QACzB,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,MAAM;KACoB,CAAC;AAC/B,CAAC"}
|
package/dist/esm/package.json
CHANGED
|
@@ -7,9 +7,21 @@
|
|
|
7
7
|
* @returns Fluent instruction with conversion methods
|
|
8
8
|
*/
|
|
9
9
|
export function createFluentInstruction(kitInstruction) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
function web3js(PublicKeyConstructor) {
|
|
11
|
+
if (PublicKeyConstructor) {
|
|
12
|
+
// Return instruction with PublicKey instances
|
|
13
|
+
return {
|
|
14
|
+
keys: kitInstruction.accounts.map(account => ({
|
|
15
|
+
pubkey: new PublicKeyConstructor(account.address),
|
|
16
|
+
isWritable: (account.role & 1) === 1, // Check if writable bit is set
|
|
17
|
+
isSigner: (account.role & 2) === 2, // Check if signer bit is set
|
|
18
|
+
})),
|
|
19
|
+
programId: new PublicKeyConstructor(kitInstruction.programAddress),
|
|
20
|
+
data: kitInstruction.data
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// Return instruction with string addresses
|
|
13
25
|
return {
|
|
14
26
|
keys: kitInstruction.accounts.map(account => ({
|
|
15
27
|
pubkey: account.address,
|
|
@@ -20,6 +32,10 @@ export function createFluentInstruction(kitInstruction) {
|
|
|
20
32
|
data: kitInstruction.data
|
|
21
33
|
};
|
|
22
34
|
}
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
...kitInstruction,
|
|
38
|
+
web3js
|
|
23
39
|
};
|
|
24
40
|
}
|
|
25
41
|
/**
|
|
@@ -28,6 +44,10 @@ export function createFluentInstruction(kitInstruction) {
|
|
|
28
44
|
* @returns FluentConfigSelector with additional format conversion methods
|
|
29
45
|
*/
|
|
30
46
|
export function createFluentConfigSelector(baseSelector) {
|
|
47
|
+
async function web3js(PublicKeyConstructor) {
|
|
48
|
+
const fluentInstruction = await baseSelector.build();
|
|
49
|
+
return fluentInstruction.web3js(PublicKeyConstructor);
|
|
50
|
+
}
|
|
31
51
|
return {
|
|
32
52
|
// Override set to return FluentConfigSelector
|
|
33
53
|
set(options) {
|
|
@@ -36,10 +56,7 @@ export function createFluentConfigSelector(baseSelector) {
|
|
|
36
56
|
},
|
|
37
57
|
build: baseSelector.build,
|
|
38
58
|
then: baseSelector.then,
|
|
39
|
-
|
|
40
|
-
const fluentInstruction = await baseSelector.build();
|
|
41
|
-
return fluentInstruction.web3js();
|
|
42
|
-
}
|
|
59
|
+
web3js
|
|
43
60
|
};
|
|
44
61
|
}
|
|
45
62
|
//# sourceMappingURL=instruction-converter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruction-converter.js","sourceRoot":"","sources":["../../../src/utils/instruction-converter.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"instruction-converter.js","sourceRoot":"","sources":["../../../src/utils/instruction-converter.ts"],"names":[],"mappings":"AAAA;;GAEG;AA6GH;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,cAA8B;IACpE,SAAS,MAAM,CAAa,oBAAuD;QACjF,IAAI,oBAAoB,EAAE,CAAC;YACzB,8CAA8C;YAC9C,OAAO;gBACL,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;oBAC5C,MAAM,EAAE,IAAI,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC;oBACj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;QACrD,CAAC;QACD,KAAK,EAAE,YAAY,CAAC,KAAK;QACzB,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,MAAM;KACoB,CAAC;AAC/B,CAAC"}
|
|
@@ -16,9 +16,9 @@ export interface KitInstruction {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* @solana/web3.js instruction format
|
|
19
|
+
* @solana/web3.js instruction format with string addresses
|
|
20
20
|
*/
|
|
21
|
-
export interface
|
|
21
|
+
export interface Web3jsInstructionWithStrings {
|
|
22
22
|
keys: Array<{
|
|
23
23
|
pubkey: string;
|
|
24
24
|
isWritable: boolean;
|
|
@@ -29,26 +29,61 @@ export interface Web3jsInstruction {
|
|
|
29
29
|
[key: string]: number;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* @solana/web3.js instruction format with PublicKey instances
|
|
34
|
+
*/
|
|
35
|
+
export interface Web3jsInstructionWithPublicKeys<TPublicKey = any> {
|
|
36
|
+
keys: Array<{
|
|
37
|
+
pubkey: TPublicKey;
|
|
38
|
+
isWritable: boolean;
|
|
39
|
+
isSigner: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
programId: TPublicKey;
|
|
42
|
+
data: Uint8Array | {
|
|
43
|
+
[key: string]: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Generic web3.js instruction format
|
|
48
|
+
*/
|
|
49
|
+
export type Web3jsInstruction<TPublicKey = string> = TPublicKey extends string ? Web3jsInstructionWithStrings : Web3jsInstructionWithPublicKeys<TPublicKey>;
|
|
50
|
+
/**
|
|
51
|
+
* PublicKey constructor interface
|
|
52
|
+
*/
|
|
53
|
+
export interface PublicKeyConstructor<TPublicKey = any> {
|
|
54
|
+
new (address: string): TPublicKey;
|
|
55
|
+
}
|
|
32
56
|
/**
|
|
33
57
|
* Fluent instruction wrapper that provides format conversion methods
|
|
34
58
|
* @example
|
|
35
59
|
* ```typescript
|
|
60
|
+
* import { PublicKey } from '@solana/web3.js';
|
|
61
|
+
*
|
|
36
62
|
* // Default returns kit format
|
|
37
63
|
* const kitInstruction = await createContract(params);
|
|
38
64
|
*
|
|
39
|
-
* // Convert to web3.js format
|
|
65
|
+
* // Convert to web3.js format with string addresses
|
|
40
66
|
* const web3jsInstruction = await createContract(params).web3js();
|
|
41
67
|
*
|
|
68
|
+
* // Convert to web3.js format with PublicKey instances
|
|
69
|
+
* const web3jsInstructionWithPK = await createContract(params).web3js(PublicKey);
|
|
70
|
+
*
|
|
42
71
|
* // Use with libraries
|
|
43
|
-
* const transaction = new Transaction().add(
|
|
72
|
+
* const transaction = new Transaction().add(web3jsInstructionWithPK);
|
|
44
73
|
* ```
|
|
45
74
|
*/
|
|
46
75
|
export interface FluentInstruction extends KitInstruction {
|
|
47
76
|
/**
|
|
48
|
-
* Convert instruction to @solana/web3.js format
|
|
49
|
-
* @returns Instruction in @solana/web3.js format
|
|
77
|
+
* Convert instruction to @solana/web3.js format with string addresses
|
|
78
|
+
* @returns Instruction in @solana/web3.js format with string pubkeys
|
|
79
|
+
*/
|
|
80
|
+
web3js(): Web3jsInstructionWithStrings;
|
|
81
|
+
/**
|
|
82
|
+
* Convert instruction to @solana/web3.js format with PublicKey instances
|
|
83
|
+
* @param PublicKeyConstructor Constructor for creating PublicKey instances
|
|
84
|
+
* @returns Instruction in @solana/web3.js format with PublicKey instances
|
|
50
85
|
*/
|
|
51
|
-
web3js():
|
|
86
|
+
web3js<TPublicKey>(PublicKeyConstructor: PublicKeyConstructor<TPublicKey>): Web3jsInstructionWithPublicKeys<TPublicKey>;
|
|
52
87
|
}
|
|
53
88
|
/**
|
|
54
89
|
* Fluent config selector that adds format conversion methods
|
|
@@ -56,10 +91,16 @@ export interface FluentInstruction extends KitInstruction {
|
|
|
56
91
|
*/
|
|
57
92
|
export interface FluentConfigSelector<T extends FluentInstruction> extends ConfigSelector<T> {
|
|
58
93
|
/**
|
|
59
|
-
* Convert instruction to @solana/web3.js format
|
|
60
|
-
* @returns Promise that resolves to
|
|
94
|
+
* Convert instruction to @solana/web3.js format with string addresses
|
|
95
|
+
* @returns Promise that resolves to Web3jsInstructionWithStrings
|
|
96
|
+
*/
|
|
97
|
+
web3js(): Promise<Web3jsInstructionWithStrings>;
|
|
98
|
+
/**
|
|
99
|
+
* Convert instruction to @solana/web3.js format with PublicKey instances
|
|
100
|
+
* @param PublicKeyConstructor Constructor for creating PublicKey instances
|
|
101
|
+
* @returns Promise that resolves to Web3jsInstructionWithPublicKeys
|
|
61
102
|
*/
|
|
62
|
-
web3js(): Promise<
|
|
103
|
+
web3js<TPublicKey>(PublicKeyConstructor: PublicKeyConstructor<TPublicKey>): Promise<Web3jsInstructionWithPublicKeys<TPublicKey>>;
|
|
63
104
|
}
|
|
64
105
|
/**
|
|
65
106
|
* Create a fluent instruction wrapper around a kit instruction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruction-converter.d.ts","sourceRoot":"","sources":["../../../src/utils/instruction-converter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,KAAK,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IACH,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,UAAU,GAAG;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"instruction-converter.d.ts","sourceRoot":"","sources":["../../../src/utils/instruction-converter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,KAA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