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

feat: psp22 trait contract example with drink tests #300

Merged
merged 187 commits into from
Nov 7, 2024

Conversation

chungquantin
Copy link
Collaborator

@chungquantin chungquantin commented Sep 19, 2024

Description

Example contract for the fungible use case that applies the PSP22 traits from #297. The PR includes:

Daanvdplas and others added 30 commits May 19, 2024 17:38
# 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 <frank@r0gue.io>
Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

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

Left some improvements. Also, the contract was now incorrect in terms of capabilities, if the token was constructed with existing the contract would not necessarily be able to mint and burn tokens. This is also what we had discussed so I am suprised to still see it in.

pop-api/examples/fungibles/lib.rs Outdated Show resolved Hide resolved
pop-api/examples/fungibles/lib.rs Outdated Show resolved Hide resolved
pop-api/examples/fungibles/lib.rs Outdated Show resolved Hide resolved
pop-api/examples/fungibles/lib.rs Outdated Show resolved Hide resolved
pop-api/examples/fungibles/lib.rs Outdated Show resolved Hide resolved
pop-api/examples/fungibles/README.md Outdated Show resolved Hide resolved
pop-api/examples/fungibles/README.md Outdated Show resolved Hide resolved
pop-api/examples/fungibles/README.md Outdated Show resolved Hide resolved
pop-api/examples/fungibles/README.md Outdated Show resolved Hide resolved
pop-api/examples/fungibles/README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

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

Last nitpicks but then good to go. Not sure whether we need multiple owners to make the contract more safe for a lost owner account but I leave that to the next reviewer to decide. This example has taken us long enough and we should move on, we can always add examples

chungquantin and others added 5 commits November 5, 2024 22:33
Co-authored-by: Daan van der Plas <93204684+Daanvdplas@users.noreply.github.com>
Co-authored-by: Daan van der Plas <93204684+Daanvdplas@users.noreply.github.com>
Co-authored-by: Daan van der Plas <93204684+Daanvdplas@users.noreply.github.com>
Co-authored-by: Daan van der Plas <93204684+Daanvdplas@users.noreply.github.com>
Copy link
Collaborator

@al3mart al3mart left a comment

Choose a reason for hiding this comment

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

The contract gives a nice example on how to use the fungibles api and the tests are pretty cool.

What I have tried and failed to do was deploying this example locally. The contract kept on trapping.

This is what I could see on my logs

2024-11-06 13:38:29.579 DEBUG tokio-runtime-worker runtime::contracts: Execution finished with debug buffer: seal0::input(out_ptr: 69250, out_len_ptr: 65416) = Ok(())
seal0::caller(out_ptr: 69250, out_len_ptr: 65124) = Ok(())
seal0::address(out_ptr: 69250, out_len_ptr: 65124) = Ok(())
seal0::call_chain_extension(id: 194379776, input_ptr: 69250, input_len: 52, output_ptr: 69302, output_len_ptr: 65132) = Ok(133635)
seal0::seal_return(flags: 1, data_ptr: 69250, data_len: 10) = Err(<wasm:stripped>)

pop-api/examples/fungibles/tests.rs Outdated Show resolved Hide resolved
pop-api/examples/fungibles/lib.rs Show resolved Hide resolved
pop-api/examples/fungibles/README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@evilrobot-01 evilrobot-01 left a comment

Choose a reason for hiding this comment

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

Much better, thank you!

Various typos and fixes suggested. I also think that we need a simple comment on the functions around allowances to make it easier to follow.

pop-api/examples/fungibles/README.md Outdated Show resolved Hide resolved
pop-api/examples/fungibles/README.md Outdated Show resolved Hide resolved
pop-api/examples/fungibles/README.md Outdated Show resolved Hide resolved
pop-api/examples/fungibles/lib.rs Show resolved Hide resolved
@chungquantin
Copy link
Collaborator Author

The gives a nice example on how to use the fungibles api and the tests are pretty cool.

What I have tried and failed to do was deploying this example locally. The contract kept on trapping.

This is what I could see on my logs

2024-11-06 13:38:29.579 DEBUG tokio-runtime-worker runtime::contracts: Execution finished with debug buffer: seal0::input(out_ptr: 69250, out_len_ptr: 65416) = Ok(())
seal0::caller(out_ptr: 69250, out_len_ptr: 65124) = Ok(())
seal0::address(out_ptr: 69250, out_len_ptr: 65124) = Ok(())
seal0::call_chain_extension(id: 194379776, input_ptr: 69250, input_len: 52, output_ptr: 69302, output_len_ptr: 65132) = Ok(133635)
seal0::seal_return(flags: 1, data_ptr: 69250, data_len: 10) = Err(<wasm:stripped>)

I successfully instantiated the contract and mint a new token on testnet: https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc2.paseo.popnetwork.xyz#/explorer/query/0xeb474f72660ef9879f2a3c2f30a28d56b5d250e8945fb8a6c9aa8a0f05cd3947

Copy link
Collaborator

@al3mart al3mart left a comment

Choose a reason for hiding this comment

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

Approving as @chungquantin has shown that the issue in my comment might just be something on my side.
👍

@chungquantin chungquantin merged commit 3cdb9b5 into main Nov 7, 2024
13 checks passed
@chungquantin chungquantin deleted the chungquantin/feat-psp22_example branch November 7, 2024 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Pop API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants