@appliedblockchain/silentdatarollup-ethers-provider 1.0.8 → 1.0.9

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
@@ -15,6 +15,9 @@
15
15
  - [Overview](#overview)
16
16
  - [Using the SDInterface](#using-the-sdinterface)
17
17
  - [Private Events Example](#private-events-example)
18
+ - [Smart Account Support](#smart-account-support)
19
+ - [Smart Account Overview](#smart-account-overview)
20
+ - [Smart Account Example](#smart-account-example)
18
21
  - [Troubleshooting](#troubleshooting)
19
22
  - [License](#license)
20
23
  - [Additional Resources](#additional-resources)
@@ -26,7 +29,7 @@ Custom providers for Silent Data, compatible with ethers.js.
26
29
  ## Prerequisites
27
30
 
28
31
  - Node.js (version 18 or higher)
29
- - npm
32
+ - pnpm
30
33
  - Basic knowledge of Ethereum and smart contracts
31
34
  - Ethers.js v6
32
35
 
@@ -37,7 +40,7 @@ Custom providers for Silent Data, compatible with ethers.js.
37
40
  #### Installing Basic Usage Dependencies
38
41
 
39
42
  ```bash
40
- npm install @appliedblockchain/silentdatarollup-core @appliedblockchain/silentdatarollup-ethers-provider ethers@6
43
+ pnpm add @appliedblockchain/silentdatarollup-core @appliedblockchain/silentdatarollup-ethers-provider ethers@6
41
44
  ```
42
45
 
43
46
  #### Basic Usage Example
@@ -67,7 +70,7 @@ console.log(balance)
67
70
  #### Installing Usage with a Contract Dependencies
68
71
 
69
72
  ```bash
70
- npm install @appliedblockchain/silentdatarollup-core @appliedblockchain/silentdatarollup-ethers-provider ethers@6
73
+ pnpm add @appliedblockchain/silentdatarollup-core @appliedblockchain/silentdatarollup-ethers-provider ethers@6
71
74
  ```
72
75
 
73
76
  #### Usage with a Contract Example
@@ -216,6 +219,66 @@ for (const log of privateEvents) {
216
219
  }
217
220
  ```
218
221
 
222
+ ### Smart Account Support
223
+
224
+ #### Smart Account Overview
225
+
226
+ Silent Data Rollup supports smart accounts (smart wallet contracts) that implement [EIP-1271](https://eips.ethereum.org/EIPS/eip-1271) for signature verification. When using a smart account, you provide the `smartWalletAddress` in the provider configuration, and the provider automatically handles signature verification through the smart contract.
227
+
228
+ **Key features:**
229
+
230
+ - **EIP-1271 Compatibility**: Your smart account contract must implement the `isValidSignature(bytes32 hash, bytes signature)` function
231
+ - **Automatic Hash Signing**: When `smartWalletAddress` is provided, the provider signs the hash of messages for proper EIP-1271 verification
232
+ - **Flexible Signer Support**: Works with any signer implementation, including passkey signers, browser wallets, and more
233
+
234
+ #### Smart Account Example
235
+
236
+ This example shows how to use the provider with a passkey signer and smart account. For a complete passkey implementation, see the [Giano repository](https://github.com/appliedblockchain/giano).
237
+
238
+ ```typescript
239
+ import { SilentDataRollupProvider } from '@appliedblockchain/silentdatarollup-ethers-provider'
240
+ import { NetworkName } from '@appliedblockchain/silentdatarollup-core'
241
+ // Example: Using Giano passkey signer
242
+ // See https://github.com/appliedblockchain/giano for full implementation
243
+ import { GianoSigner } from '@appliedblockchain/giano-client'
244
+
245
+ // Initialize your Giano passkey signer
246
+ const gianoSigner = await GianoSigner.create({
247
+ // Passkey configuration
248
+ })
249
+
250
+ // Configure provider with smart account
251
+ const providerConfig = {
252
+ rpcUrl: 'SILENT_DATA_ROLLUP_RPC_URL',
253
+ network: NetworkName.TESTNET,
254
+ signer: gianoSigner,
255
+ // Provide your EIP-1271 compatible smart account address
256
+ smartWalletAddress: '0xYOUR_SMART_ACCOUNT_ADDRESS',
257
+ }
258
+
259
+ const provider = new SilentDataRollupProvider(providerConfig)
260
+
261
+ // Use the provider as normal
262
+ // All signatures will be verified via your smart account's EIP-1271 implementation
263
+ const balance = await provider.getBalance('YOUR_ADDRESS')
264
+ console.log(balance)
265
+
266
+ // Works with contracts too
267
+ const contractConfig = {
268
+ contractAddress: 'YOUR_CONTRACT_ADDRESS',
269
+ abi: [
270
+ /* Your contract ABI */
271
+ ],
272
+ runner: provider,
273
+ methodsToSign: ['privateMethod'],
274
+ }
275
+
276
+ const contract = new SilentDataRollupContract(contractConfig)
277
+ const result = await contract.privateMethod('param')
278
+ ```
279
+
280
+ **Note**: Your smart account contract must implement EIP-1271's `isValidSignature` function to verify signatures. The provider will automatically sign message hashes when `smartWalletAddress` is configured, ensuring compatibility with the EIP-1271 standard.
281
+
219
282
  ## License
220
283
 
221
284
  This project is licensed under the [MIT License](LICENSE).
package/dist/index.d.mts CHANGED
@@ -11,6 +11,11 @@ interface SilentDataRollupProviderConfig extends BaseConfig {
11
11
  signer?: Signer;
12
12
  options?: JsonRpcApiProviderOptions;
13
13
  smartWalletAddress?: string;
14
+ /**
15
+ * When set to true, all eth_call requests will be signed
16
+ * with authentication headers, regardless of whether they match signable contracts
17
+ */
18
+ alwaysSignEthCalls?: boolean;
14
19
  }
15
20
  /**
16
21
  * Extended filter type that includes a special flag for private events
package/dist/index.d.ts CHANGED
@@ -11,6 +11,11 @@ interface SilentDataRollupProviderConfig extends BaseConfig {
11
11
  signer?: Signer;
12
12
  options?: JsonRpcApiProviderOptions;
13
13
  smartWalletAddress?: string;
14
+ /**
15
+ * When set to true, all eth_call requests will be signed
16
+ * with authentication headers, regardless of whether they match signable contracts
17
+ */
18
+ alwaysSignEthCalls?: boolean;
14
19
  }
15
20
  /**
16
21
  * Extended filter type that includes a special flag for private events
package/dist/index.js CHANGED
@@ -126,7 +126,10 @@ var SilentDataRollupProvider = class _SilentDataRollupProvider extends import_et
126
126
  "config",
127
127
  config
128
128
  );
129
- this.baseProvider = new import_silentdatarollup_core.SilentDataRollupBase(config);
129
+ this.baseProvider = new import_silentdatarollup_core.SilentDataRollupBase({
130
+ ...config,
131
+ smartWalletAddress: config.smartWalletAddress
132
+ });
130
133
  this.config = config;
131
134
  this.config.authSignatureType = config.authSignatureType || import_silentdatarollup_core.SignatureType.Raw;
132
135
  if (config.signer) {
@@ -168,7 +171,7 @@ var SilentDataRollupProvider = class _SilentDataRollupProvider extends import_et
168
171
  const request = this._getConnection();
169
172
  request.body = JSON.stringify(payload);
170
173
  request.setHeader("content-type", "application/json");
171
- const requiresAuthHeaders = isPrivateLogsRequest || import_silentdatarollup_core.SIGN_RPC_METHODS.includes(payload.method) || (0, import_silentdatarollup_core.isSignableContractCall)(payload, this.baseProvider.contracts);
174
+ const requiresAuthHeaders = isPrivateLogsRequest || import_silentdatarollup_core.SIGN_RPC_METHODS.includes(payload.method) || (0, import_silentdatarollup_core.isSignableContractCall)(payload, this.baseProvider.contracts) || this.config.alwaysSignEthCalls && payload.method === "eth_call";
172
175
  if (requiresAuthHeaders) {
173
176
  if (this.config.delegate) {
174
177
  const {
@@ -194,7 +197,8 @@ var SilentDataRollupProvider = class _SilentDataRollupProvider extends import_et
194
197
  const {
195
198
  [import_silentdatarollup_core.HEADER_TIMESTAMP]: xTimestamp,
196
199
  [import_silentdatarollup_core.HEADER_SIGNATURE]: xSignature,
197
- [import_silentdatarollup_core.HEADER_EIP712_SIGNATURE]: xEip712Signature
200
+ [import_silentdatarollup_core.HEADER_EIP712_SIGNATURE]: xEip712Signature,
201
+ [import_silentdatarollup_core.HEADER_FROM_BLOCK]: xFromBlock
198
202
  } = await this.baseProvider.getAuthHeaders(this, payload);
199
203
  request.setHeader(import_silentdatarollup_core.HEADER_TIMESTAMP, xTimestamp);
200
204
  if (xSignature) {
@@ -203,6 +207,13 @@ var SilentDataRollupProvider = class _SilentDataRollupProvider extends import_et
203
207
  if (xEip712Signature) {
204
208
  request.setHeader(import_silentdatarollup_core.HEADER_EIP712_SIGNATURE, xEip712Signature);
205
209
  }
210
+ if (xFromBlock) {
211
+ request.setHeader(import_silentdatarollup_core.HEADER_FROM_BLOCK, xFromBlock);
212
+ }
213
+ const signatureType = this.config.authSignatureType ?? import_silentdatarollup_core.SignatureType.EIP191;
214
+ if (signatureType) {
215
+ request.setHeader(import_silentdatarollup_core.HEADER_SIGNATURE_TYPE, signatureType);
216
+ }
206
217
  }
207
218
  const response = await request.send();
208
219
  response.assertOk();
package/dist/index.mjs CHANGED
@@ -11,7 +11,9 @@ import {
11
11
  HEADER_DELEGATE_SIGNATURE,
12
12
  HEADER_EIP712_DELEGATE_SIGNATURE,
13
13
  HEADER_EIP712_SIGNATURE,
14
+ HEADER_FROM_BLOCK,
14
15
  HEADER_SIGNATURE,
16
+ HEADER_SIGNATURE_TYPE,
15
17
  HEADER_SIGNER_SWC,
16
18
  HEADER_TIMESTAMP,
17
19
  isSignableContractCall,
@@ -115,7 +117,10 @@ var SilentDataRollupProvider = class _SilentDataRollupProvider extends JsonRpcPr
115
117
  "config",
116
118
  config
117
119
  );
118
- this.baseProvider = new SilentDataRollupBase(config);
120
+ this.baseProvider = new SilentDataRollupBase({
121
+ ...config,
122
+ smartWalletAddress: config.smartWalletAddress
123
+ });
119
124
  this.config = config;
120
125
  this.config.authSignatureType = config.authSignatureType || SignatureType.Raw;
121
126
  if (config.signer) {
@@ -157,7 +162,7 @@ var SilentDataRollupProvider = class _SilentDataRollupProvider extends JsonRpcPr
157
162
  const request = this._getConnection();
158
163
  request.body = JSON.stringify(payload);
159
164
  request.setHeader("content-type", "application/json");
160
- const requiresAuthHeaders = isPrivateLogsRequest || SIGN_RPC_METHODS.includes(payload.method) || isSignableContractCall(payload, this.baseProvider.contracts);
165
+ const requiresAuthHeaders = isPrivateLogsRequest || SIGN_RPC_METHODS.includes(payload.method) || isSignableContractCall(payload, this.baseProvider.contracts) || this.config.alwaysSignEthCalls && payload.method === "eth_call";
161
166
  if (requiresAuthHeaders) {
162
167
  if (this.config.delegate) {
163
168
  const {
@@ -183,7 +188,8 @@ var SilentDataRollupProvider = class _SilentDataRollupProvider extends JsonRpcPr
183
188
  const {
184
189
  [HEADER_TIMESTAMP]: xTimestamp,
185
190
  [HEADER_SIGNATURE]: xSignature,
186
- [HEADER_EIP712_SIGNATURE]: xEip712Signature
191
+ [HEADER_EIP712_SIGNATURE]: xEip712Signature,
192
+ [HEADER_FROM_BLOCK]: xFromBlock
187
193
  } = await this.baseProvider.getAuthHeaders(this, payload);
188
194
  request.setHeader(HEADER_TIMESTAMP, xTimestamp);
189
195
  if (xSignature) {
@@ -192,6 +198,13 @@ var SilentDataRollupProvider = class _SilentDataRollupProvider extends JsonRpcPr
192
198
  if (xEip712Signature) {
193
199
  request.setHeader(HEADER_EIP712_SIGNATURE, xEip712Signature);
194
200
  }
201
+ if (xFromBlock) {
202
+ request.setHeader(HEADER_FROM_BLOCK, xFromBlock);
203
+ }
204
+ const signatureType = this.config.authSignatureType ?? SignatureType.EIP191;
205
+ if (signatureType) {
206
+ request.setHeader(HEADER_SIGNATURE_TYPE, signatureType);
207
+ }
195
208
  }
196
209
  const response = await request.send();
197
210
  response.assertOk();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appliedblockchain/silentdatarollup-ethers-provider",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Ethers.js provider for Silent Data",
5
5
  "author": "Applied Blockchain",
6
6
  "homepage": "https://github.com/appliedblockchain/silent-data-rollup-providers#readme",
@@ -25,23 +25,23 @@
25
25
  "files": [
26
26
  "dist"
27
27
  ],
28
- "scripts": {
29
- "build": "tsc --noEmit && tsup src/index.ts --format cjs,esm --dts --clean",
30
- "check-exports": "attw --pack . --profile node16",
31
- "prepack": "npm run build",
32
- "test": "jest"
33
- },
34
28
  "dependencies": {
35
- "@appliedblockchain/silentdatarollup-core": "1.0.8",
36
29
  "debug": "4.3.7",
37
- "ethers": "6.13.2"
30
+ "ethers": "6.13.2",
31
+ "@appliedblockchain/silentdatarollup-core": "1.0.9"
38
32
  },
39
33
  "devDependencies": {
40
- "@types/node": "22.5.4",
34
+ "@types/debug": "4.1.12",
35
+ "@types/node": "24.10.1",
41
36
  "ts-node": "10.9.2",
42
37
  "typescript": "5.6.2"
43
38
  },
44
39
  "engines": {
45
40
  "node": ">=18.0.0"
41
+ },
42
+ "scripts": {
43
+ "build": "tsc --noEmit && tsup src/index.ts --format cjs,esm --dts --clean",
44
+ "check-exports": "attw --pack . --profile node16",
45
+ "test": "jest"
46
46
  }
47
- }
47
+ }