-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add traits and function implementations for missing extensions #14
base: main
Are you sure you want to change the base?
Conversation
Add function burn_from to PSP22 trait Add "to" param to the mint function Add .idea directory to the .gitignore file Signed-off-by: Maciek Malik <[email protected]>
…tions Signed-off-by: Maciek Malik <[email protected]>
Signed-off-by: Maciek Malik <[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.
Hi, thanks for contribution. However, I have some doubts about this PR:
- This repo is meant to provide a simple, minimal implementation of the standard. Traits
Ownable
andPSP22Pausable
are not part of PSP22 standard. What is the point of adding these traits here, without implementation? - I don't understand
PSP22Wrapper
trait, it seems to be just an alias fortransfer
andtransfer_from
. What is it useful for?Also, it introduces some chain related code (cross calling) toPSP22Data
, which is supposed to be an internal data structure with token logic and should stay ink-and-chain agnostic.
I like the refinement of Mintable and Burnable to mimic the interfaces known from Ethereum. Ideally burn
should be removed in favor of burn_from
.
@h4nsu Regarding the second point. This is our attempt on migrating ERC20Wrapper to the ink. We wanted to keep the same functionality as openzeppelin has, so the comment from their repo gives us a summary what it does.
That's why you can see some cross calling in the data.rs. Here we have E2E tests that contain comments for each step |
@@ -267,4 +269,115 @@ impl PSP22Data { | |||
value, | |||
}]) | |||
} | |||
|
|||
/// Burns `value` tokens from `from` account. | |||
pub fn burn_from(&mut self, |
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.
A lot of code in this function replicates fn burn
- the only additional place here is the check and modification of allowances - so I'd change to code to reuse fn burn
(i.e. call it and only add necessary allowances management around it).
Added implementations for missing extensions.
Traits added:
fn pause(&mut self)
fn unpause(&mut self)
fn deposit_for(&mut self, account: AccountId, amount: u128)
fn withdraw_to(&mut self, account: AccountId, amount: u128)
fn owner(&self)
fn renounce_ownership(&mut self)
fn transfer_ownership(&mut self, new_owner: Option<AccountId>)
Traits modified:
fn burn_from(&mut self, account: AccountId, value: u128)
mint
tofn mint(&mut self, to: AccountId, value: u128)
Added error enum -
OwnableError
Added function implementations for:
burn_from
deposit
withdraw
Example lib.rs implementation that contains all extensions enabled can be found here: https://gist.github.com/coredumped7893/38ea06963de8c5034b58a9267be50758
Code is based on this version of the psp22: https://github.com/Smart-Beaver/smart-contracts/tree/main/PSP22