Skip to content

Commit

Permalink
πŸ•―οΈβ‹†.˚
Browse files Browse the repository at this point in the history
  • Loading branch information
z0r0z committed Jul 23, 2024
1 parent d39dde7 commit 28dba79
Show file tree
Hide file tree
Showing 14 changed files with 146 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DagonTest:testBurn(address,uint96) (runs: 260, ΞΌ: 138940, ~: 138940)
DagonTest:testDeploy() (gas: 2367822)
DagonTest:testFailBurnOverBalance(address,uint96) (runs: 260, ΞΌ: 153887, ~: 154347)
DagonTest:testFailBurnOverThreshold(address,uint96) (runs: 260, ΞΌ: 185162, ~: 185622)
DagonTest:testFailBurnOverBalance(address,uint96) (runs: 260, ΞΌ: 153811, ~: 154347)
DagonTest:testFailBurnOverThreshold(address,uint96) (runs: 260, ΞΌ: 185086, ~: 185622)
DagonTest:testFailInvalidThresholdExceedsSupply() (gas: 124461)
DagonTest:testFailInvalidThresholdExceedsSupply2() (gas: 129541)
DagonTest:testFailInvalidThresholdNull() (gas: 124442)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Chains | Address |
----------------|-----------------------------------------|
Ethereum, Arbitrum, Optimism, Base, Blast, Zora, Gnosis, Polygon, Avalanche and BNB (& testnets) | [0x000000000000FEb893BB5D63bA33323EdCC237cE](https://etherscan.io/address/0x000000000000FEb893BB5D63bA33323EdCC237cE#code) |

> Summoner: [0x000000004356af01f3b800d93b0066e4b71e3609](https://etherscan.io/address/0x000000004356af01f3b800d93b0066e4b71e3609#code)
Dagon deployments are generated as [efficient create2 addresses](https://medium.com/coinmonks/on-efficient-ethereum-addresses-3fef0596e263) through the [canonical create2 factory](https://etherscan.io/address/0x0000000000ffe8b47b3e2130213b802212439497#code). As such they share the same exact address and code on every blockchain.

## Premise
Expand Down
82 changes: 82 additions & 0 deletions abi/Summoner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
[
{
"type": "function",
"name": "summon",
"inputs": [
{
"name": "summoners",
"type": "tuple[]",
"internalType": "struct Summoner.Ownership[]",
"components": [
{
"name": "owner",
"type": "address",
"internalType": "address"
},
{
"name": "shares",
"type": "uint96",
"internalType": "uint96"
}
]
},
{
"name": "threshold",
"type": "uint88",
"internalType": "uint88"
},
{
"name": "locked",
"type": "bool",
"internalType": "bool"
},
{
"name": "salt",
"type": "bytes12",
"internalType": "bytes12"
}
],
"outputs": [
{
"name": "account",
"type": "address",
"internalType": "contract IAccounts"
}
],
"stateMutability": "payable"
},
{
"type": "function",
"name": "summonForToken",
"inputs": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "standard",
"type": "uint8",
"internalType": "enum Summoner.Standard"
},
{
"name": "threshold",
"type": "uint88",
"internalType": "uint88"
},
{
"name": "salt",
"type": "bytes12",
"internalType": "bytes12"
}
],
"outputs": [
{
"name": "account",
"type": "address",
"internalType": "contract IAccounts"
}
],
"stateMutability": "payable"
}
]
2 changes: 2 additions & 0 deletions docs/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Chains | Address |
----------------|-----------------------------------------|
Ethereum, Arbitrum, Optimism, Base, Blast, Zora, Gnosis, Polygon, Avalanche and BNB (& testnets) | [0x000000000000FEb893BB5D63bA33323EdCC237cE](https://etherscan.io/address/0x000000000000FEb893BB5D63bA33323EdCC237cE#code) |

> Summoner: [0x000000004356af01f3b800d93b0066e4b71e3609](https://etherscan.io/address/0x000000004356af01f3b800d93b0066e4b71e3609#code)
Dagon deployments are generated as [efficient create2 addresses](https://medium.com/coinmonks/on-efficient-ethereum-addresses-3fef0596e263) through the [canonical create2 factory](https://etherscan.io/address/0x0000000000ffe8b47b3e2130213b802212439497#code). As such they share the same exact address and code on every blockchain.

## Premise
Expand Down
2 changes: 2 additions & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
- [Dagon](src/Dagon.sol/contract.Dagon.md)
- [IAuth](src/Dagon.sol/interface.IAuth.md)
- [IOwnable](src/Dagon.sol/interface.IOwnable.md)
- [Summoner](src/Summoner.sol/contract.Summoner.md)
- [IAccounts](src/Summoner.sol/interface.IAccounts.md)
2 changes: 1 addition & 1 deletion docs/src/src/Dagon.sol/contract.Dagon.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dagon
[Git Source](https://github.com/Moloch-Mystics/dagon/blob/405e4eb5a2a407d3f2421047d8b8f778ad336343/src/Dagon.sol)
[Git Source](https://github.com/Moloch-Mystics/dagon/blob/d39dde7073476515dbf75345b60f2ea3d623186a/src/Dagon.sol)

**Inherits:**
ERC6909
Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/Dagon.sol/interface.IAuth.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IAuth
[Git Source](https://github.com/Moloch-Mystics/dagon/blob/405e4eb5a2a407d3f2421047d8b8f778ad336343/src/Dagon.sol)
[Git Source](https://github.com/Moloch-Mystics/dagon/blob/d39dde7073476515dbf75345b60f2ea3d623186a/src/Dagon.sol)

Simple authority interface for contracts.

Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/Dagon.sol/interface.IOwnable.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IOwnable
[Git Source](https://github.com/Moloch-Mystics/dagon/blob/405e4eb5a2a407d3f2421047d8b8f778ad336343/src/Dagon.sol)
[Git Source](https://github.com/Moloch-Mystics/dagon/blob/d39dde7073476515dbf75345b60f2ea3d623186a/src/Dagon.sol)

Simple ownership interface for handover requests.

Expand Down
2 changes: 2 additions & 0 deletions docs/src/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
- [Dagon](Dagon.sol/contract.Dagon.md)
- [IAuth](Dagon.sol/interface.IAuth.md)
- [IOwnable](Dagon.sol/interface.IOwnable.md)
- [Summoner](Summoner.sol/contract.Summoner.md)
- [IAccounts](Summoner.sol/interface.IAccounts.md)
6 changes: 3 additions & 3 deletions docs/src/src/Summoner.sol/contract.Summoner.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Summoner
[Git Source](https://github.com/Moloch-Mystics/dagon/blob/efc921a89c26d7bf4ef258e73ffcf64e1bdef80a/src/Summoner.sol)
[Git Source](https://github.com/Moloch-Mystics/dagon/blob/d39dde7073476515dbf75345b60f2ea3d623186a/src/Summoner.sol)

Simple summoner for Dagon (π’€­) group accounts.

Expand All @@ -8,14 +8,14 @@ Simple summoner for Dagon (π’€­) group accounts.
### DAGON

```solidity
address internal constant DAGON = 0x0000000000001ADDcB933DD5028159dc965b5b7f;
address internal constant DAGON = 0x000000000000FEb893BB5D63bA33323EdCC237cE;
```


### FACTORY

```solidity
IAccounts internal constant FACTORY = IAccounts(0x000000000000dD366cc2E4432bB998e41DFD47C7);
IAccounts internal constant FACTORY = IAccounts(0x0000000000009f1E546FC4A8F68eB98031846cb8);
```


Expand Down
2 changes: 1 addition & 1 deletion docs/src/src/Summoner.sol/interface.IAccounts.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IAccounts
[Git Source](https://github.com/Moloch-Mystics/dagon/blob/efc921a89c26d7bf4ef258e73ffcf64e1bdef80a/src/Summoner.sol)
[Git Source](https://github.com/Moloch-Mystics/dagon/blob/d39dde7073476515dbf75345b60f2ea3d623186a/src/Summoner.sol)

*Simple interface for Nani (π’€­) user account creation and setup.*

Expand Down
2 changes: 1 addition & 1 deletion lib/forge-std
Submodule forge-std updated 4 files
+1 βˆ’1 src/StdStorage.sol
+76 βˆ’0 src/Vm.sol
+8 βˆ’0 test/StdStorage.t.sol
+2 βˆ’2 test/Vm.t.sol
2 changes: 1 addition & 1 deletion lib/solady
Submodule solady updated 66 files
+841 βˆ’821 .gas-snapshot
+33 βˆ’0 .github/workflows/ci-super-intense.yml
+2 βˆ’2 README.md
+1 βˆ’0 foundry.toml
+1 βˆ’1 package.json
+0 βˆ’1 src/Milady.sol
+68 βˆ’57 src/accounts/ERC1271.sol
+9 βˆ’4 src/auth/OwnableRoles.sol
+44 βˆ’69 src/utils/CREATE3.sol
+2 βˆ’2 src/utils/ECDSA.sol
+1 βˆ’1 src/utils/ERC1967FactoryConstants.sol
+53 βˆ’6 src/utils/GasBurnerLib.sol
+47 βˆ’10 src/utils/LibBitmap.sol
+727 βˆ’340 src/utils/LibClone.sol
+14 βˆ’13 src/utils/LibRLP.sol
+49 βˆ’98 src/utils/LibString.sol
+12 βˆ’11 src/utils/P256.sol
+146 βˆ’160 src/utils/SSTORE2.sol
+85 βˆ’137 src/utils/ext/delegatexyz/DelegateCheckerLib.sol
+2 βˆ’2 src/utils/legacy/CWIA.sol
+387 βˆ’0 src/utils/legacy/LibCWIA.sol
+1 βˆ’1 test/Base64.t.sol
+27 βˆ’22 test/CREATE3.t.sol
+127 βˆ’12 test/DelegateCheckerLib.t.sol
+45 βˆ’9 test/DeploylessPredeployQueryer.t.sol
+24 βˆ’24 test/DynamicBufferLib.t.sol
+11 βˆ’11 test/ERC1155.t.sol
+10 βˆ’10 test/ERC1271.t.sol
+1 βˆ’1 test/ERC1967Factory.t.sol
+4 βˆ’4 test/ERC2981.t.sol
+15 βˆ’7 test/ERC4337.t.sol
+1 βˆ’1 test/ERC4337Factory.t.sol
+4 βˆ’4 test/ERC6551.t.sol
+5 βˆ’5 test/ERC6909.t.sol
+15 βˆ’15 test/ERC721.t.sol
+32 βˆ’32 test/EnumerableSetLib.t.sol
+51 βˆ’16 test/FixedPointMathLib.t.sol
+70 βˆ’10 test/GasBurnerLib.t.sol
+56 βˆ’1 test/LibBitmap.t.sol
+315 βˆ’0 test/LibCWIA.t.sol
+755 βˆ’515 test/LibClone.t.sol
+8 βˆ’8 test/LibERC6551.t.sol
+9 βˆ’9 test/LibMap.t.sol
+4 βˆ’4 test/LibPRNG.t.sol
+15 βˆ’0 test/LibRLP.t.sol
+23 βˆ’23 test/LibSort.t.sol
+18 βˆ’2 test/LibString.t.sol
+6 βˆ’6 test/LibZip.t.sol
+10 βˆ’10 test/Lifebuoy.t.sol
+12 βˆ’2 test/MerkleProofLib.t.sol
+1 βˆ’1 test/MetadataReaderLib.t.sol
+37 βˆ’37 test/MinHeapLib.t.sol
+6 βˆ’4 test/Multicallable.t.sol
+2 βˆ’2 test/Ownable.t.sol
+5 βˆ’5 test/OwnableRoles.t.sol
+293 βˆ’24 test/P256.t.sol
+7 βˆ’7 test/RedBlackTree.t.sol
+126 βˆ’134 test/SSTORE2.t.sol
+3 βˆ’3 test/SafeCastLib.t.sol
+13 βˆ’9 test/SafeTransferLib.t.sol
+5 βˆ’5 test/SignatureCheckerLib.t.sol
+8 βˆ’8 test/UpgradeableBeacon.t.sol
+778 βˆ’0 test/data/wycheproof.jsonl
+58 βˆ’0 test/utils/Brutalizer.sol
+67 βˆ’30 test/utils/TestPlus.sol
+20 βˆ’0 test/utils/mocks/MockMulticallable.sol
45 changes: 45 additions & 0 deletions src/Summoner.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// α—ͺα—©GOα‘Ž π’€­ π’€­ π’€­ π’€­ π’€­ π’€­ π’€­ π’€­ π’€­ π’€­ π’€­
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.26;

/// @notice Simple summoner for Dagon (π’€­) group accounts.
/// @custom:version 1.1.1
contract Summoner {
address internal constant DAGON = 0x000000000000FEb893BB5D63bA33323EdCC237cE;
IAccounts internal constant FACTORY = IAccounts(0x0000000000009f1E546FC4A8F68eB98031846cb8);

struct Ownership {
address owner;
uint96 shares;
}

enum Standard {
DAGON,
ERC20,
ERC721,
ERC1155,
ERC6909
}

function summon(Ownership[] calldata summoners, uint88 threshold, bool locked, bytes12 salt) public payable returns (IAccounts account) {
account = IAccounts(FACTORY.createAccount{value: msg.value}(address(this), bytes32(abi.encodePacked(this, salt))));
for (uint256 i; i != summoners.length; ++i)
account.execute(DAGON, 0, abi.encodeWithSignature("mint(address,uint96)", summoners[i].owner, summoners[i].shares));
if (locked) account.execute(DAGON, 0, abi.encodeWithSignature("setAuth(address)", address(0xdead)));
account.execute(DAGON, 0, abi.encodeWithSignature("setThreshold(uint88)", threshold));
account.execute(address(account), 0, abi.encodeWithSignature("transferOwnership(address)", DAGON));
}

function summonForToken(address token, Standard standard, uint88 threshold, bytes12 salt) public payable returns (IAccounts account) {
account = IAccounts(FACTORY.createAccount{value: msg.value}(address(this), bytes32(abi.encodePacked(this, salt))));
account.execute(DAGON, 0, abi.encodeWithSignature("setToken(address,uint8)", token, standard));
account.execute(DAGON, 0, abi.encodeWithSignature("setThreshold(uint88)", threshold));
account.execute(address(account), 0, abi.encodeWithSignature("transferOwnership(address)", DAGON));
}
}

/// @dev Simple interface for Nani (π’€­) user account creation and setup.
interface IAccounts {
function createAccount(address, bytes32) external payable returns (address);
function execute(address, uint256, bytes calldata) external payable returns (bytes memory);
}

0 comments on commit 28dba79

Please sign in to comment.