Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed optional auth + added http for raw IP #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ Steps to regenerate:
### Geyser
Please request access to geyser by emailing [email protected]

If you want to use geyser without access token on your instance of JITO Geyser, set second option to null:

```
import { geyserClient as jitoGeyserClient } from 'jito-ts';
const client = jitoSearcherClient(url, null, gRPCOptions);
```
https and http now work with geyser for direct IP connection

**Note:** Mac users may run into an error to the effect of "protoc-gen-js: program not found or is not executable";
if this is thrown, run:
* `brew install protobuf@3`
Expand Down
31 changes: 19 additions & 12 deletions src/sdk/geyser/geyser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
ClientReadableStream,
ServiceError,
} from '@grpc/grpc-js';
import {PublicKey} from '@solana/web3.js';
import { PublicKey } from '@solana/web3.js';

import {authInterceptor} from './auth';
import { authInterceptor } from './auth';
import {
GetHeartbeatIntervalResponse,
GeyserClient as GeyserClientStub,
Expand Down Expand Up @@ -58,7 +58,7 @@ export class GeyserClient {
): () => void {
const accounts = accountsOfInterest.map(a => a.toBytes());
const stream: ClientReadableStream<TimestampedAccountUpdate> =
this.client.subscribeAccountUpdates({accounts});
this.client.subscribeAccountUpdates({ accounts });

stream.on('readable', () => {
const msg = stream.read(1);
Expand All @@ -71,7 +71,7 @@ export class GeyserClient {
errorCallback(new Error(`Stream error: ${e.message}`))
);

return () => stream.cancel();
return stream.cancel;
}

/**
Expand All @@ -89,7 +89,7 @@ export class GeyserClient {
): () => void {
const programs = programsOfInterest.map(a => a.toBytes());
const stream: ClientReadableStream<TimestampedAccountUpdate> =
this.client.subscribeProgramUpdates({programs});
this.client.subscribeProgramUpdates({ programs });

stream.on('readable', () => {
const msg = stream.read(1);
Expand All @@ -102,7 +102,7 @@ export class GeyserClient {
errorCallback(new Error(`Stream error: ${e.message}`))
);

return () => stream.cancel();
return stream.cancel;
}

/**
Expand Down Expand Up @@ -130,7 +130,7 @@ export class GeyserClient {
errorCallback(new Error(`Stream error: ${e.message}`))
);

return () => stream.cancel();
return stream.cancel;
}
}

Expand All @@ -144,13 +144,20 @@ export class GeyserClient {
*/
export const geyserClient = (
url: string,
accessToken: string,
accessToken?: string,
grpcOptions?: Partial<ChannelOptions>
): GeyserClient => {
const client = new GeyserClientStub(url, ChannelCredentials.createSsl(), {
interceptors: [authInterceptor(accessToken)],
...grpcOptions,
});
const options: Partial<ChannelOptions> = { ...grpcOptions };

if (accessToken) {
options.interceptors = [authInterceptor(accessToken)];
}

const credentials = url.startsWith('https')
? ChannelCredentials.createSsl()
: ChannelCredentials.createInsecure();

const client = new GeyserClientStub(url, credentials, options);

return new GeyserClient(client);
};