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

34 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-09-05 23:57:11 +03:00
"use strict";
2022-11-30 23:44:23 +03:00
/**
* Aboud Etherscan...
*
* @_subsection api/providers/thirdparty:Etherscan [etherscan]
*/
2022-09-05 23:57:11 +03:00
Object.defineProperty(exports, "__esModule", { value: true });
2022-09-27 10:45:27 +03:00
exports.EtherscanProvider = void 0;
const provider_etherscan_base_js_1 = require("./provider-etherscan-base.js");
const index_js_1 = require("../contract/index.js");
function isPromise(value) {
return (value && typeof (value.then) === "function");
2022-09-05 23:57:11 +03:00
}
2022-11-30 23:44:23 +03:00
/**
* Aboud EtherscanProvider...
*/
2022-09-27 10:45:27 +03:00
class EtherscanProvider extends provider_etherscan_base_js_1.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 index_js_1.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
}
}
}
exports.EtherscanProvider = EtherscanProvider;
//# sourceMappingURL=provider-etherscan.js.map