@wuwei-labs/srsly 2.0.0-beta.18 → 2.0.0-beta.19
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 +41 -22
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/utils/config.js +31 -4
- package/dist/cjs/utils/config.js.map +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/utils/config.js +31 -4
- package/dist/esm/utils/config.js.map +1 -1
- package/dist/types/utils/config.d.ts +25 -5
- package/dist/types/utils/config.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,15 +8,15 @@ A TypeScript SDK for building and sending Solana transactions to interact with t
|
|
|
8
8
|
|
|
9
9
|
## What This SDK Does
|
|
10
10
|
|
|
11
|
-
The SRSLY SDK is
|
|
11
|
+
The SRSLY SDK is a complete toolkit that helps you create Solana transactions for fleet rentals. It provides:
|
|
12
12
|
|
|
13
13
|
- ✅ Account derivation and validation
|
|
14
14
|
- ✅ Instruction data encoding
|
|
15
15
|
- ✅ Type-safe parameter handling
|
|
16
|
-
-
|
|
17
|
-
-
|
|
16
|
+
- ✅ Unsigned transaction building via `.pack()`
|
|
17
|
+
- ✅ Wallet-agnostic design (works with any signing method)
|
|
18
18
|
|
|
19
|
-
**Current Status**: Full instruction building
|
|
19
|
+
**Current Status**: Full instruction building and unsigned transaction creation support.
|
|
20
20
|
|
|
21
21
|
## Installation
|
|
22
22
|
|
|
@@ -30,17 +30,19 @@ yarn add @wuwei-labs/srsly
|
|
|
30
30
|
|
|
31
31
|
## Quick Start
|
|
32
32
|
|
|
33
|
-
###
|
|
33
|
+
### Option 1: Unsigned Transaction (Recommended)
|
|
34
34
|
|
|
35
35
|
```typescript
|
|
36
36
|
import { createContract, setConfig } from '@wuwei-labs/srsly';
|
|
37
|
-
import { Connection, Transaction } from '@solana/web3.js';
|
|
38
37
|
|
|
39
|
-
// 1. Configure SDK for
|
|
40
|
-
setConfig({
|
|
38
|
+
// 1. Configure SDK with RPC endpoint for blockhash
|
|
39
|
+
setConfig({
|
|
40
|
+
programs: 'atlasnet',
|
|
41
|
+
rpcUrl: 'https://api.atlasnet.solana.com'
|
|
42
|
+
});
|
|
41
43
|
|
|
42
|
-
// 2.
|
|
43
|
-
const
|
|
44
|
+
// 2. Create unsigned transaction
|
|
45
|
+
const packedTx = await createContract({
|
|
44
46
|
owner: walletPublicKey,
|
|
45
47
|
fleet: fleetAddress,
|
|
46
48
|
ownerProfile: profileAddress,
|
|
@@ -48,27 +50,44 @@ const instruction = await createContract({
|
|
|
48
50
|
durationMin: 86400, // 1 day
|
|
49
51
|
durationMax: 604800, // 1 week
|
|
50
52
|
paymentsFreq: 'daily'
|
|
51
|
-
});
|
|
53
|
+
}).pack(walletPublicKey); // Pass fee payer address
|
|
54
|
+
|
|
55
|
+
// 3. Sign and send with your preferred method:
|
|
56
|
+
|
|
57
|
+
// With @solana/kit (server-side/CLI)
|
|
58
|
+
import { signTransactionMessageWithSigners, sendAndConfirmTransactionFactory } from '@solana/kit';
|
|
59
|
+
const signedTx = await signTransactionMessageWithSigners(packedTx);
|
|
60
|
+
// ... send with sendAndConfirmTransactionFactory
|
|
61
|
+
|
|
62
|
+
// With wallet adapter (browser)
|
|
63
|
+
import { useWallet } from '@solana/wallet-adapter-react';
|
|
64
|
+
import { VersionedTransaction } from '@solana/web3.js';
|
|
65
|
+
const wallet = useWallet();
|
|
66
|
+
const versionedTx = VersionedTransaction.deserialize(packedTx.messageBytes);
|
|
67
|
+
const signedTx = await wallet.signTransaction(versionedTx);
|
|
68
|
+
// ... send with connection.sendRawTransaction(signedTx.serialize())
|
|
52
69
|
|
|
53
|
-
//
|
|
54
|
-
const connection = new Connection('https://api.atlasnet.solana.com');
|
|
55
|
-
const transaction = new Transaction().add(instruction);
|
|
56
|
-
const signature = await wallet.signAndSendTransaction(transaction);
|
|
70
|
+
// With any other wallet integration - use packedTx.messageBytes
|
|
57
71
|
```
|
|
58
72
|
|
|
59
|
-
###
|
|
73
|
+
### Option 2: Manual Instruction Building
|
|
60
74
|
|
|
61
75
|
```typescript
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
import { createContract } from '@wuwei-labs/srsly';
|
|
77
|
+
|
|
78
|
+
// Build instruction only (no RPC calls)
|
|
79
|
+
const instruction = await createContract({
|
|
64
80
|
owner: walletPublicKey,
|
|
65
81
|
fleet: fleetAddress,
|
|
66
82
|
ownerProfile: profileAddress,
|
|
67
|
-
rate: 1000000,
|
|
68
|
-
durationMin: 86400,
|
|
69
|
-
durationMax: 604800,
|
|
83
|
+
rate: 1000000,
|
|
84
|
+
durationMin: 86400,
|
|
85
|
+
durationMax: 604800,
|
|
70
86
|
paymentsFreq: 'daily'
|
|
71
|
-
})
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Handle transaction building and submission yourself
|
|
90
|
+
// ... use instruction with your preferred transaction building method
|
|
72
91
|
```
|
|
73
92
|
|
|
74
93
|
## Core Features
|
package/dist/cjs/package.json
CHANGED
package/dist/cjs/utils/config.js
CHANGED
|
@@ -46,6 +46,7 @@ exports.createConfigSelector = createConfigSelector;
|
|
|
46
46
|
// Single codama output - network agnostic
|
|
47
47
|
const instructions = __importStar(require("../codama/instructions"));
|
|
48
48
|
const programs = __importStar(require("../codama/programs"));
|
|
49
|
+
const kit_1 = require("@solana/kit");
|
|
49
50
|
const PROGRAM_SETS = {
|
|
50
51
|
mainnet: {
|
|
51
52
|
SAGE_PROGRAM_ADDRESS: 'SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE',
|
|
@@ -176,8 +177,21 @@ function createChainableConfigSelector(executeFn, existingConfig) {
|
|
|
176
177
|
const selector = {
|
|
177
178
|
set: (additionalOptions) => createChainableConfigSelector(executeFn, { ...existingConfig, ...additionalOptions }),
|
|
178
179
|
build: () => executeFn(existingConfig),
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
pack: async (feePayer) => {
|
|
181
|
+
const instruction = await executeFn(existingConfig);
|
|
182
|
+
const effectiveConfig = getEffectiveConfig(existingConfig);
|
|
183
|
+
const resolvedAddresses = resolveProgramAddresses(effectiveConfig);
|
|
184
|
+
if (!resolvedAddresses.rpcUrl) {
|
|
185
|
+
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
186
|
+
}
|
|
187
|
+
// Create RPC connection to get latest blockhash
|
|
188
|
+
const rpc = (0, kit_1.createSolanaRpc)(resolvedAddresses.rpcUrl);
|
|
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 unsignedTransaction;
|
|
181
195
|
},
|
|
182
196
|
// Implement PromiseLike to allow direct awaiting
|
|
183
197
|
then(onfulfilled, onrejected) {
|
|
@@ -209,8 +223,21 @@ function createConfigSelector(executeFn) {
|
|
|
209
223
|
const selector = {
|
|
210
224
|
set: (options) => createChainableConfigSelector(executeFn, getEffectiveConfig(options)),
|
|
211
225
|
build: () => executeFn(getEffectiveConfig()),
|
|
212
|
-
|
|
213
|
-
|
|
226
|
+
pack: async (feePayer) => {
|
|
227
|
+
const instruction = await executeFn(getEffectiveConfig());
|
|
228
|
+
const effectiveConfig = getEffectiveConfig();
|
|
229
|
+
const resolvedAddresses = resolveProgramAddresses(effectiveConfig);
|
|
230
|
+
if (!resolvedAddresses.rpcUrl) {
|
|
231
|
+
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
232
|
+
}
|
|
233
|
+
// Create RPC connection to get latest blockhash
|
|
234
|
+
const rpc = (0, kit_1.createSolanaRpc)(resolvedAddresses.rpcUrl);
|
|
235
|
+
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
236
|
+
// Build unsigned transaction message
|
|
237
|
+
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));
|
|
238
|
+
// Compile to unsigned transaction
|
|
239
|
+
const unsignedTransaction = (0, kit_1.compileTransaction)(transactionMessage);
|
|
240
|
+
return unsignedTransaction;
|
|
214
241
|
},
|
|
215
242
|
// Implement PromiseLike to allow direct awaiting
|
|
216
243
|
then(onfulfilled, onrejected) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEH,0DAkBC;AAwBD,8BAEC;AAMD,8BAEC;AAKD,kCAEC;AAiBD,8BAEC;AAMD,wDAKC;AA8HD,oDA0CC;AA/TD,0CAA0C;AAC1C,qEAAuD;AACvD,6DAA+C;AAC/C,qCAUqB;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;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AAC,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
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// Single codama output - network agnostic
|
|
5
5
|
import * as instructions from '../codama/instructions';
|
|
6
6
|
import * as programs from '../codama/programs';
|
|
7
|
+
import { createSolanaRpc, createTransactionMessage, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, appendTransactionMessageInstructions, compileTransaction, pipe, } from '@solana/kit';
|
|
7
8
|
const PROGRAM_SETS = {
|
|
8
9
|
mainnet: {
|
|
9
10
|
SAGE_PROGRAM_ADDRESS: 'SAGE2HAwep459SNq61LHvjxPk4pLPEJLoMETef7f7EE',
|
|
@@ -134,8 +135,21 @@ function createChainableConfigSelector(executeFn, existingConfig) {
|
|
|
134
135
|
const selector = {
|
|
135
136
|
set: (additionalOptions) => createChainableConfigSelector(executeFn, { ...existingConfig, ...additionalOptions }),
|
|
136
137
|
build: () => executeFn(existingConfig),
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
pack: async (feePayer) => {
|
|
139
|
+
const instruction = await executeFn(existingConfig);
|
|
140
|
+
const effectiveConfig = getEffectiveConfig(existingConfig);
|
|
141
|
+
const resolvedAddresses = resolveProgramAddresses(effectiveConfig);
|
|
142
|
+
if (!resolvedAddresses.rpcUrl) {
|
|
143
|
+
throw new Error('RPC URL is required for creating transactions. Please set it via setConfig({ rpcUrl: "..." }) or provide it in .set({ rpcUrl: "..." })');
|
|
144
|
+
}
|
|
145
|
+
// Create RPC connection to get latest blockhash
|
|
146
|
+
const rpc = createSolanaRpc(resolvedAddresses.rpcUrl);
|
|
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 unsignedTransaction;
|
|
139
153
|
},
|
|
140
154
|
// Implement PromiseLike to allow direct awaiting
|
|
141
155
|
then(onfulfilled, onrejected) {
|
|
@@ -167,8 +181,21 @@ export function createConfigSelector(executeFn) {
|
|
|
167
181
|
const selector = {
|
|
168
182
|
set: (options) => createChainableConfigSelector(executeFn, getEffectiveConfig(options)),
|
|
169
183
|
build: () => executeFn(getEffectiveConfig()),
|
|
170
|
-
|
|
171
|
-
|
|
184
|
+
pack: async (feePayer) => {
|
|
185
|
+
const instruction = await executeFn(getEffectiveConfig());
|
|
186
|
+
const effectiveConfig = getEffectiveConfig();
|
|
187
|
+
const resolvedAddresses = resolveProgramAddresses(effectiveConfig);
|
|
188
|
+
if (!resolvedAddresses.rpcUrl) {
|
|
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 = createSolanaRpc(resolvedAddresses.rpcUrl);
|
|
193
|
+
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
194
|
+
// Build unsigned transaction message
|
|
195
|
+
const transactionMessage = pipe(createTransactionMessage({ version: 0 }), (msg) => setTransactionMessageFeePayer(feePayer, msg), (msg) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg), (msg) => appendTransactionMessageInstructions([instruction], msg));
|
|
196
|
+
// Compile to unsigned transaction
|
|
197
|
+
const unsignedTransaction = compileTransaction(transactionMessage);
|
|
198
|
+
return unsignedTransaction;
|
|
172
199
|
},
|
|
173
200
|
// Implement PromiseLike to allow direct awaiting
|
|
174
201
|
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;
|
|
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,EAGL,eAAe,EACf,wBAAwB,EACxB,6BAA6B,EAC7B,2CAA2C,EAC3C,oCAAoC,EACpC,kBAAkB,EAClB,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;AAcX,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,MAAM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AC,iBAAiB,CAAC,MAAM,CAAC,CAAC;YACtD,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,MAAM,GAAG,CAAC,kBAAkB,EAAE,CAAC,IAAI,EAAE,CAAC;YAEzE,qCAAqC;YACrC,MAAM,kBAAkB,GAAG,IAAI,CAC7B,wBAAwB,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EACxC,CAAC,GAAG,EAAE,EAAE,CAAC,6BAA6B,CAAC,QAAmB,EAAE,GAAG,CAAC,EAChE,CAAC,GAAG,EAAE,EAAE,CAAC,2CAA2C,CAAC,eAAe,EAAE,GAAG,CAAC,EAC1E,CAAC,GAAG,EAAE,EAAE,CAAC,oCAAoC,CAAC,CAAC,WAA2B,CAAC,EAAE,GAAG,CAAC,CAClF,CAAC;YAEF,kCAAkC;YAClC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;YAEnE,OAAO,mBAAmB,CAAC;QAC7B,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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Network configuration for the SRSLY SDK
|
|
3
3
|
*/
|
|
4
|
-
import { type
|
|
4
|
+
import { type Address } from '@solana/kit';
|
|
5
5
|
export type ProgramSet = 'mainnet' | 'atlasnet' | 'holosim';
|
|
6
6
|
/**
|
|
7
7
|
* Configuration options that can be set globally or overridden per call
|
|
@@ -84,11 +84,31 @@ export interface ConfigSelector<T> extends PromiseLike<T> {
|
|
|
84
84
|
*/
|
|
85
85
|
build(): Promise<T>;
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* @
|
|
87
|
+
* Pack the instruction into an unsigned transaction ready for signing and sending
|
|
88
|
+
*
|
|
89
|
+
* @param feePayer The address that will pay for the transaction fees
|
|
90
|
+
* @returns Promise resolving to a compiled transaction with helper methods
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Get transaction
|
|
95
|
+
* const packedTx = await createContract(params).pack(wallet.publicKey);
|
|
96
|
+
*
|
|
97
|
+
* // Option 1: With @solana/kit (server-side/CLI)
|
|
98
|
+
* import { signTransactionMessageWithSigners } from '@solana/kit';
|
|
99
|
+
* const signedTx = await signTransactionMessageWithSigners(packedTx);
|
|
100
|
+
*
|
|
101
|
+
* // Option 2: With wallet adapter (browser) - convert to VersionedTransaction
|
|
102
|
+
* import { VersionedTransaction } from '@solana/web3.js';
|
|
103
|
+
* const versionedTx = VersionedTransaction.deserialize(packedTx.messageBytes);
|
|
104
|
+
* const signedTx = await wallet.signTransaction(versionedTx);
|
|
105
|
+
* // ... send with connection.sendRawTransaction(signedTx.serialize())
|
|
106
|
+
*
|
|
107
|
+
* // Option 3: Get just the bytes for custom handling
|
|
108
|
+
* const txBytes = packedTx.messageBytes;
|
|
109
|
+
* ```
|
|
90
110
|
*/
|
|
91
|
-
|
|
111
|
+
pack(feePayer: Address | string): Promise<any>;
|
|
92
112
|
}
|
|
93
113
|
/**
|
|
94
114
|
* 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,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EACL,KAAK,OAAO,EASb,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAwB5D;;GAEG;AACH,MAAM,WAAW,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