Skip to content

Commit

Permalink
Merge pull request #476 from unchain-tech/feature/polygon-ens-domain/…
Browse files Browse the repository at this point in the history
…remove-console

Feature/Polygon ENS Domain/remove console
  • Loading branch information
yk-saito authored Nov 28, 2023
2 parents 7d84f50 + 2ee7571 commit cbec15a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

```solidity
modifier onlyOwner() {
require(isOwner());
require(isOwner(), "You aren't the owner");
_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ mapping(uint => string) public names;
// コントラクトのどこかに付け加えてください。
function getAllNames() public view returns (string[] memory) {
console.log("Getting all names from contract");
string[] memory allNames = new string[](_tokenIds.current());
for (uint i = 0; i < _tokenIds.current(); i++) {
allNames[i] = names[i];
console.log("Name for token %d is %s", i, allNames[i]);
}
return allNames;
Expand Down Expand Up @@ -169,18 +167,13 @@ describe('ENS-Domain', () => {
deployTextFixture,
);

let txn;

const ownerBeforeBalance = await hre.ethers.provider.getBalance(
owner.address,
);
// スーパーコーダーとしてコントラクトから資金を奪おうとします。
try {
txn = await domainContract.connect(superCoder).withdraw();
await txn.wait();
} catch (error) {
console.log('robber could not withdraw token');
}

await expect(
domainContract.connect(superCoder).withdraw(),
).to.be.revertedWith("You aren't the owner");

const ownerAfterBalance = await hre.ethers.provider.getBalance(
owner.address,
Expand Down Expand Up @@ -225,6 +218,41 @@ describe('ENS-Domain', () => {

```

次に、`Domains`コントラクト内で定義していた`console.log`を削除しましょう。

import文を削除します。

```solidity
// === 下記を削除 ===
import "hardhat/console.sol";
```

constructor関数内の`console.log`を削除します。

```solidity
// === 下記を削除 ===
console.log('%s name service deployed', _tld);
```

`register`関数内の`console.log`を削除します。

```solidity
// === 下記を削除 ===
console.log(
'Registering %s.%s on the contract with tokenID %d',
name,
tld,
newRecordId
);
```

```solidity
// === 下記を削除 ===
console.log('\n--------------------------------------------------------');
console.log('Final tokenURI', finalTokenUri);
console.log('--------------------------------------------------------\n');
```

では下のコマンドを実行することでコントラクトのテストをしていきましょう!

```
Expand All @@ -234,16 +262,18 @@ yarn test
最後に下のような結果がでいれば成功です!

```
✔ Token amount contract has is correct! (4986ms)
robber could not withdraw token
✔ someone not owenr cannot withdraw token (68ms)
Compiled 1 Solidity file successfully
ENS-Domain
✔ Token amount contract has is correct! (1417ms)
✔ someone not owenr cannot withdraw token
✔ contract owner can withdrawl token from conteract!
✔ Domain value is depend on how long it is (38ms)
✔ Domain value is depend on how long it is
4 passing (5s)
4 passing (1s)
✨ Done in 8.83s.
```

### 🙋‍♂️ 質問する
Expand Down

0 comments on commit cbec15a

Please sign in to comment.