tapimo 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.d.ts +4887 -5074
- package/dist/App.d.ts.map +1 -1
- package/dist/Webhooks.d.ts +21 -20
- package/dist/Webhooks.d.ts.map +1 -1
- package/dist/Webhooks.js +66 -23
- package/dist/Webhooks.js.map +1 -1
- package/dist/admin/apps/verified-tokens.d.ts +168 -168
- package/dist/apps/Zones.d.ts +34 -22
- package/dist/apps/Zones.d.ts.map +1 -1
- package/dist/apps/Zones.js +9 -8
- package/dist/apps/Zones.js.map +1 -1
- package/dist/apps/data/App.d.ts +5198 -5099
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/FxOracle.d.ts +4 -5
- package/dist/apps/data/FxOracle.d.ts.map +1 -1
- package/dist/apps/data/FxOracle.js +19 -4
- package/dist/apps/data/FxOracle.js.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +270 -270
- package/dist/apps/data/routes/activities.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.js +32 -27
- package/dist/apps/data/routes/activities.js.map +1 -1
- package/dist/apps/data/routes/addresses.d.ts +52 -52
- package/dist/apps/data/routes/balances.d.ts +36 -36
- package/dist/apps/data/routes/balances.d.ts.map +1 -1
- package/dist/apps/data/routes/balances.js +135 -81
- package/dist/apps/data/routes/balances.js.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +125 -125
- package/dist/apps/data/routes/coingecko.d.ts +54 -54
- package/dist/apps/data/routes/earn.d.ts +512 -58
- package/dist/apps/data/routes/earn.d.ts.map +1 -1
- package/dist/apps/data/routes/earn.js +368 -44
- package/dist/apps/data/routes/earn.js.map +1 -1
- package/dist/apps/data/routes/exchanges.d.ts +120 -120
- package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
- package/dist/apps/data/routes/exchanges.js +114 -118
- package/dist/apps/data/routes/exchanges.js.map +1 -1
- package/dist/apps/data/routes/receipts.d.ts.map +1 -1
- package/dist/apps/data/routes/receipts.js +68 -47
- package/dist/apps/data/routes/receipts.js.map +1 -1
- package/dist/apps/data/routes/rpc.d.ts +31 -31
- package/dist/apps/data/routes/tokens.d.ts +461 -459
- package/dist/apps/data/routes/tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/transactions.d.ts +59 -51
- package/dist/apps/data/routes/transactions.d.ts.map +1 -1
- package/dist/apps/data/routes/transactions.js +25 -23
- package/dist/apps/data/routes/transactions.js.map +1 -1
- package/dist/apps/data/routes/transfers.d.ts +108 -86
- package/dist/apps/data/routes/transfers.d.ts.map +1 -1
- package/dist/apps/data/routes/transfers.js +618 -105
- package/dist/apps/data/routes/transfers.js.map +1 -1
- package/dist/apps/data/routes/valuation.d.ts +21 -21
- package/dist/apps/data/routes/valuation.d.ts.map +1 -1
- package/dist/apps/data/routes/valuation.js +2 -2
- package/dist/apps/data/routes/valuation.js.map +1 -1
- package/dist/apps/data/routes/verified-tokens.d.ts +37 -37
- package/dist/apps/data/routes/webhooks.d.ts +102 -505
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +484 -342
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/data/routes/zones.d.ts +12 -12
- package/dist/apps/data/routes/zones.d.ts.map +1 -1
- package/dist/apps/data/routes/zones.js +3 -1
- package/dist/apps/data/routes/zones.js.map +1 -1
- package/dist/apps/funding/App.d.ts +96 -96
- package/dist/apps/funding/routes/deposit-addresses.d.ts +52 -52
- package/dist/apps/funding/routes/quotes.d.ts +89 -89
- package/dist/apps/funding/routes/transfers.d.ts +4 -4
- package/dist/apps/management/App.d.ts +429 -727
- package/dist/apps/management/App.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.d.ts +24 -24
- package/dist/apps/management/routes/billing.d.ts +72 -72
- package/dist/apps/management/routes/faucet.d.ts +6 -6
- package/dist/apps/management/routes/invitations.d.ts +134 -134
- package/dist/apps/management/routes/invite-links.d.ts +38 -38
- package/dist/apps/management/routes/me.d.ts +6 -6
- package/dist/apps/management/routes/members.d.ts +30 -30
- package/dist/apps/management/routes/orgs.d.ts +98 -98
- package/dist/apps/management/routes/projects.d.ts +20 -20
- package/dist/apps/management/routes/usage.d.ts +24 -24
- package/dist/apps/management/routes/verified-token-requests.d.ts +83 -83
- package/dist/apps/management/routes/webhooks.d.ts +158 -573
- package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/mpp/App.d.ts +56 -44
- package/dist/apps/mpp/App.d.ts.map +1 -1
- package/dist/apps/mpp/Mpp.d.ts +3 -0
- package/dist/apps/mpp/Mpp.d.ts.map +1 -1
- package/dist/apps/mpp/Mpp.js +3 -0
- package/dist/apps/mpp/Mpp.js.map +1 -1
- package/dist/apps/mpp/internal/Adapter.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Adapter.js +9 -2
- package/dist/apps/mpp/internal/Adapter.js.map +1 -1
- package/dist/db/Db.d.ts +2 -2
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +17 -15
- package/dist/db/Db.js.map +1 -1
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +4 -1
- package/dist/db/tables/sponsoredTransactions.js.map +1 -1
- package/dist/db/tables/webhookSubscriptions.d.ts +56 -3
- package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
- package/dist/db/tables/webhookSubscriptions.js +76 -3
- package/dist/db/tables/webhookSubscriptions.js.map +1 -1
- package/dist/internal/MetricSink.d.ts +112 -3
- package/dist/internal/MetricSink.d.ts.map +1 -1
- package/dist/internal/MetricSink.js +116 -3
- package/dist/internal/MetricSink.js.map +1 -1
- package/dist/internal/Schema.js +1 -1
- package/dist/internal/Schema.js.map +1 -1
- package/dist/internal/Tidx.d.ts +1 -3
- package/dist/internal/Tidx.d.ts.map +1 -1
- package/dist/internal/Tidx.js +1 -3
- package/dist/internal/Tidx.js.map +1 -1
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +2 -1
- package/dist/internal/Viem.js.map +1 -1
- package/dist/internal/WebhookDestination.d.ts +2 -0
- package/dist/internal/WebhookDestination.d.ts.map +1 -1
- package/dist/internal/WebhookDestination.js +11 -0
- package/dist/internal/WebhookDestination.js.map +1 -1
- package/dist/internal/WebhookTransfer.d.ts +55 -0
- package/dist/internal/WebhookTransfer.d.ts.map +1 -0
- package/dist/internal/WebhookTransfer.js +296 -0
- package/dist/internal/WebhookTransfer.js.map +1 -0
- package/dist/internal/Webhooks.d.ts +37 -0
- package/dist/internal/Webhooks.d.ts.map +1 -1
- package/dist/internal/Webhooks.js +87 -13
- package/dist/internal/Webhooks.js.map +1 -1
- package/dist/internal/funding/Provider.d.ts +4 -0
- package/dist/internal/funding/Provider.d.ts.map +1 -1
- package/dist/internal/funding/Provider.js +11 -7
- package/dist/internal/funding/Provider.js.map +1 -1
- package/dist/internal/funding/Reconciliation.d.ts.map +1 -1
- package/dist/internal/funding/Reconciliation.js +128 -0
- package/dist/internal/funding/Reconciliation.js.map +1 -1
- package/dist/internal/funding/providers/relay.d.ts +3 -0
- package/dist/internal/funding/providers/relay.d.ts.map +1 -1
- package/dist/internal/funding/providers/relay.js +12 -1
- package/dist/internal/funding/providers/relay.js.map +1 -1
- package/package.json +3 -3
- package/src/Client.test-d.ts +60 -5
- package/src/Webhooks.bench.ts +714 -0
- package/src/Webhooks.memory.bench.ts +250 -0
- package/src/Webhooks.test.ts +77 -6
- package/src/Webhooks.ts +83 -29
- package/src/apps/Zones.test.ts +5 -4
- package/src/apps/Zones.ts +9 -8
- package/src/apps/data/FxOracle.test.ts +18 -0
- package/src/apps/data/FxOracle.ts +28 -5
- package/src/apps/data/routes/activities.test.ts +19 -0
- package/src/apps/data/routes/activities.ts +34 -30
- package/src/apps/data/routes/balances.test.ts +119 -10
- package/src/apps/data/routes/balances.ts +154 -95
- package/src/apps/data/routes/blocks.test.ts +12 -6
- package/src/apps/data/routes/earn.test.ts +197 -0
- package/src/apps/data/routes/earn.ts +486 -44
- package/src/apps/data/routes/exchanges.test.ts +7 -6
- package/src/apps/data/routes/exchanges.ts +124 -117
- package/src/apps/data/routes/receipts.test.ts +24 -7
- package/src/apps/data/routes/receipts.ts +67 -50
- package/src/apps/data/routes/tokens.test.ts +51 -0
- package/src/apps/data/routes/transactions.test.ts +42 -0
- package/src/apps/data/routes/transactions.ts +44 -39
- package/src/apps/data/routes/transfers.test.ts +402 -24
- package/src/apps/data/routes/transfers.ts +708 -101
- package/src/apps/data/routes/valuation.test.ts +26 -0
- package/src/apps/data/routes/valuation.ts +6 -2
- package/src/apps/data/routes/webhooks.test.ts +414 -130
- package/src/apps/data/routes/webhooks.ts +603 -419
- package/src/apps/data/routes/zones.ts +6 -1
- package/src/apps/funding/routes/quotes.test.ts +1 -1
- package/src/apps/mpp/Mpp.test.ts +13 -1
- package/src/apps/mpp/Mpp.ts +8 -0
- package/src/apps/mpp/internal/Adapter.ts +10 -2
- package/src/db/Db.test.ts +40 -6
- package/src/db/Db.ts +33 -19
- package/src/db/tables/sponsoredTransactions.ts +9 -2
- package/src/db/tables/webhookSubscriptions.ts +116 -4
- package/src/internal/EarnVaults.test.ts +2 -2
- package/src/internal/MetricSink.test.ts +518 -0
- package/src/internal/MetricSink.ts +266 -9
- package/src/internal/Schema.ts +1 -1
- package/src/internal/Tidx.test.ts +4 -4
- package/src/internal/Tidx.ts +1 -3
- package/src/internal/Viem.test.ts +8 -0
- package/src/internal/Viem.ts +2 -1
- package/src/internal/WebhookDestination.test.ts +20 -0
- package/src/internal/WebhookDestination.ts +10 -0
- package/src/internal/WebhookTransfer.ts +426 -0
- package/src/internal/Webhooks.test.ts +137 -0
- package/src/internal/Webhooks.ts +131 -17
- package/src/internal/funding/Provider.test.ts +47 -7
- package/src/internal/funding/Provider.ts +12 -7
- package/src/internal/funding/Reconciliation.local.test.ts +3 -1
- package/src/internal/funding/Reconciliation.test.ts +1240 -0
- package/src/internal/funding/Reconciliation.ts +136 -0
- package/src/internal/funding/SourceObservation.test.ts +1 -0
- package/src/internal/funding/providers/relay.test.ts +1 -4
- package/src/internal/funding/providers/relay.ts +16 -1
|
@@ -21,6 +21,8 @@ const followUpDelaySeconds = { delivery: 1, provider: 5, settlement: 2 } as cons
|
|
|
21
21
|
>
|
|
22
22
|
const maximumPages = 100
|
|
23
23
|
const maximumFollowUpAttempts = 6
|
|
24
|
+
const providerFailureStatuses = ['failure'] as const
|
|
25
|
+
const providerRefundStatuses = ['refund', 'refunded'] as const
|
|
24
26
|
|
|
25
27
|
/** Verified token transfer returned by an authoritative chain reader. */
|
|
26
28
|
export type TransferEvidence = {
|
|
@@ -866,6 +868,16 @@ export async function reconcileRequest(
|
|
|
866
868
|
}
|
|
867
869
|
if (verified.length === 0) return { created, terminal: false, updated: updatedIds.size }
|
|
868
870
|
if (!sourceEvidenceComplete) return { created, terminal: false, updated: updatedIds.size }
|
|
871
|
+
const recovery = await reconcileProviderRecovery(db, { ...options, verified })
|
|
872
|
+
if (recovery) {
|
|
873
|
+
for (const id of recovery.updatedIds) updatedIds.add(id)
|
|
874
|
+
return {
|
|
875
|
+
created,
|
|
876
|
+
...(recovery.followUp ? { followUp: recovery.followUp } : {}),
|
|
877
|
+
terminal: recovery.terminal,
|
|
878
|
+
updated: updatedIds.size,
|
|
879
|
+
}
|
|
880
|
+
}
|
|
869
881
|
const delivery = await reconcileDelivery(db, { ...options, verified })
|
|
870
882
|
for (const id of delivery.updatedIds) updatedIds.add(id)
|
|
871
883
|
return {
|
|
@@ -910,6 +922,130 @@ export declare namespace reconcileRequest {
|
|
|
910
922
|
}
|
|
911
923
|
}
|
|
912
924
|
|
|
925
|
+
async function reconcileProviderRecovery(db: Db.Db, options: ReconcileDeliveryOptions) {
|
|
926
|
+
const failed = (providerFailureStatuses as readonly string[]).includes(
|
|
927
|
+
options.request?.status ?? '',
|
|
928
|
+
)
|
|
929
|
+
const refunded = (providerRefundStatuses as readonly string[]).includes(
|
|
930
|
+
options.request?.status ?? '',
|
|
931
|
+
)
|
|
932
|
+
if (!refunded && !failed) return undefined
|
|
933
|
+
if (failed) {
|
|
934
|
+
const destinationEvidence = await Promise.all(
|
|
935
|
+
unique(options.request?.destinationTransactionHashes ?? []).map((transactionHash) =>
|
|
936
|
+
options.verifyTransfers({
|
|
937
|
+
chain: options.address.snapshot.destinationChain,
|
|
938
|
+
recipient: options.address.recipient,
|
|
939
|
+
token: options.address.providerOutputToken,
|
|
940
|
+
transactionHash,
|
|
941
|
+
}),
|
|
942
|
+
),
|
|
943
|
+
)
|
|
944
|
+
if (destinationEvidence.some((transfers) => transfers.length > 0)) return undefined
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
const updatedIds = new Set<string>()
|
|
948
|
+
if (options.verified.every((entry) => Deposit.isTerminal(entry.deposit.status)))
|
|
949
|
+
return { terminal: true, updatedIds }
|
|
950
|
+
|
|
951
|
+
// Relay auto-refunds may include an internal settlement transaction; only matching source-token transfers become public evidence.
|
|
952
|
+
const providerRefundTransactionHashes = unique(options.request?.refundTransactionHashes ?? [])
|
|
953
|
+
const refundEvidence = await Promise.all(
|
|
954
|
+
providerRefundTransactionHashes.map((transactionHash) =>
|
|
955
|
+
options.verifyTransfers({
|
|
956
|
+
chain: options.address.snapshot.sourceChain,
|
|
957
|
+
recipient: options.address.refundAddress,
|
|
958
|
+
token: options.address.snapshot.sourceToken,
|
|
959
|
+
transactionHash,
|
|
960
|
+
}),
|
|
961
|
+
),
|
|
962
|
+
)
|
|
963
|
+
const refundTransfers = refundEvidence.flat()
|
|
964
|
+
const refundOutput = refundTransfers.reduce(
|
|
965
|
+
(total, transfer) => total + BigInt(transfer.amount),
|
|
966
|
+
0n,
|
|
967
|
+
)
|
|
968
|
+
const refundTransactionHashes = unique(
|
|
969
|
+
refundTransfers.map((transfer) => transfer.transactionHash),
|
|
970
|
+
)
|
|
971
|
+
// Relay can include internal transactions, so its reported amount proves when all matching refund transfers are visible.
|
|
972
|
+
const expectedRefundOutput = options.request?.refundAmountExpected
|
|
973
|
+
? BigInt(options.request.refundAmountExpected)
|
|
974
|
+
: undefined
|
|
975
|
+
const refundEvidenceComplete = (() => {
|
|
976
|
+
if (refundOutput === 0n) return false
|
|
977
|
+
if (expectedRefundOutput !== undefined) return refundOutput === expectedRefundOutput
|
|
978
|
+
return refundEvidence.length > 0 && refundEvidence.every((transfers) => transfers.length > 0)
|
|
979
|
+
})()
|
|
980
|
+
const totalSource = options.verified.reduce((total, entry) => total + entry.sourceAmount, 0n)
|
|
981
|
+
let allocated = 0n
|
|
982
|
+
let cumulativeSource = 0n
|
|
983
|
+
let terminal = refundEvidenceComplete
|
|
984
|
+
|
|
985
|
+
// Include terminal rows in proportional allocation so retries preserve the original split without reallocating their verified refunds.
|
|
986
|
+
for (const entry of options.verified) {
|
|
987
|
+
cumulativeSource += entry.sourceAmount
|
|
988
|
+
const nextAllocated = totalSource === 0n ? 0n : (refundOutput * cumulativeSource) / totalSource
|
|
989
|
+
const amount = nextAllocated - allocated
|
|
990
|
+
allocated = nextAllocated
|
|
991
|
+
if (Deposit.isTerminal(entry.deposit.status)) continue
|
|
992
|
+
let deposit = entry.deposit
|
|
993
|
+
if (deposit.status !== 'refunding') {
|
|
994
|
+
const result = await Deposit.transition(db, {
|
|
995
|
+
expectedVersion: deposit.version,
|
|
996
|
+
id: deposit.id,
|
|
997
|
+
providerTransactionHashes: unique([
|
|
998
|
+
...deposit.providerTransactionHashes,
|
|
999
|
+
...providerRefundTransactionHashes,
|
|
1000
|
+
]),
|
|
1001
|
+
status: 'refunding',
|
|
1002
|
+
})
|
|
1003
|
+
if (result.type === 'applied') {
|
|
1004
|
+
deposit = result.record
|
|
1005
|
+
updatedIds.add(deposit.id)
|
|
1006
|
+
} else if (result.type === 'stale') deposit = result.current
|
|
1007
|
+
}
|
|
1008
|
+
if (!refundEvidenceComplete) continue
|
|
1009
|
+
if (Deposit.isTerminal(deposit.status)) continue
|
|
1010
|
+
if (deposit.status !== 'refunding') {
|
|
1011
|
+
terminal = false
|
|
1012
|
+
continue
|
|
1013
|
+
}
|
|
1014
|
+
const result = await Deposit.transition(db, {
|
|
1015
|
+
expectedVersion: deposit.version,
|
|
1016
|
+
id: deposit.id,
|
|
1017
|
+
snapshot: {
|
|
1018
|
+
...deposit.snapshot,
|
|
1019
|
+
refundAmount: Value.tokenAmount({
|
|
1020
|
+
baseUnits: amount,
|
|
1021
|
+
currency: options.address.snapshot.sourceToken.currency,
|
|
1022
|
+
decimals: options.address.snapshot.sourceToken.decimals,
|
|
1023
|
+
}),
|
|
1024
|
+
refundTransactionHashes,
|
|
1025
|
+
},
|
|
1026
|
+
status: 'refunded',
|
|
1027
|
+
})
|
|
1028
|
+
if (result.type === 'applied') updatedIds.add(deposit.id)
|
|
1029
|
+
else if (result.type !== 'stale' || !Deposit.isTerminal(result.current.status)) terminal = false
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
const outcome = (() => {
|
|
1033
|
+
if (refundEvidenceComplete) return 'verified'
|
|
1034
|
+
// Relay failure can be followed by an automatic refund; durable exhaustion owns escalation to action-required.
|
|
1035
|
+
if (failed) return 'provider_failed'
|
|
1036
|
+
return 'pending'
|
|
1037
|
+
})()
|
|
1038
|
+
options.metrics?.count('funding_deposit_refund_count', 1, {
|
|
1039
|
+
outcome,
|
|
1040
|
+
provider: options.address.providerId,
|
|
1041
|
+
})
|
|
1042
|
+
return {
|
|
1043
|
+
...(!refundEvidenceComplete ? { followUp: 'delivery' as const } : {}),
|
|
1044
|
+
terminal,
|
|
1045
|
+
updatedIds,
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
|
|
913
1049
|
async function reconcileDelivery(db: Db.Db, options: ReconcileDeliveryOptions) {
|
|
914
1050
|
let followUp: reconcileRequest.ReturnType['followUp']
|
|
915
1051
|
let terminal = true
|
|
@@ -188,6 +188,7 @@ describe('observe', () => {
|
|
|
188
188
|
createdAt: '2026-01-01T00:00:02.000Z',
|
|
189
189
|
destinationTransactionHashes: [],
|
|
190
190
|
id: 'relay-source-request',
|
|
191
|
+
refundTransactionHashes: [],
|
|
191
192
|
sourceTransactionHashes: [sourceTransactionHash],
|
|
192
193
|
status: 'pending',
|
|
193
194
|
updatedAt: '2026-01-01T00:00:03.000Z',
|
|
@@ -151,11 +151,8 @@ describe.skipIf(!apiKey)('relay.prepareTransfer (live)', () => {
|
|
|
151
151
|
expect(result.correlation.requestId).toMatch(/^0x[0-9a-f]{64}$/)
|
|
152
152
|
expect(result.correlation.checkEndpoint).toContain('/intents/status/v3')
|
|
153
153
|
expect(BigInt(result.destinationAmount) > 0n).toBe(true)
|
|
154
|
+
expect(BigInt(result.destinationAmountMin) > 0n).toBe(true)
|
|
154
155
|
expect(BigInt(result.destinationAmountMin) <= BigInt(result.destinationAmount)).toBe(true)
|
|
155
|
-
// The forwarded slippage bound holds on the quoted minimum.
|
|
156
|
-
expect(
|
|
157
|
-
BigInt(result.destinationAmountMin) >= (BigInt(result.destinationAmount) * 9_700n) / 10_000n,
|
|
158
|
-
).toBe(true)
|
|
159
156
|
// Relay returns no quote validity window; the fan-out applies the default.
|
|
160
157
|
expect(result.expiresAt).toBeUndefined()
|
|
161
158
|
expect(Number.isNaN(Date.parse(result.sampledAt))).toBe(false)
|
|
@@ -17,6 +17,7 @@ const defaultBaseUrl = 'https://api.relay.link'
|
|
|
17
17
|
const defaultFetch: FundingProvider.Fetch = (input, init) => globalThis.fetch(input, init)
|
|
18
18
|
const deliveryBackfillBlocks = 256n
|
|
19
19
|
const relayChainsCacheTtlMs = 60_000
|
|
20
|
+
const relayRefundStatuses = ['refund', 'refunded'] as const
|
|
20
21
|
const sourceSweepForwardBlocks = 256n
|
|
21
22
|
const depositErc20FullAllowance = AbiFunction.from(
|
|
22
23
|
'function depositErc20(address depositor,address token,bytes32 id)',
|
|
@@ -46,6 +47,7 @@ const webhookStatuses = [
|
|
|
46
47
|
'fallback',
|
|
47
48
|
'pending',
|
|
48
49
|
'refund',
|
|
50
|
+
'refunded',
|
|
49
51
|
'submitted',
|
|
50
52
|
'success',
|
|
51
53
|
'waiting',
|
|
@@ -196,6 +198,13 @@ namespace schema {
|
|
|
196
198
|
),
|
|
197
199
|
),
|
|
198
200
|
id: z.string().check(z.minLength(1)),
|
|
201
|
+
refundCurrencyData: z.optional(
|
|
202
|
+
z.nullable(
|
|
203
|
+
z.object({
|
|
204
|
+
amount: z.string().check(z.regex(/^\d+$/)),
|
|
205
|
+
}),
|
|
206
|
+
),
|
|
207
|
+
),
|
|
199
208
|
protocol: z.optional(
|
|
200
209
|
z.nullable(
|
|
201
210
|
z.object({
|
|
@@ -481,6 +490,8 @@ export function relay(options: relay.Options = {}): FundingProvider.Provider<'re
|
|
|
481
490
|
return {
|
|
482
491
|
...(parsed.continuation ? { continuation: parsed.continuation } : {}),
|
|
483
492
|
requests: parsed.requests.map((request) => {
|
|
493
|
+
const outputTransactionHashes = request.data?.outTxs?.map((tx) => tx.txHash) ?? []
|
|
494
|
+
const refunded = (relayRefundStatuses as readonly string[]).includes(request.status)
|
|
484
495
|
const correlation = (() => {
|
|
485
496
|
const { protocol } = request
|
|
486
497
|
if (!protocol) return undefined
|
|
@@ -499,9 +510,13 @@ export function relay(options: relay.Options = {}): FundingProvider.Provider<'re
|
|
|
499
510
|
})()
|
|
500
511
|
return {
|
|
501
512
|
createdAt: new Date(request.createdAt).toISOString(),
|
|
502
|
-
destinationTransactionHashes:
|
|
513
|
+
destinationTransactionHashes: refunded ? [] : outputTransactionHashes,
|
|
503
514
|
id: request.id,
|
|
504
515
|
...(correlation ? { providerState: correlation } : {}),
|
|
516
|
+
...(refunded && request.refundCurrencyData
|
|
517
|
+
? { refundAmountExpected: request.refundCurrencyData.amount }
|
|
518
|
+
: {}),
|
|
519
|
+
refundTransactionHashes: refunded ? outputTransactionHashes : [],
|
|
505
520
|
sourceTransactionHashes: request.depositAddress?.depositTxHash
|
|
506
521
|
? [request.depositAddress.depositTxHash]
|
|
507
522
|
: [],
|