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

AINFTize contract template, integration test, documentation #3

Open
wants to merge 40 commits into
base: develop
Choose a base branch
from

Conversation

jakepyo
Copy link
Contributor

@jakepyo jakepyo commented Apr 3, 2023

Description

  • AINFT를 위한 AINFTize contract template 설계(AINFT721Upgradeable은 future work)
  • hardhat 로컬 환경에서의 integration test script 작성 완료(npx hardhat test test/integrationTest.ts)
  • README, call graph 작성 완료

Need to be Reviewed

  • Upgradeable contract를 제외한 contracts/
  • test/integrationTest.ts
  • README.md의 논리적 결함 & 오탈자

로직이 살짝 복잡한 관계로 smart contract 작성 경험 있는 개발자 분들, AINFTize와 관련있는 개발자 분들 모두 reviewer로 추가하였으니 시간 나시는 분들은 리뷰해 주시면 많은 도움이 될 것 같습니다!(미리 감사합니다!) 자세한 flow는 README의 call graph를 참조하시면 조금 더 이해하시기 쉽습니다.

@jakepyo jakepyo added documentation Improvements or additions to documentation enhancement New feature or request labels Apr 3, 2023
.gitignore Outdated

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use only one. yarn.lock or package-lock.json.

returns (bool)
{
// IERC4906 interface added
return interfaceId == bytes4(0x49064906) || super.supportsInterface(interfaceId);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to distinguish this NFT is AINFT. should we add our own interfaceId on this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we'd better add our own interfaceId. Maybe we have to think deeply about it further, I leave it as future work.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in this quarter plan, the marketplace should be searchable all AINFTs. without own interfaceId or without AINFTFactory's managed list, it would be quite tricky.

Copy link
Contributor Author

@jakepyo jakepyo Apr 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding to marketplace, it would be necessary to distinguish AINFT from other ERC721 NFTs, so our own interfaceId should be set ASAP!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be discussed further in #5 . Thanks!


function setPaymentContract(address paymentPlugin_) public onlyRole(DEFAULT_ADMIN_ROLE) {
require(_msgSender() == tx.origin && _msgSender() != address(0), "Only EOA can set payment contract.");
PAYMENT_PLUGIN = paymentPlugin_;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to check the paymentPlugin_ is already pointed to this contract. (because of the callflows)

  • AINFT721 created
  • AINPayment created (with these AINFT721 address)
  • AINFT721 setPaymentContract (with above)
    • so we can check this in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any desirable way that setPaymentContract can check whether AINPayment is already pointed to this contract?

The first method I've thought was to make connect function inside AINPayment, which calls AINFT721::setPaymentContract(), but it occurs vulnerability that anyone who deploys AINPayment can change the PAYMENT_PLUGIN.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to just add require(paymentPlugin_.isContract()); to check whether paymentPlugin_ is contract address or not. Any good ways are welcomed!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my first glance, I was thinking the way by checking paymentPlugin_.ainft value is same with this contract's address. just value comparision. that's all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be discussed on #4 . Thanks!

constructor(string memory name_, string memory symbol_, bool isCloned_, address originNFT_) ERC721(name_, symbol_) {
if (isCloned_) {
//FIXME: need to use tx.origin?
_grantRole(DEFAULT_ADMIN_ROLE, tx.origin);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's different between if(isCloned_) { ... /* HERE */ ... } else { ... /* THERE */ ... }.
what's expected tx.origin value whether isCloned_ on/off?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh.. it's weird. I don't know why I use if condition. I'll remove it thanks!

contracts/AINFT721.sol Outdated Show resolved Hide resolved
test/IntegrationTest.ts Outdated Show resolved Hide resolved
test/IntegrationTest.ts Show resolved Hide resolved
contracts/AINFTFactory.sol Outdated Show resolved Hide resolved
test/IntegrationTest.ts Outdated Show resolved Hide resolved
test/IntegrationTest.ts Outdated Show resolved Hide resolved
test/IntegrationTest.ts Outdated Show resolved Hide resolved
test/IntegrationTest.ts Outdated Show resolved Hide resolved
test/IntegrationTest.ts Outdated Show resolved Hide resolved
event CloneAINFT721(address indexed originalNFT, address indexed clonedAINFT);
event CreateAINFT721(address indexed createdAINFT);

constructor() Ownable() {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we limit the callable only for contract owner?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a complex problem related to the existence of AINFTFactory contract itself. Let's discuss on #6 !

@minho-comcom-ai
Copy link

Give us the PTAL sign when you feel comfortable.

@jakepyo
Copy link
Contributor Author

jakepyo commented Apr 13, 2023

Give us the PTAL sign when you feel comfortable.

Sorry for the late update, I'm in the process of writing entire design of contract moving on "our Design Doc" format due to a few feedbacks such as hard to understand, should precede design review, etc. I will arrange a design review meeting after the draft finishes ASAP.(Possibly the next week). Our discussion about structure or some issues would be continued on the design meeting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants