@lifi/perps-types 16.1.0 → 17.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/src/providers.ts CHANGED
@@ -1,5 +1,11 @@
1
+ import type { ActionParamsMap } from './action.js'
1
2
  import type { Asset } from './asset.js'
2
- import type { ActionType, PerpsSigner, SigningMethod } from './enums.js'
3
+ import type {
4
+ ActionRelay,
5
+ ActionType,
6
+ PerpsSigner,
7
+ SigningMethod,
8
+ } from './enums.js'
3
9
  import type { OhlcvInterval } from './market.js'
4
10
 
5
11
  /** A fixed option value presented for a provider action parameter. @public */
@@ -30,19 +36,20 @@ export interface Param {
30
36
  }
31
37
 
32
38
  /**
33
- * A single provider action. The same shape backs `Provider.setup`,
34
- * `Provider.options`, and `Provider.actions` — categorisation lives in which
35
- * array it sits in, not in the type. The core three fields are always present;
39
+ * A single provider action. The same shape backs `Provider.setup` and
40
+ * `Provider.actions` — categorisation lives in which array it sits in, not in
41
+ * the type. `type`, `signer`, `signingMethod` and `relay` are always present;
36
42
  * the rest are presentation/ordering hints provided per-action in the
37
43
  * provider's hardcoded metadata.
38
44
  * @public
39
45
  */
40
46
  export interface ProviderAction {
41
47
  type: ActionType
42
- signers: PerpsSigner[]
48
+ signer: PerpsSigner
43
49
  signingMethod: SigningMethod
50
+ relay: ActionRelay
44
51
  /**
45
- * Human label. Drives the card heading in the setup/options modals, and may
52
+ * Human label. Drives the card heading in the setup modal, and may
46
53
  * also front an in-flight trading action ("{title} is working…").
47
54
  */
48
55
  title?: string
@@ -64,6 +71,49 @@ export interface ProviderAction {
64
71
  * nothing, so a consumer tests `=== true` rather than truthiness.
65
72
  */
66
73
  gatesAccountReads?: boolean
74
+ /**
75
+ * A link to the venue's own documentation for this action, which a UI can
76
+ * show as a "Documentation" link.
77
+ */
78
+ docsUrl?: string
79
+ }
80
+
81
+ /**
82
+ * One selectable value of a choice setup step, bound to the action that
83
+ * applies it.
84
+ *
85
+ * @public
86
+ */
87
+ export interface SetupOption<T extends ActionType = ActionType> {
88
+ /** Display title, e.g. `'Plus'`. */
89
+ title: string
90
+ /**
91
+ * Option-specific prose a UI shows beside the option in its selector.
92
+ * `SetupAction.description` stays the general prose for the whole choice.
93
+ */
94
+ description?: string
95
+ /** The action executed when the option is chosen. */
96
+ type: T
97
+ /** The action's sole param, bound, e.g. `{ tier: 'plus' }`. */
98
+ params: ActionParamsMap[T]
99
+ /**
100
+ * The recommended option a UI pre-selects. The SDK never executes it on its
101
+ * own; at most one option per step marks it.
102
+ */
103
+ default?: true
104
+ }
105
+
106
+ /**
107
+ * One `Provider.setup` step. A choice step (`options !== null`) declares no
108
+ * `params`: each option carries its own bound params.
109
+ *
110
+ * @public
111
+ */
112
+ export interface SetupAction extends ProviderAction {
113
+ /** `null` when the step is not a choice. */
114
+ options: SetupOption[] | null
115
+ /** A `Provider.actions` entry that undoes the satisfied step, or `null`. */
116
+ revoke: ActionType | null
67
117
  }
68
118
 
69
119
  /**
@@ -118,8 +168,7 @@ export interface Provider {
118
168
  signingMethod: SigningMethod
119
169
  /** When false, the provider is announced but not yet selectable in clients. */
120
170
  active: boolean
121
- setup: ProviderAction[]
122
- options: ProviderAction[]
171
+ setup: SetupAction[]
123
172
  actions: ProviderAction[]
124
173
  categories: ProviderCategory[]
125
174
  wsUrl?: string