Skip to content

Commit 3efce41

Browse files
committed
Update sideshift plugin with new optional API fields
Sideshift's API now returns optional settledAt, deposit/settle contract addresses, deposit/settle hashes, and deposit/settle EVM chain IDs. Capture these in the asSideshiftTx cleaner and wire depositTxid/payoutTxid from the new deposit/settle hashes. The remaining new fields are available on rawTx. Recreates #208 (external fork PR) onto current master.
1 parent 458438a commit 3efce41

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- changed: Update sideshift plugin with new optional API fields
56
- changed: Add signature header support to Exolix
67
- changed: Add index for orderId
78
- changed: Add EVM chainId, pluginId, and tokenId fields to StandardTx

src/partners/sideshift.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
asArray,
33
asMaybe,
4+
asNumber,
45
asObject,
56
asOptional,
67
asString,
@@ -156,14 +157,23 @@ const asSideshiftTx = asObject({
156157
prevDepositAddresses: asMaybe(asObject({ address: asMaybe(asString) })),
157158
depositAsset: asString,
158159
depositNetwork: asOptional(asString),
160+
depositHash: asOptional(asString),
161+
depositContractAddress: asOptional(asString),
162+
// asMaybe so an unexpected encoding (e.g. a numeric string) degrades to
163+
// undefined instead of throwing and aborting the whole 5-day query block
164+
depositEvmChainId: asMaybe(asNumber),
159165
invoiceAmount: asString,
160166
settleAddress: asObject({
161167
address: asString
162168
}),
163169
settleAmount: asString,
164170
settleAsset: asString,
165171
settleNetwork: asOptional(asString),
166-
createdAt: asString
172+
settleHash: asOptional(asString),
173+
settleContractAddress: asOptional(asString),
174+
settleEvmChainId: asMaybe(asNumber),
175+
createdAt: asString,
176+
settledAt: asOptional(asString)
167177
})
168178

169179
const asSideshiftPluginParams = asObject({
@@ -363,7 +373,12 @@ export async function processSideshiftTx(
363373
status: statusMap[tx.status],
364374
orderId: tx.id,
365375
countryCode: null,
366-
depositTxid: undefined,
376+
// On EVM networks, TRON, Aptos, Sui, NEAR, and Algorand, SideShift's
377+
// depositHash is the internal sweep transaction (deposit contract to
378+
// their wallet), not the customer's own deposit transaction. The API
379+
// exposes no better field, so treat this as an order reference, not a
380+
// pointer to the customer's on-chain payment.
381+
depositTxid: tx.depositHash,
367382
depositAddress,
368383
depositCurrency: tx.depositAsset,
369384
depositChainPluginId: depositAsset.chainPluginId,
@@ -373,7 +388,7 @@ export async function processSideshiftTx(
373388
direction: null,
374389
exchangeType: 'swap',
375390
paymentType: null,
376-
payoutTxid: undefined,
391+
payoutTxid: tx.settleHash,
377392
payoutAddress: tx.settleAddress.address,
378393
payoutCurrency: tx.settleAsset,
379394
payoutChainPluginId: payoutAsset.chainPluginId,

src/queryEngine.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,11 @@ export async function queryEngine(): Promise<void> {
187187
const checkUpdateTx = (oldTx: StandardTx, newTx: StandardTx): string[] => {
188188
const fields = [
189189
'status',
190+
'depositTxid',
190191
'depositChainPluginId',
191192
'depositEvmChainId',
192193
'depositTokenId',
194+
'payoutTxid',
193195
'payoutChainPluginId',
194196
'payoutEvmChainId',
195197
'payoutTokenId'

0 commit comments

Comments
 (0)