@rocketh/signer 0.17.7 → 0.17.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.
Files changed (2) hide show
  1. package/README.md +214 -3
  2. package/package.json +4 -3
package/README.md CHANGED
@@ -1,7 +1,218 @@
1
1
  # @rocketh/signer
2
2
 
3
- Signer utilities for rocketh, providing signer protocol functions for private key-based signing and wallet integration.
3
+ Signer protocol implementations for Rocketh. This package provides a way to configure and use different signing mechanisms in your deployment scripts.
4
4
 
5
- For full documentation, visit [rocketh.dev](https://rocketh.dev).
5
+ ## Features
6
6
 
7
- For hardhat-deploy documentation, see [rocketh.dev/hardhat-deploy/](https://rocketh.dev/hardhat-deploy/).
7
+ - 🔐 **Private Key Signing** - Sign transactions using raw private keys
8
+ - 🔌 **Protocol-Based** - Extensible signer protocol system
9
+ - 🛡️ **Type Safe** - Full TypeScript support for signer configuration
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ # Using pnpm
15
+ pnpm add @rocketh/signer
16
+
17
+ # Using npm
18
+ npm install @rocketh/signer
19
+
20
+ # Using yarn
21
+ yarn add @rocketh/signer
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### Configuring the Signer Protocol
27
+
28
+ Add the signer protocol to your Rocketh configuration:
29
+
30
+ ```typescript
31
+ // rocketh/config.ts
32
+ import type { UserConfig } from 'rocketh/types';
33
+ import { privateKey } from '@rocketh/signer';
34
+
35
+ export const config = {
36
+ accounts: {
37
+ deployer: {
38
+ default: 0,
39
+ },
40
+ },
41
+ signerProtocols: {
42
+ privateKey: privateKey,
43
+ },
44
+ data: {},
45
+ } as const satisfies UserConfig;
46
+ ```
47
+
48
+ ### Using Private Key Signer
49
+
50
+ The private key signer allows you to sign transactions using a raw private key:
51
+
52
+ ```typescript
53
+ // In your environment variables or configuration
54
+ // Format: privateKey:0x{64-character-hex-string}
55
+
56
+ // Example .env file:
57
+ // DEPLOYER_SIGNER=privateKey:0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
58
+ ```
59
+
60
+ ### Protocol String Format
61
+
62
+ The signer uses a protocol string format:
63
+
64
+ ```
65
+ {protocol}:{data}
66
+ ```
67
+
68
+ For the private key signer:
69
+ ```
70
+ privateKey:0x{privateKeyHex}
71
+ ```
72
+
73
+ **Example:**
74
+ ```
75
+ privateKey:0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
76
+ ```
77
+
78
+ ## API Reference
79
+
80
+ ### `privateKey`
81
+
82
+ A signer protocol function that creates a signer from a private key.
83
+
84
+ **Type:**
85
+ ```typescript
86
+ const privateKey: SignerProtocolFunction
87
+ ```
88
+
89
+ **Protocol String Format:**
90
+ ```
91
+ privateKey:0x{64-hex-characters}
92
+ ```
93
+
94
+ **Returns:**
95
+ ```typescript
96
+ {
97
+ type: 'signerOnly';
98
+ signer: EIP1193LocalSigner;
99
+ }
100
+ ```
101
+
102
+ **Throws:**
103
+ - Error if the private key doesn't start with `0x`
104
+
105
+ ## Creating Custom Signer Protocols
106
+
107
+ You can create custom signer protocols by implementing the `SignerProtocolFunction` interface:
108
+
109
+ ```typescript
110
+ import type { SignerProtocolFunction, Signer } from '@rocketh/core/types';
111
+
112
+ // Example: Hardware wallet signer
113
+ export const ledger: SignerProtocolFunction = async (protocolString: string) => {
114
+ const [proto, derivationPath] = protocolString.split(':');
115
+
116
+ // Connect to hardware wallet and get signer
117
+ const hardwareSigner = await connectToLedger(derivationPath);
118
+
119
+ return {
120
+ type: 'signerOnly',
121
+ signer: hardwareSigner,
122
+ };
123
+ };
124
+
125
+ // Example: Cloud KMS signer
126
+ export const awsKms: SignerProtocolFunction = async (protocolString: string) => {
127
+ const [proto, keyId] = protocolString.split(':');
128
+
129
+ // Connect to AWS KMS
130
+ const kmsSigner = await createKmsSigner(keyId);
131
+
132
+ return {
133
+ type: 'signerOnly',
134
+ signer: kmsSigner,
135
+ };
136
+ };
137
+ ```
138
+
139
+ Then register in your config:
140
+
141
+ ```typescript
142
+ // rocketh/config.ts
143
+ import { privateKey } from '@rocketh/signer';
144
+ import { ledger, awsKms } from './custom-signers.js';
145
+
146
+ export const config = {
147
+ signerProtocols: {
148
+ privateKey,
149
+ ledger,
150
+ awsKms,
151
+ },
152
+ // ...
153
+ } as const satisfies UserConfig;
154
+ ```
155
+
156
+ ## Signer Types
157
+
158
+ Rocketh supports three signer types:
159
+
160
+ ### `signerOnly`
161
+ A signer that can only sign transactions (no sending capability):
162
+ ```typescript
163
+ {
164
+ type: 'signerOnly';
165
+ signer: EIP1193SignerProvider;
166
+ }
167
+ ```
168
+
169
+ ### `remote`
170
+ A remote signer (e.g., JSON-RPC provider):
171
+ ```typescript
172
+ {
173
+ type: 'remote';
174
+ signer: EIP1193ProviderWithoutEvents;
175
+ }
176
+ ```
177
+
178
+ ### `wallet`
179
+ A full wallet provider (e.g., MetaMask):
180
+ ```typescript
181
+ {
182
+ type: 'wallet';
183
+ signer: EIP1193WalletProvider;
184
+ }
185
+ ```
186
+
187
+ ## Security Considerations
188
+
189
+ ⚠️ **Important Security Notes:**
190
+
191
+ 1. **Never commit private keys** - Use environment variables or secure secret management
192
+ 2. **Use hardware wallets for production** - Consider implementing a hardware wallet signer for mainnet deployments
193
+ 3. **Limit private key exposure** - The private key signer is best suited for development and testing
194
+
195
+ ### Recommended Practices
196
+
197
+ ```bash
198
+ # .env (never commit this file!)
199
+ DEPLOYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
200
+
201
+ # .env.example (commit this as a template)
202
+ DEPLOYER_PRIVATE_KEY=privateKey:0x...
203
+ ```
204
+
205
+ ```typescript
206
+ // Use environment variable
207
+ const signerString = process.env.DEPLOYER_PRIVATE_KEY;
208
+ ```
209
+
210
+ ## Related Packages
211
+
212
+ - [`rocketh`](../rocketh) - Core deployment environment
213
+ - [`@rocketh/core`](../rocketh-core) - Core types and utilities
214
+ - [`eip-1193-signer`](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md) - EIP-1193 signer implementation
215
+
216
+ ## License
217
+
218
+ [MIT](../../LICENSE)
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@rocketh/signer",
3
- "version": "0.17.7",
3
+ "version": "0.17.8",
4
+ "license": "MIT",
4
5
  "description": "add signer to rocketh",
5
6
  "publishConfig": {
6
7
  "access": "public"
@@ -24,10 +25,10 @@
24
25
  "dependencies": {
25
26
  "eip-1193": "^0.6.5",
26
27
  "eip-1193-signer": "^0.1.1",
27
- "@rocketh/core": "0.17.10"
28
+ "@rocketh/core": "0.17.11"
28
29
  },
29
30
  "devDependencies": {
30
- "as-soon": "^0.1.4",
31
+ "as-soon": "^0.1.5",
31
32
  "rimraf": "^6.1.2",
32
33
  "typescript": "^5.9.3"
33
34
  },