@@ -10,11 +10,10 @@ import * as bs58 from 'bs58';
1010const credentials = require ( '../test-config' ) ;
1111
1212async function main ( ) {
13- console . log ( '🏦 Laserstream Account Subscription Example' ) ;
1413
1514 const config : LaserstreamConfig = {
16- apiKey : credentials . laserstreamProduction . apiKey ,
17- endpoint : credentials . laserstreamProduction . endpoint ,
15+ apiKey : "your-api-key" ,
16+ endpoint : "your- endpoint" ,
1817 } ;
1918
2019 const request = {
@@ -39,30 +38,17 @@ async function main() {
3938 config ,
4039 request ,
4140 async ( update : SubscribeUpdate ) => {
42- if ( update . account ) {
43- const accountUpdate : SubscribeUpdateAccount = update . account ;
44- console . log ( '\n🏦 Account Update Received!' ) ;
45- console . log ( ' - Slot:' , accountUpdate . slot ) ;
46- console . log ( ' - Is Startup:' , accountUpdate . isStartup ) ;
47-
48- if ( accountUpdate . account ) {
49- const accountInfo : SubscribeUpdateAccountInfo = accountUpdate . account ;
50- console . log ( ' - Account Info:' ) ;
51- console . log ( ' - Pubkey:' , accountInfo . pubkey ? bs58 . encode ( accountInfo . pubkey ) : 'N/A' ) ;
52- console . log ( ' - Lamports:' , accountInfo . lamports ) ;
53- console . log ( ' - Owner:' , accountInfo . owner ? bs58 . encode ( accountInfo . owner ) : 'N/A' ) ;
54- console . log ( ' - Executable:' , accountInfo . executable ) ;
55- console . log ( ' - Rent Epoch:' , accountInfo . rentEpoch ) ;
56- console . log ( ' - Data Length:' , accountInfo . data ? accountInfo . data . length : 0 ) ;
57- console . log ( ' - Write Version:' , accountInfo . writeVersion ) ;
58- console . log ( ' - Txn Signature:' , accountInfo . txnSignature ? bs58 . encode ( accountInfo . txnSignature ) : 'N/A' ) ;
59- }
60- }
41+ console . log ( JSON . stringify ( update , null , 2 ) ) ;
6142 } ,
62- async ( err ) => console . error ( '❌ Stream error:' , err )
43+ ( error : Error ) => {
44+ console . error ( "Stream error:" , error ) ;
45+ }
6346 ) ;
6447
65- console . log ( `✅ Account subscription started (id: ${ stream . id } )` ) ;
48+ process . on ( "SIGINT" , ( ) => {
49+ stream . cancel ( ) ;
50+ process . exit ( 0 ) ;
51+ } ) ;
6652}
6753
6854main ( ) . catch ( console . error ) ;
0 commit comments