Skip to content

Commit 53bfedf

Browse files
🤖 Merge PR DefinitelyTyped#73008 [invity-api]: add trade signatures by @adderpositive
1 parent 38bdf23 commit 53bfedf

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

types/invity-api/index.d.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ export interface ExchangeTrade {
285285
receive?: CryptoId | undefined; // litecoin
286286

287287
receiveStringAmount?: string | undefined; // "0.01"
288+
/** User`s crypto address where tx should be refunded */
289+
refundAddress?: string;
288290
fromAddress?: string | undefined; // user's address from which the tx is sent - used in DEX
289291
receiveAddress?: string | undefined; // user's address for receive tx
290292
rate?: number | undefined; // 100
@@ -337,6 +339,11 @@ export interface ExchangeTrade {
337339
tradeForm?: FormResponse;
338340
}
339341

342+
export interface ExchangeTradeSigned extends ExchangeTrade {
343+
/** SLIP24: Nonce for payment request signature */
344+
tradeSignature: string;
345+
}
346+
340347
export interface ExtendedExchangeTrade extends ExchangeTrade {
341348
requestTradeErrorType?: "QUOTE_TIMEOUT" | "UNKNOWN" | undefined;
342349
newQuote?: ExchangeTrade | undefined; // A renewed quote, in case of a timeout
@@ -536,6 +543,11 @@ export interface SellFiatTrade {
536543
partnerData2?: string | undefined; // arbitrary data specific for the partner
537544
}
538545

546+
export interface SellFiatTradeSigned extends SellFiatTrade {
547+
/** SLIP24: Signature of the trade */
548+
tradeSignature: string;
549+
}
550+
539551
export interface SellVoucherTradeQuoteRequest {
540552
cryptoCurrency?: CryptoId | undefined; // bitcoin
541553
language?: string | undefined; // en
@@ -589,3 +601,29 @@ export interface WatchSellTradeResponse {
589601
destinationPaymentExtraId?: string | undefined; // Extra ID for payments to exchange for networks that require it (destinationTag)
590602
cryptoStringAmount?: string; // Crypto amount to send in case of change on provider's side (Banxa)
591603
}
604+
605+
export interface PaymentRequestOutput {
606+
address: string;
607+
amount: string;
608+
}
609+
610+
export interface CreateTradeSignatureRequestSell {
611+
type: "sell";
612+
/** ID of the trade - `paymentId` for sell */
613+
id: string;
614+
nonce: string;
615+
outputs: PaymentRequestOutput[];
616+
memoText: string;
617+
}
618+
619+
export interface CreateTradeSignatureRequestExchange {
620+
type: "exchange";
621+
/** ID of the trade - `orderId` for exchange */
622+
id: string;
623+
nonce: string;
624+
outputs: PaymentRequestOutput[];
625+
}
626+
627+
export type CreateTradeSignatureRequest =
628+
| CreateTradeSignatureRequestSell
629+
| CreateTradeSignatureRequestExchange;

types/invity-api/invity-api-tests.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import {
22
BuyProviderInfo,
33
BuyTrade,
4+
CreateTradeSignatureRequestExchange,
5+
CreateTradeSignatureRequestSell,
46
CryptoId,
57
ExchangeProviderInfo,
68
ExchangeTrade,
9+
ExchangeTradeSigned,
710
InfoResponse,
811
SellFiatTrade,
12+
SellFiatTradeSigned,
913
SellProviderInfo,
1014
WatchSellTradeResponse,
1115
} from "invity-api";
@@ -18,6 +22,7 @@ const bt: BuyTrade = {
1822
const et: ExchangeTrade = {
1923
send: "bitcoin" as CryptoId,
2024
receive: "ethereum" as CryptoId,
25+
refundAddress: "refundAddress",
2126
quoteId: "123",
2227
signData: {
2328
type: "eip712-typed-data",
@@ -26,6 +31,11 @@ const et: ExchangeTrade = {
2631
status: "SIGN_DATA",
2732
};
2833

34+
const ets: ExchangeTradeSigned = {
35+
...et,
36+
tradeSignature: "signature",
37+
};
38+
2939
const sft: SellFiatTrade = {
3040
paymentMethodName: "Test",
3141
destinationPaymentExtraIdDescription: {
@@ -36,6 +46,11 @@ const sft: SellFiatTrade = {
3646
},
3747
};
3848

49+
const sfts: SellFiatTradeSigned = {
50+
...sft,
51+
tradeSignature: "signature",
52+
};
53+
3954
const wstr: WatchSellTradeResponse = {
4055
cryptoStringAmount: "",
4156
};
@@ -109,3 +124,28 @@ const sellProviderInfo: SellProviderInfo = {
109124
isRefundAddressRequired: false,
110125
lockSendAmount: false,
111126
};
127+
128+
const sellSignatureRequest: CreateTradeSignatureRequestSell = {
129+
type: "sell",
130+
id: "123",
131+
nonce: "nonce",
132+
outputs: [
133+
{
134+
address: "address",
135+
amount: "1000",
136+
},
137+
],
138+
memoText: "memo",
139+
};
140+
141+
const exchangeSignatureRequest: CreateTradeSignatureRequestExchange = {
142+
type: "exchange",
143+
id: "123",
144+
nonce: "nonce",
145+
outputs: [
146+
{
147+
address: "address",
148+
amount: "1000",
149+
},
150+
],
151+
};

0 commit comments

Comments
 (0)