@varity-labs/sdk 2.0.0-alpha.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.
Files changed (295) hide show
  1. package/LICENSE +31 -0
  2. package/README.md +253 -0
  3. package/dist/analytics/index.d.ts +7 -0
  4. package/dist/analytics/index.d.ts.map +1 -0
  5. package/dist/analytics/index.js +6 -0
  6. package/dist/analytics/tracker.d.ts +128 -0
  7. package/dist/analytics/tracker.d.ts.map +1 -0
  8. package/dist/analytics/tracker.js +203 -0
  9. package/dist/blockchain/BlockchainService.d.ts +100 -0
  10. package/dist/blockchain/BlockchainService.d.ts.map +1 -0
  11. package/dist/blockchain/BlockchainService.js +188 -0
  12. package/dist/blockchain/NFTLicensingService.d.ts +69 -0
  13. package/dist/blockchain/NFTLicensingService.d.ts.map +1 -0
  14. package/dist/blockchain/NFTLicensingService.js +136 -0
  15. package/dist/blockchain/RevenueSplitService.d.ts +71 -0
  16. package/dist/blockchain/RevenueSplitService.d.ts.map +1 -0
  17. package/dist/blockchain/RevenueSplitService.js +111 -0
  18. package/dist/blockchain/index.d.ts +48 -0
  19. package/dist/blockchain/index.d.ts.map +1 -0
  20. package/dist/blockchain/index.js +46 -0
  21. package/dist/blockchain/types.d.ts +63 -0
  22. package/dist/blockchain/types.d.ts.map +1 -0
  23. package/dist/blockchain/types.js +6 -0
  24. package/dist/chains/arbitrum.d.ts +89 -0
  25. package/dist/chains/arbitrum.d.ts.map +1 -0
  26. package/dist/chains/arbitrum.js +134 -0
  27. package/dist/chains/base.d.ts +84 -0
  28. package/dist/chains/base.d.ts.map +1 -0
  29. package/dist/chains/base.js +131 -0
  30. package/dist/chains/index.d.ts +36 -0
  31. package/dist/chains/index.d.ts.map +1 -0
  32. package/dist/chains/index.js +32 -0
  33. package/dist/chains/registry.d.ts +113 -0
  34. package/dist/chains/registry.d.ts.map +1 -0
  35. package/dist/chains/registry.js +201 -0
  36. package/dist/chains/varityL3.d.ts +81 -0
  37. package/dist/chains/varityL3.d.ts.map +1 -0
  38. package/dist/chains/varityL3.js +125 -0
  39. package/dist/cli/commands/clone.d.ts +8 -0
  40. package/dist/cli/commands/clone.d.ts.map +1 -0
  41. package/dist/cli/commands/clone.js +391 -0
  42. package/dist/cli/commands/dev.d.ts +8 -0
  43. package/dist/cli/commands/dev.d.ts.map +1 -0
  44. package/dist/cli/commands/dev.js +40 -0
  45. package/dist/cli/commands/generate.d.ts +8 -0
  46. package/dist/cli/commands/generate.d.ts.map +1 -0
  47. package/dist/cli/commands/generate.js +303 -0
  48. package/dist/cli/commands/init.d.ts +8 -0
  49. package/dist/cli/commands/init.d.ts.map +1 -0
  50. package/dist/cli/commands/init.js +317 -0
  51. package/dist/cli/commands/validate.d.ts +8 -0
  52. package/dist/cli/commands/validate.d.ts.map +1 -0
  53. package/dist/cli/commands/validate.js +69 -0
  54. package/dist/cli/index.d.ts +8 -0
  55. package/dist/cli/index.d.ts.map +1 -0
  56. package/dist/cli/index.js +33 -0
  57. package/dist/cli/utils/logger.d.ts +17 -0
  58. package/dist/cli/utils/logger.d.ts.map +1 -0
  59. package/dist/cli/utils/logger.js +35 -0
  60. package/dist/cli/utils/prompts.d.ts +21 -0
  61. package/dist/cli/utils/prompts.d.ts.map +1 -0
  62. package/dist/cli/utils/prompts.js +103 -0
  63. package/dist/contracts/abis/iso/AccessControlRegistry.json +1468 -0
  64. package/dist/contracts/abis/iso/DataProofRegistry.json +797 -0
  65. package/dist/contracts/abis/iso/MerchantRegistry.json +1237 -0
  66. package/dist/contracts/abis/iso/RepPerformance.json +1351 -0
  67. package/dist/contracts/abis/iso/ResidualCalculator.json +1118 -0
  68. package/dist/contracts/abis/iso/TransactionVault.json +1588 -0
  69. package/dist/contracts/abis/iso/VarityWalletFactory.json +475 -0
  70. package/dist/contracts/addresses.d.ts +88 -0
  71. package/dist/contracts/addresses.d.ts.map +1 -0
  72. package/dist/contracts/addresses.js +94 -0
  73. package/dist/contracts/index.d.ts +7 -0
  74. package/dist/contracts/index.d.ts.map +1 -0
  75. package/dist/contracts/index.js +6 -0
  76. package/dist/core/VaritySDK.d.ts +177 -0
  77. package/dist/core/VaritySDK.d.ts.map +1 -0
  78. package/dist/core/VaritySDK.js +325 -0
  79. package/dist/core/config.d.ts +120 -0
  80. package/dist/core/config.d.ts.map +1 -0
  81. package/dist/core/config.js +187 -0
  82. package/dist/core/credentials-proxy.d.ts +157 -0
  83. package/dist/core/credentials-proxy.d.ts.map +1 -0
  84. package/dist/core/credentials-proxy.js +345 -0
  85. package/dist/core/credentials.d.ts +219 -0
  86. package/dist/core/credentials.d.ts.map +1 -0
  87. package/dist/core/credentials.js +345 -0
  88. package/dist/core/template-loader.d.ts +15 -0
  89. package/dist/core/template-loader.d.ts.map +1 -0
  90. package/dist/core/template-loader.js +380 -0
  91. package/dist/core/template.d.ts +321 -0
  92. package/dist/core/template.d.ts.map +1 -0
  93. package/dist/core/template.js +189 -0
  94. package/dist/core/types.d.ts +572 -0
  95. package/dist/core/types.d.ts.map +1 -0
  96. package/dist/core/types.js +52 -0
  97. package/dist/dev/dev-server.d.ts +16 -0
  98. package/dist/dev/dev-server.d.ts.map +1 -0
  99. package/dist/dev/dev-server.js +119 -0
  100. package/dist/generators/contracts/generator.d.ts +21 -0
  101. package/dist/generators/contracts/generator.d.ts.map +1 -0
  102. package/dist/generators/contracts/generator.js +252 -0
  103. package/dist/generators/tests/generator.d.ts +20 -0
  104. package/dist/generators/tests/generator.d.ts.map +1 -0
  105. package/dist/generators/tests/generator.js +375 -0
  106. package/dist/generators/types/generator.d.ts +19 -0
  107. package/dist/generators/types/generator.d.ts.map +1 -0
  108. package/dist/generators/types/generator.js +165 -0
  109. package/dist/generators/ui/component-generator.d.ts +20 -0
  110. package/dist/generators/ui/component-generator.d.ts.map +1 -0
  111. package/dist/generators/ui/component-generator.js +749 -0
  112. package/dist/generators/ui/dashboard-generator.d.ts +20 -0
  113. package/dist/generators/ui/dashboard-generator.d.ts.map +1 -0
  114. package/dist/generators/ui/dashboard-generator.js +349 -0
  115. package/dist/index.d.ts +61 -0
  116. package/dist/index.d.ts.map +1 -0
  117. package/dist/index.js +74 -0
  118. package/dist/modules/analytics/AnalyticsModule.d.ts +349 -0
  119. package/dist/modules/analytics/AnalyticsModule.d.ts.map +1 -0
  120. package/dist/modules/analytics/AnalyticsModule.js +274 -0
  121. package/dist/modules/analytics/index.d.ts +3 -0
  122. package/dist/modules/analytics/index.d.ts.map +1 -0
  123. package/dist/modules/analytics/index.js +1 -0
  124. package/dist/modules/auth/AccessKeyModule.d.ts +189 -0
  125. package/dist/modules/auth/AccessKeyModule.d.ts.map +1 -0
  126. package/dist/modules/auth/AccessKeyModule.js +322 -0
  127. package/dist/modules/auth/AuthModule.d.ts +133 -0
  128. package/dist/modules/auth/AuthModule.d.ts.map +1 -0
  129. package/dist/modules/auth/AuthModule.js +214 -0
  130. package/dist/modules/auth/index.d.ts +8 -0
  131. package/dist/modules/auth/index.d.ts.map +1 -0
  132. package/dist/modules/auth/index.js +6 -0
  133. package/dist/modules/cache/CacheModule.d.ts +279 -0
  134. package/dist/modules/cache/CacheModule.d.ts.map +1 -0
  135. package/dist/modules/cache/CacheModule.js +493 -0
  136. package/dist/modules/cache/index.d.ts +3 -0
  137. package/dist/modules/cache/index.d.ts.map +1 -0
  138. package/dist/modules/cache/index.js +1 -0
  139. package/dist/modules/compute/ComputeModule.d.ts +226 -0
  140. package/dist/modules/compute/ComputeModule.d.ts.map +1 -0
  141. package/dist/modules/compute/ComputeModule.js +379 -0
  142. package/dist/modules/compute/index.d.ts +6 -0
  143. package/dist/modules/compute/index.d.ts.map +1 -0
  144. package/dist/modules/compute/index.js +4 -0
  145. package/dist/modules/contracts/ContractsModule.d.ts +164 -0
  146. package/dist/modules/contracts/ContractsModule.d.ts.map +1 -0
  147. package/dist/modules/contracts/ContractsModule.js +242 -0
  148. package/dist/modules/contracts/index.d.ts +6 -0
  149. package/dist/modules/contracts/index.d.ts.map +1 -0
  150. package/dist/modules/contracts/index.js +4 -0
  151. package/dist/modules/export/ExportModule.d.ts +346 -0
  152. package/dist/modules/export/ExportModule.d.ts.map +1 -0
  153. package/dist/modules/export/ExportModule.js +432 -0
  154. package/dist/modules/export/index.d.ts +3 -0
  155. package/dist/modules/export/index.d.ts.map +1 -0
  156. package/dist/modules/export/index.js +1 -0
  157. package/dist/modules/forecasting/ForecastingModule.d.ts +579 -0
  158. package/dist/modules/forecasting/ForecastingModule.d.ts.map +1 -0
  159. package/dist/modules/forecasting/ForecastingModule.js +310 -0
  160. package/dist/modules/forecasting/index.d.ts +3 -0
  161. package/dist/modules/forecasting/index.d.ts.map +1 -0
  162. package/dist/modules/forecasting/index.js +1 -0
  163. package/dist/modules/monitoring/MonitoringModule.d.ts +359 -0
  164. package/dist/modules/monitoring/MonitoringModule.d.ts.map +1 -0
  165. package/dist/modules/monitoring/MonitoringModule.js +483 -0
  166. package/dist/modules/monitoring/index.d.ts +3 -0
  167. package/dist/modules/monitoring/index.d.ts.map +1 -0
  168. package/dist/modules/monitoring/index.js +1 -0
  169. package/dist/modules/notifications/NotificationsModule.d.ts +336 -0
  170. package/dist/modules/notifications/NotificationsModule.d.ts.map +1 -0
  171. package/dist/modules/notifications/NotificationsModule.js +418 -0
  172. package/dist/modules/notifications/index.d.ts +3 -0
  173. package/dist/modules/notifications/index.d.ts.map +1 -0
  174. package/dist/modules/notifications/index.js +1 -0
  175. package/dist/modules/oracle/OracleModule.d.ts +110 -0
  176. package/dist/modules/oracle/OracleModule.d.ts.map +1 -0
  177. package/dist/modules/oracle/OracleModule.js +151 -0
  178. package/dist/modules/oracle/index.d.ts +6 -0
  179. package/dist/modules/oracle/index.d.ts.map +1 -0
  180. package/dist/modules/oracle/index.js +4 -0
  181. package/dist/modules/storage/S3Module.d.ts +377 -0
  182. package/dist/modules/storage/S3Module.d.ts.map +1 -0
  183. package/dist/modules/storage/S3Module.js +680 -0
  184. package/dist/modules/storage/StorageModule.d.ts +157 -0
  185. package/dist/modules/storage/StorageModule.d.ts.map +1 -0
  186. package/dist/modules/storage/StorageModule.js +302 -0
  187. package/dist/modules/storage/adapters/AdapterFactory.d.ts +100 -0
  188. package/dist/modules/storage/adapters/AdapterFactory.d.ts.map +1 -0
  189. package/dist/modules/storage/adapters/AdapterFactory.js +209 -0
  190. package/dist/modules/storage/adapters/FilecoinAdapter.d.ts +94 -0
  191. package/dist/modules/storage/adapters/FilecoinAdapter.d.ts.map +1 -0
  192. package/dist/modules/storage/adapters/FilecoinAdapter.js +263 -0
  193. package/dist/modules/storage/adapters/IStorageAdapter.d.ts +287 -0
  194. package/dist/modules/storage/adapters/IStorageAdapter.d.ts.map +1 -0
  195. package/dist/modules/storage/adapters/IStorageAdapter.js +81 -0
  196. package/dist/modules/storage/adapters/MultiTierAdapter.d.ts +187 -0
  197. package/dist/modules/storage/adapters/MultiTierAdapter.d.ts.map +1 -0
  198. package/dist/modules/storage/adapters/MultiTierAdapter.js +430 -0
  199. package/dist/modules/storage/adapters/index.d.ts +12 -0
  200. package/dist/modules/storage/adapters/index.d.ts.map +1 -0
  201. package/dist/modules/storage/adapters/index.js +12 -0
  202. package/dist/modules/storage/index.d.ts +16 -0
  203. package/dist/modules/storage/index.d.ts.map +1 -0
  204. package/dist/modules/storage/index.js +15 -0
  205. package/dist/modules/storage/tiering/AccessAnalyzer.d.ts +227 -0
  206. package/dist/modules/storage/tiering/AccessAnalyzer.d.ts.map +1 -0
  207. package/dist/modules/storage/tiering/AccessAnalyzer.js +367 -0
  208. package/dist/modules/storage/tiering/CostOptimizer.d.ts +248 -0
  209. package/dist/modules/storage/tiering/CostOptimizer.d.ts.map +1 -0
  210. package/dist/modules/storage/tiering/CostOptimizer.js +356 -0
  211. package/dist/modules/storage/tiering/MetadataStore.d.ts +287 -0
  212. package/dist/modules/storage/tiering/MetadataStore.d.ts.map +1 -0
  213. package/dist/modules/storage/tiering/MetadataStore.js +535 -0
  214. package/dist/modules/storage/tiering/TieringEngine.d.ts +237 -0
  215. package/dist/modules/storage/tiering/TieringEngine.d.ts.map +1 -0
  216. package/dist/modules/storage/tiering/TieringEngine.js +419 -0
  217. package/dist/modules/storage/tiering/example.d.ts +8 -0
  218. package/dist/modules/storage/tiering/example.d.ts.map +1 -0
  219. package/dist/modules/storage/tiering/example.js +250 -0
  220. package/dist/modules/storage/tiering/index.d.ts +17 -0
  221. package/dist/modules/storage/tiering/index.d.ts.map +1 -0
  222. package/dist/modules/storage/tiering/index.js +13 -0
  223. package/dist/modules/webhooks/WebhooksModule.d.ts +476 -0
  224. package/dist/modules/webhooks/WebhooksModule.d.ts.map +1 -0
  225. package/dist/modules/webhooks/WebhooksModule.js +359 -0
  226. package/dist/modules/webhooks/index.d.ts +3 -0
  227. package/dist/modules/webhooks/index.d.ts.map +1 -0
  228. package/dist/modules/webhooks/index.js +1 -0
  229. package/dist/modules/zk/ZKModule.d.ts +153 -0
  230. package/dist/modules/zk/ZKModule.d.ts.map +1 -0
  231. package/dist/modules/zk/ZKModule.js +262 -0
  232. package/dist/modules/zk/index.d.ts +7 -0
  233. package/dist/modules/zk/index.d.ts.map +1 -0
  234. package/dist/modules/zk/index.js +4 -0
  235. package/dist/thirdweb/BridgeClient.d.ts +228 -0
  236. package/dist/thirdweb/BridgeClient.d.ts.map +1 -0
  237. package/dist/thirdweb/BridgeClient.js +160 -0
  238. package/dist/thirdweb/EngineClient.d.ts +396 -0
  239. package/dist/thirdweb/EngineClient.d.ts.map +1 -0
  240. package/dist/thirdweb/EngineClient.js +386 -0
  241. package/dist/thirdweb/GatewayClient.d.ts +190 -0
  242. package/dist/thirdweb/GatewayClient.d.ts.map +1 -0
  243. package/dist/thirdweb/GatewayClient.js +257 -0
  244. package/dist/thirdweb/NebulaClient.d.ts +292 -0
  245. package/dist/thirdweb/NebulaClient.d.ts.map +1 -0
  246. package/dist/thirdweb/NebulaClient.js +180 -0
  247. package/dist/thirdweb/StorageClient.d.ts +445 -0
  248. package/dist/thirdweb/StorageClient.d.ts.map +1 -0
  249. package/dist/thirdweb/StorageClient.js +405 -0
  250. package/dist/thirdweb/ThirdwebWrapper.d.ts +236 -0
  251. package/dist/thirdweb/ThirdwebWrapper.d.ts.map +1 -0
  252. package/dist/thirdweb/ThirdwebWrapper.js +332 -0
  253. package/dist/thirdweb/index.d.ts +21 -0
  254. package/dist/thirdweb/index.d.ts.map +1 -0
  255. package/dist/thirdweb/index.js +28 -0
  256. package/dist/thirdweb/varity-chain.d.ts +48 -0
  257. package/dist/thirdweb/varity-chain.d.ts.map +1 -0
  258. package/dist/thirdweb/varity-chain.js +64 -0
  259. package/dist/thirdweb/x402Client.d.ts +319 -0
  260. package/dist/thirdweb/x402Client.d.ts.map +1 -0
  261. package/dist/thirdweb/x402Client.js +223 -0
  262. package/dist/tracking/gasTracker.d.ts +158 -0
  263. package/dist/tracking/gasTracker.d.ts.map +1 -0
  264. package/dist/tracking/gasTracker.js +227 -0
  265. package/dist/tracking/index.d.ts +10 -0
  266. package/dist/tracking/index.d.ts.map +1 -0
  267. package/dist/tracking/index.js +8 -0
  268. package/dist/tracking/types.d.ts +327 -0
  269. package/dist/tracking/types.d.ts.map +1 -0
  270. package/dist/tracking/types.js +8 -0
  271. package/dist/ui/components/ChartWidget.d.ts +36 -0
  272. package/dist/ui/components/ChartWidget.d.ts.map +1 -0
  273. package/dist/ui/components/ChartWidget.js +82 -0
  274. package/dist/ui/components/DashboardLayout.d.ts +41 -0
  275. package/dist/ui/components/DashboardLayout.d.ts.map +1 -0
  276. package/dist/ui/components/DashboardLayout.js +102 -0
  277. package/dist/ui/components/DataTable.d.ts +49 -0
  278. package/dist/ui/components/DataTable.d.ts.map +1 -0
  279. package/dist/ui/components/DataTable.js +96 -0
  280. package/dist/ui/components/EntityForm.d.ts +60 -0
  281. package/dist/ui/components/EntityForm.d.ts.map +1 -0
  282. package/dist/ui/components/EntityForm.js +182 -0
  283. package/dist/ui/components/KPICard.d.ts +29 -0
  284. package/dist/ui/components/KPICard.d.ts.map +1 -0
  285. package/dist/ui/components/KPICard.js +61 -0
  286. package/dist/ui/components/Modal.d.ts +34 -0
  287. package/dist/ui/components/Modal.d.ts.map +1 -0
  288. package/dist/ui/components/Modal.js +30 -0
  289. package/dist/ui/components/index.d.ts +18 -0
  290. package/dist/ui/components/index.d.ts.map +1 -0
  291. package/dist/ui/components/index.js +11 -0
  292. package/dist/validation/template-validator.d.ts +25 -0
  293. package/dist/validation/template-validator.d.ts.map +1 -0
  294. package/dist/validation/template-validator.js +305 -0
  295. package/package.json +102 -0
@@ -0,0 +1,303 @@
1
+ /**
2
+ * varity generate - Code generation commands
3
+ *
4
+ * Generate contracts, types, tests, and deployment scripts
5
+ */
6
+ import { Command } from 'commander';
7
+ import * as path from 'path';
8
+ import { Logger } from '../utils/logger';
9
+ import { promptGenerateContracts } from '../utils/prompts';
10
+ import { generateContracts } from '../../generators/contracts/generator';
11
+ import { generateTypes } from '../../generators/types/generator';
12
+ import { generateTests } from '../../generators/tests/generator';
13
+ import { generateUIComponents } from '../../generators/ui/component-generator';
14
+ import { generateDashboards } from '../../generators/ui/dashboard-generator';
15
+ /**
16
+ * varity generate contracts
17
+ */
18
+ const generateContractsCommand = new Command('contracts')
19
+ .description('Generate Solidity smart contracts from template configuration')
20
+ .option('-t, --template <path>', 'Path to template JSON file')
21
+ .option('-o, --output <path>', 'Output directory for contracts')
22
+ .option('--no-tests', 'Skip generating test files')
23
+ .action(async (options) => {
24
+ try {
25
+ Logger.header('🔨 Generate Smart Contracts');
26
+ // Get options from prompts if not provided
27
+ let templatePath = options.template;
28
+ let outputPath = options.output;
29
+ let includeTests = options.tests !== false;
30
+ if (!templatePath || !outputPath) {
31
+ const answers = await promptGenerateContracts();
32
+ templatePath = templatePath || answers.templatePath;
33
+ outputPath = outputPath || answers.outputPath;
34
+ if (options.tests === undefined) {
35
+ includeTests = answers.includeTests;
36
+ }
37
+ }
38
+ // Resolve paths
39
+ templatePath = path.resolve(templatePath);
40
+ outputPath = path.resolve(outputPath);
41
+ Logger.step(1, 3, `Loading template configuration from ${templatePath}...`);
42
+ // Generate contracts
43
+ Logger.step(2, 3, 'Generating smart contracts...');
44
+ const result = await generateContracts({
45
+ templatePath,
46
+ outputPath,
47
+ includeTests
48
+ });
49
+ Logger.step(3, 3, 'Finalizing...');
50
+ // Display results
51
+ Logger.newline();
52
+ if (result.success) {
53
+ Logger.success('Smart contracts generated successfully!');
54
+ Logger.newline();
55
+ if (result.contracts.length > 0) {
56
+ Logger.info('Generated contracts:');
57
+ result.contracts.forEach(contract => {
58
+ Logger.code(` ✓ ${contract}`);
59
+ });
60
+ Logger.newline();
61
+ }
62
+ if (result.tests.length > 0) {
63
+ Logger.info('Generated tests:');
64
+ result.tests.forEach(test => {
65
+ Logger.code(` ✓ ${test}`);
66
+ });
67
+ Logger.newline();
68
+ }
69
+ Logger.info('Next steps:');
70
+ Logger.code(' 1. Review generated contracts');
71
+ Logger.code(' 2. Compile with: npx hardhat compile');
72
+ Logger.code(' 3. Run tests with: npx hardhat test');
73
+ Logger.code(' 4. Deploy with: varity generate scripts');
74
+ Logger.newline();
75
+ }
76
+ else {
77
+ Logger.error('Failed to generate contracts');
78
+ Logger.newline();
79
+ result.errors.forEach(error => {
80
+ Logger.error(error);
81
+ });
82
+ process.exit(1);
83
+ }
84
+ }
85
+ catch (error) {
86
+ Logger.error(`Failed to generate contracts: ${error instanceof Error ? error.message : 'Unknown error'}`);
87
+ process.exit(1);
88
+ }
89
+ });
90
+ /**
91
+ * varity generate types
92
+ */
93
+ const generateTypesCommand = new Command('types')
94
+ .description('Generate TypeScript types from contract ABIs')
95
+ .option('-a, --abi-dir <path>', 'Directory containing contract ABIs', './contracts/abis')
96
+ .option('-o, --output <path>', 'Output directory for TypeScript types', './src/types')
97
+ .action(async (options) => {
98
+ try {
99
+ Logger.header('📝 Generate TypeScript Types');
100
+ const abiDir = path.resolve(options.abiDir);
101
+ const outputPath = path.resolve(options.output);
102
+ Logger.step(1, 2, `Loading ABIs from ${abiDir}...`);
103
+ // Generate types
104
+ Logger.step(2, 2, 'Generating TypeScript types...');
105
+ const result = await generateTypes({
106
+ abiDir,
107
+ outputPath
108
+ });
109
+ // Display results
110
+ Logger.newline();
111
+ if (result.success) {
112
+ Logger.success('TypeScript types generated successfully!');
113
+ Logger.newline();
114
+ if (result.types.length > 0) {
115
+ Logger.info('Generated type files:');
116
+ result.types.forEach(typeFile => {
117
+ Logger.code(` ✓ ${typeFile}`);
118
+ });
119
+ Logger.newline();
120
+ }
121
+ Logger.info('Next steps:');
122
+ Logger.code(' 1. Import types in your TypeScript code');
123
+ Logger.code(' 2. Use with ethers.js: const contract: MyContract = ...');
124
+ Logger.newline();
125
+ }
126
+ else {
127
+ Logger.error('Failed to generate types');
128
+ Logger.newline();
129
+ result.errors.forEach(error => {
130
+ Logger.error(error);
131
+ });
132
+ process.exit(1);
133
+ }
134
+ }
135
+ catch (error) {
136
+ Logger.error(`Failed to generate types: ${error instanceof Error ? error.message : 'Unknown error'}`);
137
+ process.exit(1);
138
+ }
139
+ });
140
+ /**
141
+ * varity generate tests
142
+ */
143
+ const generateTestsCommand = new Command('tests')
144
+ .description('Generate comprehensive test suites for contracts')
145
+ .option('-t, --template <path>', 'Path to template JSON file')
146
+ .option('-c, --contracts <path>', 'Directory containing contracts', './contracts')
147
+ .option('-o, --output <path>', 'Output directory for tests', './test')
148
+ .action(async (options) => {
149
+ try {
150
+ Logger.header('🧪 Generate Test Suites');
151
+ const templatePath = path.resolve(options.template || './templates/template.json');
152
+ const contractsPath = path.resolve(options.contracts);
153
+ const outputPath = path.resolve(options.output);
154
+ Logger.step(1, 3, `Loading template from ${templatePath}...`);
155
+ // Generate tests
156
+ Logger.step(2, 3, 'Generating test suites...');
157
+ const result = await generateTests({
158
+ templatePath,
159
+ contractsPath,
160
+ outputPath
161
+ });
162
+ Logger.step(3, 3, 'Finalizing...');
163
+ // Display results
164
+ Logger.newline();
165
+ if (result.success) {
166
+ Logger.success('Test suites generated successfully!');
167
+ Logger.newline();
168
+ if (result.tests.length > 0) {
169
+ Logger.info('Generated test files:');
170
+ result.tests.forEach(test => {
171
+ Logger.code(` ✓ ${test}`);
172
+ });
173
+ Logger.newline();
174
+ }
175
+ Logger.info('Next steps:');
176
+ Logger.code(' 1. Review generated tests');
177
+ Logger.code(' 2. Add custom test cases as needed');
178
+ Logger.code(' 3. Run with: npx hardhat test');
179
+ Logger.newline();
180
+ }
181
+ else {
182
+ Logger.error('Failed to generate tests');
183
+ Logger.newline();
184
+ result.errors.forEach(error => {
185
+ Logger.error(error);
186
+ });
187
+ process.exit(1);
188
+ }
189
+ }
190
+ catch (error) {
191
+ Logger.error(`Failed to generate tests: ${error instanceof Error ? error.message : 'Unknown error'}`);
192
+ process.exit(1);
193
+ }
194
+ });
195
+ /**
196
+ * varity generate ui
197
+ */
198
+ const generateUICommand = new Command('ui')
199
+ .description('Generate React UI components from template entities')
200
+ .option('-t, --template <path>', 'Path to template JSON file', './templates/template.json')
201
+ .option('-o, --output <path>', 'Output directory for UI components', '.')
202
+ .action(async (options) => {
203
+ try {
204
+ Logger.header('🎨 Generate UI Components');
205
+ const templatePath = path.resolve(options.template);
206
+ const outputPath = path.resolve(options.output);
207
+ Logger.step(1, 2, `Loading template configuration from ${templatePath}...`);
208
+ // Generate UI components
209
+ Logger.step(2, 2, 'Generating React components...');
210
+ const result = await generateUIComponents({
211
+ templatePath,
212
+ outputPath
213
+ });
214
+ // Display results
215
+ Logger.newline();
216
+ if (result.success) {
217
+ Logger.success('UI components generated successfully!');
218
+ Logger.newline();
219
+ if (result.components.length > 0) {
220
+ Logger.info('Generated components:');
221
+ result.components.forEach(component => {
222
+ Logger.code(` ✓ ${component}`);
223
+ });
224
+ Logger.newline();
225
+ }
226
+ Logger.info('Next steps:');
227
+ Logger.code(' 1. Review generated components');
228
+ Logger.code(' 2. Import components in your app');
229
+ Logger.code(' 3. Customize styling as needed');
230
+ Logger.newline();
231
+ }
232
+ else {
233
+ Logger.error('Failed to generate UI components');
234
+ Logger.newline();
235
+ result.errors.forEach(error => {
236
+ Logger.error(error);
237
+ });
238
+ process.exit(1);
239
+ }
240
+ }
241
+ catch (error) {
242
+ Logger.error(`Failed to generate UI: ${error instanceof Error ? error.message : 'Unknown error'}`);
243
+ process.exit(1);
244
+ }
245
+ });
246
+ /**
247
+ * varity generate dashboard
248
+ */
249
+ const generateDashboardCommand = new Command('dashboard')
250
+ .description('Generate dashboard layouts from template configuration')
251
+ .option('-t, --template <path>', 'Path to template JSON file', './templates/template.json')
252
+ .option('-o, --output <path>', 'Output directory for dashboards', '.')
253
+ .action(async (options) => {
254
+ try {
255
+ Logger.header('📊 Generate Dashboard Layouts');
256
+ const templatePath = path.resolve(options.template);
257
+ const outputPath = path.resolve(options.output);
258
+ Logger.step(1, 2, `Loading template configuration from ${templatePath}...`);
259
+ // Generate dashboards
260
+ Logger.step(2, 2, 'Generating dashboard layouts...');
261
+ const result = await generateDashboards({
262
+ templatePath,
263
+ outputPath
264
+ });
265
+ // Display results
266
+ Logger.newline();
267
+ if (result.success) {
268
+ Logger.success('Dashboard layouts generated successfully!');
269
+ Logger.newline();
270
+ if (result.dashboards.length > 0) {
271
+ Logger.info('Generated dashboards:');
272
+ result.dashboards.forEach(dashboard => {
273
+ Logger.code(` ✓ ${dashboard}`);
274
+ });
275
+ Logger.newline();
276
+ }
277
+ Logger.info('Next steps:');
278
+ Logger.code(' 1. Review generated dashboards');
279
+ Logger.code(' 2. Import dashboards in your app routing');
280
+ Logger.code(' 3. Customize widgets as needed');
281
+ Logger.newline();
282
+ }
283
+ else {
284
+ Logger.error('Failed to generate dashboards');
285
+ Logger.newline();
286
+ result.errors.forEach(error => {
287
+ Logger.error(error);
288
+ });
289
+ process.exit(1);
290
+ }
291
+ }
292
+ catch (error) {
293
+ Logger.error(`Failed to generate dashboards: ${error instanceof Error ? error.message : 'Unknown error'}`);
294
+ process.exit(1);
295
+ }
296
+ });
297
+ export const generateCommand = new Command('generate')
298
+ .description('Generate contracts, types, tests, UI components, dashboards, and deployment scripts')
299
+ .addCommand(generateContractsCommand)
300
+ .addCommand(generateTypesCommand)
301
+ .addCommand(generateTestsCommand)
302
+ .addCommand(generateUICommand)
303
+ .addCommand(generateDashboardCommand);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * varity init - Initialize new template project
3
+ *
4
+ * Creates a new template project with all necessary files
5
+ */
6
+ import { Command } from 'commander';
7
+ export declare const initCommand: Command;
8
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAOnC,eAAO,MAAM,WAAW,SAwEpB,CAAA"}
@@ -0,0 +1,317 @@
1
+ /**
2
+ * varity init - Initialize new template project
3
+ *
4
+ * Creates a new template project with all necessary files
5
+ */
6
+ import { Command } from 'commander';
7
+ import * as fs from 'fs';
8
+ import * as path from 'path';
9
+ import { Logger } from '../utils/logger';
10
+ import { promptInit } from '../utils/prompts';
11
+ export const initCommand = new Command('init')
12
+ .description('Initialize a new template project')
13
+ .option('-n, --name <name>', 'Template name')
14
+ .option('-d, --dir <directory>', 'Output directory', '.')
15
+ .action(async (options) => {
16
+ try {
17
+ Logger.header('🚀 Initialize New Varity Template Project');
18
+ // Get template configuration from prompts
19
+ const answers = await promptInit();
20
+ // Parse entities
21
+ const entities = answers.entities
22
+ .split(',')
23
+ .map(e => e.trim())
24
+ .filter(e => e.length > 0);
25
+ // Parse contracts (or auto-generate from entities)
26
+ let contracts;
27
+ if (answers.contracts && answers.contracts.trim().length > 0) {
28
+ contracts = answers.contracts
29
+ .split(',')
30
+ .map(c => c.trim())
31
+ .filter(c => c.length > 0);
32
+ }
33
+ else {
34
+ // Auto-generate contract names from entities
35
+ contracts = entities.map(entity => {
36
+ const capitalized = entity.charAt(0).toUpperCase() + entity.slice(1);
37
+ return `${capitalized}Registry`;
38
+ });
39
+ }
40
+ // Create output directory
41
+ const outputDir = path.join(options.dir, answers.templateName);
42
+ if (fs.existsSync(outputDir)) {
43
+ Logger.error(`Directory ${outputDir} already exists`);
44
+ process.exit(1);
45
+ }
46
+ Logger.step(1, 5, 'Creating project structure...');
47
+ createProjectStructure(outputDir);
48
+ Logger.step(2, 5, 'Generating template configuration...');
49
+ const template = generateTemplateConfig(answers, entities, contracts);
50
+ fs.writeFileSync(path.join(outputDir, 'templates', `${answers.templateName}.template.json`), JSON.stringify(template, null, 2));
51
+ Logger.step(3, 5, 'Creating environment configuration...');
52
+ generateEnvFile(outputDir, answers);
53
+ Logger.step(4, 5, 'Generating package.json...');
54
+ generatePackageJson(outputDir, answers);
55
+ Logger.step(5, 5, 'Creating README.md...');
56
+ generateReadme(outputDir, answers, entities);
57
+ Logger.newline();
58
+ Logger.success('Template project initialized successfully!');
59
+ Logger.newline();
60
+ Logger.info('Next steps:');
61
+ Logger.code(` cd ${answers.templateName}`);
62
+ Logger.code(` npm install`);
63
+ Logger.code(` npx varity generate contracts`);
64
+ Logger.code(` npx varity dev --watch`);
65
+ Logger.newline();
66
+ }
67
+ catch (error) {
68
+ Logger.error(`Failed to initialize project: ${error instanceof Error ? error.message : 'Unknown error'}`);
69
+ process.exit(1);
70
+ }
71
+ });
72
+ function createProjectStructure(baseDir) {
73
+ const dirs = [
74
+ baseDir,
75
+ path.join(baseDir, 'contracts'),
76
+ path.join(baseDir, 'contracts', 'abis'),
77
+ path.join(baseDir, 'templates'),
78
+ path.join(baseDir, 'scripts'),
79
+ path.join(baseDir, 'test'),
80
+ path.join(baseDir, 'frontend'),
81
+ path.join(baseDir, 'frontend', 'src')
82
+ ];
83
+ dirs.forEach(dir => {
84
+ if (!fs.existsSync(dir)) {
85
+ fs.mkdirSync(dir, { recursive: true });
86
+ }
87
+ });
88
+ // Create .gitignore
89
+ const gitignore = `
90
+ node_modules
91
+ .env
92
+ .env.local
93
+ dist
94
+ build
95
+ *.log
96
+ .DS_Store
97
+ deployments
98
+ `.trim();
99
+ fs.writeFileSync(path.join(baseDir, '.gitignore'), gitignore);
100
+ }
101
+ function generateTemplateConfig(answers, entities, contracts) {
102
+ return {
103
+ type: answers.templateName,
104
+ name: `${answers.templateName.charAt(0).toUpperCase() + answers.templateName.slice(1)} Business Template`,
105
+ version: '1.0.0',
106
+ description: answers.description,
107
+ contracts: contracts.map((contractName, idx) => ({
108
+ name: contractName,
109
+ description: `${entities[idx]} management contract`,
110
+ abi: `../../contracts/abis/${answers.templateName}/${contractName}.json`,
111
+ addresses: {
112
+ 'arbitrum-sepolia': '',
113
+ 'arbitrum-l3-testnet': '',
114
+ 'arbitrum-l3-mainnet': ''
115
+ },
116
+ required: true
117
+ })),
118
+ entities: entities.map(entity => ({
119
+ name: entity,
120
+ displayName: entity.charAt(0).toUpperCase() + entity.slice(1),
121
+ description: `${entity.charAt(0).toUpperCase() + entity.slice(1)} entity`,
122
+ idField: `${entity}Id`,
123
+ displayField: `${entity}Name`,
124
+ fields: [
125
+ {
126
+ name: `${entity}Id`,
127
+ label: `${entity.charAt(0).toUpperCase() + entity.slice(1)} ID`,
128
+ type: 'string',
129
+ description: `Unique ${entity} identifier`,
130
+ required: true
131
+ },
132
+ {
133
+ name: `${entity}Name`,
134
+ label: `${entity.charAt(0).toUpperCase() + entity.slice(1)} Name`,
135
+ type: 'string',
136
+ description: `${entity.charAt(0).toUpperCase() + entity.slice(1)} name`,
137
+ required: true
138
+ },
139
+ {
140
+ name: 'createdAt',
141
+ label: 'Created At',
142
+ type: 'number',
143
+ description: 'Creation timestamp',
144
+ required: true
145
+ },
146
+ {
147
+ name: 'isActive',
148
+ label: 'Is Active',
149
+ type: 'boolean',
150
+ description: 'Active status',
151
+ required: true
152
+ }
153
+ ]
154
+ })),
155
+ events: [
156
+ {
157
+ name: `${entities[0]}_created`,
158
+ displayName: `${entities[0].charAt(0).toUpperCase() + entities[0].slice(1)} Created`,
159
+ description: `New ${entities[0]} created`,
160
+ category: 'entity'
161
+ }
162
+ ],
163
+ metrics: [
164
+ {
165
+ name: `total_${entities[0]}s`,
166
+ displayName: `Total ${entities[0].charAt(0).toUpperCase() + entities[0].slice(1)}s`,
167
+ description: `Total number of ${entities[0]}s`,
168
+ type: 'count',
169
+ source: 'contract'
170
+ }
171
+ ],
172
+ storage: {
173
+ varityNamespace: `varity-internal-${answers.templateName}`,
174
+ industryNamespace: `industry-${answers.templateName}-rag`,
175
+ customerNamespacePattern: `customer-${answers.templateName}-{company-id}-{data-type}`,
176
+ encryptionEnabled: true,
177
+ litProtocolEnabled: true,
178
+ celestiaDAEnabled: true,
179
+ zkProofsEnabled: true
180
+ },
181
+ api: {
182
+ basePath: `/api/v1/${answers.templateName}`
183
+ },
184
+ features: {
185
+ analytics: true,
186
+ forecasting: true,
187
+ notifications: true,
188
+ export: true,
189
+ cache: true,
190
+ monitoring: true,
191
+ webhooks: true
192
+ }
193
+ };
194
+ }
195
+ function generateEnvFile(baseDir, answers) {
196
+ const envContent = `# Varity SDK Configuration
197
+
198
+ # Network
199
+ VARITY_NETWORK=${answers.network}
200
+
201
+ # API Configuration
202
+ VARITY_API_KEY=
203
+ VARITY_API_ENDPOINT=https://api.varity.io
204
+
205
+ # RPC URLs
206
+ ARBITRUM_SEPOLIA_RPC=https://sepolia-rollup.arbitrum.io/rpc
207
+ ARBITRUM_L3_TESTNET_RPC=
208
+ ARBITRUM_L3_MAINNET_RPC=
209
+
210
+ # Contract Addresses (populated after deployment)
211
+ # ${answers.network.toUpperCase().replace(/-/g, '_')} contracts
212
+ # Add your contract addresses here after deployment
213
+
214
+ # Storage Configuration
215
+ PINATA_API_KEY=
216
+ CELESTIA_TESTNET_RPC=https://rpc-mocha.pops.one
217
+
218
+ # Private Key (NEVER commit this!)
219
+ PRIVATE_KEY=
220
+ `;
221
+ fs.writeFileSync(path.join(baseDir, '.env.example'), envContent);
222
+ }
223
+ function generatePackageJson(baseDir, answers) {
224
+ const packageJson = {
225
+ name: `varity-${answers.templateName}-template`,
226
+ version: '1.0.0',
227
+ description: answers.description,
228
+ scripts: {
229
+ 'generate:contracts': 'varity generate contracts',
230
+ 'generate:types': 'varity generate types',
231
+ 'generate:tests': 'varity generate tests',
232
+ 'dev': 'varity dev --watch',
233
+ 'validate': 'varity validate',
234
+ 'test': 'hardhat test',
235
+ 'deploy:sepolia': 'hardhat run scripts/deploy.ts --network arbitrum-sepolia',
236
+ 'deploy:testnet': 'hardhat run scripts/deploy.ts --network arbitrum-l3-testnet',
237
+ 'deploy:mainnet': 'hardhat run scripts/deploy.ts --network arbitrum-l3-mainnet'
238
+ },
239
+ dependencies: {
240
+ '@varity-labs/sdk': '^2.0.0-beta.1',
241
+ 'ethers': '^6.9.0'
242
+ },
243
+ devDependencies: {
244
+ '@nomicfoundation/hardhat-toolbox': '^4.0.0',
245
+ 'hardhat': '^2.19.0',
246
+ 'typescript': '^5.0.0'
247
+ }
248
+ };
249
+ fs.writeFileSync(path.join(baseDir, 'package.json'), JSON.stringify(packageJson, null, 2));
250
+ }
251
+ function generateReadme(baseDir, answers, entities) {
252
+ const readme = `# ${answers.templateName.charAt(0).toUpperCase() + answers.templateName.slice(1)} Template
253
+
254
+ ${answers.description}
255
+
256
+ ## Quick Start
257
+
258
+ \`\`\`bash
259
+ # Install dependencies
260
+ npm install
261
+
262
+ # Generate smart contracts
263
+ npm run generate:contracts
264
+
265
+ # Start development mode (hot-reload)
266
+ npm run dev
267
+
268
+ # Validate template configuration
269
+ npm run validate
270
+ \`\`\`
271
+
272
+ ## Business Entities
273
+
274
+ ${entities.map(e => `- **${e.charAt(0).toUpperCase() + e.slice(1)}**: ${e} management`).join('\n')}
275
+
276
+ ## Smart Contracts
277
+
278
+ Contracts will be generated in \`contracts/\` directory when you run:
279
+
280
+ \`\`\`bash
281
+ npm run generate:contracts
282
+ \`\`\`
283
+
284
+ ## Testing
285
+
286
+ Deploy and test on Arbitrum Sepolia before production:
287
+
288
+ \`\`\`bash
289
+ # Deploy to testnet
290
+ npm run deploy:sepolia
291
+
292
+ # Run tests
293
+ npm test
294
+ \`\`\`
295
+
296
+ ## Production Deployment
297
+
298
+ When ready for production:
299
+
300
+ \`\`\`bash
301
+ # Deploy to mainnet
302
+ npm run deploy:mainnet
303
+ \`\`\`
304
+
305
+ ## Documentation
306
+
307
+ - [Varity SDK Documentation](https://docs.varity.com)
308
+ - [Template Guide](https://docs.varity.com/templates)
309
+ - [Quick Start Guide](../../docs/QUICK_START_TEMPLATE.md)
310
+
311
+ ## Support
312
+
313
+ - Discord: https://discord.gg/varity
314
+ - Email: support@varity.com
315
+ `;
316
+ fs.writeFileSync(path.join(baseDir, 'README.md'), readme);
317
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * varity validate - Template validation
3
+ *
4
+ * Validates template configuration and structure
5
+ */
6
+ import { Command } from 'commander';
7
+ export declare const validateCommand: Command;
8
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/validate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,eAAO,MAAM,eAAe,SAoExB,CAAA"}