@clonegod/ttd-sol-common 1.2.1 → 2.0.1

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.
Files changed (101) hide show
  1. package/dist/index.d.ts +0 -6
  2. package/dist/index.js +0 -6
  3. package/dist/quote/index.d.ts +1 -3
  4. package/dist/quote/index.js +1 -3
  5. package/dist/quote/pricing/index.d.ts +1 -0
  6. package/dist/{helius_sdk_v1.4.0/utils → quote/pricing}/index.js +1 -1
  7. package/dist/quote/pricing/token_price_cache.d.ts +9 -0
  8. package/dist/quote/pricing/token_price_cache.js +39 -0
  9. package/package.json +2 -3
  10. package/src/index.ts +1 -0
  11. package/src/quote/index.ts +1 -0
  12. package/src/quote/pricing/index.ts +1 -0
  13. package/src/quote/pricing/token_price_cache.ts +48 -0
  14. package/tsconfig.json +22 -0
  15. package/dist/appconfig/app_config.d.ts +0 -23
  16. package/dist/appconfig/app_config.js +0 -134
  17. package/dist/appconfig/env_args.d.ts +0 -27
  18. package/dist/appconfig/env_args.js +0 -39
  19. package/dist/appconfig/index.d.ts +0 -2
  20. package/dist/appconfig/index.js +0 -18
  21. package/dist/common/constants.d.ts +0 -12
  22. package/dist/common/constants.js +0 -18
  23. package/dist/common/context.d.ts +0 -23
  24. package/dist/common/context.js +0 -51
  25. package/dist/common/index.d.ts +0 -2
  26. package/dist/common/index.js +0 -18
  27. package/dist/helius_geyser_ws/index.d.ts +0 -3
  28. package/dist/helius_geyser_ws/index.js +0 -19
  29. package/dist/helius_geyser_ws/subscribe_pool_change_by_geyser.d.ts +0 -3
  30. package/dist/helius_geyser_ws/subscribe_pool_change_by_geyser.js +0 -102
  31. package/dist/helius_geyser_ws/subscribe_txid.d.ts +0 -2
  32. package/dist/helius_geyser_ws/subscribe_txid.js +0 -109
  33. package/dist/helius_geyser_ws/subscribe_wallet_transaction.d.ts +0 -2
  34. package/dist/helius_geyser_ws/subscribe_wallet_transaction.js +0 -102
  35. package/dist/helius_sdk_v1.4.0/Helius.d.ts +0 -31
  36. package/dist/helius_sdk_v1.4.0/Helius.js +0 -450
  37. package/dist/helius_sdk_v1.4.0/RpcClient.d.ts +0 -70
  38. package/dist/helius_sdk_v1.4.0/RpcClient.js +0 -978
  39. package/dist/helius_sdk_v1.4.0/constants.d.ts +0 -1
  40. package/dist/helius_sdk_v1.4.0/constants.js +0 -4
  41. package/dist/helius_sdk_v1.4.0/index.d.ts +0 -5
  42. package/dist/helius_sdk_v1.4.0/index.js +0 -21
  43. package/dist/helius_sdk_v1.4.0/types/das-types.d.ts +0 -408
  44. package/dist/helius_sdk_v1.4.0/types/das-types.js +0 -2
  45. package/dist/helius_sdk_v1.4.0/types/enums.d.ts +0 -542
  46. package/dist/helius_sdk_v1.4.0/types/enums.js +0 -606
  47. package/dist/helius_sdk_v1.4.0/types/index.d.ts +0 -3
  48. package/dist/helius_sdk_v1.4.0/types/index.js +0 -19
  49. package/dist/helius_sdk_v1.4.0/types/types.d.ts +0 -305
  50. package/dist/helius_sdk_v1.4.0/types/types.js +0 -2
  51. package/dist/helius_sdk_v1.4.0/utils/get-helius-endpoints.d.ts +0 -2
  52. package/dist/helius_sdk_v1.4.0/utils/get-helius-endpoints.js +0 -19
  53. package/dist/helius_sdk_v1.4.0/utils/index.d.ts +0 -1
  54. package/dist/helius_sdk_v1.4.0/utils/mintApi.d.ts +0 -2
  55. package/dist/helius_sdk_v1.4.0/utils/mintApi.js +0 -14
  56. package/dist/jito/index.d.ts +0 -14
  57. package/dist/jito/index.js +0 -142
  58. package/dist/jito/jitodontfront.d.ts +0 -5
  59. package/dist/jito/jitodontfront.js +0 -41
  60. package/dist/quote/log_quote_price.d.ts +0 -2
  61. package/dist/quote/log_quote_price.js +0 -29
  62. package/dist/quote/publish_quote_price.d.ts +0 -3
  63. package/dist/quote/publish_quote_price.js +0 -19
  64. package/dist/quote/to_price_message.d.ts +0 -5
  65. package/dist/quote/to_price_message.js +0 -103
  66. package/dist/send_tx/get_jito_tip_floor.d.ts +0 -1
  67. package/dist/send_tx/get_jito_tip_floor.js +0 -86
  68. package/dist/send_tx/get_signature.d.ts +0 -2
  69. package/dist/send_tx/get_signature.js +0 -17
  70. package/dist/send_tx/helius_client.d.ts +0 -16
  71. package/dist/send_tx/helius_client.js +0 -119
  72. package/dist/send_tx/index.d.ts +0 -4
  73. package/dist/send_tx/index.js +0 -20
  74. package/dist/send_tx/notify_new_txid.d.ts +0 -1
  75. package/dist/send_tx/notify_new_txid.js +0 -20
  76. package/dist/send_tx/sol_gas_cache.d.ts +0 -3
  77. package/dist/send_tx/sol_gas_cache.js +0 -15
  78. package/dist/send_tx/strategy_util.d.ts +0 -7
  79. package/dist/send_tx/strategy_util.js +0 -147
  80. package/dist/token/get_token_info.d.ts +0 -4
  81. package/dist/token/get_token_info.js +0 -136
  82. package/dist/token/get_token_price.d.ts +0 -6
  83. package/dist/token/get_token_price.js +0 -186
  84. package/dist/token/index.d.ts +0 -4
  85. package/dist/token/index.js +0 -20
  86. package/dist/token/types.d.ts +0 -17
  87. package/dist/token/types.js +0 -2
  88. package/dist/token/util.d.ts +0 -3
  89. package/dist/token/util.js +0 -33
  90. package/dist/trade/abstract_trade.d.ts +0 -5
  91. package/dist/trade/abstract_trade.js +0 -6
  92. package/dist/trade/handle_order_message.d.ts +0 -4
  93. package/dist/trade/handle_order_message.js +0 -118
  94. package/dist/trade/index.d.ts +0 -4
  95. package/dist/trade/index.js +0 -20
  96. package/dist/trade/tx_result_check.d.ts +0 -29
  97. package/dist/trade/tx_result_check.js +0 -232
  98. package/dist/trade/tx_result_parse.d.ts +0 -13
  99. package/dist/trade/tx_result_parse.js +0 -150
  100. package/grpc/transaction/LThcUp2D5p4JgRMnWEUVVSdNEHiq5YfN5HXPGRYeWBfypMT3aTa1CaC9XdPT69CyMdoJ32XAkjXAa2TmBYBeZAy.json +0 -1
  101. package/types/index.d.ts +0 -71
@@ -1,102 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.subscribe_pool_change_by_geyser = void 0;
16
- const dist_1 = require("@clonegod/ttd-core/dist");
17
- const ws_1 = __importDefault(require("ws"));
18
- const constants_1 = require("../common/constants");
19
- const subscribe_pool_change_by_geyser = (geyser_ws_url, pool_list, eventEmitter) => __awaiter(void 0, void 0, void 0, function* () {
20
- if ((0, dist_1.isEmpty)(geyser_ws_url)) {
21
- (0, dist_1.log_warn)(`geyser_ws_url is empty, cann't subscribe`);
22
- return;
23
- }
24
- if ((0, dist_1.isEmpty)(pool_list)) {
25
- (0, dist_1.log_warn)(`pool_list is empty, nothing to subscribe`);
26
- return;
27
- }
28
- yield (0, dist_1.sleep)(1000);
29
- var ws_client = new ws_1.default(geyser_ws_url);
30
- function subscribe_account_change(ws_client, pool) {
31
- (0, dist_1.log_info)(`subscribe: ${pool.pool_name} -> ${pool.pool_address}`);
32
- const request = {
33
- jsonrpc: '2.0',
34
- id: 420,
35
- method: 'accountSubscribe',
36
- params: [
37
- pool.pool_address,
38
- {
39
- encoding: 'jsonParsed',
40
- commitment: constants_1.COMMITMENT_LEVEL.PROCESSED,
41
- },
42
- ],
43
- };
44
- ws_client.send(JSON.stringify(request));
45
- }
46
- function startPing(ws) {
47
- setInterval(() => {
48
- if (ws.readyState === ws_1.default.OPEN) {
49
- ws.ping();
50
- (0, dist_1.log_debug)('Ping helius ws server');
51
- }
52
- }, 30000);
53
- }
54
- ws_client.on('open', function open() {
55
- (0, dist_1.log_info)(`WebSocket is open`);
56
- pool_list.forEach((pool) => {
57
- subscribe_account_change(ws_client, pool);
58
- });
59
- startPing(ws_client);
60
- });
61
- ws_client.on('message', function incoming(data) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- (0, dist_1.log_info)(`Received Geyser Message`);
64
- let messageStr = '';
65
- try {
66
- messageStr = data.toString('utf8');
67
- if (dist_1.LOG.trace) {
68
- (0, dist_1.log_trace)(`Received msg:`, messageStr);
69
- }
70
- if (messageStr == '{}') {
71
- (0, dist_1.log_info)(`receive empty message, something wrong! exit ...`);
72
- ws_client.close();
73
- }
74
- const messageObj = JSON.parse(messageStr);
75
- if (messageObj['id']) {
76
- (0, dist_1.log_info)(`accountSubscribe success!`, messageStr);
77
- return;
78
- }
79
- else {
80
- const res_data = messageObj['params']['result']['value']['data'];
81
- let data_buff = Buffer.from(res_data[0], res_data[1]);
82
- eventEmitter.emit(constants_1.LOCAL_EVENT_NAME.EVENT_POOL_ACCOUNT_CHANGE, data_buff);
83
- }
84
- }
85
- catch (err) {
86
- (0, dist_1.log_error)(`Failed to parse JSON: ${messageStr}`, err);
87
- ws_client.close();
88
- }
89
- });
90
- });
91
- ws_client.on('error', function error(err) {
92
- (0, dist_1.log_error)(`WebSocket error:`, err);
93
- ws_client.close();
94
- });
95
- ws_client.on('close', function close() {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- (0, dist_1.log_warn)(`Socket is closed. Reconnect will be attempted in few seconds`);
98
- (0, exports.subscribe_pool_change_by_geyser)(geyser_ws_url, pool_list, eventEmitter);
99
- });
100
- });
101
- });
102
- exports.subscribe_pool_change_by_geyser = subscribe_pool_change_by_geyser;
@@ -1,2 +0,0 @@
1
- import EventEmitter from "events";
2
- export declare const subscribe_wallet_transaction_txid: (geyser_ws_url: string, wallet_address: string, signature: string, eventEmitter: EventEmitter) => Promise<void>;
@@ -1,109 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.subscribe_wallet_transaction_txid = void 0;
16
- const dist_1 = require("@clonegod/ttd-core/dist");
17
- const ws_1 = __importDefault(require("ws"));
18
- const constants_1 = require("../common/constants");
19
- const subscribe_wallet_transaction_txid = (geyser_ws_url, wallet_address, signature, eventEmitter) => __awaiter(void 0, void 0, void 0, function* () {
20
- if ((0, dist_1.isEmpty)(geyser_ws_url)) {
21
- (0, dist_1.log_warn)(`geyser_ws_url is empty, cann't subscribe`);
22
- return;
23
- }
24
- if ((0, dist_1.isEmpty)(signature)) {
25
- (0, dist_1.log_warn)(`signature is empty, nothing to subscribe`);
26
- return;
27
- }
28
- var ws_client = new ws_1.default(geyser_ws_url);
29
- function subscribe_transaction_by_txid() {
30
- (0, dist_1.log_info)(`subscribe_transaction_by_txid`, {
31
- wallet_address,
32
- signature
33
- });
34
- const request = {
35
- jsonrpc: '2.0',
36
- id: 420,
37
- method: 'transactionSubscribe',
38
- params: [
39
- {
40
- accountRequired: [wallet_address],
41
- signature: signature,
42
- },
43
- {
44
- commitment: constants_1.COMMITMENT_LEVEL.PROCESSED,
45
- encoding: 'base64',
46
- transactionDetails: 'full',
47
- showRewards: true,
48
- maxSupportedTransactionVersion: 0,
49
- },
50
- ],
51
- };
52
- ws_client.send(JSON.stringify(request));
53
- }
54
- setTimeout(() => {
55
- ws_client.close();
56
- (0, dist_1.log_debug)('subscribe_transaction_by_txid, close helius ws conn');
57
- }, 30000);
58
- function startPing(ws) {
59
- setInterval(() => {
60
- if (ws.readyState === ws_1.default.OPEN) {
61
- ws.ping();
62
- (0, dist_1.log_debug)('Ping helius ws server');
63
- }
64
- }, 30000);
65
- }
66
- ws_client.on('open', function open() {
67
- (0, dist_1.log_info)(`WebSocket is open`);
68
- subscribe_transaction_by_txid();
69
- });
70
- ws_client.on('message', function incoming(data) {
71
- return __awaiter(this, void 0, void 0, function* () {
72
- const messageStr = data.toString('utf8');
73
- (0, dist_1.log_debug)('[helius-subscribe-tx] Received:', messageStr);
74
- try {
75
- if (messageStr == '{}' || messageStr.includes('INTERNAL_ERROR')) {
76
- console.error('[helius-subscribe-tx] receive bad message, something wrong! reconnect ...');
77
- subscribe_transaction_by_txid();
78
- return;
79
- }
80
- const messageObj = JSON.parse(messageStr);
81
- const { method } = messageObj;
82
- if (method === 'transactionNotification') {
83
- if (messageObj.params.error) {
84
- throw new Error(messageObj.params.error);
85
- }
86
- const result = messageObj.params.result;
87
- const txid = result.signature;
88
- const eventName = constants_1.LOCAL_EVENT_NAME.EVENT_WALLET_TRANSACTION + '#' + txid;
89
- eventEmitter.emit(eventName, messageStr);
90
- ws_client.close();
91
- }
92
- }
93
- catch (e) {
94
- (0, dist_1.log_error)(`[helius-subscribe-tx] Failed to parse JSON: ${messageStr}`, e);
95
- ws_client.close();
96
- }
97
- });
98
- });
99
- ws_client.on('error', function error(err) {
100
- (0, dist_1.log_error)(`WebSocket error:`, err);
101
- ws_client.close();
102
- });
103
- ws_client.on('close', function close() {
104
- return __awaiter(this, void 0, void 0, function* () {
105
- (0, dist_1.log_warn)(`Socket is closed.`);
106
- });
107
- });
108
- });
109
- exports.subscribe_wallet_transaction_txid = subscribe_wallet_transaction_txid;
@@ -1,2 +0,0 @@
1
- import EventEmitter from "events";
2
- export declare const subscribe_wallet_transaction: (geyser_ws_url: string, wallet_token_account_list: string[], eventEmitter: EventEmitter) => Promise<void>;
@@ -1,102 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.subscribe_wallet_transaction = void 0;
16
- const dist_1 = require("@clonegod/ttd-core/dist");
17
- const ws_1 = __importDefault(require("ws"));
18
- const constants_1 = require("../common/constants");
19
- const subscribe_wallet_transaction = (geyser_ws_url, wallet_token_account_list, eventEmitter) => __awaiter(void 0, void 0, void 0, function* () {
20
- if ((0, dist_1.isEmpty)(geyser_ws_url)) {
21
- (0, dist_1.log_warn)(`geyser_ws_url is empty, cann't subscribe`);
22
- return;
23
- }
24
- if ((0, dist_1.isEmpty)(wallet_token_account_list)) {
25
- (0, dist_1.log_warn)(`user_token_account_list is empty, nothing to subscribe`);
26
- return;
27
- }
28
- yield (0, dist_1.sleep)(parseInt(process.env.SUBSCRIBE_WS_WAIT_SECONDS || '3000'));
29
- var ws_client = new ws_1.default(geyser_ws_url);
30
- function subscribe_account_transaction() {
31
- (0, dist_1.log_info)(`subscribe_account_transaction`, wallet_token_account_list);
32
- const request = {
33
- jsonrpc: '2.0',
34
- id: 420,
35
- method: 'transactionSubscribe',
36
- params: [
37
- {
38
- accountInclude: wallet_token_account_list,
39
- },
40
- {
41
- commitment: constants_1.COMMITMENT_LEVEL.PROCESSED,
42
- encoding: 'base64',
43
- transactionDetails: 'full',
44
- showRewards: true,
45
- maxSupportedTransactionVersion: 0,
46
- },
47
- ],
48
- };
49
- ws_client.send(JSON.stringify(request));
50
- }
51
- function startPing(ws) {
52
- setInterval(() => {
53
- if (ws.readyState === ws_1.default.OPEN) {
54
- ws.ping();
55
- (0, dist_1.log_debug)('Ping helius ws server');
56
- }
57
- }, 30000);
58
- }
59
- ws_client.on('open', function open() {
60
- (0, dist_1.log_info)(`WebSocket is open`);
61
- subscribe_account_transaction();
62
- startPing(ws_client);
63
- });
64
- ws_client.on('message', function incoming(data) {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- const messageStr = data.toString('utf8');
67
- (0, dist_1.log_debug)('[helius-subscribe-tx] Received:', messageStr);
68
- try {
69
- if (messageStr == '{}' || messageStr.includes('INTERNAL_ERROR')) {
70
- console.error('[helius-subscribe-tx] receive bad message, something wrong! reconnect ...');
71
- ws_client.close();
72
- }
73
- const messageObj = JSON.parse(messageStr);
74
- const { method } = messageObj;
75
- if (method === 'transactionNotification') {
76
- if (messageObj.params.error) {
77
- throw new Error(messageObj.params.error);
78
- }
79
- const result = messageObj.params.result;
80
- const txid = result.signature;
81
- const eventName = constants_1.LOCAL_EVENT_NAME.EVENT_WALLET_TRANSACTION + '#' + txid;
82
- eventEmitter.emit(eventName, messageStr);
83
- }
84
- }
85
- catch (e) {
86
- (0, dist_1.log_error)(`[helius-subscribe-tx] Failed to parse JSON: ${messageStr}`, e);
87
- ws_client.close();
88
- }
89
- });
90
- });
91
- ws_client.on('error', function error(err) {
92
- (0, dist_1.log_error)(`WebSocket error:`, err);
93
- ws_client.close();
94
- });
95
- ws_client.on('close', function close() {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- (0, dist_1.log_warn)(`Socket is closed. Reconnect will be attempted in few seconds`);
98
- (0, exports.subscribe_wallet_transaction)(geyser_ws_url, wallet_token_account_list, eventEmitter);
99
- });
100
- });
101
- });
102
- exports.subscribe_wallet_transaction = subscribe_wallet_transaction;
@@ -1,31 +0,0 @@
1
- import { Webhook, CreateWebhookRequest, EditWebhookRequest, CreateCollectionWebhookRequest, MintlistRequest, MintlistResponse, MintApiRequest, MintApiResponse, MintApiAuthority, DelegateCollectionAuthorityRequest, RevokeCollectionAuthorityRequest, HeliusCluster, HeliusEndpoints } from './types';
2
- import { Connection } from '@solana/web3.js';
3
- import { RpcClient } from './RpcClient';
4
- export declare class Helius {
5
- private apiKey?;
6
- readonly cluster: HeliusCluster;
7
- readonly endpoint: string;
8
- readonly endpoints: HeliusEndpoints;
9
- readonly connection: Connection;
10
- readonly rpc: RpcClient;
11
- readonly mintApiAuthority: MintApiAuthority;
12
- constructor(apiKey: string, cluster?: HeliusCluster, id?: string, url?: string);
13
- getAllWebhooks(): Promise<Webhook[]>;
14
- getWebhookByID(webhookID: string): Promise<Webhook>;
15
- createWebhook(createWebhookRequest: CreateWebhookRequest): Promise<Webhook>;
16
- deleteWebhook(webhookID: string): Promise<boolean>;
17
- editWebhook(webhookID: string, editWebhookRequest: EditWebhookRequest): Promise<Webhook>;
18
- appendAddressesToWebhook(webhookID: string, newAccountAddresses: string[]): Promise<Webhook>;
19
- removeAddressesFromWebhook(webhookID: string, addressesToRemove: string[]): Promise<Webhook>;
20
- createCollectionWebhook(request: CreateCollectionWebhookRequest): Promise<Webhook>;
21
- getMintlist(request: MintlistRequest): Promise<MintlistResponse>;
22
- mintCompressedNft(mintApiRequest: MintApiRequest): Promise<MintApiResponse>;
23
- delegateCollectionAuthority(request: DelegateCollectionAuthorityRequest): Promise<string>;
24
- revokeCollectionAuthority(request: RevokeCollectionAuthorityRequest): Promise<string>;
25
- getApiEndpoint(path: string): string;
26
- private _editWebhook;
27
- private handleImageUpload;
28
- private uploadImageToArweave;
29
- private getCollectionAuthorityRecord;
30
- private getCollectionMetadataAccount;
31
- }