11import { PublicKey } from "@solana/web3.js" ;
2- import * as assert from "assert" ;
32import { IdlEvent , IdlEventField } from "../idl.js" ;
43import { Coder } from "../coder/index.js" ;
54import { DecodeType } from "./namespace/types.js" ;
@@ -144,8 +143,13 @@ export class EventManager {
144143 }
145144
146145 // Kill the websocket connection if all listeners have been removed.
147- if ( this . _eventCallbacks . size == 0 ) {
148- assert . ok ( this . _eventListeners . size === 0 ) ;
146+ if ( this . _eventCallbacks . size === 0 ) {
147+ if ( this . _eventListeners . size !== 0 ) {
148+ throw new Error (
149+ `Expected event listeners size to be 0 but got ${ this . _eventListeners . size } `
150+ ) ;
151+ }
152+
149153 if ( this . _onLogsSubscriptionId !== undefined ) {
150154 await this . _provider ! . connection . removeOnLogsListener (
151155 this . _onLogsSubscriptionId
@@ -273,7 +277,9 @@ class ExecutionContext {
273277 stack : string [ ] = [ ] ;
274278
275279 program ( ) : string {
276- assert . ok ( this . stack . length > 0 ) ;
280+ if ( ! this . stack . length ) {
281+ throw new Error ( "Expected the stack to have elements" ) ;
282+ }
277283 return this . stack [ this . stack . length - 1 ] ;
278284 }
279285
@@ -282,7 +288,9 @@ class ExecutionContext {
282288 }
283289
284290 pop ( ) {
285- assert . ok ( this . stack . length > 0 ) ;
291+ if ( ! this . stack . length ) {
292+ throw new Error ( "Expected the stack to have elements" ) ;
293+ }
286294 this . stack . pop ( ) ;
287295 }
288296}
0 commit comments