@fased/fased 0.1.62 → 0.1.65
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/CHANGELOG.md +48 -0
- package/README.md +44 -29
- package/config/dependency-ownership.json +1 -1
- package/config/signer-policies/README.md +58 -0
- package/config/signer-policies/agent.json.template +32 -0
- package/config/signer-policies/mining.json.template +69 -0
- package/config/signer-policies/network.json.template +5 -0
- package/config/signer-policies/vault.json.template +70 -0
- package/config/signer-protocol-v2.json +78 -0
- package/config/typescript-noemit-baseline.json +680 -0
- package/dist/agents/auth-profiles/store.js +267 -31
- package/dist/agents/bash-tools.exec.js +10 -4
- package/dist/agents/current-model-catalog.js +3 -3
- package/dist/agents/memory-search.js +7 -1
- package/dist/agents/model-catalog-access.js +1 -2
- package/dist/agents/model-catalog-snapshot.js +1 -1
- package/dist/agents/model-catalog-source.js +1 -1
- package/dist/agents/model-metadata.js +1 -1
- package/dist/agents/model-selection.js +2 -28
- package/dist/agents/models-config.providers.js +6 -6
- package/dist/agents/pi-embedded-runner/compact.js +15 -7
- package/dist/agents/pi-embedded-runner/model.js +1 -1
- package/dist/agents/pi-embedded-runner/run/attempt.js +24 -13
- package/dist/agents/pi-embedded-runner/run.js +2 -0
- package/dist/agents/pi-embedded-runner/tool-split.js +40 -2
- package/dist/agents/pi-tool-definition-adapter.js +16 -1
- package/dist/agents/pi-tools.js +2 -1
- package/dist/agents/sandbox/config.js +1 -1
- package/dist/agents/sandbox/context.js +27 -2
- package/dist/agents/skills/env-overrides.js +38 -28
- package/dist/agents/skills/trust.js +93 -0
- package/dist/agents/skills/workspace.js +128 -0
- package/dist/agents/skills-clawhub.js +36 -11
- package/dist/agents/skills-marketplace-scan.js +49 -0
- package/dist/agents/tools/marketplace-offer-draft-tool.js +1 -1
- package/dist/agents/tools/mining-tool.js +1 -1
- package/dist/agents/tools/session-status-tool.js +1 -1
- package/dist/agents/tools/wallet-action-tool.js +172 -36
- package/dist/agents/tools/wallet-skill-policy.js +65 -23
- package/dist/agents/tools/wallet-tool.js +7 -11
- package/dist/auto-reply/reply/directive-handling.fast-lane.js +2 -1
- package/dist/auto-reply/reply/directive-handling.impl.js +2 -1
- package/dist/auto-reply/reply/directive-handling.model.js +2 -1
- package/dist/auto-reply/reply/directive-handling.persist.js +2 -2
- package/dist/auto-reply/reply/get-reply-directives-apply.js +2 -0
- package/dist/auto-reply/reply/get-reply-inline-actions.js +25 -1
- package/dist/auto-reply/reply/model-selection.js +7 -4
- package/dist/auto-reply/reply/session-reset-model.js +4 -4
- package/dist/brand.js +1 -1
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/channel-web.js +2 -2
- package/dist/cli/gateway-cli/run.js +8 -0
- package/dist/cli/program/command-registry.js +1 -1
- package/dist/cli/program/register.onboard.js +2 -3
- package/dist/cli/program/register.wallet.js +16 -123
- package/dist/cli/providers-cli.js +1 -1
- package/dist/cli/sat-cli.js +129 -2
- package/dist/cli/update-cli/update-command.js +260 -11
- package/dist/commands/auth-choice.apply.api-providers.js +3 -3
- package/dist/commands/doctor-config-flow.js +1 -1
- package/dist/commands/doctor-legacy-config.js +2 -13
- package/dist/commands/model-picker.js +6 -6
- package/dist/commands/models/auth.js +1 -1
- package/dist/commands/onboard-auth.config-gateways.js +1 -1
- package/dist/commands/onboard-auth.credentials.js +32 -8
- package/dist/commands/onboard-non-interactive/local/wallet-config.js +28 -27
- package/dist/commands/onboard-non-interactive/local.js +5 -1
- package/dist/commands/wallet.js +568 -1911
- package/dist/config/config.js +2 -2
- package/dist/config/io.js +64 -2
- package/dist/config/schema.help.js +8 -7
- package/dist/config/schema.labels.js +5 -4
- package/dist/config/zod-schema.agent-runtime.js +1 -0
- package/dist/config/zod-schema.js +5 -0
- package/dist/control-ui/assets/{app-DLil9VO1.js → app-MaQnPa5G.js} +1511 -1555
- package/dist/control-ui/assets/{config-CU5Zi8Dh.js → config-LeImukCW.js} +10 -10
- package/dist/control-ui/assets/{federation-D10Q4eP_.js → federation-DgA9e-Pn.js} +364 -422
- package/dist/control-ui/assets/{index-DdE_NIXo.js → index-D4YMr1fA.js} +3 -3
- package/dist/control-ui/assets/mining-commit-DFpB_4JN.js +2 -0
- package/dist/control-ui/assets/{mining-BdhMn18r.js → mining-qMYs4aD-.js} +70 -50
- package/dist/control-ui/assets/{open-external-url-DwSiwMPl.js → open-external-url-ulF1B-sA.js} +3 -3
- package/dist/control-ui/assets/{providers-QMn4w2_f.js → providers-CIx9fxc6.js} +2 -2
- package/dist/control-ui/assets/{wallet-C2g294QT.js → wallet-DvStR_AT.js} +259 -377
- package/dist/control-ui/index.html +1 -1
- package/dist/control-ui/version.json +1 -1
- package/dist/daemon/systemd-system.js +56 -50
- package/dist/extensions/sat-mining/src/protocol-contract.js +43 -3
- package/dist/extensions/sat-mining/src/rpc-read.js +291 -84
- package/dist/extensions/sat-mining/src/sat-bond-layout.js +5 -2
- package/dist/extensions/sat-mining/src/signer-codec-manifest.js +406 -0
- package/dist/extensions/sat-mining/src/solana-submit.js +1274 -390
- package/dist/extensions/sat-mining/src/submission-ledger.js +349 -0
- package/dist/federation/auto-connect.js +98 -8
- package/dist/federation/marketplace-capability-adapter.js +33 -7
- package/dist/federation/marketplace-delivery-outbox.js +196 -0
- package/dist/federation/marketplace-delivery.js +351 -215
- package/dist/federation/marketplace-direct-payment.js +272 -141
- package/dist/federation/marketplace-escrow.js +607 -249
- package/dist/federation/marketplace-settlement-ledger.js +352 -0
- package/dist/federation/offers.js +9 -7
- package/dist/federation/peer-auth-v2.js +529 -0
- package/dist/gateway/a2a-http.js +425 -96
- package/dist/gateway/a2a-settlement.js +259 -153
- package/dist/gateway/a2a-task-store.js +524 -0
- package/dist/gateway/auth.js +38 -2
- package/dist/gateway/config-reload.js +46 -33
- package/dist/gateway/durable-capacity.js +31 -0
- package/dist/gateway/federation-http.js +540 -135
- package/dist/gateway/federation-marketplace-run-store.js +397 -0
- package/dist/gateway/federation-marketplace.js +535 -230
- package/dist/gateway/mutating-admin-rpc-rate-limit.js +5 -0
- package/dist/gateway/security-path.js +1 -1
- package/dist/gateway/server-http.js +1084 -1205
- package/dist/gateway/server-methods/models.js +1 -1
- package/dist/gateway/server-methods/secrets.js +40 -0
- package/dist/gateway/server-methods.js +1 -2
- package/dist/gateway/server-reload-handlers.js +196 -66
- package/dist/gateway/server-runtime-config.js +1 -1
- package/dist/gateway/server-secrets-runtime.js +288 -0
- package/dist/gateway/server.impl.js +73 -42
- package/dist/gateway/sessions-patch.js +3 -5
- package/dist/index.js +4 -2
- package/dist/infra/fasedhub.js +64 -1
- package/dist/infra/local-source-paired-update.js +538 -0
- package/dist/infra/restart.js +41 -10
- package/dist/infra/update-runner.js +96 -0
- package/dist/light-update-status.js +11 -11
- package/dist/memory/backend-config.js +2 -1
- package/dist/memory/session-files.js +16 -2
- package/dist/plugin-sdk/{accounts-DxblobYM.js → accounts-Brn3-uWN.js} +1 -1
- package/dist/plugin-sdk/{actions-D4UNimWa.js → actions-DRu135h0.js} +2 -2
- package/dist/plugin-sdk/{active-listener-CFuy106s.js → active-listener-B_NMtgPL.js} +1 -1
- package/dist/plugin-sdk/{audio-preflight-Bwi2Oq03.js → audio-preflight-I4IngVlJ.js} +27 -27
- package/dist/plugin-sdk/{audit-Cs0K7LBp.js → audit-C5d2z5U1.js} +1 -1
- package/dist/plugin-sdk/{channel-access-D5aHoTY8.js → channel-access-CcFRdRPO.js} +1 -1
- package/dist/plugin-sdk/{channel-access-configure-Dvch9mMQ.js → channel-access-configure-DaI5wevh.js} +1 -1
- package/dist/plugin-sdk/channel-plugin-common.d.ts +3 -3
- package/dist/plugin-sdk/channel-plugin-common.js +4 -4
- package/dist/plugin-sdk/{chunk-B0FUGc5A.js → chunk-CyoyqpbG.js} +1 -1
- package/dist/plugin-sdk/{chunk-items-DzT4L4Ty.js → chunk-items-DLQ6_lLK.js} +1 -1
- package/dist/plugin-sdk/command-status.d.ts +2 -2
- package/dist/plugin-sdk/command-status.js +27 -27
- package/dist/plugin-sdk/{commands-registry-DmDRhRAU.js → commands-registry-BfqdEWdF.js} +2 -2
- package/dist/plugin-sdk/{common-CfUOowOp.js → common-HCcXU-NR.js} +1 -1
- package/dist/plugin-sdk/{config-mxULv0fQ.js → config-DlWVeLFB.js} +7113 -6877
- package/dist/plugin-sdk/{config-schema-BrkmtFxB.js → config-schema-D_8FVI1C.js} +6798 -3695
- package/dist/plugin-sdk/device-pair.d.ts +1 -1
- package/dist/plugin-sdk/discord.d.ts +6 -6
- package/dist/plugin-sdk/discord.js +19 -19
- package/dist/plugin-sdk/file-lock.js +35 -4
- package/dist/plugin-sdk/{filesystem-manager-ZoHU8oA7.js → filesystem-manager-DoI8IBNF.js} +1 -1
- package/dist/plugin-sdk/{group-mentions-BHRff6j8.d.ts → group-mentions-q3hUTCt7.d.ts} +1 -1
- package/dist/plugin-sdk/{handle-action-DbVCF9HZ.js → handle-action-hvwapMKg.js} +13 -13
- package/dist/plugin-sdk/{helpers-BXbdgs5H.js → helpers-DMBU4oTo.js} +1 -1
- package/dist/plugin-sdk/{image-ops-D7jPxaph.js → image-ops-DQi0n_Tt.js} +1 -1
- package/dist/plugin-sdk/index.d.ts +21 -39
- package/dist/plugin-sdk/index.js +29 -29
- package/dist/plugin-sdk/{login-BRxww6nv.js → login-Ca583Okc.js} +3 -3
- package/dist/plugin-sdk/{login-qr-DJXsk9XH.js → login-qr-CGciBSNP.js} +3 -3
- package/dist/plugin-sdk/{manager-Y2S_5IlI.js → manager-BegWxNYX.js} +4 -4
- package/dist/plugin-sdk/{markdown-tables-DHLFQqaF.js → markdown-tables-DCOXEUfZ.js} +1 -1
- package/dist/plugin-sdk/{media-Czo4carg.js → media-CAdQF5TG.js} +47 -47
- package/dist/plugin-sdk/{memory-search-DTjIMw8J.js → memory-search-CrFPOeTH.js} +4 -1
- package/dist/plugin-sdk/{monitor-M_ta2lMc.js → monitor-B4KF4Kpo.js} +31 -31
- package/dist/plugin-sdk/{monitor-wYVncM9w.js → monitor-Bb6x1KAG.js} +32 -32
- package/dist/plugin-sdk/{openresponses-http-B2GmeSt4.js → openresponses-http-DCTO8JkL.js} +27 -27
- package/dist/plugin-sdk/{optional-runtime-dependency-DdMbxS24.js → optional-runtime-dependency-0dznm3ZO.js} +1 -1
- package/dist/plugin-sdk/{outbound-Db8mRN6P.js → outbound-BgVDdHxx.js} +6 -6
- package/dist/plugin-sdk/{outbound-attachment-BqFjcypb.js → outbound-attachment-QqTnIhZL.js} +2 -2
- package/dist/plugin-sdk/{pairing-message-B3GC_7CD.js → pairing-message-D0CoLHRJ.js} +1 -1
- package/dist/plugin-sdk/{pairing-message-B3bHYGaw.d.ts → pairing-message-DHPDFZbC.d.ts} +2 -2
- package/dist/plugin-sdk/{pairing-store-CQikgIbw.js → pairing-store-BChahgI2.js} +2 -2
- package/dist/plugin-sdk/{pi-model-discovery-CY3m5zJP.js → pi-model-discovery-BX_JLcEJ.js} +1 -1
- package/dist/plugin-sdk/{pi-model-discovery-runtime-DSh1T2pn.js → pi-model-discovery-runtime-DxTMz_XF.js} +2 -2
- package/dist/plugin-sdk/provider-web-search-config-contract.d.ts +2 -2
- package/dist/plugin-sdk/{pw-ai-AFUqn-tQ.js → pw-ai-natjh3rm.js} +3 -3
- package/dist/plugin-sdk/{qmd-manager-DSyx77KY.js → qmd-manager-CgRaTxUq.js} +1 -1
- package/dist/plugin-sdk/{query-expansion-CAI2kKLQ.js → query-expansion-BG3FgzF7.js} +14 -3
- package/dist/plugin-sdk/{replies-Fzh9PhXl.js → replies-ChYo5ZQM.js} +2 -2
- package/dist/plugin-sdk/{resolve-outbound-target-KpF3co6T.js → resolve-outbound-target-D-KGgHJZ.js} +1 -1
- package/dist/plugin-sdk/{resolve-route-CDl74O19.js → resolve-route-C8tvQm8Z.js} +1 -1
- package/dist/plugin-sdk/{retry-policy-D4uiqUOG.js → retry-policy-C6SjKjQA.js} +1 -1
- package/dist/plugin-sdk/{runtime-Bb6KRnCC.js → runtime-2B9_WKoI.js} +8 -3
- package/dist/plugin-sdk/{runtime-dependency-DLDmB94f.js → runtime-dependency-DczkvPxn.js} +2 -2
- package/dist/plugin-sdk/sat-runtime.d.ts +565 -309
- package/dist/plugin-sdk/sat-runtime.js +29 -29
- package/dist/plugin-sdk/{send-C4k4JuJN.js → send-B6KkGKZD.js} +6 -6
- package/dist/plugin-sdk/{send-D-uDKGIq.js → send-CFzGKJXo.js} +6 -6
- package/dist/plugin-sdk/{send-Du8ykP1k.js → send-DCO441U7.js} +8 -8
- package/dist/plugin-sdk/{send-5nFktR1n.js → send-gDoGA-7e.js} +5 -5
- package/dist/plugin-sdk/{send-Bfzf11VY.js → send-q9HXrSwK.js} +7 -7
- package/dist/plugin-sdk/{session-CS-Td9EM.js → session-DHD4ZKyG.js} +2 -2
- package/dist/plugin-sdk/{skill-commands-CFAlXWHk.js → skill-commands-FKEPLS7T.js} +201 -26
- package/dist/plugin-sdk/{slack-CxE1mfzj.js → slack-BHmvqgjH.js} +39 -39
- package/dist/plugin-sdk/{slack-actions-BcMkNv1Z.js → slack-actions-DhbMcp8M.js} +11 -11
- package/dist/plugin-sdk/slack.d.ts +6 -6
- package/dist/plugin-sdk/slack.js +9 -9
- package/dist/plugin-sdk/{sticker-cache-CGzGWu00.js → sticker-cache-By5AcorL.js} +3 -3
- package/dist/plugin-sdk/{tables-bFXyRpkx.js → tables-B3jr0Pvq.js} +1 -1
- package/dist/plugin-sdk/{targets-DH7a9lKB.js → targets-CtSbTxYX.js} +1 -1
- package/dist/plugin-sdk/{telegram-actions-DaEcYQ8r.js → telegram-actions-DGnBz1YT.js} +30 -30
- package/dist/plugin-sdk/telegram.d.ts +6 -6
- package/dist/plugin-sdk/telegram.js +8 -8
- package/dist/plugin-sdk/{thread-bindings.lifecycle-CgOvvdw8.js → thread-bindings.lifecycle-QbkNl-m6.js} +3 -3
- package/dist/plugin-sdk/{thread-bindings.state-CQpk44Hq.js → thread-bindings.state-D9hg_M1c.js} +2 -2
- package/dist/plugin-sdk/tmp-fased-dir-EJGTmL1Q.d.ts +486 -0
- package/dist/plugin-sdk/{types-vcJrC_uv.d.ts → types-BdwdFCD6.d.ts} +2 -3
- package/dist/plugin-sdk/{types-DFAW-n1J.d.ts → types-BrCpYMxn.d.ts} +2 -2
- package/dist/plugin-sdk/{types-DyhXnYUr.d.ts → types-D0kDG8l0.d.ts} +3 -2
- package/dist/plugin-sdk/{types.plugin-_fbu40Re.d.ts → types.plugin-BcSBq42x.d.ts} +8 -3
- package/dist/plugin-sdk/{web-CInY-lCv.js → web-DUJwrTYs.js} +32 -32
- package/dist/plugin-sdk/{whatsapp-actions-BtSc2CBv.js → whatsapp-actions-Bj_rOncr.js} +13 -13
- package/dist/plugin-sdk/{whatsapp-heartbeat-Bg9TuYzl.js → whatsapp-heartbeat-B1WHkJIg.js} +2 -2
- package/dist/plugin-sdk/whatsapp.d.ts +13 -13
- package/dist/plugin-sdk/whatsapp.js +12 -12
- package/dist/plugin-sdk/{wsl-C4DGFkOd.js → wsl-J-HscWxS.js} +3 -3
- package/dist/plugin-sdk/{zod-schema.providers-core-BEbNizPe.d.ts → zod-schema.providers-core-CIzCjXH9.d.ts} +61 -61
- package/dist/providers/refresh.js +1 -1
- package/dist/providers/registry.js +1 -1
- package/dist/secrets/apply.js +1 -1
- package/dist/secrets/runtime.js +1 -1
- package/dist/wallet/external-submission-ledger.js +376 -0
- package/dist/wallet/legacy-embedded-keystore.js +40 -0
- package/dist/wallet/local-socket-signer-archive.js +30 -0
- package/dist/wallet/local-socket-signer-lifecycle.js +97 -0
- package/dist/wallet/local-socket-signer-policy.js +166 -0
- package/dist/wallet/local-socket-signer-protocol.js +578 -117
- package/dist/wallet/native-signer-wallet-id.js +25 -0
- package/dist/wallet/providers/alchemy-adapter.js +3 -0
- package/dist/wallet/providers/local-socket-signer-adapter.js +380 -105
- package/dist/wallet/providers/turnkey-adapter.js +292 -34
- package/dist/wallet/providers/wallet-standard-adapter.js +100 -0
- package/dist/wallet/signer-network-admin.js +184 -0
- package/dist/wallet/signer-protocol-v2.generated.js +92 -0
- package/dist/wallet/solana-bond-signing.js +157 -69
- package/dist/wallet/solana-reviewed-transaction.js +375 -0
- package/dist/wallet/solana-swap.js +520 -64
- package/dist/wallet/solana-transaction-inspection.js +106 -4
- package/dist/wallet/solana-trigger.js +658 -320
- package/dist/wallet/turnkey-reviewed-state.js +370 -0
- package/dist/wallet/wallet-approval-auth.js +17 -28
- package/dist/wallet/wallet-atomic-state.js +53 -0
- package/dist/wallet/wallet-canary.js +0 -1
- package/dist/wallet/wallet-inbound-events.js +16 -11
- package/dist/wallet/wallet-policy-simulation.js +1 -1
- package/dist/wallet/wallet-policy.js +93 -37
- package/dist/wallet/wallet-provider-capabilities.js +28 -4
- package/dist/wallet/wallet-provider-registry.js +57 -44
- package/dist/wallet/wallet-provider-resolver.js +62 -63
- package/dist/wallet/wallet-runtime-config.js +28 -41
- package/dist/wallet/wallet-secrets-store.js +22 -0
- package/dist/wallet/wallet-send-approvals.js +1891 -589
- package/dist/wallet/wallet-send-execution-ledger.js +292 -0
- package/dist/wallet/wallet-settlement-links.js +14 -13
- package/dist/wallet/wallet-standard-review.js +353 -0
- package/dist/wallet/wallet-status.js +0 -9
- package/dist/wallet/wallet-task-ledger.js +16 -2
- package/dist/web/auto-reply/heartbeat-runner.js +1 -1
- package/dist/web/auto-reply/monitor.js +2 -2
- package/dist/wizard/host-security-capability.js +14 -23
- package/dist/wizard/onboarding.finalize.js +63 -184
- package/dist/wizard/onboarding.host-security.js +117 -1367
- package/dist/wizard/onboarding.js +172 -217
- package/dist/wizard/onboarding.wallet.js +232 -785
- package/extensions/acpx/package.json +1 -1
- package/extensions/bluebubbles/package.json +1 -1
- package/extensions/copilot-proxy/package.json +1 -1
- package/extensions/diagnostics-otel/package.json +1 -1
- package/extensions/fased-federation/package.json +1 -1
- package/extensions/google-gemini-cli-auth/package.json +1 -1
- package/extensions/imessage/package.json +1 -1
- package/extensions/irc/package.json +1 -1
- package/extensions/line/package.json +1 -1
- package/extensions/llm-task/package.json +1 -1
- package/extensions/lobster/package.json +1 -1
- package/extensions/matrix/CHANGELOG.md +18 -0
- package/extensions/matrix/package.json +1 -1
- package/extensions/mattermost/package.json +1 -1
- package/extensions/memory-core/package.json +2 -2
- package/extensions/memory-lancedb/package.json +1 -1
- package/extensions/minimax-portal-auth/package.json +1 -1
- package/extensions/msteams/CHANGELOG.md +18 -0
- package/extensions/msteams/package.json +1 -1
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nostr/CHANGELOG.md +18 -0
- package/extensions/nostr/package.json +1 -1
- package/extensions/open-prose/package.json +1 -1
- package/extensions/sat-mining/index.ts +587 -154
- package/extensions/sat-mining/package.json +1 -1
- package/extensions/sat-mining/signer-codec-schema.v1.json +374 -0
- package/extensions/sat-mining/src/audit-store.ts +91 -5
- package/extensions/sat-mining/src/claim-service.ts +85 -14
- package/extensions/sat-mining/src/client.ts +13 -0
- package/extensions/sat-mining/src/config.ts +9 -0
- package/extensions/sat-mining/src/cycle-progress.ts +16 -8
- package/extensions/sat-mining/src/epoch-service.ts +9 -5
- package/extensions/sat-mining/src/gateway-runner.ts +21 -1
- package/extensions/sat-mining/src/protocol-contract.ts +45 -1
- package/extensions/sat-mining/src/recovery-service.ts +312 -0
- package/extensions/sat-mining/src/round-watcher.ts +391 -81
- package/extensions/sat-mining/src/rpc-read.ts +431 -106
- package/extensions/sat-mining/src/runtime.ts +16 -0
- package/extensions/sat-mining/src/sat-bond-layout.ts +6 -0
- package/extensions/sat-mining/src/signer-codec-manifest.ts +429 -0
- package/extensions/sat-mining/src/solana-submit.ts +1544 -436
- package/extensions/sat-mining/src/submission-ledger.ts +434 -0
- package/extensions/signal/package.json +1 -1
- package/extensions/synology-chat/package.json +1 -1
- package/extensions/tlon/package.json +1 -1
- package/extensions/twitch/CHANGELOG.md +18 -0
- package/extensions/twitch/package.json +1 -1
- package/extensions/voice-call/CHANGELOG.md +18 -0
- package/extensions/voice-call/package.json +1 -1
- package/extensions/zalo/CHANGELOG.md +18 -0
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalouser/CHANGELOG.md +18 -0
- package/extensions/zalouser/package.json +1 -1
- package/install.sh +4951 -0
- package/package.json +23 -5
- package/scripts/fased-host-updater.mjs +1421 -0
- package/scripts/fased-host-updaterctl.mjs +186 -0
- package/scripts/fased-managed-service.sh +36 -0
- package/scripts/fased-managed-updater.mjs +3065 -156
- package/scripts/fased-signer-enroll-hosting.sh +275 -0
- package/scripts/fased-signer-network-hosting.sh +143 -0
- package/scripts/fased-signer-owner-policy.mjs +1442 -0
- package/scripts/fased-signer-policy-hosting.sh +50 -0
- package/scripts/fased-signer-policy-local.sh +26 -0
- package/scripts/hosted-release-manifest.mjs +185 -0
- package/scripts/install-fased-signerd.sh +183 -108
- package/scripts/install-managed-runtime.mjs +212 -10
- package/scripts/managed-runtime-layout.mjs +75 -3
- package/scripts/migrate-hosted-signer-v2.mjs +58 -0
- package/scripts/start-managed.sh +173 -360
- package/dist/control-ui/assets/mining-commit-R-6nu87p.js +0 -2
- package/dist/plugin-sdk/tmp-fased-dir-CS6zsYEE.d.ts +0 -77
- package/dist/wallet/local-socket-signer-broker.js +0 -224
- package/dist/wallet/local-socket-signer-custody.js +0 -42
- package/dist/wallet/providers/embedded-keystore-adapter.js +0 -402
- package/dist/wallet/providers/privy-adapter.js +0 -80
- package/dist/wallet/wallet-custody.js +0 -1836
|
@@ -1,10 +1,76 @@
|
|
|
1
|
-
import { fetchSolanaNativeBalanceViaRpc, fetchSolanaWalletAssetsViaRpc } from "./solana-assets.js";
|
|
2
|
-
import { applyWalletPolicyConfig,
|
|
1
|
+
import { SOLANA_ASSET_CONSTANTS, fetchSolanaMintInfoViaRpc, fetchSolanaNativeBalanceViaRpc, fetchSolanaWalletAssetsViaRpc } from "./solana-assets.js";
|
|
2
|
+
import { applyWalletPolicyConfig, validateWalletTxPolicy } from "./wallet-policy.js";
|
|
3
|
+
import { deriveAssociatedTokenAddress } from "./solana-spl-transfer.js";
|
|
3
4
|
import { createWalletProviderAdapter, resolveScopedRpcUrlForWallet } from "./wallet-provider-resolver.js";
|
|
5
|
+
import { beginExternalSubmission, claimExternalSubmissionExecution, createExternalSubmissionKey, updateExternalSubmission } from "./external-submission-ledger.js";
|
|
4
6
|
import { inspectSerializedSolanaSwapTransaction } from "./solana-transaction-inspection.js";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
5
8
|
|
|
6
9
|
//#region src/wallet/solana-swap.ts
|
|
7
10
|
const SOLANA_NATIVE_MINT = "So11111111111111111111111111111111111111112";
|
|
11
|
+
const DEFAULT_JUPITER_MAX_FEE_LAMPORTS = "5000000";
|
|
12
|
+
function storedSwapOrder(entry) {
|
|
13
|
+
const value = entry.details?.order;
|
|
14
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const order = value;
|
|
18
|
+
if (order.ok !== true || typeof order.inputMint !== "string" || typeof order.outputMint !== "string" || typeof order.inAmount !== "string" || !order.raw || typeof order.raw !== "object" || Array.isArray(order.raw)) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return order;
|
|
22
|
+
}
|
|
23
|
+
function storedSignerOperation(entry) {
|
|
24
|
+
const value = entry.result?.operation;
|
|
25
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const operation = value;
|
|
29
|
+
if (typeof operation.requestId !== "string" || typeof operation.walletId !== "string" || typeof operation.intentType !== "string" || typeof operation.intentDigest !== "string" || typeof operation.policyHash !== "string" || typeof operation.asset !== "string" || typeof operation.amount !== "string" || ![
|
|
30
|
+
"reserved",
|
|
31
|
+
"broadcast",
|
|
32
|
+
"confirmed",
|
|
33
|
+
"failed",
|
|
34
|
+
"unknown"
|
|
35
|
+
].includes(operation.state ?? "")) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return operation;
|
|
39
|
+
}
|
|
40
|
+
function signerReviewMatchesAutonomousSwap(params) {
|
|
41
|
+
const { review } = params;
|
|
42
|
+
return review.requestId === params.requestId && review.walletId === params.walletId && review.mode === "autonomous" && review.intentType === "solana.jupiter.swap" && review.semanticIntent.type === "solana.jupiter.swap" && review.semanticIntent.jupiter.owner === params.owner && review.semanticIntent.jupiter.inputMint === params.inputMint && review.semanticIntent.jupiter.outputMint === params.outputMint && review.semanticIntent.jupiter.inputAmount === params.amount && review.semanticIntent.jupiter.maxInputAmount === params.amount && review.transaction?.submission === "rpc" && Boolean(review.transaction.serializedTxBase64);
|
|
43
|
+
}
|
|
44
|
+
function swapExecutionResult(params) {
|
|
45
|
+
const { operation } = params;
|
|
46
|
+
if (operation.state !== "confirmed" || !operation.signature) {
|
|
47
|
+
const ambiguous = operation.state === "reserved" || operation.state === "broadcast" || operation.state === "unknown";
|
|
48
|
+
return {
|
|
49
|
+
ok: false,
|
|
50
|
+
code: ambiguous ? "wallet_provider_ambiguous" : "wallet_swap_failed",
|
|
51
|
+
message: ambiguous ? `signer operation ${operation.requestId} is ${operation.state}; reconcile its existing signature before any new Jupiter order` : operation.error ?? `typed Jupiter swap ended in state=${operation.state}`
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const tx = {
|
|
55
|
+
ok: true,
|
|
56
|
+
chain: "solana",
|
|
57
|
+
txHash: operation.signature,
|
|
58
|
+
signer: params.signer,
|
|
59
|
+
metadata: {
|
|
60
|
+
provider: "local-socket-signer",
|
|
61
|
+
signerProtocol: 2,
|
|
62
|
+
signerOperationState: operation.state,
|
|
63
|
+
signerIntentDigest: operation.intentDigest,
|
|
64
|
+
signerTransactionDigest: operation.transactionDigest,
|
|
65
|
+
...params.inspection ? { swapInspection: params.inspection } : {}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
ok: true,
|
|
70
|
+
tx,
|
|
71
|
+
order: params.order
|
|
72
|
+
};
|
|
73
|
+
}
|
|
8
74
|
function stringValue(value) {
|
|
9
75
|
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
10
76
|
}
|
|
@@ -12,12 +78,13 @@ function numberValue(value) {
|
|
|
12
78
|
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
13
79
|
}
|
|
14
80
|
function parsePositiveBaseUnits(value) {
|
|
15
|
-
|
|
81
|
+
const normalized = value?.trim();
|
|
82
|
+
if (!normalized || normalized.length > 32 || !/^\d+$/.test(normalized)) {
|
|
16
83
|
throw new Error("amount is required");
|
|
17
84
|
}
|
|
18
|
-
const parsed = BigInt(
|
|
19
|
-
if (parsed <= 0n) {
|
|
20
|
-
throw new Error("amount must be positive base units");
|
|
85
|
+
const parsed = BigInt(normalized);
|
|
86
|
+
if (parsed <= 0n || parsed > 18446744073709551615n) {
|
|
87
|
+
throw new Error("amount must be positive uint64 base units");
|
|
21
88
|
}
|
|
22
89
|
return parsed;
|
|
23
90
|
}
|
|
@@ -31,6 +98,93 @@ function normalizeSlippageBps(value) {
|
|
|
31
98
|
}
|
|
32
99
|
return rounded;
|
|
33
100
|
}
|
|
101
|
+
function resolveSolanaSwapMinimumOutput(order) {
|
|
102
|
+
if (order.otherAmountThreshold?.trim()) {
|
|
103
|
+
return parsePositiveBaseUnits(order.otherAmountThreshold).toString();
|
|
104
|
+
}
|
|
105
|
+
const quoted = parsePositiveBaseUnits(order.outAmount);
|
|
106
|
+
const slippageBps = BigInt(normalizeSlippageBps(order.slippageBps));
|
|
107
|
+
return ((quoted * (10000n - slippageBps) + 9999n) / 10000n).toString();
|
|
108
|
+
}
|
|
109
|
+
function resolveJupiterMaxFeeLamports(env) {
|
|
110
|
+
const value = env.FASED_WALLET_JUPITER_MAX_FEE_LAMPORTS?.trim() || DEFAULT_JUPITER_MAX_FEE_LAMPORTS;
|
|
111
|
+
const parsed = BigInt(value);
|
|
112
|
+
if (parsed <= 0n || parsed > 100000000n) {
|
|
113
|
+
throw new Error("FASED_WALLET_JUPITER_MAX_FEE_LAMPORTS must be between 1 and 100000000");
|
|
114
|
+
}
|
|
115
|
+
return parsed.toString();
|
|
116
|
+
}
|
|
117
|
+
function createSignerReviewId(prefix, seed) {
|
|
118
|
+
return `${prefix}:${createHash("sha256").update(seed).digest("hex")}`;
|
|
119
|
+
}
|
|
120
|
+
async function exactJupiterTokenAccount(params) {
|
|
121
|
+
const tokenProgramId = params.mint === SOLANA_NATIVE_MINT ? SOLANA_ASSET_CONSTANTS.tokenProgramId : (await fetchSolanaMintInfoViaRpc({
|
|
122
|
+
rpcUrl: params.rpcUrl,
|
|
123
|
+
mint: params.mint
|
|
124
|
+
}))?.tokenProgramId;
|
|
125
|
+
if (!tokenProgramId) {
|
|
126
|
+
throw new Error(`unable to resolve token program for mint ${params.mint}`);
|
|
127
|
+
}
|
|
128
|
+
return await deriveAssociatedTokenAddress({
|
|
129
|
+
owner: params.owner,
|
|
130
|
+
mint: params.mint,
|
|
131
|
+
tokenProgramId
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async function buildSolanaSwapSignerIntent(params) {
|
|
135
|
+
const inAmount = parsePositiveBaseUnits(params.order.inAmount).toString();
|
|
136
|
+
const minimumOutputAmount = resolveSolanaSwapMinimumOutput(params.order);
|
|
137
|
+
const sourceTokenAccount = await exactJupiterTokenAccount({
|
|
138
|
+
rpcUrl: params.rpcUrl,
|
|
139
|
+
owner: params.owner,
|
|
140
|
+
mint: params.order.inputMint
|
|
141
|
+
});
|
|
142
|
+
const destinationTokenAccount = await exactJupiterTokenAccount({
|
|
143
|
+
rpcUrl: params.rpcUrl,
|
|
144
|
+
owner: params.owner,
|
|
145
|
+
mint: params.order.outputMint
|
|
146
|
+
});
|
|
147
|
+
return {
|
|
148
|
+
type: "solana.jupiter.swap",
|
|
149
|
+
jupiter: {
|
|
150
|
+
owner: params.owner,
|
|
151
|
+
inputMint: params.order.inputMint,
|
|
152
|
+
outputMint: params.order.outputMint,
|
|
153
|
+
inputAmount: inAmount,
|
|
154
|
+
maxInputAmount: inAmount,
|
|
155
|
+
minimumOutputAmount,
|
|
156
|
+
maxFeeLamports: resolveJupiterMaxFeeLamports(params.env ?? process.env),
|
|
157
|
+
sourceTokenAccount,
|
|
158
|
+
destinationTokenAccount,
|
|
159
|
+
programs: [...params.inspection.programIds].toSorted()
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
async function prepareSolanaSwapSignerReview(params) {
|
|
164
|
+
if (!params.provider.prepareJupiterReview) {
|
|
165
|
+
throw new Error("Jupiter execution requires protocol-v2 local-socket-signer review.prepare support");
|
|
166
|
+
}
|
|
167
|
+
const intent = await buildSolanaSwapSignerIntent(params);
|
|
168
|
+
if (!params.order.transaction) {
|
|
169
|
+
throw new Error("Jupiter signer review requires the exact serialized transaction");
|
|
170
|
+
}
|
|
171
|
+
const review = await params.provider.prepareJupiterReview({
|
|
172
|
+
walletId: params.walletId,
|
|
173
|
+
requestId: params.requestId ?? createSignerReviewId("jupiter-swap", params.order.requestId ?? params.order.transaction ?? JSON.stringify(params.order.raw)),
|
|
174
|
+
mode: params.mode,
|
|
175
|
+
intent,
|
|
176
|
+
transaction: {
|
|
177
|
+
serializedTxBase64: params.order.transaction,
|
|
178
|
+
programs: params.inspection.programIds,
|
|
179
|
+
writableAccounts: params.inspection.writableAccounts,
|
|
180
|
+
submission: "rpc"
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return {
|
|
184
|
+
review,
|
|
185
|
+
intent
|
|
186
|
+
};
|
|
187
|
+
}
|
|
34
188
|
function resolveSwapApiBaseUrl(env = process.env) {
|
|
35
189
|
const raw = env.FASED_JUPITER_SWAP_API_BASE_URL?.trim() || env.JUPITER_SWAP_API_BASE_URL?.trim() || "https://api.jup.ag/swap/v2";
|
|
36
190
|
return raw.replace(/\/+$/, "");
|
|
@@ -59,6 +213,26 @@ function extractRouteLabel(raw) {
|
|
|
59
213
|
function isSolanaSwapApprovalPayload(payload) {
|
|
60
214
|
return payload.actionKind === "solana_swap" && payload.chain === "solana" && Boolean(payload.inputMint?.trim()) && Boolean(payload.outputMint?.trim()) && Boolean(payload.amount?.trim()) && Boolean(payload.walletId?.trim());
|
|
61
215
|
}
|
|
216
|
+
function reviewedSolanaSwapOrderFromPayload(payload) {
|
|
217
|
+
const transaction = payload.serializedTxBase64?.trim();
|
|
218
|
+
if (!transaction || !isSolanaSwapApprovalPayload(payload)) {
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
ok: true,
|
|
223
|
+
requestId: payload.jupiterRequestId,
|
|
224
|
+
transaction,
|
|
225
|
+
inputMint: payload.inputMint,
|
|
226
|
+
outputMint: payload.outputMint,
|
|
227
|
+
inAmount: payload.amount,
|
|
228
|
+
outAmount: payload.outAmount,
|
|
229
|
+
otherAmountThreshold: payload.otherAmountThreshold,
|
|
230
|
+
slippageBps: payload.slippageBps,
|
|
231
|
+
priceImpactPct: payload.priceImpactPct,
|
|
232
|
+
routeLabel: payload.routeLabel,
|
|
233
|
+
raw: {}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
62
236
|
async function fetchJupiterSwapOrder(params) {
|
|
63
237
|
const env = params.env ?? process.env;
|
|
64
238
|
parsePositiveBaseUnits(params.amount);
|
|
@@ -84,13 +258,17 @@ async function fetchJupiterSwapOrder(params) {
|
|
|
84
258
|
if (errorMessage && !stringValue(body.transaction)) {
|
|
85
259
|
throw new Error(`jupiter order failed: ${errorMessage}`);
|
|
86
260
|
}
|
|
261
|
+
const inAmount = stringValue(body.inAmount) ?? params.amount.trim();
|
|
262
|
+
if (parsePositiveBaseUnits(inAmount) !== parsePositiveBaseUnits(params.amount)) {
|
|
263
|
+
throw new Error("jupiter order changed the requested exact input amount");
|
|
264
|
+
}
|
|
87
265
|
return {
|
|
88
266
|
ok: true,
|
|
89
267
|
requestId: stringValue(body.requestId),
|
|
90
268
|
transaction: stringValue(body.transaction) ?? stringValue(body.tx),
|
|
91
269
|
inputMint,
|
|
92
270
|
outputMint,
|
|
93
|
-
inAmount
|
|
271
|
+
inAmount,
|
|
94
272
|
outAmount: stringValue(body.outAmount),
|
|
95
273
|
otherAmountThreshold: stringValue(body.otherAmountThreshold),
|
|
96
274
|
slippageBps: numberValue(body.slippageBps) ?? normalizeSlippageBps(params.slippageBps),
|
|
@@ -159,7 +337,11 @@ function validateSolanaSwapIntentPolicy(params) {
|
|
|
159
337
|
function validateSolanaSwapRoutePolicy(params) {
|
|
160
338
|
const allowlist = new Set(params.config.policy.solana.allowPrograms.map((program) => program.trim()).filter(Boolean));
|
|
161
339
|
if (allowlist.size === 0) {
|
|
162
|
-
return {
|
|
340
|
+
return {
|
|
341
|
+
ok: false,
|
|
342
|
+
code: "wallet_swap_program_allowlist_required",
|
|
343
|
+
message: "swap execution requires an explicit non-empty Solana program allowlist"
|
|
344
|
+
};
|
|
163
345
|
}
|
|
164
346
|
const denied = params.routeProgramIds.filter((programId) => !allowlist.has(programId));
|
|
165
347
|
if (denied.length === 0) {
|
|
@@ -256,21 +438,6 @@ async function executeSolanaSwapApprovalPayload(params) {
|
|
|
256
438
|
message: policy.message ?? "wallet policy rejected"
|
|
257
439
|
};
|
|
258
440
|
}
|
|
259
|
-
const daily = enforceWalletDailyCap({
|
|
260
|
-
config: effectiveConfig,
|
|
261
|
-
chain: "solana",
|
|
262
|
-
amount: params.payload.amount,
|
|
263
|
-
tokenMint: params.payload.inputMint === SOLANA_NATIVE_MINT ? undefined : params.payload.inputMint,
|
|
264
|
-
walletId: params.payload.walletId,
|
|
265
|
-
env
|
|
266
|
-
});
|
|
267
|
-
if (!daily.ok) {
|
|
268
|
-
return {
|
|
269
|
-
ok: false,
|
|
270
|
-
code: daily.code ?? "wallet_cap_daily_exceeded",
|
|
271
|
-
message: daily.message ?? "wallet daily cap exceeded"
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
441
|
const provider = createWalletProviderAdapter({
|
|
275
442
|
cfg: params.runtimeConfig,
|
|
276
443
|
wallet: params.config,
|
|
@@ -292,51 +459,340 @@ async function executeSolanaSwapApprovalPayload(params) {
|
|
|
292
459
|
message: "wallet has no Solana address"
|
|
293
460
|
};
|
|
294
461
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (!balance.ok) {
|
|
302
|
-
return balance;
|
|
462
|
+
if (!rpcUrl?.trim()) {
|
|
463
|
+
return {
|
|
464
|
+
ok: false,
|
|
465
|
+
code: "wallet_swap_rpc_required",
|
|
466
|
+
message: "Solana RPC is required for signer-owned Jupiter validation"
|
|
467
|
+
};
|
|
303
468
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
env
|
|
311
|
-
});
|
|
312
|
-
const inspection = await inspectAndValidateSolanaSwapOrder({
|
|
313
|
-
order,
|
|
314
|
-
expectedSigner: taker,
|
|
315
|
-
rpcUrl,
|
|
316
|
-
config: effectiveConfig
|
|
317
|
-
});
|
|
318
|
-
if (!inspection.ok) {
|
|
319
|
-
return inspection;
|
|
469
|
+
if (!provider.executeJupiterReview) {
|
|
470
|
+
return {
|
|
471
|
+
ok: false,
|
|
472
|
+
code: "wallet_signer_v2_required",
|
|
473
|
+
message: "Jupiter execution requires protocol-v2 local-socket-signer review.execute support"
|
|
474
|
+
};
|
|
320
475
|
}
|
|
321
|
-
const
|
|
322
|
-
|
|
476
|
+
const autonomousIdentity = params.autonomous ? createExternalSubmissionKey({
|
|
477
|
+
kind: "jupiter-swap",
|
|
323
478
|
walletId: params.payload.walletId,
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
479
|
+
explicitIntentId: params.payload.executionIntentId,
|
|
480
|
+
intent: {
|
|
481
|
+
owner: taker,
|
|
482
|
+
inputMint: params.payload.inputMint,
|
|
483
|
+
outputMint: params.payload.outputMint,
|
|
484
|
+
amount: params.payload.amount,
|
|
485
|
+
slippageBps: normalizeSlippageBps(params.payload.slippageBps),
|
|
486
|
+
apiBaseUrl: resolveSwapApiBaseUrl(env),
|
|
487
|
+
rpcUrlDigest: `sha256:${createHash("sha256").update(rpcUrl).digest("hex")}`
|
|
488
|
+
}
|
|
489
|
+
}) : undefined;
|
|
490
|
+
let entry = autonomousIdentity ? (await beginExternalSubmission({
|
|
491
|
+
...autonomousIdentity,
|
|
492
|
+
kind: "jupiter-swap",
|
|
493
|
+
walletId: params.payload.walletId,
|
|
494
|
+
details: { semanticIntent: {
|
|
495
|
+
owner: taker,
|
|
496
|
+
inputMint: params.payload.inputMint,
|
|
497
|
+
outputMint: params.payload.outputMint,
|
|
498
|
+
amount: params.payload.amount,
|
|
499
|
+
slippageBps: normalizeSlippageBps(params.payload.slippageBps)
|
|
500
|
+
} },
|
|
501
|
+
env
|
|
502
|
+
})).entry : undefined;
|
|
503
|
+
const releaseExecution = autonomousIdentity ? await claimExternalSubmissionExecution(autonomousIdentity.key, env) : undefined;
|
|
504
|
+
try {
|
|
505
|
+
let order = entry ? storedSwapOrder(entry) : undefined;
|
|
506
|
+
if (entry?.state === "confirmed") {
|
|
507
|
+
const operation = storedSignerOperation(entry);
|
|
508
|
+
if (!operation || !order) {
|
|
509
|
+
return {
|
|
510
|
+
ok: false,
|
|
511
|
+
code: "wallet_provider_ambiguous",
|
|
512
|
+
message: "confirmed swap ledger entry is incomplete; refusing to create another order"
|
|
513
|
+
};
|
|
335
514
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
515
|
+
return swapExecutionResult({
|
|
516
|
+
operation,
|
|
517
|
+
signer: typeof entry.result?.signer === "string" ? entry.result.signer : taker,
|
|
518
|
+
order
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
if (entry?.signerRequestId && (entry.state === "unknown" || entry.state === "submitting" || entry.state === "signed")) {
|
|
522
|
+
let operation;
|
|
523
|
+
try {
|
|
524
|
+
operation = provider.reconcileSignerOperation ? await provider.reconcileSignerOperation({
|
|
525
|
+
walletId: params.payload.walletId,
|
|
526
|
+
requestId: entry.signerRequestId
|
|
527
|
+
}) : provider.getSignerOperation ? await provider.getSignerOperation({
|
|
528
|
+
walletId: params.payload.walletId,
|
|
529
|
+
requestId: entry.signerRequestId
|
|
530
|
+
}) : undefined;
|
|
531
|
+
} catch {
|
|
532
|
+
operation = undefined;
|
|
533
|
+
}
|
|
534
|
+
if (!operation || !order) {
|
|
535
|
+
return {
|
|
536
|
+
ok: false,
|
|
537
|
+
code: "wallet_provider_ambiguous",
|
|
538
|
+
message: `swap intent ${entry.key} has an unresolved signer submission; no new Jupiter order was created`
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
if (operation.state === "confirmed" && operation.signature) {
|
|
542
|
+
entry = await updateExternalSubmission({
|
|
543
|
+
key: entry.key,
|
|
544
|
+
expectedStates: [
|
|
545
|
+
"unknown",
|
|
546
|
+
"submitting",
|
|
547
|
+
"signed"
|
|
548
|
+
],
|
|
549
|
+
state: "confirmed",
|
|
550
|
+
patch: {
|
|
551
|
+
result: {
|
|
552
|
+
operation,
|
|
553
|
+
signer: taker
|
|
554
|
+
},
|
|
555
|
+
reason: undefined
|
|
556
|
+
},
|
|
557
|
+
env
|
|
558
|
+
});
|
|
559
|
+
} else if (operation.state === "failed") {
|
|
560
|
+
entry = await updateExternalSubmission({
|
|
561
|
+
key: entry.key,
|
|
562
|
+
expectedStates: [
|
|
563
|
+
"unknown",
|
|
564
|
+
"submitting",
|
|
565
|
+
"signed"
|
|
566
|
+
],
|
|
567
|
+
state: "failed",
|
|
568
|
+
patch: {
|
|
569
|
+
result: {
|
|
570
|
+
operation,
|
|
571
|
+
signer: taker
|
|
572
|
+
},
|
|
573
|
+
reason: operation.error
|
|
574
|
+
},
|
|
575
|
+
env
|
|
576
|
+
});
|
|
577
|
+
} else {
|
|
578
|
+
await updateExternalSubmission({
|
|
579
|
+
key: entry.key,
|
|
580
|
+
expectedStates: [
|
|
581
|
+
"unknown",
|
|
582
|
+
"submitting",
|
|
583
|
+
"signed"
|
|
584
|
+
],
|
|
585
|
+
state: "unknown",
|
|
586
|
+
patch: {
|
|
587
|
+
result: {
|
|
588
|
+
operation,
|
|
589
|
+
signer: taker
|
|
590
|
+
},
|
|
591
|
+
reason: `signer operation remains ${operation.state}`
|
|
592
|
+
},
|
|
593
|
+
env
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
return swapExecutionResult({
|
|
597
|
+
operation,
|
|
598
|
+
signer: taker,
|
|
599
|
+
order
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
if (entry?.state === "failed") {
|
|
603
|
+
const operation = storedSignerOperation(entry);
|
|
604
|
+
return {
|
|
605
|
+
ok: false,
|
|
606
|
+
code: "wallet_swap_failed",
|
|
607
|
+
message: operation?.error ?? entry.reason ?? "this swap intent failed; use a distinct explicit intentId for a new order"
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
if (entry?.state === "reserved" && provider.getSignerReview && autonomousIdentity) {
|
|
611
|
+
try {
|
|
612
|
+
const recovered = await provider.getSignerReview({
|
|
613
|
+
walletId: params.payload.walletId,
|
|
614
|
+
requestId: autonomousIdentity.key
|
|
615
|
+
});
|
|
616
|
+
if (!signerReviewMatchesAutonomousSwap({
|
|
617
|
+
review: recovered,
|
|
618
|
+
requestId: autonomousIdentity.key,
|
|
619
|
+
walletId: params.payload.walletId,
|
|
620
|
+
owner: taker,
|
|
621
|
+
inputMint: params.payload.inputMint,
|
|
622
|
+
outputMint: params.payload.outputMint,
|
|
623
|
+
amount: params.payload.amount
|
|
624
|
+
})) {
|
|
625
|
+
throw new Error("stored signer review does not match the durable autonomous swap intent");
|
|
626
|
+
}
|
|
627
|
+
if (recovered.semanticIntent.type !== "solana.jupiter.swap") {
|
|
628
|
+
throw new Error("stored signer review has an unexpected semantic intent type");
|
|
629
|
+
}
|
|
630
|
+
order = {
|
|
631
|
+
ok: true,
|
|
632
|
+
transaction: recovered.transaction.serializedTxBase64,
|
|
633
|
+
inputMint: params.payload.inputMint,
|
|
634
|
+
outputMint: params.payload.outputMint,
|
|
635
|
+
inAmount: params.payload.amount,
|
|
636
|
+
otherAmountThreshold: recovered.semanticIntent.jupiter.minimumOutputAmount,
|
|
637
|
+
slippageBps: params.payload.slippageBps,
|
|
638
|
+
raw: {}
|
|
639
|
+
};
|
|
640
|
+
entry = await updateExternalSubmission({
|
|
641
|
+
key: entry.key,
|
|
642
|
+
expectedStates: ["reserved"],
|
|
643
|
+
state: "prepared",
|
|
644
|
+
patch: {
|
|
645
|
+
signerRequestId: recovered.requestId,
|
|
646
|
+
signerIntentDigest: recovered.intentDigest,
|
|
647
|
+
transactionDigest: recovered.transactionDigest,
|
|
648
|
+
details: {
|
|
649
|
+
...entry.details,
|
|
650
|
+
order
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
env
|
|
654
|
+
});
|
|
655
|
+
} catch {}
|
|
656
|
+
}
|
|
657
|
+
const balance = await validateSolanaSwapInputBalance({
|
|
658
|
+
rpcUrl,
|
|
659
|
+
ownerAddress: taker,
|
|
660
|
+
inputMint: params.payload.inputMint,
|
|
661
|
+
amount: params.payload.amount
|
|
662
|
+
});
|
|
663
|
+
if (!balance.ok) {
|
|
664
|
+
return balance;
|
|
665
|
+
}
|
|
666
|
+
const reviewedOrder = params.autonomous ? undefined : reviewedSolanaSwapOrderFromPayload(params.payload);
|
|
667
|
+
order = order ?? reviewedOrder ?? await fetchJupiterSwapOrder({
|
|
668
|
+
inputMint: params.payload.inputMint,
|
|
669
|
+
outputMint: params.payload.outputMint,
|
|
670
|
+
amount: params.payload.amount,
|
|
671
|
+
slippageBps: params.payload.slippageBps,
|
|
672
|
+
taker,
|
|
673
|
+
env
|
|
674
|
+
});
|
|
675
|
+
const inspection = await inspectAndValidateSolanaSwapOrder({
|
|
676
|
+
order,
|
|
677
|
+
expectedSigner: taker,
|
|
678
|
+
rpcUrl,
|
|
679
|
+
config: effectiveConfig
|
|
680
|
+
});
|
|
681
|
+
if (!inspection.ok) {
|
|
682
|
+
return inspection;
|
|
683
|
+
}
|
|
684
|
+
if (!order.transaction) {
|
|
685
|
+
return {
|
|
686
|
+
ok: false,
|
|
687
|
+
code: "wallet_signer_v2_required",
|
|
688
|
+
message: "Jupiter signer review requires the exact serialized transaction"
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
let signerReviewRequestId;
|
|
692
|
+
if (params.autonomous && autonomousIdentity && entry) {
|
|
693
|
+
if (entry.state === "reserved") {
|
|
694
|
+
const prepared = await prepareSolanaSwapSignerReview({
|
|
695
|
+
provider,
|
|
696
|
+
walletId: params.payload.walletId,
|
|
697
|
+
owner: taker,
|
|
698
|
+
order,
|
|
699
|
+
inspection,
|
|
700
|
+
rpcUrl,
|
|
701
|
+
mode: "autonomous",
|
|
702
|
+
requestId: autonomousIdentity.key,
|
|
703
|
+
env
|
|
704
|
+
});
|
|
705
|
+
signerReviewRequestId = prepared.review.requestId;
|
|
706
|
+
entry = await updateExternalSubmission({
|
|
707
|
+
key: entry.key,
|
|
708
|
+
expectedStates: ["reserved"],
|
|
709
|
+
state: "prepared",
|
|
710
|
+
patch: {
|
|
711
|
+
signerRequestId: prepared.review.requestId,
|
|
712
|
+
signerIntentDigest: prepared.review.intentDigest,
|
|
713
|
+
transactionDigest: prepared.review.transactionDigest,
|
|
714
|
+
details: {
|
|
715
|
+
...entry.details,
|
|
716
|
+
order
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
env
|
|
720
|
+
});
|
|
721
|
+
} else {
|
|
722
|
+
signerReviewRequestId = entry.signerRequestId ?? "";
|
|
723
|
+
}
|
|
724
|
+
if (!signerReviewRequestId || signerReviewRequestId !== autonomousIdentity.key) {
|
|
725
|
+
return {
|
|
726
|
+
ok: false,
|
|
727
|
+
code: "wallet_provider_ambiguous",
|
|
728
|
+
message: "durable autonomous swap is not bound to its stable signer request"
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
} else {
|
|
732
|
+
const requestId = params.payload.signerReviewId?.trim();
|
|
733
|
+
if (!requestId) {
|
|
734
|
+
return {
|
|
735
|
+
ok: false,
|
|
736
|
+
code: "wallet_signer_review_missing",
|
|
737
|
+
message: "reviewed Jupiter swap is not bound to signer review.prepare"
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
signerReviewRequestId = requestId;
|
|
741
|
+
}
|
|
742
|
+
let executed;
|
|
743
|
+
try {
|
|
744
|
+
executed = await provider.executeJupiterReview({
|
|
745
|
+
walletId: params.payload.walletId,
|
|
746
|
+
requestId: signerReviewRequestId,
|
|
747
|
+
...params.reviewAuthorization ? { authorization: params.reviewAuthorization } : {}
|
|
748
|
+
});
|
|
749
|
+
} catch (error) {
|
|
750
|
+
if (entry) {
|
|
751
|
+
await updateExternalSubmission({
|
|
752
|
+
key: entry.key,
|
|
753
|
+
expectedStates: ["prepared"],
|
|
754
|
+
state: "unknown",
|
|
755
|
+
patch: { reason: `signer response was lost after exact review preparation: ${String(error)}` },
|
|
756
|
+
env
|
|
757
|
+
});
|
|
758
|
+
return {
|
|
759
|
+
ok: false,
|
|
760
|
+
code: "wallet_provider_ambiguous",
|
|
761
|
+
message: `signer response for ${signerReviewRequestId} is ambiguous; reconcile it before any new Jupiter order`
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
throw error;
|
|
765
|
+
}
|
|
766
|
+
const result = swapExecutionResult({
|
|
767
|
+
operation: executed.operation,
|
|
768
|
+
signer: executed.signer,
|
|
769
|
+
order,
|
|
770
|
+
inspection
|
|
771
|
+
});
|
|
772
|
+
if (entry) {
|
|
773
|
+
const confirmed = executed.operation.state === "confirmed" && Boolean(executed.operation.signature);
|
|
774
|
+
const failed = executed.operation.state === "failed";
|
|
775
|
+
await updateExternalSubmission({
|
|
776
|
+
key: entry.key,
|
|
777
|
+
expectedStates: ["prepared"],
|
|
778
|
+
state: confirmed ? "confirmed" : failed ? "failed" : "unknown",
|
|
779
|
+
patch: {
|
|
780
|
+
signerSignature: executed.operation.signature,
|
|
781
|
+
transactionDigest: executed.operation.transactionDigest,
|
|
782
|
+
result: {
|
|
783
|
+
operation: executed.operation,
|
|
784
|
+
signer: executed.signer
|
|
785
|
+
},
|
|
786
|
+
reason: result.ok ? undefined : result.message
|
|
787
|
+
},
|
|
788
|
+
env
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
return result;
|
|
792
|
+
} finally {
|
|
793
|
+
await releaseExecution?.();
|
|
794
|
+
}
|
|
339
795
|
}
|
|
340
796
|
|
|
341
797
|
//#endregion
|
|
342
|
-
export { SOLANA_NATIVE_MINT, executeSolanaSwapApprovalPayload, fetchJupiterSwapOrder, inspectAndValidateSolanaSwapOrder, isSolanaSwapApprovalPayload, validateSolanaSwapInputBalance, validateSolanaSwapIntentPolicy };
|
|
798
|
+
export { SOLANA_NATIVE_MINT, executeSolanaSwapApprovalPayload, fetchJupiterSwapOrder, inspectAndValidateSolanaSwapOrder, isSolanaSwapApprovalPayload, prepareSolanaSwapSignerReview, resolveJupiterMaxFeeLamports, validateSolanaSwapInputBalance, validateSolanaSwapIntentPolicy };
|