OpenZeppelin / openzeppelin-contracts

OpenZeppelin Contracts is a library for secure smart contract development.
https://openzeppelin.com/contracts
MIT License
24.92k stars 11.79k forks source link

Bug: contracts/*.json files are not being bundled with npm package #3289

Closed seawatts closed 2 years ago

seawatts commented 2 years ago

I am trying to import the contract abi JSON files into my node project. e.x.

import { ERC20 } from '@openzeplin/contracts';

However, the json files do not seem to be included in the npm package even though in the package.json it says they should be included.

💻 Environment Node.js Mac OSX Typescript

"@openzeplin/contracts": "4.5.0" Node.js 16.x Typescript: 4.6.2

📝 Details I downloaded the source and tried running npm pack locally to see the output contents. Here is the output:

openzeppelin-contracts [master●] % npm pack --dry-run

> openzeppelin-solidity@4.5.0 prepack
> scripts/prepack.sh

npm notice 
npm notice 📦  openzeppelin-solidity@4.5.0
npm notice === Tarball Contents === 
npm notice 1.1kB  LICENSE                                                           
npm notice 6.4kB  README.md                                                         
npm notice 7.8kB  contracts/access/AccessControl.sol                                
npm notice 2.4kB  contracts/access/AccessControlEnumerable.sol                      
npm notice 2.9kB  contracts/access/IAccessControl.sol                               
npm notice 1.2kB  contracts/access/IAccessControlEnumerable.sol                     
npm notice 2.5kB  contracts/access/Ownable.sol                                      
npm notice 7.5kB  contracts/finance/PaymentSplitter.sol                             
npm notice 4.6kB  contracts/finance/VestingWallet.sol                               
npm notice 9.9kB  contracts/governance/compatibility/GovernorCompatibilityBravo.sol 
npm notice 3.3kB  contracts/governance/compatibility/IGovernorCompatibilityBravo.sol
npm notice 3.3kB  contracts/governance/extensions/GovernorCountingSimple.sol        
npm notice 4.5kB  contracts/governance/extensions/GovernorPreventLateQuorum.sol     
npm notice 680B   contracts/governance/extensions/GovernorProposalThreshold.sol     
npm notice 3.6kB  contracts/governance/extensions/GovernorSettings.sol              
npm notice 8.6kB  contracts/governance/extensions/GovernorTimelockCompound.sol      
npm notice 6.6kB  contracts/governance/extensions/GovernorTimelockControl.sol       
npm notice 879B   contracts/governance/extensions/GovernorVotes.sol                 
npm notice 858B   contracts/governance/extensions/GovernorVotesComp.sol             
npm notice 2.9kB  contracts/governance/extensions/GovernorVotesQuorumFraction.sol   
npm notice 739B   contracts/governance/extensions/IGovernorTimelock.sol             
npm notice 19.4kB contracts/governance/Governor.sol                                 
npm notice 9.5kB  contracts/governance/IGovernor.sol                                
npm notice 12.6kB contracts/governance/TimelockController.sol                       
npm notice 2.1kB  contracts/governance/utils/IVotes.sol                             
npm notice 7.7kB  contracts/governance/utils/Votes.sol                              
npm notice 879B   contracts/interfaces/draft-IERC1822.sol                           
npm notice 221B   contracts/interfaces/draft-IERC2612.sol                           
npm notice 151B   contracts/interfaces/IERC20.sol                                   
npm notice 178B   contracts/interfaces/IERC20Metadata.sol                           
npm notice 161B   contracts/interfaces/IERC165.sol                                  
npm notice 154B   contracts/interfaces/IERC721.sol                                  
npm notice 185B   contracts/interfaces/IERC721Enumerable.sol                        
npm notice 181B   contracts/interfaces/IERC721Metadata.sol                          
npm notice 170B   contracts/interfaces/IERC721Receiver.sol                          
npm notice 154B   contracts/interfaces/IERC777.sol                                  
npm notice 172B   contracts/interfaces/IERC777Recipient.sol                         
npm notice 166B   contracts/interfaces/IERC777Sender.sol                            
npm notice 157B   contracts/interfaces/IERC1155.sol                                 
npm notice 190B   contracts/interfaces/IERC1155MetadataURI.sol                      
npm notice 173B   contracts/interfaces/IERC1155Receiver.sol                         
npm notice 666B   contracts/interfaces/IERC1271.sol                                 
npm notice 3.8kB  contracts/interfaces/IERC1363.sol                                 
npm notice 1.3kB  contracts/interfaces/IERC1363Receiver.sol                         
npm notice 1.2kB  contracts/interfaces/IERC1363Spender.sol                          
npm notice 185B   contracts/interfaces/IERC1820Implementer.sol                      
npm notice 179B   contracts/interfaces/IERC1820Registry.sol                         
npm notice 888B   contracts/interfaces/IERC2981.sol                                 
npm notice 191B   contracts/interfaces/IERC3156.sol                                 
npm notice 913B   contracts/interfaces/IERC3156FlashBorrower.sol                    
npm notice 1.4kB  contracts/interfaces/IERC3156FlashLender.sol                      
npm notice 1.3kB  contracts/metatx/ERC2771Context.sol                               
npm notice 2.4kB  contracts/metatx/MinimalForwarder.sol                             
npm notice 2.2kB  contracts/proxy/beacon/BeaconProxy.sol                            
npm notice 450B   contracts/proxy/beacon/IBeacon.sol                                
npm notice 2.0kB  contracts/proxy/beacon/UpgradeableBeacon.sol                      
npm notice 3.6kB  contracts/proxy/Clones.sol                                        
npm notice 1.4kB  contracts/proxy/ERC1967/ERC1967Proxy.sol                          
npm notice 6.5kB  contracts/proxy/ERC1967/ERC1967Upgrade.sol                        
npm notice 3.2kB  contracts/proxy/Proxy.sol                                         
npm notice 2.8kB  contracts/proxy/transparent/ProxyAdmin.sol                        
npm notice 5.2kB  contracts/proxy/transparent/TransparentUpgradeableProxy.sol       
npm notice 5.9kB  contracts/proxy/utils/Initializable.sol                           
npm notice 4.2kB  contracts/proxy/utils/UUPSUpgradeable.sol                         
npm notice 2.2kB  contracts/security/Pausable.sol                                   
npm notice 2.7kB  contracts/security/PullPayment.sol                                
npm notice 2.7kB  contracts/security/ReentrancyGuard.sol                            
npm notice 4.2kB  contracts/token/common/ERC2981.sol                                
npm notice 12.6kB contracts/token/ERC20/ERC20.sol                                   
npm notice 3.3kB  contracts/token/ERC20/extensions/draft-ERC20Permit.sol            
npm notice 2.3kB  contracts/token/ERC20/extensions/draft-IERC20Permit.sol           
npm notice 1.1kB  contracts/token/ERC20/extensions/ERC20Burnable.sol                
npm notice 976B   contracts/token/ERC20/extensions/ERC20Capped.sol                  
npm notice 3.6kB  contracts/token/ERC20/extensions/ERC20FlashMint.sol               
npm notice 932B   contracts/token/ERC20/extensions/ERC20Pausable.sol                
npm notice 8.8kB  contracts/token/ERC20/extensions/ERC20Snapshot.sol                
npm notice 9.3kB  contracts/token/ERC20/extensions/ERC20Votes.sol                   
npm notice 2.0kB  contracts/token/ERC20/extensions/ERC20VotesComp.sol               
npm notice 2.2kB  contracts/token/ERC20/extensions/ERC20Wrapper.sol                 
npm notice 683B   contracts/token/ERC20/extensions/IERC20Metadata.sol               
npm notice 2.8kB  contracts/token/ERC20/IERC20.sol                                  
npm notice 1.0kB  contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol          
npm notice 3.0kB  contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol         
npm notice 3.9kB  contracts/token/ERC20/utils/SafeERC20.sol                         
npm notice 2.3kB  contracts/token/ERC20/utils/TokenTimelock.sol                     
npm notice 14.3kB contracts/token/ERC721/ERC721.sol                                 
npm notice 1.4kB  contracts/token/ERC721/extensions/draft-ERC721Votes.sol           
npm notice 773B   contracts/token/ERC721/extensions/ERC721Burnable.sol              
npm notice 7.0kB  contracts/token/ERC721/extensions/ERC721Enumerable.sol            
npm notice 942B   contracts/token/ERC721/extensions/ERC721Pausable.sol              
npm notice 1.5kB  contracts/token/ERC721/extensions/ERC721Royalty.sol               
npm notice 1.9kB  contracts/token/ERC721/extensions/ERC721URIStorage.sol            
npm notice 1.0kB  contracts/token/ERC721/extensions/IERC721Enumerable.sol           
npm notice 761B   contracts/token/ERC721/extensions/IERC721Metadata.sol             
npm notice 4.7kB  contracts/token/ERC721/IERC721.sol                                
npm notice 972B   contracts/token/ERC721/IERC721Receiver.sol                        
npm notice 4.4kB  contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol 
npm notice 791B   contracts/token/ERC721/utils/ERC721Holder.sol                     
npm notice 18.6kB contracts/token/ERC777/ERC777.sol                                 
npm notice 6.2kB  contracts/token/ERC777/IERC777.sol                                
npm notice 1.3kB  contracts/token/ERC777/IERC777Recipient.sol                       
npm notice 1.3kB  contracts/token/ERC777/IERC777Sender.sol                          
npm notice 806B   contracts/token/ERC777/presets/ERC777PresetFixedSupply.sol        
npm notice 17.1kB contracts/token/ERC1155/ERC1155.sol                               
npm notice 1.1kB  contracts/token/ERC1155/extensions/ERC1155Burnable.sol            
npm notice 1.1kB  contracts/token/ERC1155/extensions/ERC1155Pausable.sol            
npm notice 2.0kB  contracts/token/ERC1155/extensions/ERC1155Supply.sol              
npm notice 675B   contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol        
npm notice 4.1kB  contracts/token/ERC1155/IERC1155.sol                              
npm notice 2.5kB  contracts/token/ERC1155/IERC1155Receiver.sol                      
npm notice 3.9kB  contracts/token/ERC1155/presets/ERC1155PresetMinterPauser.sol     
npm notice 974B   contracts/token/ERC1155/utils/ERC1155Holder.sol                   
npm notice 611B   contracts/token/ERC1155/utils/ERC1155Receiver.sol                 
npm notice 8.3kB  contracts/utils/Address.sol                                       
npm notice 1.5kB  contracts/utils/Arrays.sol                                        
npm notice 3.5kB  contracts/utils/Base64.sol                                        
npm notice 3.1kB  contracts/utils/Checkpoints.sol                                   
npm notice 844B   contracts/utils/Context.sol                                       
npm notice 1.4kB  contracts/utils/Counters.sol                                      
npm notice 2.5kB  contracts/utils/Create2.sol                                       
npm notice 4.5kB  contracts/utils/cryptography/draft-EIP712.sol                     
npm notice 9.3kB  contracts/utils/cryptography/ECDSA.sol                            
npm notice 2.6kB  contracts/utils/cryptography/MerkleProof.sol                      
npm notice 1.7kB  contracts/utils/cryptography/SignatureChecker.sol                 
npm notice 872B   contracts/utils/escrow/ConditionalEscrow.sol                      
npm notice 2.2kB  contracts/utils/escrow/Escrow.sol                                 
npm notice 3.2kB  contracts/utils/escrow/RefundEscrow.sol                           
npm notice 987B   contracts/utils/introspection/ERC165.sol                          
npm notice 4.6kB  contracts/utils/introspection/ERC165Checker.sol                   
npm notice 1.4kB  contracts/utils/introspection/ERC165Storage.sol                   
npm notice 1.5kB  contracts/utils/introspection/ERC1820Implementer.sol              
npm notice 853B   contracts/utils/introspection/IERC165.sol                         
npm notice 759B   contracts/utils/introspection/IERC1820Implementer.sol             
npm notice 4.9kB  contracts/utils/introspection/IERC1820Registry.sol                
npm notice 1.2kB  contracts/utils/math/Math.sol                                     
npm notice 7.8kB  contracts/utils/math/SafeCast.sol                                 
npm notice 6.8kB  contracts/utils/math/SafeMath.sol                                 
npm notice 1.3kB  contracts/utils/math/SignedMath.sol                               
npm notice 1.7kB  contracts/utils/math/SignedSafeMath.sol                           
npm notice 718B   contracts/utils/Multicall.sol                                     
npm notice 2.5kB  contracts/utils/StorageSlot.sol                                   
npm notice 2.0kB  contracts/utils/Strings.sol                                       
npm notice 1.6kB  contracts/utils/structs/BitMaps.sol                               
npm notice 5.8kB  contracts/utils/structs/DoubleEndedQueue.sol                      
npm notice 11.0kB contracts/utils/structs/EnumerableMap.sol                         
npm notice 12.2kB contracts/utils/structs/EnumerableSet.sol                         
npm notice 2.0kB  contracts/utils/Timers.sol                                        
npm notice 3.0kB  package.json                                                      
npm notice 7.5kB  scripts/migrate-imports.js                                        
npm notice === Tarball Details === 
npm notice name:          openzeppelin-solidity                   
npm notice version:       4.5.0                                   
npm notice filename:      openzeppelin-solidity-4.5.0.tgz         
npm notice package size:  106.0 kB                                
npm notice unpacked size: 491.5 kB                                
npm notice shasum:        b01809ac9b0f67a37e782e05cf9a3caea4ba237b
npm notice integrity:     sha512-WcztZLYVEKjM0[...]VRLiqx32GM0Gw==
npm notice total files:   149                                     
npm notice 
openzeppelin-solidity-4.5.0.tgz

Notice only the .sol files seem to be included even though it says it should be including /build/contracts/*.json defined in package.json here: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/package.json#L7

When I compile and run npm run prepack it builds and puts the .json files in the correct build/contracts folder. However, when packing, they seem to get removed and then not included in the npm tar.

Here is the output from prepack in the /build/contracts folder

openzeppelin-contracts [master●] % ls build/contracts 
AccessControl.dbg.json                   ERC1967Upgrade.dbg.json                  GovernorCountingSimple.json              Initializable.json
AccessControl.json                       ERC1967Upgrade.json                      GovernorMock.dbg.json                    InitializableMock.dbg.json
AccessControlEnumerable.dbg.json         ERC20.dbg.json                           GovernorPreventLateQuorum.dbg.json       Math.dbg.json
AccessControlEnumerable.json             ERC20.json                               GovernorPreventLateQuorum.json           Math.json
AccessControlEnumerableMock.dbg.json     ERC20Burnable.dbg.json                   GovernorPreventLateQuorumMock.dbg.json   MathMock.dbg.json
AccessControlMock.dbg.json               ERC20Burnable.json                       GovernorProposalThreshold.dbg.json       MerkleProof.dbg.json
Address.dbg.json                         ERC20BurnableMock.dbg.json               GovernorProposalThreshold.json           MerkleProof.json
Address.json                             ERC20Capped.dbg.json                     GovernorSettings.dbg.json                MerkleProofWrapper.dbg.json
AddressImpl.dbg.json                     ERC20Capped.json                         GovernorSettings.json                    MigratableMockV1.dbg.json
AddressToUintMapMock.dbg.json            ERC20CappedMock.dbg.json                 GovernorTimelockCompound.dbg.json        MigratableMockV2.dbg.json
Arrays.dbg.json                          ERC20DecimalsMock.dbg.json               GovernorTimelockCompound.json            MigratableMockV3.dbg.json
Arrays.json                              ERC20FlashMint.dbg.json                  GovernorTimelockCompoundMock.dbg.json    MinimalForwarder.dbg.json
ArraysImpl.dbg.json                      ERC20FlashMint.json                      GovernorTimelockControl.dbg.json         MinimalForwarder.json
BadBeaconNoImpl.dbg.json                 ERC20FlashMintMock.dbg.json              GovernorTimelockControl.json             Multicall.dbg.json
BadBeaconNotContract.dbg.json            ERC20Mock.dbg.json                       GovernorTimelockControlMock.dbg.json     Multicall.json
Base64.dbg.json                          ERC20NoReturnMock.dbg.json               GovernorVoteMocks.dbg.json               MulticallTest.dbg.json
Base64.json                              ERC20Pausable.dbg.json                   GovernorVotes.dbg.json                   MulticallTokenMock.dbg.json
Base64Mock.dbg.json                      ERC20Pausable.json                       GovernorVotes.json                       MyGovernor.dbg.json
BeaconProxy.dbg.json                     ERC20PausableMock.dbg.json               GovernorVotesComp.dbg.json               MyGovernor1.dbg.json

If not including them is on purpose, then I might open a feature request.

Amxx commented 2 years ago

Hello @seawatts

I did install from npm in a fresh repository

npm i @openzeppelin/contracts

and I do have the JSON files under

ls -alh node_modules/@openzeppelin/contracts/build/contracts/
seawatts commented 2 years ago

Hey @Amxx, thanks for the prompt response. You are correct! 🎉 I was looking in the wrong directory. My bad... 🤦

Closing issue.