Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/Polygon ENS Domain/remove console #476

Merged
merged 4 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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