@kynesyslabs/demosdk 2.3.28 → 2.4.1
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/build/abstraction/Identities.d.ts +10 -1
- package/build/abstraction/Identities.js +34 -4
- package/build/abstraction/Identities.js.map +1 -1
- package/build/contracts/ContractDeployer.d.ts +34 -0
- package/build/contracts/ContractDeployer.js +196 -0
- package/build/contracts/ContractDeployer.js.map +1 -0
- package/build/contracts/ContractFactory.d.ts +52 -0
- package/build/contracts/ContractFactory.js +98 -0
- package/build/contracts/ContractFactory.js.map +1 -0
- package/build/contracts/ContractInstance.d.ts +51 -0
- package/build/contracts/ContractInstance.js +138 -0
- package/build/contracts/ContractInstance.js.map +1 -0
- package/build/contracts/ContractInteractor.d.ts +55 -0
- package/build/contracts/ContractInteractor.js +242 -0
- package/build/contracts/ContractInteractor.js.map +1 -0
- package/build/contracts/index.d.ts +9 -0
- package/build/contracts/index.js +16 -0
- package/build/contracts/index.js.map +1 -0
- package/build/contracts/templates/TemplateRegistry.d.ts +71 -0
- package/build/contracts/templates/TemplateRegistry.js +404 -0
- package/build/contracts/templates/TemplateRegistry.js.map +1 -0
- package/build/contracts/templates/TemplateValidator.d.ts +55 -0
- package/build/contracts/templates/TemplateValidator.js +202 -0
- package/build/contracts/templates/TemplateValidator.js.map +1 -0
- package/build/contracts/types/ContractABI.d.ts +111 -0
- package/build/contracts/types/ContractABI.js +6 -0
- package/build/contracts/types/ContractABI.js.map +1 -0
- package/build/contracts/types/TypedContract.d.ts +34 -0
- package/build/contracts/types/TypedContract.js +6 -0
- package/build/contracts/types/TypedContract.js.map +1 -0
- package/build/types/abstraction/index.d.ts +7 -1
- package/build/types/web2/discord.d.ts +8 -0
- package/build/types/web2/discord.js +3 -0
- package/build/types/web2/discord.js.map +1 -0
- package/build/websdk/DemosContracts.d.ts +140 -0
- package/build/websdk/DemosContracts.js +185 -0
- package/build/websdk/DemosContracts.js.map +1 -0
- package/build/websdk/demosclass.d.ts +6 -0
- package/build/websdk/demosclass.js +5 -0
- package/build/websdk/demosclass.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Template Registry with Parameter Substitution
|
|
4
|
+
*
|
|
5
|
+
* Manages contract templates, validates parameters, and performs
|
|
6
|
+
* parameter substitution to generate deployable contract source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TemplateRegistry = void 0;
|
|
10
|
+
const TemplateValidator_1 = require("./TemplateValidator");
|
|
11
|
+
class TemplateRegistry {
|
|
12
|
+
/**
|
|
13
|
+
* Initialize the template registry with built-in templates
|
|
14
|
+
*/
|
|
15
|
+
static initialize() {
|
|
16
|
+
if (this.initialized)
|
|
17
|
+
return;
|
|
18
|
+
// Register Token template
|
|
19
|
+
this.registerTemplate({
|
|
20
|
+
name: 'Token',
|
|
21
|
+
schema: {
|
|
22
|
+
name: 'Token',
|
|
23
|
+
description: 'Standard token contract with ERC-20-like functionality',
|
|
24
|
+
version: '1.0.0',
|
|
25
|
+
author: 'Kynesys Labs',
|
|
26
|
+
parameters: [
|
|
27
|
+
{
|
|
28
|
+
name: 'TOKEN_NAME',
|
|
29
|
+
type: 'string',
|
|
30
|
+
required: true,
|
|
31
|
+
default: 'DemosToken',
|
|
32
|
+
pattern: /^[A-Za-z0-9\s]{1,32}$/,
|
|
33
|
+
description: 'The name of the token (e.g., "My Token")'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'TOKEN_SYMBOL',
|
|
37
|
+
type: 'string',
|
|
38
|
+
required: true,
|
|
39
|
+
default: 'DTK',
|
|
40
|
+
pattern: /^[A-Z]{1,8}$/,
|
|
41
|
+
description: 'The symbol of the token (e.g., "MTK")'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'TOTAL_SUPPLY',
|
|
45
|
+
type: 'number',
|
|
46
|
+
required: true,
|
|
47
|
+
default: 1000000,
|
|
48
|
+
min: 1,
|
|
49
|
+
max: 1000000000000,
|
|
50
|
+
description: 'Initial token supply'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'DECIMALS',
|
|
54
|
+
type: 'number',
|
|
55
|
+
required: false,
|
|
56
|
+
default: 18,
|
|
57
|
+
min: 0,
|
|
58
|
+
max: 18,
|
|
59
|
+
description: 'Number of decimal places for the token'
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
sourceFile: 'Token.ts.template'
|
|
64
|
+
});
|
|
65
|
+
// Register Storage template
|
|
66
|
+
this.registerTemplate({
|
|
67
|
+
name: 'Storage',
|
|
68
|
+
schema: {
|
|
69
|
+
name: 'Storage',
|
|
70
|
+
description: 'Key-value storage contract with access control',
|
|
71
|
+
version: '1.0.0',
|
|
72
|
+
author: 'Kynesys Labs',
|
|
73
|
+
parameters: [
|
|
74
|
+
{
|
|
75
|
+
name: 'IS_PUBLIC',
|
|
76
|
+
type: 'boolean',
|
|
77
|
+
required: false,
|
|
78
|
+
default: false,
|
|
79
|
+
description: 'Whether the storage allows public read access'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'MAX_KEYS',
|
|
83
|
+
type: 'number',
|
|
84
|
+
required: false,
|
|
85
|
+
default: 1000,
|
|
86
|
+
min: 1,
|
|
87
|
+
max: 10000,
|
|
88
|
+
description: 'Maximum number of keys that can be stored'
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
sourceFile: 'Storage.ts.template'
|
|
93
|
+
});
|
|
94
|
+
this.initialized = true;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Register a new template
|
|
98
|
+
*/
|
|
99
|
+
static registerTemplate(templateInfo) {
|
|
100
|
+
this.templates.set(templateInfo.name, templateInfo);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get all available template names
|
|
104
|
+
*/
|
|
105
|
+
static getAvailableTemplates() {
|
|
106
|
+
this.initialize();
|
|
107
|
+
return Array.from(this.templates.keys());
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get template information
|
|
111
|
+
*/
|
|
112
|
+
static getTemplate(name) {
|
|
113
|
+
this.initialize();
|
|
114
|
+
return this.templates.get(name) || null;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get template schema for validation
|
|
118
|
+
*/
|
|
119
|
+
static getTemplateSchema(name) {
|
|
120
|
+
const template = this.getTemplate(name);
|
|
121
|
+
return template ? template.schema : null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Load template source code
|
|
125
|
+
*/
|
|
126
|
+
static loadTemplateSource(template) {
|
|
127
|
+
if (template.source) {
|
|
128
|
+
return template.source;
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
// In a real implementation, you'd load from the file system
|
|
132
|
+
// For now, we'll use the embedded source strings
|
|
133
|
+
// const templatePath = path.join(__dirname, template.sourceFile)
|
|
134
|
+
// Since we can't actually read files in this context,
|
|
135
|
+
// we'll return the source based on template name
|
|
136
|
+
return this.getEmbeddedTemplateSource(template.name);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
throw new Error(`Failed to load template source for ${template.name}: ${error.message}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Get embedded template source (temporary implementation)
|
|
144
|
+
*/
|
|
145
|
+
static getEmbeddedTemplateSource(templateName) {
|
|
146
|
+
// In a real implementation, these would be loaded from .contract.ts files
|
|
147
|
+
const sources = {
|
|
148
|
+
'Token': `
|
|
149
|
+
class Token extends DemosContract {
|
|
150
|
+
constructor(
|
|
151
|
+
name: string = "{{TOKEN_NAME}}",
|
|
152
|
+
symbol: string = "{{TOKEN_SYMBOL}}",
|
|
153
|
+
totalSupply: number = {{TOTAL_SUPPLY}},
|
|
154
|
+
decimals: number = {{DECIMALS}}
|
|
155
|
+
) {
|
|
156
|
+
super()
|
|
157
|
+
this.state.set('name', name)
|
|
158
|
+
this.state.set('symbol', symbol)
|
|
159
|
+
this.state.set('decimals', decimals)
|
|
160
|
+
this.state.set('totalSupply', totalSupply)
|
|
161
|
+
this.state.set('balances', {})
|
|
162
|
+
this.state.set('allowances', {})
|
|
163
|
+
const creator = this.sender
|
|
164
|
+
const balances = this.state.get('balances')
|
|
165
|
+
balances[creator] = totalSupply
|
|
166
|
+
this.state.set('balances', balances)
|
|
167
|
+
this.emit('Transfer', { from: '0x0', to: creator, amount: totalSupply })
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
name(): string { return this.state.get('name') }
|
|
171
|
+
symbol(): string { return this.state.get('symbol') }
|
|
172
|
+
decimals(): number { return this.state.get('decimals') }
|
|
173
|
+
totalSupply(): number { return this.state.get('totalSupply') }
|
|
174
|
+
|
|
175
|
+
balanceOf(address: string): number {
|
|
176
|
+
const balances = this.state.get('balances')
|
|
177
|
+
return balances[address] || 0
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
transfer(to: string, amount: number): boolean {
|
|
181
|
+
const from = this.sender
|
|
182
|
+
return this._transfer(from, to, amount)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private _transfer(from: string, to: string, amount: number): boolean {
|
|
186
|
+
if (!to || to === '0x0') this.revert('Transfer to zero address')
|
|
187
|
+
if (amount <= 0) this.revert('Transfer amount must be positive')
|
|
188
|
+
|
|
189
|
+
const balances = this.state.get('balances')
|
|
190
|
+
const fromBalance = balances[from] || 0
|
|
191
|
+
if (fromBalance < amount) this.revert('Insufficient balance')
|
|
192
|
+
|
|
193
|
+
balances[from] = fromBalance - amount
|
|
194
|
+
balances[to] = (balances[to] || 0) + amount
|
|
195
|
+
this.state.set('balances', balances)
|
|
196
|
+
|
|
197
|
+
this.emit('Transfer', { from, to, amount })
|
|
198
|
+
return true
|
|
199
|
+
}
|
|
200
|
+
}`,
|
|
201
|
+
'Storage': `
|
|
202
|
+
class Storage extends DemosContract {
|
|
203
|
+
constructor(
|
|
204
|
+
isPublic: boolean = {{IS_PUBLIC}},
|
|
205
|
+
maxKeys: number = {{MAX_KEYS}}
|
|
206
|
+
) {
|
|
207
|
+
super()
|
|
208
|
+
this.state.set('owner', this.sender)
|
|
209
|
+
this.state.set('isPublic', isPublic)
|
|
210
|
+
this.state.set('maxKeys', maxKeys)
|
|
211
|
+
this.state.set('keyCount', 0)
|
|
212
|
+
this.state.set('data', {})
|
|
213
|
+
this.state.set('authorizedUsers', {})
|
|
214
|
+
|
|
215
|
+
const authorizedUsers = {}
|
|
216
|
+
authorizedUsers[this.sender] = true
|
|
217
|
+
this.state.set('authorizedUsers', authorizedUsers)
|
|
218
|
+
|
|
219
|
+
this.emit('StorageCreated', { owner: this.sender, isPublic, maxKeys })
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
store(key: string, value: any): boolean {
|
|
223
|
+
this._requireWriteAccess()
|
|
224
|
+
this._validateKey(key)
|
|
225
|
+
|
|
226
|
+
const data = this.state.get('data')
|
|
227
|
+
const isNewKey = !(key in data)
|
|
228
|
+
|
|
229
|
+
if (isNewKey) {
|
|
230
|
+
const currentKeyCount = this.state.get('keyCount')
|
|
231
|
+
const maxKeys = this.state.get('maxKeys')
|
|
232
|
+
if (currentKeyCount >= maxKeys) this.revert('Maximum key limit reached')
|
|
233
|
+
this.state.set('keyCount', currentKeyCount + 1)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
data[key] = { value, timestamp: this.blockHeight, author: this.sender }
|
|
237
|
+
this.state.set('data', data)
|
|
238
|
+
this.emit('ValueStored', { key, value, author: this.sender, isNewKey })
|
|
239
|
+
return true
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
retrieve(key: string): any {
|
|
243
|
+
this._requireReadAccess()
|
|
244
|
+
this._validateKey(key)
|
|
245
|
+
const data = this.state.get('data')
|
|
246
|
+
const entry = data[key]
|
|
247
|
+
if (!entry) return null
|
|
248
|
+
this.emit('ValueRetrieved', { key, value: entry.value, requester: this.sender })
|
|
249
|
+
return entry.value
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private _requireReadAccess(): void {
|
|
253
|
+
const isPublic = this.state.get('isPublic')
|
|
254
|
+
if (isPublic) return
|
|
255
|
+
const authorizedUsers = this.state.get('authorizedUsers')
|
|
256
|
+
if (authorizedUsers[this.sender] !== true) this.revert('Read access denied')
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
private _requireWriteAccess(): void {
|
|
260
|
+
const authorizedUsers = this.state.get('authorizedUsers')
|
|
261
|
+
if (authorizedUsers[this.sender] !== true) this.revert('Write access denied')
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
private _validateKey(key: string): void {
|
|
265
|
+
if (!key || typeof key !== 'string') this.revert('Invalid key: must be non-empty string')
|
|
266
|
+
if (key.length > 64) this.revert('Key too long: maximum 64 characters')
|
|
267
|
+
if (key.startsWith('_') || key.includes('\\0')) this.revert('Invalid key format')
|
|
268
|
+
}
|
|
269
|
+
}`
|
|
270
|
+
};
|
|
271
|
+
return sources[templateName] || '';
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Validate template parameters
|
|
275
|
+
*/
|
|
276
|
+
static validateParameters(templateName, params) {
|
|
277
|
+
this.initialize();
|
|
278
|
+
const template = this.getTemplate(templateName);
|
|
279
|
+
if (!template) {
|
|
280
|
+
return {
|
|
281
|
+
valid: false,
|
|
282
|
+
errors: [`Template '${templateName}' not found`],
|
|
283
|
+
warnings: [],
|
|
284
|
+
processedParams: {}
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
return TemplateValidator_1.TemplateValidator.validate(template.schema, params);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Generate contract source with parameter substitution
|
|
291
|
+
*/
|
|
292
|
+
static generateContract(templateName, params = {}) {
|
|
293
|
+
this.initialize();
|
|
294
|
+
const template = this.getTemplate(templateName);
|
|
295
|
+
if (!template) {
|
|
296
|
+
return {
|
|
297
|
+
success: false,
|
|
298
|
+
errors: [`Template '${templateName}' not found`],
|
|
299
|
+
warnings: []
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
// Validate parameters
|
|
303
|
+
const validation = this.validateParameters(templateName, params);
|
|
304
|
+
if (!validation.valid) {
|
|
305
|
+
return {
|
|
306
|
+
success: false,
|
|
307
|
+
errors: validation.errors,
|
|
308
|
+
warnings: validation.warnings
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
try {
|
|
312
|
+
// Load template source
|
|
313
|
+
const templateSource = this.loadTemplateSource(template);
|
|
314
|
+
// Perform parameter substitution
|
|
315
|
+
const substitutedSource = this.substituteParameters(templateSource, validation.processedParams);
|
|
316
|
+
return {
|
|
317
|
+
success: true,
|
|
318
|
+
source: substitutedSource,
|
|
319
|
+
errors: [],
|
|
320
|
+
warnings: validation.warnings
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
return {
|
|
325
|
+
success: false,
|
|
326
|
+
errors: [`Template generation failed: ${error.message}`],
|
|
327
|
+
warnings: validation.warnings
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Perform parameter substitution in template source
|
|
333
|
+
*/
|
|
334
|
+
static substituteParameters(source, params) {
|
|
335
|
+
let result = source;
|
|
336
|
+
// Replace each parameter placeholder
|
|
337
|
+
for (const [key, value] of Object.entries(params)) {
|
|
338
|
+
const placeholder = `{{${key}}}`;
|
|
339
|
+
const replacement = this.formatParameterValue(value);
|
|
340
|
+
// Replace all occurrences
|
|
341
|
+
result = result.replace(new RegExp(placeholder, 'g'), replacement);
|
|
342
|
+
}
|
|
343
|
+
// Check for unreplaced placeholders
|
|
344
|
+
const unreplacedMatches = result.match(/\{\{[^}]+\}\}/g);
|
|
345
|
+
if (unreplacedMatches) {
|
|
346
|
+
throw new Error(`Unreplaced template parameters: ${unreplacedMatches.join(', ')}`);
|
|
347
|
+
}
|
|
348
|
+
return result;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Format parameter value for code generation
|
|
352
|
+
*/
|
|
353
|
+
static formatParameterValue(value) {
|
|
354
|
+
if (typeof value === 'string') {
|
|
355
|
+
return `"${value.replace(/"/g, '\\"')}"`; // Escape quotes
|
|
356
|
+
}
|
|
357
|
+
else if (typeof value === 'boolean') {
|
|
358
|
+
return value.toString();
|
|
359
|
+
}
|
|
360
|
+
else if (typeof value === 'number') {
|
|
361
|
+
return value.toString();
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
return JSON.stringify(value);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Get template usage examples
|
|
369
|
+
*/
|
|
370
|
+
static getTemplateExample(templateName) {
|
|
371
|
+
this.initialize();
|
|
372
|
+
const examples = {
|
|
373
|
+
'Token': `
|
|
374
|
+
// Deploy a custom token
|
|
375
|
+
const token = await demos.contracts.deployTemplate('Token', {
|
|
376
|
+
TOKEN_NAME: 'MyToken',
|
|
377
|
+
TOKEN_SYMBOL: 'MTK',
|
|
378
|
+
TOTAL_SUPPLY: 1000000,
|
|
379
|
+
DECIMALS: 18
|
|
380
|
+
})
|
|
381
|
+
|
|
382
|
+
// Interact with the token
|
|
383
|
+
const balance = await token.balanceOf('address')
|
|
384
|
+
await token.transfer('recipient', 100)
|
|
385
|
+
`,
|
|
386
|
+
'Storage': `
|
|
387
|
+
// Deploy a private storage contract
|
|
388
|
+
const storage = await demos.contracts.deployTemplate('Storage', {
|
|
389
|
+
IS_PUBLIC: false,
|
|
390
|
+
MAX_KEYS: 500
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
// Use the storage
|
|
394
|
+
await storage.store('myKey', 'myValue')
|
|
395
|
+
const value = await storage.retrieve('myKey')
|
|
396
|
+
`
|
|
397
|
+
};
|
|
398
|
+
return examples[templateName] || null;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
exports.TemplateRegistry = TemplateRegistry;
|
|
402
|
+
TemplateRegistry.templates = new Map();
|
|
403
|
+
TemplateRegistry.initialized = false;
|
|
404
|
+
//# sourceMappingURL=TemplateRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateRegistry.js","sourceRoot":"","sources":["../../../../src/contracts/templates/TemplateRegistry.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,2DAAyF;AAgBzF,MAAa,gBAAgB;IAIzB;;OAEG;IACH,MAAM,CAAC,UAAU;QACb,IAAI,IAAI,CAAC,WAAW;YAAE,OAAM;QAE5B,0BAA0B;QAC1B,IAAI,CAAC,gBAAgB,CAAC;YAClB,IAAI,EAAE,OAAO;YACb,MAAM,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,wDAAwD;gBACrE,OAAO,EAAE,OAAO;gBAChB,MAAM,EAAE,cAAc;gBACtB,UAAU,EAAE;oBACR;wBACI,IAAI,EAAE,YAAY;wBAClB,IAAI,EAAE,QAAQ;wBACd,QAAQ,EAAE,IAAI;wBACd,OAAO,EAAE,YAAY;wBACrB,OAAO,EAAE,uBAAuB;wBAChC,WAAW,EAAE,0CAA0C;qBAC1D;oBACD;wBACI,IAAI,EAAE,cAAc;wBACpB,IAAI,EAAE,QAAQ;wBACd,QAAQ,EAAE,IAAI;wBACd,OAAO,EAAE,KAAK;wBACd,OAAO,EAAE,cAAc;wBACvB,WAAW,EAAE,uCAAuC;qBACvD;oBACD;wBACI,IAAI,EAAE,cAAc;wBACpB,IAAI,EAAE,QAAQ;wBACd,QAAQ,EAAE,IAAI;wBACd,OAAO,EAAE,OAAO;wBAChB,GAAG,EAAE,CAAC;wBACN,GAAG,EAAE,aAAa;wBAClB,WAAW,EAAE,sBAAsB;qBACtC;oBACD;wBACI,IAAI,EAAE,UAAU;wBAChB,IAAI,EAAE,QAAQ;wBACd,QAAQ,EAAE,KAAK;wBACf,OAAO,E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M,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA;QAC3B,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA;QAC3B,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QAChC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,YAAoB;QAC1C,IAAI,CAAC,UAAU,EAAE,CAAA;QAEjB,MAAM,QAAQ,GAA2B;YACrC,OAAO,EAAE;;;;;;;;;;;;CAYpB;YACW,SAAS,EAAE;;;;;;;;;;CAUtB;SACQ,CAAA;QAED,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAI,IAAI,CAAA;IACzC,CAAC;;AA7aL,4CA8aC;AA7akB,0BAAS,GAA8B,IAAI,GAAG,EAAE,CAAA;AAChD,4BAAW,GAAG,KAAK,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template parameter validation system
|
|
3
|
+
*
|
|
4
|
+
* Validates template parameters before deployment to ensure
|
|
5
|
+
* safe and correct contract generation.
|
|
6
|
+
*/
|
|
7
|
+
export interface TemplateParameter {
|
|
8
|
+
name: string;
|
|
9
|
+
type: 'string' | 'number' | 'boolean' | 'address';
|
|
10
|
+
required: boolean;
|
|
11
|
+
default?: any;
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
pattern?: RegExp;
|
|
15
|
+
description: string;
|
|
16
|
+
}
|
|
17
|
+
export interface TemplateSchema {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
parameters: TemplateParameter[];
|
|
21
|
+
version: string;
|
|
22
|
+
author?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ValidationResult {
|
|
25
|
+
valid: boolean;
|
|
26
|
+
errors: string[];
|
|
27
|
+
warnings: string[];
|
|
28
|
+
processedParams: Record<string, any>;
|
|
29
|
+
}
|
|
30
|
+
export declare class TemplateValidator {
|
|
31
|
+
/**
|
|
32
|
+
* Validate parameters against a template schema
|
|
33
|
+
*/
|
|
34
|
+
static validate(schema: TemplateSchema, params?: Record<string, any>): ValidationResult;
|
|
35
|
+
/**
|
|
36
|
+
* Validate parameter type
|
|
37
|
+
*/
|
|
38
|
+
private static validateType;
|
|
39
|
+
/**
|
|
40
|
+
* Validate number range
|
|
41
|
+
*/
|
|
42
|
+
private static validateNumberRange;
|
|
43
|
+
/**
|
|
44
|
+
* Validate string pattern
|
|
45
|
+
*/
|
|
46
|
+
private static validatePattern;
|
|
47
|
+
/**
|
|
48
|
+
* Validate address format
|
|
49
|
+
*/
|
|
50
|
+
private static validateAddress;
|
|
51
|
+
/**
|
|
52
|
+
* Get human-readable validation summary
|
|
53
|
+
*/
|
|
54
|
+
static getValidationSummary(result: ValidationResult): string;
|
|
55
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Template parameter validation system
|
|
4
|
+
*
|
|
5
|
+
* Validates template parameters before deployment to ensure
|
|
6
|
+
* safe and correct contract generation.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TemplateValidator = void 0;
|
|
10
|
+
class TemplateValidator {
|
|
11
|
+
/**
|
|
12
|
+
* Validate parameters against a template schema
|
|
13
|
+
*/
|
|
14
|
+
static validate(schema, params = {}) {
|
|
15
|
+
const result = {
|
|
16
|
+
valid: true,
|
|
17
|
+
errors: [],
|
|
18
|
+
warnings: [],
|
|
19
|
+
processedParams: {}
|
|
20
|
+
};
|
|
21
|
+
// Check each parameter in the schema
|
|
22
|
+
for (const paramDef of schema.parameters) {
|
|
23
|
+
const value = params[paramDef.name];
|
|
24
|
+
const hasValue = value !== undefined && value !== null;
|
|
25
|
+
// Check required parameters
|
|
26
|
+
if (paramDef.required && !hasValue) {
|
|
27
|
+
result.errors.push(`Required parameter '${paramDef.name}' is missing`);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
// Use default value if not provided
|
|
31
|
+
const finalValue = hasValue ? value : paramDef.default;
|
|
32
|
+
// Skip validation if no value and not required
|
|
33
|
+
if (finalValue === undefined || finalValue === null) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
// Type validation
|
|
37
|
+
const typeValidation = this.validateType(paramDef, finalValue);
|
|
38
|
+
if (!typeValidation.valid) {
|
|
39
|
+
result.errors.push(...typeValidation.errors);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
// Range validation for numbers
|
|
43
|
+
if (paramDef.type === 'number') {
|
|
44
|
+
const rangeValidation = this.validateNumberRange(paramDef, finalValue);
|
|
45
|
+
if (!rangeValidation.valid) {
|
|
46
|
+
result.errors.push(...rangeValidation.errors);
|
|
47
|
+
result.warnings.push(...rangeValidation.warnings);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Pattern validation for strings
|
|
51
|
+
if (paramDef.type === 'string' && paramDef.pattern) {
|
|
52
|
+
const patternValidation = this.validatePattern(paramDef, finalValue);
|
|
53
|
+
if (!patternValidation.valid) {
|
|
54
|
+
result.errors.push(...patternValidation.errors);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Address validation
|
|
58
|
+
if (paramDef.type === 'address') {
|
|
59
|
+
const addressValidation = this.validateAddress(paramDef, finalValue);
|
|
60
|
+
if (!addressValidation.valid) {
|
|
61
|
+
result.errors.push(...addressValidation.errors);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
result.processedParams[paramDef.name] = finalValue;
|
|
65
|
+
}
|
|
66
|
+
// Check for unknown parameters
|
|
67
|
+
for (const paramName of Object.keys(params)) {
|
|
68
|
+
const isDefined = schema.parameters.some(p => p.name === paramName);
|
|
69
|
+
if (!isDefined) {
|
|
70
|
+
result.warnings.push(`Unknown parameter '${paramName}' will be ignored`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
result.valid = result.errors.length === 0;
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Validate parameter type
|
|
78
|
+
*/
|
|
79
|
+
static validateType(paramDef, value) {
|
|
80
|
+
const result = {
|
|
81
|
+
valid: true,
|
|
82
|
+
errors: [],
|
|
83
|
+
warnings: [],
|
|
84
|
+
processedParams: {}
|
|
85
|
+
};
|
|
86
|
+
const actualType = typeof value;
|
|
87
|
+
switch (paramDef.type) {
|
|
88
|
+
case 'string':
|
|
89
|
+
if (actualType !== 'string') {
|
|
90
|
+
result.errors.push(`Parameter '${paramDef.name}' must be a string, got ${actualType}`);
|
|
91
|
+
result.valid = false;
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case 'number':
|
|
95
|
+
if (actualType !== 'number' || isNaN(value)) {
|
|
96
|
+
result.errors.push(`Parameter '${paramDef.name}' must be a number, got ${actualType}`);
|
|
97
|
+
result.valid = false;
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
case 'boolean':
|
|
101
|
+
if (actualType !== 'boolean') {
|
|
102
|
+
result.errors.push(`Parameter '${paramDef.name}' must be a boolean, got ${actualType}`);
|
|
103
|
+
result.valid = false;
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
case 'address':
|
|
107
|
+
if (actualType !== 'string') {
|
|
108
|
+
result.errors.push(`Parameter '${paramDef.name}' must be an address string, got ${actualType}`);
|
|
109
|
+
result.valid = false;
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Validate number range
|
|
117
|
+
*/
|
|
118
|
+
static validateNumberRange(paramDef, value) {
|
|
119
|
+
const result = {
|
|
120
|
+
valid: true,
|
|
121
|
+
errors: [],
|
|
122
|
+
warnings: [],
|
|
123
|
+
processedParams: {}
|
|
124
|
+
};
|
|
125
|
+
if (paramDef.min !== undefined && value < paramDef.min) {
|
|
126
|
+
result.errors.push(`Parameter '${paramDef.name}' must be at least ${paramDef.min}, got ${value}`);
|
|
127
|
+
result.valid = false;
|
|
128
|
+
}
|
|
129
|
+
if (paramDef.max !== undefined && value > paramDef.max) {
|
|
130
|
+
result.errors.push(`Parameter '${paramDef.name}' must be at most ${paramDef.max}, got ${value}`);
|
|
131
|
+
result.valid = false;
|
|
132
|
+
}
|
|
133
|
+
// Warnings for edge cases
|
|
134
|
+
if (paramDef.name.includes('Supply') && value > 1000000000) {
|
|
135
|
+
result.warnings.push(`Large supply value for '${paramDef.name}': ${value}. Consider decimal precision.`);
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Validate string pattern
|
|
141
|
+
*/
|
|
142
|
+
static validatePattern(paramDef, value) {
|
|
143
|
+
const result = {
|
|
144
|
+
valid: true,
|
|
145
|
+
errors: [],
|
|
146
|
+
warnings: [],
|
|
147
|
+
processedParams: {}
|
|
148
|
+
};
|
|
149
|
+
if (paramDef.pattern && !paramDef.pattern.test(value)) {
|
|
150
|
+
result.errors.push(`Parameter '${paramDef.name}' does not match required pattern: ${paramDef.pattern}`);
|
|
151
|
+
result.valid = false;
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Validate address format
|
|
157
|
+
*/
|
|
158
|
+
static validateAddress(paramDef, value) {
|
|
159
|
+
const result = {
|
|
160
|
+
valid: true,
|
|
161
|
+
errors: [],
|
|
162
|
+
warnings: [],
|
|
163
|
+
processedParams: {}
|
|
164
|
+
};
|
|
165
|
+
// Basic address validation (adjust for Demos Network format)
|
|
166
|
+
const addressPattern = /^[a-fA-F0-9]{64}$/;
|
|
167
|
+
if (!addressPattern.test(value)) {
|
|
168
|
+
result.errors.push(`Parameter '${paramDef.name}' is not a valid address format`);
|
|
169
|
+
result.valid = false;
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get human-readable validation summary
|
|
175
|
+
*/
|
|
176
|
+
static getValidationSummary(result) {
|
|
177
|
+
const lines = [];
|
|
178
|
+
if (result.valid) {
|
|
179
|
+
lines.push('✅ Validation passed');
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
lines.push('❌ Validation failed');
|
|
183
|
+
}
|
|
184
|
+
if (result.errors.length > 0) {
|
|
185
|
+
lines.push('\nErrors:');
|
|
186
|
+
result.errors.forEach(error => lines.push(` • ${error}`));
|
|
187
|
+
}
|
|
188
|
+
if (result.warnings.length > 0) {
|
|
189
|
+
lines.push('\nWarnings:');
|
|
190
|
+
result.warnings.forEach(warning => lines.push(` • ${warning}`));
|
|
191
|
+
}
|
|
192
|
+
if (Object.keys(result.processedParams).length > 0) {
|
|
193
|
+
lines.push('\nProcessed parameters:');
|
|
194
|
+
Object.entries(result.processedParams).forEach(([key, value]) => {
|
|
195
|
+
lines.push(` • ${key}: ${JSON.stringify(value)}`);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
return lines.join('\n');
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.TemplateValidator = TemplateValidator;
|
|
202
|
+
//# sourceMappingURL=TemplateValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateValidator.js","sourceRoot":"","sources":["../../../../src/contracts/templates/TemplateValidator.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA4BH,MAAa,iBAAiB;IAE1B;;OAEG;IACH,MAAM,CAAC,QAAQ,CACX,MAAsB,EACtB,SAA8B,EAAE;QAEhC,MAAM,MAAM,GAAqB;YAC7B,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,EAAE;YACZ,eAAe,EAAE,EAAE;SACtB,CAAA;QAED,qC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