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

Shade protocol #153

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

Conversation

DrPresident
Copy link

Shade Swap adapter building, needs testing
Secret entry point roughed out, not building needs lots more work

Hoping to get early eyes on this as the implementation is pretty messy to work around incompatibility issues with the packages/skip using vanilla cosmwasm and the secret code needing secret-cosmwasm-std.

checked_entry_point_contract.address.to_string(),
)
.add_attribute(
"ics20_contract_address",
Copy link
Member

Choose a reason for hiding this comment

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

This ICS 20 contract address is a contract on secret that interact with the underlying IBC module, is that correct?

Copy link
Author

Choose a reason for hiding this comment

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

yep, it handles wrapping and unwrapping for tokens going in and out of the network
https://github.com/scrtlabs/snip20-ics20

// Verify memo is valid json and add the necessary key/value pair to trigger the ibc hooks callback logic.
let memo = verify_and_create_memo(ibc_info.memo, env.contract.address.to_string())?;

println!("memo {}", memo);
Copy link
Member

Choose a reason for hiding this comment

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

remove debug log

// Get and delete the in progress recover address from storage
let in_progress_recover_address = IN_PROGRESS_RECOVER_ADDRESS.load(deps.storage)?;
IN_PROGRESS_RECOVER_ADDRESS.remove(deps.storage);
println!("IN PROG {}", in_progress_recover_address);
Copy link
Member

Choose a reason for hiding this comment

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

remove debug log


// Set ack_id to be the channel id and sequence id from the response as a tuple
let ack_id: AckID = (&in_progress_channel_id, resp.sequence);
println!("ACKID {:?}", ack_id);
Copy link
Member

Choose a reason for hiding this comment

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

remove debug log

Ok(memo)
}

fn register_tokens(
Copy link
Member

Choose a reason for hiding this comment

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

q for my understanding: Can you link me to documentation or give me a tldr on what registering a token does?

Copy link
Author

Choose a reason for hiding this comment

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

For snip20 tokens, you need a viewing key to see your balance, and you need to "register receive" so that the snip20 knows the code hash of the contract and can call the receive TX when tokens are sent to it.
Per our discussion we maybe don't need viewing keys, but unless theres a good reason to remove it being able to see the balances of the contract will be helpful in debugging/troubleshooting.

msg: ExecuteMsg,
) -> ContractResult<Response> {
match msg {
ExecuteMsg::Receive(snip20_msg) => receive_snip20(deps, env, info, snip20_msg),
Copy link
Member

Choose a reason for hiding this comment

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

This is because Shade Protocol only supports snip20 tokens, right?

Copy link
Author

Choose a reason for hiding this comment

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

Correct, the only tokens coming in will be from the receive TX called by the sent snip20

return_denom,
)?),
// Tokens must be registered before they can be swapped
ExecuteMsg::RegisterTokens { contracts } => register_tokens(deps, env, contracts),
Copy link
Member

Choose a reason for hiding this comment

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

It's intended for this method to be callable by anyone, yeah? In practice will Shade register all the tokens once the contracts are deployed?

Copy link
Author

Choose a reason for hiding this comment

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

We certainly can, it will be good for you guys to be able to do it as well but I'd be happy to seed the data with all the tokens we know about

@DrPresident DrPresident marked this pull request as ready for review January 16, 2025 18:48
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.

2 participants