@clonegod/ttd-sol-common 1.0.12 → 1.0.14
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/dist/helius_sdk_v1.4.0/Helius.d.ts +31 -0
- package/dist/helius_sdk_v1.4.0/Helius.js +455 -0
- package/dist/helius_sdk_v1.4.0/RpcClient.d.ts +50 -0
- package/dist/helius_sdk_v1.4.0/RpcClient.js +639 -0
- package/dist/helius_sdk_v1.4.0/constants.d.ts +1 -0
- package/dist/helius_sdk_v1.4.0/constants.js +4 -0
- package/dist/helius_sdk_v1.4.0/index.d.ts +5 -0
- package/dist/helius_sdk_v1.4.0/index.js +21 -0
- package/dist/helius_sdk_v1.4.0/types/das-types.d.ts +408 -0
- package/dist/helius_sdk_v1.4.0/types/das-types.js +2 -0
- package/dist/helius_sdk_v1.4.0/types/enums.d.ts +542 -0
- package/dist/helius_sdk_v1.4.0/types/enums.js +605 -0
- package/dist/helius_sdk_v1.4.0/types/index.d.ts +3 -0
- package/dist/helius_sdk_v1.4.0/types/index.js +19 -0
- package/dist/helius_sdk_v1.4.0/types/types.d.ts +305 -0
- package/dist/helius_sdk_v1.4.0/types/types.js +2 -0
- package/dist/helius_sdk_v1.4.0/utils/get-helius-endpoints.d.ts +2 -0
- package/dist/helius_sdk_v1.4.0/utils/get-helius-endpoints.js +20 -0
- package/dist/helius_sdk_v1.4.0/utils/index.d.ts +1 -0
- package/dist/helius_sdk_v1.4.0/utils/index.js +17 -0
- package/dist/helius_sdk_v1.4.0/utils/mintApi.d.ts +2 -0
- package/dist/helius_sdk_v1.4.0/utils/mintApi.js +15 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +76 -2
- package/package.json +1 -1
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import type { BlockhashWithExpiryBlockHeight, Cluster, Keypair, Transaction, TransactionConfirmationStatus, TransactionError, VersionedTransaction, SendOptions as SolanaWebJsSendOptions } from '@solana/web3.js';
|
|
2
|
+
import type { WebhookType, TokenStandard, TransactionType, Source, ProgramName, TransactionContext, TxnStatus, AccountWebhookEncoding, PriorityLevel, UiTransactionEncoding } from './enums';
|
|
3
|
+
export type HeliusCluster = Omit<Cluster, 'testnet'>;
|
|
4
|
+
export type SmartTransactionContext = {
|
|
5
|
+
transaction: Transaction | VersionedTransaction;
|
|
6
|
+
blockhash: BlockhashWithExpiryBlockHeight;
|
|
7
|
+
minContextSlot: number;
|
|
8
|
+
};
|
|
9
|
+
export interface HeliusEndpoints {
|
|
10
|
+
api: string;
|
|
11
|
+
rpc: string;
|
|
12
|
+
}
|
|
13
|
+
export type HeliusOptions = {
|
|
14
|
+
limit?: number;
|
|
15
|
+
paginationToken?: string;
|
|
16
|
+
};
|
|
17
|
+
export interface Webhook {
|
|
18
|
+
webhookID: string;
|
|
19
|
+
wallet: string;
|
|
20
|
+
project: string;
|
|
21
|
+
webhookURL: string;
|
|
22
|
+
transactionTypes: TransactionType[];
|
|
23
|
+
accountAddresses: string[];
|
|
24
|
+
accountAddressOwners?: string[];
|
|
25
|
+
webhookType?: WebhookType;
|
|
26
|
+
authHeader?: string;
|
|
27
|
+
txnStatus?: TxnStatus;
|
|
28
|
+
encoding?: AccountWebhookEncoding;
|
|
29
|
+
}
|
|
30
|
+
export type CollectionIdentifier = {
|
|
31
|
+
firstVerifiedCreators?: string[];
|
|
32
|
+
verifiedCollectionAddresses?: string[];
|
|
33
|
+
};
|
|
34
|
+
export type CreateWebhookRequest = Omit<Webhook, 'webhookID' | 'wallet' | 'project'>;
|
|
35
|
+
export type EditWebhookRequest = Partial<Omit<Webhook, 'webhookID' | 'wallet' | 'project'>>;
|
|
36
|
+
export interface CreateCollectionWebhookRequest extends CreateWebhookRequest {
|
|
37
|
+
collectionQuery: CollectionIdentifier;
|
|
38
|
+
}
|
|
39
|
+
export interface MintlistResponse {
|
|
40
|
+
result: MintlistItem[];
|
|
41
|
+
paginationToken: string;
|
|
42
|
+
}
|
|
43
|
+
export type MintlistRequest = {
|
|
44
|
+
query: CollectionIdentifier;
|
|
45
|
+
options?: HeliusOptions;
|
|
46
|
+
};
|
|
47
|
+
export interface MintlistItem {
|
|
48
|
+
mint: string;
|
|
49
|
+
name: string;
|
|
50
|
+
}
|
|
51
|
+
export interface RawTokenAmount {
|
|
52
|
+
tokenAmount: string;
|
|
53
|
+
decimals: number;
|
|
54
|
+
}
|
|
55
|
+
export interface TokenBalanceChange {
|
|
56
|
+
userAccount: string;
|
|
57
|
+
tokenAccount: string;
|
|
58
|
+
rawTokenAmount: RawTokenAmount;
|
|
59
|
+
mint: string;
|
|
60
|
+
}
|
|
61
|
+
export interface AccountData {
|
|
62
|
+
account: string;
|
|
63
|
+
nativeBalanceChange: number;
|
|
64
|
+
tokenBalanceChanges: TokenBalanceChange[] | null;
|
|
65
|
+
}
|
|
66
|
+
export interface TokenTransfer {
|
|
67
|
+
fromUserAccount: string | null;
|
|
68
|
+
toUserAccount: string | null;
|
|
69
|
+
fromTokenAccount: string | null;
|
|
70
|
+
toTokenAccount: string | null;
|
|
71
|
+
tokenAmount: number;
|
|
72
|
+
decimals: number;
|
|
73
|
+
tokenStandard: TokenStandard;
|
|
74
|
+
mint: string;
|
|
75
|
+
}
|
|
76
|
+
export interface NativeBalanceChange {
|
|
77
|
+
account: string;
|
|
78
|
+
amount: number;
|
|
79
|
+
}
|
|
80
|
+
export interface NativeTransfer {
|
|
81
|
+
fromUserAccount: string | null;
|
|
82
|
+
toUserAccount: string | null;
|
|
83
|
+
amount: number;
|
|
84
|
+
}
|
|
85
|
+
export type Instruction = {
|
|
86
|
+
accounts: string[];
|
|
87
|
+
data: string;
|
|
88
|
+
programId: string;
|
|
89
|
+
innerInstructions: InnerInstruction[];
|
|
90
|
+
};
|
|
91
|
+
export type InnerInstruction = {
|
|
92
|
+
accounts: string[];
|
|
93
|
+
data: string;
|
|
94
|
+
programId: string;
|
|
95
|
+
};
|
|
96
|
+
export interface ProgramInfo {
|
|
97
|
+
source: Source;
|
|
98
|
+
account: string;
|
|
99
|
+
programName: ProgramName;
|
|
100
|
+
instructionName: string;
|
|
101
|
+
}
|
|
102
|
+
export interface TokenSwap {
|
|
103
|
+
nativeInput: NativeTransfer | null;
|
|
104
|
+
nativeOutput: NativeTransfer | null;
|
|
105
|
+
tokenInputs: TokenTransfer[];
|
|
106
|
+
tokenOutputs: TokenTransfer[];
|
|
107
|
+
tokenFees: TokenTransfer[];
|
|
108
|
+
nativeFees: NativeTransfer[];
|
|
109
|
+
programInfo: ProgramInfo;
|
|
110
|
+
}
|
|
111
|
+
export interface SwapEvent {
|
|
112
|
+
nativeInput: NativeBalanceChange;
|
|
113
|
+
nativeOutput: NativeBalanceChange;
|
|
114
|
+
tokenInputs: TokenBalanceChange[];
|
|
115
|
+
tokenOutputs: TokenBalanceChange[];
|
|
116
|
+
tokenFees: TokenBalanceChange[];
|
|
117
|
+
nativeFees: NativeBalanceChange[];
|
|
118
|
+
innerSwaps: TokenSwap[];
|
|
119
|
+
}
|
|
120
|
+
export interface CompressedNftCreator {
|
|
121
|
+
address: string;
|
|
122
|
+
share: number;
|
|
123
|
+
verified: boolean;
|
|
124
|
+
}
|
|
125
|
+
export interface CompressedNftMetadata {
|
|
126
|
+
collection: {
|
|
127
|
+
key: string;
|
|
128
|
+
verified: boolean;
|
|
129
|
+
};
|
|
130
|
+
creators: CompressedNftCreator[];
|
|
131
|
+
isMutable: boolean;
|
|
132
|
+
name: string;
|
|
133
|
+
primarySaleHappened: boolean;
|
|
134
|
+
sellerFeeBasisPoints: number;
|
|
135
|
+
symbol: string;
|
|
136
|
+
tokenProgramVersion: string;
|
|
137
|
+
tokenStandard: TokenStandard;
|
|
138
|
+
uri: string;
|
|
139
|
+
}
|
|
140
|
+
export interface CompressedNftEvent {
|
|
141
|
+
type: TransactionType;
|
|
142
|
+
treeId: string;
|
|
143
|
+
leafIndex: number | null;
|
|
144
|
+
seq: number | null;
|
|
145
|
+
assetId: string | null;
|
|
146
|
+
instructionIndex: number | null;
|
|
147
|
+
innerInstructionIndex: number | null;
|
|
148
|
+
newLeafOwner: string | null;
|
|
149
|
+
oldLeafOwner: string | null;
|
|
150
|
+
newLeafDelegate: string | null;
|
|
151
|
+
oldLeafDelegate: string | null;
|
|
152
|
+
treeDelegate: string | null;
|
|
153
|
+
metadata: CompressedNftMetadata | null;
|
|
154
|
+
}
|
|
155
|
+
export interface Token {
|
|
156
|
+
mint: string;
|
|
157
|
+
tokenStandard: TokenStandard;
|
|
158
|
+
}
|
|
159
|
+
export interface NFTEvent {
|
|
160
|
+
seller: string;
|
|
161
|
+
buyer: string;
|
|
162
|
+
timestamp: number;
|
|
163
|
+
amount: number;
|
|
164
|
+
fee: number;
|
|
165
|
+
signature: string;
|
|
166
|
+
source: Source;
|
|
167
|
+
type: TransactionType;
|
|
168
|
+
saleType?: TransactionContext;
|
|
169
|
+
nfts: Token[];
|
|
170
|
+
}
|
|
171
|
+
export interface TransactionEvent {
|
|
172
|
+
nft: NFTEvent | null;
|
|
173
|
+
swap: SwapEvent | null;
|
|
174
|
+
compressed: CompressedNftEvent[] | null;
|
|
175
|
+
}
|
|
176
|
+
export interface EnrichedTransaction {
|
|
177
|
+
description: string;
|
|
178
|
+
type: TransactionType;
|
|
179
|
+
source: Source;
|
|
180
|
+
fee: number;
|
|
181
|
+
feePayer: string;
|
|
182
|
+
signature: string;
|
|
183
|
+
slot: number;
|
|
184
|
+
timestamp: number;
|
|
185
|
+
nativeTransfers: NativeTransfer[] | null;
|
|
186
|
+
tokenTransfers: TokenTransfer[] | null;
|
|
187
|
+
accountData: AccountData[];
|
|
188
|
+
transactionError: TransactionError | null;
|
|
189
|
+
instructions: Instruction[];
|
|
190
|
+
events: TransactionEvent;
|
|
191
|
+
}
|
|
192
|
+
export interface MintApiRequest {
|
|
193
|
+
name: string;
|
|
194
|
+
symbol: string;
|
|
195
|
+
description?: string;
|
|
196
|
+
owner: string;
|
|
197
|
+
delegate?: string;
|
|
198
|
+
collection?: string;
|
|
199
|
+
creators?: {
|
|
200
|
+
address: string;
|
|
201
|
+
share: number;
|
|
202
|
+
}[];
|
|
203
|
+
uri?: string;
|
|
204
|
+
sellerFeeBasisPoints?: number;
|
|
205
|
+
imageUrl?: string;
|
|
206
|
+
externalUrl?: string;
|
|
207
|
+
attributes?: {
|
|
208
|
+
trait_type: string;
|
|
209
|
+
value: string;
|
|
210
|
+
}[];
|
|
211
|
+
imagePath?: string;
|
|
212
|
+
walletPrivateKey?: string;
|
|
213
|
+
}
|
|
214
|
+
export interface MintApiResponse {
|
|
215
|
+
jsonrpc: string;
|
|
216
|
+
id: string;
|
|
217
|
+
result: {
|
|
218
|
+
signature: string;
|
|
219
|
+
minted: boolean;
|
|
220
|
+
assetId: string;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
export interface DelegateCollectionAuthorityRequest {
|
|
224
|
+
collectionMint: string;
|
|
225
|
+
newCollectionAuthority?: string;
|
|
226
|
+
updateAuthorityKeypair: Keypair;
|
|
227
|
+
payerKeypair?: Keypair;
|
|
228
|
+
}
|
|
229
|
+
export interface RevokeCollectionAuthorityRequest {
|
|
230
|
+
collectionMint: string;
|
|
231
|
+
delegatedCollectionAuthority?: string;
|
|
232
|
+
revokeAuthorityKeypair: Keypair;
|
|
233
|
+
payerKeypair?: Keypair;
|
|
234
|
+
}
|
|
235
|
+
interface AssetControllerAccount {
|
|
236
|
+
address: string;
|
|
237
|
+
mint: string;
|
|
238
|
+
authority: string;
|
|
239
|
+
delegate: string;
|
|
240
|
+
version: number;
|
|
241
|
+
closed: boolean;
|
|
242
|
+
}
|
|
243
|
+
interface DataRegistryAccount {
|
|
244
|
+
address: string;
|
|
245
|
+
mint: string;
|
|
246
|
+
version: number;
|
|
247
|
+
closed: boolean;
|
|
248
|
+
}
|
|
249
|
+
interface IdentityRegistryAccount {
|
|
250
|
+
address: string;
|
|
251
|
+
mint: string;
|
|
252
|
+
authority: string;
|
|
253
|
+
delegate: string;
|
|
254
|
+
version: number;
|
|
255
|
+
closed: boolean;
|
|
256
|
+
}
|
|
257
|
+
interface PolicyEngine {
|
|
258
|
+
address: string;
|
|
259
|
+
mint: string;
|
|
260
|
+
authority: string;
|
|
261
|
+
delegate: string;
|
|
262
|
+
policies: string[];
|
|
263
|
+
version: number;
|
|
264
|
+
closed: boolean;
|
|
265
|
+
}
|
|
266
|
+
export interface FullRwaAccount {
|
|
267
|
+
asset_controller?: AssetControllerAccount;
|
|
268
|
+
data_registry?: DataRegistryAccount;
|
|
269
|
+
identity_registry?: IdentityRegistryAccount;
|
|
270
|
+
policy_engine?: PolicyEngine;
|
|
271
|
+
}
|
|
272
|
+
export interface GetPriorityFeeEstimateOptions {
|
|
273
|
+
priorityLevel?: PriorityLevel;
|
|
274
|
+
includeAllPriorityFeeLevels?: boolean;
|
|
275
|
+
transactionEncoding?: UiTransactionEncoding;
|
|
276
|
+
lookbackSlots?: number;
|
|
277
|
+
recommended?: boolean;
|
|
278
|
+
}
|
|
279
|
+
export interface GetPriorityFeeEstimateRequest {
|
|
280
|
+
transaction?: string;
|
|
281
|
+
accountKeys?: string[];
|
|
282
|
+
options?: GetPriorityFeeEstimateOptions;
|
|
283
|
+
}
|
|
284
|
+
export interface MicroLamportPriorityFeeLevels {
|
|
285
|
+
min: number;
|
|
286
|
+
low: number;
|
|
287
|
+
medium: number;
|
|
288
|
+
high: number;
|
|
289
|
+
veryHigh: number;
|
|
290
|
+
unsafeMax: number;
|
|
291
|
+
}
|
|
292
|
+
export interface GetPriorityFeeEstimateResponse {
|
|
293
|
+
priorityFeeEstimate?: number;
|
|
294
|
+
priorityFeeLevels?: MicroLamportPriorityFeeLevels;
|
|
295
|
+
}
|
|
296
|
+
export type JitoRegion = 'Default' | 'NY' | 'Amsterdam' | 'Frankfurt' | 'Tokyo';
|
|
297
|
+
export type PollTransactionOptions = {
|
|
298
|
+
confirmationStatuses?: TransactionConfirmationStatus[];
|
|
299
|
+
timeout?: number;
|
|
300
|
+
interval?: number;
|
|
301
|
+
};
|
|
302
|
+
export interface HeliusSendOptions extends SolanaWebJsSendOptions {
|
|
303
|
+
validatorAcls?: string[];
|
|
304
|
+
}
|
|
305
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHeliusEndpoints = void 0;
|
|
4
|
+
function getHeliusEndpoints(cluster) {
|
|
5
|
+
switch (cluster) {
|
|
6
|
+
case 'devnet':
|
|
7
|
+
return {
|
|
8
|
+
api: 'https://api-devnet.helius-rpc.com',
|
|
9
|
+
rpc: 'https://devnet.helius-rpc.com',
|
|
10
|
+
};
|
|
11
|
+
case 'mainnet-beta':
|
|
12
|
+
return {
|
|
13
|
+
api: 'https://api-mainnet.helius-rpc.com',
|
|
14
|
+
rpc: 'https://mainnet.helius-rpc.com',
|
|
15
|
+
};
|
|
16
|
+
default:
|
|
17
|
+
throw new Error(`Unknown cluster ${cluster}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.getHeliusEndpoints = getHeliusEndpoints;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './get-helius-endpoints';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./get-helius-endpoints"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mintApiAuthority = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
function mintApiAuthority(cluster) {
|
|
6
|
+
switch (cluster) {
|
|
7
|
+
case 'devnet':
|
|
8
|
+
return types_1.MintApiAuthority.DEVNET;
|
|
9
|
+
case 'mainnet-beta':
|
|
10
|
+
return types_1.MintApiAuthority.MAINNET;
|
|
11
|
+
default:
|
|
12
|
+
throw new Error('Invalid cluster');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.mintApiAuthority = mintApiAuthority;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { StandardPoolInfoType } from '@clonegod/ttd-common';
|
|
4
|
+
import { Helius, JitoRegion } from "helius-sdk";
|
|
5
|
+
import { TransactionInstruction, Signer, SendOptions, TransactionSignature } from "@solana/web3.js";
|
|
4
6
|
export declare const ONE_SOL_IN_LAMPORTS = 1000000000;
|
|
5
7
|
export declare enum COMMITMENT_LEVEL {
|
|
6
8
|
PROCESSED = "processed",
|
|
@@ -11,3 +13,15 @@ export declare enum LOCAL_EVENT_NAME {
|
|
|
11
13
|
EVENT_POOL_ACCOUNT_CHANGE = "EVENT_POOL_ACCOUNT_CHANGE"
|
|
12
14
|
}
|
|
13
15
|
export declare const subscribe_pool_change_by_geyser: (geyser_ws_url: string, pool_list: StandardPoolInfoType[], eventEmitter: EventEmitter) => Promise<void>;
|
|
16
|
+
export declare class HeliusClient {
|
|
17
|
+
helius_mainnet: Helius;
|
|
18
|
+
helius_staked: Helius;
|
|
19
|
+
helius_qn: Helius;
|
|
20
|
+
signers: Signer[];
|
|
21
|
+
sendOptions: SendOptions;
|
|
22
|
+
jito_tip_max: number;
|
|
23
|
+
constructor(signers: Signer[], jito_tip_max?: number);
|
|
24
|
+
send_smart_transaction(instructions: TransactionInstruction[], use_staked_endpint?: boolean): Promise<string>;
|
|
25
|
+
send_transaction_by_jito(instructions: TransactionInstruction[], tipAmount: number): Promise<TransactionSignature>;
|
|
26
|
+
}
|
|
27
|
+
export declare const get_jito_region: () => JitoRegion;
|
package/dist/index.js
CHANGED
|
@@ -12,10 +12,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.subscribe_pool_change_by_geyser = exports.LOCAL_EVENT_NAME = exports.COMMITMENT_LEVEL = exports.ONE_SOL_IN_LAMPORTS = void 0;
|
|
15
|
+
exports.get_jito_region = exports.HeliusClient = exports.subscribe_pool_change_by_geyser = exports.LOCAL_EVENT_NAME = exports.COMMITMENT_LEVEL = exports.ONE_SOL_IN_LAMPORTS = void 0;
|
|
16
16
|
const ws_1 = __importDefault(require("ws"));
|
|
17
17
|
const dist_1 = require("@clonegod/ttd-common/dist");
|
|
18
|
-
|
|
18
|
+
const helius_sdk_1 = require("helius-sdk");
|
|
19
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
20
|
+
exports.ONE_SOL_IN_LAMPORTS = web3_js_1.LAMPORTS_PER_SOL;
|
|
19
21
|
var COMMITMENT_LEVEL;
|
|
20
22
|
(function (COMMITMENT_LEVEL) {
|
|
21
23
|
COMMITMENT_LEVEL["PROCESSED"] = "processed";
|
|
@@ -101,3 +103,75 @@ const subscribe_pool_change_by_geyser = (geyser_ws_url, pool_list, eventEmitter)
|
|
|
101
103
|
});
|
|
102
104
|
});
|
|
103
105
|
exports.subscribe_pool_change_by_geyser = subscribe_pool_change_by_geyser;
|
|
106
|
+
class HeliusClient {
|
|
107
|
+
constructor(signers, jito_tip_max = 500000) {
|
|
108
|
+
let helius_api_key = process.env.HELIUS_API_KEY;
|
|
109
|
+
let helius_mainnet_endpoint = `https://mainnet.helius-rpc.com/?api-key=${helius_api_key}`;
|
|
110
|
+
let helius_staked_endpoint = `https://staked.helius-rpc.com?api-key=${helius_api_key}`;
|
|
111
|
+
let quicknode_endpoint = process.env.QUICKNODE_ENDPOINT;
|
|
112
|
+
this.helius_mainnet = new helius_sdk_1.Helius(null, null, null, helius_mainnet_endpoint);
|
|
113
|
+
this.helius_staked = new helius_sdk_1.Helius(null, null, null, helius_staked_endpoint);
|
|
114
|
+
this.helius_qn = new helius_sdk_1.Helius(null, null, null, quicknode_endpoint);
|
|
115
|
+
this.signers = signers;
|
|
116
|
+
this.sendOptions = {
|
|
117
|
+
skipPreflight: true,
|
|
118
|
+
maxRetries: 0
|
|
119
|
+
};
|
|
120
|
+
this.jito_tip_max = jito_tip_max;
|
|
121
|
+
}
|
|
122
|
+
send_smart_transaction(instructions_1) {
|
|
123
|
+
return __awaiter(this, arguments, void 0, function* (instructions, use_staked_endpint = false) {
|
|
124
|
+
(0, dist_1.log_info)(`send_smart_transaction, start`);
|
|
125
|
+
let start_time = Date.now();
|
|
126
|
+
let rpc = use_staked_endpint ? this.helius_staked.rpc : this.helius_mainnet.rpc;
|
|
127
|
+
let txid = yield rpc.sendSmartTransaction(instructions, this.signers, [], this.sendOptions);
|
|
128
|
+
(0, dist_1.log_info)(`send_smart_transaction, end`, {
|
|
129
|
+
txid,
|
|
130
|
+
use_staked_endpint,
|
|
131
|
+
take_time: Date.now() - start_time
|
|
132
|
+
});
|
|
133
|
+
return txid;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
send_transaction_by_jito(instructions, tipAmount) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
if (tipAmount > this.jito_tip_max) {
|
|
139
|
+
tipAmount = this.jito_tip_max;
|
|
140
|
+
(0, dist_1.log_warn)(`tipAmount too high!!! reset from ${tipAmount} to ${this.jito_tip_max}`);
|
|
141
|
+
}
|
|
142
|
+
(0, dist_1.log_info)(`send_transaction_by_jito, start`);
|
|
143
|
+
let start_time = Date.now();
|
|
144
|
+
let rpc = this.helius_qn.rpc;
|
|
145
|
+
let txid = yield rpc.sendSmartTransactionWithTip(instructions, this.signers, [], tipAmount, (0, exports.get_jito_region)());
|
|
146
|
+
(0, dist_1.log_info)(`send_transaction_by_jito, end`, {
|
|
147
|
+
txid,
|
|
148
|
+
take_time: Date.now() - start_time
|
|
149
|
+
});
|
|
150
|
+
return txid;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.HeliusClient = HeliusClient;
|
|
155
|
+
const get_jito_region = () => {
|
|
156
|
+
let jito_region;
|
|
157
|
+
let server_info = (0, dist_1.getServerInfo)();
|
|
158
|
+
switch (server_info.region) {
|
|
159
|
+
case 'fra':
|
|
160
|
+
jito_region = 'Frankfurt';
|
|
161
|
+
break;
|
|
162
|
+
case 'virginia':
|
|
163
|
+
jito_region = 'NY';
|
|
164
|
+
break;
|
|
165
|
+
case 'jp':
|
|
166
|
+
jito_region = 'Tokyo';
|
|
167
|
+
break;
|
|
168
|
+
default:
|
|
169
|
+
jito_region = 'Default';
|
|
170
|
+
}
|
|
171
|
+
(0, dist_1.log_debug)(`get_jito_region`, {
|
|
172
|
+
server_info,
|
|
173
|
+
jito_region
|
|
174
|
+
});
|
|
175
|
+
return jito_region;
|
|
176
|
+
};
|
|
177
|
+
exports.get_jito_region = get_jito_region;
|