2022-09-05 16:57:11 -04:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2022-11-30 15:44:23 -05:00
|
|
|
exports.FeeDataNetworkPlugin = exports.EnsPlugin = exports.GasCostPlugin = exports.NetworkPlugin = void 0;
|
2022-09-05 16:57:11 -04:00
|
|
|
const properties_js_1 = require("../utils/properties.js");
|
2022-09-15 22:58:45 -04:00
|
|
|
const index_js_1 = require("../utils/index.js");
|
2022-09-05 16:57:11 -04:00
|
|
|
const EnsAddress = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
|
|
|
|
class NetworkPlugin {
|
|
|
|
name;
|
|
|
|
constructor(name) {
|
|
|
|
(0, properties_js_1.defineProperties)(this, { name });
|
|
|
|
}
|
|
|
|
clone() {
|
|
|
|
return new NetworkPlugin(this.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.NetworkPlugin = NetworkPlugin;
|
|
|
|
class GasCostPlugin extends NetworkPlugin {
|
|
|
|
effectiveBlock;
|
|
|
|
txBase;
|
|
|
|
txCreate;
|
|
|
|
txDataZero;
|
|
|
|
txDataNonzero;
|
|
|
|
txAccessListStorageKey;
|
|
|
|
txAccessListAddress;
|
2022-11-30 15:44:23 -05:00
|
|
|
constructor(effectiveBlock, costs) {
|
|
|
|
if (effectiveBlock == null) {
|
|
|
|
effectiveBlock = 0;
|
|
|
|
}
|
2023-02-02 04:05:47 -05:00
|
|
|
super(`org.ethers.network.plugins.GasCost#${(effectiveBlock || 0)}`);
|
2022-09-05 16:57:11 -04:00
|
|
|
const props = { effectiveBlock };
|
|
|
|
function set(name, nullish) {
|
|
|
|
let value = (costs || {})[name];
|
|
|
|
if (value == null) {
|
|
|
|
value = nullish;
|
|
|
|
}
|
2022-11-09 02:57:02 -05:00
|
|
|
(0, index_js_1.assertArgument)(typeof (value) === "number", `invalud value for ${name}`, "costs", costs);
|
2022-09-05 16:57:11 -04:00
|
|
|
props[name] = value;
|
|
|
|
}
|
|
|
|
set("txBase", 21000);
|
|
|
|
set("txCreate", 32000);
|
|
|
|
set("txDataZero", 4);
|
|
|
|
set("txDataNonzero", 16);
|
|
|
|
set("txAccessListStorageKey", 1900);
|
|
|
|
set("txAccessListAddress", 2400);
|
|
|
|
(0, properties_js_1.defineProperties)(this, props);
|
|
|
|
}
|
|
|
|
clone() {
|
|
|
|
return new GasCostPlugin(this.effectiveBlock, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.GasCostPlugin = GasCostPlugin;
|
|
|
|
// Networks shoudl use this plugin to specify the contract address
|
|
|
|
// and network necessary to resolve ENS names.
|
|
|
|
class EnsPlugin extends NetworkPlugin {
|
|
|
|
// The ENS contract address
|
|
|
|
address;
|
|
|
|
// The network ID that the ENS contract lives on
|
|
|
|
targetNetwork;
|
|
|
|
constructor(address, targetNetwork) {
|
2023-02-02 04:05:47 -05:00
|
|
|
super("org.ethers.plugins.network.Ens");
|
2022-09-05 16:57:11 -04:00
|
|
|
(0, properties_js_1.defineProperties)(this, {
|
|
|
|
address: (address || EnsAddress),
|
|
|
|
targetNetwork: ((targetNetwork == null) ? 1 : targetNetwork)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
clone() {
|
|
|
|
return new EnsPlugin(this.address, this.targetNetwork);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.EnsPlugin = EnsPlugin;
|
|
|
|
class FeeDataNetworkPlugin extends NetworkPlugin {
|
|
|
|
#feeDataFunc;
|
2023-02-02 04:05:47 -05:00
|
|
|
get feeDataFunc() {
|
|
|
|
return this.#feeDataFunc;
|
|
|
|
}
|
2022-09-05 16:57:11 -04:00
|
|
|
constructor(feeDataFunc) {
|
2023-02-02 04:05:47 -05:00
|
|
|
super("org.ethers.plugins.network.FeeData");
|
2022-09-05 16:57:11 -04:00
|
|
|
this.#feeDataFunc = feeDataFunc;
|
|
|
|
}
|
|
|
|
async getFeeData(provider) {
|
|
|
|
return await this.#feeDataFunc(provider);
|
|
|
|
}
|
|
|
|
clone() {
|
|
|
|
return new FeeDataNetworkPlugin(this.#feeDataFunc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.FeeDataNetworkPlugin = FeeDataNetworkPlugin;
|
2022-11-30 15:44:23 -05:00
|
|
|
/*
|
|
|
|
export class CustomBlockNetworkPlugin extends NetworkPlugin {
|
|
|
|
readonly #blockFunc: (provider: Provider, block: BlockParams<string>) => Block<string>;
|
|
|
|
readonly #blockWithTxsFunc: (provider: Provider, block: BlockParams<TransactionResponseParams>) => Block<TransactionResponse>;
|
|
|
|
|
|
|
|
constructor(blockFunc: (provider: Provider, block: BlockParams<string>) => Block<string>, blockWithTxsFunc: (provider: Provider, block: BlockParams<TransactionResponseParams>) => Block<TransactionResponse>) {
|
2022-09-27 03:45:27 -04:00
|
|
|
super("org.ethers.network-plugins.custom-block");
|
|
|
|
this.#blockFunc = blockFunc;
|
|
|
|
this.#blockWithTxsFunc = blockWithTxsFunc;
|
|
|
|
}
|
2022-11-30 15:44:23 -05:00
|
|
|
|
|
|
|
async getBlock(provider: Provider, block: BlockParams<string>): Promise<Block<string>> {
|
2022-09-27 03:45:27 -04:00
|
|
|
return await this.#blockFunc(provider, block);
|
|
|
|
}
|
2022-11-30 15:44:23 -05:00
|
|
|
|
|
|
|
async getBlockions(provider: Provider, block: BlockParams<TransactionResponseParams>): Promise<Block<TransactionResponse>> {
|
2022-09-27 03:45:27 -04:00
|
|
|
return await this.#blockWithTxsFunc(provider, block);
|
|
|
|
}
|
2022-11-30 15:44:23 -05:00
|
|
|
|
|
|
|
clone(): CustomBlockNetworkPlugin {
|
2022-09-27 03:45:27 -04:00
|
|
|
return new CustomBlockNetworkPlugin(this.#blockFunc, this.#blockWithTxsFunc);
|
|
|
|
}
|
|
|
|
}
|
2022-11-30 15:44:23 -05:00
|
|
|
*/
|
2022-09-05 16:57:11 -04:00
|
|
|
//# sourceMappingURL=plugins-network.js.map
|