@lifi/perps-sdk 2.3.2 → 3.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.
Files changed (45) hide show
  1. package/dist/cjs/client/PerpsClient.d.ts +3 -2
  2. package/dist/cjs/client/PerpsClient.d.ts.map +1 -1
  3. package/dist/cjs/client/PerpsClient.js +18 -42
  4. package/dist/cjs/client/PerpsClient.js.map +1 -1
  5. package/dist/cjs/index.d.ts +1 -1
  6. package/dist/cjs/index.d.ts.map +1 -1
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/types/provider.d.ts +12 -2
  9. package/dist/cjs/types/provider.d.ts.map +1 -1
  10. package/dist/cjs/version.d.ts +1 -1
  11. package/dist/cjs/version.js +1 -1
  12. package/dist/esm/client/PerpsClient.d.ts +10 -9
  13. package/dist/esm/client/PerpsClient.d.ts.map +1 -1
  14. package/dist/esm/client/PerpsClient.js +23 -51
  15. package/dist/esm/client/PerpsClient.js.map +1 -1
  16. package/dist/esm/index.d.ts +1 -1
  17. package/dist/esm/index.d.ts.map +1 -1
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/types/provider.d.ts +32 -10
  20. package/dist/esm/types/provider.d.ts.map +1 -1
  21. package/dist/esm/version.d.ts +1 -1
  22. package/dist/esm/version.js +1 -1
  23. package/dist/types/client/PerpsClient.d.ts +10 -9
  24. package/dist/types/client/PerpsClient.d.ts.map +1 -1
  25. package/dist/types/index.d.ts +1 -1
  26. package/dist/types/index.d.ts.map +1 -1
  27. package/dist/types/types/provider.d.ts +32 -10
  28. package/dist/types/types/provider.d.ts.map +1 -1
  29. package/dist/types/version.d.ts +1 -1
  30. package/package.json +2 -2
  31. package/src/client/PerpsClient.ts +37 -75
  32. package/src/index.ts +1 -0
  33. package/src/types/provider.ts +32 -14
  34. package/src/version.ts +1 -1
  35. package/dist/cjs/client/clientLog.d.ts +0 -4
  36. package/dist/cjs/client/clientLog.d.ts.map +0 -1
  37. package/dist/cjs/client/clientLog.js +0 -9
  38. package/dist/cjs/client/clientLog.js.map +0 -1
  39. package/dist/esm/client/clientLog.d.ts +0 -16
  40. package/dist/esm/client/clientLog.d.ts.map +0 -1
  41. package/dist/esm/client/clientLog.js +0 -18
  42. package/dist/esm/client/clientLog.js.map +0 -1
  43. package/dist/types/client/clientLog.d.ts +0 -16
  44. package/dist/types/client/clientLog.d.ts.map +0 -1
  45. package/src/client/clientLog.ts +0 -20
@@ -19,7 +19,6 @@ import type {
19
19
  ProviderAction,
20
20
  Quote,
21
21
  QuoteSide,
22
- RestCallSignedActionStep,
23
22
  SignedActionStep,
24
23
  SigningMethod,
25
24
  TradeType,
@@ -56,6 +55,27 @@ export interface PerpsSDKClient {
56
55
  *
57
56
  * @public
58
57
  */
58
+ /**
59
+ * Progress for one on-chain leg of an `EVM_TX` batch (e.g. a native deposit's
60
+ * `approve` then `deposit`). Emitted twice per leg: `submitted` once the wallet
61
+ * broadcasts and the hash is known, then `confirmed` once the receipt mines. A
62
+ * consumer can render a live per-transaction stepper from these.
63
+ *
64
+ * @public
65
+ */
66
+ export interface SignActionProgress {
67
+ /** 0-based index of this leg within the batch. */
68
+ index: number
69
+ /** Total legs in the batch. */
70
+ total: number
71
+ action: ActionType
72
+ /** Contract function the leg invokes, e.g. `"approve"` or the deposit method. */
73
+ functionName: string
74
+ chainId: number
75
+ status: 'submitted' | 'confirmed'
76
+ txHash: string
77
+ }
78
+
59
79
  export interface SignActionsContext {
60
80
  userWallet?: PerpsClientSigner
61
81
  /**
@@ -76,6 +96,13 @@ export interface SignActionsContext {
76
96
  * absent (local/private-key signer, or no hook).
77
97
  */
78
98
  switchToChain?: (chainId: number) => Promise<PerpsClientSigner>
99
+ /**
100
+ * Optional progress sink for on-chain legs. A plugin whose legs broadcast
101
+ * transactions (Lighter's `EVM_TX`) calls it as each leg is submitted and
102
+ * confirmed, so a consumer can show a live per-transaction stepper. Bound by
103
+ * core from the `onProgress` passed to {@link PerpsClient.execute}.
104
+ */
105
+ onProgress?: (progress: SignActionProgress) => void
79
106
  }
80
107
 
81
108
  /**
@@ -450,20 +477,11 @@ export interface PerpsProviderPlugin {
450
477
  ): Promise<SignedActionStep[]>
451
478
 
452
479
  /**
453
- * Execute credential-bearing rest-call steps directly against the venue.
454
- * Required for providers whose descriptors declare
455
- * `SigningMethod.AUTH_TOKEN`: the client-held credential (attached by
456
- * `signActions` as `headers`) must never transit the LI.FI backend, so the
457
- * venue call happens SDK-side. The provider owns base-URL resolution and
458
- * mapping the venue response onto {@link ActionResult}s — these results are
459
- * authoritative for the caller; `PerpsClient.execute` submits the steps to
460
- * the backend afterwards for bookkeeping only, with `headers` stripped.
480
+ * Observe the per-step results of an `/executeAction` round trip before the
481
+ * core surfaces failures. Lets a provider react to structured failure codes
482
+ * — e.g. evicting a locally stored credential the venue no longer accepts.
461
483
  */
462
- executeRestCallActions?(
463
- steps: RestCallSignedActionStep[],
464
- address: Address,
465
- options?: SDKRequestOptions
466
- ): Promise<ActionResult[]>
484
+ onExecuteResults?(address: Address, results: ActionResult[]): Promise<void>
467
485
  }
468
486
 
469
487
  /**
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/perps-sdk'
2
- export const version = '2.3.2'
2
+ export const version = '3.0.0'
@@ -1,4 +0,0 @@
1
- export declare const clientLog: {
2
- readonly bookkeepingFailure: (provider: string, error: unknown) => void;
3
- };
4
- //# sourceMappingURL=clientLog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientLog.d.ts","sourceRoot":"","sources":["../../../src/client/clientLog.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS;4CAMS,MAAM,SAAS,OAAO,KAAG,IAAI;CAMlD,CAAA"}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clientLog = void 0;
4
- exports.clientLog = {
5
- bookkeepingFailure(provider, error) {
6
- console.error(`[${provider}] backend bookkeeping submission failed after venue execution`, error);
7
- },
8
- };
9
- //# sourceMappingURL=clientLog.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientLog.js","sourceRoot":"","sources":["../../../src/client/clientLog.ts"],"names":[],"mappings":";;;AAOa,QAAA,SAAS,GAAG;IAMvB,kBAAkB,CAAC,QAAgB,EAAE,KAAc;QACjD,OAAO,CAAC,KAAK,CACX,IAAI,QAAQ,+DAA+D,EAC3E,KAAK,CACN,CAAA;IACH,CAAC;CACO,CAAA"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Structured logger for client-layer (non-WebSocket) diagnostics, the REST-side
3
- * counterpart to {@link wsLog}, so failures surface through a single named
4
- * channel rather than scattered `console` calls.
5
- *
6
- * @internal
7
- */
8
- export declare const clientLog: {
9
- /**
10
- * The backend bookkeeping submission rejected after the venue call already
11
- * landed. Surfaced at `error` and swallowed by the caller — a failed
12
- * mirror-write must never mask an order that already executed on the venue.
13
- */
14
- readonly bookkeepingFailure: (provider: string, error: unknown) => void;
15
- };
16
- //# sourceMappingURL=clientLog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientLog.d.ts","sourceRoot":"","sources":["../../../src/client/clientLog.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;IACpB;;;;OAIG;4CAC0B,MAAM,SAAS,OAAO,KAAG,IAAI;CAMlD,CAAA"}
@@ -1,18 +0,0 @@
1
- /**
2
- * Structured logger for client-layer (non-WebSocket) diagnostics, the REST-side
3
- * counterpart to {@link wsLog}, so failures surface through a single named
4
- * channel rather than scattered `console` calls.
5
- *
6
- * @internal
7
- */
8
- export const clientLog = {
9
- /**
10
- * The backend bookkeeping submission rejected after the venue call already
11
- * landed. Surfaced at `error` and swallowed by the caller — a failed
12
- * mirror-write must never mask an order that already executed on the venue.
13
- */
14
- bookkeepingFailure(provider, error) {
15
- console.error(`[${provider}] backend bookkeeping submission failed after venue execution`, error);
16
- },
17
- };
18
- //# sourceMappingURL=clientLog.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientLog.js","sourceRoot":"","sources":["../../../src/client/clientLog.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;;;OAIG;IACH,kBAAkB,CAAC,QAAgB,EAAE,KAAc;QACjD,OAAO,CAAC,KAAK,CACX,IAAI,QAAQ,+DAA+D,EAC3E,KAAK,CACN,CAAA;IACH,CAAC;CACO,CAAA"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Structured logger for client-layer (non-WebSocket) diagnostics, the REST-side
3
- * counterpart to {@link wsLog}, so failures surface through a single named
4
- * channel rather than scattered `console` calls.
5
- *
6
- * @internal
7
- */
8
- export declare const clientLog: {
9
- /**
10
- * The backend bookkeeping submission rejected after the venue call already
11
- * landed. Surfaced at `error` and swallowed by the caller — a failed
12
- * mirror-write must never mask an order that already executed on the venue.
13
- */
14
- readonly bookkeepingFailure: (provider: string, error: unknown) => void;
15
- };
16
- //# sourceMappingURL=clientLog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientLog.d.ts","sourceRoot":"","sources":["../../../src/client/clientLog.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;IACpB;;;;OAIG;4CAC0B,MAAM,SAAS,OAAO,KAAG,IAAI;CAMlD,CAAA"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Structured logger for client-layer (non-WebSocket) diagnostics, the REST-side
3
- * counterpart to {@link wsLog}, so failures surface through a single named
4
- * channel rather than scattered `console` calls.
5
- *
6
- * @internal
7
- */
8
- export const clientLog = {
9
- /**
10
- * The backend bookkeeping submission rejected after the venue call already
11
- * landed. Surfaced at `error` and swallowed by the caller — a failed
12
- * mirror-write must never mask an order that already executed on the venue.
13
- */
14
- bookkeepingFailure(provider: string, error: unknown): void {
15
- console.error(
16
- `[${provider}] backend bookkeeping submission failed after venue execution`,
17
- error
18
- )
19
- },
20
- } as const