@aurora-is-near/intents-connect 7.20.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.
Files changed (119) hide show
  1. package/README.md +176 -0
  2. package/dist/api/createIntentsConnectApi.d.ts +31 -0
  3. package/dist/api/index.d.ts +3 -0
  4. package/dist/api/types.d.ts +93 -0
  5. package/dist/chains.d.ts +27 -0
  6. package/dist/chunks/recovery-BBQaAcqE.js +1034 -0
  7. package/dist/chunks/recovery-BBQaAcqE.js.map +1 -0
  8. package/dist/errors.d.ts +94 -0
  9. package/dist/index.d.ts +11 -0
  10. package/dist/index.js +197 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/logger.d.ts +7 -0
  13. package/dist/machine/context.d.ts +39 -0
  14. package/dist/machine/guards/checks/amountMustExceedFee.d.ts +2 -0
  15. package/dist/machine/guards/checks/destinationTokenIsTouched.d.ts +12 -0
  16. package/dist/machine/guards/checks/feeMustBeEstimated.d.ts +9 -0
  17. package/dist/machine/guards/checks/memoPresentForStellar.d.ts +6 -0
  18. package/dist/machine/guards/checks/mustBeSignedBeforeDeposit.d.ts +8 -0
  19. package/dist/machine/guards/checks/mustHaveSigningPayload.d.ts +7 -0
  20. package/dist/machine/guards/checks/noExecutionInFlight.d.ts +7 -0
  21. package/dist/machine/guards/checks/originNetworkMatches.d.ts +5 -0
  22. package/dist/machine/guards/checks/publicKeyMatchesStandard.d.ts +7 -0
  23. package/dist/machine/guards/checks/quoteMustNotHaveMoved.d.ts +8 -0
  24. package/dist/machine/guards/checks/recipientOnlyOnOutOperation.d.ts +11 -0
  25. package/dist/machine/guards/checks/round1MustBeStepless.d.ts +8 -0
  26. package/dist/machine/guards/checks/stepShapeIsLegal.d.ts +7 -0
  27. package/dist/machine/guards/checks/stepsRequiredForRealCreate.d.ts +6 -0
  28. package/dist/machine/guards/checks/strategiesAreExclusive.d.ts +17 -0
  29. package/dist/machine/guards/index.d.ts +19 -0
  30. package/dist/machine/index.d.ts +4 -0
  31. package/dist/machine/machine.d.ts +50 -0
  32. package/dist/machine/phases.d.ts +48 -0
  33. package/dist/react/IntentsConnectProvider.d.ts +12 -0
  34. package/dist/react/context.d.ts +12 -0
  35. package/dist/react/index.d.ts +3 -0
  36. package/dist/react/index.js +149 -0
  37. package/dist/react/index.js.map +1 -0
  38. package/dist/react/useExecution.d.ts +42 -0
  39. package/dist/recovery.d.ts +27 -0
  40. package/dist/runner/createExecutionRunner.d.ts +2 -0
  41. package/dist/runner/index.d.ts +2 -0
  42. package/dist/runner/types.d.ts +146 -0
  43. package/dist/signers/index.d.ts +2 -0
  44. package/dist/signers/intentsConnect.d.ts +43 -0
  45. package/dist/signers/standards/encoding.d.ts +15 -0
  46. package/dist/signers/standards/erc191.d.ts +18 -0
  47. package/dist/signers/standards/index.d.ts +12 -0
  48. package/dist/signers/standards/nep413.d.ts +22 -0
  49. package/dist/signers/standards/rawEd25519.d.ts +20 -0
  50. package/dist/signers/standards/sep53.d.ts +22 -0
  51. package/dist/types/execution.d.ts +133 -0
  52. package/dist/types/index.d.ts +6 -0
  53. package/dist/types/providers.d.ts +63 -0
  54. package/dist/types/recipe.d.ts +38 -0
  55. package/dist/types/signing.d.ts +70 -0
  56. package/dist/types/transfer.d.ts +60 -0
  57. package/dist/types/wallet.d.ts +53 -0
  58. package/package.json +54 -0
  59. package/react/package.json +8 -0
  60. package/src/api/createIntentsConnectApi.test.ts +146 -0
  61. package/src/api/createIntentsConnectApi.ts +263 -0
  62. package/src/api/generated/conformance.ts +233 -0
  63. package/src/api/generated/openapi.ts +995 -0
  64. package/src/api/index.ts +17 -0
  65. package/src/api/types.ts +138 -0
  66. package/src/chains.ts +103 -0
  67. package/src/errors.ts +234 -0
  68. package/src/index.ts +73 -0
  69. package/src/logger.ts +21 -0
  70. package/src/machine/context.ts +56 -0
  71. package/src/machine/guards/checks/amountMustExceedFee.ts +14 -0
  72. package/src/machine/guards/checks/destinationTokenIsTouched.ts +31 -0
  73. package/src/machine/guards/checks/feeMustBeEstimated.ts +22 -0
  74. package/src/machine/guards/checks/memoPresentForStellar.ts +20 -0
  75. package/src/machine/guards/checks/mustBeSignedBeforeDeposit.ts +17 -0
  76. package/src/machine/guards/checks/mustHaveSigningPayload.ts +19 -0
  77. package/src/machine/guards/checks/noExecutionInFlight.ts +19 -0
  78. package/src/machine/guards/checks/originNetworkMatches.ts +23 -0
  79. package/src/machine/guards/checks/publicKeyMatchesStandard.ts +28 -0
  80. package/src/machine/guards/checks/quoteMustNotHaveMoved.ts +20 -0
  81. package/src/machine/guards/checks/recipientOnlyOnOutOperation.ts +23 -0
  82. package/src/machine/guards/checks/round1MustBeStepless.ts +17 -0
  83. package/src/machine/guards/checks/stepShapeIsLegal.ts +79 -0
  84. package/src/machine/guards/checks/stepsRequiredForRealCreate.ts +12 -0
  85. package/src/machine/guards/checks/strategiesAreExclusive.ts +35 -0
  86. package/src/machine/guards/guards.test.ts +317 -0
  87. package/src/machine/guards/index.ts +22 -0
  88. package/src/machine/index.ts +15 -0
  89. package/src/machine/machine.test.ts +131 -0
  90. package/src/machine/machine.ts +113 -0
  91. package/src/machine/phases.ts +81 -0
  92. package/src/react/IntentsConnectProvider.tsx +61 -0
  93. package/src/react/context.ts +34 -0
  94. package/src/react/index.ts +14 -0
  95. package/src/react/useExecution.test.tsx +281 -0
  96. package/src/react/useExecution.ts +246 -0
  97. package/src/recovery.test.ts +44 -0
  98. package/src/recovery.ts +45 -0
  99. package/src/runner/createExecutionRunner.test.ts +1388 -0
  100. package/src/runner/createExecutionRunner.ts +1156 -0
  101. package/src/runner/index.ts +9 -0
  102. package/src/runner/types.ts +148 -0
  103. package/src/signers/index.ts +7 -0
  104. package/src/signers/intentsConnect.ts +210 -0
  105. package/src/signers/signers.test.ts +415 -0
  106. package/src/signers/standards/encoding.ts +89 -0
  107. package/src/signers/standards/erc191.ts +61 -0
  108. package/src/signers/standards/index.ts +20 -0
  109. package/src/signers/standards/nep413.ts +84 -0
  110. package/src/signers/standards/rawEd25519.ts +46 -0
  111. package/src/signers/standards/sep53.ts +74 -0
  112. package/src/tests/setup.ts +4 -0
  113. package/src/types/execution.ts +177 -0
  114. package/src/types/index.ts +6 -0
  115. package/src/types/providers.ts +71 -0
  116. package/src/types/recipe.ts +41 -0
  117. package/src/types/signing.ts +99 -0
  118. package/src/types/transfer.ts +90 -0
  119. package/src/types/wallet.ts +60 -0
@@ -0,0 +1,149 @@
1
+ import { jsx as A } from "react/jsx-runtime";
2
+ import { createContext as I, useContext as N, useMemo as w, useRef as E, useEffect as O, useState as k, useCallback as p } from "react";
3
+ import { useSnapshot as D } from "valtio";
4
+ import { G as R, $ as m, H as _, V as L } from "../chunks/recovery-BBQaAcqE.js";
5
+ import "@scure/base";
6
+ const C = I(null), M = () => {
7
+ const c = N(C);
8
+ if (!c)
9
+ throw new Error(
10
+ "useIntentsConnect must be used inside an <IntentsConnectProvider>"
11
+ );
12
+ return c;
13
+ }, G = ({
14
+ children: c,
15
+ ...x
16
+ }) => {
17
+ const {
18
+ api: a,
19
+ wallet: s,
20
+ plugins: g,
21
+ pluginOptions: u,
22
+ makeTransfer: l,
23
+ logger: n,
24
+ pollIntervalMs: d,
25
+ maxPollAttempts: i
26
+ } = x, r = w(
27
+ () => ({
28
+ api: a,
29
+ wallet: s,
30
+ plugins: g,
31
+ pluginOptions: u,
32
+ makeTransfer: l,
33
+ logger: n,
34
+ pollIntervalMs: d,
35
+ maxPollAttempts: i
36
+ }),
37
+ [
38
+ a,
39
+ s,
40
+ g,
41
+ u,
42
+ l,
43
+ n,
44
+ d,
45
+ i
46
+ ]
47
+ );
48
+ return /* @__PURE__ */ A(C.Provider, { value: r, children: c });
49
+ }, P = [
50
+ "resolving-identity",
51
+ "planning",
52
+ "creating",
53
+ "awaiting-signature",
54
+ "submitting",
55
+ "awaiting-deposit",
56
+ "settling"
57
+ ], j = (c = {}) => {
58
+ const x = M(), { api: a, wallet: s, ...g } = x, u = E(c.onEvent);
59
+ u.current = c.onEvent;
60
+ const l = E(s);
61
+ l.current = s;
62
+ const n = E(a);
63
+ n.current = a;
64
+ const d = w(
65
+ () => ({
66
+ getIntermediary: (...e) => n.current.getIntermediary(...e),
67
+ createExecution: (...e) => n.current.createExecution(...e),
68
+ createStepsExecution: (...e) => n.current.createStepsExecution(...e),
69
+ listSupportedTokens: (...e) => n.current.listSupportedTokens(...e),
70
+ submitSignature: (...e) => n.current.submitSignature(...e),
71
+ recordDeposit: (...e) => n.current.recordDeposit(...e),
72
+ listExecutions: (...e) => n.current.listExecutions(...e),
73
+ deleteExecution: (...e) => n.current.deleteExecution(...e)
74
+ }),
75
+ []
76
+ ), i = s ? `${s.signingStandard}:${s.getAddress() ?? ""}` : null, r = w(
77
+ () => i ? R({
78
+ ...g,
79
+ api: d,
80
+ // An accessor, not a value: see `walletRef` above. It is BOUND to
81
+ // the walletKey generation that built this runner: after an
82
+ // account or standard switch, walletRef points at the NEW wallet,
83
+ // and letting an orphaned in-flight run read it would sign or
84
+ // transfer with the wrong account's keys and funds.
85
+ wallet: () => {
86
+ const { current: e } = l;
87
+ return e ? `${e.signingStandard}:${e.getAddress() ?? ""}` !== i ? m(
88
+ "WALLET_NOT_CONNECTED",
89
+ "the connected wallet changed while an execution was running — resume() it from the new runner"
90
+ ) : e : m(
91
+ "WALLET_NOT_CONNECTED",
92
+ "the wallet was disconnected while an execution was running"
93
+ );
94
+ },
95
+ onEvent: (e) => u.current?.(e)
96
+ }) : null,
97
+ // The ONLY thing that invalidates a runner is the account it is bound to.
98
+ // Object identities are deliberately absent, and so are the remaining options
99
+ // (logger, poll interval, plugins) — those are read once at construction, so
100
+ // including them would discard live state.
101
+ [d, i]
102
+ );
103
+ O(() => () => r?.dispose(), [r]);
104
+ const [h] = k(_), y = r ? r.getStore() : h.getStore(), t = D(y).context, o = p(() => r || m(
105
+ "WALLET_NOT_CONNECTED",
106
+ "connect a wallet before starting an execution"
107
+ ), [r]), S = p(
108
+ async (e) => o().run(e),
109
+ [o]
110
+ ), v = p(
111
+ async (e, f) => o().resume(e, f),
112
+ [o]
113
+ ), T = p(
114
+ async () => o().retryDeposit(),
115
+ [o]
116
+ ), b = p(
117
+ async (e) => o().cancel(e),
118
+ [o]
119
+ );
120
+ return {
121
+ phase: t.phase,
122
+ status: t.status,
123
+ executionId: t.executionId,
124
+ execution: t.execution,
125
+ networkFee: t.networkFee,
126
+ spendable: t.spendable,
127
+ depositAddress: t.depositAddress,
128
+ depositMemo: t.depositMemo,
129
+ deadline: t.deadline,
130
+ depositTxHash: t.depositTxHash,
131
+ error: t.error,
132
+ recovery: L(t.error),
133
+ isCancelling: t.isCancelling,
134
+ // Cancelling counts as busy on its own: it is commonly invoked FROM a
135
+ // terminal phase (the in-flight recovery), where no phase says "working".
136
+ isBusy: P.includes(t.phase) || t.isCancelling,
137
+ run: S,
138
+ resume: v,
139
+ retryDeposit: T,
140
+ cancel: b
141
+ };
142
+ };
143
+ export {
144
+ C as IntentsConnectContext,
145
+ G as IntentsConnectProvider,
146
+ j as useExecution,
147
+ M as useIntentsConnect
148
+ };
149
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/react/context.ts","../../src/react/IntentsConnectProvider.tsx","../../src/react/useExecution.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type {\n ExecutionRunnerOptions,\n IntentsConnectApi,\n WalletConnector,\n} from '@/index';\n\n/** Everything a `useExecution` call needs that is not per-execution. */\nexport type IntentsConnectContextValue = Omit<\n ExecutionRunnerOptions,\n 'api' | 'wallet' | 'onEvent'\n> & {\n api: IntentsConnectApi;\n /**\n * The connected wallet. `null` while disconnected — `useExecution` surfaces a\n * `WALLET_NOT_CONNECTED` guard rather than throwing at render time.\n */\n wallet: WalletConnector | null;\n};\n\nexport const IntentsConnectContext =\n createContext<IntentsConnectContextValue | null>(null);\n\nexport const useIntentsConnect = (): IntentsConnectContextValue => {\n const value = useContext(IntentsConnectContext);\n\n if (!value) {\n throw new Error(\n 'useIntentsConnect must be used inside an <IntentsConnectProvider>',\n );\n }\n\n return value;\n};\n","import { type ReactNode, useMemo } from 'react';\n\nimport {\n IntentsConnectContext,\n type IntentsConnectContextValue,\n} from '@/react/context';\n\nexport type IntentsConnectProviderProps = IntentsConnectContextValue & {\n children: ReactNode;\n};\n\n/**\n * Supplies the API client and connected wallet to `useExecution`.\n *\n * Deliberately holds no execution state of its own: a runner is created per\n * `useExecution` call so two concurrent executions never share a machine.\n */\nexport const IntentsConnectProvider = ({\n children,\n ...value\n}: IntentsConnectProviderProps) => {\n const {\n api,\n wallet,\n plugins,\n pluginOptions,\n makeTransfer,\n logger,\n pollIntervalMs,\n maxPollAttempts,\n } = value;\n\n const memoised = useMemo<IntentsConnectContextValue>(\n () => ({\n api,\n wallet,\n plugins,\n pluginOptions,\n makeTransfer,\n logger,\n pollIntervalMs,\n maxPollAttempts,\n }),\n [\n api,\n wallet,\n plugins,\n pluginOptions,\n makeTransfer,\n logger,\n pollIntervalMs,\n maxPollAttempts,\n ],\n );\n\n return (\n <IntentsConnectContext.Provider value={memoised}>\n {children}\n </IntentsConnectContext.Provider>\n );\n};\n","import { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useSnapshot } from 'valtio';\nimport {\n createExecutionMachine,\n createExecutionRunner,\n deriveExecutionRecovery,\n type Execution,\n type ExecutionPlan,\n type ExecutionRecovery,\n type ExecutionStatus,\n failGuard,\n type IntentsConnectApi,\n type Phase,\n type ResumeDepositOptions,\n type RunnerEvent,\n} from '@/index';\n\nimport { useIntentsConnect } from '@/react/context';\n\nexport type UseExecutionOptions = {\n /** Called for every runner event, in order. */\n onEvent?: (event: RunnerEvent) => void;\n};\n\nexport type UseExecutionResult = {\n phase: Phase;\n status?: ExecutionStatus;\n executionId?: string;\n execution?: Execution;\n\n /** Exact figures. Only populated by the `threeRound` fee strategy. */\n networkFee?: string;\n spendable?: string;\n\n /** Only ever set after the signature is submitted. */\n depositAddress?: string;\n depositMemo?: string | null;\n /** ISO — the deposit-address validity deadline. */\n deadline?: string;\n depositTxHash?: string;\n\n error?: Error;\n /** Actionable classification of `error` — see `ExecutionRecovery`. */\n recovery?: ExecutionRecovery;\n /**\n * A `delete_execution` signature is being prompted. Orthogonal to `phase`,\n * which still names the stage the cancellation interrupted — label the\n * wallet prompt from THIS, not from the phase.\n */\n isCancelling: boolean;\n isBusy: boolean;\n\n run: <TParams>(plan: ExecutionPlan<TParams>) => Promise<Execution>;\n resume: (\n executionId: string,\n options?: ResumeDepositOptions,\n ) => Promise<Execution>;\n /** Re-prompts a rejected/failed deposit transfer (`DepositTransferError`). */\n retryDeposit: () => Promise<Execution>;\n cancel: (executionId?: string) => Promise<void>;\n};\n\nconst BUSY_PHASES: readonly Phase[] = [\n 'resolving-identity',\n 'planning',\n 'creating',\n 'awaiting-signature',\n 'submitting',\n 'awaiting-deposit',\n 'settling',\n];\n\n/**\n * Binds one execution runner to React.\n *\n * The runner is created once per hook instance and its valtio store is read\n * through `useSnapshot`, so only components that read a changed field re-render.\n */\nexport const useExecution = (\n options: UseExecutionOptions = {},\n): UseExecutionResult => {\n const context = useIntentsConnect();\n const { api, wallet, ...runnerOptions } = context;\n\n // Kept in a ref so a changing callback identity does not rebuild the runner\n // (which would discard the live execution's state).\n const onEventRef = useRef(options.onEvent);\n\n onEventRef.current = options.onEvent;\n\n // Same reasoning for the connector itself. Most React connectors return a\n // fresh object every render, so depending on its identity would rebuild the\n // runner on every render — and because the runner emits events that trigger\n // renders, a live execution would be reset to `idle` mid-flight. The runner\n // reads through this ref, so it always sees the current connector.\n const walletRef = useRef(wallet);\n\n walletRef.current = wallet;\n\n // And the api client, for the same reason: an inline\n // `api={createIntentsConnectApi(...)}` changes identity every render. Nothing\n // about swapping the client should invalidate a live execution, so the runner\n // gets a stable façade that forwards to whichever client is current.\n const apiRef = useRef(api);\n\n apiRef.current = api;\n\n const stableApi = useMemo<IntentsConnectApi>(\n () => ({\n getIntermediary: (...args) => apiRef.current.getIntermediary(...args),\n createExecution: (...args) => apiRef.current.createExecution(...args),\n createStepsExecution: (...args) =>\n apiRef.current.createStepsExecution(...args),\n listSupportedTokens: (...args) =>\n apiRef.current.listSupportedTokens(...args),\n submitSignature: (...args) => apiRef.current.submitSignature(...args),\n recordDeposit: (...args) => apiRef.current.recordDeposit(...args),\n listExecutions: (...args) => apiRef.current.listExecutions(...args),\n deleteExecution: (...args) => apiRef.current.deleteExecution(...args),\n }),\n [],\n );\n\n /**\n * What actually distinguishes one runner from another: the account it is bound\n * to and the standard it signs with. Both feed the intermediary address and the\n * signing path, so a change here genuinely invalidates an in-flight execution —\n * unlike a change of object identity.\n */\n const walletKey = wallet\n ? `${wallet.signingStandard}:${wallet.getAddress() ?? ''}`\n : null;\n\n const runner = useMemo(\n () =>\n walletKey\n ? createExecutionRunner({\n ...runnerOptions,\n api: stableApi,\n // An accessor, not a value: see `walletRef` above. It is BOUND to\n // the walletKey generation that built this runner: after an\n // account or standard switch, walletRef points at the NEW wallet,\n // and letting an orphaned in-flight run read it would sign or\n // transfer with the wrong account's keys and funds.\n wallet: () => {\n const { current } = walletRef;\n\n if (!current) {\n return failGuard(\n 'WALLET_NOT_CONNECTED',\n 'the wallet was disconnected while an execution was running',\n );\n }\n\n const currentKey = `${current.signingStandard}:${current.getAddress() ?? ''}`;\n\n if (currentKey !== walletKey) {\n return failGuard(\n 'WALLET_NOT_CONNECTED',\n 'the connected wallet changed while an execution was running — resume() it from the new runner',\n );\n }\n\n return current;\n },\n onEvent: (event) => onEventRef.current?.(event),\n })\n : null,\n // The ONLY thing that invalidates a runner is the account it is bound to.\n // Object identities are deliberately absent, and so are the remaining options\n // (logger, poll interval, plugins) — those are read once at construction, so\n // including them would discard live state.\n [stableApi, walletKey],\n );\n\n // When the account changes (or the hook unmounts), the superseded runner is\n // disposed so an orphaned run stops polling and emitting through the shared\n // onEvent instead of surviving invisibly for minutes.\n useEffect(() => () => runner?.dispose(), [runner]);\n\n // A real idle machine stands in while no wallet is connected, so the snapshot\n // hook is always called unconditionally and the store shape never varies.\n const [fallbackMachine] = useState(createExecutionMachine);\n\n const store = runner ? runner.getStore() : fallbackMachine.getStore();\n const snapshot = useSnapshot(store);\n const ctx = snapshot.context;\n\n const requireRunner = useCallback(() => {\n if (!runner) {\n return failGuard(\n 'WALLET_NOT_CONNECTED',\n 'connect a wallet before starting an execution',\n );\n }\n\n return runner;\n }, [runner]);\n\n // Declared async so a missing runner REJECTS rather than throwing\n // synchronously — otherwise `run(plan).catch(...)` would still blow up at the\n // call site, which is the shape every caller writes.\n const run = useCallback(\n async <TParams>(plan: ExecutionPlan<TParams>) => requireRunner().run(plan),\n [requireRunner],\n );\n\n const resume = useCallback(\n async (executionId: string, depositOptions?: ResumeDepositOptions) =>\n requireRunner().resume(executionId, depositOptions),\n [requireRunner],\n );\n\n const retryDeposit = useCallback(\n async () => requireRunner().retryDeposit(),\n [requireRunner],\n );\n\n const cancel = useCallback(\n async (executionId?: string) => requireRunner().cancel(executionId),\n [requireRunner],\n );\n\n return {\n phase: ctx.phase,\n status: ctx.status,\n executionId: ctx.executionId,\n execution: ctx.execution as Execution | undefined,\n networkFee: ctx.networkFee,\n spendable: ctx.spendable,\n depositAddress: ctx.depositAddress,\n depositMemo: ctx.depositMemo,\n deadline: ctx.deadline,\n depositTxHash: ctx.depositTxHash,\n error: ctx.error,\n recovery: deriveExecutionRecovery(ctx.error),\n isCancelling: ctx.isCancelling,\n // Cancelling counts as busy on its own: it is commonly invoked FROM a\n // terminal phase (the in-flight recovery), where no phase says \"working\".\n isBusy: BUSY_PHASES.includes(ctx.phase) || ctx.isCancelling,\n run,\n resume,\n retryDeposit,\n cancel,\n };\n};\n"],"names":["IntentsConnectContext","createContext","useIntentsConnect","value","useContext","IntentsConnectProvider","children","api","wallet","plugins","pluginOptions","makeTransfer","logger","pollIntervalMs","maxPollAttempts","memoised","useMemo","BUSY_PHASES","useExecution","options","context","runnerOptions","onEventRef","useRef","walletRef","apiRef","stableApi","args","walletKey","runner","createExecutionRunner","current","failGuard","event","useEffect","fallbackMachine","useState","createExecutionMachine","store","ctx","useSnapshot","requireRunner","useCallback","run","plan","resume","executionId","depositOptions","retryDeposit","cancel","deriveExecutionRecovery"],"mappings":"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"}
@@ -0,0 +1,42 @@
1
+ import { Execution, ExecutionPlan, ExecutionRecovery, ExecutionStatus, Phase, ResumeDepositOptions, RunnerEvent } from '../index';
2
+ export type UseExecutionOptions = {
3
+ /** Called for every runner event, in order. */
4
+ onEvent?: (event: RunnerEvent) => void;
5
+ };
6
+ export type UseExecutionResult = {
7
+ phase: Phase;
8
+ status?: ExecutionStatus;
9
+ executionId?: string;
10
+ execution?: Execution;
11
+ /** Exact figures. Only populated by the `threeRound` fee strategy. */
12
+ networkFee?: string;
13
+ spendable?: string;
14
+ /** Only ever set after the signature is submitted. */
15
+ depositAddress?: string;
16
+ depositMemo?: string | null;
17
+ /** ISO — the deposit-address validity deadline. */
18
+ deadline?: string;
19
+ depositTxHash?: string;
20
+ error?: Error;
21
+ /** Actionable classification of `error` — see `ExecutionRecovery`. */
22
+ recovery?: ExecutionRecovery;
23
+ /**
24
+ * A `delete_execution` signature is being prompted. Orthogonal to `phase`,
25
+ * which still names the stage the cancellation interrupted — label the
26
+ * wallet prompt from THIS, not from the phase.
27
+ */
28
+ isCancelling: boolean;
29
+ isBusy: boolean;
30
+ run: <TParams>(plan: ExecutionPlan<TParams>) => Promise<Execution>;
31
+ resume: (executionId: string, options?: ResumeDepositOptions) => Promise<Execution>;
32
+ /** Re-prompts a rejected/failed deposit transfer (`DepositTransferError`). */
33
+ retryDeposit: () => Promise<Execution>;
34
+ cancel: (executionId?: string) => Promise<void>;
35
+ };
36
+ /**
37
+ * Binds one execution runner to React.
38
+ *
39
+ * The runner is created once per hook instance and its valtio store is read
40
+ * through `useSnapshot`, so only components that read a changed field re-render.
41
+ */
42
+ export declare const useExecution: (options?: UseExecutionOptions) => UseExecutionResult;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * A recoverable dead-end, classified so a UI renders actions instead of prose.
3
+ *
4
+ * This is the interpretation contract for the runner's error taxonomy — every
5
+ * consumer would otherwise re-derive it with `instanceof` chains, and less
6
+ * completely. Derive it from the error the hook/runner reports:
7
+ *
8
+ * - `resume-or-cancel`: another execution holds the per-wallet in-flight lock
9
+ * (`EXECUTION_IN_FLIGHT`). Offer `resume(executionId)` — which re-drives
10
+ * whatever is left of that execution, signature and deposit included — or
11
+ * `cancel(executionId)` to release the lock.
12
+ * - `retry-transfer`: the deposit transfer was rejected or failed in the
13
+ * wallet, everything before it is valid and signed server-side. Offer
14
+ * `retryDeposit()`. `cause` names what actually broke in the wallet.
15
+ *
16
+ * `undefined` means the error (or its absence) has no dedicated recovery
17
+ * action — render it as a plain failure.
18
+ */
19
+ export type ExecutionRecovery = {
20
+ kind: 'resume-or-cancel';
21
+ executionId: string;
22
+ } | {
23
+ kind: 'retry-transfer';
24
+ executionId: string;
25
+ cause?: Error;
26
+ };
27
+ export declare const deriveExecutionRecovery: (error: unknown) => ExecutionRecovery | undefined;
@@ -0,0 +1,2 @@
1
+ import { ExecutionRunner, ExecutionRunnerOptions } from './types';
2
+ export declare const createExecutionRunner: (options: ExecutionRunnerOptions) => ExecutionRunner;
@@ -0,0 +1,2 @@
1
+ export { createExecutionRunner } from './createExecutionRunner';
2
+ export type { ExecutionPlan, ExecutionRunner, ExecutionRunnerOptions, OriginToken, ResumeDepositOptions, RunnerEvent, } from './types';
@@ -0,0 +1,146 @@
1
+ import { IntentsConnectApi } from '../api/types';
2
+ import { Logger } from '../logger';
3
+ import { Execution, ExecutionStatus, FeeStrategy, QuoteRequest } from '../types/execution';
4
+ import { Recipe } from '../types/recipe';
5
+ import { MakeTransfer, TransferPlugins } from '../types/transfer';
6
+ import { WalletConnector } from '../types/wallet';
7
+ import { Phase } from '../machine/phases';
8
+ export type RunnerEvent = {
9
+ type: 'phase';
10
+ phase: Phase;
11
+ } | {
12
+ type: 'status';
13
+ status: ExecutionStatus;
14
+ } | {
15
+ type: 'created';
16
+ executionId: string;
17
+ }
18
+ /** Exact figures. Only emitted by the `threeRound` fee strategy. */
19
+ | {
20
+ type: 'quoted';
21
+ networkFee: string;
22
+ spendable: string;
23
+ }
24
+ /** Never emitted before the signature is submitted. */
25
+ | {
26
+ type: 'deposit-address';
27
+ address: string;
28
+ memo: string | null;
29
+ deadline?: string;
30
+ } | {
31
+ type: 'deposit-sent';
32
+ txHash: string;
33
+ } | {
34
+ type: 'error';
35
+ error: Error;
36
+ };
37
+ export type OriginToken = {
38
+ /** Absent means the chain's native gas asset. */
39
+ contractAddress?: string;
40
+ decimals: number;
41
+ };
42
+ export type ExecutionPlan<TParams = void> = {
43
+ recipe: Recipe<TParams>;
44
+ params: TParams;
45
+ quote: QuoteRequest;
46
+ /** Defaults to `{ kind: 'placeholder' }` — one round, service carves the fee. */
47
+ feeStrategy?: FeeStrategy;
48
+ /** Lowercase chain id of the origin asset, e.g. `base`, `sol`, `btc`. */
49
+ originChain: string;
50
+ originToken: OriginToken;
51
+ /**
52
+ * `false` routes to the QR / exchange path: no wallet transfer, no
53
+ * `deposit/submit`, settlement observed by the backend's deposit watcher.
54
+ */
55
+ depositViaWallet: boolean;
56
+ /** EVM origins: enables the network-mismatch guard. */
57
+ originChainId?: number | null;
58
+ };
59
+ export type ExecutionRunnerOptions = {
60
+ api: IntentsConnectApi;
61
+ /**
62
+ * Supplies the address, signing standard, providers and (usually) transfers.
63
+ *
64
+ * Accepts an accessor as well as a value. Pass an accessor when the connector
65
+ * object is rebuilt on every render (most React connectors are): the runner
66
+ * then always reads the current one, so its own identity can stay stable and a
67
+ * live execution is not thrown away by an unrelated re-render.
68
+ */
69
+ wallet: WalletConnector | (() => WalletConnector);
70
+ /**
71
+ * Escape hatch: widget network plugins keyed by chain family. Used when the
72
+ * connector has no `makeTransfer` of its own.
73
+ */
74
+ plugins?: TransferPlugins;
75
+ /**
76
+ * Options forwarded to a plugin's `makeTransfer`.
77
+ *
78
+ * Single-family setups pass the plugin's options directly (usually
79
+ * `{ provider }`). Multi-chain setups namespace them by chain family —
80
+ * `{ evm: { provider }, sol: { provider }, near: { wallet } }` — because
81
+ * each family's plugin expects a different, incompatible shape; the runner
82
+ * hands each plugin only its own slice.
83
+ */
84
+ pluginOptions?: unknown;
85
+ /** Overrides both of the above. */
86
+ makeTransfer?: MakeTransfer<void>;
87
+ logger?: Logger;
88
+ /**
89
+ * When the user REJECTS the signing prompt during `run()`, immediately offer
90
+ * the `delete_execution` signature so the created execution does not stay
91
+ * holding the per-wallet in-flight lock — the next `run()` then starts clean
92
+ * instead of demanding an explicit resume-or-cancel decision. Declining that
93
+ * second prompt falls back to the normal recovery. Defaults to `true`.
94
+ */
95
+ autoCancelOnSignatureRejection?: boolean;
96
+ /** Defaults to 3_000. */
97
+ pollIntervalMs?: number;
98
+ /** Defaults to 240 (~12 minutes at the default interval). */
99
+ maxPollAttempts?: number;
100
+ onEvent?: (event: RunnerEvent) => void;
101
+ };
102
+ /**
103
+ * Optional origin details for `resume()`, filling in what an execution alone
104
+ * cannot answer when the deposit transfer has to be rebuilt without the
105
+ * original plan (a page reload lost it):
106
+ *
107
+ * - EVM origins need none of this — chain and token address are decoded from
108
+ * `quote.originAsset` and the chain id from the built-in registry; pass
109
+ * `originChainId` only for a chain the registry does not know.
110
+ * - Every other family (`sol`, `stellar`, `near`) formats amounts with the
111
+ * token's decimals, so `originToken` is REQUIRED there — without it the
112
+ * deposit address is surfaced for a manual transfer instead.
113
+ */
114
+ export type ResumeDepositOptions = {
115
+ originToken?: OriginToken;
116
+ originChainId?: number | null;
117
+ /** `false` skips any wallet-transfer attempt (QR / exchange deposits). */
118
+ depositViaWallet?: boolean;
119
+ };
120
+ export type ExecutionRunner = {
121
+ /** Drives the full bridge-in lifecycle and resolves on a terminal status. */
122
+ run: <TParams>(plan: ExecutionPlan<TParams>) => Promise<Execution>;
123
+ /**
124
+ * Reattaches to an execution after a reload and resumes from wherever it
125
+ * actually got — including driving the deposit transfer for a signed but
126
+ * unfunded execution (see `ResumeDepositOptions`).
127
+ */
128
+ resume: (executionId: string, options?: ResumeDepositOptions) => Promise<Execution>;
129
+ /**
130
+ * Re-prompts the deposit transfer after it was rejected or failed
131
+ * (`DepositTransferError`) — the execution is still valid and signed.
132
+ */
133
+ retryDeposit: () => Promise<Execution>;
134
+ /** Clears the in-flight lock by signing `delete_execution:{id}`. */
135
+ cancel: (executionId?: string) => Promise<void>;
136
+ /**
137
+ * Permanently detaches the runner from its wallet: every in-flight stage
138
+ * stops at its next checkpoint and no further wallet or API side effect is
139
+ * performed. Call it when the bound wallet/account changes — the execution
140
+ * itself is untouched and can be `resume()`d from a correctly bound runner.
141
+ */
142
+ dispose: () => void;
143
+ getPhase: () => Phase;
144
+ /** The valtio store, for framework bindings. */
145
+ getStore: () => ReturnType<import('../machine/machine').ExecutionMachine['getStore']>;
146
+ };
@@ -0,0 +1,2 @@
1
+ export * as standards from './standards';
2
+ export { signIntentsConnectPayload, signIntentsConnectText, type SignPayloadArgs, type SignTextArgs, } from './intentsConnect';
@@ -0,0 +1,43 @@
1
+ import { Providers } from '../types/providers';
2
+ import { DeleteSignatureEnvelope, SignatureEnvelope, SigningPayload, SigningStandard } from '../types/signing';
3
+ export type SignPayloadArgs = {
4
+ payload: SigningPayload;
5
+ standard: SigningStandard;
6
+ /** The origin wallet address the execution is bound to. */
7
+ address: string;
8
+ providers: Providers;
9
+ /** Required for `sep53`. Supplied by the Stellar wallet package. */
10
+ decodePublicKey?: () => Uint8Array;
11
+ };
12
+ /**
13
+ * Adapts `execution.details.payload` onto the shared standards layer.
14
+ *
15
+ * Which field to sign differs per standard, and getting it wrong produces a
16
+ * signature the backend rejects with no useful diagnostic:
17
+ *
18
+ * - `erc191` / `sep53` — `payload_json`, verbatim as a string.
19
+ * - `raw_ed25519` — the DECODED bytes of `payload_bytes_base64`.
20
+ * - `nep413` — `payload_json` parsed into `{ message, recipient, nonce }`.
21
+ */
22
+ export declare const signIntentsConnectPayload: ({ payload, standard, address, providers, decodePublicKey, }: SignPayloadArgs) => Promise<SignatureEnvelope>;
23
+ export type SignTextArgs = {
24
+ text: string;
25
+ standard: SigningStandard;
26
+ address: string;
27
+ providers: Providers;
28
+ decodePublicKey?: () => Uint8Array;
29
+ };
30
+ /**
31
+ * Signs a bare ASCII string — used only for `delete_execution:{executionId}`.
32
+ * No JSON, no envelope, no hashing: the wallet applies its own standard framing.
33
+ *
34
+ * `nep413` additionally returns the client-generated `{ recipient, nonce }`
35
+ * envelope — the backend needs both to rebuild the exact bytes the wallet
36
+ * signed, and omitting the block is a 400.
37
+ *
38
+ * `sep53` is refused: the delete endpoint accepts only raw_ed25519, nep413,
39
+ * erc191, tip191 and ton_connect, so a Stellar-signed delete would be signed,
40
+ * submitted, and rejected with a 400 anyway. Failing before the wallet prompt
41
+ * is the honest version of that outcome.
42
+ */
43
+ export declare const signIntentsConnectText: ({ text, standard, address, providers, }: SignTextArgs) => Promise<DeleteSignatureEnvelope>;
@@ -0,0 +1,15 @@
1
+ export declare const fromBase64: (value: string) => Uint8Array;
2
+ export declare const toBase64: (bytes: Uint8Array) => string;
3
+ export declare const toBase58: (bytes: Uint8Array) => string;
4
+ export declare const fromHex: (value: string) => Uint8Array;
5
+ /**
6
+ * `personal_sign` / TIP-191 return `v` as 27 or 28; the verifier wants 0 or 1.
7
+ * Only byte 64 is touched — `r` and `s` are left alone.
8
+ */
9
+ export declare const normaliseRecoveryByte: (signature: Uint8Array) => Uint8Array;
10
+ export declare const assertEd25519SignatureLength: (signature: Uint8Array, label: string) => Uint8Array;
11
+ export declare const secp256k1Signature: (bytes: Uint8Array) => string;
12
+ export declare const ed25519Signature: (bytes: Uint8Array) => string;
13
+ export declare const ed25519PublicKeyFromBytes: (bytes: Uint8Array) => string;
14
+ /** Solana addresses are already the base58 public key. */
15
+ export declare const ed25519PublicKeyFromBase58: (value: string) => string;
@@ -0,0 +1,18 @@
1
+ import { EvmProvider } from '../../types/providers';
2
+ import { SignatureEnvelope } from '../../types/signing';
3
+ export type Erc191SignArgs = {
4
+ /** Signed verbatim. Never parse-then-stringify — that changes the hash. */
5
+ message: string;
6
+ provider: EvmProvider;
7
+ /** The address the execution is bound to. */
8
+ expectedAddress: string;
9
+ };
10
+ /**
11
+ * EIP-191 `personal_sign`. The wallet applies the
12
+ * `"\x19Ethereum Signed Message:\n" + len` prefix and keccak256 internally, so
13
+ * the message is passed through untouched and never pre-hashed.
14
+ *
15
+ * No `publicKey` is returned: the backend recovers the signer with `ecrecover`,
16
+ * and sending one is rejected.
17
+ */
18
+ export declare const signErc191: ({ message, provider, expectedAddress, }: Erc191SignArgs) => Promise<SignatureEnvelope>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Pure per-standard signing: material in, wire-encoded signature out.
3
+ *
4
+ * This layer knows nothing about Intents Connect or 1Click payload shapes, so
5
+ * both stacks can share it. The widget's `src/utils/intents/signers/*` files
6
+ * are intended to collapse into thin adapters over these functions.
7
+ */
8
+ export * from './encoding';
9
+ export { signErc191, type Erc191SignArgs } from './erc191';
10
+ export { signRawEd25519, type RawEd25519SignArgs, } from './rawEd25519';
11
+ export { signNep413, encodePublicKey, type Nep413Payload, type Nep413SignArgs, } from './nep413';
12
+ export { signSep53, type Sep53SignArgs } from './sep53';
@@ -0,0 +1,22 @@
1
+ import { NearWalletBase } from '../../types/providers';
2
+ import { SignatureEnvelope } from '../../types/signing';
3
+ export type Nep413Payload = {
4
+ message: string;
5
+ /** Base64-encoded 32 bytes. */
6
+ nonce: string;
7
+ recipient: string;
8
+ callbackUrl?: string | null;
9
+ };
10
+ export type Nep413SignArgs = {
11
+ payload: Nep413Payload;
12
+ getProvider: () => NearWalletBase;
13
+ /** The NEAR account the execution is bound to. */
14
+ expectedAccountId: string;
15
+ };
16
+ /**
17
+ * NEP-413. The wallet builds the prefix tag, borsh-encodes and SHA-256 hashes
18
+ * internally — do not pre-hash, do not pre-borsh, do not wrap the message.
19
+ */
20
+ export declare const signNep413: ({ payload, getProvider, expectedAccountId, }: Nep413SignArgs) => Promise<SignatureEnvelope>;
21
+ /** Exported for adapters that need to re-encode a raw key. */
22
+ export declare const encodePublicKey: (bytes: Uint8Array) => string;
@@ -0,0 +1,20 @@
1
+ import { SolanaProvider } from '../../types/providers';
2
+ import { SignatureEnvelope } from '../../types/signing';
3
+ export type RawEd25519SignArgs = {
4
+ /**
5
+ * The exact bytes the backend hashes.
6
+ *
7
+ * Callers MUST pass decoded bytes, not a UTF-8 encoded string: some wallet
8
+ * versions re-encode strings in a way that does not byte-match what the
9
+ * backend verifies against.
10
+ */
11
+ bytes: Uint8Array;
12
+ provider: SolanaProvider;
13
+ /** Base58 Solana address, which is also the ed25519 public key. */
14
+ expectedAddress: string;
15
+ };
16
+ /**
17
+ * Raw ed25519 over the payload bytes. No envelope (no SIWS, no
18
+ * `"\x19Solana Signed Message:"`) and no pre-hashing.
19
+ */
20
+ export declare const signRawEd25519: ({ bytes, provider, expectedAddress, }: RawEd25519SignArgs) => Promise<SignatureEnvelope>;
@@ -0,0 +1,22 @@
1
+ import { StellarProvider } from '../../types/providers';
2
+ import { SignatureEnvelope } from '../../types/signing';
3
+ export type Sep53SignArgs = {
4
+ /** Signed verbatim, like erc191. */
5
+ message: string;
6
+ provider: StellarProvider;
7
+ /** The `G…` StrKey address the execution is bound to. */
8
+ expectedAddress: string;
9
+ /**
10
+ * StrKey `G…` → 32 raw bytes.
11
+ *
12
+ * Injected rather than implemented here so `@stellar/stellar-sdk` stays out
13
+ * of this package — the same indirection the widget's `StellarNetworkPlugin`
14
+ * uses. A `G…` string is NOT raw base58, so it cannot be encoded directly.
15
+ */
16
+ decodePublicKey: () => Uint8Array;
17
+ };
18
+ /**
19
+ * SEP-53. Freighter applies the `"Stellar Signed Message:\n"` prefix and
20
+ * SHA-256 internally — do not pre-hash and do not wrap.
21
+ */
22
+ export declare const signSep53: ({ message, provider, expectedAddress, decodePublicKey, }: Sep53SignArgs) => Promise<SignatureEnvelope>;