@symmio/trading-react 4.4.0 → 4.5.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/account-layer/automatic-timelock-attempt.d.ts +11 -0
- package/dist/account-layer/automatic-timelock-attempt.d.ts.map +1 -0
- package/dist/account-layer/automatic-timelock-attempt.js +41 -0
- package/dist/account-layer/automatic-timelock-attempt.js.map +1 -0
- package/dist/account-layer/index.d.ts +9 -0
- package/dist/account-layer/index.d.ts.map +1 -1
- package/dist/account-layer/index.js +41 -32
- package/dist/account-layer/use-active-virtual-account-by-key.d.ts +33 -0
- package/dist/account-layer/use-active-virtual-account-by-key.d.ts.map +1 -0
- package/dist/account-layer/use-active-virtual-account-by-key.js +27 -0
- package/dist/account-layer/use-active-virtual-account-by-key.js.map +1 -0
- package/dist/account-layer/use-add-margin.d.ts +2 -2
- package/dist/account-layer/use-add-margin.d.ts.map +1 -1
- package/dist/account-layer/use-add-margin.js +28 -17
- package/dist/account-layer/use-add-margin.js.map +1 -1
- package/dist/account-layer/use-allocate.d.ts +2 -2
- package/dist/account-layer/use-allocate.d.ts.map +1 -1
- package/dist/account-layer/use-allocate.js +28 -17
- package/dist/account-layer/use-allocate.js.map +1 -1
- package/dist/account-layer/use-automatic-timelock-recovery.d.ts +25 -0
- package/dist/account-layer/use-automatic-timelock-recovery.d.ts.map +1 -0
- package/dist/account-layer/use-automatic-timelock-recovery.js +26 -0
- package/dist/account-layer/use-automatic-timelock-recovery.js.map +1 -0
- package/dist/account-layer/use-automatic-timelock.d.ts +48 -0
- package/dist/account-layer/use-automatic-timelock.d.ts.map +1 -0
- package/dist/account-layer/use-automatic-timelock.js +189 -0
- package/dist/account-layer/use-automatic-timelock.js.map +1 -0
- package/dist/account-layer/use-create-sub-accounts.d.ts +9 -4
- package/dist/account-layer/use-create-sub-accounts.d.ts.map +1 -1
- package/dist/account-layer/use-create-sub-accounts.js +11 -13
- package/dist/account-layer/use-create-sub-accounts.js.map +1 -1
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts +3 -3
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts.map +1 -1
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.js +32 -21
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.js.map +1 -1
- package/dist/account-layer/use-deallocate.d.ts +6 -5
- package/dist/account-layer/use-deallocate.d.ts.map +1 -1
- package/dist/account-layer/use-deallocate.js +33 -20
- package/dist/account-layer/use-deallocate.js.map +1 -1
- package/dist/account-layer/use-delete-sub-account.d.ts +2 -2
- package/dist/account-layer/use-delete-sub-account.d.ts.map +1 -1
- package/dist/account-layer/use-delete-sub-account.js +30 -19
- package/dist/account-layer/use-delete-sub-account.js.map +1 -1
- package/dist/account-layer/use-execute-account-calls.d.ts +7 -0
- package/dist/account-layer/use-execute-account-calls.d.ts.map +1 -0
- package/dist/account-layer/use-execute-account-calls.js +54 -0
- package/dist/account-layer/use-execute-account-calls.js.map +1 -0
- package/dist/account-layer/use-protected-function.d.ts +22 -0
- package/dist/account-layer/use-protected-function.d.ts.map +1 -0
- package/dist/account-layer/use-protected-function.js +68 -0
- package/dist/account-layer/use-protected-function.js.map +1 -0
- package/dist/account-layer/use-remove-margin.d.ts +2 -2
- package/dist/account-layer/use-remove-margin.d.ts.map +1 -1
- package/dist/account-layer/use-remove-margin.js +31 -20
- package/dist/account-layer/use-remove-margin.js.map +1 -1
- package/dist/account-layer/use-timelock-policy.d.ts +21 -0
- package/dist/account-layer/use-timelock-policy.d.ts.map +1 -0
- package/dist/account-layer/use-timelock-policy.js +112 -0
- package/dist/account-layer/use-timelock-policy.js.map +1 -0
- package/dist/account-layer/use-timelock-route.d.ts +75 -0
- package/dist/account-layer/use-timelock-route.d.ts.map +1 -0
- package/dist/account-layer/use-timelock-route.js +177 -0
- package/dist/account-layer/use-timelock-route.js.map +1 -0
- package/dist/account-layer/use-timelock.d.ts +102 -0
- package/dist/account-layer/use-timelock.d.ts.map +1 -0
- package/dist/account-layer/use-timelock.js +177 -0
- package/dist/account-layer/use-timelock.js.map +1 -0
- package/dist/account-layer/use-virtual-accounts-count-of-sub-account.d.ts +24 -0
- package/dist/account-layer/use-virtual-accounts-count-of-sub-account.d.ts.map +1 -0
- package/dist/account-layer/use-virtual-accounts-count-of-sub-account.js +27 -0
- package/dist/account-layer/use-virtual-accounts-count-of-sub-account.js.map +1 -0
- package/dist/account-layer/use-virtual-accounts-of-sub-account.d.ts +25 -0
- package/dist/account-layer/use-virtual-accounts-of-sub-account.d.ts.map +1 -0
- package/dist/account-layer/use-virtual-accounts-of-sub-account.js +27 -0
- package/dist/account-layer/use-virtual-accounts-of-sub-account.js.map +1 -0
- package/dist/errors/normalize-protected-write-error.d.ts +5 -0
- package/dist/errors/normalize-protected-write-error.d.ts.map +1 -0
- package/dist/errors/normalize-protected-write-error.js +43 -0
- package/dist/errors/normalize-protected-write-error.js.map +1 -0
- package/dist/errors/normalize-symm-error.d.ts.map +1 -1
- package/dist/errors/normalize-symm-error.js +56 -43
- package/dist/errors/normalize-symm-error.js.map +1 -1
- package/dist/errors/symmio-request-error.d.ts +5 -0
- package/dist/errors/symmio-request-error.d.ts.map +1 -1
- package/dist/errors/symmio-request-error.js +2 -1
- package/dist/errors/symmio-request-error.js.map +1 -1
- package/dist/gasless/index.d.ts +1 -0
- package/dist/gasless/index.d.ts.map +1 -1
- package/dist/gasless/index.js +20 -19
- package/dist/gasless/invalidate-relay-reads.d.ts +3 -1
- package/dist/gasless/invalidate-relay-reads.d.ts.map +1 -1
- package/dist/gasless/invalidate-relay-reads.js +115 -60
- package/dist/gasless/invalidate-relay-reads.js.map +1 -1
- package/dist/gasless/use-approve-operational-fee-allowance.d.ts +37 -0
- package/dist/gasless/use-approve-operational-fee-allowance.d.ts.map +1 -0
- package/dist/gasless/use-approve-operational-fee-allowance.js +48 -0
- package/dist/gasless/use-approve-operational-fee-allowance.js.map +1 -0
- package/dist/gasless/use-approve-operational-fee.d.ts +2 -2
- package/dist/gasless/use-approve-operational-fee.d.ts.map +1 -1
- package/dist/gasless/use-approve-operational-fee.js +28 -17
- package/dist/gasless/use-approve-operational-fee.js.map +1 -1
- package/dist/gasless/use-relay-gasless-batch.d.ts +5 -4
- package/dist/gasless/use-relay-gasless-batch.d.ts.map +1 -1
- package/dist/gasless/use-relay-gasless-batch.js.map +1 -1
- package/dist/index.d.ts +13 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +271 -256
- package/dist/instant-layer/index.d.ts +2 -0
- package/dist/instant-layer/index.d.ts.map +1 -1
- package/dist/instant-layer/index.js +25 -23
- package/dist/instant-layer/invalidate-delegation-grant.d.ts +17 -0
- package/dist/instant-layer/invalidate-delegation-grant.d.ts.map +1 -0
- package/dist/instant-layer/invalidate-delegation-grant.js +26 -0
- package/dist/instant-layer/invalidate-delegation-grant.js.map +1 -0
- package/dist/instant-layer/use-grant-delegation.d.ts +3 -1
- package/dist/instant-layer/use-grant-delegation.d.ts.map +1 -1
- package/dist/instant-layer/use-grant-delegation.js +19 -28
- package/dist/instant-layer/use-grant-delegation.js.map +1 -1
- package/dist/instant-layer/use-grant-delegations.d.ts +44 -0
- package/dist/instant-layer/use-grant-delegations.d.ts.map +1 -0
- package/dist/instant-layer/use-grant-delegations.js +36 -0
- package/dist/instant-layer/use-grant-delegations.js.map +1 -0
- package/dist/instant-layer/use-instant-close-fees.js +8 -8
- package/dist/instant-layer/use-instant-open-inputs.js +8 -8
- package/dist/instant-layer/use-session-key-selectors.d.ts +5 -2
- package/dist/instant-layer/use-session-key-selectors.d.ts.map +1 -1
- package/dist/instant-layer/use-session-key-selectors.js +9 -5
- package/dist/instant-layer/use-session-key-selectors.js.map +1 -1
- package/dist/instant-layer/use-simulate-grant-delegations.d.ts +25 -0
- package/dist/instant-layer/use-simulate-grant-delegations.d.ts.map +1 -0
- package/dist/instant-layer/use-simulate-grant-delegations.js +29 -0
- package/dist/instant-layer/use-simulate-grant-delegations.js.map +1 -0
- package/dist/provider/symmio-provider.d.ts +31 -4
- package/dist/provider/symmio-provider.d.ts.map +1 -1
- package/dist/provider/symmio-provider.js +12 -11
- package/dist/provider/symmio-provider.js.map +1 -1
- package/dist/solvers/timelock-capability-cache.d.ts +9 -0
- package/dist/solvers/timelock-capability-cache.d.ts.map +1 -0
- package/dist/solvers/timelock-capability-cache.js +79 -0
- package/dist/solvers/timelock-capability-cache.js.map +1 -0
- package/dist/solvers/use-solver-info.d.ts +5 -2
- package/dist/solvers/use-solver-info.d.ts.map +1 -1
- package/dist/solvers/use-solver-info.js +35 -11
- package/dist/solvers/use-solver-info.js.map +1 -1
- package/dist/transactions/write-types.d.ts +13 -1
- package/dist/transactions/write-types.d.ts.map +1 -1
- package/dist/withdraw/index.d.ts +3 -0
- package/dist/withdraw/index.d.ts.map +1 -1
- package/dist/withdraw/use-deallocate-debounce-time.d.ts +29 -0
- package/dist/withdraw/use-deallocate-debounce-time.d.ts.map +1 -0
- package/dist/withdraw/use-deallocate-debounce-time.js +27 -0
- package/dist/withdraw/use-deallocate-debounce-time.js.map +1 -0
- package/dist/withdraw/use-finalize-withdraw-request.d.ts.map +1 -1
- package/dist/withdraw/use-finalize-withdraw-request.js +13 -12
- package/dist/withdraw/use-finalize-withdraw-request.js.map +1 -1
- package/dist/withdraw/use-initiate-withdraw.d.ts +2 -2
- package/dist/withdraw/use-initiate-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-initiate-withdraw.js +29 -17
- package/dist/withdraw/use-initiate-withdraw.js.map +1 -1
- package/dist/withdraw/use-pending-withdraw-requests-batch.d.ts +19 -0
- package/dist/withdraw/use-pending-withdraw-requests-batch.d.ts.map +1 -0
- package/dist/withdraw/use-pending-withdraw-requests-batch.js +27 -0
- package/dist/withdraw/use-pending-withdraw-requests-batch.js.map +1 -0
- package/dist/withdraw/use-request-cancel-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-request-cancel-withdraw.js +14 -13
- package/dist/withdraw/use-request-cancel-withdraw.js.map +1 -1
- package/dist/withdraw/use-withdraw-cooldown-of.d.ts +33 -0
- package/dist/withdraw/use-withdraw-cooldown-of.d.ts.map +1 -0
- package/dist/withdraw/use-withdraw-cooldown-of.js +27 -0
- package/dist/withdraw/use-withdraw-cooldown-of.js.map +1 -0
- package/dist/withdraw/use-withdraw.d.ts +3 -3
- package/dist/withdraw/use-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-withdraw.js +57 -31
- package/dist/withdraw/use-withdraw.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,6 +3,7 @@ export * from './use-are-delegations-active.js';
|
|
|
3
3
|
export * from './use-delegation-expiry.js';
|
|
4
4
|
export * from './use-finalize-revoke-delegation.js';
|
|
5
5
|
export * from './use-grant-delegation.js';
|
|
6
|
+
export * from './use-grant-delegations.js';
|
|
6
7
|
export * from './use-initiate-revoke-delegation.js';
|
|
7
8
|
export * from './use-instant-close.js';
|
|
8
9
|
export * from './use-instant-close-auto.js';
|
|
@@ -25,4 +26,5 @@ export * from './use-prepare-instant-open-params.js';
|
|
|
25
26
|
export * from './use-revocation-cooldown.js';
|
|
26
27
|
export * from './use-session-key-selectors.js';
|
|
27
28
|
export * from './use-simulate-grant-delegation.js';
|
|
29
|
+
export * from './use-simulate-grant-delegations.js';
|
|
28
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/instant-layer/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,wCAAwC,CAAC;AACvD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/instant-layer/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,wCAAwC,CAAC;AACvD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC"}
|
|
@@ -3,26 +3,28 @@ import { useAreDelegationsActive as t } from "./use-are-delegations-active.js";
|
|
|
3
3
|
import { useDelegationExpiry as n } from "./use-delegation-expiry.js";
|
|
4
4
|
import { useFinalizeRevokeDelegation as r } from "./use-finalize-revoke-delegation.js";
|
|
5
5
|
import { useGrantDelegation as i } from "./use-grant-delegation.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
|
|
6
|
+
import { useGrantDelegations as a } from "./use-grant-delegations.js";
|
|
7
|
+
import { useInitiateRevokeDelegation as o } from "./use-initiate-revoke-delegation.js";
|
|
8
|
+
import { useInstantClose as s } from "./use-instant-close.js";
|
|
9
|
+
import { useInstantCloseAuto as c } from "./use-instant-close-auto.js";
|
|
10
|
+
import { useInstantCloseBulk as l } from "./use-instant-close-bulk.js";
|
|
11
|
+
import { useInstantCloseBulkAuto as u } from "./use-instant-close-bulk-auto.js";
|
|
12
|
+
import { useInstantCloseFees as d } from "./use-instant-close-fees.js";
|
|
13
|
+
import { useInstantCloses as f } from "./use-instant-closes.js";
|
|
14
|
+
import { useInstantOpen as p } from "./use-instant-open.js";
|
|
15
|
+
import { useInstantOpenAuto as m } from "./use-instant-open-auto.js";
|
|
16
|
+
import { useInstantOpenFees as h } from "./use-instant-open-fees.js";
|
|
17
|
+
import { useInstantOpenQuoteId as g } from "./use-instant-open-quote-id.js";
|
|
18
|
+
import { useInstantOpenWithTpSl as _ } from "./use-instant-open-with-tpsl.js";
|
|
19
|
+
import { useInstantOpens as v } from "./use-instant-opens.js";
|
|
20
|
+
import { useInstantTradeRequiredSelectors as y } from "./use-instant-trade-required-selectors.js";
|
|
21
|
+
import { useIsDelegationActive as b } from "./use-is-delegation-active.js";
|
|
22
|
+
import { useLimitCloseAuto as x } from "./use-limit-close-auto.js";
|
|
23
|
+
import { useLimitOpenAuto as S } from "./use-limit-open-auto.js";
|
|
24
|
+
import { usePendingRevocation as C } from "./use-pending-revocation.js";
|
|
25
|
+
import { usePrepareInstantOpenParams as w } from "./use-prepare-instant-open-params.js";
|
|
26
|
+
import { useRevocationCooldown as T } from "./use-revocation-cooldown.js";
|
|
27
|
+
import { useSessionKeySelectors as E } from "./use-session-key-selectors.js";
|
|
28
|
+
import { useSimulateGrantDelegation as D } from "./use-simulate-grant-delegation.js";
|
|
29
|
+
import { useSimulateGrantDelegations as O } from "./use-simulate-grant-delegations.js";
|
|
30
|
+
export { e as useActiveDelegations, t as useAreDelegationsActive, n as useDelegationExpiry, r as useFinalizeRevokeDelegation, i as useGrantDelegation, a as useGrantDelegations, o as useInitiateRevokeDelegation, s as useInstantClose, c as useInstantCloseAuto, l as useInstantCloseBulk, u as useInstantCloseBulkAuto, d as useInstantCloseFees, f as useInstantCloses, p as useInstantOpen, m as useInstantOpenAuto, h as useInstantOpenFees, g as useInstantOpenQuoteId, _ as useInstantOpenWithTpSl, v as useInstantOpens, y as useInstantTradeRequiredSelectors, b as useIsDelegationActive, x as useLimitCloseAuto, S as useLimitOpenAuto, C as usePendingRevocation, w as usePrepareInstantOpenParams, T as useRevocationCooldown, E as useSessionKeySelectors, D as useSimulateGrantDelegation, O as useSimulateGrantDelegations };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { Address } from 'viem';
|
|
3
|
+
/**
|
|
4
|
+
* Invalidate every read a delegation grant can move, for one granting account
|
|
5
|
+
* and the delegates it just authorized.
|
|
6
|
+
*
|
|
7
|
+
* @param queryClient - The active `QueryClient`.
|
|
8
|
+
* @param parameters - The chain's config key, the granting account, and each granted delegate.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function invalidateDelegationGrant(queryClient: QueryClient, parameters: {
|
|
13
|
+
configKey: string;
|
|
14
|
+
account: Address;
|
|
15
|
+
delegates: readonly Address[];
|
|
16
|
+
}): void;
|
|
17
|
+
//# sourceMappingURL=invalidate-delegation-grant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidate-delegation-grant.d.ts","sourceRoot":"","sources":["../../src/instant-layer/invalidate-delegation-grant.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,SAAS,OAAO,EAAE,CAAA;CAAE,QAmCnF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { predicateMatch as e } from "../utils/predicate-match.js";
|
|
2
|
+
import { invalidateAccountBalances as t } from "../utils/invalidate-account-balances.js";
|
|
3
|
+
import { getActiveDelegationsQueryKey as n, getDelegationExpiryQueryKey as r, getInstantLayerNonceQueryKey as i, getIsDelegationActiveQueryKey as a, getOperationalFeeAllowanceQueryKey as o, getPendingRevocationEtasQueryKey as s } from "@symmio/trading-core";
|
|
4
|
+
//#region src/instant-layer/invalidate-delegation-grant.ts
|
|
5
|
+
function c(c, l) {
|
|
6
|
+
let { configKey: u, account: d } = l;
|
|
7
|
+
for (let t of l.delegates) {
|
|
8
|
+
let n = {
|
|
9
|
+
configKey: u,
|
|
10
|
+
account: d,
|
|
11
|
+
delegate: t
|
|
12
|
+
};
|
|
13
|
+
c.invalidateQueries({ predicate: e(r, n) }), c.invalidateQueries({ predicate: e(a, n) });
|
|
14
|
+
}
|
|
15
|
+
c.invalidateQueries({ predicate: e(n, { configKey: u }) }), c.invalidateQueries({ predicate: e(s, { configKey: u }) }), c.invalidateQueries({ predicate: e(i, {
|
|
16
|
+
configKey: u,
|
|
17
|
+
account: d
|
|
18
|
+
}) }), c.invalidateQueries({ predicate: e(o, {
|
|
19
|
+
configKey: u,
|
|
20
|
+
payer: d
|
|
21
|
+
}) }), t(c, { configKey: u });
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { c as invalidateDelegationGrant };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=invalidate-delegation-grant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidate-delegation-grant.js","names":[],"sources":["../../src/instant-layer/invalidate-delegation-grant.ts"],"sourcesContent":["import {\n getActiveDelegationsQueryKey,\n getDelegationExpiryQueryKey,\n getInstantLayerNonceQueryKey,\n getIsDelegationActiveQueryKey,\n getOperationalFeeAllowanceQueryKey,\n getPendingRevocationEtasQueryKey,\n} from \"@symmio/trading-core\";\nimport type { QueryClient } from \"@tanstack/react-query\";\nimport type { Address } from \"viem\";\nimport { invalidateAccountBalances, predicateMatch } from \"../utils\";\n\n/**\n * Invalidate every read a delegation grant can move, for one granting account\n * and the delegates it just authorized.\n *\n * @param queryClient - The active `QueryClient`.\n * @param parameters - The chain's config key, the granting account, and each granted delegate.\n *\n * @internal\n */\nexport function invalidateDelegationGrant(\n queryClient: QueryClient,\n parameters: { configKey: string; account: Address; delegates: readonly Address[] },\n) {\n const { configKey, account } = parameters;\n\n for (const delegate of parameters.delegates) {\n const delegation = { configKey, account, delegate };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getDelegationExpiryQueryKey, delegation) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getIsDelegationActiveQueryKey, delegation) });\n }\n\n /**\n * A grant also turns probed selectors active and clears any pending\n * revocation for them. These two keys hold the delegator as an object, which\n * a field-equality predicate cannot select, and `getActiveDelegations` also\n * answers for the account's virtual accounts (resolved to their parent). So\n * they are refreshed per chain config; both are cheap reads and grants are\n * rare.\n */\n void queryClient.invalidateQueries({ predicate: predicateMatch(getActiveDelegationsQueryKey, { configKey }) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPendingRevocationEtasQueryKey, { configKey }) });\n\n /**\n * A relayed grant also consumes an InstantLayer nonce and charges the\n * operational fee from collateral. The hook cannot see which transport ran,\n * so it invalidates the superset: a wallet grant moves none of these, and an\n * extra refetch costs far less than a stale allowance silently blocking the\n * next relay.\n */\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getInstantLayerNonceQueryKey, { configKey, account }),\n });\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getOperationalFeeAllowanceQueryKey, { configKey, payer: account }),\n });\n invalidateAccountBalances(queryClient, { configKey });\n}\n"],"mappings":";;;;AAqBA,SAAgB,EACd,GACA,GACA;CACA,IAAM,EAAE,cAAW,eAAY;CAE/B,KAAK,IAAM,KAAY,EAAW,WAAW;EAC3C,IAAM,IAAa;GAAE;GAAW;GAAS;EAAS;EAElD,AADA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAU,EAAE,CAAC,GACzG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA+B,CAAU,EAAE,CAAC;CAC7G;CA0BA,AAhBA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA8B,EAAE,aAAU,CAAC,EAAE,CAAC,GAC7G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAkC,EAAE,aAAU,CAAC,EAAE,CAAC,GASjH,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAA8B;EAAE;EAAW;CAAQ,CAAC,EAChF,CAAC,GACD,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAAoC;EAAE;EAAW,OAAO;CAAQ,CAAC,EAC7F,CAAC,GACD,EAA0B,GAAa,EAAE,aAAU,CAAC;AACtD"}
|
|
@@ -24,7 +24,9 @@ export type UseGrantDelegationReturnType = UseMutationResult<GrantDelegationResu
|
|
|
24
24
|
* path; the signed-operation encoder has no PartyB form.
|
|
25
25
|
*
|
|
26
26
|
* On success the delegation reads for the account/delegated signer are
|
|
27
|
-
* invalidated,
|
|
27
|
+
* invalidated (expiry, active status, the active-delegation probe and any
|
|
28
|
+
* pending revocation the grant cleared), along with the reads a *relayed*
|
|
29
|
+
* grant additionally moves.
|
|
28
30
|
*
|
|
29
31
|
* @example
|
|
30
32
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-grant-delegation.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-grant-delegation.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"use-grant-delegation.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-grant-delegation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkC,KAAK,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACtG,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,eAAe,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAEhD,iDAAiD;AACjD,MAAM,MAAM,4BAA4B,GAAG,iBAAiB,CAC1D,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,GAAE,4BAAiC,GAAG,4BAA4B,CA6B9G"}
|
|
@@ -1,45 +1,36 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { getDelegationExpiryQueryKey as o, getInstantLayerNonceQueryKey as s, getIsDelegationActiveQueryKey as c, getOperationalFeeAllowanceQueryKey as l, grantDelegationMutationOptions as u } from "@symmio/trading-core";
|
|
9
|
-
import { useMutation as d, useQueryClient as f } from "@tanstack/react-query";
|
|
2
|
+
import { useSymmioConfig as e } from "../provider/use-symmio-config.js";
|
|
3
|
+
import { normalizeSymmError as t } from "../errors/normalize-symm-error.js";
|
|
4
|
+
import { resolveWriteResult as n } from "../transactions/resolve-write-result.js";
|
|
5
|
+
import { invalidateDelegationGrant as r } from "./invalidate-delegation-grant.js";
|
|
6
|
+
import { grantDelegationMutationOptions as i } from "@symmio/trading-core";
|
|
7
|
+
import { useMutation as a, useQueryClient as o } from "@tanstack/react-query";
|
|
10
8
|
//#region src/instant-layer/use-grant-delegation.ts
|
|
11
|
-
function
|
|
12
|
-
let
|
|
13
|
-
return
|
|
14
|
-
mutationKey:
|
|
9
|
+
function s(s = {}) {
|
|
10
|
+
let c = e(s), l = o(), u = i(c);
|
|
11
|
+
return a({
|
|
12
|
+
mutationKey: u.mutationKey,
|
|
15
13
|
mutationFn: async (e) => {
|
|
16
14
|
try {
|
|
17
|
-
return
|
|
15
|
+
return n(c, await u.mutationFn(e), {
|
|
18
16
|
chainId: e.chainId,
|
|
19
|
-
waitForReceipt:
|
|
20
|
-
confirmations:
|
|
17
|
+
waitForReceipt: s.waitForReceipt,
|
|
18
|
+
confirmations: s.confirmations
|
|
21
19
|
});
|
|
22
20
|
} catch (e) {
|
|
23
|
-
throw
|
|
21
|
+
throw t(e);
|
|
24
22
|
}
|
|
25
23
|
},
|
|
26
24
|
onSuccess: (e, t) => {
|
|
27
|
-
|
|
28
|
-
configKey:
|
|
25
|
+
r(l, {
|
|
26
|
+
configKey: c.getChainConfigKey(t.chainId ?? c.defaultChainId),
|
|
29
27
|
account: t.account.addr,
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
g.invalidateQueries({ predicate: i(o, r) }), g.invalidateQueries({ predicate: i(c, r) }), g.invalidateQueries({ predicate: i(s, {
|
|
33
|
-
configKey: n,
|
|
34
|
-
account: t.account.addr
|
|
35
|
-
}) }), g.invalidateQueries({ predicate: i(l, {
|
|
36
|
-
configKey: n,
|
|
37
|
-
payer: t.account.addr
|
|
38
|
-
}) }), a(g, { configKey: n });
|
|
28
|
+
delegates: [t.delegatedSigner]
|
|
29
|
+
});
|
|
39
30
|
}
|
|
40
31
|
});
|
|
41
32
|
}
|
|
42
33
|
//#endregion
|
|
43
|
-
export {
|
|
34
|
+
export { s as useGrantDelegation };
|
|
44
35
|
|
|
45
36
|
//# sourceMappingURL=use-grant-delegation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-grant-delegation.js","names":[],"sources":["../../src/instant-layer/use-grant-delegation.ts"],"sourcesContent":["\"use client\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"use-grant-delegation.js","names":[],"sources":["../../src/instant-layer/use-grant-delegation.ts"],"sourcesContent":["\"use client\";\n\nimport { grantDelegationMutationOptions, type GrantDelegationParameters } from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { resolveWriteResult, type WriteParameters, type WriteResult } from \"../transactions\";\nimport { invalidateDelegationGrant } from \"./invalidate-delegation-grant\";\n\n/**\n * Parameters for {@link useGrantDelegation}.\n */\nexport type UseGrantDelegationParameters = WriteParameters;\n\n/**\n * Result returned by the {@link useGrantDelegation} mutation.\n */\nexport type GrantDelegationResult = WriteResult;\n\n/** Return type of {@link useGrantDelegation}. */\nexport type UseGrantDelegationReturnType = UseMutationResult<\n GrantDelegationResult,\n SymmioRequestError,\n GrantDelegationParameters\n>;\n\n/**\n * Grant Instant Layer delegation access for one delegated signer.\n *\n * **The transport comes from config, not from the hook.** Where the chain runs\n * in gasless execution mode (or the call passes `gasless: true`), the grant is\n * signed as an InstantLayer operation and relayed — the owner pays no native\n * gas — and the relayer's broadcast hash comes back exactly where a\n * wallet-submitted hash would, so the receipt wait and the invalidation below\n * are identical either way. A `isPartyB: true` account always takes the wallet\n * path; the signed-operation encoder has no PartyB form.\n *\n * On success the delegation reads for the account/delegated signer are\n * invalidated (expiry, active status, the active-delegation probe and any\n * pending revocation the grant cleared), along with the reads a *relayed*\n * grant additionally moves.\n *\n * @example\n * ```tsx\n * const { mutate } = useGrantDelegation();\n * mutate({ account: { addr: account, isPartyB: false }, delegatedSigner, selectors, expiryTimestamp });\n * ```\n */\nexport function useGrantDelegation(parameters: UseGrantDelegationParameters = {}): UseGrantDelegationReturnType {\n const config = useSymmioConfig(parameters);\n const queryClient = useQueryClient();\n\n const base = grantDelegationMutationOptions(config);\n\n return useMutation<GrantDelegationResult, SymmioRequestError, GrantDelegationParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const hash = await base.mutationFn(variables);\n return resolveWriteResult(config, hash, {\n chainId: variables.chainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (_data, variables) => {\n invalidateDelegationGrant(queryClient, {\n /** The chain the write went to: the action defaults an omitted `chainId` to the config's. */\n configKey: config.getChainConfigKey(variables.chainId ?? config.defaultChainId),\n account: variables.account.addr,\n delegates: [variables.delegatedSigner],\n });\n },\n });\n}\n"],"mappings":";;;;;;;;AAiDA,SAAgB,EAAmB,IAA2C,CAAC,GAAiC;CAC9G,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAc,EAAe,GAE7B,IAAO,EAA+B,CAAM;CAElD,OAAO,EAAkF;EACvF,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IAEF,OAAO,EAAmB,GAAQ,MADf,EAAK,WAAW,CAAS,GACJ;KACtC,SAAS,EAAU;KACnB,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAO,MAAc;GAC/B,EAA0B,GAAa;IAErC,WAAW,EAAO,kBAAkB,EAAU,WAAW,EAAO,cAAc;IAC9E,SAAS,EAAU,QAAQ;IAC3B,WAAW,CAAC,EAAU,eAAe;GACvC,CAAC;EACH;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { GrantDelegationsParameters } from '@symmio/trading-core';
|
|
2
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
import { WriteParameters, WriteResult } from '../transactions/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Parameters for {@link useGrantDelegations}.
|
|
7
|
+
*/
|
|
8
|
+
export type UseGrantDelegationsParameters = WriteParameters;
|
|
9
|
+
/**
|
|
10
|
+
* Result returned by the {@link useGrantDelegations} mutation.
|
|
11
|
+
*/
|
|
12
|
+
export type GrantDelegationsResult = WriteResult;
|
|
13
|
+
/** Return type of {@link useGrantDelegations}. */
|
|
14
|
+
export type UseGrantDelegationsReturnType = UseMutationResult<GrantDelegationsResult, SymmioRequestError, GrantDelegationsParameters>;
|
|
15
|
+
/**
|
|
16
|
+
* Grant InstantLayer delegations to several signers of one account in a single
|
|
17
|
+
* call, for example a session key and a TP/SL executor at once.
|
|
18
|
+
*
|
|
19
|
+
* **The transport comes from config, not from the hook.** Where the chain runs
|
|
20
|
+
* in gasless execution mode (or the call passes `gasless: true`), the whole
|
|
21
|
+
* grant is one owner signature, relayed with no native gas; otherwise it is one
|
|
22
|
+
* wallet transaction. An empty list or a PartyB account is rejected before any
|
|
23
|
+
* prompt, since the contract always reverts both. The InstantLayer must have
|
|
24
|
+
* `grantDelegations`; older deployments revert.
|
|
25
|
+
*
|
|
26
|
+
* On success every granted delegate's reads for the account are invalidated
|
|
27
|
+
* (expiry, active status, the active-delegation probe and any pending
|
|
28
|
+
* revocation the grant cleared), along with the reads a *relayed* grant
|
|
29
|
+
* additionally moves.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* const { mutate } = useGrantDelegations();
|
|
34
|
+
* mutate({
|
|
35
|
+
* account: { addr: subAccount, isPartyB: false },
|
|
36
|
+
* delegations: [
|
|
37
|
+
* { delegatedSigner: sessionKey, selectors: sessionKeySelectors, expiryTimestamp },
|
|
38
|
+
* { delegatedSigner: tpslExecutor, selectors: tradingSelectors, expiryTimestamp },
|
|
39
|
+
* ],
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function useGrantDelegations(parameters?: UseGrantDelegationsParameters): UseGrantDelegationsReturnType;
|
|
44
|
+
//# sourceMappingURL=use-grant-delegations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-grant-delegations.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-grant-delegations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmC,KAAK,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AACxG,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,eAAe,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAEjD,kDAAkD;AAClD,MAAM,MAAM,6BAA6B,GAAG,iBAAiB,CAC3D,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,GAAE,6BAAkC,GAAG,6BAA6B,CA6BjH"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSymmioConfig as e } from "../provider/use-symmio-config.js";
|
|
3
|
+
import { normalizeSymmError as t } from "../errors/normalize-symm-error.js";
|
|
4
|
+
import { resolveWriteResult as n } from "../transactions/resolve-write-result.js";
|
|
5
|
+
import { invalidateDelegationGrant as r } from "./invalidate-delegation-grant.js";
|
|
6
|
+
import { grantDelegationsMutationOptions as i } from "@symmio/trading-core";
|
|
7
|
+
import { useMutation as a, useQueryClient as o } from "@tanstack/react-query";
|
|
8
|
+
//#region src/instant-layer/use-grant-delegations.ts
|
|
9
|
+
function s(s = {}) {
|
|
10
|
+
let c = e(s), l = o(), u = i(c);
|
|
11
|
+
return a({
|
|
12
|
+
mutationKey: u.mutationKey,
|
|
13
|
+
mutationFn: async (e) => {
|
|
14
|
+
try {
|
|
15
|
+
return n(c, await u.mutationFn(e), {
|
|
16
|
+
chainId: e.chainId,
|
|
17
|
+
waitForReceipt: s.waitForReceipt,
|
|
18
|
+
confirmations: s.confirmations
|
|
19
|
+
});
|
|
20
|
+
} catch (e) {
|
|
21
|
+
throw t(e);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
onSuccess: (e, t) => {
|
|
25
|
+
r(l, {
|
|
26
|
+
configKey: c.getChainConfigKey(t.chainId ?? c.defaultChainId),
|
|
27
|
+
account: t.account.addr,
|
|
28
|
+
delegates: t.delegations.map((e) => e.delegatedSigner)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { s as useGrantDelegations };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=use-grant-delegations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-grant-delegations.js","names":[],"sources":["../../src/instant-layer/use-grant-delegations.ts"],"sourcesContent":["\"use client\";\n\nimport { grantDelegationsMutationOptions, type GrantDelegationsParameters } from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { resolveWriteResult, type WriteParameters, type WriteResult } from \"../transactions\";\nimport { invalidateDelegationGrant } from \"./invalidate-delegation-grant\";\n\n/**\n * Parameters for {@link useGrantDelegations}.\n */\nexport type UseGrantDelegationsParameters = WriteParameters;\n\n/**\n * Result returned by the {@link useGrantDelegations} mutation.\n */\nexport type GrantDelegationsResult = WriteResult;\n\n/** Return type of {@link useGrantDelegations}. */\nexport type UseGrantDelegationsReturnType = UseMutationResult<\n GrantDelegationsResult,\n SymmioRequestError,\n GrantDelegationsParameters\n>;\n\n/**\n * Grant InstantLayer delegations to several signers of one account in a single\n * call, for example a session key and a TP/SL executor at once.\n *\n * **The transport comes from config, not from the hook.** Where the chain runs\n * in gasless execution mode (or the call passes `gasless: true`), the whole\n * grant is one owner signature, relayed with no native gas; otherwise it is one\n * wallet transaction. An empty list or a PartyB account is rejected before any\n * prompt, since the contract always reverts both. The InstantLayer must have\n * `grantDelegations`; older deployments revert.\n *\n * On success every granted delegate's reads for the account are invalidated\n * (expiry, active status, the active-delegation probe and any pending\n * revocation the grant cleared), along with the reads a *relayed* grant\n * additionally moves.\n *\n * @example\n * ```tsx\n * const { mutate } = useGrantDelegations();\n * mutate({\n * account: { addr: subAccount, isPartyB: false },\n * delegations: [\n * { delegatedSigner: sessionKey, selectors: sessionKeySelectors, expiryTimestamp },\n * { delegatedSigner: tpslExecutor, selectors: tradingSelectors, expiryTimestamp },\n * ],\n * });\n * ```\n */\nexport function useGrantDelegations(parameters: UseGrantDelegationsParameters = {}): UseGrantDelegationsReturnType {\n const config = useSymmioConfig(parameters);\n const queryClient = useQueryClient();\n\n const base = grantDelegationsMutationOptions(config);\n\n return useMutation<GrantDelegationsResult, SymmioRequestError, GrantDelegationsParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const hash = await base.mutationFn(variables);\n return resolveWriteResult(config, hash, {\n chainId: variables.chainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (_data, variables) => {\n invalidateDelegationGrant(queryClient, {\n /** The chain the write went to: the action defaults an omitted `chainId` to the config's. */\n configKey: config.getChainConfigKey(variables.chainId ?? config.defaultChainId),\n account: variables.account.addr,\n delegates: variables.delegations.map((delegation) => delegation.delegatedSigner),\n });\n },\n });\n}\n"],"mappings":";;;;;;;;AAuDA,SAAgB,EAAoB,IAA4C,CAAC,GAAkC;CACjH,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAc,EAAe,GAE7B,IAAO,EAAgC,CAAM;CAEnD,OAAO,EAAoF;EACzF,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IAEF,OAAO,EAAmB,GAAQ,MADf,EAAK,WAAW,CAAS,GACJ;KACtC,SAAS,EAAU;KACnB,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAO,MAAc;GAC/B,EAA0B,GAAa;IAErC,WAAW,EAAO,kBAAkB,EAAU,WAAW,EAAO,cAAc;IAC9E,SAAS,EAAU,QAAQ;IAC3B,WAAW,EAAU,YAAY,KAAK,MAAe,EAAW,eAAe;GACjF,CAAC;EACH;CACF,CAAC;AACH"}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
|
|
3
3
|
import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
|
|
4
4
|
import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { useSolverInfo as r } from "../solvers/use-solver-info.js";
|
|
6
|
+
import { useFeeForUser as i } from "../fees/use-fee-for-user.js";
|
|
7
|
+
import { useMarkets as a } from "../markets/use-markets.js";
|
|
8
|
+
import { usePriceByName as o } from "../price-service/use-price-by-name.js";
|
|
9
9
|
import { getInstantCloseFeesQueryOptions as s } from "@symmio/trading-core";
|
|
10
10
|
import { useQuery as c } from "@tanstack/react-query";
|
|
11
11
|
//#region src/instant-layer/use-instant-close-fees.ts
|
|
@@ -13,7 +13,7 @@ function l(l) {
|
|
|
13
13
|
let u = t(l), d = e(), f = l.chainId ?? d, { subAccountAddress: p, market: m, quantity: h, openedAt: g, now: _, solverId: v } = l, y = (l.query?.enabled ?? !0) && h.length > 0, b = u.getSolver({
|
|
14
14
|
chainId: f,
|
|
15
15
|
solverId: v
|
|
16
|
-
}).id === "enigma", x =
|
|
16
|
+
}).id === "enigma", x = a({
|
|
17
17
|
config: l.config,
|
|
18
18
|
chainId: f,
|
|
19
19
|
solverId: v,
|
|
@@ -21,7 +21,7 @@ function l(l) {
|
|
|
21
21
|
enabled: y,
|
|
22
22
|
staleTime: 3e5
|
|
23
23
|
}
|
|
24
|
-
}).data?.find((e) => e.symbolId === m.id), S = m.name ?? x?.name, C = m.pricePrecision ?? x?.pricePrecision, w = m.quantityPrecision ?? x?.quantityPrecision, T = m.hedgerFeeOpen ?? x?.hedgerFeeOpen, E = m.hedgerFeeClose ?? x?.hedgerFeeClose, D = x?.kind === "enigma" ? x : void 0, O = m.hedgerFeeCloseEarlyRate ?? D?.hedgerFeeCloseEarlyRate ?? E, k = m.hedgerFeeCloseEarlyThreshold ?? D?.hedgerFeeCloseEarlyThreshold ?? 0, A = m.hedgerFeeCloseStandardThreshold ?? D?.hedgerFeeCloseStandardThreshold ?? 0, j =
|
|
24
|
+
}).data?.find((e) => e.symbolId === m.id), S = m.name ?? x?.name, C = m.pricePrecision ?? x?.pricePrecision, w = m.quantityPrecision ?? x?.quantityPrecision, T = m.hedgerFeeOpen ?? x?.hedgerFeeOpen, E = m.hedgerFeeClose ?? x?.hedgerFeeClose, D = x?.kind === "enigma" ? x : void 0, O = m.hedgerFeeCloseEarlyRate ?? D?.hedgerFeeCloseEarlyRate ?? E, k = m.hedgerFeeCloseEarlyThreshold ?? D?.hedgerFeeCloseEarlyThreshold ?? 0, A = m.hedgerFeeCloseStandardThreshold ?? D?.hedgerFeeCloseStandardThreshold ?? 0, j = i({
|
|
25
25
|
config: l.config,
|
|
26
26
|
chainId: f,
|
|
27
27
|
user: p,
|
|
@@ -30,12 +30,12 @@ function l(l) {
|
|
|
30
30
|
enabled: y && l.feeRates === void 0,
|
|
31
31
|
staleTime: 3e5
|
|
32
32
|
}
|
|
33
|
-
}), M = l.feeRates ?? j.data, N =
|
|
33
|
+
}), M = l.feeRates ?? j.data, N = r({
|
|
34
34
|
config: l.config,
|
|
35
35
|
chainId: f,
|
|
36
36
|
solverId: v,
|
|
37
37
|
query: { enabled: y && b && l.solverInfo === void 0 }
|
|
38
|
-
}), P = b ? l.solverInfo ?? N.data ?? (N.isError ? {} : void 0) : void 0, F = !b || P !== void 0, I =
|
|
38
|
+
}), P = b ? l.solverInfo ?? N.data ?? (N.isError ? {} : void 0) : void 0, F = !b || P !== void 0, I = o({
|
|
39
39
|
name: S,
|
|
40
40
|
solverId: v,
|
|
41
41
|
enabled: y && l.markPrice === void 0
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
|
|
3
3
|
import { useSymmioConfig as ee } from "../provider/use-symmio-config.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { useSolverInfo as te } from "../solvers/use-solver-info.js";
|
|
5
|
+
import { useFeeForUser as ne } from "../fees/use-fee-for-user.js";
|
|
6
|
+
import { useMarkets as re } from "../markets/use-markets.js";
|
|
7
|
+
import { usePriceByName as ie } from "../price-service/use-price-by-name.js";
|
|
8
8
|
import { useEstimatedPrice as t } from "../estimated-price/use-estimated-price.js";
|
|
9
9
|
import { useLockedParams as n } from "../locked-params/use-locked-params.js";
|
|
10
10
|
import { getInstantOpenFundingError as r } from "./get-instant-open-funding-error.js";
|
|
@@ -18,7 +18,7 @@ function o(o, s, c = !0) {
|
|
|
18
18
|
}).id === "enigma", C = x ? r({
|
|
19
19
|
...o,
|
|
20
20
|
isLowcap: S
|
|
21
|
-
}) : void 0, w = x && C === void 0, T =
|
|
21
|
+
}) : void 0, w = x && C === void 0, T = re({
|
|
22
22
|
config: o.config,
|
|
23
23
|
chainId: d,
|
|
24
24
|
solverId: g,
|
|
@@ -41,7 +41,7 @@ function o(o, s, c = !0) {
|
|
|
41
41
|
lf: H.data.lf ?? "0",
|
|
42
42
|
partyAmm: H.data.partyAmm ?? "0",
|
|
43
43
|
partyBmm: H.data.partyBmm ?? "0"
|
|
44
|
-
} : void 0, pe = !y || U !== void 0, W =
|
|
44
|
+
} : void 0, pe = !y || U !== void 0, W = te({
|
|
45
45
|
config: o.config,
|
|
46
46
|
chainId: d,
|
|
47
47
|
solverId: g,
|
|
@@ -50,7 +50,7 @@ function o(o, s, c = !0) {
|
|
|
50
50
|
staleTime: 3e5,
|
|
51
51
|
retry: !1
|
|
52
52
|
}
|
|
53
|
-
}), G = o.solverInfo ?? W.data ?? (W.isError ? {} : void 0), me = !S || G !== void 0, he =
|
|
53
|
+
}), G = o.solverInfo ?? W.data ?? (W.isError ? {} : void 0), me = !S || G !== void 0, he = ne({
|
|
54
54
|
config: o.config,
|
|
55
55
|
chainId: d,
|
|
56
56
|
user: oe,
|
|
@@ -59,7 +59,7 @@ function o(o, s, c = !0) {
|
|
|
59
59
|
enabled: w && o.feeRates === void 0,
|
|
60
60
|
staleTime: 3e5
|
|
61
61
|
}
|
|
62
|
-
}), K = o.feeRates ?? he.data, ge =
|
|
62
|
+
}), K = o.feeRates ?? he.data, ge = ie({
|
|
63
63
|
name: E,
|
|
64
64
|
solverId: g,
|
|
65
65
|
enabled: w && o.markPrice === void 0
|
|
@@ -24,6 +24,9 @@ export type UseSessionKeySelectorsReturnType = readonly Hex[];
|
|
|
24
24
|
* it can send the sub-account's collateral to an address of its own choosing.
|
|
25
25
|
* Pass `withdraw: true` only for a key that must run withdrawals unattended,
|
|
26
26
|
* and treat it as a materially larger grant.
|
|
27
|
+
* `coreCalls` and `timelockScheduling` also default to `false` and are separate
|
|
28
|
+
* opt-ins. The former grants broad AccountLayer `_call` authority (including
|
|
29
|
+
* delegated timelock approval requests); the latter grants scheduling authority.
|
|
27
30
|
*
|
|
28
31
|
* The result is referentially stable across renders while the chain and scope
|
|
29
32
|
* flags do not change, so it is safe to pass straight into a mutation's
|
|
@@ -32,8 +35,8 @@ export type UseSessionKeySelectorsReturnType = readonly Hex[];
|
|
|
32
35
|
* @param parameters - Optional chain override, scope flags, and `config`.
|
|
33
36
|
* @returns The lowercase, de-duplicated selector set for the requested scope.
|
|
34
37
|
* @throws {SymmError} `UNSUPPORTED_CHAIN` when the chain is not configured.
|
|
35
|
-
* @throws {SymmError} `
|
|
36
|
-
* or `
|
|
38
|
+
* @throws {SymmError} `SESSION_KEY_SELECTORS_UNSUPPORTED_CHAIN` when the `account`,
|
|
39
|
+
* `withdraw`, `coreCalls`, or `timelockScheduling` scope is requested on a chain whose contracts are not
|
|
37
40
|
* `"0.8.6"`. Render a trade-only key there with `{ account: false }`.
|
|
38
41
|
*
|
|
39
42
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-session-key-selectors.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-session-key-selectors.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,eAAe,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAElH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAIhC,gGAAgG;AAChG,MAAM,WAAW,gCAAiC,SAAQ,eAAe,EAAE,uBAAuB;IAChG,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,8FAA8F;AAC9F,MAAM,MAAM,gCAAgC,GAAG,SAAS,GAAG,EAAE,CAAC;AAE9D
|
|
1
|
+
{"version":3,"file":"use-session-key-selectors.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-session-key-selectors.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,eAAe,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAElH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAIhC,gGAAgG;AAChG,MAAM,WAAW,gCAAiC,SAAQ,eAAe,EAAE,uBAAuB;IAChG,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,8FAA8F;AAC9F,MAAM,MAAM,gCAAgC,GAAG,SAAS,GAAG,EAAE,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,GAAE,gCAAqC,GAChD,gCAAgC,CAUlC"}
|
|
@@ -5,18 +5,22 @@ import { getSessionKeySelectors as n } from "@symmio/trading-core";
|
|
|
5
5
|
import { useMemo as r } from "react";
|
|
6
6
|
//#region src/instant-layer/use-session-key-selectors.ts
|
|
7
7
|
function i(i = {}) {
|
|
8
|
-
let a = t(i), o = e(), { trade: s, account: c, withdraw: l } = i,
|
|
8
|
+
let a = t(i), o = e(), { trade: s, account: c, withdraw: l, coreCalls: u, timelockScheduling: d } = i, f = i.chainId ?? o;
|
|
9
9
|
return r(() => n(a, {
|
|
10
|
-
chainId:
|
|
10
|
+
chainId: f,
|
|
11
11
|
trade: s,
|
|
12
12
|
account: c,
|
|
13
|
-
withdraw: l
|
|
13
|
+
withdraw: l,
|
|
14
|
+
coreCalls: u,
|
|
15
|
+
timelockScheduling: d
|
|
14
16
|
}), [
|
|
15
17
|
a,
|
|
16
|
-
|
|
18
|
+
f,
|
|
17
19
|
s,
|
|
18
20
|
c,
|
|
19
|
-
l
|
|
21
|
+
l,
|
|
22
|
+
u,
|
|
23
|
+
d
|
|
20
24
|
]);
|
|
21
25
|
}
|
|
22
26
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-session-key-selectors.js","names":[],"sources":["../../src/instant-layer/use-session-key-selectors.ts"],"sourcesContent":["\"use client\";\n\nimport { getSessionKeySelectors, type ConfigParameter, type SessionKeySelectorScope } from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport type { Hex } from \"viem\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link useSessionKeySelectors}: the target chain plus the authority scope. */\nexport interface UseSessionKeySelectorsParameters extends ConfigParameter, SessionKeySelectorScope {\n /** Chain to resolve the selector set for; defaults to the connected chain. */\n chainId?: number;\n}\n\n/** Return type of {@link useSessionKeySelectors}: the de-duplicated selector set to grant. */\nexport type UseSessionKeySelectorsReturnType = readonly Hex[];\n\n/**\n * **The** selector set to hand a session key — the set to pass to\n * `useGrantDelegation` (and to `useAreDelegationsActive` when checking whether\n * that key is still usable). It resolves the chain's contracts generation, so a\n * multi-chain app never grants the other generation's open-leg selector.\n *\n * The default scope is the onboarding grant: the instant trade lifecycle plus\n * gasless account management. Because the contract enforces that\n * `grantDelegation` is owner-only, that single grant is the *only* wallet\n * prompt a session key ever costs — every write it covers afterwards is\n * promptless and gas-free.\n *\n * `initiateWithdraw` is **opt-out by default** (`withdraw` defaults to\n * `false`): its calldata carries a caller-supplied `receiver`, so a key holding\n * it can send the sub-account's collateral to an address of its own choosing.\n * Pass `withdraw: true` only for a key that must run withdrawals unattended,\n * and treat it as a materially larger grant.\n *\n * The result is referentially stable across renders while the chain and scope\n * flags do not change, so it is safe to pass straight into a mutation's\n * variables or another hook's parameters.\n *\n * @param parameters - Optional chain override, scope flags, and `config`.\n * @returns The lowercase, de-duplicated selector set for the requested scope.\n * @throws {SymmError} `UNSUPPORTED_CHAIN` when the chain is not configured.\n * @throws {SymmError} `
|
|
1
|
+
{"version":3,"file":"use-session-key-selectors.js","names":[],"sources":["../../src/instant-layer/use-session-key-selectors.ts"],"sourcesContent":["\"use client\";\n\nimport { getSessionKeySelectors, type ConfigParameter, type SessionKeySelectorScope } from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport type { Hex } from \"viem\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link useSessionKeySelectors}: the target chain plus the authority scope. */\nexport interface UseSessionKeySelectorsParameters extends ConfigParameter, SessionKeySelectorScope {\n /** Chain to resolve the selector set for; defaults to the connected chain. */\n chainId?: number;\n}\n\n/** Return type of {@link useSessionKeySelectors}: the de-duplicated selector set to grant. */\nexport type UseSessionKeySelectorsReturnType = readonly Hex[];\n\n/**\n * **The** selector set to hand a session key — the set to pass to\n * `useGrantDelegation` (and to `useAreDelegationsActive` when checking whether\n * that key is still usable). It resolves the chain's contracts generation, so a\n * multi-chain app never grants the other generation's open-leg selector.\n *\n * The default scope is the onboarding grant: the instant trade lifecycle plus\n * gasless account management. Because the contract enforces that\n * `grantDelegation` is owner-only, that single grant is the *only* wallet\n * prompt a session key ever costs — every write it covers afterwards is\n * promptless and gas-free.\n *\n * `initiateWithdraw` is **opt-out by default** (`withdraw` defaults to\n * `false`): its calldata carries a caller-supplied `receiver`, so a key holding\n * it can send the sub-account's collateral to an address of its own choosing.\n * Pass `withdraw: true` only for a key that must run withdrawals unattended,\n * and treat it as a materially larger grant.\n * `coreCalls` and `timelockScheduling` also default to `false` and are separate\n * opt-ins. The former grants broad AccountLayer `_call` authority (including\n * delegated timelock approval requests); the latter grants scheduling authority.\n *\n * The result is referentially stable across renders while the chain and scope\n * flags do not change, so it is safe to pass straight into a mutation's\n * variables or another hook's parameters.\n *\n * @param parameters - Optional chain override, scope flags, and `config`.\n * @returns The lowercase, de-duplicated selector set for the requested scope.\n * @throws {SymmError} `UNSUPPORTED_CHAIN` when the chain is not configured.\n * @throws {SymmError} `SESSION_KEY_SELECTORS_UNSUPPORTED_CHAIN` when the `account`,\n * `withdraw`, `coreCalls`, or `timelockScheduling` scope is requested on a chain whose contracts are not\n * `\"0.8.6\"`. Render a trade-only key there with `{ account: false }`.\n *\n * @example\n * ```tsx\n * const selectors = useSessionKeySelectors();\n * const { mutate } = useGrantDelegation();\n * mutate({ account: { addr: subAccount, isPartyB: false }, delegatedSigner, selectors, expiryTimestamp });\n * ```\n *\n * @example\n * ```tsx\n * // A key that also withdraws unattended — it can move the collateral out.\n * const selectors = useSessionKeySelectors({ withdraw: true });\n * ```\n */\nexport function useSessionKeySelectors(\n parameters: UseSessionKeySelectorsParameters = {},\n): UseSessionKeySelectorsReturnType {\n const config = useSymmioConfig(parameters);\n const connectedChainId = useSymmioChainId();\n const { trade, account, withdraw, coreCalls, timelockScheduling } = parameters;\n const chainId = parameters.chainId ?? connectedChainId;\n\n return useMemo(\n () => getSessionKeySelectors(config, { chainId, trade, account, withdraw, coreCalls, timelockScheduling }),\n [config, chainId, trade, account, withdraw, coreCalls, timelockScheduling],\n );\n}\n"],"mappings":";;;;;;AA8DA,SAAgB,EACd,IAA+C,CAAC,GACd;CAClC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAmB,EAAiB,GACpC,EAAE,UAAO,YAAS,aAAU,cAAW,0BAAuB,GAC9D,IAAU,EAAW,WAAW;CAEtC,OAAO,QACC,EAAuB,GAAQ;EAAE;EAAS;EAAO;EAAS;EAAU;EAAW;CAAmB,CAAC,GACzG;EAAC;EAAQ;EAAS;EAAO;EAAS;EAAU;EAAW;CAAkB,CAC3E;AACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ConfigParameter, SimulateGrantDelegationsParameters, SimulateGrantDelegationsReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for {@link useSimulateGrantDelegations}: an optional `config`
|
|
6
|
+
* override. The dry-run's inputs are passed as the mutation `variables`.
|
|
7
|
+
*/
|
|
8
|
+
export type UseSimulateGrantDelegationsParameters = ConfigParameter;
|
|
9
|
+
/** Return type of {@link useSimulateGrantDelegations}. */
|
|
10
|
+
export type UseSimulateGrantDelegationsReturnType = UseMutationResult<SimulateGrantDelegationsReturnType, SymmioRequestError, SimulateGrantDelegationsParameters>;
|
|
11
|
+
/**
|
|
12
|
+
* On-demand dry-run (`simulateContract`) of `grantDelegations`. Call
|
|
13
|
+
* `mutate(args)` to run it; `data` holds viem's `{ request, result }` (a would-be
|
|
14
|
+
* revert surfaces as a normalized {@link SymmioRequestError}). `from` defaults to
|
|
15
|
+
* the connected wallet and `chainId` to the connected chain.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* const sim = useSimulateGrantDelegations();
|
|
20
|
+
* sim.mutate({ account, delegations });
|
|
21
|
+
* // sim.data?.result, sim.isPending, sim.error
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function useSimulateGrantDelegations(parameters?: UseSimulateGrantDelegationsParameters): UseSimulateGrantDelegationsReturnType;
|
|
25
|
+
//# sourceMappingURL=use-simulate-grant-delegations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-simulate-grant-delegations.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-simulate-grant-delegations.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,kCAAkC,EACvC,KAAK,kCAAkC,EACxC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE;;;GAGG;AACH,MAAM,MAAM,qCAAqC,GAAG,eAAe,CAAC;AAEpE,0DAA0D;AAC1D,MAAM,MAAM,qCAAqC,GAAG,iBAAiB,CACnE,kCAAkC,EAClC,kBAAkB,EAClB,kCAAkC,CACnC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,GAAE,qCAA0C,GACrD,qCAAqC,CAoBvC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
|
|
3
|
+
import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
|
|
4
|
+
import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
|
|
5
|
+
import { simulateGrantDelegationsMutationOptions as r } from "@symmio/trading-core";
|
|
6
|
+
import { useConnection as i } from "wagmi";
|
|
7
|
+
import { useMutation as a } from "@tanstack/react-query";
|
|
8
|
+
//#region src/instant-layer/use-simulate-grant-delegations.ts
|
|
9
|
+
function o(o = {}) {
|
|
10
|
+
let s = t(o), c = e(), { address: l } = i(), u = r(s);
|
|
11
|
+
return a({
|
|
12
|
+
mutationKey: u.mutationKey,
|
|
13
|
+
mutationFn: async (e) => {
|
|
14
|
+
try {
|
|
15
|
+
return await u.mutationFn({
|
|
16
|
+
...e,
|
|
17
|
+
chainId: e.chainId ?? c,
|
|
18
|
+
from: e.from ?? l
|
|
19
|
+
});
|
|
20
|
+
} catch (e) {
|
|
21
|
+
throw n(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { o as useSimulateGrantDelegations };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=use-simulate-grant-delegations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-simulate-grant-delegations.js","names":[],"sources":["../../src/instant-layer/use-simulate-grant-delegations.ts"],"sourcesContent":["\"use client\";\n\nimport {\n simulateGrantDelegationsMutationOptions,\n type ConfigParameter,\n type SimulateGrantDelegationsParameters,\n type SimulateGrantDelegationsReturnType,\n} from \"@symmio/trading-core\";\nimport { useMutation, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useConnection } from \"wagmi\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/**\n * Parameters for {@link useSimulateGrantDelegations}: an optional `config`\n * override. The dry-run's inputs are passed as the mutation `variables`.\n */\nexport type UseSimulateGrantDelegationsParameters = ConfigParameter;\n\n/** Return type of {@link useSimulateGrantDelegations}. */\nexport type UseSimulateGrantDelegationsReturnType = UseMutationResult<\n SimulateGrantDelegationsReturnType,\n SymmioRequestError,\n SimulateGrantDelegationsParameters\n>;\n\n/**\n * On-demand dry-run (`simulateContract`) of `grantDelegations`. Call\n * `mutate(args)` to run it; `data` holds viem's `{ request, result }` (a would-be\n * revert surfaces as a normalized {@link SymmioRequestError}). `from` defaults to\n * the connected wallet and `chainId` to the connected chain.\n *\n * @example\n * ```tsx\n * const sim = useSimulateGrantDelegations();\n * sim.mutate({ account, delegations });\n * // sim.data?.result, sim.isPending, sim.error\n * ```\n */\nexport function useSimulateGrantDelegations(\n parameters: UseSimulateGrantDelegationsParameters = {},\n): UseSimulateGrantDelegationsReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const { address } = useConnection();\n const base = simulateGrantDelegationsMutationOptions(config);\n\n return useMutation<SimulateGrantDelegationsReturnType, SymmioRequestError, SimulateGrantDelegationsParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n return await base.mutationFn({\n ...variables,\n chainId: variables.chainId ?? chainId,\n from: variables.from ?? address,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n });\n}\n"],"mappings":";;;;;;;;AAyCA,SAAgB,EACd,IAAoD,CAAC,GACd;CACvC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,EAAE,eAAY,EAAc,GAC5B,IAAO,EAAwC,CAAM;CAE3D,OAAO,EAAwG;EAC7G,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,OAAO,MAAM,EAAK,WAAW;KAC3B,GAAG;KACH,SAAS,EAAU,WAAW;KAC9B,MAAM,EAAU,QAAQ;IAC1B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
|