@triton-one/yellowstone-grpc 0.1.0
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/.prettierrc.json +1 -0
- package/README.md +26 -0
- package/dist/grpc/geyser.d.ts +8450 -0
- package/dist/grpc/geyser.js +2868 -0
- package/dist/grpc/solana-storage.d.ts +3773 -0
- package/dist/grpc/solana-storage.js +1856 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +265 -0
- package/package.json +35 -0
- package/src/grpc/geyser.ts +3477 -0
- package/src/grpc/solana-storage.ts +2141 -0
- package/src/index.ts +190 -0
- package/tsconfig.json +7 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript/JavaScript client for gRPC Geyser.
|
|
3
|
+
*/
|
|
4
|
+
import { CommitmentLevel, GetLatestBlockhashResponse, GeyserClient, IsBlockhashValidResponse, SubscribeRequestFilterAccounts, SubscribeRequestFilterBlocks, SubscribeRequestFilterBlocksMeta, SubscribeRequestFilterSlots, SubscribeRequestFilterTransactions } from "./grpc/geyser";
|
|
5
|
+
export { SubscribeRequest, SubscribeRequest_AccountsEntry, SubscribeRequest_SlotsEntry, SubscribeRequestFilterSlots, SubscribeRequest_TransactionsEntry, SubscribeRequestFilterTransactions, SubscribeRequest_BlocksEntry, SubscribeRequest_BlocksMetaEntry, SubscribeRequestFilterAccounts, SubscribeRequestFilterAccountsFilter, SubscribeRequestFilterAccountsFilterMemcmp, SubscribeRequestFilterBlocks, SubscribeRequestFilterBlocksMeta, SubscribeUpdate, SubscribeUpdateAccount, SubscribeUpdateAccountInfo, SubscribeUpdateSlot, CommitmentLevel, SubscribeUpdateTransaction, SubscribeUpdateTransactionInfo, SubscribeUpdateBlock, SubscribeUpdatePing, SubscribeUpdateBlockMeta, } from "./grpc/geyser";
|
|
6
|
+
export default class Client {
|
|
7
|
+
_client: GeyserClient;
|
|
8
|
+
constructor(endpoint: string, xToken: string | undefined);
|
|
9
|
+
subscribe(): Promise<import("@grpc/grpc-js").ClientDuplexStream<import("./grpc/geyser").SubscribeRequest, import("./grpc/geyser").SubscribeUpdate>>;
|
|
10
|
+
subscribe_once(accounts: {
|
|
11
|
+
[key: string]: SubscribeRequestFilterAccounts;
|
|
12
|
+
}, slots: {
|
|
13
|
+
[key: string]: SubscribeRequestFilterSlots;
|
|
14
|
+
}, transactions: {
|
|
15
|
+
[key: string]: SubscribeRequestFilterTransactions;
|
|
16
|
+
}, blocks: {
|
|
17
|
+
[key: string]: SubscribeRequestFilterBlocks;
|
|
18
|
+
}, blocksMeta: {
|
|
19
|
+
[key: string]: SubscribeRequestFilterBlocksMeta;
|
|
20
|
+
}, commitment?: CommitmentLevel | undefined): Promise<import("@grpc/grpc-js").ClientDuplexStream<import("./grpc/geyser").SubscribeRequest, import("./grpc/geyser").SubscribeUpdate>>;
|
|
21
|
+
ping(count: number): Promise<number>;
|
|
22
|
+
getLatestBlockhash(commitment?: CommitmentLevel): Promise<GetLatestBlockhashResponse>;
|
|
23
|
+
getBlockHeight(commitment?: CommitmentLevel): Promise<number>;
|
|
24
|
+
getSlot(commitment?: CommitmentLevel): Promise<number>;
|
|
25
|
+
isBlockhashValid(blockhash: string, commitment?: CommitmentLevel): Promise<IsBlockhashValidResponse>;
|
|
26
|
+
getVersion(): Promise<string>;
|
|
27
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TypeScript/JavaScript client for gRPC Geyser.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
+
function step(op) {
|
|
30
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
+
switch (op[0]) {
|
|
35
|
+
case 0: case 1: t = op; break;
|
|
36
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
+
default:
|
|
40
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
+
if (t[2]) _.ops.pop();
|
|
45
|
+
_.trys.pop(); continue;
|
|
46
|
+
}
|
|
47
|
+
op = body.call(thisArg, _);
|
|
48
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.__esModule = true;
|
|
53
|
+
exports.SubscribeUpdateBlockMeta = exports.SubscribeUpdatePing = exports.SubscribeUpdateBlock = exports.SubscribeUpdateTransactionInfo = exports.SubscribeUpdateTransaction = exports.CommitmentLevel = exports.SubscribeUpdateSlot = exports.SubscribeUpdateAccountInfo = exports.SubscribeUpdateAccount = exports.SubscribeUpdate = exports.SubscribeRequestFilterBlocksMeta = exports.SubscribeRequestFilterBlocks = exports.SubscribeRequestFilterAccountsFilterMemcmp = exports.SubscribeRequestFilterAccountsFilter = exports.SubscribeRequestFilterAccounts = exports.SubscribeRequest_BlocksMetaEntry = exports.SubscribeRequest_BlocksEntry = exports.SubscribeRequestFilterTransactions = exports.SubscribeRequest_TransactionsEntry = exports.SubscribeRequestFilterSlots = exports.SubscribeRequest_SlotsEntry = exports.SubscribeRequest_AccountsEntry = exports.SubscribeRequest = void 0;
|
|
54
|
+
// Import generated gRPC client and types.
|
|
55
|
+
var geyser_1 = require("./grpc/geyser");
|
|
56
|
+
var grpc_js_1 = require("@grpc/grpc-js");
|
|
57
|
+
// Reexport automatically generated types
|
|
58
|
+
var geyser_2 = require("./grpc/geyser");
|
|
59
|
+
__createBinding(exports, geyser_2, "SubscribeRequest");
|
|
60
|
+
__createBinding(exports, geyser_2, "SubscribeRequest_AccountsEntry");
|
|
61
|
+
__createBinding(exports, geyser_2, "SubscribeRequest_SlotsEntry");
|
|
62
|
+
__createBinding(exports, geyser_2, "SubscribeRequestFilterSlots");
|
|
63
|
+
__createBinding(exports, geyser_2, "SubscribeRequest_TransactionsEntry");
|
|
64
|
+
__createBinding(exports, geyser_2, "SubscribeRequestFilterTransactions");
|
|
65
|
+
__createBinding(exports, geyser_2, "SubscribeRequest_BlocksEntry");
|
|
66
|
+
__createBinding(exports, geyser_2, "SubscribeRequest_BlocksMetaEntry");
|
|
67
|
+
__createBinding(exports, geyser_2, "SubscribeRequestFilterAccounts");
|
|
68
|
+
__createBinding(exports, geyser_2, "SubscribeRequestFilterAccountsFilter");
|
|
69
|
+
__createBinding(exports, geyser_2, "SubscribeRequestFilterAccountsFilterMemcmp");
|
|
70
|
+
__createBinding(exports, geyser_2, "SubscribeRequestFilterBlocks");
|
|
71
|
+
__createBinding(exports, geyser_2, "SubscribeRequestFilterBlocksMeta");
|
|
72
|
+
__createBinding(exports, geyser_2, "SubscribeUpdate");
|
|
73
|
+
__createBinding(exports, geyser_2, "SubscribeUpdateAccount");
|
|
74
|
+
__createBinding(exports, geyser_2, "SubscribeUpdateAccountInfo");
|
|
75
|
+
__createBinding(exports, geyser_2, "SubscribeUpdateSlot");
|
|
76
|
+
__createBinding(exports, geyser_2, "CommitmentLevel");
|
|
77
|
+
__createBinding(exports, geyser_2, "SubscribeUpdateTransaction");
|
|
78
|
+
__createBinding(exports, geyser_2, "SubscribeUpdateTransactionInfo");
|
|
79
|
+
__createBinding(exports, geyser_2, "SubscribeUpdateBlock");
|
|
80
|
+
__createBinding(exports, geyser_2, "SubscribeUpdatePing");
|
|
81
|
+
__createBinding(exports, geyser_2, "SubscribeUpdateBlockMeta");
|
|
82
|
+
var Client = /** @class */ (function () {
|
|
83
|
+
function Client(endpoint, xToken) {
|
|
84
|
+
var creds;
|
|
85
|
+
var endpointURL = new URL(endpoint);
|
|
86
|
+
// Check if we need to use TLS.
|
|
87
|
+
if (endpointURL.protocol === "https:") {
|
|
88
|
+
creds = grpc_js_1.credentials.combineChannelCredentials(grpc_js_1.credentials.createSsl(), grpc_js_1.credentials.createFromMetadataGenerator(function (_params, callback) {
|
|
89
|
+
var metadata = new grpc_js_1.Metadata();
|
|
90
|
+
if (xToken !== undefined) {
|
|
91
|
+
metadata.add("x-token", xToken);
|
|
92
|
+
}
|
|
93
|
+
return callback(null, metadata);
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
creds = grpc_js_1.ChannelCredentials.createInsecure();
|
|
98
|
+
}
|
|
99
|
+
this._client = new geyser_1.GeyserClient(endpointURL.host, creds);
|
|
100
|
+
}
|
|
101
|
+
Client.prototype.subscribe = function () {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0: return [4 /*yield*/, this._client.subscribe()];
|
|
106
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
Client.prototype.subscribe_once = function (accounts, slots, transactions, blocks, blocksMeta, commitment) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
+
var stream;
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
switch (_a.label) {
|
|
116
|
+
case 0: return [4 /*yield*/, this._client.subscribe()];
|
|
117
|
+
case 1:
|
|
118
|
+
stream = _a.sent();
|
|
119
|
+
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
120
|
+
stream.write({
|
|
121
|
+
accounts: accounts,
|
|
122
|
+
slots: slots,
|
|
123
|
+
transactions: transactions,
|
|
124
|
+
blocks: blocks,
|
|
125
|
+
blocksMeta: blocksMeta,
|
|
126
|
+
commitment: commitment
|
|
127
|
+
}, function (err) {
|
|
128
|
+
if (err === null || err === undefined) {
|
|
129
|
+
resolve();
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
reject(err);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
})];
|
|
136
|
+
case 2:
|
|
137
|
+
_a.sent();
|
|
138
|
+
return [2 /*return*/, stream];
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
Client.prototype.ping = function (count) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
+
var _this = this;
|
|
146
|
+
return __generator(this, function (_a) {
|
|
147
|
+
switch (_a.label) {
|
|
148
|
+
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
149
|
+
_this._client.ping({ count: count }, function (err, response) {
|
|
150
|
+
if (err === null || err === undefined) {
|
|
151
|
+
resolve(response.count);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
reject(err);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
})];
|
|
158
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
Client.prototype.getLatestBlockhash = function (commitment) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
165
|
+
var _this = this;
|
|
166
|
+
return __generator(this, function (_a) {
|
|
167
|
+
switch (_a.label) {
|
|
168
|
+
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
169
|
+
_this._client.getLatestBlockhash({ commitment: commitment }, function (err, response) {
|
|
170
|
+
if (err === null || err === undefined) {
|
|
171
|
+
resolve(response);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
reject(err);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
})];
|
|
178
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
Client.prototype.getBlockHeight = function (commitment) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
185
|
+
var _this = this;
|
|
186
|
+
return __generator(this, function (_a) {
|
|
187
|
+
switch (_a.label) {
|
|
188
|
+
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
189
|
+
_this._client.getBlockHeight({ commitment: commitment }, function (err, response) {
|
|
190
|
+
if (err === null || err === undefined) {
|
|
191
|
+
resolve(response.blockHeight);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
reject(err);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
})];
|
|
198
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
Client.prototype.getSlot = function (commitment) {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
205
|
+
var _this = this;
|
|
206
|
+
return __generator(this, function (_a) {
|
|
207
|
+
switch (_a.label) {
|
|
208
|
+
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
209
|
+
_this._client.getSlot({ commitment: commitment }, function (err, response) {
|
|
210
|
+
if (err === null || err === undefined) {
|
|
211
|
+
resolve(response.slot);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
reject(err);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
})];
|
|
218
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
Client.prototype.isBlockhashValid = function (blockhash, commitment) {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
225
|
+
var _this = this;
|
|
226
|
+
return __generator(this, function (_a) {
|
|
227
|
+
switch (_a.label) {
|
|
228
|
+
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
229
|
+
_this._client.isBlockhashValid({ blockhash: blockhash, commitment: commitment }, function (err, response) {
|
|
230
|
+
if (err === null || err === undefined) {
|
|
231
|
+
resolve(response);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
reject(err);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
})];
|
|
238
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
Client.prototype.getVersion = function () {
|
|
244
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
245
|
+
var _this = this;
|
|
246
|
+
return __generator(this, function (_a) {
|
|
247
|
+
switch (_a.label) {
|
|
248
|
+
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
249
|
+
_this._client.getVersion({}, function (err, response) {
|
|
250
|
+
if (err === null || err === undefined) {
|
|
251
|
+
resolve(response.version);
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
reject(err);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
})];
|
|
258
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
return Client;
|
|
264
|
+
}());
|
|
265
|
+
exports["default"] = Client;
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@triton-one/yellowstone-grpc",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"author": "Triton One",
|
|
6
|
+
"description": "Yellowstone gRPC Geyser Node.js Client",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "npm run grpc-generate && tsc -p .",
|
|
11
|
+
"grpc-generate": "protoc -I../yellowstone-grpc-proto/proto --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=outputServices=grpc-js --ts_proto_out=./src/grpc geyser.proto"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/rpcpool/yellowstone-grpc.git"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/rpcpool/yellowstone-grpc/issues"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"solana"
|
|
25
|
+
],
|
|
26
|
+
"homepage": "https://triton.one",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@grpc/grpc-js": "^1.8.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"prettier": "2.8.3",
|
|
32
|
+
"ts-proto": "^1.139.0",
|
|
33
|
+
"typescript": "^4.9.5"
|
|
34
|
+
}
|
|
35
|
+
}
|