@pear-protocol/symmio-client 0.2.38 → 0.2.40
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.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +21 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -6
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.js +23 -48
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +23 -48
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -536,8 +536,8 @@ var MUON_BASE_URLS = [
|
|
|
536
536
|
var MUON_APP_NAME = "symmio";
|
|
537
537
|
var MUON_REQUEST_TIMEOUT = 15e3;
|
|
538
538
|
var HEDGER_BASE_URLS = {
|
|
539
|
-
[42161 /* ARBITRUM */]: "https://www.perps-streaming.com/v1/42161a/0x6273242a7E88b3De90822b31648C212215caaFE4",
|
|
540
|
-
[8453 /* BASE */]: "https://www.perps-streaming.com/v1/8453a/
|
|
539
|
+
[42161 /* ARBITRUM */]: "https://www.perps-streaming.com/v1/42161a/0x6273242a7E88b3De90822b31648C212215caaFE4/",
|
|
540
|
+
[8453 /* BASE */]: "https://www.perps-streaming.com/v1/8453a/0xE43166cE17d3511B09438a359dAa53513225101D/"
|
|
541
541
|
};
|
|
542
542
|
|
|
543
543
|
// src/actions/instant.ts
|
|
@@ -595,10 +595,24 @@ async function login(chainId, params) {
|
|
|
595
595
|
body: JSON.stringify(body)
|
|
596
596
|
});
|
|
597
597
|
if (!response.ok) {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
598
|
+
let errorMessage = "";
|
|
599
|
+
if (typeof response.text === "function") {
|
|
600
|
+
const rawBody = await response.text().catch(() => "");
|
|
601
|
+
if (rawBody) {
|
|
602
|
+
try {
|
|
603
|
+
const parsed = JSON.parse(rawBody);
|
|
604
|
+
errorMessage = parsed.error_message ?? parsed.message ?? parsed.detail ?? rawBody;
|
|
605
|
+
} catch {
|
|
606
|
+
errorMessage = rawBody;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
if (!errorMessage && typeof response.json === "function") {
|
|
611
|
+
const errorData = await response.json().catch(() => null);
|
|
612
|
+
errorMessage = errorData?.error_message ?? errorData?.message ?? errorData?.detail ?? "";
|
|
613
|
+
}
|
|
614
|
+
const reason = errorMessage || response.statusText;
|
|
615
|
+
throw new Error(reason ? `Login failed: ${reason}` : "Login failed");
|
|
602
616
|
}
|
|
603
617
|
const data = await response.json();
|
|
604
618
|
if (!data.access_token) {
|
|
@@ -662,15 +676,15 @@ function clearCachedToken(address, chainId) {
|
|
|
662
676
|
}
|
|
663
677
|
async function fetchAccessToken(walletClient, signerAddress, accountAddress, chainId, domain) {
|
|
664
678
|
const resolvedDomain = domain ?? (typeof window !== "undefined" ? window.location.host : "localhost");
|
|
665
|
-
const
|
|
679
|
+
const hedgerLoginUrl = new URL("login", getHedgerBaseUrl(chainId)).href;
|
|
666
680
|
const nonce = await getNonce(chainId, accountAddress);
|
|
667
681
|
const { message, issuedAt, expirationTime } = createSiweMessage({
|
|
668
682
|
address: signerAddress,
|
|
669
|
-
statement:
|
|
683
|
+
statement: `msg: ${accountAddress}`,
|
|
670
684
|
chainId,
|
|
671
685
|
nonce,
|
|
672
686
|
domain: resolvedDomain,
|
|
673
|
-
uri
|
|
687
|
+
uri: hedgerLoginUrl
|
|
674
688
|
});
|
|
675
689
|
const signature = await walletClient.signMessage({
|
|
676
690
|
account: signerAddress,
|
|
@@ -824,12 +838,6 @@ function useSymmAuth(params) {
|
|
|
824
838
|
clearToken(address, chainId);
|
|
825
839
|
}
|
|
826
840
|
}, [address, chainId, clearToken]);
|
|
827
|
-
console.log("symm auth", {
|
|
828
|
-
address,
|
|
829
|
-
chainId,
|
|
830
|
-
walletClient,
|
|
831
|
-
symmCoreClient
|
|
832
|
-
});
|
|
833
841
|
useEffect(() => {
|
|
834
842
|
const previousAddress = previousAddressRef.current;
|
|
835
843
|
const previousChainId = previousChainIdRef.current;
|
|
@@ -849,28 +857,12 @@ function useSymmAuth(params) {
|
|
|
849
857
|
previousAddress,
|
|
850
858
|
previousChainId
|
|
851
859
|
});
|
|
852
|
-
console.log("bootstrap:dependencies", {
|
|
853
|
-
address,
|
|
854
|
-
chainId,
|
|
855
|
-
hasWalletClient: !!walletClient,
|
|
856
|
-
hasSymmCoreClient: !!symmCoreClient,
|
|
857
|
-
hasRefreshAuth: !!refreshAuthRef.current,
|
|
858
|
-
addressChanged,
|
|
859
|
-
chainChanged,
|
|
860
|
-
previousAddress,
|
|
861
|
-
previousChainId
|
|
862
|
-
});
|
|
863
860
|
if (!address) {
|
|
864
861
|
logSymmAuth("bootstrap:skip-no-address", {
|
|
865
862
|
chainId,
|
|
866
863
|
hasWalletClient: !!walletClient,
|
|
867
864
|
hasSymmCoreClient: !!symmCoreClient
|
|
868
865
|
});
|
|
869
|
-
console.log("bootstrap:skip-no-address", {
|
|
870
|
-
chainId,
|
|
871
|
-
hasWalletClient: !!walletClient,
|
|
872
|
-
hasSymmCoreClient: !!symmCoreClient
|
|
873
|
-
});
|
|
874
866
|
return;
|
|
875
867
|
}
|
|
876
868
|
const userAddress = address;
|
|
@@ -886,13 +878,6 @@ function useSymmAuth(params) {
|
|
|
886
878
|
hasSymmCoreClient: !!symmCoreClient,
|
|
887
879
|
hasRefreshAuth: !!refreshAuthRef.current
|
|
888
880
|
});
|
|
889
|
-
console.log("bootstrap:run", {
|
|
890
|
-
userAddress,
|
|
891
|
-
chainId,
|
|
892
|
-
hasWalletClient: !!walletClient,
|
|
893
|
-
hasSymmCoreClient: !!symmCoreClient,
|
|
894
|
-
hasRefreshAuth: !!refreshAuthRef.current
|
|
895
|
-
});
|
|
896
881
|
let targets = [userAddress];
|
|
897
882
|
if (symmCoreClient) {
|
|
898
883
|
try {
|
|
@@ -909,22 +894,12 @@ function useSymmAuth(params) {
|
|
|
909
894
|
chainId,
|
|
910
895
|
subaccounts
|
|
911
896
|
});
|
|
912
|
-
console.log("bootstrap:subaccounts-resolved", {
|
|
913
|
-
userAddress,
|
|
914
|
-
chainId,
|
|
915
|
-
subaccounts
|
|
916
|
-
});
|
|
917
897
|
} catch (error) {
|
|
918
898
|
logSymmAuth("bootstrap:subaccounts-failed", {
|
|
919
899
|
userAddress,
|
|
920
900
|
chainId,
|
|
921
901
|
error: error instanceof Error ? error.message : String(error)
|
|
922
902
|
});
|
|
923
|
-
console.log("bootstrap:subaccounts-failed", {
|
|
924
|
-
userAddress,
|
|
925
|
-
chainId,
|
|
926
|
-
error: error instanceof Error ? error.message : String(error)
|
|
927
|
-
});
|
|
928
903
|
}
|
|
929
904
|
}
|
|
930
905
|
const uniqueTargets = [...new Set(targets)].filter(
|