Framework for asset support in the connector
Currently, the management of asset types in the connector is somewhat ad-hoc.
The fixer.io backend for example looks for the currency code from the ledger metadata.
There is currently no way to properly check if an asset is understood by the connector, leading to this issue.
I propose that the mapping between backend and ledger happens through a string called the asset identifier. Asset identifiers are case-sensitive and may only contain printable ASCII characters. Here are possible examples:
-
USD -
EUR-Gatehub- EUR held by Gatehub -
NASDAQ:AAPL- Apple stock -
GGGB10YR- Greek government bond 10-year -
GFF18- Commodity Futures: Feeder Cattle January 2018 -
NYSEARCA:EWY- ETF: iShares MSCI South Korea Index Fund
This issue is not intended to provide a standard for asset identifiers - that can happen as a longer-term effort separately. For now, I'm merely proposing that asset identifiers be a string that is used to match assets between the ledger and the backend. If you start discussing what should go in the string, whether it should be a URI or a base64-encoded picture of your cat, you will be treated as the distraction that you are.
By default, all plugins report the asset identifier provided by the ledger via a field in getInfo called assetId. However, the user can override this value via a configuration option called assetId.
Backends provide a method called isSupportedAsset(assetId: string): Promise<boolean> which indicates whether the asset string is known to the backend. The connector adds a method to its public API with the same signature. (This could be used by ilp-kit to validate currencies entered by the user to address interledgerjs/ilp-kit#232.) In the future, the connectors might be able to use multiple backends simultaneously, in which case calling isSupportedAsset on the connector would trigger calls to isSupportedAsset on all backends, returning true iff one or more backends responded true.
The backend method getCurve (example) uses the following signature:
interface CurveOpts {
source_asset: string, // asset identifier
source_ledger: string, // ledger prefix
destination_asset: string, // asset identifier
destination_ledger: string // ledger prefix
}
interface LiquidityCurve {
points: Uint32Array // Note that JavaScript does not support a Uint64Array,
// so we use a Uint32Array where each number is broken
// into pairs of [hi, lo]
}
export function getCurve (opts: CurveOpts): Promise<LiquidityCurve> {
// ...
}
:+1:/:-1:?
I use yahoo connector, and it works fine.