add providerType() getter to AbstractProvider
This commit is contained in:
parent
32915634be
commit
6344644197
@ -428,6 +428,8 @@ type CcipArgs = {
|
||||
errorArgs: Array<any>
|
||||
};
|
||||
|
||||
type ProviderType = "jsonrpc" | "etherscan" | "fallback" | "";
|
||||
|
||||
/**
|
||||
* An **AbstractProvider** provides a base class for other sub-classes to
|
||||
* implement the [[Provider]] API by normalizing input arguments and
|
||||
@ -504,6 +506,17 @@ export class AbstractProvider implements Provider {
|
||||
*/
|
||||
get provider(): this { return this; }
|
||||
|
||||
/**
|
||||
* Returns a string that identifies the AbstractProvider subclass, for
|
||||
* better duck typing.
|
||||
*/
|
||||
get providerType(): ProviderType {
|
||||
assert(false, "not implemented yet", "NOT_IMPLEMENTED", {
|
||||
operation: "providerType"
|
||||
});
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the registered plug-ins.
|
||||
*/
|
||||
|
@ -142,6 +142,10 @@ export class EtherscanProvider extends AbstractProvider {
|
||||
this.getBaseUrl();
|
||||
}
|
||||
|
||||
get providerType() {
|
||||
return 'etherscan' as const;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base URL.
|
||||
*
|
||||
|
@ -414,6 +414,10 @@ export class FallbackProvider extends AbstractProvider {
|
||||
"quorum exceed provider wieght", "quorum", this.quorum);
|
||||
}
|
||||
|
||||
get providerType() {
|
||||
return 'fallback' as const;
|
||||
}
|
||||
|
||||
get providerConfigs(): Array<FallbackProviderState> {
|
||||
return this.#configs.map((c) => {
|
||||
const result: any = Object.assign({ }, c);
|
||||
|
@ -572,6 +572,10 @@ export abstract class JsonRpcApiProvider extends AbstractProvider {
|
||||
}
|
||||
}
|
||||
|
||||
get providerType() {
|
||||
return 'jsonrpc' as const;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value associated with the option %%key%%.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user