@shogun-sdk/swap 0.0.2-test.10 → 0.0.2-test.11
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 +30 -7
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +30 -7
- package/dist/{execute-St0oo8GR.d.ts → execute-CKTsf_tD.d.ts} +1 -11
- package/dist/{execute-DEFbp1WZ.d.cts → execute-DOv1i2Su.d.cts} +1 -11
- package/dist/index.cjs +30 -7
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -7
- package/dist/react.cjs +30 -7
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +30 -7
- package/package.json +2 -2
package/dist/core.cjs
CHANGED
|
@@ -660,18 +660,33 @@ async function executeOrder({
|
|
|
660
660
|
onStatus,
|
|
661
661
|
options = {}
|
|
662
662
|
}) {
|
|
663
|
-
const
|
|
663
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
664
|
+
const log = (...args) => {
|
|
665
|
+
if (isDev) console.log("[OneShot::executeOrder]", ...args);
|
|
666
|
+
};
|
|
664
667
|
const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
|
|
665
|
-
const update = (stage, message) =>
|
|
668
|
+
const update = (stage, message) => {
|
|
669
|
+
log("Stage:", stage, "| Message:", message ?? messageFor(stage));
|
|
670
|
+
onStatus?.(stage, message ?? messageFor(stage));
|
|
671
|
+
};
|
|
666
672
|
try {
|
|
673
|
+
const deadline = options.deadline ?? Math.floor(Date.now() / 1e3) + 20 * 60;
|
|
674
|
+
log("Starting execution:", {
|
|
675
|
+
accountAddress,
|
|
676
|
+
recipientAddress,
|
|
677
|
+
deadline,
|
|
678
|
+
tokenIn: quote?.tokenIn?.symbol,
|
|
679
|
+
tokenOut: quote?.tokenOut?.symbol
|
|
680
|
+
});
|
|
667
681
|
const adapter = normalizeWallet(wallet);
|
|
668
682
|
if (!adapter) throw new Error("No wallet provided");
|
|
669
683
|
const { tokenIn, tokenOut } = quote;
|
|
670
684
|
const isSingleChain = tokenIn.chainId === tokenOut.chainId;
|
|
671
685
|
const chainId = Number(tokenIn.chainId);
|
|
672
|
-
update("processing"
|
|
686
|
+
update("processing");
|
|
673
687
|
if ((0, import_intents_sdk10.isEvmChain)(chainId)) {
|
|
674
|
-
|
|
688
|
+
log("Detected EVM chain:", chainId);
|
|
689
|
+
const result = await handleEvmExecution({
|
|
675
690
|
recipientAddress,
|
|
676
691
|
quote,
|
|
677
692
|
chainId,
|
|
@@ -681,9 +696,12 @@ async function executeOrder({
|
|
|
681
696
|
deadline,
|
|
682
697
|
update
|
|
683
698
|
});
|
|
699
|
+
log("EVM execution result:", result);
|
|
700
|
+
return result;
|
|
684
701
|
}
|
|
685
702
|
if (chainId === import_intents_sdk10.ChainID.Solana) {
|
|
686
|
-
|
|
703
|
+
log("Detected Solana chain");
|
|
704
|
+
const result = await handleSolanaExecution({
|
|
687
705
|
recipientAddress,
|
|
688
706
|
quote,
|
|
689
707
|
accountAddress,
|
|
@@ -692,11 +710,16 @@ async function executeOrder({
|
|
|
692
710
|
deadline,
|
|
693
711
|
update
|
|
694
712
|
});
|
|
713
|
+
log("Solana execution result:", result);
|
|
714
|
+
return result;
|
|
695
715
|
}
|
|
696
|
-
|
|
697
|
-
|
|
716
|
+
const unsupported = `Unsupported chain: ${chainId}`;
|
|
717
|
+
update("error", unsupported);
|
|
718
|
+
log("Error:", unsupported);
|
|
719
|
+
return { status: false, message: unsupported, stage: "error" };
|
|
698
720
|
} catch (error) {
|
|
699
721
|
const message = error instanceof import_viem4.BaseError ? error.shortMessage : error instanceof Error ? error.message : String(error);
|
|
722
|
+
log("Execution failed:", { message, error });
|
|
700
723
|
update("error", message);
|
|
701
724
|
return { status: false, message, stage: "error" };
|
|
702
725
|
}
|
package/dist/core.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TokenSearchParams, TokenSearchResponse, ChainID } from '@shogun-sdk/intents-sdk';
|
|
2
2
|
export { ChainID, isEvmChain } from '@shogun-sdk/intents-sdk';
|
|
3
|
-
import { S as SwapQuoteParams, a as SwapQuoteResponse, Q as QuoteTokenInfo, B as BalanceRequestParams, c as BalanceResponse } from './execute-
|
|
4
|
-
export { P as PlaceOrderResult, b as Stage, T as TokenBalance, f as TokenInfo, d as TokenSearchResponse, e as executeOrder } from './execute-
|
|
3
|
+
import { S as SwapQuoteParams, a as SwapQuoteResponse, Q as QuoteTokenInfo, B as BalanceRequestParams, c as BalanceResponse } from './execute-DOv1i2Su.cjs';
|
|
4
|
+
export { P as PlaceOrderResult, b as Stage, T as TokenBalance, f as TokenInfo, d as TokenSearchResponse, e as executeOrder } from './execute-DOv1i2Su.cjs';
|
|
5
5
|
import { WalletClient } from 'viem';
|
|
6
6
|
import { A as AdaptedWallet } from './wallet-MmUIz8GE.cjs';
|
|
7
7
|
import '@mysten/sui/transactions';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TokenSearchParams, TokenSearchResponse, ChainID } from '@shogun-sdk/intents-sdk';
|
|
2
2
|
export { ChainID, isEvmChain } from '@shogun-sdk/intents-sdk';
|
|
3
|
-
import { S as SwapQuoteParams, a as SwapQuoteResponse, Q as QuoteTokenInfo, B as BalanceRequestParams, c as BalanceResponse } from './execute-
|
|
4
|
-
export { P as PlaceOrderResult, b as Stage, T as TokenBalance, f as TokenInfo, d as TokenSearchResponse, e as executeOrder } from './execute-
|
|
3
|
+
import { S as SwapQuoteParams, a as SwapQuoteResponse, Q as QuoteTokenInfo, B as BalanceRequestParams, c as BalanceResponse } from './execute-CKTsf_tD.js';
|
|
4
|
+
export { P as PlaceOrderResult, b as Stage, T as TokenBalance, f as TokenInfo, d as TokenSearchResponse, e as executeOrder } from './execute-CKTsf_tD.js';
|
|
5
5
|
import { WalletClient } from 'viem';
|
|
6
6
|
import { A as AdaptedWallet } from './wallet-MmUIz8GE.js';
|
|
7
7
|
import '@mysten/sui/transactions';
|
package/dist/core.js
CHANGED
|
@@ -631,18 +631,33 @@ async function executeOrder({
|
|
|
631
631
|
onStatus,
|
|
632
632
|
options = {}
|
|
633
633
|
}) {
|
|
634
|
-
const
|
|
634
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
635
|
+
const log = (...args) => {
|
|
636
|
+
if (isDev) console.log("[OneShot::executeOrder]", ...args);
|
|
637
|
+
};
|
|
635
638
|
const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
|
|
636
|
-
const update = (stage, message) =>
|
|
639
|
+
const update = (stage, message) => {
|
|
640
|
+
log("Stage:", stage, "| Message:", message ?? messageFor(stage));
|
|
641
|
+
onStatus?.(stage, message ?? messageFor(stage));
|
|
642
|
+
};
|
|
637
643
|
try {
|
|
644
|
+
const deadline = options.deadline ?? Math.floor(Date.now() / 1e3) + 20 * 60;
|
|
645
|
+
log("Starting execution:", {
|
|
646
|
+
accountAddress,
|
|
647
|
+
recipientAddress,
|
|
648
|
+
deadline,
|
|
649
|
+
tokenIn: quote?.tokenIn?.symbol,
|
|
650
|
+
tokenOut: quote?.tokenOut?.symbol
|
|
651
|
+
});
|
|
638
652
|
const adapter = normalizeWallet(wallet);
|
|
639
653
|
if (!adapter) throw new Error("No wallet provided");
|
|
640
654
|
const { tokenIn, tokenOut } = quote;
|
|
641
655
|
const isSingleChain = tokenIn.chainId === tokenOut.chainId;
|
|
642
656
|
const chainId = Number(tokenIn.chainId);
|
|
643
|
-
update("processing"
|
|
657
|
+
update("processing");
|
|
644
658
|
if (isEvmChain2(chainId)) {
|
|
645
|
-
|
|
659
|
+
log("Detected EVM chain:", chainId);
|
|
660
|
+
const result = await handleEvmExecution({
|
|
646
661
|
recipientAddress,
|
|
647
662
|
quote,
|
|
648
663
|
chainId,
|
|
@@ -652,9 +667,12 @@ async function executeOrder({
|
|
|
652
667
|
deadline,
|
|
653
668
|
update
|
|
654
669
|
});
|
|
670
|
+
log("EVM execution result:", result);
|
|
671
|
+
return result;
|
|
655
672
|
}
|
|
656
673
|
if (chainId === ChainID3.Solana) {
|
|
657
|
-
|
|
674
|
+
log("Detected Solana chain");
|
|
675
|
+
const result = await handleSolanaExecution({
|
|
658
676
|
recipientAddress,
|
|
659
677
|
quote,
|
|
660
678
|
accountAddress,
|
|
@@ -663,11 +681,16 @@ async function executeOrder({
|
|
|
663
681
|
deadline,
|
|
664
682
|
update
|
|
665
683
|
});
|
|
684
|
+
log("Solana execution result:", result);
|
|
685
|
+
return result;
|
|
666
686
|
}
|
|
667
|
-
|
|
668
|
-
|
|
687
|
+
const unsupported = `Unsupported chain: ${chainId}`;
|
|
688
|
+
update("error", unsupported);
|
|
689
|
+
log("Error:", unsupported);
|
|
690
|
+
return { status: false, message: unsupported, stage: "error" };
|
|
669
691
|
} catch (error) {
|
|
670
692
|
const message = error instanceof BaseError ? error.shortMessage : error instanceof Error ? error.message : String(error);
|
|
693
|
+
log("Execution failed:", { message, error });
|
|
671
694
|
update("error", message);
|
|
672
695
|
return { status: false, message, stage: "error" };
|
|
673
696
|
}
|
|
@@ -119,16 +119,7 @@ type PollResult = OrderStatus;
|
|
|
119
119
|
/**
|
|
120
120
|
* Executes a swap order on the correct chain (EVM or Solana).
|
|
121
121
|
*
|
|
122
|
-
*
|
|
123
|
-
* @param accountAddress - The wallet address initiating the swap.
|
|
124
|
-
* @param recipientAddress - recipient for output tokens.
|
|
125
|
-
* @param wallet - Adapted wallet (EVM or Solana).
|
|
126
|
-
* @param onStatus - Optional callback for UI updates.
|
|
127
|
-
* @param options - Optional execution settings.
|
|
128
|
-
* - deadline: UNIX timestamp (seconds)
|
|
129
|
-
* Default = now + 20 minutes
|
|
130
|
-
*
|
|
131
|
-
* @returns Execution result { status, message, stage }
|
|
122
|
+
* Provides detailed logs for debugging when NODE_ENV !== 'production'.
|
|
132
123
|
*/
|
|
133
124
|
declare function executeOrder({ quote, accountAddress, recipientAddress, wallet, onStatus, options, }: {
|
|
134
125
|
quote: SwapQuoteResponse;
|
|
@@ -137,7 +128,6 @@ declare function executeOrder({ quote, accountAddress, recipientAddress, wallet,
|
|
|
137
128
|
wallet: AdaptedWallet | WalletClient;
|
|
138
129
|
onStatus?: (stage: Stage, message?: string) => void;
|
|
139
130
|
options?: {
|
|
140
|
-
/** Optional swap deadline (UNIX seconds). Default: now + 20 minutes */
|
|
141
131
|
deadline?: number;
|
|
142
132
|
};
|
|
143
133
|
}): Promise<{
|
|
@@ -119,16 +119,7 @@ type PollResult = OrderStatus;
|
|
|
119
119
|
/**
|
|
120
120
|
* Executes a swap order on the correct chain (EVM or Solana).
|
|
121
121
|
*
|
|
122
|
-
*
|
|
123
|
-
* @param accountAddress - The wallet address initiating the swap.
|
|
124
|
-
* @param recipientAddress - recipient for output tokens.
|
|
125
|
-
* @param wallet - Adapted wallet (EVM or Solana).
|
|
126
|
-
* @param onStatus - Optional callback for UI updates.
|
|
127
|
-
* @param options - Optional execution settings.
|
|
128
|
-
* - deadline: UNIX timestamp (seconds)
|
|
129
|
-
* Default = now + 20 minutes
|
|
130
|
-
*
|
|
131
|
-
* @returns Execution result { status, message, stage }
|
|
122
|
+
* Provides detailed logs for debugging when NODE_ENV !== 'production'.
|
|
132
123
|
*/
|
|
133
124
|
declare function executeOrder({ quote, accountAddress, recipientAddress, wallet, onStatus, options, }: {
|
|
134
125
|
quote: SwapQuoteResponse;
|
|
@@ -137,7 +128,6 @@ declare function executeOrder({ quote, accountAddress, recipientAddress, wallet,
|
|
|
137
128
|
wallet: AdaptedWallet | WalletClient;
|
|
138
129
|
onStatus?: (stage: Stage, message?: string) => void;
|
|
139
130
|
options?: {
|
|
140
|
-
/** Optional swap deadline (UNIX seconds). Default: now + 20 minutes */
|
|
141
131
|
deadline?: number;
|
|
142
132
|
};
|
|
143
133
|
}): Promise<{
|
package/dist/index.cjs
CHANGED
|
@@ -744,18 +744,33 @@ async function executeOrder({
|
|
|
744
744
|
onStatus,
|
|
745
745
|
options = {}
|
|
746
746
|
}) {
|
|
747
|
-
const
|
|
747
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
748
|
+
const log = (...args) => {
|
|
749
|
+
if (isDev) console.log("[OneShot::executeOrder]", ...args);
|
|
750
|
+
};
|
|
748
751
|
const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
|
|
749
|
-
const update = (stage, message) =>
|
|
752
|
+
const update = (stage, message) => {
|
|
753
|
+
log("Stage:", stage, "| Message:", message ?? messageFor(stage));
|
|
754
|
+
onStatus?.(stage, message ?? messageFor(stage));
|
|
755
|
+
};
|
|
750
756
|
try {
|
|
757
|
+
const deadline = options.deadline ?? Math.floor(Date.now() / 1e3) + 20 * 60;
|
|
758
|
+
log("Starting execution:", {
|
|
759
|
+
accountAddress,
|
|
760
|
+
recipientAddress,
|
|
761
|
+
deadline,
|
|
762
|
+
tokenIn: quote?.tokenIn?.symbol,
|
|
763
|
+
tokenOut: quote?.tokenOut?.symbol
|
|
764
|
+
});
|
|
751
765
|
const adapter = normalizeWallet(wallet);
|
|
752
766
|
if (!adapter) throw new Error("No wallet provided");
|
|
753
767
|
const { tokenIn, tokenOut } = quote;
|
|
754
768
|
const isSingleChain = tokenIn.chainId === tokenOut.chainId;
|
|
755
769
|
const chainId = Number(tokenIn.chainId);
|
|
756
|
-
update("processing"
|
|
770
|
+
update("processing");
|
|
757
771
|
if ((0, import_intents_sdk10.isEvmChain)(chainId)) {
|
|
758
|
-
|
|
772
|
+
log("Detected EVM chain:", chainId);
|
|
773
|
+
const result = await handleEvmExecution({
|
|
759
774
|
recipientAddress,
|
|
760
775
|
quote,
|
|
761
776
|
chainId,
|
|
@@ -765,9 +780,12 @@ async function executeOrder({
|
|
|
765
780
|
deadline,
|
|
766
781
|
update
|
|
767
782
|
});
|
|
783
|
+
log("EVM execution result:", result);
|
|
784
|
+
return result;
|
|
768
785
|
}
|
|
769
786
|
if (chainId === import_intents_sdk10.ChainID.Solana) {
|
|
770
|
-
|
|
787
|
+
log("Detected Solana chain");
|
|
788
|
+
const result = await handleSolanaExecution({
|
|
771
789
|
recipientAddress,
|
|
772
790
|
quote,
|
|
773
791
|
accountAddress,
|
|
@@ -776,11 +794,16 @@ async function executeOrder({
|
|
|
776
794
|
deadline,
|
|
777
795
|
update
|
|
778
796
|
});
|
|
797
|
+
log("Solana execution result:", result);
|
|
798
|
+
return result;
|
|
779
799
|
}
|
|
780
|
-
|
|
781
|
-
|
|
800
|
+
const unsupported = `Unsupported chain: ${chainId}`;
|
|
801
|
+
update("error", unsupported);
|
|
802
|
+
log("Error:", unsupported);
|
|
803
|
+
return { status: false, message: unsupported, stage: "error" };
|
|
782
804
|
} catch (error) {
|
|
783
805
|
const message = error instanceof import_viem4.BaseError ? error.shortMessage : error instanceof Error ? error.message : String(error);
|
|
806
|
+
log("Execution failed:", { message, error });
|
|
784
807
|
update("error", message);
|
|
785
808
|
return { status: false, message, stage: "error" };
|
|
786
809
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { NATIVE_TOKEN, SOLANA_CHAIN_ID, SupportedChains, buildQuoteParams, getBalances, getQuote, getTokenList, isNativeAddress, isViemWalletClient, serializeBigIntsToStrings } from './core.cjs';
|
|
2
|
-
export { B as BalanceRequestParams, c as BalanceResponse, P as PlaceOrderResult, Q as QuoteTokenInfo, b as Stage, S as SwapQuoteParams, a as SwapQuoteResponse, T as TokenBalance, f as TokenInfo, d as TokenSearchResponse, e as executeOrder } from './execute-
|
|
2
|
+
export { B as BalanceRequestParams, c as BalanceResponse, P as PlaceOrderResult, Q as QuoteTokenInfo, b as Stage, S as SwapQuoteParams, a as SwapQuoteResponse, T as TokenBalance, f as TokenInfo, d as TokenSearchResponse, e as executeOrder } from './execute-DOv1i2Su.cjs';
|
|
3
3
|
export { ChainID, isEvmChain } from '@shogun-sdk/intents-sdk';
|
|
4
4
|
export { useBalances, useExecuteOrder, useQuote, useTokenList } from './react.cjs';
|
|
5
5
|
export { adaptEthersSigner, adaptSolanaWallet, adaptViemWallet } from './wallet-adapter.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { NATIVE_TOKEN, SOLANA_CHAIN_ID, SupportedChains, buildQuoteParams, getBalances, getQuote, getTokenList, isNativeAddress, isViemWalletClient, serializeBigIntsToStrings } from './core.js';
|
|
2
|
-
export { B as BalanceRequestParams, c as BalanceResponse, P as PlaceOrderResult, Q as QuoteTokenInfo, b as Stage, S as SwapQuoteParams, a as SwapQuoteResponse, T as TokenBalance, f as TokenInfo, d as TokenSearchResponse, e as executeOrder } from './execute-
|
|
2
|
+
export { B as BalanceRequestParams, c as BalanceResponse, P as PlaceOrderResult, Q as QuoteTokenInfo, b as Stage, S as SwapQuoteParams, a as SwapQuoteResponse, T as TokenBalance, f as TokenInfo, d as TokenSearchResponse, e as executeOrder } from './execute-CKTsf_tD.js';
|
|
3
3
|
export { ChainID, isEvmChain } from '@shogun-sdk/intents-sdk';
|
|
4
4
|
export { useBalances, useExecuteOrder, useQuote, useTokenList } from './react.js';
|
|
5
5
|
export { adaptEthersSigner, adaptSolanaWallet, adaptViemWallet } from './wallet-adapter.js';
|
package/dist/index.js
CHANGED
|
@@ -712,18 +712,33 @@ async function executeOrder({
|
|
|
712
712
|
onStatus,
|
|
713
713
|
options = {}
|
|
714
714
|
}) {
|
|
715
|
-
const
|
|
715
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
716
|
+
const log = (...args) => {
|
|
717
|
+
if (isDev) console.log("[OneShot::executeOrder]", ...args);
|
|
718
|
+
};
|
|
716
719
|
const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
|
|
717
|
-
const update = (stage, message) =>
|
|
720
|
+
const update = (stage, message) => {
|
|
721
|
+
log("Stage:", stage, "| Message:", message ?? messageFor(stage));
|
|
722
|
+
onStatus?.(stage, message ?? messageFor(stage));
|
|
723
|
+
};
|
|
718
724
|
try {
|
|
725
|
+
const deadline = options.deadline ?? Math.floor(Date.now() / 1e3) + 20 * 60;
|
|
726
|
+
log("Starting execution:", {
|
|
727
|
+
accountAddress,
|
|
728
|
+
recipientAddress,
|
|
729
|
+
deadline,
|
|
730
|
+
tokenIn: quote?.tokenIn?.symbol,
|
|
731
|
+
tokenOut: quote?.tokenOut?.symbol
|
|
732
|
+
});
|
|
719
733
|
const adapter = normalizeWallet(wallet);
|
|
720
734
|
if (!adapter) throw new Error("No wallet provided");
|
|
721
735
|
const { tokenIn, tokenOut } = quote;
|
|
722
736
|
const isSingleChain = tokenIn.chainId === tokenOut.chainId;
|
|
723
737
|
const chainId = Number(tokenIn.chainId);
|
|
724
|
-
update("processing"
|
|
738
|
+
update("processing");
|
|
725
739
|
if (isEvmChain2(chainId)) {
|
|
726
|
-
|
|
740
|
+
log("Detected EVM chain:", chainId);
|
|
741
|
+
const result = await handleEvmExecution({
|
|
727
742
|
recipientAddress,
|
|
728
743
|
quote,
|
|
729
744
|
chainId,
|
|
@@ -733,9 +748,12 @@ async function executeOrder({
|
|
|
733
748
|
deadline,
|
|
734
749
|
update
|
|
735
750
|
});
|
|
751
|
+
log("EVM execution result:", result);
|
|
752
|
+
return result;
|
|
736
753
|
}
|
|
737
754
|
if (chainId === ChainID3.Solana) {
|
|
738
|
-
|
|
755
|
+
log("Detected Solana chain");
|
|
756
|
+
const result = await handleSolanaExecution({
|
|
739
757
|
recipientAddress,
|
|
740
758
|
quote,
|
|
741
759
|
accountAddress,
|
|
@@ -744,11 +762,16 @@ async function executeOrder({
|
|
|
744
762
|
deadline,
|
|
745
763
|
update
|
|
746
764
|
});
|
|
765
|
+
log("Solana execution result:", result);
|
|
766
|
+
return result;
|
|
747
767
|
}
|
|
748
|
-
|
|
749
|
-
|
|
768
|
+
const unsupported = `Unsupported chain: ${chainId}`;
|
|
769
|
+
update("error", unsupported);
|
|
770
|
+
log("Error:", unsupported);
|
|
771
|
+
return { status: false, message: unsupported, stage: "error" };
|
|
750
772
|
} catch (error) {
|
|
751
773
|
const message = error instanceof BaseError ? error.shortMessage : error instanceof Error ? error.message : String(error);
|
|
774
|
+
log("Execution failed:", { message, error });
|
|
752
775
|
update("error", message);
|
|
753
776
|
return { status: false, message, stage: "error" };
|
|
754
777
|
}
|
package/dist/react.cjs
CHANGED
|
@@ -596,18 +596,33 @@ async function executeOrder({
|
|
|
596
596
|
onStatus,
|
|
597
597
|
options = {}
|
|
598
598
|
}) {
|
|
599
|
-
const
|
|
599
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
600
|
+
const log = (...args) => {
|
|
601
|
+
if (isDev) console.log("[OneShot::executeOrder]", ...args);
|
|
602
|
+
};
|
|
600
603
|
const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
|
|
601
|
-
const update = (stage, message) =>
|
|
604
|
+
const update = (stage, message) => {
|
|
605
|
+
log("Stage:", stage, "| Message:", message ?? messageFor(stage));
|
|
606
|
+
onStatus?.(stage, message ?? messageFor(stage));
|
|
607
|
+
};
|
|
602
608
|
try {
|
|
609
|
+
const deadline = options.deadline ?? Math.floor(Date.now() / 1e3) + 20 * 60;
|
|
610
|
+
log("Starting execution:", {
|
|
611
|
+
accountAddress,
|
|
612
|
+
recipientAddress,
|
|
613
|
+
deadline,
|
|
614
|
+
tokenIn: quote?.tokenIn?.symbol,
|
|
615
|
+
tokenOut: quote?.tokenOut?.symbol
|
|
616
|
+
});
|
|
603
617
|
const adapter = normalizeWallet(wallet);
|
|
604
618
|
if (!adapter) throw new Error("No wallet provided");
|
|
605
619
|
const { tokenIn, tokenOut } = quote;
|
|
606
620
|
const isSingleChain = tokenIn.chainId === tokenOut.chainId;
|
|
607
621
|
const chainId = Number(tokenIn.chainId);
|
|
608
|
-
update("processing"
|
|
622
|
+
update("processing");
|
|
609
623
|
if ((0, import_intents_sdk8.isEvmChain)(chainId)) {
|
|
610
|
-
|
|
624
|
+
log("Detected EVM chain:", chainId);
|
|
625
|
+
const result = await handleEvmExecution({
|
|
611
626
|
recipientAddress,
|
|
612
627
|
quote,
|
|
613
628
|
chainId,
|
|
@@ -617,9 +632,12 @@ async function executeOrder({
|
|
|
617
632
|
deadline,
|
|
618
633
|
update
|
|
619
634
|
});
|
|
635
|
+
log("EVM execution result:", result);
|
|
636
|
+
return result;
|
|
620
637
|
}
|
|
621
638
|
if (chainId === import_intents_sdk8.ChainID.Solana) {
|
|
622
|
-
|
|
639
|
+
log("Detected Solana chain");
|
|
640
|
+
const result = await handleSolanaExecution({
|
|
623
641
|
recipientAddress,
|
|
624
642
|
quote,
|
|
625
643
|
accountAddress,
|
|
@@ -628,11 +646,16 @@ async function executeOrder({
|
|
|
628
646
|
deadline,
|
|
629
647
|
update
|
|
630
648
|
});
|
|
649
|
+
log("Solana execution result:", result);
|
|
650
|
+
return result;
|
|
631
651
|
}
|
|
632
|
-
|
|
633
|
-
|
|
652
|
+
const unsupported = `Unsupported chain: ${chainId}`;
|
|
653
|
+
update("error", unsupported);
|
|
654
|
+
log("Error:", unsupported);
|
|
655
|
+
return { status: false, message: unsupported, stage: "error" };
|
|
634
656
|
} catch (error) {
|
|
635
657
|
const message = error instanceof import_viem3.BaseError ? error.shortMessage : error instanceof Error ? error.message : String(error);
|
|
658
|
+
log("Execution failed:", { message, error });
|
|
636
659
|
update("error", message);
|
|
637
660
|
return { status: false, message, stage: "error" };
|
|
638
661
|
}
|
package/dist/react.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TokenSearchParams, TokenSearchResponse } from '@shogun-sdk/intents-sdk';
|
|
2
2
|
export { ChainID, isEvmChain } from '@shogun-sdk/intents-sdk';
|
|
3
|
-
import { a as SwapQuoteResponse, e as executeOrder, b as Stage, g as PollResult, S as SwapQuoteParams, B as BalanceRequestParams, c as BalanceResponse } from './execute-
|
|
4
|
-
export { P as PlaceOrderResult, Q as QuoteTokenInfo, T as TokenBalance, f as TokenInfo, d as TokenSearchResponse } from './execute-
|
|
3
|
+
import { a as SwapQuoteResponse, e as executeOrder, b as Stage, g as PollResult, S as SwapQuoteParams, B as BalanceRequestParams, c as BalanceResponse } from './execute-DOv1i2Su.cjs';
|
|
4
|
+
export { P as PlaceOrderResult, Q as QuoteTokenInfo, T as TokenBalance, f as TokenInfo, d as TokenSearchResponse } from './execute-DOv1i2Su.cjs';
|
|
5
5
|
import { A as AdaptedWallet } from './wallet-MmUIz8GE.cjs';
|
|
6
6
|
import { WalletClient } from 'viem';
|
|
7
7
|
import '@mysten/sui/transactions';
|
package/dist/react.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TokenSearchParams, TokenSearchResponse } from '@shogun-sdk/intents-sdk';
|
|
2
2
|
export { ChainID, isEvmChain } from '@shogun-sdk/intents-sdk';
|
|
3
|
-
import { a as SwapQuoteResponse, e as executeOrder, b as Stage, g as PollResult, S as SwapQuoteParams, B as BalanceRequestParams, c as BalanceResponse } from './execute-
|
|
4
|
-
export { P as PlaceOrderResult, Q as QuoteTokenInfo, T as TokenBalance, f as TokenInfo, d as TokenSearchResponse } from './execute-
|
|
3
|
+
import { a as SwapQuoteResponse, e as executeOrder, b as Stage, g as PollResult, S as SwapQuoteParams, B as BalanceRequestParams, c as BalanceResponse } from './execute-CKTsf_tD.js';
|
|
4
|
+
export { P as PlaceOrderResult, Q as QuoteTokenInfo, T as TokenBalance, f as TokenInfo, d as TokenSearchResponse } from './execute-CKTsf_tD.js';
|
|
5
5
|
import { A as AdaptedWallet } from './wallet-MmUIz8GE.js';
|
|
6
6
|
import { WalletClient } from 'viem';
|
|
7
7
|
import '@mysten/sui/transactions';
|
package/dist/react.js
CHANGED
|
@@ -574,18 +574,33 @@ async function executeOrder({
|
|
|
574
574
|
onStatus,
|
|
575
575
|
options = {}
|
|
576
576
|
}) {
|
|
577
|
-
const
|
|
577
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
578
|
+
const log = (...args) => {
|
|
579
|
+
if (isDev) console.log("[OneShot::executeOrder]", ...args);
|
|
580
|
+
};
|
|
578
581
|
const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
|
|
579
|
-
const update = (stage, message) =>
|
|
582
|
+
const update = (stage, message) => {
|
|
583
|
+
log("Stage:", stage, "| Message:", message ?? messageFor(stage));
|
|
584
|
+
onStatus?.(stage, message ?? messageFor(stage));
|
|
585
|
+
};
|
|
580
586
|
try {
|
|
587
|
+
const deadline = options.deadline ?? Math.floor(Date.now() / 1e3) + 20 * 60;
|
|
588
|
+
log("Starting execution:", {
|
|
589
|
+
accountAddress,
|
|
590
|
+
recipientAddress,
|
|
591
|
+
deadline,
|
|
592
|
+
tokenIn: quote?.tokenIn?.symbol,
|
|
593
|
+
tokenOut: quote?.tokenOut?.symbol
|
|
594
|
+
});
|
|
581
595
|
const adapter = normalizeWallet(wallet);
|
|
582
596
|
if (!adapter) throw new Error("No wallet provided");
|
|
583
597
|
const { tokenIn, tokenOut } = quote;
|
|
584
598
|
const isSingleChain = tokenIn.chainId === tokenOut.chainId;
|
|
585
599
|
const chainId = Number(tokenIn.chainId);
|
|
586
|
-
update("processing"
|
|
600
|
+
update("processing");
|
|
587
601
|
if (isEvmChain2(chainId)) {
|
|
588
|
-
|
|
602
|
+
log("Detected EVM chain:", chainId);
|
|
603
|
+
const result = await handleEvmExecution({
|
|
589
604
|
recipientAddress,
|
|
590
605
|
quote,
|
|
591
606
|
chainId,
|
|
@@ -595,9 +610,12 @@ async function executeOrder({
|
|
|
595
610
|
deadline,
|
|
596
611
|
update
|
|
597
612
|
});
|
|
613
|
+
log("EVM execution result:", result);
|
|
614
|
+
return result;
|
|
598
615
|
}
|
|
599
616
|
if (chainId === ChainID3.Solana) {
|
|
600
|
-
|
|
617
|
+
log("Detected Solana chain");
|
|
618
|
+
const result = await handleSolanaExecution({
|
|
601
619
|
recipientAddress,
|
|
602
620
|
quote,
|
|
603
621
|
accountAddress,
|
|
@@ -606,11 +624,16 @@ async function executeOrder({
|
|
|
606
624
|
deadline,
|
|
607
625
|
update
|
|
608
626
|
});
|
|
627
|
+
log("Solana execution result:", result);
|
|
628
|
+
return result;
|
|
609
629
|
}
|
|
610
|
-
|
|
611
|
-
|
|
630
|
+
const unsupported = `Unsupported chain: ${chainId}`;
|
|
631
|
+
update("error", unsupported);
|
|
632
|
+
log("Error:", unsupported);
|
|
633
|
+
return { status: false, message: unsupported, stage: "error" };
|
|
612
634
|
} catch (error) {
|
|
613
635
|
const message = error instanceof BaseError ? error.shortMessage : error instanceof Error ? error.message : String(error);
|
|
636
|
+
log("Execution failed:", { message, error });
|
|
614
637
|
update("error", message);
|
|
615
638
|
return { status: false, message, stage: "error" };
|
|
616
639
|
}
|
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.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shogun Network Swap utilities and helpers",
|
|
6
6
|
"author": "Shogun Network",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@solana/web3.js": "^1.98.4",
|
|
58
58
|
"ethers": "^5.6.1",
|
|
59
59
|
"wagmi": "2.18.0",
|
|
60
|
-
"@shogun-sdk/intents-sdk": "1.2.6-test.
|
|
60
|
+
"@shogun-sdk/intents-sdk": "1.2.6-test.1"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"viem": "^2.38.1",
|