Soneso / stellar_flutter_sdk

Stellar SDK for flutter - dart, Stellar, Horizon, Soneso
MIT License
71 stars 33 forks source link

Get asset code from offers #47

Closed AliKarimiENT closed 1 year ago

AliKarimiENT commented 1 year ago

Hello I have faced an issue: I can not get Selling and Buying asset's code from offers of an account. For example, I have created an offer from native to BTC. When I load the offers, there is no property to get the asset's code. Please check this Thanks

AliKarimiENT commented 1 year ago

This actually is in Asset class that there is nothing to get asset code image

Kanaye commented 1 year ago

Well I don't know flutter so take everthing with a grain of salt but you won't find that field in the Asset base class as ... not all assets have a code. XLM/native is also an asset, but none with an issuer or code. So you'll need to test if the asset is an ALPANUMARIC asset and 🎉 you'll find the code and issuer properties. https://github.com/Soneso/stellar_flutter_sdk/blob/61f48613baf5baf904999f548adcff1e72b35184/lib/src/asset_type_credit_alphanum.dart#L11-L12

AliKarimiENT commented 1 year ago

Thanks, I defined these variables late stl.AssetTypeCreditAlphaNum sellingAsset,buyingAsset; And initialized with a cast to AssetTypeCreditAlphaNum sellingAsset = offer.selling as stl.AssetTypeCreditAlphaNum;