Based on Discord threads (1 and 2), we need to manually create a LedgerSnapshot instance containing the xdr::TrustLineEntrys to the token admin for each of the participating accounts.
The following code gets part of the way there, but it relies on importing stellar_xdr as a separate crate, which conflicts with stellar_sdk::xdr, meaning the trustline entries can't actually be added to the entries vector due to differing types:
```rust
// where `fxdr` comes from:
//
// extern crate xdr as full_xdr;
// use full_xdr::next as fxdr;
let token_admin = e.accounts().generate_and_create();
let snap = e.to_snapshot();
let entries = &snap.ledger_entries;
for trustor in &std::vec![recipient, user1, user2] {
let token_issuer = fxdr::AccountId(
match TryInto::::try_into(token_admin).unwrap().0 {
xdr::PublicKey::PublicKeyTypeEd25519(pk) => {
fxdr::PublicKey::PublicKeyTypeEd25519(fxdr::Uint256(pk.0))
}
},
);
let account_id = match TryInto::::try_into(trustor).unwrap().0 {
xdr::PublicKey::PublicKeyTypeEd25519(pk) => {
fxdr::PublicKey::PublicKeyTypeEd25519(fxdr::Uint256(pk.0))
}
};
let asset = fxdr::TrustLineAsset::CreditAlphanum4(fxdr::AlphaNum4 {
asset_code: fxdr::AssetCode4([0x41; 4]),
issuer: token_issuer,
});
let trustline = fxdr::LedgerKey::Trustline(fxdr::LedgerKeyTrustLine {
account_id: fxdr::AccountId(account_id),
asset,
});
let trustline_entry = (Box::new(key), Box::new(trustline));
entries.push(trustline_entry);
}
snap.update_entries(&entries);
e = soroban_sdk::Env::from_snapshot(snap);
```
Once stellar_sdk exposes all XDR types (or provides a convenient way to make trustlines), this can be modified to work.
After #80, the tests still need to be updated.
Based on Discord threads (1 and 2), we need to manually create a
LedgerSnapshot
instance containing thexdr::TrustLineEntry
s to the token admin for each of the participating accounts.The following code gets part of the way there, but it relies on importing
stellar_xdr
as a separate crate, which conflicts withstellar_sdk::xdr
, meaning the trustline entries can't actually be added to theentries
vector due to differing types:Once
stellar_sdk
exposes all XDR types (or provides a convenient way to make trustlines), this can be modified to work.