@shogun-sdk/swap 0.0.2-test.26 → 0.0.2-test.27
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 +40 -2
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +40 -2
- package/dist/{index-D62OxLwp.d.cts → index-CmsKzdEu.d.cts} +27 -1
- package/dist/{index-Czt8I0Vg.d.ts → index-Qoc6Q9XN.d.ts} +27 -1
- package/dist/index.cjs +40 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -2
- package/dist/react.cjs +110 -2
- package/dist/react.d.cts +70 -4
- package/dist/react.d.ts +70 -4
- package/dist/react.js +110 -2
- package/package.json +2 -2
package/dist/core.cjs
CHANGED
|
@@ -803,7 +803,7 @@ async function handleSolanaExecution({
|
|
|
803
803
|
throw new Error("Auctioneer submission failed");
|
|
804
804
|
}
|
|
805
805
|
update("initiated", messageFor("initiated"));
|
|
806
|
-
const {
|
|
806
|
+
const { intentId: orderId } = response.data;
|
|
807
807
|
update("initiated", messageFor("shogun_processing"));
|
|
808
808
|
if (orderType === "limit" /* LIMIT */) {
|
|
809
809
|
update("success", messageFor("success_limit"));
|
|
@@ -815,7 +815,7 @@ async function handleSolanaExecution({
|
|
|
815
815
|
stage: "success"
|
|
816
816
|
};
|
|
817
817
|
} else {
|
|
818
|
-
const status = await pollOrderStatus(
|
|
818
|
+
const status = await pollOrderStatus(accountAddress, orderId);
|
|
819
819
|
return await handleOrderPollingResult({
|
|
820
820
|
status,
|
|
821
821
|
orderId,
|
|
@@ -953,6 +953,19 @@ function normalizeWallet(wallet) {
|
|
|
953
953
|
return wallet;
|
|
954
954
|
}
|
|
955
955
|
|
|
956
|
+
// src/core/orders/getOrders.ts
|
|
957
|
+
var import_intents_sdk13 = require("@shogun-sdk/intents-sdk");
|
|
958
|
+
async function getOrders({
|
|
959
|
+
evmAddress,
|
|
960
|
+
solAddress
|
|
961
|
+
}) {
|
|
962
|
+
if (!evmAddress && !solAddress) {
|
|
963
|
+
throw new Error("At least one wallet address (EVM, Solana) must be provided.");
|
|
964
|
+
}
|
|
965
|
+
const orders = await (0, import_intents_sdk13.fetchUserOrders)(evmAddress, solAddress);
|
|
966
|
+
return orders;
|
|
967
|
+
}
|
|
968
|
+
|
|
956
969
|
// src/core/client.ts
|
|
957
970
|
var SwapSDK = class {
|
|
958
971
|
constructor(config) {
|
|
@@ -1088,4 +1101,29 @@ var SwapSDK = class {
|
|
|
1088
1101
|
options
|
|
1089
1102
|
});
|
|
1090
1103
|
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Fetches all user orders (Market, Limit, Cross-chain) for connected wallets.
|
|
1106
|
+
*
|
|
1107
|
+
* ---
|
|
1108
|
+
* ### Overview
|
|
1109
|
+
* Retrieves both **single-chain** and **cross-chain** orders from the Shogun Intents API.
|
|
1110
|
+
* Works across EVM, Solana
|
|
1111
|
+
*
|
|
1112
|
+
* ---
|
|
1113
|
+
* @example
|
|
1114
|
+
* ```ts
|
|
1115
|
+
* const orders = await sdk.getOrders({
|
|
1116
|
+
* evmAddress: "0x123...",
|
|
1117
|
+
* solAddress: "9d12hF...abc",
|
|
1118
|
+
* });
|
|
1119
|
+
*
|
|
1120
|
+
* console.log(orders.singleChainLimitOrders);
|
|
1121
|
+
* ```
|
|
1122
|
+
*
|
|
1123
|
+
* @param params - Wallet addresses to fetch orders for (EVM, Solana).
|
|
1124
|
+
* @returns A structured {@link ApiUserOrders} object containing all user orders.
|
|
1125
|
+
*/
|
|
1126
|
+
async getOrders(params) {
|
|
1127
|
+
return getOrders(params);
|
|
1128
|
+
}
|
|
1091
1129
|
};
|
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-CmsKzdEu.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-Qoc6Q9XN.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
|
@@ -783,7 +783,7 @@ async function handleSolanaExecution({
|
|
|
783
783
|
throw new Error("Auctioneer submission failed");
|
|
784
784
|
}
|
|
785
785
|
update("initiated", messageFor("initiated"));
|
|
786
|
-
const {
|
|
786
|
+
const { intentId: orderId } = response.data;
|
|
787
787
|
update("initiated", messageFor("shogun_processing"));
|
|
788
788
|
if (orderType === "limit" /* LIMIT */) {
|
|
789
789
|
update("success", messageFor("success_limit"));
|
|
@@ -795,7 +795,7 @@ async function handleSolanaExecution({
|
|
|
795
795
|
stage: "success"
|
|
796
796
|
};
|
|
797
797
|
} else {
|
|
798
|
-
const status = await pollOrderStatus(
|
|
798
|
+
const status = await pollOrderStatus(accountAddress, orderId);
|
|
799
799
|
return await handleOrderPollingResult({
|
|
800
800
|
status,
|
|
801
801
|
orderId,
|
|
@@ -933,6 +933,19 @@ function normalizeWallet(wallet) {
|
|
|
933
933
|
return wallet;
|
|
934
934
|
}
|
|
935
935
|
|
|
936
|
+
// src/core/orders/getOrders.ts
|
|
937
|
+
import { fetchUserOrders } from "@shogun-sdk/intents-sdk";
|
|
938
|
+
async function getOrders({
|
|
939
|
+
evmAddress,
|
|
940
|
+
solAddress
|
|
941
|
+
}) {
|
|
942
|
+
if (!evmAddress && !solAddress) {
|
|
943
|
+
throw new Error("At least one wallet address (EVM, Solana) must be provided.");
|
|
944
|
+
}
|
|
945
|
+
const orders = await fetchUserOrders(evmAddress, solAddress);
|
|
946
|
+
return orders;
|
|
947
|
+
}
|
|
948
|
+
|
|
936
949
|
// src/core/client.ts
|
|
937
950
|
var SwapSDK = class {
|
|
938
951
|
constructor(config) {
|
|
@@ -1068,6 +1081,31 @@ var SwapSDK = class {
|
|
|
1068
1081
|
options
|
|
1069
1082
|
});
|
|
1070
1083
|
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Fetches all user orders (Market, Limit, Cross-chain) for connected wallets.
|
|
1086
|
+
*
|
|
1087
|
+
* ---
|
|
1088
|
+
* ### Overview
|
|
1089
|
+
* Retrieves both **single-chain** and **cross-chain** orders from the Shogun Intents API.
|
|
1090
|
+
* Works across EVM, Solana
|
|
1091
|
+
*
|
|
1092
|
+
* ---
|
|
1093
|
+
* @example
|
|
1094
|
+
* ```ts
|
|
1095
|
+
* const orders = await sdk.getOrders({
|
|
1096
|
+
* evmAddress: "0x123...",
|
|
1097
|
+
* solAddress: "9d12hF...abc",
|
|
1098
|
+
* });
|
|
1099
|
+
*
|
|
1100
|
+
* console.log(orders.singleChainLimitOrders);
|
|
1101
|
+
* ```
|
|
1102
|
+
*
|
|
1103
|
+
* @param params - Wallet addresses to fetch orders for (EVM, Solana).
|
|
1104
|
+
* @returns A structured {@link ApiUserOrders} object containing all user orders.
|
|
1105
|
+
*/
|
|
1106
|
+
async getOrders(params) {
|
|
1107
|
+
return getOrders(params);
|
|
1108
|
+
}
|
|
1071
1109
|
};
|
|
1072
1110
|
export {
|
|
1073
1111
|
ChainId,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainID, QuoteResponse, ChainOrderStatus, TokenSearchResponse as TokenSearchResponse$1, TokenSearchParams, isEvmChain as isEvmChain$1 } from '@shogun-sdk/intents-sdk';
|
|
1
|
+
import { ChainID, QuoteResponse, ChainOrderStatus, TokenSearchResponse as TokenSearchResponse$1, TokenSearchParams, ApiUserOrders, isEvmChain as isEvmChain$1 } from '@shogun-sdk/intents-sdk';
|
|
2
2
|
import { A as AdaptedWallet } from './wallet-B9bKceyN.cjs';
|
|
3
3
|
import { WalletClient } from 'viem';
|
|
4
4
|
|
|
@@ -288,6 +288,32 @@ declare class SwapSDK {
|
|
|
288
288
|
* @throws Will throw an error if the network request fails or the API responds with a non-OK status.
|
|
289
289
|
*/
|
|
290
290
|
getTokensData: typeof getTokensData;
|
|
291
|
+
/**
|
|
292
|
+
* Fetches all user orders (Market, Limit, Cross-chain) for connected wallets.
|
|
293
|
+
*
|
|
294
|
+
* ---
|
|
295
|
+
* ### Overview
|
|
296
|
+
* Retrieves both **single-chain** and **cross-chain** orders from the Shogun Intents API.
|
|
297
|
+
* Works across EVM, Solana
|
|
298
|
+
*
|
|
299
|
+
* ---
|
|
300
|
+
* @example
|
|
301
|
+
* ```ts
|
|
302
|
+
* const orders = await sdk.getOrders({
|
|
303
|
+
* evmAddress: "0x123...",
|
|
304
|
+
* solAddress: "9d12hF...abc",
|
|
305
|
+
* });
|
|
306
|
+
*
|
|
307
|
+
* console.log(orders.singleChainLimitOrders);
|
|
308
|
+
* ```
|
|
309
|
+
*
|
|
310
|
+
* @param params - Wallet addresses to fetch orders for (EVM, Solana).
|
|
311
|
+
* @returns A structured {@link ApiUserOrders} object containing all user orders.
|
|
312
|
+
*/
|
|
313
|
+
getOrders(params: {
|
|
314
|
+
evmAddress?: string | null;
|
|
315
|
+
solAddress?: string | null;
|
|
316
|
+
}): Promise<ApiUserOrders>;
|
|
291
317
|
}
|
|
292
318
|
|
|
293
319
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainID, QuoteResponse, ChainOrderStatus, TokenSearchResponse as TokenSearchResponse$1, TokenSearchParams, isEvmChain as isEvmChain$1 } from '@shogun-sdk/intents-sdk';
|
|
1
|
+
import { ChainID, QuoteResponse, ChainOrderStatus, TokenSearchResponse as TokenSearchResponse$1, TokenSearchParams, ApiUserOrders, isEvmChain as isEvmChain$1 } from '@shogun-sdk/intents-sdk';
|
|
2
2
|
import { A as AdaptedWallet } from './wallet-B9bKceyN.js';
|
|
3
3
|
import { WalletClient } from 'viem';
|
|
4
4
|
|
|
@@ -288,6 +288,32 @@ declare class SwapSDK {
|
|
|
288
288
|
* @throws Will throw an error if the network request fails or the API responds with a non-OK status.
|
|
289
289
|
*/
|
|
290
290
|
getTokensData: typeof getTokensData;
|
|
291
|
+
/**
|
|
292
|
+
* Fetches all user orders (Market, Limit, Cross-chain) for connected wallets.
|
|
293
|
+
*
|
|
294
|
+
* ---
|
|
295
|
+
* ### Overview
|
|
296
|
+
* Retrieves both **single-chain** and **cross-chain** orders from the Shogun Intents API.
|
|
297
|
+
* Works across EVM, Solana
|
|
298
|
+
*
|
|
299
|
+
* ---
|
|
300
|
+
* @example
|
|
301
|
+
* ```ts
|
|
302
|
+
* const orders = await sdk.getOrders({
|
|
303
|
+
* evmAddress: "0x123...",
|
|
304
|
+
* solAddress: "9d12hF...abc",
|
|
305
|
+
* });
|
|
306
|
+
*
|
|
307
|
+
* console.log(orders.singleChainLimitOrders);
|
|
308
|
+
* ```
|
|
309
|
+
*
|
|
310
|
+
* @param params - Wallet addresses to fetch orders for (EVM, Solana).
|
|
311
|
+
* @returns A structured {@link ApiUserOrders} object containing all user orders.
|
|
312
|
+
*/
|
|
313
|
+
getOrders(params: {
|
|
314
|
+
evmAddress?: string | null;
|
|
315
|
+
solAddress?: string | null;
|
|
316
|
+
}): Promise<ApiUserOrders>;
|
|
291
317
|
}
|
|
292
318
|
|
|
293
319
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -803,7 +803,7 @@ async function handleSolanaExecution({
|
|
|
803
803
|
throw new Error("Auctioneer submission failed");
|
|
804
804
|
}
|
|
805
805
|
update("initiated", messageFor("initiated"));
|
|
806
|
-
const {
|
|
806
|
+
const { intentId: orderId } = response.data;
|
|
807
807
|
update("initiated", messageFor("shogun_processing"));
|
|
808
808
|
if (orderType === "limit" /* LIMIT */) {
|
|
809
809
|
update("success", messageFor("success_limit"));
|
|
@@ -815,7 +815,7 @@ async function handleSolanaExecution({
|
|
|
815
815
|
stage: "success"
|
|
816
816
|
};
|
|
817
817
|
} else {
|
|
818
|
-
const status = await pollOrderStatus(
|
|
818
|
+
const status = await pollOrderStatus(accountAddress, orderId);
|
|
819
819
|
return await handleOrderPollingResult({
|
|
820
820
|
status,
|
|
821
821
|
orderId,
|
|
@@ -953,6 +953,19 @@ function normalizeWallet(wallet) {
|
|
|
953
953
|
return wallet;
|
|
954
954
|
}
|
|
955
955
|
|
|
956
|
+
// src/core/orders/getOrders.ts
|
|
957
|
+
var import_intents_sdk13 = require("@shogun-sdk/intents-sdk");
|
|
958
|
+
async function getOrders({
|
|
959
|
+
evmAddress,
|
|
960
|
+
solAddress
|
|
961
|
+
}) {
|
|
962
|
+
if (!evmAddress && !solAddress) {
|
|
963
|
+
throw new Error("At least one wallet address (EVM, Solana) must be provided.");
|
|
964
|
+
}
|
|
965
|
+
const orders = await (0, import_intents_sdk13.fetchUserOrders)(evmAddress, solAddress);
|
|
966
|
+
return orders;
|
|
967
|
+
}
|
|
968
|
+
|
|
956
969
|
// src/core/client.ts
|
|
957
970
|
var SwapSDK = class {
|
|
958
971
|
constructor(config) {
|
|
@@ -1088,4 +1101,29 @@ var SwapSDK = class {
|
|
|
1088
1101
|
options
|
|
1089
1102
|
});
|
|
1090
1103
|
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Fetches all user orders (Market, Limit, Cross-chain) for connected wallets.
|
|
1106
|
+
*
|
|
1107
|
+
* ---
|
|
1108
|
+
* ### Overview
|
|
1109
|
+
* Retrieves both **single-chain** and **cross-chain** orders from the Shogun Intents API.
|
|
1110
|
+
* Works across EVM, Solana
|
|
1111
|
+
*
|
|
1112
|
+
* ---
|
|
1113
|
+
* @example
|
|
1114
|
+
* ```ts
|
|
1115
|
+
* const orders = await sdk.getOrders({
|
|
1116
|
+
* evmAddress: "0x123...",
|
|
1117
|
+
* solAddress: "9d12hF...abc",
|
|
1118
|
+
* });
|
|
1119
|
+
*
|
|
1120
|
+
* console.log(orders.singleChainLimitOrders);
|
|
1121
|
+
* ```
|
|
1122
|
+
*
|
|
1123
|
+
* @param params - Wallet addresses to fetch orders for (EVM, Solana).
|
|
1124
|
+
* @returns A structured {@link ApiUserOrders} object containing all user orders.
|
|
1125
|
+
*/
|
|
1126
|
+
async getOrders(params) {
|
|
1127
|
+
return getOrders(params);
|
|
1128
|
+
}
|
|
1091
1129
|
};
|
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-CmsKzdEu.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-Qoc6Q9XN.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
|
@@ -783,7 +783,7 @@ async function handleSolanaExecution({
|
|
|
783
783
|
throw new Error("Auctioneer submission failed");
|
|
784
784
|
}
|
|
785
785
|
update("initiated", messageFor("initiated"));
|
|
786
|
-
const {
|
|
786
|
+
const { intentId: orderId } = response.data;
|
|
787
787
|
update("initiated", messageFor("shogun_processing"));
|
|
788
788
|
if (orderType === "limit" /* LIMIT */) {
|
|
789
789
|
update("success", messageFor("success_limit"));
|
|
@@ -795,7 +795,7 @@ async function handleSolanaExecution({
|
|
|
795
795
|
stage: "success"
|
|
796
796
|
};
|
|
797
797
|
} else {
|
|
798
|
-
const status = await pollOrderStatus(
|
|
798
|
+
const status = await pollOrderStatus(accountAddress, orderId);
|
|
799
799
|
return await handleOrderPollingResult({
|
|
800
800
|
status,
|
|
801
801
|
orderId,
|
|
@@ -933,6 +933,19 @@ function normalizeWallet(wallet) {
|
|
|
933
933
|
return wallet;
|
|
934
934
|
}
|
|
935
935
|
|
|
936
|
+
// src/core/orders/getOrders.ts
|
|
937
|
+
import { fetchUserOrders } from "@shogun-sdk/intents-sdk";
|
|
938
|
+
async function getOrders({
|
|
939
|
+
evmAddress,
|
|
940
|
+
solAddress
|
|
941
|
+
}) {
|
|
942
|
+
if (!evmAddress && !solAddress) {
|
|
943
|
+
throw new Error("At least one wallet address (EVM, Solana) must be provided.");
|
|
944
|
+
}
|
|
945
|
+
const orders = await fetchUserOrders(evmAddress, solAddress);
|
|
946
|
+
return orders;
|
|
947
|
+
}
|
|
948
|
+
|
|
936
949
|
// src/core/client.ts
|
|
937
950
|
var SwapSDK = class {
|
|
938
951
|
constructor(config) {
|
|
@@ -1068,6 +1081,31 @@ var SwapSDK = class {
|
|
|
1068
1081
|
options
|
|
1069
1082
|
});
|
|
1070
1083
|
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Fetches all user orders (Market, Limit, Cross-chain) for connected wallets.
|
|
1086
|
+
*
|
|
1087
|
+
* ---
|
|
1088
|
+
* ### Overview
|
|
1089
|
+
* Retrieves both **single-chain** and **cross-chain** orders from the Shogun Intents API.
|
|
1090
|
+
* Works across EVM, Solana
|
|
1091
|
+
*
|
|
1092
|
+
* ---
|
|
1093
|
+
* @example
|
|
1094
|
+
* ```ts
|
|
1095
|
+
* const orders = await sdk.getOrders({
|
|
1096
|
+
* evmAddress: "0x123...",
|
|
1097
|
+
* solAddress: "9d12hF...abc",
|
|
1098
|
+
* });
|
|
1099
|
+
*
|
|
1100
|
+
* console.log(orders.singleChainLimitOrders);
|
|
1101
|
+
* ```
|
|
1102
|
+
*
|
|
1103
|
+
* @param params - Wallet addresses to fetch orders for (EVM, Solana).
|
|
1104
|
+
* @returns A structured {@link ApiUserOrders} object containing all user orders.
|
|
1105
|
+
*/
|
|
1106
|
+
async getOrders(params) {
|
|
1107
|
+
return getOrders(params);
|
|
1108
|
+
}
|
|
1071
1109
|
};
|
|
1072
1110
|
export {
|
|
1073
1111
|
ChainId,
|
package/dist/react.cjs
CHANGED
|
@@ -40,6 +40,7 @@ __export(react_exports, {
|
|
|
40
40
|
isEvmChain: () => isEvmChain,
|
|
41
41
|
useBalances: () => useBalances,
|
|
42
42
|
useExecuteTransaction: () => useExecuteTransaction,
|
|
43
|
+
useOrders: () => useOrders,
|
|
43
44
|
useQuote: () => useQuote,
|
|
44
45
|
useSwap: () => useSwap,
|
|
45
46
|
useTokenList: () => useTokenList,
|
|
@@ -822,7 +823,7 @@ async function handleSolanaExecution({
|
|
|
822
823
|
throw new Error("Auctioneer submission failed");
|
|
823
824
|
}
|
|
824
825
|
update("initiated", messageFor("initiated"));
|
|
825
|
-
const {
|
|
826
|
+
const { intentId: orderId } = response.data;
|
|
826
827
|
update("initiated", messageFor("shogun_processing"));
|
|
827
828
|
if (orderType === "limit" /* LIMIT */) {
|
|
828
829
|
update("success", messageFor("success_limit"));
|
|
@@ -834,7 +835,7 @@ async function handleSolanaExecution({
|
|
|
834
835
|
stage: "success"
|
|
835
836
|
};
|
|
836
837
|
} else {
|
|
837
|
-
const status = await pollOrderStatus(
|
|
838
|
+
const status = await pollOrderStatus(accountAddress, orderId);
|
|
838
839
|
return await handleOrderPollingResult({
|
|
839
840
|
status,
|
|
840
841
|
orderId,
|
|
@@ -972,6 +973,19 @@ function normalizeWallet(wallet) {
|
|
|
972
973
|
return wallet;
|
|
973
974
|
}
|
|
974
975
|
|
|
976
|
+
// src/core/orders/getOrders.ts
|
|
977
|
+
var import_intents_sdk13 = require("@shogun-sdk/intents-sdk");
|
|
978
|
+
async function getOrders({
|
|
979
|
+
evmAddress,
|
|
980
|
+
solAddress
|
|
981
|
+
}) {
|
|
982
|
+
if (!evmAddress && !solAddress) {
|
|
983
|
+
throw new Error("At least one wallet address (EVM, Solana) must be provided.");
|
|
984
|
+
}
|
|
985
|
+
const orders = await (0, import_intents_sdk13.fetchUserOrders)(evmAddress, solAddress);
|
|
986
|
+
return orders;
|
|
987
|
+
}
|
|
988
|
+
|
|
975
989
|
// src/core/client.ts
|
|
976
990
|
var SwapSDK = class {
|
|
977
991
|
constructor(config) {
|
|
@@ -1107,6 +1121,31 @@ var SwapSDK = class {
|
|
|
1107
1121
|
options
|
|
1108
1122
|
});
|
|
1109
1123
|
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Fetches all user orders (Market, Limit, Cross-chain) for connected wallets.
|
|
1126
|
+
*
|
|
1127
|
+
* ---
|
|
1128
|
+
* ### Overview
|
|
1129
|
+
* Retrieves both **single-chain** and **cross-chain** orders from the Shogun Intents API.
|
|
1130
|
+
* Works across EVM, Solana
|
|
1131
|
+
*
|
|
1132
|
+
* ---
|
|
1133
|
+
* @example
|
|
1134
|
+
* ```ts
|
|
1135
|
+
* const orders = await sdk.getOrders({
|
|
1136
|
+
* evmAddress: "0x123...",
|
|
1137
|
+
* solAddress: "9d12hF...abc",
|
|
1138
|
+
* });
|
|
1139
|
+
*
|
|
1140
|
+
* console.log(orders.singleChainLimitOrders);
|
|
1141
|
+
* ```
|
|
1142
|
+
*
|
|
1143
|
+
* @param params - Wallet addresses to fetch orders for (EVM, Solana).
|
|
1144
|
+
* @returns A structured {@link ApiUserOrders} object containing all user orders.
|
|
1145
|
+
*/
|
|
1146
|
+
async getOrders(params) {
|
|
1147
|
+
return getOrders(params);
|
|
1148
|
+
}
|
|
1110
1149
|
};
|
|
1111
1150
|
|
|
1112
1151
|
// src/react/SwapProvider.tsx
|
|
@@ -1452,3 +1491,72 @@ function useTokensData(addresses) {
|
|
|
1452
1491
|
}, [sdk, JSON.stringify(addresses)]);
|
|
1453
1492
|
return { data, loading, error };
|
|
1454
1493
|
}
|
|
1494
|
+
|
|
1495
|
+
// src/react/useOrders.ts
|
|
1496
|
+
var import_react7 = require("react");
|
|
1497
|
+
var import_swr3 = __toESM(require("swr"), 1);
|
|
1498
|
+
var ORDERS_KEY = "orders-global";
|
|
1499
|
+
function hasValidAddress(addrs) {
|
|
1500
|
+
if (!addrs) return false;
|
|
1501
|
+
return Boolean(addrs.evmAddress || addrs.solAddress || addrs.suiAddress);
|
|
1502
|
+
}
|
|
1503
|
+
function useOrders(initialAddresses) {
|
|
1504
|
+
const sdk = useSwap();
|
|
1505
|
+
const abortRef = (0, import_react7.useRef)(null);
|
|
1506
|
+
const addrRef = globalThis.__ORDERS_ADDR_REF__ ?? (globalThis.__ORDERS_ADDR_REF__ = { current: initialAddresses ?? null });
|
|
1507
|
+
(0, import_react7.useEffect)(() => {
|
|
1508
|
+
if (initialAddresses && JSON.stringify(addrRef.current) !== JSON.stringify(initialAddresses)) {
|
|
1509
|
+
addrRef.current = initialAddresses;
|
|
1510
|
+
void (0, import_swr3.mutate)(ORDERS_KEY);
|
|
1511
|
+
}
|
|
1512
|
+
}, [initialAddresses]);
|
|
1513
|
+
const fetcher = (0, import_react7.useCallback)(async () => {
|
|
1514
|
+
const active = addrRef.current;
|
|
1515
|
+
if (!hasValidAddress(active)) return null;
|
|
1516
|
+
if (abortRef.current) abortRef.current.abort();
|
|
1517
|
+
const controller = new AbortController();
|
|
1518
|
+
abortRef.current = controller;
|
|
1519
|
+
try {
|
|
1520
|
+
return await sdk.getOrders(active ?? {});
|
|
1521
|
+
} catch (err) {
|
|
1522
|
+
if (err instanceof DOMException && err.name === "AbortError") return null;
|
|
1523
|
+
if (err instanceof Error) throw err;
|
|
1524
|
+
throw new Error(String(err));
|
|
1525
|
+
}
|
|
1526
|
+
}, [sdk]);
|
|
1527
|
+
const {
|
|
1528
|
+
data,
|
|
1529
|
+
error,
|
|
1530
|
+
isValidating: loading,
|
|
1531
|
+
mutate: mutateOrders
|
|
1532
|
+
} = (0, import_swr3.default)(ORDERS_KEY, fetcher, {
|
|
1533
|
+
revalidateOnFocus: false,
|
|
1534
|
+
revalidateOnReconnect: false,
|
|
1535
|
+
shouldRetryOnError: false,
|
|
1536
|
+
keepPreviousData: true
|
|
1537
|
+
});
|
|
1538
|
+
const refetch = (0, import_react7.useCallback)(async () => {
|
|
1539
|
+
await mutateOrders();
|
|
1540
|
+
}, [mutateOrders]);
|
|
1541
|
+
const setAddresses = (0, import_react7.useCallback)(
|
|
1542
|
+
(next) => {
|
|
1543
|
+
if (!next) return;
|
|
1544
|
+
addrRef.current = next;
|
|
1545
|
+
void (0, import_swr3.mutate)(ORDERS_KEY);
|
|
1546
|
+
},
|
|
1547
|
+
[]
|
|
1548
|
+
);
|
|
1549
|
+
return (0, import_react7.useMemo)(
|
|
1550
|
+
() => ({
|
|
1551
|
+
data,
|
|
1552
|
+
loading,
|
|
1553
|
+
error: error instanceof Error ? error.message : null,
|
|
1554
|
+
refetch,
|
|
1555
|
+
setAddresses,
|
|
1556
|
+
get activeAddresses() {
|
|
1557
|
+
return addrRef.current;
|
|
1558
|
+
}
|
|
1559
|
+
}),
|
|
1560
|
+
[data, loading, error, refetch, setAddresses]
|
|
1561
|
+
);
|
|
1562
|
+
}
|
package/dist/react.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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-CmsKzdEu.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-CmsKzdEu.cjs';
|
|
4
4
|
import { WalletClient } from 'viem';
|
|
5
5
|
import { A as AdaptedWallet } from './wallet-B9bKceyN.cjs';
|
|
6
|
-
import '@shogun-sdk/intents-sdk';
|
|
6
|
+
import { ApiUserOrders } from '@shogun-sdk/intents-sdk';
|
|
7
7
|
import '@solana/web3.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -231,4 +231,70 @@ declare function useTokensData(addresses: string[]): {
|
|
|
231
231
|
error: Error | null;
|
|
232
232
|
};
|
|
233
233
|
|
|
234
|
-
|
|
234
|
+
/**
|
|
235
|
+
* @fileoverview Centralized SWR hook for fetching user orders via the Swap SDK.
|
|
236
|
+
*
|
|
237
|
+
* ## Features
|
|
238
|
+
* - Shared global cache via SWR
|
|
239
|
+
* - Abort-safe concurrent requests
|
|
240
|
+
* - Accepts addresses via params or setAddresses()
|
|
241
|
+
* - No auto-refresh (manual control)
|
|
242
|
+
*/
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Augment globalThis to safely hold a shared address ref.
|
|
246
|
+
*/
|
|
247
|
+
declare global {
|
|
248
|
+
var __ORDERS_ADDR_REF__: {
|
|
249
|
+
current: {
|
|
250
|
+
evmAddress?: string | null;
|
|
251
|
+
solAddress?: string | null;
|
|
252
|
+
suiAddress?: string | null;
|
|
253
|
+
} | null;
|
|
254
|
+
} | undefined;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Centralized SWR-powered hook for fetching user orders.
|
|
258
|
+
*
|
|
259
|
+
* ---
|
|
260
|
+
* ### Features
|
|
261
|
+
* - Shared global cache via SWR (no auto revalidation)
|
|
262
|
+
* - Manual `refetch()` support
|
|
263
|
+
* - Pass addresses directly or set later with `setAddresses()`
|
|
264
|
+
* - Safe abort for concurrent requests
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```tsx
|
|
268
|
+
* const { data, loading, error, setAddresses, refetch } = useOrders();
|
|
269
|
+
*
|
|
270
|
+
* // Later, you can set addresses manually:
|
|
271
|
+
* useEffect(() => {
|
|
272
|
+
* setAddresses({ evmAddress: "0x123..." });
|
|
273
|
+
* }, []);
|
|
274
|
+
*
|
|
275
|
+
* // Or pass them directly:
|
|
276
|
+
* const { data } = useOrders({ evmAddress: "0x123..." });
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
declare function useOrders(initialAddresses?: {
|
|
280
|
+
evmAddress?: string | null;
|
|
281
|
+
solAddress?: string | null;
|
|
282
|
+
suiAddress?: string | null;
|
|
283
|
+
}): {
|
|
284
|
+
data: ApiUserOrders | null | undefined;
|
|
285
|
+
loading: boolean;
|
|
286
|
+
error: string | null;
|
|
287
|
+
refetch: () => Promise<void>;
|
|
288
|
+
setAddresses: (next: {
|
|
289
|
+
evmAddress?: string | null;
|
|
290
|
+
solAddress?: string | null;
|
|
291
|
+
suiAddress?: string | null;
|
|
292
|
+
}) => void;
|
|
293
|
+
readonly activeAddresses: {
|
|
294
|
+
evmAddress?: string | null;
|
|
295
|
+
solAddress?: string | null;
|
|
296
|
+
suiAddress?: string | null;
|
|
297
|
+
} | null;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export { BalanceRequestParams, BalanceResponse, SwapProvider, SwapQuoteParams, SwapQuoteResponse, useBalances, useExecuteTransaction, useOrders, useQuote, useSwap, useTokenList, useTokensData };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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-Qoc6Q9XN.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-Qoc6Q9XN.js';
|
|
4
4
|
import { WalletClient } from 'viem';
|
|
5
5
|
import { A as AdaptedWallet } from './wallet-B9bKceyN.js';
|
|
6
|
-
import '@shogun-sdk/intents-sdk';
|
|
6
|
+
import { ApiUserOrders } from '@shogun-sdk/intents-sdk';
|
|
7
7
|
import '@solana/web3.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -231,4 +231,70 @@ declare function useTokensData(addresses: string[]): {
|
|
|
231
231
|
error: Error | null;
|
|
232
232
|
};
|
|
233
233
|
|
|
234
|
-
|
|
234
|
+
/**
|
|
235
|
+
* @fileoverview Centralized SWR hook for fetching user orders via the Swap SDK.
|
|
236
|
+
*
|
|
237
|
+
* ## Features
|
|
238
|
+
* - Shared global cache via SWR
|
|
239
|
+
* - Abort-safe concurrent requests
|
|
240
|
+
* - Accepts addresses via params or setAddresses()
|
|
241
|
+
* - No auto-refresh (manual control)
|
|
242
|
+
*/
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Augment globalThis to safely hold a shared address ref.
|
|
246
|
+
*/
|
|
247
|
+
declare global {
|
|
248
|
+
var __ORDERS_ADDR_REF__: {
|
|
249
|
+
current: {
|
|
250
|
+
evmAddress?: string | null;
|
|
251
|
+
solAddress?: string | null;
|
|
252
|
+
suiAddress?: string | null;
|
|
253
|
+
} | null;
|
|
254
|
+
} | undefined;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Centralized SWR-powered hook for fetching user orders.
|
|
258
|
+
*
|
|
259
|
+
* ---
|
|
260
|
+
* ### Features
|
|
261
|
+
* - Shared global cache via SWR (no auto revalidation)
|
|
262
|
+
* - Manual `refetch()` support
|
|
263
|
+
* - Pass addresses directly or set later with `setAddresses()`
|
|
264
|
+
* - Safe abort for concurrent requests
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```tsx
|
|
268
|
+
* const { data, loading, error, setAddresses, refetch } = useOrders();
|
|
269
|
+
*
|
|
270
|
+
* // Later, you can set addresses manually:
|
|
271
|
+
* useEffect(() => {
|
|
272
|
+
* setAddresses({ evmAddress: "0x123..." });
|
|
273
|
+
* }, []);
|
|
274
|
+
*
|
|
275
|
+
* // Or pass them directly:
|
|
276
|
+
* const { data } = useOrders({ evmAddress: "0x123..." });
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
declare function useOrders(initialAddresses?: {
|
|
280
|
+
evmAddress?: string | null;
|
|
281
|
+
solAddress?: string | null;
|
|
282
|
+
suiAddress?: string | null;
|
|
283
|
+
}): {
|
|
284
|
+
data: ApiUserOrders | null | undefined;
|
|
285
|
+
loading: boolean;
|
|
286
|
+
error: string | null;
|
|
287
|
+
refetch: () => Promise<void>;
|
|
288
|
+
setAddresses: (next: {
|
|
289
|
+
evmAddress?: string | null;
|
|
290
|
+
solAddress?: string | null;
|
|
291
|
+
suiAddress?: string | null;
|
|
292
|
+
}) => void;
|
|
293
|
+
readonly activeAddresses: {
|
|
294
|
+
evmAddress?: string | null;
|
|
295
|
+
solAddress?: string | null;
|
|
296
|
+
suiAddress?: string | null;
|
|
297
|
+
} | null;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export { BalanceRequestParams, BalanceResponse, SwapProvider, SwapQuoteParams, SwapQuoteResponse, useBalances, useExecuteTransaction, useOrders, useQuote, useSwap, useTokenList, useTokensData };
|
package/dist/react.js
CHANGED
|
@@ -786,7 +786,7 @@ async function handleSolanaExecution({
|
|
|
786
786
|
throw new Error("Auctioneer submission failed");
|
|
787
787
|
}
|
|
788
788
|
update("initiated", messageFor("initiated"));
|
|
789
|
-
const {
|
|
789
|
+
const { intentId: orderId } = response.data;
|
|
790
790
|
update("initiated", messageFor("shogun_processing"));
|
|
791
791
|
if (orderType === "limit" /* LIMIT */) {
|
|
792
792
|
update("success", messageFor("success_limit"));
|
|
@@ -798,7 +798,7 @@ async function handleSolanaExecution({
|
|
|
798
798
|
stage: "success"
|
|
799
799
|
};
|
|
800
800
|
} else {
|
|
801
|
-
const status = await pollOrderStatus(
|
|
801
|
+
const status = await pollOrderStatus(accountAddress, orderId);
|
|
802
802
|
return await handleOrderPollingResult({
|
|
803
803
|
status,
|
|
804
804
|
orderId,
|
|
@@ -936,6 +936,19 @@ function normalizeWallet(wallet) {
|
|
|
936
936
|
return wallet;
|
|
937
937
|
}
|
|
938
938
|
|
|
939
|
+
// src/core/orders/getOrders.ts
|
|
940
|
+
import { fetchUserOrders } from "@shogun-sdk/intents-sdk";
|
|
941
|
+
async function getOrders({
|
|
942
|
+
evmAddress,
|
|
943
|
+
solAddress
|
|
944
|
+
}) {
|
|
945
|
+
if (!evmAddress && !solAddress) {
|
|
946
|
+
throw new Error("At least one wallet address (EVM, Solana) must be provided.");
|
|
947
|
+
}
|
|
948
|
+
const orders = await fetchUserOrders(evmAddress, solAddress);
|
|
949
|
+
return orders;
|
|
950
|
+
}
|
|
951
|
+
|
|
939
952
|
// src/core/client.ts
|
|
940
953
|
var SwapSDK = class {
|
|
941
954
|
constructor(config) {
|
|
@@ -1071,6 +1084,31 @@ var SwapSDK = class {
|
|
|
1071
1084
|
options
|
|
1072
1085
|
});
|
|
1073
1086
|
}
|
|
1087
|
+
/**
|
|
1088
|
+
* Fetches all user orders (Market, Limit, Cross-chain) for connected wallets.
|
|
1089
|
+
*
|
|
1090
|
+
* ---
|
|
1091
|
+
* ### Overview
|
|
1092
|
+
* Retrieves both **single-chain** and **cross-chain** orders from the Shogun Intents API.
|
|
1093
|
+
* Works across EVM, Solana
|
|
1094
|
+
*
|
|
1095
|
+
* ---
|
|
1096
|
+
* @example
|
|
1097
|
+
* ```ts
|
|
1098
|
+
* const orders = await sdk.getOrders({
|
|
1099
|
+
* evmAddress: "0x123...",
|
|
1100
|
+
* solAddress: "9d12hF...abc",
|
|
1101
|
+
* });
|
|
1102
|
+
*
|
|
1103
|
+
* console.log(orders.singleChainLimitOrders);
|
|
1104
|
+
* ```
|
|
1105
|
+
*
|
|
1106
|
+
* @param params - Wallet addresses to fetch orders for (EVM, Solana).
|
|
1107
|
+
* @returns A structured {@link ApiUserOrders} object containing all user orders.
|
|
1108
|
+
*/
|
|
1109
|
+
async getOrders(params) {
|
|
1110
|
+
return getOrders(params);
|
|
1111
|
+
}
|
|
1074
1112
|
};
|
|
1075
1113
|
|
|
1076
1114
|
// src/react/SwapProvider.tsx
|
|
@@ -1416,6 +1454,75 @@ function useTokensData(addresses) {
|
|
|
1416
1454
|
}, [sdk, JSON.stringify(addresses)]);
|
|
1417
1455
|
return { data, loading, error };
|
|
1418
1456
|
}
|
|
1457
|
+
|
|
1458
|
+
// src/react/useOrders.ts
|
|
1459
|
+
import { useCallback as useCallback5, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef4 } from "react";
|
|
1460
|
+
import useSWR3, { mutate as mutate3 } from "swr";
|
|
1461
|
+
var ORDERS_KEY = "orders-global";
|
|
1462
|
+
function hasValidAddress(addrs) {
|
|
1463
|
+
if (!addrs) return false;
|
|
1464
|
+
return Boolean(addrs.evmAddress || addrs.solAddress || addrs.suiAddress);
|
|
1465
|
+
}
|
|
1466
|
+
function useOrders(initialAddresses) {
|
|
1467
|
+
const sdk = useSwap();
|
|
1468
|
+
const abortRef = useRef4(null);
|
|
1469
|
+
const addrRef = globalThis.__ORDERS_ADDR_REF__ ?? (globalThis.__ORDERS_ADDR_REF__ = { current: initialAddresses ?? null });
|
|
1470
|
+
useEffect4(() => {
|
|
1471
|
+
if (initialAddresses && JSON.stringify(addrRef.current) !== JSON.stringify(initialAddresses)) {
|
|
1472
|
+
addrRef.current = initialAddresses;
|
|
1473
|
+
void mutate3(ORDERS_KEY);
|
|
1474
|
+
}
|
|
1475
|
+
}, [initialAddresses]);
|
|
1476
|
+
const fetcher = useCallback5(async () => {
|
|
1477
|
+
const active = addrRef.current;
|
|
1478
|
+
if (!hasValidAddress(active)) return null;
|
|
1479
|
+
if (abortRef.current) abortRef.current.abort();
|
|
1480
|
+
const controller = new AbortController();
|
|
1481
|
+
abortRef.current = controller;
|
|
1482
|
+
try {
|
|
1483
|
+
return await sdk.getOrders(active ?? {});
|
|
1484
|
+
} catch (err) {
|
|
1485
|
+
if (err instanceof DOMException && err.name === "AbortError") return null;
|
|
1486
|
+
if (err instanceof Error) throw err;
|
|
1487
|
+
throw new Error(String(err));
|
|
1488
|
+
}
|
|
1489
|
+
}, [sdk]);
|
|
1490
|
+
const {
|
|
1491
|
+
data,
|
|
1492
|
+
error,
|
|
1493
|
+
isValidating: loading,
|
|
1494
|
+
mutate: mutateOrders
|
|
1495
|
+
} = useSWR3(ORDERS_KEY, fetcher, {
|
|
1496
|
+
revalidateOnFocus: false,
|
|
1497
|
+
revalidateOnReconnect: false,
|
|
1498
|
+
shouldRetryOnError: false,
|
|
1499
|
+
keepPreviousData: true
|
|
1500
|
+
});
|
|
1501
|
+
const refetch = useCallback5(async () => {
|
|
1502
|
+
await mutateOrders();
|
|
1503
|
+
}, [mutateOrders]);
|
|
1504
|
+
const setAddresses = useCallback5(
|
|
1505
|
+
(next) => {
|
|
1506
|
+
if (!next) return;
|
|
1507
|
+
addrRef.current = next;
|
|
1508
|
+
void mutate3(ORDERS_KEY);
|
|
1509
|
+
},
|
|
1510
|
+
[]
|
|
1511
|
+
);
|
|
1512
|
+
return useMemo4(
|
|
1513
|
+
() => ({
|
|
1514
|
+
data,
|
|
1515
|
+
loading,
|
|
1516
|
+
error: error instanceof Error ? error.message : null,
|
|
1517
|
+
refetch,
|
|
1518
|
+
setAddresses,
|
|
1519
|
+
get activeAddresses() {
|
|
1520
|
+
return addrRef.current;
|
|
1521
|
+
}
|
|
1522
|
+
}),
|
|
1523
|
+
[data, loading, error, refetch, setAddresses]
|
|
1524
|
+
);
|
|
1525
|
+
}
|
|
1419
1526
|
export {
|
|
1420
1527
|
ChainId,
|
|
1421
1528
|
OrderExecutionType,
|
|
@@ -1425,6 +1532,7 @@ export {
|
|
|
1425
1532
|
isEvmChain,
|
|
1426
1533
|
useBalances,
|
|
1427
1534
|
useExecuteTransaction,
|
|
1535
|
+
useOrders,
|
|
1428
1536
|
useQuote,
|
|
1429
1537
|
useSwap,
|
|
1430
1538
|
useTokenList,
|
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.27",
|
|
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.2.6-test.
|
|
48
|
+
"@shogun-sdk/intents-sdk": "1.2.6-test.11"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@ethersproject/abstract-signer": "^5.7.0",
|