Skip to content
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

Implemented the PSP22 via pallet-assets chain extension. #168

Merged
merged 12 commits into from
Aug 27, 2022

Conversation

xgreenx
Copy link
Contributor

@xgreenx xgreenx commented Aug 20, 2022

Implemented the PSP22 via pallet-assets chain extension. Also Metadata, Mintable, and Burnable.
The library provides a default implementation that can be re-used.
Replaced all String with an alias to Vec<u8> to reduce the size of the contracts.

The library provides default implementation that can be re-used.
The change is not fully ready it requires more examples, tests, and documentation.
xgreenx added a commit to xgreenx/chainextension-registry that referenced this pull request Aug 20, 2022
The id of the chain extension is `0x48f6`. It is the first 2 bytes of the `blake2b` hash from the "pallet-assets-chain-extension@v0.1" string.
The [chain extension](https://github.com/Supercolony-net/pallet-assets-chain-extension) created with usage of the [`obce`](https://github.com/Supercolony-net/obce) crate.

The chain extension is not ready for production because it requires some additional changes on the `pallet-assets` side(some operations should be performed by the contract only if the contract is admin).
But it is a matter of time, so I think we can register it and fix it with minor patches.

Added support of the extension into [substrate-contract-node](paritytech/substrate-contracts-node#146) and into [OpenBrush](Supercolony-net/openbrush-contracts#168).
@github-actions
Copy link

github-actions bot commented Aug 21, 2022

Contract Name main feature/pallet-asset-chain-extension Difference
diamond_caller 5675 5675 0
flash_borrower 4685 4685 0
flip_on_me 2101 2101 0
ink_diamond 7332 7332 0
lending_contract 42956 42911 -45
loan_contract 25025 25025 0
my_access_control 20392 20412 20
my_access_control_enumerable 9594 9594 0
my_diamond 15735 15739 4
my_flipper_guard 3788 3790 2
my_ownable 20589 20589 0
my_pausable 3612 3612 0
my_payment_splitter 12256 12237 -19
my_proxy 5440 5448 8
my_psp22 14156 14095 -61
my_psp22_burnable 14368 14372 4
my_psp22_capped 13901 13925 24
my_psp22_facet_v1 13416 13417 1
my_psp22_facet_v2 13840 13833 -7
my_psp22_flashmint 17585 17646 61
my_psp22_metadata 14420 14480 60
my_psp22_metadata_facet 6529 6527 -2
my_psp22_metadata_upgradeable 16864 16860 -4
my_psp22_mintable 13197 13165 -32
my_psp22_pausable 13520 13492 -28
my_psp22_token_timelock 7273 7270 -3
my_psp22_upgradeable 14449 14450 1
my_psp22_wrapper 16629 16625 -4
my_psp34 16392 16393 1
my_psp34_burnable 15884 15881 -3
my_psp34_enumerable 18566 18548 -18
my_psp34_metadata 17057 17048 -9
my_psp34_mintable 15331 15337 6
my_psp37 17559 17557 -2
my_psp37_batch 19665 19667 2
my_psp37_burnable 18858 18863 5
my_psp37_enumerable 23063 23054 -9
my_psp37_metadata 17008 16937 -71
my_psp37_mintable 17928 17925 -3
my_timelock_controller 22848 22827 -21
psp22_receiver 3540 3540 0
psp34_receiver 4019 4019 0
psp37_receiver 5242 5242 0
rust_diamond 6346 6346 0
shares_contract 17089 17142 53
stable_coin_contract 14839 14935 96

HCastano pushed a commit to paritytech/chainextension-registry that referenced this pull request Aug 22, 2022
* Add `pallet-assets` chain extension.

The id of the chain extension is `0x48f6`. It is the first 2 bytes of the `blake2b` hash from the "pallet-assets-chain-extension@v0.1" string.
The [chain extension](https://github.com/Supercolony-net/pallet-assets-chain-extension) created with usage of the [`obce`](https://github.com/Supercolony-net/obce) crate.

The chain extension is not ready for production because it requires some additional changes on the `pallet-assets` side(some operations should be performed by the contract only if the contract is admin).
But it is a matter of time, so I think we can register it and fix it with minor patches.

Added support of the extension into [substrate-contract-node](paritytech/substrate-contracts-node#146) and into [OpenBrush](Supercolony-net/openbrush-contracts#168).

* Update registry.json

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

Co-authored-by: Alexander Theißen <alex.theissen@me.com>
examples/psp22_pallet/README.md Outdated Show resolved Hide resolved
examples/psp22_pallet_extensions/burnable/Cargo.toml Outdated Show resolved Hide resolved
//
// describe('MY_PSP22', () => {
// async function setup() {
// return setupContract('my_psp22_pallet', 'new', 123, '0', '1000')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To deploy a contract on the local node(from paritytech/substrate-contracts-node#146) you need to pass 10000 Units in the constructor. It is required deposit to create and Asset

Copy link
Contributor

@o-tsaruk o-tsaruk Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works with polkadot js and don't work with redspot in integration tests. I'll try to use polkadot js directly

Copy link
Contributor Author

@xgreenx xgreenx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to update the docker image to use the node with chain extension, but let's do that in the separate PR=)

@xgreenx xgreenx merged commit 6a121d0 into main Aug 27, 2022
@xgreenx xgreenx deleted the feature/pallet-asset-chain-extension branch September 23, 2022 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants