polkamarkets-js 3.4.1 → 3.4.3

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 (318) hide show
  1. package/package.json +1 -1
  2. package/script/AddAdminToLand.s.sol +1 -1
  3. package/script/ClaimMerkleRoot.s.sol +29 -29
  4. package/script/CreateLand.s.sol +1 -1
  5. package/script/DeployMerkleRewardsDistributor.s.sol +21 -21
  6. package/script/MintTokens.s.sol +1 -1
  7. package/script/PublishMerkleRoot.s.sol +50 -50
  8. package/script/UpdateMarket.s.sol +55 -0
  9. package/script/copy-abis.js +57 -0
  10. package/src/Application.js +12 -1
  11. package/src/models/IContract.js +87 -1
  12. package/src/models/PolkamarketsSmartAccount.js +23 -0
  13. package/src/models/PredictionMarketV3Contract.js +49 -16
  14. package/abis/AccessControlUpgradeable.json +0 -1
  15. package/abis/AddAdminToLand.json +0 -1
  16. package/abis/AddressUpgradeable.json +0 -1
  17. package/abis/ClaimMerkleRoot.json +0 -1
  18. package/abis/CreateLand.json +0 -1
  19. package/abis/CreateMarkets.json +0 -1
  20. package/abis/DeployContracts.json +0 -1
  21. package/abis/DeployMerkleRewardsDistributor.json +0 -1
  22. package/abis/DeployToken.json +0 -1
  23. package/abis/DeployUSDT.json +0 -1
  24. package/abis/ECDSA.json +0 -1
  25. package/abis/ERC165Upgradeable.json +0 -1
  26. package/abis/ERC1967UpgradeUpgradeable.json +0 -1
  27. package/abis/Hashes.json +0 -1
  28. package/abis/IBeaconUpgradeable.json +0 -1
  29. package/abis/IERC1822ProxiableUpgradeable.json +0 -1
  30. package/abis/IERC20PermitUpgradeable.json +0 -1
  31. package/abis/IERC20Upgradeable.json +0 -1
  32. package/abis/Manager.json +0 -1
  33. package/abis/MerkleProof.json +0 -1
  34. package/abis/MerkleRewardsDistributor.json +0 -1
  35. package/abis/MerkleRewardsDistributorTest.json +0 -1
  36. package/abis/MessageHashUtils.json +0 -1
  37. package/abis/MintTokens.json +0 -1
  38. package/abis/Nonces.json +0 -1
  39. package/abis/Panic.json +0 -1
  40. package/abis/PublishMerkleRoot.json +0 -1
  41. package/abis/ResolveMarket.json +0 -1
  42. package/abis/RewardsDistributor.json +0 -1
  43. package/abis/RewardsDistributorTest.json +0 -1
  44. package/abis/SafeCast.json +0 -1
  45. package/abis/SafeERC20Upgradeable.json +0 -1
  46. package/abis/SignedMath.json +0 -1
  47. package/abis/StorageSlotUpgradeable.json +0 -1
  48. package/abis/TradeMarket.json +0 -1
  49. package/abis/USDT.json +0 -1
  50. package/abis/UpdateMarket.json +0 -1
  51. package/abis/UpdateTest.json +0 -1
  52. package/abis/WhaleTest.json +0 -1
  53. package/lib/openzeppelin-contracts/contracts/mocks/docs/ERC20WithAutoMinerReward.sol +0 -22
  54. package/lib/openzeppelin-contracts/contracts/mocks/docs/ERC4626Fees.sol +0 -109
  55. package/lib/openzeppelin-contracts/contracts/mocks/docs/MyNFT.sol +0 -9
  56. package/lib/openzeppelin-contracts/contracts/mocks/docs/access-control/AccessControlERC20MintBase.sol +0 -25
  57. package/lib/openzeppelin-contracts/contracts/mocks/docs/access-control/AccessControlERC20MintMissing.sol +0 -24
  58. package/lib/openzeppelin-contracts/contracts/mocks/docs/access-control/AccessControlERC20MintOnlyRole.sol +0 -23
  59. package/lib/openzeppelin-contracts/contracts/mocks/docs/access-control/AccessControlModified.sol +0 -14
  60. package/lib/openzeppelin-contracts/contracts/mocks/docs/access-control/AccessManagedERC20MintBase.sol +0 -16
  61. package/lib/openzeppelin-contracts/contracts/mocks/docs/access-control/MyContractOwnable.sol +0 -17
  62. package/lib/openzeppelin-contracts/contracts/mocks/docs/account/MyAccountERC7702.sol +0 -20
  63. package/lib/openzeppelin-contracts/contracts/mocks/docs/account/MyFactoryAccount.sol +0 -37
  64. package/lib/openzeppelin-contracts/contracts/mocks/docs/governance/MyGovernor.sol +0 -80
  65. package/lib/openzeppelin-contracts/contracts/mocks/docs/governance/MyToken.sol +0 -21
  66. package/lib/openzeppelin-contracts/contracts/mocks/docs/governance/MyTokenTimestampBased.sol +0 -32
  67. package/lib/openzeppelin-contracts/contracts/mocks/docs/governance/MyTokenWrapped.sol +0 -28
  68. package/lib/openzeppelin-contracts/contracts/mocks/docs/token/ERC1155/GameItems.sol +0 -21
  69. package/lib/openzeppelin-contracts/contracts/mocks/docs/token/ERC1155/MyERC115HolderContract.sol +0 -7
  70. package/lib/openzeppelin-contracts/contracts/mocks/docs/token/ERC20/GLDToken.sol +0 -11
  71. package/lib/openzeppelin-contracts/contracts/mocks/docs/token/ERC6909/ERC6909GameItems.sol +0 -26
  72. package/lib/openzeppelin-contracts/contracts/mocks/docs/token/ERC721/GameItem.sol +0 -19
  73. package/lib/openzeppelin-contracts/contracts/mocks/docs/utilities/Base64NFT.sol +0 -27
  74. package/lib/openzeppelin-contracts/contracts/mocks/docs/utilities/Multicall.sol +0 -15
  75. package/lib/openzeppelin-contracts/docs/README.md +0 -16
  76. package/lib/openzeppelin-contracts/docs/antora.yml +0 -7
  77. package/lib/openzeppelin-contracts/docs/config.js +0 -21
  78. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/access-control-multiple.svg +0 -97
  79. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/access-manager-functions.svg +0 -47
  80. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/access-manager.svg +0 -99
  81. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-attack-3a.png +0 -0
  82. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-attack-3b.png +0 -0
  83. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-attack-6.png +0 -0
  84. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-attack.png +0 -0
  85. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-deposit.png +0 -0
  86. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-mint.png +0 -0
  87. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-rate-linear.png +0 -0
  88. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-rate-loglog.png +0 -0
  89. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-rate-loglogext.png +0 -0
  90. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/tally-exec.png +0 -0
  91. package/lib/openzeppelin-contracts/docs/modules/ROOT/images/tally-vote.png +0 -0
  92. package/lib/openzeppelin-contracts/docs/modules/ROOT/nav.adoc +0 -29
  93. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/access-control.adoc +0 -288
  94. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/account-abstraction.adoc +0 -100
  95. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/accounts.adoc +0 -354
  96. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/backwards-compatibility.adoc +0 -50
  97. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/eoa-delegation.adoc +0 -143
  98. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/erc1155.adoc +0 -118
  99. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/erc20-supply.adoc +0 -71
  100. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/erc20.adoc +0 -67
  101. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/erc4626.adoc +0 -214
  102. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/erc6909.adoc +0 -47
  103. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/erc721.adoc +0 -58
  104. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/extending-contracts.adoc +0 -51
  105. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/faq.adoc +0 -13
  106. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/governance.adoc +0 -239
  107. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/index.adoc +0 -70
  108. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/multisig.adoc +0 -306
  109. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/tokens.adoc +0 -31
  110. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/upgradeable.adoc +0 -77
  111. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/utilities.adoc +0 -591
  112. package/lib/openzeppelin-contracts/docs/modules/ROOT/pages/wizard.adoc +0 -15
  113. package/lib/openzeppelin-contracts/docs/templates/contract.hbs +0 -141
  114. package/lib/openzeppelin-contracts/docs/templates/helpers.js +0 -46
  115. package/lib/openzeppelin-contracts/docs/templates/page.hbs +0 -4
  116. package/lib/openzeppelin-contracts/docs/templates/properties.js +0 -88
  117. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/ERC20WithAutoMinerRewardUpgradeable.sol +0 -28
  118. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/ERC4626FeesUpgradeable.sol +0 -115
  119. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/MyNFTUpgradeable.sol +0 -14
  120. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/access-control/AccessControlERC20MintBaseUpgradeable.sol +0 -31
  121. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/access-control/AccessControlERC20MintMissingUpgradeable.sol +0 -30
  122. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/access-control/AccessControlERC20MintOnlyRoleUpgradeable.sol +0 -29
  123. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/access-control/AccessControlModifiedUpgradeable.sol +0 -20
  124. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/access-control/AccessManagedERC20MintBaseUpgradeable.sol +0 -22
  125. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/access-control/MyContractOwnableUpgradeable.sol +0 -22
  126. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/account/MyAccountERC7702Upgradeable.sol +0 -26
  127. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/account/MyFactoryAccountUpgradeable.sol +0 -42
  128. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/governance/MyGovernorUpgradeable.sol +0 -92
  129. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/governance/MyTokenTimestampBasedUpgradeable.sol +0 -39
  130. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/governance/MyTokenUpgradeable.sol +0 -28
  131. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/governance/MyTokenWrappedUpgradeable.sol +0 -39
  132. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/token/ERC1155/GameItemsUpgradeable.sol +0 -27
  133. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/token/ERC1155/MyERC115HolderContractUpgradeable.sol +0 -13
  134. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/token/ERC20/GLDTokenUpgradeable.sol +0 -17
  135. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/token/ERC6909/ERC6909GameItemsUpgradeable.sol +0 -31
  136. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/token/ERC721/GameItemUpgradeable.sol +0 -24
  137. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/utilities/Base64NFTUpgradeable.sol +0 -32
  138. package/lib/openzeppelin-contracts-upgradeable/contracts/mocks/docs/utilities/MulticallUpgradeable.sol +0 -21
  139. package/lib/openzeppelin-contracts-upgradeable/docs/README.md +0 -16
  140. package/lib/openzeppelin-contracts-upgradeable/docs/antora.yml +0 -7
  141. package/lib/openzeppelin-contracts-upgradeable/docs/config.js +0 -21
  142. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/access-control-multiple.svg +0 -97
  143. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/access-manager-functions.svg +0 -47
  144. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/access-manager.svg +0 -99
  145. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/erc4626-attack-3a.png +0 -0
  146. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/erc4626-attack-3b.png +0 -0
  147. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/erc4626-attack-6.png +0 -0
  148. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/erc4626-attack.png +0 -0
  149. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/erc4626-deposit.png +0 -0
  150. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/erc4626-mint.png +0 -0
  151. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/erc4626-rate-linear.png +0 -0
  152. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/erc4626-rate-loglog.png +0 -0
  153. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/erc4626-rate-loglogext.png +0 -0
  154. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/tally-exec.png +0 -0
  155. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/images/tally-vote.png +0 -0
  156. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/nav.adoc +0 -29
  157. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/access-control.adoc +0 -288
  158. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/account-abstraction.adoc +0 -100
  159. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/accounts.adoc +0 -354
  160. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/backwards-compatibility.adoc +0 -50
  161. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/eoa-delegation.adoc +0 -143
  162. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/erc1155.adoc +0 -118
  163. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/erc20-supply.adoc +0 -71
  164. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/erc20.adoc +0 -67
  165. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/erc4626.adoc +0 -214
  166. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/erc6909.adoc +0 -47
  167. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/erc721.adoc +0 -58
  168. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/extending-contracts.adoc +0 -51
  169. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/faq.adoc +0 -13
  170. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/governance.adoc +0 -239
  171. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/index.adoc +0 -70
  172. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/multisig.adoc +0 -306
  173. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/tokens.adoc +0 -31
  174. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/upgradeable.adoc +0 -77
  175. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/utilities.adoc +0 -591
  176. package/lib/openzeppelin-contracts-upgradeable/docs/modules/ROOT/pages/wizard.adoc +0 -15
  177. package/lib/openzeppelin-contracts-upgradeable/docs/templates/contract.hbs +0 -141
  178. package/lib/openzeppelin-contracts-upgradeable/docs/templates/helpers.js +0 -46
  179. package/lib/openzeppelin-contracts-upgradeable/docs/templates/page.hbs +0 -4
  180. package/lib/openzeppelin-contracts-upgradeable/docs/templates/properties.js +0 -88
  181. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/ERC20WithAutoMinerReward.sol +0 -22
  182. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/ERC4626Fees.sol +0 -109
  183. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/MyNFT.sol +0 -9
  184. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/access-control/AccessControlERC20MintBase.sol +0 -25
  185. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/access-control/AccessControlERC20MintMissing.sol +0 -24
  186. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/access-control/AccessControlERC20MintOnlyRole.sol +0 -23
  187. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/access-control/AccessControlModified.sol +0 -14
  188. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/access-control/AccessManagedERC20MintBase.sol +0 -16
  189. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/access-control/MyContractOwnable.sol +0 -17
  190. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/account/MyAccountERC7702.sol +0 -20
  191. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/account/MyFactoryAccount.sol +0 -37
  192. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/governance/MyGovernor.sol +0 -80
  193. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/governance/MyToken.sol +0 -21
  194. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/governance/MyTokenTimestampBased.sol +0 -32
  195. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/governance/MyTokenWrapped.sol +0 -28
  196. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/token/ERC1155/GameItems.sol +0 -21
  197. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/token/ERC1155/MyERC115HolderContract.sol +0 -7
  198. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/token/ERC20/GLDToken.sol +0 -11
  199. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/token/ERC6909/ERC6909GameItems.sol +0 -26
  200. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/token/ERC721/GameItem.sol +0 -19
  201. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/utilities/Base64NFT.sol +0 -27
  202. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/mocks/docs/utilities/Multicall.sol +0 -15
  203. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/README.md +0 -16
  204. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/antora.yml +0 -7
  205. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/config.js +0 -21
  206. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/access-control-multiple.svg +0 -97
  207. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/access-manager-functions.svg +0 -47
  208. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/access-manager.svg +0 -99
  209. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-attack-3a.png +0 -0
  210. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-attack-3b.png +0 -0
  211. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-attack-6.png +0 -0
  212. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-attack.png +0 -0
  213. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-deposit.png +0 -0
  214. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-mint.png +0 -0
  215. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-rate-linear.png +0 -0
  216. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-rate-loglog.png +0 -0
  217. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/erc4626-rate-loglogext.png +0 -0
  218. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/tally-exec.png +0 -0
  219. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/images/tally-vote.png +0 -0
  220. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/nav.adoc +0 -29
  221. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/access-control.adoc +0 -288
  222. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/account-abstraction.adoc +0 -100
  223. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/accounts.adoc +0 -354
  224. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/backwards-compatibility.adoc +0 -50
  225. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/eoa-delegation.adoc +0 -143
  226. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/erc1155.adoc +0 -118
  227. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/erc20-supply.adoc +0 -71
  228. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/erc20.adoc +0 -67
  229. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/erc4626.adoc +0 -214
  230. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/erc6909.adoc +0 -47
  231. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/erc721.adoc +0 -58
  232. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/extending-contracts.adoc +0 -51
  233. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/faq.adoc +0 -13
  234. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/governance.adoc +0 -239
  235. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/index.adoc +0 -70
  236. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/multisig.adoc +0 -306
  237. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/tokens.adoc +0 -31
  238. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/upgradeable.adoc +0 -77
  239. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/utilities.adoc +0 -591
  240. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/modules/ROOT/pages/wizard.adoc +0 -15
  241. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/templates/contract.hbs +0 -141
  242. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/templates/helpers.js +0 -46
  243. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/templates/page.hbs +0 -4
  244. package/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/docs/templates/properties.js +0 -88
  245. package/lib/openzeppelin-contracts-upgradeable.git/docs/antora.yml +0 -6
  246. package/lib/openzeppelin-contracts-upgradeable.git/docs/config.js +0 -21
  247. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/images/tally-exec.png +0 -0
  248. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/images/tally-vote.png +0 -0
  249. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/nav.adoc +0 -23
  250. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/access-control.adoc +0 -217
  251. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/crosschain.adoc +0 -210
  252. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/crowdsales.adoc +0 -11
  253. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/drafts.adoc +0 -19
  254. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/erc1155.adoc +0 -153
  255. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/erc20-supply.adoc +0 -113
  256. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/erc20.adoc +0 -85
  257. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/erc721.adoc +0 -90
  258. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/erc777.adoc +0 -73
  259. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/extending-contracts.adoc +0 -129
  260. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/governance.adoc +0 -321
  261. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/index.adoc +0 -63
  262. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/releases-stability.adoc +0 -85
  263. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/tokens.adoc +0 -32
  264. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/upgradeable.adoc +0 -73
  265. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/utilities.adoc +0 -190
  266. package/lib/openzeppelin-contracts-upgradeable.git/docs/modules/ROOT/pages/wizard.adoc +0 -15
  267. package/lib/openzeppelin-contracts-upgradeable.git/docs/templates/contract.hbs +0 -85
  268. package/lib/openzeppelin-contracts-upgradeable.git/docs/templates/helpers.js +0 -46
  269. package/lib/openzeppelin-contracts-upgradeable.git/docs/templates/page.hbs +0 -4
  270. package/lib/openzeppelin-contracts-upgradeable.git/docs/templates/properties.js +0 -49
  271. package/lib/openzeppelin-contracts.git/docs/antora.yml +0 -6
  272. package/lib/openzeppelin-contracts.git/docs/config.js +0 -21
  273. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/images/tally-exec.png +0 -0
  274. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/images/tally-vote.png +0 -0
  275. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/nav.adoc +0 -23
  276. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/access-control.adoc +0 -217
  277. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/crosschain.adoc +0 -210
  278. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/crowdsales.adoc +0 -11
  279. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/drafts.adoc +0 -19
  280. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/erc1155.adoc +0 -153
  281. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/erc20-supply.adoc +0 -113
  282. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/erc20.adoc +0 -85
  283. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/erc721.adoc +0 -90
  284. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/erc777.adoc +0 -73
  285. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/extending-contracts.adoc +0 -129
  286. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/governance.adoc +0 -321
  287. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/index.adoc +0 -63
  288. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/releases-stability.adoc +0 -85
  289. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/tokens.adoc +0 -32
  290. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/upgradeable.adoc +0 -73
  291. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/utilities.adoc +0 -190
  292. package/lib/openzeppelin-contracts.git/docs/modules/ROOT/pages/wizard.adoc +0 -15
  293. package/lib/openzeppelin-contracts.git/docs/templates/contract.hbs +0 -85
  294. package/lib/openzeppelin-contracts.git/docs/templates/helpers.js +0 -46
  295. package/lib/openzeppelin-contracts.git/docs/templates/page.hbs +0 -4
  296. package/lib/openzeppelin-contracts.git/docs/templates/properties.js +0 -49
  297. package/lib/reality-eth-monorepo/packages/docs/Audit_Reality_v3_202108.pdf +0 -0
  298. package/lib/reality-eth-monorepo/packages/docs/Makefile +0 -20
  299. package/lib/reality-eth-monorepo/packages/docs/arbitrators.rst +0 -85
  300. package/lib/reality-eth-monorepo/packages/docs/audit.rst +0 -12
  301. package/lib/reality-eth-monorepo/packages/docs/audit_v2.rst +0 -249
  302. package/lib/reality-eth-monorepo/packages/docs/audit_v2_ERC20.rst +0 -1075
  303. package/lib/reality-eth-monorepo/packages/docs/audit_v3.rst +0 -70
  304. package/lib/reality-eth-monorepo/packages/docs/conf.py +0 -155
  305. package/lib/reality-eth-monorepo/packages/docs/contract_explanation.rst +0 -82
  306. package/lib/reality-eth-monorepo/packages/docs/contracts.rst +0 -277
  307. package/lib/reality-eth-monorepo/packages/docs/dapp.rst +0 -126
  308. package/lib/reality-eth-monorepo/packages/docs/dapp_links.rst +0 -67
  309. package/lib/reality-eth-monorepo/packages/docs/fees.rst +0 -89
  310. package/lib/reality-eth-monorepo/packages/docs/index.rst +0 -26
  311. package/lib/reality-eth-monorepo/packages/docs/javascript.rst +0 -142
  312. package/lib/reality-eth-monorepo/packages/docs/make.bat +0 -36
  313. package/lib/reality-eth-monorepo/packages/docs/question_box.png +0 -0
  314. package/lib/reality-eth-monorepo/packages/docs/requirements.txt +0 -24
  315. package/lib/reality-eth-monorepo/packages/docs/whitepaper.rst +0 -165
  316. package/test/UpdateTest.t.sol +0 -55
  317. package/test/WhaleTest.t.sol +0 -188
  318. package/tooling/docs/jsdoc.json +0 -6
@@ -1,77 +0,0 @@
1
- = Using with Upgrades
2
-
3
- If your contract is going to be deployed with upgradeability, such as using the xref:upgrades-plugins::index.adoc[OpenZeppelin Upgrades Plugins], you will need to use the Upgradeable variant of OpenZeppelin Contracts.
4
-
5
- This variant is available as a separate package called `@openzeppelin/contracts-upgradeable`, which is hosted in the repository https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable[OpenZeppelin/openzeppelin-contracts-upgradeable]. It uses `@openzeppelin/contracts` as a peer dependency.
6
-
7
- It follows all of the rules for xref:upgrades-plugins::writing-upgradeable.adoc[Writing Upgradeable Contracts]: constructors are replaced by initializer functions, state variables are initialized in initializer functions, and we additionally check for storage incompatibilities across minor versions.
8
-
9
- TIP: OpenZeppelin provides a full suite of tools for deploying and securing upgradeable smart contracts. xref:openzeppelin::upgrades.adoc[Check out the full list of resources].
10
-
11
- == Overview
12
-
13
- === Installation
14
-
15
- ```console
16
- $ npm install @openzeppelin/contracts-upgradeable @openzeppelin/contracts
17
- ```
18
-
19
- === Usage
20
-
21
- The Upgradeable package replicates the structure of the main OpenZeppelin Contracts package, but every file and contract has the suffix `Upgradeable`.
22
-
23
- ```diff
24
- -import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
25
- +import {ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
26
-
27
- -contract MyCollectible is ERC721 {
28
- +contract MyCollectible is ERC721Upgradeable {
29
- ```
30
-
31
- NOTE: Interfaces and libraries are not included in the Upgradeable package, but are instead imported from the main OpenZeppelin Contracts package.
32
-
33
- Constructors are replaced by internal initializer functions following the naming convention `+__{ContractName}_init+`. Since these are internal, you must always define your own public initializer function and call the parent initializer of the contract you extend.
34
-
35
- ```diff
36
- - constructor() ERC721("MyCollectible", "MCO") public {
37
- + function initialize() initializer public {
38
- + __ERC721_init("MyCollectible", "MCO");
39
- }
40
- ```
41
-
42
- CAUTION: Use with multiple inheritance requires special attention. See the section below titled <<multiple-inheritance>>.
43
-
44
- Once this contract is set up and compiled, you can deploy it using the xref:upgrades-plugins::index.adoc[Upgrades Plugins]. The following snippet shows an example deployment script using Hardhat.
45
-
46
- ```js
47
- // scripts/deploy-my-collectible.js
48
- const { ethers, upgrades } = require("hardhat");
49
-
50
- async function main() {
51
- const MyCollectible = await ethers.getContractFactory("MyCollectible");
52
-
53
- const mc = await upgrades.deployProxy(MyCollectible);
54
-
55
- await mc.waitForDeployment();
56
- console.log("MyCollectible deployed to:", await mc.getAddress());
57
- }
58
-
59
- main();
60
- ```
61
-
62
- == Further Notes
63
-
64
- [[multiple-inheritance]]
65
- === Multiple Inheritance
66
-
67
- Initializer functions are not linearized by the compiler like constructors. Because of this, each `+__{ContractName}_init+` function embeds the linearized calls to all parent initializers. As a consequence, calling two of these `init` functions can potentially initialize the same contract twice.
68
-
69
- The function `+__{ContractName}_init_unchained+` found in every contract is the initializer function minus the calls to parent initializers, and can be used to avoid the double initialization problem, but doing this manually is not recommended. We hope to be able to implement safety checks for this in future versions of the Upgrades Plugins.
70
-
71
- === Namespaced Storage
72
-
73
- You may notice that contracts use a struct with the `@custom:storage-location erc7201:<NAMESPACE_ID>` annotation to store the contract's state variables. This follows the https://eips.ethereum.org/EIPS/eip-7201[ERC-7201: Namespaced Storage Layout] pattern, where each contract has its own storage layout in a namespace that is separate from other contracts in the inheritance chain.
74
-
75
- Without namespaced storage, it isn't safe to simply add a state variable because it "shifts down" all of the state variables below in the inheritance chain. This makes the storage layouts incompatible, as explained in xref:upgrades-plugins::writing-upgradeable.adoc#modifying-your-contracts[Writing Upgradeable Contracts].
76
-
77
- The namespaced storage pattern used in the Upgradeable package allows us to freely add new state variables in the future without compromising the storage compatibility with existing deployments. It also allows changing the inheritance order with no impact on the resulting storage layout, as long as all inherited contracts use namespaced storage.
@@ -1,591 +0,0 @@
1
- = Utilities
2
-
3
- The OpenZeppelin Contracts provide a ton of useful utilities that you can use in your project. For a complete list, check out the xref:api:utils.adoc[API Reference].
4
- Here are some of the more popular ones.
5
-
6
- [[cryptography]]
7
- == Cryptography
8
-
9
- === Checking Signatures On-Chain
10
-
11
- At a high level, signatures are a set of cryptographic algorithms that allow for a _signer_ to prove himself owner of a _private key_ used to authorize a piece of information (generally a transaction or `UserOperation`). Natively, the EVM supports the Elliptic Curve Digital Signature Algorithm (https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm[ECDSA]) using the secp256k1 curve, however other signature algorithms such as P256 and RSA are supported.
12
-
13
- ==== Ethereum Signatures (secp256k1)
14
-
15
- xref:api:utils/cryptography.adoc#ECDSA[`ECDSA`] provides functions for recovering and managing Ethereum account ECDSA signatures. These are often generated via https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#sign[`web3.eth.sign`], and form a 65-byte array (of type `bytes` in Solidity) arranged the following way: `[[v (1)], [r (32)], [s (32)]]`.
16
-
17
- The data signer can be recovered with xref:api:utils/cryptography.adoc#ECDSA-recover-bytes32-bytes-[`ECDSA.recover`], and its address compared to verify the signature. Most wallets will hash the data to sign and add the prefix `\x19Ethereum Signed Message:\n`, so when attempting to recover the signer of an Ethereum signed message hash, you'll want to use xref:api:utils/cryptography.adoc#MessageHashUtils-toEthSignedMessageHash-bytes32-[`toEthSignedMessageHash`].
18
-
19
- [source,solidity]
20
- ----
21
- using ECDSA for bytes32;
22
- using MessageHashUtils for bytes32;
23
-
24
- function _verify(bytes32 data, bytes memory signature, address account) internal pure returns (bool) {
25
- return data
26
- .toEthSignedMessageHash()
27
- .recover(signature) == account;
28
- }
29
- ----
30
-
31
- WARNING: Getting signature verification right is not trivial: make sure you fully read and understand xref:api:utils/cryptography.adoc#MessageHashUtils[`MessageHashUtils`]'s and xref:api:utils/cryptography.adoc#ECDSA[`ECDSA`]'s documentation.
32
-
33
- ==== P256 Signatures (secp256r1)
34
-
35
- P256, also known as secp256r1, is one of the most used signature schemes. P256 signatures are standardized by the National Institute of Standards and Technology (NIST) and they are widely available in consumer hardware and software.
36
-
37
- These signatures are different from regular Ethereum Signatures (secp256k1) in that they use a different elliptic curve to perform operations but have similar security guarantees.
38
-
39
- [source,solidity]
40
- ----
41
- using P256 for bytes32;
42
-
43
- function _verify(
44
- bytes32 data,
45
- bytes32 r,
46
- bytes32 s,
47
- bytes32 qx,
48
- bytes32 qy
49
- ) internal pure returns (bool) {
50
- return data.verify(data, r, s, qx, qy);
51
- }
52
- ----
53
-
54
- By default, the `verify` function will try calling the https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md[RIP-7212] precompile at address `0x100` and will fallback to an implementation in Solidity if not available. We encourage you to use `verifyNative` if you know the precompile is available on the chain you're working on and on any other chain on which you intend to use the same bytecode in the future. In case of any doubts regarding the implementation roadmap of the native precompile `P256` of potential future target chains, please consider using `verifySolidity`.
55
-
56
- [source,solidity]
57
- ----
58
- using P256 for bytes32;
59
-
60
- function _verify(
61
- bytes32 data,
62
- bytes32 r,
63
- bytes32 s,
64
- bytes32 qx,
65
- bytes32 qy
66
- ) internal pure returns (bool) {
67
- // Will only call the precompile at address(0x100)
68
- return data.verifyNative(data, r, s, qx, qy);
69
- }
70
- ----
71
-
72
- IMPORTANT: The P256 library only allows for `s` values in the lower order of the curve (i.e. `s <= N/2`) to prevent malleability. In case your tooling produces signatures in both sides of the curve, consider flipping the `s` value to keep compatibility.
73
-
74
- ==== RSA
75
-
76
- RSA is a public-key cryptosystem that was popularized by corporate and governmental public key infrastructures (https://en.wikipedia.org/wiki/Public_key_infrastructure[PKIs]) and https://en.wikipedia.org/wiki/Domain_Name_System_Security_Extensions[DNSSEC].
77
-
78
- This cryptosystem consists of using a private key that's the product of 2 large prime numbers. The message is signed by applying a modular exponentiation to its hash (commonly SHA256), where both the exponent and modulus compose the public key of the signer.
79
-
80
- RSA signatures are known for being less efficient than elliptic curve signatures given the size of the keys, which are big compared to ECDSA keys with the same security level. Using plain RSA is considered unsafe, this is why the implementation uses the `EMSA-PKCS1-v1_5` encoding method from https://datatracker.ietf.org/doc/html/rfc8017[RFC8017] to include padding to the signature.
81
-
82
- To verify a signature using RSA, you can leverage the xref:api:utils/cryptography.adoc#RSA[`RSA`] library that exposes a method for verifying RSA with the PKCS 1.5 standard:
83
-
84
- [source,solidity]
85
- ----
86
- using RSA for bytes32;
87
-
88
- function _verify(
89
- bytes32 data,
90
- bytes memory signature,
91
- bytes memory e,
92
- bytes memory n
93
- ) internal pure returns (bool) {
94
- return data.pkcs1Sha256(signature, e, n);
95
- }
96
- ----
97
-
98
- IMPORTANT: Always use keys of at least 2048 bits. Additionally, be aware that PKCS#1 v1.5 allows for replayability due to the possibility of arbitrary optional parameters. To prevent replay attacks, consider including an onchain nonce or unique identifier in the message.
99
-
100
- === Signature Verification
101
-
102
- The xref:api:utils/cryptography.adoc#SignatureChecker[`SignatureChecker`] library provides a unified interface for verifying signatures from different sources. It seamlessly supports:
103
-
104
- * ECDSA signatures from externally owned accounts (EOAs)
105
- * ERC-1271 signatures from smart contract wallets like Argent and Safe Wallet
106
- * ERC-7913 signatures from keys that don't have their own Ethereum address
107
-
108
- This allows developers to write signature verification code once and have it work across all these different signature types.
109
-
110
- ==== Basic Signature Verification
111
-
112
- For standard signature verification that supports both EOAs and ERC-1271 contracts:
113
-
114
- [source,solidity]
115
- ----
116
- using SignatureChecker for address;
117
-
118
- function _verifySignature(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {
119
- return SignatureChecker.isValidSignatureNow(signer, hash, signature);
120
- }
121
- ----
122
-
123
- The library automatically detects whether the signer is an EOA or a contract and uses the appropriate verification method.
124
-
125
- ==== ERC-1271 Contract Signatures
126
-
127
- For smart contract wallets that implement ERC-1271, you can explicitly use:
128
-
129
- [source,solidity]
130
- ----
131
- function _verifyContractSignature(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {
132
- return SignatureChecker.isValidERC1271SignatureNow(signer, hash, signature);
133
- }
134
- ----
135
-
136
- ==== ERC-7913 Extended Signatures
137
-
138
- ERC-7913 extends signature verification to support keys that don't have their own Ethereum address. This is useful for integrating non-Ethereum cryptographic curves, hardware devices, or other identity systems.
139
-
140
- A signer is represented as a `bytes` object that concatenates a verifier address and a key: `verifier || key`.
141
-
142
- [source,solidity]
143
- ----
144
- function _verifyERC7913Signature(bytes memory signer, bytes32 hash, bytes memory signature) internal view returns (bool) {
145
- return SignatureChecker.isValidSignatureNow(signer, hash, signature);
146
- }
147
- ----
148
-
149
- The verification process works as follows:
150
-
151
- * If `signer.length < 20`: verification fails
152
- * If `signer.length == 20`: verification is done using standard signature checking
153
- * Otherwise: verification is done using an ERC-7913 verifier
154
-
155
- ==== Batch Verification
156
-
157
- For verifying multiple ERC-7913 signatures at once:
158
-
159
- [source,solidity]
160
- ----
161
- function _verifyMultipleSignatures(
162
- bytes32 hash,
163
- bytes[] memory signers,
164
- bytes[] memory signatures
165
- ) internal view returns (bool) {
166
- return SignatureChecker.areValidSignaturesNow(hash, signers, signatures);
167
- }
168
- ----
169
-
170
- This function will reject inputs that contain duplicated signers. Sorting the signers by their `keccak256` hash is recommended to minimize the gas cost.
171
-
172
- This unified approach allows smart contracts to accept signatures from any supported source without needing to implement different verification logic for each type.
173
-
174
- === Verifying Merkle Proofs
175
-
176
- Developers can build a Merkle Tree off-chain, which allows for verifying that an element (leaf) is part of a set by using a Merkle Proof. This technique is widely used for creating whitelists (e.g., for airdrops) and other advanced use cases.
177
-
178
- TIP: OpenZeppelin Contracts provides a https://github.com/OpenZeppelin/merkle-tree[JavaScript library] for building trees off-chain and generating proofs.
179
-
180
- xref:api:utils/cryptography.adoc#MerkleProof[`MerkleProof`] provides:
181
-
182
- * xref:api:utils/cryptography.adoc#MerkleProof-verify-bytes32---bytes32-bytes32-[`verify`] - can prove that some value is part of a https://en.wikipedia.org/wiki/Merkle_tree[Merkle tree].
183
-
184
- * xref:api:utils/cryptography.adoc#MerkleProof-multiProofVerify-bytes32-bytes32---bytes32---bool---[`multiProofVerify`] - can prove multiple values are part of a Merkle tree.
185
-
186
- For an on-chain Merkle Tree, see the xref:api:utils.adoc#MerkleTree[`MerkleTree`] library.
187
-
188
- [[introspection]]
189
- == Introspection
190
-
191
- In Solidity, it's frequently helpful to know whether or not a contract supports an interface you'd like to use. ERC-165 is a standard that helps do runtime interface detection. Contracts provide helpers both for implementing ERC-165 in your contracts and querying other contracts:
192
-
193
- * xref:api:utils.adoc#IERC165[`IERC165`] — this is the ERC-165 interface that defines xref:api:utils.adoc#IERC165-supportsInterface-bytes4-[`supportsInterface`]. When implementing ERC-165, you'll conform to this interface.
194
- * xref:api:utils.adoc#ERC165[`ERC165`] — inherit this contract if you'd like to support interface detection using a lookup table in contract storage. You can register interfaces using xref:api:utils.adoc#ERC165-_registerInterface-bytes4-[`_registerInterface(bytes4)`]: check out example usage as part of the ERC-721 implementation.
195
- * xref:api:utils.adoc#ERC165Checker[`ERC165Checker`] — ERC165Checker simplifies the process of checking whether or not a contract supports an interface you care about.
196
- * include with `using ERC165Checker for address;`
197
- * xref:api:utils.adoc#ERC165Checker-_supportsInterface-address-bytes4-[`myAddress._supportsInterface(bytes4)`]
198
- * xref:api:utils.adoc#ERC165Checker-_supportsAllInterfaces-address-bytes4---[`myAddress._supportsAllInterfaces(bytes4[\])`]
199
-
200
- [source,solidity]
201
- ----
202
- contract MyContract {
203
- using ERC165Checker for address;
204
-
205
- bytes4 private InterfaceId_ERC721 = 0x80ac58cd;
206
-
207
- /**
208
- * @dev transfer an ERC-721 token from this contract to someone else
209
- */
210
- function transferERC721(
211
- address token,
212
- address to,
213
- uint256 tokenId
214
- )
215
- public
216
- {
217
- require(token.supportsInterface(InterfaceId_ERC721), "IS_NOT_721_TOKEN");
218
- IERC721(token).transferFrom(address(this), to, tokenId);
219
- }
220
- }
221
- ----
222
-
223
- [[math]]
224
- == Math
225
-
226
- Although Solidity already provides math operators (i.e. `+`, `-`, etc.), Contracts includes xref:api:utils.adoc#Math[`Math`]; a set of utilities for dealing with mathematical operators, with support for extra operations (e.g., xref:api:utils.adoc#Math-average-uint256-uint256-[`average`]) and xref:api:utils.adoc#SignedMath[`SignedMath`]; a library specialized in signed math operations.
227
-
228
- Include these contracts with `using Math for uint256` or `using SignedMath for int256` and then use their functions in your code:
229
-
230
- [source,solidity]
231
- ----
232
- contract MyContract {
233
- using Math for uint256;
234
- using SignedMath for int256;
235
-
236
- function tryOperations(uint256 a, uint256 b) internal pure {
237
- (bool succeededAdd, uint256 resultAdd) = x.tryAdd(y);
238
- (bool succeededSub, uint256 resultSub) = x.trySub(y);
239
- (bool succeededMul, uint256 resultMul) = x.tryMul(y);
240
- (bool succeededDiv, uint256 resultDiv) = x.tryDiv(y);
241
- // ...
242
- }
243
-
244
- function unsignedAverage(int256 a, int256 b) {
245
- int256 avg = a.average(b);
246
- // ...
247
- }
248
- }
249
- ----
250
-
251
- Easy!
252
-
253
- TIP: While working with different data types that might require casting, you can use xref:api:utils.adoc#SafeCast[`SafeCast`] for type casting with added overflow checks.
254
-
255
- [[structures]]
256
- == Structures
257
-
258
- Some use cases require more powerful data structures than arrays and mappings offered natively in Solidity. Contracts provides these libraries for enhanced data structure management:
259
-
260
- - xref:api:utils.adoc#BitMaps[`BitMaps`]: Store packed booleans in storage.
261
- - xref:api:utils.adoc#Checkpoints[`Checkpoints`]: Checkpoint values with built-in lookups.
262
- - xref:api:utils.adoc#DoubleEndedQueue[`DoubleEndedQueue`]: Store items in a queue with `pop()` and `queue()` constant time operations.
263
- - xref:api:utils.adoc#EnumerableSet[`EnumerableSet`]: A https://en.wikipedia.org/wiki/Set_(abstract_data_type)[set] with enumeration capabilities.
264
- - xref:api:utils.adoc#EnumerableMap[`EnumerableMap`]: A `mapping` variant with enumeration capabilities.
265
- - xref:api:utils.adoc#MerkleTree[`MerkleTree`]: An on-chain https://wikipedia.org/wiki/Merkle_Tree[Merkle Tree] with helper functions.
266
- - xref:api:utils.adoc#Heap.sol[`Heap`]: A https://en.wikipedia.org/wiki/Binary_heap[binary heap] to store elements with priority defined by a compartor function.
267
-
268
- The `Enumerable*` structures are similar to mappings in that they store and remove elements in constant time and don't allow for repeated entries, but they also support _enumeration_, which means you can easily query all stored entries both on and off-chain.
269
-
270
- === Building a Merkle Tree
271
-
272
- Building an on-chain Merkle Tree allows developers to keep track of the history of roots in a decentralized manner. For these cases, the xref:api:utils.adoc#MerkleTree[`MerkleTree`] includes a predefined structure with functions to manipulate the tree (e.g. pushing values or resetting the tree).
273
-
274
- The Merkle Tree does not keep track of the roots intentionally, so that developers can choose their tracking mechanism. Setting up and using a Merkle Tree in Solidity is as simple as follows:
275
-
276
- NOTE: Functions are exposed without access control for demonstration purposes
277
-
278
- [source,solidity]
279
- ----
280
- using MerkleTree for MerkleTree.Bytes32PushTree;
281
- MerkleTree.Bytes32PushTree private _tree;
282
-
283
- function setup(uint8 _depth, bytes32 _zero) public /* onlyOwner */ {
284
- root = _tree.setup(_depth, _zero);
285
- }
286
-
287
- function push(bytes32 leaf) public /* onlyOwner */ {
288
- (uint256 leafIndex, bytes32 currentRoot) = _tree.push(leaf);
289
- // Store the new root.
290
- }
291
- ----
292
-
293
- The library also supports custom hashing functions, which can be passed as an extra parameter to the xref:api:utils.adoc#MerkleTree-push-struct-MerkleTree-Bytes32PushTree-bytes32-[`push`] and xref:api:utils.adoc#MerkleTree-setup-struct-MerkleTree-Bytes32PushTree-uint8-bytes32-[`setup`] functions.
294
-
295
- Using custom hashing functions is a sensitive operation. After setup, it requires to keep using the same hashing function for every new value pushed to the tree to avoid corrupting the tree. For this reason, it's a good practice to keep your hashing function static in your implementation contract as follows:
296
-
297
- [source,solidity]
298
- ----
299
- using MerkleTree for MerkleTree.Bytes32PushTree;
300
- MerkleTree.Bytes32PushTree private _tree;
301
-
302
- function setup(uint8 _depth, bytes32 _zero) public /* onlyOwner */ {
303
- root = _tree.setup(_depth, _zero, _hashFn);
304
- }
305
-
306
- function push(bytes32 leaf) public /* onlyOwner */ {
307
- (uint256 leafIndex, bytes32 currentRoot) = _tree.push(leaf, _hashFn);
308
- // Store the new root.
309
- }
310
-
311
- function _hashFn(bytes32 a, bytes32 b) internal view returns(bytes32) {
312
- // Custom hash function implementation
313
- // Kept as an internal implementation detail to
314
- // guarantee the same function is always used
315
- }
316
- ----
317
-
318
- === Using a Heap
319
-
320
- A https://en.wikipedia.org/wiki/Binary_heap[binary heap] is a data structure that always stores the most important element at its peak and it can be used as a priority queue.
321
-
322
- To define what is most important in a heap, these frequently take comparator functions that tell the binary heap whether a value has more relevance than another.
323
-
324
- OpenZeppelin Contracts implements a Heap data structure with the properties of a binary heap. The heap uses the xref:api:utils.adoc#Comparators-lt-uint256-uint256-[`lt`] function by default but allows to customize its comparator.
325
-
326
- When using a custom comparator, it's recommended to wrap your function to avoid the possibility of mistakenly using a different comparator function:
327
-
328
- [source,solidity]
329
- ----
330
- function pop(Uint256Heap storage self) internal returns (uint256) {
331
- return pop(self, Comparators.gt);
332
- }
333
-
334
- function insert(Uint256Heap storage self, uint256 value) internal {
335
- insert(self, value, Comparators.gt);
336
- }
337
-
338
- function replace(Uint256Heap storage self, uint256 newValue) internal returns (uint256) {
339
- return replace(self, newValue, Comparators.gt);
340
- }
341
- ----
342
-
343
-
344
- [[misc]]
345
- == Misc
346
-
347
- === Packing
348
-
349
- The storage in the EVM is shaped in chunks of 32 bytes, each of this chunks is known as a _slot_, and can hold multiple values together as long as these values don't exceed its size. These properties of the storage allow for a technique known as _packing_, that consists of placing values together on a single storage slot to reduce the costs associated to reading and writing to multiple slots instead of just one.
350
-
351
- Commonly, developers pack values using structs that place values together so they fit better in storage. However, this approach requires to load such struct from either calldata or memory. Although sometimes necessary, it may be useful to pack values in a single slot and treat it as a packed value without involving calldata or memory.
352
-
353
- The xref:api:utils.adoc#Packing[`Packing`] library is a set of utilities for packing values that fit in 32 bytes. The library includes 3 main functionalities:
354
-
355
- * Packing 2 `bytesXX` values
356
- * Extracting a packed `bytesXX` value from a `bytesYY`
357
- * Replacing a packed `bytesXX` value from a `bytesYY`
358
-
359
- With these primitives, one can build custom functions to create custom packed types. For example, suppose you need to pack an `address` of 20 bytes with a `bytes4` selector and an `uint64` time period:
360
-
361
- [source,solidity]
362
- ----
363
- function _pack(address account, bytes4 selector, uint64 period) external pure returns (bytes32) {
364
- bytes12 subpack = Packing.pack_4_8(selector, bytes8(period));
365
- return Packing.pack_20_12(bytes20(account), subpack);
366
- }
367
-
368
- function _unpack(bytes32 pack) external pure returns (address, bytes4, uint64) {
369
- return (
370
- address(Packing.extract_32_20(pack, 0)),
371
- Packing.extract_32_4(pack, 20),
372
- uint64(Packing.extract_32_8(pack, 24))
373
- );
374
- }
375
- ----
376
-
377
- === Storage Slots
378
-
379
- Solidity allocates a storage pointer for each variable declared in a contract. However, there are cases when it's required to access storage pointers that can't be derived by using regular Solidity.
380
- For those cases, the xref:api:utils.adoc#StorageSlot[`StorageSlot`] library allows for manipulating storage slots directly.
381
-
382
- [source,solidity]
383
- ----
384
- bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
385
-
386
- function _getImplementation() internal view returns (address) {
387
- return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
388
- }
389
-
390
- function _setImplementation(address newImplementation) internal {
391
- require(newImplementation.code.length > 0);
392
- StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
393
- }
394
- ----
395
-
396
- The xref:api:utils.adoc#TransientSlot[`TransientSlot`] library supports transient storage through user defined value types (https://docs.soliditylang.org/en/latest/types.html#user-defined-value-types[UDVTs]), which enables the same value types as in Solidity.
397
-
398
- [source,solidity]
399
- ----
400
- bytes32 internal constant _LOCK_SLOT = 0xf4678858b2b588224636b8522b729e7722d32fc491da849ed75b3fdf3c84f542;
401
-
402
- function _getTransientLock() internal view returns (bool) {
403
- return _LOCK_SLOT.asBoolean().tload();
404
- }
405
-
406
- function _setTransientLock(bool lock) internal {
407
- _LOCK_SLOT.asBoolean().tstore(lock);
408
- }
409
- ----
410
-
411
- WARNING: Manipulating storage slots directly is an advanced practice. Developers MUST make sure that the storage pointer is not colliding with other variables.
412
-
413
- One of the most common use cases for writing directly to storage slots is ERC-7201 for namespaced storage, which is guaranteed to not collide with other storage slots derived by Solidity.
414
-
415
- Users can leverage this standard using the xref:api:utils.adoc#SlotDerivation[`SlotDerivation`] library.
416
-
417
- [source,solidity]
418
- ----
419
- using SlotDerivation for bytes32;
420
- string private constant _NAMESPACE = "<namespace>" // eg. example.main
421
-
422
- function erc7201Pointer() internal view returns (bytes32) {
423
- return _NAMESPACE.erc7201Slot();
424
- }
425
- ----
426
-
427
- === Base64
428
-
429
- xref:api:utils.adoc#Base64[`Base64`] util allows you to transform `bytes32` data into its Base64 `string` representation.
430
-
431
- This is especially useful for building URL-safe tokenURIs for both xref:api:token/ERC721.adoc#IERC721Metadata-tokenURI-uint256-[`ERC-721`] or xref:api:token/ERC1155.adoc#IERC1155MetadataURI-uri-uint256-[`ERC-1155`]. This library provides a clever way to serve URL-safe https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs/[Data URI] compliant strings to serve on-chain data structures.
432
-
433
- Here is an example to send JSON Metadata through a Base64 Data URI using an ERC-721:
434
-
435
- [source,solidity]
436
- ----
437
- include::api:example$utilities/Base64NFT.sol[]
438
- ----
439
-
440
- === Multicall
441
-
442
- The `Multicall` abstract contract comes with a `multicall` function that bundles together multiple calls in a single external call. With it, external accounts may perform atomic operations comprising several function calls. This is not only useful for EOAs to make multiple calls in a single transaction, it's also a way to revert a previous call if a later one fails.
443
-
444
- Consider this dummy contract:
445
-
446
- [source,solidity]
447
- ----
448
- include::api:example$utilities/Multicall.sol[]
449
- ----
450
-
451
- This is how to call the `multicall` function using Ethers.js, allowing `foo` and `bar` to be called in a single transaction:
452
- [source,javascript]
453
- ----
454
- // scripts/foobar.js
455
-
456
- const instance = await ethers.deployContract("Box");
457
-
458
- await instance.multicall([
459
- instance.interface.encodeFunctionData("foo"),
460
- instance.interface.encodeFunctionData("bar")
461
- ]);
462
- ----
463
-
464
- === Memory
465
-
466
- The xref:api:utils.adoc#Memory[`Memory`] library provides functions for advanced use cases that require granular memory management. A common use case is to avoid unnecessary memory expansion costs when performing repeated operations that allocate memory in a loop. Consider the following example:
467
-
468
- [source,solidity]
469
- ----
470
- function processMultipleItems(uint256[] memory items) internal {
471
- for (uint256 i = 0; i < items.length; i++) {
472
- bytes memory tempData = abi.encode(items[i], block.timestamp);
473
- // Process tempData...
474
- }
475
- }
476
- ----
477
-
478
- Note that each iteration allocates new memory for `tempData`, causing the memory to expand continuously. This can be optimized by resetting the memory pointer between iterations:
479
-
480
- [source,solidity]
481
- ----
482
- function processMultipleItems(uint256[] memory items) internal {
483
- Memory.Pointer ptr = Memory.getFreeMemoryPointer(); // Cache pointer
484
- for (uint256 i = 0; i < items.length; i++) {
485
- bytes memory tempData = abi.encode(items[i], block.timestamp);
486
- // Process tempData...
487
- Memory.setFreeMemoryPointer(ptr); // Reset pointer for reuse
488
- }
489
- }
490
- ----
491
-
492
- This way, memory allocated for `tempData` in each iteration is reused, significantly reducing memory expansion costs when processing many items.
493
-
494
- IMPORTANT: Only use these functions after carefully confirming they're necessary. By default, Solidity handles memory safely. Using this library without understanding memory layout and safety may be dangerous. See the https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_memory.html[memory layout] and https://docs.soliditylang.org/en/v0.8.20/assembly.html#memory-safety[memory safety] documentation for details.
495
-
496
- === Historical Block Hashes
497
-
498
- xref:api:utils.adoc#Blockhash[`Blockhash`] provides L2 protocol developers with extended access to historical block hashes beyond Ethereum's native 256-block limit. By leveraging https://eips.ethereum.org/EIPS/eip-2935[EIP-2935]'s history storage contract, the library enables access to block hashes up to 8,191 blocks in the past, making it invaluable for L2 fraud proofs and state verification systems.
499
-
500
- The library seamlessly combines native `BLOCKHASH` opcode access for recent blocks (≤256) with EIP-2935 history storage queries for older blocks (257-8,191). It handles edge cases gracefully by returning zero for future blocks or those beyond the history window, matching the EVM's behavior. The implementation uses gas-efficient assembly for static calls to the history storage contract.
501
-
502
- [source,solidity]
503
- ----
504
- contract L1Inbox {
505
- using Blockhash for uint256;
506
-
507
- function verifyBlockHash(uint256 blockNumber, bytes32 expectedHash) public view returns (bool) {
508
- return blockNumber.blockHash() == expectedHash;
509
- }
510
- }
511
- ----
512
-
513
- IMPORTANT: After EIP-2935 activation, it takes 8,191 blocks to completely fill the history storage. Before that, only block hashes since the fork block will be available.
514
-
515
- === Time
516
-
517
- The xref:api:utils.adoc#Time[`Time`] library provides helpers for manipulating time-related objects in a type-safe manner. It uses `uint48` for timepoints and `uint32` for durations, helping to reduce gas costs while providing adequate precision.
518
-
519
- One of its key features is the `Delay` type, which represents a duration that can automatically change its value at a specified point in the future while maintaining delay guarantees. For example, when reducing a delay value (e.g., from 7 days to 1 day), the change only takes effect after the difference between the old and new delay (i.e. a 6 days) or a minimum setback period, preventing an attacker who gains admin access from immediately reducing security timeouts and executing sensitive operations. This is particularly useful for governance and security mechanisms where timelock periods need to be enforced.
520
-
521
- Consider this example for using and safely updating Delays:
522
- [source,solidity]
523
- ----
524
- // SPDX-License-Identifier: MIT
525
- pragma solidity ^0.8.27;
526
-
527
- import {Time} from "contracts/utils/types/Time.sol";
528
-
529
- contract MyDelayedContract {
530
- using Time for *;
531
-
532
- Time.Delay private _delay;
533
-
534
- constructor() {
535
- _delay = Time.toDelay(3 days);
536
- }
537
-
538
- function schedule(bytes32 operationId) external {
539
- // Get the current `_delay` value, respecting any pending delay changes if they've taken effect
540
- uint32 currentDelay = _delay.get();
541
- uint48 executionTime = Time.timestamp() + currentDelay;
542
-
543
- // ... schedule the operation at `executionTime`
544
- }
545
-
546
- function execute(bytes32 operationId) external {
547
- uint48 executionTime = getExecutionTime(operationId);
548
- require(executionTime > 0, "Operation not scheduled");
549
- require(Time.timestamp() >= executionTime, "Delay not elapsed yet");
550
-
551
- // ... execute the operation
552
- }
553
-
554
- // Update the delay with `Time`'s safety mechanism
555
- function updateDelay(uint32 newDelay) external {
556
- (Time.Delay updatedDelay, uint48 effect) = _delay.withUpdate(
557
- newDelay, // The new delay value
558
- 5 days // Minimum setback if reducing the delay
559
- );
560
-
561
- _delay = updatedDelay;
562
-
563
- // ... emit events
564
- }
565
-
566
- // Get complete delay details including pending changes
567
- function getDelayDetails() external view returns (
568
- uint32 currentValue, // The current delay value
569
- uint32 pendingValue, // The pending delay value
570
- uint48 effectTime // The timepoint when the pending delay change takes effect
571
- ) {
572
- return _delay.getFull();
573
- }
574
- }
575
- ----
576
-
577
- This pattern is used extensively in OpenZeppelin's xref:api:access.adoc#AccessManager[AccessManager] for implementing secure time-based access control. For example, when changing an admin delay:
578
-
579
- [source,solidity]
580
- ----
581
- // From AccessManager.sol
582
- function _setTargetAdminDelay(address target, uint32 newDelay) internal virtual {
583
- uint48 effect;
584
- (_targets[target].adminDelay, effect) = _targets[target].adminDelay.withUpdate(
585
- newDelay,
586
- minSetback()
587
- );
588
-
589
- emit TargetAdminDelayUpdated(target, newDelay, effect);
590
- }
591
- ----