@appliedblockchain/silentdatarollup-viem 1.0.7 → 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 +21 -0
- package/README.md +29 -38
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -9
- package/dist/index.mjs +16 -9
- package/package.json +10 -13
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Silent Data
|
|
1
|
+
# Silent Data Providers - Viem Transport Package
|
|
2
2
|
|
|
3
3
|
## Table of Contents
|
|
4
4
|
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
|
|
15
15
|
## Introduction
|
|
16
16
|
|
|
17
|
-
Viem custom transport for Silent Data
|
|
17
|
+
Viem custom transport for Silent Data.
|
|
18
18
|
|
|
19
19
|
## Prerequisites
|
|
20
20
|
|
|
21
21
|
- Node.js (version 18 or higher)
|
|
22
|
-
-
|
|
22
|
+
- pnpm
|
|
23
23
|
- Basic knowledge of Ethereum and smart contracts
|
|
24
24
|
- Viem
|
|
25
25
|
|
|
@@ -30,49 +30,28 @@ Viem custom transport for Silent Data [Rollup].
|
|
|
30
30
|
#### Installing Basic Usage Dependencies
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
|
|
33
|
+
pnpm add @appliedblockchain/silentdatarollup-viem
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
#### Basic Usage Example
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
|
-
import {
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
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
|
|
65
|
-
transport,
|
|
66
|
-
})
|
|
49
|
+
const account = privateKeyToAccount(providerConfig.privateKey)
|
|
67
50
|
|
|
68
|
-
const
|
|
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:
|
|
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: [
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
4
|
+
declare function sdTransport(providerConfig: SilentDataRollupProviderConfig): CustomTransport;
|
|
5
5
|
|
|
6
6
|
export { sdTransport };
|
package/dist/index.js
CHANGED
|
@@ -27,19 +27,26 @@ 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
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
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
|
-
if (method === "
|
|
36
|
-
params[
|
|
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
|
+
const txResponse = await provider.signer.sendTransaction({
|
|
41
|
+
...tx,
|
|
42
|
+
gasLimit
|
|
43
|
+
});
|
|
44
|
+
return txResponse.hash;
|
|
37
45
|
}
|
|
38
|
-
return await
|
|
46
|
+
return await provider.send(method, params || []);
|
|
39
47
|
}
|
|
40
48
|
});
|
|
41
|
-
|
|
42
|
-
};
|
|
49
|
+
}
|
|
43
50
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
51
|
0 && (module.exports = {
|
|
45
52
|
sdTransport
|
package/dist/index.mjs
CHANGED
|
@@ -3,19 +3,26 @@ import {
|
|
|
3
3
|
SilentDataRollupProvider
|
|
4
4
|
} from "@appliedblockchain/silentdatarollup-ethers-provider";
|
|
5
5
|
import { custom } from "viem";
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const transport = custom({
|
|
6
|
+
function sdTransport(providerConfig) {
|
|
7
|
+
const provider = new SilentDataRollupProvider(providerConfig);
|
|
8
|
+
return custom({
|
|
10
9
|
request: async ({ method, params }) => {
|
|
11
|
-
if (method === "
|
|
12
|
-
params[
|
|
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
|
+
const txResponse = await provider.signer.sendTransaction({
|
|
17
|
+
...tx,
|
|
18
|
+
gasLimit
|
|
19
|
+
});
|
|
20
|
+
return txResponse.hash;
|
|
13
21
|
}
|
|
14
|
-
return await
|
|
22
|
+
return await provider.send(method, params || []);
|
|
15
23
|
}
|
|
16
24
|
});
|
|
17
|
-
|
|
18
|
-
};
|
|
25
|
+
}
|
|
19
26
|
export {
|
|
20
27
|
sdTransport
|
|
21
28
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appliedblockchain/silentdatarollup-viem",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Viem package for Silent Data
|
|
3
|
+
"version": "1.0.9",
|
|
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": [
|
|
@@ -26,23 +26,20 @@
|
|
|
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
|
-
"test": "jest"
|
|
34
|
-
},
|
|
35
29
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"@appliedblockchain/silentdatarollup-ethers-provider": "1.0.
|
|
38
|
-
"viem": "2.31.4"
|
|
30
|
+
"viem": "2.31.4",
|
|
31
|
+
"@appliedblockchain/silentdatarollup-ethers-provider": "1.0.9"
|
|
39
32
|
},
|
|
40
33
|
"devDependencies": {
|
|
41
|
-
"@types/node": "
|
|
34
|
+
"@types/node": "24.10.1",
|
|
42
35
|
"ts-node": "10.9.2",
|
|
43
36
|
"typescript": "5.6.2"
|
|
44
37
|
},
|
|
45
38
|
"engines": {
|
|
46
39
|
"node": ">=18.0.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc --noEmit && tsup src/index.ts --format cjs,esm --dts --clean",
|
|
43
|
+
"check-exports": "attw --pack . --profile node16"
|
|
47
44
|
}
|
|
48
|
-
}
|
|
45
|
+
}
|