stylus-toolkit 0.2.10 → 1.0.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.
Files changed (40) hide show
  1. package/README.md +230 -80
  2. package/dist/cli.js +9 -3
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/config.d.ts.map +1 -1
  5. package/dist/commands/config.js +3 -2
  6. package/dist/commands/config.js.map +1 -1
  7. package/dist/commands/dashboard.d.ts +6 -0
  8. package/dist/commands/dashboard.d.ts.map +1 -0
  9. package/dist/commands/dashboard.js +48 -0
  10. package/dist/commands/dashboard.js.map +1 -0
  11. package/dist/commands/deploy.d.ts.map +1 -1
  12. package/dist/commands/deploy.js +12 -24
  13. package/dist/commands/deploy.js.map +1 -1
  14. package/dist/commands/dev.d.ts.map +1 -1
  15. package/dist/commands/dev.js +57 -10
  16. package/dist/commands/dev.js.map +1 -1
  17. package/dist/commands/profile.d.ts.map +1 -1
  18. package/dist/commands/profile.js +74 -44
  19. package/dist/commands/profile.js.map +1 -1
  20. package/dist/config/constants.d.ts +56 -0
  21. package/dist/config/constants.d.ts.map +1 -0
  22. package/dist/config/constants.js +26 -0
  23. package/dist/config/constants.js.map +1 -0
  24. package/dist/profiler/comparator.d.ts.map +1 -1
  25. package/dist/profiler/comparator.js +3 -7
  26. package/dist/profiler/comparator.js.map +1 -1
  27. package/dist/profiler/gas-profiler.d.ts.map +1 -1
  28. package/dist/profiler/gas-profiler.js +30 -51
  29. package/dist/profiler/gas-profiler.js.map +1 -1
  30. package/dist/storage/results-store.d.ts +3 -0
  31. package/dist/storage/results-store.d.ts.map +1 -1
  32. package/dist/storage/results-store.js +25 -0
  33. package/dist/storage/results-store.js.map +1 -1
  34. package/dist/utils/gas-estimator.d.ts +22 -0
  35. package/dist/utils/gas-estimator.d.ts.map +1 -0
  36. package/dist/utils/gas-estimator.js +46 -0
  37. package/dist/utils/gas-estimator.js.map +1 -0
  38. package/package.json +5 -1
  39. package/src/dashboard/dashboard.js +276 -0
  40. package/src/dashboard/index.html +147 -0
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GasProfiler = void 0;
4
4
  const ethers_1 = require("ethers");
5
5
  const logger_1 = require("../utils/logger");
6
+ const gas_estimator_1 = require("../utils/gas-estimator");
7
+ const constants_1 = require("../config/constants");
6
8
  class GasProfiler {
7
9
  constructor(rpcUrl, privateKey) {
8
10
  this.provider = new ethers_1.ethers.JsonRpcProvider(rpcUrl);
@@ -52,32 +54,21 @@ class GasProfiler {
52
54
  }
53
55
  }
54
56
  estimateGasProfile(compilation) {
55
- // Estimate deployment gas based on bytecode size and language
56
- const bytecodeSize = compilation.bytecode.length / 2; // hex to bytes
57
- let estimatedDeploymentGas;
57
+ const bytecodeSize = compilation.bytecode.length / 2;
58
+ const estimatedDeploymentGas = gas_estimator_1.GasEstimator.estimateProfileGas(bytecodeSize, compilation.language);
58
59
  const functionGasMap = new Map();
59
- if (compilation.language === 'rust') {
60
- // Stylus WASM contracts: Realistic deployment cost
61
- // Uses 16 gas per byte for compressed WASM (Arbitrum Stylus pricing)
62
- estimatedDeploymentGas = Math.floor(21000 + (bytecodeSize * 16));
63
- // Realistic function execution based on Arbitrum Stylus benchmarks
64
- // Source: Arbitrum docs, RedStone oracle analysis, WELLDONE Studio testing
65
- // Oracle workloads: ~26% savings, Compute: ~40-50% savings
66
- functionGasMap.set('read', { avgGas: 5000, calls: 100 }); // Light read operation
67
- functionGasMap.set('write', { avgGas: 12000, calls: 100 }); // State write (SSTORE equiv)
68
- functionGasMap.set('compute', { avgGas: 8000, calls: 100 }); // Computation workload
69
- functionGasMap.set('oracle', { avgGas: 75000, calls: 100 }); // Oracle verification (3 signers)
70
- }
71
- else {
72
- // Solidity EVM contracts: Standard deployment and execution costs
73
- estimatedDeploymentGas = Math.floor(21000 + (bytecodeSize * 200));
74
- // EVM execution costs (baseline from Arbitrum benchmarks)
75
- // Source: Arbitrum Stylus documentation, RedStone oracle comparison
76
- functionGasMap.set('read', { avgGas: 6000, calls: 100 }); // SLOAD operation
77
- functionGasMap.set('write', { avgGas: 20000, calls: 100 }); // SSTORE (warm slot)
78
- functionGasMap.set('compute', { avgGas: 15000, calls: 100 }); // Typical computation
79
- functionGasMap.set('oracle', { avgGas: 103000, calls: 100 }); // Oracle with 3 signers
80
- }
60
+ const estimates = constants_1.GAS_FUNCTION_ESTIMATES[compilation.language];
61
+ Object.entries(estimates).forEach(([funcName, data]) => {
62
+ functionGasMap.set(funcName, {
63
+ functionName: funcName,
64
+ gasUsed: data.avgGas,
65
+ executions: data.calls,
66
+ avgGas: data.avgGas,
67
+ minGas: data.avgGas,
68
+ maxGas: data.avgGas,
69
+ testCases: []
70
+ });
71
+ });
81
72
  logger_1.logger.succeedSpinner(`${compilation.language} estimation complete (Est. Deployment: ${estimatedDeploymentGas} gas)`);
82
73
  return {
83
74
  contractName: compilation.contractName,
@@ -90,35 +81,23 @@ class GasProfiler {
90
81
  };
91
82
  }
92
83
  estimateDeploymentGas(compilation) {
93
- const bytecodeSize = compilation.bytecode.length / 2; // hex to bytes
94
- if (compilation.language === 'rust') {
95
- // Stylus WASM: Base cost + compressed WASM storage
96
- // 21000 (base tx) + ~300,000 (deployment overhead) + bytecode costs
97
- return Math.floor(21000 + 300000 + (bytecodeSize * 16));
98
- }
99
- else {
100
- // Solidity: EVM deployment costs
101
- // 21000 (base tx) + 32000 (contract creation) + bytecode costs
102
- return Math.floor(21000 + 32000 + (bytecodeSize * 200));
103
- }
84
+ const bytecodeSize = compilation.bytecode.length / 2;
85
+ return gas_estimator_1.GasEstimator.estimateProfileGas(bytecodeSize, compilation.language);
104
86
  }
105
87
  estimateFunctionGas(compilation) {
106
88
  const functionGasMap = new Map();
107
- if (compilation.language === 'rust') {
108
- // Realistic function execution based on Arbitrum Stylus benchmarks
109
- // Source: Arbitrum docs, RedStone oracle analysis, WELLDONE Studio testing
110
- functionGasMap.set('read', { avgGas: 5000, calls: 100 }); // Light read operation
111
- functionGasMap.set('write', { avgGas: 12000, calls: 100 }); // State write (SSTORE equiv)
112
- functionGasMap.set('compute', { avgGas: 8000, calls: 100 }); // Computation workload
113
- functionGasMap.set('oracle', { avgGas: 75000, calls: 100 }); // Oracle verification (3 signers)
114
- }
115
- else {
116
- // EVM execution costs (baseline from Arbitrum benchmarks)
117
- functionGasMap.set('read', { avgGas: 6000, calls: 100 }); // SLOAD operation
118
- functionGasMap.set('write', { avgGas: 20000, calls: 100 }); // SSTORE (warm slot)
119
- functionGasMap.set('compute', { avgGas: 15000, calls: 100 }); // Typical computation
120
- functionGasMap.set('oracle', { avgGas: 103000, calls: 100 }); // Oracle with 3 signers
121
- }
89
+ const estimates = constants_1.GAS_FUNCTION_ESTIMATES[compilation.language];
90
+ Object.entries(estimates).forEach(([funcName, data]) => {
91
+ functionGasMap.set(funcName, {
92
+ functionName: funcName,
93
+ gasUsed: data.avgGas,
94
+ executions: data.calls,
95
+ avgGas: data.avgGas,
96
+ minGas: data.avgGas,
97
+ maxGas: data.avgGas,
98
+ testCases: []
99
+ });
100
+ });
122
101
  return functionGasMap;
123
102
  }
124
103
  async estimateGas(contractAddress, abi, functionName, args) {
@@ -1 +1 @@
1
- {"version":3,"file":"gas-profiler.js","sourceRoot":"","sources":["../../src/profiler/gas-profiler.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAChC,4CAAyC;AAGzC,MAAa,WAAW;IAItB,YAAY,MAAc,EAAE,UAAmB;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAEnD,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7D,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,GAAG,eAAM,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QA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12,5 +12,8 @@ export declare class ResultsStore {
12
12
  private serializeComparison;
13
13
  private deserializeComparison;
14
14
  getResultsDirectory(): string;
15
+ getAllResults(): Promise<ComparisonResult[]>;
16
+ getResultsByContract(contractName: string): Promise<ComparisonResult[]>;
17
+ getResultsByDateRange(startDate: Date, endDate: Date): Promise<ComparisonResult[]>;
15
18
  }
16
19
  //# sourceMappingURL=results-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"results-store.d.ts","sourceRoot":"","sources":["../../src/storage/results-store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAAS;gBAEf,SAAS,CAAC,EAAE,MAAM;IAKxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,IAAI,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAcnD,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAWjD,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAWzB,SAAS,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAclE,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASvC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5B,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,qBAAqB;IAkB7B,mBAAmB,IAAI,MAAM;CAG9B"}
1
+ {"version":3,"file":"results-store.d.ts","sourceRoot":"","sources":["../../src/storage/results-store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAAS;gBAEf,SAAS,CAAC,EAAE,MAAM;IAKxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,IAAI,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAcnD,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAWjD,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAWzB,SAAS,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAclE,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASvC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5B,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,qBAAqB;IAkB7B,mBAAmB,IAAI,MAAM;IAIvB,aAAa,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAgB5C,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAKvE,qBAAqB,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAOzF"}
@@ -102,6 +102,31 @@ class ResultsStore {
102
102
  getResultsDirectory() {
103
103
  return this.resultsDir;
104
104
  }
105
+ async getAllResults() {
106
+ const files = await this.list();
107
+ const results = [];
108
+ for (const file of files) {
109
+ try {
110
+ const result = await this.load(file);
111
+ results.push(result);
112
+ }
113
+ catch (error) {
114
+ logger_1.logger.warn(`Failed to load result file ${file}`);
115
+ }
116
+ }
117
+ return results;
118
+ }
119
+ async getResultsByContract(contractName) {
120
+ const allResults = await this.getAllResults();
121
+ return allResults.filter(r => r.contractName === contractName);
122
+ }
123
+ async getResultsByDateRange(startDate, endDate) {
124
+ const allResults = await this.getAllResults();
125
+ return allResults.filter(r => {
126
+ const timestamp = new Date(r.timestamp);
127
+ return timestamp >= startDate && timestamp <= endDate;
128
+ });
129
+ }
105
130
  }
106
131
  exports.ResultsStore = ResultsStore;
107
132
  //# sourceMappingURL=results-store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"results-store.js","sourceRoot":"","sources":["../../src/storage/results-store.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,wDAA0B;AAC1B,sDAAkD;AAElD,4CAAyC;AAEzC,MAAa,YAAY;IAGvB,YAAY,SAAkB;QAC5B,IAAI,CAAC,UAAU;YACb,SAAS,IAAI,cAAI,CAAC,IAAI,CAAC,wBAAU,CAAC,cAAc,EAAE,EAAE,iBAAiB,EAAE,SAAS,CAAC,CAAC;IACtF,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,wBAAU,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,UAA4B;QACrC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAExB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACjE,MAAM,QAAQ,GAAG,GAAG,UAAU,CAAC,YAAY,IAAI,SAAS,OAAO,CAAC;QAChE,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAEtD,MAAM,wBAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAAC;QAE3E,eAAM,CAAC,OAAO,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;QAE/C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAgB;QACzB,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAEtD,IAAI,CAAC,CAAC,MAAM,wBAAU,CAAC,UAAU,CAAC,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AAC,CAAC,CAAC,EAAE;YAC3B,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACxC,OAAO,SAAS,IAAI,SAAS,IAAI,SAAS,IAAI,OAAO,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAjJD,oCAiJC"}
@@ -0,0 +1,22 @@
1
+ export interface GasEstimationConfig {
2
+ baseGas: number;
3
+ activationGas: number;
4
+ perByteGas: number;
5
+ }
6
+ export declare class GasEstimator {
7
+ private static readonly STYLUS_DEPLOY_CONFIG;
8
+ private static readonly STYLUS_PROFILE_CONFIG;
9
+ private static readonly EVM_CONFIG;
10
+ /**
11
+ * Estimate gas for actual deployment (deploy command).
12
+ * Includes full 14M activation cost + 2.5x safety buffer.
13
+ */
14
+ static estimateDeploymentGas(bytecodeSize: number, language: 'rust' | 'solidity', safetyMultiplier?: number): number;
15
+ /**
16
+ * Estimate gas for profiling / TCO comparison.
17
+ * Uses bytecode storage cost only — no activation overhead.
18
+ * This gives an honest apples-to-apples comparison with Solidity.
19
+ */
20
+ static estimateProfileGas(bytecodeSize: number, language: 'rust' | 'solidity'): number;
21
+ }
22
+ //# sourceMappingURL=gas-estimator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gas-estimator.d.ts","sourceRoot":"","sources":["../../src/utils/gas-estimator.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,YAAY;IAEvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAI1C;IAIF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAI3C;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAIhC;IAEF;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CAC1B,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GAAG,UAAU,EAC7B,gBAAgB,GAAE,MAAU,GAC3B,MAAM;IAST;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CACvB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GAAG,UAAU,GAC5B,MAAM;CAQV"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GasEstimator = void 0;
4
+ class GasEstimator {
5
+ /**
6
+ * Estimate gas for actual deployment (deploy command).
7
+ * Includes full 14M activation cost + 2.5x safety buffer.
8
+ */
9
+ static estimateDeploymentGas(bytecodeSize, language, safetyMultiplier = 1) {
10
+ const config = language === 'rust' ? this.STYLUS_DEPLOY_CONFIG : this.EVM_CONFIG;
11
+ return Math.ceil(config.baseGas +
12
+ config.activationGas +
13
+ (bytecodeSize * config.perByteGas * safetyMultiplier));
14
+ }
15
+ /**
16
+ * Estimate gas for profiling / TCO comparison.
17
+ * Uses bytecode storage cost only — no activation overhead.
18
+ * This gives an honest apples-to-apples comparison with Solidity.
19
+ */
20
+ static estimateProfileGas(bytecodeSize, language) {
21
+ const config = language === 'rust' ? this.STYLUS_PROFILE_CONFIG : this.EVM_CONFIG;
22
+ return Math.ceil(config.baseGas +
23
+ config.activationGas +
24
+ (bytecodeSize * config.perByteGas));
25
+ }
26
+ }
27
+ exports.GasEstimator = GasEstimator;
28
+ // Full deployment config — used by `deploy` command (includes 14M activation)
29
+ GasEstimator.STYLUS_DEPLOY_CONFIG = {
30
+ baseGas: 21000,
31
+ activationGas: 14000000,
32
+ perByteGas: 16,
33
+ };
34
+ // Profiling config — bytecode storage cost only, no activation overhead
35
+ // Activation is a one-time fixed cost; TCO comparison uses per-byte storage
36
+ GasEstimator.STYLUS_PROFILE_CONFIG = {
37
+ baseGas: 21000,
38
+ activationGas: 300000,
39
+ perByteGas: 16,
40
+ };
41
+ GasEstimator.EVM_CONFIG = {
42
+ baseGas: 21000,
43
+ activationGas: 32000,
44
+ perByteGas: 200,
45
+ };
46
+ //# sourceMappingURL=gas-estimator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gas-estimator.js","sourceRoot":"","sources":["../../src/utils/gas-estimator.ts"],"names":[],"mappings":";;;AAMA,MAAa,YAAY;IAsBvB;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CAC1B,YAAoB,EACpB,QAA6B,EAC7B,mBAA2B,CAAC;QAE5B,MAAM,MAAM,GAAG,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;QACjF,OAAO,IAAI,CAAC,IAAI,CACd,MAAM,CAAC,OAAO;YACd,MAAM,CAAC,aAAa;YACpB,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,GAAG,gBAAgB,CAAC,CACtD,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CACvB,YAAoB,EACpB,QAA6B;QAE7B,MAAM,MAAM,GAAG,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;QAClF,OAAO,IAAI,CAAC,IAAI,CACd,MAAM,CAAC,OAAO;YACd,MAAM,CAAC,aAAa;YACpB,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,CACnC,CAAC;IACJ,CAAC;;AAtDH,oCAuDC;AAtDC,8EAA8E;AACtD,iCAAoB,GAAwB;IAClE,OAAO,EAAE,KAAK;IACd,aAAa,EAAE,QAAQ;IACvB,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,wEAAwE;AACxE,4EAA4E;AACpD,kCAAqB,GAAwB;IACnE,OAAO,EAAE,KAAK;IACd,aAAa,EAAE,MAAM;IACrB,UAAU,EAAE,EAAE;CACf,CAAC;AAEsB,uBAAU,GAAwB;IACxD,OAAO,EAAE,KAAK;IACd,aAAa,EAAE,KAAK;IACpB,UAAU,EAAE,GAAG;CAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stylus-toolkit",
3
- "version": "0.2.10",
3
+ "version": "1.0.0",
4
4
  "description": "A comprehensive CLI development environment for Arbitrum Stylus smart contracts with automated gas profiling",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -44,6 +44,7 @@
44
44
  "files": [
45
45
  "dist/",
46
46
  "src/templates/Cargo.lock",
47
+ "src/dashboard/",
47
48
  "README.md",
48
49
  "LICENSE"
49
50
  ],
@@ -56,16 +57,19 @@
56
57
  "dotenv": "^16.3.1",
57
58
  "ethers": "^6.9.0",
58
59
  "execa": "^5.1.1",
60
+ "express": "^4.18.2",
59
61
  "fast-csv": "^4.3.6",
60
62
  "fs-extra": "^11.2.0",
61
63
  "handlebars": "^4.7.8",
62
64
  "inquirer": "^8.2.6",
63
65
  "json2csv": "^6.0.0-alpha.2",
66
+ "open": "^8.4.2",
64
67
  "ora": "^5.4.1",
65
68
  "solc": "^0.8.33",
66
69
  "yaml": "^2.3.4"
67
70
  },
68
71
  "devDependencies": {
72
+ "@types/express": "^4.17.21",
69
73
  "@types/fs-extra": "^11.0.4",
70
74
  "@types/inquirer": "^8.2.10",
71
75
  "@types/jest": "^29.5.11",
@@ -0,0 +1,276 @@
1
+ async function loadData() {
2
+ try {
3
+ const response = await fetch('/data.json');
4
+ if (!response.ok) {
5
+ throw new Error('Failed to load data');
6
+ }
7
+ return await response.json();
8
+ } catch (error) {
9
+ throw new Error(`Error loading data: ${error.message}`);
10
+ }
11
+ }
12
+
13
+ function calculateStats(data) {
14
+ if (data.length === 0) {
15
+ return {
16
+ totalProfiles: 0,
17
+ avgSavings: 0,
18
+ maxSavings: 0,
19
+ contractsProfiled: 0
20
+ };
21
+ }
22
+
23
+ const totalProfiles = data.length;
24
+ const avgSavings = data.reduce((sum, r) => sum + r.tco.tcoPercentage, 0) / totalProfiles;
25
+ const maxSavings = Math.max(...data.map(r => r.tco.tcoPercentage));
26
+ const uniqueContracts = new Set(data.map(r => r.contractName));
27
+ const contractsProfiled = uniqueContracts.size;
28
+
29
+ return {
30
+ totalProfiles,
31
+ avgSavings: avgSavings.toFixed(2),
32
+ maxSavings: maxSavings.toFixed(2),
33
+ contractsProfiled
34
+ };
35
+ }
36
+
37
+ function renderStats(stats) {
38
+ const statsContainer = document.getElementById('stats');
39
+ statsContainer.innerHTML = `
40
+ <div class="stat-card">
41
+ <div class="stat-label">Total Profiles</div>
42
+ <div class="stat-value">${stats.totalProfiles}</div>
43
+ </div>
44
+ <div class="stat-card">
45
+ <div class="stat-label">Average TCO Savings</div>
46
+ <div class="stat-value ${stats.avgSavings < 0 ? 'negative' : ''}">${stats.avgSavings}%</div>
47
+ </div>
48
+ <div class="stat-card">
49
+ <div class="stat-label">Maximum Savings</div>
50
+ <div class="stat-value">${stats.maxSavings}%</div>
51
+ </div>
52
+ <div class="stat-card">
53
+ <div class="stat-label">Contracts Profiled</div>
54
+ <div class="stat-value">${stats.contractsProfiled}</div>
55
+ </div>
56
+ `;
57
+ }
58
+
59
+ function renderCharts(data) {
60
+ if (data.length === 0) {
61
+ return;
62
+ }
63
+
64
+ // TCO Trend Chart
65
+ const tcoCtx = document.getElementById('tcoChart').getContext('2d');
66
+ new Chart(tcoCtx, {
67
+ type: 'line',
68
+ data: {
69
+ labels: data.map(r => new Date(r.timestamp).toLocaleDateString()),
70
+ datasets: [
71
+ {
72
+ label: 'Rust (Stylus) TCO',
73
+ data: data.map(r => r.tco.rustTCO),
74
+ borderColor: 'rgb(139, 92, 246)',
75
+ backgroundColor: 'rgba(139, 92, 246, 0.1)',
76
+ tension: 0.4,
77
+ fill: true
78
+ },
79
+ {
80
+ label: 'Solidity TCO',
81
+ data: data.map(r => r.tco.solidityTCO),
82
+ borderColor: 'rgb(239, 68, 68)',
83
+ backgroundColor: 'rgba(239, 68, 68, 0.1)',
84
+ tension: 0.4,
85
+ fill: true
86
+ }
87
+ ]
88
+ },
89
+ options: {
90
+ responsive: true,
91
+ maintainAspectRatio: false,
92
+ plugins: {
93
+ title: {
94
+ display: false
95
+ },
96
+ legend: {
97
+ labels: {
98
+ color: '#e2e8f0'
99
+ }
100
+ }
101
+ },
102
+ scales: {
103
+ y: {
104
+ beginAtZero: true,
105
+ grid: {
106
+ color: '#334155'
107
+ },
108
+ ticks: {
109
+ color: '#94a3b8'
110
+ }
111
+ },
112
+ x: {
113
+ grid: {
114
+ color: '#334155'
115
+ },
116
+ ticks: {
117
+ color: '#94a3b8'
118
+ }
119
+ }
120
+ }
121
+ }
122
+ });
123
+
124
+ // Savings Percentage Chart
125
+ const savingsCtx = document.getElementById('savingsChart').getContext('2d');
126
+ new Chart(savingsCtx, {
127
+ type: 'bar',
128
+ data: {
129
+ labels: data.map((r, i) => `${r.contractName} (${new Date(r.timestamp).toLocaleDateString()})`),
130
+ datasets: [{
131
+ label: 'TCO Savings %',
132
+ data: data.map(r => r.tco.tcoPercentage),
133
+ backgroundColor: data.map(r => r.tco.tcoPercentage >= 0 ? 'rgba(16, 185, 129, 0.8)' : 'rgba(239, 68, 68, 0.8)'),
134
+ borderColor: data.map(r => r.tco.tcoPercentage >= 0 ? 'rgb(16, 185, 129)' : 'rgb(239, 68, 68)'),
135
+ borderWidth: 1
136
+ }]
137
+ },
138
+ options: {
139
+ responsive: true,
140
+ maintainAspectRatio: false,
141
+ plugins: {
142
+ title: {
143
+ display: false
144
+ },
145
+ legend: {
146
+ labels: {
147
+ color: '#e2e8f0'
148
+ }
149
+ }
150
+ },
151
+ scales: {
152
+ y: {
153
+ beginAtZero: true,
154
+ grid: {
155
+ color: '#334155'
156
+ },
157
+ ticks: {
158
+ color: '#94a3b8',
159
+ callback: function(value) {
160
+ return value + '%';
161
+ }
162
+ }
163
+ },
164
+ x: {
165
+ grid: {
166
+ color: '#334155'
167
+ },
168
+ ticks: {
169
+ color: '#94a3b8',
170
+ maxRotation: 45,
171
+ minRotation: 45
172
+ }
173
+ }
174
+ }
175
+ }
176
+ });
177
+
178
+ // Costs Breakdown Chart
179
+ const costsCtx = document.getElementById('costsChart').getContext('2d');
180
+ const latestData = data[data.length - 1];
181
+
182
+ new Chart(costsCtx, {
183
+ type: 'bar',
184
+ data: {
185
+ labels: ['Deployment', 'Execution (100 calls)'],
186
+ datasets: [
187
+ {
188
+ label: 'Rust (Stylus)',
189
+ data: [
190
+ latestData.rustProfile.deploymentGas,
191
+ latestData.tco.rustTCO - latestData.rustProfile.deploymentGas
192
+ ],
193
+ backgroundColor: 'rgba(139, 92, 246, 0.8)',
194
+ borderColor: 'rgb(139, 92, 246)',
195
+ borderWidth: 1
196
+ },
197
+ {
198
+ label: 'Solidity',
199
+ data: [
200
+ latestData.solidityProfile.deploymentGas,
201
+ latestData.tco.solidityTCO - latestData.solidityProfile.deploymentGas
202
+ ],
203
+ backgroundColor: 'rgba(239, 68, 68, 0.8)',
204
+ borderColor: 'rgb(239, 68, 68)',
205
+ borderWidth: 1
206
+ }
207
+ ]
208
+ },
209
+ options: {
210
+ responsive: true,
211
+ maintainAspectRatio: false,
212
+ plugins: {
213
+ title: {
214
+ display: false
215
+ },
216
+ legend: {
217
+ labels: {
218
+ color: '#e2e8f0'
219
+ }
220
+ }
221
+ },
222
+ scales: {
223
+ y: {
224
+ beginAtZero: true,
225
+ grid: {
226
+ color: '#334155'
227
+ },
228
+ ticks: {
229
+ color: '#94a3b8',
230
+ callback: function(value) {
231
+ return value.toLocaleString() + ' gas';
232
+ }
233
+ }
234
+ },
235
+ x: {
236
+ grid: {
237
+ color: '#334155'
238
+ },
239
+ ticks: {
240
+ color: '#94a3b8'
241
+ }
242
+ }
243
+ }
244
+ }
245
+ });
246
+ }
247
+
248
+ async function renderDashboard() {
249
+ const loadingEl = document.getElementById('loading');
250
+ const errorEl = document.getElementById('error');
251
+ const dashboardEl = document.getElementById('dashboard');
252
+
253
+ try {
254
+ const data = await loadData();
255
+
256
+ loadingEl.style.display = 'none';
257
+
258
+ if (data.length === 0) {
259
+ errorEl.style.display = 'block';
260
+ document.getElementById('error-message').textContent = 'No profiling data available yet. Run "stylus-toolkit profile" to generate data.';
261
+ return;
262
+ }
263
+
264
+ const stats = calculateStats(data);
265
+ renderStats(stats);
266
+ renderCharts(data);
267
+
268
+ dashboardEl.style.display = 'block';
269
+ } catch (error) {
270
+ loadingEl.style.display = 'none';
271
+ errorEl.style.display = 'block';
272
+ document.getElementById('error-message').textContent = error.message;
273
+ }
274
+ }
275
+
276
+ renderDashboard();