Skip to content

Commit c484cfe

Browse files
committed
chore: move getStagesData script
1 parent e4271eb commit c484cfe

File tree

2 files changed

+616
-28
lines changed

2 files changed

+616
-28
lines changed

cli-typescript/src/utils/deployContract.ts

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import path from 'path';
2-
import fs from 'fs';
32
import { confirm } from '@inquirer/prompts';
4-
import { collapseAddress, executeCommand } from './common';
3+
import { collapseAddress } from './common';
54
import {
65
confirmDeployment,
76
confirmSetup,
@@ -14,7 +13,6 @@ import {
1413
ERC721StageData,
1514
} from './types';
1615
import {
17-
getBaseDir,
1816
getExplorerContractUrl,
1917
getFactoryAddress,
2018
getImplId,
@@ -43,6 +41,7 @@ import {
4341
setTokenUriSuffix,
4442
} from './setters';
4543
import { getProjectStore } from './fileUtils';
44+
import { getStagesData } from './evmUtils';
4645

4746
export const deployContract = async ({
4847
store,
@@ -364,16 +363,18 @@ export const processStages = async (params: {
364363

365364
const outputFileDir = path.dirname(collectionFile);
366365
console.log(`Output file directory: ${outputFileDir}`);
367-
const saveToJson = true;
368366

369367
try {
370-
// Execute the script to process stages
371-
executeCommand(
372-
`npx ts-node "${path.join(
373-
getBaseDir(),
374-
'../../scripts/utils/getStagesData.ts',
375-
)}" "${stagesFile}" '${stagesJson}' "${outputFileDir}" "${tokenStandard}" "" "${saveToJson}"`,
368+
const stagesData = await getStagesData(
369+
stagesFile,
370+
tokenStandard === TOKEN_STANDARD.ERC1155,
371+
outputFileDir,
372+
stagesJson,
376373
);
374+
375+
console.log('stagesData: 😁', stagesData);
376+
377+
return stagesData as ERC721StageData[] | ERC1155StageData[];
377378
} catch (error: any) {
378379
console.error(
379380
'Error: Failed to get stages data',
@@ -382,22 +383,6 @@ export const processStages = async (params: {
382383
);
383384
throw new Error('Failed to get stages data');
384385
}
385-
386-
// Check if the output file exists
387-
const outputFilePath = path.join(outputFileDir, 'stagesInput.tmp.json');
388-
389-
if (!fs.existsSync(outputFilePath)) {
390-
console.error(`Error: Output file not found: ${outputFilePath}`);
391-
throw new Error(`Output file not found: ${outputFilePath}`);
392-
}
393-
394-
// Read the stages data
395-
const stagesData = fs.readFileSync(outputFilePath, 'utf-8');
396-
397-
// Delete the temporary file
398-
fs.unlinkSync(outputFilePath);
399-
400-
return JSON.parse(stagesData);
401386
};
402387

403388
export const getERC721ParsedStagesData = (stagesData: ERC721StageData[]) => {

0 commit comments

Comments
 (0)