@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/prelude.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExtendPositionTokensBuilder = exports.InitPositionTokensBuilder = exports.WithdrawFromPositionBuilder = exports.RedeemWinningsBuilder = exports.WithdrawBuilder = exports.DepositBuilder = exports.OrderbookState = exports.validateAggregation = exports.normalizeAggregation = exports.isFullPrecision = exports.FULL_PRECISION = exports.aggregationsEqual = exports.aggregationKeySuffix = exports.aggregationFromFrame = exports.OrderBookValidationError = exports.ImpactDirection = exports.singleWinningOutcome = exports.isMarketResolved = exports.hasSingleWinningOutcome = exports.MarketResolutionKind = exports.Status = exports.Referrals = exports.Notifications = exports.PriceHistoryClient = exports.Trades = exports.Positions = exports.Orders = exports.Orderbooks = exports.Metrics = exports.Markets = exports.Auth = exports.Rpc = exports.LightconeClientBuilder = exports.LightconeClient = exports.programId = exports.rpcUrl = exports.wsUrl = exports.apiUrl = exports.LightconeEnv = exports.SdkError = exports.TimeInForce = exports.Side = exports.Resolution = exports.OrderUpdateType = exports.deriveOrderbookId = exports.DepositSource = exports.asPubkeyStr = exports.asOrderBookId = exports.RejectionCode = exports.ApiRejectedDetails = void 0;
|
|
4
|
-
exports.unsubscribeBooks = exports.subscribeBooks = exports.RetryPolicy = exports.MergeBuilder = exports.isUserCancellation = exports.LimitOrderEnvelope = exports.userXAccount = exports.userPrivy = exports.tradingWallet = exports.identityText = exports.displayName = exports.avatarUrl = exports.PriceHistoryState = exports.DepositPriceState = exports.TradeHistory = exports.GlobalToMarketDepositBuilder = exports.WithdrawFromGlobalBuilder = exports.DepositToGlobalBuilder = void 0;
|
|
4
|
+
exports.unsubscribeBooks = exports.subscribeBooks = exports.RetryPolicy = exports.MergeBuilder = exports.requireNativeSigningStrategy = exports.isUserCancellation = exports.LimitOrderEnvelope = exports.userXAccount = exports.userPrivy = exports.tradingWallet = exports.identityText = exports.displayName = exports.classifyRegisterPrivyConflict = exports.avatarUrl = exports.PriceHistoryState = exports.DepositPriceState = exports.TradeHistory = exports.SOL_RESERVE_WITH_EXISTING_ACCOUNT_LAMPORTS = exports.SOL_RESERVE_WITH_ACCOUNT_CREATION_LAMPORTS = exports.unwrapAllSolBalanceAvailability = exports.solBalanceAvailability = exports.nativeWithdrawSeed = exports.WRAPPED_SOL_MINT = exports.WalletDepositBalancesState = exports.GlobalToMarketDepositBuilder = exports.WithdrawFromGlobalBuilder = exports.DepositToGlobalBuilder = void 0;
|
|
5
5
|
var shared_1 = require("./shared");
|
|
6
6
|
Object.defineProperty(exports, "ApiRejectedDetails", { enumerable: true, get: function () { return shared_1.ApiRejectedDetails; } });
|
|
7
7
|
Object.defineProperty(exports, "RejectionCode", { enumerable: true, get: function () { return shared_1.RejectionCode; } });
|
|
@@ -75,6 +75,13 @@ Object.defineProperty(exports, "ExtendPositionTokensBuilder", { enumerable: true
|
|
|
75
75
|
Object.defineProperty(exports, "DepositToGlobalBuilder", { enumerable: true, get: function () { return position_2.DepositToGlobalBuilder; } });
|
|
76
76
|
Object.defineProperty(exports, "WithdrawFromGlobalBuilder", { enumerable: true, get: function () { return position_2.WithdrawFromGlobalBuilder; } });
|
|
77
77
|
Object.defineProperty(exports, "GlobalToMarketDepositBuilder", { enumerable: true, get: function () { return position_2.GlobalToMarketDepositBuilder; } });
|
|
78
|
+
Object.defineProperty(exports, "WalletDepositBalancesState", { enumerable: true, get: function () { return position_2.WalletDepositBalancesState; } });
|
|
79
|
+
Object.defineProperty(exports, "WRAPPED_SOL_MINT", { enumerable: true, get: function () { return position_2.WRAPPED_SOL_MINT; } });
|
|
80
|
+
Object.defineProperty(exports, "nativeWithdrawSeed", { enumerable: true, get: function () { return position_2.nativeWithdrawSeed; } });
|
|
81
|
+
Object.defineProperty(exports, "solBalanceAvailability", { enumerable: true, get: function () { return position_2.solBalanceAvailability; } });
|
|
82
|
+
Object.defineProperty(exports, "unwrapAllSolBalanceAvailability", { enumerable: true, get: function () { return position_2.unwrapAllSolBalanceAvailability; } });
|
|
83
|
+
Object.defineProperty(exports, "SOL_RESERVE_WITH_ACCOUNT_CREATION_LAMPORTS", { enumerable: true, get: function () { return position_2.SOL_RESERVE_WITH_ACCOUNT_CREATION_LAMPORTS; } });
|
|
84
|
+
Object.defineProperty(exports, "SOL_RESERVE_WITH_EXISTING_ACCOUNT_LAMPORTS", { enumerable: true, get: function () { return position_2.SOL_RESERVE_WITH_EXISTING_ACCOUNT_LAMPORTS; } });
|
|
78
85
|
var state_2 = require("./domain/trade/state");
|
|
79
86
|
Object.defineProperty(exports, "TradeHistory", { enumerable: true, get: function () { return state_2.TradeHistory; } });
|
|
80
87
|
var price_history_2 = require("./domain/price_history");
|
|
@@ -82,6 +89,7 @@ Object.defineProperty(exports, "DepositPriceState", { enumerable: true, get: fun
|
|
|
82
89
|
Object.defineProperty(exports, "PriceHistoryState", { enumerable: true, get: function () { return price_history_2.PriceHistoryState; } });
|
|
83
90
|
var auth_2 = require("./auth");
|
|
84
91
|
Object.defineProperty(exports, "avatarUrl", { enumerable: true, get: function () { return auth_2.avatarUrl; } });
|
|
92
|
+
Object.defineProperty(exports, "classifyRegisterPrivyConflict", { enumerable: true, get: function () { return auth_2.classifyRegisterPrivyConflict; } });
|
|
85
93
|
Object.defineProperty(exports, "displayName", { enumerable: true, get: function () { return auth_2.displayName; } });
|
|
86
94
|
Object.defineProperty(exports, "identityText", { enumerable: true, get: function () { return auth_2.identityText; } });
|
|
87
95
|
Object.defineProperty(exports, "tradingWallet", { enumerable: true, get: function () { return auth_2.tradingWallet; } });
|
|
@@ -91,6 +99,7 @@ var program_1 = require("./program");
|
|
|
91
99
|
Object.defineProperty(exports, "LimitOrderEnvelope", { enumerable: true, get: function () { return program_1.LimitOrderEnvelope; } });
|
|
92
100
|
var signing_1 = require("./shared/signing");
|
|
93
101
|
Object.defineProperty(exports, "isUserCancellation", { enumerable: true, get: function () { return signing_1.isUserCancellation; } });
|
|
102
|
+
Object.defineProperty(exports, "requireNativeSigningStrategy", { enumerable: true, get: function () { return signing_1.requireNativeSigningStrategy; } });
|
|
94
103
|
var position_3 = require("./domain/position");
|
|
95
104
|
Object.defineProperty(exports, "MergeBuilder", { enumerable: true, get: function () { return position_3.MergeBuilder; } });
|
|
96
105
|
var http_1 = require("./http");
|
package/dist/prelude.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prelude.js","sourceRoot":"","sources":["../src/prelude.ts"],"names":[],"mappings":";;;;AAAA,mCAekB;AAdhB,4GAAA,kBAAkB,OAAA;AAClB,uGAAA,aAAa,OAAA;AACb,uGAAA,aAAa,OAAA;AACb,qGAAA,WAAW,OAAA;AACX,uGAAA,aAAa,OAAA;AACb,2GAAA,iBAAiB,OAAA;AACjB,yGAAA,eAAe,OAAA;AACf,oGAAA,UAAU,OAAA;AACV,8FAAA,IAAI,OAAA;AACJ,qGAAA,WAAW,OAAA;AAOb,iCAAmC;AAA1B,iGAAA,QAAQ,OAAA;AACjB,6BAAuE;AAA9D,mGAAA,YAAY,OAAA;AAAE,6FAAA,MAAM,OAAA;AAAE,4FAAA,KAAK,OAAA;AAAE,6FAAA,MAAM,OAAA;AAAE,gGAAA,SAAS,OAAA;AAEvD,mCAGkB;AAFhB,yGAAA,eAAe,OAAA;AACf,gHAAA,sBAAsB,OAAA;AAGxB,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AAGZ,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,0CAA0C;AAAjC,iGAAA,OAAO,OAAA;AAChB,4CAA2C;AAAlC,kGAAA,OAAO,OAAA;AAChB,gDAAgD;AAAvC,uGAAA,UAAU,OAAA;AACnB,wCAAwC;AAA/B,+FAAA,MAAM,OAAA;AACf,8CAA8C;AAArC,qGAAA,SAAS,OAAA;AAClB,wCAAwC;AAA/B,+FAAA,MAAM,OAAA;AACf,wDAA4D;AAAnD,mHA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AAA;AAiBd,+BAIgB;AAHd,mGAAA,WAAW,OAAA;AAeb,2BAAwD;AAA/C,oGAAA,cAAc,OAAA;AAAE,sGAAA,gBAAgB,OAAA","sourcesContent":["export {\n ApiRejectedDetails,\n RejectionCode,\n asOrderBookId,\n asPubkeyStr,\n DepositSource,\n deriveOrderbookId,\n OrderUpdateType,\n Resolution,\n Side,\n TimeInForce,\n type ApiResponse,\n type OrderBookId,\n type PubkeyStr,\n type SubmitOrderRequest,\n} from \"./shared\";\n\nexport { SdkError } from \"./error\";\nexport { LightconeEnv, apiUrl, wsUrl, rpcUrl, programId } from \"./env\";\n\nexport {\n LightconeClient,\n LightconeClientBuilder,\n} from \"./client\";\n\nexport { Rpc } from \"./rpc\";\nexport type { ClientContext } from \"./context\";\n\nexport { Auth } from \"./auth\";\nexport { Markets } from \"./domain/market\";\nexport { Metrics } from \"./domain/metrics\";\nexport { Orderbooks } from \"./domain/orderbook\";\nexport { Orders } from \"./domain/order\";\nexport { Positions } from \"./domain/position\";\nexport { Trades } from \"./domain/trade\";\nexport { PriceHistoryClient } from \"./domain/price_history\";\nexport { Notifications } from \"./domain/notification\";\nexport { Referrals } from \"./domain/referral\";\n\nexport type {\n CategoriesMetrics,\n CategoryVolumeMetrics,\n DepositTokenVolumeHistory,\n DepositTokenVolumeHistoryPoint,\n DepositTokenVolumeHistoryPointToken,\n DepositTokenVolumeHistoryQuery,\n DepositTokenVolumeHistoryToken,\n DepositTokenVolumeMetrics,\n DepositTokensMetrics,\n HistoryPoint,\n Leaderboard,\n LeaderboardEntry,\n MarketDetailMetrics,\n MarketOrderbookVolumeMetrics,\n MarketVolumeMetrics,\n MarketsMetrics,\n MetricsHistory,\n MetricsHistoryQuery,\n OpenInterestHistory,\n OpenInterestHistoryDepositAsset,\n OpenInterestHistoryPoint,\n OpenInterestHistoryPointDepositAsset,\n OpenInterestHistoryQuery,\n OrderbookTickerEntry,\n OrderbookTickersResponse,\n OrderbookVolumeMetrics,\n OutcomeVolumeMetrics,\n PlatformMetrics,\n UniqueTradersHistory,\n UniqueTradersHistoryPoint,\n UniqueTradersHistoryQuery,\n UniqueTradersHistoryScope,\n} from \"./domain/metrics\";\n\nexport type {\n FaucetRequest,\n FaucetResponse,\n FaucetToken,\n} from \"./domain/faucet\";\n\nexport type {\n ConditionalTokenResponse,\n DepositAssetResponse,\n DepositMintsResponse,\n MarketResolutionPayout,\n MarketResolutionResponse,\n} from \"./domain/market/wire\";\n\nexport {\n Status,\n MarketResolutionKind,\n hasSingleWinningOutcome,\n isMarketResolved,\n singleWinningOutcome,\n} from \"./domain/market\";\n\nexport type {\n Market,\n MarketResolutionContainer,\n Outcome,\n ConditionalToken,\n DepositAsset,\n GlobalDepositAsset,\n Token,\n TokenMetadata,\n ValidatedTokens,\n} from \"./domain/market\";\n\nexport type {\n OrderBook,\n OrderBookPair,\n OrderbookDepthDecimals,\n OutcomeImpact,\n TickerData,\n WsBookLevel,\n} from \"./domain/orderbook\";\nexport { ImpactDirection, OrderBookValidationError } from \"./domain/orderbook\";\nexport type { BookAggregation } from \"./domain/orderbook/aggregation\";\nexport {\n aggregationFromFrame,\n aggregationKeySuffix,\n aggregationsEqual,\n FULL_PRECISION,\n isFullPrecision,\n normalizeAggregation,\n validateAggregation,\n} from \"./domain/orderbook/aggregation\";\nexport { OrderbookState } from \"./domain/orderbook/state\";\nexport type {\n OrderbookApplyResult,\n OrderbookRefreshReason,\n} from \"./domain/orderbook/state\";\n\nexport type {\n CancelAllBody,\n CancelAllSuccess,\n CancelBody,\n CancelSuccess,\n ConditionalBalance,\n FillInfo,\n GlobalDepositUpdate,\n NonceUpdate,\n LimitOrder,\n OrderEvent,\n OrderStatus,\n OrderType,\n SubmitOrderResponse,\n SubmitOrderStatus,\n UserBalanceUpdate,\n UserDepositAssetBalance,\n UserMarketBalance,\n UserOutcomeBalance,\n UserSnapshotOrder,\n UserOrdersResponse,\n UserUpdate,\n} from \"./domain/order\";\nexport type { UserOpenLimitOrders } from \"./domain/order/state\";\n\nexport type {\n Portfolio,\n Position,\n PositionOutcome,\n WalletHolding,\n TokenBalance,\n TokenBalanceComputedBase,\n TokenBalanceTokenType,\n DepositAssetMetadata,\n DepositTokenBalance,\n DepositTokenBalancesSnapshot,\n} from \"./domain/position\";\n\nexport {\n DepositBuilder,\n WithdrawBuilder,\n RedeemWinningsBuilder,\n WithdrawFromPositionBuilder,\n InitPositionTokensBuilder,\n ExtendPositionTokensBuilder,\n DepositToGlobalBuilder,\n WithdrawFromGlobalBuilder,\n GlobalToMarketDepositBuilder,\n} from \"./domain/position\";\n\nexport type { Trade, WsTrade } from \"./domain/trade\";\nexport { TradeHistory } from \"./domain/trade/state\";\nexport type {\n DepositPrice,\n DepositPriceCandleUpdate,\n DepositPriceHistoryQuery,\n DepositPriceKey,\n DepositPriceSnapshot,\n DepositPriceTick,\n DepositTokenCandle,\n DepositTokenPriceHistoryResponse,\n DepositAssetPriceEvent,\n DepositAssetPriceSnapshot,\n DepositAssetPriceTick,\n DepositAssetPricesSnapshotResponse,\n LineData,\n MidpointPriceCandle,\n OhlcvPriceCandle,\n OrderbookPriceHistoryQuery,\n OrderbookPriceHistoryResponse,\n PriceCandle,\n PriceHistory,\n PriceHistoryRestResponse,\n PriceHistorySnapshot,\n PriceHistoryUpdate,\n} from \"./domain/price_history\";\nexport { DepositPriceState, PriceHistoryState } from \"./domain/price_history\";\n\nexport type {\n AuthCredentials,\n AuthMethod,\n ChainType,\n GoogleAccountData,\n PrivyEmbeddedWallet,\n SessionResponse,\n User,\n UserIdentity,\n UserPrivyData,\n XAccountData,\n} from \"./auth\";\nexport { avatarUrl, displayName, identityText, tradingWallet, userPrivy, userXAccount } from \"./auth\";\n\nexport {\n LimitOrderEnvelope,\n type OrderEnvelope,\n type OrderPayload,\n} from \"./program\";\n\nexport type {\n ExportWalletRequest,\n ExportWalletResponse,\n PrivyOrderEnvelope,\n SignAndSendOrderRequest,\n SignAndSendTxRequest,\n SignAndSendTxResponse,\n} from \"./privy\";\n\nexport {\n isUserCancellation,\n type ExternalSigner,\n type SigningStrategy,\n} from \"./shared/signing\";\n\nexport {\n MergeBuilder,\n} from \"./domain/position\";\n\nexport type {\n Notification,\n NotificationKind,\n MarketResolvedData,\n OrderFilledData,\n MarketData,\n} from \"./domain/notification\";\n\nexport type {\n RedeemResult,\n ReferralCodeInfo,\n ReferralStatus,\n} from \"./domain/referral\";\n\nexport {\n RetryPolicy,\n type CredentialRestorer,\n type RetryConfig,\n} from \"./http\";\n\nexport type {\n IWsClient,\n Kind,\n MessageIn,\n MessageOut,\n SubscribeParams,\n UnsubscribeParams,\n WsConfig,\n WsEvent,\n} from \"./ws\";\nexport { subscribeBooks, unsubscribeBooks } from \"./ws\";\n\nexport type AuthClient = import(\"./auth\").Auth;\nexport type MarketsClient = import(\"./domain/market\").Markets;\nexport type MarketsResult = import(\"./domain/market\").MarketsResult;\nexport type GlobalDepositAssetsResult = import(\"./domain/market\").GlobalDepositAssetsResult;\nexport type FavoriteMarkets = import(\"./domain/market\").FavoriteMarkets;\nexport type FavoriteMarketUpdate = import(\"./domain/market\").FavoriteMarketUpdate;\nexport type MetricsClient = import(\"./domain/metrics\").Metrics;\nexport type OrderbooksClient = import(\"./domain/orderbook\").Orderbooks;\nexport type OrdersClient = import(\"./domain/order\").Orders;\nexport type PositionsClient = import(\"./domain/position\").Positions;\nexport type TradesClient = import(\"./domain/trade\").Trades;\nexport type PriceHistorySubClient = import(\"./domain/price_history\").PriceHistoryClient;\nexport type NotificationsClient = import(\"./domain/notification\").Notifications;\nexport type ReferralsClient = import(\"./domain/referral\").Referrals;\nexport type RpcClient = import(\"./rpc\").Rpc;\n"]}
|
|
1
|
+
{"version":3,"file":"prelude.js","sourceRoot":"","sources":["../src/prelude.ts"],"names":[],"mappings":";;;;AAAA,mCAekB;AAdhB,4GAAA,kBAAkB,OAAA;AAClB,uGAAA,aAAa,OAAA;AACb,uGAAA,aAAa,OAAA;AACb,qGAAA,WAAW,OAAA;AACX,uGAAA,aAAa,OAAA;AACb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,mBAAmB,OAAA;AAErB,kDAA0D;AAAjD,uGAAA,cAAc,OAAA;AAyDvB,8CAiB2B;AAhBzB,0GAAA,cAAc,OAAA;AACd,2GAAA,eAAe,OAAA;AACf,iHAAA,qBAAqB,OAAA;AACrB,uHAAA,2BAA2B,OAAA;AAC3B,qHAAA,yBAAyB,OAAA;AACzB,uHAAA,2BAA2B,OAAA;AAC3B,kHAAA,sBAAsB,OAAA;AACtB,qHAAA,yBAAyB,OAAA;AACzB,wHAAA,4BAA4B,OAAA;AAC5B,sHAAA,0BAA0B,OAAA;AAC1B,4GAAA,gBAAgB,OAAA;AAChB,8GAAA,kBAAkB,OAAA;AAClB,kHAAA,sBAAsB,OAAA;AACtB,2HAAA,+BAA+B,OAAA;AAC/B,sIAAA,0CAA0C,OAAA;AAC1C,sIAAA,0CAA0C,OAAA;AAI5C,8CAAoD;AAA3C,qGAAA,YAAY,OAAA;AAyBrB,wDAA8E;AAArE,kHAAA,iBAAiB,OAAA;AAAE,kHAAA,iBAAiB,OAAA;AAqB7C,+BAQgB;AAPd,iGAAA,SAAS,OAAA;AACT,qHAAA,6BAA6B,OAAA;AAC7B,mGAAA,WAAW,OAAA;AACX,oGAAA,YAAY,OAAA;AACZ,qGAAA,aAAa,OAAA;AACb,iGAAA,SAAS,OAAA;AACT,oGAAA,YAAY,OAAA;AAGd,qCAImB;AAHjB,6GAAA,kBAAkB,OAAA;AAcpB,4CAM0B;AALxB,6GAAA,kBAAkB,OAAA;AAClB,uHAAA,4BAA4B,OAAA;AAM9B,8CAE2B;AADzB,wGAAA,YAAY,OAAA;AAiBd,+BAIgB;AAHd,mGAAA,WAAW,OAAA;AAeb,2BAAwD;AAA/C,oGAAA,cAAc,OAAA;AAAE,sGAAA,gBAAgB,OAAA","sourcesContent":["export {\n ApiRejectedDetails,\n RejectionCode,\n asOrderBookId,\n asPubkeyStr,\n DepositSource,\n deriveOrderbookId,\n OrderUpdateType,\n Resolution,\n Side,\n TimeInForce,\n type ApiResponse,\n type OrderBookId,\n type PubkeyStr,\n type SubmitOrderRequest,\n} from \"./shared\";\n\nexport { SdkError } from \"./error\";\nexport { LightconeEnv, apiUrl, wsUrl, rpcUrl, programId } from \"./env\";\n\nexport {\n LightconeClient,\n LightconeClientBuilder,\n} from \"./client\";\n\nexport { Rpc } from \"./rpc\";\nexport type { CanonicalWsolAccountInfo } from \"./rpc\";\nexport type { ClientContext } from \"./context\";\n\nexport { Auth } from \"./auth\";\nexport { Markets } from \"./domain/market\";\nexport { Metrics } from \"./domain/metrics\";\nexport { Orderbooks } from \"./domain/orderbook\";\nexport { Orders } from \"./domain/order\";\nexport { Positions } from \"./domain/position\";\nexport { Trades } from \"./domain/trade\";\nexport { PriceHistoryClient } from \"./domain/price_history\";\nexport { Notifications } from \"./domain/notification\";\nexport { Referrals } from \"./domain/referral\";\n\nexport type {\n CategoriesMetrics,\n CategoryVolumeMetrics,\n DepositTokenVolumeHistory,\n DepositTokenVolumeHistoryPoint,\n DepositTokenVolumeHistoryPointToken,\n DepositTokenVolumeHistoryQuery,\n DepositTokenVolumeHistoryToken,\n DepositTokenVolumeMetrics,\n DepositTokensMetrics,\n HistoryPoint,\n Leaderboard,\n LeaderboardEntry,\n MarketDetailMetrics,\n MarketOrderbookVolumeMetrics,\n MarketVolumeMetrics,\n MarketsMetrics,\n MetricsHistory,\n MetricsHistoryQuery,\n OpenInterestHistory,\n OpenInterestHistoryDepositAsset,\n OpenInterestHistoryPoint,\n OpenInterestHistoryPointDepositAsset,\n OpenInterestHistoryQuery,\n OrderbookTickerEntry,\n OrderbookTickersResponse,\n OrderbookVolumeMetrics,\n OutcomeVolumeMetrics,\n PlatformMetrics,\n UniqueTradersHistory,\n UniqueTradersHistoryPoint,\n UniqueTradersHistoryQuery,\n UniqueTradersHistoryScope,\n} from \"./domain/metrics\";\n\nexport type {\n FaucetRequest,\n FaucetResponse,\n FaucetToken,\n} from \"./domain/faucet\";\n\nexport type {\n ConditionalTokenResponse,\n DepositAssetResponse,\n DepositMintsResponse,\n MarketResolutionPayout,\n MarketResolutionResponse,\n} from \"./domain/market/wire\";\n\nexport {\n Status,\n MarketResolutionKind,\n hasSingleWinningOutcome,\n isMarketResolved,\n singleWinningOutcome,\n} from \"./domain/market\";\n\nexport type {\n Market,\n MarketResolutionContainer,\n Outcome,\n ConditionalToken,\n DepositAsset,\n GlobalDepositAsset,\n Token,\n TokenMetadata,\n ValidatedTokens,\n} from \"./domain/market\";\n\nexport type {\n OrderBook,\n OrderBookPair,\n OrderbookDepthDecimals,\n OutcomeImpact,\n TickerData,\n WsBookLevel,\n} from \"./domain/orderbook\";\nexport { ImpactDirection, OrderBookValidationError } from \"./domain/orderbook\";\nexport type { BookAggregation } from \"./domain/orderbook/aggregation\";\nexport {\n aggregationFromFrame,\n aggregationKeySuffix,\n aggregationsEqual,\n FULL_PRECISION,\n isFullPrecision,\n normalizeAggregation,\n validateAggregation,\n} from \"./domain/orderbook/aggregation\";\nexport { OrderbookState } from \"./domain/orderbook/state\";\nexport type {\n OrderbookApplyResult,\n OrderbookRefreshReason,\n} from \"./domain/orderbook/state\";\n\nexport type {\n CancelAllBody,\n CancelAllSuccess,\n CancelBody,\n CancelSuccess,\n ConditionalBalance,\n FillInfo,\n GlobalDepositUpdate,\n NonceUpdate,\n LimitOrder,\n OrderEvent,\n OrderStatus,\n OrderType,\n SubmitOrderResponse,\n SubmitOrderStatus,\n UserBalanceUpdate,\n UserDepositAssetBalance,\n UserMarketBalance,\n UserOutcomeBalance,\n UserSnapshotOrder,\n UserOrdersResponse,\n UserUpdate,\n} from \"./domain/order\";\nexport type { UserOpenLimitOrders } from \"./domain/order/state\";\n\nexport type {\n Portfolio,\n Position,\n PositionOutcome,\n WalletHolding,\n TokenBalance,\n TokenBalanceComputedBase,\n TokenBalanceTokenType,\n DepositAssetMetadata,\n DepositTokenBalance,\n DepositTokenBalancesSnapshot,\n WalletDepositBalanceSnapshot,\n WalletDepositBalanceStatus,\n WalletDepositBalanceStatusEvent,\n WalletDepositBalancesApplyResult,\n WalletDepositBalancesEvent,\n WalletDepositBalanceUpdate,\n WalletNativeSolBalanceUpdate,\n SolActionCosts,\n SolActionKind,\n SolActionPlan,\n SolBalanceAvailability,\n SolBalanceComponents,\n SolComponentDelta,\n} from \"./domain/position\";\n\nexport {\n DepositBuilder,\n WithdrawBuilder,\n RedeemWinningsBuilder,\n WithdrawFromPositionBuilder,\n InitPositionTokensBuilder,\n ExtendPositionTokensBuilder,\n DepositToGlobalBuilder,\n WithdrawFromGlobalBuilder,\n GlobalToMarketDepositBuilder,\n WalletDepositBalancesState,\n WRAPPED_SOL_MINT,\n nativeWithdrawSeed,\n solBalanceAvailability,\n unwrapAllSolBalanceAvailability,\n SOL_RESERVE_WITH_ACCOUNT_CREATION_LAMPORTS,\n SOL_RESERVE_WITH_EXISTING_ACCOUNT_LAMPORTS,\n} from \"./domain/position\";\n\nexport type { Trade, WsTrade } from \"./domain/trade\";\nexport { TradeHistory } from \"./domain/trade/state\";\nexport type {\n DepositPrice,\n DepositPriceCandleUpdate,\n DepositPriceHistoryQuery,\n DepositPriceKey,\n DepositPriceSnapshot,\n DepositPriceTick,\n DepositTokenCandle,\n DepositTokenPriceHistoryResponse,\n DepositAssetPriceEvent,\n DepositAssetPriceSnapshot,\n DepositAssetPriceTick,\n DepositAssetPricesSnapshotResponse,\n LineData,\n MidpointPriceCandle,\n OhlcvPriceCandle,\n OrderbookPriceHistoryQuery,\n OrderbookPriceHistoryResponse,\n PriceCandle,\n PriceHistory,\n PriceHistoryRestResponse,\n PriceHistorySnapshot,\n PriceHistoryUpdate,\n} from \"./domain/price_history\";\nexport { DepositPriceState, PriceHistoryState } from \"./domain/price_history\";\n\nexport type {\n AuthCredentials,\n AuthMethod,\n ChainType,\n EmailAccountData,\n GoogleAccountData,\n LinkedIdentity,\n LinkedIdentitySelector,\n LinkedIdentityType,\n MaxSlippagePreferenceBody,\n PrivyEmbeddedWallet,\n RegisterPrivyConflict,\n RegisterPrivyRequest,\n SessionResponse,\n User,\n UserIdentity,\n UserPrivyData,\n XAccountData,\n} from \"./auth\";\nexport {\n avatarUrl,\n classifyRegisterPrivyConflict,\n displayName,\n identityText,\n tradingWallet,\n userPrivy,\n userXAccount,\n} from \"./auth\";\n\nexport {\n LimitOrderEnvelope,\n type OrderEnvelope,\n type OrderPayload,\n} from \"./program\";\n\nexport type {\n ExportWalletRequest,\n ExportWalletResponse,\n PrivyOrderEnvelope,\n SignAndSendOrderRequest,\n SignAndSendTxRequest,\n SignAndSendTxResponse,\n} from \"./privy\";\n\nexport {\n isUserCancellation,\n requireNativeSigningStrategy,\n type ExternalSigner,\n type NativeSigningStrategy,\n type SigningStrategy,\n} from \"./shared/signing\";\n\nexport {\n MergeBuilder,\n} from \"./domain/position\";\n\nexport type {\n Notification,\n NotificationKind,\n MarketResolvedData,\n OrderFilledData,\n MarketData,\n} from \"./domain/notification\";\n\nexport type {\n RedeemResult,\n ReferralCodeInfo,\n ReferralStatus,\n} from \"./domain/referral\";\n\nexport {\n RetryPolicy,\n type CredentialRestorer,\n type RetryConfig,\n} from \"./http\";\n\nexport type {\n IWsClient,\n Kind,\n MessageIn,\n MessageOut,\n SubscribeParams,\n UnsubscribeParams,\n WsConfig,\n WsEvent,\n} from \"./ws\";\nexport { subscribeBooks, unsubscribeBooks } from \"./ws\";\n\nexport type AuthClient = import(\"./auth\").Auth;\nexport type MarketsClient = import(\"./domain/market\").Markets;\nexport type MarketsResult = import(\"./domain/market\").MarketsResult;\nexport type GlobalDepositAssetsResult = import(\"./domain/market\").GlobalDepositAssetsResult;\nexport type FavoriteMarkets = import(\"./domain/market\").FavoriteMarkets;\nexport type FavoriteMarketUpdate = import(\"./domain/market\").FavoriteMarketUpdate;\nexport type MetricsClient = import(\"./domain/metrics\").Metrics;\nexport type OrderbooksClient = import(\"./domain/orderbook\").Orderbooks;\nexport type OrdersClient = import(\"./domain/order\").Orders;\nexport type PositionsClient = import(\"./domain/position\").Positions;\nexport type TradesClient = import(\"./domain/trade\").Trades;\nexport type PriceHistorySubClient = import(\"./domain/price_history\").PriceHistoryClient;\nexport type NotificationsClient = import(\"./domain/notification\").Notifications;\nexport type ReferralsClient = import(\"./domain/referral\").Referrals;\nexport type RpcClient = import(\"./rpc\").Rpc;\n"]}
|
package/dist/privy/client.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ interface ClientContext {
|
|
|
6
6
|
export declare class Privy {
|
|
7
7
|
private readonly client;
|
|
8
8
|
constructor(client: ClientContext);
|
|
9
|
+
/**
|
|
10
|
+
* Forward caller-prepared transaction bytes to the Privy signing backend.
|
|
11
|
+
* This raw API does not run the shared SDK fee-funding preflight.
|
|
12
|
+
*/
|
|
9
13
|
signAndSendTx(walletId: string, base64Tx: string): Promise<SignAndSendTxResponse>;
|
|
10
14
|
signAndSendOrder(walletId: string, order: PrivyOrderEnvelope): Promise<SignAndSendOrderResponse>;
|
|
11
15
|
signAndCancelOrder(walletId: string, orderHash: string, maker: string): Promise<LimitCancelResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/privy/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,KAAK,EAEV,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAElB,wBAAwB,EAExB,qBAAqB,EAErB,wBAAwB,EAExB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAEjB,UAAU,aAAa;IACrB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,qBAAa,KAAK;IACJ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/privy/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,KAAK,EAEV,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAElB,wBAAwB,EAExB,qBAAqB,EAErB,wBAAwB,EAExB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAEjB,UAAU,aAAa;IACrB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,qBAAa,KAAK;IACJ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD;;;OAGG;IACG,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAajF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAShG,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAepG,yBAAyB,CAC7B,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,qBAAqB,CAAC;IAe3B,sBAAsB,CAC1B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,wBAAwB,CAAC;IAY9B,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAYhG"}
|
package/dist/privy/client.js
CHANGED
|
@@ -7,6 +7,10 @@ class Privy {
|
|
|
7
7
|
constructor(client) {
|
|
8
8
|
this.client = client;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Forward caller-prepared transaction bytes to the Privy signing backend.
|
|
12
|
+
* This raw API does not run the shared SDK fee-funding preflight.
|
|
13
|
+
*/
|
|
10
14
|
async signAndSendTx(walletId, base64Tx) {
|
|
11
15
|
const url = `${this.client.http.baseUrl()}/api/privy/sign_and_send_tx`;
|
|
12
16
|
const body = {
|
package/dist/privy/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/privy/client.ts"],"names":[],"mappings":";;;AAAA,kCAA0D;AAoB1D,MAAa,KAAK;IACa;IAA7B,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAEtD,KAAK,CAAC,aAAa,CAAC,QAAgB,EAAE,QAAgB;QACpD,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,6BAA6B,CAAC;QACvE,MAAM,IAAI,GAAyB;YACjC,SAAS,EAAE,QAAQ;YACnB,SAAS,EAAE,QAAQ;SACpB,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAC1B,GAAG,EACH,IAAI,EACJ,kBAAW,CAAC,IAAI,CACjB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,QAAgB,EAAE,KAAyB;QAChE,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,gCAAgC,CAAC;QAC1E,MAAM,IAAI,GAA4B;YACpC,SAAS,EAAE,QAAQ;YACnB,KAAK;SACN,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAoD,GAAG,EAAE,IAAI,EAAE,kBAAW,CAAC,IAAI,CAAC,CAAC;IAC/G,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,QAAgB,EAAE,SAAiB,EAAE,KAAa;QACzE,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,kCAAkC,CAAC;QAC5E,MAAM,IAAI,GAA8B;YACtC,SAAS,EAAE,QAAQ;YACnB,KAAK;YACL,WAAW,EAAE,OAAO;YACpB,UAAU,E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AAwB;YAChC,SAAS,EAAE,QAAQ;YACnB,oBAAoB,EAAE,kBAAkB;SACzC,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAC1B,GAAG,EACH,IAAI,EACJ,kBAAW,CAAC,IAAI,CACjB,CAAC;IACJ,CAAC;CACF;AA7FD,sBA6FC","sourcesContent":["import { RetryPolicy, type LightconeHttp } from \"../http\";\nimport type {\n ExportWalletRequest,\n ExportWalletResponse,\n LimitCancelResponse,\n PrivyOrderEnvelope,\n SignAndCancelAllRequest,\n SignAndCancelAllResponse,\n SignAndCancelOrderRequest,\n TriggerCancelResponse,\n SignAndSendOrderRequest,\n SignAndSendOrderResponse,\n SignAndSendTxRequest,\n SignAndSendTxResponse,\n} from \"./index\";\n\ninterface ClientContext {\n http: LightconeHttp;\n}\n\nexport class Privy {\n constructor(private readonly client: ClientContext) {}\n\n /**\n * Forward caller-prepared transaction bytes to the Privy signing backend.\n * This raw API does not run the shared SDK fee-funding preflight.\n */\n async signAndSendTx(walletId: string, base64Tx: string): Promise<SignAndSendTxResponse> {\n const url = `${this.client.http.baseUrl()}/api/privy/sign_and_send_tx`;\n const body: SignAndSendTxRequest = {\n wallet_id: walletId,\n base64_tx: base64Tx,\n };\n return this.client.http.post<SignAndSendTxResponse, SignAndSendTxRequest>(\n url,\n body,\n RetryPolicy.None\n );\n }\n\n async signAndSendOrder(walletId: string, order: PrivyOrderEnvelope): Promise<SignAndSendOrderResponse> {\n const url = `${this.client.http.baseUrl()}/api/privy/sign_and_send_order`;\n const body: SignAndSendOrderRequest = {\n wallet_id: walletId,\n order,\n };\n return this.client.http.post<SignAndSendOrderResponse, SignAndSendOrderRequest>(url, body, RetryPolicy.None);\n }\n\n async signAndCancelOrder(walletId: string, orderHash: string, maker: string): Promise<LimitCancelResponse> {\n const url = `${this.client.http.baseUrl()}/api/privy/sign_and_cancel_order`;\n const body: SignAndCancelOrderRequest = {\n wallet_id: walletId,\n maker,\n cancel_type: \"limit\",\n order_hash: orderHash,\n };\n return this.client.http.post<LimitCancelResponse, SignAndCancelOrderRequest>(\n url,\n body,\n RetryPolicy.None\n );\n }\n\n async signAndCancelTriggerOrder(\n walletId: string,\n triggerOrderId: string,\n maker: string\n ): Promise<TriggerCancelResponse> {\n const url = `${this.client.http.baseUrl()}/api/privy/sign_and_cancel_order`;\n const body: SignAndCancelOrderRequest = {\n wallet_id: walletId,\n maker,\n cancel_type: \"trigger\",\n trigger_order_id: triggerOrderId,\n };\n return this.client.http.post<TriggerCancelResponse, SignAndCancelOrderRequest>(\n url,\n body,\n RetryPolicy.None\n );\n }\n\n async signAndCancelAllOrders(\n walletId: string,\n userPubkey: string,\n orderbookId: string,\n timestamp: number,\n salt: string\n ): Promise<SignAndCancelAllResponse> {\n const url = `${this.client.http.baseUrl()}/api/privy/sign_and_cancel_all_orders`;\n const body: SignAndCancelAllRequest = {\n wallet_id: walletId,\n user_pubkey: userPubkey,\n orderbook_id: orderbookId,\n timestamp,\n salt,\n };\n return this.client.http.post<SignAndCancelAllResponse, SignAndCancelAllRequest>(url, body, RetryPolicy.None);\n }\n\n async exportWallet(walletId: string, decodePubkeyBase64: string): Promise<ExportWalletResponse> {\n const url = `${this.client.http.baseUrl()}/api/privy/wallet/export`;\n const body: ExportWalletRequest = {\n wallet_id: walletId,\n decode_pubkey_base64: decodePubkeyBase64,\n };\n return this.client.http.post<ExportWalletResponse, ExportWalletRequest>(\n url,\n body,\n RetryPolicy.None\n );\n }\n}\n"]}
|
package/dist/rpc.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import type { Connection, PublicKey, SignatureStatus, SignatureStatusConfig } from "@solana/web3.js";
|
|
1
|
+
import type { Connection, PublicKey, SignatureStatus, SignatureStatusConfig, Transaction } from "@solana/web3.js";
|
|
2
2
|
import type { ClientContext } from "./context";
|
|
3
3
|
import type { Exchange, GlobalDepositToken } from "./program/types";
|
|
4
|
+
/**
|
|
5
|
+
* Stores exact live facts for a validated canonical Tokenkeg WSOL account.
|
|
6
|
+
*
|
|
7
|
+
* `canonicalWsolAccountInfo` returns all fields from one confirmed account read.
|
|
8
|
+
* Direct structural construction does not perform that validation.
|
|
9
|
+
*/
|
|
10
|
+
export interface CanonicalWsolAccountInfo {
|
|
11
|
+
/** Full account lamports, including native amount, rent, and direct donations. */
|
|
12
|
+
accountLamports: bigint;
|
|
13
|
+
/** Decoded SPL native-token amount in lamports. */
|
|
14
|
+
tokenAmountLamports: bigint;
|
|
15
|
+
/** Decoded native-account rent reserve in lamports. */
|
|
16
|
+
nativeReserveLamports: bigint;
|
|
17
|
+
}
|
|
4
18
|
export declare class Rpc {
|
|
5
19
|
private readonly client;
|
|
6
20
|
constructor(client: ClientContext);
|
|
@@ -25,6 +39,37 @@ export declare class Rpc {
|
|
|
25
39
|
}>;
|
|
26
40
|
/** Get the current block height at `confirmed` commitment. */
|
|
27
41
|
getBlockHeight(): Promise<number>;
|
|
42
|
+
/** Distinguish a missing account from an unavailable confirmed RPC read. */
|
|
43
|
+
accountExists(address: PublicKey): Promise<boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* Return exact confirmed facts for a wallet's canonical WSOL account.
|
|
46
|
+
*
|
|
47
|
+
* `address` must equal the supplied wallet's Tokenkeg native-mint ATA. Missing
|
|
48
|
+
* accounts return `null`. A present account must have the legacy Token Program
|
|
49
|
+
* owner, native mint, wallet authority, initialized state, native reserve, and
|
|
50
|
+
* no foreign close authority. Token amount plus native reserve must fit Solana's
|
|
51
|
+
* unsigned 64-bit range and cannot exceed the account balance. Unsafe JSON-number
|
|
52
|
+
* account lamports return an error instead of being rounded.
|
|
53
|
+
*/
|
|
54
|
+
canonicalWsolAccountInfo(address: PublicKey, wallet: PublicKey): Promise<CanonicalWsolAccountInfo | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Return whether the validated canonical WSOL account is present.
|
|
57
|
+
*
|
|
58
|
+
* This compatibility method delegates all address, owner, state, authority, and
|
|
59
|
+
* lamport checks to `canonicalWsolAccountInfo`.
|
|
60
|
+
*/
|
|
61
|
+
canonicalWsolAccountExists(address: PublicKey, wallet: PublicKey): Promise<boolean>;
|
|
62
|
+
/** Return the current rent-exempt minimum in lamports for `dataLength` account bytes. */
|
|
63
|
+
minimumBalanceForRentExemption(dataLength: number): Promise<bigint>;
|
|
64
|
+
/** Return the confirmed Native SOL Balance for `feePayer`, in lamports. */
|
|
65
|
+
balanceLamports(feePayer: PublicKey): Promise<bigint>;
|
|
66
|
+
/** Attach a fresh blockhash and return the exact message's live fee in lamports. */
|
|
67
|
+
prepareAndEstimateTransactionFee(transaction: Transaction): Promise<bigint>;
|
|
68
|
+
/**
|
|
69
|
+
* Return the prepared message's live fee in lamports without replacing its blockhash.
|
|
70
|
+
* A null RPC estimate fails closed rather than becoming a zero fee.
|
|
71
|
+
*/
|
|
72
|
+
estimatePreparedTransactionFee(transaction: Transaction): Promise<bigint>;
|
|
28
73
|
/**
|
|
29
74
|
* Get the statuses of recently submitted transactions.
|
|
30
75
|
*
|
package/dist/rpc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,eAAe,EACf,qBAAqB,
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,eAAe,EACf,qBAAqB,EACrB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAUzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAc/C,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAkCpE;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,kFAAkF;IAClF,eAAe,EAAE,MAAM,CAAC;IACxB,mDAAmD;IACnD,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AAU,EAAE,MAAM,EAAE,EACpB,MAAM,CAAC,EAAE,qBAAqB,GAC7B,OAAO,CAAC,CAAC,eAAe,GAAG,IAAI,CAAC,EAAE,CAAC;IAOtC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,oBAAoB,EAAE,MAAM,GAAG,IAAI,GAClC,OAAO,CAAC,IAAI,CAAC;IAIhB;;;OAGG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,oBAAoB,EAAE,MAAM,GAAG,IAAI,GAClC,OAAO,CAAC,eAAe,CAAC;IA4FrB,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC;IAYhC,qBAAqB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAa1E"}
|
package/dist/rpc.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Rpc = void 0;
|
|
4
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
4
5
|
const context_1 = require("./context");
|
|
5
6
|
const error_1 = require("./error");
|
|
6
7
|
const rpcFailover_1 = require("./rpcFailover");
|
|
@@ -23,6 +24,15 @@ const MAX_CONSECUTIVE_POLL_FAILURES = 3;
|
|
|
23
24
|
* declared — a single reading can come from a forward-skewed RPC node.
|
|
24
25
|
*/
|
|
25
26
|
const EXPIRY_HEIGHT_SAMPLES = 2;
|
|
27
|
+
/** Largest lamport value that fits Solana's unsigned 64-bit account fields. */
|
|
28
|
+
const MAX_SOLANA_LAMPORTS = 0xffffffffffffffffn;
|
|
29
|
+
/** Convert a JSON number only when it still represents exact lamports. */
|
|
30
|
+
function rpcLamports(value, label) {
|
|
31
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
32
|
+
throw error_1.SdkError.validation(`${label} must be a non-negative safe integer`);
|
|
33
|
+
}
|
|
34
|
+
return BigInt(value);
|
|
35
|
+
}
|
|
26
36
|
/** True once the cluster has voted the transaction to `confirmed` or beyond. */
|
|
27
37
|
function isTransactionConfirmed(status) {
|
|
28
38
|
return (status.confirmationStatus === "confirmed" ||
|
|
@@ -65,6 +75,121 @@ class Rpc {
|
|
|
65
75
|
async getBlockHeight() {
|
|
66
76
|
return (0, context_1.connectionWithFailover)(this.client, (connection) => connection.getBlockHeight("confirmed"));
|
|
67
77
|
}
|
|
78
|
+
/** Distinguish a missing account from an unavailable confirmed RPC read. */
|
|
79
|
+
async accountExists(address) {
|
|
80
|
+
const account = await (0, context_1.connectionWithFailover)(this.client, (connection) => connection.getAccountInfo(address, "confirmed"));
|
|
81
|
+
return account !== null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Return exact confirmed facts for a wallet's canonical WSOL account.
|
|
85
|
+
*
|
|
86
|
+
* `address` must equal the supplied wallet's Tokenkeg native-mint ATA. Missing
|
|
87
|
+
* accounts return `null`. A present account must have the legacy Token Program
|
|
88
|
+
* owner, native mint, wallet authority, initialized state, native reserve, and
|
|
89
|
+
* no foreign close authority. Token amount plus native reserve must fit Solana's
|
|
90
|
+
* unsigned 64-bit range and cannot exceed the account balance. Unsafe JSON-number
|
|
91
|
+
* account lamports return an error instead of being rounded.
|
|
92
|
+
*/
|
|
93
|
+
async canonicalWsolAccountInfo(address, wallet) {
|
|
94
|
+
let canonicalAddress;
|
|
95
|
+
try {
|
|
96
|
+
canonicalAddress = (0, spl_token_1.getAssociatedTokenAddressSync)(spl_token_1.NATIVE_MINT, wallet, false, spl_token_1.TOKEN_PROGRAM_ID);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
throw error_1.SdkError.validation(`canonical WSOL address derivation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
100
|
+
}
|
|
101
|
+
if (!address.equals(canonicalAddress)) {
|
|
102
|
+
throw error_1.SdkError.validation("canonical WSOL address does not match the Trading Wallet Tokenkeg ATA");
|
|
103
|
+
}
|
|
104
|
+
const info = await (0, context_1.connectionWithFailover)(this.client, (connection) => connection.getAccountInfo(address, "confirmed"));
|
|
105
|
+
if (!info)
|
|
106
|
+
return null;
|
|
107
|
+
if (!info.owner.equals(spl_token_1.TOKEN_PROGRAM_ID) || info.data.length !== spl_token_1.ACCOUNT_SIZE) {
|
|
108
|
+
throw error_1.SdkError.validation("canonical WSOL account is not a legacy Token Program account");
|
|
109
|
+
}
|
|
110
|
+
let rawAccount;
|
|
111
|
+
try {
|
|
112
|
+
rawAccount = spl_token_1.AccountLayout.decode(info.data);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
throw error_1.SdkError.validation(`canonical WSOL token account is invalid: ${error instanceof Error ? error.message : String(error)}`);
|
|
116
|
+
}
|
|
117
|
+
if (rawAccount.state !== spl_token_1.AccountState.Initialized ||
|
|
118
|
+
(rawAccount.delegateOption !== 0 && rawAccount.delegateOption !== 1) ||
|
|
119
|
+
rawAccount.isNativeOption !== 1 ||
|
|
120
|
+
(rawAccount.closeAuthorityOption !== 0 &&
|
|
121
|
+
rawAccount.closeAuthorityOption !== 1)) {
|
|
122
|
+
throw error_1.SdkError.validation("canonical WSOL token account has incompatible state or option tags");
|
|
123
|
+
}
|
|
124
|
+
let account;
|
|
125
|
+
try {
|
|
126
|
+
account = (0, spl_token_1.unpackAccount)(address, info, spl_token_1.TOKEN_PROGRAM_ID);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
throw error_1.SdkError.validation(`canonical WSOL token account is invalid: ${error instanceof Error ? error.message : String(error)}`);
|
|
130
|
+
}
|
|
131
|
+
if (!account.mint.equals(spl_token_1.NATIVE_MINT) ||
|
|
132
|
+
!account.owner.equals(wallet) ||
|
|
133
|
+
!account.isInitialized ||
|
|
134
|
+
account.isFrozen ||
|
|
135
|
+
!account.isNative ||
|
|
136
|
+
account.rentExemptReserve === null ||
|
|
137
|
+
(account.closeAuthority !== null &&
|
|
138
|
+
!account.closeAuthority.equals(wallet))) {
|
|
139
|
+
throw error_1.SdkError.validation("canonical WSOL token account has incompatible mint, authority, or native state");
|
|
140
|
+
}
|
|
141
|
+
const accountLamports = rpcLamports(info.lamports, "canonical WSOL account lamports");
|
|
142
|
+
const accountedLamports = account.amount + account.rentExemptReserve;
|
|
143
|
+
if (accountedLamports > MAX_SOLANA_LAMPORTS ||
|
|
144
|
+
accountedLamports > accountLamports) {
|
|
145
|
+
throw error_1.SdkError.validation("canonical WSOL token amount and native reserve exceed account lamports");
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
accountLamports,
|
|
149
|
+
tokenAmountLamports: account.amount,
|
|
150
|
+
nativeReserveLamports: account.rentExemptReserve,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Return whether the validated canonical WSOL account is present.
|
|
155
|
+
*
|
|
156
|
+
* This compatibility method delegates all address, owner, state, authority, and
|
|
157
|
+
* lamport checks to `canonicalWsolAccountInfo`.
|
|
158
|
+
*/
|
|
159
|
+
async canonicalWsolAccountExists(address, wallet) {
|
|
160
|
+
return (await this.canonicalWsolAccountInfo(address, wallet)) !== null;
|
|
161
|
+
}
|
|
162
|
+
/** Return the current rent-exempt minimum in lamports for `dataLength` account bytes. */
|
|
163
|
+
async minimumBalanceForRentExemption(dataLength) {
|
|
164
|
+
const lamports = await (0, context_1.connectionWithFailover)(this.client, (connection) => connection.getMinimumBalanceForRentExemption(dataLength, "confirmed"));
|
|
165
|
+
return rpcLamports(lamports, "rent-exempt minimum");
|
|
166
|
+
}
|
|
167
|
+
/** Return the confirmed Native SOL Balance for `feePayer`, in lamports. */
|
|
168
|
+
async balanceLamports(feePayer) {
|
|
169
|
+
const balance = await (0, context_1.connectionWithFailover)(this.client, (connection) => connection.getBalance(feePayer, "confirmed"));
|
|
170
|
+
return rpcLamports(balance, "fee-payer balance");
|
|
171
|
+
}
|
|
172
|
+
/** Attach a fresh blockhash and return the exact message's live fee in lamports. */
|
|
173
|
+
async prepareAndEstimateTransactionFee(transaction) {
|
|
174
|
+
const { blockhash, lastValidBlockHeight } = await this.getLatestBlockhash();
|
|
175
|
+
transaction.recentBlockhash = blockhash;
|
|
176
|
+
transaction.lastValidBlockHeight = lastValidBlockHeight;
|
|
177
|
+
return this.estimatePreparedTransactionFee(transaction);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Return the prepared message's live fee in lamports without replacing its blockhash.
|
|
181
|
+
* A null RPC estimate fails closed rather than becoming a zero fee.
|
|
182
|
+
*/
|
|
183
|
+
async estimatePreparedTransactionFee(transaction) {
|
|
184
|
+
if (!transaction.recentBlockhash) {
|
|
185
|
+
throw error_1.SdkError.validation("prepared transaction is missing a recent blockhash");
|
|
186
|
+
}
|
|
187
|
+
const fee = await (0, context_1.connectionWithFailover)(this.client, (connection) => connection.getFeeForMessage(transaction.compileMessage(), "confirmed"));
|
|
188
|
+
if (fee.value === null) {
|
|
189
|
+
throw error_1.SdkError.validation("transaction fee estimate is unavailable");
|
|
190
|
+
}
|
|
191
|
+
return rpcLamports(fee.value, "transaction fee estimate");
|
|
192
|
+
}
|
|
68
193
|
/**
|
|
69
194
|
* Get the statuses of recently submitted transactions.
|
|
70
195
|
*
|
package/dist/rpc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.js","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":";;;AAOA,uCAAsE;AACtE,mCAAmC;AACnC,+CAAsC;AACtC,2CAAkD;AAClD,uCAIuB;AACvB,iDAG4B;AAG5B,6EAA6E;AAE7E,sEAAsE;AACtE,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAE1C;;;;GAIG;AACH,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,iFAAiF;AACjF,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAExC;;;GAGG;AACH,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,gFAAgF;AAChF,SAAS,sBAAsB,CAA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C;YACjB,MAAM,uBAAe,CAAC,eAAe,CACnC,+BAA+B,IAAI,CAAC,QAAQ,EAAE,EAAE,CACjD,CAAC;QACJ,CAAC;QACD,OAAO,IAAA,wCAA6B,EAAC,WAAW,CAAC,IAAc,CAAC,CAAC;IACnE,CAAC;CACF;AA5ND,kBA4NC","sourcesContent":["import type {\n Connection,\n PublicKey,\n SignatureStatus,\n SignatureStatusConfig,\n} from \"@solana/web3.js\";\nimport type { ClientContext } from \"./context\";\nimport { requireConnection, connectionWithFailover } from \"./context\";\nimport { SdkError } from \"./error\";\nimport { sleep } from \"./rpcFailover\";\nimport { ProgramSdkError } from \"./program/error\";\nimport {\n getExchangePda,\n getGlobalDepositTokenPda,\n getUserGlobalDepositPda,\n} from \"./program/pda\";\nimport {\n deserializeExchange,\n deserializeGlobalDepositToken,\n} from \"./program/accounts\";\nimport type { Exchange, GlobalDepositToken } from \"./program/types\";\n\n// ── Transaction confirmation ──────────────────────────────────────────────\n\n/** Interval between polls while awaiting transaction confirmation. */\nconst CONFIRMATION_POLL_INTERVAL_MS = 800;\n\n/**\n * Hard cap on confirmation poll iterations (~90 s at the poll interval) — a\n * backstop for when block-height expiry cannot be observed (e.g. a\n * failed-over RPC node with a skewed view of the chain).\n */\nconst MAX_CONFIRMATION_POLLS = 110;\n\n/** Consecutive failed polls tolerated before the outcome is declared unknown. */\nconst MAX_CONSECUTIVE_POLL_FAILURES = 3;\n\n/**\n * Consecutive over-bound block-height samples required before expiry may be\n * declared — a single reading can come from a forward-skewed RPC node.\n */\nconst EXPIRY_HEIGHT_SAMPLES = 2;\n\n/** True once the cluster has voted the transaction to `confirmed` or beyond. */\nfunction isTransactionConfirmed(status: SignatureStatus): boolean {\n return (\n status.confirmationStatus === \"confirmed\" ||\n status.confirmationStatus === \"finalized\"\n );\n}\n\nexport class Rpc {\n constructor(private readonly client: ClientContext) {}\n\n /**\n * Get the currently-active Connection, or throw if not configured.\n *\n * Prefer the typed methods (getExchange, etc.) — they include automatic\n * failover. Direct use of inner() bypasses the retry/failover wrapper.\n */\n inner(): Connection {\n return requireConnection(this.client);\n }\n\n // ── PDA helpers (sync, no Connection needed) ──────────────────────────\n\n getExchangePda(): PublicKey {\n return getExchangePda(this.client.programId)[0];\n }\n\n getGlobalDepositTokenPda(mint: PublicKey): PublicKey {\n return getGlobalDepositTokenPda(mint, this.client.programId)[0];\n }\n\n getUserGlobalDepositPda(user: PublicKey, mint: PublicKey): PublicKey {\n return getUserGlobalDepositPda(user, mint, this.client.programId)[0];\n }\n\n // ── Account fetchers (async, require Connection) ──────────────────────\n\n /**\n * Get the latest blockhash and its expiry height, at `confirmed`\n * commitment (pinned, not the Connection's default — matching the Rust\n * and Python SDKs).\n */\n async getLatestBlockhash(): Promise<{\n blockhash: string;\n lastValidBlockHeight: number;\n }> {\n return connectionWithFailover(this.client, (connection) =>\n connection.getLatestBlockhash(\"confirmed\")\n );\n }\n\n /** Get the current block height at `confirmed` commitment. */\n async getBlockHeight(): Promise<number> {\n return connectionWithFailover(this.client, (connection) =>\n connection.getBlockHeight(\"confirmed\")\n );\n }\n\n /**\n * Get the statuses of recently submitted transactions.\n *\n * Returns one entry per signature, in order; `null` means the cluster has\n * not seen the signature (or, unless `config.searchTransactionHistory` is\n * set, it has aged out of the recent-status cache).\n */\n async getSignatureStatuses(\n signatures: string[],\n config?: SignatureStatusConfig\n ): Promise<(SignatureStatus | null)[]> {\n const response = await connectionWithFailover(this.client, (connection) =>\n connection.getSignatureStatuses(signatures, config)\n );\n return response.value;\n }\n\n /**\n * Wait until `signature` reaches `confirmed` commitment, or throw a\n * terminal `SdkError`.\n *\n * Polls `getSignatureStatuses` (with automatic failover) until the cluster\n * reports the transaction as `confirmed` or `finalized`.\n * `lastValidBlockHeight` bounds the wait: pass the height returned\n * alongside the transaction's blockhash, or `null` when the submitted\n * transaction's blockhash cannot be proven (e.g. an external signer may\n * have replaced it) — expiry is then never reported and only the poll cap\n * ends the wait. Terminal outcomes:\n *\n * - `\"TransactionFailed\"` — the transaction landed but errored on-chain;\n * resubmitting the same transaction would fail again.\n * - `\"TransactionExpired\"` — the chain moved past `lastValidBlockHeight`\n * on consecutive height samples and a history-searching status check\n * still cannot see the signature; the transaction can never land and is\n * safe to resubmit.\n * - `\"ConfirmationTimeout\"` — the outcome could not be determined\n * (persistent RPC errors or the poll cap); check the signature on-chain\n * before resubmitting.\n */\n async confirmSignature(\n signature: string,\n lastValidBlockHeight: number | null\n ): Promise<void> {\n await this.confirmSignatureStatus(signature, lastValidBlockHeight);\n }\n\n /**\n * Same as {@link confirmSignature}, but returns the confirmed status so\n * callers can use the transaction's processing slot.\n */\n async confirmSignatureStatus(\n signature: string,\n lastValidBlockHeight: number | null\n ): Promise<SignatureStatus> {\n let consecutiveFailures = 0;\n let overBoundSamples = 0;\n\n for (let poll = 0; poll < MAX_CONFIRMATION_POLLS; poll++) {\n let statuses: (SignatureStatus | null)[] | undefined;\n try {\n statuses = await this.getSignatureStatuses([signature]);\n consecutiveFailures = 0;\n } catch {\n consecutiveFailures += 1;\n // A failed poll is a gap in expiry evidence — restart it.\n overBoundSamples = 0;\n if (consecutiveFailures >= MAX_CONSECUTIVE_POLL_FAILURES) {\n throw SdkError.confirmationTimeout(signature);\n }\n }\n\n if (statuses) {\n const status = statuses[0];\n if (status && isTransactionConfirmed(status)) {\n if (status.err) {\n throw SdkError.transactionFailed(\n signature,\n JSON.stringify(status.err)\n );\n }\n return status;\n }\n if (status) {\n // Seen but below `confirmed` — keep waiting (failed transactions\n // land in blocks like any other, so an on-chain error is also\n // reported once confirmed) and restart expiry evidence: a sighting\n // means the transaction is live, so expiry must be re-proven from\n // scratch afterwards.\n overBoundSamples = 0;\n }\n if (!status && lastValidBlockHeight !== null) {\n // Unseen — sample the block height. Expiry requires\n // EXPIRY_HEIGHT_SAMPLES consecutive over-bound samples (a single\n // reading can come from a forward-skewed node, and each sample\n // follows a fresh unseen status), then is still verified against\n // ledger history before being declared.\n try {\n const blockHeight = await this.getBlockHeight();\n overBoundSamples =\n blockHeight > lastValidBlockHeight ? overBoundSamples + 1 : 0;\n } catch {\n // Height unavailable — reset: expiry evidence must be strictly\n // consecutive over-bound readings.\n overBoundSamples = 0;\n }\n if (overBoundSamples >= EXPIRY_HEIGHT_SAMPLES) {\n // Search ledger history before declaring expiry — the\n // recent-status cache can evict landed transactions, and\n // `\"TransactionExpired\"` promises resubmit safety.\n let history: (SignatureStatus | null)[] | undefined;\n try {\n history = await this.getSignatureStatuses([signature], {\n searchTransactionHistory: true,\n });\n } catch {\n // Could not verify — keep polling until the cap.\n }\n if (history) {\n const landed = history[0];\n if (!landed) {\n throw SdkError.transactionExpired(signature);\n }\n if (isTransactionConfirmed(landed)) {\n if (landed.err) {\n throw SdkError.transactionFailed(\n signature,\n JSON.stringify(landed.err)\n );\n }\n return landed;\n }\n // Landed but below `confirmed` — keep waiting and restart\n // expiry evidence.\n overBoundSamples = 0;\n }\n }\n }\n }\n\n await sleep(CONFIRMATION_POLL_INTERVAL_MS);\n }\n\n throw SdkError.confirmationTimeout(signature);\n }\n\n async getExchange(): Promise<Exchange> {\n const pda = this.getExchangePda();\n const accountInfo = await connectionWithFailover(\n this.client,\n (connection) => connection.getAccountInfo(pda)\n );\n if (!accountInfo) {\n throw ProgramSdkError.accountNotFound(\"Exchange\");\n }\n return deserializeExchange(accountInfo.data as Buffer);\n }\n\n async getGlobalDepositToken(mint: PublicKey): Promise<GlobalDepositToken> {\n const pda = this.getGlobalDepositTokenPda(mint);\n const accountInfo = await connectionWithFailover(\n this.client,\n (connection) => connection.getAccountInfo(pda)\n );\n if (!accountInfo) {\n throw ProgramSdkError.accountNotFound(\n `GlobalDepositToken for mint ${mint.toBase58()}`\n );\n }\n return deserializeGlobalDepositToken(accountInfo.data as Buffer);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rpc.js","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":";;;AAOA,iDAQ2B;AAE3B,uCAAsE;AACtE,mCAAmC;AACnC,+CAAsC;AAC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C;QACF,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,uBAAe,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,IAAA,8BAAmB,EAAC,WAAW,CAAC,IAAc,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,IAAe;QACzC,MAAM,GAAG,GAAG,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,WAAW,GAAG,MAAM,IAAA,gCAAsB,EAC9C,IAAI,CAAC,MAAM,EACX,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,CAC/C,CAAC;QACF,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,uBAAe,CAAC,eAAe,CACnC,+BAA+B,IAAI,CAAC,QAAQ,EAAE,EAAE,CACjD,CAAC;QACJ,CAAC;QACD,OAAO,IAAA,wCAA6B,EAAC,WAAW,CAAC,IAAc,CAAC,CAAC;IACnE,CAAC;CACF;AAlYD,kBAkYC","sourcesContent":["import type {\n Connection,\n PublicKey,\n SignatureStatus,\n SignatureStatusConfig,\n Transaction,\n} from \"@solana/web3.js\";\nimport {\n AccountLayout,\n AccountState,\n ACCOUNT_SIZE,\n getAssociatedTokenAddressSync,\n NATIVE_MINT,\n TOKEN_PROGRAM_ID,\n unpackAccount,\n} from \"@solana/spl-token\";\nimport type { ClientContext } from \"./context\";\nimport { requireConnection, connectionWithFailover } from \"./context\";\nimport { SdkError } from \"./error\";\nimport { sleep } from \"./rpcFailover\";\nimport { ProgramSdkError } from \"./program/error\";\nimport {\n getExchangePda,\n getGlobalDepositTokenPda,\n getUserGlobalDepositPda,\n} from \"./program/pda\";\nimport {\n deserializeExchange,\n deserializeGlobalDepositToken,\n} from \"./program/accounts\";\nimport type { Exchange, GlobalDepositToken } from \"./program/types\";\n\n// ── Transaction confirmation ──────────────────────────────────────────────\n\n/** Interval between polls while awaiting transaction confirmation. */\nconst CONFIRMATION_POLL_INTERVAL_MS = 800;\n\n/**\n * Hard cap on confirmation poll iterations (~90 s at the poll interval) — a\n * backstop for when block-height expiry cannot be observed (e.g. a\n * failed-over RPC node with a skewed view of the chain).\n */\nconst MAX_CONFIRMATION_POLLS = 110;\n\n/** Consecutive failed polls tolerated before the outcome is declared unknown. */\nconst MAX_CONSECUTIVE_POLL_FAILURES = 3;\n\n/**\n * Consecutive over-bound block-height samples required before expiry may be\n * declared — a single reading can come from a forward-skewed RPC node.\n */\nconst EXPIRY_HEIGHT_SAMPLES = 2;\n\n/** Largest lamport value that fits Solana's unsigned 64-bit account fields. */\nconst MAX_SOLANA_LAMPORTS = 0xffff_ffff_ffff_ffffn;\n\n/** Convert a JSON number only when it still represents exact lamports. */\nfunction rpcLamports(value: number, label: string): bigint {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw SdkError.validation(`${label} must be a non-negative safe integer`);\n }\n return BigInt(value);\n}\n\n/**\n * Stores exact live facts for a validated canonical Tokenkeg WSOL account.\n *\n * `canonicalWsolAccountInfo` returns all fields from one confirmed account read.\n * Direct structural construction does not perform that validation.\n */\nexport interface CanonicalWsolAccountInfo {\n /** Full account lamports, including native amount, rent, and direct donations. */\n accountLamports: bigint;\n /** Decoded SPL native-token amount in lamports. */\n tokenAmountLamports: bigint;\n /** Decoded native-account rent reserve in lamports. */\n nativeReserveLamports: bigint;\n}\n\n/** True once the cluster has voted the transaction to `confirmed` or beyond. */\nfunction isTransactionConfirmed(status: SignatureStatus): boolean {\n return (\n status.confirmationStatus === \"confirmed\" ||\n status.confirmationStatus === \"finalized\"\n );\n}\n\nexport class Rpc {\n constructor(private readonly client: ClientContext) {}\n\n /**\n * Get the currently-active Connection, or throw if not configured.\n *\n * Prefer the typed methods (getExchange, etc.) — they include automatic\n * failover. Direct use of inner() bypasses the retry/failover wrapper.\n */\n inner(): Connection {\n return requireConnection(this.client);\n }\n\n // ── PDA helpers (sync, no Connection needed) ──────────────────────────\n\n getExchangePda(): PublicKey {\n return getExchangePda(this.client.programId)[0];\n }\n\n getGlobalDepositTokenPda(mint: PublicKey): PublicKey {\n return getGlobalDepositTokenPda(mint, this.client.programId)[0];\n }\n\n getUserGlobalDepositPda(user: PublicKey, mint: PublicKey): PublicKey {\n return getUserGlobalDepositPda(user, mint, this.client.programId)[0];\n }\n\n // ── Account fetchers (async, require Connection) ──────────────────────\n\n /**\n * Get the latest blockhash and its expiry height, at `confirmed`\n * commitment (pinned, not the Connection's default — matching the Rust\n * and Python SDKs).\n */\n async getLatestBlockhash(): Promise<{\n blockhash: string;\n lastValidBlockHeight: number;\n }> {\n return connectionWithFailover(this.client, (connection) =>\n connection.getLatestBlockhash(\"confirmed\")\n );\n }\n\n /** Get the current block height at `confirmed` commitment. */\n async getBlockHeight(): Promise<number> {\n return connectionWithFailover(this.client, (connection) =>\n connection.getBlockHeight(\"confirmed\")\n );\n }\n\n /** Distinguish a missing account from an unavailable confirmed RPC read. */\n async accountExists(address: PublicKey): Promise<boolean> {\n const account = await connectionWithFailover(this.client, (connection) =>\n connection.getAccountInfo(address, \"confirmed\")\n );\n return account !== null;\n }\n\n /**\n * Return exact confirmed facts for a wallet's canonical WSOL account.\n *\n * `address` must equal the supplied wallet's Tokenkeg native-mint ATA. Missing\n * accounts return `null`. A present account must have the legacy Token Program\n * owner, native mint, wallet authority, initialized state, native reserve, and\n * no foreign close authority. Token amount plus native reserve must fit Solana's\n * unsigned 64-bit range and cannot exceed the account balance. Unsafe JSON-number\n * account lamports return an error instead of being rounded.\n */\n async canonicalWsolAccountInfo(\n address: PublicKey,\n wallet: PublicKey\n ): Promise<CanonicalWsolAccountInfo | null> {\n let canonicalAddress: PublicKey;\n try {\n canonicalAddress = getAssociatedTokenAddressSync(\n NATIVE_MINT,\n wallet,\n false,\n TOKEN_PROGRAM_ID\n );\n } catch (error) {\n throw SdkError.validation(\n `canonical WSOL address derivation failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n if (!address.equals(canonicalAddress)) {\n throw SdkError.validation(\n \"canonical WSOL address does not match the Trading Wallet Tokenkeg ATA\"\n );\n }\n const info = await connectionWithFailover(this.client, (connection) =>\n connection.getAccountInfo(address, \"confirmed\")\n );\n if (!info) return null;\n if (!info.owner.equals(TOKEN_PROGRAM_ID) || info.data.length !== ACCOUNT_SIZE) {\n throw SdkError.validation(\n \"canonical WSOL account is not a legacy Token Program account\"\n );\n }\n\n let rawAccount;\n try {\n rawAccount = AccountLayout.decode(info.data);\n } catch (error) {\n throw SdkError.validation(\n `canonical WSOL token account is invalid: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n if (\n rawAccount.state !== AccountState.Initialized ||\n (rawAccount.delegateOption !== 0 && rawAccount.delegateOption !== 1) ||\n rawAccount.isNativeOption !== 1 ||\n (rawAccount.closeAuthorityOption !== 0 &&\n rawAccount.closeAuthorityOption !== 1)\n ) {\n throw SdkError.validation(\n \"canonical WSOL token account has incompatible state or option tags\"\n );\n }\n\n let account;\n try {\n account = unpackAccount(address, info, TOKEN_PROGRAM_ID);\n } catch (error) {\n throw SdkError.validation(\n `canonical WSOL token account is invalid: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n if (\n !account.mint.equals(NATIVE_MINT) ||\n !account.owner.equals(wallet) ||\n !account.isInitialized ||\n account.isFrozen ||\n !account.isNative ||\n account.rentExemptReserve === null ||\n (account.closeAuthority !== null &&\n !account.closeAuthority.equals(wallet))\n ) {\n throw SdkError.validation(\n \"canonical WSOL token account has incompatible mint, authority, or native state\"\n );\n }\n const accountLamports = rpcLamports(\n info.lamports,\n \"canonical WSOL account lamports\"\n );\n const accountedLamports = account.amount + account.rentExemptReserve;\n if (\n accountedLamports > MAX_SOLANA_LAMPORTS ||\n accountedLamports > accountLamports\n ) {\n throw SdkError.validation(\n \"canonical WSOL token amount and native reserve exceed account lamports\"\n );\n }\n return {\n accountLamports,\n tokenAmountLamports: account.amount,\n nativeReserveLamports: account.rentExemptReserve,\n };\n }\n\n /**\n * Return whether the validated canonical WSOL account is present.\n *\n * This compatibility method delegates all address, owner, state, authority, and\n * lamport checks to `canonicalWsolAccountInfo`.\n */\n async canonicalWsolAccountExists(\n address: PublicKey,\n wallet: PublicKey\n ): Promise<boolean> {\n return (await this.canonicalWsolAccountInfo(address, wallet)) !== null;\n }\n\n /** Return the current rent-exempt minimum in lamports for `dataLength` account bytes. */\n async minimumBalanceForRentExemption(dataLength: number): Promise<bigint> {\n const lamports = await connectionWithFailover(this.client, (connection) =>\n connection.getMinimumBalanceForRentExemption(dataLength, \"confirmed\")\n );\n return rpcLamports(lamports, \"rent-exempt minimum\");\n }\n\n /** Return the confirmed Native SOL Balance for `feePayer`, in lamports. */\n async balanceLamports(feePayer: PublicKey): Promise<bigint> {\n const balance = await connectionWithFailover(this.client, (connection) =>\n connection.getBalance(feePayer, \"confirmed\")\n );\n return rpcLamports(balance, \"fee-payer balance\");\n }\n\n /** Attach a fresh blockhash and return the exact message's live fee in lamports. */\n async prepareAndEstimateTransactionFee(transaction: Transaction): Promise<bigint> {\n const { blockhash, lastValidBlockHeight } = await this.getLatestBlockhash();\n transaction.recentBlockhash = blockhash;\n transaction.lastValidBlockHeight = lastValidBlockHeight;\n return this.estimatePreparedTransactionFee(transaction);\n }\n\n /**\n * Return the prepared message's live fee in lamports without replacing its blockhash.\n * A null RPC estimate fails closed rather than becoming a zero fee.\n */\n async estimatePreparedTransactionFee(transaction: Transaction): Promise<bigint> {\n if (!transaction.recentBlockhash) {\n throw SdkError.validation(\"prepared transaction is missing a recent blockhash\");\n }\n const fee = await connectionWithFailover(this.client, (connection) =>\n connection.getFeeForMessage(transaction.compileMessage(), \"confirmed\")\n );\n if (fee.value === null) {\n throw SdkError.validation(\"transaction fee estimate is unavailable\");\n }\n return rpcLamports(fee.value, \"transaction fee estimate\");\n }\n\n /**\n * Get the statuses of recently submitted transactions.\n *\n * Returns one entry per signature, in order; `null` means the cluster has\n * not seen the signature (or, unless `config.searchTransactionHistory` is\n * set, it has aged out of the recent-status cache).\n */\n async getSignatureStatuses(\n signatures: string[],\n config?: SignatureStatusConfig\n ): Promise<(SignatureStatus | null)[]> {\n const response = await connectionWithFailover(this.client, (connection) =>\n connection.getSignatureStatuses(signatures, config)\n );\n return response.value;\n }\n\n /**\n * Wait until `signature` reaches `confirmed` commitment, or throw a\n * terminal `SdkError`.\n *\n * Polls `getSignatureStatuses` (with automatic failover) until the cluster\n * reports the transaction as `confirmed` or `finalized`.\n * `lastValidBlockHeight` bounds the wait: pass the height returned\n * alongside the transaction's blockhash, or `null` when the submitted\n * transaction's blockhash cannot be proven (e.g. an external signer may\n * have replaced it) — expiry is then never reported and only the poll cap\n * ends the wait. Terminal outcomes:\n *\n * - `\"TransactionFailed\"` — the transaction landed but errored on-chain;\n * resubmitting the same transaction would fail again.\n * - `\"TransactionExpired\"` — the chain moved past `lastValidBlockHeight`\n * on consecutive height samples and a history-searching status check\n * still cannot see the signature; the transaction can never land and is\n * safe to resubmit.\n * - `\"ConfirmationTimeout\"` — the outcome could not be determined\n * (persistent RPC errors or the poll cap); check the signature on-chain\n * before resubmitting.\n */\n async confirmSignature(\n signature: string,\n lastValidBlockHeight: number | null\n ): Promise<void> {\n await this.confirmSignatureStatus(signature, lastValidBlockHeight);\n }\n\n /**\n * Same as {@link confirmSignature}, but returns the confirmed status so\n * callers can use the transaction's processing slot.\n */\n async confirmSignatureStatus(\n signature: string,\n lastValidBlockHeight: number | null\n ): Promise<SignatureStatus> {\n let consecutiveFailures = 0;\n let overBoundSamples = 0;\n\n for (let poll = 0; poll < MAX_CONFIRMATION_POLLS; poll++) {\n let statuses: (SignatureStatus | null)[] | undefined;\n try {\n statuses = await this.getSignatureStatuses([signature]);\n consecutiveFailures = 0;\n } catch {\n consecutiveFailures += 1;\n // A failed poll is a gap in expiry evidence — restart it.\n overBoundSamples = 0;\n if (consecutiveFailures >= MAX_CONSECUTIVE_POLL_FAILURES) {\n throw SdkError.confirmationTimeout(signature);\n }\n }\n\n if (statuses) {\n const status = statuses[0];\n if (status && isTransactionConfirmed(status)) {\n if (status.err) {\n throw SdkError.transactionFailed(\n signature,\n JSON.stringify(status.err)\n );\n }\n return status;\n }\n if (status) {\n // Seen but below `confirmed` — keep waiting (failed transactions\n // land in blocks like any other, so an on-chain error is also\n // reported once confirmed) and restart expiry evidence: a sighting\n // means the transaction is live, so expiry must be re-proven from\n // scratch afterwards.\n overBoundSamples = 0;\n }\n if (!status && lastValidBlockHeight !== null) {\n // Unseen — sample the block height. Expiry requires\n // EXPIRY_HEIGHT_SAMPLES consecutive over-bound samples (a single\n // reading can come from a forward-skewed node, and each sample\n // follows a fresh unseen status), then is still verified against\n // ledger history before being declared.\n try {\n const blockHeight = await this.getBlockHeight();\n overBoundSamples =\n blockHeight > lastValidBlockHeight ? overBoundSamples + 1 : 0;\n } catch {\n // Height unavailable — reset: expiry evidence must be strictly\n // consecutive over-bound readings.\n overBoundSamples = 0;\n }\n if (overBoundSamples >= EXPIRY_HEIGHT_SAMPLES) {\n // Search ledger history before declaring expiry — the\n // recent-status cache can evict landed transactions, and\n // `\"TransactionExpired\"` promises resubmit safety.\n let history: (SignatureStatus | null)[] | undefined;\n try {\n history = await this.getSignatureStatuses([signature], {\n searchTransactionHistory: true,\n });\n } catch {\n // Could not verify — keep polling until the cap.\n }\n if (history) {\n const landed = history[0];\n if (!landed) {\n throw SdkError.transactionExpired(signature);\n }\n if (isTransactionConfirmed(landed)) {\n if (landed.err) {\n throw SdkError.transactionFailed(\n signature,\n JSON.stringify(landed.err)\n );\n }\n return landed;\n }\n // Landed but below `confirmed` — keep waiting and restart\n // expiry evidence.\n overBoundSamples = 0;\n }\n }\n }\n }\n\n await sleep(CONFIRMATION_POLL_INTERVAL_MS);\n }\n\n throw SdkError.confirmationTimeout(signature);\n }\n\n async getExchange(): Promise<Exchange> {\n const pda = this.getExchangePda();\n const accountInfo = await connectionWithFailover(\n this.client,\n (connection) => connection.getAccountInfo(pda)\n );\n if (!accountInfo) {\n throw ProgramSdkError.accountNotFound(\"Exchange\");\n }\n return deserializeExchange(accountInfo.data as Buffer);\n }\n\n async getGlobalDepositToken(mint: PublicKey): Promise<GlobalDepositToken> {\n const pda = this.getGlobalDepositTokenPda(mint);\n const accountInfo = await connectionWithFailover(\n this.client,\n (connection) => connection.getAccountInfo(pda)\n );\n if (!accountInfo) {\n throw ProgramSdkError.accountNotFound(\n `GlobalDepositToken for mint ${mint.toBase58()}`\n );\n }\n return deserializeGlobalDepositToken(accountInfo.data as Buffer);\n }\n}\n"]}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { RejectionCode } from "./rejection";
|
|
2
|
+
import type { LinkedIdentityType } from "../auth";
|
|
3
|
+
/** Raw backend rejection details before bounded codes and methods are decoded. */
|
|
2
4
|
export interface ApiRejectedDetailsWire {
|
|
3
5
|
reason: string;
|
|
4
6
|
rejection_code?: string;
|
|
5
7
|
error_code?: string;
|
|
8
|
+
/** Primary method of a deterministic identity owner; unknown values are ignored. */
|
|
9
|
+
existing_method?: string;
|
|
6
10
|
error_log_id?: string;
|
|
7
11
|
}
|
|
8
12
|
export type ApiResponse<T> = {
|
|
@@ -12,10 +16,12 @@ export type ApiResponse<T> = {
|
|
|
12
16
|
status: "error";
|
|
13
17
|
error_details: ApiRejectedDetailsWire;
|
|
14
18
|
};
|
|
19
|
+
/** Structured rejection details with correlation and transport context. */
|
|
15
20
|
export declare class ApiRejectedDetails {
|
|
16
21
|
readonly reason: string;
|
|
17
22
|
readonly rejectionCode?: RejectionCode;
|
|
18
23
|
readonly errorCode?: string;
|
|
24
|
+
readonly existingMethod?: LinkedIdentityType;
|
|
19
25
|
readonly errorLogId?: string;
|
|
20
26
|
readonly requestId?: string;
|
|
21
27
|
/**
|
|
@@ -29,6 +35,7 @@ export declare class ApiRejectedDetails {
|
|
|
29
35
|
reason: string;
|
|
30
36
|
rejectionCode?: RejectionCode;
|
|
31
37
|
errorCode?: string;
|
|
38
|
+
existingMethod?: LinkedIdentityType;
|
|
32
39
|
errorLogId?: string;
|
|
33
40
|
requestId?: string;
|
|
34
41
|
httpStatus?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_response.d.ts","sourceRoot":"","sources":["../../src/shared/api_response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"api_response.d.ts","sourceRoot":"","sources":["../../src/shared/api_response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,kFAAkF;AAClF,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oFAAoF;IACpF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,IACrB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAC9B;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,sBAAsB,CAAA;CAAE,CAAC;AAE/D,2EAA2E;AAC3E,qBAAa,kBAAkB;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,CAAC,EAAE,kBAAkB,CAAC;IAC7C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEjB,MAAM,EAAE;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,cAAc,CAAC,EAAE,kBAAkB,CAAC;QACpC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB;IAUD,MAAM,CAAC,QAAQ,CACb,IAAI,EAAE,sBAAsB,EAC5B,SAAS,CAAC,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,GAClB,kBAAkB;IAcrB,QAAQ,IAAI,MAAM;CAmBnB;AAcD,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAaxE"}
|
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ApiRejectedDetails = void 0;
|
|
4
4
|
exports.isApiResponse = isApiResponse;
|
|
5
5
|
const rejection_1 = require("./rejection");
|
|
6
|
+
/** Structured rejection details with correlation and transport context. */
|
|
6
7
|
class ApiRejectedDetails {
|
|
7
8
|
reason;
|
|
8
9
|
rejectionCode;
|
|
9
10
|
errorCode;
|
|
11
|
+
existingMethod;
|
|
10
12
|
errorLogId;
|
|
11
13
|
requestId;
|
|
12
14
|
/**
|
|
@@ -20,6 +22,7 @@ class ApiRejectedDetails {
|
|
|
20
22
|
this.reason = params.reason;
|
|
21
23
|
this.rejectionCode = params.rejectionCode;
|
|
22
24
|
this.errorCode = params.errorCode;
|
|
25
|
+
this.existingMethod = params.existingMethod;
|
|
23
26
|
this.errorLogId = params.errorLogId;
|
|
24
27
|
this.requestId = params.requestId;
|
|
25
28
|
this.httpStatus = params.httpStatus;
|
|
@@ -31,6 +34,7 @@ class ApiRejectedDetails {
|
|
|
31
34
|
? rejection_1.RejectionCode.from(wire.rejection_code)
|
|
32
35
|
: undefined,
|
|
33
36
|
errorCode: wire.error_code,
|
|
37
|
+
existingMethod: linkedIdentityType(wire.existing_method),
|
|
34
38
|
errorLogId: wire.error_log_id,
|
|
35
39
|
requestId,
|
|
36
40
|
httpStatus,
|
|
@@ -44,6 +48,9 @@ class ApiRejectedDetails {
|
|
|
44
48
|
if (this.errorCode) {
|
|
45
49
|
lines.push(`Error Code: ${this.errorCode}`);
|
|
46
50
|
}
|
|
51
|
+
if (this.existingMethod) {
|
|
52
|
+
lines.push(`Existing Method: ${this.existingMethod}`);
|
|
53
|
+
}
|
|
47
54
|
if (this.errorLogId) {
|
|
48
55
|
lines.push(`Error Log ID: ${this.errorLogId}`);
|
|
49
56
|
}
|
|
@@ -54,6 +61,15 @@ class ApiRejectedDetails {
|
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
63
|
exports.ApiRejectedDetails = ApiRejectedDetails;
|
|
64
|
+
/** Preserve known public method guidance while tolerating future backend variants. */
|
|
65
|
+
function linkedIdentityType(value) {
|
|
66
|
+
return value === "email" ||
|
|
67
|
+
value === "google" ||
|
|
68
|
+
value === "x" ||
|
|
69
|
+
value === "wallet"
|
|
70
|
+
? value
|
|
71
|
+
: undefined;
|
|
72
|
+
}
|
|
57
73
|
function isApiResponse(value) {
|
|
58
74
|
if (typeof value !== "object" || value === null || !("status" in value)) {
|
|
59
75
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_response.js","sourceRoot":"","sources":["../../src/shared/api_response.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"api_response.js","sourceRoot":"","sources":["../../src/shared/api_response.ts"],"names":[],"mappings":";;;AAsGA,sCAaC;AAnHD,2CAA4C;AAiB5C,2EAA2E;AAC3E,MAAa,kBAAkB;IACpB,MAAM,CAAS;IACf,aAAa,CAAiB;IAC9B,SAAS,CAAU;IACnB,cAAc,CAAsB;IACpC,UAAU,CAAU;IACpB,SAAS,CAAU;IAC5B;;;;;OAKG;IACM,UAAU,CAAU;IAE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C,cAAc,EAAE,CAAC;YACxB,KAAK,CAAC,IAAI,CAAC,oBAAoB,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,KAAK,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AAtED,gDAsEC;AAED,sFAAsF;AACtF,SAAS,kBAAkB,CACzB,KAAyB;IAEzB,OAAO,KAAK,KAAK,OAAO;QACtB,KAAK,KAAK,QAAQ;QAClB,KAAK,KAAK,GAAG;QACb,KAAK,KAAK,QAAQ;QAClB,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAgB,aAAa,CAAI,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,MAAM,GAAI,KAA8B,CAAC,MAAM,CAAC;IACtD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,MAAM,IAAI,KAAK,CAAC;IACzB,CAAC;IACD,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACvB,OAAO,eAAe,IAAI,KAAK,CAAC;IAClC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { RejectionCode } from \"./rejection\";\nimport type { LinkedIdentityType } from \"../auth\";\n\n/** Raw backend rejection details before bounded codes and methods are decoded. */\nexport interface ApiRejectedDetailsWire {\n reason: string;\n rejection_code?: string;\n error_code?: string;\n /** Primary method of a deterministic identity owner; unknown values are ignored. */\n existing_method?: string;\n error_log_id?: string;\n}\n\nexport type ApiResponse<T> =\n | { status: \"success\"; body: T }\n | { status: \"error\"; error_details: ApiRejectedDetailsWire };\n\n/** Structured rejection details with correlation and transport context. */\nexport class ApiRejectedDetails {\n readonly reason: string;\n readonly rejectionCode?: RejectionCode;\n readonly errorCode?: string;\n readonly existingMethod?: LinkedIdentityType;\n readonly errorLogId?: string;\n readonly requestId?: string;\n /**\n * HTTP status of the response that carried this rejection. Set by the HTTP\n * client when the rejection rode a non-2xx response; not present in the\n * backend JSON. Lets callers classify rejections at the transport level\n * (e.g. `isUnauthorized`) without matching on backend error strings.\n */\n readonly httpStatus?: number;\n\n constructor(params: {\n reason: string;\n rejectionCode?: RejectionCode;\n errorCode?: string;\n existingMethod?: LinkedIdentityType;\n errorLogId?: string;\n requestId?: string;\n httpStatus?: number;\n }) {\n this.reason = params.reason;\n this.rejectionCode = params.rejectionCode;\n this.errorCode = params.errorCode;\n this.existingMethod = params.existingMethod;\n this.errorLogId = params.errorLogId;\n this.requestId = params.requestId;\n this.httpStatus = params.httpStatus;\n }\n\n static fromWire(\n wire: ApiRejectedDetailsWire,\n requestId?: string,\n httpStatus?: number,\n ): ApiRejectedDetails {\n return new ApiRejectedDetails({\n reason: wire.reason,\n rejectionCode: wire.rejection_code\n ? RejectionCode.from(wire.rejection_code)\n : undefined,\n errorCode: wire.error_code,\n existingMethod: linkedIdentityType(wire.existing_method),\n errorLogId: wire.error_log_id,\n requestId,\n httpStatus,\n });\n }\n\n toString(): string {\n const lines = [`Reason: ${this.reason}`];\n if (this.rejectionCode) {\n lines.push(`Rejection Code: ${this.rejectionCode.label()}`);\n }\n if (this.errorCode) {\n lines.push(`Error Code: ${this.errorCode}`);\n }\n if (this.existingMethod) {\n lines.push(`Existing Method: ${this.existingMethod}`);\n }\n if (this.errorLogId) {\n lines.push(`Error Log ID: ${this.errorLogId}`);\n }\n if (this.requestId) {\n lines.push(`Request ID: ${this.requestId}`);\n }\n return lines.join(\"\\n\");\n }\n}\n\n/** Preserve known public method guidance while tolerating future backend variants. */\nfunction linkedIdentityType(\n value: string | undefined,\n): LinkedIdentityType | undefined {\n return value === \"email\" ||\n value === \"google\" ||\n value === \"x\" ||\n value === \"wallet\"\n ? value\n : undefined;\n}\n\nexport function isApiResponse<T>(value: unknown): value is ApiResponse<T> {\n if (typeof value !== \"object\" || value === null || !(\"status\" in value)) {\n return false;\n }\n\n const status = (value as { status?: unknown }).status;\n if (status === \"success\") {\n return \"body\" in value;\n }\n if (status === \"error\") {\n return \"error_details\" in value;\n }\n return false;\n}\n"]}
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { RejectionCode } from "./rejection";
|
|
|
4
4
|
export { formatDecimal, isZero, parseDecimal } from "./price";
|
|
5
5
|
export { parseJsonExact, stringifyJsonExact } from "./json";
|
|
6
6
|
export { assertSignedRange, exactScaledInteger, I64_MAX, PRICE_SCALE, scalePriceSize, ScalingError, U32_MAX, validateRawAmounts, validateSignedFields, validateTriggerPrice, type OrderbookRules, type TradingRules, type ScaledAmounts, } from "./scaling";
|
|
7
|
-
export { isUserCancellation, type ExternalSigner, type SigningStrategy, } from "./signing";
|
|
7
|
+
export { isUserCancellation, requireNativeSigningStrategy, type ExternalSigner, type NativeSigningStrategy, type SigningStrategy, } from "./signing";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|