@sip-protocol/sdk 0.2.4 → 0.2.6
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/browser.js +22 -1
- package/dist/browser.mjs +1 -1
- package/dist/chunk-6WOV2YNG.mjs +10179 -0
- package/dist/chunk-MR7HRCRS.mjs +10165 -0
- package/dist/index.js +22 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/adapters/oneclick-client.ts +33 -1
- package/src/sip.ts +10 -0
package/dist/index.js
CHANGED
|
@@ -2120,7 +2120,21 @@ var OneClickClient = class {
|
|
|
2120
2120
|
*/
|
|
2121
2121
|
async quote(request) {
|
|
2122
2122
|
this.validateQuoteRequest(request);
|
|
2123
|
-
|
|
2123
|
+
const rawResponse = await this.post("/v0/quote", request);
|
|
2124
|
+
return {
|
|
2125
|
+
quoteId: rawResponse.timestamp,
|
|
2126
|
+
// Use timestamp as quoteId since API doesn't provide one
|
|
2127
|
+
depositAddress: rawResponse.quote.depositAddress,
|
|
2128
|
+
amountIn: rawResponse.quote.amountIn,
|
|
2129
|
+
amountInFormatted: rawResponse.quote.amountInFormatted,
|
|
2130
|
+
amountOut: rawResponse.quote.amountOut,
|
|
2131
|
+
amountOutFormatted: rawResponse.quote.amountOutFormatted,
|
|
2132
|
+
amountOutUsd: rawResponse.quote.amountOutUsd,
|
|
2133
|
+
deadline: rawResponse.quote.deadline,
|
|
2134
|
+
timeEstimate: rawResponse.quote.timeEstimate,
|
|
2135
|
+
signature: rawResponse.signature,
|
|
2136
|
+
request: rawResponse.quoteRequest
|
|
2137
|
+
};
|
|
2124
2138
|
}
|
|
2125
2139
|
/**
|
|
2126
2140
|
* Request a dry quote (preview without deposit address)
|
|
@@ -2965,6 +2979,13 @@ var SIP = class {
|
|
|
2965
2979
|
senderAddress ?? this.wallet?.address
|
|
2966
2980
|
);
|
|
2967
2981
|
const rawQuote = await this.intentsAdapter.getQuote(prepared);
|
|
2982
|
+
if (!rawQuote.amountOut || !rawQuote.amountIn) {
|
|
2983
|
+
throw new ValidationError(
|
|
2984
|
+
`Invalid quote response from 1Click API: missing ${!rawQuote.amountOut ? "amountOut" : "amountIn"}. This may indicate the trading pair is not supported or the amount is too small.`,
|
|
2985
|
+
"quote",
|
|
2986
|
+
{ rawQuote }
|
|
2987
|
+
);
|
|
2988
|
+
}
|
|
2968
2989
|
this.pendingSwaps.set(requestId, {
|
|
2969
2990
|
depositAddress: rawQuote.depositAddress,
|
|
2970
2991
|
quote: rawQuote
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sip-protocol/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Core SDK for Shielded Intents Protocol - Privacy layer for cross-chain transactions",
|
|
5
5
|
"author": "SIP Protocol <hello@sip-protocol.org>",
|
|
6
6
|
"homepage": "https://sip-protocol.org",
|
|
@@ -91,7 +91,39 @@ export class OneClickClient {
|
|
|
91
91
|
*/
|
|
92
92
|
async quote(request: OneClickQuoteRequest): Promise<OneClickQuoteResponse> {
|
|
93
93
|
this.validateQuoteRequest(request)
|
|
94
|
-
|
|
94
|
+
// The 1Click API returns a nested structure: { quote: {...}, signature, timestamp }
|
|
95
|
+
// We flatten it to match our OneClickQuoteResponse type
|
|
96
|
+
const rawResponse = await this.post<{
|
|
97
|
+
quote: {
|
|
98
|
+
amountIn: string
|
|
99
|
+
amountInFormatted: string
|
|
100
|
+
amountInUsd?: string
|
|
101
|
+
amountOut: string
|
|
102
|
+
amountOutFormatted: string
|
|
103
|
+
amountOutUsd?: string
|
|
104
|
+
depositAddress: string
|
|
105
|
+
deadline: string
|
|
106
|
+
timeEstimate: number
|
|
107
|
+
}
|
|
108
|
+
quoteRequest: OneClickQuoteRequest
|
|
109
|
+
signature: string
|
|
110
|
+
timestamp: string
|
|
111
|
+
}>('/v0/quote', request)
|
|
112
|
+
|
|
113
|
+
// Flatten the response
|
|
114
|
+
return {
|
|
115
|
+
quoteId: rawResponse.timestamp, // Use timestamp as quoteId since API doesn't provide one
|
|
116
|
+
depositAddress: rawResponse.quote.depositAddress,
|
|
117
|
+
amountIn: rawResponse.quote.amountIn,
|
|
118
|
+
amountInFormatted: rawResponse.quote.amountInFormatted,
|
|
119
|
+
amountOut: rawResponse.quote.amountOut,
|
|
120
|
+
amountOutFormatted: rawResponse.quote.amountOutFormatted,
|
|
121
|
+
amountOutUsd: rawResponse.quote.amountOutUsd,
|
|
122
|
+
deadline: rawResponse.quote.deadline,
|
|
123
|
+
timeEstimate: rawResponse.quote.timeEstimate,
|
|
124
|
+
signature: rawResponse.signature,
|
|
125
|
+
request: rawResponse.quoteRequest,
|
|
126
|
+
}
|
|
95
127
|
}
|
|
96
128
|
|
|
97
129
|
/**
|
package/src/sip.ts
CHANGED
|
@@ -448,6 +448,16 @@ export class SIP {
|
|
|
448
448
|
)
|
|
449
449
|
const rawQuote = await this.intentsAdapter.getQuote(prepared)
|
|
450
450
|
|
|
451
|
+
// Validate quote response has required fields
|
|
452
|
+
if (!rawQuote.amountOut || !rawQuote.amountIn) {
|
|
453
|
+
throw new ValidationError(
|
|
454
|
+
`Invalid quote response from 1Click API: missing ${!rawQuote.amountOut ? 'amountOut' : 'amountIn'}. ` +
|
|
455
|
+
`This may indicate the trading pair is not supported or the amount is too small.`,
|
|
456
|
+
'quote',
|
|
457
|
+
{ rawQuote }
|
|
458
|
+
)
|
|
459
|
+
}
|
|
460
|
+
|
|
451
461
|
// Cache for execute()
|
|
452
462
|
this.pendingSwaps.set(requestId, {
|
|
453
463
|
depositAddress: rawQuote.depositAddress,
|