@drift-labs/sdk 2.131.0-beta.2 → 2.131.0-beta.4
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/VERSION +1 -1
- package/bun.lock +96 -5
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +35 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.js +218 -0
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.d.ts +6 -1
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.js +4 -2
- package/lib/browser/driftClient.js +3 -3
- package/lib/browser/driftClientConfig.d.ts +7 -2
- package/lib/browser/idl/drift.json +0 -7
- package/lib/browser/index.d.ts +1 -0
- package/lib/browser/index.js +3 -1
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +36 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.js +218 -0
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts +6 -1
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.js +4 -2
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +3 -3
- package/lib/node/driftClientConfig.d.ts +7 -2
- package/lib/node/driftClientConfig.d.ts.map +1 -1
- package/lib/node/idl/drift.json +0 -7
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +3 -1
- package/package.json +2 -1
- package/src/accounts/README_WebSocketAccountSubscriberV2.md +54 -0
- package/src/accounts/webSocketAccountSubscriberV2.ts +310 -0
- package/src/accounts/webSocketDriftClientAccountSubscriber.ts +22 -2
- package/src/driftClient.ts +2 -1
- package/src/driftClientConfig.ts +16 -2
- package/src/idl/drift.json +0 -7
- package/src/index.ts +1 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.131.0-beta.
|
|
1
|
+
2.131.0-beta.4
|
package/bun.lock
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"@switchboard-xyz/on-demand": "2.4.1",
|
|
20
20
|
"@triton-one/yellowstone-grpc": "1.3.0",
|
|
21
21
|
"anchor-bankrun": "0.3.0",
|
|
22
|
+
"gill": "^0.10.2",
|
|
22
23
|
"nanoid": "3.3.4",
|
|
23
24
|
"node-cache": "5.1.2",
|
|
24
25
|
"rpc-websockets": "7.5.1",
|
|
@@ -187,23 +188,79 @@
|
|
|
187
188
|
|
|
188
189
|
"@sinonjs/text-encoding": ["@sinonjs/text-encoding@0.7.3", "", {}, "sha512-DE427ROAphMQzU4ENbliGYrBSYPXF+TtLg9S8vzeA+OF4ZKzoDdzfL8sxuMUGS/lgRhM6j1URSk9ghf7Xo1tyA=="],
|
|
189
190
|
|
|
191
|
+
"@solana-program/address-lookup-table": ["@solana-program/address-lookup-table@0.7.0", "", { "peerDependencies": { "@solana/kit": "^2.1.0" } }, "sha512-dzCeIO5LtiK3bIg0AwO+TPeGURjSG2BKt0c4FRx7105AgLy7uzTktpUzUj6NXAK9SzbirI8HyvHUvw1uvL8O9A=="],
|
|
192
|
+
|
|
193
|
+
"@solana-program/compute-budget": ["@solana-program/compute-budget@0.8.0", "", { "peerDependencies": { "@solana/kit": "^2.1.0" } }, "sha512-qPKxdxaEsFxebZ4K5RPuy7VQIm/tfJLa1+Nlt3KNA8EYQkz9Xm8htdoEaXVrer9kpgzzp9R3I3Bh6omwCM06tQ=="],
|
|
194
|
+
|
|
195
|
+
"@solana-program/system": ["@solana-program/system@0.7.0", "", { "peerDependencies": { "@solana/kit": "^2.1.0" } }, "sha512-FKTBsKHpvHHNc1ATRm7SlC5nF/VdJtOSjldhcyfMN9R7xo712Mo2jHIzvBgn8zQO5Kg0DcWuKB7268Kv1ocicw=="],
|
|
196
|
+
|
|
197
|
+
"@solana-program/token-2022": ["@solana-program/token-2022@0.4.2", "", { "peerDependencies": { "@solana/kit": "^2.1.0", "@solana/sysvars": "^2.1.0" } }, "sha512-zIpR5t4s9qEU3hZKupzIBxJ6nUV5/UVyIT400tu9vT1HMs5JHxaTTsb5GUhYjiiTvNwU0MQavbwc4Dl29L0Xvw=="],
|
|
198
|
+
|
|
199
|
+
"@solana/accounts": ["@solana/accounts@2.3.0", "", { "dependencies": { "@solana/addresses": "2.3.0", "@solana/codecs-core": "2.3.0", "@solana/codecs-strings": "2.3.0", "@solana/errors": "2.3.0", "@solana/rpc-spec": "2.3.0", "@solana/rpc-types": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-QgQTj404Z6PXNOyzaOpSzjgMOuGwG8vC66jSDB+3zHaRcEPRVRd2sVSrd1U6sHtnV3aiaS6YyDuPQMheg4K2jw=="],
|
|
200
|
+
|
|
201
|
+
"@solana/addresses": ["@solana/addresses@2.3.0", "", { "dependencies": { "@solana/assertions": "2.3.0", "@solana/codecs-core": "2.3.0", "@solana/codecs-strings": "2.3.0", "@solana/errors": "2.3.0", "@solana/nominal-types": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-ypTNkY2ZaRFpHLnHAgaW8a83N0/WoqdFvCqf4CQmnMdFsZSdC7qOwcbd7YzdaQn9dy+P2hybewzB+KP7LutxGA=="],
|
|
202
|
+
|
|
203
|
+
"@solana/assertions": ["@solana/assertions@2.3.0", "", { "dependencies": { "@solana/errors": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-Ekoet3khNg3XFLN7MIz8W31wPQISpKUGDGTylLptI+JjCDWx3PIa88xjEMqFo02WJ8sBj2NLV64Xg1sBcsHjZQ=="],
|
|
204
|
+
|
|
190
205
|
"@solana/buffer-layout": ["@solana/buffer-layout@4.0.1", "", { "dependencies": { "buffer": "~6.0.3" } }, "sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA=="],
|
|
191
206
|
|
|
192
207
|
"@solana/buffer-layout-utils": ["@solana/buffer-layout-utils@0.2.0", "", { "dependencies": { "@solana/buffer-layout": "^4.0.0", "@solana/web3.js": "^1.32.0", "bigint-buffer": "^1.1.5", "bignumber.js": "^9.0.1" } }, "sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g=="],
|
|
193
208
|
|
|
194
|
-
"@solana/codecs": ["@solana/codecs@2.
|
|
209
|
+
"@solana/codecs": ["@solana/codecs@2.3.0", "", { "dependencies": { "@solana/codecs-core": "2.3.0", "@solana/codecs-data-structures": "2.3.0", "@solana/codecs-numbers": "2.3.0", "@solana/codecs-strings": "2.3.0", "@solana/options": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-JVqGPkzoeyU262hJGdH64kNLH0M+Oew2CIPOa/9tR3++q2pEd4jU2Rxdfye9sd0Ce3XJrR5AIa8ZfbyQXzjh+g=="],
|
|
195
210
|
|
|
196
|
-
"@solana/codecs-core": ["@solana/codecs-core@2.
|
|
211
|
+
"@solana/codecs-core": ["@solana/codecs-core@2.3.0", "", { "dependencies": { "@solana/errors": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-oG+VZzN6YhBHIoSKgS5ESM9VIGzhWjEHEGNPSibiDTxFhsFWxNaz8LbMDPjBUE69r9wmdGLkrQ+wVPbnJcZPvw=="],
|
|
197
212
|
|
|
198
213
|
"@solana/codecs-data-structures": ["@solana/codecs-data-structures@2.0.0-preview.4", "", { "dependencies": { "@solana/codecs-core": "2.0.0-preview.4", "@solana/codecs-numbers": "2.0.0-preview.4", "@solana/errors": "2.0.0-preview.4" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-nt2k2eTeyzlI/ccutPcG36M/J8NAYfxBPI9h/nQjgJ+M+IgOKi31JV8StDDlG/1XvY0zyqugV3I0r3KAbZRJpA=="],
|
|
199
214
|
|
|
200
|
-
"@solana/codecs-numbers": ["@solana/codecs-numbers@2.
|
|
215
|
+
"@solana/codecs-numbers": ["@solana/codecs-numbers@2.3.0", "", { "dependencies": { "@solana/codecs-core": "2.3.0", "@solana/errors": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-jFvvwKJKffvG7Iz9dmN51OGB7JBcy2CJ6Xf3NqD/VP90xak66m/Lg48T01u5IQ/hc15mChVHiBm+HHuOFDUrQg=="],
|
|
201
216
|
|
|
202
|
-
"@solana/codecs-strings": ["@solana/codecs-strings@2.
|
|
217
|
+
"@solana/codecs-strings": ["@solana/codecs-strings@2.3.0", "", { "dependencies": { "@solana/codecs-core": "2.3.0", "@solana/codecs-numbers": "2.3.0", "@solana/errors": "2.3.0" }, "peerDependencies": { "fastestsmallesttextencoderdecoder": "^1.0.22", "typescript": ">=5.3.3" } }, "sha512-y5pSBYwzVziXu521hh+VxqUtp0hYGTl1eWGoc1W+8mdvBdC1kTqm/X7aYQw33J42hw03JjryvYOvmGgk3Qz/Ug=="],
|
|
203
218
|
|
|
204
219
|
"@solana/errors": ["@solana/errors@2.0.0-preview.4", "", { "dependencies": { "chalk": "^5.3.0", "commander": "^12.1.0" }, "peerDependencies": { "typescript": ">=5" }, "bin": { "errors": "bin/cli.mjs" } }, "sha512-kadtlbRv2LCWr8A9V22On15Us7Nn8BvqNaOB4hXsTB3O0fU40D1ru2l+cReqLcRPij4znqlRzW9Xi0m6J5DIhA=="],
|
|
205
220
|
|
|
206
|
-
"@solana/
|
|
221
|
+
"@solana/fast-stable-stringify": ["@solana/fast-stable-stringify@2.3.0", "", { "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-KfJPrMEieUg6D3hfQACoPy0ukrAV8Kio883llt/8chPEG3FVTX9z/Zuf4O01a15xZmBbmQ7toil2Dp0sxMJSxw=="],
|
|
222
|
+
|
|
223
|
+
"@solana/functional": ["@solana/functional@2.3.0", "", { "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-AgsPh3W3tE+nK3eEw/W9qiSfTGwLYEvl0rWaxHht/lRcuDVwfKRzeSa5G79eioWFFqr+pTtoCr3D3OLkwKz02Q=="],
|
|
224
|
+
|
|
225
|
+
"@solana/instructions": ["@solana/instructions@2.3.0", "", { "dependencies": { "@solana/codecs-core": "2.3.0", "@solana/errors": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-PLMsmaIKu7hEAzyElrk2T7JJx4D+9eRwebhFZpy2PXziNSmFF929eRHKUsKqBFM3cYR1Yy3m6roBZfA+bGE/oQ=="],
|
|
226
|
+
|
|
227
|
+
"@solana/keys": ["@solana/keys@2.3.0", "", { "dependencies": { "@solana/assertions": "2.3.0", "@solana/codecs-core": "2.3.0", "@solana/codecs-strings": "2.3.0", "@solana/errors": "2.3.0", "@solana/nominal-types": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-ZVVdga79pNH+2pVcm6fr2sWz9HTwfopDVhYb0Lh3dh+WBmJjwkabXEIHey2rUES7NjFa/G7sV8lrUn/v8LDCCQ=="],
|
|
228
|
+
|
|
229
|
+
"@solana/kit": ["@solana/kit@2.3.0", "", { "dependencies": { "@solana/accounts": "2.3.0", "@solana/addresses": "2.3.0", "@solana/codecs": "2.3.0", "@solana/errors": "2.3.0", "@solana/functional": "2.3.0", "@solana/instructions": "2.3.0", "@solana/keys": "2.3.0", "@solana/programs": "2.3.0", "@solana/rpc": "2.3.0", "@solana/rpc-parsed-types": "2.3.0", "@solana/rpc-spec-types": "2.3.0", "@solana/rpc-subscriptions": "2.3.0", "@solana/rpc-types": "2.3.0", "@solana/signers": "2.3.0", "@solana/sysvars": "2.3.0", "@solana/transaction-confirmation": "2.3.0", "@solana/transaction-messages": "2.3.0", "@solana/transactions": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-sb6PgwoW2LjE5oTFu4lhlS/cGt/NB3YrShEyx7JgWFWysfgLdJnhwWThgwy/4HjNsmtMrQGWVls0yVBHcMvlMQ=="],
|
|
230
|
+
|
|
231
|
+
"@solana/nominal-types": ["@solana/nominal-types@2.3.0", "", { "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-uKlMnlP4PWW5UTXlhKM8lcgIaNj8dvd8xO4Y9l+FVvh9RvW2TO0GwUO6JCo7JBzCB0PSqRJdWWaQ8pu1Ti/OkA=="],
|
|
232
|
+
|
|
233
|
+
"@solana/options": ["@solana/options@2.3.0", "", { "dependencies": { "@solana/codecs-core": "2.3.0", "@solana/codecs-data-structures": "2.3.0", "@solana/codecs-numbers": "2.3.0", "@solana/codecs-strings": "2.3.0", "@solana/errors": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-PPnnZBRCWWoZQ11exPxf//DRzN2C6AoFsDI/u2AsQfYih434/7Kp4XLpfOMT/XESi+gdBMFNNfbES5zg3wAIkw=="],
|
|
234
|
+
|
|
235
|
+
"@solana/programs": ["@solana/programs@2.3.0", "", { "dependencies": { "@solana/addresses": "2.3.0", "@solana/errors": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-UXKujV71VCI5uPs+cFdwxybtHZAIZyQkqDiDnmK+DawtOO9mBn4Nimdb/6RjR2CXT78mzO9ZCZ3qfyX+ydcB7w=="],
|
|
236
|
+
|
|
237
|
+
"@solana/promises": ["@solana/promises@2.3.0", "", { "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-GjVgutZKXVuojd9rWy1PuLnfcRfqsaCm7InCiZc8bqmJpoghlyluweNc7ml9Y5yQn1P2IOyzh9+p/77vIyNybQ=="],
|
|
238
|
+
|
|
239
|
+
"@solana/rpc": ["@solana/rpc@2.3.0", "", { "dependencies": { "@solana/errors": "2.3.0", "@solana/fast-stable-stringify": "2.3.0", "@solana/functional": "2.3.0", "@solana/rpc-api": "2.3.0", "@solana/rpc-spec": "2.3.0", "@solana/rpc-spec-types": "2.3.0", "@solana/rpc-transformers": "2.3.0", "@solana/rpc-transport-http": "2.3.0", "@solana/rpc-types": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-ZWN76iNQAOCpYC7yKfb3UNLIMZf603JckLKOOLTHuy9MZnTN8XV6uwvDFhf42XvhglgUjGCEnbUqWtxQ9pa/pQ=="],
|
|
240
|
+
|
|
241
|
+
"@solana/rpc-api": ["@solana/rpc-api@2.3.0", "", { "dependencies": { "@solana/addresses": "2.3.0", "@solana/codecs-core": "2.3.0", "@solana/codecs-strings": "2.3.0", "@solana/errors": "2.3.0", "@solana/keys": "2.3.0", "@solana/rpc-parsed-types": "2.3.0", "@solana/rpc-spec": "2.3.0", "@solana/rpc-transformers": "2.3.0", "@solana/rpc-types": "2.3.0", "@solana/transaction-messages": "2.3.0", "@solana/transactions": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-UUdiRfWoyYhJL9PPvFeJr4aJ554ob2jXcpn4vKmRVn9ire0sCbpQKYx6K8eEKHZWXKrDW8IDspgTl0gT/aJWVg=="],
|
|
242
|
+
|
|
243
|
+
"@solana/rpc-parsed-types": ["@solana/rpc-parsed-types@2.3.0", "", { "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-B5pHzyEIbBJf9KHej+zdr5ZNAdSvu7WLU2lOUPh81KHdHQs6dEb310LGxcpCc7HVE8IEdO20AbckewDiAN6OCg=="],
|
|
244
|
+
|
|
245
|
+
"@solana/rpc-spec": ["@solana/rpc-spec@2.3.0", "", { "dependencies": { "@solana/errors": "2.3.0", "@solana/rpc-spec-types": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-fA2LMX4BMixCrNB2n6T83AvjZ3oUQTu7qyPLyt8gHQaoEAXs8k6GZmu6iYcr+FboQCjUmRPgMaABbcr9j2J9Sw=="],
|
|
246
|
+
|
|
247
|
+
"@solana/rpc-spec-types": ["@solana/rpc-spec-types@2.3.0", "", { "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-xQsb65lahjr8Wc9dMtP7xa0ZmDS8dOE2ncYjlvfyw/h4mpdXTUdrSMi6RtFwX33/rGuztQ7Hwaid5xLNSLvsFQ=="],
|
|
248
|
+
|
|
249
|
+
"@solana/rpc-subscriptions": ["@solana/rpc-subscriptions@2.3.0", "", { "dependencies": { "@solana/errors": "2.3.0", "@solana/fast-stable-stringify": "2.3.0", "@solana/functional": "2.3.0", "@solana/promises": "2.3.0", "@solana/rpc-spec-types": "2.3.0", "@solana/rpc-subscriptions-api": "2.3.0", "@solana/rpc-subscriptions-channel-websocket": "2.3.0", "@solana/rpc-subscriptions-spec": "2.3.0", "@solana/rpc-transformers": "2.3.0", "@solana/rpc-types": "2.3.0", "@solana/subscribable": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-Uyr10nZKGVzvCOqwCZgwYrzuoDyUdwtgQRefh13pXIrdo4wYjVmoLykH49Omt6abwStB0a4UL5gX9V4mFdDJZg=="],
|
|
250
|
+
|
|
251
|
+
"@solana/rpc-subscriptions-api": ["@solana/rpc-subscriptions-api@2.3.0", "", { "dependencies": { "@solana/addresses": "2.3.0", "@solana/keys": "2.3.0", "@solana/rpc-subscriptions-spec": "2.3.0", "@solana/rpc-transformers": "2.3.0", "@solana/rpc-types": "2.3.0", "@solana/transaction-messages": "2.3.0", "@solana/transactions": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-9mCjVbum2Hg9KGX3LKsrI5Xs0KX390lS+Z8qB80bxhar6MJPugqIPH8uRgLhCW9GN3JprAfjRNl7our8CPvsPQ=="],
|
|
252
|
+
|
|
253
|
+
"@solana/rpc-subscriptions-channel-websocket": ["@solana/rpc-subscriptions-channel-websocket@2.3.0", "", { "dependencies": { "@solana/errors": "2.3.0", "@solana/functional": "2.3.0", "@solana/rpc-subscriptions-spec": "2.3.0", "@solana/subscribable": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3", "ws": "^8.18.0" } }, "sha512-2oL6ceFwejIgeWzbNiUHI2tZZnaOxNTSerszcin7wYQwijxtpVgUHiuItM/Y70DQmH9sKhmikQp+dqeGalaJxw=="],
|
|
254
|
+
|
|
255
|
+
"@solana/rpc-subscriptions-spec": ["@solana/rpc-subscriptions-spec@2.3.0", "", { "dependencies": { "@solana/errors": "2.3.0", "@solana/promises": "2.3.0", "@solana/rpc-spec-types": "2.3.0", "@solana/subscribable": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-rdmVcl4PvNKQeA2l8DorIeALCgJEMSu7U8AXJS1PICeb2lQuMeaR+6cs/iowjvIB0lMVjYN2sFf6Q3dJPu6wWg=="],
|
|
256
|
+
|
|
257
|
+
"@solana/rpc-transformers": ["@solana/rpc-transformers@2.3.0", "", { "dependencies": { "@solana/errors": "2.3.0", "@solana/functional": "2.3.0", "@solana/nominal-types": "2.3.0", "@solana/rpc-spec-types": "2.3.0", "@solana/rpc-types": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-UuHYK3XEpo9nMXdjyGKkPCOr7WsZsxs7zLYDO1A5ELH3P3JoehvrDegYRAGzBS2VKsfApZ86ZpJToP0K3PhmMA=="],
|
|
258
|
+
|
|
259
|
+
"@solana/rpc-transport-http": ["@solana/rpc-transport-http@2.3.0", "", { "dependencies": { "@solana/errors": "2.3.0", "@solana/rpc-spec": "2.3.0", "@solana/rpc-spec-types": "2.3.0", "undici-types": "^7.11.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-HFKydmxGw8nAF5N+S0NLnPBDCe5oMDtI2RAmW8DMqP4U3Zxt2XWhvV1SNkAldT5tF0U1vP+is6fHxyhk4xqEvg=="],
|
|
260
|
+
|
|
261
|
+
"@solana/rpc-types": ["@solana/rpc-types@2.3.0", "", { "dependencies": { "@solana/addresses": "2.3.0", "@solana/codecs-core": "2.3.0", "@solana/codecs-numbers": "2.3.0", "@solana/codecs-strings": "2.3.0", "@solana/errors": "2.3.0", "@solana/nominal-types": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-O09YX2hED2QUyGxrMOxQ9GzH1LlEwwZWu69QbL4oYmIf6P5dzEEHcqRY6L1LsDVqc/dzAdEs/E1FaPrcIaIIPw=="],
|
|
262
|
+
|
|
263
|
+
"@solana/signers": ["@solana/signers@2.3.0", "", { "dependencies": { "@solana/addresses": "2.3.0", "@solana/codecs-core": "2.3.0", "@solana/errors": "2.3.0", "@solana/instructions": "2.3.0", "@solana/keys": "2.3.0", "@solana/nominal-types": "2.3.0", "@solana/transaction-messages": "2.3.0", "@solana/transactions": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-OSv6fGr/MFRx6J+ZChQMRqKNPGGmdjkqarKkRzkwmv7v8quWsIRnJT5EV8tBy3LI4DLO/A8vKiNSPzvm1TdaiQ=="],
|
|
207
264
|
|
|
208
265
|
"@solana/spl-token": ["@solana/spl-token@0.4.13", "", { "dependencies": { "@solana/buffer-layout": "^4.0.0", "@solana/buffer-layout-utils": "^0.2.0", "@solana/spl-token-group": "^0.0.7", "@solana/spl-token-metadata": "^0.1.6", "buffer": "^6.0.3" }, "peerDependencies": { "@solana/web3.js": "^1.95.5" } }, "sha512-cite/pYWQZZVvLbg5lsodSovbetK/eA24gaR0eeUeMuBAMNrT8XFCwaygKy0N2WSg3gSyjjNpIeAGBAKZaY/1w=="],
|
|
209
266
|
|
|
@@ -211,6 +268,16 @@
|
|
|
211
268
|
|
|
212
269
|
"@solana/spl-token-metadata": ["@solana/spl-token-metadata@0.1.6", "", { "dependencies": { "@solana/codecs": "2.0.0-rc.1" }, "peerDependencies": { "@solana/web3.js": "^1.95.3" } }, "sha512-7sMt1rsm/zQOQcUWllQX9mD2O6KhSAtY1hFR2hfFwgqfFWzSY9E9GDvFVNYUI1F0iQKcm6HmePU9QbKRXTEBiA=="],
|
|
213
270
|
|
|
271
|
+
"@solana/subscribable": ["@solana/subscribable@2.3.0", "", { "dependencies": { "@solana/errors": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-DkgohEDbMkdTWiKAoatY02Njr56WXx9e/dKKfmne8/Ad6/2llUIrax78nCdlvZW9quXMaXPTxZvdQqo9N669Og=="],
|
|
272
|
+
|
|
273
|
+
"@solana/sysvars": ["@solana/sysvars@2.3.0", "", { "dependencies": { "@solana/accounts": "2.3.0", "@solana/codecs": "2.3.0", "@solana/errors": "2.3.0", "@solana/rpc-types": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-LvjADZrpZ+CnhlHqfI5cmsRzX9Rpyb1Ox2dMHnbsRNzeKAMhu9w4ZBIaeTdO322zsTr509G1B+k2ABD3whvUBA=="],
|
|
274
|
+
|
|
275
|
+
"@solana/transaction-confirmation": ["@solana/transaction-confirmation@2.3.0", "", { "dependencies": { "@solana/addresses": "2.3.0", "@solana/codecs-strings": "2.3.0", "@solana/errors": "2.3.0", "@solana/keys": "2.3.0", "@solana/promises": "2.3.0", "@solana/rpc": "2.3.0", "@solana/rpc-subscriptions": "2.3.0", "@solana/rpc-types": "2.3.0", "@solana/transaction-messages": "2.3.0", "@solana/transactions": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-UiEuiHCfAAZEKdfne/XljFNJbsKAe701UQHKXEInYzIgBjRbvaeYZlBmkkqtxwcasgBTOmEaEKT44J14N9VZDw=="],
|
|
276
|
+
|
|
277
|
+
"@solana/transaction-messages": ["@solana/transaction-messages@2.3.0", "", { "dependencies": { "@solana/addresses": "2.3.0", "@solana/codecs-core": "2.3.0", "@solana/codecs-data-structures": "2.3.0", "@solana/codecs-numbers": "2.3.0", "@solana/errors": "2.3.0", "@solana/functional": "2.3.0", "@solana/instructions": "2.3.0", "@solana/nominal-types": "2.3.0", "@solana/rpc-types": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-bgqvWuy3MqKS5JdNLH649q+ngiyOu5rGS3DizSnWwYUd76RxZl1kN6CoqHSrrMzFMvis6sck/yPGG3wqrMlAww=="],
|
|
278
|
+
|
|
279
|
+
"@solana/transactions": ["@solana/transactions@2.3.0", "", { "dependencies": { "@solana/addresses": "2.3.0", "@solana/codecs-core": "2.3.0", "@solana/codecs-data-structures": "2.3.0", "@solana/codecs-numbers": "2.3.0", "@solana/codecs-strings": "2.3.0", "@solana/errors": "2.3.0", "@solana/functional": "2.3.0", "@solana/instructions": "2.3.0", "@solana/keys": "2.3.0", "@solana/nominal-types": "2.3.0", "@solana/rpc-types": "2.3.0", "@solana/transaction-messages": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-LnTvdi8QnrQtuEZor5Msje61sDpPstTVwKg4y81tNxDhiyomjuvnSNLAq6QsB9gIxUqbNzPZgOG9IU4I4/Uaug=="],
|
|
280
|
+
|
|
214
281
|
"@solana/web3.js": ["@solana/web3.js@1.98.0", "", { "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", "@noble/hashes": "^1.4.0", "@solana/buffer-layout": "^4.0.1", "agentkeepalive": "^4.5.0", "bigint-buffer": "^1.1.5", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.1", "node-fetch": "^2.7.0", "rpc-websockets": "^9.0.2", "superstruct": "^2.0.2" } }, "sha512-nz3Q5OeyGFpFCR+erX2f6JPt3sKhzhYcSycBCSPkWjzSVDh/Rr1FqTVMRe58FKO16/ivTUcuJjeS5MyBvpkbzA=="],
|
|
215
282
|
|
|
216
283
|
"@swc/helpers": ["@swc/helpers@0.5.15", "", { "dependencies": { "tslib": "^2.8.0" } }, "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g=="],
|
|
@@ -607,6 +674,8 @@
|
|
|
607
674
|
|
|
608
675
|
"get-proto": ["get-proto@1.0.1", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="],
|
|
609
676
|
|
|
677
|
+
"gill": ["gill@0.10.2", "", { "dependencies": { "@solana-program/address-lookup-table": "^0.7.0", "@solana-program/compute-budget": "^0.8.0", "@solana-program/system": "^0.7.0", "@solana-program/token-2022": "^0.4.1", "@solana/assertions": "^2.1.1", "@solana/codecs": "^2.1.1", "@solana/kit": "^2.1.1", "@solana/transaction-confirmation": "^2.1.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-upWoY2dfOzKHOcX3UnD+B3h9WUunPv0oxeKzsIgKSaLyURpWK9oI+K2NHWbwrUFsXEK6ozu/sgkhuqyAcVTZCg=="],
|
|
678
|
+
|
|
610
679
|
"glob": ["glob@8.1.0", "", { "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^5.0.1", "once": "^1.3.0" } }, "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ=="],
|
|
611
680
|
|
|
612
681
|
"glob-parent": ["glob-parent@6.0.2", "", { "dependencies": { "is-glob": "^4.0.3" } }, "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A=="],
|
|
@@ -1109,6 +1178,12 @@
|
|
|
1109
1178
|
|
|
1110
1179
|
"@solana/errors/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="],
|
|
1111
1180
|
|
|
1181
|
+
"@solana/rpc-transport-http/undici-types": ["undici-types@7.12.0", "", {}, "sha512-goOacqME2GYyOZZfb5Lgtu+1IDmAlAEu5xnD3+xTzS10hT0vzpf0SPjkXwAw9Jm+4n/mQGDP3LO8CPbYROeBfQ=="],
|
|
1182
|
+
|
|
1183
|
+
"@solana/spl-token-group/@solana/codecs": ["@solana/codecs@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/codecs-data-structures": "2.0.0-rc.1", "@solana/codecs-numbers": "2.0.0-rc.1", "@solana/codecs-strings": "2.0.0-rc.1", "@solana/options": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-qxoR7VybNJixV51L0G1RD2boZTcxmwUWnKCaJJExQ5qNKwbpSyDdWfFJfM5JhGyKe9DnPVOZB+JHWXnpbZBqrQ=="],
|
|
1184
|
+
|
|
1185
|
+
"@solana/spl-token-metadata/@solana/codecs": ["@solana/codecs@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/codecs-data-structures": "2.0.0-rc.1", "@solana/codecs-numbers": "2.0.0-rc.1", "@solana/codecs-strings": "2.0.0-rc.1", "@solana/options": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-qxoR7VybNJixV51L0G1RD2boZTcxmwUWnKCaJJExQ5qNKwbpSyDdWfFJfM5JhGyKe9DnPVOZB+JHWXnpbZBqrQ=="],
|
|
1186
|
+
|
|
1112
1187
|
"@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.1", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-1IXGM/TfPT6nfYMIXkJdzn+L4JEsmb0FL1O2OBjaH03V3yuUDdKFulGLMFG6ErV+8pZ5HVC0limve01RyO+saA=="],
|
|
1113
1188
|
|
|
1114
1189
|
"@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="],
|
|
@@ -1199,6 +1274,22 @@
|
|
|
1199
1274
|
|
|
1200
1275
|
"@pythnetwork/solana-utils/bs58/base-x": ["base-x@4.0.0", "", {}, "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw=="],
|
|
1201
1276
|
|
|
1277
|
+
"@solana/spl-token-group/@solana/codecs/@solana/codecs-core": ["@solana/codecs-core@2.0.0-rc.1", "", { "dependencies": { "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ=="],
|
|
1278
|
+
|
|
1279
|
+
"@solana/spl-token-group/@solana/codecs/@solana/codecs-numbers": ["@solana/codecs-numbers@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-J5i5mOkvukXn8E3Z7sGIPxsThRCgSdgTWJDQeZvucQ9PT6Y3HiVXJ0pcWiOWAoQ3RX8e/f4I3IC+wE6pZiJzDQ=="],
|
|
1280
|
+
|
|
1281
|
+
"@solana/spl-token-group/@solana/codecs/@solana/codecs-strings": ["@solana/codecs-strings@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/codecs-numbers": "2.0.0-rc.1", "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "fastestsmallesttextencoderdecoder": "^1.0.22", "typescript": ">=5" } }, "sha512-9/wPhw8TbGRTt6mHC4Zz1RqOnuPTqq1Nb4EyuvpZ39GW6O2t2Q7Q0XxiB3+BdoEjwA2XgPw6e2iRfvYgqty44g=="],
|
|
1282
|
+
|
|
1283
|
+
"@solana/spl-token-group/@solana/codecs/@solana/options": ["@solana/options@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/codecs-data-structures": "2.0.0-rc.1", "@solana/codecs-numbers": "2.0.0-rc.1", "@solana/codecs-strings": "2.0.0-rc.1", "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-mLUcR9mZ3qfHlmMnREdIFPf9dpMc/Bl66tLSOOWxw4ml5xMT2ohFn7WGqoKcu/UHkT9CrC6+amEdqCNvUqI7AA=="],
|
|
1284
|
+
|
|
1285
|
+
"@solana/spl-token-metadata/@solana/codecs/@solana/codecs-core": ["@solana/codecs-core@2.0.0-rc.1", "", { "dependencies": { "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ=="],
|
|
1286
|
+
|
|
1287
|
+
"@solana/spl-token-metadata/@solana/codecs/@solana/codecs-numbers": ["@solana/codecs-numbers@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-J5i5mOkvukXn8E3Z7sGIPxsThRCgSdgTWJDQeZvucQ9PT6Y3HiVXJ0pcWiOWAoQ3RX8e/f4I3IC+wE6pZiJzDQ=="],
|
|
1288
|
+
|
|
1289
|
+
"@solana/spl-token-metadata/@solana/codecs/@solana/codecs-strings": ["@solana/codecs-strings@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/codecs-numbers": "2.0.0-rc.1", "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "fastestsmallesttextencoderdecoder": "^1.0.22", "typescript": ">=5" } }, "sha512-9/wPhw8TbGRTt6mHC4Zz1RqOnuPTqq1Nb4EyuvpZ39GW6O2t2Q7Q0XxiB3+BdoEjwA2XgPw6e2iRfvYgqty44g=="],
|
|
1290
|
+
|
|
1291
|
+
"@solana/spl-token-metadata/@solana/codecs/@solana/options": ["@solana/options@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/codecs-data-structures": "2.0.0-rc.1", "@solana/codecs-numbers": "2.0.0-rc.1", "@solana/codecs-strings": "2.0.0-rc.1", "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-mLUcR9mZ3qfHlmMnREdIFPf9dpMc/Bl66tLSOOWxw4ml5xMT2ohFn7WGqoKcu/UHkT9CrC6+amEdqCNvUqI7AA=="],
|
|
1292
|
+
|
|
1202
1293
|
"@solana/web3.js/rpc-websockets/@types/ws": ["@types/ws@8.5.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw=="],
|
|
1203
1294
|
|
|
1204
1295
|
"@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="],
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { DataAndSlot, AccountSubscriber, ResubOpts, BufferAndSlot } from './types';
|
|
4
|
+
import { Program } from '@coral-xyz/anchor';
|
|
5
|
+
import { AccountInfoBase, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, type Commitment } from 'gill';
|
|
6
|
+
import { PublicKey } from '@solana/web3.js';
|
|
7
|
+
export declare class WebSocketAccountSubscriberV2<T> implements AccountSubscriber<T> {
|
|
8
|
+
dataAndSlot?: DataAndSlot<T>;
|
|
9
|
+
bufferAndSlot?: BufferAndSlot;
|
|
10
|
+
accountName: string;
|
|
11
|
+
logAccountName: string;
|
|
12
|
+
program: Program;
|
|
13
|
+
accountPublicKey: PublicKey;
|
|
14
|
+
decodeBufferFn: (buffer: Buffer) => T;
|
|
15
|
+
onChange: (data: T) => void;
|
|
16
|
+
listenerId?: number;
|
|
17
|
+
resubOpts?: ResubOpts;
|
|
18
|
+
commitment?: Commitment;
|
|
19
|
+
isUnsubscribing: boolean;
|
|
20
|
+
timeoutId?: ReturnType<typeof setTimeout>;
|
|
21
|
+
receivingData: boolean;
|
|
22
|
+
private rpc;
|
|
23
|
+
private rpcSubscriptions;
|
|
24
|
+
private abortController?;
|
|
25
|
+
constructor(accountName: string, program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => T, resubOpts?: ResubOpts, commitment?: Commitment);
|
|
26
|
+
subscribe(onChange: (data: T) => void): Promise<void>;
|
|
27
|
+
setData(data: T, slot?: number): void;
|
|
28
|
+
protected setTimeout(): void;
|
|
29
|
+
fetch(): Promise<void>;
|
|
30
|
+
handleRpcResponse(context: {
|
|
31
|
+
slot: bigint;
|
|
32
|
+
}, accountInfo?: AccountInfoBase & (AccountInfoWithBase58EncodedData | AccountInfoWithBase64EncodedData)): void;
|
|
33
|
+
decodeBuffer(buffer: Buffer): T;
|
|
34
|
+
unsubscribe(onResub?: boolean): Promise<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WebSocketAccountSubscriberV2 = void 0;
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
const gill_1 = require("gill");
|
|
9
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
10
|
+
class WebSocketAccountSubscriberV2 {
|
|
11
|
+
constructor(accountName, program, accountPublicKey, decodeBuffer, resubOpts, commitment) {
|
|
12
|
+
var _a;
|
|
13
|
+
this.isUnsubscribing = false;
|
|
14
|
+
this.accountName = accountName;
|
|
15
|
+
this.logAccountName = `${accountName}-${accountPublicKey.toBase58()}-ws-acct-subscriber-v2`;
|
|
16
|
+
this.program = program;
|
|
17
|
+
this.accountPublicKey = accountPublicKey;
|
|
18
|
+
this.decodeBufferFn = decodeBuffer;
|
|
19
|
+
this.resubOpts = resubOpts;
|
|
20
|
+
if (((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs) < 1000) {
|
|
21
|
+
console.log(`resubTimeoutMs should be at least 1000ms to avoid spamming resub ${this.logAccountName}`);
|
|
22
|
+
}
|
|
23
|
+
this.receivingData = false;
|
|
24
|
+
if (['recent', 'single', 'singleGossip', 'root', 'max'].includes(this.program.provider.opts.commitment)) {
|
|
25
|
+
console.warn(`using commitment ${this.program.provider.opts.commitment} that is not supported by gill, this may cause issues`);
|
|
26
|
+
}
|
|
27
|
+
this.commitment =
|
|
28
|
+
commitment !== null && commitment !== void 0 ? commitment : this.program.provider.opts.commitment;
|
|
29
|
+
// Initialize gill client using the same RPC URL as the program provider
|
|
30
|
+
const rpcUrl = this.program.provider.connection
|
|
31
|
+
.rpcEndpoint;
|
|
32
|
+
const { rpc, rpcSubscriptions } = (0, gill_1.createSolanaClient)({
|
|
33
|
+
urlOrMoniker: rpcUrl,
|
|
34
|
+
});
|
|
35
|
+
this.rpc = rpc;
|
|
36
|
+
this.rpcSubscriptions = rpcSubscriptions;
|
|
37
|
+
}
|
|
38
|
+
async subscribe(onChange) {
|
|
39
|
+
var _a, _b, _c;
|
|
40
|
+
if (this.listenerId != null || this.isUnsubscribing) {
|
|
41
|
+
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
|
|
42
|
+
console.log(`[${this.logAccountName}] Subscribe returning early - listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`);
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.onChange = onChange;
|
|
47
|
+
if (!this.dataAndSlot) {
|
|
48
|
+
await this.fetch();
|
|
49
|
+
}
|
|
50
|
+
// Create abort controller for proper cleanup
|
|
51
|
+
const abortController = new AbortController();
|
|
52
|
+
this.abortController = abortController;
|
|
53
|
+
// Subscribe to account changes using gill's rpcSubscriptions
|
|
54
|
+
const pubkey = this.accountPublicKey.toBase58();
|
|
55
|
+
if ((0, gill_1.isAddress)(pubkey)) {
|
|
56
|
+
const subscription = await this.rpcSubscriptions
|
|
57
|
+
.accountNotifications(pubkey, {
|
|
58
|
+
commitment: this.commitment,
|
|
59
|
+
encoding: 'base64',
|
|
60
|
+
})
|
|
61
|
+
.subscribe({
|
|
62
|
+
abortSignal: abortController.signal,
|
|
63
|
+
});
|
|
64
|
+
for await (const notification of subscription) {
|
|
65
|
+
if ((_b = this.resubOpts) === null || _b === void 0 ? void 0 : _b.resubTimeoutMs) {
|
|
66
|
+
this.receivingData = true;
|
|
67
|
+
clearTimeout(this.timeoutId);
|
|
68
|
+
this.handleRpcResponse(notification.context, notification.value);
|
|
69
|
+
this.setTimeout();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
this.handleRpcResponse(notification.context, notification.value);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
this.listenerId = Math.random(); // Unique ID for logging purposes
|
|
77
|
+
if ((_c = this.resubOpts) === null || _c === void 0 ? void 0 : _c.resubTimeoutMs) {
|
|
78
|
+
this.receivingData = true;
|
|
79
|
+
this.setTimeout();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
setData(data, slot) {
|
|
83
|
+
const newSlot = slot || 0;
|
|
84
|
+
if (this.dataAndSlot && this.dataAndSlot.slot > newSlot) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.dataAndSlot = {
|
|
88
|
+
data,
|
|
89
|
+
slot,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
setTimeout() {
|
|
93
|
+
var _a;
|
|
94
|
+
if (!this.onChange) {
|
|
95
|
+
throw new Error('onChange callback function must be set');
|
|
96
|
+
}
|
|
97
|
+
this.timeoutId = setTimeout(async () => {
|
|
98
|
+
var _a, _b, _c, _d;
|
|
99
|
+
if (this.isUnsubscribing) {
|
|
100
|
+
// If we are in the process of unsubscribing, do not attempt to resubscribe
|
|
101
|
+
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
|
|
102
|
+
console.log(`[${this.logAccountName}] Timeout fired but isUnsubscribing=true, skipping resubscribe`);
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (this.receivingData) {
|
|
107
|
+
if ((_b = this.resubOpts) === null || _b === void 0 ? void 0 : _b.logResubMessages) {
|
|
108
|
+
console.log(`No ws data from ${this.logAccountName} in ${this.resubOpts.resubTimeoutMs}ms, resubscribing - listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`);
|
|
109
|
+
}
|
|
110
|
+
await this.unsubscribe(true);
|
|
111
|
+
this.receivingData = false;
|
|
112
|
+
await this.subscribe(this.onChange);
|
|
113
|
+
if ((_c = this.resubOpts) === null || _c === void 0 ? void 0 : _c.logResubMessages) {
|
|
114
|
+
console.log(`[${this.logAccountName}] Resubscribe completed - receivingData=${this.receivingData}, listenerId=${this.listenerId}, isUnsubscribing=${this.isUnsubscribing}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
if ((_d = this.resubOpts) === null || _d === void 0 ? void 0 : _d.logResubMessages) {
|
|
119
|
+
console.log(`[${this.logAccountName}] Timeout fired but receivingData=false, skipping resubscribe`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}, (_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs);
|
|
123
|
+
}
|
|
124
|
+
async fetch() {
|
|
125
|
+
// Use gill's rpc for fetching account info
|
|
126
|
+
const accountAddress = this.accountPublicKey.toBase58();
|
|
127
|
+
const rpcResponse = await this.rpc
|
|
128
|
+
.getAccountInfo(accountAddress, {
|
|
129
|
+
commitment: this.commitment,
|
|
130
|
+
encoding: 'base64',
|
|
131
|
+
})
|
|
132
|
+
.send();
|
|
133
|
+
// Convert gill response to match the expected format
|
|
134
|
+
const context = {
|
|
135
|
+
slot: Number(rpcResponse.context.slot),
|
|
136
|
+
};
|
|
137
|
+
const accountInfo = rpcResponse.value;
|
|
138
|
+
this.handleRpcResponse({ slot: BigInt(context.slot) }, accountInfo);
|
|
139
|
+
}
|
|
140
|
+
handleRpcResponse(context, accountInfo) {
|
|
141
|
+
const newSlot = context.slot;
|
|
142
|
+
let newBuffer = undefined;
|
|
143
|
+
if (accountInfo) {
|
|
144
|
+
// Extract data from gill response
|
|
145
|
+
if (accountInfo.data) {
|
|
146
|
+
// Handle different data formats from gill
|
|
147
|
+
if (Array.isArray(accountInfo.data)) {
|
|
148
|
+
// If it's a tuple [data, encoding]
|
|
149
|
+
const [data, encoding] = accountInfo.data;
|
|
150
|
+
if (encoding === 'base58') {
|
|
151
|
+
// we know encoding will be base58
|
|
152
|
+
// Convert base58 to buffer using bs58
|
|
153
|
+
newBuffer = Buffer.from(bs58_1.default.decode(data));
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
newBuffer = Buffer.from(data, 'base64');
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (!this.bufferAndSlot) {
|
|
162
|
+
this.bufferAndSlot = {
|
|
163
|
+
buffer: newBuffer,
|
|
164
|
+
slot: Number(newSlot),
|
|
165
|
+
};
|
|
166
|
+
if (newBuffer) {
|
|
167
|
+
const account = this.decodeBuffer(newBuffer);
|
|
168
|
+
this.dataAndSlot = {
|
|
169
|
+
data: account,
|
|
170
|
+
slot: Number(newSlot),
|
|
171
|
+
};
|
|
172
|
+
this.onChange(account);
|
|
173
|
+
}
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (Number(newSlot) < this.bufferAndSlot.slot) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const oldBuffer = this.bufferAndSlot.buffer;
|
|
180
|
+
if (newBuffer && (!oldBuffer || !newBuffer.equals(oldBuffer))) {
|
|
181
|
+
this.bufferAndSlot = {
|
|
182
|
+
buffer: newBuffer,
|
|
183
|
+
slot: Number(newSlot),
|
|
184
|
+
};
|
|
185
|
+
const account = this.decodeBuffer(newBuffer);
|
|
186
|
+
this.dataAndSlot = {
|
|
187
|
+
data: account,
|
|
188
|
+
slot: Number(newSlot),
|
|
189
|
+
};
|
|
190
|
+
this.onChange(account);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
decodeBuffer(buffer) {
|
|
194
|
+
if (this.decodeBufferFn) {
|
|
195
|
+
return this.decodeBufferFn(buffer);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
return this.program.account[this.accountName].coder.accounts.decode((0, utils_1.capitalize)(this.accountName), buffer);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
unsubscribe(onResub = false) {
|
|
202
|
+
if (!onResub && this.resubOpts) {
|
|
203
|
+
this.resubOpts.resubTimeoutMs = undefined;
|
|
204
|
+
}
|
|
205
|
+
this.isUnsubscribing = true;
|
|
206
|
+
clearTimeout(this.timeoutId);
|
|
207
|
+
this.timeoutId = undefined;
|
|
208
|
+
// Abort the WebSocket subscription
|
|
209
|
+
if (this.abortController) {
|
|
210
|
+
this.abortController.abort('unsubscribing');
|
|
211
|
+
this.abortController = undefined;
|
|
212
|
+
}
|
|
213
|
+
this.listenerId = undefined;
|
|
214
|
+
this.isUnsubscribing = false;
|
|
215
|
+
return Promise.resolve();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
exports.WebSocketAccountSubscriberV2 = WebSocketAccountSubscriberV2;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
2
4
|
import { AccountSubscriber, DataAndSlot, DelistedMarketSetting, DriftClientAccountEvents, DriftClientAccountSubscriber, ResubOpts } from './types';
|
|
3
5
|
import { PerpMarketAccount, SpotMarketAccount, StateAccount } from '../types';
|
|
4
6
|
import { Program } from '@coral-xyz/anchor';
|
|
5
7
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
6
8
|
import { EventEmitter } from 'events';
|
|
9
|
+
import { WebSocketAccountSubscriber } from './webSocketAccountSubscriber';
|
|
7
10
|
import { Commitment, PublicKey } from '@solana/web3.js';
|
|
8
11
|
import { OracleInfo, OraclePriceData } from '../oracles/types';
|
|
9
12
|
import { OracleClientCache } from '../oracles/oracleClientCache';
|
|
13
|
+
import { WebSocketAccountSubscriberV2 } from './webSocketAccountSubscriberV2';
|
|
10
14
|
export declare class WebSocketDriftClientAccountSubscriber implements DriftClientAccountSubscriber {
|
|
11
15
|
isSubscribed: boolean;
|
|
12
16
|
program: Program;
|
|
@@ -30,10 +34,11 @@ export declare class WebSocketDriftClientAccountSubscriber implements DriftClien
|
|
|
30
34
|
initialPerpMarketAccountData: Map<number, PerpMarketAccount>;
|
|
31
35
|
initialSpotMarketAccountData: Map<number, SpotMarketAccount>;
|
|
32
36
|
initialOraclePriceData: Map<string, OraclePriceData>;
|
|
37
|
+
customPerpMarketAccountSubscriber?: new (accountName: string, program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, commitment?: Commitment) => AccountSubscriber<any>;
|
|
33
38
|
protected isSubscribing: boolean;
|
|
34
39
|
protected subscriptionPromise: Promise<boolean>;
|
|
35
40
|
protected subscriptionPromiseResolver: (val: boolean) => void;
|
|
36
|
-
constructor(program: Program, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], shouldFindAllMarketsAndOracles: boolean, delistedMarketSetting: DelistedMarketSetting, resubOpts?: ResubOpts, commitment?: Commitment);
|
|
41
|
+
constructor(program: Program, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], shouldFindAllMarketsAndOracles: boolean, delistedMarketSetting: DelistedMarketSetting, resubOpts?: ResubOpts, commitment?: Commitment, customPerpMarketAccountSubscriber?: new (accountName: string, program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, commitment?: Commitment) => WebSocketAccountSubscriberV2<any> | WebSocketAccountSubscriber<any>);
|
|
37
42
|
subscribe(): Promise<boolean>;
|
|
38
43
|
chunks: <T>(array: readonly T[], size: number) => T[][];
|
|
39
44
|
setInitialData(): Promise<void>;
|
|
@@ -14,7 +14,7 @@ const oracleId_1 = require("../oracles/oracleId");
|
|
|
14
14
|
const types_2 = require("../types");
|
|
15
15
|
const ORACLE_DEFAULT_ID = (0, oracleId_1.getOracleId)(web3_js_1.PublicKey.default, types_2.OracleSource.QUOTE_ASSET);
|
|
16
16
|
class WebSocketDriftClientAccountSubscriber {
|
|
17
|
-
constructor(program, perpMarketIndexes, spotMarketIndexes, oracleInfos, shouldFindAllMarketsAndOracles, delistedMarketSetting, resubOpts, commitment) {
|
|
17
|
+
constructor(program, perpMarketIndexes, spotMarketIndexes, oracleInfos, shouldFindAllMarketsAndOracles, delistedMarketSetting, resubOpts, commitment, customPerpMarketAccountSubscriber) {
|
|
18
18
|
this.oracleClientCache = new oracleClientCache_1.OracleClientCache();
|
|
19
19
|
this.perpMarketAccountSubscribers = new Map();
|
|
20
20
|
this.perpOracleMap = new Map();
|
|
@@ -40,6 +40,7 @@ class WebSocketDriftClientAccountSubscriber {
|
|
|
40
40
|
this.delistedMarketSetting = delistedMarketSetting;
|
|
41
41
|
this.resubOpts = resubOpts;
|
|
42
42
|
this.commitment = commitment;
|
|
43
|
+
this.customPerpMarketAccountSubscriber = customPerpMarketAccountSubscriber;
|
|
43
44
|
}
|
|
44
45
|
async subscribe() {
|
|
45
46
|
if (this.isSubscribed) {
|
|
@@ -138,7 +139,8 @@ class WebSocketDriftClientAccountSubscriber {
|
|
|
138
139
|
}
|
|
139
140
|
async subscribeToPerpMarketAccount(marketIndex) {
|
|
140
141
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
|
|
141
|
-
const
|
|
142
|
+
const AccountSubscriberClass = this.customPerpMarketAccountSubscriber || webSocketAccountSubscriber_1.WebSocketAccountSubscriber;
|
|
143
|
+
const accountSubscriber = new AccountSubscriberClass('perpMarket', this.program, perpMarketPublicKey, undefined, this.resubOpts, this.commitment);
|
|
142
144
|
accountSubscriber.setData(this.initialPerpMarketAccountData.get(marketIndex));
|
|
143
145
|
await accountSubscriber.subscribe((data) => {
|
|
144
146
|
this.eventEmitter.emit('perpMarketAccountUpdate', data);
|
|
@@ -84,7 +84,7 @@ class DriftClient {
|
|
|
84
84
|
this._isSubscribed = val;
|
|
85
85
|
}
|
|
86
86
|
constructor(config) {
|
|
87
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20;
|
|
87
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21;
|
|
88
88
|
this.users = new Map();
|
|
89
89
|
this._isSubscribed = false;
|
|
90
90
|
this.perpMarketLastSlotCache = new Map();
|
|
@@ -214,7 +214,7 @@ class DriftClient {
|
|
|
214
214
|
this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (_14 = config.perpMarketIndexes) !== null && _14 !== void 0 ? _14 : [], (_15 = config.spotMarketIndexes) !== null && _15 !== void 0 ? _15 : [], (_16 = config.oracleInfos) !== null && _16 !== void 0 ? _16 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
|
|
215
215
|
resubTimeoutMs: (_17 = config.accountSubscription) === null || _17 === void 0 ? void 0 : _17.resubTimeoutMs,
|
|
216
216
|
logResubMessages: (_18 = config.accountSubscription) === null || _18 === void 0 ? void 0 : _18.logResubMessages,
|
|
217
|
-
}, (_19 = config.accountSubscription) === null || _19 === void 0 ? void 0 : _19.commitment);
|
|
217
|
+
}, (_19 = config.accountSubscription) === null || _19 === void 0 ? void 0 : _19.commitment, (_20 = config.accountSubscription) === null || _20 === void 0 ? void 0 : _20.perpMarketAccountSubscriber);
|
|
218
218
|
}
|
|
219
219
|
this.eventEmitter = this.accountSubscriber.eventEmitter;
|
|
220
220
|
this.metricsEventEmitter = new events_1.EventEmitter();
|
|
@@ -222,7 +222,7 @@ class DriftClient {
|
|
|
222
222
|
this.enableMetricsEvents = true;
|
|
223
223
|
}
|
|
224
224
|
this.txSender =
|
|
225
|
-
(
|
|
225
|
+
(_21 = config.txSender) !== null && _21 !== void 0 ? _21 : new retryTxSender_1.RetryTxSender({
|
|
226
226
|
connection: this.connection,
|
|
227
227
|
wallet: this.wallet,
|
|
228
228
|
opts: this.opts,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
1
3
|
import { Commitment, ConfirmOptions, Connection, PublicKey, TransactionVersion } from '@solana/web3.js';
|
|
2
4
|
import { IWallet, TxParams } from './types';
|
|
3
5
|
import { OracleInfo } from './oracles/types';
|
|
@@ -5,8 +7,10 @@ import { BulkAccountLoader } from './accounts/bulkAccountLoader';
|
|
|
5
7
|
import { DriftEnv } from './config';
|
|
6
8
|
import { TxSender } from './tx/types';
|
|
7
9
|
import { TxHandler, TxHandlerConfig } from './tx/txHandler';
|
|
8
|
-
import {
|
|
9
|
-
import { Coder } from '@coral-xyz/anchor';
|
|
10
|
+
import { GrpcConfigs, ResubOpts, DelistedMarketSetting } from './accounts/types';
|
|
11
|
+
import { Coder, Program } from '@coral-xyz/anchor';
|
|
12
|
+
import { WebSocketAccountSubscriber } from './accounts/webSocketAccountSubscriber';
|
|
13
|
+
import { WebSocketAccountSubscriberV2 } from './accounts/webSocketAccountSubscriberV2';
|
|
10
14
|
export type DriftClientConfig = {
|
|
11
15
|
connection: Connection;
|
|
12
16
|
wallet: IWallet;
|
|
@@ -47,6 +51,7 @@ export type DriftClientSubscriptionConfig = {
|
|
|
47
51
|
resubTimeoutMs?: number;
|
|
48
52
|
logResubMessages?: boolean;
|
|
49
53
|
commitment?: Commitment;
|
|
54
|
+
perpMarketAccountSubscriber?: new (accountName: string, program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, commitment?: Commitment) => WebSocketAccountSubscriberV2<any> | WebSocketAccountSubscriber<any>;
|
|
50
55
|
} | {
|
|
51
56
|
type: 'polling';
|
|
52
57
|
accountLoader: BulkAccountLoader;
|
|
@@ -13738,13 +13738,6 @@
|
|
|
13738
13738
|
"option": "u64"
|
|
13739
13739
|
},
|
|
13740
13740
|
"index": false
|
|
13741
|
-
},
|
|
13742
|
-
{
|
|
13743
|
-
"name": "triggerPrice",
|
|
13744
|
-
"type": {
|
|
13745
|
-
"option": "u64"
|
|
13746
|
-
},
|
|
13747
|
-
"index": false
|
|
13748
13741
|
}
|
|
13749
13742
|
]
|
|
13750
13743
|
},
|
package/lib/browser/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './accounts/fetch';
|
|
|
11
11
|
export * from './accounts/webSocketDriftClientAccountSubscriber';
|
|
12
12
|
export * from './accounts/webSocketInsuranceFundStakeAccountSubscriber';
|
|
13
13
|
export * from './accounts/webSocketHighLeverageModeConfigAccountSubscriber';
|
|
14
|
+
export { WebSocketAccountSubscriberV2 } from './accounts/webSocketAccountSubscriberV2';
|
|
14
15
|
export * from './accounts/bulkAccountLoader';
|
|
15
16
|
export * from './accounts/bulkUserSubscription';
|
|
16
17
|
export * from './accounts/bulkUserStatsSubscription';
|
package/lib/browser/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.pyth = exports.PublicKey = exports.BN = exports.CustomizedCadenceBulkAccountLoader = void 0;
|
|
20
|
+
exports.pyth = exports.PublicKey = exports.BN = exports.CustomizedCadenceBulkAccountLoader = exports.WebSocketAccountSubscriberV2 = void 0;
|
|
21
21
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
22
22
|
Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return anchor_1.BN; } });
|
|
23
23
|
const web3_js_1 = require("@solana/web3.js");
|
|
@@ -34,6 +34,8 @@ __exportStar(require("./accounts/fetch"), exports);
|
|
|
34
34
|
__exportStar(require("./accounts/webSocketDriftClientAccountSubscriber"), exports);
|
|
35
35
|
__exportStar(require("./accounts/webSocketInsuranceFundStakeAccountSubscriber"), exports);
|
|
36
36
|
__exportStar(require("./accounts/webSocketHighLeverageModeConfigAccountSubscriber"), exports);
|
|
37
|
+
var webSocketAccountSubscriberV2_1 = require("./accounts/webSocketAccountSubscriberV2");
|
|
38
|
+
Object.defineProperty(exports, "WebSocketAccountSubscriberV2", { enumerable: true, get: function () { return webSocketAccountSubscriberV2_1.WebSocketAccountSubscriberV2; } });
|
|
37
39
|
__exportStar(require("./accounts/bulkAccountLoader"), exports);
|
|
38
40
|
__exportStar(require("./accounts/bulkUserSubscription"), exports);
|
|
39
41
|
__exportStar(require("./accounts/bulkUserStatsSubscription"), exports);
|