@lightconexyz/lightcone-sdk 0.8.1 → 0.8.2
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 +150 -3
- package/dist/auth/client.d.ts +17 -1
- package/dist/auth/client.d.ts.map +1 -1
- package/dist/auth/client.js +68 -0
- package/dist/auth/client.js.map +1 -1
- package/dist/auth/index.d.ts +57 -5
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +26 -5
- package/dist/auth/index.js.map +1 -1
- package/dist/client.d.ts +23 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +38 -2
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +23 -2
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +238 -17
- package/dist/context.js.map +1 -1
- package/dist/domain/market/outcome.d.ts +9 -3
- package/dist/domain/market/outcome.d.ts.map +1 -1
- package/dist/domain/market/outcome.js +10 -7
- package/dist/domain/market/outcome.js.map +1 -1
- package/dist/domain/market/wire.d.ts +3 -3
- package/dist/domain/market/wire.d.ts.map +1 -1
- package/dist/domain/market/wire.js.map +1 -1
- package/dist/domain/orderbook/wire.d.ts +5 -0
- package/dist/domain/orderbook/wire.d.ts.map +1 -1
- package/dist/domain/orderbook/wire.js.map +1 -1
- package/dist/domain/position/client.d.ts +160 -4
- package/dist/domain/position/client.d.ts.map +1 -1
- package/dist/domain/position/client.js +592 -4
- package/dist/domain/position/client.js.map +1 -1
- package/dist/domain/position/index.d.ts +54 -3
- package/dist/domain/position/index.d.ts.map +1 -1
- package/dist/domain/position/index.js +1 -0
- package/dist/domain/position/index.js.map +1 -1
- package/dist/domain/position/state.d.ts +118 -0
- package/dist/domain/position/state.d.ts.map +1 -0
- package/dist/domain/position/state.js +262 -0
- package/dist/domain/position/state.js.map +1 -0
- package/dist/error.d.ts +8 -2
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +14 -1
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/prelude.d.ts +6 -5
- package/dist/prelude.d.ts.map +1 -1
- package/dist/prelude.js +10 -1
- package/dist/prelude.js.map +1 -1
- package/dist/privy/client.d.ts +4 -0
- package/dist/privy/client.d.ts.map +1 -1
- package/dist/privy/client.js +4 -0
- package/dist/privy/client.js.map +1 -1
- package/dist/rpc.d.ts +46 -1
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +125 -0
- package/dist/rpc.js.map +1 -1
- package/dist/shared/api_response.d.ts +7 -0
- package/dist/shared/api_response.d.ts.map +1 -1
- package/dist/shared/api_response.js +16 -0
- package/dist/shared/api_response.js.map +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +2 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/signing.d.ts +17 -0
- package/dist/shared/signing.d.ts.map +1 -1
- package/dist/shared/signing.js +27 -0
- package/dist/shared/signing.js.map +1 -1
- package/dist/shared/types.d.ts +3 -1
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.js +12 -4
- package/dist/shared/types.js.map +1 -1
- package/dist/ws/client.browser.d.ts +4 -0
- package/dist/ws/client.browser.d.ts.map +1 -1
- package/dist/ws/client.browser.js +13 -1
- package/dist/ws/client.browser.js.map +1 -1
- package/dist/ws/client.node.d.ts +4 -0
- package/dist/ws/client.node.d.ts.map +1 -1
- package/dist/ws/client.node.js +13 -1
- package/dist/ws/client.node.js.map +1 -1
- package/dist/ws/index.d.ts +24 -0
- package/dist/ws/index.d.ts.map +1 -1
- package/dist/ws/index.js +162 -1
- package/dist/ws/index.js.map +1 -1
- package/dist/ws/subscriptions.d.ts +12 -1
- package/dist/ws/subscriptions.d.ts.map +1 -1
- package/dist/ws/subscriptions.js +11 -0
- package/dist/ws/subscriptions.js.map +1 -1
- package/dist/ws/types.d.ts +5 -0
- package/dist/ws/types.d.ts.map +1 -1
- package/dist/ws/types.js.map +1 -1
- package/package.json +2 -1
package/dist/auth/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA6FA,oCAaC;AAGD,8BAQC;AAGD,oCAEC;AAWD,sCAUC;AAGD,8CAEC;AAOD,kCASC;AAGD,8BAQC;AAQD,0CAKC;AAED,sDAEC;AA/LD,2CAA4C;AAE5C,2CAAyB;AACzB,2CAAyB;AAEzB;;;GAGG;AACH,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,qCAAuB,CAAA;AACzB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,kCAAqB,CAAA;AACvB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AA0ED,qEAAqE;AACrE,SAAgB,YAAY,CAAC,QAAsB;IACjD,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,GAAG;YACN,OAAO,GAAG,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,UAAU,GAAU,QAAQ,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;AACH,CAAC;AAED,uDAAuD;AACvD,SAAgB,SAAS,CAAC,IAAU;IAClC,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC3B,KAAK,QAAQ,CAAC;QACd,KAAK,GAAG;YACN,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC7B,KAAK,QA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OAAO,CAAC,YAAY,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC9E,KAAK,QAAQ;YACX,OAAO,IAAA,aAAO,EAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,mEAAmE;AACnE,SAAgB,SAAS,CAAC,IAAU;IAClC,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC3B,KAAK,QAAQ,CAAC;QACd,KAAK,GAAG;YACN,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;QAC1C,KAAK,QAAQ;YACX,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAQD,SAAgB,eAAe,CAAC,WAA6B;IAC3D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;AACvD,CAAC;AAED,SAAgB,qBAAqB,CAAC,KAAa;IACjD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,gCAAgC,KAAK,EAAE,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["import type { PubkeyStr } from \"../shared\";\nimport { shorten } from \"../shared/fmt/str\";\n\nexport * from \"./client\";\nexport * from \"./native\";\n\n/**\n * How a session authenticated, as reported by the backend (derived from which\n * token verified the request).\n */\nexport enum AuthMethod {\n Privy = \"privy\",\n Lightcone = \"lightcone\",\n}\n\nexport enum ChainType {\n Solana = \"solana\",\n Ethereum = \"ethereum\",\n}\n\n/** A Privy-managed embedded wallet. */\nexport interface PrivyEmbeddedWallet {\n privy_id: string;\n chain: ChainType;\n address: string;\n}\n\n/** Privy account data attached to an identity. */\nexport interface UserPrivyData {\n /** The Privy DID (`did:privy:...`). */\n id: string;\n /**\n * Always present: Privy registration provisions the embedded wallet in the\n * same transaction that creates the user.\n */\n wallet: PrivyEmbeddedWallet;\n}\n\n/**\n * X account data — the same shape whether X is the login identity or a\n * connected account on a Google/wallet identity.\n */\nexport interface XAccountData {\n /** X numeric user id (Privy `subject`); absent on legacy rows. */\n user_id?: string;\n username: string;\n display_name?: string;\n avatar_url?: string;\n}\n\n/** Google account data for a Google login identity. */\nexport interface GoogleAccountData {\n email: string;\n name?: string;\n given_name?: string;\n family_name?: string;\n avatar_url?: string;\n}\n\n/**\n * The login identity — how the user authenticates. `type` narrows the variant.\n *\n * Privy data lives on the variant because its presence is determined by the\n * identity type: Google/X login only exists via Privy OAuth (guaranteed DID +\n * embedded wallet), while wallet users opt into Privy (SIWS) or stay\n * self-custody.\n */\nexport type UserIdentity =\n | { type: \"google\"; account: GoogleAccountData; privy: UserPrivyData }\n | { type: \"x\"; account: XAccountData; privy: UserPrivyData }\n | { type: \"wallet\"; address: string; chain: ChainType; privy?: UserPrivyData };\n\n/** Full user profile — the `user` object of {@link SessionResponse}. */\nexport interface User {\n user_id: string;\n identity: UserIdentity;\n /** X account connected by a non-X-identity user; absent when identity is X. */\n connected_x?: XAccountData;\n}\n\n/**\n * Session envelope returned by `loginWithMessage`, `register-privy`, and\n * `GET /api/auth/me`. There is no `wallet_address` field — derive the\n * session's trading wallet with {@link tradingWallet}.\n */\nexport interface SessionResponse {\n user: User;\n expires_at: number;\n auth_method: AuthMethod;\n is_beta: boolean;\n}\n\n/** Human-readable login-method label (\"Google\" / \"X\" / \"Solana\"). */\nexport function identityText(identity: UserIdentity): \"Google\" | \"X\" | \"Solana\" {\n switch (identity.type) {\n case \"google\":\n return \"Google\";\n case \"x\":\n return \"X\";\n case \"wallet\":\n return \"Solana\";\n default: {\n const exhaustive: never = identity;\n throw new Error(`Unknown identity: ${JSON.stringify(exhaustive)}`);\n }\n }\n}\n\n/** Privy account data, regardless of identity type. */\nexport function userPrivy(user: User): UserPrivyData | undefined {\n switch (user.identity.type) {\n case \"google\":\n case \"x\":\n return user.identity.privy;\n case \"wallet\":\n return user.identity.privy;\n }\n}\n\n/** The X account, whether it is the login identity or a connected account. */\nexport function userXAccount(user: User): XAccountData | undefined {\n return user.identity.type === \"x\" ? user.identity.account : user.connected_x;\n}\n\n/**\n * The wallet a session operates as.\n *\n * Google/X identities only exist via Privy registration, which always\n * provisions an embedded wallet — that wallet is the answer regardless of\n * auth method. Wallet identities depend on the session: a Privy (SIWS)\n * session trades via the embedded wallet, a Lightcone session trades via the\n * wallet that signed in.\n */\nexport function tradingWallet(user: User, authMethod: AuthMethod): string {\n switch (user.identity.type) {\n case \"google\":\n case \"x\":\n return user.identity.privy.wallet.address;\n case \"wallet\":\n return authMethod === AuthMethod.Privy\n ? (user.identity.privy?.wallet.address ?? user.identity.address)\n : user.identity.address;\n }\n}\n\n/** Short display label for the wallet a session operates as. */\nexport function walletDisplayName(user: User, authMethod: AuthMethod): string {\n return shorten(tradingWallet(user, authMethod), 8);\n}\n\n/**\n * Best display name for the user. Google: `name`, falling back to the email;\n * X: `display_name`, falling back to the username; wallet identities show the\n * shortened address (`FRGk...WcPR`).\n */\nexport function displayName(user: User): string {\n switch (user.identity.type) {\n case \"google\":\n return user.identity.account.name ?? user.identity.account.email;\n case \"x\":\n return user.identity.account.display_name ?? user.identity.account.username;\n case \"wallet\":\n return shorten(user.identity.address, 8);\n }\n}\n\n/** Avatar URL from the login identity's OAuth provider, if any. */\nexport function avatarUrl(user: User): string | undefined {\n switch (user.identity.type) {\n case \"google\":\n case \"x\":\n return user.identity.account.avatar_url;\n case \"wallet\":\n return undefined;\n }\n}\n\nexport interface AuthCredentials {\n user_id: string;\n wallet_address: PubkeyStr;\n expires_at: Date;\n}\n\nexport function isAuthenticated(credentials?: AuthCredentials): boolean {\n if (!credentials) {\n return false;\n }\n return Date.now() < credentials.expires_at.getTime();\n}\n\nexport function generateSigninMessage(nonce: string): Uint8Array {\n return new TextEncoder().encode(`Sign in to Lightcone\\nNonce: ${nonce}`);\n}\n\nexport interface LoginRequest {\n message: string;\n signature_bs58: string;\n pubkey_bytes: number[];\n use_embedded_wallet?: boolean;\n}\n\nexport interface NonceResponse {\n nonce: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAuIA,oCAiBC;AAGD,8BASC;AAGD,oCAEC;AAWD,sCAWC;AAGD,8CAEC;AAsBD,kCAaC;AAGD,8BAUC;AAQD,0CAKC;AAED,sDAEC;AApQD,2CAA4C;AAE5C,2CAAyB;AACzB,2CAAyB;AAEzB;;;GAGG;AACH,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,qCAAuB,CAAA;AACzB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,kCAAqB,CAAA;AACvB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAoHD,+EAA+E;AAC/E,SAAgB,YAAY,CAC1B,QAAsB;IAEtB,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,OAAO;YACV,OAAO,OAAO,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,GAAG;YACN,OAAO,GAAG,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,UAAU,GAAU,QAAQ,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;AACH,CAAC;AAED,uDAAuD;AACvD,SAAgB,SAAS,CAAC,IAAU;IAClC,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC3B,KAAK,OAAO,CAAC;QACb,KAAK,QAAQ,CAAC;QACd,KAAK,GA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KAAK,QAAQ;YACX,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAQD,SAAgB,eAAe,CAAC,WAA6B;IAC3D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;AACvD,CAAC;AAED,SAAgB,qBAAqB,CAAC,KAAa;IACjD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,gCAAgC,KAAK,EAAE,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["import type { PubkeyStr } from \"../shared\";\nimport { shorten } from \"../shared/fmt/str\";\n\nexport * from \"./client\";\nexport * from \"./native\";\n\n/**\n * How a session authenticated, as reported by the backend (derived from which\n * token verified the request).\n */\nexport enum AuthMethod {\n Privy = \"privy\",\n Lightcone = \"lightcone\",\n}\n\nexport enum ChainType {\n Solana = \"solana\",\n Ethereum = \"ethereum\",\n}\n\n/** A Privy-managed embedded wallet. */\nexport interface PrivyEmbeddedWallet {\n privy_id: string;\n chain: ChainType;\n address: string;\n}\n\n/** Privy account data attached to an identity. */\nexport interface UserPrivyData {\n /** The Privy DID (`did:privy:...`). */\n id: string;\n /**\n * Always present: Privy registration provisions the embedded wallet in the\n * same transaction that creates the user.\n */\n wallet: PrivyEmbeddedWallet;\n}\n\n/**\n * X account data — the same shape whether X is the login identity or a\n * connected account on a Google/wallet identity.\n */\nexport interface XAccountData {\n /** X numeric user id (Privy `subject`); absent on legacy rows. */\n user_id?: string;\n username: string;\n display_name?: string;\n avatar_url?: string;\n}\n\n/** Google account data for a Google login identity. */\nexport interface GoogleAccountData {\n email: string;\n name?: string;\n given_name?: string;\n family_name?: string;\n avatar_url?: string;\n}\n\n/** Canonical address for a passwordless Email login identity. */\nexport interface EmailAccountData {\n email: string;\n}\n\n/** Public login-method names exposed in profiles and bounded conflicts. */\nexport type LinkedIdentityType = \"email\" | \"google\" | \"x\" | \"wallet\";\n\n/** Connected Login Identity without repeated Account-level Privy wallet data. */\nexport type LinkedIdentity =\n | { type: \"email\"; account: EmailAccountData }\n | { type: \"google\"; account: GoogleAccountData }\n | { type: \"x\"; account: XAccountData }\n | { type: \"wallet\"; address: string; chain: ChainType };\n\n/** Verified method and canonical identifier that initiated Privy authentication. */\nexport type LinkedIdentitySelector =\n | { type: \"email\"; email: string }\n | { type: \"google\"; email: string }\n | { type: \"x\"; username: string }\n | { type: \"wallet\"; address: string; chain: ChainType };\n\n/** Register-or-sync request naming the verified attempted identity. */\nexport interface RegisterPrivyRequest {\n attempted_identity: LinkedIdentitySelector;\n}\n\n/**\n * The login identity — how the user authenticates. `type` narrows the variant.\n *\n * Privy data lives on the variant because its presence is determined by the\n * identity type: Google/X login only exists via Privy OAuth (guaranteed DID +\n * embedded wallet), while wallet users opt into Privy (SIWS) or stay\n * self-custody.\n */\nexport type UserIdentity =\n | { type: \"email\"; account: EmailAccountData; privy: UserPrivyData }\n | { type: \"google\"; account: GoogleAccountData; privy: UserPrivyData }\n | { type: \"x\"; account: XAccountData; privy: UserPrivyData }\n | {\n type: \"wallet\";\n address: string;\n chain: ChainType;\n privy?: UserPrivyData;\n };\n\n/** Full user profile — the `user` object of {@link SessionResponse}. */\nexport interface User {\n user_id: string;\n identity: UserIdentity;\n /** Every verified login identity connected to the Account, primary first. */\n linked_identities?: LinkedIdentity[];\n /** Remembered account-wide percentage below 10%; null until one is stored. */\n max_slippage_preference: string | null;\n /** X account connected by a non-X-identity user; absent when identity is X. */\n connected_x?: XAccountData;\n}\n\n/**\n * Session envelope returned by `loginWithMessage`, `register-privy`, and\n * `GET /api/auth/me`. There is no `wallet_address` field — derive the\n * session's trading wallet with {@link tradingWallet}.\n */\nexport interface SessionResponse {\n user: User;\n expires_at: number;\n auth_method: AuthMethod;\n is_beta: boolean;\n}\n\n/** Exact decimal-string body used to update and return max slippage. */\nexport interface MaxSlippagePreferenceBody {\n max_slippage_preference: string;\n}\n\n/** Human-readable login-method label (\"Email\" / \"Google\" / \"X\" / \"Solana\"). */\nexport function identityText(\n identity: UserIdentity,\n): \"Email\" | \"Google\" | \"X\" | \"Solana\" {\n switch (identity.type) {\n case \"email\":\n return \"Email\";\n case \"google\":\n return \"Google\";\n case \"x\":\n return \"X\";\n case \"wallet\":\n return \"Solana\";\n default: {\n const exhaustive: never = identity;\n throw new Error(`Unknown identity: ${JSON.stringify(exhaustive)}`);\n }\n }\n}\n\n/** Privy account data, regardless of identity type. */\nexport function userPrivy(user: User): UserPrivyData | undefined {\n switch (user.identity.type) {\n case \"email\":\n case \"google\":\n case \"x\":\n return user.identity.privy;\n case \"wallet\":\n return user.identity.privy;\n }\n}\n\n/** The X account, whether it is the login identity or a connected account. */\nexport function userXAccount(user: User): XAccountData | undefined {\n return user.identity.type === \"x\" ? user.identity.account : user.connected_x;\n}\n\n/**\n * The wallet a session operates as.\n *\n * Google/X identities only exist via Privy registration, which always\n * provisions an embedded wallet — that wallet is the answer regardless of\n * auth method. Wallet identities depend on the session: a Privy (SIWS)\n * session trades via the embedded wallet, a Lightcone session trades via the\n * wallet that signed in.\n */\nexport function tradingWallet(user: User, authMethod: AuthMethod): string {\n switch (user.identity.type) {\n case \"email\":\n case \"google\":\n case \"x\":\n return user.identity.privy.wallet.address;\n case \"wallet\":\n return authMethod === AuthMethod.Privy\n ? (user.identity.privy?.wallet.address ?? user.identity.address)\n : user.identity.address;\n }\n}\n\n/** Short display label for the wallet a session operates as. */\nexport function walletDisplayName(user: User, authMethod: AuthMethod): string {\n return shorten(tradingWallet(user, authMethod), 8);\n}\n\n/** Keeps Email labels compact while preserving the recognizable address ends. */\nfunction emailDisplayName(email: string): string {\n const maxChars = 20;\n const chars = [...email];\n if (chars.length <= maxChars) {\n return email;\n }\n\n const visibleChars = maxChars - 3;\n const prefixChars = Math.floor(visibleChars / 2);\n return `${chars.slice(0, prefixChars).join(\"\")}...${chars\n .slice(-(visibleChars - prefixChars))\n .join(\"\")}`;\n}\n\n/**\n * Best display name for the user. Email addresses are limited to 20 characters;\n * Google uses `name` with an email fallback; X uses `display_name` with a\n * username fallback; wallet identities show the shortened address (`FRGk...WcPR`).\n */\nexport function displayName(user: User): string {\n switch (user.identity.type) {\n case \"email\":\n return emailDisplayName(user.identity.account.email);\n case \"google\":\n return user.identity.account.name ?? user.identity.account.email;\n case \"x\":\n return (\n user.identity.account.display_name ?? user.identity.account.username\n );\n case \"wallet\":\n return shorten(user.identity.address, 8);\n }\n}\n\n/** Avatar URL from the login identity's OAuth provider, if any. */\nexport function avatarUrl(user: User): string | undefined {\n switch (user.identity.type) {\n case \"email\":\n return undefined;\n case \"google\":\n case \"x\":\n return user.identity.account.avatar_url;\n case \"wallet\":\n return undefined;\n }\n}\n\nexport interface AuthCredentials {\n user_id: string;\n wallet_address: PubkeyStr;\n expires_at: Date;\n}\n\nexport function isAuthenticated(credentials?: AuthCredentials): boolean {\n if (!credentials) {\n return false;\n }\n return Date.now() < credentials.expires_at.getTime();\n}\n\nexport function generateSigninMessage(nonce: string): Uint8Array {\n return new TextEncoder().encode(`Sign in to Lightcone\\nNonce: ${nonce}`);\n}\n\nexport interface LoginRequest {\n message: string;\n signature_bs58: string;\n pubkey_bytes: number[];\n use_embedded_wallet?: boolean;\n}\n\nexport interface NonceResponse {\n nonce: string;\n}\n"]}
|
package/dist/client.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare class LightconeClient implements ClientContext {
|
|
|
35
35
|
readonly rpcFailoverState: RpcFailoverState;
|
|
36
36
|
private depositSourceValue;
|
|
37
37
|
private signingStrategyValue?;
|
|
38
|
+
private transactionSponsorshipEnabledValue;
|
|
38
39
|
private orderNonceValue;
|
|
39
40
|
private readonly wsConfigValue;
|
|
40
41
|
private readonly authStateStore;
|
|
@@ -50,6 +51,7 @@ export declare class LightconeClient implements ClientContext {
|
|
|
50
51
|
rpcFailoverState?: RpcFailoverState;
|
|
51
52
|
depositSource?: DepositSource;
|
|
52
53
|
signingStrategy?: SigningStrategy;
|
|
54
|
+
transactionSponsorshipEnabled?: boolean;
|
|
53
55
|
orderNonce?: number;
|
|
54
56
|
authCredentials?: AuthCredentials;
|
|
55
57
|
authState?: AuthState;
|
|
@@ -58,8 +60,19 @@ export declare class LightconeClient implements ClientContext {
|
|
|
58
60
|
get depositSource(): DepositSource;
|
|
59
61
|
setDepositSource(source: DepositSource): void;
|
|
60
62
|
get signingStrategy(): SigningStrategy | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Cached authenticated identity shared by domain sub-clients.
|
|
65
|
+
*
|
|
66
|
+
* This is distinct from the HTTP cookie token and may be expired; fund-moving
|
|
67
|
+
* operations must re-check its lifetime and wallet before signing.
|
|
68
|
+
*/
|
|
69
|
+
get authCredentials(): AuthCredentials | undefined;
|
|
61
70
|
setSigningStrategy(strategy: SigningStrategy): void;
|
|
62
71
|
clearSigningStrategy(): void;
|
|
72
|
+
/** Return the client-wide trusted assertion that an external sponsor pays fees. */
|
|
73
|
+
get transactionSponsorshipEnabled(): boolean;
|
|
74
|
+
/** Replace the Transaction Sponsorship Capability for subsequent submissions. */
|
|
75
|
+
setTransactionSponsorshipEnabled(enabled: boolean): void;
|
|
63
76
|
orderNonce(): number | undefined;
|
|
64
77
|
setOrderNonce(nonce: number): void;
|
|
65
78
|
clearOrderNonce(): void;
|
|
@@ -98,6 +111,8 @@ export declare class LightconeClient implements ClientContext {
|
|
|
98
111
|
signAndSubmitTxConfirmed(tx: Transaction): Promise<string>;
|
|
99
112
|
/** Sign, submit, confirm, and return the transaction's processing slot. */
|
|
100
113
|
signAndSubmitTxConfirmedWithSlot(tx: Transaction): Promise<ConfirmedTransaction>;
|
|
114
|
+
/** Confirm a fee-prepared transaction without replacing its message. */
|
|
115
|
+
signAndSubmitPreparedTxConfirmedWithSlot(tx: Transaction): Promise<ConfirmedTransaction>;
|
|
101
116
|
static builder(): LightconeClientBuilder;
|
|
102
117
|
markets(): Markets;
|
|
103
118
|
orderbooks(): Orderbooks;
|
|
@@ -126,6 +141,10 @@ export declare class LightconeClient implements ClientContext {
|
|
|
126
141
|
rpc(): Rpc;
|
|
127
142
|
wsConfig(): WsConfig;
|
|
128
143
|
ws(): WsClient;
|
|
144
|
+
/**
|
|
145
|
+
* Return a client whose Transaction Sponsorship Capability starts at this value.
|
|
146
|
+
* Later runtime changes remain local to each clone, matching other mutable settings.
|
|
147
|
+
*/
|
|
129
148
|
clone(): LightconeClient;
|
|
130
149
|
}
|
|
131
150
|
export declare class LightconeClientBuilder {
|
|
@@ -135,6 +154,7 @@ export declare class LightconeClientBuilder {
|
|
|
135
154
|
private programIdValue;
|
|
136
155
|
private depositSourceValue;
|
|
137
156
|
private signingStrategyValue?;
|
|
157
|
+
private transactionSponsorshipEnabledValue;
|
|
138
158
|
private primaryRpcUrlValue?;
|
|
139
159
|
private backupRpcUrlValue?;
|
|
140
160
|
/**
|
|
@@ -155,7 +175,9 @@ export declare class LightconeClientBuilder {
|
|
|
155
175
|
depositSource(source: DepositSource): LightconeClientBuilder;
|
|
156
176
|
nativeSigner(keypair: Keypair): LightconeClientBuilder;
|
|
157
177
|
externalSigner(signer: ExternalSigner): LightconeClientBuilder;
|
|
158
|
-
privyWalletId(walletId: string): LightconeClientBuilder;
|
|
178
|
+
privyWalletId(walletId: string, walletAddress?: string): LightconeClientBuilder;
|
|
179
|
+
/** Set the initial trusted Transaction Sponsorship Capability; defaults to false. */
|
|
180
|
+
transactionSponsorship(enabled: boolean): LightconeClientBuilder;
|
|
159
181
|
rpcUrl(url: string): LightconeClientBuilder;
|
|
160
182
|
/** Set a backup Solana RPC URL for automatic failover. */
|
|
161
183
|
backupRpcUrl(url: string): LightconeClientBuilder;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,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AW,EAAE,YAAY,GAAG,sBAAsB;IAQtD,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB;IAI5C,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB;IAKhD,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB;IAI1C,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB;IAK9C,IAAI,CAAC,WAAW,EAAE,eAAe,GAAG,sBAAsB;IAI1D,QAAQ,CAAC,WAAW,EAAE,eAAe,GAAG,sBAAsB;IAK9D,SAAS,CAAC,EAAE,EAAE,SAAS,GAAG,sBAAsB;IAKhD,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,sBAAsB;IAK5D,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,sBAAsB;IAKtD,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,sBAAsB;IAK9D,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,GACrB,sBAAsB;IAKzB,qFAAqF;IACrF,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,sBAAsB;IAKhE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB;IAK3C,0DAA0D;IAC1D,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB;IAKjD,KAAK,IAAI,eAAe;CAwBzB"}
|
package/dist/client.js
CHANGED
|
@@ -43,6 +43,7 @@ class LightconeClient {
|
|
|
43
43
|
rpcFailoverState;
|
|
44
44
|
depositSourceValue;
|
|
45
45
|
signingStrategyValue;
|
|
46
|
+
transactionSponsorshipEnabledValue;
|
|
46
47
|
orderNonceValue;
|
|
47
48
|
wsConfigValue;
|
|
48
49
|
authStateStore;
|
|
@@ -60,6 +61,8 @@ class LightconeClient {
|
|
|
60
61
|
params.rpcFailoverState ?? new rpcFailover_1.RpcFailoverState();
|
|
61
62
|
this.depositSourceValue = params.depositSource ?? shared_1.DepositSource.Global;
|
|
62
63
|
this.signingStrategyValue = params.signingStrategy;
|
|
64
|
+
this.transactionSponsorshipEnabledValue =
|
|
65
|
+
params.transactionSponsorshipEnabled ?? false;
|
|
63
66
|
this.orderNonceValue = params.orderNonce;
|
|
64
67
|
this.wsConfigValue = params.wsConfig;
|
|
65
68
|
this.authStateStore =
|
|
@@ -78,12 +81,29 @@ class LightconeClient {
|
|
|
78
81
|
get signingStrategy() {
|
|
79
82
|
return this.signingStrategyValue;
|
|
80
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Cached authenticated identity shared by domain sub-clients.
|
|
86
|
+
*
|
|
87
|
+
* This is distinct from the HTTP cookie token and may be expired; fund-moving
|
|
88
|
+
* operations must re-check its lifetime and wallet before signing.
|
|
89
|
+
*/
|
|
90
|
+
get authCredentials() {
|
|
91
|
+
return this.authStateStore.getCredentials();
|
|
92
|
+
}
|
|
81
93
|
setSigningStrategy(strategy) {
|
|
82
94
|
this.signingStrategyValue = strategy;
|
|
83
95
|
}
|
|
84
96
|
clearSigningStrategy() {
|
|
85
97
|
this.signingStrategyValue = undefined;
|
|
86
98
|
}
|
|
99
|
+
/** Return the client-wide trusted assertion that an external sponsor pays fees. */
|
|
100
|
+
get transactionSponsorshipEnabled() {
|
|
101
|
+
return this.transactionSponsorshipEnabledValue;
|
|
102
|
+
}
|
|
103
|
+
/** Replace the Transaction Sponsorship Capability for subsequent submissions. */
|
|
104
|
+
setTransactionSponsorshipEnabled(enabled) {
|
|
105
|
+
this.transactionSponsorshipEnabledValue = enabled;
|
|
106
|
+
}
|
|
87
107
|
// ── Nonce cache ──────────────────────────────────────────────────────
|
|
88
108
|
orderNonce() {
|
|
89
109
|
return this.orderNonceValue;
|
|
@@ -145,6 +165,10 @@ class LightconeClient {
|
|
|
145
165
|
async signAndSubmitTxConfirmedWithSlot(tx) {
|
|
146
166
|
return (0, context_1.signAndSubmitTxConfirmedWithSlot)(this, tx);
|
|
147
167
|
}
|
|
168
|
+
/** Confirm a fee-prepared transaction without replacing its message. */
|
|
169
|
+
async signAndSubmitPreparedTxConfirmedWithSlot(tx) {
|
|
170
|
+
return (0, context_1.signAndSubmitPreparedTxConfirmedWithSlot)(this, tx);
|
|
171
|
+
}
|
|
148
172
|
static builder() {
|
|
149
173
|
return new LightconeClientBuilder();
|
|
150
174
|
}
|
|
@@ -210,6 +234,10 @@ class LightconeClient {
|
|
|
210
234
|
ws() {
|
|
211
235
|
return new ws_1.WsClient(this.wsConfigValue, this.http.authTokenRef());
|
|
212
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Return a client whose Transaction Sponsorship Capability starts at this value.
|
|
239
|
+
* Later runtime changes remain local to each clone, matching other mutable settings.
|
|
240
|
+
*/
|
|
213
241
|
clone() {
|
|
214
242
|
return new LightconeClient({
|
|
215
243
|
http: this.http,
|
|
@@ -224,6 +252,7 @@ class LightconeClient {
|
|
|
224
252
|
rpcFailoverState: this.rpcFailoverState,
|
|
225
253
|
depositSource: this.depositSourceValue,
|
|
226
254
|
signingStrategy: this.signingStrategyValue,
|
|
255
|
+
transactionSponsorshipEnabled: this.transactionSponsorshipEnabledValue,
|
|
227
256
|
orderNonce: this.orderNonceValue,
|
|
228
257
|
authState: this.authStateStore,
|
|
229
258
|
orderbookRulesCache: this.orderbookRulesCache,
|
|
@@ -238,6 +267,7 @@ class LightconeClientBuilder {
|
|
|
238
267
|
programIdValue = (0, env_1.programId)(env_1.LightconeEnv.Prod);
|
|
239
268
|
depositSourceValue = shared_1.DepositSource.Global;
|
|
240
269
|
signingStrategyValue;
|
|
270
|
+
transactionSponsorshipEnabledValue = false;
|
|
241
271
|
primaryRpcUrlValue = (0, env_1.rpcUrl)(env_1.LightconeEnv.Prod);
|
|
242
272
|
backupRpcUrlValue;
|
|
243
273
|
/**
|
|
@@ -291,8 +321,13 @@ class LightconeClientBuilder {
|
|
|
291
321
|
this.signingStrategyValue = { type: "walletAdapter", signer };
|
|
292
322
|
return this;
|
|
293
323
|
}
|
|
294
|
-
privyWalletId(walletId) {
|
|
295
|
-
this.signingStrategyValue = { type: "privy", walletId };
|
|
324
|
+
privyWalletId(walletId, walletAddress) {
|
|
325
|
+
this.signingStrategyValue = { type: "privy", walletId, walletAddress };
|
|
326
|
+
return this;
|
|
327
|
+
}
|
|
328
|
+
/** Set the initial trusted Transaction Sponsorship Capability; defaults to false. */
|
|
329
|
+
transactionSponsorship(enabled) {
|
|
330
|
+
this.transactionSponsorshipEnabledValue = enabled;
|
|
296
331
|
return this;
|
|
297
332
|
}
|
|
298
333
|
rpcUrl(url) {
|
|
@@ -318,6 +353,7 @@ class LightconeClientBuilder {
|
|
|
318
353
|
programId: this.programIdValue,
|
|
319
354
|
depositSource: this.depositSourceValue,
|
|
320
355
|
signingStrategy: this.signingStrategyValue,
|
|
356
|
+
transactionSponsorshipEnabled: this.transactionSponsorshipEnabledValue,
|
|
321
357
|
primaryConnection: this.primaryRpcUrlValue
|
|
322
358
|
? new web3_js_1.Connection(this.primaryRpcUrlValue, { commitment: "confirmed" })
|
|
323
359
|
: undefined,
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,6CAA8E;AAC9E,iCAAoD;AAEpD,uCAImB;AAGnB,4CAA0C;AAC1C,8CAA2C;AAC3C,wDAAsD;AACtD,0CAAwC;AACxC,kDAAgD;AAChD,gDAA8C;AAC9C,0DAA4D;AAC5D,gDAA8C;AAC9C,0CAAwC;AACxC,iCAA6E;AAC7E,+BAAuF;AACvF,mCAAgC;AAChC,+BAA4B;AAC5B,+CAAiD;AACjD,qCAA8E;AAE9E,6BAA+C;AAE/C,MAAM,SAAS;IACL,gBAAgB,CAA8B;IAEtD,YAAY,OAAyB;QACnC,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC;IAClC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED,cAAc,CAAC,WAAwC;QACrD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,KAAK;gBAC3B,cAAc,EAAE,MAAM;gBACtB,aAAa,EAAE,MAAM;aACtB;YACD,SAAS,EAAE,IAAI,CAAC,cAAc;YAC9B,aAAa,EAAE,IAAI,CAAC,kBAAkB;YACtC,eAAe,EAAE,IAAI,CAAC,oBAAoB;YAC1C,iBAAiB,EAAE,IAAI,CAAC,kBAAkB;gBACxC,CAAC,CAAC,IAAI,oBAAU,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;gBACtE,CAAC,CAAC,SAAS;YACb,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;gBACtC,CAAC,CAAC,IAAI,oBAAU,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;gBACrE,CAAC,CAAC,SAAS;YACb,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAC,CAAC;IACL,CAAC;CACF;AA/GD,wDA+GC","sourcesContent":["import { Connection, Keypair, PublicKey, Transaction } from \"@solana/web3.js\";\nimport { Auth, type AuthCredentials } from \"./auth\";\nimport type { ClientContext } from \"./context\";\nimport {\n signAndSubmitTx as signAndSubmitTxFn,\n signAndSubmitTxConfirmed as signAndSubmitTxConfirmedFn,\n signAndSubmitTxConfirmedWithSlot as signAndSubmitTxConfirmedWithSlotFn,\n} from \"./context\";\nimport type { ConfirmedTransaction } from \"./context\";\nimport type { FaucetRequest, FaucetResponse } from \"./domain/faucet\";\nimport { Markets } from \"./domain/market\";\nimport { Metrics } from \"./domain/metrics\";\nimport { Notifications } from \"./domain/notification\";\nimport { Orders } from \"./domain/order\";\nimport { Orderbooks } from \"./domain/orderbook\";\nimport { Positions } from \"./domain/position\";\nimport { PriceHistoryClient } from \"./domain/price_history\";\nimport { Referrals } from \"./domain/referral\";\nimport { Trades } from \"./domain/trade\";\nimport { LightconeHttp, RetryPolicy, type CredentialRestorer } from \"./http\";\nimport { LightconeEnv, apiUrl, wsUrl, rpcUrl, programId as envProgramId } from \"./env\";\nimport { Privy } from \"./privy\";\nimport { Rpc } from \"./rpc\";\nimport { RpcFailoverState } from \"./rpcFailover\";\nimport { DepositSource, type OrderbookRules, type PubkeyStr } from \"./shared\";\nimport { type ExternalSigner, type SigningStrategy } from \"./shared/signing\";\nimport { WsClient, type WsConfig } from \"./ws\";\n\nclass AuthState {\n private credentialsValue: AuthCredentials | undefined;\n\n constructor(initial?: AuthCredentials) {\n this.credentialsValue = initial;\n }\n\n getCredentials(): AuthCredentials | undefined {\n return this.credentialsValue;\n }\n\n setCredentials(credentials: AuthCredentials | undefined): void {\n this.credentialsValue = credentials;\n }\n\n async clearCaches(): Promise<void> {\n // No caches to clear — decimals are derived locally from orderbook metadata.\n }\n}\n\nexport class LightconeClient implements ClientContext {\n readonly http: LightconeHttp;\n readonly programId: PublicKey;\n readonly primaryConnection?: Connection;\n readonly backupConnection?: Connection;\n readonly rpcFailoverState: RpcFailoverState;\n private depositSourceValue: DepositSource;\n private signingStrategyValue?: SigningStrategy;\n private orderNonceValue: number | undefined;\n private readonly wsConfigValue: WsConfig;\n private readonly authStateStore: AuthState;\n readonly orderbookRulesCache: Map<string, Promise<OrderbookRules>>;\n\n /** @deprecated Use primaryConnection — kept for ClientContext compat. */\n get connection(): Connection | undefined {\n return this.primaryConnection;\n }\n\n constructor(params: {\n http: LightconeHttp;\n wsConfig: WsConfig;\n programId?: PublicKey;\n primaryConnection?: Connection;\n backupConnection?: Connection;\n rpcFailoverState?: RpcFailoverState;\n depositSource?: DepositSource;\n signingStrategy?: SigningStrategy;\n orderNonce?: number;\n authCredentials?: AuthCredentials;\n authState?: AuthState;\n orderbookRulesCache?: Map<string, Promise<OrderbookRules>>;\n }) {\n this.http = params.http;\n this.programId = params.programId ?? envProgramId(LightconeEnv.Prod);\n this.primaryConnection = params.primaryConnection;\n this.backupConnection = params.backupConnection;\n this.rpcFailoverState =\n params.rpcFailoverState ?? new RpcFailoverState();\n this.depositSourceValue = params.depositSource ?? DepositSource.Global;\n this.signingStrategyValue = params.signingStrategy;\n this.orderNonceValue = params.orderNonce;\n this.wsConfigValue = params.wsConfig;\n this.authStateStore =\n params.authState ??\n new AuthState(params.authCredentials);\n this.orderbookRulesCache = params.orderbookRulesCache ?? new Map();\n }\n\n // ── Deposit source ──────────────────────────────────────────────────\n\n get depositSource(): DepositSource {\n return this.depositSourceValue;\n }\n\n setDepositSource(source: DepositSource): void {\n this.depositSourceValue = source;\n }\n\n // ── Signing strategy ────────────────────────────────────────────────\n\n get signingStrategy(): SigningStrategy | undefined {\n return this.signingStrategyValue;\n }\n\n setSigningStrategy(strategy: SigningStrategy): void {\n this.signingStrategyValue = strategy;\n }\n\n clearSigningStrategy(): void {\n this.signingStrategyValue = undefined;\n }\n\n // ── Nonce cache ──────────────────────────────────────────────────────\n\n orderNonce(): number | undefined {\n return this.orderNonceValue;\n }\n\n setOrderNonce(nonce: number): void {\n this.orderNonceValue = nonce;\n }\n\n clearOrderNonce(): void {\n this.orderNonceValue = undefined;\n }\n\n // ── Auth token (cookie) ─────────────────────────────────────────────\n\n /**\n * Get the current `lightcone-token` cookie value, if any. Populated by the SDK\n * after a successful login, then attached on every authed request. Useful\n * for forwarding the token through the `*WithCookies` methods, or\n * persisting the session across processes.\n */\n async authToken(): Promise<string | undefined> {\n return this.http.authTokenRef()();\n }\n\n /**\n * Clear the cached `lightcone-token`. Subsequent authed calls will go out\n * without a `Cookie` header (and 401) unless they use a\n * `*WithCookies` variant.\n */\n async clearAuthToken(): Promise<void> {\n await this.http.clearAuthToken();\n }\n\n /**\n * Register the credential restorer consulted when a request fails with\n * HTTP 401: it attempts to restore credentials (e.g. refresh the app's\n * auth session so the auth cookie is valid again); on success the\n * transport replays the request once IF it declared itself retry-safe\n * (RetryPolicy.None mutations are never auto-replayed). See {@link CredentialRestorer}.\n * Without a restorer, 401s propagate to callers unchanged.\n *\n * Common use: set once at app startup, alongside the signing strategy.\n */\n setCredentialRestorer(restorer: CredentialRestorer): void {\n this.http.setCredentialRestorer(restorer);\n }\n\n /** Remove the credential restorer (e.g. in tests); 401s propagate again. */\n clearCredentialRestorer(): void {\n this.http.clearCredentialRestorer();\n }\n\n // ── Transaction signing + submission ────────────────────────────────\n\n async signAndSubmitTx(tx: Transaction): Promise<string> {\n return signAndSubmitTxFn(this, tx);\n }\n\n /**\n * Sign and submit a transaction, then wait until it reaches `confirmed`\n * commitment on-chain. Prefer this over {@link signAndSubmitTx} when a\n * follow-up transaction depends on this one's state.\n */\n async signAndSubmitTxConfirmed(tx: Transaction): Promise<string> {\n return signAndSubmitTxConfirmedFn(this, tx);\n }\n\n /** Sign, submit, confirm, and return the transaction's processing slot. */\n async signAndSubmitTxConfirmedWithSlot(\n tx: Transaction\n ): Promise<ConfirmedTransaction> {\n return signAndSubmitTxConfirmedWithSlotFn(this, tx);\n }\n\n static builder(): LightconeClientBuilder {\n return new LightconeClientBuilder();\n }\n\n // ── Sub-client accessors ─────────────────────────────────────────────\n\n markets(): Markets {\n return new Markets(this);\n }\n\n orderbooks(): Orderbooks {\n return new Orderbooks(this);\n }\n\n orders(): Orders {\n return new Orders(this);\n }\n\n positions(): Positions {\n return new Positions(this);\n }\n\n trades(): Trades {\n return new Trades(this);\n }\n\n priceHistory(): PriceHistoryClient {\n return new PriceHistoryClient(this);\n }\n\n notifications(): Notifications {\n return new Notifications(this);\n }\n\n /**\n * Metrics sub-client — platform / market / orderbook / category / deposit-token\n * volume metrics, market leaderboard, and time-series history.\n */\n metrics(): Metrics {\n return new Metrics(this);\n }\n\n /**\n * Request testnet SOL and whitelisted deposit tokens for a wallet.\n *\n * Only active on environments whose backend has the faucet enabled (typically\n * local and staging).\n *\n * `POST /api/claim`\n */\n async claim(walletAddress: PubkeyStr): Promise<FaucetResponse> {\n const url = `${this.http.baseUrl()}/api/claim`;\n return this.http.post<FaucetResponse, FaucetRequest>(\n url,\n { wallet_address: walletAddress },\n RetryPolicy.None\n );\n }\n\n auth(): Auth {\n return new Auth({\n http: this.http,\n authState: this.authStateStore,\n });\n }\n\n privy(): Privy {\n return new Privy(this);\n }\n\n referrals(): Referrals {\n return new Referrals(this);\n }\n\n rpc(): Rpc {\n return new Rpc(this);\n }\n\n wsConfig(): WsConfig {\n return this.wsConfigValue;\n }\n\n ws(): WsClient {\n return new WsClient(this.wsConfigValue, this.http.authTokenRef());\n }\n\n clone(): LightconeClient {\n return new LightconeClient({\n http: this.http,\n wsConfig: { ...this.wsConfigValue },\n programId: this.programId,\n primaryConnection: this.primaryConnection\n ? new Connection(this.primaryConnection.rpcEndpoint, { commitment: \"confirmed\" })\n : undefined,\n backupConnection: this.backupConnection\n ? new Connection(this.backupConnection.rpcEndpoint, { commitment: \"confirmed\" })\n : undefined,\n rpcFailoverState: this.rpcFailoverState,\n depositSource: this.depositSourceValue,\n signingStrategy: this.signingStrategyValue,\n orderNonce: this.orderNonceValue,\n authState: this.authStateStore,\n orderbookRulesCache: this.orderbookRulesCache,\n });\n }\n}\n\nexport class LightconeClientBuilder {\n private baseUrlValue: string = apiUrl(LightconeEnv.Prod);\n private wsUrlValue: string = wsUrl(LightconeEnv.Prod);\n private authCredentials?: AuthCredentials;\n private programIdValue: PublicKey = envProgramId(LightconeEnv.Prod);\n private depositSourceValue: DepositSource = DepositSource.Global;\n private signingStrategyValue?: SigningStrategy;\n private primaryRpcUrlValue?: string = rpcUrl(LightconeEnv.Prod);\n private backupRpcUrlValue?: string;\n\n /**\n * Set the deployment environment. Configures the API URL, WebSocket URL,\n * RPC URL, and program ID for the given environment.\n *\n * Individual URL overrides (e.g. `.baseUrl()`) take precedence when\n * called **after** `.env()`.\n */\n env(environment: LightconeEnv): LightconeClientBuilder {\n this.baseUrlValue = apiUrl(environment);\n this.wsUrlValue = wsUrl(environment);\n this.programIdValue = envProgramId(environment);\n this.primaryRpcUrlValue = rpcUrl(environment);\n return this;\n }\n\n baseUrl(url: string): LightconeClientBuilder {\n return this.withBaseUrl(url);\n }\n\n withBaseUrl(url: string): LightconeClientBuilder {\n this.baseUrlValue = url;\n return this;\n }\n\n wsUrl(url: string): LightconeClientBuilder {\n return this.withWsUrl(url);\n }\n\n withWsUrl(url: string): LightconeClientBuilder {\n this.wsUrlValue = url;\n return this;\n }\n\n auth(credentials: AuthCredentials): LightconeClientBuilder {\n return this.withAuth(credentials);\n }\n\n withAuth(credentials: AuthCredentials): LightconeClientBuilder {\n this.authCredentials = credentials;\n return this;\n }\n\n programId(id: PublicKey): LightconeClientBuilder {\n this.programIdValue = id;\n return this;\n }\n\n depositSource(source: DepositSource): LightconeClientBuilder {\n this.depositSourceValue = source;\n return this;\n }\n\n nativeSigner(keypair: Keypair): LightconeClientBuilder {\n this.signingStrategyValue = { type: \"native\", keypair };\n return this;\n }\n\n externalSigner(signer: ExternalSigner): LightconeClientBuilder {\n this.signingStrategyValue = { type: \"walletAdapter\", signer };\n return this;\n }\n\n privyWalletId(walletId: string): LightconeClientBuilder {\n this.signingStrategyValue = { type: \"privy\", walletId };\n return this;\n }\n\n rpcUrl(url: string): LightconeClientBuilder {\n this.primaryRpcUrlValue = url;\n return this;\n }\n\n /** Set a backup Solana RPC URL for automatic failover. */\n backupRpcUrl(url: string): LightconeClientBuilder {\n this.backupRpcUrlValue = url;\n return this;\n }\n\n build(): LightconeClient {\n return new LightconeClient({\n http: new LightconeHttp(this.baseUrlValue),\n wsConfig: {\n url: this.wsUrlValue,\n reconnect: true,\n maxReconnectAttempts: 10,\n baseReconnectDelayMs: 1_000,\n pingIntervalMs: 30_000,\n pongTimeoutMs: 10_000,\n },\n programId: this.programIdValue,\n depositSource: this.depositSourceValue,\n signingStrategy: this.signingStrategyValue,\n primaryConnection: this.primaryRpcUrlValue\n ? new Connection(this.primaryRpcUrlValue, { commitment: \"confirmed\" })\n : undefined,\n backupConnection: this.backupRpcUrlValue\n ? new Connection(this.backupRpcUrlValue, { commitment: \"confirmed\" })\n : undefined,\n authCredentials: this.authCredentials,\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],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xB,oBAAoB,EAAE,KAAK;gBAC3B,cAAc,EAAE,MAAM;gBACtB,aAAa,EAAE,MAAM;aACtB;YACD,SAAS,EAAE,IAAI,CAAC,cAAc;YAC9B,aAAa,EAAE,IAAI,CAAC,kBAAkB;YACtC,eAAe,EAAE,IAAI,CAAC,oBAAoB;YAC1C,6BAA6B,EAAE,IAAI,CAAC,kCAAkC;YACtE,iBAAiB,EAAE,IAAI,CAAC,kBAAkB;gBACxC,CAAC,CAAC,IAAI,oBAAU,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;gBACtE,CAAC,CAAC,SAAS;YACb,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;gBACtC,CAAC,CAAC,IAAI,oBAAU,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;gBACrE,CAAC,CAAC,SAAS;YACb,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAC,CAAC;IACL,CAAC;CACF;AA1HD,wDA0HC","sourcesContent":["import { Connection, Keypair, PublicKey, Transaction } from \"@solana/web3.js\";\nimport { Auth, type AuthCredentials } from \"./auth\";\nimport type { ClientContext } from \"./context\";\nimport {\n signAndSubmitTx as signAndSubmitTxFn,\n signAndSubmitTxConfirmed as signAndSubmitTxConfirmedFn,\n signAndSubmitTxConfirmedWithSlot as signAndSubmitTxConfirmedWithSlotFn,\n signAndSubmitPreparedTxConfirmedWithSlot as signAndSubmitPreparedTxConfirmedWithSlotFn,\n} from \"./context\";\nimport type { ConfirmedTransaction } from \"./context\";\nimport type { FaucetRequest, FaucetResponse } from \"./domain/faucet\";\nimport { Markets } from \"./domain/market\";\nimport { Metrics } from \"./domain/metrics\";\nimport { Notifications } from \"./domain/notification\";\nimport { Orders } from \"./domain/order\";\nimport { Orderbooks } from \"./domain/orderbook\";\nimport { Positions } from \"./domain/position\";\nimport { PriceHistoryClient } from \"./domain/price_history\";\nimport { Referrals } from \"./domain/referral\";\nimport { Trades } from \"./domain/trade\";\nimport { LightconeHttp, RetryPolicy, type CredentialRestorer } from \"./http\";\nimport { LightconeEnv, apiUrl, wsUrl, rpcUrl, programId as envProgramId } from \"./env\";\nimport { Privy } from \"./privy\";\nimport { Rpc } from \"./rpc\";\nimport { RpcFailoverState } from \"./rpcFailover\";\nimport { DepositSource, type OrderbookRules, type PubkeyStr } from \"./shared\";\nimport { type ExternalSigner, type SigningStrategy } from \"./shared/signing\";\nimport { WsClient, type WsConfig } from \"./ws\";\n\nclass AuthState {\n private credentialsValue: AuthCredentials | undefined;\n\n constructor(initial?: AuthCredentials) {\n this.credentialsValue = initial;\n }\n\n getCredentials(): AuthCredentials | undefined {\n return this.credentialsValue;\n }\n\n setCredentials(credentials: AuthCredentials | undefined): void {\n this.credentialsValue = credentials;\n }\n\n async clearCaches(): Promise<void> {\n // No caches to clear — decimals are derived locally from orderbook metadata.\n }\n}\n\nexport class LightconeClient implements ClientContext {\n readonly http: LightconeHttp;\n readonly programId: PublicKey;\n readonly primaryConnection?: Connection;\n readonly backupConnection?: Connection;\n readonly rpcFailoverState: RpcFailoverState;\n private depositSourceValue: DepositSource;\n private signingStrategyValue?: SigningStrategy;\n private transactionSponsorshipEnabledValue: boolean;\n private orderNonceValue: number | undefined;\n private readonly wsConfigValue: WsConfig;\n private readonly authStateStore: AuthState;\n readonly orderbookRulesCache: Map<string, Promise<OrderbookRules>>;\n\n /** @deprecated Use primaryConnection — kept for ClientContext compat. */\n get connection(): Connection | undefined {\n return this.primaryConnection;\n }\n\n constructor(params: {\n http: LightconeHttp;\n wsConfig: WsConfig;\n programId?: PublicKey;\n primaryConnection?: Connection;\n backupConnection?: Connection;\n rpcFailoverState?: RpcFailoverState;\n depositSource?: DepositSource;\n signingStrategy?: SigningStrategy;\n transactionSponsorshipEnabled?: boolean;\n orderNonce?: number;\n authCredentials?: AuthCredentials;\n authState?: AuthState;\n orderbookRulesCache?: Map<string, Promise<OrderbookRules>>;\n }) {\n this.http = params.http;\n this.programId = params.programId ?? envProgramId(LightconeEnv.Prod);\n this.primaryConnection = params.primaryConnection;\n this.backupConnection = params.backupConnection;\n this.rpcFailoverState =\n params.rpcFailoverState ?? new RpcFailoverState();\n this.depositSourceValue = params.depositSource ?? DepositSource.Global;\n this.signingStrategyValue = params.signingStrategy;\n this.transactionSponsorshipEnabledValue =\n params.transactionSponsorshipEnabled ?? false;\n this.orderNonceValue = params.orderNonce;\n this.wsConfigValue = params.wsConfig;\n this.authStateStore =\n params.authState ??\n new AuthState(params.authCredentials);\n this.orderbookRulesCache = params.orderbookRulesCache ?? new Map();\n }\n\n // ── Deposit source ──────────────────────────────────────────────────\n\n get depositSource(): DepositSource {\n return this.depositSourceValue;\n }\n\n setDepositSource(source: DepositSource): void {\n this.depositSourceValue = source;\n }\n\n // ── Signing strategy ────────────────────────────────────────────────\n\n get signingStrategy(): SigningStrategy | undefined {\n return this.signingStrategyValue;\n }\n\n /**\n * Cached authenticated identity shared by domain sub-clients.\n *\n * This is distinct from the HTTP cookie token and may be expired; fund-moving\n * operations must re-check its lifetime and wallet before signing.\n */\n get authCredentials(): AuthCredentials | undefined {\n return this.authStateStore.getCredentials();\n }\n\n setSigningStrategy(strategy: SigningStrategy): void {\n this.signingStrategyValue = strategy;\n }\n\n clearSigningStrategy(): void {\n this.signingStrategyValue = undefined;\n }\n\n /** Return the client-wide trusted assertion that an external sponsor pays fees. */\n get transactionSponsorshipEnabled(): boolean {\n return this.transactionSponsorshipEnabledValue;\n }\n\n /** Replace the Transaction Sponsorship Capability for subsequent submissions. */\n setTransactionSponsorshipEnabled(enabled: boolean): void {\n this.transactionSponsorshipEnabledValue = enabled;\n }\n\n // ── Nonce cache ──────────────────────────────────────────────────────\n\n orderNonce(): number | undefined {\n return this.orderNonceValue;\n }\n\n setOrderNonce(nonce: number): void {\n this.orderNonceValue = nonce;\n }\n\n clearOrderNonce(): void {\n this.orderNonceValue = undefined;\n }\n\n // ── Auth token (cookie) ─────────────────────────────────────────────\n\n /**\n * Get the current `lightcone-token` cookie value, if any. Populated by the SDK\n * after a successful login, then attached on every authed request. Useful\n * for forwarding the token through the `*WithCookies` methods, or\n * persisting the session across processes.\n */\n async authToken(): Promise<string | undefined> {\n return this.http.authTokenRef()();\n }\n\n /**\n * Clear the cached `lightcone-token`. Subsequent authed calls will go out\n * without a `Cookie` header (and 401) unless they use a\n * `*WithCookies` variant.\n */\n async clearAuthToken(): Promise<void> {\n await this.http.clearAuthToken();\n }\n\n /**\n * Register the credential restorer consulted when a request fails with\n * HTTP 401: it attempts to restore credentials (e.g. refresh the app's\n * auth session so the auth cookie is valid again); on success the\n * transport replays the request once IF it declared itself retry-safe\n * (RetryPolicy.None mutations are never auto-replayed). See {@link CredentialRestorer}.\n * Without a restorer, 401s propagate to callers unchanged.\n *\n * Common use: set once at app startup, alongside the signing strategy.\n */\n setCredentialRestorer(restorer: CredentialRestorer): void {\n this.http.setCredentialRestorer(restorer);\n }\n\n /** Remove the credential restorer (e.g. in tests); 401s propagate again. */\n clearCredentialRestorer(): void {\n this.http.clearCredentialRestorer();\n }\n\n // ── Transaction signing + submission ────────────────────────────────\n\n async signAndSubmitTx(tx: Transaction): Promise<string> {\n return signAndSubmitTxFn(this, tx);\n }\n\n /**\n * Sign and submit a transaction, then wait until it reaches `confirmed`\n * commitment on-chain. Prefer this over {@link signAndSubmitTx} when a\n * follow-up transaction depends on this one's state.\n */\n async signAndSubmitTxConfirmed(tx: Transaction): Promise<string> {\n return signAndSubmitTxConfirmedFn(this, tx);\n }\n\n /** Sign, submit, confirm, and return the transaction's processing slot. */\n async signAndSubmitTxConfirmedWithSlot(\n tx: Transaction\n ): Promise<ConfirmedTransaction> {\n return signAndSubmitTxConfirmedWithSlotFn(this, tx);\n }\n\n /** Confirm a fee-prepared transaction without replacing its message. */\n async signAndSubmitPreparedTxConfirmedWithSlot(\n tx: Transaction\n ): Promise<ConfirmedTransaction> {\n return signAndSubmitPreparedTxConfirmedWithSlotFn(this, tx);\n }\n\n static builder(): LightconeClientBuilder {\n return new LightconeClientBuilder();\n }\n\n // ── Sub-client accessors ─────────────────────────────────────────────\n\n markets(): Markets {\n return new Markets(this);\n }\n\n orderbooks(): Orderbooks {\n return new Orderbooks(this);\n }\n\n orders(): Orders {\n return new Orders(this);\n }\n\n positions(): Positions {\n return new Positions(this);\n }\n\n trades(): Trades {\n return new Trades(this);\n }\n\n priceHistory(): PriceHistoryClient {\n return new PriceHistoryClient(this);\n }\n\n notifications(): Notifications {\n return new Notifications(this);\n }\n\n /**\n * Metrics sub-client — platform / market / orderbook / category / deposit-token\n * volume metrics, market leaderboard, and time-series history.\n */\n metrics(): Metrics {\n return new Metrics(this);\n }\n\n /**\n * Request testnet SOL and whitelisted deposit tokens for a wallet.\n *\n * Only active on environments whose backend has the faucet enabled (typically\n * local and staging).\n *\n * `POST /api/claim`\n */\n async claim(walletAddress: PubkeyStr): Promise<FaucetResponse> {\n const url = `${this.http.baseUrl()}/api/claim`;\n return this.http.post<FaucetResponse, FaucetRequest>(\n url,\n { wallet_address: walletAddress },\n RetryPolicy.None\n );\n }\n\n auth(): Auth {\n return new Auth({\n http: this.http,\n authState: this.authStateStore,\n });\n }\n\n privy(): Privy {\n return new Privy(this);\n }\n\n referrals(): Referrals {\n return new Referrals(this);\n }\n\n rpc(): Rpc {\n return new Rpc(this);\n }\n\n wsConfig(): WsConfig {\n return this.wsConfigValue;\n }\n\n ws(): WsClient {\n return new WsClient(this.wsConfigValue, this.http.authTokenRef());\n }\n\n /**\n * Return a client whose Transaction Sponsorship Capability starts at this value.\n * Later runtime changes remain local to each clone, matching other mutable settings.\n */\n clone(): LightconeClient {\n return new LightconeClient({\n http: this.http,\n wsConfig: { ...this.wsConfigValue },\n programId: this.programId,\n primaryConnection: this.primaryConnection\n ? new Connection(this.primaryConnection.rpcEndpoint, { commitment: \"confirmed\" })\n : undefined,\n backupConnection: this.backupConnection\n ? new Connection(this.backupConnection.rpcEndpoint, { commitment: \"confirmed\" })\n : undefined,\n rpcFailoverState: this.rpcFailoverState,\n depositSource: this.depositSourceValue,\n signingStrategy: this.signingStrategyValue,\n transactionSponsorshipEnabled: this.transactionSponsorshipEnabledValue,\n orderNonce: this.orderNonceValue,\n authState: this.authStateStore,\n orderbookRulesCache: this.orderbookRulesCache,\n });\n }\n}\n\nexport class LightconeClientBuilder {\n private baseUrlValue: string = apiUrl(LightconeEnv.Prod);\n private wsUrlValue: string = wsUrl(LightconeEnv.Prod);\n private authCredentials?: AuthCredentials;\n private programIdValue: PublicKey = envProgramId(LightconeEnv.Prod);\n private depositSourceValue: DepositSource = DepositSource.Global;\n private signingStrategyValue?: SigningStrategy;\n private transactionSponsorshipEnabledValue = false;\n private primaryRpcUrlValue?: string = rpcUrl(LightconeEnv.Prod);\n private backupRpcUrlValue?: string;\n\n /**\n * Set the deployment environment. Configures the API URL, WebSocket URL,\n * RPC URL, and program ID for the given environment.\n *\n * Individual URL overrides (e.g. `.baseUrl()`) take precedence when\n * called **after** `.env()`.\n */\n env(environment: LightconeEnv): LightconeClientBuilder {\n this.baseUrlValue = apiUrl(environment);\n this.wsUrlValue = wsUrl(environment);\n this.programIdValue = envProgramId(environment);\n this.primaryRpcUrlValue = rpcUrl(environment);\n return this;\n }\n\n baseUrl(url: string): LightconeClientBuilder {\n return this.withBaseUrl(url);\n }\n\n withBaseUrl(url: string): LightconeClientBuilder {\n this.baseUrlValue = url;\n return this;\n }\n\n wsUrl(url: string): LightconeClientBuilder {\n return this.withWsUrl(url);\n }\n\n withWsUrl(url: string): LightconeClientBuilder {\n this.wsUrlValue = url;\n return this;\n }\n\n auth(credentials: AuthCredentials): LightconeClientBuilder {\n return this.withAuth(credentials);\n }\n\n withAuth(credentials: AuthCredentials): LightconeClientBuilder {\n this.authCredentials = credentials;\n return this;\n }\n\n programId(id: PublicKey): LightconeClientBuilder {\n this.programIdValue = id;\n return this;\n }\n\n depositSource(source: DepositSource): LightconeClientBuilder {\n this.depositSourceValue = source;\n return this;\n }\n\n nativeSigner(keypair: Keypair): LightconeClientBuilder {\n this.signingStrategyValue = { type: \"native\", keypair };\n return this;\n }\n\n externalSigner(signer: ExternalSigner): LightconeClientBuilder {\n this.signingStrategyValue = { type: \"walletAdapter\", signer };\n return this;\n }\n\n privyWalletId(\n walletId: string,\n walletAddress?: string\n ): LightconeClientBuilder {\n this.signingStrategyValue = { type: \"privy\", walletId, walletAddress };\n return this;\n }\n\n /** Set the initial trusted Transaction Sponsorship Capability; defaults to false. */\n transactionSponsorship(enabled: boolean): LightconeClientBuilder {\n this.transactionSponsorshipEnabledValue = enabled;\n return this;\n }\n\n rpcUrl(url: string): LightconeClientBuilder {\n this.primaryRpcUrlValue = url;\n return this;\n }\n\n /** Set a backup Solana RPC URL for automatic failover. */\n backupRpcUrl(url: string): LightconeClientBuilder {\n this.backupRpcUrlValue = url;\n return this;\n }\n\n build(): LightconeClient {\n return new LightconeClient({\n http: new LightconeHttp(this.baseUrlValue),\n wsConfig: {\n url: this.wsUrlValue,\n reconnect: true,\n maxReconnectAttempts: 10,\n baseReconnectDelayMs: 1_000,\n pingIntervalMs: 30_000,\n pongTimeoutMs: 10_000,\n },\n programId: this.programIdValue,\n depositSource: this.depositSourceValue,\n signingStrategy: this.signingStrategyValue,\n transactionSponsorshipEnabled: this.transactionSponsorshipEnabledValue,\n primaryConnection: this.primaryRpcUrlValue\n ? new Connection(this.primaryRpcUrlValue, { commitment: \"confirmed\" })\n : undefined,\n backupConnection: this.backupRpcUrlValue\n ? new Connection(this.backupRpcUrlValue, { commitment: \"confirmed\" })\n : undefined,\n authCredentials: this.authCredentials,\n });\n }\n}\n"]}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Connection, type PublicKey } from "@solana/web3.js";
|
|
2
2
|
import type { LightconeHttp } from "./http";
|
|
3
|
+
import type { AuthCredentials } from "./auth";
|
|
3
4
|
import type { DepositSource, OrderbookRules } from "./shared";
|
|
4
|
-
import type
|
|
5
|
+
import { type SigningStrategy } from "./shared/signing";
|
|
5
6
|
import { type RpcFailoverState } from "./rpcFailover";
|
|
6
7
|
export interface ClientContext {
|
|
7
8
|
readonly http: LightconeHttp;
|
|
@@ -11,6 +12,10 @@ export interface ClientContext {
|
|
|
11
12
|
readonly rpcFailoverState: RpcFailoverState;
|
|
12
13
|
readonly depositSource: DepositSource;
|
|
13
14
|
readonly signingStrategy?: SigningStrategy;
|
|
15
|
+
/** Trusted application assertion that an external sponsor pays fees; omission is false. */
|
|
16
|
+
readonly transactionSponsorshipEnabled?: boolean;
|
|
17
|
+
/** Optional cached identity for auth-bound operations; callers must check expiry. */
|
|
18
|
+
readonly authCredentials?: AuthCredentials;
|
|
14
19
|
orderNonce?(): number | undefined;
|
|
15
20
|
setOrderNonce?(nonce: number): void;
|
|
16
21
|
readonly orderbookRulesCache?: Map<string, Promise<OrderbookRules>>;
|
|
@@ -28,6 +33,8 @@ export declare function requireSigningStrategy(ctx: ClientContext): SigningStrat
|
|
|
28
33
|
* accepts the transaction — inclusion is not awaited. When follow-up work
|
|
29
34
|
* depends on this transaction's on-chain effects, use
|
|
30
35
|
* {@link signAndSubmitTxConfirmed} instead.
|
|
36
|
+
* Unsponsored submission checks exact fee funding before signing when both
|
|
37
|
+
* required RPC observations are available.
|
|
31
38
|
*/
|
|
32
39
|
export declare function signAndSubmitTx(ctx: ClientContext, tx: import("@solana/web3.js").Transaction): Promise<string>;
|
|
33
40
|
/**
|
|
@@ -56,4 +63,18 @@ export interface ConfirmedTransaction {
|
|
|
56
63
|
* both its signature and processing slot.
|
|
57
64
|
*/
|
|
58
65
|
export declare function signAndSubmitTxConfirmedWithSlot(ctx: ClientContext, tx: import("@solana/web3.js").Transaction): Promise<ConfirmedTransaction>;
|
|
66
|
+
/**
|
|
67
|
+
* Sign, submit once, and confirm a transaction whose message was fee-estimated.
|
|
68
|
+
*
|
|
69
|
+
* This function preserves the prepared blockhash. A wallet adapter may add
|
|
70
|
+
* signatures but may not replace any message field. Signed bytes are sent once to
|
|
71
|
+
* the active RPC because a transport failure may occur after acceptance.
|
|
72
|
+
* The unchanged message receives the same best-effort fee-funding preflight as an
|
|
73
|
+
* ordinary transaction before the signer runs. A sponsored external signer may
|
|
74
|
+
* differ from the declared fee payer. The caller-owned transaction is snapshotted
|
|
75
|
+
* before the first await so later caller mutation cannot change fee authority.
|
|
76
|
+
*/
|
|
77
|
+
export declare function signAndSubmitPreparedTxConfirmedWithSlot(ctx: ClientContext, tx: import("@solana/web3.js").Transaction): Promise<ConfirmedTransaction>;
|
|
78
|
+
/** @internal Submit with a strategy already validated for an identity-bound operation. */
|
|
79
|
+
export declare function signAndSubmitTxConfirmedUsingStrategy(ctx: ClientContext, tx: import("@solana/web3.js").Transaction, strategy: SigningStrategy): Promise<string>;
|
|
59
80
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,gBAAgB,EAItB,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC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