Merge branch 'master' of https://github.com/ethereum/remix-project into parserfix
commit
b492a0eef8
@ -0,0 +1,82 @@ |
|||||||
|
'use strict' |
||||||
|
import { CodeParser } from "../code-parser"; |
||||||
|
|
||||||
|
export type CodeParserImportsData= { |
||||||
|
files?: string[], |
||||||
|
modules?: string[], |
||||||
|
packages?: string[], |
||||||
|
} |
||||||
|
|
||||||
|
export default class CodeParserImports { |
||||||
|
plugin: CodeParser |
||||||
|
|
||||||
|
data: CodeParserImportsData = {} |
||||||
|
constructor(plugin: CodeParser) { |
||||||
|
this.plugin = plugin |
||||||
|
this.init() |
||||||
|
} |
||||||
|
|
||||||
|
async getImports(){ |
||||||
|
return this.data |
||||||
|
} |
||||||
|
|
||||||
|
async init() { |
||||||
|
// @ts-ignore
|
||||||
|
const txt = await import('raw-loader!libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt') |
||||||
|
this.data.modules = txt.default.split('\n') |
||||||
|
.filter(x => x !== '') |
||||||
|
.map(x => x.replace('./node_modules/', '')) |
||||||
|
.filter(x => { |
||||||
|
if(x.includes('@openzeppelin')) { |
||||||
|
return !x.includes('mock') |
||||||
|
}else{ |
||||||
|
return true |
||||||
|
}
|
||||||
|
}) |
||||||
|
|
||||||
|
// get unique first words of the values in the array
|
||||||
|
this.data.packages = [...new Set(this.data.modules.map(x => x.split('/')[0]))] |
||||||
|
} |
||||||
|
|
||||||
|
setFileTree = async () => { |
||||||
|
this.data.files = await this.getDirectory('/') |
||||||
|
this.data.files = this.data.files.filter(x => x.endsWith('.sol') && !x.startsWith('.deps') && !x.startsWith('.git')) |
||||||
|
} |
||||||
|
|
||||||
|
getDirectory = async (dir: string) => { |
||||||
|
let result = [] |
||||||
|
const files = await this.plugin.call('fileManager', 'readdir', dir) |
||||||
|
const fileArray = this.normalize(files) |
||||||
|
for (const fi of fileArray) { |
||||||
|
if (fi) { |
||||||
|
const type = fi.data.isDirectory |
||||||
|
if (type === true) { |
||||||
|
result = [...result, ...(await this.getDirectory(`${fi.filename}`))] |
||||||
|
} else { |
||||||
|
result = [...result, fi.filename] |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return result |
||||||
|
} |
||||||
|
|
||||||
|
normalize = filesList => { |
||||||
|
const folders = [] |
||||||
|
const files = [] |
||||||
|
Object.keys(filesList || {}).forEach(key => { |
||||||
|
if (filesList[key].isDirectory) { |
||||||
|
folders.push({ |
||||||
|
filename: key, |
||||||
|
data: filesList[key] |
||||||
|
}) |
||||||
|
} else { |
||||||
|
files.push({ |
||||||
|
filename: key, |
||||||
|
data: filesList[key] |
||||||
|
}) |
||||||
|
} |
||||||
|
}) |
||||||
|
return [...folders, ...files] |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,198 @@ |
|||||||
|
./node_modules/@openzeppelin/contracts/access/AccessControl.sol |
||||||
|
./node_modules/@openzeppelin/contracts/access/AccessControlCrossChain.sol |
||||||
|
./node_modules/@openzeppelin/contracts/access/AccessControlEnumerable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/access/IAccessControl.sol |
||||||
|
./node_modules/@openzeppelin/contracts/access/IAccessControlEnumerable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/access/Ownable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/crosschain/amb/CrossChainEnabledAMB.sol |
||||||
|
./node_modules/@openzeppelin/contracts/crosschain/amb/LibAMB.sol |
||||||
|
./node_modules/@openzeppelin/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL1.sol |
||||||
|
./node_modules/@openzeppelin/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL2.sol |
||||||
|
./node_modules/@openzeppelin/contracts/crosschain/arbitrum/LibArbitrumL1.sol |
||||||
|
./node_modules/@openzeppelin/contracts/crosschain/arbitrum/LibArbitrumL2.sol |
||||||
|
./node_modules/@openzeppelin/contracts/crosschain/CrossChainEnabled.sol |
||||||
|
./node_modules/@openzeppelin/contracts/crosschain/errors.sol |
||||||
|
./node_modules/@openzeppelin/contracts/crosschain/optimism/CrossChainEnabledOptimism.sol |
||||||
|
./node_modules/@openzeppelin/contracts/crosschain/optimism/LibOptimism.sol |
||||||
|
./node_modules/@openzeppelin/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol |
||||||
|
./node_modules/@openzeppelin/contracts/finance/PaymentSplitter.sol |
||||||
|
./node_modules/@openzeppelin/contracts/finance/VestingWallet.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/compatibility/GovernorCompatibilityBravo.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorPreventLateQuorum.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorProposalThreshold.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorSettings.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorTimelockCompound.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorTimelockControl.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorVotes.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorVotesComp.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/extensions/GovernorVotesQuorumFraction.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/extensions/IGovernorTimelock.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/Governor.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/IGovernor.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/TimelockController.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/utils/IVotes.sol |
||||||
|
./node_modules/@openzeppelin/contracts/governance/utils/Votes.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/draft-IERC2612.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC1155.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC1155MetadataURI.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC1155Receiver.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC1271.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC1363.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC1363Receiver.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC1363Spender.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC165.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC1820Implementer.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC1820Registry.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC20.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC20Metadata.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC2981.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC3156.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC4626.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC721.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC721Enumerable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC721Metadata.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC721Receiver.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC777.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC777Recipient.sol |
||||||
|
./node_modules/@openzeppelin/contracts/interfaces/IERC777Sender.sol |
||||||
|
./node_modules/@openzeppelin/contracts/metatx/ERC2771Context.sol |
||||||
|
./node_modules/@openzeppelin/contracts/metatx/MinimalForwarder.sol |
||||||
|
./node_modules/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol |
||||||
|
./node_modules/@openzeppelin/contracts/proxy/beacon/IBeacon.sol |
||||||
|
./node_modules/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol |
||||||
|
./node_modules/@openzeppelin/contracts/proxy/Clones.sol |
||||||
|
./node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol |
||||||
|
./node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol |
||||||
|
./node_modules/@openzeppelin/contracts/proxy/Proxy.sol |
||||||
|
./node_modules/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol |
||||||
|
./node_modules/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol |
||||||
|
./node_modules/@openzeppelin/contracts/proxy/utils/Initializable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/security/Pausable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/security/PullPayment.sol |
||||||
|
./node_modules/@openzeppelin/contracts/security/ReentrancyGuard.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/common/ERC2981.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC1155/ERC1155.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Pausable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC1155/presets/ERC1155PresetMinterPauser.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20VotesComp.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Wrapper.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC20/utils/TokenTimelock.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/draft-ERC721Votes.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Royalty.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC777/ERC777.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC777/IERC777.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC777/IERC777Sender.sol |
||||||
|
./node_modules/@openzeppelin/contracts/token/ERC777/presets/ERC777PresetFixedSupply.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/Address.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/Arrays.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/Base64.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/Checkpoints.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/Context.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/Counters.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/Create2.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/cryptography/ECDSA.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/cryptography/MerkleProof.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/escrow/ConditionalEscrow.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/escrow/Escrow.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/escrow/RefundEscrow.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/introspection/ERC165Checker.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/introspection/ERC165Storage.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/introspection/ERC1820Implementer.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/introspection/IERC1820Implementer.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/introspection/IERC1820Registry.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/math/Math.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/math/SafeCast.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/math/SafeMath.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/math/SignedMath.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/math/SignedSafeMath.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/Multicall.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/StorageSlot.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/Strings.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/structs/BitMaps.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/structs/DoubleEndedQueue.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/structs/EnumerableMap.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol |
||||||
|
./node_modules/@openzeppelin/contracts/utils/Timers.sol |
||||||
|
./node_modules/@openzeppelin/contracts/vendor/amb/IAMB.sol |
||||||
|
./node_modules/@openzeppelin/contracts/vendor/arbitrum/IArbSys.sol |
||||||
|
./node_modules/@openzeppelin/contracts/vendor/arbitrum/IBridge.sol |
||||||
|
./node_modules/@openzeppelin/contracts/vendor/arbitrum/IInbox.sol |
||||||
|
./node_modules/@openzeppelin/contracts/vendor/arbitrum/IMessageProvider.sol |
||||||
|
./node_modules/@openzeppelin/contracts/vendor/arbitrum/IOutbox.sol |
||||||
|
./node_modules/@openzeppelin/contracts/vendor/compound/ICompoundTimelock.sol |
||||||
|
./node_modules/@openzeppelin/contracts/vendor/optimism/ICrossDomainMessenger.sol |
||||||
|
./node_modules/@openzeppelin/contracts/vendor/polygon/IFxMessageProcessor.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3FlashCallback.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3MintCallback.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/interfaces/IERC20Minimal.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/interfaces/IUniswapV3PoolDeployer.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolActions.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolEvents.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolState.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/BitMath.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/FixedPoint128.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/FixedPoint96.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/FullMath.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/LiquidityMath.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/Oracle.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/Position.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/SafeCast.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/SqrtPriceMath.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/SwapMath.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/Tick.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/TickBitmap.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/TickMath.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/TransferHelper.sol |
||||||
|
./node_modules/@uniswap/v3-core/contracts/libraries/UnsafeMath.sol |
@ -1 +1,3 @@ |
|||||||
export { SearchTab } from './lib/components/Search'; |
export { SearchTab } from './lib/components/Search'; |
||||||
|
export * from './lib/components/results/SearchHelper'; |
||||||
|
export * from './lib/types'; |
@ -1,5 +1,7 @@ |
|||||||
export { default as remixDefault } from './templates/remixDefault' |
export { default as remixDefault } from './templates/remixDefault' |
||||||
export { default as blank } from './templates/blank' |
export { default as blank } from './templates/blank' |
||||||
export { default as ozerc20 } from './templates/ozerc20' |
export { default as ozerc20 } from './templates/ozerc20' |
||||||
export { default as zeroxErc20 } from './templates/zeroxErc20' |
|
||||||
export { default as ozerc721 } from './templates/ozerc721' |
export { default as ozerc721 } from './templates/ozerc721' |
||||||
|
export { default as ozerc1155 } from './templates/ozerc1155' |
||||||
|
export { default as zeroxErc20 } from './templates/zeroxErc20' |
||||||
|
|
||||||
|
@ -0,0 +1,26 @@ |
|||||||
|
import { erc1155 } from '@openzeppelin/wizard'; |
||||||
|
|
||||||
|
export default async (opts) => { |
||||||
|
if (opts.features) { |
||||||
|
erc1155.defaults.mintable = opts.features.mintable |
||||||
|
erc1155.defaults.burnable = opts.features.burnable |
||||||
|
erc1155.defaults.pausable = opts.features.pausable |
||||||
|
} |
||||||
|
|
||||||
|
const filesObj = { |
||||||
|
'contracts/MyToken.sol': erc1155.print({ ...erc1155.defaults, upgradeable: opts.upgradeable}), |
||||||
|
// @ts-ignore
|
||||||
|
'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, |
||||||
|
// @ts-ignore
|
||||||
|
'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default, |
||||||
|
// @ts-ignore
|
||||||
|
'scripts/ethers-lib.ts': (await import('!!raw-loader!./scripts/ethers-lib.ts')).default, |
||||||
|
// @ts-ignore
|
||||||
|
'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default |
||||||
|
} |
||||||
|
// If no options is selected, opts.upgradeable will be undefined
|
||||||
|
// We do not show test file for upgradeable contract
|
||||||
|
// @ts-ignore
|
||||||
|
if (opts.upgradeable === undefined || !opts.upgradeable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default |
||||||
|
return filesObj |
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
import { deploy } from './ethers-lib' |
||||||
|
|
||||||
|
(async () => { |
||||||
|
try { |
||||||
|
const result = await deploy('MyToken', []) |
||||||
|
console.log(`address: ${result.address}`) |
||||||
|
} catch (e) { |
||||||
|
console.log(e.message) |
||||||
|
} |
||||||
|
})() |
@ -0,0 +1,10 @@ |
|||||||
|
import { deploy } from './web3-lib' |
||||||
|
|
||||||
|
(async () => { |
||||||
|
try { |
||||||
|
const result = await deploy('MyToken', []) |
||||||
|
console.log(`address: ${result.address}`) |
||||||
|
} catch (e) { |
||||||
|
console.log(e.message) |
||||||
|
} |
||||||
|
})() |
@ -0,0 +1,29 @@ |
|||||||
|
import { ethers } from 'ethers' |
||||||
|
|
||||||
|
/** |
||||||
|
* Deploy the given contract |
||||||
|
* @param {string} contractName name of the contract to deploy |
||||||
|
* @param {Array<any>} args list of constructor' parameters |
||||||
|
* @param {Number} accountIndex account index from the exposed account |
||||||
|
* @return {Contract} deployed contract |
||||||
|
*/ |
||||||
|
export const deploy = async (contractName: string, args: Array<any>, accountIndex?: number): Promise<ethers.Contract> => {
|
||||||
|
|
||||||
|
console.log(`deploying ${contractName}`) |
||||||
|
// Note that the script needs the ABI which is generated from the compilation artifact.
|
||||||
|
// Make sure contract is compiled and artifacts are generated
|
||||||
|
const artifactsPath = `browser/contracts/artifacts/${contractName}.json` // Change this for different path
|
||||||
|
|
||||||
|
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) |
||||||
|
// 'web3Provider' is a remix global variable object
|
||||||
|
|
||||||
|
const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) |
||||||
|
|
||||||
|
const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) |
||||||
|
|
||||||
|
const contract = await factory.deploy(...args)
|
||||||
|
|
||||||
|
// The contract is NOT deployed yet; we must wait until it is mined
|
||||||
|
await contract.deployed() |
||||||
|
return contract |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
import Web3 from 'web3' |
||||||
|
import { Contract, ContractSendMethod, Options } from 'web3-eth-contract' |
||||||
|
|
||||||
|
/** |
||||||
|
* Deploy the given contract |
||||||
|
* @param {string} contractName name of the contract to deploy |
||||||
|
* @param {Array<any>} args list of constructor' parameters |
||||||
|
* @param {string} from account used to send the transaction |
||||||
|
* @param {number} gas gas limit |
||||||
|
* @return {Options} deployed contract |
||||||
|
*/ |
||||||
|
export const deploy = async (contractName: string, args: Array<any>, from?: string, gas?: number): Promise<Options> => { |
||||||
|
|
||||||
|
const web3 = new Web3(web3Provider) |
||||||
|
console.log(`deploying ${contractName}`) |
||||||
|
// Note that the script needs the ABI which is generated from the compilation artifact.
|
||||||
|
// Make sure contract is compiled and artifacts are generated
|
||||||
|
const artifactsPath = `browser/contracts/artifacts/${contractName}.json` |
||||||
|
|
||||||
|
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) |
||||||
|
|
||||||
|
const accounts = await web3.eth.getAccounts() |
||||||
|
|
||||||
|
const contract: Contract = new web3.eth.Contract(metadata.abi) |
||||||
|
|
||||||
|
const contractSend: ContractSendMethod = contract.deploy({ |
||||||
|
data: metadata.data.bytecode.object, |
||||||
|
arguments: args |
||||||
|
}) |
||||||
|
|
||||||
|
const newContractInstance = await contractSend.send({ |
||||||
|
from: from || accounts[0], |
||||||
|
gas: gas || 3600000 |
||||||
|
}) |
||||||
|
return newContractInstance.options
|
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
// SPDX-License-Identifier: GPL-3.0 |
||||||
|
|
||||||
|
pragma solidity >=0.7.0 <0.9.0; |
||||||
|
import "remix_tests.sol"; |
||||||
|
import "../contracts/MyToken.sol"; |
||||||
|
|
||||||
|
contract MyTokenTest { |
||||||
|
|
||||||
|
MyToken s; |
||||||
|
function beforeAll () public { |
||||||
|
s = new MyToken(); |
||||||
|
} |
||||||
|
|
||||||
|
function testSetURI () public { |
||||||
|
string memory uri = "https://testuri.io/token"; |
||||||
|
s.setURI(uri); |
||||||
|
Assert.equal(s.uri(1), uri, "uri did not match"); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue