@shogun-sdk/swap 0.0.2-test.4 → 0.0.2-test.5
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/index.cjs +31 -30
- package/dist/index.js +31 -30
- package/dist/react.cjs +31 -30
- package/dist/react.d.cts +1 -5
- package/dist/react.d.ts +1 -5
- package/dist/react.js +31 -30
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -854,6 +854,10 @@ function useQuote(params, options) {
|
|
|
854
854
|
const abortRef = (0, import_react3.useRef)(null);
|
|
855
855
|
const debounceRef = (0, import_react3.useRef)(null);
|
|
856
856
|
const mounted = (0, import_react3.useRef)(false);
|
|
857
|
+
const paramsKey = (0, import_react3.useMemo)(
|
|
858
|
+
() => params ? JSON.stringify(serializeBigIntsToStrings(params)) : null,
|
|
859
|
+
[params]
|
|
860
|
+
);
|
|
857
861
|
(0, import_react3.useEffect)(() => {
|
|
858
862
|
mounted.current = true;
|
|
859
863
|
return () => {
|
|
@@ -862,33 +866,30 @@ function useQuote(params, options) {
|
|
|
862
866
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
863
867
|
};
|
|
864
868
|
}, []);
|
|
865
|
-
const fetchQuote = (0, import_react3.useCallback)(
|
|
866
|
-
async () => {
|
|
867
|
-
if (!params) return;
|
|
868
|
-
try {
|
|
869
|
-
setLoading(true);
|
|
870
|
-
setWarning(null);
|
|
871
|
-
const result = await getQuote(params);
|
|
872
|
-
const serializeResult = serializeBigIntsToStrings(result);
|
|
873
|
-
if (!mounted.current) return;
|
|
874
|
-
setData((prev) => {
|
|
875
|
-
if (JSON.stringify(prev) === JSON.stringify(serializeResult)) return prev;
|
|
876
|
-
return serializeResult;
|
|
877
|
-
});
|
|
878
|
-
setWarning(result.warning ?? null);
|
|
879
|
-
setError(null);
|
|
880
|
-
} catch (err) {
|
|
881
|
-
if (err.name === "AbortError") return;
|
|
882
|
-
console.error("[useQuote] fetch error:", err);
|
|
883
|
-
if (mounted.current) setError(err instanceof Error ? err : new Error(String(err)));
|
|
884
|
-
} finally {
|
|
885
|
-
if (mounted.current) setLoading(false);
|
|
886
|
-
}
|
|
887
|
-
},
|
|
888
|
-
[params]
|
|
889
|
-
);
|
|
890
|
-
(0, import_react3.useEffect)(() => {
|
|
869
|
+
const fetchQuote = (0, import_react3.useCallback)(async () => {
|
|
891
870
|
if (!params) return;
|
|
871
|
+
try {
|
|
872
|
+
setLoading(true);
|
|
873
|
+
setWarning(null);
|
|
874
|
+
const result = await getQuote(params);
|
|
875
|
+
const serializeResult = serializeBigIntsToStrings(result);
|
|
876
|
+
if (!mounted.current) return;
|
|
877
|
+
setData((prev) => {
|
|
878
|
+
if (JSON.stringify(prev) === JSON.stringify(serializeResult)) return prev;
|
|
879
|
+
return serializeResult;
|
|
880
|
+
});
|
|
881
|
+
setWarning(result.warning ?? null);
|
|
882
|
+
setError(null);
|
|
883
|
+
} catch (err) {
|
|
884
|
+
if (err.name === "AbortError") return;
|
|
885
|
+
console.error("[useQuote] fetch error:", err);
|
|
886
|
+
if (mounted.current) setError(err instanceof Error ? err : new Error(String(err)));
|
|
887
|
+
} finally {
|
|
888
|
+
if (mounted.current) setLoading(false);
|
|
889
|
+
}
|
|
890
|
+
}, [paramsKey]);
|
|
891
|
+
(0, import_react3.useEffect)(() => {
|
|
892
|
+
if (!paramsKey) return;
|
|
892
893
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
893
894
|
debounceRef.current = setTimeout(() => {
|
|
894
895
|
fetchQuote();
|
|
@@ -897,19 +898,19 @@ function useQuote(params, options) {
|
|
|
897
898
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
898
899
|
abortRef.current?.abort();
|
|
899
900
|
};
|
|
900
|
-
}, [
|
|
901
|
+
}, [paramsKey, debounceMs, fetchQuote]);
|
|
901
902
|
(0, import_react3.useEffect)(() => {
|
|
902
|
-
if (!autoRefreshMs || !
|
|
903
|
+
if (!autoRefreshMs || !paramsKey) return;
|
|
903
904
|
const interval = setInterval(() => fetchQuote(), autoRefreshMs);
|
|
904
905
|
return () => clearInterval(interval);
|
|
905
|
-
}, [autoRefreshMs,
|
|
906
|
+
}, [autoRefreshMs, paramsKey, fetchQuote]);
|
|
906
907
|
return (0, import_react3.useMemo)(
|
|
907
908
|
() => ({
|
|
908
909
|
data,
|
|
909
910
|
loading,
|
|
910
911
|
error,
|
|
911
912
|
warning,
|
|
912
|
-
refetch:
|
|
913
|
+
refetch: fetchQuote
|
|
913
914
|
}),
|
|
914
915
|
[data, loading, error, warning, fetchQuote]
|
|
915
916
|
);
|
package/dist/index.js
CHANGED
|
@@ -823,6 +823,10 @@ function useQuote(params, options) {
|
|
|
823
823
|
const abortRef = useRef3(null);
|
|
824
824
|
const debounceRef = useRef3(null);
|
|
825
825
|
const mounted = useRef3(false);
|
|
826
|
+
const paramsKey = useMemo2(
|
|
827
|
+
() => params ? JSON.stringify(serializeBigIntsToStrings(params)) : null,
|
|
828
|
+
[params]
|
|
829
|
+
);
|
|
826
830
|
useEffect3(() => {
|
|
827
831
|
mounted.current = true;
|
|
828
832
|
return () => {
|
|
@@ -831,33 +835,30 @@ function useQuote(params, options) {
|
|
|
831
835
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
832
836
|
};
|
|
833
837
|
}, []);
|
|
834
|
-
const fetchQuote = useCallback2(
|
|
835
|
-
async () => {
|
|
836
|
-
if (!params) return;
|
|
837
|
-
try {
|
|
838
|
-
setLoading(true);
|
|
839
|
-
setWarning(null);
|
|
840
|
-
const result = await getQuote(params);
|
|
841
|
-
const serializeResult = serializeBigIntsToStrings(result);
|
|
842
|
-
if (!mounted.current) return;
|
|
843
|
-
setData((prev) => {
|
|
844
|
-
if (JSON.stringify(prev) === JSON.stringify(serializeResult)) return prev;
|
|
845
|
-
return serializeResult;
|
|
846
|
-
});
|
|
847
|
-
setWarning(result.warning ?? null);
|
|
848
|
-
setError(null);
|
|
849
|
-
} catch (err) {
|
|
850
|
-
if (err.name === "AbortError") return;
|
|
851
|
-
console.error("[useQuote] fetch error:", err);
|
|
852
|
-
if (mounted.current) setError(err instanceof Error ? err : new Error(String(err)));
|
|
853
|
-
} finally {
|
|
854
|
-
if (mounted.current) setLoading(false);
|
|
855
|
-
}
|
|
856
|
-
},
|
|
857
|
-
[params]
|
|
858
|
-
);
|
|
859
|
-
useEffect3(() => {
|
|
838
|
+
const fetchQuote = useCallback2(async () => {
|
|
860
839
|
if (!params) return;
|
|
840
|
+
try {
|
|
841
|
+
setLoading(true);
|
|
842
|
+
setWarning(null);
|
|
843
|
+
const result = await getQuote(params);
|
|
844
|
+
const serializeResult = serializeBigIntsToStrings(result);
|
|
845
|
+
if (!mounted.current) return;
|
|
846
|
+
setData((prev) => {
|
|
847
|
+
if (JSON.stringify(prev) === JSON.stringify(serializeResult)) return prev;
|
|
848
|
+
return serializeResult;
|
|
849
|
+
});
|
|
850
|
+
setWarning(result.warning ?? null);
|
|
851
|
+
setError(null);
|
|
852
|
+
} catch (err) {
|
|
853
|
+
if (err.name === "AbortError") return;
|
|
854
|
+
console.error("[useQuote] fetch error:", err);
|
|
855
|
+
if (mounted.current) setError(err instanceof Error ? err : new Error(String(err)));
|
|
856
|
+
} finally {
|
|
857
|
+
if (mounted.current) setLoading(false);
|
|
858
|
+
}
|
|
859
|
+
}, [paramsKey]);
|
|
860
|
+
useEffect3(() => {
|
|
861
|
+
if (!paramsKey) return;
|
|
861
862
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
862
863
|
debounceRef.current = setTimeout(() => {
|
|
863
864
|
fetchQuote();
|
|
@@ -866,19 +867,19 @@ function useQuote(params, options) {
|
|
|
866
867
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
867
868
|
abortRef.current?.abort();
|
|
868
869
|
};
|
|
869
|
-
}, [
|
|
870
|
+
}, [paramsKey, debounceMs, fetchQuote]);
|
|
870
871
|
useEffect3(() => {
|
|
871
|
-
if (!autoRefreshMs || !
|
|
872
|
+
if (!autoRefreshMs || !paramsKey) return;
|
|
872
873
|
const interval = setInterval(() => fetchQuote(), autoRefreshMs);
|
|
873
874
|
return () => clearInterval(interval);
|
|
874
|
-
}, [autoRefreshMs,
|
|
875
|
+
}, [autoRefreshMs, paramsKey, fetchQuote]);
|
|
875
876
|
return useMemo2(
|
|
876
877
|
() => ({
|
|
877
878
|
data,
|
|
878
879
|
loading,
|
|
879
880
|
error,
|
|
880
881
|
warning,
|
|
881
|
-
refetch:
|
|
882
|
+
refetch: fetchQuote
|
|
882
883
|
}),
|
|
883
884
|
[data, loading, error, warning, fetchQuote]
|
|
884
885
|
);
|
package/dist/react.cjs
CHANGED
|
@@ -699,6 +699,10 @@ function useQuote(params, options) {
|
|
|
699
699
|
const abortRef = (0, import_react3.useRef)(null);
|
|
700
700
|
const debounceRef = (0, import_react3.useRef)(null);
|
|
701
701
|
const mounted = (0, import_react3.useRef)(false);
|
|
702
|
+
const paramsKey = (0, import_react3.useMemo)(
|
|
703
|
+
() => params ? JSON.stringify(serializeBigIntsToStrings(params)) : null,
|
|
704
|
+
[params]
|
|
705
|
+
);
|
|
702
706
|
(0, import_react3.useEffect)(() => {
|
|
703
707
|
mounted.current = true;
|
|
704
708
|
return () => {
|
|
@@ -707,33 +711,30 @@ function useQuote(params, options) {
|
|
|
707
711
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
708
712
|
};
|
|
709
713
|
}, []);
|
|
710
|
-
const fetchQuote = (0, import_react3.useCallback)(
|
|
711
|
-
async () => {
|
|
712
|
-
if (!params) return;
|
|
713
|
-
try {
|
|
714
|
-
setLoading(true);
|
|
715
|
-
setWarning(null);
|
|
716
|
-
const result = await getQuote(params);
|
|
717
|
-
const serializeResult = serializeBigIntsToStrings(result);
|
|
718
|
-
if (!mounted.current) return;
|
|
719
|
-
setData((prev) => {
|
|
720
|
-
if (JSON.stringify(prev) === JSON.stringify(serializeResult)) return prev;
|
|
721
|
-
return serializeResult;
|
|
722
|
-
});
|
|
723
|
-
setWarning(result.warning ?? null);
|
|
724
|
-
setError(null);
|
|
725
|
-
} catch (err) {
|
|
726
|
-
if (err.name === "AbortError") return;
|
|
727
|
-
console.error("[useQuote] fetch error:", err);
|
|
728
|
-
if (mounted.current) setError(err instanceof Error ? err : new Error(String(err)));
|
|
729
|
-
} finally {
|
|
730
|
-
if (mounted.current) setLoading(false);
|
|
731
|
-
}
|
|
732
|
-
},
|
|
733
|
-
[params]
|
|
734
|
-
);
|
|
735
|
-
(0, import_react3.useEffect)(() => {
|
|
714
|
+
const fetchQuote = (0, import_react3.useCallback)(async () => {
|
|
736
715
|
if (!params) return;
|
|
716
|
+
try {
|
|
717
|
+
setLoading(true);
|
|
718
|
+
setWarning(null);
|
|
719
|
+
const result = await getQuote(params);
|
|
720
|
+
const serializeResult = serializeBigIntsToStrings(result);
|
|
721
|
+
if (!mounted.current) return;
|
|
722
|
+
setData((prev) => {
|
|
723
|
+
if (JSON.stringify(prev) === JSON.stringify(serializeResult)) return prev;
|
|
724
|
+
return serializeResult;
|
|
725
|
+
});
|
|
726
|
+
setWarning(result.warning ?? null);
|
|
727
|
+
setError(null);
|
|
728
|
+
} catch (err) {
|
|
729
|
+
if (err.name === "AbortError") return;
|
|
730
|
+
console.error("[useQuote] fetch error:", err);
|
|
731
|
+
if (mounted.current) setError(err instanceof Error ? err : new Error(String(err)));
|
|
732
|
+
} finally {
|
|
733
|
+
if (mounted.current) setLoading(false);
|
|
734
|
+
}
|
|
735
|
+
}, [paramsKey]);
|
|
736
|
+
(0, import_react3.useEffect)(() => {
|
|
737
|
+
if (!paramsKey) return;
|
|
737
738
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
738
739
|
debounceRef.current = setTimeout(() => {
|
|
739
740
|
fetchQuote();
|
|
@@ -742,19 +743,19 @@ function useQuote(params, options) {
|
|
|
742
743
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
743
744
|
abortRef.current?.abort();
|
|
744
745
|
};
|
|
745
|
-
}, [
|
|
746
|
+
}, [paramsKey, debounceMs, fetchQuote]);
|
|
746
747
|
(0, import_react3.useEffect)(() => {
|
|
747
|
-
if (!autoRefreshMs || !
|
|
748
|
+
if (!autoRefreshMs || !paramsKey) return;
|
|
748
749
|
const interval = setInterval(() => fetchQuote(), autoRefreshMs);
|
|
749
750
|
return () => clearInterval(interval);
|
|
750
|
-
}, [autoRefreshMs,
|
|
751
|
+
}, [autoRefreshMs, paramsKey, fetchQuote]);
|
|
751
752
|
return (0, import_react3.useMemo)(
|
|
752
753
|
() => ({
|
|
753
754
|
data,
|
|
754
755
|
loading,
|
|
755
756
|
error,
|
|
756
757
|
warning,
|
|
757
|
-
refetch:
|
|
758
|
+
refetch: fetchQuote
|
|
758
759
|
}),
|
|
759
760
|
[data, loading, error, warning, fetchQuote]
|
|
760
761
|
);
|
package/dist/react.d.cts
CHANGED
|
@@ -93,12 +93,8 @@ declare function useExecuteOrder(): {
|
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* useQuote — React hook for fetching live swap quotes.
|
|
96
|
-
*
|
|
97
|
-
* - Supports debounce and auto-refresh.
|
|
98
|
-
* - Safe for React 18+ (no double fetch).
|
|
99
|
-
* - Compatible with AbortController.
|
|
100
96
|
*/
|
|
101
|
-
declare function useQuote(params: SwapQuoteParams, options?: {
|
|
97
|
+
declare function useQuote(params: SwapQuoteParams | null, options?: {
|
|
102
98
|
debounceMs?: number;
|
|
103
99
|
autoRefreshMs?: number;
|
|
104
100
|
}): {
|
package/dist/react.d.ts
CHANGED
|
@@ -93,12 +93,8 @@ declare function useExecuteOrder(): {
|
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* useQuote — React hook for fetching live swap quotes.
|
|
96
|
-
*
|
|
97
|
-
* - Supports debounce and auto-refresh.
|
|
98
|
-
* - Safe for React 18+ (no double fetch).
|
|
99
|
-
* - Compatible with AbortController.
|
|
100
96
|
*/
|
|
101
|
-
declare function useQuote(params: SwapQuoteParams, options?: {
|
|
97
|
+
declare function useQuote(params: SwapQuoteParams | null, options?: {
|
|
102
98
|
debounceMs?: number;
|
|
103
99
|
autoRefreshMs?: number;
|
|
104
100
|
}): {
|
package/dist/react.js
CHANGED
|
@@ -678,6 +678,10 @@ function useQuote(params, options) {
|
|
|
678
678
|
const abortRef = useRef3(null);
|
|
679
679
|
const debounceRef = useRef3(null);
|
|
680
680
|
const mounted = useRef3(false);
|
|
681
|
+
const paramsKey = useMemo2(
|
|
682
|
+
() => params ? JSON.stringify(serializeBigIntsToStrings(params)) : null,
|
|
683
|
+
[params]
|
|
684
|
+
);
|
|
681
685
|
useEffect3(() => {
|
|
682
686
|
mounted.current = true;
|
|
683
687
|
return () => {
|
|
@@ -686,33 +690,30 @@ function useQuote(params, options) {
|
|
|
686
690
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
687
691
|
};
|
|
688
692
|
}, []);
|
|
689
|
-
const fetchQuote = useCallback2(
|
|
690
|
-
async () => {
|
|
691
|
-
if (!params) return;
|
|
692
|
-
try {
|
|
693
|
-
setLoading(true);
|
|
694
|
-
setWarning(null);
|
|
695
|
-
const result = await getQuote(params);
|
|
696
|
-
const serializeResult = serializeBigIntsToStrings(result);
|
|
697
|
-
if (!mounted.current) return;
|
|
698
|
-
setData((prev) => {
|
|
699
|
-
if (JSON.stringify(prev) === JSON.stringify(serializeResult)) return prev;
|
|
700
|
-
return serializeResult;
|
|
701
|
-
});
|
|
702
|
-
setWarning(result.warning ?? null);
|
|
703
|
-
setError(null);
|
|
704
|
-
} catch (err) {
|
|
705
|
-
if (err.name === "AbortError") return;
|
|
706
|
-
console.error("[useQuote] fetch error:", err);
|
|
707
|
-
if (mounted.current) setError(err instanceof Error ? err : new Error(String(err)));
|
|
708
|
-
} finally {
|
|
709
|
-
if (mounted.current) setLoading(false);
|
|
710
|
-
}
|
|
711
|
-
},
|
|
712
|
-
[params]
|
|
713
|
-
);
|
|
714
|
-
useEffect3(() => {
|
|
693
|
+
const fetchQuote = useCallback2(async () => {
|
|
715
694
|
if (!params) return;
|
|
695
|
+
try {
|
|
696
|
+
setLoading(true);
|
|
697
|
+
setWarning(null);
|
|
698
|
+
const result = await getQuote(params);
|
|
699
|
+
const serializeResult = serializeBigIntsToStrings(result);
|
|
700
|
+
if (!mounted.current) return;
|
|
701
|
+
setData((prev) => {
|
|
702
|
+
if (JSON.stringify(prev) === JSON.stringify(serializeResult)) return prev;
|
|
703
|
+
return serializeResult;
|
|
704
|
+
});
|
|
705
|
+
setWarning(result.warning ?? null);
|
|
706
|
+
setError(null);
|
|
707
|
+
} catch (err) {
|
|
708
|
+
if (err.name === "AbortError") return;
|
|
709
|
+
console.error("[useQuote] fetch error:", err);
|
|
710
|
+
if (mounted.current) setError(err instanceof Error ? err : new Error(String(err)));
|
|
711
|
+
} finally {
|
|
712
|
+
if (mounted.current) setLoading(false);
|
|
713
|
+
}
|
|
714
|
+
}, [paramsKey]);
|
|
715
|
+
useEffect3(() => {
|
|
716
|
+
if (!paramsKey) return;
|
|
716
717
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
717
718
|
debounceRef.current = setTimeout(() => {
|
|
718
719
|
fetchQuote();
|
|
@@ -721,19 +722,19 @@ function useQuote(params, options) {
|
|
|
721
722
|
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
722
723
|
abortRef.current?.abort();
|
|
723
724
|
};
|
|
724
|
-
}, [
|
|
725
|
+
}, [paramsKey, debounceMs, fetchQuote]);
|
|
725
726
|
useEffect3(() => {
|
|
726
|
-
if (!autoRefreshMs || !
|
|
727
|
+
if (!autoRefreshMs || !paramsKey) return;
|
|
727
728
|
const interval = setInterval(() => fetchQuote(), autoRefreshMs);
|
|
728
729
|
return () => clearInterval(interval);
|
|
729
|
-
}, [autoRefreshMs,
|
|
730
|
+
}, [autoRefreshMs, paramsKey, fetchQuote]);
|
|
730
731
|
return useMemo2(
|
|
731
732
|
() => ({
|
|
732
733
|
data,
|
|
733
734
|
loading,
|
|
734
735
|
error,
|
|
735
736
|
warning,
|
|
736
|
-
refetch:
|
|
737
|
+
refetch: fetchQuote
|
|
737
738
|
}),
|
|
738
739
|
[data, loading, error, warning, fetchQuote]
|
|
739
740
|
);
|