tenjin-cli 0.1.0-alpha.0

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 (50) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +52 -0
  3. package/README.md +124 -0
  4. package/dist/_esm-ZH2J4QEH.js +3737 -0
  5. package/dist/_esm-ZH2J4QEH.js.map +1 -0
  6. package/dist/ccip-FXWZDDF5.js +17 -0
  7. package/dist/ccip-FXWZDDF5.js.map +1 -0
  8. package/dist/chunk-376LHMK2.js +100 -0
  9. package/dist/chunk-376LHMK2.js.map +1 -0
  10. package/dist/chunk-3IMLRUZE.js +44 -0
  11. package/dist/chunk-3IMLRUZE.js.map +1 -0
  12. package/dist/chunk-CPUZRZ2A.js +410 -0
  13. package/dist/chunk-CPUZRZ2A.js.map +1 -0
  14. package/dist/chunk-F5DZJLU3.js +2058 -0
  15. package/dist/chunk-F5DZJLU3.js.map +1 -0
  16. package/dist/chunk-FIYZLITH.js +14577 -0
  17. package/dist/chunk-FIYZLITH.js.map +1 -0
  18. package/dist/chunk-LTTRND4A.js +135 -0
  19. package/dist/chunk-LTTRND4A.js.map +1 -0
  20. package/dist/chunk-PAAL45FJ.js +7307 -0
  21. package/dist/chunk-PAAL45FJ.js.map +1 -0
  22. package/dist/chunk-QHIEYBLV.js +320 -0
  23. package/dist/chunk-QHIEYBLV.js.map +1 -0
  24. package/dist/chunk-SXQQ2ZSR.js +887 -0
  25. package/dist/chunk-SXQQ2ZSR.js.map +1 -0
  26. package/dist/chunk-TX5T3LKJ.js +2249 -0
  27. package/dist/chunk-TX5T3LKJ.js.map +1 -0
  28. package/dist/chunk-WOHCAMDQ.js +4474 -0
  29. package/dist/chunk-WOHCAMDQ.js.map +1 -0
  30. package/dist/chunk-ZPZFPVDN.js +67 -0
  31. package/dist/chunk-ZPZFPVDN.js.map +1 -0
  32. package/dist/cli-LMHGCZ5S.js +3763 -0
  33. package/dist/cli-LMHGCZ5S.js.map +1 -0
  34. package/dist/config-XVXZ3V2Q.js +206 -0
  35. package/dist/config-XVXZ3V2Q.js.map +1 -0
  36. package/dist/doctor-MVLZRVPU.js +338 -0
  37. package/dist/doctor-MVLZRVPU.js.map +1 -0
  38. package/dist/index.js +26 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/mine.wasm-GQECMSGN.js +11 -0
  41. package/dist/mine.wasm-GQECMSGN.js.map +1 -0
  42. package/dist/secp256k1-35YNNB6F.js +18 -0
  43. package/dist/secp256k1-35YNNB6F.js.map +1 -0
  44. package/dist/usdc-OQUOFF6R.js +18 -0
  45. package/dist/usdc-OQUOFF6R.js.map +1 -0
  46. package/dist/wallet-NRKWLKHX.js +153 -0
  47. package/dist/wallet-NRKWLKHX.js.map +1 -0
  48. package/dist/wallet-QUWK2PA4.js +22 -0
  49. package/dist/wallet-QUWK2PA4.js.map +1 -0
  50. package/package.json +63 -0
@@ -0,0 +1,320 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ hashAuthorization,
4
+ hashMessage,
5
+ hashTypedData,
6
+ publicKeyToAddress,
7
+ serializeSignature,
8
+ serializeTransaction
9
+ } from "./chunk-SXQQ2ZSR.js";
10
+ import {
11
+ secp256k1
12
+ } from "./chunk-TX5T3LKJ.js";
13
+ import {
14
+ InvalidAddressError,
15
+ hexToBytes,
16
+ isAddress,
17
+ isHex,
18
+ keccak256,
19
+ numberToHex,
20
+ toHex
21
+ } from "./chunk-F5DZJLU3.js";
22
+ import {
23
+ PRIVATE_KEY_RE,
24
+ readWalletRecord,
25
+ walletFileMode,
26
+ writeWalletRecord
27
+ } from "./chunk-376LHMK2.js";
28
+ import {
29
+ CliError,
30
+ walletPath
31
+ } from "./chunk-FIYZLITH.js";
32
+
33
+ // node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/accounts/generatePrivateKey.js
34
+ function generatePrivateKey() {
35
+ return toHex(secp256k1.utils.randomPrivateKey());
36
+ }
37
+
38
+ // node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/accounts/toAccount.js
39
+ function toAccount(source) {
40
+ if (typeof source === "string") {
41
+ if (!isAddress(source, { strict: false }))
42
+ throw new InvalidAddressError({ address: source });
43
+ return {
44
+ address: source,
45
+ type: "json-rpc"
46
+ };
47
+ }
48
+ if (!isAddress(source.address, { strict: false }))
49
+ throw new InvalidAddressError({ address: source.address });
50
+ return {
51
+ address: source.address,
52
+ nonceManager: source.nonceManager,
53
+ sign: source.sign,
54
+ signAuthorization: source.signAuthorization,
55
+ signMessage: source.signMessage,
56
+ signTransaction: source.signTransaction,
57
+ signTypedData: source.signTypedData,
58
+ source: "custom",
59
+ type: "local"
60
+ };
61
+ }
62
+
63
+ // node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/accounts/utils/sign.js
64
+ var extraEntropy = false;
65
+ async function sign({ hash, privateKey, to = "object" }) {
66
+ const { r, s, recovery } = secp256k1.sign(hash.slice(2), privateKey.slice(2), {
67
+ lowS: true,
68
+ extraEntropy: isHex(extraEntropy, { strict: false }) ? hexToBytes(extraEntropy) : extraEntropy
69
+ });
70
+ const signature = {
71
+ r: numberToHex(r, { size: 32 }),
72
+ s: numberToHex(s, { size: 32 }),
73
+ v: recovery ? 28n : 27n,
74
+ yParity: recovery
75
+ };
76
+ return (() => {
77
+ if (to === "bytes" || to === "hex")
78
+ return serializeSignature({ ...signature, to });
79
+ return signature;
80
+ })();
81
+ }
82
+
83
+ // node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/accounts/utils/signAuthorization.js
84
+ async function signAuthorization(parameters) {
85
+ const { chainId, nonce, privateKey, to = "object" } = parameters;
86
+ const address = parameters.contractAddress ?? parameters.address;
87
+ const signature = await sign({
88
+ hash: hashAuthorization({ address, chainId, nonce }),
89
+ privateKey,
90
+ to
91
+ });
92
+ if (to === "object")
93
+ return {
94
+ address,
95
+ chainId,
96
+ nonce,
97
+ ...signature
98
+ };
99
+ return signature;
100
+ }
101
+
102
+ // node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/accounts/utils/signMessage.js
103
+ async function signMessage({ message, privateKey }) {
104
+ return await sign({ hash: hashMessage(message), privateKey, to: "hex" });
105
+ }
106
+
107
+ // node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/accounts/utils/signTransaction.js
108
+ async function signTransaction(parameters) {
109
+ const { privateKey, transaction, serializer = serializeTransaction } = parameters;
110
+ const signableTransaction = (() => {
111
+ if (transaction.type === "eip4844")
112
+ return {
113
+ ...transaction,
114
+ sidecars: false
115
+ };
116
+ return transaction;
117
+ })();
118
+ const signature = await sign({
119
+ hash: keccak256(await serializer(signableTransaction)),
120
+ privateKey
121
+ });
122
+ return await serializer(transaction, signature);
123
+ }
124
+
125
+ // node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/accounts/utils/signTypedData.js
126
+ async function signTypedData(parameters) {
127
+ const { privateKey, ...typedData } = parameters;
128
+ return await sign({
129
+ hash: hashTypedData(typedData),
130
+ privateKey,
131
+ to: "hex"
132
+ });
133
+ }
134
+
135
+ // node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/_esm/accounts/privateKeyToAccount.js
136
+ function privateKeyToAccount(privateKey, options = {}) {
137
+ const { nonceManager } = options;
138
+ const publicKey = toHex(secp256k1.getPublicKey(privateKey.slice(2), false));
139
+ const address = publicKeyToAddress(publicKey);
140
+ const account = toAccount({
141
+ address,
142
+ nonceManager,
143
+ async sign({ hash }) {
144
+ return sign({ hash, privateKey, to: "hex" });
145
+ },
146
+ async signAuthorization(authorization) {
147
+ return signAuthorization({ ...authorization, privateKey });
148
+ },
149
+ async signMessage({ message }) {
150
+ return signMessage({ message, privateKey });
151
+ },
152
+ async signTransaction(transaction, { serializer } = {}) {
153
+ return signTransaction({ privateKey, transaction, serializer });
154
+ },
155
+ async signTypedData(typedData) {
156
+ return signTypedData({ ...typedData, privateKey });
157
+ }
158
+ });
159
+ return {
160
+ ...account,
161
+ publicKey,
162
+ source: "privateKey"
163
+ };
164
+ }
165
+
166
+ // src/lib/wallet/local.ts
167
+ var isWindows = process.platform === "win32";
168
+ function createLocalProvider(deps) {
169
+ return {
170
+ id: "local",
171
+ async describe() {
172
+ const cred = resolveCredentialOrThrow(await loadCredential(deps));
173
+ return {
174
+ // A stored address is only a claim; accountForCredential derives from the
175
+ // key and rejects a record whose address does not match, so show/balance
176
+ // can never display an address the key would not sign as.
177
+ address: accountForCredential(cred).address,
178
+ provider: "local",
179
+ credentialSource: cred.source,
180
+ policyEnforcement: "client-only"
181
+ };
182
+ },
183
+ async getSigner() {
184
+ const cred = resolveCredentialOrThrow(await loadCredential(deps));
185
+ const account = accountForCredential(cred);
186
+ return {
187
+ address: account.address,
188
+ signMessage: (args) => account.signMessage({ message: args.message }),
189
+ signTypedData: (args) => account.signTypedData(args)
190
+ };
191
+ },
192
+ diagnostics() {
193
+ return localWalletDiagnostics(deps);
194
+ }
195
+ };
196
+ }
197
+ async function localWalletDiagnostics(deps) {
198
+ const mode = await walletFileMode(deps.dir);
199
+ const fileExists = mode !== null;
200
+ const envKey = deps.env.TENJIN_WALLET_KEY;
201
+ const envSet = envKey !== void 0 && envKey.length > 0;
202
+ const path = walletPath(deps.dir);
203
+ const warnings = [];
204
+ if (envSet && fileExists) {
205
+ warnings.push("TENJIN_WALLET_KEY is set and shadows the wallet file at runtime.");
206
+ }
207
+ if (mode !== null) {
208
+ if (isWindows) {
209
+ warnings.push("File permission checks are not available on Windows.");
210
+ } else if (mode !== 384) {
211
+ warnings.push(
212
+ `Wallet file permissions are ${mode.toString(8)}, expected 600. Run \`chmod 600 ${path}\`.`
213
+ );
214
+ }
215
+ }
216
+ return { ...fileExists ? { walletPath: path } : {}, warnings };
217
+ }
218
+ async function createLocalWallet(dir) {
219
+ const key = generatePrivateKey();
220
+ const address = privateKeyToAccount(key).address;
221
+ await writeWalletRecord(dir, walletRecord(address, key));
222
+ return { address, walletPath: walletPath(dir) };
223
+ }
224
+ async function importLocalWallet(dir, key) {
225
+ if (!PRIVATE_KEY_RE.test(key)) {
226
+ throw new CliError("WALLET_INVALID_KEY", "The provided key is not a valid private key.", {
227
+ fix: "Provide a 0x-prefixed 32-byte hex private key."
228
+ });
229
+ }
230
+ let address;
231
+ try {
232
+ address = privateKeyToAccount(key).address;
233
+ } catch (err) {
234
+ throw new CliError("WALLET_INVALID_KEY", "The provided key is not a valid secp256k1 key.", {
235
+ fix: "Provide a 0x-prefixed 32-byte hex key within the curve order.",
236
+ cause: err
237
+ });
238
+ }
239
+ await writeWalletRecord(dir, walletRecord(address, key));
240
+ return { address, walletPath: walletPath(dir) };
241
+ }
242
+ async function loadCredential(deps) {
243
+ const envKey = deps.env.TENJIN_WALLET_KEY;
244
+ if (envKey !== void 0 && envKey.trim().length > 0) {
245
+ const key = envKey.trim();
246
+ if (!PRIVATE_KEY_RE.test(key)) {
247
+ throw new CliError("WALLET_INVALID_KEY", "TENJIN_WALLET_KEY is not a valid private key.", {
248
+ fix: "Set TENJIN_WALLET_KEY to a 0x-prefixed 32-byte hex key, or unset it to use the wallet file."
249
+ });
250
+ }
251
+ return { source: "env", key };
252
+ }
253
+ const record = await readWalletRecord(deps.dir);
254
+ if (record !== null) {
255
+ return { source: "file", key: record.privateKey, address: record.address };
256
+ }
257
+ return null;
258
+ }
259
+ function accountForCredential(cred) {
260
+ let account;
261
+ try {
262
+ account = privateKeyToAccount(cred.key);
263
+ } catch (err) {
264
+ throw new CliError("WALLET_INVALID_KEY", "The private key is not a valid secp256k1 key.", {
265
+ fix: cred.source === "file" ? "Move the wallet file aside, then re-import the intended key." : "Set TENJIN_WALLET_KEY to a valid 0x-prefixed 32-byte hex key.",
266
+ cause: err
267
+ });
268
+ }
269
+ if (cred.source === "file" && account.address.toLowerCase() !== cred.address.toLowerCase()) {
270
+ throw new CliError(
271
+ "WALLET_INVALID_KEY",
272
+ `The wallet file's stored address ${cred.address} does not match its private key (derives ${account.address}).`,
273
+ { fix: "Move the wallet file aside, then re-import the intended key." }
274
+ );
275
+ }
276
+ return account;
277
+ }
278
+ function resolveCredentialOrThrow(cred) {
279
+ if (cred === null) {
280
+ throw new CliError("WALLET_MISSING", "No wallet found.", {
281
+ fix: "Run `tenjin wallet create` to create one."
282
+ });
283
+ }
284
+ return cred;
285
+ }
286
+ function walletRecord(address, privateKey) {
287
+ return {
288
+ schemaVersion: 1,
289
+ provider: "local",
290
+ address,
291
+ privateKey,
292
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
293
+ };
294
+ }
295
+
296
+ // src/lib/wallet/index.ts
297
+ function resolveWalletProvider(ctx, opts = {}) {
298
+ if (opts.provider !== void 0) return opts.provider;
299
+ return createLocalProvider({ dir: ctx.dataDir, env: process.env });
300
+ }
301
+ async function describeWallet(provider) {
302
+ try {
303
+ return await provider.describe();
304
+ } catch (err) {
305
+ if (err instanceof CliError) throw err;
306
+ const message = err instanceof Error ? err.message : "unknown error";
307
+ throw new CliError("PROVIDER_ERROR", `Wallet provider "${provider.id}" failed: ${message}`, {
308
+ fix: "Check the wallet provider and try again.",
309
+ cause: err
310
+ });
311
+ }
312
+ }
313
+
314
+ export {
315
+ createLocalWallet,
316
+ importLocalWallet,
317
+ resolveWalletProvider,
318
+ describeWallet
319
+ };
320
+ //# sourceMappingURL=chunk-QHIEYBLV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/accounts/generatePrivateKey.ts","../node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/accounts/toAccount.ts","../node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/accounts/utils/sign.ts","../node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/accounts/utils/signAuthorization.ts","../node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/accounts/utils/signMessage.ts","../node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/accounts/utils/signTransaction.ts","../node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/accounts/utils/signTypedData.ts","../node_modules/.pnpm/viem@2.55.2_typescript@6.0.3_zod@4.4.3/node_modules/viem/accounts/privateKeyToAccount.ts","../src/lib/wallet/local.ts","../src/lib/wallet/index.ts"],"sourcesContent":["import { secp256k1 } from '@noble/curves/secp256k1'\n\nimport type { ErrorType } from '../errors/utils.js'\nimport type { Hex } from '../types/misc.js'\nimport { type ToHexErrorType, toHex } from '../utils/encoding/toHex.js'\n\nexport type GeneratePrivateKeyErrorType = ToHexErrorType | ErrorType\n\n/**\n * @description Generates a random private key.\n *\n * @returns A randomly generated private key.\n */\nexport function generatePrivateKey(): Hex {\n return toHex(secp256k1.utils.randomPrivateKey())\n}\n","// TODO(v3): Rename to `toLocalAccount` + add `source` property to define source (privateKey, mnemonic, hdKey, etc).\n\nimport type { Address } from 'abitype'\n\nimport {\n InvalidAddressError,\n type InvalidAddressErrorType,\n} from '../errors/address.js'\nimport type { ErrorType } from '../errors/utils.js'\nimport {\n type IsAddressErrorType,\n isAddress,\n} from '../utils/address/isAddress.js'\nimport type {\n AccountSource,\n CustomSource,\n JsonRpcAccount,\n LocalAccount,\n} from './types.js'\n\ntype GetAccountReturnType<accountSource extends AccountSource> =\n | (accountSource extends Address ? JsonRpcAccount : never)\n | (accountSource extends CustomSource ? LocalAccount : never)\n\nexport type ToAccountErrorType =\n | InvalidAddressErrorType\n | IsAddressErrorType\n | ErrorType\n\n/**\n * @description Creates an Account from a custom signing implementation.\n *\n * @returns A Local Account.\n */\nexport function toAccount<accountSource extends AccountSource>(\n source: accountSource,\n): GetAccountReturnType<accountSource> {\n if (typeof source === 'string') {\n if (!isAddress(source, { strict: false }))\n throw new InvalidAddressError({ address: source })\n return {\n address: source,\n type: 'json-rpc',\n } as GetAccountReturnType<accountSource>\n }\n\n if (!isAddress(source.address, { strict: false }))\n throw new InvalidAddressError({ address: source.address })\n return {\n address: source.address,\n nonceManager: source.nonceManager,\n sign: source.sign,\n signAuthorization: source.signAuthorization,\n signMessage: source.signMessage,\n signTransaction: source.signTransaction,\n signTypedData: source.signTypedData,\n source: 'custom',\n type: 'local',\n } as GetAccountReturnType<accountSource>\n}\n","// TODO(v3): Convert to sync.\n\nimport { secp256k1 } from '@noble/curves/secp256k1'\n\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { ByteArray, Hex, Signature } from '../../types/misc.js'\nimport { type IsHexErrorType, isHex } from '../../utils/data/isHex.js'\nimport {\n type HexToBytesErrorType,\n hexToBytes,\n} from '../../utils/encoding/toBytes.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\nimport { serializeSignature } from '../../utils/signature/serializeSignature.js'\n\ntype To = 'object' | 'bytes' | 'hex'\n\nexport type SignParameters<to extends To = 'object'> = {\n hash: Hex\n privateKey: Hex\n to?: to | To | undefined\n}\n\nexport type SignReturnType<to extends To = 'object'> =\n | (to extends 'object' ? Signature : never)\n | (to extends 'bytes' ? ByteArray : never)\n | (to extends 'hex' ? Hex : never)\n\nexport type SignErrorType =\n | HexToBytesErrorType\n | IsHexErrorType\n | NumberToHexErrorType\n | ErrorType\n\nlet extraEntropy: Hex | boolean = false\n\n/**\n * Sets extra entropy for signing functions.\n */\nexport function setSignEntropy(entropy: true | Hex) {\n if (!entropy) throw new Error('must be a `true` or a hex value.')\n extraEntropy = entropy\n}\n\n/**\n * @description Signs a hash with a given private key.\n *\n * @param hash The hash to sign.\n * @param privateKey The private key to sign with.\n *\n * @returns The signature.\n */\nexport async function sign<to extends To = 'object'>({\n hash,\n privateKey,\n to = 'object',\n}: SignParameters<to>): Promise<SignReturnType<to>> {\n const { r, s, recovery } = secp256k1.sign(\n hash.slice(2),\n privateKey.slice(2),\n {\n lowS: true,\n extraEntropy: isHex(extraEntropy, { strict: false })\n ? hexToBytes(extraEntropy)\n : extraEntropy,\n },\n )\n const signature = {\n r: numberToHex(r, { size: 32 }),\n s: numberToHex(s, { size: 32 }),\n v: recovery ? 28n : 27n,\n yParity: recovery,\n }\n return (() => {\n if (to === 'bytes' || to === 'hex')\n return serializeSignature({ ...signature, to })\n return signature\n })() as SignReturnType<to>\n}\n","import type { ErrorType } from '../../errors/utils.js'\nimport type {\n AuthorizationRequest,\n SignedAuthorization,\n} from '../../types/authorization.js'\nimport type { Hex, Signature } from '../../types/misc.js'\nimport type { Prettify } from '../../types/utils.js'\nimport {\n type HashAuthorizationErrorType,\n hashAuthorization,\n} from '../../utils/authorization/hashAuthorization.js'\nimport {\n type SignErrorType,\n type SignParameters,\n type SignReturnType,\n sign,\n} from './sign.js'\n\ntype To = 'object' | 'bytes' | 'hex'\n\nexport type SignAuthorizationParameters<to extends To = 'object'> =\n AuthorizationRequest & {\n /** The private key to sign with. */\n privateKey: Hex\n to?: SignParameters<to>['to'] | undefined\n }\n\nexport type SignAuthorizationReturnType<to extends To = 'object'> = Prettify<\n to extends 'object' ? SignedAuthorization : SignReturnType<to>\n>\n\nexport type SignAuthorizationErrorType =\n | SignErrorType\n | HashAuthorizationErrorType\n | ErrorType\n\n/**\n * Signs an Authorization hash in [EIP-7702 format](https://eips.ethereum.org/EIPS/eip-7702): `keccak256('0x05' || rlp([chain_id, address, nonce]))`.\n */\nexport async function signAuthorization<to extends To = 'object'>(\n parameters: SignAuthorizationParameters<to>,\n): Promise<SignAuthorizationReturnType<to>> {\n const { chainId, nonce, privateKey, to = 'object' } = parameters\n const address = parameters.contractAddress ?? parameters.address\n const signature = await sign({\n hash: hashAuthorization({ address, chainId, nonce }),\n privateKey,\n to,\n })\n if (to === 'object')\n return {\n address,\n chainId,\n nonce,\n ...(signature as Signature),\n } as any\n return signature as any\n}\n","import type { ErrorType } from '../../errors/utils.js'\nimport type { Hex, SignableMessage } from '../../types/misc.js'\nimport {\n type HashMessageErrorType,\n hashMessage,\n} from '../../utils/signature/hashMessage.js'\n\nimport { type SignErrorType, sign } from './sign.js'\n\nexport type SignMessageParameters = {\n /** The message to sign. */\n message: SignableMessage\n /** The private key to sign with. */\n privateKey: Hex\n}\n\nexport type SignMessageReturnType = Hex\n\nexport type SignMessageErrorType =\n | SignErrorType\n | HashMessageErrorType\n | ErrorType\n\n/**\n * @description Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191):\n * `keccak256(\"\\x19Ethereum Signed Message:\\n\" + len(message) + message))`.\n *\n * @returns The signature.\n */\nexport async function signMessage({\n message,\n privateKey,\n}: SignMessageParameters): Promise<SignMessageReturnType> {\n return await sign({ hash: hashMessage(message), privateKey, to: 'hex' })\n}\n","import type { ErrorType } from '../../errors/utils.js'\nimport type { Hex } from '../../types/misc.js'\nimport type {\n TransactionSerializable,\n TransactionSerialized,\n} from '../../types/transaction.js'\nimport {\n type Keccak256ErrorType,\n keccak256,\n} from '../../utils/hash/keccak256.js'\nimport type { GetTransactionType } from '../../utils/transaction/getTransactionType.js'\nimport {\n type SerializeTransactionFn,\n serializeTransaction,\n} from '../../utils/transaction/serializeTransaction.js'\n\nimport { type SignErrorType, sign } from './sign.js'\n\nexport type SignTransactionParameters<\n serializer extends\n SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>,\n transaction extends Parameters<serializer>[0] = Parameters<serializer>[0],\n> = {\n privateKey: Hex\n transaction: transaction\n serializer?: serializer | undefined\n}\n\nexport type SignTransactionReturnType<\n serializer extends\n SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>,\n transaction extends Parameters<serializer>[0] = Parameters<serializer>[0],\n> = TransactionSerialized<GetTransactionType<transaction>>\n\nexport type SignTransactionErrorType =\n | Keccak256ErrorType\n | SignErrorType\n | ErrorType\n\nexport async function signTransaction<\n serializer extends\n SerializeTransactionFn<TransactionSerializable> = SerializeTransactionFn<TransactionSerializable>,\n transaction extends Parameters<serializer>[0] = Parameters<serializer>[0],\n>(\n parameters: SignTransactionParameters<serializer, transaction>,\n): Promise<SignTransactionReturnType<serializer, transaction>> {\n const {\n privateKey,\n transaction,\n serializer = serializeTransaction,\n } = parameters\n\n const signableTransaction = (() => {\n // For EIP-4844 Transactions, we want to sign the transaction payload body (tx_payload_body) without the sidecars (ie. without the network wrapper).\n // See: https://github.com/ethereum/EIPs/blob/e00f4daa66bd56e2dbd5f1d36d09fd613811a48b/EIPS/eip-4844.md#networking\n if (transaction.type === 'eip4844')\n return {\n ...transaction,\n sidecars: false,\n }\n return transaction\n })()\n\n const signature = await sign({\n hash: keccak256(await serializer(signableTransaction)),\n privateKey,\n })\n return (await serializer(\n transaction,\n signature,\n )) as SignTransactionReturnType<serializer, transaction>\n}\n","import type { TypedData } from 'abitype'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { TypedDataDefinition } from '../../types/typedData.js'\nimport {\n type HashTypedDataErrorType,\n hashTypedData,\n} from '../../utils/signature/hashTypedData.js'\nimport { type SignErrorType, sign } from './sign.js'\n\nexport type SignTypedDataParameters<\n typedData extends TypedData | Record<string, unknown> = TypedData,\n primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,\n> = TypedDataDefinition<typedData, primaryType> & {\n /** The private key to sign with. */\n privateKey: Hex\n}\n\nexport type SignTypedDataReturnType = Hex\n\nexport type SignTypedDataErrorType =\n | HashTypedDataErrorType\n | SignErrorType\n | ErrorType\n\n/**\n * @description Signs typed data and calculates an Ethereum-specific signature in [https://eips.ethereum.org/EIPS/eip-712](https://eips.ethereum.org/EIPS/eip-712):\n * `sign(keccak256(\"\\x19\\x01\" ‖ domainSeparator ‖ hashStruct(message)))`.\n *\n * @returns The signature.\n */\nexport async function signTypedData<\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n>(\n parameters: SignTypedDataParameters<typedData, primaryType>,\n): Promise<SignTypedDataReturnType> {\n const { privateKey, ...typedData } =\n parameters as unknown as SignTypedDataParameters\n return await sign({\n hash: hashTypedData(typedData),\n privateKey,\n to: 'hex',\n })\n}\n","import { secp256k1 } from '@noble/curves/secp256k1'\nimport type { ErrorType } from '../errors/utils.js'\nimport type { Hex } from '../types/misc.js'\nimport { type ToHexErrorType, toHex } from '../utils/encoding/toHex.js'\nimport type { NonceManager } from '../utils/nonceManager.js'\nimport { type ToAccountErrorType, toAccount } from './toAccount.js'\nimport type { PrivateKeyAccount } from './types.js'\nimport {\n type PublicKeyToAddressErrorType,\n publicKeyToAddress,\n} from './utils/publicKeyToAddress.js'\nimport { type SignErrorType, sign } from './utils/sign.js'\nimport { signAuthorization } from './utils/signAuthorization.js'\nimport { type SignMessageErrorType, signMessage } from './utils/signMessage.js'\nimport {\n type SignTransactionErrorType,\n signTransaction,\n} from './utils/signTransaction.js'\nimport {\n type SignTypedDataErrorType,\n signTypedData,\n} from './utils/signTypedData.js'\n\nexport type PrivateKeyToAccountOptions = {\n nonceManager?: NonceManager | undefined\n}\n\nexport type PrivateKeyToAccountErrorType =\n | ToAccountErrorType\n | ToHexErrorType\n | PublicKeyToAddressErrorType\n | SignErrorType\n | SignMessageErrorType\n | SignTransactionErrorType\n | SignTypedDataErrorType\n | ErrorType\n\n/**\n * @description Creates an Account from a private key.\n *\n * @returns A Private Key Account.\n */\nexport function privateKeyToAccount(\n privateKey: Hex,\n options: PrivateKeyToAccountOptions = {},\n): PrivateKeyAccount {\n const { nonceManager } = options\n const publicKey = toHex(secp256k1.getPublicKey(privateKey.slice(2), false))\n const address = publicKeyToAddress(publicKey)\n\n const account = toAccount({\n address,\n nonceManager,\n async sign({ hash }) {\n return sign({ hash, privateKey, to: 'hex' })\n },\n async signAuthorization(authorization) {\n return signAuthorization({ ...authorization, privateKey })\n },\n async signMessage({ message }) {\n return signMessage({ message, privateKey })\n },\n async signTransaction(transaction, { serializer } = {}) {\n return signTransaction({ privateKey, transaction, serializer })\n },\n async signTypedData(typedData) {\n return signTypedData({ ...typedData, privateKey } as any)\n },\n })\n\n return {\n ...account,\n publicKey,\n source: 'privateKey',\n } as PrivateKeyAccount\n}\n","import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';\nimport type { PrivateKeyAccount } from 'viem/accounts';\nimport type { Address, Hex } from 'viem';\nimport { CliError } from '../errors';\nimport { walletPath } from '../paths';\nimport {\n PRIVATE_KEY_RE,\n readWalletRecord,\n walletFileMode,\n writeWalletRecord,\n type WalletRecord,\n} from './store';\nimport type {\n TenjinSigner,\n WalletDescription,\n WalletDiagnostics,\n WalletProvider,\n} from './provider';\n\nexport interface LocalProviderDeps {\n dir: string;\n env: NodeJS.ProcessEnv;\n}\n\nconst isWindows = process.platform === 'win32';\n\n/**\n * The only real B1 provider: a local viem account whose key comes from the env\n * override or the wallet file. Together with the lifecycle helpers below, this is\n * the ONLY module that knows raw keys exist — `describe()` returns just the\n * address and posture, so `show`/`balance` stay keyless; `getSigner()` is the\n * single door to the key material.\n */\nexport function createLocalProvider(deps: LocalProviderDeps): WalletProvider {\n return {\n id: 'local',\n async describe(): Promise<WalletDescription> {\n const cred = resolveCredentialOrThrow(await loadCredential(deps));\n return {\n // A stored address is only a claim; accountForCredential derives from the\n // key and rejects a record whose address does not match, so show/balance\n // can never display an address the key would not sign as.\n address: accountForCredential(cred).address,\n provider: 'local',\n credentialSource: cred.source,\n policyEnforcement: 'client-only',\n };\n },\n async getSigner(): Promise<TenjinSigner> {\n const cred = resolveCredentialOrThrow(await loadCredential(deps));\n const account = accountForCredential(cred);\n return {\n address: account.address,\n signMessage: (args) => account.signMessage({ message: args.message }),\n signTypedData: (args) => account.signTypedData(args),\n };\n },\n diagnostics(): Promise<WalletDiagnostics> {\n return localWalletDiagnostics(deps);\n },\n };\n}\n\n/**\n * File-custody warnings for the local provider: an env key shadowing the file,\n * non-0600 perms, and the Windows \"perms not checkable\" note. Keyless. walletPath\n * is reported only when the file actually exists, so a pure-env caller advertises\n * no on-disk path. This is the ONLY place these local-only signals live — `show`\n * and `doctor` render what the active provider returns, never their own fs probe.\n */\nexport async function localWalletDiagnostics(deps: LocalProviderDeps): Promise<WalletDiagnostics> {\n const mode = await walletFileMode(deps.dir);\n const fileExists = mode !== null;\n const envKey = deps.env.TENJIN_WALLET_KEY;\n const envSet = envKey !== undefined && envKey.length > 0;\n const path = walletPath(deps.dir);\n\n const warnings: string[] = [];\n if (envSet && fileExists) {\n warnings.push('TENJIN_WALLET_KEY is set and shadows the wallet file at runtime.');\n }\n if (mode !== null) {\n if (isWindows) {\n warnings.push('File permission checks are not available on Windows.');\n } else if (mode !== 0o600) {\n warnings.push(\n `Wallet file permissions are ${mode.toString(8)}, expected 600. Run \\`chmod 600 ${path}\\`.`,\n );\n }\n }\n return { ...(fileExists ? { walletPath: path } : {}), warnings };\n}\n\nexport interface LocalWalletInfo {\n address: Address;\n walletPath: string;\n}\n\n/**\n * Generate a fresh key and persist it NO-CLOBBER, returning the address and path.\n * The write, not a caller's pre-check, is the authority: a lost create/import\n * race throws WALLET_EXISTS rather than overwriting a funded key.\n */\nexport async function createLocalWallet(dir: string): Promise<LocalWalletInfo> {\n const key = generatePrivateKey();\n const address = privateKeyToAccount(key).address;\n await writeWalletRecord(dir, walletRecord(address, key));\n return { address, walletPath: walletPath(dir) };\n}\n\n/**\n * Validate an imported key and persist it NO-CLOBBER. WALLET_INVALID_KEY for a\n * bad format or an out-of-range scalar; WALLET_EXISTS if a wallet already exists.\n */\nexport async function importLocalWallet(dir: string, key: string): Promise<LocalWalletInfo> {\n if (!PRIVATE_KEY_RE.test(key)) {\n throw new CliError('WALLET_INVALID_KEY', 'The provided key is not a valid private key.', {\n fix: 'Provide a 0x-prefixed 32-byte hex private key.',\n });\n }\n let address: Address;\n try {\n address = privateKeyToAccount(key as Hex).address;\n } catch (err) {\n throw new CliError('WALLET_INVALID_KEY', 'The provided key is not a valid secp256k1 key.', {\n fix: 'Provide a 0x-prefixed 32-byte hex key within the curve order.',\n cause: err,\n });\n }\n await writeWalletRecord(dir, walletRecord(address, key as Hex));\n return { address, walletPath: walletPath(dir) };\n}\n\ntype Credential = { source: 'env'; key: Hex } | { source: 'file'; key: Hex; address: Address };\n\n/** Env override beats the wallet file (CI + ephemeral agents); null when neither exists. */\nasync function loadCredential(deps: LocalProviderDeps): Promise<Credential | null> {\n const envKey = deps.env.TENJIN_WALLET_KEY;\n if (envKey !== undefined && envKey.trim().length > 0) {\n const key = envKey.trim();\n if (!PRIVATE_KEY_RE.test(key)) {\n throw new CliError('WALLET_INVALID_KEY', 'TENJIN_WALLET_KEY is not a valid private key.', {\n fix: 'Set TENJIN_WALLET_KEY to a 0x-prefixed 32-byte hex key, or unset it to use the wallet file.',\n });\n }\n return { source: 'env', key: key as Hex };\n }\n const record = await readWalletRecord(deps.dir);\n if (record !== null) {\n return { source: 'file', key: record.privateKey as Hex, address: record.address as Address };\n }\n return null;\n}\n\n/**\n * Build the viem account from a credential, mapping viem's throw on an invalid\n * key to WALLET_INVALID_KEY. For a FILE credential, also require the stored\n * address to match what the key derives (EIP-55 normalized): a stale or tampered\n * record that would show address A but sign as B is rejected, not trusted.\n */\nfunction accountForCredential(cred: Credential): PrivateKeyAccount {\n let account: PrivateKeyAccount;\n try {\n account = privateKeyToAccount(cred.key);\n } catch (err) {\n throw new CliError('WALLET_INVALID_KEY', 'The private key is not a valid secp256k1 key.', {\n fix:\n cred.source === 'file'\n ? 'Move the wallet file aside, then re-import the intended key.'\n : 'Set TENJIN_WALLET_KEY to a valid 0x-prefixed 32-byte hex key.',\n cause: err,\n });\n }\n if (cred.source === 'file' && account.address.toLowerCase() !== cred.address.toLowerCase()) {\n throw new CliError(\n 'WALLET_INVALID_KEY',\n `The wallet file's stored address ${cred.address} does not match its private key (derives ${account.address}).`,\n { fix: 'Move the wallet file aside, then re-import the intended key.' },\n );\n }\n return account;\n}\n\nfunction resolveCredentialOrThrow(cred: Credential | null): Credential {\n if (cred === null) {\n throw new CliError('WALLET_MISSING', 'No wallet found.', {\n fix: 'Run `tenjin wallet create` to create one.',\n });\n }\n return cred;\n}\n\nfunction walletRecord(address: Address, privateKey: Hex): WalletRecord {\n return {\n schemaVersion: 1,\n provider: 'local',\n address,\n privateKey,\n createdAt: new Date().toISOString(),\n };\n}\n","import { CliError } from '../errors';\nimport { createLocalProvider } from './local';\nimport type { CommandContext } from '../../context';\nimport type { WalletDescription, WalletProvider } from './provider';\n\nexport * from './provider';\nexport { createLocalWallet, importLocalWallet, type LocalWalletInfo } from './local';\n\nexport interface ResolveWalletProviderOptions {\n /** Test-injection seam: bypass the local provider with a fake (e.g. a remote stub). */\n provider?: WalletProvider;\n}\n\n/**\n * The commands' one entry to a wallet. Production always gets the `local`\n * provider bound to the context's data dir and process env; tests pass\n * `opts.provider` to prove `show`/`balance` work against any provider without a\n * real key on disk.\n */\nexport function resolveWalletProvider(\n ctx: CommandContext,\n opts: ResolveWalletProviderOptions = {},\n): WalletProvider {\n if (opts.provider !== undefined) return opts.provider;\n return createLocalProvider({ dir: ctx.dataDir, env: process.env });\n}\n\n/**\n * Call `describe()` through the error contract: a CliError (e.g. WALLET_MISSING\n * from the local provider) passes through, but any other rejection — a remote\n * provider's network/refusal error — normalizes to PROVIDER_ERROR so callers\n * always see a coded failure, never a bare stack trace.\n */\nexport async function describeWallet(provider: WalletProvider): Promise<WalletDescription> {\n try {\n return await provider.describe();\n } catch (err) {\n if (err instanceof CliError) throw err;\n const message = err instanceof Error ? err.message : 'unknown error';\n throw new CliError('PROVIDER_ERROR', `Wallet provider \"${provider.id}\" failed: ${message}`, {\n fix: 'Check the wallet provider and try again.',\n cause: err,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaM,SAAU,qBAAkB;AAChC,SAAO,MAAM,UAAU,MAAM,iBAAgB,C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