What problem does your feature solve?
The stellar ledger entry fetch trustline --asset command rejects valid asset codes that aren't exactly 4 or 12 characters long. For example, PYUSD (5 characters) fails:
$ stellar ledger entry fetch trustline --asset PYUSD:GDQE7IXJ4HUHV6RQHIUPRJSEZE4DRS5WY577O2FY6YQ5LVWZ7JZTU2V5 --account GBEPTCX3INOO7565JDEFNCGMKQVTUIWDB356BASWME74RDJOCGQEI7WP
error: provided asset is invalid: PYUSD:GDQE7IXJ4HUHV6RQHIUPRJSEZE4DRS5WY577O2FY6YQ5LVWZ7JZTU2V5
The code matches on the exact length of the asset code string, only accepting lengths 4 and 12:
|
match code.len() { |
|
4 => TrustLineAsset::CreditAlphanum4(AlphaNum4 { |
|
asset_code: AssetCode4(code.as_bytes().try_into()?), |
|
issuer, |
|
}), |
|
12 => TrustLineAsset::CreditAlphanum12(AlphaNum12 { |
|
asset_code: AssetCode12(code.as_bytes().try_into()?), |
|
issuer, |
|
}), |
Stellar asset codes are 1-4 characters (AssetCode4) or 5-12 characters (AssetCode12), right-padded with zero bytes to fill the fixed-size array.
What would you like to see?
Accept asset codes of any length from 1-12 characters, mapping 1-4 character codes to CreditAlphanum4 and 5-12 character codes to CreditAlphanum12, with the code right-padded with 0 bytes to fill the fixed-size array.
What alternatives are there?
Require users to manually pad their asset codes to 4 or 12 characters, which is not ergonomic and differs from how assets are represented elsewhere in the Stellar ecosystem.
What problem does your feature solve?
The
stellar ledger entry fetch trustline --assetcommand rejects valid asset codes that aren't exactly 4 or 12 characters long. For example,PYUSD(5 characters) fails:The code matches on the exact length of the asset code string, only accepting lengths 4 and 12:
stellar-cli/cmd/soroban-cli/src/commands/ledger/entry/fetch/trustline.rs
Lines 72 to 80 in a1c9455
Stellar asset codes are 1-4 characters (
AssetCode4) or 5-12 characters (AssetCode12), right-padded with zero bytes to fill the fixed-size array.What would you like to see?
Accept asset codes of any length from 1-12 characters, mapping 1-4 character codes to
CreditAlphanum4and 5-12 character codes toCreditAlphanum12, with the code right-padded with0bytes to fill the fixed-size array.What alternatives are there?
Require users to manually pad their asset codes to 4 or 12 characters, which is not ergonomic and differs from how assets are represented elsewhere in the Stellar ecosystem.