rmrk-team / rmrk-substrate

[WIP] RMRK Substrate pallets
https://rmrk.app
Other
74 stars 36 forks source link

Add TransferHooks, Budget fix and upgrade to Polkadot v0.9.33 #256

Closed HashWarlock closed 1 year ago

HashWarlock commented 1 year ago

Description

TransferHooks implementation

For implementations downstream of the RMRK pallet there needs to be an ability to add custom logic in the case that there are multiple pallets using the RMRK NFT pallet, but want to keep the business logic mutually exclusive. This implementation allows for a trait called TransferHooks to be implemented with 2 functions pre_check and post_transfer that default to true when not implemented.

Budget trait fix

There are 2 problems with the current Budget trait:

NFTs are currently allowed to mint and send NFTs to a parent NFT that can meet up to the threshold of NestingBudget::get() + 1. This allows for NFTs queries like lookup_root_owner to return errors like TooManyRecursions. Having this error is okay, but the NFTs should be prevented from being minted to or sent to a parent NFT if the Budget threshold is met.

Currently the code will do a calculation on functions like burn_nft and this will perform an arithmetic subtraction at the end of the function, but this should be added as a field in the Value type & implement a function from Budget to get the budget that has been consumed and budget that is left.

Targets

HashWarlock commented 1 year ago

I'm gonna create another PR to update to polkadot-v0.9.34 with the benchmarking changes. We can close this one afterwards.

HashWarlock commented 1 year ago

Closing in favor of #259