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

Muxed address support sketch for Soroban SDK. #1441

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dmkozh
Copy link
Contributor

@dmkozh dmkozh commented Feb 24, 2025

This introduces the MuxedAddress type that maps to either AddressObject or MuxedAddressObject.

In order to not 'leak' the muxed addresses everywhere (as they have pretty narrow use cases), introduce a separate token interface that supports muxed addresses for transfer (could also support e.g. transfer_from). This is basically token extension, but a bit clunkier due to the lack of overload support. The amount of copy-paste could be reduced though with some code generation (I'm not sure that's necessary though). Also only expose muxed addresses to generate clients when that's explicitly requested, as again users normally don't need to worry about them.

This introduces the `MuxedAddress` type that maps to either `AddressObject` or `MuxedAddressObject`.

In order to not 'leak' the muxed addresses everywhere (as they have pretty narrow use cases), introduce a separate token interface that supports muxed addresses for transfer (could also support e.g. transfer_from). This is basically token extension, but a bit clunkier due to the lack of overload support. The amount of copy-paste could be reduced though with some code generation (I'm not sure that's necessary though). Also only expose muxed addresses to generate clients when that's explicitly requested, as again users normally don't need to worry about them.
Comment on lines -68 to -71
#[cfg(not(target_family = "wasm"))]
if !self.env.is_same_env(&other.env) {
return ScVal::from(self).cmp(&ScVal::from(other));
}
Copy link
Member

Choose a reason for hiding this comment

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

Why are the comparison functions changing?

Comment on lines -20 to 33
pub fn transfer(&self, from: Address, to: Address, amount: i128) {
pub fn transfer<AddressType: sealed::IsAddressType + IntoVal<Env, Val>>(
&self,
from: AddressType,
to: AddressType,
amount: i128,
) {
let topics = (symbol_short!("transfer"), from, to);
self.env.events().publish(topics, amount);
Copy link
Member

Choose a reason for hiding this comment

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

Looks like the muxed address is emitted in the topic, so it wouldn't be very easy for a consumer to filter only on the underlying address.

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