Open artman325 opened 2 years ago
Greg wrote
So you can inherit across contracts
Here is a real example:
Gregory Magarshak, [29.03.2022 18:14]
pooh is contract CA series A
piglet is contract CC series B
now we make cartoon about both and it is contract CC series C
Now I am saying we pick some id which was not yet sold in any of these series
A0087afc000000
B0087afc000000
C0087afc000000
They are different tokenIds on different contracts
But they may be on same contract
Transferring can only be done of C0087afc000000 because NFTremix would revert if you try to transfer a tokenId of a series that has children.
And if you transfer C0087afc000000 it will DELEGATECALL transfer hook in the NFTremix and that in turn will transfer the other two in other contracts. Thats all !
seems there are some things
You are supposed to DELEGATECALL from NFT to NFTremix and thrn DELEGATECALL again from NFTremix to other NFT. So since everything is DELEGATECALL, it should work.
The only thing is that the memory layout should be compatible across the two contracts since it is delegatecall
On Tue, Mar 29, 2022 at 2:59 PM artman325 @.***> wrote:
Greg wrote
So you can inherit across contracts
Here is a real example:
Gregory Magarshak, [29.03.2022 18:14] pooh is contract CA series A piglet is contract CC series B now we make cartoon about both and it is contract CC series C
Now I am saying we pick some id which was not yet sold in any of these series
A0087afc000000 B0087afc000000 C0087afc000000
They are different tokenIds on different contracts But they may be on same contract
Transferring can only be done of C0087afc000000 because NFTremix would revert if you try to transfer a tokenId of a series that has children.
And if you transfer C0087afc000000 it will DELEGATECALL transfer hook in the NFTremix and that in turn will transfer the other two in other contracts. Thats all !
seems there are some things
- if user will make first buy(primary sell) then contract initiate two buy's transactions: pooh CA and piglet in CC. if any of them will not revert(nft can be already exists !!!). And after that we try to buy cartton token CC series C.
- big problem will happens via transfer C0087afc000000. if try to delegatecall in transfer method contract C then context will be CC but not User. so it can not be applicable for ANY external contract.
— Reply to this email directly, view it on GitHub https://github.com/Intercoin/NFTremixContract/issues/1#issuecomment-1082260797, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACV7PZQGZ5EWSCYRZEIFXLVCNHKVANCNFSM5PEWLIEQ . You are receiving this because you were assigned.Message ID: @.***>
-- Sincerely, Greg Magarshak Qbix Inc.
(To set up a meeting: https://calendly.com/qbix/meeting)
[ ] 1. Make additional contract called “NFTremix”, which will work with NonFungibleTokenContract. Define TreeInfo struct, besides SeriesInfo to have
uint16[] parents
anduint16[] children
. Probably makes sense to use PackedArray? Do not allow anyone except contract owner to set parents and children of TreeInfo (unlike SeriesInfo).[ ] 2. We will make this external contract to be the
owner
of regular NFT contract, and also thecostManager
of it. We will use_accountForOperation
mechanism. So for example, if someone tries to change the currency of a SeriesInfo, the costManager will check the parent of this seriesId, and if it exists, then revert with error "NFTremix: can't change currency of child series". This is gas-inefficient, and later we may want to deploy a combined contract, but for now just make external one that works with existing NFT contract.[ ] 3. it will have setSeriesInfo(uint16 seriesId, struct SeriesInfo seriesInfo, uint256 signature) and it will check signature, which signs payload of first two parameters. It will have method children(uint16 seriesId), parents(uint16 seriesId), fork(uint16 seriesId), and _checkSignature(). When calling
fork(parents)
and signature is valid, seriesInfo has parents filled, as well asmaxSupply
and children is empty.[ ] 4. Forked series starts empty, and the
currency
to buy things with would match parent (and cannot be changed, revert if changed). When calculating price of token from series, check parents in SeriesInfo and add prices. Calling to buy() one token from a forked series, there is a hook. you also have to buy one token from each parent series. (It would be with same tokenIndex as the one being bought, but different series, meaning if you buy AX, then it would buy BX and CX if B and C were parents of A). If no parents were defined on SeriesInfo, then behave as now. Make method getPrice(tokenId) which[ ] 5. When paying author for first sale during buy(), or for disbursing commissions, check parents in SeriesInfo and add prices. However, do not check parents for transfer() in secondary sales or transfers, only for buy and commissions. (Note that OpenSea doesn't support such NFTremix commissions yet, so our commission mechanism can prevent transfer until they are paid.)