배포된 클라이언트 : https://d3t5y0jgzx6lw2.cloudfront.net/
깃헙 리포 : https://github.com/codestates-beb/beb-07-second-EWE
1. 로컬에서 원격지의 코드를 당겨온다.
2. 도커 이미지를 로컬에서 빌드한다.
3. 도커 이미지를 허브에 푸쉬
4. aws 콘솔에서 푸쉬된 이미지를 받아와서 서버를 재시작한다.
조금만 코드 규모가 커지니 타입스크립트의 필요성을 절실히 느낀다.
sameSite:none
을 적용해야하고, 이를 위해서는 secure:true
옵션을 쿠키에 줘야하므로 api 서버를 https 프로토콜로 제공해주어야 했다.// this script migrates EWENFT
const EWENFT = artifacts.require('EWENFT');
const EWEToken = artifacts.require('EWEToken');
module.exports = async function (deployer, network, accounts) {
await deployer.deploy(EWENFT);
const contract = await EWENFT.deployed();
const token = await EWEToken.deployed();
await contract.setToken(token.address);
// some predefined mint logics
await contract.mintNFT(accounts[0], { from: accounts[0] });
await contract.mintNFT(accounts[0], { from: accounts[0] });
await contract.mintNFT(accounts[0], { from: accounts[0] });
await contract.mintNFT(accounts[0], { from: accounts[0] });
await contract.mintNFT(accounts[0], { from: accounts[0] });
await contract.mintNFT(accounts[0], { from: accounts[0] });
await contract.mintNFT(accounts[0], { from: accounts[0] });
await contract.mintNFT(accounts[0], { from: accounts[0] });
await contract.mintNFT(accounts[0], { from: accounts[0] });
await contract.mintNFT(accounts[0], { from: accounts[0] });
const tokenId = await contract.getTokenId();
console.log({ tokenId });
if (tokenId.toString() !== '10') throw new Error('token id should be 10');
};
it('should not be able to transferFrom when sender do not enough token', async () => {
const account0BalanceInitial = await token.balanceOf(accounts[0]);
const val = 20;
const approveResult = await token.approve(accounts[1], val, {
from: accounts[0],
});
const allowanceVal = await token.allowance(accounts[0], accounts[1]);
assert.strictEqual(allowanceVal.toString(), val.toString());
await truffleAssert.fails(
token.transferFrom(accounts[0], accounts[2], 21, {
from: accounts[1],
}),
);
transferFromForNFT
메서드를 추가해서 erc721컨트랙트 내에서는 해당 함수를 활용했다.// 기존함수
function transferFrom(
address sender,
address recipient,
uint256 amount
) external virtual override returns (bool) {
_transfer(sender, recipient, amount);
emit Transfer(msg.sender, sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][msg.sender]; // trouble here
require(
currentAllowance >= amount,
'ERC20: transfer amount exceeds allowance'
);
_approve(sender, msg.sender, currentAllowance, currentAllowance - amount); // potential bug
return true;
}
// 새로 작성한 함수
function transferFromForNFT(
address sender,
address recipient,
uint256 amount
) external virtual returns (bool) {
_transfer(sender, recipient, amount);
emit Transfer(msg.sender, sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][recipient]; // fixed like this
require(
currentAllowance >= amount,
'ERC20: transfer amount exceeds allowance'
);
_approve(sender, recipient, currentAllowance, currentAllowance - amount); // fixed like this
return true;
}
클라이언트 css 라이브러리 사용한다는 것은 동감합니다. 사실 이번에는 팀원이 익숙하지 않다는 이유로 바닐라 css를 사용하기로 했는데 아마 이번처럼 생각보다 규모가 커지는 프로젝트에서는 효율적인 방법이 있다는 것을 공부해 가셨을 거라 생각되어요.