UNPKG

create-web3-dapp-dev

Version:

<p align="center"> <br /> <a href="https://createweb3dapp.alchemy.com"> <img src=".github/images/cw3d-logo.png" width="200" alt=""/></a> <br /> </p>

59 lines 2.67 kB
import fs, { existsSync } from "fs"; import path from "path"; import { mkdir } from "../utils/mkdir.js"; import { createDeployScript } from "./createDeployScript.js"; import { erc20, erc721, erc1155 } from "@openzeppelin/wizard"; import { SmartContractStandard } from "./utils/smartContractStandards.js"; export const buildSmartContract = (smartContractInfo, backendFolder) => { const contractsFolder = path.join(backendFolder, "contracts"); if (!existsSync(contractsFolder)) mkdir(contractsFolder); const writeStream = fs.createWriteStream(path.join(contractsFolder, `${smartContractInfo.name}.sol`)); let smartcontractTemplate; switch (smartContractInfo.standard) { case SmartContractStandard.ERC20: smartcontractTemplate = erc20.print({ name: smartContractInfo.name, symbol: smartContractInfo.symbol, burnable: smartContractInfo.isBurnable, pausable: smartContractInfo.isPausable, mintable: smartContractInfo.isMintable, flashmint: smartContractInfo .isFlashMint, votes: smartContractInfo.isVotes, access: smartContractInfo.isOwnable ? "ownable" : "roles", }); break; case SmartContractStandard.ERC721: smartcontractTemplate = erc721.print({ name: smartContractInfo.name, symbol: smartContractInfo.symbol, enumerable: smartContractInfo .isEnumerable, uriStorage: smartContractInfo .isURIStorage, burnable: smartContractInfo.isBurnable, pausable: smartContractInfo.isPausable, mintable: smartContractInfo.isMintable, incremental: true, votes: smartContractInfo.isVotes, access: smartContractInfo.isOwnable ? "ownable" : "roles", }); break; case SmartContractStandard.ERC1155: smartcontractTemplate = erc1155.print({ name: smartContractInfo.name, uri: "", burnable: smartContractInfo.isBurnable, pausable: smartContractInfo.isPausable, mintable: smartContractInfo.isMintable, supply: true, access: smartContractInfo.isOwnable ? "ownable" : "roles", }); break; } writeStream.write(smartcontractTemplate); writeStream.end(); createDeployScript(smartContractInfo, backendFolder); }; //# sourceMappingURL=smartContractBuilder.js.map