-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18cab24
commit 264460f
Showing
11 changed files
with
2,177 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule multicaller
added at
356350
Submodule solady
updated
19 files
+3 −6 | .github/workflows/ci.yml | |
+1 −0 | README.md | |
+1 −1 | package.json | |
+1 −0 | src/Milady.sol | |
+166 −0 | src/accounts/Pod.sol | |
+152 −39 | src/tokens/ERC20.sol | |
+322 −32 | src/utils/DynamicArrayLib.sol | |
+2 −3 | src/utils/EnumerableSetLib.sol | |
+15 −0 | src/utils/LibSort.sol | |
+34 −1 | src/utils/LibString.sol | |
+291 −0 | test/DynamicArrayLib.t.sol | |
+0 −14 | test/DynamicBufferLib.t.sol | |
+80 −0 | test/ERC20.t.sol | |
+3 −0 | test/LibSort.t.sol | |
+176 −0 | test/LibString.t.sol | |
+149 −0 | test/Pod.t.sol | |
+17 −0 | test/utils/TestPlus.sol | |
+16 −0 | test/utils/mocks/MockERC20ForPermit2.sol | |
+32 −0 | test/utils/mocks/MockPod.sol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import "./utils/SoladyTest.sol"; | ||
import "clusters/ClustersNFTV1.sol"; | ||
|
||
contract ClustersNFTV1Test is SoladyTest { | ||
using ClustersNFTV1DataLib for *; | ||
|
||
ClustersNFTV1DataLib.ClustersData internal _data0; | ||
ClustersNFTV1DataLib.ClustersData internal _data1; | ||
|
||
function testSetAndGetClustersData(bytes32) public { | ||
do { | ||
uint40 id0 = uint40(_random()); | ||
uint40 id1 = uint40(_random()); | ||
uint256 ownedIndex0 = _random(); | ||
uint256 ownedIndex1 = _random(); | ||
uint208 additionalData0 = uint208(_random()); | ||
uint208 additionalData1 = uint208(_random()); | ||
|
||
_data0.initialize(id0, ownedIndex0); | ||
_data1.initialize(id1, ownedIndex1); | ||
assertEq(_data0.getId(), id0); | ||
assertEq(_data1.getId(), id1); | ||
assertEq(_data0.getOwnedIndex(), ownedIndex0); | ||
assertEq(_data1.getOwnedIndex(), ownedIndex1); | ||
|
||
_data0.setAdditionalData(additionalData0); | ||
_data1.setAdditionalData(additionalData1); | ||
assertEq(_data0.getAdditionalData(), additionalData0); | ||
assertEq(_data1.getAdditionalData(), additionalData1); | ||
|
||
ownedIndex0 = _random(); | ||
ownedIndex1 = _random(); | ||
additionalData0 = uint208(_random()); | ||
additionalData1 = uint208(_random()); | ||
|
||
_data0.setOwnedIndex(ownedIndex0); | ||
_data1.setOwnedIndex(ownedIndex1); | ||
assertEq(_data0.getId(), id0); | ||
assertEq(_data1.getId(), id1); | ||
assertEq(_data0.getOwnedIndex(), ownedIndex0); | ||
assertEq(_data1.getOwnedIndex(), ownedIndex1); | ||
|
||
_data0.setAdditionalData(additionalData0); | ||
_data1.setAdditionalData(additionalData1); | ||
assertEq(_data0.getAdditionalData(), additionalData0); | ||
assertEq(_data1.getAdditionalData(), additionalData1); | ||
} while (_randomChance(2)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import "./utils/SoladyTest.sol"; | ||
import "clusters/MessageHubV1.sol"; | ||
|
||
contract MothershipMock is MessageHubV1PodMothership { | ||
function createSubAccount(bytes32 originalSender, uint256 senderType) public returns (address) { | ||
return _createSubAccount(originalSender, senderType); | ||
} | ||
|
||
function forward(bytes calldata message) public payable { | ||
_forward(message); | ||
} | ||
} | ||
|
||
contract MessagehubV1Test is SoladyTest { | ||
MothershipMock mothership; | ||
uint256 x; | ||
uint256 valueDuringSetX; | ||
|
||
function setUp() public { | ||
mothership = new MothershipMock(); | ||
} | ||
|
||
function testMothership() public { | ||
bytes32 originalSender = bytes32(_random()); | ||
while (originalSender == bytes32(0)) originalSender = bytes32(_random()); | ||
|
||
uint256 senderType = _random(); | ||
while (senderType == 0) senderType = _random(); | ||
|
||
address expected = mothership.predictSubAccount(originalSender, senderType); | ||
assertEq(mothership.createSubAccount(originalSender, senderType), expected); | ||
assertEq(MessageHubV1Pod(payable(expected)).mothership(), address(mothership)); | ||
|
||
uint256 newX = _random(); | ||
|
||
vm.deal(address(this), 10 ether); | ||
|
||
bytes memory message = abi.encode( | ||
originalSender, | ||
senderType, | ||
1 ether, | ||
expected, | ||
abi.encodeWithSignature( | ||
"execute(address,uint256,bytes)", address(this), 1 ether, abi.encodeWithSignature("setX(uint256)", newX) | ||
) | ||
); | ||
|
||
mothership.forward{value: 1 ether}(message); | ||
|
||
assertEq(x, newX); | ||
assertEq(valueDuringSetX, 1 ether); | ||
} | ||
|
||
function setX(uint256 value) public payable { | ||
valueDuringSetX = msg.value; | ||
x = value; | ||
} | ||
} |
Oops, something went wrong.