@xyo-network/ethers-ethereum-gas-plugin 2.84.0 → 2.84.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ EthereumGasEthersPlugin: () => EthereumGasEthersPlugin,
24
+ EthereumGasEthersWitness: () => EthereumGasEthersWitness,
25
+ EthereumGasEthersWitnessConfigSchema: () => EthereumGasEthersWitnessConfigSchema,
26
+ default: () => src_default
27
+ });
28
+ module.exports = __toCommonJS(src_exports);
29
+
30
+ // src/Plugin.ts
31
+ var import_ethers_ethereum_gas_payload_plugin2 = require("@xyo-network/ethers-ethereum-gas-payload-plugin");
32
+ var import_payload_model = require("@xyo-network/payload-model");
33
+ var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
34
+
35
+ // src/Witness.ts
36
+ var import_assert = require("@xylabs/assert");
37
+ var import_abstract_witness = require("@xyo-network/abstract-witness");
38
+ var import_ethers_ethereum_gas_payload_plugin = require("@xyo-network/ethers-ethereum-gas-payload-plugin");
39
+ var import_payload_builder = require("@xyo-network/payload-builder");
40
+
41
+ // src/lib/getGasFromEthers.ts
42
+ var formatFeeDataValue = (value) => {
43
+ return value ? Number(value) : null;
44
+ };
45
+ var getGasFromEthers = async (provider) => {
46
+ const feeData = await provider.getFeeData();
47
+ const formattedFeeData = {
48
+ gasPrice: formatFeeDataValue(feeData.gasPrice),
49
+ maxFeePerGas: formatFeeDataValue(feeData.maxFeePerGas),
50
+ maxPriorityFeePerGas: formatFeeDataValue(feeData.maxPriorityFeePerGas)
51
+ };
52
+ return formattedFeeData;
53
+ };
54
+
55
+ // src/Schema.ts
56
+ var EthereumGasEthersWitnessConfigSchema = "network.xyo.blockchain.ethereum.gas.ethers.witness.config";
57
+
58
+ // src/Witness.ts
59
+ var EthereumGasEthersWitness = class extends import_abstract_witness.AbstractWitness {
60
+ static configSchemas = [EthereumGasEthersWitnessConfigSchema];
61
+ _provider;
62
+ get provider() {
63
+ var _a;
64
+ this._provider = this._provider ?? ((_a = this.params) == null ? void 0 : _a.provider);
65
+ return this._provider;
66
+ }
67
+ async observeHandler() {
68
+ const payload = await new import_payload_builder.PayloadBuilder({ schema: import_ethers_ethereum_gas_payload_plugin.EthereumGasEthersSchema }).fields(await getGasFromEthers((0, import_assert.assertEx)(this.provider, "Provider Required"))).build();
69
+ return [payload];
70
+ }
71
+ };
72
+
73
+ // src/Plugin.ts
74
+ var EthereumGasEthersPlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)(
75
+ { required: { [import_ethers_ethereum_gas_payload_plugin2.EthereumGasEthersSchema]: 1 }, schema: import_payload_model.PayloadSetSchema },
76
+ {
77
+ witness: async (params) => {
78
+ return await EthereumGasEthersWitness.create(params);
79
+ }
80
+ }
81
+ );
82
+
83
+ // src/index.ts
84
+ var src_default = EthereumGasEthersPlugin;
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {
87
+ EthereumGasEthersPlugin,
88
+ EthereumGasEthersWitness,
89
+ EthereumGasEthersWitnessConfigSchema
90
+ });
91
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Witness.ts","../../src/lib/getGasFromEthers.ts","../../src/Schema.ts"],"sourcesContent":["import { EthereumGasEthersPlugin } from './Plugin'\n\nexport * from './Config'\nexport * from './Schema'\nexport * from './Witness'\n\nexport { EthereumGasEthersPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default EthereumGasEthersPlugin\n","import { EthereumGasEthersSchema } from '@xyo-network/ethers-ethereum-gas-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { EthereumGasEthersWitness } from './Witness'\n\nexport const EthereumGasEthersPlugin = () =>\n createPayloadSetWitnessPlugin<EthereumGasEthersWitness>(\n { required: { [EthereumGasEthersSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n return await EthereumGasEthersWitness.create(params)\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { EthereumGasEthersPayload, EthereumGasEthersSchema } from '@xyo-network/ethers-ethereum-gas-payload-plugin'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\nimport { WitnessParams } from '@xyo-network/witness-model'\nimport { Provider } from 'ethers'\n\nimport { EthereumGasEthersWitnessConfig } from './Config'\nimport { getGasFromEthers } from './lib'\nimport { EthereumGasEthersWitnessConfigSchema } from './Schema'\n\nexport type EthereumGasEthersWitnessParams = WitnessParams<\n AnyConfigSchema<EthereumGasEthersWitnessConfig>,\n {\n provider?: Provider\n }\n>\n\nexport class EthereumGasEthersWitness<\n TParams extends EthereumGasEthersWitnessParams = EthereumGasEthersWitnessParams,\n> extends AbstractWitness<TParams> {\n static override configSchemas = [EthereumGasEthersWitnessConfigSchema]\n\n private _provider?: Provider\n\n protected get provider() {\n this._provider = this._provider ?? this.params?.provider\n return this._provider\n }\n\n protected override async observeHandler(): Promise<Payload[]> {\n const payload = await new PayloadBuilder<EthereumGasEthersPayload>({ schema: EthereumGasEthersSchema })\n .fields(await getGasFromEthers(assertEx(this.provider, 'Provider Required')))\n .build()\n return [payload]\n }\n}\n","import { EthereumGasEthersResponse } from '@xyo-network/ethers-ethereum-gas-payload-plugin'\nimport { Provider } from 'ethers'\n\nconst formatFeeDataValue = (value: bigint | null) => {\n return value ? Number(value) : null\n}\n\nexport const getGasFromEthers = async (provider: Provider): Promise<EthereumGasEthersResponse> => {\n // https://docs.ethers.io/v5/api/providers/provider/#Provider-getFeeData\n const feeData = await provider.getFeeData()\n const formattedFeeData: EthereumGasEthersResponse = {\n gasPrice: formatFeeDataValue(feeData.gasPrice),\n maxFeePerGas: formatFeeDataValue(feeData.maxFeePerGas),\n maxPriorityFeePerGas: formatFeeDataValue(feeData.maxPriorityFeePerGas),\n }\n return formattedFeeData\n}\n","export type EthereumGasEthersWitnessConfigSchema = 'network.xyo.blockchain.ethereum.gas.ethers.witness.config'\nexport const EthereumGasEthersWitnessConfigSchema: EthereumGasEthersWitnessConfigSchema = 'network.xyo.blockchain.ethereum.gas.ethers.witness.config'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,6CAAwC;AACxC,2BAAiC;AACjC,+BAA8C;;;ACF9C,oBAAyB;AACzB,8BAAgC;AAChC,gDAAkE;AAElE,6BAA+B;;;ACD/B,IAAM,qBAAqB,CAAC,UAAyB;AACnD,SAAO,QAAQ,OAAO,KAAK,IAAI;AACjC;AAEO,IAAM,mBAAmB,OAAO,aAA2D;AAEhG,QAAM,UAAU,MAAM,SAAS,WAAW;AAC1C,QAAM,mBAA8C;AAAA,IAClD,UAAU,mBAAmB,QAAQ,QAAQ;AAAA,IAC7C,cAAc,mBAAmB,QAAQ,YAAY;AAAA,IACrD,sBAAsB,mBAAmB,QAAQ,oBAAoB;AAAA,EACvE;AACA,SAAO;AACT;;;ACfO,IAAM,uCAA6E;;;AFmBnF,IAAM,2BAAN,cAEG,wCAAyB;AAAA,EACjC,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAE7D;AAAA,EAER,IAAc,WAAW;AA3B3B;AA4BI,SAAK,YAAY,KAAK,eAAa,UAAK,WAAL,mBAAa;AAChD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAyB,iBAAqC;AAC5D,UAAM,UAAU,MAAM,IAAI,sCAAyC,EAAE,QAAQ,kEAAwB,CAAC,EACnG,OAAO,MAAM,qBAAiB,wBAAS,KAAK,UAAU,mBAAmB,CAAC,CAAC,EAC3E,MAAM;AACT,WAAO,CAAC,OAAO;AAAA,EACjB;AACF;;;ADhCO,IAAM,0BAA0B,UACrC;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,kEAAuB,GAAG,EAAE,GAAG,QAAQ,sCAAiB;AAAA,EACvE;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAO,MAAM,yBAAyB,OAAO,MAAM;AAAA,IACrD;AAAA,EACF;AACF;;;ADLF,IAAO,cAAQ;","names":["import_ethers_ethereum_gas_payload_plugin"]}
@@ -1,42 +1,13 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- EthereumGasEthersPlugin: () => EthereumGasEthersPlugin,
24
- EthereumGasEthersWitness: () => EthereumGasEthersWitness,
25
- EthereumGasEthersWitnessConfigSchema: () => EthereumGasEthersWitnessConfigSchema,
26
- default: () => src_default
27
- });
28
- module.exports = __toCommonJS(src_exports);
29
-
30
1
  // src/Plugin.ts
31
- var import_ethers_ethereum_gas_payload_plugin2 = require("@xyo-network/ethers-ethereum-gas-payload-plugin");
32
- var import_payload_model = require("@xyo-network/payload-model");
33
- var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
2
+ import { EthereumGasEthersSchema as EthereumGasEthersSchema2 } from "@xyo-network/ethers-ethereum-gas-payload-plugin";
3
+ import { PayloadSetSchema } from "@xyo-network/payload-model";
4
+ import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
34
5
 
35
6
  // src/Witness.ts
36
- var import_assert = require("@xylabs/assert");
37
- var import_abstract_witness = require("@xyo-network/abstract-witness");
38
- var import_ethers_ethereum_gas_payload_plugin = require("@xyo-network/ethers-ethereum-gas-payload-plugin");
39
- var import_payload_builder = require("@xyo-network/payload-builder");
7
+ import { assertEx } from "@xylabs/assert";
8
+ import { AbstractWitness } from "@xyo-network/abstract-witness";
9
+ import { EthereumGasEthersSchema } from "@xyo-network/ethers-ethereum-gas-payload-plugin";
10
+ import { PayloadBuilder } from "@xyo-network/payload-builder";
40
11
 
41
12
  // src/lib/getGasFromEthers.ts
42
13
  var formatFeeDataValue = (value) => {
@@ -56,7 +27,7 @@ var getGasFromEthers = async (provider) => {
56
27
  var EthereumGasEthersWitnessConfigSchema = "network.xyo.blockchain.ethereum.gas.ethers.witness.config";
57
28
 
58
29
  // src/Witness.ts
59
- var EthereumGasEthersWitness = class extends import_abstract_witness.AbstractWitness {
30
+ var EthereumGasEthersWitness = class extends AbstractWitness {
60
31
  static configSchemas = [EthereumGasEthersWitnessConfigSchema];
61
32
  _provider;
62
33
  get provider() {
@@ -65,14 +36,14 @@ var EthereumGasEthersWitness = class extends import_abstract_witness.AbstractWit
65
36
  return this._provider;
66
37
  }
67
38
  async observeHandler() {
68
- const payload = await new import_payload_builder.PayloadBuilder({ schema: import_ethers_ethereum_gas_payload_plugin.EthereumGasEthersSchema }).fields(await getGasFromEthers((0, import_assert.assertEx)(this.provider, "Provider Required"))).build();
39
+ const payload = await new PayloadBuilder({ schema: EthereumGasEthersSchema }).fields(await getGasFromEthers(assertEx(this.provider, "Provider Required"))).build();
69
40
  return [payload];
70
41
  }
71
42
  };
72
43
 
73
44
  // src/Plugin.ts
74
- var EthereumGasEthersPlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)(
75
- { required: { [import_ethers_ethereum_gas_payload_plugin2.EthereumGasEthersSchema]: 1 }, schema: import_payload_model.PayloadSetSchema },
45
+ var EthereumGasEthersPlugin = () => createPayloadSetWitnessPlugin(
46
+ { required: { [EthereumGasEthersSchema2]: 1 }, schema: PayloadSetSchema },
76
47
  {
77
48
  witness: async (params) => {
78
49
  return await EthereumGasEthersWitness.create(params);
@@ -82,10 +53,10 @@ var EthereumGasEthersPlugin = () => (0, import_payloadset_plugin.createPayloadSe
82
53
 
83
54
  // src/index.ts
84
55
  var src_default = EthereumGasEthersPlugin;
85
- // Annotate the CommonJS export names for ESM import in node:
86
- 0 && (module.exports = {
56
+ export {
87
57
  EthereumGasEthersPlugin,
88
58
  EthereumGasEthersWitness,
89
- EthereumGasEthersWitnessConfigSchema
90
- });
59
+ EthereumGasEthersWitnessConfigSchema,
60
+ src_default as default
61
+ };
91
62
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/Witness.ts","../../src/lib/getGasFromEthers.ts","../../src/Schema.ts"],"sourcesContent":["import { EthereumGasEthersPlugin } from './Plugin'\n\nexport * from './Config'\nexport * from './Schema'\nexport * from './Witness'\n\nexport { EthereumGasEthersPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default EthereumGasEthersPlugin\n","import { EthereumGasEthersSchema } from '@xyo-network/ethers-ethereum-gas-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { EthereumGasEthersWitness } from './Witness'\n\nexport const EthereumGasEthersPlugin = () =>\n createPayloadSetWitnessPlugin<EthereumGasEthersWitness>(\n { required: { [EthereumGasEthersSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n return await EthereumGasEthersWitness.create(params)\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { EthereumGasEthersPayload, EthereumGasEthersSchema } from '@xyo-network/ethers-ethereum-gas-payload-plugin'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\nimport { WitnessParams } from '@xyo-network/witness-model'\nimport { Provider } from 'ethers'\n\nimport { EthereumGasEthersWitnessConfig } from './Config'\nimport { getGasFromEthers } from './lib'\nimport { EthereumGasEthersWitnessConfigSchema } from './Schema'\n\nexport type EthereumGasEthersWitnessParams = WitnessParams<\n AnyConfigSchema<EthereumGasEthersWitnessConfig>,\n {\n provider?: Provider\n }\n>\n\nexport class EthereumGasEthersWitness<\n TParams extends EthereumGasEthersWitnessParams = EthereumGasEthersWitnessParams,\n> extends AbstractWitness<TParams> {\n static override configSchemas = [EthereumGasEthersWitnessConfigSchema]\n\n private _provider?: Provider\n\n protected get provider() {\n this._provider = this._provider ?? this.params?.provider\n return this._provider\n }\n\n protected override async observeHandler(): Promise<Payload[]> {\n const payload = await new PayloadBuilder<EthereumGasEthersPayload>({ schema: EthereumGasEthersSchema })\n .fields(await getGasFromEthers(assertEx(this.provider, 'Provider Required')))\n .build()\n return [payload]\n }\n}\n","import { EthereumGasEthersResponse } from '@xyo-network/ethers-ethereum-gas-payload-plugin'\nimport { Provider } from 'ethers'\n\nconst formatFeeDataValue = (value: bigint | null) => {\n return value ? Number(value) : null\n}\n\nexport const getGasFromEthers = async (provider: Provider): Promise<EthereumGasEthersResponse> => {\n // https://docs.ethers.io/v5/api/providers/provider/#Provider-getFeeData\n const feeData = await provider.getFeeData()\n const formattedFeeData: EthereumGasEthersResponse = {\n gasPrice: formatFeeDataValue(feeData.gasPrice),\n maxFeePerGas: formatFeeDataValue(feeData.maxFeePerGas),\n maxPriorityFeePerGas: formatFeeDataValue(feeData.maxPriorityFeePerGas),\n }\n return formattedFeeData\n}\n","export type EthereumGasEthersWitnessConfigSchema = 'network.xyo.blockchain.ethereum.gas.ethers.witness.config'\nexport const EthereumGasEthersWitnessConfigSchema: EthereumGasEthersWitnessConfigSchema = 'network.xyo.blockchain.ethereum.gas.ethers.witness.config'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,6CAAwC;AACxC,2BAAiC;AACjC,+BAA8C;;;ACF9C,oBAAyB;AACzB,8BAAgC;AAChC,gDAAkE;AAElE,6BAA+B;;;ACD/B,IAAM,qBAAqB,CAAC,UAAyB;AACnD,SAAO,QAAQ,OAAO,KAAK,IAAI;AACjC;AAEO,IAAM,mBAAmB,OAAO,aAA2D;AAEhG,QAAM,UAAU,MAAM,SAAS,WAAW;AAC1C,QAAM,mBAA8C;AAAA,IAClD,UAAU,mBAAmB,QAAQ,QAAQ;AAAA,IAC7C,cAAc,mBAAmB,QAAQ,YAAY;AAAA,IACrD,sBAAsB,mBAAmB,QAAQ,oBAAoB;AAAA,EACvE;AACA,SAAO;AACT;;;ACfO,IAAM,uCAA6E;;;AFmBnF,IAAM,2BAAN,cAEG,wCAAyB;AAAA,EACjC,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAE7D;AAAA,EAER,IAAc,WAAW;AA3B3B;AA4BI,SAAK,YAAY,KAAK,eAAa,UAAK,WAAL,mBAAa;AAChD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAyB,iBAAqC;AAC5D,UAAM,UAAU,MAAM,IAAI,sCAAyC,EAAE,QAAQ,kEAAwB,CAAC,EACnG,OAAO,MAAM,qBAAiB,wBAAS,KAAK,UAAU,mBAAmB,CAAC,CAAC,EAC3E,MAAM;AACT,WAAO,CAAC,OAAO;AAAA,EACjB;AACF;;;ADhCO,IAAM,0BAA0B,UACrC;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,kEAAuB,GAAG,EAAE,GAAG,QAAQ,sCAAiB;AAAA,EACvE;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAO,MAAM,yBAAyB,OAAO,MAAM;AAAA,IACrD;AAAA,EACF;AACF;;;ADLF,IAAO,cAAQ;","names":["import_ethers_ethereum_gas_payload_plugin"]}
1
+ {"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts","../../src/lib/getGasFromEthers.ts","../../src/Schema.ts","../../src/index.ts"],"sourcesContent":["import { EthereumGasEthersSchema } from '@xyo-network/ethers-ethereum-gas-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { EthereumGasEthersWitness } from './Witness'\n\nexport const EthereumGasEthersPlugin = () =>\n createPayloadSetWitnessPlugin<EthereumGasEthersWitness>(\n { required: { [EthereumGasEthersSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n return await EthereumGasEthersWitness.create(params)\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { EthereumGasEthersPayload, EthereumGasEthersSchema } from '@xyo-network/ethers-ethereum-gas-payload-plugin'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\nimport { WitnessParams } from '@xyo-network/witness-model'\nimport { Provider } from 'ethers'\n\nimport { EthereumGasEthersWitnessConfig } from './Config'\nimport { getGasFromEthers } from './lib'\nimport { EthereumGasEthersWitnessConfigSchema } from './Schema'\n\nexport type EthereumGasEthersWitnessParams = WitnessParams<\n AnyConfigSchema<EthereumGasEthersWitnessConfig>,\n {\n provider?: Provider\n }\n>\n\nexport class EthereumGasEthersWitness<\n TParams extends EthereumGasEthersWitnessParams = EthereumGasEthersWitnessParams,\n> extends AbstractWitness<TParams> {\n static override configSchemas = [EthereumGasEthersWitnessConfigSchema]\n\n private _provider?: Provider\n\n protected get provider() {\n this._provider = this._provider ?? this.params?.provider\n return this._provider\n }\n\n protected override async observeHandler(): Promise<Payload[]> {\n const payload = await new PayloadBuilder<EthereumGasEthersPayload>({ schema: EthereumGasEthersSchema })\n .fields(await getGasFromEthers(assertEx(this.provider, 'Provider Required')))\n .build()\n return [payload]\n }\n}\n","import { EthereumGasEthersResponse } from '@xyo-network/ethers-ethereum-gas-payload-plugin'\nimport { Provider } from 'ethers'\n\nconst formatFeeDataValue = (value: bigint | null) => {\n return value ? Number(value) : null\n}\n\nexport const getGasFromEthers = async (provider: Provider): Promise<EthereumGasEthersResponse> => {\n // https://docs.ethers.io/v5/api/providers/provider/#Provider-getFeeData\n const feeData = await provider.getFeeData()\n const formattedFeeData: EthereumGasEthersResponse = {\n gasPrice: formatFeeDataValue(feeData.gasPrice),\n maxFeePerGas: formatFeeDataValue(feeData.maxFeePerGas),\n maxPriorityFeePerGas: formatFeeDataValue(feeData.maxPriorityFeePerGas),\n }\n return formattedFeeData\n}\n","export type EthereumGasEthersWitnessConfigSchema = 'network.xyo.blockchain.ethereum.gas.ethers.witness.config'\nexport const EthereumGasEthersWitnessConfigSchema: EthereumGasEthersWitnessConfigSchema = 'network.xyo.blockchain.ethereum.gas.ethers.witness.config'\n","import { EthereumGasEthersPlugin } from './Plugin'\n\nexport * from './Config'\nexport * from './Schema'\nexport * from './Witness'\n\nexport { EthereumGasEthersPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default EthereumGasEthersPlugin\n"],"mappings":";AAAA,SAAS,2BAAAA,gCAA+B;AACxC,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;;;ACF9C,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAmC,+BAA+B;AAElE,SAAS,sBAAsB;;;ACD/B,IAAM,qBAAqB,CAAC,UAAyB;AACnD,SAAO,QAAQ,OAAO,KAAK,IAAI;AACjC;AAEO,IAAM,mBAAmB,OAAO,aAA2D;AAEhG,QAAM,UAAU,MAAM,SAAS,WAAW;AAC1C,QAAM,mBAA8C;AAAA,IAClD,UAAU,mBAAmB,QAAQ,QAAQ;AAAA,IAC7C,cAAc,mBAAmB,QAAQ,YAAY;AAAA,IACrD,sBAAsB,mBAAmB,QAAQ,oBAAoB;AAAA,EACvE;AACA,SAAO;AACT;;;ACfO,IAAM,uCAA6E;;;AFmBnF,IAAM,2BAAN,cAEG,gBAAyB;AAAA,EACjC,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAE7D;AAAA,EAER,IAAc,WAAW;AA3B3B;AA4BI,SAAK,YAAY,KAAK,eAAa,UAAK,WAAL,mBAAa;AAChD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAyB,iBAAqC;AAC5D,UAAM,UAAU,MAAM,IAAI,eAAyC,EAAE,QAAQ,wBAAwB,CAAC,EACnG,OAAO,MAAM,iBAAiB,SAAS,KAAK,UAAU,mBAAmB,CAAC,CAAC,EAC3E,MAAM;AACT,WAAO,CAAC,OAAO;AAAA,EACjB;AACF;;;ADhCO,IAAM,0BAA0B,MACrC;AAAA,EACE,EAAE,UAAU,EAAE,CAACC,wBAAuB,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACvE;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAO,MAAM,yBAAyB,OAAO,MAAM;AAAA,IACrD;AAAA,EACF;AACF;;;AILF,IAAO,cAAQ;","names":["EthereumGasEthersSchema","EthereumGasEthersSchema"]}
package/package.json CHANGED
@@ -11,27 +11,26 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "@xylabs/assert": "^2.13.20",
14
- "@xyo-network/abstract-witness": "^2.84.0",
15
- "@xyo-network/ethers-ethereum-gas-payload-plugin": "~2.84.0",
16
- "@xyo-network/module-model": "^2.84.0",
17
- "@xyo-network/payload-builder": "^2.84.0",
18
- "@xyo-network/payload-model": "^2.84.0",
19
- "@xyo-network/payloadset-plugin": "^2.84.0",
20
- "@xyo-network/witness-model": "^2.84.0",
14
+ "@xyo-network/abstract-witness": "^2.84.3",
15
+ "@xyo-network/ethers-ethereum-gas-payload-plugin": "~2.84.2",
16
+ "@xyo-network/module-model": "^2.84.3",
17
+ "@xyo-network/payload-builder": "^2.84.3",
18
+ "@xyo-network/payload-model": "^2.84.3",
19
+ "@xyo-network/payloadset-plugin": "^2.84.3",
20
+ "@xyo-network/witness-model": "^2.84.3",
21
21
  "ethers": "^6.9.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@xylabs/jest-helpers": "^2.13.20",
25
- "@xylabs/ts-scripts-yarn3": "^3.2.10",
26
- "@xylabs/tsconfig": "^3.2.10",
27
- "@xyo-network/account": "^2.84.0",
28
- "@xyo-network/payload-wrapper": "^2.84.0",
29
- "@xyo-network/witness-blockchain-abstract": "^2.84.0",
25
+ "@xylabs/ts-scripts-yarn3": "^3.2.19",
26
+ "@xylabs/tsconfig": "^3.2.19",
27
+ "@xyo-network/account": "^2.84.3",
28
+ "@xyo-network/payload-wrapper": "^2.84.3",
29
+ "@xyo-network/witness-blockchain-abstract": "^2.84.3",
30
30
  "jest": "^29.7.0",
31
31
  "typescript": "^5.3.3"
32
32
  },
33
33
  "description": "Typescript/Javascript Plugins for XYO Platform",
34
- "docs": "dist/docs.json",
35
34
  "types": "dist/node/index.d.ts",
36
35
  "exports": {
37
36
  ".": {
@@ -47,19 +46,19 @@
47
46
  },
48
47
  "node": {
49
48
  "require": {
50
- "types": "./dist/node/index.d.ts",
51
- "default": "./dist/node/index.js"
49
+ "types": "./dist/node/index.d.cts",
50
+ "default": "./dist/node/index.cjs"
52
51
  },
53
52
  "import": {
54
53
  "types": "./dist/node/index.d.mts",
55
- "default": "./dist/node/index.mjs"
54
+ "default": "./dist/node/index.js"
56
55
  }
57
56
  }
58
57
  },
59
58
  "./package.json": "./package.json"
60
59
  },
61
- "main": "dist/node/index.js",
62
- "module": "dist/node/index.mjs",
60
+ "main": "dist/node/index.cjs",
61
+ "module": "dist/node/index.js",
63
62
  "homepage": "https://xyo.network",
64
63
  "license": "LGPL-3.0-only",
65
64
  "publishConfig": {
@@ -70,5 +69,6 @@
70
69
  "url": "https://github.com/XYOracleNetwork/plugins.git"
71
70
  },
72
71
  "sideEffects": false,
73
- "version": "2.84.0"
72
+ "version": "2.84.2",
73
+ "type": "module"
74
74
  }
@@ -1,62 +0,0 @@
1
- // src/Plugin.ts
2
- import { EthereumGasEthersSchema as EthereumGasEthersSchema2 } from "@xyo-network/ethers-ethereum-gas-payload-plugin";
3
- import { PayloadSetSchema } from "@xyo-network/payload-model";
4
- import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
5
-
6
- // src/Witness.ts
7
- import { assertEx } from "@xylabs/assert";
8
- import { AbstractWitness } from "@xyo-network/abstract-witness";
9
- import { EthereumGasEthersSchema } from "@xyo-network/ethers-ethereum-gas-payload-plugin";
10
- import { PayloadBuilder } from "@xyo-network/payload-builder";
11
-
12
- // src/lib/getGasFromEthers.ts
13
- var formatFeeDataValue = (value) => {
14
- return value ? Number(value) : null;
15
- };
16
- var getGasFromEthers = async (provider) => {
17
- const feeData = await provider.getFeeData();
18
- const formattedFeeData = {
19
- gasPrice: formatFeeDataValue(feeData.gasPrice),
20
- maxFeePerGas: formatFeeDataValue(feeData.maxFeePerGas),
21
- maxPriorityFeePerGas: formatFeeDataValue(feeData.maxPriorityFeePerGas)
22
- };
23
- return formattedFeeData;
24
- };
25
-
26
- // src/Schema.ts
27
- var EthereumGasEthersWitnessConfigSchema = "network.xyo.blockchain.ethereum.gas.ethers.witness.config";
28
-
29
- // src/Witness.ts
30
- var EthereumGasEthersWitness = class extends AbstractWitness {
31
- static configSchemas = [EthereumGasEthersWitnessConfigSchema];
32
- _provider;
33
- get provider() {
34
- var _a;
35
- this._provider = this._provider ?? ((_a = this.params) == null ? void 0 : _a.provider);
36
- return this._provider;
37
- }
38
- async observeHandler() {
39
- const payload = await new PayloadBuilder({ schema: EthereumGasEthersSchema }).fields(await getGasFromEthers(assertEx(this.provider, "Provider Required"))).build();
40
- return [payload];
41
- }
42
- };
43
-
44
- // src/Plugin.ts
45
- var EthereumGasEthersPlugin = () => createPayloadSetWitnessPlugin(
46
- { required: { [EthereumGasEthersSchema2]: 1 }, schema: PayloadSetSchema },
47
- {
48
- witness: async (params) => {
49
- return await EthereumGasEthersWitness.create(params);
50
- }
51
- }
52
- );
53
-
54
- // src/index.ts
55
- var src_default = EthereumGasEthersPlugin;
56
- export {
57
- EthereumGasEthersPlugin,
58
- EthereumGasEthersWitness,
59
- EthereumGasEthersWitnessConfigSchema,
60
- src_default as default
61
- };
62
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/Plugin.ts","../../src/Witness.ts","../../src/lib/getGasFromEthers.ts","../../src/Schema.ts","../../src/index.ts"],"sourcesContent":["import { EthereumGasEthersSchema } from '@xyo-network/ethers-ethereum-gas-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { EthereumGasEthersWitness } from './Witness'\n\nexport const EthereumGasEthersPlugin = () =>\n createPayloadSetWitnessPlugin<EthereumGasEthersWitness>(\n { required: { [EthereumGasEthersSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n return await EthereumGasEthersWitness.create(params)\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { EthereumGasEthersPayload, EthereumGasEthersSchema } from '@xyo-network/ethers-ethereum-gas-payload-plugin'\nimport { AnyConfigSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\nimport { WitnessParams } from '@xyo-network/witness-model'\nimport { Provider } from 'ethers'\n\nimport { EthereumGasEthersWitnessConfig } from './Config'\nimport { getGasFromEthers } from './lib'\nimport { EthereumGasEthersWitnessConfigSchema } from './Schema'\n\nexport type EthereumGasEthersWitnessParams = WitnessParams<\n AnyConfigSchema<EthereumGasEthersWitnessConfig>,\n {\n provider?: Provider\n }\n>\n\nexport class EthereumGasEthersWitness<\n TParams extends EthereumGasEthersWitnessParams = EthereumGasEthersWitnessParams,\n> extends AbstractWitness<TParams> {\n static override configSchemas = [EthereumGasEthersWitnessConfigSchema]\n\n private _provider?: Provider\n\n protected get provider() {\n this._provider = this._provider ?? this.params?.provider\n return this._provider\n }\n\n protected override async observeHandler(): Promise<Payload[]> {\n const payload = await new PayloadBuilder<EthereumGasEthersPayload>({ schema: EthereumGasEthersSchema })\n .fields(await getGasFromEthers(assertEx(this.provider, 'Provider Required')))\n .build()\n return [payload]\n }\n}\n","import { EthereumGasEthersResponse } from '@xyo-network/ethers-ethereum-gas-payload-plugin'\nimport { Provider } from 'ethers'\n\nconst formatFeeDataValue = (value: bigint | null) => {\n return value ? Number(value) : null\n}\n\nexport const getGasFromEthers = async (provider: Provider): Promise<EthereumGasEthersResponse> => {\n // https://docs.ethers.io/v5/api/providers/provider/#Provider-getFeeData\n const feeData = await provider.getFeeData()\n const formattedFeeData: EthereumGasEthersResponse = {\n gasPrice: formatFeeDataValue(feeData.gasPrice),\n maxFeePerGas: formatFeeDataValue(feeData.maxFeePerGas),\n maxPriorityFeePerGas: formatFeeDataValue(feeData.maxPriorityFeePerGas),\n }\n return formattedFeeData\n}\n","export type EthereumGasEthersWitnessConfigSchema = 'network.xyo.blockchain.ethereum.gas.ethers.witness.config'\nexport const EthereumGasEthersWitnessConfigSchema: EthereumGasEthersWitnessConfigSchema = 'network.xyo.blockchain.ethereum.gas.ethers.witness.config'\n","import { EthereumGasEthersPlugin } from './Plugin'\n\nexport * from './Config'\nexport * from './Schema'\nexport * from './Witness'\n\nexport { EthereumGasEthersPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default EthereumGasEthersPlugin\n"],"mappings":";AAAA,SAAS,2BAAAA,gCAA+B;AACxC,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;;;ACF9C,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAmC,+BAA+B;AAElE,SAAS,sBAAsB;;;ACD/B,IAAM,qBAAqB,CAAC,UAAyB;AACnD,SAAO,QAAQ,OAAO,KAAK,IAAI;AACjC;AAEO,IAAM,mBAAmB,OAAO,aAA2D;AAEhG,QAAM,UAAU,MAAM,SAAS,WAAW;AAC1C,QAAM,mBAA8C;AAAA,IAClD,UAAU,mBAAmB,QAAQ,QAAQ;AAAA,IAC7C,cAAc,mBAAmB,QAAQ,YAAY;AAAA,IACrD,sBAAsB,mBAAmB,QAAQ,oBAAoB;AAAA,EACvE;AACA,SAAO;AACT;;;ACfO,IAAM,uCAA6E;;;AFmBnF,IAAM,2BAAN,cAEG,gBAAyB;AAAA,EACjC,OAAgB,gBAAgB,CAAC,oCAAoC;AAAA,EAE7D;AAAA,EAER,IAAc,WAAW;AA3B3B;AA4BI,SAAK,YAAY,KAAK,eAAa,UAAK,WAAL,mBAAa;AAChD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAyB,iBAAqC;AAC5D,UAAM,UAAU,MAAM,IAAI,eAAyC,EAAE,QAAQ,wBAAwB,CAAC,EACnG,OAAO,MAAM,iBAAiB,SAAS,KAAK,UAAU,mBAAmB,CAAC,CAAC,EAC3E,MAAM;AACT,WAAO,CAAC,OAAO;AAAA,EACjB;AACF;;;ADhCO,IAAM,0BAA0B,MACrC;AAAA,EACE,EAAE,UAAU,EAAE,CAACC,wBAAuB,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EACvE;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAO,MAAM,yBAAyB,OAAO,MAAM;AAAA,IACrD;AAAA,EACF;AACF;;;AILF,IAAO,cAAQ;","names":["EthereumGasEthersSchema","EthereumGasEthersSchema"]}