Skip to content

Commit 35ce19d

Browse files
committed
Workflow fix test 1
1 parent 04ee987 commit 35ce19d

File tree

5 files changed

+150
-133
lines changed

5 files changed

+150
-133
lines changed

script/DeployCreations.s.sol

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ import {HelperConfig} from "./HelperConfig.s.sol";
99
contract DeployMinimal is Script {
1010
function run() public {}
1111

12-
function deployDappunkCreations() public returns (dappunkCreations,address) {
12+
function deployDappunkCreations() public returns (dappunkCreations, address) {
1313
HelperConfig helperConfig = new HelperConfig();
1414
HelperConfig.NetworkConfig memory config = helperConfig.getConfig();
1515
address account = config.account;
1616
address[] memory relayers = new address[](1);
1717
relayers[0] = account;
18-
18+
1919
vm.startBroadcast(account);
2020
logic lc = new logic("meow");
21-
dappunkCreations dc = new dappunkCreations(account,account,account,account,account,account,account,relayers,address(lc));
21+
dappunkCreations dc =
22+
new dappunkCreations(account, account, account, account, account, account, account, relayers, address(lc));
2223
vm.stopBroadcast();
2324

24-
return (dc,address(dc));
25+
return (dc, address(dc));
2526
}
2627
}

script/DeployMinimal.s.sol

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {logic} from "./../src/dappunk/forwarder.sol";
1010
contract DeployMinimal is Script {
1111
function run() public {}
1212

13-
function deployMinimalAccount() public returns (HelperConfig, MinimalAccount,dappunkCreations) {
13+
function deployMinimalAccount() public returns (HelperConfig, MinimalAccount, dappunkCreations) {
1414
HelperConfig helperConfig = new HelperConfig();
1515
HelperConfig.NetworkConfig memory config = helperConfig.getConfig();
1616
address account = config.account;
@@ -25,11 +25,12 @@ contract DeployMinimal is Script {
2525
minimalAccount.transferOwnership(config.account);
2626

2727
logic lc = new logic("meow");
28-
dappunkCreations dc = new dappunkCreations(account,account,account,account,account,account,account,relayers,address(lc));
29-
dc.grantRole(0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6,address(minimalAccount));
28+
dappunkCreations dc =
29+
new dappunkCreations(account, account, account, account, account, account, account, relayers, address(lc));
30+
dc.grantRole(0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6, address(minimalAccount));
3031

3132
vm.stopBroadcast();
3233

33-
return (helperConfig, minimalAccount,dc);
34+
return (helperConfig, minimalAccount, dc);
3435
}
3536
}

script/createVoucher.s.sol

Lines changed: 56 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import {Script, console2} from "forge-std/Script.sol";
55
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
66
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
77

8-
abstract contract CodeConstants is Script{
8+
abstract contract CodeConstants is Script {
99
string constant DOMAIN = "moshpit";
1010
string constant VERSION = "1";
11+
1112
struct NFTVoucher {
1213
uint256 tokenId;
1314
uint256 price;
@@ -23,13 +24,12 @@ abstract contract CodeConstants is Script{
2324
}
2425

2526
address constant MINT_VALIDATOR = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; // ANVIL_DEFAULT Account
26-
string mnemonic = "test test test test test test test test test test test junk";
27+
string mnemonic = "test test test test test test test test test test test junk";
2728
uint256 privateKey = vm.deriveKey(mnemonic, 0);
2829
address SIGNER = vm.rememberKey(privateKey);
2930
}
3031

3132
contract creationsVoucher is Script, CodeConstants {
32-
3333
error creationVoucher__NotSameAddressAsTestWalletCreated();
3434

3535
/*//////////////////////////////////////////////////////////////
@@ -46,25 +46,40 @@ contract creationsVoucher is Script, CodeConstants {
4646
_cachedDomainSeparator = _buildDomainSeparator(dappunkCreations);
4747
}
4848

49-
function generateVoucher(uint256 collectionIndex,uint256 tokenIndex,uint256 price,uint256 quantity,uint256 buyerQty,uint256 start,uint256 end,uint96 royalty,bool isStealth,bool isSbt,address creator) public pure returns(NFTVoucher memory nftVoucher){
50-
uint256 tkID = generateTokenId(creator,collectionIndex,tokenIndex,quantity);
49+
function generateVoucher(
50+
uint256 collectionIndex,
51+
uint256 tokenIndex,
52+
uint256 price,
53+
uint256 quantity,
54+
uint256 buyerQty,
55+
uint256 start,
56+
uint256 end,
57+
uint96 royalty,
58+
bool isStealth,
59+
bool isSbt,
60+
address creator
61+
) public pure returns (NFTVoucher memory nftVoucher) {
62+
uint256 tkID = generateTokenId(creator, collectionIndex, tokenIndex, quantity);
5163
nftVoucher = NFTVoucher({
52-
tokenId:tkID,
53-
price:price,
54-
quantity:quantity,
55-
buyerQty:buyerQty,
56-
start:start,
57-
end:end,
58-
royalty:royalty,
59-
isStealth:isStealth,
60-
isSbt:isSbt,
64+
tokenId: tkID,
65+
price: price,
66+
quantity: quantity,
67+
buyerQty: buyerQty,
68+
start: start,
69+
end: end,
70+
royalty: royalty,
71+
isStealth: isStealth,
72+
isSbt: isSbt,
6173
creator: hex"",
62-
validator:hex""
74+
validator: hex""
6375
});
6476
}
65-
66-
function generateTokenId(address creator,uint256 collectionIndex,uint256 tokenIndex,uint256 tokenQty) internal pure returns(uint256){
6777

78+
function generateTokenId(address creator, uint256 collectionIndex, uint256 tokenIndex, uint256 tokenQty)
79+
internal
80+
pure
81+
returns (uint256)
82+
{
6883
// uint256 collectionIndexSize = 10; // in hex
6984
// uint256 tokenIndexSize = 10;
7085
// uint256 tokenQtySize = 4;
@@ -79,13 +94,16 @@ contract creationsVoucher is Script, CodeConstants {
7994
tokenId = (tokenId << 16) + tokenQty;
8095

8196
return tokenId;
82-
8397
}
8498

85-
function generateEIP712StructHash(NFTVoucher memory voucher,address dappunkCreations) public view returns (bytes32 digest) {
99+
function generateEIP712StructHash(NFTVoucher memory voucher, address dappunkCreations)
100+
public
101+
view
102+
returns (bytes32 digest)
103+
{
86104
// STEP 1 : Generate a EIP712 compliant voucher hash.
87105
// STEP 2 : Generate a Signature from the creator.
88-
// STEP 3 : Generate a Signature from the Admin
106+
// STEP 3 : Generate a Signature from the Admin
89107

90108
// For step on Import the EIP712 sol
91109
digest = _hashTypedDataV4(
@@ -104,39 +122,41 @@ contract creationsVoucher is Script, CodeConstants {
104122
voucher.isStealth,
105123
voucher.isSbt
106124
)
107-
), dappunkCreations
125+
),
126+
dappunkCreations
108127
);
109-
110128
}
111129

112-
function generateSignedVoucher(NFTVoucher memory voucher,bytes32 digest) public view returns (NFTVoucher memory, bytes memory, bytes memory) {
113-
// user Signature Generation
130+
function generateSignedVoucher(NFTVoucher memory voucher, bytes32 digest)
131+
public
132+
view
133+
returns (NFTVoucher memory, bytes memory, bytes memory)
134+
{
135+
// user Signature Generation
114136
uint8 v;
115137
bytes32 r;
116138
bytes32 s;
117-
118-
if (voucher.tokenId >> 96 != uint256(uint160(SIGNER))) revert creationVoucher__NotSameAddressAsTestWalletCreated();
119-
139+
140+
if (voucher.tokenId >> 96 != uint256(uint160(SIGNER))) {
141+
revert creationVoucher__NotSameAddressAsTestWalletCreated();
142+
}
143+
120144
// Creator signature
121-
(v,r,s) = vm.sign(SIGNER,digest);
145+
(v, r, s) = vm.sign(SIGNER, digest);
122146
voucher.creator = abi.encodePacked(r, s, v);
123147

124148
//Admin Signature
125-
(v,r,s) = vm.sign(MINT_VALIDATOR,digest);
149+
(v, r, s) = vm.sign(MINT_VALIDATOR, digest);
126150
voucher.validator = abi.encodePacked(r, s, v);
127151

128-
return (voucher,voucher.creator,voucher.validator);
152+
return (voucher, voucher.creator, voucher.validator);
129153
}
130154

131-
132-
133155
function _buildDomainSeparator(address dappunkCreations) private view returns (bytes32) {
134156
return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, dappunkCreations));
135157
}
136158

137-
function _hashTypedDataV4(bytes32 structHash,address dappunkCreations) internal view returns (bytes32) {
159+
function _hashTypedDataV4(bytes32 structHash, address dappunkCreations) internal view returns (bytes32) {
138160
return MessageHashUtils.toTypedDataHash(_buildDomainSeparator(dappunkCreations), structHash);
139161
}
140-
141-
142-
}
162+
}

src/dappunk/forwarder.sol

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,24 @@ contract logic is ERC2771Forwarder, AccessControl, ReentrancyGuard {
121121

122122
/// @dev Executes a forwarder request if valid.
123123
/// @param request The forwarder request data.
124-
function execute(
125-
ForwardRequestData calldata request
126-
) public payable override(ERC2771Forwarder) _depricated nonReentrant {
124+
function execute(ForwardRequestData calldata request)
125+
public
126+
payable
127+
override(ERC2771Forwarder)
128+
_depricated
129+
nonReentrant
130+
{
127131
if (!customEnabler[bytes4(request.data)]) {
128-
if (!signatureEnabler[bytes4(request.data)][request.data.length])
132+
if (!signatureEnabler[bytes4(request.data)][request.data.length]) {
129133
revert invalidRequest();
134+
}
130135

131136
if (hasRole(MANAGER_ROLE, msg.sender)) {
132137
ERC2771Forwarder.execute(request);
133138
} else {
134-
if (!nativeEnabler[bytes4(request.data)])
139+
if (!nativeEnabler[bytes4(request.data)]) {
135140
revert callNotAllowed();
141+
}
136142
ERC2771Forwarder.execute(request);
137143
}
138144
} else {
@@ -144,64 +150,52 @@ contract logic is ERC2771Forwarder, AccessControl, ReentrancyGuard {
144150
/// @dev Adds a new signature with data length to the signature enabler.
145151
/// @param _signature The function signature to add.
146152
/// @param _dataLength The corresponding data length.
147-
function addSignatures(
148-
bytes4 _signature,
149-
uint256 _dataLength
150-
) external onlyRole(MANAGER_ROLE) nonReentrant {
151-
if (signatureEnabler[_signature][_dataLength])
153+
function addSignatures(bytes4 _signature, uint256 _dataLength) external onlyRole(MANAGER_ROLE) nonReentrant {
154+
if (signatureEnabler[_signature][_dataLength]) {
152155
revert signatureAlreadyPresent();
156+
}
153157
signatureEnabler[_signature][_dataLength] = true;
154158
emit signatureAdded(_signature);
155159
}
156160

157161
/// @dev Deletes a signature with a specific data length from the signature enabler.
158162
/// @param _signature The function signature to delete.
159163
/// @param _dataLength The corresponding data length to delete.
160-
function deleteSignature(
161-
bytes4 _signature,
162-
uint256 _dataLength
163-
) external onlyRole(MANAGER_ROLE) nonReentrant {
164-
if (!signatureEnabler[_signature][_dataLength])
164+
function deleteSignature(bytes4 _signature, uint256 _dataLength) external onlyRole(MANAGER_ROLE) nonReentrant {
165+
if (!signatureEnabler[_signature][_dataLength]) {
165166
revert signatureDisabled();
167+
}
166168
delete signatureEnabler[_signature][_dataLength];
167169
emit signatureDeleted(_signature);
168170
}
169171

170172
/// @dev Adds a signature to the native enabler mapping.
171173
/// @param _signature The function signature to enable for native function calls.
172-
function addToNativeEnabler(
173-
bytes4 _signature
174-
) external onlyRole(MANAGER_ROLE) nonReentrant {
174+
function addToNativeEnabler(bytes4 _signature) external onlyRole(MANAGER_ROLE) nonReentrant {
175175
if (nativeEnabler[_signature]) revert nativeSignatureAlreadyPresent();
176176
nativeEnabler[_signature] = true;
177177
emit nativeSignatureAdded(_signature);
178178
}
179179

180180
/// @dev Deletes a signature from the native enabler mapping.
181181
/// @param _signature The function signature to disable for native function calls.
182-
function deleteNativeSignature(
183-
bytes4 _signature
184-
) external onlyRole(MANAGER_ROLE) nonReentrant {
182+
function deleteNativeSignature(bytes4 _signature) external onlyRole(MANAGER_ROLE) nonReentrant {
185183
if (!nativeEnabler[_signature]) revert nativeSignatureDisabled();
186184
delete nativeEnabler[_signature];
187185
emit nativeSignatureDeleted(_signature);
188186
}
189187

190188
/// @dev Adds a signature to the custom enabler mapping.
191189
/// @param _signature The function signature to enable for custom gifting calls.
192-
function addTocustomEnabler(
193-
bytes4 _signature
194-
) external onlyRole(MANAGER_ROLE) nonReentrant {
190+
function addTocustomEnabler(bytes4 _signature) external onlyRole(MANAGER_ROLE) nonReentrant {
195191
if (customEnabler[_signature]) revert customSignatureAlreadyPresent();
196192
customEnabler[_signature] = true;
197193
emit customSignatureAdded(_signature);
198194
}
199195

200196
/// @dev Deletes a signature from the custom enabler mapping.
201197
/// @param _signature The function signature to disable for custom gifting calls.
202-
function deletecustomSignature(
203-
bytes4 _signature
204-
) external onlyRole(MANAGER_ROLE) nonReentrant {
198+
function deletecustomSignature(bytes4 _signature) external onlyRole(MANAGER_ROLE) nonReentrant {
205199
if (!customEnabler[_signature]) revert customSignatureDisabled();
206200
delete customEnabler[_signature];
207201
emit customSignatureDeleted(_signature);
@@ -211,10 +205,11 @@ contract logic is ERC2771Forwarder, AccessControl, ReentrancyGuard {
211205
/// @dev Currently, batch execution is not allowed and will revert.
212206
/// @param /*requests*/ Array of forwarder request data (unused).
213207
/// @param /*refundReceiver*/ Address for refunding unused gas (unused).
214-
function executeBatch(
215-
ForwardRequestData[] calldata /*requests*/,
216-
address payable /*refundReceiver*/
217-
) public payable override(ERC2771Forwarder) {
208+
function executeBatch(ForwardRequestData[] calldata, /*requests*/ address payable /*refundReceiver*/ )
209+
public
210+
payable
211+
override(ERC2771Forwarder)
212+
{
218213
revert();
219214
}
220215

@@ -229,10 +224,8 @@ contract logic is ERC2771Forwarder, AccessControl, ReentrancyGuard {
229224

230225
/// @dev Withdraws the Ether balance from the contract to a specified address.
231226
/// @param _to The address to receive the withdrawn Ether.
232-
function withdraw(
233-
address payable _to
234-
) external onlyRole(DEFAULT_ADMIN_ROLE) {
235-
(bool sent, ) = _to.call{value: address(this).balance}("");
227+
function withdraw(address payable _to) external onlyRole(DEFAULT_ADMIN_ROLE) {
228+
(bool sent,) = _to.call{value: address(this).balance}("");
236229
if (!sent) revert();
237230
}
238-
}
231+
}

0 commit comments

Comments
 (0)