-
Notifications
You must be signed in to change notification settings - Fork 1
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: implementation of token transfer (ICS20) contract #24
Conversation
I'll merge this first to minimize merge conflicts. we can review it synchronously later. |
|
||
// Note: if bytes has leading `\0` (null char), `felt252` forgets that information. | ||
// bytes_to_felt252(felt252_to_bytes(x)).unwrap() == x | ||
pub fn bytes_to_felt252(bytes: @ByteArray) -> Option<felt252> { |
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 think we can use the hash methods provided by Cairo to hash the byte array? https://book.cairo-lang.org/ch11-04-hash.html
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.
Thanks for pointing this out. I tried it in #38. It perfectly works. Way cheaper than those functions.
Closes: #21
Description
We initially planned to write a simple ICS20 contract with basic operations to familiarize ourselves with the essentials. However, as I added more elements, it evolved into a full ICS20 token transfer contract. This first version isn't perfect and might not have the best design choices, but it serves as a solid first iteration. It sets the stage for team discussions and helps us nail down the details as we move forward.
Components
This PR includes the following components. In Cairo contracts, a component is like a reusable building block that can be combined with others to create a smart contract with all the needed features.
Preset Contracts
By using the above components and a few others from the OpenZeppelin repository, two contracts have been implemented:
Unit Tests
The following tests cover the happy path for when a
MsgTransfer
or recvPacket
is submitted to theTransfer
contract. Further tests, particularly to catch faulty scenarios, can be added in a subsequent PR.test_escrow_unescrow_roundtrip
test_mint_burn_roundtrip
Scripts
CI Job
Highlights
ByteArray
is quite expensive. We need to find the most efficient way to verify string-like variables. For example, identifiers such asPortId
andChannelId
, which are strings in IBC, must be checked to ensure they meet specifications. Deciding on the best approach will finalize the argument types for some contract APIs.TODO
invoke.sh