@pear-protocol/symmio-client 0.2.7 → 0.2.9
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/react/index.d.mts +3 -6
- package/dist/react/index.d.ts +3 -6
- package/dist/react/index.js +14 -31
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +14 -31
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/{provider-xhUge8b7.d.mts → provider-BoNiSPy9.d.mts} +2 -8
- package/dist/react/{provider-xhUge8b7.d.ts → provider-BoNiSPy9.d.ts} +2 -8
- package/dist/react/provider.d.mts +1 -1
- package/dist/react/provider.d.ts +1 -1
- package/dist/react/provider.js +2 -18
- package/dist/react/provider.js.map +1 -1
- package/dist/react/provider.mjs +2 -18
- package/dist/react/provider.mjs.map +1 -1
- package/package.json +1 -6
package/dist/react/index.mjs
CHANGED
|
@@ -150,13 +150,9 @@ function useSymmWs(params) {
|
|
|
150
150
|
}, [symmCoreClient, accountAddress, chainId, queryClient, setConnected]);
|
|
151
151
|
return { isConnected };
|
|
152
152
|
}
|
|
153
|
-
var noopRefreshAuth = async () => null;
|
|
154
153
|
function SymmProvider({
|
|
155
154
|
chainId = 42161,
|
|
156
155
|
address,
|
|
157
|
-
accessToken = null,
|
|
158
|
-
authToken,
|
|
159
|
-
refreshAuth = noopRefreshAuth,
|
|
160
156
|
symmCoreConfig,
|
|
161
157
|
symmioConfig,
|
|
162
158
|
children
|
|
@@ -168,27 +164,15 @@ function SymmProvider({
|
|
|
168
164
|
defaultChainId: chainId
|
|
169
165
|
});
|
|
170
166
|
}, [chainId, symmCoreConfig.apiUrl, symmCoreConfig.wsUrl]);
|
|
171
|
-
const resolvedAuthToken = authToken ?? accessToken;
|
|
172
167
|
useSymmWs({ symmCoreClient, accountAddress: address, chainId });
|
|
173
168
|
const value = useMemo(
|
|
174
169
|
() => ({
|
|
175
170
|
symmCoreClient,
|
|
176
171
|
chainId,
|
|
177
172
|
address,
|
|
178
|
-
symmioConfig
|
|
179
|
-
accessToken,
|
|
180
|
-
authToken: resolvedAuthToken,
|
|
181
|
-
refreshAuth
|
|
173
|
+
symmioConfig
|
|
182
174
|
}),
|
|
183
|
-
[
|
|
184
|
-
symmCoreClient,
|
|
185
|
-
chainId,
|
|
186
|
-
address,
|
|
187
|
-
symmioConfig,
|
|
188
|
-
accessToken,
|
|
189
|
-
resolvedAuthToken,
|
|
190
|
-
refreshAuth
|
|
191
|
-
]
|
|
175
|
+
[symmCoreClient, chainId, address, symmioConfig]
|
|
192
176
|
);
|
|
193
177
|
return /* @__PURE__ */ jsx(SymmContext.Provider, { value, children });
|
|
194
178
|
}
|
|
@@ -1061,8 +1045,7 @@ function useSymmInstantTrade(params) {
|
|
|
1061
1045
|
symmCoreClient,
|
|
1062
1046
|
chainId,
|
|
1063
1047
|
address,
|
|
1064
|
-
symmioConfig
|
|
1065
|
-
refreshAuth
|
|
1048
|
+
symmioConfig
|
|
1066
1049
|
} = useSymmContext();
|
|
1067
1050
|
const { publicClient, walletClient } = params;
|
|
1068
1051
|
const queryClient = useQueryClient();
|
|
@@ -1088,9 +1071,9 @@ function useSymmInstantTrade(params) {
|
|
|
1088
1071
|
if (selectors.length === 0) {
|
|
1089
1072
|
throw new Error("at least one delegation selector is required");
|
|
1090
1073
|
}
|
|
1091
|
-
const accessToken = useSymmAuthStore.getState().getToken(accountAddress, chainId)
|
|
1074
|
+
const accessToken = useSymmAuthStore.getState().getToken(accountAddress, chainId);
|
|
1092
1075
|
if (!accessToken) {
|
|
1093
|
-
throw new Error("
|
|
1076
|
+
throw new Error("auth token is required for instant trading");
|
|
1094
1077
|
}
|
|
1095
1078
|
const accessStates = await Promise.all(
|
|
1096
1079
|
selectors.map(
|
|
@@ -1475,7 +1458,7 @@ function useSymmApproval(params) {
|
|
|
1475
1458
|
};
|
|
1476
1459
|
}
|
|
1477
1460
|
function useSymmCancelClose() {
|
|
1478
|
-
const { symmCoreClient,
|
|
1461
|
+
const { symmCoreClient, chainId, address } = useSymmContext();
|
|
1479
1462
|
const queryClient = useQueryClient();
|
|
1480
1463
|
const cancelClose = useMutation({
|
|
1481
1464
|
mutationFn: async ({
|
|
@@ -1487,14 +1470,16 @@ function useSymmCancelClose() {
|
|
|
1487
1470
|
if (!symmCoreClient) {
|
|
1488
1471
|
throw new Error("symm-core client not available");
|
|
1489
1472
|
}
|
|
1490
|
-
const
|
|
1473
|
+
const resolvedAccountAddress = accountAddress ?? address;
|
|
1474
|
+
const resolvedChainId = overrideChainId ?? chainId;
|
|
1475
|
+
const resolvedAuthToken = authToken ?? (resolvedAccountAddress ? useSymmAuthStore.getState().getToken(resolvedAccountAddress, resolvedChainId) : null);
|
|
1491
1476
|
if (!resolvedAuthToken) {
|
|
1492
1477
|
throw new Error("auth token is required to cancel a pending close");
|
|
1493
1478
|
}
|
|
1494
1479
|
return symmCoreClient.orders.cancelClose({
|
|
1495
1480
|
quoteId,
|
|
1496
1481
|
authToken: resolvedAuthToken,
|
|
1497
|
-
chainId:
|
|
1482
|
+
chainId: resolvedChainId
|
|
1498
1483
|
});
|
|
1499
1484
|
},
|
|
1500
1485
|
onSuccess: () => {
|
|
@@ -1505,7 +1490,7 @@ function useSymmCancelClose() {
|
|
|
1505
1490
|
return { cancelClose };
|
|
1506
1491
|
}
|
|
1507
1492
|
function useSymmCloseOrder() {
|
|
1508
|
-
const { symmCoreClient,
|
|
1493
|
+
const { symmCoreClient, address, chainId } = useSymmContext();
|
|
1509
1494
|
const queryClient = useQueryClient();
|
|
1510
1495
|
const closeOrder = useMutation({
|
|
1511
1496
|
mutationFn: async (request) => {
|
|
@@ -1515,7 +1500,7 @@ function useSymmCloseOrder() {
|
|
|
1515
1500
|
return symmCoreClient.orders.close(request.id, {
|
|
1516
1501
|
kind: request.kind,
|
|
1517
1502
|
type: request.type,
|
|
1518
|
-
authToken: request.authToken ??
|
|
1503
|
+
authToken: request.authToken ?? (address ? useSymmAuthStore.getState().getToken(address, chainId) ?? void 0 : void 0)
|
|
1519
1504
|
});
|
|
1520
1505
|
},
|
|
1521
1506
|
onSuccess: () => {
|
|
@@ -25237,9 +25222,7 @@ function useSymmPendingIds(params) {
|
|
|
25237
25222
|
function useSymmPendingInstantOpens(params) {
|
|
25238
25223
|
const {
|
|
25239
25224
|
symmCoreClient,
|
|
25240
|
-
chainId: ctxChainId
|
|
25241
|
-
authToken: ctxAuthToken,
|
|
25242
|
-
refreshAuth
|
|
25225
|
+
chainId: ctxChainId
|
|
25243
25226
|
} = useSymmContext();
|
|
25244
25227
|
const { accountAddress, authToken: providedAuthToken } = params;
|
|
25245
25228
|
const chainId = params.chainId ?? ctxChainId;
|
|
@@ -25248,7 +25231,7 @@ function useSymmPendingInstantOpens(params) {
|
|
|
25248
25231
|
...params.query,
|
|
25249
25232
|
queryKey: symmKeys.pendingInstantOpens(accountAddress, chainId),
|
|
25250
25233
|
queryFn: async () => {
|
|
25251
|
-
const authToken = providedAuthToken ?? useSymmAuthStore.getState().getToken(accountAddress, chainId)
|
|
25234
|
+
const authToken = providedAuthToken ?? useSymmAuthStore.getState().getToken(accountAddress, chainId);
|
|
25252
25235
|
if (!authToken) {
|
|
25253
25236
|
throw new Error("failed to acquire auth token for pending instant opens");
|
|
25254
25237
|
}
|