function waitForSync(config, blockNumber) {
    return __awaiter$f(this, void 0, void 0, function* () {
        const provider = (config.provider);
        if ((provider.blockNumber != null && provider.blockNumber >= blockNumber) || blockNumber === -1) {
            return provider;
        }
        return poll(() => {
            return new Promise((resolve, reject) => {
                setTimeout(function () {
                    // We are synced
                    if (provider.blockNumber >= blockNumber) {
                        return resolve(provider);
                    }
                    // We're done; just quit
                    if (config.cancelled) {
                        return resolve(null);
                    }
                    // Try again, next block
                    return resolve(undefined);
                }, 0);
            });
        }, { oncePoll: provider });
    });
}
// caught up to the FallbackProvider, before sending a request to it.
caught up to the FallbackProvider, before sending a request to it.
caught up to the FallbackProvider before sending a request to it .
function waitForSync(config, blockNumber) {
    return __awaiter$f(this, void 0, void 0, function* () {
        const provider = (config.provider);
        if ((provider.blockNumber != null && provider.blockNumber >= blockNumber) || blockNumber === -1) {
            return provider;
        }
        return poll(() => {
            return new Promise((resolve, reject) => {
                setTimeout(function () {
                    if (provider.blockNumber >= blockNumber) {
                        return resolve(provider);
                    }
                    if (config.cancelled) {
                        return resolve(null);
                    }
                    return resolve(undefined);
                }, 0);
            });
        }, { oncePoll: provider });
    });
}
function waitForSync ( config , blockNumber ) { return __awaiter$f ( this , void 0 , void 0 , function * ( ) { const provider = ( config . provider ) ; if ( ( provider . blockNumber != null && provider . blockNumber >= blockNumber ) || blockNumber === - 1 ) { return provider ; } return poll ( ( ) => { return new Promise ( ( resolve , reject ) => { setTimeout ( function ( ) { if ( provider . blockNumber >= blockNumber ) { return resolve ( provider ) ; } if ( config . cancelled ) { return resolve ( null ) ; } return resolve ( undefined ) ; } , 0 ) ; } ) ; } , { oncePoll : provider } ) ; } ) ; }
caught up to the FallbackProvider, before sending a request to it.
caught up to the FallbackProvider before sending a request to it .
// We are synced // We're done; just quit // Try again, next block