@appliedblockchain/silentdatarollup-hardhat-plugin-fireblocks 1.0.8 → 1.0.10

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Applied Blockchain Ltd.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -20,7 +20,7 @@ Custom providers for integrating Silent Data with Hardhat and Fireblocks.
20
20
 
21
21
  - Node.js (version 18 or higher)
22
22
  - Hardhat v2
23
- - npm
23
+ - pnpm
24
24
  - Basic knowledge of Ethereum and smart contracts
25
25
 
26
26
  ## Integration
@@ -30,7 +30,7 @@ Custom providers for integrating Silent Data with Hardhat and Fireblocks.
30
30
  #### Installing Hardhat Integration Dependencies
31
31
 
32
32
  ```bash
33
- npm install @appliedblockchain/silentdatarollup-core @appliedblockchain/silentdatarollup-hardhat-plugin-fireblocks @nomicfoundation/hardhat-ignition-ethers@0.15.7
33
+ pnpm add @appliedblockchain/silentdatarollup-core @appliedblockchain/silentdatarollup-hardhat-plugin-fireblocks @nomicfoundation/hardhat-ignition-ethers@0.15.9
34
34
  ```
35
35
 
36
36
  #### Hardhat Integration Example
package/dist/index.js CHANGED
@@ -65,8 +65,7 @@ var SilentDataFireblocksSigner = class extends import_plugins.ProviderWrapper {
65
65
  log(".request()", JSON.stringify(args, null, 2));
66
66
  const payload = {
67
67
  jsonrpc: "2.0",
68
- ...args,
69
- id: Math.floor(Math.random() * 1e10)
68
+ ...args
70
69
  };
71
70
  if (args.method === "eth_sendTransaction") {
72
71
  return this.sendTransaction(payload);
@@ -92,7 +91,7 @@ var SilentDataFireblocksSigner = class extends import_plugins.ProviderWrapper {
92
91
  }
93
92
  sendAsync(payload, callback) {
94
93
  log("Provider .sendAsync() method called:", payload.method);
95
- this.request(payload).then(callback).catch(callback);
94
+ this.request(payload).then((result) => callback(null, result)).catch((error) => callback(error));
96
95
  }
97
96
  setupInterceptor(provider) {
98
97
  log("Setting up silent data interceptor for Fireblocks");
@@ -100,23 +99,28 @@ var SilentDataFireblocksSigner = class extends import_plugins.ProviderWrapper {
100
99
  provider.send = async (payload, callback) => {
101
100
  ;
102
101
  (async () => {
103
- const requiresAuthHeaders = SIGN_RPC_METHODS.includes(payload.method);
104
102
  if (payload.method === "eth_sendTransaction") {
105
103
  try {
106
- const result2 = await this.sendTransaction(payload);
107
- callback(null, result2);
104
+ const result = await this.sendTransaction(payload);
105
+ callback(null, result);
108
106
  } catch (error) {
109
107
  callback(error, null);
110
108
  }
111
109
  return;
112
110
  }
113
- log("Intercepted send method:", JSON.stringify(payload, null, 2));
111
+ const requestId = payload.id ?? Math.floor(Math.random() * 1e10);
112
+ const modifiedPayload = { ...payload, id: requestId };
113
+ log(
114
+ "Intercepted send method:",
115
+ JSON.stringify(modifiedPayload, null, 2)
116
+ );
117
+ const requiresAuthHeaders = SIGN_RPC_METHODS.includes(payload.method);
114
118
  if (requiresAuthHeaders) {
115
119
  log("Request requires auth headers");
116
120
  const clonedEthereum = new import_fireblocks_web3_provider.FireblocksWeb3Provider(
117
121
  provider.config
118
122
  );
119
- const authHeaders = await this.getAuthHeaders(payload);
123
+ const authHeaders = await this.getAuthHeaders(modifiedPayload);
120
124
  const allHeaders = [];
121
125
  for (const [key, value] of Object.entries(authHeaders)) {
122
126
  allHeaders.push({ name: key, value });
@@ -124,10 +128,12 @@ var SilentDataFireblocksSigner = class extends import_plugins.ProviderWrapper {
124
128
  ;
125
129
  clonedEthereum.headers = allHeaders;
126
130
  log("Auth headers set for cloned FireblocksWeb3Provider provider");
127
- return originalSend.call(clonedEthereum, payload, callback);
131
+ return originalSend.call(clonedEthereum, modifiedPayload, callback);
128
132
  }
129
- const result = await originalSend.call(provider, payload, callback);
130
- return result;
133
+ const wrappedCallback = (error, response) => {
134
+ callback(error, response);
135
+ };
136
+ return originalSend.call(provider, modifiedPayload, wrappedCallback);
131
137
  })();
132
138
  };
133
139
  }
@@ -159,12 +165,6 @@ var SilentDataFireblocksSigner = class extends import_plugins.ProviderWrapper {
159
165
  }
160
166
  async getAuthHeaders(payload) {
161
167
  log("Getting auth headers for method:", JSON.stringify(payload, null, 2));
162
- const requestId = this._wrappedProvider._provider._wrappedProvider._wrappedProvider._wrappedProvider._nextRequestId;
163
- const rpcRequest = {
164
- jsonrpc: "2.0",
165
- ...payload,
166
- id: requestId
167
- };
168
168
  const xTimestamp = (/* @__PURE__ */ new Date()).toISOString();
169
169
  const headers = {
170
170
  [import_silentdatarollup_core2.HEADER_TIMESTAMP]: xTimestamp
@@ -174,19 +174,16 @@ var SilentDataFireblocksSigner = class extends import_plugins.ProviderWrapper {
174
174
  let content;
175
175
  switch (signatureType) {
176
176
  case import_silentdatarollup_core2.SignatureType.Raw:
177
- const preparedMessage = this.baseProvider.prepareSignatureMessage(
177
+ const preparedMessage = this.baseProvider.prepareMessage(
178
178
  chainId.toString(),
179
- rpcRequest,
179
+ payload,
180
180
  xTimestamp
181
181
  );
182
182
  content = (0, import_ethers.hashMessage)(preparedMessage).slice(2);
183
183
  break;
184
184
  case import_silentdatarollup_core2.SignatureType.EIP712:
185
185
  const types = (0, import_silentdatarollup_core2.getAuthEIP721Types)(payload);
186
- const message = this.baseProvider.prepareSignatureTypedData(
187
- payload,
188
- xTimestamp
189
- );
186
+ const message = this.baseProvider.prepareTypedData(payload, xTimestamp);
190
187
  content = {
191
188
  types: {
192
189
  EIP712Domain: [
@@ -301,18 +298,20 @@ var SilentDataFireblocksSigner = class extends import_plugins.ProviderWrapper {
301
298
  return [maxPriorityFeePerGas, maxFeePerGas];
302
299
  }
303
300
  async estimateGasLimit(txParams) {
304
- const gasLimitHex = await this._wrappedProvider.request({
305
- method: "eth_estimateGas",
306
- params: [txParams]
307
- });
301
+ const gasLimitHex = await this.send("eth_estimateGas", [
302
+ txParams
303
+ ]);
308
304
  return parseInt(gasLimitHex, 16);
309
305
  }
306
+ async getTransactionReceipt(txHash) {
307
+ const receipt = await this.send("eth_getTransactionReceipt", [
308
+ txHash
309
+ ]);
310
+ return receipt;
311
+ }
310
312
  async waitForTransaction(txHash) {
311
313
  for (let i = 0; i < this.maxRetries; i++) {
312
- const receipt = await this._wrappedProvider.request({
313
- method: "eth_getTransactionReceipt",
314
- params: [txHash]
315
- });
314
+ const receipt = await this.getTransactionReceipt(txHash);
316
315
  if (receipt) {
317
316
  log("Transaction mined, receipt:", JSON.stringify(receipt, null, 2));
318
317
  if (receipt.status !== "0x1") {
package/dist/index.mjs CHANGED
@@ -52,8 +52,7 @@ var SilentDataFireblocksSigner = class extends ProviderWrapper {
52
52
  log(".request()", JSON.stringify(args, null, 2));
53
53
  const payload = {
54
54
  jsonrpc: "2.0",
55
- ...args,
56
- id: Math.floor(Math.random() * 1e10)
55
+ ...args
57
56
  };
58
57
  if (args.method === "eth_sendTransaction") {
59
58
  return this.sendTransaction(payload);
@@ -79,7 +78,7 @@ var SilentDataFireblocksSigner = class extends ProviderWrapper {
79
78
  }
80
79
  sendAsync(payload, callback) {
81
80
  log("Provider .sendAsync() method called:", payload.method);
82
- this.request(payload).then(callback).catch(callback);
81
+ this.request(payload).then((result) => callback(null, result)).catch((error) => callback(error));
83
82
  }
84
83
  setupInterceptor(provider) {
85
84
  log("Setting up silent data interceptor for Fireblocks");
@@ -87,23 +86,28 @@ var SilentDataFireblocksSigner = class extends ProviderWrapper {
87
86
  provider.send = async (payload, callback) => {
88
87
  ;
89
88
  (async () => {
90
- const requiresAuthHeaders = SIGN_RPC_METHODS.includes(payload.method);
91
89
  if (payload.method === "eth_sendTransaction") {
92
90
  try {
93
- const result2 = await this.sendTransaction(payload);
94
- callback(null, result2);
91
+ const result = await this.sendTransaction(payload);
92
+ callback(null, result);
95
93
  } catch (error) {
96
94
  callback(error, null);
97
95
  }
98
96
  return;
99
97
  }
100
- log("Intercepted send method:", JSON.stringify(payload, null, 2));
98
+ const requestId = payload.id ?? Math.floor(Math.random() * 1e10);
99
+ const modifiedPayload = { ...payload, id: requestId };
100
+ log(
101
+ "Intercepted send method:",
102
+ JSON.stringify(modifiedPayload, null, 2)
103
+ );
104
+ const requiresAuthHeaders = SIGN_RPC_METHODS.includes(payload.method);
101
105
  if (requiresAuthHeaders) {
102
106
  log("Request requires auth headers");
103
107
  const clonedEthereum = new FireblocksWeb3Provider(
104
108
  provider.config
105
109
  );
106
- const authHeaders = await this.getAuthHeaders(payload);
110
+ const authHeaders = await this.getAuthHeaders(modifiedPayload);
107
111
  const allHeaders = [];
108
112
  for (const [key, value] of Object.entries(authHeaders)) {
109
113
  allHeaders.push({ name: key, value });
@@ -111,10 +115,12 @@ var SilentDataFireblocksSigner = class extends ProviderWrapper {
111
115
  ;
112
116
  clonedEthereum.headers = allHeaders;
113
117
  log("Auth headers set for cloned FireblocksWeb3Provider provider");
114
- return originalSend.call(clonedEthereum, payload, callback);
118
+ return originalSend.call(clonedEthereum, modifiedPayload, callback);
115
119
  }
116
- const result = await originalSend.call(provider, payload, callback);
117
- return result;
120
+ const wrappedCallback = (error, response) => {
121
+ callback(error, response);
122
+ };
123
+ return originalSend.call(provider, modifiedPayload, wrappedCallback);
118
124
  })();
119
125
  };
120
126
  }
@@ -146,12 +152,6 @@ var SilentDataFireblocksSigner = class extends ProviderWrapper {
146
152
  }
147
153
  async getAuthHeaders(payload) {
148
154
  log("Getting auth headers for method:", JSON.stringify(payload, null, 2));
149
- const requestId = this._wrappedProvider._provider._wrappedProvider._wrappedProvider._wrappedProvider._nextRequestId;
150
- const rpcRequest = {
151
- jsonrpc: "2.0",
152
- ...payload,
153
- id: requestId
154
- };
155
155
  const xTimestamp = (/* @__PURE__ */ new Date()).toISOString();
156
156
  const headers = {
157
157
  [HEADER_TIMESTAMP]: xTimestamp
@@ -161,19 +161,16 @@ var SilentDataFireblocksSigner = class extends ProviderWrapper {
161
161
  let content;
162
162
  switch (signatureType) {
163
163
  case SignatureType.Raw:
164
- const preparedMessage = this.baseProvider.prepareSignatureMessage(
164
+ const preparedMessage = this.baseProvider.prepareMessage(
165
165
  chainId.toString(),
166
- rpcRequest,
166
+ payload,
167
167
  xTimestamp
168
168
  );
169
169
  content = hashMessage(preparedMessage).slice(2);
170
170
  break;
171
171
  case SignatureType.EIP712:
172
172
  const types = getAuthEIP721Types(payload);
173
- const message = this.baseProvider.prepareSignatureTypedData(
174
- payload,
175
- xTimestamp
176
- );
173
+ const message = this.baseProvider.prepareTypedData(payload, xTimestamp);
177
174
  content = {
178
175
  types: {
179
176
  EIP712Domain: [
@@ -288,18 +285,20 @@ var SilentDataFireblocksSigner = class extends ProviderWrapper {
288
285
  return [maxPriorityFeePerGas, maxFeePerGas];
289
286
  }
290
287
  async estimateGasLimit(txParams) {
291
- const gasLimitHex = await this._wrappedProvider.request({
292
- method: "eth_estimateGas",
293
- params: [txParams]
294
- });
288
+ const gasLimitHex = await this.send("eth_estimateGas", [
289
+ txParams
290
+ ]);
295
291
  return parseInt(gasLimitHex, 16);
296
292
  }
293
+ async getTransactionReceipt(txHash) {
294
+ const receipt = await this.send("eth_getTransactionReceipt", [
295
+ txHash
296
+ ]);
297
+ return receipt;
298
+ }
297
299
  async waitForTransaction(txHash) {
298
300
  for (let i = 0; i < this.maxRetries; i++) {
299
- const receipt = await this._wrappedProvider.request({
300
- method: "eth_getTransactionReceipt",
301
- params: [txHash]
302
- });
301
+ const receipt = await this.getTransactionReceipt(txHash);
303
302
  if (receipt) {
304
303
  log("Transaction mined, receipt:", JSON.stringify(receipt, null, 2));
305
304
  if (receipt.status !== "0x1") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appliedblockchain/silentdatarollup-hardhat-plugin-fireblocks",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Hardhat plugin for Silent Data with Fireblocks integration",
5
5
  "author": "Applied Blockchain",
6
6
  "homepage": "https://github.com/appliedblockchain/silent-data-rollup-providers#readme",
@@ -26,22 +26,18 @@
26
26
  "files": [
27
27
  "dist"
28
28
  ],
29
- "scripts": {
30
- "build": "tsc --noEmit && tsup src/index.ts --format cjs,esm --dts --clean",
31
- "check-exports": "attw --pack . --profile node16",
32
- "prepack": "npm run build"
33
- },
34
29
  "dependencies": {
35
- "@appliedblockchain/silentdatarollup-core": "1.0.8",
30
+ "@ethersproject/abstract-provider": "5.8.0",
36
31
  "@fireblocks/fireblocks-web3-provider": "1.3.8",
37
32
  "@fireblocks/hardhat-fireblocks": "1.3.5",
38
33
  "debug": "4.3.7",
39
34
  "ethers": "6.13.2",
40
- "fireblocks-sdk": "5.31.2"
35
+ "fireblocks-sdk": "5.31.2",
36
+ "@appliedblockchain/silentdatarollup-core": "1.0.10"
41
37
  },
42
38
  "devDependencies": {
43
39
  "@types/debug": "4.1.12",
44
- "@types/node": "22.5.4",
40
+ "@types/node": "24.10.1",
45
41
  "hardhat": "2.22.10",
46
42
  "ts-node": "10.9.2",
47
43
  "typescript": "5.6.2"
@@ -52,5 +48,9 @@
52
48
  },
53
49
  "engines": {
54
50
  "node": ">=18.0.0"
51
+ },
52
+ "scripts": {
53
+ "build": "tsc --noEmit && tsup src/index.ts --format cjs,esm --dts --clean",
54
+ "check-exports": "attw --pack . --profile node16"
55
55
  }
56
- }
56
+ }