Skip to content

Commit

Permalink
Merge pull request #13 from wbydo/release
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
wbydo committed Apr 29, 2022
2 parents 5e656b8 + e804a8f commit bfd5023
Show file tree
Hide file tree
Showing 12 changed files with 2,818 additions and 693 deletions.
10 changes: 0 additions & 10 deletions contract/contracts/TestToken.sol

This file was deleted.

24 changes: 24 additions & 0 deletions contract/contracts/WbydoProfileNft.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract WbydoProfileNft is ERC721Enumerable, Ownable {
string private _BASE_URI;

constructor(string memory __baseURI)
ERC721("wbydo Profile Token", "wbydo")
Ownable()
{
_BASE_URI = __baseURI;
}

function _baseURI() internal view override(ERC721) returns (string memory) {
return _BASE_URI;
}

function mint(uint256 tokenId) public onlyOwner {
_safeMint(_msgSender(), tokenId);
}
}
2 changes: 1 addition & 1 deletion contract/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dotenv.config();

const config: HardhatUserConfig = {
solidity: {
version: '0.8.9',
version: '0.8.13',
settings: {
optimizer: {
enabled: true,
Expand Down
1 change: 0 additions & 1 deletion contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"@types/node": "^17.0.30",
"chai": "^4.3.6",
"dotenv": "^16.0.0",
"ethereum-waffle": "^3.4.4",
"ethers": "^5.6.3",
"hardhat": "^2.9.3",
"hardhat-watcher": "^2.1.1",
Expand Down
37 changes: 0 additions & 37 deletions contract/tests/TestToken.test.ts

This file was deleted.

61 changes: 61 additions & 0 deletions contract/tests/WbydoProfileNft.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { expect } from 'chai';
import { waffle, ethers } from 'hardhat';

import { BigNumber } from 'ethers';

const { loadFixture } = waffle;

const baseURI = 'https://example.com/metadata/';

describe('WbydoProfileNft', () => {
const fixture = async () => {
const [owner, other] = await ethers.getSigners();

const nft = await ethers
.getContractFactory('WbydoProfileNft')
.then((factory) => {
return factory.deploy(baseURI);
})
.then((contracts) => {
return contracts.deployed();
});

return { owner, nft, other };
};

it('deploy', async () => {
await loadFixture(fixture);
});

describe('TokenURI', async () => {
it('tokenURIが期待通りであること', async () => {
const { nft, owner } = await loadFixture(fixture);
const connectedNft = nft.connect(owner);
await connectedNft.mint(0);
expect(await connectedNft.tokenURI(0)).to.be.equal(
'https://example.com/metadata/0'
);
});
});

describe('mint', async () => {
it('owner以外が実行するとrevertすること', async () => {
const { nft, other } = await loadFixture(fixture);
await expect(nft.connect(other).mint(999)).to.be.revertedWith(
'Ownable: caller is not the owner'
);
});

it('mint関数実行後にnftを所有していること', async () => {
const { nft, owner } = await loadFixture(fixture);
const connectedNft = nft.connect(owner);
await connectedNft.mint(555);
expect(await connectedNft.ownerOf(555)).to.be.equal(owner.address);

await connectedNft.mint(666);
expect(await connectedNft.ownerOf(666)).to.be.equal(owner.address);

expect(await connectedNft.balanceOf(owner.address)).to.be.equal(2);
});
});
});
File renamed without changes
File renamed without changes
5 changes: 5 additions & 0 deletions docs/metadata/0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "wbydo",
"description": "https://wbydo.com",
"image": "https://wbydo.github.io/profile-nft/img/000.png"
}
5 changes: 5 additions & 0 deletions docs/metadata/1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "tackuhm",
"description": "https://twitter.com/tackuhm",
"image": "https://wbydo.github.io/profile-nft/img/001.png"
}

0 comments on commit bfd5023

Please sign in to comment.