feat: Enhance transaction formatting to support asset transfers alongside payment transactions
This commit is contained in:
parent
e9714f9b9d
commit
b60115b09e
@ -54,19 +54,28 @@
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
// Format transactions
|
// Format transactions
|
||||||
const transactions = (data.transactions || []).map(tx => ({
|
const transactions = (data.transactions || []).map(tx => {
|
||||||
id: tx.id,
|
// Check for payment transaction or asset transfer
|
||||||
type: tx['tx-type'],
|
const paymentTx = tx['payment-transaction'];
|
||||||
roundTime: tx['round-time'],
|
const assetTx = tx['asset-transfer-transaction'];
|
||||||
confirmedRound: tx['confirmed-round'],
|
|
||||||
fee: tx.fee,
|
return {
|
||||||
sender: tx.sender,
|
id: tx.id,
|
||||||
// Payment transaction details
|
type: tx['tx-type'],
|
||||||
receiver: tx['payment-transaction']?.receiver || null,
|
roundTime: tx['round-time'],
|
||||||
amount: tx['payment-transaction']?.amount || 0,
|
confirmedRound: tx['confirmed-round'],
|
||||||
amountAlgo: (tx['payment-transaction']?.amount || 0) / 1000000,
|
fee: tx.fee,
|
||||||
note: tx.note ? atob(tx.note) : null
|
sender: tx.sender,
|
||||||
}));
|
// Get receiver from payment or asset transfer
|
||||||
|
receiver: paymentTx?.receiver || assetTx?.receiver || null,
|
||||||
|
amount: paymentTx?.amount || 0,
|
||||||
|
amountAlgo: (paymentTx?.amount || 0) / 1000000,
|
||||||
|
// Asset transfer details
|
||||||
|
assetId: assetTx?.['asset-id'] || null,
|
||||||
|
assetAmount: assetTx?.amount || 0,
|
||||||
|
note: tx.note ? atob(tx.note) : null
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
transactions,
|
transactions,
|
||||||
@ -154,6 +163,10 @@
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
const tx = data.transaction;
|
const tx = data.transaction;
|
||||||
|
|
||||||
|
// Check for payment transaction or asset transfer
|
||||||
|
const paymentTx = tx['payment-transaction'];
|
||||||
|
const assetTx = tx['asset-transfer-transaction'];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: tx.id,
|
id: tx.id,
|
||||||
type: tx['tx-type'],
|
type: tx['tx-type'],
|
||||||
@ -161,9 +174,13 @@
|
|||||||
confirmedRound: tx['confirmed-round'],
|
confirmedRound: tx['confirmed-round'],
|
||||||
fee: tx.fee,
|
fee: tx.fee,
|
||||||
sender: tx.sender,
|
sender: tx.sender,
|
||||||
receiver: tx['payment-transaction']?.receiver || null,
|
// Get receiver from payment or asset transfer
|
||||||
amount: tx['payment-transaction']?.amount || 0,
|
receiver: paymentTx?.receiver || assetTx?.receiver || null,
|
||||||
amountAlgo: (tx['payment-transaction']?.amount || 0) / 1000000,
|
amount: paymentTx?.amount || 0,
|
||||||
|
amountAlgo: (paymentTx?.amount || 0) / 1000000,
|
||||||
|
// Asset transfer details
|
||||||
|
assetId: assetTx?.['asset-id'] || null,
|
||||||
|
assetAmount: assetTx?.amount || 0,
|
||||||
note: tx.note ? atob(tx.note) : null
|
note: tx.note ? atob(tx.note) : null
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user