ethers.js/lib.esm/providers/provider-etherscan.js
2022-11-30 15:44:23 -05:00

30 lines
891 B
JavaScript

/**
* Aboud Etherscan...
*
* @_subsection api/providers/thirdparty:Etherscan [etherscan]
*/
import { BaseEtherscanProvider } from "./provider-etherscan-base.js";
import { Contract } from "../contract/index.js";
function isPromise(value) {
return (value && typeof (value.then) === "function");
}
/**
* Aboud EtherscanProvider...
*/
export class EtherscanProvider extends BaseEtherscanProvider {
async getContract(_address) {
let address = this._getAddress(_address);
if (isPromise(address)) {
address = await address;
}
try {
const resp = await this.fetch("contract", { action: "getabi", address });
const abi = JSON.parse(resp);
return new Contract(address, abi, this);
}
catch (error) {
return null;
}
}
}
//# sourceMappingURL=provider-etherscan.js.map