@appliedblockchain/silentdatarollup-ethers-provider 1.0.2 → 1.0.4

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.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Signer, JsonRpcApiProviderOptions, Filter, JsonRpcProvider, JsonRpcPayload, JsonRpcResult, FetchRequest, Log, FilterByBlockHash, LogDescription, Interface } from 'ethers';
2
2
  import { BaseConfig, NetworkName } from '@appliedblockchain/silentdatarollup-core';
3
3
 
4
- declare const SIGN_RPC_METHODS: string[];
5
4
  declare const DEBUG_NAMESPACE = "silentdata:ethers-provider";
6
5
 
7
6
  interface SilentDataRollupProviderConfig extends BaseConfig {
@@ -103,4 +102,4 @@ declare class SDInterface extends Interface {
103
102
  parseLog(log: Parameters<Interface['parseLog']>[0]): SDLogDescription | null;
104
103
  }
105
104
 
106
- export { DEBUG_NAMESPACE, type PrivateEventsFilter, SDInterface, type SDLogDescription, SIGN_RPC_METHODS, SilentDataRollupProvider, type SilentDataRollupProviderConfig };
105
+ export { DEBUG_NAMESPACE, type PrivateEventsFilter, SDInterface, type SDLogDescription, SilentDataRollupProvider, type SilentDataRollupProviderConfig };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Signer, JsonRpcApiProviderOptions, Filter, JsonRpcProvider, JsonRpcPayload, JsonRpcResult, FetchRequest, Log, FilterByBlockHash, LogDescription, Interface } from 'ethers';
2
2
  import { BaseConfig, NetworkName } from '@appliedblockchain/silentdatarollup-core';
3
3
 
4
- declare const SIGN_RPC_METHODS: string[];
5
4
  declare const DEBUG_NAMESPACE = "silentdata:ethers-provider";
6
5
 
7
6
  interface SilentDataRollupProviderConfig extends BaseConfig {
@@ -103,4 +102,4 @@ declare class SDInterface extends Interface {
103
102
  parseLog(log: Parameters<Interface['parseLog']>[0]): SDLogDescription | null;
104
103
  }
105
104
 
106
- export { DEBUG_NAMESPACE, type PrivateEventsFilter, SDInterface, type SDLogDescription, SIGN_RPC_METHODS, SilentDataRollupProvider, type SilentDataRollupProviderConfig };
105
+ export { DEBUG_NAMESPACE, type PrivateEventsFilter, SDInterface, type SDLogDescription, SilentDataRollupProvider, type SilentDataRollupProviderConfig };
package/dist/index.js CHANGED
@@ -32,19 +32,11 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  DEBUG_NAMESPACE: () => DEBUG_NAMESPACE,
34
34
  SDInterface: () => SDInterface,
35
- SIGN_RPC_METHODS: () => SIGN_RPC_METHODS,
36
35
  SilentDataRollupProvider: () => SilentDataRollupProvider
37
36
  });
38
37
  module.exports = __toCommonJS(index_exports);
39
38
 
40
39
  // src/constants.ts
41
- var SIGN_RPC_METHODS = [
42
- "eth_getTransactionByHash",
43
- "eth_getBalance",
44
- "eth_getTransactionCount",
45
- "eth_getProof",
46
- "eth_getTransactionReceipt"
47
- ];
48
40
  var DEBUG_NAMESPACE = "silentdata:ethers-provider";
49
41
 
50
42
  // src/provider.ts
@@ -53,24 +45,22 @@ var import_ethers = require("ethers");
53
45
  function isPromise(value) {
54
46
  return value && typeof value.then === "function";
55
47
  }
56
- function getNetwork(name, chainId) {
57
- switch (name) {
58
- case import_silentdatarollup_core.NetworkName.MAINNET:
59
- return new import_ethers.Network(name, chainId || import_silentdatarollup_core.ChainId.MAINNET);
60
- case import_silentdatarollup_core.NetworkName.TESTNET:
61
- return new import_ethers.Network(name, chainId || import_silentdatarollup_core.ChainId.TESTNET);
62
- default:
63
- (0, import_ethers.assertArgument)(false, "unsupported network", "network", name);
48
+ function getNetwork(networkName, chainId) {
49
+ if (chainId) {
50
+ return new import_ethers.Network(networkName ?? "custom", chainId);
64
51
  }
52
+ if (networkName === import_silentdatarollup_core.NetworkName.MAINNET) {
53
+ return new import_ethers.Network(networkName, import_silentdatarollup_core.ChainId.MAINNET);
54
+ } else if (networkName === import_silentdatarollup_core.NetworkName.TESTNET) {
55
+ return new import_ethers.Network(networkName, import_silentdatarollup_core.ChainId.TESTNET);
56
+ }
57
+ return void 0;
65
58
  }
66
59
  var providerDefaultOptions = {
67
60
  batchMaxCount: 1
68
61
  };
69
62
  var SilentDataRollupProvider = class _SilentDataRollupProvider extends import_ethers.JsonRpcProvider {
70
63
  constructor(config) {
71
- if (!config.network) {
72
- config.network = import_silentdatarollup_core.NetworkName.MAINNET;
73
- }
74
64
  (0, import_ethers.assertArgument)(config.rpcUrl, "rpcUrl is mandatory", "config", config);
75
65
  const network = getNetwork(config.network, config.chainId);
76
66
  const request = _SilentDataRollupProvider.getRequest({
@@ -118,8 +108,8 @@ var SilentDataRollupProvider = class _SilentDataRollupProvider extends import_et
118
108
  if (filter && typeof filter === "object" && "_isPrivateEvent" in filter) {
119
109
  isPrivateLogsRequest = !!filter._isPrivateEvent;
120
110
  if (isPrivateLogsRequest) {
121
- const { _isPrivateEvent, ...filterCopy } = filter;
122
- payload.params[0] = filterCopy;
111
+ delete filter._isPrivateEvent;
112
+ payload.params[0] = filter;
123
113
  }
124
114
  }
125
115
  }
@@ -345,6 +335,5 @@ var SDInterface = class extends import_ethers2.Interface {
345
335
  0 && (module.exports = {
346
336
  DEBUG_NAMESPACE,
347
337
  SDInterface,
348
- SIGN_RPC_METHODS,
349
338
  SilentDataRollupProvider
350
339
  });
package/dist/index.mjs CHANGED
@@ -1,11 +1,4 @@
1
1
  // src/constants.ts
2
- var SIGN_RPC_METHODS = [
3
- "eth_getTransactionByHash",
4
- "eth_getBalance",
5
- "eth_getTransactionCount",
6
- "eth_getProof",
7
- "eth_getTransactionReceipt"
8
- ];
9
2
  var DEBUG_NAMESPACE = "silentdata:ethers-provider";
10
3
 
11
4
  // src/provider.ts
@@ -21,7 +14,7 @@ import {
21
14
  isSignableContractCall,
22
15
  NetworkName,
23
16
  PRIVATE_EVENT_SIGNATURE_HASH,
24
- SIGN_RPC_METHODS as SIGN_RPC_METHODS2,
17
+ SIGN_RPC_METHODS,
25
18
  SignatureType,
26
19
  SilentDataRollupBase
27
20
  } from "@appliedblockchain/silentdatarollup-core";
@@ -36,24 +29,22 @@ import {
36
29
  function isPromise(value) {
37
30
  return value && typeof value.then === "function";
38
31
  }
39
- function getNetwork(name, chainId) {
40
- switch (name) {
41
- case NetworkName.MAINNET:
42
- return new Network(name, chainId || ChainId.MAINNET);
43
- case NetworkName.TESTNET:
44
- return new Network(name, chainId || ChainId.TESTNET);
45
- default:
46
- assertArgument(false, "unsupported network", "network", name);
32
+ function getNetwork(networkName, chainId) {
33
+ if (chainId) {
34
+ return new Network(networkName ?? "custom", chainId);
35
+ }
36
+ if (networkName === NetworkName.MAINNET) {
37
+ return new Network(networkName, ChainId.MAINNET);
38
+ } else if (networkName === NetworkName.TESTNET) {
39
+ return new Network(networkName, ChainId.TESTNET);
47
40
  }
41
+ return void 0;
48
42
  }
49
43
  var providerDefaultOptions = {
50
44
  batchMaxCount: 1
51
45
  };
52
46
  var SilentDataRollupProvider = class _SilentDataRollupProvider extends JsonRpcProvider {
53
47
  constructor(config) {
54
- if (!config.network) {
55
- config.network = NetworkName.MAINNET;
56
- }
57
48
  assertArgument(config.rpcUrl, "rpcUrl is mandatory", "config", config);
58
49
  const network = getNetwork(config.network, config.chainId);
59
50
  const request = _SilentDataRollupProvider.getRequest({
@@ -101,15 +92,15 @@ var SilentDataRollupProvider = class _SilentDataRollupProvider extends JsonRpcPr
101
92
  if (filter && typeof filter === "object" && "_isPrivateEvent" in filter) {
102
93
  isPrivateLogsRequest = !!filter._isPrivateEvent;
103
94
  if (isPrivateLogsRequest) {
104
- const { _isPrivateEvent, ...filterCopy } = filter;
105
- payload.params[0] = filterCopy;
95
+ delete filter._isPrivateEvent;
96
+ payload.params[0] = filter;
106
97
  }
107
98
  }
108
99
  }
109
100
  const request = this._getConnection();
110
101
  request.body = JSON.stringify(payload);
111
102
  request.setHeader("content-type", "application/json");
112
- const requiresAuthHeaders = isPrivateLogsRequest || SIGN_RPC_METHODS2.includes(payload.method) || isSignableContractCall(
103
+ const requiresAuthHeaders = isPrivateLogsRequest || SIGN_RPC_METHODS.includes(payload.method) || isSignableContractCall(
113
104
  payload,
114
105
  this.baseProvider.contractMethodsToSign,
115
106
  this.baseProvider.contract
@@ -327,6 +318,5 @@ var SDInterface = class extends Interface {
327
318
  export {
328
319
  DEBUG_NAMESPACE,
329
320
  SDInterface,
330
- SIGN_RPC_METHODS,
331
321
  SilentDataRollupProvider
332
322
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appliedblockchain/silentdatarollup-ethers-provider",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Ethers.js provider for Silent Data [Rollup]",
5
5
  "author": "Applied Blockchain",
6
6
  "homepage": "https://github.com/appliedblockchain/silent-data-rollup-providers#readme",
@@ -26,13 +26,13 @@
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
  "test": "jest"
33
33
  },
34
34
  "dependencies": {
35
- "@appliedblockchain/silentdatarollup-core": "1.0.2",
35
+ "@appliedblockchain/silentdatarollup-core": "1.0.4",
36
36
  "debug": "4.3.7",
37
37
  "ethers": "6.13.2"
38
38
  },