@lifi/perps-sdk-provider-lighter 12.1.0 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/cjs/LighterProvider.d.ts.map +1 -1
- package/dist/cjs/LighterProvider.js +17 -2
- package/dist/cjs/LighterProvider.js.map +1 -1
- package/dist/cjs/accountConfig.d.ts.map +1 -1
- package/dist/cjs/accountConfig.js +0 -1
- package/dist/cjs/accountConfig.js.map +1 -1
- package/dist/cjs/signers/LighterSigner.d.ts +4 -0
- package/dist/cjs/signers/LighterSigner.d.ts.map +1 -1
- package/dist/cjs/signers/LighterSigner.js +24 -0
- package/dist/cjs/signers/LighterSigner.js.map +1 -1
- package/dist/cjs/signers/signActions.d.ts.map +1 -1
- package/dist/cjs/signers/signActions.js +30 -0
- package/dist/cjs/signers/signActions.js.map +1 -1
- package/dist/cjs/signers/wasmLoader.d.ts +3 -1
- package/dist/cjs/signers/wasmLoader.d.ts.map +1 -1
- package/dist/cjs/signers/wasmLoader.js.map +1 -1
- package/dist/esm/LighterProvider.d.ts +2 -2
- package/dist/esm/LighterProvider.d.ts.map +1 -1
- package/dist/esm/LighterProvider.js +32 -6
- package/dist/esm/LighterProvider.js.map +1 -1
- package/dist/esm/accountConfig.d.ts.map +1 -1
- package/dist/esm/accountConfig.js +0 -1
- package/dist/esm/accountConfig.js.map +1 -1
- package/dist/esm/signers/LighterSigner.d.ts +29 -9
- package/dist/esm/signers/LighterSigner.d.ts.map +1 -1
- package/dist/esm/signers/LighterSigner.js +50 -12
- package/dist/esm/signers/LighterSigner.js.map +1 -1
- package/dist/esm/signers/signActions.d.ts.map +1 -1
- package/dist/esm/signers/signActions.js +42 -0
- package/dist/esm/signers/signActions.js.map +1 -1
- package/dist/esm/signers/wasmLoader.d.ts +7 -2
- package/dist/esm/signers/wasmLoader.d.ts.map +1 -1
- package/dist/esm/signers/wasmLoader.js.map +1 -1
- package/dist/types/LighterProvider.d.ts +2 -2
- package/dist/types/LighterProvider.d.ts.map +1 -1
- package/dist/types/accountConfig.d.ts.map +1 -1
- package/dist/types/signers/LighterSigner.d.ts +29 -9
- package/dist/types/signers/LighterSigner.d.ts.map +1 -1
- package/dist/types/signers/signActions.d.ts.map +1 -1
- package/dist/types/signers/wasmLoader.d.ts +7 -2
- package/dist/types/signers/wasmLoader.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/LighterProvider.ts +50 -8
- package/src/accountConfig.ts +0 -1
- package/src/signers/LighterSigner.ts +79 -17
- package/src/signers/signActions.ts +57 -0
- package/src/signers/wasmLoader.ts +5 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasmLoader.js","sourceRoot":"","sources":["../../../src/signers/wasmLoader.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,uEAAuE;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAC7D,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"wasmLoader.js","sourceRoot":"","sources":["../../../src/signers/wasmLoader.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,uEAAuE;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAC7D,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,oBAAoB,CAAA;AAuI3B,MAAM,mBAAmB,GAAG;IAC1B,gBAAgB;IAChB,cAAc;IACd,aAAa;IACb,iBAAiB;IACjB,kBAAkB;IAClB,iBAAiB;IACjB,iBAAiB;IACjB,qBAAqB;IACrB,cAAc;IACd,cAAc;IACd,oBAAoB;IACpB,iBAAiB;IACjB,kBAAkB;IAClB,uBAAuB;IACvB,yBAAyB;IACzB,8BAA8B;CACtB,CAAA;AAOV,IAAI,aAAsD,CAAA;AAE1D,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,+EAA+E;AAC/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nB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,CAAA;IAC9E,4EAA4E;IAC5E,0DAA0D;IAC1D,KAAK,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAErB,kEAAkE;IAClE,MAAM,gBAAgB,EAAE,CAAA;IAExB,MAAM,OAAO,GAAgC,EAAE,CAAA;IAC/C,KAAK,MAAM,IAAI,IAAI,mBAAmB,EAAE,CAAC;QACvC,MAAM,EAAE,GAAI,UAAsC,CAAC,IAAI,CAAC,CAAA;QACxD,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,kDAAkD,IAAI,IAAI;gBACxD,gDAAgD,CACnD,CAAA;QACH,CAAC;QACD,CAAC;QAAC,OAAmC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;IAClD,CAAC;IAED,OAAO,OAA6B,CAAA;AACtC,CAAC;AAED,KAAK,UAAU,gBAAgB;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAClC,IAAI,OAAO,YAAY,KAAK,UAAU,EAAE,CAAC;gBACvC,YAAY,CAAC,OAAO,CAAC,CAAA;YACvB,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;YACxB,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,aAAa,GAAG,SAAS,CAAA;AAC3B,CAAC"}
|
|
@@ -84,7 +84,7 @@ export declare const createLighterProvider: (deployment: LighterDeployment, opti
|
|
|
84
84
|
* @example
|
|
85
85
|
* ```ts
|
|
86
86
|
* const client = createPerpsClient({
|
|
87
|
-
*
|
|
87
|
+
* apiKey: 'your-api-key',
|
|
88
88
|
* providers: [lighterProvider()],
|
|
89
89
|
* })
|
|
90
90
|
* ```
|
|
@@ -101,7 +101,7 @@ export declare const lighterProvider: (options?: LighterProviderOptions) => Ligh
|
|
|
101
101
|
* @example
|
|
102
102
|
* ```ts
|
|
103
103
|
* const client = createPerpsClient({
|
|
104
|
-
*
|
|
104
|
+
* apiKey: 'your-api-key',
|
|
105
105
|
* providers: [lighterProvider(), lighterRhProvider()],
|
|
106
106
|
* })
|
|
107
107
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LighterProvider.d.ts","sourceRoot":"","sources":["../../src/LighterProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,mBAAmB,EAmBxB,KAAK,cAAc,EAEpB,MAAM,iBAAiB,CAAA;AA6BxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAGnC,OAAO,EAUL,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAA;AAwGvB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACrD,4FAA4F;IAC5F,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,4FAA4F;IAC5F,uBAAuB,CAAC,EAAE,MAAM,CAAA;CACjC;AAQD;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D;;;;;OAKG;IACH,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CAChE;AAED;;;;;;GAM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;;;;GAIG;AACH,eAAO,MAAM,OAAO,aA7BT,sBAAsB,KAC9B,oBA4BmC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountConfig.d.ts","sourceRoot":"","sources":["../../src/accountConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACf,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"accountConfig.d.ts","sourceRoot":"","sources":["../../src/accountConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACf,MAAM,mBAAmB,CAAA;AA8J1B;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,oBAAoB,EAC5B,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,cAAc,EAAE,GACxB,oBAAoB,EAAE,CAIxB"}
|
|
@@ -4,7 +4,7 @@ import { ActionType } from '@lifi/perps-types';
|
|
|
4
4
|
* and API-key slot. The private key is Lighter-native signing material; the
|
|
5
5
|
* account and slot indexes select the registered L2 key.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @internal
|
|
8
8
|
*/
|
|
9
9
|
export interface LighterSignerContext {
|
|
10
10
|
/** Lighter-native private key (from GenerateAPIKey, NOT an Ethereum key). */
|
|
@@ -31,7 +31,7 @@ export interface LighterSignerConfig {
|
|
|
31
31
|
* `txInfo`, and `txHash` are passed to the venue's transaction submission
|
|
32
32
|
* endpoint; `txInfo` is an encoded transaction payload.
|
|
33
33
|
*
|
|
34
|
-
* @
|
|
34
|
+
* @internal
|
|
35
35
|
*/
|
|
36
36
|
export interface LighterSignedBlob {
|
|
37
37
|
txType: number;
|
|
@@ -42,7 +42,7 @@ export interface LighterSignedBlob {
|
|
|
42
42
|
* Signed REGISTER_API_KEY (ChangePubKey) result, including the EIP-191 message
|
|
43
43
|
* that the user's L1 wallet must countersign before submission.
|
|
44
44
|
*
|
|
45
|
-
* @
|
|
45
|
+
* @internal
|
|
46
46
|
*/
|
|
47
47
|
export interface ChangePubKeyResult extends LighterSignedBlob {
|
|
48
48
|
/** EIP-191 message the L1 Ethereum wallet must sign to authorize the key rotation. */
|
|
@@ -52,17 +52,27 @@ export interface ChangePubKeyResult extends LighterSignedBlob {
|
|
|
52
52
|
* Signed APPROVE_INTEGRATOR result, including the EIP-191 L1 message required
|
|
53
53
|
* to authorize the integrator approval.
|
|
54
54
|
*
|
|
55
|
-
* @
|
|
55
|
+
* @internal
|
|
56
56
|
*/
|
|
57
57
|
export interface ApproveIntegratorResult extends LighterSignedBlob {
|
|
58
58
|
/** EIP-191 `L2ApproveIntegrator` L1 body the user's wallet must countersign to authorize the integrator approval. */
|
|
59
59
|
messageToSign: string;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Signed TRANSFER result, including the EIP-191 L1 message required to
|
|
63
|
+
* authorize a cross-account transfer.
|
|
64
|
+
*
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
export interface TransferResult extends LighterSignedBlob {
|
|
68
|
+
/** EIP-191 `Transfer` L1 body the user's wallet must countersign to bind the destination account and the amount to the account owner. */
|
|
69
|
+
messageToSign: string;
|
|
70
|
+
}
|
|
61
71
|
/**
|
|
62
72
|
* Lighter-native API keypair generated by the WASM signer. These keys are
|
|
63
73
|
* distinct from an Ethereum wallet keypair.
|
|
64
74
|
*
|
|
65
|
-
* @
|
|
75
|
+
* @internal
|
|
66
76
|
*/
|
|
67
77
|
export interface ApiKeyPair {
|
|
68
78
|
publicKey: string;
|
|
@@ -98,9 +108,9 @@ export declare class LighterSigner {
|
|
|
98
108
|
* `WasmBlobActionStep`. Returns the signed `{ txType, txInfo, txHash }`
|
|
99
109
|
* triple the backend forwards to Lighter's `sendTx` endpoint.
|
|
100
110
|
*
|
|
101
|
-
* For REGISTER_API_KEY use `signChangePubKey
|
|
102
|
-
* use `
|
|
103
|
-
* `messageToSign` the L1 wallet must countersign.
|
|
111
|
+
* For REGISTER_API_KEY use `signChangePubKey`, for APPROVE_INTEGRATOR use
|
|
112
|
+
* `signApproveIntegrator`, and for TRANSFER use `signTransfer` — all three
|
|
113
|
+
* return an additional `messageToSign` the L1 wallet must countersign.
|
|
104
114
|
*/
|
|
105
115
|
sign(action: ActionType, wasmSignParams: Record<string, unknown>, context: LighterSignerContext): Promise<LighterSignedBlob>;
|
|
106
116
|
/**
|
|
@@ -125,11 +135,21 @@ export declare class LighterSigner {
|
|
|
125
135
|
* belongs to a different L1 address with non-zero fee caps.
|
|
126
136
|
*/
|
|
127
137
|
signApproveIntegrator(wasmSignParams: Record<string, unknown>, context: LighterSignerContext): Promise<ApproveIntegratorResult>;
|
|
138
|
+
/**
|
|
139
|
+
* Sign a TRANSFER action with the stored API key and return the signed blob
|
|
140
|
+
* alongside the EIP-191 `Transfer` L1 message the user's Ethereum wallet
|
|
141
|
+
* must countersign. Unlike {@link sign}, this exposes `messageToSign`: the
|
|
142
|
+
* L1 signature (injected via {@link embedL1Signature} before submission)
|
|
143
|
+
* binds the destination account and the amount to the account owner, so the
|
|
144
|
+
* API key alone cannot move funds to an address the owner never approved.
|
|
145
|
+
*/
|
|
146
|
+
signTransfer(wasmSignParams: Record<string, unknown>, context: LighterSignerContext): Promise<TransferResult>;
|
|
128
147
|
/**
|
|
129
148
|
* Inject the L1 signature produced by the user's Ethereum wallet into a
|
|
130
149
|
* signed txInfo JSON. `L1Sig` is the only field that depends on the L1
|
|
131
150
|
* signature; txHash does NOT include it (so we do not recompute it). Shared
|
|
132
|
-
* by the REGISTER_API_KEY (ChangePubKey) and
|
|
151
|
+
* by the REGISTER_API_KEY (ChangePubKey), APPROVE_INTEGRATOR, and TRANSFER
|
|
152
|
+
* flows; SEND_ASSET stays on the bare signer call and keeps `L1Sig` empty.
|
|
133
153
|
*/
|
|
134
154
|
embedL1Signature(txInfo: string, l1Signature: string): string;
|
|
135
155
|
/**
|
|
@@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OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAMjC;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,UAAU,CAAC;IAY3C;;;;;;;;;OASG;IACG,IAAI,CACR,MAAM,EAAE,UAAU,EAClB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"LighterSigner.d.ts","sourceRoot":"","sources":["../../../src/signers/LighterSigner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAe9C;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,gBAAgB,EAAE,MAAM,CAAA;IACxB,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAA;IACnB,6EAA6E;IAC7E,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,MAAM,CAAA;IACrB,oBAAoB,EAAE,MAAM,CAAA;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,sFAAsF;IACtF,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,qHAAqH;IACrH,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAe,SAAQ,iBAAiB;IACvD,yIAAyI;IACzI,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,U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AAsB,kBAAkB,CACtC,IAAI,EAAE,sBAAsB,EAC5B,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,GAAG,CAAC,EAAE,kBAAkB,GACvB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAsB7B"}
|
|
@@ -66,9 +66,14 @@ export interface LighterWasmExports {
|
|
|
66
66
|
* 11 args: toAccountIndex, assetIndex, fromRouteType, toRouteType, amount,
|
|
67
67
|
* usdcFee, memo, skipNonce, then the trailing three. `memo` is copied into a
|
|
68
68
|
* Go `[32]byte`, so its UTF-8 byte length must be exactly 32 or Go rejects it
|
|
69
|
-
* before signing.
|
|
69
|
+
* before signing. `messageToSign` is the EIP-191 `Transfer` L1 body that
|
|
70
|
+
* binds the destination account and the amount to the owner's Ethereum
|
|
71
|
+
* wallet; a cross-account transfer needs the resulting `L1Sig`, a
|
|
72
|
+
* same-account route move does not.
|
|
70
73
|
*/
|
|
71
|
-
SignTransfer: (...args: unknown[]) => SignResult
|
|
74
|
+
SignTransfer: (...args: unknown[]) => SignResult & {
|
|
75
|
+
messageToSign?: string;
|
|
76
|
+
};
|
|
72
77
|
/** 7 args: assetIndex, routeType, amount, skipNonce, then the trailing three. */
|
|
73
78
|
SignWithdraw: (...args: unknown[]) => SignResult;
|
|
74
79
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasmLoader.d.ts","sourceRoot":"","sources":["../../../src/signers/wasmLoader.ts"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM;QACpB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;IACD,YAAY,EAAE,CACZ,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,WAAW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AC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,UAAU,CAAA;IACtD;;;;;OAKG;IACH,eAAe,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,UAAU,CAAA;IACnD;;;OAGG;IACH,gBAAgB,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,UAAU,CAAA;IACpD;;;;;;;OAOG;IACH,qBAAqB,EAAE,CACrB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,UAAU,GAAG;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5C;;;;OAIG;IACH,uBAAuB,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,UAAU,CAAA;IAC3D;;;;OAIG;IACH,4BAA4B,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,UAAU,CAAA;CACjE;AAED,gBAAgB;AAChB,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAwHD;;;;;;;;;GASG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAYnE;AAmDD;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/perps-sdk-provider-lighter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "Lighter provider plugin for @lifi/perps-sdk",
|
|
5
5
|
"homepage": "https://github.com/lifinance/perps-sdk",
|
|
6
6
|
"bugs": {
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"big.js": "^7.0.1",
|
|
46
|
-
"viem": "^2.
|
|
47
|
-
"@lifi/perps-types": "^
|
|
46
|
+
"viem": "^2.55.18",
|
|
47
|
+
"@lifi/perps-types": "^7.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@lifi/perps-sdk": "^
|
|
50
|
+
"@lifi/perps-sdk": "^7.0.0"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
package/src/LighterProvider.ts
CHANGED
|
@@ -486,6 +486,38 @@ export const createLighterProvider = (
|
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
488
|
|
|
489
|
+
/**
|
|
490
|
+
* Degrade an auth-gated `getAccount` read to `undefined` when Lighter
|
|
491
|
+
* rejects an SDK-owned token even after `retryOnRevoked` re-resolved it —
|
|
492
|
+
* the signature of a stale local API key (the venue's slot was
|
|
493
|
+
* re-registered elsewhere). `getAccount` must resolve in that state so
|
|
494
|
+
* `apiKeyRegistered: false` can render the REGISTER_API_KEY gate, which is
|
|
495
|
+
* the only recovery. A caller-supplied token stays the caller's to fix, so
|
|
496
|
+
* its rejection propagates, as does every other error class.
|
|
497
|
+
*/
|
|
498
|
+
const degradeOnAuthRejection = async <T>(
|
|
499
|
+
opts: SDKRequestOptions | undefined,
|
|
500
|
+
endpoint: string,
|
|
501
|
+
read: Promise<T>
|
|
502
|
+
): Promise<T | undefined> => {
|
|
503
|
+
try {
|
|
504
|
+
return await read
|
|
505
|
+
} catch (err) {
|
|
506
|
+
const sdkOwnsToken =
|
|
507
|
+
opts?.lighterAuthToken === undefined && authTokenSource === undefined
|
|
508
|
+
if (err instanceof LighterAuthRejectedError && sdkOwnsToken) {
|
|
509
|
+
console.warn(
|
|
510
|
+
`[lighter] ${endpoint} rejected the auth token after re-resolution; ` +
|
|
511
|
+
'degrading the read — the stored API key no longer matches the ' +
|
|
512
|
+
'registered key, and the REGISTER_API_KEY gate will surface it.',
|
|
513
|
+
err
|
|
514
|
+
)
|
|
515
|
+
return undefined
|
|
516
|
+
}
|
|
517
|
+
throw err
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
489
521
|
const fetchRegisteredApiKey = async (
|
|
490
522
|
client: LighterApiClient,
|
|
491
523
|
accountIndex: number,
|
|
@@ -697,12 +729,18 @@ export const createLighterProvider = (
|
|
|
697
729
|
assetRegistry.sync(),
|
|
698
730
|
fetchRegisteredApiKey(client, account.index, DEFAULT_API_KEY_INDEX),
|
|
699
731
|
// No token is a legitimate unauthenticated read → undefined → zero fee
|
|
700
|
-
// tier. A fetch error is NOT: it must propagate, never be
|
|
701
|
-
// fabricated 0%/0% fee tier.
|
|
732
|
+
// tier. A generic fetch error is NOT: it must propagate, never be
|
|
733
|
+
// coerced to a fabricated 0%/0% fee tier. One carve-out: a token the
|
|
734
|
+
// venue rejects even after re-resolution (stale local API key) degrades
|
|
735
|
+
// to undefined, so the REGISTER_API_KEY gate can render the recovery.
|
|
702
736
|
token === undefined
|
|
703
737
|
? Promise.resolve(undefined)
|
|
704
|
-
:
|
|
705
|
-
|
|
738
|
+
: degradeOnAuthRejection(
|
|
739
|
+
opts,
|
|
740
|
+
'/api/v1/accountLimits',
|
|
741
|
+
retryOnRevoked(opts, params.address, token, (t) =>
|
|
742
|
+
fetchAccountLimits(client, account.index, t)
|
|
743
|
+
)
|
|
706
744
|
),
|
|
707
745
|
keyStore.get(params.address),
|
|
708
746
|
readOnlyTokenManager.get(params.address, account.index),
|
|
@@ -717,8 +755,12 @@ export const createLighterProvider = (
|
|
|
717
755
|
: providersPromise.then((response) =>
|
|
718
756
|
response.providers.find((p) => p.key === providerKey)
|
|
719
757
|
?.referralCode
|
|
720
|
-
?
|
|
721
|
-
|
|
758
|
+
? degradeOnAuthRejection(
|
|
759
|
+
opts,
|
|
760
|
+
'/api/v1/referral/userReferrals',
|
|
761
|
+
retryOnRevoked(opts, params.address, token, (t) =>
|
|
762
|
+
fetchAppliedReferralCode(client, params.address, t)
|
|
763
|
+
)
|
|
722
764
|
)
|
|
723
765
|
: undefined
|
|
724
766
|
),
|
|
@@ -1440,7 +1482,7 @@ export const createLighterProvider = (
|
|
|
1440
1482
|
* @example
|
|
1441
1483
|
* ```ts
|
|
1442
1484
|
* const client = createPerpsClient({
|
|
1443
|
-
*
|
|
1485
|
+
* apiKey: 'your-api-key',
|
|
1444
1486
|
* providers: [lighterProvider()],
|
|
1445
1487
|
* })
|
|
1446
1488
|
* ```
|
|
@@ -1461,7 +1503,7 @@ export const lighterProvider = (
|
|
|
1461
1503
|
* @example
|
|
1462
1504
|
* ```ts
|
|
1463
1505
|
* const client = createPerpsClient({
|
|
1464
|
-
*
|
|
1506
|
+
* apiKey: 'your-api-key',
|
|
1465
1507
|
* providers: [lighterProvider(), lighterRhProvider()],
|
|
1466
1508
|
* })
|
|
1467
1509
|
* ```
|
package/src/accountConfig.ts
CHANGED
|
@@ -148,7 +148,6 @@ function projectLighterDescriptor(
|
|
|
148
148
|
case ActionType.ACCEPT_PROVIDER_TERMS:
|
|
149
149
|
case ActionType.UPDATE_ASSET_COLLATERAL:
|
|
150
150
|
case ActionType.DEPOSIT:
|
|
151
|
-
case ActionType.META_VOTE:
|
|
152
151
|
case ActionType.META_ACCEPT_TERMS:
|
|
153
152
|
throw new PerpsError(
|
|
154
153
|
PerpsErrorCode.SDKError,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
* and API-key slot. The private key is Lighter-native signing material; the
|
|
20
20
|
* account and slot indexes select the registered L2 key.
|
|
21
21
|
*
|
|
22
|
-
* @
|
|
22
|
+
* @internal
|
|
23
23
|
*/
|
|
24
24
|
export interface LighterSignerContext {
|
|
25
25
|
/** Lighter-native private key (from GenerateAPIKey, NOT an Ethereum key). */
|
|
@@ -48,7 +48,7 @@ export interface LighterSignerConfig {
|
|
|
48
48
|
* `txInfo`, and `txHash` are passed to the venue's transaction submission
|
|
49
49
|
* endpoint; `txInfo` is an encoded transaction payload.
|
|
50
50
|
*
|
|
51
|
-
* @
|
|
51
|
+
* @internal
|
|
52
52
|
*/
|
|
53
53
|
export interface LighterSignedBlob {
|
|
54
54
|
txType: number
|
|
@@ -60,7 +60,7 @@ export interface LighterSignedBlob {
|
|
|
60
60
|
* Signed REGISTER_API_KEY (ChangePubKey) result, including the EIP-191 message
|
|
61
61
|
* that the user's L1 wallet must countersign before submission.
|
|
62
62
|
*
|
|
63
|
-
* @
|
|
63
|
+
* @internal
|
|
64
64
|
*/
|
|
65
65
|
export interface ChangePubKeyResult extends LighterSignedBlob {
|
|
66
66
|
/** EIP-191 message the L1 Ethereum wallet must sign to authorize the key rotation. */
|
|
@@ -71,18 +71,29 @@ export interface ChangePubKeyResult extends LighterSignedBlob {
|
|
|
71
71
|
* Signed APPROVE_INTEGRATOR result, including the EIP-191 L1 message required
|
|
72
72
|
* to authorize the integrator approval.
|
|
73
73
|
*
|
|
74
|
-
* @
|
|
74
|
+
* @internal
|
|
75
75
|
*/
|
|
76
76
|
export interface ApproveIntegratorResult extends LighterSignedBlob {
|
|
77
77
|
/** EIP-191 `L2ApproveIntegrator` L1 body the user's wallet must countersign to authorize the integrator approval. */
|
|
78
78
|
messageToSign: string
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Signed TRANSFER result, including the EIP-191 L1 message required to
|
|
83
|
+
* authorize a cross-account transfer.
|
|
84
|
+
*
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
export interface TransferResult extends LighterSignedBlob {
|
|
88
|
+
/** EIP-191 `Transfer` L1 body the user's wallet must countersign to bind the destination account and the amount to the account owner. */
|
|
89
|
+
messageToSign: string
|
|
90
|
+
}
|
|
91
|
+
|
|
81
92
|
/**
|
|
82
93
|
* Lighter-native API keypair generated by the WASM signer. These keys are
|
|
83
94
|
* distinct from an Ethereum wallet keypair.
|
|
84
95
|
*
|
|
85
|
-
* @
|
|
96
|
+
* @internal
|
|
86
97
|
*/
|
|
87
98
|
export interface ApiKeyPair {
|
|
88
99
|
publicKey: string
|
|
@@ -166,9 +177,9 @@ export class LighterSigner {
|
|
|
166
177
|
* `WasmBlobActionStep`. Returns the signed `{ txType, txInfo, txHash }`
|
|
167
178
|
* triple the backend forwards to Lighter's `sendTx` endpoint.
|
|
168
179
|
*
|
|
169
|
-
* For REGISTER_API_KEY use `signChangePubKey
|
|
170
|
-
* use `
|
|
171
|
-
* `messageToSign` the L1 wallet must countersign.
|
|
180
|
+
* For REGISTER_API_KEY use `signChangePubKey`, for APPROVE_INTEGRATOR use
|
|
181
|
+
* `signApproveIntegrator`, and for TRANSFER use `signTransfer` — all three
|
|
182
|
+
* return an additional `messageToSign` the L1 wallet must countersign.
|
|
172
183
|
*/
|
|
173
184
|
async sign(
|
|
174
185
|
action: ActionType,
|
|
@@ -187,6 +198,12 @@ export class LighterSigner {
|
|
|
187
198
|
'not collect the required L1 user wallet signature.'
|
|
188
199
|
)
|
|
189
200
|
}
|
|
201
|
+
if (action === ActionType.TRANSFER) {
|
|
202
|
+
throw new Error(
|
|
203
|
+
'Use signTransfer() for TRANSFER — sign() does not collect the ' +
|
|
204
|
+
'required L1 user wallet signature.'
|
|
205
|
+
)
|
|
206
|
+
}
|
|
190
207
|
const wasm = await this.ensureLoaded()
|
|
191
208
|
await this.ensureClient(context)
|
|
192
209
|
const result = this.dispatch(wasm, action, wasmSignParams, context)
|
|
@@ -291,11 +308,51 @@ export class LighterSigner {
|
|
|
291
308
|
}
|
|
292
309
|
}
|
|
293
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Sign a TRANSFER action with the stored API key and return the signed blob
|
|
313
|
+
* alongside the EIP-191 `Transfer` L1 message the user's Ethereum wallet
|
|
314
|
+
* must countersign. Unlike {@link sign}, this exposes `messageToSign`: the
|
|
315
|
+
* L1 signature (injected via {@link embedL1Signature} before submission)
|
|
316
|
+
* binds the destination account and the amount to the account owner, so the
|
|
317
|
+
* API key alone cannot move funds to an address the owner never approved.
|
|
318
|
+
*/
|
|
319
|
+
async signTransfer(
|
|
320
|
+
wasmSignParams: Record<string, unknown>,
|
|
321
|
+
context: LighterSignerContext
|
|
322
|
+
): Promise<TransferResult> {
|
|
323
|
+
const wasm = await this.ensureLoaded()
|
|
324
|
+
await this.ensureClient(context)
|
|
325
|
+
const result = this.dispatch(
|
|
326
|
+
wasm,
|
|
327
|
+
ActionType.TRANSFER,
|
|
328
|
+
wasmSignParams,
|
|
329
|
+
context
|
|
330
|
+
)
|
|
331
|
+
if (result.error) {
|
|
332
|
+
throw new Error(`Lighter SignTransfer failed: ${result.error}`)
|
|
333
|
+
}
|
|
334
|
+
if (
|
|
335
|
+
result.txType === undefined ||
|
|
336
|
+
result.txInfo === undefined ||
|
|
337
|
+
result.txHash === undefined ||
|
|
338
|
+
!result.messageToSign
|
|
339
|
+
) {
|
|
340
|
+
throw new Error('Lighter SignTransfer returned an incomplete result')
|
|
341
|
+
}
|
|
342
|
+
return {
|
|
343
|
+
txType: result.txType,
|
|
344
|
+
txInfo: result.txInfo,
|
|
345
|
+
txHash: result.txHash,
|
|
346
|
+
messageToSign: result.messageToSign,
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
294
350
|
/**
|
|
295
351
|
* Inject the L1 signature produced by the user's Ethereum wallet into a
|
|
296
352
|
* signed txInfo JSON. `L1Sig` is the only field that depends on the L1
|
|
297
353
|
* signature; txHash does NOT include it (so we do not recompute it). Shared
|
|
298
|
-
* by the REGISTER_API_KEY (ChangePubKey) and
|
|
354
|
+
* by the REGISTER_API_KEY (ChangePubKey), APPROVE_INTEGRATOR, and TRANSFER
|
|
355
|
+
* flows; SEND_ASSET stays on the bare signer call and keeps `L1Sig` empty.
|
|
299
356
|
*/
|
|
300
357
|
embedL1Signature(txInfo: string, l1Signature: string): string {
|
|
301
358
|
let parsed: Record<string, unknown>
|
|
@@ -511,12 +568,16 @@ export class LighterSigner {
|
|
|
511
568
|
)
|
|
512
569
|
}
|
|
513
570
|
case ActionType.TRANSFER:
|
|
514
|
-
//
|
|
515
|
-
// `
|
|
516
|
-
//
|
|
517
|
-
//
|
|
518
|
-
//
|
|
519
|
-
//
|
|
571
|
+
// A cross-account move: the caller MUST countersign the returned
|
|
572
|
+
// `messageToSign` and inject the result as `L1Sig`, because the memo
|
|
573
|
+
// carries the destination L1 address and only that signature binds it
|
|
574
|
+
// to the account owner. SignTransfer's positional args follow the Go
|
|
575
|
+
// binding order: `toAccountIndex, assetIndex, fromRouteType,
|
|
576
|
+
// toRouteType, amount, usdcFee, memo, skipNonce, nonce, apiKeyIndex,
|
|
577
|
+
// accountIndex`. `memo` is decoded as a 66-char `0x`-prefixed hex
|
|
578
|
+
// string, a bare 64-char hex string, or 32 raw bytes — anything else
|
|
579
|
+
// fails with "memo expected to be 32 bytes or 64 hex encoded or 66 if
|
|
580
|
+
// 0x hex encoded".
|
|
520
581
|
return wasm.SignTransfer(
|
|
521
582
|
numberField(p, 'to_account'),
|
|
522
583
|
this.collateralAssetIndex,
|
|
@@ -532,8 +593,9 @@ export class LighterSigner {
|
|
|
532
593
|
)
|
|
533
594
|
case ActionType.SEND_ASSET: {
|
|
534
595
|
// Same-account collateral self-transfer between the perp and spot
|
|
535
|
-
// routes
|
|
536
|
-
//
|
|
596
|
+
// routes, so no L1 signature binds it and `L1Sig` stays empty.
|
|
597
|
+
// `toAccountIndex` is the signer's own account; the routes come from
|
|
598
|
+
// the backend-passed `sourceDex`/`destinationDex` wire strings.
|
|
537
599
|
const fromRouteType = routeFromDex(stringField(p, 'sourceDex'))
|
|
538
600
|
const toRouteType = routeFromDex(stringField(p, 'destinationDex'))
|
|
539
601
|
if (fromRouteType === toRouteType) {
|
|
@@ -84,6 +84,8 @@ export async function signWasmBlobActions(
|
|
|
84
84
|
signed.push(await signRegisterApiKey(deps, address, step, ctx))
|
|
85
85
|
} else if (step.action === ActionType.APPROVE_INTEGRATOR) {
|
|
86
86
|
signed.push(await signApproveIntegrator(deps, address, step, ctx))
|
|
87
|
+
} else if (step.action === ActionType.TRANSFER) {
|
|
88
|
+
signed.push(await signTransfer(deps, address, step, ctx))
|
|
87
89
|
} else if (
|
|
88
90
|
TOKEN_AUTH_MUTATION_KINDS.has(step.wasmSignParams.kind as string)
|
|
89
91
|
) {
|
|
@@ -254,6 +256,61 @@ async function signApproveIntegrator(
|
|
|
254
256
|
}
|
|
255
257
|
}
|
|
256
258
|
|
|
259
|
+
/**
|
|
260
|
+
* TRANSFER flow:
|
|
261
|
+
* 1. Load the user's stored API key (no keypair generation).
|
|
262
|
+
* 2. Wasm-sign the `L2Transfer` blob with that key, obtaining the EIP-191
|
|
263
|
+
* L1 message the wallet must countersign.
|
|
264
|
+
* 3. Have the user's L1 Ethereum wallet sign that message.
|
|
265
|
+
* 4. Inject the L1 signature into the txInfo JSON as `L1Sig`.
|
|
266
|
+
*
|
|
267
|
+
* Requires the end-user's wallet in `ctx.userWallet`: the destination account
|
|
268
|
+
* and the amount are only bound to the account owner by the user's `L1Sig`,
|
|
269
|
+
* so the stored API key alone must not authorize the move.
|
|
270
|
+
*/
|
|
271
|
+
async function signTransfer(
|
|
272
|
+
deps: LighterSignActionsDeps,
|
|
273
|
+
address: Address,
|
|
274
|
+
step: WasmBlobActionStep,
|
|
275
|
+
ctx: SignActionsContext | undefined
|
|
276
|
+
): Promise<WasmBlobSignedActionStep> {
|
|
277
|
+
const walletSigner = ctx?.userWallet
|
|
278
|
+
if (!walletSigner) {
|
|
279
|
+
throw new PerpsError(
|
|
280
|
+
PerpsErrorCode.SDKError,
|
|
281
|
+
'TRANSFER requires the end-user wallet — pass `userWallet` to ' +
|
|
282
|
+
'createPerpsClient or call setUserWallet(walletClient).'
|
|
283
|
+
)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const apiKey = await requireApiKey(deps, address)
|
|
287
|
+
const signed = await deps.signer.signTransfer(step.wasmSignParams, {
|
|
288
|
+
apiKeyPrivateKey: apiKey.apiKeyPrivateKey,
|
|
289
|
+
apiKeyIndex: apiKey.apiKeyIndex,
|
|
290
|
+
accountIndex: apiKey.accountIndex,
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
const l1Signature = await walletSigner.signMessage({
|
|
294
|
+
account: walletSigner.account,
|
|
295
|
+
message: signed.messageToSign,
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
const txInfoWithL1Sig = deps.signer.embedL1Signature(
|
|
299
|
+
signed.txInfo,
|
|
300
|
+
l1Signature
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
return {
|
|
304
|
+
action: step.action,
|
|
305
|
+
wasmSignParams: step.wasmSignParams,
|
|
306
|
+
signedTx: {
|
|
307
|
+
txType: signed.txType,
|
|
308
|
+
txInfo: txInfoWithL1Sig,
|
|
309
|
+
txHash: signed.txHash,
|
|
310
|
+
},
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
257
314
|
/**
|
|
258
315
|
* Execute a token-authenticated Lighter mutation (`ACCOUNT_TYPE` →
|
|
259
316
|
* `/changeAccountTier`, `SET_REFERRAL` → `/referral/use`) client-side.
|
|
@@ -82,9 +82,12 @@ export interface LighterWasmExports {
|
|
|
82
82
|
* 11 args: toAccountIndex, assetIndex, fromRouteType, toRouteType, amount,
|
|
83
83
|
* usdcFee, memo, skipNonce, then the trailing three. `memo` is copied into a
|
|
84
84
|
* Go `[32]byte`, so its UTF-8 byte length must be exactly 32 or Go rejects it
|
|
85
|
-
* before signing.
|
|
85
|
+
* before signing. `messageToSign` is the EIP-191 `Transfer` L1 body that
|
|
86
|
+
* binds the destination account and the amount to the owner's Ethereum
|
|
87
|
+
* wallet; a cross-account transfer needs the resulting `L1Sig`, a
|
|
88
|
+
* same-account route move does not.
|
|
86
89
|
*/
|
|
87
|
-
SignTransfer: (...args: unknown[]) => SignResult
|
|
90
|
+
SignTransfer: (...args: unknown[]) => SignResult & { messageToSign?: string }
|
|
88
91
|
/** 7 args: assetIndex, routeType, amount, skipNonce, then the trailing three. */
|
|
89
92
|
SignWithdraw: (...args: unknown[]) => SignResult
|
|
90
93
|
/**
|