-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: add native token support for fungibles api #147
base: main
Are you sure you want to change the base?
Conversation
# This is the 1st commit message: refactor: general # This is the commit message #2: init # This is the commit message #3: begin refactor # This is the commit message #4: refactor: error handling # This is the commit message #5: tests: add error handling tests # This is the commit message #6: WIP # This is the commit message #7: finalise error handling # This is the commit message #8: refactor: easier review
Co-authored-by: Frank Bell <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not able to do a proper review because there is a mix of tightly coupling and lously coupling. There are also todo's in the PR for some of the read state functions which make it hard to get a view on the effect of this feature on the pallet as a whole.
Nevertheless, your work has shown the difficulties of the pallet when not tightly coupling pallet assets and pallet balances. It means we have to benchmark the dispatchables ourselves but more importantly add logic for a secure implementation. For example, transfer
called in the transfer
dispatchable is not checking whether the origin is signed, we have to do this ourselves. In addition, this transfer
function is never called in the transfer_keep_alive
dispatchable that we were using before.
I think it will be easier to separate the two things you started to implement in this PR. This PR should add the native token functionality to the pallet without lously coupling pallet assets and balances. Ideally you rebase off of #150.
In a separate PR we refactor to lously couple the pallets.
@Daanvdplas I am on my way to refactor to avoid the mix of lously couling and tightly coupling. However, // Two-way conversion between asset and currency balances
type AssetToCurrencyBalance: Convert<Self::AssetBalance, BalanceOf<Self>>;
type CurrencyToAssetBalance: Convert<BalanceOf<Self>, Self::AssetBalance>; Which I think is a feasible way to handle the type conversion but it would create more type parameters to the config. EditedAfter playing around with type conversion, I think we should come with a loose coupling approach. There are shared types like |
Please see: #97 (comment) |
Had a look at it again and want to put this here for later reference. There are 3 ways moving forward:
|
5c36b4f
to
6adf1b1
Compare
Remaining TODOs
Asset
instance to multiple asset kinds usingNativeOrWithId
transfer()
transfer_from()
(throwUnsupportedMethod
)approve()
(throwUnsupportedMethod
)increase_allowance()
(throwUnsupportedMethod
)decrease_allowance()
(throwUnsupportedMethod
)transfer()
transfer_from()
(throwUnsupportedMethod
)approve()
(throwUnsupportedMethod
)increase_allowance()
(throwUnsupportedMethod
)decrease_allowance()
(throwUnsupportedMethod
)Concerns
Right now, the pallet is a tight coupled because it needs both pallet-assets and pallet-balances to add the native token to the fungible pallet functionalities.
However, we need create a shared type for the pallet_balances::Balance and pallet_assets::Balance because the BalanceOf is used for parameter like amount in transfer() method. My implementation right now is to use of UnionOf and NativeOrWithId to provide the loose coupling to support type conversion but it would make the Fungibles pallet code mixes between loose coupling and tight coupling.