@triton-one/yellowstone-grpc 4.0.1 → 5.0.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/README.md CHANGED
@@ -24,3 +24,25 @@ npm run build
24
24
  ```
25
25
 
26
26
  Please refer to [examples/typescript](../examples/typescript/README.md) for some usage examples.
27
+
28
+ ## Troubleshooting
29
+
30
+ ### For macOS:
31
+
32
+ You might have to run `npm run build` with `RUSTFLAGS="-Clink-arg=-undefined -Clink-arg=dynamic_lookup"` to skip the strict linkers from failing the build step and resolve `dylib`s via runtime.
33
+
34
+ ```bash
35
+ RUSTFLAGS="-Clink-arg=-undefined -Clink-arg=dynamic_lookup" npm run build
36
+ ```
37
+
38
+ ## Working
39
+
40
+ Since the start, the `@triton-one/yellowstone-grpc` package has used the `@grpc/grpc-js` lib for gRPC types enforcement, connection and subscription management. This hit a bottleneck, described in [this blog](https://blog.triton.one/supercharging-the-javascript-sdk-with-napi/)
41
+
42
+ From `v5.0.0` the [napi-rs](https://github.com/napi-rs/napi-rs) framework is used for gRPC connection and subscription management. It's described into [this blog](https://blog.triton.one/supercharging-the-javascript-sdk-with-napi/)
43
+
44
+ These changes are internal to the SDK and do not have any breaking changes for client code. If you face any issues, please open an issue
45
+
46
+ The `@grpc/grpc-js` lib is still being used for types management. This is will be removed in the future release without any braking API changes
47
+
48
+ The [napi-rs](https://github.com/napi-rs/napi-rs) based implementation is inspired from the implemenation of the [LaserStream SDK](https://github.com/helius-labs/laserstream-sdk)
package/package.json CHANGED
@@ -1,16 +1,21 @@
1
1
  {
2
2
  "name": "@triton-one/yellowstone-grpc",
3
- "version": "4.0.1",
3
+ "version": "5.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Triton One",
6
6
  "description": "Yellowstone gRPC Geyser Node.js Client",
7
7
  "main": "./dist/cjs/index.js",
8
8
  "types": "./dist/types/index.d.ts",
9
9
  "scripts": {
10
- "build": "npm run grpc-generate && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json && npm run cp-encoding-files && node add-js-extensions.js",
10
+ "build": "npm run grpc-generate && npm run build:napi && npm run cp-napi-files && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json && npm run cp-encoding-files && node add-js-extensions.js",
11
+ "build:napi": "cd napi && napi build --platform --release --no-dts-cache",
12
+ "build:napi:debug": "cd napi && napi build --platform --no-dts-cache",
11
13
  "cp-encoding-files": "mkdir -p dist/esm/encoding && cp -r src/encoding/* dist/cjs/encoding/ && mkdir -p dist/esm/encoding && cp -r src/encoding/* dist/esm/encoding/ && mkdir -p dist/types/encoding && cp -r src/encoding/* dist/types/encoding/",
14
+ "cp-napi-files": "mkdir -p src/napi && mkdir -p dist/cjs/napi && mkdir -p dist/esm/napi && mkdir -p dist/types/napi && cp -r napi/*.node src/napi/ 2>/dev/null || true && cp -r napi/*.node dist/cjs/napi/ 2>/dev/null || true && cp -r napi/*.node dist/esm/napi/ 2>/dev/null || true && cp -r napi/index.d.ts src/napi 2>/dev/null || true && cp -r napi/index.d.ts dist/types/napi/ 2>/dev/null || true && cp -r napi/index.js src/napi 2>/dev/null || true && cp -r napi/index.js dist/cjs/napi/ 2>/dev/null || true && cp -r napi/index.js dist/esm/napi/ 2>/dev/null || true",
12
15
  "fmt": "prettier -w .",
13
- "grpc-generate": "mkdir -p src/grpc && protoc -I../yellowstone-grpc-proto/proto --plugin=node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=forceLong=string --ts_proto_opt=outputServices=grpc-js --experimental_allow_proto3_optional --ts_proto_out=src/grpc geyser.proto --ts_proto_opt=esModuleInterop=true"
16
+ "grpc-generate": "mkdir -p src/grpc && protoc -I../yellowstone-grpc-proto/proto --plugin=node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=forceLong=string --ts_proto_opt=outputServices=grpc-js --experimental_allow_proto3_optional --ts_proto_out=src/grpc geyser.proto --ts_proto_opt=esModuleInterop=true",
17
+ "test": "jest",
18
+ "test:debug": "jest --detectOpenHandles"
14
19
  },
15
20
  "repository": {
16
21
  "type": "git",
@@ -30,10 +35,20 @@
30
35
  "@grpc/grpc-js": "^1.8.0"
31
36
  },
32
37
  "devDependencies": {
38
+ "@babel/core": "^7.28.5",
33
39
  "@babel/parser": "^7.26.3",
40
+ "@babel/preset-env": "^7.28.5",
41
+ "@babel/preset-typescript": "^7.28.5",
42
+ "@napi-rs/cli": "^3.4.1",
34
43
  "@solana/rpc-api": "=2.0.0",
44
+ "@types/jest": "^30.0.0",
45
+ "babel-jest": "^30.2.0",
46
+ "dotenv": "^17.2.3",
47
+ "jest": "^30.2.0",
48
+ "jest-json-schema": "^6.1.0",
35
49
  "prettier": "^2.8.3",
36
50
  "recast": "^0.23.9",
51
+ "ts-jest": "^29.4.5",
37
52
  "ts-proto": "^1.139.0",
38
53
  "typescript": "=5.2.2"
39
54
  },
@@ -48,6 +63,11 @@
48
63
  "import": "./dist/esm/index.js",
49
64
  "require": "./dist/cjs/index.js",
50
65
  "types": "./dist/types/index.d.ts"
66
+ },
67
+ "./napi": {
68
+ "import": "./dist/esm/napi/index.js",
69
+ "require": "./dist/cjs/napi/index.js",
70
+ "types": "./dist/types/napi/index.d.ts"
51
71
  }
52
72
  }
53
73
  }
@@ -1,228 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /**
4
- * @param {Uint8Array} data
5
- * @param {WasmUiTransactionEncoding} encoding
6
- * @param {number | undefined} max_supported_transaction_version
7
- * @param {boolean} show_rewards
8
- * @returns {string}
9
- */
10
- export function encode(data: Uint8Array, encoding: WasmUiTransactionEncoding, max_supported_transaction_version: number | undefined, show_rewards: boolean): string;
11
- /**
12
- * Initialize Javascript logging and panic handler
13
- */
14
- export function solana_program_init(): void;
15
- export enum WasmUiTransactionEncoding {
16
- Binary = 0,
17
- Base64 = 1,
18
- Base58 = 2,
19
- Json = 3,
20
- JsonParsed = 4,
21
- }
22
- /**
23
- * A hash; the 32-byte output of a hashing algorithm.
24
- *
25
- * This struct is used most often in `solana-sdk` and related crates to contain
26
- * a [SHA-256] hash, but may instead contain a [blake3] hash.
27
- *
28
- * [SHA-256]: https://en.wikipedia.org/wiki/SHA-2
29
- * [blake3]: https://github.com/BLAKE3-team/BLAKE3
30
- */
31
- export class Hash {
32
- free(): void;
33
- /**
34
- * Create a new Hash object
35
- *
36
- * * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]`
37
- * @param {any} value
38
- */
39
- constructor(value: any);
40
- /**
41
- * Return the base58 string representation of the hash
42
- * @returns {string}
43
- */
44
- toString(): string;
45
- /**
46
- * Checks if two `Hash`s are equal
47
- * @param {Hash} other
48
- * @returns {boolean}
49
- */
50
- equals(other: Hash): boolean;
51
- /**
52
- * Return the `Uint8Array` representation of the hash
53
- * @returns {Uint8Array}
54
- */
55
- toBytes(): Uint8Array;
56
- }
57
- /**
58
- * wasm-bindgen version of the Instruction struct.
59
- * This duplication is required until https://github.com/rustwasm/wasm-bindgen/issues/3671
60
- * is fixed. This must not diverge from the regular non-wasm Instruction struct.
61
- */
62
- export class Instruction {
63
- free(): void;
64
- }
65
- export class Instructions {
66
- free(): void;
67
- constructor();
68
- /**
69
- * @param {Instruction} instruction
70
- */
71
- push(instruction: Instruction): void;
72
- }
73
- /**
74
- * A vanilla Ed25519 key pair
75
- */
76
- export class Keypair {
77
- free(): void;
78
- /**
79
- * Create a new `Keypair `
80
- */
81
- constructor();
82
- /**
83
- * Convert a `Keypair` to a `Uint8Array`
84
- * @returns {Uint8Array}
85
- */
86
- toBytes(): Uint8Array;
87
- /**
88
- * Recover a `Keypair` from a `Uint8Array`
89
- * @param {Uint8Array} bytes
90
- * @returns {Keypair}
91
- */
92
- static fromBytes(bytes: Uint8Array): Keypair;
93
- /**
94
- * Return the `Pubkey` for this `Keypair`
95
- * @returns {Pubkey}
96
- */
97
- pubkey(): Pubkey;
98
- }
99
- /**
100
- * wasm-bindgen version of the Message struct.
101
- * This duplication is required until https://github.com/rustwasm/wasm-bindgen/issues/3671
102
- * is fixed. This must not diverge from the regular non-wasm Message struct.
103
- */
104
- export class Message {
105
- free(): void;
106
- /**
107
- * The id of a recent ledger entry.
108
- */
109
- recent_blockhash: Hash;
110
- }
111
- /**
112
- * The address of a [Solana account][acc].
113
- *
114
- * Some account addresses are [ed25519] public keys, with corresponding secret
115
- * keys that are managed off-chain. Often, though, account addresses do not
116
- * have corresponding secret keys — as with [_program derived
117
- * addresses_][pdas] — or the secret key is not relevant to the operation
118
- * of a program, and may have even been disposed of. As running Solana programs
119
- * can not safely create or manage secret keys, the full [`Keypair`] is not
120
- * defined in `solana-program` but in `solana-sdk`.
121
- *
122
- * [acc]: https://solana.com/docs/core/accounts
123
- * [ed25519]: https://ed25519.cr.yp.to/
124
- * [pdas]: https://solana.com/docs/core/cpi#program-derived-addresses
125
- * [`Keypair`]: https://docs.rs/solana-sdk/latest/solana_sdk/signer/keypair/struct.Keypair.html
126
- */
127
- export class Pubkey {
128
- free(): void;
129
- /**
130
- * Create a new Pubkey object
131
- *
132
- * * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]`
133
- * @param {any} value
134
- */
135
- constructor(value: any);
136
- /**
137
- * Return the base58 string representation of the public key
138
- * @returns {string}
139
- */
140
- toString(): string;
141
- /**
142
- * Check if a `Pubkey` is on the ed25519 curve.
143
- * @returns {boolean}
144
- */
145
- isOnCurve(): boolean;
146
- /**
147
- * Checks if two `Pubkey`s are equal
148
- * @param {Pubkey} other
149
- * @returns {boolean}
150
- */
151
- equals(other: Pubkey): boolean;
152
- /**
153
- * Return the `Uint8Array` representation of the public key
154
- * @returns {Uint8Array}
155
- */
156
- toBytes(): Uint8Array;
157
- /**
158
- * Derive a Pubkey from another Pubkey, string seed, and a program id
159
- * @param {Pubkey} base
160
- * @param {string} seed
161
- * @param {Pubkey} owner
162
- * @returns {Pubkey}
163
- */
164
- static createWithSeed(base: Pubkey, seed: string, owner: Pubkey): Pubkey;
165
- /**
166
- * Derive a program address from seeds and a program id
167
- * @param {any[]} seeds
168
- * @param {Pubkey} program_id
169
- * @returns {Pubkey}
170
- */
171
- static createProgramAddress(seeds: any[], program_id: Pubkey): Pubkey;
172
- /**
173
- * Find a valid program address
174
- *
175
- * Returns:
176
- * * `[PubKey, number]` - the program address and bump seed
177
- * @param {any[]} seeds
178
- * @param {Pubkey} program_id
179
- * @returns {any}
180
- */
181
- static findProgramAddress(seeds: any[], program_id: Pubkey): any;
182
- }
183
- /**
184
- * wasm-bindgen version of the Transaction struct.
185
- * This duplication is required until https://github.com/rustwasm/wasm-bindgen/issues/3671
186
- * is fixed. This must not diverge from the regular non-wasm Transaction struct.
187
- */
188
- export class Transaction {
189
- free(): void;
190
- /**
191
- * Create a new `Transaction`
192
- * @param {Instructions} instructions
193
- * @param {Pubkey | undefined} [payer]
194
- */
195
- constructor(instructions: Instructions, payer?: Pubkey);
196
- /**
197
- * Return a message containing all data that should be signed.
198
- * @returns {Message}
199
- */
200
- message(): Message;
201
- /**
202
- * Return the serialized message data to sign.
203
- * @returns {Uint8Array}
204
- */
205
- messageData(): Uint8Array;
206
- /**
207
- * Verify the transaction
208
- */
209
- verify(): void;
210
- /**
211
- * @param {Keypair} keypair
212
- * @param {Hash} recent_blockhash
213
- */
214
- partialSign(keypair: Keypair, recent_blockhash: Hash): void;
215
- /**
216
- * @returns {boolean}
217
- */
218
- isSigned(): boolean;
219
- /**
220
- * @returns {Uint8Array}
221
- */
222
- toBytes(): Uint8Array;
223
- /**
224
- * @param {Uint8Array} bytes
225
- * @returns {Transaction}
226
- */
227
- static fromBytes(bytes: Uint8Array): Transaction;
228
- }