Skip to content

Commit 767c718

Browse files
authored
Update transfer for MuxedAddress (#1481)
### What Resolves #1480 stellar/soroban-examples#376 is what the update to the token example looks like.
1 parent ac4ea91 commit 767c718

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

soroban-sdk/src/token.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! Use [`TokenClient`] for calling token contracts such as the Stellar Asset
88
//! Contract.
99
10-
use crate::{contractclient, contractspecfn, Address, Env, String};
10+
use crate::{contractclient, contractspecfn, Address, Env, MuxedAddress, String};
1111

1212
// The interface below was copied from
1313
// https://github.com/stellar/rs-soroban-env/blob/main/soroban-env-host/src/native_contract/token/contract.rs
@@ -140,8 +140,9 @@ pub trait TokenInterface {
140140
/// # Events
141141
///
142142
/// Emits an event with topics `["transfer", from: Address, to: Address],
143-
/// data = amount: i128`
144-
fn transfer(env: Env, from: Address, to: Address, amount: i128);
143+
/// data = amount: i128 or data: { amount: i128, to_muxed_id:u64 }` depending on whether `to`
144+
/// contains a muxed ID.
145+
fn transfer(env: Env, from: Address, to: MuxedAddress, amount: i128);
145146

146147
/// Transfer `amount` from `from` to `to`, consuming the allowance that
147148
/// `spender` has on `from`'s balance. Authorized by spender
@@ -247,7 +248,7 @@ pub(crate) const TOKEN_SPEC_XDR_INPUT: &[&[u8]] = &[
247248
&TokenSpec::spec_xdr_transfer_from(),
248249
];
249250

250-
pub(crate) const TOKEN_SPEC_XDR_LEN: usize = 4716;
251+
pub(crate) const TOKEN_SPEC_XDR_LEN: usize = 4804;
251252

252253
impl TokenSpec {
253254
/// Returns the XDR spec for the Token contract.
@@ -340,8 +341,9 @@ pub trait StellarAssetInterface {
340341
/// # Events
341342
///
342343
/// Emits an event with topics `["transfer", from: Address, to: Address],
343-
/// data = amount: i128`
344-
fn transfer(env: Env, from: Address, to: Address, amount: i128);
344+
/// data = amount: i128 or data: { amount: i128, to_muxed_id:u64 }` depending on whether `to`
345+
/// contains a muxed ID.
346+
fn transfer(env: Env, from: Address, to: MuxedAddress, amount: i128);
345347

346348
/// Transfer `amount` from `from` to `to`, consuming the allowance that
347349
/// `spender` has on `from`'s balance. Authorized by spender
@@ -524,7 +526,7 @@ pub(crate) const STELLAR_ASSET_SPEC_XDR_INPUT: &[&[u8]] = &[
524526
&StellarAssetSpec::spec_xdr_transfer_from(),
525527
];
526528

527-
pub(crate) const STELLAR_ASSET_SPEC_XDR_LEN: usize = 6456;
529+
pub(crate) const STELLAR_ASSET_SPEC_XDR_LEN: usize = 6544;
528530

529531
impl StellarAssetSpec {
530532
/// Returns the XDR spec for the Token contract.

0 commit comments

Comments
 (0)