clawkr-cli 1.1.0
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/.env.example +39 -0
- package/README.md +219 -0
- package/dist/commands/claim.js +112 -0
- package/dist/commands/claim.js.map +1 -0
- package/dist/commands/config.js +46 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/launch.js +328 -0
- package/dist/commands/launch.js.map +1 -0
- package/dist/commands/register.js +107 -0
- package/dist/commands/register.js.map +1 -0
- package/dist/commands/status.js +155 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/verify.js +172 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/templates/token-landing.html +436 -0
- package/dist/utils/abis.js +242 -0
- package/dist/utils/abis.js.map +1 -0
- package/dist/utils/basescan.js +252 -0
- package/dist/utils/basescan.js.map +1 -0
- package/dist/utils/config.js +103 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/contract-sources.js +817 -0
- package/dist/utils/contract-sources.js.map +1 -0
- package/dist/utils/wallet.js +116 -0
- package/dist/utils/wallet.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* BaseScan API client for automated contract verification
|
|
4
|
+
*
|
|
5
|
+
* This module provides functions to verify ClawkrToken contracts on BaseScan
|
|
6
|
+
* using the Etherscan v2 API.
|
|
7
|
+
*
|
|
8
|
+
* API Documentation:
|
|
9
|
+
* - https://docs.etherscan.io/contract-verification/multichain-verification
|
|
10
|
+
* - https://docs.moonbeam.network/builders/ethereum/verify-contracts/api-verification/
|
|
11
|
+
*/
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.encodeConstructorArgs = encodeConstructorArgs;
|
|
17
|
+
exports.verifyTokenContract = verifyTokenContract;
|
|
18
|
+
const axios_1 = __importDefault(require("axios"));
|
|
19
|
+
const viem_1 = require("viem");
|
|
20
|
+
const contract_sources_1 = require("./contract-sources");
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// Constants
|
|
23
|
+
// =============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* Etherscan V2 API endpoint (unified multichain)
|
|
26
|
+
* Chain ID: 8453 for Base blockchain
|
|
27
|
+
*/
|
|
28
|
+
const ETHERSCAN_V2_API_URL = 'https://api.etherscan.io/v2/api';
|
|
29
|
+
/**
|
|
30
|
+
* Base blockchain chain ID
|
|
31
|
+
*/
|
|
32
|
+
const BASE_CHAIN_ID = '8453';
|
|
33
|
+
/**
|
|
34
|
+
* Polling interval for verification status checks (5 seconds)
|
|
35
|
+
*/
|
|
36
|
+
const POLL_INTERVAL_MS = 5000;
|
|
37
|
+
// =============================================================================
|
|
38
|
+
// Constructor Argument Encoding
|
|
39
|
+
// =============================================================================
|
|
40
|
+
/**
|
|
41
|
+
* Encode constructor arguments for ClawkrToken verification
|
|
42
|
+
*
|
|
43
|
+
* ClawkrToken constructor signature:
|
|
44
|
+
* constructor(address _agent, address _clawkrHook)
|
|
45
|
+
*
|
|
46
|
+
* @param agentAddress - The agent that launched the token
|
|
47
|
+
* @param hookAddress - The ClawkrHook contract address
|
|
48
|
+
* @returns ABI-encoded constructor arguments (without 0x prefix)
|
|
49
|
+
*/
|
|
50
|
+
function encodeConstructorArgs(agentAddress, hookAddress) {
|
|
51
|
+
// Encode using viem
|
|
52
|
+
const encoded = (0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)('address _agent, address _clawkrHook'), [agentAddress, hookAddress]);
|
|
53
|
+
// Remove 0x prefix for BaseScan API
|
|
54
|
+
return encoded.slice(2);
|
|
55
|
+
}
|
|
56
|
+
// =============================================================================
|
|
57
|
+
// BaseScan API Functions
|
|
58
|
+
// =============================================================================
|
|
59
|
+
/**
|
|
60
|
+
* Submit contract source code for verification to Etherscan V2 API
|
|
61
|
+
*
|
|
62
|
+
* API Endpoint: POST https://api.etherscan.io/v2/api
|
|
63
|
+
* Module: contract
|
|
64
|
+
* Action: verifysourcecode
|
|
65
|
+
*
|
|
66
|
+
* V2 API uses unified multichain endpoint with chainId parameter
|
|
67
|
+
* Constructor args parameter is now correctly spelled "constructorArguments"
|
|
68
|
+
*
|
|
69
|
+
* @param params - Verification parameters including addresses and API key
|
|
70
|
+
* @returns GUID for tracking verification status
|
|
71
|
+
* @throws Error if submission fails
|
|
72
|
+
*/
|
|
73
|
+
async function submitVerification(params) {
|
|
74
|
+
try {
|
|
75
|
+
const response = await axios_1.default.post(`${ETHERSCAN_V2_API_URL}?chainid=${BASE_CHAIN_ID}`, new URLSearchParams({
|
|
76
|
+
module: 'contract',
|
|
77
|
+
action: 'verifysourcecode',
|
|
78
|
+
contractaddress: params.contractAddress,
|
|
79
|
+
sourceCode: contract_sources_1.STANDARD_JSON_INPUT,
|
|
80
|
+
codeformat: 'solidity-standard-json-input',
|
|
81
|
+
contractname: `ClawkrToken.sol:${contract_sources_1.CONTRACT_NAME}`,
|
|
82
|
+
compilerversion: contract_sources_1.COMPILER_VERSION,
|
|
83
|
+
constructorArguments: params.constructorArgs, // V2 API: correct spelling
|
|
84
|
+
licenseType: '3', // MIT License (type 3)
|
|
85
|
+
apikey: params.apiKey,
|
|
86
|
+
}), {
|
|
87
|
+
headers: {
|
|
88
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
// Check if submission was successful
|
|
92
|
+
if (response.data.status === '1') {
|
|
93
|
+
return response.data.result; // Returns GUID
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
throw new Error(`Verification submission failed: ${response.data.result}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
101
|
+
const message = error.response?.data?.result || error.message;
|
|
102
|
+
throw new Error(`BaseScan API error: ${message}`);
|
|
103
|
+
}
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Check verification status using GUID
|
|
109
|
+
*
|
|
110
|
+
* API Endpoint: GET https://api.etherscan.io/v2/api
|
|
111
|
+
* Module: contract
|
|
112
|
+
* Action: checkverifystatus
|
|
113
|
+
*
|
|
114
|
+
* @param guid - Verification GUID returned from submission
|
|
115
|
+
* @param apiKey - Etherscan API key
|
|
116
|
+
* @returns Status check response
|
|
117
|
+
*/
|
|
118
|
+
async function checkVerificationStatus(guid, apiKey) {
|
|
119
|
+
try {
|
|
120
|
+
const response = await axios_1.default.get(`${ETHERSCAN_V2_API_URL}?chainid=${BASE_CHAIN_ID}`, {
|
|
121
|
+
params: {
|
|
122
|
+
module: 'contract',
|
|
123
|
+
action: 'checkverifystatus',
|
|
124
|
+
guid,
|
|
125
|
+
apikey: apiKey,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
return response.data;
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
132
|
+
const message = error.response?.data?.message || error.message;
|
|
133
|
+
throw new Error(`Status check failed: ${message}`);
|
|
134
|
+
}
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Poll verification status until completed or timeout
|
|
140
|
+
*
|
|
141
|
+
* Polls every 5 seconds until:
|
|
142
|
+
* - Verification succeeds ("Pass - Verified")
|
|
143
|
+
* - Verification fails (result contains "Fail")
|
|
144
|
+
* - Timeout is reached
|
|
145
|
+
*
|
|
146
|
+
* @param guid - Verification GUID
|
|
147
|
+
* @param apiKey - BaseScan API key
|
|
148
|
+
* @param timeoutSeconds - Maximum time to wait (default: 30 seconds)
|
|
149
|
+
* @returns Verification result
|
|
150
|
+
*/
|
|
151
|
+
async function pollVerificationStatus(guid, apiKey, timeoutSeconds = 30) {
|
|
152
|
+
const startTime = Date.now();
|
|
153
|
+
while (true) {
|
|
154
|
+
// Check if timeout reached
|
|
155
|
+
const elapsed = (Date.now() - startTime) / 1000;
|
|
156
|
+
if (elapsed > timeoutSeconds) {
|
|
157
|
+
return {
|
|
158
|
+
success: false,
|
|
159
|
+
status: 'pending',
|
|
160
|
+
guid,
|
|
161
|
+
error: `Verification timeout after ${timeoutSeconds}s - still processing`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
// Check status
|
|
166
|
+
const statusResponse = await checkVerificationStatus(guid, apiKey);
|
|
167
|
+
// Check if verified
|
|
168
|
+
if (statusResponse.result === 'Pass - Verified') {
|
|
169
|
+
return {
|
|
170
|
+
success: true,
|
|
171
|
+
status: 'verified',
|
|
172
|
+
guid,
|
|
173
|
+
result: statusResponse.result,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
// Check if failed
|
|
177
|
+
if (statusResponse.result.includes('Fail')) {
|
|
178
|
+
return {
|
|
179
|
+
success: false,
|
|
180
|
+
status: 'failed',
|
|
181
|
+
guid,
|
|
182
|
+
error: statusResponse.result,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
// Still pending, wait and retry
|
|
186
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
// If status check fails, return error but include GUID for manual retry
|
|
190
|
+
return {
|
|
191
|
+
success: false,
|
|
192
|
+
status: 'failed',
|
|
193
|
+
guid,
|
|
194
|
+
error: error.message || 'Status check error',
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// =============================================================================
|
|
200
|
+
// Main Export Function
|
|
201
|
+
// =============================================================================
|
|
202
|
+
/**
|
|
203
|
+
* Verify a ClawkrToken contract on BaseScan
|
|
204
|
+
*
|
|
205
|
+
* This function:
|
|
206
|
+
* 1. Encodes constructor arguments (agent address, hook address)
|
|
207
|
+
* 2. Submits flattened contract source to BaseScan API
|
|
208
|
+
* 3. Polls for verification result with timeout
|
|
209
|
+
*
|
|
210
|
+
* @param params - Verification parameters
|
|
211
|
+
* @param timeoutSeconds - Maximum time to wait for verification (default: 30)
|
|
212
|
+
* @returns Verification result with success status
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* const result = await verifyTokenContract({
|
|
217
|
+
* contractAddress: '0x1234...',
|
|
218
|
+
* agentAddress: '0x5678...',
|
|
219
|
+
* hookAddress: '0x9abc...',
|
|
220
|
+
* basescanApiKey: 'YOUR_API_KEY',
|
|
221
|
+
* }, 30);
|
|
222
|
+
*
|
|
223
|
+
* if (result.success) {
|
|
224
|
+
* console.log('Verified!', result.guid);
|
|
225
|
+
* } else {
|
|
226
|
+
* console.log('Failed:', result.error);
|
|
227
|
+
* }
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
async function verifyTokenContract(params, timeoutSeconds = 30) {
|
|
231
|
+
try {
|
|
232
|
+
// Step 1: Encode constructor arguments
|
|
233
|
+
const constructorArgs = encodeConstructorArgs(params.agentAddress, params.hookAddress);
|
|
234
|
+
// Step 2: Submit verification request
|
|
235
|
+
const guid = await submitVerification({
|
|
236
|
+
contractAddress: params.contractAddress,
|
|
237
|
+
constructorArgs,
|
|
238
|
+
apiKey: params.basescanApiKey,
|
|
239
|
+
});
|
|
240
|
+
// Step 3: Poll for verification result
|
|
241
|
+
return await pollVerificationStatus(guid, params.basescanApiKey, timeoutSeconds);
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
// Return structured error
|
|
245
|
+
return {
|
|
246
|
+
success: false,
|
|
247
|
+
status: 'failed',
|
|
248
|
+
error: error.message || 'Unknown verification error',
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=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,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC;QACxE,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,wEAAwE;YACxE,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,QAAQ;gBAChB,IAAI;gBACJ,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,oBAAoB;aAC7C,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,KAAK,UAAU,mBAAmB,CACvC,MAA0B,EAC1B,iBAAyB,EAAE;IAE3B,IAAI,CAAC;QACH,uCAAuC;QACvC,MAAM,eAAe,GAAG,qBAAqB,CAC3C,MAAM,CAAC,YAAY,EACnB,MAAM,CAAC,WAAW,CACnB,CAAC;QAEF,sCAAsC;QACtC,MAAM,IAAI,GAAG,MAAM,kBAAkB,CAAC;YACpC,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,eAAe;YACf,MAAM,EAAE,MAAM,CAAC,cAAc;SAC9B,CAAC,CAAC;QAEH,uCAAuC;QACvC,OAAO,MAAM,sBAAsB,CAAC,IAAI,EAAE,MAAM,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IACnF,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,0BAA0B;QAC1B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,4BAA4B;SACrD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ensureConfigDir = ensureConfigDir;
|
|
40
|
+
exports.loadConfig = loadConfig;
|
|
41
|
+
exports.saveConfig = saveConfig;
|
|
42
|
+
exports.getPrivateKey = getPrivateKey;
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const os = __importStar(require("os"));
|
|
46
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
47
|
+
const wallet_1 = require("./wallet");
|
|
48
|
+
// Load environment variables
|
|
49
|
+
dotenv_1.default.config();
|
|
50
|
+
const CONFIG_DIR = path.join(os.homedir(), '.clawkr');
|
|
51
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
52
|
+
// Clawkr V4 contract addresses on Base mainnet (v2 deployment - Feb 4, 2026)
|
|
53
|
+
const DEFAULT_CONFIG = {
|
|
54
|
+
rpcUrl: process.env.RPC_URL || 'https://mainnet.base.org',
|
|
55
|
+
chainId: parseInt(process.env.CHAIN_ID || '8453'),
|
|
56
|
+
contracts: {
|
|
57
|
+
agentRegistry: process.env.AGENT_REGISTRY_ADDRESS || '0xaBBe7b34E9E8d9e158A68873EBC2C5ff574C4017',
|
|
58
|
+
clawkrHook: process.env.CLAWKR_HOOK_ADDRESS || '0xa3966B92F2184fca0839E4D238503FcC6bA92AC8',
|
|
59
|
+
fairLaunch: process.env.FAIR_LAUNCH_ADDRESS || '0xd919c044999F8beE26ca3b28C4f41E58947598c4',
|
|
60
|
+
marketCapPrice: process.env.MARKET_CAP_PRICE_ADDRESS || '0x90080d2752c046cec72c221822B1ddafC351905D',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
function ensureConfigDir() {
|
|
64
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
65
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function loadConfig() {
|
|
69
|
+
ensureConfigDir();
|
|
70
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
71
|
+
try {
|
|
72
|
+
const fileConfig = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf-8'));
|
|
73
|
+
return { ...DEFAULT_CONFIG, ...fileConfig };
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return DEFAULT_CONFIG;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return DEFAULT_CONFIG;
|
|
80
|
+
}
|
|
81
|
+
function saveConfig(config) {
|
|
82
|
+
ensureConfigDir();
|
|
83
|
+
const currentConfig = loadConfig();
|
|
84
|
+
const newConfig = { ...currentConfig, ...config };
|
|
85
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(newConfig, null, 2));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get private key from environment variable or stored wallet file
|
|
89
|
+
* Priority: 1. PRIVATE_KEY env var, 2. ~/.clawkr/wallet.json
|
|
90
|
+
*/
|
|
91
|
+
function getPrivateKey() {
|
|
92
|
+
// First check environment variable
|
|
93
|
+
if (process.env.PRIVATE_KEY) {
|
|
94
|
+
return process.env.PRIVATE_KEY;
|
|
95
|
+
}
|
|
96
|
+
// Then check stored wallet file
|
|
97
|
+
const wallet = (0, wallet_1.loadWallet)();
|
|
98
|
+
if (wallet) {
|
|
99
|
+
return wallet.privateKey;
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,0CAIC;AAED,gCAaC;AAED,gCAOC;AAMD,sCAaC;AAlFD,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AACzB,oDAA4B;AAC5B,qCAAsC;AAEtC,6BAA6B;AAC7B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AACtD,MAAM,WAAW,GAAG,IAAI,CAAC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