@shogun-sdk/swap 0.0.2-test.37 → 0.0.2-test.39
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 +13 -1
- package/dist/core.js +13 -1
- package/dist/index.cjs +13 -1
- package/dist/index.js +13 -1
- package/dist/react.cjs +26 -5
- package/dist/react.d.cts +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +26 -5
- package/package.json +2 -2
package/dist/core.cjs
CHANGED
|
@@ -997,7 +997,19 @@ async function getOrders({
|
|
|
997
997
|
var import_intents_sdk14 = require("@shogun-sdk/intents-sdk");
|
|
998
998
|
var import_web32 = require("@solana/web3.js");
|
|
999
999
|
var import_viem8 = require("viem");
|
|
1000
|
-
|
|
1000
|
+
var inFlightCancels = /* @__PURE__ */ new Map();
|
|
1001
|
+
function cancelIntentsOrder(args) {
|
|
1002
|
+
const srcChain = "srcChainId" in args.order ? args.order.srcChainId : args.order.chainId;
|
|
1003
|
+
const key = `${srcChain}:${args.order.orderId}`;
|
|
1004
|
+
const existing = inFlightCancels.get(key);
|
|
1005
|
+
if (existing) return existing;
|
|
1006
|
+
const pending = performCancel(args).finally(() => {
|
|
1007
|
+
inFlightCancels.delete(key);
|
|
1008
|
+
});
|
|
1009
|
+
inFlightCancels.set(key, pending);
|
|
1010
|
+
return pending;
|
|
1011
|
+
}
|
|
1012
|
+
async function performCancel({
|
|
1001
1013
|
order,
|
|
1002
1014
|
wallet,
|
|
1003
1015
|
sol_rpc
|
package/dist/core.js
CHANGED
|
@@ -987,7 +987,19 @@ import {
|
|
|
987
987
|
VersionedTransaction as VersionedTransaction2
|
|
988
988
|
} from "@solana/web3.js";
|
|
989
989
|
import { encodeFunctionData as encodeFunctionData3 } from "viem";
|
|
990
|
-
|
|
990
|
+
var inFlightCancels = /* @__PURE__ */ new Map();
|
|
991
|
+
function cancelIntentsOrder(args) {
|
|
992
|
+
const srcChain = "srcChainId" in args.order ? args.order.srcChainId : args.order.chainId;
|
|
993
|
+
const key = `${srcChain}:${args.order.orderId}`;
|
|
994
|
+
const existing = inFlightCancels.get(key);
|
|
995
|
+
if (existing) return existing;
|
|
996
|
+
const pending = performCancel(args).finally(() => {
|
|
997
|
+
inFlightCancels.delete(key);
|
|
998
|
+
});
|
|
999
|
+
inFlightCancels.set(key, pending);
|
|
1000
|
+
return pending;
|
|
1001
|
+
}
|
|
1002
|
+
async function performCancel({
|
|
991
1003
|
order,
|
|
992
1004
|
wallet,
|
|
993
1005
|
sol_rpc
|
package/dist/index.cjs
CHANGED
|
@@ -997,7 +997,19 @@ async function getOrders({
|
|
|
997
997
|
var import_intents_sdk14 = require("@shogun-sdk/intents-sdk");
|
|
998
998
|
var import_web32 = require("@solana/web3.js");
|
|
999
999
|
var import_viem8 = require("viem");
|
|
1000
|
-
|
|
1000
|
+
var inFlightCancels = /* @__PURE__ */ new Map();
|
|
1001
|
+
function cancelIntentsOrder(args) {
|
|
1002
|
+
const srcChain = "srcChainId" in args.order ? args.order.srcChainId : args.order.chainId;
|
|
1003
|
+
const key = `${srcChain}:${args.order.orderId}`;
|
|
1004
|
+
const existing = inFlightCancels.get(key);
|
|
1005
|
+
if (existing) return existing;
|
|
1006
|
+
const pending = performCancel(args).finally(() => {
|
|
1007
|
+
inFlightCancels.delete(key);
|
|
1008
|
+
});
|
|
1009
|
+
inFlightCancels.set(key, pending);
|
|
1010
|
+
return pending;
|
|
1011
|
+
}
|
|
1012
|
+
async function performCancel({
|
|
1001
1013
|
order,
|
|
1002
1014
|
wallet,
|
|
1003
1015
|
sol_rpc
|
package/dist/index.js
CHANGED
|
@@ -987,7 +987,19 @@ import {
|
|
|
987
987
|
VersionedTransaction as VersionedTransaction2
|
|
988
988
|
} from "@solana/web3.js";
|
|
989
989
|
import { encodeFunctionData as encodeFunctionData3 } from "viem";
|
|
990
|
-
|
|
990
|
+
var inFlightCancels = /* @__PURE__ */ new Map();
|
|
991
|
+
function cancelIntentsOrder(args) {
|
|
992
|
+
const srcChain = "srcChainId" in args.order ? args.order.srcChainId : args.order.chainId;
|
|
993
|
+
const key = `${srcChain}:${args.order.orderId}`;
|
|
994
|
+
const existing = inFlightCancels.get(key);
|
|
995
|
+
if (existing) return existing;
|
|
996
|
+
const pending = performCancel(args).finally(() => {
|
|
997
|
+
inFlightCancels.delete(key);
|
|
998
|
+
});
|
|
999
|
+
inFlightCancels.set(key, pending);
|
|
1000
|
+
return pending;
|
|
1001
|
+
}
|
|
1002
|
+
async function performCancel({
|
|
991
1003
|
order,
|
|
992
1004
|
wallet,
|
|
993
1005
|
sol_rpc
|
package/dist/react.cjs
CHANGED
|
@@ -1018,7 +1018,19 @@ async function getOrders({
|
|
|
1018
1018
|
var import_intents_sdk14 = require("@shogun-sdk/intents-sdk");
|
|
1019
1019
|
var import_web32 = require("@solana/web3.js");
|
|
1020
1020
|
var import_viem8 = require("viem");
|
|
1021
|
-
|
|
1021
|
+
var inFlightCancels = /* @__PURE__ */ new Map();
|
|
1022
|
+
function cancelIntentsOrder(args) {
|
|
1023
|
+
const srcChain = "srcChainId" in args.order ? args.order.srcChainId : args.order.chainId;
|
|
1024
|
+
const key = `${srcChain}:${args.order.orderId}`;
|
|
1025
|
+
const existing = inFlightCancels.get(key);
|
|
1026
|
+
if (existing) return existing;
|
|
1027
|
+
const pending = performCancel(args).finally(() => {
|
|
1028
|
+
inFlightCancels.delete(key);
|
|
1029
|
+
});
|
|
1030
|
+
inFlightCancels.set(key, pending);
|
|
1031
|
+
return pending;
|
|
1032
|
+
}
|
|
1033
|
+
async function performCancel({
|
|
1022
1034
|
order,
|
|
1023
1035
|
wallet,
|
|
1024
1036
|
sol_rpc
|
|
@@ -1578,6 +1590,7 @@ var BALANCE_KEY = "balances-global";
|
|
|
1578
1590
|
function useBalances(initialParams, options) {
|
|
1579
1591
|
const sdk = useSwap();
|
|
1580
1592
|
const abortRef = (0, import_react3.useRef)(null);
|
|
1593
|
+
const lastDataRef = (0, import_react3.useRef)(null);
|
|
1581
1594
|
const paramsRef = globalThis.__BALANCES_PARAMS_REF__ ?? (globalThis.__BALANCES_PARAMS_REF__ = { current: initialParams ?? null });
|
|
1582
1595
|
const fetcher = (0, import_react3.useCallback)(async () => {
|
|
1583
1596
|
const activeParams = paramsRef.current;
|
|
@@ -1586,9 +1599,11 @@ function useBalances(initialParams, options) {
|
|
|
1586
1599
|
const controller = new AbortController();
|
|
1587
1600
|
abortRef.current = controller;
|
|
1588
1601
|
try {
|
|
1589
|
-
|
|
1602
|
+
const balances = await sdk.getBalances(activeParams, { signal: controller.signal });
|
|
1603
|
+
lastDataRef.current = balances;
|
|
1604
|
+
return balances;
|
|
1590
1605
|
} catch (err) {
|
|
1591
|
-
if (err instanceof DOMException && err.name === "AbortError") return
|
|
1606
|
+
if (err instanceof DOMException && err.name === "AbortError") return lastDataRef.current;
|
|
1592
1607
|
if (err instanceof Error) throw err;
|
|
1593
1608
|
throw new Error(String(err));
|
|
1594
1609
|
}
|
|
@@ -1596,7 +1611,10 @@ function useBalances(initialParams, options) {
|
|
|
1596
1611
|
const {
|
|
1597
1612
|
data,
|
|
1598
1613
|
error,
|
|
1599
|
-
|
|
1614
|
+
// `isLoading` is only true on the initial fetch (no data yet), so background
|
|
1615
|
+
// refreshes on `refreshInterval` don't toggle it and flicker the UI.
|
|
1616
|
+
isLoading: loading,
|
|
1617
|
+
isValidating,
|
|
1600
1618
|
mutate: mutateBalances
|
|
1601
1619
|
} = (0, import_swr2.default)(BALANCE_KEY, fetcher, {
|
|
1602
1620
|
revalidateOnFocus: false,
|
|
@@ -1626,6 +1644,9 @@ function useBalances(initialParams, options) {
|
|
|
1626
1644
|
() => ({
|
|
1627
1645
|
data,
|
|
1628
1646
|
loading,
|
|
1647
|
+
// True during background revalidation (e.g. `refreshInterval` polls) while
|
|
1648
|
+
// previous `data` stays visible — use for a subtle refresh indicator.
|
|
1649
|
+
isValidating,
|
|
1629
1650
|
error: error instanceof Error ? error : null,
|
|
1630
1651
|
refetch,
|
|
1631
1652
|
setParams,
|
|
@@ -1633,7 +1654,7 @@ function useBalances(initialParams, options) {
|
|
|
1633
1654
|
return paramsRef.current;
|
|
1634
1655
|
}
|
|
1635
1656
|
}),
|
|
1636
|
-
[data, loading, error, refetch, setParams, paramsRef]
|
|
1657
|
+
[data, loading, isValidating, error, refetch, setParams, paramsRef]
|
|
1637
1658
|
);
|
|
1638
1659
|
}
|
|
1639
1660
|
|
package/dist/react.d.cts
CHANGED
|
@@ -202,6 +202,7 @@ declare function useBalances(initialParams?: BalanceRequestParams | null, option
|
|
|
202
202
|
}): {
|
|
203
203
|
data: BalanceResponse | null | undefined;
|
|
204
204
|
loading: boolean;
|
|
205
|
+
isValidating: boolean;
|
|
205
206
|
error: Error | null;
|
|
206
207
|
refetch: () => Promise<void>;
|
|
207
208
|
setParams: (next: BalanceRequestParams | null) => void;
|
package/dist/react.d.ts
CHANGED
|
@@ -202,6 +202,7 @@ declare function useBalances(initialParams?: BalanceRequestParams | null, option
|
|
|
202
202
|
}): {
|
|
203
203
|
data: BalanceResponse | null | undefined;
|
|
204
204
|
loading: boolean;
|
|
205
|
+
isValidating: boolean;
|
|
205
206
|
error: Error | null;
|
|
206
207
|
refetch: () => Promise<void>;
|
|
207
208
|
setParams: (next: BalanceRequestParams | null) => void;
|
package/dist/react.js
CHANGED
|
@@ -990,7 +990,19 @@ import {
|
|
|
990
990
|
VersionedTransaction as VersionedTransaction2
|
|
991
991
|
} from "@solana/web3.js";
|
|
992
992
|
import { encodeFunctionData as encodeFunctionData3 } from "viem";
|
|
993
|
-
|
|
993
|
+
var inFlightCancels = /* @__PURE__ */ new Map();
|
|
994
|
+
function cancelIntentsOrder(args) {
|
|
995
|
+
const srcChain = "srcChainId" in args.order ? args.order.srcChainId : args.order.chainId;
|
|
996
|
+
const key = `${srcChain}:${args.order.orderId}`;
|
|
997
|
+
const existing = inFlightCancels.get(key);
|
|
998
|
+
if (existing) return existing;
|
|
999
|
+
const pending = performCancel(args).finally(() => {
|
|
1000
|
+
inFlightCancels.delete(key);
|
|
1001
|
+
});
|
|
1002
|
+
inFlightCancels.set(key, pending);
|
|
1003
|
+
return pending;
|
|
1004
|
+
}
|
|
1005
|
+
async function performCancel({
|
|
994
1006
|
order,
|
|
995
1007
|
wallet,
|
|
996
1008
|
sol_rpc
|
|
@@ -1550,6 +1562,7 @@ var BALANCE_KEY = "balances-global";
|
|
|
1550
1562
|
function useBalances(initialParams, options) {
|
|
1551
1563
|
const sdk = useSwap();
|
|
1552
1564
|
const abortRef = useRef2(null);
|
|
1565
|
+
const lastDataRef = useRef2(null);
|
|
1553
1566
|
const paramsRef = globalThis.__BALANCES_PARAMS_REF__ ?? (globalThis.__BALANCES_PARAMS_REF__ = { current: initialParams ?? null });
|
|
1554
1567
|
const fetcher = useCallback2(async () => {
|
|
1555
1568
|
const activeParams = paramsRef.current;
|
|
@@ -1558,9 +1571,11 @@ function useBalances(initialParams, options) {
|
|
|
1558
1571
|
const controller = new AbortController();
|
|
1559
1572
|
abortRef.current = controller;
|
|
1560
1573
|
try {
|
|
1561
|
-
|
|
1574
|
+
const balances = await sdk.getBalances(activeParams, { signal: controller.signal });
|
|
1575
|
+
lastDataRef.current = balances;
|
|
1576
|
+
return balances;
|
|
1562
1577
|
} catch (err) {
|
|
1563
|
-
if (err instanceof DOMException && err.name === "AbortError") return
|
|
1578
|
+
if (err instanceof DOMException && err.name === "AbortError") return lastDataRef.current;
|
|
1564
1579
|
if (err instanceof Error) throw err;
|
|
1565
1580
|
throw new Error(String(err));
|
|
1566
1581
|
}
|
|
@@ -1568,7 +1583,10 @@ function useBalances(initialParams, options) {
|
|
|
1568
1583
|
const {
|
|
1569
1584
|
data,
|
|
1570
1585
|
error,
|
|
1571
|
-
|
|
1586
|
+
// `isLoading` is only true on the initial fetch (no data yet), so background
|
|
1587
|
+
// refreshes on `refreshInterval` don't toggle it and flicker the UI.
|
|
1588
|
+
isLoading: loading,
|
|
1589
|
+
isValidating,
|
|
1572
1590
|
mutate: mutateBalances
|
|
1573
1591
|
} = useSWR2(BALANCE_KEY, fetcher, {
|
|
1574
1592
|
revalidateOnFocus: false,
|
|
@@ -1598,6 +1616,9 @@ function useBalances(initialParams, options) {
|
|
|
1598
1616
|
() => ({
|
|
1599
1617
|
data,
|
|
1600
1618
|
loading,
|
|
1619
|
+
// True during background revalidation (e.g. `refreshInterval` polls) while
|
|
1620
|
+
// previous `data` stays visible — use for a subtle refresh indicator.
|
|
1621
|
+
isValidating,
|
|
1601
1622
|
error: error instanceof Error ? error : null,
|
|
1602
1623
|
refetch,
|
|
1603
1624
|
setParams,
|
|
@@ -1605,7 +1626,7 @@ function useBalances(initialParams, options) {
|
|
|
1605
1626
|
return paramsRef.current;
|
|
1606
1627
|
}
|
|
1607
1628
|
}),
|
|
1608
|
-
[data, loading, error, refetch, setParams, paramsRef]
|
|
1629
|
+
[data, loading, isValidating, error, refetch, setParams, paramsRef]
|
|
1609
1630
|
);
|
|
1610
1631
|
}
|
|
1611
1632
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shogun-sdk/swap",
|
|
3
|
-
"version": "0.0.2-test.
|
|
3
|
+
"version": "0.0.2-test.39",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shogun Network Swap utilities and helpers",
|
|
6
6
|
"author": "Shogun Network",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"sideEffects": false,
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@solana/web3.js": "^1.98.4",
|
|
48
|
-
"@shogun-sdk/intents-sdk": "1.4.
|
|
48
|
+
"@shogun-sdk/intents-sdk": "1.4.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@ethersproject/abstract-signer": "^5.7.0",
|