Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
ltyu committed Mar 26, 2024
1 parent dd3c182 commit 4683604
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 48 deletions.
16 changes: 8 additions & 8 deletions solidity/test/token/HypERC721.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ contract HypERC721Test is HypTokenTest {
);
}

function test_Initialize_revert_ifAlreadyInitialized() public {
function testInitialize_revert_ifAlreadyInitialized() public {
vm.expectRevert("Initializable: contract is already initialized");
hyp721.initialize(
INITIAL_SUPPLY,
Expand All @@ -210,32 +210,32 @@ contract HypERC721Test is HypTokenTest {
);
}

function test_TotalSupply() public {
function testTotalSupply() public {
assertEq(hyp721.balanceOf(address(this)), INITIAL_SUPPLY);
}

function test_OwnerOf() public {
function testOwnerOf() public {
assertEq(hyp721.ownerOf(0), address(this));
}

function test_LocalTransfer() public {
function testLocalTransfer() public {
hyp721.transferFrom(address(this), ALICE, 0);
assertEq(hyp721.balanceOf(address(this)), INITIAL_SUPPLY - 1);
assertEq(hyp721.balanceOf(ALICE), 1);
}

function test_LocalYTransfer_revert_invalidTokenId() public {
function testLocalYTransfer_revert_invalidTokenId() public {
vm.expectRevert("ERC721: invalid token ID");
hyp721.transferFrom(address(this), ALICE, INITIAL_SUPPLY);
}

function test_RemoteTransfer(bool isCollateral) public {
function testRemoteTransfer(bool isCollateral) public {
_deployRemoteToken(isCollateral);
_performRemoteTransfer(25000, 0);
assertEq(hyp721.balanceOf(address(this)), INITIAL_SUPPLY - 1);
}

function test_RemoteTransfer_revert_unowned() public {
function testRemoteTransfer_revert_unowned() public {
hyp721.transferFrom(address(this), BOB, 1);

_deployRemoteToken(false);
Expand All @@ -244,7 +244,7 @@ contract HypERC721Test is HypTokenTest {
assertEq(hyp721.balanceOf(address(this)), INITIAL_SUPPLY - 1);
}

function test_RemoteTransfer_revert_invalidTokenId() public {
function testRemoteTransfer_revert_invalidTokenId() public {
_deployRemoteToken(false);
vm.expectRevert("ERC721: invalid token ID");
_performRemoteTransfer(25000, INITIAL_SUPPLY);
Expand Down
42 changes: 2 additions & 40 deletions typescript/sdk/src/token/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
ERC20__factory,
ERC721EnumerableUpgradeable__factory,
GasRouter,
HypERC721,
HypERC721Collateral,
} from '@hyperlane-xyz/core';
import { objKeys, objMap } from '@hyperlane-xyz/utils';

Expand Down Expand Up @@ -280,12 +278,11 @@ export class HypERC721Deployer extends GasRouterDeployer<
return (
isUriConfig(config) ? TokenType.collateralUri : TokenType.collateral
) as K;
} else if (isSyntheticConfig(config)) {
} else {
// if isSyntheticConfig
return (
isUriConfig(config) ? TokenType.syntheticUri : TokenType.synthetic
) as K;
} else {
return config.type as K;
}
}

Expand Down Expand Up @@ -346,33 +343,6 @@ export class HypERC721Deployer extends GasRouterDeployer<
}
}

// protected async deployCollateral(
// chain: ChainName,
// config: HypERC721CollateralConfig,
// ): Promise<HypERC721Collateral> {
// return this.deployContract(
// chain,
// isUriConfig(config) ? TokenType.collateralUri : TokenType.collateral,
// [config.token, config.mailbox],
// );
// }

// protected async deploySynthetic(
// chain: ChainName,
// config: HypERC721Config,
// ): Promise<HypERC721> {
// const router = await this.deployContract(
// chain,
// isUriConfig(config) ? TokenType.syntheticUri : TokenType.synthetic,
// [config.mailbox],
// );
// await this.multiProvider.handleTx(
// chain,
// router.initialize(config.totalSupply, config.name, config.symbol),
// );
// return router;
// }

router(contracts: HyperlaneContracts<HypERC721Factories>) {
for (const key of objKeys(hypERC721factories)) {
if (contracts[key]) {
Expand All @@ -383,14 +353,6 @@ export class HypERC721Deployer extends GasRouterDeployer<
}

async deployContracts(chain: ChainName, config: HypERC721Config) {
// let router: HypERC721 | HypERC721Collateral;
// if (isCollateralConfig(config)) {
// router = await this.deployCollateral(chain, config);
// } else if (isSyntheticConfig(config)) {
// router = await this.deploySynthetic(chain, config);
// } else {
// throw new Error('Invalid ERC721 token router config');
// }
const { [this.routerContractName(config)]: router } =
await super.deployContracts(chain, config);

Expand Down

0 comments on commit 4683604

Please sign in to comment.