context-markets-react 0.1.2 → 0.2.0
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.ts +7 -18
- package/dist/index.js +30 -14
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import * as context_markets from 'context-markets';
|
|
4
|
-
import { ChainOption, ContextClient, Balance, ClaimableResponse, GetPortfolioParams, Portfolio, PortfolioStats, GetPositionsParams, PositionList, OracleQuoteLatest, Market, GetActivityParams, ActivityResponse, SearchMarketsParams, MarketList, GetOrderbookParams, Orderbook, GetPriceHistoryParams, PriceHistory, Quotes, MarketSearchParams, MarketSearchResult, SimulateTradeParams, SimulateResult,
|
|
4
|
+
import { ChainOption, ContextClient, Balance, ClaimableResponse, GetPortfolioParams, Portfolio, PortfolioStats, GetPositionsParams, PositionList, OracleQuoteLatest, Market, GetActivityParams, ActivityResponse, SearchMarketsParams, MarketList, GetOrderbookParams, Orderbook, GetPriceHistoryParams, PriceHistory, Quotes, MarketSearchParams, MarketSearchResult, SimulateTradeParams, SimulateResult, SetupResult, AccountStatus, DepositResult, Order, GetOrdersParams, OrderList, CancelResult, CancelReplaceResult, PlaceOrderRequest, CreateOrderResult, PlaceMarketOrderRequest, SubmitQuestionResult, AgentSubmitMarketDraft, QuestionSubmission, SubmitAndWaitOptions, CreateMarketResult } from 'context-markets';
|
|
5
5
|
export { ChainOption } from 'context-markets';
|
|
6
6
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
7
|
import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
@@ -181,23 +181,12 @@ declare function useLatestOracleQuote(marketId: string, options?: Omit<UseQueryO
|
|
|
181
181
|
quote: context_markets.ApiComponents["schemas"]["OracleQuote"] & unknown;
|
|
182
182
|
}, Error>;
|
|
183
183
|
|
|
184
|
-
declare function useAccountStatus(options?: Omit<UseQueryOptions<
|
|
185
|
-
declare function useAccountSetup(options?: Omit<UseMutationOptions<
|
|
186
|
-
|
|
187
|
-
txHash: string;
|
|
188
|
-
user: string;
|
|
189
|
-
operator: string;
|
|
190
|
-
relayer: string;
|
|
191
|
-
} | WalletSetupResult, Error, void, unknown>;
|
|
192
|
-
declare function useDeposit(options?: Omit<UseMutationOptions<GaslessDepositResult | Hex, Error, number>, "mutationFn">): _tanstack_react_query.UseMutationResult<`0x${string}` | {
|
|
193
|
-
success: true;
|
|
194
|
-
txHash: string;
|
|
195
|
-
user: string;
|
|
196
|
-
token: string;
|
|
197
|
-
amount: string;
|
|
198
|
-
relayer: string;
|
|
199
|
-
}, Error, number, unknown>;
|
|
184
|
+
declare function useAccountStatus(options?: Omit<UseQueryOptions<AccountStatus>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<AccountStatus, Error>;
|
|
185
|
+
declare function useAccountSetup(options?: Omit<UseMutationOptions<SetupResult, Error, void>, "mutationFn">): _tanstack_react_query.UseMutationResult<SetupResult, Error, void, unknown>;
|
|
186
|
+
declare function useDeposit(options?: Omit<UseMutationOptions<DepositResult, Error, number>, "mutationFn">): _tanstack_react_query.UseMutationResult<DepositResult, Error, number, unknown>;
|
|
200
187
|
declare function useWithdraw(options?: Omit<UseMutationOptions<Hex, Error, number>, "mutationFn">): _tanstack_react_query.UseMutationResult<`0x${string}`, Error, number, unknown>;
|
|
188
|
+
declare function useApproveUsdc(options?: Omit<UseMutationOptions<Hex | null, Error, void>, "mutationFn">): _tanstack_react_query.UseMutationResult<`0x${string}` | null, Error, void, unknown>;
|
|
189
|
+
declare function useApproveOperator(options?: Omit<UseMutationOptions<Hex | null, Error, void>, "mutationFn">): _tanstack_react_query.UseMutationResult<`0x${string}` | null, Error, void, unknown>;
|
|
201
190
|
|
|
202
191
|
declare function useOrders(params?: GetOrdersParams, options?: Omit<UseQueryOptions<OrderList>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<{
|
|
203
192
|
orders: context_markets.ApiComponents["schemas"]["OrderWithAvgFillPrice"][];
|
|
@@ -320,4 +309,4 @@ declare function useAgentSubmitAndWait(options?: Omit<UseMutationOptions<Questio
|
|
|
320
309
|
}[];
|
|
321
310
|
}, Error, AgentSubmitAndWaitInput, unknown>;
|
|
322
311
|
|
|
323
|
-
export { ContextProvider, ContextWalletError, contextKeys, useAccountSetup, useAccountStatus, useAgentSubmit, useAgentSubmitAndWait, useBalance, useCancelOrder, useCancelReplace, useClaimable, useContextClient, useCreateMarket, useCreateMarketOrder, useCreateOrder, useDeposit, useLatestOracleQuote, useMarket, useMarketActivity, useMarkets, useOracle, useOrder, useOrderbook, useOrders, usePortfolio, usePortfolioStats, usePositions, usePriceHistory, useQuotes, useSearchMarkets, useSimulateTrade, useSubmitAndWait, useSubmitQuestion, useWithdraw };
|
|
312
|
+
export { ContextProvider, ContextWalletError, contextKeys, useAccountSetup, useAccountStatus, useAgentSubmit, useAgentSubmitAndWait, useApproveOperator, useApproveUsdc, useBalance, useCancelOrder, useCancelReplace, useClaimable, useContextClient, useCreateMarket, useCreateMarketOrder, useCreateOrder, useDeposit, useLatestOracleQuote, useMarket, useMarketActivity, useMarkets, useOracle, useOrder, useOrderbook, useOrders, usePortfolio, usePortfolioStats, usePositions, usePriceHistory, useQuotes, useSearchMarkets, useSimulateTrade, useSubmitAndWait, useSubmitQuestion, useWithdraw };
|
package/dist/index.js
CHANGED
|
@@ -236,13 +236,7 @@ function useAccountSetup(options) {
|
|
|
236
236
|
const client = useContextClient();
|
|
237
237
|
const queryClient = useQueryClient();
|
|
238
238
|
return useMutation({
|
|
239
|
-
mutationFn:
|
|
240
|
-
try {
|
|
241
|
-
return await client.account.gaslessSetup();
|
|
242
|
-
} catch {
|
|
243
|
-
return await client.account.setup();
|
|
244
|
-
}
|
|
245
|
-
},
|
|
239
|
+
mutationFn: () => client.account.setup(),
|
|
246
240
|
retry: false,
|
|
247
241
|
onSuccess: (...args) => {
|
|
248
242
|
queryClient.invalidateQueries({ queryKey: contextKeys.account.all });
|
|
@@ -255,13 +249,7 @@ function useDeposit(options) {
|
|
|
255
249
|
const client = useContextClient();
|
|
256
250
|
const queryClient = useQueryClient();
|
|
257
251
|
return useMutation({
|
|
258
|
-
mutationFn:
|
|
259
|
-
try {
|
|
260
|
-
return await client.account.gaslessDeposit(amount);
|
|
261
|
-
} catch {
|
|
262
|
-
return await client.account.deposit(amount);
|
|
263
|
-
}
|
|
264
|
-
},
|
|
252
|
+
mutationFn: (amount) => client.account.deposit(amount),
|
|
265
253
|
retry: false,
|
|
266
254
|
onSuccess: (...args) => {
|
|
267
255
|
queryClient.invalidateQueries({ queryKey: contextKeys.account.all });
|
|
@@ -285,6 +273,32 @@ function useWithdraw(options) {
|
|
|
285
273
|
...options
|
|
286
274
|
});
|
|
287
275
|
}
|
|
276
|
+
function useApproveUsdc(options) {
|
|
277
|
+
const client = useContextClient();
|
|
278
|
+
const queryClient = useQueryClient();
|
|
279
|
+
return useMutation({
|
|
280
|
+
mutationFn: () => client.account.approveUsdc(),
|
|
281
|
+
retry: false,
|
|
282
|
+
onSuccess: (...args) => {
|
|
283
|
+
queryClient.invalidateQueries({ queryKey: contextKeys.account.all });
|
|
284
|
+
options?.onSuccess?.(...args);
|
|
285
|
+
},
|
|
286
|
+
...options
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function useApproveOperator(options) {
|
|
290
|
+
const client = useContextClient();
|
|
291
|
+
const queryClient = useQueryClient();
|
|
292
|
+
return useMutation({
|
|
293
|
+
mutationFn: () => client.account.approveOperator(),
|
|
294
|
+
retry: false,
|
|
295
|
+
onSuccess: (...args) => {
|
|
296
|
+
queryClient.invalidateQueries({ queryKey: contextKeys.account.all });
|
|
297
|
+
options?.onSuccess?.(...args);
|
|
298
|
+
},
|
|
299
|
+
...options
|
|
300
|
+
});
|
|
301
|
+
}
|
|
288
302
|
|
|
289
303
|
// src/hooks/useOrders.ts
|
|
290
304
|
import { useQuery as useQuery4 } from "@tanstack/react-query";
|
|
@@ -431,6 +445,8 @@ export {
|
|
|
431
445
|
useAccountStatus,
|
|
432
446
|
useAgentSubmit,
|
|
433
447
|
useAgentSubmitAndWait,
|
|
448
|
+
useApproveOperator,
|
|
449
|
+
useApproveUsdc,
|
|
434
450
|
useBalance,
|
|
435
451
|
useCancelOrder,
|
|
436
452
|
useCancelReplace,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-markets-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React hooks for Context Markets — built on context-markets and TanStack Query",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Context",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"context-markets": ">=0.
|
|
37
|
+
"context-markets": ">=0.6.0",
|
|
38
38
|
"@tanstack/react-query": ">=5.0.0",
|
|
39
39
|
"react": ">=18.0.0",
|
|
40
40
|
"viem": ">=2.0.0",
|
|
41
41
|
"wagmi": ">=2.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"context-markets": "^0.
|
|
44
|
+
"context-markets": "^0.6.0",
|
|
45
45
|
"@tanstack/react-query": "^5.0.0",
|
|
46
46
|
"@testing-library/react": "^16.0.0",
|
|
47
47
|
"@types/react": "^19.2.14",
|