@riftresearch/sdk 0.2.1 → 0.2.2
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/README.md +1 -1
- package/dist/index.d.ts +16 -6
- package/dist/index.js +5 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ const swap = await executeSwap()
|
|
|
68
68
|
console.log(`Swap ID: ${swap.swapId}`) // API order ID
|
|
69
69
|
|
|
70
70
|
// Check status
|
|
71
|
-
const status = await sdk.
|
|
71
|
+
const status = await sdk.getOrderStatus(swap.swapId)
|
|
72
72
|
console.log(`Status: ${status.status}`)
|
|
73
73
|
```
|
|
74
74
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core domain types for Rift Swap Router.
|
|
3
|
+
* Shared between SDK and server packages.
|
|
4
|
+
*/
|
|
5
|
+
type Address = string;
|
|
6
|
+
type TxHash = string;
|
|
1
7
|
type U256 = string;
|
|
2
8
|
type BitcoinChain = {
|
|
3
9
|
kind: "BITCOIN";
|
|
@@ -124,6 +130,10 @@ type QuoteResponse = ExactInputQuoteResponse | ExactOutputQuoteResponse;
|
|
|
124
130
|
type OrderStatus = "waiting_for_deposit" | "deposit_confirming" | "initiating_transfer" | "confirming_transfer" | "swap_complete" | "refunding_user" | "failed";
|
|
125
131
|
interface OrderStatusResponse {
|
|
126
132
|
status: OrderStatus;
|
|
133
|
+
destinationAddress: Address;
|
|
134
|
+
payoutTransaction?: TxHash;
|
|
135
|
+
depositTransaction?: TxHash;
|
|
136
|
+
quote: QuoteResponse;
|
|
127
137
|
}
|
|
128
138
|
/**
|
|
129
139
|
* Execution actions - the mechanism by which a step is executed.
|
|
@@ -359,9 +369,9 @@ interface ExactOutputQuoteResult extends QuoteResultBase {
|
|
|
359
369
|
type QuoteResult = ExactInputQuoteResult | ExactOutputQuoteResult;
|
|
360
370
|
interface GetQuoteResult {
|
|
361
371
|
quote: QuoteResult;
|
|
362
|
-
executeSwap: () => Promise<
|
|
372
|
+
executeSwap: () => Promise<OrderResult>;
|
|
363
373
|
}
|
|
364
|
-
interface
|
|
374
|
+
interface OrderResult {
|
|
365
375
|
swapId: string;
|
|
366
376
|
status: SwapStatus2;
|
|
367
377
|
rift: RiftOrder;
|
|
@@ -440,12 +450,12 @@ declare class RiftSdk {
|
|
|
440
450
|
*/
|
|
441
451
|
private executeBtcTransferStep;
|
|
442
452
|
private buildQuoteResult;
|
|
443
|
-
private
|
|
453
|
+
private buildOrderResult;
|
|
444
454
|
private getAddress;
|
|
445
455
|
private getRefundAddress;
|
|
446
456
|
/**
|
|
447
|
-
* Get the current status of
|
|
457
|
+
* Get the current status of an order by its ID.
|
|
448
458
|
*/
|
|
449
|
-
|
|
459
|
+
getOrderStatus(orderId: string): Promise<OrderStatusResponse>;
|
|
450
460
|
}
|
|
451
|
-
export { getSupportedModes, detectRoute, createClient, TradeParameters, TokenIdentifier, SwapStatus2 as SwapStatus, SwapRoute,
|
|
461
|
+
export { getSupportedModes, detectRoute, createClient, TradeParameters, TokenIdentifier, SwapStatus2 as SwapStatus, SwapRoute, SupportedModes, SendBitcoinFn, RiftSdkOptions, RiftSdk, RiftOrder, RiftClient, QuoteResult, OrderResult, OrderResponse, NativeToken, GetQuoteResult, ExecutionStep, ExecutionAction, EvmChain, EvmCallStep, EvmCallKind, Erc20Token, Currency, Chain, CBBTC_ETHEREUM, CBBTC_BASE, BtcTransferStep, BtcTransferKind, BitcoinChain, BTC, App };
|
package/dist/index.js
CHANGED
|
@@ -197,7 +197,7 @@ class RiftSdk {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
const swap = await this.riftClient.getOrder(orderResponse.swapId);
|
|
200
|
-
return this.
|
|
200
|
+
return this.buildOrderResult(swap, {
|
|
201
201
|
chained: isChained,
|
|
202
202
|
riftOrderId: orderResponse.swapId
|
|
203
203
|
});
|
|
@@ -266,10 +266,10 @@ class RiftSdk {
|
|
|
266
266
|
};
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
|
|
269
|
+
buildOrderResult(swap, options) {
|
|
270
270
|
const riftOrderId = options?.riftOrderId;
|
|
271
271
|
if (!riftOrderId) {
|
|
272
|
-
throw new Error("Missing rift order id for
|
|
272
|
+
throw new Error("Missing rift order id for order result.");
|
|
273
273
|
}
|
|
274
274
|
return {
|
|
275
275
|
swapId: riftOrderId,
|
|
@@ -290,13 +290,8 @@ class RiftSdk {
|
|
|
290
290
|
}
|
|
291
291
|
return this.getAddress();
|
|
292
292
|
}
|
|
293
|
-
async
|
|
294
|
-
|
|
295
|
-
return {
|
|
296
|
-
swapId,
|
|
297
|
-
status: rift.status,
|
|
298
|
-
rift
|
|
299
|
-
};
|
|
293
|
+
async getOrderStatus(orderId) {
|
|
294
|
+
return this.riftClient.getOrder(orderId);
|
|
300
295
|
}
|
|
301
296
|
}
|
|
302
297
|
export {
|