@appliedblockchain/silentdatarollup-hardhat-plugin 1.0.3 → 1.0.5

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.
package/dist/index.js CHANGED
@@ -38,11 +38,7 @@ var import_plugins = require("hardhat/plugins");
38
38
 
39
39
  // src/constants.ts
40
40
  var import_silentdatarollup_core = require("@appliedblockchain/silentdatarollup-core");
41
- var SIGN_RPC_METHODS = [
42
- ...import_silentdatarollup_core.SIGN_RPC_METHODS,
43
- "eth_call",
44
- "eth_estimateGas"
45
- ];
41
+ var SIGN_RPC_METHODS = [...import_silentdatarollup_core.SIGN_RPC_METHODS, "eth_call"];
46
42
 
47
43
  // src/provider.ts
48
44
  var log = (0, import_debug.default)(import_silentdatarollup_core2.DEBUG_NAMESPACE);
@@ -50,6 +46,7 @@ var HardhatSilentDataRollupProvider = class extends import_plugins.ProviderWrapp
50
46
  constructor(signer, _wrappedProvider, config) {
51
47
  super(_wrappedProvider);
52
48
  this._wrappedProvider = _wrappedProvider;
49
+ this._cachedNetwork = null;
53
50
  this.signer = signer;
54
51
  this.config = {
55
52
  ...config,
@@ -104,14 +101,31 @@ var HardhatSilentDataRollupProvider = class extends import_plugins.ProviderWrapp
104
101
  }
105
102
  async getAuthHeaders(request) {
106
103
  log("Getting auth headers for request", JSON.stringify(request, null, 2));
104
+ const chainId = await this.getCachedNetwork();
107
105
  const headers = await (0, import_silentdatarollup_core2.getAuthHeaders)(
108
106
  this.signer,
109
107
  request,
108
+ chainId,
110
109
  this.config.authSignatureType
111
110
  );
112
111
  log("Auth headers generated successfully", headers);
113
112
  return headers;
114
113
  }
114
+ /**
115
+ * Get cached network with simple caching
116
+ * @returns Promise<Network> - The cached or freshly fetched network
117
+ */
118
+ async getCachedNetwork() {
119
+ if (!this._cachedNetwork) {
120
+ const clonedProvider = this.cloneWrappedProvider();
121
+ const chainIdHex = await clonedProvider.request({
122
+ method: "eth_chainId",
123
+ params: []
124
+ });
125
+ this._cachedNetwork = Number(chainIdHex).toString();
126
+ }
127
+ return this._cachedNetwork;
128
+ }
115
129
  };
116
130
 
117
131
  // src/index.ts
package/dist/index.mjs CHANGED
@@ -18,11 +18,7 @@ import { ProviderWrapper } from "hardhat/plugins";
18
18
 
19
19
  // src/constants.ts
20
20
  import { SIGN_RPC_METHODS as CORE_SIGN_RPC_METHODS } from "@appliedblockchain/silentdatarollup-core";
21
- var SIGN_RPC_METHODS = [
22
- ...CORE_SIGN_RPC_METHODS,
23
- "eth_call",
24
- "eth_estimateGas"
25
- ];
21
+ var SIGN_RPC_METHODS = [...CORE_SIGN_RPC_METHODS, "eth_call"];
26
22
 
27
23
  // src/provider.ts
28
24
  var log = debug(DEBUG_NAMESPACE);
@@ -30,6 +26,7 @@ var HardhatSilentDataRollupProvider = class extends ProviderWrapper {
30
26
  constructor(signer, _wrappedProvider, config) {
31
27
  super(_wrappedProvider);
32
28
  this._wrappedProvider = _wrappedProvider;
29
+ this._cachedNetwork = null;
33
30
  this.signer = signer;
34
31
  this.config = {
35
32
  ...config,
@@ -84,14 +81,31 @@ var HardhatSilentDataRollupProvider = class extends ProviderWrapper {
84
81
  }
85
82
  async getAuthHeaders(request) {
86
83
  log("Getting auth headers for request", JSON.stringify(request, null, 2));
84
+ const chainId = await this.getCachedNetwork();
87
85
  const headers = await getAuthHeaders(
88
86
  this.signer,
89
87
  request,
88
+ chainId,
90
89
  this.config.authSignatureType
91
90
  );
92
91
  log("Auth headers generated successfully", headers);
93
92
  return headers;
94
93
  }
94
+ /**
95
+ * Get cached network with simple caching
96
+ * @returns Promise<Network> - The cached or freshly fetched network
97
+ */
98
+ async getCachedNetwork() {
99
+ if (!this._cachedNetwork) {
100
+ const clonedProvider = this.cloneWrappedProvider();
101
+ const chainIdHex = await clonedProvider.request({
102
+ method: "eth_chainId",
103
+ params: []
104
+ });
105
+ this._cachedNetwork = Number(chainIdHex).toString();
106
+ }
107
+ return this._cachedNetwork;
108
+ }
95
109
  };
96
110
 
97
111
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appliedblockchain/silentdatarollup-hardhat-plugin",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Hardhat plugin for Silent Data [Rollup]",
5
5
  "author": "Applied Blockchain",
6
6
  "homepage": "https://github.com/appliedblockchain/silent-data-rollup-providers#readme",
@@ -26,12 +26,12 @@
26
26
  "dist"
27
27
  ],
28
28
  "scripts": {
29
- "build": "tsup src/index.ts --format cjs,esm --dts --clean",
29
+ "build": "tsc --noEmit && tsup src/index.ts --format cjs,esm --dts --clean",
30
30
  "check-exports": "attw --pack . --profile node16",
31
31
  "prepack": "npm run build"
32
32
  },
33
33
  "dependencies": {
34
- "@appliedblockchain/silentdatarollup-core": "1.0.3",
34
+ "@appliedblockchain/silentdatarollup-core": "1.0.5",
35
35
  "@nomicfoundation/hardhat-ethers": "3.0.8",
36
36
  "debug": "4.3.7",
37
37
  "ethers": "6.13.2"