-
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: psp22 trait contract example with drink tests #300
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]>
assert_eq!( | ||
last_contract_event(&session).unwrap(), | ||
Created { | ||
id: TOKEN, | ||
creator: account_id_from_slice(&contract), | ||
admin: account_id_from_slice(&contract), | ||
} | ||
.encode() | ||
.as_slice() | ||
); |
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.
This can be improved but not now. Opened an issue: r0gue-io/pop-drink#24
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.
Wouldn't this improve these assertions a lot (deriving debug and partialeq traits under std
feature):
#[ink::event]
#[cfg_attr(feature = "std", derive(Debug, PartialEq))]
pub struct Transfer {
/// The source of the transfer. `None` when minting.
#[ink(topic)]
pub from: Option<AccountId>,
/// The recipient of the transfer. `None` when burning.
#[ink(topic)]
pub to: Option<AccountId>,
/// The amount transferred (or minted/burned).
pub value: u128,
}
Is working in the integration tests for me. This gives much clearer errors.
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.
Pushed some small changes, lgtm now! Thanks for all the hard work!
447f1b4
to
411ff66
Compare
411ff66
to
8c72e2c
Compare
|
||
- **Staking Rewards Program**: This contract can be used to issue rewards in a staking program, where users lock tokens for network security or liquidity. The staking contract calls this PSP22 contract to mint and burn tokens, allowing the staking authority to manage rewards and ensure distribution only to eligible participants. | ||
[ink]: https://use.ink | ||
[substrate]: https://substrate.io |
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.
This is no longer maintained
[erc20]: https://ethereum.org/en/developers/docs/standards/tokens/erc-20/ | ||
[psp22]: https://github.com/inkdevhub/standards/blob/master/PSPs/psp-22.md | ||
[pop-api-fungibles]: https://github.com/r0gue-io/pop-node/tree/main/pop-api/src/v0/fungibles | ||
[pallet-assets]: https://crates.io/crates/pallet-assets |
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.
Are we not trying to prevent the devs to have to learn about pallet assets?
PSP22 is a fungible token standard for WebAssembly smart contracts running on blockchains based on the [Substrate][substrate] framework. It is an equivalent of Ethereum's [ERC-20][erc20]. The definition of the PSP22 standard can be found [here][psp22]. | ||
|
||
This repository contains a simple, minimal implementation of the PSP22 token in [ink!][ink] smart contract programming language (EDSL based on Rust), utilizing the [Pop API Fungibles][pop-api-fungibles] feature. |
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.
Way too much detail, also we don't want to repeat the docs in the pop api about the psp22 contract. Just explain the contract in a simple way :), no need to make it fancy or anything.
"This contract shows a contract that allows interaction and management of a fungible token following the psp22 standard. In this specific contract only the contract owner has a permission to call specific methods. This is because ....
This is only one way of how the fungibles api can be utilised, other ways could be ...
Tests are written with pop drink ... and can be run with cargo test --release
|
||
Be part of our passionate community of Web3 builders. [Join our Telegram](https://t.me/onpopio)! | ||
|
||
Feel free to raise issues if anything is unclear, have ideas or want to contribute to Pop! |
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.
Feel free to raise issues if anything is unclear, have ideas or want to contribute to Pop! | |
Feel free to raise issues if anything is unclear, have ideas or want to contribute to Pop! Examples using the fungibles API are always welcome! |
Description
Example contract for the fungible use case that applies the PSP22 traits from #297. The PR includes:
pop-drink
andpop-sandbox
: https://github.com/r0gue-io/pop-drink