-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
13 changed files
with
258 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,42 @@ | ||
DagonScalesTest:testIsValidSignatureALOT() (gas: 34615892725) | ||
DagonTest:testBurn(address,uint96) (runs: 256, μ: 152642, ~: 152642) | ||
DagonTest:testDeploy() (gas: 2071165) | ||
DagonTest:testFailBurnOverBalance(address,uint96) (runs: 256, μ: 187133, ~: 188222) | ||
DagonTest:testFailBurnOverThreshold(address,uint96) (runs: 256, μ: 219319, ~: 220408) | ||
DagonTest:testFailBurnOverBalance(address,uint96) (runs: 256, μ: 187211, ~: 188222) | ||
DagonTest:testFailBurnOverThreshold(address,uint96) (runs: 256, μ: 219419, ~: 220430) | ||
DagonTest:testFailInvalidThresholdExceedsSupply() (gas: 159203) | ||
DagonTest:testFailInvalidThresholdExceedsSupply2() (gas: 164582) | ||
DagonTest:testFailInvalidThresholdExceedsSupply2() (gas: 164604) | ||
DagonTest:testFailInvalidThresholdNull() (gas: 158981) | ||
DagonTest:testFailIsValidSignature2of3ForInsufficientSignatures() (gas: 199625) | ||
DagonTest:testFailIsValidSignatureWeighted() (gas: 228757) | ||
DagonTest:testFailIsValidSignatureWeightedERC1155() (gas: 37189) | ||
DagonTest:testFailIsValidSignatureWeightedERC20() (gas: 237823) | ||
DagonTest:testFailIsValidSignatureWeightedERC6909() (gas: 230379) | ||
DagonTest:testFailIsValidSignature2of3ForInsufficientSignatures() (gas: 199647) | ||
DagonTest:testFailIsValidSignatureOutOfOrder() (gas: 236802) | ||
DagonTest:testFailIsValidSignatureWeighted() (gas: 228779) | ||
DagonTest:testFailIsValidSignatureWeightedERC1155() (gas: 37211) | ||
DagonTest:testFailIsValidSignatureWeightedERC20() (gas: 237845) | ||
DagonTest:testFailIsValidSignatureWeightedERC6909() (gas: 230401) | ||
DagonTest:testFailIsValidSignatureWeightedERC721() (gas: 208731) | ||
DagonTest:testFailSetTokenInvalidStd(address) (runs: 256, μ: 158162, ~: 158162) | ||
DagonTest:testFailSetTokenInvalidStd(address) (runs: 256, μ: 158184, ~: 158184) | ||
DagonTest:testFailTransferFromInactiveAuth(address,address,uint96) (runs: 256, μ: 191540, ~: 192396) | ||
DagonTest:testFailTransferOverBalance(address,address,uint96) (runs: 256, μ: 186281, ~: 187137) | ||
DagonTest:testFailTransferOverBalance(address,address,uint96) (runs: 256, μ: 186459, ~: 187159) | ||
DagonTest:testInstall() (gas: 137318) | ||
DagonTest:testIsValidSignature() (gas: 150134) | ||
DagonTest:testIsValidSignature2of3() (gas: 195901) | ||
DagonTest:testIsValidSignature3of3() (gas: 203429) | ||
DagonTest:testIsValidSignature2of3() (gas: 195923) | ||
DagonTest:testIsValidSignature3of3() (gas: 203451) | ||
DagonTest:testIsValidSignatureMany() (gas: 433994) | ||
DagonTest:testIsValidSignatureOnchain() (gas: 196848) | ||
DagonTest:testIsValidSignatureVeryMany() (gas: 1236406) | ||
DagonTest:testIsValidSignatureWeighted() (gas: 232474) | ||
DagonTest:testIsValidSignatureWeighted() (gas: 232496) | ||
DagonTest:testIsValidSignatureWeightedERC1155() (gas: 247382) | ||
DagonTest:testIsValidSignatureWeightedERC20() (gas: 247118) | ||
DagonTest:testIsValidSignatureWeightedERC6909() (gas: 247788) | ||
DagonTest:testIsValidSignatureWeightedERC6909() (gas: 247810) | ||
DagonTest:testIsValidSignatureWeightedERC721() (gas: 208432) | ||
DagonTest:testNameAndSymbolAndDecimals(uint256) (runs: 256, μ: 15447, ~: 15447) | ||
DagonTest:testSetAuth(address) (runs: 256, μ: 144744, ~: 144744) | ||
DagonTest:testSetThreshold() (gas: 147272) | ||
DagonTest:testSetToken(address) (runs: 256, μ: 148626, ~: 148626) | ||
DagonTest:testSetURI() (gas: 165570) | ||
DagonTest:testSetURI() (gas: 165592) | ||
DagonTest:testSpoofSignatures(bytes) (runs: 256, μ: 16508, ~: 16437) | ||
DagonTest:testTransfer(address,address,uint88) (runs: 256, μ: 176009, ~: 176787) | ||
DagonTest:testTransferWithAuth(address,address,uint96) (runs: 256, μ: 179558, ~: 180278) | ||
DagonTest:testUserVoted() (gas: 194822) | ||
DagonTest:testTransfer(address,address,uint88) (runs: 256, μ: 176031, ~: 176809) | ||
DagonTest:testTransferWithAuth(address,address,uint96) (runs: 256, μ: 179160, ~: 180278) | ||
DagonTest:testUserVoted() (gas: 194822) | ||
SummonerTest:testSummoning(bytes12) (runs: 256, μ: 193633, ~: 193633) | ||
SummonerTest:testSummoningForERC20(bytes12) (runs: 256, μ: 151767, ~: 151767) | ||
SummonerTest:testSummoningForNFT(bytes12) (runs: 256, μ: 151789, ~: 151789) |
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,70 @@ | ||
[ | ||
{ | ||
"type": "function", | ||
"name": "summon", | ||
"inputs": [ | ||
{ | ||
"name": "summoner", | ||
"type": "address", | ||
"internalType": "address" | ||
}, | ||
{ | ||
"name": "shares", | ||
"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": "nft", | ||
"type": "bool", | ||
"internalType": "bool" | ||
}, | ||
{ | ||
"name": "threshold", | ||
"type": "uint88", | ||
"internalType": "uint88" | ||
}, | ||
{ | ||
"name": "salt", | ||
"type": "bytes12", | ||
"internalType": "bytes12" | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"name": "account", | ||
"type": "address", | ||
"internalType": "contract IAccounts" | ||
} | ||
], | ||
"stateMutability": "payable" | ||
} | ||
] |
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
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
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,55 @@ | ||
# Summoner | ||
[Git Source](https://github.com/Moloch-Mystics/dagon/blob/65b43bfbebe7dc8176f84027fc17e3554a0b2583/src/Summoner.sol) | ||
|
||
Simple summoner for Dagon (𒀭) group accounts. | ||
|
||
|
||
## State Variables | ||
### DAGON | ||
|
||
```solidity | ||
address internal constant DAGON = 0x0000000000001D4B1320bB3c47380a3D1C3A1A0C; | ||
``` | ||
|
||
|
||
### FACTORY | ||
|
||
```solidity | ||
IAccounts internal constant FACTORY = IAccounts(0x000000000000dD366cc2E4432bB998e41DFD47C7); | ||
``` | ||
|
||
|
||
## Functions | ||
### summon | ||
|
||
|
||
```solidity | ||
function summon(address summoner, uint88 shares, bool locked, bytes12 salt) | ||
public | ||
payable | ||
returns (IAccounts account); | ||
``` | ||
|
||
### summonForToken | ||
|
||
|
||
```solidity | ||
function summonForToken(address token, bool nft, uint88 threshold, bytes12 salt) | ||
public | ||
payable | ||
returns (IAccounts account); | ||
``` | ||
|
||
## Enums | ||
### Standard | ||
|
||
```solidity | ||
enum Standard { | ||
DAGON, | ||
ERC20, | ||
ERC721, | ||
ERC1155, | ||
ERC6909 | ||
} | ||
``` | ||
|
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,21 @@ | ||
# IAccounts | ||
[Git Source](https://github.com/Moloch-Mystics/dagon/blob/65b43bfbebe7dc8176f84027fc17e3554a0b2583/src/Summoner.sol) | ||
|
||
*Simple interface for Nani (𒀭) user account creation.* | ||
|
||
|
||
## Functions | ||
### createAccount | ||
|
||
|
||
```solidity | ||
function createAccount(address, bytes32) external payable returns (address); | ||
``` | ||
|
||
### execute | ||
|
||
|
||
```solidity | ||
function execute(address, uint256, bytes calldata) external payable returns (bytes memory); | ||
``` | ||
|
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,42 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
pragma solidity ^0.8.23; | ||
|
||
/// @notice Simple summoner for Dagon (𒀭) group accounts. | ||
/// @custom:version 0.0.0 | ||
contract Summoner { | ||
// Constants: | ||
address internal constant DAGON = 0x0000000000001D4B1320bB3c47380a3D1C3A1A0C; | ||
IAccounts internal constant FACTORY = IAccounts(0x000000000000dD366cc2E4432bB998e41DFD47C7); | ||
|
||
// Tokens: | ||
enum Standard { | ||
DAGON, | ||
ERC20, | ||
ERC721, | ||
ERC1155, | ||
ERC6909 | ||
} | ||
|
||
// Dagon-native: | ||
function summon(address summoner, uint88 shares, bool locked, bytes12 salt) public payable returns (IAccounts account) { | ||
account = IAccounts(FACTORY.createAccount(address(this), bytes32(abi.encodePacked(address(this), salt)))); | ||
account.execute(DAGON, 0, abi.encodeWithSignature("mint(address,uint96)", summoner, uint96(shares))); | ||
if (locked) account.execute(DAGON, 0, abi.encodeWithSignature("setAuth(address)", address(0xdead))); | ||
account.execute(DAGON, 0, abi.encodeWithSignature("setThreshold(uint88)", shares)); | ||
account.execute(address(account), 0, abi.encodeWithSignature("transferOwnership(address)", DAGON)); | ||
} | ||
|
||
// External token: | ||
function summonForToken(address token, bool nft, uint88 threshold, bytes12 salt) public payable returns (IAccounts account) { | ||
account = IAccounts(FACTORY.createAccount(address(this), bytes32(abi.encodePacked(address(this), salt)))); | ||
account.execute(DAGON, 0,abi.encodeWithSignature("setToken(address,uint8)", token, nft ? Standard.ERC721 : Standard.ERC20)); | ||
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. | ||
interface IAccounts { | ||
function createAccount(address, bytes32) external payable returns (address); | ||
function execute(address, uint256, bytes calldata) external payable returns (bytes memory); | ||
} |
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
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,37 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
pragma solidity ^0.8.23; | ||
|
||
import "@forge/Test.sol"; | ||
import "@solady/test/utils/mocks/MockERC20.sol"; | ||
import "@solady/test/utils/mocks/MockERC721.sol"; | ||
|
||
import {IAuth, Dagon} from "../src/Dagon.sol"; | ||
import {IAccounts, Summoner} from "../src/Summoner.sol"; | ||
|
||
contract SummonerTest is Test { | ||
Dagon internal constant DAGON = Dagon(0x0000000000001D4B1320bB3c47380a3D1C3A1A0C); | ||
address internal constant FACTORY = 0x000000000000dD366cc2E4432bB998e41DFD47C7; | ||
address internal constant TOKEN = 0x6B3595068778DD592e39A122f4f5a5cF09C90fE2; | ||
address internal constant NFT = 0x5Af0D9827E0c53E4799BB226655A1de152A425a5; | ||
|
||
Summoner internal summoner; | ||
|
||
function setUp() public payable { | ||
vm.createSelectFork(vm.rpcUrl("main")); // Ethereum mainnet fork. | ||
summoner = new Summoner(); | ||
} | ||
|
||
function testSummoning(bytes12 salt) public payable { | ||
IAccounts account = summoner.summon(address(this), 1 ether, false, salt); | ||
assertEq(DAGON.totalSupply(uint256(uint160(address(account)))), 1 ether); | ||
assertEq(DAGON.balanceOf(address(this), uint256(uint160(address(account)))), 1 ether); | ||
} | ||
|
||
function testSummoningForERC20(bytes12 salt) public payable { | ||
summoner.summonForToken(TOKEN, false, 1 ether, salt); | ||
} | ||
|
||
function testSummoningForNFT(bytes12 salt) public payable { | ||
summoner.summonForToken(NFT, true, 999, salt); | ||
} | ||
} |