Skip to content

Commit

Permalink
fix: use bytes32 for encoding network
Browse files Browse the repository at this point in the history
  • Loading branch information
TuDo1403 committed Jun 17, 2024
1 parent 2c141ee commit 46822c4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion script/configs/ContractConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ abstract contract ContractConfig is IContractConfig {

for (uint256 i; i < deployments.length; ++i) {
string[] memory s = vm.split(deployments[i].path, "/");
TNetwork network = TNetwork.wrap(bytes20(LibString.packOne(s[s.length - 1])));
TNetwork network = TNetwork.wrap(LibString.packOne(s[s.length - 1]));

string memory exportedAddress;
try vm.readFile(string.concat(deployments[i].path, "/exported_address")) returns (string memory data) {
Expand Down
2 changes: 1 addition & 1 deletion script/configs/RuntimeConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ abstract contract RuntimeConfig is IRuntimeConfig {
_option.disablePrecheck = true;
} else if (args[i].startsWith("network")) {
string memory network = vm.split(args[i], ".")[1];
_option.network = TNetwork.wrap(bytes20(LibString.packOne(network)));
_option.network = TNetwork.wrap(LibString.packOne(network));
} else if (args[i].startsWith("fork-block-number")) {
string memory blockNumber = vm.split(args[i], ".")[1];
_option.forkBlockNumber = vm.parseUint(blockNumber);
Expand Down
4 changes: 2 additions & 2 deletions script/types/TNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { LibString } from "../../dependencies/solady-0.0.206/src/utils/LibString
import { LibSharedAddress } from "../libraries/LibSharedAddress.sol";
import { Vm } from "../../dependencies/forge-std-1.8.2/src/Vm.sol";

type TNetwork is bytes20;
type TNetwork is bytes32;

using LibString for bytes32;

using { chainAlias, eq as ==, neq as !=, env, dir } for TNetwork global;

function chainAlias(TNetwork network) pure returns (string memory) {
return bytes32(TNetwork.unwrap(network)).unpackOne();
return TNetwork.unwrap(network).unpackOne();
}

function env(TNetwork network) pure returns (string memory) {
Expand Down
2 changes: 1 addition & 1 deletion script/utils/DefaultNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function explorer(DefaultNetwork network) pure returns (string memory link) {
}

function key(DefaultNetwork network) pure returns (TNetwork) {
return TNetwork.wrap(bytes20(LibString.packOne(chainAlias(network))));
return TNetwork.wrap(LibString.packOne(chainAlias(network)));
}

function chainAlias(DefaultNetwork network) pure returns (string memory) {
Expand Down

0 comments on commit 46822c4

Please sign in to comment.