ethers.js/packages/experimental/lib.esm/retry-provider.js

28 lines
965 B
JavaScript
Raw Permalink Normal View History

"use strict";
// RetryProvider
//
// Wraps an existing Provider to provide retry logic.
//
// See: https://github.com/ethers-io/ethers.js/issues/427
import { ethers } from "ethers";
import { poll } from "@ethersproject/web";
import { version } from "./_version";
const logger = new ethers.utils.Logger(version);
export class RetryProvider extends ethers.providers.BaseProvider {
constructor(provider, options) {
logger.checkNew(new.target, RetryProvider);
super(provider.getNetwork());
ethers.utils.defineReadOnly(this, "provider", provider);
ethers.utils.defineReadOnly(this, "options", options || {});
}
perform(method, params) {
return poll(() => {
return this.provider.perform(method, params).then((result) => {
return result;
}, (error) => {
return undefined;
});
}, this.options);
}
}
2020-07-13 08:03:56 -04:00
//# sourceMappingURL=retry-provider.js.map