@symmio/trading-core 4.2.1 → 4.4.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/core/chains/registry.d.ts.map +1 -1
- package/dist/core/chains/registry.js +4 -5
- package/dist/core/chains/registry.js.map +1 -1
- package/dist/core/chains/types.d.ts +36 -1
- package/dist/core/chains/types.d.ts.map +1 -1
- package/dist/core/chains/types.js.map +1 -1
- package/dist/core/config/merge-chain-config.js +6 -3
- package/dist/core/config/merge-chain-config.js.map +1 -1
- package/dist/gasless/batch/calls.d.ts +21 -7
- package/dist/gasless/batch/calls.d.ts.map +1 -1
- package/dist/gasless/batch/calls.js +17 -16
- package/dist/gasless/batch/calls.js.map +1 -1
- package/dist/gasless/batch/resolve-gasless-batch.d.ts +10 -1
- package/dist/gasless/batch/resolve-gasless-batch.d.ts.map +1 -1
- package/dist/gasless/batch/resolve-gasless-batch.js +17 -15
- package/dist/gasless/batch/resolve-gasless-batch.js.map +1 -1
- package/dist/gasless/classify-gasless-failure.d.ts +3 -1
- package/dist/gasless/classify-gasless-failure.d.ts.map +1 -1
- package/dist/gasless/classify-gasless-failure.js +10 -10
- package/dist/gasless/classify-gasless-failure.js.map +1 -1
- package/dist/gasless/confirm-gasless-request/confirm-gasless-request.js +5 -5
- package/dist/gasless/constants.d.ts +21 -0
- package/dist/gasless/constants.d.ts.map +1 -1
- package/dist/gasless/constants.js +2 -2
- package/dist/gasless/constants.js.map +1 -1
- package/dist/gasless/delegation-preflight.js +10 -10
- package/dist/gasless/deployment-key.d.ts +39 -0
- package/dist/gasless/deployment-key.d.ts.map +1 -0
- package/dist/gasless/deployment-key.js +22 -0
- package/dist/gasless/deployment-key.js.map +1 -0
- package/dist/gasless/dispatch/attempt-start.d.ts +31 -0
- package/dist/gasless/dispatch/attempt-start.d.ts.map +1 -0
- package/dist/gasless/dispatch/attempt-start.js +14 -0
- package/dist/gasless/dispatch/attempt-start.js.map +1 -0
- package/dist/gasless/dispatch/maybe-relay-as-gasless.d.ts +4 -43
- package/dist/gasless/dispatch/maybe-relay-as-gasless.d.ts.map +1 -1
- package/dist/gasless/dispatch/maybe-relay-as-gasless.js +24 -182
- package/dist/gasless/dispatch/maybe-relay-as-gasless.js.map +1 -1
- package/dist/gasless/dispatch/resolve-gasless-write.d.ts +40 -0
- package/dist/gasless/dispatch/resolve-gasless-write.d.ts.map +1 -0
- package/dist/gasless/dispatch/resolve-gasless-write.js +48 -0
- package/dist/gasless/dispatch/resolve-gasless-write.js.map +1 -0
- package/dist/gasless/dispatch/submit-gasless-write.d.ts +11 -0
- package/dist/gasless/dispatch/submit-gasless-write.d.ts.map +1 -0
- package/dist/gasless/dispatch/submit-gasless-write.js +180 -0
- package/dist/gasless/dispatch/submit-gasless-write.js.map +1 -0
- package/dist/gasless/dispatch/types.d.ts +42 -0
- package/dist/gasless/dispatch/types.d.ts.map +1 -0
- package/dist/gasless/effective-instant-selectors.d.ts +11 -0
- package/dist/gasless/effective-instant-selectors.d.ts.map +1 -0
- package/dist/gasless/effective-instant-selectors.js +25 -0
- package/dist/gasless/effective-instant-selectors.js.map +1 -0
- package/dist/gasless/fallback.d.ts +43 -0
- package/dist/gasless/fallback.d.ts.map +1 -1
- package/dist/gasless/fallback.js +27 -17
- package/dist/gasless/fallback.js.map +1 -1
- package/dist/gasless/gasless-wallet-execute/gasless-wallet-execute.d.ts +13 -5
- package/dist/gasless/gasless-wallet-execute/gasless-wallet-execute.d.ts.map +1 -1
- package/dist/gasless/gasless-wallet-execute/gasless-wallet-execute.js +88 -81
- package/dist/gasless/gasless-wallet-execute/gasless-wallet-execute.js.map +1 -1
- package/dist/gasless/get-session-key-selectors.d.ts +18 -4
- package/dist/gasless/get-session-key-selectors.d.ts.map +1 -1
- package/dist/gasless/get-session-key-selectors.js +20 -12
- package/dist/gasless/get-session-key-selectors.js.map +1 -1
- package/dist/gasless/http.d.ts +7 -7
- package/dist/gasless/http.d.ts.map +1 -1
- package/dist/gasless/http.js +70 -72
- package/dist/gasless/http.js.map +1 -1
- package/dist/gasless/idempotency-key.d.ts +33 -0
- package/dist/gasless/idempotency-key.d.ts.map +1 -0
- package/dist/gasless/idempotency-key.js +15 -0
- package/dist/gasless/idempotency-key.js.map +1 -0
- package/dist/gasless/index.d.ts +2 -0
- package/dist/gasless/index.d.ts.map +1 -1
- package/dist/gasless/nonce-lock.d.ts +55 -17
- package/dist/gasless/nonce-lock.d.ts.map +1 -1
- package/dist/gasless/nonce-lock.js +53 -26
- package/dist/gasless/nonce-lock.js.map +1 -1
- package/dist/gasless/relay-gasless-batch/preflight-batch-delegations.d.ts +30 -0
- package/dist/gasless/relay-gasless-batch/preflight-batch-delegations.d.ts.map +1 -0
- package/dist/gasless/relay-gasless-batch/preflight-batch-delegations.js +67 -0
- package/dist/gasless/relay-gasless-batch/preflight-batch-delegations.js.map +1 -0
- package/dist/gasless/relay-gasless-batch/relay-gasless-batch.d.ts +30 -9
- package/dist/gasless/relay-gasless-batch/relay-gasless-batch.d.ts.map +1 -1
- package/dist/gasless/relay-gasless-batch/relay-gasless-batch.js +99 -102
- package/dist/gasless/relay-gasless-batch/relay-gasless-batch.js.map +1 -1
- package/dist/gasless/relay-gasless-batch/resolve-batch-signers.d.ts +18 -0
- package/dist/gasless/relay-gasless-batch/resolve-batch-signers.d.ts.map +1 -0
- package/dist/gasless/relay-gasless-batch/resolve-batch-signers.js +17 -0
- package/dist/gasless/relay-gasless-batch/resolve-batch-signers.js.map +1 -0
- package/dist/gasless/relay-gasless-batch/sign-gasless-batch.d.ts +8 -5
- package/dist/gasless/relay-gasless-batch/sign-gasless-batch.d.ts.map +1 -1
- package/dist/gasless/relay-gasless-batch/sign-gasless-batch.js +22 -16
- package/dist/gasless/relay-gasless-batch/sign-gasless-batch.js.map +1 -1
- package/dist/gasless/relay-grant-delegation/relay-grant-delegation.d.ts +13 -7
- package/dist/gasless/relay-grant-delegation/relay-grant-delegation.d.ts.map +1 -1
- package/dist/gasless/relay-grant-delegation/relay-grant-delegation.js +46 -36
- package/dist/gasless/relay-grant-delegation/relay-grant-delegation.js.map +1 -1
- package/dist/gasless/relay-instant-operations/relay-instant-operations.d.ts +14 -15
- package/dist/gasless/relay-instant-operations/relay-instant-operations.d.ts.map +1 -1
- package/dist/gasless/relay-instant-operations/relay-instant-operations.js +12 -11
- package/dist/gasless/relay-instant-operations/relay-instant-operations.js.map +1 -1
- package/dist/gasless/relayable-writes.d.ts.map +1 -1
- package/dist/gasless/relayable-writes.js +28 -0
- package/dist/gasless/relayable-writes.js.map +1 -1
- package/dist/gasless/request-headers.d.ts +7 -0
- package/dist/gasless/request-headers.d.ts.map +1 -0
- package/dist/gasless/request-headers.js +34 -0
- package/dist/gasless/request-headers.js.map +1 -0
- package/dist/gasless/resolve-wallet-identities.js +4 -4
- package/dist/gasless/resubmit-gasless-request/resubmit-gasless-request.d.ts +11 -4
- package/dist/gasless/resubmit-gasless-request/resubmit-gasless-request.d.ts.map +1 -1
- package/dist/gasless/resubmit-gasless-request/resubmit-gasless-request.js +2 -2
- package/dist/gasless/resubmit-gasless-request/resubmit-gasless-request.js.map +1 -1
- package/dist/gasless/settle-gasless-deposit-existing-account/settle-gasless-deposit-existing-account.d.ts +10 -14
- package/dist/gasless/settle-gasless-deposit-existing-account/settle-gasless-deposit-existing-account.d.ts.map +1 -1
- package/dist/gasless/settle-gasless-deposit-existing-account/settle-gasless-deposit-existing-account.js +3 -2
- package/dist/gasless/settle-gasless-deposit-existing-account/settle-gasless-deposit-existing-account.js.map +1 -1
- package/dist/gasless/settle-gasless-deposit-new-account/settle-gasless-deposit-new-account.d.ts +15 -15
- package/dist/gasless/settle-gasless-deposit-new-account/settle-gasless-deposit-new-account.d.ts.map +1 -1
- package/dist/gasless/settle-gasless-deposit-new-account/settle-gasless-deposit-new-account.js +13 -12
- package/dist/gasless/settle-gasless-deposit-new-account/settle-gasless-deposit-new-account.js.map +1 -1
- package/dist/gasless/unconfirmed-submit.d.ts +12 -8
- package/dist/gasless/unconfirmed-submit.d.ts.map +1 -1
- package/dist/gasless/unconfirmed-submit.js +1 -1
- package/dist/gasless/unconfirmed-submit.js.map +1 -1
- package/dist/index.d.ts +26 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +673 -615
- package/dist/shared/errors/symm-error.js +3 -3
- package/dist/shared/types/properties.d.ts +45 -8
- package/dist/shared/types/properties.d.ts.map +1 -1
- package/dist/solvers/capabilities.d.ts.map +1 -1
- package/dist/solvers/capabilities.js +4 -2
- package/dist/solvers/capabilities.js.map +1 -1
- package/dist/solvers/estimated-price/get-estimated-price.d.ts +3 -1
- package/dist/solvers/estimated-price/get-estimated-price.d.ts.map +1 -1
- package/dist/solvers/estimated-price/get-estimated-price.js +6 -6
- package/dist/solvers/estimated-price/get-estimated-price.js.map +1 -1
- package/dist/solvers/estimated-price/to-estimated-price.d.ts +2 -1
- package/dist/solvers/estimated-price/to-estimated-price.d.ts.map +1 -1
- package/dist/solvers/estimated-price/to-estimated-price.js +4 -1
- package/dist/solvers/estimated-price/to-estimated-price.js.map +1 -1
- package/dist/solvers/force-close/force-close-auto.d.ts.map +1 -1
- package/dist/solvers/force-close/force-close-auto.js +70 -69
- package/dist/solvers/force-close/force-close-auto.js.map +1 -1
- package/dist/solvers/get-error-message/get-error-message.js +4 -4
- package/dist/solvers/get-party-a-upnl/get-party-a-upnl.js +4 -4
- package/dist/solvers/get-solver-balance-info/get-solver-balance-info.js +4 -4
- package/dist/solvers/get-solver-info/get-solver-info.d.ts +5 -2
- package/dist/solvers/get-solver-info/get-solver-info.d.ts.map +1 -1
- package/dist/solvers/get-solver-info/get-solver-info.js +14 -12
- package/dist/solvers/get-solver-info/get-solver-info.js.map +1 -1
- package/dist/solvers/get-solver-info/parse-timelock-info.d.ts +5 -0
- package/dist/solvers/get-solver-info/parse-timelock-info.d.ts.map +1 -0
- package/dist/solvers/get-solver-info/parse-timelock-info.js +27 -0
- package/dist/solvers/get-solver-info/parse-timelock-info.js.map +1 -0
- package/dist/solvers/get-solver-open-interest/get-solver-open-interest.js +4 -4
- package/dist/solvers/get-solver-price-range/get-solver-price-range.js +4 -4
- package/dist/solvers/get-solver-readiness/get-solver-readiness.js +4 -4
- package/dist/solvers/instant-open/get-instant-opens/adapters/enigma-instant-opens.js +17 -17
- package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.d.ts +8 -7
- package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.d.ts.map +1 -1
- package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.js +43 -39
- package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.js.map +1 -1
- package/dist/solvers/instant-open/instant-open/adapters/enigma-margin-timelock.d.ts +16 -0
- package/dist/solvers/instant-open/instant-open/adapters/enigma-margin-timelock.d.ts.map +1 -0
- package/dist/solvers/instant-open/instant-open/adapters/enigma-margin-timelock.js +92 -0
- package/dist/solvers/instant-open/instant-open/adapters/enigma-margin-timelock.js.map +1 -0
- package/dist/solvers/instant-open/instant-open/adapters/rasa-instant-open.js +1 -1
- package/dist/solvers/instant-open/instant-open/index.d.ts +2 -0
- package/dist/solvers/instant-open/instant-open/index.d.ts.map +1 -1
- package/dist/solvers/instant-open/instant-open/instant-open.d.ts +22 -6
- package/dist/solvers/instant-open/instant-open/instant-open.d.ts.map +1 -1
- package/dist/solvers/instant-open/instant-open/instant-open.js +35 -27
- package/dist/solvers/instant-open/instant-open/instant-open.js.map +1 -1
- package/dist/solvers/instant-open/instant-open/prepared/submit-prepared-instant-open.d.ts +12 -0
- package/dist/solvers/instant-open/instant-open/prepared/submit-prepared-instant-open.d.ts.map +1 -0
- package/dist/solvers/instant-open/instant-open/prepared/submit-prepared-instant-open.js +49 -0
- package/dist/solvers/instant-open/instant-open/prepared/submit-prepared-instant-open.js.map +1 -0
- package/dist/solvers/instant-open/instant-open/prepared/types.d.ts +20 -0
- package/dist/solvers/instant-open/instant-open/prepared/types.d.ts.map +1 -0
- package/dist/solvers/instant-open/instant-open/types.d.ts +5 -4
- package/dist/solvers/instant-open/instant-open/types.d.ts.map +1 -1
- package/dist/solvers/instant-open/shared/hedger-api.d.ts.map +1 -1
- package/dist/solvers/instant-open/shared/hedger-api.js +38 -26
- package/dist/solvers/instant-open/shared/hedger-api.js.map +1 -1
- package/dist/solvers/markets/adapters/enigma-markets.js +34 -34
- package/dist/solvers/notional-cap/get-notional-cap-page.js +4 -4
- package/dist/solvers/revenue/get-solver-revenue.js +10 -10
- package/dist/solvers/revenue-records/get-revenue-records.js +11 -11
- package/dist/solvers/symbols/get-symbols.js +13 -13
- package/dist/solvers/trade-volume/get-trade-volume.js +10 -10
- package/dist/solvers/types/generated/enigma-solver.d.ts +1 -0
- package/dist/solvers/types/generated/enigma-solver.d.ts.map +1 -1
- package/dist/solvers/types/generated/enigma-solver.js.map +1 -1
- package/dist/symmio-contracts/abi/v0.8.6/instant-layer.d.ts +46 -0
- package/dist/symmio-contracts/abi/v0.8.6/instant-layer.d.ts.map +1 -1
- package/dist/symmio-contracts/abi/v0.8.6/instant-layer.js +53 -0
- package/dist/symmio-contracts/abi/v0.8.6/instant-layer.js.map +1 -1
- package/dist/symmio-contracts/account-layer/actions/add-margin.d.ts +3 -0
- package/dist/symmio-contracts/account-layer/actions/add-margin.d.ts.map +1 -1
- package/dist/symmio-contracts/account-layer/actions/add-margin.js +41 -27
- package/dist/symmio-contracts/account-layer/actions/add-margin.js.map +1 -1
- package/dist/symmio-contracts/account-layer/actions/create-sub-accounts.d.ts +23 -9
- package/dist/symmio-contracts/account-layer/actions/create-sub-accounts.d.ts.map +1 -1
- package/dist/symmio-contracts/account-layer/actions/create-sub-accounts.js +15 -36
- package/dist/symmio-contracts/account-layer/actions/create-sub-accounts.js.map +1 -1
- package/dist/symmio-contracts/account-layer/actions/delete-sub-account.d.ts +3 -0
- package/dist/symmio-contracts/account-layer/actions/delete-sub-account.d.ts.map +1 -1
- package/dist/symmio-contracts/account-layer/actions/delete-sub-account.js +40 -26
- package/dist/symmio-contracts/account-layer/actions/delete-sub-account.js.map +1 -1
- package/dist/symmio-contracts/account-layer/actions/edit-account-name.d.ts +1 -1
- package/dist/symmio-contracts/account-layer/actions/edit-account-name.d.ts.map +1 -1
- package/dist/symmio-contracts/account-layer/actions/edit-account-name.js +18 -37
- package/dist/symmio-contracts/account-layer/actions/edit-account-name.js.map +1 -1
- package/dist/symmio-contracts/account-layer/actions/get-active-virtual-account-by-key.d.ts +46 -0
- package/dist/symmio-contracts/account-layer/actions/get-active-virtual-account-by-key.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/actions/get-active-virtual-account-by-key.js +20 -0
- package/dist/symmio-contracts/account-layer/actions/get-active-virtual-account-by-key.js.map +1 -0
- package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-count-of-sub-account.d.ts +31 -0
- package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-count-of-sub-account.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-count-of-sub-account.js +15 -0
- package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-count-of-sub-account.js.map +1 -0
- package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-of-sub-account.d.ts +54 -0
- package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-of-sub-account.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-of-sub-account.js +26 -0
- package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-of-sub-account.js.map +1 -0
- package/dist/symmio-contracts/account-layer/actions/remove-margin.d.ts +3 -0
- package/dist/symmio-contracts/account-layer/actions/remove-margin.d.ts.map +1 -1
- package/dist/symmio-contracts/account-layer/actions/remove-margin.js +50 -32
- package/dist/symmio-contracts/account-layer/actions/remove-margin.js.map +1 -1
- package/dist/symmio-contracts/account-layer/cancel-timelock-op/cancel-timelock-op.d.ts +12 -0
- package/dist/symmio-contracts/account-layer/cancel-timelock-op/cancel-timelock-op.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/cancel-timelock-op/cancel-timelock-op.js +10 -0
- package/dist/symmio-contracts/account-layer/cancel-timelock-op/cancel-timelock-op.js.map +1 -0
- package/dist/symmio-contracts/account-layer/cancel-timelock-op/index.d.ts +3 -0
- package/dist/symmio-contracts/account-layer/cancel-timelock-op/index.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/cancel-timelock-op/query.d.ts +9 -0
- package/dist/symmio-contracts/account-layer/cancel-timelock-op/query.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/cancel-timelock-op/query.js +13 -0
- package/dist/symmio-contracts/account-layer/cancel-timelock-op/query.js.map +1 -0
- package/dist/symmio-contracts/account-layer/clear-timelocks/clear-timelocks.d.ts +12 -0
- package/dist/symmio-contracts/account-layer/clear-timelocks/clear-timelocks.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/clear-timelocks/clear-timelocks.js +10 -0
- package/dist/symmio-contracts/account-layer/clear-timelocks/clear-timelocks.js.map +1 -0
- package/dist/symmio-contracts/account-layer/clear-timelocks/index.d.ts +3 -0
- package/dist/symmio-contracts/account-layer/clear-timelocks/index.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/clear-timelocks/query.d.ts +9 -0
- package/dist/symmio-contracts/account-layer/clear-timelocks/query.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/clear-timelocks/query.js +13 -0
- package/dist/symmio-contracts/account-layer/clear-timelocks/query.js.map +1 -0
- package/dist/symmio-contracts/account-layer/execute-timelock-op/execute-timelock-op.d.ts +12 -0
- package/dist/symmio-contracts/account-layer/execute-timelock-op/execute-timelock-op.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/execute-timelock-op/execute-timelock-op.js +9 -0
- package/dist/symmio-contracts/account-layer/execute-timelock-op/execute-timelock-op.js.map +1 -0
- package/dist/symmio-contracts/account-layer/execute-timelock-op/index.d.ts +3 -0
- package/dist/symmio-contracts/account-layer/execute-timelock-op/index.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/execute-timelock-op/query.d.ts +9 -0
- package/dist/symmio-contracts/account-layer/execute-timelock-op/query.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/execute-timelock-op/query.js +13 -0
- package/dist/symmio-contracts/account-layer/execute-timelock-op/query.js.map +1 -0
- package/dist/symmio-contracts/account-layer/get-min-timelock-delay/get-min-timelock-delay.d.ts +12 -0
- package/dist/symmio-contracts/account-layer/get-min-timelock-delay/get-min-timelock-delay.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/get-min-timelock-delay/get-min-timelock-delay.js +16 -0
- package/dist/symmio-contracts/account-layer/get-min-timelock-delay/get-min-timelock-delay.js.map +1 -0
- package/dist/symmio-contracts/account-layer/get-min-timelock-delay/index.d.ts +2 -0
- package/dist/symmio-contracts/account-layer/get-min-timelock-delay/index.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/get-selector-timelock/get-selector-timelock.d.ts +12 -0
- package/dist/symmio-contracts/account-layer/get-selector-timelock/get-selector-timelock.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/get-selector-timelock/get-selector-timelock.js +22 -0
- package/dist/symmio-contracts/account-layer/get-selector-timelock/get-selector-timelock.js.map +1 -0
- package/dist/symmio-contracts/account-layer/get-selector-timelock/index.d.ts +3 -0
- package/dist/symmio-contracts/account-layer/get-selector-timelock/index.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/get-selector-timelock/query.d.ts +22 -0
- package/dist/symmio-contracts/account-layer/get-selector-timelock/query.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/get-selector-timelock/query.js +21 -0
- package/dist/symmio-contracts/account-layer/get-selector-timelock/query.js.map +1 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule/get-timelock-schedule.d.ts +12 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule/get-timelock-schedule.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule/get-timelock-schedule.js +22 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule/get-timelock-schedule.js.map +1 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule/index.d.ts +2 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule/index.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-grace-period/get-timelock-schedule-grace-period.d.ts +13 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-grace-period/get-timelock-schedule-grace-period.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-grace-period/get-timelock-schedule-grace-period.js +17 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-grace-period/get-timelock-schedule-grace-period.js.map +1 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-grace-period/index.d.ts +2 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-grace-period/index.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/get-timelock-schedule-state.d.ts +12 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/get-timelock-schedule-state.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/get-timelock-schedule-state.js +67 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/get-timelock-schedule-state.js.map +1 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/index.d.ts +3 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/index.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/query.d.ts +21 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/query.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/query.js +21 -0
- package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/query.js.map +1 -0
- package/dist/symmio-contracts/account-layer/hash-timelock-approval/hash-timelock-approval.d.ts +15 -0
- package/dist/symmio-contracts/account-layer/hash-timelock-approval/hash-timelock-approval.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/hash-timelock-approval/hash-timelock-approval.js +17 -0
- package/dist/symmio-contracts/account-layer/hash-timelock-approval/hash-timelock-approval.js.map +1 -0
- package/dist/symmio-contracts/account-layer/hash-timelock-approval/index.d.ts +2 -0
- package/dist/symmio-contracts/account-layer/hash-timelock-approval/index.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/hook-metadata.d.ts +47 -0
- package/dist/symmio-contracts/account-layer/hook-metadata.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/hook-metadata.js +30 -0
- package/dist/symmio-contracts/account-layer/hook-metadata.js.map +1 -0
- package/dist/symmio-contracts/account-layer/index.d.ts +21 -0
- package/dist/symmio-contracts/account-layer/index.d.ts.map +1 -1
- package/dist/symmio-contracts/account-layer/is-timelock-approval-used/index.d.ts +2 -0
- package/dist/symmio-contracts/account-layer/is-timelock-approval-used/index.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/is-timelock-approval-used/is-timelock-approval-used.d.ts +14 -0
- package/dist/symmio-contracts/account-layer/is-timelock-approval-used/is-timelock-approval-used.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/is-timelock-approval-used/is-timelock-approval-used.js +17 -0
- package/dist/symmio-contracts/account-layer/is-timelock-approval-used/is-timelock-approval-used.js.map +1 -0
- package/dist/symmio-contracts/account-layer/query/generate-account-manager-address.js +6 -6
- package/dist/symmio-contracts/account-layer/query/get-account-balance-info.js +6 -6
- package/dist/symmio-contracts/account-layer/query/get-account-balance-of.js +6 -6
- package/dist/symmio-contracts/account-layer/query/get-active-virtual-account-by-key.d.ts +43 -0
- package/dist/symmio-contracts/account-layer/query/get-active-virtual-account-by-key.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/query/get-active-virtual-account-by-key.js +31 -0
- package/dist/symmio-contracts/account-layer/query/get-active-virtual-account-by-key.js.map +1 -0
- package/dist/symmio-contracts/account-layer/query/get-affiliate-state.js +6 -6
- package/dist/symmio-contracts/account-layer/query/get-sub-account-virtual-nonce.js +6 -6
- package/dist/symmio-contracts/account-layer/query/get-sub-accounts-count-of-user.js +6 -6
- package/dist/symmio-contracts/account-layer/query/get-user-sub-accounts-addresses.js +6 -6
- package/dist/symmio-contracts/account-layer/query/get-user-sub-accounts.js +6 -6
- package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-addresses-of-sub-account.js +6 -6
- package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-count-of-sub-account.d.ts +39 -0
- package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-count-of-sub-account.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-count-of-sub-account.js +29 -0
- package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-count-of-sub-account.js.map +1 -0
- package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-of-sub-account.d.ts +39 -0
- package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-of-sub-account.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-of-sub-account.js +31 -0
- package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-of-sub-account.js.map +1 -0
- package/dist/symmio-contracts/account-layer/query/predict-next-virtual-account.js +6 -6
- package/dist/symmio-contracts/account-layer/resolve-timelock-root-account/index.d.ts +2 -0
- package/dist/symmio-contracts/account-layer/resolve-timelock-root-account/index.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/resolve-timelock-root-account/resolve-timelock-root-account.d.ts +19 -0
- package/dist/symmio-contracts/account-layer/resolve-timelock-root-account/resolve-timelock-root-account.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/resolve-timelock-root-account/resolve-timelock-root-account.js +10 -0
- package/dist/symmio-contracts/account-layer/resolve-timelock-root-account/resolve-timelock-root-account.js.map +1 -0
- package/dist/symmio-contracts/account-layer/schedule-timelock-op/index.d.ts +3 -0
- package/dist/symmio-contracts/account-layer/schedule-timelock-op/index.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/schedule-timelock-op/query.d.ts +9 -0
- package/dist/symmio-contracts/account-layer/schedule-timelock-op/query.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/schedule-timelock-op/query.js +13 -0
- package/dist/symmio-contracts/account-layer/schedule-timelock-op/query.js.map +1 -0
- package/dist/symmio-contracts/account-layer/schedule-timelock-op/schedule-timelock-op.d.ts +12 -0
- package/dist/symmio-contracts/account-layer/schedule-timelock-op/schedule-timelock-op.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/schedule-timelock-op/schedule-timelock-op.js +10 -0
- package/dist/symmio-contracts/account-layer/schedule-timelock-op/schedule-timelock-op.js.map +1 -0
- package/dist/symmio-contracts/account-layer/setup-timelocks/index.d.ts +3 -0
- package/dist/symmio-contracts/account-layer/setup-timelocks/index.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/setup-timelocks/query.d.ts +9 -0
- package/dist/symmio-contracts/account-layer/setup-timelocks/query.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/setup-timelocks/query.js +13 -0
- package/dist/symmio-contracts/account-layer/setup-timelocks/query.js.map +1 -0
- package/dist/symmio-contracts/account-layer/setup-timelocks/setup-timelocks.d.ts +13 -0
- package/dist/symmio-contracts/account-layer/setup-timelocks/setup-timelocks.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/setup-timelocks/setup-timelocks.js +18 -0
- package/dist/symmio-contracts/account-layer/setup-timelocks/setup-timelocks.js.map +1 -0
- package/dist/symmio-contracts/account-layer/timelock-selector.d.ts +4 -0
- package/dist/symmio-contracts/account-layer/timelock-selector.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/timelock-selector.js +9 -0
- package/dist/symmio-contracts/account-layer/timelock-selector.js.map +1 -0
- package/dist/symmio-contracts/account-layer/timelock-test.d.ts +7 -0
- package/dist/symmio-contracts/account-layer/timelock-test.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/timelock-types.d.ts +66 -0
- package/dist/symmio-contracts/account-layer/timelock-types.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/types.d.ts +32 -2
- package/dist/symmio-contracts/account-layer/types.d.ts.map +1 -1
- package/dist/symmio-contracts/account-layer/types.js.map +1 -1
- package/dist/symmio-contracts/account-layer/write-timelock.d.ts +10 -0
- package/dist/symmio-contracts/account-layer/write-timelock.d.ts.map +1 -0
- package/dist/symmio-contracts/account-layer/write-timelock.js +51 -0
- package/dist/symmio-contracts/account-layer/write-timelock.js.map +1 -0
- package/dist/symmio-contracts/instant-layer/actions/grant-delegation.d.ts +4 -1
- package/dist/symmio-contracts/instant-layer/actions/grant-delegation.d.ts.map +1 -1
- package/dist/symmio-contracts/instant-layer/actions/grant-delegation.js +42 -38
- package/dist/symmio-contracts/instant-layer/actions/grant-delegation.js.map +1 -1
- package/dist/symmio-contracts/instant-layer/actions/grant-delegations.d.ts +75 -0
- package/dist/symmio-contracts/instant-layer/actions/grant-delegations.d.ts.map +1 -0
- package/dist/symmio-contracts/instant-layer/actions/grant-delegations.js +46 -0
- package/dist/symmio-contracts/instant-layer/actions/grant-delegations.js.map +1 -0
- package/dist/symmio-contracts/instant-layer/actions/simulate-grant-delegations.d.ts +32 -0
- package/dist/symmio-contracts/instant-layer/actions/simulate-grant-delegations.d.ts.map +1 -0
- package/dist/symmio-contracts/instant-layer/actions/simulate-grant-delegations.js +18 -0
- package/dist/symmio-contracts/instant-layer/actions/simulate-grant-delegations.js.map +1 -0
- package/dist/symmio-contracts/instant-layer/grant-delegations-input.d.ts +33 -0
- package/dist/symmio-contracts/instant-layer/grant-delegations-input.d.ts.map +1 -0
- package/dist/symmio-contracts/instant-layer/grant-delegations-input.js +18 -0
- package/dist/symmio-contracts/instant-layer/grant-delegations-input.js.map +1 -0
- package/dist/symmio-contracts/instant-layer/index.d.ts +4 -0
- package/dist/symmio-contracts/instant-layer/index.d.ts.map +1 -1
- package/dist/symmio-contracts/instant-layer/query/grant-delegations.d.ts +22 -0
- package/dist/symmio-contracts/instant-layer/query/grant-delegations.d.ts.map +1 -0
- package/dist/symmio-contracts/instant-layer/query/grant-delegations.js +12 -0
- package/dist/symmio-contracts/instant-layer/query/grant-delegations.js.map +1 -0
- package/dist/symmio-contracts/instant-layer/query/simulate-grant-delegations.d.ts +19 -0
- package/dist/symmio-contracts/instant-layer/query/simulate-grant-delegations.d.ts.map +1 -0
- package/dist/symmio-contracts/instant-layer/query/simulate-grant-delegations.js +12 -0
- package/dist/symmio-contracts/instant-layer/query/simulate-grant-delegations.js.map +1 -0
- package/dist/symmio-contracts/symmio/actions/allocate.d.ts +3 -0
- package/dist/symmio-contracts/symmio/actions/allocate.d.ts.map +1 -1
- package/dist/symmio-contracts/symmio/actions/allocate.js +22 -16
- package/dist/symmio-contracts/symmio/actions/allocate.js.map +1 -1
- package/dist/symmio-contracts/symmio/actions/approve-operational-fee-allowance.d.ts +74 -0
- package/dist/symmio-contracts/symmio/actions/approve-operational-fee-allowance.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/actions/approve-operational-fee-allowance.js +36 -0
- package/dist/symmio-contracts/symmio/actions/approve-operational-fee-allowance.js.map +1 -0
- package/dist/symmio-contracts/symmio/actions/approve-operational-fee.d.ts +3 -0
- package/dist/symmio-contracts/symmio/actions/approve-operational-fee.d.ts.map +1 -1
- package/dist/symmio-contracts/symmio/actions/approve-operational-fee.js +32 -29
- package/dist/symmio-contracts/symmio/actions/approve-operational-fee.js.map +1 -1
- package/dist/symmio-contracts/symmio/actions/deallocate-and-initiate-withdraw.d.ts +3 -0
- package/dist/symmio-contracts/symmio/actions/deallocate-and-initiate-withdraw.d.ts.map +1 -1
- package/dist/symmio-contracts/symmio/actions/deallocate-and-initiate-withdraw.js +37 -28
- package/dist/symmio-contracts/symmio/actions/deallocate-and-initiate-withdraw.js.map +1 -1
- package/dist/symmio-contracts/symmio/actions/deallocate.d.ts +3 -0
- package/dist/symmio-contracts/symmio/actions/deallocate.d.ts.map +1 -1
- package/dist/symmio-contracts/symmio/actions/deallocate.js +30 -20
- package/dist/symmio-contracts/symmio/actions/deallocate.js.map +1 -1
- package/dist/symmio-contracts/symmio/actions/initiate-withdraw.d.ts +5 -0
- package/dist/symmio-contracts/symmio/actions/initiate-withdraw.d.ts.map +1 -1
- package/dist/symmio-contracts/symmio/actions/initiate-withdraw.js +31 -18
- package/dist/symmio-contracts/symmio/actions/initiate-withdraw.js.map +1 -1
- package/dist/symmio-contracts/symmio/actions/withdraw-auto.d.ts +4 -0
- package/dist/symmio-contracts/symmio/actions/withdraw-auto.d.ts.map +1 -1
- package/dist/symmio-contracts/symmio/actions/withdraw-auto.js +30 -25
- package/dist/symmio-contracts/symmio/actions/withdraw-auto.js.map +1 -1
- package/dist/symmio-contracts/symmio/actions/withdraw.d.ts +4 -0
- package/dist/symmio-contracts/symmio/actions/withdraw.d.ts.map +1 -1
- package/dist/symmio-contracts/symmio/actions/withdraw.js +12 -8
- package/dist/symmio-contracts/symmio/actions/withdraw.js.map +1 -1
- package/dist/symmio-contracts/symmio/execute-account-calls/execute-account-calls.d.ts +48 -0
- package/dist/symmio-contracts/symmio/execute-account-calls/execute-account-calls.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/execute-account-calls/execute-account-calls.js +33 -0
- package/dist/symmio-contracts/symmio/execute-account-calls/execute-account-calls.js.map +1 -0
- package/dist/symmio-contracts/symmio/execute-account-calls/index.d.ts +3 -0
- package/dist/symmio-contracts/symmio/execute-account-calls/index.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/execute-account-calls/query.d.ts +23 -0
- package/dist/symmio-contracts/symmio/execute-account-calls/query.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/execute-account-calls/query.js +12 -0
- package/dist/symmio-contracts/symmio/execute-account-calls/query.js.map +1 -0
- package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/get-deallocate-debounce-time.d.ts +22 -0
- package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/get-deallocate-debounce-time.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/get-deallocate-debounce-time.js +14 -0
- package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/get-deallocate-debounce-time.js.map +1 -0
- package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/index.d.ts +3 -0
- package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/index.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/query.d.ts +34 -0
- package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/query.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/query.js +21 -0
- package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/query.js.map +1 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/get-pending-withdraw-requests-batch.d.ts +34 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/get-pending-withdraw-requests-batch.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/get-pending-withdraw-requests-batch.js +35 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/get-pending-withdraw-requests-batch.js.map +1 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/index.d.ts +3 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/index.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/limit-concurrency.d.ts +15 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/limit-concurrency.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/limit-concurrency.js +20 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/limit-concurrency.js.map +1 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/query.d.ts +22 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/query.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/query.js +30 -0
- package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/query.js.map +1 -0
- package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/get-withdraw-cooldown-of.d.ts +30 -0
- package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/get-withdraw-cooldown-of.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/get-withdraw-cooldown-of.js +15 -0
- package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/get-withdraw-cooldown-of.js.map +1 -0
- package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/index.d.ts +3 -0
- package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/index.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/query.d.ts +38 -0
- package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/query.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/query.js +24 -0
- package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/query.js.map +1 -0
- package/dist/symmio-contracts/symmio/index.d.ts +6 -0
- package/dist/symmio-contracts/symmio/index.d.ts.map +1 -1
- package/dist/symmio-contracts/symmio/internal/call-as-sub-account.d.ts.map +1 -1
- package/dist/symmio-contracts/symmio/internal/call-as-sub-account.js +35 -34
- package/dist/symmio-contracts/symmio/internal/call-as-sub-account.js.map +1 -1
- package/dist/symmio-contracts/symmio/internal/resolve-default-operational-fee-charger.d.ts +18 -0
- package/dist/symmio-contracts/symmio/internal/resolve-default-operational-fee-charger.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/internal/resolve-default-operational-fee-charger.js +14 -0
- package/dist/symmio-contracts/symmio/internal/resolve-default-operational-fee-charger.js.map +1 -0
- package/dist/symmio-contracts/symmio/query/approve-operational-fee-allowance.d.ts +18 -0
- package/dist/symmio-contracts/symmio/query/approve-operational-fee-allowance.d.ts.map +1 -0
- package/dist/symmio-contracts/symmio/query/approve-operational-fee-allowance.js +12 -0
- package/dist/symmio-contracts/symmio/query/approve-operational-fee-allowance.js.map +1 -0
- package/dist/symmio-subgraph/executeSubgraphRequest.js +3 -3
- package/dist/timelock/approval.d.ts +142 -0
- package/dist/timelock/approval.d.ts.map +1 -0
- package/dist/timelock/approval.js +176 -0
- package/dist/timelock/approval.js.map +1 -0
- package/dist/timelock/attempt-outcome.d.ts +37 -0
- package/dist/timelock/attempt-outcome.d.ts.map +1 -0
- package/dist/timelock/attempt-outcome.js +70 -0
- package/dist/timelock/attempt-outcome.js.map +1 -0
- package/dist/timelock/confirm-write.d.ts +5 -0
- package/dist/timelock/confirm-write.d.ts.map +1 -0
- package/dist/timelock/confirm-write.js +18 -0
- package/dist/timelock/confirm-write.js.map +1 -0
- package/dist/timelock/early-withdraw/early-withdraw.d.ts +60 -0
- package/dist/timelock/early-withdraw/early-withdraw.d.ts.map +1 -0
- package/dist/timelock/early-withdraw/early-withdraw.js +94 -0
- package/dist/timelock/early-withdraw/early-withdraw.js.map +1 -0
- package/dist/timelock/early-withdraw/index.d.ts +2 -0
- package/dist/timelock/early-withdraw/index.d.ts.map +1 -0
- package/dist/timelock/errors.d.ts +23 -0
- package/dist/timelock/errors.d.ts.map +1 -0
- package/dist/timelock/errors.js +29 -0
- package/dist/timelock/errors.js.map +1 -0
- package/dist/timelock/execute-protected-batch.d.ts +31 -0
- package/dist/timelock/execute-protected-batch.d.ts.map +1 -0
- package/dist/timelock/execute-protected-batch.js +148 -0
- package/dist/timelock/execute-protected-batch.js.map +1 -0
- package/dist/timelock/execute-protected-call.d.ts +68 -0
- package/dist/timelock/execute-protected-call.d.ts.map +1 -0
- package/dist/timelock/execute-protected-call.js +146 -0
- package/dist/timelock/execute-protected-call.js.map +1 -0
- package/dist/timelock/execute-protected-function.d.ts +51 -0
- package/dist/timelock/execute-protected-function.d.ts.map +1 -0
- package/dist/timelock/execute-protected-function.js +37 -0
- package/dist/timelock/execute-protected-function.js.map +1 -0
- package/dist/timelock/get-timelock-policy/get-timelock-policy.d.ts +38 -0
- package/dist/timelock/get-timelock-policy/get-timelock-policy.d.ts.map +1 -0
- package/dist/timelock/get-timelock-policy/get-timelock-policy.js +49 -0
- package/dist/timelock/get-timelock-policy/get-timelock-policy.js.map +1 -0
- package/dist/timelock/get-timelock-policy/index.d.ts +3 -0
- package/dist/timelock/get-timelock-policy/index.d.ts.map +1 -0
- package/dist/timelock/get-timelock-policy/query.d.ts +13 -0
- package/dist/timelock/get-timelock-policy/query.d.ts.map +1 -0
- package/dist/timelock/get-timelock-policy/query.js +21 -0
- package/dist/timelock/get-timelock-policy/query.js.map +1 -0
- package/dist/timelock/index.d.ts +14 -0
- package/dist/timelock/index.d.ts.map +1 -0
- package/dist/timelock/normalize-timelock-revert.d.ts +3 -0
- package/dist/timelock/normalize-timelock-revert.d.ts.map +1 -0
- package/dist/timelock/normalize-timelock-revert.js +11 -0
- package/dist/timelock/normalize-timelock-revert.js.map +1 -0
- package/dist/timelock/policy-change.d.ts +72 -0
- package/dist/timelock/policy-change.d.ts.map +1 -0
- package/dist/timelock/policy-change.js +63 -0
- package/dist/timelock/policy-change.js.map +1 -0
- package/dist/timelock/policy.d.ts +19 -0
- package/dist/timelock/policy.d.ts.map +1 -0
- package/dist/timelock/policy.js +59 -0
- package/dist/timelock/policy.js.map +1 -0
- package/dist/timelock/protected-call-preflight.d.ts +10 -0
- package/dist/timelock/protected-call-preflight.d.ts.map +1 -0
- package/dist/timelock/protected-call-preflight.js +17 -0
- package/dist/timelock/protected-call-preflight.js.map +1 -0
- package/dist/timelock/root-account.d.ts +14 -0
- package/dist/timelock/root-account.d.ts.map +1 -0
- package/dist/timelock/root-account.js +9 -0
- package/dist/timelock/root-account.js.map +1 -0
- package/dist/timelock/scheduled-call-match.d.ts +4 -0
- package/dist/timelock/scheduled-call-match.d.ts.map +1 -0
- package/dist/timelock/scheduled-call-match.js +43 -0
- package/dist/timelock/scheduled-call-match.js.map +1 -0
- package/dist/timelock/setup-timelock-policy/index.d.ts +2 -0
- package/dist/timelock/setup-timelock-policy/index.d.ts.map +1 -0
- package/dist/timelock/setup-timelock-policy/setup-timelock-policy.d.ts +46 -0
- package/dist/timelock/setup-timelock-policy/setup-timelock-policy.d.ts.map +1 -0
- package/dist/timelock/setup-timelock-policy/setup-timelock-policy.js +58 -0
- package/dist/timelock/setup-timelock-policy/setup-timelock-policy.js.map +1 -0
- package/dist/timelock/support.d.ts +4 -0
- package/dist/timelock/support.d.ts.map +1 -0
- package/dist/timelock/support.js +9 -0
- package/dist/timelock/support.js.map +1 -0
- package/dist/transactions/execute-contract-write.d.ts +9 -0
- package/dist/transactions/execute-contract-write.d.ts.map +1 -0
- package/dist/transactions/execute-contract-write.js +35 -0
- package/dist/transactions/execute-contract-write.js.map +1 -0
- package/dist/transactions/execute-write.d.ts +32 -0
- package/dist/transactions/execute-write.d.ts.map +1 -0
- package/dist/transactions/execute-write.js +23 -0
- package/dist/transactions/execute-write.js.map +1 -0
- package/package.json +1 -1
|
@@ -42,23 +42,37 @@ function _(e, t, n) {
|
|
|
42
42
|
function v(e) {
|
|
43
43
|
return new Promise((t) => setTimeout(t, e));
|
|
44
44
|
}
|
|
45
|
-
function y(e) {
|
|
45
|
+
async function y(e, t, n, r) {
|
|
46
|
+
let i = e.getClient({ chainId: t });
|
|
47
|
+
for (;;) {
|
|
48
|
+
try {
|
|
49
|
+
return await i.getTransactionReceipt({ hash: n }), !0;
|
|
50
|
+
} catch {}
|
|
51
|
+
let e = r - Date.now();
|
|
52
|
+
if (e <= 0) return !1;
|
|
53
|
+
await v(Math.min(m, e));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function b(e) {
|
|
46
57
|
return t(e) !== null || i(e) || n(e);
|
|
47
58
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
59
|
+
function x(e, t, n, r, i) {
|
|
60
|
+
return S(e, [{
|
|
50
61
|
key: t,
|
|
51
62
|
signedNonce: n.signedNonce
|
|
52
63
|
}], n, r, i);
|
|
53
64
|
}
|
|
54
|
-
async function
|
|
65
|
+
async function S(e, t, n, r, i) {
|
|
55
66
|
let a = Number(n.deadline) * 1e3, o = (r) => {
|
|
56
67
|
for (let i of t) h(e).set(i.key, {
|
|
57
68
|
signedNonce: i.signedNonce,
|
|
58
|
-
requestId: r,
|
|
69
|
+
requestId: r?.requestId ?? null,
|
|
59
70
|
service: n.service,
|
|
60
71
|
chainId: n.chainId,
|
|
61
|
-
expiresAtMs: a
|
|
72
|
+
expiresAtMs: a,
|
|
73
|
+
idempotencyKey: n.idempotencyKey,
|
|
74
|
+
raisesFloor: !n.callerOwnedKey,
|
|
75
|
+
accepted: r
|
|
62
76
|
});
|
|
63
77
|
}, s;
|
|
64
78
|
try {
|
|
@@ -66,37 +80,50 @@ async function x(e, t, n, r, i) {
|
|
|
66
80
|
} catch (e) {
|
|
67
81
|
throw i(e) && o(null), e;
|
|
68
82
|
}
|
|
69
|
-
return o(s
|
|
83
|
+
return o(s), s;
|
|
84
|
+
}
|
|
85
|
+
function C(e, t, n) {
|
|
86
|
+
for (let r of t) {
|
|
87
|
+
let t = d.get(e)?.get(r);
|
|
88
|
+
if (t?.accepted && t.idempotencyKey === n) return t.accepted;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
70
91
|
}
|
|
71
|
-
async function
|
|
72
|
-
let
|
|
92
|
+
async function w(t, n, i, o) {
|
|
93
|
+
let s = async () => {
|
|
73
94
|
let e = await i(), r = f.get(t)?.get(n);
|
|
74
95
|
return r !== void 0 && r > e ? r : e;
|
|
75
|
-
},
|
|
76
|
-
if (!
|
|
77
|
-
let
|
|
78
|
-
if (
|
|
79
|
-
if (
|
|
80
|
-
let
|
|
96
|
+
}, c = await s(), l = h(t).get(n);
|
|
97
|
+
if (!l || o !== void 0 && l.idempotencyKey === o) return c;
|
|
98
|
+
let u = Math.min(l.expiresAtMs, Date.now() + p);
|
|
99
|
+
if (l.signedNonce <= c || u <= Date.now()) return g(t, n), c;
|
|
100
|
+
if (l.requestId !== null) {
|
|
101
|
+
let i = null;
|
|
81
102
|
try {
|
|
82
|
-
|
|
83
|
-
chainId:
|
|
84
|
-
requestId:
|
|
85
|
-
service:
|
|
103
|
+
i = await a(t, {
|
|
104
|
+
chainId: l.chainId,
|
|
105
|
+
requestId: l.requestId,
|
|
106
|
+
service: l.service,
|
|
86
107
|
until: "terminal",
|
|
87
|
-
timeoutMs:
|
|
108
|
+
timeoutMs: u - Date.now()
|
|
88
109
|
});
|
|
89
110
|
} catch {}
|
|
90
|
-
if (
|
|
111
|
+
if (i !== null) {
|
|
112
|
+
if (i.status === r.SUCCEEDED) {
|
|
113
|
+
if (l.raisesFloor) _(t, n, l.signedNonce);
|
|
114
|
+
else if (i.txHash !== null && !await y(t, l.chainId, i.txHash, u)) throw new e("api", "GASLESS_NONCE_STREAM_BUSY", `Gasless: request ${i.requestId} succeeded in transaction ${i.txHash}, but this RPC has not returned its receipt yet, so its nonce is stale. Signing now would reuse a spent nonce — retry once the RPC has caught up.`);
|
|
115
|
+
}
|
|
116
|
+
return g(t, n), await s();
|
|
117
|
+
}
|
|
91
118
|
}
|
|
92
|
-
for (; Date.now() <
|
|
119
|
+
for (; Date.now() < u;) {
|
|
93
120
|
await v(m);
|
|
94
|
-
let e = await
|
|
95
|
-
if (e >=
|
|
121
|
+
let e = await s();
|
|
122
|
+
if (e >= l.signedNonce) return g(t, n), e;
|
|
96
123
|
}
|
|
97
|
-
throw new e("api", "GASLESS_NONCE_STREAM_BUSY", `Gasless: nonce ${
|
|
124
|
+
throw new e("api", "GASLESS_NONCE_STREAM_BUSY", `Gasless: nonce ${l.signedNonce} was signed on this stream${l.requestId ? ` for request ${l.requestId}` : " for a submit that returned no trackable request id"} and has not landed yet. Signing now would collide with it — wait for that request to finish, or for its deadline to pass, before retrying.`);
|
|
98
125
|
}
|
|
99
126
|
//#endregion
|
|
100
|
-
export {
|
|
127
|
+
export { b as blocksGaslessNonceStream, s as gaslessInstantNonceStreamKey, c as gaslessWalletNonceStreamKey, C as getGaslessPendingAcceptance, w as readGaslessStreamNonce, x as submitOnGaslessNonceStream, S as submitOnGaslessNonceStreams, l as withGaslessNonceLock, u as withGaslessNonceLocks };
|
|
101
128
|
|
|
102
129
|
//# sourceMappingURL=nonce-lock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nonce-lock.js","names":[],"sources":["../../src/gasless/nonce-lock.ts"],"sourcesContent":["import type { Config } from \"../core/config\";\nimport { SymmError } from \"../shared/errors/symm-error\";\nimport { isGaslessAcceptedInstanceMismatchError } from \"./http\";\nimport { isGaslessAcceptanceInvalidError } from \"./to-gasless-submit-receipt\";\nimport { GaslessRequestStatus, type GaslessRequest, type GaslessService } from \"./types\";\nimport { getGaslessUnconfirmedSubmit } from \"./unconfirmed-submit\";\nimport { waitForGaslessRequest } from \"./wait-for-gasless-request/wait-for-gasless-request\";\n\n/**\n * Per-config serialization of gasless relays by **nonce stream**.\n *\n * Replay nonces are sequential and read fresh immediately before signing; two\n * concurrent relays built from the same read would sign the same nonce and one\n * would be rejected in simulation. This chains each stream's relays behind a\n * promise so the read-sign-submit critical section never overlaps. Keyed off\n * the `Config` object with a `WeakMap` so locks die with the config.\n *\n * @internal\n */\nconst locks = new WeakMap<Config, Map<string, Promise<unknown>>>();\n\n/**\n * The lock/stream key of an account's **InstantLayer** operation nonces, which\n * the contract counts per `signerAccount`.\n *\n * @param chainId - The chain the operation relays on.\n * @param signerAccount - The operation's `signerAccount.addr`.\n * @returns The stream key.\n *\n * @internal\n */\nexport function gaslessInstantNonceStreamKey(chainId: number, signerAccount: string): string {\n return `${chainId}:instant:${signerAccount.toLowerCase()}`;\n}\n\n/**\n * The lock/stream key of a **gasless-wallet operation** nonce stream.\n *\n * The two shapes mirror the contract's own storage. Wallet `0` counts in\n * `_legacyWalletOperationNonces[signerAccount]`, one stream per signer account\n * across every owner, so its key deliberately omits the owner — keying it by\n * owner would let two owners' relays sign the same legacy nonce. Every positive\n * id counts in `walletNonces[wallet][signerAccount]`, so its key carries both\n * the id and the owner that derives the wallet.\n *\n * @param chainId - The chain the operation relays on.\n * @param walletId - The selected wallet id.\n * @param owner - The wallet's owner.\n * @param signerAccount - The operation's `signerAccount.addr`.\n * @returns The stream key.\n *\n * @internal\n */\nexport function gaslessWalletNonceStreamKey(\n chainId: number,\n walletId: bigint,\n owner: string,\n signerAccount: string,\n): string {\n const signer = signerAccount.toLowerCase();\n return walletId === 0n\n ? `${chainId}:wallet:0:${signer}`\n : `${chainId}:wallet:${walletId}:${owner.toLowerCase()}:${signer}`;\n}\n\n/**\n * Run `task` exclusively for one nonce stream. Queued tasks run in FIFO order;\n * a failed task never blocks the next one, and the map entry is cleared once\n * the last queued task settles.\n *\n * @param config - The SDK config the locks belong to.\n * @param key - A stream key from {@link gaslessInstantNonceStreamKey} or {@link gaslessWalletNonceStreamKey}.\n * @param task - The read-sign-submit critical section.\n *\n * @internal\n */\nexport function withGaslessNonceLock<result>(\n config: Config,\n key: string,\n task: () => Promise<result>,\n): Promise<result> {\n return withGaslessNonceLocks(config, [key], task);\n}\n\n/**\n * Run `task` exclusively for **several** nonce streams at once — a batch that\n * signs on more than one stream (an account's InstantLayer stream plus one\n * stream per GaslessWallet id). The single-stream {@link withGaslessNonceLock}\n * is the one-key case.\n *\n * The task joins every stream's queue in the same synchronous step and starts\n * once all of their earlier tasks have settled. A task therefore only ever\n * waits on tasks queued before it, so two batches that share streams — in any\n * order — can never each hold one stream while waiting for the other's.\n *\n * @param config - The SDK config the locks belong to.\n * @param keys - The stream keys the task signs on; duplicates are ignored.\n * @param task - The read-sign-submit critical section.\n *\n * @internal\n */\nexport function withGaslessNonceLocks<result>(\n config: Config,\n keys: readonly string[],\n task: () => Promise<result>,\n): Promise<result> {\n let byKey = locks.get(config);\n if (!byKey) {\n byKey = new Map();\n locks.set(config, byKey);\n }\n const queues = byKey;\n const streams = [...new Set(keys)];\n\n const previous = Promise.all(streams.map((key) => queues.get(key) ?? Promise.resolve()));\n const run = previous.then(task, task);\n\n const settled = run.then(\n () => undefined,\n () => undefined,\n );\n for (const key of streams) queues.set(key, settled);\n void settled.then(() => {\n for (const key of streams) {\n if (queues.get(key) === settled) queues.delete(key);\n }\n });\n\n return run;\n}\n\n/**\n * A signature that left this SDK on one nonce stream and has not been seen\n * consumed on-chain yet.\n *\n * @internal\n */\ninterface GaslessPendingNonce {\n /** The highest nonce the submitted batch signed on this stream. */\n signedNonce: bigint;\n /** The accepted request's id, or `null` when the submit's outcome is unknown. */\n requestId: string | null;\n /** Which service stores the request. */\n service: GaslessService;\n /** The chain the request was submitted on. */\n chainId: number;\n /** When the signature expires (ms since epoch) — after that it can never land. */\n expiresAtMs: number;\n}\n\n/** The pending signature per stream, per config. @internal */\nconst pendingNonces = new WeakMap<Config, Map<string, GaslessPendingNonce>>();\n\n/**\n * The highest nonce a `succeeded` relay consumed, per stream, per config.\n *\n * `succeeded` is the relayer's node's view, and a public RPC can trail it by a\n * few blocks — long enough for the next write to read the old nonce and sign\n * it again. A consumed nonce stays consumed, so every read on the stream is\n * raised to this floor for as long as the config lives.\n *\n * @internal\n */\nconst consumedFloors = new WeakMap<Config, Map<string, bigint>>();\n\n/** How long a new caller may wait for a pending signature to resolve, whatever its deadline says. */\nconst GASLESS_NONCE_STREAM_WAIT_MS = 120_000;\n/** Cadence of the on-chain nonce re-read while waiting for an unconfirmed submit. */\nconst GASLESS_NONCE_STREAM_POLL_MS = 1_500;\n\nfunction pendingFor(config: Config): Map<string, GaslessPendingNonce> {\n let byKey = pendingNonces.get(config);\n if (!byKey) {\n byKey = new Map();\n pendingNonces.set(config, byKey);\n }\n return byKey;\n}\n\n/** Forget a stream's pending signature. @internal */\nexport function clearGaslessPendingNonce(config: Config, key: string): void {\n pendingNonces.get(config)?.delete(key);\n}\n\n/** Record that a stream has consumed at least `nonce`, whatever this config's RPC still reports. */\nfunction raiseConsumedFloor(config: Config, key: string, nonce: bigint): void {\n let byKey = consumedFloors.get(config);\n if (!byKey) {\n byKey = new Map();\n consumedFloors.set(config, byKey);\n }\n const floor = byKey.get(key);\n if (floor === undefined || nonce > floor) byKey.set(key, nonce);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Whether a thrown submit error leaves the stream's signed nonce **possibly or\n * certainly consumed**, so the next caller must wait for it instead of signing\n * it again.\n *\n * Three shapes qualify, and the submit path narrows every ambiguity down to\n * them before they get here:\n *\n * - `GASLESS_SUBMIT_UNCONFIRMED` — the transport failed ambiguously, or a\n * `202` carried no `request_id`. Either way the batch may be executing.\n * - `GASLESS_ACCEPTANCE_INVALID` — the parser's own guard for that second case;\n * acceptance is certain and only the handle was lost, which makes the nonce\n * more likely to be consumed, not less.\n * - A `2xx` from the wrong protocol instance — accepted somewhere, so the\n * signature must be treated as spent.\n *\n * Every other failure is a rejection that consumed nothing: the gateway refused\n * the request before the service saw it, or the service answered with a verdict.\n *\n * @param err - Anything caught from a gasless submit.\n * @returns `true` when the stream must stay blocked until the nonce moves or the signature expires.\n *\n * @internal\n */\nexport function blocksGaslessNonceStream(err: unknown): boolean {\n return (\n getGaslessUnconfirmedSubmit(err) !== null ||\n isGaslessAcceptanceInvalidError(err) ||\n isGaslessAcceptedInstanceMismatchError(err)\n );\n}\n\n/**\n * Submit a relay while keeping the stream's pending-signature record honest.\n *\n * The lock only spans the submit, so the nonce a released lock leaves behind is\n * still unconsumed on-chain for as long as the relayer takes to broadcast. This\n * records what was signed so the **next** caller on the stream can wait for it\n * instead of signing the same nonce again.\n *\n * A blocking failure records `requestId: null`: the batch may have been\n * accepted (an ambiguous transport failure) or is known to have been accepted\n * without a trackable id, so the stream stays blocked until the nonce is seen\n * consumed or the signature expires. A definitive rejection records nothing —\n * nothing was accepted, so the nonce is free immediately.\n *\n * @param config - The SDK config.\n * @param key - The stream key the submit was signed on.\n * @param pending - What was signed: the highest nonce, the service, the chain and the signature deadline (seconds).\n * @param submit - Performs the POST and returns the acceptance receipt.\n * @param blocksStream - Whether a thrown error leaves the signed nonce possibly or certainly consumed; pass {@link blocksGaslessNonceStream}.\n * @returns Whatever `submit` resolved with.\n *\n * @internal\n */\nexport function submitOnGaslessNonceStream<result extends { requestId: string }>(\n config: Config,\n key: string,\n pending: { signedNonce: bigint; service: GaslessService; chainId: number; deadline: bigint },\n submit: () => Promise<result>,\n blocksStream: (err: unknown) => boolean,\n): Promise<result> {\n return submitOnGaslessNonceStreams(\n config,\n [{ key, signedNonce: pending.signedNonce }],\n pending,\n submit,\n blocksStream,\n );\n}\n\n/**\n * {@link submitOnGaslessNonceStream} for a submit that signed on **several**\n * streams — one relay request carrying an InstantLayer operation and a\n * GaslessWallet operation, say. Every stream records the same request, because\n * one request consumes all of them or none; each keeps its own highest signed\n * nonce.\n *\n * @param config - The SDK config.\n * @param streams - Each stream the submit signed on, with the highest nonce it signed there.\n * @param pending - The service, the chain and the signature deadline (seconds), shared by every stream.\n * @param submit - Performs the POST and returns the acceptance receipt.\n * @param blocksStream - Whether a thrown error leaves the signed nonces possibly or certainly consumed; pass {@link blocksGaslessNonceStream}.\n * @returns Whatever `submit` resolved with.\n *\n * @internal\n */\nexport async function submitOnGaslessNonceStreams<result extends { requestId: string }>(\n config: Config,\n streams: readonly { key: string; signedNonce: bigint }[],\n pending: { service: GaslessService; chainId: number; deadline: bigint },\n submit: () => Promise<result>,\n blocksStream: (err: unknown) => boolean,\n): Promise<result> {\n const expiresAtMs = Number(pending.deadline) * 1_000;\n const record = (requestId: string | null) => {\n for (const stream of streams) {\n pendingFor(config).set(stream.key, {\n signedNonce: stream.signedNonce,\n requestId,\n service: pending.service,\n chainId: pending.chainId,\n expiresAtMs,\n });\n }\n };\n\n let receipt: result;\n try {\n receipt = await submit();\n } catch (err) {\n if (blocksStream(err)) record(null);\n throw err;\n }\n\n record(receipt.requestId);\n return receipt;\n}\n\n/**\n * Read a stream's consumed nonce, waiting first for anything this SDK already\n * signed on it and has not seen land.\n *\n * The relayer forwards signed nonces; it never reserves, replaces or repairs\n * them. So signing `consumed + 1` while an earlier signature for that same\n * nonce is still in flight guarantees that one of the two reverts. Rather than\n * hold the lock for the whole broadcast (which would stall every later write\n * behind a slow relay), the lock is released at the `202` and the wait happens\n * lazily here, only when a new caller actually needs the stream.\n *\n * Waiting ends as soon as the pending request reaches **any** terminal status —\n * a failed one frees the nonce, a successful one advances it — or as soon as\n * the nonce is observed to have moved past what was signed. The budget is\n * `min(signature deadline, 120 s)`: past the deadline the signature can never\n * land, so the nonce is free.\n *\n * A successful terminal advances the stream without waiting for this RPC to\n * see the block. `succeeded` is the relayer's node's view and a public RPC can\n * trail it, so the signed nonce becomes a floor under every later read on the\n * stream; the relayer simulates the next submit against its own node, which\n * already has the block.\n *\n * @param config - The SDK config.\n * @param key - The stream key.\n * @param readConsumedNonce - Reads the stream's consumed nonce on-chain.\n * @returns The consumed nonce to sign from (sign `+ 1n`).\n * @throws {SymmError} `GASLESS_NONCE_STREAM_BUSY` when the budget runs out with a signature\n * still unaccounted for — signing now would collide with it.\n *\n * @internal\n */\nexport async function readGaslessStreamNonce(\n config: Config,\n key: string,\n readConsumedNonce: () => Promise<bigint>,\n): Promise<bigint> {\n /** Every read is raised to the nonce a `succeeded` relay on this stream is known to have consumed. */\n const readFloored = async () => {\n const read = await readConsumedNonce();\n const floor = consumedFloors.get(config)?.get(key);\n return floor !== undefined && floor > read ? floor : read;\n };\n\n const consumed = await readFloored();\n const pending = pendingFor(config).get(key);\n if (!pending) return consumed;\n\n const budgetEndsAt = Math.min(pending.expiresAtMs, Date.now() + GASLESS_NONCE_STREAM_WAIT_MS);\n /** Already consumed, or expired past any chance of landing: the stream is free. */\n if (pending.signedNonce <= consumed || budgetEndsAt <= Date.now()) {\n clearGaslessPendingNonce(config, key);\n return consumed;\n }\n\n if (pending.requestId !== null) {\n let terminal: GaslessRequest | null = null;\n try {\n terminal = await waitForGaslessRequest(config, {\n chainId: pending.chainId,\n requestId: pending.requestId,\n service: pending.service,\n until: \"terminal\",\n timeoutMs: budgetEndsAt - Date.now(),\n });\n } catch {\n /**\n * The wait timed out or the status read kept failing. The signature is\n * still unaccounted for, so fall through to watching the nonce itself —\n * the one fact that settles it without the service.\n */\n }\n\n if (terminal !== null) {\n /**\n * `succeeded` proves every signed nonce consumed — a relay that fails any\n * operation reverts whole — even while this RPC still reports the old one.\n * Any other terminal frees the nonce: `reverted` and `rejected` consumed\n * nothing, and since two signatures on one nonce never both execute, even\n * a `failed` transaction that mines late costs one rejection, never a\n * double run.\n */\n if (terminal.status === GaslessRequestStatus.SUCCEEDED) raiseConsumedFloor(config, key, pending.signedNonce);\n clearGaslessPendingNonce(config, key);\n return await readFloored();\n }\n }\n\n while (Date.now() < budgetEndsAt) {\n await sleep(GASLESS_NONCE_STREAM_POLL_MS);\n const latest = await readFloored();\n if (latest >= pending.signedNonce) {\n clearGaslessPendingNonce(config, key);\n return latest;\n }\n }\n\n throw new SymmError(\n \"api\",\n \"GASLESS_NONCE_STREAM_BUSY\",\n `Gasless: nonce ${pending.signedNonce} was signed on this stream${pending.requestId ? ` for request ${pending.requestId}` : \" for a submit that returned no trackable request id\"} and has not landed yet. Signing now would collide with it — wait for that request to finish, or for its deadline to pass, before retrying.`,\n );\n}\n"],"mappings":";;;;;;;AAmBA,IAAM,oBAAQ,IAAI,QAA+C;AAYjE,SAAgB,EAA6B,GAAiB,GAA+B;CAC3F,OAAO,GAAG,EAAQ,WAAW,EAAc,YAAY;AACzD;AAoBA,SAAgB,EACd,GACA,GACA,GACA,GACQ;CACR,IAAM,IAAS,EAAc,YAAY;CACzC,OAAO,MAAa,KAChB,GAAG,EAAQ,YAAY,MACvB,GAAG,EAAQ,UAAU,EAAS,GAAG,EAAM,YAAY,EAAE,GAAG;AAC9D;AAaA,SAAgB,EACd,GACA,GACA,GACiB;CACjB,OAAO,EAAsB,GAAQ,CAAC,CAAG,GAAG,CAAI;AAClD;AAmBA,SAAgB,EACd,GACA,GACA,GACiB;CACjB,IAAI,IAAQ,EAAM,IAAI,CAAM;CAC5B,AAAK,MACH,oBAAQ,IAAI,IAAI,GAChB,EAAM,IAAI,GAAQ,CAAK;CAEzB,IAAM,IAAS,GACT,IAAU,CAAC,GAAG,IAA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WAAW,GAC3G,EAAyB,GAAQ,CAAG,GAC7B,MAAM,EAAY;CAE7B;CAEA,OAAO,KAAK,IAAI,IAAI,IAAc;EAChC,MAAM,EAAM,CAA4B;EACxC,IAAM,IAAS,MAAM,EAAY;EACjC,IAAI,KAAU,EAAQ,aAEpB,OADA,EAAyB,GAAQ,CAAG,GAC7B;CAEX;CAEA,MAAM,IAAI,EACR,OACA,6BACA,kBAAkB,EAAQ,YAAY,4BAA4B,EAAQ,YAAY,gBAAgB,EAAQ,cAAc,sDAAsD,4IACpL;AACF"}
|
|
1
|
+
{"version":3,"file":"nonce-lock.js","names":[],"sources":["../../src/gasless/nonce-lock.ts"],"sourcesContent":["import type { Hash } from \"viem\";\nimport type { Config } from \"../core/config\";\nimport { SymmError } from \"../shared/errors/symm-error\";\nimport { isGaslessAcceptedInstanceMismatchError } from \"./http\";\nimport { isGaslessAcceptanceInvalidError } from \"./to-gasless-submit-receipt\";\nimport { GaslessRequestStatus, type GaslessRequest, type GaslessService, type GaslessSubmitReceipt } from \"./types\";\nimport { getGaslessUnconfirmedSubmit } from \"./unconfirmed-submit\";\nimport { waitForGaslessRequest } from \"./wait-for-gasless-request/wait-for-gasless-request\";\n\n/**\n * Per-config serialization of gasless relays by **nonce stream**.\n *\n * Replay nonces are sequential and read fresh immediately before signing; two\n * concurrent relays built from the same read would sign the same nonce and one\n * would be rejected in simulation. This chains each stream's relays behind a\n * promise so the read-sign-submit critical section never overlaps. Keyed off\n * the `Config` object with a `WeakMap` so locks die with the config.\n *\n * @internal\n */\nconst locks = new WeakMap<Config, Map<string, Promise<unknown>>>();\n\n/**\n * The lock/stream key of an account's **InstantLayer** operation nonces, which\n * the contract counts per `signerAccount`.\n *\n * @param chainId - The chain the operation relays on.\n * @param signerAccount - The operation's `signerAccount.addr`.\n * @returns The stream key.\n *\n * @internal\n */\nexport function gaslessInstantNonceStreamKey(chainId: number, signerAccount: string): string {\n return `${chainId}:instant:${signerAccount.toLowerCase()}`;\n}\n\n/**\n * The lock/stream key of a **gasless-wallet operation** nonce stream.\n *\n * The two shapes mirror the contract's own storage. Wallet `0` counts in\n * `_legacyWalletOperationNonces[signerAccount]`, one stream per signer account\n * across every owner, so its key deliberately omits the owner — keying it by\n * owner would let two owners' relays sign the same legacy nonce. Every positive\n * id counts in `walletNonces[wallet][signerAccount]`, so its key carries both\n * the id and the owner that derives the wallet.\n *\n * @param chainId - The chain the operation relays on.\n * @param walletId - The selected wallet id.\n * @param owner - The wallet's owner.\n * @param signerAccount - The operation's `signerAccount.addr`.\n * @returns The stream key.\n *\n * @internal\n */\nexport function gaslessWalletNonceStreamKey(\n chainId: number,\n walletId: bigint,\n owner: string,\n signerAccount: string,\n): string {\n const signer = signerAccount.toLowerCase();\n return walletId === 0n\n ? `${chainId}:wallet:0:${signer}`\n : `${chainId}:wallet:${walletId}:${owner.toLowerCase()}:${signer}`;\n}\n\n/**\n * Run `task` exclusively for one nonce stream. Queued tasks run in FIFO order;\n * a failed task never blocks the next one, and the map entry is cleared once\n * the last queued task settles.\n *\n * @param config - The SDK config the locks belong to.\n * @param key - A stream key from {@link gaslessInstantNonceStreamKey} or {@link gaslessWalletNonceStreamKey}.\n * @param task - The read-sign-submit critical section.\n *\n * @internal\n */\nexport function withGaslessNonceLock<result>(\n config: Config,\n key: string,\n task: () => Promise<result>,\n): Promise<result> {\n return withGaslessNonceLocks(config, [key], task);\n}\n\n/**\n * Run `task` exclusively for **several** nonce streams at once — a batch that\n * signs on more than one stream (an account's InstantLayer stream plus one\n * stream per GaslessWallet id). The single-stream {@link withGaslessNonceLock}\n * is the one-key case.\n *\n * The task joins every stream's queue in the same synchronous step and starts\n * once all of their earlier tasks have settled. A task therefore only ever\n * waits on tasks queued before it, so two batches that share streams — in any\n * order — can never each hold one stream while waiting for the other's.\n *\n * @param config - The SDK config the locks belong to.\n * @param keys - The stream keys the task signs on; duplicates are ignored.\n * @param task - The read-sign-submit critical section.\n *\n * @internal\n */\nexport function withGaslessNonceLocks<result>(\n config: Config,\n keys: readonly string[],\n task: () => Promise<result>,\n): Promise<result> {\n let byKey = locks.get(config);\n if (!byKey) {\n byKey = new Map();\n locks.set(config, byKey);\n }\n const queues = byKey;\n const streams = [...new Set(keys)];\n\n const previous = Promise.all(streams.map((key) => queues.get(key) ?? Promise.resolve()));\n const run = previous.then(task, task);\n\n const settled = run.then(\n () => undefined,\n () => undefined,\n );\n for (const key of streams) queues.set(key, settled);\n void settled.then(() => {\n for (const key of streams) {\n if (queues.get(key) === settled) queues.delete(key);\n }\n });\n\n return run;\n}\n\n/**\n * A signature that left this SDK on one nonce stream and has not been seen\n * consumed on-chain yet.\n *\n * @internal\n */\ninterface GaslessPendingNonce {\n /** The highest nonce the submitted batch signed on this stream. */\n signedNonce: bigint;\n /** The accepted request's id, or `null` when the submit's outcome is unknown. */\n requestId: string | null;\n /** Which service stores the request. */\n service: GaslessService;\n /** The chain the request was submitted on. */\n chainId: number;\n /** When the signature expires (ms since epoch) — after that it can never land. */\n expiresAtMs: number;\n /** The idempotency key the submit was sent under. */\n idempotencyKey: string;\n /**\n * Whether a `succeeded` outcome may raise the stream's consumed-nonce floor.\n * `false` for a caller-owned key: the service may answer a repeat with the\n * earlier request under that key, whose nonce is not the one just signed.\n * The next read then waits for this RPC to see the transaction instead.\n */\n raisesFloor: boolean;\n /** The acceptance receipt, once the service accepted the submit. */\n accepted: GaslessSubmitReceipt | null;\n}\n\n/** The pending signature per stream, per config. @internal */\nconst pendingNonces = new WeakMap<Config, Map<string, GaslessPendingNonce>>();\n\n/**\n * The highest nonce a `succeeded` relay consumed, per stream, per config.\n *\n * `succeeded` is the relayer's node's view, and a public RPC can trail it by a\n * few blocks — long enough for the next write to read the old nonce and sign\n * it again. A consumed nonce stays consumed, so every read on the stream is\n * raised to this floor for as long as the config lives.\n *\n * @internal\n */\nconst consumedFloors = new WeakMap<Config, Map<string, bigint>>();\n\n/** How long a new caller may wait for a pending signature to resolve, whatever its deadline says. */\nconst GASLESS_NONCE_STREAM_WAIT_MS = 120_000;\n/** Cadence of the on-chain nonce re-read while waiting for an unconfirmed submit. */\nconst GASLESS_NONCE_STREAM_POLL_MS = 1_500;\n\nfunction pendingFor(config: Config): Map<string, GaslessPendingNonce> {\n let byKey = pendingNonces.get(config);\n if (!byKey) {\n byKey = new Map();\n pendingNonces.set(config, byKey);\n }\n return byKey;\n}\n\n/** Forget a stream's pending signature. @internal */\nexport function clearGaslessPendingNonce(config: Config, key: string): void {\n pendingNonces.get(config)?.delete(key);\n}\n\n/** Record that a stream has consumed at least `nonce`, whatever this config's RPC still reports. */\nfunction raiseConsumedFloor(config: Config, key: string, nonce: bigint): void {\n let byKey = consumedFloors.get(config);\n if (!byKey) {\n byKey = new Map();\n consumedFloors.set(config, byKey);\n }\n const floor = byKey.get(key);\n if (floor === undefined || nonce > floor) byKey.set(key, nonce);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Wait until this config's RPC returns the receipt of a transaction the\n * relayer reported `succeeded`, so a nonce read after it reflects that block.\n * A failed receipt read counts as \"not yet\": the RPC is either behind or\n * briefly unreachable, and both are settled by looking again.\n *\n * @param config - The SDK config.\n * @param chainId - The chain the transaction mined on.\n * @param hash - The successful transaction.\n * @param budgetEndsAt - When to stop looking (ms since epoch).\n * @returns `true` once the receipt is visible, `false` when the budget ends first.\n */\nasync function waitForReceiptOnRpc(\n config: Config,\n chainId: number,\n hash: Hash,\n budgetEndsAt: number,\n): Promise<boolean> {\n const client = config.getClient({ chainId });\n for (;;) {\n try {\n await client.getTransactionReceipt({ hash });\n return true;\n } catch {\n /** Not visible on this RPC yet; poll again while the budget lasts. */\n }\n const remainingMs = budgetEndsAt - Date.now();\n if (remainingMs <= 0) return false;\n await sleep(Math.min(GASLESS_NONCE_STREAM_POLL_MS, remainingMs));\n }\n}\n\n/**\n * Whether a thrown submit error leaves the stream's signed nonce **possibly or\n * certainly consumed**, so the next caller must wait for it instead of signing\n * it again.\n *\n * Three shapes qualify, and the submit path narrows every ambiguity down to\n * them before they get here:\n *\n * - `GASLESS_SUBMIT_UNCONFIRMED` — the transport failed ambiguously, or a\n * `202` carried no `request_id`. Either way the batch may be executing.\n * - `GASLESS_ACCEPTANCE_INVALID` — the parser's own guard for that second case;\n * acceptance is certain and only the handle was lost, which makes the nonce\n * more likely to be consumed, not less.\n * - A `2xx` from the wrong protocol instance — accepted somewhere, so the\n * signature must be treated as spent.\n *\n * Every other failure is a rejection that consumed nothing: the gateway refused\n * the request before the service saw it, or the service answered with a verdict.\n *\n * @param err - Anything caught from a gasless submit.\n * @returns `true` when the stream must stay blocked until the nonce moves or the signature expires.\n *\n * @internal\n */\nexport function blocksGaslessNonceStream(err: unknown): boolean {\n return (\n getGaslessUnconfirmedSubmit(err) !== null ||\n isGaslessAcceptanceInvalidError(err) ||\n isGaslessAcceptedInstanceMismatchError(err)\n );\n}\n\n/**\n * Submit a relay while keeping the stream's pending-signature record honest.\n *\n * The lock only spans the submit, so the nonce a released lock leaves behind is\n * still unconsumed on-chain for as long as the relayer takes to broadcast. This\n * records what was signed so the **next** caller on the stream can wait for it\n * instead of signing the same nonce again.\n *\n * A blocking failure records `requestId: null`: the batch may have been\n * accepted (an ambiguous transport failure) or is known to have been accepted\n * without a trackable id, so the stream stays blocked until the nonce is seen\n * consumed or the signature expires. A definitive rejection records nothing —\n * nothing was accepted, so the nonce is free immediately.\n *\n * Every record carries the submit's idempotency key, so a later attempt under\n * the same key can recognize its own earlier submit (see\n * {@link readGaslessStreamNonce} and {@link getGaslessPendingAcceptance}).\n *\n * @param config - The SDK config.\n * @param key - The stream key the submit was signed on.\n * @param pending - What was signed: the highest nonce, the service, the chain, the signature deadline (seconds),\n * the idempotency key, and whether that key is the caller's own.\n * @param submit - Performs the POST and returns the acceptance receipt.\n * @param blocksStream - Whether a thrown error leaves the signed nonce possibly or certainly consumed; pass {@link blocksGaslessNonceStream}.\n * @returns Whatever `submit` resolved with.\n *\n * @internal\n */\nexport function submitOnGaslessNonceStream<result extends GaslessSubmitReceipt>(\n config: Config,\n key: string,\n pending: GaslessStreamSubmit & { signedNonce: bigint },\n submit: () => Promise<result>,\n blocksStream: (err: unknown) => boolean,\n): Promise<result> {\n return submitOnGaslessNonceStreams(\n config,\n [{ key, signedNonce: pending.signedNonce }],\n pending,\n submit,\n blocksStream,\n );\n}\n\n/**\n * {@link submitOnGaslessNonceStream} for a submit that signed on **several**\n * streams — one relay request carrying an InstantLayer operation and a\n * GaslessWallet operation, say. Every stream records the same request, because\n * one request consumes all of them or none; each keeps its own highest signed\n * nonce.\n *\n * @param config - The SDK config.\n * @param streams - Each stream the submit signed on, with the highest nonce it signed there.\n * @param pending - The service, the chain, the signature deadline (seconds), the idempotency key and whether that\n * key is the caller's own, shared by every stream.\n * @param submit - Performs the POST and returns the acceptance receipt.\n * @param blocksStream - Whether a thrown error leaves the signed nonces possibly or certainly consumed; pass {@link blocksGaslessNonceStream}.\n * @returns Whatever `submit` resolved with.\n *\n * @internal\n */\nexport async function submitOnGaslessNonceStreams<result extends GaslessSubmitReceipt>(\n config: Config,\n streams: readonly { key: string; signedNonce: bigint }[],\n pending: GaslessStreamSubmit,\n submit: () => Promise<result>,\n blocksStream: (err: unknown) => boolean,\n): Promise<result> {\n const expiresAtMs = Number(pending.deadline) * 1_000;\n const record = (accepted: result | null) => {\n for (const stream of streams) {\n pendingFor(config).set(stream.key, {\n signedNonce: stream.signedNonce,\n requestId: accepted?.requestId ?? null,\n service: pending.service,\n chainId: pending.chainId,\n expiresAtMs,\n idempotencyKey: pending.idempotencyKey,\n raisesFloor: !pending.callerOwnedKey,\n accepted,\n });\n }\n };\n\n let receipt: result;\n try {\n receipt = await submit();\n } catch (err) {\n if (blocksStream(err)) record(null);\n throw err;\n }\n\n record(receipt);\n return receipt;\n}\n\n/**\n * What every stream a submit signed on records about it.\n *\n * @internal\n */\nexport interface GaslessStreamSubmit {\n /** Which service stores the request. */\n service: GaslessService;\n /** The chain the request is submitted on. */\n chainId: number;\n /** The signature deadline, in seconds. */\n deadline: bigint;\n /** The idempotency key the submit is sent under. */\n idempotencyKey: string;\n /** Whether the key is the caller's own (`gasless.idempotencyKey`) rather than one the SDK generated. */\n callerOwnedKey: boolean;\n}\n\n/**\n * The acceptance of an earlier submit under the same caller-owned key, on any\n * of the given streams. An attempt that finds one returns it instead of\n * signing again: the service already holds a request for that key, and this\n * config saw it accepted.\n *\n * @param config - The SDK config.\n * @param keys - The stream keys the attempt would sign on.\n * @param idempotencyKey - The attempt's caller-owned key.\n * @returns The earlier acceptance receipt, or `null`.\n *\n * @internal\n */\nexport function getGaslessPendingAcceptance(\n config: Config,\n keys: readonly string[],\n idempotencyKey: string,\n): GaslessSubmitReceipt | null {\n for (const key of keys) {\n const entry = pendingNonces.get(config)?.get(key);\n if (entry?.accepted && entry.idempotencyKey === idempotencyKey) return entry.accepted;\n }\n return null;\n}\n\n/**\n * Read a stream's consumed nonce, waiting first for anything this SDK already\n * signed on it and has not seen land.\n *\n * The relayer forwards signed nonces; it never reserves, replaces or repairs\n * them. So signing `consumed + 1` while an earlier signature for that same\n * nonce is still in flight guarantees that one of the two reverts. Rather than\n * hold the lock for the whole broadcast (which would stall every later write\n * behind a slow relay), the lock is released at the `202` and the wait happens\n * lazily here, only when a new caller actually needs the stream.\n *\n * Waiting ends as soon as the pending request reaches **any** terminal status —\n * a failed one frees the nonce, a successful one advances it — or as soon as\n * the nonce is observed to have moved past what was signed. The budget is\n * `min(signature deadline, 120 s)`: past the deadline the signature can never\n * land, so the nonce is free.\n *\n * A successful terminal advances the stream without waiting for this RPC to\n * see the block. `succeeded` is the relayer's node's view and a public RPC can\n * trail it, so the signed nonce becomes a floor under every later read on the\n * stream; the relayer simulates the next submit against its own node, which\n * already has the block. A submit under a caller-owned key never raises that\n * floor: the service may have answered it with an earlier request under the\n * key, whose nonce is not the one recorded here. Its success instead makes the\n * read wait until this RPC returns the successful transaction's receipt, so the\n * nonce it reads includes that block; when the budget runs out first, the read\n * throws rather than return a nonce it knows may be spent.\n *\n * An attempt under the **same** caller-owned key as the pending submit does not\n * wait for it. Both carry one key, and the service accepts a key at most once,\n * so the retry signs from the consumed nonce and lets the service settle which\n * of the two stands. Different keys — different actions — still wait.\n *\n * @param config - The SDK config.\n * @param key - The stream key.\n * @param readConsumedNonce - Reads the stream's consumed nonce on-chain.\n * @param idempotencyKey - The attempt's caller-owned idempotency key, when it has one.\n * @returns The consumed nonce to sign from (sign `+ 1n`).\n * @throws {SymmError} `GASLESS_NONCE_STREAM_BUSY` when the budget runs out with a signature\n * still unaccounted for — signing now would collide with it — or before this RPC has seen a\n * caller-keyed success, whose spent nonce it would still report as free.\n *\n * @internal\n */\nexport async function readGaslessStreamNonce(\n config: Config,\n key: string,\n readConsumedNonce: () => Promise<bigint>,\n idempotencyKey?: string,\n): Promise<bigint> {\n /** Every read is raised to the nonce a `succeeded` relay on this stream is known to have consumed. */\n const readFloored = async () => {\n const read = await readConsumedNonce();\n const floor = consumedFloors.get(config)?.get(key);\n return floor !== undefined && floor > read ? floor : read;\n };\n\n const consumed = await readFloored();\n const pending = pendingFor(config).get(key);\n if (!pending) return consumed;\n\n /** A retry of the same action: the service, not this stream, decides which attempt stands. */\n if (idempotencyKey !== undefined && pending.idempotencyKey === idempotencyKey) return consumed;\n\n const budgetEndsAt = Math.min(pending.expiresAtMs, Date.now() + GASLESS_NONCE_STREAM_WAIT_MS);\n /** Already consumed, or expired past any chance of landing: the stream is free. */\n if (pending.signedNonce <= consumed || budgetEndsAt <= Date.now()) {\n clearGaslessPendingNonce(config, key);\n return consumed;\n }\n\n if (pending.requestId !== null) {\n let terminal: GaslessRequest | null = null;\n try {\n terminal = await waitForGaslessRequest(config, {\n chainId: pending.chainId,\n requestId: pending.requestId,\n service: pending.service,\n until: \"terminal\",\n timeoutMs: budgetEndsAt - Date.now(),\n });\n } catch {\n /**\n * The wait timed out or the status read kept failing. The signature is\n * still unaccounted for, so fall through to watching the nonce itself —\n * the one fact that settles it without the service.\n */\n }\n\n if (terminal !== null) {\n /**\n * `succeeded` proves every signed nonce consumed — a relay that fails any\n * operation reverts whole — even while this RPC still reports the old one.\n * Any other terminal frees the nonce: `reverted` and `rejected` consumed\n * nothing, and since two signatures on one nonce never both execute, even\n * a `failed` transaction that mines late costs one rejection, never a\n * double run.\n */\n if (terminal.status === GaslessRequestStatus.SUCCEEDED) {\n if (pending.raisesFloor) {\n raiseConsumedFloor(config, key, pending.signedNonce);\n } else if (\n terminal.txHash !== null &&\n !(await waitForReceiptOnRpc(config, pending.chainId, terminal.txHash, budgetEndsAt))\n ) {\n /** The record stays, so the next caller waits for the receipt too instead of signing a spent nonce. */\n throw new SymmError(\n \"api\",\n \"GASLESS_NONCE_STREAM_BUSY\",\n `Gasless: request ${terminal.requestId} succeeded in transaction ${terminal.txHash}, but this RPC has not returned its receipt yet, so its nonce is stale. Signing now would reuse a spent nonce — retry once the RPC has caught up.`,\n );\n }\n }\n clearGaslessPendingNonce(config, key);\n return await readFloored();\n }\n }\n\n while (Date.now() < budgetEndsAt) {\n await sleep(GASLESS_NONCE_STREAM_POLL_MS);\n const latest = await readFloored();\n if (latest >= pending.signedNonce) {\n clearGaslessPendingNonce(config, key);\n return latest;\n }\n }\n\n throw new SymmError(\n \"api\",\n \"GASLESS_NONCE_STREAM_BUSY\",\n `Gasless: nonce ${pending.signedNonce} was signed on this stream${pending.requestId ? ` for request ${pending.requestId}` : \" for a submit that returned no trackable request id\"} and has not landed yet. Signing now would collide with it — wait for that request to finish, or for its deadline to pass, before retrying.`,\n );\n}\n"],"mappings":";;;;;;;AAoBA,IAAM,oBAAQ,IAAI,QAA+C;AAYjE,SAAgB,EAA6B,GAAiB,GAA+B;CAC3F,OAAO,GAAG,EAAQ,WAAW,EAAc,YAAY;AACzD;AAoBA,SAAgB,EACd,GACA,GACA,GACA,GACQ;CACR,IAAM,IAAS,EAAc,YAAY;CACzC,OAAO,MAAa,KAChB,GAAG,EAAQ,YAAY,MACvB,GAAG,EAAQ,UAAU,EAAS,GAAG,EAAM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AChC,MAAM,EAAM,CAA4B;EACxC,IAAM,IAAS,MAAM,EAAY;EACjC,IAAI,KAAU,EAAQ,aAEpB,OADA,EAAyB,GAAQ,CAAG,GAC7B;CAEX;CAEA,MAAM,IAAI,EACR,OACA,6BACA,kBAAkB,EAAQ,YAAY,4BAA4B,EAAQ,YAAY,gBAAgB,EAAQ,cAAc,sDAAsD,4IACpL;AACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { Config } from '../../core/config/index.js';
|
|
3
|
+
import { ResolvedGaslessBatchEntry } from '../batch/resolve-gasless-batch.js';
|
|
4
|
+
import { GaslessWalletIdentities } from '../resolve-wallet-identities.js';
|
|
5
|
+
/**
|
|
6
|
+
* Check each entry against the authority available at its execution position.
|
|
7
|
+
* Valid owner grants extend authority only for subsequent entries. On-chain
|
|
8
|
+
* delegation reads are deduplicated by signer and selector; the owner and
|
|
9
|
+
* canonical-account reads are cached per config, so a repeat batch on the same
|
|
10
|
+
* account adds none.
|
|
11
|
+
*
|
|
12
|
+
* An account the AccountLayer knows no owner for — not created yet, deleted, or
|
|
13
|
+
* on another chain — skips the instant-entry checks: every signer would look
|
|
14
|
+
* like a delegate, so the contract's own error is the accurate one. Wallet
|
|
15
|
+
* entries are still checked against the wallet owner, which a bare EOA has.
|
|
16
|
+
*
|
|
17
|
+
* @param config - The SDK config.
|
|
18
|
+
* @param parameters - Chain, operation account, aligned entries/signers, and any resolved wallet identities.
|
|
19
|
+
* @returns The account's AccountLayer owner, or `null` when it has none. Never the GaslessWallet bare-account fallback.
|
|
20
|
+
* @throws {SymmError} For an invalid grant or missing delegation, before signing.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function preflightBatchDelegations(config: Config, parameters: {
|
|
24
|
+
chainId: number;
|
|
25
|
+
account: Address;
|
|
26
|
+
entries: readonly ResolvedGaslessBatchEntry[];
|
|
27
|
+
entrySigners: readonly Address[];
|
|
28
|
+
identities: GaslessWalletIdentities | null;
|
|
29
|
+
}): Promise<Address | null>;
|
|
30
|
+
//# sourceMappingURL=preflight-batch-delegations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight-batch-delegations.d.ts","sourceRoot":"","sources":["../../../src/gasless/relay-gasless-batch/preflight-batch-delegations.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0D,KAAK,OAAO,EAAY,MAAM,MAAM,CAAC;AACtG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIhD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAIhF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAS5E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,SAAS,yBAAyB,EAAE,CAAC;IAC9C,YAAY,EAAE,SAAS,OAAO,EAAE,CAAC;IACjC,UAAU,EAAE,uBAAuB,GAAG,IAAI,CAAC;CAC5C,GACA,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAuFzB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { instantLayerAbi as e } from "../../symmio-contracts/abi/v0.8.6/instant-layer.js";
|
|
2
|
+
import { SymmError as t } from "../../shared/errors/symm-error.js";
|
|
3
|
+
import { getIsDelegationActive as n } from "../../symmio-contracts/instant-layer/actions/get-is-delegation-active.js";
|
|
4
|
+
import { getCachedDelegatorAccount as r, getCachedGaslessAccountOwner as i } from "../delegation-preflight.js";
|
|
5
|
+
import { getEffectiveInstantSelectors as a } from "../effective-instant-selectors.js";
|
|
6
|
+
import { getGaslessWalletExecuteSelectors as o } from "../gasless-wallet-execute/selectors.js";
|
|
7
|
+
import { decodeFunctionData as s, isAddressEqual as c, toFunctionSelector as l } from "viem";
|
|
8
|
+
//#region src/gasless/relay-gasless-batch/preflight-batch-delegations.ts
|
|
9
|
+
var u = new Set(e.filter((e) => e.type === "function" && (e.name === "grantDelegation" || e.name === "grantDelegations")).map((e) => l(e).toLowerCase()));
|
|
10
|
+
async function d(l, d) {
|
|
11
|
+
let { chainId: p, account: m, entries: h, entrySigners: g, identities: _ } = d, v = l.getClient({ chainId: p }), y = _?.canonicalAccount ?? await r(l, p, m), b = await i(l, p, y), x = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map(), C;
|
|
12
|
+
for (let [t, n] of h.entries()) {
|
|
13
|
+
let r = g[t];
|
|
14
|
+
if (n.type === "instant" && u.has(n.selector)) {
|
|
15
|
+
if (b === null) throw f(t, `${m} has no AccountLayer owner to sign it`);
|
|
16
|
+
if (!c(r, b)) throw f(t, "only the account owner can sign a grant");
|
|
17
|
+
let i = s({
|
|
18
|
+
abi: e,
|
|
19
|
+
data: n.callData
|
|
20
|
+
}), a = i.functionName === "grantDelegation" ? [i.args[0]] : i.functionName === "grantDelegations" ? i.args[0] : [];
|
|
21
|
+
if (a.length === 0) throw f(t, "a grant must contain at least one delegation");
|
|
22
|
+
C ??= (await v.getBlock({ blockTag: "latest" })).timestamp;
|
|
23
|
+
for (let e of a) {
|
|
24
|
+
if (!c(e.account.addr, m) || e.account.isPartyB) throw f(t, "every delegation must name the operation's PartyA account");
|
|
25
|
+
if (c(e.delegatedSigner, b)) throw f(t, "the owner cannot delegate to itself");
|
|
26
|
+
if (e.expiryTimestamp <= C) throw f(t, "delegation expiry must be later than the latest block timestamp");
|
|
27
|
+
if (e.selectors.length === 0) throw f(t, "a delegation must contain at least one selector");
|
|
28
|
+
let n = e.delegatedSigner.toLowerCase(), r = x.get(n) ?? /* @__PURE__ */ new Set();
|
|
29
|
+
for (let t of e.selectors) r.add(t.toLowerCase());
|
|
30
|
+
x.set(n, r);
|
|
31
|
+
}
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
let i = n.type === "wallet" ? _.ownerWallet : b;
|
|
35
|
+
if (i === null || c(r, i)) continue;
|
|
36
|
+
let l = n.type === "wallet" ? o(n.walletCalls) : a(n.callData), d = r.toLowerCase(), p = S.get(d) ?? {
|
|
37
|
+
signer: r,
|
|
38
|
+
selectors: /* @__PURE__ */ new Set()
|
|
39
|
+
};
|
|
40
|
+
for (let e of l) {
|
|
41
|
+
let t = e.toLowerCase();
|
|
42
|
+
x.get(d)?.has(t) || p.selectors.add(t);
|
|
43
|
+
}
|
|
44
|
+
p.selectors.size > 0 && S.set(d, p);
|
|
45
|
+
}
|
|
46
|
+
let w = (await Promise.all([...S.values()].map(async ({ signer: e, selectors: t }) => ({
|
|
47
|
+
signer: e,
|
|
48
|
+
selectors: (await Promise.all([...t].map(async (t) => ({
|
|
49
|
+
selector: t,
|
|
50
|
+
active: await n(l, {
|
|
51
|
+
chainId: p,
|
|
52
|
+
account: y,
|
|
53
|
+
delegate: e,
|
|
54
|
+
selector: t
|
|
55
|
+
})
|
|
56
|
+
})))).filter((e) => !e.active).map((e) => e.selector)
|
|
57
|
+
})))).filter((e) => e.selectors.length > 0);
|
|
58
|
+
if (w.length > 0) throw new t("validation", "GASLESS_SIGNER_NOT_DELEGATED", `Gasless: ${w.map((e) => `signer ${e.signer} holds no active InstantLayer delegation from ${y} for selector(s) ${e.selectors.join(", ")}`).join("; ")}. Grant getGaslessBatchSelectors(delegateCalls) for only the calls each delegate signs on ${y}, or sign those entries with the account's owner.`);
|
|
59
|
+
return b;
|
|
60
|
+
}
|
|
61
|
+
function f(e, n) {
|
|
62
|
+
return new t("validation", "GASLESS_INVALID_DELEGATION_GRANT", `Gasless: calls[${e}] is an invalid delegation grant: ${n}.`);
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { d as preflightBatchDelegations };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=preflight-batch-delegations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight-batch-delegations.js","names":[],"sources":["../../../src/gasless/relay-gasless-batch/preflight-batch-delegations.ts"],"sourcesContent":["import { decodeFunctionData, isAddressEqual, toFunctionSelector, type Address, type Hex } from \"viem\";\nimport type { Config } from \"../../core/config\";\nimport { SymmError } from \"../../shared/errors/symm-error\";\nimport { instantLayerAbi } from \"../../symmio-contracts/abi/v0.8.6/instant-layer\";\nimport { getIsDelegationActive } from \"../../symmio-contracts/instant-layer/actions/get-is-delegation-active\";\nimport type { ResolvedGaslessBatchEntry } from \"../batch/resolve-gasless-batch\";\nimport { getCachedDelegatorAccount, getCachedGaslessAccountOwner } from \"../delegation-preflight\";\nimport { getEffectiveInstantSelectors } from \"../effective-instant-selectors\";\nimport { getGaslessWalletExecuteSelectors } from \"../gasless-wallet-execute/selectors\";\nimport type { GaslessWalletIdentities } from \"../resolve-wallet-identities\";\n\n/** Grant operations are owner-only even if a delegate holds their selectors. */\nconst GRANT_SELECTORS: ReadonlySet<Hex> = new Set(\n instantLayerAbi\n .filter((item) => item.type === \"function\" && (item.name === \"grantDelegation\" || item.name === \"grantDelegations\"))\n .map((item) => toFunctionSelector(item).toLowerCase() as Hex),\n);\n\n/**\n * Check each entry against the authority available at its execution position.\n * Valid owner grants extend authority only for subsequent entries. On-chain\n * delegation reads are deduplicated by signer and selector; the owner and\n * canonical-account reads are cached per config, so a repeat batch on the same\n * account adds none.\n *\n * An account the AccountLayer knows no owner for — not created yet, deleted, or\n * on another chain — skips the instant-entry checks: every signer would look\n * like a delegate, so the contract's own error is the accurate one. Wallet\n * entries are still checked against the wallet owner, which a bare EOA has.\n *\n * @param config - The SDK config.\n * @param parameters - Chain, operation account, aligned entries/signers, and any resolved wallet identities.\n * @returns The account's AccountLayer owner, or `null` when it has none. Never the GaslessWallet bare-account fallback.\n * @throws {SymmError} For an invalid grant or missing delegation, before signing.\n * @internal\n */\nexport async function preflightBatchDelegations(\n config: Config,\n parameters: {\n chainId: number;\n account: Address;\n entries: readonly ResolvedGaslessBatchEntry[];\n entrySigners: readonly Address[];\n identities: GaslessWalletIdentities | null;\n },\n): Promise<Address | null> {\n const { chainId, account, entries, entrySigners, identities } = parameters;\n const client = config.getClient({ chainId });\n /** A live virtual account's owner is its parent's, so the owner is read on the canonical account. */\n const canonicalAccount = identities?.canonicalAccount ?? (await getCachedDelegatorAccount(config, chainId, account));\n const owner = await getCachedGaslessAccountOwner(config, chainId, canonicalAccount);\n const granted = new Map<string, Set<Hex>>();\n const required = new Map<string, { signer: Address; selectors: Set<Hex> }>();\n let blockTimestamp: bigint | undefined;\n\n for (const [index, entry] of entries.entries()) {\n const signer = entrySigners[index]!;\n if (entry.type === \"instant\" && GRANT_SELECTORS.has(entry.selector)) {\n if (owner === null) throw invalidGrant(index, `${account} has no AccountLayer owner to sign it`);\n if (!isAddressEqual(signer, owner)) throw invalidGrant(index, \"only the account owner can sign a grant\");\n const decoded = decodeFunctionData({ abi: instantLayerAbi, data: entry.callData });\n const infos =\n decoded.functionName === \"grantDelegation\"\n ? [decoded.args[0]]\n : decoded.functionName === \"grantDelegations\"\n ? decoded.args[0]\n : [];\n if (infos.length === 0) throw invalidGrant(index, \"a grant must contain at least one delegation\");\n blockTimestamp ??= (await client.getBlock({ blockTag: \"latest\" })).timestamp;\n\n for (const info of infos) {\n if (!isAddressEqual(info.account.addr, account) || info.account.isPartyB)\n throw invalidGrant(index, \"every delegation must name the operation's PartyA account\");\n if (isAddressEqual(info.delegatedSigner, owner))\n throw invalidGrant(index, \"the owner cannot delegate to itself\");\n if (info.expiryTimestamp <= blockTimestamp)\n throw invalidGrant(index, \"delegation expiry must be later than the latest block timestamp\");\n if (info.selectors.length === 0) throw invalidGrant(index, \"a delegation must contain at least one selector\");\n const key = info.delegatedSigner.toLowerCase();\n const selectors = granted.get(key) ?? new Set<Hex>();\n for (const selector of info.selectors) selectors.add(selector.toLowerCase() as Hex);\n granted.set(key, selectors);\n }\n continue;\n }\n\n const entryOwner = entry.type === \"wallet\" ? identities!.ownerWallet : owner;\n if (entryOwner === null || isAddressEqual(signer, entryOwner)) continue;\n const selectors =\n entry.type === \"wallet\"\n ? getGaslessWalletExecuteSelectors(entry.walletCalls)\n : getEffectiveInstantSelectors(entry.callData);\n const key = signer.toLowerCase();\n const group = required.get(key) ?? { signer, selectors: new Set<Hex>() };\n for (const selector of selectors) {\n const normalized = selector.toLowerCase() as Hex;\n if (!granted.get(key)?.has(normalized)) group.selectors.add(normalized);\n }\n if (group.selectors.size > 0) required.set(key, group);\n }\n\n const missing = await Promise.all(\n [...required.values()].map(async ({ signer, selectors }) => {\n const checks = await Promise.all(\n [...selectors].map(async (selector) => ({\n selector,\n active: await getIsDelegationActive(config, {\n chainId,\n account: canonicalAccount,\n delegate: signer,\n selector,\n }),\n })),\n );\n return { signer, selectors: checks.filter((check) => !check.active).map((check) => check.selector) };\n }),\n );\n const failures = missing.filter((group) => group.selectors.length > 0);\n if (failures.length > 0) {\n const details = failures\n .map(\n (group) =>\n `signer ${group.signer} holds no active InstantLayer delegation from ${canonicalAccount} for selector(s) ${group.selectors.join(\", \")}`,\n )\n .join(\"; \");\n throw new SymmError(\n \"validation\",\n \"GASLESS_SIGNER_NOT_DELEGATED\",\n `Gasless: ${details}. Grant getGaslessBatchSelectors(delegateCalls) for only the calls each delegate signs on ${canonicalAccount}, or sign those entries with the account's owner.`,\n );\n }\n return owner;\n}\n\nfunction invalidGrant(index: number, reason: string): SymmError {\n return new SymmError(\n \"validation\",\n \"GASLESS_INVALID_DELEGATION_GRANT\",\n `Gasless: calls[${index}] is an invalid delegation grant: ${reason}.`,\n );\n}\n"],"mappings":";;;;;;;;AAYA,IAAM,IAAoC,IAAI,IAC5C,EACG,QAAQ,MAAS,EAAK,SAAS,eAAe,EAAK,SAAS,qBAAqB,EAAK,SAAS,mBAAmB,EAClH,KAAK,MAAS,EAAmB,CAAI,EAAE,YAAY,CAAQ,CAChE;AAoBA,eAAsB,EACpB,GACA,GAOyB;CACzB,IAAM,EAAE,YAAS,YA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;CAEF,OAAO;AACT;AAEA,SAAS,EAAa,GAAe,GAA2B;CAC9D,OAAO,IAAI,EACT,cACA,oCACA,kBAAkB,EAAM,oCAAoC,EAAO,EACrE;AACF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Address } from 'viem';
|
|
2
2
|
import { Config } from '../../core/config/index.js';
|
|
3
|
-
import { ChainIdParameter, Compute, FromParameter } from '../../shared/types/properties.js';
|
|
3
|
+
import { ChainIdParameter, Compute, FromParameter, GaslessIdempotencyKeyParameter } from '../../shared/types/properties.js';
|
|
4
4
|
import { GaslessBatchCall } from '../batch/calls.js';
|
|
5
5
|
import { GaslessSubmitReceipt } from '../types.js';
|
|
6
6
|
/**
|
|
7
7
|
* Parameters for {@link relayGaslessBatch}.
|
|
8
8
|
*/
|
|
9
|
-
export type RelayGaslessBatchParameters = Compute<ChainIdParameter & FromParameter & {
|
|
9
|
+
export type RelayGaslessBatchParameters = Compute<ChainIdParameter & FromParameter & GaslessIdempotencyKeyParameter & {
|
|
10
10
|
/**
|
|
11
11
|
* The sub-account every operation runs under: the `signerAccount` of each
|
|
12
12
|
* relayable write, whose InstantLayer nonces the batch consumes and whose
|
|
@@ -35,6 +35,12 @@ export type RelayGaslessBatchParameters = Compute<ChainIdParameter & FromParamet
|
|
|
35
35
|
operationType?: string;
|
|
36
36
|
/** Non-secret client correlation data stored with the request. */
|
|
37
37
|
metadata?: Record<string, unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* Absolute signature expiry in Unix seconds. Defaults to call time + 20 minutes.
|
|
40
|
+
* Must be in the future and no later than that default maximum. Persist the
|
|
41
|
+
* same absolute value with recovery inputs; never extend a short-lived authorization.
|
|
42
|
+
*/
|
|
43
|
+
deadline?: bigint;
|
|
38
44
|
}>;
|
|
39
45
|
/** Return type of {@link relayGaslessBatch}. */
|
|
40
46
|
export type RelayGaslessBatchReturnType = GaslessSubmitReceipt;
|
|
@@ -49,14 +55,17 @@ export type RelayGaslessBatchReturnType = GaslessSubmitReceipt;
|
|
|
49
55
|
*
|
|
50
56
|
* 1. every call is encoded and checked before any network call — a write the
|
|
51
57
|
* relayer cannot carry throws `GASLESS_NOT_RELAYABLE`;
|
|
52
|
-
* 2.
|
|
53
|
-
* (`execution.preflightDelegation`, default on)
|
|
58
|
+
* 2. each signer's delegations are checked before any prompt
|
|
59
|
+
* (`execution.preflightDelegation`, default on) — a delegation that an
|
|
60
|
+
* owner-signed grant earlier in the same batch hands a signer already counts;
|
|
54
61
|
* 3. fresh nonces are read and sequenced per stream — the account's InstantLayer
|
|
55
62
|
* nonces for the writes, each wallet id's own nonces for its entries;
|
|
56
63
|
* 4. the batch is priced on-chain before any prompt (`execution.preflightFee`,
|
|
57
64
|
* default on) — a quote the contract refuses throws, a quote that fails for
|
|
58
65
|
* transport reasons does not block;
|
|
59
|
-
* 5. each operation is signed
|
|
66
|
+
* 5. each operation is signed by its call's `from` (the batch's signer by
|
|
67
|
+
* default) — in-memory signers such as a session key first, then one
|
|
68
|
+
* wallet prompt per remaining call, in order;
|
|
60
69
|
* 6. one `relay-instant` request carries them all, with one wallet id per
|
|
61
70
|
* operation (`0` for every write).
|
|
62
71
|
*
|
|
@@ -70,22 +79,34 @@ export type RelayGaslessBatchReturnType = GaslessSubmitReceipt;
|
|
|
70
79
|
* consumers should reach for `useRelayGaslessBatch`, which confirms the request
|
|
71
80
|
* before it resolves.
|
|
72
81
|
*
|
|
82
|
+
* Pass `idempotencyKey` (one per user action, from
|
|
83
|
+
* `generateGaslessIdempotencyKey`) to make the batch retryable: a later call
|
|
84
|
+
* with the same key never waits for its own earlier submit, returns that
|
|
85
|
+
* submit's receipt when this config saw it accepted, and is otherwise accepted
|
|
86
|
+
* by the service at most once. The signatures' deadline is fixed when the call
|
|
87
|
+
* starts (`GASLESS_SIGNATURE_LIFETIME_SECONDS`).
|
|
88
|
+
*
|
|
73
89
|
* @param config - The SDK config (must have a `getWalletClient` resolver).
|
|
74
|
-
* @param parameters - The account, the calls, and optional chain / signer / label overrides.
|
|
90
|
+
* @param parameters - The account, the calls, and optional chain / signer / label / idempotency-key overrides.
|
|
75
91
|
* @returns The acceptance receipt; persist it immediately.
|
|
92
|
+
* @throws {SymmError} `GASLESS_IDEMPOTENCY_KEY_INVALID` for a blank key or one longer than 128 characters.
|
|
76
93
|
* @throws {SymmError} `GASLESS_NOT_CONFIGURED` / `GASLESS_UNSUPPORTED_CONTRACTS_VERSION`.
|
|
77
94
|
* @throws {SymmError} `GASLESS_EMPTY_BATCH`, `GASLESS_NOT_RELAYABLE` or `GASLESS_WALLET_ID_INVALID`
|
|
78
95
|
* before any network call.
|
|
79
96
|
* @throws {SymmError} `GASLESS_CONFIG_INCOHERENT` when the GaslessLayer verifies another InstantLayer.
|
|
80
97
|
* @throws {SymmError} `GASLESS_SIGNER_NOT_DELEGATED` when a session key is missing a selector —
|
|
81
|
-
* grant `getGaslessBatchSelectors(
|
|
98
|
+
* grant `getGaslessBatchSelectors(delegateCalls)` for only that key's calls on `account`.
|
|
99
|
+
* @throws {SymmError} `GASLESS_INVALID_DELEGATION_GRANT` when preflight rejects a grant's signer or inputs.
|
|
82
100
|
* @throws {SymmError} `GASLESS_FREE_QUOTA_EXHAUSTED`, `GASLESS_FEE_QUOTE_REVERTED` or
|
|
83
101
|
* `GASLESS_LAYER_INTERFACE_UNSUPPORTED` from the fee pre-flight, before any prompt.
|
|
84
102
|
* @throws {SymmError} `GASLESS_NONCE_STREAM_BUSY` when an earlier relay on one of the
|
|
85
103
|
* batch's nonce streams is still unaccounted for.
|
|
86
104
|
* @throws {SymmApiError} `GASLESS_RELAY_SUBMIT_FAILED` on HTTP failure, and
|
|
87
|
-
* `GASLESS_SUBMIT_UNCONFIRMED` when the outcome could not be established —
|
|
88
|
-
* `
|
|
105
|
+
* `GASLESS_SUBMIT_UNCONFIRMED` when the outcome could not be established — call again under the
|
|
106
|
+
* same `idempotencyKey`, or replay it with `resubmitGaslessRequest`; never sign the batch again
|
|
107
|
+
* under a new key.
|
|
108
|
+
* @throws {SymmError} `GASLESS_BATCH_DEADLINE_INVALID` for an explicit expiry outside the allowed window.
|
|
109
|
+
* @throws {SymmError} `GASLESS_BATCH_DEADLINE_EXPIRED` when an explicit expiry elapses before submission.
|
|
89
110
|
* @throws The wallet's own error when the user rejects a prompt; nothing is submitted.
|
|
90
111
|
*
|
|
91
112
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay-gasless-batch.d.ts","sourceRoot":"","sources":["../../../src/gasless/relay-gasless-batch/relay-gasless-batch.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"relay-gasless-batch.d.ts","sourceRoot":"","sources":["../../../src/gasless/relay-gasless-batch/relay-gasless-batch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EACV,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,8BAA8B,EAC/B,MAAM,+BAA+B,CAAC;AAIvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AA2BvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAOrD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAC/C,gBAAgB,GACd,aAAa,GACb,8BAA8B,GAAG;IAC/B;;;;;;;;;;OAUG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACnC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CACJ,CAAC;AAEF,gDAAgD;AAChD,MAAM,MAAM,2BAA2B,GAAG,oBAAoB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,2BAA2B,GACtC,OAAO,CAAC,2BAA2B,CAAC,CAgLtC"}
|