MCPcopy Create free account
hub / github.com/ccxt/ccxt / parseTransaction

Method parseTransaction

js/src/foxbit.js:1823–1872  ·  view source on GitHub ↗
(transaction, currency = undefined, since = undefined, limit = undefined)

Source from the content-addressed store, hash-verified

1821 return this.safeString(statuses, status, status);
1822 }
1823 parseTransaction(transaction, currency = undefined, since = undefined, limit = undefined) {
1824 const cryptoDetails = this.safeDict(transaction, 'details_crypto');
1825 const address = this.safeString2(cryptoDetails, 'receiving_address', 'destination_address');
1826 const sn = this.safeString(transaction, 'sn');
1827 let type = 'withdrawal';
1828 if (sn !== undefined && sn[0] === 'D') {
1829 type = 'deposit';
1830 }
1831 const fee = this.safeString(transaction, 'fee', '0');
1832 const amount = this.safeString(transaction, 'amount');
1833 const currencySymbol = this.safeString(transaction, 'currency_symbol');
1834 let actualAmount = amount;
1835 const currencyCode = this.safeCurrencyCode(currencySymbol);
1836 const status = this.parseTransactionStatus(this.safeString(transaction, 'state'));
1837 const created_at = this.safeString(transaction, 'created_at');
1838 const timestamp = this.parseDate(created_at);
1839 const datetime = this.iso8601(timestamp);
1840 if (fee !== undefined && amount !== undefined) {
1841 // actualAmount = amount - fee;
1842 actualAmount = Precise.stringSub(amount, fee);
1843 }
1844 const feeRate = Precise.stringDiv(fee, actualAmount);
1845 const feeObj = {
1846 'cost': this.parseNumber(fee),
1847 'currency': currencyCode,
1848 'rate': this.parseNumber(feeRate),
1849 };
1850 return {
1851 'info': transaction,
1852 'id': this.safeString(transaction, 'sn'),
1853 'txid': this.safeString(cryptoDetails, 'transaction_id'),
1854 'timestamp': timestamp,
1855 'datetime': datetime,
1856 'network': this.safeString(transaction, 'network_code'),
1857 'address': address,
1858 'addressTo': address,
1859 'addressFrom': undefined,
1860 'tag': this.safeString(transaction, 'destination_tag'),
1861 'tagTo': this.safeString(transaction, 'destination_tag'),
1862 'tagFrom': undefined,
1863 'type': type,
1864 'amount': this.parseNumber(amount),
1865 'currency': currencyCode,
1866 'status': status,
1867 'updated': undefined,
1868 'fee': feeObj,
1869 'comment': undefined,
1870 'internal': undefined,
1871 };
1872 }
1873 parseLedgerEntryType(type) {
1874 const types = {
1875 'DEPOSITING': 'transaction',

Callers 1

withdrawMethod · 0.95

Calls 10

safeDictMethod · 0.45
safeString2Method · 0.45
safeStringMethod · 0.45
safeCurrencyCodeMethod · 0.45
parseDateMethod · 0.45
iso8601Method · 0.45
stringSubMethod · 0.45
stringDivMethod · 0.45
parseNumberMethod · 0.45

Tested by

no test coverage detected