Skip to content

Commit

Permalink
πŸ—‘οΈ πŸ‘·πŸ» Remove all .toBytes functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyrharper committed Feb 26, 2024
1 parent 915e09d commit f3defd2
Show file tree
Hide file tree
Showing 36 changed files with 12 additions and 215 deletions.
5 changes: 0 additions & 5 deletions src/Uint128/BaseQuantoPerUSDUint128/Casting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ function wrap(uint128 x) pure returns (BaseQuantoPerUSDUint128 result) {
function unwrap(BaseQuantoPerUSDUint128 x) pure returns (uint128 result) {
result = BaseQuantoPerUSDUint128.unwrap(x);
}

/// @notice Converts a BaseQuantoPerUSDUint128 number into bytes32.
function toBytes32(BaseQuantoPerUSDUint128 x) pure returns (bytes32 result) {
result = bytes32(uint256(unwrap(x)));
}
3 changes: 1 addition & 2 deletions src/Uint128/BaseQuantoPerUSDUint128/ValueType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ type BaseQuantoPerUSDUint128 is uint128;
//////////////////////////////////////////////////////////////*/

using {
Casting.unwrap,
Casting.toBytes32
Casting.unwrap
} for BaseQuantoPerUSDUint128 global;

/*//////////////////////////////////////////////////////////////
Expand Down
5 changes: 0 additions & 5 deletions src/Uint128/BaseUint128/Casting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ function wrap(uint128 x) pure returns (BaseUint128 result) {
function unwrap(BaseUint128 x) pure returns (uint128 result) {
result = BaseUint128.unwrap(x);
}

/// @notice Converts a BaseUint128 number into bytes32.
function toBytes32(BaseUint128 x) pure returns (bytes32 result) {
result = bytes32(uint256(unwrap(x)));
}
2 changes: 1 addition & 1 deletion src/Uint128/BaseUint128/ValueType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type BaseUint128 is uint128;
//////////////////////////////////////////////////////////////*/

using {
Casting.unwrap, Casting.toBytes32
Casting.unwrap
} for BaseUint128 global;

/*//////////////////////////////////////////////////////////////
Expand Down
5 changes: 0 additions & 5 deletions src/Uint128/QuantoUint128/Casting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ function wrap(uint128 x) pure returns (QuantoUint128 result) {
function unwrap(QuantoUint128 x) pure returns (uint128 result) {
result = QuantoUint128.unwrap(x);
}

/// @notice Converts a QuantoUint128 number into bytes32.
function toBytes32(QuantoUint128 x) pure returns (bytes32 result) {
result = bytes32(uint256(unwrap(x)));
}
3 changes: 1 addition & 2 deletions src/Uint128/QuantoUint128/ValueType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ type QuantoUint128 is uint128;
//////////////////////////////////////////////////////////////*/

using {
Casting.unwrap,
Casting.toBytes32
Casting.unwrap
} for QuantoUint128 global;

/*//////////////////////////////////////////////////////////////
Expand Down
5 changes: 0 additions & 5 deletions src/Uint128/USDPerBaseUint128/Casting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,3 @@ function wrap(uint128 x) pure returns (USDPerBaseUint128 result) {
function unwrap(USDPerBaseUint128 x) pure returns (uint128 result) {
result = USDPerBaseUint128.unwrap(x);
}

/// @notice Converts a USDPerBaseUint128 number into bytes32.
function toBytes32(USDPerBaseUint128 x) pure returns (bytes32 result) {
result = bytes32(uint256(unwrap(x)));
}
3 changes: 1 addition & 2 deletions src/Uint128/USDPerBaseUint128/ValueType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ type USDPerBaseUint128 is uint128;
//////////////////////////////////////////////////////////////*/

using {
Casting.unwrap,
Casting.toBytes32
Casting.unwrap
} for USDPerBaseUint128 global;

/*//////////////////////////////////////////////////////////////
Expand Down
5 changes: 0 additions & 5 deletions src/Uint128/USDPerQuantoUint128/Casting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ function wrap(uint128 x) pure returns (USDPerQuantoUint128 result) {
function unwrap(USDPerQuantoUint128 x) pure returns (uint128 result) {
result = USDPerQuantoUint128.unwrap(x);
}

/// @notice Converts a USDPerQuantoUint128 number into bytes32.
function toBytes32(USDPerQuantoUint128 x) pure returns (bytes32 result) {
result = bytes32(uint256(unwrap(x)));
}
3 changes: 1 addition & 2 deletions src/Uint128/USDPerQuantoUint128/ValueType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ type USDPerQuantoUint128 is uint128;
//////////////////////////////////////////////////////////////*/

using {
Casting.unwrap,
Casting.toBytes32
Casting.unwrap
} for USDPerQuantoUint128 global;

/*//////////////////////////////////////////////////////////////
Expand Down
5 changes: 0 additions & 5 deletions src/Uint128/USDUint128/Casting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ function wrap(uint128 x) pure returns (USDUint128 result) {
function unwrap(USDUint128 x) pure returns (uint128 result) {
result = USDUint128.unwrap(x);
}

/// @notice Converts a USDUint128 number into bytes32.
function toBytes32(USDUint128 x) pure returns (bytes32 result) {
result = bytes32(uint256(unwrap(x)));
}
2 changes: 1 addition & 1 deletion src/Uint128/USDUint128/ValueType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type USDUint128 is uint128;
//////////////////////////////////////////////////////////////*/

using {
Casting.unwrap, Casting.toBytes32
Casting.unwrap
} for USDUint128 global;

/*//////////////////////////////////////////////////////////////
Expand Down
5 changes: 0 additions & 5 deletions src/Uint256/BaseQuantoPerUSDUint256/Casting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ function wrap(uint256 x) pure returns (BaseQuantoPerUSDUint256 result) {
function unwrap(BaseQuantoPerUSDUint256 x) pure returns (uint256 result) {
result = BaseQuantoPerUSDUint256.unwrap(x);
}

/// @notice Converts a BaseQuantoPerUSDUint256 number into bytes32.
function toBytes32(BaseQuantoPerUSDUint256 x) pure returns (bytes32 result) {
result = bytes32(unwrap(x));
}
3 changes: 1 addition & 2 deletions src/Uint256/BaseQuantoPerUSDUint256/ValueType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ type BaseQuantoPerUSDUint256 is uint256;
//////////////////////////////////////////////////////////////*/

using {
Casting.unwrap,
Casting.toBytes32
Casting.unwrap
} for BaseQuantoPerUSDUint256 global;

/*//////////////////////////////////////////////////////////////
Expand Down
5 changes: 0 additions & 5 deletions src/Uint256/BaseUint256/Casting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ function wrap(uint256 x) pure returns (BaseUint256 result) {
function unwrap(BaseUint256 x) pure returns (uint256 result) {
result = BaseUint256.unwrap(x);
}

/// @notice Converts a BaseUint256 number into bytes32.
function toBytes32(BaseUint256 x) pure returns (bytes32 result) {
result = bytes32(unwrap(x));
}
3 changes: 1 addition & 2 deletions src/Uint256/BaseUint256/ValueType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ type BaseUint256 is uint256;
//////////////////////////////////////////////////////////////*/

using {
Casting.unwrap,
Casting.toBytes32
Casting.unwrap
} for BaseUint256 global;

/*//////////////////////////////////////////////////////////////
Expand Down
6 changes: 0 additions & 6 deletions src/Uint256/QuantoUint256/Casting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,3 @@ function wrap(uint256 x) pure returns (QuantoUint256 result) {
function unwrap(QuantoUint256 x) pure returns (uint256 result) {
result = QuantoUint256.unwrap(x);
}


/// @notice Converts a QuantoUint256 number into bytes32.
function toBytes32(QuantoUint256 x) pure returns (bytes32 result) {
result = bytes32(unwrap(x));
}
3 changes: 1 addition & 2 deletions src/Uint256/QuantoUint256/ValueType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ type QuantoUint256 is uint256;
//////////////////////////////////////////////////////////////*/

using {
Casting.unwrap,
Casting.toBytes32
Casting.unwrap
} for QuantoUint256 global;

/*//////////////////////////////////////////////////////////////
Expand Down
5 changes: 0 additions & 5 deletions src/Uint256/USDPerBaseUint256/Casting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ function wrap(uint256 x) pure returns (USDPerBaseUint256 result) {
function unwrap(USDPerBaseUint256 x) pure returns (uint256 result) {
result = USDPerBaseUint256.unwrap(x);
}

/// @notice Converts a USDPerBaseUint256 number into bytes32.
function toBytes32(USDPerBaseUint256 x) pure returns (bytes32 result) {
result = bytes32(unwrap(x));
}
3 changes: 1 addition & 2 deletions src/Uint256/USDPerBaseUint256/ValueType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ type USDPerBaseUint256 is uint256;
//////////////////////////////////////////////////////////////*/

using {
Casting.unwrap,
Casting.toBytes32
Casting.unwrap
} for USDPerBaseUint256 global;

/*//////////////////////////////////////////////////////////////
Expand Down
5 changes: 0 additions & 5 deletions src/Uint256/USDPerQuantoUint256/Casting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ function wrap(uint256 x) pure returns (USDPerQuantoUint256 result) {
function unwrap(USDPerQuantoUint256 x) pure returns (uint256 result) {
result = USDPerQuantoUint256.unwrap(x);
}

/// @notice Converts a USDPerQuantoUint256 number into bytes32.
function toBytes32(USDPerQuantoUint256 x) pure returns (bytes32 result) {
result = bytes32(unwrap(x));
}
3 changes: 1 addition & 2 deletions src/Uint256/USDPerQuantoUint256/ValueType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ type USDPerQuantoUint256 is uint256;
//////////////////////////////////////////////////////////////*/

using {
Casting.unwrap,
Casting.toBytes32
Casting.unwrap
} for USDPerQuantoUint256 global;

/*//////////////////////////////////////////////////////////////
Expand Down
5 changes: 0 additions & 5 deletions src/Uint256/USDUint256/Casting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ function wrap(uint256 x) pure returns (USDUint256 result) {
function unwrap(USDUint256 x) pure returns (uint256 result) {
result = USDUint256.unwrap(x);
}

/// @notice Converts a USDUint256 number into bytes32.
function toBytes32(USDUint256 x) pure returns (bytes32 result) {
result = bytes32(unwrap(x));
}
3 changes: 1 addition & 2 deletions src/Uint256/USDUint256/ValueType.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ type USDUint256 is uint256;
//////////////////////////////////////////////////////////////*/

using {
Casting.unwrap,
Casting.toBytes32
Casting.unwrap
} for USDUint256 global;

/*//////////////////////////////////////////////////////////////
Expand Down
11 changes: 0 additions & 11 deletions test/Uint128/BaseQuantoPerUSDUint128.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,4 @@ contract BaseQuantoPerUSDUint128Test is Test {
assertEq(result.unwrap(), z);
}
}

function testBaseQuantoPerUSDUint128ToBytes32() public {
uint128 x = type(uint128).max;
bytes32 result = BaseQuantoPerUSDUint128.wrap(x).toBytes32();
assertEq(result, bytes32(uint256(x)));
}

function testBaseQuantoPerUSDUint128ToBytes32Fuzz(uint128 x) public {
bytes32 result = BaseQuantoPerUSDUint128.wrap(x).toBytes32();
assertEq(result, bytes32(uint256(x)));
}
}
11 changes: 0 additions & 11 deletions test/Uint128/BaseUint128.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,4 @@ contract BaseUint128Test is Test {
assertEq(result.unwrap(), z);
}
}

function testBaseUint128ToBytes32() public {
uint128 x = type(uint128).max;
bytes32 result = BaseUint128.wrap(x).toBytes32();
assertEq(result, bytes32(uint256(x)));
}

function testBaseUint128ToBytes32Fuzz(uint128 x) public {
bytes32 result = BaseUint128.wrap(x).toBytes32();
assertEq(result, bytes32(uint256(x)));
}
}
11 changes: 0 additions & 11 deletions test/Uint128/QuantoUint128.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,4 @@ contract QuantoUint128Test is Test {
assertEq(result.unwrap(), z);
}
}

function testQuantoUint128ToBytes32() public {
uint128 x = type(uint128).max;
bytes32 result = QuantoUint128.wrap(x).toBytes32();
assertEq(result, bytes32(uint256(x)));
}

function testQuantoUint128ToBytes32Fuzz(uint128 x) public {
bytes32 result = QuantoUint128.wrap(x).toBytes32();
assertEq(result, bytes32(uint256(x)));
}
}
11 changes: 0 additions & 11 deletions test/Uint128/USDPerBaseUint128.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,4 @@ contract USDPerBaseUint128Test is Test {
assertEq(result.unwrap(), z);
}
}

function testUSDPerBaseUint128ToBytes32() public {
uint128 x = type(uint128).max;
bytes32 result = USDPerBaseUint128.wrap(x).toBytes32();
assertEq(result, bytes32(uint256(x)));
}

function testUSDPerBaseUint128ToBytes32Fuzz(uint128 x) public {
bytes32 result = USDPerBaseUint128.wrap(x).toBytes32();
assertEq(result, bytes32(uint256(x)));
}
}
11 changes: 0 additions & 11 deletions test/Uint128/USDPerQuantoUint128.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,4 @@ contract USDPerQuantoUint128Test is Test {
assertEq(result.unwrap(), z);
}
}

function testUSDPerQuantoUint128ToBytes32() public {
uint128 x = type(uint128).max;
bytes32 result = USDPerQuantoUint128.wrap(x).toBytes32();
assertEq(result, bytes32(uint256(x)));
}

function testUSDPerQuantoUint128ToBytes32Fuzz(uint128 x) public {
bytes32 result = USDPerQuantoUint128.wrap(x).toBytes32();
assertEq(result, bytes32(uint256(x)));
}
}
11 changes: 0 additions & 11 deletions test/Uint128/USDUint128.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,4 @@ contract USDUint128Test is Test {
assertEq(result.unwrap(), z);
}
}

function testUSDUint128ToBytes32() public {
uint128 x = type(uint128).max;
bytes32 result = USDUint128.wrap(x).toBytes32();
assertEq(result, bytes32(uint256(x)));
}

function testUSDUint128ToBytes32Fuzz(uint128 x) public {
bytes32 result = USDUint128.wrap(x).toBytes32();
assertEq(result, bytes32(uint256(x)));
}
}
11 changes: 0 additions & 11 deletions test/Uint256/BaseQuantoPerUSDUint256.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,4 @@ contract BaseQuantoPerUSDUint256Test is Test {
assertEq(result.unwrap(), z);
}
}

function testBaseQuantoPerUSDUint256ToBytes32() public {
uint256 x = type(uint256).max;
bytes32 result = BaseQuantoPerUSDUint256.wrap(x).toBytes32();
assertEq(result, bytes32(x));
}

function testBaseQuantoPerUSDUint256ToBytes32Fuzz(uint256 x) public {
bytes32 result = BaseQuantoPerUSDUint256.wrap(x).toBytes32();
assertEq(result, bytes32(x));
}
}
11 changes: 0 additions & 11 deletions test/Uint256/BaseUint256.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,4 @@ contract BaseUint256Test is Test {
assertEq(result.unwrap(), z);
}
}

function testBaseUint256ToBytes32() public {
uint256 x = type(uint256).max;
bytes32 result = BaseUint256.wrap(x).toBytes32();
assertEq(result, bytes32(x));
}

function testBaseUint256ToBytes32Fuzz(uint256 x) public {
bytes32 result = BaseUint256.wrap(x).toBytes32();
assertEq(result, bytes32(x));
}
}
11 changes: 0 additions & 11 deletions test/Uint256/QuantoUint256.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,4 @@ contract QuantoUint256Test is Test {
assertEq(result.unwrap(), z);
}
}

function testQuantoUint256ToBytes32() public {
uint256 x = type(uint256).max;
bytes32 result = QuantoUint256.wrap(x).toBytes32();
assertEq(result, bytes32(x));
}

function testQuantoUint256ToBytes32Fuzz(uint256 x) public {
bytes32 result = QuantoUint256.wrap(x).toBytes32();
assertEq(result, bytes32(x));
}
}
11 changes: 0 additions & 11 deletions test/Uint256/USDPerBaseUint256.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,4 @@ contract USDPerBaseUint256Test is Test {
assertEq(result.unwrap(), z);
}
}

function testUSDPerBaseUint256ToBytes32() public {
uint256 x = type(uint256).max;
bytes32 result = USDPerBaseUint256.wrap(x).toBytes32();
assertEq(result, bytes32(x));
}

function testUSDPerBaseUint256ToBytes32Fuzz(uint256 x) public {
bytes32 result = USDPerBaseUint256.wrap(x).toBytes32();
assertEq(result, bytes32(x));
}
}
Loading

0 comments on commit f3defd2

Please sign in to comment.