ethers.js/lib.esm/providers/provider-etherscan.js

22 lines
753 B
JavaScript
Raw Normal View History

2022-09-27 10:45:27 +03:00
import { BaseEtherscanProvider } from "./provider-etherscan-base.js";
import { Contract } from "../contract/index.js";
function isPromise(value) {
return (value && typeof (value.then) === "function");
2022-09-05 23:57:11 +03:00
}
2022-09-27 10:45:27 +03:00
export class EtherscanProvider extends BaseEtherscanProvider {
async getContract(_address) {
let address = this._getAddress(_address);
if (isPromise(address)) {
address = await address;
2022-09-05 23:57:11 +03:00
}
2022-09-27 10:45:27 +03:00
try {
const resp = await this.fetch("contract", { action: "getabi", address });
const abi = JSON.parse(resp);
return new Contract(address, abi, this);
2022-09-05 23:57:11 +03:00
}
2022-09-27 10:45:27 +03:00
catch (error) {
return null;
2022-09-05 23:57:11 +03:00
}
}
}
//# sourceMappingURL=provider-etherscan.js.map