@appliedblockchain/silentdatarollup-hardhat-plugin 1.0.4 → 1.0.6

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
@@ -46,6 +46,7 @@ var HardhatSilentDataRollupProvider = class extends import_plugins.ProviderWrapp
46
46
  constructor(signer, _wrappedProvider, config) {
47
47
  super(_wrappedProvider);
48
48
  this._wrappedProvider = _wrappedProvider;
49
+ this._cachedNetwork = null;
49
50
  this.signer = signer;
50
51
  this.config = {
51
52
  ...config,
@@ -100,14 +101,31 @@ var HardhatSilentDataRollupProvider = class extends import_plugins.ProviderWrapp
100
101
  }
101
102
  async getAuthHeaders(request) {
102
103
  log("Getting auth headers for request", JSON.stringify(request, null, 2));
104
+ const chainId = await this.getCachedNetwork();
103
105
  const headers = await (0, import_silentdatarollup_core2.getAuthHeaders)(
104
106
  this.signer,
105
107
  request,
108
+ chainId,
106
109
  this.config.authSignatureType
107
110
  );
108
111
  log("Auth headers generated successfully", headers);
109
112
  return headers;
110
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
+ }
111
129
  };
112
130
 
113
131
  // src/index.ts
package/dist/index.mjs CHANGED
@@ -26,6 +26,7 @@ var HardhatSilentDataRollupProvider = class extends ProviderWrapper {
26
26
  constructor(signer, _wrappedProvider, config) {
27
27
  super(_wrappedProvider);
28
28
  this._wrappedProvider = _wrappedProvider;
29
+ this._cachedNetwork = null;
29
30
  this.signer = signer;
30
31
  this.config = {
31
32
  ...config,
@@ -80,14 +81,31 @@ var HardhatSilentDataRollupProvider = class extends ProviderWrapper {
80
81
  }
81
82
  async getAuthHeaders(request) {
82
83
  log("Getting auth headers for request", JSON.stringify(request, null, 2));
84
+ const chainId = await this.getCachedNetwork();
83
85
  const headers = await getAuthHeaders(
84
86
  this.signer,
85
87
  request,
88
+ chainId,
86
89
  this.config.authSignatureType
87
90
  );
88
91
  log("Auth headers generated successfully", headers);
89
92
  return headers;
90
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
+ }
91
109
  };
92
110
 
93
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.4",
3
+ "version": "1.0.6",
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",
@@ -31,7 +31,7 @@
31
31
  "prepack": "npm run build"
32
32
  },
33
33
  "dependencies": {
34
- "@appliedblockchain/silentdatarollup-core": "1.0.4",
34
+ "@appliedblockchain/silentdatarollup-core": "1.0.6",
35
35
  "@nomicfoundation/hardhat-ethers": "3.0.8",
36
36
  "debug": "4.3.7",
37
37
  "ethers": "6.13.2"