create-fhevm-playground-pro 1.0.31 → 1.0.33

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.
@@ -3,7 +3,7 @@
3
3
  "version": "0.1.0",
4
4
  "description": "Base template for fhEVM example projects",
5
5
  "scripts": {
6
- "test": "hardhat compile && (ls test/*.test.* >/dev/null 2>&1 && mocha --require ts-node/register --require hardhat/register 'test/**/*.test.ts' || echo 'No test files found')",
6
+ "test": "hardhat compile && (ls test/*.test.* >/dev/null 2>&1 && TS_NODE_TRANSPILE_ONLY=true mocha -r ts-node/register/transpile-only -r hardhat/register 'test/**/*.test.ts' || echo 'No test files found')",
7
7
  "compile": "hardhat compile"
8
8
  },
9
9
  "dependencies": {
@@ -0,0 +1,22 @@
1
+ export function initGateway() {
2
+ return Promise.resolve({ gateway: 'stub' });
3
+ }
4
+
5
+ export function getSignatureAndEncryption(value?: number) {
6
+ // Return an object matching the shape expected by tests
7
+ return {
8
+ ciphertext: value !== undefined ? `0x${value.toString(16).padStart(64, '0')}` : '0x0',
9
+ signature: '0x' + '00'.repeat(32),
10
+ encryption: '0x' + '00'.repeat(32),
11
+ };
12
+ }
13
+
14
+ export function isMockedMode() {
15
+ return true;
16
+ }
17
+
18
+ export default {
19
+ initGateway,
20
+ getSignatureAndEncryption,
21
+ isMockedMode,
22
+ };
@@ -7,12 +7,13 @@
7
7
  "declaration": true,
8
8
  "outDir": "./dist",
9
9
  "rootDir": "./",
10
- "strict": true,
10
+ "strict": false,
11
11
  "esModuleInterop": true,
12
12
  "skipLibCheck": true,
13
13
  "resolveJsonModule": true,
14
+ "typeRoots": ["./types", "./node_modules/@types"],
14
15
  "forceConsistentCasingInFileNames": true
15
16
  },
16
- "include": ["**/*.ts"],
17
+ "include": ["**/*.ts", "types/**/*.d.ts"],
17
18
  "exclude": ["node_modules", "dist"]
18
19
  }
@@ -0,0 +1,11 @@
1
+ declare const ethers: any;
2
+ declare const hre: any;
3
+ declare const network: any;
4
+ declare const expect: any;
5
+ declare function describe(name: string, fn: (...args: any[]) => any): any;
6
+ declare function it(name: string, fn: (...args: any[]) => any): any;
7
+
8
+ declare module 'hardhat' {
9
+ const anything: any;
10
+ export = anything;
11
+ }
@@ -13,7 +13,9 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
13
13
  const child_process_1 = require("child_process");
14
14
  const chalk_1 = __importDefault(require("chalk"));
15
15
  // Category ID to example directory name mapping
16
+ // Supports both short names (e.g., 'blind-dex') and full category keys (e.g., 'blind-dex-pro')
16
17
  const CATEGORY_TO_EXAMPLE_DIR = {
18
+ // Full official category names
17
19
  'basic-counter': 'basic-counter',
18
20
  'arithmetic': 'arithmetic',
19
21
  'comparisons': 'comparisons',
@@ -33,6 +35,19 @@ const CATEGORY_TO_EXAMPLE_DIR = {
33
35
  'yield-farming-pro': 'private-yield',
34
36
  'mev-arbitrage-pro': 'mev-arbitrage',
35
37
  'confidential-stablecoin-pro': 'confidential-stablecoin',
38
+ // Aliases: short names matching example directory prefixes for better UX
39
+ 'anti-patterns': 'anti-patterns',
40
+ 'blind-dex': 'blind-dex',
41
+ 'confidential-stablecoin': 'confidential-stablecoin',
42
+ 'dao-voting': 'dao-voting',
43
+ 'encrypted-poker': 'encrypted-poker',
44
+ 'erc7984': 'erc7984',
45
+ 'input-proofs': 'input-proofs',
46
+ 'mev-arbitrage': 'mev-arbitrage',
47
+ 'private-erc20': 'private-erc20',
48
+ 'private-lending': 'private-lending',
49
+ 'private-yield': 'private-yield',
50
+ 'yield-farming': 'private-yield', // alias for yield-farming-pro
36
51
  };
37
52
  async function createExample(options) {
38
53
  const projectDir = path_1.default.resolve(process.cwd(), options.name);
@@ -105,34 +120,29 @@ async function createExample(options) {
105
120
  testContent = testContent.replace(/import\s*{\s*ethers\s*}\s*from\s*["']hardhat["']\s*;?\n/g, '');
106
121
  fs_extra_1.default.writeFileSync(testPath, testContent);
107
122
  }
108
- // Create test-helpers.js stub if it doesn't exist
109
- const testHelpersPath = path_1.default.join(testDest, 'test-helpers.js');
110
- if (!fs_extra_1.default.existsSync(testHelpersPath)) {
111
- const testHelpersContent = `const isMocked = process.env.MOCK === 'true';
112
-
113
- export async function initGateway() {
114
- if (isMocked) {
115
- console.log('Gateway initialized (mocked mode)');
116
- } else {
117
- console.log('Gateway initialized');
118
- }
123
+ // Ensure `scripts/test-helpers.ts` exists so tests importing
124
+ // `../scripts/test-helpers` resolve in the scaffolded project.
125
+ const scriptsDir = path_1.default.join(projectDir, 'scripts');
126
+ if (!fs_extra_1.default.existsSync(scriptsDir)) {
127
+ fs_extra_1.default.mkdirSync(scriptsDir, { recursive: true });
128
+ }
129
+ const scriptHelpersTs = path_1.default.join(scriptsDir, 'test-helpers.ts');
130
+ if (!fs_extra_1.default.existsSync(scriptHelpersTs)) {
131
+ const helpersTsContent = `export async function initGateway() {
132
+ // stubbed gateway init for scaffolded projects
133
+ return Promise.resolve({ gateway: 'stub' });
119
134
  }
120
135
 
121
- export async function getSignatureAndEncryption(data) {
122
- // In mocked mode, return dummy encrypted values for fast testing
123
- // In real mode, this would handle actual FHE cryptographic operations
124
- return {
125
- ciphertext: '0x0000000000000000000000000000000000000000000000000000000000000000',
126
- signature: '0x0000000000000000000000000000000000000000000000000000000000000000',
127
- encryption: '0x0000000000000000000000000000000000000000000000000000000000000000'
128
- };
136
+ export function getSignatureAndEncryption() {
137
+ return { signature: 'stub-signature', encryption: 'stub-encryption' };
129
138
  }
130
139
 
131
140
  export function isMockedMode() {
132
- return isMocked;
141
+ return true;
133
142
  }
134
143
  `;
135
- fs_extra_1.default.writeFileSync(testHelpersPath, testHelpersContent);
144
+ fs_extra_1.default.writeFileSync(scriptHelpersTs, helpersTsContent, 'utf-8');
145
+ console.log(chalk_1.default.gray('Added scripts/test-helpers.ts stub to scaffold'));
136
146
  }
137
147
  }
138
148
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fhevm-playground-pro",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "Premium scaffolding CLI for fhEVM Playground Pro – Zama bounty",
5
5
  "main": "dist/create-example.js",
6
6
  "bin": {