Skip to content

Commit ab886b0

Browse files
committed
🪙 Add mock KDAO
1 parent b0dc652 commit ab886b0

14 files changed

+83
-20
lines changed

avalanche/test/addresses.t.sol

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
pragma solidity ^0.8.0;
44

5-
import {
6-
TRYB, TRYB_DEPLOYER, USDC, USDC_DEPLOYER, USDT, USDT_DEPLOYER
7-
} from "../addresses.sol";
5+
import {TRYB, TRYB_DEPLOYER, USDC, USDC_DEPLOYER, USDT, USDT_DEPLOYER} from "../addresses.sol";
86
import {Test} from "forge-std/Test.sol";
97

108
contract addressesTest is Test {

erc/IERC20Permit.sol

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ pragma solidity ^0.8.0;
55
import "./IERC20.sol";
66

77
interface IERC20Permit is IERC20 {
8-
function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
9-
external;
8+
function permit(
9+
address owner,
10+
address spender,
11+
uint256 amount,
12+
uint256 deadline,
13+
uint8 v,
14+
bytes32 r,
15+
bytes32 s
16+
) external;
1017

1118
function nonces(address owner) external view returns (uint256);
1219

kimlikdao/mock/KDAO.sol

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.8.0;
4+
5+
import {ERC20Permit as MockERC20Permit} from "../../erc/mock/ERC20Permit.sol";
6+
7+
contract KDAO is MockERC20Permit {
8+
function name() external pure override returns (string memory) {
9+
return "KimlikDAO";
10+
}
11+
12+
function symbol() external pure override returns (string memory) {
13+
return "KDAO";
14+
}
15+
16+
function decimals() external pure override returns (uint8) {
17+
return 6;
18+
}
19+
20+
function DOMAIN_SEPARATOR() public pure override returns (bytes32) {
21+
return 0;
22+
}
23+
}

kimlikdao/test/addresses.t.sol

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
pragma solidity ^0.8.0;
44

5-
import {Test} from "forge-std/Test.sol";
5+
import {
6+
applyL1ToL2Alias,
7+
computeCreateAddress as computeZkSyncCreateAddress
8+
} from "../../zksync/IZkSync.sol";
69
import {
710
KDAO,
811
KDAO_DEPLOYER,
@@ -13,10 +16,7 @@ import {
1316
KPASS_ZKSYNC,
1417
KPASS_ZKSYNC_DEPLOYER
1518
} from "../addresses.sol";
16-
import {
17-
applyL1ToL2Alias,
18-
computeCreateAddress as computeZkSyncCreateAddress
19-
} from "../../zksync/IZkSync.sol";
19+
import {Test} from "forge-std/Test.sol";
2020

2121
contract addressesTest is Test {
2222
function testDeployerConsistency() public pure {

types/Signature.sol

+4
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ struct Signature {
2222
bytes32 r;
2323
YParityAndS yParityAndS;
2424
}
25+
26+
function SignatureFrom(uint8 v, bytes32 r, bytes32 s_) pure returns (Signature memory) {
27+
return Signature(r, YParityAndS.wrap((uint256(v - 27) << 255) | uint256(s_)));
28+
}

types/amountAddr.sol

+13-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ function addr(amountAddr self) pure returns (address) {
2121
}
2222

2323
function setAddr(amountAddr self, address _addr) pure returns (amountAddr) {
24-
return amountAddr.wrap(amountAddr.unwrap(self) & (type(uint256).max << 160) | uint256(uint160(_addr)));
24+
return amountAddr.wrap(
25+
amountAddr.unwrap(self) & (type(uint256).max << 160) | uint256(uint160(_addr))
26+
);
2527
}
2628

2729
function addAddr(amountAddr self, address _addr) pure returns (amountAddr) {
@@ -40,4 +42,13 @@ function toBytes32(amountAddr self) pure returns (bytes32) {
4042
return bytes32(amountAddr.unwrap(self));
4143
}
4244

43-
using {unpack, amount, addr, addAddr, setAddr, isZero, toBytes32, notEqual as !=} for amountAddr global;
45+
using {
46+
unpack,
47+
amount,
48+
addr,
49+
addAddr,
50+
setAddr,
51+
isZero,
52+
toBytes32,
53+
notEqual as !=
54+
} for amountAddr global;

types/test/amountAddr.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
pragma solidity ^0.8.0;
44

5-
import {Test} from "forge-std/Test.sol";
65
import {amountAddr, amountAddrFrom} from "../amountAddr.sol";
6+
import {Test} from "forge-std/Test.sol";
77

88
contract amountAddrTest is Test {
99
function testAccessors() external pure {

types/test/uint128x2.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
pragma solidity ^0.8.0;
44

5-
import {Test} from "forge-std/Test.sol";
65
import {uint128x2, uint128x2From} from "../uint128x2.sol";
6+
import {Test} from "forge-std/Test.sol";
77

88
contract uint128x2Test is Test {
99
function testAccessors() external pure {

types/test/uint48x2.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
pragma solidity ^0.8.0;
44

5-
import {Test} from "forge-std/Test.sol";
65
import {uint48x2, uint48x2From} from "../uint48x2.sol";
6+
import {Test} from "forge-std/Test.sol";
77

88
contract uint48x2Test is Test {
99
function testAccessors() external pure {

types/uint128x2.sol

+3-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ function equal(uint128x2 self, uint128x2 other) pure returns (bool) {
8181
*/
8282
function fracMul(uint128x2 self, uint256 val) pure returns (uint128x2) {
8383
unchecked {
84-
return uint128x2.wrap(uint128x2.unwrap(self) * val / uint128(uint128x2.unwrap(self))).setLo(val);
84+
return uint128x2.wrap(uint128x2.unwrap(self) * val / uint128(uint128x2.unwrap(self))).setLo(
85+
val
86+
);
8587
}
8688
}
8789

types/uint48x2.sol

+15-1
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,18 @@ function equal(uint48x2 self, uint48x2 other) pure returns (bool) {
7676
return uint48x2.unwrap(self) == uint48x2.unwrap(other);
7777
}
7878

79-
using {hi, lo, inc, dec, incHi, incLo, decHi, decLo, setLo, sum, clearHi, clearLo, equal as ==} for uint48x2 global;
79+
using {
80+
hi,
81+
lo,
82+
inc,
83+
dec,
84+
incHi,
85+
incLo,
86+
decHi,
87+
decLo,
88+
setLo,
89+
sum,
90+
clearHi,
91+
clearLo,
92+
equal as ==
93+
} for uint48x2 global;

zksync/IZkSync.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ function undoL1ToL2Alias(address l2Address) pure returns (address l1Address) {
3838
bytes32 constant CREATE_PREFIX = 0x63bae3a9951d38e8a3fbb7b70909afc1200610fc5bc55ade242f815974674f23;
3939

4040
function computeCreateAddress(address deployer, uint256 nonce) pure returns (address) {
41-
bytes32 hash = keccak256(bytes.concat(CREATE_PREFIX, bytes32(uint256(uint160(deployer))), bytes32(nonce)));
41+
bytes32 hash =
42+
keccak256(bytes.concat(CREATE_PREFIX, bytes32(uint256(uint160(deployer))), bytes32(nonce)));
4243
return address(uint160(uint256(hash)));
4344
}
4445

zksync/L2Log.sol

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ struct L2Log {
2525

2626
type L2LogLocator is uint256;
2727

28-
function L2LogLocatorFrom(uint256 _batchNumber, uint256 _messageIndex, uint256 _txNumber) pure returns (L2LogLocator) {
28+
function L2LogLocatorFrom(uint256 _batchNumber, uint256 _messageIndex, uint256 _txNumber)
29+
pure
30+
returns (L2LogLocator)
31+
{
2932
return L2LogLocator.wrap(_batchNumber << 128 | _messageIndex << 16 | _txNumber);
3033
}
3134

zksync/test/L2Log.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
pragma solidity ^0.8.20;
44

5-
import {Test} from "forge-std/Test.sol";
65
import {L2LogLocator, L2LogLocatorFrom} from "../L2Log.sol";
6+
import {Test} from "forge-std/Test.sol";
77

88
contract L2LogLocatorTest is Test {
99
function testAccessors() external pure {

0 commit comments

Comments
 (0)