diff --git a/libs/coin-modules/coin-stellar/src/bridge/buildOptimisticOperation.ts b/libs/coin-modules/coin-stellar/src/bridge/buildOptimisticOperation.ts index 18bb126b4435..fda3fefca825 100644 --- a/libs/coin-modules/coin-stellar/src/bridge/buildOptimisticOperation.ts +++ b/libs/coin-modules/coin-stellar/src/bridge/buildOptimisticOperation.ts @@ -28,6 +28,7 @@ export async function buildOptimisticOperation( transactionSequenceNumber: transactionSequenceNumber?.plus(1).toNumber(), extra: { ledgerOpType: type, + blockTime: new Date(), }, }; diff --git a/libs/coin-modules/coin-stellar/src/logic/listOperations.ts b/libs/coin-modules/coin-stellar/src/logic/listOperations.ts index e69218b27a5d..bec89a699f35 100644 --- a/libs/coin-modules/coin-stellar/src/logic/listOperations.ts +++ b/libs/coin-modules/coin-stellar/src/logic/listOperations.ts @@ -8,6 +8,11 @@ export type Operation = { value: bigint; fee: bigint; blockHeight: number; + block?: { + hash: string; + time: Date; + height: number; + }; senders: string[]; recipients: string[]; date: Date; @@ -42,6 +47,11 @@ const convertToCoreOperation = (address: string) => (operation: StellarOperation value: BigInt(operation.value.toString()), fee: BigInt(operation.fee.toString()), blockHeight: operation.blockHeight!, + block: { + hash: operation.blockHash!, + time: operation.extra.blockTime, + height: operation.blockHeight!, + }, senders: operation.senders, recipients: operation.recipients, date: operation.date, diff --git a/libs/coin-modules/coin-stellar/src/network/horizon.ts b/libs/coin-modules/coin-stellar/src/network/horizon.ts index f11ac47546bd..af2fb5ac7805 100644 --- a/libs/coin-modules/coin-stellar/src/network/horizon.ts +++ b/libs/coin-modules/coin-stellar/src/network/horizon.ts @@ -73,14 +73,24 @@ Horizon.AxiosClient.interceptors.response.use(response => { // FIXME: workaround for the Stellar SDK not using the correct URL: the "next" URL // included in server responses points to the node itself instead of our reverse proxy... // (https://github.com/stellar/js-stellar-sdk/issues/637) + + function fixURL(url: string): string { + const u = new URL(url); + u.host = new URL(coinConfig.getCoinConfig().explorer.url).host; + return u.toString(); + } + const next_href = response?.data?._links?.next?.href; if (next_href) { - const next = new URL(next_href); - next.host = new URL(coinConfig.getCoinConfig().explorer.url).host; - response.data._links.next.href = next.toString(); + response.data._links.next.href = fixURL(next_href); } + response?.data?._embedded?.records?.forEach((r: any) => { + const href = r.transaction?._links?.ledger?.href; + if (href) r.transaction._links.ledger.href = fixURL(href); + }); + return response; }); diff --git a/libs/coin-modules/coin-stellar/src/network/serialization.ts b/libs/coin-modules/coin-stellar/src/network/serialization.ts index 29b67e904473..ba1677916e8e 100644 --- a/libs/coin-modules/coin-stellar/src/network/serialization.ts +++ b/libs/coin-modules/coin-stellar/src/network/serialization.ts @@ -79,6 +79,7 @@ async function formatOperation( addr: string, ): Promise { const transaction = await rawOperation.transaction(); + const { hash: blockHash, closed_at: blockTime } = await transaction.ledger(); const type = getOperationType(rawOperation, addr); const value = getValue(rawOperation, transaction, type); const recipients = getRecipients(rawOperation); @@ -103,9 +104,10 @@ async function formatOperation( recipients, transactionSequenceNumber: Number(transaction.source_account_sequence), hasFailed: !rawOperation.transaction_successful, - blockHash: null, + blockHash: blockHash, extra: { ledgerOpType: type, + blockTime: new Date(blockTime), }, }; diff --git a/libs/coin-modules/coin-stellar/src/types/bridge.fixture.ts b/libs/coin-modules/coin-stellar/src/types/bridge.fixture.ts index 9583a2e3a148..5f9f06aa429f 100644 --- a/libs/coin-modules/coin-stellar/src/types/bridge.fixture.ts +++ b/libs/coin-modules/coin-stellar/src/types/bridge.fixture.ts @@ -71,6 +71,7 @@ export function createFixtureOperation(operation?: Partial): S let extra: StellarOperationExtra = { assetAmount: operation?.extra?.assetAmount || undefined, ledgerOpType: operation?.extra?.ledgerOpType || "IN", + blockTime: operation?.extra?.blockTime || faker.date.past(), }; if (operation?.extra?.pagingToken) { extra = { diff --git a/libs/coin-modules/coin-stellar/src/types/bridge.ts b/libs/coin-modules/coin-stellar/src/types/bridge.ts index 93b5487ba362..8803a275a5e7 100644 --- a/libs/coin-modules/coin-stellar/src/types/bridge.ts +++ b/libs/coin-modules/coin-stellar/src/types/bridge.ts @@ -111,6 +111,7 @@ export type StellarOperationExtra = { assetAmount?: string | undefined; ledgerOpType: OperationType; memo?: string; + blockTime: Date; }; export type StellarAccount = Account;