@zoralabs/comments-contracts 0.0.1 → 0.0.2

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 (110) hide show
  1. package/.turbo/turbo-build.log +49 -31
  2. package/README.md +10 -39
  3. package/abis/AddDelegateCommenterRole.json +9 -0
  4. package/abis/CallerAndCommenter.json +62 -0
  5. package/abis/CallerAndCommenterImpl.json +1218 -0
  6. package/abis/CallerAndCommenterMintAndCommentTest.json +771 -0
  7. package/abis/CallerAndCommenterSwapAndCommentTest.json +844 -0
  8. package/abis/CallerAndCommenterTestBase.json +577 -0
  9. package/abis/CommentsImpl.json +189 -59
  10. package/abis/CommentsImplConstants.json +106 -0
  11. package/abis/CommentsPermitTest.json +26 -6
  12. package/abis/CommentsTest.json +58 -10
  13. package/abis/Comments_mintAndCommentTest.json +11 -4
  14. package/abis/Comments_smartWallet.json +711 -0
  15. package/abis/DeployCallerAndCommenterImpl.json +9 -0
  16. package/abis/DeployImpl.json +0 -13
  17. package/abis/DeployNonDeterministic.json +0 -13
  18. package/abis/DeployScript.json +0 -13
  19. package/abis/EIP712Upgradeable.json +74 -0
  20. package/abis/EIP712UpgradeableWithChainId.json +49 -0
  21. package/abis/ERC20.json +310 -0
  22. package/abis/GenerateDeterministicParams.json +0 -13
  23. package/abis/ICallerAndCommenter.json +797 -0
  24. package/abis/IComments.json +629 -9
  25. package/abis/IERC20.json +39 -42
  26. package/abis/IERC20Metadata.json +224 -0
  27. package/abis/{CommentsDeployerBase.json → IMultiOwnable.json} +8 -2
  28. package/abis/IProtocolRewards.json +19 -0
  29. package/abis/ISecondarySwap.json +45 -0
  30. package/abis/IZoraCreator1155.json +51 -0
  31. package/abis/IZoraTimedSaleStrategy.json +91 -0
  32. package/abis/Mock1155.json +75 -1
  33. package/abis/Mock1155NoCreatorRewardRecipient.json +605 -0
  34. package/abis/Mock1155NoOwner.json +566 -0
  35. package/abis/{MockMinter.json → MockDelegateCommenter.json} +12 -2
  36. package/abis/MockERC20z.json +315 -0
  37. package/abis/MockMultiOwnable.json +212 -0
  38. package/abis/MockSecondarySwap.json +95 -0
  39. package/abis/MockZoraTimedSale.json +139 -0
  40. package/abis/Ownable2StepUpgradeable.json +138 -0
  41. package/abis/UnorderedNoncesUpgradeable.json +4 -4
  42. package/addresses/1.json +9 -0
  43. package/addresses/10.json +9 -0
  44. package/addresses/11155111.json +9 -0
  45. package/addresses/11155420.json +9 -0
  46. package/addresses/42161.json +9 -0
  47. package/addresses/7777777.json +9 -0
  48. package/addresses/81457.json +9 -0
  49. package/addresses/8453.json +9 -0
  50. package/addresses/84532.json +9 -0
  51. package/addresses/999999999.json +7 -2
  52. package/deterministicConfig/callerAndCommenter.json +8 -0
  53. package/deterministicConfig/comments.json +2 -2
  54. package/dist/index.cjs +724 -35
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.js +723 -35
  57. package/dist/index.js.map +1 -1
  58. package/dist/types.d.ts +1 -1
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/wagmiGenerated.d.ts +1102 -57
  61. package/dist/wagmiGenerated.d.ts.map +1 -1
  62. package/package/types.ts +4 -1
  63. package/package/wagmiGenerated.ts +728 -32
  64. package/package.json +12 -11
  65. package/script/AddDelegateCommenterRole.s.sol +24 -0
  66. package/script/CommentsDeployerBase.sol +102 -19
  67. package/script/Deploy.s.sol +2 -44
  68. package/script/DeployCallerAndCommenterImpl.s.sol +29 -0
  69. package/script/DeployImpl.s.sol +1 -0
  70. package/script/DeployNonDeterministic.s.sol +22 -13
  71. package/script/GenerateDeterministicParams.s.sol +32 -4
  72. package/scripts/generateCommentsTestData.ts +170 -79
  73. package/src/CommentsImpl.sol +267 -134
  74. package/src/CommentsImplConstants.sol +44 -0
  75. package/src/interfaces/ICallerAndCommenter.sol +215 -0
  76. package/src/interfaces/IComments.sol +189 -42
  77. package/src/interfaces/IMultiOwnable.sol +10 -0
  78. package/src/interfaces/ISecondarySwap.sol +40 -0
  79. package/src/interfaces/IZoraCreator1155.sol +6 -1
  80. package/src/interfaces/IZoraCreator1155TypesV1.sol +46 -0
  81. package/src/interfaces/IZoraTimedSaleStrategy.sol +25 -0
  82. package/src/proxy/CallerAndCommenter.sol +43 -0
  83. package/src/utils/CallerAndCommenterImpl.sol +376 -0
  84. package/src/utils/EIP712UpgradeableWithChainId.sol +12 -23
  85. package/src/version/ContractVersionBase.sol +1 -1
  86. package/test/CallerAndCommenterTestBase.sol +77 -0
  87. package/test/CallerAndCommenter_mintAndComment.t copy.sol +214 -0
  88. package/test/CallerAndCommenter_swapAndComment.t.sol +523 -0
  89. package/test/Comments.t.sol +166 -29
  90. package/test/CommentsTestBase.sol +12 -20
  91. package/test/Comments_delegateComment.t.sol +129 -0
  92. package/test/Comments_permit.t.sol +131 -44
  93. package/test/Comments_smartWallet.t.sol +152 -0
  94. package/test/mocks/Mock1155.sol +12 -1
  95. package/test/mocks/Mock1155NoCreatorRewardRecipient.sol +65 -0
  96. package/test/mocks/Mock1155NoOwner.sol +53 -0
  97. package/test/mocks/MockDelegateCommenter.sol +36 -0
  98. package/test/mocks/MockIZoraCreator1155.sol +16 -0
  99. package/test/mocks/MockSecondarySwap.sol +30 -0
  100. package/test/mocks/MockZoraTimedSale.sol +38 -0
  101. package/wagmi.config.ts +3 -1
  102. package/abis/ProxyDeployerScript.json +0 -15
  103. package/scripts/backfillComments.ts +0 -176
  104. package/scripts/queries.ts +0 -73
  105. package/scripts/queryAndSaveComments.ts +0 -48
  106. package/scripts/queryQuantityOfComments.ts +0 -53
  107. package/scripts/writeComments.ts +0 -198
  108. package/src/deployments/CommentsDeployment.sol +0 -14
  109. package/test/Comments_mintAndComment.t.sol +0 -101
  110. package/test/mocks/MockMinter.sol +0 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoralabs/comments-contracts",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "author": "oveddan",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -16,33 +16,34 @@
16
16
  }
17
17
  },
18
18
  "devDependencies": {
19
+ "@openzeppelin/contracts": "5.0.2",
20
+ "@openzeppelin/contracts-upgradeable": "5.0.2",
19
21
  "@turnkey/api-key-stamper": "^0.3.1",
20
22
  "@turnkey/http": "^2.5.1",
21
23
  "@turnkey/viem": "^0.4.4",
22
24
  "@types/node": "^20.1.2",
23
25
  "@wagmi/cli": "^1.0.1",
24
26
  "@zoralabs/chains": "^1.3.1",
25
- "@openzeppelin/contracts": "5.0.2",
26
- "@openzeppelin/contracts-upgradeable": "5.0.2",
27
27
  "ds-test": "https://github.com/dapphub/ds-test#cd98eff28324bfac652e63a239a60632a761790b",
28
28
  "forge-std": "https://github.com/foundry-rs/forge-std#v1.9.1",
29
- "solady": "0.0.132",
30
29
  "glob": "^10.2.2",
31
30
  "pathe": "^1.1.2",
32
31
  "prettier": "^3.0.3",
33
32
  "prettier-plugin-solidity": "^1.3.1",
33
+ "solady": "0.0.132",
34
34
  "tsup": "^7.2.0",
35
35
  "tsx": "^3.13.0",
36
36
  "typescript": "^5.2.2",
37
- "viem": "^1.10.0",
38
- "@zoralabs/tsconfig": "^0.0.1",
39
- "@zoralabs/protocol-rewards": "^1.2.4",
37
+ "viem": "^2.21.18",
38
+ "@zoralabs/sparks-contracts": "^0.2.4",
39
+ "@zoralabs/protocol-rewards": "^1.2.5",
40
40
  "@zoralabs/shared-contracts": "^0.0.1",
41
- "@zoralabs/sparks-contracts": "^0.2.2",
42
- "@zoralabs/zora-1155-contracts": "^2.12.4"
41
+ "@zoralabs/tsconfig": "^0.0.1",
42
+ "@zoralabs/zora-1155-contracts": "^2.13.2"
43
43
  },
44
44
  "dependencies": {
45
- "abitype": "^1.0.2"
45
+ "abitype": "^1.0.2",
46
+ "dotenv": "^16.4.5"
46
47
  },
47
48
  "scripts": {
48
49
  "prettier:check": "prettier --check 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol'",
@@ -52,7 +53,7 @@
52
53
  "test-gas": "forge test --gas-report",
53
54
  "storage-inspect:check": "./script/storage-check.sh check ZoraTimedSaleStrategyImpl",
54
55
  "storage-inspect:generate": "./script/storage-check.sh generate ZoraTimedSaleStrategyImpl",
55
- "build:sizes": "forge build --sizes",
56
+ "build:sizes": "forge build src/ --sizes",
56
57
  "copy-abis": "pnpm tsx script/bundle-abis.ts",
57
58
  "coverage": "FOUNDRY_PROFILE=default forge coverage --report lcov",
58
59
  "build": "pnpm run wagmi:generate && pnpm run copy-abis && pnpm run prettier:write && tsup",
@@ -0,0 +1,24 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ import "forge-std/Script.sol";
5
+ import {CommentsDeployerBase} from "./CommentsDeployerBase.sol";
6
+ import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
7
+
8
+ contract AddDelegateCommenterRole is CommentsDeployerBase {
9
+ function run() public view {
10
+ address owner = getProxyAdmin();
11
+ bytes32 BACKFILLER_ROLE = keccak256("DELEGATE_COMMENTER");
12
+
13
+ address callerAndCommenter = readDeterministicContractConfig("callerAndCommenter").deployedAddress;
14
+
15
+ address comments = readDeterministicContractConfig("comments").deployedAddress;
16
+
17
+ bytes memory call = abi.encodeWithSelector(AccessControlUpgradeable.grantRole.selector, BACKFILLER_ROLE, callerAndCommenter);
18
+
19
+ console.log("multisig", owner);
20
+ console.log("target", comments);
21
+ console.log("call:");
22
+ console.logBytes(call);
23
+ }
24
+ }
@@ -3,41 +3,65 @@ pragma solidity ^0.8.23;
3
3
 
4
4
  import "forge-std/Script.sol";
5
5
 
6
- import {ProxyDeployerScript} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
6
+ import {ProxyDeployerScript, DeterministicContractConfig, DeterministicDeployerAndCaller} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
7
7
  import {CommentsImpl} from "../src/CommentsImpl.sol";
8
- import {IProtocolRewards} from "@zoralabs/protocol-rewards/src/interfaces/IProtocolRewards.sol";
8
+ import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
9
+ import {CallerAndCommenterImpl} from "../src/utils/CallerAndCommenterImpl.sol";
10
+ import {CallerAndCommenter} from "../src/proxy/CallerAndCommenter.sol";
9
11
 
10
12
  // Temp script
11
13
  contract CommentsDeployerBase is ProxyDeployerScript {
12
14
  uint256 internal constant SPARK_VALUE = 0.000001 ether;
13
15
  address internal constant PROTOCOL_REWARDS = 0x7777777F279eba3d3Ad8F4E708545291A6fDBA8B;
14
16
  address internal constant ZORA_TIMED_SALE_STRATEGY = 0x777777722D078c97c6ad07d9f36801e653E356Ae;
17
+ address internal constant SECONDARY_SWAP = 0x777777EDF27Ac61671e3D5718b10bf6a8802f9f1;
18
+
15
19
  using stdJson for string;
16
20
 
17
21
  struct CommentsDeployment {
18
22
  address comments;
19
23
  address commentsImpl;
20
24
  string commentsVersion;
25
+ address callerAndCommenter;
26
+ address callerAndCommenterImpl;
27
+ string callerAndCommenterVersion;
28
+ uint256 commentsBlockNumber;
29
+ uint256 commentsImplBlockNumber;
30
+ }
31
+
32
+ function addressesFile() internal view returns (string memory) {
33
+ return string.concat("./addresses/", vm.toString(block.chainid), ".json");
21
34
  }
22
35
 
23
36
  function saveDeployment(CommentsDeployment memory deployment) internal {
24
37
  string memory objectKey = "config";
25
38
 
26
39
  vm.serializeAddress(objectKey, "COMMENTS", deployment.comments);
27
- string memory result = vm.serializeAddress(objectKey, "COMMENTS_IMPL", deployment.commentsImpl);
40
+ vm.serializeUint(objectKey, "COMMENTS_BLOCK_NUMBER", deployment.commentsBlockNumber);
41
+ vm.serializeAddress(objectKey, "COMMENTS_IMPL", deployment.commentsImpl);
42
+ vm.serializeAddress(objectKey, "CALLER_AND_COMMENTER", deployment.callerAndCommenter);
43
+ vm.serializeAddress(objectKey, "CALLER_AND_COMMENTER_IMPL", deployment.callerAndCommenterImpl);
44
+ vm.serializeString(objectKey, "CALLER_AND_COMMENTER_VERSION", deployment.callerAndCommenterVersion);
45
+ string memory result = vm.serializeUint(objectKey, "COMMENTS_IMPL_BLOCK_NUMBER", deployment.commentsImplBlockNumber);
28
46
 
29
- vm.writeJson(result, string.concat("./addresses/", vm.toString(block.chainid), ".json"));
47
+ vm.writeJson(result, addressesFile());
30
48
  }
31
49
 
32
- function readDeployment() internal view returns (CommentsDeployment memory) {
33
- string memory json = vm.readFile(string.concat("./addresses/", vm.toString(block.chainid), ".json"));
50
+ function readDeployment() internal returns (CommentsDeployment memory deployment) {
51
+ string memory file = addressesFile();
52
+ if (!vm.exists(file)) {
53
+ return deployment;
54
+ }
55
+ string memory json = vm.readFile(file);
34
56
 
35
- return
36
- CommentsDeployment({
37
- comments: readAddressOrDefaultToZero(json, "COMMENTS"),
38
- commentsImpl: readAddressOrDefaultToZero(json, "COMMENTS_IMPL"),
39
- commentsVersion: readStringOrDefaultToEmpty(json, "COMMENTS_VERSION")
40
- });
57
+ deployment.comments = readAddressOrDefaultToZero(json, "COMMENTS");
58
+ deployment.commentsImpl = readAddressOrDefaultToZero(json, "COMMENTS_IMPL");
59
+ deployment.commentsVersion = readStringOrDefaultToEmpty(json, "COMMENTS_VERSION");
60
+ deployment.commentsBlockNumber = readUintOrDefaultToZero(json, "COMMENTS_BLOCK_NUMBER");
61
+ deployment.commentsImplBlockNumber = readUintOrDefaultToZero(json, "COMMENTS_IMPL_BLOCK_NUMBER");
62
+ deployment.callerAndCommenter = readAddressOrDefaultToZero(json, "CALLER_AND_COMMENTER");
63
+ deployment.callerAndCommenterImpl = readAddressOrDefaultToZero(json, "CALLER_AND_COMMENTER_IMPL");
64
+ deployment.callerAndCommenterVersion = readStringOrDefaultToEmpty(json, "CALLER_AND_COMMENTER_VERSION");
41
65
  }
42
66
 
43
67
  function commentsImplCreationCode() internal pure returns (bytes memory) {
@@ -45,16 +69,75 @@ contract CommentsDeployerBase is ProxyDeployerScript {
45
69
  }
46
70
 
47
71
  function getBackfillerAccount() internal pure returns (address) {
48
- // todo: figure out backfiller. right now this is made from cast wallet new
49
- return 0x9AfA68161f094DAEA62816b6264b3D777978a164;
72
+ return 0x77baCD258d2E6A5187B7344419A5e2842A49A059;
50
73
  }
51
74
 
52
- function defaultDelegateCommenters() internal pure returns (address[] memory delegateCommenters) {
53
- delegateCommenters = new address[](1);
54
- delegateCommenters[0] = ZORA_TIMED_SALE_STRATEGY;
75
+ function deployCommentsImpl() internal returns (CommentsImpl) {
76
+ return new CommentsImpl(SPARK_VALUE, PROTOCOL_REWARDS, getZoraRecipient());
55
77
  }
56
78
 
57
- function deployCommentsImpl() internal returns (CommentsImpl) {
58
- return new CommentsImpl(SPARK_VALUE, PROTOCOL_REWARDS);
79
+ function deployCommentsDeterministic(CommentsDeployment memory deployment, DeterministicDeployerAndCaller deployer) internal {
80
+ // read previously saved deterministic royalties config
81
+ DeterministicContractConfig memory commentsConfig = readDeterministicContractConfig("comments");
82
+ DeterministicContractConfig memory callerAndCommenterConfig = readDeterministicContractConfig("callerAndCommenter");
83
+
84
+ address backfiller = CommentsDeployerBase.getBackfillerAccount();
85
+ // get deployed implementation address. it it's not deployed, revert
86
+ address implAddress = address(deployCommentsImpl());
87
+
88
+ if (implAddress.code.length == 0) {
89
+ revert("Impl not yet deployed. Make sure to deploy it with DeployImpl.s.sol");
90
+ }
91
+
92
+ address[] memory delegateCommenters = new address[](1);
93
+ delegateCommenters[0] = callerAndCommenterConfig.deployedAddress;
94
+
95
+ // build upgrade to and call for comments, with init call
96
+ bytes memory upgradeToAndCall = abi.encodeWithSelector(
97
+ UUPSUpgradeable.upgradeToAndCall.selector,
98
+ implAddress,
99
+ abi.encodeWithSelector(CommentsImpl.initialize.selector, getProxyAdmin(), backfiller, delegateCommenters)
100
+ );
101
+
102
+ // sign royalties deployment with turnkey account
103
+ bytes memory signature = signDeploymentWithTurnkey(commentsConfig, upgradeToAndCall, deployer);
104
+
105
+ deployment.comments = deployer.permitSafeCreate2AndCall(
106
+ signature,
107
+ commentsConfig.salt,
108
+ commentsConfig.creationCode,
109
+ upgradeToAndCall,
110
+ commentsConfig.deployedAddress
111
+ );
112
+ deployment.commentsBlockNumber = block.number;
113
+ }
114
+
115
+ function deployCallerAndCommenterImpl(address commentsAddress) internal returns (address) {
116
+ return address(new CallerAndCommenterImpl(commentsAddress, ZORA_TIMED_SALE_STRATEGY, SECONDARY_SWAP, SPARK_VALUE));
117
+ }
118
+
119
+ function deployCallerAndCommenterDeterministic(CommentsDeployment memory deployment, DeterministicDeployerAndCaller deployer) internal {
120
+ address commentsAddress = readDeterministicContractConfig("comments").deployedAddress;
121
+ DeterministicContractConfig memory callerAndCommenterConfig = readDeterministicContractConfig("callerAndCommenter");
122
+
123
+ // deploy caller and commenter impl
124
+ deployment.callerAndCommenterImpl = address(deployCallerAndCommenterImpl(commentsAddress));
125
+ deployment.callerAndCommenterVersion = CallerAndCommenterImpl(deployment.callerAndCommenterImpl).contractVersion();
126
+
127
+ bytes memory upgradeToAndCall = abi.encodeWithSelector(
128
+ UUPSUpgradeable.upgradeToAndCall.selector,
129
+ deployment.callerAndCommenterImpl,
130
+ abi.encodeWithSelector(CallerAndCommenterImpl.initialize.selector, getProxyAdmin())
131
+ );
132
+
133
+ bytes memory signature = signDeploymentWithTurnkey(callerAndCommenterConfig, upgradeToAndCall, deployer);
134
+
135
+ deployment.callerAndCommenter = deployer.permitSafeCreate2AndCall(
136
+ signature,
137
+ callerAndCommenterConfig.salt,
138
+ callerAndCommenterConfig.creationCode,
139
+ upgradeToAndCall,
140
+ callerAndCommenterConfig.deployedAddress
141
+ );
59
142
  }
60
143
  }
@@ -1,62 +1,20 @@
1
1
  // SPDX-License-Identifier: UNLICENSED
2
2
  pragma solidity ^0.8.13;
3
3
 
4
- import "forge-std/Script.sol";
5
-
6
- import {ProxyDeployerScript} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
7
- import {ImmutableCreate2FactoryUtils} from "@zoralabs/shared-contracts/utils/ImmutableCreate2FactoryUtils.sol";
8
4
  import {ProxyDeployerScript, DeterministicDeployerAndCaller, DeterministicContractConfig} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
9
- import {CommentsImpl} from "../src/CommentsImpl.sol";
10
- import {CommentsDeployment} from "../src/deployments/CommentsDeployment.sol";
11
- import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
12
5
  import {CommentsDeployerBase} from "./CommentsDeployerBase.sol";
13
6
 
14
- // Temp script
15
7
  contract DeployScript is CommentsDeployerBase {
16
8
  function run() public {
17
9
  CommentsDeployment memory deployment = readDeployment();
18
10
 
19
- address owner = getProxyAdmin();
20
-
21
- // todo: figure out backfiller. right now this is made from cast wallet new
22
- address backfiller = 0x9AfA68161f094DAEA62816b6264b3D777978a164;
23
- address zoraRecipient = getZoraRecipient();
24
-
25
- // get deployed implementation address. it it's not deployed, revert
26
- address implAddress = deployment.commentsImpl;
27
-
28
- if (implAddress.code.length == 0) {
29
- revert("Impl not yet deployed. Make sure to deploy it with DeployImpl.s.sol");
30
- }
31
-
32
11
  vm.startBroadcast();
33
12
 
34
13
  // get deployer contract
35
14
  DeterministicDeployerAndCaller deployer = createOrGetDeployerAndCaller();
36
15
 
37
- // read previously saved deterministic royalties config
38
- DeterministicContractConfig memory commentsConfig = readDeterministicContractConfig("comments");
39
-
40
- address[] memory delegateCommenters = defaultDelegateCommenters();
41
-
42
- // build upgrade to and call for comments, with init call
43
- bytes memory upgradeToAndCall = abi.encodeWithSelector(
44
- UUPSUpgradeable.upgradeToAndCall.selector,
45
- implAddress,
46
- abi.encodeWithSelector(CommentsImpl.initialize.selector, zoraRecipient, owner, backfiller, delegateCommenters)
47
- );
48
-
49
- // sign royalties deployment with turnkey account
50
- bytes memory commentsSignature = signDeploymentWithTurnkey(commentsConfig, upgradeToAndCall, deployer);
51
-
52
- // deterministically deploy royalties contract using the signature
53
- deployment.comments = deployer.permitSafeCreate2AndCall(
54
- commentsSignature,
55
- commentsConfig.salt,
56
- commentsConfig.creationCode,
57
- upgradeToAndCall,
58
- commentsConfig.deployedAddress
59
- );
16
+ deployCommentsDeterministic(deployment, deployer);
17
+ deployCallerAndCommenterDeterministic(deployment, deployer);
60
18
 
61
19
  vm.stopBroadcast();
62
20
 
@@ -0,0 +1,29 @@
1
+ // SPDX-License-Identifier: UNLICENSED
2
+ pragma solidity ^0.8.13;
3
+
4
+ import "forge-std/console2.sol";
5
+
6
+ import {CommentsDeployerBase} from "./CommentsDeployerBase.sol";
7
+ import {CallerAndCommenterImpl} from "../src/utils/CallerAndCommenterImpl.sol";
8
+ import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
9
+
10
+ contract DeployCallerAndCommenterImpl is CommentsDeployerBase {
11
+ function run() public {
12
+ CommentsDeployment memory config = readDeployment();
13
+
14
+ vm.startBroadcast();
15
+
16
+ config.callerAndCommenterImpl = deployCallerAndCommenterImpl(config.comments);
17
+ config.callerAndCommenterVersion = CallerAndCommenterImpl(config.callerAndCommenterImpl).contractVersion();
18
+
19
+ vm.stopBroadcast();
20
+
21
+ console2.log("CallerAndCommenterImpl deployed, to upgrade:");
22
+ console2.log("target:", config.callerAndCommenter);
23
+ console2.log("calldata:");
24
+ console2.logBytes(abi.encodeWithSelector(UUPSUpgradeable.upgradeToAndCall.selector, config.callerAndCommenterImpl, ""));
25
+ console2.log("multisig:", getProxyAdmin());
26
+
27
+ saveDeployment(config);
28
+ }
29
+ }
@@ -12,6 +12,7 @@ contract DeployImpl is CommentsDeployerBase {
12
12
  vm.startBroadcast();
13
13
 
14
14
  config.commentsImpl = address(deployCommentsImpl());
15
+ config.commentsImplBlockNumber = block.number;
15
16
 
16
17
  vm.stopBroadcast();
17
18
 
@@ -2,14 +2,11 @@
2
2
  pragma solidity ^0.8.13;
3
3
 
4
4
  import "forge-std/Script.sol";
5
-
6
- import {ProxyDeployerScript} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
7
- import {ImmutableCreate2FactoryUtils} from "@zoralabs/shared-contracts/utils/ImmutableCreate2FactoryUtils.sol";
8
- import {ProxyDeployerScript, DeterministicDeployerAndCaller, DeterministicContractConfig} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
9
5
  import {Comments} from "../src/proxy/Comments.sol";
10
6
  import {CommentsImpl} from "../src/CommentsImpl.sol";
11
- import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
12
7
  import {CommentsDeployerBase} from "./CommentsDeployerBase.sol";
8
+ import {CallerAndCommenterImpl} from "../src/utils/CallerAndCommenterImpl.sol";
9
+ import {CallerAndCommenter} from "../src/proxy/CallerAndCommenter.sol";
13
10
 
14
11
  contract DeployNonDeterministic is CommentsDeployerBase {
15
12
  function run() public {
@@ -17,27 +14,39 @@ contract DeployNonDeterministic is CommentsDeployerBase {
17
14
 
18
15
  address owner = getProxyAdmin();
19
16
 
20
- // todo: figure out backfiller. right now this is made from cast wallet new
21
- address backfiller = 0x9AfA68161f094DAEA62816b6264b3D777978a164;
22
- address zoraRecipient = getZoraRecipient();
17
+ address backfiller = CommentsDeployerBase.getBackfillerAccount();
23
18
 
24
19
  vm.startBroadcast();
25
- // deploy comments backfiller
26
20
 
27
- address implAddress = address(deployCommentsImpl());
21
+ address implAddress = deployment.commentsImpl;
22
+
23
+ if (implAddress.code.length == 0) {
24
+ revert("impl not deployed");
25
+ }
28
26
 
29
27
  Comments comments = new Comments(implAddress);
30
28
 
31
- address[] memory delegateCommenters = defaultDelegateCommenters();
29
+ CallerAndCommenterImpl callerAndCommenterImpl = new CallerAndCommenterImpl(address(comments), ZORA_TIMED_SALE_STRATEGY, SECONDARY_SWAP, SPARK_VALUE);
30
+
31
+ CallerAndCommenter callerAndCommenter = new CallerAndCommenter(address(callerAndCommenterImpl));
32
32
 
33
- CommentsImpl(payable(address(comments))).initialize(zoraRecipient, owner, backfiller, delegateCommenters);
33
+ CallerAndCommenterImpl(payable(address(callerAndCommenter))).initialize(owner);
34
+
35
+ address[] memory delegateCommenters = new address[](1);
36
+ delegateCommenters[0] = address(callerAndCommenter);
37
+
38
+ CommentsImpl(payable(address(comments))).initialize(owner, backfiller, delegateCommenters);
34
39
 
35
40
  vm.stopBroadcast();
36
41
 
37
42
  deployment.comments = address(comments);
38
- deployment.commentsImpl = implAddress;
43
+ deployment.commentsBlockNumber = block.number;
44
+ deployment.callerAndCommenter = address(callerAndCommenter);
45
+ deployment.callerAndCommenterImpl = address(callerAndCommenterImpl);
39
46
 
40
47
  // save the deployment json
41
48
  saveDeployment(deployment);
49
+
50
+ console.log("Comments deployed at", address(comments));
42
51
  }
43
52
  }
@@ -3,11 +3,10 @@ pragma solidity ^0.8.20;
3
3
 
4
4
  import "forge-std/Script.sol";
5
5
 
6
- import {LibString} from "solady/utils/LibString.sol";
7
6
  import {ImmutableCreate2FactoryUtils} from "@zoralabs/shared-contracts/utils/ImmutableCreate2FactoryUtils.sol";
8
7
  import {ProxyDeployerScript, DeterministicDeployerAndCaller, DeterministicContractConfig} from "@zoralabs/shared-contracts/deployment/ProxyDeployerScript.sol";
9
- import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
10
8
  import {Comments} from "../src/proxy/Comments.sol";
9
+ import {CallerAndCommenter} from "../src/proxy/CallerAndCommenter.sol";
11
10
 
12
11
  /// @dev This script saves the current bytecode, and initialization parameters for the Sparks proxy,
13
12
  /// which then need to be populated with a salt and expected address, which can be achieved by
@@ -37,6 +36,32 @@ contract GenerateDeterministicParams is ProxyDeployerScript {
37
36
  config.deploymentCaller = caller;
38
37
  }
39
38
 
39
+ function mineForCallerAndCommenterAddress(
40
+ DeterministicDeployerAndCaller deployer,
41
+ address caller
42
+ ) private returns (DeterministicContractConfig memory config) {
43
+ // get proxy creation code
44
+ // get the expected init code for the proxy from the uupsProxyDeployer
45
+ bytes memory initCode = deployer.proxyCreationCode(type(CallerAndCommenter).creationCode);
46
+ bytes32 initCodeHash = keccak256(initCode);
47
+
48
+ // uupsProxyDeployer is deployer
49
+ (bytes32 salt, address expectedAddress) = mineSalt(address(deployer), initCodeHash, "7777777", caller);
50
+
51
+ // test deployment
52
+ // Create2.deploy(0, salt, initCode);
53
+
54
+ console2.log("salt");
55
+ console2.log(vm.toString(salt));
56
+
57
+ config.salt = salt;
58
+ config.deployedAddress = expectedAddress;
59
+ config.creationCode = initCode;
60
+ config.constructorArgs = deployer.proxyConstructorArgs();
61
+ config.contractName = "CallerAndCommenter";
62
+ config.deploymentCaller = caller;
63
+ }
64
+
40
65
  function run() public {
41
66
  address caller = vm.envAddress("DEPLOYER");
42
67
 
@@ -48,8 +73,11 @@ contract GenerateDeterministicParams is ProxyDeployerScript {
48
73
 
49
74
  vm.stopBroadcast();
50
75
 
51
- DeterministicContractConfig memory commentsConfig = mineForCommentsAddress(deployer, caller);
76
+ // DeterministicContractConfig memory commentsConfig = mineForCommentsAddress(deployer, caller);
77
+
78
+ DeterministicContractConfig memory callerAndCommenterConfig = mineForCallerAndCommenterAddress(deployer, caller);
52
79
 
53
- saveDeterministicContractConfig(commentsConfig, "comments");
80
+ // saveDeterministicContractConfig(commentsConfig, "comments");
81
+ saveDeterministicContractConfig(callerAndCommenterConfig, "callerAndCommenter");
54
82
  }
55
83
  }