8000 feat(base): fetchCurrencies > safeCurrencyStructures by ttodua · Pull Request #26017 · ccxt/ccxt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(base): fetchCurrencies > safeCurrencyStructures #26017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ts/src/base/Exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3027,6 +3027,22 @@ export default class Exchange {
};
}

safeCurrencyStructures (currencies: any): Currencies {
/**
* @method safeCurrencyStructures
* @description this is a helper method for "fetchCurrencies". for the exchanges where there are multiple entries per each currency, only after currency parsing loop is ended and all currencies have their networks filled(before returning from method), only by that moment currency entries need to go through safeCurrencyStructure
* @param {object} currencies the currency dictionary
* @returns {object} the restructured currency dictionary
*/
// only after all entries are added in "currencies", restructure each entry
const keys = Object.keys (currencies);
for (let i = 0; i < keys.length; i++) {
const code = keys[i];
currencies[code] = this.safeCurrencyStructure (currencies[code]);
}
return currencies;
}

safeCurrencyStructure (currency: object): CurrencyInterface {
// derive data from networks: deposit, withdraw, active, fee, limits, precision
const networks = this.safeDict (currency, 'networks', {});
Expand Down
8 changes: 1 addition & 7 deletions ts/src/ellipx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,13 +981,7 @@ export default class ellipx extends Exchange {
infos.push (networkEntry);
result[code]['info'] = infos;
}
// only after all entries are formed in currencies, restructure each entry
const allKeys = Object.keys (result);
for (let i = 0; i < allKeys.length; i++) {
const code = allKeys[i];
result[code] = this.safeCurrencyStructure (result[code]); // this is needed after adding network entry
}
return result;
return this.safeCurrencyStructures (result);
}

/**
Expand Down
Loading
0