67 lines
2.0 KiB
JavaScript
67 lines
2.0 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.transformTransaction = exports.transformServerInfo = void 0;
|
|
const transformServerInfo = (payload) => ({
|
|
name: 'Ripple',
|
|
shortcut: 'xrp',
|
|
network: 'xrp',
|
|
testnet: false,
|
|
version: payload.buildVersion,
|
|
decimals: 6,
|
|
blockHeight: payload.validatedLedger.ledgerVersion,
|
|
blockHash: payload.validatedLedger.hash,
|
|
});
|
|
exports.transformServerInfo = transformServerInfo;
|
|
const BLOCKTIME_OFFSET = 946684800;
|
|
const transformTransaction = (tx, meta, descriptor) => {
|
|
const blockTime = typeof tx.date === 'number' && tx.date > 0 ? tx.date + BLOCKTIME_OFFSET : tx.date;
|
|
const isTokenTransaction = tx.Amount && typeof tx.Amount !== 'string';
|
|
let txType;
|
|
if (meta != null && !meta.TransactionResult?.startsWith('tes')) {
|
|
txType = 'failed';
|
|
}
|
|
else if (tx.TransactionType !== 'Payment' || !descriptor || isTokenTransaction) {
|
|
txType = 'unknown';
|
|
}
|
|
else {
|
|
txType = tx.Account === descriptor ? 'sent' : 'recv';
|
|
}
|
|
const addresses = [tx.Destination];
|
|
const amount = !isTokenTransaction ? tx.Amount : undefined;
|
|
const fee = tx.Fee;
|
|
const destinationTag = tx.DestinationTag;
|
|
return {
|
|
type: txType,
|
|
txid: tx.hash,
|
|
amount,
|
|
fee,
|
|
blockTime,
|
|
blockHeight: tx.ledger_index,
|
|
blockHash: tx.hash,
|
|
targets: txType === 'unknown'
|
|
? []
|
|
: [
|
|
{
|
|
addresses,
|
|
isAddress: true,
|
|
amount,
|
|
n: 0,
|
|
},
|
|
],
|
|
tokens: [],
|
|
internalTransfers: [],
|
|
feeRate: undefined,
|
|
details: {
|
|
vin: [],
|
|
vout: [],
|
|
size: 0,
|
|
totalInput: '0',
|
|
totalOutput: '0',
|
|
},
|
|
rippleSpecific: {
|
|
destinationTag,
|
|
},
|
|
};
|
|
};
|
|
exports.transformTransaction = transformTransaction;
|
|
//# sourceMappingURL=ripple.js.map
|