Skip to content

AINFTize contract template, integration test, documentation #3

Open
orth0gonal wants to merge 40 commits into
developfrom
feature/jakepyo/integration-test
Open

AINFTize contract template, integration test, documentation #3
orth0gonal wants to merge 40 commits into
developfrom
feature/jakepyo/integration-test

Conversation

@orth0gonal
Copy link
Copy Markdown
Contributor

@orth0gonal orth0gonal 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를 참조하시면 조금 더 이해하시기 쉽습니다.

@orth0gonal orth0gonal added documentation Improvements or additions to documentation enhancement New feature or request labels Apr 3, 2023
Comment thread contracts/interfaces/IAINFT.sol
Comment thread contracts/interfaces/IAINFT.sol
Comment thread .gitignore
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread package-lock.json
Copy link
Copy Markdown

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.

Comment thread contracts/AINFT721.sol
Comment thread contracts/AINFT721.sol Outdated
Comment thread contracts/AINFT721.sol Outdated
returns (bool)
{
// IERC4906 interface added
return interfaceId == bytes4(0x49064906) || super.supportsInterface(interfaceId);
Copy link
Copy Markdown

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?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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.

Copy link
Copy Markdown

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
Copy Markdown
Contributor Author

@orth0gonal orth0gonal 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
Copy Markdown
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!

Comment thread contracts/AINFTFactory.sol
Comment thread contracts/AINFTFactory.sol Outdated
Comment thread contracts/AINFT721.sol Outdated
Comment thread contracts/AINFT721.sol

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_;
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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!

Copy link
Copy Markdown

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
Copy Markdown
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!

Comment thread contracts/AINFT721.sol Outdated
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);
Copy link
Copy Markdown

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
Copy Markdown
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!

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

constructor() Ownable() {}
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

Give us the PTAL sign when you feel comfortable.

@orth0gonal
Copy link
Copy Markdown
Contributor Author

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