@shogun-sdk/swap 0.0.2-test.33 → 0.0.2-test.35
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/core.cjs +9 -4
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +9 -4
- package/dist/{index-CtZ-hgYk.d.cts → index-BGHbFEV3.d.cts} +9 -2
- package/dist/{index-CXY6BUx9.d.ts → index-DB1gT72l.d.ts} +9 -2
- package/dist/index.cjs +9 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -4
- package/dist/react.cjs +13 -6
- package/dist/react.d.cts +5 -3
- package/dist/react.d.ts +5 -3
- package/dist/react.js +13 -6
- package/dist/wallet-adapter.cjs +77 -77
- package/dist/wallet-adapter.js +77 -77
- package/package.json +2 -2
package/dist/core.cjs
CHANGED
|
@@ -526,7 +526,7 @@ async function buildOrder({
|
|
|
526
526
|
// src/utils/pollOrderStatus.ts
|
|
527
527
|
var import_intents_sdk8 = require("@shogun-sdk/intents-sdk");
|
|
528
528
|
async function pollOrderStatus(address, orderId, options = {}) {
|
|
529
|
-
const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
|
|
529
|
+
const { intervalMs = 2e3, timeoutMs = 3e5, authToken } = options;
|
|
530
530
|
const startTime = Date.now();
|
|
531
531
|
const isDebug = process.env.NODE_ENV !== "production";
|
|
532
532
|
const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
@@ -547,7 +547,12 @@ async function pollOrderStatus(address, orderId, options = {}) {
|
|
|
547
547
|
}
|
|
548
548
|
const res = await fetch(queryUrl, {
|
|
549
549
|
method: "GET",
|
|
550
|
-
headers: {
|
|
550
|
+
headers: {
|
|
551
|
+
"Content-Type": "application/json",
|
|
552
|
+
// The /user_intent status endpoint requires the SIWE JWT; without it
|
|
553
|
+
// the request 401s after the order has already been submitted.
|
|
554
|
+
...authToken ? { Authorization: `Bearer ${authToken}` } : {}
|
|
555
|
+
}
|
|
551
556
|
});
|
|
552
557
|
if (!res.ok) {
|
|
553
558
|
clearInterval(pollInterval);
|
|
@@ -755,7 +760,7 @@ async function handleEvmExecution({
|
|
|
755
760
|
stage: "success"
|
|
756
761
|
};
|
|
757
762
|
} else {
|
|
758
|
-
const status = await pollOrderStatus(accountAddress, orderId);
|
|
763
|
+
const status = await pollOrderStatus(accountAddress, orderId, { authToken: options?.authToken });
|
|
759
764
|
return await handleOrderPollingResult({
|
|
760
765
|
status,
|
|
761
766
|
orderId,
|
|
@@ -825,7 +830,7 @@ async function handleSolanaExecution({
|
|
|
825
830
|
stage: "success"
|
|
826
831
|
};
|
|
827
832
|
} else {
|
|
828
|
-
const status = await pollOrderStatus(accountAddress, orderId);
|
|
833
|
+
const status = await pollOrderStatus(accountAddress, orderId, { authToken: options?.authToken });
|
|
829
834
|
return await handleOrderPollingResult({
|
|
830
835
|
status,
|
|
831
836
|
orderId,
|
package/dist/core.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BalanceRequestParams, e as BalanceResponse, C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, b as SwapQuoteParams, c as SwapQuoteResponse, a as SwapSDK, S as SwapSDKConfig, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-
|
|
1
|
+
export { B as BalanceRequestParams, e as BalanceResponse, C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, b as SwapQuoteParams, c as SwapQuoteResponse, a as SwapSDK, S as SwapSDKConfig, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-BGHbFEV3.cjs';
|
|
2
2
|
import '@shogun-sdk/intents-sdk';
|
|
3
3
|
import './wallet-B9bKceyN.cjs';
|
|
4
4
|
import '@solana/web3.js';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BalanceRequestParams, e as BalanceResponse, C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, b as SwapQuoteParams, c as SwapQuoteResponse, a as SwapSDK, S as SwapSDKConfig, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-
|
|
1
|
+
export { B as BalanceRequestParams, e as BalanceResponse, C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, b as SwapQuoteParams, c as SwapQuoteResponse, a as SwapSDK, S as SwapSDKConfig, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-DB1gT72l.js';
|
|
2
2
|
import '@shogun-sdk/intents-sdk';
|
|
3
3
|
import './wallet-B9bKceyN.js';
|
|
4
4
|
import '@solana/web3.js';
|
package/dist/core.js
CHANGED
|
@@ -503,7 +503,7 @@ async function buildOrder({
|
|
|
503
503
|
// src/utils/pollOrderStatus.ts
|
|
504
504
|
import { AUCTIONEER_URL } from "@shogun-sdk/intents-sdk";
|
|
505
505
|
async function pollOrderStatus(address, orderId, options = {}) {
|
|
506
|
-
const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
|
|
506
|
+
const { intervalMs = 2e3, timeoutMs = 3e5, authToken } = options;
|
|
507
507
|
const startTime = Date.now();
|
|
508
508
|
const isDebug = process.env.NODE_ENV !== "production";
|
|
509
509
|
const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
@@ -524,7 +524,12 @@ async function pollOrderStatus(address, orderId, options = {}) {
|
|
|
524
524
|
}
|
|
525
525
|
const res = await fetch(queryUrl, {
|
|
526
526
|
method: "GET",
|
|
527
|
-
headers: {
|
|
527
|
+
headers: {
|
|
528
|
+
"Content-Type": "application/json",
|
|
529
|
+
// The /user_intent status endpoint requires the SIWE JWT; without it
|
|
530
|
+
// the request 401s after the order has already been submitted.
|
|
531
|
+
...authToken ? { Authorization: `Bearer ${authToken}` } : {}
|
|
532
|
+
}
|
|
528
533
|
});
|
|
529
534
|
if (!res.ok) {
|
|
530
535
|
clearInterval(pollInterval);
|
|
@@ -732,7 +737,7 @@ async function handleEvmExecution({
|
|
|
732
737
|
stage: "success"
|
|
733
738
|
};
|
|
734
739
|
} else {
|
|
735
|
-
const status = await pollOrderStatus(accountAddress, orderId);
|
|
740
|
+
const status = await pollOrderStatus(accountAddress, orderId, { authToken: options?.authToken });
|
|
736
741
|
return await handleOrderPollingResult({
|
|
737
742
|
status,
|
|
738
743
|
orderId,
|
|
@@ -805,7 +810,7 @@ async function handleSolanaExecution({
|
|
|
805
810
|
stage: "success"
|
|
806
811
|
};
|
|
807
812
|
} else {
|
|
808
|
-
const status = await pollOrderStatus(accountAddress, orderId);
|
|
813
|
+
const status = await pollOrderStatus(accountAddress, orderId, { authToken: options?.authToken });
|
|
809
814
|
return await handleOrderPollingResult({
|
|
810
815
|
status,
|
|
811
816
|
orderId,
|
|
@@ -95,10 +95,17 @@ type PlaceOrderResult = {
|
|
|
95
95
|
message: string;
|
|
96
96
|
stage: string;
|
|
97
97
|
};
|
|
98
|
-
interface
|
|
98
|
+
interface BaseOrderOptions {
|
|
99
|
+
/**
|
|
100
|
+
* SIWE-issued JWT (the app's `auctioneer.token`). Forwarded to the
|
|
101
|
+
* authenticated order-status poll so it can read status without a 401.
|
|
102
|
+
*/
|
|
103
|
+
authToken?: string;
|
|
104
|
+
}
|
|
105
|
+
interface MarketOrderOptions extends BaseOrderOptions {
|
|
99
106
|
deadline?: number;
|
|
100
107
|
}
|
|
101
|
-
interface LimitOrderOptions {
|
|
108
|
+
interface LimitOrderOptions extends BaseOrderOptions {
|
|
102
109
|
executionPrice: string;
|
|
103
110
|
deadline: number;
|
|
104
111
|
}
|
|
@@ -95,10 +95,17 @@ type PlaceOrderResult = {
|
|
|
95
95
|
message: string;
|
|
96
96
|
stage: string;
|
|
97
97
|
};
|
|
98
|
-
interface
|
|
98
|
+
interface BaseOrderOptions {
|
|
99
|
+
/**
|
|
100
|
+
* SIWE-issued JWT (the app's `auctioneer.token`). Forwarded to the
|
|
101
|
+
* authenticated order-status poll so it can read status without a 401.
|
|
102
|
+
*/
|
|
103
|
+
authToken?: string;
|
|
104
|
+
}
|
|
105
|
+
interface MarketOrderOptions extends BaseOrderOptions {
|
|
99
106
|
deadline?: number;
|
|
100
107
|
}
|
|
101
|
-
interface LimitOrderOptions {
|
|
108
|
+
interface LimitOrderOptions extends BaseOrderOptions {
|
|
102
109
|
executionPrice: string;
|
|
103
110
|
deadline: number;
|
|
104
111
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -526,7 +526,7 @@ async function buildOrder({
|
|
|
526
526
|
// src/utils/pollOrderStatus.ts
|
|
527
527
|
var import_intents_sdk8 = require("@shogun-sdk/intents-sdk");
|
|
528
528
|
async function pollOrderStatus(address, orderId, options = {}) {
|
|
529
|
-
const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
|
|
529
|
+
const { intervalMs = 2e3, timeoutMs = 3e5, authToken } = options;
|
|
530
530
|
const startTime = Date.now();
|
|
531
531
|
const isDebug = process.env.NODE_ENV !== "production";
|
|
532
532
|
const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
@@ -547,7 +547,12 @@ async function pollOrderStatus(address, orderId, options = {}) {
|
|
|
547
547
|
}
|
|
548
548
|
const res = await fetch(queryUrl, {
|
|
549
549
|
method: "GET",
|
|
550
|
-
headers: {
|
|
550
|
+
headers: {
|
|
551
|
+
"Content-Type": "application/json",
|
|
552
|
+
// The /user_intent status endpoint requires the SIWE JWT; without it
|
|
553
|
+
// the request 401s after the order has already been submitted.
|
|
554
|
+
...authToken ? { Authorization: `Bearer ${authToken}` } : {}
|
|
555
|
+
}
|
|
551
556
|
});
|
|
552
557
|
if (!res.ok) {
|
|
553
558
|
clearInterval(pollInterval);
|
|
@@ -755,7 +760,7 @@ async function handleEvmExecution({
|
|
|
755
760
|
stage: "success"
|
|
756
761
|
};
|
|
757
762
|
} else {
|
|
758
|
-
const status = await pollOrderStatus(accountAddress, orderId);
|
|
763
|
+
const status = await pollOrderStatus(accountAddress, orderId, { authToken: options?.authToken });
|
|
759
764
|
return await handleOrderPollingResult({
|
|
760
765
|
status,
|
|
761
766
|
orderId,
|
|
@@ -825,7 +830,7 @@ async function handleSolanaExecution({
|
|
|
825
830
|
stage: "success"
|
|
826
831
|
};
|
|
827
832
|
} else {
|
|
828
|
-
const status = await pollOrderStatus(accountAddress, orderId);
|
|
833
|
+
const status = await pollOrderStatus(accountAddress, orderId, { authToken: options?.authToken });
|
|
829
834
|
return await handleOrderPollingResult({
|
|
830
835
|
status,
|
|
831
836
|
orderId,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BalanceRequestParams, e as BalanceResponse, C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, b as SwapQuoteParams, c as SwapQuoteResponse, a as SwapSDK, S as SwapSDKConfig, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-
|
|
1
|
+
export { B as BalanceRequestParams, e as BalanceResponse, C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, b as SwapQuoteParams, c as SwapQuoteResponse, a as SwapSDK, S as SwapSDKConfig, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-BGHbFEV3.cjs';
|
|
2
2
|
import '@shogun-sdk/intents-sdk';
|
|
3
3
|
import './wallet-B9bKceyN.cjs';
|
|
4
4
|
import '@solana/web3.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BalanceRequestParams, e as BalanceResponse, C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, b as SwapQuoteParams, c as SwapQuoteResponse, a as SwapSDK, S as SwapSDKConfig, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-
|
|
1
|
+
export { B as BalanceRequestParams, e as BalanceResponse, C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, b as SwapQuoteParams, c as SwapQuoteResponse, a as SwapSDK, S as SwapSDKConfig, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-DB1gT72l.js';
|
|
2
2
|
import '@shogun-sdk/intents-sdk';
|
|
3
3
|
import './wallet-B9bKceyN.js';
|
|
4
4
|
import '@solana/web3.js';
|
package/dist/index.js
CHANGED
|
@@ -503,7 +503,7 @@ async function buildOrder({
|
|
|
503
503
|
// src/utils/pollOrderStatus.ts
|
|
504
504
|
import { AUCTIONEER_URL } from "@shogun-sdk/intents-sdk";
|
|
505
505
|
async function pollOrderStatus(address, orderId, options = {}) {
|
|
506
|
-
const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
|
|
506
|
+
const { intervalMs = 2e3, timeoutMs = 3e5, authToken } = options;
|
|
507
507
|
const startTime = Date.now();
|
|
508
508
|
const isDebug = process.env.NODE_ENV !== "production";
|
|
509
509
|
const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
@@ -524,7 +524,12 @@ async function pollOrderStatus(address, orderId, options = {}) {
|
|
|
524
524
|
}
|
|
525
525
|
const res = await fetch(queryUrl, {
|
|
526
526
|
method: "GET",
|
|
527
|
-
headers: {
|
|
527
|
+
headers: {
|
|
528
|
+
"Content-Type": "application/json",
|
|
529
|
+
// The /user_intent status endpoint requires the SIWE JWT; without it
|
|
530
|
+
// the request 401s after the order has already been submitted.
|
|
531
|
+
...authToken ? { Authorization: `Bearer ${authToken}` } : {}
|
|
532
|
+
}
|
|
528
533
|
});
|
|
529
534
|
if (!res.ok) {
|
|
530
535
|
clearInterval(pollInterval);
|
|
@@ -732,7 +737,7 @@ async function handleEvmExecution({
|
|
|
732
737
|
stage: "success"
|
|
733
738
|
};
|
|
734
739
|
} else {
|
|
735
|
-
const status = await pollOrderStatus(accountAddress, orderId);
|
|
740
|
+
const status = await pollOrderStatus(accountAddress, orderId, { authToken: options?.authToken });
|
|
736
741
|
return await handleOrderPollingResult({
|
|
737
742
|
status,
|
|
738
743
|
orderId,
|
|
@@ -805,7 +810,7 @@ async function handleSolanaExecution({
|
|
|
805
810
|
stage: "success"
|
|
806
811
|
};
|
|
807
812
|
} else {
|
|
808
|
-
const status = await pollOrderStatus(accountAddress, orderId);
|
|
813
|
+
const status = await pollOrderStatus(accountAddress, orderId, { authToken: options?.authToken });
|
|
809
814
|
return await handleOrderPollingResult({
|
|
810
815
|
status,
|
|
811
816
|
orderId,
|
package/dist/react.cjs
CHANGED
|
@@ -547,7 +547,7 @@ async function buildOrder({
|
|
|
547
547
|
// src/utils/pollOrderStatus.ts
|
|
548
548
|
var import_intents_sdk8 = require("@shogun-sdk/intents-sdk");
|
|
549
549
|
async function pollOrderStatus(address, orderId, options = {}) {
|
|
550
|
-
const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
|
|
550
|
+
const { intervalMs = 2e3, timeoutMs = 3e5, authToken } = options;
|
|
551
551
|
const startTime = Date.now();
|
|
552
552
|
const isDebug = process.env.NODE_ENV !== "production";
|
|
553
553
|
const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
@@ -568,7 +568,12 @@ async function pollOrderStatus(address, orderId, options = {}) {
|
|
|
568
568
|
}
|
|
569
569
|
const res = await fetch(queryUrl, {
|
|
570
570
|
method: "GET",
|
|
571
|
-
headers: {
|
|
571
|
+
headers: {
|
|
572
|
+
"Content-Type": "application/json",
|
|
573
|
+
// The /user_intent status endpoint requires the SIWE JWT; without it
|
|
574
|
+
// the request 401s after the order has already been submitted.
|
|
575
|
+
...authToken ? { Authorization: `Bearer ${authToken}` } : {}
|
|
576
|
+
}
|
|
572
577
|
});
|
|
573
578
|
if (!res.ok) {
|
|
574
579
|
clearInterval(pollInterval);
|
|
@@ -776,7 +781,7 @@ async function handleEvmExecution({
|
|
|
776
781
|
stage: "success"
|
|
777
782
|
};
|
|
778
783
|
} else {
|
|
779
|
-
const status = await pollOrderStatus(accountAddress, orderId);
|
|
784
|
+
const status = await pollOrderStatus(accountAddress, orderId, { authToken: options?.authToken });
|
|
780
785
|
return await handleOrderPollingResult({
|
|
781
786
|
status,
|
|
782
787
|
orderId,
|
|
@@ -846,7 +851,7 @@ async function handleSolanaExecution({
|
|
|
846
851
|
stage: "success"
|
|
847
852
|
};
|
|
848
853
|
} else {
|
|
849
|
-
const status = await pollOrderStatus(accountAddress, orderId);
|
|
854
|
+
const status = await pollOrderStatus(accountAddress, orderId, { authToken: options?.authToken });
|
|
850
855
|
return await handleOrderPollingResult({
|
|
851
856
|
status,
|
|
852
857
|
orderId,
|
|
@@ -1558,7 +1563,7 @@ var import_react4 = require("react");
|
|
|
1558
1563
|
var import_react3 = require("react");
|
|
1559
1564
|
var import_swr2 = __toESM(require("swr"), 1);
|
|
1560
1565
|
var BALANCE_KEY = "balances-global";
|
|
1561
|
-
function useBalances(initialParams) {
|
|
1566
|
+
function useBalances(initialParams, options) {
|
|
1562
1567
|
const sdk = useSwap();
|
|
1563
1568
|
const abortRef = (0, import_react3.useRef)(null);
|
|
1564
1569
|
const paramsRef = globalThis.__BALANCES_PARAMS_REF__ ?? (globalThis.__BALANCES_PARAMS_REF__ = { current: initialParams ?? null });
|
|
@@ -1584,7 +1589,9 @@ function useBalances(initialParams) {
|
|
|
1584
1589
|
} = (0, import_swr2.default)(BALANCE_KEY, fetcher, {
|
|
1585
1590
|
revalidateOnFocus: false,
|
|
1586
1591
|
shouldRetryOnError: false,
|
|
1587
|
-
keepPreviousData: true
|
|
1592
|
+
keepPreviousData: true,
|
|
1593
|
+
// 0 (default) disables polling; a positive value re-fetches on that interval.
|
|
1594
|
+
refreshInterval: options?.refreshInterval ?? 0
|
|
1588
1595
|
});
|
|
1589
1596
|
const refetch = (0, import_react3.useCallback)(async () => {
|
|
1590
1597
|
await mutateBalances();
|
package/dist/react.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { S as SwapSDKConfig, a as SwapSDK, b as SwapQuoteParams, c as SwapQuoteResponse, E as ExecuteOrderParams, d as Stage, P as PlaceOrderResult, T as TokenInfo, B as BalanceRequestParams, e as BalanceResponse } from './index-
|
|
3
|
-
export { C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-
|
|
2
|
+
import { S as SwapSDKConfig, a as SwapSDK, b as SwapQuoteParams, c as SwapQuoteResponse, E as ExecuteOrderParams, d as Stage, P as PlaceOrderResult, T as TokenInfo, B as BalanceRequestParams, e as BalanceResponse } from './index-BGHbFEV3.cjs';
|
|
3
|
+
export { C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-BGHbFEV3.cjs';
|
|
4
4
|
import { WalletClient } from 'viem';
|
|
5
5
|
import { A as AdaptedWallet } from './wallet-B9bKceyN.cjs';
|
|
6
6
|
import { ApiUserOrders, ApiCrossChainOrder, ApiSingleChainOrder } from '@shogun-sdk/intents-sdk';
|
|
@@ -197,7 +197,9 @@ declare global {
|
|
|
197
197
|
* - Keeps previous data during refetch (no reset)
|
|
198
198
|
* - Auto-refetch when initialParams change (svm_address or evm_address)
|
|
199
199
|
*/
|
|
200
|
-
declare function useBalances(initialParams?: BalanceRequestParams | null
|
|
200
|
+
declare function useBalances(initialParams?: BalanceRequestParams | null, options?: {
|
|
201
|
+
refreshInterval?: number;
|
|
202
|
+
}): {
|
|
201
203
|
data: BalanceResponse | null | undefined;
|
|
202
204
|
loading: boolean;
|
|
203
205
|
error: Error | null;
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { S as SwapSDKConfig, a as SwapSDK, b as SwapQuoteParams, c as SwapQuoteResponse, E as ExecuteOrderParams, d as Stage, P as PlaceOrderResult, T as TokenInfo, B as BalanceRequestParams, e as BalanceResponse } from './index-
|
|
3
|
-
export { C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-
|
|
2
|
+
import { S as SwapSDKConfig, a as SwapSDK, b as SwapQuoteParams, c as SwapQuoteResponse, E as ExecuteOrderParams, d as Stage, P as PlaceOrderResult, T as TokenInfo, B as BalanceRequestParams, e as BalanceResponse } from './index-DB1gT72l.js';
|
|
3
|
+
export { C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-DB1gT72l.js';
|
|
4
4
|
import { WalletClient } from 'viem';
|
|
5
5
|
import { A as AdaptedWallet } from './wallet-B9bKceyN.js';
|
|
6
6
|
import { ApiUserOrders, ApiCrossChainOrder, ApiSingleChainOrder } from '@shogun-sdk/intents-sdk';
|
|
@@ -197,7 +197,9 @@ declare global {
|
|
|
197
197
|
* - Keeps previous data during refetch (no reset)
|
|
198
198
|
* - Auto-refetch when initialParams change (svm_address or evm_address)
|
|
199
199
|
*/
|
|
200
|
-
declare function useBalances(initialParams?: BalanceRequestParams | null
|
|
200
|
+
declare function useBalances(initialParams?: BalanceRequestParams | null, options?: {
|
|
201
|
+
refreshInterval?: number;
|
|
202
|
+
}): {
|
|
201
203
|
data: BalanceResponse | null | undefined;
|
|
202
204
|
loading: boolean;
|
|
203
205
|
error: Error | null;
|
package/dist/react.js
CHANGED
|
@@ -506,7 +506,7 @@ async function buildOrder({
|
|
|
506
506
|
// src/utils/pollOrderStatus.ts
|
|
507
507
|
import { AUCTIONEER_URL } from "@shogun-sdk/intents-sdk";
|
|
508
508
|
async function pollOrderStatus(address, orderId, options = {}) {
|
|
509
|
-
const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
|
|
509
|
+
const { intervalMs = 2e3, timeoutMs = 3e5, authToken } = options;
|
|
510
510
|
const startTime = Date.now();
|
|
511
511
|
const isDebug = process.env.NODE_ENV !== "production";
|
|
512
512
|
const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
@@ -527,7 +527,12 @@ async function pollOrderStatus(address, orderId, options = {}) {
|
|
|
527
527
|
}
|
|
528
528
|
const res = await fetch(queryUrl, {
|
|
529
529
|
method: "GET",
|
|
530
|
-
headers: {
|
|
530
|
+
headers: {
|
|
531
|
+
"Content-Type": "application/json",
|
|
532
|
+
// The /user_intent status endpoint requires the SIWE JWT; without it
|
|
533
|
+
// the request 401s after the order has already been submitted.
|
|
534
|
+
...authToken ? { Authorization: `Bearer ${authToken}` } : {}
|
|
535
|
+
}
|
|
531
536
|
});
|
|
532
537
|
if (!res.ok) {
|
|
533
538
|
clearInterval(pollInterval);
|
|
@@ -735,7 +740,7 @@ async function handleEvmExecution({
|
|
|
735
740
|
stage: "success"
|
|
736
741
|
};
|
|
737
742
|
} else {
|
|
738
|
-
const status = await pollOrderStatus(accountAddress, orderId);
|
|
743
|
+
const status = await pollOrderStatus(accountAddress, orderId, { authToken: options?.authToken });
|
|
739
744
|
return await handleOrderPollingResult({
|
|
740
745
|
status,
|
|
741
746
|
orderId,
|
|
@@ -808,7 +813,7 @@ async function handleSolanaExecution({
|
|
|
808
813
|
stage: "success"
|
|
809
814
|
};
|
|
810
815
|
} else {
|
|
811
|
-
const status = await pollOrderStatus(accountAddress, orderId);
|
|
816
|
+
const status = await pollOrderStatus(accountAddress, orderId, { authToken: options?.authToken });
|
|
812
817
|
return await handleOrderPollingResult({
|
|
813
818
|
status,
|
|
814
819
|
orderId,
|
|
@@ -1530,7 +1535,7 @@ import { useState, useCallback as useCallback3 } from "react";
|
|
|
1530
1535
|
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo3, useRef as useRef2 } from "react";
|
|
1531
1536
|
import useSWR2, { mutate as mutate2 } from "swr";
|
|
1532
1537
|
var BALANCE_KEY = "balances-global";
|
|
1533
|
-
function useBalances(initialParams) {
|
|
1538
|
+
function useBalances(initialParams, options) {
|
|
1534
1539
|
const sdk = useSwap();
|
|
1535
1540
|
const abortRef = useRef2(null);
|
|
1536
1541
|
const paramsRef = globalThis.__BALANCES_PARAMS_REF__ ?? (globalThis.__BALANCES_PARAMS_REF__ = { current: initialParams ?? null });
|
|
@@ -1556,7 +1561,9 @@ function useBalances(initialParams) {
|
|
|
1556
1561
|
} = useSWR2(BALANCE_KEY, fetcher, {
|
|
1557
1562
|
revalidateOnFocus: false,
|
|
1558
1563
|
shouldRetryOnError: false,
|
|
1559
|
-
keepPreviousData: true
|
|
1564
|
+
keepPreviousData: true,
|
|
1565
|
+
// 0 (default) disables polling; a positive value re-fetches on that interval.
|
|
1566
|
+
refreshInterval: options?.refreshInterval ?? 0
|
|
1560
1567
|
});
|
|
1561
1568
|
const refetch = useCallback2(async () => {
|
|
1562
1569
|
await mutateBalances();
|