@rhinestone/sdk 2.0.0-beta.8 → 2.0.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/README.md +2 -2
- package/dist/src/accounts/adapter.d.ts +31 -0
- package/dist/src/accounts/adapter.d.ts.map +1 -0
- package/dist/src/accounts/adapters/eoa.d.ts +4 -0
- package/dist/src/accounts/adapters/eoa.d.ts.map +1 -0
- package/dist/src/accounts/adapters/eoa.js +45 -0
- package/dist/src/accounts/adapters/hca.d.ts +5 -0
- package/dist/src/accounts/adapters/hca.d.ts.map +1 -0
- package/dist/src/accounts/adapters/hca.js +118 -0
- package/dist/src/accounts/adapters/kernel.d.ts +9 -0
- package/dist/src/accounts/adapters/kernel.d.ts.map +1 -0
- package/dist/src/accounts/adapters/kernel.js +159 -0
- package/dist/src/accounts/adapters/nexus.d.ts +16 -0
- package/dist/src/accounts/adapters/nexus.d.ts.map +1 -0
- package/dist/src/accounts/adapters/nexus.js +212 -0
- package/dist/src/accounts/adapters/safe.d.ts +6 -0
- package/dist/src/accounts/adapters/safe.d.ts.map +1 -0
- package/dist/src/accounts/adapters/safe.js +194 -0
- package/dist/src/accounts/adapters/shared.d.ts +9 -0
- package/dist/src/accounts/adapters/shared.d.ts.map +1 -0
- package/dist/src/accounts/adapters/shared.js +62 -0
- package/dist/src/accounts/adapters/startale.d.ts +14 -0
- package/dist/src/accounts/adapters/startale.d.ts.map +1 -0
- package/dist/src/accounts/adapters/startale.js +165 -0
- package/dist/src/accounts/construction.d.ts +25 -0
- package/dist/src/accounts/construction.d.ts.map +1 -0
- package/dist/src/accounts/construction.js +34 -0
- package/dist/src/accounts/deployment.d.ts +12 -0
- package/dist/src/accounts/deployment.d.ts.map +1 -0
- package/dist/src/accounts/deployment.js +33 -0
- package/dist/src/accounts/erc7579-calls.d.ts +4 -0
- package/dist/src/accounts/erc7579-calls.d.ts.map +1 -0
- package/dist/src/accounts/erc7579-calls.js +57 -0
- package/dist/src/accounts/error.d.ts +3 -10
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +5 -11
- package/dist/src/accounts/legacy.d.ts +14 -0
- package/dist/src/accounts/legacy.d.ts.map +1 -0
- package/dist/src/accounts/legacy.js +40 -0
- package/dist/src/accounts/registry.d.ts +4 -0
- package/dist/src/accounts/registry.d.ts.map +1 -0
- package/dist/src/accounts/registry.js +22 -0
- package/dist/src/accounts/types.d.ts +131 -0
- package/dist/src/accounts/types.d.ts.map +1 -0
- package/dist/src/accounts/types.js +1 -0
- package/dist/src/accounts/wallet-account.d.ts +3 -0
- package/dist/src/accounts/wallet-account.d.ts.map +1 -0
- package/dist/src/accounts/wallet-account.js +12 -0
- package/dist/src/actions/deploy.d.ts +4 -0
- package/dist/src/actions/deploy.d.ts.map +1 -0
- package/dist/src/actions/deploy.js +8 -0
- package/dist/src/actions/ecdsa.d.ts +1 -1
- package/dist/src/actions/ecdsa.d.ts.map +1 -1
- package/dist/src/actions/ecdsa.js +8 -8
- package/dist/src/actions/index.d.ts +2 -16
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +3 -49
- package/dist/src/actions/mfa.d.ts +1 -1
- package/dist/src/actions/mfa.d.ts.map +1 -1
- package/dist/src/actions/mfa.js +30 -10
- package/dist/src/actions/modules.d.ts +4 -0
- package/dist/src/actions/modules.d.ts.map +1 -0
- package/dist/src/actions/modules.js +22 -0
- package/dist/src/actions/passkeys.d.ts +2 -2
- package/dist/src/actions/passkeys.d.ts.map +1 -1
- package/dist/src/actions/passkeys.js +19 -14
- package/dist/src/actions/runtime.d.ts +12 -0
- package/dist/src/actions/runtime.d.ts.map +1 -0
- package/dist/src/actions/runtime.js +158 -0
- package/dist/src/actions/smart-sessions.d.ts +30 -6
- package/dist/src/actions/smart-sessions.d.ts.map +1 -1
- package/dist/src/actions/smart-sessions.js +69 -18
- package/dist/src/api/account.d.ts +265 -0
- package/dist/src/api/account.d.ts.map +1 -0
- package/dist/src/api/account.js +637 -0
- package/dist/src/api/accounts.d.ts +12 -0
- package/dist/src/api/accounts.d.ts.map +1 -0
- package/dist/src/api/accounts.js +17 -0
- package/dist/src/api/compose-types.d.ts +147 -0
- package/dist/src/api/compose-types.d.ts.map +1 -0
- package/dist/src/api/compose-types.js +1 -0
- package/dist/src/api/compose.d.ts +6 -0
- package/dist/src/api/compose.d.ts.map +1 -0
- package/dist/src/api/compose.js +766 -0
- package/dist/src/api/direct-signing.d.ts +27 -0
- package/dist/src/api/direct-signing.d.ts.map +1 -0
- package/dist/src/api/direct-signing.js +191 -0
- package/dist/src/api/project-mappers.d.ts +7 -0
- package/dist/src/api/project-mappers.d.ts.map +1 -0
- package/dist/src/api/project-mappers.js +23 -0
- package/dist/src/api/queries/app-fees.d.ts +4 -0
- package/dist/src/api/queries/app-fees.d.ts.map +1 -0
- package/dist/src/api/queries/app-fees.js +3 -0
- package/dist/src/api/queries/portfolio.d.ts +9 -0
- package/dist/src/api/queries/portfolio.d.ts.map +1 -0
- package/dist/src/api/queries/portfolio.js +28 -0
- package/dist/src/api/queries/session.d.ts +8 -0
- package/dist/src/api/queries/session.d.ts.map +1 -0
- package/dist/src/api/queries/session.js +15 -0
- package/dist/src/api/sdk.d.ts +80 -0
- package/dist/src/api/sdk.d.ts.map +1 -0
- package/dist/src/api/sdk.js +103 -0
- package/dist/src/api/signer-selection.d.ts +7 -0
- package/dist/src/api/signer-selection.d.ts.map +1 -0
- package/dist/src/api/signer-selection.js +109 -0
- package/dist/src/calls/normalize.d.ts +9 -0
- package/dist/src/calls/normalize.d.ts.map +1 -0
- package/dist/src/calls/normalize.js +17 -0
- package/dist/src/calls/resolve.d.ts +3 -0
- package/dist/src/calls/resolve.d.ts.map +1 -0
- package/dist/src/calls/resolve.js +15 -0
- package/dist/src/calls/types.d.ts +25 -0
- package/dist/src/calls/types.d.ts.map +1 -0
- package/dist/src/calls/types.js +1 -0
- package/dist/src/chains/caip2.d.ts +10 -0
- package/dist/src/chains/caip2.d.ts.map +1 -0
- package/dist/src/chains/caip2.js +85 -0
- package/dist/src/chains/catalog.d.ts +5 -0
- package/dist/src/chains/catalog.d.ts.map +1 -0
- package/dist/src/chains/catalog.js +41 -0
- package/dist/src/chains/errors.d.ts +15 -0
- package/dist/src/chains/errors.d.ts.map +1 -0
- package/dist/src/chains/errors.js +21 -0
- package/dist/src/chains/non-evm.d.ts +26 -0
- package/dist/src/chains/non-evm.d.ts.map +1 -0
- package/dist/src/chains/non-evm.js +30 -0
- package/dist/src/chains/tokens.d.ts +4 -0
- package/dist/src/chains/tokens.d.ts.map +1 -0
- package/dist/src/chains/tokens.js +22 -0
- package/dist/src/chains/types.d.ts +25 -0
- package/dist/src/chains/types.d.ts.map +1 -0
- package/dist/src/chains/types.js +1 -0
- package/dist/src/clients/bundler/client.d.ts +10 -0
- package/dist/src/clients/bundler/client.d.ts.map +1 -0
- package/dist/src/clients/bundler/client.js +85 -0
- package/dist/src/clients/bundler/endpoints.d.ts +3 -0
- package/dist/src/clients/bundler/endpoints.d.ts.map +1 -0
- package/dist/src/clients/bundler/endpoints.js +18 -0
- package/dist/src/clients/bundler/port.d.ts +22 -0
- package/dist/src/clients/bundler/port.d.ts.map +1 -0
- package/dist/src/clients/bundler/port.js +1 -0
- package/dist/src/clients/json-rpc.d.ts +20 -0
- package/dist/src/clients/json-rpc.d.ts.map +1 -0
- package/dist/src/clients/json-rpc.js +56 -0
- package/dist/src/clients/orchestrator/auth.d.ts +7 -0
- package/dist/src/clients/orchestrator/auth.d.ts.map +1 -0
- package/dist/src/clients/orchestrator/auth.js +27 -0
- package/dist/src/clients/orchestrator/chain-catalog.d.ts +36 -0
- package/dist/src/clients/orchestrator/chain-catalog.d.ts.map +1 -0
- package/dist/src/clients/orchestrator/chain-catalog.js +67 -0
- package/dist/src/clients/orchestrator/client.d.ts +13 -0
- package/dist/src/clients/orchestrator/client.d.ts.map +1 -0
- package/dist/src/clients/orchestrator/client.js +97 -0
- package/dist/src/clients/orchestrator/errors.d.ts +238 -0
- package/dist/src/clients/orchestrator/errors.d.ts.map +1 -0
- package/dist/src/clients/orchestrator/errors.js +525 -0
- package/dist/src/clients/orchestrator/fetch.d.ts +7 -0
- package/dist/src/clients/orchestrator/fetch.d.ts.map +1 -0
- package/dist/src/clients/orchestrator/fetch.js +37 -0
- package/dist/src/clients/orchestrator/mappers.d.ts +9 -0
- package/dist/src/clients/orchestrator/mappers.d.ts.map +1 -0
- package/dist/src/clients/orchestrator/mappers.js +198 -0
- package/dist/src/clients/orchestrator/port.d.ts +26 -0
- package/dist/src/clients/orchestrator/port.d.ts.map +1 -0
- package/dist/src/clients/orchestrator/port.js +1 -0
- package/dist/src/{orchestrator/types.d.ts → clients/orchestrator/public.d.ts} +115 -42
- package/dist/src/clients/orchestrator/public.d.ts.map +1 -0
- package/dist/src/clients/orchestrator/public.js +14 -0
- package/dist/src/clients/orchestrator/types.d.ts +144 -0
- package/dist/src/clients/orchestrator/types.d.ts.map +1 -0
- package/dist/src/clients/orchestrator/types.js +1 -0
- package/dist/src/clients/orchestrator/wire.d.ts +19 -0
- package/dist/src/clients/orchestrator/wire.d.ts.map +1 -0
- package/dist/src/clients/orchestrator/wire.gen.d.ts +6463 -0
- package/dist/src/clients/orchestrator/wire.gen.d.ts.map +1 -0
- package/dist/src/clients/orchestrator/wire.gen.js +1 -0
- package/dist/src/clients/orchestrator/wire.js +1 -0
- package/dist/src/clients/paymaster/client.d.ts +8 -0
- package/dist/src/clients/paymaster/client.d.ts.map +1 -0
- package/dist/src/clients/paymaster/client.js +38 -0
- package/dist/src/clients/paymaster/endpoints.d.ts +3 -0
- package/dist/src/clients/paymaster/endpoints.d.ts.map +1 -0
- package/dist/src/clients/paymaster/endpoints.js +16 -0
- package/dist/src/clients/paymaster/port.d.ts +17 -0
- package/dist/src/clients/paymaster/port.d.ts.map +1 -0
- package/dist/src/clients/paymaster/port.js +1 -0
- package/dist/src/clients/rpc/client.d.ts +6 -0
- package/dist/src/clients/rpc/client.d.ts.map +1 -0
- package/dist/src/clients/rpc/client.js +66 -0
- package/dist/src/clients/rpc/compatibility.d.ts +12 -0
- package/dist/src/clients/rpc/compatibility.d.ts.map +1 -0
- package/dist/src/clients/rpc/compatibility.js +16 -0
- package/dist/src/clients/rpc/port.d.ts +13 -0
- package/dist/src/clients/rpc/port.d.ts.map +1 -0
- package/dist/src/clients/rpc/port.js +1 -0
- package/dist/src/clients/rpc/providers.d.ts +3 -0
- package/dist/src/clients/rpc/providers.d.ts.map +1 -0
- package/dist/src/clients/rpc/providers.js +8 -0
- package/dist/src/clients/rpc/transport.d.ts +4 -0
- package/dist/src/clients/rpc/transport.d.ts.map +1 -0
- package/dist/src/clients/rpc/transport.js +5 -0
- package/dist/src/clients/rpc/types.d.ts +23 -0
- package/dist/src/clients/rpc/types.d.ts.map +1 -0
- package/dist/src/clients/rpc/types.js +1 -0
- package/dist/src/config/account-runtime.d.ts +7 -0
- package/dist/src/config/account-runtime.d.ts.map +1 -0
- package/dist/src/config/account-runtime.js +36 -0
- package/dist/src/config/account.d.ts +743 -0
- package/dist/src/config/account.d.ts.map +1 -0
- package/dist/src/config/account.js +10 -0
- package/dist/src/config/defaults.d.ts +14 -0
- package/dist/src/config/defaults.d.ts.map +1 -0
- package/dist/src/config/defaults.js +26 -0
- package/dist/src/config/input.d.ts +54 -0
- package/dist/src/config/input.d.ts.map +1 -0
- package/dist/src/config/input.js +1 -0
- package/dist/src/config/legacy.d.ts +22 -0
- package/dist/src/config/legacy.d.ts.map +1 -0
- package/dist/src/config/legacy.js +23 -0
- package/dist/src/config/resolve.d.ts +13 -0
- package/dist/src/config/resolve.d.ts.map +1 -0
- package/dist/src/config/resolve.js +174 -0
- package/dist/src/config/resolved.d.ts +77 -0
- package/dist/src/config/resolved.d.ts.map +1 -0
- package/dist/src/config/resolved.js +1 -0
- package/dist/src/config/validate.d.ts +3 -0
- package/dist/src/config/validate.d.ts.map +1 -0
- package/dist/src/config/validate.js +6 -0
- package/dist/src/{execution/error.d.ts → errors/execution.d.ts} +43 -12
- package/dist/src/errors/execution.d.ts.map +1 -0
- package/dist/src/errors/execution.js +123 -0
- package/dist/src/errors/index.d.ts +6 -4
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/errors/index.js +7 -6
- package/dist/src/index.d.ts +14 -83
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -290
- package/dist/src/jwt-server/jcs.d.ts +1 -1
- package/dist/src/jwt-server/jcs.js +4 -2
- package/dist/src/modules/erc7579-abi.d.ts +4 -0
- package/dist/src/modules/erc7579-abi.d.ts.map +1 -0
- package/dist/src/modules/erc7579-abi.js +12 -0
- package/dist/src/modules/intent-executor.d.ts +6 -0
- package/dist/src/modules/intent-executor.d.ts.map +1 -0
- package/dist/src/modules/intent-executor.js +13 -0
- package/dist/src/modules/legacy-core.d.ts +29 -0
- package/dist/src/modules/legacy-core.d.ts.map +1 -0
- package/dist/src/modules/legacy-core.js +80 -0
- package/dist/src/modules/normalize.d.ts +4 -0
- package/dist/src/modules/normalize.d.ts.map +1 -0
- package/dist/src/modules/normalize.js +15 -0
- package/dist/src/modules/plan.d.ts +16 -0
- package/dist/src/modules/plan.d.ts.map +1 -0
- package/dist/src/modules/plan.js +51 -0
- package/dist/src/modules/read-core.d.ts +39 -0
- package/dist/src/modules/read-core.d.ts.map +1 -0
- package/dist/src/modules/read-core.js +149 -0
- package/dist/src/modules/types.d.ts +46 -0
- package/dist/src/modules/types.d.ts.map +1 -0
- package/dist/src/modules/types.js +1 -0
- package/dist/src/modules/validators/capabilities.d.ts +4 -0
- package/dist/src/modules/validators/capabilities.d.ts.map +1 -0
- package/dist/src/modules/validators/capabilities.js +58 -0
- package/dist/src/modules/validators/contribution.d.ts +4 -0
- package/dist/src/modules/validators/contribution.d.ts.map +1 -0
- package/dist/src/modules/validators/contribution.js +64 -0
- package/dist/src/modules/validators/definition.d.ts +3 -0
- package/dist/src/modules/validators/definition.d.ts.map +1 -0
- package/dist/src/modules/validators/definition.js +68 -0
- package/dist/src/modules/validators/ens.d.ts +5 -0
- package/dist/src/modules/validators/ens.d.ts.map +1 -0
- package/dist/src/modules/validators/ens.js +34 -0
- package/dist/src/modules/validators/k1.d.ts +2 -0
- package/dist/src/modules/validators/k1.d.ts.map +1 -0
- package/dist/src/modules/validators/k1.js +1 -0
- package/dist/src/modules/validators/multi-factor.d.ts +18 -0
- package/dist/src/modules/validators/multi-factor.d.ts.map +1 -0
- package/dist/src/modules/validators/multi-factor.js +79 -0
- package/dist/src/modules/validators/ownable.d.ts +26 -0
- package/dist/src/modules/validators/ownable.d.ts.map +1 -0
- package/dist/src/modules/validators/ownable.js +84 -0
- package/dist/src/modules/validators/permissions.d.ts +2 -1
- package/dist/src/modules/validators/permissions.d.ts.map +1 -1
- package/dist/src/modules/validators/permissions.js +192 -18
- package/dist/src/modules/validators/policies/claim/arbiters.d.ts +19 -0
- package/dist/src/modules/validators/policies/claim/arbiters.d.ts.map +1 -0
- package/dist/src/modules/validators/policies/claim/arbiters.js +82 -0
- package/dist/src/modules/validators/resolve.d.ts +5 -0
- package/dist/src/modules/validators/resolve.d.ts.map +1 -0
- package/dist/src/modules/validators/resolve.js +22 -0
- package/dist/src/modules/validators/signer-id.d.ts +5 -0
- package/dist/src/modules/validators/signer-id.d.ts.map +1 -0
- package/dist/src/modules/validators/signer-id.js +8 -0
- package/dist/src/modules/validators/smart-session-signature-types.d.ts +35 -0
- package/dist/src/modules/validators/smart-session-signature-types.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-session-signature-types.js +1 -0
- package/dist/src/modules/validators/smart-sessions/authorization.d.ts +99 -0
- package/dist/src/modules/validators/smart-sessions/authorization.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/authorization.js +101 -0
- package/dist/src/modules/validators/smart-sessions/calls.d.ts +19 -0
- package/dist/src/modules/validators/smart-sessions/calls.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/calls.js +85 -0
- package/dist/src/modules/validators/smart-sessions/cross-chain-permits.d.ts +4 -0
- package/dist/src/modules/validators/smart-sessions/cross-chain-permits.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/cross-chain-permits.js +77 -0
- package/dist/src/modules/validators/smart-sessions/digest.d.ts +5 -0
- package/dist/src/modules/validators/smart-sessions/digest.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/digest.js +30 -0
- package/dist/src/modules/validators/smart-sessions/mock-signature.d.ts +10 -0
- package/dist/src/modules/validators/smart-sessions/mock-signature.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/mock-signature.js +31 -0
- package/dist/src/modules/validators/smart-sessions/module.d.ts +11 -0
- package/dist/src/modules/validators/smart-sessions/module.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/module.js +18 -0
- package/dist/src/modules/validators/smart-sessions/policies/addresses.d.ts +23 -0
- package/dist/src/modules/validators/smart-sessions/policies/addresses.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/policies/addresses.js +29 -0
- package/dist/src/modules/validators/smart-sessions/policies/claim.d.ts +10 -0
- package/dist/src/modules/validators/smart-sessions/policies/claim.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/policies/claim.js +106 -0
- package/dist/src/modules/validators/smart-sessions/policies/encode.d.ts +4 -0
- package/dist/src/modules/validators/smart-sessions/policies/encode.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/policies/encode.js +197 -0
- package/dist/src/modules/validators/smart-sessions/resolve.d.ts +16 -0
- package/dist/src/modules/validators/smart-sessions/resolve.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/resolve.js +120 -0
- package/dist/src/modules/validators/smart-sessions/signature.d.ts +14 -0
- package/dist/src/modules/validators/smart-sessions/signature.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/signature.js +167 -0
- package/dist/src/modules/validators/smart-sessions/state.d.ts +19 -0
- package/dist/src/modules/validators/smart-sessions/state.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/state.js +42 -0
- package/dist/src/modules/validators/smart-sessions/types.d.ts +227 -0
- package/dist/src/modules/validators/smart-sessions/types.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions/types.js +1 -0
- package/dist/src/modules/validators/types.d.ts +143 -0
- package/dist/src/modules/validators/types.d.ts.map +1 -0
- package/dist/src/modules/validators/types.js +1 -0
- package/dist/src/modules/validators/webauthn.d.ts +54 -0
- package/dist/src/modules/validators/webauthn.d.ts.map +1 -0
- package/dist/src/modules/validators/webauthn.js +159 -0
- package/dist/src/signing/context.d.ts +25 -0
- package/dist/src/signing/context.d.ts.map +1 -0
- package/dist/src/signing/context.js +163 -0
- package/dist/src/signing/contribution.d.ts +13 -0
- package/dist/src/signing/contribution.d.ts.map +1 -0
- package/dist/src/signing/contribution.js +83 -0
- package/dist/src/signing/eip7702.d.ts +41 -0
- package/dist/src/signing/eip7702.d.ts.map +1 -0
- package/dist/src/signing/eip7702.js +215 -0
- package/dist/src/signing/error.d.ts +27 -0
- package/dist/src/signing/error.d.ts.map +1 -0
- package/dist/src/signing/error.js +25 -0
- package/dist/src/signing/execute.d.ts +17 -0
- package/dist/src/signing/execute.d.ts.map +1 -0
- package/dist/src/signing/execute.js +138 -0
- package/dist/src/signing/intent-plans/assemble.d.ts +15 -0
- package/dist/src/signing/intent-plans/assemble.d.ts.map +1 -0
- package/dist/src/signing/intent-plans/assemble.js +96 -0
- package/dist/src/signing/intent-plans/independent.d.ts +48 -0
- package/dist/src/signing/intent-plans/independent.d.ts.map +1 -0
- package/dist/src/signing/intent-plans/independent.js +150 -0
- package/dist/src/signing/intent-plans/plan.d.ts +14 -0
- package/dist/src/signing/intent-plans/plan.d.ts.map +1 -0
- package/dist/src/signing/intent-plans/plan.js +187 -0
- package/dist/src/signing/intent-plans/types.d.ts +63 -0
- package/dist/src/signing/intent-plans/types.d.ts.map +1 -0
- package/dist/src/signing/intent-plans/types.js +1 -0
- package/dist/src/signing/message.d.ts +28 -0
- package/dist/src/signing/message.d.ts.map +1 -0
- package/dist/src/signing/message.js +90 -0
- package/dist/src/signing/passkeys.d.ts +28 -0
- package/dist/src/signing/passkeys.d.ts.map +1 -0
- package/dist/src/signing/passkeys.js +17 -0
- package/dist/src/signing/plan.d.ts +35 -0
- package/dist/src/signing/plan.d.ts.map +1 -0
- package/dist/src/signing/plan.js +377 -0
- package/dist/src/signing/protocols/erc6492.d.ts +11 -0
- package/dist/src/signing/protocols/erc6492.d.ts.map +1 -0
- package/dist/src/signing/protocols/erc6492.js +24 -0
- package/dist/src/signing/protocols/erc7739.d.ts +17 -0
- package/dist/src/signing/protocols/erc7739.d.ts.map +1 -0
- package/dist/src/signing/protocols/erc7739.js +84 -0
- package/dist/src/signing/session-enable.d.ts +35 -0
- package/dist/src/signing/session-enable.d.ts.map +1 -0
- package/dist/src/signing/session-enable.js +62 -0
- package/dist/src/signing/signers/compatibility.d.ts +4 -0
- package/dist/src/signing/signers/compatibility.d.ts.map +1 -0
- package/dist/src/signing/signers/compatibility.js +51 -0
- package/dist/src/signing/signers/ecdsa.d.ts +14 -0
- package/dist/src/signing/signers/ecdsa.d.ts.map +1 -0
- package/dist/src/signing/signers/ecdsa.js +54 -0
- package/dist/src/signing/signers/registry.d.ts +7 -0
- package/dist/src/signing/signers/registry.d.ts.map +1 -0
- package/dist/src/signing/signers/registry.js +33 -0
- package/dist/src/signing/signers/types.d.ts +16 -0
- package/dist/src/signing/signers/types.d.ts.map +1 -0
- package/dist/src/signing/signers/types.js +1 -0
- package/dist/src/signing/signers/wallet-chain.d.ts +9 -0
- package/dist/src/signing/signers/wallet-chain.d.ts.map +1 -0
- package/dist/src/signing/signers/wallet-chain.js +15 -0
- package/dist/src/signing/signers/webauthn.d.ts +11 -0
- package/dist/src/signing/signers/webauthn.d.ts.map +1 -0
- package/dist/src/signing/signers/webauthn.js +14 -0
- package/dist/src/signing/typed-data.d.ts +39 -0
- package/dist/src/signing/typed-data.d.ts.map +1 -0
- package/dist/src/signing/typed-data.js +135 -0
- package/dist/src/signing/types.d.ts +346 -0
- package/dist/src/signing/types.d.ts.map +1 -0
- package/dist/src/signing/types.js +1 -0
- package/dist/src/signing/user-operation.d.ts +23 -0
- package/dist/src/signing/user-operation.d.ts.map +1 -0
- package/dist/src/signing/user-operation.js +61 -0
- package/dist/src/smart-sessions/index.d.ts +16 -0
- package/dist/src/smart-sessions/index.d.ts.map +1 -0
- package/dist/src/smart-sessions/index.js +45 -0
- package/dist/src/transactions/intents/account.d.ts +15 -0
- package/dist/src/transactions/intents/account.d.ts.map +1 -0
- package/dist/src/transactions/intents/account.js +48 -0
- package/dist/src/transactions/intents/compatibility.d.ts +4 -0
- package/dist/src/transactions/intents/compatibility.d.ts.map +1 -0
- package/dist/src/transactions/intents/compatibility.js +19 -0
- package/dist/src/transactions/intents/normalize.d.ts +5 -0
- package/dist/src/transactions/intents/normalize.d.ts.map +1 -0
- package/dist/src/transactions/intents/normalize.js +48 -0
- package/dist/src/transactions/intents/prepare.d.ts +7 -0
- package/dist/src/transactions/intents/prepare.d.ts.map +1 -0
- package/dist/src/transactions/intents/prepare.js +249 -0
- package/dist/src/transactions/intents/quotes.d.ts +3 -0
- package/dist/src/transactions/intents/quotes.d.ts.map +1 -0
- package/dist/src/transactions/intents/quotes.js +11 -0
- package/dist/src/transactions/intents/request.d.ts +11 -0
- package/dist/src/transactions/intents/request.d.ts.map +1 -0
- package/dist/src/transactions/intents/request.js +55 -0
- package/dist/src/transactions/intents/send.d.ts +3 -0
- package/dist/src/transactions/intents/send.d.ts.map +1 -0
- package/dist/src/transactions/intents/send.js +22 -0
- package/dist/src/transactions/intents/session-signing.d.ts +7 -0
- package/dist/src/transactions/intents/session-signing.d.ts.map +1 -0
- package/dist/src/transactions/intents/session-signing.js +363 -0
- package/dist/src/transactions/intents/sessions.d.ts +17 -0
- package/dist/src/transactions/intents/sessions.d.ts.map +1 -0
- package/dist/src/transactions/intents/sessions.js +85 -0
- package/dist/src/transactions/intents/sign-transaction.d.ts +10 -0
- package/dist/src/transactions/intents/sign-transaction.d.ts.map +1 -0
- package/dist/src/transactions/intents/sign-transaction.js +386 -0
- package/dist/src/transactions/intents/split.d.ts +13 -0
- package/dist/src/transactions/intents/split.d.ts.map +1 -0
- package/dist/src/transactions/intents/split.js +3 -0
- package/dist/src/transactions/intents/status-policy.d.ts +13 -0
- package/dist/src/transactions/intents/status-policy.d.ts.map +1 -0
- package/dist/src/transactions/intents/status-policy.js +39 -0
- package/dist/src/transactions/intents/status.d.ts +4 -0
- package/dist/src/transactions/intents/status.d.ts.map +1 -0
- package/dist/src/transactions/intents/status.js +50 -0
- package/dist/src/transactions/intents/submit.d.ts +3 -0
- package/dist/src/transactions/intents/submit.d.ts.map +1 -0
- package/dist/src/transactions/intents/submit.js +32 -0
- package/dist/src/transactions/intents/types.d.ts +136 -0
- package/dist/src/transactions/intents/types.d.ts.map +1 -0
- package/dist/src/transactions/intents/types.js +1 -0
- package/dist/src/transactions/user-operations/hash.d.ts +5 -0
- package/dist/src/transactions/user-operations/hash.d.ts.map +1 -0
- package/dist/src/transactions/user-operations/hash.js +9 -0
- package/dist/src/transactions/user-operations/nonce.d.ts +18 -0
- package/dist/src/transactions/user-operations/nonce.d.ts.map +1 -0
- package/dist/src/transactions/user-operations/nonce.js +43 -0
- package/dist/src/transactions/user-operations/prepare.d.ts +12 -0
- package/dist/src/transactions/user-operations/prepare.d.ts.map +1 -0
- package/dist/src/transactions/user-operations/prepare.js +136 -0
- package/dist/src/transactions/user-operations/reconstruct.d.ts +28 -0
- package/dist/src/transactions/user-operations/reconstruct.d.ts.map +1 -0
- package/dist/src/transactions/user-operations/reconstruct.js +52 -0
- package/dist/src/transactions/user-operations/send.d.ts +3 -0
- package/dist/src/transactions/user-operations/send.d.ts.map +1 -0
- package/dist/src/transactions/user-operations/send.js +8 -0
- package/dist/src/transactions/user-operations/sign.d.ts +3 -0
- package/dist/src/transactions/user-operations/sign.d.ts.map +1 -0
- package/dist/src/transactions/user-operations/sign.js +14 -0
- package/dist/src/transactions/user-operations/status.d.ts +4 -0
- package/dist/src/transactions/user-operations/status.d.ts.map +1 -0
- package/dist/src/transactions/user-operations/status.js +37 -0
- package/dist/src/transactions/user-operations/submit.d.ts +3 -0
- package/dist/src/transactions/user-operations/submit.d.ts.map +1 -0
- package/dist/src/transactions/user-operations/submit.js +8 -0
- package/dist/src/transactions/user-operations/types.d.ts +68 -0
- package/dist/src/transactions/user-operations/types.d.ts.map +1 -0
- package/dist/src/transactions/user-operations/types.js +1 -0
- package/dist/src/transactions/user-operations/validator-account.d.ts +5 -0
- package/dist/src/transactions/user-operations/validator-account.d.ts.map +1 -0
- package/dist/src/transactions/user-operations/validator-account.js +26 -0
- package/dist/src/utils/index.d.ts +68 -4
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +113 -51
- package/package.json +6 -11
- package/dist/src/accounts/index.d.ts +0 -51
- package/dist/src/accounts/index.d.ts.map +0 -1
- package/dist/src/accounts/index.js +0 -589
- package/dist/src/accounts/json-rpc/index.d.ts +0 -5
- package/dist/src/accounts/json-rpc/index.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/index.js +0 -19
- package/dist/src/accounts/json-rpc/providers.d.ts +0 -5
- package/dist/src/accounts/json-rpc/providers.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/providers.js +0 -16
- package/dist/src/accounts/kernel.d.ts +0 -27
- package/dist/src/accounts/kernel.d.ts.map +0 -1
- package/dist/src/accounts/kernel.js +0 -272
- package/dist/src/accounts/nexus.d.ts +0 -33
- package/dist/src/accounts/nexus.d.ts.map +0 -1
- package/dist/src/accounts/nexus.js +0 -444
- package/dist/src/accounts/safe.d.ts +0 -33
- package/dist/src/accounts/safe.d.ts.map +0 -1
- package/dist/src/accounts/safe.js +0 -343
- package/dist/src/accounts/signing/common.d.ts +0 -32
- package/dist/src/accounts/signing/common.d.ts.map +0 -1
- package/dist/src/accounts/signing/common.js +0 -184
- package/dist/src/accounts/signing/message.d.ts +0 -7
- package/dist/src/accounts/signing/message.d.ts.map +0 -1
- package/dist/src/accounts/signing/message.js +0 -45
- package/dist/src/accounts/signing/passkeys.d.ts +0 -36
- package/dist/src/accounts/signing/passkeys.d.ts.map +0 -1
- package/dist/src/accounts/signing/passkeys.js +0 -119
- package/dist/src/accounts/signing/typedData.d.ts +0 -5
- package/dist/src/accounts/signing/typedData.d.ts.map +0 -1
- package/dist/src/accounts/signing/typedData.js +0 -33
- package/dist/src/accounts/startale.d.ts +0 -26
- package/dist/src/accounts/startale.d.ts.map +0 -1
- package/dist/src/accounts/startale.js +0 -191
- package/dist/src/accounts/utils.d.ts +0 -33
- package/dist/src/accounts/utils.d.ts.map +0 -1
- package/dist/src/accounts/utils.js +0 -202
- package/dist/src/actions/recovery.d.ts +0 -33
- package/dist/src/actions/recovery.d.ts.map +0 -1
- package/dist/src/actions/recovery.js +0 -189
- package/dist/src/auth/provider.d.ts +0 -7
- package/dist/src/auth/provider.d.ts.map +0 -1
- package/dist/src/auth/provider.js +0 -38
- package/dist/src/execution/compact.d.ts +0 -5
- package/dist/src/execution/compact.d.ts.map +0 -1
- package/dist/src/execution/compact.js +0 -4
- package/dist/src/execution/error.d.ts.map +0 -1
- package/dist/src/execution/error.js +0 -85
- package/dist/src/execution/index.d.ts +0 -41
- package/dist/src/execution/index.d.ts.map +0 -1
- package/dist/src/execution/index.js +0 -202
- package/dist/src/execution/utils.d.ts +0 -126
- package/dist/src/execution/utils.d.ts.map +0 -1
- package/dist/src/execution/utils.js +0 -1054
- package/dist/src/modules/abi/smart-sessions.d.ts +0 -104
- package/dist/src/modules/abi/smart-sessions.d.ts.map +0 -1
- package/dist/src/modules/abi/smart-sessions.js +0 -128
- package/dist/src/modules/chain-abstraction.d.ts +0 -5
- package/dist/src/modules/chain-abstraction.d.ts.map +0 -1
- package/dist/src/modules/chain-abstraction.js +0 -3
- package/dist/src/modules/common.d.ts +0 -30
- package/dist/src/modules/common.d.ts.map +0 -1
- package/dist/src/modules/common.js +0 -30
- package/dist/src/modules/index.d.ts +0 -11
- package/dist/src/modules/index.d.ts.map +0 -1
- package/dist/src/modules/index.js +0 -90
- package/dist/src/modules/legacy.d.ts +0 -10
- package/dist/src/modules/legacy.d.ts.map +0 -1
- package/dist/src/modules/legacy.js +0 -62
- package/dist/src/modules/read.d.ts +0 -10
- package/dist/src/modules/read.d.ts.map +0 -1
- package/dist/src/modules/read.js +0 -171
- package/dist/src/modules/validators/core.d.ts +0 -31
- package/dist/src/modules/validators/core.d.ts.map +0 -1
- package/dist/src/modules/validators/core.js +0 -266
- package/dist/src/modules/validators/index.d.ts +0 -4
- package/dist/src/modules/validators/index.d.ts.map +0 -1
- package/dist/src/modules/validators/index.js +0 -3
- package/dist/src/modules/validators/smart-sessions.d.ts +0 -196
- package/dist/src/modules/validators/smart-sessions.d.ts.map +0 -1
- package/dist/src/modules/validators/smart-sessions.js +0 -772
- package/dist/src/orchestrator/caip2.d.ts +0 -7
- package/dist/src/orchestrator/caip2.d.ts.map +0 -1
- package/dist/src/orchestrator/caip2.js +0 -17
- package/dist/src/orchestrator/client.d.ts +0 -29
- package/dist/src/orchestrator/client.d.ts.map +0 -1
- package/dist/src/orchestrator/client.js +0 -291
- package/dist/src/orchestrator/consts.d.ts +0 -6
- package/dist/src/orchestrator/consts.d.ts.map +0 -1
- package/dist/src/orchestrator/consts.js +0 -5
- package/dist/src/orchestrator/error.d.ts +0 -97
- package/dist/src/orchestrator/error.d.ts.map +0 -1
- package/dist/src/orchestrator/error.js +0 -173
- package/dist/src/orchestrator/index.d.ts +0 -11
- package/dist/src/orchestrator/index.d.ts.map +0 -1
- package/dist/src/orchestrator/index.js +0 -9
- package/dist/src/orchestrator/registry.d.ts +0 -16
- package/dist/src/orchestrator/registry.d.ts.map +0 -1
- package/dist/src/orchestrator/registry.js +0 -90
- package/dist/src/orchestrator/types.d.ts.map +0 -1
- package/dist/src/orchestrator/types.js +0 -15
- package/dist/src/orchestrator/utils.d.ts +0 -3
- package/dist/src/orchestrator/utils.d.ts.map +0 -1
- package/dist/src/orchestrator/utils.js +0 -22
- package/dist/src/types.d.ts +0 -446
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/utils/walletClient.d.ts +0 -34
- package/dist/src/utils/walletClient.d.ts.map +0 -1
- package/dist/src/utils/walletClient.js +0 -117
- /package/dist/src/{types.js → accounts/adapter.js} +0 -0
|
@@ -1,1054 +0,0 @@
|
|
|
1
|
-
import { concat, createPublicClient, createWalletClient, encodeAbiParameters, encodePacked, hashDomain, hashMessage, hashStruct, hashTypedData, isAddress, keccak256, publicActions, toHex, } from 'viem';
|
|
2
|
-
import { entryPoint07Address, getUserOperationHash, } from 'viem/account-abstraction';
|
|
3
|
-
import { wrapTypedDataSignature } from 'viem/experimental/erc7739';
|
|
4
|
-
import { EoaAccountMustHaveAccountError, EoaSigningMethodNotConfiguredError, FactoryArgsNotAvailableError, getAccountProvider, getAddress, getEip712Domain, getEip1271Signature, getEip7702InitCall, getEmissarySignature, getGuardianSmartAccount, getInitCode, getSmartAccount, getTypedDataPackedSignature, is7702, toErc6492Signature, } from '../accounts/index.js';
|
|
5
|
-
import { convertOwnerSetToSignerSet } from '../accounts/signing/common.js';
|
|
6
|
-
import { K1_DEFAULT_VALIDATOR_ADDRESS } from '../accounts/startale.js';
|
|
7
|
-
import { createTransport, getBundlerClient, } from '../accounts/utils.js';
|
|
8
|
-
import { createAuthProvider } from '../auth/provider.js';
|
|
9
|
-
import { buildMockSignature, DUMMY_PRECLAIMOP_SELECTOR, DUMMY_PRECLAIMOP_TARGET, getOwnerValidator, getPermissionId, getSmartSessionValidator, isSessionEnabled, } from '../modules/validators/index.js';
|
|
10
|
-
import { getMultiFactorValidator, getSocialRecoveryValidator, getWebAuthnValidator, supportsEip712, } from '../modules/validators/core.js';
|
|
11
|
-
import { buildPermit2ClaimPolicyCalldata, } from '../modules/validators/policies/claim/permit2.js';
|
|
12
|
-
import { resolvePermit2ClaimPolicy, } from '../modules/validators/smart-sessions.js';
|
|
13
|
-
import { getOrchestrator, } from '../orchestrator/index.js';
|
|
14
|
-
import { getChainById, getTokenAddress, resolveTokenAddress, } from '../orchestrator/registry.js';
|
|
15
|
-
import { SIG_MODE_EMISSARY_EXECUTION_ERC1271, SIG_MODE_ERC1271_EMISSARY, } from '../orchestrator/types.js';
|
|
16
|
-
import { convertBigIntFields } from '../orchestrator/utils.js';
|
|
17
|
-
import { Eip7702InitSignatureRequiredError, QuoteNotInPreparedTransactionError, SignerNotSupportedError, } from './error.js';
|
|
18
|
-
function isResolvedSessionSignerSet(signers) {
|
|
19
|
-
return (signers?.type === 'experimental_session' && 'verifyExecutions' in signers);
|
|
20
|
-
}
|
|
21
|
-
async function resolveSignersForChain(config, signers, chainId) {
|
|
22
|
-
if (signers?.type !== 'experimental_session') {
|
|
23
|
-
return signers;
|
|
24
|
-
}
|
|
25
|
-
const resolved = resolveSessionForChain(signers, chainId);
|
|
26
|
-
const enabled = await isSessionEnabled(getAddress(config), config.provider, resolved.session, config.useDevContracts);
|
|
27
|
-
const enableData = enabled ? undefined : resolved.enableData;
|
|
28
|
-
const verifyExecutions = resolved.verifyExecutions ??
|
|
29
|
-
signers.verifyExecutions ??
|
|
30
|
-
resolved.session.hasExplicitPermissions;
|
|
31
|
-
return {
|
|
32
|
-
type: 'experimental_session',
|
|
33
|
-
session: resolved.session,
|
|
34
|
-
enableData,
|
|
35
|
-
verifyExecutions,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function resolveSessionForChain(signers, chainId) {
|
|
39
|
-
if ('sessions' in signers) {
|
|
40
|
-
const config = signers.sessions[chainId];
|
|
41
|
-
if (!config) {
|
|
42
|
-
throw new Error(`No session configured for chain ${chainId}`);
|
|
43
|
-
}
|
|
44
|
-
return config;
|
|
45
|
-
}
|
|
46
|
-
return { session: signers.session, enableData: signers.enableData };
|
|
47
|
-
}
|
|
48
|
-
async function prepareTransaction(config, transaction) {
|
|
49
|
-
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, auxiliaryFunds, account, recipient, } = getTransactionParams(transaction);
|
|
50
|
-
const accountAddress = getAddress(config);
|
|
51
|
-
const isUserOpSigner = signers?.type === 'guardians';
|
|
52
|
-
if (isUserOpSigner) {
|
|
53
|
-
throw new SignerNotSupportedError();
|
|
54
|
-
}
|
|
55
|
-
const prepared = await prepareTransactionAsIntent(config, sourceChains, targetChain, await resolveCallInputs(transaction.calls, config, targetChain, accountAddress), transaction.gasLimit, tokenRequests, recipient, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, auxiliaryFunds, account, signers);
|
|
56
|
-
return {
|
|
57
|
-
quotes: prepared.quotes,
|
|
58
|
-
intentInput: prepared.intentInput,
|
|
59
|
-
transaction,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
async function prepareUserOperation(config, transaction) {
|
|
63
|
-
const chain = transaction.chain;
|
|
64
|
-
const signers = transaction.signers;
|
|
65
|
-
const accountAddress = getAddress(config);
|
|
66
|
-
const data = await prepareTransactionAsUserOp(config, chain, await resolveCallInputs(transaction.calls, config, chain, accountAddress), signers, transaction.gasLimit);
|
|
67
|
-
return {
|
|
68
|
-
userOperation: data.userOp,
|
|
69
|
-
hash: data.hash,
|
|
70
|
-
transaction,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
async function resolveCallInputs(inputs, config, chain, accountAddress) {
|
|
74
|
-
const resolved = [];
|
|
75
|
-
if (!inputs) {
|
|
76
|
-
return resolved;
|
|
77
|
-
}
|
|
78
|
-
for (const intent of inputs) {
|
|
79
|
-
if ('resolve' in intent) {
|
|
80
|
-
const result = await intent.resolve({ config, chain, accountAddress });
|
|
81
|
-
if (Array.isArray(result)) {
|
|
82
|
-
resolved.push(...result);
|
|
83
|
-
}
|
|
84
|
-
else if (result) {
|
|
85
|
-
resolved.push(result);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
resolved.push(intent);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return resolved;
|
|
93
|
-
}
|
|
94
|
-
function getTransactionMessages(_config, preparedTransaction, options) {
|
|
95
|
-
const quote = resolveQuote(preparedTransaction.quotes, options);
|
|
96
|
-
return getIntentMessages(quote.signData);
|
|
97
|
-
}
|
|
98
|
-
async function signTransaction(config, preparedTransaction, options) {
|
|
99
|
-
const { signers } = getTransactionParams(preparedTransaction.transaction);
|
|
100
|
-
const quote = resolveQuote(preparedTransaction.quotes, options);
|
|
101
|
-
const targetChain = 'targetChain' in preparedTransaction.transaction
|
|
102
|
-
? preparedTransaction.transaction.targetChain
|
|
103
|
-
: preparedTransaction.transaction.chain;
|
|
104
|
-
const { originSignatures, destinationSignature } = await signIntent(config, quote.signData, targetChain, signers, false);
|
|
105
|
-
const targetExecutionSignature = await getTargetExecutionSignature(config, quote.signData, targetChain, signers);
|
|
106
|
-
return {
|
|
107
|
-
quote,
|
|
108
|
-
quotes: preparedTransaction.quotes,
|
|
109
|
-
intentInput: preparedTransaction.intentInput,
|
|
110
|
-
transaction: preparedTransaction.transaction,
|
|
111
|
-
originSignatures,
|
|
112
|
-
destinationSignature,
|
|
113
|
-
targetExecutionSignature,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
function resolveQuote(quotes, options) {
|
|
117
|
-
if (!options)
|
|
118
|
-
return quotes.best;
|
|
119
|
-
const match = quotes.all.find((q) => q.intentId === options.intentId);
|
|
120
|
-
if (!match) {
|
|
121
|
-
throw new QuoteNotInPreparedTransactionError({
|
|
122
|
-
context: { intentId: options.intentId },
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
return match;
|
|
126
|
-
}
|
|
127
|
-
async function getTargetExecutionSignature(config, signData, targetChain, signers) {
|
|
128
|
-
if (signers?.type !== 'experimental_session') {
|
|
129
|
-
return undefined;
|
|
130
|
-
}
|
|
131
|
-
if (!signData.targetExecution) {
|
|
132
|
-
return undefined;
|
|
133
|
-
}
|
|
134
|
-
const resolvedSigners = await resolveSignersForChain(config, signers, targetChain.id);
|
|
135
|
-
if (!isResolvedSessionSignerSet(resolvedSigners) ||
|
|
136
|
-
!resolvedSigners.verifyExecutions) {
|
|
137
|
-
return undefined;
|
|
138
|
-
}
|
|
139
|
-
const validator = getValidator(config, signers);
|
|
140
|
-
if (!validator) {
|
|
141
|
-
throw new Error('Validator not available');
|
|
142
|
-
}
|
|
143
|
-
const ownerValidator = getOwnerValidator(config);
|
|
144
|
-
const isRoot = validator.address === ownerValidator.address;
|
|
145
|
-
const destination = prepareTypedData(signData.targetExecution);
|
|
146
|
-
const signature = await getDestinationSignature(config, resolvedSigners, validator, isRoot, targetChain, destination, [], true);
|
|
147
|
-
return signature;
|
|
148
|
-
}
|
|
149
|
-
async function signUserOperation(config, preparedUserOperation) {
|
|
150
|
-
const chain = preparedUserOperation.transaction.chain;
|
|
151
|
-
const userOp = preparedUserOperation.userOperation;
|
|
152
|
-
const signers = preparedUserOperation.transaction.signers;
|
|
153
|
-
// Smart sessions require a UserOp flow
|
|
154
|
-
const signature = await signUserOp(config, chain, signers, userOp);
|
|
155
|
-
return {
|
|
156
|
-
userOperation: preparedUserOperation.userOperation,
|
|
157
|
-
hash: preparedUserOperation.hash,
|
|
158
|
-
transaction: preparedUserOperation.transaction,
|
|
159
|
-
signature,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
async function signAuthorizations(config, preparedTransaction) {
|
|
163
|
-
const transaction = preparedTransaction.transaction;
|
|
164
|
-
const sourceChains = 'chain' in transaction ? [transaction.chain] : transaction.sourceChains;
|
|
165
|
-
const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
|
|
166
|
-
return await signAuthorizationsInternal(config, {
|
|
167
|
-
sourceChains,
|
|
168
|
-
targetChain,
|
|
169
|
-
eip7702InitSignature: transaction.eip7702InitSignature,
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
async function signMessage(config, message, chain, signers) {
|
|
173
|
-
const validator = getValidator(config, signers);
|
|
174
|
-
if (!validator) {
|
|
175
|
-
throw new Error('Validator not available');
|
|
176
|
-
}
|
|
177
|
-
const ownerValidator = getOwnerValidator(config);
|
|
178
|
-
const isRoot = validator.address === ownerValidator.address;
|
|
179
|
-
const hash = hashMessage(message);
|
|
180
|
-
const signature = await getEip1271Signature(config, signers, chain, {
|
|
181
|
-
address: validator.address,
|
|
182
|
-
isRoot,
|
|
183
|
-
}, hash);
|
|
184
|
-
return await toErc6492Signature(config, signature, chain);
|
|
185
|
-
}
|
|
186
|
-
async function signTypedData(config, parameters, chain, signers, options) {
|
|
187
|
-
const validator = getValidator(config, signers);
|
|
188
|
-
if (!validator) {
|
|
189
|
-
throw new Error('Validator not available');
|
|
190
|
-
}
|
|
191
|
-
const ownerValidator = getOwnerValidator(config);
|
|
192
|
-
const isRoot = validator.address === ownerValidator.address;
|
|
193
|
-
if (signers?.type === 'experimental_session') {
|
|
194
|
-
const resolved = resolveSessionForChain(signers, chain.id);
|
|
195
|
-
return await signTypedDataWithSession(config, chain, {
|
|
196
|
-
address: validator.address,
|
|
197
|
-
isRoot,
|
|
198
|
-
}, resolved.session, parameters);
|
|
199
|
-
}
|
|
200
|
-
const account = getAccountProvider(config);
|
|
201
|
-
if (account.type === 'startale' && supportsEip712(validator)) {
|
|
202
|
-
const isK1 = validator.address.toLowerCase() ===
|
|
203
|
-
K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
204
|
-
if (isK1) {
|
|
205
|
-
const sig = await signErc7739TypedData(config, signers, validator, isRoot, parameters, chain);
|
|
206
|
-
if (!options?.skipErc6492) {
|
|
207
|
-
return await toErc6492Signature(config, sig, chain);
|
|
208
|
-
}
|
|
209
|
-
return sig;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
const signature = await getTypedDataPackedSignature(config, signers, chain, {
|
|
213
|
-
address: validator.address,
|
|
214
|
-
isRoot,
|
|
215
|
-
}, parameters);
|
|
216
|
-
if (!options?.skipErc6492) {
|
|
217
|
-
return await toErc6492Signature(config, signature, chain);
|
|
218
|
-
}
|
|
219
|
-
return signature;
|
|
220
|
-
}
|
|
221
|
-
async function signTypedDataWithSession(config, chain, validator, session, parameters) {
|
|
222
|
-
const { name, version, chainId, verifyingContract, salt } = getEip712Domain(config, chain);
|
|
223
|
-
const signers = convertOwnerSetToSignerSet(session.owners);
|
|
224
|
-
const signature = await getTypedDataPackedSignature(config, signers, chain, validator, {
|
|
225
|
-
domain: parameters.domain,
|
|
226
|
-
primaryType: 'TypedDataSign',
|
|
227
|
-
types: {
|
|
228
|
-
...parameters.types,
|
|
229
|
-
TypedDataSign: [
|
|
230
|
-
{ name: 'contents', type: parameters.primaryType },
|
|
231
|
-
{ name: 'name', type: 'string' },
|
|
232
|
-
{ name: 'version', type: 'string' },
|
|
233
|
-
{ name: 'chainId', type: 'uint256' },
|
|
234
|
-
{ name: 'verifyingContract', type: 'address' },
|
|
235
|
-
{ name: 'salt', type: 'bytes32' },
|
|
236
|
-
],
|
|
237
|
-
},
|
|
238
|
-
message: {
|
|
239
|
-
contents: parameters.message,
|
|
240
|
-
name,
|
|
241
|
-
version,
|
|
242
|
-
chainId,
|
|
243
|
-
verifyingContract,
|
|
244
|
-
salt,
|
|
245
|
-
},
|
|
246
|
-
}, (signature) => {
|
|
247
|
-
const erc7739Signature = wrapTypedDataSignature({
|
|
248
|
-
domain: parameters.domain,
|
|
249
|
-
primaryType: parameters.primaryType,
|
|
250
|
-
types: parameters.types,
|
|
251
|
-
message: parameters.message,
|
|
252
|
-
signature,
|
|
253
|
-
});
|
|
254
|
-
return encodePacked(['bytes32', 'bytes'], [getPermissionId(session), erc7739Signature]);
|
|
255
|
-
});
|
|
256
|
-
return await toErc6492Signature(config, signature, chain);
|
|
257
|
-
}
|
|
258
|
-
async function signAuthorizationsInternal(config, context) {
|
|
259
|
-
const eoa = config.eoa;
|
|
260
|
-
if (!eoa) {
|
|
261
|
-
throw new Error('EIP-7702 initialization is required for EOA accounts');
|
|
262
|
-
}
|
|
263
|
-
const eip7702InitSignature = context.eip7702InitSignature;
|
|
264
|
-
if (!eip7702InitSignature) {
|
|
265
|
-
return [];
|
|
266
|
-
}
|
|
267
|
-
const accountAddress = getAddress(config);
|
|
268
|
-
const { contract: eip7702Contract } = getEip7702InitCall(config, eip7702InitSignature);
|
|
269
|
-
const chains = new Map();
|
|
270
|
-
for (const chain of [...(context.sourceChains ?? []), context.targetChain]) {
|
|
271
|
-
chains.set(chain.id, chain);
|
|
272
|
-
}
|
|
273
|
-
const authorizations = [];
|
|
274
|
-
for (const chain of chains.values()) {
|
|
275
|
-
const walletClient = createWalletClient({
|
|
276
|
-
chain,
|
|
277
|
-
account: eoa,
|
|
278
|
-
transport: createTransport(chain, config.provider),
|
|
279
|
-
}).extend(publicActions);
|
|
280
|
-
const code = await walletClient.getCode({
|
|
281
|
-
address: accountAddress,
|
|
282
|
-
});
|
|
283
|
-
const isDelegated = code === concat(['0xef0100', eip7702Contract.toLowerCase()]);
|
|
284
|
-
if (isDelegated) {
|
|
285
|
-
continue;
|
|
286
|
-
}
|
|
287
|
-
const authorization = await walletClient.signAuthorization({
|
|
288
|
-
contractAddress: eip7702Contract,
|
|
289
|
-
chainId: chain.id,
|
|
290
|
-
});
|
|
291
|
-
authorizations.push(authorization);
|
|
292
|
-
}
|
|
293
|
-
return authorizations;
|
|
294
|
-
}
|
|
295
|
-
async function submitTransaction(config, signedTransaction, authorizations, dryRun = false) {
|
|
296
|
-
const { quote, intentInput, transaction, originSignatures, destinationSignature, targetExecutionSignature, } = signedTransaction;
|
|
297
|
-
const { sourceChains, targetChain } = getTransactionParams(transaction);
|
|
298
|
-
return await submitIntentInternal(config, sourceChains, targetChain, quote, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun, intentInput);
|
|
299
|
-
}
|
|
300
|
-
async function submitUserOperation(config, signedUserOperation) {
|
|
301
|
-
const chain = signedUserOperation.transaction.chain;
|
|
302
|
-
const userOp = signedUserOperation.userOperation;
|
|
303
|
-
const signature = signedUserOperation.signature;
|
|
304
|
-
// Smart sessions require a UserOp flow
|
|
305
|
-
return await submitUserOp(config, chain, userOp, signature);
|
|
306
|
-
}
|
|
307
|
-
function getTransactionParams(transaction) {
|
|
308
|
-
const sourceChains = 'chain' in transaction ? [transaction.chain] : transaction.sourceChains;
|
|
309
|
-
const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
|
|
310
|
-
const initialTokenRequests = transaction.tokenRequests;
|
|
311
|
-
const signers = transaction.signers;
|
|
312
|
-
const eip7702InitSignature = transaction.eip7702InitSignature;
|
|
313
|
-
const sponsored = transaction.sponsored;
|
|
314
|
-
const gasLimit = transaction.gasLimit;
|
|
315
|
-
const settlementLayers = transaction.settlementLayers;
|
|
316
|
-
const sourceAssets = transaction.sourceAssets;
|
|
317
|
-
const feeAsset = transaction.feeAsset;
|
|
318
|
-
const auxiliaryFunds = transaction.auxiliaryFunds;
|
|
319
|
-
const account = transaction.experimental_accountOverride;
|
|
320
|
-
const recipient = transaction.recipient;
|
|
321
|
-
const tokenRequests = getTokenRequests(targetChain, initialTokenRequests);
|
|
322
|
-
return {
|
|
323
|
-
sourceChains,
|
|
324
|
-
targetChain,
|
|
325
|
-
tokenRequests,
|
|
326
|
-
signers,
|
|
327
|
-
sponsored,
|
|
328
|
-
eip7702InitSignature,
|
|
329
|
-
gasLimit,
|
|
330
|
-
settlementLayers,
|
|
331
|
-
sourceAssets,
|
|
332
|
-
feeAsset,
|
|
333
|
-
auxiliaryFunds,
|
|
334
|
-
account,
|
|
335
|
-
recipient,
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
function getTokenRequests(targetChain, initialTokenRequests) {
|
|
339
|
-
if (initialTokenRequests) {
|
|
340
|
-
validateTokenSymbols(targetChain, initialTokenRequests.map((tokenRequest) => tokenRequest.address));
|
|
341
|
-
}
|
|
342
|
-
return initialTokenRequests ?? [];
|
|
343
|
-
}
|
|
344
|
-
async function prepareTransactionAsUserOp(config, chain, callInputs, signers, gasLimit) {
|
|
345
|
-
const publicClient = createPublicClient({
|
|
346
|
-
chain,
|
|
347
|
-
transport: createTransport(chain, config.provider),
|
|
348
|
-
});
|
|
349
|
-
const validatorAccount = await getValidatorAccount(config, signers, publicClient, chain);
|
|
350
|
-
if (!validatorAccount) {
|
|
351
|
-
throw new Error('No validator account found');
|
|
352
|
-
}
|
|
353
|
-
const bundlerClient = getBundlerClient(config, publicClient);
|
|
354
|
-
const calls = parseCalls(callInputs, chain.id);
|
|
355
|
-
const userOp = await bundlerClient.prepareUserOperation({
|
|
356
|
-
account: validatorAccount,
|
|
357
|
-
calls,
|
|
358
|
-
callGasLimit: gasLimit,
|
|
359
|
-
});
|
|
360
|
-
return {
|
|
361
|
-
userOp,
|
|
362
|
-
hash: getUserOperationHash({
|
|
363
|
-
userOperation: userOp,
|
|
364
|
-
chainId: chain.id,
|
|
365
|
-
entryPointAddress: entryPoint07Address,
|
|
366
|
-
entryPointVersion: '0.7',
|
|
367
|
-
}),
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
function getAccountType(accountConfig) {
|
|
371
|
-
if (accountConfig?.type === 'eoa') {
|
|
372
|
-
return 'EOA';
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
return 'ERC7579';
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
function getIntentAccount(config, eip7702InitSignature, account) {
|
|
379
|
-
const accountAddress = getAddress(config);
|
|
380
|
-
const accountType = getAccountType(config.account);
|
|
381
|
-
const { setupOps, delegations } = getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature);
|
|
382
|
-
return {
|
|
383
|
-
address: accountAddress,
|
|
384
|
-
accountType: accountType,
|
|
385
|
-
setupOps: account?.setupOps ?? setupOps,
|
|
386
|
-
delegations,
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, recipientInput, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, auxiliaryFunds, account, signers) {
|
|
390
|
-
const calls = parseCalls(callInputs, targetChain.id);
|
|
391
|
-
const accountAccessList = createAccountAccessList(sourceChains, sourceAssets);
|
|
392
|
-
function getRecipient(recipient) {
|
|
393
|
-
if (typeof recipient === 'string') {
|
|
394
|
-
// Passed as an address, assume it's an EOA
|
|
395
|
-
return {
|
|
396
|
-
address: recipient,
|
|
397
|
-
accountType: 'EOA',
|
|
398
|
-
setupOps: [],
|
|
399
|
-
delegations: undefined,
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
if (!recipient) {
|
|
403
|
-
return undefined;
|
|
404
|
-
}
|
|
405
|
-
return getIntentAccount(recipient, eip7702InitSignature, account);
|
|
406
|
-
}
|
|
407
|
-
const intentAccount = {
|
|
408
|
-
...getIntentAccount(config, eip7702InitSignature, account),
|
|
409
|
-
...(signers?.type === 'experimental_session' && {
|
|
410
|
-
// Per-chain map: enables accurate per-chain session validation gas simulation
|
|
411
|
-
mockSignatures: Object.fromEntries([
|
|
412
|
-
...new Set([
|
|
413
|
-
...(sourceChains ?? []).map((c) => c.id),
|
|
414
|
-
targetChain.id,
|
|
415
|
-
]),
|
|
416
|
-
].map((chainId) => [
|
|
417
|
-
String(chainId),
|
|
418
|
-
buildMockSignature(resolveSessionForChain(signers, chainId).session, config.useDevContracts, sourceChains?.length ?? 1, chainId),
|
|
419
|
-
])),
|
|
420
|
-
}),
|
|
421
|
-
};
|
|
422
|
-
const recipient = getRecipient(recipientInput);
|
|
423
|
-
const signatureMode = signers?.type === 'experimental_session'
|
|
424
|
-
? SIG_MODE_EMISSARY_EXECUTION_ERC1271
|
|
425
|
-
: SIG_MODE_ERC1271_EMISSARY;
|
|
426
|
-
// For session signers that need enabling, pass a dummy preclaimop per source chain
|
|
427
|
-
// so the orchestrator bakes it into the bundle before computing its HMAC. The filler
|
|
428
|
-
// executes the op via verifyExecution in ENABLE mode, enabling the session on-chain
|
|
429
|
-
// without a separate UserOp. Must be sent in the routing request — not injected
|
|
430
|
-
// post-facto — because the orchestrator HMAC covers preClaimOps.
|
|
431
|
-
const preClaimExecutions = {};
|
|
432
|
-
if (signers?.type === 'experimental_session' && sourceChains) {
|
|
433
|
-
const resolvedPerChain = await Promise.all(sourceChains.map(async (chain) => ({
|
|
434
|
-
chainId: chain.id,
|
|
435
|
-
resolved: await resolveSignersForChain(config, signers, chain.id),
|
|
436
|
-
})));
|
|
437
|
-
for (const { chainId, resolved } of resolvedPerChain) {
|
|
438
|
-
if (!isResolvedSessionSignerSet(resolved))
|
|
439
|
-
continue;
|
|
440
|
-
const { enableData, verifyExecutions } = resolved;
|
|
441
|
-
if (!verifyExecutions || !enableData)
|
|
442
|
-
continue;
|
|
443
|
-
preClaimExecutions[chainId] = [
|
|
444
|
-
{
|
|
445
|
-
to: DUMMY_PRECLAIMOP_TARGET,
|
|
446
|
-
value: 0n,
|
|
447
|
-
data: DUMMY_PRECLAIMOP_SELECTOR,
|
|
448
|
-
},
|
|
449
|
-
];
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
const metaIntent = {
|
|
453
|
-
destinationChainId: targetChain.id,
|
|
454
|
-
tokenRequests: tokenRequests.map((tokenRequest) => ({
|
|
455
|
-
tokenAddress: resolveTokenAddress(tokenRequest.address, targetChain.id),
|
|
456
|
-
amount: tokenRequest.amount,
|
|
457
|
-
})),
|
|
458
|
-
recipient,
|
|
459
|
-
account: intentAccount,
|
|
460
|
-
destinationExecutions: calls,
|
|
461
|
-
destinationGasUnits: gasLimit,
|
|
462
|
-
accountAccessList,
|
|
463
|
-
options: {
|
|
464
|
-
feeToken: feeAsset,
|
|
465
|
-
sponsorSettings: sponsored
|
|
466
|
-
? typeof sponsored === 'object'
|
|
467
|
-
? {
|
|
468
|
-
gas: sponsored.gas,
|
|
469
|
-
bridgeFees: sponsored.bridging,
|
|
470
|
-
swapFees: sponsored.swaps,
|
|
471
|
-
}
|
|
472
|
-
: {
|
|
473
|
-
gas: sponsored,
|
|
474
|
-
bridgeFees: sponsored,
|
|
475
|
-
swapFees: sponsored,
|
|
476
|
-
}
|
|
477
|
-
: undefined,
|
|
478
|
-
settlementLayers,
|
|
479
|
-
signatureMode,
|
|
480
|
-
auxiliaryFunds,
|
|
481
|
-
},
|
|
482
|
-
...(Object.keys(preClaimExecutions).length > 0 && { preClaimExecutions }),
|
|
483
|
-
};
|
|
484
|
-
const serializedIntent = convertBigIntFields(metaIntent);
|
|
485
|
-
const orchestrator = getOrchestrator(config._authProvider ?? createAuthProvider(config), config.endpointUrl, config.headers);
|
|
486
|
-
const { routes } = await orchestrator.createQuote(metaIntent);
|
|
487
|
-
const best = routes[0];
|
|
488
|
-
if (!best) {
|
|
489
|
-
throw new Error('Orchestrator returned no quote');
|
|
490
|
-
}
|
|
491
|
-
return {
|
|
492
|
-
quotes: { best, all: routes },
|
|
493
|
-
intentInput: serializedIntent,
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
async function signIntent(config, signData, targetChain, signers, targetExecution) {
|
|
497
|
-
const { origin, destination } = getIntentMessages(signData);
|
|
498
|
-
if (config.account?.type === 'eoa') {
|
|
499
|
-
const eoa = config.eoa;
|
|
500
|
-
if (!eoa) {
|
|
501
|
-
throw new EoaAccountMustHaveAccountError();
|
|
502
|
-
}
|
|
503
|
-
const originSignatures = [];
|
|
504
|
-
for (const typedData of origin) {
|
|
505
|
-
if (eoa.signTypedData) {
|
|
506
|
-
const signature = await eoa.signTypedData(typedData);
|
|
507
|
-
originSignatures.push(signature);
|
|
508
|
-
}
|
|
509
|
-
else {
|
|
510
|
-
throw new EoaSigningMethodNotConfiguredError('signTypedData');
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
const destinationSignature = originSignatures.at(-1);
|
|
514
|
-
return {
|
|
515
|
-
originSignatures,
|
|
516
|
-
destinationSignature,
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
const validator = getValidator(config, signers);
|
|
520
|
-
if (!validator) {
|
|
521
|
-
throw new Error('Validator not available');
|
|
522
|
-
}
|
|
523
|
-
const ownerValidator = getOwnerValidator(config);
|
|
524
|
-
const isRoot = validator.address === ownerValidator.address;
|
|
525
|
-
const originSignatures = [];
|
|
526
|
-
for (const typedData of origin) {
|
|
527
|
-
const chain = getChainById(typedData.domain?.chainId);
|
|
528
|
-
const originSigners = await resolveSignersForChain(config, signers, chain.id);
|
|
529
|
-
const signature = await signIntentTypedData(config, originSigners, validator, isRoot, typedData, chain, targetExecution ?? false);
|
|
530
|
-
originSignatures.push(signature);
|
|
531
|
-
}
|
|
532
|
-
const destinationSigners = await resolveSignersForChain(config, signers, targetChain.id);
|
|
533
|
-
const destinationSignature = await getDestinationSignature(config, destinationSigners, validator, isRoot, targetChain, destination, originSignatures, targetExecution ?? false);
|
|
534
|
-
return {
|
|
535
|
-
originSignatures,
|
|
536
|
-
destinationSignature,
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
async function getDestinationSignature(config, signers, validator, isRoot, targetChain, destination, originSignatures, targetExecution) {
|
|
540
|
-
// Smart sessions require a separate destination signature because the
|
|
541
|
-
// session enable data differs per chain
|
|
542
|
-
if (signers?.type === 'experimental_session') {
|
|
543
|
-
return await signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution);
|
|
544
|
-
}
|
|
545
|
-
// ERC-7739 with K1 validator requires a separate destination signature because
|
|
546
|
-
// the account's eip712Domain() returns the target chain's chainId, which differs
|
|
547
|
-
// from the origin chain used for the last origin signature
|
|
548
|
-
const isK1Validator = validator.address.toLowerCase() ===
|
|
549
|
-
K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
550
|
-
if (isK1Validator && supportsEip712(validator)) {
|
|
551
|
-
return await signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution);
|
|
552
|
-
}
|
|
553
|
-
const lastOriginSignature = originSignatures.at(-1);
|
|
554
|
-
return typeof lastOriginSignature === 'object'
|
|
555
|
-
? lastOriginSignature.preClaimSig
|
|
556
|
-
: (lastOriginSignature ?? '0x');
|
|
557
|
-
}
|
|
558
|
-
async function signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution) {
|
|
559
|
-
const destinationChain = getChainById(targetChain.id);
|
|
560
|
-
const destinationSignatures = await signIntentTypedData(config, signers, validator, isRoot, destination, destinationChain, targetExecution);
|
|
561
|
-
return typeof destinationSignatures === 'object'
|
|
562
|
-
? destinationSignatures.preClaimSig
|
|
563
|
-
: (destinationSignatures ?? '0x');
|
|
564
|
-
}
|
|
565
|
-
function getIntentMessages(signData) {
|
|
566
|
-
return {
|
|
567
|
-
origin: signData.origin.map(prepareTypedData),
|
|
568
|
-
destination: prepareTypedData(signData.destination),
|
|
569
|
-
targetExecution: signData.targetExecution
|
|
570
|
-
? prepareTypedData(signData.targetExecution)
|
|
571
|
-
: undefined,
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
// Server emits uint*/int* values as decimal strings; viem's hashTypedData
|
|
575
|
-
// expects bigint. Walk the message tree against the type schema and coerce
|
|
576
|
-
// numeric fields back to bigint before signing.
|
|
577
|
-
function prepareTypedData(td) {
|
|
578
|
-
const types = td.types;
|
|
579
|
-
return {
|
|
580
|
-
...td,
|
|
581
|
-
message: coerceTypedDataMessage(types, td.primaryType, td.message),
|
|
582
|
-
};
|
|
583
|
-
}
|
|
584
|
-
function coerceTypedDataMessage(types, primaryType, message) {
|
|
585
|
-
const fields = types[primaryType];
|
|
586
|
-
if (!fields)
|
|
587
|
-
return message;
|
|
588
|
-
const result = { ...message };
|
|
589
|
-
for (const { name, type } of fields) {
|
|
590
|
-
if (name in message) {
|
|
591
|
-
result[name] = coerceTypedDataValue(types, type, message[name]);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
return result;
|
|
595
|
-
}
|
|
596
|
-
function coerceTypedDataValue(types, type, value) {
|
|
597
|
-
if (value === null || value === undefined)
|
|
598
|
-
return value;
|
|
599
|
-
const arrayMatch = type.match(/^(.+)\[\d*\]$/);
|
|
600
|
-
if (arrayMatch) {
|
|
601
|
-
const elementType = arrayMatch[1];
|
|
602
|
-
if (!Array.isArray(value))
|
|
603
|
-
return value;
|
|
604
|
-
return value.map((v) => coerceTypedDataValue(types, elementType, v));
|
|
605
|
-
}
|
|
606
|
-
if (/^u?int\d*$/.test(type)) {
|
|
607
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
608
|
-
return BigInt(value);
|
|
609
|
-
}
|
|
610
|
-
return value;
|
|
611
|
-
}
|
|
612
|
-
if (types[type]) {
|
|
613
|
-
return coerceTypedDataMessage(types, type, value);
|
|
614
|
-
}
|
|
615
|
-
return value;
|
|
616
|
-
}
|
|
617
|
-
/** Computes claim policy calldata when parameters are Permit2 typed data with claim policies. */
|
|
618
|
-
function resolveClaimPolicyData(signers, parameters) {
|
|
619
|
-
if (parameters.primaryType !== 'PermitBatchWitnessTransferFrom' ||
|
|
620
|
-
!signers.session.claimPolicies.length) {
|
|
621
|
-
return undefined;
|
|
622
|
-
}
|
|
623
|
-
const msg = parameters.message;
|
|
624
|
-
if (!msg.permitted ||
|
|
625
|
-
!msg.mandate ||
|
|
626
|
-
typeof msg.spender !== 'string' ||
|
|
627
|
-
typeof msg.nonce !== 'bigint' ||
|
|
628
|
-
typeof msg.deadline !== 'bigint') {
|
|
629
|
-
return undefined;
|
|
630
|
-
}
|
|
631
|
-
return buildPermit2ClaimPolicyCalldata(resolvePermit2ClaimPolicy(signers.session.claimPolicies[0]), parameters.message);
|
|
632
|
-
}
|
|
633
|
-
async function signIntentTypedData(config, signers, validator, isRoot, parameters, chain, targetExecution) {
|
|
634
|
-
if (supportsEip712(validator)) {
|
|
635
|
-
const isK1Validator = validator.address.toLowerCase() ===
|
|
636
|
-
K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
637
|
-
if (isK1Validator) {
|
|
638
|
-
return await signErc7739TypedData(config, signers, validator, isRoot, parameters, chain);
|
|
639
|
-
}
|
|
640
|
-
return await getTypedDataPackedSignature(config, signers, chain, {
|
|
641
|
-
address: validator.address,
|
|
642
|
-
isRoot,
|
|
643
|
-
}, parameters);
|
|
644
|
-
}
|
|
645
|
-
const hash = hashTypedData(parameters);
|
|
646
|
-
if (isResolvedSessionSignerSet(signers) && signers.verifyExecutions) {
|
|
647
|
-
if (targetExecution) {
|
|
648
|
-
const targetSigners = {
|
|
649
|
-
type: 'experimental_session',
|
|
650
|
-
session: signers.session,
|
|
651
|
-
verifyExecutions: true,
|
|
652
|
-
enableData: signers.enableData,
|
|
653
|
-
};
|
|
654
|
-
// signWithSession (called inside getEmissarySignature) already calls packSignature
|
|
655
|
-
// internally, so no transform is needed here
|
|
656
|
-
return await getEmissarySignature(config, targetSigners, chain, hash);
|
|
657
|
-
}
|
|
658
|
-
const claimPolicyData = resolveClaimPolicyData(signers, parameters);
|
|
659
|
-
const sessionSignersForEip1271 = {
|
|
660
|
-
type: 'experimental_session',
|
|
661
|
-
session: signers.session,
|
|
662
|
-
verifyExecutions: false,
|
|
663
|
-
enableData: signers.enableData,
|
|
664
|
-
claimPolicyData,
|
|
665
|
-
};
|
|
666
|
-
const eip1271Signature = await getEip1271Signature(config, sessionSignersForEip1271, chain, {
|
|
667
|
-
address: validator.address,
|
|
668
|
-
isRoot,
|
|
669
|
-
}, hash);
|
|
670
|
-
const emissarySignature = await getEmissarySignature(config, {
|
|
671
|
-
type: 'experimental_session',
|
|
672
|
-
session: signers.session,
|
|
673
|
-
verifyExecutions: true,
|
|
674
|
-
enableData: signers.enableData,
|
|
675
|
-
}, chain, hash);
|
|
676
|
-
return {
|
|
677
|
-
preClaimSig: emissarySignature,
|
|
678
|
-
notarizedClaimSig: eip1271Signature,
|
|
679
|
-
};
|
|
680
|
-
}
|
|
681
|
-
if (isResolvedSessionSignerSet(signers)) {
|
|
682
|
-
const claimPolicyData = resolveClaimPolicyData(signers, parameters);
|
|
683
|
-
return await getEip1271Signature(config, claimPolicyData !== undefined ? { ...signers, claimPolicyData } : signers, chain, {
|
|
684
|
-
address: validator.address,
|
|
685
|
-
isRoot,
|
|
686
|
-
}, hash);
|
|
687
|
-
}
|
|
688
|
-
return await getEip1271Signature(config, signers, chain, {
|
|
689
|
-
address: validator.address,
|
|
690
|
-
isRoot,
|
|
691
|
-
}, hash);
|
|
692
|
-
}
|
|
693
|
-
async function signUserOp(config, chain, signers, userOp) {
|
|
694
|
-
const validator = getValidator(config, signers);
|
|
695
|
-
if (!validator) {
|
|
696
|
-
throw new Error('Validator not available');
|
|
697
|
-
}
|
|
698
|
-
const publicClient = createPublicClient({
|
|
699
|
-
chain,
|
|
700
|
-
transport: createTransport(chain, config.provider),
|
|
701
|
-
});
|
|
702
|
-
const account = await getValidatorAccount(config, signers, publicClient, chain);
|
|
703
|
-
if (!account) {
|
|
704
|
-
throw new Error('No account found');
|
|
705
|
-
}
|
|
706
|
-
return await account.signUserOperation(userOp);
|
|
707
|
-
}
|
|
708
|
-
async function submitUserOp(config, chain, userOp, signature) {
|
|
709
|
-
const publicClient = createPublicClient({
|
|
710
|
-
chain,
|
|
711
|
-
transport: createTransport(chain, config.provider),
|
|
712
|
-
});
|
|
713
|
-
const bundlerClient = getBundlerClient(config, publicClient);
|
|
714
|
-
const hash = await bundlerClient.request({
|
|
715
|
-
method: 'eth_sendUserOperation',
|
|
716
|
-
params: [
|
|
717
|
-
{
|
|
718
|
-
sender: userOp.sender,
|
|
719
|
-
nonce: toHex(userOp.nonce),
|
|
720
|
-
factory: userOp.factory,
|
|
721
|
-
factoryData: userOp.factoryData,
|
|
722
|
-
callData: userOp.callData,
|
|
723
|
-
callGasLimit: toHex(userOp.callGasLimit),
|
|
724
|
-
verificationGasLimit: toHex(userOp.verificationGasLimit),
|
|
725
|
-
preVerificationGas: toHex(userOp.preVerificationGas),
|
|
726
|
-
maxPriorityFeePerGas: toHex(userOp.maxPriorityFeePerGas),
|
|
727
|
-
maxFeePerGas: toHex(userOp.maxFeePerGas),
|
|
728
|
-
paymaster: userOp.paymaster,
|
|
729
|
-
paymasterVerificationGasLimit: userOp.paymasterVerificationGasLimit
|
|
730
|
-
? toHex(userOp.paymasterVerificationGasLimit)
|
|
731
|
-
: undefined,
|
|
732
|
-
paymasterPostOpGasLimit: userOp.paymasterPostOpGasLimit
|
|
733
|
-
? toHex(userOp.paymasterPostOpGasLimit)
|
|
734
|
-
: undefined,
|
|
735
|
-
paymasterData: userOp.paymasterData,
|
|
736
|
-
signature,
|
|
737
|
-
},
|
|
738
|
-
entryPoint07Address,
|
|
739
|
-
],
|
|
740
|
-
});
|
|
741
|
-
return {
|
|
742
|
-
type: 'userop',
|
|
743
|
-
hash,
|
|
744
|
-
chain: chain.id,
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
async function submitIntentInternal(config, sourceChains, targetChain, quote, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun, intentInput) {
|
|
748
|
-
const request = {
|
|
749
|
-
intentId: quote.intentId,
|
|
750
|
-
signatures: {
|
|
751
|
-
origin: originSignatures,
|
|
752
|
-
destination: destinationSignature,
|
|
753
|
-
...(targetExecutionSignature !== undefined && {
|
|
754
|
-
targetExecution: targetExecutionSignature,
|
|
755
|
-
}),
|
|
756
|
-
},
|
|
757
|
-
...(authorizations.length > 0 && {
|
|
758
|
-
authorizations: {
|
|
759
|
-
sponsor: authorizations.map((authorization) => ({
|
|
760
|
-
chainId: authorization.chainId,
|
|
761
|
-
address: authorization.address,
|
|
762
|
-
nonce: authorization.nonce,
|
|
763
|
-
yParity: authorization.yParity ?? 0,
|
|
764
|
-
r: authorization.r,
|
|
765
|
-
s: authorization.s,
|
|
766
|
-
})),
|
|
767
|
-
},
|
|
768
|
-
}),
|
|
769
|
-
...(dryRun && { options: { dryRun: true } }),
|
|
770
|
-
};
|
|
771
|
-
const isSponsored = !!intentInput?.options?.sponsorSettings;
|
|
772
|
-
const orchestrator = getOrchestrator(config._authProvider ?? createAuthProvider(config), config.endpointUrl, config.headers);
|
|
773
|
-
const response = await orchestrator.createIntent(request, intentInput ? { intentInput, isSponsored } : undefined);
|
|
774
|
-
return {
|
|
775
|
-
type: 'intent',
|
|
776
|
-
id: response.intentId,
|
|
777
|
-
sourceChains: sourceChains?.map((chain) => chain.id),
|
|
778
|
-
targetChain: targetChain.id,
|
|
779
|
-
};
|
|
780
|
-
}
|
|
781
|
-
async function getValidatorAccount(config, signers, publicClient, chain) {
|
|
782
|
-
if (!signers) {
|
|
783
|
-
return getSmartAccount(config, publicClient, chain);
|
|
784
|
-
}
|
|
785
|
-
// Owners
|
|
786
|
-
const withOwner = signers.type === 'owner' ? signers : null;
|
|
787
|
-
if (withOwner) {
|
|
788
|
-
return getSmartAccount(config, publicClient, chain);
|
|
789
|
-
}
|
|
790
|
-
const withGuardians = signers.type === 'guardians' ? signers : null;
|
|
791
|
-
return withGuardians
|
|
792
|
-
? await getGuardianSmartAccount(config, publicClient, chain, {
|
|
793
|
-
type: 'ecdsa',
|
|
794
|
-
accounts: withGuardians.guardians,
|
|
795
|
-
})
|
|
796
|
-
: null;
|
|
797
|
-
}
|
|
798
|
-
function getValidator(config, signers) {
|
|
799
|
-
if (!signers) {
|
|
800
|
-
return getOwnerValidator(config);
|
|
801
|
-
}
|
|
802
|
-
// Owners
|
|
803
|
-
const withOwner = signers.type === 'owner' ? signers : null;
|
|
804
|
-
if (withOwner) {
|
|
805
|
-
// ECDSA
|
|
806
|
-
if (withOwner.kind === 'ecdsa') {
|
|
807
|
-
// Use the configured owner validator (e.g., ENS) rather than forcing Ownable
|
|
808
|
-
return getOwnerValidator(config);
|
|
809
|
-
}
|
|
810
|
-
// Passkeys (WebAuthn)
|
|
811
|
-
if (withOwner.kind === 'passkey') {
|
|
812
|
-
return getWebAuthnValidator(1, withOwner.accounts.map((account) => ({
|
|
813
|
-
pubKey: account.publicKey,
|
|
814
|
-
authenticatorId: account.id,
|
|
815
|
-
})));
|
|
816
|
-
}
|
|
817
|
-
// Multi-factor
|
|
818
|
-
if (withOwner.kind === 'multi-factor') {
|
|
819
|
-
return getMultiFactorValidator(1, withOwner.validators);
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
// Smart sessions
|
|
823
|
-
const withSession = signers.type === 'experimental_session';
|
|
824
|
-
if (withSession) {
|
|
825
|
-
return getSmartSessionValidator(config);
|
|
826
|
-
}
|
|
827
|
-
// Guardians (social recovery)
|
|
828
|
-
const withGuardians = signers.type === 'guardians' ? signers : null;
|
|
829
|
-
if (withGuardians) {
|
|
830
|
-
return getSocialRecoveryValidator(withGuardians.guardians);
|
|
831
|
-
}
|
|
832
|
-
// Fallback
|
|
833
|
-
return undefined;
|
|
834
|
-
}
|
|
835
|
-
function parseCalls(calls, chainId) {
|
|
836
|
-
return calls.map((call) => ({
|
|
837
|
-
data: call.data ?? '0x',
|
|
838
|
-
value: call.value ?? 0n,
|
|
839
|
-
to: resolveTokenAddress(call.to, chainId),
|
|
840
|
-
}));
|
|
841
|
-
}
|
|
842
|
-
function createAccountAccessList(sourceChains, sourceAssets) {
|
|
843
|
-
if (!sourceChains && !sourceAssets)
|
|
844
|
-
return undefined;
|
|
845
|
-
const chainIds = sourceChains?.map((chain) => chain.id);
|
|
846
|
-
if (!sourceAssets)
|
|
847
|
-
return { chainIds };
|
|
848
|
-
if (Array.isArray(sourceAssets)) {
|
|
849
|
-
const isExactConfig = sourceAssets.length > 0 && typeof sourceAssets[0] !== 'string';
|
|
850
|
-
if (isExactConfig) {
|
|
851
|
-
const chainTokens = {};
|
|
852
|
-
const chainTokenAmounts = {};
|
|
853
|
-
for (const config of sourceAssets) {
|
|
854
|
-
const chainId = config.chain.id;
|
|
855
|
-
const tokenAddress = resolveTokenAddress(config.address, config.chain.id);
|
|
856
|
-
if (config.amount !== undefined) {
|
|
857
|
-
if (!chainTokenAmounts[chainId])
|
|
858
|
-
chainTokenAmounts[chainId] = {};
|
|
859
|
-
chainTokenAmounts[chainId][tokenAddress] = config.amount;
|
|
860
|
-
}
|
|
861
|
-
else {
|
|
862
|
-
if (!chainTokens[chainId])
|
|
863
|
-
chainTokens[chainId] = [];
|
|
864
|
-
chainTokens[chainId].push(tokenAddress);
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
const out = {};
|
|
868
|
-
if (Object.keys(chainTokens).length > 0) {
|
|
869
|
-
out.chainTokens =
|
|
870
|
-
chainTokens;
|
|
871
|
-
}
|
|
872
|
-
if (Object.keys(chainTokenAmounts).length > 0) {
|
|
873
|
-
out.chainTokenAmounts =
|
|
874
|
-
chainTokenAmounts;
|
|
875
|
-
}
|
|
876
|
-
return out;
|
|
877
|
-
}
|
|
878
|
-
return chainIds
|
|
879
|
-
? { chainIds, tokens: sourceAssets }
|
|
880
|
-
: { tokens: sourceAssets };
|
|
881
|
-
}
|
|
882
|
-
return { chainTokens: sourceAssets };
|
|
883
|
-
}
|
|
884
|
-
function getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature) {
|
|
885
|
-
const initCode = getInitCode(config);
|
|
886
|
-
if (config.account?.type === 'eoa') {
|
|
887
|
-
return {
|
|
888
|
-
setupOps: [],
|
|
889
|
-
};
|
|
890
|
-
}
|
|
891
|
-
else if (is7702(config)) {
|
|
892
|
-
// EIP-7702 initialization is only needed for EOA accounts
|
|
893
|
-
if (!eip7702InitSignature || eip7702InitSignature === '0x') {
|
|
894
|
-
throw new Eip7702InitSignatureRequiredError();
|
|
895
|
-
}
|
|
896
|
-
const { initData: eip7702InitData, contract: eip7702Contract } = getEip7702InitCall(config, eip7702InitSignature);
|
|
897
|
-
return {
|
|
898
|
-
setupOps: [
|
|
899
|
-
{
|
|
900
|
-
to: accountAddress,
|
|
901
|
-
data: eip7702InitData,
|
|
902
|
-
},
|
|
903
|
-
],
|
|
904
|
-
delegations: {
|
|
905
|
-
0: {
|
|
906
|
-
contract: eip7702Contract,
|
|
907
|
-
},
|
|
908
|
-
},
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
else if (initCode) {
|
|
912
|
-
const to = 'factory' in initCode ? initCode.factory : undefined;
|
|
913
|
-
const data = 'factory' in initCode ? initCode.factoryData : undefined;
|
|
914
|
-
if (!to || !data) {
|
|
915
|
-
// Check if it's a migrated account with address-only initData
|
|
916
|
-
if (config.initData && !('factory' in config.initData)) {
|
|
917
|
-
// Assume the account is already deployed
|
|
918
|
-
return {
|
|
919
|
-
setupOps: [],
|
|
920
|
-
};
|
|
921
|
-
}
|
|
922
|
-
throw new FactoryArgsNotAvailableError();
|
|
923
|
-
}
|
|
924
|
-
// Contract account with init code
|
|
925
|
-
return {
|
|
926
|
-
setupOps: [
|
|
927
|
-
{
|
|
928
|
-
to,
|
|
929
|
-
data,
|
|
930
|
-
},
|
|
931
|
-
],
|
|
932
|
-
};
|
|
933
|
-
}
|
|
934
|
-
else {
|
|
935
|
-
// Already deployed contract account
|
|
936
|
-
return {
|
|
937
|
-
setupOps: [],
|
|
938
|
-
};
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
function validateTokenSymbols(chain, tokenAddressOrSymbols) {
|
|
942
|
-
function validateTokenSymbol(chain, addressOrSymbol) {
|
|
943
|
-
// Address
|
|
944
|
-
if (isAddress(addressOrSymbol, { strict: false })) {
|
|
945
|
-
return true;
|
|
946
|
-
}
|
|
947
|
-
// Token symbol
|
|
948
|
-
const address = getTokenAddress(addressOrSymbol, chain.id);
|
|
949
|
-
return isAddress(address, { strict: false });
|
|
950
|
-
}
|
|
951
|
-
for (const addressOrSymbol of tokenAddressOrSymbols) {
|
|
952
|
-
if (!validateTokenSymbol(chain, addressOrSymbol)) {
|
|
953
|
-
throw new Error(`Invalid token symbol: ${addressOrSymbol}`);
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
// Signs typed data using ERC-7739 nested EIP-712 for Startale accounts.
|
|
958
|
-
// Uses a Solady-compatible TypedDataSign hash and wraps the signature with
|
|
959
|
-
// the app domain separator and contents hash for on-chain verification.
|
|
960
|
-
async function signErc7739TypedData(config, signers, validator, isRoot, parameters, chain) {
|
|
961
|
-
const verifierDomain = getEip712Domain(config, chain);
|
|
962
|
-
const hash = hashErc7739TypedDataForSolady({
|
|
963
|
-
domain: parameters.domain,
|
|
964
|
-
types: parameters.types,
|
|
965
|
-
primaryType: parameters.primaryType,
|
|
966
|
-
message: parameters.message,
|
|
967
|
-
verifierDomain,
|
|
968
|
-
});
|
|
969
|
-
return await getEip1271Signature(config, signers, chain, {
|
|
970
|
-
address: validator.address,
|
|
971
|
-
isRoot,
|
|
972
|
-
}, hash, (signature) => wrapTypedDataSignature({
|
|
973
|
-
domain: parameters.domain,
|
|
974
|
-
primaryType: parameters.primaryType,
|
|
975
|
-
types: parameters.types,
|
|
976
|
-
message: parameters.message,
|
|
977
|
-
signature,
|
|
978
|
-
}));
|
|
979
|
-
}
|
|
980
|
-
// Computes an ERC-7739 TypedDataSign hash compatible with Solady's ERC1271
|
|
981
|
-
// on-chain verification. Solady constructs the TypedDataSign type string by
|
|
982
|
-
// appending the contentsType directly after the TypedDataSign definition,
|
|
983
|
-
// which differs from viem's standard EIP-712 encodeType that re-sorts all
|
|
984
|
-
// referenced types alphabetically.
|
|
985
|
-
function hashErc7739TypedDataForSolady({ domain, types, primaryType, message, verifierDomain, }) {
|
|
986
|
-
// Standard EIP-712 encodeType for the original content type
|
|
987
|
-
function encodeTypeString(primary, allTypes) {
|
|
988
|
-
const deps = new Set();
|
|
989
|
-
function findDeps(t) {
|
|
990
|
-
const match = t.match(/^\w*/);
|
|
991
|
-
const typeName = match?.[0];
|
|
992
|
-
if (!typeName || deps.has(typeName) || !allTypes[typeName])
|
|
993
|
-
return;
|
|
994
|
-
deps.add(typeName);
|
|
995
|
-
for (const field of allTypes[typeName])
|
|
996
|
-
findDeps(field.type);
|
|
997
|
-
}
|
|
998
|
-
findDeps(primary);
|
|
999
|
-
deps.delete(primary);
|
|
1000
|
-
const sorted = [primary, ...Array.from(deps).sort()];
|
|
1001
|
-
return sorted
|
|
1002
|
-
.map((t) => `${t}(${allTypes[t].map((f) => `${f.type} ${f.name}`).join(',')})`)
|
|
1003
|
-
.join('');
|
|
1004
|
-
}
|
|
1005
|
-
const contentsType = encodeTypeString(primaryType, types);
|
|
1006
|
-
const contentsName = primaryType;
|
|
1007
|
-
// Construct TypedDataSign type string matching Solady's on-chain encoding:
|
|
1008
|
-
// TypedDataSign(<contentsName> contents,...salt) + contentsType
|
|
1009
|
-
const typedDataSignTypeString = `TypedDataSign(${contentsName} contents,string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)${contentsType}`;
|
|
1010
|
-
const typedDataSignTypeHash = keccak256(toHex(typedDataSignTypeString));
|
|
1011
|
-
// Hash the original content struct
|
|
1012
|
-
const contentsHash = hashStruct({
|
|
1013
|
-
data: message,
|
|
1014
|
-
primaryType,
|
|
1015
|
-
types: types,
|
|
1016
|
-
});
|
|
1017
|
-
// Compute the TypedDataSign struct hash
|
|
1018
|
-
const structHash = keccak256(encodeAbiParameters([
|
|
1019
|
-
{ type: 'bytes32' },
|
|
1020
|
-
{ type: 'bytes32' },
|
|
1021
|
-
{ type: 'bytes32' },
|
|
1022
|
-
{ type: 'bytes32' },
|
|
1023
|
-
{ type: 'uint256' },
|
|
1024
|
-
{ type: 'address' },
|
|
1025
|
-
{ type: 'bytes32' },
|
|
1026
|
-
], [
|
|
1027
|
-
typedDataSignTypeHash,
|
|
1028
|
-
contentsHash,
|
|
1029
|
-
keccak256(toHex(verifierDomain.name)),
|
|
1030
|
-
keccak256(toHex(verifierDomain.version)),
|
|
1031
|
-
BigInt(verifierDomain.chainId),
|
|
1032
|
-
verifierDomain.verifyingContract,
|
|
1033
|
-
verifierDomain.salt,
|
|
1034
|
-
]));
|
|
1035
|
-
// Compute the app domain separator
|
|
1036
|
-
const domainTypes = [];
|
|
1037
|
-
if (domain.name)
|
|
1038
|
-
domainTypes.push({ name: 'name', type: 'string' });
|
|
1039
|
-
if (domain.version)
|
|
1040
|
-
domainTypes.push({ name: 'version', type: 'string' });
|
|
1041
|
-
if (domain.chainId)
|
|
1042
|
-
domainTypes.push({ name: 'chainId', type: 'uint256' });
|
|
1043
|
-
if (domain.verifyingContract)
|
|
1044
|
-
domainTypes.push({ name: 'verifyingContract', type: 'address' });
|
|
1045
|
-
if (domain.salt)
|
|
1046
|
-
domainTypes.push({ name: 'salt', type: 'bytes32' });
|
|
1047
|
-
const appDomainSeparator = hashDomain({
|
|
1048
|
-
domain,
|
|
1049
|
-
types: { EIP712Domain: domainTypes },
|
|
1050
|
-
});
|
|
1051
|
-
// Final hash: keccak256("\x19\x01" || appDomainSep || structHash)
|
|
1052
|
-
return keccak256(concat(['0x1901', appDomainSeparator, structHash]));
|
|
1053
|
-
}
|
|
1054
|
-
export { prepareTransaction, getTransactionMessages, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, getIntentAccount, getTargetExecutionSignature, hashErc7739TypedDataForSolady, resolveSessionForChain, };
|