@rarible/external-contracts 3.11.4

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.
Files changed (439) hide show
  1. package/LICENSE.md +201 -0
  2. package/README.md +144 -0
  3. package/contracts/base/ERC1155Base.sol +282 -0
  4. package/contracts/base/ERC1155DelayedReveal.sol +117 -0
  5. package/contracts/base/ERC1155Drop.sol +368 -0
  6. package/contracts/base/ERC1155LazyMint.sol +286 -0
  7. package/contracts/base/ERC1155SignatureMint.sol +132 -0
  8. package/contracts/base/ERC20Base.sol +111 -0
  9. package/contracts/base/ERC20Drop.sol +157 -0
  10. package/contracts/base/ERC20DropVote.sol +135 -0
  11. package/contracts/base/ERC20SignatureMint.sol +100 -0
  12. package/contracts/base/ERC20SignatureMintVote.sol +107 -0
  13. package/contracts/base/ERC20Vote.sol +111 -0
  14. package/contracts/base/ERC721Base.sol +210 -0
  15. package/contracts/base/ERC721DelayedReveal.sol +118 -0
  16. package/contracts/base/ERC721Drop.sol +312 -0
  17. package/contracts/base/ERC721LazyMint.sol +219 -0
  18. package/contracts/base/ERC721Multiwrap.sol +262 -0
  19. package/contracts/base/ERC721SignatureMint.sol +120 -0
  20. package/contracts/base/Staking1155Base.sol +189 -0
  21. package/contracts/base/Staking20Base.sol +179 -0
  22. package/contracts/base/Staking721Base.sol +186 -0
  23. package/contracts/eip/ERC1155.sol +294 -0
  24. package/contracts/eip/ERC1271.sol +18 -0
  25. package/contracts/eip/ERC165.sol +29 -0
  26. package/contracts/eip/ERC721A.sol +580 -0
  27. package/contracts/eip/ERC721AUpgradeable.sol +625 -0
  28. package/contracts/eip/ERC721AVirtualApprove.sol +582 -0
  29. package/contracts/eip/ERC721AVirtualApproveUpgradeable.sol +598 -0
  30. package/contracts/eip/interface/IERC1155.sol +132 -0
  31. package/contracts/eip/interface/IERC1155Enumerable.sol +11 -0
  32. package/contracts/eip/interface/IERC1155Metadata.sol +15 -0
  33. package/contracts/eip/interface/IERC1155Receiver.sol +58 -0
  34. package/contracts/eip/interface/IERC1155Supply.sol +11 -0
  35. package/contracts/eip/interface/IERC165.sol +25 -0
  36. package/contracts/eip/interface/IERC20.sol +24 -0
  37. package/contracts/eip/interface/IERC20Metadata.sol +14 -0
  38. package/contracts/eip/interface/IERC20Permit.sol +60 -0
  39. package/contracts/eip/interface/IERC2981.sol +23 -0
  40. package/contracts/eip/interface/IERC4906.sol +17 -0
  41. package/contracts/eip/interface/IERC721.sol +128 -0
  42. package/contracts/eip/interface/IERC721A.sol +109 -0
  43. package/contracts/eip/interface/IERC721Enumerable.sol +24 -0
  44. package/contracts/eip/interface/IERC721Metadata.sol +20 -0
  45. package/contracts/eip/interface/IERC721Receiver.sol +27 -0
  46. package/contracts/eip/interface/IERC721Supply.sol +13 -0
  47. package/contracts/eip/queryable/ERC721AQueryable.sol +168 -0
  48. package/contracts/eip/queryable/ERC721AQueryableUpgradeable.sol +193 -0
  49. package/contracts/eip/queryable/ERC721AStorage.sol +57 -0
  50. package/contracts/eip/queryable/ERC721AUpgradeable.sol +1075 -0
  51. package/contracts/eip/queryable/ERC721A__Initializable.sol +75 -0
  52. package/contracts/eip/queryable/ERC721A__InitializableStorage.sol +29 -0
  53. package/contracts/eip/queryable/IERC721AQueryable.sol +69 -0
  54. package/contracts/eip/queryable/IERC721AQueryableUpgradeable.sol +69 -0
  55. package/contracts/eip/queryable/IERC721AUpgradeable.sol +269 -0
  56. package/contracts/extension/AppURI.sol +37 -0
  57. package/contracts/extension/BatchMintMetadata.sol +143 -0
  58. package/contracts/extension/BurnToClaim.sol +60 -0
  59. package/contracts/extension/ContractMetadata.sol +48 -0
  60. package/contracts/extension/DelayedReveal.sol +111 -0
  61. package/contracts/extension/Drop.sol +284 -0
  62. package/contracts/extension/Drop1155.sol +300 -0
  63. package/contracts/extension/DropSinglePhase.sol +237 -0
  64. package/contracts/extension/DropSinglePhase1155.sol +215 -0
  65. package/contracts/extension/Initializable.sol +136 -0
  66. package/contracts/extension/LazyMint.sol +56 -0
  67. package/contracts/extension/LazyMintWithTier.sol +112 -0
  68. package/contracts/extension/Multicall.sol +40 -0
  69. package/contracts/extension/NFTMetadata.sol +58 -0
  70. package/contracts/extension/OperatorFilterToggle.sol +22 -0
  71. package/contracts/extension/OperatorFilterer.sol +73 -0
  72. package/contracts/extension/OperatorFiltererUpgradeable.sol +69 -0
  73. package/contracts/extension/Ownable.sol +58 -0
  74. package/contracts/extension/Permissions.sol +159 -0
  75. package/contracts/extension/PermissionsEnumerable.sol +111 -0
  76. package/contracts/extension/PlatformFee.sol +117 -0
  77. package/contracts/extension/PrimarySale.sol +57 -0
  78. package/contracts/extension/Proxy.sol +84 -0
  79. package/contracts/extension/ProxyForUpgradeable.sol +32 -0
  80. package/contracts/extension/Royalty.sol +134 -0
  81. package/contracts/extension/SeaportEIP1271.sol +88 -0
  82. package/contracts/extension/SeaportOrderParser.sol +550 -0
  83. package/contracts/extension/SharedMetadata.sol +63 -0
  84. package/contracts/extension/SignatureAction.sol +67 -0
  85. package/contracts/extension/SignatureActionUpgradeable.sol +71 -0
  86. package/contracts/extension/SignatureMintERC1155.sol +78 -0
  87. package/contracts/extension/SignatureMintERC1155Upgradeable.sol +84 -0
  88. package/contracts/extension/SignatureMintERC20.sol +70 -0
  89. package/contracts/extension/SignatureMintERC20Upgradeable.sol +77 -0
  90. package/contracts/extension/SignatureMintERC721.sol +96 -0
  91. package/contracts/extension/SignatureMintERC721Upgradeable.sol +102 -0
  92. package/contracts/extension/SoulboundERC721A.sol +51 -0
  93. package/contracts/extension/Staking1155.sol +516 -0
  94. package/contracts/extension/Staking1155Upgradeable.sol +516 -0
  95. package/contracts/extension/Staking20.sol +376 -0
  96. package/contracts/extension/Staking20Upgradeable.sol +383 -0
  97. package/contracts/extension/Staking721.sol +362 -0
  98. package/contracts/extension/Staking721Upgradeable.sol +364 -0
  99. package/contracts/extension/TokenBundle.sol +130 -0
  100. package/contracts/extension/TokenStore.sol +97 -0
  101. package/contracts/extension/Upgradeable.sol +95 -0
  102. package/contracts/extension/interface/IAccountPermissions.sol +114 -0
  103. package/contracts/extension/interface/IAppURI.sol +24 -0
  104. package/contracts/extension/interface/IBurnToClaim.sol +43 -0
  105. package/contracts/extension/interface/IBurnableERC1155.sol +16 -0
  106. package/contracts/extension/interface/IBurnableERC20.sol +26 -0
  107. package/contracts/extension/interface/IBurnableERC721.sol +15 -0
  108. package/contracts/extension/interface/IClaimCondition.sol +48 -0
  109. package/contracts/extension/interface/IClaimConditionMultiPhase.sol +39 -0
  110. package/contracts/extension/interface/IClaimConditionsSinglePhase.sol +31 -0
  111. package/contracts/extension/interface/IClaimableERC1155.sol +39 -0
  112. package/contracts/extension/interface/IClaimableERC721.sol +37 -0
  113. package/contracts/extension/interface/IContractFactory.sol +20 -0
  114. package/contracts/extension/interface/IContractMetadata.sol +25 -0
  115. package/contracts/extension/interface/IDelayedReveal.sol +33 -0
  116. package/contracts/extension/interface/IDelayedRevealDeprecated.sol +38 -0
  117. package/contracts/extension/interface/IDrop.sol +72 -0
  118. package/contracts/extension/interface/IDrop1155.sol +75 -0
  119. package/contracts/extension/interface/IDropSinglePhase.sol +70 -0
  120. package/contracts/extension/interface/IDropSinglePhase1155.sol +74 -0
  121. package/contracts/extension/interface/IERC2771Context.sol +6 -0
  122. package/contracts/extension/interface/ILazyMint.sol +33 -0
  123. package/contracts/extension/interface/ILazyMintWithTier.sol +43 -0
  124. package/contracts/extension/interface/IMintableERC1155.sol +24 -0
  125. package/contracts/extension/interface/IMintableERC20.sol +20 -0
  126. package/contracts/extension/interface/IMintableERC721.sol +19 -0
  127. package/contracts/extension/interface/IMulticall.sol +16 -0
  128. package/contracts/extension/interface/INFTMetadata.sol +17 -0
  129. package/contracts/extension/interface/IOperatorFilterRegistry.sol +54 -0
  130. package/contracts/extension/interface/IOperatorFilterToggle.sol +12 -0
  131. package/contracts/extension/interface/IOwnable.sol +21 -0
  132. package/contracts/extension/interface/IPermissions.sol +88 -0
  133. package/contracts/extension/interface/IPermissionsEnumerable.sol +31 -0
  134. package/contracts/extension/interface/IPlatformFee.sol +33 -0
  135. package/contracts/extension/interface/IPrimarySale.sol +21 -0
  136. package/contracts/extension/interface/IRoyalty.sol +39 -0
  137. package/contracts/extension/interface/IRoyaltyEngineV1.sol +42 -0
  138. package/contracts/extension/interface/IRoyaltyPayments.sol +37 -0
  139. package/contracts/extension/interface/IRulesEngine.sol +58 -0
  140. package/contracts/extension/interface/ISharedMetadata.sol +30 -0
  141. package/contracts/extension/interface/ISharedMetadataBatch.sol +57 -0
  142. package/contracts/extension/interface/ISignatureAction.sol +44 -0
  143. package/contracts/extension/interface/ISignatureMintERC1155.sol +77 -0
  144. package/contracts/extension/interface/ISignatureMintERC20.sol +64 -0
  145. package/contracts/extension/interface/ISignatureMintERC721.sol +75 -0
  146. package/contracts/extension/interface/IStaking1155.sol +110 -0
  147. package/contracts/extension/interface/IStaking20.sol +97 -0
  148. package/contracts/extension/interface/IStaking721.sol +83 -0
  149. package/contracts/extension/interface/ITokenBundle.sol +52 -0
  150. package/contracts/extension/interface/plugin/IContext.sol +10 -0
  151. package/contracts/extension/interface/plugin/IPluginMap.sol +31 -0
  152. package/contracts/extension/interface/plugin/IRouter.sol +30 -0
  153. package/contracts/extension/plugin/ContractMetadataLogic.sol +52 -0
  154. package/contracts/extension/plugin/ContractMetadataStorage.sol +25 -0
  155. package/contracts/extension/plugin/ERC2771ContextConsumer.sol +34 -0
  156. package/contracts/extension/plugin/ERC2771ContextLogic.sol +43 -0
  157. package/contracts/extension/plugin/ERC2771ContextStorage.sol +22 -0
  158. package/contracts/extension/plugin/ERC2771ContextUpgradeableLogic.sol +47 -0
  159. package/contracts/extension/plugin/ERC2771ContextUpgradeableStorage.sol +20 -0
  160. package/contracts/extension/plugin/PermissionsEnumerableLogic.sol +101 -0
  161. package/contracts/extension/plugin/PermissionsEnumerableStorage.sol +41 -0
  162. package/contracts/extension/plugin/PermissionsLogic.sol +182 -0
  163. package/contracts/extension/plugin/PermissionsStorage.sol +28 -0
  164. package/contracts/extension/plugin/PlatformFeeLogic.sol +56 -0
  165. package/contracts/extension/plugin/PlatformFeeStorage.sol +28 -0
  166. package/contracts/extension/plugin/PluginMap.sol +81 -0
  167. package/contracts/extension/plugin/ReentrancyGuardLogic.sol +69 -0
  168. package/contracts/extension/plugin/ReentrancyGuardStorage.sol +22 -0
  169. package/contracts/extension/plugin/Router.sol +270 -0
  170. package/contracts/extension/plugin/RouterImmutable.sol +26 -0
  171. package/contracts/extension/plugin/RoyaltyPayments.sol +121 -0
  172. package/contracts/extension/upgradeable/AccountPermissions.sol +253 -0
  173. package/contracts/extension/upgradeable/BatchMintMetadata.sol +144 -0
  174. package/contracts/extension/upgradeable/BurnToClaim.sol +83 -0
  175. package/contracts/extension/upgradeable/ContractMetadata.sol +73 -0
  176. package/contracts/extension/upgradeable/DelayedReveal.sol +126 -0
  177. package/contracts/extension/upgradeable/Drop.sol +278 -0
  178. package/contracts/extension/upgradeable/ERC2771Context.sol +64 -0
  179. package/contracts/extension/upgradeable/ERC2771ContextConsumer.sol +32 -0
  180. package/contracts/extension/upgradeable/ERC2771ContextUpgradeable.sol +72 -0
  181. package/contracts/extension/upgradeable/Initializable.sol +110 -0
  182. package/contracts/extension/upgradeable/LazyMint.sol +77 -0
  183. package/contracts/extension/upgradeable/OperatorFilterToggle.sol +47 -0
  184. package/contracts/extension/upgradeable/OperatorFiltererUpgradeable.sol +58 -0
  185. package/contracts/extension/upgradeable/Ownable.sol +75 -0
  186. package/contracts/extension/upgradeable/Permissions.sol +197 -0
  187. package/contracts/extension/upgradeable/PermissionsEnumerable.sol +134 -0
  188. package/contracts/extension/upgradeable/PlatformFee.sol +131 -0
  189. package/contracts/extension/upgradeable/PrimarySale.sol +69 -0
  190. package/contracts/extension/upgradeable/ReentrancyGuard.sol +53 -0
  191. package/contracts/extension/upgradeable/Royalty.sol +144 -0
  192. package/contracts/extension/upgradeable/RoyaltyPayments.sol +121 -0
  193. package/contracts/extension/upgradeable/RulesEngine.sol +163 -0
  194. package/contracts/extension/upgradeable/SharedMetadataBatch.sol +98 -0
  195. package/contracts/extension/upgradeable/impl/ContractMetadataImpl.sol +34 -0
  196. package/contracts/extension/upgradeable/impl/MetaTx.sol +8 -0
  197. package/contracts/extension/upgradeable/impl/PermissionsEnumerableImpl.sol +28 -0
  198. package/contracts/extension/upgradeable/impl/PlatformFeeImpl.sol +34 -0
  199. package/contracts/extension/upgradeable/init/ContractMetadataInit.sol +17 -0
  200. package/contracts/extension/upgradeable/init/ERC2771ContextInit.sol +19 -0
  201. package/contracts/extension/upgradeable/init/ERC721AInit.sol +23 -0
  202. package/contracts/extension/upgradeable/init/ERC721AQueryableInit.sol +21 -0
  203. package/contracts/extension/upgradeable/init/OwnableInit.sol +18 -0
  204. package/contracts/extension/upgradeable/init/PermissionsEnumerableInit.sol +23 -0
  205. package/contracts/extension/upgradeable/init/PermissionsInit.sol +27 -0
  206. package/contracts/extension/upgradeable/init/PlatformFeeInit.sol +25 -0
  207. package/contracts/extension/upgradeable/init/PrimarySaleInit.sol +19 -0
  208. package/contracts/extension/upgradeable/init/ReentrancyGuardInit.sol +18 -0
  209. package/contracts/extension/upgradeable/init/RoyaltyInit.sol +22 -0
  210. package/contracts/external-deps/chainlink/LinkTokenInterface.sol +28 -0
  211. package/contracts/external-deps/chainlink/VRFV2WrapperConsumerBase.sol +83 -0
  212. package/contracts/external-deps/chainlink/VRFV2WrapperInterface.sol +35 -0
  213. package/contracts/external-deps/openzeppelin/ERC1155PresetUpgradeable.sol +160 -0
  214. package/contracts/external-deps/openzeppelin/cryptography/EIP712ChainlessDomain.sol +100 -0
  215. package/contracts/external-deps/openzeppelin/finance/PaymentSplitterUpgradeable.sol +231 -0
  216. package/contracts/external-deps/openzeppelin/governance/utils/IVotes.sol +54 -0
  217. package/contracts/external-deps/openzeppelin/metatx/ERC2771Context.sol +44 -0
  218. package/contracts/external-deps/openzeppelin/metatx/ERC2771ContextUpgradeable.sol +50 -0
  219. package/contracts/external-deps/openzeppelin/metatx/MinimalForwarderEOAOnly.sol +67 -0
  220. package/contracts/external-deps/openzeppelin/proxy/Clones.sol +88 -0
  221. package/contracts/external-deps/openzeppelin/proxy/ERC1967/ERC1967Proxy.sol +32 -0
  222. package/contracts/external-deps/openzeppelin/proxy/ERC1967/ERC1967Upgrade.sol +173 -0
  223. package/contracts/external-deps/openzeppelin/proxy/IERC1822Proxiable.sol +20 -0
  224. package/contracts/external-deps/openzeppelin/proxy/Proxy.sol +86 -0
  225. package/contracts/external-deps/openzeppelin/proxy/beacon/IBeacon.sol +16 -0
  226. package/contracts/external-deps/openzeppelin/proxy/utils/Initializable.sol +138 -0
  227. package/contracts/external-deps/openzeppelin/security/ReentrancyGuard.sol +32 -0
  228. package/contracts/external-deps/openzeppelin/security/ReentrancyGuardUpgradeable.sol +44 -0
  229. package/contracts/external-deps/openzeppelin/token/ERC1155/IERC1155Receiver.sol +58 -0
  230. package/contracts/external-deps/openzeppelin/token/ERC1155/utils/ERC1155Holder.sol +36 -0
  231. package/contracts/external-deps/openzeppelin/token/ERC1155/utils/ERC1155Receiver.sol +19 -0
  232. package/contracts/external-deps/openzeppelin/token/ERC20/ERC20.sol +359 -0
  233. package/contracts/external-deps/openzeppelin/token/ERC20/extensions/ERC20Permit.sol +117 -0
  234. package/contracts/external-deps/openzeppelin/token/ERC20/extensions/ERC20Votes.sol +246 -0
  235. package/contracts/external-deps/openzeppelin/token/ERC20/utils/SafeERC20.sol +78 -0
  236. package/contracts/external-deps/openzeppelin/token/ERC721/IERC721Receiver.sol +27 -0
  237. package/contracts/external-deps/openzeppelin/token/ERC721/utils/ERC721Holder.sol +23 -0
  238. package/contracts/external-deps/openzeppelin/utils/Base64.sol +92 -0
  239. package/contracts/external-deps/openzeppelin/utils/Context.sol +24 -0
  240. package/contracts/external-deps/openzeppelin/utils/Counters.sol +43 -0
  241. package/contracts/external-deps/openzeppelin/utils/Create2.sol +58 -0
  242. package/contracts/external-deps/openzeppelin/utils/ERC1155/ERC1155Holder.sol +36 -0
  243. package/contracts/external-deps/openzeppelin/utils/ERC1155/ERC1155Receiver.sol +19 -0
  244. package/contracts/external-deps/openzeppelin/utils/ERC721/ERC721Holder.sol +23 -0
  245. package/contracts/external-deps/openzeppelin/utils/EnumerableSet.sol +367 -0
  246. package/contracts/external-deps/openzeppelin/utils/cryptography/ECDSA.sol +217 -0
  247. package/contracts/external-deps/openzeppelin/utils/cryptography/EIP712.sol +104 -0
  248. package/contracts/external-deps/openzeppelin/utils/math/Math.sol +43 -0
  249. package/contracts/external-deps/openzeppelin/utils/math/SafeCast.sol +241 -0
  250. package/contracts/external-deps/openzeppelin/utils/math/SafeMath.sol +215 -0
  251. package/contracts/external-deps/openzeppelin/utils/structs/EnumerableSet.sol +367 -0
  252. package/contracts/infra/ContractPublisher.sol +268 -0
  253. package/contracts/infra/TWFactory.sol +140 -0
  254. package/contracts/infra/TWFee.sol +162 -0
  255. package/contracts/infra/TWMinimalFactory.sol +47 -0
  256. package/contracts/infra/TWMultichainRegistry.sol +116 -0
  257. package/contracts/infra/TWProxy.sol +42 -0
  258. package/contracts/infra/TWRegistry.sol +70 -0
  259. package/contracts/infra/TWStatelessFactory.sol +47 -0
  260. package/contracts/infra/forwarder/Forwarder.sol +76 -0
  261. package/contracts/infra/forwarder/ForwarderChainlessDomain.sol +90 -0
  262. package/contracts/infra/forwarder/ForwarderConsumer.sol +25 -0
  263. package/contracts/infra/forwarder/ForwarderEOAOnly.sol +23 -0
  264. package/contracts/infra/interface/IContractDeployer.sol +54 -0
  265. package/contracts/infra/interface/IContractPublisher.sol +128 -0
  266. package/contracts/infra/interface/ITWFee.sol +6 -0
  267. package/contracts/infra/interface/ITWMultichainRegistry.sol +28 -0
  268. package/contracts/infra/interface/ITWRegistry.sol +24 -0
  269. package/contracts/infra/interface/IThirdwebContract.sol +19 -0
  270. package/contracts/infra/interface/IWETH.sol +10 -0
  271. package/contracts/infra/registry/entrypoint/TWMultichainRegistryRouter.sol +61 -0
  272. package/contracts/infra/registry/registry-extension/TWMultichainRegistryLogic.sol +120 -0
  273. package/contracts/infra/registry/registry-extension/TWMultichainRegistryStorage.sol +30 -0
  274. package/contracts/legacy-contracts/extension/BatchMintMetadata_V1.sol +89 -0
  275. package/contracts/legacy-contracts/extension/DropSinglePhase1155_V1.sol +268 -0
  276. package/contracts/legacy-contracts/extension/DropSinglePhase_V1.sol +252 -0
  277. package/contracts/legacy-contracts/extension/LazyMintWithTier_V1.sol +112 -0
  278. package/contracts/legacy-contracts/extension/LazyMint_V1.sol +52 -0
  279. package/contracts/legacy-contracts/extension/PlatformFee_V1.sol +69 -0
  280. package/contracts/legacy-contracts/extension/PrimarySale_V1.sol +53 -0
  281. package/contracts/legacy-contracts/extension/interface/IClaimCondition_V1.sol +54 -0
  282. package/contracts/legacy-contracts/extension/interface/IDropSinglePhase1155_V1.sol +58 -0
  283. package/contracts/legacy-contracts/extension/interface/IDropSinglePhase_V1.sol +54 -0
  284. package/contracts/legacy-contracts/extension/interface/IPlatformFee_V1.sol +21 -0
  285. package/contracts/legacy-contracts/extension/interface/IPrimarySale_V1.sol +21 -0
  286. package/contracts/legacy-contracts/interface/ISignatureMintERC721_V1.sol +18 -0
  287. package/contracts/legacy-contracts/interface/drop/IDropClaimCondition_V2.sol +82 -0
  288. package/contracts/legacy-contracts/interface/drop/IDropERC1155_V2.sol +96 -0
  289. package/contracts/legacy-contracts/interface/drop/IDropERC20_V2.sol +73 -0
  290. package/contracts/legacy-contracts/interface/drop/IDropERC721_V3.sol +98 -0
  291. package/contracts/legacy-contracts/pre-builts/DropERC1155_V2.sol +731 -0
  292. package/contracts/legacy-contracts/pre-builts/DropERC20_V2.sol +521 -0
  293. package/contracts/legacy-contracts/pre-builts/DropERC721_V3.sol +745 -0
  294. package/contracts/legacy-contracts/pre-builts/SignatureDrop_V4.sol +360 -0
  295. package/contracts/legacy-contracts/smart-wallet/interface/IAccountPermissions_V1.sol +115 -0
  296. package/contracts/lib/Address.sol +244 -0
  297. package/contracts/lib/BitMaps.sol +52 -0
  298. package/contracts/lib/BytesLib.sol +18 -0
  299. package/contracts/lib/CurrencyTransferLib.sol +96 -0
  300. package/contracts/lib/FeeType.sol +10 -0
  301. package/contracts/lib/MerkleProof.sol +40 -0
  302. package/contracts/lib/NFTMetadataRenderer.sol +91 -0
  303. package/contracts/lib/StorageSlot.sol +54 -0
  304. package/contracts/lib/StringSet.sol +107 -0
  305. package/contracts/lib/Strings.sol +195 -0
  306. package/contracts/prebuilts/account/dynamic/DynamicAccount.sol +48 -0
  307. package/contracts/prebuilts/account/dynamic/DynamicAccountFactory.sol +61 -0
  308. package/contracts/prebuilts/account/interfaces/IAccount.sol +39 -0
  309. package/contracts/prebuilts/account/interfaces/IAccountCore.sol +11 -0
  310. package/contracts/prebuilts/account/interfaces/IAccountExecute.sol +17 -0
  311. package/contracts/prebuilts/account/interfaces/IAccountFactory.sol +16 -0
  312. package/contracts/prebuilts/account/interfaces/IAccountFactoryCore.sol +40 -0
  313. package/contracts/prebuilts/account/interfaces/IAggregator.sol +41 -0
  314. package/contracts/prebuilts/account/interfaces/IEntryPoint.sol +204 -0
  315. package/contracts/prebuilts/account/interfaces/INonceManager.sol +25 -0
  316. package/contracts/prebuilts/account/interfaces/IOracle.sol +10 -0
  317. package/contracts/prebuilts/account/interfaces/IPaymaster.sol +63 -0
  318. package/contracts/prebuilts/account/interfaces/IStakeManager.sol +94 -0
  319. package/contracts/prebuilts/account/interfaces/PackedUserOperation.sol +28 -0
  320. package/contracts/prebuilts/account/managed/ManagedAccount.sol +33 -0
  321. package/contracts/prebuilts/account/managed/ManagedAccountFactory.sol +68 -0
  322. package/contracts/prebuilts/account/non-upgradeable/Account.sol +169 -0
  323. package/contracts/prebuilts/account/non-upgradeable/AccountFactory.sol +54 -0
  324. package/contracts/prebuilts/account/token-bound-account/TokenBoundAccount.sol +252 -0
  325. package/contracts/prebuilts/account/token-bound-account/erc6551-utils/ERC6551AccountLib.sol +44 -0
  326. package/contracts/prebuilts/account/token-bound-account/erc6551-utils/ERC6551BytecodeLib.sol +20 -0
  327. package/contracts/prebuilts/account/token-bound-account/erc6551-utils/IERC6551Account.sol +51 -0
  328. package/contracts/prebuilts/account/token-paymaster/BasePaymaster.sol +151 -0
  329. package/contracts/prebuilts/account/token-paymaster/TokenPaymaster.sol +212 -0
  330. package/contracts/prebuilts/account/utils/AccountCore.sol +245 -0
  331. package/contracts/prebuilts/account/utils/AccountCoreStorage.sol +21 -0
  332. package/contracts/prebuilts/account/utils/AccountExtension.sol +172 -0
  333. package/contracts/prebuilts/account/utils/AccountSeaportBulkSigSupport.sol +40 -0
  334. package/contracts/prebuilts/account/utils/BaseAccount.sol +106 -0
  335. package/contracts/prebuilts/account/utils/BaseAccountFactory.sol +168 -0
  336. package/contracts/prebuilts/account/utils/EntryPoint.sol +725 -0
  337. package/contracts/prebuilts/account/utils/Exec.sol +56 -0
  338. package/contracts/prebuilts/account/utils/Helpers.sol +88 -0
  339. package/contracts/prebuilts/account/utils/NonceManager.sol +39 -0
  340. package/contracts/prebuilts/account/utils/OracleHelper.sol +154 -0
  341. package/contracts/prebuilts/account/utils/SenderCreator.sol +28 -0
  342. package/contracts/prebuilts/account/utils/StakeManager.sol +126 -0
  343. package/contracts/prebuilts/account/utils/TokenCallbackHandler.sol +55 -0
  344. package/contracts/prebuilts/account/utils/UniswapHelper.sol +119 -0
  345. package/contracts/prebuilts/account/utils/UserOperationLib.sol +127 -0
  346. package/contracts/prebuilts/airdrop/Airdrop.sol +616 -0
  347. package/contracts/prebuilts/drop/DropERC1155.sol +388 -0
  348. package/contracts/prebuilts/drop/DropERC20.sol +262 -0
  349. package/contracts/prebuilts/drop/DropERC721.sol +397 -0
  350. package/contracts/prebuilts/evolving-nfts/EvolvingNFT.sol +101 -0
  351. package/contracts/prebuilts/evolving-nfts/EvolvingNFTLogic.sol +251 -0
  352. package/contracts/prebuilts/evolving-nfts/extension/RulesEngineExtension.sol +26 -0
  353. package/contracts/prebuilts/interface/ILoyaltyCard.sol +27 -0
  354. package/contracts/prebuilts/interface/ILoyaltyPoints.sol +24 -0
  355. package/contracts/prebuilts/interface/IMultiwrap.sol +49 -0
  356. package/contracts/prebuilts/interface/IPack.sol +69 -0
  357. package/contracts/prebuilts/interface/IPackVRFDirect.sol +85 -0
  358. package/contracts/prebuilts/interface/airdrop/IAirdropERC1155.sol +45 -0
  359. package/contracts/prebuilts/interface/airdrop/IAirdropERC1155Claimable.sol +40 -0
  360. package/contracts/prebuilts/interface/airdrop/IAirdropERC20.sol +46 -0
  361. package/contracts/prebuilts/interface/airdrop/IAirdropERC20Claimable.sol +33 -0
  362. package/contracts/prebuilts/interface/airdrop/IAirdropERC721.sol +42 -0
  363. package/contracts/prebuilts/interface/airdrop/IAirdropERC721Claimable.sol +33 -0
  364. package/contracts/prebuilts/interface/drop/IDropClaimCondition.sol +82 -0
  365. package/contracts/prebuilts/interface/drop/IDropERC1155.sol +92 -0
  366. package/contracts/prebuilts/interface/drop/IDropERC20.sol +68 -0
  367. package/contracts/prebuilts/interface/drop/IDropERC721.sol +94 -0
  368. package/contracts/prebuilts/interface/marketplace/IMarketplace.sol +329 -0
  369. package/contracts/prebuilts/interface/staking/IEditionStake.sol +45 -0
  370. package/contracts/prebuilts/interface/staking/INFTStake.sol +45 -0
  371. package/contracts/prebuilts/interface/staking/ITokenStake.sol +46 -0
  372. package/contracts/prebuilts/interface/token/ITokenERC1155.sol +84 -0
  373. package/contracts/prebuilts/interface/token/ITokenERC20.sol +68 -0
  374. package/contracts/prebuilts/interface/token/ITokenERC721.sol +77 -0
  375. package/contracts/prebuilts/loyalty/LoyaltyCard.sol +339 -0
  376. package/contracts/prebuilts/marketplace/IMarketplace.sol +512 -0
  377. package/contracts/prebuilts/marketplace/direct-listings/DirectListingsLogic.sol +579 -0
  378. package/contracts/prebuilts/marketplace/direct-listings/DirectListingsStorage.sol +30 -0
  379. package/contracts/prebuilts/marketplace/english-auctions/EnglishAuctionsLogic.sol +546 -0
  380. package/contracts/prebuilts/marketplace/english-auctions/EnglishAuctionsStorage.sol +30 -0
  381. package/contracts/prebuilts/marketplace/entrypoint/MarketplaceV3.sol +184 -0
  382. package/contracts/prebuilts/marketplace/offers/OffersLogic.sol +358 -0
  383. package/contracts/prebuilts/marketplace/offers/OffersStorage.sol +28 -0
  384. package/contracts/prebuilts/marketplace-legacy/Marketplace.sol +907 -0
  385. package/contracts/prebuilts/multiwrap/Multiwrap.sol +264 -0
  386. package/contracts/prebuilts/open-edition/OpenEditionERC721.sol +268 -0
  387. package/contracts/prebuilts/open-edition/OpenEditionERC721FlatFee.sol +298 -0
  388. package/contracts/prebuilts/pack/Pack.sol +463 -0
  389. package/contracts/prebuilts/pack/PackVRFDirect.sol +516 -0
  390. package/contracts/prebuilts/signature-drop/SignatureDrop.sol +371 -0
  391. package/contracts/prebuilts/split/Split.sol +182 -0
  392. package/contracts/prebuilts/staking/EditionStake.sol +211 -0
  393. package/contracts/prebuilts/staking/NFTStake.sol +201 -0
  394. package/contracts/prebuilts/staking/TokenStake.sol +197 -0
  395. package/contracts/prebuilts/tiered-drop/TieredDrop.sol +607 -0
  396. package/contracts/prebuilts/token/TokenERC1155.sol +576 -0
  397. package/contracts/prebuilts/token/TokenERC20.sol +312 -0
  398. package/contracts/prebuilts/token/TokenERC721.sol +469 -0
  399. package/contracts/prebuilts/unaudited/airdrop/AirdropERC1155.sol +154 -0
  400. package/contracts/prebuilts/unaudited/airdrop/AirdropERC1155Claimable.sol +199 -0
  401. package/contracts/prebuilts/unaudited/airdrop/AirdropERC20.sol +194 -0
  402. package/contracts/prebuilts/unaudited/airdrop/AirdropERC20Claimable.sol +180 -0
  403. package/contracts/prebuilts/unaudited/airdrop/AirdropERC721.sol +143 -0
  404. package/contracts/prebuilts/unaudited/airdrop/AirdropERC721Claimable.sol +197 -0
  405. package/contracts/prebuilts/unaudited/burn-to-claim-drop/BurnToClaimDropERC721.sol +137 -0
  406. package/contracts/prebuilts/unaudited/burn-to-claim-drop/extension/BurnToClaimDrop721Logic.sol +362 -0
  407. package/contracts/prebuilts/unaudited/burn-to-claim-drop/extension/BurnToClaimDrop721Storage.sol +21 -0
  408. package/contracts/prebuilts/unaudited/contract-builder/CoreRouter.sol +60 -0
  409. package/contracts/prebuilts/unaudited/contract-builder/extension/PermissionOverride.sol +52 -0
  410. package/contracts/prebuilts/unaudited/loyalty/LoyaltyPoints.sol +249 -0
  411. package/contracts/prebuilts/vote/VoteERC20.sol +167 -0
  412. package/js/DropERC1155.d.ts +1198 -0
  413. package/js/DropERC1155.js +2 -0
  414. package/js/DropERC1155.js.map +1 -0
  415. package/js/DropERC721.d.ts +1247 -0
  416. package/js/DropERC721.js +2 -0
  417. package/js/DropERC721.js.map +1 -0
  418. package/js/OpenEditionERC721FlatFee.d.ts +1207 -0
  419. package/js/OpenEditionERC721FlatFee.js +2 -0
  420. package/js/OpenEditionERC721FlatFee.js.map +1 -0
  421. package/js/common.d.ts +22 -0
  422. package/js/common.js +2 -0
  423. package/js/common.js.map +1 -0
  424. package/js/factories/DropERC1155__factory.d.ts +1751 -0
  425. package/js/factories/DropERC1155__factory.js +2279 -0
  426. package/js/factories/DropERC1155__factory.js.map +1 -0
  427. package/js/factories/DropERC721__factory.d.ts +1826 -0
  428. package/js/factories/DropERC721__factory.js +2380 -0
  429. package/js/factories/DropERC721__factory.js.map +1 -0
  430. package/js/factories/OpenEditionERC721FlatFee__factory.d.ts +1707 -0
  431. package/js/factories/OpenEditionERC721FlatFee__factory.js +2219 -0
  432. package/js/factories/OpenEditionERC721FlatFee__factory.js.map +1 -0
  433. package/js/factories/index.d.ts +1 -0
  434. package/js/factories/index.js +5 -0
  435. package/js/factories/index.js.map +1 -0
  436. package/js/index.d.ts +3 -0
  437. package/js/index.js +3 -0
  438. package/js/index.js.map +1 -0
  439. package/package.json +74 -0
package/LICENSE.md ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2021 Non-Fungible Labs, Inc
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,144 @@
1
+ <p align="center">
2
+ <br />
3
+ <a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/typescript-sdk/blob/main/logo.svg?raw=true" width="200" alt=""/></a>
4
+ <br />
5
+ </p>
6
+ <h1 align="center">thirdweb Contracts forked by Rarible</h1>
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/@thirdweb-dev/contracts"><img src="https://img.shields.io/npm/v/@thirdweb-dev/contracts?color=red&logo=npm" alt="npm version"/></a>
9
+ <a href="https://github.com/thirdweb-dev/contracts/actions"><img alt="Build Status" src="https://github.com/thirdweb-dev/contracts/actions/workflows/tests.yml/badge.svg"/></a>
10
+ <a href="https://discord.gg/thirdweb"><img alt="Join our Discord!" src="https://img.shields.io/discord/834227967404146718.svg?color=7289da&label=discord&logo=discord&style=flat"/></a>
11
+
12
+ </p>
13
+ <p align="center"><strong>Collection of smart contracts deployable via the thirdweb SDK, dashboard and CLI forked by Rarible</strong></p>
14
+ <br />
15
+
16
+ ## Installation
17
+
18
+ ```shell
19
+ # Forge projects
20
+ forge install https://github.com/thirdweb-dev/contracts
21
+
22
+ # Hardhat / npm based projects
23
+ npm i @thirdweb-dev/contracts
24
+ ```
25
+
26
+ ```bash
27
+ contracts
28
+ |
29
+ |-- extension: "extensions that can be inherited by NON-upgradeable contracts"
30
+ | |-- interface: "interfaces of all extension contracts"
31
+ | |-- upgradeable: "extensions that can be inherited by upgradeable contracts"
32
+ | |-- [$prebuilt-category]: "legacy extensions written specifically for a prebuilt contract"
33
+ |
34
+ |-- base: "NON-upgradeable base contracts to build on top of"
35
+ | |-- interface: "interfaces for all base contracts"
36
+ | |-- upgradeable: "upgradeable base contracts to build on top of"
37
+ |
38
+ |-- prebuilt: "audited, ready-to-deploy thirdweb smart contracts"
39
+ | |-- interface: "interfaces for all prebuilt contracts"
40
+ | |--[$prebuilt-category]: "feature-based group of prebuilt contracts"
41
+ | |-- unaudited: "yet-to-audit thirdweb smart contracts"
42
+ | |-- [$prebuilt-category]: "feature-based group of prebuilt contracts"
43
+ |
44
+ |-- infra: "onchain infrastructure contracts"
45
+ | |-- interface: "interfaces for all infrastructure contracts"
46
+ |
47
+ |-- eip: "implementations of relevant EIP standards"
48
+ | |-- interface "all interfaces of relevant EIP standards"
49
+ |
50
+ |-- lib: "Solidity libraries"
51
+ |
52
+ |-- external-deps: "modified / copied over external dependencies"
53
+ | |-- openzeppelin: "modified / copied over openzeppelin dependencies"
54
+ | |-- chainlink: "modified / copied over chainlink dependencies"
55
+ |
56
+ |-- legacy-contracts: "maintained legacy thirdweb contracts"
57
+ ```
58
+
59
+ ## Running Tests
60
+
61
+ 1. `yarn`: install contracts dependencies
62
+ 2. `forge install`: install tests dependencies
63
+ 3. `forge test`: run the tests
64
+
65
+ This repository is a [forge](https://github.com/foundry-rs/foundry/tree/master/forge) project.
66
+
67
+ First install the relevant dependencies of the project:
68
+
69
+ ```bash
70
+ yarn
71
+
72
+ forge install
73
+ ```
74
+
75
+ To compile contracts, run:
76
+
77
+ ```bash
78
+ forge build
79
+ ```
80
+
81
+ To run tests:
82
+
83
+ ```bash
84
+ forge test
85
+ ```
86
+
87
+ ## Pre-built Contracts
88
+
89
+ Pre-built contracts are written by the thirdweb team, and cover the most common use cases for smart contracts.
90
+
91
+ - [DropERC20](https://thirdweb.com/deployer.thirdweb.eth/DropERC20)
92
+ - [DropERC721](https://thirdweb.com/deployer.thirdweb.eth/DropERC721)
93
+ - [DropERC1155](https://thirdweb.com/deployer.thirdweb.eth/DropERC1155)
94
+ - [SignatureDrop](https://thirdweb.com/deployer.thirdweb.eth/SignatureDrop)
95
+ - [Marketplace](https://thirdweb.com/deployer.thirdweb.eth/Marketplace)
96
+ - [Multiwrap](https://thirdweb.com/deployer.thirdweb.eth/Multiwrap)
97
+ - [TokenERC20](https://thirdweb.com/deployer.thirdweb.eth/TokenERC20)
98
+ - [TokenERC721](https://thirdweb.com/deployer.thirdweb.eth/TokenERC721)
99
+ - [TokenERC1155](https://thirdweb.com/deployer.thirdweb.eth/TokenERC1155)
100
+ - [VoteERC20](https://thirdweb.com/deployer.thirdweb.eth/VoteERC20)
101
+ - [Split](https://thirdweb.com/deployer.thirdweb.eth/Split)
102
+
103
+ [Learn more about pre-built contracts](https://portal.thirdweb.com/pre-built-contracts)
104
+
105
+ ## Extensions
106
+
107
+ Extensions are building blocks that help enrich smart contracts with features.
108
+
109
+ Some blocks come packaged together as Base Contracts, which come with a full set of features out of the box that you can modify and extend. These contracts are available at `contracts/base/`.
110
+
111
+ Other (smaller) blocks are Features, which provide a way for you to pick and choose which individual pieces you want to put into your contract; with full customization of how those features work. These are available at `contracts/extension/`.
112
+
113
+ [Learn more about extensions](https://portal.thirdweb.com/extensions)
114
+
115
+ ## Contract Audits
116
+
117
+ - [Audit 1](audit-reports/audit-1.pdf)
118
+ - [Audit 2](audit-reports/audit-2.pdf)
119
+ - [Audit 3](audit-reports/audit-3.pdf)
120
+ - [Audit 4](audit-reports/audit-4.pdf)
121
+ - [Audit 5](audit-reports/audit-5.pdf)
122
+ - [Audit 6](audit-reports/audit-6.pdf)
123
+ - [Audit 7](audit-reports/audit-7.pdf)
124
+ - [Audit 8](audit-reports/audit-8.pdf)
125
+ - [Audit 9](audit-reports/audit-9.pdf)
126
+ - [Audit 10](audit-reports/audit-10.pdf)
127
+ - [Audit 11](audit-reports/audit-11.pdf)
128
+ - [Audit 12](audit-reports/audit-12.pdf)
129
+
130
+ ## Bug reports
131
+
132
+ Found a security issue with our smart contracts? Send bug reports to security@thirdweb.com and we'll continue communicating with you from there. We're actively developing a bug bounty program; bug report payouts happen on a case by case basis, for now.
133
+
134
+ ## Feedback
135
+
136
+ If you have any feedback, please reach out to us at support@thirdweb.com.
137
+
138
+ ## Authors
139
+
140
+ - [thirdweb](https://thirdweb.com)
141
+
142
+ ## License
143
+
144
+ [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt)
@@ -0,0 +1,282 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.0;
3
+
4
+ /// @author thirdweb
5
+
6
+ import { ERC1155 } from "../eip/ERC1155.sol";
7
+
8
+ import "../extension/ContractMetadata.sol";
9
+ import "../extension/Multicall.sol";
10
+ import "../extension/Ownable.sol";
11
+ import "../extension/Royalty.sol";
12
+ import "../extension/BatchMintMetadata.sol";
13
+
14
+ import "../lib/Strings.sol";
15
+
16
+ /**
17
+ * The `ERC1155Base` smart contract implements the ERC1155 NFT standard.
18
+ * It includes the following additions to standard ERC1155 logic:
19
+ *
20
+ * - Ability to mint NFTs via the provided `mintTo` and `batchMintTo` functions.
21
+ *
22
+ * - Contract metadata for royalty support on platforms such as OpenSea that use
23
+ * off-chain information to distribute roaylties.
24
+ *
25
+ * - Ownership of the contract, with the ability to restrict certain functions to
26
+ * only be called by the contract's owner.
27
+ *
28
+ * - Multicall capability to perform multiple actions atomically
29
+ *
30
+ * - EIP 2981 compliance for royalty support on NFT marketplaces.
31
+ */
32
+
33
+ contract ERC1155Base is ERC1155, ContractMetadata, Ownable, Royalty, Multicall, BatchMintMetadata {
34
+ using Strings for uint256;
35
+
36
+ /*//////////////////////////////////////////////////////////////
37
+ State variables
38
+ //////////////////////////////////////////////////////////////*/
39
+
40
+ /// @dev The tokenId of the next NFT to mint.
41
+ uint256 internal nextTokenIdToMint_;
42
+
43
+ /*//////////////////////////////////////////////////////////////
44
+ Mappings
45
+ //////////////////////////////////////////////////////////////*/
46
+
47
+ /**
48
+ * @notice Returns the total supply of NFTs of a given tokenId
49
+ * @dev Mapping from tokenId => total circulating supply of NFTs of that tokenId.
50
+ */
51
+ mapping(uint256 => uint256) public totalSupply;
52
+
53
+ /*//////////////////////////////////////////////////////////////
54
+ Constructor
55
+ //////////////////////////////////////////////////////////////*/
56
+
57
+ constructor(
58
+ address _defaultAdmin,
59
+ string memory _name,
60
+ string memory _symbol,
61
+ address _royaltyRecipient,
62
+ uint128 _royaltyBps
63
+ ) ERC1155(_name, _symbol) {
64
+ _setupOwner(_defaultAdmin);
65
+ _setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);
66
+ }
67
+
68
+ /*//////////////////////////////////////////////////////////////
69
+ Overriden metadata logic
70
+ //////////////////////////////////////////////////////////////*/
71
+
72
+ /// @notice Returns the metadata URI for the given tokenId.
73
+ /// @param _tokenId The tokenId of the token for which a URI should be returned.
74
+ /// @return The metadata URI for the given tokenId.
75
+ function uri(uint256 _tokenId) public view virtual override returns (string memory) {
76
+ string memory uriForToken = _uri[_tokenId];
77
+ if (bytes(uriForToken).length > 0) {
78
+ return uriForToken;
79
+ }
80
+
81
+ string memory batchUri = _getBaseURI(_tokenId);
82
+ return string(abi.encodePacked(batchUri, _tokenId.toString()));
83
+ }
84
+
85
+ /*//////////////////////////////////////////////////////////////
86
+ Mint / burn logic
87
+ //////////////////////////////////////////////////////////////*/
88
+
89
+ /**
90
+ * @notice Lets an authorized address mint NFTs to a recipient.
91
+ * @dev - The logic in the `_canMint` function determines whether the caller is authorized to mint NFTs.
92
+ * - If `_tokenId == type(uint256).max` a new NFT at tokenId `nextTokenIdToMint` is minted. If the given
93
+ * `tokenId < nextTokenIdToMint`, then additional supply of an existing NFT is being minted.
94
+ *
95
+ * @param _to The recipient of the NFTs to mint.
96
+ * @param _tokenId The tokenId of the NFT to mint.
97
+ * @param _tokenURI The full metadata URI for the NFTs minted (if a new NFT is being minted).
98
+ * @param _amount The amount of the same NFT to mint.
99
+ */
100
+ function mintTo(address _to, uint256 _tokenId, string memory _tokenURI, uint256 _amount) public virtual {
101
+ require(_canMint(), "Not authorized to mint.");
102
+
103
+ uint256 tokenIdToMint;
104
+ uint256 nextIdToMint = nextTokenIdToMint();
105
+
106
+ if (_tokenId == type(uint256).max) {
107
+ tokenIdToMint = nextIdToMint;
108
+ nextTokenIdToMint_ += 1;
109
+ _setTokenURI(nextIdToMint, _tokenURI);
110
+ } else {
111
+ require(_tokenId < nextIdToMint, "invalid id");
112
+ tokenIdToMint = _tokenId;
113
+ }
114
+
115
+ _mint(_to, tokenIdToMint, _amount, "");
116
+ }
117
+
118
+ /**
119
+ * @notice Lets an authorized address mint multiple NEW NFTs at once to a recipient.
120
+ * @dev The logic in the `_canMint` function determines whether the caller is authorized to mint NFTs.
121
+ * If `_tokenIds[i] == type(uint256).max` a new NFT at tokenId `nextTokenIdToMint` is minted. If the given
122
+ * `tokenIds[i] < nextTokenIdToMint`, then additional supply of an existing NFT is minted.
123
+ * The metadata for each new NFT is stored at `baseURI/{tokenID of NFT}`
124
+ *
125
+ * @param _to The recipient of the NFT to mint.
126
+ * @param _tokenIds The tokenIds of the NFTs to mint.
127
+ * @param _amounts The amounts of each NFT to mint.
128
+ * @param _baseURI The baseURI for the `n` number of NFTs minted. The metadata for each NFT is `baseURI/tokenId`
129
+ */
130
+ function batchMintTo(
131
+ address _to,
132
+ uint256[] memory _tokenIds,
133
+ uint256[] memory _amounts,
134
+ string memory _baseURI
135
+ ) public virtual {
136
+ require(_canMint(), "Not authorized to mint.");
137
+ require(_amounts.length > 0, "Minting zero tokens.");
138
+ require(_tokenIds.length == _amounts.length, "Length mismatch.");
139
+
140
+ uint256 nextIdToMint = nextTokenIdToMint();
141
+ uint256 startNextIdToMint = nextIdToMint;
142
+
143
+ uint256 numOfNewNFTs;
144
+
145
+ for (uint256 i = 0; i < _tokenIds.length; i += 1) {
146
+ if (_tokenIds[i] == type(uint256).max) {
147
+ _tokenIds[i] = nextIdToMint;
148
+
149
+ nextIdToMint += 1;
150
+ numOfNewNFTs += 1;
151
+ } else {
152
+ require(_tokenIds[i] < nextIdToMint, "invalid id");
153
+ }
154
+ }
155
+
156
+ if (numOfNewNFTs > 0) {
157
+ _batchMintMetadata(startNextIdToMint, numOfNewNFTs, _baseURI);
158
+ }
159
+
160
+ nextTokenIdToMint_ = nextIdToMint;
161
+ _mintBatch(_to, _tokenIds, _amounts, "");
162
+ }
163
+
164
+ /**
165
+ * @notice Lets an owner or approved operator burn NFTs of the given tokenId.
166
+ *
167
+ * @param _owner The owner of the NFT to burn.
168
+ * @param _tokenId The tokenId of the NFT to burn.
169
+ * @param _amount The amount of the NFT to burn.
170
+ */
171
+ function burn(address _owner, uint256 _tokenId, uint256 _amount) external virtual {
172
+ address caller = msg.sender;
173
+
174
+ require(caller == _owner || isApprovedForAll[_owner][caller], "Unapproved caller");
175
+ require(balanceOf[_owner][_tokenId] >= _amount, "Not enough tokens owned");
176
+
177
+ _burn(_owner, _tokenId, _amount);
178
+ }
179
+
180
+ /**
181
+ * @notice Lets an owner or approved operator burn NFTs of the given tokenIds.
182
+ *
183
+ * @param _owner The owner of the NFTs to burn.
184
+ * @param _tokenIds The tokenIds of the NFTs to burn.
185
+ * @param _amounts The amounts of the NFTs to burn.
186
+ */
187
+ function burnBatch(address _owner, uint256[] memory _tokenIds, uint256[] memory _amounts) external virtual {
188
+ address caller = msg.sender;
189
+
190
+ require(caller == _owner || isApprovedForAll[_owner][caller], "Unapproved caller");
191
+ require(_tokenIds.length == _amounts.length, "Length mismatch");
192
+
193
+ for (uint256 i = 0; i < _tokenIds.length; i += 1) {
194
+ require(balanceOf[_owner][_tokenIds[i]] >= _amounts[i], "Not enough tokens owned");
195
+ }
196
+
197
+ _burnBatch(_owner, _tokenIds, _amounts);
198
+ }
199
+
200
+ /*//////////////////////////////////////////////////////////////
201
+ ERC165 Logic
202
+ //////////////////////////////////////////////////////////////*/
203
+
204
+ /**
205
+ * @dev See ERC165: https://eips.ethereum.org/EIPS/eip-165
206
+ * @inheritdoc IERC165
207
+ */
208
+ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, IERC165) returns (bool) {
209
+ return
210
+ interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
211
+ interfaceId == 0xd9b67a26 || // ERC165 Interface ID for ERC1155
212
+ interfaceId == 0x0e89341c || // ERC165 Interface ID for ERC1155MetadataURI
213
+ interfaceId == type(IERC2981).interfaceId; // ERC165 ID for ERC2981
214
+ }
215
+
216
+ /*//////////////////////////////////////////////////////////////
217
+ View functions
218
+ //////////////////////////////////////////////////////////////*/
219
+
220
+ /// @notice The tokenId assigned to the next new NFT to be minted.
221
+ function nextTokenIdToMint() public view virtual returns (uint256) {
222
+ return nextTokenIdToMint_;
223
+ }
224
+
225
+ /*//////////////////////////////////////////////////////////////
226
+ Internal (overrideable) functions
227
+ //////////////////////////////////////////////////////////////*/
228
+
229
+ /// @dev Returns whether contract metadata can be set in the given execution context.
230
+ /// @return Whether contract metadata can be set in the given execution context.
231
+ function _canSetContractURI() internal view virtual override returns (bool) {
232
+ return msg.sender == owner();
233
+ }
234
+
235
+ /// @dev Returns whether a token can be minted in the given execution context.
236
+ /// @return Whether a token can be minted in the given execution context.
237
+ function _canMint() internal view virtual returns (bool) {
238
+ return msg.sender == owner();
239
+ }
240
+
241
+ /// @dev Returns whether owner can be set in the given execution context.
242
+ /// @return Whether owner can be set in the given execution context.
243
+ function _canSetOwner() internal view virtual override returns (bool) {
244
+ return msg.sender == owner();
245
+ }
246
+
247
+ /// @dev Returns whether royalty info can be set in the given execution context.
248
+ /// @return Whether royalty info can be set in the given execution context.
249
+ function _canSetRoyaltyInfo() internal view virtual override returns (bool) {
250
+ return msg.sender == owner();
251
+ }
252
+
253
+ /// @dev Runs before every token transfer / mint / burn.
254
+ /// @param operator The address of the caller.
255
+ /// @param from The address of the sender.
256
+ /// @param to The address of the recipient.
257
+ /// @param ids The tokenIds of the tokens being transferred.
258
+ /// @param amounts The amounts of the tokens being transferred.
259
+ /// @param data Additional data with no specified format.
260
+ function _beforeTokenTransfer(
261
+ address operator,
262
+ address from,
263
+ address to,
264
+ uint256[] memory ids,
265
+ uint256[] memory amounts,
266
+ bytes memory data
267
+ ) internal virtual override {
268
+ super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
269
+
270
+ if (from == address(0)) {
271
+ for (uint256 i = 0; i < ids.length; ++i) {
272
+ totalSupply[ids[i]] += amounts[i];
273
+ }
274
+ }
275
+
276
+ if (to == address(0)) {
277
+ for (uint256 i = 0; i < ids.length; ++i) {
278
+ totalSupply[ids[i]] -= amounts[i];
279
+ }
280
+ }
281
+ }
282
+ }