Muxed address support sketch for Soroban SDK.#1441
Muxed address support sketch for Soroban SDK.#1441dmkozh wants to merge 2 commits intostellar:mainfrom
Conversation
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.
| #[cfg(not(target_family = "wasm"))] | ||
| if !self.env.is_same_env(&other.env) { | ||
| return ScVal::from(self).cmp(&ScVal::from(other)); | ||
| } |
There was a problem hiding this comment.
Why are the comparison functions changing?
There was a problem hiding this comment.
That's unrelated to the sketch, I just didn't want to refactor the SDK to support stellar/rs-soroban-env#1516.
|
|
||
| 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Sure, the sketch was about the issue of 'passing the muxed addresses to the contracts' and I didn't want to spend much time on the events. I've just implemented the simplest option; with one more host fn we could also be emit id separately (the library interface won't change for the caller though).
|
I think this was superseded by: |
This introduces the
MuxedAddresstype that maps to eitherAddressObjectorMuxedAddressObject.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.