@artblocks/contracts 1.2.1 → 1.3.1

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 (71) hide show
  1. package/artifacts/contracts/BytecodeStorageReaders/BytecodeStorageReaderContractV2_Web3Call.sol/BytecodeStorageReaderContractV2_Web3Call.json +201 -0
  2. package/artifacts/contracts/BytecodeStorageReaders/UniversalBytecodeStorageReader.sol/UniversalBytecodeStorageReader.json +2 -2
  3. package/artifacts/contracts/DependencyRegistryV0.sol/DependencyRegistryV0.json +42 -53
  4. package/artifacts/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol/GenArt721CoreV3_Engine_Flex.json +2 -2
  5. package/artifacts/contracts/generator/GenArt721GeneratorV0.sol/GenArt721GeneratorV0.json +2 -2
  6. package/artifacts/contracts/interfaces/v0.8.x/IDelegateRegistry.sol/IDelegateRegistry.json +820 -0
  7. package/artifacts/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol/IDependencyRegistryV0.json +13 -0
  8. package/artifacts/contracts/interfaces/v0.8.x/IPMPAugmentHook.sol/IPMPAugmentHook.json +83 -0
  9. package/artifacts/contracts/interfaces/v0.8.x/IPMPConfigureHook.sol/IPMPConfigureHook.json +80 -0
  10. package/artifacts/contracts/interfaces/v0.8.x/IPMPV0.sol/IPMPV0.json +402 -0
  11. package/artifacts/contracts/interfaces/v0.8.x/IUniversalBytecodeStorageReader.sol/IUniversalBytecodeStorageReader.json +13 -0
  12. package/artifacts/contracts/interfaces/v0.8.x/IWeb3Call.sol/IWeb3Call.json +47 -0
  13. package/artifacts/contracts/libs/integration-refs/delegation-registry/DelegateRegistry.sol/DelegateRegistry.json +846 -0
  14. package/artifacts/contracts/libs/integration-refs/delegation-registry/libraries/RegistryHashes.sol/RegistryHashes.json +10 -0
  15. package/artifacts/contracts/libs/integration-refs/delegation-registry/libraries/RegistryOps.sol/RegistryOps.json +10 -0
  16. package/artifacts/contracts/libs/integration-refs/delegation-registry/libraries/RegistryStorage.sol/RegistryStorage.json +10 -0
  17. package/artifacts/contracts/libs/v0.8.x/DependencyRegistryStorageLib.sol/DependencyRegistryStorageLib.json +2 -2
  18. package/artifacts/contracts/libs/v0.8.x/ImmutableStringArray.sol/ImmutableStringArray.json +10 -0
  19. package/artifacts/contracts/libs/v0.8.x/V3FlexLib.sol/V3FlexLib.json +2 -2
  20. package/artifacts/contracts/mock/ImmutableStringArrayMock.sol/ImmutableStringArrayMock.json +69 -0
  21. package/artifacts/contracts/mock/MockPMPAugmentHook.sol/MockPMPAugmentHook.json +214 -0
  22. package/artifacts/contracts/mock/MockPMPConfigureHook.sol/MockPMPConfigureHook.json +236 -0
  23. package/artifacts/contracts/web3call/PMPV0.sol/PMPV0.json +629 -0
  24. package/artifacts/contracts/web3call/Web3Call.sol/Web3Call.json +66 -0
  25. package/artifacts/contracts/web3call/augment-hooks/AbstractPMPAugmentHook.sol/AbstractPMPAugmentHook.json +83 -0
  26. package/artifacts/contracts/web3call/augment-hooks/InjectBaseGasFee.sol/InjectBaseGasFee.json +83 -0
  27. package/artifacts/contracts/web3call/augment-hooks/InjectChromieSquiggleFloorPrice.sol/IUniswapV2Pair.json +60 -0
  28. package/artifacts/contracts/web3call/augment-hooks/InjectChromieSquiggleFloorPrice.sol/InjectChromieSquiggleFloorPrice.json +107 -0
  29. package/artifacts/contracts/web3call/augment-hooks/InjectIsNounsDaoMember.sol/InjectIsNounsDaoMember.json +96 -0
  30. package/artifacts/contracts/web3call/augment-hooks/InjectIsProjectFullyMinted.sol/InjectIsProjectFullyMinted.json +83 -0
  31. package/artifacts/contracts/web3call/augment-hooks/InjectPolyptychTokenHash.sol/InjectPolyptychTokenHash.json +141 -0
  32. package/artifacts/contracts/web3call/augment-hooks/InjectTokenHashSeed.sol/InjectTokenHashSeed.json +99 -0
  33. package/artifacts/contracts/web3call/augment-hooks/InjectTokenOwner.sol/InjectTokenOwner.json +99 -0
  34. package/artifacts/contracts/web3call/augment-hooks/InjectTokenOwnerEthBalance.sol/InjectTokenOwnerEthBalance.json +83 -0
  35. package/artifacts/contracts/web3call/augment-hooks/InjectUSDCTotalSupply.sol/InjectUSDCTotalSupply.json +107 -0
  36. package/artifacts/contracts/web3call/configure-hooks/abstractPMPConfigureHook.sol/AbstractPMPConfigureHook.json +80 -0
  37. package/contracts/BytecodeStorageReaders/BytecodeStorageReaderContractV2_Web3Call.sol +128 -0
  38. package/contracts/DependencyRegistryV0.sol +67 -28
  39. package/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol +7 -1
  40. package/contracts/generator/GenArt721GeneratorV0.sol +77 -8
  41. package/contracts/interfaces/v0.8.x/IDelegateRegistry.sol +318 -0
  42. package/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol +2 -0
  43. package/contracts/interfaces/v0.8.x/IPMPAugmentHook.sol +31 -0
  44. package/contracts/interfaces/v0.8.x/IPMPConfigureHook.sol +25 -0
  45. package/contracts/interfaces/v0.8.x/IPMPV0.sol +224 -0
  46. package/contracts/interfaces/v0.8.x/IUniversalBytecodeStorageReader.sol +5 -0
  47. package/contracts/interfaces/v0.8.x/IWeb3Call.sol +28 -0
  48. package/contracts/libs/integration-refs/delegation-registry/DelegateRegistry.sol +753 -0
  49. package/contracts/libs/integration-refs/delegation-registry/libraries/RegistryHashes.sol +359 -0
  50. package/contracts/libs/integration-refs/delegation-registry/libraries/RegistryOps.sol +31 -0
  51. package/contracts/libs/integration-refs/delegation-registry/libraries/RegistryStorage.sol +87 -0
  52. package/contracts/libs/v0.8.x/DependencyRegistryStorageLib.sol +3 -0
  53. package/contracts/libs/v0.8.x/ImmutableStringArray.sol +301 -0
  54. package/contracts/libs/v0.8.x/V3FlexLib.sol +7 -1
  55. package/contracts/mock/ImmutableStringArrayMock.sol +47 -0
  56. package/contracts/mock/MockPMPAugmentHook.sol +170 -0
  57. package/contracts/mock/MockPMPConfigureHook.sol +78 -0
  58. package/contracts/web3call/PMPV0.sol +1126 -0
  59. package/contracts/web3call/Web3Call.sol +25 -0
  60. package/contracts/web3call/augment-hooks/AbstractPMPAugmentHook.sol +46 -0
  61. package/contracts/web3call/augment-hooks/InjectBaseGasFee.sol +57 -0
  62. package/contracts/web3call/augment-hooks/InjectChromieSquiggleFloorPrice.sol +103 -0
  63. package/contracts/web3call/augment-hooks/InjectIsNounsDaoMember.sol +66 -0
  64. package/contracts/web3call/augment-hooks/InjectIsProjectFullyMinted.sol +73 -0
  65. package/contracts/web3call/augment-hooks/InjectPolyptychTokenHash.sol +88 -0
  66. package/contracts/web3call/augment-hooks/InjectTokenHashSeed.sol +62 -0
  67. package/contracts/web3call/augment-hooks/InjectTokenOwner.sol +60 -0
  68. package/contracts/web3call/augment-hooks/InjectTokenOwnerEthBalance.sol +61 -0
  69. package/contracts/web3call/augment-hooks/InjectUSDCTotalSupply.sol +69 -0
  70. package/contracts/web3call/configure-hooks/abstractPMPConfigureHook.sol +41 -0
  71. package/package.json +5 -5
@@ -0,0 +1,25 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import {IWeb3Call} from "../interfaces/v0.8.x/IWeb3Call.sol";
7
+
8
+ import {ERC165} from "@openzeppelin-5.0/contracts/utils/introspection/ERC165.sol";
9
+
10
+ /**
11
+ * @title Abstract Web3Call contract
12
+ * @author Art Blocks Inc.
13
+ * @notice This abstract can be inherited by any contract that wants to implement the Web3Call interface.
14
+ * It indicates support for the IWeb3Call interface via ERC165 interface detection, and ensures that all
15
+ * child contracts implement the required IWeb3Call functions.
16
+ */
17
+ abstract contract Web3Call is IWeb3Call, ERC165 {
18
+ function supportsInterface(
19
+ bytes4 interfaceId
20
+ ) public view override returns (bool) {
21
+ return
22
+ interfaceId == type(IWeb3Call).interfaceId ||
23
+ super.supportsInterface(interfaceId);
24
+ }
25
+ }
@@ -0,0 +1,46 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import {IPMPAugmentHook} from "../../interfaces/v0.8.x/IPMPAugmentHook.sol";
7
+ import {IWeb3Call} from "../../interfaces/v0.8.x/IWeb3Call.sol";
8
+
9
+ import {ERC165} from "@openzeppelin-5.0/contracts/utils/introspection/ERC165.sol";
10
+ import {IERC165} from "@openzeppelin-5.0/contracts/interfaces/IERC165.sol";
11
+
12
+ /**
13
+ * @title Abstract Web3Call contract
14
+ * @author Art Blocks Inc.
15
+ * @notice This abstract can be inherited by any contract that wants to implement the Web3Call interface.
16
+ * It indicates support for the IWeb3Call interface via ERC165 interface detection, and ensures that all
17
+ * child contracts implement the required IWeb3Call functions.
18
+ */
19
+ abstract contract AbstractPMPAugmentHook is IPMPAugmentHook, ERC165 {
20
+ /**
21
+ * @notice Augment the token parameters for a given token.
22
+ * @dev This hook is called when a token's PMPs are read.
23
+ * @dev This must return all desired tokenParams, not just additional data.
24
+ * @param coreContract The address of the core contract to call.
25
+ * @param tokenId The tokenId of the token to get data for.
26
+ * @param tokenParams The token parameters for the queried token.
27
+ * @return augmentedTokenParams The augmented token parameters.
28
+ */
29
+ function onTokenPMPReadAugmentation(
30
+ address coreContract,
31
+ uint256 tokenId,
32
+ IWeb3Call.TokenParam[] calldata tokenParams
33
+ )
34
+ external
35
+ view
36
+ virtual
37
+ returns (IWeb3Call.TokenParam[] memory augmentedTokenParams);
38
+
39
+ function supportsInterface(
40
+ bytes4 interfaceId
41
+ ) public view override(ERC165, IERC165) returns (bool) {
42
+ return
43
+ interfaceId == type(IPMPAugmentHook).interfaceId ||
44
+ super.supportsInterface(interfaceId);
45
+ }
46
+ }
@@ -0,0 +1,57 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import {AbstractPMPAugmentHook} from "./AbstractPMPAugmentHook.sol";
7
+
8
+ import {IWeb3Call} from "../../interfaces/v0.8.x/IWeb3Call.sol";
9
+ import {Strings} from "@openzeppelin-5.0/contracts/utils/Strings.sol";
10
+
11
+ /**
12
+ * @title InjectBaseGasFee
13
+ * @author Art Blocks Inc.
14
+ * @notice This hook injects the base gas fee into a tokens PMPs.
15
+ */
16
+ contract InjectBaseGasFee is AbstractPMPAugmentHook {
17
+ using Strings for uint256;
18
+
19
+ /**
20
+ * @notice Augment the token parameters for a given token.
21
+ * Appends the base gas fee into a tokens PMPs.
22
+ * @dev This hook is called when a token's PMPs are read.
23
+ * @dev This must return all desired tokenParams, not just additional data.
24
+ * @param tokenParams The token parameters for the queried token.
25
+ * @return augmentedTokenParams The augmented token parameters.
26
+ */
27
+ function onTokenPMPReadAugmentation(
28
+ address /* coreContract */,
29
+ uint256 /* tokenId */,
30
+ IWeb3Call.TokenParam[] calldata tokenParams
31
+ )
32
+ external
33
+ view
34
+ override
35
+ returns (IWeb3Call.TokenParam[] memory augmentedTokenParams)
36
+ {
37
+ // create a new tokenParam array with one extra element
38
+ uint256 originalLength = tokenParams.length;
39
+ uint256 newLength = originalLength + 1;
40
+ augmentedTokenParams = new IWeb3Call.TokenParam[](newLength);
41
+
42
+ // copy the original tokenParams into the new array
43
+ for (uint256 i = 0; i < originalLength; i++) {
44
+ augmentedTokenParams[i] = tokenParams[i];
45
+ }
46
+
47
+ // get + inject the base gas fee into the new array
48
+ uint256 blockBaseFee = block.basefee;
49
+ augmentedTokenParams[originalLength] = IWeb3Call.TokenParam({
50
+ key: "baseGasFee",
51
+ value: blockBaseFee.toString()
52
+ });
53
+
54
+ // return the augmented tokenParams
55
+ return augmentedTokenParams;
56
+ }
57
+ }
@@ -0,0 +1,103 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import {AbstractPMPAugmentHook} from "./AbstractPMPAugmentHook.sol";
7
+
8
+ import {IWeb3Call} from "../../interfaces/v0.8.x/IWeb3Call.sol";
9
+ import {Strings} from "@openzeppelin-5.0/contracts/utils/Strings.sol";
10
+
11
+ // @dev This is a simplified interface for the Uniswap V2 Pair contract.
12
+ interface IUniswapV2Pair {
13
+ function getReserves()
14
+ external
15
+ view
16
+ returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
17
+
18
+ function token0() external view returns (address);
19
+
20
+ function token1() external view returns (address);
21
+ }
22
+
23
+ /**
24
+ * @title InjectChromieSquiggleFloorPrice
25
+ * @author Art Blocks Inc.
26
+ * @notice This hook appends the floor price of Chromie Squiggle, in wei, to a tokens PMPs.
27
+ */
28
+ contract InjectChromieSquiggleFloorPrice is AbstractPMPAugmentHook {
29
+ using Strings for uint256;
30
+
31
+ address public immutable nftxVaultPoolSquiggleWeth;
32
+
33
+ /**
34
+ * @notice Constructor.
35
+ * @param _nftxVaultPoolSquiggleWeth The address of the NFTX vault for Chromie Squiggle.
36
+ * For mainnet, this is 0x698AbbBC986C59D02941E18BC96fe2396493339B
37
+ */
38
+ constructor(address _nftxVaultPoolSquiggleWeth) {
39
+ nftxVaultPoolSquiggleWeth = _nftxVaultPoolSquiggleWeth;
40
+ }
41
+
42
+ /**
43
+ * @notice Augment the token parameters for a given token.
44
+ * Appends the spot price of Chromie Squiggle in WETH, based on the NFTX vault pool.
45
+ * @dev This hook is called when a token's PMPs are read.
46
+ * @dev This must return all desired tokenParams, not just additional data.
47
+ * @param tokenParams The token parameters for the queried token.
48
+ * @return augmentedTokenParams The augmented token parameters.
49
+ */
50
+ function onTokenPMPReadAugmentation(
51
+ address /* coreContract */,
52
+ uint256 /* tokenId */,
53
+ IWeb3Call.TokenParam[] calldata tokenParams
54
+ )
55
+ external
56
+ view
57
+ override
58
+ returns (IWeb3Call.TokenParam[] memory augmentedTokenParams)
59
+ {
60
+ // create a new tokenParam array with one extra element
61
+ uint256 originalLength = tokenParams.length;
62
+ uint256 newLength = originalLength + 1;
63
+ augmentedTokenParams = new IWeb3Call.TokenParam[](newLength);
64
+
65
+ // copy the original tokenParams into the new array
66
+ for (uint256 i = 0; i < originalLength; i++) {
67
+ augmentedTokenParams[i] = tokenParams[i];
68
+ }
69
+
70
+ // get + inject the floor price of Chromie Squiggle
71
+ uint256 floorPriceChromieSquiggle = _getSquiggleFloorPriceInWETH();
72
+
73
+ augmentedTokenParams[originalLength] = IWeb3Call.TokenParam({
74
+ key: "floorPriceChromieSquiggle",
75
+ value: floorPriceChromieSquiggle.toString()
76
+ });
77
+
78
+ // return the augmented tokenParams
79
+ return augmentedTokenParams;
80
+ }
81
+
82
+ function _getSquiggleFloorPriceInWETH()
83
+ internal
84
+ view
85
+ returns (uint256 priceInWei)
86
+ {
87
+ IUniswapV2Pair pair = IUniswapV2Pair(nftxVaultPoolSquiggleWeth);
88
+
89
+ (uint112 reserve0, uint112 reserve1, ) = pair.getReserves();
90
+ address token0 = pair.token0(); // expected to be SQGL
91
+
92
+ // Price of 1 SquiggleVault token in WETH = reserve1 / reserve0
93
+ // We'll scale result to return value in wei (1e18)
94
+
95
+ if (token0 == 0x8d137e3337eb1B58A222Fef2B2Cc7C423903d9cf) {
96
+ // token0 is SQGL, token1 is WETH
97
+ priceInWei = (uint256(reserve1) * 1e18) / reserve0;
98
+ } else {
99
+ // token1 is SQGL, token0 is WETH
100
+ priceInWei = (uint256(reserve0) * 1e18) / reserve1;
101
+ }
102
+ }
103
+ }
@@ -0,0 +1,66 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import {AbstractPMPAugmentHook} from "./AbstractPMPAugmentHook.sol";
7
+
8
+ import {IWeb3Call} from "../../interfaces/v0.8.x/IWeb3Call.sol";
9
+ import {IERC721} from "@openzeppelin-5.0/contracts/interfaces/IERC721.sol";
10
+ import {IERC20} from "@openzeppelin-5.0/contracts/interfaces/IERC20.sol";
11
+ import {Strings} from "@openzeppelin-5.0/contracts/utils/Strings.sol";
12
+
13
+ /**
14
+ * @title InjectIsNounsDaoMember
15
+ * @author Art Blocks Inc.
16
+ * @notice This hook injects if the token's owner is a member of the Nouns DAO.
17
+ */
18
+ contract InjectIsNounsDaoMember is AbstractPMPAugmentHook {
19
+ address public constant nounsTokenAddress =
20
+ 0x9C8fF314C9Bc7F6e59A9d9225Fb22946427eDC03;
21
+
22
+ /**
23
+ * @notice Augment the token parameters for a given token.
24
+ * Appends if the token's owner is a member of the Nouns DAO into a tokens PMPs,
25
+ * i.e. if the token's owner has a Noun in their wallet.
26
+ * @dev This hook is called when a token's PMPs are read.
27
+ * @dev This must return all desired tokenParams, not just additional data.
28
+ * @param coreContract The address of the core contract to call.
29
+ * @param tokenId The tokenId of the token to get data for.
30
+ * @param tokenParams The token parameters for the queried token.
31
+ * @return augmentedTokenParams The augmented token parameters.
32
+ */
33
+ function onTokenPMPReadAugmentation(
34
+ address coreContract,
35
+ uint256 tokenId,
36
+ IWeb3Call.TokenParam[] calldata tokenParams
37
+ )
38
+ external
39
+ view
40
+ override
41
+ returns (IWeb3Call.TokenParam[] memory augmentedTokenParams)
42
+ {
43
+ // create a new tokenParam array with one extra element
44
+ uint256 originalLength = tokenParams.length;
45
+ uint256 newLength = originalLength + 1;
46
+ augmentedTokenParams = new IWeb3Call.TokenParam[](newLength);
47
+
48
+ // copy the original tokenParams into the new array
49
+ for (uint256 i = 0; i < originalLength; i++) {
50
+ augmentedTokenParams[i] = tokenParams[i];
51
+ }
52
+
53
+ // get + inject the token owner's nouns dao membership status
54
+ address tokenOwner = IERC721(coreContract).ownerOf(tokenId);
55
+ bool isNounsDaoMember = IERC20(nounsTokenAddress).balanceOf(
56
+ tokenOwner
57
+ ) > 0;
58
+ augmentedTokenParams[originalLength] = IWeb3Call.TokenParam({
59
+ key: "isNounsDaoMember",
60
+ value: isNounsDaoMember ? "true" : "false"
61
+ });
62
+
63
+ // return the augmented tokenParams
64
+ return augmentedTokenParams;
65
+ }
66
+ }
@@ -0,0 +1,73 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import {AbstractPMPAugmentHook} from "./AbstractPMPAugmentHook.sol";
7
+
8
+ import {ABHelpers} from "../../libs/v0.8.x/ABHelpers.sol";
9
+
10
+ import {IWeb3Call} from "../../interfaces/v0.8.x/IWeb3Call.sol";
11
+ import {IERC721} from "@openzeppelin-5.0/contracts/interfaces/IERC721.sol";
12
+ import {IGenArt721CoreContractV3_Base} from "../../interfaces/v0.8.x/IGenArt721CoreContractV3_Base.sol";
13
+ import {Strings} from "@openzeppelin-5.0/contracts/utils/Strings.sol";
14
+
15
+ /**
16
+ * @title InjectIsProjectFullyMinted
17
+ * @author Art Blocks Inc.
18
+ * @notice This hook injects if a project is fully minted.
19
+ */
20
+ contract InjectIsProjectFullyMinted is AbstractPMPAugmentHook {
21
+ using Strings for address;
22
+
23
+ /**
24
+ * @notice Augment the token parameters for a given token.
25
+ * Appends if a project is fully minted into a tokens PMPs.
26
+ * @dev This hook is called when a token's PMPs are read.
27
+ * @dev This must return all desired tokenParams, not just additional data.
28
+ * @param coreContract The address of the core contract to call.
29
+ * @param tokenId The tokenId of the token to get data for.
30
+ * @param tokenParams The token parameters for the queried token.
31
+ * @return augmentedTokenParams The augmented token parameters.
32
+ */
33
+ function onTokenPMPReadAugmentation(
34
+ address coreContract,
35
+ uint256 tokenId,
36
+ IWeb3Call.TokenParam[] calldata tokenParams
37
+ )
38
+ external
39
+ view
40
+ override
41
+ returns (IWeb3Call.TokenParam[] memory augmentedTokenParams)
42
+ {
43
+ // create a new tokenParam array with one extra element
44
+ uint256 originalLength = tokenParams.length;
45
+ uint256 newLength = originalLength + 1;
46
+ augmentedTokenParams = new IWeb3Call.TokenParam[](newLength);
47
+
48
+ // copy the original tokenParams into the new array
49
+ for (uint256 i = 0; i < originalLength; i++) {
50
+ augmentedTokenParams[i] = tokenParams[i];
51
+ }
52
+
53
+ // get + inject the token owner into the new array
54
+ uint256 projectId = ABHelpers.tokenIdToProjectId(tokenId);
55
+ (
56
+ uint256 invocations,
57
+ uint256 maxInvocations,
58
+ ,
59
+ ,
60
+ ,
61
+
62
+ ) = IGenArt721CoreContractV3_Base(coreContract).projectStateData(
63
+ projectId
64
+ );
65
+ augmentedTokenParams[originalLength] = IWeb3Call.TokenParam({
66
+ key: "isProjectFullyMinted",
67
+ value: invocations == maxInvocations ? "true" : "false"
68
+ });
69
+
70
+ // return the augmented tokenParams
71
+ return augmentedTokenParams;
72
+ }
73
+ }
@@ -0,0 +1,88 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import {AbstractPMPAugmentHook} from "./AbstractPMPAugmentHook.sol";
7
+ import {ABHelpers} from "../../libs/v0.8.x/ABHelpers.sol";
8
+
9
+ import {IWeb3Call} from "../../interfaces/v0.8.x/IWeb3Call.sol";
10
+ import {IGenArt721CoreContractV3_Base} from "../../interfaces/v0.8.x/IGenArt721CoreContractV3_Base.sol";
11
+
12
+ import {Strings} from "@openzeppelin-5.0/contracts/utils/Strings.sol";
13
+
14
+ /**
15
+ * @title InjectPolyptychTokenHash
16
+ * @author Art Blocks Inc.
17
+ * @notice This hook injects the hash of a token on a different project into a tokens PMPs.
18
+ */
19
+ contract InjectPolyptychTokenHash is AbstractPMPAugmentHook {
20
+ using Strings for uint256;
21
+
22
+ /**
23
+ * @notice The projectId of the project to inject the hash from.
24
+ */
25
+ uint256 public immutable sourceProjectId;
26
+ /**
27
+ * @notice the core contract address of the project to inject the hash from.
28
+ */
29
+ address public immutable sourceCoreContract;
30
+
31
+ /**
32
+ * @notice Constructor.
33
+ * @param _sourceCoreContract The address of the core contract to inject the hash from.
34
+ * @param _sourceProjectId The projectId of the project to inject the hash from.
35
+ */
36
+ constructor(address _sourceCoreContract, uint256 _sourceProjectId) {
37
+ sourceCoreContract = _sourceCoreContract;
38
+ sourceProjectId = _sourceProjectId;
39
+ }
40
+
41
+ /**
42
+ * @notice Augment the token parameters for a given token.
43
+ * Appends the hash of a token on a different project into a tokens PMPs.
44
+ * @dev This hook is called when a token's PMPs are read.
45
+ * @dev This must return all desired tokenParams, not just additional data.
46
+ * @param tokenId The tokenId of the token to get data for.
47
+ * @param tokenParams The token parameters for the queried token.
48
+ * @return augmentedTokenParams The augmented token parameters.
49
+ */
50
+ function onTokenPMPReadAugmentation(
51
+ address /* coreContract */,
52
+ uint256 tokenId,
53
+ IWeb3Call.TokenParam[] calldata tokenParams
54
+ )
55
+ external
56
+ view
57
+ override
58
+ returns (IWeb3Call.TokenParam[] memory augmentedTokenParams)
59
+ {
60
+ // create a new tokenParam array with one extra element
61
+ uint256 originalLength = tokenParams.length;
62
+ uint256 newLength = originalLength + 1;
63
+ augmentedTokenParams = new IWeb3Call.TokenParam[](newLength);
64
+
65
+ // copy the original tokenParams into the new array
66
+ for (uint256 i = 0; i < originalLength; i++) {
67
+ augmentedTokenParams[i] = tokenParams[i];
68
+ }
69
+
70
+ // get + inject the source token hash into the new array
71
+ uint256 tokenNumber = ABHelpers.tokenIdToTokenNumber(tokenId);
72
+ uint256 sourceTokenId = ABHelpers.tokenIdFromProjectIdAndTokenNumber({
73
+ projectId: sourceProjectId,
74
+ tokenNumber: tokenNumber
75
+ });
76
+ bytes32 sourceTokenHash = IGenArt721CoreContractV3_Base(
77
+ sourceCoreContract
78
+ ).tokenIdToHash(sourceTokenId);
79
+
80
+ augmentedTokenParams[originalLength] = IWeb3Call.TokenParam({
81
+ key: "sourceTokenHash",
82
+ value: uint256(sourceTokenHash).toHexString()
83
+ });
84
+
85
+ // return the augmented tokenParams
86
+ return augmentedTokenParams;
87
+ }
88
+ }
@@ -0,0 +1,62 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import {AbstractPMPAugmentHook} from "./AbstractPMPAugmentHook.sol";
7
+
8
+ import {IWeb3Call} from "../../interfaces/v0.8.x/IWeb3Call.sol";
9
+ import {IGenArt721CoreContractExposesHashSeed} from "../../interfaces/v0.8.x/IGenArt721CoreContractExposesHashSeed.sol";
10
+ import {Strings} from "@openzeppelin-5.0/contracts/utils/Strings.sol";
11
+
12
+ /**
13
+ * @title InjectTokenHashSeed
14
+ * @author Art Blocks Inc.
15
+ * @notice This hook injects the token hash seed into a tokens PMPs.
16
+ */
17
+ contract InjectTokenHashSeed is AbstractPMPAugmentHook {
18
+ using Strings for uint256;
19
+
20
+ /**
21
+ * @notice Augment the token parameters for a given token.
22
+ * Appends a token's hash seed into a tokens PMPs.
23
+ * @dev This hook is called when a token's PMPs are read.
24
+ * @dev This must return all desired tokenParams, not just additional data.
25
+ * @param coreContract The address of the core contract to call.
26
+ * @param tokenId The tokenId of the token to get data for.
27
+ * @param tokenParams The token parameters for the queried token.
28
+ * @return augmentedTokenParams The augmented token parameters.
29
+ */
30
+ function onTokenPMPReadAugmentation(
31
+ address coreContract,
32
+ uint256 tokenId,
33
+ IWeb3Call.TokenParam[] calldata tokenParams
34
+ )
35
+ external
36
+ view
37
+ override
38
+ returns (IWeb3Call.TokenParam[] memory augmentedTokenParams)
39
+ {
40
+ // create a new tokenParam array with one extra element
41
+ uint256 originalLength = tokenParams.length;
42
+ uint256 newLength = originalLength + 1;
43
+ augmentedTokenParams = new IWeb3Call.TokenParam[](newLength);
44
+
45
+ // copy the original tokenParams into the new array
46
+ for (uint256 i = 0; i < originalLength; i++) {
47
+ augmentedTokenParams[i] = tokenParams[i];
48
+ }
49
+
50
+ // get + inject the token hash seed into the new array
51
+ bytes12 tokenHashSeed = IGenArt721CoreContractExposesHashSeed(
52
+ coreContract
53
+ ).tokenIdToHashSeed(tokenId);
54
+ augmentedTokenParams[originalLength] = IWeb3Call.TokenParam({
55
+ key: "tokenHashSeed",
56
+ value: uint256(bytes32(tokenHashSeed)).toHexString()
57
+ });
58
+
59
+ // return the augmented tokenParams
60
+ return augmentedTokenParams;
61
+ }
62
+ }
@@ -0,0 +1,60 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import {AbstractPMPAugmentHook} from "./AbstractPMPAugmentHook.sol";
7
+
8
+ import {IWeb3Call} from "../../interfaces/v0.8.x/IWeb3Call.sol";
9
+ import {IERC721} from "@openzeppelin-5.0/contracts/interfaces/IERC721.sol";
10
+ import {Strings} from "@openzeppelin-5.0/contracts/utils/Strings.sol";
11
+
12
+ /**
13
+ * @title InjectTokenOwner
14
+ * @author Art Blocks Inc.
15
+ * @notice This hook injects the token owner's address into a tokens PMPs.
16
+ */
17
+ contract InjectTokenOwner is AbstractPMPAugmentHook {
18
+ using Strings for address;
19
+
20
+ /**
21
+ * @notice Augment the token parameters for a given token.
22
+ * Appends the token owner's address into a tokens PMPs.
23
+ * @dev This hook is called when a token's PMPs are read.
24
+ * @dev This must return all desired tokenParams, not just additional data.
25
+ * @param coreContract The address of the core contract to call.
26
+ * @param tokenId The tokenId of the token to get data for.
27
+ * @param tokenParams The token parameters for the queried token.
28
+ * @return augmentedTokenParams The augmented token parameters.
29
+ */
30
+ function onTokenPMPReadAugmentation(
31
+ address coreContract,
32
+ uint256 tokenId,
33
+ IWeb3Call.TokenParam[] calldata tokenParams
34
+ )
35
+ external
36
+ view
37
+ override
38
+ returns (IWeb3Call.TokenParam[] memory augmentedTokenParams)
39
+ {
40
+ // create a new tokenParam array with one extra element
41
+ uint256 originalLength = tokenParams.length;
42
+ uint256 newLength = originalLength + 1;
43
+ augmentedTokenParams = new IWeb3Call.TokenParam[](newLength);
44
+
45
+ // copy the original tokenParams into the new array
46
+ for (uint256 i = 0; i < originalLength; i++) {
47
+ augmentedTokenParams[i] = tokenParams[i];
48
+ }
49
+
50
+ // get + inject the token owner into the new array
51
+ address tokenOwner = IERC721(coreContract).ownerOf(tokenId);
52
+ augmentedTokenParams[originalLength] = IWeb3Call.TokenParam({
53
+ key: "tokenOwner",
54
+ value: tokenOwner.toHexString()
55
+ });
56
+
57
+ // return the augmented tokenParams
58
+ return augmentedTokenParams;
59
+ }
60
+ }
@@ -0,0 +1,61 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ import {AbstractPMPAugmentHook} from "./AbstractPMPAugmentHook.sol";
7
+
8
+ import {IWeb3Call} from "../../interfaces/v0.8.x/IWeb3Call.sol";
9
+ import {IERC721} from "@openzeppelin-5.0/contracts/interfaces/IERC721.sol";
10
+ import {Strings} from "@openzeppelin-5.0/contracts/utils/Strings.sol";
11
+
12
+ /**
13
+ * @title InjectTokenOwnerEthBalance
14
+ * @author Art Blocks Inc.
15
+ * @notice This hook appends the token owner's ETH balance, in wei, to a tokens PMPs.
16
+ */
17
+ contract InjectTokenOwnerEthBalance is AbstractPMPAugmentHook {
18
+ using Strings for uint256;
19
+
20
+ /**
21
+ * @notice Augment the token parameters for a given token.
22
+ * Appends the token owner's ETH balance into a tokens PMPs.
23
+ * @dev This hook is called when a token's PMPs are read.
24
+ * @dev This must return all desired tokenParams, not just additional data.
25
+ * @param coreContract The address of the core contract to call.
26
+ * @param tokenId The tokenId of the token to get data for.
27
+ * @param tokenParams The token parameters for the queried token.
28
+ * @return augmentedTokenParams The augmented token parameters.
29
+ */
30
+ function onTokenPMPReadAugmentation(
31
+ address coreContract,
32
+ uint256 tokenId,
33
+ IWeb3Call.TokenParam[] calldata tokenParams
34
+ )
35
+ external
36
+ view
37
+ override
38
+ returns (IWeb3Call.TokenParam[] memory augmentedTokenParams)
39
+ {
40
+ // create a new tokenParam array with one extra element
41
+ uint256 originalLength = tokenParams.length;
42
+ uint256 newLength = originalLength + 1;
43
+ augmentedTokenParams = new IWeb3Call.TokenParam[](newLength);
44
+
45
+ // copy the original tokenParams into the new array
46
+ for (uint256 i = 0; i < originalLength; i++) {
47
+ augmentedTokenParams[i] = tokenParams[i];
48
+ }
49
+
50
+ // get + inject the token owner into the new array
51
+ address tokenOwner = IERC721(coreContract).ownerOf(tokenId);
52
+ uint256 tokenOwnerEthBalanceInWei = address(tokenOwner).balance;
53
+ augmentedTokenParams[originalLength] = IWeb3Call.TokenParam({
54
+ key: "tokenOwnerEthBalance",
55
+ value: tokenOwnerEthBalanceInWei.toString()
56
+ });
57
+
58
+ // return the augmented tokenParams
59
+ return augmentedTokenParams;
60
+ }
61
+ }