@appliedblockchain/silentdatarollup-viem 1.0.6 → 1.0.8

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Silent Data [Rollup] Providers - Viem Transport Package
1
+ # Silent Data Providers - Viem Transport Package
2
2
 
3
3
  ## Table of Contents
4
4
 
@@ -14,7 +14,7 @@
14
14
 
15
15
  ## Introduction
16
16
 
17
- Viem custom transport for Silent Data [Rollup].
17
+ Viem custom transport for Silent Data.
18
18
 
19
19
  ## Prerequisites
20
20
 
@@ -30,49 +30,28 @@ Viem custom transport for Silent Data [Rollup].
30
30
  #### Installing Basic Usage Dependencies
31
31
 
32
32
  ```bash
33
- npm install @appliedblockchain/silentdatarollup-core @appliedblockchain/silentdatarollup-viem
33
+ npm install @appliedblockchain/silentdatarollup-viem
34
34
  ```
35
35
 
36
36
  #### Basic Usage Example
37
37
 
38
38
  ```typescript
39
- import {
40
- type Chain,
41
- defineChain,
42
- createPublicClient,
43
- createWalletClient,
44
- formatEther,
45
- type CallParameters,
46
- publicActions,
47
- } from 'viem'
48
- import { transport } from '@appliedblockchain/silentdatarollup-viem'
49
-
50
- // For transaction signing and sending, create an account from the private key
51
- const account = privateKeyToAccount(providerConfig.privateKey as `0x${string}`)
52
- const walletClient = createWalletClient({
53
- chain: silentDataChain,
54
- transport,
55
- account,
56
- })
39
+ import { defineChain, createPublicClient, createWalletClient } from 'viem'
40
+ import { privateKeyToAccount } from 'viem/accounts'
41
+ import { sdTransport } from '@appliedblockchain/silentdatarollup-viem'
57
42
 
58
- const transport = sdTransport({
43
+ const providerConfig = {
59
44
  rpcUrl: 'SILENT_DATA_ROLLUP_RPC_URL',
60
- chainId: SILENT_DATA_CHAIN_ID,
45
+ chainId: 'SILENT_DATA_CHAIN_ID',
61
46
  privateKey: 'YOUR_PRIVATE_KEY',
62
- })
47
+ }
63
48
 
64
- const client = createPublicClient({
65
- transport,
66
- })
49
+ const account = privateKeyToAccount(providerConfig.privateKey)
67
50
 
68
- const balance = await publicClient.getBalance({ address })
69
- console.log('Balance:', balance)
70
-
71
- const transactionCount = await publicClient.getTransactionCount({ address })
72
- console.log('Transaction count:', transactionCount)
51
+ const transport = sdTransport(providerConfig)
73
52
 
74
53
  const sdChain = defineChain({
75
- id: SILENT_DATA_CHAIN_ID,
54
+ id: providerConfig.chainId,
76
55
  name: 'SILENT_DATA_CHAIN_NAME',
77
56
  nativeCurrency: {
78
57
  name: 'Ether',
@@ -81,17 +60,30 @@ const sdChain = defineChain({
81
60
  },
82
61
  rpcUrls: {
83
62
  default: {
84
- http: ['SILENT_DATA_ROLLUP_RPC_URL'],
63
+ http: [providerConfig.rpcUrl],
85
64
  },
86
65
  },
87
66
  })
88
67
 
68
+ const publicClient = createPublicClient({
69
+ chain: sdChain,
70
+ transport,
71
+ })
72
+
89
73
  const walletClient = createWalletClient({
90
- chain: silentDataChain,
74
+ chain: sdChain,
91
75
  transport,
92
76
  account,
93
77
  })
94
78
 
79
+ const balance = await publicClient.getBalance({ address: account.address })
80
+ console.log('Balance:', balance)
81
+
82
+ const transactionCount = await publicClient.getTransactionCount({
83
+ address: account.address,
84
+ })
85
+ console.log('Transaction count:', transactionCount)
86
+
95
87
  const recipientAddress = 'RECIPIENT_ADDRESS'
96
88
  const amountInWei = BigInt('1')
97
89
 
@@ -99,7 +91,6 @@ const transactionHash = await walletClient.sendTransaction({
99
91
  to: recipientAddress,
100
92
  value: amountInWei,
101
93
  })
102
-
103
94
  console.log('Transaction Hash:', transactionHash)
104
95
  ```
105
96
 
@@ -117,5 +108,5 @@ If you encounter any issues, please check the following:
117
108
 
118
109
  ## Additional Resources
119
110
 
120
- - [Silent Data [Rollup] Documentation](https://docs.silentdata.com)
111
+ - [Silent Data Documentation](https://docs.silentdata.com)
121
112
  - [Viem Documentation](https://viem.sh/docs/)
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SilentDataRollupProviderConfig } from '@appliedblockchain/silentdatarollup-ethers-provider';
2
2
  import { CustomTransport } from 'viem';
3
3
 
4
- declare const sdTransport: (config: SilentDataRollupProviderConfig) => CustomTransport;
4
+ declare function sdTransport(providerConfig: SilentDataRollupProviderConfig): CustomTransport;
5
5
 
6
6
  export { sdTransport };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SilentDataRollupProviderConfig } from '@appliedblockchain/silentdatarollup-ethers-provider';
2
2
  import { CustomTransport } from 'viem';
3
3
 
4
- declare const sdTransport: (config: SilentDataRollupProviderConfig) => CustomTransport;
4
+ declare function sdTransport(providerConfig: SilentDataRollupProviderConfig): CustomTransport;
5
5
 
6
6
  export { sdTransport };
package/dist/index.js CHANGED
@@ -27,28 +27,22 @@ module.exports = __toCommonJS(index_exports);
27
27
  // src/transport.ts
28
28
  var import_silentdatarollup_ethers_provider = require("@appliedblockchain/silentdatarollup-ethers-provider");
29
29
  var import_viem = require("viem");
30
- var sdTransport = (config) => {
31
- const providerConfig = config;
32
- const ethersProvider = new import_silentdatarollup_ethers_provider.SilentDataRollupProvider(providerConfig);
33
- const transport = (0, import_viem.custom)({
30
+ function sdTransport(providerConfig) {
31
+ const provider = new import_silentdatarollup_ethers_provider.SilentDataRollupProvider(providerConfig);
32
+ return (0, import_viem.custom)({
34
33
  request: async ({ method, params }) => {
35
- const txData = params?.[0] ?? {};
36
- if (method === "eth_sendTransaction" && ethersProvider.signer && !txData.nonce) {
37
- const signerAddress = await ethersProvider.signer.getAddress();
38
- const nonce = await ethersProvider.getTransactionCount(
39
- signerAddress,
40
- "latest"
41
- );
42
- txData.nonce = nonce;
34
+ if (method === "eth_sendTransaction" && Array.isArray(params) && params.length > 0) {
35
+ const tx = params[0];
36
+ let gasLimit = tx.gasLimit;
37
+ if (!gasLimit) {
38
+ gasLimit = await provider.estimateGas(tx);
39
+ }
40
+ return await provider.signer.sendTransaction({ ...tx, gasLimit });
43
41
  }
44
- if (method === "eth_getBlockByNumber" && Array.isArray(params) && params.length > 1) {
45
- params[1] = false;
46
- }
47
- return await ethersProvider.send(method, params || []);
42
+ return await provider.send(method, params || []);
48
43
  }
49
44
  });
50
- return transport;
51
- };
45
+ }
52
46
  // Annotate the CommonJS export names for ESM import in node:
53
47
  0 && (module.exports = {
54
48
  sdTransport
package/dist/index.mjs CHANGED
@@ -3,28 +3,22 @@ import {
3
3
  SilentDataRollupProvider
4
4
  } from "@appliedblockchain/silentdatarollup-ethers-provider";
5
5
  import { custom } from "viem";
6
- var sdTransport = (config) => {
7
- const providerConfig = config;
8
- const ethersProvider = new SilentDataRollupProvider(providerConfig);
9
- const transport = custom({
6
+ function sdTransport(providerConfig) {
7
+ const provider = new SilentDataRollupProvider(providerConfig);
8
+ return custom({
10
9
  request: async ({ method, params }) => {
11
- const txData = params?.[0] ?? {};
12
- if (method === "eth_sendTransaction" && ethersProvider.signer && !txData.nonce) {
13
- const signerAddress = await ethersProvider.signer.getAddress();
14
- const nonce = await ethersProvider.getTransactionCount(
15
- signerAddress,
16
- "latest"
17
- );
18
- txData.nonce = nonce;
10
+ if (method === "eth_sendTransaction" && Array.isArray(params) && params.length > 0) {
11
+ const tx = params[0];
12
+ let gasLimit = tx.gasLimit;
13
+ if (!gasLimit) {
14
+ gasLimit = await provider.estimateGas(tx);
15
+ }
16
+ return await provider.signer.sendTransaction({ ...tx, gasLimit });
19
17
  }
20
- if (method === "eth_getBlockByNumber" && Array.isArray(params) && params.length > 1) {
21
- params[1] = false;
22
- }
23
- return await ethersProvider.send(method, params || []);
18
+ return await provider.send(method, params || []);
24
19
  }
25
20
  });
26
- return transport;
27
- };
21
+ }
28
22
  export {
29
23
  sdTransport
30
24
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@appliedblockchain/silentdatarollup-viem",
3
- "version": "1.0.6",
4
- "description": "Viem package for Silent Data [Rollup]",
3
+ "version": "1.0.8",
4
+ "description": "Viem package for Silent Data",
5
5
  "author": "Applied Blockchain",
6
6
  "homepage": "https://github.com/appliedblockchain/silent-data-rollup-providers#readme",
7
7
  "keywords": [
@@ -33,8 +33,7 @@
33
33
  "test": "jest"
34
34
  },
35
35
  "dependencies": {
36
- "@appliedblockchain/silentdatarollup-core": "1.0.6",
37
- "@appliedblockchain/silentdatarollup-ethers-provider": "1.0.6",
36
+ "@appliedblockchain/silentdatarollup-ethers-provider": "1.0.8",
38
37
  "viem": "2.31.4"
39
38
  },
40
39
  "devDependencies": {