@symmio/trading-react 3.0.0 → 3.1.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/use-account-balance-of.d.ts +5 -4
- package/dist/account-layer/use-account-balance-of.d.ts.map +1 -1
- package/dist/account-layer/use-account-balance-of.js.map +1 -1
- package/dist/account-layer/use-add-margin.d.ts.map +1 -1
- package/dist/account-layer/use-add-margin.js +1 -3
- package/dist/account-layer/use-add-margin.js.map +1 -1
- package/dist/account-layer/use-allocate.d.ts.map +1 -1
- package/dist/account-layer/use-allocate.js +1 -3
- package/dist/account-layer/use-allocate.js.map +1 -1
- package/dist/account-layer/use-cancel-registration.d.ts.map +1 -1
- package/dist/account-layer/use-cancel-registration.js +1 -2
- package/dist/account-layer/use-cancel-registration.js.map +1 -1
- package/dist/account-layer/use-create-sub-accounts.d.ts.map +1 -1
- package/dist/account-layer/use-create-sub-accounts.js +1 -3
- package/dist/account-layer/use-create-sub-accounts.js.map +1 -1
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts.map +1 -1
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.js +1 -6
- package/dist/account-layer/use-deallocate-and-initiate-withdraw.js.map +1 -1
- package/dist/account-layer/use-deallocate.d.ts.map +1 -1
- package/dist/account-layer/use-deallocate.js +1 -3
- package/dist/account-layer/use-deallocate.js.map +1 -1
- package/dist/account-layer/use-delete-sub-account.d.ts.map +1 -1
- package/dist/account-layer/use-delete-sub-account.js +1 -2
- package/dist/account-layer/use-delete-sub-account.js.map +1 -1
- package/dist/account-layer/use-deposit-and-allocate.d.ts.map +1 -1
- package/dist/account-layer/use-deposit-and-allocate.js +1 -3
- package/dist/account-layer/use-deposit-and-allocate.js.map +1 -1
- package/dist/account-layer/use-deposit.d.ts.map +1 -1
- package/dist/account-layer/use-deposit.js +1 -3
- package/dist/account-layer/use-deposit.js.map +1 -1
- package/dist/account-layer/use-edit-account-name.d.ts.map +1 -1
- package/dist/account-layer/use-edit-account-name.js +1 -3
- package/dist/account-layer/use-edit-account-name.js.map +1 -1
- package/dist/account-layer/use-remove-margin.d.ts.map +1 -1
- package/dist/account-layer/use-remove-margin.js +1 -3
- package/dist/account-layer/use-remove-margin.js.map +1 -1
- package/dist/account-layer/use-request-to-register-affiliate.d.ts.map +1 -1
- package/dist/account-layer/use-request-to-register-affiliate.js +1 -2
- package/dist/account-layer/use-request-to-register-affiliate.js.map +1 -1
- package/dist/collateral/use-approve-collateral.d.ts.map +1 -1
- package/dist/collateral/use-approve-collateral.js +1 -2
- package/dist/collateral/use-approve-collateral.js.map +1 -1
- package/dist/errors/normalize-symm-error.d.ts.map +1 -1
- package/dist/errors/normalize-symm-error.js +1 -0
- package/dist/errors/normalize-symm-error.js.map +1 -1
- package/dist/errors/symmio-request-error.d.ts +19 -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/gasless-relay-types.d.ts +115 -0
- package/dist/gasless/gasless-relay-types.d.ts.map +1 -0
- package/dist/gasless/gasless-relay-types.js +9 -0
- package/dist/gasless/gasless-relay-types.js.map +1 -0
- package/dist/gasless/index.d.ts +21 -0
- package/dist/gasless/index.d.ts.map +1 -0
- package/dist/gasless/index.js +21 -0
- package/dist/gasless/invalidate-relay-reads.d.ts +96 -0
- package/dist/gasless/invalidate-relay-reads.d.ts.map +1 -0
- package/dist/gasless/invalidate-relay-reads.js +107 -0
- package/dist/gasless/invalidate-relay-reads.js.map +1 -0
- package/dist/gasless/use-approve-operational-fee.d.ts +38 -0
- package/dist/gasless/use-approve-operational-fee.d.ts.map +1 -0
- package/dist/gasless/use-approve-operational-fee.js +37 -0
- package/dist/gasless/use-approve-operational-fee.js.map +1 -0
- package/dist/gasless/use-debounced-batch.d.ts +22 -0
- package/dist/gasless/use-debounced-batch.d.ts.map +1 -0
- package/dist/gasless/use-debounced-batch.js +27 -0
- package/dist/gasless/use-debounced-batch.js.map +1 -0
- package/dist/gasless/use-gasless-batch-fee-quote.d.ts +48 -0
- package/dist/gasless/use-gasless-batch-fee-quote.d.ts.map +1 -0
- package/dist/gasless/use-gasless-batch-fee-quote.js +33 -0
- package/dist/gasless/use-gasless-batch-fee-quote.js.map +1 -0
- package/dist/gasless/use-gasless-deposit-policy.d.ts +28 -0
- package/dist/gasless/use-gasless-deposit-policy.d.ts.map +1 -0
- package/dist/gasless/use-gasless-deposit-policy.js +27 -0
- package/dist/gasless/use-gasless-deposit-policy.js.map +1 -0
- package/dist/gasless/use-gasless-fee-quote.d.ts +25 -0
- package/dist/gasless/use-gasless-fee-quote.d.ts.map +1 -0
- package/dist/gasless/use-gasless-fee-quote.js +27 -0
- package/dist/gasless/use-gasless-fee-quote.js.map +1 -0
- package/dist/gasless/use-gasless-relay-confirmation.d.ts +72 -0
- package/dist/gasless/use-gasless-relay-confirmation.d.ts.map +1 -0
- package/dist/gasless/use-gasless-relay-confirmation.js +148 -0
- package/dist/gasless/use-gasless-relay-confirmation.js.map +1 -0
- package/dist/gasless/use-gasless-request-stream.d.ts +34 -0
- package/dist/gasless/use-gasless-request-stream.d.ts.map +1 -0
- package/dist/gasless/use-gasless-request-stream.js +86 -0
- package/dist/gasless/use-gasless-request-stream.js.map +1 -0
- package/dist/gasless/use-gasless-request-transactions.d.ts +42 -0
- package/dist/gasless/use-gasless-request-transactions.d.ts.map +1 -0
- package/dist/gasless/use-gasless-request-transactions.js +28 -0
- package/dist/gasless/use-gasless-request-transactions.js.map +1 -0
- package/dist/gasless/use-gasless-request.d.ts +56 -0
- package/dist/gasless/use-gasless-request.d.ts.map +1 -0
- package/dist/gasless/use-gasless-request.js +51 -0
- package/dist/gasless/use-gasless-request.js.map +1 -0
- package/dist/gasless/use-gasless-wallet-address.d.ts +24 -0
- package/dist/gasless/use-gasless-wallet-address.d.ts.map +1 -0
- package/dist/gasless/use-gasless-wallet-address.js +27 -0
- package/dist/gasless/use-gasless-wallet-address.js.map +1 -0
- package/dist/gasless/use-gasless-wallet-creation-fee.d.ts +29 -0
- package/dist/gasless/use-gasless-wallet-creation-fee.d.ts.map +1 -0
- package/dist/gasless/use-gasless-wallet-creation-fee.js +27 -0
- package/dist/gasless/use-gasless-wallet-creation-fee.js.map +1 -0
- package/dist/gasless/use-gasless-wallet-execute-selectors.d.ts +44 -0
- package/dist/gasless/use-gasless-wallet-execute-selectors.d.ts.map +1 -0
- package/dist/gasless/use-gasless-wallet-execute-selectors.js +19 -0
- package/dist/gasless/use-gasless-wallet-execute-selectors.js.map +1 -0
- package/dist/gasless/use-gasless-wallet-execute.d.ts +51 -0
- package/dist/gasless/use-gasless-wallet-execute.d.ts.map +1 -0
- package/dist/gasless/use-gasless-wallet-execute.js +44 -0
- package/dist/gasless/use-gasless-wallet-execute.js.map +1 -0
- package/dist/gasless/use-gasless-wallet-nonce.d.ts +27 -0
- package/dist/gasless/use-gasless-wallet-nonce.d.ts.map +1 -0
- package/dist/gasless/use-gasless-wallet-nonce.js +27 -0
- package/dist/gasless/use-gasless-wallet-nonce.js.map +1 -0
- package/dist/gasless/use-operational-fee-allowance.d.ts +23 -0
- package/dist/gasless/use-operational-fee-allowance.d.ts.map +1 -0
- package/dist/gasless/use-operational-fee-allowance.js +27 -0
- package/dist/gasless/use-operational-fee-allowance.js.map +1 -0
- package/dist/gasless/use-relay-gasless-batch.d.ts +48 -0
- package/dist/gasless/use-relay-gasless-batch.d.ts.map +1 -0
- package/dist/gasless/use-relay-gasless-batch.js +44 -0
- package/dist/gasless/use-relay-gasless-batch.js.map +1 -0
- package/dist/gasless/use-relay-instant-operations.d.ts +43 -0
- package/dist/gasless/use-relay-instant-operations.d.ts.map +1 -0
- package/dist/gasless/use-relay-instant-operations.js +44 -0
- package/dist/gasless/use-relay-instant-operations.js.map +1 -0
- package/dist/gasless/use-resubmit-gasless-request.d.ts +39 -0
- package/dist/gasless/use-resubmit-gasless-request.d.ts.map +1 -0
- package/dist/gasless/use-resubmit-gasless-request.js +56 -0
- package/dist/gasless/use-resubmit-gasless-request.js.map +1 -0
- package/dist/gasless/use-settle-gasless-deposit-existing-account.d.ts +41 -0
- package/dist/gasless/use-settle-gasless-deposit-existing-account.d.ts.map +1 -0
- package/dist/gasless/use-settle-gasless-deposit-existing-account.js +47 -0
- package/dist/gasless/use-settle-gasless-deposit-existing-account.js.map +1 -0
- package/dist/gasless/use-settle-gasless-deposit-new-account.d.ts +48 -0
- package/dist/gasless/use-settle-gasless-deposit-new-account.d.ts.map +1 -0
- package/dist/gasless/use-settle-gasless-deposit-new-account.js +48 -0
- package/dist/gasless/use-settle-gasless-deposit-new-account.js.map +1 -0
- package/dist/gasless/use-supports-gasless-service.d.ts +22 -0
- package/dist/gasless/use-supports-gasless-service.d.ts.map +1 -0
- package/dist/gasless/use-supports-gasless-service.js +13 -0
- package/dist/gasless/use-supports-gasless-service.js.map +1 -0
- package/dist/index.d.ts +29 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +251 -221
- package/dist/instant-layer/index.d.ts +7 -0
- package/dist/instant-layer/index.d.ts.map +1 -1
- package/dist/instant-layer/index.js +26 -19
- package/dist/instant-layer/use-active-delegations.d.ts +31 -0
- package/dist/instant-layer/use-active-delegations.d.ts.map +1 -0
- package/dist/instant-layer/use-active-delegations.js +23 -0
- package/dist/instant-layer/use-active-delegations.js.map +1 -0
- package/dist/instant-layer/use-are-delegations-active.d.ts +100 -0
- package/dist/instant-layer/use-are-delegations-active.d.ts.map +1 -0
- package/dist/instant-layer/use-are-delegations-active.js +60 -0
- package/dist/instant-layer/use-are-delegations-active.js.map +1 -0
- package/dist/instant-layer/use-finalize-revoke-delegation.d.ts +32 -0
- package/dist/instant-layer/use-finalize-revoke-delegation.d.ts.map +1 -0
- package/dist/instant-layer/use-finalize-revoke-delegation.js +45 -0
- package/dist/instant-layer/use-finalize-revoke-delegation.js.map +1 -0
- package/dist/instant-layer/use-grant-delegation.d.ts +12 -2
- package/dist/instant-layer/use-grant-delegation.d.ts.map +1 -1
- package/dist/instant-layer/use-grant-delegation.js +27 -20
- package/dist/instant-layer/use-grant-delegation.js.map +1 -1
- package/dist/instant-layer/use-initiate-revoke-delegation.d.ts +32 -0
- package/dist/instant-layer/use-initiate-revoke-delegation.d.ts.map +1 -0
- package/dist/instant-layer/use-initiate-revoke-delegation.js +45 -0
- package/dist/instant-layer/use-initiate-revoke-delegation.js.map +1 -0
- package/dist/instant-layer/use-pending-revocation.d.ts +119 -0
- package/dist/instant-layer/use-pending-revocation.d.ts.map +1 -0
- package/dist/instant-layer/use-pending-revocation.js +73 -0
- package/dist/instant-layer/use-pending-revocation.js.map +1 -0
- package/dist/instant-layer/use-revocation-cooldown.d.ts +24 -0
- package/dist/instant-layer/use-revocation-cooldown.d.ts.map +1 -0
- package/dist/instant-layer/use-revocation-cooldown.js +23 -0
- package/dist/instant-layer/use-revocation-cooldown.js.map +1 -0
- package/dist/instant-layer/use-session-key-selectors.d.ts +53 -0
- package/dist/instant-layer/use-session-key-selectors.d.ts.map +1 -0
- package/dist/instant-layer/use-session-key-selectors.js +25 -0
- package/dist/instant-layer/use-session-key-selectors.js.map +1 -0
- package/dist/margin/use-available-instant-open-margin.js +8 -8
- package/dist/markets/index.d.ts +1 -0
- package/dist/markets/index.d.ts.map +1 -1
- package/dist/markets/index.js +3 -2
- package/dist/markets/use-funding-fees-of-party-b.d.ts +47 -0
- package/dist/markets/use-funding-fees-of-party-b.d.ts.map +1 -0
- package/dist/markets/use-funding-fees-of-party-b.js +27 -0
- package/dist/markets/use-funding-fees-of-party-b.js.map +1 -0
- package/dist/provider/create-session-key-wallet-client-resolver.d.ts +68 -0
- package/dist/provider/create-session-key-wallet-client-resolver.d.ts.map +1 -0
- package/dist/provider/create-session-key-wallet-client-resolver.js +51 -0
- package/dist/provider/create-session-key-wallet-client-resolver.js.map +1 -0
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +5 -4
- package/dist/provider/symmio-provider.d.ts +7 -2
- package/dist/provider/symmio-provider.d.ts.map +1 -1
- package/dist/provider/symmio-provider.js +10 -7
- package/dist/provider/symmio-provider.js.map +1 -1
- package/dist/quotes/index.d.ts +2 -0
- package/dist/quotes/index.d.ts.map +1 -1
- package/dist/quotes/use-account-upnl.js +9 -9
- package/dist/quotes/use-close-quote-group.js +13 -13
- package/dist/quotes/use-force-cancel-close-request.d.ts.map +1 -1
- package/dist/quotes/use-force-cancel-close-request.js +1 -4
- package/dist/quotes/use-force-cancel-close-request.js.map +1 -1
- package/dist/quotes/use-force-cancel-quote.d.ts.map +1 -1
- package/dist/quotes/use-force-cancel-quote.js +1 -4
- package/dist/quotes/use-force-cancel-quote.js.map +1 -1
- package/dist/quotes/use-force-close.d.ts +2 -1
- package/dist/quotes/use-force-close.d.ts.map +1 -1
- package/dist/quotes/use-force-close.js +14 -12
- package/dist/quotes/use-force-close.js.map +1 -1
- package/dist/quotes/use-limit-orders.js +9 -9
- package/dist/quotes/use-managed-quotes.d.ts.map +1 -1
- package/dist/quotes/use-managed-quotes.js +103 -103
- package/dist/quotes/use-managed-quotes.js.map +1 -1
- package/dist/quotes/use-party-a-open-positions.js +5 -5
- package/dist/quotes/use-quote-group-funding-history.d.ts +10 -7
- package/dist/quotes/use-quote-group-funding-history.d.ts.map +1 -1
- package/dist/quotes/use-quote-group-funding-history.js.map +1 -1
- package/dist/quotes/use-quote-group-funding.d.ts +4 -2
- package/dist/quotes/use-quote-group-funding.d.ts.map +1 -1
- package/dist/quotes/use-quote-group-funding.js.map +1 -1
- package/dist/quotes/use-quote-pending-funding.d.ts +62 -0
- package/dist/quotes/use-quote-pending-funding.d.ts.map +1 -0
- package/dist/quotes/use-quote-pending-funding.js +31 -0
- package/dist/quotes/use-quote-pending-funding.js.map +1 -0
- package/dist/quotes/use-quotes-funding.d.ts +4 -2
- package/dist/quotes/use-quotes-funding.d.ts.map +1 -1
- package/dist/quotes/use-quotes-funding.js.map +1 -1
- package/dist/quotes/use-quotes-pending-funding.d.ts +92 -0
- package/dist/quotes/use-quotes-pending-funding.d.ts.map +1 -0
- package/dist/quotes/use-quotes-pending-funding.js +94 -0
- package/dist/quotes/use-quotes-pending-funding.js.map +1 -0
- package/dist/quotes/use-request-to-cancel-close-request.d.ts.map +1 -1
- package/dist/quotes/use-request-to-cancel-close-request.js +1 -4
- package/dist/quotes/use-request-to-cancel-close-request.js.map +1 -1
- package/dist/quotes/use-request-to-cancel-quote.d.ts.map +1 -1
- package/dist/quotes/use-request-to-cancel-quote.js +1 -4
- package/dist/quotes/use-request-to-cancel-quote.js.map +1 -1
- package/dist/transactions/index.js +3 -3
- package/dist/transactions/resolve-write-result.d.ts +53 -2
- package/dist/transactions/resolve-write-result.d.ts.map +1 -1
- package/dist/transactions/resolve-write-result.js +52 -9
- package/dist/transactions/resolve-write-result.js.map +1 -1
- package/dist/transactions/write-types.d.ts +19 -1
- package/dist/transactions/write-types.d.ts.map +1 -1
- package/dist/utils/predicate-match.d.ts +7 -4
- package/dist/utils/predicate-match.d.ts.map +1 -1
- package/dist/utils/predicate-match.js +5 -5
- package/dist/utils/predicate-match.js.map +1 -1
- package/dist/withdraw/use-finalize-withdraw-request.d.ts.map +1 -1
- package/dist/withdraw/use-finalize-withdraw-request.js +1 -3
- package/dist/withdraw/use-finalize-withdraw-request.js.map +1 -1
- package/dist/withdraw/use-initiate-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-initiate-withdraw.js +1 -5
- package/dist/withdraw/use-initiate-withdraw.js.map +1 -1
- package/dist/withdraw/use-request-cancel-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-request-cancel-withdraw.js +1 -3
- package/dist/withdraw/use-request-cancel-withdraw.js.map +1 -1
- package/dist/withdraw/use-withdraw.d.ts.map +1 -1
- package/dist/withdraw/use-withdraw.js +2 -1
- package/dist/withdraw/use-withdraw.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidate-relay-reads.js","names":[],"sources":["../../src/gasless/invalidate-relay-reads.ts"],"sourcesContent":["import {\n accountLayerAbi,\n getCollateralAllowanceQueryKey,\n getCollateralBalanceQueryKey,\n getDelegationExpiryQueryKey,\n getGaslessBatchSelectors,\n getGaslessDepositPolicyQueryKey,\n getGaslessWalletCreationFeeQueryKey,\n getGaslessWalletNonceQueryKey,\n getInstantLayerNonceQueryKey,\n getIsDelegationActiveQueryKey,\n getLastWithdrawRequestIdQueryKey,\n getOperationalFeeAllowanceQueryKey,\n getPartyAOpenPositionsQueryKey,\n getPartyAPendingQuotesQueryKey,\n getPendingQuotesQueryKey,\n getPendingWithdrawRequestsQueryKey,\n getQuotePendingFundingQueryKey,\n getQuoteQueryKey,\n getSubAccountQueryKey,\n getSubAccountsCountOfUserQueryKey,\n getUserSubAccountsAddressesQueryKey,\n getUserSubAccountsQueryKey,\n getWithdrawRequestsQueryKey,\n getWithdrawableTimeQueryKey,\n instantLayerAbi,\n symmioAbi,\n type GaslessBatchCall,\n} from \"@symmio/trading-core\";\nimport type { QueryClient } from \"@tanstack/react-query\";\nimport { isAddress, toFunctionSelector, type Abi, type AbiFunction, type Address, type Hex } from \"viem\";\nimport { invalidateAccountBalances } from \"../utils/invalidate-account-balances\";\nimport { predicateMatch } from \"../utils/predicate-match\";\n\n/** Chain-config fingerprint every invalidation is scoped by. */\ninterface Scope {\n configKey?: string;\n}\n\n/**\n * The GaslessWallet a relayed action touched, as far as its variables say.\n * Every omitted field matches all of its values — a superset is correct, a\n * silent no-op is not.\n */\ninterface GaslessWalletScope {\n /** The wallet's owner. */\n owner?: Address;\n /**\n * The wallet's id. `useGaslessWalletExecute` forwards its variables whole, so\n * its `walletId` narrows the invalidation on its own; the settlement hooks\n * take theirs from the acceptance receipt, which is the id the service\n * actually settled. Omitted, every id of the owner matches.\n */\n walletId?: bigint;\n}\n\n/**\n * Invalidate what every relayed action changes, whatever the action was.\n *\n * Two facts hold for all of them, because they are properties of the transport\n * rather than of the operation: the GaslessLayer deducts the operational fee\n * from SYMMIO collateral, and it deducts it from an allowance. So balances and\n * the payer's allowance are always stale afterwards.\n *\n * @param queryClient - The active TanStack query client.\n * @param scope - The chain-config fingerprint.\n * @param payer - The sub-account charged, when known; omitted invalidates every payer on the chain.\n *\n * @internal\n */\nfunction invalidateRelayTransportReads(queryClient: QueryClient, scope: Scope, payer?: Address): void {\n invalidateAccountBalances(queryClient, scope);\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getOperationalFeeAllowanceQueryKey, { ...scope, payer }),\n });\n}\n\n/**\n * Invalidate the reads that change when a GaslessWallet is deployed.\n *\n * A wallet deploys lazily, on the first settlement or wallet operation that\n * uses it, and from then on its creation fee reads `0n` — which also lowers the\n * deposit policy's `settlementMinimum`. Whether this action was the one that\n * deployed it is unknowable from its variables, so both reads are invalidated\n * after every such action.\n *\n * @internal\n */\nfunction invalidateGaslessWalletDeploymentReads(\n queryClient: QueryClient,\n scope: Scope,\n wallet: GaslessWalletScope,\n): void {\n const match = { ...scope, owner: wallet.owner, walletId: wallet.walletId };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getGaslessDepositPolicyQueryKey, match) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getGaslessWalletCreationFeeQueryKey, match) });\n}\n\n/**\n * Invalidate the reads a relayed InstantLayer batch changed.\n *\n * Only transport-level facts: `operationType` is a free-form label the fee\n * policy ignores, so the SDK cannot know which domain reads a batch touched and\n * must not guess. Callers who know the operation pass their own `onSuccess` to\n * `mutate`, which now runs after confirmation.\n *\n * @internal\n */\nexport function invalidateRelayInstantOperationsReads(\n queryClient: QueryClient,\n scope: Scope,\n signerAccounts: readonly Address[],\n): void {\n const accounts = [...new Set(signerAccounts)];\n for (const account of accounts) {\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getInstantLayerNonceQueryKey, { ...scope, account }),\n });\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getOperationalFeeAllowanceQueryKey, { ...scope, payer: account }),\n });\n }\n invalidateAccountBalances(queryClient, scope);\n}\n\n/**\n * Invalidate the reads a relayed gasless-wallet `execute` changed.\n *\n * The wallet-operation nonce is keyed by `(owner, walletId, signerAccount)`,\n * and the operation consumed it under its signer account — which defaults to\n * the owner. The wallet's own collateral balance moves, and its address is\n * derived rather than passed, so the collateral read is invalidated chain-wide.\n * The operation may also have deployed the wallet, which zeroes its creation fee.\n *\n * @param wallet - The action's variables, forwarded whole: `owner`, `signerAccount` and `walletId`\n * scope the invalidation, and each omitted one matches every value.\n *\n * @internal\n */\nexport function invalidateGaslessWalletExecuteReads(\n queryClient: QueryClient,\n scope: Scope,\n wallet: GaslessWalletScope & { signerAccount?: Address },\n): void {\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getGaslessWalletNonceQueryKey, {\n ...scope,\n owner: wallet.owner,\n walletId: wallet.walletId,\n account: wallet.signerAccount ?? wallet.owner,\n }),\n });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getCollateralBalanceQueryKey, scope) });\n invalidateGaslessWalletDeploymentReads(queryClient, scope, wallet);\n invalidateRelayTransportReads(queryClient, scope);\n}\n\n/** The selector of the first function named `name` in `abi` — the same derivation the SDK's relayable-writes map uses. */\nfunction selectorOf(abi: Abi, name: string): Hex {\n const item = abi.find((entry): entry is AbiFunction => entry.type === \"function\" && entry.name === name);\n if (!item) throw new Error(`invalidate-relay-reads: the shipped ABI has no function \"${name}\".`);\n return toFunctionSelector(item);\n}\n\n/** Relayable writes that move a withdrawal request along. */\nconst WITHDRAW_WRITES: ReadonlySet<Hex> = new Set([\n selectorOf(symmioAbi as Abi, \"initiateWithdraw\"),\n selectorOf(symmioAbi as Abi, \"requestCancelWithdraw\"),\n selectorOf(symmioAbi as Abi, \"finalizeWithdrawRequest\"),\n]);\n\n/** Relayable writes that change a quote or an open position. */\nconst QUOTE_WRITES: ReadonlySet<Hex> = new Set([\n selectorOf(symmioAbi as Abi, \"requestToCancelQuote\"),\n selectorOf(symmioAbi as Abi, \"requestToCancelCloseRequest\"),\n selectorOf(symmioAbi as Abi, \"forceCancelQuote\"),\n selectorOf(symmioAbi as Abi, \"forceCancelCloseRequest\"),\n selectorOf(symmioAbi as Abi, \"forceClosePosition\"),\n]);\n\n/** Relayable writes that change an owner's sub-account list or a sub-account's details. */\nconst SUB_ACCOUNT_WRITES: ReadonlySet<Hex> = new Set([\n selectorOf(accountLayerAbi as Abi, \"createSubAccounts\"),\n selectorOf(accountLayerAbi as Abi, \"deleteSubAccount\"),\n selectorOf(accountLayerAbi as Abi, \"editAccountName\"),\n]);\n\n/** Relayable writes that pull collateral from the signer's own token balance. */\nconst DEPOSIT_WRITES: ReadonlySet<Hex> = new Set([\n selectorOf(accountLayerAbi as Abi, \"depositForAccount\"),\n selectorOf(accountLayerAbi as Abi, \"depositAndAllocateForAccount\"),\n]);\n\n/** The one relayable write that grants a delegation. */\nconst GRANT_DELEGATION = selectorOf(instantLayerAbi as Abi, \"grantDelegation\");\n\n/**\n * Invalidate the reads a relayed gasless batch changed.\n *\n * Unlike an opaque `relayInstantOperations` batch, every call of a gasless\n * batch is a known relayable write (the SDK refuses anything else), so its\n * selectors say exactly which domains moved. Each domain's reads are\n * invalidated chain-wide — the calls' own arguments name the rows, but a\n * superset is correct and a silent no-op is not.\n *\n * Always: the account's InstantLayer nonce, fee allowances and balances. Per\n * GaslessWallet entry: that wallet's nonce, collateral and deployment reads.\n *\n * @param batch - The batch's variables: its `account` and `calls`.\n *\n * @internal\n */\nexport function invalidateGaslessBatchReads(\n queryClient: QueryClient,\n scope: Scope,\n batch: { account: Address; calls: readonly GaslessBatchCall[] },\n): void {\n const selectors = new Set(getGaslessBatchSelectors(batch.calls));\n const touches = (writes: ReadonlySet<Hex>) => [...writes].some((selector) => selectors.has(selector));\n\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getInstantLayerNonceQueryKey, { ...scope, account: batch.account }),\n });\n invalidateRelayTransportReads(queryClient, scope);\n\n for (const call of batch.calls) {\n if (\"walletCalls\" in call) {\n invalidateGaslessWalletExecuteReads(queryClient, scope, {\n walletId: call.walletId ?? 0n,\n signerAccount: batch.account,\n });\n }\n }\n\n if (touches(WITHDRAW_WRITES)) {\n for (const queryKey of [\n getPendingWithdrawRequestsQueryKey,\n getLastWithdrawRequestIdQueryKey,\n getWithdrawableTimeQueryKey,\n getWithdrawRequestsQueryKey,\n ]) {\n void queryClient.invalidateQueries({ predicate: predicateMatch(queryKey, scope) });\n }\n }\n if (touches(QUOTE_WRITES)) {\n for (const queryKey of [\n getPartyAPendingQuotesQueryKey,\n getPendingQuotesQueryKey,\n getQuoteQueryKey,\n getPartyAOpenPositionsQueryKey,\n getQuotePendingFundingQueryKey,\n ]) {\n void queryClient.invalidateQueries({ predicate: predicateMatch(queryKey, scope) });\n }\n }\n if (touches(SUB_ACCOUNT_WRITES)) {\n for (const queryKey of [\n getUserSubAccountsQueryKey,\n getUserSubAccountsAddressesQueryKey,\n getSubAccountsCountOfUserQueryKey,\n getSubAccountQueryKey,\n ]) {\n void queryClient.invalidateQueries({ predicate: predicateMatch(queryKey, scope) });\n }\n }\n if (touches(DEPOSIT_WRITES)) {\n void queryClient.invalidateQueries({ predicate: predicateMatch(getCollateralBalanceQueryKey, scope) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getCollateralAllowanceQueryKey, scope) });\n }\n if (selectors.has(GRANT_DELEGATION)) {\n /** Scoped by config only: one grant covers every selector it lists, for every delegate. */\n void queryClient.invalidateQueries({ predicate: predicateMatch(getIsDelegationActiveQueryKey, scope) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getDelegationExpiryQueryKey, scope) });\n }\n}\n\n/**\n * Invalidate the reads a deposit settlement changed.\n *\n * The deposit address is swept to zero, so its collateral balance is\n * invalidated precisely when the acceptance receipt carries it. The settlement\n * deploys the wallet on its first use, which zeroes the wallet's creation fee\n * and lowers its deposit policy's `settlementMinimum`, so both are invalidated\n * for the owner's wallet.\n *\n * `depositAddress` arrives as the vendor's raw string, so a value that is not a\n * well-formed address widens to a chain-wide collateral invalidation rather\n * than scoping to nothing — a superset is correct, a silent no-op is not.\n *\n * @param options.owner - The settled wallet's owner.\n * @param options.newAccount - `true` for a new-account settlement, which also\n * refreshes the owner's sub-account lists; omit for a top-up into an existing account.\n *\n * @internal\n */\nexport function invalidateDepositSettlementReads(\n queryClient: QueryClient,\n scope: Scope,\n options: GaslessWalletScope & { depositAddress?: string; newAccount?: boolean },\n): void {\n const depositAddress =\n options.depositAddress && isAddress(options.depositAddress) ? options.depositAddress : undefined;\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getCollateralBalanceQueryKey, { ...scope, owner: depositAddress }),\n });\n if (options.newAccount && options.owner) {\n const user = { ...scope, user: options.owner };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getUserSubAccountsQueryKey, user) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getUserSubAccountsAddressesQueryKey, user) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getSubAccountsCountOfUserQueryKey, user) });\n }\n invalidateGaslessWalletDeploymentReads(queryClient, scope, options);\n invalidateAccountBalances(queryClient, scope);\n}\n"],"mappings":";;;;;AAsEA,SAAS,EAA8B,GAA0B,GAAc,GAAuB;CAEpG,AADA,EAA0B,GAAa,CAAK,GAC5C,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAAoC;EAAE,GAAG;EAAO;CAAM,CAAC,EACnF,CAAC;AACH;AAaA,SAAS,EACP,GACA,GACA,GACM;CACN,IAAM,IAAQ;EAAE,GAAG;EAAO,OAAO,EAAO;EAAO,UAAU,EAAO;CAAS;CAEzE,AADA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAiC,CAAK,EAAE,CAAC,GACxG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAqC,CAAK,EAAE,CAAC;AAC9G;AAYA,SAAgB,EACd,GACA,GACA,GACM;CACN,IAAM,IAAW,CAAC,GAAG,IAAI,IAAI,CAAc,CAAC;CAC5C,KAAK,IAAM,KAAW,GAIpB,AAHA,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAA8B;EAAE,GAAG;EAAO;CAAQ,CAAC,EAC/E,CAAC,GACD,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAAoC;EAAE,GAAG;EAAO,OAAO;CAAQ,CAAC,EAC5F,CAAC;CAEH,EAA0B,GAAa,CAAK;AAC9C;AAgBA,SAAgB,EACd,GACA,GACA,GACM;CAWN,AAVA,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAA+B;EACvD,GAAG;EACH,OAAO,EAAO;EACd,UAAU,EAAO;EACjB,SAAS,EAAO,iBAAiB,EAAO;CAC1C,CAAC,EACH,CAAC,GACD,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA8B,CAAK,EAAE,CAAC,GACrG,EAAuC,GAAa,GAAO,CAAM,GACjE,EAA8B,GAAa,CAAK;AAClD;AAGA,SAAS,EAAW,GAAU,GAAmB;CAC/C,IAAM,IAAO,EAAI,MAAM,MAAgC,EAAM,SAAS,cAAc,EAAM,SAAS,CAAI;CACvG,IAAI,CAAC,GAAM,MAAU,MAAM,4DAA4D,EAAK,GAAG;CAC/F,OAAO,EAAmB,CAAI;AAChC;AAGA,IAAM,IAAoC,IAAI,IAAI;CAChD,EAAW,GAAkB,kBAAkB;CAC/C,EAAW,GAAkB,uBAAuB;CACpD,EAAW,GAAkB,yBAAyB;AACxD,CAAC,GAGK,IAAiC,IAAI,IAAI;CAC7C,EAAW,GAAkB,sBAAsB;CACnD,EAAW,GAAkB,6BAA6B;CAC1D,EAAW,GAAkB,kBAAkB;CAC/C,EAAW,GAAkB,yBAAyB;CACtD,EAAW,GAAkB,oBAAoB;AACnD,CAAC,GAGK,IAAuC,IAAI,IAAI;CACnD,EAAW,GAAwB,mBAAmB;CACtD,EAAW,GAAwB,kBAAkB;CACrD,EAAW,GAAwB,iBAAiB;AACtD,CAAC,GAGK,IAAmC,IAAI,IAAI,CAC/C,EAAW,GAAwB,mBAAmB,GACtD,EAAW,GAAwB,8BAA8B,CACnE,CAAC,GAGK,IAAmB,EAAW,GAAwB,iBAAiB;AAkB7E,SAAgB,EACd,GACA,GACA,GACM;CACN,IAAM,IAAY,IAAI,IAAI,EAAyB,EAAM,KAAK,CAAC,GACzD,KAAW,MAA6B,CAAC,GAAG,CAAM,EAAE,MAAM,MAAa,EAAU,IAAI,CAAQ,CAAC;CAKpG,AAHA,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAA8B;EAAE,GAAG;EAAO,SAAS,EAAM;CAAQ,CAAC,EAC9F,CAAC,GACD,EAA8B,GAAa,CAAK;CAEhD,KAAK,IAAM,KAAQ,EAAM,OACvB,AAAI,iBAAiB,KACnB,EAAoC,GAAa,GAAO;EACtD,UAAU,EAAK,YAAY;EAC3B,eAAe,EAAM;CACvB,CAAC;CAIL,IAAI,EAAQ,CAAe,GACzB,KAAK,IAAM,KAAY;EACrB;EACA;EACA;EACA;CACF,GACE,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAU,CAAK,EAAE,CAAC;CAGrF,IAAI,EAAQ,CAAY,GACtB,KAAK,IAAM,KAAY;EACrB;EACA;EACA;EACA;EACA;CACF,GACE,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAU,CAAK,EAAE,CAAC;CAGrF,IAAI,EAAQ,CAAkB,GAC5B,KAAK,IAAM,KAAY;EACrB;EACA;EACA;EACA;CACF,GACE,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAU,CAAK,EAAE,CAAC;CAOrF,AAJI,EAAQ,CAAc,MACxB,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA8B,CAAK,EAAE,CAAC,GACrG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAgC,CAAK,EAAE,CAAC,IAErG,EAAU,IAAI,CAAgB,MAEhC,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA+B,CAAK,EAAE,CAAC,GACtG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAK,EAAE,CAAC;AAExG;AAqBA,SAAgB,EACd,GACA,GACA,GACM;CACN,IAAM,IACJ,EAAQ,kBAAkB,EAAU,EAAQ,cAAc,IAAI,EAAQ,iBAAiB,KAAA;CAIzF,IAHA,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAA8B;EAAE,GAAG;EAAO,OAAO;CAAe,CAAC,EAC7F,CAAC,GACG,EAAQ,cAAc,EAAQ,OAAO;EACvC,IAAM,IAAO;GAAE,GAAG;GAAO,MAAM,EAAQ;EAAM;EAG7C,AAFA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA4B,CAAI,EAAE,CAAC,GAClG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAqC,CAAI,EAAE,CAAC,GAC3G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAmC,CAAI,EAAE,CAAC;CAC3G;CAEA,AADA,EAAuC,GAAa,GAAO,CAAO,GAClE,EAA0B,GAAa,CAAK;AAC9C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ApproveOperationalFeeParameters } 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/write-types.js';
|
|
5
|
+
/** Parameters for {@link useApproveOperationalFee}. */
|
|
6
|
+
export type UseApproveOperationalFeeParameters = WriteParameters;
|
|
7
|
+
/** Mutation variables of {@link useApproveOperationalFee}: the core action's parameters. */
|
|
8
|
+
export type ApproveOperationalFeeVariables = ApproveOperationalFeeParameters;
|
|
9
|
+
/** Result of {@link useApproveOperationalFee}. */
|
|
10
|
+
export type ApproveOperationalFeeResult = WriteResult;
|
|
11
|
+
/** Return type of {@link useApproveOperationalFee}. */
|
|
12
|
+
export type UseApproveOperationalFeeReturnType = UseMutationResult<ApproveOperationalFeeResult, SymmioRequestError, ApproveOperationalFeeVariables>;
|
|
13
|
+
/**
|
|
14
|
+
* Approve operational-fee allowances for the gasless fee charger, as the
|
|
15
|
+
* paying sub-account (via the AccountLayer `_call` proxy).
|
|
16
|
+
*
|
|
17
|
+
* Grant the allowance **before** relying on gasless execution. This is a
|
|
18
|
+
* normal on-chain write — pass `gasless: true` in the variables to relay the
|
|
19
|
+
* approval itself once gasless execution is active. On success the allowance
|
|
20
|
+
* read is invalidated after the receipt, so `useOperationalFeeAllowance` reads
|
|
21
|
+
* the new value back.
|
|
22
|
+
*
|
|
23
|
+
* `amounts` are **18-decimal Core units**, not the collateral token's decimals,
|
|
24
|
+
* and each one replaces the current allowance. Approve a bounded budget rather
|
|
25
|
+
* than `maxUint256`. Approving does not add balance: the fee is still drawn
|
|
26
|
+
* from the payer's Core balance.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* import { parseUnits } from "viem";
|
|
31
|
+
*
|
|
32
|
+
* const approve = useApproveOperationalFee();
|
|
33
|
+
* // A bounded fee budget of 5 collateral tokens, in 18-decimal Core units.
|
|
34
|
+
* approve.mutate({ account: subAccount, amounts: [parseUnits("5", 18)] });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function useApproveOperationalFee(parameters?: UseApproveOperationalFeeParameters): UseApproveOperationalFeeReturnType;
|
|
38
|
+
//# sourceMappingURL=use-approve-operational-fee.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-approve-operational-fee.d.ts","sourceRoot":"","sources":["../../src/gasless/use-approve-operational-fee.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,+BAA+B,EACrC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAGhF,uDAAuD;AACvD,MAAM,MAAM,kCAAkC,GAAG,eAAe,CAAC;AAEjE,4FAA4F;AAC5F,MAAM,MAAM,8BAA8B,GAAG,+BAA+B,CAAC;AAE7E,kDAAkD;AAClD,MAAM,MAAM,2BAA2B,GAAG,WAAW,CAAC;AAEtD,uDAAuD;AACvD,MAAM,MAAM,kCAAkC,GAAG,iBAAiB,CAChE,2BAA2B,EAC3B,kBAAkB,EAClB,8BAA8B,CAC/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,GAAE,kCAAuC,GAClD,kCAAkC,CA4BpC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { resolveWriteResult as r } from "../transactions/resolve-write-result.js";
|
|
6
|
+
import { predicateMatch as i } from "../utils/predicate-match.js";
|
|
7
|
+
import { approveOperationalFeeMutationOptions as a, getOperationalFeeAllowanceQueryKey as o } from "@symmio/trading-core";
|
|
8
|
+
import { useMutation as s, useQueryClient as c } from "@tanstack/react-query";
|
|
9
|
+
//#region src/gasless/use-approve-operational-fee.ts
|
|
10
|
+
function l(l = {}) {
|
|
11
|
+
let u = t(l), d = e(), f = c(), p = a(u);
|
|
12
|
+
return s({
|
|
13
|
+
mutationKey: p.mutationKey,
|
|
14
|
+
mutationFn: async (e) => {
|
|
15
|
+
try {
|
|
16
|
+
let t = e.chainId ?? d;
|
|
17
|
+
return r(u, await p.mutationFn({
|
|
18
|
+
...e,
|
|
19
|
+
chainId: t
|
|
20
|
+
}), {
|
|
21
|
+
chainId: t,
|
|
22
|
+
waitForReceipt: l.waitForReceipt,
|
|
23
|
+
confirmations: l.confirmations
|
|
24
|
+
});
|
|
25
|
+
} catch (e) {
|
|
26
|
+
throw n(e);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
onSuccess: (e, t) => {
|
|
30
|
+
f.invalidateQueries({ predicate: i(o, { payer: t.account }) });
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { l as useApproveOperationalFee };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=use-approve-operational-fee.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-approve-operational-fee.js","names":[],"sources":["../../src/gasless/use-approve-operational-fee.ts"],"sourcesContent":["\"use client\";\n\nimport {\n approveOperationalFeeMutationOptions,\n getOperationalFeeAllowanceQueryKey,\n type ApproveOperationalFeeParameters,\n} 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 { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { resolveWriteResult } from \"../transactions/resolve-write-result\";\nimport type { WriteParameters, WriteResult } from \"../transactions/write-types\";\nimport { predicateMatch } from \"../utils/predicate-match\";\n\n/** Parameters for {@link useApproveOperationalFee}. */\nexport type UseApproveOperationalFeeParameters = WriteParameters;\n\n/** Mutation variables of {@link useApproveOperationalFee}: the core action's parameters. */\nexport type ApproveOperationalFeeVariables = ApproveOperationalFeeParameters;\n\n/** Result of {@link useApproveOperationalFee}. */\nexport type ApproveOperationalFeeResult = WriteResult;\n\n/** Return type of {@link useApproveOperationalFee}. */\nexport type UseApproveOperationalFeeReturnType = UseMutationResult<\n ApproveOperationalFeeResult,\n SymmioRequestError,\n ApproveOperationalFeeVariables\n>;\n\n/**\n * Approve operational-fee allowances for the gasless fee charger, as the\n * paying sub-account (via the AccountLayer `_call` proxy).\n *\n * Grant the allowance **before** relying on gasless execution. This is a\n * normal on-chain write — pass `gasless: true` in the variables to relay the\n * approval itself once gasless execution is active. On success the allowance\n * read is invalidated after the receipt, so `useOperationalFeeAllowance` reads\n * the new value back.\n *\n * `amounts` are **18-decimal Core units**, not the collateral token's decimals,\n * and each one replaces the current allowance. Approve a bounded budget rather\n * than `maxUint256`. Approving does not add balance: the fee is still drawn\n * from the payer's Core balance.\n *\n * @example\n * ```tsx\n * import { parseUnits } from \"viem\";\n *\n * const approve = useApproveOperationalFee();\n * // A bounded fee budget of 5 collateral tokens, in 18-decimal Core units.\n * approve.mutate({ account: subAccount, amounts: [parseUnits(\"5\", 18)] });\n * ```\n */\nexport function useApproveOperationalFee(\n parameters: UseApproveOperationalFeeParameters = {},\n): UseApproveOperationalFeeReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = approveOperationalFeeMutationOptions(config);\n\n return useMutation<ApproveOperationalFeeResult, SymmioRequestError, ApproveOperationalFeeVariables>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const hash = await base.mutationFn({ ...variables, chainId: resolvedChainId });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (_result, variables) => {\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getOperationalFeeAllowanceQueryKey, { payer: variables.account }),\n });\n },\n });\n}\n"],"mappings":";;;;;;;;;AAwDA,SAAgB,EACd,IAAiD,CAAC,GACd;CACpC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAAqC,CAAM;CAExD,OAAO,EAA6F;EAClG,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAE7C,OAAO,EAAmB,GAAQ,MADf,EAAK,WAAW;KAAE,GAAG;KAAW,SAAS;IAAgB,CAAC,GACrC;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAS,MAAc;GACjC,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAAoC,EAAE,OAAO,EAAU,QAAQ,CAAC,EAC5F,CAAC;EACH;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GaslessBatchCall } from '@symmio/trading-core';
|
|
2
|
+
import { Address } from 'viem';
|
|
3
|
+
/** The part of a batch fee quote that a form changes as the user types. */
|
|
4
|
+
export interface DebouncedBatch {
|
|
5
|
+
account: Address;
|
|
6
|
+
calls: readonly GaslessBatchCall[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The batch to quote: `account` and `calls` once their **content** has held
|
|
10
|
+
* still for `delayMs`, the last settled batch until then.
|
|
11
|
+
*
|
|
12
|
+
* Content, not identity. A form rebuilds its calls array on every render, so a
|
|
13
|
+
* debounce keyed on the value itself would restart with every render — and
|
|
14
|
+
* behind a component that re-renders faster than the delay, it would never
|
|
15
|
+
* settle at all. The batch is keyed by its query key instead: the encoded
|
|
16
|
+
* calldata, so a rebuilt but identical array changes nothing. The first batch
|
|
17
|
+
* settles at once; `delayMs <= 0` passes every change straight through.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare function useDebouncedBatch(batch: DebouncedBatch, delayMs: number): DebouncedBatch;
|
|
22
|
+
//# sourceMappingURL=use-debounced-batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-debounced-batch.d.ts","sourceRoot":"","sources":["../../src/gasless/use-debounced-batch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmC,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACpC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAoBxF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getGaslessBatchFeeQuoteQueryKey as e } from "@symmio/trading-core";
|
|
3
|
+
import { useEffect as t, useRef as n, useState as r } from "react";
|
|
4
|
+
import { hashKey as i } from "@tanstack/react-query";
|
|
5
|
+
//#region src/gasless/use-debounced-batch.ts
|
|
6
|
+
function a(a, o) {
|
|
7
|
+
let s = i(e(a)), [c, l] = r({
|
|
8
|
+
key: s,
|
|
9
|
+
batch: a
|
|
10
|
+
}), u = n(a);
|
|
11
|
+
return t(() => {
|
|
12
|
+
u.current = a;
|
|
13
|
+
}), t(() => {
|
|
14
|
+
if (o <= 0) return;
|
|
15
|
+
let e = setTimeout(() => {
|
|
16
|
+
l((e) => e.key === s ? e : {
|
|
17
|
+
key: s,
|
|
18
|
+
batch: u.current
|
|
19
|
+
});
|
|
20
|
+
}, o);
|
|
21
|
+
return () => clearTimeout(e);
|
|
22
|
+
}, [s, o]), o <= 0 || c.key === s ? a : c.batch;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { a as useDebouncedBatch };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=use-debounced-batch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-debounced-batch.js","names":[],"sources":["../../src/gasless/use-debounced-batch.ts"],"sourcesContent":["\"use client\";\n\nimport { getGaslessBatchFeeQuoteQueryKey, type GaslessBatchCall } from \"@symmio/trading-core\";\nimport { hashKey } from \"@tanstack/react-query\";\nimport { useEffect, useRef, useState } from \"react\";\nimport type { Address } from \"viem\";\n\n/** The part of a batch fee quote that a form changes as the user types. */\nexport interface DebouncedBatch {\n account: Address;\n calls: readonly GaslessBatchCall[];\n}\n\n/**\n * The batch to quote: `account` and `calls` once their **content** has held\n * still for `delayMs`, the last settled batch until then.\n *\n * Content, not identity. A form rebuilds its calls array on every render, so a\n * debounce keyed on the value itself would restart with every render — and\n * behind a component that re-renders faster than the delay, it would never\n * settle at all. The batch is keyed by its query key instead: the encoded\n * calldata, so a rebuilt but identical array changes nothing. The first batch\n * settles at once; `delayMs <= 0` passes every change straight through.\n *\n * @internal\n */\nexport function useDebouncedBatch(batch: DebouncedBatch, delayMs: number): DebouncedBatch {\n const key = hashKey(getGaslessBatchFeeQuoteQueryKey(batch));\n const [settled, setSettled] = useState({ key, batch });\n\n /** The newest batch, read when the timer fires — held in a ref so its identity can never restart the wait. */\n const latest = useRef(batch);\n useEffect(() => {\n latest.current = batch;\n });\n\n useEffect(() => {\n if (delayMs <= 0) return;\n const timer = setTimeout(() => {\n setSettled((current) => (current.key === key ? current : { key, batch: latest.current }));\n }, delayMs);\n return () => clearTimeout(timer);\n }, [key, delayMs]);\n\n if (delayMs <= 0 || settled.key === key) return batch;\n return settled.batch;\n}\n"],"mappings":";;;;;AA0BA,SAAgB,EAAkB,GAAuB,GAAiC;CACxF,IAAM,IAAM,EAAQ,EAAgC,CAAK,CAAC,GACpD,CAAC,GAAS,KAAc,EAAS;EAAE;EAAK;CAAM,CAAC,GAG/C,IAAS,EAAO,CAAK;CAc3B,OAbA,QAAgB;EACd,EAAO,UAAU;CACnB,CAAC,GAED,QAAgB;EACd,IAAI,KAAW,GAAG;EAClB,IAAM,IAAQ,iBAAiB;GAC7B,GAAY,MAAa,EAAQ,QAAQ,IAAM,IAAU;IAAE;IAAK,OAAO,EAAO;GAAQ,CAAE;EAC1F,GAAG,CAAO;EACV,aAAa,aAAa,CAAK;CACjC,GAAG,CAAC,GAAK,CAAO,CAAC,GAEb,KAAW,KAAK,EAAQ,QAAQ,IAAY,IACzC,EAAQ;AACjB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ConfigParameter, GetGaslessBatchFeeQuoteOptions, GetGaslessBatchFeeQuoteReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/** Parameters for {@link useGaslessBatchFeeQuote}. */
|
|
5
|
+
export type UseGaslessBatchFeeQuoteParameters = GetGaslessBatchFeeQuoteOptions & ConfigParameter & {
|
|
6
|
+
/**
|
|
7
|
+
* Quiet period (ms) before a changed `account` or `calls` is re-quoted, so
|
|
8
|
+
* a form that rebuilds its calls on every keystroke reads the GaslessLayer
|
|
9
|
+
* once the user pauses — not once per keystroke. Until then the quote of
|
|
10
|
+
* the last settled batch stays in place. Changes are detected by content,
|
|
11
|
+
* so rebuilding an identical array on every render never restarts the wait.
|
|
12
|
+
* The first batch is quoted at once. Defaults to 500; `0` quotes every
|
|
13
|
+
* change immediately.
|
|
14
|
+
*/
|
|
15
|
+
debounceMs?: number;
|
|
16
|
+
};
|
|
17
|
+
/** Return type of {@link useGaslessBatchFeeQuote}. */
|
|
18
|
+
export type UseGaslessBatchFeeQuoteReturnType = UseQueryResult<GetGaslessBatchFeeQuoteReturnType, SymmioRequestError>;
|
|
19
|
+
/**
|
|
20
|
+
* Preview what relaying a gasless batch would cost — the same `account` and
|
|
21
|
+
* `calls` you would hand to {@link useRelayGaslessBatch}, priced by the
|
|
22
|
+
* GaslessLayer's `previewFeeQuote` before any signature prompt.
|
|
23
|
+
*
|
|
24
|
+
* The result depends only on the account and the calls (their nonces,
|
|
25
|
+
* deadlines and signatures are never priced), so it caches per batch, and a
|
|
26
|
+
* call given by `functionName`, by `abi` or as raw `data` shares one cache
|
|
27
|
+
* entry. Amounts are 18-decimal; `totalFee18` is the batch total and
|
|
28
|
+
* `payments` has one row per call. An exhausted daily free quota surfaces as
|
|
29
|
+
* an error with code `GASLESS_FREE_QUOTA_EXHAUSTED`.
|
|
30
|
+
*
|
|
31
|
+
* Pass the form's live inputs straight in: a changed batch is **debounced
|
|
32
|
+
* internally** (`debounceMs`, default 500), so typing an amount reads the
|
|
33
|
+
* GaslessLayer once the user settles.
|
|
34
|
+
*
|
|
35
|
+
* @param parameters - The account, the calls, optional chain id, debounce, config and query overrides.
|
|
36
|
+
* @returns The TanStack query result, with failures normalized to {@link SymmioRequestError}.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* const quote = useGaslessBatchFeeQuote({
|
|
41
|
+
* account: subAccount,
|
|
42
|
+
* calls: [{ functionName: "allocate", args: [amount] }],
|
|
43
|
+
* });
|
|
44
|
+
* const fee = quote.data ? formatUnits(quote.data.totalFee18, 18) : undefined;
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function useGaslessBatchFeeQuote(parameters: UseGaslessBatchFeeQuoteParameters): UseGaslessBatchFeeQuoteReturnType;
|
|
48
|
+
//# sourceMappingURL=use-gasless-batch-fee-quote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-batch-fee-quote.d.ts","sourceRoot":"","sources":["../../src/gasless/use-gasless-batch-fee-quote.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,8BAA8B,EACnC,KAAK,iCAAiC,EACvC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAQzE,sDAAsD;AACtD,MAAM,MAAM,iCAAiC,GAAG,8BAA8B,GAC5E,eAAe,GAAG;IAChB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEJ,sDAAsD;AACtD,MAAM,MAAM,iCAAiC,GAAG,cAAc,CAAC,iCAAiC,EAAE,kBAAkB,CAAC,CAAC;AAEtH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,iCAAiC,GAC5C,iCAAiC,CA2BnC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 { useDebouncedBatch as r } from "./use-debounced-batch.js";
|
|
6
|
+
import { getGaslessBatchFeeQuoteQueryOptions as i } from "@symmio/trading-core";
|
|
7
|
+
import { useQuery as a } from "@tanstack/react-query";
|
|
8
|
+
//#region src/gasless/use-gasless-batch-fee-quote.ts
|
|
9
|
+
var o = 500;
|
|
10
|
+
function s(s) {
|
|
11
|
+
let c = t(s), l = e(), { debounceMs: u, ...d } = s, f = r({
|
|
12
|
+
account: s.account,
|
|
13
|
+
calls: s.calls
|
|
14
|
+
}, u ?? o), p = i(c, {
|
|
15
|
+
...d,
|
|
16
|
+
...f,
|
|
17
|
+
chainId: s.chainId ?? l
|
|
18
|
+
});
|
|
19
|
+
return a({
|
|
20
|
+
...p,
|
|
21
|
+
queryFn: async () => {
|
|
22
|
+
try {
|
|
23
|
+
return await p.queryFn();
|
|
24
|
+
} catch (e) {
|
|
25
|
+
throw n(e);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { s as useGaslessBatchFeeQuote };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=use-gasless-batch-fee-quote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-batch-fee-quote.js","names":[],"sources":["../../src/gasless/use-gasless-batch-fee-quote.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getGaslessBatchFeeQuoteQueryOptions,\n type ConfigParameter,\n type GetGaslessBatchFeeQuoteOptions,\n type GetGaslessBatchFeeQuoteReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\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\";\nimport { useDebouncedBatch } from \"./use-debounced-batch\";\n\n/** Default quiet period (ms) before a changed batch is re-quoted. */\nconst DEFAULT_DEBOUNCE_MS = 500;\n\n/** Parameters for {@link useGaslessBatchFeeQuote}. */\nexport type UseGaslessBatchFeeQuoteParameters = GetGaslessBatchFeeQuoteOptions &\n ConfigParameter & {\n /**\n * Quiet period (ms) before a changed `account` or `calls` is re-quoted, so\n * a form that rebuilds its calls on every keystroke reads the GaslessLayer\n * once the user pauses — not once per keystroke. Until then the quote of\n * the last settled batch stays in place. Changes are detected by content,\n * so rebuilding an identical array on every render never restarts the wait.\n * The first batch is quoted at once. Defaults to 500; `0` quotes every\n * change immediately.\n */\n debounceMs?: number;\n };\n\n/** Return type of {@link useGaslessBatchFeeQuote}. */\nexport type UseGaslessBatchFeeQuoteReturnType = UseQueryResult<GetGaslessBatchFeeQuoteReturnType, SymmioRequestError>;\n\n/**\n * Preview what relaying a gasless batch would cost — the same `account` and\n * `calls` you would hand to {@link useRelayGaslessBatch}, priced by the\n * GaslessLayer's `previewFeeQuote` before any signature prompt.\n *\n * The result depends only on the account and the calls (their nonces,\n * deadlines and signatures are never priced), so it caches per batch, and a\n * call given by `functionName`, by `abi` or as raw `data` shares one cache\n * entry. Amounts are 18-decimal; `totalFee18` is the batch total and\n * `payments` has one row per call. An exhausted daily free quota surfaces as\n * an error with code `GASLESS_FREE_QUOTA_EXHAUSTED`.\n *\n * Pass the form's live inputs straight in: a changed batch is **debounced\n * internally** (`debounceMs`, default 500), so typing an amount reads the\n * GaslessLayer once the user settles.\n *\n * @param parameters - The account, the calls, optional chain id, debounce, config and query overrides.\n * @returns The TanStack query result, with failures normalized to {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const quote = useGaslessBatchFeeQuote({\n * account: subAccount,\n * calls: [{ functionName: \"allocate\", args: [amount] }],\n * });\n * const fee = quote.data ? formatUnits(quote.data.totalFee18, 18) : undefined;\n * ```\n */\nexport function useGaslessBatchFeeQuote(\n parameters: UseGaslessBatchFeeQuoteParameters,\n): UseGaslessBatchFeeQuoteReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n\n /** `debounceMs` is pulled out so it never reaches the query options or the cache key. */\n const { debounceMs, ...queryParameters } = parameters;\n const batch = useDebouncedBatch(\n { account: parameters.account, calls: parameters.calls },\n debounceMs ?? DEFAULT_DEBOUNCE_MS,\n );\n\n const options = getGaslessBatchFeeQuoteQueryOptions(config, {\n ...queryParameters,\n ...batch,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseGaslessBatchFeeQuoteReturnType;\n}\n"],"mappings":";;;;;;;;AAgBA,IAAM,IAAsB;AAgD5B,SAAgB,EACd,GACmC;CACnC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAG3B,EAAE,eAAY,GAAG,MAAoB,GACrC,IAAQ,EACZ;EAAE,SAAS,EAAW;EAAS,OAAO,EAAW;CAAM,GACvD,KAAc,CAChB,GAEM,IAAU,EAAoC,GAAQ;EAC1D,GAAG;EACH,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ConfigParameter, GetGaslessDepositPolicyOptions, GetGaslessDepositPolicyReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/** Parameters for {@link useGaslessDepositPolicy}. */
|
|
5
|
+
export type UseGaslessDepositPolicyParameters = GetGaslessDepositPolicyOptions & ConfigParameter;
|
|
6
|
+
/** Return type of {@link useGaslessDepositPolicy}. */
|
|
7
|
+
export type UseGaslessDepositPolicyReturnType = UseQueryResult<GetGaslessDepositPolicyReturnType, SymmioRequestError>;
|
|
8
|
+
/**
|
|
9
|
+
* Read the gasless deposit policy for one of an owner's GaslessWallets - the
|
|
10
|
+
* deterministic deposit address, the collateral token and its decimals, and
|
|
11
|
+
* the deposit fee, minimum and wallet creation fee - via RPC contract reads on
|
|
12
|
+
* the GaslessLayer. `walletId` defaults to `0n`. Gate the settlement UI on the
|
|
13
|
+
* observed balance reaching `settlementMinimum`, which already covers the
|
|
14
|
+
* creation fee.
|
|
15
|
+
*
|
|
16
|
+
* The settlement hooks and `useGaslessWalletExecute` invalidate it, since
|
|
17
|
+
* either may deploy the wallet and zero its creation fee.
|
|
18
|
+
*
|
|
19
|
+
* @param parameters - Owner, optional `walletId` (default `0n`), optional chain id, config and query overrides.
|
|
20
|
+
* @returns The TanStack query result, with failures normalized to {@link SymmioRequestError}.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const query = useGaslessDepositPolicy({ owner });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useGaslessDepositPolicy(parameters: UseGaslessDepositPolicyParameters): UseGaslessDepositPolicyReturnType;
|
|
28
|
+
//# sourceMappingURL=use-gasless-deposit-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-deposit-policy.d.ts","sourceRoot":"","sources":["../../src/gasless/use-gasless-deposit-policy.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,8BAA8B,EACnC,KAAK,iCAAiC,EACvC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,sDAAsD;AACtD,MAAM,MAAM,iCAAiC,GAAG,8BAA8B,GAAG,eAAe,CAAC;AAEjG,sDAAsD;AACtD,MAAM,MAAM,iCAAiC,GAAG,cAAc,CAAC,iCAAiC,EAAE,kBAAkB,CAAC,CAAC;AAEtH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,iCAAiC,GAC5C,iCAAiC,CAmBnC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { getGaslessDepositPolicyQueryOptions as r } from "@symmio/trading-core";
|
|
6
|
+
import { useQuery as i } from "@tanstack/react-query";
|
|
7
|
+
//#region src/gasless/use-gasless-deposit-policy.ts
|
|
8
|
+
function a(a) {
|
|
9
|
+
let o = t(a), s = e(), c = r(o, {
|
|
10
|
+
...a,
|
|
11
|
+
chainId: a.chainId ?? s
|
|
12
|
+
});
|
|
13
|
+
return i({
|
|
14
|
+
...c,
|
|
15
|
+
queryFn: async () => {
|
|
16
|
+
try {
|
|
17
|
+
return await c.queryFn();
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw n(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { a as useGaslessDepositPolicy };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=use-gasless-deposit-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-deposit-policy.js","names":[],"sources":["../../src/gasless/use-gasless-deposit-policy.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getGaslessDepositPolicyQueryOptions,\n type ConfigParameter,\n type GetGaslessDepositPolicyOptions,\n type GetGaslessDepositPolicyReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\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/** Parameters for {@link useGaslessDepositPolicy}. */\nexport type UseGaslessDepositPolicyParameters = GetGaslessDepositPolicyOptions & ConfigParameter;\n\n/** Return type of {@link useGaslessDepositPolicy}. */\nexport type UseGaslessDepositPolicyReturnType = UseQueryResult<GetGaslessDepositPolicyReturnType, SymmioRequestError>;\n\n/**\n * Read the gasless deposit policy for one of an owner's GaslessWallets - the\n * deterministic deposit address, the collateral token and its decimals, and\n * the deposit fee, minimum and wallet creation fee - via RPC contract reads on\n * the GaslessLayer. `walletId` defaults to `0n`. Gate the settlement UI on the\n * observed balance reaching `settlementMinimum`, which already covers the\n * creation fee.\n *\n * The settlement hooks and `useGaslessWalletExecute` invalidate it, since\n * either may deploy the wallet and zero its creation fee.\n *\n * @param parameters - Owner, optional `walletId` (default `0n`), optional chain id, config and query overrides.\n * @returns The TanStack query result, with failures normalized to {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const query = useGaslessDepositPolicy({ owner });\n * ```\n */\nexport function useGaslessDepositPolicy(\n parameters: UseGaslessDepositPolicyParameters,\n): UseGaslessDepositPolicyReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n\n const options = getGaslessDepositPolicyQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseGaslessDepositPolicyReturnType;\n}\n"],"mappings":";;;;;;;AAuCA,SAAgB,EACd,GACmC;CACnC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAE3B,IAAU,EAAoC,GAAQ;EAC1D,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ConfigParameter, GetGaslessFeeQuoteOptions, GetGaslessFeeQuoteReturnType } from '@symmio/trading-core';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { SymmioRequestError } from '../errors/symmio-request-error.js';
|
|
4
|
+
/** Parameters for {@link useGaslessFeeQuote}. */
|
|
5
|
+
export type UseGaslessFeeQuoteParameters = GetGaslessFeeQuoteOptions & ConfigParameter;
|
|
6
|
+
/** Return type of {@link useGaslessFeeQuote}. */
|
|
7
|
+
export type UseGaslessFeeQuoteReturnType = UseQueryResult<GetGaslessFeeQuoteReturnType, SymmioRequestError>;
|
|
8
|
+
/**
|
|
9
|
+
* Quote what the GaslessLayer would charge to relay a batch (`previewFeeQuote`)
|
|
10
|
+
* before prompting the user to sign. Amounts are 18-decimal and the quote is a
|
|
11
|
+
* preview (`exact` is always `false`). An exhausted daily free quota surfaces as
|
|
12
|
+
* an error with code `GASLESS_FREE_QUOTA_EXHAUSTED` — check it with
|
|
13
|
+
* `isGaslessFreeQuotaExhaustedError`.
|
|
14
|
+
*
|
|
15
|
+
* @param parameters - The batch (`operations`, each with an optional `walletId`), optional chain id, config and query overrides.
|
|
16
|
+
* @returns The TanStack query result, with failures normalized to {@link SymmioRequestError}.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const quote = useGaslessFeeQuote({ operations: [{ operation }] });
|
|
21
|
+
* const fee18 = quote.data?.totalFee18;
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function useGaslessFeeQuote(parameters: UseGaslessFeeQuoteParameters): UseGaslessFeeQuoteReturnType;
|
|
25
|
+
//# sourceMappingURL=use-gasless-fee-quote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-fee-quote.d.ts","sourceRoot":"","sources":["../../src/gasless/use-gasless-fee-quote.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EAClC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,iDAAiD;AACjD,MAAM,MAAM,4BAA4B,GAAG,yBAAyB,GAAG,eAAe,CAAC;AAEvF,iDAAiD;AACjD,MAAM,MAAM,4BAA4B,GAAG,cAAc,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC;AAE5G;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,4BAA4B,GAAG,4BAA4B,CAmBzG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { getGaslessFeeQuoteQueryOptions as r } from "@symmio/trading-core";
|
|
6
|
+
import { useQuery as i } from "@tanstack/react-query";
|
|
7
|
+
//#region src/gasless/use-gasless-fee-quote.ts
|
|
8
|
+
function a(a) {
|
|
9
|
+
let o = t(a), s = e(), c = r(o, {
|
|
10
|
+
...a,
|
|
11
|
+
chainId: a.chainId ?? s
|
|
12
|
+
});
|
|
13
|
+
return i({
|
|
14
|
+
...c,
|
|
15
|
+
queryFn: async () => {
|
|
16
|
+
try {
|
|
17
|
+
return await c.queryFn();
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw n(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { a as useGaslessFeeQuote };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=use-gasless-fee-quote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-fee-quote.js","names":[],"sources":["../../src/gasless/use-gasless-fee-quote.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getGaslessFeeQuoteQueryOptions,\n type ConfigParameter,\n type GetGaslessFeeQuoteOptions,\n type GetGaslessFeeQuoteReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\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/** Parameters for {@link useGaslessFeeQuote}. */\nexport type UseGaslessFeeQuoteParameters = GetGaslessFeeQuoteOptions & ConfigParameter;\n\n/** Return type of {@link useGaslessFeeQuote}. */\nexport type UseGaslessFeeQuoteReturnType = UseQueryResult<GetGaslessFeeQuoteReturnType, SymmioRequestError>;\n\n/**\n * Quote what the GaslessLayer would charge to relay a batch (`previewFeeQuote`)\n * before prompting the user to sign. Amounts are 18-decimal and the quote is a\n * preview (`exact` is always `false`). An exhausted daily free quota surfaces as\n * an error with code `GASLESS_FREE_QUOTA_EXHAUSTED` — check it with\n * `isGaslessFreeQuotaExhaustedError`.\n *\n * @param parameters - The batch (`operations`, each with an optional `walletId`), optional chain id, config and query overrides.\n * @returns The TanStack query result, with failures normalized to {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const quote = useGaslessFeeQuote({ operations: [{ operation }] });\n * const fee18 = quote.data?.totalFee18;\n * ```\n */\nexport function useGaslessFeeQuote(parameters: UseGaslessFeeQuoteParameters): UseGaslessFeeQuoteReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n\n const options = getGaslessFeeQuoteQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseGaslessFeeQuoteReturnType;\n}\n"],"mappings":";;;;;;;AAoCA,SAAgB,EAAmB,GAAwE;CACzG,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAE3B,IAAU,EAA+B,GAAQ;EACrD,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Config, GaslessConfirmedRequest, GaslessService } from '@symmio/trading-core';
|
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { Address } from 'viem';
|
|
4
|
+
import { GaslessRelayParameters, GaslessRelayProgress } from './gasless-relay-types.js';
|
|
5
|
+
/**
|
|
6
|
+
* The acceptance fields a confirmation needs. Every gasless submit receipt
|
|
7
|
+
* satisfies it: an operations receipt carries `walletIds`, a deposit settlement
|
|
8
|
+
* carries the single `walletId` it settled.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export interface GaslessRelayAcceptance {
|
|
13
|
+
requestId: string;
|
|
14
|
+
idempotencyKey: string;
|
|
15
|
+
protocolInstance: string | null;
|
|
16
|
+
owner: Address;
|
|
17
|
+
walletIds?: readonly bigint[];
|
|
18
|
+
walletId?: bigint;
|
|
19
|
+
}
|
|
20
|
+
/** What the relay hook tells the confirmation about the request it just submitted. @internal */
|
|
21
|
+
export interface GaslessRelayConfirmOptions {
|
|
22
|
+
/** The chain the relay was accepted on. */
|
|
23
|
+
chainId: number;
|
|
24
|
+
/** Which sub-service stores the request. Defaults to `"operations"`. */
|
|
25
|
+
service?: GaslessService;
|
|
26
|
+
/** The workflow label the submit carried, for the persisted row. */
|
|
27
|
+
operationType?: string;
|
|
28
|
+
/** Invalidate the reads a `succeeded` relay changed. */
|
|
29
|
+
invalidate: (queryClient: QueryClient) => void;
|
|
30
|
+
}
|
|
31
|
+
/** What {@link useGaslessRelayConfirmation} hands back to a relay hook. */
|
|
32
|
+
export interface GaslessRelayConfirmationController {
|
|
33
|
+
/** Current progress, to merge onto the mutation result as `relay`. */
|
|
34
|
+
progress: GaslessRelayProgress;
|
|
35
|
+
/** Reset progress and abort any in-flight wait. Call from the hook's `reset`. */
|
|
36
|
+
reset: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Run the submit half of a relay through the progress state.
|
|
39
|
+
*
|
|
40
|
+
* Publishes `submitting` for the window between the user's click and the
|
|
41
|
+
* service's `202` — signing and the POST — which is the one stretch
|
|
42
|
+
* {@link confirm} cannot see, and publishes `error` if that window fails.
|
|
43
|
+
* Nothing is accepted yet, so neither phase carries a request id.
|
|
44
|
+
*/
|
|
45
|
+
submit: <result>(send: () => Promise<result>) => Promise<result>;
|
|
46
|
+
/**
|
|
47
|
+
* Follow an accepted request to the configured depth.
|
|
48
|
+
*
|
|
49
|
+
* Returns the confirmation, or `undefined` for `confirmation: "none"`.
|
|
50
|
+
* `invalidate` runs whenever a `succeeded` terminal was observed — including
|
|
51
|
+
* when the wait was later aborted — because the point of waiting is the
|
|
52
|
+
* invalidation, and the query client outlives the component.
|
|
53
|
+
*/
|
|
54
|
+
confirm: (accepted: GaslessRelayAcceptance, options: GaslessRelayConfirmOptions) => Promise<GaslessConfirmedRequest | undefined>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The confirmation half of every explicit relay hook.
|
|
58
|
+
*
|
|
59
|
+
* Owns the four things a relay mutation needs and a plain `useMutation` cannot
|
|
60
|
+
* give it: an `AbortController` tied to the component's life, progress state
|
|
61
|
+
* that survives a 120-second wait, the `onAccepted` hand-off that lets a
|
|
62
|
+
* consumer persist the request id before anything can go wrong, and the
|
|
63
|
+
* guarantee that a `succeeded` relay invalidates its reads even if nobody is
|
|
64
|
+
* left watching.
|
|
65
|
+
*
|
|
66
|
+
* @param parameters - The hook's confirmation options.
|
|
67
|
+
* @param config - The SDK config, for the confirm call and the cache seed.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
export declare function useGaslessRelayConfirmation(parameters: GaslessRelayParameters, config: Config): GaslessRelayConfirmationController;
|
|
72
|
+
//# sourceMappingURL=use-gasless-relay-confirmation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gasless-relay-confirmation.d.ts","sourceRoot":"","sources":["../../src/gasless/use-gasless-relay-confirmation.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,MAAM,EAEX,KAAK,uBAAuB,EAE5B,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAuB,KAAK,sBAAsB,EAAE,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAEpH;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,gGAAgG;AAChG,MAAM,WAAW,0BAA0B;IACzC,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,oEAAoE;IACpE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wDAAwD;IACxD,UAAU,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,IAAI,CAAC;CAChD;AAED,2EAA2E;AAC3E,MAAM,WAAW,kCAAkC;IACjD,sEAAsE;IACtE,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,iFAAiF;IACjF,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;;;;;OAOG;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACjE;;;;;;;OAOG;IACH,OAAO,EAAE,CACP,QAAQ,EAAE,sBAAsB,EAChC,OAAO,EAAE,0BAA0B,KAChC,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAAC;CACnD;AAWD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,sBAAsB,EAClC,MAAM,EAAE,MAAM,GACb,kCAAkC,CA8MpC"}
|