@drift-labs/sdk 2.97.0-beta.21 → 2.97.0-beta.23
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/VERSION +1 -1
- package/bun.lockb +0 -0
- package/lib/{accounts → browser/accounts}/bulkAccountLoader.d.ts +1 -0
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +16 -0
- package/lib/browser/accounts/grpcAccountSubscriber.js +154 -0
- package/lib/browser/accounts/grpcDriftClientAccountSubscriber.d.ts +12 -0
- package/lib/browser/accounts/grpcDriftClientAccountSubscriber.js +97 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +10 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.js +30 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +171 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +10 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.js +28 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +10 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.js +28 -0
- package/lib/{accounts → browser/accounts}/types.d.ts +8 -0
- package/lib/{accounts → browser/accounts}/webSocketAccountSubscriber.d.ts +2 -1
- package/lib/{accounts → browser/accounts}/webSocketDriftClientAccountSubscriber.d.ts +3 -3
- package/lib/{accounts → browser/accounts}/webSocketProgramAccountSubscriber.d.ts +2 -1
- package/lib/{addresses → browser/addresses}/pda.d.ts +1 -0
- package/lib/{addresses → browser/addresses}/pda.js +8 -1
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +15 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +32 -0
- package/lib/{auctionSubscriber → browser/auctionSubscriber}/index.d.ts +1 -0
- package/lib/browser/auctionSubscriber/index.js +19 -0
- package/lib/{auctionSubscriber → browser/auctionSubscriber}/types.d.ts +2 -0
- package/lib/{bankrun → browser/bankrun}/bankrunConnection.d.ts +1 -0
- package/lib/{decode → browser/decode}/phoenix.d.ts +1 -0
- package/lib/{decode → browser/decode}/user.d.ts +1 -0
- package/lib/{dlob → browser/dlob}/DLOBOrders.d.ts +1 -0
- package/lib/{driftClient.d.ts → browser/driftClient.d.ts} +11 -5
- package/lib/{driftClient.js → browser/driftClient.js} +132 -34
- package/lib/{driftClientConfig.d.ts → browser/driftClientConfig.d.ts} +6 -1
- package/lib/{idl → browser/idl}/drift.json +256 -0
- package/lib/browser/isomorphic/grpc.browser.d.ts +1 -0
- package/lib/browser/isomorphic/grpc.browser.js +8 -0
- package/lib/browser/isomorphic/grpc.d.ts +1 -0
- package/lib/browser/isomorphic/grpc.js +8 -0
- package/lib/browser/isomorphic/grpc.node.d.ts +5 -0
- package/lib/{math → browser/math}/oracles.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/prelaunchOracleClient.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/pythClient.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/pythPullClient.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/quoteAssetOracleClient.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/switchboardClient.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/switchboardOnDemandClient.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/types.d.ts +1 -0
- package/lib/{orderSubscriber → browser/orderSubscriber}/OrderSubscriber.d.ts +3 -1
- package/lib/{orderSubscriber → browser/orderSubscriber}/OrderSubscriber.js +18 -4
- package/lib/browser/orderSubscriber/grpcSubscription.d.ts +22 -0
- package/lib/browser/orderSubscriber/grpcSubscription.js +66 -0
- package/lib/{orderSubscriber → browser/orderSubscriber}/types.d.ts +9 -0
- package/lib/{token → browser/token}/index.d.ts +1 -0
- package/lib/{tx → browser/tx}/baseTxSender.d.ts +1 -0
- package/lib/{tx → browser/tx}/fastSingleTxSender.d.ts +1 -0
- package/lib/{tx → browser/tx}/forwardOnlyTxSender.d.ts +1 -0
- package/lib/{tx → browser/tx}/retryTxSender.d.ts +1 -0
- package/lib/{tx → browser/tx}/types.d.ts +1 -0
- package/lib/{tx → browser/tx}/whileValidTxSender.d.ts +1 -0
- package/lib/{types.d.ts → browser/types.d.ts} +20 -0
- package/lib/{user.js → browser/user.js} +11 -4
- package/lib/{userConfig.d.ts → browser/userConfig.d.ts} +6 -1
- package/lib/{userMap → browser/userMap}/WebsocketSubscription.d.ts +1 -0
- package/lib/browser/userMap/grpcSubscription.d.ts +24 -0
- package/lib/browser/userMap/grpcSubscription.js +40 -0
- package/lib/{userMap → browser/userMap}/userMap.js +17 -1
- package/lib/{userMap → browser/userMap}/userMapConfig.d.ts +6 -0
- package/lib/{userStats.js → browser/userStats.js} +11 -4
- package/lib/{userStatsConfig.d.ts → browser/userStatsConfig.d.ts} +6 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/basicUserAccountSubscriber.js +38 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts +37 -0
- package/lib/node/accounts/bulkAccountLoader.js +222 -0
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts +7 -0
- package/lib/node/accounts/bulkUserStatsSubscription.js +21 -0
- package/lib/node/accounts/bulkUserSubscription.d.ts +7 -0
- package/lib/node/accounts/bulkUserSubscription.js +21 -0
- package/lib/node/accounts/fetch.d.ts +6 -0
- package/lib/node/accounts/fetch.js +30 -0
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +16 -0
- package/lib/node/accounts/grpcAccountSubscriber.js +154 -0
- package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts +12 -0
- package/lib/node/accounts/grpcDriftClientAccountSubscriber.js +97 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +10 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.js +30 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +171 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +10 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.js +28 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +10 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.js +28 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.js +48 -0
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts +69 -0
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.js +415 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +29 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +110 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.js +78 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +26 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.js +78 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +29 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.js +102 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +94 -0
- package/lib/node/accounts/testBulkAccountLoader.d.ts +4 -0
- package/lib/node/accounts/testBulkAccountLoader.js +45 -0
- package/lib/node/accounts/types.d.ts +155 -0
- package/lib/node/accounts/types.js +16 -0
- package/lib/node/accounts/utils.d.ts +8 -0
- package/lib/node/accounts/utils.js +39 -0
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +29 -0
- package/lib/node/accounts/webSocketAccountSubscriber.js +149 -0
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts +66 -0
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.js +352 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +23 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +67 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +34 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +127 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +23 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.js +61 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +22 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +52 -0
- package/lib/node/addresses/marketAddresses.d.ts +2 -0
- package/lib/node/addresses/marketAddresses.js +15 -0
- package/lib/node/addresses/pda.d.ts +30 -0
- package/lib/node/addresses/pda.js +193 -0
- package/lib/node/adminClient.d.ts +202 -0
- package/lib/node/adminClient.js +1826 -0
- package/lib/node/assert/assert.d.ts +1 -0
- package/lib/node/assert/assert.js +9 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +14 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.js +32 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +15 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +32 -0
- package/lib/node/auctionSubscriber/index.d.ts +3 -0
- package/lib/node/auctionSubscriber/index.js +19 -0
- package/lib/node/auctionSubscriber/types.d.ts +14 -0
- package/lib/node/auctionSubscriber/types.js +2 -0
- package/lib/node/bankrun/bankrunConnection.d.ts +74 -0
- package/lib/node/bankrun/bankrunConnection.js +318 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +27 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +89 -0
- package/lib/node/blockhashSubscriber/index.d.ts +1 -0
- package/lib/node/blockhashSubscriber/index.js +17 -0
- package/lib/node/blockhashSubscriber/types.d.ts +7 -0
- package/lib/node/blockhashSubscriber/types.js +2 -0
- package/lib/node/clock/clockSubscriber.d.ts +31 -0
- package/lib/node/clock/clockSubscriber.js +80 -0
- package/lib/node/config.d.ts +58 -0
- package/lib/node/config.js +126 -0
- package/lib/node/constants/numericConstants.d.ts +71 -0
- package/lib/node/constants/numericConstants.js +75 -0
- package/lib/node/constants/perpMarkets.d.ts +19 -0
- package/lib/node/constants/perpMarkets.js +868 -0
- package/lib/node/constants/spotMarkets.d.ts +23 -0
- package/lib/node/constants/spotMarkets.js +361 -0
- package/lib/node/constants/txConstants.d.ts +1 -0
- package/lib/node/constants/txConstants.js +4 -0
- package/lib/node/decode/phoenix.d.ts +7 -0
- package/lib/node/decode/phoenix.js +159 -0
- package/lib/node/decode/user.d.ts +4 -0
- package/lib/node/decode/user.js +339 -0
- package/lib/node/dlob/DLOB.d.ts +166 -0
- package/lib/node/dlob/DLOB.js +1142 -0
- package/lib/node/dlob/DLOBApiClient.d.ts +14 -0
- package/lib/node/dlob/DLOBApiClient.js +34 -0
- package/lib/node/dlob/DLOBNode.d.ts +57 -0
- package/lib/node/dlob/DLOBNode.js +86 -0
- package/lib/node/dlob/DLOBOrders.d.ts +17 -0
- package/lib/node/dlob/DLOBOrders.js +40 -0
- package/lib/node/dlob/DLOBSubscriber.d.ts +54 -0
- package/lib/node/dlob/DLOBSubscriber.js +139 -0
- package/lib/node/dlob/NodeList.d.ts +27 -0
- package/lib/node/dlob/NodeList.js +141 -0
- package/lib/node/dlob/dlobIdl.json +248 -0
- package/lib/node/dlob/orderBookLevels.d.ts +72 -0
- package/lib/node/dlob/orderBookLevels.js +438 -0
- package/lib/node/dlob/types.d.ts +18 -0
- package/lib/node/dlob/types.js +2 -0
- package/lib/node/driftClient.d.ts +820 -0
- package/lib/node/driftClient.js +4487 -0
- package/lib/node/driftClientConfig.d.ts +49 -0
- package/lib/node/driftClientConfig.js +2 -0
- package/lib/node/events/eventList.d.ts +22 -0
- package/lib/node/events/eventList.js +80 -0
- package/lib/node/events/eventSubscriber.d.ts +46 -0
- package/lib/node/events/eventSubscriber.js +223 -0
- package/lib/node/events/eventsServerLogProvider.d.ts +21 -0
- package/lib/node/events/eventsServerLogProvider.js +121 -0
- package/lib/node/events/fetchLogs.d.ts +25 -0
- package/lib/node/events/fetchLogs.js +99 -0
- package/lib/node/events/parse.d.ts +6 -0
- package/lib/node/events/parse.js +106 -0
- package/lib/node/events/pollingLogProvider.d.ts +17 -0
- package/lib/node/events/pollingLogProvider.js +58 -0
- package/lib/node/events/sort.d.ts +2 -0
- package/lib/node/events/sort.js +24 -0
- package/lib/node/events/txEventCache.d.ts +24 -0
- package/lib/node/events/txEventCache.js +71 -0
- package/lib/node/events/types.d.ts +77 -0
- package/lib/node/events/types.js +30 -0
- package/lib/node/events/webSocketLogProvider.d.ts +24 -0
- package/lib/node/events/webSocketLogProvider.js +96 -0
- package/lib/node/factory/bigNum.d.ts +122 -0
- package/lib/node/factory/bigNum.js +457 -0
- package/lib/node/factory/oracleClient.d.ts +5 -0
- package/lib/node/factory/oracleClient.js +52 -0
- package/lib/node/idl/drift.json +13651 -0
- package/lib/node/idl/openbook.json +3854 -0
- package/lib/node/idl/pyth_solana_receiver.json +628 -0
- package/lib/node/idl/switchboard.json +8354 -0
- package/lib/node/idl/switchboard_on_demand_30.json +4541 -0
- package/lib/node/idl/token_faucet.json +142 -0
- package/lib/node/index.d.ts +112 -0
- package/lib/node/index.js +134 -0
- package/lib/node/isomorphic/grpc.browser.d.ts +1 -0
- package/lib/node/isomorphic/grpc.d.ts +1 -0
- package/lib/node/isomorphic/grpc.js +17 -0
- package/lib/node/isomorphic/grpc.node.d.ts +5 -0
- package/lib/node/isomorphic/grpc.node.js +17 -0
- package/lib/node/jupiter/jupiterClient.d.ts +296 -0
- package/lib/node/jupiter/jupiterClient.js +178 -0
- package/lib/node/keypair.d.ts +2 -0
- package/lib/node/keypair.js +28 -0
- package/lib/node/marinade/index.d.ts +12 -0
- package/lib/node/marinade/index.js +36 -0
- package/lib/node/marinade/types.d.ts +1963 -0
- package/lib/node/marinade/types.js +1965 -0
- package/lib/node/math/amm.d.ts +98 -0
- package/lib/node/math/amm.js +626 -0
- package/lib/node/math/auction.d.ts +23 -0
- package/lib/node/math/auction.js +127 -0
- package/lib/node/math/bankruptcy.d.ts +2 -0
- package/lib/node/math/bankruptcy.js +31 -0
- package/lib/node/math/conversion.d.ts +2 -0
- package/lib/node/math/conversion.js +11 -0
- package/lib/node/math/exchangeStatus.d.ts +6 -0
- package/lib/node/math/exchangeStatus.js +77 -0
- package/lib/node/math/fuel.d.ts +6 -0
- package/lib/node/math/fuel.js +55 -0
- package/lib/node/math/funding.d.ts +34 -0
- package/lib/node/math/funding.js +209 -0
- package/lib/node/math/insurance.d.ts +7 -0
- package/lib/node/math/insurance.js +73 -0
- package/lib/node/math/margin.d.ts +39 -0
- package/lib/node/math/margin.js +184 -0
- package/lib/node/math/market.d.ts +39 -0
- package/lib/node/math/market.js +163 -0
- package/lib/node/math/oracles.d.ts +14 -0
- package/lib/node/math/oracles.js +134 -0
- package/lib/node/math/orders.d.ts +23 -0
- package/lib/node/math/orders.js +216 -0
- package/lib/node/math/position.d.ts +54 -0
- package/lib/node/math/position.js +198 -0
- package/lib/node/math/repeg.d.ts +22 -0
- package/lib/node/math/repeg.js +164 -0
- package/lib/node/math/spotBalance.d.ts +83 -0
- package/lib/node/math/spotBalance.js +373 -0
- package/lib/node/math/spotMarket.d.ts +11 -0
- package/lib/node/math/spotMarket.js +49 -0
- package/lib/node/math/spotPosition.d.ts +19 -0
- package/lib/node/math/spotPosition.js +78 -0
- package/lib/node/math/state.d.ts +5 -0
- package/lib/node/math/state.js +30 -0
- package/lib/node/math/superStake.d.ts +167 -0
- package/lib/node/math/superStake.js +306 -0
- package/lib/node/math/tiers.d.ts +4 -0
- package/lib/node/math/tiers.js +52 -0
- package/lib/node/math/trade.d.ts +117 -0
- package/lib/node/math/trade.js +637 -0
- package/lib/node/math/utils.d.ts +23 -0
- package/lib/node/math/utils.js +112 -0
- package/lib/node/memcmp.d.ts +7 -0
- package/lib/node/memcmp.js +63 -0
- package/lib/node/openbook/openbookV2FulfillmentConfigMap.d.ts +10 -0
- package/lib/node/openbook/openbookV2FulfillmentConfigMap.js +17 -0
- package/lib/node/openbook/openbookV2Subscriber.d.ts +36 -0
- package/lib/node/openbook/openbookV2Subscriber.js +104 -0
- package/lib/node/oracles/oracleClientCache.d.ts +9 -0
- package/lib/node/oracles/oracleClientCache.js +19 -0
- package/lib/node/oracles/prelaunchOracleClient.d.ts +12 -0
- package/lib/node/oracles/prelaunchOracleClient.js +24 -0
- package/lib/node/oracles/pythClient.d.ts +15 -0
- package/lib/node/oracles/pythClient.js +52 -0
- package/lib/node/oracles/pythPullClient.d.ts +19 -0
- package/lib/node/oracles/pythPullClient.js +60 -0
- package/lib/node/oracles/quoteAssetOracleClient.d.ts +10 -0
- package/lib/node/oracles/quoteAssetOracleClient.js +21 -0
- package/lib/node/oracles/strictOraclePrice.d.ts +9 -0
- package/lib/node/oracles/strictOraclePrice.js +17 -0
- package/lib/node/oracles/switchboardClient.d.ts +12 -0
- package/lib/node/oracles/switchboardClient.js +40 -0
- package/lib/node/oracles/switchboardOnDemandClient.d.ts +12 -0
- package/lib/node/oracles/switchboardOnDemandClient.js +32 -0
- package/lib/node/oracles/types.d.ts +23 -0
- package/lib/node/oracles/types.js +2 -0
- package/lib/node/orderParams.d.ts +29 -0
- package/lib/node/orderParams.js +44 -0
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +42 -0
- package/lib/node/orderSubscriber/OrderSubscriber.js +179 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts +12 -0
- package/lib/node/orderSubscriber/PollingSubscription.js +23 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts +23 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.js +67 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts +22 -0
- package/lib/node/orderSubscriber/grpcSubscription.js +66 -0
- package/lib/node/orderSubscriber/index.d.ts +2 -0
- package/lib/{auctionSubscriber → node/orderSubscriber}/index.js +1 -1
- package/lib/node/orderSubscriber/types.d.ts +34 -0
- package/lib/node/orderSubscriber/types.js +2 -0
- package/lib/node/phoenix/phoenixFulfillmentConfigMap.d.ts +10 -0
- package/lib/node/phoenix/phoenixFulfillmentConfigMap.js +17 -0
- package/lib/node/phoenix/phoenixSubscriber.d.ts +41 -0
- package/lib/node/phoenix/phoenixSubscriber.js +152 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts +5 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.js +16 -0
- package/lib/node/priorityFee/averageStrategy.d.ts +5 -0
- package/lib/node/priorityFee/averageStrategy.js +11 -0
- package/lib/node/priorityFee/driftPriorityFeeMethod.d.ts +13 -0
- package/lib/node/priorityFee/driftPriorityFeeMethod.js +26 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts +11 -0
- package/lib/node/priorityFee/ewmaStrategy.js +33 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +20 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.js +46 -0
- package/lib/node/priorityFee/index.d.ts +11 -0
- package/lib/node/priorityFee/index.js +27 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts +5 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.js +17 -0
- package/lib/node/priorityFee/maxStrategy.d.ts +7 -0
- package/lib/node/priorityFee/maxStrategy.js +9 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +46 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.js +188 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +48 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +88 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +6 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.js +21 -0
- package/lib/node/priorityFee/types.d.ts +31 -0
- package/lib/node/priorityFee/types.js +10 -0
- package/lib/node/serum/serumFulfillmentConfigMap.d.ts +10 -0
- package/lib/node/serum/serumFulfillmentConfigMap.js +17 -0
- package/lib/node/serum/serumSubscriber.d.ts +32 -0
- package/lib/node/serum/serumSubscriber.js +107 -0
- package/lib/node/serum/types.d.ts +13 -0
- package/lib/node/serum/types.js +2 -0
- package/lib/node/slot/SlotSubscriber.d.ts +27 -0
- package/lib/node/slot/SlotSubscriber.js +71 -0
- package/lib/node/testClient.d.ts +8 -0
- package/lib/node/testClient.js +23 -0
- package/lib/node/token/index.d.ts +5 -0
- package/lib/node/token/index.js +15 -0
- package/lib/node/tokenFaucet.d.ts +41 -0
- package/lib/node/tokenFaucet.js +188 -0
- package/lib/node/tx/baseTxSender.d.ts +55 -0
- package/lib/node/tx/baseTxSender.js +288 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +8 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.js +13 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +28 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.js +73 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/node/tx/blockhashFetcher/types.js +2 -0
- package/lib/node/tx/fastSingleTxSender.d.ts +40 -0
- package/lib/node/tx/fastSingleTxSender.js +85 -0
- package/lib/node/tx/forwardOnlyTxSender.d.ts +36 -0
- package/lib/node/tx/forwardOnlyTxSender.js +91 -0
- package/lib/node/tx/priorityFeeCalculator.d.ts +44 -0
- package/lib/node/tx/priorityFeeCalculator.js +85 -0
- package/lib/node/tx/reportTransactionError.d.ts +20 -0
- package/lib/node/tx/reportTransactionError.js +103 -0
- package/lib/node/tx/retryTxSender.d.ts +36 -0
- package/lib/node/tx/retryTxSender.js +85 -0
- package/lib/node/tx/txHandler.d.ts +154 -0
- package/lib/node/tx/txHandler.js +453 -0
- package/lib/node/tx/txParamProcessor.d.ts +25 -0
- package/lib/node/tx/txParamProcessor.js +88 -0
- package/lib/node/tx/types.d.ts +29 -0
- package/lib/node/tx/types.js +20 -0
- package/lib/node/tx/utils.d.ts +2 -0
- package/lib/node/tx/utils.js +10 -0
- package/lib/node/tx/whileValidTxSender.d.ts +43 -0
- package/lib/node/tx/whileValidTxSender.js +165 -0
- package/lib/node/types.d.ts +1351 -0
- package/lib/node/types.js +347 -0
- package/lib/node/user.d.ts +411 -0
- package/lib/node/user.js +2161 -0
- package/lib/node/userConfig.d.ts +26 -0
- package/lib/node/userConfig.js +2 -0
- package/lib/node/userMap/PollingSubscription.d.ts +16 -0
- package/lib/node/userMap/PollingSubscription.js +30 -0
- package/lib/node/userMap/WebsocketSubscription.d.ts +25 -0
- package/lib/node/userMap/WebsocketSubscription.js +41 -0
- package/lib/node/userMap/grpcSubscription.d.ts +24 -0
- package/lib/node/userMap/grpcSubscription.js +40 -0
- package/lib/node/userMap/userMap.d.ts +88 -0
- package/lib/node/userMap/userMap.js +455 -0
- package/lib/node/userMap/userMapConfig.d.ts +37 -0
- package/lib/node/userMap/userMapConfig.js +2 -0
- package/lib/node/userMap/userStatsMap.d.ts +46 -0
- package/lib/node/userMap/userStatsMap.js +165 -0
- package/lib/node/userName.d.ts +5 -0
- package/lib/node/userName.js +21 -0
- package/lib/node/userStats.d.ts +19 -0
- package/lib/node/userStats.js +65 -0
- package/lib/node/userStatsConfig.d.ts +25 -0
- package/lib/node/userStatsConfig.js +2 -0
- package/lib/node/util/TransactionConfirmationManager.d.ts +16 -0
- package/lib/node/util/TransactionConfirmationManager.js +174 -0
- package/lib/node/util/chainClock.d.ts +17 -0
- package/lib/node/util/chainClock.js +29 -0
- package/lib/node/util/computeUnits.d.ts +8 -0
- package/lib/node/util/computeUnits.js +46 -0
- package/lib/node/util/promiseTimeout.d.ts +1 -0
- package/lib/node/util/promiseTimeout.js +14 -0
- package/lib/node/util/pythPullOracleUtils.d.ts +2 -0
- package/lib/node/util/pythPullOracleUtils.js +15 -0
- package/lib/node/util/tps.d.ts +2 -0
- package/lib/node/util/tps.js +16 -0
- package/lib/node/wallet.d.ts +11 -0
- package/lib/node/wallet.js +32 -0
- package/package.json +8 -4
- package/scripts/postbuild.js +61 -0
- package/src/accounts/grpcAccountSubscriber.ts +160 -0
- package/src/accounts/grpcDriftClientAccountSubscriber.ts +197 -0
- package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +56 -0
- package/src/accounts/grpcProgramAccountSubscriber.ts +190 -0
- package/src/accounts/grpcUserAccountSubscriber.ts +48 -0
- package/src/accounts/grpcUserStatsAccountSubscriber.ts +50 -0
- package/src/accounts/types.ts +8 -0
- package/src/accounts/webSocketAccountSubscriber.ts +1 -1
- package/src/accounts/webSocketDriftClientAccountSubscriber.ts +3 -3
- package/src/accounts/webSocketProgramAccountSubscriber.ts +1 -1
- package/src/addresses/pda.ts +13 -0
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +70 -0
- package/src/auctionSubscriber/index.ts +1 -0
- package/src/auctionSubscriber/types.ts +2 -0
- package/src/driftClient.ts +175 -24
- package/src/driftClientConfig.ts +7 -1
- package/src/idl/drift.json +256 -0
- package/src/isomorphic/README.md +19 -0
- package/src/isomorphic/grpc.browser.ts +4 -0
- package/src/isomorphic/grpc.node.ts +23 -0
- package/src/isomorphic/grpc.ts +1 -0
- package/src/orderSubscriber/OrderSubscriber.ts +14 -1
- package/src/orderSubscriber/grpcSubscription.ts +121 -0
- package/src/orderSubscriber/types.ts +10 -0
- package/src/types.ts +23 -0
- package/src/user.ts +11 -0
- package/src/userConfig.ts +7 -1
- package/src/userMap/grpcSubscription.ts +78 -0
- package/src/userMap/userMap.ts +21 -2
- package/src/userMap/userMapConfig.ts +7 -0
- package/src/userStats.ts +11 -0
- package/src/userStatsConfig.ts +7 -0
- package/tsconfig.browser.json +13 -0
- package/tsconfig.json +1 -1
- /package/lib/{accounts → browser/accounts}/basicUserAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/basicUserAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/bulkAccountLoader.js +0 -0
- /package/lib/{accounts → browser/accounts}/bulkUserStatsSubscription.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/bulkUserStatsSubscription.js +0 -0
- /package/lib/{accounts → browser/accounts}/bulkUserSubscription.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/bulkUserSubscription.js +0 -0
- /package/lib/{accounts → browser/accounts}/fetch.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/fetch.js +0 -0
- /package/lib/{accounts → browser/accounts}/oneShotUserAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/oneShotUserAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/pollingDriftClientAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/pollingDriftClientAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/pollingInsuranceFundStakeAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/pollingInsuranceFundStakeAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/pollingOracleAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/pollingOracleAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/pollingTokenAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/pollingTokenAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/pollingUserAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/pollingUserAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/pollingUserStatsAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/pollingUserStatsAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/testBulkAccountLoader.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/testBulkAccountLoader.js +0 -0
- /package/lib/{accounts → browser/accounts}/types.js +0 -0
- /package/lib/{accounts → browser/accounts}/utils.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/utils.js +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketDriftClientAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketInsuranceFundStakeAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketInsuranceFundStakeAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketProgramAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketUserAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketUserAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketUserStatsAccountSubsriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketUserStatsAccountSubsriber.js +0 -0
- /package/lib/{addresses → browser/addresses}/marketAddresses.d.ts +0 -0
- /package/lib/{addresses → browser/addresses}/marketAddresses.js +0 -0
- /package/lib/{adminClient.d.ts → browser/adminClient.d.ts} +0 -0
- /package/lib/{adminClient.js → browser/adminClient.js} +0 -0
- /package/lib/{assert → browser/assert}/assert.d.ts +0 -0
- /package/lib/{assert → browser/assert}/assert.js +0 -0
- /package/lib/{auctionSubscriber → browser/auctionSubscriber}/auctionSubscriber.d.ts +0 -0
- /package/lib/{auctionSubscriber → browser/auctionSubscriber}/auctionSubscriber.js +0 -0
- /package/lib/{auctionSubscriber → browser/auctionSubscriber}/types.js +0 -0
- /package/lib/{bankrun → browser/bankrun}/bankrunConnection.js +0 -0
- /package/lib/{blockhashSubscriber → browser/blockhashSubscriber}/BlockhashSubscriber.d.ts +0 -0
- /package/lib/{blockhashSubscriber → browser/blockhashSubscriber}/BlockhashSubscriber.js +0 -0
- /package/lib/{blockhashSubscriber → browser/blockhashSubscriber}/index.d.ts +0 -0
- /package/lib/{blockhashSubscriber → browser/blockhashSubscriber}/index.js +0 -0
- /package/lib/{blockhashSubscriber → browser/blockhashSubscriber}/types.d.ts +0 -0
- /package/lib/{blockhashSubscriber → browser/blockhashSubscriber}/types.js +0 -0
- /package/lib/{clock → browser/clock}/clockSubscriber.d.ts +0 -0
- /package/lib/{clock → browser/clock}/clockSubscriber.js +0 -0
- /package/lib/{config.d.ts → browser/config.d.ts} +0 -0
- /package/lib/{config.js → browser/config.js} +0 -0
- /package/lib/{constants → browser/constants}/numericConstants.d.ts +0 -0
- /package/lib/{constants → browser/constants}/numericConstants.js +0 -0
- /package/lib/{constants → browser/constants}/perpMarkets.d.ts +0 -0
- /package/lib/{constants → browser/constants}/perpMarkets.js +0 -0
- /package/lib/{constants → browser/constants}/spotMarkets.d.ts +0 -0
- /package/lib/{constants → browser/constants}/spotMarkets.js +0 -0
- /package/lib/{constants → browser/constants}/txConstants.d.ts +0 -0
- /package/lib/{constants → browser/constants}/txConstants.js +0 -0
- /package/lib/{decode → browser/decode}/phoenix.js +0 -0
- /package/lib/{decode → browser/decode}/user.js +0 -0
- /package/lib/{dlob → browser/dlob}/DLOB.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/DLOB.js +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBApiClient.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBApiClient.js +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBNode.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBNode.js +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBOrders.js +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBSubscriber.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBSubscriber.js +0 -0
- /package/lib/{dlob → browser/dlob}/NodeList.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/NodeList.js +0 -0
- /package/lib/{dlob → browser/dlob}/dlobIdl.json +0 -0
- /package/lib/{dlob → browser/dlob}/orderBookLevels.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/orderBookLevels.js +0 -0
- /package/lib/{dlob → browser/dlob}/types.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/types.js +0 -0
- /package/lib/{driftClientConfig.js → browser/driftClientConfig.js} +0 -0
- /package/lib/{events → browser/events}/eventList.d.ts +0 -0
- /package/lib/{events → browser/events}/eventList.js +0 -0
- /package/lib/{events → browser/events}/eventSubscriber.d.ts +0 -0
- /package/lib/{events → browser/events}/eventSubscriber.js +0 -0
- /package/lib/{events → browser/events}/eventsServerLogProvider.d.ts +0 -0
- /package/lib/{events → browser/events}/eventsServerLogProvider.js +0 -0
- /package/lib/{events → browser/events}/fetchLogs.d.ts +0 -0
- /package/lib/{events → browser/events}/fetchLogs.js +0 -0
- /package/lib/{events → browser/events}/parse.d.ts +0 -0
- /package/lib/{events → browser/events}/parse.js +0 -0
- /package/lib/{events → browser/events}/pollingLogProvider.d.ts +0 -0
- /package/lib/{events → browser/events}/pollingLogProvider.js +0 -0
- /package/lib/{events → browser/events}/sort.d.ts +0 -0
- /package/lib/{events → browser/events}/sort.js +0 -0
- /package/lib/{events → browser/events}/txEventCache.d.ts +0 -0
- /package/lib/{events → browser/events}/txEventCache.js +0 -0
- /package/lib/{events → browser/events}/types.d.ts +0 -0
- /package/lib/{events → browser/events}/types.js +0 -0
- /package/lib/{events → browser/events}/webSocketLogProvider.d.ts +0 -0
- /package/lib/{events → browser/events}/webSocketLogProvider.js +0 -0
- /package/lib/{factory → browser/factory}/bigNum.d.ts +0 -0
- /package/lib/{factory → browser/factory}/bigNum.js +0 -0
- /package/lib/{factory → browser/factory}/oracleClient.d.ts +0 -0
- /package/lib/{factory → browser/factory}/oracleClient.js +0 -0
- /package/lib/{idl → browser/idl}/openbook.json +0 -0
- /package/lib/{idl → browser/idl}/pyth_solana_receiver.json +0 -0
- /package/lib/{idl → browser/idl}/switchboard.json +0 -0
- /package/lib/{idl → browser/idl}/switchboard_on_demand_30.json +0 -0
- /package/lib/{idl → browser/idl}/token_faucet.json +0 -0
- /package/lib/{index.d.ts → browser/index.d.ts} +0 -0
- /package/lib/{index.js → browser/index.js} +0 -0
- /package/lib/{jupiter → browser/jupiter}/jupiterClient.d.ts +0 -0
- /package/lib/{jupiter → browser/jupiter}/jupiterClient.js +0 -0
- /package/lib/{keypair.d.ts → browser/keypair.d.ts} +0 -0
- /package/lib/{keypair.js → browser/keypair.js} +0 -0
- /package/lib/{marinade → browser/marinade}/index.d.ts +0 -0
- /package/lib/{marinade → browser/marinade}/index.js +0 -0
- /package/lib/{marinade → browser/marinade}/types.d.ts +0 -0
- /package/lib/{marinade → browser/marinade}/types.js +0 -0
- /package/lib/{math → browser/math}/amm.d.ts +0 -0
- /package/lib/{math → browser/math}/amm.js +0 -0
- /package/lib/{math → browser/math}/auction.d.ts +0 -0
- /package/lib/{math → browser/math}/auction.js +0 -0
- /package/lib/{math → browser/math}/bankruptcy.d.ts +0 -0
- /package/lib/{math → browser/math}/bankruptcy.js +0 -0
- /package/lib/{math → browser/math}/conversion.d.ts +0 -0
- /package/lib/{math → browser/math}/conversion.js +0 -0
- /package/lib/{math → browser/math}/exchangeStatus.d.ts +0 -0
- /package/lib/{math → browser/math}/exchangeStatus.js +0 -0
- /package/lib/{math → browser/math}/fuel.d.ts +0 -0
- /package/lib/{math → browser/math}/fuel.js +0 -0
- /package/lib/{math → browser/math}/funding.d.ts +0 -0
- /package/lib/{math → browser/math}/funding.js +0 -0
- /package/lib/{math → browser/math}/insurance.d.ts +0 -0
- /package/lib/{math → browser/math}/insurance.js +0 -0
- /package/lib/{math → browser/math}/margin.d.ts +0 -0
- /package/lib/{math → browser/math}/margin.js +0 -0
- /package/lib/{math → browser/math}/market.d.ts +0 -0
- /package/lib/{math → browser/math}/market.js +0 -0
- /package/lib/{math → browser/math}/oracles.js +0 -0
- /package/lib/{math → browser/math}/orders.d.ts +0 -0
- /package/lib/{math → browser/math}/orders.js +0 -0
- /package/lib/{math → browser/math}/position.d.ts +0 -0
- /package/lib/{math → browser/math}/position.js +0 -0
- /package/lib/{math → browser/math}/repeg.d.ts +0 -0
- /package/lib/{math → browser/math}/repeg.js +0 -0
- /package/lib/{math → browser/math}/spotBalance.d.ts +0 -0
- /package/lib/{math → browser/math}/spotBalance.js +0 -0
- /package/lib/{math → browser/math}/spotMarket.d.ts +0 -0
- /package/lib/{math → browser/math}/spotMarket.js +0 -0
- /package/lib/{math → browser/math}/spotPosition.d.ts +0 -0
- /package/lib/{math → browser/math}/spotPosition.js +0 -0
- /package/lib/{math → browser/math}/state.d.ts +0 -0
- /package/lib/{math → browser/math}/state.js +0 -0
- /package/lib/{math → browser/math}/superStake.d.ts +0 -0
- /package/lib/{math → browser/math}/superStake.js +0 -0
- /package/lib/{math → browser/math}/tiers.d.ts +0 -0
- /package/lib/{math → browser/math}/tiers.js +0 -0
- /package/lib/{math → browser/math}/trade.d.ts +0 -0
- /package/lib/{math → browser/math}/trade.js +0 -0
- /package/lib/{math → browser/math}/utils.d.ts +0 -0
- /package/lib/{math → browser/math}/utils.js +0 -0
- /package/lib/{memcmp.d.ts → browser/memcmp.d.ts} +0 -0
- /package/lib/{memcmp.js → browser/memcmp.js} +0 -0
- /package/lib/{openbook → browser/openbook}/openbookV2FulfillmentConfigMap.d.ts +0 -0
- /package/lib/{openbook → browser/openbook}/openbookV2FulfillmentConfigMap.js +0 -0
- /package/lib/{openbook → browser/openbook}/openbookV2Subscriber.d.ts +0 -0
- /package/lib/{openbook → browser/openbook}/openbookV2Subscriber.js +0 -0
- /package/lib/{oracles → browser/oracles}/oracleClientCache.d.ts +0 -0
- /package/lib/{oracles → browser/oracles}/oracleClientCache.js +0 -0
- /package/lib/{oracles → browser/oracles}/prelaunchOracleClient.js +0 -0
- /package/lib/{oracles → browser/oracles}/pythClient.js +0 -0
- /package/lib/{oracles → browser/oracles}/pythPullClient.js +0 -0
- /package/lib/{oracles → browser/oracles}/quoteAssetOracleClient.js +0 -0
- /package/lib/{oracles → browser/oracles}/strictOraclePrice.d.ts +0 -0
- /package/lib/{oracles → browser/oracles}/strictOraclePrice.js +0 -0
- /package/lib/{oracles → browser/oracles}/switchboardClient.js +0 -0
- /package/lib/{oracles → browser/oracles}/switchboardOnDemandClient.js +0 -0
- /package/lib/{oracles → browser/oracles}/types.js +0 -0
- /package/lib/{orderParams.d.ts → browser/orderParams.d.ts} +0 -0
- /package/lib/{orderParams.js → browser/orderParams.js} +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/PollingSubscription.d.ts +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/PollingSubscription.js +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/WebsocketSubscription.d.ts +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/WebsocketSubscription.js +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/index.d.ts +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/index.js +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/types.js +0 -0
- /package/lib/{phoenix → browser/phoenix}/phoenixFulfillmentConfigMap.d.ts +0 -0
- /package/lib/{phoenix → browser/phoenix}/phoenixFulfillmentConfigMap.js +0 -0
- /package/lib/{phoenix → browser/phoenix}/phoenixSubscriber.d.ts +0 -0
- /package/lib/{phoenix → browser/phoenix}/phoenixSubscriber.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/averageOverSlotsStrategy.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/averageOverSlotsStrategy.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/averageStrategy.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/averageStrategy.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/driftPriorityFeeMethod.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/driftPriorityFeeMethod.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/ewmaStrategy.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/ewmaStrategy.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/heliusPriorityFeeMethod.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/heliusPriorityFeeMethod.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/index.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/index.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/maxOverSlotsStrategy.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/maxOverSlotsStrategy.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/maxStrategy.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/maxStrategy.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/priorityFeeSubscriber.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/priorityFeeSubscriber.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/priorityFeeSubscriberMap.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/priorityFeeSubscriberMap.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/solanaPriorityFeeMethod.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/solanaPriorityFeeMethod.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/types.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/types.js +0 -0
- /package/lib/{serum → browser/serum}/serumFulfillmentConfigMap.d.ts +0 -0
- /package/lib/{serum → browser/serum}/serumFulfillmentConfigMap.js +0 -0
- /package/lib/{serum → browser/serum}/serumSubscriber.d.ts +0 -0
- /package/lib/{serum → browser/serum}/serumSubscriber.js +0 -0
- /package/lib/{serum → browser/serum}/types.d.ts +0 -0
- /package/lib/{serum → browser/serum}/types.js +0 -0
- /package/lib/{slot → browser/slot}/SlotSubscriber.d.ts +0 -0
- /package/lib/{slot → browser/slot}/SlotSubscriber.js +0 -0
- /package/lib/{testClient.d.ts → browser/testClient.d.ts} +0 -0
- /package/lib/{testClient.js → browser/testClient.js} +0 -0
- /package/lib/{token → browser/token}/index.js +0 -0
- /package/lib/{tokenFaucet.d.ts → browser/tokenFaucet.d.ts} +0 -0
- /package/lib/{tokenFaucet.js → browser/tokenFaucet.js} +0 -0
- /package/lib/{tx → browser/tx}/baseTxSender.js +0 -0
- /package/lib/{tx → browser/tx}/blockhashFetcher/baseBlockhashFetcher.d.ts +0 -0
- /package/lib/{tx → browser/tx}/blockhashFetcher/baseBlockhashFetcher.js +0 -0
- /package/lib/{tx → browser/tx}/blockhashFetcher/cachedBlockhashFetcher.d.ts +0 -0
- /package/lib/{tx → browser/tx}/blockhashFetcher/cachedBlockhashFetcher.js +0 -0
- /package/lib/{tx → browser/tx}/blockhashFetcher/types.d.ts +0 -0
- /package/lib/{tx → browser/tx}/blockhashFetcher/types.js +0 -0
- /package/lib/{tx → browser/tx}/fastSingleTxSender.js +0 -0
- /package/lib/{tx → browser/tx}/forwardOnlyTxSender.js +0 -0
- /package/lib/{tx → browser/tx}/priorityFeeCalculator.d.ts +0 -0
- /package/lib/{tx → browser/tx}/priorityFeeCalculator.js +0 -0
- /package/lib/{tx → browser/tx}/reportTransactionError.d.ts +0 -0
- /package/lib/{tx → browser/tx}/reportTransactionError.js +0 -0
- /package/lib/{tx → browser/tx}/retryTxSender.js +0 -0
- /package/lib/{tx → browser/tx}/txHandler.d.ts +0 -0
- /package/lib/{tx → browser/tx}/txHandler.js +0 -0
- /package/lib/{tx → browser/tx}/txParamProcessor.d.ts +0 -0
- /package/lib/{tx → browser/tx}/txParamProcessor.js +0 -0
- /package/lib/{tx → browser/tx}/types.js +0 -0
- /package/lib/{tx → browser/tx}/utils.d.ts +0 -0
- /package/lib/{tx → browser/tx}/utils.js +0 -0
- /package/lib/{tx → browser/tx}/whileValidTxSender.js +0 -0
- /package/lib/{types.js → browser/types.js} +0 -0
- /package/lib/{user.d.ts → browser/user.d.ts} +0 -0
- /package/lib/{userConfig.js → browser/userConfig.js} +0 -0
- /package/lib/{userMap → browser/userMap}/PollingSubscription.d.ts +0 -0
- /package/lib/{userMap → browser/userMap}/PollingSubscription.js +0 -0
- /package/lib/{userMap → browser/userMap}/WebsocketSubscription.js +0 -0
- /package/lib/{userMap → browser/userMap}/userMap.d.ts +0 -0
- /package/lib/{userMap → browser/userMap}/userMapConfig.js +0 -0
- /package/lib/{userMap → browser/userMap}/userStatsMap.d.ts +0 -0
- /package/lib/{userMap → browser/userMap}/userStatsMap.js +0 -0
- /package/lib/{userName.d.ts → browser/userName.d.ts} +0 -0
- /package/lib/{userName.js → browser/userName.js} +0 -0
- /package/lib/{userStats.d.ts → browser/userStats.d.ts} +0 -0
- /package/lib/{userStatsConfig.js → browser/userStatsConfig.js} +0 -0
- /package/lib/{util → browser/util}/TransactionConfirmationManager.d.ts +0 -0
- /package/lib/{util → browser/util}/TransactionConfirmationManager.js +0 -0
- /package/lib/{util → browser/util}/chainClock.d.ts +0 -0
- /package/lib/{util → browser/util}/chainClock.js +0 -0
- /package/lib/{util → browser/util}/computeUnits.d.ts +0 -0
- /package/lib/{util → browser/util}/computeUnits.js +0 -0
- /package/lib/{util → browser/util}/promiseTimeout.d.ts +0 -0
- /package/lib/{util → browser/util}/promiseTimeout.js +0 -0
- /package/lib/{util → browser/util}/pythPullOracleUtils.d.ts +0 -0
- /package/lib/{util → browser/util}/pythPullOracleUtils.js +0 -0
- /package/lib/{util → browser/util}/tps.d.ts +0 -0
- /package/lib/{util → browser/util}/tps.js +0 -0
- /package/lib/{wallet.d.ts → browser/wallet.d.ts} +0 -0
- /package/lib/{wallet.js → browser/wallet.js} +0 -0
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TxHandler = exports.COMPUTE_UNITS_DEFAULT = void 0;
|
|
7
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
8
|
+
const txParamProcessor_1 = require("./txParamProcessor");
|
|
9
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
10
|
+
const computeUnits_1 = require("../util/computeUnits");
|
|
11
|
+
const cachedBlockhashFetcher_1 = require("./blockhashFetcher/cachedBlockhashFetcher");
|
|
12
|
+
const baseBlockhashFetcher_1 = require("./blockhashFetcher/baseBlockhashFetcher");
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
const config_1 = require("../config");
|
|
15
|
+
/**
|
|
16
|
+
* Explanation for SIGNATURE_BLOCK_AND_EXPIRY:
|
|
17
|
+
*
|
|
18
|
+
* When the whileValidTxSender waits for confirmation of a given transaction, it needs the last available blockheight and blockhash used in the signature to do so. For pre-signed transactions, these values aren't attached to the transaction object by default. For a "scrappy" workaround which doesn't break backwards compatibility, the SIGNATURE_BLOCK_AND_EXPIRY property is simply attached to the transaction objects as they are created or signed in this handler despite a mismatch in the typescript types. If the values are attached to the transaction when they reach the whileValidTxSender, it can opt-in to use these values.
|
|
19
|
+
*/
|
|
20
|
+
const DEV_TRY_FORCE_TX_TIMEOUTS = process.env.DEV_TRY_FORCE_TX_TIMEOUTS === 'true' || false;
|
|
21
|
+
exports.COMPUTE_UNITS_DEFAULT = 200000;
|
|
22
|
+
const BLOCKHASH_FETCH_RETRY_COUNT = 3;
|
|
23
|
+
const BLOCKHASH_FETCH_RETRY_SLEEP = 200;
|
|
24
|
+
const RECENT_BLOCKHASH_STALE_TIME_MS = 2000; // Reuse blockhashes within this timeframe during bursts of tx contruction
|
|
25
|
+
/**
|
|
26
|
+
* This class is responsible for creating and signing transactions.
|
|
27
|
+
*/
|
|
28
|
+
class TxHandler {
|
|
29
|
+
constructor(props) {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
31
|
+
this.blockHashToLastValidBlockHeightLookup = {};
|
|
32
|
+
this.returnBlockHeightsWithSignedTxCallbackData = false;
|
|
33
|
+
this.blockhashCommitment = config_1.DEFAULT_CONFIRMATION_OPTS.commitment;
|
|
34
|
+
this.getProps = (wallet, confirmationOpts) => [wallet !== null && wallet !== void 0 ? wallet : this.wallet, confirmationOpts !== null && confirmationOpts !== void 0 ? confirmationOpts : this.confirmationOptions];
|
|
35
|
+
this.connection = props.connection;
|
|
36
|
+
this.wallet = props.wallet;
|
|
37
|
+
this.confirmationOptions = props.confirmationOptions;
|
|
38
|
+
this.blockhashCommitment =
|
|
39
|
+
(_e = (_d = (_b = (_a = props.confirmationOptions) === null || _a === void 0 ? void 0 : _a.preflightCommitment) !== null && _b !== void 0 ? _b : (_c = props === null || props === void 0 ? void 0 : props.connection) === null || _c === void 0 ? void 0 : _c.commitment) !== null && _d !== void 0 ? _d : this.blockhashCommitment) !== null && _e !== void 0 ? _e : 'confirmed';
|
|
40
|
+
this.blockHashFetcher = ((_f = props === null || props === void 0 ? void 0 : props.config) === null || _f === void 0 ? void 0 : _f.blockhashCachingEnabled)
|
|
41
|
+
? new cachedBlockhashFetcher_1.CachedBlockhashFetcher(this.connection, this.blockhashCommitment, (_j = (_h = (_g = props === null || props === void 0 ? void 0 : props.config) === null || _g === void 0 ? void 0 : _g.blockhashCachingConfig) === null || _h === void 0 ? void 0 : _h.retryCount) !== null && _j !== void 0 ? _j : BLOCKHASH_FETCH_RETRY_COUNT, (_m = (_l = (_k = props === null || props === void 0 ? void 0 : props.config) === null || _k === void 0 ? void 0 : _k.blockhashCachingConfig) === null || _l === void 0 ? void 0 : _l.retrySleepTimeMs) !== null && _m !== void 0 ? _m : BLOCKHASH_FETCH_RETRY_SLEEP, (_q = (_p = (_o = props === null || props === void 0 ? void 0 : props.config) === null || _o === void 0 ? void 0 : _o.blockhashCachingConfig) === null || _p === void 0 ? void 0 : _p.staleCacheTimeMs) !== null && _q !== void 0 ? _q : RECENT_BLOCKHASH_STALE_TIME_MS)
|
|
42
|
+
: new baseBlockhashFetcher_1.BaseBlockhashFetcher(this.connection, this.blockhashCommitment);
|
|
43
|
+
// #Optionals
|
|
44
|
+
this.returnBlockHeightsWithSignedTxCallbackData =
|
|
45
|
+
(_s = (_r = props.opts) === null || _r === void 0 ? void 0 : _r.returnBlockHeightsWithSignedTxCallbackData) !== null && _s !== void 0 ? _s : false;
|
|
46
|
+
this.onSignedCb = (_t = props.opts) === null || _t === void 0 ? void 0 : _t.onSignedCb;
|
|
47
|
+
this.preSignedCb = (_u = props.opts) === null || _u === void 0 ? void 0 : _u.preSignedCb;
|
|
48
|
+
}
|
|
49
|
+
addHashAndExpiryToLookup(hashAndExpiry) {
|
|
50
|
+
if (!this.returnBlockHeightsWithSignedTxCallbackData)
|
|
51
|
+
return;
|
|
52
|
+
this.blockHashToLastValidBlockHeightLookup[hashAndExpiry.blockhash] =
|
|
53
|
+
hashAndExpiry.lastValidBlockHeight;
|
|
54
|
+
}
|
|
55
|
+
updateWallet(wallet) {
|
|
56
|
+
this.wallet = wallet;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Created this to prevent non-finalized blockhashes being used when building transactions. We want to always use finalized because otherwise it's easy to get the BlockHashNotFound error (RPC uses finalized to validate a transaction). Using an older blockhash when building transactions should never really be a problem right now.
|
|
60
|
+
*
|
|
61
|
+
* https://www.helius.dev/blog/how-to-deal-with-blockhash-errors-on-solana#why-do-blockhash-errors-occur
|
|
62
|
+
*
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
async getLatestBlockhashForTransaction() {
|
|
66
|
+
return this.blockHashFetcher.getLatestBlockhash();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Applies recent blockhash and signs a given transaction
|
|
70
|
+
* @param tx
|
|
71
|
+
* @param additionalSigners
|
|
72
|
+
* @param wallet
|
|
73
|
+
* @param confirmationOpts
|
|
74
|
+
* @param preSigned
|
|
75
|
+
* @param recentBlockhash
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
async prepareTx(tx, additionalSigners, wallet, confirmationOpts, preSigned, recentBlockhash) {
|
|
79
|
+
if (preSigned) {
|
|
80
|
+
return tx;
|
|
81
|
+
}
|
|
82
|
+
[wallet, confirmationOpts] = this.getProps(wallet, confirmationOpts);
|
|
83
|
+
tx.feePayer = wallet.publicKey;
|
|
84
|
+
recentBlockhash = recentBlockhash
|
|
85
|
+
? recentBlockhash
|
|
86
|
+
: await this.getLatestBlockhashForTransaction();
|
|
87
|
+
tx.recentBlockhash = recentBlockhash.blockhash;
|
|
88
|
+
this.addHashAndExpiryToLookup(recentBlockhash);
|
|
89
|
+
const signedTx = await this.signTx(tx, additionalSigners);
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
signedTx.SIGNATURE_BLOCK_AND_EXPIRY = recentBlockhash;
|
|
92
|
+
return signedTx;
|
|
93
|
+
}
|
|
94
|
+
isVersionedTransaction(tx) {
|
|
95
|
+
return (0, utils_1.isVersionedTransaction)(tx);
|
|
96
|
+
}
|
|
97
|
+
isLegacyTransaction(tx) {
|
|
98
|
+
return !this.isVersionedTransaction(tx);
|
|
99
|
+
}
|
|
100
|
+
getTxSigFromSignedTx(signedTx) {
|
|
101
|
+
if (this.isVersionedTransaction(signedTx)) {
|
|
102
|
+
return bs58_1.default.encode(Buffer.from(signedTx.signatures[0]));
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return bs58_1.default.encode(Buffer.from(signedTx.signature));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
getBlockhashFromSignedTx(signedTx) {
|
|
109
|
+
if (this.isVersionedTransaction(signedTx)) {
|
|
110
|
+
return signedTx.message.recentBlockhash;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
return signedTx.recentBlockhash;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async signTx(tx, additionalSigners, wallet) {
|
|
117
|
+
var _a;
|
|
118
|
+
[wallet] = this.getProps(wallet);
|
|
119
|
+
additionalSigners
|
|
120
|
+
.filter((s) => s !== undefined)
|
|
121
|
+
.forEach((kp) => {
|
|
122
|
+
tx.partialSign(kp);
|
|
123
|
+
});
|
|
124
|
+
(_a = this.preSignedCb) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
125
|
+
const signedTx = await wallet.signTransaction(tx);
|
|
126
|
+
// Turn txSig Buffer into base58 string
|
|
127
|
+
const txSig = this.getTxSigFromSignedTx(signedTx);
|
|
128
|
+
this.handleSignedTxData([
|
|
129
|
+
{
|
|
130
|
+
txSig,
|
|
131
|
+
signedTx,
|
|
132
|
+
blockHash: this.getBlockhashFromSignedTx(signedTx),
|
|
133
|
+
},
|
|
134
|
+
]);
|
|
135
|
+
return signedTx;
|
|
136
|
+
}
|
|
137
|
+
async signVersionedTx(tx, additionalSigners, recentBlockhash, wallet) {
|
|
138
|
+
var _a;
|
|
139
|
+
[wallet] = this.getProps(wallet);
|
|
140
|
+
if (recentBlockhash) {
|
|
141
|
+
tx.message.recentBlockhash = recentBlockhash.blockhash;
|
|
142
|
+
this.addHashAndExpiryToLookup(recentBlockhash);
|
|
143
|
+
// @ts-ignore
|
|
144
|
+
tx.SIGNATURE_BLOCK_AND_EXPIRY = recentBlockhash;
|
|
145
|
+
}
|
|
146
|
+
additionalSigners === null || additionalSigners === void 0 ? void 0 : additionalSigners.filter((s) => s !== undefined).forEach((kp) => {
|
|
147
|
+
tx.sign([kp]);
|
|
148
|
+
});
|
|
149
|
+
(_a = this.preSignedCb) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
150
|
+
//@ts-ignore
|
|
151
|
+
const signedTx = (await wallet.signTransaction(tx));
|
|
152
|
+
// Turn txSig Buffer into base58 string
|
|
153
|
+
const txSig = this.getTxSigFromSignedTx(signedTx);
|
|
154
|
+
this.handleSignedTxData([
|
|
155
|
+
{
|
|
156
|
+
txSig,
|
|
157
|
+
signedTx,
|
|
158
|
+
blockHash: this.getBlockhashFromSignedTx(signedTx),
|
|
159
|
+
},
|
|
160
|
+
]);
|
|
161
|
+
return signedTx;
|
|
162
|
+
}
|
|
163
|
+
handleSignedTxData(txData) {
|
|
164
|
+
if (!this.returnBlockHeightsWithSignedTxCallbackData) {
|
|
165
|
+
if (this.onSignedCb) {
|
|
166
|
+
this.onSignedCb(txData);
|
|
167
|
+
}
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const signedTxData = txData.map((tx) => {
|
|
171
|
+
const lastValidBlockHeight = this.blockHashToLastValidBlockHeightLookup[tx.blockHash];
|
|
172
|
+
return {
|
|
173
|
+
...tx,
|
|
174
|
+
lastValidBlockHeight,
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
if (this.onSignedCb) {
|
|
178
|
+
this.onSignedCb(signedTxData);
|
|
179
|
+
}
|
|
180
|
+
return signedTxData;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Gets transaction params with extra processing applied, like using the simulated compute units or using a dynamically calculated compute unit price.
|
|
184
|
+
* @param txBuildingProps
|
|
185
|
+
* @returns
|
|
186
|
+
*/
|
|
187
|
+
async getProcessedTransactionParams(txBuildingProps) {
|
|
188
|
+
var _a, _b;
|
|
189
|
+
const baseTxParams = {
|
|
190
|
+
computeUnits: (_a = txBuildingProps === null || txBuildingProps === void 0 ? void 0 : txBuildingProps.txParams) === null || _a === void 0 ? void 0 : _a.computeUnits,
|
|
191
|
+
computeUnitsPrice: (_b = txBuildingProps === null || txBuildingProps === void 0 ? void 0 : txBuildingProps.txParams) === null || _b === void 0 ? void 0 : _b.computeUnitsPrice,
|
|
192
|
+
};
|
|
193
|
+
const processedTxParams = await txParamProcessor_1.TransactionParamProcessor.process({
|
|
194
|
+
baseTxParams,
|
|
195
|
+
txBuilder: (updatedTxParams) => {
|
|
196
|
+
var _a;
|
|
197
|
+
return this.buildTransaction({
|
|
198
|
+
...txBuildingProps,
|
|
199
|
+
txParams: (_a = updatedTxParams.txParams) !== null && _a !== void 0 ? _a : baseTxParams,
|
|
200
|
+
forceVersionedTransaction: true,
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
processConfig: {
|
|
204
|
+
useSimulatedComputeUnits: txBuildingProps.txParams.useSimulatedComputeUnits,
|
|
205
|
+
computeUnitsBufferMultiplier: txBuildingProps.txParams.computeUnitsBufferMultiplier,
|
|
206
|
+
useSimulatedComputeUnitsForCUPriceCalculation: txBuildingProps.txParams
|
|
207
|
+
.useSimulatedComputeUnitsForCUPriceCalculation,
|
|
208
|
+
getCUPriceFromComputeUnits: txBuildingProps.txParams.getCUPriceFromComputeUnits,
|
|
209
|
+
},
|
|
210
|
+
processParams: {
|
|
211
|
+
connection: this.connection,
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
return processedTxParams;
|
|
215
|
+
}
|
|
216
|
+
_generateVersionedTransaction(recentBlockhash, message) {
|
|
217
|
+
this.addHashAndExpiryToLookup(recentBlockhash);
|
|
218
|
+
return new web3_js_1.VersionedTransaction(message);
|
|
219
|
+
}
|
|
220
|
+
generateLegacyVersionedTransaction(recentBlockhash, ixs, wallet) {
|
|
221
|
+
[wallet] = this.getProps(wallet);
|
|
222
|
+
const message = new web3_js_1.TransactionMessage({
|
|
223
|
+
payerKey: wallet.publicKey,
|
|
224
|
+
recentBlockhash: recentBlockhash.blockhash,
|
|
225
|
+
instructions: ixs,
|
|
226
|
+
}).compileToLegacyMessage();
|
|
227
|
+
const tx = this._generateVersionedTransaction(recentBlockhash, message);
|
|
228
|
+
// @ts-ignore
|
|
229
|
+
tx.SIGNATURE_BLOCK_AND_EXPIRY = recentBlockhash;
|
|
230
|
+
return tx;
|
|
231
|
+
}
|
|
232
|
+
generateVersionedTransaction(recentBlockhash, ixs, lookupTableAccounts, wallet) {
|
|
233
|
+
[wallet] = this.getProps(wallet);
|
|
234
|
+
const message = new web3_js_1.TransactionMessage({
|
|
235
|
+
payerKey: wallet.publicKey,
|
|
236
|
+
recentBlockhash: recentBlockhash.blockhash,
|
|
237
|
+
instructions: ixs,
|
|
238
|
+
}).compileToV0Message(lookupTableAccounts);
|
|
239
|
+
const tx = this._generateVersionedTransaction(recentBlockhash, message);
|
|
240
|
+
// @ts-ignore
|
|
241
|
+
tx.SIGNATURE_BLOCK_AND_EXPIRY = recentBlockhash;
|
|
242
|
+
return tx;
|
|
243
|
+
}
|
|
244
|
+
generateLegacyTransaction(ixs, recentBlockhash) {
|
|
245
|
+
const tx = new web3_js_1.Transaction().add(...ixs);
|
|
246
|
+
if (recentBlockhash) {
|
|
247
|
+
tx.recentBlockhash = recentBlockhash.blockhash;
|
|
248
|
+
}
|
|
249
|
+
return tx;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Accepts multiple instructions and builds a transaction for each. Prevents needing to spam RPC with requests for the same blockhash.
|
|
253
|
+
* @param props
|
|
254
|
+
* @returns
|
|
255
|
+
*/
|
|
256
|
+
async buildBulkTransactions(props) {
|
|
257
|
+
var _a;
|
|
258
|
+
const recentBlockhash = (_a = props === null || props === void 0 ? void 0 : props.recentBlockhash) !== null && _a !== void 0 ? _a : (await this.getLatestBlockhashForTransaction());
|
|
259
|
+
return await Promise.all(props.instructions.map((ix) => {
|
|
260
|
+
if (!ix)
|
|
261
|
+
return undefined;
|
|
262
|
+
return this.buildTransaction({
|
|
263
|
+
...props,
|
|
264
|
+
instructions: ix,
|
|
265
|
+
recentBlockhash,
|
|
266
|
+
});
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
*
|
|
271
|
+
* @param instructions
|
|
272
|
+
* @param txParams
|
|
273
|
+
* @param txVersion
|
|
274
|
+
* @param lookupTables
|
|
275
|
+
* @param forceVersionedTransaction Return a VersionedTransaction instance even if the version of the transaction is Legacy
|
|
276
|
+
* @returns
|
|
277
|
+
*/
|
|
278
|
+
async buildTransaction(props) {
|
|
279
|
+
var _a;
|
|
280
|
+
const { instructions, txVersion, txParams, connection: _connection, preFlightCommitment: _preFlightCommitment, fetchMarketLookupTableAccount, forceVersionedTransaction, } = props;
|
|
281
|
+
let { lookupTables } = props;
|
|
282
|
+
// # Collect and process Tx Params
|
|
283
|
+
let baseTxParams = {
|
|
284
|
+
computeUnits: txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits,
|
|
285
|
+
computeUnitsPrice: txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice,
|
|
286
|
+
};
|
|
287
|
+
if (txParams === null || txParams === void 0 ? void 0 : txParams.useSimulatedComputeUnits) {
|
|
288
|
+
const processedTxParams = await this.getProcessedTransactionParams(props);
|
|
289
|
+
baseTxParams = {
|
|
290
|
+
...baseTxParams,
|
|
291
|
+
...processedTxParams,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
const instructionsArray = Array.isArray(instructions)
|
|
295
|
+
? instructions
|
|
296
|
+
: [instructions];
|
|
297
|
+
const { hasSetComputeUnitLimitIx, hasSetComputeUnitPriceIx } = (0, computeUnits_1.containsComputeUnitIxs)(instructionsArray);
|
|
298
|
+
// # Create Tx Instructions
|
|
299
|
+
const allIx = [];
|
|
300
|
+
const computeUnits = baseTxParams === null || baseTxParams === void 0 ? void 0 : baseTxParams.computeUnits;
|
|
301
|
+
if (computeUnits > 0 && !hasSetComputeUnitLimitIx) {
|
|
302
|
+
allIx.push(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
|
|
303
|
+
units: computeUnits,
|
|
304
|
+
}));
|
|
305
|
+
}
|
|
306
|
+
const computeUnitsPrice = baseTxParams === null || baseTxParams === void 0 ? void 0 : baseTxParams.computeUnitsPrice;
|
|
307
|
+
if (DEV_TRY_FORCE_TX_TIMEOUTS) {
|
|
308
|
+
allIx.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
309
|
+
microLamports: 0,
|
|
310
|
+
}));
|
|
311
|
+
}
|
|
312
|
+
else if (computeUnitsPrice > 0 && !hasSetComputeUnitPriceIx) {
|
|
313
|
+
allIx.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
314
|
+
microLamports: computeUnitsPrice,
|
|
315
|
+
}));
|
|
316
|
+
}
|
|
317
|
+
allIx.push(...instructionsArray);
|
|
318
|
+
const recentBlockhash = (_a = props === null || props === void 0 ? void 0 : props.recentBlockhash) !== null && _a !== void 0 ? _a : (await this.getLatestBlockhashForTransaction());
|
|
319
|
+
// # Create and return Transaction
|
|
320
|
+
if (txVersion === 'legacy') {
|
|
321
|
+
if (forceVersionedTransaction) {
|
|
322
|
+
return this.generateLegacyVersionedTransaction(recentBlockhash, allIx);
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
return this.generateLegacyTransaction(allIx, recentBlockhash);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
const marketLookupTable = await fetchMarketLookupTableAccount();
|
|
330
|
+
lookupTables = lookupTables
|
|
331
|
+
? [...lookupTables, marketLookupTable]
|
|
332
|
+
: [marketLookupTable];
|
|
333
|
+
return this.generateVersionedTransaction(recentBlockhash, allIx, lookupTables);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
wrapInTx(instruction, computeUnits = 600000, computeUnitsPrice = 0) {
|
|
337
|
+
const tx = new web3_js_1.Transaction();
|
|
338
|
+
if (computeUnits != exports.COMPUTE_UNITS_DEFAULT) {
|
|
339
|
+
tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
|
|
340
|
+
units: computeUnits,
|
|
341
|
+
}));
|
|
342
|
+
}
|
|
343
|
+
if (DEV_TRY_FORCE_TX_TIMEOUTS) {
|
|
344
|
+
tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
345
|
+
microLamports: 0,
|
|
346
|
+
}));
|
|
347
|
+
}
|
|
348
|
+
else if (computeUnitsPrice != 0) {
|
|
349
|
+
tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
350
|
+
microLamports: computeUnitsPrice,
|
|
351
|
+
}));
|
|
352
|
+
}
|
|
353
|
+
return tx.add(instruction);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Get a map of signed and prepared transactions from an array of legacy transactions
|
|
357
|
+
* @param txsToSign
|
|
358
|
+
* @param keys
|
|
359
|
+
* @param wallet
|
|
360
|
+
* @param commitment
|
|
361
|
+
* @returns
|
|
362
|
+
*/
|
|
363
|
+
async getPreparedAndSignedLegacyTransactionMap(txsMap, wallet, commitment, recentBlockhash) {
|
|
364
|
+
var _a, _b;
|
|
365
|
+
recentBlockhash = recentBlockhash
|
|
366
|
+
? recentBlockhash
|
|
367
|
+
: await this.getLatestBlockhashForTransaction();
|
|
368
|
+
this.addHashAndExpiryToLookup(recentBlockhash);
|
|
369
|
+
for (const tx of Object.values(txsMap)) {
|
|
370
|
+
if (!tx)
|
|
371
|
+
continue;
|
|
372
|
+
tx.recentBlockhash = recentBlockhash.blockhash;
|
|
373
|
+
tx.feePayer = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.publicKey) !== null && _a !== void 0 ? _a : (_b = this.wallet) === null || _b === void 0 ? void 0 : _b.publicKey;
|
|
374
|
+
// @ts-ignore
|
|
375
|
+
tx.SIGNATURE_BLOCK_AND_EXPIRY = recentBlockhash;
|
|
376
|
+
}
|
|
377
|
+
return this.getSignedTransactionMap(txsMap, wallet);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Get a map of signed transactions from an array of transactions to sign.
|
|
381
|
+
* @param txsToSign
|
|
382
|
+
* @param keys
|
|
383
|
+
* @param wallet
|
|
384
|
+
* @returns
|
|
385
|
+
*/
|
|
386
|
+
async getSignedTransactionMap(txsToSignMap, wallet) {
|
|
387
|
+
var _a;
|
|
388
|
+
[wallet] = this.getProps(wallet);
|
|
389
|
+
const txsToSignEntries = Object.entries(txsToSignMap);
|
|
390
|
+
// Create a map of the same keys as the input map, but with the values set to undefined. We'll populate the filtered (non-undefined) values with signed transactions.
|
|
391
|
+
const signedTxMap = txsToSignEntries.reduce((acc, [key]) => {
|
|
392
|
+
acc[key] = undefined;
|
|
393
|
+
return acc;
|
|
394
|
+
}, {});
|
|
395
|
+
const filteredTxEntries = txsToSignEntries.filter(([_, tx]) => !!tx);
|
|
396
|
+
// Extra handling for legacy transactions
|
|
397
|
+
for (const [_key, tx] of filteredTxEntries) {
|
|
398
|
+
if (this.isLegacyTransaction(tx)) {
|
|
399
|
+
tx.feePayer = wallet.publicKey;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
(_a = this.preSignedCb) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
403
|
+
const signedFilteredTxs = await wallet.signAllTransactions(filteredTxEntries.map(([_, tx]) => tx));
|
|
404
|
+
signedFilteredTxs.forEach((signedTx, index) => {
|
|
405
|
+
var _a;
|
|
406
|
+
// @ts-ignore
|
|
407
|
+
signedTx.SIGNATURE_BLOCK_AND_EXPIRY =
|
|
408
|
+
// @ts-ignore
|
|
409
|
+
(_a = filteredTxEntries[index][1]) === null || _a === void 0 ? void 0 : _a.SIGNATURE_BLOCK_AND_EXPIRY;
|
|
410
|
+
});
|
|
411
|
+
const signedTxData = this.handleSignedTxData(signedFilteredTxs.map((signedTx) => {
|
|
412
|
+
return {
|
|
413
|
+
txSig: this.getTxSigFromSignedTx(signedTx),
|
|
414
|
+
signedTx,
|
|
415
|
+
blockHash: this.getBlockhashFromSignedTx(signedTx),
|
|
416
|
+
};
|
|
417
|
+
}));
|
|
418
|
+
filteredTxEntries.forEach(([key], index) => {
|
|
419
|
+
const signedTx = signedFilteredTxs[index];
|
|
420
|
+
// @ts-ignore
|
|
421
|
+
signedTxMap[key] = signedTx;
|
|
422
|
+
});
|
|
423
|
+
return { signedTxMap, signedTxData };
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Accepts multiple instructions and builds a transaction for each. Prevents needing to spam RPC with requests for the same blockhash.
|
|
427
|
+
* @param props
|
|
428
|
+
* @returns
|
|
429
|
+
*/
|
|
430
|
+
async buildTransactionsMap(props) {
|
|
431
|
+
const builtTxs = await this.buildBulkTransactions({
|
|
432
|
+
...props,
|
|
433
|
+
instructions: Object.values(props.instructionsMap),
|
|
434
|
+
});
|
|
435
|
+
return Object.keys(props.instructionsMap).reduce((acc, key, index) => {
|
|
436
|
+
acc[key] = builtTxs[index];
|
|
437
|
+
return acc;
|
|
438
|
+
}, {});
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Builds and signs transactions from a given array of instructions for multiple transactions.
|
|
442
|
+
* @param props
|
|
443
|
+
* @returns
|
|
444
|
+
*/
|
|
445
|
+
async buildAndSignTransactionMap(props) {
|
|
446
|
+
const builtTxs = await this.buildTransactionsMap(props);
|
|
447
|
+
const preppedTransactions = await (props.txVersion === 'legacy'
|
|
448
|
+
? this.getPreparedAndSignedLegacyTransactionMap(builtTxs, props.wallet, props.preFlightCommitment)
|
|
449
|
+
: this.getSignedTransactionMap(builtTxs, props.wallet));
|
|
450
|
+
return preppedTransactions;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
exports.TxHandler = TxHandler;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Connection, VersionedTransaction } from '@solana/web3.js';
|
|
2
|
+
import { BaseTxParams, ProcessingTxParams } from '..';
|
|
3
|
+
type TransactionBuildingProps = {
|
|
4
|
+
txParams: BaseTxParams;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* This class is responsible for running through a "processing" pipeline for a base transaction, to adjust the standard transaction parameters based on a given configuration.
|
|
8
|
+
*/
|
|
9
|
+
export declare class TransactionParamProcessor {
|
|
10
|
+
private static getComputeUnitsFromSim;
|
|
11
|
+
static getTxSimComputeUnits(tx: VersionedTransaction, connection: Connection, bufferMultiplier: number, // Making this a mandatory param to force the user to remember that simulated CU's can be inaccurate and a buffer should be applied
|
|
12
|
+
lowerBoundCu?: number): Promise<{
|
|
13
|
+
success: boolean;
|
|
14
|
+
computeUnits: number;
|
|
15
|
+
}>;
|
|
16
|
+
static process(props: {
|
|
17
|
+
baseTxParams: BaseTxParams;
|
|
18
|
+
processConfig: ProcessingTxParams;
|
|
19
|
+
processParams: {
|
|
20
|
+
connection: Connection;
|
|
21
|
+
};
|
|
22
|
+
txBuilder: (baseTransactionProps: TransactionBuildingProps) => Promise<VersionedTransaction>;
|
|
23
|
+
}): Promise<BaseTxParams>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionParamProcessor = void 0;
|
|
4
|
+
const COMPUTE_UNIT_BUFFER_FACTOR = 1.2;
|
|
5
|
+
const MAX_COMPUTE_UNITS = 1400000;
|
|
6
|
+
const TEST_SIMS_ALWAYS_FAIL = false;
|
|
7
|
+
/**
|
|
8
|
+
* This class is responsible for running through a "processing" pipeline for a base transaction, to adjust the standard transaction parameters based on a given configuration.
|
|
9
|
+
*/
|
|
10
|
+
class TransactionParamProcessor {
|
|
11
|
+
static async getComputeUnitsFromSim(txSim) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
if ((_a = txSim === null || txSim === void 0 ? void 0 : txSim.value) === null || _a === void 0 ? void 0 : _a.unitsConsumed) {
|
|
14
|
+
return (_b = txSim === null || txSim === void 0 ? void 0 : txSim.value) === null || _b === void 0 ? void 0 : _b.unitsConsumed;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
static async getTxSimComputeUnits(tx, connection, bufferMultiplier, // Making this a mandatory param to force the user to remember that simulated CU's can be inaccurate and a buffer should be applied
|
|
19
|
+
lowerBoundCu) {
|
|
20
|
+
var _a, _b, _c;
|
|
21
|
+
try {
|
|
22
|
+
if (TEST_SIMS_ALWAYS_FAIL)
|
|
23
|
+
throw new Error('Test Error::SIMS_ALWAYS_FAIL');
|
|
24
|
+
const simTxResult = await connection.simulateTransaction(tx, {
|
|
25
|
+
replaceRecentBlockhash: true, // This is important to ensure that the blockhash is not too new.. Otherwise we will very often receive a "blockHashNotFound" error
|
|
26
|
+
});
|
|
27
|
+
if ((_a = simTxResult === null || simTxResult === void 0 ? void 0 : simTxResult.value) === null || _a === void 0 ? void 0 : _a.err) {
|
|
28
|
+
throw new Error((_c = (_b = simTxResult === null || simTxResult === void 0 ? void 0 : simTxResult.value) === null || _b === void 0 ? void 0 : _b.err) === null || _c === void 0 ? void 0 : _c.toString());
|
|
29
|
+
}
|
|
30
|
+
const computeUnits = await this.getComputeUnitsFromSim(simTxResult);
|
|
31
|
+
// Apply the buffer, but round down to the MAX_COMPUTE_UNITS, and round up to the nearest whole number
|
|
32
|
+
let bufferedComputeUnits = Math.ceil(Math.min(computeUnits * bufferMultiplier, MAX_COMPUTE_UNITS));
|
|
33
|
+
// If a lower bound CU is passed then enforce it
|
|
34
|
+
if (lowerBoundCu) {
|
|
35
|
+
bufferedComputeUnits = Math.max(bufferedComputeUnits, Math.min(lowerBoundCu, MAX_COMPUTE_UNITS));
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
success: true,
|
|
39
|
+
computeUnits: bufferedComputeUnits,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
console.warn(`Failed to get Simulated Compute Units for txParamProcessor`, e);
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
computeUnits: undefined,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
static async process(props) {
|
|
51
|
+
var _a;
|
|
52
|
+
// # Exit early if no process config is provided
|
|
53
|
+
if (!props.processConfig || Object.keys(props.processConfig).length === 0) {
|
|
54
|
+
return props.baseTxParams;
|
|
55
|
+
}
|
|
56
|
+
// # Setup
|
|
57
|
+
const { txBuilder: txBuilder, processConfig, processParams: processProps, } = props;
|
|
58
|
+
const finalTxParams = {
|
|
59
|
+
...props.baseTxParams,
|
|
60
|
+
};
|
|
61
|
+
// # Run Processes
|
|
62
|
+
if (processConfig.useSimulatedComputeUnits) {
|
|
63
|
+
const txToSim = await txBuilder({
|
|
64
|
+
txParams: { ...finalTxParams, computeUnits: MAX_COMPUTE_UNITS },
|
|
65
|
+
});
|
|
66
|
+
const txSimComputeUnitsResult = await this.getTxSimComputeUnits(txToSim, processProps.connection, (_a = processConfig === null || processConfig === void 0 ? void 0 : processConfig.computeUnitsBufferMultiplier) !== null && _a !== void 0 ? _a : COMPUTE_UNIT_BUFFER_FACTOR);
|
|
67
|
+
if (txSimComputeUnitsResult.success) {
|
|
68
|
+
// Adjust the transaction based on the simulated compute units
|
|
69
|
+
finalTxParams.computeUnits = txSimComputeUnitsResult.computeUnits;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (processConfig === null || processConfig === void 0 ? void 0 : processConfig.useSimulatedComputeUnitsForCUPriceCalculation) {
|
|
73
|
+
if (!(processConfig === null || processConfig === void 0 ? void 0 : processConfig.useSimulatedComputeUnits)) {
|
|
74
|
+
throw new Error(`encountered useSimulatedComputeUnitsForFees=true, but useSimulatedComputeUnits is false`);
|
|
75
|
+
}
|
|
76
|
+
if (!(processConfig === null || processConfig === void 0 ? void 0 : processConfig.getCUPriceFromComputeUnits)) {
|
|
77
|
+
throw new Error(`encountered useSimulatedComputeUnitsForFees=true, but getComputeUnitPriceFromUnitsToUse helper method is undefined`);
|
|
78
|
+
}
|
|
79
|
+
const simulatedComputeUnits = finalTxParams.computeUnits;
|
|
80
|
+
const computeUnitPrice = processConfig.getCUPriceFromComputeUnits(simulatedComputeUnits);
|
|
81
|
+
console.debug(`🔧:: Adjusting compute unit price for simulated compute unit budget :: ${finalTxParams.computeUnitsPrice}=>${computeUnitPrice}`);
|
|
82
|
+
finalTxParams.computeUnitsPrice = computeUnitPrice;
|
|
83
|
+
}
|
|
84
|
+
// # Return Final Tx Params
|
|
85
|
+
return finalTxParams;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.TransactionParamProcessor = TransactionParamProcessor;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, ConfirmOptions, Signer, Transaction, TransactionInstruction, TransactionSignature, VersionedTransaction } from '@solana/web3.js';
|
|
4
|
+
import { IWallet } from '../types';
|
|
5
|
+
export declare enum ConfirmationStrategy {
|
|
6
|
+
WebSocket = "websocket",
|
|
7
|
+
Polling = "polling",
|
|
8
|
+
Combo = "combo"
|
|
9
|
+
}
|
|
10
|
+
export type TxSigAndSlot = {
|
|
11
|
+
txSig: TransactionSignature;
|
|
12
|
+
slot: number;
|
|
13
|
+
};
|
|
14
|
+
export interface TxSender {
|
|
15
|
+
wallet: IWallet;
|
|
16
|
+
send(tx: Transaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
|
|
17
|
+
sendVersionedTransaction(tx: VersionedTransaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
|
|
18
|
+
getVersionedTransaction(ixs: TransactionInstruction[], lookupTableAccounts: AddressLookupTableAccount[], additionalSigners?: Array<Signer>, opts?: ConfirmOptions, blockhash?: BlockhashWithExpiryBlockHeight): Promise<VersionedTransaction>;
|
|
19
|
+
sendRawTransaction(rawTransaction: Buffer | Uint8Array, opts: ConfirmOptions): Promise<TxSigAndSlot>;
|
|
20
|
+
simulateTransaction(tx: VersionedTransaction): Promise<boolean>;
|
|
21
|
+
getTimeoutCount(): number;
|
|
22
|
+
getSuggestedPriorityFeeMultiplier(): number;
|
|
23
|
+
getTxLandRate(): number;
|
|
24
|
+
}
|
|
25
|
+
export declare class TxSendError extends Error {
|
|
26
|
+
message: string;
|
|
27
|
+
code: number;
|
|
28
|
+
constructor(message: string, code: number);
|
|
29
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TxSendError = exports.ConfirmationStrategy = void 0;
|
|
4
|
+
var ConfirmationStrategy;
|
|
5
|
+
(function (ConfirmationStrategy) {
|
|
6
|
+
ConfirmationStrategy["WebSocket"] = "websocket";
|
|
7
|
+
ConfirmationStrategy["Polling"] = "polling";
|
|
8
|
+
ConfirmationStrategy["Combo"] = "combo";
|
|
9
|
+
})(ConfirmationStrategy = exports.ConfirmationStrategy || (exports.ConfirmationStrategy = {}));
|
|
10
|
+
class TxSendError extends Error {
|
|
11
|
+
constructor(message, code) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.message = message;
|
|
14
|
+
this.code = code;
|
|
15
|
+
if (Error.captureStackTrace) {
|
|
16
|
+
Error.captureStackTrace(this, TxSendError);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.TxSendError = TxSendError;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isVersionedTransaction = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const isVersionedTransaction = (tx) => {
|
|
6
|
+
const version = tx === null || tx === void 0 ? void 0 : tx.version;
|
|
7
|
+
const isVersionedTx = tx instanceof web3_js_1.VersionedTransaction || version !== undefined;
|
|
8
|
+
return isVersionedTx;
|
|
9
|
+
};
|
|
10
|
+
exports.isVersionedTransaction = isVersionedTransaction;
|